@almadar/ui 6.20.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.
@@ -2176,6 +2176,36 @@ var init_Typography = __esm({
2176
2176
  Typography.displayName = "Typography";
2177
2177
  }
2178
2178
  });
2179
+
2180
+ // lib/portalRoot.ts
2181
+ function lastThemedElement(selector, portalRoot) {
2182
+ const matches = Array.from(document.querySelectorAll(selector)).filter(
2183
+ (el) => el !== document.documentElement && el !== portalRoot
2184
+ );
2185
+ return matches[matches.length - 1] ?? null;
2186
+ }
2187
+ function getOrCreatePortalRoot() {
2188
+ let root = document.getElementById("ui-slot-portal-root");
2189
+ if (!root) {
2190
+ root = document.createElement("div");
2191
+ root.id = "ui-slot-portal-root";
2192
+ root.style.position = "relative";
2193
+ root.style.zIndex = "9999";
2194
+ document.body.appendChild(root);
2195
+ }
2196
+ const themed = lastThemedElement('[data-theme*="-"]', root) ?? lastThemedElement("[data-theme]", root);
2197
+ if (themed) {
2198
+ const theme = themed.getAttribute("data-theme");
2199
+ if (theme && root.getAttribute("data-theme") !== theme) {
2200
+ root.setAttribute("data-theme", theme);
2201
+ }
2202
+ }
2203
+ return root;
2204
+ }
2205
+ var init_portalRoot = __esm({
2206
+ "lib/portalRoot.ts"() {
2207
+ }
2208
+ });
2179
2209
  function isMotionEnabled() {
2180
2210
  if (typeof document === "undefined") return true;
2181
2211
  if (motionEnabledCache !== null) return motionEnabledCache;
@@ -2256,6 +2286,7 @@ var init_Modal = __esm({
2256
2286
  init_Dialog();
2257
2287
  init_Typography();
2258
2288
  init_cn();
2289
+ init_portalRoot();
2259
2290
  init_useEventBus();
2260
2291
  init_Presence();
2261
2292
  sizeClasses2 = {
@@ -2466,7 +2497,7 @@ var init_Modal = __esm({
2466
2497
  )
2467
2498
  }
2468
2499
  ),
2469
- document.body
2500
+ getOrCreatePortalRoot()
2470
2501
  );
2471
2502
  };
2472
2503
  Modal.displayName = "Modal";
@@ -20532,6 +20563,7 @@ var init_StateMachineView = __esm({
20532
20563
  init_Icon();
20533
20564
  init_useEventBus();
20534
20565
  init_cn();
20566
+ init_portalRoot();
20535
20567
  StateNode2 = ({ state, config }) => {
20536
20568
  const { t } = hooks.useTranslate();
20537
20569
  const size = state.radius * 2;
@@ -21048,7 +21080,7 @@ var init_StateMachineView = __esm({
21048
21080
  )
21049
21081
  }
21050
21082
  ),
21051
- document.body
21083
+ getOrCreatePortalRoot()
21052
21084
  );
21053
21085
  };
21054
21086
  EntityBox = ({ entity, config }) => {
@@ -27608,7 +27640,7 @@ function SubMenu({
27608
27640
  })
27609
27641
  }
27610
27642
  );
27611
- return typeof document !== "undefined" ? reactDom.createPortal(panel, document.body) : panel;
27643
+ return typeof document !== "undefined" ? reactDom.createPortal(panel, getOrCreatePortalRoot()) : panel;
27612
27644
  }
27613
27645
  function MenuItemRow({
27614
27646
  item,
@@ -27695,6 +27727,7 @@ var init_Menu = __esm({
27695
27727
  init_Typography();
27696
27728
  init_Badge();
27697
27729
  init_cn();
27730
+ init_portalRoot();
27698
27731
  init_useEventBus();
27699
27732
  MENU_GAP = 4;
27700
27733
  menuContainerStyles = cn(
@@ -27831,7 +27864,7 @@ var init_Menu = __esm({
27831
27864
  ) : null;
27832
27865
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
27833
27866
  triggerElement,
27834
- panel && typeof document !== "undefined" ? reactDom.createPortal(panel, document.body) : panel
27867
+ panel && typeof document !== "undefined" ? reactDom.createPortal(panel, getOrCreatePortalRoot()) : panel
27835
27868
  ] });
27836
27869
  };
27837
27870
  Menu.displayName = "Menu";
@@ -31045,6 +31078,7 @@ var init_Popover = __esm({
31045
31078
  init_Typography();
31046
31079
  init_Presence();
31047
31080
  init_cn();
31081
+ init_portalRoot();
31048
31082
  init_useTapReveal();
31049
31083
  arrowClasses = {
31050
31084
  top: "top-full left-1/2 -translate-x-1/2 border-t-white border-l-transparent border-r-transparent border-b-transparent",
@@ -31204,7 +31238,7 @@ var init_Popover = __esm({
31204
31238
  ) : null;
31205
31239
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
31206
31240
  triggerElement,
31207
- panel && typeof document !== "undefined" ? reactDom.createPortal(panel, document.body) : panel
31241
+ panel && typeof document !== "undefined" ? reactDom.createPortal(panel, getOrCreatePortalRoot()) : panel
31208
31242
  ] });
31209
31243
  };
31210
31244
  Popover.displayName = "Popover";
@@ -31710,6 +31744,7 @@ var init_Tooltip = __esm({
31710
31744
  "use client";
31711
31745
  init_Typography();
31712
31746
  init_cn();
31747
+ init_portalRoot();
31713
31748
  init_useTapReveal();
31714
31749
  TRIGGER_GAP2 = 8;
31715
31750
  arrowClasses2 = {
@@ -31815,7 +31850,7 @@ var init_Tooltip = __esm({
31815
31850
  ) : null;
31816
31851
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
31817
31852
  trigger,
31818
- typeof window !== "undefined" && tooltipContent ? reactDom.createPortal(tooltipContent, document.body) : tooltipContent
31853
+ typeof window !== "undefined" && tooltipContent ? reactDom.createPortal(tooltipContent, getOrCreatePortalRoot()) : tooltipContent
31819
31854
  ] });
31820
31855
  };
31821
31856
  Tooltip.displayName = "Tooltip";
@@ -43097,6 +43132,7 @@ var init_GraphCanvas = __esm({
43097
43132
  "components/core/molecules/GraphCanvas.tsx"() {
43098
43133
  "use client";
43099
43134
  init_cn();
43135
+ init_portalRoot();
43100
43136
  init_atoms();
43101
43137
  init_Stack();
43102
43138
  init_LoadingState();
@@ -43808,7 +43844,7 @@ var init_GraphCanvas = __esm({
43808
43844
  children: hoveredObj?.label
43809
43845
  }
43810
43846
  ),
43811
- document.body
43847
+ getOrCreatePortalRoot()
43812
43848
  )
43813
43849
  ] }),
43814
43850
  groups.length > 1 && /* @__PURE__ */ jsxRuntime.jsx(HStack, { gap: "md", className: "px-4 py-2 border-t border-border", wrap: true, children: groups.map((group, idx) => /* @__PURE__ */ jsxRuntime.jsxs(HStack, { gap: "xs", align: "center", children: [
@@ -44969,6 +45005,7 @@ var init_DetailPanel = __esm({
44969
45005
  init_ErrorState();
44970
45006
  init_EmptyState();
44971
45007
  init_cn();
45008
+ init_portalRoot();
44972
45009
  init_format();
44973
45010
  init_getNestedValue();
44974
45011
  init_relationLabel();
@@ -45388,7 +45425,7 @@ var init_DetailPanel = __esm({
45388
45425
  return /* @__PURE__ */ jsxRuntime.jsx(Box, { className, children: content });
45389
45426
  }
45390
45427
  const panel = /* @__PURE__ */ jsxRuntime.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 });
45391
- return typeof document === "undefined" ? panel : reactDom.createPortal(panel, document.body);
45428
+ return typeof document === "undefined" ? panel : reactDom.createPortal(panel, getOrCreatePortalRoot());
45392
45429
  };
45393
45430
  DetailPanel.displayName = "DetailPanel";
45394
45431
  }
@@ -52298,24 +52335,6 @@ function UISlotComponentInner({
52298
52335
  }
52299
52336
  );
52300
52337
  }
52301
- function getOrCreatePortalRoot() {
52302
- let root = document.getElementById("ui-slot-portal-root");
52303
- if (!root) {
52304
- root = document.createElement("div");
52305
- root.id = "ui-slot-portal-root";
52306
- root.style.position = "relative";
52307
- root.style.zIndex = "9999";
52308
- document.body.appendChild(root);
52309
- }
52310
- const themed = document.querySelector('[data-theme*="-"]') ?? document.querySelector("[data-theme]");
52311
- if (themed) {
52312
- const theme = themed.getAttribute("data-theme");
52313
- if (theme && root.getAttribute("data-theme") !== theme) {
52314
- root.setAttribute("data-theme", theme);
52315
- }
52316
- }
52317
- return root;
52318
- }
52319
52338
  function CompiledPortal({ slot, className, pattern, sourceTrait, children }) {
52320
52339
  const [portalRoot, setPortalRoot] = React87.useState(null);
52321
52340
  const slotsBus = context.useUISlots();
@@ -52938,6 +52957,7 @@ var init_UISlotRenderer = __esm({
52938
52957
  init_slot_types();
52939
52958
  init_cn();
52940
52959
  init_format();
52960
+ init_portalRoot();
52941
52961
  init_ErrorBoundary();
52942
52962
  init_Skeleton();
52943
52963
  init_renderer();
@@ -2102,6 +2102,36 @@ var init_Typography = __esm({
2102
2102
  Typography.displayName = "Typography";
2103
2103
  }
2104
2104
  });
2105
+
2106
+ // lib/portalRoot.ts
2107
+ function lastThemedElement(selector, portalRoot) {
2108
+ const matches = Array.from(document.querySelectorAll(selector)).filter(
2109
+ (el) => el !== document.documentElement && el !== portalRoot
2110
+ );
2111
+ return matches[matches.length - 1] ?? null;
2112
+ }
2113
+ function getOrCreatePortalRoot() {
2114
+ let root = document.getElementById("ui-slot-portal-root");
2115
+ if (!root) {
2116
+ root = document.createElement("div");
2117
+ root.id = "ui-slot-portal-root";
2118
+ root.style.position = "relative";
2119
+ root.style.zIndex = "9999";
2120
+ document.body.appendChild(root);
2121
+ }
2122
+ const themed = lastThemedElement('[data-theme*="-"]', root) ?? lastThemedElement("[data-theme]", root);
2123
+ if (themed) {
2124
+ const theme = themed.getAttribute("data-theme");
2125
+ if (theme && root.getAttribute("data-theme") !== theme) {
2126
+ root.setAttribute("data-theme", theme);
2127
+ }
2128
+ }
2129
+ return root;
2130
+ }
2131
+ var init_portalRoot = __esm({
2132
+ "lib/portalRoot.ts"() {
2133
+ }
2134
+ });
2105
2135
  function isMotionEnabled() {
2106
2136
  if (typeof document === "undefined") return true;
2107
2137
  if (motionEnabledCache !== null) return motionEnabledCache;
@@ -2182,6 +2212,7 @@ var init_Modal = __esm({
2182
2212
  init_Dialog();
2183
2213
  init_Typography();
2184
2214
  init_cn();
2215
+ init_portalRoot();
2185
2216
  init_useEventBus();
2186
2217
  init_Presence();
2187
2218
  sizeClasses2 = {
@@ -2392,7 +2423,7 @@ var init_Modal = __esm({
2392
2423
  )
2393
2424
  }
2394
2425
  ),
2395
- document.body
2426
+ getOrCreatePortalRoot()
2396
2427
  );
2397
2428
  };
2398
2429
  Modal.displayName = "Modal";
@@ -20458,6 +20489,7 @@ var init_StateMachineView = __esm({
20458
20489
  init_Icon();
20459
20490
  init_useEventBus();
20460
20491
  init_cn();
20492
+ init_portalRoot();
20461
20493
  StateNode2 = ({ state, config }) => {
20462
20494
  const { t } = useTranslate();
20463
20495
  const size = state.radius * 2;
@@ -20974,7 +21006,7 @@ var init_StateMachineView = __esm({
20974
21006
  )
20975
21007
  }
20976
21008
  ),
20977
- document.body
21009
+ getOrCreatePortalRoot()
20978
21010
  );
20979
21011
  };
20980
21012
  EntityBox = ({ entity, config }) => {
@@ -27534,7 +27566,7 @@ function SubMenu({
27534
27566
  })
27535
27567
  }
27536
27568
  );
27537
- return typeof document !== "undefined" ? createPortal(panel, document.body) : panel;
27569
+ return typeof document !== "undefined" ? createPortal(panel, getOrCreatePortalRoot()) : panel;
27538
27570
  }
27539
27571
  function MenuItemRow({
27540
27572
  item,
@@ -27621,6 +27653,7 @@ var init_Menu = __esm({
27621
27653
  init_Typography();
27622
27654
  init_Badge();
27623
27655
  init_cn();
27656
+ init_portalRoot();
27624
27657
  init_useEventBus();
27625
27658
  MENU_GAP = 4;
27626
27659
  menuContainerStyles = cn(
@@ -27757,7 +27790,7 @@ var init_Menu = __esm({
27757
27790
  ) : null;
27758
27791
  return /* @__PURE__ */ jsxs(Fragment, { children: [
27759
27792
  triggerElement,
27760
- panel && typeof document !== "undefined" ? createPortal(panel, document.body) : panel
27793
+ panel && typeof document !== "undefined" ? createPortal(panel, getOrCreatePortalRoot()) : panel
27761
27794
  ] });
27762
27795
  };
27763
27796
  Menu.displayName = "Menu";
@@ -30971,6 +31004,7 @@ var init_Popover = __esm({
30971
31004
  init_Typography();
30972
31005
  init_Presence();
30973
31006
  init_cn();
31007
+ init_portalRoot();
30974
31008
  init_useTapReveal();
30975
31009
  arrowClasses = {
30976
31010
  top: "top-full left-1/2 -translate-x-1/2 border-t-white border-l-transparent border-r-transparent border-b-transparent",
@@ -31130,7 +31164,7 @@ var init_Popover = __esm({
31130
31164
  ) : null;
31131
31165
  return /* @__PURE__ */ jsxs(Fragment, { children: [
31132
31166
  triggerElement,
31133
- panel && typeof document !== "undefined" ? createPortal(panel, document.body) : panel
31167
+ panel && typeof document !== "undefined" ? createPortal(panel, getOrCreatePortalRoot()) : panel
31134
31168
  ] });
31135
31169
  };
31136
31170
  Popover.displayName = "Popover";
@@ -31636,6 +31670,7 @@ var init_Tooltip = __esm({
31636
31670
  "use client";
31637
31671
  init_Typography();
31638
31672
  init_cn();
31673
+ init_portalRoot();
31639
31674
  init_useTapReveal();
31640
31675
  TRIGGER_GAP2 = 8;
31641
31676
  arrowClasses2 = {
@@ -31741,7 +31776,7 @@ var init_Tooltip = __esm({
31741
31776
  ) : null;
31742
31777
  return /* @__PURE__ */ jsxs(Fragment, { children: [
31743
31778
  trigger,
31744
- typeof window !== "undefined" && tooltipContent ? createPortal(tooltipContent, document.body) : tooltipContent
31779
+ typeof window !== "undefined" && tooltipContent ? createPortal(tooltipContent, getOrCreatePortalRoot()) : tooltipContent
31745
31780
  ] });
31746
31781
  };
31747
31782
  Tooltip.displayName = "Tooltip";
@@ -43023,6 +43058,7 @@ var init_GraphCanvas = __esm({
43023
43058
  "components/core/molecules/GraphCanvas.tsx"() {
43024
43059
  "use client";
43025
43060
  init_cn();
43061
+ init_portalRoot();
43026
43062
  init_atoms();
43027
43063
  init_Stack();
43028
43064
  init_LoadingState();
@@ -43734,7 +43770,7 @@ var init_GraphCanvas = __esm({
43734
43770
  children: hoveredObj?.label
43735
43771
  }
43736
43772
  ),
43737
- document.body
43773
+ getOrCreatePortalRoot()
43738
43774
  )
43739
43775
  ] }),
43740
43776
  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: [
@@ -44895,6 +44931,7 @@ var init_DetailPanel = __esm({
44895
44931
  init_ErrorState();
44896
44932
  init_EmptyState();
44897
44933
  init_cn();
44934
+ init_portalRoot();
44898
44935
  init_format();
44899
44936
  init_getNestedValue();
44900
44937
  init_relationLabel();
@@ -45314,7 +45351,7 @@ var init_DetailPanel = __esm({
45314
45351
  return /* @__PURE__ */ jsx(Box, { className, children: content });
45315
45352
  }
45316
45353
  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 });
45317
- return typeof document === "undefined" ? panel : createPortal(panel, document.body);
45354
+ return typeof document === "undefined" ? panel : createPortal(panel, getOrCreatePortalRoot());
45318
45355
  };
45319
45356
  DetailPanel.displayName = "DetailPanel";
45320
45357
  }
@@ -52224,24 +52261,6 @@ function UISlotComponentInner({
52224
52261
  }
52225
52262
  );
52226
52263
  }
52227
- function getOrCreatePortalRoot() {
52228
- let root = document.getElementById("ui-slot-portal-root");
52229
- if (!root) {
52230
- root = document.createElement("div");
52231
- root.id = "ui-slot-portal-root";
52232
- root.style.position = "relative";
52233
- root.style.zIndex = "9999";
52234
- document.body.appendChild(root);
52235
- }
52236
- const themed = document.querySelector('[data-theme*="-"]') ?? document.querySelector("[data-theme]");
52237
- if (themed) {
52238
- const theme = themed.getAttribute("data-theme");
52239
- if (theme && root.getAttribute("data-theme") !== theme) {
52240
- root.setAttribute("data-theme", theme);
52241
- }
52242
- }
52243
- return root;
52244
- }
52245
52264
  function CompiledPortal({ slot, className, pattern, sourceTrait, children }) {
52246
52265
  const [portalRoot, setPortalRoot] = useState(null);
52247
52266
  const slotsBus = useUISlots();
@@ -52864,6 +52883,7 @@ var init_UISlotRenderer = __esm({
52864
52883
  init_slot_types();
52865
52884
  init_cn();
52866
52885
  init_format();
52886
+ init_portalRoot();
52867
52887
  init_ErrorBoundary();
52868
52888
  init_Skeleton();
52869
52889
  init_renderer();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/ui",
3
- "version": "6.20.0",
3
+ "version": "6.21.0",
4
4
  "description": "React UI components, hooks, and providers for Almadar",
5
5
  "type": "module",
6
6
  "sideEffects": [