@zag-js/popover 0.1.3 → 0.1.4

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
@@ -606,6 +606,10 @@ var dom = {
606
606
  return (_a = ctx.doc) != null ? _a : document;
607
607
  },
608
608
  getActiveEl: (ctx) => dom.getDoc(ctx).activeElement,
609
+ getRootNode: (ctx) => {
610
+ var _a;
611
+ return (_a = ctx.rootNode) != null ? _a : dom.getDoc(ctx);
612
+ },
609
613
  getAnchorId: (ctx) => {
610
614
  var _a, _b;
611
615
  return (_b = (_a = ctx.ids) == null ? void 0 : _a.anchor) != null ? _b : `popover:${ctx.uid}:anchor`;
@@ -632,12 +636,12 @@ var dom = {
632
636
  var _a, _b;
633
637
  return (_b = (_a = ctx.ids) == null ? void 0 : _a.closeBtn) != null ? _b : `popover:${ctx.uid}:close-button`;
634
638
  },
635
- getAnchorEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getAnchorId(ctx)),
636
- getTriggerEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getTriggerId(ctx)),
637
- getContentEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getContentId(ctx)),
638
- getPositionerEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getPositionerId(ctx)),
639
- getTitleEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getTitleId(ctx)),
640
- getDescriptionEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getDescriptionId(ctx)),
639
+ getAnchorEl: (ctx) => dom.getRootNode(ctx).getElementById(dom.getAnchorId(ctx)),
640
+ getTriggerEl: (ctx) => dom.getRootNode(ctx).getElementById(dom.getTriggerId(ctx)),
641
+ getContentEl: (ctx) => dom.getRootNode(ctx).getElementById(dom.getContentId(ctx)),
642
+ getPositionerEl: (ctx) => dom.getRootNode(ctx).getElementById(dom.getPositionerId(ctx)),
643
+ getTitleEl: (ctx) => dom.getRootNode(ctx).getElementById(dom.getTitleId(ctx)),
644
+ getDescriptionEl: (ctx) => dom.getRootNode(ctx).getElementById(dom.getDescriptionId(ctx)),
641
645
  getFocusableEls: (ctx) => getFocusables(dom.getContentEl(ctx)),
642
646
  getFirstFocusableEl: (ctx) => dom.getFocusableEls(ctx)[0],
643
647
  getDocTabbableEls: (ctx) => getTabbables(cast(dom.getDoc(ctx))),
@@ -658,7 +662,8 @@ function connect(state, send, normalize = normalizeProp) {
658
662
  const isOpen = state.matches("open");
659
663
  const pointerdownNode = state.context.pointerdownNode;
660
664
  const popperStyles = getPlacementStyles({
661
- measured: !!state.context.isPlacementComplete
665
+ measured: !!state.context.isPlacementComplete,
666
+ placement: state.context.currentPlacement
662
667
  });
663
668
  return {
664
669
  portalled: state.context.currentPortalled,
@@ -942,6 +947,8 @@ function machine(ctx = {}) {
942
947
  setupDocument(ctx2, evt) {
943
948
  if (evt.doc)
944
949
  ctx2.doc = ref(evt.doc);
950
+ if (evt.root)
951
+ ctx2.rootNode = ref(evt.root);
945
952
  ctx2.uid = evt.id;
946
953
  },
947
954
  clearPointerDown(ctx2) {