@react-aria/selection 3.12.0 → 3.13.0

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/module.js CHANGED
@@ -1,34 +1,74 @@
1
1
  import {useRef as $eCAIO$useRef, useEffect as $eCAIO$useEffect, useMemo as $eCAIO$useMemo} from "react";
2
2
  import {getFocusableTreeWalker as $eCAIO$getFocusableTreeWalker, focusSafely as $eCAIO$focusSafely} from "@react-aria/focus";
3
- import {focusWithoutScrolling as $eCAIO$focusWithoutScrolling, useEvent as $eCAIO$useEvent, scrollIntoView as $eCAIO$scrollIntoView, mergeProps as $eCAIO$mergeProps, isAppleDevice as $eCAIO$isAppleDevice, isMac as $eCAIO$isMac} from "@react-aria/utils";
3
+ import {focusWithoutScrolling as $eCAIO$focusWithoutScrolling, useEvent as $eCAIO$useEvent, scrollIntoView as $eCAIO$scrollIntoView, scrollIntoViewport as $eCAIO$scrollIntoViewport, mergeProps as $eCAIO$mergeProps, isAppleDevice as $eCAIO$isAppleDevice, isMac as $eCAIO$isMac} from "@react-aria/utils";
4
4
  import {useLocale as $eCAIO$useLocale, useCollator as $eCAIO$useCollator} from "@react-aria/i18n";
5
5
  import {usePress as $eCAIO$usePress, useLongPress as $eCAIO$useLongPress} from "@react-aria/interactions";
6
6
 
7
-
8
-
9
-
10
-
7
+ /*
8
+ * Copyright 2020 Adobe. All rights reserved.
9
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License. You may obtain a copy
11
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software distributed under
14
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
+ * OF ANY KIND, either express or implied. See the License for the specific language
16
+ * governing permissions and limitations under the License.
17
+ */ /*
18
+ * Copyright 2020 Adobe. All rights reserved.
19
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
20
+ * you may not use this file except in compliance with the License. You may obtain a copy
21
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
22
+ *
23
+ * Unless required by applicable law or agreed to in writing, software distributed under
24
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
25
+ * OF ANY KIND, either express or implied. See the License for the specific language
26
+ * governing permissions and limitations under the License.
27
+ */
28
+
29
+
30
+ /*
31
+ * Copyright 2020 Adobe. All rights reserved.
32
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
33
+ * you may not use this file except in compliance with the License. You may obtain a copy
34
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
35
+ *
36
+ * Unless required by applicable law or agreed to in writing, software distributed under
37
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
38
+ * OF ANY KIND, either express or implied. See the License for the specific language
39
+ * governing permissions and limitations under the License.
40
+ */
11
41
 
12
42
  function $feb5ffebff200149$export$d3e3bd3e26688c04(e) {
13
43
  // Ctrl + Arrow Up/Arrow Down has a system wide meaning on macOS, so use Alt instead.
14
44
  // On Windows and Ubuntu, Alt + Space has a system wide meaning.
15
- return $eCAIO$isAppleDevice() ? e.altKey : e.ctrlKey;
45
+ return (0, $eCAIO$isAppleDevice)() ? e.altKey : e.ctrlKey;
16
46
  }
17
47
  function $feb5ffebff200149$export$16792effe837dba3(e) {
18
- if ($eCAIO$isMac()) return e.metaKey;
48
+ if ((0, $eCAIO$isMac)()) return e.metaKey;
19
49
  return e.ctrlKey;
20
50
  }
21
51
 
22
52
 
23
53
 
24
-
54
+ /*
55
+ * Copyright 2020 Adobe. All rights reserved.
56
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
57
+ * you may not use this file except in compliance with the License. You may obtain a copy
58
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
59
+ *
60
+ * Unless required by applicable law or agreed to in writing, software distributed under
61
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
62
+ * OF ANY KIND, either express or implied. See the License for the specific language
63
+ * governing permissions and limitations under the License.
64
+ */
25
65
  /**
26
66
  * Controls how long to wait before clearing the typeahead buffer.
27
67
  */ const $fb3050f43d946246$var$TYPEAHEAD_DEBOUNCE_WAIT_MS = 1000; // 1 second
28
68
  function $fb3050f43d946246$export$e32c88dfddc6e1d8(options) {
29
69
  let { keyboardDelegate: keyboardDelegate , selectionManager: selectionManager , onTypeSelect: onTypeSelect } = options;
30
- let state = $eCAIO$useRef({
31
- search: '',
70
+ let state = (0, $eCAIO$useRef)({
71
+ search: "",
32
72
  timeout: null
33
73
  }).current;
34
74
  let onKeyDown = (e)=>{
@@ -38,9 +78,9 @@ function $fb3050f43d946246$export$e32c88dfddc6e1d8(options) {
38
78
  // When we time out, the search term becomes empty, hence the check on length.
39
79
  // Trimming is to account for the case of pressing the Spacebar more than once,
40
80
  // which should cycle through the selection/deselection of the focused item.
41
- if (character === ' ' && state.search.trim().length > 0) {
81
+ if (character === " " && state.search.trim().length > 0) {
42
82
  e.preventDefault();
43
- if (!('continuePropagation' in e)) e.stopPropagation();
83
+ if (!("continuePropagation" in e)) e.stopPropagation();
44
84
  }
45
85
  state.search += character;
46
86
  // Use the delegate to find a key to focus.
@@ -54,7 +94,7 @@ function $fb3050f43d946246$export$e32c88dfddc6e1d8(options) {
54
94
  }
55
95
  clearTimeout(state.timeout);
56
96
  state.timeout = setTimeout(()=>{
57
- state.search = '';
97
+ state.search = "";
58
98
  }, $fb3050f43d946246$var$TYPEAHEAD_DEBOUNCE_WAIT_MS);
59
99
  };
60
100
  return {
@@ -71,103 +111,103 @@ function $fb3050f43d946246$var$getStringForKey(key) {
71
111
  // it is a Unicode character.
72
112
  // See https://www.w3.org/TR/uievents-key/
73
113
  if (key.length === 1 || !/^[A-Z]/i.test(key)) return key;
74
- return '';
114
+ return "";
75
115
  }
76
116
 
77
117
 
78
118
  function $ae20dd8cbca75726$export$d6daf82dcd84e87c(options) {
79
- let { selectionManager: manager , keyboardDelegate: delegate , ref: ref , autoFocus: autoFocus = false , shouldFocusWrap: shouldFocusWrap = false , disallowEmptySelection: disallowEmptySelection = false , disallowSelectAll: disallowSelectAll = false , selectOnFocus: selectOnFocus = manager.selectionBehavior === 'replace' , disallowTypeAhead: disallowTypeAhead = false , shouldUseVirtualFocus: shouldUseVirtualFocus , allowsTabNavigation: allowsTabNavigation = false , isVirtualized: isVirtualized , scrollRef: // If no scrollRef is provided, assume the collection ref is the scrollable region
119
+ let { selectionManager: manager , keyboardDelegate: delegate , ref: ref , autoFocus: autoFocus = false , shouldFocusWrap: shouldFocusWrap = false , disallowEmptySelection: disallowEmptySelection = false , disallowSelectAll: disallowSelectAll = false , selectOnFocus: selectOnFocus = manager.selectionBehavior === "replace" , disallowTypeAhead: disallowTypeAhead = false , shouldUseVirtualFocus: shouldUseVirtualFocus , allowsTabNavigation: allowsTabNavigation = false , isVirtualized: isVirtualized , scrollRef: // If no scrollRef is provided, assume the collection ref is the scrollable region
80
120
  scrollRef = ref } = options;
81
- let { direction: direction } = $eCAIO$useLocale();
121
+ let { direction: direction } = (0, $eCAIO$useLocale)();
82
122
  let onKeyDown = (e)=>{
83
123
  // Prevent option + tab from doing anything since it doesn't move focus to the cells, only buttons/checkboxes
84
- if (e.altKey && e.key === 'Tab') e.preventDefault();
124
+ if (e.altKey && e.key === "Tab") e.preventDefault();
85
125
  // Keyboard events bubble through portals. Don't handle keyboard events
86
126
  // for elements outside the collection (e.g. menus).
87
127
  if (!ref.current.contains(e.target)) return;
88
128
  const navigateToKey = (key, childFocus)=>{
89
129
  if (key != null) {
90
130
  manager.setFocusedKey(key, childFocus);
91
- if (e.shiftKey && manager.selectionMode === 'multiple') manager.extendSelection(key);
92
- else if (selectOnFocus && !$feb5ffebff200149$export$d3e3bd3e26688c04(e)) manager.replaceSelection(key);
131
+ if (e.shiftKey && manager.selectionMode === "multiple") manager.extendSelection(key);
132
+ else if (selectOnFocus && !(0, $feb5ffebff200149$export$d3e3bd3e26688c04)(e)) manager.replaceSelection(key);
93
133
  }
94
134
  };
95
135
  switch(e.key){
96
- case 'ArrowDown':
136
+ case "ArrowDown":
97
137
  if (delegate.getKeyBelow) {
98
- var ref4, ref1;
138
+ var _delegate_getFirstKey, _delegate_getFirstKey1;
99
139
  e.preventDefault();
100
- let nextKey = manager.focusedKey != null ? delegate.getKeyBelow(manager.focusedKey) : (ref4 = delegate.getFirstKey) === null || ref4 === void 0 ? void 0 : ref4.call(delegate);
101
- if (nextKey == null && shouldFocusWrap) nextKey = (ref1 = delegate.getFirstKey) === null || ref1 === void 0 ? void 0 : ref1.call(delegate, manager.focusedKey);
140
+ let nextKey = manager.focusedKey != null ? delegate.getKeyBelow(manager.focusedKey) : (_delegate_getFirstKey = delegate.getFirstKey) === null || _delegate_getFirstKey === void 0 ? void 0 : _delegate_getFirstKey.call(delegate);
141
+ if (nextKey == null && shouldFocusWrap) nextKey = (_delegate_getFirstKey1 = delegate.getFirstKey) === null || _delegate_getFirstKey1 === void 0 ? void 0 : _delegate_getFirstKey1.call(delegate, manager.focusedKey);
102
142
  navigateToKey(nextKey);
103
143
  }
104
144
  break;
105
- case 'ArrowUp':
145
+ case "ArrowUp":
106
146
  if (delegate.getKeyAbove) {
107
- var ref2, ref3;
147
+ var _delegate_getLastKey, _delegate_getLastKey1;
108
148
  e.preventDefault();
109
- let nextKey = manager.focusedKey != null ? delegate.getKeyAbove(manager.focusedKey) : (ref2 = delegate.getLastKey) === null || ref2 === void 0 ? void 0 : ref2.call(delegate);
110
- if (nextKey == null && shouldFocusWrap) nextKey = (ref3 = delegate.getLastKey) === null || ref3 === void 0 ? void 0 : ref3.call(delegate, manager.focusedKey);
111
- navigateToKey(nextKey);
149
+ let nextKey1 = manager.focusedKey != null ? delegate.getKeyAbove(manager.focusedKey) : (_delegate_getLastKey = delegate.getLastKey) === null || _delegate_getLastKey === void 0 ? void 0 : _delegate_getLastKey.call(delegate);
150
+ if (nextKey1 == null && shouldFocusWrap) nextKey1 = (_delegate_getLastKey1 = delegate.getLastKey) === null || _delegate_getLastKey1 === void 0 ? void 0 : _delegate_getLastKey1.call(delegate, manager.focusedKey);
151
+ navigateToKey(nextKey1);
112
152
  }
113
153
  break;
114
- case 'ArrowLeft':
154
+ case "ArrowLeft":
115
155
  if (delegate.getKeyLeftOf) {
116
156
  e.preventDefault();
117
- let nextKey = delegate.getKeyLeftOf(manager.focusedKey);
118
- navigateToKey(nextKey, direction === 'rtl' ? 'first' : 'last');
157
+ let nextKey2 = delegate.getKeyLeftOf(manager.focusedKey);
158
+ navigateToKey(nextKey2, direction === "rtl" ? "first" : "last");
119
159
  }
120
160
  break;
121
- case 'ArrowRight':
161
+ case "ArrowRight":
122
162
  if (delegate.getKeyRightOf) {
123
163
  e.preventDefault();
124
- let nextKey = delegate.getKeyRightOf(manager.focusedKey);
125
- navigateToKey(nextKey, direction === 'rtl' ? 'last' : 'first');
164
+ let nextKey3 = delegate.getKeyRightOf(manager.focusedKey);
165
+ navigateToKey(nextKey3, direction === "rtl" ? "last" : "first");
126
166
  }
127
167
  break;
128
- case 'Home':
168
+ case "Home":
129
169
  if (delegate.getFirstKey) {
130
170
  e.preventDefault();
131
- let firstKey = delegate.getFirstKey(manager.focusedKey, $feb5ffebff200149$export$16792effe837dba3(e));
171
+ let firstKey = delegate.getFirstKey(manager.focusedKey, (0, $feb5ffebff200149$export$16792effe837dba3)(e));
132
172
  manager.setFocusedKey(firstKey);
133
- if ($feb5ffebff200149$export$16792effe837dba3(e) && e.shiftKey && manager.selectionMode === 'multiple') manager.extendSelection(firstKey);
173
+ if ((0, $feb5ffebff200149$export$16792effe837dba3)(e) && e.shiftKey && manager.selectionMode === "multiple") manager.extendSelection(firstKey);
134
174
  else if (selectOnFocus) manager.replaceSelection(firstKey);
135
175
  }
136
176
  break;
137
- case 'End':
177
+ case "End":
138
178
  if (delegate.getLastKey) {
139
179
  e.preventDefault();
140
- let lastKey = delegate.getLastKey(manager.focusedKey, $feb5ffebff200149$export$16792effe837dba3(e));
180
+ let lastKey = delegate.getLastKey(manager.focusedKey, (0, $feb5ffebff200149$export$16792effe837dba3)(e));
141
181
  manager.setFocusedKey(lastKey);
142
- if ($feb5ffebff200149$export$16792effe837dba3(e) && e.shiftKey && manager.selectionMode === 'multiple') manager.extendSelection(lastKey);
182
+ if ((0, $feb5ffebff200149$export$16792effe837dba3)(e) && e.shiftKey && manager.selectionMode === "multiple") manager.extendSelection(lastKey);
143
183
  else if (selectOnFocus) manager.replaceSelection(lastKey);
144
184
  }
145
185
  break;
146
- case 'PageDown':
186
+ case "PageDown":
147
187
  if (delegate.getKeyPageBelow) {
148
188
  e.preventDefault();
149
- let nextKey = delegate.getKeyPageBelow(manager.focusedKey);
150
- navigateToKey(nextKey);
189
+ let nextKey4 = delegate.getKeyPageBelow(manager.focusedKey);
190
+ navigateToKey(nextKey4);
151
191
  }
152
192
  break;
153
- case 'PageUp':
193
+ case "PageUp":
154
194
  if (delegate.getKeyPageAbove) {
155
195
  e.preventDefault();
156
- let nextKey = delegate.getKeyPageAbove(manager.focusedKey);
157
- navigateToKey(nextKey);
196
+ let nextKey5 = delegate.getKeyPageAbove(manager.focusedKey);
197
+ navigateToKey(nextKey5);
158
198
  }
159
199
  break;
160
- case 'a':
161
- if ($feb5ffebff200149$export$16792effe837dba3(e) && manager.selectionMode === 'multiple' && disallowSelectAll !== true) {
200
+ case "a":
201
+ if ((0, $feb5ffebff200149$export$16792effe837dba3)(e) && manager.selectionMode === "multiple" && disallowSelectAll !== true) {
162
202
  e.preventDefault();
163
203
  manager.selectAll();
164
204
  }
165
205
  break;
166
- case 'Escape':
206
+ case "Escape":
167
207
  e.preventDefault();
168
208
  if (!disallowEmptySelection) manager.clearSelection();
169
209
  break;
170
- case 'Tab':
210
+ case "Tab":
171
211
  if (!allowsTabNavigation) {
172
212
  // There may be elements that are "tabbable" inside a collection (e.g. in a grid cell).
173
213
  // However, collections should be treated as a single tab stop, with arrow key navigation internally.
@@ -177,7 +217,7 @@ function $ae20dd8cbca75726$export$d6daf82dcd84e87c(options) {
177
217
  // rather than the currently focused one.
178
218
  if (e.shiftKey) ref.current.focus();
179
219
  else {
180
- let walker = $eCAIO$getFocusableTreeWalker(ref.current, {
220
+ let walker = (0, $eCAIO$getFocusableTreeWalker)(ref.current, {
181
221
  tabbable: true
182
222
  });
183
223
  let next;
@@ -185,19 +225,19 @@ function $ae20dd8cbca75726$export$d6daf82dcd84e87c(options) {
185
225
  do {
186
226
  last = walker.lastChild();
187
227
  if (last) next = last;
188
- }while (last)
189
- if (next && !next.contains(document.activeElement)) $eCAIO$focusWithoutScrolling(next);
228
+ }while (last);
229
+ if (next && !next.contains(document.activeElement)) (0, $eCAIO$focusWithoutScrolling)(next);
190
230
  }
191
231
  break;
192
232
  }
193
233
  }
194
234
  };
195
235
  // Store the scroll position so we can restore it later.
196
- let scrollPos = $eCAIO$useRef({
236
+ let scrollPos = (0, $eCAIO$useRef)({
197
237
  top: 0,
198
238
  left: 0
199
239
  });
200
- $eCAIO$useEvent(scrollRef, 'scroll', isVirtualized ? null : ()=>{
240
+ (0, $eCAIO$useEvent)(scrollRef, "scroll", isVirtualized ? null : ()=>{
201
241
  scrollPos.current = {
202
242
  top: scrollRef.current.scrollTop,
203
243
  left: scrollRef.current.scrollLeft
@@ -223,9 +263,9 @@ function $ae20dd8cbca75726$export$d6daf82dcd84e87c(options) {
223
263
  // Attempt to detect whether the user is tabbing forward or backward into the collection
224
264
  // and either focus the first or last item accordingly.
225
265
  let relatedTarget = e.relatedTarget;
226
- var _lastSelectedKey, _firstSelectedKey;
227
- if (relatedTarget && e.currentTarget.compareDocumentPosition(relatedTarget) & Node.DOCUMENT_POSITION_FOLLOWING) navigateToFirstKey((_lastSelectedKey = manager.lastSelectedKey) !== null && _lastSelectedKey !== void 0 ? _lastSelectedKey : delegate.getLastKey());
228
- else navigateToFirstKey((_firstSelectedKey = manager.firstSelectedKey) !== null && _firstSelectedKey !== void 0 ? _firstSelectedKey : delegate.getFirstKey());
266
+ var _manager_lastSelectedKey, _manager_firstSelectedKey;
267
+ if (relatedTarget && e.currentTarget.compareDocumentPosition(relatedTarget) & Node.DOCUMENT_POSITION_FOLLOWING) navigateToFirstKey((_manager_lastSelectedKey = manager.lastSelectedKey) !== null && _manager_lastSelectedKey !== void 0 ? _manager_lastSelectedKey : delegate.getLastKey());
268
+ else navigateToFirstKey((_manager_firstSelectedKey = manager.firstSelectedKey) !== null && _manager_firstSelectedKey !== void 0 ? _manager_firstSelectedKey : delegate.getFirstKey());
229
269
  } else if (!isVirtualized) {
230
270
  // Restore the scroll position to what it was before.
231
271
  scrollRef.current.scrollTop = scrollPos.current.top;
@@ -234,8 +274,8 @@ function $ae20dd8cbca75726$export$d6daf82dcd84e87c(options) {
234
274
  let element = scrollRef.current.querySelector(`[data-key="${manager.focusedKey}"]`);
235
275
  if (element) {
236
276
  // This prevents a flash of focus on the first/last element in the collection
237
- $eCAIO$focusWithoutScrolling(element);
238
- $eCAIO$scrollIntoView(scrollRef.current, element);
277
+ (0, $eCAIO$focusWithoutScrolling)(element);
278
+ (0, $eCAIO$scrollIntoView)(scrollRef.current, element);
239
279
  }
240
280
  }
241
281
  };
@@ -243,35 +283,41 @@ function $ae20dd8cbca75726$export$d6daf82dcd84e87c(options) {
243
283
  // Don't set blurred and then focused again if moving focus within the collection.
244
284
  if (!e.currentTarget.contains(e.relatedTarget)) manager.setFocused(false);
245
285
  };
246
- const autoFocusRef = $eCAIO$useRef(autoFocus);
247
- $eCAIO$useEffect(()=>{
286
+ const autoFocusRef = (0, $eCAIO$useRef)(autoFocus);
287
+ (0, $eCAIO$useEffect)(()=>{
248
288
  if (autoFocusRef.current) {
249
289
  let focusedKey = null;
250
290
  // Check focus strategy to determine which item to focus
251
- if (autoFocus === 'first') focusedKey = delegate.getFirstKey();
252
- if (autoFocus === 'last') focusedKey = delegate.getLastKey();
291
+ if (autoFocus === "first") focusedKey = delegate.getFirstKey();
292
+ if (autoFocus === "last") focusedKey = delegate.getLastKey();
253
293
  // If there are any selected keys, make the first one the new focus target
254
294
  let selectedKeys = manager.selectedKeys;
255
295
  if (selectedKeys.size) focusedKey = selectedKeys.values().next().value;
256
296
  manager.setFocused(true);
257
297
  manager.setFocusedKey(focusedKey);
258
298
  // If no default focus key is selected, focus the collection itself.
259
- if (focusedKey == null && !shouldUseVirtualFocus) $eCAIO$focusSafely(ref.current);
299
+ if (focusedKey == null && !shouldUseVirtualFocus) (0, $eCAIO$focusSafely)(ref.current);
260
300
  }
261
301
  autoFocusRef.current = false;
262
302
  // eslint-disable-next-line react-hooks/exhaustive-deps
263
303
  }, []);
264
304
  // If not virtualized, scroll the focused element into view when the focusedKey changes.
265
305
  // When virtualized, Virtualizer handles this internally.
266
- $eCAIO$useEffect(()=>{
306
+ (0, $eCAIO$useEffect)(()=>{
267
307
  if (!isVirtualized && manager.focusedKey && (scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current)) {
268
308
  let element = scrollRef.current.querySelector(`[data-key="${manager.focusedKey}"]`);
269
- if (element) $eCAIO$scrollIntoView(scrollRef.current, element);
309
+ if (element) {
310
+ (0, $eCAIO$scrollIntoView)(scrollRef.current, element);
311
+ (0, $eCAIO$scrollIntoViewport)(element, {
312
+ containingElement: ref.current
313
+ });
314
+ }
270
315
  }
271
316
  }, [
272
317
  isVirtualized,
273
318
  scrollRef,
274
- manager.focusedKey
319
+ manager.focusedKey,
320
+ ref
275
321
  ]);
276
322
  let handlers = {
277
323
  onKeyDown: onKeyDown,
@@ -283,11 +329,11 @@ function $ae20dd8cbca75726$export$d6daf82dcd84e87c(options) {
283
329
  e.preventDefault();
284
330
  }
285
331
  };
286
- let { typeSelectProps: typeSelectProps } = $fb3050f43d946246$export$e32c88dfddc6e1d8({
332
+ let { typeSelectProps: typeSelectProps } = (0, $fb3050f43d946246$export$e32c88dfddc6e1d8)({
287
333
  keyboardDelegate: delegate,
288
334
  selectionManager: manager
289
335
  });
290
- if (!disallowTypeAhead) handlers = $eCAIO$mergeProps(typeSelectProps, handlers);
336
+ if (!disallowTypeAhead) handlers = (0, $eCAIO$mergeProps)(typeSelectProps, handlers);
291
337
  // If nothing is focused within the collection, make the collection itself tabbable.
292
338
  // This will be marshalled to either the first or last item depending on where focus came from.
293
339
  // If using virtual focus, don't set a tabIndex at all so that VoiceOver on iOS 14 doesn't try
@@ -303,7 +349,17 @@ function $ae20dd8cbca75726$export$d6daf82dcd84e87c(options) {
303
349
  }
304
350
 
305
351
 
306
-
352
+ /*
353
+ * Copyright 2020 Adobe. All rights reserved.
354
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
355
+ * you may not use this file except in compliance with the License. You may obtain a copy
356
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
357
+ *
358
+ * Unless required by applicable law or agreed to in writing, software distributed under
359
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
360
+ * OF ANY KIND, either express or implied. See the License for the specific language
361
+ * governing permissions and limitations under the License.
362
+ */
307
363
 
308
364
 
309
365
 
@@ -311,24 +367,24 @@ function $ae20dd8cbca75726$export$d6daf82dcd84e87c(options) {
311
367
  function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
312
368
  let { selectionManager: manager , key: key , ref: ref , shouldSelectOnPressUp: shouldSelectOnPressUp , isVirtualized: isVirtualized , shouldUseVirtualFocus: shouldUseVirtualFocus , focus: focus , isDisabled: isDisabled , onAction: onAction , allowsDifferentPressOrigin: allowsDifferentPressOrigin } = options;
313
369
  let onSelect = (e)=>{
314
- if (e.pointerType === 'keyboard' && $feb5ffebff200149$export$d3e3bd3e26688c04(e)) manager.toggleSelection(key);
370
+ if (e.pointerType === "keyboard" && (0, $feb5ffebff200149$export$d3e3bd3e26688c04)(e)) manager.toggleSelection(key);
315
371
  else {
316
- if (manager.selectionMode === 'none') return;
317
- if (manager.selectionMode === 'single') {
372
+ if (manager.selectionMode === "none") return;
373
+ if (manager.selectionMode === "single") {
318
374
  if (manager.isSelected(key) && !manager.disallowEmptySelection) manager.toggleSelection(key);
319
375
  else manager.replaceSelection(key);
320
376
  } else if (e && e.shiftKey) manager.extendSelection(key);
321
- else if (manager.selectionBehavior === 'toggle' || e && ($feb5ffebff200149$export$16792effe837dba3(e) || e.pointerType === 'touch' || e.pointerType === 'virtual')) // if touch or virtual (VO) then we just want to toggle, otherwise it's impossible to multi select because they don't have modifier keys
377
+ else if (manager.selectionBehavior === "toggle" || e && ((0, $feb5ffebff200149$export$16792effe837dba3)(e) || e.pointerType === "touch" || e.pointerType === "virtual")) // if touch or virtual (VO) then we just want to toggle, otherwise it's impossible to multi select because they don't have modifier keys
322
378
  manager.toggleSelection(key);
323
379
  else manager.replaceSelection(key);
324
380
  }
325
381
  };
326
382
  // Focus the associated DOM node when this item becomes the focusedKey
327
- $eCAIO$useEffect(()=>{
383
+ (0, $eCAIO$useEffect)(()=>{
328
384
  let isFocused = key === manager.focusedKey;
329
385
  if (isFocused && manager.isFocused && !shouldUseVirtualFocus && document.activeElement !== ref.current) {
330
386
  if (focus) focus();
331
- else $eCAIO$focusSafely(ref.current);
387
+ else (0, $eCAIO$focusSafely)(ref.current);
332
388
  }
333
389
  // eslint-disable-next-line react-hooks/exhaustive-deps
334
390
  }, [
@@ -343,8 +399,7 @@ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
343
399
  // Set tabIndex to 0 if the element is focused, or -1 otherwise so that only the last focused
344
400
  // item is tabbable. If using virtual focus, don't set a tabIndex at all so that VoiceOver
345
401
  // on iOS 14 doesn't try to move real DOM focus to the item anyway.
346
- let itemProps = {
347
- };
402
+ let itemProps = {};
348
403
  if (!shouldUseVirtualFocus && !isDisabled) itemProps = {
349
404
  tabIndex: key === manager.focusedKey ? 0 : -1,
350
405
  onFocus (e) {
@@ -361,13 +416,13 @@ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
361
416
  // With touch, onAction occurs on single tap, and long press enters selection mode.
362
417
  let allowsSelection = !isDisabled && manager.canSelectItem(key);
363
418
  let allowsActions = onAction && !isDisabled;
364
- let hasPrimaryAction = allowsActions && (manager.selectionBehavior === 'replace' ? !allowsSelection : manager.isEmpty);
365
- let hasSecondaryAction = allowsActions && allowsSelection && manager.selectionBehavior === 'replace';
419
+ let hasPrimaryAction = allowsActions && (manager.selectionBehavior === "replace" ? !allowsSelection : manager.isEmpty);
420
+ let hasSecondaryAction = allowsActions && allowsSelection && manager.selectionBehavior === "replace";
366
421
  let hasAction = hasPrimaryAction || hasSecondaryAction;
367
- let modality = $eCAIO$useRef(null);
422
+ let modality = (0, $eCAIO$useRef)(null);
368
423
  let longPressEnabled = hasAction && allowsSelection;
369
- let longPressEnabledOnPressStart = $eCAIO$useRef(false);
370
- let hadPrimaryActionOnPressStart = $eCAIO$useRef(false);
424
+ let longPressEnabledOnPressStart = (0, $eCAIO$useRef)(false);
425
+ let hadPrimaryActionOnPressStart = (0, $eCAIO$useRef)(false);
371
426
  // By default, selection occurs on pointer down. This can be strange if selecting an
372
427
  // item causes the UI to disappear immediately (e.g. menus).
373
428
  // If shouldSelectOnPressUp is true, we use onPressUp instead of onPressStart.
@@ -375,28 +430,26 @@ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
375
430
  // we want to be able to have the pointer down on the trigger that opens the menu and
376
431
  // the pointer up on the menu item rather than requiring a separate press.
377
432
  // For keyboard events, selection still occurs on key down.
378
- let itemPressProps = {
379
- };
433
+ let itemPressProps = {};
380
434
  if (shouldSelectOnPressUp) {
381
435
  itemPressProps.onPressStart = (e)=>{
382
436
  modality.current = e.pointerType;
383
437
  longPressEnabledOnPressStart.current = longPressEnabled;
384
- if (e.pointerType === 'keyboard' && (!hasAction || $880e95eb8b93ba9a$var$isSelectionKey())) onSelect(e);
438
+ if (e.pointerType === "keyboard" && (!hasAction || $880e95eb8b93ba9a$var$isSelectionKey())) onSelect(e);
385
439
  };
386
440
  // If allowsDifferentPressOrigin, make selection happen on pressUp (e.g. open menu on press down, selection on menu item happens on press up.)
387
441
  // Otherwise, have selection happen onPress (prevents listview row selection when clicking on interactable elements in the row)
388
442
  if (!allowsDifferentPressOrigin) itemPressProps.onPress = (e)=>{
389
- if (hasPrimaryAction || hasSecondaryAction && e.pointerType !== 'mouse') {
390
- if (e.pointerType === 'keyboard' && !$880e95eb8b93ba9a$var$isActionKey()) return;
443
+ if (hasPrimaryAction || hasSecondaryAction && e.pointerType !== "mouse") {
444
+ if (e.pointerType === "keyboard" && !$880e95eb8b93ba9a$var$isActionKey()) return;
391
445
  onAction();
392
- } else if (e.pointerType !== 'keyboard') onSelect(e);
446
+ } else if (e.pointerType !== "keyboard") onSelect(e);
393
447
  };
394
448
  else {
395
449
  itemPressProps.onPressUp = (e)=>{
396
- if (e.pointerType !== 'keyboard') onSelect(e);
450
+ if (e.pointerType !== "keyboard") onSelect(e);
397
451
  };
398
- itemPressProps.onPress = hasPrimaryAction ? ()=>onAction()
399
- : null;
452
+ itemPressProps.onPress = hasPrimaryAction ? ()=>onAction() : null;
400
453
  }
401
454
  } else {
402
455
  itemPressProps.onPressStart = (e)=>{
@@ -406,24 +459,24 @@ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
406
459
  // Select on mouse down unless there is a primary action which will occur on mouse up.
407
460
  // For keyboard, select on key down. If there is an action, the Space key selects on key down,
408
461
  // and the Enter key performs onAction on key up.
409
- if (e.pointerType === 'mouse' && !hasPrimaryAction || e.pointerType === 'keyboard' && (!onAction || $880e95eb8b93ba9a$var$isSelectionKey())) onSelect(e);
462
+ if (e.pointerType === "mouse" && !hasPrimaryAction || e.pointerType === "keyboard" && (!onAction || $880e95eb8b93ba9a$var$isSelectionKey())) onSelect(e);
410
463
  };
411
464
  itemPressProps.onPress = (e)=>{
412
465
  // Selection occurs on touch up. Primary actions always occur on pointer up.
413
466
  // Both primary and secondary actions occur on Enter key up. The only exception
414
467
  // is secondary actions, which occur on double click with a mouse.
415
- if (e.pointerType === 'touch' || e.pointerType === 'pen' || e.pointerType === 'virtual' || e.pointerType === 'keyboard' && hasAction && $880e95eb8b93ba9a$var$isActionKey() || e.pointerType === 'mouse' && hadPrimaryActionOnPressStart.current) {
468
+ if (e.pointerType === "touch" || e.pointerType === "pen" || e.pointerType === "virtual" || e.pointerType === "keyboard" && hasAction && $880e95eb8b93ba9a$var$isActionKey() || e.pointerType === "mouse" && hadPrimaryActionOnPressStart.current) {
416
469
  if (hasAction) onAction();
417
470
  else onSelect(e);
418
471
  }
419
472
  };
420
473
  }
421
- if (!isVirtualized) itemProps['data-key'] = key;
474
+ if (!isVirtualized) itemProps["data-key"] = key;
422
475
  itemPressProps.preventFocusOnPress = shouldUseVirtualFocus;
423
- let { pressProps: pressProps , isPressed: isPressed } = $eCAIO$usePress(itemPressProps);
476
+ let { pressProps: pressProps , isPressed: isPressed } = (0, $eCAIO$usePress)(itemPressProps);
424
477
  // Double clicking with a mouse with selectionBehavior = 'replace' performs an action.
425
478
  let onDoubleClick = hasSecondaryAction ? (e)=>{
426
- if (modality.current === 'mouse') {
479
+ if (modality.current === "mouse") {
427
480
  e.stopPropagation();
428
481
  e.preventDefault();
429
482
  onAction();
@@ -432,12 +485,12 @@ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
432
485
  // Long pressing an item with touch when selectionBehavior = 'replace' switches the selection behavior
433
486
  // to 'toggle'. This changes the single tap behavior from performing an action (i.e. navigating) to
434
487
  // selecting, and may toggle the appearance of a UI affordance like checkboxes on each item.
435
- let { longPressProps: longPressProps } = $eCAIO$useLongPress({
488
+ let { longPressProps: longPressProps } = (0, $eCAIO$useLongPress)({
436
489
  isDisabled: !longPressEnabled,
437
490
  onLongPress (e) {
438
- if (e.pointerType === 'touch') {
491
+ if (e.pointerType === "touch") {
439
492
  onSelect(e);
440
- manager.setSelectionBehavior('toggle');
493
+ manager.setSelectionBehavior("toggle");
441
494
  }
442
495
  }
443
496
  });
@@ -446,12 +499,10 @@ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
446
499
  // Use a capturing listener to ensure this runs before useDrag, regardless of
447
500
  // the order the props get merged.
448
501
  let onDragStartCapture = (e)=>{
449
- if (modality.current === 'touch' && longPressEnabledOnPressStart.current) e.preventDefault();
502
+ if (modality.current === "touch" && longPressEnabledOnPressStart.current) e.preventDefault();
450
503
  };
451
504
  return {
452
- itemProps: $eCAIO$mergeProps(itemProps, allowsSelection || hasPrimaryAction ? pressProps : {
453
- }, longPressEnabled ? longPressProps : {
454
- }, {
505
+ itemProps: (0, $eCAIO$mergeProps)(itemProps, allowsSelection || hasPrimaryAction ? pressProps : {}, longPressEnabled ? longPressProps : {}, {
455
506
  onDoubleClick: onDoubleClick,
456
507
  onDragStartCapture: onDragStartCapture
457
508
  }),
@@ -464,21 +515,41 @@ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
464
515
  }
465
516
  function $880e95eb8b93ba9a$var$isActionKey() {
466
517
  let event = window.event;
467
- return (event === null || event === void 0 ? void 0 : event.key) === 'Enter';
518
+ return (event === null || event === void 0 ? void 0 : event.key) === "Enter";
468
519
  }
469
520
  function $880e95eb8b93ba9a$var$isSelectionKey() {
470
521
  let event = window.event;
471
- return (event === null || event === void 0 ? void 0 : event.key) === ' ' || (event === null || event === void 0 ? void 0 : event.code) === 'Space';
522
+ return (event === null || event === void 0 ? void 0 : event.key) === " " || (event === null || event === void 0 ? void 0 : event.code) === "Space";
472
523
  }
473
524
 
474
525
 
475
-
476
- class $2a25aae57d74318e$export$a05409b8bb224a5a {
526
+ /*
527
+ * Copyright 2020 Adobe. All rights reserved.
528
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
529
+ * you may not use this file except in compliance with the License. You may obtain a copy
530
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
531
+ *
532
+ * Unless required by applicable law or agreed to in writing, software distributed under
533
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
534
+ * OF ANY KIND, either express or implied. See the License for the specific language
535
+ * governing permissions and limitations under the License.
536
+ */
537
+ /*
538
+ * Copyright 2020 Adobe. All rights reserved.
539
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
540
+ * you may not use this file except in compliance with the License. You may obtain a copy
541
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
542
+ *
543
+ * Unless required by applicable law or agreed to in writing, software distributed under
544
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
545
+ * OF ANY KIND, either express or implied. See the License for the specific language
546
+ * governing permissions and limitations under the License.
547
+ */ class $2a25aae57d74318e$export$a05409b8bb224a5a {
477
548
  getKeyBelow(key) {
478
549
  key = this.collection.getKeyAfter(key);
479
550
  while(key != null){
480
551
  let item = this.collection.getItem(key);
481
- if (item.type === 'item' && !this.disabledKeys.has(key)) return key;
552
+ if (item.type === "item" && !this.disabledKeys.has(key)) return key;
482
553
  key = this.collection.getKeyAfter(key);
483
554
  }
484
555
  }
@@ -486,7 +557,7 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
486
557
  key = this.collection.getKeyBefore(key);
487
558
  while(key != null){
488
559
  let item = this.collection.getItem(key);
489
- if (item.type === 'item' && !this.disabledKeys.has(key)) return key;
560
+ if (item.type === "item" && !this.disabledKeys.has(key)) return key;
490
561
  key = this.collection.getKeyBefore(key);
491
562
  }
492
563
  }
@@ -494,7 +565,7 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
494
565
  let key = this.collection.getFirstKey();
495
566
  while(key != null){
496
567
  let item = this.collection.getItem(key);
497
- if (item.type === 'item' && !this.disabledKeys.has(key)) return key;
568
+ if (item.type === "item" && !this.disabledKeys.has(key)) return key;
498
569
  key = this.collection.getKeyAfter(key);
499
570
  }
500
571
  }
@@ -502,7 +573,7 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
502
573
  let key = this.collection.getLastKey();
503
574
  while(key != null){
504
575
  let item = this.collection.getItem(key);
505
- if (item.type === 'item' && !this.disabledKeys.has(key)) return key;
576
+ if (item.type === "item" && !this.disabledKeys.has(key)) return key;
506
577
  key = this.collection.getKeyBefore(key);
507
578
  }
508
579
  }
@@ -555,16 +626,15 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
555
626
 
556
627
 
557
628
  function $982254629710d113$export$b95089534ab7c1fd(props) {
558
- let { selectionManager: selectionManager , collection: collection , disabledKeys: disabledKeys , ref: ref , keyboardDelegate: keyboardDelegate , autoFocus: autoFocus , shouldFocusWrap: shouldFocusWrap , isVirtualized: isVirtualized , disallowEmptySelection: disallowEmptySelection , selectOnFocus: selectOnFocus = selectionManager.selectionBehavior === 'replace' , disallowTypeAhead: disallowTypeAhead , shouldUseVirtualFocus: shouldUseVirtualFocus , allowsTabNavigation: allowsTabNavigation } = props;
629
+ let { selectionManager: selectionManager , collection: collection , disabledKeys: disabledKeys , ref: ref , keyboardDelegate: keyboardDelegate , autoFocus: autoFocus , shouldFocusWrap: shouldFocusWrap , isVirtualized: isVirtualized , disallowEmptySelection: disallowEmptySelection , selectOnFocus: selectOnFocus = selectionManager.selectionBehavior === "replace" , disallowTypeAhead: disallowTypeAhead , shouldUseVirtualFocus: shouldUseVirtualFocus , allowsTabNavigation: allowsTabNavigation } = props;
559
630
  // By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).
560
631
  // When virtualized, the layout object will be passed in as a prop and override this.
561
- let collator = $eCAIO$useCollator({
562
- usage: 'search',
563
- sensitivity: 'base'
632
+ let collator = (0, $eCAIO$useCollator)({
633
+ usage: "search",
634
+ sensitivity: "base"
564
635
  });
565
636
  let disabledBehavior = selectionManager.disabledBehavior;
566
- let delegate = $eCAIO$useMemo(()=>keyboardDelegate || new $2a25aae57d74318e$export$a05409b8bb224a5a(collection, disabledBehavior === 'selection' ? new Set() : disabledKeys, ref, collator)
567
- , [
637
+ let delegate = (0, $eCAIO$useMemo)(()=>keyboardDelegate || new (0, $2a25aae57d74318e$export$a05409b8bb224a5a)(collection, disabledBehavior === "selection" ? new Set() : disabledKeys, ref, collator), [
568
638
  keyboardDelegate,
569
639
  collection,
570
640
  disabledKeys,
@@ -572,7 +642,7 @@ function $982254629710d113$export$b95089534ab7c1fd(props) {
572
642
  collator,
573
643
  disabledBehavior
574
644
  ]);
575
- let { collectionProps: collectionProps } = $ae20dd8cbca75726$export$d6daf82dcd84e87c({
645
+ let { collectionProps: collectionProps } = (0, $ae20dd8cbca75726$export$d6daf82dcd84e87c)({
576
646
  ref: ref,
577
647
  selectionManager: selectionManager,
578
648
  keyboardDelegate: delegate,