@zag-js/tooltip 0.2.4 → 0.2.6
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-GQYNO326.mjs +14 -0
- package/dist/chunk-JWVFZJC7.mjs +359 -0
- package/dist/chunk-PFKIRGNP.mjs +146 -0
- package/dist/chunk-RRQRIZBA.mjs +9 -0
- package/dist/chunk-XZ6HXWV2.mjs +147 -0
- package/dist/index.d.ts +8 -946
- package/dist/index.js +36 -18
- package/dist/index.mjs +11 -619
- package/dist/tooltip.anatomy.d.ts +6 -0
- package/dist/tooltip.anatomy.js +34 -0
- package/dist/tooltip.anatomy.mjs +8 -0
- package/dist/tooltip.connect.d.ts +23 -0
- package/dist/tooltip.connect.js +308 -0
- package/dist/tooltip.connect.mjs +9 -0
- package/dist/tooltip.dom.d.ts +41 -0
- package/dist/tooltip.dom.js +156 -0
- package/dist/tooltip.dom.mjs +6 -0
- package/dist/tooltip.machine.d.ts +8 -0
- package/dist/tooltip.machine.js +528 -0
- package/dist/tooltip.machine.mjs +8 -0
- package/dist/tooltip.store.d.ts +9 -0
- package/dist/tooltip.store.js +38 -0
- package/dist/tooltip.store.mjs +6 -0
- package/dist/tooltip.types.d.ts +77 -0
- package/dist/tooltip.types.js +18 -0
- package/dist/tooltip.types.mjs +0 -0
- package/package.json +22 -12
package/dist/index.mjs
CHANGED
|
@@ -1,622 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
g.__styleCache = g.__styleCache || /* @__PURE__ */ new WeakMap();
|
|
13
|
-
return g.__styleCache;
|
|
14
|
-
}
|
|
15
|
-
function getComputedStyle(el) {
|
|
16
|
-
var _a;
|
|
17
|
-
if (!el)
|
|
18
|
-
return {};
|
|
19
|
-
const cache = getCache();
|
|
20
|
-
let style = cache.get(el);
|
|
21
|
-
if (!style) {
|
|
22
|
-
const win = (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
|
|
23
|
-
style = win.getComputedStyle(el);
|
|
24
|
-
cache.set(el, style);
|
|
25
|
-
}
|
|
26
|
-
return style;
|
|
27
|
-
}
|
|
28
|
-
var runIfFn = (v, ...a) => {
|
|
29
|
-
const res = typeof v === "function" ? v(...a) : v;
|
|
30
|
-
return res != null ? res : void 0;
|
|
31
|
-
};
|
|
32
|
-
var isArray = (v) => Array.isArray(v);
|
|
33
|
-
var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
|
|
34
|
-
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
35
|
-
var isDom = () => typeof window !== "undefined";
|
|
36
|
-
function getPlatform() {
|
|
37
|
-
var _a;
|
|
38
|
-
const agent = navigator.userAgentData;
|
|
39
|
-
return (_a = agent == null ? void 0 : agent.platform) != null ? _a : navigator.platform;
|
|
40
|
-
}
|
|
41
|
-
var pt = (v) => isDom() && v.test(getPlatform());
|
|
42
|
-
var vn = (v) => isDom() && v.test(navigator.vendor);
|
|
43
|
-
var isSafari = () => isApple() && vn(/apple/i);
|
|
44
|
-
var isApple = () => pt(/mac|iphone|ipad|ipod/i);
|
|
45
|
-
function isDocument(el) {
|
|
46
|
-
return el.nodeType === Node.DOCUMENT_NODE;
|
|
47
|
-
}
|
|
48
|
-
function isWindow(value) {
|
|
49
|
-
return (value == null ? void 0 : value.toString()) === "[object Window]";
|
|
50
|
-
}
|
|
51
|
-
function getDocument(el) {
|
|
52
|
-
var _a;
|
|
53
|
-
if (isWindow(el))
|
|
54
|
-
return el.document;
|
|
55
|
-
if (isDocument(el))
|
|
56
|
-
return el;
|
|
57
|
-
return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
|
|
58
|
-
}
|
|
59
|
-
function getWindow(el) {
|
|
60
|
-
var _a;
|
|
61
|
-
return (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
|
|
62
|
-
}
|
|
63
|
-
function getNodeName(node) {
|
|
64
|
-
var _a;
|
|
65
|
-
return isWindow(node) ? "" : (_a = node == null ? void 0 : node.localName) != null ? _a : "";
|
|
66
|
-
}
|
|
67
|
-
function getParent(el) {
|
|
68
|
-
const doc = getDocument(el);
|
|
69
|
-
if (getNodeName(el) === "html")
|
|
70
|
-
return el;
|
|
71
|
-
return el.assignedSlot || el.parentElement || doc.documentElement;
|
|
72
|
-
}
|
|
73
|
-
function defineDomHelpers(helpers) {
|
|
74
|
-
const dom2 = {
|
|
75
|
-
getRootNode: (ctx) => {
|
|
76
|
-
var _a, _b;
|
|
77
|
-
return (_b = (_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) != null ? _b : document;
|
|
78
|
-
},
|
|
79
|
-
getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
|
|
80
|
-
getWin: (ctx) => {
|
|
81
|
-
var _a;
|
|
82
|
-
return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
|
|
83
|
-
},
|
|
84
|
-
getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
|
|
85
|
-
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id),
|
|
86
|
-
createEmitter: (ctx, target) => {
|
|
87
|
-
const win = dom2.getWin(ctx);
|
|
88
|
-
return function emit(evt, detail, options) {
|
|
89
|
-
const { bubbles = true, cancelable, composed = true } = options != null ? options : {};
|
|
90
|
-
const eventName = `zag:${evt}`;
|
|
91
|
-
const init = { bubbles, cancelable, composed, detail };
|
|
92
|
-
const event = new win.CustomEvent(eventName, init);
|
|
93
|
-
target.dispatchEvent(event);
|
|
94
|
-
};
|
|
95
|
-
},
|
|
96
|
-
createListener: (target) => {
|
|
97
|
-
return function listen(evt, handler) {
|
|
98
|
-
const eventName = `zag:${evt}`;
|
|
99
|
-
const listener = (e) => handler(e);
|
|
100
|
-
target.addEventListener(eventName, listener);
|
|
101
|
-
return () => target.removeEventListener(eventName, listener);
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
return {
|
|
106
|
-
...dom2,
|
|
107
|
-
...helpers
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
function isHTMLElement(v) {
|
|
111
|
-
return typeof v === "object" && (v == null ? void 0 : v.nodeType) === Node.ELEMENT_NODE && typeof (v == null ? void 0 : v.nodeName) === "string";
|
|
112
|
-
}
|
|
113
|
-
var supportsPointerEvent = () => isDom() && window.onpointerdown === null;
|
|
114
|
-
var supportsTouchEvent = () => isDom() && window.ontouchstart === null;
|
|
115
|
-
var supportsMouseEvent = () => isDom() && window.onmousedown === null;
|
|
116
|
-
var isTouchEvent = (v) => isObject(v) && hasProp(v, "touches");
|
|
117
|
-
var isRef = (v) => hasProp(v, "current");
|
|
118
|
-
var fallback2 = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
|
|
119
|
-
function extractInfo(event, type = "page") {
|
|
120
|
-
const point = isTouchEvent(event) ? event.touches[0] || event.changedTouches[0] || fallback2 : event;
|
|
121
|
-
return {
|
|
122
|
-
point: {
|
|
123
|
-
x: point[`${type}X`],
|
|
124
|
-
y: point[`${type}Y`]
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
function addDomEvent(target, eventName, handler, options) {
|
|
129
|
-
const node = isRef(target) ? target.current : runIfFn(target);
|
|
130
|
-
node == null ? void 0 : node.addEventListener(eventName, handler, options);
|
|
131
|
-
return () => {
|
|
132
|
-
node == null ? void 0 : node.removeEventListener(eventName, handler, options);
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
function addPointerEvent(target, event, listener, options) {
|
|
136
|
-
var _a;
|
|
137
|
-
const type = (_a = getEventName(event)) != null ? _a : event;
|
|
138
|
-
return addDomEvent(target, type, wrapHandler(listener, event === "pointerdown"), options);
|
|
139
|
-
}
|
|
140
|
-
function wrapHandler(fn, filter = false) {
|
|
141
|
-
const listener = (event) => {
|
|
142
|
-
fn(event, extractInfo(event));
|
|
143
|
-
};
|
|
144
|
-
return filter ? filterPrimaryPointer(listener) : listener;
|
|
145
|
-
}
|
|
146
|
-
function filterPrimaryPointer(fn) {
|
|
147
|
-
return (event) => {
|
|
148
|
-
var _a;
|
|
149
|
-
const win = (_a = event.view) != null ? _a : window;
|
|
150
|
-
const isMouseEvent2 = event instanceof win.MouseEvent;
|
|
151
|
-
const isPrimary = !isMouseEvent2 || isMouseEvent2 && event.button === 0;
|
|
152
|
-
if (isPrimary)
|
|
153
|
-
fn(event);
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
var mouseEventNames = {
|
|
157
|
-
pointerdown: "mousedown",
|
|
158
|
-
pointermove: "mousemove",
|
|
159
|
-
pointerup: "mouseup",
|
|
160
|
-
pointercancel: "mousecancel",
|
|
161
|
-
pointerover: "mouseover",
|
|
162
|
-
pointerout: "mouseout",
|
|
163
|
-
pointerenter: "mouseenter",
|
|
164
|
-
pointerleave: "mouseleave"
|
|
165
|
-
};
|
|
166
|
-
var touchEventNames = {
|
|
167
|
-
pointerdown: "touchstart",
|
|
168
|
-
pointermove: "touchmove",
|
|
169
|
-
pointerup: "touchend",
|
|
170
|
-
pointercancel: "touchcancel"
|
|
171
|
-
};
|
|
172
|
-
function getEventName(evt) {
|
|
173
|
-
if (supportsPointerEvent())
|
|
174
|
-
return evt;
|
|
175
|
-
if (supportsTouchEvent())
|
|
176
|
-
return touchEventNames[evt];
|
|
177
|
-
if (supportsMouseEvent())
|
|
178
|
-
return mouseEventNames[evt];
|
|
179
|
-
return evt;
|
|
180
|
-
}
|
|
181
|
-
function raf(fn) {
|
|
182
|
-
const id = globalThis.requestAnimationFrame(fn);
|
|
183
|
-
return function cleanup() {
|
|
184
|
-
globalThis.cancelAnimationFrame(id);
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
function addPointerlockChangeListener(doc, fn) {
|
|
188
|
-
return addDomEvent(doc, "pointerlockchange", fn, false);
|
|
189
|
-
}
|
|
190
|
-
function isScrollParent(el) {
|
|
191
|
-
const { overflow, overflowX, overflowY } = getComputedStyle(el);
|
|
192
|
-
return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
|
|
193
|
-
}
|
|
194
|
-
function getScrollParent(el) {
|
|
195
|
-
if (["html", "body", "#document"].includes(getNodeName(el))) {
|
|
196
|
-
return getDocument(el).body;
|
|
197
|
-
}
|
|
198
|
-
if (isHTMLElement(el) && isScrollParent(el)) {
|
|
199
|
-
return el;
|
|
200
|
-
}
|
|
201
|
-
return getScrollParent(getParent(el));
|
|
202
|
-
}
|
|
203
|
-
function getScrollParents(el, list = []) {
|
|
204
|
-
const scrollParent = getScrollParent(el);
|
|
205
|
-
const isBody = scrollParent === getDocument(el).body;
|
|
206
|
-
const win = getWindow(scrollParent);
|
|
207
|
-
const target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
|
|
208
|
-
const parents = list.concat(target);
|
|
209
|
-
if (isBody)
|
|
210
|
-
return parents;
|
|
211
|
-
return parents.concat(getScrollParents(getParent(target)));
|
|
212
|
-
}
|
|
213
|
-
var visuallyHiddenStyle = {
|
|
214
|
-
border: "0",
|
|
215
|
-
clip: "rect(0 0 0 0)",
|
|
216
|
-
height: "1px",
|
|
217
|
-
margin: "-1px",
|
|
218
|
-
overflow: "hidden",
|
|
219
|
-
padding: "0",
|
|
220
|
-
position: "absolute",
|
|
221
|
-
width: "1px",
|
|
222
|
-
whiteSpace: "nowrap",
|
|
223
|
-
wordWrap: "normal"
|
|
224
|
-
};
|
|
225
|
-
|
|
226
|
-
// src/tooltip.connect.ts
|
|
227
|
-
import { getPlacementStyles } from "@zag-js/popper";
|
|
228
|
-
|
|
229
|
-
// src/tooltip.dom.ts
|
|
230
|
-
var dom = defineDomHelpers({
|
|
231
|
-
getTriggerId: (ctx) => {
|
|
232
|
-
var _a, _b;
|
|
233
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.trigger) != null ? _b : `tooltip:${ctx.id}:trigger`;
|
|
234
|
-
},
|
|
235
|
-
getContentId: (ctx) => {
|
|
236
|
-
var _a, _b;
|
|
237
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.content) != null ? _b : `tooltip:${ctx.id}:content`;
|
|
238
|
-
},
|
|
239
|
-
getArrowId: (ctx) => `tooltip:${ctx.id}:arrow`,
|
|
240
|
-
getPositionerId: (ctx) => `tooltip:${ctx.id}:popper`,
|
|
241
|
-
portalId: "tooltip-portal",
|
|
242
|
-
getTriggerEl: (ctx) => dom.getById(ctx, dom.getTriggerId(ctx)),
|
|
243
|
-
getContentEl: (ctx) => dom.getById(ctx, dom.getContentId(ctx)),
|
|
244
|
-
getPositionerEl: (ctx) => dom.getById(ctx, dom.getPositionerId(ctx)),
|
|
245
|
-
getArrowEl: (ctx) => dom.getById(ctx, dom.getArrowId(ctx)),
|
|
246
|
-
getScrollParent: (ctx) => getScrollParent(dom.getTriggerEl(ctx)),
|
|
247
|
-
getPortalEl: (ctx) => dom.getDoc(ctx).getElementById(dom.portalId),
|
|
248
|
-
createPortalEl: (ctx) => {
|
|
249
|
-
const portal = dom.getDoc(ctx).createElement(dom.portalId);
|
|
250
|
-
portal.id = dom.portalId;
|
|
251
|
-
return portal;
|
|
252
|
-
}
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
// src/tooltip.store.ts
|
|
256
|
-
import { proxy } from "@zag-js/core";
|
|
257
|
-
var store = proxy({
|
|
258
|
-
id: null,
|
|
259
|
-
prevId: null,
|
|
260
|
-
setId(val) {
|
|
261
|
-
this.prevId = this.id;
|
|
262
|
-
this.id = val;
|
|
263
|
-
}
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
// src/tooltip.connect.ts
|
|
267
|
-
function connect(state, send, normalize) {
|
|
268
|
-
const id = state.context.id;
|
|
269
|
-
const hasAriaLabel = state.context.hasAriaLabel;
|
|
270
|
-
const isOpen = state.hasTag("open");
|
|
271
|
-
const triggerId = dom.getTriggerId(state.context);
|
|
272
|
-
const contentId = dom.getContentId(state.context);
|
|
273
|
-
const isDisabled = state.context.disabled;
|
|
274
|
-
const popperStyles = getPlacementStyles({
|
|
275
|
-
measured: !!state.context.isPlacementComplete,
|
|
276
|
-
placement: state.context.currentPlacement
|
|
277
|
-
});
|
|
278
|
-
return {
|
|
279
|
-
isOpen,
|
|
280
|
-
open() {
|
|
281
|
-
send("OPEN");
|
|
282
|
-
},
|
|
283
|
-
close() {
|
|
284
|
-
send("CLOSE");
|
|
285
|
-
},
|
|
286
|
-
getAnimationState() {
|
|
287
|
-
return {
|
|
288
|
-
enter: store.prevId === null && id === store.id,
|
|
289
|
-
exit: store.id === null
|
|
290
|
-
};
|
|
291
|
-
},
|
|
292
|
-
triggerProps: normalize.button({
|
|
293
|
-
...parts.trigger.attrs,
|
|
294
|
-
id: triggerId,
|
|
295
|
-
"data-expanded": dataAttr(isOpen),
|
|
296
|
-
"aria-describedby": isOpen ? contentId : void 0,
|
|
297
|
-
onClick() {
|
|
298
|
-
send("CLICK");
|
|
299
|
-
},
|
|
300
|
-
onFocus() {
|
|
301
|
-
send("FOCUS");
|
|
302
|
-
},
|
|
303
|
-
onBlur() {
|
|
304
|
-
if (id === store.id) {
|
|
305
|
-
send("BLUR");
|
|
306
|
-
}
|
|
307
|
-
},
|
|
308
|
-
onPointerDown() {
|
|
309
|
-
if (isDisabled)
|
|
310
|
-
return;
|
|
311
|
-
if (id === store.id) {
|
|
312
|
-
send("POINTER_DOWN");
|
|
313
|
-
}
|
|
314
|
-
},
|
|
315
|
-
onPointerMove() {
|
|
316
|
-
if (isDisabled)
|
|
317
|
-
return;
|
|
318
|
-
send("POINTER_ENTER");
|
|
319
|
-
},
|
|
320
|
-
onPointerLeave() {
|
|
321
|
-
if (isDisabled)
|
|
322
|
-
return;
|
|
323
|
-
send("POINTER_LEAVE");
|
|
324
|
-
},
|
|
325
|
-
onPointerCancel() {
|
|
326
|
-
if (isDisabled)
|
|
327
|
-
return;
|
|
328
|
-
send("POINTER_LEAVE");
|
|
329
|
-
}
|
|
330
|
-
}),
|
|
331
|
-
arrowProps: normalize.element({
|
|
332
|
-
id: dom.getArrowId(state.context),
|
|
333
|
-
...parts.arrow.attrs,
|
|
334
|
-
style: popperStyles.arrow
|
|
335
|
-
}),
|
|
336
|
-
arrowTipProps: normalize.element({
|
|
337
|
-
...parts.arrowTip.attrs,
|
|
338
|
-
style: popperStyles.arrowTip
|
|
339
|
-
}),
|
|
340
|
-
positionerProps: normalize.element({
|
|
341
|
-
id: dom.getPositionerId(state.context),
|
|
342
|
-
...parts.positioner.attrs,
|
|
343
|
-
style: popperStyles.floating
|
|
344
|
-
}),
|
|
345
|
-
contentProps: normalize.element({
|
|
346
|
-
...parts.content.attrs,
|
|
347
|
-
hidden: !isOpen,
|
|
348
|
-
role: hasAriaLabel ? void 0 : "tooltip",
|
|
349
|
-
id: hasAriaLabel ? void 0 : contentId,
|
|
350
|
-
"data-placement": state.context.currentPlacement,
|
|
351
|
-
onPointerEnter() {
|
|
352
|
-
send("TOOLTIP_POINTER_ENTER");
|
|
353
|
-
},
|
|
354
|
-
onPointerLeave() {
|
|
355
|
-
send("TOOLTIP_POINTER_LEAVE");
|
|
356
|
-
},
|
|
357
|
-
style: {
|
|
358
|
-
pointerEvents: state.context.interactive ? "auto" : "none"
|
|
359
|
-
}
|
|
360
|
-
}),
|
|
361
|
-
labelProps: normalize.element({
|
|
362
|
-
...parts.label.attrs,
|
|
363
|
-
id: contentId,
|
|
364
|
-
role: "tooltip",
|
|
365
|
-
style: visuallyHiddenStyle,
|
|
366
|
-
children: state.context["aria-label"]
|
|
367
|
-
}),
|
|
368
|
-
createPortal() {
|
|
369
|
-
const doc = dom.getDoc(state.context);
|
|
370
|
-
const exist = dom.getPortalEl(state.context);
|
|
371
|
-
if (exist)
|
|
372
|
-
return exist;
|
|
373
|
-
const portal = dom.createPortalEl(state.context);
|
|
374
|
-
doc.body.appendChild(portal);
|
|
375
|
-
return portal;
|
|
376
|
-
}
|
|
377
|
-
};
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
// src/tooltip.machine.ts
|
|
381
|
-
import { createMachine, subscribe } from "@zag-js/core";
|
|
382
|
-
import { getPlacement } from "@zag-js/popper";
|
|
383
|
-
|
|
384
|
-
// ../../utilities/core/dist/index.mjs
|
|
385
|
-
var isArray2 = (v) => Array.isArray(v);
|
|
386
|
-
var isObject2 = (v) => !(v == null || typeof v !== "object" || isArray2(v));
|
|
387
|
-
function compact(obj) {
|
|
388
|
-
if (obj === void 0)
|
|
389
|
-
return obj;
|
|
390
|
-
return Object.fromEntries(
|
|
391
|
-
Object.entries(obj).filter(([, value]) => value !== void 0).map(([key, value]) => [key, isObject2(value) ? compact(value) : value])
|
|
392
|
-
);
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
// src/tooltip.machine.ts
|
|
396
|
-
function machine(userContext) {
|
|
397
|
-
const ctx = compact(userContext);
|
|
398
|
-
return createMachine(
|
|
399
|
-
{
|
|
400
|
-
id: "tooltip",
|
|
401
|
-
initial: "unknown",
|
|
402
|
-
context: {
|
|
403
|
-
openDelay: 1e3,
|
|
404
|
-
closeDelay: 500,
|
|
405
|
-
closeOnPointerDown: true,
|
|
406
|
-
closeOnEsc: true,
|
|
407
|
-
interactive: true,
|
|
408
|
-
currentPlacement: void 0,
|
|
409
|
-
...ctx,
|
|
410
|
-
positioning: {
|
|
411
|
-
placement: "bottom",
|
|
412
|
-
...ctx.positioning
|
|
413
|
-
}
|
|
414
|
-
},
|
|
415
|
-
computed: {
|
|
416
|
-
hasAriaLabel: (ctx2) => !!ctx2["aria-label"]
|
|
417
|
-
},
|
|
418
|
-
watch: {
|
|
419
|
-
disabled: ["closeIfDisabled"]
|
|
420
|
-
},
|
|
421
|
-
on: {
|
|
422
|
-
OPEN: "open",
|
|
423
|
-
CLOSE: "closed"
|
|
424
|
-
},
|
|
425
|
-
states: {
|
|
426
|
-
unknown: {
|
|
427
|
-
on: {
|
|
428
|
-
SETUP: "closed"
|
|
429
|
-
}
|
|
430
|
-
},
|
|
431
|
-
closed: {
|
|
432
|
-
tags: ["closed"],
|
|
433
|
-
entry: ["clearGlobalId", "invokeOnClose"],
|
|
434
|
-
on: {
|
|
435
|
-
FOCUS: "open",
|
|
436
|
-
POINTER_ENTER: [
|
|
437
|
-
{
|
|
438
|
-
guard: "noVisibleTooltip",
|
|
439
|
-
target: "opening"
|
|
440
|
-
},
|
|
441
|
-
{ target: "open" }
|
|
442
|
-
]
|
|
443
|
-
}
|
|
444
|
-
},
|
|
445
|
-
opening: {
|
|
446
|
-
tags: ["closed"],
|
|
447
|
-
activities: ["trackScroll", "trackPointerlockChange"],
|
|
448
|
-
after: {
|
|
449
|
-
OPEN_DELAY: "open"
|
|
450
|
-
},
|
|
451
|
-
on: {
|
|
452
|
-
POINTER_LEAVE: "closed",
|
|
453
|
-
BLUR: "closed",
|
|
454
|
-
SCROLL: "closed",
|
|
455
|
-
POINTER_LOCK_CHANGE: "closed",
|
|
456
|
-
POINTER_DOWN: {
|
|
457
|
-
guard: "closeOnPointerDown",
|
|
458
|
-
target: "closed"
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
},
|
|
462
|
-
open: {
|
|
463
|
-
tags: ["open"],
|
|
464
|
-
activities: [
|
|
465
|
-
"trackEscapeKey",
|
|
466
|
-
"trackDisabledTriggerOnSafari",
|
|
467
|
-
"trackScroll",
|
|
468
|
-
"trackPointerlockChange",
|
|
469
|
-
"computePlacement"
|
|
470
|
-
],
|
|
471
|
-
entry: ["setGlobalId", "invokeOnOpen"],
|
|
472
|
-
on: {
|
|
473
|
-
POINTER_LEAVE: [
|
|
474
|
-
{
|
|
475
|
-
guard: "isVisible",
|
|
476
|
-
target: "closing"
|
|
477
|
-
},
|
|
478
|
-
{ target: "closed" }
|
|
479
|
-
],
|
|
480
|
-
BLUR: "closed",
|
|
481
|
-
ESCAPE: "closed",
|
|
482
|
-
SCROLL: "closed",
|
|
483
|
-
POINTER_LOCK_CHANGE: "closed",
|
|
484
|
-
TOOLTIP_POINTER_LEAVE: {
|
|
485
|
-
guard: "isInteractive",
|
|
486
|
-
target: "closing"
|
|
487
|
-
},
|
|
488
|
-
POINTER_DOWN: {
|
|
489
|
-
guard: "closeOnPointerDown",
|
|
490
|
-
target: "closed"
|
|
491
|
-
},
|
|
492
|
-
CLICK: "closed"
|
|
493
|
-
}
|
|
494
|
-
},
|
|
495
|
-
closing: {
|
|
496
|
-
tags: ["open"],
|
|
497
|
-
activities: ["trackStore", "computePlacement"],
|
|
498
|
-
after: {
|
|
499
|
-
CLOSE_DELAY: "closed"
|
|
500
|
-
},
|
|
501
|
-
on: {
|
|
502
|
-
FORCE_CLOSE: "closed",
|
|
503
|
-
POINTER_ENTER: "open",
|
|
504
|
-
TOOLTIP_POINTER_ENTER: {
|
|
505
|
-
guard: "isInteractive",
|
|
506
|
-
target: "open"
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
},
|
|
512
|
-
{
|
|
513
|
-
activities: {
|
|
514
|
-
computePlacement(ctx2) {
|
|
515
|
-
ctx2.currentPlacement = ctx2.positioning.placement;
|
|
516
|
-
let cleanup;
|
|
517
|
-
raf(() => {
|
|
518
|
-
cleanup = getPlacement(dom.getTriggerEl(ctx2), dom.getPositionerEl(ctx2), {
|
|
519
|
-
...ctx2.positioning,
|
|
520
|
-
onComplete(data) {
|
|
521
|
-
ctx2.currentPlacement = data.placement;
|
|
522
|
-
ctx2.isPlacementComplete = true;
|
|
523
|
-
},
|
|
524
|
-
onCleanup() {
|
|
525
|
-
ctx2.currentPlacement = void 0;
|
|
526
|
-
ctx2.isPlacementComplete = false;
|
|
527
|
-
}
|
|
528
|
-
});
|
|
529
|
-
});
|
|
530
|
-
return cleanup;
|
|
531
|
-
},
|
|
532
|
-
trackPointerlockChange(ctx2, _evt, { send }) {
|
|
533
|
-
return addPointerlockChangeListener(dom.getDoc(ctx2), () => {
|
|
534
|
-
send("POINTER_LOCK_CHANGE");
|
|
535
|
-
});
|
|
536
|
-
},
|
|
537
|
-
trackScroll(ctx2, _evt, { send }) {
|
|
538
|
-
const trigger = dom.getTriggerEl(ctx2);
|
|
539
|
-
if (!trigger)
|
|
540
|
-
return;
|
|
541
|
-
const cleanups = getScrollParents(trigger).map((el) => {
|
|
542
|
-
const opts = { passive: true, capture: true };
|
|
543
|
-
return addDomEvent(el, "scroll", () => send("SCROLL"), opts);
|
|
544
|
-
});
|
|
545
|
-
return () => {
|
|
546
|
-
cleanups.forEach((fn) => fn == null ? void 0 : fn());
|
|
547
|
-
};
|
|
548
|
-
},
|
|
549
|
-
trackStore(ctx2, _evt, { send }) {
|
|
550
|
-
return subscribe(store, () => {
|
|
551
|
-
if (store.id !== ctx2.id) {
|
|
552
|
-
send("FORCE_CLOSE");
|
|
553
|
-
}
|
|
554
|
-
});
|
|
555
|
-
},
|
|
556
|
-
trackDisabledTriggerOnSafari(ctx2, _evt, { send }) {
|
|
557
|
-
if (!isSafari())
|
|
558
|
-
return;
|
|
559
|
-
const doc = dom.getDoc(ctx2);
|
|
560
|
-
return addPointerEvent(doc, "pointermove", (event) => {
|
|
561
|
-
const selector = "[data-part=trigger][data-expanded]";
|
|
562
|
-
if (isHTMLElement(event.target) && event.target.closest(selector))
|
|
563
|
-
return;
|
|
564
|
-
send("POINTER_LEAVE");
|
|
565
|
-
});
|
|
566
|
-
},
|
|
567
|
-
trackEscapeKey(ctx2, _evt, { send }) {
|
|
568
|
-
if (!ctx2.closeOnEsc)
|
|
569
|
-
return;
|
|
570
|
-
const doc = dom.getDoc(ctx2);
|
|
571
|
-
return addDomEvent(doc, "keydown", (event) => {
|
|
572
|
-
if (event.key === "Escape") {
|
|
573
|
-
send("ESCAPE");
|
|
574
|
-
}
|
|
575
|
-
});
|
|
576
|
-
}
|
|
577
|
-
},
|
|
578
|
-
actions: {
|
|
579
|
-
setGlobalId(ctx2) {
|
|
580
|
-
store.setId(ctx2.id);
|
|
581
|
-
},
|
|
582
|
-
clearGlobalId(ctx2) {
|
|
583
|
-
if (ctx2.id === store.id) {
|
|
584
|
-
store.setId(null);
|
|
585
|
-
}
|
|
586
|
-
},
|
|
587
|
-
invokeOnOpen(ctx2, evt) {
|
|
588
|
-
var _a;
|
|
589
|
-
const omit = ["TOOLTIP_POINTER_ENTER", "POINTER_ENTER"];
|
|
590
|
-
if (!omit.includes(evt.type)) {
|
|
591
|
-
(_a = ctx2.onOpen) == null ? void 0 : _a.call(ctx2);
|
|
592
|
-
}
|
|
593
|
-
},
|
|
594
|
-
invokeOnClose(ctx2, evt) {
|
|
595
|
-
var _a;
|
|
596
|
-
const omit = ["SETUP"];
|
|
597
|
-
if (!omit.includes(evt.type)) {
|
|
598
|
-
(_a = ctx2.onClose) == null ? void 0 : _a.call(ctx2);
|
|
599
|
-
}
|
|
600
|
-
},
|
|
601
|
-
closeIfDisabled(ctx2, _evt, { send }) {
|
|
602
|
-
if (ctx2.disabled) {
|
|
603
|
-
send("CLOSE");
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
},
|
|
607
|
-
guards: {
|
|
608
|
-
closeOnPointerDown: (ctx2) => ctx2.closeOnPointerDown,
|
|
609
|
-
noVisibleTooltip: () => store.id === null,
|
|
610
|
-
isVisible: (ctx2) => ctx2.id === store.id,
|
|
611
|
-
isInteractive: (ctx2) => ctx2.interactive
|
|
612
|
-
},
|
|
613
|
-
delays: {
|
|
614
|
-
OPEN_DELAY: (ctx2) => ctx2.openDelay,
|
|
615
|
-
CLOSE_DELAY: (ctx2) => ctx2.closeDelay
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
);
|
|
619
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
connect
|
|
3
|
+
} from "./chunk-XZ6HXWV2.mjs";
|
|
4
|
+
import {
|
|
5
|
+
anatomy
|
|
6
|
+
} from "./chunk-RRQRIZBA.mjs";
|
|
7
|
+
import {
|
|
8
|
+
machine
|
|
9
|
+
} from "./chunk-JWVFZJC7.mjs";
|
|
10
|
+
import "./chunk-PFKIRGNP.mjs";
|
|
11
|
+
import "./chunk-GQYNO326.mjs";
|
|
620
12
|
export {
|
|
621
13
|
anatomy,
|
|
622
14
|
connect,
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as _zag_js_anatomy from '@zag-js/anatomy';
|
|
2
|
+
|
|
3
|
+
declare const anatomy: _zag_js_anatomy.AnatomyInstance<"trigger" | "arrow" | "arrowTip" | "positioner" | "content" | "label">;
|
|
4
|
+
declare const parts: Record<"trigger" | "arrow" | "arrowTip" | "positioner" | "content" | "label", _zag_js_anatomy.AnatomyPart>;
|
|
5
|
+
|
|
6
|
+
export { anatomy, parts };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/tooltip.anatomy.ts
|
|
21
|
+
var tooltip_anatomy_exports = {};
|
|
22
|
+
__export(tooltip_anatomy_exports, {
|
|
23
|
+
anatomy: () => anatomy,
|
|
24
|
+
parts: () => parts
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(tooltip_anatomy_exports);
|
|
27
|
+
var import_anatomy = require("@zag-js/anatomy");
|
|
28
|
+
var anatomy = (0, import_anatomy.createAnatomy)("tooltip").parts("trigger", "arrow", "arrowTip", "positioner", "content", "label");
|
|
29
|
+
var parts = anatomy.build();
|
|
30
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
+
0 && (module.exports = {
|
|
32
|
+
anatomy,
|
|
33
|
+
parts
|
|
34
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { PropTypes, NormalizeProps } from '@zag-js/types';
|
|
2
|
+
import { State, Send } from './tooltip.types.js';
|
|
3
|
+
import '@zag-js/core';
|
|
4
|
+
import '@zag-js/popper';
|
|
5
|
+
|
|
6
|
+
declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): {
|
|
7
|
+
isOpen: boolean;
|
|
8
|
+
open(): void;
|
|
9
|
+
close(): void;
|
|
10
|
+
getAnimationState(): {
|
|
11
|
+
enter: boolean;
|
|
12
|
+
exit: boolean;
|
|
13
|
+
};
|
|
14
|
+
triggerProps: T["button"];
|
|
15
|
+
arrowProps: T["element"];
|
|
16
|
+
arrowTipProps: T["element"];
|
|
17
|
+
positionerProps: T["element"];
|
|
18
|
+
contentProps: T["element"];
|
|
19
|
+
labelProps: T["element"];
|
|
20
|
+
createPortal(): HTMLElement;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { connect };
|