import * as React from "react"; import { type ToggleCountFields, type ToggleProp } from "./toggle.js"; type ToggleGroupVariant = ToggleProp["variant"]; type ToggleGroupSize = ToggleProp["size"]; type ToggleGroupShape = ToggleProp["shape"]; type ToggleGroupBaseProp = Omit, "defaultValue" | "dir"> & { variant?: ToggleGroupVariant; size?: ToggleGroupSize; shape?: ToggleGroupShape; /** Disable every item at once — RAC `isDisabled`. */ disabled?: boolean; /** Which way the arrow keys walk the group. */ orientation?: "horizontal" | "vertical"; /** * May the group end up with NOTHING selected? Omitted (`false`) it may, which is what a tag * filter wants — pressing the selected chip again clears it and reports `""`. Set it and the * selected item stays selected when it is pressed again. * * **It also decides the ARIA role of a `type="single"` group (gh#744)**, because emptiness is * exactly what the two roles disagree about. ARIA has no "press again to deselect" for a radio: * a radiogroup that has a selection always has exactly one checked item, so a radiogroup that * the user just emptied is a state a screen reader cannot read out. Therefore: * * - omitted → `role="group"` + `aria-pressed` per item (a row of toggle buttons, which MAY be * all-off) — this is the default, so no existing single group changes behaviour; * - set → `role="radiogroup"` + `role="radio"` / `aria-checked` per item, and the arrow keys * move the SELECTION as APG's radio-group pattern requires, not just the focus. * * The name is React Aria's own (`useToggleGroupState`, which this component is built on) — * neither antd nor Radix names the capability. See `docs/DESIGN-AUTHORITY.md`. * * On `type="multiple"` it only keeps the last remaining item selected; the roles do not move * (a row of `aria-pressed` buttons is already the right reading there). */ disallowEmptySelection?: boolean; /** * Let the row break onto further lines instead of running past its rail (gh#741). Same name, * same boolean shape and same `data-wrap` attribute as `Flex` — one spelling answers "what does * this row do when it does not fit" across the library. * * OPT-IN (`false`), and deliberately the SAME default for every `variant`. `Flex`'s `wrap` is * `false`, and one word must not mean two defaults. Measured in Chromium at a 320px rail: * forcing `flex-wrap: wrap` on all 18 groups of the docs page left the 17 that FIT untouched * (same line count, same height, at a 320px and a 1358px rail) — including every `soft` one, so * paint is not the axis that decides. The only row it moves is the one that overflows, from * 171.5px to 108px: a default of `true` reflows exactly those rows, silently, on an upgrade * whose call sites did not change. * * Wrapping keeps the group's single `gap`, so the two axes stay equal (4px × 4px measured); * `flex-wrap` reorders nothing, so arrow keys still walk the items in DOM order across lines. */ wrap?: boolean; /** * Writing direction. It still lands on the DOM node, but React Aria reads the direction it * navigates by from the ambient locale (`I18nProvider`), NOT from this attribute — where Radix * read this prop directly. An RTL app must set the locale, not just `dir`. */ dir?: "ltr" | "rtl"; /** * Accepted for source compatibility with the Radix era, where it wrapped arrow-key focus around * the ends. React Aria's toolbar navigation stops at the ends and has no equivalent switch, so * this prop no longer changes anything. */ loop?: boolean; }; /** * `type` is the discriminant, exactly as it was under Radix: `"single"` reports the one selected * value as a string (`""` once it is deselected), `"multiple"` reports an array. React Aria models * both as `selectionMode` + a `Set` of keys — that Set is built and unpacked here so the public * shape stays a string / an array of strings. */ type ToggleGroupSingleProp = ToggleGroupBaseProp & { type: "single"; value?: string; defaultValue?: string; onValueChange?: (value: string) => void; }; type ToggleGroupMultipleProp = ToggleGroupBaseProp & { type: "multiple"; value?: string[]; defaultValue?: string[]; onValueChange?: (value: string[]) => void; }; type ToggleGroupProp = ToggleGroupSingleProp | ToggleGroupMultipleProp; export declare const ToggleGroup: React.ForwardRefExoticComponent>; /** Same vocabulary as `Toggle` and `Button` — one counter pill for the whole library. */ export type ToggleGroupItemProp = Omit, "value"> & ToggleCountFields & { /** * This item's key in the group's value. React Aria calls it `id` (the key it stores in * `selectedKeys`); the public spelling stays `value`, as it was under Radix. */ value: string; variant?: ToggleGroupVariant; size?: ToggleGroupSize; shape?: ToggleGroupShape; }; export type ToggleGroupItemProps = ToggleGroupItemProp; export declare const ToggleGroupItem: React.ForwardRefExoticComponent, HTMLButtonElement>, "ref">, "value"> & ToggleCountFields & { /** * This item's key in the group's value. React Aria calls it `id` (the key it stores in * `selectedKeys`); the public spelling stays `value`, as it was under Radix. */ value: string; variant?: ToggleGroupVariant; size?: ToggleGroupSize; shape?: ToggleGroupShape; } & React.RefAttributes>; export {};