@dnd-kit/dom 0.1.21 → 0.2.0-beta-20251026132120
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 +122 -74
- package/index.cjs.map +1 -1
- package/index.d.cts +104 -96
- package/index.d.ts +104 -96
- package/index.js +125 -78
- package/index.js.map +1 -1
- package/package.json +5 -5
- package/utilities.cjs +51 -9
- package/utilities.cjs.map +1 -1
- package/utilities.d.cts +16 -2
- package/utilities.d.ts +16 -2
- package/utilities.js +50 -10
- package/utilities.js.map +1 -1
package/utilities.d.ts
CHANGED
|
@@ -13,12 +13,26 @@ declare function getViewportBoundingRectangle(element: Element): BoundingRectang
|
|
|
13
13
|
|
|
14
14
|
declare function getVisibleBoundingRectangle(element: Element, boundingClientRect?: DOMRect, margin?: number): BoundingRectangle;
|
|
15
15
|
|
|
16
|
+
declare function getEventCoordinates(event: PointerEvent): Coordinates;
|
|
17
|
+
|
|
16
18
|
declare const canUseDOM: boolean;
|
|
17
19
|
|
|
18
20
|
declare function getDocument(target: Event['target'] | undefined): Document;
|
|
19
21
|
|
|
20
22
|
declare function getWindow(target: Event['target'] | null | undefined): typeof window;
|
|
21
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Recursively finds all same-origin Document objects:
|
|
26
|
+
* - the current document
|
|
27
|
+
* - any same-origin parent documents
|
|
28
|
+
* - any same-origin child documents (iframes, frames)
|
|
29
|
+
*
|
|
30
|
+
* @param rootDoc - The starting document (defaults to current document)
|
|
31
|
+
* @param seen - Internal set to prevent duplicate traversal
|
|
32
|
+
* @returns An array of all discovered same-origin Document objects
|
|
33
|
+
*/
|
|
34
|
+
declare function getDocuments(rootDoc?: Document, seen?: Set<Document>): Document[];
|
|
35
|
+
|
|
22
36
|
declare function isSafari(): boolean;
|
|
23
37
|
|
|
24
38
|
declare function cloneElement(element: Element): Element;
|
|
@@ -36,7 +50,7 @@ type EventListenerInput = EventListenerDescriptor[] | EventListenerDescriptor;
|
|
|
36
50
|
declare class Listeners {
|
|
37
51
|
private entries;
|
|
38
52
|
constructor();
|
|
39
|
-
bind(target: EventTarget, input: EventListenerInput): () => void;
|
|
53
|
+
bind(target: EventTarget | EventTarget[], input: EventListenerInput): () => void;
|
|
40
54
|
clear: () => void;
|
|
41
55
|
}
|
|
42
56
|
|
|
@@ -212,4 +226,4 @@ declare function getFrameElement(el: Element | undefined): Element | null | unde
|
|
|
212
226
|
|
|
213
227
|
declare function getFrameTransform(el: Element | undefined, boundary?: Element | null): Transform;
|
|
214
228
|
|
|
215
|
-
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, getElementFromPoint, getFinalKeyframe, getFirstScrollableAncestor, getFrameElement, getFrameTransform, getScrollableAncestors, getViewportBoundingRectangle, getVisibleBoundingRectangle, getWindow, hidePopover, inverseTransform, isDocumentScrollingElement, isElement, isHTMLElement, isKeyboardEvent, isKeyframeEffect, isPointerEvent, isSafari, isTextInput, parseTransform, parseTranslate, scheduler, scrollIntoViewIfNeeded, showPopover, supportsPopover, supportsStyle, supportsViewTransition, timeout };
|
|
229
|
+
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, isKeyboardEvent, isKeyframeEffect, isPointerEvent, isSafari, isTextInput, parseTransform, parseTranslate, scheduler, scrollIntoViewIfNeeded, showPopover, supportsPopover, supportsStyle, supportsViewTransition, timeout };
|
package/utilities.js
CHANGED
|
@@ -39,9 +39,6 @@ function getBoundingRectangle(element) {
|
|
|
39
39
|
return { width, height, top, left, bottom, right };
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
// src/utilities/execution-context/canUseDOM.ts
|
|
43
|
-
var canUseDOM = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
44
|
-
|
|
45
42
|
// src/utilities/type-guards/isWindow.ts
|
|
46
43
|
function isWindow(element) {
|
|
47
44
|
const elementString = Object.prototype.toString.call(element);
|
|
@@ -190,6 +187,46 @@ function getVisibleBoundingRectangle(element, boundingClientRect = element.getBo
|
|
|
190
187
|
return rect;
|
|
191
188
|
}
|
|
192
189
|
|
|
190
|
+
// src/utilities/coordinates/getEventCoordinates.ts
|
|
191
|
+
function getEventCoordinates(event) {
|
|
192
|
+
return {
|
|
193
|
+
x: event.clientX,
|
|
194
|
+
y: event.clientY
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// src/utilities/execution-context/canUseDOM.ts
|
|
199
|
+
var canUseDOM = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
200
|
+
|
|
201
|
+
// src/utilities/execution-context/getDocuments.ts
|
|
202
|
+
function getDocuments(rootDoc = document, seen = /* @__PURE__ */ new Set()) {
|
|
203
|
+
if (seen.has(rootDoc)) return [];
|
|
204
|
+
seen.add(rootDoc);
|
|
205
|
+
const docs = [rootDoc];
|
|
206
|
+
for (const frame of Array.from(
|
|
207
|
+
rootDoc.querySelectorAll("iframe, frame")
|
|
208
|
+
)) {
|
|
209
|
+
try {
|
|
210
|
+
const childDoc = frame.contentDocument;
|
|
211
|
+
if (childDoc && !seen.has(childDoc)) {
|
|
212
|
+
docs.push(...getDocuments(childDoc, seen));
|
|
213
|
+
}
|
|
214
|
+
} catch (e) {
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
try {
|
|
218
|
+
const win = rootDoc.defaultView;
|
|
219
|
+
if (win && win !== window.top) {
|
|
220
|
+
const parentWin = win.parent;
|
|
221
|
+
if (parentWin && parentWin.document && parentWin.document !== rootDoc) {
|
|
222
|
+
docs.push(...getDocuments(parentWin.document, seen));
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
} catch (e) {
|
|
226
|
+
}
|
|
227
|
+
return docs;
|
|
228
|
+
}
|
|
229
|
+
|
|
193
230
|
// src/utilities/execution-context/isSafari.ts
|
|
194
231
|
function isSafari() {
|
|
195
232
|
return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
@@ -260,14 +297,17 @@ var Listeners = class {
|
|
|
260
297
|
};
|
|
261
298
|
}
|
|
262
299
|
bind(target, input) {
|
|
300
|
+
const eventTargets = Array.isArray(target) ? target : [target];
|
|
263
301
|
const listeners = Array.isArray(input) ? input : [input];
|
|
264
302
|
const entries = [];
|
|
265
|
-
for (const
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
303
|
+
for (const target2 of eventTargets) {
|
|
304
|
+
for (const descriptor of listeners) {
|
|
305
|
+
const { type, listener, options } = descriptor;
|
|
306
|
+
const entry = [target2, descriptor];
|
|
307
|
+
target2.addEventListener(type, listener, options);
|
|
308
|
+
this.entries.add(entry);
|
|
309
|
+
entries.push(entry);
|
|
310
|
+
}
|
|
271
311
|
}
|
|
272
312
|
return function cleanup() {
|
|
273
313
|
for (const [target2, { type, listener, options }] of entries) {
|
|
@@ -1356,6 +1396,6 @@ function generateUniqueId(prefix) {
|
|
|
1356
1396
|
return `${prefix}-${id}`;
|
|
1357
1397
|
}
|
|
1358
1398
|
|
|
1359
|
-
export { DOMRectangle, Listeners, FrameObserver as PositionObserver, ProxiedElements, ResizeNotifier, Scheduler, ScrollDirection, Styles, animateTransform, canScroll, canUseDOM, cloneElement, computeTranslate, detectScrollIntent, generateUniqueId, getBoundingRectangle, getComputedStyles, getDocument, getElementFromPoint, getFinalKeyframe, getFirstScrollableAncestor, getFrameElement, getFrameTransform, getScrollableAncestors, getViewportBoundingRectangle, getVisibleBoundingRectangle, getWindow, hidePopover, inverseTransform, isDocumentScrollingElement, isElement, isHTMLElement, isKeyboardEvent, isKeyframeEffect, isPointerEvent, isSafari, isTextInput, parseTransform, parseTranslate, scheduler, scrollIntoViewIfNeeded, showPopover, supportsPopover, supportsStyle, supportsViewTransition, timeout };
|
|
1399
|
+
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, isKeyboardEvent, isKeyframeEffect, isPointerEvent, isSafari, isTextInput, parseTransform, parseTranslate, scheduler, scrollIntoViewIfNeeded, showPopover, supportsPopover, supportsStyle, supportsViewTransition, timeout };
|
|
1360
1400
|
//# sourceMappingURL=utilities.js.map
|
|
1361
1401
|
//# sourceMappingURL=utilities.js.map
|