@amplifyup/sdk 0.1.14 → 0.1.16
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.d.mts +6 -1
- package/dist/AmplifyRenderer.d.ts +6 -1
- package/dist/AmplifyRenderer.js +38 -5
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +39 -6
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.js +34 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -2
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +6 -1
- package/dist/react.d.ts +6 -1
- package/dist/react.js +41 -6
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +42 -7
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -27,7 +27,12 @@ interface AmplifyRendererProps {
|
|
|
27
27
|
* Optional empty state component (when no content is configured)
|
|
28
28
|
*/
|
|
29
29
|
emptyComponent?: ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* Force Composer page-slot wrapper (avoids SSR miss when window isn't available yet).
|
|
32
|
+
* When true, root components stay under [data-slot-source="page"] so hierarchy can climb to Page.
|
|
33
|
+
*/
|
|
34
|
+
composerPreview?: boolean;
|
|
30
35
|
}
|
|
31
|
-
declare function AmplifyRenderer({ renderComponent, pageConfig: serverPageConfig, loadingComponent, errorComponent, emptyComponent, }: AmplifyRendererProps): react_jsx_runtime.JSX.Element | null;
|
|
36
|
+
declare function AmplifyRenderer({ renderComponent, pageConfig: serverPageConfig, loadingComponent, errorComponent, emptyComponent, composerPreview, }: AmplifyRendererProps): react_jsx_runtime.JSX.Element | null;
|
|
32
37
|
|
|
33
38
|
export { AmplifyRenderer };
|
|
@@ -27,7 +27,12 @@ interface AmplifyRendererProps {
|
|
|
27
27
|
* Optional empty state component (when no content is configured)
|
|
28
28
|
*/
|
|
29
29
|
emptyComponent?: ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* Force Composer page-slot wrapper (avoids SSR miss when window isn't available yet).
|
|
32
|
+
* When true, root components stay under [data-slot-source="page"] so hierarchy can climb to Page.
|
|
33
|
+
*/
|
|
34
|
+
composerPreview?: boolean;
|
|
30
35
|
}
|
|
31
|
-
declare function AmplifyRenderer({ renderComponent, pageConfig: serverPageConfig, loadingComponent, errorComponent, emptyComponent, }: AmplifyRendererProps): react_jsx_runtime.JSX.Element | null;
|
|
36
|
+
declare function AmplifyRenderer({ renderComponent, pageConfig: serverPageConfig, loadingComponent, errorComponent, emptyComponent, composerPreview, }: AmplifyRendererProps): react_jsx_runtime.JSX.Element | null;
|
|
32
37
|
|
|
33
38
|
export { AmplifyRenderer };
|
package/dist/AmplifyRenderer.js
CHANGED
|
@@ -1225,6 +1225,11 @@ Available Console Commands:
|
|
|
1225
1225
|
`[data-node-id="${nodeId}"]`
|
|
1226
1226
|
);
|
|
1227
1227
|
}
|
|
1228
|
+
if (!element && slotName) {
|
|
1229
|
+
element = document.querySelector(
|
|
1230
|
+
`[data-slot-source="page"][data-slot-id="${slotName}"], [data-slot-source="page"][data-amplifyup-slot="${slotName}"]`
|
|
1231
|
+
);
|
|
1232
|
+
}
|
|
1228
1233
|
if (!element && slotName) {
|
|
1229
1234
|
element = document.querySelector(
|
|
1230
1235
|
`[data-amplifyup-slot="${slotName}"], [data-slot-id="${slotName}"]`
|
|
@@ -1257,12 +1262,28 @@ Available Console Commands:
|
|
|
1257
1262
|
height: rect.height
|
|
1258
1263
|
};
|
|
1259
1264
|
if (window.parent && window.parent !== window) {
|
|
1265
|
+
const hierarchyEls = this.buildComponentHierarchy(element);
|
|
1260
1266
|
window.parent.postMessage({
|
|
1261
1267
|
type: "ELEMENT_POSITION",
|
|
1262
1268
|
componentId: componentId || null,
|
|
1263
1269
|
slotName: slotName || null,
|
|
1264
1270
|
nodeId: nodeId || null,
|
|
1265
|
-
isPageSlot: !!isPageSlot,
|
|
1271
|
+
isPageSlot: !!isPageSlot || element.getAttribute("data-slot-source") === "page",
|
|
1272
|
+
hierarchy: hierarchyEls.map((el, index) => {
|
|
1273
|
+
const elComponentId = el.getAttribute("data-amplifyup-component") || el.getAttribute("data-component-id");
|
|
1274
|
+
const elSlotName = el.getAttribute("data-amplifyup-slot") || el.getAttribute("data-slot-id");
|
|
1275
|
+
const isSlot = !elComponentId && !!elSlotName;
|
|
1276
|
+
const pageSlot = isSlot && el.getAttribute("data-slot-source") === "page";
|
|
1277
|
+
return {
|
|
1278
|
+
index,
|
|
1279
|
+
componentId: elComponentId,
|
|
1280
|
+
componentName: pageSlot ? "Page" : el.getAttribute("data-component-name"),
|
|
1281
|
+
slotName: isSlot ? elSlotName : null,
|
|
1282
|
+
isSlot,
|
|
1283
|
+
isPageSlot: pageSlot,
|
|
1284
|
+
nodeId: el.getAttribute("data-node-id") || (isSlot ? el.getAttribute("data-parent-node-id") : null)
|
|
1285
|
+
};
|
|
1286
|
+
}),
|
|
1266
1287
|
position,
|
|
1267
1288
|
bounds
|
|
1268
1289
|
}, "*");
|
|
@@ -1819,13 +1840,24 @@ Available Console Commands:
|
|
|
1819
1840
|
buildComponentHierarchy(element) {
|
|
1820
1841
|
const hierarchy = [];
|
|
1821
1842
|
let current = element;
|
|
1843
|
+
let sawPageSlot = false;
|
|
1822
1844
|
while (current) {
|
|
1823
1845
|
if (current.hasAttribute("data-amplifyup-component") || current.hasAttribute("data-component-id") || current.hasAttribute("data-amplifyup-slot") || current.hasAttribute("data-slot-id")) {
|
|
1824
1846
|
hierarchy.push(current);
|
|
1847
|
+
if (current.getAttribute("data-slot-source") === "page") {
|
|
1848
|
+
sawPageSlot = true;
|
|
1849
|
+
}
|
|
1825
1850
|
}
|
|
1826
1851
|
current = current.parentElement;
|
|
1827
1852
|
}
|
|
1828
|
-
|
|
1853
|
+
const ordered = hierarchy.reverse();
|
|
1854
|
+
if (!sawPageSlot) {
|
|
1855
|
+
const pageSlot = element.closest('[data-slot-source="page"]');
|
|
1856
|
+
if (pageSlot && !ordered.includes(pageSlot)) {
|
|
1857
|
+
ordered.unshift(pageSlot);
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
return ordered;
|
|
1829
1861
|
}
|
|
1830
1862
|
/**
|
|
1831
1863
|
* Send selection message to orchestrator (includes element bounds for overlay positioning).
|
|
@@ -2002,7 +2034,8 @@ function AmplifyRenderer({
|
|
|
2002
2034
|
pageConfig: serverPageConfig,
|
|
2003
2035
|
loadingComponent,
|
|
2004
2036
|
errorComponent,
|
|
2005
|
-
emptyComponent
|
|
2037
|
+
emptyComponent,
|
|
2038
|
+
composerPreview
|
|
2006
2039
|
}) {
|
|
2007
2040
|
const clientHook = useAmplifyUp();
|
|
2008
2041
|
const pageConfig = serverPageConfig || clientHook.pageConfig || null;
|
|
@@ -2284,7 +2317,7 @@ function AmplifyRenderer({
|
|
|
2284
2317
|
"data-zone-id": slot.zoneId || void 0,
|
|
2285
2318
|
"data-parent-node-id": node.id,
|
|
2286
2319
|
"data-parent-component-id": node.componentId,
|
|
2287
|
-
children: safeChildren.filter(Boolean).map((child) => renderNode(child))
|
|
2320
|
+
children: safeChildren.filter(Boolean).map((child) => /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: renderNode(child) }, child.id))
|
|
2288
2321
|
},
|
|
2289
2322
|
slot.slotId
|
|
2290
2323
|
);
|
|
@@ -2308,7 +2341,7 @@ function AmplifyRenderer({
|
|
|
2308
2341
|
if (layoutTree.length === 0) {
|
|
2309
2342
|
return /* @__PURE__ */ jsxRuntime.jsx("main", { children: emptyComponent || /* @__PURE__ */ jsxRuntime.jsx("div", { className: "container mx-auto px-4 py-16", children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground", children: "No content configured for this page." }) }) });
|
|
2310
2343
|
}
|
|
2311
|
-
return /* @__PURE__ */ jsxRuntime.jsx("main", { children: isComposerPreview() ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2344
|
+
return /* @__PURE__ */ jsxRuntime.jsx("main", { children: composerPreview || isComposerPreview() ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2312
2345
|
"div",
|
|
2313
2346
|
{
|
|
2314
2347
|
"data-slot-id": "main",
|