@mgamadeus/ddd-design-studio 0.3.2 → 0.4.0

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.
@@ -1,6 +1,9 @@
1
1
  'use client';
2
2
  import {
3
3
  CODE_PARAM,
4
+ FRAME_GAP,
5
+ FRAME_LABEL_HEIGHT,
6
+ boardCanvasSize,
4
7
  boardCodeOf,
5
8
  buildBoardCodeLink,
6
9
  buildBoardDeepLink,
@@ -9,12 +12,23 @@ import {
9
12
  copyTextToClipboard,
10
13
  cx,
11
14
  findBoardForCode,
15
+ frameCanvasHeight,
16
+ framesOf,
17
+ initialViewportForBoard,
18
+ isPinInViewport,
19
+ isResponsiveBoard,
12
20
  normalizeBoardCode,
21
+ pageHeightAtWidth,
22
+ rotateViewport,
13
23
  splitThemeReference,
14
24
  useDesignStudio,
15
25
  useDesignStudioComponents,
16
- useDesignStudioTexts
17
- } from "../chunk-ICDABLFY.js";
26
+ useDesignStudioTexts,
27
+ viewportLabel,
28
+ viewportOfComment,
29
+ viewportOfDevice,
30
+ viewportWithWidth
31
+ } from "../chunk-YYKTDLFF.js";
18
32
 
19
33
  // src/canvas/DesignStudioCanvasScreen.tsx
20
34
  import { normalizeDddError as normalizeDddError3 } from "@mgamadeus/ddd-web/api";
@@ -32,9 +46,11 @@ import {
32
46
  PanelRightClose,
33
47
  PanelRightOpen,
34
48
  RefreshCw,
35
- Sun
49
+ Sun,
50
+ FoldVertical,
51
+ UnfoldVertical
36
52
  } from "lucide-react";
37
- import { useCallback as useCallback2, useEffect as useEffect6, useMemo as useMemo2, useRef as useRef3, useState as useState8 } from "react";
53
+ import { useCallback as useCallback2, useEffect as useEffect6, useMemo as useMemo2, useRef as useRef4, useState as useState8 } from "react";
38
54
 
39
55
  // src/canvas/BoardComments.tsx
40
56
  import { normalizeDddError } from "@mgamadeus/ddd-web/api";
@@ -94,9 +110,11 @@ var ThreadCard = ({
94
110
  authAccountId,
95
111
  writesAllowed,
96
112
  hasBoardChangedSince,
97
- isExpiring
113
+ isExpiring,
114
+ onSelectViewport
98
115
  }) => {
99
116
  const { root, replies, pinNumber } = thread;
117
+ const rootViewport = viewportOfComment(root);
100
118
  const [replyText, setReplyText] = useState("");
101
119
  const { api, components, notify } = useDesignStudio();
102
120
  const { Badge, Button, Textarea } = components;
@@ -138,6 +156,22 @@ var ThreadCard = ({
138
156
  " ",
139
157
  pinNumber
140
158
  ] }) : /* @__PURE__ */ jsx(Badge, { variant: "outline", children: "Board" }),
159
+ rootViewport && /* @__PURE__ */ jsxs(
160
+ "button",
161
+ {
162
+ type: "button",
163
+ className: "rounded-full bg-tint px-2 py-0.5 text-xs font-medium text-muted-foreground tabular-nums hover:bg-tint-strong hover:text-foreground disabled:cursor-default",
164
+ title: "Pinned in this viewport: show the board in it",
165
+ disabled: !onSelectViewport,
166
+ onClick: () => onSelectViewport?.(rootViewport),
167
+ children: [
168
+ rootViewport.width,
169
+ " \xD7 ",
170
+ rootViewport.height,
171
+ rootViewport.deviceKey ? ` \xB7 ${rootViewport.deviceKey}` : ""
172
+ ]
173
+ }
174
+ ),
141
175
  root.isDecision && /* @__PURE__ */ jsxs(Badge, { variant: "outline", className: "border-transparent bg-success/15 text-success", children: [
142
176
  /* @__PURE__ */ jsx(Flag, { "aria-hidden": true }),
143
177
  " Decision"
@@ -281,7 +315,8 @@ var BoardComments = ({
281
315
  showResolved,
282
316
  onShowResolvedChange,
283
317
  pinHint,
284
- onCopyThreadReference
318
+ onCopyThreadReference,
319
+ onSelectViewport
285
320
  }) => {
286
321
  const [text, setText] = useState("");
287
322
  const [isDecision, setIsDecision] = useState(false);
@@ -305,6 +340,9 @@ var BoardComments = ({
305
340
  text,
306
341
  x: pendingPin?.x ?? null,
307
342
  y: pendingPin?.y ?? null,
343
+ viewportWidth: pendingPin?.viewport?.width ?? null,
344
+ viewportHeight: pendingPin?.viewport?.height ?? null,
345
+ deviceKey: pendingPin?.viewport?.deviceKey ?? null,
308
346
  isDecision
309
347
  }
310
348
  }).unwrap();
@@ -370,6 +408,7 @@ var BoardComments = ({
370
408
  {
371
409
  thread,
372
410
  onCopyReference: onCopyThreadReference,
411
+ onSelectViewport,
373
412
  isHighlighted: highlightedCommentId === Number(thread.root.id),
374
413
  onHighlight: () => onHighlightComment(Number(thread.root.id)),
375
414
  authAccountId,
@@ -383,8 +422,18 @@ var BoardComments = ({
383
422
  };
384
423
 
385
424
  // src/canvas/BoardFocusView.tsx
386
- import { ChevronLeft, ChevronRight, ClipboardCopy as ClipboardCopy3, MapPin as MapPin2, MapPinPlus, SquareDashedMousePointer, X } from "lucide-react";
387
- import { useEffect as useEffect4, useState as useState6 } from "react";
425
+ import {
426
+ ChevronLeft,
427
+ ChevronRight,
428
+ ClipboardCopy as ClipboardCopy3,
429
+ MapPin as MapPin2,
430
+ MapPinPlus,
431
+ RotateCw,
432
+ Smartphone,
433
+ SquareDashedMousePointer,
434
+ X
435
+ } from "lucide-react";
436
+ import { useEffect as useEffect4, useRef as useRef2, useState as useState6 } from "react";
388
437
 
389
438
  // src/canvas/BoardNode.tsx
390
439
  import { useStore } from "@xyflow/react";
@@ -830,7 +879,7 @@ var useStableContentUrl = (url, isDisplayed = false) => {
830
879
  };
831
880
 
832
881
  // src/canvas/BoardNode.tsx
833
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
882
+ import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
834
883
  var isSameContent = (first, second) => Boolean(first && second) && withoutContentToken(first) === withoutContentToken(second);
835
884
  var designContentUrl = (apiBaseUrl, path) => path ? `${apiBaseUrl}${path}` : void 0;
836
885
  var downloadName = (board, extension) => `${boardCodeOf(board.boardKey ?? "board")}.${extension}`;
@@ -842,27 +891,31 @@ var BoardNodeComponent = ({ id, data }) => {
842
891
  const texts = useDesignStudioTexts();
843
892
  const { StatusBadge } = components;
844
893
  const statusDefinition = board.status ? boardStatusDefinition(statuses, board.status) : void 0;
845
- const width = board.width ?? 390;
846
- const height = board.height ?? 844;
847
- const visibleHeight = Math.min(height, MAX_BOARD_CANVAS_HEIGHT);
848
- const isCut = height > visibleHeight;
849
- const thumbnailVariant = useStore((state) => thumbnailVariantForZoom(state.transform[2], width));
850
894
  const {
851
895
  liveBoardIds,
852
896
  selectedBoardIds,
853
897
  matchingBoardIds,
854
898
  openThreadCounts,
855
899
  defaultStatus,
900
+ frameHeightMode,
901
+ devices,
856
902
  onSelectBoard,
857
903
  onCopyReference,
858
904
  onOpenBoard
859
905
  } = useCanvasView();
906
+ const isResponsive = isResponsiveBoard(board);
907
+ const canvasSize = boardCanvasSize(board, frameHeightMode);
908
+ const width = canvasSize.width;
909
+ const height = canvasSize.height;
910
+ const visibleHeight = isResponsive ? height : Math.min(height, MAX_BOARD_CANVAS_HEIGHT);
911
+ const isCut = height > visibleHeight;
912
+ const thumbnailVariant = useStore((state) => thumbnailVariantForZoom(state.transform[2], width));
860
913
  const isLive = liveBoardIds.has(id);
861
914
  const isSelected = selectedBoardIds.has(id);
862
915
  const isDimmed = matchingBoardIds !== null && !matchingBoardIds.has(id);
863
916
  const openThreads = openThreadCounts.get(id) ?? 0;
864
917
  const isReady = useDeferredMount();
865
- const isThumbnailMissing = !board.thumbnailUrl;
918
+ const isThumbnailMissing = !isResponsive && !board.thumbnailUrl;
866
919
  const latestThumbnailUrl = designContentUrl(
867
920
  apiBaseUrl,
868
921
  thumbnailVariant === "small" ? board.thumbnailSmallUrl ?? board.thumbnailUrl : board.thumbnailUrl
@@ -977,12 +1030,24 @@ var BoardNodeComponent = ({ id, data }) => {
977
1030
  "div",
978
1031
  {
979
1032
  className: cx(
980
- "relative overflow-hidden rounded-[20px] bg-card shadow-surface-raised ring-1 ring-foreground/10",
981
- isSelected && "ring-4 ring-brand"
1033
+ "relative",
1034
+ isResponsive ? cx("rounded-[20px]", isSelected && "ring-4 ring-brand ring-offset-8 ring-offset-transparent") : cx("overflow-hidden rounded-[20px] bg-card shadow-surface-raised ring-1 ring-foreground/10", isSelected && "ring-4 ring-brand")
982
1035
  ),
983
1036
  style: { width, height: visibleHeight },
984
1037
  children: [
985
- thumbnailUrl && // biome-ignore lint/performance/noImgElement: canvas thumbnails are API images at canvas scale, next/image cannot optimise them
1038
+ isResponsive && /* @__PURE__ */ jsx2(
1039
+ ResponsiveBoardFrames,
1040
+ {
1041
+ board,
1042
+ frameHeightMode,
1043
+ devices,
1044
+ thumbnailVariant,
1045
+ showsLiveHtml: showsLiveHtml && isReady,
1046
+ htmlUrl,
1047
+ title
1048
+ }
1049
+ ),
1050
+ !isResponsive && thumbnailUrl && // biome-ignore lint/performance/noImgElement: canvas thumbnails are API images at canvas scale, next/image cannot optimise them
986
1051
  /* @__PURE__ */ jsx2(
987
1052
  "img",
988
1053
  {
@@ -1003,7 +1068,7 @@ var BoardNodeComponent = ({ id, data }) => {
1003
1068
  thumbnailRetry.imageKey
1004
1069
  ),
1005
1070
  isThumbnailMissing && !isCompact && !(showsLiveHtml && liveHtmlUrl) && /* @__PURE__ */ jsx2("span", { className: "pointer-events-none absolute inset-0 flex items-center justify-center px-6 text-center text-[17px] font-semibold text-muted-foreground", children: texts.thumbnailMissing }),
1006
- showsLiveHtml && liveHtmlUrl && /* @__PURE__ */ jsx2(
1071
+ !isResponsive && showsLiveHtml && liveHtmlUrl && /* @__PURE__ */ jsx2(
1007
1072
  "iframe",
1008
1073
  {
1009
1074
  src: liveHtmlUrl,
@@ -1048,6 +1113,116 @@ var BoardNodeComponent = ({ id, data }) => {
1048
1113
  ] });
1049
1114
  };
1050
1115
  var BoardNode = memo(BoardNodeComponent);
1116
+ var ResponsiveBoardFrames = ({
1117
+ board,
1118
+ frameHeightMode,
1119
+ devices,
1120
+ thumbnailVariant,
1121
+ showsLiveHtml,
1122
+ htmlUrl,
1123
+ title
1124
+ }) => {
1125
+ let left = 0;
1126
+ return /* @__PURE__ */ jsx2(Fragment2, { children: framesOf(board).map((frame) => {
1127
+ const frameLeft = left;
1128
+ left += (frame.width ?? 0) + FRAME_GAP;
1129
+ return /* @__PURE__ */ jsx2(
1130
+ ResponsiveBoardFrame,
1131
+ {
1132
+ frame,
1133
+ left: frameLeft,
1134
+ frameHeightMode,
1135
+ deviceLabel: devices.find((device) => device.deviceKey === frame.deviceKey)?.label ?? frame.deviceKey ?? "",
1136
+ thumbnailVariant,
1137
+ showsLiveHtml,
1138
+ htmlUrl,
1139
+ title
1140
+ },
1141
+ frame.deviceKey ?? frameLeft
1142
+ );
1143
+ }) });
1144
+ };
1145
+ var ResponsiveBoardFrame = ({
1146
+ frame,
1147
+ left,
1148
+ frameHeightMode,
1149
+ deviceLabel,
1150
+ thumbnailVariant,
1151
+ showsLiveHtml,
1152
+ htmlUrl,
1153
+ title
1154
+ }) => {
1155
+ const { apiBaseUrl } = useDesignStudio();
1156
+ const texts = useDesignStudioTexts();
1157
+ const frameWidth = frame.width ?? 0;
1158
+ const frameHeight = frameCanvasHeight(frame, frameHeightMode);
1159
+ const latestThumbnailUrl = designContentUrl(
1160
+ apiBaseUrl,
1161
+ thumbnailVariant === "small" ? frame.thumbnailSmallUrl ?? frame.thumbnailUrl : frame.thumbnailUrl
1162
+ );
1163
+ const [loadedImageUrl, setLoadedImageUrl] = useState5(null);
1164
+ const thumbnailUrl = useStableContentUrl(latestThumbnailUrl, isSameContent(loadedImageUrl, latestThumbnailUrl));
1165
+ const thumbnailRetry = useImageRetry(thumbnailUrl);
1166
+ const liveHtmlUrl = useCheckedContentUrl(showsLiveHtml ? htmlUrl : void 0);
1167
+ const isCut = frameHeightMode === "page" && (frame.pageHeight ?? 0) > frameHeight;
1168
+ return /* @__PURE__ */ jsxs2("div", { className: "absolute top-0", style: { left, width: frameWidth }, children: [
1169
+ /* @__PURE__ */ jsx2(
1170
+ "div",
1171
+ {
1172
+ className: "flex items-end truncate pb-2 text-[17px] font-semibold text-muted-foreground tabular-nums",
1173
+ style: { height: FRAME_LABEL_HEIGHT },
1174
+ title: `${deviceLabel} \xB7 ${frameWidth} \xD7 ${frame.height ?? 0}`,
1175
+ children: thumbnailVariant === "small" ? "" : `${deviceLabel} \xB7 ${frameWidth}`
1176
+ }
1177
+ ),
1178
+ /* @__PURE__ */ jsxs2(
1179
+ "div",
1180
+ {
1181
+ className: "relative overflow-hidden rounded-[20px] bg-card shadow-surface-raised ring-1 ring-foreground/10",
1182
+ style: { width: frameWidth, height: frameHeight },
1183
+ children: [
1184
+ thumbnailUrl && // biome-ignore lint/performance/noImgElement: canvas thumbnails are API images at canvas scale
1185
+ /* @__PURE__ */ jsx2(
1186
+ "img",
1187
+ {
1188
+ src: thumbnailUrl,
1189
+ alt: "",
1190
+ loading: "lazy",
1191
+ decoding: "async",
1192
+ draggable: false,
1193
+ onError: thumbnailRetry.onError,
1194
+ onLoad: () => setLoadedImageUrl(thumbnailUrl),
1195
+ className: cx(
1196
+ "pointer-events-none absolute inset-x-0 top-0 w-full select-none",
1197
+ thumbnailRetry.isFailed && "invisible"
1198
+ )
1199
+ },
1200
+ thumbnailRetry.imageKey
1201
+ ),
1202
+ !frame.thumbnailUrl && !(showsLiveHtml && liveHtmlUrl) && thumbnailVariant !== "small" && /* @__PURE__ */ jsx2("span", { className: "pointer-events-none absolute inset-0 flex items-center justify-center px-6 text-center text-[17px] font-semibold text-muted-foreground", children: texts.thumbnailMissing }),
1203
+ showsLiveHtml && liveHtmlUrl && /* @__PURE__ */ jsx2(
1204
+ "iframe",
1205
+ {
1206
+ src: liveHtmlUrl,
1207
+ title: `${title} \xB7 ${deviceLabel}`,
1208
+ sandbox: "",
1209
+ referrerPolicy: "no-referrer",
1210
+ loading: "lazy",
1211
+ width: frameWidth,
1212
+ height: frameHeight,
1213
+ className: "pointer-events-none absolute inset-0 border-0 bg-transparent"
1214
+ }
1215
+ ),
1216
+ isCut && /* @__PURE__ */ jsxs2("span", { className: "pointer-events-none absolute inset-x-0 bottom-0 flex h-40 items-end justify-center bg-gradient-to-t from-card to-transparent pb-4 text-[16px] font-semibold text-muted-foreground", children: [
1217
+ "\u2193 ",
1218
+ Math.round(frame.pageHeight ?? 0),
1219
+ " px \u2014 full length in the focus view"
1220
+ ] })
1221
+ ]
1222
+ }
1223
+ )
1224
+ ] });
1225
+ };
1051
1226
 
1052
1227
  // src/canvas/BoardStatusChips.tsx
1053
1228
  import { normalizeDddError as normalizeDddError2 } from "@mgamadeus/ddd-web/api";
@@ -1103,7 +1278,7 @@ var BoardStatusChips = ({
1103
1278
  };
1104
1279
 
1105
1280
  // src/canvas/BoardFocusView.tsx
1106
- import { Fragment as Fragment2, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
1281
+ import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
1107
1282
  var DEVICE_SCREEN_HEIGHT = 844;
1108
1283
  var BoardFocusView = ({
1109
1284
  projectKey,
@@ -1115,6 +1290,9 @@ var BoardFocusView = ({
1115
1290
  threads,
1116
1291
  writesAllowed,
1117
1292
  presentLabel,
1293
+ devices = [],
1294
+ viewport = null,
1295
+ onViewportChange,
1118
1296
  onClose,
1119
1297
  onPrevious,
1120
1298
  onNext,
@@ -1167,11 +1345,33 @@ var BoardFocusView = ({
1167
1345
  window.addEventListener("keydown", onKeyDown);
1168
1346
  return () => window.removeEventListener("keydown", onKeyDown);
1169
1347
  });
1170
- const width = board?.width ?? 390;
1171
- const height = board?.height ?? 844;
1348
+ const isResponsive = isResponsiveBoard(board) && viewport !== null;
1349
+ const [showsDeviceFrame, setShowsDeviceFrame] = useState6(true);
1350
+ const stageRef = useRef2(null);
1351
+ const [stageWidth, setStageWidth] = useState6(0);
1352
+ useEffect4(() => {
1353
+ const stage = stageRef.current;
1354
+ if (!stage || typeof ResizeObserver === "undefined") return;
1355
+ const observer = new ResizeObserver(() => setStageWidth(stage.clientWidth));
1356
+ observer.observe(stage);
1357
+ setStageWidth(stage.clientWidth);
1358
+ return () => observer.disconnect();
1359
+ }, [board]);
1360
+ const width = isResponsive ? viewport.width : board?.width ?? 390;
1361
+ const height = isResponsive && board ? pageHeightAtWidth(board, viewport.width, viewport.height) : board?.height ?? 844;
1362
+ const screenHeight = isResponsive ? viewport.height : Math.min(height, DEVICE_SCREEN_HEIGHT);
1363
+ const bezelPadding = !isResponsive || showsDeviceFrame ? 24 : 0;
1364
+ const scale = isResponsive && stageWidth > 0 ? Math.min(1, (stageWidth - 48) / (width + bezelPadding)) : 1;
1365
+ const frameOfWidth = isResponsive ? framesOf(board).find((frame) => frame.width === width) : void 0;
1172
1366
  const htmlUrl = useCheckedContentUrl(useStableContentUrl(designContentUrl(apiBaseUrl, board?.htmlUrl), true));
1173
- const thumbnailUrl = useStableContentUrl(designContentUrl(apiBaseUrl, board?.thumbnailUrl), true);
1174
- const pinnedThreads = threads.filter((thread) => thread.pinNumber !== null && (showResolved || !thread.root.isResolved));
1367
+ const thumbnailUrl = useStableContentUrl(
1368
+ designContentUrl(apiBaseUrl, isResponsive ? frameOfWidth?.thumbnailUrl : board?.thumbnailUrl),
1369
+ true
1370
+ );
1371
+ const pinnedThreads = threads.filter(
1372
+ (thread) => thread.pinNumber !== null && (showResolved || !thread.root.isResolved) && isPinInViewport(thread.root, isResponsive ? viewport : null)
1373
+ );
1374
+ const hiddenPinCount = threads.filter((thread) => thread.pinNumber !== null && !thread.root.isResolved).length - pinnedThreads.filter((thread) => !thread.root.isResolved).length;
1175
1375
  const copyReference = () => {
1176
1376
  onCopyReference({ region, note: referenceNote });
1177
1377
  if (region) {
@@ -1182,8 +1382,8 @@ var BoardFocusView = ({
1182
1382
  const boardPointOf = (event) => {
1183
1383
  const rect = event.currentTarget.getBoundingClientRect();
1184
1384
  return {
1185
- x: Math.max(0, Math.min(width, event.clientX - rect.left)),
1186
- y: Math.max(0, Math.min(height, event.clientY - rect.top))
1385
+ x: Math.max(0, Math.min(width, (event.clientX - rect.left) / scale)),
1386
+ y: Math.max(0, Math.min(height, (event.clientY - rect.top) / scale))
1187
1387
  };
1188
1388
  };
1189
1389
  const startRegion = (event) => {
@@ -1218,7 +1418,11 @@ var BoardFocusView = ({
1218
1418
  } : region;
1219
1419
  const placePin = (event) => {
1220
1420
  const rect = event.currentTarget.getBoundingClientRect();
1221
- setPendingPin({ x: Math.round(event.clientX - rect.left), y: Math.round(event.clientY - rect.top) });
1421
+ setPendingPin({
1422
+ x: Math.round((event.clientX - rect.left) / scale),
1423
+ y: Math.round((event.clientY - rect.top) / scale),
1424
+ viewport: isResponsive ? viewport : null
1425
+ });
1222
1426
  setIsPlacingPin(false);
1223
1427
  };
1224
1428
  return /* @__PURE__ */ jsx4(Dialog, { open: board !== null, onOpenChange: (open) => !open && onClose(), children: /* @__PURE__ */ jsx4(
@@ -1226,7 +1430,7 @@ var BoardFocusView = ({
1226
1430
  {
1227
1431
  showCloseButton: false,
1228
1432
  className: "flex h-[calc(100dvh-2rem)] w-[calc(100vw-2rem)] max-w-none flex-col gap-0 overflow-hidden rounded-3xl p-0 sm:max-w-none",
1229
- children: board && /* @__PURE__ */ jsxs4(Fragment2, { children: [
1433
+ children: board && /* @__PURE__ */ jsxs4(Fragment3, { children: [
1230
1434
  /* @__PURE__ */ jsxs4("header", { className: "flex flex-wrap items-center gap-3 border-b border-border px-5 py-3", children: [
1231
1435
  /* @__PURE__ */ jsxs4("div", { className: "min-w-0 flex-1", children: [
1232
1436
  /* @__PURE__ */ jsx4(DialogTitle, { className: "truncate text-lg font-semibold", children: board.title }),
@@ -1260,101 +1464,138 @@ var BoardFocusView = ({
1260
1464
  ] })
1261
1465
  ] }),
1262
1466
  /* @__PURE__ */ jsxs4("div", { className: "flex min-h-0 flex-1 flex-col lg:flex-row", children: [
1263
- /* @__PURE__ */ jsx4("div", { className: "flex min-h-0 flex-1 items-start justify-center overflow-auto bg-tint p-6", children: /* @__PURE__ */ jsx4("div", { className: "rounded-[56px] bg-foreground p-3 shadow-surface-raised", children: /* @__PURE__ */ jsx4(
1264
- "div",
1265
- {
1266
- className: "relative overflow-y-auto overflow-x-hidden rounded-[44px] bg-card",
1267
- style: { width, height: Math.min(height, DEVICE_SCREEN_HEIGHT) },
1268
- children: /* @__PURE__ */ jsxs4("div", { className: "relative", style: { width, height }, children: [
1269
- thumbnailUrl && // biome-ignore lint/performance/noImgElement: API thumbnail under the live board while it loads
1270
- /* @__PURE__ */ jsx4(
1271
- "img",
1272
- {
1273
- src: thumbnailUrl,
1274
- alt: "",
1275
- width,
1276
- height,
1277
- className: "pointer-events-none absolute inset-0 select-none"
1278
- }
1279
- ),
1280
- htmlUrl && /* @__PURE__ */ jsx4(
1281
- "iframe",
1282
- {
1283
- src: htmlUrl,
1284
- title: board.title ?? board.boardKey ?? "Board",
1285
- sandbox: "",
1286
- referrerPolicy: "no-referrer",
1287
- width,
1288
- height,
1289
- className: "absolute inset-0 border-0 bg-transparent"
1290
- },
1291
- htmlUrl
1292
- ),
1293
- isPlacingPin && /* @__PURE__ */ jsx4(
1294
- "button",
1295
- {
1296
- type: "button",
1297
- "aria-label": "Place the pin here",
1298
- className: "absolute inset-0 z-10 cursor-crosshair bg-brand/10",
1299
- onClick: placePin
1300
- }
1301
- ),
1302
- isMarkingRegion && /* @__PURE__ */ jsx4(
1303
- "button",
1304
- {
1305
- type: "button",
1306
- "aria-label": "Drag a rectangle to mark a region of the board",
1307
- className: "absolute inset-0 z-10 cursor-crosshair touch-none bg-brand/5",
1308
- onPointerDown: startRegion,
1309
- onPointerMove: moveRegion,
1310
- onPointerUp: endRegion
1311
- }
1467
+ /* @__PURE__ */ jsxs4("div", { className: "flex min-h-0 flex-1 flex-col bg-tint", children: [
1468
+ isResponsive && /* @__PURE__ */ jsx4(
1469
+ ViewportToolbar,
1470
+ {
1471
+ devices,
1472
+ viewport,
1473
+ hiddenPinCount,
1474
+ showsDeviceFrame,
1475
+ onShowsDeviceFrameChange: setShowsDeviceFrame,
1476
+ onViewportChange: (nextViewport) => onViewportChange?.(nextViewport)
1477
+ }
1478
+ ),
1479
+ /* @__PURE__ */ jsx4("div", { ref: stageRef, className: "flex min-h-0 flex-1 items-start justify-center overflow-auto p-6", children: /* @__PURE__ */ jsx4("div", { style: { width: (width + bezelPadding) * scale, height: (screenHeight + bezelPadding) * scale }, children: /* @__PURE__ */ jsxs4(
1480
+ "div",
1481
+ {
1482
+ className: cx(
1483
+ "relative origin-top-left",
1484
+ (!isResponsive || showsDeviceFrame) && "bg-foreground p-3 shadow-surface-raised",
1485
+ !isResponsive || viewport.width < 600 ? "rounded-[56px]" : "rounded-[28px]"
1312
1486
  ),
1313
- shownRegion && /* @__PURE__ */ jsx4(
1314
- "span",
1315
- {
1316
- "aria-hidden": true,
1317
- className: cx(
1318
- "pointer-events-none absolute z-20 rounded-md border-2 border-dashed border-brand bg-brand/10 transition-shadow motion-reduce:transition-none",
1319
- isRegionFlashing && "shadow-[0_0_0_6px_var(--brand)]"
1320
- ),
1321
- style: {
1322
- left: shownRegion.x,
1323
- top: shownRegion.y,
1324
- width: shownRegion.width,
1325
- height: shownRegion.height
1487
+ style: { transform: scale !== 1 ? `scale(${scale})` : void 0, width: width + bezelPadding },
1488
+ children: [
1489
+ /* @__PURE__ */ jsx4(
1490
+ "div",
1491
+ {
1492
+ className: cx(
1493
+ "relative overflow-y-auto overflow-x-hidden bg-card",
1494
+ !isResponsive || showsDeviceFrame ? !isResponsive || viewport.width < 600 ? "rounded-[44px]" : "rounded-[18px]" : "rounded-md ring-1 ring-foreground/10"
1495
+ ),
1496
+ style: { width, height: screenHeight },
1497
+ children: /* @__PURE__ */ jsxs4("div", { className: "relative", style: { width, height }, children: [
1498
+ thumbnailUrl && // biome-ignore lint/performance/noImgElement: API thumbnail under the live board while it loads
1499
+ /* @__PURE__ */ jsx4(
1500
+ "img",
1501
+ {
1502
+ src: thumbnailUrl,
1503
+ alt: "",
1504
+ width,
1505
+ height,
1506
+ className: "pointer-events-none absolute inset-0 select-none"
1507
+ }
1508
+ ),
1509
+ htmlUrl && /* @__PURE__ */ jsx4(
1510
+ "iframe",
1511
+ {
1512
+ src: htmlUrl,
1513
+ title: board.title ?? board.boardKey ?? "Board",
1514
+ sandbox: "",
1515
+ referrerPolicy: "no-referrer",
1516
+ width,
1517
+ height,
1518
+ className: "absolute inset-0 border-0 bg-transparent"
1519
+ },
1520
+ htmlUrl
1521
+ ),
1522
+ isPlacingPin && /* @__PURE__ */ jsx4(
1523
+ "button",
1524
+ {
1525
+ type: "button",
1526
+ "aria-label": "Place the pin here",
1527
+ className: "absolute inset-0 z-10 cursor-crosshair bg-brand/10",
1528
+ onClick: placePin
1529
+ }
1530
+ ),
1531
+ isMarkingRegion && /* @__PURE__ */ jsx4(
1532
+ "button",
1533
+ {
1534
+ type: "button",
1535
+ "aria-label": "Drag a rectangle to mark a region of the board",
1536
+ className: "absolute inset-0 z-10 cursor-crosshair touch-none bg-brand/5",
1537
+ onPointerDown: startRegion,
1538
+ onPointerMove: moveRegion,
1539
+ onPointerUp: endRegion
1540
+ }
1541
+ ),
1542
+ shownRegion && /* @__PURE__ */ jsx4(
1543
+ "span",
1544
+ {
1545
+ "aria-hidden": true,
1546
+ className: cx(
1547
+ "pointer-events-none absolute z-20 rounded-md border-2 border-dashed border-brand bg-brand/10 transition-shadow motion-reduce:transition-none",
1548
+ isRegionFlashing && "shadow-[0_0_0_6px_var(--brand)]"
1549
+ ),
1550
+ style: {
1551
+ left: shownRegion.x,
1552
+ top: shownRegion.y,
1553
+ width: shownRegion.width,
1554
+ height: shownRegion.height
1555
+ }
1556
+ }
1557
+ ),
1558
+ pinnedThreads.map((thread) => /* @__PURE__ */ jsx4(
1559
+ "button",
1560
+ {
1561
+ type: "button",
1562
+ "aria-label": `Comment ${thread.pinNumber}`,
1563
+ onMouseEnter: () => setHighlightedCommentId(Number(thread.root.id)),
1564
+ onClick: () => setHighlightedCommentId(Number(thread.root.id)),
1565
+ className: cx(
1566
+ "absolute z-20 flex size-7 -translate-x-1/2 -translate-y-full items-center justify-center rounded-full rounded-bl-none text-xs font-bold shadow-surface-raised ring-2 ring-card",
1567
+ thread.root.isResolved ? "bg-muted text-muted-foreground" : "bg-primary text-primary-foreground",
1568
+ highlightedCommentId === Number(thread.root.id) && "ring-brand scale-110"
1569
+ ),
1570
+ style: { left: thread.root.x ?? 0, top: thread.root.y ?? 0 },
1571
+ children: thread.pinNumber
1572
+ },
1573
+ String(thread.root.id)
1574
+ )),
1575
+ pendingPin && /* @__PURE__ */ jsx4(
1576
+ "span",
1577
+ {
1578
+ className: "absolute z-20 flex size-7 -translate-x-1/2 -translate-y-full items-center justify-center rounded-full rounded-bl-none bg-brand text-card shadow-surface-raised ring-2 ring-card",
1579
+ style: { left: pendingPin.x, top: pendingPin.y },
1580
+ "aria-hidden": true,
1581
+ children: /* @__PURE__ */ jsx4(MapPin2, { className: "size-4" })
1582
+ }
1583
+ )
1584
+ ] })
1326
1585
  }
1327
- }
1328
- ),
1329
- pinnedThreads.map((thread) => /* @__PURE__ */ jsx4(
1330
- "button",
1331
- {
1332
- type: "button",
1333
- "aria-label": `Comment ${thread.pinNumber}`,
1334
- onMouseEnter: () => setHighlightedCommentId(Number(thread.root.id)),
1335
- onClick: () => setHighlightedCommentId(Number(thread.root.id)),
1336
- className: cx(
1337
- "absolute z-20 flex size-7 -translate-x-1/2 -translate-y-full items-center justify-center rounded-full rounded-bl-none text-xs font-bold shadow-surface-raised ring-2 ring-card",
1338
- thread.root.isResolved ? "bg-muted text-muted-foreground" : "bg-primary text-primary-foreground",
1339
- highlightedCommentId === Number(thread.root.id) && "ring-brand scale-110"
1340
- ),
1341
- style: { left: thread.root.x ?? 0, top: thread.root.y ?? 0 },
1342
- children: thread.pinNumber
1343
- },
1344
- String(thread.root.id)
1345
- )),
1346
- pendingPin && /* @__PURE__ */ jsx4(
1347
- "span",
1348
- {
1349
- className: "absolute z-20 flex size-7 -translate-x-1/2 -translate-y-full items-center justify-center rounded-full rounded-bl-none bg-brand text-card shadow-surface-raised ring-2 ring-card",
1350
- style: { left: pendingPin.x, top: pendingPin.y },
1351
- "aria-hidden": true,
1352
- children: /* @__PURE__ */ jsx4(MapPin2, { className: "size-4" })
1353
- }
1354
- )
1355
- ] })
1356
- }
1357
- ) }) }),
1586
+ ),
1587
+ isResponsive && /* @__PURE__ */ jsx4(
1588
+ WidthDragHandle,
1589
+ {
1590
+ scale,
1591
+ width,
1592
+ onWidthChange: (nextWidth) => onViewportChange?.(viewportWithWidth(viewport, nextWidth))
1593
+ }
1594
+ )
1595
+ ]
1596
+ }
1597
+ ) }) })
1598
+ ] }),
1358
1599
  /* @__PURE__ */ jsxs4("aside", { className: "flex min-h-0 w-full flex-col border-t border-border lg:w-[400px] lg:border-t-0 lg:border-l", children: [
1359
1600
  /* @__PURE__ */ jsxs4("div", { className: "space-y-2 border-b border-border px-5 py-4", children: [
1360
1601
  /* @__PURE__ */ jsx4("p", { className: "text-sm font-semibold", children: "Reference for an agent" }),
@@ -1438,7 +1679,8 @@ var BoardFocusView = ({
1438
1679
  showResolved,
1439
1680
  onShowResolvedChange: setShowResolved,
1440
1681
  pinHint: "\u201CAdd pin\u201D marks a spot on the board",
1441
- onCopyThreadReference
1682
+ onCopyThreadReference,
1683
+ onSelectViewport: isResponsive ? onViewportChange : void 0
1442
1684
  }
1443
1685
  ) })
1444
1686
  ] })
@@ -1447,6 +1689,101 @@ var BoardFocusView = ({
1447
1689
  }
1448
1690
  ) });
1449
1691
  };
1692
+ var ViewportToolbar = ({
1693
+ devices,
1694
+ viewport,
1695
+ hiddenPinCount,
1696
+ showsDeviceFrame,
1697
+ onShowsDeviceFrameChange,
1698
+ onViewportChange
1699
+ }) => {
1700
+ const { components } = useDesignStudio();
1701
+ const { Button } = components;
1702
+ return /* @__PURE__ */ jsxs4("div", { className: "flex flex-wrap items-center gap-2 border-b border-border px-5 py-2 text-sm", children: [
1703
+ /* @__PURE__ */ jsxs4("label", { className: "flex items-center gap-2", children: [
1704
+ /* @__PURE__ */ jsx4("span", { className: "sr-only", children: "Device" }),
1705
+ /* @__PURE__ */ jsxs4(
1706
+ "select",
1707
+ {
1708
+ className: "h-8 rounded-lg border border-border bg-card px-2 text-sm",
1709
+ value: viewport.deviceKey ?? "",
1710
+ onChange: (event) => {
1711
+ const device = devices.find((candidate) => candidate.deviceKey === event.target.value);
1712
+ if (device) onViewportChange(viewportOfDevice(device));
1713
+ },
1714
+ children: [
1715
+ viewport.deviceKey === null && /* @__PURE__ */ jsx4("option", { value: "", children: "Free width" }),
1716
+ devices.map((device) => /* @__PURE__ */ jsxs4("option", { value: device.deviceKey ?? "", children: [
1717
+ device.label,
1718
+ " \xB7 ",
1719
+ device.width,
1720
+ " \xD7 ",
1721
+ device.height
1722
+ ] }, device.deviceKey ?? ""))
1723
+ ]
1724
+ }
1725
+ )
1726
+ ] }),
1727
+ /* @__PURE__ */ jsxs4(
1728
+ Button,
1729
+ {
1730
+ variant: "outline",
1731
+ size: "sm",
1732
+ "aria-label": "Rotate (landscape / portrait)",
1733
+ onClick: () => onViewportChange(rotateViewport(viewport, devices)),
1734
+ children: [
1735
+ /* @__PURE__ */ jsx4(RotateCw, {}),
1736
+ " Rotate"
1737
+ ]
1738
+ }
1739
+ ),
1740
+ /* @__PURE__ */ jsx4("span", { className: "text-muted-foreground tabular-nums", children: viewportLabel(viewport, devices) }),
1741
+ /* @__PURE__ */ jsxs4(
1742
+ Button,
1743
+ {
1744
+ variant: showsDeviceFrame ? "default" : "outline",
1745
+ size: "sm",
1746
+ "aria-pressed": showsDeviceFrame,
1747
+ onClick: () => onShowsDeviceFrameChange(!showsDeviceFrame),
1748
+ children: [
1749
+ /* @__PURE__ */ jsx4(Smartphone, {}),
1750
+ " Device frame"
1751
+ ]
1752
+ }
1753
+ ),
1754
+ hiddenPinCount > 0 && /* @__PURE__ */ jsxs4("span", { className: "ml-auto text-xs text-muted-foreground", children: [
1755
+ hiddenPinCount,
1756
+ " open pin(s) in other widths \u2014 pick their size in the comment list"
1757
+ ] })
1758
+ ] });
1759
+ };
1760
+ var WidthDragHandle = ({ scale, width, onWidthChange }) => {
1761
+ const dragStartRef = useRef2(null);
1762
+ return /* @__PURE__ */ jsx4(
1763
+ "button",
1764
+ {
1765
+ type: "button",
1766
+ "aria-label": `Viewport width ${width} px: drag to change`,
1767
+ className: "absolute top-1/2 -right-6 z-30 h-24 w-3 -translate-y-1/2 cursor-ew-resize touch-none rounded-full bg-foreground/40 hover:bg-foreground/70",
1768
+ onPointerDown: (event) => {
1769
+ event.currentTarget.setPointerCapture(event.pointerId);
1770
+ dragStartRef.current = { clientX: event.clientX, width };
1771
+ },
1772
+ onPointerMove: (event) => {
1773
+ const dragStart = dragStartRef.current;
1774
+ if (!dragStart) return;
1775
+ onWidthChange(dragStart.width + (event.clientX - dragStart.clientX) / Math.max(0.05, scale));
1776
+ },
1777
+ onPointerUp: () => {
1778
+ dragStartRef.current = null;
1779
+ },
1780
+ onKeyDown: (event) => {
1781
+ if (event.key === "ArrowLeft") onWidthChange(width - 10);
1782
+ if (event.key === "ArrowRight") onWidthChange(width + 10);
1783
+ }
1784
+ }
1785
+ );
1786
+ };
1450
1787
 
1451
1788
  // src/canvas/DesignCanvasFlow.tsx
1452
1789
  import "@xyflow/react/dist/style.css";
@@ -1461,7 +1798,7 @@ import {
1461
1798
  useStore as useStore3
1462
1799
  } from "@xyflow/react";
1463
1800
  import { ChevronDown, Hand, MousePointer2, Play } from "lucide-react";
1464
- import { useCallback, useEffect as useEffect5, useMemo, useRef as useRef2, useState as useState7 } from "react";
1801
+ import { useCallback, useEffect as useEffect5, useMemo, useRef as useRef3, useState as useState7 } from "react";
1465
1802
 
1466
1803
  // src/canvas/SectionNode.tsx
1467
1804
  import { useStore as useStore2 } from "@xyflow/react";
@@ -1752,11 +2089,11 @@ var FlowCanvas = ({
1752
2089
  }) => {
1753
2090
  const { apiBaseUrl, components, statusColors } = useDesignStudio();
1754
2091
  const { Tooltip, TooltipContent, TooltipTrigger } = components;
1755
- const containerRef = useRef2(null);
2092
+ const containerRef = useRef3(null);
1756
2093
  const reactFlow = useReactFlow();
1757
2094
  useWheelZoom(containerRef);
1758
2095
  const isOverview = useStore3((state) => state.transform[2] < OVERVIEW_ZOOM);
1759
- const previousNodesRef = useRef2([]);
2096
+ const previousNodesRef = useRef3([]);
1760
2097
  const nodes = useMemo(() => {
1761
2098
  const reused = reuseUnchangedNodes(
1762
2099
  previousNodesRef.current,
@@ -1773,7 +2110,7 @@ var FlowCanvas = ({
1773
2110
  () => [...layout.boards].map(([id, rect]) => ({ id, ...rect })),
1774
2111
  [layout]
1775
2112
  );
1776
- const liveBoardsTimerRef = useRef2(null);
2113
+ const liveBoardsTimerRef = useRef3(null);
1777
2114
  const cancelLiveBoardsUpdate = useCallback(() => {
1778
2115
  if (liveBoardsTimerRef.current) clearTimeout(liveBoardsTimerRef.current);
1779
2116
  liveBoardsTimerRef.current = null;
@@ -1789,7 +2126,7 @@ var FlowCanvas = ({
1789
2126
  },
1790
2127
  [boardRects, onLiveBoardIdsChange, onVisibleBoardIdsChange, liveMinRatio]
1791
2128
  );
1792
- const hasInitialFitRef = useRef2(false);
2129
+ const hasInitialFitRef = useRef3(false);
1793
2130
  const fitRect = useCallback(
1794
2131
  (rect, duration, fitWidthOnly = false) => {
1795
2132
  const container = containerRef.current;
@@ -1831,15 +2168,15 @@ var FlowCanvas = ({
1831
2168
  const fitAll = useCallback(() => {
1832
2169
  fitRect(layout.bounds, 400);
1833
2170
  }, [fitRect, layout]);
1834
- const handledFitKeyRef = useRef2(null);
2171
+ const handledFitKeyRef = useRef3(null);
1835
2172
  useEffect5(() => {
1836
2173
  if (!fitRequest || handledFitKeyRef.current === fitRequest.key) return;
1837
2174
  handledFitKeyRef.current = fitRequest.key;
1838
2175
  fitNodes(fitRequest.nodeIds);
1839
2176
  }, [fitRequest, fitNodes]);
1840
- const committedViewportRef = useRef2(null);
1841
- const isFlowReadyRef = useRef2(false);
1842
- const initialViewportRef = useRef2(initialViewport);
2177
+ const committedViewportRef = useRef3(null);
2178
+ const isFlowReadyRef = useRef3(false);
2179
+ const initialViewportRef = useRef3(initialViewport);
1843
2180
  const fitInitialView = useCallback(() => {
1844
2181
  if (!isFlowReadyRef.current || hasInitialFitRef.current || layout.sections.length === 0) return;
1845
2182
  const container = containerRef.current;
@@ -1857,7 +2194,7 @@ var FlowCanvas = ({
1857
2194
  committedViewportRef.current = formatViewportParam(viewport);
1858
2195
  }
1859
2196
  }, [layout, initialFitNodeIds, fitNodes, fitRect, reactFlow, updateLiveBoards]);
1860
- const viewportCommitTimerRef = useRef2(null);
2197
+ const viewportCommitTimerRef = useRef3(null);
1861
2198
  useEffect5(
1862
2199
  () => () => {
1863
2200
  if (viewportCommitTimerRef.current) clearTimeout(viewportCommitTimerRef.current);
@@ -1929,7 +2266,7 @@ var FlowCanvas = ({
1929
2266
  if (presentationStart) onPresentSection(presentationStart.sectionId, presentationStart.boardId);
1930
2267
  };
1931
2268
  const [marquee, setMarquee] = useState7(null);
1932
- const isMarqueeJustEndedRef = useRef2(false);
2269
+ const isMarqueeJustEndedRef = useRef3(false);
1933
2270
  const startMarquee = (event) => {
1934
2271
  const target = event.target;
1935
2272
  if (tool !== "select" || event.button !== 0 || !target.classList.contains("react-flow__pane")) return;
@@ -2096,7 +2433,7 @@ var FlowCanvas = ({
2096
2433
  var DesignCanvasFlow = (props) => /* @__PURE__ */ jsx6(ReactFlowProvider, { children: /* @__PURE__ */ jsx6(FlowCanvas, { ...props }) });
2097
2434
 
2098
2435
  // src/canvas/DesignStudioCanvasScreen.tsx
2099
- import { Fragment as Fragment3, jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
2436
+ import { Fragment as Fragment4, jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
2100
2437
  var CANVAS_STATE_KEYS = ["q", "section", "status", "theme", "mode", "vp"];
2101
2438
  var UNCOUNTED_CANVAS_STATE_KEYS = ["q", "theme", "mode", "vp"];
2102
2439
  var LIVE_UPDATE_POLL_MS = 15e3;
@@ -2122,8 +2459,8 @@ var NO_SIDEBAR = [true, () => void 0];
2122
2459
  var useNoSidebar = () => NO_SIDEBAR;
2123
2460
  var useCollapsedSidebarWhileMounted = (useSidebarCollapsed = useNoSidebar) => {
2124
2461
  const [isCollapsed, toggleCollapsed] = useSidebarCollapsed();
2125
- const collapsedByCanvasRef = useRef3(false);
2126
- const toggleRef = useRef3(toggleCollapsed);
2462
+ const collapsedByCanvasRef = useRef4(false);
2463
+ const toggleRef = useRef4(toggleCollapsed);
2127
2464
  toggleRef.current = toggleCollapsed;
2128
2465
  useEffect6(() => {
2129
2466
  if (!isCollapsed) {
@@ -2248,6 +2585,8 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
2248
2585
  const [selectedBoardId, setSelectedBoardId] = useState8(null);
2249
2586
  const [selectedBoardIds, setSelectedBoardIds] = useState8(/* @__PURE__ */ new Set());
2250
2587
  const [focusedBoardId, setFocusedBoardId] = useState8(null);
2588
+ const [frameHeightMode, setFrameHeightMode] = useState8("viewport");
2589
+ const [chosenFocusViewport, setChosenFocusViewport] = useState8(null);
2251
2590
  const [presentSectionId, setPresentSectionId] = useState8(null);
2252
2591
  const [fitRequest, setFitRequest] = useState8(null);
2253
2592
  const [tool, setTool] = useState8("hand");
@@ -2269,7 +2608,7 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
2269
2608
  const setSectionFilter = useCallback2((value) => setCanvasStateValue("section", value), [setCanvasStateValue]);
2270
2609
  const setStatusFilter = useCallback2((value) => setCanvasStateValue("status", value), [setCanvasStateValue]);
2271
2610
  const [isFullscreen, setIsFullscreen] = useState8(false);
2272
- const canvasAreaRef = useRef3(null);
2611
+ const canvasAreaRef = useRef4(null);
2273
2612
  const [canvasAspectRatio, setCanvasAspectRatio] = useState8(null);
2274
2613
  useCollapsedSidebarWhileMounted(shell?.useSidebarCollapsed);
2275
2614
  const debouncedSearch = canvasState.debounced.q;
@@ -2280,7 +2619,7 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
2280
2619
  const [hasInitialFilterWithViewport] = useState8(
2281
2620
  () => initialViewport !== null && Boolean(canvasState.values.q.trim() || canvasState.values.section || canvasState.values.status)
2282
2621
  );
2283
- const currentViewportRef = useRef3(initialViewport ? formatViewportParam(initialViewport) : null);
2622
+ const currentViewportRef = useRef4(initialViewport ? formatViewportParam(initialViewport) : null);
2284
2623
  const commitViewport = useCallback2(
2285
2624
  (viewport) => {
2286
2625
  const value = formatViewportParam(viewport);
@@ -2402,13 +2741,14 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
2402
2741
  shownBoardList.map((board) => ({
2403
2742
  id: boardNodeId(board.boardKey ?? ""),
2404
2743
  sectionId: board.sectionKey && sectionKeys.has(board.sectionKey) ? board.sectionKey : null,
2405
- width: board.width ?? 390,
2406
- height: board.height ?? 844,
2744
+ ...boardCanvasSize(board, frameHeightMode),
2407
2745
  displayOrder: board.displayOrder ?? 0
2408
2746
  })),
2409
2747
  canvasAspectRatio ?? void 0
2410
2748
  );
2411
- }, [sections, shownBoardList, canvasAspectRatio]);
2749
+ }, [sections, shownBoardList, canvasAspectRatio, frameHeightMode]);
2750
+ const devices = useMemo2(() => canvas?.devices?.elements ?? [], [canvas?.devices]);
2751
+ const hasResponsiveBoards = useMemo2(() => shownBoardList.some((board) => isResponsiveBoard(board)), [shownBoardList]);
2412
2752
  const hasCanvas = Boolean(canvas);
2413
2753
  useEffect6(() => {
2414
2754
  const canvasArea = canvasAreaRef.current;
@@ -2431,13 +2771,13 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
2431
2771
  const isRenderOpen = renderStatus !== null && OPEN_RENDER_STATUSES.has(renderStatus);
2432
2772
  useEffect6(() => setIsRenderPolling(isRenderOpen), [isRenderOpen]);
2433
2773
  const [requestThumbnailRendering] = api.useRequestThumbnailRenderingMutation();
2434
- const visibleBoardIdsRef = useRef3([]);
2774
+ const visibleBoardIdsRef = useRef4([]);
2435
2775
  const rememberVisibleBoardIds = useCallback2((visibleBoardIds) => {
2436
2776
  visibleBoardIdsRef.current = visibleBoardIds;
2437
2777
  }, []);
2438
- const boardsByNodeIdRef = useRef3(boardsByNodeId);
2778
+ const boardsByNodeIdRef = useRef4(boardsByNodeId);
2439
2779
  boardsByNodeIdRef.current = boardsByNodeId;
2440
- const requestedThumbnailsRef = useRef3(/* @__PURE__ */ new Set());
2780
+ const requestedThumbnailsRef = useRef4(/* @__PURE__ */ new Set());
2441
2781
  const fileRenderRequest = useCallback2(
2442
2782
  (isRetry) => {
2443
2783
  if (!writesAllowed || !currentCanvas) return;
@@ -2519,14 +2859,14 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
2519
2859
  }
2520
2860
  return layoutOrder.filter((nodeId) => matchingBoardIds === null || matchingBoardIds.has(nodeId));
2521
2861
  }, [layout, layoutOrder, matchingBoardIds, presentSectionId]);
2522
- const fitKeyRef = useRef3(0);
2862
+ const fitKeyRef = useRef4(0);
2523
2863
  const requestFit = useCallback2((nodeIds) => {
2524
2864
  fitKeyRef.current += 1;
2525
2865
  setFitRequest({ nodeIds, key: fitKeyRef.current });
2526
2866
  }, []);
2527
2867
  const filterKey = matchingBoardIds === null ? null : `${debouncedSearch.trim()}|${sectionFilter}|${statusFilter}`;
2528
- const fittedFilterKeyRef = useRef3(null);
2529
- const skipInitialFilterFitRef = useRef3(hasInitialFilterWithViewport);
2868
+ const fittedFilterKeyRef = useRef4(null);
2869
+ const skipInitialFilterFitRef = useRef4(hasInitialFilterWithViewport);
2530
2870
  useEffect6(() => {
2531
2871
  if (filterKey === null || matchingBoardIds === null) {
2532
2872
  fittedFilterKeyRef.current = null;
@@ -2561,6 +2901,7 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
2561
2901
  const closeFocus = useCallback2(() => {
2562
2902
  setFocusedBoardId(null);
2563
2903
  setPresentSectionId(null);
2904
+ setChosenFocusViewport(null);
2564
2905
  writeSearchParams({ [BOARD_PARAM]: null });
2565
2906
  }, [writeSearchParams]);
2566
2907
  const presentSection = useCallback2(
@@ -2574,7 +2915,7 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
2574
2915
  [layout, openBoard]
2575
2916
  );
2576
2917
  const boardParam = searchParams.get(BOARD_PARAM);
2577
- const isDeepLinkHandledRef = useRef3(false);
2918
+ const isDeepLinkHandledRef = useRef4(false);
2578
2919
  useEffect6(() => {
2579
2920
  if (isDeepLinkHandledRef.current || !boardParam || boards.length === 0) return;
2580
2921
  isDeepLinkHandledRef.current = true;
@@ -2585,7 +2926,7 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
2585
2926
  if (!initialViewport) requestFit([nodeId]);
2586
2927
  }, [boardParam, boards.length, boardsByNodeId, requestFit, initialViewport]);
2587
2928
  const codeParam = searchParams.get(CODE_PARAM);
2588
- const handledCodeRef = useRef3(null);
2929
+ const handledCodeRef = useRef4(null);
2589
2930
  useEffect6(() => {
2590
2931
  if (!codeParam) {
2591
2932
  if (handledCodeRef.current !== null) handledCodeRef.current = "";
@@ -2611,7 +2952,7 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
2611
2952
  setIsCommentsPanelOpen(true);
2612
2953
  }
2613
2954
  }, [codeParam, codeAtLoad, boards, isCommentsPanelOpen, writeSearchParams, notify, texts, requestFit]);
2614
- const pendingCodeFitRef = useRef3(null);
2955
+ const pendingCodeFitRef = useRef4(null);
2615
2956
  useEffect6(() => {
2616
2957
  const nodeId = pendingCodeFitRef.current;
2617
2958
  if (!nodeId || layout.sections.length === 0) return;
@@ -2698,6 +3039,7 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
2698
3039
  const copyThreadReference = useCallback2(
2699
3040
  (thread) => void copyReferences([
2700
3041
  buildReferenceFor(boardNodeId(thread.root.boardKey ?? ""), {
3042
+ viewport: viewportOfComment(thread.root),
2701
3043
  comment: {
2702
3044
  id: thread.root.id ?? "",
2703
3045
  x: thread.root.x ?? null,
@@ -2720,7 +3062,7 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
2720
3062
  },
2721
3063
  [shownLook, notify, texts]
2722
3064
  );
2723
- const seenRevisionRef = useRef3(null);
3065
+ const seenRevisionRef = useRef4(null);
2724
3066
  const revision = currentRevisionData?.revision;
2725
3067
  const revisionLook = themeArgument ?? "";
2726
3068
  useEffect6(() => {
@@ -2742,7 +3084,7 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
2742
3084
  },
2743
3085
  [requestFit]
2744
3086
  );
2745
- const layoutOrderRef = useRef3(layoutOrder);
3087
+ const layoutOrderRef = useRef4(layoutOrder);
2746
3088
  layoutOrderRef.current = layoutOrder;
2747
3089
  useEffect6(() => {
2748
3090
  const changedBoardKeys = shownBoards.changedBoardKeys;
@@ -2754,7 +3096,7 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
2754
3096
  action: { label: texts.showUpdatedBoard, onClick: () => showBoard(firstNodeId) }
2755
3097
  });
2756
3098
  }, [shownBoards.serial]);
2757
- const shownBoardsRef = useRef3(shownBoards);
3099
+ const shownBoardsRef = useRef4(shownBoards);
2758
3100
  shownBoardsRef.current = shownBoards;
2759
3101
  const reloadCanvas = useCallback2(async () => {
2760
3102
  if (shownBoardsRef.current.source === void 0) return;
@@ -2767,7 +3109,7 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
2767
3109
  notify.info(texts.canvasUpToDate, { id: LIVE_UPDATE_TOAST_ID });
2768
3110
  }
2769
3111
  }, [refetchCanvas, refetchComments, refetchRevision, notify, texts]);
2770
- const reloadCanvasRef = useRef3(reloadCanvas);
3112
+ const reloadCanvasRef = useRef4(reloadCanvas);
2771
3113
  reloadCanvasRef.current = reloadCanvas;
2772
3114
  const canvasView = useMemo2(
2773
3115
  () => ({
@@ -2777,6 +3119,8 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
2777
3119
  matchingBoardIds,
2778
3120
  openThreadCounts,
2779
3121
  defaultStatus,
3122
+ frameHeightMode,
3123
+ devices,
2780
3124
  isHandTool: tool === "hand",
2781
3125
  onSelectBoard: selectBoard,
2782
3126
  onCopyReference: (nodeId) => void copyReferences([buildReferenceFor(nodeId)]),
@@ -2790,6 +3134,8 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
2790
3134
  matchingBoardIds,
2791
3135
  openThreadCounts,
2792
3136
  defaultStatus,
3137
+ frameHeightMode,
3138
+ devices,
2793
3139
  tool,
2794
3140
  selectBoard,
2795
3141
  copyReferences,
@@ -2800,6 +3146,7 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
2800
3146
  );
2801
3147
  const selectedBoard = selectedBoardId ? boardsByNodeId.get(selectedBoardId) ?? null : null;
2802
3148
  const focusedBoard = focusedBoardId ? boardsByNodeId.get(focusedBoardId) ?? null : null;
3149
+ const focusViewport = initialViewportForBoard(focusedBoard, chosenFocusViewport);
2803
3150
  const threadsOf = (nodeId) => nodeId ? buildCommentThreads(commentsByBoardNodeId.get(nodeId) ?? []) : [];
2804
3151
  const boardsWithOpenThreads = layoutOrder.filter((nodeId) => openThreadCounts.has(nodeId));
2805
3152
  const codeAtLoadBoard = useMemo2(
@@ -2812,7 +3159,7 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
2812
3159
  }, [layout, codeAtLoadBoard]);
2813
3160
  const sectionOptions = layout.sections.map((section) => ({ value: section.id, label: section.title }));
2814
3161
  const presentedSectionTitle = presentSectionId ? layout.sections.find((section) => section.id === presentSectionId)?.title ?? null : null;
2815
- const copySelectedRef = useRef3(copySelectedReferences);
3162
+ const copySelectedRef = useRef4(copySelectedReferences);
2816
3163
  copySelectedRef.current = copySelectedReferences;
2817
3164
  useEffect6(() => {
2818
3165
  const onKeyDown = (event) => {
@@ -2902,7 +3249,21 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
2902
3249
  ] })
2903
3250
  ] })
2904
3251
  ] });
2905
- const toolbarEnd = /* @__PURE__ */ jsxs7(Fragment3, { children: [
3252
+ const toolbarEnd = /* @__PURE__ */ jsxs7(Fragment4, { children: [
3253
+ hasResponsiveBoards && /* @__PURE__ */ jsxs7(Tooltip, { children: [
3254
+ /* @__PURE__ */ jsx7(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx7(
3255
+ "button",
3256
+ {
3257
+ type: "button",
3258
+ className: TOOL_BUTTON_CLASS2,
3259
+ "aria-pressed": frameHeightMode === "page",
3260
+ "aria-label": frameHeightMode === "page" ? "Device frames: whole page" : "Device frames: one screen",
3261
+ onClick: () => setFrameHeightMode((mode) => mode === "page" ? "viewport" : "page"),
3262
+ children: frameHeightMode === "page" ? /* @__PURE__ */ jsx7(FoldVertical, { className: "size-4" }) : /* @__PURE__ */ jsx7(UnfoldVertical, { className: "size-4" })
3263
+ }
3264
+ ) }),
3265
+ /* @__PURE__ */ jsx7(TooltipContent, { side: "bottom", children: frameHeightMode === "page" ? "Responsive boards: whole page \u2014 show one screen per device" : "Responsive boards: one screen \u2014 show the whole page per device" })
3266
+ ] }),
2906
3267
  /* @__PURE__ */ jsxs7(Tooltip, { children: [
2907
3268
  /* @__PURE__ */ jsx7(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx7(
2908
3269
  "button",
@@ -3129,7 +3490,10 @@ var DesignStudioCanvasScreen = ({ projectKey, canvasKey }) => {
3129
3490
  onPrevious: () => stepFocus(-1),
3130
3491
  onNext: () => stepFocus(1),
3131
3492
  onStatusChanged: (status) => focusedBoardId && setBoardStatus(focusedBoardId, status),
3132
- onCopyReference: ({ region, note }) => focusedBoardId && void copyReferences([buildReferenceFor(focusedBoardId, { region, note })]),
3493
+ devices,
3494
+ viewport: focusViewport,
3495
+ onViewportChange: setChosenFocusViewport,
3496
+ onCopyReference: ({ region, note }) => focusedBoardId && void copyReferences([buildReferenceFor(focusedBoardId, { region, note, viewport: focusViewport })]),
3133
3497
  onCopyThreadReference: copyThreadReference
3134
3498
  }
3135
3499
  )