@pdfslick/react 2.1.4-next.0 → 2.3.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.
- package/dist/esm/index.js +20 -6
- package/dist/umd/index.js +3 -3
- package/package.json +8 -9
package/dist/esm/index.js
CHANGED
|
@@ -1,11 +1,25 @@
|
|
|
1
|
-
import { useState, useMemo, useCallback, useEffect } from 'react';
|
|
2
|
-
import
|
|
1
|
+
import React, { useState, useMemo, useCallback, useEffect } from 'react';
|
|
2
|
+
import useSyncExternalStoreExports from 'use-sync-external-store/shim/with-selector.js';
|
|
3
3
|
import { create, PDFSlick } from '@pdfslick/core';
|
|
4
4
|
export * from '@pdfslick/core';
|
|
5
5
|
import { jsx } from 'react/jsx-runtime';
|
|
6
6
|
import { useMeasure, useDebounce } from 'react-use';
|
|
7
7
|
import { createPortal } from 'react-dom';
|
|
8
8
|
|
|
9
|
+
const { useSyncExternalStoreWithSelector } = useSyncExternalStoreExports;
|
|
10
|
+
const identity = (arg) => arg;
|
|
11
|
+
function useStoreWithEqualityFn(api, selector = identity, equalityFn) {
|
|
12
|
+
const slice = useSyncExternalStoreWithSelector(
|
|
13
|
+
api.subscribe,
|
|
14
|
+
api.getState,
|
|
15
|
+
api.getInitialState,
|
|
16
|
+
selector,
|
|
17
|
+
equalityFn
|
|
18
|
+
);
|
|
19
|
+
React.useDebugValue(slice);
|
|
20
|
+
return slice;
|
|
21
|
+
}
|
|
22
|
+
|
|
9
23
|
function PDFSlickViewer({ usePDFSlickStore, viewerRef, className, }) {
|
|
10
24
|
const pdfSlick = usePDFSlickStore((s) => s.pdfSlick);
|
|
11
25
|
const scaleValue = usePDFSlickStore((s) => s.scaleValue);
|
|
@@ -18,13 +32,13 @@ function PDFSlickViewer({ usePDFSlickStore, viewerRef, className, }) {
|
|
|
18
32
|
scaleValue === "page-width")) {
|
|
19
33
|
pdfSlick.viewer.currentScaleValue = scaleValue;
|
|
20
34
|
}
|
|
21
|
-
pdfSlick === null || pdfSlick ===
|
|
35
|
+
pdfSlick === null || pdfSlick === void 0 ? void 0 : pdfSlick.viewer.update();
|
|
22
36
|
}
|
|
23
37
|
}, 0, [width]);
|
|
24
38
|
return (jsx("div", { ref: (el) => {
|
|
25
39
|
viewerRef(el);
|
|
26
40
|
resizeRef(el);
|
|
27
|
-
}, id: "viewerContainer", className: `pdfSlickContainer ${className !== null && className !==
|
|
41
|
+
}, id: "viewerContainer", className: `pdfSlickContainer ${className !== null && className !== void 0 ? className : ""}`, style: {
|
|
28
42
|
position: "absolute",
|
|
29
43
|
inset: 0,
|
|
30
44
|
overflow: "auto"
|
|
@@ -37,7 +51,7 @@ function PDFSlickThumbnails({ children: renderChild, thumbsRef, usePDFSlickStore
|
|
|
37
51
|
const [resizeRef, { width }] = useMeasure();
|
|
38
52
|
useDebounce(() => {
|
|
39
53
|
if (width) {
|
|
40
|
-
pdfSlick === null || pdfSlick ===
|
|
54
|
+
pdfSlick === null || pdfSlick === void 0 ? void 0 : pdfSlick.forceRendering();
|
|
41
55
|
}
|
|
42
56
|
}, 0, [width]);
|
|
43
57
|
return (jsx("div", { ref: (el) => {
|
|
@@ -54,7 +68,7 @@ function PDFSlickThumbnails({ children: renderChild, thumbsRef, usePDFSlickStore
|
|
|
54
68
|
width: view.canvasWidth,
|
|
55
69
|
height: view.canvasHeight,
|
|
56
70
|
scale: view.scale,
|
|
57
|
-
src: (_a = view === null || view ===
|
|
71
|
+
src: (_a = view === null || view === void 0 ? void 0 : view.src) !== null && _a !== void 0 ? _a : null,
|
|
58
72
|
rotation: view.rotation,
|
|
59
73
|
pageLabel: view.pageLabel,
|
|
60
74
|
loaded: view.loaded,
|