@dnd-kit/dom 0.2.3 → 0.2.4-beta-20260207150257
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/utilities.d.cts
CHANGED
|
@@ -35,9 +35,11 @@ declare function getDocuments(rootDoc?: Document, seen?: Set<Document>): Documen
|
|
|
35
35
|
|
|
36
36
|
declare function isSafari(): boolean;
|
|
37
37
|
|
|
38
|
+
declare function getRoot(target: Event['target'] | undefined): Document | ShadowRoot;
|
|
39
|
+
|
|
38
40
|
declare function cloneElement(element: Element): Element;
|
|
39
41
|
|
|
40
|
-
declare function getElementFromPoint(
|
|
42
|
+
declare function getElementFromPoint(root: Document | ShadowRoot, { x, y }: Coordinates): Element | null;
|
|
41
43
|
|
|
42
44
|
declare const ProxiedElements: WeakMap<Element, Element>;
|
|
43
45
|
|
|
@@ -97,6 +99,7 @@ declare function canScroll(scrollableElement: Element, by?: Coordinates): {
|
|
|
97
99
|
interface Options {
|
|
98
100
|
limit?: number;
|
|
99
101
|
excludeElement?: boolean;
|
|
102
|
+
escapeShadowDOM?: boolean;
|
|
100
103
|
}
|
|
101
104
|
declare function getScrollableAncestors(element: Node | null, options?: Options): Set<Element>;
|
|
102
105
|
declare function getFirstScrollableAncestor(node: Node | null): Element | null;
|
|
@@ -196,6 +199,8 @@ declare class Styles {
|
|
|
196
199
|
*/
|
|
197
200
|
declare function getComputedStyles(element: Element, cached?: boolean): CSSStyleDeclaration;
|
|
198
201
|
|
|
202
|
+
declare function isDocument(node: Node): node is Document;
|
|
203
|
+
|
|
199
204
|
declare function isElement(target: EventTarget | null): target is Element;
|
|
200
205
|
|
|
201
206
|
declare function isHTMLElement(node: Node | Window | null | undefined): node is HTMLElement;
|
|
@@ -206,6 +211,8 @@ declare function isKeyboardEvent(event: Event | null | undefined): event is Keyb
|
|
|
206
211
|
|
|
207
212
|
declare function isPointerEvent(event: Event | null | undefined): event is PointerEvent;
|
|
208
213
|
|
|
214
|
+
declare function isShadowRoot(target: EventTarget | null): target is ShadowRoot;
|
|
215
|
+
|
|
209
216
|
interface ViewTransition {
|
|
210
217
|
ready: Promise<void>;
|
|
211
218
|
updateCallbackDone: Promise<void>;
|
|
@@ -228,4 +235,4 @@ declare function getFrameElement(el: Element | undefined): Element | null | unde
|
|
|
228
235
|
|
|
229
236
|
declare function getFrameTransform(el: Element | undefined, boundary?: Element | null): Transform;
|
|
230
237
|
|
|
231
|
-
export { DOMRectangle, type DOMRectangleOptions, Listeners, FrameObserver as PositionObserver, ProxiedElements, ResizeNotifier, Scheduler, ScrollDirection, Styles, type Transform, animateTransform, canScroll, canUseDOM, cloneElement, computeTranslate, detectScrollIntent, generateUniqueId, getBoundingRectangle, getComputedStyles, getDocument, getDocuments, getElementFromPoint, getEventCoordinates, getFinalKeyframe, getFirstScrollableAncestor, getFrameElement, getFrameTransform, getScrollableAncestors, getViewportBoundingRectangle, getVisibleBoundingRectangle, getWindow, hidePopover, inverseTransform, isDocumentScrollingElement, isElement, isHTMLElement, isInteractiveElement, isKeyboardEvent, isKeyframeEffect, isPointerEvent, isSafari, isTextInput, parseTransform, parseTranslate, scheduler, scrollIntoViewIfNeeded, showPopover, supportsPopover, supportsStyle, supportsViewTransition, timeout };
|
|
238
|
+
export { DOMRectangle, type DOMRectangleOptions, Listeners, FrameObserver as PositionObserver, ProxiedElements, ResizeNotifier, Scheduler, ScrollDirection, Styles, type Transform, animateTransform, canScroll, canUseDOM, cloneElement, computeTranslate, detectScrollIntent, generateUniqueId, getBoundingRectangle, getComputedStyles, getDocument, getDocuments, getElementFromPoint, getEventCoordinates, getFinalKeyframe, getFirstScrollableAncestor, getFrameElement, getFrameTransform, getRoot, getScrollableAncestors, getViewportBoundingRectangle, getVisibleBoundingRectangle, getWindow, hidePopover, inverseTransform, isDocument, isDocumentScrollingElement, isElement, isHTMLElement, isInteractiveElement, isKeyboardEvent, isKeyframeEffect, isPointerEvent, isSafari, isShadowRoot, isTextInput, parseTransform, parseTranslate, scheduler, scrollIntoViewIfNeeded, showPopover, supportsPopover, supportsStyle, supportsViewTransition, timeout };
|
package/utilities.d.ts
CHANGED
|
@@ -35,9 +35,11 @@ declare function getDocuments(rootDoc?: Document, seen?: Set<Document>): Documen
|
|
|
35
35
|
|
|
36
36
|
declare function isSafari(): boolean;
|
|
37
37
|
|
|
38
|
+
declare function getRoot(target: Event['target'] | undefined): Document | ShadowRoot;
|
|
39
|
+
|
|
38
40
|
declare function cloneElement(element: Element): Element;
|
|
39
41
|
|
|
40
|
-
declare function getElementFromPoint(
|
|
42
|
+
declare function getElementFromPoint(root: Document | ShadowRoot, { x, y }: Coordinates): Element | null;
|
|
41
43
|
|
|
42
44
|
declare const ProxiedElements: WeakMap<Element, Element>;
|
|
43
45
|
|
|
@@ -97,6 +99,7 @@ declare function canScroll(scrollableElement: Element, by?: Coordinates): {
|
|
|
97
99
|
interface Options {
|
|
98
100
|
limit?: number;
|
|
99
101
|
excludeElement?: boolean;
|
|
102
|
+
escapeShadowDOM?: boolean;
|
|
100
103
|
}
|
|
101
104
|
declare function getScrollableAncestors(element: Node | null, options?: Options): Set<Element>;
|
|
102
105
|
declare function getFirstScrollableAncestor(node: Node | null): Element | null;
|
|
@@ -196,6 +199,8 @@ declare class Styles {
|
|
|
196
199
|
*/
|
|
197
200
|
declare function getComputedStyles(element: Element, cached?: boolean): CSSStyleDeclaration;
|
|
198
201
|
|
|
202
|
+
declare function isDocument(node: Node): node is Document;
|
|
203
|
+
|
|
199
204
|
declare function isElement(target: EventTarget | null): target is Element;
|
|
200
205
|
|
|
201
206
|
declare function isHTMLElement(node: Node | Window | null | undefined): node is HTMLElement;
|
|
@@ -206,6 +211,8 @@ declare function isKeyboardEvent(event: Event | null | undefined): event is Keyb
|
|
|
206
211
|
|
|
207
212
|
declare function isPointerEvent(event: Event | null | undefined): event is PointerEvent;
|
|
208
213
|
|
|
214
|
+
declare function isShadowRoot(target: EventTarget | null): target is ShadowRoot;
|
|
215
|
+
|
|
209
216
|
interface ViewTransition {
|
|
210
217
|
ready: Promise<void>;
|
|
211
218
|
updateCallbackDone: Promise<void>;
|
|
@@ -228,4 +235,4 @@ declare function getFrameElement(el: Element | undefined): Element | null | unde
|
|
|
228
235
|
|
|
229
236
|
declare function getFrameTransform(el: Element | undefined, boundary?: Element | null): Transform;
|
|
230
237
|
|
|
231
|
-
export { DOMRectangle, type DOMRectangleOptions, Listeners, FrameObserver as PositionObserver, ProxiedElements, ResizeNotifier, Scheduler, ScrollDirection, Styles, type Transform, animateTransform, canScroll, canUseDOM, cloneElement, computeTranslate, detectScrollIntent, generateUniqueId, getBoundingRectangle, getComputedStyles, getDocument, getDocuments, getElementFromPoint, getEventCoordinates, getFinalKeyframe, getFirstScrollableAncestor, getFrameElement, getFrameTransform, getScrollableAncestors, getViewportBoundingRectangle, getVisibleBoundingRectangle, getWindow, hidePopover, inverseTransform, isDocumentScrollingElement, isElement, isHTMLElement, isInteractiveElement, isKeyboardEvent, isKeyframeEffect, isPointerEvent, isSafari, isTextInput, parseTransform, parseTranslate, scheduler, scrollIntoViewIfNeeded, showPopover, supportsPopover, supportsStyle, supportsViewTransition, timeout };
|
|
238
|
+
export { DOMRectangle, type DOMRectangleOptions, Listeners, FrameObserver as PositionObserver, ProxiedElements, ResizeNotifier, Scheduler, ScrollDirection, Styles, type Transform, animateTransform, canScroll, canUseDOM, cloneElement, computeTranslate, detectScrollIntent, generateUniqueId, getBoundingRectangle, getComputedStyles, getDocument, getDocuments, getElementFromPoint, getEventCoordinates, getFinalKeyframe, getFirstScrollableAncestor, getFrameElement, getFrameTransform, getRoot, getScrollableAncestors, getViewportBoundingRectangle, getVisibleBoundingRectangle, getWindow, hidePopover, inverseTransform, isDocument, isDocumentScrollingElement, isElement, isHTMLElement, isInteractiveElement, isKeyboardEvent, isKeyframeEffect, isPointerEvent, isSafari, isShadowRoot, isTextInput, parseTransform, parseTranslate, scheduler, scrollIntoViewIfNeeded, showPopover, supportsPopover, supportsStyle, supportsViewTransition, timeout };
|
package/utilities.js
CHANGED
|
@@ -71,8 +71,8 @@ function getWindow(target) {
|
|
|
71
71
|
|
|
72
72
|
// src/utilities/type-guards/isDocument.ts
|
|
73
73
|
function isDocument(node) {
|
|
74
|
-
const { Document } = getWindow(node);
|
|
75
|
-
return node instanceof
|
|
74
|
+
const { Document: Document2 } = getWindow(node);
|
|
75
|
+
return node instanceof Document2 || "nodeType" in node && node.nodeType === Node.DOCUMENT_NODE;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
// src/utilities/type-guards/isHTMLElement.ts
|
|
@@ -232,6 +232,25 @@ function isSafari() {
|
|
|
232
232
|
return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
233
233
|
}
|
|
234
234
|
|
|
235
|
+
// src/utilities/type-guards/isShadowRoot.ts
|
|
236
|
+
function isShadowRoot(target) {
|
|
237
|
+
if (!target || !isNode(target)) return false;
|
|
238
|
+
return target instanceof getWindow(target).ShadowRoot;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// src/utilities/execution-context/getRoot.ts
|
|
242
|
+
function getRoot(target) {
|
|
243
|
+
if (target && isNode(target)) {
|
|
244
|
+
let root = target.getRootNode();
|
|
245
|
+
if (isShadowRoot(root)) {
|
|
246
|
+
return root;
|
|
247
|
+
} else if (root instanceof Document) {
|
|
248
|
+
return root;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return getDocument(target);
|
|
252
|
+
}
|
|
253
|
+
|
|
235
254
|
// src/utilities/element/cloneElement.ts
|
|
236
255
|
function cloneElement(element) {
|
|
237
256
|
const selector = "input, textarea, select, canvas, [contenteditable]";
|
|
@@ -263,8 +282,8 @@ function isCanvasElement(element) {
|
|
|
263
282
|
}
|
|
264
283
|
|
|
265
284
|
// src/utilities/element/getElementFromPoint.ts
|
|
266
|
-
function getElementFromPoint(
|
|
267
|
-
const element =
|
|
285
|
+
function getElementFromPoint(root, { x, y }) {
|
|
286
|
+
const element = root.elementFromPoint(x, y);
|
|
268
287
|
if (isIFrameElement(element)) {
|
|
269
288
|
const { contentDocument } = element;
|
|
270
289
|
if (contentDocument) {
|
|
@@ -829,10 +848,11 @@ function isScrollable(element, computedStyle = getComputedStyles(element, true))
|
|
|
829
848
|
|
|
830
849
|
// src/utilities/scroll/getScrollableAncestors.ts
|
|
831
850
|
var defaultOptions = {
|
|
832
|
-
excludeElement: true
|
|
851
|
+
excludeElement: true,
|
|
852
|
+
escapeShadowDOM: true
|
|
833
853
|
};
|
|
834
854
|
function getScrollableAncestors(element, options = defaultOptions) {
|
|
835
|
-
const { limit, excludeElement } = options;
|
|
855
|
+
const { limit, excludeElement, escapeShadowDOM } = options;
|
|
836
856
|
const scrollParents = /* @__PURE__ */ new Set();
|
|
837
857
|
function findScrollableAncestors(node) {
|
|
838
858
|
if (limit != null && scrollParents.size >= limit) {
|
|
@@ -845,6 +865,9 @@ function getScrollableAncestors(element, options = defaultOptions) {
|
|
|
845
865
|
scrollParents.add(node.scrollingElement);
|
|
846
866
|
return scrollParents;
|
|
847
867
|
}
|
|
868
|
+
if (escapeShadowDOM && isShadowRoot(node)) {
|
|
869
|
+
return findScrollableAncestors(node.host);
|
|
870
|
+
}
|
|
848
871
|
if (!isHTMLElement(node)) {
|
|
849
872
|
if (isSVGElement(node)) {
|
|
850
873
|
return findScrollableAncestors(node.parentElement);
|
|
@@ -1410,6 +1433,6 @@ function generateUniqueId(prefix) {
|
|
|
1410
1433
|
return `${prefix}-${id}`;
|
|
1411
1434
|
}
|
|
1412
1435
|
|
|
1413
|
-
export { DOMRectangle, Listeners, FrameObserver as PositionObserver, ProxiedElements, ResizeNotifier, Scheduler, ScrollDirection, Styles, animateTransform, canScroll, canUseDOM, cloneElement, computeTranslate, detectScrollIntent, generateUniqueId, getBoundingRectangle, getComputedStyles, getDocument, getDocuments, getElementFromPoint, getEventCoordinates, getFinalKeyframe, getFirstScrollableAncestor, getFrameElement, getFrameTransform, getScrollableAncestors, getViewportBoundingRectangle, getVisibleBoundingRectangle, getWindow, hidePopover, inverseTransform, isDocumentScrollingElement, isElement, isHTMLElement, isInteractiveElement, isKeyboardEvent, isKeyframeEffect, isPointerEvent, isSafari, isTextInput, parseTransform, parseTranslate, scheduler, scrollIntoViewIfNeeded, showPopover, supportsPopover, supportsStyle, supportsViewTransition, timeout };
|
|
1436
|
+
export { DOMRectangle, Listeners, FrameObserver as PositionObserver, ProxiedElements, ResizeNotifier, Scheduler, ScrollDirection, Styles, animateTransform, canScroll, canUseDOM, cloneElement, computeTranslate, detectScrollIntent, generateUniqueId, getBoundingRectangle, getComputedStyles, getDocument, getDocuments, getElementFromPoint, getEventCoordinates, getFinalKeyframe, getFirstScrollableAncestor, getFrameElement, getFrameTransform, getRoot, getScrollableAncestors, getViewportBoundingRectangle, getVisibleBoundingRectangle, getWindow, hidePopover, inverseTransform, isDocument, isDocumentScrollingElement, isElement, isHTMLElement, isInteractiveElement, isKeyboardEvent, isKeyframeEffect, isPointerEvent, isSafari, isShadowRoot, isTextInput, parseTransform, parseTranslate, scheduler, scrollIntoViewIfNeeded, showPopover, supportsPopover, supportsStyle, supportsViewTransition, timeout };
|
|
1414
1437
|
//# sourceMappingURL=utilities.js.map
|
|
1415
1438
|
//# sourceMappingURL=utilities.js.map
|