@react-aria/autocomplete 3.0.0-alpha.3 → 3.0.0-alpha.30

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,17 @@
1
+ import {useSearchAutocomplete as $c04f11f368135585$export$da7ade746446be1f} from "./useSearchAutocomplete.mjs";
2
+
3
+ /*
4
+ * Copyright 2021 Adobe. All rights reserved.
5
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License. You may obtain a copy
7
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
+ * OF ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ */
14
+
15
+
16
+ export {$c04f11f368135585$export$da7ade746446be1f as useSearchAutocomplete};
17
+ //# sourceMappingURL=module.js.map
package/dist/main.js CHANGED
@@ -1,69 +1,22 @@
1
- var $b2FiB$reactariautils = require("@react-aria/utils");
2
- var $b2FiB$reactariacombobox = require("@react-aria/combobox");
3
- var $b2FiB$reactariasearchfield = require("@react-aria/searchfield");
1
+ var $3c40871f8cc2eb01$exports = require("./useSearchAutocomplete.main.js");
4
2
 
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
3
 
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
4
  function $parcel$export(e, n, v, s) {
22
5
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
23
6
  }
24
- var $b62821d4fd5b19fa$exports = {};
25
-
26
- $parcel$export($b62821d4fd5b19fa$exports, "useSearchAutocomplete", () => $b62821d4fd5b19fa$export$da7ade746446be1f);
27
-
28
-
29
-
30
- function $b62821d4fd5b19fa$export$da7ade746446be1f(props, state) {
31
- let { popoverRef: popoverRef , inputRef: inputRef , listBoxRef: listBoxRef , keyboardDelegate: keyboardDelegate , onSubmit: onSubmit = ()=>{
32
- } } = props;
33
- let { inputProps: inputProps , clearButtonProps: clearButtonProps } = $b2FiB$reactariasearchfield.useSearchField({
34
- ...props,
35
- value: state.inputValue,
36
- onChange: state.setInputValue,
37
- autoComplete: 'off',
38
- onClear: ()=>state.setInputValue('')
39
- ,
40
- onSubmit: (value)=>{
41
- // Prevent submission from search field if menu item was selected
42
- if (state.selectionManager.focusedKey === null) onSubmit(value, null);
43
- }
44
- }, {
45
- value: state.inputValue,
46
- setValue: state.setInputValue
47
- }, inputRef);
48
- let { listBoxProps: listBoxProps , labelProps: labelProps , inputProps: comboBoxInputProps } = $b2FiB$reactariacombobox.useComboBox({
49
- ...props,
50
- keyboardDelegate: keyboardDelegate,
51
- popoverRef: popoverRef,
52
- listBoxRef: listBoxRef,
53
- inputRef: inputRef,
54
- onFocus: undefined,
55
- onBlur: undefined
56
- }, state);
57
- return {
58
- labelProps: labelProps,
59
- inputProps: $b2FiB$reactariautils.mergeProps(inputProps, comboBoxInputProps),
60
- listBoxProps: listBoxProps,
61
- clearButtonProps: clearButtonProps
62
- };
63
- }
64
-
65
7
 
66
- $parcel$exportWildcard(module.exports, $b62821d4fd5b19fa$exports);
8
+ $parcel$export(module.exports, "useSearchAutocomplete", () => $3c40871f8cc2eb01$exports.useSearchAutocomplete);
9
+ /*
10
+ * Copyright 2021 Adobe. All rights reserved.
11
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
12
+ * you may not use this file except in compliance with the License. You may obtain a copy
13
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
14
+ *
15
+ * Unless required by applicable law or agreed to in writing, software distributed under
16
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
17
+ * OF ANY KIND, either express or implied. See the License for the specific language
18
+ * governing permissions and limitations under the License.
19
+ */
67
20
 
68
21
 
69
22
  //# 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;;;;;;;;;;CAUC","sources":["packages/@react-aria/autocomplete/src/index.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"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -1,53 +1,17 @@
1
- import {mergeProps as $7oZbT$mergeProps} from "@react-aria/utils";
2
- import {useComboBox as $7oZbT$useComboBox} from "@react-aria/combobox";
3
- import {useSearchField as $7oZbT$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 $4bf7cff9646c9c7f$exports = {};
9
-
10
- $parcel$export($4bf7cff9646c9c7f$exports, "useSearchAutocomplete", () => $4bf7cff9646c9c7f$export$da7ade746446be1f);
11
-
12
-
13
-
14
- function $4bf7cff9646c9c7f$export$da7ade746446be1f(props, state) {
15
- let { popoverRef: popoverRef , inputRef: inputRef , listBoxRef: listBoxRef , keyboardDelegate: keyboardDelegate , onSubmit: onSubmit = ()=>{
16
- } } = props;
17
- let { inputProps: inputProps , clearButtonProps: clearButtonProps } = $7oZbT$useSearchField({
18
- ...props,
19
- value: state.inputValue,
20
- onChange: state.setInputValue,
21
- autoComplete: 'off',
22
- onClear: ()=>state.setInputValue('')
23
- ,
24
- onSubmit: (value)=>{
25
- // Prevent submission from search field if menu item was selected
26
- if (state.selectionManager.focusedKey === null) onSubmit(value, null);
27
- }
28
- }, {
29
- value: state.inputValue,
30
- setValue: state.setInputValue
31
- }, inputRef);
32
- let { listBoxProps: listBoxProps , labelProps: labelProps , inputProps: comboBoxInputProps } = $7oZbT$useComboBox({
33
- ...props,
34
- keyboardDelegate: keyboardDelegate,
35
- popoverRef: popoverRef,
36
- listBoxRef: listBoxRef,
37
- inputRef: inputRef,
38
- onFocus: undefined,
39
- onBlur: undefined
40
- }, state);
41
- return {
42
- labelProps: labelProps,
43
- inputProps: $7oZbT$mergeProps(inputProps, comboBoxInputProps),
44
- listBoxProps: listBoxProps,
45
- clearButtonProps: clearButtonProps
46
- };
47
- }
48
-
49
-
50
-
51
-
52
- export {$4bf7cff9646c9c7f$export$da7ade746446be1f as useSearchAutocomplete};
1
+ import {useSearchAutocomplete as $c04f11f368135585$export$da7ade746446be1f} from "./useSearchAutocomplete.module.js";
2
+
3
+ /*
4
+ * Copyright 2021 Adobe. All rights reserved.
5
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License. You may obtain a copy
7
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
+ * OF ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ */
14
+
15
+
16
+ export {$c04f11f368135585$export$da7ade746446be1f as useSearchAutocomplete};
53
17
  //# 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;;;;;;;;;;CAUC","sources":["packages/@react-aria/autocomplete/src/index.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"],"names":[],"version":3,"file":"module.js.map"}
package/dist/types.d.ts CHANGED
@@ -1,28 +1,38 @@
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> {
8
- /** The ref for the input element. */
9
- inputRef: RefObject<HTMLInputElement>;
10
- /** The ref for the list box popover. */
11
- popoverRef: RefObject<HTMLDivElement>;
12
- /** The ref for the list box. */
13
- listBoxRef: RefObject<HTMLElement>;
14
- /** An optional keyboard delegate implementation, to override the default. */
15
- keyboardDelegate?: KeyboardDelegate;
16
- }
17
- interface SearchAutocompleteAria<T> {
5
+ import { DOMAttributes, KeyboardDelegate, LayoutDelegate, RefObject, ValidationResult } from "@react-types/shared";
6
+ import { InputHTMLAttributes } from "react";
7
+ export interface SearchAutocompleteAria<T> extends ValidationResult {
18
8
  /** Props for the label element. */
19
- labelProps: HTMLAttributes<HTMLElement>;
9
+ labelProps: DOMAttributes;
20
10
  /** Props for the search input element. */
21
11
  inputProps: InputHTMLAttributes<HTMLInputElement>;
22
12
  /** Props for the list box, to be passed to [useListBox](useListBox.html). */
23
13
  listBoxProps: AriaListBoxOptions<T>;
24
14
  /** Props for the search input's clear button. */
25
15
  clearButtonProps: AriaButtonProps;
16
+ /** Props for the search autocomplete description element, if any. */
17
+ descriptionProps: DOMAttributes;
18
+ /** Props for the search autocomplete error message element, if any. */
19
+ errorMessageProps: DOMAttributes;
20
+ }
21
+ export interface AriaSearchAutocompleteOptions<T> extends AriaSearchAutocompleteProps<T> {
22
+ /** The ref for the input element. */
23
+ inputRef: RefObject<HTMLInputElement | null>;
24
+ /** The ref for the list box popover. */
25
+ popoverRef: RefObject<HTMLDivElement | null>;
26
+ /** The ref for the list box. */
27
+ listBoxRef: RefObject<HTMLElement | null>;
28
+ /** An optional keyboard delegate implementation, to override the default. */
29
+ keyboardDelegate?: KeyboardDelegate;
30
+ /**
31
+ * A delegate object that provides layout information for items in the collection.
32
+ * By default this uses the DOM, but this can be overridden to implement things like
33
+ * virtualized scrolling.
34
+ */
35
+ layoutDelegate?: LayoutDelegate;
26
36
  }
27
37
  /**
28
38
  * Provides the behavior and accessibility implementation for a search autocomplete component.
@@ -30,6 +40,7 @@ interface SearchAutocompleteAria<T> {
30
40
  * @param props - Props for the search autocomplete.
31
41
  * @param state - State for the search autocomplete, as returned by `useSearchAutocomplete`.
32
42
  */
33
- export function useSearchAutocomplete<T>(props: AriaSearchAutocompleteProps<T>, state: ComboBoxState<T>): SearchAutocompleteAria<T>;
43
+ export function useSearchAutocomplete<T>(props: AriaSearchAutocompleteOptions<T>, state: ComboBoxState<T>): SearchAutocompleteAria<T>;
44
+ export type { AriaSearchAutocompleteProps } from '@react-types/autocomplete';
34
45
 
35
46
  //# 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,CAAE,SAAQ,gBAAgB;IACjE,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,GAAG,IAAI,CAAC,CAAC;IAC7C,wCAAwC;IACxC,UAAU,EAAE,UAAU,cAAc,GAAG,IAAI,CAAC,CAAC;IAC7C,gCAAgC;IAChC,UAAU,EAAE,UAAU,WAAW,GAAG,IAAI,CAAC,CAAC;IAC1C,6EAA6E;IAC7E,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC;;;;OAIG;IACH,cAAc,CAAC,EAAE,cAAc,CAAA;CAChC;AAED;;;;;GAKG;AACH,sCAAsC,CAAC,EAAE,KAAK,EAAE,8BAA8B,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,GAAG,uBAAuB,CAAC,CAAC,CAwEpI;ACvHD,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"}
@@ -0,0 +1,73 @@
1
+ var $2rg0a$reactariautils = require("@react-aria/utils");
2
+ var $2rg0a$reactariacombobox = require("@react-aria/combobox");
3
+ var $2rg0a$reactariasearchfield = require("@react-aria/searchfield");
4
+
5
+
6
+ function $parcel$export(e, n, v, s) {
7
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
8
+ }
9
+
10
+ $parcel$export(module.exports, "useSearchAutocomplete", () => $3c40871f8cc2eb01$export$da7ade746446be1f);
11
+ /*
12
+ * Copyright 2020 Adobe. All rights reserved.
13
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
14
+ * you may not use this file except in compliance with the License. You may obtain a copy
15
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
16
+ *
17
+ * Unless required by applicable law or agreed to in writing, software distributed under
18
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
19
+ * OF ANY KIND, either express or implied. See the License for the specific language
20
+ * governing permissions and limitations under the License.
21
+ */
22
+
23
+
24
+ function $3c40871f8cc2eb01$export$da7ade746446be1f(props, state) {
25
+ let { popoverRef: popoverRef, inputRef: inputRef, listBoxRef: listBoxRef, keyboardDelegate: keyboardDelegate, layoutDelegate: layoutDelegate, onSubmit: onSubmit = ()=>{}, onClear: onClear, onKeyDown: onKeyDown, onKeyUp: onKeyUp, isInvalid: isInvalid, validationState: validationState, validationBehavior: validationBehavior, isRequired: isRequired, ...otherProps } = props;
26
+ let { inputProps: inputProps, clearButtonProps: clearButtonProps } = (0, $2rg0a$reactariasearchfield.useSearchField)({
27
+ ...otherProps,
28
+ value: state.inputValue,
29
+ onChange: state.setInputValue,
30
+ autoComplete: 'off',
31
+ onClear: ()=>{
32
+ state.setInputValue('');
33
+ if (onClear) onClear();
34
+ },
35
+ onSubmit: (value)=>{
36
+ // Prevent submission from search field if menu item was selected
37
+ if (state.selectionManager.focusedKey === null) onSubmit(value, null);
38
+ },
39
+ onKeyDown: onKeyDown,
40
+ onKeyUp: onKeyUp
41
+ }, {
42
+ value: state.inputValue,
43
+ setValue: state.setInputValue
44
+ }, inputRef);
45
+ let { listBoxProps: listBoxProps, labelProps: labelProps, inputProps: comboBoxInputProps, ...validation } = (0, $2rg0a$reactariacombobox.useComboBox)({
46
+ ...otherProps,
47
+ keyboardDelegate: keyboardDelegate,
48
+ layoutDelegate: layoutDelegate,
49
+ popoverRef: popoverRef,
50
+ listBoxRef: listBoxRef,
51
+ inputRef: inputRef,
52
+ onFocus: undefined,
53
+ onFocusChange: undefined,
54
+ onBlur: undefined,
55
+ onKeyDown: undefined,
56
+ onKeyUp: undefined,
57
+ isInvalid: isInvalid,
58
+ validationState: validationState,
59
+ validationBehavior: validationBehavior,
60
+ isRequired: isRequired,
61
+ validate: undefined
62
+ }, state);
63
+ return {
64
+ labelProps: labelProps,
65
+ inputProps: (0, $2rg0a$reactariautils.mergeProps)(inputProps, comboBoxInputProps),
66
+ listBoxProps: listBoxProps,
67
+ clearButtonProps: clearButtonProps,
68
+ ...validation
69
+ };
70
+ }
71
+
72
+
73
+ //# sourceMappingURL=useSearchAutocomplete.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAkDM,SAAS,0CAAyB,KAAuC,EAAE,KAAuB;IACvG,IAAI,cACF,UAAU,YACV,QAAQ,cACR,UAAU,oBACV,gBAAgB,kBAChB,cAAc,YACd,WAAW,KAAO,YAClB,OAAO,aACP,SAAS,WACT,OAAO,aACP,SAAS,mBACT,eAAe,sBACf,kBAAkB,cAClB,UAAU,EACV,GAAG,YACJ,GAAG;IAEJ,IAAI,cAAC,UAAU,oBAAE,gBAAgB,EAAC,GAAG,CAAA,GAAA,0CAAa,EAAE;QAClD,GAAG,UAAU;QACb,OAAO,MAAM,UAAU;QACvB,UAAU,MAAM,aAAa;QAC7B,cAAc;QACd,SAAS;YACP,MAAM,aAAa,CAAC;YACpB,IAAI,SACF;QAEJ;QACA,UAAU,CAAC;YACT,iEAAiE;YACjE,IAAI,MAAM,gBAAgB,CAAC,UAAU,KAAK,MACxC,SAAS,OAAO;QAEpB;mBACA;iBACA;IACF,GAAG;QACD,OAAO,MAAM,UAAU;QACvB,UAAU,MAAM,aAAa;IAC/B,GAAG;IAGH,IAAI,gBAAC,YAAY,cAAE,UAAU,EAAE,YAAY,kBAAkB,EAAE,GAAG,YAAW,GAAG,CAAA,GAAA,oCAAU,EACxF;QACE,GAAG,UAAU;0BACb;wBACA;oBACA;oBACA;kBACA;QACA,SAAS;QACT,eAAe;QACf,QAAQ;QACR,WAAW;QACX,SAAS;mBACT;yBACA;4BACA;oBACA;QACA,UAAU;IACZ,GACA;IAGF,OAAO;oBACL;QACA,YAAY,CAAA,GAAA,gCAAS,EAAE,YAAY;sBACnC;0BACA;QACA,GAAG,UAAU;IACf;AACF","sources":["packages/@react-aria/autocomplete/src/useSearchAutocomplete.ts"],"sourcesContent":["/*\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, LayoutDelegate, RefObject, ValidationResult} from '@react-types/shared';\nimport {InputHTMLAttributes} 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> extends ValidationResult {\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 | null>,\n /** The ref for the list box popover. */\n popoverRef: RefObject<HTMLDivElement | null>,\n /** The ref for the list box. */\n listBoxRef: RefObject<HTMLElement | null>,\n /** An optional keyboard delegate implementation, to override the default. */\n keyboardDelegate?: KeyboardDelegate,\n /**\n * A delegate object that provides layout information for items in the collection.\n * By default this uses the DOM, but this can be overridden to implement things like\n * virtualized scrolling.\n */\n layoutDelegate?: LayoutDelegate\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 layoutDelegate,\n onSubmit = () => {},\n onClear,\n onKeyDown,\n onKeyUp,\n isInvalid,\n validationState,\n validationBehavior,\n isRequired,\n ...otherProps\n } = props;\n\n let {inputProps, clearButtonProps} = useSearchField({\n ...otherProps,\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, ...validation} = useComboBox(\n {\n ...otherProps,\n keyboardDelegate,\n layoutDelegate,\n popoverRef,\n listBoxRef,\n inputRef,\n onFocus: undefined,\n onFocusChange: undefined,\n onBlur: undefined,\n onKeyDown: undefined,\n onKeyUp: undefined,\n isInvalid,\n validationState,\n validationBehavior,\n isRequired,\n validate: undefined\n },\n state\n );\n\n return {\n labelProps,\n inputProps: mergeProps(inputProps, comboBoxInputProps),\n listBoxProps,\n clearButtonProps,\n ...validation\n };\n}\n"],"names":[],"version":3,"file":"useSearchAutocomplete.main.js.map"}
@@ -0,0 +1,68 @@
1
+ import {mergeProps as $3Hzop$mergeProps} from "@react-aria/utils";
2
+ import {useComboBox as $3Hzop$useComboBox} from "@react-aria/combobox";
3
+ import {useSearchField as $3Hzop$useSearchField} from "@react-aria/searchfield";
4
+
5
+ /*
6
+ * Copyright 2020 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
+
17
+
18
+ function $c04f11f368135585$export$da7ade746446be1f(props, state) {
19
+ let { popoverRef: popoverRef, inputRef: inputRef, listBoxRef: listBoxRef, keyboardDelegate: keyboardDelegate, layoutDelegate: layoutDelegate, onSubmit: onSubmit = ()=>{}, onClear: onClear, onKeyDown: onKeyDown, onKeyUp: onKeyUp, isInvalid: isInvalid, validationState: validationState, validationBehavior: validationBehavior, isRequired: isRequired, ...otherProps } = props;
20
+ let { inputProps: inputProps, clearButtonProps: clearButtonProps } = (0, $3Hzop$useSearchField)({
21
+ ...otherProps,
22
+ value: state.inputValue,
23
+ onChange: state.setInputValue,
24
+ autoComplete: 'off',
25
+ onClear: ()=>{
26
+ state.setInputValue('');
27
+ if (onClear) onClear();
28
+ },
29
+ onSubmit: (value)=>{
30
+ // Prevent submission from search field if menu item was selected
31
+ if (state.selectionManager.focusedKey === null) onSubmit(value, null);
32
+ },
33
+ onKeyDown: onKeyDown,
34
+ onKeyUp: onKeyUp
35
+ }, {
36
+ value: state.inputValue,
37
+ setValue: state.setInputValue
38
+ }, inputRef);
39
+ let { listBoxProps: listBoxProps, labelProps: labelProps, inputProps: comboBoxInputProps, ...validation } = (0, $3Hzop$useComboBox)({
40
+ ...otherProps,
41
+ keyboardDelegate: keyboardDelegate,
42
+ layoutDelegate: layoutDelegate,
43
+ popoverRef: popoverRef,
44
+ listBoxRef: listBoxRef,
45
+ inputRef: inputRef,
46
+ onFocus: undefined,
47
+ onFocusChange: undefined,
48
+ onBlur: undefined,
49
+ onKeyDown: undefined,
50
+ onKeyUp: undefined,
51
+ isInvalid: isInvalid,
52
+ validationState: validationState,
53
+ validationBehavior: validationBehavior,
54
+ isRequired: isRequired,
55
+ validate: undefined
56
+ }, state);
57
+ return {
58
+ labelProps: labelProps,
59
+ inputProps: (0, $3Hzop$mergeProps)(inputProps, comboBoxInputProps),
60
+ listBoxProps: listBoxProps,
61
+ clearButtonProps: clearButtonProps,
62
+ ...validation
63
+ };
64
+ }
65
+
66
+
67
+ export {$c04f11f368135585$export$da7ade746446be1f as useSearchAutocomplete};
68
+ //# sourceMappingURL=useSearchAutocomplete.module.js.map
@@ -0,0 +1,68 @@
1
+ import {mergeProps as $3Hzop$mergeProps} from "@react-aria/utils";
2
+ import {useComboBox as $3Hzop$useComboBox} from "@react-aria/combobox";
3
+ import {useSearchField as $3Hzop$useSearchField} from "@react-aria/searchfield";
4
+
5
+ /*
6
+ * Copyright 2020 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
+
17
+
18
+ function $c04f11f368135585$export$da7ade746446be1f(props, state) {
19
+ let { popoverRef: popoverRef, inputRef: inputRef, listBoxRef: listBoxRef, keyboardDelegate: keyboardDelegate, layoutDelegate: layoutDelegate, onSubmit: onSubmit = ()=>{}, onClear: onClear, onKeyDown: onKeyDown, onKeyUp: onKeyUp, isInvalid: isInvalid, validationState: validationState, validationBehavior: validationBehavior, isRequired: isRequired, ...otherProps } = props;
20
+ let { inputProps: inputProps, clearButtonProps: clearButtonProps } = (0, $3Hzop$useSearchField)({
21
+ ...otherProps,
22
+ value: state.inputValue,
23
+ onChange: state.setInputValue,
24
+ autoComplete: 'off',
25
+ onClear: ()=>{
26
+ state.setInputValue('');
27
+ if (onClear) onClear();
28
+ },
29
+ onSubmit: (value)=>{
30
+ // Prevent submission from search field if menu item was selected
31
+ if (state.selectionManager.focusedKey === null) onSubmit(value, null);
32
+ },
33
+ onKeyDown: onKeyDown,
34
+ onKeyUp: onKeyUp
35
+ }, {
36
+ value: state.inputValue,
37
+ setValue: state.setInputValue
38
+ }, inputRef);
39
+ let { listBoxProps: listBoxProps, labelProps: labelProps, inputProps: comboBoxInputProps, ...validation } = (0, $3Hzop$useComboBox)({
40
+ ...otherProps,
41
+ keyboardDelegate: keyboardDelegate,
42
+ layoutDelegate: layoutDelegate,
43
+ popoverRef: popoverRef,
44
+ listBoxRef: listBoxRef,
45
+ inputRef: inputRef,
46
+ onFocus: undefined,
47
+ onFocusChange: undefined,
48
+ onBlur: undefined,
49
+ onKeyDown: undefined,
50
+ onKeyUp: undefined,
51
+ isInvalid: isInvalid,
52
+ validationState: validationState,
53
+ validationBehavior: validationBehavior,
54
+ isRequired: isRequired,
55
+ validate: undefined
56
+ }, state);
57
+ return {
58
+ labelProps: labelProps,
59
+ inputProps: (0, $3Hzop$mergeProps)(inputProps, comboBoxInputProps),
60
+ listBoxProps: listBoxProps,
61
+ clearButtonProps: clearButtonProps,
62
+ ...validation
63
+ };
64
+ }
65
+
66
+
67
+ export {$c04f11f368135585$export$da7ade746446be1f as useSearchAutocomplete};
68
+ //# sourceMappingURL=useSearchAutocomplete.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAkDM,SAAS,0CAAyB,KAAuC,EAAE,KAAuB;IACvG,IAAI,cACF,UAAU,YACV,QAAQ,cACR,UAAU,oBACV,gBAAgB,kBAChB,cAAc,YACd,WAAW,KAAO,YAClB,OAAO,aACP,SAAS,WACT,OAAO,aACP,SAAS,mBACT,eAAe,sBACf,kBAAkB,cAClB,UAAU,EACV,GAAG,YACJ,GAAG;IAEJ,IAAI,cAAC,UAAU,oBAAE,gBAAgB,EAAC,GAAG,CAAA,GAAA,qBAAa,EAAE;QAClD,GAAG,UAAU;QACb,OAAO,MAAM,UAAU;QACvB,UAAU,MAAM,aAAa;QAC7B,cAAc;QACd,SAAS;YACP,MAAM,aAAa,CAAC;YACpB,IAAI,SACF;QAEJ;QACA,UAAU,CAAC;YACT,iEAAiE;YACjE,IAAI,MAAM,gBAAgB,CAAC,UAAU,KAAK,MACxC,SAAS,OAAO;QAEpB;mBACA;iBACA;IACF,GAAG;QACD,OAAO,MAAM,UAAU;QACvB,UAAU,MAAM,aAAa;IAC/B,GAAG;IAGH,IAAI,gBAAC,YAAY,cAAE,UAAU,EAAE,YAAY,kBAAkB,EAAE,GAAG,YAAW,GAAG,CAAA,GAAA,kBAAU,EACxF;QACE,GAAG,UAAU;0BACb;wBACA;oBACA;oBACA;kBACA;QACA,SAAS;QACT,eAAe;QACf,QAAQ;QACR,WAAW;QACX,SAAS;mBACT;yBACA;4BACA;oBACA;QACA,UAAU;IACZ,GACA;IAGF,OAAO;oBACL;QACA,YAAY,CAAA,GAAA,iBAAS,EAAE,YAAY;sBACnC;0BACA;QACA,GAAG,UAAU;IACf;AACF","sources":["packages/@react-aria/autocomplete/src/useSearchAutocomplete.ts"],"sourcesContent":["/*\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, LayoutDelegate, RefObject, ValidationResult} from '@react-types/shared';\nimport {InputHTMLAttributes} 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> extends ValidationResult {\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 | null>,\n /** The ref for the list box popover. */\n popoverRef: RefObject<HTMLDivElement | null>,\n /** The ref for the list box. */\n listBoxRef: RefObject<HTMLElement | null>,\n /** An optional keyboard delegate implementation, to override the default. */\n keyboardDelegate?: KeyboardDelegate,\n /**\n * A delegate object that provides layout information for items in the collection.\n * By default this uses the DOM, but this can be overridden to implement things like\n * virtualized scrolling.\n */\n layoutDelegate?: LayoutDelegate\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 layoutDelegate,\n onSubmit = () => {},\n onClear,\n onKeyDown,\n onKeyUp,\n isInvalid,\n validationState,\n validationBehavior,\n isRequired,\n ...otherProps\n } = props;\n\n let {inputProps, clearButtonProps} = useSearchField({\n ...otherProps,\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, ...validation} = useComboBox(\n {\n ...otherProps,\n keyboardDelegate,\n layoutDelegate,\n popoverRef,\n listBoxRef,\n inputRef,\n onFocus: undefined,\n onFocusChange: undefined,\n onBlur: undefined,\n onKeyDown: undefined,\n onKeyUp: undefined,\n isInvalid,\n validationState,\n validationBehavior,\n isRequired,\n validate: undefined\n },\n state\n );\n\n return {\n labelProps,\n inputProps: mergeProps(inputProps, comboBoxInputProps),\n listBoxProps,\n clearButtonProps,\n ...validation\n };\n}\n"],"names":[],"version":3,"file":"useSearchAutocomplete.module.js.map"}
package/package.json CHANGED
@@ -1,10 +1,15 @@
1
1
  {
2
2
  "name": "@react-aria/autocomplete",
3
- "version": "3.0.0-alpha.3",
3
+ "version": "3.0.0-alpha.30",
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,22 @@
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.3",
22
- "@react-aria/i18n": "^3.3.6",
23
- "@react-aria/listbox": "^3.4.2",
24
- "@react-aria/live-announcer": "^3.0.3",
25
- "@react-aria/menu": "^3.4.1",
26
- "@react-aria/overlays": "^3.7.5",
27
- "@react-aria/searchfield": "^3.2.4",
28
- "@react-aria/selection": "^3.7.3",
29
- "@react-aria/textfield": "^3.5.2",
30
- "@react-aria/utils": "^3.11.2",
31
- "@react-stately/collections": "^3.3.6",
32
- "@react-stately/combobox": "^3.0.3",
33
- "@react-types/autocomplete": "3.0.0-alpha.2",
34
- "@react-types/button": "^3.4.3",
35
- "@react-types/combobox": "^3.2.3",
36
- "@react-types/searchfield": "^3.1.4",
37
- "@react-types/shared": "^3.11.1"
25
+ "@react-aria/combobox": "^3.10.0",
26
+ "@react-aria/listbox": "^3.13.0",
27
+ "@react-aria/searchfield": "^3.7.6",
28
+ "@react-aria/utils": "^3.25.0",
29
+ "@react-stately/combobox": "^3.9.0",
30
+ "@react-types/autocomplete": "3.0.0-alpha.23",
31
+ "@react-types/button": "^3.9.5",
32
+ "@react-types/shared": "^3.24.0",
33
+ "@swc/helpers": "^0.5.0"
38
34
  },
39
35
  "peerDependencies": {
40
- "react": "^16.8.0 || ^17.0.0-rc.1"
36
+ "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0",
37
+ "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
41
38
  },
42
39
  "publishConfig": {
43
40
  "access": "public"
44
41
  },
45
- "gitHead": "404d41859b7d6f56201d7fc01bd9f22ae3512937"
42
+ "gitHead": "86d80e3216bc32e75108831cf3a5a720bc849206"
46
43
  }
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,34 +12,44 @@
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, LayoutDelegate, RefObject, ValidationResult} from '@react-types/shared';
18
+ import {InputHTMLAttributes} 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> {
24
- /** The ref for the input element. */
25
- inputRef: RefObject<HTMLInputElement>,
26
- /** The ref for the list box popover. */
27
- popoverRef: RefObject<HTMLDivElement>,
28
- /** The ref for the list box. */
29
- listBoxRef: RefObject<HTMLElement>,
30
- /** An optional keyboard delegate implementation, to override the default. */
31
- keyboardDelegate?: KeyboardDelegate
32
- }
33
-
34
- interface SearchAutocompleteAria<T> {
23
+ export interface SearchAutocompleteAria<T> extends ValidationResult {
35
24
  /** Props for the label element. */
36
- labelProps: HTMLAttributes<HTMLElement>,
25
+ labelProps: DOMAttributes,
37
26
  /** Props for the search input element. */
38
27
  inputProps: InputHTMLAttributes<HTMLInputElement>,
39
28
  /** Props for the list box, to be passed to [useListBox](useListBox.html). */
40
29
  listBoxProps: AriaListBoxOptions<T>,
41
30
  /** Props for the search input's clear button. */
42
- clearButtonProps: AriaButtonProps
31
+ clearButtonProps: AriaButtonProps,
32
+ /** Props for the search autocomplete description element, if any. */
33
+ descriptionProps: DOMAttributes,
34
+ /** Props for the search autocomplete error message element, if any. */
35
+ errorMessageProps: DOMAttributes
36
+ }
37
+
38
+ export interface AriaSearchAutocompleteOptions<T> extends AriaSearchAutocompleteProps<T> {
39
+ /** The ref for the input element. */
40
+ inputRef: RefObject<HTMLInputElement | null>,
41
+ /** The ref for the list box popover. */
42
+ popoverRef: RefObject<HTMLDivElement | null>,
43
+ /** The ref for the list box. */
44
+ listBoxRef: RefObject<HTMLElement | null>,
45
+ /** An optional keyboard delegate implementation, to override the default. */
46
+ keyboardDelegate?: KeyboardDelegate,
47
+ /**
48
+ * A delegate object that provides layout information for items in the collection.
49
+ * By default this uses the DOM, but this can be overridden to implement things like
50
+ * virtualized scrolling.
51
+ */
52
+ layoutDelegate?: LayoutDelegate
43
53
  }
44
54
 
45
55
  /**
@@ -48,42 +58,67 @@ interface SearchAutocompleteAria<T> {
48
58
  * @param props - Props for the search autocomplete.
49
59
  * @param state - State for the search autocomplete, as returned by `useSearchAutocomplete`.
50
60
  */
51
- export function useSearchAutocomplete<T>(props: AriaSearchAutocompleteProps<T>, state: ComboBoxState<T>): SearchAutocompleteAria<T> {
61
+ export function useSearchAutocomplete<T>(props: AriaSearchAutocompleteOptions<T>, state: ComboBoxState<T>): SearchAutocompleteAria<T> {
52
62
  let {
53
63
  popoverRef,
54
64
  inputRef,
55
65
  listBoxRef,
56
66
  keyboardDelegate,
57
- onSubmit = () => {}
67
+ layoutDelegate,
68
+ onSubmit = () => {},
69
+ onClear,
70
+ onKeyDown,
71
+ onKeyUp,
72
+ isInvalid,
73
+ validationState,
74
+ validationBehavior,
75
+ isRequired,
76
+ ...otherProps
58
77
  } = props;
59
78
 
60
79
  let {inputProps, clearButtonProps} = useSearchField({
61
- ...props,
80
+ ...otherProps,
62
81
  value: state.inputValue,
63
82
  onChange: state.setInputValue,
64
83
  autoComplete: 'off',
65
- onClear: () => state.setInputValue(''),
84
+ onClear: () => {
85
+ state.setInputValue('');
86
+ if (onClear) {
87
+ onClear();
88
+ }
89
+ },
66
90
  onSubmit: (value) => {
67
91
  // Prevent submission from search field if menu item was selected
68
92
  if (state.selectionManager.focusedKey === null) {
69
93
  onSubmit(value, null);
70
94
  }
71
- }
95
+ },
96
+ onKeyDown,
97
+ onKeyUp
72
98
  }, {
73
99
  value: state.inputValue,
74
100
  setValue: state.setInputValue
75
101
  }, inputRef);
76
-
77
102
 
78
- let {listBoxProps, labelProps, inputProps: comboBoxInputProps} = useComboBox(
103
+
104
+ let {listBoxProps, labelProps, inputProps: comboBoxInputProps, ...validation} = useComboBox(
79
105
  {
80
- ...props,
106
+ ...otherProps,
81
107
  keyboardDelegate,
108
+ layoutDelegate,
82
109
  popoverRef,
83
110
  listBoxRef,
84
111
  inputRef,
85
112
  onFocus: undefined,
86
- onBlur: undefined
113
+ onFocusChange: undefined,
114
+ onBlur: undefined,
115
+ onKeyDown: undefined,
116
+ onKeyUp: undefined,
117
+ isInvalid,
118
+ validationState,
119
+ validationBehavior,
120
+ isRequired,
121
+ validate: undefined
87
122
  },
88
123
  state
89
124
  );
@@ -92,6 +127,7 @@ export function useSearchAutocomplete<T>(props: AriaSearchAutocompleteProps<T>,
92
127
  labelProps,
93
128
  inputProps: mergeProps(inputProps, comboBoxInputProps),
94
129
  listBoxProps,
95
- clearButtonProps
130
+ clearButtonProps,
131
+ ...validation
96
132
  };
97
133
  }