@rue-js/design 0.0.21

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.
@@ -0,0 +1,2060 @@
1
+ /**
2
+ * @rue-js/design v0.0.21
3
+ * (c) 2025-present Xiangmin Liu and Rue contributors
4
+ * @license MIT
5
+ **/
6
+ 'use strict';
7
+
8
+ Object.defineProperty(exports, '__esModule', { value: true });
9
+
10
+ var rue = require('@rue-js/rue');
11
+ var router = require('@rue-js/router');
12
+
13
+ function jsx(type, props, key) {
14
+ const p = key !== void 0 ? (() => {
15
+ const o = {};
16
+ if (props) {
17
+ for (const k in props) o[k] = props[k];
18
+ }
19
+ o.key = key;
20
+ return o;
21
+ })() : props ? props : null;
22
+ const c = props ? props.children : void 0;
23
+ return Array.isArray(c) ? rue.h(type, p, ...c) : c !== void 0 ? rue.h(type, p, c) : rue.h(type, p);
24
+ }
25
+ const jsxs = jsx;
26
+
27
+ const Alert = ({
28
+ variant,
29
+ outline,
30
+ dash,
31
+ soft,
32
+ direction,
33
+ className,
34
+ children
35
+ }) => {
36
+ let cls = "alert";
37
+ if (variant) cls += ` alert-${variant}`;
38
+ if (outline) cls += ` alert-outline`;
39
+ if (dash) cls += ` alert-dash`;
40
+ if (soft) cls += ` alert-soft`;
41
+ if (direction) cls += ` alert-${direction}`;
42
+ if (className) cls += ` ${className}`;
43
+ return /* @__PURE__ */ jsx("div", { role: "alert", className: cls, children });
44
+ };
45
+
46
+ const Accordion = ({
47
+ icon,
48
+ force,
49
+ use = "radio",
50
+ name,
51
+ open,
52
+ className,
53
+ children,
54
+ items
55
+ }) => {
56
+ if (items && items.length) {
57
+ return /* @__PURE__ */ jsx(rue.Fragment, { children: items.map((it, i) => {
58
+ const iIcon = it.icon ?? icon;
59
+ const iForce = it.force ?? force;
60
+ const iUse = it.use ?? use;
61
+ let iCls = "collapse";
62
+ if (iIcon === "arrow") iCls += ` collapse-arrow`;
63
+ if (iIcon === "plus") iCls += ` collapse-plus`;
64
+ if (iForce === "open") iCls += ` collapse-open`;
65
+ if (iForce === "close") iCls += ` collapse-close`;
66
+ if (className) iCls += ` ${className}`;
67
+ if (it.className) iCls += ` ${it.className}`;
68
+ if (iUse === "details") {
69
+ return /* @__PURE__ */ jsxs("details", { className: iCls, name, open: it.open, children: [
70
+ /* @__PURE__ */ jsx(
71
+ "summary",
72
+ {
73
+ className: it.titleClassName ? `collapse-title ${it.titleClassName}` : "collapse-title",
74
+ children: it.title
75
+ }
76
+ ),
77
+ /* @__PURE__ */ jsx(
78
+ "div",
79
+ {
80
+ className: it.contentClassName ? `collapse-content ${it.contentClassName}` : "collapse-content",
81
+ children: it.content
82
+ }
83
+ )
84
+ ] }, i);
85
+ }
86
+ return /* @__PURE__ */ jsxs("div", { className: iCls, children: [
87
+ /* @__PURE__ */ jsx("input", { type: "radio", name, checked: it.open }),
88
+ /* @__PURE__ */ jsx(
89
+ "div",
90
+ {
91
+ className: it.titleClassName ? `collapse-title ${it.titleClassName}` : "collapse-title",
92
+ children: it.title
93
+ }
94
+ ),
95
+ /* @__PURE__ */ jsx(
96
+ "div",
97
+ {
98
+ className: it.contentClassName ? `collapse-content ${it.contentClassName}` : "collapse-content",
99
+ children: it.content
100
+ }
101
+ )
102
+ ] }, i);
103
+ }) });
104
+ }
105
+ let cls = "collapse";
106
+ if (icon === "arrow") cls += ` collapse-arrow`;
107
+ if (icon === "plus") cls += ` collapse-plus`;
108
+ if (force === "open") cls += ` collapse-open`;
109
+ if (force === "close") cls += ` collapse-close`;
110
+ if (className) cls += ` ${className}`;
111
+ if (use === "details") {
112
+ return /* @__PURE__ */ jsx("details", { className: cls, name, open, children });
113
+ }
114
+ return /* @__PURE__ */ jsxs("div", { className: cls, children: [
115
+ /* @__PURE__ */ jsx("input", { type: "radio", name, checked: open }),
116
+ children
117
+ ] });
118
+ };
119
+ const Title$4 = ({ className, children, as = "div" }) => {
120
+ let cls = "collapse-title";
121
+ if (className) cls += ` ${className}`;
122
+ return as === "summary" ? /* @__PURE__ */ jsx("summary", { className: cls, children }) : /* @__PURE__ */ jsx("div", { className: cls, children });
123
+ };
124
+ const Content$1 = ({ className, children }) => {
125
+ let cls = "collapse-content";
126
+ if (className) cls += ` ${className}`;
127
+ return /* @__PURE__ */ jsx("div", { className: cls, children });
128
+ };
129
+ const AccordionCompound = Object.assign(Accordion, {
130
+ Title: Title$4,
131
+ Content: Content$1
132
+ });
133
+
134
+ const Button = ({
135
+ variant,
136
+ size,
137
+ outline,
138
+ dash,
139
+ soft,
140
+ ghost,
141
+ link,
142
+ active,
143
+ block,
144
+ wide,
145
+ square,
146
+ circle,
147
+ disabled,
148
+ disabledClass,
149
+ loading,
150
+ type,
151
+ className,
152
+ onClick,
153
+ children
154
+ }) => {
155
+ let cls = "btn";
156
+ if (variant) cls += ` btn-${variant}`;
157
+ if (size) cls += ` btn-${size}`;
158
+ if (outline) cls += ` btn-outline`;
159
+ if (dash) cls += ` btn-dash`;
160
+ if (soft) cls += ` btn-soft`;
161
+ if (ghost) cls += ` btn-ghost`;
162
+ if (link) cls += ` btn-link`;
163
+ if (active) cls += ` btn-active`;
164
+ if (block) cls += ` btn-block`;
165
+ if (wide) cls += ` btn-wide`;
166
+ if (square) cls += ` btn-square`;
167
+ if (circle) cls += ` btn-circle`;
168
+ if (disabledClass) cls += ` btn-disabled`;
169
+ if (className) cls += ` ${className}`;
170
+ return /* @__PURE__ */ jsx("button", { className: cls, disabled: disabled || loading, type, onClick, children });
171
+ };
172
+
173
+ const Card = ({ size, border, dash, side, imageFull, className, children }) => {
174
+ let cls = "card";
175
+ if (size) cls += ` card-${size}`;
176
+ if (border) cls += ` card-border`;
177
+ if (dash) cls += ` card-dash`;
178
+ if (side) cls += ` card-side`;
179
+ if (imageFull) cls += ` image-full`;
180
+ if (className) cls += ` ${className}`;
181
+ return /* @__PURE__ */ jsx("div", { className: cls, children });
182
+ };
183
+ const Body$1 = ({ className, children }) => {
184
+ let cls = "card-body";
185
+ if (className) cls += ` ${className}`;
186
+ return /* @__PURE__ */ jsx("div", { className: cls, children });
187
+ };
188
+ const Title$3 = ({ className, children }) => {
189
+ let cls = "card-title";
190
+ if (className) cls += ` ${className}`;
191
+ return /* @__PURE__ */ jsx("h2", { className: cls, children });
192
+ };
193
+ const Actions$1 = ({ className, children }) => {
194
+ let cls = "card-actions";
195
+ if (className) cls += ` ${className}`;
196
+ return /* @__PURE__ */ jsx("div", { className: cls, children });
197
+ };
198
+ const Figure$1 = ({ className, children }) => {
199
+ let cls = "figure";
200
+ if (className) cls += ` ${className}`;
201
+ return /* @__PURE__ */ jsx("figure", { className: cls, children });
202
+ };
203
+ const CardCompound = Object.assign(Card, {
204
+ Body: Body$1,
205
+ Title: Title$3,
206
+ Actions: Actions$1,
207
+ Figure: Figure$1
208
+ });
209
+
210
+ const Avatar = ({ status, className, children }) => {
211
+ let cls = "avatar not-prose";
212
+ if (status) cls += ` avatar-${status}`;
213
+ if (className) cls += ` ${className}`;
214
+ return /* @__PURE__ */ jsx("div", { className: cls, children });
215
+ };
216
+ const Group = ({ className, children, items }) => {
217
+ let cls = "avatar-group";
218
+ if (className) cls += ` ${className}`;
219
+ if (items && items.length) {
220
+ return /* @__PURE__ */ jsx("div", { className: cls, children: items.map((m, i) => (
221
+ /* 逐项渲染子头像 */
222
+ /* @__PURE__ */ jsx(Avatar, { status: m.status, children: m.children }, i)
223
+ )) });
224
+ }
225
+ return /* @__PURE__ */ jsx("div", { className: cls, children });
226
+ };
227
+ const AvatarCompound = Object.assign(Avatar, {
228
+ Group
229
+ });
230
+
231
+ const Divider = ({ variant, direction, placement, className, children }) => {
232
+ let cls = "divider";
233
+ if (direction) cls += ` divider-${direction}`;
234
+ if (variant) cls += ` divider-${variant}`;
235
+ if (placement) cls += ` divider-${placement}`;
236
+ if (className) cls += ` ${className}`;
237
+ return /* @__PURE__ */ jsx("div", { className: cls, children });
238
+ };
239
+
240
+ const Footer$1 = ({ direction, center, className, children }) => {
241
+ let cls = "footer";
242
+ if (direction) cls += ` footer-${direction}`;
243
+ if (center) cls += ` footer-center`;
244
+ if (className) cls += ` ${className}`;
245
+ return /* @__PURE__ */ jsx("footer", { className: cls, children });
246
+ };
247
+
248
+ const Modal = ({ open, title, children, actions, className, onClose }) => {
249
+ if (!open) return null;
250
+ return /* @__PURE__ */ jsx("div", { className: "modal modal-open", children: /* @__PURE__ */ jsxs("div", { className: `modal-box ${className ?? ""}`, children: [
251
+ title ? /* @__PURE__ */ jsx("div", { className: "font-semibold mb-2", children: title }) : null,
252
+ children,
253
+ /* @__PURE__ */ jsxs("div", { className: "modal-action", children: [
254
+ actions,
255
+ onClose ? /* @__PURE__ */ jsx("button", { className: "btn", onClick: onClose, children: "\u5173\u95ED" }) : null
256
+ ] })
257
+ ] }) });
258
+ };
259
+
260
+ const Tabs = ({ items, activeKey, onChange, style, placement, size, className }) => {
261
+ let cls = "tabs";
262
+ if (style === "box") cls += " tabs-box";
263
+ if (style === "border") cls += " tabs-border";
264
+ if (style === "lift") cls += " tabs-lift";
265
+ if (placement === "bottom") cls += " tabs-bottom";
266
+ if (size) cls += ` tabs-${size}`;
267
+ if (className) cls += ` ${className}`;
268
+ return /* @__PURE__ */ jsx("div", { role: "tablist", className: cls, children: items.map((it) => /* @__PURE__ */ jsx(
269
+ "button",
270
+ {
271
+ role: "tab",
272
+ className: `tab ${activeKey === it.key ? "tab-active" : ""} ${it.disabled ? "tab-disabled" : ""} ${it.className ?? ""}`,
273
+ disabled: it.disabled,
274
+ onClick: () => !it.disabled && onChange && onChange(it.key),
275
+ children: it.label
276
+ },
277
+ it.key
278
+ )) });
279
+ };
280
+
281
+ const Badge = ({
282
+ variant,
283
+ size,
284
+ outline,
285
+ dash,
286
+ soft,
287
+ ghost,
288
+ className,
289
+ children
290
+ }) => {
291
+ let cls = "badge";
292
+ if (variant) cls += ` badge-${variant}`;
293
+ if (size) cls += ` badge-${size}`;
294
+ if (outline) cls += ` badge-outline`;
295
+ if (dash) cls += ` badge-dash`;
296
+ if (soft) cls += ` badge-soft`;
297
+ if (ghost) cls += ` badge-ghost`;
298
+ if (className) cls += ` ${className}`;
299
+ return /* @__PURE__ */ jsx("div", { className: cls, children });
300
+ };
301
+
302
+ const Diff = ({ className, tabIndex, children }) => {
303
+ let cls = "diff";
304
+ if (className) cls += ` ${className}`;
305
+ return /* @__PURE__ */ jsx("figure", { className: cls, tabIndex, children });
306
+ };
307
+ const Item1 = ({ className, role, tabIndex, children }) => {
308
+ let cls = "diff-item-1";
309
+ if (className) cls += ` ${className}`;
310
+ return /* @__PURE__ */ jsx("div", { className: cls, role, tabIndex, children });
311
+ };
312
+ const Item2 = ({ className, role, tabIndex, children }) => {
313
+ let cls = "diff-item-2";
314
+ if (className) cls += ` ${className}`;
315
+ return /* @__PURE__ */ jsx("div", { className: cls, role, tabIndex, children });
316
+ };
317
+ const Resizer = ({ className }) => {
318
+ let cls = "diff-resizer";
319
+ if (className) cls += ` ${className}`;
320
+ return /* @__PURE__ */ jsx("div", { className: cls });
321
+ };
322
+ const DiffCompound = Object.assign(Diff, {
323
+ Item1,
324
+ Item2,
325
+ Resizer
326
+ });
327
+
328
+ const OverlayDivs = () => /* @__PURE__ */ jsxs(rue.Fragment, { children: [
329
+ /* @__PURE__ */ jsx("div", {}),
330
+ /* @__PURE__ */ jsx("div", {}),
331
+ /* @__PURE__ */ jsx("div", {}),
332
+ /* @__PURE__ */ jsx("div", {}),
333
+ /* @__PURE__ */ jsx("div", {}),
334
+ /* @__PURE__ */ jsx("div", {}),
335
+ /* @__PURE__ */ jsx("div", {}),
336
+ /* @__PURE__ */ jsx("div", {})
337
+ ] });
338
+ const Hover3D = ({ as = "div", href, className, overlays = true, children }) => {
339
+ const cls = className ? `hover-3d ${className}` : "hover-3d";
340
+ if (as === "a") {
341
+ return /* @__PURE__ */ jsxs("a", { href, className: cls, children: [
342
+ children,
343
+ overlays ? /* @__PURE__ */ jsx(OverlayDivs, {}) : null
344
+ ] });
345
+ }
346
+ return /* @__PURE__ */ jsxs("div", { className: cls, children: [
347
+ children,
348
+ overlays ? /* @__PURE__ */ jsx(OverlayDivs, {}) : null
349
+ ] });
350
+ };
351
+
352
+ const Timeline = ({
353
+ direction,
354
+ snapIcon,
355
+ compact,
356
+ className,
357
+ children,
358
+ items
359
+ }) => {
360
+ let cls = "timeline";
361
+ if (direction) cls += ` timeline-${direction}`;
362
+ if (snapIcon) cls += ` timeline-snap-icon`;
363
+ if (compact) cls += ` timeline-compact`;
364
+ if (className) cls += ` ${className}`;
365
+ if (items && items.length) {
366
+ return /* @__PURE__ */ jsx("ul", { className: cls, children: items.map((it, i) => /* @__PURE__ */ jsxs("li", { className: it.liClassName, children: [
367
+ it.beforeLine ? /* @__PURE__ */ jsx("hr", {}) : null,
368
+ it.start ? /* @__PURE__ */ jsx(Start, { box: it.start.box, className: it.start.className, children: it.start.content }) : null,
369
+ it.middle ? /* @__PURE__ */ jsx(Middle, { className: it.middle.className, children: it.middle.content }) : null,
370
+ it.end ? /* @__PURE__ */ jsx(End, { box: it.end.box, className: it.end.className, children: it.end.content }) : null,
371
+ it.afterLine ? /* @__PURE__ */ jsx("hr", {}) : null
372
+ ] }, i)) });
373
+ }
374
+ return /* @__PURE__ */ jsx("ul", { className: cls, children });
375
+ };
376
+ const Start = ({ box, className, children }) => {
377
+ let cls = "timeline-start";
378
+ if (box) cls += ` timeline-box`;
379
+ if (className) cls += ` ${className}`;
380
+ return /* @__PURE__ */ jsx("div", { className: cls, children });
381
+ };
382
+ const Middle = ({ className, children }) => {
383
+ let cls = "timeline-middle";
384
+ if (className) cls += ` ${className}`;
385
+ return /* @__PURE__ */ jsx("div", { className: cls, children });
386
+ };
387
+ const End = ({ box, className, children }) => {
388
+ let cls = "timeline-end";
389
+ if (box) cls += ` timeline-box`;
390
+ if (className) cls += ` ${className}`;
391
+ return /* @__PURE__ */ jsx("div", { className: cls, children });
392
+ };
393
+ const TimelineCompound = Object.assign(Timeline, {
394
+ Start,
395
+ Middle,
396
+ End
397
+ });
398
+
399
+ const TextRotate = ({ className, children, items, innerClassName }) => {
400
+ let cls = "text-rotate";
401
+ if (className) cls += ` ${className}`;
402
+ if (items && items.length) {
403
+ return /* @__PURE__ */ jsx("span", { className: cls, children: /* @__PURE__ */ jsx("span", { className: innerClassName, children: items.map((m, i) => /* @__PURE__ */ jsx("span", { className: m.className, children: m.text }, i)) }) });
404
+ }
405
+ return /* @__PURE__ */ jsx("span", { className: cls, children });
406
+ };
407
+
408
+ const Status = ({ as = "span", ariaLabel, size, color, className, children }) => {
409
+ let cls = "status";
410
+ if (size) cls += ` status-${size}`;
411
+ if (color) cls += ` status-${color}`;
412
+ if (className) cls += ` ${className}`;
413
+ const common = { className: cls, "aria-label": ariaLabel };
414
+ if (as === "div") {
415
+ return /* @__PURE__ */ jsx("div", { ...common, children });
416
+ }
417
+ return /* @__PURE__ */ jsx("span", { ...common, children });
418
+ };
419
+
420
+ const Stat = ({ direction, className, children, items }) => {
421
+ let cls = "stats";
422
+ if (direction) cls += ` stats-${direction}`;
423
+ if (className) cls += ` ${className}`;
424
+ if (items && items.length) {
425
+ return /* @__PURE__ */ jsx("div", { className: cls, children: items.map((m, i) => {
426
+ const itemCls = m.className;
427
+ return (
428
+ /* 单项:按 center/figure/title/value/desc/actions 组合 */
429
+ /* @__PURE__ */ jsxs(Item$5, { center: m.center, className: itemCls, children: [
430
+ m.figure ? /* @__PURE__ */ jsx(Figure, { className: m.figureClassName, children: m.figure }) : null,
431
+ m.title ? /* @__PURE__ */ jsx(Title$2, { className: m.titleClassName, children: m.title }) : null,
432
+ m.value ? /* @__PURE__ */ jsx(Value$1, { className: m.valueClassName, children: m.value }) : null,
433
+ m.desc ? /* @__PURE__ */ jsx(Desc, { className: m.descClassName, children: m.desc }) : null,
434
+ m.actions ? /* @__PURE__ */ jsx(Actions, { className: m.actionsClassName, children: m.actions }) : null
435
+ ] }, i)
436
+ );
437
+ }) });
438
+ }
439
+ return /* @__PURE__ */ jsx("div", { className: cls, children });
440
+ };
441
+ const Item$5 = ({ center, className, children }) => {
442
+ let cls = "stat";
443
+ if (center) cls += ` place-items-center`;
444
+ if (className) cls += ` ${className}`;
445
+ return /* @__PURE__ */ jsx("div", { className: cls, children });
446
+ };
447
+ const Title$2 = ({ className, children }) => {
448
+ let cls = "stat-title";
449
+ if (className) cls += ` ${className}`;
450
+ return /* @__PURE__ */ jsx("div", { className: cls, children });
451
+ };
452
+ const Value$1 = ({ className, children }) => {
453
+ let cls = "stat-value";
454
+ if (className) cls += ` ${className}`;
455
+ return /* @__PURE__ */ jsx("div", { className: cls, children });
456
+ };
457
+ const Desc = ({ className, children }) => {
458
+ let cls = "stat-desc";
459
+ if (className) cls += ` ${className}`;
460
+ return /* @__PURE__ */ jsx("div", { className: cls, children });
461
+ };
462
+ const Figure = ({ className, children }) => {
463
+ let cls = "stat-figure";
464
+ if (className) cls += ` ${className}`;
465
+ return /* @__PURE__ */ jsx("div", { className: cls, children });
466
+ };
467
+ const Actions = ({ className, children }) => {
468
+ let cls = "stat-actions";
469
+ if (className) cls += ` ${className}`;
470
+ return /* @__PURE__ */ jsx("div", { className: cls, children });
471
+ };
472
+ const StatCompound = Object.assign(Stat, {
473
+ Item: Item$5,
474
+ Title: Title$2,
475
+ Value: Value$1,
476
+ Desc,
477
+ Figure,
478
+ Actions
479
+ });
480
+
481
+ const Carousel = ({
482
+ align = "start",
483
+ direction = "horizontal",
484
+ auto = false,
485
+ interval = 3e3,
486
+ loop = true,
487
+ autoDirection = "forward",
488
+ activeIndex,
489
+ onIndexChange,
490
+ className,
491
+ children,
492
+ items
493
+ }) => {
494
+ const containerRef = rue.useRef();
495
+ let cls = "carousel";
496
+ if (align === "center") cls += ` carousel-center`;
497
+ if (align === "end") cls += ` carousel-end`;
498
+ if (direction === "vertical") cls += ` carousel-vertical`;
499
+ else cls += ` carousel-horizontal`;
500
+ if (className) cls += ` ${className}`;
501
+ const getItems = () => {
502
+ const el = containerRef.current;
503
+ if (!el) return [];
504
+ return Array.from(el.querySelectorAll(".carousel-item"));
505
+ };
506
+ const scrollToIndex = (i) => {
507
+ const items2 = getItems();
508
+ if (!items2.length) return;
509
+ const idx = Math.max(0, Math.min(i, items2.length - 1));
510
+ const target = items2[idx];
511
+ const el = containerRef.current;
512
+ if (!el || !target) return;
513
+ const canScrollTo = typeof el.scrollTo === "function";
514
+ if (direction === "vertical") {
515
+ if (canScrollTo) el.scrollTo({ top: target.offsetTop, behavior: "smooth" });
516
+ else el.scrollTop = target.offsetTop;
517
+ } else {
518
+ if (canScrollTo) el.scrollTo({ left: target.offsetLeft, behavior: "smooth" });
519
+ else el.scrollLeft = target.offsetLeft;
520
+ }
521
+ if (onIndexChange) onIndexChange(idx);
522
+ };
523
+ const getCurrentIndex = () => {
524
+ const items2 = getItems();
525
+ const el = containerRef.current;
526
+ if (!el || !items2.length) return 0;
527
+ const pos = direction === "vertical" ? el.scrollTop : el.scrollLeft;
528
+ let idx = 0;
529
+ for (let i = 0; i < items2.length; i++) {
530
+ const off = direction === "vertical" ? items2[i].offsetTop : items2[i].offsetLeft;
531
+ if (off <= pos + 1) idx = i;
532
+ else break;
533
+ }
534
+ return idx;
535
+ };
536
+ let timer = null;
537
+ const smoothScrollTo = (pos) => {
538
+ const el = containerRef.current;
539
+ if (!el) return;
540
+ const canScrollTo = typeof el.scrollTo === "function";
541
+ if (direction === "vertical") {
542
+ requestAnimationFrame(() => {
543
+ if (canScrollTo) el.scrollTo({ top: pos, behavior: "smooth" });
544
+ else el.scrollTop = pos;
545
+ });
546
+ } else {
547
+ requestAnimationFrame(() => {
548
+ if (canScrollTo) el.scrollTo({ left: pos, behavior: "smooth" });
549
+ else el.scrollLeft = pos;
550
+ });
551
+ }
552
+ };
553
+ const scrollByPage = (dir) => {
554
+ const el = containerRef.current;
555
+ if (!el) return;
556
+ const delta = direction === "vertical" ? el.clientHeight : el.clientWidth;
557
+ const pos = direction === "vertical" ? el.scrollTop : el.scrollLeft;
558
+ const max = direction === "vertical" ? el.scrollHeight : el.scrollWidth;
559
+ let nextPos = pos;
560
+ if (dir === "forward") {
561
+ if (loop) {
562
+ if (pos - delta >= 0) {
563
+ nextPos = pos - delta;
564
+ } else {
565
+ nextPos = Math.max(0, max - delta);
566
+ }
567
+ } else {
568
+ nextPos = Math.max(pos - delta, 0);
569
+ }
570
+ } else {
571
+ if (loop) {
572
+ if (pos + delta <= Math.max(0, max - delta)) {
573
+ nextPos = pos + delta;
574
+ } else {
575
+ nextPos = 0;
576
+ }
577
+ } else {
578
+ nextPos = Math.min(pos + delta, Math.max(0, max - delta));
579
+ }
580
+ }
581
+ smoothScrollTo(nextPos);
582
+ const idx = getCurrentIndex();
583
+ if (onIndexChange) onIndexChange(idx);
584
+ };
585
+ const startAuto = () => {
586
+ if (!auto) return;
587
+ stopAuto();
588
+ timer = setInterval(() => {
589
+ if (autoDirection === "backward") scrollByPage("backward");
590
+ else scrollByPage("forward");
591
+ }, interval);
592
+ };
593
+ const stopAuto = () => {
594
+ if (timer) {
595
+ clearInterval(timer);
596
+ timer = null;
597
+ }
598
+ };
599
+ rue.onMounted(() => {
600
+ const el = containerRef.current;
601
+ if (el && loop) {
602
+ const delta = direction === "vertical" ? el.clientHeight : el.clientWidth;
603
+ const max = direction === "vertical" ? el.scrollHeight : el.scrollWidth;
604
+ if (autoDirection === "forward") {
605
+ if (direction === "vertical") el.scrollTop = Math.max(0, max - delta);
606
+ else {
607
+ el.scrollLeft = Math.max(0, max - delta);
608
+ }
609
+ } else {
610
+ if (direction === "vertical") el.scrollTop = 0;
611
+ else el.scrollLeft = 0;
612
+ }
613
+ }
614
+ startAuto();
615
+ });
616
+ rue.onUnmounted(() => {
617
+ stopAuto();
618
+ });
619
+ rue.watch(
620
+ () => activeIndex,
621
+ (v) => {
622
+ if (typeof v === "number") {
623
+ scrollToIndex(v);
624
+ }
625
+ },
626
+ { immediate: true }
627
+ );
628
+ return /* @__PURE__ */ jsx("div", { ref: containerRef, className: cls, children: items && items.length ? items.map((it, i) => /* @__PURE__ */ jsx("div", { className: `carousel-item${it.className ? ` ${it.className}` : ""}`, children: it.content }, i)) : children });
629
+ };
630
+ const Item$4 = ({ className, children }) => {
631
+ let cls = "carousel-item";
632
+ if (className) cls += ` ${className}`;
633
+ return /* @__PURE__ */ jsx("div", { className: cls, children });
634
+ };
635
+ const CarouselCompound = Object.assign(Carousel, {
636
+ Item: Item$4
637
+ });
638
+
639
+ const Chat = ({ placement, className, children, items }) => {
640
+ if (items && items.length) {
641
+ return /* @__PURE__ */ jsx(rue.Fragment, { children: items.map((m, i) => {
642
+ let cls2 = "chat";
643
+ cls2 += ` chat-${m.placement}`;
644
+ if (className) cls2 += ` ${className}`;
645
+ return /* @__PURE__ */ jsxs("div", { className: cls2, children: [
646
+ m.imageSrc ? /* @__PURE__ */ jsx(Image, { className: m.imageClassName, children: /* @__PURE__ */ jsx("div", { className: "w-10 rounded-full", children: /* @__PURE__ */ jsx("img", { alt: m.imageAlt ?? "chat image", src: m.imageSrc }) }) }) : null,
647
+ m.headerName || m.headerTime ? /* @__PURE__ */ jsxs(Header, { className: m.headerClassName, children: [
648
+ m.headerName,
649
+ " ",
650
+ m.headerTime ? /* @__PURE__ */ jsx("time", { className: "text-xs opacity-50", children: m.headerTime }) : null
651
+ ] }) : null,
652
+ /* @__PURE__ */ jsx(Bubble, { color: m.color, children: m.text }),
653
+ m.footer ? /* @__PURE__ */ jsx(Footer, { className: m.footerClassName, children: m.footer }) : null
654
+ ] }, i);
655
+ }) });
656
+ }
657
+ let cls = "chat";
658
+ cls += ` chat-${placement}`;
659
+ if (className) cls += ` ${className}`;
660
+ return /* @__PURE__ */ jsx("div", { className: cls, children });
661
+ };
662
+ const Bubble = ({ color, className, children }) => {
663
+ let cls = "chat-bubble";
664
+ if (color) cls += ` chat-bubble-${color}`;
665
+ if (className) cls += ` ${className}`;
666
+ return /* @__PURE__ */ jsx("div", { className: cls, children });
667
+ };
668
+ const Header = ({ className, children }) => {
669
+ let cls = "chat-header";
670
+ if (className) cls += ` ${className}`;
671
+ return /* @__PURE__ */ jsx("div", { className: cls, children });
672
+ };
673
+ const Footer = ({ className, children }) => {
674
+ let cls = "chat-footer";
675
+ if (className) cls += ` ${className}`;
676
+ return /* @__PURE__ */ jsx("div", { className: cls, children });
677
+ };
678
+ const Image = ({ className, children }) => {
679
+ let cls = "chat-image";
680
+ if (className) cls += ` ${className}`;
681
+ return /* @__PURE__ */ jsx("div", { className: cls, children });
682
+ };
683
+ const ChatCompound = Object.assign(Chat, {
684
+ Bubble,
685
+ Header,
686
+ Footer,
687
+ Image
688
+ });
689
+
690
+ const Collapse = ({
691
+ arrow,
692
+ plus,
693
+ open,
694
+ close,
695
+ tabIndex,
696
+ tag = "div",
697
+ className,
698
+ children
699
+ }) => {
700
+ let cls = "collapse";
701
+ if (arrow) cls += " collapse-arrow";
702
+ if (plus) cls += " collapse-plus";
703
+ if (open) cls += " collapse-open";
704
+ if (close) cls += " collapse-close";
705
+ if (className) cls += ` ${className}`;
706
+ if (tag === "details") {
707
+ return /* @__PURE__ */ jsx("details", { className: cls, children });
708
+ }
709
+ const props = { className: cls };
710
+ if (typeof tabIndex === "number") props.tabIndex = tabIndex;
711
+ return /* @__PURE__ */ jsx("div", { ...props, children });
712
+ };
713
+ const Title$1 = ({ as = "div", className, children }) => {
714
+ let cls = "collapse-title";
715
+ if (className) cls += ` ${className}`;
716
+ if (as === "summary") return /* @__PURE__ */ jsx("summary", { className: cls, children });
717
+ return /* @__PURE__ */ jsx("div", { className: cls, children });
718
+ };
719
+ const Content = ({ className, children }) => {
720
+ let cls = "collapse-content";
721
+ if (className) cls += ` ${className}`;
722
+ return /* @__PURE__ */ jsx("div", { className: cls, children });
723
+ };
724
+ const CollapseCompound = Object.assign(Collapse, {
725
+ Title: Title$1,
726
+ Content
727
+ });
728
+
729
+ const Countdown = ({ className, children, items }) => {
730
+ let cls = "countdown";
731
+ if (className) cls += ` ${className}`;
732
+ if (items && items.length) {
733
+ return /* @__PURE__ */ jsx("span", { className: cls, children: items.map((it, i) => {
734
+ if ("value" in it) {
735
+ const { value, digits, className: vCls, ariaLive, ariaLabel, children: children2 } = it;
736
+ return /* @__PURE__ */ jsx(
737
+ Value,
738
+ {
739
+ value,
740
+ digits,
741
+ className: vCls,
742
+ ariaLive,
743
+ ariaLabel,
744
+ children: children2
745
+ },
746
+ i
747
+ );
748
+ }
749
+ return /* @__PURE__ */ jsx("span", { className: it.className, children: it.content }, i);
750
+ }) });
751
+ }
752
+ return /* @__PURE__ */ jsx("span", { className: cls, children });
753
+ };
754
+ const Value = ({
755
+ value,
756
+ digits,
757
+ className,
758
+ ariaLive = "polite",
759
+ ariaLabel,
760
+ children
761
+ }) => {
762
+ const styleAttr = `--value:${value};${digits != null ? ` --digits:${digits};` : ""}`;
763
+ let cls = "";
764
+ if (className) cls += ` ${className}`;
765
+ return /* @__PURE__ */ jsx(
766
+ "span",
767
+ {
768
+ style: styleAttr,
769
+ "aria-live": ariaLive,
770
+ "aria-label": ariaLabel ?? String(value),
771
+ className: cls.trim(),
772
+ children: children != null ? children : rue.h("div", null, String(value))
773
+ }
774
+ );
775
+ };
776
+ const CountdownCompound = Object.assign(Countdown, {
777
+ Value
778
+ });
779
+
780
+ const HoverGallery = ({ as = "figure", className, children, items }) => {
781
+ let cls = "hover-gallery";
782
+ if (className) cls += ` ${className}`;
783
+ const content = items && items.length ? items.map((it, i) => {
784
+ if (typeof it === "string") {
785
+ return /* @__PURE__ */ jsx("img", { src: it, alt: "" }, i);
786
+ }
787
+ if (it && typeof it === "object") {
788
+ const obj = it;
789
+ if (obj.node) return obj.node;
790
+ if (obj.src)
791
+ return /* @__PURE__ */ jsx("img", { src: obj.src, alt: obj.alt ?? "", className: obj.className }, i);
792
+ }
793
+ return it;
794
+ }) : children;
795
+ return as === "figure" ? /* @__PURE__ */ jsx("figure", { className: cls, children: content }) : /* @__PURE__ */ jsx("div", { className: cls, children: content });
796
+ };
797
+
798
+ const Kbd = ({ size, className, children }) => {
799
+ let cls = "kbd";
800
+ if (size) cls += ` kbd-${size}`;
801
+ if (className) cls += ` ${className}`;
802
+ return /* @__PURE__ */ jsx("kbd", { className: cls, children });
803
+ };
804
+
805
+ const List = ({ className, children, items }) => {
806
+ let cls = "list";
807
+ if (className) cls += ` ${className}`;
808
+ if (items && items.length) {
809
+ return /* @__PURE__ */ jsx("ul", { className: cls, children: items.map((m, i) => {
810
+ const t = m.type ?? (m.cols ? "row" : "item");
811
+ if (t === "item") {
812
+ const liCls2 = m.className ? `${m.className}` : "";
813
+ return /* @__PURE__ */ jsx("li", { className: liCls2 || void 0, children: m.content }, i);
814
+ }
815
+ if (m.normal) {
816
+ const liCls2 = m.className ? `${m.className}` : "";
817
+ return /* @__PURE__ */ jsxs("li", { className: liCls2 || void 0, children: [
818
+ m.content,
819
+ m.cols?.map((c, ci) => {
820
+ if (c.type === "grow")
821
+ return /* @__PURE__ */ jsx(ColGrow, { as: c.as, className: c.className, children: c.content }, ci);
822
+ return /* @__PURE__ */ jsx(ColWrap, { as: c.as, className: c.className, children: c.content }, ci);
823
+ })
824
+ ] }, i);
825
+ }
826
+ let liCls = "list-row";
827
+ if (m.className) liCls += ` ${m.className}`;
828
+ return /* @__PURE__ */ jsxs("li", { className: liCls, children: [
829
+ m.content,
830
+ m.cols?.map((c, ci) => {
831
+ if (c.type === "grow")
832
+ return /* @__PURE__ */ jsx(ColGrow, { as: c.as, className: c.className, children: c.content }, ci);
833
+ return /* @__PURE__ */ jsx(ColWrap, { as: c.as, className: c.className, children: c.content }, ci);
834
+ })
835
+ ] }, i);
836
+ }) });
837
+ }
838
+ return /* @__PURE__ */ jsx("ul", { className: cls, children });
839
+ };
840
+ const Row = ({ normal, className, children }) => {
841
+ if (normal) {
842
+ const cls2 = className ? `${className}` : "";
843
+ return /* @__PURE__ */ jsx("li", { className: cls2 || void 0, children });
844
+ }
845
+ let cls = "list-row";
846
+ if (className) cls += ` ${className}`;
847
+ return /* @__PURE__ */ jsx("li", { className: cls, children });
848
+ };
849
+ const ColGrow = ({ as = "div", className, children }) => {
850
+ let cls = "list-col-grow";
851
+ if (className) cls += ` ${className}`;
852
+ if (as === "p") return /* @__PURE__ */ jsx("p", { className: cls, children });
853
+ if (as === "span") return /* @__PURE__ */ jsx("span", { className: cls, children });
854
+ return /* @__PURE__ */ jsx("div", { className: cls, children });
855
+ };
856
+ const ColWrap = ({ as = "div", className, children }) => {
857
+ let cls = "list-col-wrap";
858
+ if (className) cls += ` ${className}`;
859
+ if (as === "p") return /* @__PURE__ */ jsx("p", { className: cls, children });
860
+ if (as === "span") return /* @__PURE__ */ jsx("span", { className: cls, children });
861
+ return /* @__PURE__ */ jsx("div", { className: cls, children });
862
+ };
863
+ const Item$3 = ({ className, children }) => {
864
+ let cls = "";
865
+ if (className) cls += ` ${className}`;
866
+ return /* @__PURE__ */ jsx("li", { className: cls.trim(), children });
867
+ };
868
+ const ListCompound = Object.assign(List, {
869
+ Row,
870
+ ColGrow,
871
+ ColWrap,
872
+ Item: Item$3
873
+ });
874
+
875
+ const getVal = (record, dataIndex) => {
876
+ if (!dataIndex) return void 0;
877
+ if (Array.isArray(dataIndex)) {
878
+ let cur = record;
879
+ for (const k of dataIndex) {
880
+ if (cur == null) return void 0;
881
+ cur = cur[k];
882
+ }
883
+ return cur;
884
+ }
885
+ return record?.[dataIndex];
886
+ };
887
+ const alignClass = (align) => {
888
+ if (align === "right") return "text-right";
889
+ if (align === "center") return "text-center";
890
+ return "text-left";
891
+ };
892
+ const Table = ({
893
+ size,
894
+ zebra,
895
+ pinRows,
896
+ pinCols,
897
+ className,
898
+ children,
899
+ dataSource,
900
+ columns,
901
+ rowKey = "key",
902
+ showHeader = true,
903
+ onRow,
904
+ onHeaderRow,
905
+ onChange,
906
+ rowSelection,
907
+ pagination,
908
+ expandable,
909
+ rowClassName,
910
+ summary,
911
+ emptyText,
912
+ title,
913
+ footer,
914
+ rowHoverable = false,
915
+ rowHoverClass,
916
+ tableLayout,
917
+ scroll,
918
+ height,
919
+ onScroll
920
+ }) => {
921
+ let cls = "table";
922
+ if (size) cls += ` table-${size}`;
923
+ if (zebra) cls += ` table-zebra`;
924
+ if (pinRows) cls += ` table-pin-rows`;
925
+ if (pinCols) cls += ` table-pin-cols`;
926
+ if (className) cls += ` ${className}`;
927
+ const hasChildren = !(children === void 0 || children === null || Array.isArray(children) && children.length === 0);
928
+ if (hasChildren) return /* @__PURE__ */ jsx("table", { className: cls, children });
929
+ if (Array.isArray(columns) && Array.isArray(dataSource)) {
930
+ const tableId = Math.random().toString(36).slice(2);
931
+ const headerProps = onHeaderRow ? onHeaderRow(columns, 0) || {} : {};
932
+ const visibleColumns = columns.filter((col) => !col.hidden);
933
+ let sortColIndex = null;
934
+ let sortOrder = null;
935
+ visibleColumns.forEach((col, i) => {
936
+ if (col.sortOrder != null) {
937
+ sortColIndex = i;
938
+ sortOrder = col.sortOrder;
939
+ } else if (sortColIndex == null && col.defaultSortOrder) {
940
+ sortColIndex = i;
941
+ sortOrder = col.defaultSortOrder;
942
+ }
943
+ });
944
+ let workingData = dataSource.slice();
945
+ const activeFilters = {};
946
+ const getColKey = (col) => typeof col.dataIndex === "string" ? col.dataIndex : Array.isArray(col.dataIndex) ? col.dataIndex.join(".") : col.key;
947
+ visibleColumns.forEach((col) => {
948
+ const vals = col.filteredValue ?? col.defaultFilteredValue;
949
+ if (Array.isArray(vals) && vals.length > 0) {
950
+ const key = getColKey(col);
951
+ if (key) activeFilters[key] = vals;
952
+ workingData = workingData.filter((rec) => {
953
+ if (col.onFilter) {
954
+ if (col.filterCombine === "and") {
955
+ return vals.every((v) => col.onFilter(v, rec));
956
+ }
957
+ return vals.some((v) => col.onFilter(v, rec));
958
+ }
959
+ const rv = getVal(rec, col.dataIndex);
960
+ return vals.includes(rv);
961
+ });
962
+ }
963
+ });
964
+ if (sortColIndex != null && sortOrder && visibleColumns[sortColIndex]) {
965
+ const col = visibleColumns[sortColIndex];
966
+ const cmp = typeof col.sorter === "function" ? col.sorter : (a, b) => {
967
+ const va = getVal(a, col.dataIndex);
968
+ const vb = getVal(b, col.dataIndex);
969
+ if (va == null && vb == null) return 0;
970
+ if (va == null) return -1;
971
+ if (vb == null) return 1;
972
+ if (va > vb) return 1;
973
+ if (va < vb) return -1;
974
+ return 0;
975
+ };
976
+ workingData.sort((a, b) => sortOrder === "ascend" ? cmp(a, b) : -cmp(a, b));
977
+ }
978
+ let page = 1;
979
+ let pageSize = workingData.length;
980
+ if (pagination !== false && pagination != null) {
981
+ page = pagination.current || 1;
982
+ pageSize = pagination.pageSize || 10;
983
+ }
984
+ const total = workingData.length;
985
+ const pageCount = Math.ceil(total / pageSize) || 1;
986
+ const start = (page - 1) * pageSize;
987
+ const end = start + pageSize;
988
+ const pageData = workingData.slice(start, end);
989
+ const hasSelection = !!rowSelection;
990
+ const hasExpand = !!expandable && typeof expandable.expandedRowRender === "function";
991
+ const expKeys = new Set(
992
+ expandable?.expandedRowKeys || (expandable?.defaultExpandAllRows ? workingData.map((rec) => typeof rowKey === "function" ? rowKey(rec) : rec?.[rowKey]) : [])
993
+ );
994
+ const selectedBase = rowSelection?.selectedRowKeys ?? rowSelection?.defaultSelectedRowKeys ?? [];
995
+ const isSelected = (key) => Array.isArray(selectedBase) && selectedBase.includes(key);
996
+ const onHeaderSortClick = (i) => {
997
+ const col = visibleColumns[i];
998
+ if (!col.sorter) return;
999
+ let next = "ascend";
1000
+ if (sortColIndex === i && sortOrder === "ascend") next = "descend";
1001
+ else if (sortColIndex === i && sortOrder === "descend") next = null;
1002
+ if (onChange)
1003
+ onChange(
1004
+ { current: page, pageSize },
1005
+ activeFilters,
1006
+ { column: col, order: next },
1007
+ { action: "sort", currentDataSource: pageData }
1008
+ );
1009
+ };
1010
+ const onPageChange = (p) => {
1011
+ if (pagination !== false && pagination != null && pagination.onChange)
1012
+ pagination.onChange(p, pageSize);
1013
+ if (onChange)
1014
+ onChange(
1015
+ { current: p, pageSize },
1016
+ activeFilters,
1017
+ { order: sortOrder, column: sortColIndex != null ? visibleColumns[sortColIndex] : null },
1018
+ { action: "paginate", currentDataSource: pageData }
1019
+ );
1020
+ };
1021
+ const onHeaderSetSort = (i, order) => {
1022
+ const col = visibleColumns[i];
1023
+ if (!col.sorter) return;
1024
+ if (onChange)
1025
+ onChange(
1026
+ { current: page, pageSize },
1027
+ activeFilters,
1028
+ { column: col, order },
1029
+ { action: "sort", currentDataSource: pageData }
1030
+ );
1031
+ };
1032
+ const resetHeaderFilterMenu = (i, menuEl) => {
1033
+ const col = visibleColumns[i];
1034
+ const el = menuEl || document.getElementById(`table-filter-menu-${i}`);
1035
+ if (!col || !el) return;
1036
+ const defaults = col.filterResetToDefaultFilteredValue ? col.defaultFilteredValue ?? [] : [];
1037
+ const inputs = el.querySelectorAll(
1038
+ 'input[type="checkbox"], input[type="radio"]'
1039
+ );
1040
+ inputs.forEach((inp) => {
1041
+ const v = inp.getAttribute("data-value") || inp.value;
1042
+ if (inp.type === "checkbox") {
1043
+ inp.checked = defaults.includes(v);
1044
+ } else {
1045
+ inp.checked = defaults[0] === v;
1046
+ }
1047
+ });
1048
+ };
1049
+ const ensureOutsideCloseRegistered = (id) => {
1050
+ const g = globalThis;
1051
+ const key = `__rue_table_outside_close_${id}`;
1052
+ if (g[key]) return;
1053
+ const handler = (e) => {
1054
+ const target = e.target;
1055
+ const withinIcon = target.closest(`[data-rue-table-id="${id}"] .rue-table-filter-icon`);
1056
+ const withinMenu = target.closest(`[data-rue-table-id="${id}"] .rue-table-filter-menu`);
1057
+ if (!withinIcon && !withinMenu) {
1058
+ const tableEl = document.querySelector(
1059
+ `table[data-rue-table-id="${id}"]`
1060
+ );
1061
+ if (!tableEl) return;
1062
+ const menus = tableEl.querySelectorAll(".rue-table-filter-menu");
1063
+ menus.forEach((m) => m.style.display = "none");
1064
+ }
1065
+ };
1066
+ if (g && g.addEventListener) g.addEventListener("pointerdown", handler);
1067
+ g[key] = handler;
1068
+ };
1069
+ ensureOutsideCloseRegistered(tableId);
1070
+ const toggleHeaderFilterMenu = (i, open, anchor) => {
1071
+ let el = null;
1072
+ if (anchor) {
1073
+ const cell = anchor.closest("th, td");
1074
+ el = cell ? cell.querySelector(".rue-table-filter-menu") : null;
1075
+ }
1076
+ if (!el) el = document.getElementById(`table-filter-menu-${i}`);
1077
+ if (!el) return;
1078
+ const hidden = el.style.display === "none";
1079
+ const shouldOpen = open != null ? open : hidden;
1080
+ if (!shouldOpen) {
1081
+ el.style.display = "none";
1082
+ return;
1083
+ }
1084
+ el.style.position = "fixed";
1085
+ el.style.visibility = "hidden";
1086
+ el.style.display = "";
1087
+ const anchorEl = anchor || el;
1088
+ const rect = anchorEl.getBoundingClientRect();
1089
+ const menuW = el.offsetWidth || 176;
1090
+ const menuH = el.offsetHeight || 160;
1091
+ const gap = 8;
1092
+ const vw = window.innerWidth;
1093
+ const vh = window.innerHeight;
1094
+ let top = rect.bottom + gap;
1095
+ let left = rect.left;
1096
+ if (vh - rect.bottom < menuH + gap) top = Math.max(8, rect.top - menuH - gap);
1097
+ if (vw - rect.left < menuW + 8) left = Math.max(8, rect.right - menuW);
1098
+ el.style.visibility = "";
1099
+ el.style.top = `${top}px`;
1100
+ el.style.left = `${left}px`;
1101
+ el.style.maxHeight = "calc(100vh - 16px)";
1102
+ el.style.overflow = "auto";
1103
+ el.style.zIndex = "50";
1104
+ };
1105
+ const collectHeaderFilterValues = (i, menuEl) => {
1106
+ const el = menuEl || document.getElementById(`table-filter-menu-${i}`);
1107
+ if (!el) return [];
1108
+ const inputs = el.querySelectorAll(
1109
+ 'input[type="checkbox"], input[type="radio"]'
1110
+ );
1111
+ const vals = [];
1112
+ inputs.forEach((inp) => {
1113
+ const v = inp.getAttribute("data-value") || inp.value;
1114
+ if (inp.checked) vals.push(v);
1115
+ });
1116
+ return vals;
1117
+ };
1118
+ const onHeaderFilterApply = (i, vals, menuEl) => {
1119
+ const col = visibleColumns[i];
1120
+ if (!col || !Array.isArray(col.filters) || col.filters.length === 0) return;
1121
+ const key = getColKey(col);
1122
+ const cur = Array.isArray(vals) ? vals : collectHeaderFilterValues(i, menuEl);
1123
+ const nextFilters = { ...activeFilters };
1124
+ if (key) nextFilters[key] = cur;
1125
+ if (onChange)
1126
+ onChange(
1127
+ { current: page, pageSize },
1128
+ nextFilters,
1129
+ { order: sortOrder, column: sortColIndex != null ? visibleColumns[sortColIndex] : null },
1130
+ { action: "filter", currentDataSource: pageData }
1131
+ );
1132
+ toggleHeaderFilterMenu(i, false, menuEl || void 0);
1133
+ };
1134
+ const toggleExpand = (key, record, e) => {
1135
+ const btnEl = e?.currentTarget;
1136
+ const rowEl = btnEl ? btnEl.closest("tr") : null;
1137
+ const expRow = rowEl?.nextElementSibling;
1138
+ if (expRow) {
1139
+ const hidden = expRow.style.display === "none";
1140
+ expRow.style.display = hidden ? "" : "none";
1141
+ if (btnEl) btnEl.textContent = hidden ? "-" : "+";
1142
+ }
1143
+ const has = expKeys.has(key);
1144
+ if (expandable?.onExpand) expandable.onExpand(!has, record);
1145
+ };
1146
+ const selectAll = (checked) => {
1147
+ if (!rowSelection || rowSelection.type === "radio") return;
1148
+ const keys = checked ? pageData.map((rec) => typeof rowKey === "function" ? rowKey(rec) : rec?.[rowKey]) : [];
1149
+ if (rowSelection.onChange) {
1150
+ const rows = workingData.filter(
1151
+ (rec) => keys.includes(typeof rowKey === "function" ? rowKey(rec) : rec?.[rowKey])
1152
+ );
1153
+ rowSelection.onChange(keys, rows, { type: "checkbox" });
1154
+ }
1155
+ if (rowSelection.onSelectAll) {
1156
+ const rows = workingData.filter(
1157
+ (rec) => keys.includes(typeof rowKey === "function" ? rowKey(rec) : rec?.[rowKey])
1158
+ );
1159
+ rowSelection.onSelectAll(checked, rows);
1160
+ }
1161
+ };
1162
+ const pageKeys = pageData.map(
1163
+ (rec) => typeof rowKey === "function" ? rowKey(rec) : rec?.[rowKey]
1164
+ );
1165
+ const allSelectedOnPage = pageKeys.length > 0 && pageKeys.every((k) => isSelected(k));
1166
+ const someSelectedOnPage = pageKeys.some((k) => isSelected(k)) && !allSelectedOnPage;
1167
+ const tableStyle = {};
1168
+ const needFixedLayout = visibleColumns.some((c) => !!c.ellipsis);
1169
+ if (tableLayout) tableStyle.tableLayout = tableLayout;
1170
+ else if (needFixedLayout) tableStyle.tableLayout = "fixed";
1171
+ const wrapperNeeded = !!(scroll?.x || scroll?.y || typeof height !== "undefined" || onScroll);
1172
+ const wrapperStyle = {};
1173
+ const wrapperCls = `${scroll?.x ? "overflow-x-auto" : ""} ${scroll?.y || typeof height !== "undefined" ? "overflow-y-auto" : ""}`.trim() || void 0;
1174
+ if (typeof scroll?.y !== "undefined") {
1175
+ const maxH = typeof scroll.y === "number" ? `${scroll.y}px` : scroll.y;
1176
+ wrapperStyle.maxHeight = maxH;
1177
+ }
1178
+ if (typeof height !== "undefined") {
1179
+ const h = typeof height === "number" ? `${height}px` : height;
1180
+ wrapperStyle.height = h;
1181
+ }
1182
+ return wrapperNeeded ? /* @__PURE__ */ jsxs("div", { className: wrapperCls, style: wrapperStyle, onScroll, children: [
1183
+ typeof title === "function" ? /* @__PURE__ */ jsx("div", { className: "p-2", children: title(pageData) }) : null,
1184
+ /* @__PURE__ */ jsxs("table", { className: cls, style: tableStyle, "data-rue-table-id": tableId, children: [
1185
+ showHeader ? /* @__PURE__ */ jsx("thead", { ...headerProps, children: /* @__PURE__ */ jsxs("tr", { children: [
1186
+ hasExpand ? /* @__PURE__ */ jsx("th", { className: alignClass("center") }) : null,
1187
+ hasSelection ? /* @__PURE__ */ jsx(
1188
+ "th",
1189
+ {
1190
+ style: rowSelection?.columnWidth ? { width: rowSelection.columnWidth } : void 0,
1191
+ className: alignClass("center"),
1192
+ children: rowSelection?.type !== "radio" ? /* @__PURE__ */ jsx("label", { children: /* @__PURE__ */ jsx(
1193
+ "input",
1194
+ {
1195
+ type: "checkbox",
1196
+ className: "checkbox",
1197
+ checked: allSelectedOnPage,
1198
+ "aria-checked": someSelectedOnPage ? "mixed" : allSelectedOnPage ? "true" : "false",
1199
+ disabled: !!rowSelection?.disabled,
1200
+ onChange: (e) => selectAll(e.target.checked)
1201
+ }
1202
+ ) }) : null
1203
+ }
1204
+ ) : null,
1205
+ visibleColumns.map((col, i) => {
1206
+ const cellProps = col.onHeaderCell ? col.onHeaderCell(col, i) || {} : {};
1207
+ const keyVal = col.key ?? col.dataIndex ?? i;
1208
+ const className2 = `${alignClass(col.align)}${col.className ? ` ${col.className}` : ""}${cellProps.className ? ` ${cellProps.className}` : ""}`.trim() || void 0;
1209
+ const style = col.width ? { width: col.width } : cellProps.style;
1210
+ if (pinCols && !col.fixedCol) {
1211
+ return /* @__PURE__ */ jsx(
1212
+ "td",
1213
+ {
1214
+ className: className2,
1215
+ style,
1216
+ onClick: () => onHeaderSortClick(i),
1217
+ ...cellProps,
1218
+ children: col.title
1219
+ },
1220
+ keyVal
1221
+ );
1222
+ }
1223
+ return /* @__PURE__ */ jsx(
1224
+ "th",
1225
+ {
1226
+ className: className2,
1227
+ style,
1228
+ onClick: () => onHeaderSortClick(i),
1229
+ ...cellProps,
1230
+ children: col.title
1231
+ },
1232
+ keyVal
1233
+ );
1234
+ })
1235
+ ] }) }) : null,
1236
+ /* @__PURE__ */ jsxs("tbody", { children: [
1237
+ pageData.map((record, rowIndex) => {
1238
+ const key = typeof rowKey === "function" ? rowKey(record) : record?.[rowKey];
1239
+ const rowProps = onRow ? onRow(record, rowIndex) || {} : {};
1240
+ const baseCls = typeof rowClassName === "function" ? rowClassName(record, rowIndex) : "";
1241
+ const hoverCls = rowHoverable ? rowHoverClass || "hover:bg-base-200" : "";
1242
+ const rowCls = `${baseCls}${hoverCls ? ` ${hoverCls}` : ""}`.trim() || void 0;
1243
+ const colSpan = (visibleColumns.length || 0) + (hasSelection ? 1 : 0) + (hasExpand ? 1 : 0);
1244
+ return /* @__PURE__ */ jsxs(rue.Fragment, { children: [
1245
+ /* @__PURE__ */ jsxs(
1246
+ "tr",
1247
+ {
1248
+ ...rowProps,
1249
+ className: rowCls || rowProps.className,
1250
+ children: [
1251
+ hasExpand ? /* @__PURE__ */ jsx("td", { className: alignClass("center"), children: /* @__PURE__ */ jsx(
1252
+ "button",
1253
+ {
1254
+ className: "btn btn-ghost btn-xs",
1255
+ onClick: (e) => toggleExpand(key, record, e),
1256
+ children: expKeys.has(key) ? "-" : "+"
1257
+ }
1258
+ ) }) : null,
1259
+ hasSelection ? /* @__PURE__ */ jsx(
1260
+ "td",
1261
+ {
1262
+ className: alignClass("center"),
1263
+ style: rowSelection?.columnWidth ? { width: rowSelection.columnWidth } : void 0,
1264
+ children: /* @__PURE__ */ jsx("label", { children: rowSelection?.type === "radio" ? /* @__PURE__ */ jsx(
1265
+ "input",
1266
+ {
1267
+ type: "radio",
1268
+ className: "radio",
1269
+ checked: !!isSelected(key),
1270
+ onChange: () => {
1271
+ const keys = [key];
1272
+ if (rowSelection?.onChange) {
1273
+ const rows = workingData.filter(
1274
+ (rec) => keys.includes(
1275
+ typeof rowKey === "function" ? rowKey(rec) : rec?.[rowKey]
1276
+ )
1277
+ );
1278
+ rowSelection.onChange(keys, rows, { type: "radio" });
1279
+ }
1280
+ },
1281
+ ...rowSelection?.getCheckboxProps ? rowSelection.getCheckboxProps(record) : {}
1282
+ }
1283
+ ) : /* @__PURE__ */ jsx(
1284
+ "input",
1285
+ {
1286
+ type: "checkbox",
1287
+ className: "checkbox",
1288
+ checked: !!isSelected(key),
1289
+ onChange: (e) => {
1290
+ const checked = e.target.checked;
1291
+ const base = rowSelection?.selectedRowKeys ?? rowSelection?.defaultSelectedRowKeys ?? [];
1292
+ const set = new Set(base);
1293
+ if (checked) set.add(key);
1294
+ else set.delete(key);
1295
+ const keys = Array.from(set);
1296
+ if (rowSelection?.onChange) {
1297
+ const rows = workingData.filter(
1298
+ (rec) => keys.includes(
1299
+ typeof rowKey === "function" ? rowKey(rec) : rec?.[rowKey]
1300
+ )
1301
+ );
1302
+ rowSelection.onChange(keys, rows, { type: "checkbox" });
1303
+ }
1304
+ },
1305
+ ...rowSelection?.getCheckboxProps ? rowSelection.getCheckboxProps(record) : {}
1306
+ }
1307
+ ) })
1308
+ }
1309
+ ) : null,
1310
+ visibleColumns.map((col, colIndex) => {
1311
+ const val = getVal(record, col.dataIndex);
1312
+ const node = col.render ? col.render(val, record, rowIndex) : val;
1313
+ const cellCls = `${alignClass(col.align)}${col.className ? ` ${col.className}` : ""}${col.ellipsis ? " truncate" : ""}`;
1314
+ const cellProps = col.onCell ? col.onCell(record, rowIndex) || {} : {};
1315
+ const keyVal = col.key ?? `${rowIndex}-${colIndex}`;
1316
+ const className2 = `${cellCls}${cellProps.className ? ` ${cellProps.className}` : ""}`.trim() || void 0;
1317
+ const style = col.width ? { width: col.width } : cellProps.style;
1318
+ if (pinCols && col.fixedCol) {
1319
+ return /* @__PURE__ */ jsx("th", { className: className2, style, ...cellProps, children: node }, keyVal);
1320
+ }
1321
+ return /* @__PURE__ */ jsx("td", { className: className2, style, ...cellProps, children: node }, keyVal);
1322
+ })
1323
+ ]
1324
+ },
1325
+ key ?? rowIndex
1326
+ ),
1327
+ hasExpand && expandable?.expandedRowRender ? /* @__PURE__ */ jsx("tr", { style: { display: expKeys.has(key) ? "" : "none" }, children: /* @__PURE__ */ jsx("td", { colSpan, children: expandable.expandedRowRender(record, rowIndex) }) }, `expanded-${key}`) : null
1328
+ ] });
1329
+ }),
1330
+ pageData.length === 0 ? /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx(
1331
+ "td",
1332
+ {
1333
+ colSpan: (visibleColumns.length || 0) + (hasSelection ? 1 : 0) + (hasExpand ? 1 : 0),
1334
+ className: alignClass("center"),
1335
+ children: typeof emptyText !== "undefined" ? emptyText : "No Data"
1336
+ }
1337
+ ) }) : null
1338
+ ] }),
1339
+ (() => {
1340
+ const colSpan = (visibleColumns.length || 0) + (hasSelection ? 1 : 0) + (hasExpand ? 1 : 0);
1341
+ const summaryInfo = { total, page, pageSize };
1342
+ const pageDataWithTotal = pageData.slice();
1343
+ pageDataWithTotal.total = total;
1344
+ const summaryNode = typeof summary === "function" ? summary(pageDataWithTotal, summaryInfo) : null;
1345
+ const showPager = pagination !== false && pagination != null && !(pagination.hideOnSinglePage && pageCount <= 1);
1346
+ if (!summaryNode && !showPager) return null;
1347
+ return /* @__PURE__ */ jsxs("tfoot", { children: [
1348
+ summaryNode ? /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { colSpan, children: summaryNode }) }) : null,
1349
+ showPager ? /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { colSpan, children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-2 p-2", children: [
1350
+ /* @__PURE__ */ jsx(
1351
+ "button",
1352
+ {
1353
+ className: "btn btn-ghost btn-xs",
1354
+ disabled: page <= 1,
1355
+ onClick: () => onPageChange(page - 1),
1356
+ children: "Prev"
1357
+ }
1358
+ ),
1359
+ Array.from({ length: pageCount }).map((_, i) => /* @__PURE__ */ jsx(
1360
+ "button",
1361
+ {
1362
+ className: `btn btn-ghost btn-xs${page === i + 1 ? " btn-active" : ""}`,
1363
+ onClick: () => onPageChange(i + 1),
1364
+ children: i + 1
1365
+ },
1366
+ i
1367
+ )),
1368
+ /* @__PURE__ */ jsx(
1369
+ "button",
1370
+ {
1371
+ className: "btn btn-ghost btn-xs",
1372
+ disabled: page >= pageCount,
1373
+ onClick: () => onPageChange(page + 1),
1374
+ children: "Next"
1375
+ }
1376
+ )
1377
+ ] }) }) }) : null
1378
+ ] });
1379
+ })()
1380
+ ] }),
1381
+ typeof footer === "function" ? /* @__PURE__ */ jsx("div", { className: "p-2", children: footer(pageData) }) : null
1382
+ ] }) : /* @__PURE__ */ jsxs("table", { className: cls, style: tableStyle, "data-rue-table-id": tableId, children: [
1383
+ showHeader ? /* @__PURE__ */ jsx("thead", { ...headerProps, children: /* @__PURE__ */ jsxs("tr", { children: [
1384
+ hasExpand ? /* @__PURE__ */ jsx("th", { className: alignClass("center") }) : null,
1385
+ hasSelection ? /* @__PURE__ */ jsx(
1386
+ "th",
1387
+ {
1388
+ style: rowSelection?.columnWidth ? { width: rowSelection.columnWidth } : void 0,
1389
+ className: alignClass("center"),
1390
+ children: rowSelection?.type !== "radio" ? /* @__PURE__ */ jsx("label", { children: /* @__PURE__ */ jsx(
1391
+ "input",
1392
+ {
1393
+ type: "checkbox",
1394
+ className: "checkbox",
1395
+ checked: allSelectedOnPage,
1396
+ "aria-checked": someSelectedOnPage ? "mixed" : allSelectedOnPage ? "true" : "false",
1397
+ disabled: !!rowSelection?.disabled,
1398
+ onChange: (e) => selectAll(e.target.checked)
1399
+ }
1400
+ ) }) : null
1401
+ }
1402
+ ) : null,
1403
+ visibleColumns.map((col, i) => {
1404
+ const cellProps = col.onHeaderCell ? col.onHeaderCell(col, i) || {} : {};
1405
+ const keyVal = col.key ?? col.dataIndex ?? i;
1406
+ const className2 = `${alignClass(col.align)}${col.className ? ` ${col.className}` : ""}${cellProps.className ? ` ${cellProps.className}` : ""}`.trim() || void 0;
1407
+ const style = col.width ? { width: col.width } : cellProps.style;
1408
+ if (pinCols && !col.fixedCol) {
1409
+ return /* @__PURE__ */ jsxs(
1410
+ "td",
1411
+ {
1412
+ className: className2,
1413
+ style,
1414
+ onClick: () => onHeaderSortClick(i),
1415
+ ...cellProps,
1416
+ children: [
1417
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center relative", children: [
1418
+ /* @__PURE__ */ jsx("span", { children: col.title }),
1419
+ col.sorter ? /* @__PURE__ */ jsxs("span", { className: "ml-1 inline-flex flex-col leading-none", children: [
1420
+ /* @__PURE__ */ jsx(
1421
+ "span",
1422
+ {
1423
+ className: `${sortColIndex === i && sortOrder === "ascend" ? "text-base-content" : "opacity-40"} cursor-pointer`,
1424
+ onClick: (e) => {
1425
+ e.stopPropagation();
1426
+ onHeaderSetSort(i, "ascend");
1427
+ },
1428
+ children: "\u25B2"
1429
+ }
1430
+ ),
1431
+ /* @__PURE__ */ jsx(
1432
+ "span",
1433
+ {
1434
+ className: `${sortColIndex === i && sortOrder === "descend" ? "text-base-content" : "opacity-40"} cursor-pointer -mt-0.5`,
1435
+ onClick: (e) => {
1436
+ e.stopPropagation();
1437
+ onHeaderSetSort(i, "descend");
1438
+ },
1439
+ children: "\u25BC"
1440
+ }
1441
+ )
1442
+ ] }) : null,
1443
+ Array.isArray(col.filters) && col.filters.length > 0 ? /* @__PURE__ */ jsx(
1444
+ "span",
1445
+ {
1446
+ className: `rue-table-filter-icon ml-2 cursor-pointer ${activeFilters[getColKey(col)]?.length ? "text-base-content" : "opacity-40"}`,
1447
+ onClick: (e) => {
1448
+ e.stopPropagation();
1449
+ toggleHeaderFilterMenu(i, void 0, e.currentTarget);
1450
+ },
1451
+ children: "\u2630"
1452
+ }
1453
+ ) : null
1454
+ ] }),
1455
+ Array.isArray(col.filters) && col.filters.length > 0 ? (() => {
1456
+ const menuGroup = `header-filter-${i}-${Math.random().toString(36).slice(2)}`;
1457
+ return /* @__PURE__ */ jsxs(
1458
+ "div",
1459
+ {
1460
+ id: `table-filter-menu-${i}`,
1461
+ className: "rue-table-filter-menu fixed z-50 w-44 rounded-box border border-base-content/10 bg-base-100 p-2 shadow",
1462
+ style: { display: "none" },
1463
+ children: [
1464
+ /* @__PURE__ */ jsx("div", { className: "space-y-1", children: col.filters.map((f) => /* @__PURE__ */ jsxs(
1465
+ "label",
1466
+ {
1467
+ className: "flex items-center gap-2",
1468
+ children: [
1469
+ /* @__PURE__ */ jsx(
1470
+ "input",
1471
+ {
1472
+ type: col.filterMultiple === false ? "radio" : "checkbox",
1473
+ name: menuGroup,
1474
+ className: col.filterMultiple === false ? "radio radio-xs" : "checkbox checkbox-xs",
1475
+ defaultChecked: (activeFilters[getColKey(col)] ?? col.defaultFilteredValue ?? []).includes(f.value),
1476
+ "data-value": String(f.value),
1477
+ onChange: (e) => {
1478
+ if (col.filterOnClose) return;
1479
+ const menuEl = e.currentTarget.closest(
1480
+ ".rue-table-filter-menu"
1481
+ );
1482
+ onHeaderFilterApply(i, void 0, menuEl || void 0);
1483
+ }
1484
+ }
1485
+ ),
1486
+ /* @__PURE__ */ jsx("span", { className: "text-sm", children: f.text })
1487
+ ]
1488
+ },
1489
+ f.value ?? String(f.text)
1490
+ )) }),
1491
+ col.filterOnClose ? /* @__PURE__ */ jsxs("div", { className: "mt-2 flex justify-end gap-2", children: [
1492
+ /* @__PURE__ */ jsx(
1493
+ "button",
1494
+ {
1495
+ className: "btn btn-ghost btn-xs",
1496
+ onClick: (e) => {
1497
+ const menuEl = e.currentTarget.closest(
1498
+ ".rue-table-filter-menu"
1499
+ );
1500
+ resetHeaderFilterMenu(i, menuEl || void 0);
1501
+ },
1502
+ children: "\u91CD\u7F6E"
1503
+ }
1504
+ ),
1505
+ /* @__PURE__ */ jsx(
1506
+ "button",
1507
+ {
1508
+ className: "btn btn-primary btn-xs",
1509
+ onClick: (e) => {
1510
+ const menuEl = e.currentTarget.closest(
1511
+ ".rue-table-filter-menu"
1512
+ );
1513
+ onHeaderFilterApply(i, void 0, menuEl || void 0);
1514
+ },
1515
+ children: "\u5E94\u7528"
1516
+ }
1517
+ )
1518
+ ] }) : null
1519
+ ]
1520
+ }
1521
+ );
1522
+ })() : null
1523
+ ]
1524
+ },
1525
+ keyVal
1526
+ );
1527
+ }
1528
+ return /* @__PURE__ */ jsx(
1529
+ "th",
1530
+ {
1531
+ className: className2,
1532
+ style,
1533
+ onClick: () => onHeaderSortClick(i),
1534
+ ...cellProps,
1535
+ children: /* @__PURE__ */ jsxs("div", { className: "flex items-center relative", children: [
1536
+ /* @__PURE__ */ jsx("span", { children: col.title }),
1537
+ col.sorter ? /* @__PURE__ */ jsxs("span", { className: "ml-1 inline-flex flex-col leading-none", children: [
1538
+ /* @__PURE__ */ jsx(
1539
+ "span",
1540
+ {
1541
+ className: `${sortColIndex === i && sortOrder === "ascend" ? "text-base-content" : "opacity-40"} cursor-pointer`,
1542
+ onClick: (e) => {
1543
+ e.stopPropagation();
1544
+ onHeaderSetSort(i, "ascend");
1545
+ },
1546
+ children: "\u25B2"
1547
+ }
1548
+ ),
1549
+ /* @__PURE__ */ jsx(
1550
+ "span",
1551
+ {
1552
+ className: `${sortColIndex === i && sortOrder === "descend" ? "text-base-content" : "opacity-40"} cursor-pointer -mt-0.5`,
1553
+ onClick: (e) => {
1554
+ e.stopPropagation();
1555
+ onHeaderSetSort(i, "descend");
1556
+ },
1557
+ children: "\u25BC"
1558
+ }
1559
+ )
1560
+ ] }) : null,
1561
+ Array.isArray(col.filters) && col.filters.length > 0 ? /* @__PURE__ */ jsx(
1562
+ "span",
1563
+ {
1564
+ className: `rue-table-filter-icon ml-2 cursor-pointer ${activeFilters[getColKey(col)]?.length ? "text-base-content" : "opacity-40"}`,
1565
+ onClick: (e) => {
1566
+ e.stopPropagation();
1567
+ toggleHeaderFilterMenu(i, void 0, e.currentTarget);
1568
+ },
1569
+ children: "\u2630"
1570
+ }
1571
+ ) : null,
1572
+ Array.isArray(col.filters) && col.filters.length > 0 ? (() => {
1573
+ const menuGroup = `header-filter-${i}-${Math.random().toString(36).slice(2)}`;
1574
+ return /* @__PURE__ */ jsxs(
1575
+ "div",
1576
+ {
1577
+ id: `table-filter-menu-${i}`,
1578
+ className: "rue-table-filter-menu fixed z-50 w-44 rounded-box border border-base-content/10 bg-base-100 p-2 shadow",
1579
+ style: { display: "none" },
1580
+ children: [
1581
+ /* @__PURE__ */ jsx("div", { className: "space-y-1", children: col.filters.map((f) => /* @__PURE__ */ jsxs(
1582
+ "label",
1583
+ {
1584
+ className: "flex items-center gap-2",
1585
+ children: [
1586
+ /* @__PURE__ */ jsx(
1587
+ "input",
1588
+ {
1589
+ type: col.filterMultiple === false ? "radio" : "checkbox",
1590
+ name: menuGroup,
1591
+ className: col.filterMultiple === false ? "radio radio-xs" : "checkbox checkbox-xs",
1592
+ defaultChecked: (activeFilters[getColKey(col)] ?? col.defaultFilteredValue ?? []).includes(f.value),
1593
+ "data-value": String(f.value),
1594
+ onChange: (e) => {
1595
+ if (col.filterOnClose) return;
1596
+ const menuEl = e.currentTarget.closest(
1597
+ ".rue-table-filter-menu"
1598
+ );
1599
+ onHeaderFilterApply(i, void 0, menuEl || void 0);
1600
+ }
1601
+ }
1602
+ ),
1603
+ /* @__PURE__ */ jsx("span", { className: "text-sm", children: f.text })
1604
+ ]
1605
+ },
1606
+ f.value ?? String(f.text)
1607
+ )) }),
1608
+ col.filterOnClose ? /* @__PURE__ */ jsxs("div", { className: "mt-2 flex justify-end gap-2", children: [
1609
+ /* @__PURE__ */ jsx(
1610
+ "button",
1611
+ {
1612
+ className: "btn btn-ghost btn-xs",
1613
+ onClick: (e) => {
1614
+ const menuEl = e.currentTarget.closest(
1615
+ ".rue-table-filter-menu"
1616
+ );
1617
+ resetHeaderFilterMenu(i, menuEl || void 0);
1618
+ },
1619
+ children: "\u91CD\u7F6E"
1620
+ }
1621
+ ),
1622
+ /* @__PURE__ */ jsx(
1623
+ "button",
1624
+ {
1625
+ className: "btn btn-primary btn-xs",
1626
+ onClick: (e) => {
1627
+ const menuEl = e.currentTarget.closest(
1628
+ ".rue-table-filter-menu"
1629
+ );
1630
+ onHeaderFilterApply(i, void 0, menuEl || void 0);
1631
+ },
1632
+ children: "\u5E94\u7528"
1633
+ }
1634
+ )
1635
+ ] }) : null
1636
+ ]
1637
+ }
1638
+ );
1639
+ })() : null
1640
+ ] })
1641
+ },
1642
+ keyVal
1643
+ );
1644
+ })
1645
+ ] }) }) : null,
1646
+ /* @__PURE__ */ jsxs("tbody", { children: [
1647
+ pageData.map((record, rowIndex) => {
1648
+ const key = typeof rowKey === "function" ? rowKey(record) : record?.[rowKey];
1649
+ const rowProps = onRow ? onRow(record, rowIndex) || {} : {};
1650
+ const baseCls = typeof rowClassName === "function" ? rowClassName(record, rowIndex) : "";
1651
+ const hoverCls = rowHoverable ? rowHoverClass || "hover:bg-base-200" : "";
1652
+ const rowCls = `${baseCls}${hoverCls ? ` ${hoverCls}` : ""}`.trim() || void 0;
1653
+ return /* @__PURE__ */ jsxs(rue.Fragment, { children: [
1654
+ /* @__PURE__ */ jsxs(
1655
+ "tr",
1656
+ {
1657
+ ...rowProps,
1658
+ className: rowCls || rowProps.className,
1659
+ children: [
1660
+ hasExpand ? /* @__PURE__ */ jsx("td", { className: alignClass("center"), children: /* @__PURE__ */ jsx(
1661
+ "button",
1662
+ {
1663
+ className: "btn btn-ghost btn-xs",
1664
+ onClick: (e) => toggleExpand(key, record, e),
1665
+ children: expKeys.has(key) ? "-" : "+"
1666
+ }
1667
+ ) }) : null,
1668
+ hasSelection ? /* @__PURE__ */ jsx(
1669
+ "td",
1670
+ {
1671
+ className: alignClass("center"),
1672
+ style: rowSelection?.columnWidth ? { width: rowSelection.columnWidth } : void 0,
1673
+ children: /* @__PURE__ */ jsx("label", { children: (() => {
1674
+ const cbProps = rowSelection?.getCheckboxProps ? { ...rowSelection.getCheckboxProps(record) } : {};
1675
+ if (rowSelection?.disabled) cbProps.disabled = true;
1676
+ if (rowSelection?.type === "radio") {
1677
+ return /* @__PURE__ */ jsx(
1678
+ "input",
1679
+ {
1680
+ type: "radio",
1681
+ className: "radio",
1682
+ checked: !!isSelected(key),
1683
+ onChange: () => {
1684
+ const keys = [key];
1685
+ if (rowSelection?.onChange) {
1686
+ const rows = workingData.filter(
1687
+ (rec) => keys.includes(
1688
+ typeof rowKey === "function" ? rowKey(rec) : rec?.[rowKey]
1689
+ )
1690
+ );
1691
+ rowSelection.onChange(keys, rows, { type: "radio" });
1692
+ }
1693
+ },
1694
+ ...cbProps
1695
+ }
1696
+ );
1697
+ }
1698
+ return /* @__PURE__ */ jsx(
1699
+ "input",
1700
+ {
1701
+ type: "checkbox",
1702
+ className: "checkbox",
1703
+ checked: !!isSelected(key),
1704
+ onChange: (e) => {
1705
+ const checked = e.target.checked;
1706
+ const base = rowSelection?.selectedRowKeys ?? rowSelection?.defaultSelectedRowKeys ?? [];
1707
+ const set = new Set(base);
1708
+ if (checked) set.add(key);
1709
+ else set.delete(key);
1710
+ const keys = Array.from(set);
1711
+ if (rowSelection?.onChange) {
1712
+ const rows = workingData.filter(
1713
+ (rec) => keys.includes(
1714
+ typeof rowKey === "function" ? rowKey(rec) : rec?.[rowKey]
1715
+ )
1716
+ );
1717
+ rowSelection.onChange(keys, rows, { type: "checkbox" });
1718
+ }
1719
+ },
1720
+ ...cbProps
1721
+ }
1722
+ );
1723
+ })() })
1724
+ }
1725
+ ) : null,
1726
+ visibleColumns.map((col, colIndex) => {
1727
+ const val = getVal(record, col.dataIndex);
1728
+ const node = col.render ? col.render(val, record, rowIndex) : val;
1729
+ const cellCls = `${alignClass(col.align)}${col.className ? ` ${col.className}` : ""}${col.ellipsis ? " truncate" : ""}`;
1730
+ const cellProps = col.onCell ? col.onCell(record, rowIndex) || {} : {};
1731
+ const keyVal = col.key ?? `${rowIndex}-${colIndex}`;
1732
+ const className2 = `${cellCls}${cellProps.className ? ` ${cellProps.className}` : ""}`.trim() || void 0;
1733
+ const style = col.width ? { width: col.width } : cellProps.style;
1734
+ if (pinCols && col.fixedCol) {
1735
+ return /* @__PURE__ */ jsx("th", { className: className2, style, ...cellProps, children: node }, keyVal);
1736
+ }
1737
+ return /* @__PURE__ */ jsx("td", { className: className2, style, ...cellProps, children: node }, keyVal);
1738
+ })
1739
+ ]
1740
+ },
1741
+ key ?? rowIndex
1742
+ ),
1743
+ hasExpand && expandable?.expandedRowRender ? /* @__PURE__ */ jsx("tr", { style: { display: expKeys.has(key) ? "" : "none" }, children: /* @__PURE__ */ jsx(
1744
+ "td",
1745
+ {
1746
+ colSpan: (visibleColumns.length || 0) + (hasSelection ? 1 : 0) + (hasExpand ? 1 : 0),
1747
+ children: expandable.expandedRowRender(record, rowIndex)
1748
+ }
1749
+ ) }, `expanded-${key}`) : null
1750
+ ] });
1751
+ }),
1752
+ pageData.length === 0 ? /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx(
1753
+ "td",
1754
+ {
1755
+ colSpan: (visibleColumns.length || 0) + (hasSelection ? 1 : 0) + (hasExpand ? 1 : 0),
1756
+ className: alignClass("center"),
1757
+ children: typeof emptyText !== "undefined" ? emptyText : "No Data"
1758
+ }
1759
+ ) }) : null
1760
+ ] }),
1761
+ (() => {
1762
+ const colSpan = (visibleColumns.length || 0) + (hasSelection ? 1 : 0) + (hasExpand ? 1 : 0);
1763
+ const summaryInfo = { total, page, pageSize };
1764
+ const pageDataWithTotal = pageData.slice();
1765
+ pageDataWithTotal.total = total;
1766
+ const summaryNode = typeof summary === "function" ? summary(pageDataWithTotal, summaryInfo) : null;
1767
+ const showPager = pagination !== false && pagination != null && !(pagination.hideOnSinglePage && pageCount <= 1);
1768
+ if (!summaryNode && !showPager) return null;
1769
+ return /* @__PURE__ */ jsxs("tfoot", { children: [
1770
+ summaryNode ? /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { colSpan, children: summaryNode }) }) : null,
1771
+ showPager ? /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { colSpan, children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-2 p-2", children: [
1772
+ /* @__PURE__ */ jsx(
1773
+ "button",
1774
+ {
1775
+ className: "btn btn-ghost btn-xs",
1776
+ disabled: page <= 1,
1777
+ onClick: () => onPageChange(page - 1),
1778
+ children: "Prev"
1779
+ }
1780
+ ),
1781
+ Array.from({ length: pageCount }).map((_, i) => /* @__PURE__ */ jsx(
1782
+ "button",
1783
+ {
1784
+ className: `btn btn-ghost btn-xs${page === i + 1 ? " btn-active" : ""}`,
1785
+ onClick: () => onPageChange(i + 1),
1786
+ children: i + 1
1787
+ },
1788
+ i
1789
+ )),
1790
+ /* @__PURE__ */ jsx(
1791
+ "button",
1792
+ {
1793
+ className: "btn btn-ghost btn-xs",
1794
+ disabled: page >= pageCount,
1795
+ onClick: () => onPageChange(page + 1),
1796
+ children: "Next"
1797
+ }
1798
+ )
1799
+ ] }) }) }) : null
1800
+ ] });
1801
+ })()
1802
+ ] });
1803
+ }
1804
+ return /* @__PURE__ */ jsx("table", { className: cls });
1805
+ };
1806
+ const Head = ({ className, children }) => {
1807
+ const cls = className ? className : void 0;
1808
+ return /* @__PURE__ */ jsx("thead", { className: cls, children });
1809
+ };
1810
+ const Body = ({ className, children }) => {
1811
+ const cls = className ? className : void 0;
1812
+ return /* @__PURE__ */ jsx("tbody", { className: cls, children });
1813
+ };
1814
+ const Foot = ({ className, children }) => {
1815
+ const cls = className ? className : void 0;
1816
+ return /* @__PURE__ */ jsx("tfoot", { className: cls, children });
1817
+ };
1818
+ const TR = ({ className, children }) => {
1819
+ const cls = className ? className : void 0;
1820
+ return /* @__PURE__ */ jsx("tr", { className: cls, children });
1821
+ };
1822
+ const TH = ({ className, children }) => {
1823
+ let cls = "";
1824
+ if (className) cls += ` ${className}`;
1825
+ return /* @__PURE__ */ jsx("th", { className: cls.trim() || void 0, children });
1826
+ };
1827
+ const TD = ({ className, children }) => {
1828
+ let cls = "";
1829
+ if (className) cls += ` ${className}`;
1830
+ return /* @__PURE__ */ jsx("td", { className: cls.trim() || void 0, children });
1831
+ };
1832
+ const TableCompound = Object.assign(Table, {
1833
+ Head,
1834
+ Body,
1835
+ Foot,
1836
+ TR,
1837
+ TH,
1838
+ TD
1839
+ });
1840
+
1841
+ const Breadcrumbs = ({ className, children, items }) => {
1842
+ let cls = "breadcrumbs";
1843
+ if (className) cls += ` ${className}`;
1844
+ if (items && items.length) {
1845
+ return /* @__PURE__ */ jsx("div", { className: cls, children: /* @__PURE__ */ jsx("ul", { children: items.map((it, i) => /* @__PURE__ */ jsx("li", { className: it.className ?? "", children: it.href ? /* @__PURE__ */ jsxs("a", { className: it.linkClassName ?? "", href: it.href, children: [
1846
+ it.icon ?? null,
1847
+ it.label
1848
+ ] }) : /* @__PURE__ */ jsxs("span", { className: it.linkClassName ?? "", children: [
1849
+ it.icon ?? null,
1850
+ it.label
1851
+ ] }) }, i)) }) });
1852
+ } else {
1853
+ return /* @__PURE__ */ jsx("div", { className: cls, children: /* @__PURE__ */ jsx("ul", { children }) });
1854
+ }
1855
+ };
1856
+ const Item$2 = ({ className, children }) => {
1857
+ let cls = "";
1858
+ if (className) cls += ` ${className}`;
1859
+ return /* @__PURE__ */ jsx("li", { className: cls.trim(), children });
1860
+ };
1861
+ const BreadcrumbsCompound = Object.assign(Breadcrumbs, {
1862
+ Item: Item$2
1863
+ });
1864
+
1865
+ const Dock = ({ size, className, items, activeIndex, onChange, children }) => {
1866
+ let cls = "dock";
1867
+ if (size) cls += ` dock-${size}`;
1868
+ if (className) cls += ` ${className}`;
1869
+ if (items && items.length) {
1870
+ return /* @__PURE__ */ jsx("div", { className: cls, children: items.map((it, idx) => (
1871
+ /* 渲染单个停靠项,active 来源于 activeIndex 或自身 active */
1872
+ /* @__PURE__ */ jsxs(
1873
+ Item$1,
1874
+ {
1875
+ as: it.as,
1876
+ className: it.className,
1877
+ active: activeIndex != null ? activeIndex === idx : !!it.active,
1878
+ href: it.href,
1879
+ onClick: () => onChange && onChange(idx),
1880
+ children: [
1881
+ it.icon,
1882
+ it.label != null ? /* @__PURE__ */ jsx(Label, { children: it.label }) : null
1883
+ ]
1884
+ },
1885
+ idx
1886
+ )
1887
+ )) });
1888
+ }
1889
+ return /* @__PURE__ */ jsx("div", { className: cls, children });
1890
+ };
1891
+ const Item$1 = ({ as = "button", active, className, href, onClick, children }) => {
1892
+ let cls = "";
1893
+ if (active) cls += " dock-active";
1894
+ if (className) cls += ` ${className}`;
1895
+ const clsTrim = cls.trim();
1896
+ if (as === "a")
1897
+ return /* @__PURE__ */ jsx("a", { href, className: clsTrim, onClick, children });
1898
+ if (as === "div")
1899
+ return /* @__PURE__ */ jsx("div", { className: clsTrim, onClick, children });
1900
+ return /* @__PURE__ */ jsx("button", { className: clsTrim, onClick, children });
1901
+ };
1902
+ const Label = ({ className, children }) => {
1903
+ let cls = "dock-label";
1904
+ if (className) cls += ` ${className}`;
1905
+ return /* @__PURE__ */ jsx("span", { className: cls, children });
1906
+ };
1907
+ const DockCompound = Object.assign(Dock, {
1908
+ Item: Item$1,
1909
+ Label
1910
+ });
1911
+
1912
+ const Link = ({
1913
+ href = "#",
1914
+ target,
1915
+ rel,
1916
+ to,
1917
+ onClick,
1918
+ variant,
1919
+ hover,
1920
+ className,
1921
+ children
1922
+ }) => {
1923
+ let cls = "link";
1924
+ if (variant) cls += ` link-${variant}`;
1925
+ if (hover) cls += ` link-hover`;
1926
+ if (className) cls += ` ${className}`;
1927
+ return to ? /* @__PURE__ */ jsx(router.RouterLink, { className: cls, to, onClick, children }) : /* @__PURE__ */ jsx("a", { className: cls, href, target, rel, onClick, children });
1928
+ };
1929
+
1930
+ const renderEntry = (m, idx) => {
1931
+ if (m.kind === "title") {
1932
+ return /* @__PURE__ */ jsx(Title, { as: m.as, className: m.className, children: m.children }, idx);
1933
+ }
1934
+ const innerClasses = [
1935
+ m.disabled ? "menu-disabled" : "",
1936
+ m.active ? "menu-active" : "",
1937
+ m.focus ? "menu-focus" : "",
1938
+ m.className ?? ""
1939
+ ].filter(Boolean).join(" ").trim();
1940
+ const liCls = m.liClassName ? m.liClassName : void 0;
1941
+ return /* @__PURE__ */ jsxs("li", { className: liCls, children: [
1942
+ m.as === "button" ? /* @__PURE__ */ jsx("button", { className: innerClasses || void 0, ...m, children: m.children }) : m.as === "span" ? /* @__PURE__ */ jsx("span", { className: innerClasses || void 0, ...m, children: m.children }) : m.to ? /* @__PURE__ */ jsx(router.RouterLink, { className: innerClasses || void 0, to: m.to, onClick: m.onClick, children: m.children }) : m.href ? /* @__PURE__ */ jsx(
1943
+ "a",
1944
+ {
1945
+ className: innerClasses || void 0,
1946
+ href: m.href,
1947
+ target: m.target,
1948
+ rel: m.rel,
1949
+ onClick: m.onClick,
1950
+ children: m.children
1951
+ }
1952
+ ) : /* @__PURE__ */ jsx("a", { className: innerClasses || void 0, onClick: m.onClick, children: m.children }),
1953
+ m.dropdownToggle ? /* @__PURE__ */ jsx(DropdownToggle, { visible: m.dropdownToggle.visible, className: m.dropdownToggle.className, children: m.dropdownToggle.children }) : null,
1954
+ m.dropdown ? /* @__PURE__ */ jsx(Dropdown, { visible: m.dropdown.visible, className: m.dropdown.className, children: m.dropdown.items?.map((child, i) => renderEntry(child, i)) }) : null,
1955
+ m.submenu ? /* @__PURE__ */ jsx(Submenu, { className: m.submenu.className, children: m.submenu.items?.map((child, i) => renderEntry(child, i)) }) : null
1956
+ ] }, idx);
1957
+ };
1958
+ const Menu = ({ size, direction = "vertical", className, children, items }) => {
1959
+ let cls = "menu";
1960
+ if (direction === "horizontal") cls += ` menu-horizontal`;
1961
+ else if (direction === "vertical") cls += ` menu-vertical`;
1962
+ if (size) cls += ` menu-${size}`;
1963
+ if (className) cls += ` ${className}`;
1964
+ if (items && items.length)
1965
+ return /* @__PURE__ */ jsx("ul", { className: cls, children: items.map((m, i) => renderEntry(m, i)) });
1966
+ return /* @__PURE__ */ jsx("ul", { className: cls, children });
1967
+ };
1968
+ const Item = ({
1969
+ as = "a",
1970
+ href,
1971
+ to,
1972
+ target,
1973
+ rel,
1974
+ onClick,
1975
+ disabled,
1976
+ active,
1977
+ focus,
1978
+ liClassName,
1979
+ className,
1980
+ children,
1981
+ ...rest
1982
+ }) => {
1983
+ const innerClasses = [
1984
+ disabled ? "menu-disabled" : "",
1985
+ active ? "menu-active" : "",
1986
+ focus ? "menu-focus" : "",
1987
+ className ?? ""
1988
+ ].filter(Boolean).join(" ").trim();
1989
+ const liCls = liClassName ? liClassName : void 0;
1990
+ return /* @__PURE__ */ jsx("li", { className: liCls, children: as === "button" ? /* @__PURE__ */ jsx("button", { className: innerClasses || void 0, onClick, ...rest, children }) : as === "span" ? /* @__PURE__ */ jsx("span", { className: innerClasses || void 0, onClick, ...rest, children }) : to ? /* @__PURE__ */ jsx(router.RouterLink, { className: innerClasses || void 0, to, onClick, children }) : href ? /* @__PURE__ */ jsx(
1991
+ "a",
1992
+ {
1993
+ className: innerClasses || void 0,
1994
+ href,
1995
+ target,
1996
+ rel,
1997
+ onClick,
1998
+ ...rest,
1999
+ children
2000
+ }
2001
+ ) : /* @__PURE__ */ jsx("a", { className: innerClasses || void 0, onClick, ...rest, children }) });
2002
+ };
2003
+ const Title = ({ as = "li", className, children }) => {
2004
+ let cls = "menu-title";
2005
+ if (className) cls += ` ${className}`;
2006
+ if (as === "h2") return /* @__PURE__ */ jsx("h2", { className: cls, children });
2007
+ return /* @__PURE__ */ jsx("li", { className: cls, children });
2008
+ };
2009
+ const Dropdown = ({ visible, className, children }) => {
2010
+ let cls = "menu-dropdown";
2011
+ if (visible) cls += ` menu-dropdown-visible`;
2012
+ if (className) cls += ` ${className}`;
2013
+ return /* @__PURE__ */ jsx("ul", { className: cls, children });
2014
+ };
2015
+ const DropdownToggle = ({ visible, className, children }) => {
2016
+ let cls = "menu-dropdown-toggle";
2017
+ if (visible) cls += ` menu-dropdown-visible`;
2018
+ if (className) cls += ` ${className}`;
2019
+ return /* @__PURE__ */ jsx("span", { className: cls, children });
2020
+ };
2021
+ const Submenu = ({ className, children }) => {
2022
+ const cls = className ? className : void 0;
2023
+ return /* @__PURE__ */ jsx("ul", { className: cls, children });
2024
+ };
2025
+ const MenuCompound = Object.assign(Menu, {
2026
+ Item,
2027
+ Title,
2028
+ Dropdown,
2029
+ DropdownToggle,
2030
+ Submenu
2031
+ });
2032
+
2033
+ exports.Accordion = AccordionCompound;
2034
+ exports.Alert = Alert;
2035
+ exports.Avatar = AvatarCompound;
2036
+ exports.Badge = Badge;
2037
+ exports.Breadcrumbs = BreadcrumbsCompound;
2038
+ exports.Button = Button;
2039
+ exports.Card = CardCompound;
2040
+ exports.Carousel = CarouselCompound;
2041
+ exports.Chat = ChatCompound;
2042
+ exports.Collapse = CollapseCompound;
2043
+ exports.Countdown = CountdownCompound;
2044
+ exports.Diff = DiffCompound;
2045
+ exports.Divider = Divider;
2046
+ exports.Dock = DockCompound;
2047
+ exports.Footer = Footer$1;
2048
+ exports.Hover3D = Hover3D;
2049
+ exports.HoverGallery = HoverGallery;
2050
+ exports.Kbd = Kbd;
2051
+ exports.Link = Link;
2052
+ exports.List = ListCompound;
2053
+ exports.Menu = MenuCompound;
2054
+ exports.Modal = Modal;
2055
+ exports.Stat = StatCompound;
2056
+ exports.Status = Status;
2057
+ exports.Table = TableCompound;
2058
+ exports.Tabs = Tabs;
2059
+ exports.TextRotate = TextRotate;
2060
+ exports.Timeline = TimelineCompound;