@turinhub/atomix-common-ui 0.2.2 → 0.4.0

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 (116) hide show
  1. package/README.md +34 -15
  2. package/dist/PDFSidebar-BBtucLK6.js +232 -0
  3. package/dist/PDFSidebar-BBtucLK6.js.map +1 -0
  4. package/dist/PDFSidebar-Di0D-yPS.cjs +2 -0
  5. package/dist/PDFSidebar-Di0D-yPS.cjs.map +1 -0
  6. package/dist/component-types.cjs +2 -0
  7. package/dist/component-types.cjs.map +1 -0
  8. package/dist/component-types.d.ts +2 -0
  9. package/dist/component-types.d.ts.map +1 -0
  10. package/dist/component-types.js +2 -0
  11. package/dist/component-types.js.map +1 -0
  12. package/dist/components/FileUpload.d.ts +61 -0
  13. package/dist/components/FileUpload.d.ts.map +1 -0
  14. package/dist/components/MarkdownReader.d.ts +26 -0
  15. package/dist/components/MarkdownReader.d.ts.map +1 -0
  16. package/dist/components/PDFReader.d.ts +2 -2
  17. package/dist/components/PDFReader.d.ts.map +1 -1
  18. package/dist/components/PDFSidebar.d.ts +1 -1
  19. package/dist/components/PDFSidebar.d.ts.map +1 -1
  20. package/dist/components/SimplePDFReader.d.ts +1 -1
  21. package/dist/data-table.cjs +2 -0
  22. package/dist/data-table.cjs.map +1 -0
  23. package/dist/data-table.d.ts +3 -0
  24. package/dist/data-table.d.ts.map +1 -0
  25. package/dist/data-table.js +159 -0
  26. package/dist/data-table.js.map +1 -0
  27. package/dist/delete-confirm-dialog.cjs +2 -0
  28. package/dist/delete-confirm-dialog.cjs.map +1 -0
  29. package/dist/delete-confirm-dialog.d.ts +3 -0
  30. package/dist/delete-confirm-dialog.d.ts.map +1 -0
  31. package/dist/delete-confirm-dialog.js +109 -0
  32. package/dist/delete-confirm-dialog.js.map +1 -0
  33. package/dist/file-upload.cjs +2 -0
  34. package/dist/file-upload.cjs.map +1 -0
  35. package/dist/file-upload.d.ts +3 -0
  36. package/dist/file-upload.d.ts.map +1 -0
  37. package/dist/file-upload.js +354 -0
  38. package/dist/file-upload.js.map +1 -0
  39. package/dist/{index-CN76z2bu.cjs → index-BiA_tnaq.cjs} +3 -3
  40. package/dist/{index-CN76z2bu.cjs.map → index-BiA_tnaq.cjs.map} +1 -1
  41. package/dist/{index-Ba1twkJn.js → index-BypbGNpR.js} +2 -2
  42. package/dist/{index-Ba1twkJn.js.map → index-BypbGNpR.js.map} +1 -1
  43. package/dist/index.cjs +2 -0
  44. package/dist/index.cjs.map +1 -0
  45. package/dist/index.d.ts +0 -18
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +2 -11
  48. package/dist/jsx-runtime-B4hRZ52C.js +283 -0
  49. package/dist/jsx-runtime-B4hRZ52C.js.map +1 -0
  50. package/dist/jsx-runtime-BB_1_6y_.cjs +23 -0
  51. package/dist/jsx-runtime-BB_1_6y_.cjs.map +1 -0
  52. package/dist/markdown-reader.cjs +2 -0
  53. package/dist/markdown-reader.cjs.map +1 -0
  54. package/dist/markdown-reader.d.ts +3 -0
  55. package/dist/markdown-reader.d.ts.map +1 -0
  56. package/dist/markdown-reader.js +145 -0
  57. package/dist/markdown-reader.js.map +1 -0
  58. package/dist/pdf-reader.cjs +2 -0
  59. package/dist/pdf-reader.cjs.map +1 -0
  60. package/dist/pdf-reader.d.ts +3 -0
  61. package/dist/pdf-reader.d.ts.map +1 -0
  62. package/dist/pdf-reader.js +427 -0
  63. package/dist/pdf-reader.js.map +1 -0
  64. package/dist/pdf-sidebar.cjs +2 -0
  65. package/dist/pdf-sidebar.cjs.map +1 -0
  66. package/dist/pdf-sidebar.d.ts +3 -0
  67. package/dist/pdf-sidebar.d.ts.map +1 -0
  68. package/dist/pdf-sidebar.js +5 -0
  69. package/dist/pdf-sidebar.js.map +1 -0
  70. package/dist/simple-pdf-reader.cjs +2 -0
  71. package/dist/simple-pdf-reader.cjs.map +1 -0
  72. package/dist/simple-pdf-reader.d.ts +3 -0
  73. package/dist/simple-pdf-reader.d.ts.map +1 -0
  74. package/dist/simple-pdf-reader.js +268 -0
  75. package/dist/simple-pdf-reader.js.map +1 -0
  76. package/dist/table-header.cjs +2 -0
  77. package/dist/table-header.cjs.map +1 -0
  78. package/dist/table-header.d.ts +3 -0
  79. package/dist/table-header.d.ts.map +1 -0
  80. package/dist/table-header.js +63 -0
  81. package/dist/table-header.js.map +1 -0
  82. package/dist/table-pagination.cjs +2 -0
  83. package/dist/table-pagination.cjs.map +1 -0
  84. package/dist/table-pagination.d.ts +3 -0
  85. package/dist/table-pagination.d.ts.map +1 -0
  86. package/dist/table-pagination.js +172 -0
  87. package/dist/table-pagination.js.map +1 -0
  88. package/dist/theme-switcher-content.cjs +2 -0
  89. package/dist/theme-switcher-content.cjs.map +1 -0
  90. package/dist/theme-switcher-content.d.ts +3 -0
  91. package/dist/theme-switcher-content.d.ts.map +1 -0
  92. package/dist/theme-switcher-content.js +103 -0
  93. package/dist/theme-switcher-content.js.map +1 -0
  94. package/dist/theme-switcher.cjs +2 -0
  95. package/dist/theme-switcher.cjs.map +1 -0
  96. package/dist/theme-switcher.d.ts +3 -0
  97. package/dist/theme-switcher.d.ts.map +1 -0
  98. package/dist/theme-switcher.js +140 -0
  99. package/dist/theme-switcher.js.map +1 -0
  100. package/dist/utils-B6yFEsav.js +9 -0
  101. package/dist/utils-B6yFEsav.js.map +1 -0
  102. package/dist/utils-IjLH3w2e.cjs +2 -0
  103. package/dist/utils-IjLH3w2e.cjs.map +1 -0
  104. package/dist/utils.cjs +2 -0
  105. package/dist/utils.cjs.map +1 -0
  106. package/dist/utils.d.ts +2 -0
  107. package/dist/utils.d.ts.map +1 -0
  108. package/dist/utils.js +5 -0
  109. package/dist/utils.js.map +1 -0
  110. package/package.json +161 -3
  111. package/dist/index-6lJCWESg.js +0 -1793
  112. package/dist/index-6lJCWESg.js.map +0 -1
  113. package/dist/index-C94iJmKE.cjs +0 -23
  114. package/dist/index-C94iJmKE.cjs.map +0 -1
  115. package/dist/index.c.js +0 -2
  116. package/dist/index.c.js.map +0 -1
@@ -1,1793 +0,0 @@
1
- import { clsx as Qe } from "clsx";
2
- import { twMerge as et } from "tailwind-merge";
3
- import tt, { useState as M, useEffect as te, useRef as je, useMemo as Oe, useCallback as ne, memo as rt } from "react";
4
- import { MoreVertical as st, Plus as nt, Search as lt, ChevronLeft as we, ChevronRight as ke, ZoomOut as Ie, ZoomIn as Fe, Minimize2 as Se, Maximize2 as $e, PanelLeft as at, RotateCw as it, ScrollText as ct, FileText as ot } from "lucide-react";
5
- function yt(...r) {
6
- return et(Qe(r));
7
- }
8
- var Ne = { exports: {} }, he = {};
9
- /**
10
- * @license React
11
- * react-jsx-runtime.production.js
12
- *
13
- * Copyright (c) Meta Platforms, Inc. and affiliates.
14
- *
15
- * This source code is licensed under the MIT license found in the
16
- * LICENSE file in the root directory of this source tree.
17
- */
18
- var De;
19
- function ut() {
20
- if (De) return he;
21
- De = 1;
22
- var r = Symbol.for("react.transitional.element"), j = Symbol.for("react.fragment");
23
- function c(u, a, f) {
24
- var h = null;
25
- if (f !== void 0 && (h = "" + f), a.key !== void 0 && (h = "" + a.key), "key" in a) {
26
- f = {};
27
- for (var o in a)
28
- o !== "key" && (f[o] = a[o]);
29
- } else f = a;
30
- return a = f.ref, {
31
- $$typeof: r,
32
- type: u,
33
- key: h,
34
- ref: a !== void 0 ? a : null,
35
- props: f
36
- };
37
- }
38
- return he.Fragment = j, he.jsx = c, he.jsxs = c, he;
39
- }
40
- var pe = {};
41
- /**
42
- * @license React
43
- * react-jsx-runtime.development.js
44
- *
45
- * Copyright (c) Meta Platforms, Inc. and affiliates.
46
- *
47
- * This source code is licensed under the MIT license found in the
48
- * LICENSE file in the root directory of this source tree.
49
- */
50
- var Me;
51
- function dt() {
52
- return Me || (Me = 1, process.env.NODE_ENV !== "production" && (function() {
53
- function r(t) {
54
- if (t == null) return null;
55
- if (typeof t == "function")
56
- return t.$$typeof === K ? null : t.displayName || t.name || null;
57
- if (typeof t == "string") return t;
58
- switch (t) {
59
- case L:
60
- return "Fragment";
61
- case N:
62
- return "Profiler";
63
- case W:
64
- return "StrictMode";
65
- case q:
66
- return "Suspense";
67
- case O:
68
- return "SuspenseList";
69
- case U:
70
- return "Activity";
71
- }
72
- if (typeof t == "object")
73
- switch (typeof t.tag == "number" && console.error(
74
- "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
75
- ), t.$$typeof) {
76
- case J:
77
- return "Portal";
78
- case d:
79
- return t.displayName || "Context";
80
- case g:
81
- return (t._context.displayName || "Context") + ".Consumer";
82
- case Y:
83
- var s = t.render;
84
- return t = t.displayName, t || (t = s.displayName || s.name || "", t = t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef"), t;
85
- case I:
86
- return s = t.displayName || null, s !== null ? s : r(t.type) || "Memo";
87
- case S:
88
- s = t._payload, t = t._init;
89
- try {
90
- return r(t(s));
91
- } catch {
92
- }
93
- }
94
- return null;
95
- }
96
- function j(t) {
97
- return "" + t;
98
- }
99
- function c(t) {
100
- try {
101
- j(t);
102
- var s = !1;
103
- } catch {
104
- s = !0;
105
- }
106
- if (s) {
107
- s = console;
108
- var x = s.error, D = typeof Symbol == "function" && Symbol.toStringTag && t[Symbol.toStringTag] || t.constructor.name || "Object";
109
- return x.call(
110
- s,
111
- "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
112
- D
113
- ), j(t);
114
- }
115
- }
116
- function u(t) {
117
- if (t === L) return "<>";
118
- if (typeof t == "object" && t !== null && t.$$typeof === S)
119
- return "<...>";
120
- try {
121
- var s = r(t);
122
- return s ? "<" + s + ">" : "<...>";
123
- } catch {
124
- return "<...>";
125
- }
126
- }
127
- function a() {
128
- var t = i.A;
129
- return t === null ? null : t.getOwner();
130
- }
131
- function f() {
132
- return Error("react-stack-top-frame");
133
- }
134
- function h(t) {
135
- if (C.call(t, "key")) {
136
- var s = Object.getOwnPropertyDescriptor(t, "key").get;
137
- if (s && s.isReactWarning) return !1;
138
- }
139
- return t.key !== void 0;
140
- }
141
- function o(t, s) {
142
- function x() {
143
- H || (H = !0, console.error(
144
- "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
145
- s
146
- ));
147
- }
148
- x.isReactWarning = !0, Object.defineProperty(t, "key", {
149
- get: x,
150
- configurable: !0
151
- });
152
- }
153
- function _() {
154
- var t = r(this.type);
155
- return ue[t] || (ue[t] = !0, console.error(
156
- "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
157
- )), t = this.props.ref, t !== void 0 ? t : null;
158
- }
159
- function b(t, s, x, D, X, le) {
160
- var R = x.ref;
161
- return t = {
162
- $$typeof: z,
163
- type: t,
164
- key: s,
165
- props: x,
166
- _owner: D
167
- }, (R !== void 0 ? R : null) !== null ? Object.defineProperty(t, "ref", {
168
- enumerable: !1,
169
- get: _
170
- }) : Object.defineProperty(t, "ref", { enumerable: !1, value: null }), t._store = {}, Object.defineProperty(t._store, "validated", {
171
- configurable: !1,
172
- enumerable: !1,
173
- writable: !0,
174
- value: 0
175
- }), Object.defineProperty(t, "_debugInfo", {
176
- configurable: !1,
177
- enumerable: !1,
178
- writable: !0,
179
- value: null
180
- }), Object.defineProperty(t, "_debugStack", {
181
- configurable: !1,
182
- enumerable: !1,
183
- writable: !0,
184
- value: X
185
- }), Object.defineProperty(t, "_debugTask", {
186
- configurable: !1,
187
- enumerable: !1,
188
- writable: !0,
189
- value: le
190
- }), Object.freeze && (Object.freeze(t.props), Object.freeze(t)), t;
191
- }
192
- function l(t, s, x, D, X, le) {
193
- var R = s.children;
194
- if (R !== void 0)
195
- if (D)
196
- if (E(R)) {
197
- for (D = 0; D < R.length; D++)
198
- P(R[D]);
199
- Object.freeze && Object.freeze(R);
200
- } else
201
- console.error(
202
- "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
203
- );
204
- else P(R);
205
- if (C.call(s, "key")) {
206
- R = r(t);
207
- var V = Object.keys(s).filter(function(w) {
208
- return w !== "key";
209
- });
210
- D = 0 < V.length ? "{key: someKey, " + V.join(": ..., ") + ": ...}" : "{key: someKey}", se[R + D] || (V = 0 < V.length ? "{" + V.join(": ..., ") + ": ...}" : "{}", console.error(
211
- `A props object containing a "key" prop is being spread into JSX:
212
- let props = %s;
213
- <%s {...props} />
214
- React keys must be passed directly to JSX without using spread:
215
- let props = %s;
216
- <%s key={someKey} {...props} />`,
217
- D,
218
- R,
219
- V,
220
- R
221
- ), se[R + D] = !0);
222
- }
223
- if (R = null, x !== void 0 && (c(x), R = "" + x), h(s) && (c(s.key), R = "" + s.key), "key" in s) {
224
- x = {};
225
- for (var p in s)
226
- p !== "key" && (x[p] = s[p]);
227
- } else x = s;
228
- return R && o(
229
- x,
230
- typeof t == "function" ? t.displayName || t.name || "Unknown" : t
231
- ), b(
232
- t,
233
- R,
234
- x,
235
- a(),
236
- X,
237
- le
238
- );
239
- }
240
- function P(t) {
241
- A(t) ? t._store && (t._store.validated = 1) : typeof t == "object" && t !== null && t.$$typeof === S && (t._payload.status === "fulfilled" ? A(t._payload.value) && t._payload.value._store && (t._payload.value._store.validated = 1) : t._store && (t._store.validated = 1));
242
- }
243
- function A(t) {
244
- return typeof t == "object" && t !== null && t.$$typeof === z;
245
- }
246
- var y = tt, z = Symbol.for("react.transitional.element"), J = Symbol.for("react.portal"), L = Symbol.for("react.fragment"), W = Symbol.for("react.strict_mode"), N = Symbol.for("react.profiler"), g = Symbol.for("react.consumer"), d = Symbol.for("react.context"), Y = Symbol.for("react.forward_ref"), q = Symbol.for("react.suspense"), O = Symbol.for("react.suspense_list"), I = Symbol.for("react.memo"), S = Symbol.for("react.lazy"), U = Symbol.for("react.activity"), K = Symbol.for("react.client.reference"), i = y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, C = Object.prototype.hasOwnProperty, E = Array.isArray, $ = console.createTask ? console.createTask : function() {
247
- return null;
248
- };
249
- y = {
250
- react_stack_bottom_frame: function(t) {
251
- return t();
252
- }
253
- };
254
- var H, ue = {}, re = y.react_stack_bottom_frame.bind(
255
- y,
256
- f
257
- )(), Z = $(u(f)), se = {};
258
- pe.Fragment = L, pe.jsx = function(t, s, x) {
259
- var D = 1e4 > i.recentlyCreatedOwnerStacks++;
260
- return l(
261
- t,
262
- s,
263
- x,
264
- !1,
265
- D ? Error("react-stack-top-frame") : re,
266
- D ? $(u(t)) : Z
267
- );
268
- }, pe.jsxs = function(t, s, x) {
269
- var D = 1e4 > i.recentlyCreatedOwnerStacks++;
270
- return l(
271
- t,
272
- s,
273
- x,
274
- !0,
275
- D ? Error("react-stack-top-frame") : re,
276
- D ? $(u(t)) : Z
277
- );
278
- };
279
- })()), pe;
280
- }
281
- var Ae;
282
- function mt() {
283
- return Ae || (Ae = 1, process.env.NODE_ENV === "production" ? Ne.exports = ut() : Ne.exports = dt()), Ne.exports;
284
- }
285
- var e = mt();
286
- function Nt({
287
- data: r,
288
- loading: j = !1,
289
- columns: c,
290
- rowKey: u,
291
- emptyText: a = "暂无数据",
292
- searchActiveEmptyText: f = "未找到匹配的记录",
293
- header: h,
294
- pagination: o,
295
- rowClassName: _,
296
- onRow: b,
297
- actions: l,
298
- components: P,
299
- renderCard: A,
300
- renderTable: y,
301
- renderActions: z
302
- }) {
303
- var R, V;
304
- if (!P)
305
- return /* @__PURE__ */ e.jsxs("div", { className: "p-4 text-center text-destructive", children: [
306
- "错误:请通过 components prop 注入 UI 组件",
307
- /* @__PURE__ */ e.jsx("br", {}),
308
- /* @__PURE__ */ e.jsx("code", { className: "text-sm", children: 'import { Card, Table, Button, ... } from "@/components/ui"' })
309
- ] });
310
- const {
311
- Card: J,
312
- CardContent: L,
313
- CardFooter: W,
314
- Table: N,
315
- TableBody: g,
316
- TableCell: d,
317
- TableHead: Y,
318
- TableHeader: q,
319
- TableRow: O,
320
- Button: I,
321
- DropdownMenu: S,
322
- DropdownMenuTrigger: U,
323
- DropdownMenuContent: K,
324
- DropdownMenuItem: i,
325
- DropdownMenuSeparator: C,
326
- Skeleton: E,
327
- TableHeaderComponent: $,
328
- TablePaginationComponent: H
329
- } = P, ue = (p, w) => {
330
- if (typeof u == "function")
331
- return u(p);
332
- const B = p[u];
333
- return B != null ? String(B) : `row-${w}`;
334
- }, re = !!(h != null && h.searchValue && h.searchValue.trim().length > 0), Z = !!(l != null && l.render || (R = l == null ? void 0 : l.items) != null && R.length), se = (l == null ? void 0 : l.mode) ?? ((V = l == null ? void 0 : l.items) != null && V.length ? "collapsed" : "expanded"), t = (p) => p.separator === !0, s = (p, w) => !l || !Z ? null : se === "collapsed" && l.items && l.items.length > 0 ? /* @__PURE__ */ e.jsxs(S, { children: [
335
- /* @__PURE__ */ e.jsx(U, { asChild: !0, children: /* @__PURE__ */ e.jsx(
336
- I,
337
- {
338
- variant: "ghost",
339
- className: "h-8 w-8 p-0",
340
- "aria-label": "打开行操作菜单",
341
- children: /* @__PURE__ */ e.jsx(st, { className: "h-4 w-4" })
342
- }
343
- ) }),
344
- /* @__PURE__ */ e.jsx(K, { align: "end", children: l.items.map(
345
- (B, de) => t(B) ? /* @__PURE__ */ e.jsx(C, {}, `separator-${de}`) : /* @__PURE__ */ e.jsxs(
346
- i,
347
- {
348
- onClick: () => B.onClick(p, w),
349
- className: B.className,
350
- children: [
351
- B.icon && /* @__PURE__ */ e.jsx("span", { className: "mr-2 h-4 w-4", children: B.icon }),
352
- B.label
353
- ]
354
- },
355
- `action-${de}`
356
- )
357
- ) })
358
- ] }) : l.render ? l.render(p, w) : null, x = () => /* @__PURE__ */ e.jsx(q, { children: /* @__PURE__ */ e.jsxs(O, { className: "bg-muted/50 hover:bg-muted/50", children: [
359
- c.map((p) => /* @__PURE__ */ e.jsx(
360
- Y,
361
- {
362
- className: `font-semibold text-foreground ${p.align === "center" ? "text-center" : p.align === "right" ? "text-right" : "text-left"}`,
363
- style: { width: p.width },
364
- children: p.title
365
- },
366
- String(p.key)
367
- )),
368
- Z && /* @__PURE__ */ e.jsx(Y, { className: "text-right font-semibold text-foreground", children: (l == null ? void 0 : l.title) || "操作" })
369
- ] }) }), D = () => j ? /* @__PURE__ */ e.jsx(g, { children: Array.from({ length: 5 }).map((p, w) => /* @__PURE__ */ e.jsxs(O, { children: [
370
- c.map((B) => /* @__PURE__ */ e.jsx(
371
- d,
372
- {
373
- style: { width: B.width },
374
- className: B.align === "center" ? "text-center" : B.align === "right" ? "text-right" : "",
375
- children: /* @__PURE__ */ e.jsx(E, { className: "h-4 w-full" })
376
- },
377
- String(B.key)
378
- )),
379
- Z && /* @__PURE__ */ e.jsx(d, { children: /* @__PURE__ */ e.jsx(E, { className: "ml-auto h-4 w-8" }) })
380
- ] }, w)) }) : r.length === 0 ? /* @__PURE__ */ e.jsx(g, { children: /* @__PURE__ */ e.jsx(O, { children: /* @__PURE__ */ e.jsx(
381
- d,
382
- {
383
- colSpan: c.length + (Z ? 1 : 0),
384
- className: "py-8 text-center text-muted-foreground",
385
- children: re ? f : a
386
- }
387
- ) }) }) : /* @__PURE__ */ e.jsx(g, { children: r.map((p, w) => {
388
- const B = ue(p, w), de = b == null ? void 0 : b(p, w), ie = _ == null ? void 0 : _(p, w);
389
- return /* @__PURE__ */ e.jsxs(
390
- O,
391
- {
392
- className: `${ie || ""} hover:bg-muted/50`,
393
- ...de,
394
- children: [
395
- c.map((ee) => {
396
- const me = p[ee.key], fe = ee.render ? ee.render(me, p, w) : me;
397
- return /* @__PURE__ */ e.jsx(
398
- d,
399
- {
400
- className: ee.align === "center" ? "text-center" : ee.align === "right" ? "text-right" : "",
401
- children: fe
402
- },
403
- String(ee.key)
404
- );
405
- }),
406
- Z && /* @__PURE__ */ e.jsx(d, { className: "text-right", children: z ? z(p, w) : s(p, w) })
407
- ]
408
- },
409
- B
410
- );
411
- }) }), X = (p) => /* @__PURE__ */ e.jsxs(J, { children: [
412
- h && /* @__PURE__ */ e.jsx("div", { className: "p-6 pb-0", children: /* @__PURE__ */ e.jsx($, { ...h }) }),
413
- /* @__PURE__ */ e.jsx(L, { className: "p-0", children: p }),
414
- (o == null ? void 0 : o.show) !== !1 && o && /* @__PURE__ */ e.jsx(W, { className: "border-t py-4", children: /* @__PURE__ */ e.jsx(
415
- H,
416
- {
417
- currentPage: o.currentPage,
418
- pageSize: o.pageSize,
419
- total: o.total,
420
- onPageChange: o.onPageChange,
421
- onPageSizeChange: o.onPageSizeChange,
422
- pageSizeOptions: o.pageSizeOptions,
423
- showPageSizeSelector: o.showPageSizeSelector,
424
- showJumpToPage: o.showJumpToPage,
425
- showTotal: o.showTotal,
426
- searchActive: re
427
- }
428
- ) })
429
- ] }), le = (p, w) => /* @__PURE__ */ e.jsxs(N, { children: [
430
- p,
431
- w
432
- ] });
433
- return A ? A(
434
- y ? y(x(), D()) : le(x(), D())
435
- ) : X(
436
- y ? y(x(), D()) : le(x(), D())
437
- );
438
- }
439
- function wt({
440
- open: r,
441
- onOpenChange: j,
442
- title: c,
443
- description: u,
444
- onConfirm: a,
445
- loading: f = !1,
446
- confirmText: h = "确认删除",
447
- cancelText: o = "取消",
448
- confirmButtonVariant: _ = "destructive",
449
- verification: b,
450
- components: l,
451
- loadingIcon: P
452
- }) {
453
- const [A, y] = M("");
454
- if (te(() => {
455
- r && y("");
456
- }, [r, b == null ? void 0 : b.targetValue]), !l)
457
- return /* @__PURE__ */ e.jsx("div", { className: "p-4 text-center text-destructive", children: "错误:请通过 components prop 注入 UI 组件" });
458
- const {
459
- Dialog: z,
460
- DialogContent: J,
461
- DialogHeader: L,
462
- DialogFooter: W,
463
- DialogTitle: N,
464
- DialogDescription: g,
465
- Button: d,
466
- Input: Y,
467
- Label: q
468
- } = l, O = b ? A !== b.targetValue : !1, I = () => {
469
- O || a();
470
- };
471
- return /* @__PURE__ */ e.jsx(z, { open: r, onOpenChange: j, children: /* @__PURE__ */ e.jsxs(J, { children: [
472
- /* @__PURE__ */ e.jsxs(L, { children: [
473
- /* @__PURE__ */ e.jsx(N, { asChild: !0, children: /* @__PURE__ */ e.jsx("div", { className: "flex items-center gap-2", children: c }) }),
474
- /* @__PURE__ */ e.jsx(g, { asChild: !0, children: /* @__PURE__ */ e.jsx("div", { children: u }) })
475
- ] }),
476
- b && /* @__PURE__ */ e.jsx("div", { className: "space-y-4 py-2", children: /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
477
- /* @__PURE__ */ e.jsx(q, { htmlFor: "confirm-input", children: b.label || "请输入以确认" }),
478
- /* @__PURE__ */ e.jsx(
479
- Y,
480
- {
481
- id: "confirm-input",
482
- value: A,
483
- onChange: (S) => y(S.target.value),
484
- placeholder: b.placeholder,
485
- disabled: f
486
- }
487
- )
488
- ] }) }),
489
- /* @__PURE__ */ e.jsxs(W, { children: [
490
- /* @__PURE__ */ e.jsx(
491
- d,
492
- {
493
- variant: "outline",
494
- onClick: () => j(!1),
495
- disabled: f,
496
- children: o
497
- }
498
- ),
499
- /* @__PURE__ */ e.jsxs(
500
- d,
501
- {
502
- variant: _,
503
- onClick: I,
504
- disabled: O || f,
505
- children: [
506
- f && /* @__PURE__ */ e.jsx("span", { className: "mr-2", children: P || /* @__PURE__ */ e.jsxs(
507
- "svg",
508
- {
509
- className: "h-4 w-4 animate-spin",
510
- fill: "none",
511
- viewBox: "0 0 24 24",
512
- children: [
513
- /* @__PURE__ */ e.jsx(
514
- "circle",
515
- {
516
- className: "opacity-25",
517
- cx: "12",
518
- cy: "12",
519
- r: "10",
520
- stroke: "currentColor",
521
- strokeWidth: "4"
522
- }
523
- ),
524
- /* @__PURE__ */ e.jsx(
525
- "path",
526
- {
527
- className: "opacity-75",
528
- fill: "currentColor",
529
- d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
530
- }
531
- )
532
- ]
533
- }
534
- ) }),
535
- h
536
- ]
537
- }
538
- )
539
- ] })
540
- ] }) });
541
- }
542
- function kt({
543
- title: r,
544
- searchPlaceholder: j = "搜索...",
545
- searchValue: c = "",
546
- onSearchChange: u,
547
- onSearch: a,
548
- showSearch: f = !0,
549
- action: h,
550
- actionLabel: o,
551
- onActionClick: _,
552
- loading: b = !1,
553
- components: l
554
- }) {
555
- if (!l)
556
- return /* @__PURE__ */ e.jsx("div", { className: "p-4 text-center text-destructive", children: "错误:请通过 components prop 注入 UI 组件" });
557
- const { Input: P, Button: A } = l, y = (z) => {
558
- z.key === "Enter" && a && a();
559
- };
560
- return /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-4 p-1", children: [
561
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between", children: [
562
- /* @__PURE__ */ e.jsx("div", { className: "text-lg font-semibold leading-none tracking-tight", children: r }),
563
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
564
- h && /* @__PURE__ */ e.jsx("div", { className: "flex items-center gap-2", children: h }),
565
- !h && o && _ && /* @__PURE__ */ e.jsxs(A, { onClick: _, disabled: b, size: "sm", children: [
566
- /* @__PURE__ */ e.jsx(nt, { className: "mr-2 h-4 w-4" }),
567
- o
568
- ] })
569
- ] })
570
- ] }),
571
- f && /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
572
- /* @__PURE__ */ e.jsxs("div", { className: "relative max-w-sm flex-1", children: [
573
- /* @__PURE__ */ e.jsx(lt, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
574
- /* @__PURE__ */ e.jsx(
575
- P,
576
- {
577
- placeholder: j,
578
- value: c,
579
- onChange: (z) => u == null ? void 0 : u(z.target.value),
580
- onKeyPress: y,
581
- className: "h-9 pl-8",
582
- disabled: b
583
- }
584
- )
585
- ] }),
586
- a && /* @__PURE__ */ e.jsx(
587
- A,
588
- {
589
- onClick: a,
590
- disabled: b,
591
- variant: "secondary",
592
- size: "sm",
593
- children: "搜索"
594
- }
595
- )
596
- ] })
597
- ] });
598
- }
599
- function Tt({
600
- currentPage: r,
601
- pageSize: j,
602
- total: c,
603
- onPageChange: u,
604
- onPageSizeChange: a,
605
- pageSizeOptions: f = [10, 20, 50],
606
- showPageSizeSelector: h = !0,
607
- showJumpToPage: o = !0,
608
- showTotal: _ = !0,
609
- searchActive: b = !1,
610
- components: l
611
- }) {
612
- const [P, A] = M(String(r + 1));
613
- if (te(() => {
614
- A(String(r + 1));
615
- }, [r]), !l)
616
- return /* @__PURE__ */ e.jsx("div", { className: "p-4 text-center text-destructive", children: "错误:请通过 components prop 注入 UI 组件" });
617
- const {
618
- Button: y,
619
- Select: z,
620
- SelectTrigger: J,
621
- SelectContent: L,
622
- SelectItem: W,
623
- SelectValue: N
624
- } = l, g = Math.ceil(c / j), d = Math.max(g, 1), Y = r * j + 1, q = Math.min((r + 1) * j, c), O = Array.from(
625
- /* @__PURE__ */ new Set([...f, j])
626
- ).sort((i, C) => i - C), I = h && !!a, S = d > 1, U = (i) => {
627
- const C = Math.max(0, Math.min(i, d - 1));
628
- C !== r && u(C);
629
- }, K = (() => {
630
- if (d <= 7)
631
- return Array.from({ length: d }, ($, H) => H);
632
- const i = /* @__PURE__ */ new Set([
633
- 0,
634
- 1,
635
- d - 2,
636
- d - 1,
637
- r - 1,
638
- r,
639
- r + 1
640
- ]), C = Array.from(i).filter(($) => $ >= 0 && $ < d).sort(($, H) => $ - H), E = [];
641
- for (const $ of C) {
642
- const H = E[E.length - 1];
643
- typeof H == "number" && $ - H > 1 && E.push("ellipsis"), E.push($);
644
- }
645
- return E;
646
- })();
647
- return c === 0 ? null : /* @__PURE__ */ e.jsxs(
648
- "div",
649
- {
650
- className: `flex w-full items-center gap-3 ${_ ? "justify-between" : "justify-end"}`,
651
- children: [
652
- _ && /* @__PURE__ */ e.jsx("div", { className: "text-sm text-muted-foreground", children: b ? `找到 ${c} 条匹配记录` : c > 0 ? `显示 ${Y} - ${q} 条,共 ${c} 条记录` : "暂无数据" }),
653
- /* @__PURE__ */ e.jsxs("div", { className: "flex flex-wrap items-center justify-end gap-2", children: [
654
- I && /* @__PURE__ */ e.jsxs("div", { className: "mr-2 flex items-center gap-2", children: [
655
- /* @__PURE__ */ e.jsx("span", { className: "text-sm text-muted-foreground", children: "每页" }),
656
- /* @__PURE__ */ e.jsxs(
657
- z,
658
- {
659
- value: String(j),
660
- onValueChange: (i) => {
661
- const C = Number(i);
662
- Number.isNaN(C) || C === j || !a || a(C);
663
- },
664
- children: [
665
- /* @__PURE__ */ e.jsx(J, { className: "h-8 w-[90px]", children: /* @__PURE__ */ e.jsx(N, {}) }),
666
- /* @__PURE__ */ e.jsx(L, { children: O.map((i) => /* @__PURE__ */ e.jsx(W, { value: String(i), children: i }, i)) })
667
- ]
668
- }
669
- ),
670
- /* @__PURE__ */ e.jsx("span", { className: "text-sm text-muted-foreground", children: "条" })
671
- ] }),
672
- /* @__PURE__ */ e.jsxs("div", { className: "mr-4 text-sm text-muted-foreground", children: [
673
- "第 ",
674
- r + 1,
675
- " 页,共 ",
676
- d,
677
- " 页"
678
- ] }),
679
- /* @__PURE__ */ e.jsx(
680
- y,
681
- {
682
- variant: "outline",
683
- size: "icon",
684
- onClick: () => U(r - 1),
685
- disabled: r === 0 || !S,
686
- "aria-label": "上一页",
687
- children: /* @__PURE__ */ e.jsx(we, { className: "h-4 w-4" })
688
- }
689
- ),
690
- /* @__PURE__ */ e.jsx("div", { className: "flex items-center gap-1", children: K.map(
691
- (i, C) => i === "ellipsis" ? /* @__PURE__ */ e.jsx(
692
- "span",
693
- {
694
- className: "inline-flex h-8 w-8 items-center justify-center text-sm text-muted-foreground",
695
- children: "..."
696
- },
697
- `ellipsis-${C}`
698
- ) : /* @__PURE__ */ e.jsx(
699
- y,
700
- {
701
- variant: i === r ? "default" : "outline",
702
- size: "sm",
703
- onClick: () => U(i),
704
- disabled: i === r,
705
- "aria-current": i === r ? "page" : void 0,
706
- children: i + 1
707
- },
708
- i
709
- )
710
- ) }),
711
- /* @__PURE__ */ e.jsx(
712
- y,
713
- {
714
- variant: "outline",
715
- size: "icon",
716
- onClick: () => U(r + 1),
717
- disabled: r >= d - 1 || !S,
718
- "aria-label": "下一页",
719
- children: /* @__PURE__ */ e.jsx(ke, { className: "h-4 w-4" })
720
- }
721
- ),
722
- o && /* @__PURE__ */ e.jsxs(
723
- "form",
724
- {
725
- className: "ml-1 flex items-center gap-2",
726
- onSubmit: (i) => {
727
- i.preventDefault();
728
- const C = Number.parseInt(P, 10);
729
- Number.isNaN(C) || U(C - 1);
730
- },
731
- children: [
732
- /* @__PURE__ */ e.jsx("span", { className: "text-sm text-muted-foreground", children: "跳至" }),
733
- /* @__PURE__ */ e.jsx(
734
- "input",
735
- {
736
- type: "number",
737
- min: 1,
738
- max: d,
739
- value: P,
740
- disabled: !S,
741
- onChange: (i) => A(i.target.value),
742
- className: "h-8 w-16 rounded-md border border-input bg-background px-2 text-sm",
743
- "aria-label": "跳转页码"
744
- }
745
- ),
746
- /* @__PURE__ */ e.jsx(
747
- y,
748
- {
749
- type: "submit",
750
- variant: "outline",
751
- size: "sm",
752
- disabled: !S,
753
- children: "跳转"
754
- }
755
- )
756
- ]
757
- }
758
- )
759
- ] })
760
- ]
761
- }
762
- );
763
- }
764
- const ft = [
765
- {
766
- value: "light",
767
- label: "浅色",
768
- icon: /* @__PURE__ */ e.jsxs(
769
- "svg",
770
- {
771
- className: "h-4 w-4",
772
- fill: "none",
773
- viewBox: "0 0 24 24",
774
- stroke: "currentColor",
775
- children: [
776
- /* @__PURE__ */ e.jsx("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", strokeWidth: "2" }),
777
- /* @__PURE__ */ e.jsx(
778
- "path",
779
- {
780
- className: "opacity-75",
781
- d: "M12 2v2m0 16v2M4.93 4.93l1.41 1.41m11.32 11.32l1.41 1.41M2 12h2m16 0h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41",
782
- strokeWidth: "2",
783
- strokeLinecap: "round"
784
- }
785
- )
786
- ]
787
- }
788
- )
789
- },
790
- {
791
- value: "dark",
792
- label: "深色",
793
- icon: /* @__PURE__ */ e.jsx(
794
- "svg",
795
- {
796
- className: "h-4 w-4",
797
- fill: "none",
798
- viewBox: "0 0 24 24",
799
- stroke: "currentColor",
800
- children: /* @__PURE__ */ e.jsx(
801
- "path",
802
- {
803
- d: "M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z",
804
- strokeWidth: "2",
805
- strokeLinecap: "round",
806
- strokeLinejoin: "round"
807
- }
808
- )
809
- }
810
- )
811
- },
812
- {
813
- value: "system",
814
- label: "跟随系统",
815
- icon: /* @__PURE__ */ e.jsxs(
816
- "svg",
817
- {
818
- className: "h-4 w-4",
819
- fill: "none",
820
- viewBox: "0 0 24 24",
821
- stroke: "currentColor",
822
- children: [
823
- /* @__PURE__ */ e.jsx(
824
- "rect",
825
- {
826
- x: "2",
827
- y: "3",
828
- width: "20",
829
- height: "14",
830
- rx: "2",
831
- ry: "2",
832
- strokeWidth: "2"
833
- }
834
- ),
835
- /* @__PURE__ */ e.jsx("path", { d: "M8 21h8m-4-4v4", strokeWidth: "2", strokeLinecap: "round" })
836
- ]
837
- }
838
- )
839
- }
840
- ];
841
- function Et({
842
- value: r,
843
- onValueChange: j,
844
- themes: c = ft,
845
- triggerVariant: u = "ghost",
846
- triggerSize: a = "icon",
847
- triggerClassName: f,
848
- iconSize: h = 16,
849
- showCurrentIcon: o = !0,
850
- enableSSRHandling: _ = !0,
851
- triggerContent: b,
852
- components: l,
853
- themeIcons: P
854
- }) {
855
- const [A, y] = M(!1);
856
- if (te(() => {
857
- y(!0);
858
- }, []), _ && !A)
859
- return null;
860
- if (!l)
861
- return /* @__PURE__ */ e.jsx("div", { className: "p-4 text-center text-destructive", children: "错误:请通过 components prop 注入 UI 组件" });
862
- const {
863
- DropdownMenu: z,
864
- DropdownMenuTrigger: J,
865
- DropdownMenuContent: L,
866
- DropdownMenuRadioGroup: W,
867
- DropdownMenuRadioItem: N,
868
- Button: g
869
- } = l, d = (I) => {
870
- if (P && P[I])
871
- return P[I];
872
- const S = c.find((U) => U.value === I);
873
- return S == null ? void 0 : S.icon;
874
- }, Y = d(r), q = o ? Y : null, O = h ? { width: h, height: h } : {};
875
- return /* @__PURE__ */ e.jsxs(z, { children: [
876
- /* @__PURE__ */ e.jsx(J, { asChild: !0, children: /* @__PURE__ */ e.jsx(
877
- g,
878
- {
879
- variant: u,
880
- size: a,
881
- className: f,
882
- children: b || /* @__PURE__ */ e.jsx(
883
- "span",
884
- {
885
- style: O,
886
- className: "inline-flex items-center justify-center",
887
- children: q
888
- }
889
- )
890
- }
891
- ) }),
892
- /* @__PURE__ */ e.jsx(L, { children: /* @__PURE__ */ e.jsx(W, { value: r, onValueChange: j, children: c.map((I) => /* @__PURE__ */ e.jsxs(N, { value: I.value, children: [
893
- /* @__PURE__ */ e.jsx("span", { className: "mr-2 inline-flex items-center", children: d(I.value) }),
894
- /* @__PURE__ */ e.jsx("span", { children: I.label })
895
- ] }, I.value)) }) })
896
- ] });
897
- }
898
- const xt = [
899
- {
900
- value: "light",
901
- label: "浅色",
902
- icon: /* @__PURE__ */ e.jsxs(
903
- "svg",
904
- {
905
- className: "h-4 w-4",
906
- fill: "none",
907
- viewBox: "0 0 24 24",
908
- stroke: "currentColor",
909
- children: [
910
- /* @__PURE__ */ e.jsx("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", strokeWidth: "2" }),
911
- /* @__PURE__ */ e.jsx(
912
- "path",
913
- {
914
- className: "opacity-75",
915
- d: "M12 2v2m0 16v2M4.93 4.93l1.41 1.41m11.32 11.32l1.41 1.41M2 12h2m16 0h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41",
916
- strokeWidth: "2",
917
- strokeLinecap: "round"
918
- }
919
- )
920
- ]
921
- }
922
- )
923
- },
924
- {
925
- value: "dark",
926
- label: "深色",
927
- icon: /* @__PURE__ */ e.jsx(
928
- "svg",
929
- {
930
- className: "h-4 w-4",
931
- fill: "none",
932
- viewBox: "0 0 24 24",
933
- stroke: "currentColor",
934
- children: /* @__PURE__ */ e.jsx(
935
- "path",
936
- {
937
- d: "M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z",
938
- strokeWidth: "2",
939
- strokeLinecap: "round",
940
- strokeLinejoin: "round"
941
- }
942
- )
943
- }
944
- )
945
- },
946
- {
947
- value: "system",
948
- label: "跟随系统",
949
- icon: /* @__PURE__ */ e.jsxs(
950
- "svg",
951
- {
952
- className: "h-4 w-4",
953
- fill: "none",
954
- viewBox: "0 0 24 24",
955
- stroke: "currentColor",
956
- children: [
957
- /* @__PURE__ */ e.jsx(
958
- "rect",
959
- {
960
- x: "2",
961
- y: "3",
962
- width: "20",
963
- height: "14",
964
- rx: "2",
965
- ry: "2",
966
- strokeWidth: "2"
967
- }
968
- ),
969
- /* @__PURE__ */ e.jsx("path", { d: "M8 21h8m-4-4v4", strokeWidth: "2", strokeLinecap: "round" })
970
- ]
971
- }
972
- )
973
- }
974
- ];
975
- function Pt({
976
- value: r,
977
- onValueChange: j,
978
- themes: c = xt,
979
- iconSize: u = 16,
980
- components: a,
981
- themeIcons: f
982
- }) {
983
- if (!a)
984
- return /* @__PURE__ */ e.jsx("div", { className: "p-4 text-center text-destructive", children: "错误:请通过 components prop 注入 UI 组件" });
985
- const { DropdownMenuRadioGroup: h, DropdownMenuRadioItem: o } = a, _ = (l) => {
986
- if (f && f[l])
987
- return f[l];
988
- const P = c.find((A) => A.value === l);
989
- return P == null ? void 0 : P.icon;
990
- }, b = u ? { width: u, height: u } : {};
991
- return /* @__PURE__ */ e.jsx(h, { value: r, onValueChange: j, children: c.map((l) => /* @__PURE__ */ e.jsxs(o, { value: l.value, children: [
992
- /* @__PURE__ */ e.jsx("span", { className: "mr-2 inline-flex items-center", style: b, children: _(l.value) }),
993
- /* @__PURE__ */ e.jsx("span", { children: l.label })
994
- ] }, l.value)) });
995
- }
996
- function Rt({
997
- url: r,
998
- initialPage: j = 1,
999
- initialScale: c = 1,
1000
- scale: u,
1001
- onScaleChange: a,
1002
- minScale: f = 0.5,
1003
- maxScale: h = 3,
1004
- currentPage: o,
1005
- onPageChange: _,
1006
- showToolbar: b = !0,
1007
- showPagination: l = !0,
1008
- enableHotkeys: P = !0,
1009
- className: A,
1010
- containerClassName: y,
1011
- pageClassName: z,
1012
- components: J,
1013
- onLoadSuccess: L,
1014
- onLoadError: W,
1015
- loadingText: N = "加载中...",
1016
- errorText: g = "加载失败"
1017
- }) {
1018
- const [d, Y] = M(null), [q, O] = M(j), [I, S] = M(c), [U, K] = M(!0), [i, C] = M(null), [E, $] = M(0), [H, ue] = M(!1), re = je(null), Z = je(null), [se, t] = M(null), s = o ?? q, x = u ?? I, D = Oe(() => {
1019
- const m = [s];
1020
- return s > 1 && m.push(s - 1), s < E && m.push(s + 1), m;
1021
- }, [s, E]), X = ne(
1022
- (m) => {
1023
- const k = Math.max(E, 1), v = Math.min(Math.max(m, 1), k);
1024
- o === void 0 && O(v), _ == null || _(v);
1025
- },
1026
- [E, o, _]
1027
- ), le = ne(() => {
1028
- s > 1 && X(s - 1);
1029
- }, [s, X]), R = ne(() => {
1030
- s < E && X(s + 1);
1031
- }, [s, E, X]), V = ne(() => {
1032
- const m = Math.min(x + 0.25, h);
1033
- u === void 0 && S(m), a == null || a(m);
1034
- }, [x, h, u, a]), p = ne(() => {
1035
- const m = Math.max(x - 0.25, f);
1036
- u === void 0 && S(m), a == null || a(m);
1037
- }, [x, f, u, a]), w = ne(async () => {
1038
- var m, k, v;
1039
- if (!(typeof document > "u")) {
1040
- if (!document.fullscreenElement) {
1041
- await ((k = (m = re.current) == null ? void 0 : m.requestFullscreen) == null ? void 0 : k.call(m));
1042
- return;
1043
- }
1044
- await ((v = document.exitFullscreen) == null ? void 0 : v.call(document));
1045
- }
1046
- }, []);
1047
- if (te(() => {
1048
- let m = !0;
1049
- return (async () => {
1050
- try {
1051
- const v = await import("./index-Ba1twkJn.js");
1052
- if (typeof window < "u") {
1053
- const F = v.pdfjs, ae = F == null ? void 0 : F.version;
1054
- F != null && F.GlobalWorkerOptions && ae && (F.GlobalWorkerOptions.workerSrc = `https://cdn.jsdelivr.net/npm/pdfjs-dist@${ae}/build/pdf.worker.min.mjs`);
1055
- }
1056
- m && t(v);
1057
- } catch (v) {
1058
- if (m) {
1059
- const F = v instanceof Error ? v : new Error("无法加载 react-pdf 库");
1060
- C(F), K(!1), W == null || W(F);
1061
- }
1062
- }
1063
- })(), () => {
1064
- m = !1;
1065
- };
1066
- }, []), te(() => {
1067
- if (!se || !r) return;
1068
- let m = !0;
1069
- return (async () => {
1070
- K(!0), C(null);
1071
- try {
1072
- const { Document: v } = se;
1073
- if (!v)
1074
- throw new Error("react-pdf Document 组件不可用");
1075
- const F = se.pdfjs.getDocument(r);
1076
- Z.current = F;
1077
- const ae = await F.promise;
1078
- m && (Y(ae), $(ae.numPages), o === void 0 && O(
1079
- (Pe) => Math.max(1, Math.min(Pe, ae.numPages))
1080
- ), K(!1), L == null || L(ae));
1081
- } catch (v) {
1082
- if (m) {
1083
- const F = v instanceof Error ? v : new Error("PDF 加载失败");
1084
- C(F), K(!1), W == null || W(F);
1085
- }
1086
- }
1087
- })(), () => {
1088
- m = !1, Z.current && typeof Z.current.destroy == "function" && (Z.current.destroy(), Z.current = null);
1089
- };
1090
- }, [se, r, o, L, W]), te(() => {
1091
- if (typeof document > "u") return;
1092
- const m = () => {
1093
- ue(document.fullscreenElement === re.current);
1094
- };
1095
- return document.addEventListener("fullscreenchange", m), () => {
1096
- document.removeEventListener("fullscreenchange", m);
1097
- };
1098
- }, []), te(() => {
1099
- if (!P) return;
1100
- const m = (k) => {
1101
- const v = document.activeElement;
1102
- v && (v.tagName === "INPUT" || v.getAttribute("role") === "input") || ((k.ctrlKey || k.metaKey) && (k.key === "=" || k.key === "+") ? (k.preventDefault(), V()) : (k.ctrlKey || k.metaKey) && k.key === "-" ? (k.preventDefault(), p()) : k.key === "ArrowLeft" ? (k.preventDefault(), le()) : k.key === "ArrowRight" ? (k.preventDefault(), R()) : (k.key === "f" || k.key === "F") && (k.preventDefault(), w()));
1103
- };
1104
- return document.addEventListener("keydown", m), () => {
1105
- document.removeEventListener("keydown", m);
1106
- };
1107
- }, [
1108
- P,
1109
- V,
1110
- p,
1111
- le,
1112
- R,
1113
- w
1114
- ]), !J)
1115
- return /* @__PURE__ */ e.jsx("div", { className: "p-4 text-center text-destructive", children: "错误:请通过 components prop 注入 UI 组件" });
1116
- const {
1117
- Card: B,
1118
- CardContent: de,
1119
- Button: ie,
1120
- Input: ee,
1121
- Skeleton: me
1122
- } = J, fe = () => b ? /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
1123
- /* @__PURE__ */ e.jsx(
1124
- ie,
1125
- {
1126
- variant: "outline",
1127
- size: "sm",
1128
- onClick: p,
1129
- disabled: x <= f,
1130
- children: /* @__PURE__ */ e.jsx(Ie, {})
1131
- }
1132
- ),
1133
- /* @__PURE__ */ e.jsxs("span", { className: "text-sm", children: [
1134
- Math.round(x * 100),
1135
- "%"
1136
- ] }),
1137
- /* @__PURE__ */ e.jsx(
1138
- ie,
1139
- {
1140
- variant: "outline",
1141
- size: "sm",
1142
- onClick: V,
1143
- disabled: x >= h,
1144
- children: /* @__PURE__ */ e.jsx(Fe, {})
1145
- }
1146
- ),
1147
- /* @__PURE__ */ e.jsx(
1148
- ie,
1149
- {
1150
- variant: "outline",
1151
- size: "icon",
1152
- onClick: () => {
1153
- w();
1154
- },
1155
- children: H ? /* @__PURE__ */ e.jsx(Se, {}) : /* @__PURE__ */ e.jsx($e, {})
1156
- }
1157
- )
1158
- ] }) : null, ve = () => l ? /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
1159
- /* @__PURE__ */ e.jsx(
1160
- ie,
1161
- {
1162
- variant: "outline",
1163
- size: "icon",
1164
- onClick: le,
1165
- disabled: s <= 1,
1166
- children: /* @__PURE__ */ e.jsx(we, {})
1167
- }
1168
- ),
1169
- ee ? /* @__PURE__ */ e.jsx(
1170
- ee,
1171
- {
1172
- type: "number",
1173
- min: 1,
1174
- max: Math.max(E, 1),
1175
- value: s,
1176
- onChange: (m) => X(parseInt(m.target.value, 10) || 1),
1177
- className: "w-16 text-center"
1178
- }
1179
- ) : /* @__PURE__ */ e.jsx(
1180
- "input",
1181
- {
1182
- type: "number",
1183
- min: 1,
1184
- max: Math.max(E, 1),
1185
- value: s,
1186
- onChange: (m) => X(parseInt(m.target.value, 10) || 1),
1187
- className: "w-16 rounded-md border border-input bg-background px-2 text-center text-sm"
1188
- }
1189
- ),
1190
- /* @__PURE__ */ e.jsxs("span", { className: "text-sm text-muted-foreground", children: [
1191
- "/ ",
1192
- E
1193
- ] }),
1194
- /* @__PURE__ */ e.jsx(
1195
- ie,
1196
- {
1197
- variant: "outline",
1198
- size: "icon",
1199
- onClick: R,
1200
- disabled: s >= E,
1201
- children: /* @__PURE__ */ e.jsx(ke, {})
1202
- }
1203
- )
1204
- ] }) : null, be = () => !b && !l ? null : /* @__PURE__ */ e.jsxs(
1205
- "div",
1206
- {
1207
- "data-testid": "pdf-operations-bar",
1208
- className: "flex items-center justify-between gap-4 border-b px-4 py-2",
1209
- children: [
1210
- fe(),
1211
- ve()
1212
- ]
1213
- }
1214
- ), Te = () => /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col items-center justify-center space-y-4 p-8", children: [
1215
- /* @__PURE__ */ e.jsx(me, { className: "h-8 w-32" }),
1216
- /* @__PURE__ */ e.jsx(me, { className: "h-64 w-full max-w-2xl" }),
1217
- /* @__PURE__ */ e.jsx("p", { className: "text-sm text-muted-foreground", children: N })
1218
- ] }), ge = () => /* @__PURE__ */ e.jsx("div", { className: "flex flex-col items-center justify-center space-y-4 p-8", children: /* @__PURE__ */ e.jsxs("div", { className: "text-center text-destructive", children: [
1219
- /* @__PURE__ */ e.jsx("p", { className: "font-medium", children: g }),
1220
- i && /* @__PURE__ */ e.jsx("p", { className: "mt-2 text-sm text-muted-foreground", children: i.message })
1221
- ] }) }), Ee = () => {
1222
- if (!se || !d) return null;
1223
- const { Page: m } = se;
1224
- return /* @__PURE__ */ e.jsx(
1225
- "div",
1226
- {
1227
- className: `flex flex-col items-center justify-center ${H ? "h-[calc(100vh-56px)] overflow-auto" : "overflow-visible"}`,
1228
- children: D.map((k) => /* @__PURE__ */ e.jsx(
1229
- "div",
1230
- {
1231
- className: z,
1232
- style: {
1233
- display: k === s ? "block" : "none"
1234
- },
1235
- children: /* @__PURE__ */ e.jsx(
1236
- m,
1237
- {
1238
- pdf: d,
1239
- pageNumber: k,
1240
- scale: x,
1241
- renderTextLayer: !1,
1242
- renderAnnotationLayer: !1,
1243
- className: "shadow-md"
1244
- }
1245
- )
1246
- },
1247
- k
1248
- ))
1249
- }
1250
- );
1251
- };
1252
- return /* @__PURE__ */ e.jsx("div", { ref: re, children: /* @__PURE__ */ e.jsxs(B, { className: A, children: [
1253
- be(),
1254
- /* @__PURE__ */ e.jsx(de, { className: y, children: U ? Te() : i ? ge() : Ee() })
1255
- ] }) });
1256
- }
1257
- const ze = rt(
1258
- ({
1259
- thumbnail: r,
1260
- isCurrentPage: j,
1261
- onClick: c
1262
- }) => /* @__PURE__ */ e.jsxs(
1263
- "div",
1264
- {
1265
- className: `flex w-full flex-col items-center rounded p-1 ${j ? "bg-primary/10" : ""}`,
1266
- children: [
1267
- /* @__PURE__ */ e.jsx(
1268
- "img",
1269
- {
1270
- src: r.url,
1271
- alt: `Page ${r.pageNumber}`,
1272
- className: "w-48 cursor-pointer border transition-opacity hover:opacity-80",
1273
- onClick: c,
1274
- onKeyDown: (u) => {
1275
- (u.key === "Enter" || u.key === " ") && (u.preventDefault(), c());
1276
- },
1277
- role: "button",
1278
- tabIndex: 0
1279
- }
1280
- ),
1281
- /* @__PURE__ */ e.jsxs("span", { className: "mt-1 text-sm", children: [
1282
- "第 ",
1283
- r.pageNumber,
1284
- " 页"
1285
- ] })
1286
- ]
1287
- }
1288
- )
1289
- );
1290
- ze.displayName = "PDFThumbnail";
1291
- const We = ({
1292
- bookmark: r,
1293
- depth: j,
1294
- onClick: c
1295
- }) => /* @__PURE__ */ e.jsxs("div", { style: { paddingLeft: `${j * 16}px` }, children: [
1296
- /* @__PURE__ */ e.jsx(
1297
- "button",
1298
- {
1299
- onClick: () => c(r),
1300
- className: "w-full rounded px-2 py-1 text-left text-sm hover:bg-primary/10 hover:text-primary",
1301
- children: r.title
1302
- }
1303
- ),
1304
- r.items && r.items.map((u, a) => /* @__PURE__ */ e.jsx(
1305
- We,
1306
- {
1307
- bookmark: u,
1308
- depth: j + 1,
1309
- onClick: c
1310
- },
1311
- `${r.title}-${a}`
1312
- ))
1313
- ] });
1314
- function ht({
1315
- pdfDocument: r,
1316
- currentPage: j,
1317
- onPageClick: c,
1318
- components: u
1319
- }) {
1320
- const [a, f] = M([]), [h, o] = M([]), [_, b] = M(!0), { Tabs: l, TabsList: P, TabsTrigger: A, TabsContent: y, ScrollArea: z, Skeleton: J } = u;
1321
- te(() => {
1322
- (async () => {
1323
- if (!r) return;
1324
- b(!0);
1325
- const g = [];
1326
- for (let d = 1; d <= r.numPages; d++)
1327
- try {
1328
- const Y = await r.getPage(d), q = Y.getViewport({ scale: 0.2 }), O = document.createElement("canvas"), I = O.getContext("2d");
1329
- if (!I) continue;
1330
- O.width = q.width, O.height = q.height, await Y.render({
1331
- canvasContext: I,
1332
- viewport: q,
1333
- canvas: O
1334
- }).promise, g.push({
1335
- pageNumber: d,
1336
- url: O.toDataURL()
1337
- });
1338
- } catch (Y) {
1339
- console.error(`Error loading thumbnail for page ${d}:`, Y);
1340
- }
1341
- f(g), b(!1);
1342
- })();
1343
- }, [r]), te(() => {
1344
- (async () => {
1345
- if (r)
1346
- try {
1347
- const g = await r.getOutline();
1348
- o(g || []);
1349
- } catch (g) {
1350
- console.error("Error loading bookmarks:", g), o([]);
1351
- }
1352
- })();
1353
- }, [r]);
1354
- const L = async (N) => {
1355
- if (r)
1356
- try {
1357
- let g;
1358
- if (N.dest)
1359
- if (typeof N.dest == "string") {
1360
- const d = await r.getDestination(N.dest);
1361
- d && d[0] && (g = await r.getPageIndex(d[0]));
1362
- } else Array.isArray(N.dest) && N.dest[0] && (g = await r.getPageIndex(N.dest[0]));
1363
- else N.pageNumber && (g = N.pageNumber - 1);
1364
- typeof g == "number" && c(g + 1);
1365
- } catch (g) {
1366
- console.error("Error navigating to bookmark:", g);
1367
- }
1368
- }, W = () => /* @__PURE__ */ e.jsx("div", { className: "space-y-2 p-4", children: Array.from({ length: (r == null ? void 0 : r.numPages) || 5 }, (N, g) => /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col items-center p-1", children: [
1369
- /* @__PURE__ */ e.jsx(J, { className: "h-32 w-48" }),
1370
- /* @__PURE__ */ e.jsx(J, { className: "mt-1 h-4 w-16" })
1371
- ] }, g)) });
1372
- return /* @__PURE__ */ e.jsx("div", { className: "w-64 border-r bg-muted", children: /* @__PURE__ */ e.jsxs(l, { defaultValue: "thumbnails", children: [
1373
- /* @__PURE__ */ e.jsxs(P, { className: "w-full p-2", children: [
1374
- /* @__PURE__ */ e.jsx(A, { value: "thumbnails", className: "flex-1 bg-transparent", children: "缩略图" }),
1375
- /* @__PURE__ */ e.jsx(A, { value: "bookmarks", className: "flex-1 bg-transparent", children: "书签" })
1376
- ] }),
1377
- /* @__PURE__ */ e.jsx(y, { value: "thumbnails", children: /* @__PURE__ */ e.jsx(z, { className: "h-[calc(100vh-8rem)]", children: _ ? W() : /* @__PURE__ */ e.jsx("div", { className: "space-y-2 p-4", children: a.map((N) => /* @__PURE__ */ e.jsx(
1378
- ze,
1379
- {
1380
- thumbnail: N,
1381
- isCurrentPage: j === N.pageNumber,
1382
- onClick: () => c(N.pageNumber)
1383
- },
1384
- N.pageNumber
1385
- )) }) }) }),
1386
- /* @__PURE__ */ e.jsx(y, { value: "bookmarks", children: /* @__PURE__ */ e.jsx(z, { className: "h-[calc(100vh-8rem)]", children: /* @__PURE__ */ e.jsx("div", { className: "p-4", children: h.length === 0 ? /* @__PURE__ */ e.jsx("div", { className: "py-4 text-center text-sm text-muted-foreground", children: "没有可用的书签" }) : /* @__PURE__ */ e.jsx("div", { className: "space-y-2", children: h.map((N, g) => /* @__PURE__ */ e.jsx(
1387
- We,
1388
- {
1389
- bookmark: N,
1390
- depth: 0,
1391
- onClick: L
1392
- },
1393
- `${N.title}-${g}`
1394
- )) }) }) }) })
1395
- ] }) });
1396
- }
1397
- function pt(r, j) {
1398
- const c = je(
1399
- void 0
1400
- );
1401
- return ne(
1402
- (...u) => {
1403
- c.current && clearTimeout(c.current), c.current = setTimeout(() => r(...u), j);
1404
- },
1405
- [r, j]
1406
- );
1407
- }
1408
- function _t({
1409
- url: r,
1410
- initialPage: j = 1,
1411
- initialScale: c = 1,
1412
- initialRotation: u = 0,
1413
- currentPage: a,
1414
- onPageChange: f,
1415
- scale: h,
1416
- onScaleChange: o,
1417
- rotation: _,
1418
- onRotationChange: b,
1419
- minScale: l = 0.5,
1420
- maxScale: P = 2.5,
1421
- showToolbar: A = !0,
1422
- showSidebar: y = !0,
1423
- showRotation: z = !0,
1424
- showModeToggle: J = !0,
1425
- showFullscreen: L = !0,
1426
- enableHotkeys: W = !0,
1427
- enableMobileNav: N = !0,
1428
- displayMode: g = "scroll",
1429
- className: d,
1430
- toolbarClassName: Y,
1431
- contentClassName: q,
1432
- contentHeight: O = "80vh",
1433
- pageClassName: I,
1434
- workerUrl: S,
1435
- cMapUrl: U,
1436
- standardFontDataUrl: K,
1437
- components: i,
1438
- onLoadSuccess: C,
1439
- onLoadError: E,
1440
- onPageRender: $,
1441
- loadingText: H = "正在加载PDF文档...",
1442
- errorText: ue = "PDF加载失败"
1443
- }) {
1444
- const [re, Z] = M(null), [se, t] = M(j), [s, x] = M(c), [D, X] = M(u), [le, R] = M(!1), [V, p] = M(null), [w, B] = M(0), [de, ie] = M(!1), [ee, me] = M(
1445
- g === "scroll"
1446
- ), [fe, ve] = M(y);
1447
- te(() => {
1448
- ve(y);
1449
- }, [y]);
1450
- const [be, Te] = M(void 0), [ge, Ee] = M(null), m = je(null), k = je(null), v = a ?? se, F = h ?? s, ae = _ ?? D, { Card: Pe, CardContent: Be, Button: ce, Input: Le, Skeleton: Ye } = i || {}, Ve = Oe(() => {
1451
- const n = {
1452
- withCredentials: !1
1453
- };
1454
- return U && (n.cMapUrl = U, n.cMapPacked = !0), K && (n.standardFontDataUrl = K), n;
1455
- }, [U, K]);
1456
- te(() => {
1457
- let n = !0;
1458
- return (async () => {
1459
- try {
1460
- const Q = await import("./index-Ba1twkJn.js");
1461
- if (typeof window < "u") {
1462
- const G = Q.pdfjs, ye = G == null ? void 0 : G.version;
1463
- G != null && G.GlobalWorkerOptions && ye && (S ? G.GlobalWorkerOptions.workerSrc = S : G.GlobalWorkerOptions.workerSrc = `https://cdn.jsdelivr.net/npm/pdfjs-dist@${ye}/build/pdf.worker.min.mjs`, !U && G.GlobalWorkerOptions && (G.GlobalWorkerOptions.cMapUrl = `https://unpkg.com/pdfjs-dist@${ye}/cmaps/`), !K && G.GlobalWorkerOptions && (G.GlobalWorkerOptions.standardFontDataUrl = `https://unpkg.com/pdfjs-dist@${ye}/standard_fonts/`));
1464
- }
1465
- n && Ee(Q);
1466
- } catch (Q) {
1467
- if (n) {
1468
- const G = Q instanceof Error ? Q : new Error("无法加载 react-pdf 库");
1469
- p(G), R(!1), E == null || E(G);
1470
- }
1471
- }
1472
- })(), () => {
1473
- n = !1;
1474
- };
1475
- }, [S, U, K, E]);
1476
- const Ge = ne(
1477
- (n) => {
1478
- console.error("PDF加载失败:", n), console.error("PDF URL:", r), p(
1479
- new Error(`${ue}: ${n.message || "请检查文件路径或网络连接"}`)
1480
- ), E == null || E(n);
1481
- },
1482
- [r, ue, E]
1483
- ), oe = ne(
1484
- (n) => {
1485
- const T = w > 0 ? Math.max(1, Math.min(n, w)) : n;
1486
- a === void 0 && t(T), f == null || f(T);
1487
- },
1488
- [w, a, f]
1489
- ), xe = ne(
1490
- (n) => {
1491
- const T = Math.max(l, Math.min(P, F + n));
1492
- h === void 0 && x(T), o == null || o(T);
1493
- },
1494
- [F, l, P, h, o]
1495
- ), Ue = ne(() => {
1496
- const n = (ae + 90) % 360;
1497
- _ === void 0 && X(n), b == null || b(n);
1498
- }, [ae, _, b]), Ce = pt((n) => {
1499
- Te(n);
1500
- }, 100);
1501
- te(() => {
1502
- if (!k.current) return;
1503
- const n = k.current, T = () => {
1504
- Ce(n.clientWidth);
1505
- };
1506
- T();
1507
- const Q = new ResizeObserver(() => {
1508
- T();
1509
- });
1510
- return Q.observe(n), () => {
1511
- Q.disconnect();
1512
- };
1513
- }, [Ce]), te(() => {
1514
- if (!W) return;
1515
- const n = (T) => {
1516
- (T.ctrlKey || T.metaKey) && (T.key === "=" || T.key === "+") ? (T.preventDefault(), xe(0.1)) : (T.ctrlKey || T.metaKey) && T.key === "-" ? (T.preventDefault(), xe(-0.1)) : T.key === "ArrowLeft" ? (T.preventDefault(), oe(v - 1)) : T.key === "ArrowRight" && (T.preventDefault(), oe(v + 1));
1517
- };
1518
- return document.addEventListener("keydown", n), () => {
1519
- document.removeEventListener("keydown", n);
1520
- };
1521
- }, [W, v, oe, xe]);
1522
- const Je = ne(async () => {
1523
- var n, T;
1524
- if (!(typeof document > "u"))
1525
- if (document.fullscreenElement)
1526
- document.exitFullscreen && (await document.exitFullscreen(), ie(!1));
1527
- else
1528
- try {
1529
- await ((T = (n = m.current) == null ? void 0 : n.requestFullscreen) == null ? void 0 : T.call(n)), ie(!0);
1530
- } catch (Q) {
1531
- console.error("Error attempting to enable fullscreen:", Q);
1532
- }
1533
- }, []);
1534
- te(() => {
1535
- if (typeof document > "u") return;
1536
- const n = () => {
1537
- ie(!!document.fullscreenElement);
1538
- };
1539
- return document.addEventListener("fullscreenchange", n), () => {
1540
- document.removeEventListener("fullscreenchange", n);
1541
- };
1542
- }, []);
1543
- const qe = ne(
1544
- (n) => {
1545
- oe(n), me(!1);
1546
- },
1547
- [oe]
1548
- ), Ke = () => A ? /* @__PURE__ */ e.jsxs(
1549
- "div",
1550
- {
1551
- className: `flex items-center justify-between gap-4 border-b px-4 py-2 ${Y || ""}`,
1552
- children: [
1553
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
1554
- y && /* @__PURE__ */ e.jsx(
1555
- ce,
1556
- {
1557
- variant: "outline",
1558
- size: "icon",
1559
- onClick: () => ve(!fe),
1560
- title: fe ? "隐藏侧边栏" : "显示侧边栏",
1561
- children: /* @__PURE__ */ e.jsx(at, {})
1562
- }
1563
- ),
1564
- /* @__PURE__ */ e.jsx(
1565
- ce,
1566
- {
1567
- variant: "outline",
1568
- size: "icon",
1569
- onClick: () => xe(-0.1),
1570
- disabled: F <= l,
1571
- children: /* @__PURE__ */ e.jsx(Ie, {})
1572
- }
1573
- ),
1574
- /* @__PURE__ */ e.jsxs("span", { className: "min-w-[3rem] text-center text-sm", children: [
1575
- Math.round(F * 100),
1576
- "%"
1577
- ] }),
1578
- /* @__PURE__ */ e.jsx(
1579
- ce,
1580
- {
1581
- variant: "outline",
1582
- size: "icon",
1583
- onClick: () => xe(0.1),
1584
- disabled: F >= P,
1585
- children: /* @__PURE__ */ e.jsx(Fe, {})
1586
- }
1587
- ),
1588
- z && /* @__PURE__ */ e.jsx(ce, { variant: "outline", size: "icon", onClick: Ue, children: /* @__PURE__ */ e.jsx(it, {}) }),
1589
- J && /* @__PURE__ */ e.jsx(
1590
- ce,
1591
- {
1592
- variant: "outline",
1593
- size: "icon",
1594
- onClick: () => me(!ee),
1595
- title: ee ? "单页模式" : "滚动模式",
1596
- children: ee ? /* @__PURE__ */ e.jsx(ct, {}) : /* @__PURE__ */ e.jsx(ot, {})
1597
- }
1598
- ),
1599
- L && /* @__PURE__ */ e.jsx(ce, { variant: "outline", size: "icon", onClick: Je, children: de ? /* @__PURE__ */ e.jsx(Se, {}) : /* @__PURE__ */ e.jsx($e, {}) })
1600
- ] }),
1601
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
1602
- /* @__PURE__ */ e.jsx(
1603
- ce,
1604
- {
1605
- variant: "outline",
1606
- size: "icon",
1607
- onClick: () => oe(v - 1),
1608
- disabled: v <= 1,
1609
- children: /* @__PURE__ */ e.jsx(we, {})
1610
- }
1611
- ),
1612
- /* @__PURE__ */ e.jsx(
1613
- Le,
1614
- {
1615
- type: "number",
1616
- min: 1,
1617
- max: w,
1618
- value: v,
1619
- onChange: (n) => oe(parseInt(n.target.value) || 1),
1620
- className: "w-16 text-center"
1621
- }
1622
- ),
1623
- /* @__PURE__ */ e.jsxs("span", { className: "text-sm text-muted-foreground", children: [
1624
- "/ ",
1625
- w
1626
- ] }),
1627
- /* @__PURE__ */ e.jsx(
1628
- ce,
1629
- {
1630
- variant: "outline",
1631
- size: "icon",
1632
- onClick: () => oe(v + 1),
1633
- disabled: w > 0 && v >= w,
1634
- children: /* @__PURE__ */ e.jsx(ke, {})
1635
- }
1636
- )
1637
- ] })
1638
- ]
1639
- }
1640
- ) : null, Re = () => /* @__PURE__ */ e.jsx("div", { className: "flex h-full items-center justify-center", children: /* @__PURE__ */ e.jsx("p", { className: "text-muted-foreground", children: H }) }), _e = () => /* @__PURE__ */ e.jsx("div", { className: "flex h-full min-h-[400px] items-center justify-center px-4 text-center text-destructive", children: /* @__PURE__ */ e.jsxs("div", { className: "max-w-md", children: [
1641
- /* @__PURE__ */ e.jsx("p", { className: "mb-2 text-lg font-medium", children: "文件加载失败" }),
1642
- /* @__PURE__ */ e.jsx("p", { className: "text-sm opacity-80", children: V == null ? void 0 : V.message })
1643
- ] }) }), He = () => {
1644
- if (!ge) return Re();
1645
- const { Document: n, Page: T } = ge;
1646
- return /* @__PURE__ */ e.jsx(
1647
- "div",
1648
- {
1649
- ref: k,
1650
- className: `pdf-container flex-1 overflow-y-auto ${q || ""}`,
1651
- children: /* @__PURE__ */ e.jsx("div", { className: "flex min-h-full justify-center px-4", children: /* @__PURE__ */ e.jsx(
1652
- n,
1653
- {
1654
- file: r,
1655
- onLoadError: Ge,
1656
- options: Ve,
1657
- loading: Re(),
1658
- error: _e(),
1659
- onLoadSuccess: (Q) => {
1660
- re || (Z(Q), B(Q.numPages), R(!1), C == null || C(Q));
1661
- },
1662
- children: V ? _e() : ee ? (
1663
- // 显示所有页面模式
1664
- Array.from(new Array(w), (Q, G) => /* @__PURE__ */ e.jsx(
1665
- "div",
1666
- {
1667
- className: `mb-4 ${I || ""}`,
1668
- children: /* @__PURE__ */ e.jsx(
1669
- T,
1670
- {
1671
- pageNumber: G + 1,
1672
- renderTextLayer: !1,
1673
- renderAnnotationLayer: !1,
1674
- width: be,
1675
- scale: F,
1676
- rotate: ae,
1677
- onRenderSuccess: () => $ == null ? void 0 : $(G + 1)
1678
- }
1679
- )
1680
- },
1681
- `page_${G + 1}`
1682
- ))
1683
- ) : (
1684
- // 单页模式
1685
- /* @__PURE__ */ e.jsx("div", { className: I || "", children: /* @__PURE__ */ e.jsx(
1686
- T,
1687
- {
1688
- pageNumber: v,
1689
- renderTextLayer: !1,
1690
- renderAnnotationLayer: !1,
1691
- width: be,
1692
- scale: F,
1693
- rotate: ae,
1694
- onRenderSuccess: () => $ == null ? void 0 : $(v)
1695
- }
1696
- ) })
1697
- )
1698
- }
1699
- ) })
1700
- }
1701
- );
1702
- }, Ze = () => {
1703
- if (!y || !fe || !re) return null;
1704
- const n = ht;
1705
- return /* @__PURE__ */ e.jsx(
1706
- n,
1707
- {
1708
- pdfDocument: re,
1709
- currentPage: v,
1710
- onPageClick: qe,
1711
- components: {
1712
- Tabs: i.Tabs,
1713
- TabsList: i.TabsList,
1714
- TabsTrigger: i.TabsTrigger,
1715
- TabsContent: i.TabsContent,
1716
- ScrollArea: i.ScrollArea,
1717
- Skeleton: Ye
1718
- }
1719
- }
1720
- );
1721
- }, Xe = () => N ? /* @__PURE__ */ e.jsxs("div", { className: "fixed bottom-4 left-1/2 z-50 flex -translate-x-1/2 gap-2 md:hidden", children: [
1722
- /* @__PURE__ */ e.jsxs(
1723
- ce,
1724
- {
1725
- variant: "secondary",
1726
- size: "sm",
1727
- onClick: () => oe(v - 1),
1728
- disabled: v <= 1,
1729
- children: [
1730
- /* @__PURE__ */ e.jsx(we, {}),
1731
- /* @__PURE__ */ e.jsx("span", { className: "ml-1", children: "上一页" })
1732
- ]
1733
- }
1734
- ),
1735
- /* @__PURE__ */ e.jsxs(
1736
- ce,
1737
- {
1738
- variant: "secondary",
1739
- size: "sm",
1740
- onClick: () => oe(v + 1),
1741
- disabled: v >= w,
1742
- children: [
1743
- /* @__PURE__ */ e.jsx("span", { className: "mr-1", children: "下一页" }),
1744
- /* @__PURE__ */ e.jsx(ke, {})
1745
- ]
1746
- }
1747
- )
1748
- ] }) : null;
1749
- if (!i)
1750
- return /* @__PURE__ */ e.jsx("div", { className: "p-4 text-center text-destructive", children: "错误:请通过 components prop 注入 UI 组件" });
1751
- if (y) {
1752
- const n = [];
1753
- if (i.Tabs || n.push("Tabs"), i.TabsList || n.push("TabsList"), i.TabsTrigger || n.push("TabsTrigger"), i.TabsContent || n.push("TabsContent"), i.ScrollArea || n.push("ScrollArea"), n.length > 0) {
1754
- const T = n.length === 1 ? n[0] : `${n.slice(0, -1).join("、")} 和 ${n[n.length - 1]}`;
1755
- return /* @__PURE__ */ e.jsxs("div", { className: "p-4 text-center text-destructive", children: [
1756
- "错误:侧边栏功能需要注入 ",
1757
- T,
1758
- " 组件"
1759
- ] });
1760
- }
1761
- }
1762
- return /* @__PURE__ */ e.jsxs("div", { ref: m, children: [
1763
- /* @__PURE__ */ e.jsxs(Pe, { className: d, children: [
1764
- Ke(),
1765
- /* @__PURE__ */ e.jsx(
1766
- Be,
1767
- {
1768
- className: "p-0",
1769
- style: { height: de ? "100vh" : O },
1770
- children: /* @__PURE__ */ e.jsx("div", { className: "flex h-full flex-col", children: /* @__PURE__ */ e.jsxs("div", { className: "flex flex-1 overflow-hidden", children: [
1771
- Ze(),
1772
- le ? Re() : V ? _e() : He()
1773
- ] }) })
1774
- }
1775
- )
1776
- ] }),
1777
- Xe()
1778
- ] });
1779
- }
1780
- export {
1781
- Nt as D,
1782
- _t as P,
1783
- Rt as S,
1784
- kt as T,
1785
- wt as a,
1786
- ht as b,
1787
- Tt as c,
1788
- Et as d,
1789
- Pt as e,
1790
- yt as f,
1791
- e as j
1792
- };
1793
- //# sourceMappingURL=index-6lJCWESg.js.map