@react-aria/autocomplete 3.0.0-nightly.4228 → 3.0.0-nightly.4242
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/import.mjs +12 -8
- package/dist/main.js +13 -8
- package/dist/main.js.map +1 -1
- package/dist/module.js +12 -8
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +19 -19
- package/src/useSearchAutocomplete.ts +20 -11
package/dist/import.mjs
CHANGED
|
@@ -26,9 +26,9 @@ import {useSearchField as $fgZRc$useSearchField} from "@react-aria/searchfield";
|
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
function $c04f11f368135585$export$da7ade746446be1f(props, state) {
|
|
29
|
-
let { popoverRef: popoverRef, inputRef: inputRef, listBoxRef: listBoxRef, keyboardDelegate: keyboardDelegate, onSubmit: onSubmit = ()=>{}, onClear: onClear, onKeyDown: onKeyDown, onKeyUp: onKeyUp } = props;
|
|
30
|
-
let { inputProps: inputProps, clearButtonProps: clearButtonProps
|
|
31
|
-
...
|
|
29
|
+
let { popoverRef: popoverRef, inputRef: inputRef, listBoxRef: listBoxRef, keyboardDelegate: keyboardDelegate, onSubmit: onSubmit = ()=>{}, onClear: onClear, onKeyDown: onKeyDown, onKeyUp: onKeyUp, isInvalid: isInvalid, validationState: validationState, validationBehavior: validationBehavior, isRequired: isRequired, ...otherProps } = props;
|
|
30
|
+
let { inputProps: inputProps, clearButtonProps: clearButtonProps } = (0, $fgZRc$useSearchField)({
|
|
31
|
+
...otherProps,
|
|
32
32
|
value: state.inputValue,
|
|
33
33
|
onChange: state.setInputValue,
|
|
34
34
|
autoComplete: "off",
|
|
@@ -46,8 +46,8 @@ function $c04f11f368135585$export$da7ade746446be1f(props, state) {
|
|
|
46
46
|
value: state.inputValue,
|
|
47
47
|
setValue: state.setInputValue
|
|
48
48
|
}, inputRef);
|
|
49
|
-
let { listBoxProps: listBoxProps, labelProps: labelProps, inputProps: comboBoxInputProps } = (0, $fgZRc$useComboBox)({
|
|
50
|
-
...
|
|
49
|
+
let { listBoxProps: listBoxProps, labelProps: labelProps, inputProps: comboBoxInputProps, ...validation } = (0, $fgZRc$useComboBox)({
|
|
50
|
+
...otherProps,
|
|
51
51
|
keyboardDelegate: keyboardDelegate,
|
|
52
52
|
popoverRef: popoverRef,
|
|
53
53
|
listBoxRef: listBoxRef,
|
|
@@ -56,15 +56,19 @@ function $c04f11f368135585$export$da7ade746446be1f(props, state) {
|
|
|
56
56
|
onFocusChange: undefined,
|
|
57
57
|
onBlur: undefined,
|
|
58
58
|
onKeyDown: undefined,
|
|
59
|
-
onKeyUp: undefined
|
|
59
|
+
onKeyUp: undefined,
|
|
60
|
+
isInvalid: isInvalid,
|
|
61
|
+
validationState: validationState,
|
|
62
|
+
validationBehavior: validationBehavior,
|
|
63
|
+
isRequired: isRequired,
|
|
64
|
+
validate: undefined
|
|
60
65
|
}, state);
|
|
61
66
|
return {
|
|
62
67
|
labelProps: labelProps,
|
|
63
68
|
inputProps: (0, $fgZRc$mergeProps)(inputProps, comboBoxInputProps),
|
|
64
69
|
listBoxProps: listBoxProps,
|
|
65
70
|
clearButtonProps: clearButtonProps,
|
|
66
|
-
|
|
67
|
-
errorMessageProps: errorMessageProps
|
|
71
|
+
...validation
|
|
68
72
|
};
|
|
69
73
|
}
|
|
70
74
|
|
package/dist/main.js
CHANGED
|
@@ -2,6 +2,7 @@ var $kDrMH$reactariautils = require("@react-aria/utils");
|
|
|
2
2
|
var $kDrMH$reactariacombobox = require("@react-aria/combobox");
|
|
3
3
|
var $kDrMH$reactariasearchfield = require("@react-aria/searchfield");
|
|
4
4
|
|
|
5
|
+
|
|
5
6
|
function $parcel$export(e, n, v, s) {
|
|
6
7
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
7
8
|
}
|
|
@@ -31,9 +32,9 @@ $parcel$export(module.exports, "useSearchAutocomplete", () => $3c40871f8cc2eb01$
|
|
|
31
32
|
|
|
32
33
|
|
|
33
34
|
function $3c40871f8cc2eb01$export$da7ade746446be1f(props, state) {
|
|
34
|
-
let { popoverRef: popoverRef, inputRef: inputRef, listBoxRef: listBoxRef, keyboardDelegate: keyboardDelegate, onSubmit: onSubmit = ()=>{}, onClear: onClear, onKeyDown: onKeyDown, onKeyUp: onKeyUp } = props;
|
|
35
|
-
let { inputProps: inputProps, clearButtonProps: clearButtonProps
|
|
36
|
-
...
|
|
35
|
+
let { popoverRef: popoverRef, inputRef: inputRef, listBoxRef: listBoxRef, keyboardDelegate: keyboardDelegate, onSubmit: onSubmit = ()=>{}, onClear: onClear, onKeyDown: onKeyDown, onKeyUp: onKeyUp, isInvalid: isInvalid, validationState: validationState, validationBehavior: validationBehavior, isRequired: isRequired, ...otherProps } = props;
|
|
36
|
+
let { inputProps: inputProps, clearButtonProps: clearButtonProps } = (0, $kDrMH$reactariasearchfield.useSearchField)({
|
|
37
|
+
...otherProps,
|
|
37
38
|
value: state.inputValue,
|
|
38
39
|
onChange: state.setInputValue,
|
|
39
40
|
autoComplete: "off",
|
|
@@ -51,8 +52,8 @@ function $3c40871f8cc2eb01$export$da7ade746446be1f(props, state) {
|
|
|
51
52
|
value: state.inputValue,
|
|
52
53
|
setValue: state.setInputValue
|
|
53
54
|
}, inputRef);
|
|
54
|
-
let { listBoxProps: listBoxProps, labelProps: labelProps, inputProps: comboBoxInputProps } = (0, $kDrMH$reactariacombobox.useComboBox)({
|
|
55
|
-
...
|
|
55
|
+
let { listBoxProps: listBoxProps, labelProps: labelProps, inputProps: comboBoxInputProps, ...validation } = (0, $kDrMH$reactariacombobox.useComboBox)({
|
|
56
|
+
...otherProps,
|
|
56
57
|
keyboardDelegate: keyboardDelegate,
|
|
57
58
|
popoverRef: popoverRef,
|
|
58
59
|
listBoxRef: listBoxRef,
|
|
@@ -61,15 +62,19 @@ function $3c40871f8cc2eb01$export$da7ade746446be1f(props, state) {
|
|
|
61
62
|
onFocusChange: undefined,
|
|
62
63
|
onBlur: undefined,
|
|
63
64
|
onKeyDown: undefined,
|
|
64
|
-
onKeyUp: undefined
|
|
65
|
+
onKeyUp: undefined,
|
|
66
|
+
isInvalid: isInvalid,
|
|
67
|
+
validationState: validationState,
|
|
68
|
+
validationBehavior: validationBehavior,
|
|
69
|
+
isRequired: isRequired,
|
|
70
|
+
validate: undefined
|
|
65
71
|
}, state);
|
|
66
72
|
return {
|
|
67
73
|
labelProps: labelProps,
|
|
68
74
|
inputProps: (0, $kDrMH$reactariautils.mergeProps)(inputProps, comboBoxInputProps),
|
|
69
75
|
listBoxProps: listBoxProps,
|
|
70
76
|
clearButtonProps: clearButtonProps,
|
|
71
|
-
|
|
72
|
-
errorMessageProps: errorMessageProps
|
|
77
|
+
...validation
|
|
73
78
|
};
|
|
74
79
|
}
|
|
75
80
|
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC;;;AA4CM,SAAS,0CAAyB,KAAuC,EAAE,KAAuB;IACvG,IAAI,cACF,UAAU,YACV,QAAQ,cACR,UAAU,oBACV,gBAAgB,YAChB,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;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;;CDlHC","sources":["packages/@react-aria/autocomplete/src/index.ts","packages/@react-aria/autocomplete/src/useSearchAutocomplete.ts"],"sourcesContent":["/*\n * Copyright 2021 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useSearchAutocomplete} from './useSearchAutocomplete';\nexport type {AriaSearchAutocompleteOptions, SearchAutocompleteAria} from './useSearchAutocomplete';\nexport type {AriaSearchAutocompleteProps} from '@react-types/autocomplete';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '@react-types/button';\nimport {AriaListBoxOptions} from '@react-aria/listbox';\nimport {AriaSearchAutocompleteProps} from '@react-types/autocomplete';\nimport {ComboBoxState} from '@react-stately/combobox';\nimport {DOMAttributes, KeyboardDelegate, ValidationResult} from '@react-types/shared';\nimport {InputHTMLAttributes, RefObject} from 'react';\nimport {mergeProps} from '@react-aria/utils';\nimport {useComboBox} from '@react-aria/combobox';\nimport {useSearchField} from '@react-aria/searchfield';\n\nexport interface SearchAutocompleteAria<T> 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>,\n /** The ref for the list box popover. */\n popoverRef: RefObject<HTMLDivElement>,\n /** The ref for the list box. */\n listBoxRef: RefObject<HTMLElement>,\n /** An optional keyboard delegate implementation, to override the default. */\n keyboardDelegate?: KeyboardDelegate\n}\n\n/**\n * Provides the behavior and accessibility implementation for a search autocomplete component.\n * A search autocomplete combines a combobox with a searchfield, allowing users to filter a list of options to items matching a query.\n * @param props - Props for the search autocomplete.\n * @param state - State for the search autocomplete, as returned by `useSearchAutocomplete`.\n */\nexport function useSearchAutocomplete<T>(props: AriaSearchAutocompleteOptions<T>, state: ComboBoxState<T>): SearchAutocompleteAria<T> {\n let {\n popoverRef,\n inputRef,\n listBoxRef,\n keyboardDelegate,\n onSubmit = () => {},\n onClear,\n onKeyDown,\n onKeyUp,\n 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 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":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -26,9 +26,9 @@ import {useSearchField as $fgZRc$useSearchField} from "@react-aria/searchfield";
|
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
function $c04f11f368135585$export$da7ade746446be1f(props, state) {
|
|
29
|
-
let { popoverRef: popoverRef, inputRef: inputRef, listBoxRef: listBoxRef, keyboardDelegate: keyboardDelegate, onSubmit: onSubmit = ()=>{}, onClear: onClear, onKeyDown: onKeyDown, onKeyUp: onKeyUp } = props;
|
|
30
|
-
let { inputProps: inputProps, clearButtonProps: clearButtonProps
|
|
31
|
-
...
|
|
29
|
+
let { popoverRef: popoverRef, inputRef: inputRef, listBoxRef: listBoxRef, keyboardDelegate: keyboardDelegate, onSubmit: onSubmit = ()=>{}, onClear: onClear, onKeyDown: onKeyDown, onKeyUp: onKeyUp, isInvalid: isInvalid, validationState: validationState, validationBehavior: validationBehavior, isRequired: isRequired, ...otherProps } = props;
|
|
30
|
+
let { inputProps: inputProps, clearButtonProps: clearButtonProps } = (0, $fgZRc$useSearchField)({
|
|
31
|
+
...otherProps,
|
|
32
32
|
value: state.inputValue,
|
|
33
33
|
onChange: state.setInputValue,
|
|
34
34
|
autoComplete: "off",
|
|
@@ -46,8 +46,8 @@ function $c04f11f368135585$export$da7ade746446be1f(props, state) {
|
|
|
46
46
|
value: state.inputValue,
|
|
47
47
|
setValue: state.setInputValue
|
|
48
48
|
}, inputRef);
|
|
49
|
-
let { listBoxProps: listBoxProps, labelProps: labelProps, inputProps: comboBoxInputProps } = (0, $fgZRc$useComboBox)({
|
|
50
|
-
...
|
|
49
|
+
let { listBoxProps: listBoxProps, labelProps: labelProps, inputProps: comboBoxInputProps, ...validation } = (0, $fgZRc$useComboBox)({
|
|
50
|
+
...otherProps,
|
|
51
51
|
keyboardDelegate: keyboardDelegate,
|
|
52
52
|
popoverRef: popoverRef,
|
|
53
53
|
listBoxRef: listBoxRef,
|
|
@@ -56,15 +56,19 @@ function $c04f11f368135585$export$da7ade746446be1f(props, state) {
|
|
|
56
56
|
onFocusChange: undefined,
|
|
57
57
|
onBlur: undefined,
|
|
58
58
|
onKeyDown: undefined,
|
|
59
|
-
onKeyUp: undefined
|
|
59
|
+
onKeyUp: undefined,
|
|
60
|
+
isInvalid: isInvalid,
|
|
61
|
+
validationState: validationState,
|
|
62
|
+
validationBehavior: validationBehavior,
|
|
63
|
+
isRequired: isRequired,
|
|
64
|
+
validate: undefined
|
|
60
65
|
}, state);
|
|
61
66
|
return {
|
|
62
67
|
labelProps: labelProps,
|
|
63
68
|
inputProps: (0, $fgZRc$mergeProps)(inputProps, comboBoxInputProps),
|
|
64
69
|
listBoxProps: listBoxProps,
|
|
65
70
|
clearButtonProps: clearButtonProps,
|
|
66
|
-
|
|
67
|
-
errorMessageProps: errorMessageProps
|
|
71
|
+
...validation
|
|
68
72
|
};
|
|
69
73
|
}
|
|
70
74
|
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC;;;AA4CM,SAAS,0CAAyB,KAAuC,EAAE,KAAuB;IACvG,IAAI,cACF,UAAU,YACV,QAAQ,cACR,UAAU,oBACV,gBAAgB,YAChB,WAAW,KAAO,YAClB,OAAO,aACP,SAAS,WACT,OAAO,
|
|
1
|
+
{"mappings":";;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC;;;AA4CM,SAAS,0CAAyB,KAAuC,EAAE,KAAuB;IACvG,IAAI,cACF,UAAU,YACV,QAAQ,cACR,UAAU,oBACV,gBAAgB,YAChB,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;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;;CDlHC","sources":["packages/@react-aria/autocomplete/src/index.ts","packages/@react-aria/autocomplete/src/useSearchAutocomplete.ts"],"sourcesContent":["/*\n * Copyright 2021 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useSearchAutocomplete} from './useSearchAutocomplete';\nexport type {AriaSearchAutocompleteOptions, SearchAutocompleteAria} from './useSearchAutocomplete';\nexport type {AriaSearchAutocompleteProps} from '@react-types/autocomplete';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '@react-types/button';\nimport {AriaListBoxOptions} from '@react-aria/listbox';\nimport {AriaSearchAutocompleteProps} from '@react-types/autocomplete';\nimport {ComboBoxState} from '@react-stately/combobox';\nimport {DOMAttributes, KeyboardDelegate, ValidationResult} from '@react-types/shared';\nimport {InputHTMLAttributes, RefObject} from 'react';\nimport {mergeProps} from '@react-aria/utils';\nimport {useComboBox} from '@react-aria/combobox';\nimport {useSearchField} from '@react-aria/searchfield';\n\nexport interface SearchAutocompleteAria<T> 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>,\n /** The ref for the list box popover. */\n popoverRef: RefObject<HTMLDivElement>,\n /** The ref for the list box. */\n listBoxRef: RefObject<HTMLElement>,\n /** An optional keyboard delegate implementation, to override the default. */\n keyboardDelegate?: KeyboardDelegate\n}\n\n/**\n * Provides the behavior and accessibility implementation for a search autocomplete component.\n * A search autocomplete combines a combobox with a searchfield, allowing users to filter a list of options to items matching a query.\n * @param props - Props for the search autocomplete.\n * @param state - State for the search autocomplete, as returned by `useSearchAutocomplete`.\n */\nexport function useSearchAutocomplete<T>(props: AriaSearchAutocompleteOptions<T>, state: ComboBoxState<T>): SearchAutocompleteAria<T> {\n let {\n popoverRef,\n inputRef,\n listBoxRef,\n keyboardDelegate,\n onSubmit = () => {},\n onClear,\n onKeyDown,\n onKeyUp,\n 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 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":"module.js.map"}
|
package/dist/types.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ import { AriaButtonProps } from "@react-types/button";
|
|
|
2
2
|
import { AriaListBoxOptions } from "@react-aria/listbox";
|
|
3
3
|
import { AriaSearchAutocompleteProps } from "@react-types/autocomplete";
|
|
4
4
|
import { ComboBoxState } from "@react-stately/combobox";
|
|
5
|
-
import { DOMAttributes, KeyboardDelegate } from "@react-types/shared";
|
|
5
|
+
import { DOMAttributes, KeyboardDelegate, ValidationResult } from "@react-types/shared";
|
|
6
6
|
import { InputHTMLAttributes, RefObject } from "react";
|
|
7
|
-
export interface SearchAutocompleteAria<T> {
|
|
7
|
+
export interface SearchAutocompleteAria<T> extends ValidationResult {
|
|
8
8
|
/** Props for the label element. */
|
|
9
9
|
labelProps: DOMAttributes;
|
|
10
10
|
/** Props for the search input element. */
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;AAsBA,wCAAwC,CAAC;
|
|
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,CAAC,CAAC;IACtC,wCAAwC;IACxC,UAAU,EAAE,UAAU,cAAc,CAAC,CAAC;IACtC,gCAAgC;IAChC,UAAU,EAAE,UAAU,WAAW,CAAC,CAAC;IACnC,6EAA6E;IAC7E,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;CACpC;AAED;;;;;GAKG;AACH,sCAAsC,CAAC,EAAE,KAAK,EAAE,8BAA8B,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,GAAG,uBAAuB,CAAC,CAAC,CAsEpI;AC/GD,YAAY,EAAC,2BAA2B,EAAC,MAAM,2BAA2B,CAAC","sources":["packages/@react-aria/autocomplete/src/packages/@react-aria/autocomplete/src/useSearchAutocomplete.ts","packages/@react-aria/autocomplete/src/packages/@react-aria/autocomplete/src/index.ts","packages/@react-aria/autocomplete/src/index.ts"],"sourcesContent":[null,null,"/*\n * Copyright 2021 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useSearchAutocomplete} from './useSearchAutocomplete';\nexport type {AriaSearchAutocompleteOptions, SearchAutocompleteAria} from './useSearchAutocomplete';\nexport type {AriaSearchAutocompleteProps} from '@react-types/autocomplete';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/autocomplete",
|
|
3
|
-
"version": "3.0.0-nightly.
|
|
3
|
+
"version": "3.0.0-nightly.4242+068ecd12e",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -22,23 +22,23 @@
|
|
|
22
22
|
"url": "https://github.com/adobe/react-spectrum"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@react-aria/combobox": "3.7.2-nightly.
|
|
26
|
-
"@react-aria/i18n": "3.0.0-nightly.
|
|
27
|
-
"@react-aria/listbox": "3.11.2-nightly.
|
|
28
|
-
"@react-aria/live-announcer": "3.0.0-nightly.
|
|
29
|
-
"@react-aria/menu": "3.11.2-nightly.
|
|
30
|
-
"@react-aria/overlays": "3.0.0-nightly.
|
|
31
|
-
"@react-aria/searchfield": "3.0.0-nightly.
|
|
32
|
-
"@react-aria/selection": "3.0.0-nightly.
|
|
33
|
-
"@react-aria/textfield": "3.0.0-nightly.
|
|
34
|
-
"@react-aria/utils": "3.0.0-nightly.
|
|
35
|
-
"@react-stately/collections": "3.0.0-nightly.
|
|
36
|
-
"@react-stately/combobox": "3.7.2-nightly.
|
|
37
|
-
"@react-types/autocomplete": "3.0.0-nightly.
|
|
38
|
-
"@react-types/button": "3.9.1-nightly.
|
|
39
|
-
"@react-types/combobox": "3.8.2-nightly.
|
|
40
|
-
"@react-types/searchfield": "3.0.0-nightly.
|
|
41
|
-
"@react-types/shared": "3.0.0-nightly.
|
|
25
|
+
"@react-aria/combobox": "3.7.2-nightly.4242+068ecd12e",
|
|
26
|
+
"@react-aria/i18n": "3.0.0-nightly.2531+068ecd12e",
|
|
27
|
+
"@react-aria/listbox": "3.11.2-nightly.4242+068ecd12e",
|
|
28
|
+
"@react-aria/live-announcer": "3.0.0-nightly.2531+068ecd12e",
|
|
29
|
+
"@react-aria/menu": "3.11.2-nightly.4242+068ecd12e",
|
|
30
|
+
"@react-aria/overlays": "3.0.0-nightly.2531+068ecd12e",
|
|
31
|
+
"@react-aria/searchfield": "3.0.0-nightly.2531+068ecd12e",
|
|
32
|
+
"@react-aria/selection": "3.0.0-nightly.2531+068ecd12e",
|
|
33
|
+
"@react-aria/textfield": "3.0.0-nightly.2531+068ecd12e",
|
|
34
|
+
"@react-aria/utils": "3.0.0-nightly.2531+068ecd12e",
|
|
35
|
+
"@react-stately/collections": "3.0.0-nightly.2531+068ecd12e",
|
|
36
|
+
"@react-stately/combobox": "3.7.2-nightly.4242+068ecd12e",
|
|
37
|
+
"@react-types/autocomplete": "3.0.0-nightly.4242+068ecd12e",
|
|
38
|
+
"@react-types/button": "3.9.1-nightly.4242+068ecd12e",
|
|
39
|
+
"@react-types/combobox": "3.8.2-nightly.4242+068ecd12e",
|
|
40
|
+
"@react-types/searchfield": "3.0.0-nightly.2531+068ecd12e",
|
|
41
|
+
"@react-types/shared": "3.0.0-nightly.2531+068ecd12e",
|
|
42
42
|
"@swc/helpers": "^0.5.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"publishConfig": {
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "068ecd12e8a8c61546dfda691b04ca87cbdae687"
|
|
52
52
|
}
|
|
@@ -14,13 +14,13 @@ import {AriaButtonProps} from '@react-types/button';
|
|
|
14
14
|
import {AriaListBoxOptions} from '@react-aria/listbox';
|
|
15
15
|
import {AriaSearchAutocompleteProps} from '@react-types/autocomplete';
|
|
16
16
|
import {ComboBoxState} from '@react-stately/combobox';
|
|
17
|
-
import {DOMAttributes, KeyboardDelegate} from '@react-types/shared';
|
|
17
|
+
import {DOMAttributes, KeyboardDelegate, ValidationResult} from '@react-types/shared';
|
|
18
18
|
import {InputHTMLAttributes, RefObject} from 'react';
|
|
19
19
|
import {mergeProps} from '@react-aria/utils';
|
|
20
20
|
import {useComboBox} from '@react-aria/combobox';
|
|
21
21
|
import {useSearchField} from '@react-aria/searchfield';
|
|
22
22
|
|
|
23
|
-
export interface SearchAutocompleteAria<T> {
|
|
23
|
+
export interface SearchAutocompleteAria<T> extends ValidationResult {
|
|
24
24
|
/** Props for the label element. */
|
|
25
25
|
labelProps: DOMAttributes,
|
|
26
26
|
/** Props for the search input element. */
|
|
@@ -61,11 +61,16 @@ export function useSearchAutocomplete<T>(props: AriaSearchAutocompleteOptions<T>
|
|
|
61
61
|
onSubmit = () => {},
|
|
62
62
|
onClear,
|
|
63
63
|
onKeyDown,
|
|
64
|
-
onKeyUp
|
|
64
|
+
onKeyUp,
|
|
65
|
+
isInvalid,
|
|
66
|
+
validationState,
|
|
67
|
+
validationBehavior,
|
|
68
|
+
isRequired,
|
|
69
|
+
...otherProps
|
|
65
70
|
} = props;
|
|
66
71
|
|
|
67
|
-
let {inputProps, clearButtonProps
|
|
68
|
-
...
|
|
72
|
+
let {inputProps, clearButtonProps} = useSearchField({
|
|
73
|
+
...otherProps,
|
|
69
74
|
value: state.inputValue,
|
|
70
75
|
onChange: state.setInputValue,
|
|
71
76
|
autoComplete: 'off',
|
|
@@ -87,11 +92,11 @@ export function useSearchAutocomplete<T>(props: AriaSearchAutocompleteOptions<T>
|
|
|
87
92
|
value: state.inputValue,
|
|
88
93
|
setValue: state.setInputValue
|
|
89
94
|
}, inputRef);
|
|
90
|
-
|
|
91
95
|
|
|
92
|
-
|
|
96
|
+
|
|
97
|
+
let {listBoxProps, labelProps, inputProps: comboBoxInputProps, ...validation} = useComboBox(
|
|
93
98
|
{
|
|
94
|
-
...
|
|
99
|
+
...otherProps,
|
|
95
100
|
keyboardDelegate,
|
|
96
101
|
popoverRef,
|
|
97
102
|
listBoxRef,
|
|
@@ -100,7 +105,12 @@ export function useSearchAutocomplete<T>(props: AriaSearchAutocompleteOptions<T>
|
|
|
100
105
|
onFocusChange: undefined,
|
|
101
106
|
onBlur: undefined,
|
|
102
107
|
onKeyDown: undefined,
|
|
103
|
-
onKeyUp: undefined
|
|
108
|
+
onKeyUp: undefined,
|
|
109
|
+
isInvalid,
|
|
110
|
+
validationState,
|
|
111
|
+
validationBehavior,
|
|
112
|
+
isRequired,
|
|
113
|
+
validate: undefined
|
|
104
114
|
},
|
|
105
115
|
state
|
|
106
116
|
);
|
|
@@ -110,7 +120,6 @@ export function useSearchAutocomplete<T>(props: AriaSearchAutocompleteOptions<T>
|
|
|
110
120
|
inputProps: mergeProps(inputProps, comboBoxInputProps),
|
|
111
121
|
listBoxProps,
|
|
112
122
|
clearButtonProps,
|
|
113
|
-
|
|
114
|
-
errorMessageProps
|
|
123
|
+
...validation
|
|
115
124
|
};
|
|
116
125
|
}
|