@zag-js/popover 0.1.4 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -18,115 +18,6 @@ var __spreadValues = (a, b) => {
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
20
 
21
- // ../../../node_modules/compute-scroll-into-view/dist/index.module.js
22
- function t(t3) {
23
- return typeof t3 == "object" && t3 != null && t3.nodeType === 1;
24
- }
25
- function e(t3, e2) {
26
- return (!e2 || t3 !== "hidden") && t3 !== "visible" && t3 !== "clip";
27
- }
28
- function n(t3, n2) {
29
- if (t3.clientHeight < t3.scrollHeight || t3.clientWidth < t3.scrollWidth) {
30
- var r2 = getComputedStyle(t3, null);
31
- return e(r2.overflowY, n2) || e(r2.overflowX, n2) || function(t4) {
32
- var e2 = function(t5) {
33
- if (!t5.ownerDocument || !t5.ownerDocument.defaultView)
34
- return null;
35
- try {
36
- return t5.ownerDocument.defaultView.frameElement;
37
- } catch (t6) {
38
- return null;
39
- }
40
- }(t4);
41
- return !!e2 && (e2.clientHeight < t4.scrollHeight || e2.clientWidth < t4.scrollWidth);
42
- }(t3);
43
- }
44
- return false;
45
- }
46
- function r(t3, e2, n2, r2, i, o, l, d) {
47
- return o < t3 && l > e2 || o > t3 && l < e2 ? 0 : o <= t3 && d <= n2 || l >= e2 && d >= n2 ? o - t3 - r2 : l > e2 && d < n2 || o < t3 && d > n2 ? l - e2 + i : 0;
48
- }
49
- function index_module_default(e2, i) {
50
- var o = window, l = i.scrollMode, d = i.block, u = i.inline, h = i.boundary, a = i.skipOverflowHiddenElements, c = typeof h == "function" ? h : function(t3) {
51
- return t3 !== h;
52
- };
53
- if (!t(e2))
54
- throw new TypeError("Invalid target");
55
- for (var f = document.scrollingElement || document.documentElement, s = [], p = e2; t(p) && c(p); ) {
56
- if ((p = p.parentElement) === f) {
57
- s.push(p);
58
- break;
59
- }
60
- p != null && p === document.body && n(p) && !n(document.documentElement) || p != null && n(p, a) && s.push(p);
61
- }
62
- for (var m = o.visualViewport ? o.visualViewport.width : innerWidth, g = o.visualViewport ? o.visualViewport.height : innerHeight, w = window.scrollX || pageXOffset, v = window.scrollY || pageYOffset, W = e2.getBoundingClientRect(), b = W.height, H = W.width, y = W.top, E = W.right, M = W.bottom, V = W.left, x = d === "start" || d === "nearest" ? y : d === "end" ? M : y + b / 2, I = u === "center" ? V + H / 2 : u === "end" ? E : V, C = [], T = 0; T < s.length; T++) {
63
- var k = s[T], B = k.getBoundingClientRect(), D = B.height, O = B.width, R = B.top, X = B.right, Y = B.bottom, L = B.left;
64
- if (l === "if-needed" && y >= 0 && V >= 0 && M <= g && E <= m && y >= R && M <= Y && V >= L && E <= X)
65
- return C;
66
- var S = getComputedStyle(k), j = parseInt(S.borderLeftWidth, 10), q = parseInt(S.borderTopWidth, 10), z = parseInt(S.borderRightWidth, 10), A = parseInt(S.borderBottomWidth, 10), F = 0, G = 0, J = "offsetWidth" in k ? k.offsetWidth - k.clientWidth - j - z : 0, K = "offsetHeight" in k ? k.offsetHeight - k.clientHeight - q - A : 0;
67
- if (f === k)
68
- F = d === "start" ? x : d === "end" ? x - g : d === "nearest" ? r(v, v + g, g, q, A, v + x, v + x + b, b) : x - g / 2, G = u === "start" ? I : u === "center" ? I - m / 2 : u === "end" ? I - m : r(w, w + m, m, j, z, w + I, w + I + H, H), F = Math.max(0, F + v), G = Math.max(0, G + w);
69
- else {
70
- F = d === "start" ? x - R - q : d === "end" ? x - Y + A + K : d === "nearest" ? r(R, Y, D, q, A + K, x, x + b, b) : x - (R + D / 2) + K / 2, G = u === "start" ? I - L - j : u === "center" ? I - (L + O / 2) + J / 2 : u === "end" ? I - X + z + J : r(L, X, O, j, z + J, I, I + H, H);
71
- var N = k.scrollLeft, P = k.scrollTop;
72
- x += P - (F = Math.max(0, Math.min(P + F, k.scrollHeight - D + K))), I += N - (G = Math.max(0, Math.min(N + G, k.scrollWidth - O + J)));
73
- }
74
- C.push({ el: k, top: F, left: G });
75
- }
76
- return C;
77
- }
78
-
79
- // ../../utilities/dom/node_modules/scroll-into-view-if-needed/es/index.js
80
- function isOptionsObject(options) {
81
- return options === Object(options) && Object.keys(options).length !== 0;
82
- }
83
- function defaultBehavior(actions, behavior) {
84
- if (behavior === void 0) {
85
- behavior = "auto";
86
- }
87
- var canSmoothScroll = "scrollBehavior" in document.body.style;
88
- actions.forEach(function(_ref) {
89
- var el = _ref.el, top = _ref.top, left = _ref.left;
90
- if (el.scroll && canSmoothScroll) {
91
- el.scroll({
92
- top,
93
- left,
94
- behavior
95
- });
96
- } else {
97
- el.scrollTop = top;
98
- el.scrollLeft = left;
99
- }
100
- });
101
- }
102
- function getOptions(options) {
103
- if (options === false) {
104
- return {
105
- block: "end",
106
- inline: "nearest"
107
- };
108
- }
109
- if (isOptionsObject(options)) {
110
- return options;
111
- }
112
- return {
113
- block: "start",
114
- inline: "nearest"
115
- };
116
- }
117
- function scrollIntoView(target, options) {
118
- var isTargetAttached = target.isConnected || target.ownerDocument.documentElement.contains(target);
119
- if (isOptionsObject(options) && typeof options.behavior === "function") {
120
- return options.behavior(isTargetAttached ? index_module_default(target, options) : []);
121
- }
122
- if (!isTargetAttached) {
123
- return;
124
- }
125
- var computeOptions = getOptions(options);
126
- return defaultBehavior(index_module_default(target, computeOptions), computeOptions.behavior);
127
- }
128
- var es_default = scrollIntoView;
129
-
130
21
  // ../../utilities/dom/dist/index.mjs
131
22
  var dataAttr = (guard) => {
132
23
  return guard ? "" : void 0;
@@ -168,16 +59,17 @@ function raf(fn) {
168
59
  globalThis.cancelAnimationFrame(id);
169
60
  };
170
61
  }
62
+ var isDom = () => typeof window !== "undefined";
63
+ var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
64
+ var isTouchDevice = isDom() && !!navigator.maxTouchPoints;
65
+ var isLeftClick = (v) => v.button === 0;
66
+ var runIfFn = (v, ...a) => {
67
+ const res = typeof v === "function" ? v(...a) : v;
68
+ return res != null ? res : void 0;
69
+ };
171
70
  var noop = () => {
172
71
  };
173
72
  var pipe = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
174
- var platform = (v) => isDom() && v.test(navigator.platform);
175
- var isDom = () => !!(typeof window !== "undefined");
176
- var isMac = () => platform(/^Mac/);
177
- var isIPhone = () => platform(/^iPhone/);
178
- var isIPad = () => platform(/^iPad/) || isMac() && navigator.maxTouchPoints > 1;
179
- var isIos = () => isIPhone() || isIPad();
180
- var isLeftClick = (v) => v.button === 0;
181
73
  function getListenerElements() {
182
74
  ;
183
75
  globalThis.__listenerElements__ = globalThis.__listenerElements__ || /* @__PURE__ */ new Map();
@@ -188,7 +80,7 @@ function getListenerCache() {
188
80
  globalThis.__listenerCache__ = globalThis.__listenerCache__ || /* @__PURE__ */ new Map();
189
81
  return globalThis.__listenerCache__;
190
82
  }
191
- function globalEventBus(node, type, handler, options) {
83
+ function addGlobalEventListener(node, type, handler, options) {
192
84
  var _a;
193
85
  if (!node)
194
86
  return noop;
@@ -240,12 +132,10 @@ function globalEventBus(node, type, handler, options) {
240
132
  }
241
133
  };
242
134
  }
243
- var t2 = (v) => Object.prototype.toString.call(v).slice(8, -1);
244
- var isRef = (v) => t2(v) === "Object" && "current" in v;
245
- var runIfFn = (fn) => t2(fn) === "Function" ? fn() : fn;
135
+ var isRef = (v) => hasProp(v, "current");
246
136
  function addDomEvent(target, event, listener, options) {
247
137
  const node = isRef(target) ? target.current : runIfFn(target);
248
- return globalEventBus(node, event, listener, options);
138
+ return addGlobalEventListener(node, event, listener, options);
249
139
  }
250
140
  var changeCount = 0;
251
141
  var originalBodyPointerEvents;
@@ -305,21 +195,6 @@ function preventBodyPointerEvents(el, opts = {}) {
305
195
  cleanups.forEach((cleanup) => cleanup == null ? void 0 : cleanup());
306
196
  };
307
197
  }
308
- function getOwnerDocument(el) {
309
- var _a;
310
- if (isWindow(el))
311
- return el.document;
312
- return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
313
- }
314
- function getNodeName(node) {
315
- return isWindow(node) ? "" : node ? node.localName || "" : "";
316
- }
317
- function getParent(el) {
318
- const doc = getOwnerDocument(el);
319
- if (getNodeName(el) === "html")
320
- return el;
321
- return el.assignedSlot || el.parentElement || doc.documentElement;
322
- }
323
198
  function contains(parent, child) {
324
199
  if (!parent)
325
200
  return false;
@@ -328,124 +203,9 @@ function contains(parent, child) {
328
203
  function isHTMLElement(v) {
329
204
  return typeof v === "object" && (v == null ? void 0 : v.nodeType) === Node.ELEMENT_NODE && typeof (v == null ? void 0 : v.nodeName) === "string";
330
205
  }
331
- function isWindow(value) {
332
- return (value == null ? void 0 : value.toString()) === "[object Window]";
333
- }
334
206
  var isDisabled = (el) => {
335
207
  return (el == null ? void 0 : el.getAttribute("disabled")) != null || !!(el == null ? void 0 : el.getAttribute("aria-disabled")) === true;
336
208
  };
337
- function isScrollParent(el) {
338
- const { overflow, overflowX, overflowY } = getComputedStyle2(el);
339
- return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
340
- }
341
- function getScrollParent(el) {
342
- if (["html", "body", "#document"].includes(getNodeName(el))) {
343
- return getOwnerDocument(el).body;
344
- }
345
- if (isHTMLElement(el) && isScrollParent(el)) {
346
- return el;
347
- }
348
- return getScrollParent(getParent(el));
349
- }
350
- var nonTextInputTypes = /* @__PURE__ */ new Set(["checkbox", "radio", "range", "color", "file", "image", "button", "submit", "reset"]);
351
- function preventBodyScroll(opts) {
352
- var _a;
353
- const { document: docProp, disabled = false, allowPinchZoom } = opts != null ? opts : {};
354
- const doc = docProp != null ? docProp : document;
355
- const win = (_a = doc == null ? void 0 : doc.defaultView) != null ? _a : window;
356
- const viewport = isDom() ? win.visualViewport : null;
357
- const docEl = doc.documentElement;
358
- function preventScrollStandard() {
359
- if (docEl.hasAttribute("scroll-lock"))
360
- return;
361
- const fn = pipe(setStyle(docEl, "paddingRight", `${win.innerWidth - docEl.clientWidth}px`), setStyle(docEl, "overflow", "hidden"), () => docEl.setAttribute("scroll-lock", "true"));
362
- return pipe(fn, () => docEl.removeAttribute("scroll-lock"));
363
- }
364
- function preventScrollMobileSafari() {
365
- if (docEl.hasAttribute("scroll-lock"))
366
- return;
367
- let scrollable;
368
- let lastY = 0;
369
- let onTouchStart = (e2) => {
370
- scrollable = getScrollParent(e2.target);
371
- if (scrollable === docEl && scrollable === doc.body) {
372
- return;
373
- }
374
- lastY = e2.changedTouches[0].pageY;
375
- };
376
- let onTouchMove = (e2) => {
377
- if (e2.touches.length === 2 && allowPinchZoom)
378
- return;
379
- if (!scrollable || scrollable === docEl || scrollable === doc.body) {
380
- e2.preventDefault();
381
- return;
382
- }
383
- let y = e2.changedTouches[0].pageY;
384
- let scrollTop = scrollable.scrollTop;
385
- let bottom = scrollable.scrollHeight - scrollable.clientHeight;
386
- if (scrollTop <= 0 && y > lastY || scrollTop >= bottom && y < lastY) {
387
- e2.preventDefault();
388
- }
389
- lastY = y;
390
- };
391
- let onTouchEnd = (e2) => {
392
- let target = e2.target;
393
- if (target instanceof win.HTMLInputElement && !nonTextInputTypes.has(target.type)) {
394
- e2.preventDefault();
395
- target.style.transform = "translateY(-2000px)";
396
- target.focus();
397
- win.requestAnimationFrame(() => {
398
- target.style.transform = "";
399
- });
400
- }
401
- };
402
- let onFocus = (e2) => {
403
- let target = e2.target;
404
- if (target instanceof win.HTMLInputElement && !nonTextInputTypes.has(target.type)) {
405
- target.style.transform = "translateY(-2000px)";
406
- win.requestAnimationFrame(() => {
407
- target.style.transform = "";
408
- if (!viewport)
409
- return;
410
- if (viewport.height < win.innerHeight) {
411
- win.requestAnimationFrame(function() {
412
- es_default(target, { scrollMode: "if-needed" });
413
- });
414
- } else {
415
- const onResize = () => {
416
- es_default(target, { scrollMode: "if-needed" });
417
- };
418
- addDomEvent(viewport, "resize", onResize, { once: true });
419
- }
420
- });
421
- }
422
- };
423
- let onWindowScroll = () => {
424
- win.scrollTo(0, 0);
425
- };
426
- let scrollX = win.scrollX;
427
- let scrollY = win.scrollY;
428
- let restoreStyles = pipe(setStyle(docEl, "paddingRight", `${win.innerWidth - docEl.clientWidth}px`), setStyle(docEl, "overflow", "hidden"), setStyle(doc.body, "marginTop", `-${scrollY}px`));
429
- win.scrollTo(0, 0);
430
- let removeEvents = pipe(addDomEvent(doc, "touchstart", onTouchStart, { passive: false, capture: true }), addDomEvent(doc, "touchmove", onTouchMove, { passive: false, capture: true }), addDomEvent(doc, "touchend", onTouchEnd, { passive: false, capture: true }), addDomEvent(doc, "focus", onFocus, true), addDomEvent(win, "scroll", onWindowScroll), () => docEl.setAttribute("scroll-lock", "true"));
431
- return () => {
432
- restoreStyles();
433
- removeEvents();
434
- win.scrollTo(scrollX, scrollY);
435
- docEl.removeAttribute("scroll-lock");
436
- };
437
- }
438
- if (disabled)
439
- return noop;
440
- return isIos() ? preventScrollMobileSafari() : preventScrollStandard();
441
- }
442
- function setStyle(el, key, value) {
443
- let cur = el.style[key];
444
- el.style[key] = value;
445
- return () => {
446
- el.style[key] = cur;
447
- };
448
- }
449
209
  function validateBlur(event, opts) {
450
210
  var _a;
451
211
  const exclude = Array.isArray(opts.exclude) ? opts.exclude : [opts.exclude];
@@ -486,7 +246,8 @@ var getFocusables = (el, includeContainer = false) => {
486
246
  if (!el)
487
247
  return [];
488
248
  let els = Array.from(el.querySelectorAll(focusableSelector));
489
- if (includeContainer && isHTMLElement(el)) {
249
+ const shouldAddContainer = includeContainer == true || includeContainer == "if-empty" && els.length === 0;
250
+ if (shouldAddContainer && isHTMLElement(el)) {
490
251
  els.unshift(el);
491
252
  }
492
253
  return els.filter((el2) => isFocusable(el2) && !isHidden(el2));
@@ -497,6 +258,8 @@ var isFocusable = (el) => {
497
258
  return el == null ? void 0 : el.matches(focusableSelector);
498
259
  };
499
260
  var getTabbables = (el, includeContainer = false) => {
261
+ if (!el)
262
+ return [];
500
263
  return getFocusables(el, includeContainer).filter(isTabbable);
501
264
  };
502
265
  var isTabbable = (el) => {
@@ -570,7 +333,11 @@ import { getPlacementStyles } from "@zag-js/popper";
570
333
 
571
334
  // ../../types/dist/index.mjs
572
335
  function createNormalizer(fn) {
573
- return { button: fn, label: fn, input: fn, output: fn, element: fn };
336
+ return new Proxy({}, {
337
+ get() {
338
+ return fn;
339
+ }
340
+ });
574
341
  }
575
342
  var normalizeProp = createNormalizer((v) => v);
576
343
 
@@ -593,6 +360,8 @@ function nextIndex(v, idx, opts = {}) {
593
360
  function next(v, idx, opts = {}) {
594
361
  return v[nextIndex(v, idx, opts)];
595
362
  }
363
+ var isDom2 = () => typeof window !== "undefined";
364
+ var isTouchDevice2 = isDom2() && !!navigator.maxTouchPoints;
596
365
  var runIfFn2 = (v, ...a) => {
597
366
  const res = typeof v === "function" ? v(...a) : v;
598
367
  return res != null ? res : void 0;
@@ -645,15 +414,16 @@ var dom = {
645
414
  getFocusableEls: (ctx) => getFocusables(dom.getContentEl(ctx)),
646
415
  getFirstFocusableEl: (ctx) => dom.getFocusableEls(ctx)[0],
647
416
  getDocTabbableEls: (ctx) => getTabbables(cast(dom.getDoc(ctx))),
648
- getTabbableEls: (ctx) => {
649
- const el = dom.getContentEl(ctx);
650
- return el ? getTabbables(el) : [];
651
- },
417
+ getTabbableEls: (ctx) => getTabbables(dom.getContentEl(ctx), "if-empty"),
652
418
  getFirstTabbableEl: (ctx) => first(dom.getTabbableEls(ctx)),
653
419
  getLastTabbableEl: (ctx) => last(dom.getTabbableEls(ctx)),
654
420
  getInitialFocusEl: (ctx) => {
655
- var _a;
656
- return (_a = runIfFn2(ctx.initialFocusEl)) != null ? _a : dom.getFirstFocusableEl(ctx);
421
+ let el = runIfFn2(ctx.initialFocusEl);
422
+ if (!el && ctx.autoFocus)
423
+ el = dom.getFirstFocusableEl(ctx);
424
+ if (!el)
425
+ el = dom.getContentEl(ctx);
426
+ return el;
657
427
  }
658
428
  };
659
429
 
@@ -661,9 +431,10 @@ var dom = {
661
431
  function connect(state, send, normalize = normalizeProp) {
662
432
  const isOpen = state.matches("open");
663
433
  const pointerdownNode = state.context.pointerdownNode;
434
+ const currentPlacement = state.context.currentPlacement;
664
435
  const popperStyles = getPlacementStyles({
665
436
  measured: !!state.context.isPlacementComplete,
666
- placement: state.context.currentPlacement
437
+ placement: currentPlacement
667
438
  });
668
439
  return {
669
440
  portalled: state.context.currentPortalled,
@@ -690,7 +461,7 @@ function connect(state, send, normalize = normalizeProp) {
690
461
  triggerProps: normalize.button({
691
462
  "data-part": "trigger",
692
463
  type: "button",
693
- "data-placement": state.context.currentPlacement,
464
+ "data-placement": currentPlacement,
694
465
  id: dom.getTriggerId(state.context),
695
466
  "aria-haspopup": "dialog",
696
467
  "aria-expanded": isOpen,
@@ -698,6 +469,11 @@ function connect(state, send, normalize = normalizeProp) {
698
469
  "aria-controls": dom.getContentId(state.context),
699
470
  onClick() {
700
471
  send("TRIGGER_CLICK");
472
+ },
473
+ onKeyDown(event) {
474
+ if (event.key === "Escape") {
475
+ send("ESCAPE");
476
+ }
701
477
  }
702
478
  }),
703
479
  positionerProps: normalize.element({
@@ -711,9 +487,10 @@ function connect(state, send, normalize = normalizeProp) {
711
487
  tabIndex: -1,
712
488
  role: "dialog",
713
489
  hidden: !isOpen,
714
- "aria-labelledby": state.context.isTitleRendered ? dom.getTitleId(state.context) : void 0,
715
- "aria-describedby": state.context.isDescriptionRendered ? dom.getDescriptionId(state.context) : void 0,
716
- "data-placement": state.context.currentPlacement,
490
+ "data-expanded": dataAttr(isOpen),
491
+ "aria-labelledby": state.context.renderedElements.title ? dom.getTitleId(state.context) : void 0,
492
+ "aria-describedby": state.context.renderedElements.description ? dom.getDescriptionId(state.context) : void 0,
493
+ "data-placement": currentPlacement,
717
494
  onKeyDown(event) {
718
495
  const keyMap = {
719
496
  Escape(event2) {
@@ -761,19 +538,17 @@ function connect(state, send, normalize = normalizeProp) {
761
538
  }
762
539
 
763
540
  // src/popover.machine.ts
764
- import { choose, createMachine, guards, ref } from "@zag-js/core";
765
- import { getPlacement } from "@zag-js/popper";
766
541
  import { ariaHidden } from "@zag-js/aria-hidden";
542
+ import { createMachine, guards, ref } from "@zag-js/core";
543
+ import { getPlacement } from "@zag-js/popper";
544
+ import { preventBodyScroll } from "@zag-js/remove-scroll";
767
545
  import { createFocusTrap } from "focus-trap";
768
546
  var { and, or } = guards;
769
547
  function machine(ctx = {}) {
770
548
  return createMachine({
771
549
  id: "popover",
772
550
  initial: "unknown",
773
- context: __spreadValues({
774
- isTitleRendered: true,
775
- isDescriptionRendered: true,
776
- isAnchorRendered: false,
551
+ context: __spreadProps(__spreadValues({
777
552
  uid: "",
778
553
  closeOnBlur: true,
779
554
  closeOnEsc: true,
@@ -783,7 +558,13 @@ function machine(ctx = {}) {
783
558
  placement: "bottom"
784
559
  }, ctx.positioning),
785
560
  currentPlacement: void 0
786
- }, ctx),
561
+ }, ctx), {
562
+ renderedElements: {
563
+ title: true,
564
+ description: true,
565
+ anchor: false
566
+ }
567
+ }),
787
568
  computed: {
788
569
  currentPortalled: (ctx2) => !!ctx2.modal || !!ctx2.portalled
789
570
  },
@@ -791,7 +572,7 @@ function machine(ctx = {}) {
791
572
  unknown: {
792
573
  on: {
793
574
  SETUP: {
794
- target: "closed",
575
+ target: ctx.open ? "open" : "closed",
795
576
  actions: ["setupDocument", "checkRenderedElements"]
796
577
  }
797
578
  }
@@ -812,13 +593,7 @@ function machine(ctx = {}) {
812
593
  "disableOutsidePointerEvents",
813
594
  "computePlacement"
814
595
  ],
815
- entry: choose([
816
- {
817
- guard: "autoFocus",
818
- actions: ["setInitialFocus", "invokeOnOpen"]
819
- },
820
- { actions: ["focusContent", "invokeOnOpen"] }
821
- ]),
596
+ entry: ["setInitialFocus", "invokeOnOpen"],
822
597
  on: {
823
598
  CLOSE: {
824
599
  target: "closed",
@@ -861,7 +636,7 @@ function machine(ctx = {}) {
861
636
  activities: {
862
637
  computePlacement(ctx2) {
863
638
  ctx2.currentPlacement = ctx2.positioning.placement;
864
- const anchorEl = ctx2.isAnchorRendered ? dom.getAnchorEl(ctx2) : dom.getTriggerEl(ctx2);
639
+ const anchorEl = ctx2.renderedElements.anchor ? dom.getAnchorEl(ctx2) : dom.getTriggerEl(ctx2);
865
640
  return getPlacement(anchorEl, dom.getPositionerEl(ctx2), __spreadProps(__spreadValues({}, ctx2.positioning), {
866
641
  onComplete(data) {
867
642
  ctx2.currentPlacement = data.placement;
@@ -896,7 +671,6 @@ function machine(ctx = {}) {
896
671
  },
897
672
  preventScroll(ctx2) {
898
673
  return preventBodyScroll({
899
- allowPinchZoom: true,
900
674
  disabled: !ctx2.modal,
901
675
  document: dom.getDoc(ctx2)
902
676
  });
@@ -919,7 +693,7 @@ function machine(ctx = {}) {
919
693
  });
920
694
  try {
921
695
  trap.activate();
922
- } catch (e2) {
696
+ } catch (e) {
923
697
  }
924
698
  });
925
699
  return () => trap == null ? void 0 : trap.deactivate();
@@ -939,9 +713,11 @@ function machine(ctx = {}) {
939
713
  actions: {
940
714
  checkRenderedElements(ctx2) {
941
715
  raf(() => {
942
- ctx2.isAnchorRendered = !!dom.getAnchorEl(ctx2);
943
- ctx2.isTitleRendered = !!dom.getTitleEl(ctx2);
944
- ctx2.isDescriptionRendered = !!dom.getDescriptionEl(ctx2);
716
+ Object.assign(ctx2.renderedElements, {
717
+ title: !!dom.getTitleEl(ctx2),
718
+ description: !!dom.getDescriptionEl(ctx2),
719
+ anchor: !!dom.getAnchorEl(ctx2)
720
+ });
945
721
  });
946
722
  },
947
723
  setupDocument(ctx2, evt) {
@@ -954,12 +730,6 @@ function machine(ctx = {}) {
954
730
  clearPointerDown(ctx2) {
955
731
  ctx2.pointerdownNode = null;
956
732
  },
957
- focusContent(ctx2) {
958
- raf(() => {
959
- var _a;
960
- (_a = dom.getContentEl(ctx2)) == null ? void 0 : _a.focus();
961
- });
962
- },
963
733
  setInitialFocus(ctx2) {
964
734
  raf(() => {
965
735
  var _a;