@react-aria/autocomplete 3.0.0-rc.6 → 3.0.0-rc.7

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 (197) hide show
  1. package/dist/import.mjs +3 -3
  2. package/dist/main.js +4 -4
  3. package/dist/main.js.map +1 -1
  4. package/dist/module.js +3 -3
  5. package/dist/module.js.map +1 -1
  6. package/dist/types/src/index.d.ts +4 -0
  7. package/package.json +15 -24
  8. package/src/index.ts +4 -5
  9. package/dist/ar-AE.main.js +0 -6
  10. package/dist/ar-AE.main.js.map +0 -1
  11. package/dist/ar-AE.mjs +0 -8
  12. package/dist/ar-AE.module.js +0 -8
  13. package/dist/ar-AE.module.js.map +0 -1
  14. package/dist/bg-BG.main.js +0 -6
  15. package/dist/bg-BG.main.js.map +0 -1
  16. package/dist/bg-BG.mjs +0 -8
  17. package/dist/bg-BG.module.js +0 -8
  18. package/dist/bg-BG.module.js.map +0 -1
  19. package/dist/cs-CZ.main.js +0 -6
  20. package/dist/cs-CZ.main.js.map +0 -1
  21. package/dist/cs-CZ.mjs +0 -8
  22. package/dist/cs-CZ.module.js +0 -8
  23. package/dist/cs-CZ.module.js.map +0 -1
  24. package/dist/da-DK.main.js +0 -6
  25. package/dist/da-DK.main.js.map +0 -1
  26. package/dist/da-DK.mjs +0 -8
  27. package/dist/da-DK.module.js +0 -8
  28. package/dist/da-DK.module.js.map +0 -1
  29. package/dist/de-DE.main.js +0 -6
  30. package/dist/de-DE.main.js.map +0 -1
  31. package/dist/de-DE.mjs +0 -8
  32. package/dist/de-DE.module.js +0 -8
  33. package/dist/de-DE.module.js.map +0 -1
  34. package/dist/el-GR.main.js +0 -6
  35. package/dist/el-GR.main.js.map +0 -1
  36. package/dist/el-GR.mjs +0 -8
  37. package/dist/el-GR.module.js +0 -8
  38. package/dist/el-GR.module.js.map +0 -1
  39. package/dist/en-US.main.js +0 -6
  40. package/dist/en-US.main.js.map +0 -1
  41. package/dist/en-US.mjs +0 -8
  42. package/dist/en-US.module.js +0 -8
  43. package/dist/en-US.module.js.map +0 -1
  44. package/dist/es-ES.main.js +0 -6
  45. package/dist/es-ES.main.js.map +0 -1
  46. package/dist/es-ES.mjs +0 -8
  47. package/dist/es-ES.module.js +0 -8
  48. package/dist/es-ES.module.js.map +0 -1
  49. package/dist/et-EE.main.js +0 -6
  50. package/dist/et-EE.main.js.map +0 -1
  51. package/dist/et-EE.mjs +0 -8
  52. package/dist/et-EE.module.js +0 -8
  53. package/dist/et-EE.module.js.map +0 -1
  54. package/dist/fi-FI.main.js +0 -6
  55. package/dist/fi-FI.main.js.map +0 -1
  56. package/dist/fi-FI.mjs +0 -8
  57. package/dist/fi-FI.module.js +0 -8
  58. package/dist/fi-FI.module.js.map +0 -1
  59. package/dist/fr-FR.main.js +0 -6
  60. package/dist/fr-FR.main.js.map +0 -1
  61. package/dist/fr-FR.mjs +0 -8
  62. package/dist/fr-FR.module.js +0 -8
  63. package/dist/fr-FR.module.js.map +0 -1
  64. package/dist/he-IL.main.js +0 -6
  65. package/dist/he-IL.main.js.map +0 -1
  66. package/dist/he-IL.mjs +0 -8
  67. package/dist/he-IL.module.js +0 -8
  68. package/dist/he-IL.module.js.map +0 -1
  69. package/dist/hr-HR.main.js +0 -6
  70. package/dist/hr-HR.main.js.map +0 -1
  71. package/dist/hr-HR.mjs +0 -8
  72. package/dist/hr-HR.module.js +0 -8
  73. package/dist/hr-HR.module.js.map +0 -1
  74. package/dist/hu-HU.main.js +0 -6
  75. package/dist/hu-HU.main.js.map +0 -1
  76. package/dist/hu-HU.mjs +0 -8
  77. package/dist/hu-HU.module.js +0 -8
  78. package/dist/hu-HU.module.js.map +0 -1
  79. package/dist/intlStrings.main.js +0 -108
  80. package/dist/intlStrings.main.js.map +0 -1
  81. package/dist/intlStrings.mjs +0 -110
  82. package/dist/intlStrings.module.js +0 -110
  83. package/dist/intlStrings.module.js.map +0 -1
  84. package/dist/it-IT.main.js +0 -6
  85. package/dist/it-IT.main.js.map +0 -1
  86. package/dist/it-IT.mjs +0 -8
  87. package/dist/it-IT.module.js +0 -8
  88. package/dist/it-IT.module.js.map +0 -1
  89. package/dist/ja-JP.main.js +0 -6
  90. package/dist/ja-JP.main.js.map +0 -1
  91. package/dist/ja-JP.mjs +0 -8
  92. package/dist/ja-JP.module.js +0 -8
  93. package/dist/ja-JP.module.js.map +0 -1
  94. package/dist/ko-KR.main.js +0 -6
  95. package/dist/ko-KR.main.js.map +0 -1
  96. package/dist/ko-KR.mjs +0 -8
  97. package/dist/ko-KR.module.js +0 -8
  98. package/dist/ko-KR.module.js.map +0 -1
  99. package/dist/lt-LT.main.js +0 -6
  100. package/dist/lt-LT.main.js.map +0 -1
  101. package/dist/lt-LT.mjs +0 -8
  102. package/dist/lt-LT.module.js +0 -8
  103. package/dist/lt-LT.module.js.map +0 -1
  104. package/dist/lv-LV.main.js +0 -6
  105. package/dist/lv-LV.main.js.map +0 -1
  106. package/dist/lv-LV.mjs +0 -8
  107. package/dist/lv-LV.module.js +0 -8
  108. package/dist/lv-LV.module.js.map +0 -1
  109. package/dist/nb-NO.main.js +0 -6
  110. package/dist/nb-NO.main.js.map +0 -1
  111. package/dist/nb-NO.mjs +0 -8
  112. package/dist/nb-NO.module.js +0 -8
  113. package/dist/nb-NO.module.js.map +0 -1
  114. package/dist/nl-NL.main.js +0 -6
  115. package/dist/nl-NL.main.js.map +0 -1
  116. package/dist/nl-NL.mjs +0 -8
  117. package/dist/nl-NL.module.js +0 -8
  118. package/dist/nl-NL.module.js.map +0 -1
  119. package/dist/pl-PL.main.js +0 -6
  120. package/dist/pl-PL.main.js.map +0 -1
  121. package/dist/pl-PL.mjs +0 -8
  122. package/dist/pl-PL.module.js +0 -8
  123. package/dist/pl-PL.module.js.map +0 -1
  124. package/dist/pt-BR.main.js +0 -6
  125. package/dist/pt-BR.main.js.map +0 -1
  126. package/dist/pt-BR.mjs +0 -8
  127. package/dist/pt-BR.module.js +0 -8
  128. package/dist/pt-BR.module.js.map +0 -1
  129. package/dist/pt-PT.main.js +0 -6
  130. package/dist/pt-PT.main.js.map +0 -1
  131. package/dist/pt-PT.mjs +0 -8
  132. package/dist/pt-PT.module.js +0 -8
  133. package/dist/pt-PT.module.js.map +0 -1
  134. package/dist/ro-RO.main.js +0 -6
  135. package/dist/ro-RO.main.js.map +0 -1
  136. package/dist/ro-RO.mjs +0 -8
  137. package/dist/ro-RO.module.js +0 -8
  138. package/dist/ro-RO.module.js.map +0 -1
  139. package/dist/ru-RU.main.js +0 -6
  140. package/dist/ru-RU.main.js.map +0 -1
  141. package/dist/ru-RU.mjs +0 -8
  142. package/dist/ru-RU.module.js +0 -8
  143. package/dist/ru-RU.module.js.map +0 -1
  144. package/dist/sk-SK.main.js +0 -6
  145. package/dist/sk-SK.main.js.map +0 -1
  146. package/dist/sk-SK.mjs +0 -8
  147. package/dist/sk-SK.module.js +0 -8
  148. package/dist/sk-SK.module.js.map +0 -1
  149. package/dist/sl-SI.main.js +0 -6
  150. package/dist/sl-SI.main.js.map +0 -1
  151. package/dist/sl-SI.mjs +0 -8
  152. package/dist/sl-SI.module.js +0 -8
  153. package/dist/sl-SI.module.js.map +0 -1
  154. package/dist/sr-SP.main.js +0 -6
  155. package/dist/sr-SP.main.js.map +0 -1
  156. package/dist/sr-SP.mjs +0 -8
  157. package/dist/sr-SP.module.js +0 -8
  158. package/dist/sr-SP.module.js.map +0 -1
  159. package/dist/sv-SE.main.js +0 -6
  160. package/dist/sv-SE.main.js.map +0 -1
  161. package/dist/sv-SE.mjs +0 -8
  162. package/dist/sv-SE.module.js +0 -8
  163. package/dist/sv-SE.module.js.map +0 -1
  164. package/dist/tr-TR.main.js +0 -6
  165. package/dist/tr-TR.main.js.map +0 -1
  166. package/dist/tr-TR.mjs +0 -8
  167. package/dist/tr-TR.module.js +0 -8
  168. package/dist/tr-TR.module.js.map +0 -1
  169. package/dist/types.d.ts +0 -97
  170. package/dist/types.d.ts.map +0 -1
  171. package/dist/uk-UA.main.js +0 -6
  172. package/dist/uk-UA.main.js.map +0 -1
  173. package/dist/uk-UA.mjs +0 -8
  174. package/dist/uk-UA.module.js +0 -8
  175. package/dist/uk-UA.module.js.map +0 -1
  176. package/dist/useAutocomplete.main.js +0 -318
  177. package/dist/useAutocomplete.main.js.map +0 -1
  178. package/dist/useAutocomplete.mjs +0 -313
  179. package/dist/useAutocomplete.module.js +0 -313
  180. package/dist/useAutocomplete.module.js.map +0 -1
  181. package/dist/useSearchAutocomplete.main.js +0 -73
  182. package/dist/useSearchAutocomplete.main.js.map +0 -1
  183. package/dist/useSearchAutocomplete.mjs +0 -68
  184. package/dist/useSearchAutocomplete.module.js +0 -68
  185. package/dist/useSearchAutocomplete.module.js.map +0 -1
  186. package/dist/zh-CN.main.js +0 -6
  187. package/dist/zh-CN.main.js.map +0 -1
  188. package/dist/zh-CN.mjs +0 -8
  189. package/dist/zh-CN.module.js +0 -8
  190. package/dist/zh-CN.module.js.map +0 -1
  191. package/dist/zh-TW.main.js +0 -6
  192. package/dist/zh-TW.main.js.map +0 -1
  193. package/dist/zh-TW.mjs +0 -8
  194. package/dist/zh-TW.module.js +0 -8
  195. package/dist/zh-TW.module.js.map +0 -1
  196. package/src/useAutocomplete.ts +0 -437
  197. package/src/useSearchAutocomplete.ts +0 -133
@@ -1,313 +0,0 @@
1
- import $4ELxY$intlStringsmodulejs from "./intlStrings.mjs";
2
- import {useId as $4ELxY$useId, isIOS as $4ELxY$isIOS, isAndroid as $4ELxY$isAndroid, useEffectEvent as $4ELxY$useEffectEvent, getActiveElement as $4ELxY$getActiveElement, getOwnerDocument as $4ELxY$getOwnerDocument, getEventTarget as $4ELxY$getEventTarget, useLayoutEffect as $4ELxY$useLayoutEffect, useObjectRef as $4ELxY$useObjectRef, mergeRefs as $4ELxY$mergeRefs, FOCUS_EVENT as $4ELxY$FOCUS_EVENT, CLEAR_FOCUS_EVENT as $4ELxY$CLEAR_FOCUS_EVENT, useEvent as $4ELxY$useEvent, isCtrlKeyPressed as $4ELxY$isCtrlKeyPressed, useLabels as $4ELxY$useLabels, mergeProps as $4ELxY$mergeProps} from "@react-aria/utils";
3
- import {moveVirtualFocus as $4ELxY$moveVirtualFocus, getVirtuallyFocusedElement as $4ELxY$getVirtuallyFocusedElement, dispatchVirtualFocus as $4ELxY$dispatchVirtualFocus, dispatchVirtualBlur as $4ELxY$dispatchVirtualBlur} from "@react-aria/focus";
4
- import {getInteractionModality as $4ELxY$getInteractionModality, getPointerType as $4ELxY$getPointerType} from "@react-aria/interactions";
5
- import {useRef as $4ELxY$useRef, useState as $4ELxY$useState, useEffect as $4ELxY$useEffect, useCallback as $4ELxY$useCallback, useMemo as $4ELxY$useMemo} from "react";
6
- import {useLocalizedStringFormatter as $4ELxY$useLocalizedStringFormatter} from "@react-aria/i18n";
7
-
8
-
9
- function $parcel$interopDefault(a) {
10
- return a && a.__esModule ? a.default : a;
11
- }
12
- /*
13
- * Copyright 2024 Adobe. All rights reserved.
14
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
15
- * you may not use this file except in compliance with the License. You may obtain a copy
16
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
17
- *
18
- * Unless required by applicable law or agreed to in writing, software distributed under
19
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
20
- * OF ANY KIND, either express or implied. See the License for the specific language
21
- * governing permissions and limitations under the License.
22
- */
23
-
24
-
25
-
26
-
27
-
28
- function $48f6ba390f8c5b59$export$1e40b3ca02d92d21(props, state) {
29
- let { inputRef: inputRef, collectionRef: collectionRef, filter: filter, disableAutoFocusFirst: disableAutoFocusFirst = false, disableVirtualFocus: disableVirtualFocus = false } = props;
30
- let collectionId = (0, $4ELxY$useId)();
31
- let timeout = (0, $4ELxY$useRef)(undefined);
32
- let delayNextActiveDescendant = (0, $4ELxY$useRef)(false);
33
- let queuedActiveDescendant = (0, $4ELxY$useRef)(null);
34
- // For mobile screen readers, we don't want virtual focus, instead opting to disable FocusScope's restoreFocus and manually
35
- // moving focus back to the subtriggers
36
- let isMobileScreenReader = (0, $4ELxY$getInteractionModality)() === 'virtual' && ((0, $4ELxY$isIOS)() || (0, $4ELxY$isAndroid)());
37
- let [shouldUseVirtualFocus, setShouldUseVirtualFocus] = (0, $4ELxY$useState)(!isMobileScreenReader && !disableVirtualFocus);
38
- // Tracks if a collection has been connected to the autocomplete. If false, we don't want to add various attributes to the autocomplete input
39
- // since it isn't attached to a filterable collection (e.g. Tabs)
40
- let [hasCollection, setHasCollection] = (0, $4ELxY$useState)(false);
41
- (0, $4ELxY$useEffect)(()=>{
42
- return ()=>clearTimeout(timeout.current);
43
- }, []);
44
- let updateActiveDescendantEvent = (0, $4ELxY$useEffectEvent)((e)=>{
45
- // Ensure input is focused if the user clicks on the collection directly.
46
- // don't trigger on touch so that mobile keyboard doesnt appear when tapping on options
47
- if (!e.isTrusted && shouldUseVirtualFocus && inputRef.current && (0, $4ELxY$getActiveElement)((0, $4ELxY$getOwnerDocument)(inputRef.current)) !== inputRef.current && (0, $4ELxY$getPointerType)() !== 'touch') inputRef.current.focus();
48
- let target = (0, $4ELxY$getEventTarget)(e);
49
- if (e.isTrusted || !target || queuedActiveDescendant.current === target.id) return;
50
- clearTimeout(timeout.current);
51
- if (target !== collectionRef.current) {
52
- if (delayNextActiveDescendant.current) {
53
- queuedActiveDescendant.current = target.id;
54
- timeout.current = setTimeout(()=>{
55
- state.setFocusedNodeId(target.id);
56
- }, 500);
57
- } else {
58
- queuedActiveDescendant.current = target.id;
59
- state.setFocusedNodeId(target.id);
60
- }
61
- } else if (queuedActiveDescendant.current && !document.getElementById(queuedActiveDescendant.current)) {
62
- // If we recieve a focus event refocusing the collection, either we have newly refocused the input and are waiting for the
63
- // wrapped collection to refocus the previously focused node if any OR
64
- // we are in a state where we've filtered to such a point that there aren't any matching items in the collection to focus.
65
- // In this case we want to clear tracked item if any and clear active descendant
66
- queuedActiveDescendant.current = null;
67
- state.setFocusedNodeId(null);
68
- }
69
- delayNextActiveDescendant.current = false;
70
- });
71
- let [collectionNode, setCollectionNode] = (0, $4ELxY$useState)(null);
72
- let callbackRef = (0, $4ELxY$useCallback)((node)=>{
73
- setCollectionNode(node);
74
- if (node != null) {
75
- // If useSelectableCollection isn't passed shouldUseVirtualFocus even when useAutocomplete provides it
76
- // that means the collection doesn't support it (e.g. Table). If that is the case, we need to disable it here regardless
77
- // of what the user's provided so that the input doesn't recieve the onKeyDown and autocomplete props.
78
- if (node.getAttribute('tabindex') != null) setShouldUseVirtualFocus(false);
79
- setHasCollection(true);
80
- } else setHasCollection(false);
81
- }, []);
82
- (0, $4ELxY$useLayoutEffect)(()=>{
83
- if (collectionNode != null) // When typing forward, we want to delay the setting of active descendant to not interrupt the native screen reader announcement
84
- // of the letter you just typed. If we recieve another focus event then we clear the queued update
85
- collectionNode.addEventListener('focusin', updateActiveDescendantEvent);
86
- return ()=>{
87
- collectionNode === null || collectionNode === void 0 ? void 0 : collectionNode.removeEventListener('focusin', updateActiveDescendantEvent);
88
- };
89
- }, [
90
- collectionNode
91
- ]);
92
- // Make sure to memo so that React doesn't keep registering a new event listeners on every rerender of the wrapped collection
93
- let mergedCollectionRef = (0, $4ELxY$useObjectRef)((0, $4ELxY$useMemo)(()=>(0, $4ELxY$mergeRefs)(collectionRef, callbackRef), [
94
- collectionRef,
95
- callbackRef
96
- ]));
97
- let focusFirstItem = (0, $4ELxY$useCallback)(()=>{
98
- var _collectionRef_current;
99
- delayNextActiveDescendant.current = true;
100
- (_collectionRef_current = collectionRef.current) === null || _collectionRef_current === void 0 ? void 0 : _collectionRef_current.dispatchEvent(new CustomEvent((0, $4ELxY$FOCUS_EVENT), {
101
- cancelable: true,
102
- bubbles: true,
103
- detail: {
104
- focusStrategy: 'first'
105
- }
106
- }));
107
- }, [
108
- collectionRef
109
- ]);
110
- let clearVirtualFocus = (0, $4ELxY$useCallback)((clearFocusKey)=>{
111
- var _collectionRef_current;
112
- (0, $4ELxY$moveVirtualFocus)((0, $4ELxY$getActiveElement)());
113
- queuedActiveDescendant.current = null;
114
- state.setFocusedNodeId(null);
115
- let clearFocusEvent = new CustomEvent((0, $4ELxY$CLEAR_FOCUS_EVENT), {
116
- cancelable: true,
117
- bubbles: true,
118
- detail: {
119
- clearFocusKey: clearFocusKey
120
- }
121
- });
122
- clearTimeout(timeout.current);
123
- delayNextActiveDescendant.current = false;
124
- (_collectionRef_current = collectionRef.current) === null || _collectionRef_current === void 0 ? void 0 : _collectionRef_current.dispatchEvent(clearFocusEvent);
125
- }, [
126
- collectionRef,
127
- state
128
- ]);
129
- let lastInputType = (0, $4ELxY$useRef)('');
130
- (0, $4ELxY$useEvent)(inputRef, 'input', (e)=>{
131
- let { inputType: inputType } = e;
132
- lastInputType.current = inputType;
133
- });
134
- let onChange = (value)=>{
135
- // Tell wrapped collection to focus the first element in the list when typing forward and to clear focused key when modifying the text via
136
- // copy paste/backspacing/undo/redo for screen reader announcements
137
- if (lastInputType.current === 'insertText' && !disableAutoFocusFirst) focusFirstItem();
138
- else if (lastInputType.current && (lastInputType.current.includes('insert') || lastInputType.current.includes('delete') || lastInputType.current.includes('history'))) {
139
- clearVirtualFocus(true);
140
- // If onChange was triggered before the timeout actually updated the activedescendant, we need to fire
141
- // our own dispatchVirtualFocus so focusVisible gets reapplied on the input
142
- if ((0, $4ELxY$getVirtuallyFocusedElement)(document) === inputRef.current) (0, $4ELxY$dispatchVirtualFocus)(inputRef.current, null);
143
- }
144
- state.setInputValue(value);
145
- };
146
- let keyDownTarget = (0, $4ELxY$useRef)(null);
147
- // For textfield specific keydown operations
148
- let onKeyDown = (e)=>{
149
- keyDownTarget.current = (0, $4ELxY$getEventTarget)(e);
150
- if (e.nativeEvent.isComposing) return;
151
- let focusedNodeId = queuedActiveDescendant.current;
152
- switch(e.key){
153
- case 'a':
154
- if ((0, $4ELxY$isCtrlKeyPressed)(e)) return;
155
- break;
156
- case 'Escape':
157
- // Early return for Escape here so it doesn't leak the Escape event from the simulated collection event below and
158
- // close the dialog prematurely. Ideally that should be up to the discretion of the input element hence the check
159
- // for isPropagationStopped
160
- if (e.isDefaultPrevented()) return;
161
- break;
162
- case ' ':
163
- // Space shouldn't trigger onAction so early return.
164
- return;
165
- case 'Tab':
166
- // Don't propogate Tab down to the collection, otherwise we will try to focus the collection via useSelectableCollection's Tab handler (aka shift tab logic)
167
- // We want FocusScope to handle Tab if one exists (aka sub dialog), so special casepropogate
168
- if ('continuePropagation' in e) e.continuePropagation();
169
- return;
170
- case 'Home':
171
- case 'End':
172
- case 'PageDown':
173
- case 'PageUp':
174
- case 'ArrowUp':
175
- case 'ArrowDown':
176
- {
177
- var _collectionRef_current;
178
- if ((e.key === 'Home' || e.key === 'End') && focusedNodeId == null && e.shiftKey) return;
179
- // Prevent these keys from moving the text cursor in the input
180
- e.preventDefault();
181
- // Move virtual focus into the wrapped collection
182
- let focusCollection = new CustomEvent((0, $4ELxY$FOCUS_EVENT), {
183
- cancelable: true,
184
- bubbles: true
185
- });
186
- (_collectionRef_current = collectionRef.current) === null || _collectionRef_current === void 0 ? void 0 : _collectionRef_current.dispatchEvent(focusCollection);
187
- break;
188
- }
189
- }
190
- // Emulate the keyboard events that happen in the input field in the wrapped collection. This is for triggering things like onAction via Enter
191
- // or moving focus from one item to another. Stop propagation on the input event if it isn't already stopped so it doesn't leak out. For events
192
- // like ESC, the dispatched event below will bubble out of the collection and be stopped if handled by useSelectableCollection, otherwise will bubble
193
- // as expected
194
- if (!e.isPropagationStopped()) e.stopPropagation();
195
- let shouldPerformDefaultAction = true;
196
- if (collectionRef.current !== null) {
197
- var _collectionRef_current1;
198
- if (focusedNodeId == null) shouldPerformDefaultAction = ((_collectionRef_current1 = collectionRef.current) === null || _collectionRef_current1 === void 0 ? void 0 : _collectionRef_current1.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent))) || false;
199
- else {
200
- let item = document.getElementById(focusedNodeId);
201
- if (item) shouldPerformDefaultAction = (item === null || item === void 0 ? void 0 : item.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent))) || false;
202
- }
203
- }
204
- if (shouldPerformDefaultAction) switch(e.key){
205
- case 'ArrowLeft':
206
- case 'ArrowRight':
207
- // Clear the activedescendant so NVDA announcements aren't interrupted but retain the focused key in the collection so the
208
- // user's keyboard navigation restarts from where they left off
209
- clearVirtualFocus();
210
- break;
211
- case 'Enter':
212
- // Trigger click action on item when Enter key was pressed.
213
- if (focusedNodeId != null) {
214
- let item = document.getElementById(focusedNodeId);
215
- item === null || item === void 0 ? void 0 : item.dispatchEvent(new PointerEvent('click', e.nativeEvent));
216
- }
217
- break;
218
- }
219
- else // TODO: check if we can do this, want to stop textArea from using its default Enter behavior so items are properly triggered
220
- e.preventDefault();
221
- };
222
- let onKeyUpCapture = (0, $4ELxY$useEffectEvent)((e)=>{
223
- // Dispatch simulated key up events for things like triggering links in listbox
224
- // Make sure to stop the propagation of the input keyup event so that the simulated keyup/down pair
225
- // is detected by usePress instead of the original keyup originating from the input
226
- if ((0, $4ELxY$getEventTarget)(e) === keyDownTarget.current) {
227
- var _collectionRef_current;
228
- e.stopImmediatePropagation();
229
- let focusedNodeId = queuedActiveDescendant.current;
230
- if (focusedNodeId == null) (_collectionRef_current = collectionRef.current) === null || _collectionRef_current === void 0 ? void 0 : _collectionRef_current.dispatchEvent(new KeyboardEvent(e.type, e));
231
- else {
232
- let item = document.getElementById(focusedNodeId);
233
- item === null || item === void 0 ? void 0 : item.dispatchEvent(new KeyboardEvent(e.type, e));
234
- }
235
- }
236
- });
237
- (0, $4ELxY$useEffect)(()=>{
238
- document.addEventListener('keyup', onKeyUpCapture, true);
239
- return ()=>{
240
- document.removeEventListener('keyup', onKeyUpCapture, true);
241
- };
242
- }, []);
243
- let stringFormatter = (0, $4ELxY$useLocalizedStringFormatter)((0, ($parcel$interopDefault($4ELxY$intlStringsmodulejs))), '@react-aria/autocomplete');
244
- let collectionProps = (0, $4ELxY$useLabels)({
245
- id: collectionId,
246
- 'aria-label': stringFormatter.format('collectionLabel')
247
- });
248
- let filterFn = (0, $4ELxY$useCallback)((nodeTextValue, node)=>{
249
- if (filter) return filter(nodeTextValue, state.inputValue, node);
250
- return true;
251
- }, [
252
- state.inputValue,
253
- filter
254
- ]);
255
- // Be sure to clear/restore the virtual + collection focus when blurring/refocusing the field so we only show the
256
- // focus ring on the virtually focused collection when are actually interacting with the Autocomplete
257
- let onBlur = (e)=>{
258
- if (!e.isTrusted) return;
259
- let lastFocusedNode = queuedActiveDescendant.current ? document.getElementById(queuedActiveDescendant.current) : null;
260
- if (lastFocusedNode) (0, $4ELxY$dispatchVirtualBlur)(lastFocusedNode, e.relatedTarget);
261
- };
262
- let onFocus = (e)=>{
263
- if (!e.isTrusted) return;
264
- let curFocusedNode = queuedActiveDescendant.current ? document.getElementById(queuedActiveDescendant.current) : null;
265
- if (curFocusedNode) {
266
- let target = (0, $4ELxY$getEventTarget)(e);
267
- queueMicrotask(()=>{
268
- // instead of focusing the last focused node, just focus the collection instead and have the collection handle what item to focus via useSelectableCollection/Item
269
- (0, $4ELxY$dispatchVirtualBlur)(target, collectionRef.current);
270
- (0, $4ELxY$dispatchVirtualFocus)(collectionRef.current, target);
271
- });
272
- }
273
- };
274
- // Only apply the autocomplete specific behaviors if the collection component wrapped by it is actually
275
- // being filtered/allows filtering by the Autocomplete.
276
- let inputProps = {
277
- value: state.inputValue,
278
- onChange: onChange
279
- };
280
- var _state_focusedNodeId;
281
- let virtualFocusProps = {
282
- onKeyDown: onKeyDown,
283
- 'aria-activedescendant': (_state_focusedNodeId = state.focusedNodeId) !== null && _state_focusedNodeId !== void 0 ? _state_focusedNodeId : undefined,
284
- onBlur: onBlur,
285
- onFocus: onFocus
286
- };
287
- if (hasCollection) inputProps = {
288
- ...inputProps,
289
- ...shouldUseVirtualFocus && virtualFocusProps,
290
- enterKeyHint: 'go',
291
- 'aria-controls': collectionId,
292
- // TODO: readd proper logic for completionMode = complete (aria-autocomplete: both)
293
- 'aria-autocomplete': 'list',
294
- // This disable's iOS's autocorrect suggestions, since the autocomplete provides its own suggestions.
295
- autoCorrect: 'off',
296
- // This disable's the macOS Safari spell check auto corrections.
297
- spellCheck: 'false',
298
- autoComplete: 'off'
299
- };
300
- return {
301
- inputProps: inputProps,
302
- collectionProps: (0, $4ELxY$mergeProps)(collectionProps, {
303
- shouldUseVirtualFocus: shouldUseVirtualFocus,
304
- disallowTypeAhead: shouldUseVirtualFocus
305
- }),
306
- collectionRef: mergedCollectionRef,
307
- filter: filter != null ? filterFn : undefined
308
- };
309
- }
310
-
311
-
312
- export {$48f6ba390f8c5b59$export$1e40b3ca02d92d21 as useAutocomplete};
313
- //# sourceMappingURL=useAutocomplete.module.js.map
@@ -1,313 +0,0 @@
1
- import $4ELxY$intlStringsmodulejs from "./intlStrings.module.js";
2
- import {useId as $4ELxY$useId, isIOS as $4ELxY$isIOS, isAndroid as $4ELxY$isAndroid, useEffectEvent as $4ELxY$useEffectEvent, getActiveElement as $4ELxY$getActiveElement, getOwnerDocument as $4ELxY$getOwnerDocument, getEventTarget as $4ELxY$getEventTarget, useLayoutEffect as $4ELxY$useLayoutEffect, useObjectRef as $4ELxY$useObjectRef, mergeRefs as $4ELxY$mergeRefs, FOCUS_EVENT as $4ELxY$FOCUS_EVENT, CLEAR_FOCUS_EVENT as $4ELxY$CLEAR_FOCUS_EVENT, useEvent as $4ELxY$useEvent, isCtrlKeyPressed as $4ELxY$isCtrlKeyPressed, useLabels as $4ELxY$useLabels, mergeProps as $4ELxY$mergeProps} from "@react-aria/utils";
3
- import {moveVirtualFocus as $4ELxY$moveVirtualFocus, getVirtuallyFocusedElement as $4ELxY$getVirtuallyFocusedElement, dispatchVirtualFocus as $4ELxY$dispatchVirtualFocus, dispatchVirtualBlur as $4ELxY$dispatchVirtualBlur} from "@react-aria/focus";
4
- import {getInteractionModality as $4ELxY$getInteractionModality, getPointerType as $4ELxY$getPointerType} from "@react-aria/interactions";
5
- import {useRef as $4ELxY$useRef, useState as $4ELxY$useState, useEffect as $4ELxY$useEffect, useCallback as $4ELxY$useCallback, useMemo as $4ELxY$useMemo} from "react";
6
- import {useLocalizedStringFormatter as $4ELxY$useLocalizedStringFormatter} from "@react-aria/i18n";
7
-
8
-
9
- function $parcel$interopDefault(a) {
10
- return a && a.__esModule ? a.default : a;
11
- }
12
- /*
13
- * Copyright 2024 Adobe. All rights reserved.
14
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
15
- * you may not use this file except in compliance with the License. You may obtain a copy
16
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
17
- *
18
- * Unless required by applicable law or agreed to in writing, software distributed under
19
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
20
- * OF ANY KIND, either express or implied. See the License for the specific language
21
- * governing permissions and limitations under the License.
22
- */
23
-
24
-
25
-
26
-
27
-
28
- function $48f6ba390f8c5b59$export$1e40b3ca02d92d21(props, state) {
29
- let { inputRef: inputRef, collectionRef: collectionRef, filter: filter, disableAutoFocusFirst: disableAutoFocusFirst = false, disableVirtualFocus: disableVirtualFocus = false } = props;
30
- let collectionId = (0, $4ELxY$useId)();
31
- let timeout = (0, $4ELxY$useRef)(undefined);
32
- let delayNextActiveDescendant = (0, $4ELxY$useRef)(false);
33
- let queuedActiveDescendant = (0, $4ELxY$useRef)(null);
34
- // For mobile screen readers, we don't want virtual focus, instead opting to disable FocusScope's restoreFocus and manually
35
- // moving focus back to the subtriggers
36
- let isMobileScreenReader = (0, $4ELxY$getInteractionModality)() === 'virtual' && ((0, $4ELxY$isIOS)() || (0, $4ELxY$isAndroid)());
37
- let [shouldUseVirtualFocus, setShouldUseVirtualFocus] = (0, $4ELxY$useState)(!isMobileScreenReader && !disableVirtualFocus);
38
- // Tracks if a collection has been connected to the autocomplete. If false, we don't want to add various attributes to the autocomplete input
39
- // since it isn't attached to a filterable collection (e.g. Tabs)
40
- let [hasCollection, setHasCollection] = (0, $4ELxY$useState)(false);
41
- (0, $4ELxY$useEffect)(()=>{
42
- return ()=>clearTimeout(timeout.current);
43
- }, []);
44
- let updateActiveDescendantEvent = (0, $4ELxY$useEffectEvent)((e)=>{
45
- // Ensure input is focused if the user clicks on the collection directly.
46
- // don't trigger on touch so that mobile keyboard doesnt appear when tapping on options
47
- if (!e.isTrusted && shouldUseVirtualFocus && inputRef.current && (0, $4ELxY$getActiveElement)((0, $4ELxY$getOwnerDocument)(inputRef.current)) !== inputRef.current && (0, $4ELxY$getPointerType)() !== 'touch') inputRef.current.focus();
48
- let target = (0, $4ELxY$getEventTarget)(e);
49
- if (e.isTrusted || !target || queuedActiveDescendant.current === target.id) return;
50
- clearTimeout(timeout.current);
51
- if (target !== collectionRef.current) {
52
- if (delayNextActiveDescendant.current) {
53
- queuedActiveDescendant.current = target.id;
54
- timeout.current = setTimeout(()=>{
55
- state.setFocusedNodeId(target.id);
56
- }, 500);
57
- } else {
58
- queuedActiveDescendant.current = target.id;
59
- state.setFocusedNodeId(target.id);
60
- }
61
- } else if (queuedActiveDescendant.current && !document.getElementById(queuedActiveDescendant.current)) {
62
- // If we recieve a focus event refocusing the collection, either we have newly refocused the input and are waiting for the
63
- // wrapped collection to refocus the previously focused node if any OR
64
- // we are in a state where we've filtered to such a point that there aren't any matching items in the collection to focus.
65
- // In this case we want to clear tracked item if any and clear active descendant
66
- queuedActiveDescendant.current = null;
67
- state.setFocusedNodeId(null);
68
- }
69
- delayNextActiveDescendant.current = false;
70
- });
71
- let [collectionNode, setCollectionNode] = (0, $4ELxY$useState)(null);
72
- let callbackRef = (0, $4ELxY$useCallback)((node)=>{
73
- setCollectionNode(node);
74
- if (node != null) {
75
- // If useSelectableCollection isn't passed shouldUseVirtualFocus even when useAutocomplete provides it
76
- // that means the collection doesn't support it (e.g. Table). If that is the case, we need to disable it here regardless
77
- // of what the user's provided so that the input doesn't recieve the onKeyDown and autocomplete props.
78
- if (node.getAttribute('tabindex') != null) setShouldUseVirtualFocus(false);
79
- setHasCollection(true);
80
- } else setHasCollection(false);
81
- }, []);
82
- (0, $4ELxY$useLayoutEffect)(()=>{
83
- if (collectionNode != null) // When typing forward, we want to delay the setting of active descendant to not interrupt the native screen reader announcement
84
- // of the letter you just typed. If we recieve another focus event then we clear the queued update
85
- collectionNode.addEventListener('focusin', updateActiveDescendantEvent);
86
- return ()=>{
87
- collectionNode === null || collectionNode === void 0 ? void 0 : collectionNode.removeEventListener('focusin', updateActiveDescendantEvent);
88
- };
89
- }, [
90
- collectionNode
91
- ]);
92
- // Make sure to memo so that React doesn't keep registering a new event listeners on every rerender of the wrapped collection
93
- let mergedCollectionRef = (0, $4ELxY$useObjectRef)((0, $4ELxY$useMemo)(()=>(0, $4ELxY$mergeRefs)(collectionRef, callbackRef), [
94
- collectionRef,
95
- callbackRef
96
- ]));
97
- let focusFirstItem = (0, $4ELxY$useCallback)(()=>{
98
- var _collectionRef_current;
99
- delayNextActiveDescendant.current = true;
100
- (_collectionRef_current = collectionRef.current) === null || _collectionRef_current === void 0 ? void 0 : _collectionRef_current.dispatchEvent(new CustomEvent((0, $4ELxY$FOCUS_EVENT), {
101
- cancelable: true,
102
- bubbles: true,
103
- detail: {
104
- focusStrategy: 'first'
105
- }
106
- }));
107
- }, [
108
- collectionRef
109
- ]);
110
- let clearVirtualFocus = (0, $4ELxY$useCallback)((clearFocusKey)=>{
111
- var _collectionRef_current;
112
- (0, $4ELxY$moveVirtualFocus)((0, $4ELxY$getActiveElement)());
113
- queuedActiveDescendant.current = null;
114
- state.setFocusedNodeId(null);
115
- let clearFocusEvent = new CustomEvent((0, $4ELxY$CLEAR_FOCUS_EVENT), {
116
- cancelable: true,
117
- bubbles: true,
118
- detail: {
119
- clearFocusKey: clearFocusKey
120
- }
121
- });
122
- clearTimeout(timeout.current);
123
- delayNextActiveDescendant.current = false;
124
- (_collectionRef_current = collectionRef.current) === null || _collectionRef_current === void 0 ? void 0 : _collectionRef_current.dispatchEvent(clearFocusEvent);
125
- }, [
126
- collectionRef,
127
- state
128
- ]);
129
- let lastInputType = (0, $4ELxY$useRef)('');
130
- (0, $4ELxY$useEvent)(inputRef, 'input', (e)=>{
131
- let { inputType: inputType } = e;
132
- lastInputType.current = inputType;
133
- });
134
- let onChange = (value)=>{
135
- // Tell wrapped collection to focus the first element in the list when typing forward and to clear focused key when modifying the text via
136
- // copy paste/backspacing/undo/redo for screen reader announcements
137
- if (lastInputType.current === 'insertText' && !disableAutoFocusFirst) focusFirstItem();
138
- else if (lastInputType.current && (lastInputType.current.includes('insert') || lastInputType.current.includes('delete') || lastInputType.current.includes('history'))) {
139
- clearVirtualFocus(true);
140
- // If onChange was triggered before the timeout actually updated the activedescendant, we need to fire
141
- // our own dispatchVirtualFocus so focusVisible gets reapplied on the input
142
- if ((0, $4ELxY$getVirtuallyFocusedElement)(document) === inputRef.current) (0, $4ELxY$dispatchVirtualFocus)(inputRef.current, null);
143
- }
144
- state.setInputValue(value);
145
- };
146
- let keyDownTarget = (0, $4ELxY$useRef)(null);
147
- // For textfield specific keydown operations
148
- let onKeyDown = (e)=>{
149
- keyDownTarget.current = (0, $4ELxY$getEventTarget)(e);
150
- if (e.nativeEvent.isComposing) return;
151
- let focusedNodeId = queuedActiveDescendant.current;
152
- switch(e.key){
153
- case 'a':
154
- if ((0, $4ELxY$isCtrlKeyPressed)(e)) return;
155
- break;
156
- case 'Escape':
157
- // Early return for Escape here so it doesn't leak the Escape event from the simulated collection event below and
158
- // close the dialog prematurely. Ideally that should be up to the discretion of the input element hence the check
159
- // for isPropagationStopped
160
- if (e.isDefaultPrevented()) return;
161
- break;
162
- case ' ':
163
- // Space shouldn't trigger onAction so early return.
164
- return;
165
- case 'Tab':
166
- // Don't propogate Tab down to the collection, otherwise we will try to focus the collection via useSelectableCollection's Tab handler (aka shift tab logic)
167
- // We want FocusScope to handle Tab if one exists (aka sub dialog), so special casepropogate
168
- if ('continuePropagation' in e) e.continuePropagation();
169
- return;
170
- case 'Home':
171
- case 'End':
172
- case 'PageDown':
173
- case 'PageUp':
174
- case 'ArrowUp':
175
- case 'ArrowDown':
176
- {
177
- var _collectionRef_current;
178
- if ((e.key === 'Home' || e.key === 'End') && focusedNodeId == null && e.shiftKey) return;
179
- // Prevent these keys from moving the text cursor in the input
180
- e.preventDefault();
181
- // Move virtual focus into the wrapped collection
182
- let focusCollection = new CustomEvent((0, $4ELxY$FOCUS_EVENT), {
183
- cancelable: true,
184
- bubbles: true
185
- });
186
- (_collectionRef_current = collectionRef.current) === null || _collectionRef_current === void 0 ? void 0 : _collectionRef_current.dispatchEvent(focusCollection);
187
- break;
188
- }
189
- }
190
- // Emulate the keyboard events that happen in the input field in the wrapped collection. This is for triggering things like onAction via Enter
191
- // or moving focus from one item to another. Stop propagation on the input event if it isn't already stopped so it doesn't leak out. For events
192
- // like ESC, the dispatched event below will bubble out of the collection and be stopped if handled by useSelectableCollection, otherwise will bubble
193
- // as expected
194
- if (!e.isPropagationStopped()) e.stopPropagation();
195
- let shouldPerformDefaultAction = true;
196
- if (collectionRef.current !== null) {
197
- var _collectionRef_current1;
198
- if (focusedNodeId == null) shouldPerformDefaultAction = ((_collectionRef_current1 = collectionRef.current) === null || _collectionRef_current1 === void 0 ? void 0 : _collectionRef_current1.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent))) || false;
199
- else {
200
- let item = document.getElementById(focusedNodeId);
201
- if (item) shouldPerformDefaultAction = (item === null || item === void 0 ? void 0 : item.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent))) || false;
202
- }
203
- }
204
- if (shouldPerformDefaultAction) switch(e.key){
205
- case 'ArrowLeft':
206
- case 'ArrowRight':
207
- // Clear the activedescendant so NVDA announcements aren't interrupted but retain the focused key in the collection so the
208
- // user's keyboard navigation restarts from where they left off
209
- clearVirtualFocus();
210
- break;
211
- case 'Enter':
212
- // Trigger click action on item when Enter key was pressed.
213
- if (focusedNodeId != null) {
214
- let item = document.getElementById(focusedNodeId);
215
- item === null || item === void 0 ? void 0 : item.dispatchEvent(new PointerEvent('click', e.nativeEvent));
216
- }
217
- break;
218
- }
219
- else // TODO: check if we can do this, want to stop textArea from using its default Enter behavior so items are properly triggered
220
- e.preventDefault();
221
- };
222
- let onKeyUpCapture = (0, $4ELxY$useEffectEvent)((e)=>{
223
- // Dispatch simulated key up events for things like triggering links in listbox
224
- // Make sure to stop the propagation of the input keyup event so that the simulated keyup/down pair
225
- // is detected by usePress instead of the original keyup originating from the input
226
- if ((0, $4ELxY$getEventTarget)(e) === keyDownTarget.current) {
227
- var _collectionRef_current;
228
- e.stopImmediatePropagation();
229
- let focusedNodeId = queuedActiveDescendant.current;
230
- if (focusedNodeId == null) (_collectionRef_current = collectionRef.current) === null || _collectionRef_current === void 0 ? void 0 : _collectionRef_current.dispatchEvent(new KeyboardEvent(e.type, e));
231
- else {
232
- let item = document.getElementById(focusedNodeId);
233
- item === null || item === void 0 ? void 0 : item.dispatchEvent(new KeyboardEvent(e.type, e));
234
- }
235
- }
236
- });
237
- (0, $4ELxY$useEffect)(()=>{
238
- document.addEventListener('keyup', onKeyUpCapture, true);
239
- return ()=>{
240
- document.removeEventListener('keyup', onKeyUpCapture, true);
241
- };
242
- }, []);
243
- let stringFormatter = (0, $4ELxY$useLocalizedStringFormatter)((0, ($parcel$interopDefault($4ELxY$intlStringsmodulejs))), '@react-aria/autocomplete');
244
- let collectionProps = (0, $4ELxY$useLabels)({
245
- id: collectionId,
246
- 'aria-label': stringFormatter.format('collectionLabel')
247
- });
248
- let filterFn = (0, $4ELxY$useCallback)((nodeTextValue, node)=>{
249
- if (filter) return filter(nodeTextValue, state.inputValue, node);
250
- return true;
251
- }, [
252
- state.inputValue,
253
- filter
254
- ]);
255
- // Be sure to clear/restore the virtual + collection focus when blurring/refocusing the field so we only show the
256
- // focus ring on the virtually focused collection when are actually interacting with the Autocomplete
257
- let onBlur = (e)=>{
258
- if (!e.isTrusted) return;
259
- let lastFocusedNode = queuedActiveDescendant.current ? document.getElementById(queuedActiveDescendant.current) : null;
260
- if (lastFocusedNode) (0, $4ELxY$dispatchVirtualBlur)(lastFocusedNode, e.relatedTarget);
261
- };
262
- let onFocus = (e)=>{
263
- if (!e.isTrusted) return;
264
- let curFocusedNode = queuedActiveDescendant.current ? document.getElementById(queuedActiveDescendant.current) : null;
265
- if (curFocusedNode) {
266
- let target = (0, $4ELxY$getEventTarget)(e);
267
- queueMicrotask(()=>{
268
- // instead of focusing the last focused node, just focus the collection instead and have the collection handle what item to focus via useSelectableCollection/Item
269
- (0, $4ELxY$dispatchVirtualBlur)(target, collectionRef.current);
270
- (0, $4ELxY$dispatchVirtualFocus)(collectionRef.current, target);
271
- });
272
- }
273
- };
274
- // Only apply the autocomplete specific behaviors if the collection component wrapped by it is actually
275
- // being filtered/allows filtering by the Autocomplete.
276
- let inputProps = {
277
- value: state.inputValue,
278
- onChange: onChange
279
- };
280
- var _state_focusedNodeId;
281
- let virtualFocusProps = {
282
- onKeyDown: onKeyDown,
283
- 'aria-activedescendant': (_state_focusedNodeId = state.focusedNodeId) !== null && _state_focusedNodeId !== void 0 ? _state_focusedNodeId : undefined,
284
- onBlur: onBlur,
285
- onFocus: onFocus
286
- };
287
- if (hasCollection) inputProps = {
288
- ...inputProps,
289
- ...shouldUseVirtualFocus && virtualFocusProps,
290
- enterKeyHint: 'go',
291
- 'aria-controls': collectionId,
292
- // TODO: readd proper logic for completionMode = complete (aria-autocomplete: both)
293
- 'aria-autocomplete': 'list',
294
- // This disable's iOS's autocorrect suggestions, since the autocomplete provides its own suggestions.
295
- autoCorrect: 'off',
296
- // This disable's the macOS Safari spell check auto corrections.
297
- spellCheck: 'false',
298
- autoComplete: 'off'
299
- };
300
- return {
301
- inputProps: inputProps,
302
- collectionProps: (0, $4ELxY$mergeProps)(collectionProps, {
303
- shouldUseVirtualFocus: shouldUseVirtualFocus,
304
- disallowTypeAhead: shouldUseVirtualFocus
305
- }),
306
- collectionRef: mergedCollectionRef,
307
- filter: filter != null ? filterFn : undefined
308
- };
309
- }
310
-
311
-
312
- export {$48f6ba390f8c5b59$export$1e40b3ca02d92d21 as useAutocomplete};
313
- //# sourceMappingURL=useAutocomplete.module.js.map