import "./option_toggles.css"; import type * as React from "react"; import { CheckboxGroup } from "@base-ui/react/checkbox-group"; import { type OptionMark } from "./status"; import { type StyleProps } from "./style_props"; export interface OptionToggle { /** What `value` holds and `onChange` returns. */ key: string; label: string; /** The mark `Status` draws for it once stored, so the chip ticked is the chip read. */ mark?: OptionMark; } interface OptionTogglesBase extends StyleProps { /** Names the set; the chips carry no visible label. */ accessibilityLabel: string; /** The closed set in field order. */ options: readonly OptionToggle[]; /** Always a set: a single-choice field holds none or one, so switching `multi` changes one flag, not the * value shape. */ value: readonly string[]; multi: boolean; /** Single choice may return to none: pressing the on chip, Delete or Backspace clears it. `multi` is * always clearable. */ clearable?: boolean; disabled?: boolean; testID?: string; ref?: React.Ref; render?: CheckboxGroup.Props["render"]; } /** A form owns the value and commits it in its footer. */ interface OptionTogglesControlled { /** In the options' order, never press order, so a diff never sees a reordering. */ onChange: (next: readonly string[]) => void; onSave?: never; } /** The field saves itself: each press writes the whole set, shown at once; a refusal reverts and is said * under the chips. Only stated picks write — radio arrows move and check (WAI-ARIA), so a move is held * until focus leaves or Enter; a press writes at once. */ interface OptionTogglesSelfSaving { onSave: (next: readonly string[]) => void | Promise; onChange?: never; } export type OptionTogglesProps = OptionTogglesBase & (OptionTogglesControlled | OptionTogglesSelfSaving); /** A small closed set edited in place as chips, ticked when on. One bit per chip: every chosen chip takes * the inverse ground and a check, whatever the option; its own colour stays in `Status` on the register * and read view. For `choiceControl`'s `chips` answer on a form (inclusions, requirements), never a * record at rest. Options differing in degree that parameterise the view are `ChoiceStrip`; fixed * positions read down a column are `ToggleStrip`. `multi` is a Base UI `CheckboxGroup` (Tab to each, * Space toggles); single is a `RadioGroup` (arrows move and select, one tab stop). `onChange` for a form, * `onSave` to self-save ({@link OptionTogglesSelfSaving}). */ export declare function OptionToggles(props: OptionTogglesProps): React.JSX.Element; export {};