@ohhwells/bridge 0.1.42-next.90 → 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
  },
@@ -8493,7 +8511,8 @@ function EditGlowChrome({
8493
8511
  rect,
8494
8512
  elRef,
8495
8513
  reorderHrefKey,
8496
- dragDisabled = false
8514
+ dragDisabled = false,
8515
+ hideHandle = false
8497
8516
  }) {
8498
8517
  const GAP = SELECTION_CHROME_GAP2;
8499
8518
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
@@ -8524,7 +8543,7 @@ function EditGlowChrome({
8524
8543
  }
8525
8544
  }
8526
8545
  ),
8527
- reorderHrefKey && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
8546
+ reorderHrefKey && !hideHandle && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
8528
8547
  "div",
8529
8548
  {
8530
8549
  "data-ohw-drag-handle-container": "",
@@ -10225,8 +10244,7 @@ function OhhwellsBridge() {
10225
10244
  setHoveredNavContainerRect(null);
10226
10245
  return;
10227
10246
  }
10228
- const itemSelected = toolbarVariantRef.current === "link-action" && Boolean(selectedElRef.current && isNavigationItem(selectedElRef.current));
10229
- if (toolbarVariantRef.current !== "select-frame" && !itemSelected) {
10247
+ if (toolbarVariantRef.current !== "select-frame") {
10230
10248
  const navContainer = target.closest("[data-ohw-nav-container]");
10231
10249
  if (navContainer && !getNavigationItemAnchor(target)) {
10232
10250
  hoveredNavContainerRef.current = navContainer;
@@ -10239,16 +10257,13 @@ function OhhwellsBridge() {
10239
10257
  hoveredNavContainerRef.current = null;
10240
10258
  setHoveredNavContainerRect(null);
10241
10259
  }
10242
- } else if (itemSelected) {
10243
- hoveredNavContainerRef.current = null;
10244
- setHoveredNavContainerRect(null);
10245
10260
  }
10246
10261
  const navAnchor = getNavigationItemAnchor(target);
10247
10262
  if (navAnchor) {
10248
10263
  hoveredNavContainerRef.current = null;
10249
10264
  setHoveredNavContainerRect(null);
10250
10265
  const selected2 = selectedElRef.current;
10251
- if (selected2 === navAnchor || selected2?.contains(navAnchor)) return;
10266
+ if (selected2 === navAnchor) return;
10252
10267
  clearHrefKeyHover(navAnchor);
10253
10268
  hoveredItemElRef.current = navAnchor;
10254
10269
  setHoveredItemRect(navAnchor.getBoundingClientRect());
@@ -10258,7 +10273,7 @@ function OhhwellsBridge() {
10258
10273
  if (footerCol) {
10259
10274
  hoveredNavContainerRef.current = null;
10260
10275
  setHoveredNavContainerRect(null);
10261
- if (itemSelected || selectedElRef.current === footerCol) return;
10276
+ if (selectedElRef.current === footerCol) return;
10262
10277
  hoveredItemElRef.current = footerCol;
10263
10278
  setHoveredItemRect(footerCol.getBoundingClientRect());
10264
10279
  return;
@@ -10429,8 +10444,7 @@ function OhhwellsBridge() {
10429
10444
  }
10430
10445
  };
10431
10446
  const probeNavigationHoverAt = (x, y) => {
10432
- const itemSelected = toolbarVariantRef.current === "link-action" && Boolean(selectedElRef.current && isNavigationItem(selectedElRef.current));
10433
- if (toolbarVariantRef.current === "select-frame" || itemSelected) {
10447
+ if (toolbarVariantRef.current === "select-frame") {
10434
10448
  hoveredNavContainerRef.current = null;
10435
10449
  setHoveredNavContainerRect(null);
10436
10450
  }
@@ -10453,7 +10467,7 @@ function OhhwellsBridge() {
10453
10467
  hoveredNavContainerRef.current = null;
10454
10468
  setHoveredNavContainerRect(null);
10455
10469
  const selected = selectedElRef.current;
10456
- if (selected !== navItemHit && !selected?.contains(navItemHit)) {
10470
+ if (selected !== navItemHit) {
10457
10471
  clearHrefKeyHover(navItemHit);
10458
10472
  hoveredItemElRef.current = navItemHit;
10459
10473
  setHoveredItemRect(navItemHit.getBoundingClientRect());
@@ -10464,7 +10478,7 @@ function OhhwellsBridge() {
10464
10478
  return;
10465
10479
  }
10466
10480
  }
10467
- if (toolbarVariantRef.current !== "select-frame" && !itemSelected) {
10481
+ if (toolbarVariantRef.current !== "select-frame") {
10468
10482
  for (const container of navContainers) {
10469
10483
  const containerRect = container.getBoundingClientRect();
10470
10484
  const overContainer = x >= containerRect.left && x <= containerRect.right && y >= containerRect.top && y <= containerRect.bottom;
@@ -10482,23 +10496,21 @@ function OhhwellsBridge() {
10482
10496
  hoveredNavContainerRef.current = null;
10483
10497
  setHoveredNavContainerRect(null);
10484
10498
  }
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;
10499
+ for (const column of footerColumns) {
10500
+ const containerRect = column.getBoundingClientRect();
10501
+ const overContainer = x >= containerRect.left && x <= containerRect.right && y >= containerRect.top && y <= containerRect.bottom;
10502
+ if (!overContainer) continue;
10503
+ if (isPointOverNavItem(column, x, y)) continue;
10504
+ if (selectedElRef.current === column) {
10505
+ if (hoveredItemElRef.current === column) {
10506
+ hoveredItemElRef.current = null;
10507
+ setHoveredItemRect(null);
10497
10508
  }
10498
- hoveredItemElRef.current = column;
10499
- setHoveredItemRect(column.getBoundingClientRect());
10500
10509
  return;
10501
10510
  }
10511
+ hoveredItemElRef.current = column;
10512
+ setHoveredItemRect(column.getBoundingClientRect());
10513
+ return;
10502
10514
  }
10503
10515
  if (hoveredItemElRef.current?.hasAttribute("data-ohw-footer-col") || hoveredItemElRef.current?.hasAttribute("data-ohw-footer-column")) {
10504
10516
  hoveredItemElRef.current = null;
@@ -11898,7 +11910,6 @@ function OhhwellsBridge() {
11898
11910
  )),
11899
11911
  hoveredNavContainerRect && toolbarVariant !== "select-frame" && !linkPopover && !isItemDragging && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ItemInteractionLayer, { rect: hoveredNavContainerRect, state: "hover" }),
11900
11912
  toolbarVariant === "select-frame" && toolbarRect && !linkPopover && !isItemDragging && !isFooterFrameSelection && selectedElRef.current && isNavbarLinksContainer(selectedElRef.current) && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(NavbarContainerChrome, { rect: toolbarRect, onAdd: handleAddTopLevelNavItem }),
11901
- hoveredItemRect && !linkPopover && !hoveredNavContainerRect && !isItemDragging && hoveredItemElRef.current !== selectedElRef.current && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ItemInteractionLayer, { rect: hoveredItemRect, state: "hover" }),
11902
11913
  toolbarRect && (toolbarVariant === "link-action" || toolbarVariant === "select-frame") && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
11903
11914
  ItemInteractionLayer,
11904
11915
  {
@@ -11912,6 +11923,7 @@ function OhhwellsBridge() {
11912
11923
  onDragHandleDragEnd: handleItemDragEnd,
11913
11924
  onItemPointerDown: handleItemChromePointerDown,
11914
11925
  onItemClick: handleItemChromeClick,
11926
+ itemDragSurface: !isFooterFrameSelection,
11915
11927
  toolbar: toolbarVariant === "link-action" && !isItemDragging ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
11916
11928
  ItemActionToolbar,
11917
11929
  {
@@ -11925,6 +11937,7 @@ function OhhwellsBridge() {
11925
11937
  ) : void 0
11926
11938
  }
11927
11939
  ),
11940
+ hoveredItemRect && !linkPopover && !hoveredNavContainerRect && !isItemDragging && hoveredItemElRef.current !== selectedElRef.current && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ItemInteractionLayer, { rect: hoveredItemRect, state: "hover" }),
11928
11941
  toolbarRect && toolbarVariant === "rich-text" && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
11929
11942
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
11930
11943
  EditGlowChrome,
@@ -11932,7 +11945,8 @@ function OhhwellsBridge() {
11932
11945
  rect: toolbarRect,
11933
11946
  elRef: glowElRef,
11934
11947
  reorderHrefKey,
11935
- dragDisabled: reorderDragDisabled
11948
+ dragDisabled: reorderDragDisabled,
11949
+ hideHandle: isItemDragging
11936
11950
  }
11937
11951
  ),
11938
11952
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(