@dnd-kit/dom 0.2.3 → 0.2.4-beta-20260118161656
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 +60 -43
- package/index.cjs.map +1 -1
- package/index.d.cts +3 -0
- package/index.d.ts +3 -0
- package/index.js +62 -45
- package/index.js.map +1 -1
- package/package.json +5 -5
- package/utilities.cjs +32 -6
- package/utilities.cjs.map +1 -1
- package/utilities.d.cts +9 -2
- package/utilities.d.ts +9 -2
- package/utilities.js +30 -7
- package/utilities.js.map +1 -1
package/index.d.cts
CHANGED
|
@@ -248,6 +248,9 @@ declare class Feedback extends Plugin<DragDropManager, FeedbackOptions> {
|
|
|
248
248
|
accessor overlay: Element | undefined;
|
|
249
249
|
private state;
|
|
250
250
|
constructor(manager: DragDropManager, options?: FeedbackOptions);
|
|
251
|
+
private get sourceRoot();
|
|
252
|
+
private get targetRoot();
|
|
253
|
+
private get roots();
|
|
251
254
|
destroy(): void;
|
|
252
255
|
static configure: (options: FeedbackOptions) => _dnd_kit_abstract.PluginDescriptor<any, any, typeof Feedback>;
|
|
253
256
|
}
|
package/index.d.ts
CHANGED
|
@@ -248,6 +248,9 @@ declare class Feedback extends Plugin<DragDropManager, FeedbackOptions> {
|
|
|
248
248
|
accessor overlay: Element | undefined;
|
|
249
249
|
private state;
|
|
250
250
|
constructor(manager: DragDropManager, options?: FeedbackOptions);
|
|
251
|
+
private get sourceRoot();
|
|
252
|
+
private get targetRoot();
|
|
253
|
+
private get roots();
|
|
251
254
|
destroy(): void;
|
|
252
255
|
static configure: (options: FeedbackOptions) => _dnd_kit_abstract.PluginDescriptor<any, any, typeof Feedback>;
|
|
253
256
|
}
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { configurator, Sensor, ActivationController, Plugin, CorePlugin, DragDropManager as DragDropManager$1, Draggable as Draggable$1, Droppable as Droppable$1, ActivationConstraint, descriptor } from '@dnd-kit/abstract';
|
|
2
|
-
import { ScrollDirection, Listeners, isElement, scrollIntoViewIfNeeded, DOMRectangle, getDocument, isHTMLElement, getFrameTransform, getEventCoordinates, getDocuments, scheduler, isInteractiveElement, isTextInput, isKeyboardEvent, isPointerEvent, canScroll, detectScrollIntent, getElementFromPoint, getScrollableAncestors, generateUniqueId, isSafari, Styles, getComputedStyles, parseTranslate, supportsPopover, showPopover, getWindow, supportsStyle, getFrameElement, cloneElement, getFinalKeyframe, animateTransform, ProxiedElements, PositionObserver } from '@dnd-kit/dom/utilities';
|
|
3
|
-
import { effect, computed, deepEqual, signal, batch, untracked, effects, reactive } from '@dnd-kit/state';
|
|
2
|
+
import { ScrollDirection, getRoot, Listeners, isElement, scrollIntoViewIfNeeded, DOMRectangle, getDocument, isHTMLElement, getFrameTransform, getEventCoordinates, getDocuments, scheduler, isInteractiveElement, isTextInput, isKeyboardEvent, isPointerEvent, canScroll, detectScrollIntent, getElementFromPoint, getScrollableAncestors, generateUniqueId, isSafari, Styles, getComputedStyles, parseTranslate, supportsPopover, showPopover, getWindow, supportsStyle, isDocument, isShadowRoot, getFrameElement, cloneElement, getFinalKeyframe, animateTransform, ProxiedElements, PositionObserver } from '@dnd-kit/dom/utilities';
|
|
3
|
+
import { effect, computed, deepEqual, signal, batch, untracked, effects, reactive, derived } from '@dnd-kit/state';
|
|
4
4
|
import { Axes, Point, Rectangle, exceedsDistance } from '@dnd-kit/geometry';
|
|
5
5
|
import { defaultCollisionDetection } from '@dnd-kit/collision';
|
|
6
6
|
|
|
@@ -339,7 +339,7 @@ var IGNORED_ATTRIBUTES = [
|
|
|
339
339
|
];
|
|
340
340
|
var IGNORED_STYLES = ["view-transition-name"];
|
|
341
341
|
var CSS_RULES = `
|
|
342
|
-
:root [${ATTRIBUTE}] {
|
|
342
|
+
:is(:root,:host) [${ATTRIBUTE}] {
|
|
343
343
|
position: fixed !important;
|
|
344
344
|
pointer-events: none !important;
|
|
345
345
|
touch-action: none;
|
|
@@ -356,11 +356,11 @@ var CSS_RULES = `
|
|
|
356
356
|
transition: var(${CSS_PREFIX}transition) !important;
|
|
357
357
|
}
|
|
358
358
|
|
|
359
|
-
:root [${PLACEHOLDER_ATTRIBUTE}] {
|
|
359
|
+
:is(:root,:host) [${PLACEHOLDER_ATTRIBUTE}] {
|
|
360
360
|
transition: none;
|
|
361
361
|
}
|
|
362
362
|
|
|
363
|
-
:root [${PLACEHOLDER_ATTRIBUTE}='hidden'] {
|
|
363
|
+
:is(:root,:host) [${PLACEHOLDER_ATTRIBUTE}='hidden'] {
|
|
364
364
|
visibility: hidden;
|
|
365
365
|
}
|
|
366
366
|
|
|
@@ -468,10 +468,11 @@ function isTableRow(element) {
|
|
|
468
468
|
|
|
469
469
|
// src/core/plugins/feedback/Feedback.ts
|
|
470
470
|
var styleSheetRegistry = /* @__PURE__ */ new Map();
|
|
471
|
-
var _overlay_dec, _a, _init, _overlay, _Feedback_instances, render_fn, injectStyles_fn;
|
|
472
|
-
var _Feedback = class _Feedback extends (_a = Plugin, _overlay_dec = [reactive], _a) {
|
|
471
|
+
var _roots_dec, _targetRoot_dec, _sourceRoot_dec, _overlay_dec, _a, _init, _overlay, _Feedback_instances, render_fn, injectStyles_fn;
|
|
472
|
+
var _Feedback = class _Feedback extends (_a = Plugin, _overlay_dec = [reactive], _sourceRoot_dec = [derived], _targetRoot_dec = [derived], _roots_dec = [derived], _a) {
|
|
473
473
|
constructor(manager, options) {
|
|
474
474
|
super(manager, options);
|
|
475
|
+
__runInitializers(_init, 5, this);
|
|
475
476
|
__privateAdd(this, _Feedback_instances);
|
|
476
477
|
__privateAdd(this, _overlay, __runInitializers(_init, 8, this)), __runInitializers(_init, 11, this);
|
|
477
478
|
this.state = {
|
|
@@ -481,14 +482,32 @@ var _Feedback = class _Feedback extends (_a = Plugin, _overlay_dec = [reactive],
|
|
|
481
482
|
this.registerEffect(__privateMethod(this, _Feedback_instances, injectStyles_fn));
|
|
482
483
|
this.registerEffect(__privateMethod(this, _Feedback_instances, render_fn));
|
|
483
484
|
}
|
|
485
|
+
get sourceRoot() {
|
|
486
|
+
var _a4;
|
|
487
|
+
const { source } = this.manager.dragOperation;
|
|
488
|
+
return getRoot((_a4 = source == null ? void 0 : source.element) != null ? _a4 : null);
|
|
489
|
+
}
|
|
490
|
+
get targetRoot() {
|
|
491
|
+
var _a4;
|
|
492
|
+
const { target } = this.manager.dragOperation;
|
|
493
|
+
return getRoot((_a4 = target == null ? void 0 : target.element) != null ? _a4 : null);
|
|
494
|
+
}
|
|
495
|
+
get roots() {
|
|
496
|
+
const { status } = this.manager.dragOperation;
|
|
497
|
+
if (status.initializing || status.initialized) {
|
|
498
|
+
const roots = [this.sourceRoot, this.targetRoot].filter((root) => root != null);
|
|
499
|
+
return new Set(roots);
|
|
500
|
+
}
|
|
501
|
+
return /* @__PURE__ */ new Set();
|
|
502
|
+
}
|
|
484
503
|
destroy() {
|
|
485
504
|
super.destroy();
|
|
486
|
-
for (const [
|
|
505
|
+
for (const [root, registration] of styleSheetRegistry.entries()) {
|
|
487
506
|
if (registration.instances.has(this)) {
|
|
488
507
|
registration.instances.delete(this);
|
|
489
508
|
if (registration.instances.size === 0) {
|
|
490
509
|
registration.cleanup();
|
|
491
|
-
styleSheetRegistry.delete(
|
|
510
|
+
styleSheetRegistry.delete(root);
|
|
492
511
|
}
|
|
493
512
|
}
|
|
494
513
|
}
|
|
@@ -917,47 +936,45 @@ render_fn = function() {
|
|
|
917
936
|
};
|
|
918
937
|
};
|
|
919
938
|
injectStyles_fn = function() {
|
|
920
|
-
|
|
921
|
-
const
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
if (!
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
if (nonce) {
|
|
933
|
-
style.setAttribute("nonce", nonce);
|
|
939
|
+
const { roots } = this;
|
|
940
|
+
for (const root of roots) {
|
|
941
|
+
let registration = styleSheetRegistry.get(root);
|
|
942
|
+
if (!registration) {
|
|
943
|
+
if (!("adoptedStyleSheets" in root && Array.isArray(root.adoptedStyleSheets)) && process.env.NODE_ENV !== "production") {
|
|
944
|
+
console.error("Cannot inject styles: This browser doesn't support adoptedStyleSheets");
|
|
945
|
+
}
|
|
946
|
+
const targetWindow = isDocument(root) ? root.defaultView : root.ownerDocument.defaultView;
|
|
947
|
+
const { CSSStyleSheet } = targetWindow != null ? targetWindow : {};
|
|
948
|
+
if (!CSSStyleSheet) {
|
|
949
|
+
if (process.env.NODE_ENV !== "production") {
|
|
950
|
+
console.error("Cannot inject styles: CSSStyleSheet constructor not available");
|
|
934
951
|
}
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
952
|
+
continue;
|
|
953
|
+
}
|
|
954
|
+
const sheet = new CSSStyleSheet();
|
|
955
|
+
sheet.replaceSync(CSS_RULES);
|
|
956
|
+
root.adoptedStyleSheets.push(sheet);
|
|
957
|
+
registration = {
|
|
958
|
+
cleanup: () => {
|
|
959
|
+
var _a4;
|
|
960
|
+
if (isDocument(root) || isShadowRoot(root) && ((_a4 = root.host) == null ? void 0 : _a4.isConnected)) {
|
|
961
|
+
const index = root.adoptedStyleSheets.indexOf(sheet);
|
|
962
|
+
if (index != -1) {
|
|
963
|
+
root.adoptedStyleSheets.splice(index, 1);
|
|
943
964
|
}
|
|
944
965
|
}
|
|
945
|
-
}
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
mutationObserver.disconnect();
|
|
950
|
-
style.remove();
|
|
951
|
-
},
|
|
952
|
-
instances: /* @__PURE__ */ new Set()
|
|
953
|
-
};
|
|
954
|
-
styleSheetRegistry.set(doc, registration);
|
|
955
|
-
}
|
|
956
|
-
registration.instances.add(this);
|
|
966
|
+
},
|
|
967
|
+
instances: /* @__PURE__ */ new Set()
|
|
968
|
+
};
|
|
969
|
+
styleSheetRegistry.set(root, registration);
|
|
957
970
|
}
|
|
971
|
+
registration.instances.add(this);
|
|
958
972
|
}
|
|
959
973
|
};
|
|
960
974
|
__decorateElement(_init, 4, "overlay", _overlay_dec, _Feedback, _overlay);
|
|
975
|
+
__decorateElement(_init, 2, "sourceRoot", _sourceRoot_dec, _Feedback);
|
|
976
|
+
__decorateElement(_init, 2, "targetRoot", _targetRoot_dec, _Feedback);
|
|
977
|
+
__decorateElement(_init, 2, "roots", _roots_dec, _Feedback);
|
|
961
978
|
__decoratorMetadata(_init, _Feedback);
|
|
962
979
|
_Feedback.configure = configurator(_Feedback);
|
|
963
980
|
var Feedback = _Feedback;
|
|
@@ -1134,7 +1151,7 @@ var Scroller = class extends (_a3 = CorePlugin, _autoScrolling_dec = [reactive],
|
|
|
1134
1151
|
return null;
|
|
1135
1152
|
}
|
|
1136
1153
|
const element = getElementFromPoint(
|
|
1137
|
-
|
|
1154
|
+
getRoot(source == null ? void 0 : source.element),
|
|
1138
1155
|
position.current
|
|
1139
1156
|
);
|
|
1140
1157
|
if (element) {
|
|
@@ -1802,7 +1819,7 @@ var _PointerSensor = class _PointerSensor extends Sensor {
|
|
|
1802
1819
|
const ownerDocument = getDocument(event.target);
|
|
1803
1820
|
const pointerCaptureTarget = ownerDocument.body;
|
|
1804
1821
|
pointerCaptureTarget.setPointerCapture(event.pointerId);
|
|
1805
|
-
const listenerTargets = isElement(event.target) ? [event.target,
|
|
1822
|
+
const listenerTargets = isElement(event.target) ? [event.target, pointerCaptureTarget] : pointerCaptureTarget;
|
|
1806
1823
|
const unbind = this.listeners.bind(listenerTargets, [
|
|
1807
1824
|
{
|
|
1808
1825
|
// Prevent scrolling on touch devices
|