@react-aria/selection 3.12.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 +182 -118
- package/dist/main.js.map +1 -1
- package/dist/module.js +182 -118
- package/dist/module.js.map +1 -1
- package/package.json +10 -10
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 ===
|
|
81
|
+
if (character === " " && state.search.trim().length > 0) {
|
|
42
82
|
e.preventDefault();
|
|
43
|
-
if (!(
|
|
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 ===
|
|
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 ===
|
|
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 ===
|
|
92
|
-
else if (selectOnFocus &&
|
|
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
|
|
136
|
+
case "ArrowDown":
|
|
97
137
|
if (delegate.getKeyBelow) {
|
|
98
|
-
var
|
|
138
|
+
var _delegate_getFirstKey, _delegate_getFirstKey1;
|
|
99
139
|
e.preventDefault();
|
|
100
|
-
let nextKey = manager.focusedKey != null ? delegate.getKeyBelow(manager.focusedKey) : (
|
|
101
|
-
if (nextKey == null && shouldFocusWrap) nextKey = (
|
|
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
|
|
145
|
+
case "ArrowUp":
|
|
106
146
|
if (delegate.getKeyAbove) {
|
|
107
|
-
var
|
|
147
|
+
var _delegate_getLastKey, _delegate_getLastKey1;
|
|
108
148
|
e.preventDefault();
|
|
109
|
-
let
|
|
110
|
-
if (
|
|
111
|
-
navigateToKey(
|
|
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
|
|
154
|
+
case "ArrowLeft":
|
|
115
155
|
if (delegate.getKeyLeftOf) {
|
|
116
156
|
e.preventDefault();
|
|
117
|
-
let
|
|
118
|
-
navigateToKey(
|
|
157
|
+
let nextKey2 = delegate.getKeyLeftOf(manager.focusedKey);
|
|
158
|
+
navigateToKey(nextKey2, direction === "rtl" ? "first" : "last");
|
|
119
159
|
}
|
|
120
160
|
break;
|
|
121
|
-
case
|
|
161
|
+
case "ArrowRight":
|
|
122
162
|
if (delegate.getKeyRightOf) {
|
|
123
163
|
e.preventDefault();
|
|
124
|
-
let
|
|
125
|
-
navigateToKey(
|
|
164
|
+
let nextKey3 = delegate.getKeyRightOf(manager.focusedKey);
|
|
165
|
+
navigateToKey(nextKey3, direction === "rtl" ? "last" : "first");
|
|
126
166
|
}
|
|
127
167
|
break;
|
|
128
|
-
case
|
|
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 ===
|
|
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
|
|
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 ===
|
|
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
|
|
186
|
+
case "PageDown":
|
|
147
187
|
if (delegate.getKeyPageBelow) {
|
|
148
188
|
e.preventDefault();
|
|
149
|
-
let
|
|
150
|
-
navigateToKey(
|
|
189
|
+
let nextKey4 = delegate.getKeyPageBelow(manager.focusedKey);
|
|
190
|
+
navigateToKey(nextKey4);
|
|
151
191
|
}
|
|
152
192
|
break;
|
|
153
|
-
case
|
|
193
|
+
case "PageUp":
|
|
154
194
|
if (delegate.getKeyPageAbove) {
|
|
155
195
|
e.preventDefault();
|
|
156
|
-
let
|
|
157
|
-
navigateToKey(
|
|
196
|
+
let nextKey5 = delegate.getKeyPageAbove(manager.focusedKey);
|
|
197
|
+
navigateToKey(nextKey5);
|
|
158
198
|
}
|
|
159
199
|
break;
|
|
160
|
-
case
|
|
161
|
-
if ($feb5ffebff200149$export$16792effe837dba3(e) && manager.selectionMode ===
|
|
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
|
|
206
|
+
case "Escape":
|
|
167
207
|
e.preventDefault();
|
|
168
208
|
if (!disallowEmptySelection) manager.clearSelection();
|
|
169
209
|
break;
|
|
170
|
-
case
|
|
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,
|
|
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
|
|
227
|
-
if (relatedTarget && e.currentTarget.compareDocumentPosition(relatedTarget) & Node.DOCUMENT_POSITION_FOLLOWING) navigateToFirstKey((
|
|
228
|
-
else navigateToFirstKey((
|
|
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 ===
|
|
252
|
-
if (autoFocus ===
|
|
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,
|
|
@@ -283,11 +323,11 @@ function $ae20dd8cbca75726$export$d6daf82dcd84e87c(options) {
|
|
|
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,24 +361,24 @@ 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 ===
|
|
364
|
+
if (e.pointerType === "keyboard" && (0, $feb5ffebff200149$export$d3e3bd3e26688c04)(e)) manager.toggleSelection(key);
|
|
315
365
|
else {
|
|
316
|
-
if (manager.selectionMode ===
|
|
317
|
-
if (manager.selectionMode ===
|
|
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 ===
|
|
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
|
}
|
|
333
383
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
334
384
|
}, [
|
|
@@ -343,8 +393,7 @@ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
|
|
|
343
393
|
// Set tabIndex to 0 if the element is focused, or -1 otherwise so that only the last focused
|
|
344
394
|
// item is tabbable. If using virtual focus, don't set a tabIndex at all so that VoiceOver
|
|
345
395
|
// on iOS 14 doesn't try to move real DOM focus to the item anyway.
|
|
346
|
-
let itemProps = {
|
|
347
|
-
};
|
|
396
|
+
let itemProps = {};
|
|
348
397
|
if (!shouldUseVirtualFocus && !isDisabled) itemProps = {
|
|
349
398
|
tabIndex: key === manager.focusedKey ? 0 : -1,
|
|
350
399
|
onFocus (e) {
|
|
@@ -361,13 +410,13 @@ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
|
|
|
361
410
|
// With touch, onAction occurs on single tap, and long press enters selection mode.
|
|
362
411
|
let allowsSelection = !isDisabled && manager.canSelectItem(key);
|
|
363
412
|
let allowsActions = onAction && !isDisabled;
|
|
364
|
-
let hasPrimaryAction = allowsActions && (manager.selectionBehavior ===
|
|
365
|
-
let hasSecondaryAction = allowsActions && allowsSelection && manager.selectionBehavior ===
|
|
413
|
+
let hasPrimaryAction = allowsActions && (manager.selectionBehavior === "replace" ? !allowsSelection : manager.isEmpty);
|
|
414
|
+
let hasSecondaryAction = allowsActions && allowsSelection && manager.selectionBehavior === "replace";
|
|
366
415
|
let hasAction = hasPrimaryAction || hasSecondaryAction;
|
|
367
|
-
let modality = $eCAIO$useRef(null);
|
|
416
|
+
let modality = (0, $eCAIO$useRef)(null);
|
|
368
417
|
let longPressEnabled = hasAction && allowsSelection;
|
|
369
|
-
let longPressEnabledOnPressStart = $eCAIO$useRef(false);
|
|
370
|
-
let hadPrimaryActionOnPressStart = $eCAIO$useRef(false);
|
|
418
|
+
let longPressEnabledOnPressStart = (0, $eCAIO$useRef)(false);
|
|
419
|
+
let hadPrimaryActionOnPressStart = (0, $eCAIO$useRef)(false);
|
|
371
420
|
// By default, selection occurs on pointer down. This can be strange if selecting an
|
|
372
421
|
// item causes the UI to disappear immediately (e.g. menus).
|
|
373
422
|
// If shouldSelectOnPressUp is true, we use onPressUp instead of onPressStart.
|
|
@@ -375,28 +424,26 @@ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
|
|
|
375
424
|
// we want to be able to have the pointer down on the trigger that opens the menu and
|
|
376
425
|
// the pointer up on the menu item rather than requiring a separate press.
|
|
377
426
|
// For keyboard events, selection still occurs on key down.
|
|
378
|
-
let itemPressProps = {
|
|
379
|
-
};
|
|
427
|
+
let itemPressProps = {};
|
|
380
428
|
if (shouldSelectOnPressUp) {
|
|
381
429
|
itemPressProps.onPressStart = (e)=>{
|
|
382
430
|
modality.current = e.pointerType;
|
|
383
431
|
longPressEnabledOnPressStart.current = longPressEnabled;
|
|
384
|
-
if (e.pointerType ===
|
|
432
|
+
if (e.pointerType === "keyboard" && (!hasAction || $880e95eb8b93ba9a$var$isSelectionKey())) onSelect(e);
|
|
385
433
|
};
|
|
386
434
|
// If allowsDifferentPressOrigin, make selection happen on pressUp (e.g. open menu on press down, selection on menu item happens on press up.)
|
|
387
435
|
// Otherwise, have selection happen onPress (prevents listview row selection when clicking on interactable elements in the row)
|
|
388
436
|
if (!allowsDifferentPressOrigin) itemPressProps.onPress = (e)=>{
|
|
389
|
-
if (hasPrimaryAction || hasSecondaryAction && e.pointerType !==
|
|
390
|
-
if (e.pointerType ===
|
|
437
|
+
if (hasPrimaryAction || hasSecondaryAction && e.pointerType !== "mouse") {
|
|
438
|
+
if (e.pointerType === "keyboard" && !$880e95eb8b93ba9a$var$isActionKey()) return;
|
|
391
439
|
onAction();
|
|
392
|
-
} else if (e.pointerType !==
|
|
440
|
+
} else if (e.pointerType !== "keyboard") onSelect(e);
|
|
393
441
|
};
|
|
394
442
|
else {
|
|
395
443
|
itemPressProps.onPressUp = (e)=>{
|
|
396
|
-
if (e.pointerType !==
|
|
444
|
+
if (e.pointerType !== "keyboard") onSelect(e);
|
|
397
445
|
};
|
|
398
|
-
itemPressProps.onPress = hasPrimaryAction ? ()=>onAction()
|
|
399
|
-
: null;
|
|
446
|
+
itemPressProps.onPress = hasPrimaryAction ? ()=>onAction() : null;
|
|
400
447
|
}
|
|
401
448
|
} else {
|
|
402
449
|
itemPressProps.onPressStart = (e)=>{
|
|
@@ -406,24 +453,24 @@ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
|
|
|
406
453
|
// Select on mouse down unless there is a primary action which will occur on mouse up.
|
|
407
454
|
// For keyboard, select on key down. If there is an action, the Space key selects on key down,
|
|
408
455
|
// and the Enter key performs onAction on key up.
|
|
409
|
-
if (e.pointerType ===
|
|
456
|
+
if (e.pointerType === "mouse" && !hasPrimaryAction || e.pointerType === "keyboard" && (!onAction || $880e95eb8b93ba9a$var$isSelectionKey())) onSelect(e);
|
|
410
457
|
};
|
|
411
458
|
itemPressProps.onPress = (e)=>{
|
|
412
459
|
// Selection occurs on touch up. Primary actions always occur on pointer up.
|
|
413
460
|
// Both primary and secondary actions occur on Enter key up. The only exception
|
|
414
461
|
// is secondary actions, which occur on double click with a mouse.
|
|
415
|
-
if (e.pointerType ===
|
|
462
|
+
if (e.pointerType === "touch" || e.pointerType === "pen" || e.pointerType === "virtual" || e.pointerType === "keyboard" && hasAction && $880e95eb8b93ba9a$var$isActionKey() || e.pointerType === "mouse" && hadPrimaryActionOnPressStart.current) {
|
|
416
463
|
if (hasAction) onAction();
|
|
417
464
|
else onSelect(e);
|
|
418
465
|
}
|
|
419
466
|
};
|
|
420
467
|
}
|
|
421
|
-
if (!isVirtualized) itemProps[
|
|
468
|
+
if (!isVirtualized) itemProps["data-key"] = key;
|
|
422
469
|
itemPressProps.preventFocusOnPress = shouldUseVirtualFocus;
|
|
423
|
-
let { pressProps: pressProps , isPressed: isPressed } = $eCAIO$usePress(itemPressProps);
|
|
470
|
+
let { pressProps: pressProps , isPressed: isPressed } = (0, $eCAIO$usePress)(itemPressProps);
|
|
424
471
|
// Double clicking with a mouse with selectionBehavior = 'replace' performs an action.
|
|
425
472
|
let onDoubleClick = hasSecondaryAction ? (e)=>{
|
|
426
|
-
if (modality.current ===
|
|
473
|
+
if (modality.current === "mouse") {
|
|
427
474
|
e.stopPropagation();
|
|
428
475
|
e.preventDefault();
|
|
429
476
|
onAction();
|
|
@@ -432,12 +479,12 @@ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
|
|
|
432
479
|
// Long pressing an item with touch when selectionBehavior = 'replace' switches the selection behavior
|
|
433
480
|
// to 'toggle'. This changes the single tap behavior from performing an action (i.e. navigating) to
|
|
434
481
|
// selecting, and may toggle the appearance of a UI affordance like checkboxes on each item.
|
|
435
|
-
let { longPressProps: longPressProps } = $eCAIO$useLongPress({
|
|
482
|
+
let { longPressProps: longPressProps } = (0, $eCAIO$useLongPress)({
|
|
436
483
|
isDisabled: !longPressEnabled,
|
|
437
484
|
onLongPress (e) {
|
|
438
|
-
if (e.pointerType ===
|
|
485
|
+
if (e.pointerType === "touch") {
|
|
439
486
|
onSelect(e);
|
|
440
|
-
manager.setSelectionBehavior(
|
|
487
|
+
manager.setSelectionBehavior("toggle");
|
|
441
488
|
}
|
|
442
489
|
}
|
|
443
490
|
});
|
|
@@ -446,12 +493,10 @@ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
|
|
|
446
493
|
// Use a capturing listener to ensure this runs before useDrag, regardless of
|
|
447
494
|
// the order the props get merged.
|
|
448
495
|
let onDragStartCapture = (e)=>{
|
|
449
|
-
if (modality.current ===
|
|
496
|
+
if (modality.current === "touch" && longPressEnabledOnPressStart.current) e.preventDefault();
|
|
450
497
|
};
|
|
451
498
|
return {
|
|
452
|
-
itemProps: $eCAIO$mergeProps(itemProps, allowsSelection || hasPrimaryAction ? pressProps : {
|
|
453
|
-
}, longPressEnabled ? longPressProps : {
|
|
454
|
-
}, {
|
|
499
|
+
itemProps: (0, $eCAIO$mergeProps)(itemProps, allowsSelection || hasPrimaryAction ? pressProps : {}, longPressEnabled ? longPressProps : {}, {
|
|
455
500
|
onDoubleClick: onDoubleClick,
|
|
456
501
|
onDragStartCapture: onDragStartCapture
|
|
457
502
|
}),
|
|
@@ -464,21 +509,41 @@ function $880e95eb8b93ba9a$export$ecf600387e221c37(options) {
|
|
|
464
509
|
}
|
|
465
510
|
function $880e95eb8b93ba9a$var$isActionKey() {
|
|
466
511
|
let event = window.event;
|
|
467
|
-
return (event === null || event === void 0 ? void 0 : event.key) ===
|
|
512
|
+
return (event === null || event === void 0 ? void 0 : event.key) === "Enter";
|
|
468
513
|
}
|
|
469
514
|
function $880e95eb8b93ba9a$var$isSelectionKey() {
|
|
470
515
|
let event = window.event;
|
|
471
|
-
return (event === null || event === void 0 ? void 0 : event.key) ===
|
|
516
|
+
return (event === null || event === void 0 ? void 0 : event.key) === " " || (event === null || event === void 0 ? void 0 : event.code) === "Space";
|
|
472
517
|
}
|
|
473
518
|
|
|
474
519
|
|
|
475
|
-
|
|
476
|
-
|
|
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 {
|
|
477
542
|
getKeyBelow(key) {
|
|
478
543
|
key = this.collection.getKeyAfter(key);
|
|
479
544
|
while(key != null){
|
|
480
545
|
let item = this.collection.getItem(key);
|
|
481
|
-
if (item.type ===
|
|
546
|
+
if (item.type === "item" && !this.disabledKeys.has(key)) return key;
|
|
482
547
|
key = this.collection.getKeyAfter(key);
|
|
483
548
|
}
|
|
484
549
|
}
|
|
@@ -486,7 +551,7 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
|
|
|
486
551
|
key = this.collection.getKeyBefore(key);
|
|
487
552
|
while(key != null){
|
|
488
553
|
let item = this.collection.getItem(key);
|
|
489
|
-
if (item.type ===
|
|
554
|
+
if (item.type === "item" && !this.disabledKeys.has(key)) return key;
|
|
490
555
|
key = this.collection.getKeyBefore(key);
|
|
491
556
|
}
|
|
492
557
|
}
|
|
@@ -494,7 +559,7 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
|
|
|
494
559
|
let key = this.collection.getFirstKey();
|
|
495
560
|
while(key != null){
|
|
496
561
|
let item = this.collection.getItem(key);
|
|
497
|
-
if (item.type ===
|
|
562
|
+
if (item.type === "item" && !this.disabledKeys.has(key)) return key;
|
|
498
563
|
key = this.collection.getKeyAfter(key);
|
|
499
564
|
}
|
|
500
565
|
}
|
|
@@ -502,7 +567,7 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
|
|
|
502
567
|
let key = this.collection.getLastKey();
|
|
503
568
|
while(key != null){
|
|
504
569
|
let item = this.collection.getItem(key);
|
|
505
|
-
if (item.type ===
|
|
570
|
+
if (item.type === "item" && !this.disabledKeys.has(key)) return key;
|
|
506
571
|
key = this.collection.getKeyBefore(key);
|
|
507
572
|
}
|
|
508
573
|
}
|
|
@@ -555,16 +620,15 @@ class $2a25aae57d74318e$export$a05409b8bb224a5a {
|
|
|
555
620
|
|
|
556
621
|
|
|
557
622
|
function $982254629710d113$export$b95089534ab7c1fd(props) {
|
|
558
|
-
let { selectionManager: selectionManager , collection: collection , disabledKeys: disabledKeys , ref: ref , keyboardDelegate: keyboardDelegate , autoFocus: autoFocus , shouldFocusWrap: shouldFocusWrap , isVirtualized: isVirtualized , disallowEmptySelection: disallowEmptySelection , selectOnFocus: selectOnFocus = selectionManager.selectionBehavior ===
|
|
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;
|
|
559
624
|
// By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).
|
|
560
625
|
// When virtualized, the layout object will be passed in as a prop and override this.
|
|
561
|
-
let collator = $eCAIO$useCollator({
|
|
562
|
-
usage:
|
|
563
|
-
sensitivity:
|
|
626
|
+
let collator = (0, $eCAIO$useCollator)({
|
|
627
|
+
usage: "search",
|
|
628
|
+
sensitivity: "base"
|
|
564
629
|
});
|
|
565
630
|
let disabledBehavior = selectionManager.disabledBehavior;
|
|
566
|
-
let delegate = $eCAIO$useMemo(()=>keyboardDelegate || new $2a25aae57d74318e$export$a05409b8bb224a5a(collection, disabledBehavior ===
|
|
567
|
-
, [
|
|
631
|
+
let delegate = (0, $eCAIO$useMemo)(()=>keyboardDelegate || new (0, $2a25aae57d74318e$export$a05409b8bb224a5a)(collection, disabledBehavior === "selection" ? new Set() : disabledKeys, ref, collator), [
|
|
568
632
|
keyboardDelegate,
|
|
569
633
|
collection,
|
|
570
634
|
disabledKeys,
|
|
@@ -572,7 +636,7 @@ function $982254629710d113$export$b95089534ab7c1fd(props) {
|
|
|
572
636
|
collator,
|
|
573
637
|
disabledBehavior
|
|
574
638
|
]);
|
|
575
|
-
let { collectionProps: collectionProps } = $ae20dd8cbca75726$export$d6daf82dcd84e87c({
|
|
639
|
+
let { collectionProps: collectionProps } = (0, $ae20dd8cbca75726$export$d6daf82dcd84e87c)({
|
|
576
640
|
ref: ref,
|
|
577
641
|
selectionManager: selectionManager,
|
|
578
642
|
keyboardDelegate: delegate,
|