@zag-js/tooltip 0.1.7 → 0.1.10
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.d.ts +0 -1
- package/dist/index.js +119 -229
- package/dist/index.mjs +118 -229
- package/dist/tooltip.connect.d.ts +3 -4
- package/dist/tooltip.dom.d.ts +17 -5
- package/dist/tooltip.machine.d.ts +2 -3
- package/dist/tooltip.store.d.ts +0 -1
- package/dist/tooltip.types.d.ts +4 -5
- package/package.json +8 -5
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -7
- package/dist/index.mjs.map +0 -7
- package/dist/tooltip.connect.d.ts.map +0 -1
- package/dist/tooltip.dom.d.ts.map +0 -1
- package/dist/tooltip.machine.d.ts.map +0 -1
- package/dist/tooltip.store.d.ts.map +0 -1
- package/dist/tooltip.types.d.ts.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -19,19 +19,35 @@ var __spreadValues = (a, b) => {
|
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
20
|
|
|
21
21
|
// ../../utilities/dom/dist/index.mjs
|
|
22
|
+
var __defProp2 = Object.defineProperty;
|
|
23
|
+
var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
|
|
24
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
25
|
+
var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
|
|
26
|
+
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
27
|
+
var __spreadValues2 = (a, b) => {
|
|
28
|
+
for (var prop in b || (b = {}))
|
|
29
|
+
if (__hasOwnProp2.call(b, prop))
|
|
30
|
+
__defNormalProp2(a, prop, b[prop]);
|
|
31
|
+
if (__getOwnPropSymbols2)
|
|
32
|
+
for (var prop of __getOwnPropSymbols2(b)) {
|
|
33
|
+
if (__propIsEnum2.call(b, prop))
|
|
34
|
+
__defNormalProp2(a, prop, b[prop]);
|
|
35
|
+
}
|
|
36
|
+
return a;
|
|
37
|
+
};
|
|
22
38
|
var dataAttr = (guard) => {
|
|
23
39
|
return guard ? "" : void 0;
|
|
24
40
|
};
|
|
25
|
-
function
|
|
26
|
-
;
|
|
27
|
-
|
|
28
|
-
return
|
|
41
|
+
function getCache() {
|
|
42
|
+
const g = globalThis;
|
|
43
|
+
g.__styleCache = g.__styleCache || /* @__PURE__ */ new WeakMap();
|
|
44
|
+
return g.__styleCache;
|
|
29
45
|
}
|
|
30
|
-
function
|
|
46
|
+
function getComputedStyle(el) {
|
|
31
47
|
var _a;
|
|
32
48
|
if (!el)
|
|
33
49
|
return {};
|
|
34
|
-
const cache =
|
|
50
|
+
const cache = getCache();
|
|
35
51
|
let style = cache.get(el);
|
|
36
52
|
if (!style) {
|
|
37
53
|
const win = (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
|
|
@@ -40,93 +56,78 @@ function getComputedStyle2(el) {
|
|
|
40
56
|
}
|
|
41
57
|
return style;
|
|
42
58
|
}
|
|
43
|
-
function raf(fn) {
|
|
44
|
-
const id = globalThis.requestAnimationFrame(fn);
|
|
45
|
-
return function cleanup() {
|
|
46
|
-
globalThis.cancelAnimationFrame(id);
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
var isDom = () => typeof window !== "undefined";
|
|
50
|
-
var isArray = (v) => Array.isArray(v);
|
|
51
|
-
var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
|
|
52
|
-
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
53
|
-
var isTouchDevice = isDom() && !!navigator.maxTouchPoints;
|
|
54
|
-
var supportsPointerEvent = () => isDom() && window.onpointerdown === null;
|
|
55
|
-
var supportsTouchEvent = () => isDom() && window.ontouchstart === null;
|
|
56
|
-
var supportsMouseEvent = () => isDom() && window.onmousedown === null;
|
|
57
|
-
var isTouchEvent = (v) => isObject(v) && hasProp(v, "touches");
|
|
58
59
|
var runIfFn = (v, ...a) => {
|
|
59
60
|
const res = typeof v === "function" ? v(...a) : v;
|
|
60
61
|
return res != null ? res : void 0;
|
|
61
62
|
};
|
|
62
|
-
var
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
var isArray = (v) => Array.isArray(v);
|
|
64
|
+
var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
|
|
65
|
+
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
66
|
+
var isDom = () => typeof window !== "undefined";
|
|
67
|
+
function getPlatform() {
|
|
68
|
+
var _a;
|
|
69
|
+
const agent = navigator.userAgentData;
|
|
70
|
+
return (_a = agent == null ? void 0 : agent.platform) != null ? _a : navigator.platform;
|
|
71
|
+
}
|
|
72
|
+
var pt = (v) => isDom() && v.test(getPlatform());
|
|
73
|
+
var vn = (v) => isDom() && v.test(navigator.vendor);
|
|
74
|
+
var isSafari = () => isApple() && vn(/apple/i);
|
|
75
|
+
var isApple = () => pt(/mac|iphone|ipad|ipod/i);
|
|
76
|
+
function isDocument(el) {
|
|
77
|
+
return el.nodeType === Node.DOCUMENT_NODE;
|
|
68
78
|
}
|
|
69
|
-
function
|
|
70
|
-
;
|
|
71
|
-
globalThis.__listenerCache__ = globalThis.__listenerCache__ || /* @__PURE__ */ new Map();
|
|
72
|
-
return globalThis.__listenerCache__;
|
|
79
|
+
function isWindow(value) {
|
|
80
|
+
return (value == null ? void 0 : value.toString()) === "[object Window]";
|
|
73
81
|
}
|
|
74
|
-
function
|
|
82
|
+
function getDocument(el) {
|
|
75
83
|
var _a;
|
|
76
|
-
if (
|
|
77
|
-
return
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
var _a2, _b, _c, _d;
|
|
110
|
-
if (!listenerElements.has(node))
|
|
111
|
-
return;
|
|
112
|
-
const group2 = listenerElements.get(node);
|
|
113
|
-
(_a2 = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _a2.delete(handler);
|
|
114
|
-
if (((_b = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _b.size) === 0) {
|
|
115
|
-
const listener = (_c = listenerCache.get(node)) == null ? void 0 : _c.get(hash);
|
|
116
|
-
node.removeEventListener(type, listener, options);
|
|
117
|
-
group2 == null ? void 0 : group2.delete(hash);
|
|
118
|
-
(_d = listenerCache.get(node)) == null ? void 0 : _d.delete(hash);
|
|
119
|
-
if ((group2 == null ? void 0 : group2.size) === 0) {
|
|
120
|
-
listenerElements.delete(node);
|
|
121
|
-
listenerCache.delete(node);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
84
|
+
if (isWindow(el))
|
|
85
|
+
return el.document;
|
|
86
|
+
if (isDocument(el))
|
|
87
|
+
return el;
|
|
88
|
+
return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
|
|
89
|
+
}
|
|
90
|
+
function getWindow(el) {
|
|
91
|
+
var _a;
|
|
92
|
+
return (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
|
|
93
|
+
}
|
|
94
|
+
function getNodeName(node) {
|
|
95
|
+
var _a;
|
|
96
|
+
return isWindow(node) ? "" : (_a = node == null ? void 0 : node.localName) != null ? _a : "";
|
|
97
|
+
}
|
|
98
|
+
function getParent(el) {
|
|
99
|
+
const doc = getDocument(el);
|
|
100
|
+
if (getNodeName(el) === "html")
|
|
101
|
+
return el;
|
|
102
|
+
return el.assignedSlot || el.parentElement || doc.documentElement;
|
|
103
|
+
}
|
|
104
|
+
function defineDomHelpers(helpers) {
|
|
105
|
+
const dom2 = {
|
|
106
|
+
getRootNode: (ctx) => {
|
|
107
|
+
var _a, _b;
|
|
108
|
+
return (_b = (_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) != null ? _b : document;
|
|
109
|
+
},
|
|
110
|
+
getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
|
|
111
|
+
getWin: (ctx) => {
|
|
112
|
+
var _a;
|
|
113
|
+
return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
|
|
114
|
+
},
|
|
115
|
+
getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
|
|
116
|
+
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
|
|
124
117
|
};
|
|
118
|
+
return __spreadValues2(__spreadValues2({}, dom2), helpers);
|
|
125
119
|
}
|
|
120
|
+
function isHTMLElement(v) {
|
|
121
|
+
return typeof v === "object" && (v == null ? void 0 : v.nodeType) === Node.ELEMENT_NODE && typeof (v == null ? void 0 : v.nodeName) === "string";
|
|
122
|
+
}
|
|
123
|
+
var supportsPointerEvent = () => isDom() && window.onpointerdown === null;
|
|
124
|
+
var supportsTouchEvent = () => isDom() && window.ontouchstart === null;
|
|
125
|
+
var supportsMouseEvent = () => isDom() && window.onmousedown === null;
|
|
126
|
+
var isTouchEvent = (v) => isObject(v) && hasProp(v, "touches");
|
|
126
127
|
var isRef = (v) => hasProp(v, "current");
|
|
127
|
-
var
|
|
128
|
+
var fallback2 = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
|
|
128
129
|
function extractInfo(event, type = "page") {
|
|
129
|
-
const point = isTouchEvent(event) ? event.touches[0] || event.changedTouches[0] ||
|
|
130
|
+
const point = isTouchEvent(event) ? event.touches[0] || event.changedTouches[0] || fallback2 : event;
|
|
130
131
|
return {
|
|
131
132
|
point: {
|
|
132
133
|
x: point[`${type}X`],
|
|
@@ -134,9 +135,12 @@ function extractInfo(event, type = "page") {
|
|
|
134
135
|
}
|
|
135
136
|
};
|
|
136
137
|
}
|
|
137
|
-
function addDomEvent(target,
|
|
138
|
+
function addDomEvent(target, eventName, handler, options) {
|
|
138
139
|
const node = isRef(target) ? target.current : runIfFn(target);
|
|
139
|
-
|
|
140
|
+
node == null ? void 0 : node.addEventListener(eventName, handler, options);
|
|
141
|
+
return () => {
|
|
142
|
+
node == null ? void 0 : node.removeEventListener(eventName, handler, options);
|
|
143
|
+
};
|
|
140
144
|
}
|
|
141
145
|
function addPointerEvent(target, event, listener, options) {
|
|
142
146
|
var _a;
|
|
@@ -184,77 +188,22 @@ function getEventName(evt) {
|
|
|
184
188
|
return mouseEventNames[evt];
|
|
185
189
|
return evt;
|
|
186
190
|
}
|
|
187
|
-
function
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}
|
|
193
|
-
function getOwnerWindow(el) {
|
|
194
|
-
var _a;
|
|
195
|
-
return (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
|
|
196
|
-
}
|
|
197
|
-
function getNodeName(node) {
|
|
198
|
-
return isWindow(node) ? "" : node ? node.localName || "" : "";
|
|
199
|
-
}
|
|
200
|
-
function getParent(el) {
|
|
201
|
-
const doc = getOwnerDocument(el);
|
|
202
|
-
if (getNodeName(el) === "html")
|
|
203
|
-
return el;
|
|
204
|
-
return el.assignedSlot || el.parentElement || doc.documentElement;
|
|
205
|
-
}
|
|
206
|
-
function isHTMLElement(v) {
|
|
207
|
-
return typeof v === "object" && (v == null ? void 0 : v.nodeType) === Node.ELEMENT_NODE && typeof (v == null ? void 0 : v.nodeName) === "string";
|
|
208
|
-
}
|
|
209
|
-
function isWindow(value) {
|
|
210
|
-
return (value == null ? void 0 : value.toString()) === "[object Window]";
|
|
211
|
-
}
|
|
212
|
-
var visuallyHiddenStyle = {
|
|
213
|
-
border: "0",
|
|
214
|
-
clip: "rect(0 0 0 0)",
|
|
215
|
-
height: "1px",
|
|
216
|
-
margin: "-1px",
|
|
217
|
-
overflow: "hidden",
|
|
218
|
-
padding: "0",
|
|
219
|
-
position: "absolute",
|
|
220
|
-
width: "1px",
|
|
221
|
-
whiteSpace: "nowrap",
|
|
222
|
-
wordWrap: "normal"
|
|
223
|
-
};
|
|
224
|
-
function itemById(v, id) {
|
|
225
|
-
return v.find((node) => node.id === id);
|
|
226
|
-
}
|
|
227
|
-
function indexOfId(v, id) {
|
|
228
|
-
const item = itemById(v, id);
|
|
229
|
-
return item ? v.indexOf(item) : -1;
|
|
230
|
-
}
|
|
231
|
-
var getValueText = (item) => {
|
|
232
|
-
var _a, _b;
|
|
233
|
-
return (_b = (_a = item.dataset.valuetext) != null ? _a : item.textContent) != null ? _b : "";
|
|
234
|
-
};
|
|
235
|
-
var match = (valueText, query2) => valueText.toLowerCase().startsWith(query2.toLowerCase());
|
|
236
|
-
var wrap = (v, idx) => {
|
|
237
|
-
return v.map((_, index) => v[(Math.max(idx, 0) + index) % v.length]);
|
|
238
|
-
};
|
|
239
|
-
function findByText(v, text, currentId) {
|
|
240
|
-
const index = currentId ? indexOfId(v, currentId) : -1;
|
|
241
|
-
let items = currentId ? wrap(v, index) : v;
|
|
242
|
-
const isSingleKey = text.length === 1;
|
|
243
|
-
if (isSingleKey) {
|
|
244
|
-
items = items.filter((item) => item.id !== currentId);
|
|
245
|
-
}
|
|
246
|
-
return items.find((item) => match(getValueText(item), text));
|
|
191
|
+
function raf(fn) {
|
|
192
|
+
const id = globalThis.requestAnimationFrame(fn);
|
|
193
|
+
return function cleanup() {
|
|
194
|
+
globalThis.cancelAnimationFrame(id);
|
|
195
|
+
};
|
|
247
196
|
}
|
|
248
197
|
function addPointerlockChangeListener(doc, fn) {
|
|
249
198
|
return addDomEvent(doc, "pointerlockchange", fn, false);
|
|
250
199
|
}
|
|
251
200
|
function isScrollParent(el) {
|
|
252
|
-
const { overflow, overflowX, overflowY } =
|
|
201
|
+
const { overflow, overflowX, overflowY } = getComputedStyle(el);
|
|
253
202
|
return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
|
|
254
203
|
}
|
|
255
204
|
function getScrollParent(el) {
|
|
256
205
|
if (["html", "body", "#document"].includes(getNodeName(el))) {
|
|
257
|
-
return
|
|
206
|
+
return getDocument(el).body;
|
|
258
207
|
}
|
|
259
208
|
if (isHTMLElement(el) && isScrollParent(el)) {
|
|
260
209
|
return el;
|
|
@@ -263,70 +212,32 @@ function getScrollParent(el) {
|
|
|
263
212
|
}
|
|
264
213
|
function getScrollParents(el, list = []) {
|
|
265
214
|
const scrollParent = getScrollParent(el);
|
|
266
|
-
const isBody = scrollParent ===
|
|
267
|
-
const win =
|
|
215
|
+
const isBody = scrollParent === getDocument(el).body;
|
|
216
|
+
const win = getWindow(scrollParent);
|
|
268
217
|
const target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
|
|
269
218
|
const parents = list.concat(target);
|
|
270
219
|
if (isBody)
|
|
271
220
|
return parents;
|
|
272
221
|
return parents.concat(getScrollParents(getParent(target)));
|
|
273
222
|
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
function update(value) {
|
|
286
|
-
state2.keysSoFar = value;
|
|
287
|
-
cleanup();
|
|
288
|
-
if (value !== "") {
|
|
289
|
-
state2.timer = +setTimeout(() => {
|
|
290
|
-
update("");
|
|
291
|
-
cleanup();
|
|
292
|
-
}, timeout);
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
update(search);
|
|
296
|
-
return next;
|
|
297
|
-
}
|
|
298
|
-
findByTypeahead.defaultOptions = {
|
|
299
|
-
keysSoFar: "",
|
|
300
|
-
timer: -1
|
|
223
|
+
var visuallyHiddenStyle = {
|
|
224
|
+
border: "0",
|
|
225
|
+
clip: "rect(0 0 0 0)",
|
|
226
|
+
height: "1px",
|
|
227
|
+
margin: "-1px",
|
|
228
|
+
overflow: "hidden",
|
|
229
|
+
padding: "0",
|
|
230
|
+
position: "absolute",
|
|
231
|
+
width: "1px",
|
|
232
|
+
whiteSpace: "nowrap",
|
|
233
|
+
wordWrap: "normal"
|
|
301
234
|
};
|
|
302
235
|
|
|
303
236
|
// src/tooltip.connect.ts
|
|
304
237
|
import { getPlacementStyles } from "@zag-js/popper";
|
|
305
238
|
|
|
306
|
-
// ../../types/dist/index.mjs
|
|
307
|
-
function createNormalizer(fn) {
|
|
308
|
-
return new Proxy({}, {
|
|
309
|
-
get() {
|
|
310
|
-
return fn;
|
|
311
|
-
}
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
var normalizeProp = createNormalizer((v) => v);
|
|
315
|
-
|
|
316
239
|
// src/tooltip.dom.ts
|
|
317
|
-
var dom = {
|
|
318
|
-
getDoc: (ctx) => {
|
|
319
|
-
var _a;
|
|
320
|
-
return (_a = ctx.doc) != null ? _a : document;
|
|
321
|
-
},
|
|
322
|
-
getWin: (ctx) => {
|
|
323
|
-
var _a, _b;
|
|
324
|
-
return (_b = (_a = ctx.doc) == null ? void 0 : _a.defaultView) != null ? _b : window;
|
|
325
|
-
},
|
|
326
|
-
getRootNode: (ctx) => {
|
|
327
|
-
var _a;
|
|
328
|
-
return (_a = ctx.rootNode) != null ? _a : dom.getDoc(ctx);
|
|
329
|
-
},
|
|
240
|
+
var dom = defineDomHelpers({
|
|
330
241
|
getTriggerId: (ctx) => {
|
|
331
242
|
var _a, _b;
|
|
332
243
|
return (_b = (_a = ctx.ids) == null ? void 0 : _a.trigger) != null ? _b : `tooltip:${ctx.id}:trigger`;
|
|
@@ -338,10 +249,10 @@ var dom = {
|
|
|
338
249
|
getArrowId: (ctx) => `tooltip:${ctx.id}:arrow`,
|
|
339
250
|
getPositionerId: (ctx) => `tooltip:${ctx.id}:popper`,
|
|
340
251
|
portalId: "tooltip-portal",
|
|
341
|
-
getTriggerEl: (ctx) => dom.
|
|
342
|
-
getContentEl: (ctx) => dom.
|
|
343
|
-
getPositionerEl: (ctx) => dom.
|
|
344
|
-
getArrowEl: (ctx) => dom.
|
|
252
|
+
getTriggerEl: (ctx) => dom.getById(ctx, dom.getTriggerId(ctx)),
|
|
253
|
+
getContentEl: (ctx) => dom.getById(ctx, dom.getContentId(ctx)),
|
|
254
|
+
getPositionerEl: (ctx) => dom.getById(ctx, dom.getPositionerId(ctx)),
|
|
255
|
+
getArrowEl: (ctx) => dom.getById(ctx, dom.getArrowId(ctx)),
|
|
345
256
|
getScrollParent: (ctx) => getScrollParent(dom.getTriggerEl(ctx)),
|
|
346
257
|
getPortalEl: (ctx) => dom.getDoc(ctx).getElementById(dom.portalId),
|
|
347
258
|
createPortalEl: (ctx) => {
|
|
@@ -349,7 +260,7 @@ var dom = {
|
|
|
349
260
|
portal.id = dom.portalId;
|
|
350
261
|
return portal;
|
|
351
262
|
}
|
|
352
|
-
};
|
|
263
|
+
});
|
|
353
264
|
|
|
354
265
|
// src/tooltip.store.ts
|
|
355
266
|
import { proxy } from "@zag-js/core";
|
|
@@ -363,7 +274,7 @@ var store = proxy({
|
|
|
363
274
|
});
|
|
364
275
|
|
|
365
276
|
// src/tooltip.connect.ts
|
|
366
|
-
function connect(state, send, normalize
|
|
277
|
+
function connect(state, send, normalize) {
|
|
367
278
|
const id = state.context.id;
|
|
368
279
|
const hasAriaLabel = state.context.hasAriaLabel;
|
|
369
280
|
const isOpen = state.hasTag("open");
|
|
@@ -469,29 +380,11 @@ function connect(state, send, normalize = normalizeProp) {
|
|
|
469
380
|
// src/tooltip.machine.ts
|
|
470
381
|
import { createMachine, ref, subscribe } from "@zag-js/core";
|
|
471
382
|
import { getPlacement } from "@zag-js/popper";
|
|
472
|
-
|
|
473
|
-
// ../../utilities/core/dist/index.mjs
|
|
474
|
-
var isDom2 = () => typeof window !== "undefined";
|
|
475
|
-
function getPlatform() {
|
|
476
|
-
var _a;
|
|
477
|
-
const agent = navigator.userAgentData;
|
|
478
|
-
return (_a = agent == null ? void 0 : agent.platform) != null ? _a : navigator.platform;
|
|
479
|
-
}
|
|
480
|
-
var pt = (v) => isDom2() && v.test(getPlatform());
|
|
481
|
-
var vn = (v) => isDom2() && v.test(navigator.vendor);
|
|
482
|
-
var isTouchDevice2 = isDom2() && !!navigator.maxTouchPoints;
|
|
483
|
-
var isSafari = () => isApple() && vn(/apple/i);
|
|
484
|
-
var isApple = () => pt(/mac|iphone|ipad|ipod/i);
|
|
485
|
-
var noop2 = () => {
|
|
486
|
-
};
|
|
487
|
-
|
|
488
|
-
// src/tooltip.machine.ts
|
|
489
|
-
function machine(ctx = {}) {
|
|
383
|
+
function machine(ctx) {
|
|
490
384
|
return createMachine({
|
|
491
385
|
id: "tooltip",
|
|
492
386
|
initial: "unknown",
|
|
493
387
|
context: __spreadProps(__spreadValues({
|
|
494
|
-
id: "",
|
|
495
388
|
openDelay: 1e3,
|
|
496
389
|
closeDelay: 500,
|
|
497
390
|
closeOnPointerDown: true,
|
|
@@ -513,10 +406,7 @@ function machine(ctx = {}) {
|
|
|
513
406
|
states: {
|
|
514
407
|
unknown: {
|
|
515
408
|
on: {
|
|
516
|
-
SETUP:
|
|
517
|
-
target: "closed",
|
|
518
|
-
actions: "setupDocument"
|
|
519
|
-
}
|
|
409
|
+
SETUP: "closed"
|
|
520
410
|
}
|
|
521
411
|
},
|
|
522
412
|
closed: {
|
|
@@ -644,7 +534,7 @@ function machine(ctx = {}) {
|
|
|
644
534
|
},
|
|
645
535
|
trackDisabledTriggerOnSafari(ctx2, _evt, { send }) {
|
|
646
536
|
if (!isSafari())
|
|
647
|
-
return
|
|
537
|
+
return;
|
|
648
538
|
const doc = dom.getDoc(ctx2);
|
|
649
539
|
return addPointerEvent(doc, "pointermove", (event) => {
|
|
650
540
|
const selector = "[data-part=trigger][data-expanded]";
|
|
@@ -711,4 +601,3 @@ export {
|
|
|
711
601
|
connect,
|
|
712
602
|
machine
|
|
713
603
|
};
|
|
714
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Send, State } from "./tooltip.types";
|
|
3
|
-
export declare function connect<T extends PropTypes
|
|
1
|
+
import type { NormalizeProps, PropTypes } from "@zag-js/types";
|
|
2
|
+
import type { Send, State } from "./tooltip.types";
|
|
3
|
+
export declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): {
|
|
4
4
|
isOpen: boolean;
|
|
5
5
|
open(): void;
|
|
6
6
|
close(): void;
|
|
@@ -16,4 +16,3 @@ export declare function connect<T extends PropTypes = ReactPropTypes>(state: Sta
|
|
|
16
16
|
labelProps: T["element"];
|
|
17
17
|
createPortal(): HTMLElement;
|
|
18
18
|
};
|
|
19
|
-
//# sourceMappingURL=tooltip.connect.d.ts.map
|
package/dist/tooltip.dom.d.ts
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
|
-
import { MachineContext as Ctx } from "./tooltip.types";
|
|
1
|
+
import type { MachineContext as Ctx } from "./tooltip.types";
|
|
2
2
|
export declare const dom: {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
getRootNode: (ctx: {
|
|
4
|
+
getRootNode?: () => Document | Node | ShadowRoot;
|
|
5
|
+
}) => Document | ShadowRoot;
|
|
6
|
+
getDoc: (ctx: {
|
|
7
|
+
getRootNode?: () => Document | Node | ShadowRoot;
|
|
8
|
+
}) => Document;
|
|
9
|
+
getWin: (ctx: {
|
|
10
|
+
getRootNode?: () => Document | Node | ShadowRoot;
|
|
11
|
+
}) => Window & typeof globalThis;
|
|
12
|
+
getActiveElement: (ctx: {
|
|
13
|
+
getRootNode?: () => Document | Node | ShadowRoot;
|
|
14
|
+
}) => HTMLElement;
|
|
15
|
+
getById: <T_1 = HTMLElement>(ctx: {
|
|
16
|
+
getRootNode?: () => Document | Node | ShadowRoot;
|
|
17
|
+
}, id: string) => T_1;
|
|
18
|
+
} & {
|
|
6
19
|
getTriggerId: (ctx: Ctx) => string;
|
|
7
20
|
getContentId: (ctx: Ctx) => string;
|
|
8
21
|
getArrowId: (ctx: Ctx) => string;
|
|
@@ -16,4 +29,3 @@ export declare const dom: {
|
|
|
16
29
|
getPortalEl: (ctx: Ctx) => HTMLElement;
|
|
17
30
|
createPortalEl: (ctx: Ctx) => HTMLElement;
|
|
18
31
|
};
|
|
19
|
-
//# sourceMappingURL=tooltip.dom.d.ts.map
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function machine(ctx
|
|
3
|
-
//# sourceMappingURL=tooltip.machine.d.ts.map
|
|
1
|
+
import type { MachineContext, MachineState, UserDefinedContext } from "./tooltip.types";
|
|
2
|
+
export declare function machine(ctx: UserDefinedContext): import("@zag-js/core").Machine<MachineContext, MachineState, import("@zag-js/core").StateMachine.AnyEventObject>;
|
package/dist/tooltip.store.d.ts
CHANGED
package/dist/tooltip.types.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { StateMachine as S } from "@zag-js/core";
|
|
2
|
-
import { Placement, PositioningOptions } from "@zag-js/popper";
|
|
3
|
-
import { RootProperties } from "@zag-js/types";
|
|
2
|
+
import type { Placement, PositioningOptions } from "@zag-js/popper";
|
|
3
|
+
import type { CommonProperties, RequiredBy, RootProperties } from "@zag-js/types";
|
|
4
4
|
declare type ElementIds = Partial<{
|
|
5
5
|
trigger: string;
|
|
6
6
|
content: string;
|
|
7
7
|
}>;
|
|
8
|
-
declare type PublicContext = {
|
|
8
|
+
declare type PublicContext = CommonProperties & {
|
|
9
9
|
/**
|
|
10
10
|
* The ids of the elements in the tooltip. Useful for composition.
|
|
11
11
|
*/
|
|
@@ -53,7 +53,7 @@ declare type PublicContext = {
|
|
|
53
53
|
*/
|
|
54
54
|
positioning: PositioningOptions;
|
|
55
55
|
};
|
|
56
|
-
export declare type UserDefinedContext =
|
|
56
|
+
export declare type UserDefinedContext = RequiredBy<PublicContext, "id">;
|
|
57
57
|
declare type ComputedContext = Readonly<{
|
|
58
58
|
/**
|
|
59
59
|
* @computed Whether an `aria-label` is set.
|
|
@@ -80,4 +80,3 @@ export declare type MachineState = {
|
|
|
80
80
|
export declare type State = S.State<MachineContext, MachineState>;
|
|
81
81
|
export declare type Send = S.Send<S.AnyEventObject>;
|
|
82
82
|
export {};
|
|
83
|
-
//# sourceMappingURL=tooltip.types.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/tooltip",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "Core logic for the tooltip widget implemented as a state machine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -29,10 +29,13 @@
|
|
|
29
29
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@zag-js/core": "0.1.
|
|
33
|
-
"@zag-js/
|
|
34
|
-
"@zag-js/
|
|
35
|
-
|
|
32
|
+
"@zag-js/core": "0.1.8",
|
|
33
|
+
"@zag-js/popper": "0.1.8",
|
|
34
|
+
"@zag-js/types": "0.2.2"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@zag-js/dom-utils": "0.1.7",
|
|
38
|
+
"@zag-js/utils": "0.1.2"
|
|
36
39
|
},
|
|
37
40
|
"scripts": {
|
|
38
41
|
"build:fast": "zag build",
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC3C,YAAY,EAAE,kBAAkB,IAAI,OAAO,EAAE,MAAM,iBAAiB,CAAA"}
|