@almadar/ui 4.15.4 → 4.15.6

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.
@@ -2041,11 +2041,11 @@ function refId(obj) {
2041
2041
  refIds.set(obj, id);
2042
2042
  return id;
2043
2043
  }
2044
- var slotLog, refIds, nextRefId;
2044
+ var slotLog2, refIds, nextRefId;
2045
2045
  var init_slot_types = __esm({
2046
2046
  "runtime/ui/slot-types.ts"() {
2047
2047
  init_logger();
2048
- slotLog = createLogger("almadar:ui:slot-render");
2048
+ slotLog2 = createLogger("almadar:ui:slot-render");
2049
2049
  refIds = /* @__PURE__ */ new WeakMap();
2050
2050
  nextRefId = 1;
2051
2051
  }
@@ -18480,6 +18480,17 @@ function DataGrid({
18480
18480
  };
18481
18481
  eventBus.emit(`UI:${action.event}`, payload);
18482
18482
  };
18483
+ const hasRenderProp = typeof children === "function";
18484
+ useEffect(() => {
18485
+ if (data.length > 0 && !hasRenderProp && (!fields || fields.length === 0)) {
18486
+ const renderItemRaw = schemaRenderItem;
18487
+ const isFnLambda = Array.isArray(renderItemRaw) && renderItemRaw.length >= 3 && (renderItemRaw[0] === "fn" || renderItemRaw[0] === "lambda");
18488
+ dataGridLog.warn("renderItem-unresolved", {
18489
+ rowCount: data.length,
18490
+ renderItemIsFnLambda: isFnLambda
18491
+ });
18492
+ }
18493
+ }, [data, hasRenderProp, schemaRenderItem, fields]);
18483
18494
  const gridTemplateColumns = cols ? void 0 : `repeat(auto-fit, minmax(min(${minCardWidth}px, 100%), 1fr))`;
18484
18495
  const colsClass = cols ? {
18485
18496
  1: "grid-cols-1",
@@ -18498,17 +18509,6 @@ function DataGrid({
18498
18509
  if (data.length === 0) {
18499
18510
  return /* @__PURE__ */ jsx(Box, { className: "text-center py-12", children: /* @__PURE__ */ jsx(Typography, { variant: "body", color: "secondary", children: t("empty.noItems") || "No items found" }) });
18500
18511
  }
18501
- const hasRenderProp = typeof children === "function";
18502
- useEffect(() => {
18503
- if (data.length > 0 && !hasRenderProp && (!fields || fields.length === 0)) {
18504
- const renderItemRaw = schemaRenderItem;
18505
- const isFnLambda = Array.isArray(renderItemRaw) && renderItemRaw.length >= 3 && (renderItemRaw[0] === "fn" || renderItemRaw[0] === "lambda");
18506
- dataGridLog.warn("renderItem-unresolved", {
18507
- rowCount: data.length,
18508
- renderItemIsFnLambda: isFnLambda
18509
- });
18510
- }
18511
- }, [data, hasRenderProp, schemaRenderItem, fields]);
18512
18512
  const allIds = data.map((item, i) => item.id || String(i));
18513
18513
  const allSelected = allIds.length > 0 && allIds.every((id) => selectedIds.has(id));
18514
18514
  const someSelected = selectedIds.size > 0;
@@ -19344,7 +19344,7 @@ var init_FilterGroup = __esm({
19344
19344
  eventBus.emit("UI:FILTER", {
19345
19345
  entity,
19346
19346
  field,
19347
- value: value === "all" ? null : value,
19347
+ value: value === "all" || value === null ? "" : value,
19348
19348
  query
19349
19349
  });
19350
19350
  },
@@ -20156,7 +20156,7 @@ var init_SearchInput = __esm({
20156
20156
  /* @__PURE__ */ jsx(
20157
20157
  Input,
20158
20158
  {
20159
- type: "search",
20159
+ type: "text",
20160
20160
  value: searchValue,
20161
20161
  onChange: handleChange,
20162
20162
  placeholder: resolvedPlaceholder,
@@ -37835,7 +37835,7 @@ function SlotContentRenderer({
37835
37835
  }) {
37836
37836
  const entityProp = content.props.entity;
37837
37837
  if (content.pattern === "form-section") {
37838
- slotLog.debug("SlotContentRenderer:form-section-render", {
37838
+ slotLog2.debug("SlotContentRenderer:form-section-render", {
37839
37839
  contentId: content.id,
37840
37840
  sourceTrait: content.sourceTrait,
37841
37841
  entityRefId: refId(entityProp),
@@ -38046,6 +38046,10 @@ var init_UISlotRenderer = __esm({
38046
38046
 
38047
38047
  // hooks/index.ts
38048
38048
  init_useEventBus();
38049
+
38050
+ // hooks/useUISlots.ts
38051
+ init_logger();
38052
+ createLogger("almadar:ui:useUISlots");
38049
38053
  var ALL_SLOTS = [
38050
38054
  "main",
38051
38055
  "sidebar",
@@ -38248,6 +38252,7 @@ init_traitRegistry();
38248
38252
  init_verificationRegistry();
38249
38253
  var crossTraitLog = createLogger("almadar:ui:cross-trait");
38250
38254
  var flushLog = createLogger("almadar:ui:slot-flush");
38255
+ var stateLog = createLogger("almadar:ui:state-transitions");
38251
38256
  function toTraitDefinition(binding) {
38252
38257
  return {
38253
38258
  name: binding.trait.name,
@@ -38680,21 +38685,29 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
38680
38685
  const executor = new EffectExecutor({ handlers: trackingHandlers, bindings: bindingCtx, context: effectContext });
38681
38686
  try {
38682
38687
  await executor.executeAll(result.effects);
38683
- console.log(
38684
- "[TraitStateMachine] After executeAll, pendingSlots:",
38685
- Object.fromEntries(pendingSlots.entries())
38686
- );
38688
+ stateLog.info("transition:render-ui-dispatched", {
38689
+ traitName,
38690
+ fromState: result.previousState,
38691
+ toState: result.newState,
38692
+ event: eventKey,
38693
+ slotsTouched: Array.from(pendingSlots.keys()).join(","),
38694
+ patternTypes: Array.from(pendingSlots.entries()).map(
38695
+ ([slot, patterns]) => `${slot}:[${patterns.map((p2) => p2.pattern?.type ?? "null").join(",")}]`
38696
+ ).join(";")
38697
+ });
38687
38698
  void slotSource;
38688
38699
  for (const [slot, patterns] of pendingSlots) {
38689
38700
  flushSlot(traitName, slot, patterns);
38690
38701
  }
38691
38702
  } catch (error) {
38692
- console.error(
38693
- "[TraitStateMachine] Effect execution error:",
38694
- error,
38695
- "| effects:",
38696
- JSON.stringify(result.effects)
38697
- );
38703
+ stateLog.error("transition:effect-error", {
38704
+ traitName,
38705
+ fromState: result.previousState,
38706
+ toState: result.newState,
38707
+ event: eventKey,
38708
+ error: error instanceof Error ? error.message : String(error),
38709
+ effectCount: result.effects.length
38710
+ });
38698
38711
  }
38699
38712
  } else if (!result.executed) {
38700
38713
  if (result.guardResult === false) {
@@ -38840,13 +38853,20 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
38840
38853
  if (eventKey === "INIT" || eventKey === "LOAD" || eventKey === "$MOUNT") {
38841
38854
  continue;
38842
38855
  }
38843
- const unsub = eventBus.on(`UI:${orbitalName}.${traitName}.${eventKey}`, (event) => {
38856
+ const selfBusKey = `UI:${orbitalName}.${traitName}.${eventKey}`;
38857
+ crossTraitLog.debug("self:subscribe", { traitName, busKey: selfBusKey, eventKey });
38858
+ const unsub = eventBus.on(selfBusKey, (event) => {
38844
38859
  if (event.source && event.source.fromBridge) {
38860
+ crossTraitLog.debug("self:fire-skipped-bridge-echo", { traitName, busKey: selfBusKey, eventKey });
38845
38861
  return;
38846
38862
  }
38863
+ crossTraitLog.info("self:fire", { traitName, busKey: selfBusKey, eventKey });
38847
38864
  enqueueAndDrain(eventKey, event.payload);
38848
38865
  });
38849
- unsubscribes.push(unsub);
38866
+ unsubscribes.push(() => {
38867
+ crossTraitLog.debug("self:unsubscribe", { traitName, busKey: selfBusKey, eventKey });
38868
+ unsub();
38869
+ });
38850
38870
  }
38851
38871
  }
38852
38872
  for (const binding of traitBindings) {
@@ -38864,18 +38884,23 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
38864
38884
  const sourceOrbital = listen.source?.orbital ?? ownOrbital;
38865
38885
  if (!sourceOrbital) continue;
38866
38886
  const busKey = `UI:${sourceOrbital}.${sourceTrait}.${listen.event}`;
38867
- crossTraitLog.debug("listen:subscribed", { busKey, targetTrait: binding.trait.name, triggers: listen.triggers });
38887
+ crossTraitLog.debug("listen:subscribed", { busKey, targetTrait: binding.trait.name, sourceOrbital, sourceTrait, listenEvent: listen.event, triggers: listen.triggers });
38868
38888
  const unsub = eventBus.on(busKey, (event) => {
38869
38889
  crossTraitLog.info("listen:fired", { busKey, targetTrait: binding.trait.name, triggers: listen.triggers });
38870
38890
  enqueueAndDrain(listen.triggers, event.payload);
38871
38891
  });
38872
- unsubscribes.push(unsub);
38892
+ unsubscribes.push(() => {
38893
+ crossTraitLog.debug("listen:unsubscribe", { busKey, targetTrait: binding.trait.name, triggers: listen.triggers });
38894
+ unsub();
38895
+ });
38873
38896
  }
38874
38897
  }
38875
38898
  return () => {
38899
+ crossTraitLog.debug("cleanup:start", { unsubscribeCount: unsubscribes.length });
38876
38900
  for (const unsub of unsubscribes) {
38877
38901
  unsub();
38878
38902
  }
38903
+ crossTraitLog.debug("cleanup:done", {});
38879
38904
  };
38880
38905
  }, [traitBindings, eventBus, enqueueAndDrain]);
38881
38906
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/ui",
3
- "version": "4.15.4",
3
+ "version": "4.15.6",
4
4
  "description": "React UI components, hooks, and providers for Almadar",
5
5
  "type": "module",
6
6
  "main": "./dist/components/index.js",
@@ -121,7 +121,7 @@
121
121
  "@almadar/core": "^7.5.1",
122
122
  "@almadar/evaluator": ">=2.9.2",
123
123
  "@almadar/patterns": ">=2.17.1",
124
- "@almadar/runtime": "^5.8.3",
124
+ "@almadar/runtime": "^5.8.4",
125
125
  "@almadar/std": ">=6.4.1",
126
126
  "@almadar/syntax": ">=1.3.1",
127
127
  "@xyflow/react": "12.10.1",