@almadar/ui 4.15.5 → 4.16.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.
@@ -21998,6 +21998,17 @@ function DataGrid({
21998
21998
  };
21999
21999
  eventBus.emit(`UI:${action.event}`, payload);
22000
22000
  };
22001
+ const hasRenderProp = typeof children === "function";
22002
+ React127.useEffect(() => {
22003
+ if (data.length > 0 && !hasRenderProp && (!fields || fields.length === 0)) {
22004
+ const renderItemRaw = schemaRenderItem;
22005
+ const isFnLambda = Array.isArray(renderItemRaw) && renderItemRaw.length >= 3 && (renderItemRaw[0] === "fn" || renderItemRaw[0] === "lambda");
22006
+ dataGridLog.warn("renderItem-unresolved", {
22007
+ rowCount: data.length,
22008
+ renderItemIsFnLambda: isFnLambda
22009
+ });
22010
+ }
22011
+ }, [data, hasRenderProp, schemaRenderItem, fields]);
22001
22012
  const gridTemplateColumns = cols ? void 0 : `repeat(auto-fit, minmax(min(${minCardWidth}px, 100%), 1fr))`;
22002
22013
  const colsClass = cols ? {
22003
22014
  1: "grid-cols-1",
@@ -22016,17 +22027,6 @@ function DataGrid({
22016
22027
  if (data.length === 0) {
22017
22028
  return /* @__PURE__ */ jsxRuntime.jsx(Box, { className: "text-center py-12", children: /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "body", color: "secondary", children: t("empty.noItems") || "No items found" }) });
22018
22029
  }
22019
- const hasRenderProp = typeof children === "function";
22020
- React127.useEffect(() => {
22021
- if (data.length > 0 && !hasRenderProp && (!fields || fields.length === 0)) {
22022
- const renderItemRaw = schemaRenderItem;
22023
- const isFnLambda = Array.isArray(renderItemRaw) && renderItemRaw.length >= 3 && (renderItemRaw[0] === "fn" || renderItemRaw[0] === "lambda");
22024
- dataGridLog.warn("renderItem-unresolved", {
22025
- rowCount: data.length,
22026
- renderItemIsFnLambda: isFnLambda
22027
- });
22028
- }
22029
- }, [data, hasRenderProp, schemaRenderItem, fields]);
22030
22030
  const allIds = data.map((item, i) => item.id || String(i));
22031
22031
  const allSelected = allIds.length > 0 && allIds.every((id) => selectedIds.has(id));
22032
22032
  const someSelected = selectedIds.size > 0;
@@ -22926,7 +22926,7 @@ var init_FilterGroup = __esm({
22926
22926
  eventBus.emit("UI:FILTER", {
22927
22927
  entity,
22928
22928
  field,
22929
- value: value === "all" ? null : value,
22929
+ value: value === "all" || value === null ? "" : value,
22930
22930
  query
22931
22931
  });
22932
22932
  },
@@ -23738,7 +23738,7 @@ var init_SearchInput = __esm({
23738
23738
  /* @__PURE__ */ jsxRuntime.jsx(
23739
23739
  Input,
23740
23740
  {
23741
- type: "search",
23741
+ type: "text",
23742
23742
  value: searchValue,
23743
23743
  onChange: handleChange,
23744
23744
  placeholder: resolvedPlaceholder,
@@ -52070,10 +52070,6 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
52070
52070
  ...payload !== void 0 ? { payload } : {},
52071
52071
  timestamp: Date.now()
52072
52072
  };
52073
- const pdata = payload?.data;
52074
- if (Array.isArray(pdata) && binding.linkedEntity) {
52075
- snap.data[binding.linkedEntity] = pdata;
52076
- }
52077
52073
  const listensEntry = (binding.trait.listens ?? []).find(
52078
52074
  (l) => l.event === normalizedEvent || l.triggers === normalizedEvent
52079
52075
  );
@@ -52167,9 +52163,53 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
52167
52163
  notify: clientHandlers.notify
52168
52164
  };
52169
52165
  }
52166
+ const writeFetchResultToSnap = (fetchedEntityType, fetchResult) => {
52167
+ if (!fetchResult) return;
52168
+ const snapNow = traitSnapshotDataRef.current.get(traitName);
52169
+ if (!snapNow) return;
52170
+ const rows = Array.isArray(fetchResult.rows) ? fetchResult.rows : [fetchResult.rows];
52171
+ snapNow.data[fetchedEntityType] = rows;
52172
+ };
52173
+ const baseFetch = handlers.fetch;
52174
+ const baseRef = handlers.ref;
52175
+ const baseDeref = handlers.deref;
52176
+ handlers = {
52177
+ ...handlers,
52178
+ ...baseFetch ? {
52179
+ fetch: async (entityType, options2) => {
52180
+ const r2 = await baseFetch(entityType, options2);
52181
+ writeFetchResultToSnap(entityType, r2);
52182
+ return r2;
52183
+ }
52184
+ } : {},
52185
+ ...baseRef ? {
52186
+ ref: async (entityType, options2) => {
52187
+ const r2 = await baseRef(entityType, options2);
52188
+ writeFetchResultToSnap(entityType, r2);
52189
+ return r2;
52190
+ }
52191
+ } : {},
52192
+ ...baseDeref ? {
52193
+ deref: async (entityType, options2) => {
52194
+ const r2 = await baseDeref(entityType, options2);
52195
+ writeFetchResultToSnap(entityType, r2);
52196
+ return r2;
52197
+ }
52198
+ } : {}
52199
+ };
52170
52200
  const entityFromPayload = payload ?? {};
52201
+ const reducerSnap = traitSnapshotDataRef.current.get(traitName);
52202
+ const persistedRows = linkedEntity ? reducerSnap?.data[linkedEntity] : void 0;
52203
+ let entityForBinding = entityFromPayload;
52204
+ if (persistedRows && persistedRows.length > 0) {
52205
+ const hybrid = Object.assign(
52206
+ [...persistedRows],
52207
+ persistedRows[0]
52208
+ );
52209
+ entityForBinding = hybrid;
52210
+ }
52171
52211
  const bindingCtx = {
52172
- entity: entityFromPayload,
52212
+ entity: entityForBinding,
52173
52213
  payload: payload || {},
52174
52214
  state: result.previousState
52175
52215
  };
package/dist/avl/index.js CHANGED
@@ -21952,6 +21952,17 @@ function DataGrid({
21952
21952
  };
21953
21953
  eventBus.emit(`UI:${action.event}`, payload);
21954
21954
  };
21955
+ const hasRenderProp = typeof children === "function";
21956
+ useEffect(() => {
21957
+ if (data.length > 0 && !hasRenderProp && (!fields || fields.length === 0)) {
21958
+ const renderItemRaw = schemaRenderItem;
21959
+ const isFnLambda = Array.isArray(renderItemRaw) && renderItemRaw.length >= 3 && (renderItemRaw[0] === "fn" || renderItemRaw[0] === "lambda");
21960
+ dataGridLog.warn("renderItem-unresolved", {
21961
+ rowCount: data.length,
21962
+ renderItemIsFnLambda: isFnLambda
21963
+ });
21964
+ }
21965
+ }, [data, hasRenderProp, schemaRenderItem, fields]);
21955
21966
  const gridTemplateColumns = cols ? void 0 : `repeat(auto-fit, minmax(min(${minCardWidth}px, 100%), 1fr))`;
21956
21967
  const colsClass = cols ? {
21957
21968
  1: "grid-cols-1",
@@ -21970,17 +21981,6 @@ function DataGrid({
21970
21981
  if (data.length === 0) {
21971
21982
  return /* @__PURE__ */ jsx(Box, { className: "text-center py-12", children: /* @__PURE__ */ jsx(Typography, { variant: "body", color: "secondary", children: t("empty.noItems") || "No items found" }) });
21972
21983
  }
21973
- const hasRenderProp = typeof children === "function";
21974
- useEffect(() => {
21975
- if (data.length > 0 && !hasRenderProp && (!fields || fields.length === 0)) {
21976
- const renderItemRaw = schemaRenderItem;
21977
- const isFnLambda = Array.isArray(renderItemRaw) && renderItemRaw.length >= 3 && (renderItemRaw[0] === "fn" || renderItemRaw[0] === "lambda");
21978
- dataGridLog.warn("renderItem-unresolved", {
21979
- rowCount: data.length,
21980
- renderItemIsFnLambda: isFnLambda
21981
- });
21982
- }
21983
- }, [data, hasRenderProp, schemaRenderItem, fields]);
21984
21984
  const allIds = data.map((item, i) => item.id || String(i));
21985
21985
  const allSelected = allIds.length > 0 && allIds.every((id) => selectedIds.has(id));
21986
21986
  const someSelected = selectedIds.size > 0;
@@ -22880,7 +22880,7 @@ var init_FilterGroup = __esm({
22880
22880
  eventBus.emit("UI:FILTER", {
22881
22881
  entity,
22882
22882
  field,
22883
- value: value === "all" ? null : value,
22883
+ value: value === "all" || value === null ? "" : value,
22884
22884
  query
22885
22885
  });
22886
22886
  },
@@ -23692,7 +23692,7 @@ var init_SearchInput = __esm({
23692
23692
  /* @__PURE__ */ jsx(
23693
23693
  Input,
23694
23694
  {
23695
- type: "search",
23695
+ type: "text",
23696
23696
  value: searchValue,
23697
23697
  onChange: handleChange,
23698
23698
  placeholder: resolvedPlaceholder,
@@ -52024,10 +52024,6 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
52024
52024
  ...payload !== void 0 ? { payload } : {},
52025
52025
  timestamp: Date.now()
52026
52026
  };
52027
- const pdata = payload?.data;
52028
- if (Array.isArray(pdata) && binding.linkedEntity) {
52029
- snap.data[binding.linkedEntity] = pdata;
52030
- }
52031
52027
  const listensEntry = (binding.trait.listens ?? []).find(
52032
52028
  (l) => l.event === normalizedEvent || l.triggers === normalizedEvent
52033
52029
  );
@@ -52121,9 +52117,53 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
52121
52117
  notify: clientHandlers.notify
52122
52118
  };
52123
52119
  }
52120
+ const writeFetchResultToSnap = (fetchedEntityType, fetchResult) => {
52121
+ if (!fetchResult) return;
52122
+ const snapNow = traitSnapshotDataRef.current.get(traitName);
52123
+ if (!snapNow) return;
52124
+ const rows = Array.isArray(fetchResult.rows) ? fetchResult.rows : [fetchResult.rows];
52125
+ snapNow.data[fetchedEntityType] = rows;
52126
+ };
52127
+ const baseFetch = handlers.fetch;
52128
+ const baseRef = handlers.ref;
52129
+ const baseDeref = handlers.deref;
52130
+ handlers = {
52131
+ ...handlers,
52132
+ ...baseFetch ? {
52133
+ fetch: async (entityType, options2) => {
52134
+ const r2 = await baseFetch(entityType, options2);
52135
+ writeFetchResultToSnap(entityType, r2);
52136
+ return r2;
52137
+ }
52138
+ } : {},
52139
+ ...baseRef ? {
52140
+ ref: async (entityType, options2) => {
52141
+ const r2 = await baseRef(entityType, options2);
52142
+ writeFetchResultToSnap(entityType, r2);
52143
+ return r2;
52144
+ }
52145
+ } : {},
52146
+ ...baseDeref ? {
52147
+ deref: async (entityType, options2) => {
52148
+ const r2 = await baseDeref(entityType, options2);
52149
+ writeFetchResultToSnap(entityType, r2);
52150
+ return r2;
52151
+ }
52152
+ } : {}
52153
+ };
52124
52154
  const entityFromPayload = payload ?? {};
52155
+ const reducerSnap = traitSnapshotDataRef.current.get(traitName);
52156
+ const persistedRows = linkedEntity ? reducerSnap?.data[linkedEntity] : void 0;
52157
+ let entityForBinding = entityFromPayload;
52158
+ if (persistedRows && persistedRows.length > 0) {
52159
+ const hybrid = Object.assign(
52160
+ [...persistedRows],
52161
+ persistedRows[0]
52162
+ );
52163
+ entityForBinding = hybrid;
52164
+ }
52125
52165
  const bindingCtx = {
52126
- entity: entityFromPayload,
52166
+ entity: entityForBinding,
52127
52167
  payload: payload || {},
52128
52168
  state: result.previousState
52129
52169
  };
@@ -17426,6 +17426,17 @@ function DataGrid({
17426
17426
  };
17427
17427
  eventBus.emit(`UI:${action.event}`, payload);
17428
17428
  };
17429
+ const hasRenderProp = typeof children === "function";
17430
+ React110.useEffect(() => {
17431
+ if (data.length > 0 && !hasRenderProp && (!fields || fields.length === 0)) {
17432
+ const renderItemRaw = schemaRenderItem;
17433
+ const isFnLambda = Array.isArray(renderItemRaw) && renderItemRaw.length >= 3 && (renderItemRaw[0] === "fn" || renderItemRaw[0] === "lambda");
17434
+ dataGridLog.warn("renderItem-unresolved", {
17435
+ rowCount: data.length,
17436
+ renderItemIsFnLambda: isFnLambda
17437
+ });
17438
+ }
17439
+ }, [data, hasRenderProp, schemaRenderItem, fields]);
17429
17440
  const gridTemplateColumns = cols ? void 0 : `repeat(auto-fit, minmax(min(${minCardWidth}px, 100%), 1fr))`;
17430
17441
  const colsClass = cols ? {
17431
17442
  1: "grid-cols-1",
@@ -17444,17 +17455,6 @@ function DataGrid({
17444
17455
  if (data.length === 0) {
17445
17456
  return /* @__PURE__ */ jsxRuntime.jsx(exports.Box, { className: "text-center py-12", children: /* @__PURE__ */ jsxRuntime.jsx(exports.Typography, { variant: "body", color: "secondary", children: t("empty.noItems") || "No items found" }) });
17446
17457
  }
17447
- const hasRenderProp = typeof children === "function";
17448
- React110.useEffect(() => {
17449
- if (data.length > 0 && !hasRenderProp && (!fields || fields.length === 0)) {
17450
- const renderItemRaw = schemaRenderItem;
17451
- const isFnLambda = Array.isArray(renderItemRaw) && renderItemRaw.length >= 3 && (renderItemRaw[0] === "fn" || renderItemRaw[0] === "lambda");
17452
- dataGridLog.warn("renderItem-unresolved", {
17453
- rowCount: data.length,
17454
- renderItemIsFnLambda: isFnLambda
17455
- });
17456
- }
17457
- }, [data, hasRenderProp, schemaRenderItem, fields]);
17458
17458
  const allIds = data.map((item, i) => item.id || String(i));
17459
17459
  const allSelected = allIds.length > 0 && allIds.every((id) => selectedIds.has(id));
17460
17460
  const someSelected = selectedIds.size > 0;
@@ -18362,7 +18362,7 @@ var init_FilterGroup = __esm({
18362
18362
  eventBus.emit("UI:FILTER", {
18363
18363
  entity,
18364
18364
  field,
18365
- value: value === "all" ? null : value,
18365
+ value: value === "all" || value === null ? "" : value,
18366
18366
  query
18367
18367
  });
18368
18368
  },
@@ -19174,7 +19174,7 @@ var init_SearchInput = __esm({
19174
19174
  /* @__PURE__ */ jsxRuntime.jsx(
19175
19175
  exports.Input,
19176
19176
  {
19177
- type: "search",
19177
+ type: "text",
19178
19178
  value: searchValue,
19179
19179
  onChange: handleChange,
19180
19180
  placeholder: resolvedPlaceholder,
@@ -17381,6 +17381,17 @@ function DataGrid({
17381
17381
  };
17382
17382
  eventBus.emit(`UI:${action.event}`, payload);
17383
17383
  };
17384
+ const hasRenderProp = typeof children === "function";
17385
+ useEffect(() => {
17386
+ if (data.length > 0 && !hasRenderProp && (!fields || fields.length === 0)) {
17387
+ const renderItemRaw = schemaRenderItem;
17388
+ const isFnLambda = Array.isArray(renderItemRaw) && renderItemRaw.length >= 3 && (renderItemRaw[0] === "fn" || renderItemRaw[0] === "lambda");
17389
+ dataGridLog.warn("renderItem-unresolved", {
17390
+ rowCount: data.length,
17391
+ renderItemIsFnLambda: isFnLambda
17392
+ });
17393
+ }
17394
+ }, [data, hasRenderProp, schemaRenderItem, fields]);
17384
17395
  const gridTemplateColumns = cols ? void 0 : `repeat(auto-fit, minmax(min(${minCardWidth}px, 100%), 1fr))`;
17385
17396
  const colsClass = cols ? {
17386
17397
  1: "grid-cols-1",
@@ -17399,17 +17410,6 @@ function DataGrid({
17399
17410
  if (data.length === 0) {
17400
17411
  return /* @__PURE__ */ jsx(Box, { className: "text-center py-12", children: /* @__PURE__ */ jsx(Typography, { variant: "body", color: "secondary", children: t("empty.noItems") || "No items found" }) });
17401
17412
  }
17402
- const hasRenderProp = typeof children === "function";
17403
- useEffect(() => {
17404
- if (data.length > 0 && !hasRenderProp && (!fields || fields.length === 0)) {
17405
- const renderItemRaw = schemaRenderItem;
17406
- const isFnLambda = Array.isArray(renderItemRaw) && renderItemRaw.length >= 3 && (renderItemRaw[0] === "fn" || renderItemRaw[0] === "lambda");
17407
- dataGridLog.warn("renderItem-unresolved", {
17408
- rowCount: data.length,
17409
- renderItemIsFnLambda: isFnLambda
17410
- });
17411
- }
17412
- }, [data, hasRenderProp, schemaRenderItem, fields]);
17413
17413
  const allIds = data.map((item, i) => item.id || String(i));
17414
17414
  const allSelected = allIds.length > 0 && allIds.every((id) => selectedIds.has(id));
17415
17415
  const someSelected = selectedIds.size > 0;
@@ -18317,7 +18317,7 @@ var init_FilterGroup = __esm({
18317
18317
  eventBus.emit("UI:FILTER", {
18318
18318
  entity,
18319
18319
  field,
18320
- value: value === "all" ? null : value,
18320
+ value: value === "all" || value === null ? "" : value,
18321
18321
  query
18322
18322
  });
18323
18323
  },
@@ -19129,7 +19129,7 @@ var init_SearchInput = __esm({
19129
19129
  /* @__PURE__ */ jsx(
19130
19130
  Input,
19131
19131
  {
19132
- type: "search",
19132
+ type: "text",
19133
19133
  value: searchValue,
19134
19134
  onChange: handleChange,
19135
19135
  placeholder: resolvedPlaceholder,
@@ -18749,6 +18749,17 @@ function DataGrid({
18749
18749
  };
18750
18750
  eventBus.emit(`UI:${action.event}`, payload);
18751
18751
  };
18752
+ const hasRenderProp = typeof children === "function";
18753
+ React115.useEffect(() => {
18754
+ if (data.length > 0 && !hasRenderProp && (!fields || fields.length === 0)) {
18755
+ const renderItemRaw = schemaRenderItem;
18756
+ const isFnLambda = Array.isArray(renderItemRaw) && renderItemRaw.length >= 3 && (renderItemRaw[0] === "fn" || renderItemRaw[0] === "lambda");
18757
+ dataGridLog.warn("renderItem-unresolved", {
18758
+ rowCount: data.length,
18759
+ renderItemIsFnLambda: isFnLambda
18760
+ });
18761
+ }
18762
+ }, [data, hasRenderProp, schemaRenderItem, fields]);
18752
18763
  const gridTemplateColumns = cols ? void 0 : `repeat(auto-fit, minmax(min(${minCardWidth}px, 100%), 1fr))`;
18753
18764
  const colsClass = cols ? {
18754
18765
  1: "grid-cols-1",
@@ -18767,17 +18778,6 @@ function DataGrid({
18767
18778
  if (data.length === 0) {
18768
18779
  return /* @__PURE__ */ jsxRuntime.jsx(Box, { className: "text-center py-12", children: /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "body", color: "secondary", children: t("empty.noItems") || "No items found" }) });
18769
18780
  }
18770
- const hasRenderProp = typeof children === "function";
18771
- React115.useEffect(() => {
18772
- if (data.length > 0 && !hasRenderProp && (!fields || fields.length === 0)) {
18773
- const renderItemRaw = schemaRenderItem;
18774
- const isFnLambda = Array.isArray(renderItemRaw) && renderItemRaw.length >= 3 && (renderItemRaw[0] === "fn" || renderItemRaw[0] === "lambda");
18775
- dataGridLog.warn("renderItem-unresolved", {
18776
- rowCount: data.length,
18777
- renderItemIsFnLambda: isFnLambda
18778
- });
18779
- }
18780
- }, [data, hasRenderProp, schemaRenderItem, fields]);
18781
18781
  const allIds = data.map((item, i) => item.id || String(i));
18782
18782
  const allSelected = allIds.length > 0 && allIds.every((id) => selectedIds.has(id));
18783
18783
  const someSelected = selectedIds.size > 0;
@@ -19677,7 +19677,7 @@ var init_FilterGroup = __esm({
19677
19677
  eventBus.emit("UI:FILTER", {
19678
19678
  entity,
19679
19679
  field,
19680
- value: value === "all" ? null : value,
19680
+ value: value === "all" || value === null ? "" : value,
19681
19681
  query
19682
19682
  });
19683
19683
  },
@@ -20489,7 +20489,7 @@ var init_SearchInput = __esm({
20489
20489
  /* @__PURE__ */ jsxRuntime.jsx(
20490
20490
  Input,
20491
20491
  {
20492
- type: "search",
20492
+ type: "text",
20493
20493
  value: searchValue,
20494
20494
  onChange: handleChange,
20495
20495
  placeholder: resolvedPlaceholder,
@@ -18704,6 +18704,17 @@ function DataGrid({
18704
18704
  };
18705
18705
  eventBus.emit(`UI:${action.event}`, payload);
18706
18706
  };
18707
+ const hasRenderProp = typeof children === "function";
18708
+ useEffect(() => {
18709
+ if (data.length > 0 && !hasRenderProp && (!fields || fields.length === 0)) {
18710
+ const renderItemRaw = schemaRenderItem;
18711
+ const isFnLambda = Array.isArray(renderItemRaw) && renderItemRaw.length >= 3 && (renderItemRaw[0] === "fn" || renderItemRaw[0] === "lambda");
18712
+ dataGridLog.warn("renderItem-unresolved", {
18713
+ rowCount: data.length,
18714
+ renderItemIsFnLambda: isFnLambda
18715
+ });
18716
+ }
18717
+ }, [data, hasRenderProp, schemaRenderItem, fields]);
18707
18718
  const gridTemplateColumns = cols ? void 0 : `repeat(auto-fit, minmax(min(${minCardWidth}px, 100%), 1fr))`;
18708
18719
  const colsClass = cols ? {
18709
18720
  1: "grid-cols-1",
@@ -18722,17 +18733,6 @@ function DataGrid({
18722
18733
  if (data.length === 0) {
18723
18734
  return /* @__PURE__ */ jsx(Box, { className: "text-center py-12", children: /* @__PURE__ */ jsx(Typography, { variant: "body", color: "secondary", children: t("empty.noItems") || "No items found" }) });
18724
18735
  }
18725
- const hasRenderProp = typeof children === "function";
18726
- useEffect(() => {
18727
- if (data.length > 0 && !hasRenderProp && (!fields || fields.length === 0)) {
18728
- const renderItemRaw = schemaRenderItem;
18729
- const isFnLambda = Array.isArray(renderItemRaw) && renderItemRaw.length >= 3 && (renderItemRaw[0] === "fn" || renderItemRaw[0] === "lambda");
18730
- dataGridLog.warn("renderItem-unresolved", {
18731
- rowCount: data.length,
18732
- renderItemIsFnLambda: isFnLambda
18733
- });
18734
- }
18735
- }, [data, hasRenderProp, schemaRenderItem, fields]);
18736
18736
  const allIds = data.map((item, i) => item.id || String(i));
18737
18737
  const allSelected = allIds.length > 0 && allIds.every((id) => selectedIds.has(id));
18738
18738
  const someSelected = selectedIds.size > 0;
@@ -19632,7 +19632,7 @@ var init_FilterGroup = __esm({
19632
19632
  eventBus.emit("UI:FILTER", {
19633
19633
  entity,
19634
19634
  field,
19635
- value: value === "all" ? null : value,
19635
+ value: value === "all" || value === null ? "" : value,
19636
19636
  query
19637
19637
  });
19638
19638
  },
@@ -20444,7 +20444,7 @@ var init_SearchInput = __esm({
20444
20444
  /* @__PURE__ */ jsx(
20445
20445
  Input,
20446
20446
  {
20447
- type: "search",
20447
+ type: "text",
20448
20448
  value: searchValue,
20449
20449
  onChange: handleChange,
20450
20450
  placeholder: resolvedPlaceholder,
@@ -18525,6 +18525,17 @@ function DataGrid({
18525
18525
  };
18526
18526
  eventBus.emit(`UI:${action.event}`, payload);
18527
18527
  };
18528
+ const hasRenderProp = typeof children === "function";
18529
+ React113.useEffect(() => {
18530
+ if (data.length > 0 && !hasRenderProp && (!fields || fields.length === 0)) {
18531
+ const renderItemRaw = schemaRenderItem;
18532
+ const isFnLambda = Array.isArray(renderItemRaw) && renderItemRaw.length >= 3 && (renderItemRaw[0] === "fn" || renderItemRaw[0] === "lambda");
18533
+ dataGridLog.warn("renderItem-unresolved", {
18534
+ rowCount: data.length,
18535
+ renderItemIsFnLambda: isFnLambda
18536
+ });
18537
+ }
18538
+ }, [data, hasRenderProp, schemaRenderItem, fields]);
18528
18539
  const gridTemplateColumns = cols ? void 0 : `repeat(auto-fit, minmax(min(${minCardWidth}px, 100%), 1fr))`;
18529
18540
  const colsClass = cols ? {
18530
18541
  1: "grid-cols-1",
@@ -18543,17 +18554,6 @@ function DataGrid({
18543
18554
  if (data.length === 0) {
18544
18555
  return /* @__PURE__ */ jsxRuntime.jsx(Box, { className: "text-center py-12", children: /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "body", color: "secondary", children: t("empty.noItems") || "No items found" }) });
18545
18556
  }
18546
- const hasRenderProp = typeof children === "function";
18547
- React113.useEffect(() => {
18548
- if (data.length > 0 && !hasRenderProp && (!fields || fields.length === 0)) {
18549
- const renderItemRaw = schemaRenderItem;
18550
- const isFnLambda = Array.isArray(renderItemRaw) && renderItemRaw.length >= 3 && (renderItemRaw[0] === "fn" || renderItemRaw[0] === "lambda");
18551
- dataGridLog.warn("renderItem-unresolved", {
18552
- rowCount: data.length,
18553
- renderItemIsFnLambda: isFnLambda
18554
- });
18555
- }
18556
- }, [data, hasRenderProp, schemaRenderItem, fields]);
18557
18557
  const allIds = data.map((item, i) => item.id || String(i));
18558
18558
  const allSelected = allIds.length > 0 && allIds.every((id) => selectedIds.has(id));
18559
18559
  const someSelected = selectedIds.size > 0;
@@ -19389,7 +19389,7 @@ var init_FilterGroup = __esm({
19389
19389
  eventBus.emit("UI:FILTER", {
19390
19390
  entity,
19391
19391
  field,
19392
- value: value === "all" ? null : value,
19392
+ value: value === "all" || value === null ? "" : value,
19393
19393
  query
19394
19394
  });
19395
19395
  },
@@ -20201,7 +20201,7 @@ var init_SearchInput = __esm({
20201
20201
  /* @__PURE__ */ jsxRuntime.jsx(
20202
20202
  Input,
20203
20203
  {
20204
- type: "search",
20204
+ type: "text",
20205
20205
  value: searchValue,
20206
20206
  onChange: handleChange,
20207
20207
  placeholder: resolvedPlaceholder,
@@ -38597,10 +38597,6 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
38597
38597
  ...payload !== void 0 ? { payload } : {},
38598
38598
  timestamp: Date.now()
38599
38599
  };
38600
- const pdata = payload?.data;
38601
- if (Array.isArray(pdata) && binding.linkedEntity) {
38602
- snap.data[binding.linkedEntity] = pdata;
38603
- }
38604
38600
  const listensEntry = (binding.trait.listens ?? []).find(
38605
38601
  (l) => l.event === normalizedEvent || l.triggers === normalizedEvent
38606
38602
  );
@@ -38694,9 +38690,53 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
38694
38690
  notify: clientHandlers.notify
38695
38691
  };
38696
38692
  }
38693
+ const writeFetchResultToSnap = (fetchedEntityType, fetchResult) => {
38694
+ if (!fetchResult) return;
38695
+ const snapNow = traitSnapshotDataRef.current.get(traitName);
38696
+ if (!snapNow) return;
38697
+ const rows = Array.isArray(fetchResult.rows) ? fetchResult.rows : [fetchResult.rows];
38698
+ snapNow.data[fetchedEntityType] = rows;
38699
+ };
38700
+ const baseFetch = handlers.fetch;
38701
+ const baseRef = handlers.ref;
38702
+ const baseDeref = handlers.deref;
38703
+ handlers = {
38704
+ ...handlers,
38705
+ ...baseFetch ? {
38706
+ fetch: async (entityType, options2) => {
38707
+ const r = await baseFetch(entityType, options2);
38708
+ writeFetchResultToSnap(entityType, r);
38709
+ return r;
38710
+ }
38711
+ } : {},
38712
+ ...baseRef ? {
38713
+ ref: async (entityType, options2) => {
38714
+ const r = await baseRef(entityType, options2);
38715
+ writeFetchResultToSnap(entityType, r);
38716
+ return r;
38717
+ }
38718
+ } : {},
38719
+ ...baseDeref ? {
38720
+ deref: async (entityType, options2) => {
38721
+ const r = await baseDeref(entityType, options2);
38722
+ writeFetchResultToSnap(entityType, r);
38723
+ return r;
38724
+ }
38725
+ } : {}
38726
+ };
38697
38727
  const entityFromPayload = payload ?? {};
38728
+ const reducerSnap = traitSnapshotDataRef.current.get(traitName);
38729
+ const persistedRows = linkedEntity ? reducerSnap?.data[linkedEntity] : void 0;
38730
+ let entityForBinding = entityFromPayload;
38731
+ if (persistedRows && persistedRows.length > 0) {
38732
+ const hybrid = Object.assign(
38733
+ [...persistedRows],
38734
+ persistedRows[0]
38735
+ );
38736
+ entityForBinding = hybrid;
38737
+ }
38698
38738
  const bindingCtx = {
38699
- entity: entityFromPayload,
38739
+ entity: entityForBinding,
38700
38740
  payload: payload || {},
38701
38741
  state: result.previousState
38702
38742
  };
@@ -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,
@@ -38552,10 +38552,6 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
38552
38552
  ...payload !== void 0 ? { payload } : {},
38553
38553
  timestamp: Date.now()
38554
38554
  };
38555
- const pdata = payload?.data;
38556
- if (Array.isArray(pdata) && binding.linkedEntity) {
38557
- snap.data[binding.linkedEntity] = pdata;
38558
- }
38559
38555
  const listensEntry = (binding.trait.listens ?? []).find(
38560
38556
  (l) => l.event === normalizedEvent || l.triggers === normalizedEvent
38561
38557
  );
@@ -38649,9 +38645,53 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
38649
38645
  notify: clientHandlers.notify
38650
38646
  };
38651
38647
  }
38648
+ const writeFetchResultToSnap = (fetchedEntityType, fetchResult) => {
38649
+ if (!fetchResult) return;
38650
+ const snapNow = traitSnapshotDataRef.current.get(traitName);
38651
+ if (!snapNow) return;
38652
+ const rows = Array.isArray(fetchResult.rows) ? fetchResult.rows : [fetchResult.rows];
38653
+ snapNow.data[fetchedEntityType] = rows;
38654
+ };
38655
+ const baseFetch = handlers.fetch;
38656
+ const baseRef = handlers.ref;
38657
+ const baseDeref = handlers.deref;
38658
+ handlers = {
38659
+ ...handlers,
38660
+ ...baseFetch ? {
38661
+ fetch: async (entityType, options2) => {
38662
+ const r = await baseFetch(entityType, options2);
38663
+ writeFetchResultToSnap(entityType, r);
38664
+ return r;
38665
+ }
38666
+ } : {},
38667
+ ...baseRef ? {
38668
+ ref: async (entityType, options2) => {
38669
+ const r = await baseRef(entityType, options2);
38670
+ writeFetchResultToSnap(entityType, r);
38671
+ return r;
38672
+ }
38673
+ } : {},
38674
+ ...baseDeref ? {
38675
+ deref: async (entityType, options2) => {
38676
+ const r = await baseDeref(entityType, options2);
38677
+ writeFetchResultToSnap(entityType, r);
38678
+ return r;
38679
+ }
38680
+ } : {}
38681
+ };
38652
38682
  const entityFromPayload = payload ?? {};
38683
+ const reducerSnap = traitSnapshotDataRef.current.get(traitName);
38684
+ const persistedRows = linkedEntity ? reducerSnap?.data[linkedEntity] : void 0;
38685
+ let entityForBinding = entityFromPayload;
38686
+ if (persistedRows && persistedRows.length > 0) {
38687
+ const hybrid = Object.assign(
38688
+ [...persistedRows],
38689
+ persistedRows[0]
38690
+ );
38691
+ entityForBinding = hybrid;
38692
+ }
38653
38693
  const bindingCtx = {
38654
- entity: entityFromPayload,
38694
+ entity: entityForBinding,
38655
38695
  payload: payload || {},
38656
38696
  state: result.previousState
38657
38697
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/ui",
3
- "version": "4.15.5",
3
+ "version": "4.16.0",
4
4
  "description": "React UI components, hooks, and providers for Almadar",
5
5
  "type": "module",
6
6
  "main": "./dist/components/index.js",
@@ -118,10 +118,10 @@
118
118
  "access": "public"
119
119
  },
120
120
  "dependencies": {
121
- "@almadar/core": "^7.5.1",
121
+ "@almadar/core": "^7.7.1",
122
122
  "@almadar/evaluator": ">=2.9.2",
123
123
  "@almadar/patterns": ">=2.17.1",
124
- "@almadar/runtime": "^5.8.4",
124
+ "@almadar/runtime": "^5.11.1",
125
125
  "@almadar/std": ">=6.4.1",
126
126
  "@almadar/syntax": ">=1.3.1",
127
127
  "@xyflow/react": "12.10.1",