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