@almadar/ui 3.8.2 → 3.9.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.
@@ -19065,10 +19065,7 @@ var init_DataList = __esm({
19065
19065
  HStack,
19066
19066
  {
19067
19067
  gap: "xs",
19068
- className: cn(
19069
- "flex-shrink-0 transition-opacity duration-200",
19070
- "opacity-0 group-hover:opacity-100"
19071
- ),
19068
+ className: "flex-shrink-0",
19072
19069
  children: itemActions.map((action, idx) => /* @__PURE__ */ jsxs(
19073
19070
  Button,
19074
19071
  {
@@ -19158,33 +19155,23 @@ var init_DataList = __esm({
19158
19155
  ] }, field.name);
19159
19156
  })
19160
19157
  ] }),
19161
- itemActions && itemActions.length > 0 && /* @__PURE__ */ jsx(
19162
- HStack,
19158
+ itemActions && itemActions.length > 0 && /* @__PURE__ */ jsx(HStack, { gap: "xs", className: "flex-shrink-0", children: itemActions.map((action, idx) => /* @__PURE__ */ jsxs(
19159
+ Button,
19163
19160
  {
19164
- gap: "xs",
19161
+ variant: action.variant ?? "ghost",
19162
+ size: "sm",
19163
+ onClick: handleActionClick(action, itemData),
19164
+ "data-testid": `action-${action.event}`,
19165
19165
  className: cn(
19166
- "flex-shrink-0 transition-opacity duration-200",
19167
- "opacity-0 group-hover:opacity-100"
19166
+ action.variant === "danger" && "text-error hover:bg-error/10"
19168
19167
  ),
19169
- children: itemActions.map((action, idx) => /* @__PURE__ */ jsxs(
19170
- Button,
19171
- {
19172
- variant: action.variant ?? "ghost",
19173
- size: "sm",
19174
- onClick: handleActionClick(action, itemData),
19175
- "data-testid": `action-${action.event}`,
19176
- className: cn(
19177
- action.variant === "danger" && "text-error hover:bg-error/10"
19178
- ),
19179
- children: [
19180
- action.icon && /* @__PURE__ */ jsx(Icon, { name: action.icon, size: "xs", className: "mr-1" }),
19181
- action.label
19182
- ]
19183
- },
19184
- idx
19185
- ))
19186
- }
19187
- )
19168
+ children: [
19169
+ action.icon && /* @__PURE__ */ jsx(Icon, { name: action.icon, size: "xs", className: "mr-1" }),
19170
+ action.label
19171
+ ]
19172
+ },
19173
+ idx
19174
+ )) })
19188
19175
  ]
19189
19176
  }
19190
19177
  ),
@@ -30616,75 +30603,66 @@ var init_List = __esm({
30616
30603
  hasProgress && /* @__PURE__ */ jsx(Box, { className: "ml-auto", children: /* @__PURE__ */ jsx(ProgressIndicator, { value: progressValue }) })
30617
30604
  ] })
30618
30605
  ] }),
30619
- /* @__PURE__ */ jsxs(
30620
- HStack,
30621
- {
30622
- className: cn(
30623
- "flex items-center gap-1 flex-shrink-0 transition-opacity duration-200",
30624
- "opacity-0 group-hover:opacity-100"
30625
- ),
30626
- children: [
30627
- editAction && /* @__PURE__ */ jsx(
30628
- Button,
30629
- {
30630
- variant: "ghost",
30631
- action: editAction.event,
30632
- className: cn(
30633
- "p-2 rounded-lg transition-all duration-200",
30634
- "hover:bg-primary/10 hover:text-primary",
30635
- "text-muted-foreground",
30636
- "active:scale-95"
30637
- ),
30638
- title: editAction.label,
30639
- "data-testid": editAction.event ? `action-${editAction.event}` : void 0,
30640
- children: /* @__PURE__ */ jsx(Pencil, { className: "w-4 h-4" })
30641
- }
30606
+ /* @__PURE__ */ jsxs(HStack, { className: "flex items-center gap-1 flex-shrink-0", children: [
30607
+ editAction && /* @__PURE__ */ jsx(
30608
+ Button,
30609
+ {
30610
+ variant: "ghost",
30611
+ action: editAction.event,
30612
+ className: cn(
30613
+ "p-2 rounded-lg transition-all duration-200",
30614
+ "hover:bg-primary/10 hover:text-primary",
30615
+ "text-muted-foreground",
30616
+ "active:scale-95"
30642
30617
  ),
30643
- viewAction && /* @__PURE__ */ jsx(
30644
- Button,
30645
- {
30646
- variant: "ghost",
30647
- action: viewAction.event,
30648
- className: cn(
30649
- "p-2 rounded-lg transition-all duration-200",
30650
- "hover:bg-muted hover:text-foreground",
30651
- "text-muted-foreground",
30652
- "active:scale-95"
30653
- ),
30654
- title: viewAction.label,
30655
- "data-testid": viewAction.event ? `action-${viewAction.event}` : void 0,
30656
- children: /* @__PURE__ */ jsx(Eye, { className: "w-4 h-4" })
30657
- }
30618
+ title: editAction.label,
30619
+ "data-testid": editAction.event ? `action-${editAction.event}` : void 0,
30620
+ children: /* @__PURE__ */ jsx(Pencil, { className: "w-4 h-4" })
30621
+ }
30622
+ ),
30623
+ viewAction && /* @__PURE__ */ jsx(
30624
+ Button,
30625
+ {
30626
+ variant: "ghost",
30627
+ action: viewAction.event,
30628
+ className: cn(
30629
+ "p-2 rounded-lg transition-all duration-200",
30630
+ "hover:bg-muted hover:text-foreground",
30631
+ "text-muted-foreground",
30632
+ "active:scale-95"
30658
30633
  ),
30659
- (() => {
30660
- const filteredActions = actions.filter(
30661
- (a) => !a.label.toLowerCase().includes("edit") && !a.label.toLowerCase().includes("view") && !a.label.toLowerCase().includes("open")
30662
- );
30663
- return filteredActions.length > 0 ? /* @__PURE__ */ jsx(
30664
- Menu,
30634
+ title: viewAction.label,
30635
+ "data-testid": viewAction.event ? `action-${viewAction.event}` : void 0,
30636
+ children: /* @__PURE__ */ jsx(Eye, { className: "w-4 h-4" })
30637
+ }
30638
+ ),
30639
+ (() => {
30640
+ const filteredActions = actions.filter(
30641
+ (a) => !a.label.toLowerCase().includes("edit") && !a.label.toLowerCase().includes("view") && !a.label.toLowerCase().includes("open")
30642
+ );
30643
+ return filteredActions.length > 0 ? /* @__PURE__ */ jsx(
30644
+ Menu,
30645
+ {
30646
+ trigger: /* @__PURE__ */ jsx(
30647
+ Button,
30665
30648
  {
30666
- trigger: /* @__PURE__ */ jsx(
30667
- Button,
30668
- {
30669
- variant: "ghost",
30670
- className: cn(
30671
- "p-2 rounded-lg transition-all duration-200",
30672
- "hover:bg-muted hover:shadow-sm",
30673
- "text-muted-foreground hover:text-foreground",
30674
- "active:scale-95"
30675
- ),
30676
- children: /* @__PURE__ */ jsx(MoreHorizontal, { className: "w-4 h-4" })
30677
- }
30649
+ variant: "ghost",
30650
+ className: cn(
30651
+ "p-2 rounded-lg transition-all duration-200",
30652
+ "hover:bg-muted hover:shadow-sm",
30653
+ "text-muted-foreground hover:text-foreground",
30654
+ "active:scale-95"
30678
30655
  ),
30679
- items: filteredActions,
30680
- position: "bottom-right"
30656
+ children: /* @__PURE__ */ jsx(MoreHorizontal, { className: "w-4 h-4" })
30681
30657
  }
30682
- ) : null;
30683
- })(),
30684
- hasExplicitClick && /* @__PURE__ */ jsx(ChevronRight, { className: "w-4 h-4 text-muted-foreground/50 group-hover:text-muted-foreground group-hover:translate-x-0.5 transition-all" })
30685
- ]
30686
- }
30687
- )
30658
+ ),
30659
+ items: filteredActions,
30660
+ position: "bottom-right"
30661
+ }
30662
+ ) : null;
30663
+ })(),
30664
+ hasExplicitClick && /* @__PURE__ */ jsx(ChevronRight, { className: "w-4 h-4 text-muted-foreground/50 group-hover:text-muted-foreground group-hover:translate-x-0.5 transition-all" })
30665
+ ] })
30688
30666
  ]
30689
30667
  }
30690
30668
  ),
@@ -18914,10 +18914,7 @@ var init_DataList = __esm({
18914
18914
  HStack,
18915
18915
  {
18916
18916
  gap: "xs",
18917
- className: cn(
18918
- "flex-shrink-0 transition-opacity duration-200",
18919
- "opacity-0 group-hover:opacity-100"
18920
- ),
18917
+ className: "flex-shrink-0",
18921
18918
  children: itemActions.map((action, idx) => /* @__PURE__ */ jsxRuntime.jsxs(
18922
18919
  Button,
18923
18920
  {
@@ -19007,33 +19004,23 @@ var init_DataList = __esm({
19007
19004
  ] }, field.name);
19008
19005
  })
19009
19006
  ] }),
19010
- itemActions && itemActions.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
19011
- HStack,
19007
+ itemActions && itemActions.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(HStack, { gap: "xs", className: "flex-shrink-0", children: itemActions.map((action, idx) => /* @__PURE__ */ jsxRuntime.jsxs(
19008
+ Button,
19012
19009
  {
19013
- gap: "xs",
19010
+ variant: action.variant ?? "ghost",
19011
+ size: "sm",
19012
+ onClick: handleActionClick(action, itemData),
19013
+ "data-testid": `action-${action.event}`,
19014
19014
  className: cn(
19015
- "flex-shrink-0 transition-opacity duration-200",
19016
- "opacity-0 group-hover:opacity-100"
19015
+ action.variant === "danger" && "text-error hover:bg-error/10"
19017
19016
  ),
19018
- children: itemActions.map((action, idx) => /* @__PURE__ */ jsxRuntime.jsxs(
19019
- Button,
19020
- {
19021
- variant: action.variant ?? "ghost",
19022
- size: "sm",
19023
- onClick: handleActionClick(action, itemData),
19024
- "data-testid": `action-${action.event}`,
19025
- className: cn(
19026
- action.variant === "danger" && "text-error hover:bg-error/10"
19027
- ),
19028
- children: [
19029
- action.icon && /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: action.icon, size: "xs", className: "mr-1" }),
19030
- action.label
19031
- ]
19032
- },
19033
- idx
19034
- ))
19035
- }
19036
- )
19017
+ children: [
19018
+ action.icon && /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: action.icon, size: "xs", className: "mr-1" }),
19019
+ action.label
19020
+ ]
19021
+ },
19022
+ idx
19023
+ )) })
19037
19024
  ]
19038
19025
  }
19039
19026
  ),
@@ -30263,75 +30250,66 @@ var init_List = __esm({
30263
30250
  hasProgress && /* @__PURE__ */ jsxRuntime.jsx(Box, { className: "ml-auto", children: /* @__PURE__ */ jsxRuntime.jsx(ProgressIndicator, { value: progressValue }) })
30264
30251
  ] })
30265
30252
  ] }),
30266
- /* @__PURE__ */ jsxRuntime.jsxs(
30267
- HStack,
30268
- {
30269
- className: cn(
30270
- "flex items-center gap-1 flex-shrink-0 transition-opacity duration-200",
30271
- "opacity-0 group-hover:opacity-100"
30272
- ),
30273
- children: [
30274
- editAction && /* @__PURE__ */ jsxRuntime.jsx(
30275
- Button,
30276
- {
30277
- variant: "ghost",
30278
- action: editAction.event,
30279
- className: cn(
30280
- "p-2 rounded-lg transition-all duration-200",
30281
- "hover:bg-primary/10 hover:text-primary",
30282
- "text-muted-foreground",
30283
- "active:scale-95"
30284
- ),
30285
- title: editAction.label,
30286
- "data-testid": editAction.event ? `action-${editAction.event}` : void 0,
30287
- children: /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.Pencil, { className: "w-4 h-4" })
30288
- }
30253
+ /* @__PURE__ */ jsxRuntime.jsxs(HStack, { className: "flex items-center gap-1 flex-shrink-0", children: [
30254
+ editAction && /* @__PURE__ */ jsxRuntime.jsx(
30255
+ Button,
30256
+ {
30257
+ variant: "ghost",
30258
+ action: editAction.event,
30259
+ className: cn(
30260
+ "p-2 rounded-lg transition-all duration-200",
30261
+ "hover:bg-primary/10 hover:text-primary",
30262
+ "text-muted-foreground",
30263
+ "active:scale-95"
30289
30264
  ),
30290
- viewAction && /* @__PURE__ */ jsxRuntime.jsx(
30291
- Button,
30292
- {
30293
- variant: "ghost",
30294
- action: viewAction.event,
30295
- className: cn(
30296
- "p-2 rounded-lg transition-all duration-200",
30297
- "hover:bg-muted hover:text-foreground",
30298
- "text-muted-foreground",
30299
- "active:scale-95"
30300
- ),
30301
- title: viewAction.label,
30302
- "data-testid": viewAction.event ? `action-${viewAction.event}` : void 0,
30303
- children: /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.Eye, { className: "w-4 h-4" })
30304
- }
30265
+ title: editAction.label,
30266
+ "data-testid": editAction.event ? `action-${editAction.event}` : void 0,
30267
+ children: /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.Pencil, { className: "w-4 h-4" })
30268
+ }
30269
+ ),
30270
+ viewAction && /* @__PURE__ */ jsxRuntime.jsx(
30271
+ Button,
30272
+ {
30273
+ variant: "ghost",
30274
+ action: viewAction.event,
30275
+ className: cn(
30276
+ "p-2 rounded-lg transition-all duration-200",
30277
+ "hover:bg-muted hover:text-foreground",
30278
+ "text-muted-foreground",
30279
+ "active:scale-95"
30305
30280
  ),
30306
- (() => {
30307
- const filteredActions = actions.filter(
30308
- (a) => !a.label.toLowerCase().includes("edit") && !a.label.toLowerCase().includes("view") && !a.label.toLowerCase().includes("open")
30309
- );
30310
- return filteredActions.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
30311
- Menu,
30281
+ title: viewAction.label,
30282
+ "data-testid": viewAction.event ? `action-${viewAction.event}` : void 0,
30283
+ children: /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.Eye, { className: "w-4 h-4" })
30284
+ }
30285
+ ),
30286
+ (() => {
30287
+ const filteredActions = actions.filter(
30288
+ (a) => !a.label.toLowerCase().includes("edit") && !a.label.toLowerCase().includes("view") && !a.label.toLowerCase().includes("open")
30289
+ );
30290
+ return filteredActions.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
30291
+ Menu,
30292
+ {
30293
+ trigger: /* @__PURE__ */ jsxRuntime.jsx(
30294
+ Button,
30312
30295
  {
30313
- trigger: /* @__PURE__ */ jsxRuntime.jsx(
30314
- Button,
30315
- {
30316
- variant: "ghost",
30317
- className: cn(
30318
- "p-2 rounded-lg transition-all duration-200",
30319
- "hover:bg-muted hover:shadow-sm",
30320
- "text-muted-foreground hover:text-foreground",
30321
- "active:scale-95"
30322
- ),
30323
- children: /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.MoreHorizontal, { className: "w-4 h-4" })
30324
- }
30296
+ variant: "ghost",
30297
+ className: cn(
30298
+ "p-2 rounded-lg transition-all duration-200",
30299
+ "hover:bg-muted hover:shadow-sm",
30300
+ "text-muted-foreground hover:text-foreground",
30301
+ "active:scale-95"
30325
30302
  ),
30326
- items: filteredActions,
30327
- position: "bottom-right"
30303
+ children: /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.MoreHorizontal, { className: "w-4 h-4" })
30328
30304
  }
30329
- ) : null;
30330
- })(),
30331
- hasExplicitClick && /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.ChevronRight, { className: "w-4 h-4 text-muted-foreground/50 group-hover:text-muted-foreground group-hover:translate-x-0.5 transition-all" })
30332
- ]
30333
- }
30334
- )
30305
+ ),
30306
+ items: filteredActions,
30307
+ position: "bottom-right"
30308
+ }
30309
+ ) : null;
30310
+ })(),
30311
+ hasExplicitClick && /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.ChevronRight, { className: "w-4 h-4 text-muted-foreground/50 group-hover:text-muted-foreground group-hover:translate-x-0.5 transition-all" })
30312
+ ] })
30335
30313
  ]
30336
30314
  }
30337
30315
  ),
@@ -38185,7 +38163,7 @@ function useTraitStateMachine(traitBindings, slotsActions, options) {
38185
38163
  effects: result.effects,
38186
38164
  traitDefinition: binding.trait
38187
38165
  };
38188
- const handlers = createClientEffectHandlers({
38166
+ const clientHandlers = createClientEffectHandlers({
38189
38167
  eventBus,
38190
38168
  slotSetter: {
38191
38169
  addPattern: (slot, pattern, props) => {
@@ -38200,6 +38178,43 @@ function useTraitStateMachine(traitBindings, slotsActions, options) {
38200
38178
  navigate: optionsRef.current?.navigate,
38201
38179
  notify: optionsRef.current?.notify
38202
38180
  });
38181
+ const persistence = optionsRef.current?.persistence;
38182
+ let handlers = clientHandlers;
38183
+ if (persistence) {
38184
+ const sharedBindings = {
38185
+ entity: payload ?? {},
38186
+ payload: payload || {},
38187
+ state: result.previousState
38188
+ };
38189
+ if (binding.config) {
38190
+ sharedBindings.config = binding.config;
38191
+ }
38192
+ const serverHandlers = runtime.createServerEffectHandlers({
38193
+ persistence,
38194
+ eventBus,
38195
+ entityType: linkedEntity,
38196
+ entityId,
38197
+ bindings: sharedBindings,
38198
+ context: {
38199
+ traitName: binding.trait.name,
38200
+ state: result.previousState,
38201
+ transition: `${result.previousState}->${result.newState}`,
38202
+ linkedEntity,
38203
+ entityId
38204
+ },
38205
+ source: { trait: binding.trait.name },
38206
+ callService: optionsRef.current?.callService
38207
+ });
38208
+ handlers = {
38209
+ ...serverHandlers,
38210
+ // Client handlers own UI + emit: keep the slot setter
38211
+ // and pre-prefixed UI:* emit path intact.
38212
+ emit: clientHandlers.emit,
38213
+ renderUI: clientHandlers.renderUI,
38214
+ navigate: clientHandlers.navigate,
38215
+ notify: clientHandlers.notify
38216
+ };
38217
+ }
38203
38218
  const entityFromPayload = payload ?? {};
38204
38219
  const bindingCtx = {
38205
38220
  entity: entityFromPayload,
@@ -38821,7 +38836,7 @@ function applyServerEffects(effects, uiSlots, onNavigate) {
38821
38836
  }
38822
38837
  }
38823
38838
  }
38824
- function TraitInitializer({ traits: traits2, orbitalNames, onNavigate, onLocalFallback }) {
38839
+ function TraitInitializer({ traits: traits2, orbitalNames, onNavigate, onLocalFallback, persistence }) {
38825
38840
  const slotsActions = useSlotsActions();
38826
38841
  const bridge = useServerBridge();
38827
38842
  const uiSlots = context.useUISlots();
@@ -38833,7 +38848,7 @@ function TraitInitializer({ traits: traits2, orbitalNames, onNavigate, onLocalFa
38833
38848
  applyServerEffects(effects, uiSlots, onNavigate);
38834
38849
  }
38835
38850
  }, [bridge.connected, bridge.sendEvent, orbitalNames, uiSlots, onNavigate]);
38836
- const opts = orbitalNames ? { onEventProcessed, navigate: onNavigate } : { navigate: onNavigate };
38851
+ const opts = orbitalNames ? { onEventProcessed, navigate: onNavigate } : { navigate: onNavigate, persistence };
38837
38852
  const { sendEvent } = useTraitStateMachine(traits2, slotsActions, opts);
38838
38853
  const initSentRef = React116.useRef(false);
38839
38854
  React116.useEffect(() => {
@@ -38878,7 +38893,7 @@ function TraitInitializer({ traits: traits2, orbitalNames, onNavigate, onLocalFa
38878
38893
  }, [bridge.connected, orbitalNames, bridge.sendEvent, uiSlots, onNavigate]);
38879
38894
  return null;
38880
38895
  }
38881
- function SchemaRunner({ schema, serverUrl, mockData, pageName, onNavigate, onLocalFallback }) {
38896
+ function SchemaRunner({ schema, serverUrl, mockData, pageName, onNavigate, onLocalFallback, persistence }) {
38882
38897
  const { traits: traits2, allEntities, ir } = useResolvedSchema(schema, pageName);
38883
38898
  const allPageTraits = React116.useMemo(() => {
38884
38899
  if (pageName && traits2.length > 0) return traits2;
@@ -38911,7 +38926,8 @@ function SchemaRunner({ schema, serverUrl, mockData, pageName, onNavigate, onLoc
38911
38926
  traits: allPageTraits,
38912
38927
  orbitalNames: serverUrl ? orbitalNames : void 0,
38913
38928
  onNavigate,
38914
- onLocalFallback
38929
+ onLocalFallback,
38930
+ persistence
38915
38931
  }
38916
38932
  ),
38917
38933
  /* @__PURE__ */ jsxRuntime.jsx(SlotBridge, {}),
@@ -38959,6 +38975,13 @@ function OrbPreview({
38959
38975
  }, [schema, autoMock, serverUrl, mockData]);
38960
38976
  const parsedSchema = parseResult.ok ? parseResult.schema : null;
38961
38977
  const effectiveMockData = parseResult.ok ? parseResult.mockData : {};
38978
+ const persistence = React116.useMemo(() => {
38979
+ if (!parsedSchema || serverUrl) return void 0;
38980
+ if (!autoMock) return void 0;
38981
+ const adapter = new runtime.InMemoryPersistence();
38982
+ adapter.seed(effectiveMockData);
38983
+ return adapter;
38984
+ }, [parsedSchema, serverUrl, autoMock, effectiveMockData]);
38962
38985
  const pages = React116.useMemo(() => {
38963
38986
  if (!parsedSchema) return [];
38964
38987
  try {
@@ -39013,7 +39036,8 @@ function OrbPreview({
39013
39036
  mockData: effectiveMockData,
39014
39037
  pageName: currentPage,
39015
39038
  onNavigate: handleNavigate,
39016
- onLocalFallback: handleLocalFallback
39039
+ onLocalFallback: handleLocalFallback,
39040
+ persistence
39017
39041
  }
39018
39042
  ) }) })
39019
39043
  ]