@react-aria/dnd 3.6.1-nightly.4623 → 3.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/DragManager.main.js +68 -68
- package/dist/DragManager.mjs +68 -68
- package/dist/DragManager.module.js +68 -68
- package/dist/DragPreview.main.js +1 -1
- package/dist/DragPreview.mjs +1 -1
- package/dist/DragPreview.module.js +1 -1
- package/dist/ListDropTargetDelegate.main.js +31 -31
- package/dist/ListDropTargetDelegate.mjs +31 -31
- package/dist/ListDropTargetDelegate.module.js +31 -31
- package/dist/constants.main.js +10 -10
- package/dist/constants.mjs +10 -10
- package/dist/constants.module.js +10 -10
- package/dist/useClipboard.main.js +1 -1
- package/dist/useClipboard.mjs +1 -1
- package/dist/useClipboard.module.js +1 -1
- package/dist/useDrag.main.js +38 -38
- package/dist/useDrag.mjs +38 -38
- package/dist/useDrag.module.js +38 -38
- package/dist/useDraggableItem.main.js +17 -17
- package/dist/useDraggableItem.mjs +17 -17
- package/dist/useDraggableItem.module.js +17 -17
- package/dist/useDrop.main.js +30 -30
- package/dist/useDrop.mjs +30 -30
- package/dist/useDrop.module.js +30 -30
- package/dist/useDropIndicator.main.js +17 -17
- package/dist/useDropIndicator.mjs +17 -17
- package/dist/useDropIndicator.module.js +17 -17
- package/dist/useDroppableCollection.main.js +83 -83
- package/dist/useDroppableCollection.mjs +83 -83
- package/dist/useDroppableCollection.module.js +83 -83
- package/dist/useDroppableItem.main.js +2 -2
- package/dist/useDroppableItem.mjs +2 -2
- package/dist/useDroppableItem.module.js +2 -2
- package/dist/useVirtualDrop.main.js +5 -5
- package/dist/useVirtualDrop.mjs +5 -5
- package/dist/useVirtualDrop.module.js +5 -5
- package/dist/utils.main.js +20 -20
- package/dist/utils.mjs +20 -20
- package/dist/utils.module.js +20 -20
- package/package.json +11 -11
package/dist/useDrag.mjs
CHANGED
|
@@ -29,21 +29,21 @@ function $parcel$interopDefault(a) {
|
|
|
29
29
|
|
|
30
30
|
const $8253ed7ece74b463$var$MESSAGES = {
|
|
31
31
|
keyboard: {
|
|
32
|
-
start:
|
|
33
|
-
end:
|
|
32
|
+
start: 'dragDescriptionKeyboard',
|
|
33
|
+
end: 'endDragKeyboard'
|
|
34
34
|
},
|
|
35
35
|
touch: {
|
|
36
|
-
start:
|
|
37
|
-
end:
|
|
36
|
+
start: 'dragDescriptionTouch',
|
|
37
|
+
end: 'endDragTouch'
|
|
38
38
|
},
|
|
39
39
|
virtual: {
|
|
40
|
-
start:
|
|
41
|
-
end:
|
|
40
|
+
start: 'dragDescriptionVirtual',
|
|
41
|
+
end: 'endDragVirtual'
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
function $8253ed7ece74b463$export$7941f8aafa4b6021(options) {
|
|
45
45
|
let { hasDragButton: hasDragButton, isDisabled: isDisabled } = options;
|
|
46
|
-
let stringFormatter = (0, $72Evg$useLocalizedStringFormatter)((0, ($parcel$interopDefault($72Evg$intlStringsmodulejs))),
|
|
46
|
+
let stringFormatter = (0, $72Evg$useLocalizedStringFormatter)((0, ($parcel$interopDefault($72Evg$intlStringsmodulejs))), '@react-aria/dnd');
|
|
47
47
|
let state = (0, $72Evg$useRef)({
|
|
48
48
|
options: options,
|
|
49
49
|
x: 0,
|
|
@@ -64,30 +64,30 @@ function $8253ed7ece74b463$export$7941f8aafa4b6021(options) {
|
|
|
64
64
|
// Prevent the drag event from propagating to any parent draggables
|
|
65
65
|
e.stopPropagation();
|
|
66
66
|
// If this drag was initiated by a mobile screen reader (e.g. VoiceOver or TalkBack), enter virtual dragging mode.
|
|
67
|
-
if (modalityOnPointerDown.current ===
|
|
67
|
+
if (modalityOnPointerDown.current === 'virtual') {
|
|
68
68
|
e.preventDefault();
|
|
69
69
|
startDragging(e.target);
|
|
70
70
|
modalityOnPointerDown.current = null;
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
|
-
if (typeof options.onDragStart ===
|
|
74
|
-
type:
|
|
73
|
+
if (typeof options.onDragStart === 'function') options.onDragStart({
|
|
74
|
+
type: 'dragstart',
|
|
75
75
|
x: e.clientX,
|
|
76
76
|
y: e.clientY
|
|
77
77
|
});
|
|
78
78
|
let items = options.getItems();
|
|
79
79
|
(0, $7252cd45fc48c07c$export$f9c1490890ddd063)(e.dataTransfer, items);
|
|
80
80
|
let allowed = (0, $103790afe9474d1c$export$60b7b4bcf3903d8e).all;
|
|
81
|
-
if (typeof options.getAllowedDropOperations ===
|
|
81
|
+
if (typeof options.getAllowedDropOperations === 'function') {
|
|
82
82
|
let allowedOperations = options.getAllowedDropOperations();
|
|
83
83
|
allowed = (0, $103790afe9474d1c$export$60b7b4bcf3903d8e).none;
|
|
84
84
|
for (let operation of allowedOperations)allowed |= (0, $103790afe9474d1c$export$60b7b4bcf3903d8e)[operation] || (0, $103790afe9474d1c$export$60b7b4bcf3903d8e).none;
|
|
85
85
|
}
|
|
86
86
|
(0, $7252cd45fc48c07c$export$6539bc8c3a0a2d67)(allowed);
|
|
87
|
-
e.dataTransfer.effectAllowed = (0, $103790afe9474d1c$export$dd0165308d8bff45)[allowed] ||
|
|
87
|
+
e.dataTransfer.effectAllowed = (0, $103790afe9474d1c$export$dd0165308d8bff45)[allowed] || 'none';
|
|
88
88
|
// If there is a preview option, use it to render a custom preview image that will
|
|
89
89
|
// appear under the pointer while dragging. If not, the element itself is dragged by the browser.
|
|
90
|
-
if (typeof ((_options_preview = options.preview) === null || _options_preview === void 0 ? void 0 : _options_preview.current) ===
|
|
90
|
+
if (typeof ((_options_preview = options.preview) === null || _options_preview === void 0 ? void 0 : _options_preview.current) === 'function') options.preview.current(items, (node)=>{
|
|
91
91
|
// Compute the offset that the preview will appear under the mouse.
|
|
92
92
|
// If possible, this is based on the point the user clicked on the target.
|
|
93
93
|
// If the preview is much smaller, then just use the center point of the preview.
|
|
@@ -105,10 +105,10 @@ function $8253ed7ece74b463$export$7941f8aafa4b6021(options) {
|
|
|
105
105
|
e.dataTransfer.setDragImage(node, x, y);
|
|
106
106
|
});
|
|
107
107
|
// Enforce that drops are handled by useDrop.
|
|
108
|
-
addGlobalListener(window,
|
|
108
|
+
addGlobalListener(window, 'drop', (e)=>{
|
|
109
109
|
e.preventDefault();
|
|
110
110
|
e.stopPropagation();
|
|
111
|
-
console.warn(
|
|
111
|
+
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.');
|
|
112
112
|
}, {
|
|
113
113
|
once: true
|
|
114
114
|
});
|
|
@@ -124,8 +124,8 @@ function $8253ed7ece74b463$export$7941f8aafa4b6021(options) {
|
|
|
124
124
|
// Prevent the drag event from propagating to any parent draggables
|
|
125
125
|
e.stopPropagation();
|
|
126
126
|
if (e.clientX === state.x && e.clientY === state.y) return;
|
|
127
|
-
if (typeof options.onDragMove ===
|
|
128
|
-
type:
|
|
127
|
+
if (typeof options.onDragMove === 'function') options.onDragMove({
|
|
128
|
+
type: 'dragmove',
|
|
129
129
|
x: e.clientX,
|
|
130
130
|
y: e.clientY
|
|
131
131
|
});
|
|
@@ -135,9 +135,9 @@ function $8253ed7ece74b463$export$7941f8aafa4b6021(options) {
|
|
|
135
135
|
let onDragEnd = (e)=>{
|
|
136
136
|
// Prevent the drag event from propagating to any parent draggables
|
|
137
137
|
e.stopPropagation();
|
|
138
|
-
if (typeof options.onDragEnd ===
|
|
138
|
+
if (typeof options.onDragEnd === 'function') {
|
|
139
139
|
let event = {
|
|
140
|
-
type:
|
|
140
|
+
type: 'dragend',
|
|
141
141
|
x: e.clientX,
|
|
142
142
|
y: e.clientY,
|
|
143
143
|
dropOperation: (0, $103790afe9474d1c$export$608ecc6f1b23c35d)[e.dataTransfer.dropEffect]
|
|
@@ -158,12 +158,12 @@ function $8253ed7ece74b463$export$7941f8aafa4b6021(options) {
|
|
|
158
158
|
(0, $72Evg$useLayoutEffect)(()=>{
|
|
159
159
|
return ()=>{
|
|
160
160
|
if (isDraggingRef.current) {
|
|
161
|
-
if (typeof state.options.onDragEnd ===
|
|
161
|
+
if (typeof state.options.onDragEnd === 'function') {
|
|
162
162
|
let event = {
|
|
163
|
-
type:
|
|
163
|
+
type: 'dragend',
|
|
164
164
|
x: 0,
|
|
165
165
|
y: 0,
|
|
166
|
-
dropOperation: (0, $103790afe9474d1c$export$608ecc6f1b23c35d)[(0, $7252cd45fc48c07c$export$8e6636520ac15722) ||
|
|
166
|
+
dropOperation: (0, $103790afe9474d1c$export$608ecc6f1b23c35d)[(0, $7252cd45fc48c07c$export$8e6636520ac15722) || 'none']
|
|
167
167
|
};
|
|
168
168
|
state.options.onDragEnd(event);
|
|
169
169
|
}
|
|
@@ -176,14 +176,14 @@ function $8253ed7ece74b463$export$7941f8aafa4b6021(options) {
|
|
|
176
176
|
state
|
|
177
177
|
]);
|
|
178
178
|
let onPress = (e)=>{
|
|
179
|
-
if (e.pointerType !==
|
|
179
|
+
if (e.pointerType !== 'keyboard' && e.pointerType !== 'virtual') return;
|
|
180
180
|
startDragging(e.target);
|
|
181
181
|
};
|
|
182
182
|
let startDragging = (target)=>{
|
|
183
|
-
if (typeof state.options.onDragStart ===
|
|
183
|
+
if (typeof state.options.onDragStart === 'function') {
|
|
184
184
|
let rect = target.getBoundingClientRect();
|
|
185
185
|
state.options.onDragStart({
|
|
186
|
-
type:
|
|
186
|
+
type: 'dragstart',
|
|
187
187
|
x: rect.x + rect.width / 2,
|
|
188
188
|
y: rect.y + rect.height / 2
|
|
189
189
|
});
|
|
@@ -191,14 +191,14 @@ function $8253ed7ece74b463$export$7941f8aafa4b6021(options) {
|
|
|
191
191
|
$67560de7c78cb232$export$549dbcf8649bf3b2({
|
|
192
192
|
element: target,
|
|
193
193
|
items: state.options.getItems(),
|
|
194
|
-
allowedDropOperations: typeof state.options.getAllowedDropOperations ===
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
194
|
+
allowedDropOperations: typeof state.options.getAllowedDropOperations === 'function' ? state.options.getAllowedDropOperations() : [
|
|
195
|
+
'move',
|
|
196
|
+
'copy',
|
|
197
|
+
'link'
|
|
198
198
|
],
|
|
199
199
|
onDragEnd (e) {
|
|
200
200
|
setDragging(false);
|
|
201
|
-
if (typeof state.options.onDragEnd ===
|
|
201
|
+
if (typeof state.options.onDragEnd === 'function') state.options.onDragEnd(e);
|
|
202
202
|
}
|
|
203
203
|
}, stringFormatter);
|
|
204
204
|
setDragging(true);
|
|
@@ -216,10 +216,10 @@ function $8253ed7ece74b463$export$7941f8aafa4b6021(options) {
|
|
|
216
216
|
interactions = {
|
|
217
217
|
...descriptionProps,
|
|
218
218
|
onPointerDown (e) {
|
|
219
|
-
modalityOnPointerDown.current = (0, $72Evg$isVirtualPointerEvent)(e.nativeEvent) ?
|
|
219
|
+
modalityOnPointerDown.current = (0, $72Evg$isVirtualPointerEvent)(e.nativeEvent) ? 'virtual' : e.pointerType;
|
|
220
220
|
// Try to detect virtual drag passthrough gestures.
|
|
221
221
|
if (e.width < 1 && e.height < 1) // iOS VoiceOver.
|
|
222
|
-
modalityOnPointerDown.current =
|
|
222
|
+
modalityOnPointerDown.current = 'virtual';
|
|
223
223
|
else {
|
|
224
224
|
let rect = e.currentTarget.getBoundingClientRect();
|
|
225
225
|
let offsetX = e.clientX - rect.x;
|
|
@@ -227,18 +227,18 @@ function $8253ed7ece74b463$export$7941f8aafa4b6021(options) {
|
|
|
227
227
|
let centerX = rect.width / 2;
|
|
228
228
|
let centerY = rect.height / 2;
|
|
229
229
|
if (Math.abs(offsetX - centerX) <= 0.5 && Math.abs(offsetY - centerY) <= 0.5) // Android TalkBack.
|
|
230
|
-
modalityOnPointerDown.current =
|
|
230
|
+
modalityOnPointerDown.current = 'virtual';
|
|
231
231
|
else modalityOnPointerDown.current = e.pointerType;
|
|
232
232
|
}
|
|
233
233
|
},
|
|
234
234
|
onKeyDownCapture (e) {
|
|
235
|
-
if (e.target === e.currentTarget && e.key ===
|
|
235
|
+
if (e.target === e.currentTarget && e.key === 'Enter') {
|
|
236
236
|
e.preventDefault();
|
|
237
237
|
e.stopPropagation();
|
|
238
238
|
}
|
|
239
239
|
},
|
|
240
240
|
onKeyUpCapture (e) {
|
|
241
|
-
if (e.target === e.currentTarget && e.key ===
|
|
241
|
+
if (e.target === e.currentTarget && e.key === 'Enter') {
|
|
242
242
|
e.preventDefault();
|
|
243
243
|
e.stopPropagation();
|
|
244
244
|
startDragging(e.target);
|
|
@@ -246,7 +246,7 @@ function $8253ed7ece74b463$export$7941f8aafa4b6021(options) {
|
|
|
246
246
|
},
|
|
247
247
|
onClick (e) {
|
|
248
248
|
// Handle NVDA/JAWS in browse mode, and touch screen readers. In this case, no keyboard events are fired.
|
|
249
|
-
if ((0, $72Evg$isVirtualClick)(e.nativeEvent) || modalityOnPointerDown.current ===
|
|
249
|
+
if ((0, $72Evg$isVirtualClick)(e.nativeEvent) || modalityOnPointerDown.current === 'virtual') {
|
|
250
250
|
e.preventDefault();
|
|
251
251
|
e.stopPropagation();
|
|
252
252
|
startDragging(e.target);
|
|
@@ -255,7 +255,7 @@ function $8253ed7ece74b463$export$7941f8aafa4b6021(options) {
|
|
|
255
255
|
};
|
|
256
256
|
if (isDisabled) return {
|
|
257
257
|
dragProps: {
|
|
258
|
-
draggable:
|
|
258
|
+
draggable: 'false'
|
|
259
259
|
},
|
|
260
260
|
dragButtonProps: {},
|
|
261
261
|
isDragging: false
|
|
@@ -263,7 +263,7 @@ function $8253ed7ece74b463$export$7941f8aafa4b6021(options) {
|
|
|
263
263
|
return {
|
|
264
264
|
dragProps: {
|
|
265
265
|
...interactions,
|
|
266
|
-
draggable:
|
|
266
|
+
draggable: 'true',
|
|
267
267
|
onDragStart: onDragStart,
|
|
268
268
|
onDrag: onDrag,
|
|
269
269
|
onDragEnd: onDragEnd
|
package/dist/useDrag.module.js
CHANGED
|
@@ -29,21 +29,21 @@ function $parcel$interopDefault(a) {
|
|
|
29
29
|
|
|
30
30
|
const $8253ed7ece74b463$var$MESSAGES = {
|
|
31
31
|
keyboard: {
|
|
32
|
-
start:
|
|
33
|
-
end:
|
|
32
|
+
start: 'dragDescriptionKeyboard',
|
|
33
|
+
end: 'endDragKeyboard'
|
|
34
34
|
},
|
|
35
35
|
touch: {
|
|
36
|
-
start:
|
|
37
|
-
end:
|
|
36
|
+
start: 'dragDescriptionTouch',
|
|
37
|
+
end: 'endDragTouch'
|
|
38
38
|
},
|
|
39
39
|
virtual: {
|
|
40
|
-
start:
|
|
41
|
-
end:
|
|
40
|
+
start: 'dragDescriptionVirtual',
|
|
41
|
+
end: 'endDragVirtual'
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
function $8253ed7ece74b463$export$7941f8aafa4b6021(options) {
|
|
45
45
|
let { hasDragButton: hasDragButton, isDisabled: isDisabled } = options;
|
|
46
|
-
let stringFormatter = (0, $72Evg$useLocalizedStringFormatter)((0, ($parcel$interopDefault($72Evg$intlStringsmodulejs))),
|
|
46
|
+
let stringFormatter = (0, $72Evg$useLocalizedStringFormatter)((0, ($parcel$interopDefault($72Evg$intlStringsmodulejs))), '@react-aria/dnd');
|
|
47
47
|
let state = (0, $72Evg$useRef)({
|
|
48
48
|
options: options,
|
|
49
49
|
x: 0,
|
|
@@ -64,30 +64,30 @@ function $8253ed7ece74b463$export$7941f8aafa4b6021(options) {
|
|
|
64
64
|
// Prevent the drag event from propagating to any parent draggables
|
|
65
65
|
e.stopPropagation();
|
|
66
66
|
// If this drag was initiated by a mobile screen reader (e.g. VoiceOver or TalkBack), enter virtual dragging mode.
|
|
67
|
-
if (modalityOnPointerDown.current ===
|
|
67
|
+
if (modalityOnPointerDown.current === 'virtual') {
|
|
68
68
|
e.preventDefault();
|
|
69
69
|
startDragging(e.target);
|
|
70
70
|
modalityOnPointerDown.current = null;
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
|
-
if (typeof options.onDragStart ===
|
|
74
|
-
type:
|
|
73
|
+
if (typeof options.onDragStart === 'function') options.onDragStart({
|
|
74
|
+
type: 'dragstart',
|
|
75
75
|
x: e.clientX,
|
|
76
76
|
y: e.clientY
|
|
77
77
|
});
|
|
78
78
|
let items = options.getItems();
|
|
79
79
|
(0, $7252cd45fc48c07c$export$f9c1490890ddd063)(e.dataTransfer, items);
|
|
80
80
|
let allowed = (0, $103790afe9474d1c$export$60b7b4bcf3903d8e).all;
|
|
81
|
-
if (typeof options.getAllowedDropOperations ===
|
|
81
|
+
if (typeof options.getAllowedDropOperations === 'function') {
|
|
82
82
|
let allowedOperations = options.getAllowedDropOperations();
|
|
83
83
|
allowed = (0, $103790afe9474d1c$export$60b7b4bcf3903d8e).none;
|
|
84
84
|
for (let operation of allowedOperations)allowed |= (0, $103790afe9474d1c$export$60b7b4bcf3903d8e)[operation] || (0, $103790afe9474d1c$export$60b7b4bcf3903d8e).none;
|
|
85
85
|
}
|
|
86
86
|
(0, $7252cd45fc48c07c$export$6539bc8c3a0a2d67)(allowed);
|
|
87
|
-
e.dataTransfer.effectAllowed = (0, $103790afe9474d1c$export$dd0165308d8bff45)[allowed] ||
|
|
87
|
+
e.dataTransfer.effectAllowed = (0, $103790afe9474d1c$export$dd0165308d8bff45)[allowed] || 'none';
|
|
88
88
|
// If there is a preview option, use it to render a custom preview image that will
|
|
89
89
|
// appear under the pointer while dragging. If not, the element itself is dragged by the browser.
|
|
90
|
-
if (typeof ((_options_preview = options.preview) === null || _options_preview === void 0 ? void 0 : _options_preview.current) ===
|
|
90
|
+
if (typeof ((_options_preview = options.preview) === null || _options_preview === void 0 ? void 0 : _options_preview.current) === 'function') options.preview.current(items, (node)=>{
|
|
91
91
|
// Compute the offset that the preview will appear under the mouse.
|
|
92
92
|
// If possible, this is based on the point the user clicked on the target.
|
|
93
93
|
// If the preview is much smaller, then just use the center point of the preview.
|
|
@@ -105,10 +105,10 @@ function $8253ed7ece74b463$export$7941f8aafa4b6021(options) {
|
|
|
105
105
|
e.dataTransfer.setDragImage(node, x, y);
|
|
106
106
|
});
|
|
107
107
|
// Enforce that drops are handled by useDrop.
|
|
108
|
-
addGlobalListener(window,
|
|
108
|
+
addGlobalListener(window, 'drop', (e)=>{
|
|
109
109
|
e.preventDefault();
|
|
110
110
|
e.stopPropagation();
|
|
111
|
-
console.warn(
|
|
111
|
+
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.');
|
|
112
112
|
}, {
|
|
113
113
|
once: true
|
|
114
114
|
});
|
|
@@ -124,8 +124,8 @@ function $8253ed7ece74b463$export$7941f8aafa4b6021(options) {
|
|
|
124
124
|
// Prevent the drag event from propagating to any parent draggables
|
|
125
125
|
e.stopPropagation();
|
|
126
126
|
if (e.clientX === state.x && e.clientY === state.y) return;
|
|
127
|
-
if (typeof options.onDragMove ===
|
|
128
|
-
type:
|
|
127
|
+
if (typeof options.onDragMove === 'function') options.onDragMove({
|
|
128
|
+
type: 'dragmove',
|
|
129
129
|
x: e.clientX,
|
|
130
130
|
y: e.clientY
|
|
131
131
|
});
|
|
@@ -135,9 +135,9 @@ function $8253ed7ece74b463$export$7941f8aafa4b6021(options) {
|
|
|
135
135
|
let onDragEnd = (e)=>{
|
|
136
136
|
// Prevent the drag event from propagating to any parent draggables
|
|
137
137
|
e.stopPropagation();
|
|
138
|
-
if (typeof options.onDragEnd ===
|
|
138
|
+
if (typeof options.onDragEnd === 'function') {
|
|
139
139
|
let event = {
|
|
140
|
-
type:
|
|
140
|
+
type: 'dragend',
|
|
141
141
|
x: e.clientX,
|
|
142
142
|
y: e.clientY,
|
|
143
143
|
dropOperation: (0, $103790afe9474d1c$export$608ecc6f1b23c35d)[e.dataTransfer.dropEffect]
|
|
@@ -158,12 +158,12 @@ function $8253ed7ece74b463$export$7941f8aafa4b6021(options) {
|
|
|
158
158
|
(0, $72Evg$useLayoutEffect)(()=>{
|
|
159
159
|
return ()=>{
|
|
160
160
|
if (isDraggingRef.current) {
|
|
161
|
-
if (typeof state.options.onDragEnd ===
|
|
161
|
+
if (typeof state.options.onDragEnd === 'function') {
|
|
162
162
|
let event = {
|
|
163
|
-
type:
|
|
163
|
+
type: 'dragend',
|
|
164
164
|
x: 0,
|
|
165
165
|
y: 0,
|
|
166
|
-
dropOperation: (0, $103790afe9474d1c$export$608ecc6f1b23c35d)[(0, $7252cd45fc48c07c$export$8e6636520ac15722) ||
|
|
166
|
+
dropOperation: (0, $103790afe9474d1c$export$608ecc6f1b23c35d)[(0, $7252cd45fc48c07c$export$8e6636520ac15722) || 'none']
|
|
167
167
|
};
|
|
168
168
|
state.options.onDragEnd(event);
|
|
169
169
|
}
|
|
@@ -176,14 +176,14 @@ function $8253ed7ece74b463$export$7941f8aafa4b6021(options) {
|
|
|
176
176
|
state
|
|
177
177
|
]);
|
|
178
178
|
let onPress = (e)=>{
|
|
179
|
-
if (e.pointerType !==
|
|
179
|
+
if (e.pointerType !== 'keyboard' && e.pointerType !== 'virtual') return;
|
|
180
180
|
startDragging(e.target);
|
|
181
181
|
};
|
|
182
182
|
let startDragging = (target)=>{
|
|
183
|
-
if (typeof state.options.onDragStart ===
|
|
183
|
+
if (typeof state.options.onDragStart === 'function') {
|
|
184
184
|
let rect = target.getBoundingClientRect();
|
|
185
185
|
state.options.onDragStart({
|
|
186
|
-
type:
|
|
186
|
+
type: 'dragstart',
|
|
187
187
|
x: rect.x + rect.width / 2,
|
|
188
188
|
y: rect.y + rect.height / 2
|
|
189
189
|
});
|
|
@@ -191,14 +191,14 @@ function $8253ed7ece74b463$export$7941f8aafa4b6021(options) {
|
|
|
191
191
|
$67560de7c78cb232$export$549dbcf8649bf3b2({
|
|
192
192
|
element: target,
|
|
193
193
|
items: state.options.getItems(),
|
|
194
|
-
allowedDropOperations: typeof state.options.getAllowedDropOperations ===
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
194
|
+
allowedDropOperations: typeof state.options.getAllowedDropOperations === 'function' ? state.options.getAllowedDropOperations() : [
|
|
195
|
+
'move',
|
|
196
|
+
'copy',
|
|
197
|
+
'link'
|
|
198
198
|
],
|
|
199
199
|
onDragEnd (e) {
|
|
200
200
|
setDragging(false);
|
|
201
|
-
if (typeof state.options.onDragEnd ===
|
|
201
|
+
if (typeof state.options.onDragEnd === 'function') state.options.onDragEnd(e);
|
|
202
202
|
}
|
|
203
203
|
}, stringFormatter);
|
|
204
204
|
setDragging(true);
|
|
@@ -216,10 +216,10 @@ function $8253ed7ece74b463$export$7941f8aafa4b6021(options) {
|
|
|
216
216
|
interactions = {
|
|
217
217
|
...descriptionProps,
|
|
218
218
|
onPointerDown (e) {
|
|
219
|
-
modalityOnPointerDown.current = (0, $72Evg$isVirtualPointerEvent)(e.nativeEvent) ?
|
|
219
|
+
modalityOnPointerDown.current = (0, $72Evg$isVirtualPointerEvent)(e.nativeEvent) ? 'virtual' : e.pointerType;
|
|
220
220
|
// Try to detect virtual drag passthrough gestures.
|
|
221
221
|
if (e.width < 1 && e.height < 1) // iOS VoiceOver.
|
|
222
|
-
modalityOnPointerDown.current =
|
|
222
|
+
modalityOnPointerDown.current = 'virtual';
|
|
223
223
|
else {
|
|
224
224
|
let rect = e.currentTarget.getBoundingClientRect();
|
|
225
225
|
let offsetX = e.clientX - rect.x;
|
|
@@ -227,18 +227,18 @@ function $8253ed7ece74b463$export$7941f8aafa4b6021(options) {
|
|
|
227
227
|
let centerX = rect.width / 2;
|
|
228
228
|
let centerY = rect.height / 2;
|
|
229
229
|
if (Math.abs(offsetX - centerX) <= 0.5 && Math.abs(offsetY - centerY) <= 0.5) // Android TalkBack.
|
|
230
|
-
modalityOnPointerDown.current =
|
|
230
|
+
modalityOnPointerDown.current = 'virtual';
|
|
231
231
|
else modalityOnPointerDown.current = e.pointerType;
|
|
232
232
|
}
|
|
233
233
|
},
|
|
234
234
|
onKeyDownCapture (e) {
|
|
235
|
-
if (e.target === e.currentTarget && e.key ===
|
|
235
|
+
if (e.target === e.currentTarget && e.key === 'Enter') {
|
|
236
236
|
e.preventDefault();
|
|
237
237
|
e.stopPropagation();
|
|
238
238
|
}
|
|
239
239
|
},
|
|
240
240
|
onKeyUpCapture (e) {
|
|
241
|
-
if (e.target === e.currentTarget && e.key ===
|
|
241
|
+
if (e.target === e.currentTarget && e.key === 'Enter') {
|
|
242
242
|
e.preventDefault();
|
|
243
243
|
e.stopPropagation();
|
|
244
244
|
startDragging(e.target);
|
|
@@ -246,7 +246,7 @@ function $8253ed7ece74b463$export$7941f8aafa4b6021(options) {
|
|
|
246
246
|
},
|
|
247
247
|
onClick (e) {
|
|
248
248
|
// Handle NVDA/JAWS in browse mode, and touch screen readers. In this case, no keyboard events are fired.
|
|
249
|
-
if ((0, $72Evg$isVirtualClick)(e.nativeEvent) || modalityOnPointerDown.current ===
|
|
249
|
+
if ((0, $72Evg$isVirtualClick)(e.nativeEvent) || modalityOnPointerDown.current === 'virtual') {
|
|
250
250
|
e.preventDefault();
|
|
251
251
|
e.stopPropagation();
|
|
252
252
|
startDragging(e.target);
|
|
@@ -255,7 +255,7 @@ function $8253ed7ece74b463$export$7941f8aafa4b6021(options) {
|
|
|
255
255
|
};
|
|
256
256
|
if (isDisabled) return {
|
|
257
257
|
dragProps: {
|
|
258
|
-
draggable:
|
|
258
|
+
draggable: 'false'
|
|
259
259
|
},
|
|
260
260
|
dragButtonProps: {},
|
|
261
261
|
isDragging: false
|
|
@@ -263,7 +263,7 @@ function $8253ed7ece74b463$export$7941f8aafa4b6021(options) {
|
|
|
263
263
|
return {
|
|
264
264
|
dragProps: {
|
|
265
265
|
...interactions,
|
|
266
|
-
draggable:
|
|
266
|
+
draggable: 'true',
|
|
267
267
|
onDragStart: onDragStart,
|
|
268
268
|
onDrag: onDrag,
|
|
269
269
|
onDragEnd: onDragEnd
|
|
@@ -31,20 +31,20 @@ $parcel$export(module.exports, "useDraggableItem", () => $0cbbd00cda972c67$expor
|
|
|
31
31
|
|
|
32
32
|
const $0cbbd00cda972c67$var$MESSAGES = {
|
|
33
33
|
keyboard: {
|
|
34
|
-
selected:
|
|
35
|
-
notSelected:
|
|
34
|
+
selected: 'dragSelectedKeyboard',
|
|
35
|
+
notSelected: 'dragDescriptionKeyboard'
|
|
36
36
|
},
|
|
37
37
|
touch: {
|
|
38
|
-
selected:
|
|
39
|
-
notSelected:
|
|
38
|
+
selected: 'dragSelectedLongPress',
|
|
39
|
+
notSelected: 'dragDescriptionLongPress'
|
|
40
40
|
},
|
|
41
41
|
virtual: {
|
|
42
|
-
selected:
|
|
43
|
-
notSelected:
|
|
42
|
+
selected: 'dragDescriptionVirtual',
|
|
43
|
+
notSelected: 'dragDescriptionVirtual'
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
46
|
function $0cbbd00cda972c67$export$b35afafff42da2d9(props, state) {
|
|
47
|
-
let stringFormatter = (0, $6Ms7J$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($7c8adf3925a26206$exports))),
|
|
47
|
+
let stringFormatter = (0, $6Ms7J$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($7c8adf3925a26206$exports))), '@react-aria/dnd');
|
|
48
48
|
let isDisabled = state.isDisabled || state.selectionManager.isDisabled(props.key);
|
|
49
49
|
let { dragProps: dragProps, dragButtonProps: dragButtonProps } = (0, $dc204e8ec58447a6$exports.useDrag)({
|
|
50
50
|
getItems () {
|
|
@@ -63,7 +63,7 @@ function $0cbbd00cda972c67$export$b35afafff42da2d9(props, state) {
|
|
|
63
63
|
},
|
|
64
64
|
onDragEnd (e) {
|
|
65
65
|
let { dropOperation: dropOperation } = e;
|
|
66
|
-
let isInternal = dropOperation ===
|
|
66
|
+
let isInternal = dropOperation === 'cancel' ? false : (0, $4620ae0dc40f0031$exports.isInternalDropOperation)();
|
|
67
67
|
state.endDrag({
|
|
68
68
|
...e,
|
|
69
69
|
keys: state.draggingKeys,
|
|
@@ -79,9 +79,9 @@ function $0cbbd00cda972c67$export$b35afafff42da2d9(props, state) {
|
|
|
79
79
|
let description;
|
|
80
80
|
// Override description to include selected item count.
|
|
81
81
|
let modality = (0, $4620ae0dc40f0031$exports.useDragModality)();
|
|
82
|
-
if (!props.hasDragButton && state.selectionManager.selectionMode !==
|
|
83
|
-
let msg = $0cbbd00cda972c67$var$MESSAGES[modality][isSelected ?
|
|
84
|
-
if (props.hasAction && modality ===
|
|
82
|
+
if (!props.hasDragButton && state.selectionManager.selectionMode !== 'none') {
|
|
83
|
+
let msg = $0cbbd00cda972c67$var$MESSAGES[modality][isSelected ? 'selected' : 'notSelected'];
|
|
84
|
+
if (props.hasAction && modality === 'keyboard') msg += 'Alt';
|
|
85
85
|
if (isSelected) description = stringFormatter.format(msg, {
|
|
86
86
|
count: numKeysForDrag
|
|
87
87
|
});
|
|
@@ -89,14 +89,14 @@ function $0cbbd00cda972c67$export$b35afafff42da2d9(props, state) {
|
|
|
89
89
|
// Remove the onClick handler from useDrag. Long pressing will be required on touch devices,
|
|
90
90
|
// and NVDA/JAWS are always in forms mode within collection components.
|
|
91
91
|
delete dragProps.onClick;
|
|
92
|
-
} else if (isSelected) dragButtonLabel = stringFormatter.format(
|
|
92
|
+
} else if (isSelected) dragButtonLabel = stringFormatter.format('dragSelectedItems', {
|
|
93
93
|
count: numKeysForDrag
|
|
94
94
|
});
|
|
95
95
|
else {
|
|
96
96
|
var _state_collection_getTextValue, _state_collection;
|
|
97
97
|
var _state_collection_getTextValue1, _ref;
|
|
98
|
-
let itemText = (_ref = (_state_collection_getTextValue1 = (_state_collection_getTextValue = (_state_collection = state.collection).getTextValue) === null || _state_collection_getTextValue === void 0 ? void 0 : _state_collection_getTextValue.call(_state_collection, props.key)) !== null && _state_collection_getTextValue1 !== void 0 ? _state_collection_getTextValue1 : item === null || item === void 0 ? void 0 : item.textValue) !== null && _ref !== void 0 ? _ref :
|
|
99
|
-
dragButtonLabel = stringFormatter.format(
|
|
98
|
+
let itemText = (_ref = (_state_collection_getTextValue1 = (_state_collection_getTextValue = (_state_collection = state.collection).getTextValue) === null || _state_collection_getTextValue === void 0 ? void 0 : _state_collection_getTextValue.call(_state_collection, props.key)) !== null && _state_collection_getTextValue1 !== void 0 ? _state_collection_getTextValue1 : item === null || item === void 0 ? void 0 : item.textValue) !== null && _ref !== void 0 ? _ref : '';
|
|
99
|
+
dragButtonLabel = stringFormatter.format('dragItem', {
|
|
100
100
|
itemText: itemText
|
|
101
101
|
});
|
|
102
102
|
}
|
|
@@ -104,8 +104,8 @@ function $0cbbd00cda972c67$export$b35afafff42da2d9(props, state) {
|
|
|
104
104
|
if (description) Object.assign(dragProps, descriptionProps);
|
|
105
105
|
if (!props.hasDragButton && props.hasAction) {
|
|
106
106
|
let { onKeyDownCapture: onKeyDownCapture, onKeyUpCapture: onKeyUpCapture } = dragProps;
|
|
107
|
-
if (modality ===
|
|
108
|
-
delete dragProps[
|
|
107
|
+
if (modality === 'touch') // Remove long press description if an action is present, because in that case long pressing selects the item.
|
|
108
|
+
delete dragProps['aria-describedby'];
|
|
109
109
|
// Require Alt key if there is a conflicting action.
|
|
110
110
|
dragProps.onKeyDownCapture = (e)=>{
|
|
111
111
|
if (e.altKey) onKeyDownCapture === null || onKeyDownCapture === void 0 ? void 0 : onKeyDownCapture(e);
|
|
@@ -119,7 +119,7 @@ function $0cbbd00cda972c67$export$b35afafff42da2d9(props, state) {
|
|
|
119
119
|
dragButtonProps: {
|
|
120
120
|
...dragButtonProps,
|
|
121
121
|
isDisabled: isDisabled,
|
|
122
|
-
|
|
122
|
+
'aria-label': dragButtonLabel
|
|
123
123
|
}
|
|
124
124
|
};
|
|
125
125
|
}
|
|
@@ -25,20 +25,20 @@ function $parcel$interopDefault(a) {
|
|
|
25
25
|
|
|
26
26
|
const $fd98cf7cbf233429$var$MESSAGES = {
|
|
27
27
|
keyboard: {
|
|
28
|
-
selected:
|
|
29
|
-
notSelected:
|
|
28
|
+
selected: 'dragSelectedKeyboard',
|
|
29
|
+
notSelected: 'dragDescriptionKeyboard'
|
|
30
30
|
},
|
|
31
31
|
touch: {
|
|
32
|
-
selected:
|
|
33
|
-
notSelected:
|
|
32
|
+
selected: 'dragSelectedLongPress',
|
|
33
|
+
notSelected: 'dragDescriptionLongPress'
|
|
34
34
|
},
|
|
35
35
|
virtual: {
|
|
36
|
-
selected:
|
|
37
|
-
notSelected:
|
|
36
|
+
selected: 'dragDescriptionVirtual',
|
|
37
|
+
notSelected: 'dragDescriptionVirtual'
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
function $fd98cf7cbf233429$export$b35afafff42da2d9(props, state) {
|
|
41
|
-
let stringFormatter = (0, $91Fvt$useLocalizedStringFormatter)((0, ($parcel$interopDefault($91Fvt$intlStringsmodulejs))),
|
|
41
|
+
let stringFormatter = (0, $91Fvt$useLocalizedStringFormatter)((0, ($parcel$interopDefault($91Fvt$intlStringsmodulejs))), '@react-aria/dnd');
|
|
42
42
|
let isDisabled = state.isDisabled || state.selectionManager.isDisabled(props.key);
|
|
43
43
|
let { dragProps: dragProps, dragButtonProps: dragButtonProps } = (0, $8253ed7ece74b463$export$7941f8aafa4b6021)({
|
|
44
44
|
getItems () {
|
|
@@ -57,7 +57,7 @@ function $fd98cf7cbf233429$export$b35afafff42da2d9(props, state) {
|
|
|
57
57
|
},
|
|
58
58
|
onDragEnd (e) {
|
|
59
59
|
let { dropOperation: dropOperation } = e;
|
|
60
|
-
let isInternal = dropOperation ===
|
|
60
|
+
let isInternal = dropOperation === 'cancel' ? false : (0, $7252cd45fc48c07c$export$78bf638634500fa5)();
|
|
61
61
|
state.endDrag({
|
|
62
62
|
...e,
|
|
63
63
|
keys: state.draggingKeys,
|
|
@@ -73,9 +73,9 @@ function $fd98cf7cbf233429$export$b35afafff42da2d9(props, state) {
|
|
|
73
73
|
let description;
|
|
74
74
|
// Override description to include selected item count.
|
|
75
75
|
let modality = (0, $7252cd45fc48c07c$export$49bac5d6d4b352ea)();
|
|
76
|
-
if (!props.hasDragButton && state.selectionManager.selectionMode !==
|
|
77
|
-
let msg = $fd98cf7cbf233429$var$MESSAGES[modality][isSelected ?
|
|
78
|
-
if (props.hasAction && modality ===
|
|
76
|
+
if (!props.hasDragButton && state.selectionManager.selectionMode !== 'none') {
|
|
77
|
+
let msg = $fd98cf7cbf233429$var$MESSAGES[modality][isSelected ? 'selected' : 'notSelected'];
|
|
78
|
+
if (props.hasAction && modality === 'keyboard') msg += 'Alt';
|
|
79
79
|
if (isSelected) description = stringFormatter.format(msg, {
|
|
80
80
|
count: numKeysForDrag
|
|
81
81
|
});
|
|
@@ -83,14 +83,14 @@ function $fd98cf7cbf233429$export$b35afafff42da2d9(props, state) {
|
|
|
83
83
|
// Remove the onClick handler from useDrag. Long pressing will be required on touch devices,
|
|
84
84
|
// and NVDA/JAWS are always in forms mode within collection components.
|
|
85
85
|
delete dragProps.onClick;
|
|
86
|
-
} else if (isSelected) dragButtonLabel = stringFormatter.format(
|
|
86
|
+
} else if (isSelected) dragButtonLabel = stringFormatter.format('dragSelectedItems', {
|
|
87
87
|
count: numKeysForDrag
|
|
88
88
|
});
|
|
89
89
|
else {
|
|
90
90
|
var _state_collection_getTextValue, _state_collection;
|
|
91
91
|
var _state_collection_getTextValue1, _ref;
|
|
92
|
-
let itemText = (_ref = (_state_collection_getTextValue1 = (_state_collection_getTextValue = (_state_collection = state.collection).getTextValue) === null || _state_collection_getTextValue === void 0 ? void 0 : _state_collection_getTextValue.call(_state_collection, props.key)) !== null && _state_collection_getTextValue1 !== void 0 ? _state_collection_getTextValue1 : item === null || item === void 0 ? void 0 : item.textValue) !== null && _ref !== void 0 ? _ref :
|
|
93
|
-
dragButtonLabel = stringFormatter.format(
|
|
92
|
+
let itemText = (_ref = (_state_collection_getTextValue1 = (_state_collection_getTextValue = (_state_collection = state.collection).getTextValue) === null || _state_collection_getTextValue === void 0 ? void 0 : _state_collection_getTextValue.call(_state_collection, props.key)) !== null && _state_collection_getTextValue1 !== void 0 ? _state_collection_getTextValue1 : item === null || item === void 0 ? void 0 : item.textValue) !== null && _ref !== void 0 ? _ref : '';
|
|
93
|
+
dragButtonLabel = stringFormatter.format('dragItem', {
|
|
94
94
|
itemText: itemText
|
|
95
95
|
});
|
|
96
96
|
}
|
|
@@ -98,8 +98,8 @@ function $fd98cf7cbf233429$export$b35afafff42da2d9(props, state) {
|
|
|
98
98
|
if (description) Object.assign(dragProps, descriptionProps);
|
|
99
99
|
if (!props.hasDragButton && props.hasAction) {
|
|
100
100
|
let { onKeyDownCapture: onKeyDownCapture, onKeyUpCapture: onKeyUpCapture } = dragProps;
|
|
101
|
-
if (modality ===
|
|
102
|
-
delete dragProps[
|
|
101
|
+
if (modality === 'touch') // Remove long press description if an action is present, because in that case long pressing selects the item.
|
|
102
|
+
delete dragProps['aria-describedby'];
|
|
103
103
|
// Require Alt key if there is a conflicting action.
|
|
104
104
|
dragProps.onKeyDownCapture = (e)=>{
|
|
105
105
|
if (e.altKey) onKeyDownCapture === null || onKeyDownCapture === void 0 ? void 0 : onKeyDownCapture(e);
|
|
@@ -113,7 +113,7 @@ function $fd98cf7cbf233429$export$b35afafff42da2d9(props, state) {
|
|
|
113
113
|
dragButtonProps: {
|
|
114
114
|
...dragButtonProps,
|
|
115
115
|
isDisabled: isDisabled,
|
|
116
|
-
|
|
116
|
+
'aria-label': dragButtonLabel
|
|
117
117
|
}
|
|
118
118
|
};
|
|
119
119
|
}
|