@react-aria/dnd 3.6.1-nightly.4624 → 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
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
class $3ca85212bf8898e4$export$fbd65d14c79e28cc {
|
|
2
2
|
getPrimaryStart(rect) {
|
|
3
|
-
return this.orientation ===
|
|
3
|
+
return this.orientation === 'horizontal' ? rect.left : rect.top;
|
|
4
4
|
}
|
|
5
5
|
getPrimaryEnd(rect) {
|
|
6
|
-
return this.orientation ===
|
|
6
|
+
return this.orientation === 'horizontal' ? rect.right : rect.bottom;
|
|
7
7
|
}
|
|
8
8
|
getSecondaryStart(rect) {
|
|
9
|
-
return this.orientation ===
|
|
9
|
+
return this.orientation === 'horizontal' ? rect.top : rect.left;
|
|
10
10
|
}
|
|
11
11
|
getSecondaryEnd(rect) {
|
|
12
|
-
return this.orientation ===
|
|
12
|
+
return this.orientation === 'horizontal' ? rect.bottom : rect.right;
|
|
13
13
|
}
|
|
14
14
|
getFlowStart(rect) {
|
|
15
|
-
return this.layout ===
|
|
15
|
+
return this.layout === 'stack' ? this.getPrimaryStart(rect) : this.getSecondaryStart(rect);
|
|
16
16
|
}
|
|
17
17
|
getFlowEnd(rect) {
|
|
18
|
-
return this.layout ===
|
|
18
|
+
return this.layout === 'stack' ? this.getPrimaryEnd(rect) : this.getSecondaryEnd(rect);
|
|
19
19
|
}
|
|
20
20
|
getFlowSize(rect) {
|
|
21
21
|
return this.getFlowEnd(rect) - this.getFlowStart(rect);
|
|
22
22
|
}
|
|
23
23
|
getDropTargetFromPoint(x, y, isValidDropTarget) {
|
|
24
24
|
if (this.collection.size === 0) return {
|
|
25
|
-
type:
|
|
25
|
+
type: 'root'
|
|
26
26
|
};
|
|
27
27
|
let rect = this.ref.current.getBoundingClientRect();
|
|
28
|
-
let primary = this.orientation ===
|
|
29
|
-
let secondary = this.orientation ===
|
|
28
|
+
let primary = this.orientation === 'horizontal' ? x : y;
|
|
29
|
+
let secondary = this.orientation === 'horizontal' ? y : x;
|
|
30
30
|
primary += this.getPrimaryStart(rect);
|
|
31
31
|
secondary += this.getSecondaryStart(rect);
|
|
32
|
-
let flow = this.layout ===
|
|
33
|
-
let isPrimaryRTL = this.orientation ===
|
|
34
|
-
let isSecondaryRTL = this.layout ===
|
|
35
|
-
let isFlowRTL = this.layout ===
|
|
36
|
-
let elements = this.ref.current.querySelectorAll(
|
|
32
|
+
let flow = this.layout === 'stack' ? primary : secondary;
|
|
33
|
+
let isPrimaryRTL = this.orientation === 'horizontal' && this.direction === 'rtl';
|
|
34
|
+
let isSecondaryRTL = this.layout === 'grid' && this.orientation === 'vertical' && this.direction === 'rtl';
|
|
35
|
+
let isFlowRTL = this.layout === 'stack' ? isPrimaryRTL : isSecondaryRTL;
|
|
36
|
+
let elements = this.ref.current.querySelectorAll('[data-key]');
|
|
37
37
|
let elementMap = new Map();
|
|
38
38
|
for (let item of elements)if (item instanceof HTMLElement) elementMap.set(item.dataset.key, item);
|
|
39
39
|
let items = [
|
|
@@ -56,32 +56,32 @@ class $3ca85212bf8898e4$export$fbd65d14c79e28cc {
|
|
|
56
56
|
else if (secondary > this.getSecondaryEnd(rect)) update(!isSecondaryRTL);
|
|
57
57
|
else {
|
|
58
58
|
let target = {
|
|
59
|
-
type:
|
|
59
|
+
type: 'item',
|
|
60
60
|
key: item.key,
|
|
61
|
-
dropPosition:
|
|
61
|
+
dropPosition: 'on'
|
|
62
62
|
};
|
|
63
63
|
if (isValidDropTarget(target)) {
|
|
64
64
|
// Otherwise, if dropping on the item is accepted, try the before/after positions if within 5px
|
|
65
65
|
// of the start or end of the item.
|
|
66
66
|
if (flow <= this.getFlowStart(rect) + 5 && isValidDropTarget({
|
|
67
67
|
...target,
|
|
68
|
-
dropPosition:
|
|
69
|
-
})) target.dropPosition = isFlowRTL ?
|
|
68
|
+
dropPosition: 'before'
|
|
69
|
+
})) target.dropPosition = isFlowRTL ? 'after' : 'before';
|
|
70
70
|
else if (flow >= this.getFlowEnd(rect) - 5 && isValidDropTarget({
|
|
71
71
|
...target,
|
|
72
|
-
dropPosition:
|
|
73
|
-
})) target.dropPosition = isFlowRTL ?
|
|
72
|
+
dropPosition: 'after'
|
|
73
|
+
})) target.dropPosition = isFlowRTL ? 'before' : 'after';
|
|
74
74
|
} else {
|
|
75
75
|
// If dropping on the item isn't accepted, try the target before or after depending on the position.
|
|
76
76
|
let mid = this.getFlowStart(rect) + this.getFlowSize(rect) / 2;
|
|
77
77
|
if (flow <= mid && isValidDropTarget({
|
|
78
78
|
...target,
|
|
79
|
-
dropPosition:
|
|
80
|
-
})) target.dropPosition = isFlowRTL ?
|
|
79
|
+
dropPosition: 'before'
|
|
80
|
+
})) target.dropPosition = isFlowRTL ? 'after' : 'before';
|
|
81
81
|
else if (flow >= mid && isValidDropTarget({
|
|
82
82
|
...target,
|
|
83
|
-
dropPosition:
|
|
84
|
-
})) target.dropPosition = isFlowRTL ?
|
|
83
|
+
dropPosition: 'after'
|
|
84
|
+
})) target.dropPosition = isFlowRTL ? 'before' : 'after';
|
|
85
85
|
}
|
|
86
86
|
return target;
|
|
87
87
|
}
|
|
@@ -90,22 +90,22 @@ class $3ca85212bf8898e4$export$fbd65d14c79e28cc {
|
|
|
90
90
|
let element = elementMap.get(String(item.key));
|
|
91
91
|
rect = element.getBoundingClientRect();
|
|
92
92
|
if (primary < this.getPrimaryStart(rect) || Math.abs(flow - this.getFlowStart(rect)) < Math.abs(flow - this.getFlowEnd(rect))) return {
|
|
93
|
-
type:
|
|
93
|
+
type: 'item',
|
|
94
94
|
key: item.key,
|
|
95
|
-
dropPosition: isFlowRTL ?
|
|
95
|
+
dropPosition: isFlowRTL ? 'after' : 'before'
|
|
96
96
|
};
|
|
97
97
|
return {
|
|
98
|
-
type:
|
|
98
|
+
type: 'item',
|
|
99
99
|
key: item.key,
|
|
100
|
-
dropPosition: isFlowRTL ?
|
|
100
|
+
dropPosition: isFlowRTL ? 'before' : 'after'
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
103
|
constructor(collection, ref, options){
|
|
104
104
|
this.collection = collection;
|
|
105
105
|
this.ref = ref;
|
|
106
|
-
this.layout = (options === null || options === void 0 ? void 0 : options.layout) ||
|
|
107
|
-
this.orientation = (options === null || options === void 0 ? void 0 : options.orientation) ||
|
|
108
|
-
this.direction = (options === null || options === void 0 ? void 0 : options.direction) ||
|
|
106
|
+
this.layout = (options === null || options === void 0 ? void 0 : options.layout) || 'stack';
|
|
107
|
+
this.orientation = (options === null || options === void 0 ? void 0 : options.orientation) || 'vertical';
|
|
108
|
+
this.direction = (options === null || options === void 0 ? void 0 : options.direction) || 'ltr';
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
|
package/dist/constants.main.js
CHANGED
|
@@ -39,13 +39,13 @@ const $76b1e110a27b1ccd$export$9bbdfc78cf083e16 = {
|
|
|
39
39
|
uninitialized: 7
|
|
40
40
|
};
|
|
41
41
|
const $76b1e110a27b1ccd$export$dd0165308d8bff45 = $76b1e110a27b1ccd$var$invert($76b1e110a27b1ccd$export$9bbdfc78cf083e16);
|
|
42
|
-
$76b1e110a27b1ccd$export$dd0165308d8bff45[7] =
|
|
42
|
+
$76b1e110a27b1ccd$export$dd0165308d8bff45[7] = 'all'; // ensure we don't map to 'uninitialized'.
|
|
43
43
|
const $76b1e110a27b1ccd$export$d7ebf00f36b7a95e = $76b1e110a27b1ccd$var$invert($76b1e110a27b1ccd$export$60b7b4bcf3903d8e);
|
|
44
44
|
const $76b1e110a27b1ccd$export$608ecc6f1b23c35d = {
|
|
45
|
-
none:
|
|
46
|
-
link:
|
|
47
|
-
copy:
|
|
48
|
-
move:
|
|
45
|
+
none: 'cancel',
|
|
46
|
+
link: 'link',
|
|
47
|
+
copy: 'copy',
|
|
48
|
+
move: 'move'
|
|
49
49
|
};
|
|
50
50
|
const $76b1e110a27b1ccd$export$5eacb0769d26d3b2 = $76b1e110a27b1ccd$var$invert($76b1e110a27b1ccd$export$608ecc6f1b23c35d);
|
|
51
51
|
function $76b1e110a27b1ccd$var$invert(object) {
|
|
@@ -54,12 +54,12 @@ function $76b1e110a27b1ccd$var$invert(object) {
|
|
|
54
54
|
return res;
|
|
55
55
|
}
|
|
56
56
|
const $76b1e110a27b1ccd$export$4a7729b856e9a690 = new Set([
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
'text/plain',
|
|
58
|
+
'text/uri-list',
|
|
59
|
+
'text/html'
|
|
60
60
|
]);
|
|
61
|
-
const $76b1e110a27b1ccd$export$fd9f9fc120c5402d =
|
|
62
|
-
const $76b1e110a27b1ccd$export$f8fc6581787339b3 =
|
|
61
|
+
const $76b1e110a27b1ccd$export$fd9f9fc120c5402d = 'application/vnd.react-aria.items+json';
|
|
62
|
+
const $76b1e110a27b1ccd$export$f8fc6581787339b3 = 'application/octet-stream';
|
|
63
63
|
|
|
64
64
|
|
|
65
65
|
//# sourceMappingURL=constants.main.js.map
|
package/dist/constants.mjs
CHANGED
|
@@ -26,13 +26,13 @@ const $103790afe9474d1c$export$9bbdfc78cf083e16 = {
|
|
|
26
26
|
uninitialized: 7
|
|
27
27
|
};
|
|
28
28
|
const $103790afe9474d1c$export$dd0165308d8bff45 = $103790afe9474d1c$var$invert($103790afe9474d1c$export$9bbdfc78cf083e16);
|
|
29
|
-
$103790afe9474d1c$export$dd0165308d8bff45[7] =
|
|
29
|
+
$103790afe9474d1c$export$dd0165308d8bff45[7] = 'all'; // ensure we don't map to 'uninitialized'.
|
|
30
30
|
const $103790afe9474d1c$export$d7ebf00f36b7a95e = $103790afe9474d1c$var$invert($103790afe9474d1c$export$60b7b4bcf3903d8e);
|
|
31
31
|
const $103790afe9474d1c$export$608ecc6f1b23c35d = {
|
|
32
|
-
none:
|
|
33
|
-
link:
|
|
34
|
-
copy:
|
|
35
|
-
move:
|
|
32
|
+
none: 'cancel',
|
|
33
|
+
link: 'link',
|
|
34
|
+
copy: 'copy',
|
|
35
|
+
move: 'move'
|
|
36
36
|
};
|
|
37
37
|
const $103790afe9474d1c$export$5eacb0769d26d3b2 = $103790afe9474d1c$var$invert($103790afe9474d1c$export$608ecc6f1b23c35d);
|
|
38
38
|
function $103790afe9474d1c$var$invert(object) {
|
|
@@ -41,12 +41,12 @@ function $103790afe9474d1c$var$invert(object) {
|
|
|
41
41
|
return res;
|
|
42
42
|
}
|
|
43
43
|
const $103790afe9474d1c$export$4a7729b856e9a690 = new Set([
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
'text/plain',
|
|
45
|
+
'text/uri-list',
|
|
46
|
+
'text/html'
|
|
47
47
|
]);
|
|
48
|
-
const $103790afe9474d1c$export$fd9f9fc120c5402d =
|
|
49
|
-
const $103790afe9474d1c$export$f8fc6581787339b3 =
|
|
48
|
+
const $103790afe9474d1c$export$fd9f9fc120c5402d = 'application/vnd.react-aria.items+json';
|
|
49
|
+
const $103790afe9474d1c$export$f8fc6581787339b3 = 'application/octet-stream';
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
export {$103790afe9474d1c$export$60b7b4bcf3903d8e as DROP_OPERATION, $103790afe9474d1c$export$9bbdfc78cf083e16 as DROP_OPERATION_ALLOWED, $103790afe9474d1c$export$dd0165308d8bff45 as EFFECT_ALLOWED, $103790afe9474d1c$export$d7ebf00f36b7a95e as DROP_EFFECT, $103790afe9474d1c$export$608ecc6f1b23c35d as DROP_EFFECT_TO_DROP_OPERATION, $103790afe9474d1c$export$5eacb0769d26d3b2 as DROP_OPERATION_TO_DROP_EFFECT, $103790afe9474d1c$export$4a7729b856e9a690 as NATIVE_DRAG_TYPES, $103790afe9474d1c$export$fd9f9fc120c5402d as CUSTOM_DRAG_TYPE, $103790afe9474d1c$export$f8fc6581787339b3 as GENERIC_TYPE};
|
package/dist/constants.module.js
CHANGED
|
@@ -26,13 +26,13 @@ const $103790afe9474d1c$export$9bbdfc78cf083e16 = {
|
|
|
26
26
|
uninitialized: 7
|
|
27
27
|
};
|
|
28
28
|
const $103790afe9474d1c$export$dd0165308d8bff45 = $103790afe9474d1c$var$invert($103790afe9474d1c$export$9bbdfc78cf083e16);
|
|
29
|
-
$103790afe9474d1c$export$dd0165308d8bff45[7] =
|
|
29
|
+
$103790afe9474d1c$export$dd0165308d8bff45[7] = 'all'; // ensure we don't map to 'uninitialized'.
|
|
30
30
|
const $103790afe9474d1c$export$d7ebf00f36b7a95e = $103790afe9474d1c$var$invert($103790afe9474d1c$export$60b7b4bcf3903d8e);
|
|
31
31
|
const $103790afe9474d1c$export$608ecc6f1b23c35d = {
|
|
32
|
-
none:
|
|
33
|
-
link:
|
|
34
|
-
copy:
|
|
35
|
-
move:
|
|
32
|
+
none: 'cancel',
|
|
33
|
+
link: 'link',
|
|
34
|
+
copy: 'copy',
|
|
35
|
+
move: 'move'
|
|
36
36
|
};
|
|
37
37
|
const $103790afe9474d1c$export$5eacb0769d26d3b2 = $103790afe9474d1c$var$invert($103790afe9474d1c$export$608ecc6f1b23c35d);
|
|
38
38
|
function $103790afe9474d1c$var$invert(object) {
|
|
@@ -41,12 +41,12 @@ function $103790afe9474d1c$var$invert(object) {
|
|
|
41
41
|
return res;
|
|
42
42
|
}
|
|
43
43
|
const $103790afe9474d1c$export$4a7729b856e9a690 = new Set([
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
'text/plain',
|
|
45
|
+
'text/uri-list',
|
|
46
|
+
'text/html'
|
|
47
47
|
]);
|
|
48
|
-
const $103790afe9474d1c$export$fd9f9fc120c5402d =
|
|
49
|
-
const $103790afe9474d1c$export$f8fc6581787339b3 =
|
|
48
|
+
const $103790afe9474d1c$export$fd9f9fc120c5402d = 'application/vnd.react-aria.items+json';
|
|
49
|
+
const $103790afe9474d1c$export$f8fc6581787339b3 = 'application/octet-stream';
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
export {$103790afe9474d1c$export$60b7b4bcf3903d8e as DROP_OPERATION, $103790afe9474d1c$export$9bbdfc78cf083e16 as DROP_OPERATION_ALLOWED, $103790afe9474d1c$export$dd0165308d8bff45 as EFFECT_ALLOWED, $103790afe9474d1c$export$d7ebf00f36b7a95e as DROP_EFFECT, $103790afe9474d1c$export$608ecc6f1b23c35d as DROP_EFFECT_TO_DROP_OPERATION, $103790afe9474d1c$export$5eacb0769d26d3b2 as DROP_OPERATION_TO_DROP_EFFECT, $103790afe9474d1c$export$4a7729b856e9a690 as NATIVE_DRAG_TYPES, $103790afe9474d1c$export$fd9f9fc120c5402d as CUSTOM_DRAG_TYPE, $103790afe9474d1c$export$f8fc6581787339b3 as GENERIC_TYPE};
|
|
@@ -88,7 +88,7 @@ function $74f3dedaa4d234b4$export$2314ca2a3e892862(options) {
|
|
|
88
88
|
});
|
|
89
89
|
(0, $gAFdr$react.useEffect)(()=>{
|
|
90
90
|
if (isDisabled) return;
|
|
91
|
-
return (0, $gAFdr$reactariautils.chain)($74f3dedaa4d234b4$var$addGlobalEventListener(
|
|
91
|
+
return (0, $gAFdr$reactariautils.chain)($74f3dedaa4d234b4$var$addGlobalEventListener('beforecopy', onBeforeCopy), $74f3dedaa4d234b4$var$addGlobalEventListener('copy', onCopy), $74f3dedaa4d234b4$var$addGlobalEventListener('beforecut', onBeforeCut), $74f3dedaa4d234b4$var$addGlobalEventListener('cut', onCut), $74f3dedaa4d234b4$var$addGlobalEventListener('beforepaste', onBeforePaste), $74f3dedaa4d234b4$var$addGlobalEventListener('paste', onPaste));
|
|
92
92
|
}, [
|
|
93
93
|
isDisabled,
|
|
94
94
|
onBeforeCopy,
|
package/dist/useClipboard.mjs
CHANGED
|
@@ -82,7 +82,7 @@ function $9fcc7f0d70d084ee$export$2314ca2a3e892862(options) {
|
|
|
82
82
|
});
|
|
83
83
|
(0, $9Tt78$useEffect)(()=>{
|
|
84
84
|
if (isDisabled) return;
|
|
85
|
-
return (0, $9Tt78$chain)($9fcc7f0d70d084ee$var$addGlobalEventListener(
|
|
85
|
+
return (0, $9Tt78$chain)($9fcc7f0d70d084ee$var$addGlobalEventListener('beforecopy', onBeforeCopy), $9fcc7f0d70d084ee$var$addGlobalEventListener('copy', onCopy), $9fcc7f0d70d084ee$var$addGlobalEventListener('beforecut', onBeforeCut), $9fcc7f0d70d084ee$var$addGlobalEventListener('cut', onCut), $9fcc7f0d70d084ee$var$addGlobalEventListener('beforepaste', onBeforePaste), $9fcc7f0d70d084ee$var$addGlobalEventListener('paste', onPaste));
|
|
86
86
|
}, [
|
|
87
87
|
isDisabled,
|
|
88
88
|
onBeforeCopy,
|
|
@@ -82,7 +82,7 @@ function $9fcc7f0d70d084ee$export$2314ca2a3e892862(options) {
|
|
|
82
82
|
});
|
|
83
83
|
(0, $9Tt78$useEffect)(()=>{
|
|
84
84
|
if (isDisabled) return;
|
|
85
|
-
return (0, $9Tt78$chain)($9fcc7f0d70d084ee$var$addGlobalEventListener(
|
|
85
|
+
return (0, $9Tt78$chain)($9fcc7f0d70d084ee$var$addGlobalEventListener('beforecopy', onBeforeCopy), $9fcc7f0d70d084ee$var$addGlobalEventListener('copy', onCopy), $9fcc7f0d70d084ee$var$addGlobalEventListener('beforecut', onBeforeCut), $9fcc7f0d70d084ee$var$addGlobalEventListener('cut', onCut), $9fcc7f0d70d084ee$var$addGlobalEventListener('beforepaste', onBeforePaste), $9fcc7f0d70d084ee$var$addGlobalEventListener('paste', onPaste));
|
|
86
86
|
}, [
|
|
87
87
|
isDisabled,
|
|
88
88
|
onBeforeCopy,
|
package/dist/useDrag.main.js
CHANGED
|
@@ -35,21 +35,21 @@ $parcel$export(module.exports, "useDrag", () => $dc204e8ec58447a6$export$7941f8a
|
|
|
35
35
|
|
|
36
36
|
const $dc204e8ec58447a6$var$MESSAGES = {
|
|
37
37
|
keyboard: {
|
|
38
|
-
start:
|
|
39
|
-
end:
|
|
38
|
+
start: 'dragDescriptionKeyboard',
|
|
39
|
+
end: 'endDragKeyboard'
|
|
40
40
|
},
|
|
41
41
|
touch: {
|
|
42
|
-
start:
|
|
43
|
-
end:
|
|
42
|
+
start: 'dragDescriptionTouch',
|
|
43
|
+
end: 'endDragTouch'
|
|
44
44
|
},
|
|
45
45
|
virtual: {
|
|
46
|
-
start:
|
|
47
|
-
end:
|
|
46
|
+
start: 'dragDescriptionVirtual',
|
|
47
|
+
end: 'endDragVirtual'
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
50
|
function $dc204e8ec58447a6$export$7941f8aafa4b6021(options) {
|
|
51
51
|
let { hasDragButton: hasDragButton, isDisabled: isDisabled } = options;
|
|
52
|
-
let stringFormatter = (0, $3w36N$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($7c8adf3925a26206$exports))),
|
|
52
|
+
let stringFormatter = (0, $3w36N$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($7c8adf3925a26206$exports))), '@react-aria/dnd');
|
|
53
53
|
let state = (0, $3w36N$react.useRef)({
|
|
54
54
|
options: options,
|
|
55
55
|
x: 0,
|
|
@@ -70,30 +70,30 @@ function $dc204e8ec58447a6$export$7941f8aafa4b6021(options) {
|
|
|
70
70
|
// Prevent the drag event from propagating to any parent draggables
|
|
71
71
|
e.stopPropagation();
|
|
72
72
|
// If this drag was initiated by a mobile screen reader (e.g. VoiceOver or TalkBack), enter virtual dragging mode.
|
|
73
|
-
if (modalityOnPointerDown.current ===
|
|
73
|
+
if (modalityOnPointerDown.current === 'virtual') {
|
|
74
74
|
e.preventDefault();
|
|
75
75
|
startDragging(e.target);
|
|
76
76
|
modalityOnPointerDown.current = null;
|
|
77
77
|
return;
|
|
78
78
|
}
|
|
79
|
-
if (typeof options.onDragStart ===
|
|
80
|
-
type:
|
|
79
|
+
if (typeof options.onDragStart === 'function') options.onDragStart({
|
|
80
|
+
type: 'dragstart',
|
|
81
81
|
x: e.clientX,
|
|
82
82
|
y: e.clientY
|
|
83
83
|
});
|
|
84
84
|
let items = options.getItems();
|
|
85
85
|
(0, $4620ae0dc40f0031$exports.writeToDataTransfer)(e.dataTransfer, items);
|
|
86
86
|
let allowed = (0, $76b1e110a27b1ccd$exports.DROP_OPERATION).all;
|
|
87
|
-
if (typeof options.getAllowedDropOperations ===
|
|
87
|
+
if (typeof options.getAllowedDropOperations === 'function') {
|
|
88
88
|
let allowedOperations = options.getAllowedDropOperations();
|
|
89
89
|
allowed = (0, $76b1e110a27b1ccd$exports.DROP_OPERATION).none;
|
|
90
90
|
for (let operation of allowedOperations)allowed |= (0, $76b1e110a27b1ccd$exports.DROP_OPERATION)[operation] || (0, $76b1e110a27b1ccd$exports.DROP_OPERATION).none;
|
|
91
91
|
}
|
|
92
92
|
(0, $4620ae0dc40f0031$exports.setGlobalAllowedDropOperations)(allowed);
|
|
93
|
-
e.dataTransfer.effectAllowed = (0, $76b1e110a27b1ccd$exports.EFFECT_ALLOWED)[allowed] ||
|
|
93
|
+
e.dataTransfer.effectAllowed = (0, $76b1e110a27b1ccd$exports.EFFECT_ALLOWED)[allowed] || 'none';
|
|
94
94
|
// If there is a preview option, use it to render a custom preview image that will
|
|
95
95
|
// appear under the pointer while dragging. If not, the element itself is dragged by the browser.
|
|
96
|
-
if (typeof ((_options_preview = options.preview) === null || _options_preview === void 0 ? void 0 : _options_preview.current) ===
|
|
96
|
+
if (typeof ((_options_preview = options.preview) === null || _options_preview === void 0 ? void 0 : _options_preview.current) === 'function') options.preview.current(items, (node)=>{
|
|
97
97
|
// Compute the offset that the preview will appear under the mouse.
|
|
98
98
|
// If possible, this is based on the point the user clicked on the target.
|
|
99
99
|
// If the preview is much smaller, then just use the center point of the preview.
|
|
@@ -111,10 +111,10 @@ function $dc204e8ec58447a6$export$7941f8aafa4b6021(options) {
|
|
|
111
111
|
e.dataTransfer.setDragImage(node, x, y);
|
|
112
112
|
});
|
|
113
113
|
// Enforce that drops are handled by useDrop.
|
|
114
|
-
addGlobalListener(window,
|
|
114
|
+
addGlobalListener(window, 'drop', (e)=>{
|
|
115
115
|
e.preventDefault();
|
|
116
116
|
e.stopPropagation();
|
|
117
|
-
console.warn(
|
|
117
|
+
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.');
|
|
118
118
|
}, {
|
|
119
119
|
once: true
|
|
120
120
|
});
|
|
@@ -130,8 +130,8 @@ function $dc204e8ec58447a6$export$7941f8aafa4b6021(options) {
|
|
|
130
130
|
// Prevent the drag event from propagating to any parent draggables
|
|
131
131
|
e.stopPropagation();
|
|
132
132
|
if (e.clientX === state.x && e.clientY === state.y) return;
|
|
133
|
-
if (typeof options.onDragMove ===
|
|
134
|
-
type:
|
|
133
|
+
if (typeof options.onDragMove === 'function') options.onDragMove({
|
|
134
|
+
type: 'dragmove',
|
|
135
135
|
x: e.clientX,
|
|
136
136
|
y: e.clientY
|
|
137
137
|
});
|
|
@@ -141,9 +141,9 @@ function $dc204e8ec58447a6$export$7941f8aafa4b6021(options) {
|
|
|
141
141
|
let onDragEnd = (e)=>{
|
|
142
142
|
// Prevent the drag event from propagating to any parent draggables
|
|
143
143
|
e.stopPropagation();
|
|
144
|
-
if (typeof options.onDragEnd ===
|
|
144
|
+
if (typeof options.onDragEnd === 'function') {
|
|
145
145
|
let event = {
|
|
146
|
-
type:
|
|
146
|
+
type: 'dragend',
|
|
147
147
|
x: e.clientX,
|
|
148
148
|
y: e.clientY,
|
|
149
149
|
dropOperation: (0, $76b1e110a27b1ccd$exports.DROP_EFFECT_TO_DROP_OPERATION)[e.dataTransfer.dropEffect]
|
|
@@ -164,12 +164,12 @@ function $dc204e8ec58447a6$export$7941f8aafa4b6021(options) {
|
|
|
164
164
|
(0, $3w36N$reactariautils.useLayoutEffect)(()=>{
|
|
165
165
|
return ()=>{
|
|
166
166
|
if (isDraggingRef.current) {
|
|
167
|
-
if (typeof state.options.onDragEnd ===
|
|
167
|
+
if (typeof state.options.onDragEnd === 'function') {
|
|
168
168
|
let event = {
|
|
169
|
-
type:
|
|
169
|
+
type: 'dragend',
|
|
170
170
|
x: 0,
|
|
171
171
|
y: 0,
|
|
172
|
-
dropOperation: (0, $76b1e110a27b1ccd$exports.DROP_EFFECT_TO_DROP_OPERATION)[(0, $4620ae0dc40f0031$exports.globalDropEffect) ||
|
|
172
|
+
dropOperation: (0, $76b1e110a27b1ccd$exports.DROP_EFFECT_TO_DROP_OPERATION)[(0, $4620ae0dc40f0031$exports.globalDropEffect) || 'none']
|
|
173
173
|
};
|
|
174
174
|
state.options.onDragEnd(event);
|
|
175
175
|
}
|
|
@@ -182,14 +182,14 @@ function $dc204e8ec58447a6$export$7941f8aafa4b6021(options) {
|
|
|
182
182
|
state
|
|
183
183
|
]);
|
|
184
184
|
let onPress = (e)=>{
|
|
185
|
-
if (e.pointerType !==
|
|
185
|
+
if (e.pointerType !== 'keyboard' && e.pointerType !== 'virtual') return;
|
|
186
186
|
startDragging(e.target);
|
|
187
187
|
};
|
|
188
188
|
let startDragging = (target)=>{
|
|
189
|
-
if (typeof state.options.onDragStart ===
|
|
189
|
+
if (typeof state.options.onDragStart === 'function') {
|
|
190
190
|
let rect = target.getBoundingClientRect();
|
|
191
191
|
state.options.onDragStart({
|
|
192
|
-
type:
|
|
192
|
+
type: 'dragstart',
|
|
193
193
|
x: rect.x + rect.width / 2,
|
|
194
194
|
y: rect.y + rect.height / 2
|
|
195
195
|
});
|
|
@@ -197,14 +197,14 @@ function $dc204e8ec58447a6$export$7941f8aafa4b6021(options) {
|
|
|
197
197
|
$28e10663603f5ea1$exports.beginDragging({
|
|
198
198
|
element: target,
|
|
199
199
|
items: state.options.getItems(),
|
|
200
|
-
allowedDropOperations: typeof state.options.getAllowedDropOperations ===
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
200
|
+
allowedDropOperations: typeof state.options.getAllowedDropOperations === 'function' ? state.options.getAllowedDropOperations() : [
|
|
201
|
+
'move',
|
|
202
|
+
'copy',
|
|
203
|
+
'link'
|
|
204
204
|
],
|
|
205
205
|
onDragEnd (e) {
|
|
206
206
|
setDragging(false);
|
|
207
|
-
if (typeof state.options.onDragEnd ===
|
|
207
|
+
if (typeof state.options.onDragEnd === 'function') state.options.onDragEnd(e);
|
|
208
208
|
}
|
|
209
209
|
}, stringFormatter);
|
|
210
210
|
setDragging(true);
|
|
@@ -222,10 +222,10 @@ function $dc204e8ec58447a6$export$7941f8aafa4b6021(options) {
|
|
|
222
222
|
interactions = {
|
|
223
223
|
...descriptionProps,
|
|
224
224
|
onPointerDown (e) {
|
|
225
|
-
modalityOnPointerDown.current = (0, $3w36N$reactariautils.isVirtualPointerEvent)(e.nativeEvent) ?
|
|
225
|
+
modalityOnPointerDown.current = (0, $3w36N$reactariautils.isVirtualPointerEvent)(e.nativeEvent) ? 'virtual' : e.pointerType;
|
|
226
226
|
// Try to detect virtual drag passthrough gestures.
|
|
227
227
|
if (e.width < 1 && e.height < 1) // iOS VoiceOver.
|
|
228
|
-
modalityOnPointerDown.current =
|
|
228
|
+
modalityOnPointerDown.current = 'virtual';
|
|
229
229
|
else {
|
|
230
230
|
let rect = e.currentTarget.getBoundingClientRect();
|
|
231
231
|
let offsetX = e.clientX - rect.x;
|
|
@@ -233,18 +233,18 @@ function $dc204e8ec58447a6$export$7941f8aafa4b6021(options) {
|
|
|
233
233
|
let centerX = rect.width / 2;
|
|
234
234
|
let centerY = rect.height / 2;
|
|
235
235
|
if (Math.abs(offsetX - centerX) <= 0.5 && Math.abs(offsetY - centerY) <= 0.5) // Android TalkBack.
|
|
236
|
-
modalityOnPointerDown.current =
|
|
236
|
+
modalityOnPointerDown.current = 'virtual';
|
|
237
237
|
else modalityOnPointerDown.current = e.pointerType;
|
|
238
238
|
}
|
|
239
239
|
},
|
|
240
240
|
onKeyDownCapture (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
|
}
|
|
245
245
|
},
|
|
246
246
|
onKeyUpCapture (e) {
|
|
247
|
-
if (e.target === e.currentTarget && e.key ===
|
|
247
|
+
if (e.target === e.currentTarget && e.key === 'Enter') {
|
|
248
248
|
e.preventDefault();
|
|
249
249
|
e.stopPropagation();
|
|
250
250
|
startDragging(e.target);
|
|
@@ -252,7 +252,7 @@ function $dc204e8ec58447a6$export$7941f8aafa4b6021(options) {
|
|
|
252
252
|
},
|
|
253
253
|
onClick (e) {
|
|
254
254
|
// Handle NVDA/JAWS in browse mode, and touch screen readers. In this case, no keyboard events are fired.
|
|
255
|
-
if ((0, $3w36N$reactariautils.isVirtualClick)(e.nativeEvent) || modalityOnPointerDown.current ===
|
|
255
|
+
if ((0, $3w36N$reactariautils.isVirtualClick)(e.nativeEvent) || modalityOnPointerDown.current === 'virtual') {
|
|
256
256
|
e.preventDefault();
|
|
257
257
|
e.stopPropagation();
|
|
258
258
|
startDragging(e.target);
|
|
@@ -261,7 +261,7 @@ function $dc204e8ec58447a6$export$7941f8aafa4b6021(options) {
|
|
|
261
261
|
};
|
|
262
262
|
if (isDisabled) return {
|
|
263
263
|
dragProps: {
|
|
264
|
-
draggable:
|
|
264
|
+
draggable: 'false'
|
|
265
265
|
},
|
|
266
266
|
dragButtonProps: {},
|
|
267
267
|
isDragging: false
|
|
@@ -269,7 +269,7 @@ function $dc204e8ec58447a6$export$7941f8aafa4b6021(options) {
|
|
|
269
269
|
return {
|
|
270
270
|
dragProps: {
|
|
271
271
|
...interactions,
|
|
272
|
-
draggable:
|
|
272
|
+
draggable: 'true',
|
|
273
273
|
onDragStart: onDragStart,
|
|
274
274
|
onDrag: onDrag,
|
|
275
275
|
onDragEnd: onDragEnd
|