@react-aria/selection 3.7.2 → 3.8.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 +91 -80
- package/dist/main.js.map +1 -1
- package/dist/module.js +87 -76
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +9 -9
- package/src/useSelectableItem.ts +27 -7
package/dist/module.js
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import {useRef as $
|
|
2
|
-
import {getFocusableTreeWalker as $
|
|
3
|
-
import {focusWithoutScrolling as $
|
|
4
|
-
import {useLocale as $
|
|
5
|
-
import {usePress as $
|
|
1
|
+
import {useRef as $eCAIO$useRef, useEffect as $eCAIO$useEffect, useMemo as $eCAIO$useMemo} from "react";
|
|
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";
|
|
4
|
+
import {useLocale as $eCAIO$useLocale, useCollator as $eCAIO$useCollator} from "@react-aria/i18n";
|
|
5
|
+
import {usePress as $eCAIO$usePress, useLongPress as $eCAIO$useLongPress} from "@react-aria/interactions";
|
|
6
6
|
|
|
7
7
|
function $parcel$export(e, n, v, s) {
|
|
8
8
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
9
9
|
}
|
|
10
|
-
var $
|
|
10
|
+
var $ae20dd8cbca75726$exports = {};
|
|
11
11
|
|
|
12
|
-
$parcel$export($
|
|
12
|
+
$parcel$export($ae20dd8cbca75726$exports, "useSelectableCollection", () => $ae20dd8cbca75726$export$d6daf82dcd84e87c);
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
function $
|
|
18
|
+
function $feb5ffebff200149$export$d3e3bd3e26688c04(e) {
|
|
19
19
|
// Ctrl + Arrow Up/Arrow Down has a system wide meaning on macOS, so use Alt instead.
|
|
20
20
|
// On Windows and Ubuntu, Alt + Space has a system wide meaning.
|
|
21
|
-
return $
|
|
21
|
+
return $eCAIO$isAppleDevice() ? e.altKey : e.ctrlKey;
|
|
22
22
|
}
|
|
23
|
-
function $
|
|
24
|
-
if ($
|
|
23
|
+
function $feb5ffebff200149$export$16792effe837dba3(e) {
|
|
24
|
+
if ($eCAIO$isMac()) return e.metaKey;
|
|
25
25
|
return e.ctrlKey;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
var $
|
|
30
|
+
var $fb3050f43d946246$exports = {};
|
|
31
31
|
|
|
32
|
-
$parcel$export($
|
|
32
|
+
$parcel$export($fb3050f43d946246$exports, "useTypeSelect", () => $fb3050f43d946246$export$e32c88dfddc6e1d8);
|
|
33
33
|
|
|
34
|
-
function $
|
|
34
|
+
function $fb3050f43d946246$export$e32c88dfddc6e1d8(options) {
|
|
35
35
|
let { keyboardDelegate: keyboardDelegate , selectionManager: selectionManager , onTypeSelect: onTypeSelect } = options;
|
|
36
|
-
let state = $
|
|
36
|
+
let state = $eCAIO$useRef({
|
|
37
37
|
search: '',
|
|
38
38
|
timeout: null
|
|
39
39
|
}).current;
|
|
40
40
|
let onKeyDown = (e)=>{
|
|
41
|
-
let character = $
|
|
41
|
+
let character = $fb3050f43d946246$var$getStringForKey(e.key);
|
|
42
42
|
if (!character || e.ctrlKey || e.metaKey) return;
|
|
43
43
|
// Do not propagate the Spacebar event if it's meant to be part of the search.
|
|
44
44
|
// When we time out, the search term becomes empty, hence the check on length.
|
|
@@ -71,7 +71,7 @@ function $eb39f547daf47539$export$e32c88dfddc6e1d8(options) {
|
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
|
-
function $
|
|
74
|
+
function $fb3050f43d946246$var$getStringForKey(key) {
|
|
75
75
|
// If the key is of length 1, it is an ASCII value.
|
|
76
76
|
// Otherwise, if there are no ASCII characters in the key name,
|
|
77
77
|
// it is a Unicode character.
|
|
@@ -81,10 +81,10 @@ function $eb39f547daf47539$var$getStringForKey(key) {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
|
|
84
|
-
function $
|
|
84
|
+
function $ae20dd8cbca75726$export$d6daf82dcd84e87c(options) {
|
|
85
85
|
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
|
|
86
86
|
scrollRef = ref } = options;
|
|
87
|
-
let { direction: direction } = $
|
|
87
|
+
let { direction: direction } = $eCAIO$useLocale();
|
|
88
88
|
let onKeyDown = (e)=>{
|
|
89
89
|
// Prevent option + tab from doing anything since it doesn't move focus to the cells, only buttons/checkboxes
|
|
90
90
|
if (e.altKey && e.key === 'Tab') e.preventDefault();
|
|
@@ -95,23 +95,25 @@ function $f2918947066e8d51$export$d6daf82dcd84e87c(options) {
|
|
|
95
95
|
if (key != null) {
|
|
96
96
|
manager.setFocusedKey(key, childFocus);
|
|
97
97
|
if (e.shiftKey && manager.selectionMode === 'multiple') manager.extendSelection(key);
|
|
98
|
-
else if (selectOnFocus && !$
|
|
98
|
+
else if (selectOnFocus && !$feb5ffebff200149$export$d3e3bd3e26688c04(e)) manager.replaceSelection(key);
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
101
|
switch(e.key){
|
|
102
102
|
case 'ArrowDown':
|
|
103
103
|
if (delegate.getKeyBelow) {
|
|
104
|
+
var ref4, ref1;
|
|
104
105
|
e.preventDefault();
|
|
105
|
-
let nextKey = manager.focusedKey != null ? delegate.getKeyBelow(manager.focusedKey) : delegate.getFirstKey
|
|
106
|
-
if (nextKey == null && shouldFocusWrap) nextKey = delegate.getFirstKey
|
|
106
|
+
let nextKey = manager.focusedKey != null ? delegate.getKeyBelow(manager.focusedKey) : (ref4 = delegate.getFirstKey) === null || ref4 === void 0 ? void 0 : ref4.call(delegate);
|
|
107
|
+
if (nextKey == null && shouldFocusWrap) nextKey = (ref1 = delegate.getFirstKey) === null || ref1 === void 0 ? void 0 : ref1.call(delegate, manager.focusedKey);
|
|
107
108
|
navigateToKey(nextKey);
|
|
108
109
|
}
|
|
109
110
|
break;
|
|
110
111
|
case 'ArrowUp':
|
|
111
112
|
if (delegate.getKeyAbove) {
|
|
113
|
+
var ref2, ref3;
|
|
112
114
|
e.preventDefault();
|
|
113
|
-
let nextKey = manager.focusedKey != null ? delegate.getKeyAbove(manager.focusedKey) : delegate.getLastKey
|
|
114
|
-
if (nextKey == null && shouldFocusWrap) nextKey = delegate.getLastKey
|
|
115
|
+
let nextKey = manager.focusedKey != null ? delegate.getKeyAbove(manager.focusedKey) : (ref2 = delegate.getLastKey) === null || ref2 === void 0 ? void 0 : ref2.call(delegate);
|
|
116
|
+
if (nextKey == null && shouldFocusWrap) nextKey = (ref3 = delegate.getLastKey) === null || ref3 === void 0 ? void 0 : ref3.call(delegate, manager.focusedKey);
|
|
115
117
|
navigateToKey(nextKey);
|
|
116
118
|
}
|
|
117
119
|
break;
|
|
@@ -132,18 +134,18 @@ function $f2918947066e8d51$export$d6daf82dcd84e87c(options) {
|
|
|
132
134
|
case 'Home':
|
|
133
135
|
if (delegate.getFirstKey) {
|
|
134
136
|
e.preventDefault();
|
|
135
|
-
let firstKey = delegate.getFirstKey(manager.focusedKey, $
|
|
137
|
+
let firstKey = delegate.getFirstKey(manager.focusedKey, $feb5ffebff200149$export$16792effe837dba3(e));
|
|
136
138
|
manager.setFocusedKey(firstKey);
|
|
137
|
-
if ($
|
|
139
|
+
if ($feb5ffebff200149$export$16792effe837dba3(e) && e.shiftKey && manager.selectionMode === 'multiple') manager.extendSelection(firstKey);
|
|
138
140
|
else if (selectOnFocus) manager.replaceSelection(firstKey);
|
|
139
141
|
}
|
|
140
142
|
break;
|
|
141
143
|
case 'End':
|
|
142
144
|
if (delegate.getLastKey) {
|
|
143
145
|
e.preventDefault();
|
|
144
|
-
let lastKey = delegate.getLastKey(manager.focusedKey, $
|
|
146
|
+
let lastKey = delegate.getLastKey(manager.focusedKey, $feb5ffebff200149$export$16792effe837dba3(e));
|
|
145
147
|
manager.setFocusedKey(lastKey);
|
|
146
|
-
if ($
|
|
148
|
+
if ($feb5ffebff200149$export$16792effe837dba3(e) && e.shiftKey && manager.selectionMode === 'multiple') manager.extendSelection(lastKey);
|
|
147
149
|
else if (selectOnFocus) manager.replaceSelection(lastKey);
|
|
148
150
|
}
|
|
149
151
|
break;
|
|
@@ -162,7 +164,7 @@ function $f2918947066e8d51$export$d6daf82dcd84e87c(options) {
|
|
|
162
164
|
}
|
|
163
165
|
break;
|
|
164
166
|
case 'a':
|
|
165
|
-
if ($
|
|
167
|
+
if ($feb5ffebff200149$export$16792effe837dba3(e) && manager.selectionMode === 'multiple' && disallowSelectAll !== true) {
|
|
166
168
|
e.preventDefault();
|
|
167
169
|
manager.selectAll();
|
|
168
170
|
}
|
|
@@ -181,7 +183,7 @@ function $f2918947066e8d51$export$d6daf82dcd84e87c(options) {
|
|
|
181
183
|
// rather than the currently focused one.
|
|
182
184
|
if (e.shiftKey) ref.current.focus();
|
|
183
185
|
else {
|
|
184
|
-
let walker = $
|
|
186
|
+
let walker = $eCAIO$getFocusableTreeWalker(ref.current, {
|
|
185
187
|
tabbable: true
|
|
186
188
|
});
|
|
187
189
|
let next;
|
|
@@ -190,18 +192,18 @@ function $f2918947066e8d51$export$d6daf82dcd84e87c(options) {
|
|
|
190
192
|
last = walker.lastChild();
|
|
191
193
|
if (last) next = last;
|
|
192
194
|
}while (last)
|
|
193
|
-
if (next && !next.contains(document.activeElement)) $
|
|
195
|
+
if (next && !next.contains(document.activeElement)) $eCAIO$focusWithoutScrolling(next);
|
|
194
196
|
}
|
|
195
197
|
break;
|
|
196
198
|
}
|
|
197
199
|
}
|
|
198
200
|
};
|
|
199
201
|
// Store the scroll position so we can restore it later.
|
|
200
|
-
let scrollPos = $
|
|
202
|
+
let scrollPos = $eCAIO$useRef({
|
|
201
203
|
top: 0,
|
|
202
204
|
left: 0
|
|
203
205
|
});
|
|
204
|
-
$
|
|
206
|
+
$eCAIO$useEvent(scrollRef, 'scroll', isVirtualized ? null : ()=>{
|
|
205
207
|
scrollPos.current = {
|
|
206
208
|
top: scrollRef.current.scrollTop,
|
|
207
209
|
left: scrollRef.current.scrollLeft
|
|
@@ -227,8 +229,9 @@ function $f2918947066e8d51$export$d6daf82dcd84e87c(options) {
|
|
|
227
229
|
// Attempt to detect whether the user is tabbing forward or backward into the collection
|
|
228
230
|
// and either focus the first or last item accordingly.
|
|
229
231
|
let relatedTarget = e.relatedTarget;
|
|
230
|
-
|
|
231
|
-
|
|
232
|
+
var _lastSelectedKey, _firstSelectedKey;
|
|
233
|
+
if (relatedTarget && e.currentTarget.compareDocumentPosition(relatedTarget) & Node.DOCUMENT_POSITION_FOLLOWING) navigateToFirstKey((_lastSelectedKey = manager.lastSelectedKey) !== null && _lastSelectedKey !== void 0 ? _lastSelectedKey : delegate.getLastKey());
|
|
234
|
+
else navigateToFirstKey((_firstSelectedKey = manager.firstSelectedKey) !== null && _firstSelectedKey !== void 0 ? _firstSelectedKey : delegate.getFirstKey());
|
|
232
235
|
} else if (!isVirtualized) {
|
|
233
236
|
// Restore the scroll position to what it was before.
|
|
234
237
|
scrollRef.current.scrollTop = scrollPos.current.top;
|
|
@@ -237,8 +240,8 @@ function $f2918947066e8d51$export$d6daf82dcd84e87c(options) {
|
|
|
237
240
|
let element = scrollRef.current.querySelector(`[data-key="${manager.focusedKey}"]`);
|
|
238
241
|
if (element) {
|
|
239
242
|
// This prevents a flash of focus on the first/last element in the collection
|
|
240
|
-
$
|
|
241
|
-
$
|
|
243
|
+
$eCAIO$focusWithoutScrolling(element);
|
|
244
|
+
$eCAIO$scrollIntoView(scrollRef.current, element);
|
|
242
245
|
}
|
|
243
246
|
}
|
|
244
247
|
};
|
|
@@ -246,8 +249,8 @@ function $f2918947066e8d51$export$d6daf82dcd84e87c(options) {
|
|
|
246
249
|
// Don't set blurred and then focused again if moving focus within the collection.
|
|
247
250
|
if (!e.currentTarget.contains(e.relatedTarget)) manager.setFocused(false);
|
|
248
251
|
};
|
|
249
|
-
const autoFocusRef = $
|
|
250
|
-
$
|
|
252
|
+
const autoFocusRef = $eCAIO$useRef(autoFocus);
|
|
253
|
+
$eCAIO$useEffect(()=>{
|
|
251
254
|
if (autoFocusRef.current) {
|
|
252
255
|
let focusedKey = null;
|
|
253
256
|
// Check focus strategy to determine which item to focus
|
|
@@ -259,17 +262,17 @@ function $f2918947066e8d51$export$d6daf82dcd84e87c(options) {
|
|
|
259
262
|
manager.setFocused(true);
|
|
260
263
|
manager.setFocusedKey(focusedKey);
|
|
261
264
|
// If no default focus key is selected, focus the collection itself.
|
|
262
|
-
if (focusedKey == null && !shouldUseVirtualFocus) $
|
|
265
|
+
if (focusedKey == null && !shouldUseVirtualFocus) $eCAIO$focusSafely(ref.current);
|
|
263
266
|
}
|
|
264
267
|
autoFocusRef.current = false;
|
|
265
268
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
266
269
|
}, []);
|
|
267
270
|
// If not virtualized, scroll the focused element into view when the focusedKey changes.
|
|
268
271
|
// When virtualized, Virtualizer handles this internally.
|
|
269
|
-
$
|
|
270
|
-
if (!isVirtualized && manager.focusedKey && scrollRef
|
|
272
|
+
$eCAIO$useEffect(()=>{
|
|
273
|
+
if (!isVirtualized && manager.focusedKey && (scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current)) {
|
|
271
274
|
let element = scrollRef.current.querySelector(`[data-key="${manager.focusedKey}"]`);
|
|
272
|
-
if (element) $
|
|
275
|
+
if (element) $eCAIO$scrollIntoView(scrollRef.current, element);
|
|
273
276
|
}
|
|
274
277
|
}, [
|
|
275
278
|
isVirtualized,
|
|
@@ -286,11 +289,11 @@ function $f2918947066e8d51$export$d6daf82dcd84e87c(options) {
|
|
|
286
289
|
e.preventDefault();
|
|
287
290
|
}
|
|
288
291
|
};
|
|
289
|
-
let { typeSelectProps: typeSelectProps } = $
|
|
292
|
+
let { typeSelectProps: typeSelectProps } = $fb3050f43d946246$export$e32c88dfddc6e1d8({
|
|
290
293
|
keyboardDelegate: delegate,
|
|
291
294
|
selectionManager: manager
|
|
292
295
|
});
|
|
293
|
-
if (!disallowTypeAhead) handlers = $
|
|
296
|
+
if (!disallowTypeAhead) handlers = $eCAIO$mergeProps(typeSelectProps, handlers);
|
|
294
297
|
// If nothing is focused within the collection, make the collection itself tabbable.
|
|
295
298
|
// This will be marshalled to either the first or last item depending on where focus came from.
|
|
296
299
|
// If using virtual focus, don't set a tabIndex at all so that VoiceOver on iOS 14 doesn't try
|
|
@@ -306,35 +309,35 @@ function $f2918947066e8d51$export$d6daf82dcd84e87c(options) {
|
|
|
306
309
|
}
|
|
307
310
|
|
|
308
311
|
|
|
309
|
-
var $
|
|
312
|
+
var $880e95eb8b93ba9a$exports = {};
|
|
310
313
|
|
|
311
|
-
$parcel$export($
|
|
314
|
+
$parcel$export($880e95eb8b93ba9a$exports, "useSelectableItem", () => $880e95eb8b93ba9a$export$ecf600387e221c37);
|
|
312
315
|
|
|
313
316
|
|
|
314
317
|
|
|
315
318
|
|
|
316
319
|
|
|
317
|
-
function $
|
|
318
|
-
let { selectionManager: manager , key: key , ref: ref , shouldSelectOnPressUp: shouldSelectOnPressUp , isVirtualized: isVirtualized , shouldUseVirtualFocus: shouldUseVirtualFocus , focus: focus , isDisabled: isDisabled , onAction: onAction } = options;
|
|
320
|
+
function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
|
|
321
|
+
let { selectionManager: manager , key: key , ref: ref , shouldSelectOnPressUp: shouldSelectOnPressUp , isVirtualized: isVirtualized , shouldUseVirtualFocus: shouldUseVirtualFocus , focus: focus , isDisabled: isDisabled , onAction: onAction , allowsDifferentPressOrigin: allowsDifferentPressOrigin } = options;
|
|
319
322
|
let onSelect = (e)=>{
|
|
320
|
-
if (e.pointerType === 'keyboard' && $
|
|
323
|
+
if (e.pointerType === 'keyboard' && $feb5ffebff200149$export$d3e3bd3e26688c04(e)) manager.toggleSelection(key);
|
|
321
324
|
else {
|
|
322
325
|
if (manager.selectionMode === 'none') return;
|
|
323
326
|
if (manager.selectionMode === 'single') {
|
|
324
327
|
if (manager.isSelected(key) && !manager.disallowEmptySelection) manager.toggleSelection(key);
|
|
325
328
|
else manager.replaceSelection(key);
|
|
326
329
|
} else if (e && e.shiftKey) manager.extendSelection(key);
|
|
327
|
-
else if (manager.selectionBehavior === 'toggle' || e && ($
|
|
330
|
+
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
|
|
328
331
|
manager.toggleSelection(key);
|
|
329
332
|
else manager.replaceSelection(key);
|
|
330
333
|
}
|
|
331
334
|
};
|
|
332
335
|
// Focus the associated DOM node when this item becomes the focusedKey
|
|
333
336
|
let isFocused = key === manager.focusedKey;
|
|
334
|
-
$
|
|
337
|
+
$eCAIO$useEffect(()=>{
|
|
335
338
|
if (isFocused && manager.isFocused && !shouldUseVirtualFocus && document.activeElement !== ref.current) {
|
|
336
339
|
if (focus) focus();
|
|
337
|
-
else $
|
|
340
|
+
else $eCAIO$focusSafely(ref.current);
|
|
338
341
|
}
|
|
339
342
|
}, [
|
|
340
343
|
ref,
|
|
@@ -355,7 +358,7 @@ function $28b3f01514e02622$export$ecf600387e221c37(options) {
|
|
|
355
358
|
if (e.target === ref.current) manager.setFocusedKey(key);
|
|
356
359
|
}
|
|
357
360
|
};
|
|
358
|
-
let modality = $
|
|
361
|
+
let modality = $eCAIO$useRef(null);
|
|
359
362
|
let hasPrimaryAction = onAction && manager.selectionMode === 'none';
|
|
360
363
|
let hasSecondaryAction = onAction && manager.selectionMode !== 'none' && manager.selectionBehavior === 'replace';
|
|
361
364
|
let allowsSelection = !isDisabled && manager.canSelectItem(key);
|
|
@@ -373,11 +376,19 @@ function $28b3f01514e02622$export$ecf600387e221c37(options) {
|
|
|
373
376
|
modality.current = e.pointerType;
|
|
374
377
|
if (e.pointerType === 'keyboard') onSelect(e);
|
|
375
378
|
};
|
|
376
|
-
|
|
379
|
+
// If allowsDifferentPressOrigin, make selection happen on pressUp (e.g. open menu on press down, selection on menu item happens on press up.)
|
|
380
|
+
// Otherwise, have selection happen onPress (prevents listview row selection when clicking on interactable elements in the row)
|
|
381
|
+
if (!allowsDifferentPressOrigin) itemPressProps.onPress = (e)=>{
|
|
377
382
|
if (e.pointerType !== 'keyboard') onSelect(e);
|
|
383
|
+
if (hasPrimaryAction) onAction();
|
|
378
384
|
};
|
|
379
|
-
|
|
380
|
-
|
|
385
|
+
else {
|
|
386
|
+
itemPressProps.onPressUp = (e)=>{
|
|
387
|
+
if (e.pointerType !== 'keyboard') onSelect(e);
|
|
388
|
+
};
|
|
389
|
+
itemPressProps.onPress = hasPrimaryAction ? ()=>onAction()
|
|
390
|
+
: null;
|
|
391
|
+
}
|
|
381
392
|
} else {
|
|
382
393
|
// On touch, it feels strange to select on touch down, so we special case this.
|
|
383
394
|
itemPressProps.onPressStart = (e)=>{
|
|
@@ -395,7 +406,7 @@ function $28b3f01514e02622$export$ecf600387e221c37(options) {
|
|
|
395
406
|
}
|
|
396
407
|
if (!isVirtualized) itemProps['data-key'] = key;
|
|
397
408
|
itemPressProps.preventFocusOnPress = shouldUseVirtualFocus;
|
|
398
|
-
let { pressProps: pressProps , isPressed: isPressed } = $
|
|
409
|
+
let { pressProps: pressProps , isPressed: isPressed } = $eCAIO$usePress(itemPressProps);
|
|
399
410
|
// Double clicking with a mouse with selectionBehavior = 'replace' performs an action.
|
|
400
411
|
let onDoubleClick = hasSecondaryAction ? (e)=>{
|
|
401
412
|
if (modality.current === 'mouse') {
|
|
@@ -408,7 +419,7 @@ function $28b3f01514e02622$export$ecf600387e221c37(options) {
|
|
|
408
419
|
// to 'toggle'. This changes the single tap behavior from performing an action (i.e. navigating) to
|
|
409
420
|
// selecting, and may toggle the appearance of a UI affordance like checkboxes on each item.
|
|
410
421
|
// TODO: what about when drag and drop is also enabled??
|
|
411
|
-
let { longPressProps: longPressProps } = $
|
|
422
|
+
let { longPressProps: longPressProps } = $eCAIO$useLongPress({
|
|
412
423
|
isDisabled: !hasSecondaryAction,
|
|
413
424
|
onLongPress (e) {
|
|
414
425
|
if (e.pointerType === 'touch') {
|
|
@@ -422,7 +433,7 @@ function $28b3f01514e02622$export$ecf600387e221c37(options) {
|
|
|
422
433
|
if (e.key === 'Enter') onAction();
|
|
423
434
|
} : undefined;
|
|
424
435
|
return {
|
|
425
|
-
itemProps: $
|
|
436
|
+
itemProps: $eCAIO$mergeProps(itemProps, allowsSelection || hasPrimaryAction ? pressProps : {
|
|
426
437
|
}, hasSecondaryAction ? longPressProps : {
|
|
427
438
|
}, {
|
|
428
439
|
onKeyUp: onKeyUp,
|
|
@@ -433,20 +444,14 @@ function $28b3f01514e02622$export$ecf600387e221c37(options) {
|
|
|
433
444
|
}
|
|
434
445
|
|
|
435
446
|
|
|
436
|
-
var $
|
|
447
|
+
var $982254629710d113$exports = {};
|
|
437
448
|
|
|
438
|
-
$parcel$export($
|
|
449
|
+
$parcel$export($982254629710d113$exports, "useSelectableList", () => $982254629710d113$export$b95089534ab7c1fd);
|
|
439
450
|
|
|
440
|
-
var $
|
|
451
|
+
var $2a25aae57d74318e$exports = {};
|
|
441
452
|
|
|
442
|
-
$parcel$export($
|
|
443
|
-
class $
|
|
444
|
-
constructor(collection, disabledKeys, ref, collator){
|
|
445
|
-
this.collection = collection;
|
|
446
|
-
this.disabledKeys = disabledKeys;
|
|
447
|
-
this.ref = ref;
|
|
448
|
-
this.collator = collator;
|
|
449
|
-
}
|
|
453
|
+
$parcel$export($2a25aae57d74318e$exports, "ListKeyboardDelegate", () => $2a25aae57d74318e$export$a05409b8bb224a5a);
|
|
454
|
+
class $2a25aae57d74318e$export$a05409b8bb224a5a {
|
|
450
455
|
getKeyBelow(key) {
|
|
451
456
|
key = this.collection.getKeyAfter(key);
|
|
452
457
|
while(key != null){
|
|
@@ -516,20 +521,26 @@ class $57c17da9c35ecb23$export$a05409b8bb224a5a {
|
|
|
516
521
|
}
|
|
517
522
|
return null;
|
|
518
523
|
}
|
|
524
|
+
constructor(collection, disabledKeys, ref, collator){
|
|
525
|
+
this.collection = collection;
|
|
526
|
+
this.disabledKeys = disabledKeys;
|
|
527
|
+
this.ref = ref;
|
|
528
|
+
this.collator = collator;
|
|
529
|
+
}
|
|
519
530
|
}
|
|
520
531
|
|
|
521
532
|
|
|
522
533
|
|
|
523
534
|
|
|
524
|
-
function $
|
|
535
|
+
function $982254629710d113$export$b95089534ab7c1fd(props) {
|
|
525
536
|
let { selectionManager: selectionManager , collection: collection , disabledKeys: disabledKeys , ref: ref , keyboardDelegate: keyboardDelegate , autoFocus: autoFocus , shouldFocusWrap: shouldFocusWrap , isVirtualized: isVirtualized , disallowEmptySelection: disallowEmptySelection , selectOnFocus: selectOnFocus = false , disallowTypeAhead: disallowTypeAhead , shouldUseVirtualFocus: shouldUseVirtualFocus , allowsTabNavigation: allowsTabNavigation } = props;
|
|
526
537
|
// By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).
|
|
527
538
|
// When virtualized, the layout object will be passed in as a prop and override this.
|
|
528
|
-
let collator = $
|
|
539
|
+
let collator = $eCAIO$useCollator({
|
|
529
540
|
usage: 'search',
|
|
530
541
|
sensitivity: 'base'
|
|
531
542
|
});
|
|
532
|
-
let delegate = $
|
|
543
|
+
let delegate = $eCAIO$useMemo(()=>keyboardDelegate || new $2a25aae57d74318e$export$a05409b8bb224a5a(collection, disabledKeys, ref, collator)
|
|
533
544
|
, [
|
|
534
545
|
keyboardDelegate,
|
|
535
546
|
collection,
|
|
@@ -537,7 +548,7 @@ function $95210d28646fd635$export$b95089534ab7c1fd(props) {
|
|
|
537
548
|
ref,
|
|
538
549
|
collator
|
|
539
550
|
]);
|
|
540
|
-
let { collectionProps: collectionProps } = $
|
|
551
|
+
let { collectionProps: collectionProps } = $ae20dd8cbca75726$export$d6daf82dcd84e87c({
|
|
541
552
|
ref: ref,
|
|
542
553
|
selectionManager: selectionManager,
|
|
543
554
|
keyboardDelegate: delegate,
|
|
@@ -561,5 +572,5 @@ function $95210d28646fd635$export$b95089534ab7c1fd(props) {
|
|
|
561
572
|
|
|
562
573
|
|
|
563
574
|
|
|
564
|
-
export {$
|
|
575
|
+
export {$ae20dd8cbca75726$export$d6daf82dcd84e87c as useSelectableCollection, $880e95eb8b93ba9a$export$ecf600387e221c37 as useSelectableItem, $982254629710d113$export$b95089534ab7c1fd as useSelectableList, $2a25aae57d74318e$export$a05409b8bb224a5a as ListKeyboardDelegate, $fb3050f43d946246$export$e32c88dfddc6e1d8 as useTypeSelect};
|
|
565
576
|
//# sourceMappingURL=module.js.map
|