art-bd-ui 1.0.41 → 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 (29) hide show
  1. package/dist/cjs/_virtual/index5.js +8 -2
  2. package/dist/cjs/_virtual/index6.js +4 -4
  3. package/dist/cjs/_virtual/index7.js +2 -8
  4. package/dist/cjs/components/ui/pdf-content/hooks/use-page-layout.js +25 -31
  5. package/dist/cjs/components/ui/pdf-content/pdf-content.js +125 -34
  6. package/dist/cjs/components/ui/pdf-content/pdf-page.js +7 -10
  7. package/dist/cjs/components/ui/pdf-viewer/pdf-viewer.js +2 -2
  8. package/dist/cjs/node_modules/@ckeditor/ckeditor5-mention/dist/index.js +1 -1
  9. package/dist/cjs/node_modules/@ckeditor/ckeditor5-paragraph/dist/index.js +1 -1
  10. package/dist/cjs/node_modules/@ckeditor/ckeditor5-ui/dist/index.js +1 -1
  11. package/dist/cjs/node_modules/color-parse/index.js +1 -1
  12. package/dist/cjs/node_modules/prop-types/index.js +1 -1
  13. package/dist/cjs/node_modules/react-window/dist/react-window.js +608 -0
  14. package/dist/esm/_virtual/index5.js +6 -2
  15. package/dist/esm/_virtual/index6.js +4 -4
  16. package/dist/esm/_virtual/index7.js +2 -6
  17. package/dist/esm/components/ui/pdf-content/hooks/use-page-layout.js +26 -32
  18. package/dist/esm/components/ui/pdf-content/pdf-content.js +126 -35
  19. package/dist/esm/components/ui/pdf-content/pdf-page.js +7 -10
  20. package/dist/esm/components/ui/pdf-viewer/pdf-viewer.js +2 -2
  21. package/dist/esm/node_modules/@ckeditor/ckeditor5-mention/dist/index.js +1 -1
  22. package/dist/esm/node_modules/@ckeditor/ckeditor5-paragraph/dist/index.js +1 -1
  23. package/dist/esm/node_modules/@ckeditor/ckeditor5-ui/dist/index.js +1 -1
  24. package/dist/esm/node_modules/color-parse/index.js +1 -1
  25. package/dist/esm/node_modules/prop-types/index.js +1 -1
  26. package/dist/esm/node_modules/react-window/dist/react-window.js +606 -0
  27. package/dist/styles.css +0 -3
  28. package/dist/types/index.d.ts +23 -20
  29. package/package.json +2 -1
@@ -1,5 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var propTypes = {exports: {}};
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- exports.__module = propTypes;
5
+ var _commonjsHelpers = require('./_commonjsHelpers.js');
6
+ var index = require('../node_modules/color-name/index.js');
7
+
8
+ var colorNameExports = index.__require();
9
+ var names = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(colorNameExports);
10
+
11
+ exports.default = names;
@@ -3,9 +3,9 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _commonjsHelpers = require('./_commonjsHelpers.js');
6
- var index = require('../node_modules/color-name/index.js');
6
+ var index$1 = require('../node_modules/color-convert/index.js');
7
7
 
8
- var colorNameExports = index.__require();
9
- var names = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(colorNameExports);
8
+ var colorConvertExports = index$1.__require();
9
+ var index = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(colorConvertExports);
10
10
 
11
- exports.default = names;
11
+ exports.default = index;
@@ -1,11 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
3
+ var propTypes = {exports: {}};
4
4
 
5
- var _commonjsHelpers = require('./_commonjsHelpers.js');
6
- var index$1 = require('../node_modules/color-convert/index.js');
7
-
8
- var colorConvertExports = index$1.__require();
9
- var index = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(colorConvertExports);
10
-
11
- exports.default = index;
5
+ exports.__module = propTypes;
@@ -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;
@@ -2,8 +2,8 @@
2
2
 
3
3
  require('../../ckeditor5-core/dist/index.js');
4
4
  var index = require('../../ckeditor5-utils/dist/index.js');
5
+ require('../../../../_virtual/index5.js');
5
6
  require('../../../../_virtual/index6.js');
6
- require('../../../../_virtual/index7.js');
7
7
  require('../../ckeditor5-engine/dist/index.js');
8
8
 
9
9
  /**
@@ -2,8 +2,8 @@
2
2
 
3
3
  var index = require('../../ckeditor5-core/dist/index.js');
4
4
  var index$1 = require('../../ckeditor5-utils/dist/index.js');
5
+ require('../../../../_virtual/index5.js');
5
6
  require('../../../../_virtual/index6.js');
6
- require('../../../../_virtual/index7.js');
7
7
  require('../../ckeditor5-engine/dist/index.js');
8
8
 
9
9
  /**
@@ -3,7 +3,7 @@
3
3
  var index$1 = require('../../ckeditor5-utils/dist/index.js');
4
4
  var index = require('../../ckeditor5-core/dist/index.js');
5
5
  var index$3 = require('../../../color-parse/index.js');
6
- var index$2 = require('../../../../_virtual/index7.js');
6
+ var index$2 = require('../../../../_virtual/index6.js');
7
7
  var hex = require('../../../vanilla-colorful/lib/entrypoints/hex.js');
8
8
  require('../../ckeditor5-engine/dist/index.js');
9
9
  var assignIn = require('../../../lodash-es/assignIn.js');
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('../../_virtual/index6.js');
5
+ var index = require('../../_virtual/index5.js');
6
6
 
7
7
  /**
8
8
  * @module color-parse
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index$1 = require('../../_virtual/index5.js');
3
+ var index$1 = require('../../_virtual/index7.js');
4
4
  var index = require('./node_modules/react-is/index.js');
5
5
  var factoryWithTypeCheckers = require('./factoryWithTypeCheckers.js');
6
6
  var factoryWithThrowingShims = require('./factoryWithThrowingShims.js');