@dnd-kit/dom 0.1.13 → 0.1.14-beta-20250520125507

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/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { configurator, Sensor, Plugin, CorePlugin, DragDropManager as DragDropManager$1, Draggable as Draggable$1, Droppable as Droppable$1, descriptor } from '@dnd-kit/abstract';
2
- import { ScrollDirection, Listeners, isElement, scrollIntoViewIfNeeded, DOMRectangle, getDocument, getWindow, isHTMLElement, getFrameTransform, scheduler, isTextInput, isKeyboardEvent, isPointerEvent, canScroll, detectScrollIntent, getElementFromPoint, getScrollableAncestors, generateUniqueId, isSafari, Styles, getComputedStyles, parseTranslate, supportsPopover, showPopover, supportsStyle, getFrameElement, cloneElement, isKeyframeEffect, animateTransform, ProxiedElements, PositionObserver } from '@dnd-kit/dom/utilities';
2
+ import { ScrollDirection, Listeners, isElement, scrollIntoViewIfNeeded, DOMRectangle, getDocument, isHTMLElement, getFrameTransform, scheduler, isTextInput, isKeyboardEvent, isPointerEvent, canScroll, detectScrollIntent, getElementFromPoint, getScrollableAncestors, generateUniqueId, isSafari, Styles, getComputedStyles, parseTranslate, supportsPopover, showPopover, getWindow, supportsStyle, getFrameElement, cloneElement, isKeyframeEffect, animateTransform, ProxiedElements, PositionObserver } from '@dnd-kit/dom/utilities';
3
3
  import { effect, computed, deepEqual, signal, batch, untracked, reactive } from '@dnd-kit/state';
4
4
  import { exceedsDistance, Axes, Point, Rectangle } from '@dnd-kit/geometry';
5
5
  import { defaultCollisionDetection } from '@dnd-kit/collision';
@@ -599,7 +599,8 @@ render_fn = function() {
599
599
  const initialTranslate = (_b2 = initial.translate) != null ? _b2 : { x: 0, y: 0 };
600
600
  const tX = transform.x * frameTransform.scaleX + initialTranslate.x;
601
601
  const tY = transform.y * frameTransform.scaleY + initialTranslate.y;
602
- const translateString = `${tX}px, ${tY}px, 0`;
602
+ const translateString = `${tX}px ${tY}px 0`;
603
+ const transitionString = transition ? `${transition}, translate 0ms linear` : "";
603
604
  styles.set(
604
605
  {
605
606
  width: width - widthOffset,
@@ -607,8 +608,8 @@ render_fn = function() {
607
608
  top: projected.top,
608
609
  left: projected.left,
609
610
  translate: translateString,
611
+ transition: transitionString,
610
612
  scale: crossFrame ? `${scaleDelta.x} ${scaleDelta.y}` : "",
611
- transition,
612
613
  "transform-origin": `${transformOrigin.x * 100}% ${transformOrigin.y * 100}%`
613
614
  },
614
615
  CSS_PREFIX
@@ -654,9 +655,17 @@ render_fn = function() {
654
655
  cell.style.width = `${placeholderCell.offsetWidth}px`;
655
656
  }
656
657
  }
657
- dragOperation.shape = new DOMRectangle(element);
658
+ dragOperation.shape = new DOMRectangle(feedbackElement);
658
659
  });
659
- dragOperation.shape = new DOMRectangle(feedbackElement);
660
+ const initialShape = new DOMRectangle(feedbackElement);
661
+ untracked(() => dragOperation.shape = initialShape);
662
+ const feedbackWindow = getWindow(feedbackElement);
663
+ const handleWindowResize = (event) => {
664
+ this.manager.actions.stop({ event });
665
+ };
666
+ if (isKeyboardOperation) {
667
+ feedbackWindow.addEventListener("resize", handleWindowResize);
668
+ }
660
669
  if (untracked(() => source.status) === "idle") {
661
670
  requestAnimationFrame(() => source.status = "dragging");
662
671
  }
@@ -742,6 +751,12 @@ render_fn = function() {
742
751
  x: transform2.x / frameTransform.scaleX + initialTranslate2.x,
743
752
  y: transform2.y / frameTransform.scaleY + initialTranslate2.y
744
753
  };
754
+ const previousTranslate = state.current.translate;
755
+ const modifiers = untracked(() => dragOperation.modifiers);
756
+ const currentShape = untracked(() => {
757
+ var _a6;
758
+ return (_a6 = dragOperation.shape) == null ? void 0 : _a6.current;
759
+ });
745
760
  const translateTransition = isKeyboardOperation ? "250ms cubic-bezier(0.25, 1, 0.5, 1)" : "0ms linear";
746
761
  styles.set(
747
762
  {
@@ -751,13 +766,7 @@ render_fn = function() {
751
766
  CSS_PREFIX
752
767
  );
753
768
  elementMutationObserver == null ? void 0 : elementMutationObserver.takeRecords();
754
- const previousTranslate = state.current.translate;
755
- const modifiers = untracked(() => dragOperation.modifiers);
756
- const currentShape = untracked(() => {
757
- var _a6;
758
- return (_a6 = dragOperation.shape) == null ? void 0 : _a6.current;
759
- });
760
- if (currentShape && previousTranslate && !modifiers.length) {
769
+ if (currentShape && currentShape !== initialShape && previousTranslate && !modifiers.length) {
761
770
  const delta2 = Point.delta(translate2, previousTranslate);
762
771
  dragOperation.shape = Rectangle.from(
763
772
  currentShape.boundingRectangle
@@ -785,6 +794,7 @@ render_fn = function() {
785
794
  elementMutationObserver == null ? void 0 : elementMutationObserver.disconnect();
786
795
  documentMutationObserver == null ? void 0 : documentMutationObserver.disconnect();
787
796
  resizeObserver.disconnect();
797
+ feedbackWindow.removeEventListener("resize", handleWindowResize);
788
798
  if (supportsPopover(feedbackElement)) {
789
799
  feedbackElement.removeEventListener(
790
800
  "beforetoggle",
@@ -893,7 +903,7 @@ render_fn = function() {
893
903
  injectStyles_fn = function() {
894
904
  var _a4, _b2;
895
905
  const { status, source, target } = this.manager.dragOperation;
896
- if (status.initialized) {
906
+ if (status.initializing) {
897
907
  const sourceDocument = getDocument((_a4 = source == null ? void 0 : source.element) != null ? _a4 : null);
898
908
  const targetDocument = getDocument((_b2 = target == null ? void 0 : target.element) != null ? _b2 : null);
899
909
  const documents = /* @__PURE__ */ new Set([sourceDocument, targetDocument]);
@@ -1372,7 +1382,6 @@ var _KeyboardSensor = class _KeyboardSensor extends Sensor {
1372
1382
  if (controller.signal.aborted) return this.cleanup();
1373
1383
  this.sideEffects();
1374
1384
  const sourceDocument = getDocument(element);
1375
- const sourceWindow = getWindow(sourceDocument);
1376
1385
  const listeners = [
1377
1386
  this.listeners.bind(sourceDocument, [
1378
1387
  {
@@ -1380,9 +1389,6 @@ var _KeyboardSensor = class _KeyboardSensor extends Sensor {
1380
1389
  listener: (event2) => this.handleKeyDown(event2, source, options),
1381
1390
  options: { capture: true }
1382
1391
  }
1383
- ]),
1384
- this.listeners.bind(sourceWindow, [
1385
- { type: "resize", listener: () => this.handleEnd(event, true) }
1386
1392
  ])
1387
1393
  ];
1388
1394
  __privateGet(this, _cleanupFunctions).push(...listeners);