import { buttonRecipe } from '@luke-ui/react/button'; import type { IconName } from '@luke-ui/react/icon'; import { Icon } from '@luke-ui/react/icon'; import type { ComponentProps } from 'react'; import type { Selection } from 'react-aria-components/GridList'; import { ToggleButton } from 'react-aria-components/ToggleButton'; import { ToggleButtonGroup } from 'react-aria-components/ToggleButtonGroup'; type IconToggleItem = { icon: IconName; label: string; value: Value; }; type IconToggleButtonGroupProps = { label: string; onChange: (value: Value) => void; options: ReadonlyArray>; value: Value; }; type TextToggleItem = { label: string; value: Value; }; type TextToggleButtonGroupProps = { label: string; onChange: (value: Value) => void; options: ReadonlyArray>; value: Value; }; /** * A round icon-only pill group for choices with well-known glyphs such as light, dark, and system. */ export function IconToggleButtonGroup({ label, onChange, options, value, }: IconToggleButtonGroupProps) { return ( {options.map(({ icon, label: optionLabel, value: optionValue }) => ( ))} ); } /** * A round pill group with visible text labels for choices without an established glyph, such as a * named theme identity. Matches `IconToggleButtonGroup` in height, radius, and focus treatment. */ export function TextToggleButtonGroup({ label, onChange, options, value, }: TextToggleButtonGroupProps) { return ( {options.map(({ label: optionLabel, value: optionValue }) => ( {optionLabel} ))} ); } const GROUP_CLASS_NAME = 'flex items-center gap-2'; function toggleButtonClassName() { return buttonRecipe({ prominence: 'low', size: 'small', tone: 'neutral', }); } type RenderToggleButton = ComponentProps['render']; /** * Renders the toggle's `