@yoamigo.com/core 0.3.14 → 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.
Files changed (2) hide show
  1. package/dist/index.js +18 -33
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -5640,31 +5640,6 @@ function Toolbar({ containerRef, onImageClick, onColorClick, onAIClick, onClearC
5640
5640
  children: "Background Color"
5641
5641
  }
5642
5642
  ) }),
5643
- /* @__PURE__ */ jsx16(
5644
- "button",
5645
- {
5646
- ref: aiRefs.setReference,
5647
- type: "button",
5648
- onClick: onAIClick,
5649
- "aria-label": "Ask AI for help",
5650
- ...getAiRefProps(),
5651
- children: /* @__PURE__ */ jsxs10("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
5652
- /* @__PURE__ */ jsx16("path", { d: "M12 2L2 7l10 5 10-5-10-5z" }),
5653
- /* @__PURE__ */ jsx16("path", { d: "M2 17l10 5 10-5" }),
5654
- /* @__PURE__ */ jsx16("path", { d: "M2 12l10 5 10-5" })
5655
- ] })
5656
- }
5657
- ),
5658
- aiOpen && /* @__PURE__ */ jsx16(FloatingPortal2, { children: /* @__PURE__ */ jsx16(
5659
- "div",
5660
- {
5661
- ref: aiRefs.setFloating,
5662
- className: "ya-container-tooltip",
5663
- style: aiStyles,
5664
- ...getAiFloatProps(),
5665
- children: "AI Assist"
5666
- }
5667
- ) }),
5668
5643
  hasBackground && /* @__PURE__ */ jsxs10(Fragment5, { children: [
5669
5644
  /* @__PURE__ */ jsx16(
5670
5645
  "button",
@@ -5711,6 +5686,7 @@ function YaContainer({
5711
5686
  const [isSelected, setIsSelected] = useState13(false);
5712
5687
  const [isDropMode, setIsDropMode] = useState13(false);
5713
5688
  const [isDropHover, setIsDropHover] = useState13(false);
5689
+ const [previewConfig, setPreviewConfig] = useState13(null);
5714
5690
  useEffect14(() => {
5715
5691
  if (mode !== "inline-edit") return;
5716
5692
  const containerEl = containerRef.current;
@@ -5735,13 +5711,14 @@ function YaContainer({
5735
5711
  }, [mode]);
5736
5712
  const rawValue = getValue(fieldId);
5737
5713
  const backgroundConfig = rawValue ? parseBackgroundConfig(rawValue) : defaultBackground || { type: "none" };
5738
- const hasBackground = backgroundConfig.type !== "none";
5714
+ const displayConfig = previewConfig ?? backgroundConfig;
5715
+ const hasBackground = displayConfig.type !== "none";
5739
5716
  const backgroundStyles = {};
5740
- if (backgroundConfig.type === "color" && backgroundConfig.backgroundColor) {
5741
- backgroundStyles.backgroundColor = backgroundConfig.backgroundColor;
5717
+ if (displayConfig.type === "color" && displayConfig.backgroundColor) {
5718
+ backgroundStyles.backgroundColor = displayConfig.backgroundColor;
5742
5719
  }
5743
- if (backgroundConfig.type === "image" && backgroundConfig.backgroundImage) {
5744
- const img = backgroundConfig.backgroundImage;
5720
+ if (displayConfig.type === "image" && displayConfig.backgroundImage) {
5721
+ const img = displayConfig.backgroundImage;
5745
5722
  const resolvedSrc = resolveAssetUrl(img.src);
5746
5723
  backgroundStyles.backgroundImage = `url(${resolvedSrc})`;
5747
5724
  backgroundStyles.backgroundSize = img.objectFit || "cover";
@@ -5749,9 +5726,9 @@ function YaContainer({
5749
5726
  backgroundStyles.backgroundRepeat = "no-repeat";
5750
5727
  }
5751
5728
  const overlayCustomProps = {};
5752
- if (backgroundConfig.overlay) {
5753
- overlayCustomProps["--ya-overlay-color"] = backgroundConfig.overlay.color;
5754
- 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;
5755
5732
  }
5756
5733
  const handleImageClick = useCallback15(() => {
5757
5734
  if (mode !== "inline-edit") return;
@@ -5816,11 +5793,19 @@ function YaContainer({
5816
5793
  useEffect14(() => {
5817
5794
  if (mode !== "inline-edit") return;
5818
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
+ }
5819
5802
  if (event.data?.type === "YA_CONTAINER_EDIT_COMPLETE" && event.data.fieldId === fieldId) {
5820
5803
  setIsSelected(false);
5804
+ setPreviewConfig(null);
5821
5805
  }
5822
5806
  if (event.data?.type === "YA_CONTAINER_EDIT_CANCEL" && event.data.fieldId === fieldId) {
5823
5807
  setIsSelected(false);
5808
+ setPreviewConfig(null);
5824
5809
  }
5825
5810
  };
5826
5811
  window.addEventListener("message", handleMessage2);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yoamigo.com/core",
3
- "version": "0.3.14",
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",