@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.
@@ -0,0 +1,528 @@
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.machine.ts
21
+ var tooltip_machine_exports = {};
22
+ __export(tooltip_machine_exports, {
23
+ machine: () => machine
24
+ });
25
+ module.exports = __toCommonJS(tooltip_machine_exports);
26
+ var import_core2 = require("@zag-js/core");
27
+
28
+ // ../../utilities/dom/src/get-computed-style.ts
29
+ function getCache() {
30
+ const g = globalThis;
31
+ g.__styleCache = g.__styleCache || /* @__PURE__ */ new WeakMap();
32
+ return g.__styleCache;
33
+ }
34
+ function getComputedStyle(el) {
35
+ var _a;
36
+ if (!el)
37
+ return {};
38
+ const cache = getCache();
39
+ let style = cache.get(el);
40
+ if (!style) {
41
+ const win = (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
42
+ style = win.getComputedStyle(el);
43
+ cache.set(el, style);
44
+ }
45
+ return style;
46
+ }
47
+
48
+ // ../../utilities/core/src/functions.ts
49
+ var runIfFn = (v, ...a) => {
50
+ const res = typeof v === "function" ? v(...a) : v;
51
+ return res != null ? res : void 0;
52
+ };
53
+
54
+ // ../../utilities/core/src/guard.ts
55
+ var isArray = (v) => Array.isArray(v);
56
+ var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
57
+ var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
58
+
59
+ // ../../utilities/core/src/object.ts
60
+ function compact(obj) {
61
+ if (obj === void 0)
62
+ return obj;
63
+ return Object.fromEntries(
64
+ Object.entries(obj).filter(([, value]) => value !== void 0).map(([key, value]) => [key, isObject(value) ? compact(value) : value])
65
+ );
66
+ }
67
+
68
+ // ../../utilities/dom/src/platform.ts
69
+ var isDom = () => typeof window !== "undefined";
70
+ function getPlatform() {
71
+ var _a;
72
+ const agent = navigator.userAgentData;
73
+ return (_a = agent == null ? void 0 : agent.platform) != null ? _a : navigator.platform;
74
+ }
75
+ var pt = (v) => isDom() && v.test(getPlatform());
76
+ var vn = (v) => isDom() && v.test(navigator.vendor);
77
+ var isSafari = () => isApple() && vn(/apple/i);
78
+ var isApple = () => pt(/mac|iphone|ipad|ipod/i);
79
+
80
+ // ../../utilities/dom/src/query.ts
81
+ function isDocument(el) {
82
+ return el.nodeType === Node.DOCUMENT_NODE;
83
+ }
84
+ function isWindow(value) {
85
+ return (value == null ? void 0 : value.toString()) === "[object Window]";
86
+ }
87
+ function getDocument(el) {
88
+ var _a;
89
+ if (isWindow(el))
90
+ return el.document;
91
+ if (isDocument(el))
92
+ return el;
93
+ return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
94
+ }
95
+ function getWindow(el) {
96
+ var _a;
97
+ return (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
98
+ }
99
+ function getNodeName(node) {
100
+ var _a;
101
+ return isWindow(node) ? "" : (_a = node == null ? void 0 : node.localName) != null ? _a : "";
102
+ }
103
+ function getParent(el) {
104
+ const doc = getDocument(el);
105
+ if (getNodeName(el) === "html")
106
+ return el;
107
+ return el.assignedSlot || el.parentElement || doc.documentElement;
108
+ }
109
+ function defineDomHelpers(helpers) {
110
+ const dom2 = {
111
+ getRootNode: (ctx) => {
112
+ var _a, _b;
113
+ return (_b = (_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) != null ? _b : document;
114
+ },
115
+ getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
116
+ getWin: (ctx) => {
117
+ var _a;
118
+ return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
119
+ },
120
+ getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
121
+ getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id),
122
+ createEmitter: (ctx, target) => {
123
+ const win = dom2.getWin(ctx);
124
+ return function emit(evt, detail, options) {
125
+ const { bubbles = true, cancelable, composed = true } = options != null ? options : {};
126
+ const eventName = `zag:${evt}`;
127
+ const init = { bubbles, cancelable, composed, detail };
128
+ const event = new win.CustomEvent(eventName, init);
129
+ target.dispatchEvent(event);
130
+ };
131
+ },
132
+ createListener: (target) => {
133
+ return function listen(evt, handler) {
134
+ const eventName = `zag:${evt}`;
135
+ const listener = (e) => handler(e);
136
+ target.addEventListener(eventName, listener);
137
+ return () => target.removeEventListener(eventName, listener);
138
+ };
139
+ }
140
+ };
141
+ return {
142
+ ...dom2,
143
+ ...helpers
144
+ };
145
+ }
146
+ function isHTMLElement(v) {
147
+ return typeof v === "object" && (v == null ? void 0 : v.nodeType) === Node.ELEMENT_NODE && typeof (v == null ? void 0 : v.nodeName) === "string";
148
+ }
149
+
150
+ // ../../utilities/dom/src/event.ts
151
+ var supportsPointerEvent = () => isDom() && window.onpointerdown === null;
152
+ var supportsTouchEvent = () => isDom() && window.ontouchstart === null;
153
+ var supportsMouseEvent = () => isDom() && window.onmousedown === null;
154
+ var isTouchEvent = (v) => isObject(v) && hasProp(v, "touches");
155
+
156
+ // ../../utilities/dom/src/listener.ts
157
+ var isRef = (v) => hasProp(v, "current");
158
+ var fallback = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
159
+ function extractInfo(event, type = "page") {
160
+ const point = isTouchEvent(event) ? event.touches[0] || event.changedTouches[0] || fallback : event;
161
+ return {
162
+ point: {
163
+ x: point[`${type}X`],
164
+ y: point[`${type}Y`]
165
+ }
166
+ };
167
+ }
168
+ function addDomEvent(target, eventName, handler, options) {
169
+ const node = isRef(target) ? target.current : runIfFn(target);
170
+ node == null ? void 0 : node.addEventListener(eventName, handler, options);
171
+ return () => {
172
+ node == null ? void 0 : node.removeEventListener(eventName, handler, options);
173
+ };
174
+ }
175
+ function addPointerEvent(target, event, listener, options) {
176
+ var _a;
177
+ const type = (_a = getEventName(event)) != null ? _a : event;
178
+ return addDomEvent(target, type, wrapHandler(listener, event === "pointerdown"), options);
179
+ }
180
+ function wrapHandler(fn, filter = false) {
181
+ const listener = (event) => {
182
+ fn(event, extractInfo(event));
183
+ };
184
+ return filter ? filterPrimaryPointer(listener) : listener;
185
+ }
186
+ function filterPrimaryPointer(fn) {
187
+ return (event) => {
188
+ var _a;
189
+ const win = (_a = event.view) != null ? _a : window;
190
+ const isMouseEvent = event instanceof win.MouseEvent;
191
+ const isPrimary = !isMouseEvent || isMouseEvent && event.button === 0;
192
+ if (isPrimary)
193
+ fn(event);
194
+ };
195
+ }
196
+ var mouseEventNames = {
197
+ pointerdown: "mousedown",
198
+ pointermove: "mousemove",
199
+ pointerup: "mouseup",
200
+ pointercancel: "mousecancel",
201
+ pointerover: "mouseover",
202
+ pointerout: "mouseout",
203
+ pointerenter: "mouseenter",
204
+ pointerleave: "mouseleave"
205
+ };
206
+ var touchEventNames = {
207
+ pointerdown: "touchstart",
208
+ pointermove: "touchmove",
209
+ pointerup: "touchend",
210
+ pointercancel: "touchcancel"
211
+ };
212
+ function getEventName(evt) {
213
+ if (supportsPointerEvent())
214
+ return evt;
215
+ if (supportsTouchEvent())
216
+ return touchEventNames[evt];
217
+ if (supportsMouseEvent())
218
+ return mouseEventNames[evt];
219
+ return evt;
220
+ }
221
+
222
+ // ../../utilities/dom/src/next-tick.ts
223
+ function raf(fn) {
224
+ const id = globalThis.requestAnimationFrame(fn);
225
+ return function cleanup() {
226
+ globalThis.cancelAnimationFrame(id);
227
+ };
228
+ }
229
+
230
+ // ../../utilities/dom/src/pointerlock.ts
231
+ function addPointerlockChangeListener(doc, fn) {
232
+ return addDomEvent(doc, "pointerlockchange", fn, false);
233
+ }
234
+
235
+ // ../../utilities/dom/src/scrollable.ts
236
+ function isScrollParent(el) {
237
+ const { overflow, overflowX, overflowY } = getComputedStyle(el);
238
+ return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
239
+ }
240
+ function getScrollParent(el) {
241
+ if (["html", "body", "#document"].includes(getNodeName(el))) {
242
+ return getDocument(el).body;
243
+ }
244
+ if (isHTMLElement(el) && isScrollParent(el)) {
245
+ return el;
246
+ }
247
+ return getScrollParent(getParent(el));
248
+ }
249
+ function getScrollParents(el, list = []) {
250
+ const scrollParent = getScrollParent(el);
251
+ const isBody = scrollParent === getDocument(el).body;
252
+ const win = getWindow(scrollParent);
253
+ const target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
254
+ const parents = list.concat(target);
255
+ if (isBody)
256
+ return parents;
257
+ return parents.concat(getScrollParents(getParent(target)));
258
+ }
259
+
260
+ // src/tooltip.machine.ts
261
+ var import_popper = require("@zag-js/popper");
262
+
263
+ // src/tooltip.dom.ts
264
+ var dom = defineDomHelpers({
265
+ getTriggerId: (ctx) => {
266
+ var _a, _b;
267
+ return (_b = (_a = ctx.ids) == null ? void 0 : _a.trigger) != null ? _b : `tooltip:${ctx.id}:trigger`;
268
+ },
269
+ getContentId: (ctx) => {
270
+ var _a, _b;
271
+ return (_b = (_a = ctx.ids) == null ? void 0 : _a.content) != null ? _b : `tooltip:${ctx.id}:content`;
272
+ },
273
+ getArrowId: (ctx) => `tooltip:${ctx.id}:arrow`,
274
+ getPositionerId: (ctx) => `tooltip:${ctx.id}:popper`,
275
+ portalId: "tooltip-portal",
276
+ getTriggerEl: (ctx) => dom.getById(ctx, dom.getTriggerId(ctx)),
277
+ getContentEl: (ctx) => dom.getById(ctx, dom.getContentId(ctx)),
278
+ getPositionerEl: (ctx) => dom.getById(ctx, dom.getPositionerId(ctx)),
279
+ getArrowEl: (ctx) => dom.getById(ctx, dom.getArrowId(ctx)),
280
+ getScrollParent: (ctx) => getScrollParent(dom.getTriggerEl(ctx)),
281
+ getPortalEl: (ctx) => dom.getDoc(ctx).getElementById(dom.portalId),
282
+ createPortalEl: (ctx) => {
283
+ const portal = dom.getDoc(ctx).createElement(dom.portalId);
284
+ portal.id = dom.portalId;
285
+ return portal;
286
+ }
287
+ });
288
+
289
+ // src/tooltip.store.ts
290
+ var import_core = require("@zag-js/core");
291
+ var store = (0, import_core.proxy)({
292
+ id: null,
293
+ prevId: null,
294
+ setId(val) {
295
+ this.prevId = this.id;
296
+ this.id = val;
297
+ }
298
+ });
299
+
300
+ // src/tooltip.machine.ts
301
+ function machine(userContext) {
302
+ const ctx = compact(userContext);
303
+ return (0, import_core2.createMachine)(
304
+ {
305
+ id: "tooltip",
306
+ initial: "unknown",
307
+ context: {
308
+ openDelay: 1e3,
309
+ closeDelay: 500,
310
+ closeOnPointerDown: true,
311
+ closeOnEsc: true,
312
+ interactive: true,
313
+ currentPlacement: void 0,
314
+ ...ctx,
315
+ positioning: {
316
+ placement: "bottom",
317
+ ...ctx.positioning
318
+ }
319
+ },
320
+ computed: {
321
+ hasAriaLabel: (ctx2) => !!ctx2["aria-label"]
322
+ },
323
+ watch: {
324
+ disabled: ["closeIfDisabled"]
325
+ },
326
+ on: {
327
+ OPEN: "open",
328
+ CLOSE: "closed"
329
+ },
330
+ states: {
331
+ unknown: {
332
+ on: {
333
+ SETUP: "closed"
334
+ }
335
+ },
336
+ closed: {
337
+ tags: ["closed"],
338
+ entry: ["clearGlobalId", "invokeOnClose"],
339
+ on: {
340
+ FOCUS: "open",
341
+ POINTER_ENTER: [
342
+ {
343
+ guard: "noVisibleTooltip",
344
+ target: "opening"
345
+ },
346
+ { target: "open" }
347
+ ]
348
+ }
349
+ },
350
+ opening: {
351
+ tags: ["closed"],
352
+ activities: ["trackScroll", "trackPointerlockChange"],
353
+ after: {
354
+ OPEN_DELAY: "open"
355
+ },
356
+ on: {
357
+ POINTER_LEAVE: "closed",
358
+ BLUR: "closed",
359
+ SCROLL: "closed",
360
+ POINTER_LOCK_CHANGE: "closed",
361
+ POINTER_DOWN: {
362
+ guard: "closeOnPointerDown",
363
+ target: "closed"
364
+ }
365
+ }
366
+ },
367
+ open: {
368
+ tags: ["open"],
369
+ activities: [
370
+ "trackEscapeKey",
371
+ "trackDisabledTriggerOnSafari",
372
+ "trackScroll",
373
+ "trackPointerlockChange",
374
+ "computePlacement"
375
+ ],
376
+ entry: ["setGlobalId", "invokeOnOpen"],
377
+ on: {
378
+ POINTER_LEAVE: [
379
+ {
380
+ guard: "isVisible",
381
+ target: "closing"
382
+ },
383
+ { target: "closed" }
384
+ ],
385
+ BLUR: "closed",
386
+ ESCAPE: "closed",
387
+ SCROLL: "closed",
388
+ POINTER_LOCK_CHANGE: "closed",
389
+ TOOLTIP_POINTER_LEAVE: {
390
+ guard: "isInteractive",
391
+ target: "closing"
392
+ },
393
+ POINTER_DOWN: {
394
+ guard: "closeOnPointerDown",
395
+ target: "closed"
396
+ },
397
+ CLICK: "closed"
398
+ }
399
+ },
400
+ closing: {
401
+ tags: ["open"],
402
+ activities: ["trackStore", "computePlacement"],
403
+ after: {
404
+ CLOSE_DELAY: "closed"
405
+ },
406
+ on: {
407
+ FORCE_CLOSE: "closed",
408
+ POINTER_ENTER: "open",
409
+ TOOLTIP_POINTER_ENTER: {
410
+ guard: "isInteractive",
411
+ target: "open"
412
+ }
413
+ }
414
+ }
415
+ }
416
+ },
417
+ {
418
+ activities: {
419
+ computePlacement(ctx2) {
420
+ ctx2.currentPlacement = ctx2.positioning.placement;
421
+ let cleanup;
422
+ raf(() => {
423
+ cleanup = (0, import_popper.getPlacement)(dom.getTriggerEl(ctx2), dom.getPositionerEl(ctx2), {
424
+ ...ctx2.positioning,
425
+ onComplete(data) {
426
+ ctx2.currentPlacement = data.placement;
427
+ ctx2.isPlacementComplete = true;
428
+ },
429
+ onCleanup() {
430
+ ctx2.currentPlacement = void 0;
431
+ ctx2.isPlacementComplete = false;
432
+ }
433
+ });
434
+ });
435
+ return cleanup;
436
+ },
437
+ trackPointerlockChange(ctx2, _evt, { send }) {
438
+ return addPointerlockChangeListener(dom.getDoc(ctx2), () => {
439
+ send("POINTER_LOCK_CHANGE");
440
+ });
441
+ },
442
+ trackScroll(ctx2, _evt, { send }) {
443
+ const trigger = dom.getTriggerEl(ctx2);
444
+ if (!trigger)
445
+ return;
446
+ const cleanups = getScrollParents(trigger).map((el) => {
447
+ const opts = { passive: true, capture: true };
448
+ return addDomEvent(el, "scroll", () => send("SCROLL"), opts);
449
+ });
450
+ return () => {
451
+ cleanups.forEach((fn) => fn == null ? void 0 : fn());
452
+ };
453
+ },
454
+ trackStore(ctx2, _evt, { send }) {
455
+ return (0, import_core2.subscribe)(store, () => {
456
+ if (store.id !== ctx2.id) {
457
+ send("FORCE_CLOSE");
458
+ }
459
+ });
460
+ },
461
+ trackDisabledTriggerOnSafari(ctx2, _evt, { send }) {
462
+ if (!isSafari())
463
+ return;
464
+ const doc = dom.getDoc(ctx2);
465
+ return addPointerEvent(doc, "pointermove", (event) => {
466
+ const selector = "[data-part=trigger][data-expanded]";
467
+ if (isHTMLElement(event.target) && event.target.closest(selector))
468
+ return;
469
+ send("POINTER_LEAVE");
470
+ });
471
+ },
472
+ trackEscapeKey(ctx2, _evt, { send }) {
473
+ if (!ctx2.closeOnEsc)
474
+ return;
475
+ const doc = dom.getDoc(ctx2);
476
+ return addDomEvent(doc, "keydown", (event) => {
477
+ if (event.key === "Escape") {
478
+ send("ESCAPE");
479
+ }
480
+ });
481
+ }
482
+ },
483
+ actions: {
484
+ setGlobalId(ctx2) {
485
+ store.setId(ctx2.id);
486
+ },
487
+ clearGlobalId(ctx2) {
488
+ if (ctx2.id === store.id) {
489
+ store.setId(null);
490
+ }
491
+ },
492
+ invokeOnOpen(ctx2, evt) {
493
+ var _a;
494
+ const omit = ["TOOLTIP_POINTER_ENTER", "POINTER_ENTER"];
495
+ if (!omit.includes(evt.type)) {
496
+ (_a = ctx2.onOpen) == null ? void 0 : _a.call(ctx2);
497
+ }
498
+ },
499
+ invokeOnClose(ctx2, evt) {
500
+ var _a;
501
+ const omit = ["SETUP"];
502
+ if (!omit.includes(evt.type)) {
503
+ (_a = ctx2.onClose) == null ? void 0 : _a.call(ctx2);
504
+ }
505
+ },
506
+ closeIfDisabled(ctx2, _evt, { send }) {
507
+ if (ctx2.disabled) {
508
+ send("CLOSE");
509
+ }
510
+ }
511
+ },
512
+ guards: {
513
+ closeOnPointerDown: (ctx2) => ctx2.closeOnPointerDown,
514
+ noVisibleTooltip: () => store.id === null,
515
+ isVisible: (ctx2) => ctx2.id === store.id,
516
+ isInteractive: (ctx2) => ctx2.interactive
517
+ },
518
+ delays: {
519
+ OPEN_DELAY: (ctx2) => ctx2.openDelay,
520
+ CLOSE_DELAY: (ctx2) => ctx2.closeDelay
521
+ }
522
+ }
523
+ );
524
+ }
525
+ // Annotate the CommonJS export names for ESM import in node:
526
+ 0 && (module.exports = {
527
+ machine
528
+ });
@@ -0,0 +1,8 @@
1
+ import {
2
+ machine
3
+ } from "./chunk-JWVFZJC7.mjs";
4
+ import "./chunk-PFKIRGNP.mjs";
5
+ import "./chunk-GQYNO326.mjs";
6
+ export {
7
+ machine
8
+ };
@@ -0,0 +1,9 @@
1
+ type Id = string | null;
2
+ type Store = {
3
+ id: Id;
4
+ prevId: Id;
5
+ setId: (val: Id) => void;
6
+ };
7
+ declare const store: Store;
8
+
9
+ export { store };
@@ -0,0 +1,38 @@
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.store.ts
21
+ var tooltip_store_exports = {};
22
+ __export(tooltip_store_exports, {
23
+ store: () => store
24
+ });
25
+ module.exports = __toCommonJS(tooltip_store_exports);
26
+ var import_core = require("@zag-js/core");
27
+ var store = (0, import_core.proxy)({
28
+ id: null,
29
+ prevId: null,
30
+ setId(val) {
31
+ this.prevId = this.id;
32
+ this.id = val;
33
+ }
34
+ });
35
+ // Annotate the CommonJS export names for ESM import in node:
36
+ 0 && (module.exports = {
37
+ store
38
+ });
@@ -0,0 +1,6 @@
1
+ import {
2
+ store
3
+ } from "./chunk-GQYNO326.mjs";
4
+ export {
5
+ store
6
+ };
@@ -0,0 +1,77 @@
1
+ import { StateMachine } from '@zag-js/core';
2
+ import { PositioningOptions } from '@zag-js/popper';
3
+ import { RequiredBy, CommonProperties, RootProperties } from '@zag-js/types';
4
+
5
+ type ElementIds = Partial<{
6
+ trigger: string;
7
+ content: string;
8
+ }>;
9
+ type PublicContext = CommonProperties & {
10
+ /**
11
+ * The ids of the elements in the tooltip. Useful for composition.
12
+ */
13
+ ids?: ElementIds;
14
+ /**
15
+ * The `id` of the tooltip.
16
+ */
17
+ id: string;
18
+ /**
19
+ * The open delay of the tooltip.
20
+ */
21
+ openDelay: number;
22
+ /**
23
+ * The close delay of the tooltip.
24
+ */
25
+ closeDelay: number;
26
+ /**
27
+ * Whether to close the tooltip on pointerdown.
28
+ */
29
+ closeOnPointerDown: boolean;
30
+ /**
31
+ * Whether to close the tooltip when the Escape key is pressed.
32
+ */
33
+ closeOnEsc?: boolean;
34
+ /**
35
+ * Whether the tooltip's content is interactive.
36
+ * In this mode, the tooltip will remain open when user hovers over the content.
37
+ * @see https://www.w3.org/TR/WCAG21/#content-on-hover-or-focus
38
+ */
39
+ interactive: boolean;
40
+ /**
41
+ * Function called when the tooltip is opened.
42
+ */
43
+ onOpen?: VoidFunction;
44
+ /**
45
+ * Function called when the tooltip is closed.
46
+ */
47
+ onClose?: VoidFunction;
48
+ /**
49
+ * Custom label for the tooltip.
50
+ */
51
+ "aria-label"?: string;
52
+ /**
53
+ * The user provided options used to position the popover content
54
+ */
55
+ positioning: PositioningOptions;
56
+ /**
57
+ * Whether the tooltip is disabled
58
+ */
59
+ disabled?: boolean;
60
+ };
61
+ type UserDefinedContext = RequiredBy<PublicContext, "id">;
62
+ type ComputedContext = Readonly<{
63
+ /**
64
+ * @computed Whether an `aria-label` is set.
65
+ */
66
+ readonly hasAriaLabel: boolean;
67
+ }>;
68
+ type PrivateContext = RootProperties & {};
69
+ type MachineContext = PublicContext & ComputedContext & PrivateContext;
70
+ type MachineState = {
71
+ value: "unknown" | "opening" | "open" | "closing" | "closed";
72
+ tags: "open" | "closed";
73
+ };
74
+ type State = StateMachine.State<MachineContext, MachineState>;
75
+ type Send = StateMachine.Send<StateMachine.AnyEventObject>;
76
+
77
+ export { MachineContext, MachineState, Send, State, UserDefinedContext };
@@ -0,0 +1,18 @@
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 __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/tooltip.types.ts
17
+ var tooltip_types_exports = {};
18
+ module.exports = __toCommonJS(tooltip_types_exports);
File without changes