@zag-js/popover 0.1.10 → 0.1.13
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/LICENSE +21 -0
- package/dist/index.d.ts +103 -3
- package/dist/index.js +269 -288
- package/dist/index.mjs +264 -291
- package/package.json +16 -15
- package/dist/popover.connect.d.ts +0 -17
- package/dist/popover.dom.d.ts +0 -41
- package/dist/popover.machine.d.ts +0 -2
- package/dist/popover.types.d.ts +0 -101
package/dist/index.js
CHANGED
|
@@ -1,25 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
-
var __spreadValues = (a, b) => {
|
|
12
|
-
for (var prop in b || (b = {}))
|
|
13
|
-
if (__hasOwnProp.call(b, prop))
|
|
14
|
-
__defNormalProp(a, prop, b[prop]);
|
|
15
|
-
if (__getOwnPropSymbols)
|
|
16
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
-
if (__propIsEnum.call(b, prop))
|
|
18
|
-
__defNormalProp(a, prop, b[prop]);
|
|
19
|
-
}
|
|
20
|
-
return a;
|
|
21
|
-
};
|
|
22
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
6
|
var __export = (target, all) => {
|
|
24
7
|
for (var name in all)
|
|
25
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -43,28 +26,12 @@ __export(src_exports, {
|
|
|
43
26
|
module.exports = __toCommonJS(src_exports);
|
|
44
27
|
|
|
45
28
|
// ../../utilities/dom/dist/index.mjs
|
|
46
|
-
var __defProp2 = Object.defineProperty;
|
|
47
|
-
var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
|
|
48
|
-
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
49
|
-
var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
|
|
50
|
-
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
51
|
-
var __spreadValues2 = (a, b) => {
|
|
52
|
-
for (var prop in b || (b = {}))
|
|
53
|
-
if (__hasOwnProp2.call(b, prop))
|
|
54
|
-
__defNormalProp2(a, prop, b[prop]);
|
|
55
|
-
if (__getOwnPropSymbols2)
|
|
56
|
-
for (var prop of __getOwnPropSymbols2(b)) {
|
|
57
|
-
if (__propIsEnum2.call(b, prop))
|
|
58
|
-
__defNormalProp2(a, prop, b[prop]);
|
|
59
|
-
}
|
|
60
|
-
return a;
|
|
61
|
-
};
|
|
62
29
|
var dataAttr = (guard) => {
|
|
63
30
|
return guard ? "" : void 0;
|
|
64
31
|
};
|
|
65
32
|
var runIfFn = (v, ...a) => {
|
|
66
33
|
const res = typeof v === "function" ? v(...a) : v;
|
|
67
|
-
return res
|
|
34
|
+
return res ?? void 0;
|
|
68
35
|
};
|
|
69
36
|
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
70
37
|
function isDocument(el) {
|
|
@@ -77,28 +44,27 @@ function isFrame(element) {
|
|
|
77
44
|
return element.localName === "iframe";
|
|
78
45
|
}
|
|
79
46
|
function getDocument(el) {
|
|
80
|
-
var _a;
|
|
81
47
|
if (isWindow(el))
|
|
82
48
|
return el.document;
|
|
83
49
|
if (isDocument(el))
|
|
84
50
|
return el;
|
|
85
|
-
return (
|
|
51
|
+
return (el == null ? void 0 : el.ownerDocument) ?? document;
|
|
86
52
|
}
|
|
87
53
|
function defineDomHelpers(helpers) {
|
|
88
54
|
const dom2 = {
|
|
89
55
|
getRootNode: (ctx) => {
|
|
90
|
-
var _a, _b;
|
|
91
|
-
return (_b = (_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) != null ? _b : document;
|
|
92
|
-
},
|
|
93
|
-
getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
|
|
94
|
-
getWin: (ctx) => {
|
|
95
56
|
var _a;
|
|
96
|
-
return (_a =
|
|
57
|
+
return ((_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) ?? document;
|
|
97
58
|
},
|
|
59
|
+
getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
|
|
60
|
+
getWin: (ctx) => dom2.getDoc(ctx).defaultView ?? window,
|
|
98
61
|
getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
|
|
99
62
|
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
|
|
100
63
|
};
|
|
101
|
-
return
|
|
64
|
+
return {
|
|
65
|
+
...dom2,
|
|
66
|
+
...helpers
|
|
67
|
+
};
|
|
102
68
|
}
|
|
103
69
|
function contains(parent, child) {
|
|
104
70
|
if (!parent)
|
|
@@ -222,37 +188,37 @@ function next(v, idx, opts = {}) {
|
|
|
222
188
|
}
|
|
223
189
|
var runIfFn2 = (v, ...a) => {
|
|
224
190
|
const res = typeof v === "function" ? v(...a) : v;
|
|
225
|
-
return res
|
|
191
|
+
return res ?? void 0;
|
|
226
192
|
};
|
|
227
193
|
|
|
228
194
|
// src/popover.dom.ts
|
|
229
195
|
var dom = defineDomHelpers({
|
|
230
196
|
getActiveEl: (ctx) => dom.getDoc(ctx).activeElement,
|
|
231
197
|
getAnchorId: (ctx) => {
|
|
232
|
-
var _a
|
|
233
|
-
return (
|
|
198
|
+
var _a;
|
|
199
|
+
return ((_a = ctx.ids) == null ? void 0 : _a.anchor) ?? `popover:${ctx.id}:anchor`;
|
|
234
200
|
},
|
|
235
201
|
getTriggerId: (ctx) => {
|
|
236
|
-
var _a
|
|
237
|
-
return (
|
|
202
|
+
var _a;
|
|
203
|
+
return ((_a = ctx.ids) == null ? void 0 : _a.trigger) ?? `popover:${ctx.id}:trigger`;
|
|
238
204
|
},
|
|
239
205
|
getContentId: (ctx) => {
|
|
240
|
-
var _a
|
|
241
|
-
return (
|
|
206
|
+
var _a;
|
|
207
|
+
return ((_a = ctx.ids) == null ? void 0 : _a.content) ?? `popover:${ctx.id}:content`;
|
|
242
208
|
},
|
|
243
209
|
getPositionerId: (ctx) => `popover:${ctx.id}:popper`,
|
|
244
210
|
getArrowId: (ctx) => `popover:${ctx.id}:arrow`,
|
|
245
211
|
getTitleId: (ctx) => {
|
|
246
|
-
var _a
|
|
247
|
-
return (
|
|
212
|
+
var _a;
|
|
213
|
+
return ((_a = ctx.ids) == null ? void 0 : _a.title) ?? `popover:${ctx.id}:title`;
|
|
248
214
|
},
|
|
249
215
|
getDescriptionId: (ctx) => {
|
|
250
|
-
var _a
|
|
251
|
-
return (
|
|
216
|
+
var _a;
|
|
217
|
+
return ((_a = ctx.ids) == null ? void 0 : _a.description) ?? `popover:${ctx.id}:desc`;
|
|
252
218
|
},
|
|
253
219
|
getCloseButtonId: (ctx) => {
|
|
254
|
-
var _a
|
|
255
|
-
return (
|
|
220
|
+
var _a;
|
|
221
|
+
return ((_a = ctx.ids) == null ? void 0 : _a.closeBtn) ?? `popover:${ctx.id}:close-button`;
|
|
256
222
|
},
|
|
257
223
|
getAnchorEl: (ctx) => dom.getById(ctx, dom.getAnchorId(ctx)),
|
|
258
224
|
getTriggerEl: (ctx) => dom.getById(ctx, dom.getTriggerId(ctx)),
|
|
@@ -369,258 +335,273 @@ var import_remove_scroll = require("@zag-js/remove-scroll");
|
|
|
369
335
|
var import_focus_trap = require("focus-trap");
|
|
370
336
|
var { and, or, not } = import_core.guards;
|
|
371
337
|
function machine(ctx) {
|
|
372
|
-
return (0, import_core.createMachine)(
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
computed: {
|
|
393
|
-
currentPortalled: (ctx2) => !!ctx2.modal || !!ctx2.portalled
|
|
394
|
-
},
|
|
395
|
-
states: {
|
|
396
|
-
unknown: {
|
|
397
|
-
on: {
|
|
398
|
-
SETUP: {
|
|
399
|
-
target: ctx.defaultOpen ? "open" : "closed",
|
|
400
|
-
actions: "checkRenderedElements"
|
|
401
|
-
}
|
|
338
|
+
return (0, import_core.createMachine)(
|
|
339
|
+
{
|
|
340
|
+
id: "popover",
|
|
341
|
+
initial: "unknown",
|
|
342
|
+
context: {
|
|
343
|
+
closeOnInteractOutside: true,
|
|
344
|
+
closeOnEsc: true,
|
|
345
|
+
autoFocus: true,
|
|
346
|
+
modal: false,
|
|
347
|
+
positioning: {
|
|
348
|
+
placement: "bottom",
|
|
349
|
+
...ctx.positioning
|
|
350
|
+
},
|
|
351
|
+
currentPlacement: void 0,
|
|
352
|
+
...ctx,
|
|
353
|
+
focusTriggerOnClose: true,
|
|
354
|
+
renderedElements: {
|
|
355
|
+
title: true,
|
|
356
|
+
description: true,
|
|
357
|
+
anchor: false
|
|
402
358
|
}
|
|
403
359
|
},
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
on: {
|
|
407
|
-
TOGGLE: "open",
|
|
408
|
-
OPEN: "open"
|
|
409
|
-
}
|
|
360
|
+
computed: {
|
|
361
|
+
currentPortalled: (ctx2) => !!ctx2.modal || !!ctx2.portalled
|
|
410
362
|
},
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
"trackInteractionOutside",
|
|
418
|
-
"trackTabKeyDown"
|
|
419
|
-
],
|
|
420
|
-
entry: ["setInitialFocus", "invokeOnOpen"],
|
|
421
|
-
on: {
|
|
422
|
-
CLOSE: "closed",
|
|
423
|
-
REQUEST_CLOSE: {
|
|
424
|
-
target: "closed",
|
|
425
|
-
actions: "focusTriggerIfNeeded"
|
|
426
|
-
},
|
|
427
|
-
TOGGLE: "closed",
|
|
428
|
-
TRIGGER_BLUR: {
|
|
429
|
-
guard: not("isRelatedTargetWithinContent"),
|
|
430
|
-
target: "closed"
|
|
431
|
-
},
|
|
432
|
-
TAB: [
|
|
433
|
-
{
|
|
434
|
-
guard: and("isTriggerFocused", "portalled"),
|
|
435
|
-
actions: "focusFirstTabbableElement"
|
|
436
|
-
},
|
|
437
|
-
{
|
|
438
|
-
guard: and("isLastTabbableElement", "closeOnInteractOutside", "portalled"),
|
|
439
|
-
target: "closed",
|
|
440
|
-
actions: "focusNextTabbableElementAfterTrigger"
|
|
363
|
+
states: {
|
|
364
|
+
unknown: {
|
|
365
|
+
on: {
|
|
366
|
+
SETUP: {
|
|
367
|
+
target: ctx.defaultOpen ? "open" : "closed",
|
|
368
|
+
actions: "checkRenderedElements"
|
|
441
369
|
}
|
|
370
|
+
}
|
|
371
|
+
},
|
|
372
|
+
closed: {
|
|
373
|
+
entry: "invokeOnClose",
|
|
374
|
+
on: {
|
|
375
|
+
TOGGLE: "open",
|
|
376
|
+
OPEN: "open"
|
|
377
|
+
}
|
|
378
|
+
},
|
|
379
|
+
open: {
|
|
380
|
+
activities: [
|
|
381
|
+
"trapFocus",
|
|
382
|
+
"preventScroll",
|
|
383
|
+
"hideContentBelow",
|
|
384
|
+
"computePlacement",
|
|
385
|
+
"trackInteractionOutside",
|
|
386
|
+
"trackTabKeyDown"
|
|
442
387
|
],
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
388
|
+
entry: ["setInitialFocus", "invokeOnOpen"],
|
|
389
|
+
on: {
|
|
390
|
+
CLOSE: "closed",
|
|
391
|
+
REQUEST_CLOSE: {
|
|
392
|
+
target: "closed",
|
|
393
|
+
actions: "focusTriggerIfNeeded"
|
|
394
|
+
},
|
|
395
|
+
TOGGLE: "closed",
|
|
396
|
+
TRIGGER_BLUR: {
|
|
397
|
+
guard: not("isRelatedTargetWithinContent"),
|
|
398
|
+
target: "closed"
|
|
399
|
+
},
|
|
400
|
+
TAB: [
|
|
401
|
+
{
|
|
402
|
+
guard: and("isTriggerFocused", "portalled"),
|
|
403
|
+
actions: "focusFirstTabbableElement"
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
guard: and("isLastTabbableElement", "closeOnInteractOutside", "portalled"),
|
|
407
|
+
target: "closed",
|
|
408
|
+
actions: "focusNextTabbableElementAfterTrigger"
|
|
409
|
+
}
|
|
410
|
+
],
|
|
411
|
+
SHIFT_TAB: {
|
|
412
|
+
guard: and(or("isFirstTabbableElement", "isContentFocused"), "portalled"),
|
|
413
|
+
actions: "focusTriggerIfNeeded"
|
|
414
|
+
}
|
|
446
415
|
}
|
|
447
416
|
}
|
|
448
417
|
}
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
}));
|
|
465
|
-
},
|
|
466
|
-
trackInteractionOutside(ctx2, _evt, { send }) {
|
|
467
|
-
return (0, import_dismissable.trackDismissableElement)(dom.getContentEl(ctx2), {
|
|
468
|
-
pointerBlocking: ctx2.modal,
|
|
469
|
-
exclude: dom.getTriggerEl(ctx2),
|
|
470
|
-
onEscapeKeyDown(event) {
|
|
471
|
-
var _a;
|
|
472
|
-
(_a = ctx2.onEscapeKeyDown) == null ? void 0 : _a.call(ctx2, event);
|
|
473
|
-
if (ctx2.closeOnEsc)
|
|
474
|
-
return;
|
|
475
|
-
ctx2.focusTriggerOnClose = true;
|
|
476
|
-
event.preventDefault();
|
|
477
|
-
},
|
|
478
|
-
onInteractOutside(event) {
|
|
479
|
-
var _a;
|
|
480
|
-
(_a = ctx2.onInteractOutside) == null ? void 0 : _a.call(ctx2, event);
|
|
481
|
-
if (event.defaultPrevented)
|
|
482
|
-
return;
|
|
483
|
-
ctx2.focusTriggerOnClose = !(event.detail.focusable || event.detail.contextmenu);
|
|
484
|
-
if (!ctx2.closeOnInteractOutside) {
|
|
485
|
-
event.preventDefault();
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
activities: {
|
|
421
|
+
computePlacement(ctx2) {
|
|
422
|
+
ctx2.currentPlacement = ctx2.positioning.placement;
|
|
423
|
+
const anchorEl = ctx2.renderedElements.anchor ? dom.getAnchorEl(ctx2) : dom.getTriggerEl(ctx2);
|
|
424
|
+
return (0, import_popper2.getPlacement)(anchorEl, dom.getPositionerEl(ctx2), {
|
|
425
|
+
...ctx2.positioning,
|
|
426
|
+
onComplete(data) {
|
|
427
|
+
ctx2.currentPlacement = data.placement;
|
|
428
|
+
ctx2.isPlacementComplete = true;
|
|
429
|
+
},
|
|
430
|
+
onCleanup() {
|
|
431
|
+
ctx2.currentPlacement = void 0;
|
|
432
|
+
ctx2.isPlacementComplete = false;
|
|
486
433
|
}
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
434
|
+
});
|
|
435
|
+
},
|
|
436
|
+
trackInteractionOutside(ctx2, _evt, { send }) {
|
|
437
|
+
return (0, import_dismissable.trackDismissableElement)(dom.getContentEl(ctx2), {
|
|
438
|
+
pointerBlocking: ctx2.modal,
|
|
439
|
+
exclude: dom.getTriggerEl(ctx2),
|
|
440
|
+
onEscapeKeyDown(event) {
|
|
441
|
+
var _a;
|
|
442
|
+
(_a = ctx2.onEscapeKeyDown) == null ? void 0 : _a.call(ctx2, event);
|
|
443
|
+
if (ctx2.closeOnEsc)
|
|
444
|
+
return;
|
|
445
|
+
ctx2.focusTriggerOnClose = true;
|
|
496
446
|
event.preventDefault();
|
|
447
|
+
},
|
|
448
|
+
onInteractOutside(event) {
|
|
449
|
+
var _a;
|
|
450
|
+
(_a = ctx2.onInteractOutside) == null ? void 0 : _a.call(ctx2, event);
|
|
451
|
+
if (event.defaultPrevented)
|
|
452
|
+
return;
|
|
453
|
+
ctx2.focusTriggerOnClose = !(event.detail.focusable || event.detail.contextmenu);
|
|
454
|
+
if (!ctx2.closeOnInteractOutside) {
|
|
455
|
+
event.preventDefault();
|
|
456
|
+
}
|
|
457
|
+
},
|
|
458
|
+
onPointerDownOutside(event) {
|
|
459
|
+
var _a;
|
|
460
|
+
(_a = ctx2.onPointerDownOutside) == null ? void 0 : _a.call(ctx2, event);
|
|
461
|
+
},
|
|
462
|
+
onFocusOutside(event) {
|
|
463
|
+
var _a;
|
|
464
|
+
(_a = ctx2.onFocusOutside) == null ? void 0 : _a.call(ctx2, event);
|
|
465
|
+
if (ctx2.currentPortalled) {
|
|
466
|
+
event.preventDefault();
|
|
467
|
+
}
|
|
468
|
+
},
|
|
469
|
+
onDismiss() {
|
|
470
|
+
send({ type: "REQUEST_CLOSE", src: "#interact-outside" });
|
|
497
471
|
}
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
472
|
+
});
|
|
473
|
+
},
|
|
474
|
+
trackTabKeyDown(ctx2, _evt, { send }) {
|
|
475
|
+
if (ctx2.modal)
|
|
476
|
+
return;
|
|
477
|
+
return addDomEvent(
|
|
478
|
+
dom.getWin(ctx2),
|
|
479
|
+
"keydown",
|
|
480
|
+
(event) => {
|
|
481
|
+
const isTabKey = event.key === "Tab" && !isModifiedEvent(event);
|
|
482
|
+
if (!isTabKey)
|
|
483
|
+
return;
|
|
484
|
+
send({
|
|
485
|
+
type: event.shiftKey ? "SHIFT_TAB" : "TAB",
|
|
486
|
+
preventDefault: () => event.preventDefault()
|
|
487
|
+
});
|
|
488
|
+
},
|
|
489
|
+
true
|
|
490
|
+
);
|
|
491
|
+
},
|
|
492
|
+
hideContentBelow(ctx2) {
|
|
493
|
+
if (!ctx2.modal)
|
|
510
494
|
return;
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
495
|
+
let cleanup;
|
|
496
|
+
nextTick(() => {
|
|
497
|
+
cleanup = (0, import_aria_hidden.ariaHidden)([dom.getContentEl(ctx2), dom.getTriggerEl(ctx2)]);
|
|
514
498
|
});
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
499
|
+
return () => cleanup == null ? void 0 : cleanup();
|
|
500
|
+
},
|
|
501
|
+
preventScroll(ctx2) {
|
|
502
|
+
if (!ctx2.modal)
|
|
503
|
+
return;
|
|
504
|
+
return (0, import_remove_scroll.preventBodyScroll)(dom.getDoc(ctx2));
|
|
505
|
+
},
|
|
506
|
+
trapFocus(ctx2) {
|
|
507
|
+
if (!ctx2.modal)
|
|
508
|
+
return;
|
|
509
|
+
let trap;
|
|
510
|
+
nextTick(() => {
|
|
511
|
+
const el = dom.getContentEl(ctx2);
|
|
512
|
+
if (!el)
|
|
513
|
+
return;
|
|
514
|
+
trap = (0, import_focus_trap.createFocusTrap)(el, {
|
|
515
|
+
escapeDeactivates: false,
|
|
516
|
+
allowOutsideClick: true,
|
|
517
|
+
returnFocusOnDeactivate: true,
|
|
518
|
+
document: dom.getDoc(ctx2),
|
|
519
|
+
fallbackFocus: el,
|
|
520
|
+
initialFocus: runIfFn2(ctx2.initialFocusEl)
|
|
521
|
+
});
|
|
522
|
+
try {
|
|
523
|
+
trap.activate();
|
|
524
|
+
} catch {
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
return () => trap == null ? void 0 : trap.deactivate();
|
|
528
|
+
}
|
|
525
529
|
},
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
+
guards: {
|
|
531
|
+
portalled: (ctx2) => ctx2.currentPortalled,
|
|
532
|
+
isRelatedTargetWithinContent: (ctx2, evt) => contains(dom.getContentEl(ctx2), evt.target),
|
|
533
|
+
closeOnInteractOutside: (ctx2) => !!ctx2.closeOnInteractOutside,
|
|
534
|
+
isContentFocused: (ctx2) => dom.getContentEl(ctx2) === dom.getActiveEl(ctx2),
|
|
535
|
+
isTriggerFocused: (ctx2) => dom.getTriggerEl(ctx2) === dom.getActiveEl(ctx2),
|
|
536
|
+
isFirstTabbableElement: (ctx2) => dom.getFirstTabbableEl(ctx2) === dom.getActiveEl(ctx2),
|
|
537
|
+
isLastTabbableElement: (ctx2) => dom.getLastTabbableEl(ctx2) === dom.getActiveEl(ctx2)
|
|
530
538
|
},
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
trap = (0, import_focus_trap.createFocusTrap)(el, {
|
|
540
|
-
escapeDeactivates: false,
|
|
541
|
-
allowOutsideClick: true,
|
|
542
|
-
returnFocusOnDeactivate: true,
|
|
543
|
-
document: dom.getDoc(ctx2),
|
|
544
|
-
fallbackFocus: el,
|
|
545
|
-
initialFocus: runIfFn2(ctx2.initialFocusEl)
|
|
539
|
+
actions: {
|
|
540
|
+
checkRenderedElements(ctx2) {
|
|
541
|
+
raf(() => {
|
|
542
|
+
Object.assign(ctx2.renderedElements, {
|
|
543
|
+
title: !!dom.getTitleEl(ctx2),
|
|
544
|
+
description: !!dom.getDescriptionEl(ctx2),
|
|
545
|
+
anchor: !!dom.getAnchorEl(ctx2)
|
|
546
|
+
});
|
|
546
547
|
});
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
return () => trap == null ? void 0 : trap.deactivate();
|
|
553
|
-
}
|
|
554
|
-
},
|
|
555
|
-
guards: {
|
|
556
|
-
portalled: (ctx2) => ctx2.currentPortalled,
|
|
557
|
-
isRelatedTargetWithinContent: (ctx2, evt) => contains(dom.getContentEl(ctx2), evt.target),
|
|
558
|
-
closeOnInteractOutside: (ctx2) => !!ctx2.closeOnInteractOutside,
|
|
559
|
-
isContentFocused: (ctx2) => dom.getContentEl(ctx2) === dom.getActiveEl(ctx2),
|
|
560
|
-
isTriggerFocused: (ctx2) => dom.getTriggerEl(ctx2) === dom.getActiveEl(ctx2),
|
|
561
|
-
isFirstTabbableElement: (ctx2) => dom.getFirstTabbableEl(ctx2) === dom.getActiveEl(ctx2),
|
|
562
|
-
isLastTabbableElement: (ctx2) => dom.getLastTabbableEl(ctx2) === dom.getActiveEl(ctx2)
|
|
563
|
-
},
|
|
564
|
-
actions: {
|
|
565
|
-
checkRenderedElements(ctx2) {
|
|
566
|
-
raf(() => {
|
|
567
|
-
Object.assign(ctx2.renderedElements, {
|
|
568
|
-
title: !!dom.getTitleEl(ctx2),
|
|
569
|
-
description: !!dom.getDescriptionEl(ctx2),
|
|
570
|
-
anchor: !!dom.getAnchorEl(ctx2)
|
|
548
|
+
},
|
|
549
|
+
setInitialFocus(ctx2) {
|
|
550
|
+
raf(() => {
|
|
551
|
+
var _a;
|
|
552
|
+
(_a = dom.getInitialFocusEl(ctx2)) == null ? void 0 : _a.focus();
|
|
571
553
|
});
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
554
|
+
},
|
|
555
|
+
focusTriggerIfNeeded(ctx2) {
|
|
556
|
+
if (!ctx2.focusTriggerOnClose)
|
|
557
|
+
return;
|
|
558
|
+
raf(() => {
|
|
559
|
+
var _a;
|
|
560
|
+
return (_a = dom.getTriggerEl(ctx2)) == null ? void 0 : _a.focus();
|
|
561
|
+
});
|
|
562
|
+
},
|
|
563
|
+
focusFirstTabbableElement(ctx2, evt) {
|
|
576
564
|
var _a;
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
if (!ctx2.focusTriggerOnClose)
|
|
582
|
-
return;
|
|
583
|
-
raf(() => {
|
|
565
|
+
evt.preventDefault();
|
|
566
|
+
(_a = dom.getFirstTabbableEl(ctx2)) == null ? void 0 : _a.focus();
|
|
567
|
+
},
|
|
568
|
+
invokeOnOpen(ctx2, evt) {
|
|
584
569
|
var _a;
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
let tabbables = dom.getDocTabbableEls(ctx2);
|
|
614
|
-
let elementAfterTrigger = next(tabbables, tabbables.indexOf(button), { loop: false });
|
|
615
|
-
if (elementAfterTrigger === content) {
|
|
616
|
-
tabbables = tabbables.filter((el) => !contains(content, el));
|
|
617
|
-
elementAfterTrigger = next(tabbables, tabbables.indexOf(button), { loop: false });
|
|
570
|
+
if (evt.type !== "SETUP") {
|
|
571
|
+
(_a = ctx2.onOpenChange) == null ? void 0 : _a.call(ctx2, true);
|
|
572
|
+
}
|
|
573
|
+
},
|
|
574
|
+
invokeOnClose(ctx2, evt) {
|
|
575
|
+
var _a;
|
|
576
|
+
if (evt.type !== "SETUP") {
|
|
577
|
+
(_a = ctx2.onOpenChange) == null ? void 0 : _a.call(ctx2, false);
|
|
578
|
+
}
|
|
579
|
+
},
|
|
580
|
+
focusNextTabbableElementAfterTrigger(ctx2, evt) {
|
|
581
|
+
const content = dom.getContentEl(ctx2);
|
|
582
|
+
const button = dom.getTriggerEl(ctx2);
|
|
583
|
+
if (!content || !button)
|
|
584
|
+
return;
|
|
585
|
+
const lastTabbable = dom.getLastTabbableEl(ctx2);
|
|
586
|
+
if (lastTabbable !== dom.getActiveEl(ctx2))
|
|
587
|
+
return;
|
|
588
|
+
let tabbables = dom.getDocTabbableEls(ctx2);
|
|
589
|
+
let elementAfterTrigger = next(tabbables, tabbables.indexOf(button), { loop: false });
|
|
590
|
+
if (elementAfterTrigger === content) {
|
|
591
|
+
tabbables = tabbables.filter((el) => !contains(content, el));
|
|
592
|
+
elementAfterTrigger = next(tabbables, tabbables.indexOf(button), { loop: false });
|
|
593
|
+
}
|
|
594
|
+
if (!elementAfterTrigger || elementAfterTrigger === button)
|
|
595
|
+
return;
|
|
596
|
+
evt.preventDefault();
|
|
597
|
+
raf(() => elementAfterTrigger == null ? void 0 : elementAfterTrigger.focus());
|
|
618
598
|
}
|
|
619
|
-
if (!elementAfterTrigger || elementAfterTrigger === button)
|
|
620
|
-
return;
|
|
621
|
-
evt.preventDefault();
|
|
622
|
-
raf(() => elementAfterTrigger == null ? void 0 : elementAfterTrigger.focus());
|
|
623
599
|
}
|
|
624
600
|
}
|
|
625
|
-
|
|
601
|
+
);
|
|
626
602
|
}
|
|
603
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
604
|
+
0 && (module.exports = {
|
|
605
|
+
connect,
|
|
606
|
+
machine
|
|
607
|
+
});
|