// // 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 { byTestId, expectAnchoredBelow, expectPopupSize } 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 { Group } from '../Group/Group.tsx'; import * as Typography from '../Typography/Typography.tsx'; import { MenuButton, type MenuButtonItem } from './MenuButton.tsx'; const DEVICES = ['Built-in microphone', 'USB headset']; const VIEW_ICONS: Record = { List: 'ph--list--regular', Grid: 'ph--squares-four--regular', Board: 'ph--kanban--regular', }; /** The microphone options caret: two headed radio runs, a separator, and a checkbox, beside an action of its own. */ const DefaultStory = ({ size = 'md' }: SizeArgs) => { const [mode, setMode] = useState<'toggle' | 'hold'>('toggle'); const [device, setDevice] = useState(''); const [extraction, setExtraction] = useState(false); const [view, setView] = useState('List'); const items: MenuButtonItem[] = [ { type: 'group', label: 'Record mode' }, { type: 'option', label: 'Toggle', selected: mode === 'toggle', onSelect: () => setMode('toggle') }, { type: 'option', label: 'Hold', selected: mode === 'hold', onSelect: () => setMode('hold') }, { type: 'separator' }, { type: 'group', label: 'Audio device' }, { type: 'option', label: 'Default', selected: device === '', onSelect: () => setDevice('') }, ...DEVICES.map((label): MenuButtonItem => ({ type: 'option', label, selected: device === label, onSelect: () => setDevice(label), testId: `device-${label}`, })), { type: 'separator' }, { type: 'checkbox', label: 'Entity extraction', checked: extraction, onCheckedChange: setExtraction, testId: `extraction-${size}`, }, ]; return (