@zag-js/tooltip 0.10.5 → 0.11.0

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,122 @@
1
+ import * as _zag_js_anatomy from '@zag-js/anatomy';
2
+ import { PositioningOptions } from '@zag-js/popper';
3
+ export { Placement, PositioningOptions } from '@zag-js/popper';
4
+ import { RequiredBy, CommonProperties, RootProperties, PropTypes, NormalizeProps } from '@zag-js/types';
5
+ import * as _zag_js_core from '@zag-js/core';
6
+ import { StateMachine } from '@zag-js/core';
7
+
8
+ declare const anatomy: _zag_js_anatomy.AnatomyInstance<"trigger" | "arrow" | "arrowTip" | "positioner" | "content" | "label">;
9
+
10
+ type ElementIds = Partial<{
11
+ trigger: string;
12
+ content: string;
13
+ arrow: string;
14
+ positioner: string;
15
+ }>;
16
+ type PublicContext = CommonProperties & {
17
+ /**
18
+ * The ids of the elements in the tooltip. Useful for composition.
19
+ */
20
+ ids?: ElementIds;
21
+ /**
22
+ * The `id` of the tooltip.
23
+ */
24
+ id: string;
25
+ /**
26
+ * The open delay of the tooltip.
27
+ */
28
+ openDelay: number;
29
+ /**
30
+ * The close delay of the tooltip.
31
+ */
32
+ closeDelay: number;
33
+ /**
34
+ * Whether to close the tooltip on pointerdown.
35
+ */
36
+ closeOnPointerDown: boolean;
37
+ /**
38
+ * Whether to close the tooltip when the Escape key is pressed.
39
+ */
40
+ closeOnEsc?: boolean;
41
+ /**
42
+ * Whether the tooltip's content is interactive.
43
+ * In this mode, the tooltip will remain open when user hovers over the content.
44
+ * @see https://www.w3.org/TR/WCAG21/#content-on-hover-or-focus
45
+ */
46
+ interactive: boolean;
47
+ /**
48
+ * Function called when the tooltip is opened.
49
+ */
50
+ onOpen?: VoidFunction;
51
+ /**
52
+ * Function called when the tooltip is closed.
53
+ */
54
+ onClose?: VoidFunction;
55
+ /**
56
+ * Custom label for the tooltip.
57
+ */
58
+ "aria-label"?: string;
59
+ /**
60
+ * The user provided options used to position the popover content
61
+ */
62
+ positioning: PositioningOptions;
63
+ /**
64
+ * Whether the tooltip is disabled
65
+ */
66
+ disabled?: boolean;
67
+ /**
68
+ * Whether the tooltip is open
69
+ */
70
+ open?: boolean;
71
+ };
72
+ type UserDefinedContext = RequiredBy<PublicContext, "id">;
73
+ type ComputedContext = Readonly<{
74
+ /**
75
+ * @computed Whether an `aria-label` is set.
76
+ */
77
+ readonly hasAriaLabel: boolean;
78
+ }>;
79
+ type PrivateContext = RootProperties & {};
80
+ type MachineContext = PublicContext & ComputedContext & PrivateContext;
81
+ type MachineState = {
82
+ value: "opening" | "open" | "closing" | "closed";
83
+ tags: "open" | "closed";
84
+ };
85
+ type State = StateMachine.State<MachineContext, MachineState>;
86
+ type Send = StateMachine.Send<StateMachine.AnyEventObject>;
87
+
88
+ declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): {
89
+ /**
90
+ * Whether the tooltip is open.
91
+ */
92
+ isOpen: boolean;
93
+ /**
94
+ * Function to open the tooltip.
95
+ */
96
+ open(): void;
97
+ /**
98
+ * Function to close the tooltip.
99
+ */
100
+ close(): void;
101
+ /**
102
+ * Returns the animation state of the tooltip.
103
+ */
104
+ getAnimationState(): {
105
+ enter: boolean;
106
+ exit: boolean;
107
+ };
108
+ /**
109
+ * Function to reposition the popover
110
+ */
111
+ setPositioning(options?: Partial<PositioningOptions>): void;
112
+ triggerProps: T["button"];
113
+ arrowProps: T["element"];
114
+ arrowTipProps: T["element"];
115
+ positionerProps: T["element"];
116
+ contentProps: T["element"];
117
+ labelProps: T["element"];
118
+ };
119
+
120
+ declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
121
+
122
+ export { UserDefinedContext as Context, anatomy, connect, machine };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,122 @@
1
- export { anatomy } from "./tooltip.anatomy";
2
- export { connect } from "./tooltip.connect";
3
- export { machine } from "./tooltip.machine";
4
- export type { UserDefinedContext as Context, Placement, PositioningOptions } from "./tooltip.types";
1
+ import * as _zag_js_anatomy from '@zag-js/anatomy';
2
+ import { PositioningOptions } from '@zag-js/popper';
3
+ export { Placement, PositioningOptions } from '@zag-js/popper';
4
+ import { RequiredBy, CommonProperties, RootProperties, PropTypes, NormalizeProps } from '@zag-js/types';
5
+ import * as _zag_js_core from '@zag-js/core';
6
+ import { StateMachine } from '@zag-js/core';
7
+
8
+ declare const anatomy: _zag_js_anatomy.AnatomyInstance<"trigger" | "arrow" | "arrowTip" | "positioner" | "content" | "label">;
9
+
10
+ type ElementIds = Partial<{
11
+ trigger: string;
12
+ content: string;
13
+ arrow: string;
14
+ positioner: string;
15
+ }>;
16
+ type PublicContext = CommonProperties & {
17
+ /**
18
+ * The ids of the elements in the tooltip. Useful for composition.
19
+ */
20
+ ids?: ElementIds;
21
+ /**
22
+ * The `id` of the tooltip.
23
+ */
24
+ id: string;
25
+ /**
26
+ * The open delay of the tooltip.
27
+ */
28
+ openDelay: number;
29
+ /**
30
+ * The close delay of the tooltip.
31
+ */
32
+ closeDelay: number;
33
+ /**
34
+ * Whether to close the tooltip on pointerdown.
35
+ */
36
+ closeOnPointerDown: boolean;
37
+ /**
38
+ * Whether to close the tooltip when the Escape key is pressed.
39
+ */
40
+ closeOnEsc?: boolean;
41
+ /**
42
+ * Whether the tooltip's content is interactive.
43
+ * In this mode, the tooltip will remain open when user hovers over the content.
44
+ * @see https://www.w3.org/TR/WCAG21/#content-on-hover-or-focus
45
+ */
46
+ interactive: boolean;
47
+ /**
48
+ * Function called when the tooltip is opened.
49
+ */
50
+ onOpen?: VoidFunction;
51
+ /**
52
+ * Function called when the tooltip is closed.
53
+ */
54
+ onClose?: VoidFunction;
55
+ /**
56
+ * Custom label for the tooltip.
57
+ */
58
+ "aria-label"?: string;
59
+ /**
60
+ * The user provided options used to position the popover content
61
+ */
62
+ positioning: PositioningOptions;
63
+ /**
64
+ * Whether the tooltip is disabled
65
+ */
66
+ disabled?: boolean;
67
+ /**
68
+ * Whether the tooltip is open
69
+ */
70
+ open?: boolean;
71
+ };
72
+ type UserDefinedContext = RequiredBy<PublicContext, "id">;
73
+ type ComputedContext = Readonly<{
74
+ /**
75
+ * @computed Whether an `aria-label` is set.
76
+ */
77
+ readonly hasAriaLabel: boolean;
78
+ }>;
79
+ type PrivateContext = RootProperties & {};
80
+ type MachineContext = PublicContext & ComputedContext & PrivateContext;
81
+ type MachineState = {
82
+ value: "opening" | "open" | "closing" | "closed";
83
+ tags: "open" | "closed";
84
+ };
85
+ type State = StateMachine.State<MachineContext, MachineState>;
86
+ type Send = StateMachine.Send<StateMachine.AnyEventObject>;
87
+
88
+ declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): {
89
+ /**
90
+ * Whether the tooltip is open.
91
+ */
92
+ isOpen: boolean;
93
+ /**
94
+ * Function to open the tooltip.
95
+ */
96
+ open(): void;
97
+ /**
98
+ * Function to close the tooltip.
99
+ */
100
+ close(): void;
101
+ /**
102
+ * Returns the animation state of the tooltip.
103
+ */
104
+ getAnimationState(): {
105
+ enter: boolean;
106
+ exit: boolean;
107
+ };
108
+ /**
109
+ * Function to reposition the popover
110
+ */
111
+ setPositioning(options?: Partial<PositioningOptions>): void;
112
+ triggerProps: T["button"];
113
+ arrowProps: T["element"];
114
+ arrowTipProps: T["element"];
115
+ positionerProps: T["element"];
116
+ contentProps: T["element"];
117
+ labelProps: T["element"];
118
+ };
119
+
120
+ declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
121
+
122
+ export { UserDefinedContext as Context, anatomy, connect, machine };
package/dist/index.js CHANGED
@@ -1,13 +1,452 @@
1
- 'use strict';
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);
2
19
 
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ anatomy: () => anatomy,
24
+ connect: () => connect,
25
+ machine: () => machine
26
+ });
27
+ module.exports = __toCommonJS(src_exports);
4
28
 
5
- const tooltip_anatomy = require('./tooltip.anatomy.js');
6
- const tooltip_connect = require('./tooltip.connect.js');
7
- const tooltip_machine = require('./tooltip.machine.js');
29
+ // src/tooltip.anatomy.ts
30
+ var import_anatomy = require("@zag-js/anatomy");
31
+ var anatomy = (0, import_anatomy.createAnatomy)("tooltip").parts("trigger", "arrow", "arrowTip", "positioner", "content", "label");
32
+ var parts = anatomy.build();
8
33
 
34
+ // src/tooltip.connect.ts
35
+ var import_dom_query2 = require("@zag-js/dom-query");
36
+ var import_popper = require("@zag-js/popper");
37
+ var import_visually_hidden = require("@zag-js/visually-hidden");
9
38
 
39
+ // src/tooltip.dom.ts
40
+ var import_dom_query = require("@zag-js/dom-query");
41
+ var dom = (0, import_dom_query.createScope)({
42
+ getTriggerId: (ctx) => ctx.ids?.trigger ?? `tooltip:${ctx.id}:trigger`,
43
+ getContentId: (ctx) => ctx.ids?.content ?? `tooltip:${ctx.id}:content`,
44
+ getArrowId: (ctx) => ctx.ids?.arrow ?? `tooltip:${ctx.id}:arrow`,
45
+ getPositionerId: (ctx) => ctx.ids?.positioner ?? `tooltip:${ctx.id}:popper`,
46
+ getTriggerEl: (ctx) => dom.getById(ctx, dom.getTriggerId(ctx)),
47
+ getContentEl: (ctx) => dom.getById(ctx, dom.getContentId(ctx)),
48
+ getPositionerEl: (ctx) => dom.getById(ctx, dom.getPositionerId(ctx)),
49
+ getArrowEl: (ctx) => dom.getById(ctx, dom.getArrowId(ctx)),
50
+ getScrollParent: (ctx) => (0, import_dom_query.getScrollParent)(dom.getTriggerEl(ctx))
51
+ });
10
52
 
11
- exports.anatomy = tooltip_anatomy.anatomy;
12
- exports.connect = tooltip_connect.connect;
13
- exports.machine = tooltip_machine.machine;
53
+ // src/tooltip.store.ts
54
+ var import_core = require("@zag-js/core");
55
+ var store = (0, import_core.proxy)({
56
+ id: null,
57
+ prevId: null,
58
+ setId(val) {
59
+ this.prevId = this.id;
60
+ this.id = val;
61
+ }
62
+ });
63
+
64
+ // src/tooltip.connect.ts
65
+ function connect(state, send, normalize) {
66
+ const id = state.context.id;
67
+ const hasAriaLabel = state.context.hasAriaLabel;
68
+ const isOpen = state.hasTag("open");
69
+ const triggerId = dom.getTriggerId(state.context);
70
+ const contentId = dom.getContentId(state.context);
71
+ const isDisabled = state.context.disabled;
72
+ const popperStyles = (0, import_popper.getPlacementStyles)({
73
+ placement: state.context.currentPlacement
74
+ });
75
+ return {
76
+ /**
77
+ * Whether the tooltip is open.
78
+ */
79
+ isOpen,
80
+ /**
81
+ * Function to open the tooltip.
82
+ */
83
+ open() {
84
+ send("OPEN");
85
+ },
86
+ /**
87
+ * Function to close the tooltip.
88
+ */
89
+ close() {
90
+ send("CLOSE");
91
+ },
92
+ /**
93
+ * Returns the animation state of the tooltip.
94
+ */
95
+ getAnimationState() {
96
+ return {
97
+ enter: store.prevId === null && id === store.id,
98
+ exit: store.id === null
99
+ };
100
+ },
101
+ /**
102
+ * Function to reposition the popover
103
+ */
104
+ setPositioning(options = {}) {
105
+ send({ type: "SET_POSITIONING", options });
106
+ },
107
+ triggerProps: normalize.button({
108
+ ...parts.trigger.attrs,
109
+ id: triggerId,
110
+ "data-expanded": (0, import_dom_query2.dataAttr)(isOpen),
111
+ "aria-describedby": isOpen ? contentId : void 0,
112
+ onClick() {
113
+ send("CLICK");
114
+ },
115
+ onFocus() {
116
+ send("FOCUS");
117
+ },
118
+ onBlur() {
119
+ if (id === store.id) {
120
+ send("BLUR");
121
+ }
122
+ },
123
+ onPointerDown() {
124
+ if (isDisabled)
125
+ return;
126
+ if (id === store.id) {
127
+ send("POINTER_DOWN");
128
+ }
129
+ },
130
+ onPointerMove(event) {
131
+ if (isDisabled || event.pointerType === "touch")
132
+ return;
133
+ send("POINTER_MOVE");
134
+ },
135
+ onPointerLeave() {
136
+ if (isDisabled)
137
+ return;
138
+ send("POINTER_LEAVE");
139
+ },
140
+ onPointerCancel() {
141
+ if (isDisabled)
142
+ return;
143
+ send("POINTER_LEAVE");
144
+ }
145
+ }),
146
+ arrowProps: normalize.element({
147
+ id: dom.getArrowId(state.context),
148
+ ...parts.arrow.attrs,
149
+ style: popperStyles.arrow
150
+ }),
151
+ arrowTipProps: normalize.element({
152
+ ...parts.arrowTip.attrs,
153
+ style: popperStyles.arrowTip
154
+ }),
155
+ positionerProps: normalize.element({
156
+ id: dom.getPositionerId(state.context),
157
+ ...parts.positioner.attrs,
158
+ style: popperStyles.floating
159
+ }),
160
+ contentProps: normalize.element({
161
+ ...parts.content.attrs,
162
+ hidden: !isOpen,
163
+ role: hasAriaLabel ? void 0 : "tooltip",
164
+ id: hasAriaLabel ? void 0 : contentId,
165
+ "data-placement": state.context.currentPlacement,
166
+ onPointerEnter() {
167
+ send("CONTENT.POINTER_MOVE");
168
+ },
169
+ onPointerLeave() {
170
+ send("CONTENT.POINTER_LEAVE");
171
+ },
172
+ style: {
173
+ pointerEvents: state.context.interactive ? "auto" : "none"
174
+ }
175
+ }),
176
+ labelProps: normalize.element({
177
+ ...parts.label.attrs,
178
+ id: contentId,
179
+ role: "tooltip",
180
+ style: import_visually_hidden.visuallyHiddenStyle,
181
+ children: state.context["aria-label"]
182
+ })
183
+ };
184
+ }
185
+
186
+ // src/tooltip.machine.ts
187
+ var import_core2 = require("@zag-js/core");
188
+ var import_dom_event = require("@zag-js/dom-event");
189
+ var import_dom_query3 = require("@zag-js/dom-query");
190
+ var import_popper2 = require("@zag-js/popper");
191
+ var import_utils = require("@zag-js/utils");
192
+ var { and, not } = import_core2.guards;
193
+ function machine(userContext) {
194
+ const ctx = (0, import_utils.compact)(userContext);
195
+ return (0, import_core2.createMachine)(
196
+ {
197
+ id: "tooltip",
198
+ initial: "closed",
199
+ context: {
200
+ openDelay: 1e3,
201
+ closeDelay: 500,
202
+ closeOnPointerDown: true,
203
+ closeOnEsc: true,
204
+ interactive: true,
205
+ currentPlacement: void 0,
206
+ ...ctx,
207
+ hasPointerMoveOpened: false,
208
+ positioning: {
209
+ placement: "bottom",
210
+ ...ctx.positioning
211
+ }
212
+ },
213
+ computed: {
214
+ hasAriaLabel: (ctx2) => !!ctx2["aria-label"]
215
+ },
216
+ watch: {
217
+ disabled: ["closeIfDisabled"],
218
+ open: ["toggleVisibility"]
219
+ },
220
+ on: {
221
+ OPEN: "open",
222
+ CLOSE: "closed"
223
+ },
224
+ states: {
225
+ closed: {
226
+ tags: ["closed"],
227
+ entry: ["clearGlobalId", "invokeOnClose"],
228
+ on: {
229
+ FOCUS: "open",
230
+ POINTER_LEAVE: {
231
+ actions: ["clearPointerMoveOpened"]
232
+ },
233
+ POINTER_MOVE: [
234
+ {
235
+ guard: and("noVisibleTooltip", not("hasPointerMoveOpened")),
236
+ target: "opening"
237
+ },
238
+ {
239
+ guard: not("hasPointerMoveOpened"),
240
+ target: "open",
241
+ actions: ["setPointerMoveOpened"]
242
+ }
243
+ ]
244
+ }
245
+ },
246
+ opening: {
247
+ tags: ["closed"],
248
+ activities: ["trackScroll", "trackPointerlockChange"],
249
+ after: {
250
+ OPEN_DELAY: {
251
+ target: "open",
252
+ actions: ["setPointerMoveOpened"]
253
+ }
254
+ },
255
+ on: {
256
+ POINTER_LEAVE: {
257
+ target: "closed",
258
+ actions: ["clearPointerMoveOpened"]
259
+ },
260
+ BLUR: "closed",
261
+ SCROLL: "closed",
262
+ POINTER_LOCK_CHANGE: "closed",
263
+ POINTER_DOWN: {
264
+ guard: "closeOnPointerDown",
265
+ target: "closed"
266
+ }
267
+ }
268
+ },
269
+ open: {
270
+ tags: ["open"],
271
+ activities: [
272
+ "trackEscapeKey",
273
+ "trackDisabledTriggerOnSafari",
274
+ "trackScroll",
275
+ "trackPointerlockChange",
276
+ "trackPositioning"
277
+ ],
278
+ entry: ["setGlobalId", "invokeOnOpen"],
279
+ on: {
280
+ POINTER_LEAVE: [
281
+ {
282
+ guard: "isVisible",
283
+ target: "closing",
284
+ actions: ["clearPointerMoveOpened"]
285
+ },
286
+ {
287
+ target: "closed",
288
+ actions: ["clearPointerMoveOpened"]
289
+ }
290
+ ],
291
+ BLUR: "closed",
292
+ ESCAPE: "closed",
293
+ SCROLL: "closed",
294
+ POINTER_LOCK_CHANGE: "closed",
295
+ "CONTENT.POINTER_LEAVE": {
296
+ guard: "isInteractive",
297
+ target: "closing"
298
+ },
299
+ POINTER_DOWN: {
300
+ guard: "closeOnPointerDown",
301
+ target: "closed"
302
+ },
303
+ CLICK: "closed",
304
+ SET_POSITIONING: {
305
+ actions: "setPositioning"
306
+ }
307
+ }
308
+ },
309
+ closing: {
310
+ tags: ["open"],
311
+ activities: ["trackStore", "trackPositioning"],
312
+ after: {
313
+ CLOSE_DELAY: "closed"
314
+ },
315
+ on: {
316
+ FORCE_CLOSE: "closed",
317
+ POINTER_MOVE: {
318
+ target: "open",
319
+ actions: ["setPointerMoveOpened"]
320
+ },
321
+ "CONTENT.POINTER_MOVE": {
322
+ guard: "isInteractive",
323
+ target: "open"
324
+ }
325
+ }
326
+ }
327
+ }
328
+ },
329
+ {
330
+ activities: {
331
+ trackPositioning(ctx2) {
332
+ ctx2.currentPlacement = ctx2.positioning.placement;
333
+ const getPositionerEl = () => dom.getPositionerEl(ctx2);
334
+ return (0, import_popper2.getPlacement)(dom.getTriggerEl(ctx2), getPositionerEl, {
335
+ ...ctx2.positioning,
336
+ defer: true,
337
+ onComplete(data) {
338
+ ctx2.currentPlacement = data.placement;
339
+ },
340
+ onCleanup() {
341
+ ctx2.currentPlacement = void 0;
342
+ }
343
+ });
344
+ },
345
+ trackPointerlockChange(ctx2, _evt, { send }) {
346
+ const onChange = () => send("POINTER_LOCK_CHANGE");
347
+ return (0, import_dom_event.addDomEvent)(dom.getDoc(ctx2), "pointerlockchange", onChange, false);
348
+ },
349
+ trackScroll(ctx2, _evt, { send }) {
350
+ const trigger = dom.getTriggerEl(ctx2);
351
+ if (!trigger)
352
+ return;
353
+ const cleanups = (0, import_dom_query3.getScrollParents)(trigger).map((el) => {
354
+ const opts = { passive: true, capture: true };
355
+ return (0, import_dom_event.addDomEvent)(el, "scroll", () => send("SCROLL"), opts);
356
+ });
357
+ return () => {
358
+ cleanups.forEach((fn) => fn?.());
359
+ };
360
+ },
361
+ trackStore(ctx2, _evt, { send }) {
362
+ return (0, import_core2.subscribe)(store, () => {
363
+ if (store.id !== ctx2.id) {
364
+ send("FORCE_CLOSE");
365
+ }
366
+ });
367
+ },
368
+ trackDisabledTriggerOnSafari(ctx2, _evt, { send }) {
369
+ if (!(0, import_dom_query3.isSafari)())
370
+ return;
371
+ const doc = dom.getDoc(ctx2);
372
+ return (0, import_dom_event.addDomEvent)(doc, "pointermove", (event) => {
373
+ const selector = "[data-part=trigger][data-expanded]";
374
+ if ((0, import_dom_query3.isHTMLElement)(event.target) && event.target.closest(selector))
375
+ return;
376
+ send("POINTER_LEAVE");
377
+ });
378
+ },
379
+ trackEscapeKey(ctx2, _evt, { send }) {
380
+ if (!ctx2.closeOnEsc)
381
+ return;
382
+ const doc = dom.getDoc(ctx2);
383
+ return (0, import_dom_event.addDomEvent)(doc, "keydown", (event) => {
384
+ if (event.key === "Escape") {
385
+ send("ESCAPE");
386
+ }
387
+ });
388
+ }
389
+ },
390
+ actions: {
391
+ setGlobalId(ctx2) {
392
+ store.setId(ctx2.id);
393
+ },
394
+ clearGlobalId(ctx2) {
395
+ if (ctx2.id === store.id) {
396
+ store.setId(null);
397
+ }
398
+ },
399
+ invokeOnOpen(ctx2, evt) {
400
+ const omit = ["CONTENT.POINTER_MOVE", "POINTER_MOVE"];
401
+ if (!omit.includes(evt.type)) {
402
+ ctx2.onOpen?.();
403
+ }
404
+ },
405
+ invokeOnClose(ctx2) {
406
+ ctx2.onClose?.();
407
+ },
408
+ closeIfDisabled(ctx2, _evt, { send }) {
409
+ if (!ctx2.disabled)
410
+ return;
411
+ send("CLOSE");
412
+ },
413
+ setPositioning(ctx2, evt) {
414
+ const getPositionerEl = () => dom.getPositionerEl(ctx2);
415
+ (0, import_popper2.getPlacement)(dom.getTriggerEl(ctx2), getPositionerEl, {
416
+ ...ctx2.positioning,
417
+ ...evt.options,
418
+ defer: true,
419
+ listeners: false
420
+ });
421
+ },
422
+ toggleVisibility(ctx2, _evt, { send }) {
423
+ send({ type: ctx2.open ? "OPEN" : "CLOSE", src: "controlled" });
424
+ },
425
+ setPointerMoveOpened(ctx2) {
426
+ ctx2.hasPointerMoveOpened = true;
427
+ },
428
+ clearPointerMoveOpened(ctx2) {
429
+ ctx2.hasPointerMoveOpened = false;
430
+ }
431
+ },
432
+ guards: {
433
+ closeOnPointerDown: (ctx2) => ctx2.closeOnPointerDown,
434
+ noVisibleTooltip: () => store.id === null,
435
+ isVisible: (ctx2) => ctx2.id === store.id,
436
+ isInteractive: (ctx2) => ctx2.interactive,
437
+ hasPointerMoveOpened: (ctx2) => !!ctx2.hasPointerMoveOpened
438
+ },
439
+ delays: {
440
+ OPEN_DELAY: (ctx2) => ctx2.openDelay,
441
+ CLOSE_DELAY: (ctx2) => ctx2.closeDelay
442
+ }
443
+ }
444
+ );
445
+ }
446
+ // Annotate the CommonJS export names for ESM import in node:
447
+ 0 && (module.exports = {
448
+ anatomy,
449
+ connect,
450
+ machine
451
+ });
452
+ //# sourceMappingURL=index.js.map