import type { Meta, StoryObj } from '@storybook/html'; import { TreeView, type TreeViewOptions } from './TreeView'; import './treeview.css'; // `storybook-readme` (installed for this repo) targets Storybook 5 and is // incompatible with this Storybook 8 setup, so the README is surfaced through // SB8's native docs mechanism: imported as raw Markdown and shown on the Docs // page via `parameters.docs.description.component`. See the Accordion stories. import readme from './README.md?raw'; /** * Storybook stories for the TreeView component. * * The library is framework-agnostic vanilla TS, so each story's `render` builds * real nested-list DOM, then enhances it with `new TreeView(...)` — exactly how * a consumer would use it. The `@storybook/addon-a11y` panel runs axe-core * against the rendered output so regressions in the ARIA wiring surface here. */ interface Node { label: string; /** Start this parent expanded (maps to `data-expanded` on the item). */ open?: boolean; /** Start this node selected (maps to `data-selected` on the item). */ selected?: boolean; children?: readonly Node[]; } const SAMPLE_TREE: readonly Node[] = [ { label: 'README.md' }, { label: 'src', open: true, children: [ { label: 'index.ts', selected: true }, { label: 'components', open: true, children: [{ label: 'Accordion.ts' }, { label: 'TreeView.ts' }], }, ], }, { label: 'docs', children: [{ label: 'getting-started.md' }, { label: 'accessibility.md' }], }, ]; /** Recursively build the `
  • `/`