/* eslint-disable no-alert */ import React from 'react'; import type { Meta, StoryObj } from '@storybook/react-vite'; import { Header, Keyboard, Text, type Selection } from 'react-aria-components'; import { Button } from '../Button/Button'; import { SettingsIcon } from '../icons/SettingsIcon'; import { Menu, MenuItem, MenuSection, MenuSeparator, MenuTrigger, SubmenuTrigger, } from './Menu'; const meta = { title: 'Basic/Menu', component: Menu, parameters: { layout: 'centered', }, tags: ['autodocs'], } satisfies Meta; export default meta; type Story = StoryObj; function TriggerButton({ children }: { children: React.ReactNode }) { return ; } export const Default: Story = { render: (args: any) => ( Edit Cut Copy Paste ), args: {}, }; export const WithTextSlots: Story = { render: (args: any) => ( Edit Cut Cut to the clipboard ⌘X Copy Copy to the clipboard ⌘C Paste Paste from the clipboard ⌘V ), args: {}, }; export const WithIconButton: Story = { render: (args: any) => ( Cut Copy Paste ), args: {}, }; export const DisabledItems: Story = { render: (args: any) => ( Cut Copy Paste ), args: {}, }; export const AsADynamicCollection: Story = { render: (args: any) => ( Actions {(item: { id: number; name: string }) => ( {item.name} )} ), args: { items: [ { id: 1, name: 'New' }, { id: 2, name: 'Open' }, { id: 3, name: 'Close' }, { id: 4, name: 'Save' }, { id: 5, name: 'Duplicate' }, { id: 6, name: 'Rename' }, { id: 7, name: 'Move' }, ], }, }; export const WithSeparators: Story = { render: (args: any) => ( Cut Copy Paste Bold ), args: {}, }; export const WithSections: Story = { render: (args: any) => (
Styles
Bold Underline
Align
Left Middle Right
), args: {}, }; export const WithCustomHeader: Story = { render: (args: any) => (
Styles
Bold Underline
), args: {}, }; export const AsLinks: Story = { render: (args: any) => ( Adobe Apple Google Microsoft ), args: {}, }; export const SingleSelection: Story = { render: (args: any) => { const [selected, setSelected] = React.useState( new Set(['center']), ); return ( <> Align Left Center Right

Current selection (controlled):{' '} {selected === 'all' ? 'all' : [...selected].join(', ')}

); }, args: {}, }; export const MultipleSelection: Story = { render: (args: any) => { const [selected, setSelected] = React.useState( new Set(['sidebar', 'console']), ); return ( <> View Sidebar Searchbar Tools Console

Current selection (controlled):{' '} {selected === 'all' ? 'all' : [...selected].join(', ')}

); }, args: {}, }; export const ControlledState: Story = { render: (args: any) => { const [open, setOpen] = React.useState(false); return ( Cut Copy Paste ); }, args: {}, }; export const LongPress: Story = { render: (args: any) => ( alert(String(id))}> Cut Copy Paste ), args: {}, }; export const WithSubmenu: Story = { render: (args: any) => ( New Share SMS Email ), args: {}, };