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

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 (97) hide show
  1. package/dist/{Popover-48c8394c.js → Popover-1faa77f6.js} +2 -2
  2. package/dist/RPLayout-897cb09d.js +3393 -0
  3. package/dist/assets/RPLayout.css +1 -1
  4. package/dist/{component-2aa6e53b.js → component-1da194e8.js} +1 -1
  5. package/dist/components/RPConfig.js +673 -691
  6. package/dist/components/RPController.js +1 -1
  7. package/dist/components/RPDropFileZone.js +27 -26
  8. package/dist/components/RPPages.js +9 -3
  9. package/dist/components/layout/LayoutContainer.js +9 -3
  10. package/dist/components/layout/RPDefaultLayout.js +1 -1
  11. package/dist/components/layout/RPLayout.js +9 -4
  12. package/dist/components/layout/WrapperLayout.js +8 -7
  13. package/dist/components/layout/sidebar/RPSidebar.js +3 -2
  14. package/dist/components/layout/sidebar/Thumbnail.js +1 -1
  15. package/dist/components/layout/sidebar/Thumbnails.js +1 -1
  16. package/dist/components/layout/toolbar/DarkModeTool.js +20 -18
  17. package/dist/components/layout/toolbar/DocumentDialog.js +7 -4
  18. package/dist/components/layout/toolbar/DocumentProperties.js +19 -17
  19. package/dist/components/layout/toolbar/FileDownloadTool.js +4 -2
  20. package/dist/components/layout/toolbar/FileUploadTool.js +21 -19
  21. package/dist/components/layout/toolbar/FullScreenTool.js +45 -36
  22. package/dist/components/layout/toolbar/MenuItem.js +1 -1
  23. package/dist/components/layout/toolbar/MenuSeparator.js +1 -1
  24. package/dist/components/layout/toolbar/MostPageTool.js +10 -4
  25. package/dist/components/layout/toolbar/OtherTool.js +4 -3
  26. package/dist/components/layout/toolbar/Paginate.js +4 -2
  27. package/dist/components/layout/toolbar/PrintTool.js +4 -2
  28. package/dist/components/layout/toolbar/RPToolbar.js +3 -2
  29. package/dist/components/layout/toolbar/RPToolbarEnd.js +1 -1
  30. package/dist/components/layout/toolbar/RotateTool.js +27 -25
  31. package/dist/components/layout/toolbar/ScrollModeTool.js +43 -41
  32. package/dist/components/layout/toolbar/SearchResultNavigator.js +1 -1
  33. package/dist/components/layout/toolbar/SearchTool.js +10 -4
  34. package/dist/components/layout/toolbar/SelectionModeTool.js +32 -30
  35. package/dist/components/layout/toolbar/ThumbnailTool.js +17 -0
  36. package/dist/components/layout/toolbar/ToolbarCustom.js +9 -3
  37. package/dist/components/layout/toolbar/ViewModeTool.js +33 -24
  38. package/dist/components/layout/toolbar/ZoomTool.js +5 -3
  39. package/dist/components/layout/toolbar/tools/FileDownloadTool.js +9 -13
  40. package/dist/components/layout/toolbar/tools/FileUploadTool.js +10 -14
  41. package/dist/components/layout/toolbar/tools/FullScreenTool.js +13 -17
  42. package/dist/components/layout/toolbar/tools/InputPageTool.js +1 -1
  43. package/dist/components/layout/toolbar/tools/NextPageTool.js +10 -4
  44. package/dist/components/layout/toolbar/tools/PreviousPageTool.js +1 -1
  45. package/dist/components/layout/toolbar/tools/PrintTool.js +8 -12
  46. package/dist/components/layout/toolbar/tools/ThumbnailTool.js +1 -1
  47. package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +55 -56
  48. package/dist/components/layout/toolbar/tools/defaults/LeftSidebarDefaultTools.js +16 -0
  49. package/dist/components/layout/toolbar/tools/defaults/TopbarDefaultTools.js +59 -0
  50. package/dist/components/page/AnnotationLayer.js +9 -3
  51. package/dist/components/page/CanvasLayer.js +9 -3
  52. package/dist/components/page/DualPage.js +1 -1
  53. package/dist/components/page/RPPage.js +9 -3
  54. package/dist/components/page/SinglePage.js +1 -1
  55. package/dist/components/page/TextHighlightLayer.js +9 -3
  56. package/dist/components/page/TextLayer.js +9 -3
  57. package/dist/components/ui/Checkbox.js +116 -228
  58. package/dist/components/ui/DropDown.js +1 -1
  59. package/dist/components/ui/LoadingIndicator.js +1 -1
  60. package/dist/components/ui/Popover.js +1 -1
  61. package/dist/components/ui/RPTooltip.js +207 -207
  62. package/dist/contexts/DropFileZoneContext.js +28 -29
  63. package/dist/contexts/ElementPageContext.js +54 -43
  64. package/dist/contexts/IconToolContext.js +13 -0
  65. package/dist/contexts/PaginationContext.js +3 -3
  66. package/dist/contexts/PrintContext.js +1 -1
  67. package/dist/contexts/SearchContext.js +1 -1
  68. package/dist/contexts/ThumbnailsContext.js +1 -1
  69. package/dist/contexts/ToolComponentContext.js +52 -0
  70. package/dist/contexts/ToolbarComponentContext.js +6 -3
  71. package/dist/{floating-ui.react-dom-4b1e2e46.js → floating-ui.react-dom-15b9b819.js} +380 -394
  72. package/dist/index-1cb41342.js +307 -0
  73. package/dist/{index-951f0f1f.js → index-7279fb4e.js} +456 -464
  74. package/dist/index-aa2d3884.js +140 -0
  75. package/dist/main.js +23 -19
  76. package/dist/types/components/layout/toolbar/ThumbnailTool.d.ts +2 -0
  77. package/dist/types/components/layout/toolbar/tools/defaults/LeftSidebarDefaultTools.d.ts +3 -0
  78. package/dist/types/components/layout/toolbar/tools/defaults/TopbarDefaultTools.d.ts +3 -0
  79. package/dist/types/contexts/IconToolContext.d.ts +9 -0
  80. package/dist/types/contexts/ToolComponentContext.d.ts +12 -0
  81. package/dist/types/main.d.ts +3 -1
  82. package/dist/types/utils/types.d.ts +63 -43
  83. package/dist/utils/hooks/useFileDownload.js +9 -3
  84. package/dist/utils/hooks/useLicense.js +26 -24
  85. package/dist/utils/hooks/usePageRotateContext.js +19 -20
  86. package/dist/utils/hooks/usePaginate.js +9 -3
  87. package/dist/utils/hooks/usePresentPage.js +9 -3
  88. package/dist/utils/hooks/usePrint.js +9 -3
  89. package/dist/utils/hooks/useScrollToPage.js +9 -3
  90. package/dist/utils/hooks/useSearch.js +9 -3
  91. package/dist/utils/hooks/useThumbnail.js +9 -3
  92. package/dist/utils/hooks/useVirtualReactWindow.js +9 -3
  93. package/dist/utils/types.js +6 -6
  94. package/package.json +1 -1
  95. package/dist/RPLayout-3042ec91.js +0 -3349
  96. package/dist/index-6e0e48fa.js +0 -332
  97. package/dist/index-e3a67935.js +0 -150
@@ -1,332 +0,0 @@
1
- import * as s from "react";
2
- import { jsx as v, Fragment as A } from "react/jsx-runtime";
3
- import * as E from "react-dom";
4
- function k(e, t, { checkForDefaultPrevented: n = !0 } = {}) {
5
- return function(r) {
6
- if (e == null || e(r), n === !1 || !r.defaultPrevented)
7
- return t == null ? void 0 : t(r);
8
- };
9
- }
10
- function C(e, t) {
11
- if (typeof e == "function")
12
- return e(t);
13
- e != null && (e.current = t);
14
- }
15
- function P(...e) {
16
- return (t) => {
17
- let n = !1;
18
- const o = e.map((r) => {
19
- const i = C(r, t);
20
- return !n && typeof i == "function" && (n = !0), i;
21
- });
22
- if (n)
23
- return () => {
24
- for (let r = 0; r < o.length; r++) {
25
- const i = o[r];
26
- typeof i == "function" ? i() : C(e[r], null);
27
- }
28
- };
29
- };
30
- }
31
- function x(...e) {
32
- return s.useCallback(P(...e), e);
33
- }
34
- function B(e, t) {
35
- const n = s.createContext(t), o = (i) => {
36
- const { children: u, ...c } = i, a = s.useMemo(() => c, Object.values(c));
37
- return /* @__PURE__ */ v(n.Provider, { value: a, children: u });
38
- };
39
- o.displayName = e + "Provider";
40
- function r(i) {
41
- const u = s.useContext(n);
42
- if (u)
43
- return u;
44
- if (t !== void 0)
45
- return t;
46
- throw new Error(`\`${i}\` must be used within \`${e}\``);
47
- }
48
- return [o, r];
49
- }
50
- function Z(e, t = []) {
51
- let n = [];
52
- function o(i, u) {
53
- const c = s.createContext(u), a = n.length;
54
- n = [...n, u];
55
- const l = (f) => {
56
- var g;
57
- const { scope: m, children: p, ...h } = f, S = ((g = m == null ? void 0 : m[e]) == null ? void 0 : g[a]) || c, b = s.useMemo(() => h, Object.values(h));
58
- return /* @__PURE__ */ v(S.Provider, { value: b, children: p });
59
- };
60
- l.displayName = i + "Provider";
61
- function d(f, m) {
62
- var S;
63
- const p = ((S = m == null ? void 0 : m[e]) == null ? void 0 : S[a]) || c, h = s.useContext(p);
64
- if (h)
65
- return h;
66
- if (u !== void 0)
67
- return u;
68
- throw new Error(`\`${f}\` must be used within \`${i}\``);
69
- }
70
- return [l, d];
71
- }
72
- const r = () => {
73
- const i = n.map((u) => s.createContext(u));
74
- return function(c) {
75
- const a = (c == null ? void 0 : c[e]) || i;
76
- return s.useMemo(
77
- () => ({ [`__scope${e}`]: { ...c, [e]: a } }),
78
- [c, a]
79
- );
80
- };
81
- };
82
- return r.scopeName = e, [o, R(r, ...t)];
83
- }
84
- function R(...e) {
85
- const t = e[0];
86
- if (e.length === 1)
87
- return t;
88
- const n = () => {
89
- const o = e.map((r) => ({
90
- useScope: r(),
91
- scopeName: r.scopeName
92
- }));
93
- return function(i) {
94
- const u = o.reduce((c, { useScope: a, scopeName: l }) => {
95
- const f = a(i)[`__scope${l}`];
96
- return { ...c, ...f };
97
- }, {});
98
- return s.useMemo(() => ({ [`__scope${t.scopeName}`]: u }), [u]);
99
- };
100
- };
101
- return n.scopeName = t.scopeName, n;
102
- }
103
- // @__NO_SIDE_EFFECTS__
104
- function O(e) {
105
- const t = /* @__PURE__ */ M(e), n = s.forwardRef((o, r) => {
106
- const { children: i, ...u } = o, c = s.Children.toArray(i), a = c.find(I);
107
- if (a) {
108
- const l = a.props.children, d = c.map((f) => f === a ? s.Children.count(l) > 1 ? s.Children.only(null) : s.isValidElement(l) ? l.props.children : null : f);
109
- return /* @__PURE__ */ v(t, { ...u, ref: r, children: s.isValidElement(l) ? s.cloneElement(l, void 0, d) : null });
110
- }
111
- return /* @__PURE__ */ v(t, { ...u, ref: r, children: i });
112
- });
113
- return n.displayName = `${e}.Slot`, n;
114
- }
115
- // @__NO_SIDE_EFFECTS__
116
- function M(e) {
117
- const t = s.forwardRef((n, o) => {
118
- const { children: r, ...i } = n;
119
- if (s.isValidElement(r)) {
120
- const u = _(r), c = T(i, r.props);
121
- return r.type !== s.Fragment && (c.ref = o ? P(o, u) : u), s.cloneElement(r, c);
122
- }
123
- return s.Children.count(r) > 1 ? s.Children.only(null) : null;
124
- });
125
- return t.displayName = `${e}.SlotClone`, t;
126
- }
127
- var w = Symbol("radix.slottable");
128
- // @__NO_SIDE_EFFECTS__
129
- function q(e) {
130
- const t = ({ children: n }) => /* @__PURE__ */ v(A, { children: n });
131
- return t.displayName = `${e}.Slottable`, t.__radixId = w, t;
132
- }
133
- function I(e) {
134
- return s.isValidElement(e) && typeof e.type == "function" && "__radixId" in e.type && e.type.__radixId === w;
135
- }
136
- function T(e, t) {
137
- const n = { ...t };
138
- for (const o in t) {
139
- const r = e[o], i = t[o];
140
- /^on[A-Z]/.test(o) ? r && i ? n[o] = (...c) => {
141
- const a = i(...c);
142
- return r(...c), a;
143
- } : r && (n[o] = r) : o === "style" ? n[o] = { ...r, ...i } : o === "className" && (n[o] = [r, i].filter(Boolean).join(" "));
144
- }
145
- return { ...e, ...n };
146
- }
147
- function _(e) {
148
- var o, r;
149
- let t = (o = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : o.get, n = t && "isReactWarning" in t && t.isReactWarning;
150
- return n ? e.ref : (t = (r = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : r.get, n = t && "isReactWarning" in t && t.isReactWarning, n ? e.props.ref : e.props.ref || e.ref);
151
- }
152
- var $ = [
153
- "a",
154
- "button",
155
- "div",
156
- "form",
157
- "h2",
158
- "h3",
159
- "img",
160
- "input",
161
- "label",
162
- "li",
163
- "nav",
164
- "ol",
165
- "p",
166
- "select",
167
- "span",
168
- "svg",
169
- "ul"
170
- ], G = $.reduce((e, t) => {
171
- const n = /* @__PURE__ */ O(`Primitive.${t}`), o = s.forwardRef((r, i) => {
172
- const { asChild: u, ...c } = r, a = u ? n : t;
173
- return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ v(a, { ...c, ref: i });
174
- });
175
- return o.displayName = `Primitive.${t}`, { ...e, [t]: o };
176
- }, {});
177
- function J(e, t) {
178
- e && E.flushSync(() => e.dispatchEvent(t));
179
- }
180
- var N = globalThis != null && globalThis.document ? s.useLayoutEffect : () => {
181
- };
182
- function K(e) {
183
- const [t, n] = s.useState(void 0);
184
- return N(() => {
185
- if (e) {
186
- n({ width: e.offsetWidth, height: e.offsetHeight });
187
- const o = new ResizeObserver((r) => {
188
- if (!Array.isArray(r) || !r.length)
189
- return;
190
- const i = r[0];
191
- let u, c;
192
- if ("borderBoxSize" in i) {
193
- const a = i.borderBoxSize, l = Array.isArray(a) ? a[0] : a;
194
- u = l.inlineSize, c = l.blockSize;
195
- } else
196
- u = e.offsetWidth, c = e.offsetHeight;
197
- n({ width: u, height: c });
198
- });
199
- return o.observe(e, { box: "border-box" }), () => o.unobserve(e);
200
- } else
201
- n(void 0);
202
- }, [e]), t;
203
- }
204
- function D(e, t) {
205
- return s.useReducer((n, o) => t[n][o] ?? n, e);
206
- }
207
- var U = (e) => {
208
- const { present: t, children: n } = e, o = W(t), r = typeof n == "function" ? n({ present: o.isPresent }) : s.Children.only(n), i = x(o.ref, z(r));
209
- return typeof n == "function" || o.isPresent ? s.cloneElement(r, { ref: i }) : null;
210
- };
211
- U.displayName = "Presence";
212
- function W(e) {
213
- const [t, n] = s.useState(), o = s.useRef(null), r = s.useRef(e), i = s.useRef("none"), u = e ? "mounted" : "unmounted", [c, a] = D(u, {
214
- mounted: {
215
- UNMOUNT: "unmounted",
216
- ANIMATION_OUT: "unmountSuspended"
217
- },
218
- unmountSuspended: {
219
- MOUNT: "mounted",
220
- ANIMATION_END: "unmounted"
221
- },
222
- unmounted: {
223
- MOUNT: "mounted"
224
- }
225
- });
226
- return s.useEffect(() => {
227
- const l = y(o.current);
228
- i.current = c === "mounted" ? l : "none";
229
- }, [c]), N(() => {
230
- const l = o.current, d = r.current;
231
- if (d !== e) {
232
- const m = i.current, p = y(l);
233
- e ? a("MOUNT") : p === "none" || (l == null ? void 0 : l.display) === "none" ? a("UNMOUNT") : a(d && m !== p ? "ANIMATION_OUT" : "UNMOUNT"), r.current = e;
234
- }
235
- }, [e, a]), N(() => {
236
- if (t) {
237
- let l;
238
- const d = t.ownerDocument.defaultView ?? window, f = (p) => {
239
- const S = y(o.current).includes(p.animationName);
240
- if (p.target === t && S && (a("ANIMATION_END"), !r.current)) {
241
- const b = t.style.animationFillMode;
242
- t.style.animationFillMode = "forwards", l = d.setTimeout(() => {
243
- t.style.animationFillMode === "forwards" && (t.style.animationFillMode = b);
244
- });
245
- }
246
- }, m = (p) => {
247
- p.target === t && (i.current = y(o.current));
248
- };
249
- return t.addEventListener("animationstart", m), t.addEventListener("animationcancel", f), t.addEventListener("animationend", f), () => {
250
- d.clearTimeout(l), t.removeEventListener("animationstart", m), t.removeEventListener("animationcancel", f), t.removeEventListener("animationend", f);
251
- };
252
- } else
253
- a("ANIMATION_END");
254
- }, [t, a]), {
255
- isPresent: ["mounted", "unmountSuspended"].includes(c),
256
- ref: s.useCallback((l) => {
257
- o.current = l ? getComputedStyle(l) : null, n(l);
258
- }, [])
259
- };
260
- }
261
- function y(e) {
262
- return (e == null ? void 0 : e.animationName) || "none";
263
- }
264
- function z(e) {
265
- var o, r;
266
- let t = (o = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : o.get, n = t && "isReactWarning" in t && t.isReactWarning;
267
- return n ? e.ref : (t = (r = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : r.get, n = t && "isReactWarning" in t && t.isReactWarning, n ? e.props.ref : e.props.ref || e.ref);
268
- }
269
- var L = s[" useInsertionEffect ".trim().toString()] || N;
270
- function Q({
271
- prop: e,
272
- defaultProp: t,
273
- onChange: n = () => {
274
- },
275
- caller: o
276
- }) {
277
- const [r, i, u] = j({
278
- defaultProp: t,
279
- onChange: n
280
- }), c = e !== void 0, a = c ? e : r;
281
- {
282
- const d = s.useRef(e !== void 0);
283
- s.useEffect(() => {
284
- const f = d.current;
285
- f !== c && console.warn(
286
- `${o} is changing from ${f ? "controlled" : "uncontrolled"} to ${c ? "controlled" : "uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`
287
- ), d.current = c;
288
- }, [c, o]);
289
- }
290
- const l = s.useCallback(
291
- (d) => {
292
- var f;
293
- if (c) {
294
- const m = F(d) ? d(e) : d;
295
- m !== e && ((f = u.current) == null || f.call(u, m));
296
- } else
297
- i(d);
298
- },
299
- [c, e, i, u]
300
- );
301
- return [a, l];
302
- }
303
- function j({
304
- defaultProp: e,
305
- onChange: t
306
- }) {
307
- const [n, o] = s.useState(e), r = s.useRef(n), i = s.useRef(t);
308
- return L(() => {
309
- i.current = t;
310
- }, [t]), s.useEffect(() => {
311
- var u;
312
- r.current !== n && ((u = i.current) == null || u.call(i, n), r.current = n);
313
- }, [n, r]), [n, o, i];
314
- }
315
- function F(e) {
316
- return typeof e == "function";
317
- }
318
- export {
319
- G as P,
320
- k as a,
321
- U as b,
322
- Z as c,
323
- K as d,
324
- Q as e,
325
- J as f,
326
- N as g,
327
- q as h,
328
- O as i,
329
- P as j,
330
- B as k,
331
- x as u
332
- };
@@ -1,150 +0,0 @@
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
- };