@turinhub/atomix-common-ui 0.1.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 (39) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +307 -0
  3. package/dist/components/DataTable.d.ts +89 -0
  4. package/dist/components/DataTable.d.ts.map +1 -0
  5. package/dist/components/DeleteConfirmDialog.d.ts +38 -0
  6. package/dist/components/DeleteConfirmDialog.d.ts.map +1 -0
  7. package/dist/components/TableHeader.d.ts +28 -0
  8. package/dist/components/TableHeader.d.ts.map +1 -0
  9. package/dist/components/TablePagination.d.ts +30 -0
  10. package/dist/components/TablePagination.d.ts.map +1 -0
  11. package/dist/components/ui/button.d.ts +12 -0
  12. package/dist/components/ui/button.d.ts.map +1 -0
  13. package/dist/components/ui/card.d.ts +9 -0
  14. package/dist/components/ui/card.d.ts.map +1 -0
  15. package/dist/components/ui/dialog.d.ts +20 -0
  16. package/dist/components/ui/dialog.d.ts.map +1 -0
  17. package/dist/components/ui/dropdown-menu.d.ts +28 -0
  18. package/dist/components/ui/dropdown-menu.d.ts.map +1 -0
  19. package/dist/components/ui/input.d.ts +6 -0
  20. package/dist/components/ui/input.d.ts.map +1 -0
  21. package/dist/components/ui/label.d.ts +6 -0
  22. package/dist/components/ui/label.d.ts.map +1 -0
  23. package/dist/components/ui/select.d.ts +14 -0
  24. package/dist/components/ui/select.d.ts.map +1 -0
  25. package/dist/components/ui/skeleton.d.ts +3 -0
  26. package/dist/components/ui/skeleton.d.ts.map +1 -0
  27. package/dist/components/ui/table.d.ts +11 -0
  28. package/dist/components/ui/table.d.ts.map +1 -0
  29. package/dist/index.c.js +23 -0
  30. package/dist/index.c.js.map +1 -0
  31. package/dist/index.d.ts +11 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +765 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/lib/utils.d.ts +3 -0
  36. package/dist/lib/utils.d.ts.map +1 -0
  37. package/dist/types/component-types.d.ts +83 -0
  38. package/dist/types/component-types.d.ts.map +1 -0
  39. package/package.json +92 -0
package/dist/index.js ADDED
@@ -0,0 +1,765 @@
1
+ import { clsx as ae } from "clsx";
2
+ import { twMerge as oe } from "tailwind-merge";
3
+ import ce, { useState as ie, useEffect as ue } from "react";
4
+ function pe(...a) {
5
+ return oe(ae(a));
6
+ }
7
+ var Z = { exports: {} }, F = {};
8
+ /**
9
+ * @license React
10
+ * react-jsx-runtime.production.js
11
+ *
12
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
13
+ *
14
+ * This source code is licensed under the MIT license found in the
15
+ * LICENSE file in the root directory of this source tree.
16
+ */
17
+ var re;
18
+ function de() {
19
+ if (re) return F;
20
+ re = 1;
21
+ var a = Symbol.for("react.transitional.element"), h = Symbol.for("react.fragment");
22
+ function d(j, c, f) {
23
+ var x = null;
24
+ if (f !== void 0 && (x = "" + f), c.key !== void 0 && (x = "" + c.key), "key" in c) {
25
+ f = {};
26
+ for (var o in c)
27
+ o !== "key" && (f[o] = c[o]);
28
+ } else f = c;
29
+ return c = f.ref, {
30
+ $$typeof: a,
31
+ type: j,
32
+ key: x,
33
+ ref: c !== void 0 ? c : null,
34
+ props: f
35
+ };
36
+ }
37
+ return F.Fragment = h, F.jsx = d, F.jsxs = d, F;
38
+ }
39
+ var W = {};
40
+ /**
41
+ * @license React
42
+ * react-jsx-runtime.development.js
43
+ *
44
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
45
+ *
46
+ * This source code is licensed under the MIT license found in the
47
+ * LICENSE file in the root directory of this source tree.
48
+ */
49
+ var te;
50
+ function fe() {
51
+ return te || (te = 1, process.env.NODE_ENV !== "production" && (function() {
52
+ function a(e) {
53
+ if (e == null) return null;
54
+ if (typeof e == "function")
55
+ return e.$$typeof === K ? null : e.displayName || e.name || null;
56
+ if (typeof e == "string") return e;
57
+ switch (e) {
58
+ case S:
59
+ return "Fragment";
60
+ case D:
61
+ return "Profiler";
62
+ case w:
63
+ return "StrictMode";
64
+ case g:
65
+ return "Suspense";
66
+ case k:
67
+ return "SuspenseList";
68
+ case Q:
69
+ return "Activity";
70
+ }
71
+ if (typeof e == "object")
72
+ switch (typeof e.tag == "number" && console.error(
73
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
74
+ ), e.$$typeof) {
75
+ case O:
76
+ return "Portal";
77
+ case R:
78
+ return e.displayName || "Context";
79
+ case y:
80
+ return (e._context.displayName || "Context") + ".Consumer";
81
+ case P:
82
+ var t = e.render;
83
+ return e = e.displayName, e || (e = t.displayName || t.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
84
+ case Y:
85
+ return t = e.displayName || null, t !== null ? t : a(e.type) || "Memo";
86
+ case L:
87
+ t = e._payload, e = e._init;
88
+ try {
89
+ return a(e(t));
90
+ } catch {
91
+ }
92
+ }
93
+ return null;
94
+ }
95
+ function h(e) {
96
+ return "" + e;
97
+ }
98
+ function d(e) {
99
+ try {
100
+ h(e);
101
+ var t = !1;
102
+ } catch {
103
+ t = !0;
104
+ }
105
+ if (t) {
106
+ t = console;
107
+ var l = t.error, i = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
108
+ return l.call(
109
+ t,
110
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
111
+ i
112
+ ), h(e);
113
+ }
114
+ }
115
+ function j(e) {
116
+ if (e === S) return "<>";
117
+ if (typeof e == "object" && e !== null && e.$$typeof === L)
118
+ return "<...>";
119
+ try {
120
+ var t = a(e);
121
+ return t ? "<" + t + ">" : "<...>";
122
+ } catch {
123
+ return "<...>";
124
+ }
125
+ }
126
+ function c() {
127
+ var e = z.A;
128
+ return e === null ? null : e.getOwner();
129
+ }
130
+ function f() {
131
+ return Error("react-stack-top-frame");
132
+ }
133
+ function x(e) {
134
+ if (U.call(e, "key")) {
135
+ var t = Object.getOwnPropertyDescriptor(e, "key").get;
136
+ if (t && t.isReactWarning) return !1;
137
+ }
138
+ return e.key !== void 0;
139
+ }
140
+ function o(e, t) {
141
+ function l() {
142
+ q || (q = !0, console.error(
143
+ "%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)",
144
+ t
145
+ ));
146
+ }
147
+ l.isReactWarning = !0, Object.defineProperty(e, "key", {
148
+ get: l,
149
+ configurable: !0
150
+ });
151
+ }
152
+ function _() {
153
+ var e = a(this.type);
154
+ return J[e] || (J[e] = !0, console.error(
155
+ "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."
156
+ )), e = this.props.ref, e !== void 0 ? e : null;
157
+ }
158
+ function m(e, t, l, i, I, M) {
159
+ var u = l.ref;
160
+ return e = {
161
+ $$typeof: E,
162
+ type: e,
163
+ key: t,
164
+ props: l,
165
+ _owner: i
166
+ }, (u !== void 0 ? u : null) !== null ? Object.defineProperty(e, "ref", {
167
+ enumerable: !1,
168
+ get: _
169
+ }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
170
+ configurable: !1,
171
+ enumerable: !1,
172
+ writable: !0,
173
+ value: 0
174
+ }), Object.defineProperty(e, "_debugInfo", {
175
+ configurable: !1,
176
+ enumerable: !1,
177
+ writable: !0,
178
+ value: null
179
+ }), Object.defineProperty(e, "_debugStack", {
180
+ configurable: !1,
181
+ enumerable: !1,
182
+ writable: !0,
183
+ value: I
184
+ }), Object.defineProperty(e, "_debugTask", {
185
+ configurable: !1,
186
+ enumerable: !1,
187
+ writable: !0,
188
+ value: M
189
+ }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
190
+ }
191
+ function s(e, t, l, i, I, M) {
192
+ var u = t.children;
193
+ if (u !== void 0)
194
+ if (i)
195
+ if (H(u)) {
196
+ for (i = 0; i < u.length; i++)
197
+ T(u[i]);
198
+ Object.freeze && Object.freeze(u);
199
+ } else
200
+ console.error(
201
+ "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
202
+ );
203
+ else T(u);
204
+ if (U.call(t, "key")) {
205
+ u = a(e);
206
+ var C = Object.keys(t).filter(function(p) {
207
+ return p !== "key";
208
+ });
209
+ i = 0 < C.length ? "{key: someKey, " + C.join(": ..., ") + ": ...}" : "{key: someKey}", G[u + i] || (C = 0 < C.length ? "{" + C.join(": ..., ") + ": ...}" : "{}", console.error(
210
+ `A props object containing a "key" prop is being spread into JSX:
211
+ let props = %s;
212
+ <%s {...props} />
213
+ React keys must be passed directly to JSX without using spread:
214
+ let props = %s;
215
+ <%s key={someKey} {...props} />`,
216
+ i,
217
+ u,
218
+ C,
219
+ u
220
+ ), G[u + i] = !0);
221
+ }
222
+ if (u = null, l !== void 0 && (d(l), u = "" + l), x(t) && (d(t.key), u = "" + t.key), "key" in t) {
223
+ l = {};
224
+ for (var n in t)
225
+ n !== "key" && (l[n] = t[n]);
226
+ } else l = t;
227
+ return u && o(
228
+ l,
229
+ typeof e == "function" ? e.displayName || e.name || "Unknown" : e
230
+ ), m(
231
+ e,
232
+ u,
233
+ l,
234
+ c(),
235
+ I,
236
+ M
237
+ );
238
+ }
239
+ function T(e) {
240
+ N(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === L && (e._payload.status === "fulfilled" ? N(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
241
+ }
242
+ function N(e) {
243
+ return typeof e == "object" && e !== null && e.$$typeof === E;
244
+ }
245
+ var b = ce, E = Symbol.for("react.transitional.element"), O = Symbol.for("react.portal"), S = Symbol.for("react.fragment"), w = Symbol.for("react.strict_mode"), D = Symbol.for("react.profiler"), y = Symbol.for("react.consumer"), R = Symbol.for("react.context"), P = Symbol.for("react.forward_ref"), g = Symbol.for("react.suspense"), k = Symbol.for("react.suspense_list"), Y = Symbol.for("react.memo"), L = Symbol.for("react.lazy"), Q = Symbol.for("react.activity"), K = Symbol.for("react.client.reference"), z = b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, U = Object.prototype.hasOwnProperty, H = Array.isArray, B = console.createTask ? console.createTask : function() {
246
+ return null;
247
+ };
248
+ b = {
249
+ react_stack_bottom_frame: function(e) {
250
+ return e();
251
+ }
252
+ };
253
+ var q, J = {}, V = b.react_stack_bottom_frame.bind(
254
+ b,
255
+ f
256
+ )(), A = B(j(f)), G = {};
257
+ W.Fragment = S, W.jsx = function(e, t, l) {
258
+ var i = 1e4 > z.recentlyCreatedOwnerStacks++;
259
+ return s(
260
+ e,
261
+ t,
262
+ l,
263
+ !1,
264
+ i ? Error("react-stack-top-frame") : V,
265
+ i ? B(j(e)) : A
266
+ );
267
+ }, W.jsxs = function(e, t, l) {
268
+ var i = 1e4 > z.recentlyCreatedOwnerStacks++;
269
+ return s(
270
+ e,
271
+ t,
272
+ l,
273
+ !0,
274
+ i ? Error("react-stack-top-frame") : V,
275
+ i ? B(j(e)) : A
276
+ );
277
+ };
278
+ })()), W;
279
+ }
280
+ var se;
281
+ function me() {
282
+ return se || (se = 1, process.env.NODE_ENV === "production" ? Z.exports = de() : Z.exports = fe()), Z.exports;
283
+ }
284
+ var r = me();
285
+ function ve({
286
+ data: a,
287
+ loading: h = !1,
288
+ columns: d,
289
+ rowKey: j,
290
+ emptyText: c = "暂无数据",
291
+ searchActiveEmptyText: f = "未找到匹配的记录",
292
+ header: x,
293
+ pagination: o,
294
+ rowClassName: _,
295
+ onRow: m,
296
+ actions: s,
297
+ components: T,
298
+ renderCard: N,
299
+ renderTable: b,
300
+ renderActions: E
301
+ }) {
302
+ var u, C;
303
+ if (!T)
304
+ return /* @__PURE__ */ r.jsxs("div", { className: "p-4 text-center text-destructive", children: [
305
+ "错误:请通过 components prop 注入 UI 组件",
306
+ /* @__PURE__ */ r.jsx("br", {}),
307
+ /* @__PURE__ */ r.jsx("code", { className: "text-sm", children: 'import { Card, Table, Button, ... } from "@/components/ui"' })
308
+ ] });
309
+ const {
310
+ Card: O,
311
+ CardContent: S,
312
+ CardFooter: w,
313
+ Table: D,
314
+ TableBody: y,
315
+ TableCell: R,
316
+ TableHead: P,
317
+ TableHeader: g,
318
+ TableRow: k,
319
+ Button: Y,
320
+ DropdownMenu: L,
321
+ DropdownMenuTrigger: Q,
322
+ DropdownMenuContent: K,
323
+ DropdownMenuItem: z,
324
+ DropdownMenuSeparator: U,
325
+ Skeleton: H,
326
+ TableHeaderComponent: B,
327
+ TablePaginationComponent: q
328
+ } = T, J = (n, p) => {
329
+ if (typeof j == "function")
330
+ return j(n);
331
+ const v = n[j];
332
+ return v != null ? String(v) : `row-${p}`;
333
+ }, V = !!(x != null && x.searchValue && x.searchValue.trim().length > 0), A = !!(s != null && s.render || (u = s == null ? void 0 : s.items) != null && u.length), G = (s == null ? void 0 : s.mode) ?? ((C = s == null ? void 0 : s.items) != null && C.length ? "collapsed" : "expanded"), e = (n) => n.separator === !0, t = (n, p) => !s || !A ? null : G === "collapsed" && s.items && s.items.length > 0 ? /* @__PURE__ */ r.jsxs(L, { children: [
334
+ /* @__PURE__ */ r.jsx(Q, { asChild: !0, children: /* @__PURE__ */ r.jsx(
335
+ Y,
336
+ {
337
+ variant: "ghost",
338
+ className: "h-8 w-8 p-0",
339
+ "aria-label": "打开行操作菜单",
340
+ children: /* @__PURE__ */ r.jsxs(
341
+ "svg",
342
+ {
343
+ className: "h-4 w-4",
344
+ fill: "none",
345
+ stroke: "currentColor",
346
+ viewBox: "0 0 24 24",
347
+ children: [
348
+ /* @__PURE__ */ r.jsx("circle", { cx: "12", cy: "12", r: "1" }),
349
+ /* @__PURE__ */ r.jsx("circle", { cx: "12", cy: "5", r: "1" }),
350
+ /* @__PURE__ */ r.jsx("circle", { cx: "12", cy: "19", r: "1" })
351
+ ]
352
+ }
353
+ )
354
+ }
355
+ ) }),
356
+ /* @__PURE__ */ r.jsx(K, { align: "end", children: s.items.map(
357
+ (v, X) => e(v) ? /* @__PURE__ */ r.jsx(U, {}, `separator-${X}`) : /* @__PURE__ */ r.jsxs(
358
+ z,
359
+ {
360
+ onClick: () => v.onClick(n, p),
361
+ className: v.className,
362
+ children: [
363
+ v.icon && /* @__PURE__ */ r.jsx("span", { className: "mr-2 h-4 w-4", children: v.icon }),
364
+ v.label
365
+ ]
366
+ },
367
+ `action-${X}`
368
+ )
369
+ ) })
370
+ ] }) : s.render ? s.render(n, p) : null, l = () => /* @__PURE__ */ r.jsx(g, { children: /* @__PURE__ */ r.jsxs(k, { className: "bg-muted/50 hover:bg-muted/50", children: [
371
+ d.map((n) => /* @__PURE__ */ r.jsx(
372
+ P,
373
+ {
374
+ className: `font-semibold text-foreground ${n.align === "center" ? "text-center" : n.align === "right" ? "text-right" : "text-left"}`,
375
+ style: { width: n.width },
376
+ children: n.title
377
+ },
378
+ String(n.key)
379
+ )),
380
+ A && /* @__PURE__ */ r.jsx(P, { className: "text-right font-semibold text-foreground", children: (s == null ? void 0 : s.title) || "操作" })
381
+ ] }) }), i = () => h ? /* @__PURE__ */ r.jsx(y, { children: Array.from({ length: 5 }).map((n, p) => /* @__PURE__ */ r.jsxs(k, { children: [
382
+ d.map((v) => /* @__PURE__ */ r.jsx(
383
+ R,
384
+ {
385
+ style: { width: v.width },
386
+ className: v.align === "center" ? "text-center" : v.align === "right" ? "text-right" : "",
387
+ children: /* @__PURE__ */ r.jsx(H, { className: "h-4 w-full" })
388
+ },
389
+ String(v.key)
390
+ )),
391
+ A && /* @__PURE__ */ r.jsx(R, { children: /* @__PURE__ */ r.jsx(H, { className: "ml-auto h-4 w-8" }) })
392
+ ] }, p)) }) : a.length === 0 ? /* @__PURE__ */ r.jsx(y, { children: /* @__PURE__ */ r.jsx(k, { children: /* @__PURE__ */ r.jsx(
393
+ R,
394
+ {
395
+ colSpan: d.length + (A ? 1 : 0),
396
+ className: "py-8 text-center text-muted-foreground",
397
+ children: V ? f : c
398
+ }
399
+ ) }) }) : /* @__PURE__ */ r.jsx(y, { children: a.map((n, p) => {
400
+ const v = J(n, p), X = m == null ? void 0 : m(n, p), ne = _ == null ? void 0 : _(n, p);
401
+ return /* @__PURE__ */ r.jsxs(
402
+ k,
403
+ {
404
+ className: `${ne || ""} hover:bg-muted/50`,
405
+ ...X,
406
+ children: [
407
+ d.map(($) => {
408
+ const ee = n[$.key], le = $.render ? $.render(ee, n, p) : ee;
409
+ return /* @__PURE__ */ r.jsx(
410
+ R,
411
+ {
412
+ className: $.align === "center" ? "text-center" : $.align === "right" ? "text-right" : "",
413
+ children: le
414
+ },
415
+ String($.key)
416
+ );
417
+ }),
418
+ A && /* @__PURE__ */ r.jsx(R, { className: "text-right", children: E ? E(n, p) : t(n, p) })
419
+ ]
420
+ },
421
+ v
422
+ );
423
+ }) }), I = (n) => /* @__PURE__ */ r.jsxs(O, { children: [
424
+ x && /* @__PURE__ */ r.jsx("div", { className: "p-6 pb-0", children: /* @__PURE__ */ r.jsx(B, { ...x }) }),
425
+ /* @__PURE__ */ r.jsx(S, { className: "p-0", children: n }),
426
+ (o == null ? void 0 : o.show) !== !1 && o && /* @__PURE__ */ r.jsx(w, { className: "border-t py-4", children: /* @__PURE__ */ r.jsx(
427
+ q,
428
+ {
429
+ currentPage: o.currentPage,
430
+ pageSize: o.pageSize,
431
+ total: o.total,
432
+ onPageChange: o.onPageChange,
433
+ onPageSizeChange: o.onPageSizeChange,
434
+ pageSizeOptions: o.pageSizeOptions,
435
+ showPageSizeSelector: o.showPageSizeSelector,
436
+ showTotal: o.showTotal,
437
+ searchActive: V
438
+ }
439
+ ) })
440
+ ] }), M = (n, p) => /* @__PURE__ */ r.jsxs(D, { children: [
441
+ n,
442
+ p
443
+ ] });
444
+ return N ? N(
445
+ b ? b(l(), i()) : M(l(), i())
446
+ ) : I(
447
+ b ? b(l(), i()) : M(l(), i())
448
+ );
449
+ }
450
+ function be({
451
+ open: a,
452
+ onOpenChange: h,
453
+ title: d,
454
+ description: j,
455
+ onConfirm: c,
456
+ loading: f = !1,
457
+ confirmText: x = "确认删除",
458
+ cancelText: o = "取消",
459
+ confirmButtonVariant: _ = "destructive",
460
+ verification: m,
461
+ components: s
462
+ }) {
463
+ const [T, N] = ie("");
464
+ if (ue(() => {
465
+ a && N("");
466
+ }, [a, m == null ? void 0 : m.targetValue]), !s)
467
+ return /* @__PURE__ */ r.jsx("div", { className: "p-4 text-center text-destructive", children: "错误:请通过 components prop 注入 UI 组件" });
468
+ const {
469
+ Dialog: b,
470
+ DialogContent: E,
471
+ DialogHeader: O,
472
+ DialogFooter: S,
473
+ DialogTitle: w,
474
+ DialogDescription: D,
475
+ Button: y,
476
+ Input: R,
477
+ Label: P
478
+ } = s, g = m ? T !== m.targetValue : !1, k = () => {
479
+ g || c();
480
+ };
481
+ return /* @__PURE__ */ r.jsx(b, { open: a, onOpenChange: h, children: /* @__PURE__ */ r.jsxs(E, { children: [
482
+ /* @__PURE__ */ r.jsxs(O, { children: [
483
+ /* @__PURE__ */ r.jsx(w, { asChild: !0, children: /* @__PURE__ */ r.jsx("div", { className: "flex items-center gap-2", children: d }) }),
484
+ /* @__PURE__ */ r.jsx(D, { asChild: !0, children: /* @__PURE__ */ r.jsx("div", { children: j }) })
485
+ ] }),
486
+ m && /* @__PURE__ */ r.jsx("div", { className: "space-y-4 py-2", children: /* @__PURE__ */ r.jsxs("div", { className: "space-y-2", children: [
487
+ /* @__PURE__ */ r.jsx(P, { htmlFor: "confirm-input", children: m.label || "请输入以确认" }),
488
+ /* @__PURE__ */ r.jsx(
489
+ R,
490
+ {
491
+ id: "confirm-input",
492
+ value: T,
493
+ onChange: (Y) => N(Y.target.value),
494
+ placeholder: m.placeholder,
495
+ disabled: f
496
+ }
497
+ )
498
+ ] }) }),
499
+ /* @__PURE__ */ r.jsxs(S, { children: [
500
+ /* @__PURE__ */ r.jsx(
501
+ y,
502
+ {
503
+ variant: "outline",
504
+ onClick: () => h(!1),
505
+ disabled: f,
506
+ children: o
507
+ }
508
+ ),
509
+ /* @__PURE__ */ r.jsxs(
510
+ y,
511
+ {
512
+ variant: _,
513
+ onClick: k,
514
+ disabled: g || f,
515
+ children: [
516
+ f && /* @__PURE__ */ r.jsxs(
517
+ "svg",
518
+ {
519
+ className: "mr-2 h-4 w-4 animate-spin",
520
+ fill: "none",
521
+ viewBox: "0 0 24 24",
522
+ children: [
523
+ /* @__PURE__ */ r.jsx(
524
+ "circle",
525
+ {
526
+ className: "opacity-25",
527
+ cx: "12",
528
+ cy: "12",
529
+ r: "10",
530
+ stroke: "currentColor",
531
+ strokeWidth: "4"
532
+ }
533
+ ),
534
+ /* @__PURE__ */ r.jsx(
535
+ "path",
536
+ {
537
+ className: "opacity-75",
538
+ fill: "currentColor",
539
+ 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"
540
+ }
541
+ )
542
+ ]
543
+ }
544
+ ),
545
+ x
546
+ ]
547
+ }
548
+ )
549
+ ] })
550
+ ] }) });
551
+ }
552
+ function ge({
553
+ title: a,
554
+ searchPlaceholder: h = "搜索...",
555
+ searchValue: d = "",
556
+ onSearchChange: j,
557
+ onSearch: c,
558
+ showSearch: f = !0,
559
+ action: x,
560
+ actionLabel: o,
561
+ onActionClick: _,
562
+ loading: m = !1,
563
+ components: s
564
+ }) {
565
+ if (!s)
566
+ return /* @__PURE__ */ r.jsx("div", { className: "p-4 text-center text-destructive", children: "错误:请通过 components prop 注入 UI 组件" });
567
+ const { Input: T, Button: N } = s, b = (E) => {
568
+ E.key === "Enter" && c && c();
569
+ };
570
+ return /* @__PURE__ */ r.jsxs("div", { className: "flex flex-col gap-4 p-1", children: [
571
+ /* @__PURE__ */ r.jsxs("div", { className: "flex items-center justify-between", children: [
572
+ /* @__PURE__ */ r.jsx("div", { className: "text-lg font-semibold leading-none tracking-tight", children: a }),
573
+ /* @__PURE__ */ r.jsxs("div", { className: "flex items-center gap-2", children: [
574
+ x && /* @__PURE__ */ r.jsx("div", { className: "flex items-center gap-2", children: x }),
575
+ !x && o && _ && /* @__PURE__ */ r.jsxs(N, { onClick: _, disabled: m, size: "sm", children: [
576
+ /* @__PURE__ */ r.jsx(
577
+ "svg",
578
+ {
579
+ className: "mr-2 h-4 w-4",
580
+ fill: "none",
581
+ stroke: "currentColor",
582
+ viewBox: "0 0 24 24",
583
+ children: /* @__PURE__ */ r.jsx(
584
+ "path",
585
+ {
586
+ strokeLinecap: "round",
587
+ strokeLinejoin: "round",
588
+ strokeWidth: 2,
589
+ d: "M12 4v16m8-8H4"
590
+ }
591
+ )
592
+ }
593
+ ),
594
+ o
595
+ ] })
596
+ ] })
597
+ ] }),
598
+ f && /* @__PURE__ */ r.jsxs("div", { className: "flex items-center gap-2", children: [
599
+ /* @__PURE__ */ r.jsxs("div", { className: "relative max-w-sm flex-1", children: [
600
+ /* @__PURE__ */ r.jsx(
601
+ "svg",
602
+ {
603
+ className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground",
604
+ fill: "none",
605
+ stroke: "currentColor",
606
+ viewBox: "0 0 24 24",
607
+ children: /* @__PURE__ */ r.jsx(
608
+ "path",
609
+ {
610
+ strokeLinecap: "round",
611
+ strokeLinejoin: "round",
612
+ strokeWidth: 2,
613
+ d: "M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
614
+ }
615
+ )
616
+ }
617
+ ),
618
+ /* @__PURE__ */ r.jsx(
619
+ T,
620
+ {
621
+ placeholder: h,
622
+ value: d,
623
+ onChange: (E) => j == null ? void 0 : j(E.target.value),
624
+ onKeyPress: b,
625
+ className: "h-9 pl-8",
626
+ disabled: m
627
+ }
628
+ )
629
+ ] }),
630
+ c && /* @__PURE__ */ r.jsx(
631
+ N,
632
+ {
633
+ onClick: c,
634
+ disabled: m,
635
+ variant: "secondary",
636
+ size: "sm",
637
+ children: "搜索"
638
+ }
639
+ )
640
+ ] })
641
+ ] });
642
+ }
643
+ function ke({
644
+ currentPage: a,
645
+ pageSize: h,
646
+ total: d,
647
+ onPageChange: j,
648
+ onPageSizeChange: c,
649
+ pageSizeOptions: f = [10, 20, 50],
650
+ showPageSizeSelector: x = !0,
651
+ showTotal: o = !0,
652
+ searchActive: _ = !1,
653
+ components: m
654
+ }) {
655
+ if (!m)
656
+ return /* @__PURE__ */ r.jsx("div", { className: "p-4 text-center text-destructive", children: "错误:请通过 components prop 注入 UI 组件" });
657
+ const {
658
+ Button: s,
659
+ Select: T,
660
+ SelectTrigger: N,
661
+ SelectContent: b,
662
+ SelectItem: E,
663
+ SelectValue: O
664
+ } = m, S = Math.ceil(d / h), w = Math.max(S, 1), D = a * h + 1, y = Math.min((a + 1) * h, d), R = Array.from(
665
+ /* @__PURE__ */ new Set([...f, h])
666
+ ).sort((g, k) => g - k), P = x && !!c;
667
+ return d === 0 ? null : /* @__PURE__ */ r.jsxs("div", { className: "flex w-full items-center justify-between", children: [
668
+ o && /* @__PURE__ */ r.jsx("div", { className: "text-sm text-muted-foreground", children: _ ? `找到 ${d} 条匹配记录` : d > 0 ? `显示 ${D} - ${y} 条,共 ${d} 条记录` : "暂无数据" }),
669
+ /* @__PURE__ */ r.jsxs("div", { className: "flex items-center space-x-2", children: [
670
+ P && /* @__PURE__ */ r.jsxs("div", { className: "mr-2 flex items-center gap-2", children: [
671
+ /* @__PURE__ */ r.jsx("span", { className: "text-sm text-muted-foreground", children: "每页" }),
672
+ /* @__PURE__ */ r.jsxs(
673
+ T,
674
+ {
675
+ value: String(h),
676
+ onValueChange: (g) => {
677
+ const k = Number(g);
678
+ Number.isNaN(k) || k === h || !c || c(k);
679
+ },
680
+ children: [
681
+ /* @__PURE__ */ r.jsx(N, { className: "h-8 w-[90px]", children: /* @__PURE__ */ r.jsx(O, {}) }),
682
+ /* @__PURE__ */ r.jsx(b, { children: R.map((g) => /* @__PURE__ */ r.jsx(E, { value: String(g), children: g }, g)) })
683
+ ]
684
+ }
685
+ ),
686
+ /* @__PURE__ */ r.jsx("span", { className: "text-sm text-muted-foreground", children: "条" })
687
+ ] }),
688
+ /* @__PURE__ */ r.jsxs("div", { className: "mr-4 text-sm text-muted-foreground", children: [
689
+ "第 ",
690
+ a + 1,
691
+ " 页,共 ",
692
+ w,
693
+ " 页"
694
+ ] }),
695
+ /* @__PURE__ */ r.jsxs(
696
+ s,
697
+ {
698
+ variant: "outline",
699
+ size: "sm",
700
+ onClick: () => j(a - 1),
701
+ disabled: a === 0 || w <= 1,
702
+ children: [
703
+ /* @__PURE__ */ r.jsx(
704
+ "svg",
705
+ {
706
+ className: "h-4 w-4",
707
+ fill: "none",
708
+ stroke: "currentColor",
709
+ viewBox: "0 0 24 24",
710
+ children: /* @__PURE__ */ r.jsx(
711
+ "path",
712
+ {
713
+ strokeLinecap: "round",
714
+ strokeLinejoin: "round",
715
+ strokeWidth: 2,
716
+ d: "M15 19l-7-7 7-7"
717
+ }
718
+ )
719
+ }
720
+ ),
721
+ "上一页"
722
+ ]
723
+ }
724
+ ),
725
+ /* @__PURE__ */ r.jsxs(
726
+ s,
727
+ {
728
+ variant: "outline",
729
+ size: "sm",
730
+ onClick: () => j(a + 1),
731
+ disabled: a >= w - 1 || w <= 1,
732
+ children: [
733
+ "下一页",
734
+ /* @__PURE__ */ r.jsx(
735
+ "svg",
736
+ {
737
+ className: "h-4 w-4",
738
+ fill: "none",
739
+ stroke: "currentColor",
740
+ viewBox: "0 0 24 24",
741
+ children: /* @__PURE__ */ r.jsx(
742
+ "path",
743
+ {
744
+ strokeLinecap: "round",
745
+ strokeLinejoin: "round",
746
+ strokeWidth: 2,
747
+ d: "M9 5l7 7-7 7"
748
+ }
749
+ )
750
+ }
751
+ )
752
+ ]
753
+ }
754
+ )
755
+ ] })
756
+ ] });
757
+ }
758
+ export {
759
+ ve as DataTable,
760
+ be as DeleteConfirmDialog,
761
+ ge as TableHeader,
762
+ ke as TablePagination,
763
+ pe as cn
764
+ };
765
+ //# sourceMappingURL=index.js.map