@baseline-ui/core 0.59.0 → 0.60.1

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,708 @@
1
+ import { ReactNode, ClipboardEventHandler, CompositionEventHandler, ReactEventHandler, FormEventHandler, AriaAttributes, DOMAttributes as DOMAttributes$1, AriaRole, CSSProperties, MouseEvent, FocusEvent, SyntheticEvent, KeyboardEvent as KeyboardEvent$1, JSX, HTMLAttributes, RefObject, LabelHTMLAttributes, ElementType, JSXElementConstructor, ButtonHTMLAttributes, AnchorHTMLAttributes, InputHTMLAttributes } from 'react';
2
+
3
+ /*
4
+ * Copyright 2020 Adobe. All rights reserved.
5
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License. You may obtain a copy
7
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
+ * OF ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ */
14
+
15
+
16
+
17
+ type ValidationState = 'valid' | 'invalid';
18
+
19
+ type ValidationError = string | string[];
20
+
21
+ interface Validation<T = unknown> {
22
+ /** Whether user input is required on the input before form submission. */
23
+ isRequired?: boolean,
24
+ /** Whether the input value is invalid. */
25
+ isInvalid?: boolean,
26
+ /** @deprecated Use `isInvalid` instead. */
27
+ validationState?: ValidationState,
28
+ /**
29
+ * Whether to use native HTML form validation to prevent form submission
30
+ * when the value is missing or invalid, or mark the field as required
31
+ * or invalid via ARIA.
32
+ * @default 'aria'
33
+ */
34
+ validationBehavior?: 'aria' | 'native',
35
+ /**
36
+ * A function that returns an error message if a given value is invalid.
37
+ * Validation errors are displayed to the user when the form is submitted
38
+ * if `validationBehavior="native"`. For realtime validation, use the `isInvalid`
39
+ * prop instead.
40
+ */
41
+ validate?: (value: T) => ValidationError | true | null | undefined
42
+ }
43
+
44
+ interface ValidationResult {
45
+ /** Whether the input value is invalid. */
46
+ isInvalid: boolean,
47
+ /** The current error messages for the input if it is invalid, otherwise an empty array. */
48
+ validationErrors: string[],
49
+ /** The native validation details for the input. */
50
+ validationDetails: ValidityState
51
+ }
52
+
53
+ interface InputBase {
54
+ /** Whether the input is disabled. */
55
+ isDisabled?: boolean,
56
+ /** Whether the input can be selected but not changed by the user. */
57
+ isReadOnly?: boolean
58
+ }
59
+
60
+ interface ValueBase<T, C = T> {
61
+ /** The current value (controlled). */
62
+ value?: T,
63
+ /** The default value (uncontrolled). */
64
+ defaultValue?: T,
65
+ /** Handler that is called when the value changes. */
66
+ onChange?: (value: C) => void
67
+ }
68
+
69
+ interface TextInputBase {
70
+ /** Temporary text that occupies the text input when it is empty. */
71
+ placeholder?: string
72
+ }
73
+
74
+ interface HelpTextProps {
75
+ /** A description for the field. Provides a hint such as specific requirements for what to choose. */
76
+ description?: ReactNode,
77
+ /** An error message for the field. */
78
+ errorMessage?: ReactNode | ((v: ValidationResult) => ReactNode)
79
+ }
80
+
81
+ /*
82
+ * Copyright 2020 Adobe. All rights reserved.
83
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
84
+ * you may not use this file except in compliance with the License. You may obtain a copy
85
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
86
+ *
87
+ * Unless required by applicable law or agreed to in writing, software distributed under
88
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
89
+ * OF ANY KIND, either express or implied. See the License for the specific language
90
+ * governing permissions and limitations under the License.
91
+ */
92
+
93
+
94
+
95
+ interface AriaLabelingProps {
96
+ /**
97
+ * Defines a string value that labels the current element.
98
+ */
99
+ 'aria-label'?: string,
100
+
101
+ /**
102
+ * Identifies the element (or elements) that labels the current element.
103
+ */
104
+ 'aria-labelledby'?: string,
105
+
106
+ /**
107
+ * Identifies the element (or elements) that describes the object.
108
+ */
109
+ 'aria-describedby'?: string,
110
+
111
+ /**
112
+ * Identifies the element (or elements) that provide a detailed, extended description for the object.
113
+ */
114
+ 'aria-details'?: string
115
+ }
116
+
117
+ interface AriaValidationProps {
118
+ // https://www.w3.org/TR/wai-aria-1.2/#aria-errormessage
119
+ /**
120
+ * Identifies the element that provides an error message for the object.
121
+ */
122
+ 'aria-errormessage'?: string
123
+ }
124
+
125
+ // A set of common DOM props that are allowed on any component
126
+ // Ensure this is synced with DOMPropNames in filterDOMProps
127
+ interface DOMProps {
128
+ /**
129
+ * The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id).
130
+ */
131
+ id?: string
132
+ }
133
+
134
+ interface FocusableDOMProps extends DOMProps {
135
+ /**
136
+ * Whether to exclude the element from the sequential tab order. If true,
137
+ * the element will not be focusable via the keyboard by tabbing. This should
138
+ * be avoided except in rare scenarios where an alternative means of accessing
139
+ * the element or its functionality via the keyboard is available.
140
+ */
141
+ excludeFromTabOrder?: boolean
142
+ }
143
+
144
+
145
+ interface TextInputDOMEvents {
146
+ // Clipboard events
147
+ /**
148
+ * Handler that is called when the user copies text. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/oncopy).
149
+ */
150
+ onCopy?: ClipboardEventHandler<HTMLInputElement>,
151
+
152
+ /**
153
+ * Handler that is called when the user cuts text. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/oncut).
154
+ */
155
+ onCut?: ClipboardEventHandler<HTMLInputElement>,
156
+
157
+ /**
158
+ * Handler that is called when the user pastes text. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/onpaste).
159
+ */
160
+ onPaste?: ClipboardEventHandler<HTMLInputElement>,
161
+
162
+ // Composition events
163
+ /**
164
+ * Handler that is called when a text composition system starts a new text composition session. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/compositionstart_event).
165
+ */
166
+ onCompositionStart?: CompositionEventHandler<HTMLInputElement>,
167
+
168
+ /**
169
+ * Handler that is called when a text composition system completes or cancels the current text composition session. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/compositionend_event).
170
+ */
171
+ onCompositionEnd?: CompositionEventHandler<HTMLInputElement>,
172
+
173
+ /**
174
+ * Handler that is called when a new character is received in the current text composition session. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/compositionupdate_event).
175
+ */
176
+ onCompositionUpdate?: CompositionEventHandler<HTMLInputElement>,
177
+
178
+ // Selection events
179
+ /**
180
+ * Handler that is called when text in the input is selected. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/select_event).
181
+ */
182
+ onSelect?: ReactEventHandler<HTMLInputElement>,
183
+
184
+ // Input events
185
+ /**
186
+ * Handler that is called when the input value is about to be modified. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/beforeinput_event).
187
+ */
188
+ onBeforeInput?: FormEventHandler<HTMLInputElement>,
189
+ /**
190
+ * Handler that is called when the input value is modified. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/input_event).
191
+ */
192
+ onInput?: FormEventHandler<HTMLInputElement>
193
+ }
194
+
195
+ interface InputDOMProps {
196
+ /**
197
+ * The name of the input element, used when submitting an HTML form. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefname).
198
+ */
199
+ name?: string,
200
+ /**
201
+ * The `<form>` element to associate the input with.
202
+ * The value of this attribute must be the id of a `<form>` in the same document.
203
+ * See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#form).
204
+ */
205
+ form?: string
206
+ }
207
+
208
+ // DOM props that apply to all text inputs
209
+ // Ensure this is synced with useTextField
210
+ interface TextInputDOMProps extends DOMProps, InputDOMProps, TextInputDOMEvents {
211
+ /**
212
+ * Describes the type of autocomplete functionality the input should provide if any. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefautocomplete).
213
+ */
214
+ autoComplete?: string,
215
+
216
+ /**
217
+ * The maximum number of characters supported by the input. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefmaxlength).
218
+ */
219
+ maxLength?: number,
220
+
221
+ /**
222
+ * The minimum number of characters required by the input. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefminlength).
223
+ */
224
+ minLength?: number,
225
+
226
+ /**
227
+ * Regex pattern that the value of the input must match to be valid. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefpattern).
228
+ */
229
+ pattern?: string,
230
+
231
+ /**
232
+ * Content that appears in the input when it is empty. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefplaceholder).
233
+ */
234
+ placeholder?: string,
235
+
236
+ /**
237
+ * The type of input to render. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdeftype).
238
+ * @default 'text'
239
+ */
240
+ type?: 'text' | 'search' | 'url' | 'tel' | 'email' | 'password' | (string & {}),
241
+
242
+ /**
243
+ * Hints at the type of data that might be entered by the user while editing the element or its contents. See [MDN](https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute).
244
+ */
245
+ inputMode?: 'none' | 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search',
246
+
247
+ /**
248
+ * An attribute that takes as its value a space-separated string that describes what, if any, type of autocomplete functionality the input should provide. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#autocomplete).
249
+ */
250
+ autoCorrect?: string,
251
+
252
+ /**
253
+ * An enumerated attribute that defines whether the element may be checked for spelling errors. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/spellcheck).
254
+ */
255
+ spellCheck?: string
256
+ }
257
+
258
+ /** Any focusable element, including both HTML and SVG elements. */
259
+ interface FocusableElement extends Element, HTMLOrSVGElement {}
260
+
261
+ /** All DOM attributes supported across both HTML and SVG elements. */
262
+ interface DOMAttributes<T = FocusableElement> extends AriaAttributes, DOMAttributes$1<T> {
263
+ id?: string | undefined,
264
+ role?: AriaRole | undefined,
265
+ tabIndex?: number | undefined,
266
+ style?: CSSProperties | undefined,
267
+ className?: string | undefined
268
+ }
269
+
270
+ /*
271
+ * Copyright 2020 Adobe. All rights reserved.
272
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
273
+ * you may not use this file except in compliance with the License. You may obtain a copy
274
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
275
+ *
276
+ * Unless required by applicable law or agreed to in writing, software distributed under
277
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
278
+ * OF ANY KIND, either express or implied. See the License for the specific language
279
+ * governing permissions and limitations under the License.
280
+ */
281
+
282
+
283
+
284
+ type DropOperation = 'copy' | 'link' | 'move' | 'cancel';
285
+
286
+ type DropPosition = 'on' | 'before' | 'after';
287
+
288
+ interface ItemDropTarget {
289
+ /** The drop target type. */
290
+ type: 'item',
291
+ /** The item key. */
292
+ key: Key,
293
+ /** The drop position relative to the item. */
294
+ dropPosition: DropPosition
295
+ }
296
+
297
+ interface DroppableCollectionReorderEvent {
298
+ /** The keys of the items that were reordered. */
299
+ keys: Set<Key>,
300
+ /** The drop operation that should occur. */
301
+ dropOperation: DropOperation,
302
+ /** The drop target. */
303
+ target: ItemDropTarget
304
+ }
305
+
306
+ /*
307
+ * Copyright 2020 Adobe. All rights reserved.
308
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
309
+ * you may not use this file except in compliance with the License. You may obtain a copy
310
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
311
+ *
312
+ * Unless required by applicable law or agreed to in writing, software distributed under
313
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
314
+ * OF ANY KIND, either express or implied. See the License for the specific language
315
+ * governing permissions and limitations under the License.
316
+ */
317
+
318
+
319
+
320
+ // Event bubbling can be problematic in real-world applications, so the default for React Spectrum components
321
+ // is not to propagate. This can be overridden by calling continuePropagation() on the event.
322
+ type BaseEvent<T extends SyntheticEvent> = T & {
323
+ /**
324
+ * Use continuePropagation.
325
+ * @deprecated */
326
+ stopPropagation(): void,
327
+ continuePropagation(): void
328
+ }
329
+
330
+ type KeyboardEvent = BaseEvent<KeyboardEvent$1<any>>;
331
+
332
+ type PointerType = 'mouse' | 'pen' | 'touch' | 'keyboard' | 'virtual';
333
+
334
+ interface PressEvent {
335
+ /** The type of press event being fired. */
336
+ type: 'pressstart' | 'pressend' | 'pressup' | 'press',
337
+ /** The pointer type that triggered the press event. */
338
+ pointerType: PointerType,
339
+ /** The target element of the press event. */
340
+ target: Element,
341
+ /** Whether the shift keyboard modifier was held during the press event. */
342
+ shiftKey: boolean,
343
+ /** Whether the ctrl keyboard modifier was held during the press event. */
344
+ ctrlKey: boolean,
345
+ /** Whether the meta keyboard modifier was held during the press event. */
346
+ metaKey: boolean,
347
+ /** Whether the alt keyboard modifier was held during the press event. */
348
+ altKey: boolean,
349
+ /** X position relative to the target. */
350
+ x: number,
351
+ /** Y position relative to the target. */
352
+ y: number,
353
+ /**
354
+ * The key that triggered the press event, if it was triggered by a keyboard interaction.
355
+ * This is useful for differentiating between Space and Enter key presses.
356
+ */
357
+ key?: string,
358
+ /**
359
+ * By default, press events stop propagation to parent elements.
360
+ * In cases where a handler decides not to handle a specific event,
361
+ * it can call `continuePropagation()` to allow a parent to handle it.
362
+ */
363
+ continuePropagation(): void
364
+ }
365
+
366
+ interface KeyboardEvents {
367
+ /** Handler that is called when a key is pressed. */
368
+ onKeyDown?: (e: KeyboardEvent) => void,
369
+ /** Handler that is called when a key is released. */
370
+ onKeyUp?: (e: KeyboardEvent) => void
371
+ }
372
+
373
+ interface FocusEvents<Target = Element> {
374
+ /** Handler that is called when the element receives focus. */
375
+ onFocus?: (e: FocusEvent<Target>) => void,
376
+ /** Handler that is called when the element loses focus. */
377
+ onBlur?: (e: FocusEvent<Target>) => void,
378
+ /** Handler that is called when the element's focus status changes. */
379
+ onFocusChange?: (isFocused: boolean) => void
380
+ }
381
+
382
+ interface PressEvents {
383
+ /** Handler that is called when the press is released over the target. */
384
+ onPress?: (e: PressEvent) => void,
385
+ /** Handler that is called when a press interaction starts. */
386
+ onPressStart?: (e: PressEvent) => void,
387
+ /**
388
+ * Handler that is called when a press interaction ends, either
389
+ * over the target or when the pointer leaves the target.
390
+ */
391
+ onPressEnd?: (e: PressEvent) => void,
392
+ /** Handler that is called when the press state changes. */
393
+ onPressChange?: (isPressed: boolean) => void,
394
+ /**
395
+ * Handler that is called when a press is released over the target, regardless of
396
+ * whether it started on the target or not.
397
+ */
398
+ onPressUp?: (e: PressEvent) => void,
399
+ /**
400
+ * **Not recommended – use `onPress` instead.** `onClick` is an alias for `onPress`
401
+ * provided for compatibility with other libraries. `onPress` provides
402
+ * additional event details for non-mouse interactions.
403
+ */
404
+ onClick?: (e: MouseEvent<FocusableElement>) => void
405
+ }
406
+
407
+ interface FocusableProps<Target = Element> extends FocusEvents<Target>, KeyboardEvents {
408
+ /** Whether the element should receive focus on render. */
409
+ autoFocus?: boolean
410
+ }
411
+
412
+ /*
413
+ * Copyright 2020 Adobe. All rights reserved.
414
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
415
+ * you may not use this file except in compliance with the License. You may obtain a copy
416
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
417
+ *
418
+ * Unless required by applicable law or agreed to in writing, software distributed under
419
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
420
+ * OF ANY KIND, either express or implied. See the License for the specific language
421
+ * governing permissions and limitations under the License.
422
+ */
423
+
424
+
425
+
426
+ interface LabelableProps {
427
+ /** The content to display as the label. */
428
+ label?: ReactNode
429
+ }
430
+
431
+ /*
432
+ * Copyright 2023 Adobe. All rights reserved.
433
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
434
+ * you may not use this file except in compliance with the License. You may obtain a copy
435
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
436
+ *
437
+ * Unless required by applicable law or agreed to in writing, software distributed under
438
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
439
+ * OF ANY KIND, either express or implied. See the License for the specific language
440
+ * governing permissions and limitations under the License.
441
+ */
442
+
443
+ type Key = string | number;
444
+
445
+ /**
446
+ * A map of HTML element names and their interface types.
447
+ * For example `'a'` -> `HTMLAnchorElement`.
448
+ */
449
+ type IntrinsicHTMLElements = {
450
+ [K in keyof IntrinsicHTMLAttributes]: IntrinsicHTMLAttributes[K] extends HTMLAttributes<infer T> ? T : never;
451
+ };
452
+ /**
453
+ * A map of HTML element names and their attribute interface types.
454
+ * For example `'a'` -> `AnchorHTMLAttributes<HTMLAnchorElement>`.
455
+ */
456
+ type IntrinsicHTMLAttributes = JSX.IntrinsicElements;
457
+ type DefaultElementType = 'input';
458
+ /**
459
+ * The intrinsic HTML element names that `useTextField` supports; e.g. `input`,
460
+ * `textarea`.
461
+ */
462
+ type TextFieldIntrinsicElements = keyof Pick<IntrinsicHTMLElements, 'input' | 'textarea'>;
463
+ /**
464
+ * The HTML element interfaces that `useTextField` supports based on what is
465
+ * defined for `TextFieldIntrinsicElements`; e.g. `HTMLInputElement`,
466
+ * `HTMLTextAreaElement`.
467
+ */
468
+ type TextFieldHTMLElementType = Pick<IntrinsicHTMLElements, TextFieldIntrinsicElements>;
469
+ /**
470
+ * The HTML attributes interfaces that `useTextField` supports based on what
471
+ * is defined for `TextFieldIntrinsicElements`; e.g. `InputHTMLAttributes`,
472
+ * `TextareaHTMLAttributes`.
473
+ */
474
+ type TextFieldHTMLAttributesType = Pick<IntrinsicHTMLAttributes, TextFieldIntrinsicElements>;
475
+ /**
476
+ * The type of `inputProps` returned by `useTextField`; e.g. `InputHTMLAttributes`,
477
+ * `TextareaHTMLAttributes`.
478
+ */
479
+ type TextFieldInputProps<T extends TextFieldIntrinsicElements> = TextFieldHTMLAttributesType[T];
480
+ interface TextFieldProps<T = HTMLInputElement> extends InputBase, Validation<string>, HelpTextProps, FocusableProps<T>, TextInputBase, ValueBase<string>, LabelableProps {
481
+ }
482
+ interface AriaTextFieldProps<T = HTMLInputElement> extends TextFieldProps<T>, AriaLabelingProps, FocusableDOMProps, TextInputDOMProps, AriaValidationProps {
483
+ /** Identifies the currently active element when DOM focus is on a composite widget, textbox, group, or application. */
484
+ 'aria-activedescendant'?: string;
485
+ /**
486
+ * Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be
487
+ * presented if they are made.
488
+ */
489
+ 'aria-autocomplete'?: 'none' | 'inline' | 'list' | 'both';
490
+ /** Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element. */
491
+ 'aria-haspopup'?: boolean | 'false' | 'true' | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog';
492
+ /** Identifies the element (or elements) whose contents or presence are controlled by the current element. */
493
+ 'aria-controls'?: string;
494
+ /**
495
+ * An enumerated attribute that defines what action label or icon to preset for the enter key on virtual keyboards. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/enterkeyhint).
496
+ */
497
+ enterKeyHint?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send';
498
+ }
499
+ interface AriaTextFieldOptions<T extends TextFieldIntrinsicElements> extends AriaTextFieldProps<TextFieldHTMLElementType[T]> {
500
+ /**
501
+ * The HTML element used to render the input, e.g. 'input', or 'textarea'.
502
+ * It determines whether certain HTML attributes will be included in `inputProps`.
503
+ * For example, [`type`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-type).
504
+ * @default 'input'
505
+ */
506
+ inputElementType?: T;
507
+ /**
508
+ * Controls whether inputted text is automatically capitalized and, if so, in what manner.
509
+ * See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/autocapitalize).
510
+ */
511
+ autoCapitalize?: 'off' | 'none' | 'on' | 'sentences' | 'words' | 'characters';
512
+ /**
513
+ * An enumerated attribute that defines what action label or icon to preset for the enter key on virtual keyboards. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/enterkeyhint).
514
+ */
515
+ enterKeyHint?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send';
516
+ }
517
+ /**
518
+ * The type of `ref` object that can be passed to `useTextField` based on the given
519
+ * intrinsic HTML element name; e.g.`RefObject<HTMLInputElement>`,
520
+ * `RefObject<HTMLTextAreaElement>`.
521
+ */
522
+ type TextFieldRefObject<T extends TextFieldIntrinsicElements> = RefObject<TextFieldHTMLElementType[T] | null>;
523
+ interface TextFieldAria<T extends TextFieldIntrinsicElements = DefaultElementType> extends ValidationResult {
524
+ /** Props for the input element. */
525
+ inputProps: TextFieldInputProps<T>;
526
+ /** Props for the text field's visible label element, if any. */
527
+ labelProps: DOMAttributes | LabelHTMLAttributes<HTMLLabelElement>;
528
+ /** Props for the text field's description element, if any. */
529
+ descriptionProps: DOMAttributes;
530
+ /** Props for the text field's error message element, if any. */
531
+ errorMessageProps: DOMAttributes;
532
+ }
533
+ /**
534
+ * Provides the behavior and accessibility implementation for a text field.
535
+ * @param props - Props for the text field.
536
+ * @param ref - Ref to the HTML input or textarea element.
537
+ */
538
+ declare function useTextField<T extends TextFieldIntrinsicElements = DefaultElementType>(props: AriaTextFieldOptions<T>, ref: TextFieldRefObject<T>): TextFieldAria<T>;
539
+
540
+ interface ButtonProps extends PressEvents, FocusableProps {
541
+ /** Whether the button is disabled. */
542
+ isDisabled?: boolean;
543
+ /** The content to display in the button. */
544
+ children?: ReactNode;
545
+ }
546
+ interface AriaBaseButtonProps extends FocusableDOMProps, AriaLabelingProps {
547
+ /** Indicates whether the element is disabled to users of assistive technology. */
548
+ 'aria-disabled'?: boolean | 'true' | 'false';
549
+ /** Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed. */
550
+ 'aria-expanded'?: boolean | 'true' | 'false';
551
+ /** Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element. */
552
+ 'aria-haspopup'?: boolean | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog' | 'true' | 'false';
553
+ /** Identifies the element (or elements) whose contents or presence are controlled by the current element. */
554
+ 'aria-controls'?: string;
555
+ /** Indicates the current "pressed" state of toggle buttons. */
556
+ 'aria-pressed'?: boolean | 'true' | 'false' | 'mixed';
557
+ /** Indicates whether this element represents the current item within a container or set of related elements. */
558
+ 'aria-current'?: boolean | 'true' | 'false' | 'page' | 'step' | 'location' | 'date' | 'time';
559
+ /**
560
+ * The behavior of the button when used in an HTML form.
561
+ * @default 'button'
562
+ */
563
+ type?: 'button' | 'submit' | 'reset';
564
+ /**
565
+ * Whether to prevent focus from moving to the button when pressing it.
566
+ *
567
+ * Caution, this can make the button inaccessible and should only be used when alternative keyboard interaction is provided,
568
+ * such as ComboBox's MenuTrigger or a NumberField's increment/decrement control.
569
+ */
570
+ preventFocusOnPress?: boolean;
571
+ /**
572
+ * The `<form>` element to associate the button with.
573
+ * The value of this attribute must be the id of a `<form>` in the same document.
574
+ * See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/button#form).
575
+ */
576
+ form?: string;
577
+ /**
578
+ * The URL that processes the information submitted by the button.
579
+ * Overrides the action attribute of the button's form owner.
580
+ */
581
+ formAction?: ButtonHTMLAttributes<HTMLButtonElement>['formAction'];
582
+ /** Indicates how to encode the form data that is submitted. */
583
+ formEncType?: string;
584
+ /** Indicates the HTTP method used to submit the form. */
585
+ formMethod?: string;
586
+ /** Indicates that the form is not to be validated when it is submitted. */
587
+ formNoValidate?: boolean;
588
+ /** Overrides the target attribute of the button's form owner. */
589
+ formTarget?: string;
590
+ /** Submitted as a pair with the button's value as part of the form data. */
591
+ name?: string;
592
+ /** The value associated with the button's name when it's submitted with the form data. */
593
+ value?: string;
594
+ }
595
+ interface AriaButtonElementTypeProps<T extends ElementType = 'button'> {
596
+ /**
597
+ * The HTML element or React element used to render the button, e.g. 'div', 'a', or `RouterLink`.
598
+ * @default 'button'
599
+ */
600
+ elementType?: T | JSXElementConstructor<any>;
601
+ }
602
+ interface LinkButtonProps<T extends ElementType = 'button'> extends AriaButtonElementTypeProps<T> {
603
+ /** A URL to link to if elementType="a". */
604
+ href?: string;
605
+ /** The target window for the link. */
606
+ target?: string;
607
+ /** The relationship between the linked resource and the current page. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel). */
608
+ rel?: string;
609
+ }
610
+ interface AriaButtonProps<T extends ElementType = 'button'> extends ButtonProps, LinkButtonProps<T>, AriaBaseButtonProps {
611
+ }
612
+ interface AriaButtonOptions<E extends ElementType> extends Omit<AriaButtonProps<E>, 'children'> {
613
+ }
614
+ interface ButtonAria<T> {
615
+ /** Props for the button element. */
616
+ buttonProps: T;
617
+ /** Whether the button is currently pressed. */
618
+ isPressed: boolean;
619
+ }
620
+ declare function useButton(props: AriaButtonOptions<'button'>, ref: RefObject<HTMLButtonElement | null>): ButtonAria<ButtonHTMLAttributes<HTMLButtonElement>>;
621
+ declare function useButton(props: AriaButtonOptions<'a'>, ref: RefObject<HTMLAnchorElement | null>): ButtonAria<AnchorHTMLAttributes<HTMLAnchorElement>>;
622
+ declare function useButton(props: AriaButtonOptions<'div'>, ref: RefObject<HTMLDivElement | null>): ButtonAria<HTMLAttributes<HTMLDivElement>>;
623
+ declare function useButton(props: AriaButtonOptions<'input'>, ref: RefObject<HTMLInputElement | null>): ButtonAria<InputHTMLAttributes<HTMLInputElement>>;
624
+ declare function useButton(props: AriaButtonOptions<'span'>, ref: RefObject<HTMLSpanElement | null>): ButtonAria<HTMLAttributes<HTMLSpanElement>>;
625
+ declare function useButton(props: AriaButtonOptions<ElementType>, ref: RefObject<Element | null>): ButtonAria<DOMAttributes>;
626
+
627
+ interface FocusManagerOptions {
628
+ /** The element to start searching from. The currently focused element by default. */
629
+ from?: Element;
630
+ /** Whether to only include tabbable elements, or all focusable elements. */
631
+ tabbable?: boolean;
632
+ /** Whether focus should wrap around when it reaches the end of the scope. */
633
+ wrap?: boolean;
634
+ /** A callback that determines whether the given element is focused. */
635
+ accept?: (node: Element) => boolean;
636
+ }
637
+ interface FocusManager {
638
+ /** Moves focus to the next focusable or tabbable element in the focus scope. */
639
+ focusNext(opts?: FocusManagerOptions): FocusableElement | null;
640
+ /** Moves focus to the previous focusable or tabbable element in the focus scope. */
641
+ focusPrevious(opts?: FocusManagerOptions): FocusableElement | null;
642
+ /** Moves focus to the first focusable or tabbable element in the focus scope. */
643
+ focusFirst(opts?: FocusManagerOptions): FocusableElement | null;
644
+ /** Moves focus to the last focusable or tabbable element in the focus scope. */
645
+ focusLast(opts?: FocusManagerOptions): FocusableElement | null;
646
+ }
647
+ /**
648
+ * Returns a FocusManager interface for the parent FocusScope.
649
+ * A FocusManager can be used to programmatically move focus within
650
+ * a FocusScope, e.g. in response to user events like keyboard navigation.
651
+ */
652
+ declare function useFocusManager(): FocusManager | undefined;
653
+
654
+ interface FocusWithinProps {
655
+ /** Whether the focus within events should be disabled. */
656
+ isDisabled?: boolean;
657
+ /** Handler that is called when the target element or a descendant receives focus. */
658
+ onFocusWithin?: (e: FocusEvent) => void;
659
+ /** Handler that is called when the target element and all descendants lose focus. */
660
+ onBlurWithin?: (e: FocusEvent) => void;
661
+ /** Handler that is called when the the focus within state changes. */
662
+ onFocusWithinChange?: (isFocusWithin: boolean) => void;
663
+ }
664
+ interface FocusWithinResult {
665
+ /** Props to spread onto the target element. */
666
+ focusWithinProps: DOMAttributes;
667
+ }
668
+ /**
669
+ * Handles focus events for the target and its descendants.
670
+ */
671
+ declare function useFocusWithin(props: FocusWithinProps): FocusWithinResult;
672
+
673
+ interface SelectableItemStates {
674
+ /** Whether the item is currently in a pressed state. */
675
+ isPressed: boolean;
676
+ /** Whether the item is currently selected. */
677
+ isSelected: boolean;
678
+ /** Whether the item is currently focused. */
679
+ isFocused: boolean;
680
+ /**
681
+ * Whether the item is non-interactive, i.e. both selection and actions are disabled and the item may
682
+ * not be focused. Dependent on `disabledKeys` and `disabledBehavior`.
683
+ */
684
+ isDisabled: boolean;
685
+ /**
686
+ * Whether the item may be selected, dependent on `selectionMode`, `disabledKeys`, and `disabledBehavior`.
687
+ */
688
+ allowsSelection: boolean;
689
+ /**
690
+ * Whether the item has an action, dependent on `onAction`, `disabledKeys`,
691
+ * and `disabledBehavior`. It may also change depending on the current selection state
692
+ * of the list (e.g. when selection is primary). This can be used to enable or disable hover
693
+ * styles or other visual indications of interactivity.
694
+ */
695
+ hasAction: boolean;
696
+ }
697
+
698
+ interface GridListItemAria extends SelectableItemStates {
699
+ /** Props for the list row element. */
700
+ rowProps: DOMAttributes;
701
+ /** Props for the grid cell element within the list row. */
702
+ gridCellProps: DOMAttributes;
703
+ /** Props for the list item description element, if any. */
704
+ descriptionProps: DOMAttributes;
705
+ }
706
+
707
+ export { useButton, useFocusManager, useFocusWithin, useTextField };
708
+ export type { AriaButtonProps, AriaTextFieldOptions, DroppableCollectionReorderEvent, GridListItemAria };