@react-spectrum/autocomplete 3.0.0-nightly.4230 → 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 +421 -326
- package/dist/main.js +416 -321
- package/dist/main.js.map +1 -1
- package/dist/module.js +421 -326
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +30 -28
- package/src/MobileSearchAutocomplete.tsx +53 -12
- package/src/SearchAutocomplete.tsx +12 -4
|
@@ -41,12 +41,14 @@ import {TextFieldBase} from '@react-spectrum/textfield';
|
|
|
41
41
|
import textfieldStyles from '@adobe/spectrum-css-temp/components/textfield/vars.css';
|
|
42
42
|
import {useComboBoxState} from '@react-stately/combobox';
|
|
43
43
|
import {useFilter, useLocalizedStringFormatter} from '@react-aria/i18n';
|
|
44
|
+
import {useFormProps} from '@react-spectrum/form';
|
|
44
45
|
import {useHover} from '@react-aria/interactions';
|
|
45
46
|
import {useProvider, useProviderProps} from '@react-spectrum/provider';
|
|
46
47
|
import {useSearchAutocomplete} from '@react-aria/autocomplete';
|
|
47
48
|
|
|
48
49
|
function SearchAutocomplete<T extends object>(props: SpectrumSearchAutocompleteProps<T>, ref: FocusableRef<HTMLElement>) {
|
|
49
50
|
props = useProviderProps(props);
|
|
51
|
+
props = useFormProps(props);
|
|
50
52
|
|
|
51
53
|
if (props.placeholder) {
|
|
52
54
|
console.warn('Placeholders are deprecated due to accessibility issues. Please use help text instead.');
|
|
@@ -71,7 +73,8 @@ function _SearchAutocompleteBase<T extends object>(props: SpectrumSearchAutocomp
|
|
|
71
73
|
isQuiet,
|
|
72
74
|
loadingState,
|
|
73
75
|
onLoadMore,
|
|
74
|
-
onSubmit = () => {}
|
|
76
|
+
onSubmit = () => {},
|
|
77
|
+
validate
|
|
75
78
|
} = props;
|
|
76
79
|
|
|
77
80
|
let stringFormatter = useLocalizedStringFormatter(intlMessages);
|
|
@@ -91,12 +94,13 @@ function _SearchAutocompleteBase<T extends object>(props: SpectrumSearchAutocomp
|
|
|
91
94
|
allowsCustomValue: true,
|
|
92
95
|
onSelectionChange: (key) => key !== null && onSubmit(null, key),
|
|
93
96
|
selectedKey: undefined,
|
|
94
|
-
defaultSelectedKey: undefined
|
|
97
|
+
defaultSelectedKey: undefined,
|
|
98
|
+
validate: useCallback(v => validate?.(v.inputValue), [validate])
|
|
95
99
|
}
|
|
96
100
|
);
|
|
97
101
|
let layout = useListBoxLayout(state, loadingState === 'loadingMore');
|
|
98
102
|
|
|
99
|
-
let {inputProps, listBoxProps, labelProps, clearButtonProps, descriptionProps, errorMessageProps} = useSearchAutocomplete(
|
|
103
|
+
let {inputProps, listBoxProps, labelProps, clearButtonProps, descriptionProps, errorMessageProps, isInvalid, validationErrors, validationDetails} = useSearchAutocomplete(
|
|
100
104
|
{
|
|
101
105
|
...props,
|
|
102
106
|
keyboardDelegate: layout,
|
|
@@ -138,6 +142,9 @@ function _SearchAutocompleteBase<T extends object>(props: SpectrumSearchAutocomp
|
|
|
138
142
|
descriptionProps={descriptionProps}
|
|
139
143
|
errorMessageProps={errorMessageProps}
|
|
140
144
|
labelProps={labelProps}
|
|
145
|
+
isInvalid={isInvalid}
|
|
146
|
+
validationErrors={validationErrors}
|
|
147
|
+
validationDetails={validationDetails}
|
|
141
148
|
ref={domRef}>
|
|
142
149
|
<SearchAutocompleteInput
|
|
143
150
|
{...props}
|
|
@@ -145,7 +152,8 @@ function _SearchAutocompleteBase<T extends object>(props: SpectrumSearchAutocomp
|
|
|
145
152
|
loadingState={loadingState}
|
|
146
153
|
inputProps={inputProps}
|
|
147
154
|
inputRef={inputRef}
|
|
148
|
-
clearButtonProps={clearButtonProps}
|
|
155
|
+
clearButtonProps={clearButtonProps}
|
|
156
|
+
validationState={props.validationState || (isInvalid ? 'invalid' : undefined)} />
|
|
149
157
|
</Field>
|
|
150
158
|
<Popover
|
|
151
159
|
state={state}
|