@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.
@@ -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}"]`);
@@ -2293,7 +2299,7 @@ Available Console Commands:
2293
2299
  if (!highlightComponents && !showZones) return;
2294
2300
  const existing = document.getElementById("amplifyup-preview-highlights");
2295
2301
  if (existing) existing.remove();
2296
- const primary = "hsl(82 92% 42%)";
2302
+ const primary = "hsl(82 100% 52%)";
2297
2303
  const lines = [];
2298
2304
  if (highlightComponents) {
2299
2305
  lines.push(
@@ -2303,7 +2309,7 @@ Available Console Commands:
2303
2309
  "[data-amplifyup-component].amplifyup-selected, [data-component-id].amplifyup-selected {",
2304
2310
  ` outline: 2px solid ${primary} !important;`,
2305
2311
  " outline-offset: -2px !important;",
2306
- " box-shadow: inset 0 0 0 1px hsl(82 92% 42% / 0.25) !important;",
2312
+ " box-shadow: inset 0 0 0 1px hsl(82 100% 52% / 0.25) !important;",
2307
2313
  "}",
2308
2314
  "[data-amplifyup-component].amplifyup-component-hover:not(.amplifyup-selected),",
2309
2315
  "[data-component-id].amplifyup-component-hover:not(.amplifyup-selected) {",
@@ -2315,7 +2321,7 @@ Available Console Commands:
2315
2321
  if (highlightComponents || showZones) {
2316
2322
  lines.push(
2317
2323
  "[data-slot-id].amplifyup-selected, [data-amplifyup-slot].amplifyup-selected {",
2318
- " background-color: rgba(245, 245, 220, 0.35) !important;",
2324
+ " background-color: hsl(82 100% 52% / 0.12) !important;",
2319
2325
  "}"
2320
2326
  );
2321
2327
  }
@@ -2674,25 +2680,46 @@ function useLiveComposerProps(layoutNodeId, props) {
2674
2680
  setLive(props);
2675
2681
  }, [props]);
2676
2682
  react.useEffect(() => {
2677
- const apply = (fieldName, value, nodeId) => {
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
- apply(detail.fieldName, detail.value, detail.layoutNodeId);
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
- apply(event.data.fieldName, event.data.value, event.data.layoutNodeId);
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]);