@amplifyup/sdk 0.1.36 → 0.1.38
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 +32 -5
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +32 -5
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -0
- package/dist/index.mjs.map +1 -1
- package/dist/react.js +32 -5
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +32 -5
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/AmplifyRenderer.mjs
CHANGED
|
@@ -1656,6 +1656,12 @@ Available Console Commands:
|
|
|
1656
1656
|
);
|
|
1657
1657
|
return;
|
|
1658
1658
|
}
|
|
1659
|
+
if (event.data?.type === "AMPLIFYUP_PROPS_PATCH") {
|
|
1660
|
+
window.dispatchEvent(
|
|
1661
|
+
new CustomEvent("amplifyup:props-patch", { detail: event.data })
|
|
1662
|
+
);
|
|
1663
|
+
return;
|
|
1664
|
+
}
|
|
1659
1665
|
if (event.data?.type === "COMPONENT_DELETABLE_STATUS") {
|
|
1660
1666
|
const { componentId, deletable, nodeId } = event.data;
|
|
1661
1667
|
const element = document.querySelector(`[data-component-id="${componentId}"]`);
|
|
@@ -2672,25 +2678,46 @@ function useLiveComposerProps(layoutNodeId, props) {
|
|
|
2672
2678
|
setLive(props);
|
|
2673
2679
|
}, [props]);
|
|
2674
2680
|
useEffect(() => {
|
|
2675
|
-
const
|
|
2676
|
-
if (!fieldName || typeof fieldName !== "string") return;
|
|
2681
|
+
const matchesNode = (nodeId) => {
|
|
2677
2682
|
if (nodeId && layoutNodeId && String(nodeId) !== String(layoutNodeId)) {
|
|
2678
|
-
return;
|
|
2683
|
+
return false;
|
|
2679
2684
|
}
|
|
2685
|
+
return true;
|
|
2686
|
+
};
|
|
2687
|
+
const applyField = (fieldName, value, nodeId) => {
|
|
2688
|
+
if (!fieldName || typeof fieldName !== "string") return;
|
|
2689
|
+
if (!matchesNode(nodeId)) return;
|
|
2680
2690
|
setLive((prev) => ({ ...prev, [fieldName]: value }));
|
|
2681
2691
|
};
|
|
2692
|
+
const applyProps = (nextProps, nodeId) => {
|
|
2693
|
+
if (!nextProps || typeof nextProps !== "object" || Array.isArray(nextProps)) {
|
|
2694
|
+
return;
|
|
2695
|
+
}
|
|
2696
|
+
if (!matchesNode(nodeId)) return;
|
|
2697
|
+
setLive(nextProps);
|
|
2698
|
+
};
|
|
2682
2699
|
const onPatch = (event) => {
|
|
2683
2700
|
const detail = event.detail || {};
|
|
2684
|
-
|
|
2701
|
+
applyField(detail.fieldName, detail.value, detail.layoutNodeId);
|
|
2702
|
+
};
|
|
2703
|
+
const onPropsPatch = (event) => {
|
|
2704
|
+
const detail = event.detail || {};
|
|
2705
|
+
applyProps(detail.props, detail.layoutNodeId);
|
|
2685
2706
|
};
|
|
2686
2707
|
const onMessage = (event) => {
|
|
2708
|
+
if (event.data?.type === "AMPLIFYUP_PROPS_PATCH") {
|
|
2709
|
+
applyProps(event.data.props, event.data.layoutNodeId);
|
|
2710
|
+
return;
|
|
2711
|
+
}
|
|
2687
2712
|
if (event.data?.type !== "AMPLIFYUP_FIELD_PATCH") return;
|
|
2688
|
-
|
|
2713
|
+
applyField(event.data.fieldName, event.data.value, event.data.layoutNodeId);
|
|
2689
2714
|
};
|
|
2690
2715
|
window.addEventListener("amplifyup:field-patch", onPatch);
|
|
2716
|
+
window.addEventListener("amplifyup:props-patch", onPropsPatch);
|
|
2691
2717
|
window.addEventListener("message", onMessage);
|
|
2692
2718
|
return () => {
|
|
2693
2719
|
window.removeEventListener("amplifyup:field-patch", onPatch);
|
|
2720
|
+
window.removeEventListener("amplifyup:props-patch", onPropsPatch);
|
|
2694
2721
|
window.removeEventListener("message", onMessage);
|
|
2695
2722
|
};
|
|
2696
2723
|
}, [layoutNodeId]);
|