@zag-js/popover 0.0.0-dev-20230221113221 → 0.0.0-dev-20230222181847

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.
@@ -0,0 +1,39 @@
1
+ // src/popover.dom.ts
2
+ import { createScope } from "@zag-js/dom-query";
3
+ import { getFirstTabbable, getFocusables, getLastTabbable, getTabbables } from "@zag-js/tabbable";
4
+ import { runIfFn } from "@zag-js/utils";
5
+ var dom = createScope({
6
+ getActiveEl: (ctx) => dom.getDoc(ctx).activeElement,
7
+ getAnchorId: (ctx) => ctx.ids?.anchor ?? `popover:${ctx.id}:anchor`,
8
+ getTriggerId: (ctx) => ctx.ids?.trigger ?? `popover:${ctx.id}:trigger`,
9
+ getContentId: (ctx) => ctx.ids?.content ?? `popover:${ctx.id}:content`,
10
+ getPositionerId: (ctx) => `popover:${ctx.id}:popper`,
11
+ getArrowId: (ctx) => `popover:${ctx.id}:arrow`,
12
+ getTitleId: (ctx) => ctx.ids?.title ?? `popover:${ctx.id}:title`,
13
+ getDescriptionId: (ctx) => ctx.ids?.description ?? `popover:${ctx.id}:desc`,
14
+ getCloseTriggerId: (ctx) => ctx.ids?.closeTrigger ?? `popover:${ctx.id}:close`,
15
+ getAnchorEl: (ctx) => dom.getById(ctx, dom.getAnchorId(ctx)),
16
+ getTriggerEl: (ctx) => dom.getById(ctx, dom.getTriggerId(ctx)),
17
+ getContentEl: (ctx) => dom.getById(ctx, dom.getContentId(ctx)),
18
+ getPositionerEl: (ctx) => dom.getById(ctx, dom.getPositionerId(ctx)),
19
+ getTitleEl: (ctx) => dom.getById(ctx, dom.getTitleId(ctx)),
20
+ getDescriptionEl: (ctx) => dom.getById(ctx, dom.getDescriptionId(ctx)),
21
+ getFocusableEls: (ctx) => getFocusables(dom.getContentEl(ctx)),
22
+ getFirstFocusableEl: (ctx) => dom.getFocusableEls(ctx)[0],
23
+ getDocTabbableEls: (ctx) => getTabbables(dom.getDoc(ctx).body),
24
+ getTabbableEls: (ctx) => getTabbables(dom.getContentEl(ctx), "if-empty"),
25
+ getFirstTabbableEl: (ctx) => getFirstTabbable(dom.getContentEl(ctx), "if-empty"),
26
+ getLastTabbableEl: (ctx) => getLastTabbable(dom.getContentEl(ctx), "if-empty"),
27
+ getInitialFocusEl: (ctx) => {
28
+ let el = runIfFn(ctx.initialFocusEl);
29
+ if (!el && ctx.autoFocus)
30
+ el = dom.getFirstFocusableEl(ctx);
31
+ if (!el)
32
+ el = dom.getContentEl(ctx);
33
+ return el;
34
+ }
35
+ });
36
+
37
+ export {
38
+ dom
39
+ };
@@ -3,14 +3,10 @@ import {
3
3
  } from "./chunk-KTOPDXGV.mjs";
4
4
  import {
5
5
  dom
6
- } from "./chunk-Z2WON7A5.mjs";
7
-
8
- // ../../utilities/dom/src/attrs.ts
9
- var dataAttr = (guard) => {
10
- return guard ? "" : void 0;
11
- };
6
+ } from "./chunk-4IGGT6KB.mjs";
12
7
 
13
8
  // src/popover.connect.ts
9
+ import { dataAttr } from "@zag-js/dom-query";
14
10
  import { getPlacementStyles } from "@zag-js/popper";
15
11
  function connect(state, send, normalize) {
16
12
  const isOpen = state.matches("open");
@@ -22,11 +18,23 @@ function connect(state, send, normalize) {
22
18
  placement: currentPlacement
23
19
  });
24
20
  return {
21
+ /**
22
+ * Whether the popover is portalled
23
+ */
25
24
  portalled,
25
+ /**
26
+ * Whether the popover is open
27
+ */
26
28
  isOpen,
29
+ /**
30
+ * Function to open the popover
31
+ */
27
32
  open() {
28
33
  send("OPEN");
29
34
  },
35
+ /**
36
+ * Function to close the popover
37
+ */
30
38
  close() {
31
39
  send("CLOSE");
32
40
  },
@@ -1,83 +1,16 @@
1
1
  import {
2
- contains,
3
- dom,
4
- runIfFn
5
- } from "./chunk-Z2WON7A5.mjs";
2
+ dom
3
+ } from "./chunk-4IGGT6KB.mjs";
6
4
 
7
5
  // src/popover.machine.ts
8
6
  import { ariaHidden } from "@zag-js/aria-hidden";
9
7
  import { createMachine, guards } from "@zag-js/core";
10
8
  import { trackDismissableElement } from "@zag-js/dismissable";
11
-
12
- // ../../utilities/core/src/array.ts
13
- function nextIndex(v, idx, opts = {}) {
14
- const { step = 1, loop = true } = opts;
15
- const next2 = idx + step;
16
- const len = v.length;
17
- const last = len - 1;
18
- if (idx === -1)
19
- return step > 0 ? 0 : last;
20
- if (next2 < 0)
21
- return loop ? last : 0;
22
- if (next2 >= len)
23
- return loop ? 0 : idx > len ? len : idx;
24
- return next2;
25
- }
26
- function next(v, idx, opts = {}) {
27
- return v[nextIndex(v, idx, opts)];
28
- }
29
-
30
- // ../../utilities/core/src/guard.ts
31
- var isArray = (v) => Array.isArray(v);
32
- var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
33
- var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
34
-
35
- // ../../utilities/core/src/object.ts
36
- function compact(obj) {
37
- if (obj === void 0)
38
- return obj;
39
- return Object.fromEntries(
40
- Object.entries(obj).filter(([, value]) => value !== void 0).map(([key, value]) => [key, isObject(value) ? compact(value) : value])
41
- );
42
- }
43
-
44
- // ../../utilities/dom/src/event.ts
45
- var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey;
46
-
47
- // ../../utilities/dom/src/listener.ts
48
- var isRef = (v) => hasProp(v, "current");
49
- function addDomEvent(target, eventName, handler, options) {
50
- const node = isRef(target) ? target.current : runIfFn(target);
51
- node?.addEventListener(eventName, handler, options);
52
- return () => {
53
- node?.removeEventListener(eventName, handler, options);
54
- };
55
- }
56
-
57
- // ../../utilities/dom/src/next-tick.ts
58
- function nextTick(fn) {
59
- const set = /* @__PURE__ */ new Set();
60
- function raf2(fn2) {
61
- const id = globalThis.requestAnimationFrame(fn2);
62
- set.add(() => globalThis.cancelAnimationFrame(id));
63
- }
64
- raf2(() => raf2(fn));
65
- return function cleanup() {
66
- set.forEach(function(fn2) {
67
- fn2();
68
- });
69
- };
70
- }
71
- function raf(fn) {
72
- const id = globalThis.requestAnimationFrame(fn);
73
- return function cleanup() {
74
- globalThis.cancelAnimationFrame(id);
75
- };
76
- }
77
-
78
- // src/popover.machine.ts
9
+ import { contains, nextTick, raf } from "@zag-js/dom-query";
10
+ import { addDomEvent, isModifiedEvent } from "@zag-js/dom-event";
79
11
  import { getPlacement } from "@zag-js/popper";
80
12
  import { preventBodyScroll } from "@zag-js/remove-scroll";
13
+ import { compact, next, runIfFn } from "@zag-js/utils";
81
14
  import { createFocusTrap } from "focus-trap";
82
15
  var { and, or, not } = guards;
83
16
  function machine(userContext) {
package/dist/index.js CHANGED
@@ -41,198 +41,15 @@ var anatomy = (0, import_anatomy.createAnatomy)("popover").parts(
41
41
  );
42
42
  var parts = anatomy.build();
43
43
 
44
- // ../../utilities/dom/src/attrs.ts
45
- var dataAttr = (guard) => {
46
- return guard ? "" : void 0;
47
- };
48
-
49
- // ../../utilities/core/src/array.ts
50
- function nextIndex(v, idx, opts = {}) {
51
- const { step = 1, loop = true } = opts;
52
- const next2 = idx + step;
53
- const len = v.length;
54
- const last = len - 1;
55
- if (idx === -1)
56
- return step > 0 ? 0 : last;
57
- if (next2 < 0)
58
- return loop ? last : 0;
59
- if (next2 >= len)
60
- return loop ? 0 : idx > len ? len : idx;
61
- return next2;
62
- }
63
- function next(v, idx, opts = {}) {
64
- return v[nextIndex(v, idx, opts)];
65
- }
66
-
67
- // ../../utilities/core/src/functions.ts
68
- var runIfFn = (v, ...a) => {
69
- const res = typeof v === "function" ? v(...a) : v;
70
- return res ?? void 0;
71
- };
72
-
73
- // ../../utilities/core/src/guard.ts
74
- var isArray = (v) => Array.isArray(v);
75
- var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
76
- var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
77
-
78
- // ../../utilities/core/src/object.ts
79
- function compact(obj) {
80
- if (obj === void 0)
81
- return obj;
82
- return Object.fromEntries(
83
- Object.entries(obj).filter(([, value]) => value !== void 0).map(([key, value]) => [key, isObject(value) ? compact(value) : value])
84
- );
85
- }
86
-
87
- // ../../utilities/dom/src/query.ts
88
- function isDocument(el) {
89
- return el.nodeType === Node.DOCUMENT_NODE;
90
- }
91
- function isWindow(value) {
92
- return value?.toString() === "[object Window]";
93
- }
94
- function isFrame(element) {
95
- return element.localName === "iframe";
96
- }
97
- function getDocument(el) {
98
- if (isWindow(el))
99
- return el.document;
100
- if (isDocument(el))
101
- return el;
102
- return el?.ownerDocument ?? document;
103
- }
104
- function defineDomHelpers(helpers) {
105
- const dom2 = {
106
- getRootNode: (ctx) => ctx.getRootNode?.() ?? document,
107
- getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
108
- getWin: (ctx) => dom2.getDoc(ctx).defaultView ?? window,
109
- getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
110
- getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id),
111
- queryById: (ctx, id) => {
112
- const el = dom2.getById(ctx, id);
113
- if (!el)
114
- throw new Error(`Element with id "${id}" not found.`);
115
- return el;
116
- }
117
- };
118
- return {
119
- ...dom2,
120
- ...helpers
121
- };
122
- }
123
- function contains(parent, child) {
124
- if (!parent)
125
- return false;
126
- return parent === child || isHTMLElement(parent) && isHTMLElement(child) && parent.contains(child);
127
- }
128
- function isHTMLElement(v) {
129
- return typeof v === "object" && v?.nodeType === Node.ELEMENT_NODE && typeof v?.nodeName === "string";
130
- }
131
- function isVisible(el) {
132
- if (!isHTMLElement(el))
133
- return false;
134
- return el.offsetWidth > 0 || el.offsetHeight > 0 || el.getClientRects().length > 0;
135
- }
136
-
137
- // ../../utilities/dom/src/event.ts
138
- var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey;
139
-
140
- // ../../utilities/dom/src/focusable.ts
141
- function hasNegativeTabIndex(element) {
142
- const tabIndex = parseInt(element.getAttribute("tabindex") || "0", 10);
143
- return tabIndex < 0;
144
- }
145
- var focusableSelector = "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";
146
- var getFocusables = (container, includeContainer = false) => {
147
- if (!container)
148
- return [];
149
- const elements = Array.from(container.querySelectorAll(focusableSelector));
150
- const include = includeContainer == true || includeContainer == "if-empty" && elements.length === 0;
151
- if (include && isHTMLElement(container) && isFocusable(container)) {
152
- elements.unshift(container);
153
- }
154
- const focusableElements = elements.filter(isFocusable);
155
- focusableElements.forEach((element, i) => {
156
- if (isFrame(element) && element.contentDocument) {
157
- const frameBody = element.contentDocument.body;
158
- focusableElements.splice(i, 1, ...getFocusables(frameBody));
159
- }
160
- });
161
- return focusableElements;
162
- };
163
- function isFocusable(element) {
164
- if (!element)
165
- return false;
166
- return element.matches(focusableSelector) && isVisible(element);
167
- }
168
- function getTabbables(container, includeContainer) {
169
- if (!container)
170
- return [];
171
- const elements = Array.from(container.querySelectorAll(focusableSelector));
172
- const tabbableElements = elements.filter(isTabbable);
173
- if (includeContainer && isTabbable(container)) {
174
- tabbableElements.unshift(container);
175
- }
176
- tabbableElements.forEach((element, i) => {
177
- if (isFrame(element) && element.contentDocument) {
178
- const frameBody = element.contentDocument.body;
179
- const allFrameTabbable = getTabbables(frameBody);
180
- tabbableElements.splice(i, 1, ...allFrameTabbable);
181
- }
182
- });
183
- if (!tabbableElements.length && includeContainer) {
184
- return elements;
185
- }
186
- return tabbableElements;
187
- }
188
- function isTabbable(el) {
189
- return isFocusable(el) && !hasNegativeTabIndex(el);
190
- }
191
- function getFirstTabbable(container, includeContainer) {
192
- const [first] = getTabbables(container, includeContainer);
193
- return first || null;
194
- }
195
- function getLastTabbable(container, includeContainer) {
196
- const elements = getTabbables(container, includeContainer);
197
- return elements[elements.length - 1] || null;
198
- }
199
-
200
- // ../../utilities/dom/src/listener.ts
201
- var isRef = (v) => hasProp(v, "current");
202
- function addDomEvent(target, eventName, handler, options) {
203
- const node = isRef(target) ? target.current : runIfFn(target);
204
- node?.addEventListener(eventName, handler, options);
205
- return () => {
206
- node?.removeEventListener(eventName, handler, options);
207
- };
208
- }
209
-
210
- // ../../utilities/dom/src/next-tick.ts
211
- function nextTick(fn) {
212
- const set = /* @__PURE__ */ new Set();
213
- function raf2(fn2) {
214
- const id = globalThis.requestAnimationFrame(fn2);
215
- set.add(() => globalThis.cancelAnimationFrame(id));
216
- }
217
- raf2(() => raf2(fn));
218
- return function cleanup() {
219
- set.forEach(function(fn2) {
220
- fn2();
221
- });
222
- };
223
- }
224
- function raf(fn) {
225
- const id = globalThis.requestAnimationFrame(fn);
226
- return function cleanup() {
227
- globalThis.cancelAnimationFrame(id);
228
- };
229
- }
230
-
231
44
  // src/popover.connect.ts
45
+ var import_dom_query2 = require("@zag-js/dom-query");
232
46
  var import_popper = require("@zag-js/popper");
233
47
 
234
48
  // src/popover.dom.ts
235
- var dom = defineDomHelpers({
49
+ var import_dom_query = require("@zag-js/dom-query");
50
+ var import_tabbable = require("@zag-js/tabbable");
51
+ var import_utils = require("@zag-js/utils");
52
+ var dom = (0, import_dom_query.createScope)({
236
53
  getActiveEl: (ctx) => dom.getDoc(ctx).activeElement,
237
54
  getAnchorId: (ctx) => ctx.ids?.anchor ?? `popover:${ctx.id}:anchor`,
238
55
  getTriggerId: (ctx) => ctx.ids?.trigger ?? `popover:${ctx.id}:trigger`,
@@ -248,14 +65,14 @@ var dom = defineDomHelpers({
248
65
  getPositionerEl: (ctx) => dom.getById(ctx, dom.getPositionerId(ctx)),
249
66
  getTitleEl: (ctx) => dom.getById(ctx, dom.getTitleId(ctx)),
250
67
  getDescriptionEl: (ctx) => dom.getById(ctx, dom.getDescriptionId(ctx)),
251
- getFocusableEls: (ctx) => getFocusables(dom.getContentEl(ctx)),
68
+ getFocusableEls: (ctx) => (0, import_tabbable.getFocusables)(dom.getContentEl(ctx)),
252
69
  getFirstFocusableEl: (ctx) => dom.getFocusableEls(ctx)[0],
253
- getDocTabbableEls: (ctx) => getTabbables(dom.getDoc(ctx).body),
254
- getTabbableEls: (ctx) => getTabbables(dom.getContentEl(ctx), "if-empty"),
255
- getFirstTabbableEl: (ctx) => getFirstTabbable(dom.getContentEl(ctx), "if-empty"),
256
- getLastTabbableEl: (ctx) => getLastTabbable(dom.getContentEl(ctx), "if-empty"),
70
+ getDocTabbableEls: (ctx) => (0, import_tabbable.getTabbables)(dom.getDoc(ctx).body),
71
+ getTabbableEls: (ctx) => (0, import_tabbable.getTabbables)(dom.getContentEl(ctx), "if-empty"),
72
+ getFirstTabbableEl: (ctx) => (0, import_tabbable.getFirstTabbable)(dom.getContentEl(ctx), "if-empty"),
73
+ getLastTabbableEl: (ctx) => (0, import_tabbable.getLastTabbable)(dom.getContentEl(ctx), "if-empty"),
257
74
  getInitialFocusEl: (ctx) => {
258
- let el = runIfFn(ctx.initialFocusEl);
75
+ let el = (0, import_utils.runIfFn)(ctx.initialFocusEl);
259
76
  if (!el && ctx.autoFocus)
260
77
  el = dom.getFirstFocusableEl(ctx);
261
78
  if (!el)
@@ -275,11 +92,23 @@ function connect(state, send, normalize) {
275
92
  placement: currentPlacement
276
93
  });
277
94
  return {
95
+ /**
96
+ * Whether the popover is portalled
97
+ */
278
98
  portalled,
99
+ /**
100
+ * Whether the popover is open
101
+ */
279
102
  isOpen,
103
+ /**
104
+ * Function to open the popover
105
+ */
280
106
  open() {
281
107
  send("OPEN");
282
108
  },
109
+ /**
110
+ * Function to close the popover
111
+ */
283
112
  close() {
284
113
  send("CLOSE");
285
114
  },
@@ -303,7 +132,7 @@ function connect(state, send, normalize) {
303
132
  id: dom.getTriggerId(state.context),
304
133
  "aria-haspopup": "dialog",
305
134
  "aria-expanded": isOpen,
306
- "data-expanded": dataAttr(isOpen),
135
+ "data-expanded": (0, import_dom_query2.dataAttr)(isOpen),
307
136
  "aria-controls": dom.getContentId(state.context),
308
137
  onClick() {
309
138
  send("TOGGLE");
@@ -323,7 +152,7 @@ function connect(state, send, normalize) {
323
152
  tabIndex: -1,
324
153
  role: "dialog",
325
154
  hidden: !isOpen,
326
- "data-expanded": dataAttr(isOpen),
155
+ "data-expanded": (0, import_dom_query2.dataAttr)(isOpen),
327
156
  "aria-labelledby": rendered.title ? dom.getTitleId(state.context) : void 0,
328
157
  "aria-describedby": rendered.description ? dom.getDescriptionId(state.context) : void 0,
329
158
  "data-placement": currentPlacement
@@ -352,12 +181,15 @@ function connect(state, send, normalize) {
352
181
  var import_aria_hidden = require("@zag-js/aria-hidden");
353
182
  var import_core = require("@zag-js/core");
354
183
  var import_dismissable = require("@zag-js/dismissable");
184
+ var import_dom_query3 = require("@zag-js/dom-query");
185
+ var import_dom_event = require("@zag-js/dom-event");
355
186
  var import_popper2 = require("@zag-js/popper");
356
187
  var import_remove_scroll = require("@zag-js/remove-scroll");
188
+ var import_utils2 = require("@zag-js/utils");
357
189
  var import_focus_trap = require("focus-trap");
358
190
  var { and, or, not } = import_core.guards;
359
191
  function machine(userContext) {
360
- const ctx = compact(userContext);
192
+ const ctx = (0, import_utils2.compact)(userContext);
361
193
  return (0, import_core.createMachine)(
362
194
  {
363
195
  id: "popover",
@@ -486,11 +318,11 @@ function machine(userContext) {
486
318
  trackTabKeyDown(ctx2, _evt, { send }) {
487
319
  if (ctx2.modal)
488
320
  return;
489
- return addDomEvent(
321
+ return (0, import_dom_event.addDomEvent)(
490
322
  dom.getWin(ctx2),
491
323
  "keydown",
492
324
  (event) => {
493
- const isTabKey = event.key === "Tab" && !isModifiedEvent(event);
325
+ const isTabKey = event.key === "Tab" && !(0, import_dom_event.isModifiedEvent)(event);
494
326
  if (!isTabKey)
495
327
  return;
496
328
  send({
@@ -505,7 +337,7 @@ function machine(userContext) {
505
337
  if (!ctx2.modal)
506
338
  return;
507
339
  let cleanup;
508
- nextTick(() => {
340
+ (0, import_dom_query3.nextTick)(() => {
509
341
  cleanup = (0, import_aria_hidden.ariaHidden)([dom.getContentEl(ctx2), dom.getTriggerEl(ctx2)]);
510
342
  });
511
343
  return () => cleanup?.();
@@ -519,7 +351,7 @@ function machine(userContext) {
519
351
  if (!ctx2.modal)
520
352
  return;
521
353
  let trap;
522
- nextTick(() => {
354
+ (0, import_dom_query3.nextTick)(() => {
523
355
  const el = dom.getContentEl(ctx2);
524
356
  if (!el)
525
357
  return;
@@ -529,7 +361,7 @@ function machine(userContext) {
529
361
  returnFocusOnDeactivate: true,
530
362
  document: dom.getDoc(ctx2),
531
363
  fallbackFocus: el,
532
- initialFocus: runIfFn(ctx2.initialFocusEl)
364
+ initialFocus: (0, import_utils2.runIfFn)(ctx2.initialFocusEl)
533
365
  });
534
366
  try {
535
367
  trap.activate();
@@ -541,7 +373,7 @@ function machine(userContext) {
541
373
  },
542
374
  guards: {
543
375
  portalled: (ctx2) => ctx2.currentPortalled,
544
- isRelatedTargetWithinContent: (ctx2, evt) => contains(dom.getContentEl(ctx2), evt.target),
376
+ isRelatedTargetWithinContent: (ctx2, evt) => (0, import_dom_query3.contains)(dom.getContentEl(ctx2), evt.target),
545
377
  closeOnInteractOutside: (ctx2) => !!ctx2.closeOnInteractOutside,
546
378
  isContentFocused: (ctx2) => dom.getContentEl(ctx2) === dom.getActiveEl(ctx2),
547
379
  isTriggerFocused: (ctx2) => dom.getTriggerEl(ctx2) === dom.getActiveEl(ctx2),
@@ -550,7 +382,7 @@ function machine(userContext) {
550
382
  },
551
383
  actions: {
552
384
  checkRenderedElements(ctx2) {
553
- raf(() => {
385
+ (0, import_dom_query3.raf)(() => {
554
386
  Object.assign(ctx2.renderedElements, {
555
387
  title: !!dom.getTitleEl(ctx2),
556
388
  description: !!dom.getDescriptionEl(ctx2),
@@ -559,14 +391,14 @@ function machine(userContext) {
559
391
  });
560
392
  },
561
393
  setInitialFocus(ctx2) {
562
- raf(() => {
394
+ (0, import_dom_query3.raf)(() => {
563
395
  dom.getInitialFocusEl(ctx2)?.focus();
564
396
  });
565
397
  },
566
398
  focusTriggerIfNeeded(ctx2) {
567
399
  if (!ctx2.focusTriggerOnClose)
568
400
  return;
569
- raf(() => dom.getTriggerEl(ctx2)?.focus());
401
+ (0, import_dom_query3.raf)(() => dom.getTriggerEl(ctx2)?.focus());
570
402
  },
571
403
  focusFirstTabbableElement(ctx2, evt) {
572
404
  evt.preventDefault();
@@ -591,15 +423,15 @@ function machine(userContext) {
591
423
  if (lastTabbable !== dom.getActiveEl(ctx2))
592
424
  return;
593
425
  let tabbables = dom.getDocTabbableEls(ctx2);
594
- let elementAfterTrigger = next(tabbables, tabbables.indexOf(button), { loop: false });
426
+ let elementAfterTrigger = (0, import_utils2.next)(tabbables, tabbables.indexOf(button), { loop: false });
595
427
  if (elementAfterTrigger === content) {
596
- tabbables = tabbables.filter((el) => !contains(content, el));
597
- elementAfterTrigger = next(tabbables, tabbables.indexOf(button), { loop: false });
428
+ tabbables = tabbables.filter((el) => !(0, import_dom_query3.contains)(content, el));
429
+ elementAfterTrigger = (0, import_utils2.next)(tabbables, tabbables.indexOf(button), { loop: false });
598
430
  }
599
431
  if (!elementAfterTrigger || elementAfterTrigger === button)
600
432
  return;
601
433
  evt.preventDefault();
602
- raf(() => elementAfterTrigger?.focus());
434
+ (0, import_dom_query3.raf)(() => elementAfterTrigger?.focus());
603
435
  }
604
436
  }
605
437
  }
package/dist/index.mjs CHANGED
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  connect
3
- } from "./chunk-JDSPKDIN.mjs";
3
+ } from "./chunk-GKHXQZZB.mjs";
4
4
  import {
5
5
  anatomy
6
6
  } from "./chunk-KTOPDXGV.mjs";
7
7
  import {
8
8
  machine
9
- } from "./chunk-FRFRU5PG.mjs";
10
- import "./chunk-Z2WON7A5.mjs";
9
+ } from "./chunk-JT2RXXW4.mjs";
10
+ import "./chunk-4IGGT6KB.mjs";
11
11
  export {
12
12
  anatomy,
13
13
  connect,
@@ -5,9 +5,21 @@ import '@zag-js/dismissable';
5
5
  import '@zag-js/popper';
6
6
 
7
7
  declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): {
8
+ /**
9
+ * Whether the popover is portalled
10
+ */
8
11
  portalled: boolean;
12
+ /**
13
+ * Whether the popover is open
14
+ */
9
15
  isOpen: boolean;
16
+ /**
17
+ * Function to open the popover
18
+ */
10
19
  open(): void;
20
+ /**
21
+ * Function to close the popover
22
+ */
11
23
  close(): void;
12
24
  arrowProps: T["element"];
13
25
  arrowTipProps: T["element"];