Every component is rebuilt on @base-ui/react with a single prop API, token-only colours and dark mode, and 28 new components are added. Components - New: Field, FeaturedTextArea, NumberInput, Combobox, CheckboxGroup, Slider, ToggleGroup/Toggle, IconButton, Dialog/Modal, AlertDialog, Drawer/Sheet, Popover, InfoTip, DropdownMenu, Tabs, Breadcrumb, Pagination, Toast (Toaster, useToast), Progress, Meter, Skeleton, CountBadge, Avatar/AvatarGroup, Kbd, Separator, Table - Rewritten: Button, Input, FeaturedInput, TextArea, Select, FeaturedSelect (real ARIA combobox), NativeSelect, Checkbox, Radio, Switch, Tooltip, Accordion, Alert, Spinner, Badge, Card - Removed TextField (use Input) and sonner (use Toast) Foundations - Semantic tokens (surfaces, text, borders, status ramps) in src/styles/tokens.css, with class-based dark mode - Visible focus rings, linked labels/descriptions/errors, alert roles by severity, keyboard support from Base UI - Fixed the Classic Blue ramp; Emerald, Amber and Teal 500 steps now carry white text at AA - Library build (per-component ES modules, types, tokens.css, exports) Quality - Vitest, Testing Library and axe tests for every component (289 tests) - scripts/check-stories.mjs renders every story in Chrome and fails on errors or axe violations, including contrast; all 423 stories pass in light and dark mode and in all seven palettes - Storybook: controls for every prop, open states for every popup, light/dark toolbar, Introduction guides, docs/CONVENTIONS.md BREAKING CHANGE: component props changed across the kit; see CHANGELOG.md.
82 lines
2.2 KiB
TypeScript
82 lines
2.2 KiB
TypeScript
/**
|
|
* DropdownMenu tokens and the item data types for the `items` prop.
|
|
*/
|
|
|
|
import type { ReactNode } from 'react'
|
|
|
|
type ItemBase = {
|
|
/** React key. Defaults to the item's position. */
|
|
key?: string
|
|
label: ReactNode
|
|
/** Text used for type-ahead when `label` isn't a plain string. */
|
|
textValue?: string
|
|
icon?: ReactNode
|
|
disabled?: boolean
|
|
}
|
|
|
|
export type DropdownMenuActionItem = ItemBase & {
|
|
type?: 'item'
|
|
/** Keyboard shortcut shown right-aligned, e.g. `⌘K`. Display only. */
|
|
shortcut?: string
|
|
/** `danger` for destructive actions. */
|
|
color?: 'danger'
|
|
onSelect?: () => void
|
|
}
|
|
|
|
export type DropdownMenuCheckboxItem = ItemBase & {
|
|
type: 'checkbox'
|
|
shortcut?: string
|
|
checked?: boolean
|
|
defaultChecked?: boolean
|
|
onCheckedChange?: (checked: boolean) => void
|
|
}
|
|
|
|
export type DropdownMenuRadioOption = {
|
|
value: string
|
|
label: ReactNode
|
|
textValue?: string
|
|
icon?: ReactNode
|
|
disabled?: boolean
|
|
}
|
|
|
|
/** A group of mutually exclusive options. */
|
|
export type DropdownMenuRadioGroup = {
|
|
type: 'radio'
|
|
key?: string
|
|
/** Optional heading shown above the options. */
|
|
label?: ReactNode
|
|
value?: string
|
|
defaultValue?: string
|
|
onValueChange?: (value: string) => void
|
|
items: DropdownMenuRadioOption[]
|
|
}
|
|
|
|
export type DropdownMenuSeparator = { type: 'separator'; key?: string }
|
|
|
|
/** A heading; it labels the items that follow it, up to the next separator or label. */
|
|
export type DropdownMenuLabel = { type: 'label'; key?: string; label: ReactNode }
|
|
|
|
export type DropdownMenuSubmenu = ItemBase & {
|
|
type: 'submenu'
|
|
items: DropdownMenuItemData[]
|
|
}
|
|
|
|
export type DropdownMenuItemData =
|
|
| DropdownMenuActionItem
|
|
| DropdownMenuCheckboxItem
|
|
| DropdownMenuRadioGroup
|
|
| DropdownMenuSeparator
|
|
| DropdownMenuLabel
|
|
| DropdownMenuSubmenu
|
|
|
|
export const menuPopupClass = 'min-w-48 max-h-(--available-height) overflow-y-auto p-1'
|
|
|
|
export const menuDangerItem =
|
|
'text-danger-700 data-highlighted:bg-danger-50 dark:text-danger-300 dark:data-highlighted:bg-danger-500/15 ' +
|
|
'[&_[data-slot=icon]]:text-danger-600 dark:[&_[data-slot=icon]]:text-danger-300'
|
|
|
|
export const menuShortcut =
|
|
'ml-auto pl-6 font-sans text-xs tracking-wider text-fg-muted'
|
|
|
|
export const menuLabel = 'px-2.5 pb-1 pt-2 text-xs font-semibold text-fg-muted'
|