@zag-js/popover 1.47.0 → 1.49.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 +7 -10
- package/dist/index.d.ts +7 -10
- package/dist/index.js +12 -38
- package/dist/index.mjs +2 -7
- package/dist/popover.anatomy.d.mts +2 -6
- package/dist/popover.anatomy.d.ts +2 -6
- package/dist/popover.anatomy.js +8 -44
- package/dist/popover.anatomy.mjs +4 -18
- package/dist/popover.connect.d.mts +3 -9
- package/dist/popover.connect.d.ts +3 -9
- package/dist/popover.connect.js +164 -187
- package/dist/popover.connect.mjs +157 -149
- package/dist/popover.dom.d.mts +19 -22
- package/dist/popover.dom.d.ts +19 -22
- package/dist/popover.dom.js +47 -89
- package/dist/popover.dom.mjs +25 -46
- package/dist/popover.machine.d.mts +2 -9
- package/dist/popover.machine.d.ts +2 -9
- package/dist/popover.machine.js +308 -339
- package/dist/popover.machine.mjs +299 -299
- package/dist/popover.props.d.mts +3 -10
- package/dist/popover.props.d.ts +3 -10
- package/dist/popover.props.js +36 -60
- package/dist/popover.props.mjs +30 -33
- package/dist/popover.types.d.mts +185 -188
- package/dist/popover.types.d.ts +185 -188
- package/dist/popover.types.js +4 -18
- package/dist/popover.types.mjs +1 -0
- package/package.json +13 -13
package/dist/popover.machine.mjs
CHANGED
|
@@ -1,308 +1,308 @@
|
|
|
1
|
-
// src/popover.machine.ts
|
|
2
1
|
import { ariaHidden } from "@zag-js/aria-hidden";
|
|
3
2
|
import { createMachine } from "@zag-js/core";
|
|
4
3
|
import { trackDismissableElement } from "@zag-js/dismissable";
|
|
5
|
-
import { getInitialFocus, proxyTabFocus, raf } from "@zag-js/dom-query";
|
|
4
|
+
import { getInitialFocus, proxyTabFocus, raf, trackRenderedParts } from "@zag-js/dom-query";
|
|
6
5
|
import { trapFocus } from "@zag-js/focus-trap";
|
|
7
6
|
import { getPlacement } from "@zag-js/popper";
|
|
8
7
|
import { preventBodyScroll } from "@zag-js/remove-scroll";
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
8
|
+
import { getActiveTriggerEl, getAnchorEl, getContentEl, getDescriptionEl, getPositionerEl, getTitleEl, getTriggerEl, getTriggerEls } from "./popover.dom.mjs";
|
|
9
|
+
// src/popover.machine.ts
|
|
10
|
+
const machine = createMachine({
|
|
11
|
+
props({ props }) {
|
|
12
|
+
return {
|
|
13
|
+
closeOnInteractOutside: true,
|
|
14
|
+
closeOnEscape: true,
|
|
15
|
+
autoFocus: true,
|
|
16
|
+
modal: false,
|
|
17
|
+
portalled: true,
|
|
18
|
+
restoreFocus: true,
|
|
19
|
+
...props,
|
|
20
|
+
positioning: {
|
|
21
|
+
placement: "bottom",
|
|
22
|
+
...props.positioning
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
initialState({ prop }) {
|
|
27
|
+
return prop("open") || prop("defaultOpen") ? "open" : "closed";
|
|
28
|
+
},
|
|
29
|
+
context({ bindable, prop, scope }) {
|
|
30
|
+
return {
|
|
31
|
+
currentPlacement: bindable(() => ({ defaultValue: void 0 })),
|
|
32
|
+
renderedElements: bindable(() => ({ defaultValue: {
|
|
33
|
+
title: true,
|
|
34
|
+
description: true
|
|
35
|
+
} })),
|
|
36
|
+
triggerValue: bindable(() => ({
|
|
37
|
+
defaultValue: prop("defaultTriggerValue") ?? null,
|
|
38
|
+
value: prop("triggerValue"),
|
|
39
|
+
onChange(value) {
|
|
40
|
+
const onTriggerValueChange = prop("onTriggerValueChange");
|
|
41
|
+
if (!onTriggerValueChange) return;
|
|
42
|
+
onTriggerValueChange({
|
|
43
|
+
value,
|
|
44
|
+
triggerElement: getActiveTriggerEl(scope, value)
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}))
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
computed: { currentPortalled: ({ prop }) => !!prop("modal") || !!prop("portalled") },
|
|
51
|
+
watch({ track, prop, action }) {
|
|
52
|
+
track([() => prop("open")], () => {
|
|
53
|
+
action(["toggleVisibility"]);
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
entry: ["checkRenderedElements"],
|
|
57
|
+
on: { "TRIGGER_VALUE.SET": { actions: ["setTriggerValue", "reposition"] } },
|
|
58
|
+
states: {
|
|
59
|
+
closed: { on: {
|
|
60
|
+
"CONTROLLED.OPEN": {
|
|
61
|
+
target: "open",
|
|
62
|
+
actions: ["setInitialFocus"]
|
|
63
|
+
},
|
|
64
|
+
TOGGLE: [{
|
|
65
|
+
guard: "isOpenControlled",
|
|
66
|
+
actions: ["invokeOnOpen", "setTriggerValue"]
|
|
67
|
+
}, {
|
|
68
|
+
target: "open",
|
|
69
|
+
actions: [
|
|
70
|
+
"invokeOnOpen",
|
|
71
|
+
"setTriggerValue",
|
|
72
|
+
"setInitialFocus"
|
|
73
|
+
]
|
|
74
|
+
}],
|
|
75
|
+
OPEN: [{
|
|
76
|
+
guard: "isOpenControlled",
|
|
77
|
+
actions: ["invokeOnOpen", "setTriggerValue"]
|
|
78
|
+
}, {
|
|
79
|
+
target: "open",
|
|
80
|
+
actions: [
|
|
81
|
+
"invokeOnOpen",
|
|
82
|
+
"setTriggerValue",
|
|
83
|
+
"setInitialFocus"
|
|
84
|
+
]
|
|
85
|
+
}]
|
|
86
|
+
} },
|
|
87
|
+
open: {
|
|
88
|
+
effects: [
|
|
89
|
+
"trackRenderedElements",
|
|
90
|
+
"trapFocus",
|
|
91
|
+
"preventScroll",
|
|
92
|
+
"hideContentBelow",
|
|
93
|
+
"trackDismissableElement",
|
|
94
|
+
"trackPositioning",
|
|
95
|
+
"proxyTabFocus"
|
|
96
|
+
],
|
|
97
|
+
on: {
|
|
98
|
+
"CONTROLLED.CLOSE": {
|
|
99
|
+
target: "closed",
|
|
100
|
+
actions: ["setFinalFocus"]
|
|
101
|
+
},
|
|
102
|
+
CLOSE: [{
|
|
103
|
+
guard: "isOpenControlled",
|
|
104
|
+
actions: ["invokeOnClose"]
|
|
105
|
+
}, {
|
|
106
|
+
target: "closed",
|
|
107
|
+
actions: ["invokeOnClose", "setFinalFocus"]
|
|
108
|
+
}],
|
|
109
|
+
TOGGLE: [{
|
|
110
|
+
guard: "isOpenControlled",
|
|
111
|
+
actions: ["invokeOnClose"]
|
|
112
|
+
}, {
|
|
113
|
+
target: "closed",
|
|
114
|
+
actions: ["invokeOnClose"]
|
|
115
|
+
}],
|
|
116
|
+
"POSITIONING.SET": { actions: ["reposition"] }
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
implementations: {
|
|
121
|
+
guards: { isOpenControlled: ({ prop }) => prop("open") != void 0 },
|
|
122
|
+
effects: {
|
|
123
|
+
trackRenderedElements({ context, scope }) {
|
|
124
|
+
return trackRenderedParts({
|
|
125
|
+
getContainerEl: () => getContentEl(scope),
|
|
126
|
+
getRootNode: () => scope.getRootNode(),
|
|
127
|
+
parts: {
|
|
128
|
+
title: () => getTitleEl(scope),
|
|
129
|
+
description: () => getDescriptionEl(scope)
|
|
130
|
+
},
|
|
131
|
+
onChange: (rendered) => context.set("renderedElements", rendered)
|
|
132
|
+
});
|
|
133
|
+
},
|
|
134
|
+
trackPositioning({ context, prop, scope }) {
|
|
135
|
+
context.set("currentPlacement", prop("positioning").placement);
|
|
136
|
+
const anchorEl = getAnchorEl(scope);
|
|
137
|
+
const getPositionerEl$2 = () => getPositionerEl(scope);
|
|
138
|
+
const getTriggerEl = () => anchorEl ?? getActiveTriggerEl(scope, context.get("triggerValue"));
|
|
139
|
+
return getPlacement(getTriggerEl, getPositionerEl$2, {
|
|
140
|
+
...prop("positioning"),
|
|
141
|
+
defer: true,
|
|
142
|
+
onComplete(data) {
|
|
143
|
+
context.set("currentPlacement", data.placement);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
},
|
|
147
|
+
trackDismissableElement({ send, prop, scope }) {
|
|
148
|
+
const getContentEl$1 = () => getContentEl(scope);
|
|
149
|
+
let restoreFocus = true;
|
|
150
|
+
return trackDismissableElement(getContentEl$1, {
|
|
151
|
+
type: "popover",
|
|
152
|
+
pointerBlocking: prop("modal"),
|
|
153
|
+
exclude: [getTriggerEl(scope), ...getTriggerEls(scope)].filter(Boolean),
|
|
154
|
+
defer: true,
|
|
155
|
+
getRootNode: scope.getRootNode,
|
|
156
|
+
layerStyleTargets: [() => getPositionerEl(scope)],
|
|
157
|
+
onEscapeKeyDown(event) {
|
|
158
|
+
prop("onEscapeKeyDown")?.(event);
|
|
159
|
+
if (prop("closeOnEscape")) return;
|
|
160
|
+
event.preventDefault();
|
|
161
|
+
},
|
|
162
|
+
onInteractOutside(event) {
|
|
163
|
+
prop("onInteractOutside")?.(event);
|
|
164
|
+
if (event.defaultPrevented) return;
|
|
165
|
+
restoreFocus = !(event.detail.focusable || event.detail.contextmenu);
|
|
166
|
+
if (!prop("closeOnInteractOutside")) event.preventDefault();
|
|
167
|
+
},
|
|
168
|
+
onPointerDownOutside: prop("onPointerDownOutside"),
|
|
169
|
+
onFocusOutside: prop("onFocusOutside"),
|
|
170
|
+
persistentElements: prop("persistentElements"),
|
|
171
|
+
onRequestDismiss: prop("onRequestDismiss"),
|
|
172
|
+
onDismiss(event) {
|
|
173
|
+
send({
|
|
174
|
+
type: "CLOSE",
|
|
175
|
+
src: "interact-outside",
|
|
176
|
+
restoreFocus,
|
|
177
|
+
focusVisible: event?.type === "keydown"
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
},
|
|
182
|
+
proxyTabFocus({ prop, scope, context }) {
|
|
183
|
+
if (prop("modal") || !prop("portalled")) return;
|
|
184
|
+
const getContentEl$2 = () => getContentEl(scope);
|
|
185
|
+
return proxyTabFocus(getContentEl$2, {
|
|
186
|
+
triggerElement: getActiveTriggerEl(scope, context.get("triggerValue")),
|
|
187
|
+
defer: true,
|
|
188
|
+
getShadowRoot: true,
|
|
189
|
+
onFocus(el) {
|
|
190
|
+
el.focus({ preventScroll: true });
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
},
|
|
194
|
+
hideContentBelow({ prop, scope, context }) {
|
|
195
|
+
if (!prop("modal")) return;
|
|
196
|
+
const getElements = () => [getContentEl(scope), getActiveTriggerEl(scope, context.get("triggerValue"))];
|
|
197
|
+
return ariaHidden(getElements, { defer: true });
|
|
198
|
+
},
|
|
199
|
+
preventScroll({ prop, scope }) {
|
|
200
|
+
if (!prop("modal")) return;
|
|
201
|
+
return preventBodyScroll(scope.getDoc());
|
|
202
|
+
},
|
|
203
|
+
trapFocus({ prop, scope, context }) {
|
|
204
|
+
if (!prop("modal")) return;
|
|
205
|
+
const contentEl = () => getContentEl(scope);
|
|
206
|
+
return trapFocus(contentEl, {
|
|
207
|
+
preventScroll: true,
|
|
208
|
+
returnFocusOnDeactivate: !!prop("restoreFocus"),
|
|
209
|
+
initialFocus: () => getInitialFocus({
|
|
210
|
+
root: getContentEl(scope),
|
|
211
|
+
getInitialEl: prop("initialFocusEl"),
|
|
212
|
+
enabled: prop("autoFocus")
|
|
213
|
+
}),
|
|
214
|
+
setReturnFocus: (el) => {
|
|
215
|
+
const finalFocusEl = prop("finalFocusEl")?.();
|
|
216
|
+
if (finalFocusEl) return finalFocusEl;
|
|
217
|
+
const triggerValue = context.get("triggerValue");
|
|
218
|
+
if (triggerValue) {
|
|
219
|
+
const activeTriggerEl = getActiveTriggerEl(scope, triggerValue);
|
|
220
|
+
if (activeTriggerEl) return activeTriggerEl;
|
|
221
|
+
}
|
|
222
|
+
const fallbackTrigger = getTriggerEls(scope)[0];
|
|
223
|
+
if (fallbackTrigger) return fallbackTrigger;
|
|
224
|
+
return el;
|
|
225
|
+
},
|
|
226
|
+
getShadowRoot: true
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
actions: {
|
|
231
|
+
reposition({ event, prop, scope, context }) {
|
|
232
|
+
const anchorEl = getAnchorEl(scope);
|
|
233
|
+
const getPositionerEl$1 = () => getPositionerEl(scope);
|
|
234
|
+
const getTriggerEl = () => anchorEl ?? getActiveTriggerEl(scope, context.get("triggerValue"));
|
|
235
|
+
getPlacement(getTriggerEl, getPositionerEl$1, {
|
|
236
|
+
...prop("positioning"),
|
|
237
|
+
...event.options,
|
|
238
|
+
defer: true,
|
|
239
|
+
listeners: false,
|
|
240
|
+
onComplete(data) {
|
|
241
|
+
context.set("currentPlacement", data.placement);
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
},
|
|
245
|
+
setTriggerValue({ context, event }) {
|
|
246
|
+
if (event.value === void 0) return;
|
|
247
|
+
context.set("triggerValue", event.value);
|
|
248
|
+
},
|
|
249
|
+
checkRenderedElements({ context, scope }) {
|
|
250
|
+
raf(() => {
|
|
251
|
+
context.set("renderedElements", {
|
|
252
|
+
title: !!getTitleEl(scope),
|
|
253
|
+
description: !!getDescriptionEl(scope)
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
},
|
|
257
|
+
setInitialFocus({ prop, scope }) {
|
|
258
|
+
if (prop("modal")) return;
|
|
259
|
+
raf(() => {
|
|
260
|
+
const element = getInitialFocus({
|
|
261
|
+
root: getContentEl(scope),
|
|
262
|
+
getInitialEl: prop("initialFocusEl"),
|
|
263
|
+
enabled: prop("autoFocus")
|
|
264
|
+
});
|
|
265
|
+
if (!element) return;
|
|
266
|
+
element.focus({ preventScroll: true });
|
|
267
|
+
});
|
|
268
|
+
},
|
|
269
|
+
setFinalFocus({ event, prop, scope, context }) {
|
|
270
|
+
const eventRestoreFocus = event.restoreFocus ?? event.previousEvent?.restoreFocus;
|
|
271
|
+
if (eventRestoreFocus != null && !eventRestoreFocus) return;
|
|
272
|
+
if (!prop("restoreFocus")) return;
|
|
273
|
+
const focusOptions = getReturnFocusOptions(event);
|
|
274
|
+
raf(() => {
|
|
275
|
+
const finalFocusEl = prop("finalFocusEl")?.();
|
|
276
|
+
if (finalFocusEl) {
|
|
277
|
+
finalFocusEl.focus(focusOptions);
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
getActiveTriggerEl(scope, context.get("triggerValue"))?.focus(focusOptions);
|
|
281
|
+
});
|
|
282
|
+
},
|
|
283
|
+
invokeOnOpen({ prop, flush }) {
|
|
284
|
+
flush(() => {
|
|
285
|
+
prop("onOpenChange")?.({ open: true });
|
|
286
|
+
});
|
|
287
|
+
},
|
|
288
|
+
invokeOnClose({ prop, flush }) {
|
|
289
|
+
flush(() => {
|
|
290
|
+
prop("onOpenChange")?.({ open: false });
|
|
291
|
+
});
|
|
292
|
+
},
|
|
293
|
+
toggleVisibility({ event, send, prop }) {
|
|
294
|
+
send({
|
|
295
|
+
type: prop("open") ? "CONTROLLED.OPEN" : "CONTROLLED.CLOSE",
|
|
296
|
+
previousEvent: event
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
301
|
});
|
|
302
302
|
function getReturnFocusOptions(event) {
|
|
303
|
-
|
|
304
|
-
|
|
303
|
+
return event.focusVisible ?? event.previousEvent?.focusVisible ? {
|
|
304
|
+
preventScroll: true,
|
|
305
|
+
focusVisible: true
|
|
306
|
+
} : { preventScroll: true };
|
|
305
307
|
}
|
|
306
|
-
export {
|
|
307
|
-
machine
|
|
308
|
-
};
|
|
308
|
+
export { machine };
|
package/dist/popover.props.d.mts
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
import { PopoverProps } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import '@zag-js/popper';
|
|
5
|
-
import '@zag-js/types';
|
|
6
|
-
|
|
7
|
-
declare const props: (keyof PopoverProps)[];
|
|
8
|
-
declare const splitProps: <Props extends Partial<PopoverProps>>(props: Props) => [Partial<PopoverProps>, Omit<Props, keyof PopoverProps>];
|
|
9
|
-
|
|
10
|
-
export { props, splitProps };
|
|
1
|
+
import { PopoverProps } from "./popover.types.mjs";
|
|
2
|
+
export declare const props: (keyof PopoverProps)[];
|
|
3
|
+
export declare const splitProps: <Props extends Partial<PopoverProps>>(props: Props) => [Partial<PopoverProps>, Omit<Props, keyof PopoverProps>];
|
package/dist/popover.props.d.ts
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
import { PopoverProps } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import '@zag-js/popper';
|
|
5
|
-
import '@zag-js/types';
|
|
6
|
-
|
|
7
|
-
declare const props: (keyof PopoverProps)[];
|
|
8
|
-
declare const splitProps: <Props extends Partial<PopoverProps>>(props: Props) => [Partial<PopoverProps>, Omit<Props, keyof PopoverProps>];
|
|
9
|
-
|
|
10
|
-
export { props, splitProps };
|
|
1
|
+
import { PopoverProps } from "./popover.types.js";
|
|
2
|
+
export declare const props: (keyof PopoverProps)[];
|
|
3
|
+
export declare const splitProps: <Props extends Partial<PopoverProps>>(props: Props) => [Partial<PopoverProps>, Omit<Props, keyof PopoverProps>];
|