@zag-js/tooltip 0.1.9 → 0.1.12
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/LICENSE +21 -0
- package/dist/index.d.ts +93 -3
- package/dist/index.js +250 -272
- package/dist/index.mjs +246 -276
- package/package.json +15 -11
- package/dist/tooltip.connect.d.ts +0 -18
- package/dist/tooltip.dom.d.ts +0 -18
- package/dist/tooltip.machine.d.ts +0 -2
- package/dist/tooltip.store.d.ts +0 -8
- package/dist/tooltip.types.d.ts +0 -82
package/dist/index.js
CHANGED
|
@@ -1,25 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
-
var __spreadValues = (a, b) => {
|
|
12
|
-
for (var prop in b || (b = {}))
|
|
13
|
-
if (__hasOwnProp.call(b, prop))
|
|
14
|
-
__defNormalProp(a, prop, b[prop]);
|
|
15
|
-
if (__getOwnPropSymbols)
|
|
16
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
-
if (__propIsEnum.call(b, prop))
|
|
18
|
-
__defNormalProp(a, prop, b[prop]);
|
|
19
|
-
}
|
|
20
|
-
return a;
|
|
21
|
-
};
|
|
22
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
6
|
var __export = (target, all) => {
|
|
24
7
|
for (var name in all)
|
|
25
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -52,13 +35,12 @@ function getCache() {
|
|
|
52
35
|
return g.__styleCache;
|
|
53
36
|
}
|
|
54
37
|
function getComputedStyle(el) {
|
|
55
|
-
var _a;
|
|
56
38
|
if (!el)
|
|
57
39
|
return {};
|
|
58
40
|
const cache = getCache();
|
|
59
41
|
let style = cache.get(el);
|
|
60
42
|
if (!style) {
|
|
61
|
-
const win = (
|
|
43
|
+
const win = (el == null ? void 0 : el.ownerDocument.defaultView) ?? window;
|
|
62
44
|
style = win.getComputedStyle(el);
|
|
63
45
|
cache.set(el, style);
|
|
64
46
|
}
|
|
@@ -66,37 +48,38 @@ function getComputedStyle(el) {
|
|
|
66
48
|
}
|
|
67
49
|
var runIfFn = (v, ...a) => {
|
|
68
50
|
const res = typeof v === "function" ? v(...a) : v;
|
|
69
|
-
return res
|
|
51
|
+
return res ?? void 0;
|
|
70
52
|
};
|
|
71
53
|
var isArray = (v) => Array.isArray(v);
|
|
72
54
|
var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
|
|
73
55
|
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
74
56
|
var isDom = () => typeof window !== "undefined";
|
|
75
57
|
function getPlatform() {
|
|
76
|
-
var _a;
|
|
77
58
|
const agent = navigator.userAgentData;
|
|
78
|
-
return (
|
|
59
|
+
return (agent == null ? void 0 : agent.platform) ?? navigator.platform;
|
|
79
60
|
}
|
|
80
61
|
var pt = (v) => isDom() && v.test(getPlatform());
|
|
81
62
|
var vn = (v) => isDom() && v.test(navigator.vendor);
|
|
82
63
|
var isSafari = () => isApple() && vn(/apple/i);
|
|
83
64
|
var isApple = () => pt(/mac|iphone|ipad|ipod/i);
|
|
65
|
+
function isDocument(el) {
|
|
66
|
+
return el.nodeType === Node.DOCUMENT_NODE;
|
|
67
|
+
}
|
|
84
68
|
function isWindow(value) {
|
|
85
69
|
return (value == null ? void 0 : value.toString()) === "[object Window]";
|
|
86
70
|
}
|
|
87
71
|
function getDocument(el) {
|
|
88
|
-
var _a;
|
|
89
72
|
if (isWindow(el))
|
|
90
73
|
return el.document;
|
|
91
|
-
|
|
74
|
+
if (isDocument(el))
|
|
75
|
+
return el;
|
|
76
|
+
return (el == null ? void 0 : el.ownerDocument) ?? document;
|
|
92
77
|
}
|
|
93
78
|
function getWindow(el) {
|
|
94
|
-
|
|
95
|
-
return (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
|
|
79
|
+
return (el == null ? void 0 : el.ownerDocument.defaultView) ?? window;
|
|
96
80
|
}
|
|
97
81
|
function getNodeName(node) {
|
|
98
|
-
|
|
99
|
-
return isWindow(node) ? "" : (_a = node == null ? void 0 : node.localName) != null ? _a : "";
|
|
82
|
+
return isWindow(node) ? "" : (node == null ? void 0 : node.localName) ?? "";
|
|
100
83
|
}
|
|
101
84
|
function getParent(el) {
|
|
102
85
|
const doc = getDocument(el);
|
|
@@ -104,6 +87,22 @@ function getParent(el) {
|
|
|
104
87
|
return el;
|
|
105
88
|
return el.assignedSlot || el.parentElement || doc.documentElement;
|
|
106
89
|
}
|
|
90
|
+
function defineDomHelpers(helpers) {
|
|
91
|
+
const dom2 = {
|
|
92
|
+
getRootNode: (ctx) => {
|
|
93
|
+
var _a;
|
|
94
|
+
return ((_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) ?? document;
|
|
95
|
+
},
|
|
96
|
+
getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
|
|
97
|
+
getWin: (ctx) => dom2.getDoc(ctx).defaultView ?? window,
|
|
98
|
+
getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
|
|
99
|
+
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
|
|
100
|
+
};
|
|
101
|
+
return {
|
|
102
|
+
...dom2,
|
|
103
|
+
...helpers
|
|
104
|
+
};
|
|
105
|
+
}
|
|
107
106
|
function isHTMLElement(v) {
|
|
108
107
|
return typeof v === "object" && (v == null ? void 0 : v.nodeType) === Node.ELEMENT_NODE && typeof (v == null ? void 0 : v.nodeName) === "string";
|
|
109
108
|
}
|
|
@@ -130,8 +129,7 @@ function addDomEvent(target, eventName, handler, options) {
|
|
|
130
129
|
};
|
|
131
130
|
}
|
|
132
131
|
function addPointerEvent(target, event, listener, options) {
|
|
133
|
-
|
|
134
|
-
const type = (_a = getEventName(event)) != null ? _a : event;
|
|
132
|
+
const type = getEventName(event) ?? event;
|
|
135
133
|
return addDomEvent(target, type, wrapHandler(listener, event === "pointerdown"), options);
|
|
136
134
|
}
|
|
137
135
|
function wrapHandler(fn, filter = false) {
|
|
@@ -142,8 +140,7 @@ function wrapHandler(fn, filter = false) {
|
|
|
142
140
|
}
|
|
143
141
|
function filterPrimaryPointer(fn) {
|
|
144
142
|
return (event) => {
|
|
145
|
-
|
|
146
|
-
const win = (_a = event.view) != null ? _a : window;
|
|
143
|
+
const win = event.view ?? window;
|
|
147
144
|
const isMouseEvent2 = event instanceof win.MouseEvent;
|
|
148
145
|
const isPrimary = !isMouseEvent2 || isMouseEvent2 && event.button === 0;
|
|
149
146
|
if (isPrimary)
|
|
@@ -175,18 +172,6 @@ function getEventName(evt) {
|
|
|
175
172
|
return mouseEventNames[evt];
|
|
176
173
|
return evt;
|
|
177
174
|
}
|
|
178
|
-
var visuallyHiddenStyle = {
|
|
179
|
-
border: "0",
|
|
180
|
-
clip: "rect(0 0 0 0)",
|
|
181
|
-
height: "1px",
|
|
182
|
-
margin: "-1px",
|
|
183
|
-
overflow: "hidden",
|
|
184
|
-
padding: "0",
|
|
185
|
-
position: "absolute",
|
|
186
|
-
width: "1px",
|
|
187
|
-
whiteSpace: "nowrap",
|
|
188
|
-
wordWrap: "normal"
|
|
189
|
-
};
|
|
190
175
|
function raf(fn) {
|
|
191
176
|
const id = globalThis.requestAnimationFrame(fn);
|
|
192
177
|
return function cleanup() {
|
|
@@ -219,39 +204,39 @@ function getScrollParents(el, list = []) {
|
|
|
219
204
|
return parents;
|
|
220
205
|
return parents.concat(getScrollParents(getParent(target)));
|
|
221
206
|
}
|
|
207
|
+
var visuallyHiddenStyle = {
|
|
208
|
+
border: "0",
|
|
209
|
+
clip: "rect(0 0 0 0)",
|
|
210
|
+
height: "1px",
|
|
211
|
+
margin: "-1px",
|
|
212
|
+
overflow: "hidden",
|
|
213
|
+
padding: "0",
|
|
214
|
+
position: "absolute",
|
|
215
|
+
width: "1px",
|
|
216
|
+
whiteSpace: "nowrap",
|
|
217
|
+
wordWrap: "normal"
|
|
218
|
+
};
|
|
222
219
|
|
|
223
220
|
// src/tooltip.connect.ts
|
|
224
221
|
var import_popper = require("@zag-js/popper");
|
|
225
222
|
|
|
226
223
|
// src/tooltip.dom.ts
|
|
227
|
-
var dom = {
|
|
228
|
-
getDoc: (ctx) => {
|
|
229
|
-
var _a;
|
|
230
|
-
return (_a = ctx.doc) != null ? _a : document;
|
|
231
|
-
},
|
|
232
|
-
getWin: (ctx) => {
|
|
233
|
-
var _a, _b;
|
|
234
|
-
return (_b = (_a = ctx.doc) == null ? void 0 : _a.defaultView) != null ? _b : window;
|
|
235
|
-
},
|
|
236
|
-
getRootNode: (ctx) => {
|
|
237
|
-
var _a;
|
|
238
|
-
return (_a = ctx.rootNode) != null ? _a : dom.getDoc(ctx);
|
|
239
|
-
},
|
|
224
|
+
var dom = defineDomHelpers({
|
|
240
225
|
getTriggerId: (ctx) => {
|
|
241
|
-
var _a
|
|
242
|
-
return (
|
|
226
|
+
var _a;
|
|
227
|
+
return ((_a = ctx.ids) == null ? void 0 : _a.trigger) ?? `tooltip:${ctx.id}:trigger`;
|
|
243
228
|
},
|
|
244
229
|
getContentId: (ctx) => {
|
|
245
|
-
var _a
|
|
246
|
-
return (
|
|
230
|
+
var _a;
|
|
231
|
+
return ((_a = ctx.ids) == null ? void 0 : _a.content) ?? `tooltip:${ctx.id}:content`;
|
|
247
232
|
},
|
|
248
233
|
getArrowId: (ctx) => `tooltip:${ctx.id}:arrow`,
|
|
249
234
|
getPositionerId: (ctx) => `tooltip:${ctx.id}:popper`,
|
|
250
235
|
portalId: "tooltip-portal",
|
|
251
|
-
getTriggerEl: (ctx) => dom.
|
|
252
|
-
getContentEl: (ctx) => dom.
|
|
253
|
-
getPositionerEl: (ctx) => dom.
|
|
254
|
-
getArrowEl: (ctx) => dom.
|
|
236
|
+
getTriggerEl: (ctx) => dom.getById(ctx, dom.getTriggerId(ctx)),
|
|
237
|
+
getContentEl: (ctx) => dom.getById(ctx, dom.getContentId(ctx)),
|
|
238
|
+
getPositionerEl: (ctx) => dom.getById(ctx, dom.getPositionerId(ctx)),
|
|
239
|
+
getArrowEl: (ctx) => dom.getById(ctx, dom.getArrowId(ctx)),
|
|
255
240
|
getScrollParent: (ctx) => getScrollParent(dom.getTriggerEl(ctx)),
|
|
256
241
|
getPortalEl: (ctx) => dom.getDoc(ctx).getElementById(dom.portalId),
|
|
257
242
|
createPortalEl: (ctx) => {
|
|
@@ -259,7 +244,7 @@ var dom = {
|
|
|
259
244
|
portal.id = dom.portalId;
|
|
260
245
|
return portal;
|
|
261
246
|
}
|
|
262
|
-
};
|
|
247
|
+
});
|
|
263
248
|
|
|
264
249
|
// src/tooltip.store.ts
|
|
265
250
|
var import_core = require("@zag-js/core");
|
|
@@ -379,230 +364,223 @@ function connect(state, send, normalize) {
|
|
|
379
364
|
// src/tooltip.machine.ts
|
|
380
365
|
var import_core2 = require("@zag-js/core");
|
|
381
366
|
var import_popper2 = require("@zag-js/popper");
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
interactive: true,
|
|
399
|
-
currentPlacement: void 0
|
|
400
|
-
}, ctx), {
|
|
401
|
-
positioning: __spreadValues({
|
|
402
|
-
placement: "bottom"
|
|
403
|
-
}, ctx.positioning)
|
|
404
|
-
}),
|
|
405
|
-
computed: {
|
|
406
|
-
hasAriaLabel: (ctx2) => !!ctx2["aria-label"]
|
|
407
|
-
},
|
|
408
|
-
on: {
|
|
409
|
-
OPEN: "open",
|
|
410
|
-
CLOSE: "closed"
|
|
411
|
-
},
|
|
412
|
-
states: {
|
|
413
|
-
unknown: {
|
|
414
|
-
on: {
|
|
415
|
-
SETUP: {
|
|
416
|
-
target: "closed",
|
|
417
|
-
actions: "setupDocument"
|
|
418
|
-
}
|
|
367
|
+
function machine(ctx) {
|
|
368
|
+
return (0, import_core2.createMachine)(
|
|
369
|
+
{
|
|
370
|
+
id: "tooltip",
|
|
371
|
+
initial: "unknown",
|
|
372
|
+
context: {
|
|
373
|
+
openDelay: 1e3,
|
|
374
|
+
closeDelay: 500,
|
|
375
|
+
closeOnPointerDown: true,
|
|
376
|
+
closeOnEsc: true,
|
|
377
|
+
interactive: true,
|
|
378
|
+
currentPlacement: void 0,
|
|
379
|
+
...ctx,
|
|
380
|
+
positioning: {
|
|
381
|
+
placement: "bottom",
|
|
382
|
+
...ctx.positioning
|
|
419
383
|
}
|
|
420
384
|
},
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
{
|
|
428
|
-
guard: "noVisibleTooltip",
|
|
429
|
-
target: "opening"
|
|
430
|
-
},
|
|
431
|
-
{ target: "open" }
|
|
432
|
-
]
|
|
433
|
-
}
|
|
385
|
+
computed: {
|
|
386
|
+
hasAriaLabel: (ctx2) => !!ctx2["aria-label"]
|
|
387
|
+
},
|
|
388
|
+
on: {
|
|
389
|
+
OPEN: "open",
|
|
390
|
+
CLOSE: "closed"
|
|
434
391
|
},
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
392
|
+
states: {
|
|
393
|
+
unknown: {
|
|
394
|
+
on: {
|
|
395
|
+
SETUP: "closed"
|
|
396
|
+
}
|
|
440
397
|
},
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
398
|
+
closed: {
|
|
399
|
+
tags: ["closed"],
|
|
400
|
+
entry: ["clearGlobalId", "invokeOnClose"],
|
|
401
|
+
on: {
|
|
402
|
+
FOCUS: "open",
|
|
403
|
+
POINTER_ENTER: [
|
|
404
|
+
{
|
|
405
|
+
guard: "noVisibleTooltip",
|
|
406
|
+
target: "opening"
|
|
407
|
+
},
|
|
408
|
+
{ target: "open" }
|
|
409
|
+
]
|
|
449
410
|
}
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
411
|
+
},
|
|
412
|
+
opening: {
|
|
413
|
+
tags: ["closed"],
|
|
414
|
+
activities: ["trackScroll", "trackPointerlockChange"],
|
|
415
|
+
after: {
|
|
416
|
+
OPEN_DELAY: "open"
|
|
417
|
+
},
|
|
418
|
+
on: {
|
|
419
|
+
POINTER_LEAVE: "closed",
|
|
420
|
+
BLUR: "closed",
|
|
421
|
+
SCROLL: "closed",
|
|
422
|
+
POINTER_LOCK_CHANGE: "closed",
|
|
423
|
+
POINTER_DOWN: {
|
|
424
|
+
guard: "closeOnPointerDown",
|
|
425
|
+
target: "closed"
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
},
|
|
429
|
+
open: {
|
|
430
|
+
tags: ["open"],
|
|
431
|
+
activities: [
|
|
432
|
+
"trackEscapeKey",
|
|
433
|
+
"trackDisabledTriggerOnSafari",
|
|
434
|
+
"trackScroll",
|
|
435
|
+
"trackPointerlockChange",
|
|
436
|
+
"computePlacement"
|
|
437
|
+
],
|
|
438
|
+
entry: ["setGlobalId", "invokeOnOpen"],
|
|
439
|
+
on: {
|
|
440
|
+
POINTER_LEAVE: [
|
|
441
|
+
{
|
|
442
|
+
guard: "isVisible",
|
|
443
|
+
target: "closing"
|
|
444
|
+
},
|
|
445
|
+
{ target: "closed" }
|
|
446
|
+
],
|
|
447
|
+
BLUR: "closed",
|
|
448
|
+
ESCAPE: "closed",
|
|
449
|
+
SCROLL: "closed",
|
|
450
|
+
POINTER_LOCK_CHANGE: "closed",
|
|
451
|
+
TOOLTIP_POINTER_LEAVE: {
|
|
452
|
+
guard: "isInteractive",
|
|
466
453
|
target: "closing"
|
|
467
454
|
},
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
TOOLTIP_POINTER_LEAVE: {
|
|
475
|
-
guard: "isInteractive",
|
|
476
|
-
target: "closing"
|
|
477
|
-
},
|
|
478
|
-
POINTER_DOWN: {
|
|
479
|
-
guard: "closeOnPointerDown",
|
|
480
|
-
target: "closed"
|
|
481
|
-
},
|
|
482
|
-
CLICK: "closed"
|
|
483
|
-
}
|
|
484
|
-
},
|
|
485
|
-
closing: {
|
|
486
|
-
tags: ["open"],
|
|
487
|
-
activities: ["trackStore", "computePlacement"],
|
|
488
|
-
after: {
|
|
489
|
-
CLOSE_DELAY: "closed"
|
|
455
|
+
POINTER_DOWN: {
|
|
456
|
+
guard: "closeOnPointerDown",
|
|
457
|
+
target: "closed"
|
|
458
|
+
},
|
|
459
|
+
CLICK: "closed"
|
|
460
|
+
}
|
|
490
461
|
},
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
462
|
+
closing: {
|
|
463
|
+
tags: ["open"],
|
|
464
|
+
activities: ["trackStore", "computePlacement"],
|
|
465
|
+
after: {
|
|
466
|
+
CLOSE_DELAY: "closed"
|
|
467
|
+
},
|
|
468
|
+
on: {
|
|
469
|
+
FORCE_CLOSE: "closed",
|
|
470
|
+
POINTER_ENTER: "open",
|
|
471
|
+
TOOLTIP_POINTER_ENTER: {
|
|
472
|
+
guard: "isInteractive",
|
|
473
|
+
target: "open"
|
|
474
|
+
}
|
|
497
475
|
}
|
|
498
476
|
}
|
|
499
477
|
}
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
activities: {
|
|
481
|
+
computePlacement(ctx2) {
|
|
482
|
+
ctx2.currentPlacement = ctx2.positioning.placement;
|
|
483
|
+
let cleanup;
|
|
484
|
+
raf(() => {
|
|
485
|
+
cleanup = (0, import_popper2.getPlacement)(dom.getTriggerEl(ctx2), dom.getPositionerEl(ctx2), {
|
|
486
|
+
...ctx2.positioning,
|
|
487
|
+
onComplete(data) {
|
|
488
|
+
ctx2.currentPlacement = data.placement;
|
|
489
|
+
ctx2.isPlacementComplete = true;
|
|
490
|
+
},
|
|
491
|
+
onCleanup() {
|
|
492
|
+
ctx2.currentPlacement = void 0;
|
|
493
|
+
ctx2.isPlacementComplete = false;
|
|
494
|
+
}
|
|
495
|
+
});
|
|
496
|
+
});
|
|
497
|
+
return cleanup;
|
|
498
|
+
},
|
|
499
|
+
trackPointerlockChange(ctx2, _evt, { send }) {
|
|
500
|
+
return addPointerlockChangeListener(dom.getDoc(ctx2), () => {
|
|
501
|
+
send("POINTER_LOCK_CHANGE");
|
|
502
|
+
});
|
|
503
|
+
},
|
|
504
|
+
trackScroll(ctx2, _evt, { send }) {
|
|
505
|
+
const trigger = dom.getTriggerEl(ctx2);
|
|
506
|
+
if (!trigger)
|
|
507
|
+
return;
|
|
508
|
+
const cleanups = getScrollParents(trigger).map((el) => {
|
|
509
|
+
const opts = { passive: true, capture: true };
|
|
510
|
+
return addDomEvent(el, "scroll", () => send("SCROLL"), opts);
|
|
511
|
+
});
|
|
512
|
+
return () => {
|
|
513
|
+
cleanups.forEach((fn) => fn == null ? void 0 : fn());
|
|
514
|
+
};
|
|
515
|
+
},
|
|
516
|
+
trackStore(ctx2, _evt, { send }) {
|
|
517
|
+
return (0, import_core2.subscribe)(store, () => {
|
|
518
|
+
if (store.id !== ctx2.id) {
|
|
519
|
+
send("FORCE_CLOSE");
|
|
515
520
|
}
|
|
516
|
-
})
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
trackPointerlockChange(ctx2, _evt, { send }) {
|
|
521
|
-
return addPointerlockChangeListener(dom.getDoc(ctx2), () => {
|
|
522
|
-
send("POINTER_LOCK_CHANGE");
|
|
523
|
-
});
|
|
524
|
-
},
|
|
525
|
-
trackScroll(ctx2, _evt, { send }) {
|
|
526
|
-
const trigger = dom.getTriggerEl(ctx2);
|
|
527
|
-
if (!trigger)
|
|
528
|
-
return;
|
|
529
|
-
const cleanups = getScrollParents(trigger).map((el) => {
|
|
530
|
-
const opts = { passive: true, capture: true };
|
|
531
|
-
return addDomEvent(el, "scroll", () => send("SCROLL"), opts);
|
|
532
|
-
});
|
|
533
|
-
return () => {
|
|
534
|
-
cleanups.forEach((fn) => fn == null ? void 0 : fn());
|
|
535
|
-
};
|
|
536
|
-
},
|
|
537
|
-
trackStore(ctx2, _evt, { send }) {
|
|
538
|
-
return (0, import_core2.subscribe)(store, () => {
|
|
539
|
-
if (store.id !== ctx2.id) {
|
|
540
|
-
send("FORCE_CLOSE");
|
|
541
|
-
}
|
|
542
|
-
});
|
|
543
|
-
},
|
|
544
|
-
trackDisabledTriggerOnSafari(ctx2, _evt, { send }) {
|
|
545
|
-
if (!isSafari())
|
|
546
|
-
return noop;
|
|
547
|
-
const doc = dom.getDoc(ctx2);
|
|
548
|
-
return addPointerEvent(doc, "pointermove", (event) => {
|
|
549
|
-
const selector = "[data-part=trigger][data-expanded]";
|
|
550
|
-
if (isHTMLElement(event.target) && event.target.closest(selector))
|
|
521
|
+
});
|
|
522
|
+
},
|
|
523
|
+
trackDisabledTriggerOnSafari(ctx2, _evt, { send }) {
|
|
524
|
+
if (!isSafari())
|
|
551
525
|
return;
|
|
552
|
-
|
|
553
|
-
|
|
526
|
+
const doc = dom.getDoc(ctx2);
|
|
527
|
+
return addPointerEvent(doc, "pointermove", (event) => {
|
|
528
|
+
const selector = "[data-part=trigger][data-expanded]";
|
|
529
|
+
if (isHTMLElement(event.target) && event.target.closest(selector))
|
|
530
|
+
return;
|
|
531
|
+
send("POINTER_LEAVE");
|
|
532
|
+
});
|
|
533
|
+
},
|
|
534
|
+
trackEscapeKey(ctx2, _evt, { send }) {
|
|
535
|
+
if (!ctx2.closeOnEsc)
|
|
536
|
+
return;
|
|
537
|
+
const doc = dom.getDoc(ctx2);
|
|
538
|
+
return addDomEvent(doc, "keydown", (event) => {
|
|
539
|
+
if (event.key === "Escape") {
|
|
540
|
+
send("ESCAPE");
|
|
541
|
+
}
|
|
542
|
+
});
|
|
543
|
+
}
|
|
554
544
|
},
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
if (
|
|
561
|
-
|
|
545
|
+
actions: {
|
|
546
|
+
setGlobalId(ctx2) {
|
|
547
|
+
store.setId(ctx2.id);
|
|
548
|
+
},
|
|
549
|
+
clearGlobalId(ctx2) {
|
|
550
|
+
if (ctx2.id === store.id) {
|
|
551
|
+
store.setId(null);
|
|
552
|
+
}
|
|
553
|
+
},
|
|
554
|
+
invokeOnOpen(ctx2, evt) {
|
|
555
|
+
var _a;
|
|
556
|
+
const omit = ["TOOLTIP_POINTER_ENTER", "POINTER_ENTER"];
|
|
557
|
+
if (!omit.includes(evt.type)) {
|
|
558
|
+
(_a = ctx2.onOpen) == null ? void 0 : _a.call(ctx2);
|
|
559
|
+
}
|
|
560
|
+
},
|
|
561
|
+
invokeOnClose(ctx2, evt) {
|
|
562
|
+
var _a;
|
|
563
|
+
const omit = ["SETUP"];
|
|
564
|
+
if (!omit.includes(evt.type)) {
|
|
565
|
+
(_a = ctx2.onClose) == null ? void 0 : _a.call(ctx2);
|
|
562
566
|
}
|
|
563
|
-
});
|
|
564
|
-
}
|
|
565
|
-
},
|
|
566
|
-
actions: {
|
|
567
|
-
setupDocument(ctx2, evt) {
|
|
568
|
-
ctx2.id = evt.id;
|
|
569
|
-
if (evt.doc)
|
|
570
|
-
ctx2.doc = (0, import_core2.ref)(evt.doc);
|
|
571
|
-
if (evt.root)
|
|
572
|
-
ctx2.rootNode = (0, import_core2.ref)(evt.root);
|
|
573
|
-
},
|
|
574
|
-
setGlobalId(ctx2) {
|
|
575
|
-
store.setId(ctx2.id);
|
|
576
|
-
},
|
|
577
|
-
clearGlobalId(ctx2) {
|
|
578
|
-
if (ctx2.id === store.id) {
|
|
579
|
-
store.setId(null);
|
|
580
567
|
}
|
|
581
568
|
},
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
}
|
|
569
|
+
guards: {
|
|
570
|
+
closeOnPointerDown: (ctx2) => ctx2.closeOnPointerDown,
|
|
571
|
+
noVisibleTooltip: () => store.id === null,
|
|
572
|
+
isVisible: (ctx2) => ctx2.id === store.id,
|
|
573
|
+
isInteractive: (ctx2) => ctx2.interactive
|
|
588
574
|
},
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
if (!omit.includes(evt.type)) {
|
|
593
|
-
(_a = ctx2.onClose) == null ? void 0 : _a.call(ctx2);
|
|
594
|
-
}
|
|
575
|
+
delays: {
|
|
576
|
+
OPEN_DELAY: (ctx2) => ctx2.openDelay,
|
|
577
|
+
CLOSE_DELAY: (ctx2) => ctx2.closeDelay
|
|
595
578
|
}
|
|
596
|
-
},
|
|
597
|
-
guards: {
|
|
598
|
-
closeOnPointerDown: (ctx2) => ctx2.closeOnPointerDown,
|
|
599
|
-
noVisibleTooltip: () => store.id === null,
|
|
600
|
-
isVisible: (ctx2) => ctx2.id === store.id,
|
|
601
|
-
isInteractive: (ctx2) => ctx2.interactive
|
|
602
|
-
},
|
|
603
|
-
delays: {
|
|
604
|
-
OPEN_DELAY: (ctx2) => ctx2.openDelay,
|
|
605
|
-
CLOSE_DELAY: (ctx2) => ctx2.closeDelay
|
|
606
579
|
}
|
|
607
|
-
|
|
580
|
+
);
|
|
608
581
|
}
|
|
582
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
583
|
+
0 && (module.exports = {
|
|
584
|
+
connect,
|
|
585
|
+
machine
|
|
586
|
+
});
|