@amplifyup/sdk 0.1.37 → 0.1.39

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/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}"]`);
@@ -2630,7 +2636,7 @@ Available Console Commands:
2630
2636
  if (!highlightComponents && !showZones) return;
2631
2637
  const existing = document.getElementById("amplifyup-preview-highlights");
2632
2638
  if (existing) existing.remove();
2633
- const primary = "hsl(82 92% 42%)";
2639
+ const primary = "hsl(82 100% 52%)";
2634
2640
  const lines = [];
2635
2641
  if (highlightComponents) {
2636
2642
  lines.push(
@@ -2640,7 +2646,7 @@ Available Console Commands:
2640
2646
  "[data-amplifyup-component].amplifyup-selected, [data-component-id].amplifyup-selected {",
2641
2647
  ` outline: 2px solid ${primary} !important;`,
2642
2648
  " outline-offset: -2px !important;",
2643
- " box-shadow: inset 0 0 0 1px hsl(82 92% 42% / 0.25) !important;",
2649
+ " box-shadow: inset 0 0 0 1px hsl(82 100% 52% / 0.25) !important;",
2644
2650
  "}",
2645
2651
  "[data-amplifyup-component].amplifyup-component-hover:not(.amplifyup-selected),",
2646
2652
  "[data-component-id].amplifyup-component-hover:not(.amplifyup-selected) {",
@@ -2652,7 +2658,7 @@ Available Console Commands:
2652
2658
  if (highlightComponents || showZones) {
2653
2659
  lines.push(
2654
2660
  "[data-slot-id].amplifyup-selected, [data-amplifyup-slot].amplifyup-selected {",
2655
- " background-color: rgba(245, 245, 220, 0.35) !important;",
2661
+ " background-color: hsl(82 100% 52% / 0.12) !important;",
2656
2662
  "}"
2657
2663
  );
2658
2664
  }
@@ -3011,25 +3017,46 @@ function useLiveComposerProps(layoutNodeId, props) {
3011
3017
  setLive(props);
3012
3018
  }, [props]);
3013
3019
  react.useEffect(() => {
3014
- const apply = (fieldName, value, nodeId) => {
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
- apply(detail.fieldName, detail.value, detail.layoutNodeId);
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
- apply(event.data.fieldName, event.data.value, event.data.layoutNodeId);
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]);