@zag-js/tooltip 0.0.0-dev-20230221113221 → 0.0.0-dev-20230222181847
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/dist/chunk-3LXHM7BW.mjs +17 -0
- package/dist/{chunk-YCQQKYLH.mjs → chunk-463EFHFN.mjs} +8 -124
- package/dist/{chunk-VTDFWXSY.mjs → chunk-W3OSVXCZ.mjs} +15 -20
- package/dist/index.js +32 -241
- package/dist/index.mjs +3 -3
- package/dist/tooltip.connect.d.ts +12 -0
- package/dist/tooltip.connect.js +19 -105
- package/dist/tooltip.connect.mjs +2 -2
- package/dist/tooltip.dom.d.ts +2 -2
- package/dist/tooltip.dom.js +3 -84
- package/dist/tooltip.dom.mjs +1 -1
- package/dist/tooltip.machine.js +16 -222
- package/dist/tooltip.machine.mjs +2 -2
- package/package.json +8 -6
- package/dist/chunk-DYQY5P2O.mjs +0 -111
package/dist/chunk-DYQY5P2O.mjs
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
// ../../utilities/dom/src/get-computed-style.ts
|
|
2
|
-
function getCache() {
|
|
3
|
-
const g = globalThis;
|
|
4
|
-
g.__styleCache = g.__styleCache || /* @__PURE__ */ new WeakMap();
|
|
5
|
-
return g.__styleCache;
|
|
6
|
-
}
|
|
7
|
-
function getComputedStyle(el) {
|
|
8
|
-
if (!el)
|
|
9
|
-
return {};
|
|
10
|
-
const cache = getCache();
|
|
11
|
-
let style = cache.get(el);
|
|
12
|
-
if (!style) {
|
|
13
|
-
const win = el?.ownerDocument.defaultView ?? window;
|
|
14
|
-
style = win.getComputedStyle(el);
|
|
15
|
-
cache.set(el, style);
|
|
16
|
-
}
|
|
17
|
-
return style;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// ../../utilities/dom/src/query.ts
|
|
21
|
-
function isDocument(el) {
|
|
22
|
-
return el.nodeType === Node.DOCUMENT_NODE;
|
|
23
|
-
}
|
|
24
|
-
function isWindow(value) {
|
|
25
|
-
return value?.toString() === "[object Window]";
|
|
26
|
-
}
|
|
27
|
-
function getDocument(el) {
|
|
28
|
-
if (isWindow(el))
|
|
29
|
-
return el.document;
|
|
30
|
-
if (isDocument(el))
|
|
31
|
-
return el;
|
|
32
|
-
return el?.ownerDocument ?? document;
|
|
33
|
-
}
|
|
34
|
-
function getWindow(el) {
|
|
35
|
-
return el?.ownerDocument.defaultView ?? window;
|
|
36
|
-
}
|
|
37
|
-
function getNodeName(node) {
|
|
38
|
-
return isWindow(node) ? "" : node?.localName ?? "";
|
|
39
|
-
}
|
|
40
|
-
function getParent(el) {
|
|
41
|
-
const doc = getDocument(el);
|
|
42
|
-
if (getNodeName(el) === "html")
|
|
43
|
-
return el;
|
|
44
|
-
return el.assignedSlot || el.parentElement || doc.documentElement;
|
|
45
|
-
}
|
|
46
|
-
function defineDomHelpers(helpers) {
|
|
47
|
-
const dom2 = {
|
|
48
|
-
getRootNode: (ctx) => ctx.getRootNode?.() ?? document,
|
|
49
|
-
getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
|
|
50
|
-
getWin: (ctx) => dom2.getDoc(ctx).defaultView ?? window,
|
|
51
|
-
getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
|
|
52
|
-
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id),
|
|
53
|
-
queryById: (ctx, id) => {
|
|
54
|
-
const el = dom2.getById(ctx, id);
|
|
55
|
-
if (!el)
|
|
56
|
-
throw new Error(`Element with id "${id}" not found.`);
|
|
57
|
-
return el;
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
return {
|
|
61
|
-
...dom2,
|
|
62
|
-
...helpers
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
function isHTMLElement(v) {
|
|
66
|
-
return typeof v === "object" && v?.nodeType === Node.ELEMENT_NODE && typeof v?.nodeName === "string";
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// ../../utilities/dom/src/scrollable.ts
|
|
70
|
-
function isScrollParent(el) {
|
|
71
|
-
const { overflow, overflowX, overflowY } = getComputedStyle(el);
|
|
72
|
-
return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
|
|
73
|
-
}
|
|
74
|
-
function getScrollParent(el) {
|
|
75
|
-
if (["html", "body", "#document"].includes(getNodeName(el))) {
|
|
76
|
-
return getDocument(el).body;
|
|
77
|
-
}
|
|
78
|
-
if (isHTMLElement(el) && isScrollParent(el)) {
|
|
79
|
-
return el;
|
|
80
|
-
}
|
|
81
|
-
return getScrollParent(getParent(el));
|
|
82
|
-
}
|
|
83
|
-
function getScrollParents(el, list = []) {
|
|
84
|
-
const scrollParent = getScrollParent(el);
|
|
85
|
-
const isBody = scrollParent === getDocument(el).body;
|
|
86
|
-
const win = getWindow(scrollParent);
|
|
87
|
-
const target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
|
|
88
|
-
const parents = list.concat(target);
|
|
89
|
-
if (isBody)
|
|
90
|
-
return parents;
|
|
91
|
-
return parents.concat(getScrollParents(getParent(target)));
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// src/tooltip.dom.ts
|
|
95
|
-
var dom = defineDomHelpers({
|
|
96
|
-
getTriggerId: (ctx) => ctx.ids?.trigger ?? `tooltip:${ctx.id}:trigger`,
|
|
97
|
-
getContentId: (ctx) => ctx.ids?.content ?? `tooltip:${ctx.id}:content`,
|
|
98
|
-
getArrowId: (ctx) => `tooltip:${ctx.id}:arrow`,
|
|
99
|
-
getPositionerId: (ctx) => `tooltip:${ctx.id}:popper`,
|
|
100
|
-
getTriggerEl: (ctx) => dom.getById(ctx, dom.getTriggerId(ctx)),
|
|
101
|
-
getContentEl: (ctx) => dom.getById(ctx, dom.getContentId(ctx)),
|
|
102
|
-
getPositionerEl: (ctx) => dom.getById(ctx, dom.getPositionerId(ctx)),
|
|
103
|
-
getArrowEl: (ctx) => dom.getById(ctx, dom.getArrowId(ctx)),
|
|
104
|
-
getScrollParent: (ctx) => getScrollParent(dom.getTriggerEl(ctx))
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
export {
|
|
108
|
-
isHTMLElement,
|
|
109
|
-
getScrollParents,
|
|
110
|
-
dom
|
|
111
|
-
};
|