@dnd-kit/dom 0.1.7 → 0.1.8-beta-20250504131722
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/package.json +5 -5
- package/utilities.cjs +54 -46
- package/utilities.cjs.map +1 -1
- package/utilities.d.cts +7 -1
- package/utilities.d.ts +7 -1
- package/utilities.js +54 -46
- package/utilities.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dnd-kit/dom",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8-beta-20250504131722",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.cjs",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -74,10 +74,10 @@
|
|
|
74
74
|
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
|
-
"@dnd-kit/abstract": "
|
|
78
|
-
"@dnd-kit/collision": "
|
|
79
|
-
"@dnd-kit/geometry": "
|
|
80
|
-
"@dnd-kit/state": "
|
|
77
|
+
"@dnd-kit/abstract": "0.1.8-beta-20250504131722",
|
|
78
|
+
"@dnd-kit/collision": "0.1.8-beta-20250504131722",
|
|
79
|
+
"@dnd-kit/geometry": "0.1.8-beta-20250504131722",
|
|
80
|
+
"@dnd-kit/state": "0.1.8-beta-20250504131722",
|
|
81
81
|
"tslib": "^2.6.2"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
package/utilities.cjs
CHANGED
|
@@ -513,18 +513,59 @@ function canScroll(scrollableElement, by) {
|
|
|
513
513
|
};
|
|
514
514
|
}
|
|
515
515
|
|
|
516
|
+
// src/utilities/scheduling/scheduler.ts
|
|
517
|
+
var Scheduler = class {
|
|
518
|
+
constructor(scheduler4) {
|
|
519
|
+
this.scheduler = scheduler4;
|
|
520
|
+
this.pending = false;
|
|
521
|
+
this.tasks = /* @__PURE__ */ new Set();
|
|
522
|
+
this.resolvers = /* @__PURE__ */ new Set();
|
|
523
|
+
this.flush = () => {
|
|
524
|
+
const { tasks, resolvers } = this;
|
|
525
|
+
this.pending = false;
|
|
526
|
+
this.tasks = /* @__PURE__ */ new Set();
|
|
527
|
+
this.resolvers = /* @__PURE__ */ new Set();
|
|
528
|
+
for (const task of tasks) {
|
|
529
|
+
task();
|
|
530
|
+
}
|
|
531
|
+
for (const resolve of resolvers) {
|
|
532
|
+
resolve();
|
|
533
|
+
}
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
schedule(task) {
|
|
537
|
+
this.tasks.add(task);
|
|
538
|
+
if (!this.pending) {
|
|
539
|
+
this.pending = true;
|
|
540
|
+
this.scheduler(this.flush);
|
|
541
|
+
}
|
|
542
|
+
return new Promise((resolve) => this.resolvers.add(resolve));
|
|
543
|
+
}
|
|
544
|
+
};
|
|
545
|
+
var scheduler = new Scheduler(
|
|
546
|
+
(callback) => requestAnimationFrame(callback)
|
|
547
|
+
);
|
|
548
|
+
|
|
516
549
|
// src/utilities/styles/getComputedStyles.ts
|
|
517
|
-
|
|
518
|
-
|
|
550
|
+
var scheduler2 = new Scheduler((callback) => setTimeout(callback, 50));
|
|
551
|
+
var cachedStyles = /* @__PURE__ */ new Map();
|
|
552
|
+
var clear = cachedStyles.clear.bind(cachedStyles);
|
|
553
|
+
function getComputedStyles(element, cached = false) {
|
|
554
|
+
let styles = cachedStyles.get(element);
|
|
555
|
+
if (cached && styles) return styles;
|
|
556
|
+
styles = getWindow(element).getComputedStyle(element);
|
|
557
|
+
cachedStyles.set(element, styles);
|
|
558
|
+
scheduler2.schedule(clear);
|
|
559
|
+
return styles;
|
|
519
560
|
}
|
|
520
561
|
|
|
521
562
|
// src/utilities/scroll/isFixed.ts
|
|
522
|
-
function isFixed(node, computedStyle = getComputedStyles(node)) {
|
|
563
|
+
function isFixed(node, computedStyle = getComputedStyles(node, true)) {
|
|
523
564
|
return computedStyle.position === "fixed" || computedStyle.position === "sticky";
|
|
524
565
|
}
|
|
525
566
|
|
|
526
567
|
// src/utilities/scroll/isScrollable.ts
|
|
527
|
-
function isScrollable(element, computedStyle = getComputedStyles(element)) {
|
|
568
|
+
function isScrollable(element, computedStyle = getComputedStyles(element, true)) {
|
|
528
569
|
const overflowRegex = /(auto|scroll|overlay)/;
|
|
529
570
|
const properties = ["overflow", "overflowX", "overflowY"];
|
|
530
571
|
return properties.some((property) => {
|
|
@@ -560,7 +601,7 @@ function getScrollableAncestors(element, options = defaultOptions) {
|
|
|
560
601
|
if (scrollParents.has(node)) {
|
|
561
602
|
return scrollParents;
|
|
562
603
|
}
|
|
563
|
-
const computedStyle = getComputedStyles(node);
|
|
604
|
+
const computedStyle = getComputedStyles(node, true);
|
|
564
605
|
if (excludeElement && node === element) ; else if (isScrollable(node, computedStyle)) {
|
|
565
606
|
scrollParents.add(node);
|
|
566
607
|
}
|
|
@@ -604,7 +645,7 @@ function getFrameTransform(el, boundary = window.frameElement) {
|
|
|
604
645
|
if (frame === boundary) {
|
|
605
646
|
return transform;
|
|
606
647
|
}
|
|
607
|
-
const rect = frame
|
|
648
|
+
const rect = getBoundingRectangle(frame);
|
|
608
649
|
const { x: scaleX, y: scaleY } = getScale(frame, rect);
|
|
609
650
|
transform.x = transform.x + rect.left;
|
|
610
651
|
transform.y = transform.y + rect.top;
|
|
@@ -614,7 +655,7 @@ function getFrameTransform(el, boundary = window.frameElement) {
|
|
|
614
655
|
}
|
|
615
656
|
return transform;
|
|
616
657
|
}
|
|
617
|
-
function getScale(element, boundingRectangle = element
|
|
658
|
+
function getScale(element, boundingRectangle = getBoundingRectangle(element)) {
|
|
618
659
|
const width = Math.round(boundingRectangle.width);
|
|
619
660
|
const height = Math.round(boundingRectangle.height);
|
|
620
661
|
if (isHTMLElement(element)) {
|
|
@@ -623,7 +664,7 @@ function getScale(element, boundingRectangle = element.getBoundingClientRect())
|
|
|
623
664
|
y: height / element.offsetHeight
|
|
624
665
|
};
|
|
625
666
|
}
|
|
626
|
-
const styles = getComputedStyles(element);
|
|
667
|
+
const styles = getComputedStyles(element, true);
|
|
627
668
|
return {
|
|
628
669
|
x: (parseFloat(styles.width) || width) / width,
|
|
629
670
|
y: (parseFloat(styles.height) || height) / height
|
|
@@ -736,7 +777,7 @@ function detectScrollIntent(scrollableElement, coordinates, intent, acceleration
|
|
|
736
777
|
const { x, y } = coordinates;
|
|
737
778
|
const { rect, isTop, isBottom, isLeft, isRight } = getScrollPosition(scrollableElement);
|
|
738
779
|
const frameTransform = getFrameTransform(scrollableElement);
|
|
739
|
-
const computedStyles = getComputedStyles(scrollableElement);
|
|
780
|
+
const computedStyles = getComputedStyles(scrollableElement, true);
|
|
740
781
|
const parsedTransform = parseTransform(computedStyles);
|
|
741
782
|
const isXAxisInverted = parsedTransform !== null ? (parsedTransform == null ? void 0 : parsedTransform.scaleX) < 0 : false;
|
|
742
783
|
const isYAxisInverted = parsedTransform !== null ? (parsedTransform == null ? void 0 : parsedTransform.scaleY) < 0 : false;
|
|
@@ -802,7 +843,7 @@ function scrollIntoViewIfNeeded(el, centerIfNeeded = false) {
|
|
|
802
843
|
if (!isHTMLElement(parent)) {
|
|
803
844
|
return;
|
|
804
845
|
}
|
|
805
|
-
const parentComputedStyle = getComputedStyles(parent), parentBorderTopWidth = parseInt(
|
|
846
|
+
const parentComputedStyle = getComputedStyles(parent, true), parentBorderTopWidth = parseInt(
|
|
806
847
|
parentComputedStyle.getPropertyValue("border-top-width")
|
|
807
848
|
), parentBorderLeftWidth = parseInt(
|
|
808
849
|
parentComputedStyle.getPropertyValue("border-left-width")
|
|
@@ -818,39 +859,6 @@ function scrollIntoViewIfNeeded(el, centerIfNeeded = false) {
|
|
|
818
859
|
}
|
|
819
860
|
}
|
|
820
861
|
|
|
821
|
-
// src/utilities/scheduling/scheduler.ts
|
|
822
|
-
var Scheduler = class {
|
|
823
|
-
constructor(scheduler3) {
|
|
824
|
-
this.scheduler = scheduler3;
|
|
825
|
-
this.pending = false;
|
|
826
|
-
this.tasks = /* @__PURE__ */ new Set();
|
|
827
|
-
this.resolvers = /* @__PURE__ */ new Set();
|
|
828
|
-
this.flush = () => {
|
|
829
|
-
const { tasks, resolvers } = this;
|
|
830
|
-
this.pending = false;
|
|
831
|
-
this.tasks = /* @__PURE__ */ new Set();
|
|
832
|
-
this.resolvers = /* @__PURE__ */ new Set();
|
|
833
|
-
for (const task of tasks) {
|
|
834
|
-
task();
|
|
835
|
-
}
|
|
836
|
-
for (const resolve of resolvers) {
|
|
837
|
-
resolve();
|
|
838
|
-
}
|
|
839
|
-
};
|
|
840
|
-
}
|
|
841
|
-
schedule(task) {
|
|
842
|
-
this.tasks.add(task);
|
|
843
|
-
if (!this.pending) {
|
|
844
|
-
this.pending = true;
|
|
845
|
-
this.scheduler(this.flush);
|
|
846
|
-
}
|
|
847
|
-
return new Promise((resolve) => this.resolvers.add(resolve));
|
|
848
|
-
}
|
|
849
|
-
};
|
|
850
|
-
var scheduler = new Scheduler(
|
|
851
|
-
(callback) => requestAnimationFrame(callback)
|
|
852
|
-
);
|
|
853
|
-
|
|
854
862
|
// src/utilities/transform/inverseTransform.ts
|
|
855
863
|
function inverseTransform(rect, parsedTransform, transformOrigin) {
|
|
856
864
|
const { scaleX, scaleY, x: translateX, y: translateY } = parsedTransform;
|
|
@@ -1011,16 +1019,16 @@ function getProjectedTransform(element) {
|
|
|
1011
1019
|
}
|
|
1012
1020
|
return projectedTransform;
|
|
1013
1021
|
}
|
|
1014
|
-
var
|
|
1022
|
+
var scheduler3 = new Scheduler((callback) => setTimeout(callback, 0));
|
|
1015
1023
|
var animations = /* @__PURE__ */ new Map();
|
|
1016
|
-
var
|
|
1024
|
+
var clear2 = animations.clear.bind(animations);
|
|
1017
1025
|
function getDocumentAnimations(element) {
|
|
1018
1026
|
const document2 = element.ownerDocument;
|
|
1019
1027
|
let documentAnimations = animations.get(document2);
|
|
1020
1028
|
if (documentAnimations) return documentAnimations;
|
|
1021
1029
|
documentAnimations = document2.getAnimations();
|
|
1022
1030
|
animations.set(document2, documentAnimations);
|
|
1023
|
-
|
|
1031
|
+
scheduler3.schedule(clear2);
|
|
1024
1032
|
const elementAnimations = documentAnimations.filter(
|
|
1025
1033
|
(animation) => isKeyframeEffect(animation.effect) && animation.effect.target === element
|
|
1026
1034
|
);
|