@pdf-viewer/react 1.9.0-beta.0 → 1.9.0-beta.1

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 (71) hide show
  1. package/dist/{Popover-1faa77f6.js → Popover-48c8394c.js} +2 -2
  2. package/dist/{RPLayout-3ef4e136.js → RPLayout-3042ec91.js} +996 -990
  3. package/dist/{component-1da194e8.js → component-2aa6e53b.js} +1 -1
  4. package/dist/components/RPConfig.js +691 -673
  5. package/dist/components/RPController.js +1 -1
  6. package/dist/components/RPPages.js +2 -2
  7. package/dist/components/layout/LayoutContainer.js +2 -2
  8. package/dist/components/layout/RPDefaultLayout.js +1 -1
  9. package/dist/components/layout/RPLayout.js +2 -2
  10. package/dist/components/layout/sidebar/RPSidebar.js +1 -1
  11. package/dist/components/layout/sidebar/Thumbnail.js +1 -1
  12. package/dist/components/layout/sidebar/Thumbnails.js +1 -1
  13. package/dist/components/layout/toolbar/DocumentDialog.js +2 -2
  14. package/dist/components/layout/toolbar/FileDownloadTool.js +1 -1
  15. package/dist/components/layout/toolbar/MenuItem.js +1 -1
  16. package/dist/components/layout/toolbar/MenuSeparator.js +1 -1
  17. package/dist/components/layout/toolbar/MostPageTool.js +3 -3
  18. package/dist/components/layout/toolbar/OtherTool.js +2 -2
  19. package/dist/components/layout/toolbar/Paginate.js +1 -1
  20. package/dist/components/layout/toolbar/PrintTool.js +1 -1
  21. package/dist/components/layout/toolbar/RPToolbar.js +1 -1
  22. package/dist/components/layout/toolbar/RPToolbarEnd.js +1 -1
  23. package/dist/components/layout/toolbar/RotateTool.js +1 -1
  24. package/dist/components/layout/toolbar/ScrollModeTool.js +1 -1
  25. package/dist/components/layout/toolbar/SearchResultNavigator.js +1 -1
  26. package/dist/components/layout/toolbar/SearchTool.js +2 -2
  27. package/dist/components/layout/toolbar/SelectionModeTool.js +1 -1
  28. package/dist/components/layout/toolbar/ToolbarCustom.js +2 -2
  29. package/dist/components/layout/toolbar/ViewModeTool.js +1 -1
  30. package/dist/components/layout/toolbar/ZoomTool.js +2 -2
  31. package/dist/components/layout/toolbar/tools/FileDownloadTool.js +1 -1
  32. package/dist/components/layout/toolbar/tools/InputPageTool.js +1 -1
  33. package/dist/components/layout/toolbar/tools/NextPageTool.js +2 -2
  34. package/dist/components/layout/toolbar/tools/PreviousPageTool.js +1 -1
  35. package/dist/components/layout/toolbar/tools/PrintTool.js +1 -1
  36. package/dist/components/layout/toolbar/tools/ThumbnailTool.js +1 -1
  37. package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +2 -2
  38. package/dist/components/page/AnnotationLayer.js +2 -2
  39. package/dist/components/page/CanvasLayer.js +2 -2
  40. package/dist/components/page/DualPage.js +1 -1
  41. package/dist/components/page/RPPage.js +2 -2
  42. package/dist/components/page/SinglePage.js +1 -1
  43. package/dist/components/page/TextHighlightLayer.js +2 -2
  44. package/dist/components/page/TextLayer.js +2 -2
  45. package/dist/components/ui/Checkbox.js +228 -116
  46. package/dist/components/ui/DropDown.js +1 -1
  47. package/dist/components/ui/LoadingIndicator.js +1 -1
  48. package/dist/components/ui/Popover.js +1 -1
  49. package/dist/components/ui/RPTooltip.js +207 -207
  50. package/dist/contexts/PaginationContext.js +1 -1
  51. package/dist/contexts/PrintContext.js +1 -1
  52. package/dist/contexts/SearchContext.js +1 -1
  53. package/dist/contexts/ThumbnailsContext.js +1 -1
  54. package/dist/{floating-ui.react-dom-15b9b819.js → floating-ui.react-dom-4b1e2e46.js} +394 -380
  55. package/dist/index-6e0e48fa.js +332 -0
  56. package/dist/{index-7279fb4e.js → index-951f0f1f.js} +464 -456
  57. package/dist/index-e3a67935.js +150 -0
  58. package/dist/main.js +1 -1
  59. package/dist/types/utils/types.d.ts +9 -4
  60. package/dist/utils/hooks/useFileDownload.js +2 -2
  61. package/dist/utils/hooks/useLicense.js +1 -1
  62. package/dist/utils/hooks/usePaginate.js +2 -2
  63. package/dist/utils/hooks/usePresentPage.js +2 -2
  64. package/dist/utils/hooks/usePrint.js +2 -2
  65. package/dist/utils/hooks/useScrollToPage.js +2 -2
  66. package/dist/utils/hooks/useSearch.js +2 -2
  67. package/dist/utils/hooks/useThumbnail.js +2 -2
  68. package/dist/utils/hooks/useVirtualReactWindow.js +2 -2
  69. package/package.json +1 -1
  70. package/dist/index-1cb41342.js +0 -307
  71. package/dist/index-aa2d3884.js +0 -140
@@ -0,0 +1,150 @@
1
+ import * as r from "react";
2
+ import { u as R, P as w, a as h, f as _, g as U } from "./index-6e0e48fa.js";
3
+ import { jsx as T } from "react/jsx-runtime";
4
+ function b(t) {
5
+ const e = r.useRef(t);
6
+ return r.useEffect(() => {
7
+ e.current = t;
8
+ }), r.useMemo(() => (...n) => {
9
+ var s;
10
+ return (s = e.current) == null ? void 0 : s.call(e, ...n);
11
+ }, []);
12
+ }
13
+ function z(t, e = globalThis == null ? void 0 : globalThis.document) {
14
+ const n = b(t);
15
+ r.useEffect(() => {
16
+ const s = (i) => {
17
+ i.key === "Escape" && n(i);
18
+ };
19
+ return e.addEventListener("keydown", s, { capture: !0 }), () => e.removeEventListener("keydown", s, { capture: !0 });
20
+ }, [n, e]);
21
+ }
22
+ var H = "DismissableLayer", p = "dismissableLayer.update", M = "dismissableLayer.pointerDownOutside", K = "dismissableLayer.focusOutside", g, S = r.createContext({
23
+ layers: /* @__PURE__ */ new Set(),
24
+ layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
25
+ branches: /* @__PURE__ */ new Set()
26
+ }), j = r.forwardRef(
27
+ (t, e) => {
28
+ const {
29
+ disableOutsidePointerEvents: n = !1,
30
+ onEscapeKeyDown: s,
31
+ onPointerDownOutside: i,
32
+ onFocusOutside: a,
33
+ onInteractOutside: l,
34
+ onDismiss: d,
35
+ ...E
36
+ } = t, u = r.useContext(S), [c, B] = r.useState(null), f = (c == null ? void 0 : c.ownerDocument) ?? (globalThis == null ? void 0 : globalThis.document), [, F] = r.useState({}), I = R(e, (o) => B(o)), m = Array.from(u.layers), [W] = [...u.layersWithOutsidePointerEventsDisabled].slice(-1), A = m.indexOf(W), P = c ? m.indexOf(c) : -1, N = u.layersWithOutsidePointerEventsDisabled.size > 0, D = P >= A, k = $((o) => {
37
+ const v = o.target, C = [...u.branches].some((y) => y.contains(v));
38
+ !D || C || (i == null || i(o), l == null || l(o), o.defaultPrevented || d == null || d());
39
+ }, f), L = q((o) => {
40
+ const v = o.target;
41
+ [...u.branches].some((y) => y.contains(v)) || (a == null || a(o), l == null || l(o), o.defaultPrevented || d == null || d());
42
+ }, f);
43
+ return z((o) => {
44
+ P === u.layers.size - 1 && (s == null || s(o), !o.defaultPrevented && d && (o.preventDefault(), d()));
45
+ }, f), r.useEffect(() => {
46
+ if (c)
47
+ return n && (u.layersWithOutsidePointerEventsDisabled.size === 0 && (g = f.body.style.pointerEvents, f.body.style.pointerEvents = "none"), u.layersWithOutsidePointerEventsDisabled.add(c)), u.layers.add(c), O(), () => {
48
+ n && u.layersWithOutsidePointerEventsDisabled.size === 1 && (f.body.style.pointerEvents = g);
49
+ };
50
+ }, [c, f, n, u]), r.useEffect(() => () => {
51
+ c && (u.layers.delete(c), u.layersWithOutsidePointerEventsDisabled.delete(c), O());
52
+ }, [c, u]), r.useEffect(() => {
53
+ const o = () => F({});
54
+ return document.addEventListener(p, o), () => document.removeEventListener(p, o);
55
+ }, []), /* @__PURE__ */ T(
56
+ w.div,
57
+ {
58
+ ...E,
59
+ ref: I,
60
+ style: {
61
+ pointerEvents: N ? D ? "auto" : "none" : void 0,
62
+ ...t.style
63
+ },
64
+ onFocusCapture: h(t.onFocusCapture, L.onFocusCapture),
65
+ onBlurCapture: h(t.onBlurCapture, L.onBlurCapture),
66
+ onPointerDownCapture: h(
67
+ t.onPointerDownCapture,
68
+ k.onPointerDownCapture
69
+ )
70
+ }
71
+ );
72
+ }
73
+ );
74
+ j.displayName = H;
75
+ var X = "DismissableLayerBranch", Y = r.forwardRef((t, e) => {
76
+ const n = r.useContext(S), s = r.useRef(null), i = R(e, s);
77
+ return r.useEffect(() => {
78
+ const a = s.current;
79
+ if (a)
80
+ return n.branches.add(a), () => {
81
+ n.branches.delete(a);
82
+ };
83
+ }, [n.branches]), /* @__PURE__ */ T(w.div, { ...t, ref: i });
84
+ });
85
+ Y.displayName = X;
86
+ function $(t, e = globalThis == null ? void 0 : globalThis.document) {
87
+ const n = b(t), s = r.useRef(!1), i = r.useRef(() => {
88
+ });
89
+ return r.useEffect(() => {
90
+ const a = (d) => {
91
+ if (d.target && !s.current) {
92
+ let E = function() {
93
+ x(
94
+ M,
95
+ n,
96
+ u,
97
+ { discrete: !0 }
98
+ );
99
+ };
100
+ const u = { originalEvent: d };
101
+ d.pointerType === "touch" ? (e.removeEventListener("click", i.current), i.current = E, e.addEventListener("click", i.current, { once: !0 })) : E();
102
+ } else
103
+ e.removeEventListener("click", i.current);
104
+ s.current = !1;
105
+ }, l = window.setTimeout(() => {
106
+ e.addEventListener("pointerdown", a);
107
+ }, 0);
108
+ return () => {
109
+ window.clearTimeout(l), e.removeEventListener("pointerdown", a), e.removeEventListener("click", i.current);
110
+ };
111
+ }, [e, n]), {
112
+ // ensures we check React component tree (not just DOM tree)
113
+ onPointerDownCapture: () => s.current = !0
114
+ };
115
+ }
116
+ function q(t, e = globalThis == null ? void 0 : globalThis.document) {
117
+ const n = b(t), s = r.useRef(!1);
118
+ return r.useEffect(() => {
119
+ const i = (a) => {
120
+ a.target && !s.current && x(K, n, { originalEvent: a }, {
121
+ discrete: !1
122
+ });
123
+ };
124
+ return e.addEventListener("focusin", i), () => e.removeEventListener("focusin", i);
125
+ }, [e, n]), {
126
+ onFocusCapture: () => s.current = !0,
127
+ onBlurCapture: () => s.current = !1
128
+ };
129
+ }
130
+ function O() {
131
+ const t = new CustomEvent(p);
132
+ document.dispatchEvent(t);
133
+ }
134
+ function x(t, e, n, { discrete: s }) {
135
+ const i = n.originalEvent.target, a = new CustomEvent(t, { bubbles: !1, cancelable: !0, detail: n });
136
+ e && i.addEventListener(t, e, { once: !0 }), s ? _(i, a) : i.dispatchEvent(a);
137
+ }
138
+ var G = r[" useId ".trim().toString()] || (() => {
139
+ }), J = 0;
140
+ function Z(t) {
141
+ const [e, n] = r.useState(G());
142
+ return U(() => {
143
+ t || n((s) => s ?? String(J++));
144
+ }, [t]), t || (e ? `radix-${e}` : "");
145
+ }
146
+ export {
147
+ j as D,
148
+ Z as a,
149
+ b as u
150
+ };
package/dist/main.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { RPProvider as r } from "./components/RPProvider.js";
2
- import { a as x, b as m, R as l, S as p, c as f, u as n, d as a, e as s } from "./RPLayout-3ef4e136.js";
2
+ import { a as x, b as m, R as l, S as p, c as f, u as n, d as a, e as s } from "./RPLayout-3042ec91.js";
3
3
  import { RPConfig as i } from "./components/RPConfig.js";
4
4
  import { RPController as T } from "./components/RPController.js";
5
5
  import { RPTheme as R } from "./components/RPTheme.js";
@@ -511,8 +511,7 @@ export interface RPDefaultLayoutProps extends PropsWithChildren, ViewportProps {
511
511
  cleanupOnLoaded?: () => void;
512
512
  }
513
513
  export interface RPLayoutProps extends PropsWithChildren, ViewportProps {
514
- topBar?: React.ReactNode;
515
- sidebar?: React.ReactNode;
514
+ toolbar?: Partial<ToolbarProps>;
516
515
  style?: React.CSSProperties;
517
516
  className?: string;
518
517
  onLoaded?: () => void;
@@ -728,8 +727,7 @@ export interface CharacterIndex {
728
727
  }
729
728
  export interface ToolbarCustomProps {
730
729
  children: React.ReactNode;
731
- topBar?: React.ReactNode;
732
- sidebar?: React.ReactNode;
730
+ toolbar?: Partial<ToolbarProps>;
733
731
  }
734
732
  export interface ToolProps {
735
733
  icon?: React.ReactNode;
@@ -740,4 +738,11 @@ export interface ThemeSwitcherToolProps {
740
738
  darkModeIcon?: React.ReactNode;
741
739
  };
742
740
  }
741
+ export interface ToolbarSection {
742
+ component: React.ReactNode;
743
+ }
744
+ export interface ToolbarProps {
745
+ topbar: Partial<ToolbarSection>;
746
+ leftSidebar: Partial<ToolbarSection>;
747
+ }
743
748
  export {};
@@ -2,7 +2,7 @@ import "react/jsx-runtime";
2
2
  import "react";
3
3
  import "../../contexts/RPDocumentContext.js";
4
4
  import "../../contexts/DocumentPasswordContext.js";
5
- import { c as T } from "../../RPLayout-3ef4e136.js";
5
+ import { c as T } from "../../RPLayout-3042ec91.js";
6
6
  import "../../contexts/DarkModeContext.js";
7
7
  import "../../contexts/RotationContext.js";
8
8
  import "../../contexts/LayerContext.js";
@@ -37,7 +37,7 @@ import "../../components/ui/Checkbox.js";
37
37
  import "../../components/icons/LoaderIcon.js";
38
38
  import "../../contexts/IconContext.js";
39
39
  import "../../components/ui/RPTooltip.js";
40
- import "../../Popover-1faa77f6.js";
40
+ import "../../Popover-48c8394c.js";
41
41
  import "../../contexts/ViewportContext.js";
42
42
  import "../../components/ui/DropDown.js";
43
43
  import "../../components/layout/toolbar/MenuItem.js";
@@ -1,6 +1,6 @@
1
1
  import { useState as g, useCallback as h, useEffect as A } from "react";
2
2
  import { appConsole as c } from "../appConsole.js";
3
- const b = /* @__PURE__ */ new Date("2025-07-22T06:39:12.518Z"), l = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", s = {
3
+ const b = /* @__PURE__ */ new Date("2025-07-29T03:33:35.655Z"), l = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", s = {
4
4
  invalidLicense: `You are currently using without a valid license. ${l}`,
5
5
  mismatchedDomain: `Your license key is not valid for the current domain / IP. ${l}`,
6
6
  expired: `Your license key has expired. ${l}`,
@@ -1,6 +1,6 @@
1
1
  import "react";
2
2
  import "../types.js";
3
- import { l as V } from "../../RPLayout-3ef4e136.js";
3
+ import { l as V } from "../../RPLayout-3042ec91.js";
4
4
  import "react/jsx-runtime";
5
5
  import "../../contexts/RPDocumentContext.js";
6
6
  import "../../contexts/DocumentPasswordContext.js";
@@ -38,7 +38,7 @@ import "../../components/ui/Checkbox.js";
38
38
  import "../../components/icons/LoaderIcon.js";
39
39
  import "../../contexts/IconContext.js";
40
40
  import "../../components/ui/RPTooltip.js";
41
- import "../../Popover-1faa77f6.js";
41
+ import "../../Popover-48c8394c.js";
42
42
  import "../../contexts/ViewportContext.js";
43
43
  import "../../components/ui/DropDown.js";
44
44
  import "../../components/layout/toolbar/MenuItem.js";
@@ -5,7 +5,7 @@ import "../calculatePage.js";
5
5
  import "react/jsx-runtime";
6
6
  import "../../contexts/RPDocumentContext.js";
7
7
  import "../../contexts/DocumentPasswordContext.js";
8
- import { z as V } from "../../RPLayout-3ef4e136.js";
8
+ import { z as V } from "../../RPLayout-3042ec91.js";
9
9
  import "../../contexts/DarkModeContext.js";
10
10
  import "../../contexts/RotationContext.js";
11
11
  import "../../contexts/LayerContext.js";
@@ -38,7 +38,7 @@ import "../../components/ui/Checkbox.js";
38
38
  import "../../components/icons/LoaderIcon.js";
39
39
  import "../../contexts/IconContext.js";
40
40
  import "../../components/ui/RPTooltip.js";
41
- import "../../Popover-1faa77f6.js";
41
+ import "../../Popover-48c8394c.js";
42
42
  import "../../contexts/ViewportContext.js";
43
43
  import "../../components/ui/DropDown.js";
44
44
  import "../../components/layout/toolbar/MenuItem.js";
@@ -2,7 +2,7 @@ import "react";
2
2
  import "react/jsx-runtime";
3
3
  import "../../contexts/RPDocumentContext.js";
4
4
  import "../../contexts/DocumentPasswordContext.js";
5
- import { n as U } from "../../RPLayout-3ef4e136.js";
5
+ import { n as U } from "../../RPLayout-3042ec91.js";
6
6
  import "../../contexts/DarkModeContext.js";
7
7
  import "../../contexts/RotationContext.js";
8
8
  import "../../contexts/LayerContext.js";
@@ -37,7 +37,7 @@ import "../../components/ui/Checkbox.js";
37
37
  import "../../components/icons/LoaderIcon.js";
38
38
  import "../../contexts/IconContext.js";
39
39
  import "../../components/ui/RPTooltip.js";
40
- import "../../Popover-1faa77f6.js";
40
+ import "../../Popover-48c8394c.js";
41
41
  import "../../contexts/ViewportContext.js";
42
42
  import "../../components/ui/DropDown.js";
43
43
  import "../../components/layout/toolbar/MenuItem.js";
@@ -3,7 +3,7 @@ import "../../contexts/ScrollModeContext.js";
3
3
  import "react/jsx-runtime";
4
4
  import "../../contexts/RPDocumentContext.js";
5
5
  import "../../contexts/DocumentPasswordContext.js";
6
- import { k as W } from "../../RPLayout-3ef4e136.js";
6
+ import { k as W } from "../../RPLayout-3042ec91.js";
7
7
  import "../../contexts/DarkModeContext.js";
8
8
  import "../types.js";
9
9
  import "../../contexts/RotationContext.js";
@@ -38,7 +38,7 @@ import "../../components/ui/Checkbox.js";
38
38
  import "../../components/icons/LoaderIcon.js";
39
39
  import "../../contexts/IconContext.js";
40
40
  import "../../components/ui/RPTooltip.js";
41
- import "../../Popover-1faa77f6.js";
41
+ import "../../Popover-48c8394c.js";
42
42
  import "../../contexts/ViewportContext.js";
43
43
  import "../../components/ui/DropDown.js";
44
44
  import "../../components/layout/toolbar/MenuItem.js";
@@ -7,7 +7,7 @@ import "../../contexts/RPDocumentContext.js";
7
7
  import "../../contexts/ZoomContext.js";
8
8
  import "react/jsx-runtime";
9
9
  import "../../contexts/DocumentPasswordContext.js";
10
- import { r as X } from "../../RPLayout-3ef4e136.js";
10
+ import { r as X } from "../../RPLayout-3042ec91.js";
11
11
  import "../../contexts/DarkModeContext.js";
12
12
  import "../../contexts/RotationContext.js";
13
13
  import "../../contexts/LayerContext.js";
@@ -39,7 +39,7 @@ import "../../components/ui/Checkbox.js";
39
39
  import "../../components/icons/LoaderIcon.js";
40
40
  import "../../contexts/IconContext.js";
41
41
  import "../../components/ui/RPTooltip.js";
42
- import "../../Popover-1faa77f6.js";
42
+ import "../../Popover-48c8394c.js";
43
43
  import "../../contexts/ViewportContext.js";
44
44
  import "../../components/ui/DropDown.js";
45
45
  import "../../components/layout/toolbar/MenuItem.js";
@@ -3,7 +3,7 @@ import "../renderPage.js";
3
3
  import "react/jsx-runtime";
4
4
  import "../../contexts/RPDocumentContext.js";
5
5
  import "../../contexts/DocumentPasswordContext.js";
6
- import { p as V } from "../../RPLayout-3ef4e136.js";
6
+ import { p as V } from "../../RPLayout-3042ec91.js";
7
7
  import "../../contexts/DarkModeContext.js";
8
8
  import "../../contexts/RotationContext.js";
9
9
  import "../../contexts/LayerContext.js";
@@ -38,7 +38,7 @@ import "../../components/ui/Checkbox.js";
38
38
  import "../../components/icons/LoaderIcon.js";
39
39
  import "../../contexts/IconContext.js";
40
40
  import "../../components/ui/RPTooltip.js";
41
- import "../../Popover-1faa77f6.js";
41
+ import "../../Popover-48c8394c.js";
42
42
  import "../../contexts/ViewportContext.js";
43
43
  import "../../components/ui/DropDown.js";
44
44
  import "../../components/layout/toolbar/MenuItem.js";
@@ -4,7 +4,7 @@ import "../../contexts/ScrollModeContext.js";
4
4
  import "react/jsx-runtime";
5
5
  import "../../contexts/RPDocumentContext.js";
6
6
  import "../../contexts/DocumentPasswordContext.js";
7
- import { x as S } from "../../RPLayout-3ef4e136.js";
7
+ import { x as S } from "../../RPLayout-3042ec91.js";
8
8
  import "../../contexts/DarkModeContext.js";
9
9
  import "../../contexts/RotationContext.js";
10
10
  import "../../contexts/LayerContext.js";
@@ -38,7 +38,7 @@ import "../../components/ui/Checkbox.js";
38
38
  import "../../components/icons/LoaderIcon.js";
39
39
  import "../../contexts/IconContext.js";
40
40
  import "../../components/ui/RPTooltip.js";
41
- import "../../Popover-1faa77f6.js";
41
+ import "../../Popover-48c8394c.js";
42
42
  import "../../contexts/ViewportContext.js";
43
43
  import "../../components/ui/DropDown.js";
44
44
  import "../../components/layout/toolbar/MenuItem.js";
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@pdf-viewer/react",
3
3
  "private": false,
4
4
  "description": "A react-pdf-viewer component for React and Next.js. Suitable for react-pdf document.",
5
- "version": "1.9.0-beta.0",
5
+ "version": "1.9.0-beta.1",
6
6
  "keywords": [
7
7
  "react-pdf",
8
8
  "react-pdf-viewer",
@@ -1,307 +0,0 @@
1
- import * as s from "react";
2
- import { jsx as S, Fragment as O } from "react/jsx-runtime";
3
- import * as x from "react-dom";
4
- function V(e, t, { checkForDefaultPrevented: n = !0 } = {}) {
5
- return function(o) {
6
- if (e == null || e(o), n === !1 || !o.defaultPrevented)
7
- return t == null ? void 0 : t(o);
8
- };
9
- }
10
- function P(e, t) {
11
- if (typeof e == "function")
12
- return e(t);
13
- e != null && (e.current = t);
14
- }
15
- function w(...e) {
16
- return (t) => {
17
- let n = !1;
18
- const r = e.map((o) => {
19
- const i = P(o, t);
20
- return !n && typeof i == "function" && (n = !0), i;
21
- });
22
- if (n)
23
- return () => {
24
- for (let o = 0; o < r.length; o++) {
25
- const i = r[o];
26
- typeof i == "function" ? i() : P(e[o], null);
27
- }
28
- };
29
- };
30
- }
31
- function E(...e) {
32
- return s.useCallback(w(...e), e);
33
- }
34
- function k(e, t) {
35
- const n = s.createContext(t), r = (i) => {
36
- const { children: c, ...u } = i, a = s.useMemo(() => u, Object.values(u));
37
- return /* @__PURE__ */ S(n.Provider, { value: a, children: c });
38
- };
39
- r.displayName = e + "Provider";
40
- function o(i) {
41
- const c = s.useContext(n);
42
- if (c)
43
- return c;
44
- if (t !== void 0)
45
- return t;
46
- throw new Error(`\`${i}\` must be used within \`${e}\``);
47
- }
48
- return [r, o];
49
- }
50
- function B(e, t = []) {
51
- let n = [];
52
- function r(i, c) {
53
- const u = s.createContext(c), a = n.length;
54
- n = [...n, c];
55
- const f = (l) => {
56
- var b;
57
- const { scope: d, children: m, ...h } = l, v = ((b = d == null ? void 0 : d[e]) == null ? void 0 : b[a]) || u, y = s.useMemo(() => h, Object.values(h));
58
- return /* @__PURE__ */ S(v.Provider, { value: y, children: m });
59
- };
60
- f.displayName = i + "Provider";
61
- function p(l, d) {
62
- var v;
63
- const m = ((v = d == null ? void 0 : d[e]) == null ? void 0 : v[a]) || u, h = s.useContext(m);
64
- if (h)
65
- return h;
66
- if (c !== void 0)
67
- return c;
68
- throw new Error(`\`${l}\` must be used within \`${i}\``);
69
- }
70
- return [f, p];
71
- }
72
- const o = () => {
73
- const i = n.map((c) => s.createContext(c));
74
- return function(u) {
75
- const a = (u == null ? void 0 : u[e]) || i;
76
- return s.useMemo(
77
- () => ({ [`__scope${e}`]: { ...u, [e]: a } }),
78
- [u, a]
79
- );
80
- };
81
- };
82
- return o.scopeName = e, [r, M(o, ...t)];
83
- }
84
- function M(...e) {
85
- const t = e[0];
86
- if (e.length === 1)
87
- return t;
88
- const n = () => {
89
- const r = e.map((o) => ({
90
- useScope: o(),
91
- scopeName: o.scopeName
92
- }));
93
- return function(i) {
94
- const c = r.reduce((u, { useScope: a, scopeName: f }) => {
95
- const l = a(i)[`__scope${f}`];
96
- return { ...u, ...l };
97
- }, {});
98
- return s.useMemo(() => ({ [`__scope${t.scopeName}`]: c }), [c]);
99
- };
100
- };
101
- return n.scopeName = t.scopeName, n;
102
- }
103
- var A = s.forwardRef((e, t) => {
104
- const { children: n, ...r } = e, o = s.Children.toArray(n), i = o.find(U);
105
- if (i) {
106
- const c = i.props.children, u = o.map((a) => a === i ? s.Children.count(c) > 1 ? s.Children.only(null) : s.isValidElement(c) ? c.props.children : null : a);
107
- return /* @__PURE__ */ S(g, { ...r, ref: t, children: s.isValidElement(c) ? s.cloneElement(c, void 0, u) : null });
108
- }
109
- return /* @__PURE__ */ S(g, { ...r, ref: t, children: n });
110
- });
111
- A.displayName = "Slot";
112
- var g = s.forwardRef((e, t) => {
113
- const { children: n, ...r } = e;
114
- if (s.isValidElement(n)) {
115
- const o = z(n), i = W(r, n.props);
116
- return n.type !== s.Fragment && (i.ref = t ? w(t, o) : o), s.cloneElement(n, i);
117
- }
118
- return s.Children.count(n) > 1 ? s.Children.only(null) : null;
119
- });
120
- g.displayName = "SlotClone";
121
- var T = ({ children: e }) => /* @__PURE__ */ S(O, { children: e });
122
- function U(e) {
123
- return s.isValidElement(e) && e.type === T;
124
- }
125
- function W(e, t) {
126
- const n = { ...t };
127
- for (const r in t) {
128
- const o = e[r], i = t[r];
129
- /^on[A-Z]/.test(r) ? o && i ? n[r] = (...u) => {
130
- i(...u), o(...u);
131
- } : o && (n[r] = o) : r === "style" ? n[r] = { ...o, ...i } : r === "className" && (n[r] = [o, i].filter(Boolean).join(" "));
132
- }
133
- return { ...e, ...n };
134
- }
135
- function z(e) {
136
- var r, o;
137
- let t = (r = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : r.get, n = t && "isReactWarning" in t && t.isReactWarning;
138
- return n ? e.ref : (t = (o = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : o.get, n = t && "isReactWarning" in t && t.isReactWarning, n ? e.props.ref : e.props.ref || e.ref);
139
- }
140
- var D = [
141
- "a",
142
- "button",
143
- "div",
144
- "form",
145
- "h2",
146
- "h3",
147
- "img",
148
- "input",
149
- "label",
150
- "li",
151
- "nav",
152
- "ol",
153
- "p",
154
- "span",
155
- "svg",
156
- "ul"
157
- ], Z = D.reduce((e, t) => {
158
- const n = s.forwardRef((r, o) => {
159
- const { asChild: i, ...c } = r, u = i ? A : t;
160
- return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ S(u, { ...c, ref: o });
161
- });
162
- return n.displayName = `Primitive.${t}`, { ...e, [t]: n };
163
- }, {});
164
- function q(e, t) {
165
- e && x.flushSync(() => e.dispatchEvent(t));
166
- }
167
- function R(e) {
168
- const t = s.useRef(e);
169
- return s.useEffect(() => {
170
- t.current = e;
171
- }), s.useMemo(() => (...n) => {
172
- var r;
173
- return (r = t.current) == null ? void 0 : r.call(t, ...n);
174
- }, []);
175
- }
176
- var C = globalThis != null && globalThis.document ? s.useLayoutEffect : () => {
177
- };
178
- function G(e) {
179
- const [t, n] = s.useState(void 0);
180
- return C(() => {
181
- if (e) {
182
- n({ width: e.offsetWidth, height: e.offsetHeight });
183
- const r = new ResizeObserver((o) => {
184
- if (!Array.isArray(o) || !o.length)
185
- return;
186
- const i = o[0];
187
- let c, u;
188
- if ("borderBoxSize" in i) {
189
- const a = i.borderBoxSize, f = Array.isArray(a) ? a[0] : a;
190
- c = f.inlineSize, u = f.blockSize;
191
- } else
192
- c = e.offsetWidth, u = e.offsetHeight;
193
- n({ width: c, height: u });
194
- });
195
- return r.observe(e, { box: "border-box" }), () => r.unobserve(e);
196
- } else
197
- n(void 0);
198
- }, [e]), t;
199
- }
200
- function I(e, t) {
201
- return s.useReducer((n, r) => t[n][r] ?? n, e);
202
- }
203
- var _ = (e) => {
204
- const { present: t, children: n } = e, r = j(t), o = typeof n == "function" ? n({ present: r.isPresent }) : s.Children.only(n), i = E(r.ref, $(o));
205
- return typeof n == "function" || r.isPresent ? s.cloneElement(o, { ref: i }) : null;
206
- };
207
- _.displayName = "Presence";
208
- function j(e) {
209
- const [t, n] = s.useState(), r = s.useRef({}), o = s.useRef(e), i = s.useRef("none"), c = e ? "mounted" : "unmounted", [u, a] = I(c, {
210
- mounted: {
211
- UNMOUNT: "unmounted",
212
- ANIMATION_OUT: "unmountSuspended"
213
- },
214
- unmountSuspended: {
215
- MOUNT: "mounted",
216
- ANIMATION_END: "unmounted"
217
- },
218
- unmounted: {
219
- MOUNT: "mounted"
220
- }
221
- });
222
- return s.useEffect(() => {
223
- const f = N(r.current);
224
- i.current = u === "mounted" ? f : "none";
225
- }, [u]), C(() => {
226
- const f = r.current, p = o.current;
227
- if (p !== e) {
228
- const d = i.current, m = N(f);
229
- e ? a("MOUNT") : m === "none" || (f == null ? void 0 : f.display) === "none" ? a("UNMOUNT") : a(p && d !== m ? "ANIMATION_OUT" : "UNMOUNT"), o.current = e;
230
- }
231
- }, [e, a]), C(() => {
232
- if (t) {
233
- let f;
234
- const p = t.ownerDocument.defaultView ?? window, l = (m) => {
235
- const v = N(r.current).includes(m.animationName);
236
- if (m.target === t && v && (a("ANIMATION_END"), !o.current)) {
237
- const y = t.style.animationFillMode;
238
- t.style.animationFillMode = "forwards", f = p.setTimeout(() => {
239
- t.style.animationFillMode === "forwards" && (t.style.animationFillMode = y);
240
- });
241
- }
242
- }, d = (m) => {
243
- m.target === t && (i.current = N(r.current));
244
- };
245
- return t.addEventListener("animationstart", d), t.addEventListener("animationcancel", l), t.addEventListener("animationend", l), () => {
246
- p.clearTimeout(f), t.removeEventListener("animationstart", d), t.removeEventListener("animationcancel", l), t.removeEventListener("animationend", l);
247
- };
248
- } else
249
- a("ANIMATION_END");
250
- }, [t, a]), {
251
- isPresent: ["mounted", "unmountSuspended"].includes(u),
252
- ref: s.useCallback((f) => {
253
- f && (r.current = getComputedStyle(f)), n(f);
254
- }, [])
255
- };
256
- }
257
- function N(e) {
258
- return (e == null ? void 0 : e.animationName) || "none";
259
- }
260
- function $(e) {
261
- var r, o;
262
- let t = (r = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : r.get, n = t && "isReactWarning" in t && t.isReactWarning;
263
- return n ? e.ref : (t = (o = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : o.get, n = t && "isReactWarning" in t && t.isReactWarning, n ? e.props.ref : e.props.ref || e.ref);
264
- }
265
- function J({
266
- prop: e,
267
- defaultProp: t,
268
- onChange: n = () => {
269
- }
270
- }) {
271
- const [r, o] = L({ defaultProp: t, onChange: n }), i = e !== void 0, c = i ? e : r, u = R(n), a = s.useCallback(
272
- (f) => {
273
- if (i) {
274
- const l = typeof f == "function" ? f(e) : f;
275
- l !== e && u(l);
276
- } else
277
- o(f);
278
- },
279
- [i, e, o, u]
280
- );
281
- return [c, a];
282
- }
283
- function L({
284
- defaultProp: e,
285
- onChange: t
286
- }) {
287
- const n = s.useState(e), [r] = n, o = s.useRef(r), i = R(t);
288
- return s.useEffect(() => {
289
- o.current !== r && (i(r), o.current = r);
290
- }, [r, o, i]), n;
291
- }
292
- export {
293
- Z as P,
294
- T as S,
295
- E as a,
296
- C as b,
297
- V as c,
298
- q as d,
299
- B as e,
300
- J as f,
301
- _ as g,
302
- G as h,
303
- A as i,
304
- w as j,
305
- k,
306
- R as u
307
- };