@ohhwells/bridge 0.1.42-next.89 → 0.1.42-next.91

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
@@ -4360,6 +4360,12 @@ function Tooltip({ ...props }) {
4360
4360
  function TooltipTrigger({ ...props }) {
4361
4361
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_radix_ui3.Tooltip.Trigger, { "data-slot": "tooltip-trigger", ...props });
4362
4362
  }
4363
+ var arrowClassBySide = {
4364
+ top: "before:bottom-0 before:left-1/2 before:-translate-x-1/2 before:translate-y-1/2",
4365
+ bottom: "before:top-0 before:left-1/2 before:-translate-x-1/2 before:-translate-y-1/2",
4366
+ left: "before:right-0 before:top-1/2 before:-translate-y-1/2 before:translate-x-1/2",
4367
+ right: "before:left-0 before:top-1/2 before:-translate-y-1/2 before:-translate-x-1/2"
4368
+ };
4363
4369
  function TooltipContent({
4364
4370
  className,
4365
4371
  sideOffset = 3,
@@ -4368,25 +4374,25 @@ function TooltipContent({
4368
4374
  hideArrow,
4369
4375
  ...props
4370
4376
  }) {
4371
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_radix_ui3.Tooltip.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
4377
+ const resolvedSide = side ?? "bottom";
4378
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_radix_ui3.Tooltip.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
4372
4379
  import_radix_ui3.Tooltip.Content,
4373
4380
  {
4374
4381
  "data-slot": "tooltip-content",
4375
4382
  side,
4376
4383
  sideOffset,
4377
4384
  className: cn(
4378
- "z-[2147483647] inline-flex w-fit max-w-xs items-center rounded-md bg-foreground px-3 py-1.5 text-xs text-background",
4385
+ "relative z-[2147483647] inline-flex w-fit max-w-xs items-center rounded-md bg-foreground px-3 py-1.5 text-xs text-background",
4379
4386
  "origin-[var(--radix-tooltip-content-transform-origin)] animate-in fade-in-0 zoom-in-95",
4380
4387
  "data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",
4381
4388
  "data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2",
4382
4389
  "data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2",
4390
+ !hideArrow && 'before:pointer-events-none before:absolute before:size-2 before:rotate-45 before:bg-foreground before:content-[""]',
4391
+ !hideArrow && arrowClassBySide[resolvedSide],
4383
4392
  className
4384
4393
  ),
4385
4394
  ...props,
4386
- children: [
4387
- children,
4388
- !hideArrow && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_radix_ui3.Tooltip.Arrow, { className: "z-[2147483647] size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground" })
4389
- ]
4395
+ children
4390
4396
  }
4391
4397
  ) });
4392
4398
  }
@@ -4577,6 +4583,7 @@ function ItemInteractionLayer({
4577
4583
  onDragHandleDragEnd,
4578
4584
  onItemPointerDown,
4579
4585
  onItemClick,
4586
+ itemDragSurface = true,
4580
4587
  chromeGap = SELECTION_CHROME_GAP,
4581
4588
  className
4582
4589
  }) {
@@ -4585,7 +4592,7 @@ function ItemInteractionLayer({
4585
4592
  const isDragging = state === "dragging";
4586
4593
  const showToolbar = isActive && toolbar;
4587
4594
  const showDragHandle = (isActive || isDragging) && showHandle;
4588
- const itemDragEnabled = isActive && showHandle && !isDragging && !dragDisabled;
4595
+ const itemDragEnabled = itemDragSurface && isActive && showHandle && !isDragging && !dragDisabled;
4589
4596
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
4590
4597
  "div",
4591
4598
  {
@@ -4631,7 +4638,8 @@ function ItemInteractionLayer({
4631
4638
  {
4632
4639
  "data-ohw-drag-handle-container": "",
4633
4640
  className: "pointer-events-auto absolute left-0 top-1/2 z-10 -translate-x-[calc(100%+7px)] -translate-y-1/2",
4634
- style: isDragging ? { visibility: "hidden" } : void 0,
4641
+ style: isDragging ? { opacity: 0 } : void 0,
4642
+ "aria-hidden": isDragging || void 0,
4635
4643
  children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
4636
4644
  DragHandle,
4637
4645
  {
@@ -4643,7 +4651,17 @@ function ItemInteractionLayer({
4643
4651
  e.preventDefault();
4644
4652
  return;
4645
4653
  }
4646
- e.dataTransfer?.setData("text/plain", dragHandleLabel);
4654
+ const blank = document.createElement("canvas");
4655
+ blank.width = 1;
4656
+ blank.height = 1;
4657
+ blank.style.cssText = "position:fixed;left:-9999px;top:-9999px;width:1px;height:1px;pointer-events:none";
4658
+ document.body.appendChild(blank);
4659
+ try {
4660
+ e.dataTransfer.setDragImage(blank, 0, 0);
4661
+ } finally {
4662
+ requestAnimationFrame(() => blank.remove());
4663
+ }
4664
+ e.dataTransfer.setData("text/plain", dragHandleLabel);
4647
4665
  e.dataTransfer.effectAllowed = "move";
4648
4666
  onDragHandleDragStart?.(e);
4649
4667
  },
@@ -8142,6 +8160,11 @@ function getNavigationItemAnchor(el) {
8142
8160
  function isNavigationItem(el) {
8143
8161
  return getNavigationItemAnchor(el) !== null;
8144
8162
  }
8163
+ function listNavigationItems() {
8164
+ return Array.from(
8165
+ document.querySelectorAll("nav [data-ohw-href-key], footer [data-ohw-href-key]")
8166
+ ).filter((el) => isNavigationItem(el));
8167
+ }
8145
8168
  function getNavigationItemReorderState(anchor) {
8146
8169
  if (isNavbarButton2(anchor)) return { key: null, disabled: false };
8147
8170
  return getReorderHandleStateFromAnchor(anchor);
@@ -8277,6 +8300,18 @@ function getNavigationSelectionParent(el) {
8277
8300
  }
8278
8301
  return null;
8279
8302
  }
8303
+ function collectNavigationItemSiblingHintRects(selected) {
8304
+ if (!isNavigationItem(selected)) return [];
8305
+ const footerColumn = getFooterColumn(selected);
8306
+ if (footerColumn) {
8307
+ return listFooterLinksInColumn(footerColumn).filter((link) => link !== selected).map((link) => link.getBoundingClientRect());
8308
+ }
8309
+ const navContainer = selected.closest("[data-ohw-nav-container], [data-ohw-nav-drawer]");
8310
+ if (navContainer) {
8311
+ return Array.from(navContainer.querySelectorAll("[data-ohw-href-key]")).filter((el) => isNavigationItem(el) && el !== selected).map((el) => el.getBoundingClientRect());
8312
+ }
8313
+ return listNavigationItems().filter((el) => el !== selected).map((el) => el.getBoundingClientRect());
8314
+ }
8280
8315
  function placeCaretAtPoint(el, x, y) {
8281
8316
  const selection = window.getSelection();
8282
8317
  if (!selection) return;
@@ -8476,7 +8511,8 @@ function EditGlowChrome({
8476
8511
  rect,
8477
8512
  elRef,
8478
8513
  reorderHrefKey,
8479
- dragDisabled = false
8514
+ dragDisabled = false,
8515
+ hideHandle = false
8480
8516
  }) {
8481
8517
  const GAP = SELECTION_CHROME_GAP2;
8482
8518
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
@@ -8507,7 +8543,7 @@ function EditGlowChrome({
8507
8543
  }
8508
8544
  }
8509
8545
  ),
8510
- reorderHrefKey && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
8546
+ reorderHrefKey && !hideHandle && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
8511
8547
  "div",
8512
8548
  {
8513
8549
  "data-ohw-drag-handle-container": "",
@@ -9162,6 +9198,7 @@ function OhhwellsBridge() {
9162
9198
  setIsFooterFrameSelection(false);
9163
9199
  setToolbarVariant("link-action");
9164
9200
  setToolbarRect(link.getBoundingClientRect());
9201
+ setSiblingHintRects(collectNavigationItemSiblingHintRects(link));
9165
9202
  return;
9166
9203
  }
9167
9204
  const colAttr = selectedFooterColAttrRef.current;
@@ -9188,6 +9225,7 @@ function OhhwellsBridge() {
9188
9225
  setReorderDragDisabled(disabled);
9189
9226
  setToolbarVariant("link-action");
9190
9227
  setToolbarRect(navAnchor.getBoundingClientRect());
9228
+ setSiblingHintRects(collectNavigationItemSiblingHintRects(navAnchor));
9191
9229
  setToolbarShowEditLink(false);
9192
9230
  setActiveCommands(/* @__PURE__ */ new Set());
9193
9231
  }, [markSelected]);
@@ -9553,7 +9591,7 @@ function OhhwellsBridge() {
9553
9591
  hoveredItemElRef.current = null;
9554
9592
  siblingHintElRef.current = null;
9555
9593
  setSiblingHintRect(null);
9556
- setSiblingHintRects([]);
9594
+ setSiblingHintRects(collectNavigationItemSiblingHintRects(anchor));
9557
9595
  setIsItemDragging(false);
9558
9596
  const { key, disabled } = getNavigationItemReorderState(anchor);
9559
9597
  setReorderHrefKey(key);
@@ -10225,7 +10263,7 @@ function OhhwellsBridge() {
10225
10263
  hoveredNavContainerRef.current = null;
10226
10264
  setHoveredNavContainerRect(null);
10227
10265
  const selected2 = selectedElRef.current;
10228
- if (selected2 === navAnchor || selected2?.contains(navAnchor)) return;
10266
+ if (selected2 === navAnchor) return;
10229
10267
  clearHrefKeyHover(navAnchor);
10230
10268
  hoveredItemElRef.current = navAnchor;
10231
10269
  setHoveredItemRect(navAnchor.getBoundingClientRect());
@@ -10429,7 +10467,7 @@ function OhhwellsBridge() {
10429
10467
  hoveredNavContainerRef.current = null;
10430
10468
  setHoveredNavContainerRect(null);
10431
10469
  const selected = selectedElRef.current;
10432
- if (selected !== navItemHit && !selected?.contains(navItemHit)) {
10470
+ if (selected !== navItemHit) {
10433
10471
  clearHrefKeyHover(navItemHit);
10434
10472
  hoveredItemElRef.current = navItemHit;
10435
10473
  setHoveredItemRect(navItemHit.getBoundingClientRect());
@@ -11122,10 +11160,14 @@ function OhhwellsBridge() {
11122
11160
  setSiblingHintRect(siblingHintElRef.current.getBoundingClientRect());
11123
11161
  }
11124
11162
  const selected = selectedElRef.current;
11125
- if (selected && !footerDragRef.current && (selected.hasAttribute("data-ohw-footer-col") || Boolean(selected.closest("footer") && isInferredFooterGroup(selected)))) {
11126
- setSiblingHintRects(
11127
- listFooterColumns().filter((column) => column !== selected).map((column) => column.getBoundingClientRect())
11128
- );
11163
+ if (selected && !footerDragRef.current && !navDragRef.current) {
11164
+ if (selected.hasAttribute("data-ohw-footer-col") || Boolean(selected.closest("footer") && isInferredFooterGroup(selected))) {
11165
+ setSiblingHintRects(
11166
+ listFooterColumns().filter((column) => column !== selected).map((column) => column.getBoundingClientRect())
11167
+ );
11168
+ } else if (isNavigationItem(selected)) {
11169
+ setSiblingHintRects(collectNavigationItemSiblingHintRects(selected));
11170
+ }
11129
11171
  }
11130
11172
  if (footerDragRef.current) {
11131
11173
  const session = footerDragRef.current;
@@ -11868,7 +11910,6 @@ function OhhwellsBridge() {
11868
11910
  )),
11869
11911
  hoveredNavContainerRect && toolbarVariant !== "select-frame" && !linkPopover && !isItemDragging && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ItemInteractionLayer, { rect: hoveredNavContainerRect, state: "hover" }),
11870
11912
  toolbarVariant === "select-frame" && toolbarRect && !linkPopover && !isItemDragging && !isFooterFrameSelection && selectedElRef.current && isNavbarLinksContainer(selectedElRef.current) && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(NavbarContainerChrome, { rect: toolbarRect, onAdd: handleAddTopLevelNavItem }),
11871
- hoveredItemRect && !linkPopover && !hoveredNavContainerRect && !isItemDragging && hoveredItemElRef.current !== selectedElRef.current && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ItemInteractionLayer, { rect: hoveredItemRect, state: "hover" }),
11872
11913
  toolbarRect && (toolbarVariant === "link-action" || toolbarVariant === "select-frame") && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
11873
11914
  ItemInteractionLayer,
11874
11915
  {
@@ -11882,6 +11923,7 @@ function OhhwellsBridge() {
11882
11923
  onDragHandleDragEnd: handleItemDragEnd,
11883
11924
  onItemPointerDown: handleItemChromePointerDown,
11884
11925
  onItemClick: handleItemChromeClick,
11926
+ itemDragSurface: !isFooterFrameSelection,
11885
11927
  toolbar: toolbarVariant === "link-action" && !isItemDragging ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
11886
11928
  ItemActionToolbar,
11887
11929
  {
@@ -11895,6 +11937,7 @@ function OhhwellsBridge() {
11895
11937
  ) : void 0
11896
11938
  }
11897
11939
  ),
11940
+ hoveredItemRect && !linkPopover && !hoveredNavContainerRect && !isItemDragging && hoveredItemElRef.current !== selectedElRef.current && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ItemInteractionLayer, { rect: hoveredItemRect, state: "hover" }),
11898
11941
  toolbarRect && toolbarVariant === "rich-text" && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
11899
11942
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
11900
11943
  EditGlowChrome,
@@ -11902,7 +11945,8 @@ function OhhwellsBridge() {
11902
11945
  rect: toolbarRect,
11903
11946
  elRef: glowElRef,
11904
11947
  reorderHrefKey,
11905
- dragDisabled: reorderDragDisabled
11948
+ dragDisabled: reorderDragDisabled,
11949
+ hideHandle: isItemDragging
11906
11950
  }
11907
11951
  ),
11908
11952
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(