@almadar/ui 4.15.6 → 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.
@@ -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
@@ -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
  };
@@ -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
  };
@@ -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.6",
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",