import type { Meta, StoryObj } from 'storybook-solidjs-vite'; import { createSignal } from 'solid-js'; import { TasksCard, type TasksCardData } from './tasks-card'; import { componentDescription } from '../stories/docs/element-controls'; import type { CardEvent, CardHost, CardContext } from '../primitives/card-contract'; const ctx: CardContext = { theme: { mode: 'light' }, locale: 'en' }; /** Renders the Solid with a capturing `host`, logging emitted events. */ function Demo(props: { def: TasksCardData; heading?: string; cardId: string }) { const [log, setLog] = createSignal([]); const host: CardHost = { context: () => ctx, emit: (e) => setLog((p) => [...p, e]) }; return (
        {log().length === 0 ? '// emitted CardEvents appear here' : JSON.stringify(log(), null, 2)}
      
); } const PLAN: TasksCardData = { selectAll: true, confirmLabel: 'Run selected', tasks: [ { id: 'lint', label: 'Run linter', checked: true }, { id: 'test', label: 'Run unit tests', checked: true }, { id: 'build', label: 'Build production bundle' }, { id: 'deploy', label: 'Deploy to staging', description: 'Reversible; staging only' }, ], }; const BOUNDED: TasksCardData = { confirmLabel: 'Request review', min: 1, max: 2, tasks: [ { id: 'ana', label: 'Ana' }, { id: 'ben', label: 'Ben' }, { id: 'cat', label: 'Cat' }, ], }; const meta = { title: 'Solid (Advanced)/Elements/TasksCard', component: TasksCard, tags: ['autodocs'], parameters: { layout: 'padded', docs: { description: componentDescription([ 'The SolidJS layer behind ``. Pass a `host` (a `CardHost`) to receive the emitted `CardEvent`s directly (the native-host path), or wrap in a `CardProvider`. Toggling rows is local; only confirm emits `submit` with `{ selected }` in input order.', ]), }, }, } satisfies Meta; export default meta; type Story = StoryObj; export const SelectAPlan: Story = { render: () => , }; export const Bounded: Story = { render: () => , };