@zag-js/tooltip 0.0.0-dev-20221018140542 → 0.0.0-dev-20221031083441
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/index.js +26 -16
- package/dist/index.mjs +26 -16
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -35,12 +35,13 @@ function getCache() {
|
|
|
35
35
|
return g.__styleCache;
|
|
36
36
|
}
|
|
37
37
|
function getComputedStyle(el) {
|
|
38
|
+
var _a;
|
|
38
39
|
if (!el)
|
|
39
40
|
return {};
|
|
40
41
|
const cache = getCache();
|
|
41
42
|
let style = cache.get(el);
|
|
42
43
|
if (!style) {
|
|
43
|
-
const win = (el == null ? void 0 : el.ownerDocument.defaultView)
|
|
44
|
+
const win = (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
|
|
44
45
|
style = win.getComputedStyle(el);
|
|
45
46
|
cache.set(el, style);
|
|
46
47
|
}
|
|
@@ -48,15 +49,16 @@ function getComputedStyle(el) {
|
|
|
48
49
|
}
|
|
49
50
|
var runIfFn = (v, ...a) => {
|
|
50
51
|
const res = typeof v === "function" ? v(...a) : v;
|
|
51
|
-
return res
|
|
52
|
+
return res != null ? res : void 0;
|
|
52
53
|
};
|
|
53
54
|
var isArray = (v) => Array.isArray(v);
|
|
54
55
|
var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
|
|
55
56
|
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
56
57
|
var isDom = () => typeof window !== "undefined";
|
|
57
58
|
function getPlatform() {
|
|
59
|
+
var _a;
|
|
58
60
|
const agent = navigator.userAgentData;
|
|
59
|
-
return (agent == null ? void 0 : agent.platform)
|
|
61
|
+
return (_a = agent == null ? void 0 : agent.platform) != null ? _a : navigator.platform;
|
|
60
62
|
}
|
|
61
63
|
var pt = (v) => isDom() && v.test(getPlatform());
|
|
62
64
|
var vn = (v) => isDom() && v.test(navigator.vendor);
|
|
@@ -69,17 +71,20 @@ function isWindow(value) {
|
|
|
69
71
|
return (value == null ? void 0 : value.toString()) === "[object Window]";
|
|
70
72
|
}
|
|
71
73
|
function getDocument(el) {
|
|
74
|
+
var _a;
|
|
72
75
|
if (isWindow(el))
|
|
73
76
|
return el.document;
|
|
74
77
|
if (isDocument(el))
|
|
75
78
|
return el;
|
|
76
|
-
return (el == null ? void 0 : el.ownerDocument)
|
|
79
|
+
return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
|
|
77
80
|
}
|
|
78
81
|
function getWindow(el) {
|
|
79
|
-
|
|
82
|
+
var _a;
|
|
83
|
+
return (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
|
|
80
84
|
}
|
|
81
85
|
function getNodeName(node) {
|
|
82
|
-
|
|
86
|
+
var _a;
|
|
87
|
+
return isWindow(node) ? "" : (_a = node == null ? void 0 : node.localName) != null ? _a : "";
|
|
83
88
|
}
|
|
84
89
|
function getParent(el) {
|
|
85
90
|
const doc = getDocument(el);
|
|
@@ -90,17 +95,20 @@ function getParent(el) {
|
|
|
90
95
|
function defineDomHelpers(helpers) {
|
|
91
96
|
const dom2 = {
|
|
92
97
|
getRootNode: (ctx) => {
|
|
93
|
-
var _a;
|
|
94
|
-
return ((_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx))
|
|
98
|
+
var _a, _b;
|
|
99
|
+
return (_b = (_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) != null ? _b : document;
|
|
95
100
|
},
|
|
96
101
|
getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
|
|
97
|
-
getWin: (ctx) =>
|
|
102
|
+
getWin: (ctx) => {
|
|
103
|
+
var _a;
|
|
104
|
+
return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
|
|
105
|
+
},
|
|
98
106
|
getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
|
|
99
107
|
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id),
|
|
100
108
|
createEmitter: (ctx, target) => {
|
|
101
109
|
const win = dom2.getWin(ctx);
|
|
102
110
|
return function emit(evt, detail, options) {
|
|
103
|
-
const { bubbles = true, cancelable, composed = true } = options
|
|
111
|
+
const { bubbles = true, cancelable, composed = true } = options != null ? options : {};
|
|
104
112
|
const eventName = `zag:${evt}`;
|
|
105
113
|
const init = { bubbles, cancelable, composed, detail };
|
|
106
114
|
const event = new win.CustomEvent(eventName, init);
|
|
@@ -147,7 +155,8 @@ function addDomEvent(target, eventName, handler, options) {
|
|
|
147
155
|
};
|
|
148
156
|
}
|
|
149
157
|
function addPointerEvent(target, event, listener, options) {
|
|
150
|
-
|
|
158
|
+
var _a;
|
|
159
|
+
const type = (_a = getEventName(event)) != null ? _a : event;
|
|
151
160
|
return addDomEvent(target, type, wrapHandler(listener, event === "pointerdown"), options);
|
|
152
161
|
}
|
|
153
162
|
function wrapHandler(fn, filter = false) {
|
|
@@ -158,7 +167,8 @@ function wrapHandler(fn, filter = false) {
|
|
|
158
167
|
}
|
|
159
168
|
function filterPrimaryPointer(fn) {
|
|
160
169
|
return (event) => {
|
|
161
|
-
|
|
170
|
+
var _a;
|
|
171
|
+
const win = (_a = event.view) != null ? _a : window;
|
|
162
172
|
const isMouseEvent2 = event instanceof win.MouseEvent;
|
|
163
173
|
const isPrimary = !isMouseEvent2 || isMouseEvent2 && event.button === 0;
|
|
164
174
|
if (isPrimary)
|
|
@@ -241,12 +251,12 @@ var import_popper = require("@zag-js/popper");
|
|
|
241
251
|
// src/tooltip.dom.ts
|
|
242
252
|
var dom = defineDomHelpers({
|
|
243
253
|
getTriggerId: (ctx) => {
|
|
244
|
-
var _a;
|
|
245
|
-
return ((_a = ctx.ids) == null ? void 0 : _a.trigger)
|
|
254
|
+
var _a, _b;
|
|
255
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.trigger) != null ? _b : `tooltip:${ctx.id}:trigger`;
|
|
246
256
|
},
|
|
247
257
|
getContentId: (ctx) => {
|
|
248
|
-
var _a;
|
|
249
|
-
return ((_a = ctx.ids) == null ? void 0 : _a.content)
|
|
258
|
+
var _a, _b;
|
|
259
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.content) != null ? _b : `tooltip:${ctx.id}:content`;
|
|
250
260
|
},
|
|
251
261
|
getArrowId: (ctx) => `tooltip:${ctx.id}:arrow`,
|
|
252
262
|
getPositionerId: (ctx) => `tooltip:${ctx.id}:popper`,
|
package/dist/index.mjs
CHANGED
|
@@ -8,12 +8,13 @@ function getCache() {
|
|
|
8
8
|
return g.__styleCache;
|
|
9
9
|
}
|
|
10
10
|
function getComputedStyle(el) {
|
|
11
|
+
var _a;
|
|
11
12
|
if (!el)
|
|
12
13
|
return {};
|
|
13
14
|
const cache = getCache();
|
|
14
15
|
let style = cache.get(el);
|
|
15
16
|
if (!style) {
|
|
16
|
-
const win = (el == null ? void 0 : el.ownerDocument.defaultView)
|
|
17
|
+
const win = (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
|
|
17
18
|
style = win.getComputedStyle(el);
|
|
18
19
|
cache.set(el, style);
|
|
19
20
|
}
|
|
@@ -21,15 +22,16 @@ function getComputedStyle(el) {
|
|
|
21
22
|
}
|
|
22
23
|
var runIfFn = (v, ...a) => {
|
|
23
24
|
const res = typeof v === "function" ? v(...a) : v;
|
|
24
|
-
return res
|
|
25
|
+
return res != null ? res : void 0;
|
|
25
26
|
};
|
|
26
27
|
var isArray = (v) => Array.isArray(v);
|
|
27
28
|
var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
|
|
28
29
|
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
29
30
|
var isDom = () => typeof window !== "undefined";
|
|
30
31
|
function getPlatform() {
|
|
32
|
+
var _a;
|
|
31
33
|
const agent = navigator.userAgentData;
|
|
32
|
-
return (agent == null ? void 0 : agent.platform)
|
|
34
|
+
return (_a = agent == null ? void 0 : agent.platform) != null ? _a : navigator.platform;
|
|
33
35
|
}
|
|
34
36
|
var pt = (v) => isDom() && v.test(getPlatform());
|
|
35
37
|
var vn = (v) => isDom() && v.test(navigator.vendor);
|
|
@@ -42,17 +44,20 @@ function isWindow(value) {
|
|
|
42
44
|
return (value == null ? void 0 : value.toString()) === "[object Window]";
|
|
43
45
|
}
|
|
44
46
|
function getDocument(el) {
|
|
47
|
+
var _a;
|
|
45
48
|
if (isWindow(el))
|
|
46
49
|
return el.document;
|
|
47
50
|
if (isDocument(el))
|
|
48
51
|
return el;
|
|
49
|
-
return (el == null ? void 0 : el.ownerDocument)
|
|
52
|
+
return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
|
|
50
53
|
}
|
|
51
54
|
function getWindow(el) {
|
|
52
|
-
|
|
55
|
+
var _a;
|
|
56
|
+
return (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
|
|
53
57
|
}
|
|
54
58
|
function getNodeName(node) {
|
|
55
|
-
|
|
59
|
+
var _a;
|
|
60
|
+
return isWindow(node) ? "" : (_a = node == null ? void 0 : node.localName) != null ? _a : "";
|
|
56
61
|
}
|
|
57
62
|
function getParent(el) {
|
|
58
63
|
const doc = getDocument(el);
|
|
@@ -63,17 +68,20 @@ function getParent(el) {
|
|
|
63
68
|
function defineDomHelpers(helpers) {
|
|
64
69
|
const dom2 = {
|
|
65
70
|
getRootNode: (ctx) => {
|
|
66
|
-
var _a;
|
|
67
|
-
return ((_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx))
|
|
71
|
+
var _a, _b;
|
|
72
|
+
return (_b = (_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) != null ? _b : document;
|
|
68
73
|
},
|
|
69
74
|
getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
|
|
70
|
-
getWin: (ctx) =>
|
|
75
|
+
getWin: (ctx) => {
|
|
76
|
+
var _a;
|
|
77
|
+
return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
|
|
78
|
+
},
|
|
71
79
|
getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
|
|
72
80
|
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id),
|
|
73
81
|
createEmitter: (ctx, target) => {
|
|
74
82
|
const win = dom2.getWin(ctx);
|
|
75
83
|
return function emit(evt, detail, options) {
|
|
76
|
-
const { bubbles = true, cancelable, composed = true } = options
|
|
84
|
+
const { bubbles = true, cancelable, composed = true } = options != null ? options : {};
|
|
77
85
|
const eventName = `zag:${evt}`;
|
|
78
86
|
const init = { bubbles, cancelable, composed, detail };
|
|
79
87
|
const event = new win.CustomEvent(eventName, init);
|
|
@@ -120,7 +128,8 @@ function addDomEvent(target, eventName, handler, options) {
|
|
|
120
128
|
};
|
|
121
129
|
}
|
|
122
130
|
function addPointerEvent(target, event, listener, options) {
|
|
123
|
-
|
|
131
|
+
var _a;
|
|
132
|
+
const type = (_a = getEventName(event)) != null ? _a : event;
|
|
124
133
|
return addDomEvent(target, type, wrapHandler(listener, event === "pointerdown"), options);
|
|
125
134
|
}
|
|
126
135
|
function wrapHandler(fn, filter = false) {
|
|
@@ -131,7 +140,8 @@ function wrapHandler(fn, filter = false) {
|
|
|
131
140
|
}
|
|
132
141
|
function filterPrimaryPointer(fn) {
|
|
133
142
|
return (event) => {
|
|
134
|
-
|
|
143
|
+
var _a;
|
|
144
|
+
const win = (_a = event.view) != null ? _a : window;
|
|
135
145
|
const isMouseEvent2 = event instanceof win.MouseEvent;
|
|
136
146
|
const isPrimary = !isMouseEvent2 || isMouseEvent2 && event.button === 0;
|
|
137
147
|
if (isPrimary)
|
|
@@ -214,12 +224,12 @@ import { getPlacementStyles } from "@zag-js/popper";
|
|
|
214
224
|
// src/tooltip.dom.ts
|
|
215
225
|
var dom = defineDomHelpers({
|
|
216
226
|
getTriggerId: (ctx) => {
|
|
217
|
-
var _a;
|
|
218
|
-
return ((_a = ctx.ids) == null ? void 0 : _a.trigger)
|
|
227
|
+
var _a, _b;
|
|
228
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.trigger) != null ? _b : `tooltip:${ctx.id}:trigger`;
|
|
219
229
|
},
|
|
220
230
|
getContentId: (ctx) => {
|
|
221
|
-
var _a;
|
|
222
|
-
return ((_a = ctx.ids) == null ? void 0 : _a.content)
|
|
231
|
+
var _a, _b;
|
|
232
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.content) != null ? _b : `tooltip:${ctx.id}:content`;
|
|
223
233
|
},
|
|
224
234
|
getArrowId: (ctx) => `tooltip:${ctx.id}:arrow`,
|
|
225
235
|
getPositionerId: (ctx) => `tooltip:${ctx.id}:popper`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/tooltip",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20221031083441",
|
|
4
4
|
"description": "Core logic for the tooltip widget implemented as a state machine",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@zag-js/core": "0.
|
|
33
|
-
"@zag-js/popper": "0.0.0-dev-
|
|
34
|
-
"@zag-js/types": "0.
|
|
32
|
+
"@zag-js/core": "0.0.0-dev-20221031083441",
|
|
33
|
+
"@zag-js/popper": "0.0.0-dev-20221031083441",
|
|
34
|
+
"@zag-js/types": "0.0.0-dev-20221031083441"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@zag-js/dom-utils": "0.0.0-dev-
|
|
38
|
-
"@zag-js/utils": "0.
|
|
37
|
+
"@zag-js/dom-utils": "0.0.0-dev-20221031083441",
|
|
38
|
+
"@zag-js/utils": "0.0.0-dev-20221031083441"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build-fast": "tsup src/index.ts --format=esm,cjs",
|