docblocks-react-ui 0.4.7 → 0.6.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,4 +1,4 @@
1
- import { a as ChevronLeft, c as isSafeDownloadHref, d as cn, i as ChevronRight, n as X, r as TriangleAlert, t as isEmbeddablePdfUrl } from "../constants-BaAj3jDA.mjs";
1
+ import { c as TriangleAlert, d as ChevronRight, f as ChevronLeft, i as isSafeDownloadHref, l as Plus, p as cn, r as clamp, s as X, t as isEmbeddablePdfUrl, u as Minus } from "../constants-2VXoyPmd.mjs";
2
2
  import { t as LoaderCircle } from "../LoaderCircle-AGVFE4IP.mjs";
3
3
  import { useCallback, useEffect, useRef, useState } from "react";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -49,6 +49,52 @@ function Minimize(props) {
49
49
  });
50
50
  }
51
51
  //#endregion
52
+ //#region src/shared/ui/icons/StretchHorizontal.tsx
53
+ function StretchHorizontal(props) {
54
+ return /* @__PURE__ */ jsxs("svg", {
55
+ xmlns: "http://www.w3.org/2000/svg",
56
+ width: 24,
57
+ height: 24,
58
+ viewBox: "0 0 24 24",
59
+ fill: "none",
60
+ stroke: "currentColor",
61
+ strokeWidth: 2,
62
+ strokeLinecap: "round",
63
+ strokeLinejoin: "round",
64
+ ...props,
65
+ children: [
66
+ /* @__PURE__ */ jsx("path", { d: "M5 4v16" }),
67
+ /* @__PURE__ */ jsx("path", { d: "M19 4v16" }),
68
+ /* @__PURE__ */ jsx("path", { d: "M9 12h6" }),
69
+ /* @__PURE__ */ jsx("path", { d: "m12 9-3 3 3 3" }),
70
+ /* @__PURE__ */ jsx("path", { d: "m12 9 3 3-3 3" })
71
+ ]
72
+ });
73
+ }
74
+ //#endregion
75
+ //#region src/shared/ui/icons/StretchVertical.tsx
76
+ function StretchVertical(props) {
77
+ return /* @__PURE__ */ jsxs("svg", {
78
+ xmlns: "http://www.w3.org/2000/svg",
79
+ width: 24,
80
+ height: 24,
81
+ viewBox: "0 0 24 24",
82
+ fill: "none",
83
+ stroke: "currentColor",
84
+ strokeWidth: 2,
85
+ strokeLinecap: "round",
86
+ strokeLinejoin: "round",
87
+ ...props,
88
+ children: [
89
+ /* @__PURE__ */ jsx("path", { d: "M4 5h16" }),
90
+ /* @__PURE__ */ jsx("path", { d: "M4 19h16" }),
91
+ /* @__PURE__ */ jsx("path", { d: "M12 9v6" }),
92
+ /* @__PURE__ */ jsx("path", { d: "m9 12 3-3 3 3" }),
93
+ /* @__PURE__ */ jsx("path", { d: "m9 12 3 3 3-3" })
94
+ ]
95
+ });
96
+ }
97
+ //#endregion
52
98
  //#region src/pdf/pdf-worker.ts
53
99
  /** The pdfjs-dist worker wiring (the side-effect): the worker file is
54
100
  * copied next to this entry at build time (dist/pdf/), so the relative
@@ -73,17 +119,33 @@ if (typeof window !== "undefined") fetch(WORKER_URL, { method: "HEAD" }).catch((
73
119
  });
74
120
  //#endregion
75
121
  //#region src/pdf/PdfFirstPage.tsx
76
- /** The PDF preview of one `pdf`-subtype image block: fetch the resolved
122
+ /** The PDF preview of one file block: fetch the resolved
77
123
  * blob, render the pages to a canvas via pdfjs-dist. The inline view stands
78
124
  * the first page over the page row; the controls (the previous/next page
79
125
  * buttons + the page indicator + the fullscreen toggle) stand a bar under
80
126
  * the canvas. The fullscreen mode opens a portal overlay over the viewport
81
- * (the page scaled to fill the viewport, the same page navigation, the
82
- * Escape key / the close button / the outside click exit). A failure stands
127
+ * (the page scaled to fill the viewport, the same page navigation, the zoom
128
+ * bar — the zoom in/out buttons over the scale + the fit-width / the
129
+ * fit-height — a separate
130
+ * pill to the left of the page controls, the Escape key / the arrow keys /
131
+ * the close button / the outside click exit). The overlay's open locks the
132
+ * body's scroll (a wheel over the fixed portal chains to the document's
133
+ * scroll container — the page behind must not scroll). The page indicator's
134
+ * and the scale's numbers stand a fixed width (the digit count's change
135
+ * must not shift the buttons). The preview's chrome stands no text
136
+ * selection (`select-none`): the page indicator's and the controls' text
137
+ * is not document content, and a selection stood there would flag the
138
+ * block / pull the format toolbar over a non-text range. A failure stands
83
139
  * the error note over the native iframe fallback (the document stays
84
- * viewable). The in-flight fetch is aborted on unmount / url change and the
85
- * render task + document are released, so a torn-down preview leaves no
86
- * network request or pdf.js worker behind. */
140
+ * viewable). The in-flight fetch is aborted on unmount / url change and
141
+ * the render task + document are released, so a torn-down preview leaves
142
+ * no network request or pdf.js worker behind. */
143
+ /** The fullscreen zoom's bounds + the per-click step: the scale's units
144
+ * are the css px per pdf point (the device pixel ratio stands the backing
145
+ * store's scale, not this factor). */
146
+ const ZOOM_MIN = .25;
147
+ const ZOOM_MAX = 4;
148
+ const ZOOM_STEP = 1.25;
87
149
  /** Render one page to a canvas (the natural page size, the backing store
88
150
  * scaled by the device pixel ratio for a crisp retina display). Returns the
89
151
  * render task (the caller awaits its promise + cancels it on teardown).
@@ -103,26 +165,7 @@ function renderPageToCanvas(pdf, pageNumber, canvas) {
103
165
  });
104
166
  });
105
167
  }
106
- /** Render one page to a canvas, scaled to fill the container (the
107
- * object-fit: contain behavior — the page's aspect ratio is preserved, the
108
- * page fills the container's width or height). Returns the render task. */
109
- function renderPageToCanvasScaled(pdf, pageNumber, canvas, containerWidth, containerHeight) {
110
- return pdf.getPage(pageNumber).then((page) => {
111
- const pageViewport = page.getViewport({ scale: 1 });
112
- const scale = Math.min(containerWidth / pageViewport.width, containerHeight / pageViewport.height);
113
- const ratio = window.devicePixelRatio || 1;
114
- const viewport = page.getViewport({ scale: scale * ratio });
115
- canvas.width = Math.max(1, Math.floor(viewport.width));
116
- canvas.height = Math.max(1, Math.floor(viewport.height));
117
- canvas.style.width = `${Math.max(1, Math.floor(viewport.width / ratio))}px`;
118
- canvas.style.height = `${Math.max(1, Math.floor(viewport.height / ratio))}px`;
119
- return page.render({
120
- canvas,
121
- viewport
122
- });
123
- });
124
- }
125
- function PdfFirstPage({ id, url, name }) {
168
+ function PdfFirstPage({ id, blockType, url, name }) {
126
169
  const { t } = useTranslation("blocks");
127
170
  const canvasRef = useRef(null);
128
171
  const fullscreenCanvasRef = useRef(null);
@@ -134,6 +177,8 @@ function PdfFirstPage({ id, url, name }) {
134
177
  const [currentPage, setCurrentPage] = useState(1);
135
178
  const [totalPages, setTotalPages] = useState(0);
136
179
  const [isFullscreen, setIsFullscreen] = useState(false);
180
+ const [fullscreenZoom, setFullscreenZoom] = useState(null);
181
+ const [fullscreenScale, setFullscreenScale] = useState(1);
137
182
  useEffect(() => {
138
183
  const controller = new AbortController();
139
184
  let cancelled = false;
@@ -211,53 +256,143 @@ function PdfFirstPage({ id, url, name }) {
211
256
  const container = fullscreenContainerRef.current;
212
257
  if (pdf === null || canvas === null || container === null) return;
213
258
  let cancelled = false;
259
+ let renderToken = 0;
214
260
  let renderTask = null;
215
- const render = () => {
261
+ let renderedOnce = false;
262
+ const render = async () => {
263
+ const token = ++renderToken;
216
264
  const width = container.clientWidth;
217
265
  const height = container.clientHeight;
218
266
  if (width === 0 || height === 0) return;
219
- (async () => {
220
- try {
221
- renderTask = await renderPageToCanvasScaled(pdf, currentPage, canvas, width, height);
222
- await renderTask.promise;
223
- } catch (cause) {
224
- if (cancelled || cause instanceof RenderingCancelledException || cause instanceof DOMException && cause.name === "AbortError") return;
225
- }
226
- })();
267
+ const page = await pdf.getPage(currentPage);
268
+ if (cancelled || token !== renderToken) return;
269
+ const pageViewport = page.getViewport({ scale: 1 });
270
+ const fit = Math.min(width / pageViewport.width, height / pageViewport.height);
271
+ const scale = fullscreenZoom ?? fit;
272
+ setFullscreenScale(scale);
273
+ const ratio = window.devicePixelRatio || 1;
274
+ const viewport = page.getViewport({ scale: scale * ratio });
275
+ const storeWidth = Math.max(1, Math.floor(viewport.width));
276
+ const storeHeight = Math.max(1, Math.floor(viewport.height));
277
+ if (renderedOnce && canvas.width === storeWidth && canvas.height === storeHeight) return;
278
+ renderedOnce = true;
279
+ if (renderTask !== null) {
280
+ renderTask.cancel();
281
+ renderTask = null;
282
+ }
283
+ canvas.width = storeWidth;
284
+ canvas.height = storeHeight;
285
+ canvas.style.width = `${Math.max(1, Math.floor(viewport.width / ratio))}px`;
286
+ canvas.style.height = `${Math.max(1, Math.floor(viewport.height / ratio))}px`;
287
+ try {
288
+ renderTask = page.render({
289
+ canvas,
290
+ viewport
291
+ });
292
+ await renderTask.promise;
293
+ } catch (cause) {
294
+ if (cancelled || cause instanceof RenderingCancelledException || cause instanceof DOMException && cause.name === "AbortError") return;
295
+ }
227
296
  };
228
297
  render();
229
- const observer = new ResizeObserver(() => render());
298
+ const observer = new ResizeObserver(() => {
299
+ render();
300
+ });
230
301
  observer.observe(container);
231
302
  return () => {
232
303
  cancelled = true;
304
+ renderToken += 1;
233
305
  observer.disconnect();
234
306
  if (renderTask !== null) renderTask.cancel();
235
307
  };
236
308
  }, [
237
309
  isFullscreen,
238
310
  currentPage,
239
- phase
311
+ phase,
312
+ fullscreenZoom
240
313
  ]);
314
+ const prevPage = useCallback(() => {
315
+ setCurrentPage((page) => Math.max(1, page - 1));
316
+ }, []);
317
+ const nextPage = useCallback(() => {
318
+ setCurrentPage((page) => Math.min(totalPages, page + 1));
319
+ }, [totalPages]);
320
+ const zoomBy = useCallback((factor) => {
321
+ const pdf = pdfDocRef.current;
322
+ const container = fullscreenContainerRef.current;
323
+ if (pdf === null || container === null) return;
324
+ const width = container.clientWidth;
325
+ const height = container.clientHeight;
326
+ if (width === 0 || height === 0) return;
327
+ pdf.getPage(currentPage).then((page) => {
328
+ const pageViewport = page.getViewport({ scale: 1 });
329
+ const fit = Math.min(width / pageViewport.width, height / pageViewport.height);
330
+ setFullscreenZoom(clamp((fullscreenZoom ?? fit) * factor, ZOOM_MIN, ZOOM_MAX));
331
+ });
332
+ }, [currentPage, fullscreenZoom]);
333
+ const fitWidth = useCallback(() => {
334
+ const pdf = pdfDocRef.current;
335
+ const container = fullscreenContainerRef.current;
336
+ if (pdf === null || container === null) return;
337
+ const width = container.clientWidth;
338
+ if (width === 0) return;
339
+ pdf.getPage(currentPage).then((page) => {
340
+ const pageViewport = page.getViewport({ scale: 1 });
341
+ setFullscreenZoom(clamp(width / pageViewport.width, ZOOM_MIN, ZOOM_MAX));
342
+ });
343
+ }, [currentPage]);
344
+ const fitHeight = useCallback(() => {
345
+ const pdf = pdfDocRef.current;
346
+ const container = fullscreenContainerRef.current;
347
+ if (pdf === null || container === null) return;
348
+ const height = container.clientHeight;
349
+ if (height === 0) return;
350
+ pdf.getPage(currentPage).then((page) => {
351
+ const pageViewport = page.getViewport({ scale: 1 });
352
+ setFullscreenZoom(clamp(height / pageViewport.height, ZOOM_MIN, ZOOM_MAX));
353
+ });
354
+ }, [currentPage]);
355
+ const openFullscreen = useCallback(() => {
356
+ setFullscreenZoom(null);
357
+ setFullscreenScale(1);
358
+ setIsFullscreen(true);
359
+ }, []);
241
360
  useEffect(() => {
242
361
  if (!isFullscreen) return;
243
362
  const onKeyDown = (event) => {
244
- if (event.key === "Escape") setIsFullscreen(false);
363
+ if (event.key === "Escape") {
364
+ setIsFullscreen(false);
365
+ return;
366
+ }
367
+ if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
368
+ const target = event.target instanceof HTMLElement ? event.target : null;
369
+ if (target !== null && /^(INPUT|TEXTAREA|SELECT)$/.test(target.tagName)) return;
370
+ event.preventDefault();
371
+ if (event.key === "ArrowLeft") prevPage();
372
+ else nextPage();
245
373
  };
246
374
  window.addEventListener("keydown", onKeyDown);
247
375
  return () => window.removeEventListener("keydown", onKeyDown);
376
+ }, [
377
+ isFullscreen,
378
+ prevPage,
379
+ nextPage
380
+ ]);
381
+ useEffect(() => {
382
+ if (!isFullscreen) return;
383
+ const body = document.body;
384
+ const previous = body.style.overflow;
385
+ body.style.overflow = "hidden";
386
+ return () => {
387
+ body.style.overflow = previous;
388
+ };
248
389
  }, [isFullscreen]);
249
- const prevPage = useCallback(() => {
250
- setCurrentPage((page) => Math.max(1, page - 1));
251
- }, []);
252
- const nextPage = useCallback(() => {
253
- setCurrentPage((page) => Math.min(totalPages, page + 1));
254
- }, [totalPages]);
255
390
  if (phase === "error") return /* @__PURE__ */ jsxs("div", {
256
391
  "data-slot": "docblocks/image-pdf-preview",
257
392
  "data-block-id": id,
258
- "data-block-type": "image",
393
+ "data-block-type": blockType,
259
394
  "data-phase": "error",
260
- className: "mx-0 my-(--docblocks-block-spacing)",
395
+ className: "mx-0 my-(--docblocks-block-spacing) select-none",
261
396
  children: [/* @__PURE__ */ jsxs("div", {
262
397
  "data-slot": "docblocks/image-pdf-error",
263
398
  className: "\n mb-2 flex items-center gap-2 rounded-(--docblocks-radius) border-(length:--docblocks-table-border-width)\n border-(--docblocks-table-border-color) bg-(--muted) px-3 py-2 text-sm text-(--muted-foreground)\n ",
@@ -270,18 +405,18 @@ function PdfFirstPage({ id, url, name }) {
270
405
  "data-subtype": "pdf",
271
406
  sandbox: "",
272
407
  src: url,
273
- title: name ?? "document",
408
+ title: name,
274
409
  className: "\n block aspect-video w-full rounded-(--docblocks-image-radius)\n border-(length:--docblocks-table-border-width) border-(--docblocks-table-border-color) outline-none\n "
275
410
  }) : isSafeDownloadHref(url) ? /* @__PURE__ */ jsx("a", {
276
411
  "data-slot": "docblocks/image-pdf-download",
277
412
  href: url,
278
- download: name ?? void 0,
413
+ download: name,
279
414
  className: "inline-block text-sm underline underline-offset-2",
280
- children: name ?? "document"
415
+ children: name
281
416
  }) : /* @__PURE__ */ jsx("span", {
282
417
  "data-slot": "docblocks/image-pdf-download",
283
418
  className: "inline-block text-sm",
284
- children: name ?? "document"
419
+ children: name
285
420
  })]
286
421
  });
287
422
  const inlineControls = /* @__PURE__ */ jsxs("div", {
@@ -301,7 +436,11 @@ function PdfFirstPage({ id, url, name }) {
301
436
  "data-slot": "docblocks/image-pdf-page-indicator",
302
437
  className: "px-1 text-xs text-(--muted-foreground) tabular-nums",
303
438
  children: [
304
- currentPage,
439
+ /* @__PURE__ */ jsx("span", {
440
+ className: "inline-block text-right",
441
+ style: { minWidth: `${Math.max(1, String(totalPages).length)}ch` },
442
+ children: currentPage
443
+ }),
305
444
  " / ",
306
445
  totalPages
307
446
  ]
@@ -318,7 +457,7 @@ function PdfFirstPage({ id, url, name }) {
318
457
  /* @__PURE__ */ jsx("button", {
319
458
  type: "button",
320
459
  "data-slot": "docblocks/image-pdf-fullscreen",
321
- onClick: () => setIsFullscreen(true),
460
+ onClick: openFullscreen,
322
461
  "aria-label": t("code.pdfFullscreen"),
323
462
  className: "\n ml-1 flex size-6 items-center justify-center rounded-sm text-(--muted-foreground) transition-colors\n hover:bg-(--accent) hover:text-(--accent-foreground)\n ",
324
463
  children: /* @__PURE__ */ jsx(Maximize, { className: "size-4" })
@@ -327,7 +466,7 @@ function PdfFirstPage({ id, url, name }) {
327
466
  });
328
467
  const fullscreenControls = /* @__PURE__ */ jsxs("div", {
329
468
  "data-slot": "docblocks/image-pdf-controls",
330
- className: "\n flex items-center justify-center gap-1 rounded-(--radius) border border-(--border) bg-(--muted) px-2 py-1\n ",
469
+ className: "\n flex items-center justify-center gap-1 rounded-(--radius) border border-(--border) bg-(--muted) px-2 py-1\n select-none\n ",
331
470
  children: [
332
471
  /* @__PURE__ */ jsx("button", {
333
472
  type: "button",
@@ -342,7 +481,11 @@ function PdfFirstPage({ id, url, name }) {
342
481
  "data-slot": "docblocks/image-pdf-page-indicator",
343
482
  className: "px-1 text-xs text-(--muted-foreground) tabular-nums",
344
483
  children: [
345
- currentPage,
484
+ /* @__PURE__ */ jsx("span", {
485
+ className: "inline-block text-right",
486
+ style: { minWidth: `${Math.max(1, String(totalPages).length)}ch` },
487
+ children: currentPage
488
+ }),
346
489
  " / ",
347
490
  totalPages
348
491
  ]
@@ -366,12 +509,57 @@ function PdfFirstPage({ id, url, name }) {
366
509
  })
367
510
  ]
368
511
  });
512
+ const fullscreenZoomControls = /* @__PURE__ */ jsxs("div", {
513
+ "data-slot": "docblocks/image-pdf-zoom",
514
+ className: "\n flex items-center justify-center gap-1 rounded-(--radius) border border-(--border) bg-(--muted) px-2 py-1\n select-none\n ",
515
+ children: [
516
+ /* @__PURE__ */ jsx("button", {
517
+ type: "button",
518
+ "data-slot": "docblocks/image-pdf-zoom-out",
519
+ onClick: () => zoomBy(1 / ZOOM_STEP),
520
+ disabled: fullscreenScale <= .250000001,
521
+ "aria-label": t("code.pdfZoomOut"),
522
+ className: "\n flex size-6 items-center justify-center rounded-sm text-(--muted-foreground) transition-colors\n hover:bg-(--accent) hover:text-(--accent-foreground)\n disabled:pointer-events-none disabled:opacity-40\n ",
523
+ children: /* @__PURE__ */ jsx(Minus, { className: "size-4" })
524
+ }),
525
+ /* @__PURE__ */ jsxs("span", {
526
+ "data-slot": "docblocks/image-pdf-zoom-indicator",
527
+ className: "inline-block min-w-[4ch] px-1 text-right text-xs text-(--muted-foreground) tabular-nums",
528
+ children: [Math.round(fullscreenScale * 100), "%"]
529
+ }),
530
+ /* @__PURE__ */ jsx("button", {
531
+ type: "button",
532
+ "data-slot": "docblocks/image-pdf-zoom-in",
533
+ onClick: () => zoomBy(ZOOM_STEP),
534
+ disabled: fullscreenScale >= 3.999999999,
535
+ "aria-label": t("code.pdfZoomIn"),
536
+ className: "\n flex size-6 items-center justify-center rounded-sm text-(--muted-foreground) transition-colors\n hover:bg-(--accent) hover:text-(--accent-foreground)\n disabled:pointer-events-none disabled:opacity-40\n ",
537
+ children: /* @__PURE__ */ jsx(Plus, { className: "size-4" })
538
+ }),
539
+ /* @__PURE__ */ jsx("button", {
540
+ type: "button",
541
+ "data-slot": "docblocks/image-pdf-fit-width",
542
+ onClick: fitWidth,
543
+ "aria-label": t("code.pdfFitWidth"),
544
+ className: "\n flex size-6 items-center justify-center rounded-sm text-(--muted-foreground) transition-colors\n hover:bg-(--accent) hover:text-(--accent-foreground)\n ",
545
+ children: /* @__PURE__ */ jsx(StretchHorizontal, { className: "size-4" })
546
+ }),
547
+ /* @__PURE__ */ jsx("button", {
548
+ type: "button",
549
+ "data-slot": "docblocks/image-pdf-fit-height",
550
+ onClick: fitHeight,
551
+ "aria-label": t("code.pdfFitHeight"),
552
+ className: "\n flex size-6 items-center justify-center rounded-sm text-(--muted-foreground) transition-colors\n hover:bg-(--accent) hover:text-(--accent-foreground)\n ",
553
+ children: /* @__PURE__ */ jsx(StretchVertical, { className: "size-4" })
554
+ })
555
+ ]
556
+ });
369
557
  return /* @__PURE__ */ jsxs("div", {
370
558
  "data-slot": "docblocks/image-pdf-preview",
371
559
  "data-block-id": id,
372
- "data-block-type": "image",
560
+ "data-block-type": blockType,
373
561
  "data-phase": phase,
374
- className: "relative mx-0 my-(--docblocks-block-spacing) flex flex-col items-center gap-2",
562
+ className: "relative mx-0 my-(--docblocks-block-spacing) flex flex-col items-center gap-2 select-none",
375
563
  children: [
376
564
  /* @__PURE__ */ jsxs("div", {
377
565
  className: "relative flex w-full justify-center",
@@ -402,6 +590,7 @@ function PdfFirstPage({ id, url, name }) {
402
590
  if (target === null) return;
403
591
  if (target.closest("[data-slot=\"docblocks/image-pdf-fullscreen-canvas\"]") !== null) return;
404
592
  if (target.closest("[data-slot=\"docblocks/image-pdf-controls\"]") !== null) return;
593
+ if (target.closest("[data-slot=\"docblocks/image-pdf-zoom\"]") !== null) return;
405
594
  setIsFullscreen(false);
406
595
  },
407
596
  children: [
@@ -415,14 +604,18 @@ function PdfFirstPage({ id, url, name }) {
415
604
  }),
416
605
  /* @__PURE__ */ jsx("div", {
417
606
  ref: fullscreenContainerRef,
418
- className: "flex h-[calc(100vh-6rem)] w-[calc(100vw-4rem)] items-center justify-center overflow-hidden",
607
+ "data-slot": "docblocks/image-pdf-fullscreen-container",
608
+ className: "flex h-[calc(100vh-6rem)] w-[calc(100vw-4rem)] overflow-auto",
419
609
  children: /* @__PURE__ */ jsx("canvas", {
420
610
  ref: fullscreenCanvasRef,
421
611
  "data-slot": "docblocks/image-pdf-fullscreen-canvas",
422
- className: "max-h-full max-w-full border border-(--border) bg-(--background) shadow-lg"
612
+ className: "m-auto border border-(--border) bg-(--background) shadow-lg"
423
613
  })
424
614
  }),
425
- fullscreenControls
615
+ /* @__PURE__ */ jsxs("div", {
616
+ className: "flex items-center gap-2",
617
+ children: [fullscreenZoomControls, fullscreenControls]
618
+ })
426
619
  ]
427
620
  }), document.body)
428
621
  ]
package/dist/styles.css CHANGED
@@ -56,6 +56,7 @@
56
56
  --color-gray-700: oklch(37.3% 0.034 259.733);
57
57
  --color-white: #fff;
58
58
  --spacing: 0.25rem;
59
+ --container-xl: 36rem;
59
60
  --text-xs: 0.75rem;
60
61
  --text-xs--line-height: calc(1 / 0.75);
61
62
  --text-sm: 0.875rem;
@@ -297,6 +298,9 @@
297
298
  .top-4 {
298
299
  top: calc(var(--spacing) * 4);
299
300
  }
301
+ .top-6 {
302
+ top: calc(var(--spacing) * 6);
303
+ }
300
304
  .top-8 {
301
305
  top: calc(var(--spacing) * 8);
302
306
  }
@@ -333,12 +337,18 @@
333
337
  .right-4 {
334
338
  right: calc(var(--spacing) * 4);
335
339
  }
340
+ .-bottom-2 {
341
+ bottom: calc(var(--spacing) * -2);
342
+ }
336
343
  .bottom-0 {
337
344
  bottom: 0px;
338
345
  }
339
346
  .bottom-4 {
340
347
  bottom: calc(var(--spacing) * 4);
341
348
  }
349
+ .-left-5 {
350
+ left: calc(var(--spacing) * -5);
351
+ }
342
352
  .left-\(--docblocks-checkbox-left\) {
343
353
  left: var(--docblocks-checkbox-left);
344
354
  }
@@ -420,6 +430,9 @@
420
430
  .m-0 {
421
431
  margin: 0px;
422
432
  }
433
+ .m-auto {
434
+ margin: auto;
435
+ }
423
436
  .-mx-1 {
424
437
  margin-inline: calc(var(--spacing) * -1);
425
438
  }
@@ -682,9 +695,6 @@
682
695
  .max-h-80 {
683
696
  max-height: calc(var(--spacing) * 80);
684
697
  }
685
- .max-h-full {
686
- max-height: 100%;
687
- }
688
698
  .min-h-0 {
689
699
  min-height: 0px;
690
700
  }
@@ -724,6 +734,9 @@
724
734
  .w-1\.5 {
725
735
  width: calc(var(--spacing) * 1.5);
726
736
  }
737
+ .w-5 {
738
+ width: calc(var(--spacing) * 5);
739
+ }
727
740
  .w-7 {
728
741
  width: calc(var(--spacing) * 7);
729
742
  }
@@ -754,9 +767,6 @@
754
767
  .w-72 {
755
768
  width: calc(var(--spacing) * 72);
756
769
  }
757
- .w-96 {
758
- width: calc(var(--spacing) * 96);
759
- }
760
770
  .w-\[5ch\] {
761
771
  width: 5ch;
762
772
  }
@@ -793,6 +803,9 @@
793
803
  .max-w-full {
794
804
  max-width: 100%;
795
805
  }
806
+ .max-w-xl {
807
+ max-width: var(--container-xl);
808
+ }
796
809
  .min-w-\(--cell-size\) {
797
810
  min-width: var(--cell-size);
798
811
  }
@@ -808,6 +821,15 @@
808
821
  .min-w-32 {
809
822
  min-width: calc(var(--spacing) * 32);
810
823
  }
824
+ .min-w-35 {
825
+ min-width: calc(var(--spacing) * 35);
826
+ }
827
+ .min-w-110 {
828
+ min-width: calc(var(--spacing) * 110);
829
+ }
830
+ .min-w-\[4ch\] {
831
+ min-width: 4ch;
832
+ }
811
833
  .min-w-full {
812
834
  min-width: 100%;
813
835
  }
@@ -1009,6 +1031,9 @@
1009
1031
  .gap-\(--docblocks-block-spacing\) {
1010
1032
  gap: var(--docblocks-block-spacing);
1011
1033
  }
1034
+ .gap-0 {
1035
+ gap: 0px;
1036
+ }
1012
1037
  .gap-0\.5 {
1013
1038
  gap: calc(var(--spacing) * 0.5);
1014
1039
  }
@@ -1693,6 +1718,10 @@
1693
1718
  .italic {
1694
1719
  font-style: italic;
1695
1720
  }
1721
+ .ordinal {
1722
+ --tw-ordinal: ordinal;
1723
+ font-variant-numeric: var(--tw-ordinal,) var(--tw-slashed-zero,) var(--tw-numeric-figure,) var(--tw-numeric-spacing,) var(--tw-numeric-fraction,);
1724
+ }
1696
1725
  .tabular-nums {
1697
1726
  --tw-numeric-spacing: tabular-nums;
1698
1727
  font-variant-numeric: var(--tw-ordinal,) var(--tw-slashed-zero,) var(--tw-numeric-figure,) var(--tw-numeric-spacing,) var(--tw-numeric-fraction,);
@@ -3591,6 +3620,8 @@
3591
3620
  column type stands the one height — the cell's trigger / the input fit
3592
3621
  the content box, the row never grows over its content). */
3593
3622
  --docblocks-database-row-height: 32px;
3623
+ /* The locally inserted row that stays visible outside the active filter. */
3624
+ --docblocks-database-pending-row-border-color: #d97706;
3594
3625
 
3595
3626
  /* Image. */
3596
3627
  --docblocks-image-radius: 0;
@@ -3687,6 +3718,7 @@
3687
3718
  --docblocks-table-border-color: var(--border, rgba(110, 118, 129, 0.65));
3688
3719
  --docblocks-table-drag-background: var(--card, #27272a);
3689
3720
  --docblocks-table-drag-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
3721
+ --docblocks-database-pending-row-border-color: #f59e0b;
3690
3722
  --docblocks-selected-background: color-mix(in srgb, var(--accent, #388bfd) 15%, transparent);
3691
3723
 
3692
3724
  --docblocks-canvas-background: color-mix(in srgb, var(--muted, #6e7681) 15%, transparent);
@@ -3971,6 +4003,29 @@
3971
4003
  vertical-align: baseline;
3972
4004
  }
3973
4005
 
4006
+ /* The flat grid has no row element: the pending row's outline is composed
4007
+ over its cells, with the outer vertical edges on the first and last track. */
4008
+ [data-slot="docblocks/database-cell"][data-filter-pending="true"],
4009
+ [data-slot="docblocks/database-row-menu"][data-filter-pending="true"] {
4010
+ box-shadow:
4011
+ inset 0 1px 0 var(--docblocks-database-pending-row-border-color),
4012
+ inset 0 -1px 0 var(--docblocks-database-pending-row-border-color);
4013
+ }
4014
+
4015
+ [data-slot="docblocks/database-cell"][data-filter-pending="true"][data-col="0"] {
4016
+ box-shadow:
4017
+ inset 2px 0 0 var(--docblocks-database-pending-row-border-color),
4018
+ inset 0 1px 0 var(--docblocks-database-pending-row-border-color),
4019
+ inset 0 -1px 0 var(--docblocks-database-pending-row-border-color);
4020
+ }
4021
+
4022
+ [data-slot="docblocks/database-row-menu"][data-filter-pending="true"] {
4023
+ box-shadow:
4024
+ inset -2px 0 0 var(--docblocks-database-pending-row-border-color),
4025
+ inset 0 1px 0 var(--docblocks-database-pending-row-border-color),
4026
+ inset 0 -1px 0 var(--docblocks-database-pending-row-border-color);
4027
+ }
4028
+
3974
4029
  /* 5. The shape-text's self-hosted fonts (the woff2 in dist/fonts/; the
3975
4030
  * unicode-range keeps a file fetched only when the shape's text stands
3976
4031
  * in that font / subset). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docblocks-react-ui",
3
- "version": "0.4.7",
3
+ "version": "0.6.0",
4
4
  "description": "React rendering + editing layer for docblocks: hooks, block renderers, caret/selection, keyboard, clipboard.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -34,7 +34,7 @@
34
34
  "access": "public"
35
35
  },
36
36
  "peerDependencies": {
37
- "docblocks-core": "^0.2.2",
37
+ "docblocks-core": "^0.3.0",
38
38
  "framer-motion": "^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0",
39
39
  "mermaid": "^12.0.0",
40
40
  "pdfjs-dist": "^6.0.0",