@react-aria/autocomplete 3.0.0-alpha.16 → 3.0.0-alpha.18

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;;;AAsCO,SAAS,0CAAyB,KAAuC,EAAE,KAAuB,EAA6B;IACpI,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;;CD5FC,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}\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 } = 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;;;AA4CM,SAAS,0CAAyB,KAAuC,EAAE,KAAuB;IACvG,IAAI,cACF,WAAU,YACV,SAAQ,cACR,WAAU,oBACV,iBAAgB,YAChB,WAAW,KAAO,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;QACb,UAAU,MAAM;QAChB,cAAc;QACd,SAAS;YACP,MAAM,cAAc;YACpB,IAAI,SACF;QAEJ;QACA,UAAU,CAAC;YACT,iEAAiE;YACjE,IAAI,MAAM,iBAAiB,eAAe,MACxC,SAAS,OAAO;QAEpB;mBACA;iBACA;IACF,GAAG;QACD,OAAO,MAAM;QACb,UAAU,MAAM;IAClB,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,gCAAS,EAAE,YAAY;sBACnC;0BACA;0BACA;2BACA;IACF;AACF;;CDzGC","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;;;AAsCO,SAAS,0CAAyB,KAAuC,EAAE,KAAuB,EAA6B;IACpI,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;;CD5FC,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}\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 } = 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;;;AA4CM,SAAS,0CAAyB,KAAuC,EAAE,KAAuB;IACvG,IAAI,cACF,WAAU,YACV,SAAQ,cACR,WAAU,oBACV,iBAAgB,YAChB,WAAW,KAAO,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;QACb,UAAU,MAAM;QAChB,cAAc;QACd,SAAS;YACP,MAAM,cAAc;YACpB,IAAI,SACF;QAEJ;QACA,UAAU,CAAC;YACT,iEAAiE;YACjE,IAAI,MAAM,iBAAiB,eAAe,MACxC,SAAS,OAAO;QAEpB;mBACA;iBACA;IACF,GAAG;QACD,OAAO,MAAM;QACb,UAAU,MAAM;IAClB,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,iBAAS,EAAE,YAAY;sBACnC;0BACA;0BACA;2BACA;IACF;AACF;;CDzGC","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
@@ -13,6 +13,10 @@ export interface SearchAutocompleteAria<T> {
13
13
  listBoxProps: AriaListBoxOptions<T>;
14
14
  /** Props for the search input's clear button. */
15
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;
16
20
  }
17
21
  export interface AriaSearchAutocompleteOptions<T> extends AriaSearchAutocompleteProps<T> {
18
22
  /** The ref for the input element. */
@@ -1 +1 @@
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,CAAA;CAClC;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,CAoDpI;ACzFD,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"}
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.16",
3
+ "version": "3.0.0-alpha.18",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -22,24 +22,24 @@
22
22
  "url": "https://github.com/adobe/react-spectrum"
23
23
  },
24
24
  "dependencies": {
25
- "@react-aria/combobox": "^3.6.0",
26
- "@react-aria/i18n": "^3.7.1",
27
- "@react-aria/listbox": "^3.9.0",
28
- "@react-aria/live-announcer": "^3.3.0",
29
- "@react-aria/menu": "^3.9.0",
30
- "@react-aria/overlays": "^3.14.0",
31
- "@react-aria/searchfield": "^3.5.1",
32
- "@react-aria/selection": "^3.14.0",
33
- "@react-aria/textfield": "^3.9.1",
34
- "@react-aria/utils": "^3.16.0",
35
- "@react-stately/collections": "^3.7.0",
36
- "@react-stately/combobox": "^3.5.0",
37
- "@react-types/autocomplete": "3.0.0-alpha.13",
38
- "@react-types/button": "^3.7.2",
39
- "@react-types/combobox": "^3.6.1",
40
- "@react-types/searchfield": "^3.4.1",
41
- "@react-types/shared": "^3.18.0",
42
- "@swc/helpers": "^0.4.14"
25
+ "@react-aria/combobox": "^3.6.2",
26
+ "@react-aria/i18n": "^3.8.0",
27
+ "@react-aria/listbox": "^3.10.0",
28
+ "@react-aria/live-announcer": "^3.3.1",
29
+ "@react-aria/menu": "^3.10.0",
30
+ "@react-aria/overlays": "^3.15.0",
31
+ "@react-aria/searchfield": "^3.5.3",
32
+ "@react-aria/selection": "^3.16.0",
33
+ "@react-aria/textfield": "^3.10.0",
34
+ "@react-aria/utils": "^3.18.0",
35
+ "@react-stately/collections": "^3.9.0",
36
+ "@react-stately/combobox": "^3.5.2",
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
+ "@swc/helpers": "^0.5.0"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
@@ -47,5 +47,5 @@
47
47
  "publishConfig": {
48
48
  "access": "public"
49
49
  },
50
- "gitHead": "9d1ba9bd8ebcd63bf3495ade16d349bcb71795ce"
50
+ "gitHead": "504e40e0a50c1b20ed0fb3ba9561a263b6d5565e"
51
51
  }
@@ -28,7 +28,11 @@ export interface SearchAutocompleteAria<T> {
28
28
  /** Props for the list box, to be passed to [useListBox](useListBox.html). */
29
29
  listBoxProps: AriaListBoxOptions<T>,
30
30
  /** Props for the search input's clear button. */
31
- 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
32
36
  }
33
37
 
34
38
  export interface AriaSearchAutocompleteOptions<T> extends AriaSearchAutocompleteProps<T> {
@@ -55,10 +59,12 @@ export function useSearchAutocomplete<T>(props: AriaSearchAutocompleteOptions<T>
55
59
  listBoxRef,
56
60
  keyboardDelegate,
57
61
  onSubmit = () => {},
58
- onClear
62
+ onClear,
63
+ onKeyDown,
64
+ onKeyUp
59
65
  } = props;
60
66
 
61
- let {inputProps, clearButtonProps} = useSearchField({
67
+ let {inputProps, clearButtonProps, descriptionProps, errorMessageProps} = useSearchField({
62
68
  ...props,
63
69
  value: state.inputValue,
64
70
  onChange: state.setInputValue,
@@ -74,7 +80,9 @@ export function useSearchAutocomplete<T>(props: AriaSearchAutocompleteOptions<T>
74
80
  if (state.selectionManager.focusedKey === null) {
75
81
  onSubmit(value, null);
76
82
  }
77
- }
83
+ },
84
+ onKeyDown,
85
+ onKeyUp
78
86
  }, {
79
87
  value: state.inputValue,
80
88
  setValue: state.setInputValue
@@ -89,7 +97,10 @@ export function useSearchAutocomplete<T>(props: AriaSearchAutocompleteOptions<T>
89
97
  listBoxRef,
90
98
  inputRef,
91
99
  onFocus: undefined,
92
- onBlur: undefined
100
+ onFocusChange: undefined,
101
+ onBlur: undefined,
102
+ onKeyDown: undefined,
103
+ onKeyUp: undefined
93
104
  },
94
105
  state
95
106
  );
@@ -98,6 +109,8 @@ export function useSearchAutocomplete<T>(props: AriaSearchAutocompleteOptions<T>
98
109
  labelProps,
99
110
  inputProps: mergeProps(inputProps, comboBoxInputProps),
100
111
  listBoxProps,
101
- clearButtonProps
112
+ clearButtonProps,
113
+ descriptionProps,
114
+ errorMessageProps
102
115
  };
103
116
  }