@react-aria/dnd 3.0.0-nightly.3491 → 3.0.0-nightly.3502
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/main.js +32 -26
- package/dist/main.js.map +1 -1
- package/dist/module.js +33 -27
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +68 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/DragManager.ts +18 -32
- package/src/ListDropTargetDelegate.ts +1 -1
- package/src/useClipboard.ts +9 -0
- package/src/useDrag.ts +31 -13
- package/src/useDraggableCollection.ts +5 -1
- package/src/useDraggableItem.ts +10 -1
- package/src/useDrop.ts +10 -1
- package/src/useDropIndicator.ts +10 -0
- package/src/useDroppableCollection.ts +8 -1
- package/src/useDroppableItem.ts +6 -0
package/dist/main.js
CHANGED
|
@@ -329,7 +329,7 @@ function $28e10663603f5ea1$export$549dbcf8649bf3b2(target1, stringFormatter) {
|
|
|
329
329
|
$28e10663603f5ea1$var$dragSession = new $28e10663603f5ea1$var$DragSession(target1, stringFormatter);
|
|
330
330
|
requestAnimationFrame(()=>{
|
|
331
331
|
$28e10663603f5ea1$var$dragSession.setup();
|
|
332
|
-
if ($4620ae0dc40f0031$export$1fb2158d224b542c() === 'keyboard'
|
|
332
|
+
if ($4620ae0dc40f0031$export$1fb2158d224b542c() === 'keyboard') {
|
|
333
333
|
let target = $28e10663603f5ea1$var$dragSession.findNearestDropTarget();
|
|
334
334
|
$28e10663603f5ea1$var$dragSession.setCurrentDropTarget(target);
|
|
335
335
|
}
|
|
@@ -379,7 +379,6 @@ const $28e10663603f5ea1$var$CANCELED_EVENTS = [
|
|
|
379
379
|
'touchstart',
|
|
380
380
|
'touchmove',
|
|
381
381
|
'touchend',
|
|
382
|
-
'keyup',
|
|
383
382
|
'focusin',
|
|
384
383
|
'focusout'
|
|
385
384
|
];
|
|
@@ -396,6 +395,7 @@ const $28e10663603f5ea1$var$MESSAGES = {
|
|
|
396
395
|
class $28e10663603f5ea1$var$DragSession {
|
|
397
396
|
setup() {
|
|
398
397
|
document.addEventListener('keydown', this.onKeyDown, true);
|
|
398
|
+
document.addEventListener('keyup', this.onKeyUp, true);
|
|
399
399
|
window.addEventListener('focus', this.onFocus, true);
|
|
400
400
|
window.addEventListener('blur', this.onBlur, true);
|
|
401
401
|
document.addEventListener('click', this.onClick, true);
|
|
@@ -408,6 +408,7 @@ class $28e10663603f5ea1$var$DragSession {
|
|
|
408
408
|
}
|
|
409
409
|
teardown() {
|
|
410
410
|
document.removeEventListener('keydown', this.onKeyDown, true);
|
|
411
|
+
document.removeEventListener('keyup', this.onKeyUp, true);
|
|
411
412
|
window.removeEventListener('focus', this.onFocus, true);
|
|
412
413
|
window.removeEventListener('blur', this.onBlur, true);
|
|
413
414
|
document.removeEventListener('click', this.onClick, true);
|
|
@@ -423,17 +424,19 @@ class $28e10663603f5ea1$var$DragSession {
|
|
|
423
424
|
this.cancel();
|
|
424
425
|
return;
|
|
425
426
|
}
|
|
426
|
-
if (e.key === 'Enter') {
|
|
427
|
-
if (e.altKey) this.activate();
|
|
428
|
-
else this.drop();
|
|
429
|
-
return;
|
|
430
|
-
}
|
|
431
427
|
if (e.key === 'Tab' && !(e.metaKey || e.altKey || e.ctrlKey)) {
|
|
432
428
|
if (e.shiftKey) this.previous();
|
|
433
429
|
else this.next();
|
|
434
430
|
}
|
|
435
431
|
if (typeof ((ref = this.currentDropTarget) === null || ref === void 0 ? void 0 : ref.onKeyDown) === 'function') this.currentDropTarget.onKeyDown(e, this.dragTarget);
|
|
436
432
|
}
|
|
433
|
+
onKeyUp(e) {
|
|
434
|
+
this.cancelEvent(e);
|
|
435
|
+
if (e.key === 'Enter') {
|
|
436
|
+
if (e.altKey) this.activate();
|
|
437
|
+
else this.drop();
|
|
438
|
+
}
|
|
439
|
+
}
|
|
437
440
|
onFocus(e) {
|
|
438
441
|
// Prevent focus events, except to the original drag target.
|
|
439
442
|
if (e.target !== this.dragTarget.element) this.cancelEvent(e);
|
|
@@ -460,7 +463,7 @@ class $28e10663603f5ea1$var$DragSession {
|
|
|
460
463
|
}
|
|
461
464
|
onClick(e) {
|
|
462
465
|
this.cancelEvent(e);
|
|
463
|
-
if (e
|
|
466
|
+
if ($4vY0V$reactariautils.isVirtualClick(e) || this.isVirtualClick) {
|
|
464
467
|
if (e.target === this.dragTarget.element) {
|
|
465
468
|
this.cancel();
|
|
466
469
|
return;
|
|
@@ -478,7 +481,7 @@ class $28e10663603f5ea1$var$DragSession {
|
|
|
478
481
|
// Android Talkback double tap has e.detail = 1 for onClick. Detect the virtual click in onPointerDown before onClick fires
|
|
479
482
|
// so we can properly perform cancel and drop operations.
|
|
480
483
|
this.cancelEvent(e);
|
|
481
|
-
this.isVirtualClick = $
|
|
484
|
+
this.isVirtualClick = $4vY0V$reactariautils.isVirtualPointerEvent(e);
|
|
482
485
|
}
|
|
483
486
|
cancelEvent(e) {
|
|
484
487
|
var ref;
|
|
@@ -694,6 +697,7 @@ class $28e10663603f5ea1$var$DragSession {
|
|
|
694
697
|
this.dragTarget = target;
|
|
695
698
|
this.stringFormatter = stringFormatter;
|
|
696
699
|
this.onKeyDown = this.onKeyDown.bind(this);
|
|
700
|
+
this.onKeyUp = this.onKeyUp.bind(this);
|
|
697
701
|
this.onFocus = this.onFocus.bind(this);
|
|
698
702
|
this.onBlur = this.onBlur.bind(this);
|
|
699
703
|
this.onClick = this.onClick.bind(this);
|
|
@@ -712,14 +716,6 @@ function $28e10663603f5ea1$var$findValidDropTargets(options) {
|
|
|
712
716
|
return true;
|
|
713
717
|
});
|
|
714
718
|
}
|
|
715
|
-
function $28e10663603f5ea1$var$isVirtualPointerEvent(event) {
|
|
716
|
-
// If the pointer size is zero, then we assume it's from a screen reader.
|
|
717
|
-
// Android TalkBack double tap will sometimes return a event with width and height of 1
|
|
718
|
-
// and pointerType === 'mouse' so we need to check for a specific combination of event attributes.
|
|
719
|
-
// Cannot use "event.pressure === 0" as the sole check due to Safari pointer events always returning pressure === 0
|
|
720
|
-
// instead of .5, see https://bugs.webkit.org/show_bug.cgi?id=206216
|
|
721
|
-
return event.width === 0 && event.height === 0 || event.width === 1 && event.height === 1 && event.pressure === 0 && event.detail === 0;
|
|
722
|
-
}
|
|
723
719
|
|
|
724
720
|
|
|
725
721
|
|
|
@@ -2842,11 +2838,7 @@ function $dc204e8ec58447a6$export$7941f8aafa4b6021(options) {
|
|
|
2842
2838
|
setDragging(true);
|
|
2843
2839
|
};
|
|
2844
2840
|
let modality = $4620ae0dc40f0031$export$49bac5d6d4b352ea();
|
|
2845
|
-
let message;
|
|
2846
|
-
if (!isDraggingRef.current) {
|
|
2847
|
-
if (modality === 'touch' && !hasDragButton) message = 'dragDescriptionLongPress';
|
|
2848
|
-
else message = $dc204e8ec58447a6$var$MESSAGES[modality].start;
|
|
2849
|
-
} else message = $dc204e8ec58447a6$var$MESSAGES[modality].end;
|
|
2841
|
+
let message = !isDraggingRef.current ? $dc204e8ec58447a6$var$MESSAGES[modality].start : $dc204e8ec58447a6$var$MESSAGES[modality].end;
|
|
2850
2842
|
let descriptionProps = $4vY0V$reactariautils.useDescription(stringFormatter.format(message));
|
|
2851
2843
|
let interactions;
|
|
2852
2844
|
if (!hasDragButton) // If there's no separate button to trigger accessible drag and drop mode,
|
|
@@ -2858,7 +2850,8 @@ function $dc204e8ec58447a6$export$7941f8aafa4b6021(options) {
|
|
|
2858
2850
|
interactions = {
|
|
2859
2851
|
...descriptionProps,
|
|
2860
2852
|
onPointerDown (e) {
|
|
2861
|
-
|
|
2853
|
+
modalityOnPointerDown.current = $4vY0V$reactariautils.isVirtualPointerEvent(e.nativeEvent) ? 'virtual' : e.pointerType;
|
|
2854
|
+
// Try to detect virtual drag passthrough gestures.
|
|
2862
2855
|
if (e.width < 1 && e.height < 1) // iOS VoiceOver.
|
|
2863
2856
|
modalityOnPointerDown.current = 'virtual';
|
|
2864
2857
|
else {
|
|
@@ -2867,7 +2860,7 @@ function $dc204e8ec58447a6$export$7941f8aafa4b6021(options) {
|
|
|
2867
2860
|
let offsetY = e.clientY - rect.y;
|
|
2868
2861
|
let centerX = rect.width / 2;
|
|
2869
2862
|
let centerY = rect.height / 2;
|
|
2870
|
-
if (Math.abs(offsetX - centerX)
|
|
2863
|
+
if (Math.abs(offsetX - centerX) <= 0.5 && Math.abs(offsetY - centerY) <= 0.5) // Android TalkBack.
|
|
2871
2864
|
modalityOnPointerDown.current = 'virtual';
|
|
2872
2865
|
else modalityOnPointerDown.current = e.pointerType;
|
|
2873
2866
|
}
|
|
@@ -2884,6 +2877,14 @@ function $dc204e8ec58447a6$export$7941f8aafa4b6021(options) {
|
|
|
2884
2877
|
e.stopPropagation();
|
|
2885
2878
|
startDragging(e.target);
|
|
2886
2879
|
}
|
|
2880
|
+
},
|
|
2881
|
+
onClick (e) {
|
|
2882
|
+
// Handle NVDA/JAWS in browse mode, and touch screen readers. In this case, no keyboard events are fired.
|
|
2883
|
+
if ($4vY0V$reactariautils.isVirtualClick(e.nativeEvent) || modalityOnPointerDown.current === 'virtual') {
|
|
2884
|
+
e.preventDefault();
|
|
2885
|
+
e.stopPropagation();
|
|
2886
|
+
startDragging(e.target);
|
|
2887
|
+
}
|
|
2887
2888
|
}
|
|
2888
2889
|
};
|
|
2889
2890
|
return {
|
|
@@ -3911,13 +3912,16 @@ function $0cbbd00cda972c67$export$b35afafff42da2d9(props, state) {
|
|
|
3911
3912
|
// Override description to include selected item count.
|
|
3912
3913
|
let modality = $4620ae0dc40f0031$export$49bac5d6d4b352ea();
|
|
3913
3914
|
var ref;
|
|
3914
|
-
if (!props.hasDragButton) {
|
|
3915
|
+
if (!props.hasDragButton && state.selectionManager.selectionMode !== 'none') {
|
|
3915
3916
|
let msg = $0cbbd00cda972c67$var$MESSAGES[modality][isSelected ? 'selected' : 'notSelected'];
|
|
3916
3917
|
if (props.hasAction && modality === 'keyboard') msg += 'Alt';
|
|
3917
3918
|
if (isSelected) description = stringFormatter.format(msg, {
|
|
3918
3919
|
count: numKeysForDrag
|
|
3919
3920
|
});
|
|
3920
3921
|
else description = stringFormatter.format(msg);
|
|
3922
|
+
// Remove the onClick handler from useDrag. Long pressing will be required on touch devices,
|
|
3923
|
+
// and NVDA/JAWS are always in forms mode within collection components.
|
|
3924
|
+
delete dragProps.onClick;
|
|
3921
3925
|
} else if (isSelected) dragButtonLabel = stringFormatter.format('dragSelectedItems', {
|
|
3922
3926
|
count: numKeysForDrag
|
|
3923
3927
|
});
|
|
@@ -4079,7 +4083,9 @@ let $2dccaca1f4baa446$export$905ab40ac2179daa = /*#__PURE__*/ ($parcel$interopDe
|
|
|
4079
4083
|
|
|
4080
4084
|
class $2268795bbb597ecb$export$fbd65d14c79e28cc {
|
|
4081
4085
|
getDropTargetFromPoint(x, y, isValidDropTarget) {
|
|
4082
|
-
if (this.collection.size === 0) return
|
|
4086
|
+
if (this.collection.size === 0) return {
|
|
4087
|
+
type: 'root'
|
|
4088
|
+
};
|
|
4083
4089
|
let rect = this.ref.current.getBoundingClientRect();
|
|
4084
4090
|
x += rect.x;
|
|
4085
4091
|
y += rect.y;
|