import type { Meta, StoryObj } from 'storybook-solidjs-vite'; import { createSignal } from 'solid-js'; import { FileTree, type FileTreeFile } from './file-tree'; import { componentDescription } from '../stories/docs/element-controls'; const FILES: FileTreeFile[] = [ { path: 'index.html', type: 'html' }, { path: 'about.html', type: 'html' }, { path: 'css/site.css', type: 'other', language: 'css' }, { path: 'src/app.ts', type: 'other', language: 'ts' }, { path: 'src/lib/format.ts', type: 'other', language: 'ts' }, { path: 'src/lib/parse.ts', type: 'other', language: 'ts' }, { path: 'assets/logo.svg', type: 'image' }, { path: 'assets/report.pdf', type: 'pdf' }, ]; const meta = { title: 'Solid (Advanced)/Elements/FileTree', component: FileTree, tags: ['autodocs'], parameters: { layout: 'padded', docs: { description: componentDescription([ 'A collapsible, keyboard-navigable file explorer built from a flat list of `/`-delimited paths — nested folders are derived automatically. ARIA `tree`/`treeitem`.', '**When to use:** any file/folder tree — the Code tab of `Artifact` uses it, and it is exported for standalone reuse (project explorers, attachment browsers, doc outlines).', '**How to use:** pass `files` (`{ path, url?, code?, language?, type? }[]`); folders come from `/` in each path and `type` picks the icon. Control highlight via `activeFile`, initial open folders via `defaultExpanded`, and handle `onSelect(path, file)`. Arrow keys navigate; Enter/Space selects or toggles.', '**Placement:** a sidebar/explorer column.', ]), }, }, argTypes: { files: { control: false }, activeFile: { control: 'text' }, }, args: { files: FILES, activeFile: 'src/app.ts' }, render: (args) => (
), } satisfies Meta{active()}