@zag-js/popover 1.45.0 → 1.47.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/popover.anatomy.d.mts +2 -2
- package/dist/popover.anatomy.d.ts +2 -2
- package/dist/popover.machine.js +13 -5
- package/dist/popover.machine.mjs +13 -5
- package/package.json +11 -11
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _zag_js_anatomy from '@zag-js/anatomy';
|
|
2
2
|
|
|
3
|
-
declare const anatomy: _zag_js_anatomy.AnatomyInstance<"
|
|
4
|
-
declare const parts: Record<"
|
|
3
|
+
declare const anatomy: _zag_js_anatomy.AnatomyInstance<"content" | "title" | "anchor" | "arrow" | "arrowTip" | "trigger" | "indicator" | "positioner" | "description" | "closeTrigger">;
|
|
4
|
+
declare const parts: Record<"content" | "title" | "anchor" | "arrow" | "arrowTip" | "trigger" | "indicator" | "positioner" | "description" | "closeTrigger", _zag_js_anatomy.AnatomyPart>;
|
|
5
5
|
|
|
6
6
|
export { anatomy, parts };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _zag_js_anatomy from '@zag-js/anatomy';
|
|
2
2
|
|
|
3
|
-
declare const anatomy: _zag_js_anatomy.AnatomyInstance<"
|
|
4
|
-
declare const parts: Record<"
|
|
3
|
+
declare const anatomy: _zag_js_anatomy.AnatomyInstance<"content" | "title" | "anchor" | "arrow" | "arrowTip" | "trigger" | "indicator" | "positioner" | "description" | "closeTrigger">;
|
|
4
|
+
declare const parts: Record<"content" | "title" | "anchor" | "arrow" | "arrowTip" | "trigger" | "indicator" | "positioner" | "description" | "closeTrigger", _zag_js_anatomy.AnatomyPart>;
|
|
5
5
|
|
|
6
6
|
export { anatomy, parts };
|
package/dist/popover.machine.js
CHANGED
|
@@ -125,6 +125,7 @@ var machine = (0, import_core.createMachine)({
|
|
|
125
125
|
}
|
|
126
126
|
},
|
|
127
127
|
open: {
|
|
128
|
+
entry: ["checkRenderedElements"],
|
|
128
129
|
effects: [
|
|
129
130
|
"trapFocus",
|
|
130
131
|
"preventScroll",
|
|
@@ -190,6 +191,8 @@ var machine = (0, import_core.createMachine)({
|
|
|
190
191
|
pointerBlocking: prop("modal"),
|
|
191
192
|
exclude: [dom.getTriggerEl(scope), ...dom.getTriggerEls(scope)].filter(Boolean),
|
|
192
193
|
defer: true,
|
|
194
|
+
getRootNode: scope.getRootNode,
|
|
195
|
+
layerStyleTargets: [() => dom.getPositionerEl(scope)],
|
|
193
196
|
onEscapeKeyDown(event) {
|
|
194
197
|
prop("onEscapeKeyDown")?.(event);
|
|
195
198
|
if (prop("closeOnEscape")) return;
|
|
@@ -207,8 +210,8 @@ var machine = (0, import_core.createMachine)({
|
|
|
207
210
|
onFocusOutside: prop("onFocusOutside"),
|
|
208
211
|
persistentElements: prop("persistentElements"),
|
|
209
212
|
onRequestDismiss: prop("onRequestDismiss"),
|
|
210
|
-
onDismiss() {
|
|
211
|
-
send({ type: "CLOSE", src: "interact-outside", restoreFocus });
|
|
213
|
+
onDismiss(event) {
|
|
214
|
+
send({ type: "CLOSE", src: "interact-outside", restoreFocus, focusVisible: event?.type === "keydown" });
|
|
212
215
|
}
|
|
213
216
|
});
|
|
214
217
|
},
|
|
@@ -281,7 +284,7 @@ var machine = (0, import_core.createMachine)({
|
|
|
281
284
|
},
|
|
282
285
|
checkRenderedElements({ context, scope }) {
|
|
283
286
|
(0, import_dom_query.raf)(() => {
|
|
284
|
-
|
|
287
|
+
context.set("renderedElements", {
|
|
285
288
|
title: !!dom.getTitleEl(scope),
|
|
286
289
|
description: !!dom.getDescriptionEl(scope)
|
|
287
290
|
});
|
|
@@ -303,14 +306,15 @@ var machine = (0, import_core.createMachine)({
|
|
|
303
306
|
const eventRestoreFocus = event.restoreFocus ?? event.previousEvent?.restoreFocus;
|
|
304
307
|
if (eventRestoreFocus != null && !eventRestoreFocus) return;
|
|
305
308
|
if (!prop("restoreFocus")) return;
|
|
309
|
+
const focusOptions = getReturnFocusOptions(event);
|
|
306
310
|
(0, import_dom_query.raf)(() => {
|
|
307
311
|
const finalFocusEl = prop("finalFocusEl")?.();
|
|
308
312
|
if (finalFocusEl) {
|
|
309
|
-
finalFocusEl.focus(
|
|
313
|
+
finalFocusEl.focus(focusOptions);
|
|
310
314
|
return;
|
|
311
315
|
}
|
|
312
316
|
const element = dom.getActiveTriggerEl(scope, context.get("triggerValue"));
|
|
313
|
-
element?.focus(
|
|
317
|
+
element?.focus(focusOptions);
|
|
314
318
|
});
|
|
315
319
|
},
|
|
316
320
|
invokeOnOpen({ prop, flush }) {
|
|
@@ -329,6 +333,10 @@ var machine = (0, import_core.createMachine)({
|
|
|
329
333
|
}
|
|
330
334
|
}
|
|
331
335
|
});
|
|
336
|
+
function getReturnFocusOptions(event) {
|
|
337
|
+
const focusVisible = event.focusVisible ?? event.previousEvent?.focusVisible;
|
|
338
|
+
return focusVisible ? { preventScroll: true, focusVisible: true } : { preventScroll: true };
|
|
339
|
+
}
|
|
332
340
|
// Annotate the CommonJS export names for ESM import in node:
|
|
333
341
|
0 && (module.exports = {
|
|
334
342
|
machine
|
package/dist/popover.machine.mjs
CHANGED
|
@@ -91,6 +91,7 @@ var machine = createMachine({
|
|
|
91
91
|
}
|
|
92
92
|
},
|
|
93
93
|
open: {
|
|
94
|
+
entry: ["checkRenderedElements"],
|
|
94
95
|
effects: [
|
|
95
96
|
"trapFocus",
|
|
96
97
|
"preventScroll",
|
|
@@ -156,6 +157,8 @@ var machine = createMachine({
|
|
|
156
157
|
pointerBlocking: prop("modal"),
|
|
157
158
|
exclude: [dom.getTriggerEl(scope), ...dom.getTriggerEls(scope)].filter(Boolean),
|
|
158
159
|
defer: true,
|
|
160
|
+
getRootNode: scope.getRootNode,
|
|
161
|
+
layerStyleTargets: [() => dom.getPositionerEl(scope)],
|
|
159
162
|
onEscapeKeyDown(event) {
|
|
160
163
|
prop("onEscapeKeyDown")?.(event);
|
|
161
164
|
if (prop("closeOnEscape")) return;
|
|
@@ -173,8 +176,8 @@ var machine = createMachine({
|
|
|
173
176
|
onFocusOutside: prop("onFocusOutside"),
|
|
174
177
|
persistentElements: prop("persistentElements"),
|
|
175
178
|
onRequestDismiss: prop("onRequestDismiss"),
|
|
176
|
-
onDismiss() {
|
|
177
|
-
send({ type: "CLOSE", src: "interact-outside", restoreFocus });
|
|
179
|
+
onDismiss(event) {
|
|
180
|
+
send({ type: "CLOSE", src: "interact-outside", restoreFocus, focusVisible: event?.type === "keydown" });
|
|
178
181
|
}
|
|
179
182
|
});
|
|
180
183
|
},
|
|
@@ -247,7 +250,7 @@ var machine = createMachine({
|
|
|
247
250
|
},
|
|
248
251
|
checkRenderedElements({ context, scope }) {
|
|
249
252
|
raf(() => {
|
|
250
|
-
|
|
253
|
+
context.set("renderedElements", {
|
|
251
254
|
title: !!dom.getTitleEl(scope),
|
|
252
255
|
description: !!dom.getDescriptionEl(scope)
|
|
253
256
|
});
|
|
@@ -269,14 +272,15 @@ var machine = createMachine({
|
|
|
269
272
|
const eventRestoreFocus = event.restoreFocus ?? event.previousEvent?.restoreFocus;
|
|
270
273
|
if (eventRestoreFocus != null && !eventRestoreFocus) return;
|
|
271
274
|
if (!prop("restoreFocus")) return;
|
|
275
|
+
const focusOptions = getReturnFocusOptions(event);
|
|
272
276
|
raf(() => {
|
|
273
277
|
const finalFocusEl = prop("finalFocusEl")?.();
|
|
274
278
|
if (finalFocusEl) {
|
|
275
|
-
finalFocusEl.focus(
|
|
279
|
+
finalFocusEl.focus(focusOptions);
|
|
276
280
|
return;
|
|
277
281
|
}
|
|
278
282
|
const element = dom.getActiveTriggerEl(scope, context.get("triggerValue"));
|
|
279
|
-
element?.focus(
|
|
283
|
+
element?.focus(focusOptions);
|
|
280
284
|
});
|
|
281
285
|
},
|
|
282
286
|
invokeOnOpen({ prop, flush }) {
|
|
@@ -295,6 +299,10 @@ var machine = createMachine({
|
|
|
295
299
|
}
|
|
296
300
|
}
|
|
297
301
|
});
|
|
302
|
+
function getReturnFocusOptions(event) {
|
|
303
|
+
const focusVisible = event.focusVisible ?? event.previousEvent?.focusVisible;
|
|
304
|
+
return focusVisible ? { preventScroll: true, focusVisible: true } : { preventScroll: true };
|
|
305
|
+
}
|
|
298
306
|
export {
|
|
299
307
|
machine
|
|
300
308
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/popover",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.47.0",
|
|
4
4
|
"description": "Core logic for the popover widget implemented as a state machine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -29,16 +29,16 @@
|
|
|
29
29
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@zag-js/anatomy": "1.
|
|
33
|
-
"@zag-js/aria-hidden": "1.
|
|
34
|
-
"@zag-js/core": "1.
|
|
35
|
-
"@zag-js/dom-query": "1.
|
|
36
|
-
"@zag-js/utils": "1.
|
|
37
|
-
"@zag-js/dismissable": "1.
|
|
38
|
-
"@zag-js/popper": "1.
|
|
39
|
-
"@zag-js/remove-scroll": "1.
|
|
40
|
-
"@zag-js/types": "1.
|
|
41
|
-
"@zag-js/focus-trap": "1.
|
|
32
|
+
"@zag-js/anatomy": "1.47.0",
|
|
33
|
+
"@zag-js/aria-hidden": "1.47.0",
|
|
34
|
+
"@zag-js/core": "1.47.0",
|
|
35
|
+
"@zag-js/dom-query": "1.47.0",
|
|
36
|
+
"@zag-js/utils": "1.47.0",
|
|
37
|
+
"@zag-js/dismissable": "1.47.0",
|
|
38
|
+
"@zag-js/popper": "1.47.0",
|
|
39
|
+
"@zag-js/remove-scroll": "1.47.0",
|
|
40
|
+
"@zag-js/types": "1.47.0",
|
|
41
|
+
"@zag-js/focus-trap": "1.47.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"clean-package": "2.2.0"
|