1010 * governing permissions and limitations under the License.
1111 */
1212
13- import { AriaLabelingProps , BaseEvent , DOMProps , FocusableElement , Node , RefObject } from '@react-types/shared' ;
13+ import { AriaLabelingProps , BaseEvent , DOMProps , FocusableElement , FocusEvents , KeyboardEvents , Node , RefObject , ValueBase } from '@react-types/shared' ;
1414import { AriaTextFieldProps } from '@react-aria/textfield' ;
1515import { AutocompleteProps , AutocompleteState } from '@react-stately/autocomplete' ;
1616import { CLEAR_FOCUS_EVENT , FOCUS_EVENT , getActiveElement , getOwnerDocument , isAndroid , isCtrlKeyPressed , isIOS , mergeProps , mergeRefs , useEffectEvent , useEvent , useLabels , useObjectRef , useSlotId } from '@react-aria/utils' ;
@@ -28,6 +28,12 @@ export interface CollectionOptions extends DOMProps, AriaLabelingProps {
2828 disallowTypeAhead : boolean
2929}
3030
31+ export interface InputProps < T = FocusableElement > extends DOMProps ,
32+ FocusEvents < T > ,
33+ KeyboardEvents ,
34+ Pick < ValueBase < string > , 'onChange' | 'value' > ,
35+ Pick < AriaTextFieldProps , 'enterKeyHint' | 'aria-controls' | 'aria-autocomplete' | 'aria-activedescendant' | 'spellCheck' | 'autoCorrect' | 'autoComplete' > { }
36+
3137export interface AriaAutocompleteProps < T > extends AutocompleteProps {
3238 /**
3339 * An optional filter function used to determine if a option should be included in the autocomplete list.
@@ -57,8 +63,8 @@ export interface AriaAutocompleteOptions<T> extends Omit<AriaAutocompleteProps<T
5763}
5864
5965export interface AutocompleteAria < T > {
60- /** Props for the autocomplete textfield/searchfield element. These should be passed to the textfield/searchfield aria hooks respectively. */
61- textFieldProps : AriaTextFieldProps < FocusableElement > ,
66+ /** Props for the autocomplete input element. These should be passed to the input's aria hooks (e.g. useTextField/useSearchField/etc) respectively. */
67+ inputProps : InputProps ,
6268 /** Props for the collection, to be passed to collection's respective aria hook (e.g. useMenu). */
6369 collectionProps : CollectionOptions ,
6470 /** Ref to attach to the wrapped collection. */
@@ -368,7 +374,7 @@ export function useAutocomplete<T>(props: AriaAutocompleteOptions<T>, state: Aut
368374
369375 // Only apply the autocomplete specific behaviors if the collection component wrapped by it is actually
370376 // being filtered/allows filtering by the Autocomplete.
371- let textFieldProps = {
377+ let inputProps = {
372378 value : state . inputValue ,
373379 onChange
374380 } as AriaTextFieldProps < FocusableElement > ;
@@ -381,8 +387,8 @@ export function useAutocomplete<T>(props: AriaAutocompleteOptions<T>, state: Aut
381387 } ;
382388
383389 if ( collectionId ) {
384- textFieldProps = {
385- ...textFieldProps ,
390+ inputProps = {
391+ ...inputProps ,
386392 ...( shouldUseVirtualFocus && virtualFocusProps ) ,
387393 enterKeyHint : 'go' ,
388394 'aria-controls' : collectionId ,
@@ -397,7 +403,7 @@ export function useAutocomplete<T>(props: AriaAutocompleteOptions<T>, state: Aut
397403 }
398404
399405 return {
400- textFieldProps ,
406+ inputProps ,
401407 collectionProps : mergeProps ( collectionProps , {
402408 shouldUseVirtualFocus,
403409 disallowTypeAhead : true
0 commit comments