@yoamigo.com/core 0.3.13 → 0.3.16

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/index.js CHANGED
@@ -180,6 +180,7 @@ var BuilderSelectionManager = class {
180
180
  type: "PAGE_READY",
181
181
  page: window.location.pathname
182
182
  });
183
+ this.sendToParent({ type: "BUILDER_READY" });
183
184
  }
184
185
  sendToParent(message, transfer) {
185
186
  try {
@@ -5639,31 +5640,6 @@ function Toolbar({ containerRef, onImageClick, onColorClick, onAIClick, onClearC
5639
5640
  children: "Background Color"
5640
5641
  }
5641
5642
  ) }),
5642
- /* @__PURE__ */ jsx16(
5643
- "button",
5644
- {
5645
- ref: aiRefs.setReference,
5646
- type: "button",
5647
- onClick: onAIClick,
5648
- "aria-label": "Ask AI for help",
5649
- ...getAiRefProps(),
5650
- children: /* @__PURE__ */ jsxs10("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
5651
- /* @__PURE__ */ jsx16("path", { d: "M12 2L2 7l10 5 10-5-10-5z" }),
5652
- /* @__PURE__ */ jsx16("path", { d: "M2 17l10 5 10-5" }),
5653
- /* @__PURE__ */ jsx16("path", { d: "M2 12l10 5 10-5" })
5654
- ] })
5655
- }
5656
- ),
5657
- aiOpen && /* @__PURE__ */ jsx16(FloatingPortal2, { children: /* @__PURE__ */ jsx16(
5658
- "div",
5659
- {
5660
- ref: aiRefs.setFloating,
5661
- className: "ya-container-tooltip",
5662
- style: aiStyles,
5663
- ...getAiFloatProps(),
5664
- children: "AI Assist"
5665
- }
5666
- ) }),
5667
5643
  hasBackground && /* @__PURE__ */ jsxs10(Fragment5, { children: [
5668
5644
  /* @__PURE__ */ jsx16(
5669
5645
  "button",
@@ -5710,6 +5686,7 @@ function YaContainer({
5710
5686
  const [isSelected, setIsSelected] = useState13(false);
5711
5687
  const [isDropMode, setIsDropMode] = useState13(false);
5712
5688
  const [isDropHover, setIsDropHover] = useState13(false);
5689
+ const [previewConfig, setPreviewConfig] = useState13(null);
5713
5690
  useEffect14(() => {
5714
5691
  if (mode !== "inline-edit") return;
5715
5692
  const containerEl = containerRef.current;
@@ -5734,13 +5711,14 @@ function YaContainer({
5734
5711
  }, [mode]);
5735
5712
  const rawValue = getValue(fieldId);
5736
5713
  const backgroundConfig = rawValue ? parseBackgroundConfig(rawValue) : defaultBackground || { type: "none" };
5737
- const hasBackground = backgroundConfig.type !== "none";
5714
+ const displayConfig = previewConfig ?? backgroundConfig;
5715
+ const hasBackground = displayConfig.type !== "none";
5738
5716
  const backgroundStyles = {};
5739
- if (backgroundConfig.type === "color" && backgroundConfig.backgroundColor) {
5740
- backgroundStyles.backgroundColor = backgroundConfig.backgroundColor;
5717
+ if (displayConfig.type === "color" && displayConfig.backgroundColor) {
5718
+ backgroundStyles.backgroundColor = displayConfig.backgroundColor;
5741
5719
  }
5742
- if (backgroundConfig.type === "image" && backgroundConfig.backgroundImage) {
5743
- const img = backgroundConfig.backgroundImage;
5720
+ if (displayConfig.type === "image" && displayConfig.backgroundImage) {
5721
+ const img = displayConfig.backgroundImage;
5744
5722
  const resolvedSrc = resolveAssetUrl(img.src);
5745
5723
  backgroundStyles.backgroundImage = `url(${resolvedSrc})`;
5746
5724
  backgroundStyles.backgroundSize = img.objectFit || "cover";
@@ -5748,9 +5726,9 @@ function YaContainer({
5748
5726
  backgroundStyles.backgroundRepeat = "no-repeat";
5749
5727
  }
5750
5728
  const overlayCustomProps = {};
5751
- if (backgroundConfig.overlay) {
5752
- overlayCustomProps["--ya-overlay-color"] = backgroundConfig.overlay.color;
5753
- overlayCustomProps["--ya-overlay-opacity"] = backgroundConfig.overlay.opacity;
5729
+ if (displayConfig.overlay) {
5730
+ overlayCustomProps["--ya-overlay-color"] = displayConfig.overlay.color;
5731
+ overlayCustomProps["--ya-overlay-opacity"] = displayConfig.overlay.opacity;
5754
5732
  }
5755
5733
  const handleImageClick = useCallback15(() => {
5756
5734
  if (mode !== "inline-edit") return;
@@ -5815,11 +5793,19 @@ function YaContainer({
5815
5793
  useEffect14(() => {
5816
5794
  if (mode !== "inline-edit") return;
5817
5795
  const handleMessage2 = (event) => {
5796
+ if (event.data?.type === "YA_CONTAINER_UPDATE_PREVIEW" && event.data.fieldId === fieldId) {
5797
+ if (event.data.value) {
5798
+ const config = typeof event.data.value === "string" ? parseBackgroundConfig(event.data.value) : event.data.value;
5799
+ setPreviewConfig(config);
5800
+ }
5801
+ }
5818
5802
  if (event.data?.type === "YA_CONTAINER_EDIT_COMPLETE" && event.data.fieldId === fieldId) {
5819
5803
  setIsSelected(false);
5804
+ setPreviewConfig(null);
5820
5805
  }
5821
5806
  if (event.data?.type === "YA_CONTAINER_EDIT_CANCEL" && event.data.fieldId === fieldId) {
5822
5807
  setIsSelected(false);
5808
+ setPreviewConfig(null);
5823
5809
  }
5824
5810
  };
5825
5811
  window.addEventListener("message", handleMessage2);
package/dist/lib.js CHANGED
@@ -139,6 +139,7 @@ var BuilderSelectionManager = class {
139
139
  type: "PAGE_READY",
140
140
  page: window.location.pathname
141
141
  });
142
+ this.sendToParent({ type: "BUILDER_READY" });
142
143
  }
143
144
  sendToParent(message, transfer) {
144
145
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yoamigo.com/core",
3
- "version": "0.3.13",
3
+ "version": "0.3.16",
4
4
  "description": "Core components, router, and utilities for YoAmigo templates",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE",