@ohhwells/bridge 0.1.68-next.199 → 0.1.68-next.200

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
@@ -10857,7 +10857,8 @@ function findSocialsRow(el) {
10857
10857
  }
10858
10858
  function isSocialsRow(el) {
10859
10859
  const anchors = Array.from(el.querySelectorAll("a"));
10860
- return anchors.length > 0 && anchors.every((anchor) => isSocialItem(anchor));
10860
+ if (!anchors.length || !anchors.some((anchor) => isSocialItem(anchor))) return false;
10861
+ return findSocialsRow(anchors[0]) === el;
10861
10862
  }
10862
10863
  var MAX_SOCIAL_ITEMS_PER_ROW = 7;
10863
10864
  function canAddSocialItem(row) {
@@ -10895,6 +10896,7 @@ function markSocialsRows(root = document) {
10895
10896
  });
10896
10897
  listSocialsRows(root).forEach((row) => {
10897
10898
  row.setAttribute(SOCIALS_ROW_ATTR, "");
10899
+ allowRowToWrap(row);
10898
10900
  const items = listSocialItems(row);
10899
10901
  const firstUnit = items[0] ? socialRowUnit(items[0], row) : null;
10900
10902
  if (firstUnit) rowTemplates.set(rowKeyOf(row), firstUnit.outerHTML);
@@ -11189,7 +11191,29 @@ function applySocialsDisplayToRow(row, display) {
11189
11191
  const icon = item.querySelector(ICON_SELECTOR);
11190
11192
  if (label) label.style.display = display.text ? "" : "none";
11191
11193
  if (icon) icon.style.display = display.icon ? "" : "none";
11194
+ layOutIconAndLabel(item, Boolean(display.text && display.icon));
11192
11195
  });
11196
+ allowRowToWrap(row);
11197
+ }
11198
+ function layOutIconAndLabel(item, on) {
11199
+ const hasBoth = Boolean(item.querySelector(ICON_SELECTOR)) && Boolean(socialLabelElement(item));
11200
+ if (!hasBoth) {
11201
+ item.style.display = "";
11202
+ item.style.alignItems = "";
11203
+ item.style.gap = "";
11204
+ item.style.whiteSpace = "";
11205
+ item.style.flex = "";
11206
+ return;
11207
+ }
11208
+ item.style.display = on ? "inline-flex" : "";
11209
+ item.style.alignItems = on ? "center" : "";
11210
+ item.style.gap = on ? "8px" : "";
11211
+ item.style.whiteSpace = on ? "nowrap" : "";
11212
+ item.style.flex = on ? "0 0 auto" : "";
11213
+ }
11214
+ function allowRowToWrap(row) {
11215
+ const display = row.ownerDocument.defaultView?.getComputedStyle(row).display ?? "";
11216
+ if (display === "flex" || display === "inline-flex") row.style.flexWrap = "wrap";
11193
11217
  }
11194
11218
  function applySocialsDisplayFromContent(content, root = document) {
11195
11219
  const stored = parseSocialsDisplay(content[SOCIALS_DISPLAY_KEY]);
@@ -16116,6 +16140,7 @@ function OhhwellsBridge() {
16116
16140
  }, [clearSelectedAttr]);
16117
16141
  const markSelected = (0, import_react17.useCallback)((el) => {
16118
16142
  clearSelectedAttr();
16143
+ el.removeAttribute("data-ohw-hovered");
16119
16144
  el.setAttribute("data-ohw-selected", "");
16120
16145
  }, [clearSelectedAttr]);
16121
16146
  const resolveHrefKeyElement = (0, import_react17.useCallback)((hrefKey) => {
@@ -18057,6 +18082,16 @@ function OhhwellsBridge() {
18057
18082
  return;
18058
18083
  }
18059
18084
  }
18085
+ if (allowNavContainerHover) {
18086
+ const socialsRow = isSocialsRow(target) ? target : null;
18087
+ if (socialsRow && !getSocialItem(target) && selected2 !== socialsRow) {
18088
+ hoveredNavContainerRef.current = socialsRow;
18089
+ setHoveredNavContainerRect(socialsRow.getBoundingClientRect());
18090
+ hoveredItemElRef.current = null;
18091
+ setHoveredItemRect(null);
18092
+ return;
18093
+ }
18094
+ }
18060
18095
  if (allowFooterLinksHover) {
18061
18096
  const navContainer = target.closest("[data-ohw-nav-container]");
18062
18097
  if (!navContainer) {
@@ -18142,7 +18177,7 @@ function OhhwellsBridge() {
18142
18177
  clearHrefKeyHover(hoverTarget);
18143
18178
  hoveredItemElRef.current = hoverTarget;
18144
18179
  setHoveredItemRect(hoverTarget.getBoundingClientRect());
18145
- } else if (!isInsideNavigationItem(editable)) {
18180
+ } else if (!isInsideNavigationItem(editable) && hoverTarget !== selectedElRef.current) {
18146
18181
  hoverTarget.setAttribute("data-ohw-hovered", "");
18147
18182
  if (editable.closest("footer") || editable.closest('[data-ohw-section="footer"]')) {
18148
18183
  hoveredNavContainerRef.current = null;
@@ -18735,6 +18770,35 @@ function OhhwellsBridge() {
18735
18770
  }
18736
18771
  }
18737
18772
  };
18773
+ const probeSocialsRowAt = (clientX, clientY, fromParentViewport = false) => {
18774
+ const wasSocialsRow = Boolean(hoveredNavContainerRef.current?.hasAttribute(SOCIALS_ROW_ATTR));
18775
+ const clear = () => {
18776
+ if (!wasSocialsRow) return false;
18777
+ hoveredNavContainerRef.current = null;
18778
+ setHoveredNavContainerRect(null);
18779
+ return false;
18780
+ };
18781
+ if (linkPopoverOpenRef.current || toolbarVariantRef.current === "select-frame") return clear();
18782
+ const { x, y } = toProbeCoords(clientX, clientY, fromParentViewport);
18783
+ const SLACK = 6;
18784
+ for (const row of Array.from(document.querySelectorAll(`[${SOCIALS_ROW_ATTR}]`))) {
18785
+ const rect = row.getBoundingClientRect();
18786
+ const inside = x >= rect.left - SLACK && x <= rect.right + SLACK && y >= rect.top - SLACK && y <= rect.bottom + SLACK;
18787
+ if (!inside) continue;
18788
+ if (selectedElRef.current === row) return clear();
18789
+ const overItem = listSocialItems(row).some((item) => {
18790
+ const box = item.getBoundingClientRect();
18791
+ return x >= box.left && x <= box.right && y >= box.top && y <= box.bottom;
18792
+ });
18793
+ if (overItem) return clear();
18794
+ hoveredNavContainerRef.current = row;
18795
+ setHoveredNavContainerRect(rect);
18796
+ hoveredItemElRef.current = null;
18797
+ setHoveredItemRect(null);
18798
+ return true;
18799
+ }
18800
+ return clear();
18801
+ };
18738
18802
  const probeSectionGapAt = (clientX, clientY, fromParentViewport = false) => {
18739
18803
  if (linkPopoverOpenRef.current) {
18740
18804
  if (hoveredGapRef.current) {
@@ -18791,6 +18855,7 @@ function OhhwellsBridge() {
18791
18855
  setSectionGap(null);
18792
18856
  return;
18793
18857
  }
18858
+ if (probeSocialsRowAt(clientX, clientY)) return;
18794
18859
  probeSectionGapAt(clientX, clientY);
18795
18860
  probeImageAt(clientX, clientY);
18796
18861
  probeHoverCardsAt(clientX, clientY);
@@ -18804,6 +18869,7 @@ function OhhwellsBridge() {
18804
18869
  clearImageHover();
18805
18870
  return;
18806
18871
  }
18872
+ if (probeSocialsRowAt(clientX, clientY)) return;
18807
18873
  probeSectionGapAt(clientX, clientY);
18808
18874
  probeImageAt(clientX, clientY);
18809
18875
  probeHoverCardsAt(clientX, clientY);
@@ -20717,7 +20783,7 @@ function OhhwellsBridge() {
20717
20783
  )),
20718
20784
  hoveredNavContainerRect && (toolbarVariant !== "select-frame" || isFooterFrameSelection) && !linkPopover && !isItemDragging && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ItemInteractionLayer, { rect: hoveredNavContainerRect, state: "hover" }),
20719
20785
  hoveredItemRect && !linkPopover && !hoveredNavContainerRect && !isItemDragging && hoveredItemElRef.current !== selectedElRef.current && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ItemInteractionLayer, { rect: hoveredItemRect, state: "hover" }),
20720
- hoveredTextRect && !isItemDragging && toolbarVariant !== "rich-text" && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ItemInteractionLayer, { rect: hoveredTextRect, state: "hover" }),
20786
+ hoveredTextRect && !hoveredNavContainerRect && !hoveredItemRect && !isItemDragging && toolbarVariant !== "rich-text" && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(ItemInteractionLayer, { rect: hoveredTextRect, state: "hover" }),
20721
20787
  formPickRect && !isItemDragging && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
20722
20788
  ItemInteractionLayer,
20723
20789
  {