@ohhwells/bridge 0.1.42-next.88 → 0.1.42-next.90

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
@@ -8142,6 +8142,11 @@ function getNavigationItemAnchor(el) {
8142
8142
  function isNavigationItem(el) {
8143
8143
  return getNavigationItemAnchor(el) !== null;
8144
8144
  }
8145
+ function listNavigationItems() {
8146
+ return Array.from(
8147
+ document.querySelectorAll("nav [data-ohw-href-key], footer [data-ohw-href-key]")
8148
+ ).filter((el) => isNavigationItem(el));
8149
+ }
8145
8150
  function getNavigationItemReorderState(anchor) {
8146
8151
  if (isNavbarButton2(anchor)) return { key: null, disabled: false };
8147
8152
  return getReorderHandleStateFromAnchor(anchor);
@@ -8174,7 +8179,7 @@ function countFooterNavItems(el) {
8174
8179
  return Array.from(el.querySelectorAll("[data-ohw-href-key]")).filter(isNavigationItem).length;
8175
8180
  }
8176
8181
  function findFooterItemGroup(item) {
8177
- const explicit = item.closest("[data-ohw-footer-column]");
8182
+ const explicit = item.closest("[data-ohw-footer-col], [data-ohw-footer-column]");
8178
8183
  if (explicit) return explicit;
8179
8184
  const footer = item.closest("footer");
8180
8185
  if (!footer) return null;
@@ -8191,7 +8196,7 @@ function isNavigationRoot(el) {
8191
8196
  function isInferredFooterGroup(el) {
8192
8197
  const footer = el.closest("footer");
8193
8198
  if (!footer || el === footer) return false;
8194
- if (el.hasAttribute("data-ohw-footer-column")) return true;
8199
+ if (el.hasAttribute("data-ohw-footer-col") || el.hasAttribute("data-ohw-footer-column")) return true;
8195
8200
  return countFooterNavItems(el) >= 2;
8196
8201
  }
8197
8202
  function isNavigationContainer(el) {
@@ -8201,7 +8206,7 @@ function isNavbarLinksContainer(el) {
8201
8206
  return el.hasAttribute("data-ohw-nav-container");
8202
8207
  }
8203
8208
  function getFooterColumn(el) {
8204
- return el.closest("[data-ohw-footer-column]");
8209
+ return el.closest("[data-ohw-footer-col], [data-ohw-footer-column]");
8205
8210
  }
8206
8211
  function resolveFooterColumnSelectionTarget(target, clientX, clientY) {
8207
8212
  if (getNavigationItemAnchor(target)) return null;
@@ -8225,7 +8230,7 @@ function isPointOverNavigation(x, y) {
8225
8230
  function findHoveredNavOrFooterContainer(x, y) {
8226
8231
  const candidates = [
8227
8232
  ...document.querySelectorAll("[data-ohw-nav-container]"),
8228
- ...document.querySelectorAll("[data-ohw-footer-column]")
8233
+ ...listFooterColumns()
8229
8234
  ];
8230
8235
  for (const container of candidates) {
8231
8236
  const r2 = container.getBoundingClientRect();
@@ -8272,11 +8277,23 @@ function getNavigationSelectionParent(el) {
8272
8277
  if (footerGroup) return footerGroup;
8273
8278
  return getNavigationRoot(el);
8274
8279
  }
8275
- if (el.hasAttribute("data-ohw-nav-container") || el.hasAttribute("data-ohw-footer-column") || isInferredFooterGroup(el)) {
8280
+ if (el.hasAttribute("data-ohw-nav-container") || el.hasAttribute("data-ohw-footer-col") || el.hasAttribute("data-ohw-footer-column") || isInferredFooterGroup(el)) {
8276
8281
  return getNavigationRoot(el);
8277
8282
  }
8278
8283
  return null;
8279
8284
  }
8285
+ function collectNavigationItemSiblingHintRects(selected) {
8286
+ if (!isNavigationItem(selected)) return [];
8287
+ const footerColumn = getFooterColumn(selected);
8288
+ if (footerColumn) {
8289
+ return listFooterLinksInColumn(footerColumn).filter((link) => link !== selected).map((link) => link.getBoundingClientRect());
8290
+ }
8291
+ const navContainer = selected.closest("[data-ohw-nav-container], [data-ohw-nav-drawer]");
8292
+ if (navContainer) {
8293
+ return Array.from(navContainer.querySelectorAll("[data-ohw-href-key]")).filter((el) => isNavigationItem(el) && el !== selected).map((el) => el.getBoundingClientRect());
8294
+ }
8295
+ return listNavigationItems().filter((el) => el !== selected).map((el) => el.getBoundingClientRect());
8296
+ }
8280
8297
  function placeCaretAtPoint(el, x, y) {
8281
8298
  const selection = window.getSelection();
8282
8299
  if (!selection) return;
@@ -9162,6 +9179,7 @@ function OhhwellsBridge() {
9162
9179
  setIsFooterFrameSelection(false);
9163
9180
  setToolbarVariant("link-action");
9164
9181
  setToolbarRect(link.getBoundingClientRect());
9182
+ setSiblingHintRects(collectNavigationItemSiblingHintRects(link));
9165
9183
  return;
9166
9184
  }
9167
9185
  const colAttr = selectedFooterColAttrRef.current;
@@ -9188,6 +9206,7 @@ function OhhwellsBridge() {
9188
9206
  setReorderDragDisabled(disabled);
9189
9207
  setToolbarVariant("link-action");
9190
9208
  setToolbarRect(navAnchor.getBoundingClientRect());
9209
+ setSiblingHintRects(collectNavigationItemSiblingHintRects(navAnchor));
9191
9210
  setToolbarShowEditLink(false);
9192
9211
  setActiveCommands(/* @__PURE__ */ new Set());
9193
9212
  }, [markSelected]);
@@ -9553,7 +9572,7 @@ function OhhwellsBridge() {
9553
9572
  hoveredItemElRef.current = null;
9554
9573
  siblingHintElRef.current = null;
9555
9574
  setSiblingHintRect(null);
9556
- setSiblingHintRects([]);
9575
+ setSiblingHintRects(collectNavigationItemSiblingHintRects(anchor));
9557
9576
  setIsItemDragging(false);
9558
9577
  const { key, disabled } = getNavigationItemReorderState(anchor);
9559
9578
  setReorderHrefKey(key);
@@ -10206,19 +10225,23 @@ function OhhwellsBridge() {
10206
10225
  setHoveredNavContainerRect(null);
10207
10226
  return;
10208
10227
  }
10209
- if (toolbarVariantRef.current !== "select-frame") {
10210
- const frameContainer = target.closest("[data-ohw-nav-container]") ?? target.closest("[data-ohw-footer-col]") ?? target.closest("[data-ohw-footer-column]");
10211
- if (frameContainer && !getNavigationItemAnchor(target)) {
10212
- hoveredNavContainerRef.current = frameContainer;
10213
- setHoveredNavContainerRect(frameContainer.getBoundingClientRect());
10228
+ const itemSelected = toolbarVariantRef.current === "link-action" && Boolean(selectedElRef.current && isNavigationItem(selectedElRef.current));
10229
+ if (toolbarVariantRef.current !== "select-frame" && !itemSelected) {
10230
+ const navContainer = target.closest("[data-ohw-nav-container]");
10231
+ if (navContainer && !getNavigationItemAnchor(target)) {
10232
+ hoveredNavContainerRef.current = navContainer;
10233
+ setHoveredNavContainerRect(navContainer.getBoundingClientRect());
10214
10234
  hoveredItemElRef.current = null;
10215
10235
  setHoveredItemRect(null);
10216
10236
  return;
10217
10237
  }
10218
- if (!target.closest("[data-ohw-nav-container], [data-ohw-footer-col], [data-ohw-footer-column]")) {
10238
+ if (!target.closest("[data-ohw-nav-container]")) {
10219
10239
  hoveredNavContainerRef.current = null;
10220
10240
  setHoveredNavContainerRect(null);
10221
10241
  }
10242
+ } else if (itemSelected) {
10243
+ hoveredNavContainerRef.current = null;
10244
+ setHoveredNavContainerRect(null);
10222
10245
  }
10223
10246
  const navAnchor = getNavigationItemAnchor(target);
10224
10247
  if (navAnchor) {
@@ -10235,7 +10258,7 @@ function OhhwellsBridge() {
10235
10258
  if (footerCol) {
10236
10259
  hoveredNavContainerRef.current = null;
10237
10260
  setHoveredNavContainerRect(null);
10238
- if (selectedElRef.current === footerCol) return;
10261
+ if (itemSelected || selectedElRef.current === footerCol) return;
10239
10262
  hoveredItemElRef.current = footerCol;
10240
10263
  setHoveredItemRect(footerCol.getBoundingClientRect());
10241
10264
  return;
@@ -10257,19 +10280,21 @@ function OhhwellsBridge() {
10257
10280
  };
10258
10281
  const handleMouseOut = (e) => {
10259
10282
  const target = e.target;
10260
- if (target.closest("[data-ohw-nav-container], [data-ohw-footer-column]")) {
10283
+ if (target.closest("[data-ohw-nav-container], [data-ohw-footer-col], [data-ohw-footer-column]")) {
10261
10284
  const related2 = e.relatedTarget instanceof Element ? e.relatedTarget : null;
10262
- if (related2?.closest("[data-ohw-nav-container], [data-ohw-footer-column], [data-ohw-navbar-container-chrome], [data-ohw-navbar-add-button]")) {
10285
+ if (related2?.closest("[data-ohw-nav-container], [data-ohw-footer-col], [data-ohw-footer-column], [data-ohw-navbar-container-chrome], [data-ohw-navbar-add-button]")) {
10263
10286
  return;
10264
10287
  }
10265
10288
  hoveredNavContainerRef.current = null;
10266
10289
  setHoveredNavContainerRect(null);
10267
10290
  }
10268
- const footerCol = target.closest("[data-ohw-footer-col]");
10291
+ const footerCol = target.closest("[data-ohw-footer-col]") ?? target.closest("[data-ohw-footer-column]");
10269
10292
  if (footerCol && hoveredItemElRef.current === footerCol) {
10270
10293
  const related2 = e.relatedTarget instanceof Element ? e.relatedTarget : null;
10271
10294
  if (related2?.closest("[data-ohw-drag-handle-container], [data-ohw-item-interaction]")) return;
10272
- if (related2?.closest("[data-ohw-footer-col]") === footerCol) return;
10295
+ if (related2?.closest("[data-ohw-footer-col], [data-ohw-footer-column]") === footerCol) {
10296
+ return;
10297
+ }
10273
10298
  hoveredItemElRef.current = null;
10274
10299
  setHoveredItemRect(null);
10275
10300
  return;
@@ -10404,17 +10429,16 @@ function OhhwellsBridge() {
10404
10429
  }
10405
10430
  };
10406
10431
  const probeNavigationHoverAt = (x, y) => {
10407
- if (toolbarVariantRef.current === "select-frame") {
10432
+ const itemSelected = toolbarVariantRef.current === "link-action" && Boolean(selectedElRef.current && isNavigationItem(selectedElRef.current));
10433
+ if (toolbarVariantRef.current === "select-frame" || itemSelected) {
10408
10434
  hoveredNavContainerRef.current = null;
10409
10435
  setHoveredNavContainerRect(null);
10410
- return;
10411
10436
  }
10412
- const frameContainers = [
10413
- ...document.querySelectorAll("[data-ohw-nav-container]"),
10414
- ...document.querySelectorAll("[data-ohw-footer-column]")
10415
- ];
10416
- let overFrame = null;
10417
- for (const container of frameContainers) {
10437
+ const navContainers = Array.from(
10438
+ document.querySelectorAll("[data-ohw-nav-container]")
10439
+ );
10440
+ const footerColumns = listFooterColumns();
10441
+ for (const container of [...navContainers, ...footerColumns]) {
10418
10442
  const containerRect = container.getBoundingClientRect();
10419
10443
  const overContainer = x >= containerRect.left && x <= containerRect.right && y >= containerRect.top && y <= containerRect.bottom;
10420
10444
  if (!overContainer) continue;
@@ -10433,21 +10457,53 @@ function OhhwellsBridge() {
10433
10457
  clearHrefKeyHover(navItemHit);
10434
10458
  hoveredItemElRef.current = navItemHit;
10435
10459
  setHoveredItemRect(navItemHit.getBoundingClientRect());
10460
+ } else if (hoveredItemElRef.current === navItemHit) {
10461
+ hoveredItemElRef.current = null;
10462
+ setHoveredItemRect(null);
10436
10463
  }
10437
10464
  return;
10438
10465
  }
10439
- overFrame = container;
10440
- break;
10441
10466
  }
10442
- if (!overFrame) {
10467
+ if (toolbarVariantRef.current !== "select-frame" && !itemSelected) {
10468
+ for (const container of navContainers) {
10469
+ const containerRect = container.getBoundingClientRect();
10470
+ const overContainer = x >= containerRect.left && x <= containerRect.right && y >= containerRect.top && y <= containerRect.bottom;
10471
+ if (!overContainer) continue;
10472
+ if (isPointOverNavItem(container, x, y)) continue;
10473
+ hoveredNavContainerRef.current = container;
10474
+ setHoveredNavContainerRect(container.getBoundingClientRect());
10475
+ hoveredItemElRef.current = null;
10476
+ setHoveredItemRect(null);
10477
+ return;
10478
+ }
10443
10479
  hoveredNavContainerRef.current = null;
10444
10480
  setHoveredNavContainerRect(null);
10445
- return;
10481
+ } else {
10482
+ hoveredNavContainerRef.current = null;
10483
+ setHoveredNavContainerRect(null);
10484
+ }
10485
+ if (!itemSelected) {
10486
+ for (const column of footerColumns) {
10487
+ const containerRect = column.getBoundingClientRect();
10488
+ const overContainer = x >= containerRect.left && x <= containerRect.right && y >= containerRect.top && y <= containerRect.bottom;
10489
+ if (!overContainer) continue;
10490
+ if (isPointOverNavItem(column, x, y)) continue;
10491
+ if (selectedElRef.current === column) {
10492
+ if (hoveredItemElRef.current === column) {
10493
+ hoveredItemElRef.current = null;
10494
+ setHoveredItemRect(null);
10495
+ }
10496
+ return;
10497
+ }
10498
+ hoveredItemElRef.current = column;
10499
+ setHoveredItemRect(column.getBoundingClientRect());
10500
+ return;
10501
+ }
10502
+ }
10503
+ if (hoveredItemElRef.current?.hasAttribute("data-ohw-footer-col") || hoveredItemElRef.current?.hasAttribute("data-ohw-footer-column")) {
10504
+ hoveredItemElRef.current = null;
10505
+ setHoveredItemRect(null);
10446
10506
  }
10447
- hoveredNavContainerRef.current = overFrame;
10448
- setHoveredNavContainerRect(overFrame.getBoundingClientRect());
10449
- hoveredItemElRef.current = null;
10450
- setHoveredItemRect(null);
10451
10507
  };
10452
10508
  const probeImageAt = (clientX, clientY, isDragOver = false, fromParentViewport = false) => {
10453
10509
  if (linkPopoverOpenRef.current) {
@@ -10468,6 +10524,10 @@ function OhhwellsBridge() {
10468
10524
  }
10469
10525
  hoveredNavContainerRef.current = null;
10470
10526
  setHoveredNavContainerRect(null);
10527
+ if (hoveredItemElRef.current?.hasAttribute("data-ohw-footer-col") || hoveredItemElRef.current?.hasAttribute("data-ohw-footer-column")) {
10528
+ hoveredItemElRef.current = null;
10529
+ setHoveredItemRect(null);
10530
+ }
10471
10531
  const toggleEl = document.querySelector("[data-ohw-state-toggle]");
10472
10532
  if (toggleEl) {
10473
10533
  const tr = toggleEl.getBoundingClientRect();
@@ -11088,10 +11148,14 @@ function OhhwellsBridge() {
11088
11148
  setSiblingHintRect(siblingHintElRef.current.getBoundingClientRect());
11089
11149
  }
11090
11150
  const selected = selectedElRef.current;
11091
- if (selected && !footerDragRef.current && (selected.hasAttribute("data-ohw-footer-col") || Boolean(selected.closest("footer") && isInferredFooterGroup(selected)))) {
11092
- setSiblingHintRects(
11093
- listFooterColumns().filter((column) => column !== selected).map((column) => column.getBoundingClientRect())
11094
- );
11151
+ if (selected && !footerDragRef.current && !navDragRef.current) {
11152
+ if (selected.hasAttribute("data-ohw-footer-col") || Boolean(selected.closest("footer") && isInferredFooterGroup(selected))) {
11153
+ setSiblingHintRects(
11154
+ listFooterColumns().filter((column) => column !== selected).map((column) => column.getBoundingClientRect())
11155
+ );
11156
+ } else if (isNavigationItem(selected)) {
11157
+ setSiblingHintRects(collectNavigationItemSiblingHintRects(selected));
11158
+ }
11095
11159
  }
11096
11160
  if (footerDragRef.current) {
11097
11161
  const session = footerDragRef.current;
@@ -11336,7 +11400,7 @@ function OhhwellsBridge() {
11336
11400
  }
11337
11401
  }
11338
11402
  const footerColumn = findHoveredNavOrFooterContainer(clientX, clientY);
11339
- if (footerColumn?.hasAttribute("data-ohw-footer-column")) {
11403
+ if (footerColumn?.hasAttribute("data-ohw-footer-col") || footerColumn?.hasAttribute("data-ohw-footer-column")) {
11340
11404
  selectFrameRef.current(footerColumn);
11341
11405
  return;
11342
11406
  }