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