// // Copyright 2026 DXOS.org // import '../theme/index.css'; import { type Meta, type StoryObj } from '@storybook/react-vite'; import React, { type ComponentPropsWithoutRef, type PropsWithChildren, forwardRef, useState } from 'react'; import { expect, userEvent, waitFor, within } from 'storybook/test'; import { translations } from '#translations'; import { Button } from '../components/Button/Button.tsx'; import { Container } from '../components/Container/Container.tsx'; import { Empty } from '../components/Empty/Empty.tsx'; import * as ListboxModule from '../components/Listbox/Listbox.tsx'; import * as Panel from '../components/Panel/Panel.tsx'; import * as ScrollArea from '../components/ScrollArea/ScrollArea.tsx'; import * as Splitter from '../components/Splitter/Splitter.tsx'; import * as TabsModule from '../components/Tabs/Tabs.tsx'; import * as Toolbar from '../components/Toolbar/Toolbar.tsx'; import * as Typography from '../components/Typography/Typography.tsx'; import { withLayout, withTheme } from '../testing/index.ts'; // Master-detail is not a component: the list's own Root owns the selection, and a Splitter with `collapseBelow` lays // out the list and the detail, showing one at a time when the host is narrow. type StoryArgs = { /** Host width in rem; under `collapseBelow` the splitter shows one pane at a time. */ width: number; /** The list pane's width in rem. */ size: number; collapseBelow: string; resizable: boolean; }; type Project = ListboxModule.Option & { owner: string; status: string; updated: string }; const OWNERS = ['Alice Green', 'Bob Grey', 'Carol Black', 'Erin White']; const STATUSES = ['Active', 'Paused', 'Done']; const ICONS = ['ph--rocket--regular', 'ph--flask--regular', 'ph--book--regular', 'ph--globe--regular']; const NAMES = [ 'Apollo', 'Borealis', 'Cassini', 'Dawn', 'Europa', 'Fermi', 'Gemini', 'Hubble', 'Ion', 'Juno', 'Kepler', 'Lunar', ]; const PROJECTS: Project[] = NAMES.map((name, index) => ({ value: name.toLowerCase(), label: name, icon: ICONS[index % ICONS.length], description: `${STATUSES[index % STATUSES.length]} ยท ${OWNERS[index % OWNERS.length]}`, owner: OWNERS[index % OWNERS.length], status: STATUSES[index % STATUSES.length], updated: `2026-0${(index % 9) + 1}-1${index % 10}`, })); const projectOf = (value?: string) => PROJECTS.find((project) => project.value === value); const tasksOf = (project: Project): ListboxModule.Option[] => ['Plan', 'Build', 'Review', 'Ship'].map((step) => ({ value: `${project.value}-${step.toLowerCase()}`, label: `${step} ${project.label}`, icon: 'ph--check-square--regular', description: project.owner, })); /** The story's host, sized by the `width` arg so the collapse can be seen (and set by the play). */ const Host = ({ width, children }: PropsWithChildren>) => (
{children}
); /** Returns the collapsed splitter to its list; renders nothing while both panes show. */ const BackButton = ({ testId = 'back' }: { testId?: string }) => { const { collapsed, setMode } = Splitter.useContext(); return collapsed ? (