@react-aria/dnd 3.6.1-nightly.4624 → 3.6.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/DragManager.main.js +68 -68
- package/dist/DragManager.mjs +68 -68
- package/dist/DragManager.module.js +68 -68
- package/dist/DragPreview.main.js +1 -1
- package/dist/DragPreview.mjs +1 -1
- package/dist/DragPreview.module.js +1 -1
- package/dist/ListDropTargetDelegate.main.js +31 -31
- package/dist/ListDropTargetDelegate.mjs +31 -31
- package/dist/ListDropTargetDelegate.module.js +31 -31
- package/dist/constants.main.js +10 -10
- package/dist/constants.mjs +10 -10
- package/dist/constants.module.js +10 -10
- package/dist/useClipboard.main.js +1 -1
- package/dist/useClipboard.mjs +1 -1
- package/dist/useClipboard.module.js +1 -1
- package/dist/useDrag.main.js +38 -38
- package/dist/useDrag.mjs +38 -38
- package/dist/useDrag.module.js +38 -38
- package/dist/useDraggableItem.main.js +17 -17
- package/dist/useDraggableItem.mjs +17 -17
- package/dist/useDraggableItem.module.js +17 -17
- package/dist/useDrop.main.js +30 -30
- package/dist/useDrop.mjs +30 -30
- package/dist/useDrop.module.js +30 -30
- package/dist/useDropIndicator.main.js +17 -17
- package/dist/useDropIndicator.mjs +17 -17
- package/dist/useDropIndicator.module.js +17 -17
- package/dist/useDroppableCollection.main.js +83 -83
- package/dist/useDroppableCollection.mjs +83 -83
- package/dist/useDroppableCollection.module.js +83 -83
- package/dist/useDroppableItem.main.js +2 -2
- package/dist/useDroppableItem.mjs +2 -2
- package/dist/useDroppableItem.module.js +2 -2
- package/dist/useVirtualDrop.main.js +5 -5
- package/dist/useVirtualDrop.mjs +5 -5
- package/dist/useVirtualDrop.module.js +5 -5
- package/dist/utils.main.js +20 -20
- package/dist/utils.mjs +20 -20
- package/dist/utils.module.js +20 -20
- package/package.json +11 -11
|
@@ -26,14 +26,14 @@ import {useLocale as $4ZR0C$useLocale} from "@react-aria/i18n";
|
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
const $4b52e4eff84e5217$var$DROP_POSITIONS = [
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
'before',
|
|
30
|
+
'on',
|
|
31
|
+
'after'
|
|
32
32
|
];
|
|
33
33
|
const $4b52e4eff84e5217$var$DROP_POSITIONS_RTL = [
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
'after',
|
|
35
|
+
'on',
|
|
36
|
+
'before'
|
|
37
37
|
];
|
|
38
38
|
function $4b52e4eff84e5217$export$f4e2f423c21f7b04(props, state, ref) {
|
|
39
39
|
let localState = (0, $4ZR0C$useRef)({
|
|
@@ -45,40 +45,40 @@ function $4b52e4eff84e5217$export$f4e2f423c21f7b04(props, state, ref) {
|
|
|
45
45
|
localState.props = props;
|
|
46
46
|
localState.state = state;
|
|
47
47
|
let defaultOnDrop = (0, $4ZR0C$useCallback)(async (e)=>{
|
|
48
|
-
let { onInsert: onInsert, onRootDrop: onRootDrop, onItemDrop: onItemDrop, onReorder: onReorder, acceptedDragTypes: acceptedDragTypes =
|
|
48
|
+
let { onInsert: onInsert, onRootDrop: onRootDrop, onItemDrop: onItemDrop, onReorder: onReorder, acceptedDragTypes: acceptedDragTypes = 'all', shouldAcceptItemDrop: shouldAcceptItemDrop } = localState.props;
|
|
49
49
|
let { draggingKeys: draggingKeys } = (0, $7252cd45fc48c07c$export$6ca6700462636d0b);
|
|
50
50
|
let isInternal = (0, $7252cd45fc48c07c$export$78bf638634500fa5)(ref);
|
|
51
51
|
let { target: target, dropOperation: dropOperation, items: items } = e;
|
|
52
52
|
let filteredItems = items;
|
|
53
|
-
if (acceptedDragTypes !==
|
|
53
|
+
if (acceptedDragTypes !== 'all' || shouldAcceptItemDrop) filteredItems = items.filter((item)=>{
|
|
54
54
|
let itemTypes;
|
|
55
|
-
if (item.kind ===
|
|
55
|
+
if (item.kind === 'directory') itemTypes = new Set([
|
|
56
56
|
(0, $7252cd45fc48c07c$export$990fced5dfac2637)
|
|
57
57
|
]);
|
|
58
|
-
else itemTypes = item.kind ===
|
|
58
|
+
else itemTypes = item.kind === 'file' ? new Set([
|
|
59
59
|
item.type
|
|
60
60
|
]) : item.types;
|
|
61
|
-
if (acceptedDragTypes ===
|
|
61
|
+
if (acceptedDragTypes === 'all' || acceptedDragTypes.some((type)=>itemTypes.has(type))) {
|
|
62
62
|
// If we are performing a on item drop, check if the item in question accepts the dropped item since the item may have heavier restrictions
|
|
63
63
|
// than the droppable collection itself
|
|
64
|
-
if (target.type ===
|
|
64
|
+
if (target.type === 'item' && target.dropPosition === 'on' && shouldAcceptItemDrop) return shouldAcceptItemDrop(target, itemTypes);
|
|
65
65
|
return true;
|
|
66
66
|
}
|
|
67
67
|
return false;
|
|
68
68
|
});
|
|
69
69
|
if (filteredItems.length > 0) {
|
|
70
|
-
if (target.type ===
|
|
70
|
+
if (target.type === 'root' && onRootDrop) await onRootDrop({
|
|
71
71
|
items: filteredItems,
|
|
72
72
|
dropOperation: dropOperation
|
|
73
73
|
});
|
|
74
|
-
if (target.type ===
|
|
75
|
-
if (target.dropPosition ===
|
|
74
|
+
if (target.type === 'item') {
|
|
75
|
+
if (target.dropPosition === 'on' && onItemDrop) await onItemDrop({
|
|
76
76
|
items: filteredItems,
|
|
77
77
|
dropOperation: dropOperation,
|
|
78
78
|
isInternal: isInternal,
|
|
79
79
|
target: target
|
|
80
80
|
});
|
|
81
|
-
if (target.dropPosition !==
|
|
81
|
+
if (target.dropPosition !== 'on') {
|
|
82
82
|
if (!isInternal && onInsert) await onInsert({
|
|
83
83
|
items: filteredItems,
|
|
84
84
|
dropOperation: dropOperation,
|
|
@@ -115,12 +115,12 @@ function $4b52e4eff84e5217$export$f4e2f423c21f7b04(props, state, ref) {
|
|
|
115
115
|
allowedOperations: allowedOperations,
|
|
116
116
|
isInternal: isInternal,
|
|
117
117
|
draggingKeys: draggingKeys
|
|
118
|
-
}) !==
|
|
118
|
+
}) !== 'cancel';
|
|
119
119
|
let target = props.dropTargetDelegate.getDropTargetFromPoint(x, y, isValidDropTarget);
|
|
120
120
|
if (!target) {
|
|
121
|
-
localState.dropOperation =
|
|
121
|
+
localState.dropOperation = 'cancel';
|
|
122
122
|
localState.nextTarget = null;
|
|
123
|
-
return
|
|
123
|
+
return 'cancel';
|
|
124
124
|
}
|
|
125
125
|
localState.dropOperation = state.getDropOperation({
|
|
126
126
|
target: target,
|
|
@@ -130,9 +130,9 @@ function $4b52e4eff84e5217$export$f4e2f423c21f7b04(props, state, ref) {
|
|
|
130
130
|
draggingKeys: draggingKeys
|
|
131
131
|
});
|
|
132
132
|
// If the target doesn't accept the drop, see if the root accepts it instead.
|
|
133
|
-
if (localState.dropOperation ===
|
|
133
|
+
if (localState.dropOperation === 'cancel') {
|
|
134
134
|
let rootTarget = {
|
|
135
|
-
type:
|
|
135
|
+
type: 'root'
|
|
136
136
|
};
|
|
137
137
|
let dropOperation = state.getDropOperation({
|
|
138
138
|
target: rootTarget,
|
|
@@ -141,15 +141,15 @@ function $4b52e4eff84e5217$export$f4e2f423c21f7b04(props, state, ref) {
|
|
|
141
141
|
isInternal: isInternal,
|
|
142
142
|
draggingKeys: draggingKeys
|
|
143
143
|
});
|
|
144
|
-
if (dropOperation !==
|
|
144
|
+
if (dropOperation !== 'cancel') {
|
|
145
145
|
target = rootTarget;
|
|
146
146
|
localState.dropOperation = dropOperation;
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
// Only set dropCollectionRef if there is a valid drop target since we cleanup dropCollectionRef in onDropExit
|
|
150
150
|
// which only runs when leaving a valid drop target or if the dropEffect become none (mouse dnd only).
|
|
151
|
-
if (target && localState.dropOperation !==
|
|
152
|
-
localState.nextTarget = localState.dropOperation ===
|
|
151
|
+
if (target && localState.dropOperation !== 'cancel' && (ref === null || ref === void 0 ? void 0 : ref.current) !== (dropCollectionRef === null || dropCollectionRef === void 0 ? void 0 : dropCollectionRef.current)) (0, $7252cd45fc48c07c$export$dac8db29d42db9a1)(ref);
|
|
152
|
+
localState.nextTarget = localState.dropOperation === 'cancel' ? null : target;
|
|
153
153
|
return localState.dropOperation;
|
|
154
154
|
},
|
|
155
155
|
onDropExit () {
|
|
@@ -159,8 +159,8 @@ function $4b52e4eff84e5217$export$f4e2f423c21f7b04(props, state, ref) {
|
|
|
159
159
|
},
|
|
160
160
|
onDropActivate (e) {
|
|
161
161
|
var _state_target, _state_target1;
|
|
162
|
-
if (((_state_target = state.target) === null || _state_target === void 0 ? void 0 : _state_target.type) ===
|
|
163
|
-
type:
|
|
162
|
+
if (((_state_target = state.target) === null || _state_target === void 0 ? void 0 : _state_target.type) === 'item' && ((_state_target1 = state.target) === null || _state_target1 === void 0 ? void 0 : _state_target1.dropPosition) === 'on' && typeof props.onDropActivate === 'function') props.onDropActivate({
|
|
163
|
+
type: 'dropactivate',
|
|
164
164
|
x: e.x,
|
|
165
165
|
y: e.y,
|
|
166
166
|
target: state.target
|
|
@@ -196,7 +196,7 @@ function $4b52e4eff84e5217$export$f4e2f423c21f7b04(props, state, ref) {
|
|
|
196
196
|
};
|
|
197
197
|
let onDropFn = localState.props.onDrop || defaultOnDrop;
|
|
198
198
|
onDropFn({
|
|
199
|
-
type:
|
|
199
|
+
type: 'drop',
|
|
200
200
|
x: e.x,
|
|
201
201
|
y: e.y,
|
|
202
202
|
target: target,
|
|
@@ -212,11 +212,11 @@ function $4b52e4eff84e5217$export$f4e2f423c21f7b04(props, state, ref) {
|
|
|
212
212
|
// focus that item and show the focus ring to give the user feedback that the drop occurred.
|
|
213
213
|
// Also show the focus ring if the focused key is not selected, e.g. in case of a reorder.
|
|
214
214
|
let { state: state } = localState;
|
|
215
|
-
if (target.type ===
|
|
215
|
+
if (target.type === 'item' && target.dropPosition === 'on' && state.collection.getItem(target.key) != null) {
|
|
216
216
|
state.selectionManager.setFocusedKey(target.key);
|
|
217
217
|
state.selectionManager.setFocused(true);
|
|
218
|
-
(0, $4ZR0C$setInteractionModality)(
|
|
219
|
-
} else if (!state.selectionManager.isSelected(focusedKey)) (0, $4ZR0C$setInteractionModality)(
|
|
218
|
+
(0, $4ZR0C$setInteractionModality)('keyboard');
|
|
219
|
+
} else if (!state.selectionManager.isSelected(focusedKey)) (0, $4ZR0C$setInteractionModality)('keyboard');
|
|
220
220
|
droppingState.current = null;
|
|
221
221
|
}, 50);
|
|
222
222
|
}, [
|
|
@@ -244,9 +244,9 @@ function $4b52e4eff84e5217$export$f4e2f423c21f7b04(props, state, ref) {
|
|
|
244
244
|
let first = newKeys.keys().next().value;
|
|
245
245
|
let item = state.collection.getItem(first);
|
|
246
246
|
// If this is a cell, focus the parent row.
|
|
247
|
-
if ((item === null || item === void 0 ? void 0 : item.type) ===
|
|
247
|
+
if ((item === null || item === void 0 ? void 0 : item.type) === 'cell') first = item.parentKey;
|
|
248
248
|
state.selectionManager.setFocusedKey(first);
|
|
249
|
-
if (state.selectionManager.selectionMode ===
|
|
249
|
+
if (state.selectionManager.selectionMode === 'none') (0, $4ZR0C$setInteractionModality)('keyboard');
|
|
250
250
|
}
|
|
251
251
|
droppingState.current = null;
|
|
252
252
|
}
|
|
@@ -255,40 +255,40 @@ function $4b52e4eff84e5217$export$f4e2f423c21f7b04(props, state, ref) {
|
|
|
255
255
|
(0, $4ZR0C$useEffect)(()=>{
|
|
256
256
|
let getNextTarget = (target, wrap = true, horizontal = false)=>{
|
|
257
257
|
if (!target) return {
|
|
258
|
-
type:
|
|
258
|
+
type: 'root'
|
|
259
259
|
};
|
|
260
260
|
let { keyboardDelegate: keyboardDelegate } = localState.props;
|
|
261
261
|
let nextKey;
|
|
262
|
-
if ((target === null || target === void 0 ? void 0 : target.type) ===
|
|
263
|
-
else nextKey = horizontal && direction ===
|
|
264
|
-
let dropPositions = horizontal && direction ===
|
|
262
|
+
if ((target === null || target === void 0 ? void 0 : target.type) === 'item') nextKey = horizontal ? keyboardDelegate.getKeyRightOf(target.key) : keyboardDelegate.getKeyBelow(target.key);
|
|
263
|
+
else nextKey = horizontal && direction === 'rtl' ? keyboardDelegate.getLastKey() : keyboardDelegate.getFirstKey();
|
|
264
|
+
let dropPositions = horizontal && direction === 'rtl' ? $4b52e4eff84e5217$var$DROP_POSITIONS_RTL : $4b52e4eff84e5217$var$DROP_POSITIONS;
|
|
265
265
|
let dropPosition = dropPositions[0];
|
|
266
|
-
if (target.type ===
|
|
266
|
+
if (target.type === 'item') {
|
|
267
267
|
// If the the keyboard delegate returned the next key in the collection,
|
|
268
268
|
// first try the other positions in the current key. Otherwise (e.g. in a grid layout),
|
|
269
269
|
// jump to the same drop position in the new key.
|
|
270
|
-
let nextCollectionKey = horizontal && direction ===
|
|
270
|
+
let nextCollectionKey = horizontal && direction === 'rtl' ? localState.state.collection.getKeyBefore(target.key) : localState.state.collection.getKeyAfter(target.key);
|
|
271
271
|
if (nextKey == null || nextKey === nextCollectionKey) {
|
|
272
272
|
let positionIndex = dropPositions.indexOf(target.dropPosition);
|
|
273
273
|
let nextDropPosition = dropPositions[positionIndex + 1];
|
|
274
274
|
if (positionIndex < dropPositions.length - 1 && !(nextDropPosition === dropPositions[2] && nextKey != null)) return {
|
|
275
|
-
type:
|
|
275
|
+
type: 'item',
|
|
276
276
|
key: target.key,
|
|
277
277
|
dropPosition: nextDropPosition
|
|
278
278
|
};
|
|
279
279
|
// If the last drop position was 'after', then 'before' on the next key is equivalent.
|
|
280
280
|
// Switch to 'on' instead.
|
|
281
|
-
if (target.dropPosition === dropPositions[2]) dropPosition =
|
|
281
|
+
if (target.dropPosition === dropPositions[2]) dropPosition = 'on';
|
|
282
282
|
} else dropPosition = target.dropPosition;
|
|
283
283
|
}
|
|
284
284
|
if (nextKey == null) {
|
|
285
285
|
if (wrap) return {
|
|
286
|
-
type:
|
|
286
|
+
type: 'root'
|
|
287
287
|
};
|
|
288
288
|
return null;
|
|
289
289
|
}
|
|
290
290
|
return {
|
|
291
|
-
type:
|
|
291
|
+
type: 'item',
|
|
292
292
|
key: nextKey,
|
|
293
293
|
dropPosition: dropPosition
|
|
294
294
|
};
|
|
@@ -296,36 +296,36 @@ function $4b52e4eff84e5217$export$f4e2f423c21f7b04(props, state, ref) {
|
|
|
296
296
|
let getPreviousTarget = (target, wrap = true, horizontal = false)=>{
|
|
297
297
|
let { keyboardDelegate: keyboardDelegate } = localState.props;
|
|
298
298
|
let nextKey;
|
|
299
|
-
if ((target === null || target === void 0 ? void 0 : target.type) ===
|
|
300
|
-
else nextKey = horizontal && direction ===
|
|
301
|
-
let dropPositions = horizontal && direction ===
|
|
302
|
-
let dropPosition = !target || target.type ===
|
|
303
|
-
if ((target === null || target === void 0 ? void 0 : target.type) ===
|
|
299
|
+
if ((target === null || target === void 0 ? void 0 : target.type) === 'item') nextKey = horizontal ? keyboardDelegate.getKeyLeftOf(target.key) : keyboardDelegate.getKeyAbove(target.key);
|
|
300
|
+
else nextKey = horizontal && direction === 'rtl' ? keyboardDelegate.getFirstKey() : keyboardDelegate.getLastKey();
|
|
301
|
+
let dropPositions = horizontal && direction === 'rtl' ? $4b52e4eff84e5217$var$DROP_POSITIONS_RTL : $4b52e4eff84e5217$var$DROP_POSITIONS;
|
|
302
|
+
let dropPosition = !target || target.type === 'root' ? dropPositions[2] : 'on';
|
|
303
|
+
if ((target === null || target === void 0 ? void 0 : target.type) === 'item') {
|
|
304
304
|
// If the the keyboard delegate returned the previous key in the collection,
|
|
305
305
|
// first try the other positions in the current key. Otherwise (e.g. in a grid layout),
|
|
306
306
|
// jump to the same drop position in the new key.
|
|
307
|
-
let prevCollectionKey = horizontal && direction ===
|
|
307
|
+
let prevCollectionKey = horizontal && direction === 'rtl' ? localState.state.collection.getKeyAfter(target.key) : localState.state.collection.getKeyBefore(target.key);
|
|
308
308
|
if (nextKey == null || nextKey === prevCollectionKey) {
|
|
309
309
|
let positionIndex = dropPositions.indexOf(target.dropPosition);
|
|
310
310
|
let nextDropPosition = dropPositions[positionIndex - 1];
|
|
311
311
|
if (positionIndex > 0 && nextDropPosition !== dropPositions[2]) return {
|
|
312
|
-
type:
|
|
312
|
+
type: 'item',
|
|
313
313
|
key: target.key,
|
|
314
314
|
dropPosition: nextDropPosition
|
|
315
315
|
};
|
|
316
316
|
// If the last drop position was 'before', then 'after' on the previous key is equivalent.
|
|
317
317
|
// Switch to 'on' instead.
|
|
318
|
-
if (target.dropPosition === dropPositions[0]) dropPosition =
|
|
318
|
+
if (target.dropPosition === dropPositions[0]) dropPosition = 'on';
|
|
319
319
|
} else dropPosition = target.dropPosition;
|
|
320
320
|
}
|
|
321
321
|
if (nextKey == null) {
|
|
322
322
|
if (wrap) return {
|
|
323
|
-
type:
|
|
323
|
+
type: 'root'
|
|
324
324
|
};
|
|
325
325
|
return null;
|
|
326
326
|
}
|
|
327
327
|
return {
|
|
328
|
-
type:
|
|
328
|
+
type: 'item',
|
|
329
329
|
key: nextKey,
|
|
330
330
|
dropPosition: dropPosition
|
|
331
331
|
};
|
|
@@ -346,9 +346,9 @@ function $4b52e4eff84e5217$export$f4e2f423c21f7b04(props, state, ref) {
|
|
|
346
346
|
isInternal: isInternal,
|
|
347
347
|
draggingKeys: draggingKeys
|
|
348
348
|
});
|
|
349
|
-
if (target.type ===
|
|
350
|
-
}while (operation ===
|
|
351
|
-
if (operation ===
|
|
349
|
+
if (target.type === 'root') seenRoot++;
|
|
350
|
+
}while (operation === 'cancel' && !localState.state.isDropTarget(target) && seenRoot < 2);
|
|
351
|
+
if (operation === 'cancel') return null;
|
|
352
352
|
return target;
|
|
353
353
|
};
|
|
354
354
|
return $67560de7c78cb232$export$c28d9fb4a54e471a({
|
|
@@ -368,7 +368,7 @@ function $4b52e4eff84e5217$export$f4e2f423c21f7b04(props, state, ref) {
|
|
|
368
368
|
// Check if any of the targets accept the drop.
|
|
369
369
|
// TODO: should we have a faster way of doing this or e.g. for pagination?
|
|
370
370
|
let target = nextValidTarget(null, types, allowedOperations, getNextTarget);
|
|
371
|
-
return target ?
|
|
371
|
+
return target ? 'move' : 'cancel';
|
|
372
372
|
},
|
|
373
373
|
onDropEnter (e, drag) {
|
|
374
374
|
let types = (0, $7252cd45fc48c07c$export$e1d41611756c6326)(drag.items);
|
|
@@ -379,22 +379,22 @@ function $4b52e4eff84e5217$export$f4e2f423c21f7b04(props, state, ref) {
|
|
|
379
379
|
// When entering the droppable collection for the first time, the default drop target
|
|
380
380
|
// is after the focused key.
|
|
381
381
|
let key = selectionManager.focusedKey;
|
|
382
|
-
let dropPosition =
|
|
382
|
+
let dropPosition = 'after';
|
|
383
383
|
// If the focused key is a cell, get the parent item instead.
|
|
384
384
|
// For now, we assume that individual cells cannot be dropped on.
|
|
385
385
|
let item = localState.state.collection.getItem(key);
|
|
386
|
-
if ((item === null || item === void 0 ? void 0 : item.type) ===
|
|
386
|
+
if ((item === null || item === void 0 ? void 0 : item.type) === 'cell') key = item.parentKey;
|
|
387
387
|
// If the focused item is also selected, the default drop target is after the last selected item.
|
|
388
388
|
// But if the focused key is the first selected item, then default to before the first selected item.
|
|
389
389
|
// This is to make reordering lists slightly easier. If you select top down, we assume you want to
|
|
390
390
|
// move the items down. If you select bottom up, we assume you want to move the items up.
|
|
391
391
|
if (selectionManager.isSelected(key)) {
|
|
392
|
-
if (selectionManager.selectedKeys.size > 1 && selectionManager.firstSelectedKey === key) dropPosition =
|
|
392
|
+
if (selectionManager.selectedKeys.size > 1 && selectionManager.firstSelectedKey === key) dropPosition = 'before';
|
|
393
393
|
else key = selectionManager.lastSelectedKey;
|
|
394
394
|
}
|
|
395
395
|
if (key != null) {
|
|
396
396
|
target = {
|
|
397
|
-
type:
|
|
397
|
+
type: 'item',
|
|
398
398
|
key: key,
|
|
399
399
|
dropPosition: dropPosition
|
|
400
400
|
};
|
|
@@ -408,7 +408,7 @@ function $4b52e4eff84e5217$export$f4e2f423c21f7b04(props, state, ref) {
|
|
|
408
408
|
allowedOperations: drag.allowedDropOperations,
|
|
409
409
|
isInternal: isInternal,
|
|
410
410
|
draggingKeys: draggingKeys
|
|
411
|
-
}) ===
|
|
411
|
+
}) === 'cancel') target = (_nextValidTarget = nextValidTarget(target, types, drag.allowedDropOperations, getNextTarget, false)) !== null && _nextValidTarget !== void 0 ? _nextValidTarget : nextValidTarget(target, types, drag.allowedDropOperations, getPreviousTarget, false);
|
|
412
412
|
}
|
|
413
413
|
// If no focused key, then start from the root.
|
|
414
414
|
if (!target) target = nextValidTarget(null, types, drag.allowedDropOperations, getNextTarget);
|
|
@@ -423,8 +423,8 @@ function $4b52e4eff84e5217$export$f4e2f423c21f7b04(props, state, ref) {
|
|
|
423
423
|
},
|
|
424
424
|
onDropActivate (e) {
|
|
425
425
|
var _localState_state_target, _localState_state_target1;
|
|
426
|
-
if (((_localState_state_target = localState.state.target) === null || _localState_state_target === void 0 ? void 0 : _localState_state_target.type) ===
|
|
427
|
-
type:
|
|
426
|
+
if (((_localState_state_target = localState.state.target) === null || _localState_state_target === void 0 ? void 0 : _localState_state_target.type) === 'item' && ((_localState_state_target1 = localState.state.target) === null || _localState_state_target1 === void 0 ? void 0 : _localState_state_target1.dropPosition) === 'on' && typeof localState.props.onDropActivate === 'function') localState.props.onDropActivate({
|
|
427
|
+
type: 'dropactivate',
|
|
428
428
|
x: e.x,
|
|
429
429
|
y: e.y,
|
|
430
430
|
target: localState.state.target
|
|
@@ -438,57 +438,57 @@ function $4b52e4eff84e5217$export$f4e2f423c21f7b04(props, state, ref) {
|
|
|
438
438
|
let { keyboardDelegate: keyboardDelegate } = localState.props;
|
|
439
439
|
let types = (0, $7252cd45fc48c07c$export$e1d41611756c6326)(drag.items);
|
|
440
440
|
switch(e.key){
|
|
441
|
-
case
|
|
441
|
+
case 'ArrowDown':
|
|
442
442
|
if (keyboardDelegate.getKeyBelow) {
|
|
443
443
|
let target = nextValidTarget(localState.state.target, types, drag.allowedDropOperations, getNextTarget);
|
|
444
444
|
localState.state.setTarget(target);
|
|
445
445
|
}
|
|
446
446
|
break;
|
|
447
|
-
case
|
|
447
|
+
case 'ArrowUp':
|
|
448
448
|
if (keyboardDelegate.getKeyAbove) {
|
|
449
449
|
let target = nextValidTarget(localState.state.target, types, drag.allowedDropOperations, getPreviousTarget);
|
|
450
450
|
localState.state.setTarget(target);
|
|
451
451
|
}
|
|
452
452
|
break;
|
|
453
|
-
case
|
|
453
|
+
case 'ArrowLeft':
|
|
454
454
|
if (keyboardDelegate.getKeyLeftOf) {
|
|
455
455
|
let target = nextValidTarget(localState.state.target, types, drag.allowedDropOperations, (target, wrap)=>getPreviousTarget(target, wrap, true));
|
|
456
456
|
localState.state.setTarget(target);
|
|
457
457
|
}
|
|
458
458
|
break;
|
|
459
|
-
case
|
|
459
|
+
case 'ArrowRight':
|
|
460
460
|
if (keyboardDelegate.getKeyRightOf) {
|
|
461
461
|
let target = nextValidTarget(localState.state.target, types, drag.allowedDropOperations, (target, wrap)=>getNextTarget(target, wrap, true));
|
|
462
462
|
localState.state.setTarget(target);
|
|
463
463
|
}
|
|
464
464
|
break;
|
|
465
|
-
case
|
|
465
|
+
case 'Home':
|
|
466
466
|
if (keyboardDelegate.getFirstKey) {
|
|
467
467
|
let target = nextValidTarget(null, types, drag.allowedDropOperations, getNextTarget);
|
|
468
468
|
localState.state.setTarget(target);
|
|
469
469
|
}
|
|
470
470
|
break;
|
|
471
|
-
case
|
|
471
|
+
case 'End':
|
|
472
472
|
if (keyboardDelegate.getLastKey) {
|
|
473
473
|
let target = nextValidTarget(null, types, drag.allowedDropOperations, getPreviousTarget);
|
|
474
474
|
localState.state.setTarget(target);
|
|
475
475
|
}
|
|
476
476
|
break;
|
|
477
|
-
case
|
|
477
|
+
case 'PageDown':
|
|
478
478
|
if (keyboardDelegate.getKeyPageBelow) {
|
|
479
479
|
let target = localState.state.target;
|
|
480
480
|
if (!target) target = nextValidTarget(null, types, drag.allowedDropOperations, getNextTarget);
|
|
481
481
|
else {
|
|
482
482
|
// If on the root, go to the item a page below the top. Otherwise a page below the current item.
|
|
483
|
-
let nextKey = keyboardDelegate.getKeyPageBelow(target.type ===
|
|
484
|
-
let dropPosition = target.type ===
|
|
483
|
+
let nextKey = keyboardDelegate.getKeyPageBelow(target.type === 'item' ? target.key : keyboardDelegate.getFirstKey());
|
|
484
|
+
let dropPosition = target.type === 'item' ? target.dropPosition : 'after';
|
|
485
485
|
// If there is no next key, or we are starting on the last key, jump to the last possible position.
|
|
486
|
-
if (nextKey == null || target.type ===
|
|
486
|
+
if (nextKey == null || target.type === 'item' && target.key === keyboardDelegate.getLastKey()) {
|
|
487
487
|
nextKey = keyboardDelegate.getLastKey();
|
|
488
|
-
dropPosition =
|
|
488
|
+
dropPosition = 'after';
|
|
489
489
|
}
|
|
490
490
|
target = {
|
|
491
|
-
type:
|
|
491
|
+
type: 'item',
|
|
492
492
|
key: nextKey,
|
|
493
493
|
dropPosition: dropPosition
|
|
494
494
|
};
|
|
@@ -504,30 +504,30 @@ function $4b52e4eff84e5217$export$f4e2f423c21f7b04(props, state, ref) {
|
|
|
504
504
|
draggingKeys: draggingKeys
|
|
505
505
|
});
|
|
506
506
|
var _nextValidTarget;
|
|
507
|
-
if (operation ===
|
|
507
|
+
if (operation === 'cancel') target = (_nextValidTarget = nextValidTarget(target, types, drag.allowedDropOperations, getNextTarget, false)) !== null && _nextValidTarget !== void 0 ? _nextValidTarget : nextValidTarget(target, types, drag.allowedDropOperations, getPreviousTarget, false);
|
|
508
508
|
}
|
|
509
509
|
localState.state.setTarget(target !== null && target !== void 0 ? target : localState.state.target);
|
|
510
510
|
}
|
|
511
511
|
break;
|
|
512
|
-
case
|
|
512
|
+
case 'PageUp':
|
|
513
513
|
{
|
|
514
514
|
if (!keyboardDelegate.getKeyPageAbove) break;
|
|
515
515
|
let target = localState.state.target;
|
|
516
516
|
if (!target) target = nextValidTarget(null, types, drag.allowedDropOperations, getPreviousTarget);
|
|
517
|
-
else if (target.type ===
|
|
517
|
+
else if (target.type === 'item') {
|
|
518
518
|
// If at the top already, switch to the root. Otherwise navigate a page up.
|
|
519
519
|
if (target.key === keyboardDelegate.getFirstKey()) target = {
|
|
520
|
-
type:
|
|
520
|
+
type: 'root'
|
|
521
521
|
};
|
|
522
522
|
else {
|
|
523
523
|
let nextKey = keyboardDelegate.getKeyPageAbove(target.key);
|
|
524
524
|
let dropPosition = target.dropPosition;
|
|
525
525
|
if (nextKey == null) {
|
|
526
526
|
nextKey = keyboardDelegate.getFirstKey();
|
|
527
|
-
dropPosition =
|
|
527
|
+
dropPosition = 'before';
|
|
528
528
|
}
|
|
529
529
|
target = {
|
|
530
|
-
type:
|
|
530
|
+
type: 'item',
|
|
531
531
|
key: nextKey,
|
|
532
532
|
dropPosition: dropPosition
|
|
533
533
|
};
|
|
@@ -544,7 +544,7 @@ function $4b52e4eff84e5217$export$f4e2f423c21f7b04(props, state, ref) {
|
|
|
544
544
|
draggingKeys: draggingKeys
|
|
545
545
|
});
|
|
546
546
|
var _nextValidTarget1;
|
|
547
|
-
if (operation ===
|
|
547
|
+
if (operation === 'cancel') target = (_nextValidTarget1 = nextValidTarget(target, types, drag.allowedDropOperations, getPreviousTarget, false)) !== null && _nextValidTarget1 !== void 0 ? _nextValidTarget1 : nextValidTarget(target, types, drag.allowedDropOperations, getNextTarget, false);
|
|
548
548
|
}
|
|
549
549
|
localState.state.setTarget(target !== null && target !== void 0 ? target : localState.state.target);
|
|
550
550
|
break;
|
|
@@ -568,7 +568,7 @@ function $4b52e4eff84e5217$export$f4e2f423c21f7b04(props, state, ref) {
|
|
|
568
568
|
id: id,
|
|
569
569
|
// Remove description from collection element. If dropping on the entire collection,
|
|
570
570
|
// there should be a drop indicator that has this description, so no need to double announce.
|
|
571
|
-
|
|
571
|
+
'aria-describedby': null
|
|
572
572
|
})
|
|
573
573
|
};
|
|
574
574
|
}
|