@react-aria/dnd 3.0.0-alpha.7 → 3.0.0-alpha.8
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 +35 -14
- package/dist/main.js.map +1 -1
- package/dist/module.js +35 -14
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/DragManager.ts +37 -13
- package/src/useDrag.ts +4 -0
- package/src/useDraggableItem.ts +3 -3
package/dist/main.js
CHANGED
|
@@ -363,6 +363,7 @@ class $28e10663603f5ea1$var$DragSession {
|
|
|
363
363
|
window.addEventListener('focus', this.onFocus, true);
|
|
364
364
|
window.addEventListener('blur', this.onBlur, true);
|
|
365
365
|
document.addEventListener('click', this.onClick, true);
|
|
366
|
+
document.addEventListener('pointerdown', this.onPointerDown, true);
|
|
366
367
|
for (let event of $28e10663603f5ea1$var$CANCELED_EVENTS)document.addEventListener(event, this.cancelEvent, true);
|
|
367
368
|
this.mutationObserver = new MutationObserver(()=>this.updateValidDropTargets()
|
|
368
369
|
);
|
|
@@ -374,6 +375,7 @@ class $28e10663603f5ea1$var$DragSession {
|
|
|
374
375
|
window.removeEventListener('focus', this.onFocus, true);
|
|
375
376
|
window.removeEventListener('blur', this.onBlur, true);
|
|
376
377
|
document.removeEventListener('click', this.onClick, true);
|
|
378
|
+
document.removeEventListener('pointerdown', this.onPointerDown, true);
|
|
377
379
|
for (let event of $28e10663603f5ea1$var$CANCELED_EVENTS)document.removeEventListener(event, this.cancelEvent, true);
|
|
378
380
|
this.mutationObserver.disconnect();
|
|
379
381
|
this.restoreAriaHidden();
|
|
@@ -423,19 +425,26 @@ class $28e10663603f5ea1$var$DragSession {
|
|
|
423
425
|
}
|
|
424
426
|
onClick(e) {
|
|
425
427
|
this.cancelEvent(e);
|
|
426
|
-
if (e.detail
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
428
|
+
if (e.detail === 0 || this.isVirtualClick) {
|
|
429
|
+
if (e.target === this.dragTarget.element) {
|
|
430
|
+
this.cancel();
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
let dropTarget = this.validDropTargets.find((target)=>target.element.contains(e.target)
|
|
434
|
+
);
|
|
435
|
+
if (dropTarget) {
|
|
436
|
+
let item = $28e10663603f5ea1$var$dropItems.get(e.target);
|
|
437
|
+
this.setCurrentDropTarget(dropTarget, item);
|
|
438
|
+
this.drop(item);
|
|
439
|
+
}
|
|
437
440
|
}
|
|
438
441
|
}
|
|
442
|
+
onPointerDown(e) {
|
|
443
|
+
// Android Talkback double tap has e.detail = 1 for onClick. Detect the virtual click in onPointerDown before onClick fires
|
|
444
|
+
// so we can properly perform cancel and drop operations.
|
|
445
|
+
this.cancelEvent(e);
|
|
446
|
+
this.isVirtualClick = $28e10663603f5ea1$var$isVirtualPointerEvent(e);
|
|
447
|
+
}
|
|
439
448
|
cancelEvent(e) {
|
|
440
449
|
var ref;
|
|
441
450
|
// Allow focusin and focusout on the drag target so focus ring works properly.
|
|
@@ -620,6 +629,7 @@ class $28e10663603f5ea1$var$DragSession {
|
|
|
620
629
|
this.onFocus = this.onFocus.bind(this);
|
|
621
630
|
this.onBlur = this.onBlur.bind(this);
|
|
622
631
|
this.onClick = this.onClick.bind(this);
|
|
632
|
+
this.onPointerDown = this.onPointerDown.bind(this);
|
|
623
633
|
this.cancelEvent = this.cancelEvent.bind(this);
|
|
624
634
|
}
|
|
625
635
|
}
|
|
@@ -633,6 +643,14 @@ function $28e10663603f5ea1$var$findValidDropTargets(options) {
|
|
|
633
643
|
return true;
|
|
634
644
|
});
|
|
635
645
|
}
|
|
646
|
+
function $28e10663603f5ea1$var$isVirtualPointerEvent(event) {
|
|
647
|
+
// If the pointer size is zero, then we assume it's from a screen reader.
|
|
648
|
+
// Android TalkBack double tap will sometimes return a event with width and height of 1
|
|
649
|
+
// and pointerType === 'mouse' so we need to check for a specific combination of event attributes.
|
|
650
|
+
// Cannot use "event.pressure === 0" as the sole check due to Safari pointer events always returning pressure === 0
|
|
651
|
+
// instead of .5, see https://bugs.webkit.org/show_bug.cgi?id=206216
|
|
652
|
+
return event.width === 0 && event.height === 0 || event.width === 1 && event.height === 1 && event.pressure === 0 && event.detail === 0;
|
|
653
|
+
}
|
|
636
654
|
|
|
637
655
|
|
|
638
656
|
|
|
@@ -874,6 +892,9 @@ function $dc204e8ec58447a6$export$7941f8aafa4b6021(options) {
|
|
|
874
892
|
x = size.width / 2;
|
|
875
893
|
y = size.height / 2;
|
|
876
894
|
}
|
|
895
|
+
// Rounding height to an even number prevents blurry preview seen on some screens
|
|
896
|
+
let height = 2 * Math.round(rect.height / 2);
|
|
897
|
+
node.style.height = `${height}px`;
|
|
877
898
|
e1.dataTransfer.setDragImage(node, x, y);
|
|
878
899
|
// Remove the preview from the DOM after a frame so the browser has time to paint.
|
|
879
900
|
requestAnimationFrame(()=>{
|
|
@@ -1736,12 +1757,12 @@ function $0cbbd00cda972c67$export$b35afafff42da2d9(props, state) {
|
|
|
1736
1757
|
}
|
|
1737
1758
|
});
|
|
1738
1759
|
let item = state.collection.getItem(props.key);
|
|
1739
|
-
let
|
|
1760
|
+
let numKeysForDrag = state.getKeysForDrag(props.key).size;
|
|
1740
1761
|
let isSelected = state.selectionManager.isSelected(props.key);
|
|
1741
1762
|
let message;
|
|
1742
1763
|
var ref;
|
|
1743
|
-
if (isSelected &&
|
|
1744
|
-
count:
|
|
1764
|
+
if (isSelected && numKeysForDrag > 1) message = formatMessage('dragSelectedItems', {
|
|
1765
|
+
count: numKeysForDrag
|
|
1745
1766
|
});
|
|
1746
1767
|
else message = formatMessage('dragItem', {
|
|
1747
1768
|
itemText: (ref = item === null || item === void 0 ? void 0 : item.textValue) !== null && ref !== void 0 ? ref : ''
|