@react-aria/dnd 3.11.3 → 3.11.5
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 +13 -9
- package/dist/DragManager.main.js.map +1 -1
- package/dist/DragManager.mjs +14 -10
- package/dist/DragManager.module.js +14 -10
- package/dist/DragManager.module.js.map +1 -1
- package/dist/DragPreview.main.js +1 -1
- package/dist/DragPreview.main.js.map +1 -1
- package/dist/DragPreview.mjs +1 -1
- package/dist/DragPreview.module.js +1 -1
- package/dist/DragPreview.module.js.map +1 -1
- package/dist/DropTargetKeyboardNavigation.main.js +11 -7
- package/dist/DropTargetKeyboardNavigation.main.js.map +1 -1
- package/dist/DropTargetKeyboardNavigation.mjs +11 -7
- package/dist/DropTargetKeyboardNavigation.module.js +11 -7
- package/dist/DropTargetKeyboardNavigation.module.js.map +1 -1
- package/dist/ListDropTargetDelegate.main.js +3 -0
- package/dist/ListDropTargetDelegate.main.js.map +1 -1
- package/dist/ListDropTargetDelegate.mjs +3 -0
- package/dist/ListDropTargetDelegate.module.js +3 -0
- package/dist/ListDropTargetDelegate.module.js.map +1 -1
- package/dist/es-ES.main.js +3 -3
- package/dist/es-ES.main.js.map +1 -1
- package/dist/es-ES.mjs +3 -3
- package/dist/es-ES.module.js +3 -3
- package/dist/es-ES.module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/useClipboard.main.js +1 -7
- package/dist/useClipboard.main.js.map +1 -1
- package/dist/useClipboard.mjs +1 -7
- package/dist/useClipboard.module.js +1 -7
- package/dist/useClipboard.module.js.map +1 -1
- package/dist/useDrop.main.js +2 -7
- package/dist/useDrop.main.js.map +1 -1
- package/dist/useDrop.mjs +3 -8
- package/dist/useDrop.module.js +3 -8
- package/dist/useDrop.module.js.map +1 -1
- package/package.json +10 -10
- package/src/DragManager.ts +11 -8
- package/src/DragPreview.tsx +1 -1
- package/src/DropTargetKeyboardNavigation.ts +17 -8
- package/src/ListDropTargetDelegate.ts +5 -0
- package/src/useClipboard.ts +1 -1
- package/src/useDrop.ts +3 -3
- package/src/.DS_Store +0 -0
package/src/DragPreview.tsx
CHANGED
|
@@ -74,7 +74,7 @@ React.forwardRef(function DragPreview(props: DragPreviewProps, ref: ForwardedRef
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
return (
|
|
77
|
-
<div style={{zIndex: -100, position: '
|
|
77
|
+
<div style={{zIndex: -100, position: 'fixed', top: 0, left: -100000}} ref={domRef}>
|
|
78
78
|
{children}
|
|
79
79
|
</div>
|
|
80
80
|
);
|
|
@@ -100,19 +100,25 @@ function nextDropTarget(
|
|
|
100
100
|
}
|
|
101
101
|
case 'after': {
|
|
102
102
|
// If this is the last sibling in a level, traverse to the parent.
|
|
103
|
-
let targetNode = collection.getItem(target.key);
|
|
104
|
-
|
|
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) {
|
|
105
110
|
// If the parent item has an item after it, use the "before" position.
|
|
106
111
|
let parentNode = collection.getItem(targetNode.parentKey);
|
|
107
|
-
|
|
112
|
+
const nextNode = parentNode?.nextKey != null ? collection.getItem(parentNode.nextKey) : null;
|
|
113
|
+
if (nextNode?.type === 'item') {
|
|
108
114
|
return {
|
|
109
115
|
type: 'item',
|
|
110
|
-
key:
|
|
116
|
+
key: nextNode.key,
|
|
111
117
|
dropPosition: 'before'
|
|
112
118
|
};
|
|
113
119
|
}
|
|
114
120
|
|
|
115
|
-
if (parentNode) {
|
|
121
|
+
if (parentNode?.type === 'item') {
|
|
116
122
|
return {
|
|
117
123
|
type: 'item',
|
|
118
124
|
key: parentNode.key,
|
|
@@ -121,10 +127,10 @@ function nextDropTarget(
|
|
|
121
127
|
}
|
|
122
128
|
}
|
|
123
129
|
|
|
124
|
-
if (
|
|
130
|
+
if (nextItemInSameLevel) {
|
|
125
131
|
return {
|
|
126
132
|
type: 'item',
|
|
127
|
-
key:
|
|
133
|
+
key: nextItemInSameLevel.key,
|
|
128
134
|
dropPosition: 'on'
|
|
129
135
|
};
|
|
130
136
|
}
|
|
@@ -154,8 +160,11 @@ function previousDropTarget(
|
|
|
154
160
|
let prevKey: Key | null = null;
|
|
155
161
|
let lastKey = keyboardDelegate.getLastKey?.();
|
|
156
162
|
while (lastKey != null) {
|
|
157
|
-
prevKey = lastKey;
|
|
158
163
|
let node = collection.getItem(lastKey);
|
|
164
|
+
if (node?.type !== 'item') {
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
prevKey = lastKey;
|
|
159
168
|
lastKey = node?.parentKey;
|
|
160
169
|
}
|
|
161
170
|
|
|
@@ -101,6 +101,11 @@ export class ListDropTargetDelegate implements DropTargetDelegate {
|
|
|
101
101
|
// Can see https://github.com/adobe/react-spectrum/pull/4210/files#diff-21e555e0c597a28215e36137f5be076a65a1e1456c92cd0fdd60f866929aae2a for additional logic
|
|
102
102
|
// that may need to happen then
|
|
103
103
|
let items = [...this.collection].filter(item => item.type === 'item');
|
|
104
|
+
|
|
105
|
+
if (items.length < 1) {
|
|
106
|
+
return {type: 'root'};
|
|
107
|
+
}
|
|
108
|
+
|
|
104
109
|
let low = 0;
|
|
105
110
|
let high = items.length;
|
|
106
111
|
while (low < high) {
|
package/src/useClipboard.ts
CHANGED
|
@@ -143,7 +143,7 @@ export function useClipboard(options: ClipboardProps): ClipboardResult {
|
|
|
143
143
|
addGlobalEventListener('beforepaste', onBeforePaste),
|
|
144
144
|
addGlobalEventListener('paste', onPaste)
|
|
145
145
|
);
|
|
146
|
-
}, [isDisabled
|
|
146
|
+
}, [isDisabled]);
|
|
147
147
|
|
|
148
148
|
return {
|
|
149
149
|
clipboardProps: focusProps
|
package/src/useDrop.ts
CHANGED
|
@@ -16,7 +16,7 @@ import {DragEvent, useRef, useState} from 'react';
|
|
|
16
16
|
import * as DragManager from './DragManager';
|
|
17
17
|
import {DragTypes, globalAllowedDropOperations, globalDndState, readFromDataTransfer, setGlobalDnDState, setGlobalDropEffect} from './utils';
|
|
18
18
|
import {DROP_EFFECT_TO_DROP_OPERATION, DROP_OPERATION, DROP_OPERATION_ALLOWED, DROP_OPERATION_TO_DROP_EFFECT} from './constants';
|
|
19
|
-
import {isIPad, isMac, useEffectEvent, useLayoutEffect} from '@react-aria/utils';
|
|
19
|
+
import {isIPad, isMac, nodeContains, useEffectEvent, useLayoutEffect} from '@react-aria/utils';
|
|
20
20
|
import {useVirtualDrop} from './useVirtualDrop';
|
|
21
21
|
|
|
22
22
|
export interface DropOptions {
|
|
@@ -234,7 +234,7 @@ export function useDrop(options: DropOptions): DropResult {
|
|
|
234
234
|
|
|
235
235
|
state.dragOverElements.delete(e.target as Element);
|
|
236
236
|
for (let element of state.dragOverElements) {
|
|
237
|
-
if (!e.currentTarget
|
|
237
|
+
if (!nodeContains(e.currentTarget, element)) {
|
|
238
238
|
state.dragOverElements.delete(element);
|
|
239
239
|
}
|
|
240
240
|
}
|
|
@@ -339,7 +339,7 @@ export function useDrop(options: DropOptions): DropResult {
|
|
|
339
339
|
onDrop: onKeyboardDrop,
|
|
340
340
|
onDropActivate
|
|
341
341
|
});
|
|
342
|
-
}, [isDisabled, ref
|
|
342
|
+
}, [isDisabled, ref]);
|
|
343
343
|
|
|
344
344
|
let {dropProps} = useVirtualDrop();
|
|
345
345
|
if (isDisabled) {
|
package/src/.DS_Store
DELETED
|
Binary file
|