@react-aria/autocomplete 3.0.0-alpha.12 → 3.0.0-alpha.14

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,68 @@
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 } = props;
30
+ let { inputProps: inputProps , clearButtonProps: clearButtonProps } = (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
+ }, {
44
+ value: state.inputValue,
45
+ setValue: state.setInputValue
46
+ }, inputRef);
47
+ let { listBoxProps: listBoxProps , labelProps: labelProps , inputProps: comboBoxInputProps } = (0, $fgZRc$useComboBox)({
48
+ ...props,
49
+ keyboardDelegate: keyboardDelegate,
50
+ popoverRef: popoverRef,
51
+ listBoxRef: listBoxRef,
52
+ inputRef: inputRef,
53
+ onFocus: undefined,
54
+ onBlur: undefined
55
+ }, state);
56
+ return {
57
+ labelProps: labelProps,
58
+ inputProps: (0, $fgZRc$mergeProps)(inputProps, comboBoxInputProps),
59
+ listBoxProps: listBoxProps,
60
+ clearButtonProps: clearButtonProps
61
+ };
62
+ }
63
+
64
+
65
+
66
+
67
+ export {$c04f11f368135585$export$da7ade746446be1f as useSearchAutocomplete};
68
+ //# sourceMappingURL=module.js.map
package/dist/main.js CHANGED
@@ -7,19 +7,40 @@ function $parcel$export(e, n, v, s) {
7
7
  }
8
8
 
9
9
  $parcel$export(module.exports, "useSearchAutocomplete", () => $3c40871f8cc2eb01$export$da7ade746446be1f);
10
-
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
+ */
11
31
 
12
32
 
13
33
  function $3c40871f8cc2eb01$export$da7ade746446be1f(props, state) {
14
- let { popoverRef: popoverRef , inputRef: inputRef , listBoxRef: listBoxRef , keyboardDelegate: keyboardDelegate , onSubmit: onSubmit = ()=>{
15
- } } = props;
16
- let { inputProps: inputProps , clearButtonProps: clearButtonProps } = $kDrMH$reactariasearchfield.useSearchField({
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)({
17
36
  ...props,
18
37
  value: state.inputValue,
19
38
  onChange: state.setInputValue,
20
- autoComplete: 'off',
21
- onClear: ()=>state.setInputValue('')
22
- ,
39
+ autoComplete: "off",
40
+ onClear: ()=>{
41
+ state.setInputValue("");
42
+ if (onClear) onClear();
43
+ },
23
44
  onSubmit: (value)=>{
24
45
  // Prevent submission from search field if menu item was selected
25
46
  if (state.selectionManager.focusedKey === null) onSubmit(value, null);
@@ -28,7 +49,7 @@ function $3c40871f8cc2eb01$export$da7ade746446be1f(props, state) {
28
49
  value: state.inputValue,
29
50
  setValue: state.setInputValue
30
51
  }, inputRef);
31
- let { listBoxProps: listBoxProps , labelProps: labelProps , inputProps: comboBoxInputProps } = $kDrMH$reactariacombobox.useComboBox({
52
+ let { listBoxProps: listBoxProps , labelProps: labelProps , inputProps: comboBoxInputProps } = (0, $kDrMH$reactariacombobox.useComboBox)({
32
53
  ...props,
33
54
  keyboardDelegate: keyboardDelegate,
34
55
  popoverRef: popoverRef,
@@ -39,7 +60,7 @@ function $3c40871f8cc2eb01$export$da7ade746446be1f(props, state) {
39
60
  }, state);
40
61
  return {
41
62
  labelProps: labelProps,
42
- inputProps: $kDrMH$reactariautils.mergeProps(inputProps, comboBoxInputProps),
63
+ inputProps: (0, $kDrMH$reactariautils.mergeProps)(inputProps, comboBoxInputProps),
43
64
  listBoxProps: listBoxProps,
44
65
  clearButtonProps: clearButtonProps
45
66
  };
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;SCmDgB,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 */\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 } = 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,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"}
package/dist/module.js CHANGED
@@ -2,19 +2,40 @@ import {mergeProps as $fgZRc$mergeProps} from "@react-aria/utils";
2
2
  import {useComboBox as $fgZRc$useComboBox} from "@react-aria/combobox";
3
3
  import {useSearchField as $fgZRc$useSearchField} from "@react-aria/searchfield";
4
4
 
5
-
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
+ */
6
26
 
7
27
 
8
28
  function $c04f11f368135585$export$da7ade746446be1f(props, state) {
9
- let { popoverRef: popoverRef , inputRef: inputRef , listBoxRef: listBoxRef , keyboardDelegate: keyboardDelegate , onSubmit: onSubmit = ()=>{
10
- } } = props;
11
- let { inputProps: inputProps , clearButtonProps: clearButtonProps } = $fgZRc$useSearchField({
29
+ let { popoverRef: popoverRef , inputRef: inputRef , listBoxRef: listBoxRef , keyboardDelegate: keyboardDelegate , onSubmit: onSubmit = ()=>{} , onClear: onClear } = props;
30
+ let { inputProps: inputProps , clearButtonProps: clearButtonProps } = (0, $fgZRc$useSearchField)({
12
31
  ...props,
13
32
  value: state.inputValue,
14
33
  onChange: state.setInputValue,
15
- autoComplete: 'off',
16
- onClear: ()=>state.setInputValue('')
17
- ,
34
+ autoComplete: "off",
35
+ onClear: ()=>{
36
+ state.setInputValue("");
37
+ if (onClear) onClear();
38
+ },
18
39
  onSubmit: (value)=>{
19
40
  // Prevent submission from search field if menu item was selected
20
41
  if (state.selectionManager.focusedKey === null) onSubmit(value, null);
@@ -23,7 +44,7 @@ function $c04f11f368135585$export$da7ade746446be1f(props, state) {
23
44
  value: state.inputValue,
24
45
  setValue: state.setInputValue
25
46
  }, inputRef);
26
- let { listBoxProps: listBoxProps , labelProps: labelProps , inputProps: comboBoxInputProps } = $fgZRc$useComboBox({
47
+ let { listBoxProps: listBoxProps , labelProps: labelProps , inputProps: comboBoxInputProps } = (0, $fgZRc$useComboBox)({
27
48
  ...props,
28
49
  keyboardDelegate: keyboardDelegate,
29
50
  popoverRef: popoverRef,
@@ -34,7 +55,7 @@ function $c04f11f368135585$export$da7ade746446be1f(props, state) {
34
55
  }, state);
35
56
  return {
36
57
  labelProps: labelProps,
37
- inputProps: $fgZRc$mergeProps(inputProps, comboBoxInputProps),
58
+ inputProps: (0, $fgZRc$mergeProps)(inputProps, comboBoxInputProps),
38
59
  listBoxProps: listBoxProps,
39
60
  clearButtonProps: clearButtonProps
40
61
  };
@@ -1 +1 @@
1
- {"mappings":";;;;;;;SCmDgB,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 */\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 } = 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,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 +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,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 */\nexport {useSearchAutocomplete} from './useSearchAutocomplete';\nexport type {AriaSearchAutocompleteProps, SearchAutocompleteAria} from './useSearchAutocomplete';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
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"}
package/package.json CHANGED
@@ -1,10 +1,15 @@
1
1
  {
2
2
  "name": "@react-aria/autocomplete",
3
- "version": "3.0.0-alpha.12",
3
+ "version": "3.0.0-alpha.14",
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,24 +22,24 @@
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.4.3",
22
- "@react-aria/i18n": "^3.6.2",
23
- "@react-aria/listbox": "^3.7.1",
24
- "@react-aria/live-announcer": "^3.1.1",
25
- "@react-aria/menu": "^3.7.0",
26
- "@react-aria/overlays": "^3.12.0",
27
- "@react-aria/searchfield": "^3.4.3",
28
- "@react-aria/selection": "^3.12.0",
29
- "@react-aria/textfield": "^3.8.0",
30
- "@react-aria/utils": "^3.14.1",
31
- "@react-stately/collections": "^3.5.0",
32
- "@react-stately/combobox": "^3.3.0",
33
- "@react-types/autocomplete": "3.0.0-alpha.10",
34
- "@react-types/button": "^3.7.0",
35
- "@react-types/combobox": "^3.5.5",
36
- "@react-types/searchfield": "^3.3.5",
37
- "@react-types/shared": "^3.16.0"
25
+ "@react-aria/combobox": "^3.5.0",
26
+ "@react-aria/i18n": "^3.7.0",
27
+ "@react-aria/listbox": "^3.8.0",
28
+ "@react-aria/live-announcer": "^3.2.0",
29
+ "@react-aria/menu": "^3.8.0",
30
+ "@react-aria/overlays": "^3.13.0",
31
+ "@react-aria/searchfield": "^3.5.0",
32
+ "@react-aria/selection": "^3.13.0",
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",
42
+ "@swc/helpers": "^0.4.14"
38
43
  },
39
44
  "peerDependencies": {
40
45
  "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
@@ -42,5 +47,5 @@
42
47
  "publishConfig": {
43
48
  "access": "public"
44
49
  },
45
- "gitHead": "2954307ddbefe149241685440c81f80ece6b2c83"
50
+ "gitHead": "a0efee84aa178cb1a202951dfd6d8de02b292307"
46
51
  }
@@ -55,7 +55,8 @@ export function useSearchAutocomplete<T>(props: AriaSearchAutocompleteProps<T>,
55
55
  inputRef,
56
56
  listBoxRef,
57
57
  keyboardDelegate,
58
- onSubmit = () => {}
58
+ onSubmit = () => {},
59
+ onClear
59
60
  } = props;
60
61
 
61
62
  let {inputProps, clearButtonProps} = useSearchField({
@@ -63,7 +64,12 @@ export function useSearchAutocomplete<T>(props: AriaSearchAutocompleteProps<T>,
63
64
  value: state.inputValue,
64
65
  onChange: state.setInputValue,
65
66
  autoComplete: 'off',
66
- onClear: () => state.setInputValue(''),
67
+ onClear: () => {
68
+ state.setInputValue('');
69
+ if (onClear) {
70
+ onClear();
71
+ }
72
+ },
67
73
  onSubmit: (value) => {
68
74
  // Prevent submission from search field if menu item was selected
69
75
  if (state.selectionManager.focusedKey === null) {