import { Component, createSignal, Show } from "solid-js"; import { loadFromUserFolder, switchToBuiltInSource, getActiveSource, clearIndex, } from "../data-loader/file-index"; export interface DataSourceDialogProps { isOpen: boolean; onClose: () => void; onSourceChanged: () => void; } /** * Dialog for choosing how to source content files. * Supports: * - Built-in content (CLI / webpack bundled files) * - Local folder (via File System Access API) */ export const DataSourceDialog: Component = (props) => { const [loading, setLoading] = createSignal(false); const [error, setError] = createSignal(null); const [folderPath, setFolderPath] = createSignal(null); const currentSource = () => getActiveSource(); const handleFolderPick = async () => { setLoading(true); setError(null); const paths = await loadFromUserFolder(); if (paths === null) { // User cancelled or API not supported — don't show error for cancellation setLoading(false); return; } if (paths.length === 0) { setError( "No supported files (.md, .yarn, .csv) found in the selected folder.", ); setLoading(false); return; } setFolderPath(`${paths.length} files loaded`); setLoading(false); props.onSourceChanged(); props.onClose(); }; const handleBuiltIn = async () => { setLoading(true); setError(null); await switchToBuiltInSource(); // Force re-index from built-in sources clearIndex(); setLoading(false); props.onSourceChanged(); props.onClose(); }; return (
e.stopPropagation()} >

Content Source

{/* Built-in option */} {/* Folder picker option */}
{error()}
); }; export default DataSourceDialog;