@almadar/ui 6.19.0 → 6.21.0

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.
@@ -6505,6 +6505,36 @@ var init_resolve_render_bindings = __esm({
6505
6505
  evaluatorResolvedData = /* @__PURE__ */ new WeakSet();
6506
6506
  }
6507
6507
  });
6508
+
6509
+ // lib/portalRoot.ts
6510
+ function lastThemedElement(selector, portalRoot) {
6511
+ const matches = Array.from(document.querySelectorAll(selector)).filter(
6512
+ (el) => el !== document.documentElement && el !== portalRoot
6513
+ );
6514
+ return matches[matches.length - 1] ?? null;
6515
+ }
6516
+ function getOrCreatePortalRoot() {
6517
+ let root = document.getElementById("ui-slot-portal-root");
6518
+ if (!root) {
6519
+ root = document.createElement("div");
6520
+ root.id = "ui-slot-portal-root";
6521
+ root.style.position = "relative";
6522
+ root.style.zIndex = "9999";
6523
+ document.body.appendChild(root);
6524
+ }
6525
+ const themed = lastThemedElement('[data-theme*="-"]', root) ?? lastThemedElement("[data-theme]", root);
6526
+ if (themed) {
6527
+ const theme = themed.getAttribute("data-theme");
6528
+ if (theme && root.getAttribute("data-theme") !== theme) {
6529
+ root.setAttribute("data-theme", theme);
6530
+ }
6531
+ }
6532
+ return root;
6533
+ }
6534
+ var init_portalRoot = __esm({
6535
+ "lib/portalRoot.ts"() {
6536
+ }
6537
+ });
6508
6538
  var sizeClasses6, minWidthClasses, lookStyles2; exports.Modal = void 0;
6509
6539
  var init_Modal = __esm({
6510
6540
  "components/core/molecules/Modal.tsx"() {
@@ -6514,6 +6544,7 @@ var init_Modal = __esm({
6514
6544
  init_Dialog();
6515
6545
  init_Typography();
6516
6546
  init_cn();
6547
+ init_portalRoot();
6517
6548
  init_useEventBus();
6518
6549
  init_Presence();
6519
6550
  sizeClasses6 = {
@@ -6724,7 +6755,7 @@ var init_Modal = __esm({
6724
6755
  )
6725
6756
  }
6726
6757
  ),
6727
- document.body
6758
+ getOrCreatePortalRoot()
6728
6759
  );
6729
6760
  };
6730
6761
  exports.Modal.displayName = "Modal";
@@ -16298,6 +16329,7 @@ var init_StateMachineView = __esm({
16298
16329
  init_Icon();
16299
16330
  init_useEventBus();
16300
16331
  init_cn();
16332
+ init_portalRoot();
16301
16333
  StateNode = ({ state, config }) => {
16302
16334
  const { t } = hooks.useTranslate();
16303
16335
  const size = state.radius * 2;
@@ -16814,7 +16846,7 @@ var init_StateMachineView = __esm({
16814
16846
  )
16815
16847
  }
16816
16848
  ),
16817
- document.body
16849
+ getOrCreatePortalRoot()
16818
16850
  );
16819
16851
  };
16820
16852
  EntityBox = ({ entity, config }) => {
@@ -25293,7 +25325,7 @@ function SubMenu({
25293
25325
  })
25294
25326
  }
25295
25327
  );
25296
- return typeof document !== "undefined" ? reactDom.createPortal(panel, document.body) : panel;
25328
+ return typeof document !== "undefined" ? reactDom.createPortal(panel, getOrCreatePortalRoot()) : panel;
25297
25329
  }
25298
25330
  function MenuItemRow({
25299
25331
  item,
@@ -25380,6 +25412,7 @@ var init_Menu = __esm({
25380
25412
  init_Typography();
25381
25413
  init_Badge();
25382
25414
  init_cn();
25415
+ init_portalRoot();
25383
25416
  init_useEventBus();
25384
25417
  MENU_GAP = 4;
25385
25418
  menuContainerStyles = cn(
@@ -25516,7 +25549,7 @@ var init_Menu = __esm({
25516
25549
  ) : null;
25517
25550
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
25518
25551
  triggerElement,
25519
- panel && typeof document !== "undefined" ? reactDom.createPortal(panel, document.body) : panel
25552
+ panel && typeof document !== "undefined" ? reactDom.createPortal(panel, getOrCreatePortalRoot()) : panel
25520
25553
  ] });
25521
25554
  };
25522
25555
  exports.Menu.displayName = "Menu";
@@ -29571,6 +29604,7 @@ var init_Popover = __esm({
29571
29604
  init_Typography();
29572
29605
  init_Presence();
29573
29606
  init_cn();
29607
+ init_portalRoot();
29574
29608
  init_useTapReveal();
29575
29609
  arrowClasses = {
29576
29610
  top: "top-full left-1/2 -translate-x-1/2 border-t-white border-l-transparent border-r-transparent border-b-transparent",
@@ -29730,7 +29764,7 @@ var init_Popover = __esm({
29730
29764
  ) : null;
29731
29765
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
29732
29766
  triggerElement,
29733
- panel && typeof document !== "undefined" ? reactDom.createPortal(panel, document.body) : panel
29767
+ panel && typeof document !== "undefined" ? reactDom.createPortal(panel, getOrCreatePortalRoot()) : panel
29734
29768
  ] });
29735
29769
  };
29736
29770
  exports.Popover.displayName = "Popover";
@@ -29811,6 +29845,7 @@ var init_Coachmark = __esm({
29811
29845
  init_Button();
29812
29846
  init_Icon();
29813
29847
  init_cn();
29848
+ init_portalRoot();
29814
29849
  GAP = 10;
29815
29850
  EDGE = 8;
29816
29851
  exports.Coachmark = ({
@@ -29913,7 +29948,7 @@ var init_Coachmark = __esm({
29913
29948
  beacon,
29914
29949
  card
29915
29950
  ] }),
29916
- document.body
29951
+ getOrCreatePortalRoot()
29917
29952
  );
29918
29953
  };
29919
29954
  exports.Coachmark.displayName = "Coachmark";
@@ -29925,6 +29960,7 @@ var init_OnboardingSpotlight = __esm({
29925
29960
  "use client";
29926
29961
  init_Coachmark();
29927
29962
  init_cn();
29963
+ init_portalRoot();
29928
29964
  DIM = "fixed z-[45] bg-black/60";
29929
29965
  exports.OnboardingSpotlight = ({
29930
29966
  steps,
@@ -29952,7 +29988,7 @@ var init_OnboardingSpotlight = __esm({
29952
29988
  ] });
29953
29989
  })() : /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(DIM, "inset-0") });
29954
29990
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
29955
- reactDom.createPortal(backdrop, document.body),
29991
+ reactDom.createPortal(backdrop, getOrCreatePortalRoot()),
29956
29992
  /* @__PURE__ */ jsxRuntime.jsxs(
29957
29993
  exports.Coachmark,
29958
29994
  {
@@ -30486,6 +30522,7 @@ var init_Tooltip = __esm({
30486
30522
  "use client";
30487
30523
  init_Typography();
30488
30524
  init_cn();
30525
+ init_portalRoot();
30489
30526
  init_useTapReveal();
30490
30527
  TRIGGER_GAP2 = 8;
30491
30528
  arrowClasses2 = {
@@ -30591,7 +30628,7 @@ var init_Tooltip = __esm({
30591
30628
  ) : null;
30592
30629
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
30593
30630
  trigger,
30594
- typeof window !== "undefined" && tooltipContent ? reactDom.createPortal(tooltipContent, document.body) : tooltipContent
30631
+ typeof window !== "undefined" && tooltipContent ? reactDom.createPortal(tooltipContent, getOrCreatePortalRoot()) : tooltipContent
30595
30632
  ] });
30596
30633
  };
30597
30634
  exports.Tooltip.displayName = "Tooltip";
@@ -44508,6 +44545,7 @@ var init_GraphCanvas = __esm({
44508
44545
  "components/core/molecules/GraphCanvas.tsx"() {
44509
44546
  "use client";
44510
44547
  init_cn();
44548
+ init_portalRoot();
44511
44549
  init_atoms();
44512
44550
  init_Stack();
44513
44551
  init_LoadingState();
@@ -45219,7 +45257,7 @@ var init_GraphCanvas = __esm({
45219
45257
  children: hoveredObj?.label
45220
45258
  }
45221
45259
  ),
45222
- document.body
45260
+ getOrCreatePortalRoot()
45223
45261
  )
45224
45262
  ] }),
45225
45263
  groups.length > 1 && /* @__PURE__ */ jsxRuntime.jsx(exports.HStack, { gap: "md", className: "px-4 py-2 border-t border-border", wrap: true, children: groups.map((group, idx) => /* @__PURE__ */ jsxRuntime.jsxs(exports.HStack, { gap: "xs", align: "center", children: [
@@ -46609,6 +46647,7 @@ var init_DetailPanel = __esm({
46609
46647
  init_ErrorState();
46610
46648
  init_EmptyState();
46611
46649
  init_cn();
46650
+ init_portalRoot();
46612
46651
  init_format();
46613
46652
  init_getNestedValue();
46614
46653
  init_relationLabel();
@@ -47028,7 +47067,7 @@ var init_DetailPanel = __esm({
47028
47067
  return /* @__PURE__ */ jsxRuntime.jsx(exports.Box, { className, children: content });
47029
47068
  }
47030
47069
  const panel = /* @__PURE__ */ jsxRuntime.jsx(exports.Box, { className: cn("fixed inset-y-0 right-0 w-full max-w-2xl bg-card shadow-lg z-50 overflow-y-auto p-6", className), children: content });
47031
- return typeof document === "undefined" ? panel : reactDom.createPortal(panel, document.body);
47070
+ return typeof document === "undefined" ? panel : reactDom.createPortal(panel, getOrCreatePortalRoot());
47032
47071
  };
47033
47072
  exports.DetailPanel.displayName = "DetailPanel";
47034
47073
  }
@@ -53919,24 +53958,6 @@ function UISlotComponentInner({
53919
53958
  }
53920
53959
  );
53921
53960
  }
53922
- function getOrCreatePortalRoot() {
53923
- let root = document.getElementById("ui-slot-portal-root");
53924
- if (!root) {
53925
- root = document.createElement("div");
53926
- root.id = "ui-slot-portal-root";
53927
- root.style.position = "relative";
53928
- root.style.zIndex = "9999";
53929
- document.body.appendChild(root);
53930
- }
53931
- const themed = document.querySelector('[data-theme*="-"]') ?? document.querySelector("[data-theme]");
53932
- if (themed) {
53933
- const theme = themed.getAttribute("data-theme");
53934
- if (theme && root.getAttribute("data-theme") !== theme) {
53935
- root.setAttribute("data-theme", theme);
53936
- }
53937
- }
53938
- return root;
53939
- }
53940
53961
  function CompiledPortal({ slot, className, pattern, sourceTrait, children }) {
53941
53962
  const [portalRoot, setPortalRoot] = React79.useState(null);
53942
53963
  const slotsBus = context.useUISlots();
@@ -54559,6 +54580,7 @@ var init_UISlotRenderer = __esm({
54559
54580
  init_slot_types();
54560
54581
  init_cn();
54561
54582
  init_format();
54583
+ init_portalRoot();
54562
54584
  init_ErrorBoundary();
54563
54585
  init_Skeleton();
54564
54586
  init_renderer();
@@ -4965,7 +4965,7 @@ declare const Popover: React__default.FC<PopoverProps>;
4965
4965
  * Popover (uncontrolled, wraps its own trigger), a Coachmark is driven by
4966
4966
  * `open` and points at an element it does not own — a tab button, the persona
4967
4967
  * menu, a canvas node — resolved from a ref, a CSS selector, or a DOMRect.
4968
- * Portals to document.body so it escapes the canvas/preview transform contexts.
4968
+ * Portals into the shared portal root so it escapes the canvas/preview transform contexts.
4969
4969
  */
4970
4970
 
4971
4971
  type CoachmarkPlacement = "top" | "bottom" | "left" | "right";
@@ -4965,7 +4965,7 @@ declare const Popover: React__default.FC<PopoverProps>;
4965
4965
  * Popover (uncontrolled, wraps its own trigger), a Coachmark is driven by
4966
4966
  * `open` and points at an element it does not own — a tab button, the persona
4967
4967
  * menu, a canvas node — resolved from a ref, a CSS selector, or a DOMRect.
4968
- * Portals to document.body so it escapes the canvas/preview transform contexts.
4968
+ * Portals into the shared portal root so it escapes the canvas/preview transform contexts.
4969
4969
  */
4970
4970
 
4971
4971
  type CoachmarkPlacement = "top" | "bottom" | "left" | "right";
@@ -6430,6 +6430,36 @@ var init_resolve_render_bindings = __esm({
6430
6430
  evaluatorResolvedData = /* @__PURE__ */ new WeakSet();
6431
6431
  }
6432
6432
  });
6433
+
6434
+ // lib/portalRoot.ts
6435
+ function lastThemedElement(selector, portalRoot) {
6436
+ const matches = Array.from(document.querySelectorAll(selector)).filter(
6437
+ (el) => el !== document.documentElement && el !== portalRoot
6438
+ );
6439
+ return matches[matches.length - 1] ?? null;
6440
+ }
6441
+ function getOrCreatePortalRoot() {
6442
+ let root = document.getElementById("ui-slot-portal-root");
6443
+ if (!root) {
6444
+ root = document.createElement("div");
6445
+ root.id = "ui-slot-portal-root";
6446
+ root.style.position = "relative";
6447
+ root.style.zIndex = "9999";
6448
+ document.body.appendChild(root);
6449
+ }
6450
+ const themed = lastThemedElement('[data-theme*="-"]', root) ?? lastThemedElement("[data-theme]", root);
6451
+ if (themed) {
6452
+ const theme = themed.getAttribute("data-theme");
6453
+ if (theme && root.getAttribute("data-theme") !== theme) {
6454
+ root.setAttribute("data-theme", theme);
6455
+ }
6456
+ }
6457
+ return root;
6458
+ }
6459
+ var init_portalRoot = __esm({
6460
+ "lib/portalRoot.ts"() {
6461
+ }
6462
+ });
6433
6463
  var sizeClasses6, minWidthClasses, lookStyles2, Modal;
6434
6464
  var init_Modal = __esm({
6435
6465
  "components/core/molecules/Modal.tsx"() {
@@ -6439,6 +6469,7 @@ var init_Modal = __esm({
6439
6469
  init_Dialog();
6440
6470
  init_Typography();
6441
6471
  init_cn();
6472
+ init_portalRoot();
6442
6473
  init_useEventBus();
6443
6474
  init_Presence();
6444
6475
  sizeClasses6 = {
@@ -6649,7 +6680,7 @@ var init_Modal = __esm({
6649
6680
  )
6650
6681
  }
6651
6682
  ),
6652
- document.body
6683
+ getOrCreatePortalRoot()
6653
6684
  );
6654
6685
  };
6655
6686
  Modal.displayName = "Modal";
@@ -16223,6 +16254,7 @@ var init_StateMachineView = __esm({
16223
16254
  init_Icon();
16224
16255
  init_useEventBus();
16225
16256
  init_cn();
16257
+ init_portalRoot();
16226
16258
  StateNode = ({ state, config }) => {
16227
16259
  const { t } = useTranslate();
16228
16260
  const size = state.radius * 2;
@@ -16739,7 +16771,7 @@ var init_StateMachineView = __esm({
16739
16771
  )
16740
16772
  }
16741
16773
  ),
16742
- document.body
16774
+ getOrCreatePortalRoot()
16743
16775
  );
16744
16776
  };
16745
16777
  EntityBox = ({ entity, config }) => {
@@ -25218,7 +25250,7 @@ function SubMenu({
25218
25250
  })
25219
25251
  }
25220
25252
  );
25221
- return typeof document !== "undefined" ? createPortal(panel, document.body) : panel;
25253
+ return typeof document !== "undefined" ? createPortal(panel, getOrCreatePortalRoot()) : panel;
25222
25254
  }
25223
25255
  function MenuItemRow({
25224
25256
  item,
@@ -25305,6 +25337,7 @@ var init_Menu = __esm({
25305
25337
  init_Typography();
25306
25338
  init_Badge();
25307
25339
  init_cn();
25340
+ init_portalRoot();
25308
25341
  init_useEventBus();
25309
25342
  MENU_GAP = 4;
25310
25343
  menuContainerStyles = cn(
@@ -25441,7 +25474,7 @@ var init_Menu = __esm({
25441
25474
  ) : null;
25442
25475
  return /* @__PURE__ */ jsxs(Fragment, { children: [
25443
25476
  triggerElement,
25444
- panel && typeof document !== "undefined" ? createPortal(panel, document.body) : panel
25477
+ panel && typeof document !== "undefined" ? createPortal(panel, getOrCreatePortalRoot()) : panel
25445
25478
  ] });
25446
25479
  };
25447
25480
  Menu.displayName = "Menu";
@@ -29496,6 +29529,7 @@ var init_Popover = __esm({
29496
29529
  init_Typography();
29497
29530
  init_Presence();
29498
29531
  init_cn();
29532
+ init_portalRoot();
29499
29533
  init_useTapReveal();
29500
29534
  arrowClasses = {
29501
29535
  top: "top-full left-1/2 -translate-x-1/2 border-t-white border-l-transparent border-r-transparent border-b-transparent",
@@ -29655,7 +29689,7 @@ var init_Popover = __esm({
29655
29689
  ) : null;
29656
29690
  return /* @__PURE__ */ jsxs(Fragment, { children: [
29657
29691
  triggerElement,
29658
- panel && typeof document !== "undefined" ? createPortal(panel, document.body) : panel
29692
+ panel && typeof document !== "undefined" ? createPortal(panel, getOrCreatePortalRoot()) : panel
29659
29693
  ] });
29660
29694
  };
29661
29695
  Popover.displayName = "Popover";
@@ -29736,6 +29770,7 @@ var init_Coachmark = __esm({
29736
29770
  init_Button();
29737
29771
  init_Icon();
29738
29772
  init_cn();
29773
+ init_portalRoot();
29739
29774
  GAP = 10;
29740
29775
  EDGE = 8;
29741
29776
  Coachmark = ({
@@ -29838,7 +29873,7 @@ var init_Coachmark = __esm({
29838
29873
  beacon,
29839
29874
  card
29840
29875
  ] }),
29841
- document.body
29876
+ getOrCreatePortalRoot()
29842
29877
  );
29843
29878
  };
29844
29879
  Coachmark.displayName = "Coachmark";
@@ -29850,6 +29885,7 @@ var init_OnboardingSpotlight = __esm({
29850
29885
  "use client";
29851
29886
  init_Coachmark();
29852
29887
  init_cn();
29888
+ init_portalRoot();
29853
29889
  DIM = "fixed z-[45] bg-black/60";
29854
29890
  OnboardingSpotlight = ({
29855
29891
  steps,
@@ -29877,7 +29913,7 @@ var init_OnboardingSpotlight = __esm({
29877
29913
  ] });
29878
29914
  })() : /* @__PURE__ */ jsx("div", { className: cn(DIM, "inset-0") });
29879
29915
  return /* @__PURE__ */ jsxs(Fragment, { children: [
29880
- createPortal(backdrop, document.body),
29916
+ createPortal(backdrop, getOrCreatePortalRoot()),
29881
29917
  /* @__PURE__ */ jsxs(
29882
29918
  Coachmark,
29883
29919
  {
@@ -30411,6 +30447,7 @@ var init_Tooltip = __esm({
30411
30447
  "use client";
30412
30448
  init_Typography();
30413
30449
  init_cn();
30450
+ init_portalRoot();
30414
30451
  init_useTapReveal();
30415
30452
  TRIGGER_GAP2 = 8;
30416
30453
  arrowClasses2 = {
@@ -30516,7 +30553,7 @@ var init_Tooltip = __esm({
30516
30553
  ) : null;
30517
30554
  return /* @__PURE__ */ jsxs(Fragment, { children: [
30518
30555
  trigger,
30519
- typeof window !== "undefined" && tooltipContent ? createPortal(tooltipContent, document.body) : tooltipContent
30556
+ typeof window !== "undefined" && tooltipContent ? createPortal(tooltipContent, getOrCreatePortalRoot()) : tooltipContent
30520
30557
  ] });
30521
30558
  };
30522
30559
  Tooltip.displayName = "Tooltip";
@@ -44433,6 +44470,7 @@ var init_GraphCanvas = __esm({
44433
44470
  "components/core/molecules/GraphCanvas.tsx"() {
44434
44471
  "use client";
44435
44472
  init_cn();
44473
+ init_portalRoot();
44436
44474
  init_atoms();
44437
44475
  init_Stack();
44438
44476
  init_LoadingState();
@@ -45144,7 +45182,7 @@ var init_GraphCanvas = __esm({
45144
45182
  children: hoveredObj?.label
45145
45183
  }
45146
45184
  ),
45147
- document.body
45185
+ getOrCreatePortalRoot()
45148
45186
  )
45149
45187
  ] }),
45150
45188
  groups.length > 1 && /* @__PURE__ */ jsx(HStack, { gap: "md", className: "px-4 py-2 border-t border-border", wrap: true, children: groups.map((group, idx) => /* @__PURE__ */ jsxs(HStack, { gap: "xs", align: "center", children: [
@@ -46534,6 +46572,7 @@ var init_DetailPanel = __esm({
46534
46572
  init_ErrorState();
46535
46573
  init_EmptyState();
46536
46574
  init_cn();
46575
+ init_portalRoot();
46537
46576
  init_format();
46538
46577
  init_getNestedValue();
46539
46578
  init_relationLabel();
@@ -46953,7 +46992,7 @@ var init_DetailPanel = __esm({
46953
46992
  return /* @__PURE__ */ jsx(Box, { className, children: content });
46954
46993
  }
46955
46994
  const panel = /* @__PURE__ */ jsx(Box, { className: cn("fixed inset-y-0 right-0 w-full max-w-2xl bg-card shadow-lg z-50 overflow-y-auto p-6", className), children: content });
46956
- return typeof document === "undefined" ? panel : createPortal(panel, document.body);
46995
+ return typeof document === "undefined" ? panel : createPortal(panel, getOrCreatePortalRoot());
46957
46996
  };
46958
46997
  DetailPanel.displayName = "DetailPanel";
46959
46998
  }
@@ -53844,24 +53883,6 @@ function UISlotComponentInner({
53844
53883
  }
53845
53884
  );
53846
53885
  }
53847
- function getOrCreatePortalRoot() {
53848
- let root = document.getElementById("ui-slot-portal-root");
53849
- if (!root) {
53850
- root = document.createElement("div");
53851
- root.id = "ui-slot-portal-root";
53852
- root.style.position = "relative";
53853
- root.style.zIndex = "9999";
53854
- document.body.appendChild(root);
53855
- }
53856
- const themed = document.querySelector('[data-theme*="-"]') ?? document.querySelector("[data-theme]");
53857
- if (themed) {
53858
- const theme = themed.getAttribute("data-theme");
53859
- if (theme && root.getAttribute("data-theme") !== theme) {
53860
- root.setAttribute("data-theme", theme);
53861
- }
53862
- }
53863
- return root;
53864
- }
53865
53886
  function CompiledPortal({ slot, className, pattern, sourceTrait, children }) {
53866
53887
  const [portalRoot, setPortalRoot] = useState(null);
53867
53888
  const slotsBus = useUISlots();
@@ -54484,6 +54505,7 @@ var init_UISlotRenderer = __esm({
54484
54505
  init_slot_types();
54485
54506
  init_cn();
54486
54507
  init_format();
54508
+ init_portalRoot();
54487
54509
  init_ErrorBoundary();
54488
54510
  init_Skeleton();
54489
54511
  init_renderer();