@almadar/ui 6.27.0 → 6.29.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.
@@ -2862,6 +2862,13 @@ var init_slot_types = __esm({
2862
2862
  nextRefId = 1;
2863
2863
  }
2864
2864
  });
2865
+ var SlotContainedContext;
2866
+ var init_slotContained = __esm({
2867
+ "lib/slotContained.ts"() {
2868
+ "use client";
2869
+ SlotContainedContext = createContext(false);
2870
+ }
2871
+ });
2865
2872
  function buildForkPaths(x, y, branches, scale) {
2866
2873
  const inLength = 30 * scale;
2867
2874
  const outLength = 30 * scale;
@@ -35623,7 +35630,6 @@ function TableView({
35623
35630
  columns,
35624
35631
  fields,
35625
35632
  itemActions,
35626
- maxInlineActions,
35627
35633
  itemClickEvent = "",
35628
35634
  selectable = false,
35629
35635
  selectEvent,
@@ -35657,8 +35663,7 @@ function TableView({
35657
35663
  const [localSelected, setLocalSelected] = React87__default.useState(/* @__PURE__ */ new Set());
35658
35664
  const colDefs = (Array.isArray(columns) ? columns : void 0) ?? (Array.isArray(fields) ? fields : void 0) ?? [];
35659
35665
  const actionDefs = Array.isArray(itemActions) ? itemActions : [];
35660
- const inlineActions = maxInlineActions != null ? actionDefs.slice(0, maxInlineActions) : [];
35661
- const overflowActions = maxInlineActions != null ? actionDefs.slice(maxInlineActions) : actionDefs;
35666
+ const overflowActions = actionDefs;
35662
35667
  const fireAction = (action, row) => eventBus.emit(`UI:${action.event}`, {
35663
35668
  id: row.id,
35664
35669
  row
@@ -35840,7 +35845,7 @@ function TableView({
35840
35845
  }
35841
35846
  return /* @__PURE__ */ jsx(Box, { role: "cell", className: cellBase, children: /* @__PURE__ */ jsx("span", { className: "truncate text-foreground", children: formatCell(raw, col.format, relationsData?.[col.field ?? col.key]) }) }, col.key);
35842
35847
  }),
35843
- hasActions && /* @__PURE__ */ jsxs(
35848
+ hasActions && /* @__PURE__ */ jsx(
35844
35849
  HStack,
35845
35850
  {
35846
35851
  gap: "xs",
@@ -35854,38 +35859,20 @@ function TableView({
35854
35859
  "border-l border-[var(--color-border)]",
35855
35860
  lk.striped && index % 2 === 1 ? "bg-[var(--color-surface-subtle)]" : "bg-[var(--color-card)] group-hover:bg-[var(--color-surface-subtle)]"
35856
35861
  ),
35857
- children: [
35858
- inlineActions.map((action) => /* @__PURE__ */ jsxs(
35859
- Button,
35860
- {
35861
- variant: action.variant ?? "ghost",
35862
- size: "sm",
35863
- onClick: () => fireAction(action, row),
35864
- "data-testid": `action-${action.event}`,
35865
- "data-row-id": String(row.id),
35866
- className: cn(action.variant === "danger" && "text-error hover:bg-error/10"),
35867
- children: [
35868
- action.icon && renderIconInput3(action.icon, { size: "xs", className: "mr-1" }),
35869
- action.label
35870
- ]
35871
- },
35872
- action.event
35873
- )),
35874
- overflowActions.length > 0 && /* @__PURE__ */ jsx(
35875
- Menu,
35876
- {
35877
- position: "bottom-end",
35878
- trigger: /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "sm", "aria-label": t("common.actions"), "data-testid": "action-overflow", "data-row-id": String(row.id), children: /* @__PURE__ */ jsx(Icon, { name: "more-horizontal", size: "xs" }) }),
35879
- items: overflowActions.map((action) => ({
35880
- label: action.label,
35881
- icon: action.icon,
35882
- event: action.event,
35883
- variant: action.variant === "danger" ? "danger" : "default",
35884
- onClick: () => fireAction(action, row)
35885
- }))
35886
- }
35887
- )
35888
- ]
35862
+ children: overflowActions.length > 0 && /* @__PURE__ */ jsx(
35863
+ Menu,
35864
+ {
35865
+ position: "bottom-end",
35866
+ trigger: /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "sm", "aria-label": t("common.actions"), "data-testid": "action-overflow", "data-row-id": String(row.id), children: /* @__PURE__ */ jsx(Icon, { name: "more-horizontal", size: "xs" }) }),
35867
+ items: overflowActions.map((action) => ({
35868
+ label: action.label,
35869
+ icon: action.icon,
35870
+ event: action.event,
35871
+ variant: action.variant === "danger" ? "danger" : "default",
35872
+ onClick: () => fireAction(action, row)
35873
+ }))
35874
+ }
35875
+ )
35889
35876
  }
35890
35877
  )
35891
35878
  ]
@@ -45173,6 +45160,7 @@ var init_DetailPanel = __esm({
45173
45160
  init_EmptyState();
45174
45161
  init_cn();
45175
45162
  init_portalRoot();
45163
+ init_slotContained();
45176
45164
  init_format();
45177
45165
  init_getNestedValue();
45178
45166
  init_relationLabel();
@@ -45204,6 +45192,7 @@ var init_DetailPanel = __esm({
45204
45192
  }) => {
45205
45193
  const eventBus = useEventBus();
45206
45194
  const { t } = useTranslate();
45195
+ const contained = useContext(SlotContainedContext);
45207
45196
  const [titleDraft, setTitleDraft] = React87__default.useState(null);
45208
45197
  const isFieldDefArray = (arr) => {
45209
45198
  if (!arr || arr.length === 0) return false;
@@ -45591,8 +45580,9 @@ var init_DetailPanel = __esm({
45591
45580
  if (!slideOver) {
45592
45581
  return /* @__PURE__ */ jsx(Box, { className, children: content });
45593
45582
  }
45594
- 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 });
45595
- return typeof document === "undefined" ? panel : createPortal(panel, getOrCreatePortalRoot());
45583
+ const panel = /* @__PURE__ */ jsx(Box, { className: cn(contained ? "absolute" : "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 });
45584
+ if (contained || typeof document === "undefined") return panel;
45585
+ return createPortal(panel, getOrCreatePortalRoot());
45596
45586
  };
45597
45587
  DetailPanel.displayName = "DetailPanel";
45598
45588
  }
@@ -52089,6 +52079,7 @@ var init_component_registry_generated = __esm({
52089
52079
  // components/core/organisms/UISlotRenderer.tsx
52090
52080
  var UISlotRenderer_exports = {};
52091
52081
  __export(UISlotRenderer_exports, {
52082
+ SlotContainedContext: () => SlotContainedContext,
52092
52083
  SlotContentRenderer: () => SlotContentRenderer,
52093
52084
  SuspenseConfigProvider: () => SuspenseConfigProvider,
52094
52085
  UISlotComponent: () => UISlotComponent,
@@ -52261,6 +52252,25 @@ function renderContainedPortal(t, slot, content, onDismiss) {
52261
52252
  }
52262
52253
  );
52263
52254
  case "drawer":
52255
+ if (content.pattern === "detail-panel" && content.props.slideOver === true) {
52256
+ return /* @__PURE__ */ jsx(
52257
+ Box,
52258
+ {
52259
+ id: slotId,
52260
+ className: "absolute inset-0 z-50 overflow-hidden",
52261
+ style: { backgroundColor: "rgba(0, 0, 0, 0.5)" },
52262
+ onClick: onDismiss,
52263
+ children: /* @__PURE__ */ jsx(
52264
+ Box,
52265
+ {
52266
+ className: "absolute inset-y-0 right-0 pointer-events-auto",
52267
+ onClick: (e) => e.stopPropagation(),
52268
+ children: slotContent
52269
+ }
52270
+ )
52271
+ }
52272
+ );
52273
+ }
52264
52274
  return /* @__PURE__ */ jsx(
52265
52275
  Box,
52266
52276
  {
@@ -53112,7 +53122,7 @@ function UISlotRenderer({
53112
53122
  }
53113
53123
  return wrapped;
53114
53124
  }
53115
- var scopeWrapLog, TRAIT_BINDING_RE, SuspenseConfigContext, SlotContainedContext, SLOT_SKELETON_MAP, CONTENT_NODE_SLOTS, PATTERNS_WITH_CHILDREN, traitRefPresenceCache;
53125
+ var scopeWrapLog, TRAIT_BINDING_RE, SuspenseConfigContext, SLOT_SKELETON_MAP, CONTENT_NODE_SLOTS, PATTERNS_WITH_CHILDREN, traitRefPresenceCache;
53116
53126
  var init_UISlotRenderer = __esm({
53117
53127
  "components/core/organisms/UISlotRenderer.tsx"() {
53118
53128
  "use client";
@@ -53127,6 +53137,7 @@ var init_UISlotRenderer = __esm({
53127
53137
  init_cn();
53128
53138
  init_format();
53129
53139
  init_portalRoot();
53140
+ init_slotContained();
53130
53141
  init_ErrorBoundary();
53131
53142
  init_Skeleton();
53132
53143
  init_renderer();
@@ -53136,7 +53147,6 @@ var init_UISlotRenderer = __esm({
53136
53147
  scopeWrapLog = createLogger("almadar:ui:scope-wrap");
53137
53148
  TRAIT_BINDING_RE = /^@trait\.([A-Z][A-Za-z0-9]*)$/;
53138
53149
  SuspenseConfigContext = createContext({ enabled: false });
53139
- SlotContainedContext = createContext(false);
53140
53150
  SuspenseConfigProvider.displayName = "SuspenseConfigProvider";
53141
53151
  SLOT_SKELETON_MAP = {
53142
53152
  main: "table",
@@ -54604,6 +54614,9 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
54604
54614
  const normalizedEvent = normalizeEventKey(eventKey);
54605
54615
  return managerRef.current.canHandleEvent(traitName, normalizedEvent);
54606
54616
  }, []);
54617
+ const commitServerEntity = useCallback((traitName, entity) => {
54618
+ traitFieldStatesRef.current.set(traitName, entity);
54619
+ }, []);
54607
54620
  useEffect(() => {
54608
54621
  const allEvents = /* @__PURE__ */ new Set();
54609
54622
  for (const binding of traitBindings) {
@@ -54767,7 +54780,8 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
54767
54780
  sendEvent,
54768
54781
  getTraitState,
54769
54782
  canHandleEvent,
54770
- entityBindingSource
54783
+ entityBindingSource,
54784
+ commitServerEntity
54771
54785
  };
54772
54786
  }
54773
54787
  var resolvedSchemaLog = createLogger("almadar:ui:resolved-schema");
@@ -54988,7 +55002,7 @@ function NavStackRefBridge({ apiRef }) {
54988
55002
  }, [api, apiRef]);
54989
55003
  return null;
54990
55004
  }
54991
- function TraitInitializer({ traits: traits2, routeParams, orbitalNames, onNavigate, onNavigateBack, onLocalFallback, localFallbackTimeoutMs, persistence, traitConfigsByName, orbitalsByTrait, embeddedTraits, callsiteCaptureChildrenByTrait, serverActiveTraits, children }) {
55005
+ function TraitInitializer({ traits: traits2, routeParams, orbitalNames, onNavigate, onNavigateBack, onLocalFallback, localFallbackTimeoutMs, persistence, traitConfigsByName, orbitalsByTrait, embeddedTraits, callsiteCaptureChildrenByTrait, serverActiveTraits, user, children }) {
54992
55006
  const bridge = useServerBridge();
54993
55007
  const activeTraitNames = useMemo(
54994
55008
  () => new Set(traits2.map((b) => b.trait.name).filter((n) => !!n)),
@@ -55006,6 +55020,8 @@ function TraitInitializer({ traits: traits2, routeParams, orbitalNames, onNaviga
55006
55020
  [serverActiveTraits]
55007
55021
  );
55008
55022
  const uiSlots = useUISlots();
55023
+ const commitServerEntityRef = useRef(() => {
55024
+ });
55009
55025
  const onEventProcessed = useCallback((event, payload, dispatchedOrbitals, tick, sourceTrait, locallyEmitted, results, entityByTrait) => {
55010
55026
  if (!bridge.connected || !orbitalNames?.length) return;
55011
55027
  const targets = dispatchedOrbitals && dispatchedOrbitals.size > 0 ? orbitalNames.filter((n) => dispatchedOrbitals.has(n)) : orbitalNames;
@@ -55020,14 +55036,20 @@ function TraitInitializer({ traits: traits2, routeParams, orbitalNames, onNaviga
55020
55036
  void bridge.sendEvent(name, event, withActiveTraits(payload), tick, sourceTrait);
55021
55037
  continue;
55022
55038
  }
55023
- void bridge.sendEvent(name, event, withActiveTraits(payload), void 0, void 0, locallyEmitted, results, entityByTrait).then(({ effects, meta }) => {
55039
+ void bridge.sendEvent(name, event, withActiveTraits(payload), void 0, void 0, locallyEmitted, results, entityByTrait, user ?? void 0).then(({ effects, meta }) => {
55024
55040
  recordServerResponse(name, event, { ...meta, effectResults: effectResultsToTraces(meta.effectResults) });
55041
+ if (meta.entityByTrait) {
55042
+ for (const [traitName, entity] of Object.entries(meta.entityByTrait)) {
55043
+ commitServerEntityRef.current(traitName, entity);
55044
+ }
55045
+ }
55025
55046
  applyServerEffects(effects, uiSlots, onNavigate, embeddedTraits, activeTraitNamesRef.current, onNavigateBack);
55026
55047
  });
55027
55048
  }
55028
- }, [bridge.connected, bridge.sendEvent, orbitalNames, uiSlots, onNavigate, onNavigateBack, embeddedTraits, activeTraitNames, withActiveTraits]);
55049
+ }, [bridge.connected, bridge.sendEvent, orbitalNames, uiSlots, onNavigate, onNavigateBack, embeddedTraits, activeTraitNames, withActiveTraits, user]);
55029
55050
  const opts = orbitalNames ? { onEventProcessed, navigate: onNavigate, navigateBack: onNavigateBack, traitConfigsByName, orbitalsByTrait, embeddedTraits, callsiteCaptureChildrenByTrait, initPayload: routeParams } : { navigate: onNavigate, navigateBack: onNavigateBack, persistence, traitConfigsByName, orbitalsByTrait, embeddedTraits, callsiteCaptureChildrenByTrait, initPayload: routeParams };
55030
- const { sendEvent, entityBindingSource } = useTraitStateMachine(traits2, uiSlots, opts);
55051
+ const { sendEvent, entityBindingSource, commitServerEntity } = useTraitStateMachine(traits2, uiSlots, opts);
55052
+ commitServerEntityRef.current = commitServerEntity;
55031
55053
  const initSentRef = useRef(false);
55032
55054
  const prevTraitsRef = useRef(void 0);
55033
55055
  const paramsKey = JSON.stringify(routeParams ?? {});
@@ -55067,8 +55089,23 @@ function TraitInitializer({ traits: traits2, routeParams, orbitalNames, onNaviga
55067
55089
  initSentRef.current = true;
55068
55090
  (async () => {
55069
55091
  for (const name of orbitalNames) {
55070
- const { effects, meta } = await bridge.sendEvent(name, "INIT", withActiveTraits({ ...routeParams ?? {} }));
55092
+ const { effects, meta } = await bridge.sendEvent(
55093
+ name,
55094
+ "INIT",
55095
+ withActiveTraits({ ...routeParams ?? {} }),
55096
+ void 0,
55097
+ void 0,
55098
+ void 0,
55099
+ void 0,
55100
+ void 0,
55101
+ user ?? void 0
55102
+ );
55071
55103
  recordServerResponse(name, "INIT", { ...meta, effectResults: effectResultsToTraces(meta.effectResults) });
55104
+ if (meta.entityByTrait) {
55105
+ for (const [traitName, entity] of Object.entries(meta.entityByTrait)) {
55106
+ commitServerEntityRef.current(traitName, entity);
55107
+ }
55108
+ }
55072
55109
  const effectTraces = [
55073
55110
  { type: "fetch", args: [], status: "executed" },
55074
55111
  ...effects.map((eff) => ({
@@ -55088,7 +55125,7 @@ function TraitInitializer({ traits: traits2, routeParams, orbitalNames, onNaviga
55088
55125
  applyServerEffects(effects, uiSlots, onNavigate, embeddedTraits, activeTraitNamesRef.current, onNavigateBack);
55089
55126
  }
55090
55127
  })();
55091
- }, [bridge.connected, orbitalNames, bridge.sendEvent, uiSlots, onNavigate, onNavigateBack, embeddedTraits, activeTraitNames, withActiveTraits, routeParams]);
55128
+ }, [bridge.connected, orbitalNames, bridge.sendEvent, uiSlots, onNavigate, onNavigateBack, embeddedTraits, activeTraitNames, withActiveTraits, routeParams, user]);
55092
55129
  return /* @__PURE__ */ jsx(EntityBindingContext.Provider, { value: entityBindingSource, children });
55093
55130
  }
55094
55131
  function FitToBox({ children }) {
@@ -55115,7 +55152,7 @@ function FitToBox({ children }) {
55115
55152
  }, []);
55116
55153
  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 }) });
55117
55154
  }
55118
- function SchemaRunner({ schema, serverUrl, transport, getAccessToken, mockData, pageName, routeParams, onNavigate, onNavigateBack, onLocalFallback, localFallbackTimeoutMs, persistence }) {
55155
+ function SchemaRunner({ schema, serverUrl, transport, getAccessToken, mockData, pageName, routeParams, onNavigate, onNavigateBack, onLocalFallback, localFallbackTimeoutMs, persistence, user }) {
55119
55156
  const { traits: traits2, allEntities, allTraits, ir } = useResolvedSchema(schema, pageName);
55120
55157
  const allPageTraits = useMemo(() => {
55121
55158
  let base;
@@ -55280,6 +55317,7 @@ function SchemaRunner({ schema, serverUrl, transport, getAccessToken, mockData,
55280
55317
  onLocalFallback,
55281
55318
  localFallbackTimeoutMs,
55282
55319
  persistence,
55320
+ user,
55283
55321
  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 }) }) })
55284
55322
  }
55285
55323
  )
@@ -55486,7 +55524,8 @@ function OrbPreview({
55486
55524
  onNavigateBack: handleNavigateBack,
55487
55525
  onLocalFallback: handleLocalFallback,
55488
55526
  localFallbackTimeoutMs,
55489
- persistence
55527
+ persistence,
55528
+ user
55490
55529
  }
55491
55530
  ) }) : /* @__PURE__ */ jsx(
55492
55531
  SchemaRunner,
@@ -55502,7 +55541,8 @@ function OrbPreview({
55502
55541
  onNavigateBack: handleNavigateBack,
55503
55542
  onLocalFallback: handleLocalFallback,
55504
55543
  localFallbackTimeoutMs,
55505
- persistence
55544
+ persistence,
55545
+ user
55506
55546
  }
55507
55547
  ) }) })
55508
55548
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/ui",
3
- "version": "6.27.0",
3
+ "version": "6.29.0",
4
4
  "description": "React UI components, hooks, and providers for Almadar",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -118,11 +118,11 @@
118
118
  "access": "public"
119
119
  },
120
120
  "dependencies": {
121
- "@almadar/core": "^10.93.0",
122
- "@almadar/evaluator": "^2.46.0",
121
+ "@almadar/core": "^10.96.0",
122
+ "@almadar/evaluator": "^2.47.0",
123
123
  "@almadar/logger": "^1.12.0",
124
- "@almadar/runtime": "^6.81.0",
125
- "@almadar/std": "^16.219.0",
124
+ "@almadar/runtime": "^6.83.0",
125
+ "@almadar/std": "^16.220.0",
126
126
  "@almadar/syntax": "^1.17.0",
127
127
  "@dnd-kit/core": "^6.3.1",
128
128
  "@dnd-kit/sortable": "^10.0.0",