@react-aria/autocomplete 3.0.0-alpha.2 → 3.0.0-alpha.20

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,75 @@
1
+ import {mergeProps as $fgZRc$mergeProps} from "@react-aria/utils";
2
+ import {useComboBox as $fgZRc$useComboBox} from "@react-aria/combobox";
3
+ import {useSearchField as $fgZRc$useSearchField} from "@react-aria/searchfield";
4
+
5
+ /*
6
+ * Copyright 2021 Adobe. All rights reserved.
7
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License. You may obtain a copy
9
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software distributed under
12
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13
+ * OF ANY KIND, either express or implied. See the License for the specific language
14
+ * governing permissions and limitations under the License.
15
+ */ /*
16
+ * Copyright 2020 Adobe. All rights reserved.
17
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
18
+ * you may not use this file except in compliance with the License. You may obtain a copy
19
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
20
+ *
21
+ * Unless required by applicable law or agreed to in writing, software distributed under
22
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
23
+ * OF ANY KIND, either express or implied. See the License for the specific language
24
+ * governing permissions and limitations under the License.
25
+ */
26
+
27
+
28
+ function $c04f11f368135585$export$da7ade746446be1f(props, state) {
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
+ ...props,
32
+ value: state.inputValue,
33
+ onChange: state.setInputValue,
34
+ autoComplete: "off",
35
+ onClear: ()=>{
36
+ state.setInputValue("");
37
+ if (onClear) onClear();
38
+ },
39
+ onSubmit: (value)=>{
40
+ // Prevent submission from search field if menu item was selected
41
+ if (state.selectionManager.focusedKey === null) onSubmit(value, null);
42
+ },
43
+ onKeyDown: onKeyDown,
44
+ onKeyUp: onKeyUp
45
+ }, {
46
+ value: state.inputValue,
47
+ setValue: state.setInputValue
48
+ }, inputRef);
49
+ let { listBoxProps: listBoxProps , labelProps: labelProps , inputProps: comboBoxInputProps } = (0, $fgZRc$useComboBox)({
50
+ ...props,
51
+ keyboardDelegate: keyboardDelegate,
52
+ popoverRef: popoverRef,
53
+ listBoxRef: listBoxRef,
54
+ inputRef: inputRef,
55
+ onFocus: undefined,
56
+ onFocusChange: undefined,
57
+ onBlur: undefined,
58
+ onKeyDown: undefined,
59
+ onKeyUp: undefined
60
+ }, state);
61
+ return {
62
+ labelProps: labelProps,
63
+ inputProps: (0, $fgZRc$mergeProps)(inputProps, comboBoxInputProps),
64
+ listBoxProps: listBoxProps,
65
+ clearButtonProps: clearButtonProps,
66
+ descriptionProps: descriptionProps,
67
+ errorMessageProps: errorMessageProps
68
+ };
69
+ }
70
+
71
+
72
+
73
+
74
+ export {$c04f11f368135585$export$da7ade746446be1f as useSearchAutocomplete};
75
+ //# sourceMappingURL=module.js.map
package/dist/main.js CHANGED
@@ -1,69 +1,79 @@
1
- var $51hfB$reactariautils = require("@react-aria/utils");
2
- var $51hfB$reactariacombobox = require("@react-aria/combobox");
3
- var $51hfB$reactariasearchfield = require("@react-aria/searchfield");
1
+ var $kDrMH$reactariautils = require("@react-aria/utils");
2
+ var $kDrMH$reactariacombobox = require("@react-aria/combobox");
3
+ var $kDrMH$reactariasearchfield = require("@react-aria/searchfield");
4
4
 
5
- function $parcel$exportWildcard(dest, source) {
6
- Object.keys(source).forEach(function(key) {
7
- if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
8
- return;
9
- }
10
-
11
- Object.defineProperty(dest, key, {
12
- enumerable: true,
13
- get: function get() {
14
- return source[key];
15
- }
16
- });
17
- });
18
-
19
- return dest;
20
- }
21
5
  function $parcel$export(e, n, v, s) {
22
6
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
23
7
  }
24
- var $c9cabc3db9f996d9$exports = {};
25
-
26
- $parcel$export($c9cabc3db9f996d9$exports, "useSearchAutocomplete", () => $c9cabc3db9f996d9$export$da7ade746446be1f);
27
8
 
9
+ $parcel$export(module.exports, "useSearchAutocomplete", () => $3c40871f8cc2eb01$export$da7ade746446be1f);
10
+ /*
11
+ * Copyright 2021 Adobe. All rights reserved.
12
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
13
+ * you may not use this file except in compliance with the License. You may obtain a copy
14
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
15
+ *
16
+ * Unless required by applicable law or agreed to in writing, software distributed under
17
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
18
+ * OF ANY KIND, either express or implied. See the License for the specific language
19
+ * governing permissions and limitations under the License.
20
+ */ /*
21
+ * Copyright 2020 Adobe. All rights reserved.
22
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
23
+ * you may not use this file except in compliance with the License. You may obtain a copy
24
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
25
+ *
26
+ * Unless required by applicable law or agreed to in writing, software distributed under
27
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
28
+ * OF ANY KIND, either express or implied. See the License for the specific language
29
+ * governing permissions and limitations under the License.
30
+ */
28
31
 
29
32
 
30
- function $c9cabc3db9f996d9$export$da7ade746446be1f(props, state) {
31
- let { popoverRef: popoverRef , inputRef: inputRef , listBoxRef: listBoxRef , keyboardDelegate: keyboardDelegate , onSubmit: onSubmit = ()=>{
32
- } } = props;
33
- let { inputProps: inputProps , clearButtonProps: clearButtonProps } = $51hfB$reactariasearchfield.useSearchField({
33
+ function $3c40871f8cc2eb01$export$da7ade746446be1f(props, state) {
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)({
34
36
  ...props,
35
37
  value: state.inputValue,
36
38
  onChange: state.setInputValue,
37
- autoComplete: 'off',
38
- onClear: ()=>state.setInputValue('')
39
- ,
39
+ autoComplete: "off",
40
+ onClear: ()=>{
41
+ state.setInputValue("");
42
+ if (onClear) onClear();
43
+ },
40
44
  onSubmit: (value)=>{
41
45
  // Prevent submission from search field if menu item was selected
42
46
  if (state.selectionManager.focusedKey === null) onSubmit(value, null);
43
- }
47
+ },
48
+ onKeyDown: onKeyDown,
49
+ onKeyUp: onKeyUp
44
50
  }, {
45
51
  value: state.inputValue,
46
52
  setValue: state.setInputValue
47
53
  }, inputRef);
48
- let { listBoxProps: listBoxProps , labelProps: labelProps , inputProps: comboBoxInputProps } = $51hfB$reactariacombobox.useComboBox({
54
+ let { listBoxProps: listBoxProps , labelProps: labelProps , inputProps: comboBoxInputProps } = (0, $kDrMH$reactariacombobox.useComboBox)({
49
55
  ...props,
50
56
  keyboardDelegate: keyboardDelegate,
51
57
  popoverRef: popoverRef,
52
58
  listBoxRef: listBoxRef,
53
59
  inputRef: inputRef,
54
60
  onFocus: undefined,
55
- onBlur: undefined
61
+ onFocusChange: undefined,
62
+ onBlur: undefined,
63
+ onKeyDown: undefined,
64
+ onKeyUp: undefined
56
65
  }, state);
57
66
  return {
58
67
  labelProps: labelProps,
59
- inputProps: $51hfB$reactariautils.mergeProps(inputProps, comboBoxInputProps),
68
+ inputProps: (0, $kDrMH$reactariautils.mergeProps)(inputProps, comboBoxInputProps),
60
69
  listBoxProps: listBoxProps,
61
- clearButtonProps: clearButtonProps
70
+ clearButtonProps: clearButtonProps,
71
+ descriptionProps: descriptionProps,
72
+ errorMessageProps: errorMessageProps
62
73
  };
63
74
  }
64
75
 
65
76
 
66
- $parcel$exportWildcard(module.exports, $c9cabc3db9f996d9$exports);
67
77
 
68
78
 
69
79
  //# sourceMappingURL=main.js.map
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;SCkDgB,yCAAqB,CAAI,KAAqC,EAAE,KAAuB,EAA6B,CAAC;IACnI,GAAG,CAAC,CAAC,aACH,UAAU,aACV,QAAQ,eACR,UAAU,qBACV,gBAAgB,aAChB,QAAQ,OAAS,CAAC;IAAA,CAAC,EACrB,CAAC,GAAG,KAAK;IAET,GAAG,CAAC,CAAC,aAAA,UAAU,qBAAE,gBAAgB,EAAA,CAAC,GAAG,0CAAc,CAAC,CAAC;WAChD,KAAK;QACR,KAAK,EAAE,KAAK,CAAC,UAAU;QACvB,QAAQ,EAAE,KAAK,CAAC,aAAa;QAC7B,YAAY,EAAE,CAAK;QACnB,OAAO,MAAQ,KAAK,CAAC,aAAa,CAAC,CAAE;;QACrC,QAAQ,GAAG,KAAK,GAAK,CAAC;YACpB,EAAiE,AAAjE,+DAAiE;YACjE,EAAE,EAAE,KAAK,CAAC,gBAAgB,CAAC,UAAU,KAAK,IAAI,EAC5C,QAAQ,CAAC,KAAK,EAAE,IAAI;QAExB,CAAC;IACH,CAAC,EAAE,CAAC;QACF,KAAK,EAAE,KAAK,CAAC,UAAU;QACvB,QAAQ,EAAE,KAAK,CAAC,aAAa;IAC/B,CAAC,EAAE,QAAQ;IAGX,GAAG,CAAC,CAAC,eAAA,YAAY,eAAE,UAAU,GAAE,UAAU,EAAE,kBAAkB,EAAA,CAAC,GAAG,oCAAW,CAC1E,CAAC;WACI,KAAK;0BACR,gBAAgB;oBAChB,UAAU;oBACV,UAAU;kBACV,QAAQ;QACR,OAAO,EAAE,SAAS;QAClB,MAAM,EAAE,SAAS;IACnB,CAAC,EACD,KAAK;IAGP,MAAM,CAAC,CAAC;oBACN,UAAU;QACV,UAAU,EAAE,gCAAU,CAAC,UAAU,EAAE,kBAAkB;sBACrD,YAAY;0BACZ,gBAAgB;IAClB,CAAC;AACH,CAAC","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 */\n\nexport * 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 {HTMLAttributes, 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\ninterface 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\ninterface SearchAutocompleteAria<T> {\n /** Props for the label element. */\n labelProps: HTMLAttributes<HTMLElement>,\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 } = props;\n\n let {inputProps, clearButtonProps} = useSearchField({\n ...props,\n value: state.inputValue,\n onChange: state.setInputValue,\n autoComplete: 'off',\n onClear: () => state.setInputValue(''),\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
@@ -1,53 +1,75 @@
1
- import {mergeProps as $47e58$mergeProps} from "@react-aria/utils";
2
- import {useComboBox as $47e58$useComboBox} from "@react-aria/combobox";
3
- import {useSearchField as $47e58$useSearchField} from "@react-aria/searchfield";
4
-
5
- function $parcel$export(e, n, v, s) {
6
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
7
- }
8
- var $5a38129ece344ad1$exports = {};
9
-
10
- $parcel$export($5a38129ece344ad1$exports, "useSearchAutocomplete", () => $5a38129ece344ad1$export$da7ade746446be1f);
1
+ import {mergeProps as $fgZRc$mergeProps} from "@react-aria/utils";
2
+ import {useComboBox as $fgZRc$useComboBox} from "@react-aria/combobox";
3
+ import {useSearchField as $fgZRc$useSearchField} from "@react-aria/searchfield";
11
4
 
5
+ /*
6
+ * Copyright 2021 Adobe. All rights reserved.
7
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License. You may obtain a copy
9
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software distributed under
12
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13
+ * OF ANY KIND, either express or implied. See the License for the specific language
14
+ * governing permissions and limitations under the License.
15
+ */ /*
16
+ * Copyright 2020 Adobe. All rights reserved.
17
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
18
+ * you may not use this file except in compliance with the License. You may obtain a copy
19
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
20
+ *
21
+ * Unless required by applicable law or agreed to in writing, software distributed under
22
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
23
+ * OF ANY KIND, either express or implied. See the License for the specific language
24
+ * governing permissions and limitations under the License.
25
+ */
12
26
 
13
27
 
14
- function $5a38129ece344ad1$export$da7ade746446be1f(props, state) {
15
- let { popoverRef: popoverRef , inputRef: inputRef , listBoxRef: listBoxRef , keyboardDelegate: keyboardDelegate , onSubmit: onSubmit = ()=>{
16
- } } = props;
17
- let { inputProps: inputProps , clearButtonProps: clearButtonProps } = $47e58$useSearchField({
28
+ function $c04f11f368135585$export$da7ade746446be1f(props, state) {
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)({
18
31
  ...props,
19
32
  value: state.inputValue,
20
33
  onChange: state.setInputValue,
21
- autoComplete: 'off',
22
- onClear: ()=>state.setInputValue('')
23
- ,
34
+ autoComplete: "off",
35
+ onClear: ()=>{
36
+ state.setInputValue("");
37
+ if (onClear) onClear();
38
+ },
24
39
  onSubmit: (value)=>{
25
40
  // Prevent submission from search field if menu item was selected
26
41
  if (state.selectionManager.focusedKey === null) onSubmit(value, null);
27
- }
42
+ },
43
+ onKeyDown: onKeyDown,
44
+ onKeyUp: onKeyUp
28
45
  }, {
29
46
  value: state.inputValue,
30
47
  setValue: state.setInputValue
31
48
  }, inputRef);
32
- let { listBoxProps: listBoxProps , labelProps: labelProps , inputProps: comboBoxInputProps } = $47e58$useComboBox({
49
+ let { listBoxProps: listBoxProps , labelProps: labelProps , inputProps: comboBoxInputProps } = (0, $fgZRc$useComboBox)({
33
50
  ...props,
34
51
  keyboardDelegate: keyboardDelegate,
35
52
  popoverRef: popoverRef,
36
53
  listBoxRef: listBoxRef,
37
54
  inputRef: inputRef,
38
55
  onFocus: undefined,
39
- onBlur: undefined
56
+ onFocusChange: undefined,
57
+ onBlur: undefined,
58
+ onKeyDown: undefined,
59
+ onKeyUp: undefined
40
60
  }, state);
41
61
  return {
42
62
  labelProps: labelProps,
43
- inputProps: $47e58$mergeProps(inputProps, comboBoxInputProps),
63
+ inputProps: (0, $fgZRc$mergeProps)(inputProps, comboBoxInputProps),
44
64
  listBoxProps: listBoxProps,
45
- clearButtonProps: clearButtonProps
65
+ clearButtonProps: clearButtonProps,
66
+ descriptionProps: descriptionProps,
67
+ errorMessageProps: errorMessageProps
46
68
  };
47
69
  }
48
70
 
49
71
 
50
72
 
51
73
 
52
- export {$5a38129ece344ad1$export$da7ade746446be1f as useSearchAutocomplete};
74
+ export {$c04f11f368135585$export$da7ade746446be1f as useSearchAutocomplete};
53
75
  //# sourceMappingURL=module.js.map
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;SCkDgB,yCAAqB,CAAI,KAAqC,EAAE,KAAuB,EAA6B,CAAC;IACnI,GAAG,CAAC,CAAC,aACH,UAAU,aACV,QAAQ,eACR,UAAU,qBACV,gBAAgB,aAChB,QAAQ,OAAS,CAAC;IAAA,CAAC,EACrB,CAAC,GAAG,KAAK;IAET,GAAG,CAAC,CAAC,aAAA,UAAU,qBAAE,gBAAgB,EAAA,CAAC,GAAG,qBAAc,CAAC,CAAC;WAChD,KAAK;QACR,KAAK,EAAE,KAAK,CAAC,UAAU;QACvB,QAAQ,EAAE,KAAK,CAAC,aAAa;QAC7B,YAAY,EAAE,CAAK;QACnB,OAAO,MAAQ,KAAK,CAAC,aAAa,CAAC,CAAE;;QACrC,QAAQ,GAAG,KAAK,GAAK,CAAC;YACpB,EAAiE,AAAjE,+DAAiE;YACjE,EAAE,EAAE,KAAK,CAAC,gBAAgB,CAAC,UAAU,KAAK,IAAI,EAC5C,QAAQ,CAAC,KAAK,EAAE,IAAI;QAExB,CAAC;IACH,CAAC,EAAE,CAAC;QACF,KAAK,EAAE,KAAK,CAAC,UAAU;QACvB,QAAQ,EAAE,KAAK,CAAC,aAAa;IAC/B,CAAC,EAAE,QAAQ;IAGX,GAAG,CAAC,CAAC,eAAA,YAAY,eAAE,UAAU,GAAE,UAAU,EAAE,kBAAkB,EAAA,CAAC,GAAG,kBAAW,CAC1E,CAAC;WACI,KAAK;0BACR,gBAAgB;oBAChB,UAAU;oBACV,UAAU;kBACV,QAAQ;QACR,OAAO,EAAE,SAAS;QAClB,MAAM,EAAE,SAAS;IACnB,CAAC,EACD,KAAK;IAGP,MAAM,CAAC,CAAC;oBACN,UAAU;QACV,UAAU,EAAE,iBAAU,CAAC,UAAU,EAAE,kBAAkB;sBACrD,YAAY;0BACZ,gBAAgB;IAClB,CAAC;AACH,CAAC","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 */\n\nexport * 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 {HTMLAttributes, 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\ninterface 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\ninterface SearchAutocompleteAria<T> {\n /** Props for the label element. */\n labelProps: HTMLAttributes<HTMLElement>,\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 } = props;\n\n let {inputProps, clearButtonProps} = useSearchField({\n ...props,\n value: state.inputValue,\n onChange: state.setInputValue,\n autoComplete: 'off',\n onClear: () => state.setInputValue(''),\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
@@ -1,10 +1,24 @@
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
- import { HTMLAttributes, InputHTMLAttributes, RefObject } from "react";
5
- import { KeyboardDelegate } from "@react-types/shared";
6
- import { SearchAutocompleteProps } from "@react-types/autocomplete";
7
- interface AriaSearchAutocompleteProps<T> extends SearchAutocompleteProps<T> {
5
+ import { DOMAttributes, KeyboardDelegate } from "@react-types/shared";
6
+ import { InputHTMLAttributes, RefObject } from "react";
7
+ export interface SearchAutocompleteAria<T> {
8
+ /** Props for the label element. */
9
+ labelProps: DOMAttributes;
10
+ /** Props for the search input element. */
11
+ inputProps: InputHTMLAttributes<HTMLInputElement>;
12
+ /** Props for the list box, to be passed to [useListBox](useListBox.html). */
13
+ listBoxProps: AriaListBoxOptions<T>;
14
+ /** Props for the search input's clear button. */
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> {
8
22
  /** The ref for the input element. */
9
23
  inputRef: RefObject<HTMLInputElement>;
10
24
  /** The ref for the list box popover. */
@@ -14,22 +28,13 @@ interface AriaSearchAutocompleteProps<T> extends SearchAutocompleteProps<T> {
14
28
  /** An optional keyboard delegate implementation, to override the default. */
15
29
  keyboardDelegate?: KeyboardDelegate;
16
30
  }
17
- interface SearchAutocompleteAria<T> {
18
- /** Props for the label element. */
19
- labelProps: HTMLAttributes<HTMLElement>;
20
- /** Props for the search input element. */
21
- inputProps: InputHTMLAttributes<HTMLInputElement>;
22
- /** Props for the list box, to be passed to [useListBox](useListBox.html). */
23
- listBoxProps: AriaListBoxOptions<T>;
24
- /** Props for the search input's clear button. */
25
- clearButtonProps: AriaButtonProps;
26
- }
27
31
  /**
28
32
  * Provides the behavior and accessibility implementation for a search autocomplete component.
29
33
  * A search autocomplete combines a combobox with a searchfield, allowing users to filter a list of options to items matching a query.
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":";;;;;;AAsBA,sCAAsC,CAAC,CAAE,SAAQ,wBAAwB,CAAC,CAAC;IACzE,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,iCAAiC,CAAC;IAChC,mCAAmC;IACnC,UAAU,EAAE,eAAe,WAAW,CAAC,CAAC;IACxC,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,CA8ClI","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 */\n\nexport * 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,10 +1,15 @@
1
1
  {
2
2
  "name": "@react-aria/autocomplete",
3
- "version": "3.0.0-alpha.2",
3
+ "version": "3.0.0-alpha.20",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/module.js",
8
+ "exports": {
9
+ "types": "./dist/types.d.ts",
10
+ "import": "./dist/import.mjs",
11
+ "require": "./dist/main.js"
12
+ },
8
13
  "types": "dist/types.d.ts",
9
14
  "source": "src/index.ts",
10
15
  "files": [
@@ -17,30 +22,31 @@
17
22
  "url": "https://github.com/adobe/react-spectrum"
18
23
  },
19
24
  "dependencies": {
20
- "@babel/runtime": "^7.6.2",
21
- "@react-aria/combobox": "^3.2.2",
22
- "@react-aria/i18n": "^3.3.5",
23
- "@react-aria/listbox": "^3.4.1",
24
- "@react-aria/live-announcer": "^3.0.2",
25
- "@react-aria/menu": "^3.4.0",
26
- "@react-aria/overlays": "^3.7.4",
27
- "@react-aria/searchfield": "^3.2.3",
28
- "@react-aria/selection": "^3.7.2",
29
- "@react-aria/textfield": "^3.5.1",
30
- "@react-aria/utils": "^3.11.1",
31
- "@react-stately/collections": "^3.3.5",
32
- "@react-stately/combobox": "^3.0.2",
33
- "@react-types/autocomplete": "3.0.0-alpha.1",
34
- "@react-types/button": "^3.4.2",
35
- "@react-types/combobox": "^3.2.2",
36
- "@react-types/searchfield": "^3.1.3",
37
- "@react-types/shared": "^3.11.0"
25
+ "@react-aria/combobox": "^3.6.4",
26
+ "@react-aria/i18n": "^3.8.2",
27
+ "@react-aria/listbox": "^3.10.2",
28
+ "@react-aria/live-announcer": "^3.3.1",
29
+ "@react-aria/menu": "^3.10.2",
30
+ "@react-aria/overlays": "^3.17.0",
31
+ "@react-aria/searchfield": "^3.5.5",
32
+ "@react-aria/selection": "^3.16.2",
33
+ "@react-aria/textfield": "^3.12.0",
34
+ "@react-aria/utils": "^3.20.0",
35
+ "@react-stately/collections": "^3.10.1",
36
+ "@react-stately/combobox": "^3.7.0",
37
+ "@react-types/autocomplete": "3.0.0-alpha.16",
38
+ "@react-types/button": "^3.8.0",
39
+ "@react-types/combobox": "^3.8.0",
40
+ "@react-types/searchfield": "^3.5.0",
41
+ "@react-types/shared": "^3.20.0",
42
+ "@swc/helpers": "^0.5.0"
38
43
  },
39
44
  "peerDependencies": {
40
- "react": "^16.8.0 || ^17.0.0-rc.1"
45
+ "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0",
46
+ "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
41
47
  },
42
48
  "publishConfig": {
43
49
  "access": "public"
44
50
  },
45
- "gitHead": "54c2366c4f31bd4bf619126131cd583c12972acc"
51
+ "gitHead": "54fbaa67cc56867506811819fef765546d403253"
46
52
  }
package/src/index.ts CHANGED
@@ -9,5 +9,6 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
-
13
- export * from './useSearchAutocomplete';
12
+ export {useSearchAutocomplete} from './useSearchAutocomplete';
13
+ export type {AriaSearchAutocompleteOptions, SearchAutocompleteAria} from './useSearchAutocomplete';
14
+ export type {AriaSearchAutocompleteProps} from '@react-types/autocomplete';
@@ -12,15 +12,30 @@
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 {HTMLAttributes, InputHTMLAttributes, RefObject} from 'react';
17
- import {KeyboardDelegate} from '@react-types/shared';
17
+ import {DOMAttributes, KeyboardDelegate} from '@react-types/shared';
18
+ import {InputHTMLAttributes, RefObject} from 'react';
18
19
  import {mergeProps} from '@react-aria/utils';
19
- import {SearchAutocompleteProps} from '@react-types/autocomplete';
20
20
  import {useComboBox} from '@react-aria/combobox';
21
21
  import {useSearchField} from '@react-aria/searchfield';
22
22
 
23
- interface AriaSearchAutocompleteProps<T> extends SearchAutocompleteProps<T> {
23
+ export interface SearchAutocompleteAria<T> {
24
+ /** Props for the label element. */
25
+ labelProps: DOMAttributes,
26
+ /** Props for the search input element. */
27
+ inputProps: InputHTMLAttributes<HTMLInputElement>,
28
+ /** Props for the list box, to be passed to [useListBox](useListBox.html). */
29
+ listBoxProps: AriaListBoxOptions<T>,
30
+ /** Props for the search input's clear button. */
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> {
24
39
  /** The ref for the input element. */
25
40
  inputRef: RefObject<HTMLInputElement>,
26
41
  /** The ref for the list box popover. */
@@ -31,44 +46,43 @@ interface AriaSearchAutocompleteProps<T> extends SearchAutocompleteProps<T> {
31
46
  keyboardDelegate?: KeyboardDelegate
32
47
  }
33
48
 
34
- interface SearchAutocompleteAria<T> {
35
- /** Props for the label element. */
36
- labelProps: HTMLAttributes<HTMLElement>,
37
- /** Props for the search input element. */
38
- inputProps: InputHTMLAttributes<HTMLInputElement>,
39
- /** Props for the list box, to be passed to [useListBox](useListBox.html). */
40
- listBoxProps: AriaListBoxOptions<T>,
41
- /** Props for the search input's clear button. */
42
- clearButtonProps: AriaButtonProps
43
- }
44
-
45
49
  /**
46
50
  * Provides the behavior and accessibility implementation for a search autocomplete component.
47
51
  * A search autocomplete combines a combobox with a searchfield, allowing users to filter a list of options to items matching a query.
48
52
  * @param props - Props for the search autocomplete.
49
53
  * @param state - State for the search autocomplete, as returned by `useSearchAutocomplete`.
50
54
  */
51
- 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> {
52
56
  let {
53
57
  popoverRef,
54
58
  inputRef,
55
59
  listBoxRef,
56
60
  keyboardDelegate,
57
- onSubmit = () => {}
61
+ onSubmit = () => {},
62
+ onClear,
63
+ onKeyDown,
64
+ onKeyUp
58
65
  } = props;
59
66
 
60
- let {inputProps, clearButtonProps} = useSearchField({
67
+ let {inputProps, clearButtonProps, descriptionProps, errorMessageProps} = useSearchField({
61
68
  ...props,
62
69
  value: state.inputValue,
63
70
  onChange: state.setInputValue,
64
71
  autoComplete: 'off',
65
- onClear: () => state.setInputValue(''),
72
+ onClear: () => {
73
+ state.setInputValue('');
74
+ if (onClear) {
75
+ onClear();
76
+ }
77
+ },
66
78
  onSubmit: (value) => {
67
79
  // Prevent submission from search field if menu item was selected
68
80
  if (state.selectionManager.focusedKey === null) {
69
81
  onSubmit(value, null);
70
82
  }
71
- }
83
+ },
84
+ onKeyDown,
85
+ onKeyUp
72
86
  }, {
73
87
  value: state.inputValue,
74
88
  setValue: state.setInputValue
@@ -83,7 +97,10 @@ export function useSearchAutocomplete<T>(props: AriaSearchAutocompleteProps<T>,
83
97
  listBoxRef,
84
98
  inputRef,
85
99
  onFocus: undefined,
86
- onBlur: undefined
100
+ onFocusChange: undefined,
101
+ onBlur: undefined,
102
+ onKeyDown: undefined,
103
+ onKeyUp: undefined
87
104
  },
88
105
  state
89
106
  );
@@ -92,6 +109,8 @@ export function useSearchAutocomplete<T>(props: AriaSearchAutocompleteProps<T>,
92
109
  labelProps,
93
110
  inputProps: mergeProps(inputProps, comboBoxInputProps),
94
111
  listBoxProps,
95
- clearButtonProps
112
+ clearButtonProps,
113
+ descriptionProps,
114
+ errorMessageProps
96
115
  };
97
116
  }