@underverse-ui/underverse 2.0.24 → 2.0.25

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.cjs CHANGED
@@ -4696,7 +4696,8 @@ var init_DropdownMenu = __esm({
4696
4696
  openOnHover = false,
4697
4697
  hoverCloseDelay = 120,
4698
4698
  items,
4699
- borderMode
4699
+ borderMode,
4700
+ getPortalContainer
4700
4701
  }) => {
4701
4702
  const [internalOpen, setInternalOpen] = (0, import_react17.useState)(false);
4702
4703
  const open = isOpen !== void 0 ? isOpen : internalOpen;
@@ -4929,6 +4930,7 @@ var init_DropdownMenu = __esm({
4929
4930
  placement,
4930
4931
  disabled,
4931
4932
  borderMode: resolvedBorderMode,
4933
+ getPortalContainer,
4932
4934
  contentClassName: cn("p-1", contentClassName),
4933
4935
  children: menuBody
4934
4936
  }
@@ -4989,7 +4991,7 @@ var init_DropdownMenu = __esm({
4989
4991
  );
4990
4992
  };
4991
4993
  DropdownMenuSeparator = ({ className }) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: cn("h-px bg-border my-1", className) });
4992
- DropdownMenuSub = ({ label, icon: Icon, disabled, borderMode, children }) => {
4994
+ DropdownMenuSub = ({ label, icon: Icon, disabled, borderMode, getPortalContainer, children }) => {
4993
4995
  const globalConfig = useUnderverseUIConfig();
4994
4996
  const resolvedBorderMode = borderMode ?? globalConfig.dropdownMenu?.borderMode ?? globalConfig.borderMode;
4995
4997
  return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
@@ -5017,11 +5019,21 @@ var init_DropdownMenu = __esm({
5017
5019
  ),
5018
5020
  placement: "right",
5019
5021
  openOnHover: true,
5022
+ getPortalContainer,
5020
5023
  children
5021
5024
  }
5022
5025
  );
5023
5026
  };
5024
- SelectDropdown = ({ options, value, onChange, placeholder = "Select...", className, borderMode, size = "md" }) => {
5027
+ SelectDropdown = ({
5028
+ options,
5029
+ value,
5030
+ onChange,
5031
+ placeholder = "Select...",
5032
+ className,
5033
+ borderMode,
5034
+ size = "md",
5035
+ getPortalContainer
5036
+ }) => {
5025
5037
  const globalConfig = useUnderverseUIConfig();
5026
5038
  const resolvedBorderMode = borderMode ?? globalConfig.dropdownMenu?.borderMode ?? globalConfig.borderMode;
5027
5039
  return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
@@ -5049,7 +5061,8 @@ var init_DropdownMenu = __esm({
5049
5061
  label: option,
5050
5062
  onClick: () => onChange(option)
5051
5063
  })),
5052
- borderMode: resolvedBorderMode
5064
+ borderMode: resolvedBorderMode,
5065
+ getPortalContainer
5053
5066
  }
5054
5067
  );
5055
5068
  };
@@ -13508,7 +13521,11 @@ init_cn();
13508
13521
  init_GlobalI18nContext();
13509
13522
  var import_lucide_react10 = require("lucide-react");
13510
13523
  init_UnderverseConfigContext();
13524
+ init_portal_context();
13511
13525
  var import_jsx_runtime28 = require("react/jsx-runtime");
13526
+ function setDocumentBodyStyles(ownerDocument, styles) {
13527
+ Object.assign(ownerDocument.body.style, styles);
13528
+ }
13512
13529
  var sizeStyles4 = {
13513
13530
  sm: {
13514
13531
  right: "w-75",
@@ -13588,7 +13605,8 @@ var Sheet = ({
13588
13605
  resizable = false,
13589
13606
  minSize = 280,
13590
13607
  maxSize,
13591
- onResize
13608
+ onResize,
13609
+ getPortalContainer
13592
13610
  }) => {
13593
13611
  const gi18n = useGlobalI18n();
13594
13612
  const [mounted, setMounted] = React26.useState(false);
@@ -13598,6 +13616,7 @@ var Sheet = ({
13598
13616
  const [sheetSize, setSheetSize] = React26.useState(null);
13599
13617
  const sheetRef = React26.useRef(null);
13600
13618
  const resizeStateRef = React26.useRef(null);
13619
+ const portalContainer = mounted ? resolveUEditorPortalContainer(getPortalContainer) : null;
13601
13620
  const isHorizontalSheet = side === "left" || side === "right";
13602
13621
  const canResize = resizable && size !== "full";
13603
13622
  React26.useEffect(() => {
@@ -13605,31 +13624,33 @@ var Sheet = ({
13605
13624
  }, []);
13606
13625
  React26.useEffect(() => {
13607
13626
  if (!closeOnEscape) return;
13627
+ const portalDocument = portalContainer?.ownerDocument;
13608
13628
  const handleEscape = (e) => {
13609
13629
  if (e.key === "Escape" && open) {
13610
13630
  onOpenChange(false);
13611
13631
  }
13612
13632
  };
13613
- document.addEventListener("keydown", handleEscape);
13614
- return () => document.removeEventListener("keydown", handleEscape);
13615
- }, [open, closeOnEscape, onOpenChange]);
13633
+ if (!portalDocument) return;
13634
+ portalDocument.addEventListener("keydown", handleEscape);
13635
+ return () => portalDocument.removeEventListener("keydown", handleEscape);
13636
+ }, [open, closeOnEscape, onOpenChange, portalContainer]);
13616
13637
  React26.useEffect(() => {
13617
- if (open) {
13618
- document.body.style.overflow = "hidden";
13619
- } else {
13620
- document.body.style.overflow = "unset";
13621
- }
13638
+ const portalDocument = portalContainer?.ownerDocument;
13639
+ if (!portalDocument || !open) return;
13640
+ const body = portalDocument.body;
13641
+ const previousOverflow = body.style.overflow;
13642
+ setDocumentBodyStyles(portalDocument, { overflow: "hidden" });
13622
13643
  return () => {
13623
- document.body.style.overflow = "unset";
13644
+ setDocumentBodyStyles(portalDocument, { overflow: previousOverflow });
13624
13645
  };
13625
- }, [open]);
13646
+ }, [open, portalContainer]);
13626
13647
  React26.useEffect(() => {
13648
+ const portalWindow = portalContainer?.ownerDocument.defaultView;
13627
13649
  if (open) {
13628
13650
  setIsVisible(true);
13629
13651
  setIsAnimating(true);
13630
- requestAnimationFrame(() => {
13631
- setIsAnimating(false);
13632
- });
13652
+ if (portalWindow) portalWindow.requestAnimationFrame(() => setIsAnimating(false));
13653
+ else setIsAnimating(false);
13633
13654
  } else if (isVisible) {
13634
13655
  setIsAnimating(true);
13635
13656
  const hideTimer = setTimeout(() => {
@@ -13637,7 +13658,7 @@ var Sheet = ({
13637
13658
  }, 300);
13638
13659
  return () => clearTimeout(hideTimer);
13639
13660
  }
13640
- }, [open, isVisible]);
13661
+ }, [open, isVisible, portalContainer]);
13641
13662
  const handleOverlayClick = (e) => {
13642
13663
  if (closeOnOutsideClick && e.target === e.currentTarget) {
13643
13664
  onOpenChange(false);
@@ -13647,7 +13668,8 @@ var Sheet = ({
13647
13668
  onOpenChange(false);
13648
13669
  };
13649
13670
  const clampResizeSize = React26.useCallback((nextSize) => {
13650
- const viewportSize = isHorizontalSheet ? window.innerWidth : window.innerHeight;
13671
+ const portalWindow = sheetRef.current?.ownerDocument.defaultView;
13672
+ const viewportSize = portalWindow ? isHorizontalSheet ? portalWindow.innerWidth : portalWindow.innerHeight : nextSize;
13651
13673
  const resolvedMaxSize = maxSize ?? Math.round(viewportSize * 0.9);
13652
13674
  return Math.min(Math.max(nextSize, minSize), resolvedMaxSize);
13653
13675
  }, [isHorizontalSheet, maxSize, minSize]);
@@ -13655,8 +13677,10 @@ var Sheet = ({
13655
13677
  if (!resizeStateRef.current) return;
13656
13678
  resizeStateRef.current = null;
13657
13679
  setIsResizing(false);
13658
- document.body.style.cursor = "";
13659
- document.body.style.userSelect = "";
13680
+ const portalDocument = sheetRef.current?.ownerDocument;
13681
+ if (portalDocument) {
13682
+ setDocumentBodyStyles(portalDocument, { cursor: "", userSelect: "" });
13683
+ }
13660
13684
  }, []);
13661
13685
  const handleResizePointerMove = React26.useCallback((event) => {
13662
13686
  const resizeState = resizeStateRef.current;
@@ -13673,13 +13697,15 @@ var Sheet = ({
13673
13697
  }, [endResize]);
13674
13698
  React26.useEffect(() => {
13675
13699
  if (!isResizing) return void 0;
13676
- window.addEventListener("pointermove", handleResizePointerMove);
13677
- window.addEventListener("pointerup", handleResizePointerUp);
13678
- window.addEventListener("pointercancel", handleResizePointerUp);
13700
+ const portalWindow = sheetRef.current?.ownerDocument.defaultView;
13701
+ if (!portalWindow) return;
13702
+ portalWindow.addEventListener("pointermove", handleResizePointerMove);
13703
+ portalWindow.addEventListener("pointerup", handleResizePointerUp);
13704
+ portalWindow.addEventListener("pointercancel", handleResizePointerUp);
13679
13705
  return () => {
13680
- window.removeEventListener("pointermove", handleResizePointerMove);
13681
- window.removeEventListener("pointerup", handleResizePointerUp);
13682
- window.removeEventListener("pointercancel", handleResizePointerUp);
13706
+ portalWindow.removeEventListener("pointermove", handleResizePointerMove);
13707
+ portalWindow.removeEventListener("pointerup", handleResizePointerUp);
13708
+ portalWindow.removeEventListener("pointercancel", handleResizePointerUp);
13683
13709
  };
13684
13710
  }, [handleResizePointerMove, handleResizePointerUp, isResizing]);
13685
13711
  React26.useEffect(() => {
@@ -13698,8 +13724,13 @@ var Sheet = ({
13698
13724
  };
13699
13725
  setIsResizing(true);
13700
13726
  event.currentTarget.setPointerCapture(event.pointerId);
13701
- document.body.style.cursor = isHorizontalSheet ? "col-resize" : "row-resize";
13702
- document.body.style.userSelect = "none";
13727
+ const portalDocument = event.currentTarget.ownerDocument;
13728
+ if (portalDocument) {
13729
+ setDocumentBodyStyles(portalDocument, {
13730
+ cursor: isHorizontalSheet ? "col-resize" : "row-resize",
13731
+ userSelect: "none"
13732
+ });
13733
+ }
13703
13734
  event.preventDefault();
13704
13735
  event.stopPropagation();
13705
13736
  };
@@ -13786,7 +13817,7 @@ var Sheet = ({
13786
13817
  }
13787
13818
  )
13788
13819
  ] });
13789
- return typeof window !== "undefined" ? (0, import_react_dom4.createPortal)(sheetContent, document.body) : null;
13820
+ return portalContainer ? (0, import_react_dom4.createPortal)(sheetContent, portalContainer) : null;
13790
13821
  };
13791
13822
  var Drawer = ({ placement = "right", ...props }) => {
13792
13823
  return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Sheet, { ...props, side: placement, variant: "overlay" });
@@ -15857,7 +15888,8 @@ var DatePicker = ({
15857
15888
  disablePastDates = false,
15858
15889
  minDate,
15859
15890
  maxDate,
15860
- borderMode
15891
+ borderMode,
15892
+ getPortalContainer
15861
15893
  }) => {
15862
15894
  const size = requestedSize === "xs" ? "sm" : requestedSize === "xl" ? "lg" : requestedSize;
15863
15895
  const t = useSmartTranslations("DatePicker");
@@ -16348,6 +16380,7 @@ var DatePicker = ({
16348
16380
  /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
16349
16381
  Popover,
16350
16382
  {
16383
+ getPortalContainer,
16351
16384
  open: isOpen,
16352
16385
  onOpenChange: setIsOpen,
16353
16386
  contentProps: { id: panelId },
@@ -16490,7 +16523,8 @@ var DateRangePicker = ({
16490
16523
  maxDate,
16491
16524
  size: requestedSize = "md",
16492
16525
  disabled = false,
16493
- borderMode
16526
+ borderMode,
16527
+ getPortalContainer
16494
16528
  }) => {
16495
16529
  const size = requestedSize === "xs" ? "sm" : requestedSize === "xl" ? "lg" : requestedSize;
16496
16530
  const locale = useSmartLocale();
@@ -17109,6 +17143,7 @@ var DateRangePicker = ({
17109
17143
  /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
17110
17144
  Popover,
17111
17145
  {
17146
+ getPortalContainer,
17112
17147
  open: isOpen,
17113
17148
  onOpenChange: setIsOpen,
17114
17149
  contentProps: { id: panelId },
@@ -17197,7 +17232,7 @@ var DateRangePicker = ({
17197
17232
  effectiveError && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: "text-xs text-destructive", children: effectiveError })
17198
17233
  ] });
17199
17234
  };
17200
- var CompactDatePicker = ({ value, onChange, className }) => {
17235
+ var CompactDatePicker = ({ value, onChange, className, getPortalContainer }) => {
17201
17236
  return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
17202
17237
  DatePicker,
17203
17238
  {
@@ -17205,7 +17240,8 @@ var CompactDatePicker = ({ value, onChange, className }) => {
17205
17240
  onChange,
17206
17241
  size: "sm",
17207
17242
  className: cn("max-w-56", className),
17208
- placeholder: "Date"
17243
+ placeholder: "Date",
17244
+ getPortalContainer
17209
17245
  }
17210
17246
  );
17211
17247
  };
@@ -17527,7 +17563,8 @@ var LunarDatePicker = ({
17527
17563
  disablePastDates = false,
17528
17564
  minDate,
17529
17565
  maxDate,
17530
- borderMode
17566
+ borderMode,
17567
+ getPortalContainer
17531
17568
  }) => {
17532
17569
  const size = requestedSize === "xs" ? "sm" : requestedSize === "xl" ? "lg" : requestedSize;
17533
17570
  const globalConfig = useUnderverseUIConfig();
@@ -18056,6 +18093,7 @@ var LunarDatePicker = ({
18056
18093
  /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
18057
18094
  Popover,
18058
18095
  {
18096
+ getPortalContainer,
18059
18097
  open: isOpen,
18060
18098
  onOpenChange: setIsOpen,
18061
18099
  contentProps: { id: panelId },
@@ -18204,7 +18242,8 @@ var LunarDateRangePicker = ({
18204
18242
  maxDate,
18205
18243
  size: requestedSize = "md",
18206
18244
  disabled = false,
18207
- borderMode
18245
+ borderMode,
18246
+ getPortalContainer
18208
18247
  }) => {
18209
18248
  const size = requestedSize === "xs" ? "sm" : requestedSize === "xl" ? "lg" : requestedSize;
18210
18249
  const locale = useSmartLocale();
@@ -18687,6 +18726,7 @@ var LunarDateRangePicker = ({
18687
18726
  /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(
18688
18727
  Popover,
18689
18728
  {
18729
+ getPortalContainer,
18690
18730
  open: isOpen,
18691
18731
  onOpenChange: setIsOpen,
18692
18732
  contentProps: { id: panelId },
@@ -19250,6 +19290,7 @@ function MonthYearPicker({
19250
19290
  columnLabels = { month: "Month", year: "Year" },
19251
19291
  className,
19252
19292
  borderMode,
19293
+ getPortalContainer,
19253
19294
  ...rest
19254
19295
  }) {
19255
19296
  const size = requestedSize === "xs" ? "sm" : requestedSize === "xl" ? "lg" : requestedSize;
@@ -19635,6 +19676,7 @@ function MonthYearPicker({
19635
19676
  /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
19636
19677
  Popover,
19637
19678
  {
19679
+ getPortalContainer,
19638
19680
  trigger,
19639
19681
  open,
19640
19682
  onOpenChange: handleOpenChange,
@@ -20794,6 +20836,7 @@ function TimePicker({
20794
20836
  onClose,
20795
20837
  className,
20796
20838
  borderMode,
20839
+ getPortalContainer,
20797
20840
  ...rest
20798
20841
  }) {
20799
20842
  const size = requestedSize === "xs" ? "sm" : requestedSize === "xl" ? "lg" : requestedSize;
@@ -21574,6 +21617,7 @@ function TimePicker({
21574
21617
  /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
21575
21618
  Popover,
21576
21619
  {
21620
+ getPortalContainer,
21577
21621
  trigger,
21578
21622
  open,
21579
21623
  onOpenChange: handleOpenChange,
@@ -21630,7 +21674,8 @@ var DateTimePicker = ({
21630
21674
  doneLabel,
21631
21675
  clearLabel,
21632
21676
  size: requestedSize = "md",
21633
- borderMode
21677
+ borderMode,
21678
+ getPortalContainer
21634
21679
  }) => {
21635
21680
  const size = requestedSize === "xs" ? "sm" : requestedSize === "xl" ? "lg" : requestedSize;
21636
21681
  const globalConfig = useUnderverseUIConfig();
@@ -21822,6 +21867,7 @@ var DateTimePicker = ({
21822
21867
  /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
21823
21868
  Popover,
21824
21869
  {
21870
+ getPortalContainer,
21825
21871
  open,
21826
21872
  onOpenChange: setOpen,
21827
21873
  contentProps: { id: panelId },
@@ -22544,6 +22590,7 @@ function CalendarTimelineHeader(props) {
22544
22590
  sizeConfig,
22545
22591
  navigate,
22546
22592
  now,
22593
+ getPortalContainer,
22547
22594
  onApplyDateTime,
22548
22595
  setView,
22549
22596
  effectiveResourceColumnWidth,
@@ -22635,6 +22682,7 @@ function CalendarTimelineHeader(props) {
22635
22682
  /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
22636
22683
  Popover,
22637
22684
  {
22685
+ getPortalContainer,
22638
22686
  open: todayOpen,
22639
22687
  onOpenChange: setTodayOpen,
22640
22688
  placement: "bottom-start",
@@ -22685,6 +22733,7 @@ function CalendarTimelineHeader(props) {
22685
22733
  /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
22686
22734
  TimePicker,
22687
22735
  {
22736
+ getPortalContainer,
22688
22737
  variant: "inline",
22689
22738
  value: getTimeString(tempDate),
22690
22739
  onChange: handleTimeChange,
@@ -23417,6 +23466,7 @@ function CalendarTimeline({
23417
23466
  workHours,
23418
23467
  maxLanesPerRow = 3,
23419
23468
  now,
23469
+ getPortalContainer,
23420
23470
  renderResource,
23421
23471
  renderGroup,
23422
23472
  renderEvent,
@@ -24451,7 +24501,8 @@ function CalendarTimeline({
24451
24501
  canResizeColumn,
24452
24502
  beginResizeColumn,
24453
24503
  headerRef,
24454
- slotHeaderNodes
24504
+ slotHeaderNodes,
24505
+ getPortalContainer
24455
24506
  }
24456
24507
  );
24457
24508
  const layoutsByResource = useLayoutsByResource({
@@ -24779,6 +24830,7 @@ function CalendarTimeline({
24779
24830
  onOpenChange: setEventSheetOpen,
24780
24831
  side: "right",
24781
24832
  size: eventSheetSize,
24833
+ getPortalContainer,
24782
24834
  overlayOpacity: eventSheetOverlayOpacity,
24783
24835
  title: selectedEvent.title ?? "Event",
24784
24836
  description: selectedTimeText || void 0,
@@ -24808,6 +24860,7 @@ function CalendarTimeline({
24808
24860
  onOpenChange: setCreateOpen,
24809
24861
  side: "right",
24810
24862
  size: "md",
24863
+ getPortalContainer,
24811
24864
  title: l.createEventTitle,
24812
24865
  description: activeView === "day" ? l.day : activeView === "week" ? l.week : l.month,
24813
24866
  children: /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "space-y-4", children: [
@@ -24819,18 +24872,19 @@ function CalendarTimeline({
24819
24872
  options: resourceOptions,
24820
24873
  value: createResourceId,
24821
24874
  onChange: (v) => setCreateResourceId(v),
24822
- placeholder: l.resource
24875
+ placeholder: l.resource,
24876
+ getPortalContainer
24823
24877
  }
24824
24878
  )
24825
24879
  ] }),
24826
24880
  /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "grid grid-cols-2 gap-3", children: [
24827
24881
  /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "space-y-2", children: [
24828
24882
  /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "text-xs text-muted-foreground", children: l.start }),
24829
- /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Combobox, { options: createStartOptions, value: createStartIdx, onChange: (v) => setCreateStartIdx(Number(v)), placeholder: l.start })
24883
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Combobox, { options: createStartOptions, value: createStartIdx, onChange: (v) => setCreateStartIdx(Number(v)), placeholder: l.start, getPortalContainer })
24830
24884
  ] }),
24831
24885
  /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "space-y-2", children: [
24832
24886
  /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "text-xs text-muted-foreground", children: l.end }),
24833
- /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Combobox, { options: createEndOptions, value: createEndIdx, onChange: (v) => setCreateEndIdx(Number(v)), placeholder: l.end })
24887
+ /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Combobox, { options: createEndOptions, value: createEndIdx, onChange: (v) => setCreateEndIdx(Number(v)), placeholder: l.end, getPortalContainer })
24834
24888
  ] })
24835
24889
  ] }),
24836
24890
  /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex items-center justify-end gap-2 pt-2", children: [
@@ -24924,7 +24978,8 @@ var MultiCombobox = ({
24924
24978
  searchDebounceMs = 0,
24925
24979
  minSearchLength = 0,
24926
24980
  maxInitialOptions,
24927
- showSearchPromptWhenEmptyQuery = false
24981
+ showSearchPromptWhenEmptyQuery = false,
24982
+ getPortalContainer
24928
24983
  }) => {
24929
24984
  const globalConfig = useUnderverseUIConfig();
24930
24985
  const resolvedBorderMode = borderMode ?? globalConfig.borderMode ?? "full";
@@ -25481,6 +25536,7 @@ var MultiCombobox = ({
25481
25536
  /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
25482
25537
  Popover,
25483
25538
  {
25539
+ getPortalContainer,
25484
25540
  open,
25485
25541
  onOpenChange: setOpen,
25486
25542
  trigger: triggerButton,
@@ -26989,7 +27045,8 @@ function CategoryTreeSelect(props) {
26989
27045
  showTreeLines = true,
26990
27046
  renderItemActions,
26991
27047
  singleSelect = false,
26992
- borderMode
27048
+ borderMode,
27049
+ getPortalContainer
26993
27050
  } = props;
26994
27051
  const globalConfig = useUnderverseUIConfig();
26995
27052
  const resolvedBorderMode = borderMode ?? globalConfig.input?.borderMode ?? globalConfig.borderMode ?? "full";
@@ -27679,6 +27736,7 @@ function CategoryTreeSelect(props) {
27679
27736
  /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
27680
27737
  Popover,
27681
27738
  {
27739
+ getPortalContainer,
27682
27740
  open: isOpen,
27683
27741
  onOpenChange: handleOpenChange,
27684
27742
  disabled,
@@ -30327,6 +30385,7 @@ function ColorPicker({
30327
30385
  showHarmony = false,
30328
30386
  maxRecent = 8,
30329
30387
  borderMode,
30388
+ getPortalContainer,
30330
30389
  ...rest
30331
30390
  }) {
30332
30391
  const globalConfig = useUnderverseUIConfig();
@@ -30464,6 +30523,7 @@ function ColorPicker({
30464
30523
  return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("div", { className: cn("inline-block w-full", className), ...rest, children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
30465
30524
  Popover,
30466
30525
  {
30526
+ getPortalContainer,
30467
30527
  trigger,
30468
30528
  open,
30469
30529
  onOpenChange: setOpen,
@@ -31687,7 +31747,8 @@ function DataTableHeader({
31687
31747
  getStickyHeaderCellStyle,
31688
31748
  sortByLabel,
31689
31749
  t,
31690
- columnColorGroups
31750
+ columnColorGroups,
31751
+ getPortalContainer
31691
31752
  }) {
31692
31753
  const gi18n = useGlobalI18n();
31693
31754
  const renderFilterControl = import_react34.default.useCallback(
@@ -31730,6 +31791,7 @@ function DataTableHeader({
31730
31791
  return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
31731
31792
  DatePicker,
31732
31793
  {
31794
+ getPortalContainer,
31733
31795
  size,
31734
31796
  placeholder: col.filter.placeholder || `Select ${columnLabel}`,
31735
31797
  value: filters[key] || null,
@@ -31742,7 +31804,7 @@ function DataTableHeader({
31742
31804
  }
31743
31805
  return null;
31744
31806
  },
31745
- [filters, setCurPage, setFilters, size]
31807
+ [filters, getPortalContainer, setCurPage, setFilters, size]
31746
31808
  );
31747
31809
  const renderHeaderContent = import_react34.default.useCallback(
31748
31810
  (col, isLeaf) => {
@@ -31847,6 +31909,7 @@ function DataTableHeader({
31847
31909
  const filterContent = col.filter ? /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
31848
31910
  Popover,
31849
31911
  {
31912
+ getPortalContainer,
31850
31913
  placement: "bottom-start",
31851
31914
  trigger: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("span", { className: "inline-flex", children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
31852
31915
  Tooltip,
@@ -31910,6 +31973,7 @@ function DataTableHeader({
31910
31973
  },
31911
31974
  [
31912
31975
  filters,
31976
+ getPortalContainer,
31913
31977
  gi18n,
31914
31978
  headerAlign,
31915
31979
  headerMinHeightClass,
@@ -32264,7 +32328,8 @@ function DataTableToolbar({
32264
32328
  labels,
32265
32329
  t,
32266
32330
  columnColorGroups,
32267
- defaultVisibleKeys
32331
+ defaultVisibleKeys,
32332
+ getPortalContainer
32268
32333
  }) {
32269
32334
  const controlButtonSize = size === "lg" ? "md" : "sm";
32270
32335
  const controlButtonClass = size === "sm" ? "h-7 px-2 text-xs" : size === "lg" ? "h-9 px-3 text-sm" : "h-8 px-2";
@@ -32288,7 +32353,8 @@ function DataTableToolbar({
32288
32353
  { label: labels?.compact || t("compact"), onClick: () => setDensity("compact") },
32289
32354
  { label: labels?.normal || t("normal"), onClick: () => setDensity("normal") },
32290
32355
  { label: labels?.comfortable || t("comfortable"), onClick: () => setDensity("comfortable") }
32291
- ]
32356
+ ],
32357
+ getPortalContainer
32292
32358
  }
32293
32359
  ),
32294
32360
  enableColumnVisibilityToggle && /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
@@ -32306,6 +32372,7 @@ function DataTableToolbar({
32306
32372
  ) }),
32307
32373
  labels?.columns || t("columns")
32308
32374
  ] }),
32375
+ getPortalContainer,
32309
32376
  children: [
32310
32377
  /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("div", { className: "flex items-center gap-2 px-2 py-1.5 mb-1", children: [
32311
32378
  /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Button_default, { variant: "outline", size: "sm", className: "h-7 text-xs flex-1", onClick: handleSelectAll, children: labels?.selectAll || t("selectAll") || "Select All" }),
@@ -32362,7 +32429,8 @@ function DataTableToolbar({
32362
32429
  { label: labels?.alignLeft || t("alignLeft"), onClick: () => setHeaderAlign("left") },
32363
32430
  { label: labels?.alignCenter || t("alignCenter"), onClick: () => setHeaderAlign("center") },
32364
32431
  { label: labels?.alignRight || t("alignRight"), onClick: () => setHeaderAlign("right") }
32365
- ]
32432
+ ],
32433
+ getPortalContainer
32366
32434
  }
32367
32435
  ),
32368
32436
  toolbar
@@ -32857,6 +32925,7 @@ function DataTable({
32857
32925
  labels,
32858
32926
  columnColorGroups,
32859
32927
  borderMode,
32928
+ getPortalContainer,
32860
32929
  paginationVariant = "default"
32861
32930
  }) {
32862
32931
  const t = useSmartTranslations("Common");
@@ -33012,7 +33081,8 @@ function DataTable({
33012
33081
  labels,
33013
33082
  t,
33014
33083
  columnColorGroups,
33015
- defaultVisibleKeys
33084
+ defaultVisibleKeys,
33085
+ getPortalContainer
33016
33086
  }
33017
33087
  ),
33018
33088
  /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
@@ -33064,7 +33134,8 @@ function DataTable({
33064
33134
  getStickyHeaderCellStyle,
33065
33135
  sortByLabel: labels?.sortBy,
33066
33136
  t,
33067
- columnColorGroups
33137
+ columnColorGroups,
33138
+ getPortalContainer
33068
33139
  }
33069
33140
  ) }),
33070
33141
  /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
@@ -33628,17 +33699,19 @@ init_cn();
33628
33699
  var import_react44 = require("react");
33629
33700
  var import_react_dom6 = require("react-dom");
33630
33701
  init_useHydrated();
33702
+ init_portal_context();
33631
33703
  var import_jsx_runtime77 = require("react/jsx-runtime");
33632
33704
  function ThemeToggleHeadless({
33633
33705
  theme,
33634
33706
  onChange,
33635
33707
  labels,
33636
- className
33708
+ className,
33709
+ getPortalContainer
33637
33710
  }) {
33638
33711
  const [isOpen, setIsOpen] = (0, import_react44.useState)(false);
33639
33712
  const isHydrated = useHydrated();
33640
- const triggerRef = (0, import_react44.useRef)(null);
33641
33713
  const [dropdownPosition, setDropdownPosition] = (0, import_react44.useState)(null);
33714
+ const [portalContainer, setPortalContainer] = (0, import_react44.useState)(null);
33642
33715
  const themes = [
33643
33716
  { value: "light", label: labels?.light ?? "Light", icon: import_lucide_react40.Sun },
33644
33717
  { value: "dark", label: labels?.dark ?? "Dark", icon: import_lucide_react40.Moon },
@@ -33646,15 +33719,19 @@ function ThemeToggleHeadless({
33646
33719
  ];
33647
33720
  const current = isHydrated ? themes.find((t) => t.value === theme) || themes[2] : themes[2];
33648
33721
  const CurrentIcon = current.icon;
33649
- const calculatePosition = () => {
33650
- const rect = triggerRef.current?.getBoundingClientRect();
33651
- if (!rect) return null;
33652
- const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
33653
- const scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
33722
+ const prepareOpen = (trigger) => {
33723
+ const rect = trigger.getBoundingClientRect();
33724
+ const ownerDocument = trigger.ownerDocument;
33725
+ const ownerWindow = ownerDocument?.defaultView;
33726
+ if (!ownerWindow) return;
33727
+ const scrollTop = ownerWindow.pageYOffset || ownerDocument.documentElement.scrollTop;
33728
+ const scrollLeft = ownerWindow.pageXOffset || ownerDocument.documentElement.scrollLeft;
33654
33729
  const width = 192;
33655
33730
  const left = rect.right + scrollLeft - width;
33656
33731
  const top = rect.bottom + scrollTop + 8;
33657
- return { top, left, width };
33732
+ const requestedContainer = resolveUEditorPortalContainer(getPortalContainer, void 0, ownerDocument);
33733
+ setDropdownPosition({ top, left, width });
33734
+ setPortalContainer(requestedContainer?.ownerDocument === ownerDocument ? requestedContainer : ownerDocument.body);
33658
33735
  };
33659
33736
  return /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)("div", { className: cn("relative", className), children: [
33660
33737
  /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
@@ -33662,13 +33739,9 @@ function ThemeToggleHeadless({
33662
33739
  {
33663
33740
  variant: "ghost",
33664
33741
  size: "icon",
33665
- ref: triggerRef,
33666
- onClick: () => {
33742
+ onClick: (event) => {
33667
33743
  const next = !isOpen;
33668
- if (next) {
33669
- const pos = calculatePosition();
33670
- if (pos) setDropdownPosition(pos);
33671
- }
33744
+ if (next) prepareOpen(event.currentTarget);
33672
33745
  setIsOpen(next);
33673
33746
  },
33674
33747
  className: "bg-muted hover:bg-accent",
@@ -33679,8 +33752,8 @@ function ThemeToggleHeadless({
33679
33752
  }
33680
33753
  ),
33681
33754
  isOpen && /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(import_jsx_runtime77.Fragment, { children: [
33682
- typeof window !== "undefined" && (0, import_react_dom6.createPortal)(/* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", { className: "fixed inset-0 z-[99998]", onClick: () => setIsOpen(false) }), document.body),
33683
- typeof window !== "undefined" && dropdownPosition && (0, import_react_dom6.createPortal)(
33755
+ portalContainer && (0, import_react_dom6.createPortal)(/* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", { className: "fixed inset-0 z-[99998]", onClick: () => setIsOpen(false) }), portalContainer),
33756
+ portalContainer && dropdownPosition && (0, import_react_dom6.createPortal)(
33684
33757
  /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
33685
33758
  "div",
33686
33759
  {
@@ -33720,7 +33793,7 @@ function ThemeToggleHeadless({
33720
33793
  ] })
33721
33794
  }
33722
33795
  ),
33723
- document.body
33796
+ portalContainer
33724
33797
  )
33725
33798
  ] })
33726
33799
  ] });
@@ -33731,27 +33804,33 @@ var import_react45 = require("react");
33731
33804
  var import_react_dom7 = require("react-dom");
33732
33805
  var import_lucide_react41 = require("lucide-react");
33733
33806
  init_cn();
33807
+ init_portal_context();
33734
33808
  var import_jsx_runtime78 = require("react/jsx-runtime");
33735
33809
  function LanguageSwitcherHeadless({
33736
33810
  locales,
33737
33811
  currentLocale,
33738
33812
  onSwitch,
33739
33813
  labels,
33740
- className
33814
+ className,
33815
+ getPortalContainer
33741
33816
  }) {
33742
33817
  const [isOpen, setIsOpen] = (0, import_react45.useState)(false);
33743
33818
  const [dropdownPosition, setDropdownPosition] = (0, import_react45.useState)(null);
33744
- const triggerButtonRef = (0, import_react45.useRef)(null);
33819
+ const [portalContainer, setPortalContainer] = (0, import_react45.useState)(null);
33745
33820
  const currentLanguage = locales.find((l) => l.code === currentLocale) || locales[0];
33746
- const calculatePosition = () => {
33747
- const rect = triggerButtonRef.current?.getBoundingClientRect();
33748
- if (!rect) return null;
33749
- const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
33750
- const scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
33821
+ const prepareOpen = (trigger) => {
33822
+ const rect = trigger.getBoundingClientRect();
33823
+ const ownerDocument = trigger.ownerDocument;
33824
+ const ownerWindow = ownerDocument?.defaultView;
33825
+ if (!ownerWindow) return;
33826
+ const scrollTop = ownerWindow.pageYOffset || ownerDocument.documentElement.scrollTop;
33827
+ const scrollLeft = ownerWindow.pageXOffset || ownerDocument.documentElement.scrollLeft;
33751
33828
  const width = 192;
33752
33829
  const left = rect.right + scrollLeft - width;
33753
33830
  const top = rect.bottom + scrollTop + 8;
33754
- return { top, left, width };
33831
+ const requestedContainer = resolveUEditorPortalContainer(getPortalContainer, void 0, ownerDocument);
33832
+ setDropdownPosition({ top, left, width });
33833
+ setPortalContainer(requestedContainer?.ownerDocument === ownerDocument ? requestedContainer : ownerDocument.body);
33755
33834
  };
33756
33835
  return /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)("div", { className: cn("relative", className), children: [
33757
33836
  /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
@@ -33759,13 +33838,9 @@ function LanguageSwitcherHeadless({
33759
33838
  {
33760
33839
  variant: "ghost",
33761
33840
  size: "icon",
33762
- ref: triggerButtonRef,
33763
- onClick: () => {
33841
+ onClick: (event) => {
33764
33842
  const next = !isOpen;
33765
- if (next) {
33766
- const pos = calculatePosition();
33767
- if (pos) setDropdownPosition(pos);
33768
- }
33843
+ if (next) prepareOpen(event.currentTarget);
33769
33844
  setIsOpen(next);
33770
33845
  },
33771
33846
  className: "bg-muted hover:bg-accent",
@@ -33777,8 +33852,8 @@ function LanguageSwitcherHeadless({
33777
33852
  }
33778
33853
  ),
33779
33854
  isOpen && /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(import_jsx_runtime78.Fragment, { children: [
33780
- typeof window !== "undefined" && (0, import_react_dom7.createPortal)(/* @__PURE__ */ (0, import_jsx_runtime78.jsx)("div", { className: "fixed inset-0 z-[99998]", onClick: () => setIsOpen(false) }), document.body),
33781
- typeof window !== "undefined" && dropdownPosition && (0, import_react_dom7.createPortal)(
33855
+ portalContainer && (0, import_react_dom7.createPortal)(/* @__PURE__ */ (0, import_jsx_runtime78.jsx)("div", { className: "fixed inset-0 z-[99998]", onClick: () => setIsOpen(false) }), portalContainer),
33856
+ portalContainer && dropdownPosition && (0, import_react_dom7.createPortal)(
33782
33857
  /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
33783
33858
  "div",
33784
33859
  {
@@ -33811,7 +33886,7 @@ function LanguageSwitcherHeadless({
33811
33886
  ] })
33812
33887
  }
33813
33888
  ),
33814
- document.body
33889
+ portalContainer
33815
33890
  )
33816
33891
  ] })
33817
33892
  ] });