@dnd-kit/dom 0.1.8 → 0.1.9

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.cjs CHANGED
@@ -260,7 +260,6 @@ var Cursor = class extends abstract.Plugin {
260
260
  var ATTR_PREFIX = "data-dnd-";
261
261
  var DROPPING_ATTRIBUTE = `${ATTR_PREFIX}dropping`;
262
262
  var CSS_PREFIX = "--dnd-";
263
- var ROOT_ATTRIBUTE = `${ATTR_PREFIX}root`;
264
263
  var ATTRIBUTE = `${ATTR_PREFIX}dragging`;
265
264
  var PLACEHOLDER_ATTRIBUTE = `${ATTR_PREFIX}placeholder`;
266
265
  var IGNORED_ATTRIBUTES = [
@@ -270,6 +269,7 @@ var IGNORED_ATTRIBUTES = [
270
269
  "aria-pressed",
271
270
  "aria-grabbing"
272
271
  ];
272
+ var IGNORED_STYLES = ["view-transition-name"];
273
273
  var CSS_RULES = `
274
274
  :root [${ATTRIBUTE}] {
275
275
  position: fixed !important;
@@ -305,11 +305,9 @@ var CSS_RULES = `
305
305
  translate: var(${CSS_PREFIX}translate) !important;
306
306
  }
307
307
 
308
- [${ROOT_ATTRIBUTE}][style*='${CSS_PREFIX}scale'] {
309
- &:is([${ATTRIBUTE}]), [${ATTRIBUTE}] {
310
- scale: var(${CSS_PREFIX}scale) !important;
311
- transform-origin: var(${CSS_PREFIX}transform-origin) !important;
312
- }
308
+ [${ATTRIBUTE}][style*='${CSS_PREFIX}scale'] {
309
+ scale: var(${CSS_PREFIX}scale) !important;
310
+ transform-origin: var(${CSS_PREFIX}transform-origin) !important;
313
311
  }
314
312
 
315
313
  @layer {
@@ -424,7 +422,7 @@ _init = __decoratorStart(_a);
424
422
  _overlay = new WeakMap();
425
423
  _Feedback_instances = new WeakSet();
426
424
  render_fn = function() {
427
- var _a4, _b2, _c3, _d2;
425
+ var _a4, _b2, _c3;
428
426
  const { state: state$1, manager, options } = this;
429
427
  const { dragOperation } = manager;
430
428
  const { position, source, status } = dragOperation;
@@ -457,11 +455,9 @@ render_fn = function() {
457
455
  width = width / scaleDelta.x;
458
456
  height = height / scaleDelta.y;
459
457
  }
460
- let root = (_b2 = this.overlay) != null ? _b2 : feedbackElement.ownerDocument.body;
461
- if (options == null ? void 0 : options.rootElement) {
462
- root = typeof options.rootElement === "function" ? options.rootElement(source) : options.rootElement;
463
- }
464
- const styles = new utilities.Styles(root);
458
+ let elementMutationObserver;
459
+ let documentMutationObserver;
460
+ const styles = new utilities.Styles(feedbackElement);
465
461
  const { transition, translate } = utilities.getComputedStyles(element);
466
462
  const clone = feedback === "clone";
467
463
  const placeholder = feedback !== "move" && !this.overlay ? createPlaceholder(source, clone ? "clone" : "hidden") : null;
@@ -520,11 +516,10 @@ render_fn = function() {
520
516
  };
521
517
  feedbackElement.setAttribute(ATTRIBUTE, "true");
522
518
  const transform = state.untracked(() => dragOperation.transform);
523
- const initialTranslate = (_c3 = initial.translate) != null ? _c3 : { x: 0, y: 0 };
519
+ const initialTranslate = (_b2 = initial.translate) != null ? _b2 : { x: 0, y: 0 };
524
520
  const tX = transform.x * frameTransform.scaleX + initialTranslate.x;
525
521
  const tY = transform.y * frameTransform.scaleY + initialTranslate.y;
526
522
  const translateString = `${tX}px ${tY}px 0`;
527
- root.setAttribute(ROOT_ATTRIBUTE, "");
528
523
  styles.set(
529
524
  {
530
525
  width,
@@ -541,6 +536,7 @@ render_fn = function() {
541
536
  if (placeholder) {
542
537
  element.insertAdjacentElement("afterend", placeholder);
543
538
  if (options == null ? void 0 : options.rootElement) {
539
+ const root = typeof options.rootElement === "function" ? options.rootElement(source) : options.rootElement;
544
540
  root.appendChild(element);
545
541
  }
546
542
  }
@@ -569,6 +565,7 @@ render_fn = function() {
569
565
  },
570
566
  CSS_PREFIX
571
567
  );
568
+ elementMutationObserver == null ? void 0 : elementMutationObserver.takeRecords();
572
569
  if (isTableRow(element) && isTableRow(placeholder)) {
573
570
  const cells = Array.from(element.cells);
574
571
  const placeholderCells = Array.from(placeholder.cells);
@@ -583,8 +580,6 @@ render_fn = function() {
583
580
  if (state.untracked(() => source.status) === "idle") {
584
581
  requestAnimationFrame(() => source.status = "dragging");
585
582
  }
586
- let elementMutationObserver;
587
- let documentMutationObserver;
588
583
  if (placeholder) {
589
584
  resizeObserver.observe(placeholder);
590
585
  elementMutationObserver = new MutationObserver((mutations) => {
@@ -602,7 +597,23 @@ render_fn = function() {
602
597
  continue;
603
598
  }
604
599
  const attributeValue = element.getAttribute(attributeName);
605
- if (attributeValue !== null) {
600
+ if (attributeName === "style") {
601
+ if (utilities.supportsStyle(element) && utilities.supportsStyle(placeholder)) {
602
+ const styles2 = element.style;
603
+ for (const key of Array.from(placeholder.style)) {
604
+ if (styles2.getPropertyValue(key) === "") {
605
+ placeholder.style.removeProperty(key);
606
+ }
607
+ }
608
+ for (const key of Array.from(styles2)) {
609
+ if (IGNORED_STYLES.includes(key) || key.startsWith(CSS_PREFIX)) {
610
+ continue;
611
+ }
612
+ const value = styles2.getPropertyValue(key);
613
+ placeholder.style.setProperty(key, value);
614
+ }
615
+ }
616
+ } else if (attributeValue !== null) {
606
617
  placeholder.setAttribute(attributeName, attributeValue);
607
618
  } else {
608
619
  placeholder.removeAttribute(attributeName);
@@ -657,6 +668,7 @@ render_fn = function() {
657
668
  },
658
669
  CSS_PREFIX
659
670
  );
671
+ elementMutationObserver == null ? void 0 : elementMutationObserver.takeRecords();
660
672
  dragOperation.shape = new utilities.DOMRectangle(feedbackElement);
661
673
  state$1.current.translate = {
662
674
  x,
@@ -664,7 +676,7 @@ render_fn = function() {
664
676
  };
665
677
  }
666
678
  });
667
- const id = (_d2 = manager.dragOperation.source) == null ? void 0 : _d2.id;
679
+ const id = (_c3 = manager.dragOperation.source) == null ? void 0 : _c3.id;
668
680
  const restoreFocus = () => {
669
681
  var _a5;
670
682
  if (!isKeyboardOperation || id == null) {
@@ -696,7 +708,6 @@ render_fn = function() {
696
708
  placeholder.replaceWith(feedbackElement);
697
709
  }
698
710
  placeholder == null ? void 0 : placeholder.remove();
699
- root.removeAttribute(ROOT_ATTRIBUTE);
700
711
  cleanupEffect();
701
712
  dropEffectCleanup == null ? void 0 : dropEffectCleanup();
702
713
  };
@@ -762,6 +773,7 @@ render_fn = function() {
762
773
  } : {};
763
774
  styles.set({ transition }, CSS_PREFIX);
764
775
  feedbackElement.setAttribute(DROPPING_ATTRIBUTE, "");
776
+ elementMutationObserver == null ? void 0 : elementMutationObserver.takeRecords();
765
777
  utilities.animateTransform({
766
778
  element: feedbackElement,
767
779
  keyframes: __spreadProps(__spreadValues(__spreadValues({}, heightKeyframes), widthKeyframes), {