@dnd-kit/dom 0.1.4 → 0.1.5-beta-20250429125415
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 +101 -89
- package/index.cjs.map +1 -1
- package/index.d.cts +3 -0
- package/index.d.ts +3 -0
- package/index.js +103 -91
- package/index.js.map +1 -1
- package/package.json +5 -5
package/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var abstract = require('@dnd-kit/abstract');
|
|
4
|
-
var utilities = require('@dnd-kit/dom/utilities');
|
|
5
4
|
var state = require('@dnd-kit/state');
|
|
5
|
+
var utilities = require('@dnd-kit/dom/utilities');
|
|
6
6
|
var geometry = require('@dnd-kit/geometry');
|
|
7
7
|
var collision = require('@dnd-kit/collision');
|
|
8
8
|
|
|
@@ -709,69 +709,74 @@ render_fn = function() {
|
|
|
709
709
|
onComplete == null ? void 0 : onComplete();
|
|
710
710
|
return;
|
|
711
711
|
}
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
animations.
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
712
|
+
const dropAnimation = () => {
|
|
713
|
+
{
|
|
714
|
+
utilities.showPopover(feedbackElement);
|
|
715
|
+
const target = placeholder != null ? placeholder : element;
|
|
716
|
+
const animations = feedbackElement.getAnimations();
|
|
717
|
+
if (animations.length) {
|
|
718
|
+
animations.forEach((animation) => {
|
|
719
|
+
const { effect: effect9 } = animation;
|
|
720
|
+
if (utilities.isKeyframeEffect(effect9) && effect9.getKeyframes().some((keyframe) => keyframe.translate)) {
|
|
721
|
+
animation.finish();
|
|
722
|
+
}
|
|
723
|
+
});
|
|
724
|
+
}
|
|
725
|
+
const options2 = {
|
|
726
|
+
frameTransform: isSameFrame(feedbackElement, target) ? null : void 0
|
|
727
|
+
};
|
|
728
|
+
const current = new utilities.DOMRectangle(feedbackElement, options2);
|
|
729
|
+
const final = new utilities.DOMRectangle(target, options2);
|
|
730
|
+
const delta2 = geometry.Rectangle.delta(current, final, source.alignment);
|
|
731
|
+
const finalTranslate = {
|
|
732
|
+
x: translate2.x - delta2.x,
|
|
733
|
+
y: translate2.y - delta2.y
|
|
734
|
+
};
|
|
735
|
+
const heightKeyframes = Math.round(current.intrinsicHeight) !== Math.round(final.intrinsicHeight) ? {
|
|
736
|
+
minHeight: [
|
|
737
|
+
`${current.intrinsicHeight}px`,
|
|
738
|
+
`${final.intrinsicHeight}px`
|
|
739
|
+
],
|
|
740
|
+
maxHeight: [
|
|
741
|
+
`${current.intrinsicHeight}px`,
|
|
742
|
+
`${final.intrinsicHeight}px`
|
|
743
|
+
]
|
|
744
|
+
} : {};
|
|
745
|
+
const widthKeyframes = Math.round(current.intrinsicWidth) !== Math.round(final.intrinsicWidth) ? {
|
|
746
|
+
minWidth: [
|
|
747
|
+
`${current.intrinsicWidth}px`,
|
|
748
|
+
`${final.intrinsicWidth}px`
|
|
749
|
+
],
|
|
750
|
+
maxWidth: [
|
|
751
|
+
`${current.intrinsicWidth}px`,
|
|
752
|
+
`${final.intrinsicWidth}px`
|
|
753
|
+
]
|
|
754
|
+
} : {};
|
|
755
|
+
utilities.animateTransform({
|
|
756
|
+
element: feedbackElement,
|
|
757
|
+
keyframes: __spreadProps(__spreadValues(__spreadValues({}, heightKeyframes), widthKeyframes), {
|
|
758
|
+
translate: [
|
|
759
|
+
`${translate2.x}px ${translate2.y}px 0`,
|
|
760
|
+
`${finalTranslate.x}px ${finalTranslate.y}px 0`
|
|
761
|
+
]
|
|
762
|
+
}),
|
|
763
|
+
options: {
|
|
764
|
+
duration: moved || feedbackElement !== element ? 250 : 0,
|
|
765
|
+
easing: "ease"
|
|
766
|
+
},
|
|
767
|
+
onReady() {
|
|
768
|
+
styles.remove(["translate"], CSS_PREFIX);
|
|
769
|
+
},
|
|
770
|
+
onFinish() {
|
|
771
|
+
onComplete == null ? void 0 : onComplete();
|
|
772
|
+
requestAnimationFrame(restoreFocus);
|
|
721
773
|
}
|
|
722
774
|
});
|
|
723
775
|
}
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
const final = new utilities.DOMRectangle(target, options2);
|
|
729
|
-
const delta2 = geometry.Rectangle.delta(current, final, source.alignment);
|
|
730
|
-
const finalTranslate = {
|
|
731
|
-
x: translate2.x - delta2.x,
|
|
732
|
-
y: translate2.y - delta2.y
|
|
733
|
-
};
|
|
734
|
-
const heightKeyframes = Math.round(current.intrinsicHeight) !== Math.round(final.intrinsicHeight) ? {
|
|
735
|
-
minHeight: [
|
|
736
|
-
`${current.intrinsicHeight}px`,
|
|
737
|
-
`${final.intrinsicHeight}px`
|
|
738
|
-
],
|
|
739
|
-
maxHeight: [
|
|
740
|
-
`${current.intrinsicHeight}px`,
|
|
741
|
-
`${final.intrinsicHeight}px`
|
|
742
|
-
]
|
|
743
|
-
} : {};
|
|
744
|
-
const widthKeyframes = Math.round(current.intrinsicWidth) !== Math.round(final.intrinsicWidth) ? {
|
|
745
|
-
minWidth: [
|
|
746
|
-
`${current.intrinsicWidth}px`,
|
|
747
|
-
`${final.intrinsicWidth}px`
|
|
748
|
-
],
|
|
749
|
-
maxWidth: [
|
|
750
|
-
`${current.intrinsicWidth}px`,
|
|
751
|
-
`${final.intrinsicWidth}px`
|
|
752
|
-
]
|
|
753
|
-
} : {};
|
|
754
|
-
utilities.animateTransform({
|
|
755
|
-
element: feedbackElement,
|
|
756
|
-
keyframes: __spreadProps(__spreadValues(__spreadValues({}, heightKeyframes), widthKeyframes), {
|
|
757
|
-
translate: [
|
|
758
|
-
`${translate2.x}px ${translate2.y}px 0`,
|
|
759
|
-
`${finalTranslate.x}px ${finalTranslate.y}px 0`
|
|
760
|
-
]
|
|
761
|
-
}),
|
|
762
|
-
options: {
|
|
763
|
-
duration: moved || feedbackElement !== element ? 250 : 0,
|
|
764
|
-
easing: "ease"
|
|
765
|
-
},
|
|
766
|
-
onReady() {
|
|
767
|
-
styles.remove(["translate"], CSS_PREFIX);
|
|
768
|
-
},
|
|
769
|
-
onFinish() {
|
|
770
|
-
onComplete == null ? void 0 : onComplete();
|
|
771
|
-
requestAnimationFrame(restoreFocus);
|
|
772
|
-
}
|
|
773
|
-
});
|
|
774
|
-
});
|
|
776
|
+
};
|
|
777
|
+
manager.renderer.rendering.then(
|
|
778
|
+
() => requestAnimationFrame(dropAnimation)
|
|
779
|
+
);
|
|
775
780
|
}
|
|
776
781
|
});
|
|
777
782
|
return () => cleanup == null ? void 0 : cleanup();
|
|
@@ -1309,6 +1314,24 @@ _cleanupFunctions = new WeakMap();
|
|
|
1309
1314
|
function isKeycode(event, codes) {
|
|
1310
1315
|
return codes.includes(event.code);
|
|
1311
1316
|
}
|
|
1317
|
+
var defaults = Object.freeze({
|
|
1318
|
+
activationConstraints(event, source) {
|
|
1319
|
+
var _a4;
|
|
1320
|
+
const { pointerType, target } = event;
|
|
1321
|
+
if (pointerType === "mouse" && utilities.isElement(target) && (source.handle === target || ((_a4 = source.handle) == null ? void 0 : _a4.contains(target)))) {
|
|
1322
|
+
return void 0;
|
|
1323
|
+
}
|
|
1324
|
+
if (pointerType === "touch") {
|
|
1325
|
+
return {
|
|
1326
|
+
delay: { value: 250, tolerance: 5 }
|
|
1327
|
+
};
|
|
1328
|
+
}
|
|
1329
|
+
return {
|
|
1330
|
+
delay: { value: 200, tolerance: 10 },
|
|
1331
|
+
distance: { value: 5 }
|
|
1332
|
+
};
|
|
1333
|
+
}
|
|
1334
|
+
});
|
|
1312
1335
|
var _cleanup, _clearTimeout;
|
|
1313
1336
|
var _PointerSensor = class _PointerSensor extends abstract.Sensor {
|
|
1314
1337
|
constructor(manager, options) {
|
|
@@ -1325,19 +1348,27 @@ var _PointerSensor = class _PointerSensor extends abstract.Sensor {
|
|
|
1325
1348
|
bind(source, options = this.options) {
|
|
1326
1349
|
const unbind = state.effect(() => {
|
|
1327
1350
|
var _a4;
|
|
1328
|
-
const
|
|
1351
|
+
const controller = new AbortController();
|
|
1352
|
+
const { signal: signal3 } = controller;
|
|
1329
1353
|
const listener = (event) => {
|
|
1330
1354
|
if (utilities.isPointerEvent(event)) {
|
|
1331
1355
|
this.handlePointerDown(event, source, options);
|
|
1332
1356
|
}
|
|
1333
1357
|
};
|
|
1334
|
-
|
|
1358
|
+
let targets = [(_a4 = source.handle) != null ? _a4 : source.element];
|
|
1359
|
+
if (options == null ? void 0 : options.activatorElements) {
|
|
1360
|
+
if (Array.isArray(options.activatorElements)) {
|
|
1361
|
+
targets = options.activatorElements;
|
|
1362
|
+
} else {
|
|
1363
|
+
targets = options.activatorElements(source);
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
for (const target of targets) {
|
|
1367
|
+
if (!target) continue;
|
|
1335
1368
|
patchWindow(target.ownerDocument.defaultView);
|
|
1336
|
-
target.addEventListener("pointerdown", listener);
|
|
1337
|
-
return () => {
|
|
1338
|
-
target.removeEventListener("pointerdown", listener);
|
|
1339
|
-
};
|
|
1369
|
+
target.addEventListener("pointerdown", listener, { signal: signal3 });
|
|
1340
1370
|
}
|
|
1371
|
+
return () => controller.abort();
|
|
1341
1372
|
});
|
|
1342
1373
|
return unbind;
|
|
1343
1374
|
}
|
|
@@ -1352,7 +1383,7 @@ var _PointerSensor = class _PointerSensor extends abstract.Sensor {
|
|
|
1352
1383
|
x: event.clientX * offset.scaleX + offset.x,
|
|
1353
1384
|
y: event.clientY * offset.scaleY + offset.y
|
|
1354
1385
|
};
|
|
1355
|
-
const { activationConstraints } = options;
|
|
1386
|
+
const { activationConstraints = defaults.activationConstraints } = options;
|
|
1356
1387
|
const constraints = typeof activationConstraints === "function" ? activationConstraints(event, source) : activationConstraints;
|
|
1357
1388
|
event.sensor = this;
|
|
1358
1389
|
if (!(constraints == null ? void 0 : constraints.delay) && !(constraints == null ? void 0 : constraints.distance)) {
|
|
@@ -1525,6 +1556,7 @@ var _PointerSensor = class _PointerSensor extends abstract.Sensor {
|
|
|
1525
1556
|
_cleanup = new WeakMap();
|
|
1526
1557
|
_clearTimeout = new WeakMap();
|
|
1527
1558
|
_PointerSensor.configure = abstract.configurator(_PointerSensor);
|
|
1559
|
+
_PointerSensor.defaults = defaults;
|
|
1528
1560
|
var PointerSensor = _PointerSensor;
|
|
1529
1561
|
function isCapturedBySensor(event) {
|
|
1530
1562
|
return "sensor" in event;
|
|
@@ -1550,27 +1582,7 @@ function patchWindow(window) {
|
|
|
1550
1582
|
var defaultPreset = {
|
|
1551
1583
|
modifiers: [],
|
|
1552
1584
|
plugins: [Accessibility, AutoScroller, Cursor, Feedback, PreventSelection],
|
|
1553
|
-
sensors: [
|
|
1554
|
-
PointerSensor.configure({
|
|
1555
|
-
activationConstraints(event, source) {
|
|
1556
|
-
var _a4;
|
|
1557
|
-
const { pointerType, target } = event;
|
|
1558
|
-
if (pointerType === "mouse" && utilities.isElement(target) && (source.handle === target || ((_a4 = source.handle) == null ? void 0 : _a4.contains(target)))) {
|
|
1559
|
-
return void 0;
|
|
1560
|
-
}
|
|
1561
|
-
if (pointerType === "touch") {
|
|
1562
|
-
return {
|
|
1563
|
-
delay: { value: 250, tolerance: 5 }
|
|
1564
|
-
};
|
|
1565
|
-
}
|
|
1566
|
-
return {
|
|
1567
|
-
delay: { value: 200, tolerance: 10 },
|
|
1568
|
-
distance: { value: 5 }
|
|
1569
|
-
};
|
|
1570
|
-
}
|
|
1571
|
-
}),
|
|
1572
|
-
KeyboardSensor
|
|
1573
|
-
]
|
|
1585
|
+
sensors: [PointerSensor, KeyboardSensor]
|
|
1574
1586
|
};
|
|
1575
1587
|
var DragDropManager = class extends abstract.DragDropManager {
|
|
1576
1588
|
constructor(input = {}) {
|