@react-aria/dnd 3.11.6 → 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 -522
- package/dist/DragManager.main.js.map +0 -1
- package/dist/DragManager.mjs +0 -513
- package/dist/DragManager.module.js +0 -513
- 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 -215
- package/dist/DropTargetKeyboardNavigation.main.js.map +0 -1
- package/dist/DropTargetKeyboardNavigation.mjs +0 -210
- package/dist/DropTargetKeyboardNavigation.module.js +0 -210
- 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 -659
- package/src/DragPreview.tsx +0 -81
- package/src/DropTargetKeyboardNavigation.ts +0 -293
- 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
package/src/DragPreview.tsx
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import {DragItem, DragPreviewRenderer} from '@react-types/shared';
|
|
14
|
-
import {flushSync} from 'react-dom';
|
|
15
|
-
import React, {ForwardedRef, JSX, useEffect, useImperativeHandle, useRef, useState} from 'react';
|
|
16
|
-
|
|
17
|
-
export interface DragPreviewProps {
|
|
18
|
-
/**
|
|
19
|
-
* A render function which returns a preview element, or an object containing the element
|
|
20
|
-
* and a custom offset. If an object is returned, the provided `x` and `y` values will be
|
|
21
|
-
* used as the drag preview offset instead of the default calculation.
|
|
22
|
-
*/
|
|
23
|
-
children: (items: DragItem[]) => JSX.Element | {element: JSX.Element, x: number, y: number} | null
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export const DragPreview:
|
|
27
|
-
React.ForwardRefExoticComponent<DragPreviewProps & React.RefAttributes<DragPreviewRenderer | null>> =
|
|
28
|
-
React.forwardRef(function DragPreview(props: DragPreviewProps, ref: ForwardedRef<DragPreviewRenderer | null>) {
|
|
29
|
-
let render = props.children;
|
|
30
|
-
let [children, setChildren] = useState<JSX.Element | null>(null);
|
|
31
|
-
let domRef = useRef<HTMLDivElement | null>(null);
|
|
32
|
-
let raf = useRef<ReturnType<typeof requestAnimationFrame> | undefined>(undefined);
|
|
33
|
-
|
|
34
|
-
useImperativeHandle(ref, () => (items: DragItem[], callback: (node: HTMLElement | null, x?: number, y?: number) => void) => {
|
|
35
|
-
// This will be called during the onDragStart event by useDrag. We need to render the
|
|
36
|
-
// preview synchronously before this event returns so we can call event.dataTransfer.setDragImage.
|
|
37
|
-
|
|
38
|
-
let result = render(items);
|
|
39
|
-
let element: JSX.Element | null;
|
|
40
|
-
let offsetX: number | undefined;
|
|
41
|
-
let offsetY: number | undefined;
|
|
42
|
-
|
|
43
|
-
if (result && typeof result === 'object' && 'element' in result) {
|
|
44
|
-
element = result.element;
|
|
45
|
-
offsetX = result.x;
|
|
46
|
-
offsetY = result.y;
|
|
47
|
-
} else {
|
|
48
|
-
element = result as JSX.Element | null;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
flushSync(() => {
|
|
52
|
-
setChildren(element);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
// Yield back to useDrag to set the drag image.
|
|
56
|
-
callback(domRef.current, offsetX, offsetY);
|
|
57
|
-
|
|
58
|
-
// Remove the preview from the DOM after a frame so the browser has time to paint.
|
|
59
|
-
raf.current = requestAnimationFrame(() => {
|
|
60
|
-
setChildren(null);
|
|
61
|
-
});
|
|
62
|
-
}, [render]);
|
|
63
|
-
|
|
64
|
-
useEffect(() => {
|
|
65
|
-
return () => {
|
|
66
|
-
if (raf.current) {
|
|
67
|
-
cancelAnimationFrame(raf.current);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
}, []);
|
|
71
|
-
|
|
72
|
-
if (!children) {
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return (
|
|
77
|
-
<div style={{zIndex: -100, position: 'fixed', top: 0, left: -100000}} ref={domRef}>
|
|
78
|
-
{children}
|
|
79
|
-
</div>
|
|
80
|
-
);
|
|
81
|
-
});
|
|
@@ -1,293 +0,0 @@
|
|
|
1
|
-
import {Collection, DropTarget, Key, KeyboardDelegate, Node} from '@react-types/shared';
|
|
2
|
-
import {getChildNodes} from '@react-stately/collections';
|
|
3
|
-
|
|
4
|
-
export function navigate(
|
|
5
|
-
keyboardDelegate: KeyboardDelegate,
|
|
6
|
-
collection: Collection<Node<unknown>>,
|
|
7
|
-
target: DropTarget | null | undefined,
|
|
8
|
-
direction: 'left' | 'right' | 'up' | 'down',
|
|
9
|
-
rtl = false,
|
|
10
|
-
wrap = false
|
|
11
|
-
): DropTarget | null {
|
|
12
|
-
switch (direction) {
|
|
13
|
-
case 'left':
|
|
14
|
-
return rtl
|
|
15
|
-
? nextDropTarget(keyboardDelegate, collection, target, wrap, 'left')
|
|
16
|
-
: previousDropTarget(keyboardDelegate, collection, target, wrap, 'left');
|
|
17
|
-
case 'right':
|
|
18
|
-
return rtl
|
|
19
|
-
? previousDropTarget(keyboardDelegate, collection, target, wrap, 'right')
|
|
20
|
-
: nextDropTarget(keyboardDelegate, collection, target, wrap, 'right');
|
|
21
|
-
case 'up':
|
|
22
|
-
return previousDropTarget(keyboardDelegate, collection, target, wrap);
|
|
23
|
-
case 'down':
|
|
24
|
-
return nextDropTarget(keyboardDelegate, collection, target, wrap);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function nextDropTarget(
|
|
29
|
-
keyboardDelegate: KeyboardDelegate,
|
|
30
|
-
collection: Collection<Node<unknown>>,
|
|
31
|
-
target: DropTarget | null | undefined,
|
|
32
|
-
wrap = false,
|
|
33
|
-
horizontal: 'left' | 'right' | null = null
|
|
34
|
-
): DropTarget | null {
|
|
35
|
-
if (!target) {
|
|
36
|
-
return {
|
|
37
|
-
type: 'root'
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (target.type === 'root') {
|
|
42
|
-
let nextKey = keyboardDelegate.getFirstKey?.() ?? null;
|
|
43
|
-
if (nextKey != null) {
|
|
44
|
-
return {
|
|
45
|
-
type: 'item',
|
|
46
|
-
key: nextKey,
|
|
47
|
-
dropPosition: 'before'
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (target.type === 'item') {
|
|
55
|
-
let nextKey: Key | null | undefined = null;
|
|
56
|
-
if (horizontal) {
|
|
57
|
-
nextKey = horizontal === 'right' ? keyboardDelegate.getKeyRightOf?.(target.key) : keyboardDelegate.getKeyLeftOf?.(target.key);
|
|
58
|
-
} else {
|
|
59
|
-
nextKey = keyboardDelegate.getKeyBelow?.(target.key);
|
|
60
|
-
}
|
|
61
|
-
let nextCollectionKey = getNextItem(collection, target.key, key => collection.getKeyAfter(key));
|
|
62
|
-
|
|
63
|
-
// If the keyboard delegate did not move to the next key in the collection,
|
|
64
|
-
// jump to that key with the same drop position. Otherwise, try the other
|
|
65
|
-
// drop positions on the current key first.
|
|
66
|
-
if (nextKey != null && nextKey !== nextCollectionKey) {
|
|
67
|
-
return {
|
|
68
|
-
type: 'item',
|
|
69
|
-
key: nextKey,
|
|
70
|
-
dropPosition: target.dropPosition
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
switch (target.dropPosition) {
|
|
75
|
-
case 'before': {
|
|
76
|
-
return {
|
|
77
|
-
type: 'item',
|
|
78
|
-
key: target.key,
|
|
79
|
-
dropPosition: 'on'
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
case 'on': {
|
|
83
|
-
// If there are nested items, traverse to them prior to the "after" position of this target.
|
|
84
|
-
// If the next key is on the same level, then its "before" position is equivalent to this item's "after" position.
|
|
85
|
-
let targetNode = collection.getItem(target.key);
|
|
86
|
-
let nextNode = nextKey != null ? collection.getItem(nextKey) : null;
|
|
87
|
-
if (targetNode && nextNode && nextNode.level >= targetNode.level) {
|
|
88
|
-
return {
|
|
89
|
-
type: 'item',
|
|
90
|
-
key: nextNode.key,
|
|
91
|
-
dropPosition: 'before'
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return {
|
|
96
|
-
type: 'item',
|
|
97
|
-
key: target.key,
|
|
98
|
-
dropPosition: 'after'
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
case 'after': {
|
|
102
|
-
// If this is the last sibling in a level, traverse to the parent.
|
|
103
|
-
let targetNode = collection.getItem(target.key);
|
|
104
|
-
let nextItemInSameLevel = targetNode?.nextKey != null ? collection.getItem(targetNode.nextKey) : null;
|
|
105
|
-
while (nextItemInSameLevel != null && nextItemInSameLevel.type !== 'item') {
|
|
106
|
-
nextItemInSameLevel = nextItemInSameLevel.nextKey != null ? collection.getItem(nextItemInSameLevel.nextKey) : null;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (targetNode && nextItemInSameLevel == null && targetNode.parentKey != null) {
|
|
110
|
-
// If the parent item has an item after it, use the "before" position.
|
|
111
|
-
let parentNode = collection.getItem(targetNode.parentKey);
|
|
112
|
-
const nextNode = parentNode?.nextKey != null ? collection.getItem(parentNode.nextKey) : null;
|
|
113
|
-
if (nextNode?.type === 'item') {
|
|
114
|
-
return {
|
|
115
|
-
type: 'item',
|
|
116
|
-
key: nextNode.key,
|
|
117
|
-
dropPosition: 'before'
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if (parentNode?.type === 'item') {
|
|
122
|
-
return {
|
|
123
|
-
type: 'item',
|
|
124
|
-
key: parentNode.key,
|
|
125
|
-
dropPosition: 'after'
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (nextItemInSameLevel) {
|
|
131
|
-
return {
|
|
132
|
-
type: 'item',
|
|
133
|
-
key: nextItemInSameLevel.key,
|
|
134
|
-
dropPosition: 'on'
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
if (wrap) {
|
|
142
|
-
return {
|
|
143
|
-
type: 'root'
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return null;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function previousDropTarget(
|
|
151
|
-
keyboardDelegate: KeyboardDelegate,
|
|
152
|
-
collection: Collection<Node<unknown>>,
|
|
153
|
-
target: DropTarget | null | undefined,
|
|
154
|
-
wrap = false,
|
|
155
|
-
horizontal: 'left' | 'right' | null = null
|
|
156
|
-
): DropTarget | null {
|
|
157
|
-
// Start after the last root-level item.
|
|
158
|
-
if (!target || (wrap && target.type === 'root')) {
|
|
159
|
-
// Keyboard delegate gets the deepest item but we want the shallowest.
|
|
160
|
-
let prevKey: Key | null = null;
|
|
161
|
-
let lastKey = keyboardDelegate.getLastKey?.();
|
|
162
|
-
while (lastKey != null) {
|
|
163
|
-
let node = collection.getItem(lastKey);
|
|
164
|
-
if (node?.type !== 'item') {
|
|
165
|
-
break;
|
|
166
|
-
}
|
|
167
|
-
prevKey = lastKey;
|
|
168
|
-
lastKey = node?.parentKey;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
if (prevKey != null) {
|
|
172
|
-
return {
|
|
173
|
-
type: 'item',
|
|
174
|
-
key: prevKey,
|
|
175
|
-
dropPosition: 'after'
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
return null;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
if (target.type === 'item') {
|
|
183
|
-
let prevKey: Key | null | undefined = null;
|
|
184
|
-
if (horizontal) {
|
|
185
|
-
prevKey = horizontal === 'left' ? keyboardDelegate.getKeyLeftOf?.(target.key) : keyboardDelegate.getKeyRightOf?.(target.key);
|
|
186
|
-
} else {
|
|
187
|
-
prevKey = keyboardDelegate.getKeyAbove?.(target.key);
|
|
188
|
-
}
|
|
189
|
-
let prevCollectionKey = getNextItem(collection, target.key, key => collection.getKeyBefore(key));
|
|
190
|
-
|
|
191
|
-
// If the keyboard delegate did not move to the next key in the collection,
|
|
192
|
-
// jump to that key with the same drop position. Otherwise, try the other
|
|
193
|
-
// drop positions on the current key first.
|
|
194
|
-
if (prevKey != null && prevKey !== prevCollectionKey) {
|
|
195
|
-
return {
|
|
196
|
-
type: 'item',
|
|
197
|
-
key: prevKey,
|
|
198
|
-
dropPosition: target.dropPosition
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
switch (target.dropPosition) {
|
|
203
|
-
case 'before': {
|
|
204
|
-
// Move after the last child of the previous item.
|
|
205
|
-
let targetNode = collection.getItem(target.key);
|
|
206
|
-
if (targetNode && targetNode.prevKey != null) {
|
|
207
|
-
let lastChild = getLastChild(collection, targetNode.prevKey);
|
|
208
|
-
if (lastChild) {
|
|
209
|
-
return lastChild;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
if (prevKey != null) {
|
|
214
|
-
return {
|
|
215
|
-
type: 'item',
|
|
216
|
-
key: prevKey,
|
|
217
|
-
dropPosition: 'on'
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
return {
|
|
222
|
-
type: 'root'
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
case 'on': {
|
|
226
|
-
return {
|
|
227
|
-
type: 'item',
|
|
228
|
-
key: target.key,
|
|
229
|
-
dropPosition: 'before'
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
case 'after': {
|
|
233
|
-
// Move after the last child of this item.
|
|
234
|
-
let lastChild = getLastChild(collection, target.key);
|
|
235
|
-
if (lastChild) {
|
|
236
|
-
return lastChild;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
return {
|
|
240
|
-
type: 'item',
|
|
241
|
-
key: target.key,
|
|
242
|
-
dropPosition: 'on'
|
|
243
|
-
};
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
if (target.type !== 'root') {
|
|
249
|
-
return {
|
|
250
|
-
type: 'root'
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
return null;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
function getLastChild(collection: Collection<Node<unknown>>, key: Key): DropTarget | null {
|
|
258
|
-
// getChildNodes still returns child tree items even when the item is collapsed.
|
|
259
|
-
// Checking if the next item has a greater level is a silly way to determine if the item is expanded.
|
|
260
|
-
let targetNode = collection.getItem(key);
|
|
261
|
-
let nextKey = getNextItem(collection, key, key => collection.getKeyAfter(key));
|
|
262
|
-
let nextNode = nextKey != null ? collection.getItem(nextKey) : null;
|
|
263
|
-
if (targetNode && nextNode && nextNode.level > targetNode.level) {
|
|
264
|
-
let children = getChildNodes(targetNode, collection);
|
|
265
|
-
let lastChild: Node<unknown> | null = null;
|
|
266
|
-
for (let child of children) {
|
|
267
|
-
if (child.type === 'item') {
|
|
268
|
-
lastChild = child;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
if (lastChild) {
|
|
273
|
-
return {
|
|
274
|
-
type: 'item',
|
|
275
|
-
key: lastChild.key,
|
|
276
|
-
dropPosition: 'after'
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
return null;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
// Find the next or previous item in a collection, skipping over other types of nodes (e.g. content).
|
|
285
|
-
function getNextItem(collection: Collection<Node<unknown>>, key: Key, getNextKey: (key: Key) => Key | null): Key | null {
|
|
286
|
-
let nextCollectionKey = getNextKey(key);
|
|
287
|
-
let nextCollectionNode = nextCollectionKey != null ? collection.getItem(nextCollectionKey) : null;
|
|
288
|
-
while (nextCollectionNode && nextCollectionNode.type !== 'item') {
|
|
289
|
-
nextCollectionKey = getNextKey(nextCollectionNode.key);
|
|
290
|
-
nextCollectionNode = nextCollectionKey != null ? collection.getItem(nextCollectionKey) : null;
|
|
291
|
-
}
|
|
292
|
-
return nextCollectionKey;
|
|
293
|
-
}
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import {Direction, DropTarget, DropTargetDelegate, Node, Orientation, RefObject} from '@react-types/shared';
|
|
2
|
-
|
|
3
|
-
interface ListDropTargetDelegateOptions {
|
|
4
|
-
/**
|
|
5
|
-
* Whether the items are arranged in a stack or grid.
|
|
6
|
-
* @default 'stack'
|
|
7
|
-
*/
|
|
8
|
-
layout?: 'stack' | 'grid',
|
|
9
|
-
/**
|
|
10
|
-
* The primary orientation of the items. Usually this is the
|
|
11
|
-
* direction that the collection scrolls.
|
|
12
|
-
* @default 'vertical'
|
|
13
|
-
*/
|
|
14
|
-
orientation?: Orientation,
|
|
15
|
-
/**
|
|
16
|
-
* The horizontal layout direction.
|
|
17
|
-
* @default 'ltr'
|
|
18
|
-
*/
|
|
19
|
-
direction?: Direction
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// Terms used in the below code:
|
|
23
|
-
// * "Primary" – The main layout direction. For stacks, this is the direction
|
|
24
|
-
// that the stack is arranged in (e.g. horizontal or vertical).
|
|
25
|
-
// For grids, this is the main scroll direction.
|
|
26
|
-
// * "Secondary" – The secondary layout direction. For stacks, there is no secondary
|
|
27
|
-
// layout direction. For grids, this is the opposite of the primary direction.
|
|
28
|
-
// * "Flow" – The flow direction of the items. For stacks, this is the the primary
|
|
29
|
-
// direction. For grids, it is the secondary direction.
|
|
30
|
-
|
|
31
|
-
export class ListDropTargetDelegate implements DropTargetDelegate {
|
|
32
|
-
private collection: Iterable<Node<unknown>>;
|
|
33
|
-
private ref: RefObject<HTMLElement | null>;
|
|
34
|
-
private layout: 'stack' | 'grid';
|
|
35
|
-
private orientation: Orientation;
|
|
36
|
-
protected direction: Direction;
|
|
37
|
-
|
|
38
|
-
constructor(collection: Iterable<Node<unknown>>, ref: RefObject<HTMLElement | null>, options?: ListDropTargetDelegateOptions) {
|
|
39
|
-
this.collection = collection;
|
|
40
|
-
this.ref = ref;
|
|
41
|
-
this.layout = options?.layout || 'stack';
|
|
42
|
-
this.orientation = options?.orientation || 'vertical';
|
|
43
|
-
this.direction = options?.direction || 'ltr';
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
private getPrimaryStart(rect: DOMRect) {
|
|
47
|
-
return this.orientation === 'horizontal' ? rect.left : rect.top;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
private getPrimaryEnd(rect: DOMRect) {
|
|
51
|
-
return this.orientation === 'horizontal' ? rect.right : rect.bottom;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
private getSecondaryStart(rect: DOMRect) {
|
|
55
|
-
return this.orientation === 'horizontal' ? rect.top : rect.left;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
private getSecondaryEnd(rect: DOMRect) {
|
|
59
|
-
return this.orientation === 'horizontal' ? rect.bottom : rect.right;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
private getFlowStart(rect: DOMRect) {
|
|
63
|
-
return this.layout === 'stack' ? this.getPrimaryStart(rect) : this.getSecondaryStart(rect);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
private getFlowEnd(rect: DOMRect) {
|
|
67
|
-
return this.layout === 'stack' ? this.getPrimaryEnd(rect) : this.getSecondaryEnd(rect);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
private getFlowSize(rect: DOMRect) {
|
|
71
|
-
return this.getFlowEnd(rect) - this.getFlowStart(rect);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
getDropTargetFromPoint(x: number, y: number, isValidDropTarget: (target: DropTarget) => boolean): DropTarget {
|
|
75
|
-
if (this.collection[Symbol.iterator]().next().done || !this.ref.current) {
|
|
76
|
-
return {type: 'root'};
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
let rect: DOMRect | undefined = this.ref.current.getBoundingClientRect();
|
|
80
|
-
let primary = this.orientation === 'horizontal' ? x : y;
|
|
81
|
-
let secondary = this.orientation === 'horizontal' ? y : x;
|
|
82
|
-
primary += this.getPrimaryStart(rect);
|
|
83
|
-
secondary += this.getSecondaryStart(rect);
|
|
84
|
-
|
|
85
|
-
let flow = this.layout === 'stack' ? primary : secondary;
|
|
86
|
-
let isPrimaryRTL = this.orientation === 'horizontal' && this.direction === 'rtl';
|
|
87
|
-
let isSecondaryRTL = this.layout === 'grid' && this.orientation === 'vertical' && this.direction === 'rtl';
|
|
88
|
-
let isFlowRTL = this.layout === 'stack' ? isPrimaryRTL : isSecondaryRTL;
|
|
89
|
-
|
|
90
|
-
let collection = this.ref.current?.dataset.collection;
|
|
91
|
-
let elements = this.ref.current.querySelectorAll(collection ? `[data-collection="${CSS.escape(collection)}"]` : '[data-key]');
|
|
92
|
-
let elementMap = new Map<string, HTMLElement>();
|
|
93
|
-
for (let item of elements) {
|
|
94
|
-
if (item instanceof HTMLElement && item.dataset.key != null) {
|
|
95
|
-
elementMap.set(item.dataset.key, item);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// TODO: assume that only item type items are valid drop targets. This is to prevent a crash when dragging over the loader
|
|
100
|
-
// row since it doesn't have a data-key set on it. Will eventually need to handle the case with drag and drop and loaders located between rows aka tree.
|
|
101
|
-
// Can see https://github.com/adobe/react-spectrum/pull/4210/files#diff-21e555e0c597a28215e36137f5be076a65a1e1456c92cd0fdd60f866929aae2a for additional logic
|
|
102
|
-
// that may need to happen then
|
|
103
|
-
let items = [...this.collection].filter(item => item.type === 'item');
|
|
104
|
-
|
|
105
|
-
if (items.length < 1) {
|
|
106
|
-
return {type: 'root'};
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
let low = 0;
|
|
110
|
-
let high = items.length;
|
|
111
|
-
while (low < high) {
|
|
112
|
-
let mid = Math.floor((low + high) / 2);
|
|
113
|
-
let item = items[mid];
|
|
114
|
-
let element = elementMap.get(String(item.key));
|
|
115
|
-
if (!element) {
|
|
116
|
-
break;
|
|
117
|
-
}
|
|
118
|
-
let rect = element.getBoundingClientRect();
|
|
119
|
-
let update = (isGreater: boolean) => {
|
|
120
|
-
if (isGreater) {
|
|
121
|
-
low = mid + 1;
|
|
122
|
-
} else {
|
|
123
|
-
high = mid;
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
if (primary < this.getPrimaryStart(rect)) {
|
|
128
|
-
update(isPrimaryRTL);
|
|
129
|
-
} else if (primary > this.getPrimaryEnd(rect)) {
|
|
130
|
-
update(!isPrimaryRTL);
|
|
131
|
-
} else if (secondary < this.getSecondaryStart(rect)) {
|
|
132
|
-
update(isSecondaryRTL);
|
|
133
|
-
} else if (secondary > this.getSecondaryEnd(rect)) {
|
|
134
|
-
update(!isSecondaryRTL);
|
|
135
|
-
} else {
|
|
136
|
-
let target: DropTarget = {
|
|
137
|
-
type: 'item',
|
|
138
|
-
key: item.key,
|
|
139
|
-
dropPosition: 'on'
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
if (isValidDropTarget(target)) {
|
|
143
|
-
// Otherwise, if dropping on the item is accepted, try the before/after positions if within 5px
|
|
144
|
-
// of the start or end of the item.
|
|
145
|
-
if (flow <= this.getFlowStart(rect) + 5 && isValidDropTarget({...target, dropPosition: 'before'})) {
|
|
146
|
-
target.dropPosition = isFlowRTL ? 'after' : 'before';
|
|
147
|
-
} else if (flow >= this.getFlowEnd(rect) - 5 && isValidDropTarget({...target, dropPosition: 'after'})) {
|
|
148
|
-
target.dropPosition = isFlowRTL ? 'before' : 'after';
|
|
149
|
-
}
|
|
150
|
-
} else {
|
|
151
|
-
// If dropping on the item isn't accepted, try the target before or after depending on the position.
|
|
152
|
-
let mid = this.getFlowStart(rect) + this.getFlowSize(rect) / 2;
|
|
153
|
-
if (flow <= mid && isValidDropTarget({...target, dropPosition: 'before'})) {
|
|
154
|
-
target.dropPosition = isFlowRTL ? 'after' : 'before';
|
|
155
|
-
} else if (flow >= mid && isValidDropTarget({...target, dropPosition: 'after'})) {
|
|
156
|
-
target.dropPosition = isFlowRTL ? 'before' : 'after';
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
return target;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
let item = items[Math.min(low, items.length - 1)];
|
|
165
|
-
let element = elementMap.get(String(item.key));
|
|
166
|
-
rect = element?.getBoundingClientRect();
|
|
167
|
-
|
|
168
|
-
if (rect && (primary < this.getPrimaryStart(rect) || Math.abs(flow - this.getFlowStart(rect)) < Math.abs(flow - this.getFlowEnd(rect)))) {
|
|
169
|
-
return {
|
|
170
|
-
type: 'item',
|
|
171
|
-
key: item.key,
|
|
172
|
-
dropPosition: isFlowRTL ? 'after' : 'before'
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
return {
|
|
177
|
-
type: 'item',
|
|
178
|
-
key: item.key,
|
|
179
|
-
dropPosition: isFlowRTL ? 'before' : 'after'
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
}
|
package/src/constants.ts
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import {DropOperation} from '@react-types/shared';
|
|
14
|
-
|
|
15
|
-
export interface IDropOperation {
|
|
16
|
-
readonly none: 0,
|
|
17
|
-
readonly cancel: 0,
|
|
18
|
-
readonly move: number,
|
|
19
|
-
readonly copy: number,
|
|
20
|
-
readonly link: number,
|
|
21
|
-
readonly all: number
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export enum DROP_OPERATION {
|
|
25
|
-
none = 0,
|
|
26
|
-
cancel = 0,
|
|
27
|
-
move = 1 << 0,
|
|
28
|
-
copy = 1 << 1,
|
|
29
|
-
link = 1 << 2,
|
|
30
|
-
all = move | copy | link
|
|
31
|
-
}
|
|
32
|
-
interface DropOperationAllowed extends IDropOperation {
|
|
33
|
-
readonly copyMove: number,
|
|
34
|
-
readonly copyLink: number,
|
|
35
|
-
readonly linkMove: number,
|
|
36
|
-
readonly all: number,
|
|
37
|
-
readonly uninitialized: number
|
|
38
|
-
}
|
|
39
|
-
// See https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/effectAllowed
|
|
40
|
-
export const DROP_OPERATION_ALLOWED: DropOperationAllowed = {
|
|
41
|
-
...DROP_OPERATION,
|
|
42
|
-
copyMove: DROP_OPERATION.copy | DROP_OPERATION.move,
|
|
43
|
-
copyLink: DROP_OPERATION.copy | DROP_OPERATION.link,
|
|
44
|
-
linkMove: DROP_OPERATION.link | DROP_OPERATION.move,
|
|
45
|
-
all: DROP_OPERATION.all,
|
|
46
|
-
uninitialized: DROP_OPERATION.all
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
interface EffectAllowed {
|
|
50
|
-
0: 'none' | 'cancel',
|
|
51
|
-
1: 'move',
|
|
52
|
-
2: 'copy',
|
|
53
|
-
3: 'copyMove',
|
|
54
|
-
4: 'link',
|
|
55
|
-
5: 'linkMove',
|
|
56
|
-
6: 'copyLink',
|
|
57
|
-
7: 'all'
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export const EFFECT_ALLOWED: EffectAllowed = invert(DROP_OPERATION_ALLOWED) as unknown as EffectAllowed;
|
|
61
|
-
EFFECT_ALLOWED[DROP_OPERATION.all] = 'all'; // ensure we don't map to 'uninitialized'.
|
|
62
|
-
|
|
63
|
-
type DropEffect = 'none' | 'link' | 'copy' | 'move';
|
|
64
|
-
|
|
65
|
-
export const DROP_EFFECT_TO_DROP_OPERATION: {[K in DropEffect]: DropOperation} = {
|
|
66
|
-
none: 'cancel',
|
|
67
|
-
link: 'link',
|
|
68
|
-
copy: 'copy',
|
|
69
|
-
move: 'move'
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export const DROP_OPERATION_TO_DROP_EFFECT: {[K in DropOperation]: DropEffect} = invert(DROP_EFFECT_TO_DROP_OPERATION);
|
|
73
|
-
|
|
74
|
-
function invert<T extends string | number, C extends string | number>(object: Record<T, C>): Record<C, T> {
|
|
75
|
-
let res: Record<C, T> = {} as Record<C, T>;
|
|
76
|
-
for (let key in object) {
|
|
77
|
-
res[object[key]] = key as T;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return res;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export const NATIVE_DRAG_TYPES: Set<string> = new Set(['text/plain', 'text/uri-list', 'text/html']);
|
|
84
|
-
export const CUSTOM_DRAG_TYPE = 'application/vnd.react-aria.items+json';
|
|
85
|
-
export const GENERIC_TYPE = 'application/octet-stream';
|