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