@react-aria/autocomplete 3.0.0-alpha.15 → 3.0.0-alpha.17

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.
package/dist/import.mjs CHANGED
@@ -26,8 +26,8 @@ import {useSearchField as $fgZRc$useSearchField} from "@react-aria/searchfield";
26
26
 
27
27
 
28
28
  function $c04f11f368135585$export$da7ade746446be1f(props, state) {
29
- let { popoverRef: popoverRef , inputRef: inputRef , listBoxRef: listBoxRef , keyboardDelegate: keyboardDelegate , onSubmit: onSubmit = ()=>{} , onClear: onClear } = props;
30
- let { inputProps: inputProps , clearButtonProps: clearButtonProps } = (0, $fgZRc$useSearchField)({
29
+ let { popoverRef: popoverRef , inputRef: inputRef , listBoxRef: listBoxRef , keyboardDelegate: keyboardDelegate , onSubmit: onSubmit = ()=>{} , onClear: onClear , onKeyDown: onKeyDown , onKeyUp: onKeyUp } = props;
30
+ let { inputProps: inputProps , clearButtonProps: clearButtonProps , descriptionProps: descriptionProps , errorMessageProps: errorMessageProps } = (0, $fgZRc$useSearchField)({
31
31
  ...props,
32
32
  value: state.inputValue,
33
33
  onChange: state.setInputValue,
@@ -39,7 +39,9 @@ function $c04f11f368135585$export$da7ade746446be1f(props, state) {
39
39
  onSubmit: (value)=>{
40
40
  // Prevent submission from search field if menu item was selected
41
41
  if (state.selectionManager.focusedKey === null) onSubmit(value, null);
42
- }
42
+ },
43
+ onKeyDown: onKeyDown,
44
+ onKeyUp: onKeyUp
43
45
  }, {
44
46
  value: state.inputValue,
45
47
  setValue: state.setInputValue
@@ -51,13 +53,18 @@ function $c04f11f368135585$export$da7ade746446be1f(props, state) {
51
53
  listBoxRef: listBoxRef,
52
54
  inputRef: inputRef,
53
55
  onFocus: undefined,
54
- onBlur: undefined
56
+ onFocusChange: undefined,
57
+ onBlur: undefined,
58
+ onKeyDown: undefined,
59
+ onKeyUp: undefined
55
60
  }, state);
56
61
  return {
57
62
  labelProps: labelProps,
58
63
  inputProps: (0, $fgZRc$mergeProps)(inputProps, comboBoxInputProps),
59
64
  listBoxProps: listBoxProps,
60
- clearButtonProps: clearButtonProps
65
+ clearButtonProps: clearButtonProps,
66
+ descriptionProps: descriptionProps,
67
+ errorMessageProps: errorMessageProps
61
68
  };
62
69
  }
63
70
 
package/dist/main.js CHANGED
@@ -31,8 +31,8 @@ $parcel$export(module.exports, "useSearchAutocomplete", () => $3c40871f8cc2eb01$
31
31
 
32
32
 
33
33
  function $3c40871f8cc2eb01$export$da7ade746446be1f(props, state) {
34
- let { popoverRef: popoverRef , inputRef: inputRef , listBoxRef: listBoxRef , keyboardDelegate: keyboardDelegate , onSubmit: onSubmit = ()=>{} , onClear: onClear } = props;
35
- let { inputProps: inputProps , clearButtonProps: clearButtonProps } = (0, $kDrMH$reactariasearchfield.useSearchField)({
34
+ let { popoverRef: popoverRef , inputRef: inputRef , listBoxRef: listBoxRef , keyboardDelegate: keyboardDelegate , onSubmit: onSubmit = ()=>{} , onClear: onClear , onKeyDown: onKeyDown , onKeyUp: onKeyUp } = props;
35
+ let { inputProps: inputProps , clearButtonProps: clearButtonProps , descriptionProps: descriptionProps , errorMessageProps: errorMessageProps } = (0, $kDrMH$reactariasearchfield.useSearchField)({
36
36
  ...props,
37
37
  value: state.inputValue,
38
38
  onChange: state.setInputValue,
@@ -44,7 +44,9 @@ function $3c40871f8cc2eb01$export$da7ade746446be1f(props, state) {
44
44
  onSubmit: (value)=>{
45
45
  // Prevent submission from search field if menu item was selected
46
46
  if (state.selectionManager.focusedKey === null) onSubmit(value, null);
47
- }
47
+ },
48
+ onKeyDown: onKeyDown,
49
+ onKeyUp: onKeyUp
48
50
  }, {
49
51
  value: state.inputValue,
50
52
  setValue: state.setInputValue
@@ -56,13 +58,18 @@ function $3c40871f8cc2eb01$export$da7ade746446be1f(props, state) {
56
58
  listBoxRef: listBoxRef,
57
59
  inputRef: inputRef,
58
60
  onFocus: undefined,
59
- onBlur: undefined
61
+ onFocusChange: undefined,
62
+ onBlur: undefined,
63
+ onKeyDown: undefined,
64
+ onKeyUp: undefined
60
65
  }, state);
61
66
  return {
62
67
  labelProps: labelProps,
63
68
  inputProps: (0, $kDrMH$reactariautils.mergeProps)(inputProps, comboBoxInputProps),
64
69
  listBoxProps: listBoxProps,
65
- clearButtonProps: clearButtonProps
70
+ clearButtonProps: clearButtonProps,
71
+ descriptionProps: descriptionProps,
72
+ errorMessageProps: errorMessageProps
66
73
  };
67
74
  }
68
75
 
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED;;;AAuCO,SAAS,0CAAyB,KAAqC,EAAE,KAAuB,EAA6B;IAClI,IAAI,cACF,WAAU,YACV,SAAQ,cACR,WAAU,oBACV,iBAAgB,YAChB,WAAW,IAAM,CAAC,aAClB,QAAO,EACR,GAAG;IAEJ,IAAI,cAAC,WAAU,oBAAE,iBAAgB,EAAC,GAAG,CAAA,GAAA,0CAAc,AAAD,EAAE;QAClD,GAAG,KAAK;QACR,OAAO,MAAM,UAAU;QACvB,UAAU,MAAM,aAAa;QAC7B,cAAc;QACd,SAAS,IAAM;YACb,MAAM,aAAa,CAAC;YACpB,IAAI,SACF;QAEJ;QACA,UAAU,CAAC,QAAU;YACnB,iEAAiE;YACjE,IAAI,MAAM,gBAAgB,CAAC,UAAU,KAAK,IAAI,EAC5C,SAAS,OAAO,IAAI;QAExB;IACF,GAAG;QACD,OAAO,MAAM,UAAU;QACvB,UAAU,MAAM,aAAa;IAC/B,GAAG;IAGH,IAAI,gBAAC,aAAY,cAAE,WAAU,EAAE,YAAY,mBAAkB,EAAC,GAAG,CAAA,GAAA,oCAAU,EACzE;QACE,GAAG,KAAK;0BACR;oBACA;oBACA;kBACA;QACA,SAAS;QACT,QAAQ;IACV,GACA;IAGF,OAAO;oBACL;QACA,YAAY,CAAA,GAAA,gCAAU,AAAD,EAAE,YAAY;sBACnC;0BACA;IACF;AACF;;CD7FC,GACD","sources":["packages/@react-aria/autocomplete/src/index.ts","packages/@react-aria/autocomplete/src/useSearchAutocomplete.ts"],"sourcesContent":["/*\n * Copyright 2021 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useSearchAutocomplete} from './useSearchAutocomplete';\nexport type {AriaSearchAutocompleteProps, SearchAutocompleteAria} from './useSearchAutocomplete';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '@react-types/button';\nimport {AriaListBoxOptions} from '@react-aria/listbox';\nimport {ComboBoxState} from '@react-stately/combobox';\nimport {DOMAttributes} from '@react-types/shared';\nimport {InputHTMLAttributes, RefObject} from 'react';\nimport {KeyboardDelegate} from '@react-types/shared';\nimport {mergeProps} from '@react-aria/utils';\nimport {SearchAutocompleteProps} from '@react-types/autocomplete';\nimport {useComboBox} from '@react-aria/combobox';\nimport {useSearchField} from '@react-aria/searchfield';\n\nexport interface AriaSearchAutocompleteProps<T> extends SearchAutocompleteProps<T> {\n /** The ref for the input element. */\n inputRef: RefObject<HTMLInputElement>,\n /** The ref for the list box popover. */\n popoverRef: RefObject<HTMLDivElement>,\n /** The ref for the list box. */\n listBoxRef: RefObject<HTMLElement>,\n /** An optional keyboard delegate implementation, to override the default. */\n keyboardDelegate?: KeyboardDelegate\n}\n\nexport interface SearchAutocompleteAria<T> {\n /** Props for the label element. */\n labelProps: DOMAttributes,\n /** Props for the search input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Props for the list box, to be passed to [useListBox](useListBox.html). */\n listBoxProps: AriaListBoxOptions<T>,\n /** Props for the search input's clear button. */\n clearButtonProps: AriaButtonProps\n}\n\n/**\n * Provides the behavior and accessibility implementation for a search autocomplete component.\n * A search autocomplete combines a combobox with a searchfield, allowing users to filter a list of options to items matching a query.\n * @param props - Props for the search autocomplete.\n * @param state - State for the search autocomplete, as returned by `useSearchAutocomplete`.\n */\nexport function useSearchAutocomplete<T>(props: AriaSearchAutocompleteProps<T>, state: ComboBoxState<T>): SearchAutocompleteAria<T> {\n let {\n popoverRef,\n inputRef,\n listBoxRef,\n keyboardDelegate,\n onSubmit = () => {},\n onClear\n } = props;\n\n let {inputProps, clearButtonProps} = useSearchField({\n ...props,\n value: state.inputValue,\n onChange: state.setInputValue,\n autoComplete: 'off',\n onClear: () => {\n state.setInputValue('');\n if (onClear) {\n onClear();\n }\n },\n onSubmit: (value) => {\n // Prevent submission from search field if menu item was selected\n if (state.selectionManager.focusedKey === null) {\n onSubmit(value, null);\n }\n } \n }, {\n value: state.inputValue,\n setValue: state.setInputValue\n }, inputRef);\n \n\n let {listBoxProps, labelProps, inputProps: comboBoxInputProps} = useComboBox(\n {\n ...props,\n keyboardDelegate,\n popoverRef,\n listBoxRef,\n inputRef,\n onFocus: undefined,\n onBlur: undefined\n },\n state\n );\n\n return {\n labelProps,\n inputProps: mergeProps(inputProps, comboBoxInputProps),\n listBoxProps,\n clearButtonProps\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED;;;AA0CO,SAAS,0CAAyB,KAAuC,EAAE,KAAuB,EAA6B;IACpI,IAAI,cACF,WAAU,YACV,SAAQ,cACR,WAAU,oBACV,iBAAgB,YAChB,WAAW,IAAM,CAAC,aAClB,QAAO,aACP,UAAS,WACT,QAAO,EACR,GAAG;IAEJ,IAAI,cAAC,WAAU,oBAAE,iBAAgB,oBAAE,iBAAgB,qBAAE,kBAAiB,EAAC,GAAG,CAAA,GAAA,0CAAa,EAAE;QACvF,GAAG,KAAK;QACR,OAAO,MAAM,UAAU;QACvB,UAAU,MAAM,aAAa;QAC7B,cAAc;QACd,SAAS,IAAM;YACb,MAAM,aAAa,CAAC;YACpB,IAAI,SACF;QAEJ;QACA,UAAU,CAAC,QAAU;YACnB,iEAAiE;YACjE,IAAI,MAAM,gBAAgB,CAAC,UAAU,KAAK,IAAI,EAC5C,SAAS,OAAO,IAAI;QAExB;mBACA;iBACA;IACF,GAAG;QACD,OAAO,MAAM,UAAU;QACvB,UAAU,MAAM,aAAa;IAC/B,GAAG;IAGH,IAAI,gBAAC,aAAY,cAAE,WAAU,EAAE,YAAY,mBAAkB,EAAC,GAAG,CAAA,GAAA,oCAAU,EACzE;QACE,GAAG,KAAK;0BACR;oBACA;oBACA;kBACA;QACA,SAAS;QACT,eAAe;QACf,QAAQ;QACR,WAAW;QACX,SAAS;IACX,GACA;IAGF,OAAO;oBACL;QACA,YAAY,CAAA,GAAA,gCAAU,AAAD,EAAE,YAAY;sBACnC;0BACA;0BACA;2BACA;IACF;AACF;;CDzGC,GACD","sources":["packages/@react-aria/autocomplete/src/index.ts","packages/@react-aria/autocomplete/src/useSearchAutocomplete.ts"],"sourcesContent":["/*\n * Copyright 2021 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useSearchAutocomplete} from './useSearchAutocomplete';\nexport type {AriaSearchAutocompleteOptions, SearchAutocompleteAria} from './useSearchAutocomplete';\nexport type {AriaSearchAutocompleteProps} from '@react-types/autocomplete';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '@react-types/button';\nimport {AriaListBoxOptions} from '@react-aria/listbox';\nimport {AriaSearchAutocompleteProps} from '@react-types/autocomplete';\nimport {ComboBoxState} from '@react-stately/combobox';\nimport {DOMAttributes, KeyboardDelegate} from '@react-types/shared';\nimport {InputHTMLAttributes, RefObject} from 'react';\nimport {mergeProps} from '@react-aria/utils';\nimport {useComboBox} from '@react-aria/combobox';\nimport {useSearchField} from '@react-aria/searchfield';\n\nexport interface SearchAutocompleteAria<T> {\n /** Props for the label element. */\n labelProps: DOMAttributes,\n /** Props for the search input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Props for the list box, to be passed to [useListBox](useListBox.html). */\n listBoxProps: AriaListBoxOptions<T>,\n /** Props for the search input's clear button. */\n clearButtonProps: AriaButtonProps,\n /** Props for the search autocomplete description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the search autocomplete error message element, if any. */\n errorMessageProps: DOMAttributes\n}\n\nexport interface AriaSearchAutocompleteOptions<T> extends AriaSearchAutocompleteProps<T> {\n /** The ref for the input element. */\n inputRef: RefObject<HTMLInputElement>,\n /** The ref for the list box popover. */\n popoverRef: RefObject<HTMLDivElement>,\n /** The ref for the list box. */\n listBoxRef: RefObject<HTMLElement>,\n /** An optional keyboard delegate implementation, to override the default. */\n keyboardDelegate?: KeyboardDelegate\n}\n\n/**\n * Provides the behavior and accessibility implementation for a search autocomplete component.\n * A search autocomplete combines a combobox with a searchfield, allowing users to filter a list of options to items matching a query.\n * @param props - Props for the search autocomplete.\n * @param state - State for the search autocomplete, as returned by `useSearchAutocomplete`.\n */\nexport function useSearchAutocomplete<T>(props: AriaSearchAutocompleteOptions<T>, state: ComboBoxState<T>): SearchAutocompleteAria<T> {\n let {\n popoverRef,\n inputRef,\n listBoxRef,\n keyboardDelegate,\n onSubmit = () => {},\n onClear,\n onKeyDown,\n onKeyUp\n } = props;\n\n let {inputProps, clearButtonProps, descriptionProps, errorMessageProps} = useSearchField({\n ...props,\n value: state.inputValue,\n onChange: state.setInputValue,\n autoComplete: 'off',\n onClear: () => {\n state.setInputValue('');\n if (onClear) {\n onClear();\n }\n },\n onSubmit: (value) => {\n // Prevent submission from search field if menu item was selected\n if (state.selectionManager.focusedKey === null) {\n onSubmit(value, null);\n }\n },\n onKeyDown,\n onKeyUp\n }, {\n value: state.inputValue,\n setValue: state.setInputValue\n }, inputRef);\n \n\n let {listBoxProps, labelProps, inputProps: comboBoxInputProps} = useComboBox(\n {\n ...props,\n keyboardDelegate,\n popoverRef,\n listBoxRef,\n inputRef,\n onFocus: undefined,\n onFocusChange: undefined,\n onBlur: undefined,\n onKeyDown: undefined,\n onKeyUp: undefined\n },\n state\n );\n\n return {\n labelProps,\n inputProps: mergeProps(inputProps, comboBoxInputProps),\n listBoxProps,\n clearButtonProps,\n descriptionProps,\n errorMessageProps\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -26,8 +26,8 @@ import {useSearchField as $fgZRc$useSearchField} from "@react-aria/searchfield";
26
26
 
27
27
 
28
28
  function $c04f11f368135585$export$da7ade746446be1f(props, state) {
29
- let { popoverRef: popoverRef , inputRef: inputRef , listBoxRef: listBoxRef , keyboardDelegate: keyboardDelegate , onSubmit: onSubmit = ()=>{} , onClear: onClear } = props;
30
- let { inputProps: inputProps , clearButtonProps: clearButtonProps } = (0, $fgZRc$useSearchField)({
29
+ let { popoverRef: popoverRef , inputRef: inputRef , listBoxRef: listBoxRef , keyboardDelegate: keyboardDelegate , onSubmit: onSubmit = ()=>{} , onClear: onClear , onKeyDown: onKeyDown , onKeyUp: onKeyUp } = props;
30
+ let { inputProps: inputProps , clearButtonProps: clearButtonProps , descriptionProps: descriptionProps , errorMessageProps: errorMessageProps } = (0, $fgZRc$useSearchField)({
31
31
  ...props,
32
32
  value: state.inputValue,
33
33
  onChange: state.setInputValue,
@@ -39,7 +39,9 @@ function $c04f11f368135585$export$da7ade746446be1f(props, state) {
39
39
  onSubmit: (value)=>{
40
40
  // Prevent submission from search field if menu item was selected
41
41
  if (state.selectionManager.focusedKey === null) onSubmit(value, null);
42
- }
42
+ },
43
+ onKeyDown: onKeyDown,
44
+ onKeyUp: onKeyUp
43
45
  }, {
44
46
  value: state.inputValue,
45
47
  setValue: state.setInputValue
@@ -51,13 +53,18 @@ function $c04f11f368135585$export$da7ade746446be1f(props, state) {
51
53
  listBoxRef: listBoxRef,
52
54
  inputRef: inputRef,
53
55
  onFocus: undefined,
54
- onBlur: undefined
56
+ onFocusChange: undefined,
57
+ onBlur: undefined,
58
+ onKeyDown: undefined,
59
+ onKeyUp: undefined
55
60
  }, state);
56
61
  return {
57
62
  labelProps: labelProps,
58
63
  inputProps: (0, $fgZRc$mergeProps)(inputProps, comboBoxInputProps),
59
64
  listBoxProps: listBoxProps,
60
- clearButtonProps: clearButtonProps
65
+ clearButtonProps: clearButtonProps,
66
+ descriptionProps: descriptionProps,
67
+ errorMessageProps: errorMessageProps
61
68
  };
62
69
  }
63
70
 
@@ -1 +1 @@
1
- {"mappings":";;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED;;;AAuCO,SAAS,0CAAyB,KAAqC,EAAE,KAAuB,EAA6B;IAClI,IAAI,cACF,WAAU,YACV,SAAQ,cACR,WAAU,oBACV,iBAAgB,YAChB,WAAW,IAAM,CAAC,aAClB,QAAO,EACR,GAAG;IAEJ,IAAI,cAAC,WAAU,oBAAE,iBAAgB,EAAC,GAAG,CAAA,GAAA,qBAAc,AAAD,EAAE;QAClD,GAAG,KAAK;QACR,OAAO,MAAM,UAAU;QACvB,UAAU,MAAM,aAAa;QAC7B,cAAc;QACd,SAAS,IAAM;YACb,MAAM,aAAa,CAAC;YACpB,IAAI,SACF;QAEJ;QACA,UAAU,CAAC,QAAU;YACnB,iEAAiE;YACjE,IAAI,MAAM,gBAAgB,CAAC,UAAU,KAAK,IAAI,EAC5C,SAAS,OAAO,IAAI;QAExB;IACF,GAAG;QACD,OAAO,MAAM,UAAU;QACvB,UAAU,MAAM,aAAa;IAC/B,GAAG;IAGH,IAAI,gBAAC,aAAY,cAAE,WAAU,EAAE,YAAY,mBAAkB,EAAC,GAAG,CAAA,GAAA,kBAAU,EACzE;QACE,GAAG,KAAK;0BACR;oBACA;oBACA;kBACA;QACA,SAAS;QACT,QAAQ;IACV,GACA;IAGF,OAAO;oBACL;QACA,YAAY,CAAA,GAAA,iBAAU,AAAD,EAAE,YAAY;sBACnC;0BACA;IACF;AACF;;CD7FC,GACD","sources":["packages/@react-aria/autocomplete/src/index.ts","packages/@react-aria/autocomplete/src/useSearchAutocomplete.ts"],"sourcesContent":["/*\n * Copyright 2021 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useSearchAutocomplete} from './useSearchAutocomplete';\nexport type {AriaSearchAutocompleteProps, SearchAutocompleteAria} from './useSearchAutocomplete';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '@react-types/button';\nimport {AriaListBoxOptions} from '@react-aria/listbox';\nimport {ComboBoxState} from '@react-stately/combobox';\nimport {DOMAttributes} from '@react-types/shared';\nimport {InputHTMLAttributes, RefObject} from 'react';\nimport {KeyboardDelegate} from '@react-types/shared';\nimport {mergeProps} from '@react-aria/utils';\nimport {SearchAutocompleteProps} from '@react-types/autocomplete';\nimport {useComboBox} from '@react-aria/combobox';\nimport {useSearchField} from '@react-aria/searchfield';\n\nexport interface AriaSearchAutocompleteProps<T> extends SearchAutocompleteProps<T> {\n /** The ref for the input element. */\n inputRef: RefObject<HTMLInputElement>,\n /** The ref for the list box popover. */\n popoverRef: RefObject<HTMLDivElement>,\n /** The ref for the list box. */\n listBoxRef: RefObject<HTMLElement>,\n /** An optional keyboard delegate implementation, to override the default. */\n keyboardDelegate?: KeyboardDelegate\n}\n\nexport interface SearchAutocompleteAria<T> {\n /** Props for the label element. */\n labelProps: DOMAttributes,\n /** Props for the search input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Props for the list box, to be passed to [useListBox](useListBox.html). */\n listBoxProps: AriaListBoxOptions<T>,\n /** Props for the search input's clear button. */\n clearButtonProps: AriaButtonProps\n}\n\n/**\n * Provides the behavior and accessibility implementation for a search autocomplete component.\n * A search autocomplete combines a combobox with a searchfield, allowing users to filter a list of options to items matching a query.\n * @param props - Props for the search autocomplete.\n * @param state - State for the search autocomplete, as returned by `useSearchAutocomplete`.\n */\nexport function useSearchAutocomplete<T>(props: AriaSearchAutocompleteProps<T>, state: ComboBoxState<T>): SearchAutocompleteAria<T> {\n let {\n popoverRef,\n inputRef,\n listBoxRef,\n keyboardDelegate,\n onSubmit = () => {},\n onClear\n } = props;\n\n let {inputProps, clearButtonProps} = useSearchField({\n ...props,\n value: state.inputValue,\n onChange: state.setInputValue,\n autoComplete: 'off',\n onClear: () => {\n state.setInputValue('');\n if (onClear) {\n onClear();\n }\n },\n onSubmit: (value) => {\n // Prevent submission from search field if menu item was selected\n if (state.selectionManager.focusedKey === null) {\n onSubmit(value, null);\n }\n } \n }, {\n value: state.inputValue,\n setValue: state.setInputValue\n }, inputRef);\n \n\n let {listBoxProps, labelProps, inputProps: comboBoxInputProps} = useComboBox(\n {\n ...props,\n keyboardDelegate,\n popoverRef,\n listBoxRef,\n inputRef,\n onFocus: undefined,\n onBlur: undefined\n },\n state\n );\n\n return {\n labelProps,\n inputProps: mergeProps(inputProps, comboBoxInputProps),\n listBoxProps,\n clearButtonProps\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
1
+ {"mappings":";;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED;;;AA0CO,SAAS,0CAAyB,KAAuC,EAAE,KAAuB,EAA6B;IACpI,IAAI,cACF,WAAU,YACV,SAAQ,cACR,WAAU,oBACV,iBAAgB,YAChB,WAAW,IAAM,CAAC,aAClB,QAAO,aACP,UAAS,WACT,QAAO,EACR,GAAG;IAEJ,IAAI,cAAC,WAAU,oBAAE,iBAAgB,oBAAE,iBAAgB,qBAAE,kBAAiB,EAAC,GAAG,CAAA,GAAA,qBAAa,EAAE;QACvF,GAAG,KAAK;QACR,OAAO,MAAM,UAAU;QACvB,UAAU,MAAM,aAAa;QAC7B,cAAc;QACd,SAAS,IAAM;YACb,MAAM,aAAa,CAAC;YACpB,IAAI,SACF;QAEJ;QACA,UAAU,CAAC,QAAU;YACnB,iEAAiE;YACjE,IAAI,MAAM,gBAAgB,CAAC,UAAU,KAAK,IAAI,EAC5C,SAAS,OAAO,IAAI;QAExB;mBACA;iBACA;IACF,GAAG;QACD,OAAO,MAAM,UAAU;QACvB,UAAU,MAAM,aAAa;IAC/B,GAAG;IAGH,IAAI,gBAAC,aAAY,cAAE,WAAU,EAAE,YAAY,mBAAkB,EAAC,GAAG,CAAA,GAAA,kBAAU,EACzE;QACE,GAAG,KAAK;0BACR;oBACA;oBACA;kBACA;QACA,SAAS;QACT,eAAe;QACf,QAAQ;QACR,WAAW;QACX,SAAS;IACX,GACA;IAGF,OAAO;oBACL;QACA,YAAY,CAAA,GAAA,iBAAU,AAAD,EAAE,YAAY;sBACnC;0BACA;0BACA;2BACA;IACF;AACF;;CDzGC,GACD","sources":["packages/@react-aria/autocomplete/src/index.ts","packages/@react-aria/autocomplete/src/useSearchAutocomplete.ts"],"sourcesContent":["/*\n * Copyright 2021 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useSearchAutocomplete} from './useSearchAutocomplete';\nexport type {AriaSearchAutocompleteOptions, SearchAutocompleteAria} from './useSearchAutocomplete';\nexport type {AriaSearchAutocompleteProps} from '@react-types/autocomplete';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '@react-types/button';\nimport {AriaListBoxOptions} from '@react-aria/listbox';\nimport {AriaSearchAutocompleteProps} from '@react-types/autocomplete';\nimport {ComboBoxState} from '@react-stately/combobox';\nimport {DOMAttributes, KeyboardDelegate} from '@react-types/shared';\nimport {InputHTMLAttributes, RefObject} from 'react';\nimport {mergeProps} from '@react-aria/utils';\nimport {useComboBox} from '@react-aria/combobox';\nimport {useSearchField} from '@react-aria/searchfield';\n\nexport interface SearchAutocompleteAria<T> {\n /** Props for the label element. */\n labelProps: DOMAttributes,\n /** Props for the search input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Props for the list box, to be passed to [useListBox](useListBox.html). */\n listBoxProps: AriaListBoxOptions<T>,\n /** Props for the search input's clear button. */\n clearButtonProps: AriaButtonProps,\n /** Props for the search autocomplete description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the search autocomplete error message element, if any. */\n errorMessageProps: DOMAttributes\n}\n\nexport interface AriaSearchAutocompleteOptions<T> extends AriaSearchAutocompleteProps<T> {\n /** The ref for the input element. */\n inputRef: RefObject<HTMLInputElement>,\n /** The ref for the list box popover. */\n popoverRef: RefObject<HTMLDivElement>,\n /** The ref for the list box. */\n listBoxRef: RefObject<HTMLElement>,\n /** An optional keyboard delegate implementation, to override the default. */\n keyboardDelegate?: KeyboardDelegate\n}\n\n/**\n * Provides the behavior and accessibility implementation for a search autocomplete component.\n * A search autocomplete combines a combobox with a searchfield, allowing users to filter a list of options to items matching a query.\n * @param props - Props for the search autocomplete.\n * @param state - State for the search autocomplete, as returned by `useSearchAutocomplete`.\n */\nexport function useSearchAutocomplete<T>(props: AriaSearchAutocompleteOptions<T>, state: ComboBoxState<T>): SearchAutocompleteAria<T> {\n let {\n popoverRef,\n inputRef,\n listBoxRef,\n keyboardDelegate,\n onSubmit = () => {},\n onClear,\n onKeyDown,\n onKeyUp\n } = props;\n\n let {inputProps, clearButtonProps, descriptionProps, errorMessageProps} = useSearchField({\n ...props,\n value: state.inputValue,\n onChange: state.setInputValue,\n autoComplete: 'off',\n onClear: () => {\n state.setInputValue('');\n if (onClear) {\n onClear();\n }\n },\n onSubmit: (value) => {\n // Prevent submission from search field if menu item was selected\n if (state.selectionManager.focusedKey === null) {\n onSubmit(value, null);\n }\n },\n onKeyDown,\n onKeyUp\n }, {\n value: state.inputValue,\n setValue: state.setInputValue\n }, inputRef);\n \n\n let {listBoxProps, labelProps, inputProps: comboBoxInputProps} = useComboBox(\n {\n ...props,\n keyboardDelegate,\n popoverRef,\n listBoxRef,\n inputRef,\n onFocus: undefined,\n onFocusChange: undefined,\n onBlur: undefined,\n onKeyDown: undefined,\n onKeyUp: undefined\n },\n state\n );\n\n return {\n labelProps,\n inputProps: mergeProps(inputProps, comboBoxInputProps),\n listBoxProps,\n clearButtonProps,\n descriptionProps,\n errorMessageProps\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
package/dist/types.d.ts CHANGED
@@ -1,19 +1,9 @@
1
1
  import { AriaButtonProps } from "@react-types/button";
2
2
  import { AriaListBoxOptions } from "@react-aria/listbox";
3
+ import { AriaSearchAutocompleteProps } from "@react-types/autocomplete";
3
4
  import { ComboBoxState } from "@react-stately/combobox";
4
5
  import { DOMAttributes, KeyboardDelegate } from "@react-types/shared";
5
6
  import { InputHTMLAttributes, RefObject } from "react";
6
- import { SearchAutocompleteProps } from "@react-types/autocomplete";
7
- export interface AriaSearchAutocompleteProps<T> extends SearchAutocompleteProps<T> {
8
- /** The ref for the input element. */
9
- inputRef: RefObject<HTMLInputElement>;
10
- /** The ref for the list box popover. */
11
- popoverRef: RefObject<HTMLDivElement>;
12
- /** The ref for the list box. */
13
- listBoxRef: RefObject<HTMLElement>;
14
- /** An optional keyboard delegate implementation, to override the default. */
15
- keyboardDelegate?: KeyboardDelegate;
16
- }
17
7
  export interface SearchAutocompleteAria<T> {
18
8
  /** Props for the label element. */
19
9
  labelProps: DOMAttributes;
@@ -23,6 +13,20 @@ export interface SearchAutocompleteAria<T> {
23
13
  listBoxProps: AriaListBoxOptions<T>;
24
14
  /** Props for the search input's clear button. */
25
15
  clearButtonProps: AriaButtonProps;
16
+ /** Props for the search autocomplete description element, if any. */
17
+ descriptionProps: DOMAttributes;
18
+ /** Props for the search autocomplete error message element, if any. */
19
+ errorMessageProps: DOMAttributes;
20
+ }
21
+ export interface AriaSearchAutocompleteOptions<T> extends AriaSearchAutocompleteProps<T> {
22
+ /** The ref for the input element. */
23
+ inputRef: RefObject<HTMLInputElement>;
24
+ /** The ref for the list box popover. */
25
+ popoverRef: RefObject<HTMLDivElement>;
26
+ /** The ref for the list box. */
27
+ listBoxRef: RefObject<HTMLElement>;
28
+ /** An optional keyboard delegate implementation, to override the default. */
29
+ keyboardDelegate?: KeyboardDelegate;
26
30
  }
27
31
  /**
28
32
  * Provides the behavior and accessibility implementation for a search autocomplete component.
@@ -30,6 +34,7 @@ export interface SearchAutocompleteAria<T> {
30
34
  * @param props - Props for the search autocomplete.
31
35
  * @param state - State for the search autocomplete, as returned by `useSearchAutocomplete`.
32
36
  */
33
- export function useSearchAutocomplete<T>(props: AriaSearchAutocompleteProps<T>, state: ComboBoxState<T>): SearchAutocompleteAria<T>;
37
+ export function useSearchAutocomplete<T>(props: AriaSearchAutocompleteOptions<T>, state: ComboBoxState<T>): SearchAutocompleteAria<T>;
38
+ export type { AriaSearchAutocompleteProps } from '@react-types/autocomplete';
34
39
 
35
40
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"mappings":";;;;;;AAuBA,6CAA6C,CAAC,CAAE,SAAQ,wBAAwB,CAAC,CAAC;IAChF,qCAAqC;IACrC,QAAQ,EAAE,UAAU,gBAAgB,CAAC,CAAC;IACtC,wCAAwC;IACxC,UAAU,EAAE,UAAU,cAAc,CAAC,CAAC;IACtC,gCAAgC;IAChC,UAAU,EAAE,UAAU,WAAW,CAAC,CAAC;IACnC,6EAA6E;IAC7E,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;CACpC;AAED,wCAAwC,CAAC;IACvC,mCAAmC;IACnC,UAAU,EAAE,aAAa,CAAC;IAC1B,0CAA0C;IAC1C,UAAU,EAAE,oBAAoB,gBAAgB,CAAC,CAAC;IAClD,6EAA6E;IAC7E,YAAY,EAAE,mBAAmB,CAAC,CAAC,CAAC;IACpC,iDAAiD;IACjD,gBAAgB,EAAE,eAAe,CAAA;CAClC;AAED;;;;;GAKG;AACH,sCAAsC,CAAC,EAAE,KAAK,EAAE,4BAA4B,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,GAAG,uBAAuB,CAAC,CAAC,CAoDlI","sources":["packages/@react-aria/autocomplete/src/packages/@react-aria/autocomplete/src/useSearchAutocomplete.ts","packages/@react-aria/autocomplete/src/packages/@react-aria/autocomplete/src/index.ts","packages/@react-aria/autocomplete/src/index.ts"],"sourcesContent":[null,null,"/*\n * Copyright 2021 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useSearchAutocomplete} from './useSearchAutocomplete';\nexport type {AriaSearchAutocompleteProps, SearchAutocompleteAria} from './useSearchAutocomplete';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":";;;;;;AAsBA,wCAAwC,CAAC;IACvC,mCAAmC;IACnC,UAAU,EAAE,aAAa,CAAC;IAC1B,0CAA0C;IAC1C,UAAU,EAAE,oBAAoB,gBAAgB,CAAC,CAAC;IAClD,6EAA6E;IAC7E,YAAY,EAAE,mBAAmB,CAAC,CAAC,CAAC;IACpC,iDAAiD;IACjD,gBAAgB,EAAE,eAAe,CAAC;IAClC,qEAAqE;IACrE,gBAAgB,EAAE,aAAa,CAAC;IAChC,uEAAuE;IACvE,iBAAiB,EAAE,aAAa,CAAA;CACjC;AAED,+CAA+C,CAAC,CAAE,SAAQ,4BAA4B,CAAC,CAAC;IACtF,qCAAqC;IACrC,QAAQ,EAAE,UAAU,gBAAgB,CAAC,CAAC;IACtC,wCAAwC;IACxC,UAAU,EAAE,UAAU,cAAc,CAAC,CAAC;IACtC,gCAAgC;IAChC,UAAU,EAAE,UAAU,WAAW,CAAC,CAAC;IACnC,6EAA6E;IAC7E,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;CACpC;AAED;;;;;GAKG;AACH,sCAAsC,CAAC,EAAE,KAAK,EAAE,8BAA8B,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,GAAG,uBAAuB,CAAC,CAAC,CA6DpI;ACtGD,YAAY,EAAC,2BAA2B,EAAC,MAAM,2BAA2B,CAAC","sources":["packages/@react-aria/autocomplete/src/packages/@react-aria/autocomplete/src/useSearchAutocomplete.ts","packages/@react-aria/autocomplete/src/packages/@react-aria/autocomplete/src/index.ts","packages/@react-aria/autocomplete/src/index.ts"],"sourcesContent":[null,null,"/*\n * Copyright 2021 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useSearchAutocomplete} from './useSearchAutocomplete';\nexport type {AriaSearchAutocompleteOptions, SearchAutocompleteAria} from './useSearchAutocomplete';\nexport type {AriaSearchAutocompleteProps} from '@react-types/autocomplete';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/autocomplete",
3
- "version": "3.0.0-alpha.15",
3
+ "version": "3.0.0-alpha.17",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -22,23 +22,23 @@
22
22
  "url": "https://github.com/adobe/react-spectrum"
23
23
  },
24
24
  "dependencies": {
25
- "@react-aria/combobox": "^3.5.1",
26
- "@react-aria/i18n": "^3.7.0",
27
- "@react-aria/listbox": "^3.8.1",
28
- "@react-aria/live-announcer": "^3.2.0",
29
- "@react-aria/menu": "^3.8.1",
30
- "@react-aria/overlays": "^3.13.0",
31
- "@react-aria/searchfield": "^3.5.0",
32
- "@react-aria/selection": "^3.13.1",
33
- "@react-aria/textfield": "^3.9.0",
34
- "@react-aria/utils": "^3.15.0",
35
- "@react-stately/collections": "^3.6.0",
36
- "@react-stately/combobox": "^3.4.0",
37
- "@react-types/autocomplete": "3.0.0-alpha.12",
38
- "@react-types/button": "^3.7.1",
39
- "@react-types/combobox": "^3.6.0",
40
- "@react-types/searchfield": "^3.4.0",
41
- "@react-types/shared": "^3.17.0",
25
+ "@react-aria/combobox": "^3.6.1",
26
+ "@react-aria/i18n": "^3.7.2",
27
+ "@react-aria/listbox": "^3.9.1",
28
+ "@react-aria/live-announcer": "^3.3.0",
29
+ "@react-aria/menu": "^3.9.1",
30
+ "@react-aria/overlays": "^3.14.1",
31
+ "@react-aria/searchfield": "^3.5.2",
32
+ "@react-aria/selection": "^3.15.0",
33
+ "@react-aria/textfield": "^3.9.2",
34
+ "@react-aria/utils": "^3.17.0",
35
+ "@react-stately/collections": "^3.8.0",
36
+ "@react-stately/combobox": "^3.5.1",
37
+ "@react-types/autocomplete": "3.0.0-alpha.14",
38
+ "@react-types/button": "^3.7.3",
39
+ "@react-types/combobox": "^3.6.2",
40
+ "@react-types/searchfield": "^3.4.2",
41
+ "@react-types/shared": "^3.18.1",
42
42
  "@swc/helpers": "^0.4.14"
43
43
  },
44
44
  "peerDependencies": {
@@ -47,5 +47,5 @@
47
47
  "publishConfig": {
48
48
  "access": "public"
49
49
  },
50
- "gitHead": "e00dfc4ca2961753b8b1037d209992adb86a0ea7"
50
+ "gitHead": "5911ed21de4b76d66f6254c02302519e02d50e16"
51
51
  }
package/src/index.ts CHANGED
@@ -10,4 +10,5 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
  export {useSearchAutocomplete} from './useSearchAutocomplete';
13
- export type {AriaSearchAutocompleteProps, SearchAutocompleteAria} from './useSearchAutocomplete';
13
+ export type {AriaSearchAutocompleteOptions, SearchAutocompleteAria} from './useSearchAutocomplete';
14
+ export type {AriaSearchAutocompleteProps} from '@react-types/autocomplete';
@@ -12,26 +12,14 @@
12
12
 
13
13
  import {AriaButtonProps} from '@react-types/button';
14
14
  import {AriaListBoxOptions} from '@react-aria/listbox';
15
+ import {AriaSearchAutocompleteProps} from '@react-types/autocomplete';
15
16
  import {ComboBoxState} from '@react-stately/combobox';
16
- import {DOMAttributes} from '@react-types/shared';
17
+ import {DOMAttributes, KeyboardDelegate} from '@react-types/shared';
17
18
  import {InputHTMLAttributes, RefObject} from 'react';
18
- import {KeyboardDelegate} from '@react-types/shared';
19
19
  import {mergeProps} from '@react-aria/utils';
20
- import {SearchAutocompleteProps} from '@react-types/autocomplete';
21
20
  import {useComboBox} from '@react-aria/combobox';
22
21
  import {useSearchField} from '@react-aria/searchfield';
23
22
 
24
- export interface AriaSearchAutocompleteProps<T> extends SearchAutocompleteProps<T> {
25
- /** The ref for the input element. */
26
- inputRef: RefObject<HTMLInputElement>,
27
- /** The ref for the list box popover. */
28
- popoverRef: RefObject<HTMLDivElement>,
29
- /** The ref for the list box. */
30
- listBoxRef: RefObject<HTMLElement>,
31
- /** An optional keyboard delegate implementation, to override the default. */
32
- keyboardDelegate?: KeyboardDelegate
33
- }
34
-
35
23
  export interface SearchAutocompleteAria<T> {
36
24
  /** Props for the label element. */
37
25
  labelProps: DOMAttributes,
@@ -40,7 +28,22 @@ export interface SearchAutocompleteAria<T> {
40
28
  /** Props for the list box, to be passed to [useListBox](useListBox.html). */
41
29
  listBoxProps: AriaListBoxOptions<T>,
42
30
  /** Props for the search input's clear button. */
43
- clearButtonProps: AriaButtonProps
31
+ clearButtonProps: AriaButtonProps,
32
+ /** Props for the search autocomplete description element, if any. */
33
+ descriptionProps: DOMAttributes,
34
+ /** Props for the search autocomplete error message element, if any. */
35
+ errorMessageProps: DOMAttributes
36
+ }
37
+
38
+ export interface AriaSearchAutocompleteOptions<T> extends AriaSearchAutocompleteProps<T> {
39
+ /** The ref for the input element. */
40
+ inputRef: RefObject<HTMLInputElement>,
41
+ /** The ref for the list box popover. */
42
+ popoverRef: RefObject<HTMLDivElement>,
43
+ /** The ref for the list box. */
44
+ listBoxRef: RefObject<HTMLElement>,
45
+ /** An optional keyboard delegate implementation, to override the default. */
46
+ keyboardDelegate?: KeyboardDelegate
44
47
  }
45
48
 
46
49
  /**
@@ -49,17 +52,19 @@ export interface SearchAutocompleteAria<T> {
49
52
  * @param props - Props for the search autocomplete.
50
53
  * @param state - State for the search autocomplete, as returned by `useSearchAutocomplete`.
51
54
  */
52
- export function useSearchAutocomplete<T>(props: AriaSearchAutocompleteProps<T>, state: ComboBoxState<T>): SearchAutocompleteAria<T> {
55
+ export function useSearchAutocomplete<T>(props: AriaSearchAutocompleteOptions<T>, state: ComboBoxState<T>): SearchAutocompleteAria<T> {
53
56
  let {
54
57
  popoverRef,
55
58
  inputRef,
56
59
  listBoxRef,
57
60
  keyboardDelegate,
58
61
  onSubmit = () => {},
59
- onClear
62
+ onClear,
63
+ onKeyDown,
64
+ onKeyUp
60
65
  } = props;
61
66
 
62
- let {inputProps, clearButtonProps} = useSearchField({
67
+ let {inputProps, clearButtonProps, descriptionProps, errorMessageProps} = useSearchField({
63
68
  ...props,
64
69
  value: state.inputValue,
65
70
  onChange: state.setInputValue,
@@ -75,7 +80,9 @@ export function useSearchAutocomplete<T>(props: AriaSearchAutocompleteProps<T>,
75
80
  if (state.selectionManager.focusedKey === null) {
76
81
  onSubmit(value, null);
77
82
  }
78
- }
83
+ },
84
+ onKeyDown,
85
+ onKeyUp
79
86
  }, {
80
87
  value: state.inputValue,
81
88
  setValue: state.setInputValue
@@ -90,7 +97,10 @@ export function useSearchAutocomplete<T>(props: AriaSearchAutocompleteProps<T>,
90
97
  listBoxRef,
91
98
  inputRef,
92
99
  onFocus: undefined,
93
- onBlur: undefined
100
+ onFocusChange: undefined,
101
+ onBlur: undefined,
102
+ onKeyDown: undefined,
103
+ onKeyUp: undefined
94
104
  },
95
105
  state
96
106
  );
@@ -99,6 +109,8 @@ export function useSearchAutocomplete<T>(props: AriaSearchAutocompleteProps<T>,
99
109
  labelProps,
100
110
  inputProps: mergeProps(inputProps, comboBoxInputProps),
101
111
  listBoxProps,
102
- clearButtonProps
112
+ clearButtonProps,
113
+ descriptionProps,
114
+ errorMessageProps
103
115
  };
104
116
  }