art-bd-ui 1.0.40 → 1.0.42

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.
Files changed (63) hide show
  1. package/dist/cjs/_virtual/index10.js +2 -8
  2. package/dist/cjs/_virtual/index9.js +8 -2
  3. package/dist/cjs/components/ui/pdf-content/hooks/use-page-layout.js +25 -31
  4. package/dist/cjs/components/ui/pdf-content/pdf-content.js +125 -34
  5. package/dist/cjs/components/ui/pdf-content/pdf-page.js +7 -10
  6. package/dist/cjs/components/ui/pdf-viewer/pdf-viewer.js +2 -2
  7. package/dist/cjs/components/ui/rich-editor/extensions/carousel/shared.js +1 -1
  8. package/dist/cjs/components/ui/rich-editor/extensions/details-content.js +1 -1
  9. package/dist/cjs/components/ui/rich-editor/extensions/details-summary.js +1 -1
  10. package/dist/cjs/components/ui/rich-editor/extensions/details.js +1 -1
  11. package/dist/cjs/components/ui/rich-editor/extensions/image.js +236 -0
  12. package/dist/cjs/components/ui/rich-editor/extensions/slash/default-suggestions.js +12 -0
  13. package/dist/cjs/components/ui/rich-editor/extensions.js +35 -35
  14. package/dist/cjs/components/ui/rich-editor/rich-editor.js +8 -1
  15. package/dist/cjs/components/ui/rich-editor/toolbar.js +2 -1
  16. package/dist/cjs/node_modules/@pdf-lib/standard-fonts/es/utils.js +1 -1
  17. package/dist/cjs/node_modules/@pdf-lib/upng/UPNG.js +1 -1
  18. package/dist/cjs/node_modules/@tiptap/extension-code-block/dist/index.js +0 -6
  19. package/dist/cjs/node_modules/@tiptap/extension-code-block-lowlight/dist/index.js +1 -1
  20. package/dist/cjs/node_modules/@tiptap/extension-image/dist/index.js +3 -2
  21. package/dist/cjs/node_modules/@tiptap/extension-link/dist/index.js +52 -28
  22. package/dist/cjs/node_modules/@tiptap/extension-list/dist/index.js +29 -1
  23. package/dist/cjs/node_modules/@tiptap/extension-paragraph/dist/index.js +13 -8
  24. package/dist/cjs/node_modules/@tiptap/extension-text-align/dist/index.js +2 -2
  25. package/dist/cjs/node_modules/@tiptap/extension-youtube/dist/index.js +1 -1
  26. package/dist/cjs/node_modules/@tiptap/extensions/dist/index.js +9 -2
  27. package/dist/cjs/node_modules/pdf-lib/es/core/PDFContext.js +1 -1
  28. package/dist/cjs/node_modules/pdf-lib/es/core/structures/PDFFlateStream.js +1 -1
  29. package/dist/cjs/node_modules/prop-types/node_modules/react-is/index.js +1 -1
  30. package/dist/cjs/node_modules/react-window/dist/react-window.js +608 -0
  31. package/dist/esm/_virtual/index10.js +2 -6
  32. package/dist/esm/_virtual/index9.js +6 -2
  33. package/dist/esm/components/ui/pdf-content/hooks/use-page-layout.js +26 -32
  34. package/dist/esm/components/ui/pdf-content/pdf-content.js +126 -35
  35. package/dist/esm/components/ui/pdf-content/pdf-page.js +7 -10
  36. package/dist/esm/components/ui/pdf-viewer/pdf-viewer.js +2 -2
  37. package/dist/esm/components/ui/rich-editor/extensions/carousel/shared.js +1 -1
  38. package/dist/esm/components/ui/rich-editor/extensions/details-content.js +1 -1
  39. package/dist/esm/components/ui/rich-editor/extensions/details-summary.js +1 -1
  40. package/dist/esm/components/ui/rich-editor/extensions/details.js +1 -1
  41. package/dist/esm/components/ui/rich-editor/extensions/image.js +234 -0
  42. package/dist/esm/components/ui/rich-editor/extensions/slash/default-suggestions.js +12 -0
  43. package/dist/esm/components/ui/rich-editor/extensions.js +29 -29
  44. package/dist/esm/components/ui/rich-editor/rich-editor.js +8 -1
  45. package/dist/esm/components/ui/rich-editor/toolbar.js +2 -1
  46. package/dist/esm/node_modules/@pdf-lib/standard-fonts/es/utils.js +1 -1
  47. package/dist/esm/node_modules/@pdf-lib/upng/UPNG.js +1 -1
  48. package/dist/esm/node_modules/@tiptap/extension-code-block/dist/index.js +1 -4
  49. package/dist/esm/node_modules/@tiptap/extension-code-block-lowlight/dist/index.js +2 -2
  50. package/dist/esm/node_modules/@tiptap/extension-image/dist/index.js +3 -2
  51. package/dist/esm/node_modules/@tiptap/extension-link/dist/index.js +52 -28
  52. package/dist/esm/node_modules/@tiptap/extension-list/dist/index.js +30 -2
  53. package/dist/esm/node_modules/@tiptap/extension-paragraph/dist/index.js +13 -8
  54. package/dist/esm/node_modules/@tiptap/extension-text-align/dist/index.js +2 -2
  55. package/dist/esm/node_modules/@tiptap/extension-youtube/dist/index.js +1 -1
  56. package/dist/esm/node_modules/@tiptap/extensions/dist/index.js +9 -3
  57. package/dist/esm/node_modules/pdf-lib/es/core/PDFContext.js +1 -1
  58. package/dist/esm/node_modules/pdf-lib/es/core/structures/PDFFlateStream.js +1 -1
  59. package/dist/esm/node_modules/prop-types/node_modules/react-is/index.js +1 -1
  60. package/dist/esm/node_modules/react-window/dist/react-window.js +606 -0
  61. package/dist/styles.css +318 -3
  62. package/dist/types/index.d.ts +19 -16
  63. package/package.json +46 -45
@@ -1,11 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
3
+ var reactIs = {exports: {}};
4
4
 
5
- var _commonjsHelpers = require('./_commonjsHelpers.js');
6
- var index = require('../node_modules/pako/index.js');
7
-
8
- var pakoExports = index.__require();
9
- var pako = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(pakoExports);
10
-
11
- exports.default = pako;
5
+ exports.__module = reactIs;
@@ -1,5 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var reactIs = {exports: {}};
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- exports.__module = reactIs;
5
+ var _commonjsHelpers = require('./_commonjsHelpers.js');
6
+ var index = require('../node_modules/pako/index.js');
7
+
8
+ var pakoExports = index.__require();
9
+ var pako = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(pakoExports);
10
+
11
+ exports.default = pako;
@@ -2,48 +2,42 @@
2
2
 
3
3
  var React = require('react');
4
4
 
5
- const DEFAULT_PAGE_HEIGHT = 800;
5
+ const DEFAULT_PAGE_SIZE = { width: 612, height: 792 };
6
6
  const PAGE_GAP = 16;
7
- function usePageLayout({ numPages, scale }) {
8
- const pageDims = React.useRef(new Map());
9
- // Bumped when page measurements change so memoized offsets recompute.
10
- const [layoutVersion, setLayoutVersion] = React.useState(0);
11
- const onPageMeasured = React.useCallback((page, dims) => {
12
- const prev = pageDims.current.get(page);
13
- if (prev && Math.abs(prev.height - dims.height) < 1 && Math.abs(prev.width - dims.width) < 1)
14
- return;
15
- pageDims.current.set(page, dims);
16
- setLayoutVersion((v) => v + 1);
17
- }, []);
18
- const estimatePageHeight = React.useCallback((page) => {
19
- const measured = pageDims.current.get(page);
20
- if (measured)
21
- return measured.height;
22
- // Use nearest known height as a better estimate
23
- for (const [, dim] of pageDims.current)
24
- return dim.height;
25
- return DEFAULT_PAGE_HEIGHT * scale;
26
- }, [scale]);
7
+ function usePageLayout({ numPages, pageSizes, containerWidth, scale }) {
8
+ const fallbackSize = React.useMemo(() => {
9
+ const firstKnownPage = pageSizes.values().next();
10
+ if (!firstKnownPage.done)
11
+ return firstKnownPage.value;
12
+ return DEFAULT_PAGE_SIZE;
13
+ }, [pageSizes]);
14
+ const pageHeights = React.useMemo(() => Array.from({ length: numPages }, (_, index) => {
15
+ var _a;
16
+ const pageNumber = index + 1;
17
+ const baseSize = (_a = pageSizes.get(pageNumber)) !== null && _a !== void 0 ? _a : fallbackSize;
18
+ const effectiveWidth = containerWidth > 0 ? containerWidth : baseSize.width;
19
+ const scaleFromWidth = effectiveWidth / baseSize.width;
20
+ return baseSize.height * scaleFromWidth * scale;
21
+ }), [numPages, pageSizes, fallbackSize, containerWidth, scale]);
27
22
  const pageOffsets = React.useMemo(() => {
23
+ var _a;
28
24
  const offsets = [];
29
25
  let y = 0;
30
26
  for (let i = 0; i < numPages; i++) {
31
27
  offsets.push(y);
32
- y += estimatePageHeight(i + 1) + PAGE_GAP;
28
+ y += (_a = pageHeights[i]) !== null && _a !== void 0 ? _a : 0;
29
+ if (i < numPages - 1)
30
+ y += PAGE_GAP;
33
31
  }
34
32
  return offsets;
35
- // layoutVersion is intentionally included to recompute when measurements change
36
- }, [numPages, estimatePageHeight, layoutVersion]);
33
+ }, [numPages, pageHeights]);
37
34
  const totalHeight = React.useMemo(() => {
35
+ var _a;
38
36
  if (numPages === 0 || pageOffsets.length === 0)
39
37
  return 0;
40
- return pageOffsets[numPages - 1] + estimatePageHeight(numPages);
41
- }, [numPages, pageOffsets, estimatePageHeight]);
42
- const resetLayout = React.useCallback(() => {
43
- pageDims.current.clear();
44
- setLayoutVersion(0);
45
- }, []);
46
- return { pageOffsets, totalHeight, estimatePageHeight, onPageMeasured, resetLayout };
38
+ return pageOffsets[numPages - 1] + ((_a = pageHeights[numPages - 1]) !== null && _a !== void 0 ? _a : 0);
39
+ }, [numPages, pageOffsets, pageHeights]);
40
+ return { pageOffsets, pageHeights, totalHeight };
47
41
  }
48
42
 
49
43
  exports.usePageLayout = usePageLayout;
@@ -1,17 +1,21 @@
1
1
  'use strict';
2
2
 
3
+ var tslib_es6 = require('../../../node_modules/tslib/tslib.es6.js');
3
4
  var jsxRuntime = require('react/jsx-runtime');
4
5
  var React = require('react');
5
6
  require('../../../node_modules/react-pdf/dist/index.js');
7
+ var reactWindow = require('../../../node_modules/react-window/dist/react-window.js');
6
8
  var pdfPage = require('./pdf-page.js');
7
9
  var usePdfScale = require('./hooks/use-pdf-scale.js');
8
10
  var usePageLayout = require('./hooks/use-page-layout.js');
9
- var useVirtualPages = require('./hooks/use-virtual-pages.js');
10
11
  var utils$1 = require('./utils.js');
11
12
  var empty = require('../../utility/empty/empty.js');
12
13
  var icon = require('../../media/icon/icon.js');
13
14
  var skeleton = require('../../utility/skeleton/skeleton.js');
15
+ var useUpdateEffect = require('../../../hooks/use-update-effect.js');
14
16
  var useResizeObserver = require('../../../hooks/use-resize-observer.js');
17
+ require('../../../_virtual/throttle.js');
18
+ require('../../../_virtual/isEqual.js');
15
19
  var utils = require('../../../lib/utils.js');
16
20
  require('../../../node_modules/react-pdf/dist/Page/AnnotationLayer.css.js');
17
21
  require('../../../node_modules/react-pdf/dist/Page/TextLayer.css.js');
@@ -21,48 +25,128 @@ var pdf = require('../../../node_modules/pdfjs-dist/build/pdf.js');
21
25
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
22
26
  pdf.GlobalWorkerOptions.workerSrc = new URL("pdfjs-dist/build/pdf.worker.min.mjs", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('components/ui/pdf-content/pdf-content.js', document.baseURI).href))).toString();
23
27
  const PAGE_GAP = 16;
28
+ const OVERSCAN = 3;
29
+ const PAGE_SIZE_BATCH = 100;
30
+ function getPageGap(index, numPages) {
31
+ return index < numPages - 1 ? PAGE_GAP : 0;
32
+ }
33
+ function getSafePageNumber(page, numPages) {
34
+ return utils$1.clamp(Number.isFinite(page) ? page : 1, 1, Math.max(1, numPages));
35
+ }
36
+ function createEmptyPageSizes() {
37
+ return new Map();
38
+ }
39
+ function findMostVisiblePage(firstIndex, lastIndex, viewportMid, pageOffsets, pageHeights) {
40
+ var _a, _b;
41
+ let bestPage = firstIndex + 1;
42
+ let bestDist = Number.POSITIVE_INFINITY;
43
+ for (let i = firstIndex; i <= lastIndex; i++) {
44
+ const pageHeight = (_a = pageHeights[i]) !== null && _a !== void 0 ? _a : 0;
45
+ const pageMid = ((_b = pageOffsets[i]) !== null && _b !== void 0 ? _b : 0) + pageHeight / 2;
46
+ const dist = Math.abs(viewportMid - pageMid);
47
+ if (dist < bestDist) {
48
+ bestDist = dist;
49
+ bestPage = i + 1;
50
+ }
51
+ }
52
+ return bestPage;
53
+ }
54
+ function loadPageSizes(pdf) {
55
+ return tslib_es6.__awaiter(this, void 0, void 0, function* () {
56
+ try {
57
+ const nextPageSizes = createEmptyPageSizes();
58
+ for (let startPage = 1; startPage <= pdf.numPages; startPage += PAGE_SIZE_BATCH) {
59
+ const endPage = Math.min(startPage + PAGE_SIZE_BATCH - 1, pdf.numPages);
60
+ const pages = yield Promise.all(Array.from({ length: endPage - startPage + 1 }, (_, offset) => pdf.getPage(startPage + offset)));
61
+ pages.forEach((page) => {
62
+ const { width, height } = page.getViewport({ scale: 1 });
63
+ nextPageSizes.set(page.pageNumber, { width, height });
64
+ });
65
+ }
66
+ return nextPageSizes;
67
+ }
68
+ catch (_a) {
69
+ return createEmptyPageSizes();
70
+ }
71
+ });
72
+ }
73
+ function PDFVirtualRow({ index, style, ariaAttributes, containerWidth, numPages, pageHeights, scale, renderTextLayer, renderAnnotationLayer, }) {
74
+ var _a;
75
+ const gap = getPageGap(index, numPages);
76
+ return (jsxRuntime.jsx(pdfPage.PDFPage, { pageNumber: index + 1, containerWidth: containerWidth, scale: scale, renderTextLayer: renderTextLayer, renderAnnotationLayer: renderAnnotationLayer, placeholderHeight: (_a = pageHeights[index]) !== null && _a !== void 0 ? _a : 0, ariaAttributes: ariaAttributes, style: Object.assign(Object.assign({}, style), { boxSizing: "border-box", paddingBottom: gap }) }));
77
+ }
24
78
  function PDFSkeleton() {
25
79
  return (jsxRuntime.jsxs("div", { className: "flex flex-col gap-4 p-6", children: [jsxRuntime.jsx(skeleton.Skeleton, { className: "h-6 w-1/3" }), jsxRuntime.jsx(skeleton.Skeleton, { className: "h-4 w-3/4" }), jsxRuntime.jsx(skeleton.Skeleton, { className: "h-4 w-full" }), jsxRuntime.jsx(skeleton.Skeleton, { className: "h-4 w-5/6" }), jsxRuntime.jsx(skeleton.Skeleton, { className: "h-4 w-2/3" }), jsxRuntime.jsx(skeleton.Skeleton, { className: "h-4 w-full" }), jsxRuntime.jsx(skeleton.Skeleton, { className: "h-4 w-4/5" })] }));
26
80
  }
27
81
  function PDFEmptyState({ icon: icon$1, title, description }) {
28
82
  return (jsxRuntime.jsxs(empty.EmptyState, { className: "py-12", children: [jsxRuntime.jsx(empty.EmptyMedia, { variant: "icon", children: jsxRuntime.jsx(icon.Icon, { name: icon$1 }) }), jsxRuntime.jsxs(empty.EmptyHeader, { children: [jsxRuntime.jsx(empty.EmptyTitle, { children: title }), jsxRuntime.jsx(empty.EmptyDescription, { children: description })] })] }));
29
83
  }
30
- const PDFContent = React.forwardRef(function PDFContent({ file, renderTextLayer = true, renderAnnotationLayer = true, initialScale = 1, minScale = 0.5, maxScale = 3, onDocumentLoad, onPageChange, onScaleChange, className, }, ref) {
84
+ const NO_DATA_PLACEHOLDER = (jsxRuntime.jsx(PDFEmptyState, { icon: "file-text", title: "No PDF to display", description: "Provide a PDF file to preview it here." }));
85
+ const LOADING_PLACEHOLDER = jsxRuntime.jsx(PDFSkeleton, {});
86
+ const ERROR_PLACEHOLDER = (jsxRuntime.jsx(PDFEmptyState, { icon: "alert-circle", title: "Failed to load PDF", description: "The PDF file could not be loaded." }));
87
+ const PDFContent = React.forwardRef(function PDFContent({ file, renderTextLayer = true, renderAnnotationLayer = true, initialScale = 1, minScale = 0.5, maxScale = 3, height, onDocumentLoad, onPageChange, onScaleChange, className, }, ref) {
31
88
  var _a;
32
89
  const containerRef = React.useRef(null);
90
+ const listRef = React.useRef(null);
91
+ const pageSizesRequestIdRef = React.useRef(0);
33
92
  const rect = useResizeObserver.useResizeObserver(containerRef);
34
93
  const containerWidth = (_a = rect === null || rect === void 0 ? void 0 : rect.width) !== null && _a !== void 0 ? _a : 0;
35
94
  const [numPages, setNumPages] = React.useState(0);
95
+ const [visiblePage, setVisiblePage] = React.useState(1);
96
+ const [isLayoutReady, setIsLayoutReady] = React.useState(false);
97
+ const [pageSizes, setPageSizes] = React.useState(createEmptyPageSizes);
36
98
  const { scale, setScale } = usePdfScale.usePdfScale({ initialScale, minScale, maxScale, onScaleChange });
37
- const { pageOffsets, totalHeight, estimatePageHeight, onPageMeasured, resetLayout } = usePageLayout.usePageLayout({
99
+ const { pageOffsets, pageHeights } = usePageLayout.usePageLayout({
38
100
  numPages,
101
+ pageSizes,
102
+ containerWidth,
39
103
  scale,
40
104
  });
41
- const { visiblePage, renderedPages, onScroll, resetVirtualState } = useVirtualPages.useVirtualPages({
42
- containerRef,
43
- numPages,
44
- pageOffsets,
45
- estimatePageHeight,
46
- scale,
47
- });
48
- // Notify parent of page changes
49
- React.useEffect(() => {
105
+ const setVisiblePageIfNeeded = React.useCallback((nextPage) => {
106
+ setVisiblePage((currentPage) => (currentPage === nextPage ? currentPage : nextPage));
107
+ }, []);
108
+ useUpdateEffect.useUpdateEffect(() => {
50
109
  onPageChange === null || onPageChange === void 0 ? void 0 : onPageChange(visiblePage);
51
110
  }, [visiblePage, onPageChange]);
52
- // Imperative scrollToPage
53
- const scrollToPage = React.useCallback((page) => {
111
+ const handleRowsRendered = React.useCallback(({ startIndex, stopIndex }) => {
54
112
  var _a;
55
- const safe = utils$1.clamp(Number.isFinite(page) ? page : 1, 1, Math.max(1, numPages));
56
- const container = containerRef.current;
57
- if (!container)
113
+ if (numPages === 0)
114
+ return;
115
+ const maxIndex = numPages - 1;
116
+ const first = utils$1.clamp(startIndex, 0, maxIndex);
117
+ const last = utils$1.clamp(stopIndex, first, maxIndex);
118
+ const listElement = (_a = listRef.current) === null || _a === void 0 ? void 0 : _a.element;
119
+ if (!listElement) {
120
+ setVisiblePageIfNeeded(first + 1);
58
121
  return;
59
- const top = (_a = pageOffsets[safe - 1]) !== null && _a !== void 0 ? _a : 0;
60
- container.scrollTo({
61
- top: Math.max(0, top - PAGE_GAP),
122
+ }
123
+ const viewportMid = listElement.scrollTop + listElement.clientHeight / 2;
124
+ const next = findMostVisiblePage(first, last, viewportMid, pageOffsets, pageHeights);
125
+ setVisiblePageIfNeeded(next);
126
+ }, [numPages, pageOffsets, pageHeights, setVisiblePageIfNeeded]);
127
+ const rowHeight = React.useCallback((index) => {
128
+ var _a;
129
+ const baseHeight = (_a = pageHeights[index]) !== null && _a !== void 0 ? _a : 0;
130
+ const gap = getPageGap(index, numPages);
131
+ return baseHeight + gap;
132
+ }, [numPages, pageHeights]);
133
+ const rowProps = React.useMemo(() => ({
134
+ containerWidth,
135
+ numPages,
136
+ pageHeights,
137
+ scale,
138
+ renderTextLayer,
139
+ renderAnnotationLayer,
140
+ }), [containerWidth, numPages, pageHeights, scale, renderTextLayer, renderAnnotationLayer]);
141
+ const scrollToPage = React.useCallback((page) => {
142
+ var _a;
143
+ const safePage = getSafePageNumber(page, numPages);
144
+ (_a = listRef.current) === null || _a === void 0 ? void 0 : _a.scrollToRow({
145
+ index: safePage - 1,
146
+ align: "start",
62
147
  behavior: "smooth",
63
148
  });
64
- }, [numPages, pageOffsets]);
65
- // Expose imperative API
149
+ }, [numPages]);
66
150
  React.useImperativeHandle(ref, () => ({
67
151
  scrollToPage,
68
152
  getState: () => ({
@@ -72,21 +156,28 @@ const PDFContent = React.forwardRef(function PDFContent({ file, renderTextLayer
72
156
  }),
73
157
  setScale,
74
158
  }), [scrollToPage, visiblePage, numPages, scale, setScale]);
75
- // Reset state when document changes
76
- React.useEffect(() => {
77
- resetLayout();
78
- resetVirtualState();
159
+ const resetDocumentState = React.useCallback(() => {
160
+ pageSizesRequestIdRef.current += 1;
161
+ setIsLayoutReady(false);
162
+ setVisiblePage(1);
79
163
  setNumPages(0);
80
- }, [file, resetLayout, resetVirtualState]);
81
- // Document load handler
82
- const handleDocumentLoad = React.useCallback((pdf) => {
83
- setNumPages(pdf.numPages);
164
+ setPageSizes(createEmptyPageSizes());
165
+ }, []);
166
+ useUpdateEffect.useUpdateEffect(() => {
167
+ resetDocumentState();
168
+ }, [file, resetDocumentState]);
169
+ const handleDocumentLoadSuccess = React.useCallback((pdf) => {
170
+ const requestId = ++pageSizesRequestIdRef.current;
84
171
  onDocumentLoad === null || onDocumentLoad === void 0 ? void 0 : onDocumentLoad(pdf.numPages);
172
+ void loadPageSizes(pdf).then((nextPageSizes) => {
173
+ if (requestId !== pageSizesRequestIdRef.current)
174
+ return;
175
+ setPageSizes(nextPageSizes);
176
+ setNumPages(pdf.numPages);
177
+ setIsLayoutReady(true);
178
+ });
85
179
  }, [onDocumentLoad]);
86
- return (jsxRuntime.jsx("div", { ref: containerRef, "data-pdf-stage": "root", className: utils.cn("relative overflow-auto bg-muted/40", className), onScroll: onScroll, children: jsxRuntime.jsx(Document.default, { file: file, onLoadSuccess: handleDocumentLoad, loading: jsxRuntime.jsx(PDFSkeleton, {}), error: jsxRuntime.jsx(PDFEmptyState, { icon: "alert-circle", title: "Failed to load PDF", description: "The PDF file could not be loaded." }), noData: jsxRuntime.jsx(PDFEmptyState, { icon: "file-text", title: "No PDF to display", description: "Provide a PDF file to preview it here." }), children: jsxRuntime.jsx("div", { className: "relative", style: { height: totalHeight }, children: renderedPages.map((pageNumber) => {
87
- var _a;
88
- return (jsxRuntime.jsx(pdfPage.PDFPage, { pageNumber: pageNumber, offsetY: (_a = pageOffsets[pageNumber - 1]) !== null && _a !== void 0 ? _a : 0, containerWidth: containerWidth, scale: scale, renderTextLayer: renderTextLayer, renderAnnotationLayer: renderAnnotationLayer, placeholderHeight: estimatePageHeight(pageNumber), onMeasured: onPageMeasured }, pageNumber));
89
- }) }) }) }));
180
+ return (jsxRuntime.jsx("div", { ref: containerRef, "data-pdf-stage": "root", className: utils.cn("relative h-full min-h-0 overflow-auto bg-muted/40", className), style: height !== undefined ? { height } : undefined, children: jsxRuntime.jsx(Document.default, { file: file, onLoadSuccess: handleDocumentLoadSuccess, loading: LOADING_PLACEHOLDER, error: ERROR_PLACEHOLDER, noData: NO_DATA_PLACEHOLDER, children: isLayoutReady ? (jsxRuntime.jsx(reactWindow.List, { listRef: listRef, rowCount: numPages, rowHeight: rowHeight, rowComponent: PDFVirtualRow, rowProps: rowProps, overscanCount: OVERSCAN, onRowsRendered: handleRowsRendered, className: "h-full w-full" })) : (LOADING_PLACEHOLDER) }) }));
90
181
  });
91
182
 
92
183
  exports.PDFContent = PDFContent;
@@ -1,20 +1,17 @@
1
1
  'use strict';
2
2
 
3
3
  var jsxRuntime = require('react/jsx-runtime');
4
- var React = require('react');
5
4
  require('../../../node_modules/react-pdf/dist/index.js');
6
5
  var skeleton = require('../../utility/skeleton/skeleton.js');
6
+ var utils = require('../../../lib/utils.js');
7
7
  var Page = require('../../../node_modules/react-pdf/dist/Page.js');
8
8
 
9
- function PDFPage({ pageNumber, offsetY, containerWidth, scale, renderTextLayer, renderAnnotationLayer, placeholderHeight, onMeasured, }) {
10
- const wrapRef = React.useRef(null);
11
- const width = containerWidth > 0 ? containerWidth : undefined;
12
- return (jsxRuntime.jsx("div", { ref: wrapRef, "data-page-num": pageNumber, className: "absolute inset-x-0 flex will-change-transform justify-center", style: { transform: `translateY(${offsetY}px)` }, children: jsxRuntime.jsx(Page.default, { pageNumber: pageNumber, width: width, scale: scale, renderTextLayer: renderTextLayer, renderAnnotationLayer: renderAnnotationLayer, onRenderSuccess: () => {
13
- const el = wrapRef.current;
14
- if (!el)
15
- return;
16
- onMeasured(pageNumber, { width: el.offsetWidth, height: el.offsetHeight });
17
- }, loading: jsxRuntime.jsxs("div", { className: "flex w-full flex-col gap-3 p-6", style: { height: placeholderHeight }, children: [jsxRuntime.jsx(skeleton.Skeleton, { className: "h-4 w-3/4" }), jsxRuntime.jsx(skeleton.Skeleton, { className: "h-4 w-full" }), jsxRuntime.jsx(skeleton.Skeleton, { className: "h-4 w-5/6" }), jsxRuntime.jsx(skeleton.Skeleton, { className: "h-4 w-2/3" }), jsxRuntime.jsx(skeleton.Skeleton, { className: "h-4 w-full" }), jsxRuntime.jsx(skeleton.Skeleton, { className: "h-4 w-4/5" })] }) }) }));
9
+ function PDFPageLoadingState({ placeholderHeight }) {
10
+ return (jsxRuntime.jsxs("div", { className: "flex w-full flex-col gap-3 p-6", style: { height: placeholderHeight }, children: [jsxRuntime.jsx(skeleton.Skeleton, { className: "h-4 w-3/4" }), jsxRuntime.jsx(skeleton.Skeleton, { className: "h-4 w-full" }), jsxRuntime.jsx(skeleton.Skeleton, { className: "h-4 w-5/6" }), jsxRuntime.jsx(skeleton.Skeleton, { className: "h-4 w-2/3" }), jsxRuntime.jsx(skeleton.Skeleton, { className: "h-4 w-full" }), jsxRuntime.jsx(skeleton.Skeleton, { className: "h-4 w-4/5" })] }));
11
+ }
12
+ function PDFPage({ pageNumber, containerWidth, scale, renderTextLayer, renderAnnotationLayer, placeholderHeight, className, style, ariaAttributes, }) {
13
+ const pageWidth = containerWidth > 0 ? containerWidth : undefined;
14
+ return (jsxRuntime.jsx("div", Object.assign({ "data-page-num": pageNumber, className: utils.cn("flex justify-center", className), style: style }, ariaAttributes, { children: jsxRuntime.jsx(Page.default, { pageNumber: pageNumber, width: pageWidth, scale: scale, renderTextLayer: renderTextLayer, renderAnnotationLayer: renderAnnotationLayer, loading: jsxRuntime.jsx(PDFPageLoadingState, { placeholderHeight: placeholderHeight }) }) })));
18
15
  }
19
16
 
20
17
  exports.PDFPage = PDFPage;
@@ -10,7 +10,7 @@ var utils = require('../pdf-content/utils.js');
10
10
  var utils$1 = require('../../../lib/utils.js');
11
11
  var file = require('../../../utils/file.js');
12
12
 
13
- function PDFViewer({ file: file$1, formData, flatten = true, initialScale = 1, minScale = 0.5, maxScale = 3, scaleStep = 0.1, renderTextLayer = true, renderAnnotationLayer = true, className, style, }) {
13
+ function PDFViewer({ file: file$1, formData, flatten = true, initialScale = 1, minScale = 0.5, maxScale = 3, scaleStep = 0.1, renderTextLayer = true, renderAnnotationLayer = true, height, className, style, }) {
14
14
  const contentRef = React.useRef(null);
15
15
  const [scale, setScale] = React.useState(initialScale);
16
16
  const [numPages, setNumPages] = React.useState(0);
@@ -43,7 +43,7 @@ function PDFViewer({ file: file$1, formData, flatten = true, initialScale = 1, m
43
43
  return;
44
44
  file.printBlob(pdfBlob);
45
45
  }, [pdfBlob]);
46
- return (jsxRuntime.jsxs("div", { className: utils$1.cn("flex flex-col overflow-hidden rounded-xl border", className), style: style, children: [jsxRuntime.jsx(toolbar.Toolbar, { scale: scale, minScale: minScale, maxScale: maxScale, onZoomIn: zoomIn, onZoomOut: zoomOut, pageNumber: visiblePage, numPages: numPages, onPageChange: goToPage, onPrev: prev, onNext: next, canDownload: !isProcessing, onDownload: download, canPrint: !isProcessing, onPrint: print, isBusy: isProcessing }), jsxRuntime.jsx(pdfContent.PDFContent, { ref: contentRef, file: pdfBlob, initialScale: initialScale, minScale: minScale, maxScale: maxScale, renderTextLayer: renderTextLayer, renderAnnotationLayer: renderAnnotationLayer, onDocumentLoad: handleDocumentLoad, onPageChange: setVisiblePage, onScaleChange: setScale })] }));
46
+ return (jsxRuntime.jsxs("div", { className: utils$1.cn("flex min-h-0 flex-col overflow-hidden rounded-xl border", className), style: Object.assign({ height }, style), children: [jsxRuntime.jsx(toolbar.Toolbar, { scale: scale, minScale: minScale, maxScale: maxScale, onZoomIn: zoomIn, onZoomOut: zoomOut, pageNumber: visiblePage, numPages: numPages, onPageChange: goToPage, onPrev: prev, onNext: next, canDownload: !isProcessing, onDownload: download, canPrint: !isProcessing, onPrint: print, isBusy: isProcessing }), jsxRuntime.jsx(pdfContent.PDFContent, { ref: contentRef, file: pdfBlob, className: "flex-1 min-h-0", initialScale: initialScale, minScale: minScale, maxScale: maxScale, renderTextLayer: renderTextLayer, renderAnnotationLayer: renderAnnotationLayer, onDocumentLoad: handleDocumentLoad, onPageChange: setVisiblePage, onScaleChange: setScale })] }));
47
47
  }
48
48
 
49
49
  exports.PDFViewer = PDFViewer;
@@ -120,7 +120,7 @@ function SharedCarousel({ images, opts, className }) {
120
120
  if (!slides.length) {
121
121
  return null;
122
122
  }
123
- return (jsxRuntime.jsx("div", { className: utils.cn("w-full", className), children: jsxRuntime.jsxs("div", { className: "max-w-screen", style: frameStyle, children: [jsxRuntime.jsx("div", { style: viewportStyle, children: jsxRuntime.jsxs(carousel.Carousel, { opts: {
123
+ return (jsxRuntime.jsx("div", { className: utils.cn("w-full", className), children: jsxRuntime.jsxs("div", { className: "max-w-screen overflow-hidden", style: frameStyle, children: [jsxRuntime.jsx("div", { style: viewportStyle, children: jsxRuntime.jsxs(carousel.Carousel, { opts: {
124
124
  loop: opts.loop,
125
125
  align: "center",
126
126
  axis: "x",
@@ -10,7 +10,7 @@ var index = require('../../../../node_modules/@tiptap/extension-details/dist/ind
10
10
  */
11
11
  const DetailsContent = index.DetailsContent.configure({
12
12
  HTMLAttributes: {
13
- class: "px-4 py-3 text-sm",
13
+ class: "px-4 pb-4 pt-3 text-sm [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",
14
14
  },
15
15
  });
16
16
 
@@ -10,7 +10,7 @@ var index = require('../../../../node_modules/@tiptap/extension-details/dist/ind
10
10
  */
11
11
  const DetailsSummary = index.DetailsSummary.configure({
12
12
  HTMLAttributes: {
13
- class: "flex cursor-pointer items-center justify-between rounded-t-lg bg-muted/50 px-4 py-3 font-semibold text-foreground hover:bg-muted transition-colors [&::-webkit-details-marker]:hidden",
13
+ class: "relative m-0 list-none rounded-lg bg-muted/40 px-12 py-3 text-sm font-medium leading-6 text-foreground transition-colors outline-none hover:bg-muted/60 before:absolute before:left-6 before:top-1/2 before:inline-block before:-translate-y-1/2 before:text-xs before:leading-none before:text-muted-foreground before:transition-transform before:content-['❯'] [.is-open_&]:rounded-b-none [.is-open_&]:border-b [.is-open_&]:border-border [.is-open_&]:before:rotate-90 [.is-open_&]:before:transform group-open/details:rounded-b-none group-open/details:border-b group-open/details:border-border group-open/details:before:rotate-90 group-open/details:before:transform [[data-type='details']_&]:before:content-none [&::-webkit-details-marker]:hidden",
14
14
  },
15
15
  });
16
16
 
@@ -12,7 +12,7 @@ const Details = index.Details.configure({
12
12
  persist: true, // Save open/closed state in document
13
13
  openClassName: "is-open",
14
14
  HTMLAttributes: {
15
- class: "mt-4 rounded-lg border border-border bg-card text-card-foreground shadow-sm first:mt-0",
15
+ class: "group/details relative mt-4 overflow-hidden rounded-lg border border-border bg-card text-card-foreground shadow-sm first:mt-0 [&>button]:absolute [&>button]:left-3 [&>button]:top-3 [&>button]:z-10 [&>button]:inline-flex [&>button]:size-6 [&>button]:cursor-pointer [&>button]:items-center [&>button]:justify-center [&>button]:rounded-md [&>button]:border-0 [&>button]:bg-transparent [&>button]:p-0 [&>button]:text-muted-foreground [&>button]:transition-colors [&>button:hover]:bg-muted [&>button:hover]:text-foreground [&>button:focus-visible]:outline-none [&>button:focus-visible]:ring-2 [&>button:focus-visible]:ring-ring [&>button:focus-visible]:ring-offset-2 [&>button:focus-visible]:ring-offset-background [&>button::before]:inline-block [&>button::before]:text-xs [&>button::before]:leading-none [&>button::before]:transition-transform [&>button::before]:content-['❯'] [&.is-open>button::before]:rotate-90 [&.is-open>button::before]:transform",
16
16
  },
17
17
  });
18
18