@almadar/ui 2.9.1 → 2.9.3

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.
@@ -183,17 +183,31 @@ function useTraitStateMachine(traitBindings, slotsActions, options) {
183
183
  navigate: optionsRef.current?.navigate,
184
184
  notify: optionsRef.current?.notify,
185
185
  enrichPattern: (pattern) => {
186
- const patternType = pattern?.type;
187
- if (linkedEntity && patternType && isEntityAwarePattern(patternType)) {
188
- const patternRecord = pattern;
189
- if (!patternRecord.entity && fetchedDataContext) {
190
- const records = fetchedDataContext.getData(linkedEntity);
191
- if (records.length > 0) {
192
- return { type: patternType, ...patternRecord, entity: records };
186
+ const enrichNode = (node) => {
187
+ if (!node || typeof node !== "object") return node;
188
+ const rec = node;
189
+ const nodeType = rec.type;
190
+ let enriched = rec;
191
+ if (Array.isArray(rec.children)) {
192
+ const enrichedChildren = rec.children.map(enrichNode);
193
+ enriched = { ...rec, children: enrichedChildren };
194
+ }
195
+ if (nodeType && isEntityAwarePattern(nodeType) && fetchedDataContext) {
196
+ if (typeof enriched.entity === "string") {
197
+ const records = fetchedDataContext.getData(enriched.entity);
198
+ if (records.length > 0) {
199
+ return { ...enriched, entity: records };
200
+ }
201
+ } else if (!enriched.entity && linkedEntity) {
202
+ const records = fetchedDataContext.getData(linkedEntity);
203
+ if (records.length > 0) {
204
+ return { ...enriched, entity: records };
205
+ }
193
206
  }
194
207
  }
195
- }
196
- return pattern;
208
+ return enriched;
209
+ };
210
+ return enrichNode(pattern);
197
211
  }
198
212
  });
199
213
  const bindingCtx = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/ui",
3
- "version": "2.9.1",
3
+ "version": "2.9.3",
4
4
  "description": "React UI components, hooks, and providers for Almadar",
5
5
  "type": "module",
6
6
  "main": "./dist/components/index.js",