@react-aria/dnd 3.0.0-nightly.3207 → 3.0.0-nightly.3218

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 CHANGED
@@ -276,6 +276,7 @@ function $4620ae0dc40f0031$var$getEntryFile(entry) {
276
276
 
277
277
 
278
278
 
279
+
279
280
  let $28e10663603f5ea1$var$dropTargets = new Map();
280
281
  let $28e10663603f5ea1$var$dropItems = new Map();
281
282
  let $28e10663603f5ea1$var$dragSession = null;
@@ -363,6 +364,7 @@ class $28e10663603f5ea1$var$DragSession {
363
364
  window.addEventListener('focus', this.onFocus, true);
364
365
  window.addEventListener('blur', this.onBlur, true);
365
366
  document.addEventListener('click', this.onClick, true);
367
+ document.addEventListener('pointerdown', this.onPointerDown, true);
366
368
  for (let event of $28e10663603f5ea1$var$CANCELED_EVENTS)document.addEventListener(event, this.cancelEvent, true);
367
369
  this.mutationObserver = new MutationObserver(()=>this.updateValidDropTargets()
368
370
  );
@@ -374,6 +376,7 @@ class $28e10663603f5ea1$var$DragSession {
374
376
  window.removeEventListener('focus', this.onFocus, true);
375
377
  window.removeEventListener('blur', this.onBlur, true);
376
378
  document.removeEventListener('click', this.onClick, true);
379
+ document.removeEventListener('pointerdown', this.onPointerDown, true);
377
380
  for (let event of $28e10663603f5ea1$var$CANCELED_EVENTS)document.removeEventListener(event, this.cancelEvent, true);
378
381
  this.mutationObserver.disconnect();
379
382
  this.restoreAriaHidden();
@@ -423,19 +426,26 @@ class $28e10663603f5ea1$var$DragSession {
423
426
  }
424
427
  onClick(e) {
425
428
  this.cancelEvent(e);
426
- if (e.detail !== 0) return;
427
- if (e.target === this.dragTarget.element) {
428
- this.cancel();
429
- return;
430
- }
431
- let dropTarget = this.validDropTargets.find((target)=>target.element.contains(e.target)
432
- );
433
- if (dropTarget) {
434
- let item = $28e10663603f5ea1$var$dropItems.get(e.target);
435
- this.setCurrentDropTarget(dropTarget, item);
436
- this.drop(item);
429
+ if (e.detail === 0 || this.isVirtualClick) {
430
+ if (e.target === this.dragTarget.element) {
431
+ this.cancel();
432
+ return;
433
+ }
434
+ let dropTarget = this.validDropTargets.find((target)=>target.element.contains(e.target)
435
+ );
436
+ if (dropTarget) {
437
+ let item = $28e10663603f5ea1$var$dropItems.get(e.target);
438
+ this.setCurrentDropTarget(dropTarget, item);
439
+ this.drop(item);
440
+ }
437
441
  }
438
442
  }
443
+ onPointerDown(e) {
444
+ // Android Talkback double tap has e.detail = 1 for onClick. Detect the virtual click in onPointerDown before onClick fires
445
+ // so we can properly perform cancel and drop operations.
446
+ this.cancelEvent(e);
447
+ this.isVirtualClick = $4vY0V$reactariainteractions.isVirtualPointerEvent(e);
448
+ }
439
449
  cancelEvent(e) {
440
450
  var ref;
441
451
  // Allow focusin and focusout on the drag target so focus ring works properly.
@@ -620,6 +630,7 @@ class $28e10663603f5ea1$var$DragSession {
620
630
  this.onFocus = this.onFocus.bind(this);
621
631
  this.onBlur = this.onBlur.bind(this);
622
632
  this.onClick = this.onClick.bind(this);
633
+ this.onPointerDown = this.onPointerDown.bind(this);
623
634
  this.cancelEvent = this.cancelEvent.bind(this);
624
635
  }
625
636
  }
@@ -874,6 +885,9 @@ function $dc204e8ec58447a6$export$7941f8aafa4b6021(options) {
874
885
  x = size.width / 2;
875
886
  y = size.height / 2;
876
887
  }
888
+ // Rounding height to an even number prevents blurry preview seen on some screens
889
+ let height = 2 * Math.round(rect.height / 2);
890
+ node.style.height = `${height}px`;
877
891
  e1.dataTransfer.setDragImage(node, x, y);
878
892
  // Remove the preview from the DOM after a frame so the browser has time to paint.
879
893
  requestAnimationFrame(()=>{
@@ -1736,12 +1750,12 @@ function $0cbbd00cda972c67$export$b35afafff42da2d9(props, state) {
1736
1750
  }
1737
1751
  });
1738
1752
  let item = state.collection.getItem(props.key);
1739
- let numSelectedKeys = state.selectionManager.selectedKeys.size;
1753
+ let numKeysForDrag = state.getKeysForDrag(props.key).size;
1740
1754
  let isSelected = state.selectionManager.isSelected(props.key);
1741
1755
  let message;
1742
1756
  var ref;
1743
- if (isSelected && numSelectedKeys > 1) message = formatMessage('dragSelectedItems', {
1744
- count: numSelectedKeys
1757
+ if (isSelected && numKeysForDrag > 1) message = formatMessage('dragSelectedItems', {
1758
+ count: numKeysForDrag
1745
1759
  });
1746
1760
  else message = formatMessage('dragItem', {
1747
1761
  itemText: (ref = item === null || item === void 0 ? void 0 : item.textValue) !== null && ref !== void 0 ? ref : ''