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