@react-aria/dnd 3.0.0-alpha.8 → 3.0.0-nightly-641446f65-240905
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/DragManager.main.js +432 -0
- package/dist/DragManager.main.js.map +1 -0
- package/dist/DragManager.mjs +423 -0
- package/dist/DragManager.module.js +423 -0
- package/dist/DragManager.module.js.map +1 -0
- package/dist/DragPreview.main.js +59 -0
- package/dist/DragPreview.main.js.map +1 -0
- package/dist/DragPreview.mjs +50 -0
- package/dist/DragPreview.module.js +50 -0
- package/dist/DragPreview.module.js.map +1 -0
- package/dist/ListDropTargetDelegate.main.js +123 -0
- package/dist/ListDropTargetDelegate.main.js.map +1 -0
- package/dist/ListDropTargetDelegate.mjs +118 -0
- package/dist/ListDropTargetDelegate.module.js +118 -0
- package/dist/ListDropTargetDelegate.module.js.map +1 -0
- package/dist/ar-AE.main.js +44 -0
- package/dist/ar-AE.main.js.map +1 -0
- package/dist/ar-AE.mjs +46 -0
- package/dist/ar-AE.module.js +46 -0
- package/dist/ar-AE.module.js.map +1 -0
- package/dist/bg-BG.main.js +44 -0
- package/dist/bg-BG.main.js.map +1 -0
- package/dist/bg-BG.mjs +46 -0
- package/dist/bg-BG.module.js +46 -0
- package/dist/bg-BG.module.js.map +1 -0
- package/dist/constants.main.js +65 -0
- package/dist/constants.main.js.map +1 -0
- package/dist/constants.mjs +53 -0
- package/dist/constants.module.js +53 -0
- package/dist/constants.module.js.map +1 -0
- package/dist/cs-CZ.main.js +45 -0
- package/dist/cs-CZ.main.js.map +1 -0
- package/dist/cs-CZ.mjs +47 -0
- package/dist/cs-CZ.module.js +47 -0
- package/dist/cs-CZ.module.js.map +1 -0
- package/dist/da-DK.main.js +44 -0
- package/dist/da-DK.main.js.map +1 -0
- package/dist/da-DK.mjs +46 -0
- package/dist/da-DK.module.js +46 -0
- package/dist/da-DK.module.js.map +1 -0
- package/dist/de-DE.main.js +44 -0
- package/dist/de-DE.main.js.map +1 -0
- package/dist/de-DE.mjs +46 -0
- package/dist/de-DE.module.js +46 -0
- package/dist/de-DE.module.js.map +1 -0
- package/dist/el-GR.main.js +44 -0
- package/dist/el-GR.main.js.map +1 -0
- package/dist/el-GR.mjs +46 -0
- package/dist/el-GR.module.js +46 -0
- package/dist/el-GR.module.js.map +1 -0
- package/dist/en-US.main.js +44 -0
- package/dist/en-US.main.js.map +1 -0
- package/dist/en-US.mjs +46 -0
- package/dist/en-US.module.js +46 -0
- package/dist/en-US.module.js.map +1 -0
- package/dist/es-ES.main.js +44 -0
- package/dist/es-ES.main.js.map +1 -0
- package/dist/es-ES.mjs +46 -0
- package/dist/es-ES.module.js +46 -0
- package/dist/es-ES.module.js.map +1 -0
- package/dist/et-EE.main.js +44 -0
- package/dist/et-EE.main.js.map +1 -0
- package/dist/et-EE.mjs +46 -0
- package/dist/et-EE.module.js +46 -0
- package/dist/et-EE.module.js.map +1 -0
- package/dist/fi-FI.main.js +44 -0
- package/dist/fi-FI.main.js.map +1 -0
- package/dist/fi-FI.mjs +46 -0
- package/dist/fi-FI.module.js +46 -0
- package/dist/fi-FI.module.js.map +1 -0
- package/dist/fr-FR.main.js +44 -0
- package/dist/fr-FR.main.js.map +1 -0
- package/dist/fr-FR.mjs +46 -0
- package/dist/fr-FR.module.js +46 -0
- package/dist/fr-FR.module.js.map +1 -0
- package/dist/he-IL.main.js +44 -0
- package/dist/he-IL.main.js.map +1 -0
- package/dist/he-IL.mjs +46 -0
- package/dist/he-IL.module.js +46 -0
- package/dist/he-IL.module.js.map +1 -0
- package/dist/hr-HR.main.js +44 -0
- package/dist/hr-HR.main.js.map +1 -0
- package/dist/hr-HR.mjs +46 -0
- package/dist/hr-HR.module.js +46 -0
- package/dist/hr-HR.module.js.map +1 -0
- package/dist/hu-HU.main.js +44 -0
- package/dist/hu-HU.main.js.map +1 -0
- package/dist/hu-HU.mjs +46 -0
- package/dist/hu-HU.module.js +46 -0
- package/dist/hu-HU.module.js.map +1 -0
- package/dist/import.mjs +39 -0
- package/dist/intlStrings.main.js +108 -0
- package/dist/intlStrings.main.js.map +1 -0
- package/dist/intlStrings.mjs +110 -0
- package/dist/intlStrings.module.js +110 -0
- package/dist/intlStrings.module.js.map +1 -0
- package/dist/it-IT.main.js +44 -0
- package/dist/it-IT.main.js.map +1 -0
- package/dist/it-IT.mjs +46 -0
- package/dist/it-IT.module.js +46 -0
- package/dist/it-IT.module.js.map +1 -0
- package/dist/ja-JP.main.js +44 -0
- package/dist/ja-JP.main.js.map +1 -0
- package/dist/ja-JP.mjs +46 -0
- package/dist/ja-JP.module.js +46 -0
- package/dist/ja-JP.module.js.map +1 -0
- package/dist/ko-KR.main.js +44 -0
- package/dist/ko-KR.main.js.map +1 -0
- package/dist/ko-KR.mjs +46 -0
- package/dist/ko-KR.module.js +46 -0
- package/dist/ko-KR.module.js.map +1 -0
- package/dist/lt-LT.main.js +44 -0
- package/dist/lt-LT.main.js.map +1 -0
- package/dist/lt-LT.mjs +46 -0
- package/dist/lt-LT.module.js +46 -0
- package/dist/lt-LT.module.js.map +1 -0
- package/dist/lv-LV.main.js +44 -0
- package/dist/lv-LV.main.js.map +1 -0
- package/dist/lv-LV.mjs +46 -0
- package/dist/lv-LV.module.js +46 -0
- package/dist/lv-LV.module.js.map +1 -0
- package/dist/main.js +38 -1855
- package/dist/main.js.map +1 -1
- package/dist/module.js +24 -1838
- package/dist/module.js.map +1 -1
- package/dist/nb-NO.main.js +44 -0
- package/dist/nb-NO.main.js.map +1 -0
- package/dist/nb-NO.mjs +46 -0
- package/dist/nb-NO.module.js +46 -0
- package/dist/nb-NO.module.js.map +1 -0
- package/dist/nl-NL.main.js +44 -0
- package/dist/nl-NL.main.js.map +1 -0
- package/dist/nl-NL.mjs +46 -0
- package/dist/nl-NL.module.js +46 -0
- package/dist/nl-NL.module.js.map +1 -0
- package/dist/pl-PL.main.js +44 -0
- package/dist/pl-PL.main.js.map +1 -0
- package/dist/pl-PL.mjs +46 -0
- package/dist/pl-PL.module.js +46 -0
- package/dist/pl-PL.module.js.map +1 -0
- package/dist/pt-BR.main.js +44 -0
- package/dist/pt-BR.main.js.map +1 -0
- package/dist/pt-BR.mjs +46 -0
- package/dist/pt-BR.module.js +46 -0
- package/dist/pt-BR.module.js.map +1 -0
- package/dist/pt-PT.main.js +44 -0
- package/dist/pt-PT.main.js.map +1 -0
- package/dist/pt-PT.mjs +46 -0
- package/dist/pt-PT.module.js +46 -0
- package/dist/pt-PT.module.js.map +1 -0
- package/dist/ro-RO.main.js +44 -0
- package/dist/ro-RO.main.js.map +1 -0
- package/dist/ro-RO.mjs +46 -0
- package/dist/ro-RO.module.js +46 -0
- package/dist/ro-RO.module.js.map +1 -0
- package/dist/ru-RU.main.js +44 -0
- package/dist/ru-RU.main.js.map +1 -0
- package/dist/ru-RU.mjs +46 -0
- package/dist/ru-RU.module.js +46 -0
- package/dist/ru-RU.module.js.map +1 -0
- package/dist/sk-SK.main.js +44 -0
- package/dist/sk-SK.main.js.map +1 -0
- package/dist/sk-SK.mjs +46 -0
- package/dist/sk-SK.module.js +46 -0
- package/dist/sk-SK.module.js.map +1 -0
- package/dist/sl-SI.main.js +44 -0
- package/dist/sl-SI.main.js.map +1 -0
- package/dist/sl-SI.mjs +46 -0
- package/dist/sl-SI.module.js +46 -0
- package/dist/sl-SI.module.js.map +1 -0
- package/dist/sr-SP.main.js +44 -0
- package/dist/sr-SP.main.js.map +1 -0
- package/dist/sr-SP.mjs +46 -0
- package/dist/sr-SP.module.js +46 -0
- package/dist/sr-SP.module.js.map +1 -0
- package/dist/sv-SE.main.js +44 -0
- package/dist/sv-SE.main.js.map +1 -0
- package/dist/sv-SE.mjs +46 -0
- package/dist/sv-SE.module.js +46 -0
- package/dist/sv-SE.module.js.map +1 -0
- package/dist/tr-TR.main.js +44 -0
- package/dist/tr-TR.main.js.map +1 -0
- package/dist/tr-TR.mjs +46 -0
- package/dist/tr-TR.module.js +46 -0
- package/dist/tr-TR.module.js.map +1 -0
- package/dist/types.d.ts +184 -32
- package/dist/types.d.ts.map +1 -1
- package/dist/uk-UA.main.js +44 -0
- package/dist/uk-UA.main.js.map +1 -0
- package/dist/uk-UA.mjs +46 -0
- package/dist/uk-UA.module.js +46 -0
- package/dist/uk-UA.module.js.map +1 -0
- package/dist/useAutoScroll.main.js +89 -0
- package/dist/useAutoScroll.main.js.map +1 -0
- package/dist/useAutoScroll.mjs +84 -0
- package/dist/useAutoScroll.module.js +84 -0
- package/dist/useAutoScroll.module.js.map +1 -0
- package/dist/useClipboard.main.js +107 -0
- package/dist/useClipboard.main.js.map +1 -0
- package/dist/useClipboard.mjs +102 -0
- package/dist/useClipboard.module.js +102 -0
- package/dist/useClipboard.module.js.map +1 -0
- package/dist/useDrag.main.js +286 -0
- package/dist/useDrag.main.js.map +1 -0
- package/dist/useDrag.mjs +281 -0
- package/dist/useDrag.module.js +281 -0
- package/dist/useDrag.module.js.map +1 -0
- package/dist/useDraggableCollection.main.js +27 -0
- package/dist/useDraggableCollection.main.js.map +1 -0
- package/dist/useDraggableCollection.mjs +22 -0
- package/dist/useDraggableCollection.module.js +22 -0
- package/dist/useDraggableCollection.module.js.map +1 -0
- package/dist/useDraggableItem.main.js +128 -0
- package/dist/useDraggableItem.main.js.map +1 -0
- package/dist/useDraggableItem.mjs +123 -0
- package/dist/useDraggableItem.module.js +123 -0
- package/dist/useDraggableItem.module.js.map +1 -0
- package/dist/useDrop.main.js +299 -0
- package/dist/useDrop.main.js.map +1 -0
- package/dist/useDrop.mjs +294 -0
- package/dist/useDrop.module.js +294 -0
- package/dist/useDrop.module.js.map +1 -0
- package/dist/useDropIndicator.main.js +93 -0
- package/dist/useDropIndicator.main.js.map +1 -0
- package/dist/useDropIndicator.mjs +88 -0
- package/dist/useDropIndicator.module.js +88 -0
- package/dist/useDropIndicator.module.js.map +1 -0
- package/dist/useDroppableCollection.main.js +592 -0
- package/dist/useDroppableCollection.main.js.map +1 -0
- package/dist/useDroppableCollection.mjs +587 -0
- package/dist/useDroppableCollection.module.js +587 -0
- package/dist/useDroppableCollection.module.js.map +1 -0
- package/dist/useDroppableItem.main.js +79 -0
- package/dist/useDroppableItem.main.js.map +1 -0
- package/dist/useDroppableItem.mjs +74 -0
- package/dist/useDroppableItem.module.js +74 -0
- package/dist/useDroppableItem.module.js.map +1 -0
- package/dist/useVirtualDrop.main.js +56 -0
- package/dist/useVirtualDrop.main.js.map +1 -0
- package/dist/useVirtualDrop.mjs +51 -0
- package/dist/useVirtualDrop.module.js +51 -0
- package/dist/useVirtualDrop.module.js.map +1 -0
- package/dist/utils.main.js +283 -0
- package/dist/utils.main.js.map +1 -0
- package/dist/utils.mjs +255 -0
- package/dist/utils.module.js +255 -0
- package/dist/utils.module.js.map +1 -0
- package/dist/zh-CN.main.js +44 -0
- package/dist/zh-CN.main.js.map +1 -0
- package/dist/zh-CN.mjs +46 -0
- package/dist/zh-CN.module.js +46 -0
- package/dist/zh-CN.module.js.map +1 -0
- package/dist/zh-TW.main.js +44 -0
- package/dist/zh-TW.main.js.map +1 -0
- package/dist/zh-TW.mjs +46 -0
- package/dist/zh-TW.module.js +46 -0
- package/dist/zh-TW.module.js.map +1 -0
- package/package.json +20 -16
- package/src/DragManager.ts +87 -52
- package/src/DragPreview.tsx +54 -0
- package/src/ListDropTargetDelegate.ts +173 -0
- package/src/constants.ts +2 -0
- package/src/index.ts +56 -7
- package/src/useAutoScroll.ts +26 -6
- package/src/useClipboard.ts +65 -59
- package/src/useDrag.ts +195 -61
- package/src/useDraggableCollection.ts +29 -0
- package/src/useDraggableItem.ts +106 -15
- package/src/useDrop.ts +273 -93
- package/src/useDropIndicator.ts +49 -23
- package/src/useDroppableCollection.ts +317 -122
- package/src/useDroppableItem.ts +35 -19
- package/src/useVirtualDrop.ts +5 -5
- package/src/utils.ts +92 -17
- package/LICENSE +0 -201
package/src/index.ts
CHANGED
|
@@ -10,10 +10,59 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
export
|
|
13
|
+
export type {DroppableCollectionOptions, DroppableCollectionResult} from './useDroppableCollection';
|
|
14
|
+
export type {DroppableItemOptions, DroppableItemResult} from './useDroppableItem';
|
|
15
|
+
export type {DropIndicatorProps, DropIndicatorAria} from './useDropIndicator';
|
|
16
|
+
export type {DraggableItemProps, DraggableItemResult} from './useDraggableItem';
|
|
17
|
+
export type {DraggableCollectionOptions} from './useDraggableCollection';
|
|
18
|
+
export type {DragPreviewProps} from './DragPreview';
|
|
19
|
+
export type {DragOptions, DragResult} from './useDrag';
|
|
20
|
+
export type {DropOptions, DropResult} from './useDrop';
|
|
21
|
+
export type {ClipboardProps, ClipboardResult} from './useClipboard';
|
|
22
|
+
export type {
|
|
23
|
+
DirectoryDropItem,
|
|
24
|
+
DragEndEvent,
|
|
25
|
+
DraggableCollectionEndEvent,
|
|
26
|
+
DraggableCollectionMoveEvent,
|
|
27
|
+
DraggableCollectionStartEvent,
|
|
28
|
+
DragItem,
|
|
29
|
+
DragMoveEvent,
|
|
30
|
+
DragPreviewRenderer,
|
|
31
|
+
DragStartEvent,
|
|
32
|
+
DragTypes,
|
|
33
|
+
DropEnterEvent,
|
|
34
|
+
DropEvent,
|
|
35
|
+
DropExitEvent,
|
|
36
|
+
DropItem,
|
|
37
|
+
DropMoveEvent,
|
|
38
|
+
DropOperation,
|
|
39
|
+
DroppableCollectionDropEvent,
|
|
40
|
+
DroppableCollectionEnterEvent,
|
|
41
|
+
DroppableCollectionExitEvent,
|
|
42
|
+
DroppableCollectionInsertDropEvent,
|
|
43
|
+
DroppableCollectionMoveEvent,
|
|
44
|
+
DroppableCollectionOnItemDropEvent,
|
|
45
|
+
DroppableCollectionReorderEvent,
|
|
46
|
+
DroppableCollectionRootDropEvent,
|
|
47
|
+
DropPosition,
|
|
48
|
+
DropTarget,
|
|
49
|
+
DropTargetDelegate,
|
|
50
|
+
FileDropItem,
|
|
51
|
+
ItemDropTarget,
|
|
52
|
+
RootDropTarget,
|
|
53
|
+
TextDropItem
|
|
54
|
+
} from '@react-types/shared';
|
|
55
|
+
|
|
56
|
+
export {DIRECTORY_DRAG_TYPE} from './utils';
|
|
57
|
+
export {useDrag} from './useDrag';
|
|
58
|
+
export {useDrop} from './useDrop';
|
|
59
|
+
export {useDroppableCollection} from './useDroppableCollection';
|
|
60
|
+
export {useDroppableItem} from './useDroppableItem';
|
|
61
|
+
export {useDropIndicator} from './useDropIndicator';
|
|
62
|
+
export {useDraggableItem} from './useDraggableItem';
|
|
63
|
+
export {useDraggableCollection} from './useDraggableCollection';
|
|
64
|
+
export {useClipboard} from './useClipboard';
|
|
65
|
+
export {DragPreview} from './DragPreview';
|
|
66
|
+
export {ListDropTargetDelegate} from './ListDropTargetDelegate';
|
|
67
|
+
export {isVirtualDragging} from './DragManager';
|
|
68
|
+
export {isDirectoryDropItem, isFileDropItem, isTextDropItem} from './utils';
|
package/src/useAutoScroll.ts
CHANGED
|
@@ -10,16 +10,22 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {getScrollParent, isIOS, isWebKit} from '@react-aria/utils';
|
|
14
|
-
import {RefObject
|
|
13
|
+
import {getScrollParent, isIOS, isScrollable, isWebKit} from '@react-aria/utils';
|
|
14
|
+
import {RefObject} from '@react-types/shared';
|
|
15
|
+
import {useCallback, useEffect, useRef} from 'react';
|
|
15
16
|
|
|
16
17
|
const AUTOSCROLL_AREA_SIZE = 20;
|
|
17
18
|
|
|
18
|
-
export function useAutoScroll(ref: RefObject<Element>) {
|
|
19
|
+
export function useAutoScroll(ref: RefObject<Element | null>) {
|
|
19
20
|
let scrollableRef = useRef<Element>(null);
|
|
21
|
+
let scrollableX = useRef(true);
|
|
22
|
+
let scrollableY = useRef(true);
|
|
20
23
|
useEffect(() => {
|
|
21
24
|
if (ref.current) {
|
|
22
|
-
scrollableRef.current = getScrollParent(ref.current);
|
|
25
|
+
scrollableRef.current = isScrollable(ref.current) ? ref.current : getScrollParent(ref.current);
|
|
26
|
+
let style = window.getComputedStyle(scrollableRef.current);
|
|
27
|
+
scrollableX.current = /(auto|scroll)/.test(style.overflowX);
|
|
28
|
+
scrollableY.current = /(auto|scroll)/.test(style.overflowY);
|
|
23
29
|
}
|
|
24
30
|
}, [ref]);
|
|
25
31
|
|
|
@@ -29,9 +35,23 @@ export function useAutoScroll(ref: RefObject<Element>) {
|
|
|
29
35
|
dy: 0
|
|
30
36
|
}).current;
|
|
31
37
|
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
return () => {
|
|
40
|
+
if (state.timer) {
|
|
41
|
+
cancelAnimationFrame(state.timer);
|
|
42
|
+
state.timer = null;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
// state will become a new object, so it's ok to use in the dependency array for unmount
|
|
46
|
+
}, [state]);
|
|
47
|
+
|
|
32
48
|
let scroll = useCallback(() => {
|
|
33
|
-
|
|
34
|
-
|
|
49
|
+
if (scrollableX.current) {
|
|
50
|
+
scrollableRef.current.scrollLeft += state.dx;
|
|
51
|
+
}
|
|
52
|
+
if (scrollableY.current) {
|
|
53
|
+
scrollableRef.current.scrollTop += state.dy;
|
|
54
|
+
}
|
|
35
55
|
|
|
36
56
|
if (state.timer) {
|
|
37
57
|
state.timer = requestAnimationFrame(scroll);
|
package/src/useClipboard.ts
CHANGED
|
@@ -10,21 +10,28 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {chain} from '@react-aria/utils';
|
|
14
|
-
import {DragItem, DropItem} from '@react-types/shared';
|
|
15
|
-
import {HTMLAttributes, useEffect, useRef} from 'react';
|
|
13
|
+
import {chain, useEffectEvent} from '@react-aria/utils';
|
|
14
|
+
import {DOMAttributes, DragItem, DropItem} from '@react-types/shared';
|
|
16
15
|
import {readFromDataTransfer, writeToDataTransfer} from './utils';
|
|
16
|
+
import {useEffect, useRef} from 'react';
|
|
17
17
|
import {useFocus} from '@react-aria/interactions';
|
|
18
18
|
|
|
19
|
-
interface ClipboardProps {
|
|
19
|
+
export interface ClipboardProps {
|
|
20
|
+
/** A function that returns the items to copy. */
|
|
20
21
|
getItems?: () => DragItem[],
|
|
22
|
+
/** Handler that is called when the user triggers a copy interaction. */
|
|
21
23
|
onCopy?: () => void,
|
|
24
|
+
/** Handler that is called when the user triggers a cut interaction. */
|
|
22
25
|
onCut?: () => void,
|
|
23
|
-
|
|
26
|
+
/** Handler that is called when the user triggers a paste interaction. */
|
|
27
|
+
onPaste?: (items: DropItem[]) => void,
|
|
28
|
+
/** Whether the clipboard is disabled. */
|
|
29
|
+
isDisabled?: boolean
|
|
24
30
|
}
|
|
25
31
|
|
|
26
|
-
interface ClipboardResult {
|
|
27
|
-
|
|
32
|
+
export interface ClipboardResult {
|
|
33
|
+
/** Props for the element that will handle clipboard events. */
|
|
34
|
+
clipboardProps: DOMAttributes
|
|
28
35
|
}
|
|
29
36
|
|
|
30
37
|
const globalEvents = new Map();
|
|
@@ -54,10 +61,12 @@ function addGlobalEventListener(event, fn) {
|
|
|
54
61
|
};
|
|
55
62
|
}
|
|
56
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Handles clipboard interactions for a focusable element. Supports items of multiple
|
|
66
|
+
* data types, and integrates with the operating system native clipboard.
|
|
67
|
+
*/
|
|
57
68
|
export function useClipboard(options: ClipboardProps): ClipboardResult {
|
|
58
|
-
let
|
|
59
|
-
ref.current = options;
|
|
60
|
-
|
|
69
|
+
let {isDisabled} = options;
|
|
61
70
|
let isFocusedRef = useRef(false);
|
|
62
71
|
let {focusProps} = useFocus({
|
|
63
72
|
onFocusChange: (isFocused) => {
|
|
@@ -65,64 +74,61 @@ export function useClipboard(options: ClipboardProps): ClipboardResult {
|
|
|
65
74
|
}
|
|
66
75
|
});
|
|
67
76
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
let options = ref.current;
|
|
72
|
-
if (isFocusedRef.current && options.getItems) {
|
|
73
|
-
e.preventDefault();
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
let onCopy = (e: ClipboardEvent) => {
|
|
78
|
-
let options = ref.current;
|
|
79
|
-
if (!isFocusedRef.current || !options.getItems) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
|
|
77
|
+
let onBeforeCopy = useEffectEvent((e: ClipboardEvent) => {
|
|
78
|
+
// Enable the "Copy" menu item in Safari if this element is focused and copying is supported.
|
|
79
|
+
if (isFocusedRef.current && options.getItems) {
|
|
83
80
|
e.preventDefault();
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
};
|
|
81
|
+
}
|
|
82
|
+
});
|
|
87
83
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
};
|
|
84
|
+
let onCopy = useEffectEvent((e: ClipboardEvent) => {
|
|
85
|
+
if (!isFocusedRef.current || !options.getItems) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
94
88
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
89
|
+
e.preventDefault();
|
|
90
|
+
writeToDataTransfer(e.clipboardData, options.getItems());
|
|
91
|
+
options.onCopy?.();
|
|
92
|
+
});
|
|
100
93
|
|
|
94
|
+
let onBeforeCut = useEffectEvent((e: ClipboardEvent) => {
|
|
95
|
+
if (isFocusedRef.current && options.onCut && options.getItems) {
|
|
101
96
|
e.preventDefault();
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
};
|
|
97
|
+
}
|
|
98
|
+
});
|
|
105
99
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
if (isFocusedRef.current && options.onPaste) {
|
|
111
|
-
e.preventDefault();
|
|
112
|
-
}
|
|
113
|
-
};
|
|
100
|
+
let onCut = useEffectEvent((e: ClipboardEvent) => {
|
|
101
|
+
if (!isFocusedRef.current || !options.onCut || !options.getItems) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
114
104
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
105
|
+
e.preventDefault();
|
|
106
|
+
writeToDataTransfer(e.clipboardData, options.getItems());
|
|
107
|
+
options.onCut();
|
|
108
|
+
});
|
|
120
109
|
|
|
110
|
+
let onBeforePaste = useEffectEvent((e: ClipboardEvent) => {
|
|
111
|
+
// Unfortunately, e.clipboardData.types is not available in this event so we always
|
|
112
|
+
// have to enable the Paste menu item even if the type of data is unsupported.
|
|
113
|
+
if (isFocusedRef.current && options.onPaste) {
|
|
121
114
|
e.preventDefault();
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
let onPaste = useEffectEvent((e: ClipboardEvent) => {
|
|
119
|
+
if (!isFocusedRef.current || !options.onPaste) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
125
122
|
|
|
123
|
+
e.preventDefault();
|
|
124
|
+
let items = readFromDataTransfer(e.clipboardData);
|
|
125
|
+
options.onPaste(items);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
useEffect(() => {
|
|
129
|
+
if (isDisabled) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
126
132
|
return chain(
|
|
127
133
|
addGlobalEventListener('beforecopy', onBeforeCopy),
|
|
128
134
|
addGlobalEventListener('copy', onCopy),
|
|
@@ -131,7 +137,7 @@ export function useClipboard(options: ClipboardProps): ClipboardResult {
|
|
|
131
137
|
addGlobalEventListener('beforepaste', onBeforePaste),
|
|
132
138
|
addGlobalEventListener('paste', onPaste)
|
|
133
139
|
);
|
|
134
|
-
}, []);
|
|
140
|
+
}, [isDisabled, onBeforeCopy, onCopy, onBeforeCut, onCut, onBeforePaste, onPaste]);
|
|
135
141
|
|
|
136
142
|
return {
|
|
137
143
|
clipboardProps: focusProps
|
package/src/useDrag.ts
CHANGED
|
@@ -11,30 +11,46 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import {AriaButtonProps} from '@react-types/button';
|
|
14
|
-
import {DragEndEvent, DragItem, DragMoveEvent, DragStartEvent, DropOperation, PressEvent} from '@react-types/shared';
|
|
14
|
+
import {DragEndEvent, DragItem, DragMoveEvent, DragPreviewRenderer, DragStartEvent, DropOperation, PressEvent, RefObject} from '@react-types/shared';
|
|
15
15
|
import {DragEvent, HTMLAttributes, useRef, useState} from 'react';
|
|
16
16
|
import * as DragManager from './DragManager';
|
|
17
17
|
import {DROP_EFFECT_TO_DROP_OPERATION, DROP_OPERATION, EFFECT_ALLOWED} from './constants';
|
|
18
|
+
import {globalDropEffect, setGlobalAllowedDropOperations, setGlobalDropEffect, useDragModality, writeToDataTransfer} from './utils';
|
|
18
19
|
// @ts-ignore
|
|
19
20
|
import intlMessages from '../intl/*.json';
|
|
20
|
-
import
|
|
21
|
-
import {
|
|
22
|
-
import {useDragModality} from './utils';
|
|
23
|
-
import {useMessageFormatter} from '@react-aria/i18n';
|
|
24
|
-
import {writeToDataTransfer} from './utils';
|
|
21
|
+
import {isVirtualClick, isVirtualPointerEvent, useDescription, useGlobalListeners, useLayoutEffect} from '@react-aria/utils';
|
|
22
|
+
import {useLocalizedStringFormatter} from '@react-aria/i18n';
|
|
25
23
|
|
|
26
|
-
interface DragOptions {
|
|
24
|
+
export interface DragOptions {
|
|
25
|
+
/** Handler that is called when a drag operation is started. */
|
|
27
26
|
onDragStart?: (e: DragStartEvent) => void,
|
|
27
|
+
/** Handler that is called when the drag is moved. */
|
|
28
28
|
onDragMove?: (e: DragMoveEvent) => void,
|
|
29
|
+
/** Handler that is called when the drag operation is ended, either as a result of a drop or a cancellation. */
|
|
29
30
|
onDragEnd?: (e: DragEndEvent) => void,
|
|
31
|
+
/** A function that returns the items being dragged. */
|
|
30
32
|
getItems: () => DragItem[],
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
/** The ref of the element that will be rendered as the drag preview while dragging. */
|
|
34
|
+
preview?: RefObject<DragPreviewRenderer | null>,
|
|
35
|
+
/** Function that returns the drop operations that are allowed for the dragged items. If not provided, all drop operations are allowed. */
|
|
36
|
+
getAllowedDropOperations?: () => DropOperation[],
|
|
37
|
+
/**
|
|
38
|
+
* Whether the item has an explicit focusable drag affordance to initiate accessible drag and drop mode.
|
|
39
|
+
* If true, the dragProps will omit these event handlers, and they will be applied to dragButtonProps instead.
|
|
40
|
+
*/
|
|
41
|
+
hasDragButton?: boolean,
|
|
42
|
+
/**
|
|
43
|
+
* Whether the drag operation is disabled. If true, the element will not be draggable.
|
|
44
|
+
*/
|
|
45
|
+
isDisabled?: boolean
|
|
33
46
|
}
|
|
34
47
|
|
|
35
|
-
interface DragResult {
|
|
48
|
+
export interface DragResult {
|
|
49
|
+
/** Props for the draggable element. */
|
|
36
50
|
dragProps: HTMLAttributes<HTMLElement>,
|
|
51
|
+
/** Props for the explicit drag button affordance, if any. */
|
|
37
52
|
dragButtonProps: AriaButtonProps,
|
|
53
|
+
/** Whether the element is currently being dragged. */
|
|
38
54
|
isDragging: boolean
|
|
39
55
|
}
|
|
40
56
|
|
|
@@ -53,47 +69,71 @@ const MESSAGES = {
|
|
|
53
69
|
}
|
|
54
70
|
};
|
|
55
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Handles drag interactions for an element, with support for traditional mouse and touch
|
|
74
|
+
* based drag and drop, in addition to full parity for keyboard and screen reader users.
|
|
75
|
+
*/
|
|
56
76
|
export function useDrag(options: DragOptions): DragResult {
|
|
57
|
-
let
|
|
77
|
+
let {hasDragButton, isDisabled} = options;
|
|
78
|
+
let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/dnd');
|
|
58
79
|
let state = useRef({
|
|
59
80
|
options,
|
|
60
81
|
x: 0,
|
|
61
82
|
y: 0
|
|
62
83
|
}).current;
|
|
63
84
|
state.options = options;
|
|
64
|
-
let
|
|
85
|
+
let isDraggingRef = useRef(false);
|
|
86
|
+
let [isDragging, setDraggingState] = useState(false);
|
|
87
|
+
let setDragging = (isDragging) => {
|
|
88
|
+
isDraggingRef.current = isDragging;
|
|
89
|
+
setDraggingState(isDragging);
|
|
90
|
+
};
|
|
65
91
|
let {addGlobalListener, removeAllGlobalListeners} = useGlobalListeners();
|
|
92
|
+
let modalityOnPointerDown = useRef<string>(null);
|
|
66
93
|
|
|
67
94
|
let onDragStart = (e: DragEvent) => {
|
|
95
|
+
if (e.defaultPrevented) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Prevent the drag event from propagating to any parent draggables
|
|
100
|
+
e.stopPropagation();
|
|
101
|
+
|
|
102
|
+
// If this drag was initiated by a mobile screen reader (e.g. VoiceOver or TalkBack), enter virtual dragging mode.
|
|
103
|
+
if (modalityOnPointerDown.current === 'virtual') {
|
|
104
|
+
e.preventDefault();
|
|
105
|
+
startDragging(e.target as HTMLElement);
|
|
106
|
+
modalityOnPointerDown.current = null;
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (typeof options.onDragStart === 'function') {
|
|
111
|
+
options.onDragStart({
|
|
112
|
+
type: 'dragstart',
|
|
113
|
+
x: e.clientX,
|
|
114
|
+
y: e.clientY
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
68
118
|
let items = options.getItems();
|
|
69
119
|
writeToDataTransfer(e.dataTransfer, items);
|
|
70
120
|
|
|
121
|
+
let allowed = DROP_OPERATION.all;
|
|
71
122
|
if (typeof options.getAllowedDropOperations === 'function') {
|
|
72
123
|
let allowedOperations = options.getAllowedDropOperations();
|
|
73
|
-
|
|
124
|
+
allowed = DROP_OPERATION.none;
|
|
74
125
|
for (let operation of allowedOperations) {
|
|
75
126
|
allowed |= DROP_OPERATION[operation] || DROP_OPERATION.none;
|
|
76
127
|
}
|
|
77
|
-
|
|
78
|
-
e.dataTransfer.effectAllowed = EFFECT_ALLOWED[allowed] || 'none';
|
|
79
128
|
}
|
|
80
129
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (typeof options.renderPreview === 'function') {
|
|
84
|
-
let preview = options.renderPreview(items);
|
|
85
|
-
if (preview) {
|
|
86
|
-
// Create an off-screen div to render the preview into.
|
|
87
|
-
let node = document.createElement('div');
|
|
88
|
-
node.style.zIndex = '-100';
|
|
89
|
-
node.style.position = 'absolute';
|
|
90
|
-
node.style.top = '0';
|
|
91
|
-
node.style.left = '-100000px';
|
|
92
|
-
document.body.appendChild(node);
|
|
93
|
-
|
|
94
|
-
// Call renderPreview to get a JSX element, and render it into the div with React DOM.
|
|
95
|
-
ReactDOM.render(preview, node);
|
|
130
|
+
setGlobalAllowedDropOperations(allowed);
|
|
131
|
+
e.dataTransfer.effectAllowed = EFFECT_ALLOWED[allowed] || 'none';
|
|
96
132
|
|
|
133
|
+
// If there is a preview option, use it to render a custom preview image that will
|
|
134
|
+
// appear under the pointer while dragging. If not, the element itself is dragged by the browser.
|
|
135
|
+
if (typeof options.preview?.current === 'function') {
|
|
136
|
+
options.preview.current(items, node => {
|
|
97
137
|
// Compute the offset that the preview will appear under the mouse.
|
|
98
138
|
// If possible, this is based on the point the user clicked on the target.
|
|
99
139
|
// If the preview is much smaller, then just use the center point of the preview.
|
|
@@ -107,35 +147,19 @@ export function useDrag(options: DragOptions): DragResult {
|
|
|
107
147
|
}
|
|
108
148
|
|
|
109
149
|
// Rounding height to an even number prevents blurry preview seen on some screens
|
|
110
|
-
let height = 2 * Math.round(
|
|
150
|
+
let height = 2 * Math.round(size.height / 2);
|
|
111
151
|
node.style.height = `${height}px`;
|
|
112
|
-
|
|
113
|
-
e.dataTransfer.setDragImage(node, x, y);
|
|
114
152
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
document.body.removeChild(node);
|
|
118
|
-
});
|
|
119
|
-
}
|
|
153
|
+
e.dataTransfer.setDragImage(node, x, y);
|
|
154
|
+
});
|
|
120
155
|
}
|
|
121
156
|
|
|
122
157
|
// Enforce that drops are handled by useDrop.
|
|
123
158
|
addGlobalListener(window, 'drop', e => {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
}, {capture: true, once: true});
|
|
130
|
-
|
|
131
|
-
if (typeof options.onDragStart === 'function') {
|
|
132
|
-
options.onDragStart({
|
|
133
|
-
type: 'dragstart',
|
|
134
|
-
x: e.clientX,
|
|
135
|
-
y: e.clientY
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
|
|
159
|
+
e.preventDefault();
|
|
160
|
+
e.stopPropagation();
|
|
161
|
+
console.warn('Drags initiated from the React Aria useDrag hook may only be dropped on a target created with useDrop. This ensures that a keyboard and screen reader accessible alternative is available.');
|
|
162
|
+
}, {once: true});
|
|
139
163
|
state.x = e.clientX;
|
|
140
164
|
state.y = e.clientY;
|
|
141
165
|
|
|
@@ -147,6 +171,9 @@ export function useDrag(options: DragOptions): DragResult {
|
|
|
147
171
|
};
|
|
148
172
|
|
|
149
173
|
let onDrag = (e: DragEvent) => {
|
|
174
|
+
// Prevent the drag event from propagating to any parent draggables
|
|
175
|
+
e.stopPropagation();
|
|
176
|
+
|
|
150
177
|
if (e.clientX === state.x && e.clientY === state.y) {
|
|
151
178
|
return;
|
|
152
179
|
}
|
|
@@ -164,26 +191,65 @@ export function useDrag(options: DragOptions): DragResult {
|
|
|
164
191
|
};
|
|
165
192
|
|
|
166
193
|
let onDragEnd = (e: DragEvent) => {
|
|
194
|
+
// Prevent the drag event from propagating to any parent draggables
|
|
195
|
+
e.stopPropagation();
|
|
196
|
+
|
|
167
197
|
if (typeof options.onDragEnd === 'function') {
|
|
168
|
-
|
|
198
|
+
let event: DragEndEvent = {
|
|
169
199
|
type: 'dragend',
|
|
170
200
|
x: e.clientX,
|
|
171
201
|
y: e.clientY,
|
|
172
202
|
dropOperation: DROP_EFFECT_TO_DROP_OPERATION[e.dataTransfer.dropEffect]
|
|
173
|
-
}
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
// Chrome Android always returns none as its dropEffect so we use the drop effect set in useDrop via
|
|
206
|
+
// onDragEnter/onDragOver instead. https://bugs.chromium.org/p/chromium/issues/detail?id=1353951
|
|
207
|
+
if (globalDropEffect) {
|
|
208
|
+
event.dropOperation = DROP_EFFECT_TO_DROP_OPERATION[globalDropEffect];
|
|
209
|
+
}
|
|
210
|
+
options.onDragEnd(event);
|
|
174
211
|
}
|
|
175
212
|
|
|
176
213
|
setDragging(false);
|
|
177
214
|
removeAllGlobalListeners();
|
|
215
|
+
setGlobalAllowedDropOperations(DROP_OPERATION.none);
|
|
216
|
+
setGlobalDropEffect(undefined);
|
|
178
217
|
};
|
|
179
218
|
|
|
219
|
+
// If the dragged element is removed from the DOM via onDrop, onDragEnd won't fire: https://bugzilla.mozilla.org/show_bug.cgi?id=460801
|
|
220
|
+
// In this case, we need to manually call onDragEnd on cleanup
|
|
221
|
+
// eslint-disable-next-line arrow-body-style
|
|
222
|
+
useLayoutEffect(() => {
|
|
223
|
+
return () => {
|
|
224
|
+
if (isDraggingRef.current) {
|
|
225
|
+
if (typeof state.options.onDragEnd === 'function') {
|
|
226
|
+
let event: DragEndEvent = {
|
|
227
|
+
type: 'dragend',
|
|
228
|
+
x: 0,
|
|
229
|
+
y: 0,
|
|
230
|
+
dropOperation: DROP_EFFECT_TO_DROP_OPERATION[globalDropEffect || 'none']
|
|
231
|
+
};
|
|
232
|
+
state.options.onDragEnd(event);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
setDragging(false);
|
|
236
|
+
setGlobalAllowedDropOperations(DROP_OPERATION.none);
|
|
237
|
+
setGlobalDropEffect(undefined);
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
}, [state]);
|
|
241
|
+
|
|
180
242
|
let onPress = (e: PressEvent) => {
|
|
181
243
|
if (e.pointerType !== 'keyboard' && e.pointerType !== 'virtual') {
|
|
182
244
|
return;
|
|
183
245
|
}
|
|
184
246
|
|
|
247
|
+
startDragging(e.target as HTMLElement);
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
let startDragging = (target: HTMLElement) => {
|
|
185
251
|
if (typeof state.options.onDragStart === 'function') {
|
|
186
|
-
let rect =
|
|
252
|
+
let rect = target.getBoundingClientRect();
|
|
187
253
|
state.options.onDragStart({
|
|
188
254
|
type: 'dragstart',
|
|
189
255
|
x: rect.x + (rect.width / 2),
|
|
@@ -192,7 +258,7 @@ export function useDrag(options: DragOptions): DragResult {
|
|
|
192
258
|
}
|
|
193
259
|
|
|
194
260
|
DragManager.beginDragging({
|
|
195
|
-
element:
|
|
261
|
+
element: target,
|
|
196
262
|
items: state.options.getItems(),
|
|
197
263
|
allowedDropOperations: typeof state.options.getAllowedDropOperations === 'function'
|
|
198
264
|
? state.options.getAllowedDropOperations()
|
|
@@ -203,18 +269,86 @@ export function useDrag(options: DragOptions): DragResult {
|
|
|
203
269
|
state.options.onDragEnd(e);
|
|
204
270
|
}
|
|
205
271
|
}
|
|
206
|
-
},
|
|
272
|
+
}, stringFormatter);
|
|
207
273
|
|
|
208
274
|
setDragging(true);
|
|
209
275
|
};
|
|
210
276
|
|
|
211
277
|
let modality = useDragModality();
|
|
212
|
-
let
|
|
213
|
-
|
|
214
|
-
);
|
|
278
|
+
let message = !isDragging ? MESSAGES[modality].start : MESSAGES[modality].end;
|
|
279
|
+
|
|
280
|
+
let descriptionProps = useDescription(stringFormatter.format(message));
|
|
281
|
+
|
|
282
|
+
let interactions: HTMLAttributes<HTMLElement>;
|
|
283
|
+
if (!hasDragButton) {
|
|
284
|
+
// If there's no separate button to trigger accessible drag and drop mode,
|
|
285
|
+
// then add event handlers to the draggable element itself to start dragging.
|
|
286
|
+
// For keyboard, we use the Enter key in a capturing listener to prevent other
|
|
287
|
+
// events such as selection from also occurring. We attempt to infer whether a
|
|
288
|
+
// pointer event (e.g. long press) came from a touch screen reader, and then initiate
|
|
289
|
+
// dragging in the native onDragStart listener above.
|
|
290
|
+
|
|
291
|
+
interactions = {
|
|
292
|
+
...descriptionProps,
|
|
293
|
+
onPointerDown(e) {
|
|
294
|
+
modalityOnPointerDown.current = isVirtualPointerEvent(e.nativeEvent) ? 'virtual' : e.pointerType;
|
|
295
|
+
|
|
296
|
+
// Try to detect virtual drag passthrough gestures.
|
|
297
|
+
if (e.width < 1 && e.height < 1) {
|
|
298
|
+
// iOS VoiceOver.
|
|
299
|
+
modalityOnPointerDown.current = 'virtual';
|
|
300
|
+
} else {
|
|
301
|
+
let rect = e.currentTarget.getBoundingClientRect();
|
|
302
|
+
let offsetX = e.clientX - rect.x;
|
|
303
|
+
let offsetY = e.clientY - rect.y;
|
|
304
|
+
let centerX = rect.width / 2;
|
|
305
|
+
let centerY = rect.height / 2;
|
|
306
|
+
|
|
307
|
+
if (Math.abs(offsetX - centerX) <= 0.5 && Math.abs(offsetY - centerY) <= 0.5) {
|
|
308
|
+
// Android TalkBack.
|
|
309
|
+
modalityOnPointerDown.current = 'virtual';
|
|
310
|
+
} else {
|
|
311
|
+
modalityOnPointerDown.current = e.pointerType;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
},
|
|
315
|
+
onKeyDownCapture(e) {
|
|
316
|
+
if (e.target === e.currentTarget && e.key === 'Enter') {
|
|
317
|
+
e.preventDefault();
|
|
318
|
+
e.stopPropagation();
|
|
319
|
+
}
|
|
320
|
+
},
|
|
321
|
+
onKeyUpCapture(e) {
|
|
322
|
+
if (e.target === e.currentTarget && e.key === 'Enter') {
|
|
323
|
+
e.preventDefault();
|
|
324
|
+
e.stopPropagation();
|
|
325
|
+
startDragging(e.target as HTMLElement);
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
onClick(e) {
|
|
329
|
+
// Handle NVDA/JAWS in browse mode, and touch screen readers. In this case, no keyboard events are fired.
|
|
330
|
+
if (isVirtualClick(e.nativeEvent) || modalityOnPointerDown.current === 'virtual') {
|
|
331
|
+
e.preventDefault();
|
|
332
|
+
e.stopPropagation();
|
|
333
|
+
startDragging(e.target as HTMLElement);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
if (isDisabled) {
|
|
340
|
+
return {
|
|
341
|
+
dragProps: {
|
|
342
|
+
draggable: 'false'
|
|
343
|
+
},
|
|
344
|
+
dragButtonProps: {},
|
|
345
|
+
isDragging: false
|
|
346
|
+
};
|
|
347
|
+
}
|
|
215
348
|
|
|
216
349
|
return {
|
|
217
350
|
dragProps: {
|
|
351
|
+
...interactions,
|
|
218
352
|
draggable: 'true',
|
|
219
353
|
onDragStart,
|
|
220
354
|
onDrag,
|