@react-spectrum/autocomplete 3.0.0-alpha.30 → 3.0.0-alpha.32

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.
Files changed (52) hide show
  1. package/dist/MobileSearchAutocomplete.main.js +449 -0
  2. package/dist/MobileSearchAutocomplete.main.js.map +1 -0
  3. package/dist/MobileSearchAutocomplete.mjs +444 -0
  4. package/dist/MobileSearchAutocomplete.module.js +444 -0
  5. package/dist/MobileSearchAutocomplete.module.js.map +1 -0
  6. package/dist/SearchAutocomplete.main.js +291 -0
  7. package/dist/SearchAutocomplete.main.js.map +1 -0
  8. package/dist/SearchAutocomplete.mjs +286 -0
  9. package/dist/SearchAutocomplete.module.js +286 -0
  10. package/dist/SearchAutocomplete.module.js.map +1 -0
  11. package/dist/import.mjs +1 -1025
  12. package/dist/inputgroup_vars_css.main.js +86 -0
  13. package/dist/inputgroup_vars_css.main.js.map +1 -0
  14. package/dist/inputgroup_vars_css.mjs +88 -0
  15. package/dist/inputgroup_vars_css.module.js +88 -0
  16. package/dist/inputgroup_vars_css.module.js.map +1 -0
  17. package/dist/intlStrings.main.js +108 -0
  18. package/dist/intlStrings.main.js.map +1 -0
  19. package/dist/intlStrings.mjs +110 -0
  20. package/dist/intlStrings.module.js +110 -0
  21. package/dist/intlStrings.module.js.map +1 -0
  22. package/dist/main.js +2 -1022
  23. package/dist/main.js.map +1 -1
  24. package/dist/module.js +1 -1025
  25. package/dist/module.js.map +1 -1
  26. package/dist/search_vars_css.main.js +53 -0
  27. package/dist/search_vars_css.main.js.map +1 -0
  28. package/dist/search_vars_css.mjs +55 -0
  29. package/dist/search_vars_css.module.js +55 -0
  30. package/dist/search_vars_css.module.js.map +1 -0
  31. package/dist/searchautocomplete.37ce4a26.css +55 -0
  32. package/dist/searchautocomplete.37ce4a26.css.map +1 -0
  33. package/dist/searchautocomplete_css.main.js +38 -0
  34. package/dist/searchautocomplete_css.main.js.map +1 -0
  35. package/dist/searchautocomplete_css.mjs +40 -0
  36. package/dist/searchautocomplete_css.module.js +40 -0
  37. package/dist/searchautocomplete_css.module.js.map +1 -0
  38. package/dist/textfield_vars_css.main.js +74 -0
  39. package/dist/textfield_vars_css.main.js.map +1 -0
  40. package/dist/textfield_vars_css.mjs +76 -0
  41. package/dist/textfield_vars_css.module.js +76 -0
  42. package/dist/textfield_vars_css.module.js.map +1 -0
  43. package/dist/vars.31879241.css +223 -0
  44. package/dist/vars.31879241.css.map +1 -0
  45. package/dist/vars.5653edea.css +549 -0
  46. package/dist/vars.5653edea.css.map +1 -0
  47. package/dist/vars.936671cd.css +649 -0
  48. package/dist/vars.936671cd.css.map +1 -0
  49. package/package.json +26 -26
  50. package/src/searchautocomplete.css +0 -1
  51. package/dist/main.css +0 -1700
  52. package/dist/main.css.map +0 -1
@@ -0,0 +1,286 @@
1
+ import $fLcex$intlStringsmodulejs from "./intlStrings.module.js";
2
+ import {MobileSearchAutocomplete as $c940f54e16bafef5$export$e7a90f7d6b078162} from "./MobileSearchAutocomplete.module.js";
3
+ import "./searchautocomplete.37ce4a26.css";
4
+ import $fLcex$searchautocomplete_cssmodulejs from "./searchautocomplete_css.module.js";
5
+ import "./vars.31879241.css";
6
+ import $fLcex$search_vars_cssmodulejs from "./search_vars_css.module.js";
7
+ import "./vars.936671cd.css";
8
+ import $fLcex$inputgroup_vars_cssmodulejs from "./inputgroup_vars_css.module.js";
9
+ import "./vars.5653edea.css";
10
+ import $fLcex$textfield_vars_cssmodulejs from "./textfield_vars_css.module.js";
11
+ import {useIsMobileDevice as $fLcex$useIsMobileDevice, useUnwrapDOMRef as $fLcex$useUnwrapDOMRef, useFocusableRef as $fLcex$useFocusableRef, useResizeObserver as $fLcex$useResizeObserver, dimensionValue as $fLcex$dimensionValue, classNames as $fLcex$classNames} from "@react-spectrum/utils";
12
+ import {ClearButton as $fLcex$ClearButton} from "@react-spectrum/button";
13
+ import {Field as $fLcex$Field} from "@react-spectrum/label";
14
+ import {useLayoutEffect as $fLcex$useLayoutEffect, filterDOMProps as $fLcex$filterDOMProps} from "@react-aria/utils";
15
+ import {FocusRing as $fLcex$FocusRing} from "@react-aria/focus";
16
+ import {useListBoxLayout as $fLcex$useListBoxLayout, ListBoxBase as $fLcex$ListBoxBase} from "@react-spectrum/listbox";
17
+ import $fLcex$spectrumiconsuiMagnifier from "@spectrum-icons/ui/Magnifier";
18
+ import {Popover as $fLcex$Popover} from "@react-spectrum/overlays";
19
+ import {ProgressCircle as $fLcex$ProgressCircle} from "@react-spectrum/progress";
20
+ import $fLcex$react, {useRef as $fLcex$useRef, useCallback as $fLcex$useCallback, useState as $fLcex$useState, useEffect as $fLcex$useEffect, forwardRef as $fLcex$forwardRef} from "react";
21
+ import {TextFieldBase as $fLcex$TextFieldBase} from "@react-spectrum/textfield";
22
+ import {useComboBoxState as $fLcex$useComboBoxState} from "@react-stately/combobox";
23
+ import {useLocalizedStringFormatter as $fLcex$useLocalizedStringFormatter, useFilter as $fLcex$useFilter} from "@react-aria/i18n";
24
+ import {useFormProps as $fLcex$useFormProps} from "@react-spectrum/form";
25
+ import {useHover as $fLcex$useHover} from "@react-aria/interactions";
26
+ import {useProviderProps as $fLcex$useProviderProps, useProvider as $fLcex$useProvider} from "@react-spectrum/provider";
27
+ import {useSearchAutocomplete as $fLcex$useSearchAutocomplete} from "@react-aria/autocomplete";
28
+
29
+
30
+ function $parcel$interopDefault(a) {
31
+ return a && a.__esModule ? a.default : a;
32
+ }
33
+ /*
34
+ * Copyright 2020 Adobe. All rights reserved.
35
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
36
+ * you may not use this file except in compliance with the License. You may obtain a copy
37
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
38
+ *
39
+ * Unless required by applicable law or agreed to in writing, software distributed under
40
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
41
+ * OF ANY KIND, either express or implied. See the License for the specific language
42
+ * governing permissions and limitations under the License.
43
+ */
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+ function $f3f3b62273a2d260$var$SearchAutocomplete(props, ref) {
67
+ props = (0, $fLcex$useProviderProps)(props);
68
+ props = (0, $fLcex$useFormProps)(props);
69
+ if (props.placeholder) console.warn('Placeholders are deprecated due to accessibility issues. Please use help text instead.');
70
+ let isMobile = (0, $fLcex$useIsMobileDevice)();
71
+ if (isMobile) // menuTrigger=focus/manual don't apply to mobile searchwithin
72
+ return /*#__PURE__*/ (0, $fLcex$react).createElement((0, $c940f54e16bafef5$export$e7a90f7d6b078162), {
73
+ ...props,
74
+ menuTrigger: "input",
75
+ ref: ref
76
+ });
77
+ else return /*#__PURE__*/ (0, $fLcex$react).createElement($f3f3b62273a2d260$var$SearchAutocompleteBase, {
78
+ ...props,
79
+ ref: ref
80
+ });
81
+ }
82
+ function $f3f3b62273a2d260$var$_SearchAutocompleteBase(props, ref) {
83
+ props = (0, $fLcex$useProviderProps)(props);
84
+ let { menuTrigger: menuTrigger = 'input', shouldFlip: shouldFlip = true, direction: direction = 'bottom', align: align = 'start', isQuiet: isQuiet, menuWidth: customMenuWidth, loadingState: loadingState, onLoadMore: onLoadMore, onSubmit: onSubmit = ()=>{}, validate: validate } = props;
85
+ let stringFormatter = (0, $fLcex$useLocalizedStringFormatter)((0, ($parcel$interopDefault($fLcex$intlStringsmodulejs))), '@react-spectrum/autocomplete');
86
+ let isAsync = loadingState != null;
87
+ let popoverRef = (0, $fLcex$useRef)(null);
88
+ let unwrappedPopoverRef = (0, $fLcex$useUnwrapDOMRef)(popoverRef);
89
+ let listBoxRef = (0, $fLcex$useRef)(null);
90
+ let inputRef = (0, $fLcex$useRef)(null);
91
+ let domRef = (0, $fLcex$useFocusableRef)(ref, inputRef);
92
+ let { contains: contains } = (0, $fLcex$useFilter)({
93
+ sensitivity: 'base'
94
+ });
95
+ let state = (0, $fLcex$useComboBoxState)({
96
+ ...props,
97
+ defaultFilter: contains,
98
+ allowsEmptyCollection: isAsync,
99
+ allowsCustomValue: true,
100
+ onSelectionChange: (key)=>key !== null && onSubmit(null, key),
101
+ selectedKey: undefined,
102
+ defaultSelectedKey: undefined,
103
+ validate: (0, $fLcex$useCallback)((v)=>validate === null || validate === void 0 ? void 0 : validate(v.inputValue), [
104
+ validate
105
+ ])
106
+ });
107
+ let layout = (0, $fLcex$useListBoxLayout)(state, loadingState === 'loadingMore');
108
+ let { inputProps: inputProps, listBoxProps: listBoxProps, labelProps: labelProps, clearButtonProps: clearButtonProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps, isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = (0, $fLcex$useSearchAutocomplete)({
109
+ ...props,
110
+ keyboardDelegate: layout,
111
+ popoverRef: unwrappedPopoverRef,
112
+ listBoxRef: listBoxRef,
113
+ inputRef: inputRef,
114
+ menuTrigger: menuTrigger
115
+ }, state);
116
+ // Measure the width of the inputfield to inform the width of the menu (below).
117
+ let [menuWidth, setMenuWidth] = (0, $fLcex$useState)(0);
118
+ let { scale: scale } = (0, $fLcex$useProvider)();
119
+ let onResize = (0, $fLcex$useCallback)(()=>{
120
+ if (inputRef.current) {
121
+ let inputWidth = inputRef.current.offsetWidth;
122
+ setMenuWidth(inputWidth);
123
+ }
124
+ }, [
125
+ inputRef,
126
+ setMenuWidth
127
+ ]);
128
+ (0, $fLcex$useResizeObserver)({
129
+ ref: domRef,
130
+ onResize: onResize
131
+ });
132
+ (0, $fLcex$useLayoutEffect)(onResize, [
133
+ scale,
134
+ onResize
135
+ ]);
136
+ let width = isQuiet ? undefined : menuWidth;
137
+ let style = {
138
+ width: customMenuWidth ? (0, $fLcex$dimensionValue)(customMenuWidth) : width,
139
+ minWidth: isQuiet ? `calc(${menuWidth}px + calc(2 * var(--spectrum-dropdown-quiet-offset)))` : menuWidth
140
+ };
141
+ return /*#__PURE__*/ (0, $fLcex$react).createElement((0, $fLcex$react).Fragment, null, /*#__PURE__*/ (0, $fLcex$react).createElement((0, $fLcex$Field), {
142
+ ...props,
143
+ descriptionProps: descriptionProps,
144
+ errorMessageProps: errorMessageProps,
145
+ labelProps: labelProps,
146
+ isInvalid: isInvalid,
147
+ validationErrors: validationErrors,
148
+ validationDetails: validationDetails,
149
+ ref: domRef
150
+ }, /*#__PURE__*/ (0, $fLcex$react).createElement($f3f3b62273a2d260$var$SearchAutocompleteInput, {
151
+ ...props,
152
+ isOpen: state.isOpen,
153
+ loadingState: loadingState,
154
+ inputProps: inputProps,
155
+ inputRef: inputRef,
156
+ clearButtonProps: clearButtonProps,
157
+ validationState: props.validationState || (isInvalid ? 'invalid' : undefined)
158
+ })), /*#__PURE__*/ (0, $fLcex$react).createElement((0, $fLcex$Popover), {
159
+ state: state,
160
+ UNSAFE_style: style,
161
+ UNSAFE_className: (0, $fLcex$classNames)((0, ($parcel$interopDefault($fLcex$inputgroup_vars_cssmodulejs))), 'spectrum-InputGroup-popover', {
162
+ 'spectrum-InputGroup-popover--quiet': isQuiet
163
+ }),
164
+ ref: popoverRef,
165
+ triggerRef: inputRef,
166
+ placement: `${direction} ${align}`,
167
+ hideArrow: true,
168
+ isNonModal: true,
169
+ shouldFlip: shouldFlip
170
+ }, /*#__PURE__*/ (0, $fLcex$react).createElement((0, $fLcex$ListBoxBase), {
171
+ ...listBoxProps,
172
+ ref: listBoxRef,
173
+ disallowEmptySelection: true,
174
+ autoFocus: state.focusStrategy,
175
+ shouldSelectOnPressUp: true,
176
+ focusOnPointerEnter: true,
177
+ layout: layout,
178
+ state: state,
179
+ shouldUseVirtualFocus: true,
180
+ isLoading: loadingState === 'loading' || loadingState === 'loadingMore',
181
+ onLoadMore: onLoadMore,
182
+ renderEmptyState: ()=>isAsync && /*#__PURE__*/ (0, $fLcex$react).createElement("span", {
183
+ className: (0, $fLcex$classNames)((0, ($parcel$interopDefault($fLcex$searchautocomplete_cssmodulejs))), 'no-results')
184
+ }, stringFormatter.format('noResults'))
185
+ })));
186
+ }
187
+ let $f3f3b62273a2d260$var$SearchAutocompleteBase = /*#__PURE__*/ (0, $fLcex$react).forwardRef($f3f3b62273a2d260$var$_SearchAutocompleteBase);
188
+ // any type is because we don't want to call useObjectRef because this is an internal component and we know
189
+ // we are always passing an object ref
190
+ function $f3f3b62273a2d260$var$_SearchAutocompleteInput(props, ref) {
191
+ let searchIcon = /*#__PURE__*/ (0, $fLcex$react).createElement((0, $fLcex$spectrumiconsuiMagnifier), {
192
+ "data-testid": "searchicon"
193
+ });
194
+ let { icon: icon = searchIcon, isQuiet: isQuiet, isDisabled: isDisabled, isReadOnly: isReadOnly, validationState: validationState, inputProps: inputProps, inputRef: inputRef, autoFocus: autoFocus, style: style, className: className, loadingState: loadingState, isOpen: isOpen, menuTrigger: menuTrigger, clearButtonProps: clearButtonProps } = props;
195
+ let { hoverProps: hoverProps, isHovered: isHovered } = (0, $fLcex$useHover)({});
196
+ let stringFormatter = (0, $fLcex$useLocalizedStringFormatter)((0, ($parcel$interopDefault($fLcex$intlStringsmodulejs))), '@react-spectrum/autocomplete');
197
+ let domProps = (0, $fLcex$filterDOMProps)(props);
198
+ let timeout = (0, $fLcex$useRef)(null);
199
+ let [showLoading, setShowLoading] = (0, $fLcex$useState)(false);
200
+ let loadingCircle = /*#__PURE__*/ (0, $fLcex$react).createElement((0, $fLcex$ProgressCircle), {
201
+ "aria-label": stringFormatter.format('loading'),
202
+ size: "S",
203
+ isIndeterminate: true,
204
+ UNSAFE_className: (0, $fLcex$classNames)((0, ($parcel$interopDefault($fLcex$textfield_vars_cssmodulejs))), 'spectrum-Textfield-circleLoader', (0, $fLcex$classNames)((0, ($parcel$interopDefault($fLcex$inputgroup_vars_cssmodulejs))), 'spectrum-InputGroup-input-circleLoader'), (0, $fLcex$classNames)((0, ($parcel$interopDefault($fLcex$search_vars_cssmodulejs))), 'spectrum-Search-circleLoader'))
205
+ });
206
+ let clearButton = /*#__PURE__*/ (0, $fLcex$react).createElement((0, $fLcex$ClearButton), {
207
+ ...clearButtonProps,
208
+ preventFocus: true,
209
+ UNSAFE_className: (0, $fLcex$classNames)((0, ($parcel$interopDefault($fLcex$search_vars_cssmodulejs))), 'spectrum-ClearButton'),
210
+ isDisabled: isDisabled
211
+ });
212
+ let isLoading = loadingState === 'loading' || loadingState === 'filtering';
213
+ let inputValue = inputProps.value;
214
+ let lastInputValue = (0, $fLcex$useRef)(inputValue);
215
+ (0, $fLcex$useEffect)(()=>{
216
+ if (isLoading && !showLoading) {
217
+ if (timeout.current === null) timeout.current = setTimeout(()=>{
218
+ setShowLoading(true);
219
+ }, 500);
220
+ // If user is typing, clear the timer and restart since it is a new request
221
+ if (inputValue !== lastInputValue.current) {
222
+ clearTimeout(timeout.current);
223
+ timeout.current = setTimeout(()=>{
224
+ setShowLoading(true);
225
+ }, 500);
226
+ }
227
+ } else if (!isLoading) {
228
+ // If loading is no longer happening, clear any timers and hide the loading circle
229
+ setShowLoading(false);
230
+ if (timeout.current != null) {
231
+ clearTimeout(timeout.current);
232
+ timeout.current = null;
233
+ }
234
+ }
235
+ lastInputValue.current = inputValue;
236
+ }, [
237
+ isLoading,
238
+ showLoading,
239
+ inputValue
240
+ ]);
241
+ return /*#__PURE__*/ (0, $fLcex$react).createElement((0, $fLcex$FocusRing), {
242
+ within: true,
243
+ isTextInput: true,
244
+ focusClass: (0, $fLcex$classNames)((0, ($parcel$interopDefault($fLcex$inputgroup_vars_cssmodulejs))), 'is-focused'),
245
+ focusRingClass: (0, $fLcex$classNames)((0, ($parcel$interopDefault($fLcex$inputgroup_vars_cssmodulejs))), 'focus-ring'),
246
+ autoFocus: autoFocus
247
+ }, /*#__PURE__*/ (0, $fLcex$react).createElement("div", {
248
+ ...hoverProps,
249
+ ref: ref,
250
+ style: style,
251
+ className: (0, $fLcex$classNames)((0, ($parcel$interopDefault($fLcex$inputgroup_vars_cssmodulejs))), 'spectrum-InputGroup', {
252
+ 'spectrum-InputGroup--quiet': isQuiet,
253
+ 'is-disabled': isDisabled,
254
+ 'spectrum-InputGroup--invalid': validationState === 'invalid' && !isDisabled,
255
+ 'is-hovered': isHovered
256
+ }, (0, $fLcex$classNames)((0, ($parcel$interopDefault($fLcex$searchautocomplete_cssmodulejs))), 'searchautocomplete'), className)
257
+ }, /*#__PURE__*/ (0, $fLcex$react).createElement((0, $fLcex$TextFieldBase), {
258
+ ...domProps,
259
+ inputProps: inputProps,
260
+ inputRef: inputRef,
261
+ UNSAFE_className: (0, $fLcex$classNames)((0, ($parcel$interopDefault($fLcex$search_vars_cssmodulejs))), 'spectrum-Search', 'spectrum-Search--loadable', 'spectrum-Textfield', {
262
+ 'is-disabled': isDisabled,
263
+ 'is-quiet': isQuiet,
264
+ 'spectrum-Search--invalid': validationState === 'invalid' && !isDisabled,
265
+ 'spectrum-Search--valid': validationState === 'valid' && !isDisabled
266
+ }, (0, $fLcex$classNames)((0, ($parcel$interopDefault($fLcex$inputgroup_vars_cssmodulejs))), 'spectrum-InputGroup-field')),
267
+ inputClassName: (0, $fLcex$classNames)((0, ($parcel$interopDefault($fLcex$search_vars_cssmodulejs))), 'spectrum-Search-input'),
268
+ validationIconClassName: (0, $fLcex$classNames)((0, ($parcel$interopDefault($fLcex$search_vars_cssmodulejs))), 'spectrum-Search-validationIcon'),
269
+ isDisabled: isDisabled,
270
+ isQuiet: isQuiet,
271
+ validationState: validationState,
272
+ isLoading: showLoading && (isOpen || menuTrigger === 'manual' || loadingState === 'loading'),
273
+ loadingIndicator: loadingState != null ? loadingCircle : undefined,
274
+ icon: icon,
275
+ wrapperChildren: (inputValue !== '' || loadingState === 'filtering' || validationState != null) && !isReadOnly ? clearButton : undefined,
276
+ disableFocusRing: true
277
+ })));
278
+ }
279
+ let $f3f3b62273a2d260$var$SearchAutocompleteInput = /*#__PURE__*/ (0, $fLcex$react).forwardRef($f3f3b62273a2d260$var$_SearchAutocompleteInput);
280
+ /**
281
+ * A SearchAutocomplete is a searchfield that supports a dynamic list of suggestions.
282
+ */ let $f3f3b62273a2d260$export$dd65332a5b19fa63 = /*#__PURE__*/ (0, $fLcex$forwardRef)($f3f3b62273a2d260$var$SearchAutocomplete);
283
+
284
+
285
+ export {$f3f3b62273a2d260$export$dd65332a5b19fa63 as SearchAutocomplete};
286
+ //# sourceMappingURL=SearchAutocomplete.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;;;;;;;AAsCD,SAAS,yCAAqC,KAAyC,EAAE,GAA8B;IACrH,QAAQ,CAAA,GAAA,uBAAe,EAAE;IACzB,QAAQ,CAAA,GAAA,mBAAW,EAAE;IAErB,IAAI,MAAM,WAAW,EACnB,QAAQ,IAAI,CAAC;IAGf,IAAI,WAAW,CAAA,GAAA,wBAAgB;IAC/B,IAAI,UACF,8DAA8D;IAC9D,qBAAO,gCAAC,CAAA,GAAA,yCAAuB;QAAG,GAAG,KAAK;QAAE,aAAY;QAAQ,KAAK;;SAErE,qBAAO,gCAAC;QAAwB,GAAG,KAAK;QAAE,KAAK;;AAEnD;AAEA,SAAS,8CAA0C,KAAyC,EAAE,GAA8B;IAC1H,QAAQ,CAAA,GAAA,uBAAe,EAAE;IAEzB,IAAI,eACF,cAAc,qBACd,aAAa,iBACb,YAAY,iBACZ,QAAQ,kBACR,OAAO,EACP,WAAW,eAAe,gBAC1B,YAAY,cACZ,UAAU,YACV,WAAW,KAAO,aAClB,QAAQ,EACT,GAAG;IAEJ,IAAI,kBAAkB,CAAA,GAAA,kCAA0B,EAAE,CAAA,GAAA,oDAAW,GAAG;IAChE,IAAI,UAAU,gBAAgB;IAC9B,IAAI,aAAa,CAAA,GAAA,aAAK,EAA+B;IACrD,IAAI,sBAAsB,CAAA,GAAA,sBAAc,EAAE;IAC1C,IAAI,aAAa,CAAA,GAAA,aAAK,EAAE;IACxB,IAAI,WAAW,CAAA,GAAA,aAAK,EAAoB;IACxC,IAAI,SAAS,CAAA,GAAA,sBAAc,E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gB,OAAO,gBAAgB;QACzD,MAAM;QACN,iBAAiB,AAAC,CAAA,eAAe,MAAM,iBAAiB,eAAe,mBAAmB,IAAG,KAAM,CAAC,aAAa,cAAc;QAC/H,kBAAA;;AAIV;AAEA,IAAI,8DAA0B,CAAA,GAAA,YAAI,EAAE,UAAU,CAAC;AAG/C;;CAEC,GACD,IAAI,0DAAsB,CAAA,GAAA,iBAAS,EAAE","sources":["packages/@react-spectrum/autocomplete/src/SearchAutocomplete.tsx"],"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 */\nimport {AriaButtonProps} from '@react-types/button';\nimport {classNames, dimensionValue, useFocusableRef, useIsMobileDevice, useResizeObserver, useUnwrapDOMRef} from '@react-spectrum/utils';\nimport {ClearButton} from '@react-spectrum/button';\nimport {DOMRefValue, FocusableRef} from '@react-types/shared';\nimport {Field} from '@react-spectrum/label';\nimport {filterDOMProps, useLayoutEffect} from '@react-aria/utils';\nimport {FocusRing} from '@react-aria/focus';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {ListBoxBase, useListBoxLayout} from '@react-spectrum/listbox';\nimport Magnifier from '@spectrum-icons/ui/Magnifier';\nimport {MobileSearchAutocomplete} from './MobileSearchAutocomplete';\nimport {Popover} from '@react-spectrum/overlays';\nimport {ProgressCircle} from '@react-spectrum/progress';\nimport React, {\n forwardRef,\n InputHTMLAttributes,\n ReactElement,\n RefObject,\n useCallback,\n useEffect,\n useRef,\n useState\n} from 'react';\nimport searchAutocompleteStyles from './searchautocomplete.css';\nimport searchStyles from '@adobe/spectrum-css-temp/components/search/vars.css';\nimport {SpectrumSearchAutocompleteProps} from '@react-types/autocomplete';\nimport styles from '@adobe/spectrum-css-temp/components/inputgroup/vars.css';\nimport {TextFieldBase} from '@react-spectrum/textfield';\nimport textfieldStyles from '@adobe/spectrum-css-temp/components/textfield/vars.css';\nimport {useComboBoxState} from '@react-stately/combobox';\nimport {useFilter, useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useFormProps} from '@react-spectrum/form';\nimport {useHover} from '@react-aria/interactions';\nimport {useProvider, useProviderProps} from '@react-spectrum/provider';\nimport {useSearchAutocomplete} from '@react-aria/autocomplete';\n\nfunction SearchAutocomplete<T extends object>(props: SpectrumSearchAutocompleteProps<T>, ref: FocusableRef<HTMLElement>) {\n props = useProviderProps(props);\n props = useFormProps(props);\n\n if (props.placeholder) {\n console.warn('Placeholders are deprecated due to accessibility issues. Please use help text instead.');\n }\n\n let isMobile = useIsMobileDevice();\n if (isMobile) {\n // menuTrigger=focus/manual don't apply to mobile searchwithin\n return <MobileSearchAutocomplete {...props} menuTrigger=\"input\" ref={ref} />;\n } else {\n return <SearchAutocompleteBase {...props} ref={ref} />;\n }\n}\n\nfunction _SearchAutocompleteBase<T extends object>(props: SpectrumSearchAutocompleteProps<T>, ref: FocusableRef<HTMLElement>) {\n props = useProviderProps(props);\n\n let {\n menuTrigger = 'input',\n shouldFlip = true,\n direction = 'bottom',\n align = 'start',\n isQuiet,\n menuWidth: customMenuWidth,\n loadingState,\n onLoadMore,\n onSubmit = () => {},\n validate\n } = props;\n\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/autocomplete');\n let isAsync = loadingState != null;\n let popoverRef = useRef<DOMRefValue<HTMLDivElement>>(null);\n let unwrappedPopoverRef = useUnwrapDOMRef(popoverRef);\n let listBoxRef = useRef(null);\n let inputRef = useRef<HTMLInputElement>(null);\n let domRef = useFocusableRef(ref, inputRef);\n\n let {contains} = useFilter({sensitivity: 'base'});\n let state = useComboBoxState(\n {\n ...props,\n defaultFilter: contains,\n allowsEmptyCollection: isAsync,\n allowsCustomValue: true,\n onSelectionChange: (key) => key !== null && onSubmit(null, key),\n selectedKey: undefined,\n defaultSelectedKey: undefined,\n validate: useCallback(v => validate?.(v.inputValue), [validate])\n }\n );\n let layout = useListBoxLayout(state, loadingState === 'loadingMore');\n\n let {inputProps, listBoxProps, labelProps, clearButtonProps, descriptionProps, errorMessageProps, isInvalid, validationErrors, validationDetails} = useSearchAutocomplete(\n {\n ...props,\n keyboardDelegate: layout,\n popoverRef: unwrappedPopoverRef,\n listBoxRef,\n inputRef,\n menuTrigger\n },\n state\n );\n\n // Measure the width of the inputfield to inform the width of the menu (below).\n let [menuWidth, setMenuWidth] = useState<number>(0);\n let {scale} = useProvider();\n\n let onResize = useCallback(() => {\n if (inputRef.current) {\n let inputWidth = inputRef.current.offsetWidth;\n setMenuWidth(inputWidth);\n }\n }, [inputRef, setMenuWidth]);\n\n useResizeObserver({\n ref: domRef,\n onResize: onResize\n });\n\n useLayoutEffect(onResize, [scale, onResize]);\n\n let width = isQuiet ? undefined : menuWidth;\n let style = {\n width: customMenuWidth ? dimensionValue(customMenuWidth) : width,\n minWidth: isQuiet ? `calc(${menuWidth}px + calc(2 * var(--spectrum-dropdown-quiet-offset)))` : menuWidth\n };\n\n return (\n <>\n <Field\n {...props}\n descriptionProps={descriptionProps}\n errorMessageProps={errorMessageProps}\n labelProps={labelProps}\n isInvalid={isInvalid}\n validationErrors={validationErrors}\n validationDetails={validationDetails}\n ref={domRef}>\n <SearchAutocompleteInput\n {...props}\n isOpen={state.isOpen}\n loadingState={loadingState}\n inputProps={inputProps}\n inputRef={inputRef}\n clearButtonProps={clearButtonProps}\n validationState={props.validationState || (isInvalid ? 'invalid' : undefined)} />\n </Field>\n <Popover\n state={state}\n UNSAFE_style={style}\n UNSAFE_className={classNames(styles, 'spectrum-InputGroup-popover', {'spectrum-InputGroup-popover--quiet': isQuiet})}\n ref={popoverRef}\n triggerRef={inputRef}\n placement={`${direction} ${align}`}\n hideArrow\n isNonModal\n shouldFlip={shouldFlip}>\n <ListBoxBase\n {...listBoxProps}\n ref={listBoxRef}\n disallowEmptySelection\n autoFocus={state.focusStrategy}\n shouldSelectOnPressUp\n focusOnPointerEnter\n layout={layout}\n state={state}\n shouldUseVirtualFocus\n isLoading={loadingState === 'loading' || loadingState === 'loadingMore'}\n onLoadMore={onLoadMore}\n renderEmptyState={() => isAsync && (\n <span className={classNames(searchAutocompleteStyles, 'no-results')}>\n {stringFormatter.format('noResults')}\n </span>\n )} />\n </Popover>\n </>\n );\n}\n\nlet SearchAutocompleteBase = React.forwardRef(_SearchAutocompleteBase) as <T>(props: SpectrumSearchAutocompleteProps<T> & {ref?: FocusableRef<HTMLElement>}) => ReactElement;\n\n\ninterface SearchAutocompleteInputProps<T> extends SpectrumSearchAutocompleteProps<T> {\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n inputRef: RefObject<HTMLInputElement>,\n style?: React.CSSProperties,\n className?: string,\n isOpen?: boolean,\n clearButtonProps: AriaButtonProps\n}\n\n// any type is because we don't want to call useObjectRef because this is an internal component and we know\n// we are always passing an object ref\nfunction _SearchAutocompleteInput<T>(props: SearchAutocompleteInputProps<T>, ref: any) {\n let searchIcon = (\n <Magnifier data-testid=\"searchicon\" />\n );\n\n let {\n icon = searchIcon,\n isQuiet,\n isDisabled,\n isReadOnly,\n validationState,\n inputProps,\n inputRef,\n autoFocus,\n style,\n className,\n loadingState,\n isOpen,\n menuTrigger,\n clearButtonProps\n } = props;\n let {hoverProps, isHovered} = useHover({});\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/autocomplete');\n let domProps = filterDOMProps(props);\n let timeout = useRef<ReturnType<typeof setTimeout> | null>(null);\n let [showLoading, setShowLoading] = useState(false);\n\n let loadingCircle = (\n <ProgressCircle\n aria-label={stringFormatter.format('loading')}\n size=\"S\"\n isIndeterminate\n UNSAFE_className={classNames(\n textfieldStyles,\n 'spectrum-Textfield-circleLoader',\n classNames(\n styles,\n 'spectrum-InputGroup-input-circleLoader'\n ),\n classNames(\n searchStyles,\n 'spectrum-Search-circleLoader'\n )\n )} />\n );\n\n let clearButton = (\n <ClearButton\n {...clearButtonProps}\n preventFocus\n UNSAFE_className={\n classNames(\n searchStyles,\n 'spectrum-ClearButton'\n )\n }\n isDisabled={isDisabled} />\n );\n\n let isLoading = loadingState === 'loading' || loadingState === 'filtering';\n let inputValue = inputProps.value;\n let lastInputValue = useRef(inputValue);\n useEffect(() => {\n if (isLoading && !showLoading) {\n if (timeout.current === null) {\n timeout.current = setTimeout(() => {\n setShowLoading(true);\n }, 500);\n }\n\n // If user is typing, clear the timer and restart since it is a new request\n if (inputValue !== lastInputValue.current) {\n clearTimeout(timeout.current);\n timeout.current = setTimeout(() => {\n setShowLoading(true);\n }, 500);\n }\n } else if (!isLoading) {\n // If loading is no longer happening, clear any timers and hide the loading circle\n setShowLoading(false);\n if (timeout.current != null) {\n clearTimeout(timeout.current);\n timeout.current = null;\n }\n }\n\n lastInputValue.current = inputValue;\n }, [isLoading, showLoading, inputValue]);\n\n return (\n <FocusRing\n within\n isTextInput\n focusClass={classNames(styles, 'is-focused')}\n focusRingClass={classNames(styles, 'focus-ring')}\n autoFocus={autoFocus}>\n <div\n {...hoverProps}\n ref={ref as RefObject<HTMLDivElement>}\n style={style}\n className={\n classNames(\n styles,\n 'spectrum-InputGroup',\n {\n 'spectrum-InputGroup--quiet': isQuiet,\n 'is-disabled': isDisabled,\n 'spectrum-InputGroup--invalid': validationState === 'invalid' && !isDisabled,\n 'is-hovered': isHovered\n },\n classNames(\n searchAutocompleteStyles,\n 'searchautocomplete'\n ),\n className\n )\n }>\n <TextFieldBase\n {...domProps}\n inputProps={inputProps}\n inputRef={inputRef}\n UNSAFE_className={\n classNames(\n searchStyles,\n 'spectrum-Search',\n 'spectrum-Search--loadable',\n 'spectrum-Textfield',\n {\n 'is-disabled': isDisabled,\n 'is-quiet': isQuiet,\n 'spectrum-Search--invalid': validationState === 'invalid' && !isDisabled,\n 'spectrum-Search--valid': validationState === 'valid' && !isDisabled\n },\n classNames(\n styles,\n 'spectrum-InputGroup-field'\n )\n )\n }\n inputClassName={classNames(searchStyles, 'spectrum-Search-input')}\n validationIconClassName={\n classNames(\n searchStyles,\n 'spectrum-Search-validationIcon'\n )\n }\n isDisabled={isDisabled}\n isQuiet={isQuiet}\n validationState={validationState}\n isLoading={showLoading && (isOpen || menuTrigger === 'manual' || loadingState === 'loading')}\n loadingIndicator={loadingState != null ? loadingCircle : undefined}\n icon={icon}\n wrapperChildren={(inputValue !== '' || loadingState === 'filtering' || validationState != null) && !isReadOnly ? clearButton : undefined}\n disableFocusRing />\n </div>\n </FocusRing>\n );\n}\n\nlet SearchAutocompleteInput = React.forwardRef(_SearchAutocompleteInput) as <T>(props: SearchAutocompleteInputProps<T> & {ref?: any}) => ReactElement;\n\n\n/**\n * A SearchAutocomplete is a searchfield that supports a dynamic list of suggestions.\n */\nlet _SearchAutocomplete = forwardRef(SearchAutocomplete) as <T>(props: SpectrumSearchAutocompleteProps<T> & {ref?: FocusableRef<HTMLElement>}) => ReactElement;\nexport {_SearchAutocomplete as SearchAutocomplete};\n"],"names":[],"version":3,"file":"SearchAutocomplete.module.js.map"}