@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/react.js
CHANGED
|
@@ -1995,6 +1995,12 @@ Available Console Commands:
|
|
|
1995
1995
|
);
|
|
1996
1996
|
return;
|
|
1997
1997
|
}
|
|
1998
|
+
if (event.data?.type === "AMPLIFYUP_PROPS_PATCH") {
|
|
1999
|
+
window.dispatchEvent(
|
|
2000
|
+
new CustomEvent("amplifyup:props-patch", { detail: event.data })
|
|
2001
|
+
);
|
|
2002
|
+
return;
|
|
2003
|
+
}
|
|
1998
2004
|
if (event.data?.type === "COMPONENT_DELETABLE_STATUS") {
|
|
1999
2005
|
const { componentId, deletable, nodeId } = event.data;
|
|
2000
2006
|
const element = document.querySelector(`[data-component-id="${componentId}"]`);
|
|
@@ -3011,25 +3017,46 @@ function useLiveComposerProps(layoutNodeId, props) {
|
|
|
3011
3017
|
setLive(props);
|
|
3012
3018
|
}, [props]);
|
|
3013
3019
|
react.useEffect(() => {
|
|
3014
|
-
const
|
|
3015
|
-
if (!fieldName || typeof fieldName !== "string") return;
|
|
3020
|
+
const matchesNode = (nodeId) => {
|
|
3016
3021
|
if (nodeId && layoutNodeId && String(nodeId) !== String(layoutNodeId)) {
|
|
3017
|
-
return;
|
|
3022
|
+
return false;
|
|
3018
3023
|
}
|
|
3024
|
+
return true;
|
|
3025
|
+
};
|
|
3026
|
+
const applyField = (fieldName, value, nodeId) => {
|
|
3027
|
+
if (!fieldName || typeof fieldName !== "string") return;
|
|
3028
|
+
if (!matchesNode(nodeId)) return;
|
|
3019
3029
|
setLive((prev) => ({ ...prev, [fieldName]: value }));
|
|
3020
3030
|
};
|
|
3031
|
+
const applyProps = (nextProps, nodeId) => {
|
|
3032
|
+
if (!nextProps || typeof nextProps !== "object" || Array.isArray(nextProps)) {
|
|
3033
|
+
return;
|
|
3034
|
+
}
|
|
3035
|
+
if (!matchesNode(nodeId)) return;
|
|
3036
|
+
setLive(nextProps);
|
|
3037
|
+
};
|
|
3021
3038
|
const onPatch = (event) => {
|
|
3022
3039
|
const detail = event.detail || {};
|
|
3023
|
-
|
|
3040
|
+
applyField(detail.fieldName, detail.value, detail.layoutNodeId);
|
|
3041
|
+
};
|
|
3042
|
+
const onPropsPatch = (event) => {
|
|
3043
|
+
const detail = event.detail || {};
|
|
3044
|
+
applyProps(detail.props, detail.layoutNodeId);
|
|
3024
3045
|
};
|
|
3025
3046
|
const onMessage = (event) => {
|
|
3047
|
+
if (event.data?.type === "AMPLIFYUP_PROPS_PATCH") {
|
|
3048
|
+
applyProps(event.data.props, event.data.layoutNodeId);
|
|
3049
|
+
return;
|
|
3050
|
+
}
|
|
3026
3051
|
if (event.data?.type !== "AMPLIFYUP_FIELD_PATCH") return;
|
|
3027
|
-
|
|
3052
|
+
applyField(event.data.fieldName, event.data.value, event.data.layoutNodeId);
|
|
3028
3053
|
};
|
|
3029
3054
|
window.addEventListener("amplifyup:field-patch", onPatch);
|
|
3055
|
+
window.addEventListener("amplifyup:props-patch", onPropsPatch);
|
|
3030
3056
|
window.addEventListener("message", onMessage);
|
|
3031
3057
|
return () => {
|
|
3032
3058
|
window.removeEventListener("amplifyup:field-patch", onPatch);
|
|
3059
|
+
window.removeEventListener("amplifyup:props-patch", onPropsPatch);
|
|
3033
3060
|
window.removeEventListener("message", onMessage);
|
|
3034
3061
|
};
|
|
3035
3062
|
}, [layoutNodeId]);
|