@zag-js/tooltip 0.53.0 → 0.54.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.
- package/dist/index.d.mts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +521 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +490 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
- package/src/tooltip.connect.ts +84 -74
- package/src/tooltip.types.ts +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -108,11 +108,11 @@ interface MachineApi<T extends PropTypes = PropTypes> {
|
|
|
108
108
|
* Function to reposition the popover
|
|
109
109
|
*/
|
|
110
110
|
reposition(options?: Partial<PositioningOptions>): void;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
111
|
+
getTriggerProps(): T["button"];
|
|
112
|
+
getArrowProps(): T["element"];
|
|
113
|
+
getArrowTipProps(): T["element"];
|
|
114
|
+
getPositionerProps(): T["element"];
|
|
115
|
+
getContentProps(): T["element"];
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): MachineApi<T>;
|
package/dist/index.d.ts
CHANGED
|
@@ -108,11 +108,11 @@ interface MachineApi<T extends PropTypes = PropTypes> {
|
|
|
108
108
|
* Function to reposition the popover
|
|
109
109
|
*/
|
|
110
110
|
reposition(options?: Partial<PositioningOptions>): void;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
111
|
+
getTriggerProps(): T["button"];
|
|
112
|
+
getArrowProps(): T["element"];
|
|
113
|
+
getArrowTipProps(): T["element"];
|
|
114
|
+
getPositionerProps(): T["element"];
|
|
115
|
+
getContentProps(): T["element"];
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): MachineApi<T>;
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,522 @@
|
|
|
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);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
anatomy: () => anatomy,
|
|
24
|
+
connect: () => connect,
|
|
25
|
+
machine: () => machine,
|
|
26
|
+
props: () => props,
|
|
27
|
+
splitProps: () => splitProps
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(src_exports);
|
|
30
|
+
|
|
31
|
+
// src/tooltip.anatomy.ts
|
|
32
|
+
var import_anatomy = require("@zag-js/anatomy");
|
|
33
|
+
var anatomy = (0, import_anatomy.createAnatomy)("tooltip").parts("trigger", "arrow", "arrowTip", "positioner", "content");
|
|
34
|
+
var parts = anatomy.build();
|
|
35
|
+
|
|
36
|
+
// src/tooltip.connect.ts
|
|
37
|
+
var import_dom_query2 = require("@zag-js/dom-query");
|
|
38
|
+
var import_popper = require("@zag-js/popper");
|
|
39
|
+
|
|
40
|
+
// src/tooltip.dom.ts
|
|
41
|
+
var import_dom_query = require("@zag-js/dom-query");
|
|
42
|
+
var dom = (0, import_dom_query.createScope)({
|
|
43
|
+
getTriggerId: (ctx) => ctx.ids?.trigger ?? `tooltip:${ctx.id}:trigger`,
|
|
44
|
+
getContentId: (ctx) => ctx.ids?.content ?? `tooltip:${ctx.id}:content`,
|
|
45
|
+
getArrowId: (ctx) => ctx.ids?.arrow ?? `tooltip:${ctx.id}:arrow`,
|
|
46
|
+
getPositionerId: (ctx) => ctx.ids?.positioner ?? `tooltip:${ctx.id}:popper`,
|
|
47
|
+
getTriggerEl: (ctx) => dom.getById(ctx, dom.getTriggerId(ctx)),
|
|
48
|
+
getContentEl: (ctx) => dom.getById(ctx, dom.getContentId(ctx)),
|
|
49
|
+
getPositionerEl: (ctx) => dom.getById(ctx, dom.getPositionerId(ctx)),
|
|
50
|
+
getArrowEl: (ctx) => dom.getById(ctx, dom.getArrowId(ctx))
|
|
51
|
+
});
|
|
52
|
+
|
|
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 open = state.hasTag("open");
|
|
69
|
+
const triggerId = dom.getTriggerId(state.context);
|
|
70
|
+
const contentId = dom.getContentId(state.context);
|
|
71
|
+
const disabled = state.context.disabled;
|
|
72
|
+
const popperStyles = (0, import_popper.getPlacementStyles)({
|
|
73
|
+
...state.context.positioning,
|
|
74
|
+
placement: state.context.currentPlacement
|
|
75
|
+
});
|
|
76
|
+
return {
|
|
77
|
+
open,
|
|
78
|
+
setOpen(nextOpen) {
|
|
79
|
+
if (nextOpen === open)
|
|
80
|
+
return;
|
|
81
|
+
send(nextOpen ? "OPEN" : "CLOSE");
|
|
82
|
+
},
|
|
83
|
+
reposition(options = {}) {
|
|
84
|
+
send({ type: "POSITIONING.SET", options });
|
|
85
|
+
},
|
|
86
|
+
getTriggerProps() {
|
|
87
|
+
return normalize.button({
|
|
88
|
+
...parts.trigger.attrs,
|
|
89
|
+
id: triggerId,
|
|
90
|
+
dir: state.context.dir,
|
|
91
|
+
"data-expanded": (0, import_dom_query2.dataAttr)(open),
|
|
92
|
+
"data-state": open ? "open" : "closed",
|
|
93
|
+
"aria-describedby": open ? contentId : void 0,
|
|
94
|
+
onClick() {
|
|
95
|
+
if (disabled)
|
|
96
|
+
return;
|
|
97
|
+
send("CLOSE");
|
|
98
|
+
},
|
|
99
|
+
onFocus() {
|
|
100
|
+
if (disabled || state.event.type === "POINTER_DOWN")
|
|
101
|
+
return;
|
|
102
|
+
send("OPEN");
|
|
103
|
+
},
|
|
104
|
+
onBlur() {
|
|
105
|
+
if (disabled)
|
|
106
|
+
return;
|
|
107
|
+
if (id === store.id) {
|
|
108
|
+
send("CLOSE");
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
onPointerDown() {
|
|
112
|
+
if (disabled || !state.context.closeOnPointerDown)
|
|
113
|
+
return;
|
|
114
|
+
if (id === store.id) {
|
|
115
|
+
send("CLOSE");
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
onPointerMove(event) {
|
|
119
|
+
if (disabled || event.pointerType === "touch")
|
|
120
|
+
return;
|
|
121
|
+
send("POINTER_MOVE");
|
|
122
|
+
},
|
|
123
|
+
onPointerLeave() {
|
|
124
|
+
if (disabled)
|
|
125
|
+
return;
|
|
126
|
+
send("POINTER_LEAVE");
|
|
127
|
+
},
|
|
128
|
+
onPointerCancel() {
|
|
129
|
+
if (disabled)
|
|
130
|
+
return;
|
|
131
|
+
send("POINTER_LEAVE");
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
},
|
|
135
|
+
getArrowProps() {
|
|
136
|
+
return normalize.element({
|
|
137
|
+
id: dom.getArrowId(state.context),
|
|
138
|
+
...parts.arrow.attrs,
|
|
139
|
+
dir: state.context.dir,
|
|
140
|
+
style: popperStyles.arrow
|
|
141
|
+
});
|
|
142
|
+
},
|
|
143
|
+
getArrowTipProps() {
|
|
144
|
+
return normalize.element({
|
|
145
|
+
...parts.arrowTip.attrs,
|
|
146
|
+
dir: state.context.dir,
|
|
147
|
+
style: popperStyles.arrowTip
|
|
148
|
+
});
|
|
149
|
+
},
|
|
150
|
+
getPositionerProps() {
|
|
151
|
+
return normalize.element({
|
|
152
|
+
id: dom.getPositionerId(state.context),
|
|
153
|
+
...parts.positioner.attrs,
|
|
154
|
+
dir: state.context.dir,
|
|
155
|
+
style: popperStyles.floating
|
|
156
|
+
});
|
|
157
|
+
},
|
|
158
|
+
getContentProps() {
|
|
159
|
+
return normalize.element({
|
|
160
|
+
...parts.content.attrs,
|
|
161
|
+
dir: state.context.dir,
|
|
162
|
+
hidden: !open,
|
|
163
|
+
"data-state": open ? "open" : "closed",
|
|
164
|
+
role: hasAriaLabel ? void 0 : "tooltip",
|
|
165
|
+
id: hasAriaLabel ? void 0 : contentId,
|
|
166
|
+
"data-placement": state.context.currentPlacement,
|
|
167
|
+
onPointerEnter() {
|
|
168
|
+
send("CONTENT.POINTER_MOVE");
|
|
169
|
+
},
|
|
170
|
+
onPointerLeave() {
|
|
171
|
+
send("CONTENT.POINTER_LEAVE");
|
|
172
|
+
},
|
|
173
|
+
style: {
|
|
174
|
+
pointerEvents: state.context.interactive ? "auto" : "none"
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// src/tooltip.machine.ts
|
|
182
|
+
var import_core2 = require("@zag-js/core");
|
|
183
|
+
var import_dom_event = require("@zag-js/dom-event");
|
|
184
|
+
var import_dom_query3 = require("@zag-js/dom-query");
|
|
185
|
+
var import_popper2 = require("@zag-js/popper");
|
|
186
|
+
var import_utils = require("@zag-js/utils");
|
|
187
|
+
var { and, not } = import_core2.guards;
|
|
188
|
+
function machine(userContext) {
|
|
189
|
+
const ctx = (0, import_utils.compact)(userContext);
|
|
190
|
+
return (0, import_core2.createMachine)(
|
|
191
|
+
{
|
|
192
|
+
id: "tooltip",
|
|
193
|
+
initial: ctx.open ? "open" : "closed",
|
|
194
|
+
context: {
|
|
195
|
+
openDelay: 1e3,
|
|
196
|
+
closeDelay: 500,
|
|
197
|
+
closeOnPointerDown: true,
|
|
198
|
+
closeOnEscape: true,
|
|
199
|
+
interactive: false,
|
|
200
|
+
...ctx,
|
|
201
|
+
currentPlacement: void 0,
|
|
202
|
+
hasPointerMoveOpened: false,
|
|
203
|
+
positioning: {
|
|
204
|
+
placement: "bottom",
|
|
205
|
+
...ctx.positioning
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
computed: {
|
|
209
|
+
hasAriaLabel: (ctx2) => !!ctx2["aria-label"]
|
|
210
|
+
},
|
|
211
|
+
watch: {
|
|
212
|
+
disabled: ["closeIfDisabled"],
|
|
213
|
+
open: ["toggleVisibility"]
|
|
214
|
+
},
|
|
215
|
+
states: {
|
|
216
|
+
closed: {
|
|
217
|
+
tags: ["closed"],
|
|
218
|
+
entry: ["clearGlobalId"],
|
|
219
|
+
on: {
|
|
220
|
+
"CONTROLLED.OPEN": "open",
|
|
221
|
+
OPEN: {
|
|
222
|
+
target: "open",
|
|
223
|
+
actions: ["invokeOnOpen"]
|
|
224
|
+
},
|
|
225
|
+
POINTER_LEAVE: {
|
|
226
|
+
actions: ["clearPointerMoveOpened"]
|
|
227
|
+
},
|
|
228
|
+
POINTER_MOVE: [
|
|
229
|
+
{
|
|
230
|
+
guard: and("noVisibleTooltip", not("hasPointerMoveOpened")),
|
|
231
|
+
target: "opening"
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
guard: not("hasPointerMoveOpened"),
|
|
235
|
+
target: "open",
|
|
236
|
+
actions: ["setPointerMoveOpened", "invokeOnOpen"]
|
|
237
|
+
}
|
|
238
|
+
]
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
opening: {
|
|
242
|
+
tags: ["closed"],
|
|
243
|
+
activities: ["trackScroll", "trackPointerlockChange"],
|
|
244
|
+
after: {
|
|
245
|
+
OPEN_DELAY: [
|
|
246
|
+
{
|
|
247
|
+
guard: "isOpenControlled",
|
|
248
|
+
actions: ["setPointerMoveOpened", "invokeOnOpen"]
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
target: "open",
|
|
252
|
+
actions: ["setPointerMoveOpened", "invokeOnOpen"]
|
|
253
|
+
}
|
|
254
|
+
]
|
|
255
|
+
},
|
|
256
|
+
on: {
|
|
257
|
+
"CONTROLLED.OPEN": "open",
|
|
258
|
+
"CONTROLLED.CLOSE": "closed",
|
|
259
|
+
OPEN: [
|
|
260
|
+
{
|
|
261
|
+
guard: "isOpenControlled",
|
|
262
|
+
actions: ["invokeOnOpen"]
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
target: "open",
|
|
266
|
+
actions: ["invokeOnOpen"]
|
|
267
|
+
}
|
|
268
|
+
],
|
|
269
|
+
POINTER_LEAVE: [
|
|
270
|
+
{
|
|
271
|
+
guard: "isOpenControlled",
|
|
272
|
+
actions: ["clearPointerMoveOpened", "invokeOnClose"]
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
target: "closed",
|
|
276
|
+
actions: ["clearPointerMoveOpened", "invokeOnClose"]
|
|
277
|
+
}
|
|
278
|
+
],
|
|
279
|
+
CLOSE: {
|
|
280
|
+
target: "closed",
|
|
281
|
+
actions: ["invokeOnClose"]
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
open: {
|
|
286
|
+
tags: ["open"],
|
|
287
|
+
activities: [
|
|
288
|
+
"trackEscapeKey",
|
|
289
|
+
"trackDisabledTriggerOnSafari",
|
|
290
|
+
"trackScroll",
|
|
291
|
+
"trackPointerlockChange",
|
|
292
|
+
"trackPositioning"
|
|
293
|
+
],
|
|
294
|
+
entry: ["setGlobalId"],
|
|
295
|
+
on: {
|
|
296
|
+
"CONTROLLED.CLOSE": "closed",
|
|
297
|
+
CLOSE: {
|
|
298
|
+
target: "closed",
|
|
299
|
+
actions: ["invokeOnClose"]
|
|
300
|
+
},
|
|
301
|
+
POINTER_LEAVE: [
|
|
302
|
+
{
|
|
303
|
+
guard: "isVisible",
|
|
304
|
+
target: "closing",
|
|
305
|
+
actions: ["clearPointerMoveOpened"]
|
|
306
|
+
},
|
|
307
|
+
// == group ==
|
|
308
|
+
{
|
|
309
|
+
guard: "isOpenControlled",
|
|
310
|
+
actions: ["clearPointerMoveOpened", "invokeOnClose"]
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
target: "closed",
|
|
314
|
+
actions: ["clearPointerMoveOpened", "invokeOnClose"]
|
|
315
|
+
}
|
|
316
|
+
],
|
|
317
|
+
"CONTENT.POINTER_LEAVE": {
|
|
318
|
+
guard: "isInteractive",
|
|
319
|
+
target: "closing"
|
|
320
|
+
},
|
|
321
|
+
"POSITIONING.SET": {
|
|
322
|
+
actions: "reposition"
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
},
|
|
326
|
+
closing: {
|
|
327
|
+
tags: ["open"],
|
|
328
|
+
activities: ["trackStore", "trackPositioning"],
|
|
329
|
+
after: {
|
|
330
|
+
CLOSE_DELAY: [
|
|
331
|
+
{
|
|
332
|
+
guard: "isOpenControlled",
|
|
333
|
+
actions: ["invokeOnClose"]
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
target: "closed",
|
|
337
|
+
actions: ["invokeOnClose"]
|
|
338
|
+
}
|
|
339
|
+
]
|
|
340
|
+
},
|
|
341
|
+
on: {
|
|
342
|
+
"CONTROLLED.CLOSE": "closed",
|
|
343
|
+
"CONTROLLED.OPEN": "open",
|
|
344
|
+
CLOSE: [
|
|
345
|
+
{
|
|
346
|
+
guard: "isOpenControlled",
|
|
347
|
+
actions: ["invokeOnClose"]
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
target: "closed",
|
|
351
|
+
actions: ["invokeOnClose"]
|
|
352
|
+
}
|
|
353
|
+
],
|
|
354
|
+
POINTER_MOVE: [
|
|
355
|
+
{
|
|
356
|
+
guard: "isOpenControlled",
|
|
357
|
+
actions: ["setPointerMoveOpened", "invokeOnOpen"]
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
target: "open",
|
|
361
|
+
actions: ["setPointerMoveOpened", "invokeOnOpen"]
|
|
362
|
+
}
|
|
363
|
+
],
|
|
364
|
+
"CONTENT.POINTER_MOVE": {
|
|
365
|
+
guard: "isInteractive",
|
|
366
|
+
target: "open"
|
|
367
|
+
},
|
|
368
|
+
"POSITIONING.SET": {
|
|
369
|
+
actions: "reposition"
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
activities: {
|
|
377
|
+
trackPositioning(ctx2) {
|
|
378
|
+
ctx2.currentPlacement = ctx2.positioning.placement;
|
|
379
|
+
const getPositionerEl = () => dom.getPositionerEl(ctx2);
|
|
380
|
+
return (0, import_popper2.getPlacement)(dom.getTriggerEl(ctx2), getPositionerEl, {
|
|
381
|
+
...ctx2.positioning,
|
|
382
|
+
defer: true,
|
|
383
|
+
onComplete(data) {
|
|
384
|
+
ctx2.currentPlacement = data.placement;
|
|
385
|
+
}
|
|
386
|
+
});
|
|
387
|
+
},
|
|
388
|
+
trackPointerlockChange(ctx2, _evt, { send }) {
|
|
389
|
+
const onChange = () => send({ type: "CLOSE", src: "pointerlock:change" });
|
|
390
|
+
return (0, import_dom_event.addDomEvent)(dom.getDoc(ctx2), "pointerlockchange", onChange, false);
|
|
391
|
+
},
|
|
392
|
+
trackScroll(ctx2, _evt, { send }) {
|
|
393
|
+
const triggerEl = dom.getTriggerEl(ctx2);
|
|
394
|
+
if (!triggerEl)
|
|
395
|
+
return;
|
|
396
|
+
const overflowParents = (0, import_dom_query3.getOverflowAncestors)(triggerEl);
|
|
397
|
+
const cleanups = overflowParents.map(
|
|
398
|
+
(overflowParent) => (0, import_dom_event.addDomEvent)(overflowParent, "scroll", () => send({ type: "CLOSE", src: "scroll" }), {
|
|
399
|
+
passive: true,
|
|
400
|
+
capture: true
|
|
401
|
+
})
|
|
402
|
+
);
|
|
403
|
+
return () => {
|
|
404
|
+
cleanups.forEach((fn) => fn?.());
|
|
405
|
+
};
|
|
406
|
+
},
|
|
407
|
+
trackStore(ctx2, _evt, { send }) {
|
|
408
|
+
return (0, import_core2.subscribe)(store, () => {
|
|
409
|
+
if (store.id !== ctx2.id) {
|
|
410
|
+
send({ type: "CLOSE", src: "id:change" });
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
},
|
|
414
|
+
trackDisabledTriggerOnSafari(ctx2, _evt, { send }) {
|
|
415
|
+
if (!(0, import_dom_query3.isSafari)())
|
|
416
|
+
return;
|
|
417
|
+
const doc = dom.getDoc(ctx2);
|
|
418
|
+
return (0, import_dom_event.addDomEvent)(doc, "pointermove", (event) => {
|
|
419
|
+
const selector = "[data-part=trigger][data-expanded]";
|
|
420
|
+
if ((0, import_dom_query3.isHTMLElement)(event.target) && event.target.closest(selector))
|
|
421
|
+
return;
|
|
422
|
+
send("POINTER_LEAVE");
|
|
423
|
+
});
|
|
424
|
+
},
|
|
425
|
+
trackEscapeKey(ctx2, _evt, { send }) {
|
|
426
|
+
if (!ctx2.closeOnEscape)
|
|
427
|
+
return;
|
|
428
|
+
const doc = dom.getDoc(ctx2);
|
|
429
|
+
return (0, import_dom_event.addDomEvent)(doc, "keydown", (event) => {
|
|
430
|
+
if (event.key === "Escape") {
|
|
431
|
+
send("CLOSE");
|
|
432
|
+
}
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
},
|
|
436
|
+
actions: {
|
|
437
|
+
setGlobalId(ctx2) {
|
|
438
|
+
store.setId(ctx2.id);
|
|
439
|
+
},
|
|
440
|
+
clearGlobalId(ctx2) {
|
|
441
|
+
if (ctx2.id === store.id) {
|
|
442
|
+
store.setId(null);
|
|
443
|
+
}
|
|
444
|
+
},
|
|
445
|
+
invokeOnOpen(ctx2) {
|
|
446
|
+
ctx2.onOpenChange?.({ open: true });
|
|
447
|
+
},
|
|
448
|
+
invokeOnClose(ctx2) {
|
|
449
|
+
ctx2.onOpenChange?.({ open: false });
|
|
450
|
+
},
|
|
451
|
+
closeIfDisabled(ctx2, _evt, { send }) {
|
|
452
|
+
if (!ctx2.disabled)
|
|
453
|
+
return;
|
|
454
|
+
send({ type: "CLOSE", src: "disabled:change" });
|
|
455
|
+
},
|
|
456
|
+
reposition(ctx2, evt) {
|
|
457
|
+
const getPositionerEl = () => dom.getPositionerEl(ctx2);
|
|
458
|
+
(0, import_popper2.getPlacement)(dom.getTriggerEl(ctx2), getPositionerEl, {
|
|
459
|
+
...ctx2.positioning,
|
|
460
|
+
...evt.options,
|
|
461
|
+
defer: true,
|
|
462
|
+
listeners: false,
|
|
463
|
+
onComplete(data) {
|
|
464
|
+
ctx2.currentPlacement = data.placement;
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
},
|
|
468
|
+
toggleVisibility(ctx2, evt, { send }) {
|
|
469
|
+
send({ type: ctx2.open ? "CONTROLLED.OPEN" : "CONTROLLED.CLOSE", previousEvent: evt });
|
|
470
|
+
},
|
|
471
|
+
setPointerMoveOpened(ctx2) {
|
|
472
|
+
ctx2.hasPointerMoveOpened = true;
|
|
473
|
+
},
|
|
474
|
+
clearPointerMoveOpened(ctx2) {
|
|
475
|
+
ctx2.hasPointerMoveOpened = false;
|
|
476
|
+
}
|
|
477
|
+
},
|
|
478
|
+
guards: {
|
|
479
|
+
noVisibleTooltip: () => store.id === null,
|
|
480
|
+
isVisible: (ctx2) => ctx2.id === store.id,
|
|
481
|
+
isInteractive: (ctx2) => ctx2.interactive,
|
|
482
|
+
hasPointerMoveOpened: (ctx2) => !!ctx2.hasPointerMoveOpened,
|
|
483
|
+
isOpenControlled: (ctx2) => !!ctx2["open.controlled"]
|
|
484
|
+
},
|
|
485
|
+
delays: {
|
|
486
|
+
OPEN_DELAY: (ctx2) => ctx2.openDelay,
|
|
487
|
+
CLOSE_DELAY: (ctx2) => ctx2.closeDelay
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
// src/tooltip.props.ts
|
|
494
|
+
var import_types = require("@zag-js/types");
|
|
495
|
+
var import_utils2 = require("@zag-js/utils");
|
|
496
|
+
var props = (0, import_types.createProps)()([
|
|
497
|
+
"aria-label",
|
|
498
|
+
"closeDelay",
|
|
499
|
+
"closeOnEscape",
|
|
500
|
+
"closeOnPointerDown",
|
|
501
|
+
"dir",
|
|
502
|
+
"disabled",
|
|
503
|
+
"getRootNode",
|
|
504
|
+
"id",
|
|
505
|
+
"ids",
|
|
506
|
+
"interactive",
|
|
507
|
+
"onOpenChange",
|
|
508
|
+
"open.controlled",
|
|
509
|
+
"open",
|
|
510
|
+
"openDelay",
|
|
511
|
+
"positioning"
|
|
512
|
+
]);
|
|
513
|
+
var splitProps = (0, import_utils2.createSplitProps)(props);
|
|
514
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
515
|
+
0 && (module.exports = {
|
|
516
|
+
anatomy,
|
|
517
|
+
connect,
|
|
518
|
+
machine,
|
|
519
|
+
props,
|
|
520
|
+
splitProps
|
|
521
|
+
});
|
|
2
522
|
//# sourceMappingURL=index.js.map
|