@zag-js/tooltip 0.10.5 → 0.11.1
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 +122 -0
- package/dist/index.d.ts +122 -4
- package/dist/index.js +447 -8
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +423 -3
- package/dist/index.mjs.map +1 -0
- package/package.json +10 -10
- package/src/tooltip.connect.ts +5 -5
- package/src/tooltip.machine.ts +43 -14
- package/src/tooltip.types.ts +5 -0
- package/dist/tooltip.anatomy.d.ts +0 -3
- package/dist/tooltip.anatomy.js +0 -11
- package/dist/tooltip.anatomy.mjs +0 -6
- package/dist/tooltip.connect.d.ts +0 -34
- package/dist/tooltip.connect.js +0 -133
- package/dist/tooltip.connect.mjs +0 -129
- package/dist/tooltip.dom.d.ts +0 -31
- package/dist/tooltip.dom.js +0 -19
- package/dist/tooltip.dom.mjs +0 -15
- package/dist/tooltip.machine.d.ts +0 -3
- package/dist/tooltip.machine.js +0 -239
- package/dist/tooltip.machine.mjs +0 -235
- package/dist/tooltip.store.d.ts +0 -8
- package/dist/tooltip.store.js +0 -16
- package/dist/tooltip.store.mjs +0 -12
- package/dist/tooltip.types.d.ts +0 -81
package/dist/tooltip.machine.js
DELETED
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
|
|
5
|
-
const core = require('@zag-js/core');
|
|
6
|
-
const domEvent = require('@zag-js/dom-event');
|
|
7
|
-
const domQuery = require('@zag-js/dom-query');
|
|
8
|
-
const popper = require('@zag-js/popper');
|
|
9
|
-
const utils = require('@zag-js/utils');
|
|
10
|
-
const tooltip_dom = require('./tooltip.dom.js');
|
|
11
|
-
const tooltip_store = require('./tooltip.store.js');
|
|
12
|
-
|
|
13
|
-
function machine(userContext) {
|
|
14
|
-
const ctx = utils.compact(userContext);
|
|
15
|
-
return core.createMachine(
|
|
16
|
-
{
|
|
17
|
-
id: "tooltip",
|
|
18
|
-
initial: "closed",
|
|
19
|
-
context: {
|
|
20
|
-
openDelay: 1e3,
|
|
21
|
-
closeDelay: 500,
|
|
22
|
-
closeOnPointerDown: true,
|
|
23
|
-
closeOnEsc: true,
|
|
24
|
-
interactive: true,
|
|
25
|
-
currentPlacement: void 0,
|
|
26
|
-
...ctx,
|
|
27
|
-
positioning: {
|
|
28
|
-
placement: "bottom",
|
|
29
|
-
...ctx.positioning
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
computed: {
|
|
33
|
-
hasAriaLabel: (ctx2) => !!ctx2["aria-label"]
|
|
34
|
-
},
|
|
35
|
-
watch: {
|
|
36
|
-
disabled: ["closeIfDisabled"],
|
|
37
|
-
open: ["toggleVisibility"]
|
|
38
|
-
},
|
|
39
|
-
on: {
|
|
40
|
-
OPEN: "open",
|
|
41
|
-
CLOSE: "closed"
|
|
42
|
-
},
|
|
43
|
-
states: {
|
|
44
|
-
closed: {
|
|
45
|
-
tags: ["closed"],
|
|
46
|
-
entry: ["clearGlobalId", "invokeOnClose"],
|
|
47
|
-
on: {
|
|
48
|
-
FOCUS: "open",
|
|
49
|
-
POINTER_ENTER: [
|
|
50
|
-
{
|
|
51
|
-
guard: "noVisibleTooltip",
|
|
52
|
-
target: "opening"
|
|
53
|
-
},
|
|
54
|
-
{ target: "open" }
|
|
55
|
-
]
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
opening: {
|
|
59
|
-
tags: ["closed"],
|
|
60
|
-
activities: ["trackScroll", "trackPointerlockChange"],
|
|
61
|
-
after: {
|
|
62
|
-
OPEN_DELAY: "open"
|
|
63
|
-
},
|
|
64
|
-
on: {
|
|
65
|
-
POINTER_LEAVE: "closed",
|
|
66
|
-
BLUR: "closed",
|
|
67
|
-
SCROLL: "closed",
|
|
68
|
-
POINTER_LOCK_CHANGE: "closed",
|
|
69
|
-
POINTER_DOWN: {
|
|
70
|
-
guard: "closeOnPointerDown",
|
|
71
|
-
target: "closed"
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
open: {
|
|
76
|
-
tags: ["open"],
|
|
77
|
-
activities: [
|
|
78
|
-
"trackEscapeKey",
|
|
79
|
-
"trackDisabledTriggerOnSafari",
|
|
80
|
-
"trackScroll",
|
|
81
|
-
"trackPointerlockChange",
|
|
82
|
-
"trackPositioning"
|
|
83
|
-
],
|
|
84
|
-
entry: ["setGlobalId", "invokeOnOpen"],
|
|
85
|
-
on: {
|
|
86
|
-
POINTER_LEAVE: [
|
|
87
|
-
{
|
|
88
|
-
guard: "isVisible",
|
|
89
|
-
target: "closing"
|
|
90
|
-
},
|
|
91
|
-
{ target: "closed" }
|
|
92
|
-
],
|
|
93
|
-
BLUR: "closed",
|
|
94
|
-
ESCAPE: "closed",
|
|
95
|
-
SCROLL: "closed",
|
|
96
|
-
POINTER_LOCK_CHANGE: "closed",
|
|
97
|
-
TOOLTIP_POINTER_LEAVE: {
|
|
98
|
-
guard: "isInteractive",
|
|
99
|
-
target: "closing"
|
|
100
|
-
},
|
|
101
|
-
POINTER_DOWN: {
|
|
102
|
-
guard: "closeOnPointerDown",
|
|
103
|
-
target: "closed"
|
|
104
|
-
},
|
|
105
|
-
CLICK: "closed",
|
|
106
|
-
SET_POSITIONING: {
|
|
107
|
-
actions: "setPositioning"
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
closing: {
|
|
112
|
-
tags: ["open"],
|
|
113
|
-
activities: ["trackStore", "trackPositioning"],
|
|
114
|
-
after: {
|
|
115
|
-
CLOSE_DELAY: "closed"
|
|
116
|
-
},
|
|
117
|
-
on: {
|
|
118
|
-
FORCE_CLOSE: "closed",
|
|
119
|
-
POINTER_ENTER: "open",
|
|
120
|
-
TOOLTIP_POINTER_ENTER: {
|
|
121
|
-
guard: "isInteractive",
|
|
122
|
-
target: "open"
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
activities: {
|
|
130
|
-
trackPositioning(ctx2) {
|
|
131
|
-
ctx2.currentPlacement = ctx2.positioning.placement;
|
|
132
|
-
const getPositionerEl = () => tooltip_dom.dom.getPositionerEl(ctx2);
|
|
133
|
-
return popper.getPlacement(tooltip_dom.dom.getTriggerEl(ctx2), getPositionerEl, {
|
|
134
|
-
...ctx2.positioning,
|
|
135
|
-
defer: true,
|
|
136
|
-
onComplete(data) {
|
|
137
|
-
ctx2.currentPlacement = data.placement;
|
|
138
|
-
},
|
|
139
|
-
onCleanup() {
|
|
140
|
-
ctx2.currentPlacement = void 0;
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
},
|
|
144
|
-
trackPointerlockChange(ctx2, _evt, { send }) {
|
|
145
|
-
const onChange = () => send("POINTER_LOCK_CHANGE");
|
|
146
|
-
return domEvent.addDomEvent(tooltip_dom.dom.getDoc(ctx2), "pointerlockchange", onChange, false);
|
|
147
|
-
},
|
|
148
|
-
trackScroll(ctx2, _evt, { send }) {
|
|
149
|
-
const trigger = tooltip_dom.dom.getTriggerEl(ctx2);
|
|
150
|
-
if (!trigger)
|
|
151
|
-
return;
|
|
152
|
-
const cleanups = domQuery.getScrollParents(trigger).map((el) => {
|
|
153
|
-
const opts = { passive: true, capture: true };
|
|
154
|
-
return domEvent.addDomEvent(el, "scroll", () => send("SCROLL"), opts);
|
|
155
|
-
});
|
|
156
|
-
return () => {
|
|
157
|
-
cleanups.forEach((fn) => fn?.());
|
|
158
|
-
};
|
|
159
|
-
},
|
|
160
|
-
trackStore(ctx2, _evt, { send }) {
|
|
161
|
-
return core.subscribe(tooltip_store.store, () => {
|
|
162
|
-
if (tooltip_store.store.id !== ctx2.id) {
|
|
163
|
-
send("FORCE_CLOSE");
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
},
|
|
167
|
-
trackDisabledTriggerOnSafari(ctx2, _evt, { send }) {
|
|
168
|
-
if (!domQuery.isSafari())
|
|
169
|
-
return;
|
|
170
|
-
const doc = tooltip_dom.dom.getDoc(ctx2);
|
|
171
|
-
return domEvent.addDomEvent(doc, "pointermove", (event) => {
|
|
172
|
-
const selector = "[data-part=trigger][data-expanded]";
|
|
173
|
-
if (domQuery.isHTMLElement(event.target) && event.target.closest(selector))
|
|
174
|
-
return;
|
|
175
|
-
send("POINTER_LEAVE");
|
|
176
|
-
});
|
|
177
|
-
},
|
|
178
|
-
trackEscapeKey(ctx2, _evt, { send }) {
|
|
179
|
-
if (!ctx2.closeOnEsc)
|
|
180
|
-
return;
|
|
181
|
-
const doc = tooltip_dom.dom.getDoc(ctx2);
|
|
182
|
-
return domEvent.addDomEvent(doc, "keydown", (event) => {
|
|
183
|
-
if (event.key === "Escape") {
|
|
184
|
-
send("ESCAPE");
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
},
|
|
189
|
-
actions: {
|
|
190
|
-
setGlobalId(ctx2) {
|
|
191
|
-
tooltip_store.store.setId(ctx2.id);
|
|
192
|
-
},
|
|
193
|
-
clearGlobalId(ctx2) {
|
|
194
|
-
if (ctx2.id === tooltip_store.store.id) {
|
|
195
|
-
tooltip_store.store.setId(null);
|
|
196
|
-
}
|
|
197
|
-
},
|
|
198
|
-
invokeOnOpen(ctx2, evt) {
|
|
199
|
-
const omit = ["TOOLTIP_POINTER_ENTER", "POINTER_ENTER"];
|
|
200
|
-
if (!omit.includes(evt.type)) {
|
|
201
|
-
ctx2.onOpen?.();
|
|
202
|
-
}
|
|
203
|
-
},
|
|
204
|
-
invokeOnClose(ctx2) {
|
|
205
|
-
ctx2.onClose?.();
|
|
206
|
-
},
|
|
207
|
-
closeIfDisabled(ctx2, _evt, { send }) {
|
|
208
|
-
if (ctx2.disabled) {
|
|
209
|
-
send("CLOSE");
|
|
210
|
-
}
|
|
211
|
-
},
|
|
212
|
-
setPositioning(ctx2, evt) {
|
|
213
|
-
const getPositionerEl = () => tooltip_dom.dom.getPositionerEl(ctx2);
|
|
214
|
-
popper.getPlacement(tooltip_dom.dom.getTriggerEl(ctx2), getPositionerEl, {
|
|
215
|
-
...ctx2.positioning,
|
|
216
|
-
...evt.options,
|
|
217
|
-
defer: true,
|
|
218
|
-
listeners: false
|
|
219
|
-
});
|
|
220
|
-
},
|
|
221
|
-
toggleVisibility(ctx2, _evt, { send }) {
|
|
222
|
-
send({ type: ctx2.open ? "OPEN" : "CLOSE", src: "controlled" });
|
|
223
|
-
}
|
|
224
|
-
},
|
|
225
|
-
guards: {
|
|
226
|
-
closeOnPointerDown: (ctx2) => ctx2.closeOnPointerDown,
|
|
227
|
-
noVisibleTooltip: () => tooltip_store.store.id === null,
|
|
228
|
-
isVisible: (ctx2) => ctx2.id === tooltip_store.store.id,
|
|
229
|
-
isInteractive: (ctx2) => ctx2.interactive
|
|
230
|
-
},
|
|
231
|
-
delays: {
|
|
232
|
-
OPEN_DELAY: (ctx2) => ctx2.openDelay,
|
|
233
|
-
CLOSE_DELAY: (ctx2) => ctx2.closeDelay
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
exports.machine = machine;
|
package/dist/tooltip.machine.mjs
DELETED
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
import { createMachine, subscribe } from '@zag-js/core';
|
|
2
|
-
import { addDomEvent } from '@zag-js/dom-event';
|
|
3
|
-
import { getScrollParents, isSafari, isHTMLElement } from '@zag-js/dom-query';
|
|
4
|
-
import { getPlacement } from '@zag-js/popper';
|
|
5
|
-
import { compact } from '@zag-js/utils';
|
|
6
|
-
import { dom } from './tooltip.dom.mjs';
|
|
7
|
-
import { store } from './tooltip.store.mjs';
|
|
8
|
-
|
|
9
|
-
function machine(userContext) {
|
|
10
|
-
const ctx = compact(userContext);
|
|
11
|
-
return createMachine(
|
|
12
|
-
{
|
|
13
|
-
id: "tooltip",
|
|
14
|
-
initial: "closed",
|
|
15
|
-
context: {
|
|
16
|
-
openDelay: 1e3,
|
|
17
|
-
closeDelay: 500,
|
|
18
|
-
closeOnPointerDown: true,
|
|
19
|
-
closeOnEsc: true,
|
|
20
|
-
interactive: true,
|
|
21
|
-
currentPlacement: void 0,
|
|
22
|
-
...ctx,
|
|
23
|
-
positioning: {
|
|
24
|
-
placement: "bottom",
|
|
25
|
-
...ctx.positioning
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
computed: {
|
|
29
|
-
hasAriaLabel: (ctx2) => !!ctx2["aria-label"]
|
|
30
|
-
},
|
|
31
|
-
watch: {
|
|
32
|
-
disabled: ["closeIfDisabled"],
|
|
33
|
-
open: ["toggleVisibility"]
|
|
34
|
-
},
|
|
35
|
-
on: {
|
|
36
|
-
OPEN: "open",
|
|
37
|
-
CLOSE: "closed"
|
|
38
|
-
},
|
|
39
|
-
states: {
|
|
40
|
-
closed: {
|
|
41
|
-
tags: ["closed"],
|
|
42
|
-
entry: ["clearGlobalId", "invokeOnClose"],
|
|
43
|
-
on: {
|
|
44
|
-
FOCUS: "open",
|
|
45
|
-
POINTER_ENTER: [
|
|
46
|
-
{
|
|
47
|
-
guard: "noVisibleTooltip",
|
|
48
|
-
target: "opening"
|
|
49
|
-
},
|
|
50
|
-
{ target: "open" }
|
|
51
|
-
]
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
opening: {
|
|
55
|
-
tags: ["closed"],
|
|
56
|
-
activities: ["trackScroll", "trackPointerlockChange"],
|
|
57
|
-
after: {
|
|
58
|
-
OPEN_DELAY: "open"
|
|
59
|
-
},
|
|
60
|
-
on: {
|
|
61
|
-
POINTER_LEAVE: "closed",
|
|
62
|
-
BLUR: "closed",
|
|
63
|
-
SCROLL: "closed",
|
|
64
|
-
POINTER_LOCK_CHANGE: "closed",
|
|
65
|
-
POINTER_DOWN: {
|
|
66
|
-
guard: "closeOnPointerDown",
|
|
67
|
-
target: "closed"
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
open: {
|
|
72
|
-
tags: ["open"],
|
|
73
|
-
activities: [
|
|
74
|
-
"trackEscapeKey",
|
|
75
|
-
"trackDisabledTriggerOnSafari",
|
|
76
|
-
"trackScroll",
|
|
77
|
-
"trackPointerlockChange",
|
|
78
|
-
"trackPositioning"
|
|
79
|
-
],
|
|
80
|
-
entry: ["setGlobalId", "invokeOnOpen"],
|
|
81
|
-
on: {
|
|
82
|
-
POINTER_LEAVE: [
|
|
83
|
-
{
|
|
84
|
-
guard: "isVisible",
|
|
85
|
-
target: "closing"
|
|
86
|
-
},
|
|
87
|
-
{ target: "closed" }
|
|
88
|
-
],
|
|
89
|
-
BLUR: "closed",
|
|
90
|
-
ESCAPE: "closed",
|
|
91
|
-
SCROLL: "closed",
|
|
92
|
-
POINTER_LOCK_CHANGE: "closed",
|
|
93
|
-
TOOLTIP_POINTER_LEAVE: {
|
|
94
|
-
guard: "isInteractive",
|
|
95
|
-
target: "closing"
|
|
96
|
-
},
|
|
97
|
-
POINTER_DOWN: {
|
|
98
|
-
guard: "closeOnPointerDown",
|
|
99
|
-
target: "closed"
|
|
100
|
-
},
|
|
101
|
-
CLICK: "closed",
|
|
102
|
-
SET_POSITIONING: {
|
|
103
|
-
actions: "setPositioning"
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
closing: {
|
|
108
|
-
tags: ["open"],
|
|
109
|
-
activities: ["trackStore", "trackPositioning"],
|
|
110
|
-
after: {
|
|
111
|
-
CLOSE_DELAY: "closed"
|
|
112
|
-
},
|
|
113
|
-
on: {
|
|
114
|
-
FORCE_CLOSE: "closed",
|
|
115
|
-
POINTER_ENTER: "open",
|
|
116
|
-
TOOLTIP_POINTER_ENTER: {
|
|
117
|
-
guard: "isInteractive",
|
|
118
|
-
target: "open"
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
activities: {
|
|
126
|
-
trackPositioning(ctx2) {
|
|
127
|
-
ctx2.currentPlacement = ctx2.positioning.placement;
|
|
128
|
-
const getPositionerEl = () => dom.getPositionerEl(ctx2);
|
|
129
|
-
return getPlacement(dom.getTriggerEl(ctx2), getPositionerEl, {
|
|
130
|
-
...ctx2.positioning,
|
|
131
|
-
defer: true,
|
|
132
|
-
onComplete(data) {
|
|
133
|
-
ctx2.currentPlacement = data.placement;
|
|
134
|
-
},
|
|
135
|
-
onCleanup() {
|
|
136
|
-
ctx2.currentPlacement = void 0;
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
},
|
|
140
|
-
trackPointerlockChange(ctx2, _evt, { send }) {
|
|
141
|
-
const onChange = () => send("POINTER_LOCK_CHANGE");
|
|
142
|
-
return addDomEvent(dom.getDoc(ctx2), "pointerlockchange", onChange, false);
|
|
143
|
-
},
|
|
144
|
-
trackScroll(ctx2, _evt, { send }) {
|
|
145
|
-
const trigger = dom.getTriggerEl(ctx2);
|
|
146
|
-
if (!trigger)
|
|
147
|
-
return;
|
|
148
|
-
const cleanups = getScrollParents(trigger).map((el) => {
|
|
149
|
-
const opts = { passive: true, capture: true };
|
|
150
|
-
return addDomEvent(el, "scroll", () => send("SCROLL"), opts);
|
|
151
|
-
});
|
|
152
|
-
return () => {
|
|
153
|
-
cleanups.forEach((fn) => fn?.());
|
|
154
|
-
};
|
|
155
|
-
},
|
|
156
|
-
trackStore(ctx2, _evt, { send }) {
|
|
157
|
-
return subscribe(store, () => {
|
|
158
|
-
if (store.id !== ctx2.id) {
|
|
159
|
-
send("FORCE_CLOSE");
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
},
|
|
163
|
-
trackDisabledTriggerOnSafari(ctx2, _evt, { send }) {
|
|
164
|
-
if (!isSafari())
|
|
165
|
-
return;
|
|
166
|
-
const doc = dom.getDoc(ctx2);
|
|
167
|
-
return addDomEvent(doc, "pointermove", (event) => {
|
|
168
|
-
const selector = "[data-part=trigger][data-expanded]";
|
|
169
|
-
if (isHTMLElement(event.target) && event.target.closest(selector))
|
|
170
|
-
return;
|
|
171
|
-
send("POINTER_LEAVE");
|
|
172
|
-
});
|
|
173
|
-
},
|
|
174
|
-
trackEscapeKey(ctx2, _evt, { send }) {
|
|
175
|
-
if (!ctx2.closeOnEsc)
|
|
176
|
-
return;
|
|
177
|
-
const doc = dom.getDoc(ctx2);
|
|
178
|
-
return addDomEvent(doc, "keydown", (event) => {
|
|
179
|
-
if (event.key === "Escape") {
|
|
180
|
-
send("ESCAPE");
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
},
|
|
185
|
-
actions: {
|
|
186
|
-
setGlobalId(ctx2) {
|
|
187
|
-
store.setId(ctx2.id);
|
|
188
|
-
},
|
|
189
|
-
clearGlobalId(ctx2) {
|
|
190
|
-
if (ctx2.id === store.id) {
|
|
191
|
-
store.setId(null);
|
|
192
|
-
}
|
|
193
|
-
},
|
|
194
|
-
invokeOnOpen(ctx2, evt) {
|
|
195
|
-
const omit = ["TOOLTIP_POINTER_ENTER", "POINTER_ENTER"];
|
|
196
|
-
if (!omit.includes(evt.type)) {
|
|
197
|
-
ctx2.onOpen?.();
|
|
198
|
-
}
|
|
199
|
-
},
|
|
200
|
-
invokeOnClose(ctx2) {
|
|
201
|
-
ctx2.onClose?.();
|
|
202
|
-
},
|
|
203
|
-
closeIfDisabled(ctx2, _evt, { send }) {
|
|
204
|
-
if (ctx2.disabled) {
|
|
205
|
-
send("CLOSE");
|
|
206
|
-
}
|
|
207
|
-
},
|
|
208
|
-
setPositioning(ctx2, evt) {
|
|
209
|
-
const getPositionerEl = () => dom.getPositionerEl(ctx2);
|
|
210
|
-
getPlacement(dom.getTriggerEl(ctx2), getPositionerEl, {
|
|
211
|
-
...ctx2.positioning,
|
|
212
|
-
...evt.options,
|
|
213
|
-
defer: true,
|
|
214
|
-
listeners: false
|
|
215
|
-
});
|
|
216
|
-
},
|
|
217
|
-
toggleVisibility(ctx2, _evt, { send }) {
|
|
218
|
-
send({ type: ctx2.open ? "OPEN" : "CLOSE", src: "controlled" });
|
|
219
|
-
}
|
|
220
|
-
},
|
|
221
|
-
guards: {
|
|
222
|
-
closeOnPointerDown: (ctx2) => ctx2.closeOnPointerDown,
|
|
223
|
-
noVisibleTooltip: () => store.id === null,
|
|
224
|
-
isVisible: (ctx2) => ctx2.id === store.id,
|
|
225
|
-
isInteractive: (ctx2) => ctx2.interactive
|
|
226
|
-
},
|
|
227
|
-
delays: {
|
|
228
|
-
OPEN_DELAY: (ctx2) => ctx2.openDelay,
|
|
229
|
-
CLOSE_DELAY: (ctx2) => ctx2.closeDelay
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
export { machine };
|
package/dist/tooltip.store.d.ts
DELETED
package/dist/tooltip.store.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
|
|
5
|
-
const core = require('@zag-js/core');
|
|
6
|
-
|
|
7
|
-
const store = core.proxy({
|
|
8
|
-
id: null,
|
|
9
|
-
prevId: null,
|
|
10
|
-
setId(val) {
|
|
11
|
-
this.prevId = this.id;
|
|
12
|
-
this.id = val;
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
exports.store = store;
|
package/dist/tooltip.store.mjs
DELETED
package/dist/tooltip.types.d.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import type { StateMachine as S } from "@zag-js/core";
|
|
2
|
-
import type { Placement, PositioningOptions } from "@zag-js/popper";
|
|
3
|
-
import type { CommonProperties, RequiredBy, RootProperties } from "@zag-js/types";
|
|
4
|
-
type ElementIds = Partial<{
|
|
5
|
-
trigger: string;
|
|
6
|
-
content: string;
|
|
7
|
-
arrow: string;
|
|
8
|
-
positioner: string;
|
|
9
|
-
}>;
|
|
10
|
-
type PublicContext = CommonProperties & {
|
|
11
|
-
/**
|
|
12
|
-
* The ids of the elements in the tooltip. Useful for composition.
|
|
13
|
-
*/
|
|
14
|
-
ids?: ElementIds;
|
|
15
|
-
/**
|
|
16
|
-
* The `id` of the tooltip.
|
|
17
|
-
*/
|
|
18
|
-
id: string;
|
|
19
|
-
/**
|
|
20
|
-
* The open delay of the tooltip.
|
|
21
|
-
*/
|
|
22
|
-
openDelay: number;
|
|
23
|
-
/**
|
|
24
|
-
* The close delay of the tooltip.
|
|
25
|
-
*/
|
|
26
|
-
closeDelay: number;
|
|
27
|
-
/**
|
|
28
|
-
* Whether to close the tooltip on pointerdown.
|
|
29
|
-
*/
|
|
30
|
-
closeOnPointerDown: boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Whether to close the tooltip when the Escape key is pressed.
|
|
33
|
-
*/
|
|
34
|
-
closeOnEsc?: boolean;
|
|
35
|
-
/**
|
|
36
|
-
* Whether the tooltip's content is interactive.
|
|
37
|
-
* In this mode, the tooltip will remain open when user hovers over the content.
|
|
38
|
-
* @see https://www.w3.org/TR/WCAG21/#content-on-hover-or-focus
|
|
39
|
-
*/
|
|
40
|
-
interactive: boolean;
|
|
41
|
-
/**
|
|
42
|
-
* Function called when the tooltip is opened.
|
|
43
|
-
*/
|
|
44
|
-
onOpen?: VoidFunction;
|
|
45
|
-
/**
|
|
46
|
-
* Function called when the tooltip is closed.
|
|
47
|
-
*/
|
|
48
|
-
onClose?: VoidFunction;
|
|
49
|
-
/**
|
|
50
|
-
* Custom label for the tooltip.
|
|
51
|
-
*/
|
|
52
|
-
"aria-label"?: string;
|
|
53
|
-
/**
|
|
54
|
-
* The user provided options used to position the popover content
|
|
55
|
-
*/
|
|
56
|
-
positioning: PositioningOptions;
|
|
57
|
-
/**
|
|
58
|
-
* Whether the tooltip is disabled
|
|
59
|
-
*/
|
|
60
|
-
disabled?: boolean;
|
|
61
|
-
/**
|
|
62
|
-
* Whether the tooltip is open
|
|
63
|
-
*/
|
|
64
|
-
open?: boolean;
|
|
65
|
-
};
|
|
66
|
-
export type UserDefinedContext = RequiredBy<PublicContext, "id">;
|
|
67
|
-
type ComputedContext = Readonly<{
|
|
68
|
-
/**
|
|
69
|
-
* @computed Whether an `aria-label` is set.
|
|
70
|
-
*/
|
|
71
|
-
readonly hasAriaLabel: boolean;
|
|
72
|
-
}>;
|
|
73
|
-
type PrivateContext = RootProperties & {};
|
|
74
|
-
export type MachineContext = PublicContext & ComputedContext & PrivateContext;
|
|
75
|
-
export type MachineState = {
|
|
76
|
-
value: "opening" | "open" | "closing" | "closed";
|
|
77
|
-
tags: "open" | "closed";
|
|
78
|
-
};
|
|
79
|
-
export type State = S.State<MachineContext, MachineState>;
|
|
80
|
-
export type Send = S.Send<S.AnyEventObject>;
|
|
81
|
-
export type { PositioningOptions, Placement };
|