@ohhwells/bridge 0.1.117-next.312 → 0.1.117-next.314

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
@@ -11223,12 +11223,21 @@ var import_lucide_react14 = require("lucide-react");
11223
11223
  var import_navigation2 = require("next/navigation");
11224
11224
 
11225
11225
  // src/lib/parent-scroll.ts
11226
+ function visibleBand(parentScroll) {
11227
+ const { iframeOffsetTop, headerH: visibleCanvasTop, canvasH } = parentScroll;
11228
+ const top = Math.max(0, visibleCanvasTop - iframeOffsetTop);
11229
+ const bottom = Math.min(window.innerHeight, visibleCanvasTop + canvasH - iframeOffsetTop);
11230
+ return { top, bottom: Math.max(top, bottom) };
11231
+ }
11226
11232
  function getIframeVisibleClip(parentScroll) {
11227
11233
  if (!parentScroll) return null;
11228
- const { iframeOffsetTop, headerH: visibleCanvasTop, canvasH, promptBarH = 0 } = parentScroll;
11229
- const clipTop = Math.max(0, visibleCanvasTop - iframeOffsetTop);
11230
- const clipBottom = Math.min(window.innerHeight, visibleCanvasTop + canvasH - iframeOffsetTop) - promptBarH;
11231
- return { top: clipTop, bottom: Math.max(clipTop, clipBottom) };
11234
+ return visibleBand(parentScroll);
11235
+ }
11236
+ function getIframeChromeClip(parentScroll) {
11237
+ if (!parentScroll) return null;
11238
+ const band = visibleBand(parentScroll);
11239
+ const promptBarH = Math.max(0, parentScroll.promptBarH ?? 0);
11240
+ return { top: band.top, bottom: Math.max(band.top, band.bottom - promptBarH) };
11232
11241
  }
11233
11242
 
11234
11243
  // src/ui/link-modal/SectionPickerOverlay.tsx
@@ -15049,34 +15058,38 @@ var import_lucide_react15 = require("lucide-react");
15049
15058
  var import_jsx_runtime28 = require("react/jsx-runtime");
15050
15059
  var PANEL_WIDTH = 256;
15051
15060
  var EDGE_MARGIN = 16;
15061
+ var HEADER_MIN = 56;
15052
15062
  function getVisibleClip(parentScroll) {
15053
15063
  const left = 0;
15054
15064
  const right = window.innerWidth;
15055
- const band = getIframeVisibleClip(parentScroll);
15065
+ const band = getIframeChromeClip(parentScroll);
15056
15066
  if (!band) {
15057
15067
  return { top: 0, bottom: window.innerHeight, left, right };
15058
15068
  }
15059
15069
  return { ...band, left, right };
15060
15070
  }
15061
- function defaultFloatingPanelPosition(parentScroll, panelHeight = 280) {
15071
+ function defaultFloatingPanelPosition(parentScroll, _panelHeight = 280) {
15062
15072
  const clip = getVisibleClip(parentScroll);
15063
15073
  return {
15064
15074
  x: Math.max(EDGE_MARGIN, clip.right - PANEL_WIDTH - EDGE_MARGIN),
15065
- y: Math.min(
15066
- Math.max(clip.top + EDGE_MARGIN, EDGE_MARGIN),
15067
- Math.max(clip.top + EDGE_MARGIN, clip.bottom - panelHeight - EDGE_MARGIN)
15068
- )
15075
+ y: clip.top + EDGE_MARGIN
15069
15076
  };
15070
15077
  }
15071
- function clampPosition(pos, parentScroll, panelW, panelH) {
15078
+ function clampPosition(pos, parentScroll, panelW, _panelH = 280) {
15072
15079
  const clip = getVisibleClip(parentScroll);
15073
15080
  const maxX = Math.max(clip.left + EDGE_MARGIN, clip.right - panelW - EDGE_MARGIN);
15074
- const maxY = Math.max(clip.top + EDGE_MARGIN, clip.bottom - panelH - EDGE_MARGIN);
15081
+ const minY = clip.top + EDGE_MARGIN;
15082
+ const maxY = Math.max(minY, clip.bottom - EDGE_MARGIN - HEADER_MIN);
15075
15083
  return {
15076
15084
  x: Math.min(Math.max(pos.x, clip.left + EDGE_MARGIN), maxX),
15077
- y: Math.min(Math.max(pos.y, clip.top + EDGE_MARGIN), maxY)
15085
+ y: Math.min(Math.max(pos.y, minY), maxY)
15078
15086
  };
15079
15087
  }
15088
+ function availablePanelHeight(parentScroll, top) {
15089
+ const clip = getVisibleClip(parentScroll);
15090
+ const available = Math.floor(clip.bottom - top - EDGE_MARGIN);
15091
+ return available > HEADER_MIN ? available : void 0;
15092
+ }
15080
15093
  function FloatingPanel({
15081
15094
  open,
15082
15095
  title,
@@ -15093,8 +15106,9 @@ function FloatingPanel({
15093
15106
  const panelRef = (0, import_react14.useRef)(null);
15094
15107
  const [measured, setMeasured] = (0, import_react14.useState)({ w: PANEL_WIDTH, h: 280 });
15095
15108
  const dragRef = (0, import_react14.useRef)(null);
15096
- const resolved = position ?? defaultFloatingPanelPosition(parentScroll, measured.h);
15097
- const clamped = clampPosition(resolved, parentScroll, measured.w, measured.h);
15109
+ const resolved = position ?? defaultFloatingPanelPosition(parentScroll);
15110
+ const clamped = clampPosition(resolved, parentScroll, measured.w);
15111
+ const maxHeight = availablePanelHeight(parentScroll, clamped.y);
15098
15112
  (0, import_react14.useLayoutEffect)(() => {
15099
15113
  if (!open || !panelRef.current) return;
15100
15114
  const el = panelRef.current;
@@ -15180,7 +15194,7 @@ function FloatingPanel({
15180
15194
  "fixed z-[2147483647] flex w-64 flex-col overflow-hidden rounded-xl border border-border bg-background font-sans shadow-lg outline-none",
15181
15195
  className
15182
15196
  ),
15183
- style: { left: clamped.x, top: clamped.y },
15197
+ style: { left: clamped.x, top: clamped.y, maxHeight },
15184
15198
  onMouseDown: (e) => e.stopPropagation(),
15185
15199
  onPointerDown: (e) => e.stopPropagation(),
15186
15200
  onClick: (e) => e.stopPropagation(),
@@ -15189,7 +15203,7 @@ function FloatingPanel({
15189
15203
  "div",
15190
15204
  {
15191
15205
  "data-ohw-floating-panel-header": "",
15192
- className: "relative flex cursor-grab items-start gap-2 border-b border-border py-5 pl-5 pr-11 active:cursor-grabbing",
15206
+ className: "relative flex shrink-0 cursor-grab items-start gap-2 border-b border-border py-5 pl-5 pr-11 active:cursor-grabbing",
15193
15207
  onPointerDown: onHeaderPointerDown,
15194
15208
  onPointerMove: onHeaderPointerMove,
15195
15209
  onPointerUp: endDrag,
@@ -15224,7 +15238,11 @@ function FloatingPanel({
15224
15238
  "div",
15225
15239
  {
15226
15240
  "data-ohw-floating-panel-body": "",
15227
- className: cn("flex w-full flex-col gap-4 p-5", bodyClassName),
15241
+ className: cn(
15242
+ "flex min-h-0 w-full flex-1 flex-col gap-4 overflow-y-auto overscroll-contain p-5",
15243
+ bodyClassName
15244
+ ),
15245
+ style: { WebkitOverflowScrolling: "touch" },
15228
15246
  children
15229
15247
  }
15230
15248
  )
@@ -17345,7 +17363,7 @@ function useSectionDrag({
17345
17363
  }, [postToParentRef, stopAutoScroll]);
17346
17364
  const updateAutoScroll = (0, import_react16.useCallback)(
17347
17365
  (clientY) => {
17348
- const clip = getIframeVisibleClip(parentScrollRef.current);
17366
+ const clip = getIframeChromeClip(parentScrollRef.current);
17349
17367
  let delta = 0;
17350
17368
  if (clip) {
17351
17369
  const distTop = clientY - clip.top;
@@ -19259,7 +19277,7 @@ function isRectOutsideClip(rect, clip) {
19259
19277
  return rect.bottom < clip.top || rect.top > clip.bottom;
19260
19278
  }
19261
19279
  function applyVisibleViewport(el, parentScroll) {
19262
- const clip = getIframeVisibleClip(parentScroll);
19280
+ const clip = getIframeChromeClip(parentScroll);
19263
19281
  const top = clip?.top ?? 0;
19264
19282
  const height = clip ? clip.bottom - clip.top : window.innerHeight;
19265
19283
  el.style.top = `${top}px`;
@@ -19299,7 +19317,7 @@ function clampToolbarLeft(centerX, toolbarWidth) {
19299
19317
  function calcToolbarPos(rect, parentScroll, toolbarW = 306) {
19300
19318
  const GAP = TOOLBAR_OFFSET_FROM_ELEMENT;
19301
19319
  const APPROX_H = 32;
19302
- const clip = getIframeVisibleClip(parentScroll);
19320
+ const clip = getIframeChromeClip(parentScroll);
19303
19321
  const clipTop = clip?.top ?? 0;
19304
19322
  const canvasTopInIframe = parentScroll != null ? parentScroll.headerH - parentScroll.iframeOffsetTop : 0;
19305
19323
  const visibleTop = rect.top - canvasTopInIframe;