@arun-dev/headless 4.7.0 → 4.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,322 @@
1
+ import * as react from 'react';
2
+ import { ReactNode, ReactElement, Ref, ComponentPropsWithRef } from 'react';
3
+ import { A as AnchorSide, a as AnchorAlign } from '../anchoring-Btxi0QwC.cjs';
4
+
5
+ /** Why a value, the input's text or the open state changed — the second callback argument. */
6
+ type ComboboxChangeReason = 'input' | 'input-press' | 'trigger-press' | 'item-press' | 'keyboard' | 'clear' | 'chip-remove' | 'escape' | 'outside-press' | 'blur' | 'form-reset';
7
+ type ComboboxChangeDetails = {
8
+ reason: ComboboxChangeReason;
9
+ };
10
+ /** Why the highlighted item changed: arrow keys, the pointer, or the component itself. */
11
+ type ComboboxHighlightReason = 'keyboard' | 'pointer' | 'none';
12
+ type ComboboxHighlightDetails = {
13
+ index: number;
14
+ reason: ComboboxHighlightReason;
15
+ };
16
+ /** The state Combobox.Root shares with its parts, and projects as `data-*` attributes. */
17
+ type ComboboxState = {
18
+ open: boolean;
19
+ multiple: boolean;
20
+ disabled: boolean;
21
+ };
22
+
23
+ /** The selection: one item or `null`, or an array with `multiple`. */
24
+ type ComboboxValue$1<T, Multiple extends boolean> = Multiple extends true ? T[] : T | null;
25
+ /** Takes the whole list, so a filter can rank as well as narrow — a fuzzy search, say. */
26
+ type ComboboxFilter<T> = (items: readonly T[], query: string, itemToString: (item: T) => string) => T[];
27
+ type ComboboxRootProps<T, Multiple extends boolean = false> = {
28
+ /** Every item the list can show. With server search, the current results. */
29
+ items: readonly T[];
30
+ /**
31
+ * An item's label: what the input shows once it is picked, and what the default filter
32
+ * matches. Defaults to the item itself for strings, else its `label` property.
33
+ */
34
+ itemToString?: (item: T) => string;
35
+ /**
36
+ * An item's identity: how a selected item is recognised when `items` is a fresh array,
37
+ * and the value the form submits. Defaults to `itemToString`.
38
+ */
39
+ itemToKey?: (item: T) => string;
40
+ /**
41
+ * Narrows `items` to what matches the input's text. Omitted, a case- and accent-insensitive
42
+ * "contains" on each label. `null` turns filtering off — `items` are shown as given, which
43
+ * is what a server search that fills them per query wants.
44
+ */
45
+ filter?: ComboboxFilter<T> | null;
46
+ /** Lets more than one item be selected. `value` is then an array. */
47
+ multiple?: Multiple;
48
+ /**
49
+ * Controlled selection. Provide `onValueChange` alongside it.
50
+ *
51
+ * Never `undefined` once mounted: the mode is latched at mount. Use `null` — or `[]` with
52
+ * `multiple` — for nothing selected.
53
+ */
54
+ value?: ComboboxValue$1<T, Multiple>;
55
+ /** Initial selection when uncontrolled. Read once, at mount. */
56
+ defaultValue?: ComboboxValue$1<T, Multiple>;
57
+ onValueChange?: (value: ComboboxValue$1<T, Multiple>, details: ComboboxChangeDetails) => void;
58
+ /** Controlled text of the input. Provide `onInputValueChange` alongside it. */
59
+ inputValue?: string;
60
+ /** Initial text when uncontrolled. Defaults to the selected item's label, without `multiple`. */
61
+ defaultInputValue?: string;
62
+ /** Called on every change of the input's text — typing, a pick, Clear, or a close. */
63
+ onInputValueChange?: (inputValue: string, details: ComboboxChangeDetails) => void;
64
+ /** Controlled open state. Provide `onOpenChange` alongside it. */
65
+ open?: boolean;
66
+ /** Initial open state when uncontrolled. */
67
+ defaultOpen?: boolean;
68
+ onOpenChange?: (open: boolean, details: ComboboxChangeDetails) => void;
69
+ /**
70
+ * Called when the highlighted item changes, with its index in the filtered list. A
71
+ * virtualized list scrolls to that index, since the highlighted option must be rendered
72
+ * for the input's `aria-activedescendant` to reach it.
73
+ */
74
+ onItemHighlighted?: (item: T | undefined, details: ComboboxHighlightDetails) => void;
75
+ /** Called when the end of the list scrolls into view and `loading` is not set. */
76
+ onLoadMore?: () => void;
77
+ /** More items are on their way: the list is `aria-busy`, and `Empty` stays hidden. */
78
+ loading?: boolean;
79
+ /** Disables the input and every button. */
80
+ disabled?: boolean;
81
+ /** Submits each selected item's key under this name, from hidden inputs. */
82
+ name?: string;
83
+ /** Associates the hidden inputs with a `<form>` by id, when rendered outside it. */
84
+ form?: string;
85
+ children?: ReactNode;
86
+ };
87
+ /**
88
+ * A text input that filters a list of options, by the WAI-ARIA combobox pattern. Holds the
89
+ * state and shares it with its parts. Renders no element of its own, apart from the hidden
90
+ * inputs a form submits.
91
+ *
92
+ * Items are data (decision 14): the Root filters `items`, and `Combobox.List` renders what is
93
+ * left. The selection holds items, not keys, and everything about it — the input's label,
94
+ * `aria-selected`, the form value — comes from `value`, never from `items` (decision 10). A
95
+ * selected item stays selected, labelled and submitted after a search stops returning it.
96
+ *
97
+ * Focus stays in the input; the highlighted option is its `aria-activedescendant`.
98
+ */
99
+ declare function ComboboxRoot<T, Multiple extends boolean = false>({ items, itemToString: itemToStringProp, itemToKey: itemToKeyProp, filter, multiple: multipleProp, value: valueProp, defaultValue, onValueChange, inputValue: inputValueProp, defaultInputValue, onInputValueChange, open: openProp, defaultOpen, onOpenChange, onItemHighlighted, onLoadMore, loading, disabled, name, form, children, }: ComboboxRootProps<T, Multiple>): react.JSX.Element;
100
+
101
+ type ComboboxInputOwnProps = {
102
+ /** Element to render instead of the default `<input>`. Props and ref are merged onto it. */
103
+ render?: ReactElement;
104
+ /** Ref to the rendered element. Merged with any ref on the `render` element. */
105
+ ref?: Ref<HTMLElement>;
106
+ };
107
+ type ComboboxInputProps = ComboboxInputOwnProps & Omit<ComponentPropsWithRef<'input'>, keyof ComboboxInputOwnProps | 'value' | 'defaultValue'>;
108
+ /**
109
+ * The text input: `role="combobox"`, and the element focus stays on. Its text is the Root's
110
+ * `inputValue`. It is what the popup is anchored to, unless an InputGroup wraps it.
111
+ *
112
+ * Typing opens the list and filters it. Up and Down open it, or move the highlight, wrapping;
113
+ * Home and End jump to the ends while it is open; Alt+Down opens it without highlighting.
114
+ * Enter picks the highlighted item; Esc closes. With `multiple`, Backspace in an empty input
115
+ * removes the last selected item, and Left at the start of the text moves into the chips.
116
+ *
117
+ * Leaving the input closes the list and puts the text back: the selected label, or empty
118
+ * with `multiple`.
119
+ */
120
+ declare function ComboboxInput({ className, render, ...rest }: ComboboxInputProps): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
121
+
122
+ type ComboboxInputGroupOwnProps = {
123
+ /** Element to render instead of the default `<div>`. Props and ref are merged onto it. */
124
+ render?: ReactElement;
125
+ /** Ref to the rendered element. Merged with any ref on the `render` element. */
126
+ ref?: Ref<HTMLElement>;
127
+ };
128
+ type ComboboxInputGroupProps = ComboboxInputGroupOwnProps & Omit<ComponentPropsWithRef<'div'>, keyof ComboboxInputGroupOwnProps>;
129
+ /**
130
+ * The field around the Input — chips, Clear and Trigger with it — when they are drawn as one
131
+ * box. It takes over as the popup's anchor, so the list lines up with the whole field rather
132
+ * than the text alone, and a press on it is not a press outside.
133
+ *
134
+ * A press on the box itself, between its children, focuses the input.
135
+ */
136
+ declare function ComboboxInputGroup({ className, children, render, ...rest }: ComboboxInputGroupProps): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
137
+
138
+ type ComboboxTriggerOwnProps = {
139
+ /** Element to render instead of the default `<button>`. Props and ref are merged onto it. */
140
+ render?: ReactElement;
141
+ /** Ref to the rendered element. Merged with any ref on the `render` element. */
142
+ ref?: Ref<HTMLElement>;
143
+ };
144
+ type ComboboxTriggerProps = ComboboxTriggerOwnProps & Omit<ComponentPropsWithRef<'button'>, keyof ComboboxTriggerOwnProps>;
145
+ /**
146
+ * The button that opens and closes the list — usually a chevron. Give it an `aria-label`.
147
+ *
148
+ * Out of the tab order and never focused: a press keeps focus in the input, which the
149
+ * keyboard already opens the list from.
150
+ */
151
+ declare function ComboboxTrigger({ className, children, render, ...rest }: ComboboxTriggerProps): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
152
+
153
+ type ComboboxClearOwnProps = {
154
+ /** Element to render instead of the default `<button>`. Props and ref are merged onto it. */
155
+ render?: ReactElement;
156
+ /** Ref to the rendered element. Merged with any ref on the `render` element. */
157
+ ref?: Ref<HTMLElement>;
158
+ };
159
+ type ComboboxClearProps = ComboboxClearOwnProps & Omit<ComponentPropsWithRef<'button'>, keyof ComboboxClearOwnProps>;
160
+ /**
161
+ * Empties the input and the selection — every selected item, with `multiple`. Give it an
162
+ * `aria-label`.
163
+ *
164
+ * `data-visible` is present while there is a selection to clear; style it hidden otherwise.
165
+ * Out of the tab order, and a press keeps focus in the input.
166
+ */
167
+ declare function ComboboxClear({ className, children, render, ...rest }: ComboboxClearProps): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
168
+
169
+ type ComboboxSide = AnchorSide;
170
+ type ComboboxAlign = AnchorAlign;
171
+ type ComboboxPopupOwnProps = {
172
+ /** Which side of the input to open on. Flips to the opposite side when there is no room. */
173
+ side?: ComboboxSide;
174
+ /** Where along that side: flush with the input's start or end edge, or centred on it. */
175
+ align?: ComboboxAlign;
176
+ /** Element to render instead of the default `<div>`. Props and ref are merged onto it. */
177
+ render?: ReactElement;
178
+ /** Ref to the rendered element. Merged with any ref on the `render` element. */
179
+ ref?: Ref<HTMLElement>;
180
+ };
181
+ type ComboboxPopupProps = ComboboxPopupOwnProps & Omit<ComponentPropsWithRef<'div'>, keyof ComboboxPopupOwnProps | 'popover'>;
182
+ /**
183
+ * The box the list opens in: a native `popover="manual"` in the top layer, anchored to the
184
+ * Input as Popover's popup is to its Trigger (decision 12). Holds `List`, and `Empty` and
185
+ * `Status` if used.
186
+ *
187
+ * `manual`, not `auto`: the platform's light dismiss would close the list on a press of the
188
+ * input itself, and of the Trigger and Clear beside it (decision 14). A press anywhere else
189
+ * closes it here instead, reported as `'outside-press'`; Esc is the Input's. A press inside
190
+ * keeps focus in the input.
191
+ */
192
+ declare function ComboboxPopup({ side, align, className, children, render, ...rest }: ComboboxPopupProps): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
193
+
194
+ type ComboboxListOwnProps<T> = {
195
+ /**
196
+ * A function rendering one `Combobox.Item` per filtered item, or any nodes. With a
197
+ * virtualizer, render only the rows it asks for.
198
+ */
199
+ children?: ReactNode | ((item: T, index: number) => ReactNode);
200
+ /** Element to render instead of the default `<div>`. Props and ref are merged onto it. */
201
+ render?: ReactElement;
202
+ /** Ref to the rendered element. Merged with any ref on the `render` element. */
203
+ ref?: Ref<HTMLElement>;
204
+ };
205
+ type ComboboxListProps<T = unknown> = ComboboxListOwnProps<T> & Omit<ComponentPropsWithRef<'div'>, keyof ComboboxListOwnProps<T>>;
206
+ /**
207
+ * The `role="listbox"`. Given a function, renders it once per item the filter left.
208
+ *
209
+ * With the Root's `onLoadMore`, an invisible sentinel follows the items; when it scrolls into
210
+ * view and nothing is `loading`, `onLoadMore` is called. The list is `aria-busy` meanwhile.
211
+ */
212
+ declare function ComboboxList<T = unknown>({ className, children, render, ...rest }: ComboboxListProps<T>): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
213
+
214
+ type ComboboxItemOwnProps<T> = {
215
+ /** The item this option stands for — one of the Root's `items`. */
216
+ value: T;
217
+ /** Cannot be picked, and the arrow keys skip it. */
218
+ disabled?: boolean;
219
+ /** Element to render instead of the default `<div>`. Props and ref are merged onto it. */
220
+ render?: ReactElement;
221
+ /** Ref to the rendered element. Merged with any ref on the `render` element. */
222
+ ref?: Ref<HTMLElement>;
223
+ };
224
+ type ComboboxItemProps<T = unknown> = ComboboxItemOwnProps<T> & Omit<ComponentPropsWithRef<'div'>, keyof ComboboxItemOwnProps<T>>;
225
+ /**
226
+ * One option. A press picks it — with `multiple`, toggles it — and the pointer highlights it.
227
+ * Never focused: the input keeps focus and points at the highlighted option.
228
+ *
229
+ * `data-selected` and `aria-selected` follow the Root's `value`; `data-highlighted` follows
230
+ * the arrow keys and the pointer. Only the items whose highlight changes re-render.
231
+ */
232
+ declare function ComboboxItem<T = unknown>({ value, disabled, className, children, render, ...rest }: ComboboxItemProps<T>): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
233
+
234
+ type ComboboxEmptyOwnProps = {
235
+ /** Element to render instead of the default `<div>`. Props and ref are merged onto it. */
236
+ render?: ReactElement;
237
+ /** Ref to the rendered element. Merged with any ref on the `render` element. */
238
+ ref?: Ref<HTMLElement>;
239
+ };
240
+ type ComboboxEmptyProps = ComboboxEmptyOwnProps & Omit<ComponentPropsWithRef<'div'>, keyof ComboboxEmptyOwnProps>;
241
+ /**
242
+ * Shown when the filter leaves nothing and nothing is `loading` — "No results". Renders
243
+ * nothing otherwise. Place it in the Popup, outside the List.
244
+ */
245
+ declare function ComboboxEmpty({ className, children, render, ...rest }: ComboboxEmptyProps): ReactElement<unknown, string | react.JSXElementConstructor<any>> | null;
246
+
247
+ type ComboboxStatusOwnProps = {
248
+ /** Element to render instead of the default `<div>`. Props and ref are merged onto it. */
249
+ render?: ReactElement;
250
+ /** Ref to the rendered element. Merged with any ref on the `render` element. */
251
+ ref?: Ref<HTMLElement>;
252
+ };
253
+ type ComboboxStatusProps = ComboboxStatusOwnProps & Omit<ComponentPropsWithRef<'div'>, keyof ComboboxStatusOwnProps>;
254
+ /**
255
+ * A polite live region for what a screen reader should hear about the list: "Searching…",
256
+ * "12 results", an error. Its text is yours; a change to it is announced.
257
+ */
258
+ declare function ComboboxStatus({ className, children, render, ...rest }: ComboboxStatusProps): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
259
+
260
+ type ComboboxChipOwnProps<T> = {
261
+ /** The selected item this chip shows — one of the Root's `value`. */
262
+ value: T;
263
+ /** Element to render instead of the default `<div>`. Props and ref are merged onto it. */
264
+ render?: ReactElement;
265
+ /** Ref to the rendered element. Merged with any ref on the `render` element. */
266
+ ref?: Ref<HTMLElement>;
267
+ };
268
+ type ComboboxChipProps<T = unknown> = ComboboxChipOwnProps<T> & Omit<ComponentPropsWithRef<'div'>, keyof ComboboxChipOwnProps<T>>;
269
+ /**
270
+ * One selected item, with `multiple`. Render one per item of the Root's `value`, before the
271
+ * Input. Give it an `aria-description` that says how to remove it.
272
+ *
273
+ * Out of the tab order. Left from the start of the input reaches the last chip; Left and
274
+ * Right move between chips, and Right from the last returns to the input; Backspace or
275
+ * Delete removes the focused chip and moves to the next, or back to the input.
276
+ */
277
+ declare function ComboboxChip<T = unknown>({ value, className, children, render, ...rest }: ComboboxChipProps<T>): react.JSX.Element;
278
+
279
+ type ComboboxChipRemoveOwnProps = {
280
+ /** Element to render instead of the default `<button>`. Props and ref are merged onto it. */
281
+ render?: ReactElement;
282
+ /** Ref to the rendered element. Merged with any ref on the `render` element. */
283
+ ref?: Ref<HTMLElement>;
284
+ };
285
+ type ComboboxChipRemoveProps = ComboboxChipRemoveOwnProps & Omit<ComponentPropsWithRef<'button'>, keyof ComboboxChipRemoveOwnProps>;
286
+ /**
287
+ * Removes its Chip's item from the selection. Give it an `aria-label` — "Remove Book".
288
+ * Out of the tab order; a press returns focus to the input.
289
+ */
290
+ declare function ComboboxChipRemove({ className, children, render, ...rest }: ComboboxChipRemoveProps): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
291
+
292
+ type ComboboxValueProps<T = unknown> = {
293
+ /**
294
+ * Renders the selection: `T | null`, or `T[]` with `multiple`. The Root's `itemToString` is
295
+ * passed along for labels — a chip's text, say.
296
+ */
297
+ children: (value: T, details: {
298
+ itemToString: (item: unknown) => string;
299
+ }) => ReactNode;
300
+ };
301
+ /**
302
+ * The current selection, for whatever shows it outside the input — chips, most often. Renders
303
+ * no element of its own.
304
+ *
305
+ * It exists so that a separate styling package can show the selection without owning a copy
306
+ * of it (decision 9): the value stays the Root's.
307
+ */
308
+ declare function ComboboxValue<T = unknown>({ children }: ComboboxValueProps<T>): react.JSX.Element;
309
+
310
+ declare namespace index_parts {
311
+ export { ComboboxChip as Chip, ComboboxChipRemove as ChipRemove, ComboboxClear as Clear, ComboboxEmpty as Empty, ComboboxInput as Input, ComboboxInputGroup as InputGroup, ComboboxItem as Item, ComboboxList as List, ComboboxPopup as Popup, ComboboxRoot as Root, ComboboxStatus as Status, ComboboxTrigger as Trigger, ComboboxValue as Value };
312
+ }
313
+
314
+ /**
315
+ * Combobox's default filter: the items whose label contains the query, ignoring case and
316
+ * accents, in their original order. An empty query keeps every item.
317
+ *
318
+ * Exported so a consumer's own filter can fall back to it, or narrow with it first.
319
+ */
320
+ declare function defaultFilter<T>(items: readonly T[], query: string, itemToString: (item: T) => string): T[];
321
+
322
+ export { index_parts as Combobox, type ComboboxAlign, type ComboboxChangeDetails, type ComboboxChangeReason, type ComboboxChipProps, type ComboboxChipRemoveProps, type ComboboxClearProps, type ComboboxEmptyProps, type ComboboxFilter, type ComboboxHighlightDetails, type ComboboxHighlightReason, type ComboboxInputGroupProps, type ComboboxInputProps, type ComboboxItemProps, type ComboboxListProps, type ComboboxPopupProps, type ComboboxRootProps, type ComboboxSide, type ComboboxState, type ComboboxStatusProps, type ComboboxTriggerProps, type ComboboxValue$1 as ComboboxValue, type ComboboxValueProps, defaultFilter };
@@ -0,0 +1,322 @@
1
+ import * as react from 'react';
2
+ import { ReactNode, ReactElement, Ref, ComponentPropsWithRef } from 'react';
3
+ import { A as AnchorSide, a as AnchorAlign } from '../anchoring-Btxi0QwC.js';
4
+
5
+ /** Why a value, the input's text or the open state changed — the second callback argument. */
6
+ type ComboboxChangeReason = 'input' | 'input-press' | 'trigger-press' | 'item-press' | 'keyboard' | 'clear' | 'chip-remove' | 'escape' | 'outside-press' | 'blur' | 'form-reset';
7
+ type ComboboxChangeDetails = {
8
+ reason: ComboboxChangeReason;
9
+ };
10
+ /** Why the highlighted item changed: arrow keys, the pointer, or the component itself. */
11
+ type ComboboxHighlightReason = 'keyboard' | 'pointer' | 'none';
12
+ type ComboboxHighlightDetails = {
13
+ index: number;
14
+ reason: ComboboxHighlightReason;
15
+ };
16
+ /** The state Combobox.Root shares with its parts, and projects as `data-*` attributes. */
17
+ type ComboboxState = {
18
+ open: boolean;
19
+ multiple: boolean;
20
+ disabled: boolean;
21
+ };
22
+
23
+ /** The selection: one item or `null`, or an array with `multiple`. */
24
+ type ComboboxValue$1<T, Multiple extends boolean> = Multiple extends true ? T[] : T | null;
25
+ /** Takes the whole list, so a filter can rank as well as narrow — a fuzzy search, say. */
26
+ type ComboboxFilter<T> = (items: readonly T[], query: string, itemToString: (item: T) => string) => T[];
27
+ type ComboboxRootProps<T, Multiple extends boolean = false> = {
28
+ /** Every item the list can show. With server search, the current results. */
29
+ items: readonly T[];
30
+ /**
31
+ * An item's label: what the input shows once it is picked, and what the default filter
32
+ * matches. Defaults to the item itself for strings, else its `label` property.
33
+ */
34
+ itemToString?: (item: T) => string;
35
+ /**
36
+ * An item's identity: how a selected item is recognised when `items` is a fresh array,
37
+ * and the value the form submits. Defaults to `itemToString`.
38
+ */
39
+ itemToKey?: (item: T) => string;
40
+ /**
41
+ * Narrows `items` to what matches the input's text. Omitted, a case- and accent-insensitive
42
+ * "contains" on each label. `null` turns filtering off — `items` are shown as given, which
43
+ * is what a server search that fills them per query wants.
44
+ */
45
+ filter?: ComboboxFilter<T> | null;
46
+ /** Lets more than one item be selected. `value` is then an array. */
47
+ multiple?: Multiple;
48
+ /**
49
+ * Controlled selection. Provide `onValueChange` alongside it.
50
+ *
51
+ * Never `undefined` once mounted: the mode is latched at mount. Use `null` — or `[]` with
52
+ * `multiple` — for nothing selected.
53
+ */
54
+ value?: ComboboxValue$1<T, Multiple>;
55
+ /** Initial selection when uncontrolled. Read once, at mount. */
56
+ defaultValue?: ComboboxValue$1<T, Multiple>;
57
+ onValueChange?: (value: ComboboxValue$1<T, Multiple>, details: ComboboxChangeDetails) => void;
58
+ /** Controlled text of the input. Provide `onInputValueChange` alongside it. */
59
+ inputValue?: string;
60
+ /** Initial text when uncontrolled. Defaults to the selected item's label, without `multiple`. */
61
+ defaultInputValue?: string;
62
+ /** Called on every change of the input's text — typing, a pick, Clear, or a close. */
63
+ onInputValueChange?: (inputValue: string, details: ComboboxChangeDetails) => void;
64
+ /** Controlled open state. Provide `onOpenChange` alongside it. */
65
+ open?: boolean;
66
+ /** Initial open state when uncontrolled. */
67
+ defaultOpen?: boolean;
68
+ onOpenChange?: (open: boolean, details: ComboboxChangeDetails) => void;
69
+ /**
70
+ * Called when the highlighted item changes, with its index in the filtered list. A
71
+ * virtualized list scrolls to that index, since the highlighted option must be rendered
72
+ * for the input's `aria-activedescendant` to reach it.
73
+ */
74
+ onItemHighlighted?: (item: T | undefined, details: ComboboxHighlightDetails) => void;
75
+ /** Called when the end of the list scrolls into view and `loading` is not set. */
76
+ onLoadMore?: () => void;
77
+ /** More items are on their way: the list is `aria-busy`, and `Empty` stays hidden. */
78
+ loading?: boolean;
79
+ /** Disables the input and every button. */
80
+ disabled?: boolean;
81
+ /** Submits each selected item's key under this name, from hidden inputs. */
82
+ name?: string;
83
+ /** Associates the hidden inputs with a `<form>` by id, when rendered outside it. */
84
+ form?: string;
85
+ children?: ReactNode;
86
+ };
87
+ /**
88
+ * A text input that filters a list of options, by the WAI-ARIA combobox pattern. Holds the
89
+ * state and shares it with its parts. Renders no element of its own, apart from the hidden
90
+ * inputs a form submits.
91
+ *
92
+ * Items are data (decision 14): the Root filters `items`, and `Combobox.List` renders what is
93
+ * left. The selection holds items, not keys, and everything about it — the input's label,
94
+ * `aria-selected`, the form value — comes from `value`, never from `items` (decision 10). A
95
+ * selected item stays selected, labelled and submitted after a search stops returning it.
96
+ *
97
+ * Focus stays in the input; the highlighted option is its `aria-activedescendant`.
98
+ */
99
+ declare function ComboboxRoot<T, Multiple extends boolean = false>({ items, itemToString: itemToStringProp, itemToKey: itemToKeyProp, filter, multiple: multipleProp, value: valueProp, defaultValue, onValueChange, inputValue: inputValueProp, defaultInputValue, onInputValueChange, open: openProp, defaultOpen, onOpenChange, onItemHighlighted, onLoadMore, loading, disabled, name, form, children, }: ComboboxRootProps<T, Multiple>): react.JSX.Element;
100
+
101
+ type ComboboxInputOwnProps = {
102
+ /** Element to render instead of the default `<input>`. Props and ref are merged onto it. */
103
+ render?: ReactElement;
104
+ /** Ref to the rendered element. Merged with any ref on the `render` element. */
105
+ ref?: Ref<HTMLElement>;
106
+ };
107
+ type ComboboxInputProps = ComboboxInputOwnProps & Omit<ComponentPropsWithRef<'input'>, keyof ComboboxInputOwnProps | 'value' | 'defaultValue'>;
108
+ /**
109
+ * The text input: `role="combobox"`, and the element focus stays on. Its text is the Root's
110
+ * `inputValue`. It is what the popup is anchored to, unless an InputGroup wraps it.
111
+ *
112
+ * Typing opens the list and filters it. Up and Down open it, or move the highlight, wrapping;
113
+ * Home and End jump to the ends while it is open; Alt+Down opens it without highlighting.
114
+ * Enter picks the highlighted item; Esc closes. With `multiple`, Backspace in an empty input
115
+ * removes the last selected item, and Left at the start of the text moves into the chips.
116
+ *
117
+ * Leaving the input closes the list and puts the text back: the selected label, or empty
118
+ * with `multiple`.
119
+ */
120
+ declare function ComboboxInput({ className, render, ...rest }: ComboboxInputProps): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
121
+
122
+ type ComboboxInputGroupOwnProps = {
123
+ /** Element to render instead of the default `<div>`. Props and ref are merged onto it. */
124
+ render?: ReactElement;
125
+ /** Ref to the rendered element. Merged with any ref on the `render` element. */
126
+ ref?: Ref<HTMLElement>;
127
+ };
128
+ type ComboboxInputGroupProps = ComboboxInputGroupOwnProps & Omit<ComponentPropsWithRef<'div'>, keyof ComboboxInputGroupOwnProps>;
129
+ /**
130
+ * The field around the Input — chips, Clear and Trigger with it — when they are drawn as one
131
+ * box. It takes over as the popup's anchor, so the list lines up with the whole field rather
132
+ * than the text alone, and a press on it is not a press outside.
133
+ *
134
+ * A press on the box itself, between its children, focuses the input.
135
+ */
136
+ declare function ComboboxInputGroup({ className, children, render, ...rest }: ComboboxInputGroupProps): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
137
+
138
+ type ComboboxTriggerOwnProps = {
139
+ /** Element to render instead of the default `<button>`. Props and ref are merged onto it. */
140
+ render?: ReactElement;
141
+ /** Ref to the rendered element. Merged with any ref on the `render` element. */
142
+ ref?: Ref<HTMLElement>;
143
+ };
144
+ type ComboboxTriggerProps = ComboboxTriggerOwnProps & Omit<ComponentPropsWithRef<'button'>, keyof ComboboxTriggerOwnProps>;
145
+ /**
146
+ * The button that opens and closes the list — usually a chevron. Give it an `aria-label`.
147
+ *
148
+ * Out of the tab order and never focused: a press keeps focus in the input, which the
149
+ * keyboard already opens the list from.
150
+ */
151
+ declare function ComboboxTrigger({ className, children, render, ...rest }: ComboboxTriggerProps): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
152
+
153
+ type ComboboxClearOwnProps = {
154
+ /** Element to render instead of the default `<button>`. Props and ref are merged onto it. */
155
+ render?: ReactElement;
156
+ /** Ref to the rendered element. Merged with any ref on the `render` element. */
157
+ ref?: Ref<HTMLElement>;
158
+ };
159
+ type ComboboxClearProps = ComboboxClearOwnProps & Omit<ComponentPropsWithRef<'button'>, keyof ComboboxClearOwnProps>;
160
+ /**
161
+ * Empties the input and the selection — every selected item, with `multiple`. Give it an
162
+ * `aria-label`.
163
+ *
164
+ * `data-visible` is present while there is a selection to clear; style it hidden otherwise.
165
+ * Out of the tab order, and a press keeps focus in the input.
166
+ */
167
+ declare function ComboboxClear({ className, children, render, ...rest }: ComboboxClearProps): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
168
+
169
+ type ComboboxSide = AnchorSide;
170
+ type ComboboxAlign = AnchorAlign;
171
+ type ComboboxPopupOwnProps = {
172
+ /** Which side of the input to open on. Flips to the opposite side when there is no room. */
173
+ side?: ComboboxSide;
174
+ /** Where along that side: flush with the input's start or end edge, or centred on it. */
175
+ align?: ComboboxAlign;
176
+ /** Element to render instead of the default `<div>`. Props and ref are merged onto it. */
177
+ render?: ReactElement;
178
+ /** Ref to the rendered element. Merged with any ref on the `render` element. */
179
+ ref?: Ref<HTMLElement>;
180
+ };
181
+ type ComboboxPopupProps = ComboboxPopupOwnProps & Omit<ComponentPropsWithRef<'div'>, keyof ComboboxPopupOwnProps | 'popover'>;
182
+ /**
183
+ * The box the list opens in: a native `popover="manual"` in the top layer, anchored to the
184
+ * Input as Popover's popup is to its Trigger (decision 12). Holds `List`, and `Empty` and
185
+ * `Status` if used.
186
+ *
187
+ * `manual`, not `auto`: the platform's light dismiss would close the list on a press of the
188
+ * input itself, and of the Trigger and Clear beside it (decision 14). A press anywhere else
189
+ * closes it here instead, reported as `'outside-press'`; Esc is the Input's. A press inside
190
+ * keeps focus in the input.
191
+ */
192
+ declare function ComboboxPopup({ side, align, className, children, render, ...rest }: ComboboxPopupProps): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
193
+
194
+ type ComboboxListOwnProps<T> = {
195
+ /**
196
+ * A function rendering one `Combobox.Item` per filtered item, or any nodes. With a
197
+ * virtualizer, render only the rows it asks for.
198
+ */
199
+ children?: ReactNode | ((item: T, index: number) => ReactNode);
200
+ /** Element to render instead of the default `<div>`. Props and ref are merged onto it. */
201
+ render?: ReactElement;
202
+ /** Ref to the rendered element. Merged with any ref on the `render` element. */
203
+ ref?: Ref<HTMLElement>;
204
+ };
205
+ type ComboboxListProps<T = unknown> = ComboboxListOwnProps<T> & Omit<ComponentPropsWithRef<'div'>, keyof ComboboxListOwnProps<T>>;
206
+ /**
207
+ * The `role="listbox"`. Given a function, renders it once per item the filter left.
208
+ *
209
+ * With the Root's `onLoadMore`, an invisible sentinel follows the items; when it scrolls into
210
+ * view and nothing is `loading`, `onLoadMore` is called. The list is `aria-busy` meanwhile.
211
+ */
212
+ declare function ComboboxList<T = unknown>({ className, children, render, ...rest }: ComboboxListProps<T>): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
213
+
214
+ type ComboboxItemOwnProps<T> = {
215
+ /** The item this option stands for — one of the Root's `items`. */
216
+ value: T;
217
+ /** Cannot be picked, and the arrow keys skip it. */
218
+ disabled?: boolean;
219
+ /** Element to render instead of the default `<div>`. Props and ref are merged onto it. */
220
+ render?: ReactElement;
221
+ /** Ref to the rendered element. Merged with any ref on the `render` element. */
222
+ ref?: Ref<HTMLElement>;
223
+ };
224
+ type ComboboxItemProps<T = unknown> = ComboboxItemOwnProps<T> & Omit<ComponentPropsWithRef<'div'>, keyof ComboboxItemOwnProps<T>>;
225
+ /**
226
+ * One option. A press picks it — with `multiple`, toggles it — and the pointer highlights it.
227
+ * Never focused: the input keeps focus and points at the highlighted option.
228
+ *
229
+ * `data-selected` and `aria-selected` follow the Root's `value`; `data-highlighted` follows
230
+ * the arrow keys and the pointer. Only the items whose highlight changes re-render.
231
+ */
232
+ declare function ComboboxItem<T = unknown>({ value, disabled, className, children, render, ...rest }: ComboboxItemProps<T>): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
233
+
234
+ type ComboboxEmptyOwnProps = {
235
+ /** Element to render instead of the default `<div>`. Props and ref are merged onto it. */
236
+ render?: ReactElement;
237
+ /** Ref to the rendered element. Merged with any ref on the `render` element. */
238
+ ref?: Ref<HTMLElement>;
239
+ };
240
+ type ComboboxEmptyProps = ComboboxEmptyOwnProps & Omit<ComponentPropsWithRef<'div'>, keyof ComboboxEmptyOwnProps>;
241
+ /**
242
+ * Shown when the filter leaves nothing and nothing is `loading` — "No results". Renders
243
+ * nothing otherwise. Place it in the Popup, outside the List.
244
+ */
245
+ declare function ComboboxEmpty({ className, children, render, ...rest }: ComboboxEmptyProps): ReactElement<unknown, string | react.JSXElementConstructor<any>> | null;
246
+
247
+ type ComboboxStatusOwnProps = {
248
+ /** Element to render instead of the default `<div>`. Props and ref are merged onto it. */
249
+ render?: ReactElement;
250
+ /** Ref to the rendered element. Merged with any ref on the `render` element. */
251
+ ref?: Ref<HTMLElement>;
252
+ };
253
+ type ComboboxStatusProps = ComboboxStatusOwnProps & Omit<ComponentPropsWithRef<'div'>, keyof ComboboxStatusOwnProps>;
254
+ /**
255
+ * A polite live region for what a screen reader should hear about the list: "Searching…",
256
+ * "12 results", an error. Its text is yours; a change to it is announced.
257
+ */
258
+ declare function ComboboxStatus({ className, children, render, ...rest }: ComboboxStatusProps): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
259
+
260
+ type ComboboxChipOwnProps<T> = {
261
+ /** The selected item this chip shows — one of the Root's `value`. */
262
+ value: T;
263
+ /** Element to render instead of the default `<div>`. Props and ref are merged onto it. */
264
+ render?: ReactElement;
265
+ /** Ref to the rendered element. Merged with any ref on the `render` element. */
266
+ ref?: Ref<HTMLElement>;
267
+ };
268
+ type ComboboxChipProps<T = unknown> = ComboboxChipOwnProps<T> & Omit<ComponentPropsWithRef<'div'>, keyof ComboboxChipOwnProps<T>>;
269
+ /**
270
+ * One selected item, with `multiple`. Render one per item of the Root's `value`, before the
271
+ * Input. Give it an `aria-description` that says how to remove it.
272
+ *
273
+ * Out of the tab order. Left from the start of the input reaches the last chip; Left and
274
+ * Right move between chips, and Right from the last returns to the input; Backspace or
275
+ * Delete removes the focused chip and moves to the next, or back to the input.
276
+ */
277
+ declare function ComboboxChip<T = unknown>({ value, className, children, render, ...rest }: ComboboxChipProps<T>): react.JSX.Element;
278
+
279
+ type ComboboxChipRemoveOwnProps = {
280
+ /** Element to render instead of the default `<button>`. Props and ref are merged onto it. */
281
+ render?: ReactElement;
282
+ /** Ref to the rendered element. Merged with any ref on the `render` element. */
283
+ ref?: Ref<HTMLElement>;
284
+ };
285
+ type ComboboxChipRemoveProps = ComboboxChipRemoveOwnProps & Omit<ComponentPropsWithRef<'button'>, keyof ComboboxChipRemoveOwnProps>;
286
+ /**
287
+ * Removes its Chip's item from the selection. Give it an `aria-label` — "Remove Book".
288
+ * Out of the tab order; a press returns focus to the input.
289
+ */
290
+ declare function ComboboxChipRemove({ className, children, render, ...rest }: ComboboxChipRemoveProps): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
291
+
292
+ type ComboboxValueProps<T = unknown> = {
293
+ /**
294
+ * Renders the selection: `T | null`, or `T[]` with `multiple`. The Root's `itemToString` is
295
+ * passed along for labels — a chip's text, say.
296
+ */
297
+ children: (value: T, details: {
298
+ itemToString: (item: unknown) => string;
299
+ }) => ReactNode;
300
+ };
301
+ /**
302
+ * The current selection, for whatever shows it outside the input — chips, most often. Renders
303
+ * no element of its own.
304
+ *
305
+ * It exists so that a separate styling package can show the selection without owning a copy
306
+ * of it (decision 9): the value stays the Root's.
307
+ */
308
+ declare function ComboboxValue<T = unknown>({ children }: ComboboxValueProps<T>): react.JSX.Element;
309
+
310
+ declare namespace index_parts {
311
+ export { ComboboxChip as Chip, ComboboxChipRemove as ChipRemove, ComboboxClear as Clear, ComboboxEmpty as Empty, ComboboxInput as Input, ComboboxInputGroup as InputGroup, ComboboxItem as Item, ComboboxList as List, ComboboxPopup as Popup, ComboboxRoot as Root, ComboboxStatus as Status, ComboboxTrigger as Trigger, ComboboxValue as Value };
312
+ }
313
+
314
+ /**
315
+ * Combobox's default filter: the items whose label contains the query, ignoring case and
316
+ * accents, in their original order. An empty query keeps every item.
317
+ *
318
+ * Exported so a consumer's own filter can fall back to it, or narrow with it first.
319
+ */
320
+ declare function defaultFilter<T>(items: readonly T[], query: string, itemToString: (item: T) => string): T[];
321
+
322
+ export { index_parts as Combobox, type ComboboxAlign, type ComboboxChangeDetails, type ComboboxChangeReason, type ComboboxChipProps, type ComboboxChipRemoveProps, type ComboboxClearProps, type ComboboxEmptyProps, type ComboboxFilter, type ComboboxHighlightDetails, type ComboboxHighlightReason, type ComboboxInputGroupProps, type ComboboxInputProps, type ComboboxItemProps, type ComboboxListProps, type ComboboxPopupProps, type ComboboxRootProps, type ComboboxSide, type ComboboxState, type ComboboxStatusProps, type ComboboxTriggerProps, type ComboboxValue$1 as ComboboxValue, type ComboboxValueProps, defaultFilter };