@pdf-viewer/react 1.5.1 → 1.6.0-beta.10
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/RPDefaultLayout-4518b3d3.js +3059 -0
- package/dist/SearchCloseButton-959cc1ed.js +32 -0
- package/dist/assets/Container.css +1 -1
- package/dist/assets/PasswordModal.css +1 -0
- package/dist/assets/RPDefaultLayout.css +1 -1
- package/dist/assets/SearchCloseButton.css +1 -0
- package/dist/components/RPController.js +1 -1
- package/dist/components/RPPages.js +4 -2
- package/dist/components/RPProvider.js +13 -12
- package/dist/components/layout/Container.js +7 -6
- package/dist/components/layout/LayoutContainer.js +3 -2
- package/dist/components/layout/RPDefaultLayout.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 +3 -2
- 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 +4 -3
- 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/SearchCloseButton.js +9 -0
- package/dist/components/layout/toolbar/SearchResultNavigator.js +10 -0
- package/dist/components/layout/toolbar/SearchTool.js +5 -4
- package/dist/components/layout/toolbar/SelectionModeTool.js +1 -1
- package/dist/components/layout/toolbar/ViewModeTool.js +18 -19
- package/dist/components/layout/toolbar/ZoomTool.js +8 -27
- package/dist/components/page/AnnotationLayer.js +3 -2
- package/dist/components/page/CanvasLayer.js +3 -2
- package/dist/components/page/DualPage.js +1 -1
- package/dist/components/page/RPPage.js +3 -2
- package/dist/components/page/SinglePage.js +1 -1
- package/dist/components/page/TextHighlightLayer.js +3 -2
- package/dist/components/page/TextLayer.js +3 -2
- package/dist/components/ui/Checkbox.js +14 -13
- package/dist/components/ui/DropDown.js +1 -1
- package/dist/components/ui/LoadingIndicator.js +1 -1
- package/dist/components/ui/PasswordModal.js +58 -0
- package/dist/components/ui/RPTooltip.js +689 -331
- package/dist/contexts/DocumentPasswordContext.js +40 -0
- package/dist/contexts/PaginationContext.js +1 -1
- package/dist/contexts/PrintContext.js +1 -1
- package/dist/contexts/RPDocumentContext.js +11 -8
- package/dist/contexts/SearchContext.js +1 -1
- package/dist/contexts/SmoothScrollContext.js +8 -9
- package/dist/contexts/ThumbnailsContext.js +1 -1
- package/dist/contexts/ToolbarComponentContext.js +2 -2
- package/dist/contexts/ViewModeContext.js +16 -17
- package/dist/contexts/ZoomContext.js +17 -16
- package/dist/index-2e540713.js +23 -0
- package/dist/index-353ec0a6.js +172 -0
- package/dist/index-5ff5dbd0.js +1675 -0
- package/dist/index-71898eb9.js +139 -0
- package/dist/main.js +1 -1
- package/dist/types/components/layout/toolbar/SearchCloseButton.d.ts +7 -0
- package/dist/types/components/layout/toolbar/SearchResultNavigator.d.ts +1 -0
- package/dist/types/components/layout/toolbar/ViewModeTool.d.ts +1 -1
- package/dist/types/components/ui/PasswordModal.d.ts +3 -0
- package/dist/types/contexts/DocumentPasswordContext.d.ts +14 -0
- package/dist/types/contexts/SmoothScrollContext.d.ts +1 -3
- package/dist/types/utils/constants.d.ts +1 -0
- package/dist/types/utils/getScrollDistance.d.ts +1 -0
- package/dist/types/utils/getWordPositionInPage.d.ts +11 -0
- package/dist/types/utils/getZoomLevel.d.ts +2 -2
- package/dist/types/utils/hooks/useLoadPdf.d.ts +2 -0
- package/dist/types/utils/types.d.ts +20 -3
- package/dist/utils/constants.js +3 -2
- package/dist/utils/getScrollDistance.js +4 -0
- package/dist/utils/getWordPositionInPage.js +19 -0
- package/dist/utils/getZoomLevel.js +13 -9
- package/dist/utils/highlight.js +141 -126
- package/dist/utils/hooks/useFileDownload.js +3 -2
- package/dist/utils/hooks/useLicense.js +1 -1
- package/dist/utils/hooks/useLoadPdf.js +52 -40
- package/dist/utils/hooks/usePaginate.js +4 -2
- package/dist/utils/hooks/usePinch.js +68 -17
- package/dist/utils/hooks/usePresentPage.js +3 -2
- package/dist/utils/hooks/usePrint.js +3 -2
- package/dist/utils/hooks/useScrollToPage.js +4 -2
- package/dist/utils/hooks/useSearch.js +5 -3
- package/dist/utils/hooks/useThumbnail.js +3 -2
- package/dist/utils/hooks/useVirtualReactWindow.js +3 -2
- package/dist/utils/types.js +4 -4
- package/package.json +1 -1
- package/dist/RPDefaultLayout-ed089918.js +0 -2958
- package/dist/index-1cb41342.js +0 -307
- package/dist/index-7279fb4e.js +0 -1557
- package/dist/index-aa2d3884.js +0 -140
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx as P } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as l, useState as r, useEffect as p, useMemo as m, useContext as f } from "react";
|
|
3
|
+
import { appConsole as v } from "../utils/appConsole.js";
|
|
4
|
+
const a = l({
|
|
5
|
+
password: void 0,
|
|
6
|
+
setPassword: () => {
|
|
7
|
+
},
|
|
8
|
+
passwordError: void 0,
|
|
9
|
+
setPasswordError: () => {
|
|
10
|
+
},
|
|
11
|
+
passwordRequired: void 0,
|
|
12
|
+
setPasswordRequired: () => {
|
|
13
|
+
},
|
|
14
|
+
invalidPassword: !1
|
|
15
|
+
}), q = ({
|
|
16
|
+
children: s
|
|
17
|
+
}) => {
|
|
18
|
+
const [e, n] = r(), [o, i] = r(), [t, c] = r(!1), [d, w] = r(!1);
|
|
19
|
+
p(() => {
|
|
20
|
+
w(o === "Incorrect Password");
|
|
21
|
+
}, [o]);
|
|
22
|
+
const u = m(() => ({
|
|
23
|
+
password: e,
|
|
24
|
+
setPassword: n,
|
|
25
|
+
passwordError: o,
|
|
26
|
+
setPasswordError: i,
|
|
27
|
+
passwordRequired: t,
|
|
28
|
+
setPasswordRequired: c,
|
|
29
|
+
invalidPassword: d
|
|
30
|
+
}), [e, o, t, d]);
|
|
31
|
+
return /* @__PURE__ */ P(a.Provider, { value: u, children: s });
|
|
32
|
+
}, D = () => {
|
|
33
|
+
const s = f(a);
|
|
34
|
+
return s || v.error("Please use this hooks inside children component of DocumentPasswordContext"), s;
|
|
35
|
+
};
|
|
36
|
+
export {
|
|
37
|
+
q as DocumentPasswordProvider,
|
|
38
|
+
a as default,
|
|
39
|
+
D as useDocumentPasswordContext
|
|
40
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
|
-
import { h as e, P as m, u as p } from "../RPDefaultLayout-
|
|
3
|
+
import { h as e, P as m, u as p } from "../RPDefaultLayout-4518b3d3.js";
|
|
4
4
|
import "./RPDocumentContext.js";
|
|
5
5
|
import "../utils/appConsole.js";
|
|
6
6
|
export {
|
|
@@ -19,21 +19,24 @@ const m = C({
|
|
|
19
19
|
onLoadError: c,
|
|
20
20
|
onLoaded: P
|
|
21
21
|
}) => {
|
|
22
|
-
const [o, n] = l(e), { pdf: r, pages:
|
|
22
|
+
const [o, n] = l(e), [s, i] = l(), { pdf: r, pages: p, loading: d, loadingProgress: f } = D(o, u, {
|
|
23
|
+
onLoadError: c,
|
|
24
|
+
onLoaded: P
|
|
25
|
+
}), a = F(o, r, s);
|
|
23
26
|
h(() => {
|
|
24
|
-
|
|
27
|
+
i(e == null ? void 0 : e.split("/").pop()), n(e);
|
|
25
28
|
}, [e]);
|
|
26
29
|
const g = S(() => ({
|
|
27
30
|
pdf: r,
|
|
28
|
-
pages:
|
|
31
|
+
pages: p,
|
|
29
32
|
pdfSrc: o,
|
|
30
33
|
setPdfSrc: n,
|
|
31
34
|
pdfProperties: a,
|
|
32
|
-
setFilename:
|
|
33
|
-
filename:
|
|
34
|
-
loading:
|
|
35
|
-
loaderProgress:
|
|
36
|
-
}), [r,
|
|
35
|
+
setFilename: i,
|
|
36
|
+
filename: s,
|
|
37
|
+
loading: d,
|
|
38
|
+
loaderProgress: f
|
|
39
|
+
}), [r, p, o, a, d, f]);
|
|
37
40
|
return /* @__PURE__ */ x(m.Provider, { value: g, children: o ? t : null });
|
|
38
41
|
}, b = () => {
|
|
39
42
|
const t = v(m);
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as c, useRef as
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}, u = () => s(t);
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as c, useRef as l, useContext as n } from "react";
|
|
3
|
+
const o = c({
|
|
4
|
+
targetScrollPage: { current: void 0 }
|
|
5
|
+
}), m = ({ children: t }) => {
|
|
6
|
+
const r = l();
|
|
7
|
+
return /* @__PURE__ */ e(o.Provider, { value: { targetScrollPage: r }, children: t });
|
|
8
|
+
}, u = () => n(o);
|
|
10
9
|
export {
|
|
11
10
|
m as SmoothScrollProvider,
|
|
12
11
|
u as useSmoothScrollContext
|
|
@@ -8,7 +8,7 @@ const e = l({
|
|
|
8
8
|
openFileTool: !0,
|
|
9
9
|
dropFileZone: !0,
|
|
10
10
|
downloadTool: !0,
|
|
11
|
-
viewModeTool:
|
|
11
|
+
// viewModeTool: true,
|
|
12
12
|
scrollModeTool: !0,
|
|
13
13
|
printTool: !0,
|
|
14
14
|
showPrintProgress: !0,
|
|
@@ -23,7 +23,7 @@ const e = l({
|
|
|
23
23
|
openFileTool: !0,
|
|
24
24
|
dropFileZone: !0,
|
|
25
25
|
downloadTool: !0,
|
|
26
|
-
viewModeTool:
|
|
26
|
+
// viewModeTool: true,
|
|
27
27
|
scrollModeTool: !0,
|
|
28
28
|
printTool: !0,
|
|
29
29
|
thumbnailTool: !0,
|
|
@@ -1,28 +1,27 @@
|
|
|
1
1
|
import { jsx as l } from "react/jsx-runtime";
|
|
2
|
-
import { createContext as m, useContext as
|
|
3
|
-
import { appConsole as
|
|
4
|
-
import { ViewMode as
|
|
5
|
-
|
|
6
|
-
const r = m({
|
|
2
|
+
import { createContext as m, useContext as a, useState as d, useCallback as r, useMemo as P } from "react";
|
|
3
|
+
import { appConsole as C } from "../utils/appConsole.js";
|
|
4
|
+
import { ViewMode as t } from "../utils/types.js";
|
|
5
|
+
const s = m({
|
|
7
6
|
columnCount: 1,
|
|
8
7
|
setSinglePage: () => {
|
|
9
8
|
},
|
|
10
9
|
setDualPage: () => {
|
|
11
10
|
},
|
|
12
|
-
viewMode:
|
|
13
|
-
}),
|
|
14
|
-
const
|
|
15
|
-
return typeof
|
|
16
|
-
},
|
|
17
|
-
const
|
|
11
|
+
viewMode: t.SINGLE_PAGE
|
|
12
|
+
}), g = () => {
|
|
13
|
+
const e = a(s);
|
|
14
|
+
return typeof e.columnCount > "u" && C.error("Please use this hooks inside children component of RPProvider"), e;
|
|
15
|
+
}, v = ({ children: e }) => {
|
|
16
|
+
const [o, n] = d(1), i = r(() => {
|
|
18
17
|
n(1);
|
|
19
|
-
}, []),
|
|
18
|
+
}, []), u = r(() => {
|
|
20
19
|
n(2);
|
|
21
|
-
}, []),
|
|
22
|
-
return /* @__PURE__ */ l(
|
|
20
|
+
}, []), c = P(() => o === 1 ? t.SINGLE_PAGE : t.DUAL_PAGE, [o]);
|
|
21
|
+
return /* @__PURE__ */ l(s.Provider, { value: { columnCount: o, setSinglePage: i, setDualPage: u, viewMode: c }, children: e });
|
|
23
22
|
};
|
|
24
23
|
export {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
s as ViewModeContext,
|
|
25
|
+
v as ViewModeProvider,
|
|
26
|
+
g as useViewModeContext
|
|
28
27
|
};
|
|
@@ -1,46 +1,47 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { ZoomLevel as
|
|
1
|
+
import { jsx as C } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as P, useContext as L, useState as y, useMemo as s, useEffect as S } from "react";
|
|
3
|
+
import { ZoomLevel as V } from "../utils/types.js";
|
|
4
4
|
import { appConsole as b } from "../utils/appConsole.js";
|
|
5
5
|
import { useInitialStateContext as A } from "./InitialStateContext.js";
|
|
6
6
|
import { useDocumentContext as D } from "./RPDocumentContext.js";
|
|
7
7
|
import { PAGE_PADDING as f } from "../utils/constants.js";
|
|
8
8
|
import { getZoomLevel as E } from "../utils/getZoomLevel.js";
|
|
9
9
|
import { useLayoutContainer as G } from "./LayoutContainerContext.js";
|
|
10
|
-
|
|
10
|
+
import { useViewModeContext as H } from "./ViewModeContext.js";
|
|
11
|
+
const g = P({
|
|
11
12
|
zoomLevel: 100,
|
|
12
13
|
currentZoom: 1,
|
|
13
14
|
setZoomLevel: () => {
|
|
14
15
|
}
|
|
15
|
-
}),
|
|
16
|
-
const n =
|
|
16
|
+
}), T = () => {
|
|
17
|
+
const n = L(g);
|
|
17
18
|
return typeof n.currentZoom != "number" && b.warn("Please use this hooks inside children component of RPProvider"), n;
|
|
18
|
-
},
|
|
19
|
+
}, q = ({ children: n }) => {
|
|
19
20
|
const {
|
|
20
|
-
initialScale: r =
|
|
21
|
+
initialScale: r = V.PAGE_FIT,
|
|
21
22
|
initialPage: u = 1,
|
|
22
23
|
initialRotation: l = 0
|
|
23
|
-
} = A(), [i, a] =
|
|
24
|
+
} = A(), [i, a] = y(typeof r == "number" ? r : 100), { pages: c } = D(), { contentRef: o } = G(), { viewMode: h } = H(), p = s(() => i / 100, [i]), t = s(() => {
|
|
24
25
|
let e = c.get(u);
|
|
25
26
|
return e || (e = c.get(1)), e == null ? void 0 : e.page.getViewport({ scale: 1, rotation: l });
|
|
26
27
|
}, [c, u, l]), m = s(() => {
|
|
27
28
|
if (!t)
|
|
28
29
|
return 0;
|
|
29
|
-
const e = ((t == null ? void 0 : t.width) || 0) + 2 * f, x = ((t == null ? void 0 : t.height) || 0) + 2 * f, Z = (o == null ? void 0 : o.clientWidth) || 0,
|
|
30
|
-
return E(r, Z,
|
|
30
|
+
const e = ((t == null ? void 0 : t.width) || 0) + 2 * f, x = ((t == null ? void 0 : t.height) || 0) + 2 * f, Z = (o == null ? void 0 : o.clientWidth) || 0, v = (o == null ? void 0 : o.clientHeight) || 0;
|
|
31
|
+
return E(r, Z, v, e, x, h);
|
|
31
32
|
}, [t, r, o]);
|
|
32
|
-
|
|
33
|
+
S(() => {
|
|
33
34
|
typeof m == "number" && m && a(m);
|
|
34
35
|
}, [m]);
|
|
35
|
-
const
|
|
36
|
+
const d = s(() => ({
|
|
36
37
|
zoomLevel: i,
|
|
37
38
|
currentZoom: p,
|
|
38
39
|
setZoomLevel: a
|
|
39
40
|
}), [p, i]);
|
|
40
|
-
return /* @__PURE__ */
|
|
41
|
+
return /* @__PURE__ */ C(g.Provider, { value: d, children: n });
|
|
41
42
|
};
|
|
42
43
|
export {
|
|
43
44
|
g as ZoomContext,
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
q as ZoomProvider,
|
|
46
|
+
T as useZoomContext
|
|
46
47
|
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as o from "react";
|
|
2
|
+
import { u as n, a as r } from "./index-71898eb9.js";
|
|
3
|
+
function i(a, e = globalThis == null ? void 0 : globalThis.document) {
|
|
4
|
+
const t = n(a);
|
|
5
|
+
o.useEffect(() => {
|
|
6
|
+
const s = (u) => {
|
|
7
|
+
u.key === "Escape" && t(u);
|
|
8
|
+
};
|
|
9
|
+
return e.addEventListener("keydown", s, { capture: !0 }), () => e.removeEventListener("keydown", s, { capture: !0 });
|
|
10
|
+
}, [t, e]);
|
|
11
|
+
}
|
|
12
|
+
var c = o["useId".toString()] || (() => {
|
|
13
|
+
}), f = 0;
|
|
14
|
+
function p(a) {
|
|
15
|
+
const [e, t] = o.useState(c());
|
|
16
|
+
return r(() => {
|
|
17
|
+
a || t((s) => s ?? String(f++));
|
|
18
|
+
}, [a]), a || (e ? `radix-${e}` : "");
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
p as a,
|
|
22
|
+
i as u
|
|
23
|
+
};
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import * as s from "react";
|
|
2
|
+
import * as C from "react-dom";
|
|
3
|
+
import { jsx as h, Fragment as M } from "react/jsx-runtime";
|
|
4
|
+
import { a as g } from "./index-71898eb9.js";
|
|
5
|
+
function x(e, n, { checkForDefaultPrevented: t = !0 } = {}) {
|
|
6
|
+
return function(r) {
|
|
7
|
+
if (e == null || e(r), t === !1 || !r.defaultPrevented)
|
|
8
|
+
return n == null ? void 0 : n(r);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function A(e, n) {
|
|
12
|
+
if (typeof e == "function")
|
|
13
|
+
return e(n);
|
|
14
|
+
e != null && (e.current = n);
|
|
15
|
+
}
|
|
16
|
+
function R(...e) {
|
|
17
|
+
return (n) => {
|
|
18
|
+
let t = !1;
|
|
19
|
+
const i = e.map((r) => {
|
|
20
|
+
const o = A(r, n);
|
|
21
|
+
return !t && typeof o == "function" && (t = !0), o;
|
|
22
|
+
});
|
|
23
|
+
if (t)
|
|
24
|
+
return () => {
|
|
25
|
+
for (let r = 0; r < i.length; r++) {
|
|
26
|
+
const o = i[r];
|
|
27
|
+
typeof o == "function" ? o() : A(e[r], null);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function S(...e) {
|
|
33
|
+
return s.useCallback(R(...e), e);
|
|
34
|
+
}
|
|
35
|
+
var O = s.forwardRef((e, n) => {
|
|
36
|
+
const { children: t, ...i } = e, r = s.Children.toArray(t), o = r.find(T);
|
|
37
|
+
if (o) {
|
|
38
|
+
const c = o.props.children, l = r.map((u) => u === o ? s.Children.count(c) > 1 ? s.Children.only(null) : s.isValidElement(c) ? c.props.children : null : u);
|
|
39
|
+
return /* @__PURE__ */ h(y, { ...i, ref: n, children: s.isValidElement(c) ? s.cloneElement(c, void 0, l) : null });
|
|
40
|
+
}
|
|
41
|
+
return /* @__PURE__ */ h(y, { ...i, ref: n, children: t });
|
|
42
|
+
});
|
|
43
|
+
O.displayName = "Slot";
|
|
44
|
+
var y = s.forwardRef((e, n) => {
|
|
45
|
+
const { children: t, ...i } = e;
|
|
46
|
+
if (s.isValidElement(t)) {
|
|
47
|
+
const r = D(t), o = b(i, t.props);
|
|
48
|
+
return t.type !== s.Fragment && (o.ref = n ? R(n, r) : r), s.cloneElement(t, o);
|
|
49
|
+
}
|
|
50
|
+
return s.Children.count(t) > 1 ? s.Children.only(null) : null;
|
|
51
|
+
});
|
|
52
|
+
y.displayName = "SlotClone";
|
|
53
|
+
var E = ({ children: e }) => /* @__PURE__ */ h(M, { children: e });
|
|
54
|
+
function T(e) {
|
|
55
|
+
return s.isValidElement(e) && e.type === E;
|
|
56
|
+
}
|
|
57
|
+
function b(e, n) {
|
|
58
|
+
const t = { ...n };
|
|
59
|
+
for (const i in n) {
|
|
60
|
+
const r = e[i], o = n[i];
|
|
61
|
+
/^on[A-Z]/.test(i) ? r && o ? t[i] = (...l) => {
|
|
62
|
+
o(...l), r(...l);
|
|
63
|
+
} : r && (t[i] = r) : i === "style" ? t[i] = { ...r, ...o } : i === "className" && (t[i] = [r, o].filter(Boolean).join(" "));
|
|
64
|
+
}
|
|
65
|
+
return { ...e, ...t };
|
|
66
|
+
}
|
|
67
|
+
function D(e) {
|
|
68
|
+
var i, r;
|
|
69
|
+
let n = (i = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : i.get, t = n && "isReactWarning" in n && n.isReactWarning;
|
|
70
|
+
return t ? e.ref : (n = (r = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : r.get, t = n && "isReactWarning" in n && n.isReactWarning, t ? e.props.ref : e.props.ref || e.ref);
|
|
71
|
+
}
|
|
72
|
+
var I = [
|
|
73
|
+
"a",
|
|
74
|
+
"button",
|
|
75
|
+
"div",
|
|
76
|
+
"form",
|
|
77
|
+
"h2",
|
|
78
|
+
"h3",
|
|
79
|
+
"img",
|
|
80
|
+
"input",
|
|
81
|
+
"label",
|
|
82
|
+
"li",
|
|
83
|
+
"nav",
|
|
84
|
+
"ol",
|
|
85
|
+
"p",
|
|
86
|
+
"span",
|
|
87
|
+
"svg",
|
|
88
|
+
"ul"
|
|
89
|
+
], _ = I.reduce((e, n) => {
|
|
90
|
+
const t = s.forwardRef((i, r) => {
|
|
91
|
+
const { asChild: o, ...c } = i, l = o ? O : n;
|
|
92
|
+
return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ h(l, { ...c, ref: r });
|
|
93
|
+
});
|
|
94
|
+
return t.displayName = `Primitive.${n}`, { ...e, [n]: t };
|
|
95
|
+
}, {});
|
|
96
|
+
function k(e, n) {
|
|
97
|
+
e && C.flushSync(() => e.dispatchEvent(n));
|
|
98
|
+
}
|
|
99
|
+
function U(e, n) {
|
|
100
|
+
return s.useReducer((t, i) => n[t][i] ?? t, e);
|
|
101
|
+
}
|
|
102
|
+
var W = (e) => {
|
|
103
|
+
const { present: n, children: t } = e, i = F(n), r = typeof t == "function" ? t({ present: i.isPresent }) : s.Children.only(t), o = S(i.ref, L(r));
|
|
104
|
+
return typeof t == "function" || i.isPresent ? s.cloneElement(r, { ref: o }) : null;
|
|
105
|
+
};
|
|
106
|
+
W.displayName = "Presence";
|
|
107
|
+
function F(e) {
|
|
108
|
+
const [n, t] = s.useState(), i = s.useRef({}), r = s.useRef(e), o = s.useRef("none"), c = e ? "mounted" : "unmounted", [l, u] = U(c, {
|
|
109
|
+
mounted: {
|
|
110
|
+
UNMOUNT: "unmounted",
|
|
111
|
+
ANIMATION_OUT: "unmountSuspended"
|
|
112
|
+
},
|
|
113
|
+
unmountSuspended: {
|
|
114
|
+
MOUNT: "mounted",
|
|
115
|
+
ANIMATION_END: "unmounted"
|
|
116
|
+
},
|
|
117
|
+
unmounted: {
|
|
118
|
+
MOUNT: "mounted"
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
return s.useEffect(() => {
|
|
122
|
+
const a = N(i.current);
|
|
123
|
+
o.current = l === "mounted" ? a : "none";
|
|
124
|
+
}, [l]), g(() => {
|
|
125
|
+
const a = i.current, m = r.current;
|
|
126
|
+
if (m !== e) {
|
|
127
|
+
const p = o.current, f = N(a);
|
|
128
|
+
e ? u("MOUNT") : f === "none" || (a == null ? void 0 : a.display) === "none" ? u("UNMOUNT") : u(m && p !== f ? "ANIMATION_OUT" : "UNMOUNT"), r.current = e;
|
|
129
|
+
}
|
|
130
|
+
}, [e, u]), g(() => {
|
|
131
|
+
if (n) {
|
|
132
|
+
let a;
|
|
133
|
+
const m = n.ownerDocument.defaultView ?? window, d = (f) => {
|
|
134
|
+
const v = N(i.current).includes(f.animationName);
|
|
135
|
+
if (f.target === n && v && (u("ANIMATION_END"), !r.current)) {
|
|
136
|
+
const w = n.style.animationFillMode;
|
|
137
|
+
n.style.animationFillMode = "forwards", a = m.setTimeout(() => {
|
|
138
|
+
n.style.animationFillMode === "forwards" && (n.style.animationFillMode = w);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}, p = (f) => {
|
|
142
|
+
f.target === n && (o.current = N(i.current));
|
|
143
|
+
};
|
|
144
|
+
return n.addEventListener("animationstart", p), n.addEventListener("animationcancel", d), n.addEventListener("animationend", d), () => {
|
|
145
|
+
m.clearTimeout(a), n.removeEventListener("animationstart", p), n.removeEventListener("animationcancel", d), n.removeEventListener("animationend", d);
|
|
146
|
+
};
|
|
147
|
+
} else
|
|
148
|
+
u("ANIMATION_END");
|
|
149
|
+
}, [n, u]), {
|
|
150
|
+
isPresent: ["mounted", "unmountSuspended"].includes(l),
|
|
151
|
+
ref: s.useCallback((a) => {
|
|
152
|
+
a && (i.current = getComputedStyle(a)), t(a);
|
|
153
|
+
}, [])
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
function N(e) {
|
|
157
|
+
return (e == null ? void 0 : e.animationName) || "none";
|
|
158
|
+
}
|
|
159
|
+
function L(e) {
|
|
160
|
+
var i, r;
|
|
161
|
+
let n = (i = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : i.get, t = n && "isReactWarning" in n && n.isReactWarning;
|
|
162
|
+
return t ? e.ref : (n = (r = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : r.get, t = n && "isReactWarning" in n && n.isReactWarning, t ? e.props.ref : e.props.ref || e.ref);
|
|
163
|
+
}
|
|
164
|
+
export {
|
|
165
|
+
_ as P,
|
|
166
|
+
O as S,
|
|
167
|
+
W as a,
|
|
168
|
+
R as b,
|
|
169
|
+
x as c,
|
|
170
|
+
k as d,
|
|
171
|
+
S as u
|
|
172
|
+
};
|