@amplifyup/sdk 0.1.13 → 0.1.14
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/AmplifyRenderer.js +11 -6
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +11 -6
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/react.js +11 -6
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +11 -6
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/AmplifyRenderer.mjs
CHANGED
|
@@ -2059,7 +2059,9 @@ function AmplifyRenderer({
|
|
|
2059
2059
|
if (!pageConfig) {
|
|
2060
2060
|
return;
|
|
2061
2061
|
}
|
|
2062
|
-
|
|
2062
|
+
const rawTree2 = pageConfig.layoutTree;
|
|
2063
|
+
const normalizedTree = Array.isArray(rawTree2) ? rawTree2 : rawTree2 && typeof rawTree2 === "object" && rawTree2.componentId ? [rawTree2] : [];
|
|
2064
|
+
if (normalizedTree.length === 0) {
|
|
2063
2065
|
if (typeof window !== "undefined" && window.parent && window.parent !== window) {
|
|
2064
2066
|
window.parent.postMessage({
|
|
2065
2067
|
type: "COMPONENT_TREE",
|
|
@@ -2071,6 +2073,7 @@ function AmplifyRenderer({
|
|
|
2071
2073
|
const convertLayoutTreeToComponentTree = (nodes, parentId = null) => {
|
|
2072
2074
|
const result = [];
|
|
2073
2075
|
nodes.forEach((node) => {
|
|
2076
|
+
if (!node) return;
|
|
2074
2077
|
const treeNode = {
|
|
2075
2078
|
id: node.id,
|
|
2076
2079
|
componentId: node.componentId,
|
|
@@ -2081,8 +2084,9 @@ function AmplifyRenderer({
|
|
|
2081
2084
|
};
|
|
2082
2085
|
if (node.slots && node.slots.length > 0) {
|
|
2083
2086
|
node.slots.forEach((slot) => {
|
|
2084
|
-
|
|
2085
|
-
|
|
2087
|
+
const kids = Array.isArray(slot?.children) ? slot.children : [];
|
|
2088
|
+
if (kids.length > 0) {
|
|
2089
|
+
const slotChildren = convertLayoutTreeToComponentTree(kids, node.id);
|
|
2086
2090
|
treeNode.children.push(...slotChildren);
|
|
2087
2091
|
}
|
|
2088
2092
|
});
|
|
@@ -2091,7 +2095,7 @@ function AmplifyRenderer({
|
|
|
2091
2095
|
});
|
|
2092
2096
|
return result;
|
|
2093
2097
|
};
|
|
2094
|
-
const layoutTree2 =
|
|
2098
|
+
const layoutTree2 = normalizedTree;
|
|
2095
2099
|
const componentTree = convertLayoutTreeToComponentTree(layoutTree2);
|
|
2096
2100
|
const describeLayoutTree = (nodes, depth = 0) => {
|
|
2097
2101
|
if (!nodes?.length) return "";
|
|
@@ -2264,11 +2268,12 @@ function AmplifyRenderer({
|
|
|
2264
2268
|
childrenCount: childrenToRender.length
|
|
2265
2269
|
});
|
|
2266
2270
|
} else {
|
|
2267
|
-
childrenToRender = slot.children;
|
|
2271
|
+
childrenToRender = Array.isArray(slot.children) ? slot.children : [];
|
|
2268
2272
|
console.log(`[AmplifyRenderer] Using direct children for slot ${slot.slotId}`, {
|
|
2269
2273
|
childrenCount: childrenToRender.length
|
|
2270
2274
|
});
|
|
2271
2275
|
}
|
|
2276
|
+
const safeChildren = Array.isArray(childrenToRender) ? childrenToRender : [];
|
|
2272
2277
|
slotChildren[slot.slotId] = /* @__PURE__ */ jsx(
|
|
2273
2278
|
"div",
|
|
2274
2279
|
{
|
|
@@ -2277,7 +2282,7 @@ function AmplifyRenderer({
|
|
|
2277
2282
|
"data-zone-id": slot.zoneId || void 0,
|
|
2278
2283
|
"data-parent-node-id": node.id,
|
|
2279
2284
|
"data-parent-component-id": node.componentId,
|
|
2280
|
-
children:
|
|
2285
|
+
children: safeChildren.filter(Boolean).map((child) => renderNode(child))
|
|
2281
2286
|
},
|
|
2282
2287
|
slot.slotId
|
|
2283
2288
|
);
|