@almadar/ui 2.9.3 → 2.9.4
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.
- package/dist/runtime/index.js +21 -2
- package/package.json +1 -1
package/dist/runtime/index.js
CHANGED
|
@@ -193,15 +193,34 @@ function useTraitStateMachine(traitBindings, slotsActions, options) {
|
|
|
193
193
|
enriched = { ...rec, children: enrichedChildren };
|
|
194
194
|
}
|
|
195
195
|
if (nodeType && isEntityAwarePattern(nodeType) && fetchedDataContext) {
|
|
196
|
+
let injected = false;
|
|
196
197
|
if (typeof enriched.entity === "string") {
|
|
197
198
|
const records = fetchedDataContext.getData(enriched.entity);
|
|
198
199
|
if (records.length > 0) {
|
|
199
|
-
|
|
200
|
+
enriched = { ...enriched, entity: records };
|
|
201
|
+
injected = true;
|
|
200
202
|
}
|
|
201
203
|
} else if (!enriched.entity && linkedEntity) {
|
|
202
204
|
const records = fetchedDataContext.getData(linkedEntity);
|
|
203
205
|
if (records.length > 0) {
|
|
204
|
-
|
|
206
|
+
enriched = { ...enriched, entity: records };
|
|
207
|
+
injected = true;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (injected && !enriched.fields && !enriched.columns) {
|
|
211
|
+
const sample = enriched.entity[0];
|
|
212
|
+
if (sample && typeof sample === "object") {
|
|
213
|
+
const keys = Object.keys(sample).filter((k) => k !== "id" && k !== "_id");
|
|
214
|
+
enriched = {
|
|
215
|
+
...enriched,
|
|
216
|
+
fields: keys.map((k, i) => ({
|
|
217
|
+
name: k,
|
|
218
|
+
variant: i === 0 ? "h4" : "body"
|
|
219
|
+
})),
|
|
220
|
+
// Remove pattern-config children that components
|
|
221
|
+
// can't render (they expect a function or nothing)
|
|
222
|
+
children: void 0
|
|
223
|
+
};
|
|
205
224
|
}
|
|
206
225
|
}
|
|
207
226
|
}
|