@zag-js/popover 0.0.0-dev-20220704111810 → 0.0.0-dev-20220706194607

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.js CHANGED
@@ -46,22 +46,14 @@ module.exports = __toCommonJS(src_exports);
46
46
  var dataAttr = (guard) => {
47
47
  return guard ? "" : void 0;
48
48
  };
49
- function isWindow(value) {
50
- return (value == null ? void 0 : value.toString()) === "[object Window]";
51
- }
49
+ var runIfFn = (v, ...a) => {
50
+ const res = typeof v === "function" ? v(...a) : v;
51
+ return res != null ? res : void 0;
52
+ };
53
+ var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
52
54
  function isFrame(element) {
53
55
  return element.localName === "iframe";
54
56
  }
55
- function getDocument(el) {
56
- var _a;
57
- if (isWindow(el))
58
- return el.document;
59
- return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
60
- }
61
- function getEventTarget(event) {
62
- var _a, _b;
63
- return (_b = (_a = event.composedPath) == null ? void 0 : _a.call(event)[0]) != null ? _b : event.target;
64
- }
65
57
  function contains(parent, child) {
66
58
  if (!parent)
67
59
  return false;
@@ -75,6 +67,7 @@ function isVisible(el) {
75
67
  return false;
76
68
  return el.offsetWidth > 0 || el.offsetHeight > 0 || el.getClientRects().length > 0;
77
69
  }
70
+ var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey;
78
71
  function hasNegativeTabIndex(element) {
79
72
  const tabIndex = parseInt(element.getAttribute("tabindex") || "0", 10);
80
73
  return tabIndex < 0;
@@ -133,11 +126,6 @@ function getLastTabbable(container, includeContainer) {
133
126
  const elements = getTabbables(container, includeContainer);
134
127
  return elements[elements.length - 1] || null;
135
128
  }
136
- var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
137
- var runIfFn = (v, ...a) => {
138
- const res = typeof v === "function" ? v(...a) : v;
139
- return res != null ? res : void 0;
140
- };
141
129
  var isRef = (v) => hasProp(v, "current");
142
130
  function addDomEvent(target, eventName, handler, options) {
143
131
  const node = isRef(target) ? target.current : runIfFn(target);
@@ -186,7 +174,6 @@ function nextIndex(v, idx, opts = {}) {
186
174
  function next(v, idx, opts = {}) {
187
175
  return v[nextIndex(v, idx, opts)];
188
176
  }
189
- var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey;
190
177
  var runIfFn2 = (v, ...a) => {
191
178
  const res = typeof v === "function" ? v(...a) : v;
192
179
  return res != null ? res : void 0;
@@ -344,12 +331,26 @@ var import_aria_hidden = require("@zag-js/aria-hidden");
344
331
  var import_core = require("@zag-js/core");
345
332
 
346
333
  // ../../utilities/interact-outside/dist/index.mjs
347
- function isWindow2(value) {
334
+ var runIfFn3 = (v, ...a) => {
335
+ const res = typeof v === "function" ? v(...a) : v;
336
+ return res != null ? res : void 0;
337
+ };
338
+ var hasProp2 = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
339
+ var isDom = () => typeof window !== "undefined";
340
+ function getPlatform() {
341
+ var _a;
342
+ const agent = navigator.userAgentData;
343
+ return (_a = agent == null ? void 0 : agent.platform) != null ? _a : navigator.platform;
344
+ }
345
+ var pt = (v) => isDom() && v.test(getPlatform());
346
+ var isTouchDevice = () => isDom() && !!navigator.maxTouchPoints;
347
+ var isMac = () => pt(/^Mac/) && !isTouchDevice;
348
+ function isWindow(value) {
348
349
  return (value == null ? void 0 : value.toString()) === "[object Window]";
349
350
  }
350
- function getDocument2(el) {
351
+ function getDocument(el) {
351
352
  var _a;
352
- if (isWindow2(el))
353
+ if (isWindow(el))
353
354
  return el.document;
354
355
  return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
355
356
  }
@@ -357,7 +358,7 @@ function getWindow(el) {
357
358
  var _a;
358
359
  return (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
359
360
  }
360
- function getEventTarget2(event) {
361
+ function getEventTarget(event) {
361
362
  var _a, _b;
362
363
  return (_b = (_a = event.composedPath) == null ? void 0 : _a.call(event)[0]) != null ? _b : event.target;
363
364
  }
@@ -374,6 +375,10 @@ function isVisible2(el) {
374
375
  return false;
375
376
  return el.offsetWidth > 0 || el.offsetHeight > 0 || el.getClientRects().length > 0;
376
377
  }
378
+ var isContextMenuEvent = (e) => {
379
+ return e.button === 2 || isCtrlKey(e) && e.button === 0;
380
+ };
381
+ var isCtrlKey = (v) => isMac() ? v.metaKey && !v.ctrlKey : v.ctrlKey && !v.metaKey;
377
382
  function fireCustomEvent(el, type, init) {
378
383
  if (!el)
379
384
  return;
@@ -386,11 +391,6 @@ function isFocusable2(element) {
386
391
  return false;
387
392
  return element.matches(focusableSelector2) && isVisible2(element);
388
393
  }
389
- var hasProp2 = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
390
- var runIfFn3 = (v, ...a) => {
391
- const res = typeof v === "function" ? v(...a) : v;
392
- return res != null ? res : void 0;
393
- };
394
394
  var isRef2 = (v) => hasProp2(v, "current");
395
395
  function addDomEvent2(target, eventName, handler, options) {
396
396
  const node = isRef2(target) ? target.current : runIfFn3(target);
@@ -399,29 +399,16 @@ function addDomEvent2(target, eventName, handler, options) {
399
399
  node == null ? void 0 : node.removeEventListener(eventName, handler, options);
400
400
  };
401
401
  }
402
- var isDom = () => typeof window !== "undefined";
403
- function getPlatform() {
404
- var _a;
405
- const agent = navigator.userAgentData;
406
- return (_a = agent == null ? void 0 : agent.platform) != null ? _a : navigator.platform;
407
- }
408
- var pt = (v) => isDom() && v.test(getPlatform());
409
- var isTouchDevice = () => isDom() && !!navigator.maxTouchPoints;
410
- var isMac = () => pt(/^Mac/) && !isTouchDevice;
411
- var isContextMenuEvent = (e) => {
412
- return e.button === 2 || isCtrlKey(e) && e.button === 0;
413
- };
414
- var isCtrlKey = (v) => isMac() ? v.metaKey && !v.ctrlKey : v.ctrlKey && !v.metaKey;
415
402
  var POINTER_OUTSIDE_EVENT = "pointerdown.outside";
416
403
  var FOCUS_OUTSIDE_EVENT = "focus.outside";
417
404
  function trackInteractOutside(node, options) {
418
405
  const { exclude, onFocusOutside, onPointerDownOutside } = options;
419
406
  if (!node)
420
407
  return;
421
- const doc = getDocument2(node);
408
+ const doc = getDocument(node);
422
409
  const win = getWindow(node);
423
410
  function isEventOutside(event) {
424
- const target = getEventTarget2(event);
411
+ const target = getEventTarget(event);
425
412
  if (!(target instanceof win.HTMLElement)) {
426
413
  return false;
427
414
  }
@@ -447,7 +434,7 @@ function trackInteractOutside(node, options) {
447
434
  detail: {
448
435
  originalEvent: event,
449
436
  contextmenu: isContextMenuEvent(event),
450
- focusable: isFocusable2(getEventTarget2(event))
437
+ focusable: isFocusable2(getEventTarget(event))
451
438
  }
452
439
  });
453
440
  }
@@ -475,7 +462,7 @@ function trackInteractOutside(node, options) {
475
462
  detail: {
476
463
  originalEvent: event,
477
464
  contextmenu: false,
478
- focusable: isFocusable2(getEventTarget2(event))
465
+ focusable: isFocusable2(getEventTarget(event))
479
466
  }
480
467
  });
481
468
  }
@@ -488,16 +475,48 @@ function trackInteractOutside(node, options) {
488
475
  };
489
476
  }
490
477
 
491
- // ../../utilities/dismissable/src/escape-keydown.ts
478
+ // ../../utilities/dismissable/dist/index.mjs
479
+ var runIfFn4 = (v, ...a) => {
480
+ const res = typeof v === "function" ? v(...a) : v;
481
+ return res != null ? res : void 0;
482
+ };
483
+ var hasProp3 = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
484
+ function isWindow2(value) {
485
+ return (value == null ? void 0 : value.toString()) === "[object Window]";
486
+ }
487
+ function getDocument2(el) {
488
+ var _a;
489
+ if (isWindow2(el))
490
+ return el.document;
491
+ return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
492
+ }
493
+ function getEventTarget2(event) {
494
+ var _a, _b;
495
+ return (_b = (_a = event.composedPath) == null ? void 0 : _a.call(event)[0]) != null ? _b : event.target;
496
+ }
497
+ function contains3(parent, child) {
498
+ if (!parent)
499
+ return false;
500
+ return parent === child || isHTMLElement3(parent) && isHTMLElement3(child) && parent.contains(child);
501
+ }
502
+ function isHTMLElement3(v) {
503
+ return typeof v === "object" && (v == null ? void 0 : v.nodeType) === Node.ELEMENT_NODE && typeof (v == null ? void 0 : v.nodeName) === "string";
504
+ }
505
+ var isRef3 = (v) => hasProp3(v, "current");
506
+ function addDomEvent3(target, eventName, handler, options) {
507
+ const node = isRef3(target) ? target.current : runIfFn4(target);
508
+ node == null ? void 0 : node.addEventListener(eventName, handler, options);
509
+ return () => {
510
+ node == null ? void 0 : node.removeEventListener(eventName, handler, options);
511
+ };
512
+ }
492
513
  function trackEscapeKeydown(fn) {
493
514
  const handleKeyDown = (event) => {
494
515
  if (event.key === "Escape")
495
516
  fn == null ? void 0 : fn(event);
496
517
  };
497
- return addDomEvent(document, "keydown", handleKeyDown);
518
+ return addDomEvent3(document, "keydown", handleKeyDown);
498
519
  }
499
-
500
- // ../../utilities/dismissable/src/layer-stack.ts
501
520
  var layerStack = {
502
521
  layers: [],
503
522
  branches: [],
@@ -527,10 +546,10 @@ var layerStack = {
527
546
  return this.layers.slice(this.indexOf(node));
528
547
  },
529
548
  isInChildLayer(node, target) {
530
- return this.getChildLayers(node).some((layer) => contains(layer.node, target));
549
+ return this.getChildLayers(node).some((layer) => contains3(layer.node, target));
531
550
  },
532
551
  isInBranch(target) {
533
- return [...this.branches].some((branch) => contains(branch, target));
552
+ return [...this.branches].some((branch) => contains3(branch, target));
534
553
  },
535
554
  add(layer) {
536
555
  this.layers.push(layer);
@@ -561,8 +580,6 @@ var layerStack = {
561
580
  this.remove(this.layers[0].node);
562
581
  }
563
582
  };
564
-
565
- // ../../utilities/dismissable/src/pointer-event-outside.ts
566
583
  var originalBodyPointerEvents;
567
584
  function assignPointerEventToLayers() {
568
585
  layerStack.layers.forEach(({ node }) => {
@@ -574,7 +591,7 @@ function clearPointerEvent(node) {
574
591
  }
575
592
  var DATA_ATTR = "data-inert";
576
593
  function disablePointerEventsOutside(node) {
577
- const doc = getDocument(node);
594
+ const doc = getDocument2(node);
578
595
  if (layerStack.hasPointerBlockingLayer() && !doc.body.hasAttribute(DATA_ATTR)) {
579
596
  originalBodyPointerEvents = document.body.style.pointerEvents;
580
597
  doc.body.style.pointerEvents = "none";
@@ -589,8 +606,6 @@ function disablePointerEventsOutside(node) {
589
606
  doc.body.removeAttribute("style");
590
607
  };
591
608
  }
592
-
593
- // ../../utilities/dismissable/src/dismissable-layer.ts
594
609
  function trackDismissableElement(node, options) {
595
610
  if (!node)
596
611
  return;
@@ -600,7 +615,7 @@ function trackDismissableElement(node, options) {
600
615
  assignPointerEventToLayers();
601
616
  function onPointerDownOutside(event) {
602
617
  var _a, _b;
603
- const target = getEventTarget(event.detail.originalEvent);
618
+ const target = getEventTarget2(event.detail.originalEvent);
604
619
  if (layerStack.isBelowPointerBlockingLayer(node) || layerStack.isInBranch(target))
605
620
  return;
606
621
  (_a = options.onPointerDownOutside) == null ? void 0 : _a.call(options, event);
@@ -611,7 +626,7 @@ function trackDismissableElement(node, options) {
611
626
  }
612
627
  function onFocusOutside(event) {
613
628
  var _a, _b;
614
- const target = getEventTarget(event.detail.originalEvent);
629
+ const target = getEventTarget2(event.detail.originalEvent);
615
630
  if (layerStack.isInBranch(target))
616
631
  return;
617
632
  (_a = options.onFocusOutside) == null ? void 0 : _a.call(options, event);
@@ -633,7 +648,7 @@ function trackDismissableElement(node, options) {
633
648
  function exclude(target) {
634
649
  const containers = typeof excludeContainers === "function" ? excludeContainers() : excludeContainers;
635
650
  const inContainers = Array.isArray(containers) ? containers : [containers];
636
- return inContainers.some((node2) => contains(node2, target)) || layerStack.isInChildLayer(node, target);
651
+ return inContainers.some((node2) => contains3(node2, target)) || layerStack.isInChildLayer(node, target);
637
652
  }
638
653
  const cleanups = [
639
654
  pointerBlocking ? disablePointerEventsOutside(node) : void 0,
package/dist/index.mjs CHANGED
@@ -22,22 +22,14 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
22
22
  var dataAttr = (guard) => {
23
23
  return guard ? "" : void 0;
24
24
  };
25
- function isWindow(value) {
26
- return (value == null ? void 0 : value.toString()) === "[object Window]";
27
- }
25
+ var runIfFn = (v, ...a) => {
26
+ const res = typeof v === "function" ? v(...a) : v;
27
+ return res != null ? res : void 0;
28
+ };
29
+ var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
28
30
  function isFrame(element) {
29
31
  return element.localName === "iframe";
30
32
  }
31
- function getDocument(el) {
32
- var _a;
33
- if (isWindow(el))
34
- return el.document;
35
- return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
36
- }
37
- function getEventTarget(event) {
38
- var _a, _b;
39
- return (_b = (_a = event.composedPath) == null ? void 0 : _a.call(event)[0]) != null ? _b : event.target;
40
- }
41
33
  function contains(parent, child) {
42
34
  if (!parent)
43
35
  return false;
@@ -51,6 +43,7 @@ function isVisible(el) {
51
43
  return false;
52
44
  return el.offsetWidth > 0 || el.offsetHeight > 0 || el.getClientRects().length > 0;
53
45
  }
46
+ var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey;
54
47
  function hasNegativeTabIndex(element) {
55
48
  const tabIndex = parseInt(element.getAttribute("tabindex") || "0", 10);
56
49
  return tabIndex < 0;
@@ -109,11 +102,6 @@ function getLastTabbable(container, includeContainer) {
109
102
  const elements = getTabbables(container, includeContainer);
110
103
  return elements[elements.length - 1] || null;
111
104
  }
112
- var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
113
- var runIfFn = (v, ...a) => {
114
- const res = typeof v === "function" ? v(...a) : v;
115
- return res != null ? res : void 0;
116
- };
117
105
  var isRef = (v) => hasProp(v, "current");
118
106
  function addDomEvent(target, eventName, handler, options) {
119
107
  const node = isRef(target) ? target.current : runIfFn(target);
@@ -162,7 +150,6 @@ function nextIndex(v, idx, opts = {}) {
162
150
  function next(v, idx, opts = {}) {
163
151
  return v[nextIndex(v, idx, opts)];
164
152
  }
165
- var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey;
166
153
  var runIfFn2 = (v, ...a) => {
167
154
  const res = typeof v === "function" ? v(...a) : v;
168
155
  return res != null ? res : void 0;
@@ -320,12 +307,26 @@ import { ariaHidden } from "@zag-js/aria-hidden";
320
307
  import { createMachine, guards, ref } from "@zag-js/core";
321
308
 
322
309
  // ../../utilities/interact-outside/dist/index.mjs
323
- function isWindow2(value) {
310
+ var runIfFn3 = (v, ...a) => {
311
+ const res = typeof v === "function" ? v(...a) : v;
312
+ return res != null ? res : void 0;
313
+ };
314
+ var hasProp2 = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
315
+ var isDom = () => typeof window !== "undefined";
316
+ function getPlatform() {
317
+ var _a;
318
+ const agent = navigator.userAgentData;
319
+ return (_a = agent == null ? void 0 : agent.platform) != null ? _a : navigator.platform;
320
+ }
321
+ var pt = (v) => isDom() && v.test(getPlatform());
322
+ var isTouchDevice = () => isDom() && !!navigator.maxTouchPoints;
323
+ var isMac = () => pt(/^Mac/) && !isTouchDevice;
324
+ function isWindow(value) {
324
325
  return (value == null ? void 0 : value.toString()) === "[object Window]";
325
326
  }
326
- function getDocument2(el) {
327
+ function getDocument(el) {
327
328
  var _a;
328
- if (isWindow2(el))
329
+ if (isWindow(el))
329
330
  return el.document;
330
331
  return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
331
332
  }
@@ -333,7 +334,7 @@ function getWindow(el) {
333
334
  var _a;
334
335
  return (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
335
336
  }
336
- function getEventTarget2(event) {
337
+ function getEventTarget(event) {
337
338
  var _a, _b;
338
339
  return (_b = (_a = event.composedPath) == null ? void 0 : _a.call(event)[0]) != null ? _b : event.target;
339
340
  }
@@ -350,6 +351,10 @@ function isVisible2(el) {
350
351
  return false;
351
352
  return el.offsetWidth > 0 || el.offsetHeight > 0 || el.getClientRects().length > 0;
352
353
  }
354
+ var isContextMenuEvent = (e) => {
355
+ return e.button === 2 || isCtrlKey(e) && e.button === 0;
356
+ };
357
+ var isCtrlKey = (v) => isMac() ? v.metaKey && !v.ctrlKey : v.ctrlKey && !v.metaKey;
353
358
  function fireCustomEvent(el, type, init) {
354
359
  if (!el)
355
360
  return;
@@ -362,11 +367,6 @@ function isFocusable2(element) {
362
367
  return false;
363
368
  return element.matches(focusableSelector2) && isVisible2(element);
364
369
  }
365
- var hasProp2 = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
366
- var runIfFn3 = (v, ...a) => {
367
- const res = typeof v === "function" ? v(...a) : v;
368
- return res != null ? res : void 0;
369
- };
370
370
  var isRef2 = (v) => hasProp2(v, "current");
371
371
  function addDomEvent2(target, eventName, handler, options) {
372
372
  const node = isRef2(target) ? target.current : runIfFn3(target);
@@ -375,29 +375,16 @@ function addDomEvent2(target, eventName, handler, options) {
375
375
  node == null ? void 0 : node.removeEventListener(eventName, handler, options);
376
376
  };
377
377
  }
378
- var isDom = () => typeof window !== "undefined";
379
- function getPlatform() {
380
- var _a;
381
- const agent = navigator.userAgentData;
382
- return (_a = agent == null ? void 0 : agent.platform) != null ? _a : navigator.platform;
383
- }
384
- var pt = (v) => isDom() && v.test(getPlatform());
385
- var isTouchDevice = () => isDom() && !!navigator.maxTouchPoints;
386
- var isMac = () => pt(/^Mac/) && !isTouchDevice;
387
- var isContextMenuEvent = (e) => {
388
- return e.button === 2 || isCtrlKey(e) && e.button === 0;
389
- };
390
- var isCtrlKey = (v) => isMac() ? v.metaKey && !v.ctrlKey : v.ctrlKey && !v.metaKey;
391
378
  var POINTER_OUTSIDE_EVENT = "pointerdown.outside";
392
379
  var FOCUS_OUTSIDE_EVENT = "focus.outside";
393
380
  function trackInteractOutside(node, options) {
394
381
  const { exclude, onFocusOutside, onPointerDownOutside } = options;
395
382
  if (!node)
396
383
  return;
397
- const doc = getDocument2(node);
384
+ const doc = getDocument(node);
398
385
  const win = getWindow(node);
399
386
  function isEventOutside(event) {
400
- const target = getEventTarget2(event);
387
+ const target = getEventTarget(event);
401
388
  if (!(target instanceof win.HTMLElement)) {
402
389
  return false;
403
390
  }
@@ -423,7 +410,7 @@ function trackInteractOutside(node, options) {
423
410
  detail: {
424
411
  originalEvent: event,
425
412
  contextmenu: isContextMenuEvent(event),
426
- focusable: isFocusable2(getEventTarget2(event))
413
+ focusable: isFocusable2(getEventTarget(event))
427
414
  }
428
415
  });
429
416
  }
@@ -451,7 +438,7 @@ function trackInteractOutside(node, options) {
451
438
  detail: {
452
439
  originalEvent: event,
453
440
  contextmenu: false,
454
- focusable: isFocusable2(getEventTarget2(event))
441
+ focusable: isFocusable2(getEventTarget(event))
455
442
  }
456
443
  });
457
444
  }
@@ -464,16 +451,48 @@ function trackInteractOutside(node, options) {
464
451
  };
465
452
  }
466
453
 
467
- // ../../utilities/dismissable/src/escape-keydown.ts
454
+ // ../../utilities/dismissable/dist/index.mjs
455
+ var runIfFn4 = (v, ...a) => {
456
+ const res = typeof v === "function" ? v(...a) : v;
457
+ return res != null ? res : void 0;
458
+ };
459
+ var hasProp3 = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
460
+ function isWindow2(value) {
461
+ return (value == null ? void 0 : value.toString()) === "[object Window]";
462
+ }
463
+ function getDocument2(el) {
464
+ var _a;
465
+ if (isWindow2(el))
466
+ return el.document;
467
+ return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
468
+ }
469
+ function getEventTarget2(event) {
470
+ var _a, _b;
471
+ return (_b = (_a = event.composedPath) == null ? void 0 : _a.call(event)[0]) != null ? _b : event.target;
472
+ }
473
+ function contains3(parent, child) {
474
+ if (!parent)
475
+ return false;
476
+ return parent === child || isHTMLElement3(parent) && isHTMLElement3(child) && parent.contains(child);
477
+ }
478
+ function isHTMLElement3(v) {
479
+ return typeof v === "object" && (v == null ? void 0 : v.nodeType) === Node.ELEMENT_NODE && typeof (v == null ? void 0 : v.nodeName) === "string";
480
+ }
481
+ var isRef3 = (v) => hasProp3(v, "current");
482
+ function addDomEvent3(target, eventName, handler, options) {
483
+ const node = isRef3(target) ? target.current : runIfFn4(target);
484
+ node == null ? void 0 : node.addEventListener(eventName, handler, options);
485
+ return () => {
486
+ node == null ? void 0 : node.removeEventListener(eventName, handler, options);
487
+ };
488
+ }
468
489
  function trackEscapeKeydown(fn) {
469
490
  const handleKeyDown = (event) => {
470
491
  if (event.key === "Escape")
471
492
  fn == null ? void 0 : fn(event);
472
493
  };
473
- return addDomEvent(document, "keydown", handleKeyDown);
494
+ return addDomEvent3(document, "keydown", handleKeyDown);
474
495
  }
475
-
476
- // ../../utilities/dismissable/src/layer-stack.ts
477
496
  var layerStack = {
478
497
  layers: [],
479
498
  branches: [],
@@ -503,10 +522,10 @@ var layerStack = {
503
522
  return this.layers.slice(this.indexOf(node));
504
523
  },
505
524
  isInChildLayer(node, target) {
506
- return this.getChildLayers(node).some((layer) => contains(layer.node, target));
525
+ return this.getChildLayers(node).some((layer) => contains3(layer.node, target));
507
526
  },
508
527
  isInBranch(target) {
509
- return [...this.branches].some((branch) => contains(branch, target));
528
+ return [...this.branches].some((branch) => contains3(branch, target));
510
529
  },
511
530
  add(layer) {
512
531
  this.layers.push(layer);
@@ -537,8 +556,6 @@ var layerStack = {
537
556
  this.remove(this.layers[0].node);
538
557
  }
539
558
  };
540
-
541
- // ../../utilities/dismissable/src/pointer-event-outside.ts
542
559
  var originalBodyPointerEvents;
543
560
  function assignPointerEventToLayers() {
544
561
  layerStack.layers.forEach(({ node }) => {
@@ -550,7 +567,7 @@ function clearPointerEvent(node) {
550
567
  }
551
568
  var DATA_ATTR = "data-inert";
552
569
  function disablePointerEventsOutside(node) {
553
- const doc = getDocument(node);
570
+ const doc = getDocument2(node);
554
571
  if (layerStack.hasPointerBlockingLayer() && !doc.body.hasAttribute(DATA_ATTR)) {
555
572
  originalBodyPointerEvents = document.body.style.pointerEvents;
556
573
  doc.body.style.pointerEvents = "none";
@@ -565,8 +582,6 @@ function disablePointerEventsOutside(node) {
565
582
  doc.body.removeAttribute("style");
566
583
  };
567
584
  }
568
-
569
- // ../../utilities/dismissable/src/dismissable-layer.ts
570
585
  function trackDismissableElement(node, options) {
571
586
  if (!node)
572
587
  return;
@@ -576,7 +591,7 @@ function trackDismissableElement(node, options) {
576
591
  assignPointerEventToLayers();
577
592
  function onPointerDownOutside(event) {
578
593
  var _a, _b;
579
- const target = getEventTarget(event.detail.originalEvent);
594
+ const target = getEventTarget2(event.detail.originalEvent);
580
595
  if (layerStack.isBelowPointerBlockingLayer(node) || layerStack.isInBranch(target))
581
596
  return;
582
597
  (_a = options.onPointerDownOutside) == null ? void 0 : _a.call(options, event);
@@ -587,7 +602,7 @@ function trackDismissableElement(node, options) {
587
602
  }
588
603
  function onFocusOutside(event) {
589
604
  var _a, _b;
590
- const target = getEventTarget(event.detail.originalEvent);
605
+ const target = getEventTarget2(event.detail.originalEvent);
591
606
  if (layerStack.isInBranch(target))
592
607
  return;
593
608
  (_a = options.onFocusOutside) == null ? void 0 : _a.call(options, event);
@@ -609,7 +624,7 @@ function trackDismissableElement(node, options) {
609
624
  function exclude(target) {
610
625
  const containers = typeof excludeContainers === "function" ? excludeContainers() : excludeContainers;
611
626
  const inContainers = Array.isArray(containers) ? containers : [containers];
612
- return inContainers.some((node2) => contains(node2, target)) || layerStack.isInChildLayer(node, target);
627
+ return inContainers.some((node2) => contains3(node2, target)) || layerStack.isInChildLayer(node, target);
613
628
  }
614
629
  const cleanups = [
615
630
  pointerBlocking ? disablePointerEventsOutside(node) : void 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/popover",
3
- "version": "0.0.0-dev-20220704111810",
3
+ "version": "0.0.0-dev-20220706194607",
4
4
  "description": "Core logic for the popover widget implemented as a state machine",
5
5
  "keywords": [
6
6
  "js",
@@ -30,11 +30,11 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "@zag-js/aria-hidden": "0.1.0",
33
- "@zag-js/core": "0.0.0-dev-20220704111810",
34
- "@zag-js/dom-utils": "0.0.0-dev-20220704111810",
35
- "@zag-js/popper": "0.0.0-dev-20220704111810",
36
- "@zag-js/remove-scroll": "0.1.0",
37
- "@zag-js/types": "0.0.0-dev-20220704111810",
33
+ "@zag-js/core": "0.0.0-dev-20220706194607",
34
+ "@zag-js/dom-utils": "0.0.0-dev-20220706194607",
35
+ "@zag-js/popper": "0.0.0-dev-20220706194607",
36
+ "@zag-js/remove-scroll": "0.0.0-dev-20220706194607",
37
+ "@zag-js/types": "0.0.0-dev-20220706194607",
38
38
  "@zag-js/utils": "0.1.2",
39
39
  "focus-trap": "6.9.4"
40
40
  },