@amplifyup/sdk 0.1.27 → 0.1.29
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 +52 -9
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +52 -9
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/react.d.mts +7 -30
- package/dist/react.d.ts +7 -30
- package/dist/react.js +768 -689
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +769 -692
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/AmplifyRenderer.mjs
CHANGED
|
@@ -2571,6 +2571,36 @@ var trackContentView = (contentId, contentType, properties) => getSDK().trackCon
|
|
|
2571
2571
|
var refreshEventTracking = () => getSDK().refreshEventTracking();
|
|
2572
2572
|
getSDK();
|
|
2573
2573
|
createContext(null);
|
|
2574
|
+
function useLiveComposerProps(layoutNodeId, props) {
|
|
2575
|
+
const [live, setLive] = useState(props);
|
|
2576
|
+
useEffect(() => {
|
|
2577
|
+
setLive(props);
|
|
2578
|
+
}, [props]);
|
|
2579
|
+
useEffect(() => {
|
|
2580
|
+
const apply = (fieldName, value, nodeId) => {
|
|
2581
|
+
if (!fieldName || typeof fieldName !== "string") return;
|
|
2582
|
+
if (nodeId && layoutNodeId && String(nodeId) !== String(layoutNodeId)) {
|
|
2583
|
+
return;
|
|
2584
|
+
}
|
|
2585
|
+
setLive((prev) => ({ ...prev, [fieldName]: value }));
|
|
2586
|
+
};
|
|
2587
|
+
const onPatch = (event) => {
|
|
2588
|
+
const detail = event.detail || {};
|
|
2589
|
+
apply(detail.fieldName, detail.value, detail.layoutNodeId);
|
|
2590
|
+
};
|
|
2591
|
+
const onMessage = (event) => {
|
|
2592
|
+
if (event.data?.type !== "AMPLIFYUP_FIELD_PATCH") return;
|
|
2593
|
+
apply(event.data.fieldName, event.data.value, event.data.layoutNodeId);
|
|
2594
|
+
};
|
|
2595
|
+
window.addEventListener("amplifyup:field-patch", onPatch);
|
|
2596
|
+
window.addEventListener("message", onMessage);
|
|
2597
|
+
return () => {
|
|
2598
|
+
window.removeEventListener("amplifyup:field-patch", onPatch);
|
|
2599
|
+
window.removeEventListener("message", onMessage);
|
|
2600
|
+
};
|
|
2601
|
+
}, [layoutNodeId]);
|
|
2602
|
+
return live;
|
|
2603
|
+
}
|
|
2574
2604
|
var usePathname = null;
|
|
2575
2605
|
if (typeof window !== "undefined") {
|
|
2576
2606
|
try {
|
|
@@ -2636,6 +2666,18 @@ var ComponentRenderBoundary = class extends Component {
|
|
|
2636
2666
|
return this.props.children;
|
|
2637
2667
|
}
|
|
2638
2668
|
};
|
|
2669
|
+
function LiveNodeRender({
|
|
2670
|
+
nodeId,
|
|
2671
|
+
componentId,
|
|
2672
|
+
props,
|
|
2673
|
+
slots,
|
|
2674
|
+
renderComponent
|
|
2675
|
+
}) {
|
|
2676
|
+
const liveProps = useLiveComposerProps(nodeId, props);
|
|
2677
|
+
return /* @__PURE__ */ jsx(Fragment, { children: renderComponent(componentId, liveProps, slots, {
|
|
2678
|
+
layoutNodeId: nodeId
|
|
2679
|
+
}) });
|
|
2680
|
+
}
|
|
2639
2681
|
function AmplifyRenderer({
|
|
2640
2682
|
renderComponent,
|
|
2641
2683
|
pageConfig: serverPageConfig,
|
|
@@ -2990,20 +3032,21 @@ function AmplifyRenderer({
|
|
|
2990
3032
|
}
|
|
2991
3033
|
}
|
|
2992
3034
|
const slotsToPass = Object.keys(slotChildren).length > 0 ? slotChildren : void 0;
|
|
2993
|
-
console.log(`[AmplifyRenderer] Calling renderComponent for ${node.componentId}`, {
|
|
2994
|
-
hasSlots: !!slotsToPass,
|
|
2995
|
-
slotKeys: slotsToPass ? Object.keys(slotsToPass) : [],
|
|
2996
|
-
propKeys: Object.keys(node.props || {}),
|
|
2997
|
-
props: node.props || {}
|
|
2998
|
-
});
|
|
2999
3035
|
return /* @__PURE__ */ jsx("div", { "data-node-id": node.id, "data-amplifyup-node": "", children: /* @__PURE__ */ jsx(
|
|
3000
3036
|
ComponentRenderBoundary,
|
|
3001
3037
|
{
|
|
3002
3038
|
componentId: node.componentId,
|
|
3003
3039
|
nodeId: node.id,
|
|
3004
|
-
children:
|
|
3005
|
-
|
|
3006
|
-
|
|
3040
|
+
children: /* @__PURE__ */ jsx(
|
|
3041
|
+
LiveNodeRender,
|
|
3042
|
+
{
|
|
3043
|
+
nodeId: node.id,
|
|
3044
|
+
componentId: node.componentId,
|
|
3045
|
+
props: node.props || {},
|
|
3046
|
+
slots: slotsToPass,
|
|
3047
|
+
renderComponent
|
|
3048
|
+
}
|
|
3049
|
+
)
|
|
3007
3050
|
}
|
|
3008
3051
|
) });
|
|
3009
3052
|
};
|