@react-aria/selection 3.11.0 → 3.12.1

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
@@ -4,31 +4,71 @@ import {focusWithoutScrolling as $eCAIO$focusWithoutScrolling, useEvent as $eCAI
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,30 +283,30 @@ 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) (0, $eCAIO$scrollIntoView)(scrollRef.current, element);
270
310
  }
271
311
  }, [
272
312
  isVirtualized,
@@ -279,15 +319,15 @@ function $ae20dd8cbca75726$export$d6daf82dcd84e87c(options) {
279
319
  onBlur: onBlur,
280
320
  onMouseDown (e) {
281
321
  // Ignore events that bubbled through portals.
282
- if (e.currentTarget.contains(e.target)) // Prevent focus going to the collection when clicking on the scrollbar.
322
+ if (scrollRef.current === e.target) // Prevent focus going to the collection when clicking on the scrollbar.
283
323
  e.preventDefault();
284
324
  }
285
325
  };
286
- let { typeSelectProps: typeSelectProps } = $fb3050f43d946246$export$e32c88dfddc6e1d8({
326
+ let { typeSelectProps: typeSelectProps } = (0, $fb3050f43d946246$export$e32c88dfddc6e1d8)({
287
327
  keyboardDelegate: delegate,
288
328
  selectionManager: manager
289
329
  });
290
- if (!disallowTypeAhead) handlers = $eCAIO$mergeProps(typeSelectProps, handlers);
330
+ if (!disallowTypeAhead) handlers = (0, $eCAIO$mergeProps)(typeSelectProps, handlers);
291
331
  // If nothing is focused within the collection, make the collection itself tabbable.
292
332
  // This will be marshalled to either the first or last item depending on where focus came from.
293
333
  // If using virtual focus, don't set a tabIndex at all so that VoiceOver on iOS 14 doesn't try
@@ -303,7 +343,17 @@ function $ae20dd8cbca75726$export$d6daf82dcd84e87c(options) {
303
343
  }
304
344
 
305
345
 
306
-
346
+ /*
347
+ * Copyright 2020 Adobe. All rights reserved.
348
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
349
+ * you may not use this file except in compliance with the License. You may obtain a copy
350
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
351
+ *
352
+ * Unless required by applicable law or agreed to in writing, software distributed under
353
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
354
+ * OF ANY KIND, either express or implied. See the License for the specific language
355
+ * governing permissions and limitations under the License.
356
+ */
307
357
 
308
358
 
309
359
 
@@ -311,25 +361,26 @@ function $ae20dd8cbca75726$export$d6daf82dcd84e87c(options) {
311
361
  function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
312
362
  let { selectionManager: manager , key: key , ref: ref , shouldSelectOnPressUp: shouldSelectOnPressUp , isVirtualized: isVirtualized , shouldUseVirtualFocus: shouldUseVirtualFocus , focus: focus , isDisabled: isDisabled , onAction: onAction , allowsDifferentPressOrigin: allowsDifferentPressOrigin } = options;
313
363
  let onSelect = (e)=>{
314
- if (e.pointerType === 'keyboard' && $feb5ffebff200149$export$d3e3bd3e26688c04(e)) manager.toggleSelection(key);
364
+ if (e.pointerType === "keyboard" && (0, $feb5ffebff200149$export$d3e3bd3e26688c04)(e)) manager.toggleSelection(key);
315
365
  else {
316
- if (manager.selectionMode === 'none') return;
317
- if (manager.selectionMode === 'single') {
366
+ if (manager.selectionMode === "none") return;
367
+ if (manager.selectionMode === "single") {
318
368
  if (manager.isSelected(key) && !manager.disallowEmptySelection) manager.toggleSelection(key);
319
369
  else manager.replaceSelection(key);
320
370
  } 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
371
+ 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
372
  manager.toggleSelection(key);
323
373
  else manager.replaceSelection(key);
324
374
  }
325
375
  };
326
376
  // Focus the associated DOM node when this item becomes the focusedKey
327
- $eCAIO$useEffect(()=>{
377
+ (0, $eCAIO$useEffect)(()=>{
328
378
  let isFocused = key === manager.focusedKey;
329
379
  if (isFocused && manager.isFocused && !shouldUseVirtualFocus && document.activeElement !== ref.current) {
330
380
  if (focus) focus();
331
- else $eCAIO$focusSafely(ref.current);
381
+ else (0, $eCAIO$focusSafely)(ref.current);
332
382
  }
383
+ // eslint-disable-next-line react-hooks/exhaustive-deps
333
384
  }, [
334
385
  ref,
335
386
  key,
@@ -338,31 +389,34 @@ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
338
389
  manager.isFocused,
339
390
  shouldUseVirtualFocus
340
391
  ]);
392
+ isDisabled = isDisabled || manager.isDisabled(key);
341
393
  // Set tabIndex to 0 if the element is focused, or -1 otherwise so that only the last focused
342
394
  // item is tabbable. If using virtual focus, don't set a tabIndex at all so that VoiceOver
343
395
  // on iOS 14 doesn't try to move real DOM focus to the item anyway.
344
- let itemProps = {
345
- };
346
- if (!shouldUseVirtualFocus) itemProps = {
396
+ let itemProps = {};
397
+ if (!shouldUseVirtualFocus && !isDisabled) itemProps = {
347
398
  tabIndex: key === manager.focusedKey ? 0 : -1,
348
399
  onFocus (e) {
349
400
  if (e.target === ref.current) manager.setFocusedKey(key);
350
401
  }
351
402
  };
403
+ else if (isDisabled) itemProps.onMouseDown = (e)=>{
404
+ // Prevent focus going to the body when clicking on a disabled item.
405
+ e.preventDefault();
406
+ };
352
407
  // With checkbox selection, onAction (i.e. navigation) becomes primary, and occurs on a single click of the row.
353
408
  // Clicking the checkbox enters selection mode, after which clicking anywhere on any row toggles selection for that row.
354
409
  // With highlight selection, onAction is secondary, and occurs on double click. Single click selects the row.
355
410
  // With touch, onAction occurs on single tap, and long press enters selection mode.
356
- isDisabled = isDisabled || manager.isDisabled(key);
357
411
  let allowsSelection = !isDisabled && manager.canSelectItem(key);
358
412
  let allowsActions = onAction && !isDisabled;
359
- let hasPrimaryAction = allowsActions && (manager.selectionBehavior === 'replace' ? !allowsSelection : manager.isEmpty);
360
- let hasSecondaryAction = allowsActions && allowsSelection && manager.selectionBehavior === 'replace';
413
+ let hasPrimaryAction = allowsActions && (manager.selectionBehavior === "replace" ? !allowsSelection : manager.isEmpty);
414
+ let hasSecondaryAction = allowsActions && allowsSelection && manager.selectionBehavior === "replace";
361
415
  let hasAction = hasPrimaryAction || hasSecondaryAction;
362
- let modality = $eCAIO$useRef(null);
416
+ let modality = (0, $eCAIO$useRef)(null);
363
417
  let longPressEnabled = hasAction && allowsSelection;
364
- let longPressEnabledOnPressStart = $eCAIO$useRef(false);
365
- let hadPrimaryActionOnPressStart = $eCAIO$useRef(false);
418
+ let longPressEnabledOnPressStart = (0, $eCAIO$useRef)(false);
419
+ let hadPrimaryActionOnPressStart = (0, $eCAIO$useRef)(false);
366
420
  // By default, selection occurs on pointer down. This can be strange if selecting an
367
421
  // item causes the UI to disappear immediately (e.g. menus).
368
422
  // If shouldSelectOnPressUp is true, we use onPressUp instead of onPressStart.
@@ -370,28 +424,26 @@ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
370
424
  // we want to be able to have the pointer down on the trigger that opens the menu and
371
425
  // the pointer up on the menu item rather than requiring a separate press.
372
426
  // For keyboard events, selection still occurs on key down.
373
- let itemPressProps = {
374
- };
427
+ let itemPressProps = {};
375
428
  if (shouldSelectOnPressUp) {
376
429
  itemPressProps.onPressStart = (e)=>{
377
430
  modality.current = e.pointerType;
378
431
  longPressEnabledOnPressStart.current = longPressEnabled;
379
- if (e.pointerType === 'keyboard' && (!hasAction || $880e95eb8b93ba9a$var$isSelectionKey())) onSelect(e);
432
+ if (e.pointerType === "keyboard" && (!hasAction || $880e95eb8b93ba9a$var$isSelectionKey())) onSelect(e);
380
433
  };
381
434
  // If allowsDifferentPressOrigin, make selection happen on pressUp (e.g. open menu on press down, selection on menu item happens on press up.)
382
435
  // Otherwise, have selection happen onPress (prevents listview row selection when clicking on interactable elements in the row)
383
436
  if (!allowsDifferentPressOrigin) itemPressProps.onPress = (e)=>{
384
- if (hasPrimaryAction || hasSecondaryAction && e.pointerType !== 'mouse') {
385
- if (e.pointerType === 'keyboard' && !$880e95eb8b93ba9a$var$isActionKey()) return;
437
+ if (hasPrimaryAction || hasSecondaryAction && e.pointerType !== "mouse") {
438
+ if (e.pointerType === "keyboard" && !$880e95eb8b93ba9a$var$isActionKey()) return;
386
439
  onAction();
387
- } else if (e.pointerType !== 'keyboard') onSelect(e);
440
+ } else if (e.pointerType !== "keyboard") onSelect(e);
388
441
  };
389
442
  else {
390
443
  itemPressProps.onPressUp = (e)=>{
391
- if (e.pointerType !== 'keyboard') onSelect(e);
444
+ if (e.pointerType !== "keyboard") onSelect(e);
392
445
  };
393
- itemPressProps.onPress = hasPrimaryAction ? ()=>onAction()
394
- : null;
446
+ itemPressProps.onPress = hasPrimaryAction ? ()=>onAction() : null;
395
447
  }
396
448
  } else {
397
449
  itemPressProps.onPressStart = (e)=>{
@@ -401,24 +453,24 @@ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
401
453
  // Select on mouse down unless there is a primary action which will occur on mouse up.
402
454
  // For keyboard, select on key down. If there is an action, the Space key selects on key down,
403
455
  // and the Enter key performs onAction on key up.
404
- if (e.pointerType === 'mouse' && !hasPrimaryAction || e.pointerType === 'keyboard' && (!onAction || $880e95eb8b93ba9a$var$isSelectionKey())) onSelect(e);
456
+ if (e.pointerType === "mouse" && !hasPrimaryAction || e.pointerType === "keyboard" && (!onAction || $880e95eb8b93ba9a$var$isSelectionKey())) onSelect(e);
405
457
  };
406
458
  itemPressProps.onPress = (e)=>{
407
459
  // Selection occurs on touch up. Primary actions always occur on pointer up.
408
460
  // Both primary and secondary actions occur on Enter key up. The only exception
409
461
  // is secondary actions, which occur on double click with a mouse.
410
- if (e.pointerType === 'touch' || e.pointerType === 'pen' || e.pointerType === 'virtual' || e.pointerType === 'keyboard' && hasAction && $880e95eb8b93ba9a$var$isActionKey() || e.pointerType === 'mouse' && hadPrimaryActionOnPressStart.current) {
462
+ if (e.pointerType === "touch" || e.pointerType === "pen" || e.pointerType === "virtual" || e.pointerType === "keyboard" && hasAction && $880e95eb8b93ba9a$var$isActionKey() || e.pointerType === "mouse" && hadPrimaryActionOnPressStart.current) {
411
463
  if (hasAction) onAction();
412
464
  else onSelect(e);
413
465
  }
414
466
  };
415
467
  }
416
- if (!isVirtualized) itemProps['data-key'] = key;
468
+ if (!isVirtualized) itemProps["data-key"] = key;
417
469
  itemPressProps.preventFocusOnPress = shouldUseVirtualFocus;
418
- let { pressProps: pressProps , isPressed: isPressed } = $eCAIO$usePress(itemPressProps);
470
+ let { pressProps: pressProps , isPressed: isPressed } = (0, $eCAIO$usePress)(itemPressProps);
419
471
  // Double clicking with a mouse with selectionBehavior = 'replace' performs an action.
420
472
  let onDoubleClick = hasSecondaryAction ? (e)=>{
421
- if (modality.current === 'mouse') {
473
+ if (modality.current === "mouse") {
422
474
  e.stopPropagation();
423
475
  e.preventDefault();
424
476
  onAction();
@@ -427,12 +479,12 @@ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
427
479
  // Long pressing an item with touch when selectionBehavior = 'replace' switches the selection behavior
428
480
  // to 'toggle'. This changes the single tap behavior from performing an action (i.e. navigating) to
429
481
  // selecting, and may toggle the appearance of a UI affordance like checkboxes on each item.
430
- let { longPressProps: longPressProps } = $eCAIO$useLongPress({
482
+ let { longPressProps: longPressProps } = (0, $eCAIO$useLongPress)({
431
483
  isDisabled: !longPressEnabled,
432
484
  onLongPress (e) {
433
- if (e.pointerType === 'touch') {
485
+ if (e.pointerType === "touch") {
434
486
  onSelect(e);
435
- manager.setSelectionBehavior('toggle');
487
+ manager.setSelectionBehavior("toggle");
436
488
  }
437
489
  }
438
490
  });
@@ -441,12 +493,10 @@ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
441
493
  // Use a capturing listener to ensure this runs before useDrag, regardless of
442
494
  // the order the props get merged.
443
495
  let onDragStartCapture = (e)=>{
444
- if (modality.current === 'touch' && longPressEnabledOnPressStart.current) e.preventDefault();
496
+ if (modality.current === "touch" && longPressEnabledOnPressStart.current) e.preventDefault();
445
497
  };
446
498
  return {
447
- itemProps: $eCAIO$mergeProps(itemProps, allowsSelection || hasPrimaryAction ? pressProps : {
448
- }, longPressEnabled ? longPressProps : {
449
- }, {
499
+ itemProps: (0, $eCAIO$mergeProps)(itemProps, allowsSelection || hasPrimaryAction ? pressProps : {}, longPressEnabled ? longPressProps : {}, {
450
500
  onDoubleClick: onDoubleClick,
451
501
  onDragStartCapture: onDragStartCapture
452
502
  }),
@@ -459,21 +509,41 @@ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
459
509
  }
460
510
  function $880e95eb8b93ba9a$var$isActionKey() {
461
511
  let event = window.event;
462
- return (event === null || event === void 0 ? void 0 : event.key) === 'Enter';
512
+ return (event === null || event === void 0 ? void 0 : event.key) === "Enter";
463
513
  }
464
514
  function $880e95eb8b93ba9a$var$isSelectionKey() {
465
515
  let event = window.event;
466
- return (event === null || event === void 0 ? void 0 : event.key) === ' ' || (event === null || event === void 0 ? void 0 : event.code) === 'Space';
516
+ return (event === null || event === void 0 ? void 0 : event.key) === " " || (event === null || event === void 0 ? void 0 : event.code) === "Space";
467
517
  }
468
518
 
469
519
 
470
-
471
- class $2a25aae57d74318e$export$a05409b8bb224a5a {
520
+ /*
521
+ * Copyright 2020 Adobe. All rights reserved.
522
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
523
+ * you may not use this file except in compliance with the License. You may obtain a copy
524
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
525
+ *
526
+ * Unless required by applicable law or agreed to in writing, software distributed under
527
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
528
+ * OF ANY KIND, either express or implied. See the License for the specific language
529
+ * governing permissions and limitations under the License.
530
+ */
531
+ /*
532
+ * Copyright 2020 Adobe. All rights reserved.
533
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
534
+ * you may not use this file except in compliance with the License. You may obtain a copy
535
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
536
+ *
537
+ * Unless required by applicable law or agreed to in writing, software distributed under
538
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
539
+ * OF ANY KIND, either express or implied. See the License for the specific language
540
+ * governing permissions and limitations under the License.
541
+ */ class $2a25aae57d74318e$export$a05409b8bb224a5a {
472
542
  getKeyBelow(key) {
473
543
  key = this.collection.getKeyAfter(key);
474
544
  while(key != null){
475
545
  let item = this.collection.getItem(key);
476
- if (item.type === 'item' && !this.disabledKeys.has(key)) return key;
546
+ if (item.type === "item" && !this.disabledKeys.has(key)) return key;
477
547
  key = this.collection.getKeyAfter(key);
478
548
  }
479
549
  }
@@ -481,7 +551,7 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
481
551
  key = this.collection.getKeyBefore(key);
482
552
  while(key != null){
483
553
  let item = this.collection.getItem(key);
484
- if (item.type === 'item' && !this.disabledKeys.has(key)) return key;
554
+ if (item.type === "item" && !this.disabledKeys.has(key)) return key;
485
555
  key = this.collection.getKeyBefore(key);
486
556
  }
487
557
  }
@@ -489,7 +559,7 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
489
559
  let key = this.collection.getFirstKey();
490
560
  while(key != null){
491
561
  let item = this.collection.getItem(key);
492
- if (item.type === 'item' && !this.disabledKeys.has(key)) return key;
562
+ if (item.type === "item" && !this.disabledKeys.has(key)) return key;
493
563
  key = this.collection.getKeyAfter(key);
494
564
  }
495
565
  }
@@ -497,7 +567,7 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
497
567
  let key = this.collection.getLastKey();
498
568
  while(key != null){
499
569
  let item = this.collection.getItem(key);
500
- if (item.type === 'item' && !this.disabledKeys.has(key)) return key;
570
+ if (item.type === "item" && !this.disabledKeys.has(key)) return key;
501
571
  key = this.collection.getKeyBefore(key);
502
572
  }
503
573
  }
@@ -550,16 +620,15 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
550
620
 
551
621
 
552
622
  function $982254629710d113$export$b95089534ab7c1fd(props) {
553
- 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;
623
+ 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;
554
624
  // By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).
555
625
  // When virtualized, the layout object will be passed in as a prop and override this.
556
- let collator = $eCAIO$useCollator({
557
- usage: 'search',
558
- sensitivity: 'base'
626
+ let collator = (0, $eCAIO$useCollator)({
627
+ usage: "search",
628
+ sensitivity: "base"
559
629
  });
560
630
  let disabledBehavior = selectionManager.disabledBehavior;
561
- let delegate = $eCAIO$useMemo(()=>keyboardDelegate || new $2a25aae57d74318e$export$a05409b8bb224a5a(collection, disabledBehavior === 'selection' ? new Set() : disabledKeys, ref, collator)
562
- , [
631
+ let delegate = (0, $eCAIO$useMemo)(()=>keyboardDelegate || new (0, $2a25aae57d74318e$export$a05409b8bb224a5a)(collection, disabledBehavior === "selection" ? new Set() : disabledKeys, ref, collator), [
563
632
  keyboardDelegate,
564
633
  collection,
565
634
  disabledKeys,
@@ -567,7 +636,7 @@ function $982254629710d113$export$b95089534ab7c1fd(props) {
567
636
  collator,
568
637
  disabledBehavior
569
638
  ]);
570
- let { collectionProps: collectionProps } = $ae20dd8cbca75726$export$d6daf82dcd84e87c({
639
+ let { collectionProps: collectionProps } = (0, $ae20dd8cbca75726$export$d6daf82dcd84e87c)({
571
640
  ref: ref,
572
641
  selectionManager: selectionManager,
573
642
  keyboardDelegate: delegate,