@react-aria/dnd 3.11.5 → 3.12.0
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/import.mjs +8 -18
- package/dist/main.js +22 -32
- package/dist/main.js.map +1 -1
- package/dist/module.js +8 -18
- package/dist/module.js.map +1 -1
- package/dist/types/src/index.d.ts +13 -0
- package/package.json +16 -21
- package/src/index.ts +13 -56
- package/dist/DragManager.main.js +0 -519
- package/dist/DragManager.main.js.map +0 -1
- package/dist/DragManager.mjs +0 -510
- package/dist/DragManager.module.js +0 -510
- package/dist/DragManager.module.js.map +0 -1
- package/dist/DragPreview.main.js +0 -73
- package/dist/DragPreview.main.js.map +0 -1
- package/dist/DragPreview.mjs +0 -64
- package/dist/DragPreview.module.js +0 -64
- package/dist/DragPreview.module.js.map +0 -1
- package/dist/DropTargetKeyboardNavigation.main.js +0 -205
- package/dist/DropTargetKeyboardNavigation.main.js.map +0 -1
- package/dist/DropTargetKeyboardNavigation.mjs +0 -200
- package/dist/DropTargetKeyboardNavigation.module.js +0 -200
- package/dist/DropTargetKeyboardNavigation.module.js.map +0 -1
- package/dist/ListDropTargetDelegate.main.js +0 -129
- package/dist/ListDropTargetDelegate.main.js.map +0 -1
- package/dist/ListDropTargetDelegate.mjs +0 -124
- package/dist/ListDropTargetDelegate.module.js +0 -124
- package/dist/ListDropTargetDelegate.module.js.map +0 -1
- package/dist/ar-AE.main.js +0 -44
- package/dist/ar-AE.main.js.map +0 -1
- package/dist/ar-AE.mjs +0 -46
- package/dist/ar-AE.module.js +0 -46
- package/dist/ar-AE.module.js.map +0 -1
- package/dist/bg-BG.main.js +0 -44
- package/dist/bg-BG.main.js.map +0 -1
- package/dist/bg-BG.mjs +0 -46
- package/dist/bg-BG.module.js +0 -46
- package/dist/bg-BG.module.js.map +0 -1
- package/dist/constants.main.js +0 -64
- package/dist/constants.main.js.map +0 -1
- package/dist/constants.mjs +0 -52
- package/dist/constants.module.js +0 -52
- package/dist/constants.module.js.map +0 -1
- package/dist/cs-CZ.main.js +0 -45
- package/dist/cs-CZ.main.js.map +0 -1
- package/dist/cs-CZ.mjs +0 -47
- package/dist/cs-CZ.module.js +0 -47
- package/dist/cs-CZ.module.js.map +0 -1
- package/dist/da-DK.main.js +0 -44
- package/dist/da-DK.main.js.map +0 -1
- package/dist/da-DK.mjs +0 -46
- package/dist/da-DK.module.js +0 -46
- package/dist/da-DK.module.js.map +0 -1
- package/dist/de-DE.main.js +0 -44
- package/dist/de-DE.main.js.map +0 -1
- package/dist/de-DE.mjs +0 -46
- package/dist/de-DE.module.js +0 -46
- package/dist/de-DE.module.js.map +0 -1
- package/dist/el-GR.main.js +0 -44
- package/dist/el-GR.main.js.map +0 -1
- package/dist/el-GR.mjs +0 -46
- package/dist/el-GR.module.js +0 -46
- package/dist/el-GR.module.js.map +0 -1
- package/dist/en-US.main.js +0 -44
- package/dist/en-US.main.js.map +0 -1
- package/dist/en-US.mjs +0 -46
- package/dist/en-US.module.js +0 -46
- package/dist/en-US.module.js.map +0 -1
- package/dist/es-ES.main.js +0 -44
- package/dist/es-ES.main.js.map +0 -1
- package/dist/es-ES.mjs +0 -46
- package/dist/es-ES.module.js +0 -46
- package/dist/es-ES.module.js.map +0 -1
- package/dist/et-EE.main.js +0 -44
- package/dist/et-EE.main.js.map +0 -1
- package/dist/et-EE.mjs +0 -46
- package/dist/et-EE.module.js +0 -46
- package/dist/et-EE.module.js.map +0 -1
- package/dist/fi-FI.main.js +0 -44
- package/dist/fi-FI.main.js.map +0 -1
- package/dist/fi-FI.mjs +0 -46
- package/dist/fi-FI.module.js +0 -46
- package/dist/fi-FI.module.js.map +0 -1
- package/dist/fr-FR.main.js +0 -44
- package/dist/fr-FR.main.js.map +0 -1
- package/dist/fr-FR.mjs +0 -46
- package/dist/fr-FR.module.js +0 -46
- package/dist/fr-FR.module.js.map +0 -1
- package/dist/he-IL.main.js +0 -44
- package/dist/he-IL.main.js.map +0 -1
- package/dist/he-IL.mjs +0 -46
- package/dist/he-IL.module.js +0 -46
- package/dist/he-IL.module.js.map +0 -1
- package/dist/hr-HR.main.js +0 -44
- package/dist/hr-HR.main.js.map +0 -1
- package/dist/hr-HR.mjs +0 -46
- package/dist/hr-HR.module.js +0 -46
- package/dist/hr-HR.module.js.map +0 -1
- package/dist/hu-HU.main.js +0 -44
- package/dist/hu-HU.main.js.map +0 -1
- package/dist/hu-HU.mjs +0 -46
- package/dist/hu-HU.module.js +0 -46
- package/dist/hu-HU.module.js.map +0 -1
- package/dist/intlStrings.main.js +0 -108
- package/dist/intlStrings.main.js.map +0 -1
- package/dist/intlStrings.mjs +0 -110
- package/dist/intlStrings.module.js +0 -110
- package/dist/intlStrings.module.js.map +0 -1
- package/dist/it-IT.main.js +0 -44
- package/dist/it-IT.main.js.map +0 -1
- package/dist/it-IT.mjs +0 -46
- package/dist/it-IT.module.js +0 -46
- package/dist/it-IT.module.js.map +0 -1
- package/dist/ja-JP.main.js +0 -44
- package/dist/ja-JP.main.js.map +0 -1
- package/dist/ja-JP.mjs +0 -46
- package/dist/ja-JP.module.js +0 -46
- package/dist/ja-JP.module.js.map +0 -1
- package/dist/ko-KR.main.js +0 -44
- package/dist/ko-KR.main.js.map +0 -1
- package/dist/ko-KR.mjs +0 -46
- package/dist/ko-KR.module.js +0 -46
- package/dist/ko-KR.module.js.map +0 -1
- package/dist/lt-LT.main.js +0 -44
- package/dist/lt-LT.main.js.map +0 -1
- package/dist/lt-LT.mjs +0 -46
- package/dist/lt-LT.module.js +0 -46
- package/dist/lt-LT.module.js.map +0 -1
- package/dist/lv-LV.main.js +0 -44
- package/dist/lv-LV.main.js.map +0 -1
- package/dist/lv-LV.mjs +0 -46
- package/dist/lv-LV.module.js +0 -46
- package/dist/lv-LV.module.js.map +0 -1
- package/dist/nb-NO.main.js +0 -44
- package/dist/nb-NO.main.js.map +0 -1
- package/dist/nb-NO.mjs +0 -46
- package/dist/nb-NO.module.js +0 -46
- package/dist/nb-NO.module.js.map +0 -1
- package/dist/nl-NL.main.js +0 -44
- package/dist/nl-NL.main.js.map +0 -1
- package/dist/nl-NL.mjs +0 -46
- package/dist/nl-NL.module.js +0 -46
- package/dist/nl-NL.module.js.map +0 -1
- package/dist/pl-PL.main.js +0 -44
- package/dist/pl-PL.main.js.map +0 -1
- package/dist/pl-PL.mjs +0 -46
- package/dist/pl-PL.module.js +0 -46
- package/dist/pl-PL.module.js.map +0 -1
- package/dist/pt-BR.main.js +0 -44
- package/dist/pt-BR.main.js.map +0 -1
- package/dist/pt-BR.mjs +0 -46
- package/dist/pt-BR.module.js +0 -46
- package/dist/pt-BR.module.js.map +0 -1
- package/dist/pt-PT.main.js +0 -44
- package/dist/pt-PT.main.js.map +0 -1
- package/dist/pt-PT.mjs +0 -46
- package/dist/pt-PT.module.js +0 -46
- package/dist/pt-PT.module.js.map +0 -1
- package/dist/ro-RO.main.js +0 -44
- package/dist/ro-RO.main.js.map +0 -1
- package/dist/ro-RO.mjs +0 -46
- package/dist/ro-RO.module.js +0 -46
- package/dist/ro-RO.module.js.map +0 -1
- package/dist/ru-RU.main.js +0 -44
- package/dist/ru-RU.main.js.map +0 -1
- package/dist/ru-RU.mjs +0 -46
- package/dist/ru-RU.module.js +0 -46
- package/dist/ru-RU.module.js.map +0 -1
- package/dist/sk-SK.main.js +0 -44
- package/dist/sk-SK.main.js.map +0 -1
- package/dist/sk-SK.mjs +0 -46
- package/dist/sk-SK.module.js +0 -46
- package/dist/sk-SK.module.js.map +0 -1
- package/dist/sl-SI.main.js +0 -44
- package/dist/sl-SI.main.js.map +0 -1
- package/dist/sl-SI.mjs +0 -46
- package/dist/sl-SI.module.js +0 -46
- package/dist/sl-SI.module.js.map +0 -1
- package/dist/sr-SP.main.js +0 -44
- package/dist/sr-SP.main.js.map +0 -1
- package/dist/sr-SP.mjs +0 -46
- package/dist/sr-SP.module.js +0 -46
- package/dist/sr-SP.module.js.map +0 -1
- package/dist/sv-SE.main.js +0 -44
- package/dist/sv-SE.main.js.map +0 -1
- package/dist/sv-SE.mjs +0 -46
- package/dist/sv-SE.module.js +0 -46
- package/dist/sv-SE.module.js.map +0 -1
- package/dist/tr-TR.main.js +0 -44
- package/dist/tr-TR.main.js.map +0 -1
- package/dist/tr-TR.mjs +0 -46
- package/dist/tr-TR.module.js +0 -46
- package/dist/tr-TR.module.js.map +0 -1
- package/dist/types.d.ts +0 -244
- package/dist/types.d.ts.map +0 -1
- package/dist/uk-UA.main.js +0 -44
- package/dist/uk-UA.main.js.map +0 -1
- package/dist/uk-UA.mjs +0 -46
- package/dist/uk-UA.module.js +0 -46
- package/dist/uk-UA.module.js.map +0 -1
- package/dist/useAutoScroll.main.js +0 -89
- package/dist/useAutoScroll.main.js.map +0 -1
- package/dist/useAutoScroll.mjs +0 -84
- package/dist/useAutoScroll.module.js +0 -84
- package/dist/useAutoScroll.module.js.map +0 -1
- package/dist/useClipboard.main.js +0 -111
- package/dist/useClipboard.main.js.map +0 -1
- package/dist/useClipboard.mjs +0 -106
- package/dist/useClipboard.module.js +0 -106
- package/dist/useClipboard.module.js.map +0 -1
- package/dist/useDrag.main.js +0 -307
- package/dist/useDrag.main.js.map +0 -1
- package/dist/useDrag.mjs +0 -302
- package/dist/useDrag.module.js +0 -302
- package/dist/useDrag.module.js.map +0 -1
- package/dist/useDraggableCollection.main.js +0 -27
- package/dist/useDraggableCollection.main.js.map +0 -1
- package/dist/useDraggableCollection.mjs +0 -22
- package/dist/useDraggableCollection.module.js +0 -22
- package/dist/useDraggableCollection.module.js.map +0 -1
- package/dist/useDraggableItem.main.js +0 -128
- package/dist/useDraggableItem.main.js.map +0 -1
- package/dist/useDraggableItem.mjs +0 -123
- package/dist/useDraggableItem.module.js +0 -123
- package/dist/useDraggableItem.module.js.map +0 -1
- package/dist/useDrop.main.js +0 -295
- package/dist/useDrop.main.js.map +0 -1
- package/dist/useDrop.mjs +0 -290
- package/dist/useDrop.module.js +0 -290
- package/dist/useDrop.module.js.map +0 -1
- package/dist/useDropIndicator.main.js +0 -102
- package/dist/useDropIndicator.main.js.map +0 -1
- package/dist/useDropIndicator.mjs +0 -97
- package/dist/useDropIndicator.module.js +0 -97
- package/dist/useDropIndicator.module.js.map +0 -1
- package/dist/useDroppableCollection.main.js +0 -536
- package/dist/useDroppableCollection.main.js.map +0 -1
- package/dist/useDroppableCollection.mjs +0 -531
- package/dist/useDroppableCollection.module.js +0 -531
- package/dist/useDroppableCollection.module.js.map +0 -1
- package/dist/useDroppableItem.main.js +0 -81
- package/dist/useDroppableItem.main.js.map +0 -1
- package/dist/useDroppableItem.mjs +0 -76
- package/dist/useDroppableItem.module.js +0 -76
- package/dist/useDroppableItem.module.js.map +0 -1
- package/dist/useVirtualDrop.main.js +0 -56
- package/dist/useVirtualDrop.main.js.map +0 -1
- package/dist/useVirtualDrop.mjs +0 -51
- package/dist/useVirtualDrop.module.js +0 -51
- package/dist/useVirtualDrop.module.js.map +0 -1
- package/dist/utils.main.js +0 -285
- package/dist/utils.main.js.map +0 -1
- package/dist/utils.mjs +0 -257
- package/dist/utils.module.js +0 -257
- package/dist/utils.module.js.map +0 -1
- package/dist/zh-CN.main.js +0 -44
- package/dist/zh-CN.main.js.map +0 -1
- package/dist/zh-CN.mjs +0 -46
- package/dist/zh-CN.module.js +0 -46
- package/dist/zh-CN.module.js.map +0 -1
- package/dist/zh-TW.main.js +0 -44
- package/dist/zh-TW.main.js.map +0 -1
- package/dist/zh-TW.mjs +0 -46
- package/dist/zh-TW.module.js +0 -46
- package/dist/zh-TW.module.js.map +0 -1
- package/src/DragManager.ts +0 -656
- package/src/DragPreview.tsx +0 -81
- package/src/DropTargetKeyboardNavigation.ts +0 -282
- package/src/ListDropTargetDelegate.ts +0 -182
- package/src/constants.ts +0 -85
- package/src/useAutoScroll.ts +0 -105
- package/src/useClipboard.ts +0 -151
- package/src/useDrag.ts +0 -390
- package/src/useDraggableCollection.ts +0 -29
- package/src/useDraggableItem.ts +0 -158
- package/src/useDrop.ts +0 -444
- package/src/useDropIndicator.ts +0 -124
- package/src/useDroppableCollection.ts +0 -665
- package/src/useDroppableItem.ts +0 -86
- package/src/useVirtualDrop.ts +0 -49
- package/src/utils.ts +0 -385
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import {useDragSession as $67560de7c78cb232$export$418e185dd3f1b968} from "./DragManager.module.js";
|
|
2
|
-
import {getDroppableCollectionId as $7252cd45fc48c07c$export$3093291712f09a77} from "./utils.module.js";
|
|
3
|
-
import $8HwJV$intlStringsmodulejs from "./intlStrings.module.js";
|
|
4
|
-
import {useDroppableItem as $bfaab576ce1c580e$export$f7b0c5d28b66b6a5} from "./useDroppableItem.module.js";
|
|
5
|
-
import {useId as $8HwJV$useId} from "@react-aria/utils";
|
|
6
|
-
import {useLocalizedStringFormatter as $8HwJV$useLocalizedStringFormatter} from "@react-aria/i18n";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function $parcel$interopDefault(a) {
|
|
10
|
-
return a && a.__esModule ? a.default : a;
|
|
11
|
-
}
|
|
12
|
-
/*
|
|
13
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
14
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
15
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
16
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
17
|
-
*
|
|
18
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
19
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
20
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
21
|
-
* governing permissions and limitations under the License.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
function $ddf25448c71fc93a$export$8d0e41d2815afac5(props, state, ref) {
|
|
29
|
-
let { target: target } = props;
|
|
30
|
-
let { collection: collection } = state;
|
|
31
|
-
let stringFormatter = (0, $8HwJV$useLocalizedStringFormatter)((0, ($parcel$interopDefault($8HwJV$intlStringsmodulejs))), '@react-aria/dnd');
|
|
32
|
-
let dragSession = $67560de7c78cb232$export$418e185dd3f1b968();
|
|
33
|
-
let { dropProps: dropProps } = (0, $bfaab576ce1c580e$export$f7b0c5d28b66b6a5)(props, state, ref);
|
|
34
|
-
let id = (0, $8HwJV$useId)();
|
|
35
|
-
let getText = (key)=>{
|
|
36
|
-
var _collection_getTextValue, _collection_getItem;
|
|
37
|
-
var _collection_getTextValue1, _ref;
|
|
38
|
-
if (key == null) return '';
|
|
39
|
-
else return (_ref = (_collection_getTextValue1 = (_collection_getTextValue = collection.getTextValue) === null || _collection_getTextValue === void 0 ? void 0 : _collection_getTextValue.call(collection, key)) !== null && _collection_getTextValue1 !== void 0 ? _collection_getTextValue1 : (_collection_getItem = collection.getItem(key)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.textValue) !== null && _ref !== void 0 ? _ref : '';
|
|
40
|
-
};
|
|
41
|
-
let label = '';
|
|
42
|
-
let labelledBy;
|
|
43
|
-
if (target.type === 'root') {
|
|
44
|
-
label = stringFormatter.format('dropOnRoot');
|
|
45
|
-
labelledBy = `${id} ${(0, $7252cd45fc48c07c$export$3093291712f09a77)(state)}`;
|
|
46
|
-
} else if (target.dropPosition === 'on') label = stringFormatter.format('dropOnItem', {
|
|
47
|
-
itemText: getText(target.key)
|
|
48
|
-
});
|
|
49
|
-
else {
|
|
50
|
-
let before;
|
|
51
|
-
let after;
|
|
52
|
-
if (target.dropPosition === 'before') {
|
|
53
|
-
var _collection_getItem;
|
|
54
|
-
let prevKey = (_collection_getItem = collection.getItem(target.key)) === null || _collection_getItem === void 0 ? void 0 : _collection_getItem.prevKey;
|
|
55
|
-
let prevNode = prevKey != null ? collection.getItem(prevKey) : null;
|
|
56
|
-
before = (prevNode === null || prevNode === void 0 ? void 0 : prevNode.type) === 'item' ? prevNode.key : null;
|
|
57
|
-
} else before = target.key;
|
|
58
|
-
if (target.dropPosition === 'after') {
|
|
59
|
-
var _collection_getItem1;
|
|
60
|
-
let nextKey = (_collection_getItem1 = collection.getItem(target.key)) === null || _collection_getItem1 === void 0 ? void 0 : _collection_getItem1.nextKey;
|
|
61
|
-
let nextNode = nextKey != null ? collection.getItem(nextKey) : null;
|
|
62
|
-
after = (nextNode === null || nextNode === void 0 ? void 0 : nextNode.type) === 'item' ? nextNode.key : null;
|
|
63
|
-
} else after = target.key;
|
|
64
|
-
if (before != null && after != null) label = stringFormatter.format('insertBetween', {
|
|
65
|
-
beforeItemText: getText(before),
|
|
66
|
-
afterItemText: getText(after)
|
|
67
|
-
});
|
|
68
|
-
else if (before != null) label = stringFormatter.format('insertAfter', {
|
|
69
|
-
itemText: getText(before)
|
|
70
|
-
});
|
|
71
|
-
else if (after != null) label = stringFormatter.format('insertBefore', {
|
|
72
|
-
itemText: getText(after)
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
let isDropTarget = state.isDropTarget(target);
|
|
76
|
-
let ariaHidden = !dragSession ? 'true' : dropProps['aria-hidden'];
|
|
77
|
-
return {
|
|
78
|
-
dropIndicatorProps: {
|
|
79
|
-
...dropProps,
|
|
80
|
-
id: id,
|
|
81
|
-
'aria-roledescription': stringFormatter.format('dropIndicator'),
|
|
82
|
-
'aria-label': label,
|
|
83
|
-
'aria-labelledby': labelledBy,
|
|
84
|
-
'aria-hidden': ariaHidden,
|
|
85
|
-
tabIndex: -1
|
|
86
|
-
},
|
|
87
|
-
isDropTarget: isDropTarget,
|
|
88
|
-
// If aria-hidden, we are either not in a drag session or the drop target is invalid.
|
|
89
|
-
// In that case, there's no need to render anything at all unless we need to show the indicator visually.
|
|
90
|
-
// This can happen when dragging using the native DnD API as opposed to keyboard dragging.
|
|
91
|
-
isHidden: !isDropTarget && !!ariaHidden
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
export {$ddf25448c71fc93a$export$8d0e41d2815afac5 as useDropIndicator};
|
|
97
|
-
//# sourceMappingURL=useDropIndicator.module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAmCM,SAAS,0CAAiB,KAAyB,EAAE,KAA+B,EAAE,GAAkC;IAC7H,IAAI,UAAC,MAAM,EAAC,GAAG;IACf,IAAI,cAAC,UAAU,EAAC,GAAG;IAEnB,IAAI,kBAAkB,CAAA,GAAA,kCAA0B,EAAE,CAAA,GAAA,oDAAW,GAAG;IAChE,IAAI,cAAc;IAClB,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,yCAAe,EAAE,OAAO,OAAO;IACjD,IAAI,KAAK,CAAA,GAAA,YAAI;IACb,IAAI,UAAU,CAAC;YAIJ,0BAAkC;YAAlC,2BAAA;QAHT,IAAI,OAAO,MACT,OAAO;aAEP,OAAO,CAAA,OAAA,CAAA,6BAAA,2BAAA,WAAW,YAAY,cAAvB,+CAAA,8BAAA,YAA0B,kBAA1B,uCAAA,6BAAkC,sBAAA,WAAW,OAAO,CAAC,kBAAnB,0CAAA,oBAAyB,SAAS,cAApE,kBAAA,OAAwE;IAEnF;IAEA,IAAI,QAAQ;IACZ,IAAI;IACJ,IAAI,OAAO,IAAI,KAAK,QAAQ;QAC1B,QAAQ,gBAAgB,MAAM,CAAC;QAC/B,aAAa,GAAG,GAAG,CAAC,EAAE,CAAA,GAAA,yCAAuB,EAAE,QAAQ;IACzD,OAAO,IAAI,OAAO,YAAY,KAAK,MACjC,QAAQ,gBAAgB,MAAM,CAAC,cAAc;QAC3C,UAAU,QAAQ,OAAO,GAAG;IAC9B;SACK;QACL,IAAI;QACJ,IAAI;QACJ,IAAI,OAAO,YAAY,KAAK,UAAU;gBACtB;YAAd,IAAI,WAAU,sBAAA,WAAW,OAAO,CAAC,OAAO,GAAG,eAA7B,0CAAA,oBAAgC,OAAO;YACrD,IAAI,WAAW,WAAW,OAAO,WAAW,OAAO,CAAC,WAAW;YAC/D,SAAS,CAAA,qBAAA,+BAAA,SAAU,IAAI,MAAK,SAAS,SAAS,GAAG,GAAG;QACtD,OACE,SAAS,OAAO,GAAG;QAGrB,IAAI,OAAO,YAAY,KAAK,SAAS;gBACrB;YAAd,IAAI,WAAU,uBAAA,WAAW,OAAO,CAAC,OAAO,GAAG,eAA7B,2CAAA,qBAAgC,OAAO;YACrD,IAAI,WAAW,WAAW,OAAO,WAAW,OAAO,CAAC,WAAW;YAC/D,QAAQ,CAAA,qBAAA,+BAAA,SAAU,IAAI,MAAK,SAAS,SAAS,GAAG,GAAG;QACrD,OACE,QAAQ,OAAO,GAAG;QAGpB,IAAI,UAAU,QAAQ,SAAS,MAC7B,QAAQ,gBAAgB,MAAM,CAAC,iBAAiB;YAC9C,gBAAgB,QAAQ;YACxB,eAAe,QAAQ;QACzB;aACK,IAAI,UAAU,MACnB,QAAQ,gBAAgB,MAAM,CAAC,eAAe;YAC5C,UAAU,QAAQ;QACpB;aACK,IAAI,SAAS,MAClB,QAAQ,gBAAgB,MAAM,CAAC,gBAAgB;YAC7C,UAAU,QAAQ;QACpB;IAEJ;IAEA,IAAI,eAAe,MAAM,YAAY,CAAC;IACtC,IAAI,aAAa,CAAC,cAAc,SAAS,SAAS,CAAC,cAAc;IACjE,OAAO;QACL,oBAAoB;YAClB,GAAG,SAAS;gBACZ;YACA,wBAAwB,gBAAgB,MAAM,CAAC;YAC/C,cAAc;YACd,mBAAmB;YACnB,eAAe;YACf,UAAU;QACZ;sBACA;QACA,qFAAqF;QACrF,yGAAyG;QACzG,0FAA0F;QAC1F,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAC/B;AACF","sources":["packages/@react-aria/dnd/src/useDropIndicator.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport * as DragManager from './DragManager';\nimport {DroppableCollectionState} from '@react-stately/dnd';\nimport {DropTarget, FocusableElement, Key, RefObject} from '@react-types/shared';\nimport {getDroppableCollectionId} from './utils';\nimport {HTMLAttributes} from 'react';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {useDroppableItem} from './useDroppableItem';\nimport {useId} from '@react-aria/utils';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\n\nexport interface DropIndicatorProps {\n /** The drop target that the drop indicator represents. */\n target: DropTarget,\n /** The ref to the activate button. */\n activateButtonRef?: RefObject<FocusableElement | null>\n}\n\nexport interface DropIndicatorAria {\n /** Props for the drop indicator element. */\n dropIndicatorProps: HTMLAttributes<HTMLElement>,\n /** Whether the drop indicator is currently the active drop target. */\n isDropTarget: boolean,\n /**\n * Whether the drop indicator is hidden, both visually and from assistive technology.\n * Use this to determine whether to omit the element from the DOM entirely.\n */\n isHidden: boolean\n}\n\n/**\n * Handles drop interactions for a target within a droppable collection.\n */\nexport function useDropIndicator(props: DropIndicatorProps, state: DroppableCollectionState, ref: RefObject<HTMLElement | null>): DropIndicatorAria {\n let {target} = props;\n let {collection} = state;\n\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/dnd');\n let dragSession = DragManager.useDragSession();\n let {dropProps} = useDroppableItem(props, state, ref);\n let id = useId();\n let getText = (key: Key | null) => {\n if (key == null) {\n return '';\n } else {\n return collection.getTextValue?.(key) ?? collection.getItem(key)?.textValue ?? '';\n }\n };\n\n let label = '';\n let labelledBy: string | undefined;\n if (target.type === 'root') {\n label = stringFormatter.format('dropOnRoot');\n labelledBy = `${id} ${getDroppableCollectionId(state)}`;\n } else if (target.dropPosition === 'on') {\n label = stringFormatter.format('dropOnItem', {\n itemText: getText(target.key)\n });\n } else {\n let before: Key | null | undefined;\n let after: Key | null | undefined;\n if (target.dropPosition === 'before') {\n let prevKey = collection.getItem(target.key)?.prevKey;\n let prevNode = prevKey != null ? collection.getItem(prevKey) : null;\n before = prevNode?.type === 'item' ? prevNode.key : null;\n } else {\n before = target.key;\n }\n\n if (target.dropPosition === 'after') {\n let nextKey = collection.getItem(target.key)?.nextKey;\n let nextNode = nextKey != null ? collection.getItem(nextKey) : null;\n after = nextNode?.type === 'item' ? nextNode.key : null;\n } else {\n after = target.key;\n }\n\n if (before != null && after != null) {\n label = stringFormatter.format('insertBetween', {\n beforeItemText: getText(before),\n afterItemText: getText(after)\n });\n } else if (before != null) {\n label = stringFormatter.format('insertAfter', {\n itemText: getText(before)\n });\n } else if (after != null) {\n label = stringFormatter.format('insertBefore', {\n itemText: getText(after)\n });\n }\n }\n\n let isDropTarget = state.isDropTarget(target);\n let ariaHidden = !dragSession ? 'true' : dropProps['aria-hidden'];\n return {\n dropIndicatorProps: {\n ...dropProps,\n id,\n 'aria-roledescription': stringFormatter.format('dropIndicator'),\n 'aria-label': label,\n 'aria-labelledby': labelledBy,\n 'aria-hidden': ariaHidden,\n tabIndex: -1\n },\n isDropTarget,\n // If aria-hidden, we are either not in a drag session or the drop target is invalid.\n // In that case, there's no need to render anything at all unless we need to show the indicator visually.\n // This can happen when dragging using the native DnD API as opposed to keyboard dragging.\n isHidden: !isDropTarget && !!ariaHidden\n };\n}\n"],"names":[],"version":3,"file":"useDropIndicator.module.js.map"}
|
|
@@ -1,536 +0,0 @@
|
|
|
1
|
-
var $4620ae0dc40f0031$exports = require("./utils.main.js");
|
|
2
|
-
var $28e10663603f5ea1$exports = require("./DragManager.main.js");
|
|
3
|
-
var $6e16de4c92a0f271$exports = require("./DropTargetKeyboardNavigation.main.js");
|
|
4
|
-
var $12cc069a1c69155b$exports = require("./useAutoScroll.main.js");
|
|
5
|
-
var $1ca228bc9257ca16$exports = require("./useDrop.main.js");
|
|
6
|
-
var $foOxf$react = require("react");
|
|
7
|
-
var $foOxf$reactariautils = require("@react-aria/utils");
|
|
8
|
-
var $foOxf$reactariainteractions = require("@react-aria/interactions");
|
|
9
|
-
var $foOxf$reactariai18n = require("@react-aria/i18n");
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
function $parcel$export(e, n, v, s) {
|
|
13
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
$parcel$export(module.exports, "useDroppableCollection", () => $7f93a158ac20b90a$export$f4e2f423c21f7b04);
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
function $7f93a158ac20b90a$export$f4e2f423c21f7b04(props, state, ref) {
|
|
37
|
-
let localState = (0, $foOxf$react.useRef)({
|
|
38
|
-
props: props,
|
|
39
|
-
state: state,
|
|
40
|
-
nextTarget: null,
|
|
41
|
-
dropOperation: null
|
|
42
|
-
}).current;
|
|
43
|
-
localState.props = props;
|
|
44
|
-
localState.state = state;
|
|
45
|
-
let defaultOnDrop = (0, $foOxf$react.useCallback)(async (e)=>{
|
|
46
|
-
let { onInsert: onInsert, onRootDrop: onRootDrop, onItemDrop: onItemDrop, onReorder: onReorder, onMove: onMove, acceptedDragTypes: acceptedDragTypes = 'all', shouldAcceptItemDrop: shouldAcceptItemDrop } = localState.props;
|
|
47
|
-
let { draggingKeys: draggingKeys } = (0, $4620ae0dc40f0031$exports.globalDndState);
|
|
48
|
-
let isInternal = (0, $4620ae0dc40f0031$exports.isInternalDropOperation)(ref);
|
|
49
|
-
let { target: target, dropOperation: dropOperation, items: items } = e;
|
|
50
|
-
let filteredItems = items;
|
|
51
|
-
if (acceptedDragTypes !== 'all' || shouldAcceptItemDrop) filteredItems = items.filter((item)=>{
|
|
52
|
-
let itemTypes;
|
|
53
|
-
if (item.kind === 'directory') itemTypes = new Set([
|
|
54
|
-
(0, $4620ae0dc40f0031$exports.DIRECTORY_DRAG_TYPE)
|
|
55
|
-
]);
|
|
56
|
-
else itemTypes = item.kind === 'file' ? new Set([
|
|
57
|
-
item.type
|
|
58
|
-
]) : item.types;
|
|
59
|
-
if (acceptedDragTypes === 'all' || acceptedDragTypes.some((type)=>itemTypes.has(type))) {
|
|
60
|
-
// 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
|
|
61
|
-
// than the droppable collection itself
|
|
62
|
-
if (target.type === 'item' && target.dropPosition === 'on' && shouldAcceptItemDrop) return shouldAcceptItemDrop(target, itemTypes);
|
|
63
|
-
return true;
|
|
64
|
-
}
|
|
65
|
-
return false;
|
|
66
|
-
});
|
|
67
|
-
if (filteredItems.length > 0) {
|
|
68
|
-
if (target.type === 'root' && onRootDrop) await onRootDrop({
|
|
69
|
-
items: filteredItems,
|
|
70
|
-
dropOperation: dropOperation
|
|
71
|
-
});
|
|
72
|
-
if (target.type === 'item') {
|
|
73
|
-
if (target.dropPosition === 'on' && onItemDrop) await onItemDrop({
|
|
74
|
-
items: filteredItems,
|
|
75
|
-
dropOperation: dropOperation,
|
|
76
|
-
isInternal: isInternal,
|
|
77
|
-
target: target
|
|
78
|
-
});
|
|
79
|
-
if (onMove && isInternal) await onMove({
|
|
80
|
-
keys: draggingKeys,
|
|
81
|
-
dropOperation: dropOperation,
|
|
82
|
-
target: target
|
|
83
|
-
});
|
|
84
|
-
if (target.dropPosition !== 'on') {
|
|
85
|
-
if (!isInternal && onInsert) await onInsert({
|
|
86
|
-
items: filteredItems,
|
|
87
|
-
dropOperation: dropOperation,
|
|
88
|
-
target: target
|
|
89
|
-
});
|
|
90
|
-
if (isInternal && onReorder) await onReorder({
|
|
91
|
-
keys: draggingKeys,
|
|
92
|
-
dropOperation: dropOperation,
|
|
93
|
-
target: target
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}, [
|
|
99
|
-
localState,
|
|
100
|
-
ref
|
|
101
|
-
]);
|
|
102
|
-
let autoScroll = (0, $12cc069a1c69155b$exports.useAutoScroll)(ref);
|
|
103
|
-
let { dropProps: dropProps } = (0, $1ca228bc9257ca16$exports.useDrop)({
|
|
104
|
-
ref: ref,
|
|
105
|
-
onDropEnter () {
|
|
106
|
-
if (localState.nextTarget != null) state.setTarget(localState.nextTarget);
|
|
107
|
-
},
|
|
108
|
-
onDropMove (e) {
|
|
109
|
-
if (localState.nextTarget != null) state.setTarget(localState.nextTarget);
|
|
110
|
-
autoScroll.move(e.x, e.y);
|
|
111
|
-
},
|
|
112
|
-
getDropOperationForPoint (types, allowedOperations, x, y) {
|
|
113
|
-
let { draggingKeys: draggingKeys, dropCollectionRef: dropCollectionRef } = (0, $4620ae0dc40f0031$exports.globalDndState);
|
|
114
|
-
let isInternal = (0, $4620ae0dc40f0031$exports.isInternalDropOperation)(ref);
|
|
115
|
-
let isValidDropTarget = (target)=>state.getDropOperation({
|
|
116
|
-
target: target,
|
|
117
|
-
types: types,
|
|
118
|
-
allowedOperations: allowedOperations,
|
|
119
|
-
isInternal: isInternal,
|
|
120
|
-
draggingKeys: draggingKeys
|
|
121
|
-
}) !== 'cancel';
|
|
122
|
-
let target = props.dropTargetDelegate.getDropTargetFromPoint(x, y, isValidDropTarget);
|
|
123
|
-
if (!target) {
|
|
124
|
-
localState.dropOperation = 'cancel';
|
|
125
|
-
localState.nextTarget = null;
|
|
126
|
-
return 'cancel';
|
|
127
|
-
}
|
|
128
|
-
localState.dropOperation = state.getDropOperation({
|
|
129
|
-
target: target,
|
|
130
|
-
types: types,
|
|
131
|
-
allowedOperations: allowedOperations,
|
|
132
|
-
isInternal: isInternal,
|
|
133
|
-
draggingKeys: draggingKeys
|
|
134
|
-
});
|
|
135
|
-
// If the target doesn't accept the drop, see if the root accepts it instead.
|
|
136
|
-
if (localState.dropOperation === 'cancel') {
|
|
137
|
-
let rootTarget = {
|
|
138
|
-
type: 'root'
|
|
139
|
-
};
|
|
140
|
-
let dropOperation = state.getDropOperation({
|
|
141
|
-
target: rootTarget,
|
|
142
|
-
types: types,
|
|
143
|
-
allowedOperations: allowedOperations,
|
|
144
|
-
isInternal: isInternal,
|
|
145
|
-
draggingKeys: draggingKeys
|
|
146
|
-
});
|
|
147
|
-
if (dropOperation !== 'cancel') {
|
|
148
|
-
target = rootTarget;
|
|
149
|
-
localState.dropOperation = dropOperation;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
// Only set dropCollectionRef if there is a valid drop target since we cleanup dropCollectionRef in onDropExit
|
|
153
|
-
// which only runs when leaving a valid drop target or if the dropEffect become none (mouse dnd only).
|
|
154
|
-
if (target && localState.dropOperation !== 'cancel' && (ref === null || ref === void 0 ? void 0 : ref.current) !== (dropCollectionRef === null || dropCollectionRef === void 0 ? void 0 : dropCollectionRef.current)) (0, $4620ae0dc40f0031$exports.setDropCollectionRef)(ref);
|
|
155
|
-
localState.nextTarget = localState.dropOperation === 'cancel' ? null : target;
|
|
156
|
-
return localState.dropOperation;
|
|
157
|
-
},
|
|
158
|
-
onDropExit () {
|
|
159
|
-
(0, $4620ae0dc40f0031$exports.setDropCollectionRef)(undefined);
|
|
160
|
-
state.setTarget(null);
|
|
161
|
-
autoScroll.stop();
|
|
162
|
-
},
|
|
163
|
-
onDropActivate (e) {
|
|
164
|
-
var _state_target;
|
|
165
|
-
if (((_state_target = state.target) === null || _state_target === void 0 ? void 0 : _state_target.type) === 'item' && typeof props.onDropActivate === 'function') props.onDropActivate({
|
|
166
|
-
type: 'dropactivate',
|
|
167
|
-
x: e.x,
|
|
168
|
-
y: e.y,
|
|
169
|
-
target: state.target
|
|
170
|
-
});
|
|
171
|
-
},
|
|
172
|
-
onDrop (e) {
|
|
173
|
-
(0, $4620ae0dc40f0031$exports.setDropCollectionRef)(ref);
|
|
174
|
-
if (state.target) onDrop(e, state.target);
|
|
175
|
-
// If there wasn't a collection being tracked as a dragged collection, then we are in a case where a non RSP drag is dropped on a
|
|
176
|
-
// RSP collection and thus we don't need to preserve the global DnD state for onDragEnd
|
|
177
|
-
let { draggingCollectionRef: draggingCollectionRef } = (0, $4620ae0dc40f0031$exports.globalDndState);
|
|
178
|
-
if (draggingCollectionRef == null) (0, $4620ae0dc40f0031$exports.clearGlobalDnDState)();
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
let droppingState = (0, $foOxf$react.useRef)(null);
|
|
182
|
-
let updateFocusAfterDrop = (0, $foOxf$react.useCallback)(()=>{
|
|
183
|
-
let { state: state } = localState;
|
|
184
|
-
if (droppingState.current) {
|
|
185
|
-
var _state_collection_getItem;
|
|
186
|
-
let { target: target, collection: prevCollection, selectedKeys: prevSelectedKeys, focusedKey: prevFocusedKey, isInternal: isInternal, draggingKeys: draggingKeys } = droppingState.current;
|
|
187
|
-
// If an insert occurs during a drop, we want to immediately select these items to give
|
|
188
|
-
// feedback to the user that a drop occurred. Only do this if the selection didn't change
|
|
189
|
-
// since the drop started so we don't override if the user or application did something.
|
|
190
|
-
if (state.collection.size > prevCollection.size && state.selectionManager.isSelectionEqual(prevSelectedKeys)) {
|
|
191
|
-
let newKeys = new Set();
|
|
192
|
-
for (let key of state.collection.getKeys())if (!prevCollection.getItem(key)) newKeys.add(key);
|
|
193
|
-
state.selectionManager.setSelectedKeys(newKeys);
|
|
194
|
-
// If the focused item didn't change since the drop occurred, also focus the first
|
|
195
|
-
// inserted item. If selection is disabled, then also show the focus ring so there
|
|
196
|
-
// is some indication that items were added.
|
|
197
|
-
if (state.selectionManager.focusedKey === prevFocusedKey) {
|
|
198
|
-
let first = newKeys.keys().next().value;
|
|
199
|
-
if (first != null) {
|
|
200
|
-
let item = state.collection.getItem(first);
|
|
201
|
-
// If this is a cell, focus the parent row.
|
|
202
|
-
// eslint-disable-next-line max-depth
|
|
203
|
-
if ((item === null || item === void 0 ? void 0 : item.type) === 'cell') first = item.parentKey;
|
|
204
|
-
// eslint-disable-next-line max-depth
|
|
205
|
-
if (first != null) state.selectionManager.setFocusedKey(first);
|
|
206
|
-
// eslint-disable-next-line max-depth
|
|
207
|
-
if (state.selectionManager.selectionMode === 'none') (0, $foOxf$reactariainteractions.setInteractionModality)('keyboard');
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
} else if (prevFocusedKey != null && state.selectionManager.focusedKey === prevFocusedKey && isInternal && target.type === 'item' && target.dropPosition !== 'on' && draggingKeys.has((_state_collection_getItem = state.collection.getItem(prevFocusedKey)) === null || _state_collection_getItem === void 0 ? void 0 : _state_collection_getItem.parentKey)) {
|
|
211
|
-
var _state_collection_getItem1;
|
|
212
|
-
var _state_collection_getItem_parentKey;
|
|
213
|
-
// Focus row instead of cell when reordering.
|
|
214
|
-
state.selectionManager.setFocusedKey((_state_collection_getItem_parentKey = (_state_collection_getItem1 = state.collection.getItem(prevFocusedKey)) === null || _state_collection_getItem1 === void 0 ? void 0 : _state_collection_getItem1.parentKey) !== null && _state_collection_getItem_parentKey !== void 0 ? _state_collection_getItem_parentKey : null);
|
|
215
|
-
(0, $foOxf$reactariainteractions.setInteractionModality)('keyboard');
|
|
216
|
-
} else if (state.selectionManager.focusedKey === prevFocusedKey && target.type === 'item' && target.dropPosition === 'on' && state.collection.getItem(target.key) != null) {
|
|
217
|
-
// If focus didn't move already (e.g. due to an insert), and the user dropped on an item,
|
|
218
|
-
// focus that item and show the focus ring to give the user feedback that the drop occurred.
|
|
219
|
-
// Also show the focus ring if the focused key is not selected, e.g. in case of a reorder.
|
|
220
|
-
state.selectionManager.setFocusedKey(target.key);
|
|
221
|
-
(0, $foOxf$reactariainteractions.setInteractionModality)('keyboard');
|
|
222
|
-
} else if (state.selectionManager.focusedKey != null && !state.selectionManager.isSelected(state.selectionManager.focusedKey)) (0, $foOxf$reactariainteractions.setInteractionModality)('keyboard');
|
|
223
|
-
state.selectionManager.setFocused(true);
|
|
224
|
-
}
|
|
225
|
-
}, [
|
|
226
|
-
localState
|
|
227
|
-
]);
|
|
228
|
-
let onDrop = (0, $foOxf$react.useCallback)((e, target)=>{
|
|
229
|
-
let { state: state } = localState;
|
|
230
|
-
// Save some state of the collection/selection before the drop occurs so we can compare later.
|
|
231
|
-
droppingState.current = {
|
|
232
|
-
timeout: undefined,
|
|
233
|
-
focusedKey: state.selectionManager.focusedKey,
|
|
234
|
-
collection: state.collection,
|
|
235
|
-
selectedKeys: state.selectionManager.selectedKeys,
|
|
236
|
-
draggingKeys: (0, $4620ae0dc40f0031$exports.globalDndState).draggingKeys,
|
|
237
|
-
isInternal: (0, $4620ae0dc40f0031$exports.isInternalDropOperation)(ref),
|
|
238
|
-
target: target
|
|
239
|
-
};
|
|
240
|
-
let onDropFn = localState.props.onDrop || defaultOnDrop;
|
|
241
|
-
onDropFn({
|
|
242
|
-
type: 'drop',
|
|
243
|
-
x: e.x,
|
|
244
|
-
y: e.y,
|
|
245
|
-
target: target,
|
|
246
|
-
items: e.items,
|
|
247
|
-
dropOperation: e.dropOperation
|
|
248
|
-
});
|
|
249
|
-
// Wait for a short time period after the onDrop is called to allow the data to be read asynchronously
|
|
250
|
-
// and for React to re-render. If the collection didn't already change during this time (handled below),
|
|
251
|
-
// update the focused key here.
|
|
252
|
-
droppingState.current.timeout = setTimeout(()=>{
|
|
253
|
-
updateFocusAfterDrop();
|
|
254
|
-
droppingState.current = null;
|
|
255
|
-
}, 50);
|
|
256
|
-
}, [
|
|
257
|
-
localState,
|
|
258
|
-
defaultOnDrop,
|
|
259
|
-
ref,
|
|
260
|
-
updateFocusAfterDrop
|
|
261
|
-
]);
|
|
262
|
-
(0, $foOxf$react.useEffect)(()=>{
|
|
263
|
-
return ()=>{
|
|
264
|
-
if (droppingState.current) clearTimeout(droppingState.current.timeout);
|
|
265
|
-
};
|
|
266
|
-
}, []);
|
|
267
|
-
(0, $foOxf$reactariautils.useLayoutEffect)(()=>{
|
|
268
|
-
// If the collection changed after a drop, update the focused key.
|
|
269
|
-
if (droppingState.current && state.collection !== droppingState.current.collection) updateFocusAfterDrop();
|
|
270
|
-
});
|
|
271
|
-
let { direction: direction } = (0, $foOxf$reactariai18n.useLocale)();
|
|
272
|
-
(0, $foOxf$react.useEffect)(()=>{
|
|
273
|
-
if (!ref.current) return;
|
|
274
|
-
let getNextTarget = (target, wrap = true, key = 'down')=>{
|
|
275
|
-
return (0, $6e16de4c92a0f271$exports.navigate)(localState.props.keyboardDelegate, localState.state.collection, target, key, direction === 'rtl', wrap);
|
|
276
|
-
};
|
|
277
|
-
let getPreviousTarget = (target, wrap = true)=>{
|
|
278
|
-
return getNextTarget(target, wrap, 'up');
|
|
279
|
-
};
|
|
280
|
-
let nextValidTarget = (target, types, allowedDropOperations, getNextTarget, wrap = true)=>{
|
|
281
|
-
let seenRoot = 0;
|
|
282
|
-
let operation;
|
|
283
|
-
let { draggingKeys: draggingKeys } = (0, $4620ae0dc40f0031$exports.globalDndState);
|
|
284
|
-
let isInternal = (0, $4620ae0dc40f0031$exports.isInternalDropOperation)(ref);
|
|
285
|
-
do {
|
|
286
|
-
let nextTarget = getNextTarget(target, wrap);
|
|
287
|
-
if (!nextTarget) return null;
|
|
288
|
-
target = nextTarget;
|
|
289
|
-
operation = localState.state.getDropOperation({
|
|
290
|
-
target: nextTarget,
|
|
291
|
-
types: types,
|
|
292
|
-
allowedOperations: allowedDropOperations,
|
|
293
|
-
isInternal: isInternal,
|
|
294
|
-
draggingKeys: draggingKeys
|
|
295
|
-
});
|
|
296
|
-
if (target.type === 'root') seenRoot++;
|
|
297
|
-
}while (operation === 'cancel' && !localState.state.isDropTarget(target) && seenRoot < 2);
|
|
298
|
-
if (operation === 'cancel') return null;
|
|
299
|
-
return target;
|
|
300
|
-
};
|
|
301
|
-
return $28e10663603f5ea1$exports.registerDropTarget({
|
|
302
|
-
element: ref.current,
|
|
303
|
-
preventFocusOnDrop: true,
|
|
304
|
-
getDropOperation (types, allowedOperations) {
|
|
305
|
-
if (localState.state.target) {
|
|
306
|
-
let { draggingKeys: draggingKeys } = (0, $4620ae0dc40f0031$exports.globalDndState);
|
|
307
|
-
let isInternal = (0, $4620ae0dc40f0031$exports.isInternalDropOperation)(ref);
|
|
308
|
-
return localState.state.getDropOperation({
|
|
309
|
-
target: localState.state.target,
|
|
310
|
-
types: types,
|
|
311
|
-
allowedOperations: allowedOperations,
|
|
312
|
-
isInternal: isInternal,
|
|
313
|
-
draggingKeys: draggingKeys
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
// Check if any of the targets accept the drop.
|
|
317
|
-
// TODO: should we have a faster way of doing this or e.g. for pagination?
|
|
318
|
-
let target = nextValidTarget(null, types, allowedOperations, getNextTarget);
|
|
319
|
-
return target ? 'move' : 'cancel';
|
|
320
|
-
},
|
|
321
|
-
onDropEnter (e, drag) {
|
|
322
|
-
let types = (0, $4620ae0dc40f0031$exports.getTypes)(drag.items);
|
|
323
|
-
let selectionManager = localState.state.selectionManager;
|
|
324
|
-
let target = null;
|
|
325
|
-
// Update the drop collection ref tracker for useDroppableItem's getDropOperation isInternal check
|
|
326
|
-
(0, $4620ae0dc40f0031$exports.setDropCollectionRef)(ref);
|
|
327
|
-
// When entering the droppable collection for the first time, the default drop target
|
|
328
|
-
// is after the focused key.
|
|
329
|
-
let key = selectionManager.focusedKey;
|
|
330
|
-
let dropPosition = 'after';
|
|
331
|
-
// If the focused key is a cell, get the parent item instead.
|
|
332
|
-
// For now, we assume that individual cells cannot be dropped on.
|
|
333
|
-
let item = key != null ? localState.state.collection.getItem(key) : null;
|
|
334
|
-
if ((item === null || item === void 0 ? void 0 : item.type) === 'cell') key = item.parentKey;
|
|
335
|
-
// If the focused item is also selected, the default drop target is after the last selected item.
|
|
336
|
-
// But if the focused key is the first selected item, then default to before the first selected item.
|
|
337
|
-
// This is to make reordering lists slightly easier. If you select top down, we assume you want to
|
|
338
|
-
// move the items down. If you select bottom up, we assume you want to move the items up.
|
|
339
|
-
if (key != null && selectionManager.isSelected(key)) {
|
|
340
|
-
if (selectionManager.selectedKeys.size > 1 && selectionManager.firstSelectedKey === key) dropPosition = 'before';
|
|
341
|
-
else key = selectionManager.lastSelectedKey;
|
|
342
|
-
}
|
|
343
|
-
if (key != null) {
|
|
344
|
-
target = {
|
|
345
|
-
type: 'item',
|
|
346
|
-
key: key,
|
|
347
|
-
dropPosition: dropPosition
|
|
348
|
-
};
|
|
349
|
-
let { draggingKeys: draggingKeys } = (0, $4620ae0dc40f0031$exports.globalDndState);
|
|
350
|
-
let isInternal = (0, $4620ae0dc40f0031$exports.isInternalDropOperation)(ref);
|
|
351
|
-
var _nextValidTarget;
|
|
352
|
-
// If the default target is not valid, find the next one that is.
|
|
353
|
-
if (localState.state.getDropOperation({
|
|
354
|
-
target: target,
|
|
355
|
-
types: types,
|
|
356
|
-
allowedOperations: drag.allowedDropOperations,
|
|
357
|
-
isInternal: isInternal,
|
|
358
|
-
draggingKeys: draggingKeys
|
|
359
|
-
}) === 'cancel') target = (_nextValidTarget = nextValidTarget(target, types, drag.allowedDropOperations, getNextTarget, false)) !== null && _nextValidTarget !== void 0 ? _nextValidTarget : nextValidTarget(target, types, drag.allowedDropOperations, getPreviousTarget, false);
|
|
360
|
-
}
|
|
361
|
-
// If no focused key, then start from the root.
|
|
362
|
-
if (!target) target = nextValidTarget(null, types, drag.allowedDropOperations, getNextTarget);
|
|
363
|
-
localState.state.setTarget(target);
|
|
364
|
-
},
|
|
365
|
-
onDropExit () {
|
|
366
|
-
(0, $4620ae0dc40f0031$exports.setDropCollectionRef)(undefined);
|
|
367
|
-
localState.state.setTarget(null);
|
|
368
|
-
},
|
|
369
|
-
onDropTargetEnter (target) {
|
|
370
|
-
localState.state.setTarget(target);
|
|
371
|
-
},
|
|
372
|
-
onDropActivate (e, target) {
|
|
373
|
-
if ((target === null || target === void 0 ? void 0 : target.type) === 'item' && (target === null || target === void 0 ? void 0 : target.dropPosition) === 'on' && typeof localState.props.onDropActivate === 'function') localState.props.onDropActivate({
|
|
374
|
-
type: 'dropactivate',
|
|
375
|
-
x: e.x,
|
|
376
|
-
y: e.y,
|
|
377
|
-
target: target
|
|
378
|
-
});
|
|
379
|
-
},
|
|
380
|
-
onDrop (e, target) {
|
|
381
|
-
(0, $4620ae0dc40f0031$exports.setDropCollectionRef)(ref);
|
|
382
|
-
if (localState.state.target) onDrop(e, target || localState.state.target);
|
|
383
|
-
},
|
|
384
|
-
onKeyDown (e, drag) {
|
|
385
|
-
var _localState_props_onKeyDown, _localState_props;
|
|
386
|
-
let { keyboardDelegate: keyboardDelegate } = localState.props;
|
|
387
|
-
let types = (0, $4620ae0dc40f0031$exports.getTypes)(drag.items);
|
|
388
|
-
switch(e.key){
|
|
389
|
-
case 'ArrowDown':
|
|
390
|
-
if (keyboardDelegate.getKeyBelow) {
|
|
391
|
-
let target = nextValidTarget(localState.state.target, types, drag.allowedDropOperations, (target, wrap)=>getNextTarget(target, wrap, 'down'));
|
|
392
|
-
localState.state.setTarget(target);
|
|
393
|
-
}
|
|
394
|
-
break;
|
|
395
|
-
case 'ArrowUp':
|
|
396
|
-
if (keyboardDelegate.getKeyAbove) {
|
|
397
|
-
let target = nextValidTarget(localState.state.target, types, drag.allowedDropOperations, (target, wrap)=>getNextTarget(target, wrap, 'up'));
|
|
398
|
-
localState.state.setTarget(target);
|
|
399
|
-
}
|
|
400
|
-
break;
|
|
401
|
-
case 'ArrowLeft':
|
|
402
|
-
if (keyboardDelegate.getKeyLeftOf) {
|
|
403
|
-
let target = nextValidTarget(localState.state.target, types, drag.allowedDropOperations, (target, wrap)=>getNextTarget(target, wrap, 'left'));
|
|
404
|
-
localState.state.setTarget(target);
|
|
405
|
-
}
|
|
406
|
-
break;
|
|
407
|
-
case 'ArrowRight':
|
|
408
|
-
if (keyboardDelegate.getKeyRightOf) {
|
|
409
|
-
let target = nextValidTarget(localState.state.target, types, drag.allowedDropOperations, (target, wrap)=>getNextTarget(target, wrap, 'right'));
|
|
410
|
-
localState.state.setTarget(target);
|
|
411
|
-
}
|
|
412
|
-
break;
|
|
413
|
-
case 'Home':
|
|
414
|
-
if (keyboardDelegate.getFirstKey) {
|
|
415
|
-
let target = nextValidTarget(null, types, drag.allowedDropOperations, getNextTarget);
|
|
416
|
-
localState.state.setTarget(target);
|
|
417
|
-
}
|
|
418
|
-
break;
|
|
419
|
-
case 'End':
|
|
420
|
-
if (keyboardDelegate.getLastKey) {
|
|
421
|
-
let target = nextValidTarget(null, types, drag.allowedDropOperations, getPreviousTarget);
|
|
422
|
-
localState.state.setTarget(target);
|
|
423
|
-
}
|
|
424
|
-
break;
|
|
425
|
-
case 'PageDown':
|
|
426
|
-
if (keyboardDelegate.getKeyPageBelow) {
|
|
427
|
-
let target = localState.state.target;
|
|
428
|
-
if (!target) target = nextValidTarget(null, types, drag.allowedDropOperations, getNextTarget);
|
|
429
|
-
else {
|
|
430
|
-
var _keyboardDelegate_getFirstKey, _keyboardDelegate_getLastKey;
|
|
431
|
-
// If on the root, go to the item a page below the top. Otherwise a page below the current item.
|
|
432
|
-
let targetKey = (_keyboardDelegate_getFirstKey = keyboardDelegate.getFirstKey) === null || _keyboardDelegate_getFirstKey === void 0 ? void 0 : _keyboardDelegate_getFirstKey.call(keyboardDelegate);
|
|
433
|
-
if (target.type === 'item') targetKey = target.key;
|
|
434
|
-
let nextKey = null;
|
|
435
|
-
if (targetKey != null) nextKey = keyboardDelegate.getKeyPageBelow(targetKey);
|
|
436
|
-
let dropPosition = target.type === 'item' ? target.dropPosition : 'after';
|
|
437
|
-
// If there is no next key, or we are starting on the last key, jump to the last possible position.
|
|
438
|
-
if (nextKey == null || target.type === 'item' && target.key === ((_keyboardDelegate_getLastKey = keyboardDelegate.getLastKey) === null || _keyboardDelegate_getLastKey === void 0 ? void 0 : _keyboardDelegate_getLastKey.call(keyboardDelegate))) {
|
|
439
|
-
var _keyboardDelegate_getLastKey1;
|
|
440
|
-
var _keyboardDelegate_getLastKey2;
|
|
441
|
-
nextKey = (_keyboardDelegate_getLastKey2 = (_keyboardDelegate_getLastKey1 = keyboardDelegate.getLastKey) === null || _keyboardDelegate_getLastKey1 === void 0 ? void 0 : _keyboardDelegate_getLastKey1.call(keyboardDelegate)) !== null && _keyboardDelegate_getLastKey2 !== void 0 ? _keyboardDelegate_getLastKey2 : null;
|
|
442
|
-
dropPosition = 'after';
|
|
443
|
-
}
|
|
444
|
-
if (nextKey == null) break;
|
|
445
|
-
target = {
|
|
446
|
-
type: 'item',
|
|
447
|
-
key: nextKey,
|
|
448
|
-
dropPosition: dropPosition
|
|
449
|
-
};
|
|
450
|
-
// If the target does not accept the drop, find the next valid target.
|
|
451
|
-
// If no next valid target, find the previous valid target.
|
|
452
|
-
let { draggingCollectionRef: draggingCollectionRef, draggingKeys: draggingKeys } = (0, $4620ae0dc40f0031$exports.globalDndState);
|
|
453
|
-
let isInternal = (draggingCollectionRef === null || draggingCollectionRef === void 0 ? void 0 : draggingCollectionRef.current) === (ref === null || ref === void 0 ? void 0 : ref.current);
|
|
454
|
-
let operation = localState.state.getDropOperation({
|
|
455
|
-
target: target,
|
|
456
|
-
types: types,
|
|
457
|
-
allowedOperations: drag.allowedDropOperations,
|
|
458
|
-
isInternal: isInternal,
|
|
459
|
-
draggingKeys: draggingKeys
|
|
460
|
-
});
|
|
461
|
-
var _nextValidTarget;
|
|
462
|
-
if (operation === 'cancel') target = (_nextValidTarget = nextValidTarget(target, types, drag.allowedDropOperations, getNextTarget, false)) !== null && _nextValidTarget !== void 0 ? _nextValidTarget : nextValidTarget(target, types, drag.allowedDropOperations, getPreviousTarget, false);
|
|
463
|
-
}
|
|
464
|
-
localState.state.setTarget(target !== null && target !== void 0 ? target : localState.state.target);
|
|
465
|
-
}
|
|
466
|
-
break;
|
|
467
|
-
case 'PageUp':
|
|
468
|
-
{
|
|
469
|
-
if (!keyboardDelegate.getKeyPageAbove) break;
|
|
470
|
-
let target = localState.state.target;
|
|
471
|
-
if (!target) target = nextValidTarget(null, types, drag.allowedDropOperations, getPreviousTarget);
|
|
472
|
-
else if (target.type === 'item') {
|
|
473
|
-
var _keyboardDelegate_getFirstKey1;
|
|
474
|
-
// If at the top already, switch to the root. Otherwise navigate a page up.
|
|
475
|
-
if (target.key === ((_keyboardDelegate_getFirstKey1 = keyboardDelegate.getFirstKey) === null || _keyboardDelegate_getFirstKey1 === void 0 ? void 0 : _keyboardDelegate_getFirstKey1.call(keyboardDelegate))) target = {
|
|
476
|
-
type: 'root'
|
|
477
|
-
};
|
|
478
|
-
else {
|
|
479
|
-
let nextKey = keyboardDelegate.getKeyPageAbove(target.key);
|
|
480
|
-
let dropPosition = target.dropPosition;
|
|
481
|
-
if (nextKey == null) {
|
|
482
|
-
var _keyboardDelegate_getFirstKey2;
|
|
483
|
-
nextKey = (_keyboardDelegate_getFirstKey2 = keyboardDelegate.getFirstKey) === null || _keyboardDelegate_getFirstKey2 === void 0 ? void 0 : _keyboardDelegate_getFirstKey2.call(keyboardDelegate);
|
|
484
|
-
dropPosition = 'before';
|
|
485
|
-
}
|
|
486
|
-
if (nextKey == null) break;
|
|
487
|
-
target = {
|
|
488
|
-
type: 'item',
|
|
489
|
-
key: nextKey,
|
|
490
|
-
dropPosition: dropPosition
|
|
491
|
-
};
|
|
492
|
-
}
|
|
493
|
-
// If the target does not accept the drop, find the previous valid target.
|
|
494
|
-
// If no next valid target, find the next valid target.
|
|
495
|
-
let { draggingKeys: draggingKeys } = (0, $4620ae0dc40f0031$exports.globalDndState);
|
|
496
|
-
let isInternal = (0, $4620ae0dc40f0031$exports.isInternalDropOperation)(ref);
|
|
497
|
-
let operation = localState.state.getDropOperation({
|
|
498
|
-
target: target,
|
|
499
|
-
types: types,
|
|
500
|
-
allowedOperations: drag.allowedDropOperations,
|
|
501
|
-
isInternal: isInternal,
|
|
502
|
-
draggingKeys: draggingKeys
|
|
503
|
-
});
|
|
504
|
-
var _nextValidTarget1;
|
|
505
|
-
if (operation === 'cancel') target = (_nextValidTarget1 = nextValidTarget(target, types, drag.allowedDropOperations, getPreviousTarget, false)) !== null && _nextValidTarget1 !== void 0 ? _nextValidTarget1 : nextValidTarget(target, types, drag.allowedDropOperations, getNextTarget, false);
|
|
506
|
-
}
|
|
507
|
-
localState.state.setTarget(target !== null && target !== void 0 ? target : localState.state.target);
|
|
508
|
-
break;
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
(_localState_props_onKeyDown = (_localState_props = localState.props).onKeyDown) === null || _localState_props_onKeyDown === void 0 ? void 0 : _localState_props_onKeyDown.call(_localState_props, e);
|
|
512
|
-
}
|
|
513
|
-
});
|
|
514
|
-
}, [
|
|
515
|
-
localState,
|
|
516
|
-
ref,
|
|
517
|
-
onDrop,
|
|
518
|
-
direction
|
|
519
|
-
]);
|
|
520
|
-
let id = (0, $foOxf$reactariautils.useId)();
|
|
521
|
-
(0, $4620ae0dc40f0031$exports.droppableCollectionMap).set(state, {
|
|
522
|
-
id: id,
|
|
523
|
-
ref: ref
|
|
524
|
-
});
|
|
525
|
-
return {
|
|
526
|
-
collectionProps: (0, $foOxf$reactariautils.mergeProps)(dropProps, {
|
|
527
|
-
id: id,
|
|
528
|
-
// Remove description from collection element. If dropping on the entire collection,
|
|
529
|
-
// there should be a drop indicator that has this description, so no need to double announce.
|
|
530
|
-
'aria-describedby': null
|
|
531
|
-
})
|
|
532
|
-
};
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
//# sourceMappingURL=useDroppableCollection.main.js.map
|