@zag-js/popover 0.1.9 → 0.1.12
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 +294 -621
- package/dist/index.mjs +290 -625
- package/package.json +18 -14
- package/dist/popover.connect.d.ts +0 -17
- package/dist/popover.dom.d.ts +0 -28
- package/dist/popover.machine.d.ts +0 -2
- package/dist/popover.types.d.ts +0 -101
package/dist/index.mjs
CHANGED
|
@@ -1,32 +1,15 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
|
|
21
1
|
// ../../utilities/dom/dist/index.mjs
|
|
22
2
|
var dataAttr = (guard) => {
|
|
23
3
|
return guard ? "" : void 0;
|
|
24
4
|
};
|
|
25
5
|
var runIfFn = (v, ...a) => {
|
|
26
6
|
const res = typeof v === "function" ? v(...a) : v;
|
|
27
|
-
return res
|
|
7
|
+
return res ?? void 0;
|
|
28
8
|
};
|
|
29
9
|
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
10
|
+
function isDocument(el) {
|
|
11
|
+
return el.nodeType === Node.DOCUMENT_NODE;
|
|
12
|
+
}
|
|
30
13
|
function isWindow(value) {
|
|
31
14
|
return (value == null ? void 0 : value.toString()) === "[object Window]";
|
|
32
15
|
}
|
|
@@ -34,14 +17,27 @@ function isFrame(element) {
|
|
|
34
17
|
return element.localName === "iframe";
|
|
35
18
|
}
|
|
36
19
|
function getDocument(el) {
|
|
37
|
-
var _a;
|
|
38
20
|
if (isWindow(el))
|
|
39
21
|
return el.document;
|
|
40
|
-
|
|
22
|
+
if (isDocument(el))
|
|
23
|
+
return el;
|
|
24
|
+
return (el == null ? void 0 : el.ownerDocument) ?? document;
|
|
41
25
|
}
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
|
|
26
|
+
function defineDomHelpers(helpers) {
|
|
27
|
+
const dom2 = {
|
|
28
|
+
getRootNode: (ctx) => {
|
|
29
|
+
var _a;
|
|
30
|
+
return ((_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) ?? document;
|
|
31
|
+
},
|
|
32
|
+
getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
|
|
33
|
+
getWin: (ctx) => dom2.getDoc(ctx).defaultView ?? window,
|
|
34
|
+
getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
|
|
35
|
+
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
|
|
36
|
+
};
|
|
37
|
+
return {
|
|
38
|
+
...dom2,
|
|
39
|
+
...helpers
|
|
40
|
+
};
|
|
45
41
|
}
|
|
46
42
|
function contains(parent, child) {
|
|
47
43
|
if (!parent)
|
|
@@ -165,56 +161,44 @@ function next(v, idx, opts = {}) {
|
|
|
165
161
|
}
|
|
166
162
|
var runIfFn2 = (v, ...a) => {
|
|
167
163
|
const res = typeof v === "function" ? v(...a) : v;
|
|
168
|
-
return res
|
|
164
|
+
return res ?? void 0;
|
|
169
165
|
};
|
|
170
166
|
|
|
171
167
|
// src/popover.dom.ts
|
|
172
|
-
var dom = {
|
|
173
|
-
getDoc: (ctx) => {
|
|
174
|
-
var _a;
|
|
175
|
-
return (_a = ctx.doc) != null ? _a : document;
|
|
176
|
-
},
|
|
177
|
-
getWin: (ctx) => {
|
|
178
|
-
var _a;
|
|
179
|
-
return (_a = dom.getDoc(ctx).defaultView) != null ? _a : window;
|
|
180
|
-
},
|
|
168
|
+
var dom = defineDomHelpers({
|
|
181
169
|
getActiveEl: (ctx) => dom.getDoc(ctx).activeElement,
|
|
182
|
-
getRootNode: (ctx) => {
|
|
183
|
-
var _a;
|
|
184
|
-
return (_a = ctx.rootNode) != null ? _a : dom.getDoc(ctx);
|
|
185
|
-
},
|
|
186
170
|
getAnchorId: (ctx) => {
|
|
187
|
-
var _a
|
|
188
|
-
return (
|
|
171
|
+
var _a;
|
|
172
|
+
return ((_a = ctx.ids) == null ? void 0 : _a.anchor) ?? `popover:${ctx.id}:anchor`;
|
|
189
173
|
},
|
|
190
174
|
getTriggerId: (ctx) => {
|
|
191
|
-
var _a
|
|
192
|
-
return (
|
|
175
|
+
var _a;
|
|
176
|
+
return ((_a = ctx.ids) == null ? void 0 : _a.trigger) ?? `popover:${ctx.id}:trigger`;
|
|
193
177
|
},
|
|
194
178
|
getContentId: (ctx) => {
|
|
195
|
-
var _a
|
|
196
|
-
return (
|
|
179
|
+
var _a;
|
|
180
|
+
return ((_a = ctx.ids) == null ? void 0 : _a.content) ?? `popover:${ctx.id}:content`;
|
|
197
181
|
},
|
|
198
|
-
getPositionerId: (ctx) => `popover:${ctx.
|
|
199
|
-
getArrowId: (ctx) => `popover:${ctx.
|
|
182
|
+
getPositionerId: (ctx) => `popover:${ctx.id}:popper`,
|
|
183
|
+
getArrowId: (ctx) => `popover:${ctx.id}:arrow`,
|
|
200
184
|
getTitleId: (ctx) => {
|
|
201
|
-
var _a
|
|
202
|
-
return (
|
|
185
|
+
var _a;
|
|
186
|
+
return ((_a = ctx.ids) == null ? void 0 : _a.title) ?? `popover:${ctx.id}:title`;
|
|
203
187
|
},
|
|
204
188
|
getDescriptionId: (ctx) => {
|
|
205
|
-
var _a
|
|
206
|
-
return (
|
|
189
|
+
var _a;
|
|
190
|
+
return ((_a = ctx.ids) == null ? void 0 : _a.description) ?? `popover:${ctx.id}:desc`;
|
|
207
191
|
},
|
|
208
192
|
getCloseButtonId: (ctx) => {
|
|
209
|
-
var _a
|
|
210
|
-
return (
|
|
193
|
+
var _a;
|
|
194
|
+
return ((_a = ctx.ids) == null ? void 0 : _a.closeBtn) ?? `popover:${ctx.id}:close-button`;
|
|
211
195
|
},
|
|
212
|
-
getAnchorEl: (ctx) => dom.
|
|
213
|
-
getTriggerEl: (ctx) => dom.
|
|
214
|
-
getContentEl: (ctx) => dom.
|
|
215
|
-
getPositionerEl: (ctx) => dom.
|
|
216
|
-
getTitleEl: (ctx) => dom.
|
|
217
|
-
getDescriptionEl: (ctx) => dom.
|
|
196
|
+
getAnchorEl: (ctx) => dom.getById(ctx, dom.getAnchorId(ctx)),
|
|
197
|
+
getTriggerEl: (ctx) => dom.getById(ctx, dom.getTriggerId(ctx)),
|
|
198
|
+
getContentEl: (ctx) => dom.getById(ctx, dom.getContentId(ctx)),
|
|
199
|
+
getPositionerEl: (ctx) => dom.getById(ctx, dom.getPositionerId(ctx)),
|
|
200
|
+
getTitleEl: (ctx) => dom.getById(ctx, dom.getTitleId(ctx)),
|
|
201
|
+
getDescriptionEl: (ctx) => dom.getById(ctx, dom.getDescriptionId(ctx)),
|
|
218
202
|
getFocusableEls: (ctx) => getFocusables(dom.getContentEl(ctx)),
|
|
219
203
|
getFirstFocusableEl: (ctx) => dom.getFocusableEls(ctx)[0],
|
|
220
204
|
getDocTabbableEls: (ctx) => getTabbables(dom.getDoc(ctx).body),
|
|
@@ -229,7 +213,7 @@ var dom = {
|
|
|
229
213
|
el = dom.getContentEl(ctx);
|
|
230
214
|
return el;
|
|
231
215
|
}
|
|
232
|
-
};
|
|
216
|
+
});
|
|
233
217
|
|
|
234
218
|
// src/popover.connect.ts
|
|
235
219
|
function connect(state, send, normalize) {
|
|
@@ -317,596 +301,277 @@ function connect(state, send, normalize) {
|
|
|
317
301
|
|
|
318
302
|
// src/popover.machine.ts
|
|
319
303
|
import { ariaHidden } from "@zag-js/aria-hidden";
|
|
320
|
-
import { createMachine, guards
|
|
321
|
-
|
|
322
|
-
// ../../utilities/interact-outside/dist/index.mjs
|
|
323
|
-
var runIfFn3 = (v, ...a) => {
|
|
324
|
-
const res = typeof v === "function" ? v(...a) : v;
|
|
325
|
-
return res != null ? res : void 0;
|
|
326
|
-
};
|
|
327
|
-
var hasProp2 = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
|
|
328
|
-
var isDom = () => typeof window !== "undefined";
|
|
329
|
-
function getPlatform() {
|
|
330
|
-
var _a;
|
|
331
|
-
const agent = navigator.userAgentData;
|
|
332
|
-
return (_a = agent == null ? void 0 : agent.platform) != null ? _a : navigator.platform;
|
|
333
|
-
}
|
|
334
|
-
var pt = (v) => isDom() && v.test(getPlatform());
|
|
335
|
-
var isTouchDevice = () => isDom() && !!navigator.maxTouchPoints;
|
|
336
|
-
var isMac = () => pt(/^Mac/) && !isTouchDevice;
|
|
337
|
-
function isWindow2(value) {
|
|
338
|
-
return (value == null ? void 0 : value.toString()) === "[object Window]";
|
|
339
|
-
}
|
|
340
|
-
function getDocument2(el) {
|
|
341
|
-
var _a;
|
|
342
|
-
if (isWindow2(el))
|
|
343
|
-
return el.document;
|
|
344
|
-
return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
|
|
345
|
-
}
|
|
346
|
-
function getWindow(el) {
|
|
347
|
-
var _a;
|
|
348
|
-
return (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
|
|
349
|
-
}
|
|
350
|
-
function getEventTarget2(event) {
|
|
351
|
-
var _a, _b;
|
|
352
|
-
return (_b = (_a = event.composedPath) == null ? void 0 : _a.call(event)[0]) != null ? _b : event.target;
|
|
353
|
-
}
|
|
354
|
-
function contains2(parent, child) {
|
|
355
|
-
if (!parent)
|
|
356
|
-
return false;
|
|
357
|
-
return parent === child || isHTMLElement2(parent) && isHTMLElement2(child) && parent.contains(child);
|
|
358
|
-
}
|
|
359
|
-
function isHTMLElement2(v) {
|
|
360
|
-
return typeof v === "object" && (v == null ? void 0 : v.nodeType) === Node.ELEMENT_NODE && typeof (v == null ? void 0 : v.nodeName) === "string";
|
|
361
|
-
}
|
|
362
|
-
function isVisible2(el) {
|
|
363
|
-
if (!isHTMLElement2(el))
|
|
364
|
-
return false;
|
|
365
|
-
return el.offsetWidth > 0 || el.offsetHeight > 0 || el.getClientRects().length > 0;
|
|
366
|
-
}
|
|
367
|
-
var isContextMenuEvent = (e) => {
|
|
368
|
-
return e.button === 2 || isCtrlKey(e) && e.button === 0;
|
|
369
|
-
};
|
|
370
|
-
var isCtrlKey = (v) => isMac() ? v.metaKey && !v.ctrlKey : v.ctrlKey && !v.metaKey;
|
|
371
|
-
function fireCustomEvent(el, type, init) {
|
|
372
|
-
if (!el)
|
|
373
|
-
return;
|
|
374
|
-
const win = getWindow(el);
|
|
375
|
-
const event = new win.CustomEvent(type, init);
|
|
376
|
-
return el.dispatchEvent(event);
|
|
377
|
-
}
|
|
378
|
-
var focusableSelector2 = "input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false']), details > summary:first-of-type";
|
|
379
|
-
function isFocusable2(element) {
|
|
380
|
-
if (!element)
|
|
381
|
-
return false;
|
|
382
|
-
return element.matches(focusableSelector2) && isVisible2(element);
|
|
383
|
-
}
|
|
384
|
-
var isRef2 = (v) => hasProp2(v, "current");
|
|
385
|
-
function addDomEvent2(target, eventName, handler, options) {
|
|
386
|
-
const node = isRef2(target) ? target.current : runIfFn3(target);
|
|
387
|
-
node == null ? void 0 : node.addEventListener(eventName, handler, options);
|
|
388
|
-
return () => {
|
|
389
|
-
node == null ? void 0 : node.removeEventListener(eventName, handler, options);
|
|
390
|
-
};
|
|
391
|
-
}
|
|
392
|
-
var POINTER_OUTSIDE_EVENT = "pointerdown.outside";
|
|
393
|
-
var FOCUS_OUTSIDE_EVENT = "focus.outside";
|
|
394
|
-
function trackInteractOutside(node, options) {
|
|
395
|
-
const { exclude, onFocusOutside, onPointerDownOutside } = options;
|
|
396
|
-
if (!node)
|
|
397
|
-
return;
|
|
398
|
-
const doc = getDocument2(node);
|
|
399
|
-
const win = getWindow(node);
|
|
400
|
-
function isEventOutside(event) {
|
|
401
|
-
const target = getEventTarget2(event);
|
|
402
|
-
if (!(target instanceof win.HTMLElement)) {
|
|
403
|
-
return false;
|
|
404
|
-
}
|
|
405
|
-
if (!contains2(doc.documentElement, target)) {
|
|
406
|
-
return false;
|
|
407
|
-
}
|
|
408
|
-
if (contains2(node, target)) {
|
|
409
|
-
return false;
|
|
410
|
-
}
|
|
411
|
-
return !(exclude == null ? void 0 : exclude(target));
|
|
412
|
-
}
|
|
413
|
-
let clickHandler;
|
|
414
|
-
function onPointerDown(event) {
|
|
415
|
-
function handler() {
|
|
416
|
-
if (!node || !isEventOutside(event))
|
|
417
|
-
return;
|
|
418
|
-
if (onPointerDownOutside) {
|
|
419
|
-
node.addEventListener(POINTER_OUTSIDE_EVENT, onPointerDownOutside, { once: true });
|
|
420
|
-
}
|
|
421
|
-
fireCustomEvent(node, POINTER_OUTSIDE_EVENT, {
|
|
422
|
-
bubbles: false,
|
|
423
|
-
cancelable: true,
|
|
424
|
-
detail: {
|
|
425
|
-
originalEvent: event,
|
|
426
|
-
contextmenu: isContextMenuEvent(event),
|
|
427
|
-
focusable: isFocusable2(getEventTarget2(event))
|
|
428
|
-
}
|
|
429
|
-
});
|
|
430
|
-
}
|
|
431
|
-
if (event.pointerType === "touch") {
|
|
432
|
-
doc.removeEventListener("click", handler);
|
|
433
|
-
clickHandler = handler;
|
|
434
|
-
doc.addEventListener("click", handler, { once: true });
|
|
435
|
-
} else {
|
|
436
|
-
handler();
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
const cleanups = /* @__PURE__ */ new Set();
|
|
440
|
-
const timer = setTimeout(() => {
|
|
441
|
-
cleanups.add(addDomEvent2(doc, "pointerdown", onPointerDown, true));
|
|
442
|
-
}, 0);
|
|
443
|
-
function onFocusin(event) {
|
|
444
|
-
if (!node || !isEventOutside(event))
|
|
445
|
-
return;
|
|
446
|
-
if (onFocusOutside) {
|
|
447
|
-
node.addEventListener(FOCUS_OUTSIDE_EVENT, onFocusOutside, { once: true });
|
|
448
|
-
}
|
|
449
|
-
fireCustomEvent(node, FOCUS_OUTSIDE_EVENT, {
|
|
450
|
-
bubbles: false,
|
|
451
|
-
cancelable: true,
|
|
452
|
-
detail: {
|
|
453
|
-
originalEvent: event,
|
|
454
|
-
contextmenu: false,
|
|
455
|
-
focusable: isFocusable2(getEventTarget2(event))
|
|
456
|
-
}
|
|
457
|
-
});
|
|
458
|
-
}
|
|
459
|
-
cleanups.add(addDomEvent2(doc, "focusin", onFocusin, true));
|
|
460
|
-
return () => {
|
|
461
|
-
clearTimeout(timer);
|
|
462
|
-
if (clickHandler)
|
|
463
|
-
doc.removeEventListener("click", clickHandler);
|
|
464
|
-
cleanups.forEach((fn) => fn());
|
|
465
|
-
};
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
// ../../utilities/dismissable/src/escape-keydown.ts
|
|
469
|
-
function trackEscapeKeydown(fn) {
|
|
470
|
-
const handleKeyDown = (event) => {
|
|
471
|
-
if (event.key === "Escape")
|
|
472
|
-
fn == null ? void 0 : fn(event);
|
|
473
|
-
};
|
|
474
|
-
return addDomEvent(document, "keydown", handleKeyDown);
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
// ../../utilities/dismissable/src/layer-stack.ts
|
|
478
|
-
var layerStack = {
|
|
479
|
-
layers: [],
|
|
480
|
-
branches: [],
|
|
481
|
-
count() {
|
|
482
|
-
return this.layers.length;
|
|
483
|
-
},
|
|
484
|
-
pointerBlockingLayers() {
|
|
485
|
-
return this.layers.filter((layer) => layer.pointerBlocking);
|
|
486
|
-
},
|
|
487
|
-
topMostPointerBlockingLayer() {
|
|
488
|
-
return [...this.pointerBlockingLayers()].slice(-1)[0];
|
|
489
|
-
},
|
|
490
|
-
hasPointerBlockingLayer() {
|
|
491
|
-
return this.pointerBlockingLayers().length > 0;
|
|
492
|
-
},
|
|
493
|
-
isBelowPointerBlockingLayer(node) {
|
|
494
|
-
var _a;
|
|
495
|
-
const index = this.indexOf(node);
|
|
496
|
-
const highestBlockingIndex = this.topMostPointerBlockingLayer() ? this.indexOf((_a = this.topMostPointerBlockingLayer()) == null ? void 0 : _a.node) : -1;
|
|
497
|
-
return index < highestBlockingIndex;
|
|
498
|
-
},
|
|
499
|
-
isTopMost(node) {
|
|
500
|
-
const layer = this.layers[this.count() - 1];
|
|
501
|
-
return (layer == null ? void 0 : layer.node) === node;
|
|
502
|
-
},
|
|
503
|
-
getNestedLayers(node) {
|
|
504
|
-
return Array.from(this.layers).slice(this.indexOf(node) + 1);
|
|
505
|
-
},
|
|
506
|
-
isInNestedLayer(node, target) {
|
|
507
|
-
return this.getNestedLayers(node).some((layer) => contains(layer.node, target));
|
|
508
|
-
},
|
|
509
|
-
isInBranch(target) {
|
|
510
|
-
return Array.from(this.branches).some((branch) => contains(branch, target));
|
|
511
|
-
},
|
|
512
|
-
add(layer) {
|
|
513
|
-
this.layers.push(layer);
|
|
514
|
-
},
|
|
515
|
-
addBranch(node) {
|
|
516
|
-
this.branches.push(node);
|
|
517
|
-
},
|
|
518
|
-
remove(node) {
|
|
519
|
-
const index = this.indexOf(node);
|
|
520
|
-
if (index < 0)
|
|
521
|
-
return;
|
|
522
|
-
if (index < this.count() - 1) {
|
|
523
|
-
const _layers = this.getNestedLayers(node);
|
|
524
|
-
_layers.forEach((layer) => layer.dismiss());
|
|
525
|
-
}
|
|
526
|
-
this.layers.splice(index, 1);
|
|
527
|
-
},
|
|
528
|
-
removeBranch(node) {
|
|
529
|
-
const index = this.branches.indexOf(node);
|
|
530
|
-
if (index >= 0)
|
|
531
|
-
this.branches.splice(index, 1);
|
|
532
|
-
},
|
|
533
|
-
indexOf(node) {
|
|
534
|
-
return this.layers.findIndex((layer) => layer.node === node);
|
|
535
|
-
},
|
|
536
|
-
dismiss(node) {
|
|
537
|
-
var _a;
|
|
538
|
-
(_a = this.layers[this.indexOf(node)]) == null ? void 0 : _a.dismiss();
|
|
539
|
-
},
|
|
540
|
-
clear() {
|
|
541
|
-
this.remove(this.layers[0].node);
|
|
542
|
-
}
|
|
543
|
-
};
|
|
544
|
-
|
|
545
|
-
// ../../utilities/dismissable/src/pointer-event-outside.ts
|
|
546
|
-
var originalBodyPointerEvents;
|
|
547
|
-
function assignPointerEventToLayers() {
|
|
548
|
-
layerStack.layers.forEach(({ node }) => {
|
|
549
|
-
node.style.pointerEvents = layerStack.isBelowPointerBlockingLayer(node) ? "none" : "auto";
|
|
550
|
-
});
|
|
551
|
-
}
|
|
552
|
-
function clearPointerEvent(node) {
|
|
553
|
-
node.style.pointerEvents = "";
|
|
554
|
-
}
|
|
555
|
-
var DATA_ATTR = "data-inert";
|
|
556
|
-
function disablePointerEventsOutside(node) {
|
|
557
|
-
const doc = getDocument(node);
|
|
558
|
-
if (layerStack.hasPointerBlockingLayer() && !doc.body.hasAttribute(DATA_ATTR)) {
|
|
559
|
-
originalBodyPointerEvents = document.body.style.pointerEvents;
|
|
560
|
-
doc.body.style.pointerEvents = "none";
|
|
561
|
-
doc.body.setAttribute(DATA_ATTR, "");
|
|
562
|
-
}
|
|
563
|
-
return () => {
|
|
564
|
-
if (layerStack.hasPointerBlockingLayer())
|
|
565
|
-
return;
|
|
566
|
-
doc.body.style.pointerEvents = originalBodyPointerEvents;
|
|
567
|
-
doc.body.removeAttribute(DATA_ATTR);
|
|
568
|
-
if (doc.body.style.length === 0)
|
|
569
|
-
doc.body.removeAttribute("style");
|
|
570
|
-
};
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
// ../../utilities/dismissable/src/dismissable-layer.ts
|
|
574
|
-
function trackDismissableElement(node, options) {
|
|
575
|
-
if (!node)
|
|
576
|
-
return;
|
|
577
|
-
const { onDismiss, pointerBlocking, exclude: excludeContainers, debug } = options;
|
|
578
|
-
const layer = { dismiss: onDismiss, node, pointerBlocking };
|
|
579
|
-
layerStack.add(layer);
|
|
580
|
-
assignPointerEventToLayers();
|
|
581
|
-
function onPointerDownOutside(event) {
|
|
582
|
-
var _a, _b;
|
|
583
|
-
const target = getEventTarget(event.detail.originalEvent);
|
|
584
|
-
if (layerStack.isBelowPointerBlockingLayer(node) || layerStack.isInBranch(target))
|
|
585
|
-
return;
|
|
586
|
-
(_a = options.onPointerDownOutside) == null ? void 0 : _a.call(options, event);
|
|
587
|
-
(_b = options.onInteractOutside) == null ? void 0 : _b.call(options, event);
|
|
588
|
-
if (event.defaultPrevented)
|
|
589
|
-
return;
|
|
590
|
-
if (debug) {
|
|
591
|
-
console.log("onPointerDownOutside:", event.detail.originalEvent);
|
|
592
|
-
}
|
|
593
|
-
onDismiss == null ? void 0 : onDismiss();
|
|
594
|
-
}
|
|
595
|
-
function onFocusOutside(event) {
|
|
596
|
-
var _a, _b;
|
|
597
|
-
const target = getEventTarget(event.detail.originalEvent);
|
|
598
|
-
if (layerStack.isInBranch(target))
|
|
599
|
-
return;
|
|
600
|
-
(_a = options.onFocusOutside) == null ? void 0 : _a.call(options, event);
|
|
601
|
-
(_b = options.onInteractOutside) == null ? void 0 : _b.call(options, event);
|
|
602
|
-
if (event.defaultPrevented)
|
|
603
|
-
return;
|
|
604
|
-
if (debug) {
|
|
605
|
-
console.log("onFocusOutside:", event.detail.originalEvent);
|
|
606
|
-
}
|
|
607
|
-
onDismiss == null ? void 0 : onDismiss();
|
|
608
|
-
}
|
|
609
|
-
function onEscapeKeyDown(event) {
|
|
610
|
-
var _a;
|
|
611
|
-
if (!layerStack.isTopMost(node))
|
|
612
|
-
return;
|
|
613
|
-
(_a = options.onEscapeKeyDown) == null ? void 0 : _a.call(options, event);
|
|
614
|
-
if (!event.defaultPrevented && onDismiss) {
|
|
615
|
-
event.preventDefault();
|
|
616
|
-
onDismiss();
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
function exclude(target) {
|
|
620
|
-
if (!node)
|
|
621
|
-
return false;
|
|
622
|
-
const containers = typeof excludeContainers === "function" ? excludeContainers() : excludeContainers;
|
|
623
|
-
const _containers = Array.isArray(containers) ? containers : [containers];
|
|
624
|
-
return _containers.some((node2) => contains(node2, target)) || layerStack.isInNestedLayer(node, target);
|
|
625
|
-
}
|
|
626
|
-
const cleanups = [
|
|
627
|
-
pointerBlocking ? disablePointerEventsOutside(node) : void 0,
|
|
628
|
-
trackEscapeKeydown(onEscapeKeyDown),
|
|
629
|
-
trackInteractOutside(node, { exclude, onFocusOutside, onPointerDownOutside })
|
|
630
|
-
];
|
|
631
|
-
return () => {
|
|
632
|
-
layerStack.remove(node);
|
|
633
|
-
assignPointerEventToLayers();
|
|
634
|
-
clearPointerEvent(node);
|
|
635
|
-
cleanups.forEach((fn) => fn == null ? void 0 : fn());
|
|
636
|
-
};
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
// src/popover.machine.ts
|
|
304
|
+
import { createMachine, guards } from "@zag-js/core";
|
|
305
|
+
import { trackDismissableElement } from "@zag-js/dismissable";
|
|
640
306
|
import { getPlacement } from "@zag-js/popper";
|
|
641
307
|
import { preventBodyScroll } from "@zag-js/remove-scroll";
|
|
642
308
|
import { createFocusTrap } from "focus-trap";
|
|
643
309
|
var { and, or, not } = guards;
|
|
644
|
-
function machine(ctx
|
|
645
|
-
return createMachine(
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
}),
|
|
666
|
-
computed: {
|
|
667
|
-
currentPortalled: (ctx2) => !!ctx2.modal || !!ctx2.portalled
|
|
668
|
-
},
|
|
669
|
-
states: {
|
|
670
|
-
unknown: {
|
|
671
|
-
on: {
|
|
672
|
-
SETUP: {
|
|
673
|
-
target: ctx.defaultOpen ? "open" : "closed",
|
|
674
|
-
actions: ["setupDocument", "checkRenderedElements"]
|
|
675
|
-
}
|
|
310
|
+
function machine(ctx) {
|
|
311
|
+
return createMachine(
|
|
312
|
+
{
|
|
313
|
+
id: "popover",
|
|
314
|
+
initial: "unknown",
|
|
315
|
+
context: {
|
|
316
|
+
closeOnInteractOutside: true,
|
|
317
|
+
closeOnEsc: true,
|
|
318
|
+
autoFocus: true,
|
|
319
|
+
modal: false,
|
|
320
|
+
positioning: {
|
|
321
|
+
placement: "bottom",
|
|
322
|
+
...ctx.positioning
|
|
323
|
+
},
|
|
324
|
+
currentPlacement: void 0,
|
|
325
|
+
...ctx,
|
|
326
|
+
focusTriggerOnClose: true,
|
|
327
|
+
renderedElements: {
|
|
328
|
+
title: true,
|
|
329
|
+
description: true,
|
|
330
|
+
anchor: false
|
|
676
331
|
}
|
|
677
332
|
},
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
on: {
|
|
681
|
-
TOGGLE: "open",
|
|
682
|
-
OPEN: "open"
|
|
683
|
-
}
|
|
333
|
+
computed: {
|
|
334
|
+
currentPortalled: (ctx2) => !!ctx2.modal || !!ctx2.portalled
|
|
684
335
|
},
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
"trackInteractionOutside",
|
|
692
|
-
"trackTabKeyDown"
|
|
693
|
-
],
|
|
694
|
-
entry: ["setInitialFocus", "invokeOnOpen"],
|
|
695
|
-
on: {
|
|
696
|
-
CLOSE: "closed",
|
|
697
|
-
REQUEST_CLOSE: {
|
|
698
|
-
target: "closed",
|
|
699
|
-
actions: "focusTriggerIfNeeded"
|
|
700
|
-
},
|
|
701
|
-
TOGGLE: "closed",
|
|
702
|
-
TRIGGER_BLUR: {
|
|
703
|
-
guard: not("isRelatedTargetWithinContent"),
|
|
704
|
-
target: "closed"
|
|
705
|
-
},
|
|
706
|
-
TAB: [
|
|
707
|
-
{
|
|
708
|
-
guard: and("isTriggerFocused", "portalled"),
|
|
709
|
-
actions: "focusFirstTabbableElement"
|
|
710
|
-
},
|
|
711
|
-
{
|
|
712
|
-
guard: and("isLastTabbableElement", "closeOnInteractOutside", "portalled"),
|
|
713
|
-
target: "closed",
|
|
714
|
-
actions: "focusNextTabbableElementAfterTrigger"
|
|
336
|
+
states: {
|
|
337
|
+
unknown: {
|
|
338
|
+
on: {
|
|
339
|
+
SETUP: {
|
|
340
|
+
target: ctx.defaultOpen ? "open" : "closed",
|
|
341
|
+
actions: "checkRenderedElements"
|
|
715
342
|
}
|
|
343
|
+
}
|
|
344
|
+
},
|
|
345
|
+
closed: {
|
|
346
|
+
entry: "invokeOnClose",
|
|
347
|
+
on: {
|
|
348
|
+
TOGGLE: "open",
|
|
349
|
+
OPEN: "open"
|
|
350
|
+
}
|
|
351
|
+
},
|
|
352
|
+
open: {
|
|
353
|
+
activities: [
|
|
354
|
+
"trapFocus",
|
|
355
|
+
"preventScroll",
|
|
356
|
+
"hideContentBelow",
|
|
357
|
+
"computePlacement",
|
|
358
|
+
"trackInteractionOutside",
|
|
359
|
+
"trackTabKeyDown"
|
|
716
360
|
],
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
361
|
+
entry: ["setInitialFocus", "invokeOnOpen"],
|
|
362
|
+
on: {
|
|
363
|
+
CLOSE: "closed",
|
|
364
|
+
REQUEST_CLOSE: {
|
|
365
|
+
target: "closed",
|
|
366
|
+
actions: "focusTriggerIfNeeded"
|
|
367
|
+
},
|
|
368
|
+
TOGGLE: "closed",
|
|
369
|
+
TRIGGER_BLUR: {
|
|
370
|
+
guard: not("isRelatedTargetWithinContent"),
|
|
371
|
+
target: "closed"
|
|
372
|
+
},
|
|
373
|
+
TAB: [
|
|
374
|
+
{
|
|
375
|
+
guard: and("isTriggerFocused", "portalled"),
|
|
376
|
+
actions: "focusFirstTabbableElement"
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
guard: and("isLastTabbableElement", "closeOnInteractOutside", "portalled"),
|
|
380
|
+
target: "closed",
|
|
381
|
+
actions: "focusNextTabbableElementAfterTrigger"
|
|
382
|
+
}
|
|
383
|
+
],
|
|
384
|
+
SHIFT_TAB: {
|
|
385
|
+
guard: and(or("isFirstTabbableElement", "isContentFocused"), "portalled"),
|
|
386
|
+
actions: "focusTriggerIfNeeded"
|
|
387
|
+
}
|
|
720
388
|
}
|
|
721
389
|
}
|
|
722
390
|
}
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
}));
|
|
739
|
-
},
|
|
740
|
-
trackInteractionOutside(ctx2, _evt, { send }) {
|
|
741
|
-
return trackDismissableElement(dom.getContentEl(ctx2), {
|
|
742
|
-
pointerBlocking: ctx2.modal,
|
|
743
|
-
exclude: dom.getTriggerEl(ctx2),
|
|
744
|
-
onEscapeKeyDown(event) {
|
|
745
|
-
var _a;
|
|
746
|
-
(_a = ctx2.onEscapeKeyDown) == null ? void 0 : _a.call(ctx2, event);
|
|
747
|
-
if (ctx2.closeOnEsc)
|
|
748
|
-
return;
|
|
749
|
-
ctx2.focusTriggerOnClose = true;
|
|
750
|
-
event.preventDefault();
|
|
751
|
-
},
|
|
752
|
-
onInteractOutside(event) {
|
|
753
|
-
var _a;
|
|
754
|
-
(_a = ctx2.onInteractOutside) == null ? void 0 : _a.call(ctx2, event);
|
|
755
|
-
if (event.defaultPrevented)
|
|
756
|
-
return;
|
|
757
|
-
ctx2.focusTriggerOnClose = !(event.detail.focusable || event.detail.contextmenu);
|
|
758
|
-
if (!ctx2.closeOnInteractOutside) {
|
|
759
|
-
event.preventDefault();
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
activities: {
|
|
394
|
+
computePlacement(ctx2) {
|
|
395
|
+
ctx2.currentPlacement = ctx2.positioning.placement;
|
|
396
|
+
const anchorEl = ctx2.renderedElements.anchor ? dom.getAnchorEl(ctx2) : dom.getTriggerEl(ctx2);
|
|
397
|
+
return getPlacement(anchorEl, dom.getPositionerEl(ctx2), {
|
|
398
|
+
...ctx2.positioning,
|
|
399
|
+
onComplete(data) {
|
|
400
|
+
ctx2.currentPlacement = data.placement;
|
|
401
|
+
ctx2.isPlacementComplete = true;
|
|
402
|
+
},
|
|
403
|
+
onCleanup() {
|
|
404
|
+
ctx2.currentPlacement = void 0;
|
|
405
|
+
ctx2.isPlacementComplete = false;
|
|
760
406
|
}
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
407
|
+
});
|
|
408
|
+
},
|
|
409
|
+
trackInteractionOutside(ctx2, _evt, { send }) {
|
|
410
|
+
return trackDismissableElement(dom.getContentEl(ctx2), {
|
|
411
|
+
pointerBlocking: ctx2.modal,
|
|
412
|
+
exclude: dom.getTriggerEl(ctx2),
|
|
413
|
+
onEscapeKeyDown(event) {
|
|
414
|
+
var _a;
|
|
415
|
+
(_a = ctx2.onEscapeKeyDown) == null ? void 0 : _a.call(ctx2, event);
|
|
416
|
+
if (ctx2.closeOnEsc)
|
|
417
|
+
return;
|
|
418
|
+
ctx2.focusTriggerOnClose = true;
|
|
770
419
|
event.preventDefault();
|
|
420
|
+
},
|
|
421
|
+
onInteractOutside(event) {
|
|
422
|
+
var _a;
|
|
423
|
+
(_a = ctx2.onInteractOutside) == null ? void 0 : _a.call(ctx2, event);
|
|
424
|
+
if (event.defaultPrevented)
|
|
425
|
+
return;
|
|
426
|
+
ctx2.focusTriggerOnClose = !(event.detail.focusable || event.detail.contextmenu);
|
|
427
|
+
if (!ctx2.closeOnInteractOutside) {
|
|
428
|
+
event.preventDefault();
|
|
429
|
+
}
|
|
430
|
+
},
|
|
431
|
+
onPointerDownOutside(event) {
|
|
432
|
+
var _a;
|
|
433
|
+
(_a = ctx2.onPointerDownOutside) == null ? void 0 : _a.call(ctx2, event);
|
|
434
|
+
},
|
|
435
|
+
onFocusOutside(event) {
|
|
436
|
+
var _a;
|
|
437
|
+
(_a = ctx2.onFocusOutside) == null ? void 0 : _a.call(ctx2, event);
|
|
438
|
+
if (ctx2.currentPortalled) {
|
|
439
|
+
event.preventDefault();
|
|
440
|
+
}
|
|
441
|
+
},
|
|
442
|
+
onDismiss() {
|
|
443
|
+
send({ type: "REQUEST_CLOSE", src: "#interact-outside" });
|
|
771
444
|
}
|
|
772
|
-
},
|
|
773
|
-
onDismiss() {
|
|
774
|
-
send({ type: "REQUEST_CLOSE", src: "#interact-outside" });
|
|
775
|
-
}
|
|
776
|
-
});
|
|
777
|
-
},
|
|
778
|
-
trackTabKeyDown(ctx2, _evt, { send }) {
|
|
779
|
-
if (ctx2.modal)
|
|
780
|
-
return;
|
|
781
|
-
return addDomEvent(dom.getWin(ctx2), "keydown", (event) => {
|
|
782
|
-
const isTabKey = event.key === "Tab" && !isModifiedEvent(event);
|
|
783
|
-
if (!isTabKey)
|
|
784
|
-
return;
|
|
785
|
-
send({
|
|
786
|
-
type: event.shiftKey ? "SHIFT_TAB" : "TAB",
|
|
787
|
-
preventDefault: () => event.preventDefault()
|
|
788
445
|
});
|
|
789
|
-
},
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
if (!ctx2.modal)
|
|
793
|
-
return;
|
|
794
|
-
let cleanup;
|
|
795
|
-
nextTick(() => {
|
|
796
|
-
cleanup = ariaHidden([dom.getContentEl(ctx2), dom.getTriggerEl(ctx2)]);
|
|
797
|
-
});
|
|
798
|
-
return () => cleanup == null ? void 0 : cleanup();
|
|
799
|
-
},
|
|
800
|
-
preventScroll(ctx2) {
|
|
801
|
-
if (!ctx2.modal)
|
|
802
|
-
return;
|
|
803
|
-
return preventBodyScroll(dom.getDoc(ctx2));
|
|
804
|
-
},
|
|
805
|
-
trapFocus(ctx2) {
|
|
806
|
-
if (!ctx2.modal)
|
|
807
|
-
return;
|
|
808
|
-
let trap;
|
|
809
|
-
nextTick(() => {
|
|
810
|
-
const el = dom.getContentEl(ctx2);
|
|
811
|
-
if (!el)
|
|
446
|
+
},
|
|
447
|
+
trackTabKeyDown(ctx2, _evt, { send }) {
|
|
448
|
+
if (ctx2.modal)
|
|
812
449
|
return;
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
450
|
+
return addDomEvent(
|
|
451
|
+
dom.getWin(ctx2),
|
|
452
|
+
"keydown",
|
|
453
|
+
(event) => {
|
|
454
|
+
const isTabKey = event.key === "Tab" && !isModifiedEvent(event);
|
|
455
|
+
if (!isTabKey)
|
|
456
|
+
return;
|
|
457
|
+
send({
|
|
458
|
+
type: event.shiftKey ? "SHIFT_TAB" : "TAB",
|
|
459
|
+
preventDefault: () => event.preventDefault()
|
|
460
|
+
});
|
|
461
|
+
},
|
|
462
|
+
true
|
|
463
|
+
);
|
|
464
|
+
},
|
|
465
|
+
hideContentBelow(ctx2) {
|
|
466
|
+
if (!ctx2.modal)
|
|
467
|
+
return;
|
|
468
|
+
let cleanup;
|
|
469
|
+
nextTick(() => {
|
|
470
|
+
cleanup = ariaHidden([dom.getContentEl(ctx2), dom.getTriggerEl(ctx2)]);
|
|
820
471
|
});
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
472
|
+
return () => cleanup == null ? void 0 : cleanup();
|
|
473
|
+
},
|
|
474
|
+
preventScroll(ctx2) {
|
|
475
|
+
if (!ctx2.modal)
|
|
476
|
+
return;
|
|
477
|
+
return preventBodyScroll(dom.getDoc(ctx2));
|
|
478
|
+
},
|
|
479
|
+
trapFocus(ctx2) {
|
|
480
|
+
if (!ctx2.modal)
|
|
481
|
+
return;
|
|
482
|
+
let trap;
|
|
483
|
+
nextTick(() => {
|
|
484
|
+
const el = dom.getContentEl(ctx2);
|
|
485
|
+
if (!el)
|
|
486
|
+
return;
|
|
487
|
+
trap = createFocusTrap(el, {
|
|
488
|
+
escapeDeactivates: false,
|
|
489
|
+
allowOutsideClick: true,
|
|
490
|
+
returnFocusOnDeactivate: true,
|
|
491
|
+
document: dom.getDoc(ctx2),
|
|
492
|
+
fallbackFocus: el,
|
|
493
|
+
initialFocus: runIfFn2(ctx2.initialFocusEl)
|
|
494
|
+
});
|
|
495
|
+
try {
|
|
496
|
+
trap.activate();
|
|
497
|
+
} catch {
|
|
498
|
+
}
|
|
845
499
|
});
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
setupDocument(ctx2, evt) {
|
|
849
|
-
if (evt.doc)
|
|
850
|
-
ctx2.doc = ref(evt.doc);
|
|
851
|
-
if (evt.root)
|
|
852
|
-
ctx2.rootNode = ref(evt.root);
|
|
853
|
-
ctx2.uid = evt.id;
|
|
500
|
+
return () => trap == null ? void 0 : trap.deactivate();
|
|
501
|
+
}
|
|
854
502
|
},
|
|
855
|
-
|
|
856
|
-
ctx2
|
|
503
|
+
guards: {
|
|
504
|
+
portalled: (ctx2) => ctx2.currentPortalled,
|
|
505
|
+
isRelatedTargetWithinContent: (ctx2, evt) => contains(dom.getContentEl(ctx2), evt.target),
|
|
506
|
+
closeOnInteractOutside: (ctx2) => !!ctx2.closeOnInteractOutside,
|
|
507
|
+
isContentFocused: (ctx2) => dom.getContentEl(ctx2) === dom.getActiveEl(ctx2),
|
|
508
|
+
isTriggerFocused: (ctx2) => dom.getTriggerEl(ctx2) === dom.getActiveEl(ctx2),
|
|
509
|
+
isFirstTabbableElement: (ctx2) => dom.getFirstTabbableEl(ctx2) === dom.getActiveEl(ctx2),
|
|
510
|
+
isLastTabbableElement: (ctx2) => dom.getLastTabbableEl(ctx2) === dom.getActiveEl(ctx2)
|
|
857
511
|
},
|
|
858
|
-
|
|
859
|
-
|
|
512
|
+
actions: {
|
|
513
|
+
checkRenderedElements(ctx2) {
|
|
514
|
+
raf(() => {
|
|
515
|
+
Object.assign(ctx2.renderedElements, {
|
|
516
|
+
title: !!dom.getTitleEl(ctx2),
|
|
517
|
+
description: !!dom.getDescriptionEl(ctx2),
|
|
518
|
+
anchor: !!dom.getAnchorEl(ctx2)
|
|
519
|
+
});
|
|
520
|
+
});
|
|
521
|
+
},
|
|
522
|
+
setInitialFocus(ctx2) {
|
|
523
|
+
raf(() => {
|
|
524
|
+
var _a;
|
|
525
|
+
(_a = dom.getInitialFocusEl(ctx2)) == null ? void 0 : _a.focus();
|
|
526
|
+
});
|
|
527
|
+
},
|
|
528
|
+
focusTriggerIfNeeded(ctx2) {
|
|
529
|
+
if (!ctx2.focusTriggerOnClose)
|
|
530
|
+
return;
|
|
531
|
+
raf(() => {
|
|
532
|
+
var _a;
|
|
533
|
+
return (_a = dom.getTriggerEl(ctx2)) == null ? void 0 : _a.focus();
|
|
534
|
+
});
|
|
535
|
+
},
|
|
536
|
+
focusFirstTabbableElement(ctx2, evt) {
|
|
860
537
|
var _a;
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
if (!ctx2.focusTriggerOnClose)
|
|
866
|
-
return;
|
|
867
|
-
raf(() => {
|
|
538
|
+
evt.preventDefault();
|
|
539
|
+
(_a = dom.getFirstTabbableEl(ctx2)) == null ? void 0 : _a.focus();
|
|
540
|
+
},
|
|
541
|
+
invokeOnOpen(ctx2, evt) {
|
|
868
542
|
var _a;
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
let tabbables = dom.getDocTabbableEls(ctx2);
|
|
898
|
-
let elementAfterTrigger = next(tabbables, tabbables.indexOf(button), { loop: false });
|
|
899
|
-
if (elementAfterTrigger === content) {
|
|
900
|
-
tabbables = tabbables.filter((el) => !contains(content, el));
|
|
901
|
-
elementAfterTrigger = next(tabbables, tabbables.indexOf(button), { loop: false });
|
|
543
|
+
if (evt.type !== "SETUP") {
|
|
544
|
+
(_a = ctx2.onOpenChange) == null ? void 0 : _a.call(ctx2, true);
|
|
545
|
+
}
|
|
546
|
+
},
|
|
547
|
+
invokeOnClose(ctx2, evt) {
|
|
548
|
+
var _a;
|
|
549
|
+
if (evt.type !== "SETUP") {
|
|
550
|
+
(_a = ctx2.onOpenChange) == null ? void 0 : _a.call(ctx2, false);
|
|
551
|
+
}
|
|
552
|
+
},
|
|
553
|
+
focusNextTabbableElementAfterTrigger(ctx2, evt) {
|
|
554
|
+
const content = dom.getContentEl(ctx2);
|
|
555
|
+
const button = dom.getTriggerEl(ctx2);
|
|
556
|
+
if (!content || !button)
|
|
557
|
+
return;
|
|
558
|
+
const lastTabbable = dom.getLastTabbableEl(ctx2);
|
|
559
|
+
if (lastTabbable !== dom.getActiveEl(ctx2))
|
|
560
|
+
return;
|
|
561
|
+
let tabbables = dom.getDocTabbableEls(ctx2);
|
|
562
|
+
let elementAfterTrigger = next(tabbables, tabbables.indexOf(button), { loop: false });
|
|
563
|
+
if (elementAfterTrigger === content) {
|
|
564
|
+
tabbables = tabbables.filter((el) => !contains(content, el));
|
|
565
|
+
elementAfterTrigger = next(tabbables, tabbables.indexOf(button), { loop: false });
|
|
566
|
+
}
|
|
567
|
+
if (!elementAfterTrigger || elementAfterTrigger === button)
|
|
568
|
+
return;
|
|
569
|
+
evt.preventDefault();
|
|
570
|
+
raf(() => elementAfterTrigger == null ? void 0 : elementAfterTrigger.focus());
|
|
902
571
|
}
|
|
903
|
-
if (!elementAfterTrigger || elementAfterTrigger === button)
|
|
904
|
-
return;
|
|
905
|
-
evt.preventDefault();
|
|
906
|
-
raf(() => elementAfterTrigger == null ? void 0 : elementAfterTrigger.focus());
|
|
907
572
|
}
|
|
908
573
|
}
|
|
909
|
-
|
|
574
|
+
);
|
|
910
575
|
}
|
|
911
576
|
export {
|
|
912
577
|
connect,
|