@zag-js/popover 1.39.1 → 1.41.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.connect.js +4 -1
- package/dist/popover.connect.mjs +5 -2
- package/dist/popover.dom.d.mts +2 -1
- package/dist/popover.dom.d.ts +2 -1
- package/dist/popover.dom.js +8 -2
- package/dist/popover.dom.mjs +7 -2
- package/dist/popover.machine.js +30 -9
- package/dist/popover.machine.mjs +30 -9
- package/dist/popover.props.js +2 -0
- package/dist/popover.props.mjs +2 -0
- package/dist/popover.types.d.mts +12 -2
- package/dist/popover.types.d.ts +12 -2
- package/package.json +11 -11
package/dist/popover.connect.js
CHANGED
|
@@ -42,6 +42,7 @@ function connect(service, normalize) {
|
|
|
42
42
|
const translations = prop("translations");
|
|
43
43
|
const open = state.matches("open");
|
|
44
44
|
const currentPlacement = context.get("currentPlacement");
|
|
45
|
+
const currentPlacementSide = currentPlacement ? (0, import_popper.getPlacementSide)(currentPlacement) : void 0;
|
|
45
46
|
const portalled = computed("currentPortalled");
|
|
46
47
|
const rendered = context.get("renderedElements");
|
|
47
48
|
const triggerValue = context.get("triggerValue");
|
|
@@ -94,6 +95,7 @@ function connect(service, normalize) {
|
|
|
94
95
|
dir: prop("dir"),
|
|
95
96
|
type: "button",
|
|
96
97
|
"data-placement": currentPlacement,
|
|
98
|
+
"data-side": currentPlacementSide,
|
|
97
99
|
id: dom.getTriggerId(scope, value),
|
|
98
100
|
"data-ownedby": scope.id,
|
|
99
101
|
"data-value": value,
|
|
@@ -146,7 +148,8 @@ function connect(service, normalize) {
|
|
|
146
148
|
"data-expanded": (0, import_dom_query.dataAttr)(open),
|
|
147
149
|
"aria-labelledby": rendered.title ? dom.getTitleId(scope) : void 0,
|
|
148
150
|
"aria-describedby": rendered.description ? dom.getDescriptionId(scope) : void 0,
|
|
149
|
-
"data-placement": currentPlacement
|
|
151
|
+
"data-placement": currentPlacement,
|
|
152
|
+
"data-side": currentPlacementSide
|
|
150
153
|
});
|
|
151
154
|
},
|
|
152
155
|
getTitleProps() {
|
package/dist/popover.connect.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/popover.connect.ts
|
|
2
2
|
import { ariaAttr, dataAttr, isLeftClick, isSafari } from "@zag-js/dom-query";
|
|
3
|
-
import { getPlacementStyles } from "@zag-js/popper";
|
|
3
|
+
import { getPlacementSide, getPlacementStyles } from "@zag-js/popper";
|
|
4
4
|
import { parts } from "./popover.anatomy.mjs";
|
|
5
5
|
import * as dom from "./popover.dom.mjs";
|
|
6
6
|
function connect(service, normalize) {
|
|
@@ -8,6 +8,7 @@ function connect(service, normalize) {
|
|
|
8
8
|
const translations = prop("translations");
|
|
9
9
|
const open = state.matches("open");
|
|
10
10
|
const currentPlacement = context.get("currentPlacement");
|
|
11
|
+
const currentPlacementSide = currentPlacement ? getPlacementSide(currentPlacement) : void 0;
|
|
11
12
|
const portalled = computed("currentPortalled");
|
|
12
13
|
const rendered = context.get("renderedElements");
|
|
13
14
|
const triggerValue = context.get("triggerValue");
|
|
@@ -60,6 +61,7 @@ function connect(service, normalize) {
|
|
|
60
61
|
dir: prop("dir"),
|
|
61
62
|
type: "button",
|
|
62
63
|
"data-placement": currentPlacement,
|
|
64
|
+
"data-side": currentPlacementSide,
|
|
63
65
|
id: dom.getTriggerId(scope, value),
|
|
64
66
|
"data-ownedby": scope.id,
|
|
65
67
|
"data-value": value,
|
|
@@ -112,7 +114,8 @@ function connect(service, normalize) {
|
|
|
112
114
|
"data-expanded": dataAttr(open),
|
|
113
115
|
"aria-labelledby": rendered.title ? dom.getTitleId(scope) : void 0,
|
|
114
116
|
"aria-describedby": rendered.description ? dom.getDescriptionId(scope) : void 0,
|
|
115
|
-
"data-placement": currentPlacement
|
|
117
|
+
"data-placement": currentPlacement,
|
|
118
|
+
"data-side": currentPlacementSide
|
|
116
119
|
});
|
|
117
120
|
},
|
|
118
121
|
getTitleProps() {
|
package/dist/popover.dom.d.mts
CHANGED
|
@@ -9,6 +9,7 @@ declare const getTitleId: (scope: Scope) => any;
|
|
|
9
9
|
declare const getDescriptionId: (scope: Scope) => any;
|
|
10
10
|
declare const getCloseTriggerId: (scope: Scope) => any;
|
|
11
11
|
declare const getAnchorEl: (scope: Scope) => HTMLElement | null;
|
|
12
|
+
declare const getTriggerEl: (scope: Scope) => HTMLElement | null;
|
|
12
13
|
declare const getTriggerEls: (scope: Scope) => HTMLElement[];
|
|
13
14
|
declare const getActiveTriggerEl: (scope: Scope, value: string | null) => HTMLElement | null;
|
|
14
15
|
declare const getContentEl: (scope: Scope) => HTMLElement | null;
|
|
@@ -18,4 +19,4 @@ declare const getDescriptionEl: (scope: Scope) => HTMLElement | null;
|
|
|
18
19
|
declare const getFocusableEls: (scope: Scope) => HTMLElement[];
|
|
19
20
|
declare const getFirstFocusableEl: (scope: Scope) => HTMLElement;
|
|
20
21
|
|
|
21
|
-
export { getActiveTriggerEl, getAnchorEl, getAnchorId, getArrowId, getCloseTriggerId, getContentEl, getContentId, getDescriptionEl, getDescriptionId, getFirstFocusableEl, getFocusableEls, getPositionerEl, getPositionerId, getTitleEl, getTitleId, getTriggerEls, getTriggerId };
|
|
22
|
+
export { getActiveTriggerEl, getAnchorEl, getAnchorId, getArrowId, getCloseTriggerId, getContentEl, getContentId, getDescriptionEl, getDescriptionId, getFirstFocusableEl, getFocusableEls, getPositionerEl, getPositionerId, getTitleEl, getTitleId, getTriggerEl, getTriggerEls, getTriggerId };
|
package/dist/popover.dom.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ declare const getTitleId: (scope: Scope) => any;
|
|
|
9
9
|
declare const getDescriptionId: (scope: Scope) => any;
|
|
10
10
|
declare const getCloseTriggerId: (scope: Scope) => any;
|
|
11
11
|
declare const getAnchorEl: (scope: Scope) => HTMLElement | null;
|
|
12
|
+
declare const getTriggerEl: (scope: Scope) => HTMLElement | null;
|
|
12
13
|
declare const getTriggerEls: (scope: Scope) => HTMLElement[];
|
|
13
14
|
declare const getActiveTriggerEl: (scope: Scope, value: string | null) => HTMLElement | null;
|
|
14
15
|
declare const getContentEl: (scope: Scope) => HTMLElement | null;
|
|
@@ -18,4 +19,4 @@ declare const getDescriptionEl: (scope: Scope) => HTMLElement | null;
|
|
|
18
19
|
declare const getFocusableEls: (scope: Scope) => HTMLElement[];
|
|
19
20
|
declare const getFirstFocusableEl: (scope: Scope) => HTMLElement;
|
|
20
21
|
|
|
21
|
-
export { getActiveTriggerEl, getAnchorEl, getAnchorId, getArrowId, getCloseTriggerId, getContentEl, getContentId, getDescriptionEl, getDescriptionId, getFirstFocusableEl, getFocusableEls, getPositionerEl, getPositionerId, getTitleEl, getTitleId, getTriggerEls, getTriggerId };
|
|
22
|
+
export { getActiveTriggerEl, getAnchorEl, getAnchorId, getArrowId, getCloseTriggerId, getContentEl, getContentId, getDescriptionEl, getDescriptionId, getFirstFocusableEl, getFocusableEls, getPositionerEl, getPositionerId, getTitleEl, getTitleId, getTriggerEl, getTriggerEls, getTriggerId };
|
package/dist/popover.dom.js
CHANGED
|
@@ -35,6 +35,7 @@ __export(popover_dom_exports, {
|
|
|
35
35
|
getPositionerId: () => getPositionerId,
|
|
36
36
|
getTitleEl: () => getTitleEl,
|
|
37
37
|
getTitleId: () => getTitleId,
|
|
38
|
+
getTriggerEl: () => getTriggerEl,
|
|
38
39
|
getTriggerEls: () => getTriggerEls,
|
|
39
40
|
getTriggerId: () => getTriggerId
|
|
40
41
|
});
|
|
@@ -54,9 +55,13 @@ var getTitleId = (scope) => scope.ids?.title ?? `popover:${scope.id}:title`;
|
|
|
54
55
|
var getDescriptionId = (scope) => scope.ids?.description ?? `popover:${scope.id}:desc`;
|
|
55
56
|
var getCloseTriggerId = (scope) => scope.ids?.closeTrigger ?? `popover:${scope.id}:close`;
|
|
56
57
|
var getAnchorEl = (scope) => scope.getById(getAnchorId(scope));
|
|
57
|
-
var
|
|
58
|
+
var getTriggerEl = (scope) => scope.getById(getTriggerId(scope));
|
|
59
|
+
var getTriggerEls = (scope) => (0, import_dom_query.queryAll)(scope.getRootNode(), `[data-scope="popover"][data-part="trigger"][data-ownedby="${scope.id}"]`);
|
|
58
60
|
var getActiveTriggerEl = (scope, value) => {
|
|
59
|
-
|
|
61
|
+
if (value == null) {
|
|
62
|
+
return getTriggerEl(scope) ?? getTriggerEls(scope)[0];
|
|
63
|
+
}
|
|
64
|
+
return scope.getById(getTriggerId(scope, value));
|
|
60
65
|
};
|
|
61
66
|
var getContentEl = (scope) => scope.getById(getContentId(scope));
|
|
62
67
|
var getPositionerEl = (scope) => scope.getById(getPositionerId(scope));
|
|
@@ -81,6 +86,7 @@ var getFirstFocusableEl = (scope) => getFocusableEls(scope)[0];
|
|
|
81
86
|
getPositionerId,
|
|
82
87
|
getTitleEl,
|
|
83
88
|
getTitleId,
|
|
89
|
+
getTriggerEl,
|
|
84
90
|
getTriggerEls,
|
|
85
91
|
getTriggerId
|
|
86
92
|
});
|
package/dist/popover.dom.mjs
CHANGED
|
@@ -14,9 +14,13 @@ var getTitleId = (scope) => scope.ids?.title ?? `popover:${scope.id}:title`;
|
|
|
14
14
|
var getDescriptionId = (scope) => scope.ids?.description ?? `popover:${scope.id}:desc`;
|
|
15
15
|
var getCloseTriggerId = (scope) => scope.ids?.closeTrigger ?? `popover:${scope.id}:close`;
|
|
16
16
|
var getAnchorEl = (scope) => scope.getById(getAnchorId(scope));
|
|
17
|
-
var
|
|
17
|
+
var getTriggerEl = (scope) => scope.getById(getTriggerId(scope));
|
|
18
|
+
var getTriggerEls = (scope) => queryAll(scope.getRootNode(), `[data-scope="popover"][data-part="trigger"][data-ownedby="${scope.id}"]`);
|
|
18
19
|
var getActiveTriggerEl = (scope, value) => {
|
|
19
|
-
|
|
20
|
+
if (value == null) {
|
|
21
|
+
return getTriggerEl(scope) ?? getTriggerEls(scope)[0];
|
|
22
|
+
}
|
|
23
|
+
return scope.getById(getTriggerId(scope, value));
|
|
20
24
|
};
|
|
21
25
|
var getContentEl = (scope) => scope.getById(getContentId(scope));
|
|
22
26
|
var getPositionerEl = (scope) => scope.getById(getPositionerId(scope));
|
|
@@ -40,6 +44,7 @@ export {
|
|
|
40
44
|
getPositionerId,
|
|
41
45
|
getTitleEl,
|
|
42
46
|
getTitleId,
|
|
47
|
+
getTriggerEl,
|
|
43
48
|
getTriggerEls,
|
|
44
49
|
getTriggerId
|
|
45
50
|
};
|
package/dist/popover.machine.js
CHANGED
|
@@ -49,6 +49,7 @@ var machine = (0, import_core.createMachine)({
|
|
|
49
49
|
autoFocus: true,
|
|
50
50
|
modal: false,
|
|
51
51
|
portalled: true,
|
|
52
|
+
restoreFocus: true,
|
|
52
53
|
...props,
|
|
53
54
|
translations: {
|
|
54
55
|
closeTriggerLabel: "close",
|
|
@@ -176,8 +177,8 @@ var machine = (0, import_core.createMachine)({
|
|
|
176
177
|
context.set("currentPlacement", prop("positioning").placement);
|
|
177
178
|
const anchorEl = dom.getAnchorEl(scope);
|
|
178
179
|
const getPositionerEl2 = () => dom.getPositionerEl(scope);
|
|
179
|
-
const
|
|
180
|
-
return (0, import_popper.getPlacement)(
|
|
180
|
+
const getTriggerEl2 = () => anchorEl ?? dom.getActiveTriggerEl(scope, context.get("triggerValue"));
|
|
181
|
+
return (0, import_popper.getPlacement)(getTriggerEl2, getPositionerEl2, {
|
|
181
182
|
...prop("positioning"),
|
|
182
183
|
defer: true,
|
|
183
184
|
onComplete(data) {
|
|
@@ -191,7 +192,7 @@ var machine = (0, import_core.createMachine)({
|
|
|
191
192
|
return (0, import_dismissable.trackDismissableElement)(getContentEl2, {
|
|
192
193
|
type: "popover",
|
|
193
194
|
pointerBlocking: prop("modal"),
|
|
194
|
-
exclude: dom.getTriggerEls(scope),
|
|
195
|
+
exclude: [dom.getTriggerEl(scope), ...dom.getTriggerEls(scope)].filter(Boolean),
|
|
195
196
|
defer: true,
|
|
196
197
|
onEscapeKeyDown(event) {
|
|
197
198
|
prop("onEscapeKeyDown")?.(event);
|
|
@@ -236,15 +237,29 @@ var machine = (0, import_core.createMachine)({
|
|
|
236
237
|
if (!prop("modal")) return;
|
|
237
238
|
return (0, import_remove_scroll.preventBodyScroll)(scope.getDoc());
|
|
238
239
|
},
|
|
239
|
-
trapFocus({ prop, scope }) {
|
|
240
|
+
trapFocus({ prop, scope, context }) {
|
|
240
241
|
if (!prop("modal")) return;
|
|
241
242
|
const contentEl = () => dom.getContentEl(scope);
|
|
242
243
|
return (0, import_focus_trap.trapFocus)(contentEl, {
|
|
244
|
+
preventScroll: true,
|
|
245
|
+
returnFocusOnDeactivate: !!prop("restoreFocus"),
|
|
243
246
|
initialFocus: () => (0, import_dom_query.getInitialFocus)({
|
|
244
247
|
root: dom.getContentEl(scope),
|
|
245
248
|
getInitialEl: prop("initialFocusEl"),
|
|
246
249
|
enabled: prop("autoFocus")
|
|
247
250
|
}),
|
|
251
|
+
setReturnFocus: (el) => {
|
|
252
|
+
const finalFocusEl = prop("finalFocusEl")?.();
|
|
253
|
+
if (finalFocusEl) return finalFocusEl;
|
|
254
|
+
const triggerValue = context.get("triggerValue");
|
|
255
|
+
if (triggerValue) {
|
|
256
|
+
const activeTriggerEl = dom.getActiveTriggerEl(scope, triggerValue);
|
|
257
|
+
if (activeTriggerEl) return activeTriggerEl;
|
|
258
|
+
}
|
|
259
|
+
const fallbackTrigger = dom.getTriggerEls(scope)[0];
|
|
260
|
+
if (fallbackTrigger) return fallbackTrigger;
|
|
261
|
+
return el;
|
|
262
|
+
},
|
|
248
263
|
getShadowRoot: true
|
|
249
264
|
});
|
|
250
265
|
}
|
|
@@ -253,8 +268,8 @@ var machine = (0, import_core.createMachine)({
|
|
|
253
268
|
reposition({ event, prop, scope, context }) {
|
|
254
269
|
const anchorEl = dom.getAnchorEl(scope);
|
|
255
270
|
const getPositionerEl2 = () => dom.getPositionerEl(scope);
|
|
256
|
-
const
|
|
257
|
-
(0, import_popper.getPlacement)(
|
|
271
|
+
const getTriggerEl2 = () => anchorEl ?? dom.getActiveTriggerEl(scope, context.get("triggerValue"));
|
|
272
|
+
(0, import_popper.getPlacement)(getTriggerEl2, getPositionerEl2, {
|
|
258
273
|
...prop("positioning"),
|
|
259
274
|
...event.options,
|
|
260
275
|
defer: true,
|
|
@@ -287,10 +302,16 @@ var machine = (0, import_core.createMachine)({
|
|
|
287
302
|
element?.focus({ preventScroll: true });
|
|
288
303
|
});
|
|
289
304
|
},
|
|
290
|
-
setFinalFocus({ event, scope, context }) {
|
|
291
|
-
const
|
|
292
|
-
if (
|
|
305
|
+
setFinalFocus({ event, prop, scope, context }) {
|
|
306
|
+
const eventRestoreFocus = event.restoreFocus ?? event.previousEvent?.restoreFocus;
|
|
307
|
+
if (eventRestoreFocus != null && !eventRestoreFocus) return;
|
|
308
|
+
if (!prop("restoreFocus")) return;
|
|
293
309
|
(0, import_dom_query.raf)(() => {
|
|
310
|
+
const finalFocusEl = prop("finalFocusEl")?.();
|
|
311
|
+
if (finalFocusEl) {
|
|
312
|
+
finalFocusEl.focus({ preventScroll: true });
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
294
315
|
const element = dom.getActiveTriggerEl(scope, context.get("triggerValue"));
|
|
295
316
|
element?.focus({ preventScroll: true });
|
|
296
317
|
});
|
package/dist/popover.machine.mjs
CHANGED
|
@@ -15,6 +15,7 @@ var machine = createMachine({
|
|
|
15
15
|
autoFocus: true,
|
|
16
16
|
modal: false,
|
|
17
17
|
portalled: true,
|
|
18
|
+
restoreFocus: true,
|
|
18
19
|
...props,
|
|
19
20
|
translations: {
|
|
20
21
|
closeTriggerLabel: "close",
|
|
@@ -142,8 +143,8 @@ var machine = createMachine({
|
|
|
142
143
|
context.set("currentPlacement", prop("positioning").placement);
|
|
143
144
|
const anchorEl = dom.getAnchorEl(scope);
|
|
144
145
|
const getPositionerEl2 = () => dom.getPositionerEl(scope);
|
|
145
|
-
const
|
|
146
|
-
return getPlacement(
|
|
146
|
+
const getTriggerEl2 = () => anchorEl ?? dom.getActiveTriggerEl(scope, context.get("triggerValue"));
|
|
147
|
+
return getPlacement(getTriggerEl2, getPositionerEl2, {
|
|
147
148
|
...prop("positioning"),
|
|
148
149
|
defer: true,
|
|
149
150
|
onComplete(data) {
|
|
@@ -157,7 +158,7 @@ var machine = createMachine({
|
|
|
157
158
|
return trackDismissableElement(getContentEl2, {
|
|
158
159
|
type: "popover",
|
|
159
160
|
pointerBlocking: prop("modal"),
|
|
160
|
-
exclude: dom.getTriggerEls(scope),
|
|
161
|
+
exclude: [dom.getTriggerEl(scope), ...dom.getTriggerEls(scope)].filter(Boolean),
|
|
161
162
|
defer: true,
|
|
162
163
|
onEscapeKeyDown(event) {
|
|
163
164
|
prop("onEscapeKeyDown")?.(event);
|
|
@@ -202,15 +203,29 @@ var machine = createMachine({
|
|
|
202
203
|
if (!prop("modal")) return;
|
|
203
204
|
return preventBodyScroll(scope.getDoc());
|
|
204
205
|
},
|
|
205
|
-
trapFocus({ prop, scope }) {
|
|
206
|
+
trapFocus({ prop, scope, context }) {
|
|
206
207
|
if (!prop("modal")) return;
|
|
207
208
|
const contentEl = () => dom.getContentEl(scope);
|
|
208
209
|
return trapFocus(contentEl, {
|
|
210
|
+
preventScroll: true,
|
|
211
|
+
returnFocusOnDeactivate: !!prop("restoreFocus"),
|
|
209
212
|
initialFocus: () => getInitialFocus({
|
|
210
213
|
root: dom.getContentEl(scope),
|
|
211
214
|
getInitialEl: prop("initialFocusEl"),
|
|
212
215
|
enabled: prop("autoFocus")
|
|
213
216
|
}),
|
|
217
|
+
setReturnFocus: (el) => {
|
|
218
|
+
const finalFocusEl = prop("finalFocusEl")?.();
|
|
219
|
+
if (finalFocusEl) return finalFocusEl;
|
|
220
|
+
const triggerValue = context.get("triggerValue");
|
|
221
|
+
if (triggerValue) {
|
|
222
|
+
const activeTriggerEl = dom.getActiveTriggerEl(scope, triggerValue);
|
|
223
|
+
if (activeTriggerEl) return activeTriggerEl;
|
|
224
|
+
}
|
|
225
|
+
const fallbackTrigger = dom.getTriggerEls(scope)[0];
|
|
226
|
+
if (fallbackTrigger) return fallbackTrigger;
|
|
227
|
+
return el;
|
|
228
|
+
},
|
|
214
229
|
getShadowRoot: true
|
|
215
230
|
});
|
|
216
231
|
}
|
|
@@ -219,8 +234,8 @@ var machine = createMachine({
|
|
|
219
234
|
reposition({ event, prop, scope, context }) {
|
|
220
235
|
const anchorEl = dom.getAnchorEl(scope);
|
|
221
236
|
const getPositionerEl2 = () => dom.getPositionerEl(scope);
|
|
222
|
-
const
|
|
223
|
-
getPlacement(
|
|
237
|
+
const getTriggerEl2 = () => anchorEl ?? dom.getActiveTriggerEl(scope, context.get("triggerValue"));
|
|
238
|
+
getPlacement(getTriggerEl2, getPositionerEl2, {
|
|
224
239
|
...prop("positioning"),
|
|
225
240
|
...event.options,
|
|
226
241
|
defer: true,
|
|
@@ -253,10 +268,16 @@ var machine = createMachine({
|
|
|
253
268
|
element?.focus({ preventScroll: true });
|
|
254
269
|
});
|
|
255
270
|
},
|
|
256
|
-
setFinalFocus({ event, scope, context }) {
|
|
257
|
-
const
|
|
258
|
-
if (
|
|
271
|
+
setFinalFocus({ event, prop, scope, context }) {
|
|
272
|
+
const eventRestoreFocus = event.restoreFocus ?? event.previousEvent?.restoreFocus;
|
|
273
|
+
if (eventRestoreFocus != null && !eventRestoreFocus) return;
|
|
274
|
+
if (!prop("restoreFocus")) return;
|
|
259
275
|
raf(() => {
|
|
276
|
+
const finalFocusEl = prop("finalFocusEl")?.();
|
|
277
|
+
if (finalFocusEl) {
|
|
278
|
+
finalFocusEl.focus({ preventScroll: true });
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
260
281
|
const element = dom.getActiveTriggerEl(scope, context.get("triggerValue"));
|
|
261
282
|
element?.focus({ preventScroll: true });
|
|
262
283
|
});
|
package/dist/popover.props.js
CHANGED
|
@@ -36,6 +36,7 @@ var props = (0, import_types.createProps)()([
|
|
|
36
36
|
"getRootNode",
|
|
37
37
|
"id",
|
|
38
38
|
"ids",
|
|
39
|
+
"finalFocusEl",
|
|
39
40
|
"initialFocusEl",
|
|
40
41
|
"modal",
|
|
41
42
|
"onEscapeKeyDown",
|
|
@@ -48,6 +49,7 @@ var props = (0, import_types.createProps)()([
|
|
|
48
49
|
"open",
|
|
49
50
|
"persistentElements",
|
|
50
51
|
"portalled",
|
|
52
|
+
"restoreFocus",
|
|
51
53
|
"positioning",
|
|
52
54
|
"translations",
|
|
53
55
|
"triggerValue"
|
package/dist/popover.props.mjs
CHANGED
|
@@ -11,6 +11,7 @@ var props = createProps()([
|
|
|
11
11
|
"getRootNode",
|
|
12
12
|
"id",
|
|
13
13
|
"ids",
|
|
14
|
+
"finalFocusEl",
|
|
14
15
|
"initialFocusEl",
|
|
15
16
|
"modal",
|
|
16
17
|
"onEscapeKeyDown",
|
|
@@ -23,6 +24,7 @@ var props = createProps()([
|
|
|
23
24
|
"open",
|
|
24
25
|
"persistentElements",
|
|
25
26
|
"portalled",
|
|
27
|
+
"restoreFocus",
|
|
26
28
|
"positioning",
|
|
27
29
|
"translations",
|
|
28
30
|
"triggerValue"
|
package/dist/popover.types.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import { Machine, EventObject, Service } from '@zag-js/core';
|
|
|
2
2
|
import { DismissableElementHandlers, PersistentElementOptions } from '@zag-js/dismissable';
|
|
3
3
|
import { PositioningOptions, Placement } from '@zag-js/popper';
|
|
4
4
|
export { Placement, PositioningOptions } from '@zag-js/popper';
|
|
5
|
-
import { PropTypes, RequiredBy, CommonProperties, DirectionProperty } from '@zag-js/types';
|
|
5
|
+
import { PropTypes, RequiredBy, CommonProperties, DirectionProperty, MaybeElement } from '@zag-js/types';
|
|
6
6
|
|
|
7
7
|
interface OpenChangeDetails {
|
|
8
8
|
open: boolean;
|
|
@@ -67,6 +67,16 @@ interface PopoverProps extends CommonProperties, DirectionProperty, DismissableE
|
|
|
67
67
|
* The element to focus on when the popover is opened.
|
|
68
68
|
*/
|
|
69
69
|
initialFocusEl?: (() => HTMLElement | null) | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Element to receive focus when the popover is closed.
|
|
72
|
+
*/
|
|
73
|
+
finalFocusEl?: (() => MaybeElement) | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* Whether to restore focus to the element that had focus before the popover was opened.
|
|
76
|
+
*
|
|
77
|
+
* @default true
|
|
78
|
+
*/
|
|
79
|
+
restoreFocus?: boolean | undefined;
|
|
70
80
|
/**
|
|
71
81
|
* Whether to close the popover when the user clicks outside of the popover.
|
|
72
82
|
* @default true
|
|
@@ -108,7 +118,7 @@ interface PopoverProps extends CommonProperties, DirectionProperty, DismissableE
|
|
|
108
118
|
*/
|
|
109
119
|
onTriggerValueChange?: ((details: TriggerValueChangeDetails) => void) | undefined;
|
|
110
120
|
}
|
|
111
|
-
type PropsWithDefault = "closeOnInteractOutside" | "closeOnEscape" | "modal" | "portalled" | "autoFocus" | "positioning" | "translations";
|
|
121
|
+
type PropsWithDefault = "closeOnInteractOutside" | "closeOnEscape" | "modal" | "portalled" | "autoFocus" | "restoreFocus" | "positioning" | "translations";
|
|
112
122
|
type ComputedContext = Readonly<{
|
|
113
123
|
/**
|
|
114
124
|
* The computed value of `portalled`
|
package/dist/popover.types.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Machine, EventObject, Service } from '@zag-js/core';
|
|
|
2
2
|
import { DismissableElementHandlers, PersistentElementOptions } from '@zag-js/dismissable';
|
|
3
3
|
import { PositioningOptions, Placement } from '@zag-js/popper';
|
|
4
4
|
export { Placement, PositioningOptions } from '@zag-js/popper';
|
|
5
|
-
import { PropTypes, RequiredBy, CommonProperties, DirectionProperty } from '@zag-js/types';
|
|
5
|
+
import { PropTypes, RequiredBy, CommonProperties, DirectionProperty, MaybeElement } from '@zag-js/types';
|
|
6
6
|
|
|
7
7
|
interface OpenChangeDetails {
|
|
8
8
|
open: boolean;
|
|
@@ -67,6 +67,16 @@ interface PopoverProps extends CommonProperties, DirectionProperty, DismissableE
|
|
|
67
67
|
* The element to focus on when the popover is opened.
|
|
68
68
|
*/
|
|
69
69
|
initialFocusEl?: (() => HTMLElement | null) | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Element to receive focus when the popover is closed.
|
|
72
|
+
*/
|
|
73
|
+
finalFocusEl?: (() => MaybeElement) | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* Whether to restore focus to the element that had focus before the popover was opened.
|
|
76
|
+
*
|
|
77
|
+
* @default true
|
|
78
|
+
*/
|
|
79
|
+
restoreFocus?: boolean | undefined;
|
|
70
80
|
/**
|
|
71
81
|
* Whether to close the popover when the user clicks outside of the popover.
|
|
72
82
|
* @default true
|
|
@@ -108,7 +118,7 @@ interface PopoverProps extends CommonProperties, DirectionProperty, DismissableE
|
|
|
108
118
|
*/
|
|
109
119
|
onTriggerValueChange?: ((details: TriggerValueChangeDetails) => void) | undefined;
|
|
110
120
|
}
|
|
111
|
-
type PropsWithDefault = "closeOnInteractOutside" | "closeOnEscape" | "modal" | "portalled" | "autoFocus" | "positioning" | "translations";
|
|
121
|
+
type PropsWithDefault = "closeOnInteractOutside" | "closeOnEscape" | "modal" | "portalled" | "autoFocus" | "restoreFocus" | "positioning" | "translations";
|
|
112
122
|
type ComputedContext = Readonly<{
|
|
113
123
|
/**
|
|
114
124
|
* The computed value of `portalled`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/popover",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.41.0",
|
|
4
4
|
"description": "Core logic for the popover widget implemented as a state machine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -26,16 +26,16 @@
|
|
|
26
26
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@zag-js/anatomy": "1.
|
|
30
|
-
"@zag-js/aria-hidden": "1.
|
|
31
|
-
"@zag-js/core": "1.
|
|
32
|
-
"@zag-js/dom-query": "1.
|
|
33
|
-
"@zag-js/utils": "1.
|
|
34
|
-
"@zag-js/dismissable": "1.
|
|
35
|
-
"@zag-js/popper": "1.
|
|
36
|
-
"@zag-js/remove-scroll": "1.
|
|
37
|
-
"@zag-js/types": "1.
|
|
38
|
-
"@zag-js/focus-trap": "1.
|
|
29
|
+
"@zag-js/anatomy": "1.41.0",
|
|
30
|
+
"@zag-js/aria-hidden": "1.41.0",
|
|
31
|
+
"@zag-js/core": "1.41.0",
|
|
32
|
+
"@zag-js/dom-query": "1.41.0",
|
|
33
|
+
"@zag-js/utils": "1.41.0",
|
|
34
|
+
"@zag-js/dismissable": "1.41.0",
|
|
35
|
+
"@zag-js/popper": "1.41.0",
|
|
36
|
+
"@zag-js/remove-scroll": "1.41.0",
|
|
37
|
+
"@zag-js/types": "1.41.0",
|
|
38
|
+
"@zag-js/focus-trap": "1.41.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"clean-package": "2.2.0"
|