import { defineWebComponent } from './define'; import { FileTree, type FileTreeFile } from '../components/file-tree'; interface Props extends Record { /** The files to render. Set as a JS property (array of `{ path, url?, code?, language?, type? }`). */ files: FileTreeFile[]; /** Selected file path — highlighted in the tree. */ activeFile?: string; /** Folder paths expanded initially. Omit to start with all folders open. */ defaultExpanded?: string[]; } interface Events extends Record { /** Fired when a file is selected. `detail.path` = the file's path. */ 'kc-select': { path: string }; } /** * `` — a collapsible, keyboard-navigable file explorer built from a * flat list of `/`-delimited paths (folders are derived). ARIA `tree`/`treeitem`. * Selecting a file fires a `select` event (`detail.path`). Fills its container. */ defineWebComponent('kc-file-tree', { files: [], activeFile: undefined, defaultExpanded: undefined, }, (props, { dispatch }) => ( <> {/* Fill the container + own the scroll (see resizable.tsx fill technique: a definite `1fr` grid cell scoped to a wrapper, NOT :host, so the facade's sibling portal-mount div can't steal a grid track). */}
dispatch('kc-select', { path })} />
));