@almadar/ui 6.20.0 → 6.22.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.
@@ -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();
@@ -54682,7 +54702,7 @@ function NavStackRefBridge({ apiRef }) {
54682
54702
  }, [api, apiRef]);
54683
54703
  return null;
54684
54704
  }
54685
- function TraitInitializer({ traits: traits2, routeParams, orbitalNames, onNavigate, onNavigateBack, onLocalFallback, persistence, traitConfigsByName, orbitalsByTrait, embeddedTraits, callsiteCaptureChildrenByTrait, serverActiveTraits, children }) {
54705
+ function TraitInitializer({ traits: traits2, routeParams, orbitalNames, onNavigate, onNavigateBack, onLocalFallback, localFallbackTimeoutMs, persistence, traitConfigsByName, orbitalsByTrait, embeddedTraits, callsiteCaptureChildrenByTrait, serverActiveTraits, children }) {
54686
54706
  const bridge = useServerBridge();
54687
54707
  const activeTraitNames = useMemo(
54688
54708
  () => new Set(traits2.map((b) => b.trait.name).filter((n) => !!n)),
@@ -54749,9 +54769,9 @@ function TraitInitializer({ traits: traits2, routeParams, orbitalNames, onNaviga
54749
54769
  sendEvent("INIT", routeParams);
54750
54770
  onLocalFallback?.();
54751
54771
  }
54752
- }, 5e3);
54772
+ }, localFallbackTimeoutMs ?? 5e3);
54753
54773
  return () => clearTimeout(fallback);
54754
- }, [traits2, orbitalNames, sendEvent, onLocalFallback, routeParams]);
54774
+ }, [traits2, orbitalNames, sendEvent, onLocalFallback, localFallbackTimeoutMs, routeParams]);
54755
54775
  useEffect(() => {
54756
54776
  if (!bridge.connected || !orbitalNames?.length || initSentRef.current) return;
54757
54777
  initSentRef.current = true;
@@ -54805,7 +54825,7 @@ function FitToBox({ children }) {
54805
54825
  }, []);
54806
54826
  return /* @__PURE__ */ jsx("div", { ref: outerRef, className: "relative h-full w-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { ref: innerRef, style: { transform: `scale(${scale})`, transformOrigin: "top left", width: "fit-content" }, children }) });
54807
54827
  }
54808
- function SchemaRunner({ schema, serverUrl, transport, getAccessToken, mockData, pageName, routeParams, onNavigate, onNavigateBack, onLocalFallback, persistence }) {
54828
+ function SchemaRunner({ schema, serverUrl, transport, getAccessToken, mockData, pageName, routeParams, onNavigate, onNavigateBack, onLocalFallback, localFallbackTimeoutMs, persistence }) {
54809
54829
  const { traits: traits2, allEntities, allTraits, ir } = useResolvedSchema(schema, pageName);
54810
54830
  const allPageTraits = useMemo(() => {
54811
54831
  let base;
@@ -54968,6 +54988,7 @@ function SchemaRunner({ schema, serverUrl, transport, getAccessToken, mockData,
54968
54988
  onNavigate,
54969
54989
  onNavigateBack,
54970
54990
  onLocalFallback,
54991
+ localFallbackTimeoutMs,
54971
54992
  persistence,
54972
54993
  children: /* @__PURE__ */ jsx(OrbitalThemeProvider, { theme: activeOrbitalTheme, children: /* @__PURE__ */ jsx(Box, { className: "h-full min-h-full overflow-auto p-4", children: /* @__PURE__ */ jsx(UISlotRenderer, { includeHud: true, hudMode: "inline", includeFloating: true }) }) })
54973
54994
  }
@@ -54991,7 +55012,8 @@ function OrbPreview({
54991
55012
  initialPagePath,
54992
55013
  isolated = false,
54993
55014
  fit = false,
54994
- user = null
55015
+ user = null,
55016
+ localFallbackTimeoutMs
54995
55017
  }) {
54996
55018
  if (serverUrl && transport) {
54997
55019
  throw new Error("OrbPreview accepts serverUrl OR transport, not both");
@@ -55173,6 +55195,7 @@ function OrbPreview({
55173
55195
  onNavigate: handleNavigateEffect,
55174
55196
  onNavigateBack: handleNavigateBack,
55175
55197
  onLocalFallback: handleLocalFallback,
55198
+ localFallbackTimeoutMs,
55176
55199
  persistence
55177
55200
  }
55178
55201
  ) }) : /* @__PURE__ */ jsx(
@@ -55188,6 +55211,7 @@ function OrbPreview({
55188
55211
  onNavigate: handleNavigateEffect,
55189
55212
  onNavigateBack: handleNavigateBack,
55190
55213
  onLocalFallback: handleLocalFallback,
55214
+ localFallbackTimeoutMs,
55191
55215
  persistence
55192
55216
  }
55193
55217
  ) }) })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/ui",
3
- "version": "6.20.0",
3
+ "version": "6.22.0",
4
4
  "description": "React UI components, hooks, and providers for Almadar",
5
5
  "type": "module",
6
6
  "sideEffects": [