@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
package/dist/react.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { createContext, useState, useEffect, useContext } from 'react';
|
|
2
|
+
import { createContext, useState, useEffect, useContext, Fragment as Fragment$1 } from 'react';
|
|
3
3
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
4
4
|
|
|
5
5
|
/* @amplifyup/sdk - https://amplifyup.ai */
|
|
@@ -1223,6 +1223,11 @@ Available Console Commands:
|
|
|
1223
1223
|
`[data-node-id="${nodeId}"]`
|
|
1224
1224
|
);
|
|
1225
1225
|
}
|
|
1226
|
+
if (!element && slotName) {
|
|
1227
|
+
element = document.querySelector(
|
|
1228
|
+
`[data-slot-source="page"][data-slot-id="${slotName}"], [data-slot-source="page"][data-amplifyup-slot="${slotName}"]`
|
|
1229
|
+
);
|
|
1230
|
+
}
|
|
1226
1231
|
if (!element && slotName) {
|
|
1227
1232
|
element = document.querySelector(
|
|
1228
1233
|
`[data-amplifyup-slot="${slotName}"], [data-slot-id="${slotName}"]`
|
|
@@ -1255,12 +1260,28 @@ Available Console Commands:
|
|
|
1255
1260
|
height: rect.height
|
|
1256
1261
|
};
|
|
1257
1262
|
if (window.parent && window.parent !== window) {
|
|
1263
|
+
const hierarchyEls = this.buildComponentHierarchy(element);
|
|
1258
1264
|
window.parent.postMessage({
|
|
1259
1265
|
type: "ELEMENT_POSITION",
|
|
1260
1266
|
componentId: componentId || null,
|
|
1261
1267
|
slotName: slotName || null,
|
|
1262
1268
|
nodeId: nodeId || null,
|
|
1263
|
-
isPageSlot: !!isPageSlot,
|
|
1269
|
+
isPageSlot: !!isPageSlot || element.getAttribute("data-slot-source") === "page",
|
|
1270
|
+
hierarchy: hierarchyEls.map((el, index) => {
|
|
1271
|
+
const elComponentId = el.getAttribute("data-amplifyup-component") || el.getAttribute("data-component-id");
|
|
1272
|
+
const elSlotName = el.getAttribute("data-amplifyup-slot") || el.getAttribute("data-slot-id");
|
|
1273
|
+
const isSlot = !elComponentId && !!elSlotName;
|
|
1274
|
+
const pageSlot = isSlot && el.getAttribute("data-slot-source") === "page";
|
|
1275
|
+
return {
|
|
1276
|
+
index,
|
|
1277
|
+
componentId: elComponentId,
|
|
1278
|
+
componentName: pageSlot ? "Page" : el.getAttribute("data-component-name"),
|
|
1279
|
+
slotName: isSlot ? elSlotName : null,
|
|
1280
|
+
isSlot,
|
|
1281
|
+
isPageSlot: pageSlot,
|
|
1282
|
+
nodeId: el.getAttribute("data-node-id") || (isSlot ? el.getAttribute("data-parent-node-id") : null)
|
|
1283
|
+
};
|
|
1284
|
+
}),
|
|
1264
1285
|
position,
|
|
1265
1286
|
bounds
|
|
1266
1287
|
}, "*");
|
|
@@ -1817,13 +1838,24 @@ Available Console Commands:
|
|
|
1817
1838
|
buildComponentHierarchy(element) {
|
|
1818
1839
|
const hierarchy = [];
|
|
1819
1840
|
let current = element;
|
|
1841
|
+
let sawPageSlot = false;
|
|
1820
1842
|
while (current) {
|
|
1821
1843
|
if (current.hasAttribute("data-amplifyup-component") || current.hasAttribute("data-component-id") || current.hasAttribute("data-amplifyup-slot") || current.hasAttribute("data-slot-id")) {
|
|
1822
1844
|
hierarchy.push(current);
|
|
1845
|
+
if (current.getAttribute("data-slot-source") === "page") {
|
|
1846
|
+
sawPageSlot = true;
|
|
1847
|
+
}
|
|
1823
1848
|
}
|
|
1824
1849
|
current = current.parentElement;
|
|
1825
1850
|
}
|
|
1826
|
-
|
|
1851
|
+
const ordered = hierarchy.reverse();
|
|
1852
|
+
if (!sawPageSlot) {
|
|
1853
|
+
const pageSlot = element.closest('[data-slot-source="page"]');
|
|
1854
|
+
if (pageSlot && !ordered.includes(pageSlot)) {
|
|
1855
|
+
ordered.unshift(pageSlot);
|
|
1856
|
+
}
|
|
1857
|
+
}
|
|
1858
|
+
return ordered;
|
|
1827
1859
|
}
|
|
1828
1860
|
/**
|
|
1829
1861
|
* Send selection message to orchestrator (includes element bounds for overlay positioning).
|
|
@@ -1981,7 +2013,8 @@ function AmplifyRenderer({
|
|
|
1981
2013
|
pageConfig: serverPageConfig,
|
|
1982
2014
|
loadingComponent,
|
|
1983
2015
|
errorComponent,
|
|
1984
|
-
emptyComponent
|
|
2016
|
+
emptyComponent,
|
|
2017
|
+
composerPreview
|
|
1985
2018
|
}) {
|
|
1986
2019
|
const clientHook = useAmplifyUp();
|
|
1987
2020
|
const pageConfig = serverPageConfig || clientHook.pageConfig || null;
|
|
@@ -2263,7 +2296,7 @@ function AmplifyRenderer({
|
|
|
2263
2296
|
"data-zone-id": slot.zoneId || void 0,
|
|
2264
2297
|
"data-parent-node-id": node.id,
|
|
2265
2298
|
"data-parent-component-id": node.componentId,
|
|
2266
|
-
children: safeChildren.filter(Boolean).map((child) => renderNode(child))
|
|
2299
|
+
children: safeChildren.filter(Boolean).map((child) => /* @__PURE__ */ jsx(Fragment$1, { children: renderNode(child) }, child.id))
|
|
2267
2300
|
},
|
|
2268
2301
|
slot.slotId
|
|
2269
2302
|
);
|
|
@@ -2287,7 +2320,7 @@ function AmplifyRenderer({
|
|
|
2287
2320
|
if (layoutTree.length === 0) {
|
|
2288
2321
|
return /* @__PURE__ */ jsx("main", { children: emptyComponent || /* @__PURE__ */ jsx("div", { className: "container mx-auto px-4 py-16", children: /* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: "No content configured for this page." }) }) });
|
|
2289
2322
|
}
|
|
2290
|
-
return /* @__PURE__ */ jsx("main", { children: isComposerPreview() ? /* @__PURE__ */ jsx(
|
|
2323
|
+
return /* @__PURE__ */ jsx("main", { children: composerPreview || isComposerPreview() ? /* @__PURE__ */ jsx(
|
|
2291
2324
|
"div",
|
|
2292
2325
|
{
|
|
2293
2326
|
"data-slot-id": "main",
|
|
@@ -2318,6 +2351,7 @@ function AmplifyPageContent({
|
|
|
2318
2351
|
fallback,
|
|
2319
2352
|
renderComponent,
|
|
2320
2353
|
pageConfig: pageConfigProp,
|
|
2354
|
+
forceComposerPreview = false,
|
|
2321
2355
|
previewLoadingComponent,
|
|
2322
2356
|
previewEmptyComponent,
|
|
2323
2357
|
loadingComponent,
|
|
@@ -2325,7 +2359,7 @@ function AmplifyPageContent({
|
|
|
2325
2359
|
errorComponent
|
|
2326
2360
|
}) {
|
|
2327
2361
|
const client = useAmplifyUp();
|
|
2328
|
-
const preview = isComposerPreview();
|
|
2362
|
+
const preview = forceComposerPreview || isComposerPreview();
|
|
2329
2363
|
const pageConfig = pageConfigProp ?? client.pageConfig;
|
|
2330
2364
|
const loading = pageConfigProp ? false : client.loading;
|
|
2331
2365
|
const error = pageConfigProp ? null : client.error;
|
|
@@ -2337,6 +2371,7 @@ function AmplifyPageContent({
|
|
|
2337
2371
|
{
|
|
2338
2372
|
pageConfig: pageConfig ?? void 0,
|
|
2339
2373
|
renderComponent,
|
|
2374
|
+
composerPreview: true,
|
|
2340
2375
|
loadingComponent: loadingComponent ?? previewLoading,
|
|
2341
2376
|
emptyComponent: emptyComponent ?? previewCanvas,
|
|
2342
2377
|
errorComponent: errorComponent ?? (() => previewCanvas)
|