@ohhwells/bridge 0.1.139-next.388 → 0.1.139-next.390

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.cjs CHANGED
@@ -6258,7 +6258,9 @@ function applyTreeToState(state, payload) {
6258
6258
  ...selfEdit ? priorEntry?.beforeSection ? { beforeSection: priorEntry.beforeSection } : {} : insertBefore && payload.targetSectionId ? { beforeSection: payload.targetSectionId } : {},
6259
6259
  ...selfEdit ? priorEntry?.replaces ? { replaces: priorEntry.replaces } : {} : payload.mode === "replace" && payload.targetSectionId ? { replaces: payload.targetSectionId } : {},
6260
6260
  tree: payload.tree,
6261
- media: payload.media ?? {},
6261
+ // A column insert rebuilds the media map from the live DOM keys. The photo
6262
+ // still points at the ref it was generated with. Keep that ref.
6263
+ media: { ...priorEntry?.media ?? {}, ...payload.media ?? {} },
6262
6264
  ...payload.brand && typeof payload.brand === "object" ? { brand: payload.brand } : {}
6263
6265
  };
6264
6266
  const others = state.sections.filter((existing) => existing.id !== entry.id);
@@ -6600,6 +6602,21 @@ function pricingCardFeatureCount(tree, index) {
6600
6602
  const target = findPricingCollection(tree)?.children?.[index];
6601
6603
  return target ? pricingFeatureList(target).length : 0;
6602
6604
  }
6605
+ function prevailingFeatureIcon(features) {
6606
+ const counts = /* @__PURE__ */ new Map();
6607
+ for (const row of features) {
6608
+ const key = `${row.icon ?? ""}|${row.iconColor ?? ""}`;
6609
+ const entry = counts.get(key) ?? { count: 0, ...row.icon ? { icon: row.icon } : {}, ...row.iconColor ? { iconColor: row.iconColor } : {} };
6610
+ entry.count += 1;
6611
+ counts.set(key, entry);
6612
+ }
6613
+ let best = null;
6614
+ for (const entry of counts.values()) {
6615
+ if (!best || entry.count > best.count) best = entry;
6616
+ }
6617
+ if (!best) return {};
6618
+ return { ...best.icon ? { icon: best.icon } : {}, ...best.iconColor ? { iconColor: best.iconColor } : {} };
6619
+ }
6603
6620
  function addPricingCardFeature(tree, index, text) {
6604
6621
  return withPricingCollection(tree, (collection) => {
6605
6622
  const children = collection.children;
@@ -6608,7 +6625,7 @@ function addPricingCardFeature(tree, index, text) {
6608
6625
  const features = pricingFeatureList(target);
6609
6626
  if (features.length >= PRICING_FEATURES_MAX) return false;
6610
6627
  target.slots = target.slots ?? {};
6611
- target.slots.features = [...features, { text }];
6628
+ target.slots.features = [...features, { text, ...prevailingFeatureIcon(features) }];
6612
6629
  return true;
6613
6630
  });
6614
6631
  }
@@ -9786,6 +9803,46 @@ function FooterSocialRowBlock({
9786
9803
  }
9787
9804
  );
9788
9805
  }
9806
+ function EmptySlotPlaceholder({ name }) {
9807
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
9808
+ "div",
9809
+ {
9810
+ "data-ai-slot": name,
9811
+ "data-ai-slot-empty": "",
9812
+ "aria-hidden": "true",
9813
+ style: {
9814
+ minHeight: 88,
9815
+ borderRadius: 12,
9816
+ border: "1px dashed #D6D3D1",
9817
+ display: "flex",
9818
+ alignItems: "center",
9819
+ justifyContent: "center",
9820
+ padding: 16,
9821
+ color: "#A8A29E",
9822
+ fontSize: 13,
9823
+ lineHeight: 1.4,
9824
+ textAlign: "center",
9825
+ pointerEvents: "none"
9826
+ },
9827
+ children: "Ask AI to add something here"
9828
+ }
9829
+ );
9830
+ }
9831
+ function splitSides(node) {
9832
+ const named = /* @__PURE__ */ new Map();
9833
+ const unnamed = [];
9834
+ (node.children ?? []).forEach((child, index) => {
9835
+ if (child.slot === "left" || child.slot === "right") {
9836
+ named.set(child.slot, { node: child, index });
9837
+ } else {
9838
+ unnamed.push({ node: child, index });
9839
+ }
9840
+ });
9841
+ return {
9842
+ left: named.get("left") ?? unnamed.shift() ?? null,
9843
+ right: named.get("right") ?? unnamed.shift() ?? null
9844
+ };
9845
+ }
9789
9846
  function renderNode(node, ctx, path, ambientAlign) {
9790
9847
  const slots = node.slots ?? {};
9791
9848
  switch (node.type) {
@@ -9893,24 +9950,38 @@ function renderNode(node, ctx, path, ambientAlign) {
9893
9950
  i
9894
9951
  ));
9895
9952
  if (layout === "grid") {
9896
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
9953
+ const holes = ctx.keyFor ? node.emptySlots ?? [] : [];
9954
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
9897
9955
  "div",
9898
9956
  {
9899
9957
  "data-ai-group": "grid",
9900
9958
  style: { display: "grid", gridTemplateColumns: "repeat(12, 1fr)", gap, alignItems: "end" },
9901
- children: kids
9959
+ children: [
9960
+ kids,
9961
+ holes.map((name) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { gridColumn: "span 6", minWidth: 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EmptySlotPlaceholder, { name }) }, name))
9962
+ ]
9902
9963
  }
9903
9964
  );
9904
9965
  }
9905
9966
  if (layout === "split") {
9967
+ const { left, right } = splitSides(node);
9968
+ const canvas = Boolean(ctx.keyFor);
9969
+ const side = (entry, name) => entry ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { minWidth: 0 }, children: renderNode(entry.node, ctx, `${path}.c${entry.index}`) }, name) : canvas ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EmptySlotPlaceholder, { name }, name) : null;
9970
+ if (!canvas && (!left || !right)) {
9971
+ const only = left ?? right;
9972
+ return only ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { "data-ai-group": "split", children: renderNode(only.node, ctx, `${path}.c${only.index}`) }) : null;
9973
+ }
9906
9974
  const ratio = str(slots.ratio);
9907
9975
  const cols = ratio === "3:5" ? "3fr 5fr" : ratio === "5:3" ? "5fr 3fr" : "1fr 1fr";
9908
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
9976
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
9909
9977
  "div",
9910
9978
  {
9911
9979
  "data-ai-group": "split",
9912
9980
  style: { display: "grid", gridTemplateColumns: cols, gap, alignItems: "center" },
9913
- children: kids
9981
+ children: [
9982
+ side(left, "left"),
9983
+ side(right, "right")
9984
+ ]
9914
9985
  }
9915
9986
  );
9916
9987
  }