@ohhwells/bridge 0.1.117-next.321 → 0.1.117-next.323

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
@@ -8504,8 +8504,15 @@ function ItemInteractionLayer({
8504
8504
  itemDragSurface = true,
8505
8505
  chromeGap,
8506
8506
  toolbarAlign = "center",
8507
+ hidden = false,
8507
8508
  className
8508
8509
  }) {
8510
+ const localRef = (0, import_react7.useRef)(null);
8511
+ (0, import_react7.useLayoutEffect)(() => {
8512
+ const node = localRef.current;
8513
+ if (!node) return;
8514
+ node.style.display = hidden ? "none" : "block";
8515
+ }, [hidden, rect.top, rect.left, rect.width, rect.height, state]);
8509
8516
  if (state === "default") return null;
8510
8517
  const gap = chromeGap ?? (state === "hover" ? HOVER_CHROME_GAP : SELECTION_CHROME_GAP);
8511
8518
  const isActive = state === "active-top" || state === "active-bottom";
@@ -8514,10 +8521,15 @@ function ItemInteractionLayer({
8514
8521
  const showDragHandle = (isActive || isDragging) && showHandle;
8515
8522
  const itemDragEnabled = itemDragSurface && isActive && !isDragging && !dragDisabled && Boolean(showHandle || onItemPointerDown);
8516
8523
  const useDetachedBelowToolbar = Boolean(showToolbar && state === "active-bottom" && toolbarBelowRect);
8524
+ const setRootRef = (node) => {
8525
+ localRef.current = node;
8526
+ if (typeof elRef === "function") elRef(node);
8527
+ else if (elRef) elRef.current = node;
8528
+ };
8517
8529
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
8518
8530
  "div",
8519
8531
  {
8520
- ref: elRef,
8532
+ ref: setRootRef,
8521
8533
  "data-ohw-item-interaction": "",
8522
8534
  "data-ohw-item-interaction-state": state,
8523
8535
  className: cn("pointer-events-none", className),
@@ -8527,7 +8539,8 @@ function ItemInteractionLayer({
8527
8539
  left: rect.left - gap,
8528
8540
  width: rect.width + gap * 2,
8529
8541
  height: rect.height + gap * 2,
8530
- zIndex: getChromeZIndex(state)
8542
+ zIndex: getChromeZIndex(state),
8543
+ display: hidden ? "none" : "block"
8531
8544
  },
8532
8545
  children: [
8533
8546
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
@@ -15240,14 +15253,18 @@ function clampDragPosition(pos, parentScroll, panelW) {
15240
15253
  y: Math.min(Math.max(pos.y, minY), maxY)
15241
15254
  };
15242
15255
  }
15243
- function stickyPageY(homeY, parentScroll) {
15244
- const clip = getVisibleClip(parentScroll);
15245
- return Math.max(homeY, clip.top + EDGE_MARGIN);
15246
- }
15247
- function availablePanelHeight(parentScroll, top) {
15256
+ function fitPanelInClip(homeY, parentScroll, preferredHeight) {
15248
15257
  const clip = getVisibleClip(parentScroll);
15249
- const available = Math.floor(clip.bottom - top - EDGE_MARGIN);
15250
- return available > HEADER_MIN ? available : void 0;
15258
+ const minY = clip.top + EDGE_MARGIN;
15259
+ const maxBottom = clip.bottom - EDGE_MARGIN;
15260
+ const band = Math.max(HEADER_MIN, maxBottom - minY);
15261
+ let y = Math.max(homeY, minY);
15262
+ const want = Math.min(Math.max(preferredHeight, HEADER_MIN), band);
15263
+ if (y + want > maxBottom) {
15264
+ y = Math.max(minY, maxBottom - want);
15265
+ }
15266
+ const maxHeight = Math.max(HEADER_MIN, Math.floor(maxBottom - y));
15267
+ return { y, maxHeight };
15251
15268
  }
15252
15269
  function FloatingPanel({
15253
15270
  open,
@@ -15275,11 +15292,11 @@ function FloatingPanel({
15275
15292
  }
15276
15293
  const [liveScroll, setLiveScroll] = (0, import_react14.useState)(parentScroll);
15277
15294
  const home = position ?? homeRef.current ?? defaultFloatingPanelPosition(parentScroll);
15295
+ const { y: fittedY, maxHeight } = fitPanelInClip(home.y, liveScroll, measured.h);
15278
15296
  const clamped = {
15279
15297
  x: clampX(home.x, measured.w),
15280
- y: stickyPageY(home.y, liveScroll)
15298
+ y: fittedY
15281
15299
  };
15282
- const maxHeight = availablePanelHeight(liveScroll, clamped.y);
15283
15300
  (0, import_react14.useEffect)(() => {
15284
15301
  if (!open) {
15285
15302
  setLiveScroll(parentScroll);
@@ -15296,7 +15313,10 @@ function FloatingPanel({
15296
15313
  (0, import_react14.useLayoutEffect)(() => {
15297
15314
  if (!open || !panelRef.current) return;
15298
15315
  const el = panelRef.current;
15299
- const next = { w: el.offsetWidth || PANEL_WIDTH, h: el.offsetHeight || 280 };
15316
+ const header = el.querySelector("[data-ohw-floating-panel-header]");
15317
+ const body = el.querySelector("[data-ohw-floating-panel-body]");
15318
+ const contentH = (header?.offsetHeight ?? 0) + (body?.scrollHeight ?? 0) || el.scrollHeight || 280;
15319
+ const next = { w: el.offsetWidth || PANEL_WIDTH, h: contentH };
15300
15320
  setMeasured((prev) => prev.w === next.w && prev.h === next.h ? prev : next);
15301
15321
  }, [open, children, title, context]);
15302
15322
  const onHeaderPointerDown = (0, import_react14.useCallback)(
@@ -16479,6 +16499,11 @@ function rekeyCopy(copy, id) {
16479
16499
  setButtonDragAttr(copy);
16480
16500
  return { labelKey };
16481
16501
  }
16502
+ function stampVariantClass(el, variant) {
16503
+ const raw = typeof el.className === "string" ? el.className : el.getAttribute("class") || "";
16504
+ const without = raw.replace(/\bbtn--(?:primary|secondary|ghost)\b/g, "").replace(/\s+/g, " ").trim();
16505
+ el.className = without ? `${without} btn--${variant}` : `btn btn--${variant}`;
16506
+ }
16482
16507
  function snapshotOf(el) {
16483
16508
  const id = buttonId(el) ?? "";
16484
16509
  const label = labelElement2(el);
@@ -16511,8 +16536,13 @@ function duplicateButton(source, content) {
16511
16536
  const href = buttonHref(source);
16512
16537
  const label = buttonLabel(source);
16513
16538
  if (href) copy.setAttribute("href", href);
16514
- const assignment = readAssignments(content)[sourceId];
16515
- if (assignment) applyButtonStyle(copy, assignment, tokens);
16539
+ const sourceAssignment = readAssignments(content)[sourceId] ?? assignmentFor(source, content, tokens);
16540
+ const copyAssignment = {
16541
+ variant: "secondary",
16542
+ size: sourceAssignment.size
16543
+ };
16544
+ stampVariantClass(copy, "secondary");
16545
+ applyButtonStyle(copy, copyAssignment, tokens);
16516
16546
  const copyLabelEl = labelElement2(copy);
16517
16547
  if (copyLabelEl) copyLabelEl.textContent = label;
16518
16548
  let collection = buttonCollectionOf(source);
@@ -16546,20 +16576,18 @@ function duplicateButton(source, content) {
16546
16576
  ...collections,
16547
16577
  [collectionId]: { id: collectionId, members, gap }
16548
16578
  };
16549
- const assignments = assignment ? withAssignment(content, copyId, assignment) : readAssignments(content);
16579
+ const assignments = withAssignment(content, copyId, copyAssignment);
16550
16580
  const nextContent = {
16551
16581
  ...content,
16552
16582
  [copyId]: href,
16553
16583
  [labelKey]: label,
16554
16584
  [BUTTON_COLLECTIONS_KEY]: JSON.stringify(nextCollections),
16555
- [BUTTON_SNAPSHOTS_KEY]: JSON.stringify(snapshots)
16585
+ [BUTTON_SNAPSHOTS_KEY]: JSON.stringify(snapshots),
16586
+ [BUTTON_ASSIGNMENTS_KEY]: JSON.stringify(assignments)
16556
16587
  };
16557
16588
  if (sourceLabelKey && nextContent[sourceLabelKey] === void 0) {
16558
16589
  nextContent[sourceLabelKey] = label;
16559
16590
  }
16560
- if (Object.keys(assignments).length > 0) {
16561
- nextContent[BUTTON_ASSIGNMENTS_KEY] = JSON.stringify(assignments);
16562
- }
16563
16591
  const nodeKeys = [
16564
16592
  copyId,
16565
16593
  labelKey,
@@ -21619,6 +21647,7 @@ function OhhwellsBridge() {
21619
21647
  setIsFooterFrameSelection(false);
21620
21648
  setToolbarVariant("link-action");
21621
21649
  setToolbarRect(anchor.getBoundingClientRect());
21650
+ if (glowElRef.current) glowElRef.current.style.display = "";
21622
21651
  setToolbarShowEditLink(false);
21623
21652
  setActiveCommands(/* @__PURE__ */ new Set());
21624
21653
  const panel = floatingPanelRef.current;
@@ -21725,6 +21754,7 @@ function OhhwellsBridge() {
21725
21754
  });
21726
21755
  }, []);
21727
21756
  const openSocialsDisplayPanel = (0, import_react18.useCallback)((row) => {
21757
+ setFloatingPanelPos(null);
21728
21758
  setParentScrollSnap(parentScrollRef.current);
21729
21759
  setFloatingPanel({
21730
21760
  key: "socials-display",
@@ -26819,6 +26849,10 @@ function OhhwellsBridge() {
26819
26849
  toolbarBelowRect: selectedElRef.current && isNavigationItem2(selectedElRef.current) ? getOpenNavDropdownPanelRect(selectedElRef.current) : null,
26820
26850
  toolbarBelowEl: selectedElRef.current && isNavigationItem2(selectedElRef.current) ? getOpenNavDropdownPanel(selectedElRef.current) : null,
26821
26851
  elRef: glowElRef,
26852
+ hidden: isRectOutsideClip(
26853
+ isItemDragging && draggedItemRect && (footerDragRef.current?.wasSelected || navDragRef.current?.wasSelected || selectedElRef.current === buttonCollectionDragRef.current) ? draggedItemRect : toolbarRect,
26854
+ getIframeVisibleClip(parentScrollRef.current)
26855
+ ),
26822
26856
  state: isItemDragging ? "dragging" : selectedElRef.current && isNavigationItem2(selectedElRef.current) && getOpenNavDropdownPanel(selectedElRef.current) ? "active-bottom" : resolveItemInteractionState(toolbarRect, parentScrollRef.current),
26823
26857
  showHandle: toolbarVariant === "link-action" && Boolean(reorderHrefKey) || toolbarVariant === "select-frame" && isFooterFrameSelection,
26824
26858
  dragDisabled: reorderDragDisabled,