@pdf-viewer/react 0.5.0-beta.2 → 0.5.0-beta.4
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/{RPLayout-fab108d3.js → RPLayout-7fd91861.js} +18 -15
- package/dist/components/RPController.js +1 -1
- package/dist/components/RPViewer.js +1 -1
- package/dist/components/layout/RPLayout.js +1 -1
- package/dist/components/layout/sidebar/RPSidebar.js +1 -1
- package/dist/components/layout/sidebar/Thumbnail.js +1 -1
- package/dist/components/layout/sidebar/Thumbnails.js +1 -1
- package/dist/components/layout/toolbar/DocumentDialog.js +1 -1
- package/dist/components/layout/toolbar/FileDownloadTool.js +1 -1
- package/dist/components/layout/toolbar/MenuItem.js +1 -1
- package/dist/components/layout/toolbar/MenuSeparator.js +1 -1
- package/dist/components/layout/toolbar/MostPageTool.js +2 -2
- package/dist/components/layout/toolbar/OtherTool.js +2 -2
- package/dist/components/layout/toolbar/Paginate.js +1 -1
- package/dist/components/layout/toolbar/PrintTool.js +1 -1
- package/dist/components/layout/toolbar/RPToolbar.js +1 -1
- package/dist/components/layout/toolbar/RPToolbarEnd.js +1 -1
- package/dist/components/layout/toolbar/RotateTool.js +1 -1
- package/dist/components/layout/toolbar/ScrollModeTool.js +1 -1
- package/dist/components/layout/toolbar/SearchTool.js +1 -1
- package/dist/components/layout/toolbar/SelectionModeTool.js +1 -1
- package/dist/components/layout/toolbar/ViewModeTool.js +1 -1
- package/dist/components/layout/toolbar/ZoomTool.js +2 -2
- package/dist/components/page/AnnotationLayer.js +1 -1
- package/dist/components/page/CanvasLayer.js +1 -1
- package/dist/components/page/DualPage.js +1 -1
- package/dist/components/page/RPPage.js +1 -1
- package/dist/components/page/SinglePage.js +1 -1
- package/dist/components/page/TextLayer.js +1 -1
- package/dist/components/ui/Checkbox.js +1 -1
- package/dist/components/ui/DropDown.js +1 -1
- package/dist/components/ui/LoadingIndicator.js +1 -1
- package/dist/components/ui/RPTooltip.js +568 -1877
- package/dist/contexts/PaginateContext.js +1 -1
- package/dist/contexts/PrintContext.js +1 -1
- package/dist/contexts/SearchContext.js +1 -1
- package/dist/contexts/ThumbnailsContext.js +1 -1
- package/dist/contexts/ToolbarComponentContext.js +14 -12
- package/dist/floating-ui.react-dom-e6d5fe8f.js +1327 -0
- package/dist/index-316854c1.js +2299 -0
- package/dist/index-71898eb9.js +139 -0
- package/dist/main.js +1 -1
- package/dist/utils/hooks/useFileDownload.js +1 -1
- package/dist/utils/hooks/useLicense.js +24 -16
- package/dist/utils/hooks/usePaginate.js +1 -1
- package/dist/utils/hooks/usePrint.js +1 -1
- package/dist/utils/hooks/useScrollToPage.js +1 -1
- package/dist/utils/hooks/useSearch.js +1 -1
- package/dist/utils/hooks/useThumbnail.js +1 -1
- package/dist/utils/hooks/useVirtualReactWindow.js +1 -1
- package/package.json +1 -1
- package/dist/index-2b077daa.js +0 -122
- package/dist/index-8049287f.js +0 -3639
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import * as i from "react";
|
|
2
|
+
import { jsx as C } from "react/jsx-runtime";
|
|
3
|
+
function m(e, n) {
|
|
4
|
+
const t = i.createContext(n), r = (s) => {
|
|
5
|
+
const { children: o, ...c } = s, a = i.useMemo(() => c, Object.values(c));
|
|
6
|
+
return /* @__PURE__ */ C(t.Provider, { value: a, children: o });
|
|
7
|
+
};
|
|
8
|
+
r.displayName = e + "Provider";
|
|
9
|
+
function u(s) {
|
|
10
|
+
const o = i.useContext(t);
|
|
11
|
+
if (o)
|
|
12
|
+
return o;
|
|
13
|
+
if (n !== void 0)
|
|
14
|
+
return n;
|
|
15
|
+
throw new Error(`\`${s}\` must be used within \`${e}\``);
|
|
16
|
+
}
|
|
17
|
+
return [r, u];
|
|
18
|
+
}
|
|
19
|
+
function E(e, n = []) {
|
|
20
|
+
let t = [];
|
|
21
|
+
function r(s, o) {
|
|
22
|
+
const c = i.createContext(o), a = t.length;
|
|
23
|
+
t = [...t, o];
|
|
24
|
+
const f = (d) => {
|
|
25
|
+
var b;
|
|
26
|
+
const { scope: l, children: S, ...v } = d, h = ((b = l == null ? void 0 : l[e]) == null ? void 0 : b[a]) || c, z = i.useMemo(() => v, Object.values(v));
|
|
27
|
+
return /* @__PURE__ */ C(h.Provider, { value: z, children: S });
|
|
28
|
+
};
|
|
29
|
+
f.displayName = s + "Provider";
|
|
30
|
+
function x(d, l) {
|
|
31
|
+
var h;
|
|
32
|
+
const S = ((h = l == null ? void 0 : l[e]) == null ? void 0 : h[a]) || c, v = i.useContext(S);
|
|
33
|
+
if (v)
|
|
34
|
+
return v;
|
|
35
|
+
if (o !== void 0)
|
|
36
|
+
return o;
|
|
37
|
+
throw new Error(`\`${d}\` must be used within \`${s}\``);
|
|
38
|
+
}
|
|
39
|
+
return [f, x];
|
|
40
|
+
}
|
|
41
|
+
const u = () => {
|
|
42
|
+
const s = t.map((o) => i.createContext(o));
|
|
43
|
+
return function(c) {
|
|
44
|
+
const a = (c == null ? void 0 : c[e]) || s;
|
|
45
|
+
return i.useMemo(
|
|
46
|
+
() => ({ [`__scope${e}`]: { ...c, [e]: a } }),
|
|
47
|
+
[c, a]
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
return u.scopeName = e, [r, P(u, ...n)];
|
|
52
|
+
}
|
|
53
|
+
function P(...e) {
|
|
54
|
+
const n = e[0];
|
|
55
|
+
if (e.length === 1)
|
|
56
|
+
return n;
|
|
57
|
+
const t = () => {
|
|
58
|
+
const r = e.map((u) => ({
|
|
59
|
+
useScope: u(),
|
|
60
|
+
scopeName: u.scopeName
|
|
61
|
+
}));
|
|
62
|
+
return function(s) {
|
|
63
|
+
const o = r.reduce((c, { useScope: a, scopeName: f }) => {
|
|
64
|
+
const d = a(s)[`__scope${f}`];
|
|
65
|
+
return { ...c, ...d };
|
|
66
|
+
}, {});
|
|
67
|
+
return i.useMemo(() => ({ [`__scope${n.scopeName}`]: o }), [o]);
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
return t.scopeName = n.scopeName, t;
|
|
71
|
+
}
|
|
72
|
+
function y(e) {
|
|
73
|
+
const n = i.useRef(e);
|
|
74
|
+
return i.useEffect(() => {
|
|
75
|
+
n.current = e;
|
|
76
|
+
}), i.useMemo(() => (...t) => {
|
|
77
|
+
var r;
|
|
78
|
+
return (r = n.current) == null ? void 0 : r.call(n, ...t);
|
|
79
|
+
}, []);
|
|
80
|
+
}
|
|
81
|
+
var g = globalThis != null && globalThis.document ? i.useLayoutEffect : () => {
|
|
82
|
+
};
|
|
83
|
+
function $(e) {
|
|
84
|
+
const [n, t] = i.useState(void 0);
|
|
85
|
+
return g(() => {
|
|
86
|
+
if (e) {
|
|
87
|
+
t({ width: e.offsetWidth, height: e.offsetHeight });
|
|
88
|
+
const r = new ResizeObserver((u) => {
|
|
89
|
+
if (!Array.isArray(u) || !u.length)
|
|
90
|
+
return;
|
|
91
|
+
const s = u[0];
|
|
92
|
+
let o, c;
|
|
93
|
+
if ("borderBoxSize" in s) {
|
|
94
|
+
const a = s.borderBoxSize, f = Array.isArray(a) ? a[0] : a;
|
|
95
|
+
o = f.inlineSize, c = f.blockSize;
|
|
96
|
+
} else
|
|
97
|
+
o = e.offsetWidth, c = e.offsetHeight;
|
|
98
|
+
t({ width: o, height: c });
|
|
99
|
+
});
|
|
100
|
+
return r.observe(e, { box: "border-box" }), () => r.unobserve(e);
|
|
101
|
+
} else
|
|
102
|
+
t(void 0);
|
|
103
|
+
}, [e]), n;
|
|
104
|
+
}
|
|
105
|
+
function _({
|
|
106
|
+
prop: e,
|
|
107
|
+
defaultProp: n,
|
|
108
|
+
onChange: t = () => {
|
|
109
|
+
}
|
|
110
|
+
}) {
|
|
111
|
+
const [r, u] = p({ defaultProp: n, onChange: t }), s = e !== void 0, o = s ? e : r, c = y(t), a = i.useCallback(
|
|
112
|
+
(f) => {
|
|
113
|
+
if (s) {
|
|
114
|
+
const d = typeof f == "function" ? f(e) : f;
|
|
115
|
+
d !== e && c(d);
|
|
116
|
+
} else
|
|
117
|
+
u(f);
|
|
118
|
+
},
|
|
119
|
+
[s, e, u, c]
|
|
120
|
+
);
|
|
121
|
+
return [o, a];
|
|
122
|
+
}
|
|
123
|
+
function p({
|
|
124
|
+
defaultProp: e,
|
|
125
|
+
onChange: n
|
|
126
|
+
}) {
|
|
127
|
+
const t = i.useState(e), [r] = t, u = i.useRef(r), s = y(n);
|
|
128
|
+
return i.useEffect(() => {
|
|
129
|
+
u.current !== r && (s(r), u.current = r);
|
|
130
|
+
}, [r, u, s]), t;
|
|
131
|
+
}
|
|
132
|
+
export {
|
|
133
|
+
g as a,
|
|
134
|
+
_ as b,
|
|
135
|
+
E as c,
|
|
136
|
+
$ as d,
|
|
137
|
+
m as e,
|
|
138
|
+
y as u
|
|
139
|
+
};
|
package/dist/main.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RPDocument as t } from "./components/RPDocument.js";
|
|
2
|
-
import { a as x, R as n, b as s, u as m, c as p, d as u } from "./RPLayout-
|
|
2
|
+
import { a as x, R as n, b as s, u as m, c as p, d as u } from "./RPLayout-7fd91861.js";
|
|
3
3
|
import { RPConfig as f } from "./components/RPConfig.js";
|
|
4
4
|
import { RPTheme as i } from "./components/RPTheme.js";
|
|
5
5
|
import { RPDropFileZone as R } from "./components/RPDropFileZone.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
2
|
import "../../contexts/RPDocumentContext.js";
|
|
3
|
-
import { b as w } from "../../RPLayout-
|
|
3
|
+
import { b as w } from "../../RPLayout-7fd91861.js";
|
|
4
4
|
import "../../components/RPConfig.js";
|
|
5
5
|
import "../../contexts/ThemeContext.js";
|
|
6
6
|
import "react";
|
|
@@ -1,38 +1,46 @@
|
|
|
1
1
|
import { useState as g, useCallback as h, useEffect as v } from "react";
|
|
2
2
|
import { appConsole as l } from "../appConsole.js";
|
|
3
|
-
const b = /* @__PURE__ */ new Date("2025-02-
|
|
3
|
+
const b = /* @__PURE__ */ new Date("2025-02-13T03:16:05.963Z"), d = "Please visit https://www.react-pdf.dev/license-management/ to generate a new license key.", o = {
|
|
4
4
|
invalidLicense: `You are currently using without a valid license. ${d}`,
|
|
5
5
|
mismatchedDomain: `Your license key is not valid for the current domain / IP. ${d}`,
|
|
6
6
|
expired: `Your license key has expired. ${d}`,
|
|
7
|
-
exceededVersion: "Your license does not support the current version of
|
|
7
|
+
exceededVersion: "Your license does not support the current version of React PDF. The library version you are using exceeds the supported range of your license.",
|
|
8
8
|
invalidSignature: "Invalid license key: Signature mismatch"
|
|
9
9
|
};
|
|
10
10
|
function y(r) {
|
|
11
|
-
const
|
|
11
|
+
const n = r.replace(/-----BEGIN PUBLIC KEY-----/, "").replace(/-----END PUBLIC KEY-----/, "").replace(/\s+/g, ""), t = atob(n), i = new Uint8Array(t.length);
|
|
12
12
|
for (let e = 0; e < t.length; e++)
|
|
13
|
-
|
|
14
|
-
return
|
|
13
|
+
i[e] = t.charCodeAt(e);
|
|
14
|
+
return i.buffer;
|
|
15
15
|
}
|
|
16
16
|
function A(r) {
|
|
17
|
-
const
|
|
18
|
-
for (let
|
|
19
|
-
t[
|
|
17
|
+
const n = atob(r), t = new Uint8Array(n.length);
|
|
18
|
+
for (let i = 0; i < n.length; i++)
|
|
19
|
+
t[i] = n.charCodeAt(i);
|
|
20
20
|
return t.buffer;
|
|
21
21
|
}
|
|
22
|
-
async function I(r,
|
|
22
|
+
async function I(r, n = "SHA-256") {
|
|
23
23
|
try {
|
|
24
|
-
const { data: t, signature:
|
|
24
|
+
const { data: t, signature: i } = JSON.parse(atob(r)), e = y(`-----BEGIN PUBLIC KEY-----
|
|
25
|
+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyrIi83Zr5AKaWO6zbZmX
|
|
26
|
+
qv3McVhtnPOnWCiFgf5xeaglLzEwMiXo3gALaPoBp5Q0WPOSBE9GTqwOyQUgpDNS
|
|
27
|
+
BuQ0cjOzQdFM3GPnKSqQThZJfjUmD9egMZDmfhcpFGPybUoicoIEFQOdX2vMFUfn
|
|
28
|
+
6yjRsyvbK6UPTombYl785V8dXNnnIHa4tQC1JSaSe/bhG3e/6kbQCy9VJ23242q9
|
|
29
|
+
WJpx9c2sZ+bmyI0r9Zx0PfqcDJzDfKn45v96EtxGhV16OZhqkbj4ljiJ/mfqfCkx
|
|
30
|
+
ybkm9nvxz0hAwcEftQaxl/0cZ1RxtsRcL+V3msLsmGcs9nPqAuXecbfg9QVCi/+m
|
|
31
|
+
iwIDAQAB
|
|
32
|
+
-----END PUBLIC KEY-----`), a = await window.crypto.subtle.importKey(
|
|
25
33
|
"spki",
|
|
26
34
|
// str2ab(publicKeyContent), // Convert PEM string to ArrayBuffer
|
|
27
35
|
e,
|
|
28
|
-
{ name: "RSA-PSS", hash:
|
|
36
|
+
{ name: "RSA-PSS", hash: n },
|
|
29
37
|
!0,
|
|
30
38
|
["verify"]
|
|
31
39
|
);
|
|
32
40
|
if (!await window.crypto.subtle.verify(
|
|
33
41
|
{ name: "RSA-PSS", saltLength: 32 },
|
|
34
42
|
a,
|
|
35
|
-
A(
|
|
43
|
+
A(i),
|
|
36
44
|
// Convert signature to ArrayBuffer
|
|
37
45
|
new TextEncoder().encode(atob(t))
|
|
38
46
|
))
|
|
@@ -42,12 +50,12 @@ async function I(r, i = "SHA-256") {
|
|
|
42
50
|
throw new Error(o.invalidLicense);
|
|
43
51
|
}
|
|
44
52
|
}
|
|
45
|
-
const L = (r,
|
|
53
|
+
const L = (r, n) => r === "specific" ? n === window.location.host : window.location.host.includes(n), c = {
|
|
46
54
|
isValid: !1,
|
|
47
55
|
invalidatedMessage: o.invalidLicense,
|
|
48
56
|
type: void 0
|
|
49
57
|
}, T = (r) => {
|
|
50
|
-
const [
|
|
58
|
+
const [n, t] = g(c), i = h(async () => {
|
|
51
59
|
if (!r)
|
|
52
60
|
return t(c), c;
|
|
53
61
|
try {
|
|
@@ -80,14 +88,14 @@ const L = (r, i) => r === "specific" ? i === window.location.host : window.locat
|
|
|
80
88
|
}
|
|
81
89
|
}, [r]);
|
|
82
90
|
return v(() => {
|
|
83
|
-
|
|
91
|
+
i().then(({ isValid: e, type: a, invalidatedMessage: s }) => {
|
|
84
92
|
t({
|
|
85
93
|
isValid: e,
|
|
86
94
|
type: a,
|
|
87
95
|
invalidatedMessage: s
|
|
88
96
|
});
|
|
89
97
|
});
|
|
90
|
-
}, [
|
|
98
|
+
}, [i]), n;
|
|
91
99
|
};
|
|
92
100
|
export {
|
|
93
101
|
T as useLicense
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "react";
|
|
2
2
|
import "react/jsx-runtime";
|
|
3
3
|
import "../../contexts/RPDocumentContext.js";
|
|
4
|
-
import { o as d } from "../../RPLayout-
|
|
4
|
+
import { o as d } from "../../RPLayout-7fd91861.js";
|
|
5
5
|
import "../../components/RPConfig.js";
|
|
6
6
|
import "../../contexts/ThemeContext.js";
|
|
7
7
|
import "../../components/RPDropFileZone.js";
|
|
@@ -2,7 +2,7 @@ import "react";
|
|
|
2
2
|
import "../../contexts/ScrollModeContext.js";
|
|
3
3
|
import "react/jsx-runtime";
|
|
4
4
|
import "../../contexts/RPDocumentContext.js";
|
|
5
|
-
import { e as h } from "../../RPLayout-
|
|
5
|
+
import { e as h } from "../../RPLayout-7fd91861.js";
|
|
6
6
|
import "../../components/RPConfig.js";
|
|
7
7
|
import "../../contexts/ThemeContext.js";
|
|
8
8
|
import "../../components/RPDropFileZone.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "react";
|
|
2
2
|
import "react/jsx-runtime";
|
|
3
3
|
import "../../contexts/RPDocumentContext.js";
|
|
4
|
-
import { f as j } from "../../RPLayout-
|
|
4
|
+
import { f as j } from "../../RPLayout-7fd91861.js";
|
|
5
5
|
import "../../components/RPConfig.js";
|
|
6
6
|
import "../../contexts/ThemeContext.js";
|
|
7
7
|
import "../../components/RPDropFileZone.js";
|
|
@@ -2,7 +2,7 @@ import "react";
|
|
|
2
2
|
import "../renderPage.js";
|
|
3
3
|
import "react/jsx-runtime";
|
|
4
4
|
import "../../contexts/RPDocumentContext.js";
|
|
5
|
-
import { x as c } from "../../RPLayout-
|
|
5
|
+
import { x as c } from "../../RPLayout-7fd91861.js";
|
|
6
6
|
import "../../components/RPConfig.js";
|
|
7
7
|
import "../../contexts/ThemeContext.js";
|
|
8
8
|
import "../../components/RPDropFileZone.js";
|
|
@@ -3,7 +3,7 @@ import "../types.js";
|
|
|
3
3
|
import "../../contexts/ScrollModeContext.js";
|
|
4
4
|
import "react/jsx-runtime";
|
|
5
5
|
import "../../contexts/RPDocumentContext.js";
|
|
6
|
-
import { i as b } from "../../RPLayout-
|
|
6
|
+
import { i as b } from "../../RPLayout-7fd91861.js";
|
|
7
7
|
import "../../components/RPConfig.js";
|
|
8
8
|
import "../../contexts/ThemeContext.js";
|
|
9
9
|
import "../../components/RPDropFileZone.js";
|
package/package.json
CHANGED
package/dist/index-2b077daa.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import * as i from "react";
|
|
2
|
-
import { jsx as y } from "react/jsx-runtime";
|
|
3
|
-
function w(e, s = []) {
|
|
4
|
-
let t = [];
|
|
5
|
-
function o(c, u) {
|
|
6
|
-
const r = i.createContext(u), f = t.length;
|
|
7
|
-
t = [...t, u];
|
|
8
|
-
const a = (d) => {
|
|
9
|
-
var x;
|
|
10
|
-
const { scope: l, children: v, ...S } = d, h = ((x = l == null ? void 0 : l[e]) == null ? void 0 : x[f]) || r, z = i.useMemo(() => S, Object.values(S));
|
|
11
|
-
return /* @__PURE__ */ y(h.Provider, { value: z, children: v });
|
|
12
|
-
};
|
|
13
|
-
a.displayName = c + "Provider";
|
|
14
|
-
function b(d, l) {
|
|
15
|
-
var h;
|
|
16
|
-
const v = ((h = l == null ? void 0 : l[e]) == null ? void 0 : h[f]) || r, S = i.useContext(v);
|
|
17
|
-
if (S)
|
|
18
|
-
return S;
|
|
19
|
-
if (u !== void 0)
|
|
20
|
-
return u;
|
|
21
|
-
throw new Error(`\`${d}\` must be used within \`${c}\``);
|
|
22
|
-
}
|
|
23
|
-
return [a, b];
|
|
24
|
-
}
|
|
25
|
-
const n = () => {
|
|
26
|
-
const c = t.map((u) => i.createContext(u));
|
|
27
|
-
return function(r) {
|
|
28
|
-
const f = (r == null ? void 0 : r[e]) || c;
|
|
29
|
-
return i.useMemo(
|
|
30
|
-
() => ({ [`__scope${e}`]: { ...r, [e]: f } }),
|
|
31
|
-
[r, f]
|
|
32
|
-
);
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
return n.scopeName = e, [o, g(n, ...s)];
|
|
36
|
-
}
|
|
37
|
-
function g(...e) {
|
|
38
|
-
const s = e[0];
|
|
39
|
-
if (e.length === 1)
|
|
40
|
-
return s;
|
|
41
|
-
const t = () => {
|
|
42
|
-
const o = e.map((n) => ({
|
|
43
|
-
useScope: n(),
|
|
44
|
-
scopeName: n.scopeName
|
|
45
|
-
}));
|
|
46
|
-
return function(c) {
|
|
47
|
-
const u = o.reduce((r, { useScope: f, scopeName: a }) => {
|
|
48
|
-
const d = f(c)[`__scope${a}`];
|
|
49
|
-
return { ...r, ...d };
|
|
50
|
-
}, {});
|
|
51
|
-
return i.useMemo(() => ({ [`__scope${s.scopeName}`]: u }), [u]);
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
return t.scopeName = s.scopeName, t;
|
|
55
|
-
}
|
|
56
|
-
function C(e) {
|
|
57
|
-
const s = i.useRef(e);
|
|
58
|
-
return i.useEffect(() => {
|
|
59
|
-
s.current = e;
|
|
60
|
-
}), i.useMemo(() => (...t) => {
|
|
61
|
-
var o;
|
|
62
|
-
return (o = s.current) == null ? void 0 : o.call(s, ...t);
|
|
63
|
-
}, []);
|
|
64
|
-
}
|
|
65
|
-
var p = globalThis != null && globalThis.document ? i.useLayoutEffect : () => {
|
|
66
|
-
};
|
|
67
|
-
function E(e) {
|
|
68
|
-
const [s, t] = i.useState(void 0);
|
|
69
|
-
return p(() => {
|
|
70
|
-
if (e) {
|
|
71
|
-
t({ width: e.offsetWidth, height: e.offsetHeight });
|
|
72
|
-
const o = new ResizeObserver((n) => {
|
|
73
|
-
if (!Array.isArray(n) || !n.length)
|
|
74
|
-
return;
|
|
75
|
-
const c = n[0];
|
|
76
|
-
let u, r;
|
|
77
|
-
if ("borderBoxSize" in c) {
|
|
78
|
-
const f = c.borderBoxSize, a = Array.isArray(f) ? f[0] : f;
|
|
79
|
-
u = a.inlineSize, r = a.blockSize;
|
|
80
|
-
} else
|
|
81
|
-
u = e.offsetWidth, r = e.offsetHeight;
|
|
82
|
-
t({ width: u, height: r });
|
|
83
|
-
});
|
|
84
|
-
return o.observe(e, { box: "border-box" }), () => o.unobserve(e);
|
|
85
|
-
} else
|
|
86
|
-
t(void 0);
|
|
87
|
-
}, [e]), s;
|
|
88
|
-
}
|
|
89
|
-
function _({
|
|
90
|
-
prop: e,
|
|
91
|
-
defaultProp: s,
|
|
92
|
-
onChange: t = () => {
|
|
93
|
-
}
|
|
94
|
-
}) {
|
|
95
|
-
const [o, n] = m({ defaultProp: s, onChange: t }), c = e !== void 0, u = c ? e : o, r = C(t), f = i.useCallback(
|
|
96
|
-
(a) => {
|
|
97
|
-
if (c) {
|
|
98
|
-
const d = typeof a == "function" ? a(e) : a;
|
|
99
|
-
d !== e && r(d);
|
|
100
|
-
} else
|
|
101
|
-
n(a);
|
|
102
|
-
},
|
|
103
|
-
[c, e, n, r]
|
|
104
|
-
);
|
|
105
|
-
return [u, f];
|
|
106
|
-
}
|
|
107
|
-
function m({
|
|
108
|
-
defaultProp: e,
|
|
109
|
-
onChange: s
|
|
110
|
-
}) {
|
|
111
|
-
const t = i.useState(e), [o] = t, n = i.useRef(o), c = C(s);
|
|
112
|
-
return i.useEffect(() => {
|
|
113
|
-
n.current !== o && (c(o), n.current = o);
|
|
114
|
-
}, [o, n, c]), t;
|
|
115
|
-
}
|
|
116
|
-
export {
|
|
117
|
-
_ as a,
|
|
118
|
-
E as b,
|
|
119
|
-
w as c,
|
|
120
|
-
C as d,
|
|
121
|
-
p as u
|
|
122
|
-
};
|