// // Copyright 2026 DXOS.org // import '../../theme/index.css'; import { type Meta, type StoryObj } from '@storybook/react-vite'; import React, { useState } from 'react'; import { expect, userEvent, waitFor, within } from 'storybook/test'; import { translations } from '#translations'; import { SIZES } from '../../sizes.ts'; import { GEOMETRY, byTestId, expectScoped, sizeRow } from '../../testing/geometry.ts'; import { withLayout, withTheme } from '../../testing/index.ts'; import { SIZE_ARG_TYPES, type SizeArgs, withSizes } from '../../testing/stories.tsx'; import { Button } from '../Button/Button.tsx'; import { Checkbox } from '../Checkbox/Checkbox.tsx'; import { Container } from '../Container/Container.tsx'; import * as Panel from '../Panel/Panel.tsx'; import * as ScrollArea from '../ScrollArea/ScrollArea.tsx'; import * as SystemButton from '../SystemButton/SystemButton.tsx'; import * as Typography from '../Typography/Typography.tsx'; import * as Listbox from './Listbox.tsx'; const PEOPLE: Listbox.Option[] = [ { value: 'alice', label: 'Alice Green', icon: 'ph--user--regular' }, { value: 'bob', label: 'Bob Grey', icon: 'ph--user--regular', description: 'Away until Monday' }, { value: 'carol', label: 'Carol Black', icon: 'ph--user--regular' }, { value: 'dan', label: 'Dan Brown', icon: 'ph--user--regular', disabled: true }, { value: 'erin', label: 'Erin White', icon: 'ph--user--regular' }, ]; const TAGS: Listbox.Option[] = [ { value: 'urgent', label: 'Urgent' }, { value: 'later', label: 'Later' }, { value: 'idea', label: 'Idea' }, ]; const LONG: Listbox.Option[] = Array.from({ length: 40 }, (_, index) => ({ value: `item-${index + 1}`, label: `Item ${index + 1}`, })); const TASKS: Listbox.Option[] = [ { value: 'report', label: 'Write report' }, { value: 'review', label: 'Review budget' }, ]; const MANY: Listbox.Option[] = Array.from({ length: 1_000 }, (_, index) => ({ value: `row-${index + 1}`, label: `Row ${index + 1}`, })); const FILES: Listbox.Option[] = [ { value: 'a', label: 'Annual plan', icon: 'ph--file--regular', description: '12 KB' }, { value: 'b', label: 'Budget', icon: 'ph--table--regular', description: '1.4 MB' }, ]; const NONE: Listbox.Option[] = []; const RECENT: Listbox.Option[] = [ { value: 'notes', label: 'Notes', icon: 'ph--file--regular' }, { value: 'tasks', label: 'Tasks', icon: 'ph--file--regular' }, ]; /** * A single-selection list whose rows are composed from parts (icon, text, description, a trailing action and the * selection indicator), except Alice's default row; a grouped multiple-selection list; a long list that scrolls in a * fixed-height host; a list with no selection and a current row; rows with controls (the grid keyboard); a windowed * 1,000-row list; rows sharing Root `columns`; and an empty list. */ const DefaultStory = ({ size = 'md' }: SizeArgs) => { const [person, setPerson] = useState(['alice']); const [tags, setTags] = useState([]); const [tasks, setTasks] = useState(TASKS); return ( <> People {PEOPLE.map((item) => ( {item.value === 'alice' ? undefined : ( <> {item.description && } {item.value === 'carol' && (