@pdf-viewer/react 1.9.0-beta.4 → 1.9.0-beta.5

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 (111) hide show
  1. package/dist/Checkbox.module-3edaacbb.js +7 -0
  2. package/dist/Combination-da8647d4.js +693 -0
  3. package/dist/Container.module-f8b5c306.js +6 -0
  4. package/dist/DropDown.module-a78567cb.js +11 -0
  5. package/dist/MenuItem.module-bc11d0d3.js +6 -0
  6. package/dist/MenuSeparator.module-89b2ff7f.js +6 -0
  7. package/dist/PropertyItem.module-db0150cc.js +8 -0
  8. package/dist/RPSplitter.module-13d612c4.js +7 -0
  9. package/dist/RPTheme.module-bd9038da.js +8 -0
  10. package/dist/RotateTool.module-03987eba.js +6 -0
  11. package/dist/SearchTool.module-016f3a8d.js +16 -0
  12. package/dist/ToolbarLayout.module-60c3d6e8.js +2434 -0
  13. package/dist/WrapperLayout.module-147bc943.js +6 -0
  14. package/dist/assets/ToolbarLayout.css +1 -0
  15. package/dist/components/RPConfig.js +673 -691
  16. package/dist/components/RPController.js +9 -9
  17. package/dist/components/RPDropFileZone.js +21 -23
  18. package/dist/components/RPPages.js +21 -18
  19. package/dist/components/RPProvider.js +19 -15
  20. package/dist/components/layout/Container.js +10 -11
  21. package/dist/components/layout/LayoutContainer.js +19 -16
  22. package/dist/components/layout/RPDefaultLayout.js +76 -14
  23. package/dist/components/layout/RPLayout.js +74 -24
  24. package/dist/components/layout/WrapperLayout.js +7 -8
  25. package/dist/components/layout/sidebar/RPSidebar.js +51 -12
  26. package/dist/components/layout/sidebar/RPSplitter.js +7 -9
  27. package/dist/components/layout/sidebar/Thumbnail.js +1 -1
  28. package/dist/components/layout/sidebar/Thumbnails.js +1 -1
  29. package/dist/components/layout/toolbar/DocumentDialog.js +307 -24
  30. package/dist/components/layout/toolbar/FileDownloadTool.js +23 -13
  31. package/dist/components/layout/toolbar/MenuItem.js +6 -7
  32. package/dist/components/layout/toolbar/MenuSeparator.js +4 -5
  33. package/dist/components/layout/toolbar/MostPageTool.js +50 -23
  34. package/dist/components/layout/toolbar/OtherTool.js +115 -22
  35. package/dist/components/layout/toolbar/Paginate.js +99 -17
  36. package/dist/components/layout/toolbar/PrintTool.js +43 -13
  37. package/dist/components/layout/toolbar/PropertyItem.js +5 -8
  38. package/dist/components/layout/toolbar/RPToolbar.js +28 -7
  39. package/dist/components/layout/toolbar/RPToolbarEnd.js +22 -7
  40. package/dist/components/layout/toolbar/RotateTool.js +20 -21
  41. package/dist/components/layout/toolbar/ScrollModeTool.js +1 -1
  42. package/dist/components/layout/toolbar/SearchCloseButton.js +19 -7
  43. package/dist/components/layout/toolbar/SearchResultNavigator.js +42 -8
  44. package/dist/components/layout/toolbar/SearchTool.js +198 -29
  45. package/dist/components/layout/toolbar/SelectionModeTool.js +1 -1
  46. package/dist/components/layout/toolbar/ThumbnailTool.js +4 -4
  47. package/dist/components/layout/toolbar/ToolbarCustom.js +48 -20
  48. package/dist/components/layout/toolbar/ToolbarDefault.js +82 -0
  49. package/dist/components/layout/toolbar/ToolbarLayout.js +10 -0
  50. package/dist/components/layout/toolbar/ViewModeTool.js +1 -1
  51. package/dist/components/layout/toolbar/ZoomTool.js +140 -28
  52. package/dist/components/layout/toolbar/tools/FileDownloadTool.js +3 -3
  53. package/dist/components/layout/toolbar/tools/InputPageTool.js +7 -7
  54. package/dist/components/layout/toolbar/tools/NextPageTool.js +21 -18
  55. package/dist/components/layout/toolbar/tools/PreviousPageTool.js +1 -1
  56. package/dist/components/layout/toolbar/tools/PrintTool.js +3 -3
  57. package/dist/components/layout/toolbar/tools/ThumbnailTool.js +1 -1
  58. package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +14 -14
  59. package/dist/components/layout/toolbar/tools/defaults/{TopbarDefaultTools.js → RPHorizontalBar.js} +29 -20
  60. package/dist/components/layout/toolbar/tools/defaults/RPVerticalBar.js +16 -0
  61. package/dist/components/page/AnnotationLayer.js +20 -17
  62. package/dist/components/page/CanvasLayer.js +20 -17
  63. package/dist/components/page/DualPage.js +1 -1
  64. package/dist/components/page/RPPage.js +20 -17
  65. package/dist/components/page/SinglePage.js +1 -1
  66. package/dist/components/page/TextHighlightLayer.js +20 -17
  67. package/dist/components/page/TextLayer.js +20 -17
  68. package/dist/components/ui/Checkbox.js +125 -239
  69. package/dist/components/ui/DropDown.js +13 -19
  70. package/dist/components/ui/LoadingIndicator.js +22 -5
  71. package/dist/components/ui/RPTooltip.js +424 -211
  72. package/dist/contexts/PaginationContext.js +4 -4
  73. package/dist/contexts/PrintContext.js +2 -2
  74. package/dist/contexts/SearchContext.js +3 -3
  75. package/dist/contexts/ThumbnailsContext.js +1 -1
  76. package/dist/contexts/ViewportContext.js +42 -35
  77. package/dist/floating-ui.react-dom-f3f380e0.js +1447 -0
  78. package/dist/index-473557b1.js +1191 -0
  79. package/dist/index-8547fbc6.js +307 -0
  80. package/dist/main.js +76 -73
  81. package/dist/types/components/layout/RPDefaultLayout.d.ts +2 -1
  82. package/dist/types/components/layout/RPLayout.d.ts +2 -1
  83. package/dist/types/components/layout/toolbar/RPToolbar.d.ts +2 -3
  84. package/dist/types/components/layout/toolbar/ToolbarCustom.d.ts +2 -2
  85. package/dist/types/components/layout/toolbar/ToolbarDefault.d.ts +4 -0
  86. package/dist/types/components/layout/toolbar/ToolbarLayout.d.ts +3 -0
  87. package/dist/types/components/layout/toolbar/tools/defaults/RPHorizontalBar.d.ts +3 -0
  88. package/dist/types/components/layout/toolbar/tools/defaults/RPVerticalBar.d.ts +3 -0
  89. package/dist/types/main.d.ts +3 -3
  90. package/dist/types/utils/types.d.ts +17 -17
  91. package/dist/utils/hooks/useFileDownload.js +20 -17
  92. package/dist/utils/hooks/useLicense.js +1 -1
  93. package/dist/utils/hooks/usePaginate.js +20 -17
  94. package/dist/utils/hooks/usePresentPage.js +20 -17
  95. package/dist/utils/hooks/usePrint.js +20 -17
  96. package/dist/utils/hooks/useScrollToPage.js +20 -17
  97. package/dist/utils/hooks/useSearch.js +20 -17
  98. package/dist/utils/hooks/useThumbnail.js +20 -17
  99. package/dist/utils/hooks/useVirtualReactWindow.js +20 -17
  100. package/package.json +1 -1
  101. package/dist/RPLayout-5892502c.js +0 -3494
  102. package/dist/SearchCloseButton-cbf182aa.js +0 -33
  103. package/dist/assets/RPLayout.css +0 -1
  104. package/dist/components/layout/toolbar/tools/defaults/LeftSidebarDefaultTools.js +0 -16
  105. package/dist/index-00f8683a.js +0 -1672
  106. package/dist/index-5f66a29f.js +0 -1681
  107. package/dist/index-6b37f504.js +0 -332
  108. package/dist/types/components/layout/toolbar/tools/defaults/LeftSidebarDefaultTools.d.ts +0 -3
  109. package/dist/types/components/layout/toolbar/tools/defaults/TopbarDefaultTools.d.ts +0 -3
  110. /package/dist/assets/{RPDropFileZone.css → RPTheme.css} +0 -0
  111. /package/dist/assets/{SearchCloseButton.css → SearchTool.css} +0 -0
@@ -1,217 +1,430 @@
1
- import { jsx as p, jsxs as L } from "react/jsx-runtime";
2
- import * as s from "react";
3
- import { P as M, c as K, e as J, u as j, a as g, b as Q, f as Z } from "../../index-6b37f504.js";
4
- import { c as G, u as $, R as ee, A as te, D as oe, C as re, a as ne } from "../../index-5f66a29f.js";
5
- import { withRef as se } from "../../utils/withRef.js";
6
- import '../../assets/RPTooltip.css';var ae = Object.freeze({
7
- // See: https://github.com/twbs/bootstrap/blob/main/scss/mixins/_visually-hidden.scss
8
- position: "absolute",
9
- border: 0,
10
- width: 1,
11
- height: 1,
12
- padding: 0,
13
- margin: -1,
14
- overflow: "hidden",
15
- clip: "rect(0, 0, 0, 0)",
16
- whiteSpace: "nowrap",
17
- wordWrap: "normal"
18
- }), ie = "VisuallyHidden", F = s.forwardRef(
19
- (e, o) => /* @__PURE__ */ p(
20
- M.span,
1
+ import { jsx as d, jsxs as j } from "react/jsx-runtime";
2
+ import * as a from "react";
3
+ import { P as O, c as ae, u as k, f as We, g as Ye, h as oe, e as Be, a as E, b as Ge, i as Xe } from "../../index-8547fbc6.js";
4
+ import { a as Ve, b as Ue, o as qe, s as ze, f as Ze, c as Ke, d as Je, h as Qe, l as et, u as tt, D as rt } from "../../floating-ui.react-dom-f3f380e0.js";
5
+ import { withRef as ot } from "../../utils/withRef.js";
6
+ import '../../assets/RPTooltip.css';var nt = "Arrow", se = a.forwardRef((e, r) => {
7
+ const { children: t, width: o = 10, height: n = 5, ...s } = e;
8
+ return /* @__PURE__ */ d(
9
+ O.svg,
10
+ {
11
+ ...s,
12
+ ref: r,
13
+ width: o,
14
+ height: n,
15
+ viewBox: "0 0 30 10",
16
+ preserveAspectRatio: "none",
17
+ children: e.asChild ? t : /* @__PURE__ */ d("polygon", { points: "0,0 30,0 15,10" })
18
+ }
19
+ );
20
+ });
21
+ se.displayName = nt;
22
+ var at = se, B = "Popper", [ie, le] = ae(B), [st, ce] = ie(B), de = (e) => {
23
+ const { __scopePopper: r, children: t } = e, [o, n] = a.useState(null);
24
+ return /* @__PURE__ */ d(st, { scope: r, anchor: o, onAnchorChange: n, children: t });
25
+ };
26
+ de.displayName = B;
27
+ var pe = "PopperAnchor", ue = a.forwardRef(
28
+ (e, r) => {
29
+ const { __scopePopper: t, virtualRef: o, ...n } = e, s = ce(pe, t), i = a.useRef(null), h = k(r, i);
30
+ return a.useEffect(() => {
31
+ s.onAnchorChange((o == null ? void 0 : o.current) || i.current);
32
+ }), o ? null : /* @__PURE__ */ d(O.div, { ...n, ref: h });
33
+ }
34
+ );
35
+ ue.displayName = pe;
36
+ var G = "PopperContent", [it, lt] = ie(G), fe = a.forwardRef(
37
+ (e, r) => {
38
+ var Z, K, J, Q, ee, te;
39
+ const {
40
+ __scopePopper: t,
41
+ side: o = "bottom",
42
+ sideOffset: n = 0,
43
+ align: s = "center",
44
+ alignOffset: i = 0,
45
+ arrowPadding: h = 0,
46
+ avoidCollisions: l = !0,
47
+ collisionBoundary: p = [],
48
+ collisionPadding: c = 0,
49
+ sticky: f = "partial",
50
+ hideWhenDetached: y = !1,
51
+ updatePositionStrategy: u = "optimized",
52
+ onPlaced: v,
53
+ ...g
54
+ } = e, m = ce(G, t), [w, x] = a.useState(null), T = k(r, (_) => x(_)), [C, b] = a.useState(null), P = We(C), N = (P == null ? void 0 : P.width) ?? 0, V = (P == null ? void 0 : P.height) ?? 0, Ee = o + (s !== "center" ? "-" + s : ""), Re = typeof c == "number" ? c : { top: 0, right: 0, bottom: 0, left: 0, ...c }, U = Array.isArray(p) ? p : [p], _e = U.length > 0, D = {
55
+ padding: Re,
56
+ boundary: U.filter(dt),
57
+ // with `strategy: 'fixed'`, this is the only way to get it to respect boundaries
58
+ altBoundary: _e
59
+ }, { refs: Oe, floatingStyles: q, placement: Ne, isPositioned: S, middlewareData: A } = Ve({
60
+ // default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues
61
+ strategy: "fixed",
62
+ placement: Ee,
63
+ whileElementsMounted: (..._) => Ue(..._, {
64
+ animationFrame: u === "always"
65
+ }),
66
+ elements: {
67
+ reference: m.anchor
68
+ },
69
+ middleware: [
70
+ qe({ mainAxis: n + V, alignmentAxis: i }),
71
+ l && ze({
72
+ mainAxis: !0,
73
+ crossAxis: !1,
74
+ limiter: f === "partial" ? et() : void 0,
75
+ ...D
76
+ }),
77
+ l && Ze({ ...D }),
78
+ Ke({
79
+ ...D,
80
+ apply: ({ elements: _, rects: re, availableWidth: Me, availableHeight: $e }) => {
81
+ const { width: Fe, height: je } = re.reference, I = _.floating.style;
82
+ I.setProperty("--radix-popper-available-width", `${Me}px`), I.setProperty("--radix-popper-available-height", `${$e}px`), I.setProperty("--radix-popper-anchor-width", `${Fe}px`), I.setProperty("--radix-popper-anchor-height", `${je}px`);
83
+ }
84
+ }),
85
+ C && Je({ element: C, padding: h }),
86
+ pt({ arrowWidth: N, arrowHeight: V }),
87
+ y && Qe({ strategy: "referenceHidden", ...D })
88
+ ]
89
+ }), [z, De] = ge(Ne), H = Ye(v);
90
+ oe(() => {
91
+ S && (H == null || H());
92
+ }, [S, H]);
93
+ const Se = (Z = A.arrow) == null ? void 0 : Z.x, He = (K = A.arrow) == null ? void 0 : K.y, Ie = ((J = A.arrow) == null ? void 0 : J.centerOffset) !== 0, [ke, Le] = a.useState();
94
+ return oe(() => {
95
+ w && Le(window.getComputedStyle(w).zIndex);
96
+ }, [w]), /* @__PURE__ */ d(
97
+ "div",
98
+ {
99
+ ref: Oe.setFloating,
100
+ "data-radix-popper-content-wrapper": "",
101
+ style: {
102
+ ...q,
103
+ transform: S ? q.transform : "translate(0, -200%)",
104
+ // keep off the page when measuring
105
+ minWidth: "max-content",
106
+ zIndex: ke,
107
+ "--radix-popper-transform-origin": [
108
+ (Q = A.transformOrigin) == null ? void 0 : Q.x,
109
+ (ee = A.transformOrigin) == null ? void 0 : ee.y
110
+ ].join(" "),
111
+ // hide the content if using the hide middleware and should be hidden
112
+ // set visibility to hidden and disable pointer events so the UI behaves
113
+ // as if the PopperContent isn't there at all
114
+ ...((te = A.hide) == null ? void 0 : te.referenceHidden) && {
115
+ visibility: "hidden",
116
+ pointerEvents: "none"
117
+ }
118
+ },
119
+ dir: e.dir,
120
+ children: /* @__PURE__ */ d(
121
+ it,
122
+ {
123
+ scope: t,
124
+ placedSide: z,
125
+ onArrowChange: b,
126
+ arrowX: Se,
127
+ arrowY: He,
128
+ shouldHideArrow: Ie,
129
+ children: /* @__PURE__ */ d(
130
+ O.div,
131
+ {
132
+ "data-side": z,
133
+ "data-align": De,
134
+ ...g,
135
+ ref: T,
136
+ style: {
137
+ ...g.style,
138
+ // if the PopperContent hasn't been placed yet (not all measurements done)
139
+ // we prevent animations so that users's animation don't kick in too early referring wrong sides
140
+ animation: S ? void 0 : "none"
141
+ }
142
+ }
143
+ )
144
+ }
145
+ )
146
+ }
147
+ );
148
+ }
149
+ );
150
+ fe.displayName = G;
151
+ var he = "PopperArrow", ct = {
152
+ top: "bottom",
153
+ right: "left",
154
+ bottom: "top",
155
+ left: "right"
156
+ }, ve = a.forwardRef(function(r, t) {
157
+ const { __scopePopper: o, ...n } = r, s = lt(he, o), i = ct[s.placedSide];
158
+ return (
159
+ // we have to use an extra wrapper because `ResizeObserver` (used by `useSize`)
160
+ // doesn't report size as we'd expect on SVG elements.
161
+ // it reports their bounding box which is effectively the largest path inside the SVG.
162
+ /* @__PURE__ */ d(
163
+ "span",
164
+ {
165
+ ref: s.onArrowChange,
166
+ style: {
167
+ position: "absolute",
168
+ left: s.arrowX,
169
+ top: s.arrowY,
170
+ [i]: 0,
171
+ transformOrigin: {
172
+ top: "",
173
+ right: "0 0",
174
+ bottom: "center 0",
175
+ left: "100% 0"
176
+ }[s.placedSide],
177
+ transform: {
178
+ top: "translateY(100%)",
179
+ right: "translateY(50%) rotate(90deg) translateX(-50%)",
180
+ bottom: "rotate(180deg)",
181
+ left: "translateY(50%) rotate(-90deg) translateX(50%)"
182
+ }[s.placedSide],
183
+ visibility: s.shouldHideArrow ? "hidden" : void 0
184
+ },
185
+ children: /* @__PURE__ */ d(
186
+ at,
187
+ {
188
+ ...n,
189
+ ref: t,
190
+ style: {
191
+ ...n.style,
192
+ // ensures the element can be measured correctly (mostly for if SVG)
193
+ display: "block"
194
+ }
195
+ }
196
+ )
197
+ }
198
+ )
199
+ );
200
+ });
201
+ ve.displayName = he;
202
+ function dt(e) {
203
+ return e !== null;
204
+ }
205
+ var pt = (e) => ({
206
+ name: "transformOrigin",
207
+ options: e,
208
+ fn(r) {
209
+ var m, w, x;
210
+ const { placement: t, rects: o, middlewareData: n } = r, i = ((m = n.arrow) == null ? void 0 : m.centerOffset) !== 0, h = i ? 0 : e.arrowWidth, l = i ? 0 : e.arrowHeight, [p, c] = ge(t), f = { start: "0%", center: "50%", end: "100%" }[c], y = (((w = n.arrow) == null ? void 0 : w.x) ?? 0) + h / 2, u = (((x = n.arrow) == null ? void 0 : x.y) ?? 0) + l / 2;
211
+ let v = "", g = "";
212
+ return p === "bottom" ? (v = i ? f : `${y}px`, g = `${-l}px`) : p === "top" ? (v = i ? f : `${y}px`, g = `${o.floating.height + l}px`) : p === "right" ? (v = `${-l}px`, g = i ? f : `${u}px`) : p === "left" && (v = `${o.floating.width + l}px`, g = i ? f : `${u}px`), { data: { x: v, y: g } };
213
+ }
214
+ });
215
+ function ge(e) {
216
+ const [r, t = "center"] = e.split("-");
217
+ return [r, t];
218
+ }
219
+ var ut = de, ft = ue, ht = fe, vt = ve, gt = "VisuallyHidden", ye = a.forwardRef(
220
+ (e, r) => /* @__PURE__ */ d(
221
+ O.span,
21
222
  {
22
223
  ...e,
23
- ref: o,
24
- style: { ...ae, ...e.style }
224
+ ref: r,
225
+ style: {
226
+ // See: https://github.com/twbs/bootstrap/blob/main/scss/mixins/_visually-hidden.scss
227
+ position: "absolute",
228
+ border: 0,
229
+ width: 1,
230
+ height: 1,
231
+ padding: 0,
232
+ margin: -1,
233
+ overflow: "hidden",
234
+ clip: "rect(0, 0, 0, 0)",
235
+ whiteSpace: "nowrap",
236
+ wordWrap: "normal",
237
+ ...e.style
238
+ }
25
239
  }
26
240
  )
27
241
  );
28
- F.displayName = ie;
29
- var le = F, [_, Oe] = K("Tooltip", [
30
- G
31
- ]), A = G(), V = "TooltipProvider", ce = 700, O = "tooltip.open", [ue, I] = _(V), Y = (e) => {
242
+ ye.displayName = gt;
243
+ var yt = ye, [L, Ft] = ae("Tooltip", [
244
+ le
245
+ ]), M = le(), me = "TooltipProvider", mt = 700, W = "tooltip.open", [wt, X] = L(me), we = (e) => {
32
246
  const {
33
- __scopeTooltip: o,
34
- delayDuration: t = ce,
35
- skipDelayDuration: r = 300,
247
+ __scopeTooltip: r,
248
+ delayDuration: t = mt,
249
+ skipDelayDuration: o = 300,
36
250
  disableHoverableContent: n = !1,
37
- children: l
38
- } = e, i = s.useRef(!0), v = s.useRef(!1), a = s.useRef(0);
39
- return s.useEffect(() => {
40
- const d = a.current;
41
- return () => window.clearTimeout(d);
42
- }, []), /* @__PURE__ */ p(
43
- ue,
251
+ children: s
252
+ } = e, [i, h] = a.useState(!0), l = a.useRef(!1), p = a.useRef(0);
253
+ return a.useEffect(() => {
254
+ const c = p.current;
255
+ return () => window.clearTimeout(c);
256
+ }, []), /* @__PURE__ */ d(
257
+ wt,
44
258
  {
45
- scope: o,
46
- isOpenDelayedRef: i,
259
+ scope: r,
260
+ isOpenDelayed: i,
47
261
  delayDuration: t,
48
- onOpen: s.useCallback(() => {
49
- window.clearTimeout(a.current), i.current = !1;
262
+ onOpen: a.useCallback(() => {
263
+ window.clearTimeout(p.current), h(!1);
50
264
  }, []),
51
- onClose: s.useCallback(() => {
52
- window.clearTimeout(a.current), a.current = window.setTimeout(
53
- () => i.current = !0,
54
- r
265
+ onClose: a.useCallback(() => {
266
+ window.clearTimeout(p.current), p.current = window.setTimeout(
267
+ () => h(!0),
268
+ o
55
269
  );
56
- }, [r]),
57
- isPointerInTransitRef: v,
58
- onPointerInTransitChange: s.useCallback((d) => {
59
- v.current = d;
270
+ }, [o]),
271
+ isPointerInTransitRef: l,
272
+ onPointerInTransitChange: a.useCallback((c) => {
273
+ l.current = c;
60
274
  }, []),
61
275
  disableHoverableContent: n,
62
- children: l
276
+ children: s
63
277
  }
64
278
  );
65
279
  };
66
- Y.displayName = V;
67
- var P = "Tooltip", [pe, D] = _(P), B = (e) => {
280
+ we.displayName = me;
281
+ var $ = "Tooltip", [xt, F] = L($), xe = (e) => {
68
282
  const {
69
- __scopeTooltip: o,
283
+ __scopeTooltip: r,
70
284
  children: t,
71
- open: r,
72
- defaultOpen: n,
73
- onOpenChange: l,
285
+ open: o,
286
+ defaultOpen: n = !1,
287
+ onOpenChange: s,
74
288
  disableHoverableContent: i,
75
- delayDuration: v
76
- } = e, a = I(P, e.__scopeTooltip), d = A(o), [c, f] = s.useState(null), h = $(), u = s.useRef(0), y = i ?? a.disableHoverableContent, C = v ?? a.delayDuration, T = s.useRef(!1), [x, m] = J({
77
- prop: r,
78
- defaultProp: n ?? !1,
79
- onChange: (S) => {
80
- S ? (a.onOpen(), document.dispatchEvent(new CustomEvent(O))) : a.onClose(), l == null || l(S);
81
- },
82
- caller: P
83
- }), b = s.useMemo(() => x ? T.current ? "delayed-open" : "instant-open" : "closed", [x]), E = s.useCallback(() => {
84
- window.clearTimeout(u.current), u.current = 0, T.current = !1, m(!0);
85
- }, [m]), R = s.useCallback(() => {
86
- window.clearTimeout(u.current), u.current = 0, m(!1);
87
- }, [m]), N = s.useCallback(() => {
289
+ delayDuration: h
290
+ } = e, l = X($, e.__scopeTooltip), p = M(r), [c, f] = a.useState(null), y = tt(), u = a.useRef(0), v = i ?? l.disableHoverableContent, g = h ?? l.delayDuration, m = a.useRef(!1), [w = !1, x] = Be({
291
+ prop: o,
292
+ defaultProp: n,
293
+ onChange: (N) => {
294
+ N ? (l.onOpen(), document.dispatchEvent(new CustomEvent(W))) : l.onClose(), s == null || s(N);
295
+ }
296
+ }), T = a.useMemo(() => w ? m.current ? "delayed-open" : "instant-open" : "closed", [w]), C = a.useCallback(() => {
297
+ window.clearTimeout(u.current), u.current = 0, m.current = !1, x(!0);
298
+ }, [x]), b = a.useCallback(() => {
299
+ window.clearTimeout(u.current), u.current = 0, x(!1);
300
+ }, [x]), P = a.useCallback(() => {
88
301
  window.clearTimeout(u.current), u.current = window.setTimeout(() => {
89
- T.current = !0, m(!0), u.current = 0;
90
- }, C);
91
- }, [C, m]);
92
- return s.useEffect(() => () => {
302
+ m.current = !0, x(!0), u.current = 0;
303
+ }, g);
304
+ }, [g, x]);
305
+ return a.useEffect(() => () => {
93
306
  u.current && (window.clearTimeout(u.current), u.current = 0);
94
- }, []), /* @__PURE__ */ p(ee, { ...d, children: /* @__PURE__ */ p(
95
- pe,
307
+ }, []), /* @__PURE__ */ d(ut, { ...p, children: /* @__PURE__ */ d(
308
+ xt,
96
309
  {
97
- scope: o,
98
- contentId: h,
99
- open: x,
100
- stateAttribute: b,
310
+ scope: r,
311
+ contentId: y,
312
+ open: w,
313
+ stateAttribute: T,
101
314
  trigger: c,
102
315
  onTriggerChange: f,
103
- onTriggerEnter: s.useCallback(() => {
104
- a.isOpenDelayedRef.current ? N() : E();
105
- }, [a.isOpenDelayedRef, N, E]),
106
- onTriggerLeave: s.useCallback(() => {
107
- y ? R() : (window.clearTimeout(u.current), u.current = 0);
108
- }, [R, y]),
109
- onOpen: E,
110
- onClose: R,
111
- disableHoverableContent: y,
316
+ onTriggerEnter: a.useCallback(() => {
317
+ l.isOpenDelayed ? P() : C();
318
+ }, [l.isOpenDelayed, P, C]),
319
+ onTriggerLeave: a.useCallback(() => {
320
+ v ? b() : (window.clearTimeout(u.current), u.current = 0);
321
+ }, [b, v]),
322
+ onOpen: C,
323
+ onClose: b,
324
+ disableHoverableContent: v,
112
325
  children: t
113
326
  }
114
327
  ) });
115
328
  };
116
- B.displayName = P;
117
- var k = "TooltipTrigger", U = s.forwardRef(
118
- (e, o) => {
119
- const { __scopeTooltip: t, ...r } = e, n = D(k, t), l = I(k, t), i = A(t), v = s.useRef(null), a = j(o, v, n.onTriggerChange), d = s.useRef(!1), c = s.useRef(!1), f = s.useCallback(() => d.current = !1, []);
120
- return s.useEffect(() => () => document.removeEventListener("pointerup", f), [f]), /* @__PURE__ */ p(te, { asChild: !0, ...i, children: /* @__PURE__ */ p(
121
- M.button,
329
+ xe.displayName = $;
330
+ var Y = "TooltipTrigger", Ce = a.forwardRef(
331
+ (e, r) => {
332
+ const { __scopeTooltip: t, ...o } = e, n = F(Y, t), s = X(Y, t), i = M(t), h = a.useRef(null), l = k(r, h, n.onTriggerChange), p = a.useRef(!1), c = a.useRef(!1), f = a.useCallback(() => p.current = !1, []);
333
+ return a.useEffect(() => () => document.removeEventListener("pointerup", f), [f]), /* @__PURE__ */ d(ft, { asChild: !0, ...i, children: /* @__PURE__ */ d(
334
+ O.button,
122
335
  {
123
336
  "aria-describedby": n.open ? n.contentId : void 0,
124
337
  "data-state": n.stateAttribute,
125
- ...r,
126
- ref: a,
127
- onPointerMove: g(e.onPointerMove, (h) => {
128
- h.pointerType !== "touch" && !c.current && !l.isPointerInTransitRef.current && (n.onTriggerEnter(), c.current = !0);
338
+ ...o,
339
+ ref: l,
340
+ onPointerMove: E(e.onPointerMove, (y) => {
341
+ y.pointerType !== "touch" && !c.current && !s.isPointerInTransitRef.current && (n.onTriggerEnter(), c.current = !0);
129
342
  }),
130
- onPointerLeave: g(e.onPointerLeave, () => {
343
+ onPointerLeave: E(e.onPointerLeave, () => {
131
344
  n.onTriggerLeave(), c.current = !1;
132
345
  }),
133
- onPointerDown: g(e.onPointerDown, () => {
134
- n.open && n.onClose(), d.current = !0, document.addEventListener("pointerup", f, { once: !0 });
346
+ onPointerDown: E(e.onPointerDown, () => {
347
+ p.current = !0, document.addEventListener("pointerup", f, { once: !0 });
135
348
  }),
136
- onFocus: g(e.onFocus, () => {
137
- d.current || n.onOpen();
349
+ onFocus: E(e.onFocus, () => {
350
+ p.current || n.onOpen();
138
351
  }),
139
- onBlur: g(e.onBlur, n.onClose),
140
- onClick: g(e.onClick, n.onClose)
352
+ onBlur: E(e.onBlur, n.onClose),
353
+ onClick: E(e.onClick, n.onClose)
141
354
  }
142
355
  ) });
143
356
  }
144
357
  );
145
- U.displayName = k;
146
- var de = "TooltipPortal", [ke, fe] = _(de, {
358
+ Ce.displayName = Y;
359
+ var Ct = "TooltipPortal", [jt, Pt] = L(Ct, {
147
360
  forceMount: void 0
148
- }), w = "TooltipContent", q = s.forwardRef(
149
- (e, o) => {
150
- const t = fe(w, e.__scopeTooltip), { forceMount: r = t.forceMount, side: n = "top", ...l } = e, i = D(w, e.__scopeTooltip);
151
- return /* @__PURE__ */ p(Q, { present: r || i.open, children: i.disableHoverableContent ? /* @__PURE__ */ p(W, { side: n, ...l, ref: o }) : /* @__PURE__ */ p(ve, { side: n, ...l, ref: o }) });
361
+ }), R = "TooltipContent", Pe = a.forwardRef(
362
+ (e, r) => {
363
+ const t = Pt(R, e.__scopeTooltip), { forceMount: o = t.forceMount, side: n = "top", ...s } = e, i = F(R, e.__scopeTooltip);
364
+ return /* @__PURE__ */ d(Ge, { present: o || i.open, children: i.disableHoverableContent ? /* @__PURE__ */ d(Te, { side: n, ...s, ref: r }) : /* @__PURE__ */ d(Tt, { side: n, ...s, ref: r }) });
152
365
  }
153
- ), ve = s.forwardRef((e, o) => {
154
- const t = D(w, e.__scopeTooltip), r = I(w, e.__scopeTooltip), n = s.useRef(null), l = j(o, n), [i, v] = s.useState(null), { trigger: a, onClose: d } = t, c = n.current, { onPointerInTransitChange: f } = r, h = s.useCallback(() => {
155
- v(null), f(!1);
156
- }, [f]), u = s.useCallback(
157
- (y, C) => {
158
- const T = y.currentTarget, x = { x: y.clientX, y: y.clientY }, m = Ce(x, T.getBoundingClientRect()), b = me(x, m), E = xe(C.getBoundingClientRect()), R = we([...b, ...E]);
159
- v(R), f(!0);
366
+ ), Tt = a.forwardRef((e, r) => {
367
+ const t = F(R, e.__scopeTooltip), o = X(R, e.__scopeTooltip), n = a.useRef(null), s = k(r, n), [i, h] = a.useState(null), { trigger: l, onClose: p } = t, c = n.current, { onPointerInTransitChange: f } = o, y = a.useCallback(() => {
368
+ h(null), f(!1);
369
+ }, [f]), u = a.useCallback(
370
+ (v, g) => {
371
+ const m = v.currentTarget, w = { x: v.clientX, y: v.clientY }, x = Et(w, m.getBoundingClientRect()), T = Rt(w, x), C = _t(g.getBoundingClientRect()), b = Nt([...T, ...C]);
372
+ h(b), f(!0);
160
373
  },
161
374
  [f]
162
375
  );
163
- return s.useEffect(() => () => h(), [h]), s.useEffect(() => {
164
- if (a && c) {
165
- const y = (T) => u(T, c), C = (T) => u(T, a);
166
- return a.addEventListener("pointerleave", y), c.addEventListener("pointerleave", C), () => {
167
- a.removeEventListener("pointerleave", y), c.removeEventListener("pointerleave", C);
376
+ return a.useEffect(() => () => y(), [y]), a.useEffect(() => {
377
+ if (l && c) {
378
+ const v = (m) => u(m, c), g = (m) => u(m, l);
379
+ return l.addEventListener("pointerleave", v), c.addEventListener("pointerleave", g), () => {
380
+ l.removeEventListener("pointerleave", v), c.removeEventListener("pointerleave", g);
168
381
  };
169
382
  }
170
- }, [a, c, u, h]), s.useEffect(() => {
383
+ }, [l, c, u, y]), a.useEffect(() => {
171
384
  if (i) {
172
- const y = (C) => {
173
- const T = C.target, x = { x: C.clientX, y: C.clientY }, m = (a == null ? void 0 : a.contains(T)) || (c == null ? void 0 : c.contains(T)), b = !ge(x, i);
174
- m ? h() : b && (h(), d());
385
+ const v = (g) => {
386
+ const m = g.target, w = { x: g.clientX, y: g.clientY }, x = (l == null ? void 0 : l.contains(m)) || (c == null ? void 0 : c.contains(m)), T = !Ot(w, i);
387
+ x ? y() : T && (y(), p());
175
388
  };
176
- return document.addEventListener("pointermove", y), () => document.removeEventListener("pointermove", y);
389
+ return document.addEventListener("pointermove", v), () => document.removeEventListener("pointermove", v);
177
390
  }
178
- }, [a, c, i, d, h]), /* @__PURE__ */ p(W, { ...e, ref: l });
179
- }), [he, ye] = _(P, { isInside: !1 }), Te = Z("TooltipContent"), W = s.forwardRef(
180
- (e, o) => {
391
+ }, [l, c, i, p, y]), /* @__PURE__ */ d(Te, { ...e, ref: s });
392
+ }), [bt, At] = L($, { isInside: !1 }), Te = a.forwardRef(
393
+ (e, r) => {
181
394
  const {
182
395
  __scopeTooltip: t,
183
- children: r,
396
+ children: o,
184
397
  "aria-label": n,
185
- onEscapeKeyDown: l,
398
+ onEscapeKeyDown: s,
186
399
  onPointerDownOutside: i,
187
- ...v
188
- } = e, a = D(w, t), d = A(t), { onClose: c } = a;
189
- return s.useEffect(() => (document.addEventListener(O, c), () => document.removeEventListener(O, c)), [c]), s.useEffect(() => {
190
- if (a.trigger) {
191
- const f = (h) => {
192
- const u = h.target;
193
- u != null && u.contains(a.trigger) && c();
400
+ ...h
401
+ } = e, l = F(R, t), p = M(t), { onClose: c } = l;
402
+ return a.useEffect(() => (document.addEventListener(W, c), () => document.removeEventListener(W, c)), [c]), a.useEffect(() => {
403
+ if (l.trigger) {
404
+ const f = (y) => {
405
+ const u = y.target;
406
+ u != null && u.contains(l.trigger) && c();
194
407
  };
195
408
  return window.addEventListener("scroll", f, { capture: !0 }), () => window.removeEventListener("scroll", f, { capture: !0 });
196
409
  }
197
- }, [a.trigger, c]), /* @__PURE__ */ p(
198
- oe,
410
+ }, [l.trigger, c]), /* @__PURE__ */ d(
411
+ rt,
199
412
  {
200
413
  asChild: !0,
201
414
  disableOutsidePointerEvents: !1,
202
- onEscapeKeyDown: l,
415
+ onEscapeKeyDown: s,
203
416
  onPointerDownOutside: i,
204
417
  onFocusOutside: (f) => f.preventDefault(),
205
418
  onDismiss: c,
206
- children: /* @__PURE__ */ L(
207
- re,
419
+ children: /* @__PURE__ */ j(
420
+ ht,
208
421
  {
209
- "data-state": a.stateAttribute,
210
- ...d,
211
- ...v,
212
- ref: o,
422
+ "data-state": l.stateAttribute,
423
+ ...p,
424
+ ...h,
425
+ ref: r,
213
426
  style: {
214
- ...v.style,
427
+ ...h.style,
215
428
  "--radix-tooltip-content-transform-origin": "var(--radix-popper-transform-origin)",
216
429
  "--radix-tooltip-content-available-width": "var(--radix-popper-available-width)",
217
430
  "--radix-tooltip-content-available-height": "var(--radix-popper-available-height)",
@@ -219,8 +432,8 @@ var de = "TooltipPortal", [ke, fe] = _(de, {
219
432
  "--radix-tooltip-trigger-height": "var(--radix-popper-anchor-height)"
220
433
  },
221
434
  children: [
222
- /* @__PURE__ */ p(Te, { children: r }),
223
- /* @__PURE__ */ p(he, { scope: t, isInside: !0, children: /* @__PURE__ */ p(le, { id: a.contentId, role: "tooltip", children: n || r }) })
435
+ /* @__PURE__ */ d(Xe, { children: o }),
436
+ /* @__PURE__ */ d(bt, { scope: t, isInside: !0, children: /* @__PURE__ */ d(yt, { id: l.contentId, role: "tooltip", children: n || o }) })
224
437
  ]
225
438
  }
226
439
  )
@@ -228,127 +441,127 @@ var de = "TooltipPortal", [ke, fe] = _(de, {
228
441
  );
229
442
  }
230
443
  );
231
- q.displayName = w;
232
- var X = "TooltipArrow", z = s.forwardRef(
233
- (e, o) => {
234
- const { __scopeTooltip: t, ...r } = e, n = A(t);
235
- return ye(
236
- X,
444
+ Pe.displayName = R;
445
+ var be = "TooltipArrow", Ae = a.forwardRef(
446
+ (e, r) => {
447
+ const { __scopeTooltip: t, ...o } = e, n = M(t);
448
+ return At(
449
+ be,
237
450
  t
238
- ).isInside ? null : /* @__PURE__ */ p(ne, { ...n, ...r, ref: o });
451
+ ).isInside ? null : /* @__PURE__ */ d(vt, { ...n, ...o, ref: r });
239
452
  }
240
453
  );
241
- z.displayName = X;
242
- function Ce(e, o) {
243
- const t = Math.abs(o.top - e.y), r = Math.abs(o.bottom - e.y), n = Math.abs(o.right - e.x), l = Math.abs(o.left - e.x);
244
- switch (Math.min(t, r, n, l)) {
245
- case l:
454
+ Ae.displayName = be;
455
+ function Et(e, r) {
456
+ const t = Math.abs(r.top - e.y), o = Math.abs(r.bottom - e.y), n = Math.abs(r.right - e.x), s = Math.abs(r.left - e.x);
457
+ switch (Math.min(t, o, n, s)) {
458
+ case s:
246
459
  return "left";
247
460
  case n:
248
461
  return "right";
249
462
  case t:
250
463
  return "top";
251
- case r:
464
+ case o:
252
465
  return "bottom";
253
466
  default:
254
467
  throw new Error("unreachable");
255
468
  }
256
469
  }
257
- function me(e, o, t = 5) {
258
- const r = [];
259
- switch (o) {
470
+ function Rt(e, r, t = 5) {
471
+ const o = [];
472
+ switch (r) {
260
473
  case "top":
261
- r.push(
474
+ o.push(
262
475
  { x: e.x - t, y: e.y + t },
263
476
  { x: e.x + t, y: e.y + t }
264
477
  );
265
478
  break;
266
479
  case "bottom":
267
- r.push(
480
+ o.push(
268
481
  { x: e.x - t, y: e.y - t },
269
482
  { x: e.x + t, y: e.y - t }
270
483
  );
271
484
  break;
272
485
  case "left":
273
- r.push(
486
+ o.push(
274
487
  { x: e.x + t, y: e.y - t },
275
488
  { x: e.x + t, y: e.y + t }
276
489
  );
277
490
  break;
278
491
  case "right":
279
- r.push(
492
+ o.push(
280
493
  { x: e.x - t, y: e.y - t },
281
494
  { x: e.x - t, y: e.y + t }
282
495
  );
283
496
  break;
284
497
  }
285
- return r;
498
+ return o;
286
499
  }
287
- function xe(e) {
288
- const { top: o, right: t, bottom: r, left: n } = e;
500
+ function _t(e) {
501
+ const { top: r, right: t, bottom: o, left: n } = e;
289
502
  return [
290
- { x: n, y: o },
291
- { x: t, y: o },
503
+ { x: n, y: r },
292
504
  { x: t, y: r },
293
- { x: n, y: r }
505
+ { x: t, y: o },
506
+ { x: n, y: o }
294
507
  ];
295
508
  }
296
- function ge(e, o) {
297
- const { x: t, y: r } = e;
509
+ function Ot(e, r) {
510
+ const { x: t, y: o } = e;
298
511
  let n = !1;
299
- for (let l = 0, i = o.length - 1; l < o.length; i = l++) {
300
- const v = o[l], a = o[i], d = v.x, c = v.y, f = a.x, h = a.y;
301
- c > r != h > r && t < (f - d) * (r - c) / (h - c) + d && (n = !n);
512
+ for (let s = 0, i = r.length - 1; s < r.length; i = s++) {
513
+ const h = r[s].x, l = r[s].y, p = r[i].x, c = r[i].y;
514
+ l > o != c > o && t < (p - h) * (o - l) / (c - l) + h && (n = !n);
302
515
  }
303
516
  return n;
304
517
  }
305
- function we(e) {
306
- const o = e.slice();
307
- return o.sort((t, r) => t.x < r.x ? -1 : t.x > r.x ? 1 : t.y < r.y ? -1 : t.y > r.y ? 1 : 0), be(o);
518
+ function Nt(e) {
519
+ const r = e.slice();
520
+ return r.sort((t, o) => t.x < o.x ? -1 : t.x > o.x ? 1 : t.y < o.y ? -1 : t.y > o.y ? 1 : 0), Dt(r);
308
521
  }
309
- function be(e) {
522
+ function Dt(e) {
310
523
  if (e.length <= 1)
311
524
  return e.slice();
312
- const o = [];
313
- for (let r = 0; r < e.length; r++) {
314
- const n = e[r];
315
- for (; o.length >= 2; ) {
316
- const l = o[o.length - 1], i = o[o.length - 2];
317
- if ((l.x - i.x) * (n.y - i.y) >= (l.y - i.y) * (n.x - i.x))
318
- o.pop();
525
+ const r = [];
526
+ for (let o = 0; o < e.length; o++) {
527
+ const n = e[o];
528
+ for (; r.length >= 2; ) {
529
+ const s = r[r.length - 1], i = r[r.length - 2];
530
+ if ((s.x - i.x) * (n.y - i.y) >= (s.y - i.y) * (n.x - i.x))
531
+ r.pop();
319
532
  else
320
533
  break;
321
534
  }
322
- o.push(n);
535
+ r.push(n);
323
536
  }
324
- o.pop();
537
+ r.pop();
325
538
  const t = [];
326
- for (let r = e.length - 1; r >= 0; r--) {
327
- const n = e[r];
539
+ for (let o = e.length - 1; o >= 0; o--) {
540
+ const n = e[o];
328
541
  for (; t.length >= 2; ) {
329
- const l = t[t.length - 1], i = t[t.length - 2];
330
- if ((l.x - i.x) * (n.y - i.y) >= (l.y - i.y) * (n.x - i.x))
542
+ const s = t[t.length - 1], i = t[t.length - 2];
543
+ if ((s.x - i.x) * (n.y - i.y) >= (s.y - i.y) * (n.x - i.x))
331
544
  t.pop();
332
545
  else
333
546
  break;
334
547
  }
335
548
  t.push(n);
336
549
  }
337
- return t.pop(), o.length === 1 && t.length === 1 && o[0].x === t[0].x && o[0].y === t[0].y ? o : o.concat(t);
550
+ return t.pop(), r.length === 1 && t.length === 1 && r[0].x === t[0].x && r[0].y === t[0].y ? r : r.concat(t);
338
551
  }
339
- const Ee = "_tooltipContent_12gjy_1", Re = "_tooltipArrow_12gjy_8", Pe = "_fadeIn_12gjy_1", H = {
340
- tooltipContent: Ee,
341
- tooltipArrow: Re,
342
- fadeIn: Pe
343
- }, Ie = se(
344
- ({ children: e, content: o, className: t, style: r }, n) => /* @__PURE__ */ p(Y, { children: /* @__PURE__ */ L(B, { delayDuration: 1e3, children: [
345
- /* @__PURE__ */ p(U, { asChild: !0, children: /* @__PURE__ */ p("div", { ref: n, className: t, style: r, children: e }) }),
346
- /* @__PURE__ */ L(q, { className: H.tooltipContent, sideOffset: 5, children: [
347
- /* @__PURE__ */ p(z, { className: H.tooltipArrow }),
348
- /* @__PURE__ */ p("span", { children: o })
552
+ const St = "_tooltipContent_12gjy_1", Ht = "_tooltipArrow_12gjy_8", It = "_fadeIn_12gjy_1", ne = {
553
+ tooltipContent: St,
554
+ tooltipArrow: Ht,
555
+ fadeIn: It
556
+ }, Wt = ot(
557
+ ({ children: e, content: r, className: t, style: o }, n) => /* @__PURE__ */ d(we, { children: /* @__PURE__ */ j(xe, { delayDuration: 1e3, children: [
558
+ /* @__PURE__ */ d(Ce, { asChild: !0, children: /* @__PURE__ */ d("div", { ref: n, className: t, style: o, children: e }) }),
559
+ /* @__PURE__ */ j(Pe, { className: ne.tooltipContent, sideOffset: 5, children: [
560
+ /* @__PURE__ */ d(Ae, { className: ne.tooltipArrow }),
561
+ /* @__PURE__ */ d("span", { children: r })
349
562
  ] })
350
563
  ] }) })
351
564
  );
352
565
  export {
353
- Ie as default
566
+ Wt as default
354
567
  };