@ohhwells/bridge 0.1.117-next.311 → 0.1.117-next.313

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
@@ -10335,16 +10335,16 @@ function AiPricingCardOverlay({
10335
10335
  const runMutation = (0, import_react9.useCallback)(
10336
10336
  async (sectionId, mutate) => {
10337
10337
  const entry = findEntry(sectionId);
10338
- if (!entry) return;
10338
+ if (!entry) return false;
10339
10339
  const nextTree = mutate(entry.tree);
10340
- if (!nextTree) return;
10340
+ if (!nextTree) return false;
10341
10341
  setPending(true);
10342
10342
  setError(null);
10343
10343
  const { ok, reasons } = await requestValidateTree(postToParent2, nextTree);
10344
10344
  setPending(false);
10345
10345
  if (!ok) {
10346
10346
  setError(reasons[0] ?? "That change is not allowed.");
10347
- return;
10347
+ return false;
10348
10348
  }
10349
10349
  applyTreeLocalRef.current?.({
10350
10350
  id: sectionId,
@@ -10358,6 +10358,7 @@ function AiPricingCardOverlay({
10358
10358
  // viewport on every tier add/remove/toggle reads as the section jumping around.
10359
10359
  skipScrollIntoView: true
10360
10360
  });
10361
+ return true;
10361
10362
  },
10362
10363
  [findEntry, postToParent2, applyTreeLocalRef]
10363
10364
  );
@@ -10406,7 +10407,13 @@ function AiPricingCardOverlay({
10406
10407
  pending,
10407
10408
  error,
10408
10409
  onAddTier: () => runMutation(active.sectionId, addPricingTier),
10409
- onRemoveTier: () => runMutation(active.sectionId, (tree) => removePricingTier(tree, active.index)),
10410
+ onRemoveTier: () => {
10411
+ void runMutation(active.sectionId, (tree) => removePricingTier(tree, active.index)).then(
10412
+ (applied) => {
10413
+ if (applied) setActive(null);
10414
+ }
10415
+ );
10416
+ },
10410
10417
  onToggleFeatured: (enabled) => runMutation(
10411
10418
  active.sectionId,
10412
10419
  (tree) => setPricingCardFeatured(tree, active.index, { enabled })
@@ -11216,12 +11223,21 @@ var import_lucide_react14 = require("lucide-react");
11216
11223
  var import_navigation2 = require("next/navigation");
11217
11224
 
11218
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
+ }
11219
11232
  function getIframeVisibleClip(parentScroll) {
11220
11233
  if (!parentScroll) return null;
11221
- const { iframeOffsetTop, headerH: visibleCanvasTop, canvasH, promptBarH = 0 } = parentScroll;
11222
- const clipTop = Math.max(0, visibleCanvasTop - iframeOffsetTop);
11223
- const clipBottom = Math.min(window.innerHeight, visibleCanvasTop + canvasH - iframeOffsetTop) - promptBarH;
11224
- 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) };
11225
11241
  }
11226
11242
 
11227
11243
  // src/ui/link-modal/SectionPickerOverlay.tsx
@@ -15042,34 +15058,38 @@ var import_lucide_react15 = require("lucide-react");
15042
15058
  var import_jsx_runtime28 = require("react/jsx-runtime");
15043
15059
  var PANEL_WIDTH = 256;
15044
15060
  var EDGE_MARGIN = 16;
15061
+ var HEADER_MIN = 56;
15045
15062
  function getVisibleClip(parentScroll) {
15046
15063
  const left = 0;
15047
15064
  const right = window.innerWidth;
15048
- const band = getIframeVisibleClip(parentScroll);
15065
+ const band = getIframeChromeClip(parentScroll);
15049
15066
  if (!band) {
15050
15067
  return { top: 0, bottom: window.innerHeight, left, right };
15051
15068
  }
15052
15069
  return { ...band, left, right };
15053
15070
  }
15054
- function defaultFloatingPanelPosition(parentScroll, panelHeight = 280) {
15071
+ function defaultFloatingPanelPosition(parentScroll, _panelHeight = 280) {
15055
15072
  const clip = getVisibleClip(parentScroll);
15056
15073
  return {
15057
15074
  x: Math.max(EDGE_MARGIN, clip.right - PANEL_WIDTH - EDGE_MARGIN),
15058
- y: Math.min(
15059
- Math.max(clip.top + EDGE_MARGIN, EDGE_MARGIN),
15060
- Math.max(clip.top + EDGE_MARGIN, clip.bottom - panelHeight - EDGE_MARGIN)
15061
- )
15075
+ y: clip.top + EDGE_MARGIN
15062
15076
  };
15063
15077
  }
15064
- function clampPosition(pos, parentScroll, panelW, panelH) {
15078
+ function clampPosition(pos, parentScroll, panelW, _panelH = 280) {
15065
15079
  const clip = getVisibleClip(parentScroll);
15066
15080
  const maxX = Math.max(clip.left + EDGE_MARGIN, clip.right - panelW - EDGE_MARGIN);
15067
- 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);
15068
15083
  return {
15069
15084
  x: Math.min(Math.max(pos.x, clip.left + EDGE_MARGIN), maxX),
15070
- y: Math.min(Math.max(pos.y, clip.top + EDGE_MARGIN), maxY)
15085
+ y: Math.min(Math.max(pos.y, minY), maxY)
15071
15086
  };
15072
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
+ }
15073
15093
  function FloatingPanel({
15074
15094
  open,
15075
15095
  title,
@@ -15086,8 +15106,9 @@ function FloatingPanel({
15086
15106
  const panelRef = (0, import_react14.useRef)(null);
15087
15107
  const [measured, setMeasured] = (0, import_react14.useState)({ w: PANEL_WIDTH, h: 280 });
15088
15108
  const dragRef = (0, import_react14.useRef)(null);
15089
- const resolved = position ?? defaultFloatingPanelPosition(parentScroll, measured.h);
15090
- 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);
15091
15112
  (0, import_react14.useLayoutEffect)(() => {
15092
15113
  if (!open || !panelRef.current) return;
15093
15114
  const el = panelRef.current;
@@ -15173,7 +15194,7 @@ function FloatingPanel({
15173
15194
  "fixed z-[2147483647] flex w-64 flex-col overflow-hidden rounded-xl border border-border bg-background font-sans shadow-lg outline-none",
15174
15195
  className
15175
15196
  ),
15176
- style: { left: clamped.x, top: clamped.y },
15197
+ style: { left: clamped.x, top: clamped.y, maxHeight },
15177
15198
  onMouseDown: (e) => e.stopPropagation(),
15178
15199
  onPointerDown: (e) => e.stopPropagation(),
15179
15200
  onClick: (e) => e.stopPropagation(),
@@ -15182,7 +15203,7 @@ function FloatingPanel({
15182
15203
  "div",
15183
15204
  {
15184
15205
  "data-ohw-floating-panel-header": "",
15185
- 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",
15186
15207
  onPointerDown: onHeaderPointerDown,
15187
15208
  onPointerMove: onHeaderPointerMove,
15188
15209
  onPointerUp: endDrag,
@@ -15217,7 +15238,10 @@ function FloatingPanel({
15217
15238
  "div",
15218
15239
  {
15219
15240
  "data-ohw-floating-panel-body": "",
15220
- 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
+ ),
15221
15245
  children
15222
15246
  }
15223
15247
  )
@@ -17338,7 +17362,7 @@ function useSectionDrag({
17338
17362
  }, [postToParentRef, stopAutoScroll]);
17339
17363
  const updateAutoScroll = (0, import_react16.useCallback)(
17340
17364
  (clientY) => {
17341
- const clip = getIframeVisibleClip(parentScrollRef.current);
17365
+ const clip = getIframeChromeClip(parentScrollRef.current);
17342
17366
  let delta = 0;
17343
17367
  if (clip) {
17344
17368
  const distTop = clientY - clip.top;
@@ -19252,7 +19276,7 @@ function isRectOutsideClip(rect, clip) {
19252
19276
  return rect.bottom < clip.top || rect.top > clip.bottom;
19253
19277
  }
19254
19278
  function applyVisibleViewport(el, parentScroll) {
19255
- const clip = getIframeVisibleClip(parentScroll);
19279
+ const clip = getIframeChromeClip(parentScroll);
19256
19280
  const top = clip?.top ?? 0;
19257
19281
  const height = clip ? clip.bottom - clip.top : window.innerHeight;
19258
19282
  el.style.top = `${top}px`;
@@ -19292,7 +19316,7 @@ function clampToolbarLeft(centerX, toolbarWidth) {
19292
19316
  function calcToolbarPos(rect, parentScroll, toolbarW = 306) {
19293
19317
  const GAP = TOOLBAR_OFFSET_FROM_ELEMENT;
19294
19318
  const APPROX_H = 32;
19295
- const clip = getIframeVisibleClip(parentScroll);
19319
+ const clip = getIframeChromeClip(parentScroll);
19296
19320
  const clipTop = clip?.top ?? 0;
19297
19321
  const canvasTopInIframe = parentScroll != null ? parentScroll.headerH - parentScroll.iframeOffsetTop : 0;
19298
19322
  const visibleTop = rect.top - canvasTopInIframe;