@canvas-components/react-list-table 0.2.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.
package/dist/index.js ADDED
@@ -0,0 +1,2913 @@
1
+ import { forwardRef, useRef, useState, useMemo, useImperativeHandle, useEffect, useLayoutEffect } from 'react';
2
+ import { createPortal } from 'react-dom';
3
+ import { ReactImagePreview, ReactNumberInput, ReactSelect, ReactPagination, ReactFilterPanel, ReactPopup, ReactPopconfirm, ReactContentScaleProvider, ReactInputNumber, ReactCheckbox, ReactInput, ReactAutoComplete, ReactColorPicker, ReactTimeRangePicker, ReactDateTimeRangePicker, ReactDateTimePicker, ReactTimePicker, ReactDateRangePicker, ReactDatePicker, ReactMonthPicker, ReactQuarterPicker, ReactYearPicker, ReactInputRange } from '@canvas-components/react-components';
4
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
5
+ import { ListTable } from '@canvas-components/list-table';
6
+
7
+ // #style-inject:#style-inject
8
+ function styleInject(css, { insertAt } = {}) {
9
+ if (!css || typeof document === "undefined") return;
10
+ const head = document.head || document.getElementsByTagName("head")[0];
11
+ const style = document.createElement("style");
12
+ style.type = "text/css";
13
+ if (insertAt === "top") {
14
+ if (head.firstChild) {
15
+ head.insertBefore(style, head.firstChild);
16
+ } else {
17
+ head.appendChild(style);
18
+ }
19
+ } else {
20
+ head.appendChild(style);
21
+ }
22
+ if (style.styleSheet) {
23
+ style.styleSheet.cssText = css;
24
+ } else {
25
+ style.appendChild(document.createTextNode(css));
26
+ }
27
+ }
28
+
29
+ // src/styles/table-overrides.css
30
+ styleInject(".react-list-table-filter-option {\n transition: background-color 0.2s ease;\n}\n.react-list-table-filter-option:hover {\n background: #f3f4f6;\n}\n.react-list-table-menu-action,\n.react-list-table-menu-row {\n transition: background-color 0.2s ease, color 0.2s ease;\n}\n.react-list-table-menu-action:hover,\n.react-list-table-menu-row:hover {\n background: #f3f4f6 !important;\n}\n.react-list-table-custom-selection-copy {\n transition: background-color 0.2s ease;\n}\n.react-list-table-custom-selection-copy:hover {\n background: #4096ff !important;\n}\n.react-list-table-custom-selection-input > .canvas-react-input-number-handler-down {\n display: none;\n}\n.react-list-table-menu-chevron {\n width: 7px;\n height: 7px;\n flex: 0 0 auto;\n margin-left: 8px;\n border-top: 1.5px solid #9ca3af;\n border-right: 1.5px solid #9ca3af;\n transform: rotate(45deg);\n transform-origin: center;\n transition: transform 0.18s ease, border-color 0.18s ease;\n}\n.react-list-table-menu-action:hover .react-list-table-menu-chevron,\n.react-list-table-menu-row:hover .react-list-table-menu-chevron {\n border-color: #6b7280;\n transform: rotate(135deg);\n}\n.react-list-table-menu-chevron-active {\n border-color: #6b7280;\n transform: rotate(135deg);\n}\n");
31
+ var CONTEXT_MENU_SURFACE_STYLE = {
32
+ padding: 8,
33
+ background: "#ffffff",
34
+ boxShadow: "0 8px 24px rgba(15, 23, 42, 0.16)"
35
+ };
36
+ function ReactTableContextMenuView(props) {
37
+ const { request } = props;
38
+ if (!request) {
39
+ return null;
40
+ }
41
+ const surfaceStyle = {
42
+ ...CONTEXT_MENU_SURFACE_STYLE,
43
+ width: 260,
44
+ maxHeight: 420,
45
+ overflow: "auto"
46
+ };
47
+ return /* @__PURE__ */ jsx(
48
+ ReactPopup,
49
+ {
50
+ open: true,
51
+ anchorRect: { x: request.x, y: request.y, width: 0, height: 0 },
52
+ minWidth: 260,
53
+ onOpenChange: (open) => {
54
+ if (!open) {
55
+ request.onClose();
56
+ }
57
+ },
58
+ surfaceStyle,
59
+ children: /* @__PURE__ */ jsxs("div", { children: [
60
+ /* @__PURE__ */ jsx(
61
+ MenuSubmenu,
62
+ {
63
+ label: "\u590D\u5236",
64
+ items: [
65
+ {
66
+ key: "copy-cell",
67
+ label: "\u590D\u5236\u5355\u5143\u683C",
68
+ onClick: request.onCopyCell
69
+ },
70
+ {
71
+ key: "copy-column",
72
+ label: "\u590D\u5236\u6574\u5217",
73
+ onClick: request.onCopyColumn
74
+ },
75
+ {
76
+ key: "copy-row-text",
77
+ label: "\u590D\u5236\u5F53\u524D\u884C\u6587\u672C",
78
+ onClick: request.onCopyRowText
79
+ },
80
+ {
81
+ key: "copy-row-json",
82
+ label: "\u590D\u5236\u5F53\u524D\u884C JSON",
83
+ onClick: request.onCopyRowJson
84
+ },
85
+ {
86
+ key: "copy-selection",
87
+ label: "\u590D\u5236\u9009\u533A",
88
+ onClick: request.onCopySelection
89
+ }
90
+ ]
91
+ }
92
+ ),
93
+ /* @__PURE__ */ jsx(CustomSelectionMenu, { request }),
94
+ /* @__PURE__ */ jsx(
95
+ MenuSubmenu,
96
+ {
97
+ label: "\u5BFC\u51FA",
98
+ items: [
99
+ {
100
+ key: "export-txt",
101
+ label: "\u5BFC\u51FA TXT",
102
+ onClick: request.onExportTxt
103
+ },
104
+ {
105
+ key: "export-csv",
106
+ label: "\u5BFC\u51FA CSV",
107
+ onClick: request.onExportCsv
108
+ },
109
+ {
110
+ key: "export-xlsx",
111
+ label: "\u5BFC\u51FA XLSX",
112
+ onClick: request.onExportXlsx
113
+ },
114
+ {
115
+ key: "export-json",
116
+ label: "\u5BFC\u51FA JSON",
117
+ onClick: request.onExportJson
118
+ }
119
+ ]
120
+ }
121
+ ),
122
+ /* @__PURE__ */ jsx(
123
+ MenuAction,
124
+ {
125
+ label: request.downloadContentLabel ?? "",
126
+ onClick: request.onDownloadContent
127
+ }
128
+ ),
129
+ /* @__PURE__ */ jsx(
130
+ MenuAction,
131
+ {
132
+ label: request.toggleExpandRowLabel ?? "",
133
+ onClick: request.onToggleExpandRow
134
+ }
135
+ ),
136
+ /* @__PURE__ */ jsx(
137
+ MenuAction,
138
+ {
139
+ label: "\u53D6\u6D88\u5168\u90E8\u6298\u53E0\u884C",
140
+ onClick: request.onExpandAllCollapsedRows
141
+ }
142
+ ),
143
+ /* @__PURE__ */ jsx(
144
+ MenuAction,
145
+ {
146
+ label: request.toggleColumnLabel ?? "",
147
+ onClick: request.onToggleCurrentColumn
148
+ }
149
+ ),
150
+ /* @__PURE__ */ jsx(
151
+ MenuAction,
152
+ {
153
+ label: "\u53D6\u6D88\u5168\u90E8\u6298\u53E0\u5217",
154
+ onClick: request.onExpandAllCollapsedColumns
155
+ }
156
+ ),
157
+ /* @__PURE__ */ jsx(
158
+ MenuAction,
159
+ {
160
+ label: request.summaryVisible ? "\u9690\u85CF\u6C47\u603B\u680F" : "\u663E\u793A\u6C47\u603B\u680F",
161
+ onClick: request.onToggleSummary
162
+ }
163
+ ),
164
+ /* @__PURE__ */ jsx(SummaryMenu, { request }),
165
+ /* @__PURE__ */ jsx(
166
+ MenuSubmenu,
167
+ {
168
+ label: "\u51BB\u7ED3",
169
+ items: [
170
+ {
171
+ key: "freeze-top",
172
+ label: "\u51BB\u7ED3\u5230\u9876\u90E8",
173
+ onClick: request.onFreezeRowTop
174
+ },
175
+ {
176
+ key: "freeze-bottom",
177
+ label: "\u51BB\u7ED3\u5230\u5E95\u90E8",
178
+ onClick: request.onFreezeRowBottom
179
+ },
180
+ {
181
+ key: "unfreeze",
182
+ label: "\u53D6\u6D88\u51BB\u7ED3",
183
+ onClick: request.onUnfreezeRow
184
+ }
185
+ ]
186
+ }
187
+ ),
188
+ /* @__PURE__ */ jsx(
189
+ MenuSubmenu,
190
+ {
191
+ label: "\u91CD\u7F6E",
192
+ items: [
193
+ {
194
+ key: "reset-filter",
195
+ label: "\u91CD\u7F6E\u7B5B\u9009",
196
+ onClick: request.onResetFilter
197
+ },
198
+ {
199
+ key: "reset-sort",
200
+ label: "\u91CD\u7F6E\u6392\u5E8F",
201
+ onClick: request.onResetSort
202
+ },
203
+ {
204
+ key: "reset-header",
205
+ label: "\u91CD\u7F6E\u8868\u5934\u914D\u7F6E",
206
+ onClick: request.onResetHeader
207
+ }
208
+ ]
209
+ }
210
+ ),
211
+ /* @__PURE__ */ jsx(
212
+ DensityMenu,
213
+ {
214
+ value: request.density ?? "middle",
215
+ onChange: request.onChangeDensity
216
+ }
217
+ ),
218
+ /* @__PURE__ */ jsx(
219
+ ZoomMenu,
220
+ {
221
+ value: request.zoom ?? 1,
222
+ onChange: request.onChangeZoom
223
+ }
224
+ ),
225
+ request.columns?.length && request.onToggleColumn ? /* @__PURE__ */ jsxs(Fragment, { children: [
226
+ /* @__PURE__ */ jsx(MenuDivider, {}),
227
+ /* @__PURE__ */ jsx(
228
+ ColumnVisibilityMenu,
229
+ {
230
+ columns: request.columns,
231
+ onToggle: request.onToggleColumn
232
+ }
233
+ )
234
+ ] }) : null
235
+ ] })
236
+ }
237
+ );
238
+ }
239
+ function MenuAction(props) {
240
+ const { label, onClick, selected, reserveSelectionIcon } = props;
241
+ if (!onClick) {
242
+ return null;
243
+ }
244
+ return /* @__PURE__ */ jsxs(
245
+ "button",
246
+ {
247
+ type: "button",
248
+ onClick,
249
+ className: "react-list-table-menu-action",
250
+ style: {
251
+ display: "flex",
252
+ alignItems: "center",
253
+ width: "100%",
254
+ height: 32,
255
+ padding: "0 10px",
256
+ border: "none",
257
+ borderRadius: 8,
258
+ background: "transparent",
259
+ color: "#374151",
260
+ textAlign: "left",
261
+ cursor: "pointer"
262
+ },
263
+ children: [
264
+ reserveSelectionIcon ? /* @__PURE__ */ jsx(
265
+ "span",
266
+ {
267
+ "aria-hidden": "true",
268
+ style: {
269
+ width: 16,
270
+ flex: "0 0 16px",
271
+ marginRight: 6,
272
+ textAlign: "center"
273
+ },
274
+ children: selected ? "\u2713" : ""
275
+ }
276
+ ) : null,
277
+ /* @__PURE__ */ jsx("span", { children: label })
278
+ ]
279
+ }
280
+ );
281
+ }
282
+ function MenuSubmenu(props) {
283
+ const { label, items, footer } = props;
284
+ const menuItems = items.filter((item) => item.onClick);
285
+ const reserveSelectionIcon = menuItems.some(
286
+ (item) => typeof item.selected === "boolean"
287
+ );
288
+ const triggerRef = useRef(null);
289
+ const [open, setOpen] = useState(false);
290
+ const closeTimerRef = useRef(null);
291
+ if (!menuItems.length && !footer) {
292
+ return null;
293
+ }
294
+ const clearCloseTimer = () => {
295
+ if (closeTimerRef.current != null) {
296
+ window.clearTimeout(closeTimerRef.current);
297
+ closeTimerRef.current = null;
298
+ }
299
+ };
300
+ const scheduleClose = () => {
301
+ clearCloseTimer();
302
+ closeTimerRef.current = window.setTimeout(() => {
303
+ setOpen(false);
304
+ closeTimerRef.current = null;
305
+ }, 120);
306
+ };
307
+ return /* @__PURE__ */ jsxs(
308
+ "div",
309
+ {
310
+ onMouseEnter: () => {
311
+ clearCloseTimer();
312
+ setOpen(true);
313
+ },
314
+ onMouseLeave: () => {
315
+ scheduleClose();
316
+ },
317
+ children: [
318
+ /* @__PURE__ */ jsxs(
319
+ "button",
320
+ {
321
+ ref: triggerRef,
322
+ type: "button",
323
+ className: "react-list-table-menu-action react-list-table-menu-action-submenu",
324
+ style: {
325
+ display: "flex",
326
+ alignItems: "center",
327
+ justifyContent: "space-between",
328
+ width: "100%",
329
+ height: 32,
330
+ padding: "0 10px",
331
+ border: "none",
332
+ borderRadius: 8,
333
+ background: "transparent",
334
+ color: "#374151",
335
+ textAlign: "left",
336
+ cursor: "pointer"
337
+ },
338
+ children: [
339
+ /* @__PURE__ */ jsx("span", { children: label }),
340
+ /* @__PURE__ */ jsx(
341
+ "span",
342
+ {
343
+ className: `react-list-table-menu-chevron${open ? " react-list-table-menu-chevron-active" : ""}`,
344
+ "aria-hidden": "true"
345
+ }
346
+ )
347
+ ]
348
+ }
349
+ ),
350
+ /* @__PURE__ */ jsx(
351
+ ReactPopup,
352
+ {
353
+ open,
354
+ anchorRef: triggerRef,
355
+ placement: "rightTop",
356
+ offset: 2,
357
+ minWidth: 220,
358
+ onOpenChange: setOpen,
359
+ surfaceStyle: {
360
+ ...CONTEXT_MENU_SURFACE_STYLE,
361
+ maxHeight: 360,
362
+ overflow: "auto"
363
+ },
364
+ children: /* @__PURE__ */ jsxs(
365
+ "div",
366
+ {
367
+ onMouseEnter: () => {
368
+ clearCloseTimer();
369
+ },
370
+ onMouseLeave: () => {
371
+ scheduleClose();
372
+ },
373
+ children: [
374
+ menuItems.map((item) => /* @__PURE__ */ jsx(
375
+ MenuAction,
376
+ {
377
+ label: item.label,
378
+ onClick: item.onClick,
379
+ selected: item.selected,
380
+ reserveSelectionIcon
381
+ },
382
+ item.key
383
+ )),
384
+ footer
385
+ ]
386
+ }
387
+ )
388
+ }
389
+ )
390
+ ]
391
+ }
392
+ );
393
+ }
394
+ function DensityMenu(props) {
395
+ const { value, onChange } = props;
396
+ if (!onChange) {
397
+ return null;
398
+ }
399
+ return /* @__PURE__ */ jsx(
400
+ MenuSubmenu,
401
+ {
402
+ label: "\u8868\u683C\u5BC6\u5EA6",
403
+ items: [
404
+ {
405
+ key: "density-comfortable",
406
+ label: "\u5BBD\u677E",
407
+ selected: value === "comfortable",
408
+ onClick: () => {
409
+ onChange("comfortable");
410
+ }
411
+ },
412
+ {
413
+ key: "density-middle",
414
+ label: "\u4E2D\u7B49",
415
+ selected: value === "middle",
416
+ onClick: () => {
417
+ onChange("middle");
418
+ }
419
+ },
420
+ {
421
+ key: "density-compact",
422
+ label: "\u7D27\u51D1",
423
+ selected: value === "compact",
424
+ onClick: () => {
425
+ onChange("compact");
426
+ }
427
+ }
428
+ ]
429
+ }
430
+ );
431
+ }
432
+ var CONTEXT_MENU_ZOOM_MIN = 50;
433
+ var CONTEXT_MENU_ZOOM_MAX = 200;
434
+ var CONTEXT_MENU_ZOOM_STEP = 10;
435
+ function ZoomMenu(props) {
436
+ const { value, onChange } = props;
437
+ const triggerRef = useRef(null);
438
+ const [open, setOpen] = useState(false);
439
+ const closeTimerRef = useRef(null);
440
+ if (!onChange) {
441
+ return null;
442
+ }
443
+ const percent = Math.round(value * 100);
444
+ const clearCloseTimer = () => {
445
+ if (closeTimerRef.current != null) {
446
+ window.clearTimeout(closeTimerRef.current);
447
+ closeTimerRef.current = null;
448
+ }
449
+ };
450
+ const scheduleClose = () => {
451
+ clearCloseTimer();
452
+ closeTimerRef.current = window.setTimeout(() => {
453
+ setOpen(false);
454
+ closeTimerRef.current = null;
455
+ }, 120);
456
+ };
457
+ return /* @__PURE__ */ jsxs(
458
+ "div",
459
+ {
460
+ onMouseEnter: () => {
461
+ clearCloseTimer();
462
+ setOpen(true);
463
+ },
464
+ onMouseLeave: () => {
465
+ scheduleClose();
466
+ },
467
+ children: [
468
+ /* @__PURE__ */ jsxs(
469
+ "button",
470
+ {
471
+ ref: triggerRef,
472
+ type: "button",
473
+ className: "react-list-table-menu-action react-list-table-menu-action-submenu",
474
+ style: {
475
+ display: "flex",
476
+ alignItems: "center",
477
+ justifyContent: "space-between",
478
+ width: "100%",
479
+ height: 32,
480
+ padding: "0 10px",
481
+ border: "none",
482
+ borderRadius: 8,
483
+ background: "transparent",
484
+ color: "#374151",
485
+ textAlign: "left",
486
+ cursor: "pointer"
487
+ },
488
+ children: [
489
+ /* @__PURE__ */ jsx("span", { children: "\u7F29\u653E" }),
490
+ /* @__PURE__ */ jsxs(
491
+ "span",
492
+ {
493
+ style: {
494
+ display: "inline-flex",
495
+ alignItems: "center",
496
+ gap: 8,
497
+ color: "#6b7280",
498
+ fontSize: 12
499
+ },
500
+ children: [
501
+ /* @__PURE__ */ jsxs("span", { children: [
502
+ percent,
503
+ "%"
504
+ ] }),
505
+ /* @__PURE__ */ jsx(
506
+ "span",
507
+ {
508
+ className: `react-list-table-menu-chevron${open ? " react-list-table-menu-chevron-active" : ""}`,
509
+ "aria-hidden": "true"
510
+ }
511
+ )
512
+ ]
513
+ }
514
+ )
515
+ ]
516
+ }
517
+ ),
518
+ /* @__PURE__ */ jsx(
519
+ ReactPopup,
520
+ {
521
+ open,
522
+ anchorRef: triggerRef,
523
+ placement: "rightTop",
524
+ offset: 2,
525
+ minWidth: 220,
526
+ onOpenChange: setOpen,
527
+ surfaceStyle: {
528
+ ...CONTEXT_MENU_SURFACE_STYLE,
529
+ width: 220
530
+ },
531
+ children: /* @__PURE__ */ jsxs(
532
+ "div",
533
+ {
534
+ onMouseEnter: () => {
535
+ clearCloseTimer();
536
+ },
537
+ onMouseLeave: () => {
538
+ scheduleClose();
539
+ },
540
+ style: {
541
+ display: "flex",
542
+ flexDirection: "column",
543
+ gap: 8,
544
+ padding: "4px 2px"
545
+ },
546
+ children: [
547
+ /* @__PURE__ */ jsx(
548
+ "div",
549
+ {
550
+ style: {
551
+ color: "#6b7280",
552
+ fontSize: 12,
553
+ padding: "0 8px"
554
+ },
555
+ children: "\u8868\u683C\u7F29\u653E\uFF0850% - 200%\uFF09"
556
+ }
557
+ ),
558
+ /* @__PURE__ */ jsx("div", { style: { padding: "0 8px 4px" }, children: /* @__PURE__ */ jsx(
559
+ ReactInputNumber,
560
+ {
561
+ value: percent,
562
+ min: CONTEXT_MENU_ZOOM_MIN,
563
+ max: CONTEXT_MENU_ZOOM_MAX,
564
+ step: CONTEXT_MENU_ZOOM_STEP,
565
+ precision: 0,
566
+ addonAfter: "%",
567
+ onChange: (next) => {
568
+ if (next == null || !Number.isFinite(next)) {
569
+ return;
570
+ }
571
+ onChange(Math.round(next) / 100);
572
+ }
573
+ }
574
+ ) }),
575
+ /* @__PURE__ */ jsx(
576
+ "button",
577
+ {
578
+ type: "button",
579
+ disabled: percent === 100,
580
+ onClick: () => {
581
+ onChange(1);
582
+ },
583
+ className: "react-list-table-menu-action",
584
+ style: {
585
+ display: "block",
586
+ width: "100%",
587
+ height: 32,
588
+ padding: "0 8px",
589
+ border: "none",
590
+ borderRadius: 8,
591
+ background: "transparent",
592
+ color: percent === 100 ? "#9ca3af" : "#374151",
593
+ textAlign: "left",
594
+ cursor: percent === 100 ? "not-allowed" : "pointer"
595
+ },
596
+ children: "\u91CD\u7F6E\u7F29\u653E"
597
+ }
598
+ )
599
+ ]
600
+ }
601
+ )
602
+ }
603
+ )
604
+ ]
605
+ }
606
+ );
607
+ }
608
+ function ColumnVisibilityMenu(props) {
609
+ const { columns, onToggle } = props;
610
+ const triggerRef = useRef(null);
611
+ const [open, setOpen] = useState(false);
612
+ const closeTimerRef = useRef(null);
613
+ const clearCloseTimer = () => {
614
+ if (closeTimerRef.current != null) {
615
+ window.clearTimeout(closeTimerRef.current);
616
+ closeTimerRef.current = null;
617
+ }
618
+ };
619
+ const scheduleClose = () => {
620
+ clearCloseTimer();
621
+ closeTimerRef.current = window.setTimeout(() => {
622
+ setOpen(false);
623
+ closeTimerRef.current = null;
624
+ }, 120);
625
+ };
626
+ return /* @__PURE__ */ jsxs(
627
+ "div",
628
+ {
629
+ onMouseEnter: () => {
630
+ clearCloseTimer();
631
+ setOpen(true);
632
+ },
633
+ onMouseLeave: () => {
634
+ scheduleClose();
635
+ },
636
+ children: [
637
+ /* @__PURE__ */ jsxs(
638
+ "button",
639
+ {
640
+ ref: triggerRef,
641
+ type: "button",
642
+ className: "react-list-table-menu-action react-list-table-menu-action-submenu",
643
+ style: {
644
+ display: "flex",
645
+ alignItems: "center",
646
+ justifyContent: "space-between",
647
+ width: "100%",
648
+ height: 32,
649
+ padding: "0 10px",
650
+ border: "none",
651
+ borderRadius: 8,
652
+ background: "transparent",
653
+ color: "#374151",
654
+ textAlign: "left",
655
+ cursor: "pointer"
656
+ },
657
+ children: [
658
+ /* @__PURE__ */ jsx("span", { children: "\u5217\u663E\u793A" }),
659
+ /* @__PURE__ */ jsx(
660
+ "span",
661
+ {
662
+ className: `react-list-table-menu-chevron${open ? " react-list-table-menu-chevron-active" : ""}`,
663
+ "aria-hidden": "true"
664
+ }
665
+ )
666
+ ]
667
+ }
668
+ ),
669
+ /* @__PURE__ */ jsx(
670
+ ReactPopup,
671
+ {
672
+ open,
673
+ anchorRef: triggerRef,
674
+ placement: "rightTop",
675
+ offset: 2,
676
+ minWidth: 220,
677
+ onOpenChange: setOpen,
678
+ surfaceStyle: {
679
+ ...CONTEXT_MENU_SURFACE_STYLE,
680
+ maxHeight: 360,
681
+ overflow: "auto"
682
+ },
683
+ children: /* @__PURE__ */ jsx(
684
+ "div",
685
+ {
686
+ onMouseEnter: () => {
687
+ clearCloseTimer();
688
+ },
689
+ onMouseLeave: () => {
690
+ scheduleClose();
691
+ },
692
+ children: columns.map((column) => /* @__PURE__ */ jsx(
693
+ ColumnVisibilityItem,
694
+ {
695
+ item: column,
696
+ onToggle
697
+ },
698
+ column.key
699
+ ))
700
+ }
701
+ )
702
+ }
703
+ )
704
+ ]
705
+ }
706
+ );
707
+ }
708
+ function ColumnVisibilityItem(props) {
709
+ const { item, onToggle } = props;
710
+ const triggerRef = useRef(null);
711
+ const [open, setOpen] = useState(false);
712
+ const closeTimerRef = useRef(null);
713
+ const hasChildren = !!item.children?.length;
714
+ const clearCloseTimer = () => {
715
+ if (closeTimerRef.current != null) {
716
+ window.clearTimeout(closeTimerRef.current);
717
+ closeTimerRef.current = null;
718
+ }
719
+ };
720
+ const scheduleClose = () => {
721
+ clearCloseTimer();
722
+ closeTimerRef.current = window.setTimeout(() => {
723
+ setOpen(false);
724
+ closeTimerRef.current = null;
725
+ }, 120);
726
+ };
727
+ return /* @__PURE__ */ jsxs(
728
+ "div",
729
+ {
730
+ ref: triggerRef,
731
+ className: "react-list-table-menu-row",
732
+ onMouseEnter: () => {
733
+ if (hasChildren) {
734
+ clearCloseTimer();
735
+ setOpen(true);
736
+ }
737
+ },
738
+ onMouseLeave: () => {
739
+ if (hasChildren) {
740
+ scheduleClose();
741
+ }
742
+ },
743
+ style: {
744
+ display: "flex",
745
+ alignItems: "center",
746
+ justifyContent: "space-between",
747
+ gap: 8,
748
+ minHeight: 32,
749
+ padding: "0 10px",
750
+ borderRadius: 8,
751
+ color: item.disabled ? "#9ca3af" : "#374151",
752
+ fontSize: 14
753
+ },
754
+ children: [
755
+ /* @__PURE__ */ jsx(
756
+ ReactCheckbox,
757
+ {
758
+ checked: item.checked,
759
+ disabled: item.disabled,
760
+ indeterminate: !!item.indeterminate,
761
+ onChange: (event) => {
762
+ onToggle(item.key, !!event.target.checked);
763
+ },
764
+ children: item.title
765
+ }
766
+ ),
767
+ hasChildren ? /* @__PURE__ */ jsx(
768
+ "span",
769
+ {
770
+ className: `react-list-table-menu-chevron${open ? " react-list-table-menu-chevron-active" : ""}`,
771
+ "aria-hidden": "true"
772
+ }
773
+ ) : null,
774
+ hasChildren ? /* @__PURE__ */ jsx(
775
+ ReactPopup,
776
+ {
777
+ open,
778
+ anchorRef: triggerRef,
779
+ placement: "rightTop",
780
+ offset: 2,
781
+ minWidth: 220,
782
+ onOpenChange: setOpen,
783
+ surfaceStyle: {
784
+ ...CONTEXT_MENU_SURFACE_STYLE,
785
+ maxHeight: 320,
786
+ overflow: "auto"
787
+ },
788
+ children: /* @__PURE__ */ jsx(
789
+ "div",
790
+ {
791
+ onMouseEnter: () => {
792
+ clearCloseTimer();
793
+ },
794
+ onMouseLeave: () => {
795
+ scheduleClose();
796
+ },
797
+ children: item.children.map((child) => /* @__PURE__ */ jsx(
798
+ ColumnVisibilityItem,
799
+ {
800
+ item: child,
801
+ onToggle
802
+ },
803
+ child.key
804
+ ))
805
+ }
806
+ )
807
+ }
808
+ ) : null
809
+ ]
810
+ }
811
+ );
812
+ }
813
+ function MenuDivider() {
814
+ return /* @__PURE__ */ jsx(
815
+ "div",
816
+ {
817
+ style: {
818
+ height: 1,
819
+ margin: "6px 0",
820
+ background: "#f0f0f0"
821
+ }
822
+ }
823
+ );
824
+ }
825
+ function CustomSelectionMenu(props) {
826
+ const { request } = props;
827
+ const triggerRef = useRef(null);
828
+ const [open, setOpen] = useState(false);
829
+ const initial = request.customSelection ?? {
830
+ startRow: 1,
831
+ startColumn: 1,
832
+ endRow: 1,
833
+ endColumn: 1,
834
+ rowCount: 0,
835
+ columnCount: 0
836
+ };
837
+ const [range, setRange] = useState(initial);
838
+ if (!request.onCopyCustomSelection || !request.customSelection) {
839
+ return null;
840
+ }
841
+ const update = (key, value) => {
842
+ setRange((current) => ({
843
+ ...current,
844
+ [key]: value == null ? 1 : Math.floor(value)
845
+ }));
846
+ };
847
+ return /* @__PURE__ */ jsxs("div", { children: [
848
+ /* @__PURE__ */ jsx(
849
+ "button",
850
+ {
851
+ ref: triggerRef,
852
+ type: "button",
853
+ className: "react-list-table-menu-action",
854
+ style: {
855
+ display: "flex",
856
+ alignItems: "center",
857
+ width: "100%",
858
+ height: 32,
859
+ padding: "0 10px",
860
+ border: "none",
861
+ borderRadius: 8,
862
+ background: "transparent",
863
+ color: "#374151",
864
+ textAlign: "left",
865
+ cursor: "pointer"
866
+ },
867
+ onClick: () => setOpen((value) => !value),
868
+ children: /* @__PURE__ */ jsx("span", { children: "\u590D\u5236\u81EA\u5B9A\u4E49\u9009\u533A" })
869
+ }
870
+ ),
871
+ /* @__PURE__ */ jsx(
872
+ ReactPopup,
873
+ {
874
+ open,
875
+ anchorRef: triggerRef,
876
+ placement: "rightTop",
877
+ offset: 2,
878
+ minWidth: 250,
879
+ onOpenChange: setOpen,
880
+ surfaceStyle: { ...CONTEXT_MENU_SURFACE_STYLE, width: 250 },
881
+ children: /* @__PURE__ */ jsxs("div", { style: { padding: 6 }, children: [
882
+ /* @__PURE__ */ jsx("div", { style: { color: "#6b7280", fontSize: 12, marginBottom: 6 }, children: "\u8F93\u5165\u8D77\u59CB\u4F4D\u7F6E\u548C\u7ED3\u675F\u4F4D\u7F6E" }),
883
+ /* @__PURE__ */ jsxs(
884
+ "div",
885
+ {
886
+ style: {
887
+ display: "grid",
888
+ gridTemplateColumns: "38px 1fr 1fr",
889
+ gap: 6,
890
+ marginBottom: 4,
891
+ color: "#6b7280",
892
+ fontSize: 12,
893
+ textAlign: "center"
894
+ },
895
+ children: [
896
+ /* @__PURE__ */ jsx("span", {}),
897
+ /* @__PURE__ */ jsx("span", { children: "\u884C" }),
898
+ /* @__PURE__ */ jsx("span", { children: "\u5217" })
899
+ ]
900
+ }
901
+ ),
902
+ /* @__PURE__ */ jsx(
903
+ CustomSelectionRow,
904
+ {
905
+ label: "\u8D77\u59CB",
906
+ row: range.startRow,
907
+ column: range.startColumn,
908
+ onRowChange: (value) => update("startRow", value),
909
+ onColumnChange: (value) => update("startColumn", value)
910
+ }
911
+ ),
912
+ /* @__PURE__ */ jsx(
913
+ CustomSelectionRow,
914
+ {
915
+ label: "\u7ED3\u675F",
916
+ row: range.endRow,
917
+ column: range.endColumn,
918
+ onRowChange: (value) => update("endRow", value),
919
+ onColumnChange: (value) => update("endColumn", value)
920
+ }
921
+ ),
922
+ /* @__PURE__ */ jsx(
923
+ "button",
924
+ {
925
+ type: "button",
926
+ className: "react-list-table-custom-selection-copy",
927
+ style: {
928
+ display: "block",
929
+ width: "100%",
930
+ height: 32,
931
+ marginTop: 6,
932
+ border: "none",
933
+ borderRadius: 8,
934
+ background: "#1677ff",
935
+ color: "#fff",
936
+ cursor: "pointer"
937
+ },
938
+ onClick: () => {
939
+ request.onCopyCustomSelection?.({
940
+ startRow: Math.max(range.startRow, 1),
941
+ startColumn: Math.max(range.startColumn, 1),
942
+ endRow: Math.max(range.endRow, 1),
943
+ endColumn: Math.max(range.endColumn, 1)
944
+ });
945
+ setOpen(false);
946
+ },
947
+ children: "\u590D\u5236"
948
+ }
949
+ )
950
+ ] })
951
+ }
952
+ )
953
+ ] });
954
+ }
955
+ function CustomSelectionRow(props) {
956
+ return /* @__PURE__ */ jsxs(
957
+ "div",
958
+ {
959
+ style: {
960
+ display: "grid",
961
+ gridTemplateColumns: "38px 1fr 1fr",
962
+ gap: 6,
963
+ alignItems: "center",
964
+ marginBottom: 6
965
+ },
966
+ children: [
967
+ /* @__PURE__ */ jsx("span", { style: { color: "#374151", fontSize: 12 }, children: props.label }),
968
+ /* @__PURE__ */ jsx(
969
+ ReactInputNumber,
970
+ {
971
+ className: "react-list-table-custom-selection-input",
972
+ value: props.row,
973
+ min: 1,
974
+ step: 1,
975
+ precision: 0,
976
+ placeholder: "\u884C",
977
+ onChange: props.onRowChange
978
+ }
979
+ ),
980
+ /* @__PURE__ */ jsx(
981
+ ReactInputNumber,
982
+ {
983
+ className: "react-list-table-custom-selection-input",
984
+ value: props.column,
985
+ min: 1,
986
+ step: 1,
987
+ precision: 0,
988
+ placeholder: "\u5217",
989
+ onChange: props.onColumnChange
990
+ }
991
+ )
992
+ ]
993
+ }
994
+ );
995
+ }
996
+ function SummaryMenu(props) {
997
+ const { request } = props;
998
+ const [precision, setPrecision] = useState(
999
+ request.summaryPrecision ?? null
1000
+ );
1001
+ useEffect(() => {
1002
+ setPrecision(request.summaryPrecision ?? null);
1003
+ }, [request.summaryColumnKey, request.summaryPrecision]);
1004
+ if (!request.summaryColumnKey) {
1005
+ return null;
1006
+ }
1007
+ const summaryTypes = [
1008
+ { key: "sum", label: "\u6C42\u548C", value: "sum" },
1009
+ { key: "avg", label: "\u5E73\u5747\u503C", value: "avg" },
1010
+ { key: "count", label: "\u8BA1\u6570", value: "count" },
1011
+ { key: "unionCount", label: "\u53BB\u91CD\u8BA1\u6570", value: "unionCount" },
1012
+ { key: "rowCount", label: "\u884C\u6570", value: "rowCount" },
1013
+ { key: "mergedRowCount", label: "\u5408\u5E76\u884C\u6570", value: "mergedRowCount" },
1014
+ { key: "min", label: "\u6700\u5C0F\u503C", value: "min" },
1015
+ { key: "max", label: "\u6700\u5927\u503C", value: "max" }
1016
+ ];
1017
+ return /* @__PURE__ */ jsx(
1018
+ MenuSubmenu,
1019
+ {
1020
+ label: "\u6C47\u603B\u65B9\u5F0F",
1021
+ items: summaryTypes.map((item) => ({
1022
+ key: item.key,
1023
+ label: item.label,
1024
+ selected: request.summaryType === item.value,
1025
+ onClick: () => request.onChangeSummaryType?.(item.value)
1026
+ })),
1027
+ footer: request.onChangeSummaryPrecision ? /* @__PURE__ */ jsxs(
1028
+ "div",
1029
+ {
1030
+ style: {
1031
+ display: "grid",
1032
+ gridTemplateColumns: "72px 1fr",
1033
+ gap: 8,
1034
+ alignItems: "center",
1035
+ marginTop: 4,
1036
+ padding: "10px 10px 2px",
1037
+ borderTop: "1px solid #e5e7eb"
1038
+ },
1039
+ children: [
1040
+ /* @__PURE__ */ jsx("span", { style: { color: "#374151", fontSize: 13 }, children: "\u5C0F\u6570\u4F4D\u6570" }),
1041
+ /* @__PURE__ */ jsx(
1042
+ ReactInputNumber,
1043
+ {
1044
+ value: precision,
1045
+ min: 0,
1046
+ max: 20,
1047
+ step: 1,
1048
+ precision: 0,
1049
+ placeholder: "\u9ED8\u8BA4",
1050
+ onChange: setPrecision,
1051
+ onCommit: (value) => {
1052
+ request.onChangeSummaryPrecision?.(value ?? void 0);
1053
+ }
1054
+ }
1055
+ )
1056
+ ]
1057
+ }
1058
+ ) : void 0
1059
+ }
1060
+ );
1061
+ }
1062
+
1063
+ // src/features/editor/utils.ts
1064
+ function toNumberValue(value) {
1065
+ if (typeof value === "number" && Number.isFinite(value)) {
1066
+ return value;
1067
+ }
1068
+ if (typeof value === "string" && value.trim().length > 0) {
1069
+ const nextValue = Number(value);
1070
+ return Number.isFinite(nextValue) ? nextValue : null;
1071
+ }
1072
+ return null;
1073
+ }
1074
+ function toNumericProp(value) {
1075
+ if (typeof value === "number") {
1076
+ return value;
1077
+ }
1078
+ if (typeof value === "string" && value.trim().length > 0) {
1079
+ const nextValue = Number(value);
1080
+ return Number.isFinite(nextValue) ? nextValue : void 0;
1081
+ }
1082
+ return void 0;
1083
+ }
1084
+ function resolvePadding(value, fallback = 0) {
1085
+ return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : fallback;
1086
+ }
1087
+ function resolveEditorControlSize(request) {
1088
+ const targetRect = request.hostRect ?? request.rect;
1089
+ const height = Math.max(targetRect.height - 2, 1);
1090
+ const fontSize = typeof request.theme.fontSize === "number" && Number.isFinite(request.theme.fontSize) && request.theme.fontSize > 0 ? request.theme.fontSize : void 0;
1091
+ const paddingInline = resolvePadding(request.theme.paddingInline);
1092
+ const paddingBlock = resolvePadding(request.theme.paddingBlock);
1093
+ const contentZoom = typeof request.theme.contentZoom === "number" && Number.isFinite(request.theme.contentZoom) && request.theme.contentZoom > 0 ? request.theme.contentZoom : 1;
1094
+ return { height, fontSize, paddingInline, paddingBlock, contentZoom };
1095
+ }
1096
+ function getEditorInputStyle(request) {
1097
+ const { height, fontSize, paddingInline, paddingBlock, contentZoom } = resolveEditorControlSize(request);
1098
+ return {
1099
+ width: "100%",
1100
+ height,
1101
+ minHeight: height,
1102
+ color: request.theme.cellColor ?? request.theme.textColor,
1103
+ fontFamily: request.theme.fontFamily,
1104
+ fontSize,
1105
+ // 用像素 token,确保 select/time/color 触发器与内部 Input 同步缩放。
1106
+ ["--canvas-react-control-height"]: `${height}px`,
1107
+ ["--canvas-react-font-size"]: fontSize != null ? `${fontSize}px` : void 0,
1108
+ ["--canvas-react-control-padding-inline"]: `${paddingInline}px`,
1109
+ ["--canvas-react-control-padding-block"]: `${paddingBlock}px`,
1110
+ ["--canvas-react-content-zoom"]: String(contentZoom),
1111
+ boxSizing: "border-box"
1112
+ };
1113
+ }
1114
+ function resolveEditorOverlayStyle(params) {
1115
+ const { rect, hostRect, fontSize, paddingInline, paddingBlock, contentZoom } = params;
1116
+ const targetRect = hostRect ?? rect;
1117
+ const height = Math.max(targetRect.height - 2, 1);
1118
+ const resolvedFontSize = typeof fontSize === "number" && Number.isFinite(fontSize) && fontSize > 0 ? fontSize : void 0;
1119
+ const resolvedPaddingInline = resolvePadding(paddingInline);
1120
+ const resolvedPaddingBlock = resolvePadding(paddingBlock);
1121
+ const resolvedContentZoom = typeof contentZoom === "number" && Number.isFinite(contentZoom) && contentZoom > 0 ? contentZoom : 1;
1122
+ return {
1123
+ position: hostRect ? "absolute" : "fixed",
1124
+ left: targetRect.x,
1125
+ top: targetRect.y + 1,
1126
+ width: Math.max(targetRect.width, 1),
1127
+ height,
1128
+ minHeight: height,
1129
+ zIndex: 1200,
1130
+ boxSizing: "border-box",
1131
+ // 覆盖表单组件 token,使输入框高度/字号/内边距跟随表格缩放。
1132
+ ["--canvas-react-control-height"]: `${height}px`,
1133
+ ["--canvas-react-control-padding-inline"]: `${resolvedPaddingInline}px`,
1134
+ ["--canvas-react-control-padding-block"]: `${resolvedPaddingBlock}px`,
1135
+ ["--canvas-react-content-zoom"]: String(resolvedContentZoom),
1136
+ ...resolvedFontSize != null ? {
1137
+ ["--canvas-react-font-size"]: `${resolvedFontSize}px`,
1138
+ fontSize: resolvedFontSize
1139
+ } : null
1140
+ };
1141
+ }
1142
+ function ReactTableEditorOverlay(props) {
1143
+ const { request } = props;
1144
+ const editorHostRef = useRef(null);
1145
+ const style = resolveEditorOverlayStyle({
1146
+ rect: request.rect,
1147
+ hostRect: request.hostRect,
1148
+ fontSize: request.theme.fontSize,
1149
+ paddingInline: request.theme.paddingInline,
1150
+ paddingBlock: request.theme.paddingBlock,
1151
+ contentZoom: request.theme.contentZoom
1152
+ });
1153
+ const contentZoom = typeof request.theme.contentZoom === "number" && Number.isFinite(request.theme.contentZoom) && request.theme.contentZoom > 0 ? request.theme.contentZoom : 1;
1154
+ useLayoutEffect(() => {
1155
+ const input = editorHostRef.current?.querySelector("input");
1156
+ if (!input) {
1157
+ return;
1158
+ }
1159
+ focusAndSelectEditorInput(input);
1160
+ }, [request]);
1161
+ return /* @__PURE__ */ jsx(ReactContentScaleProvider, { scale: contentZoom, children: /* @__PURE__ */ jsx("div", { ref: editorHostRef, children: renderEditorByType(request, style) }, request.editorKey) });
1162
+ }
1163
+ function renderEditorByType(request, style) {
1164
+ switch (request.config.valueType ?? "text") {
1165
+ case "number":
1166
+ return /* @__PURE__ */ jsx(NumberEditor, { request, style });
1167
+ case "input-range":
1168
+ return /* @__PURE__ */ jsx(InputRangeEditor, { request, style });
1169
+ case "year":
1170
+ return /* @__PURE__ */ jsx(YearEditor, { request, style });
1171
+ case "quarter":
1172
+ return /* @__PURE__ */ jsx(QuarterEditor, { request, style });
1173
+ case "month":
1174
+ return /* @__PURE__ */ jsx(MonthEditor, { request, style });
1175
+ case "date":
1176
+ return /* @__PURE__ */ jsx(DateEditor, { request, style });
1177
+ case "date-range":
1178
+ return /* @__PURE__ */ jsx(DateRangeEditor, { request, style });
1179
+ case "time":
1180
+ return /* @__PURE__ */ jsx(TimeEditor, { request, style });
1181
+ case "datetime":
1182
+ return /* @__PURE__ */ jsx(DateTimeEditor, { request, style });
1183
+ case "datetime-range":
1184
+ return /* @__PURE__ */ jsx(DateTimeRangeEditor, { request, style });
1185
+ case "timerange":
1186
+ return /* @__PURE__ */ jsx(TimeRangeEditor, { request, style });
1187
+ case "color":
1188
+ return /* @__PURE__ */ jsx(ColorEditor, { request, style });
1189
+ case "select":
1190
+ return /* @__PURE__ */ jsx(SelectEditor, { request, style });
1191
+ case "auto-complete":
1192
+ return /* @__PURE__ */ jsx(AutoCompleteEditor, { request, style });
1193
+ default:
1194
+ return /* @__PURE__ */ jsx(TextEditor, { request, style });
1195
+ }
1196
+ }
1197
+ function TextEditor(props) {
1198
+ const { request, style } = props;
1199
+ const [value, setValue] = useState(String(request.value ?? ""));
1200
+ const hostRef = useRef(null);
1201
+ const skipBlurCommitRef = useRef(false);
1202
+ useLayoutEffect(() => {
1203
+ const input = hostRef.current?.querySelector("input");
1204
+ focusAndSelectEditorInput(input);
1205
+ }, [request]);
1206
+ useEffect(() => {
1207
+ setValue(String(request.value ?? ""));
1208
+ }, [request.value]);
1209
+ return /* @__PURE__ */ jsx("div", { ref: hostRef, style, children: /* @__PURE__ */ jsx(
1210
+ ReactInput,
1211
+ {
1212
+ value,
1213
+ placeholder: request.config.placeholder ?? "",
1214
+ onChange: (event) => {
1215
+ const nextValue = event.target.value;
1216
+ setValue(nextValue);
1217
+ request.onChange(nextValue);
1218
+ },
1219
+ onPressEnter: () => {
1220
+ request.onCommit({ restoreTableFocus: true });
1221
+ },
1222
+ onBlur: (event) => {
1223
+ handleEditorBlur(event, skipBlurCommitRef, request);
1224
+ },
1225
+ onKeyDown: (event) => {
1226
+ if (handleEditorNavigationKey(event, request, skipBlurCommitRef)) {
1227
+ return;
1228
+ }
1229
+ handleEditorEscapeKey(event, request);
1230
+ },
1231
+ style: getEditorInputStyle(request)
1232
+ }
1233
+ ) });
1234
+ }
1235
+ function NumberEditor(props) {
1236
+ const { request, style } = props;
1237
+ const [value, setValue] = useState(
1238
+ toNumberValue(request.value)
1239
+ );
1240
+ const hostRef = useRef(null);
1241
+ const skipBlurCommitRef = useRef(false);
1242
+ useLayoutEffect(() => {
1243
+ const input = hostRef.current?.querySelector("input");
1244
+ focusAndSelectEditorInput(input);
1245
+ }, [request]);
1246
+ useEffect(() => {
1247
+ setValue(toNumberValue(request.value));
1248
+ }, [request.value]);
1249
+ return /* @__PURE__ */ jsx("div", { ref: hostRef, style, children: /* @__PURE__ */ jsx(
1250
+ ReactNumberInput,
1251
+ {
1252
+ value,
1253
+ min: toNumericProp(request.config.min),
1254
+ max: toNumericProp(request.config.max),
1255
+ step: toNumericProp(request.config.step),
1256
+ onChange: (nextValue) => {
1257
+ setValue(nextValue);
1258
+ request.onChange(nextValue);
1259
+ },
1260
+ onPressEnter: () => {
1261
+ request.onCommit({ restoreTableFocus: true });
1262
+ },
1263
+ onBlur: (event) => {
1264
+ handleEditorBlur(event, skipBlurCommitRef, request);
1265
+ },
1266
+ onKeyDown: (event) => {
1267
+ if (handleEditorNavigationKey(event, request, skipBlurCommitRef)) {
1268
+ return;
1269
+ }
1270
+ handleEditorEscapeKey(event, request);
1271
+ },
1272
+ style: getEditorInputStyle(request)
1273
+ }
1274
+ ) });
1275
+ }
1276
+ function InputRangeEditor(props) {
1277
+ const { request, style } = props;
1278
+ const [value, setValue] = useState(
1279
+ toNumberRangeTuple(request.value)
1280
+ );
1281
+ const skipBlurCommitRef = useRef(false);
1282
+ useEffect(() => {
1283
+ setValue(toNumberRangeTuple(request.value));
1284
+ }, [request.value]);
1285
+ return /* @__PURE__ */ jsx("div", { "data-list-table-range-editor": true, style, children: /* @__PURE__ */ jsx(
1286
+ ReactInputRange,
1287
+ {
1288
+ value,
1289
+ autoFocus: true,
1290
+ min: toNumericProp(request.config.min),
1291
+ max: toNumericProp(request.config.max),
1292
+ step: toNumericProp(request.config.step),
1293
+ rangeSeparator: request.config.rangeSeparator,
1294
+ onChange: (nextValue) => {
1295
+ setValue(nextValue);
1296
+ request.onChange(nextValue);
1297
+ },
1298
+ onPressEnter: () => {
1299
+ request.onCommit({ restoreTableFocus: true });
1300
+ },
1301
+ onBlur: (event) => {
1302
+ handleEditorBlur(event, skipBlurCommitRef, request);
1303
+ },
1304
+ onKeyDown: (event) => {
1305
+ if (handleRangeInputTab(event)) {
1306
+ return;
1307
+ }
1308
+ if (handleEditorNavigationKey(event, request, skipBlurCommitRef)) {
1309
+ return;
1310
+ }
1311
+ handleEditorEscapeKey(event, request);
1312
+ },
1313
+ style: getEditorInputStyle(request)
1314
+ }
1315
+ ) });
1316
+ }
1317
+ function YearEditor(props) {
1318
+ const { request, style } = props;
1319
+ const [value, setValue] = useState(
1320
+ request.value == null ? "" : String(request.value)
1321
+ );
1322
+ const skipBlurCommitRef = useRef(false);
1323
+ useEffect(() => {
1324
+ setValue(request.value == null ? "" : String(request.value));
1325
+ }, [request.value]);
1326
+ return /* @__PURE__ */ jsx("div", { style, children: /* @__PURE__ */ jsx(
1327
+ ReactYearPicker,
1328
+ {
1329
+ value,
1330
+ autoFocus: true,
1331
+ allowClear: false,
1332
+ showArrow: false,
1333
+ onChange: (nextValue) => {
1334
+ setValue(nextValue);
1335
+ request.onChange(nextValue);
1336
+ request.onCommit();
1337
+ },
1338
+ onBlur: (event) => {
1339
+ handleEditorBlur(event, skipBlurCommitRef, request);
1340
+ },
1341
+ onKeyDown: (event) => {
1342
+ if (handleEditorNavigationKey(event, request, skipBlurCommitRef)) {
1343
+ return;
1344
+ }
1345
+ handleEditorEscapeKey(event, request);
1346
+ },
1347
+ style: getEditorInputStyle(request)
1348
+ }
1349
+ ) });
1350
+ }
1351
+ function QuarterEditor(props) {
1352
+ const { request, style } = props;
1353
+ const [value, setValue] = useState(
1354
+ request.value == null ? "" : String(request.value)
1355
+ );
1356
+ const skipBlurCommitRef = useRef(false);
1357
+ useEffect(() => {
1358
+ setValue(request.value == null ? "" : String(request.value));
1359
+ }, [request.value]);
1360
+ return /* @__PURE__ */ jsx("div", { style, children: /* @__PURE__ */ jsx(
1361
+ ReactQuarterPicker,
1362
+ {
1363
+ value,
1364
+ autoFocus: true,
1365
+ allowClear: false,
1366
+ showArrow: false,
1367
+ onChange: (nextValue) => {
1368
+ setValue(nextValue);
1369
+ request.onChange(nextValue);
1370
+ request.onCommit();
1371
+ },
1372
+ onBlur: (event) => {
1373
+ handleEditorBlur(event, skipBlurCommitRef, request);
1374
+ },
1375
+ onKeyDown: (event) => {
1376
+ if (handleEditorNavigationKey(event, request, skipBlurCommitRef)) {
1377
+ return;
1378
+ }
1379
+ handleEditorEscapeKey(event, request);
1380
+ },
1381
+ style: getEditorInputStyle(request)
1382
+ }
1383
+ ) });
1384
+ }
1385
+ function MonthEditor(props) {
1386
+ const { request, style } = props;
1387
+ const [value, setValue] = useState(
1388
+ request.value == null ? "" : String(request.value)
1389
+ );
1390
+ const skipBlurCommitRef = useRef(false);
1391
+ useEffect(() => {
1392
+ setValue(request.value == null ? "" : String(request.value));
1393
+ }, [request.value]);
1394
+ return /* @__PURE__ */ jsx("div", { style, children: /* @__PURE__ */ jsx(
1395
+ ReactMonthPicker,
1396
+ {
1397
+ value,
1398
+ autoFocus: true,
1399
+ allowClear: false,
1400
+ showArrow: false,
1401
+ onChange: (nextValue) => {
1402
+ setValue(nextValue);
1403
+ request.onChange(nextValue);
1404
+ request.onCommit();
1405
+ },
1406
+ onBlur: (event) => {
1407
+ handleEditorBlur(event, skipBlurCommitRef, request);
1408
+ },
1409
+ onKeyDown: (event) => {
1410
+ if (handleEditorNavigationKey(event, request, skipBlurCommitRef)) {
1411
+ return;
1412
+ }
1413
+ handleEditorEscapeKey(event, request);
1414
+ },
1415
+ style: getEditorInputStyle(request)
1416
+ }
1417
+ ) });
1418
+ }
1419
+ function DateEditor(props) {
1420
+ const { request, style } = props;
1421
+ const [value, setValue] = useState(
1422
+ request.value == null ? "" : String(request.value)
1423
+ );
1424
+ const skipBlurCommitRef = useRef(false);
1425
+ useEffect(() => {
1426
+ setValue(request.value == null ? "" : String(request.value));
1427
+ }, [request.value]);
1428
+ return /* @__PURE__ */ jsx("div", { style, children: /* @__PURE__ */ jsx(
1429
+ ReactDatePicker,
1430
+ {
1431
+ value,
1432
+ autoFocus: true,
1433
+ allowClear: false,
1434
+ showArrow: false,
1435
+ onChange: (nextValue) => {
1436
+ setValue(nextValue);
1437
+ request.onChange(nextValue);
1438
+ request.onCommit();
1439
+ },
1440
+ onBlur: (event) => {
1441
+ handleEditorBlur(event, skipBlurCommitRef, request);
1442
+ },
1443
+ onKeyDown: (event) => {
1444
+ if (handleEditorNavigationKey(event, request, skipBlurCommitRef)) {
1445
+ return;
1446
+ }
1447
+ handleEditorEscapeKey(event, request);
1448
+ },
1449
+ style: getEditorInputStyle(request)
1450
+ }
1451
+ ) });
1452
+ }
1453
+ function SelectEditor(props) {
1454
+ const { request, style } = props;
1455
+ const options = request.config.options ?? [];
1456
+ const [value, setValue] = useState(
1457
+ request.value == null ? void 0 : String(request.value)
1458
+ );
1459
+ const skipBlurCommitRef = useRef(false);
1460
+ useEffect(() => {
1461
+ setValue(request.value == null ? void 0 : String(request.value));
1462
+ }, [request.value]);
1463
+ return /* @__PURE__ */ jsx("div", { style, children: /* @__PURE__ */ jsx(
1464
+ ReactSelect,
1465
+ {
1466
+ value,
1467
+ autoFocus: true,
1468
+ showArrow: false,
1469
+ showSearch: request.config.showSearch,
1470
+ filterOption: request.config.filterOption,
1471
+ options,
1472
+ onChange: (nextValue, info) => {
1473
+ const resolvedValue = String(nextValue);
1474
+ setValue(resolvedValue);
1475
+ request.onChange(
1476
+ options.find((option) => String(option.value) === resolvedValue)?.value ?? resolvedValue
1477
+ );
1478
+ if (info.trigger === "mouse") {
1479
+ request.onCommit();
1480
+ }
1481
+ },
1482
+ onBlur: (event) => {
1483
+ handleEditorBlur(event, skipBlurCommitRef, request);
1484
+ },
1485
+ onKeyDown: (event) => {
1486
+ if (handleEditorNavigationKey(event, request, skipBlurCommitRef)) {
1487
+ return;
1488
+ }
1489
+ handleEditorEscapeKey(event, request);
1490
+ },
1491
+ style: getEditorInputStyle(request)
1492
+ }
1493
+ ) });
1494
+ }
1495
+ function AutoCompleteEditor(props) {
1496
+ const { request, style } = props;
1497
+ const [value, setValue] = useState(
1498
+ request.value == null ? "" : String(request.value)
1499
+ );
1500
+ const [options, setOptions] = useState(request.config.options ?? []);
1501
+ const skipBlurCommitRef = useRef(false);
1502
+ useEffect(() => {
1503
+ setValue(request.value == null ? "" : String(request.value));
1504
+ }, [request.value]);
1505
+ return /* @__PURE__ */ jsx("div", { style, children: /* @__PURE__ */ jsx(
1506
+ ReactAutoComplete,
1507
+ {
1508
+ value,
1509
+ autoFocus: true,
1510
+ showArrow: false,
1511
+ options,
1512
+ placeholder: request.config.placeholder ?? "",
1513
+ onChange: (nextValue, info) => {
1514
+ setValue(nextValue);
1515
+ request.onChange(nextValue);
1516
+ if (info.trigger === "mouse") {
1517
+ request.onCommit();
1518
+ }
1519
+ },
1520
+ onPressEnter: async (input) => {
1521
+ const nextOptions = await request.config.onPressEnter?.(input);
1522
+ if (nextOptions) {
1523
+ setOptions(nextOptions);
1524
+ }
1525
+ return nextOptions;
1526
+ },
1527
+ onBlur: () => {
1528
+ if (!skipBlurCommitRef.current) request.onCommit();
1529
+ skipBlurCommitRef.current = false;
1530
+ },
1531
+ onKeyDown: (event) => {
1532
+ if (handleEditorNavigationKey(event, request, skipBlurCommitRef)) {
1533
+ return;
1534
+ }
1535
+ handleEditorEscapeKey(event, request);
1536
+ },
1537
+ style: getEditorInputStyle(request)
1538
+ }
1539
+ ) });
1540
+ }
1541
+ function ColorEditor(props) {
1542
+ const { request, style } = props;
1543
+ const [value, setValue] = useState(
1544
+ request.value == null ? "" : String(request.value)
1545
+ );
1546
+ const skipBlurCommitRef = useRef(false);
1547
+ useEffect(() => {
1548
+ setValue(request.value == null ? "" : String(request.value));
1549
+ }, [request.value]);
1550
+ return /* @__PURE__ */ jsx("div", { style, children: /* @__PURE__ */ jsx(
1551
+ ReactColorPicker,
1552
+ {
1553
+ value,
1554
+ autoFocus: true,
1555
+ showArrow: false,
1556
+ onChange: (nextValue) => {
1557
+ setValue(nextValue);
1558
+ request.onChange(nextValue);
1559
+ },
1560
+ onBlur: (event) => {
1561
+ handleEditorBlur(event, skipBlurCommitRef, request);
1562
+ },
1563
+ onKeyDown: (event) => {
1564
+ if (handleEditorNavigationKey(event, request, skipBlurCommitRef)) {
1565
+ return;
1566
+ }
1567
+ handleEditorEscapeKey(event, request);
1568
+ },
1569
+ style: getEditorInputStyle(request)
1570
+ }
1571
+ ) });
1572
+ }
1573
+ function DateRangeEditor(props) {
1574
+ const { request, style } = props;
1575
+ const separator = request.config.rangeSeparator ?? " ~ ";
1576
+ const [value, setValue] = useState(
1577
+ toRangeTuple(request.value)
1578
+ );
1579
+ const skipBlurCommitRef = useRef(false);
1580
+ useEffect(() => {
1581
+ setValue(toRangeTuple(request.value));
1582
+ }, [request.value]);
1583
+ return /* @__PURE__ */ jsx("div", { "data-list-table-range-editor": true, style, children: /* @__PURE__ */ jsx(
1584
+ ReactDateRangePicker,
1585
+ {
1586
+ value,
1587
+ autoFocus: true,
1588
+ allowClear: false,
1589
+ showArrow: false,
1590
+ rangeSeparator: separator,
1591
+ onChange: (nextValue) => {
1592
+ setValue(nextValue);
1593
+ request.onChange(nextValue);
1594
+ },
1595
+ onBlur: (event) => {
1596
+ handleEditorBlur(event, skipBlurCommitRef, request);
1597
+ },
1598
+ onKeyDown: (event) => {
1599
+ if (handleRangeInputTab(event)) {
1600
+ return;
1601
+ }
1602
+ if (handleEditorNavigationKey(event, request, skipBlurCommitRef)) {
1603
+ return;
1604
+ }
1605
+ handleEditorEscapeKey(event, request);
1606
+ },
1607
+ style: getEditorInputStyle(request)
1608
+ }
1609
+ ) });
1610
+ }
1611
+ function TimeEditor(props) {
1612
+ const { request, style } = props;
1613
+ const [value, setValue] = useState(
1614
+ request.value == null ? "" : String(request.value)
1615
+ );
1616
+ const skipBlurCommitRef = useRef(false);
1617
+ useEffect(() => {
1618
+ setValue(request.value == null ? "" : String(request.value));
1619
+ }, [request.value]);
1620
+ return /* @__PURE__ */ jsx("div", { style, children: /* @__PURE__ */ jsx(
1621
+ ReactTimePicker,
1622
+ {
1623
+ value,
1624
+ autoFocus: true,
1625
+ allowClear: false,
1626
+ showArrow: false,
1627
+ onChange: (nextValue) => {
1628
+ setValue(nextValue);
1629
+ request.onChange(nextValue);
1630
+ },
1631
+ onBlur: (event) => {
1632
+ handleEditorBlur(event, skipBlurCommitRef, request);
1633
+ },
1634
+ onKeyDown: (event) => {
1635
+ if (handleEditorNavigationKey(event, request, skipBlurCommitRef)) {
1636
+ return;
1637
+ }
1638
+ handleEditorEscapeKey(event, request);
1639
+ },
1640
+ style: getEditorInputStyle(request)
1641
+ }
1642
+ ) });
1643
+ }
1644
+ function DateTimeEditor(props) {
1645
+ const { request, style } = props;
1646
+ const [value, setValue] = useState(
1647
+ request.value == null ? "" : String(request.value)
1648
+ );
1649
+ const skipBlurCommitRef = useRef(false);
1650
+ useEffect(() => {
1651
+ setValue(request.value == null ? "" : String(request.value));
1652
+ }, [request.value]);
1653
+ return /* @__PURE__ */ jsx("div", { style, children: /* @__PURE__ */ jsx(
1654
+ ReactDateTimePicker,
1655
+ {
1656
+ value,
1657
+ autoFocus: true,
1658
+ allowClear: false,
1659
+ showArrow: false,
1660
+ onChange: (nextValue) => {
1661
+ setValue(nextValue);
1662
+ request.onChange(nextValue);
1663
+ request.onCommit();
1664
+ },
1665
+ onBlur: (event) => {
1666
+ handleEditorBlur(event, skipBlurCommitRef, request);
1667
+ },
1668
+ onKeyDown: (event) => {
1669
+ if (handleEditorNavigationKey(event, request, skipBlurCommitRef)) {
1670
+ return;
1671
+ }
1672
+ handleEditorEscapeKey(event, request);
1673
+ },
1674
+ style: getEditorInputStyle(request)
1675
+ }
1676
+ ) });
1677
+ }
1678
+ function DateTimeRangeEditor(props) {
1679
+ const { request, style } = props;
1680
+ const separator = request.config.rangeSeparator ?? " ~ ";
1681
+ const [value, setValue] = useState(
1682
+ toRangeTuple(request.value)
1683
+ );
1684
+ const skipBlurCommitRef = useRef(false);
1685
+ useEffect(() => {
1686
+ setValue(toRangeTuple(request.value));
1687
+ }, [request.value]);
1688
+ return /* @__PURE__ */ jsx("div", { "data-list-table-range-editor": true, style, children: /* @__PURE__ */ jsx(
1689
+ ReactDateTimeRangePicker,
1690
+ {
1691
+ value,
1692
+ autoFocus: true,
1693
+ allowClear: false,
1694
+ showArrow: false,
1695
+ rangeSeparator: separator,
1696
+ onChange: (nextValue) => {
1697
+ setValue(nextValue);
1698
+ request.onChange(nextValue);
1699
+ },
1700
+ onBlur: (event) => {
1701
+ handleEditorBlur(event, skipBlurCommitRef, request);
1702
+ },
1703
+ onKeyDown: (event) => {
1704
+ if (handleRangeInputTab(event)) {
1705
+ return;
1706
+ }
1707
+ if (handleEditorNavigationKey(event, request, skipBlurCommitRef)) {
1708
+ return;
1709
+ }
1710
+ handleEditorEscapeKey(event, request);
1711
+ },
1712
+ style: getEditorInputStyle(request)
1713
+ }
1714
+ ) });
1715
+ }
1716
+ function TimeRangeEditor(props) {
1717
+ const { request, style } = props;
1718
+ const separator = request.config.rangeSeparator ?? " ~ ";
1719
+ const [value, setValue] = useState(
1720
+ toRangeTuple(request.value)
1721
+ );
1722
+ const skipBlurCommitRef = useRef(false);
1723
+ useEffect(() => {
1724
+ setValue(toRangeTuple(request.value));
1725
+ }, [request.value]);
1726
+ return /* @__PURE__ */ jsx("div", { "data-list-table-range-editor": true, style, children: /* @__PURE__ */ jsx(
1727
+ ReactTimeRangePicker,
1728
+ {
1729
+ value,
1730
+ autoFocus: true,
1731
+ showArrow: false,
1732
+ rangeSeparator: separator,
1733
+ onChange: (nextValue) => {
1734
+ setValue(nextValue);
1735
+ request.onChange(nextValue);
1736
+ },
1737
+ onBlur: (event) => {
1738
+ handleEditorBlur(event, skipBlurCommitRef, request);
1739
+ },
1740
+ onKeyDown: (event) => {
1741
+ if (handleRangeInputTab(event)) {
1742
+ return;
1743
+ }
1744
+ if (handleEditorNavigationKey(event, request, skipBlurCommitRef)) {
1745
+ return;
1746
+ }
1747
+ handleEditorEscapeKey(event, request);
1748
+ },
1749
+ style: getEditorInputStyle(request)
1750
+ }
1751
+ ) });
1752
+ }
1753
+ function handleEditorNavigationKey(event, request, skipBlurCommitRef) {
1754
+ const direction = resolveNavigationDirection(event);
1755
+ if (!direction || !request.onNavigate) {
1756
+ return false;
1757
+ }
1758
+ event.preventDefault();
1759
+ skipBlurCommitRef.current = true;
1760
+ request.onNavigate(direction);
1761
+ return true;
1762
+ }
1763
+ function handleRangeInputTab(event) {
1764
+ if (event.key !== "Tab") {
1765
+ return false;
1766
+ }
1767
+ const host = event.currentTarget.closest(
1768
+ "[data-list-table-range-editor]"
1769
+ );
1770
+ const inputs = Array.from(
1771
+ host?.querySelectorAll("input") ?? []
1772
+ );
1773
+ const currentIndex = inputs.indexOf(event.currentTarget);
1774
+ const nextIndex = event.shiftKey ? currentIndex - 1 : currentIndex + 1;
1775
+ const nextInput = inputs[nextIndex];
1776
+ if (!nextInput) {
1777
+ return false;
1778
+ }
1779
+ event.preventDefault();
1780
+ focusAndSelectEditorInput(nextInput);
1781
+ return true;
1782
+ }
1783
+ function focusAndSelectEditorInput(input) {
1784
+ if (!input) {
1785
+ return;
1786
+ }
1787
+ input.focus();
1788
+ try {
1789
+ input.select();
1790
+ } catch {
1791
+ }
1792
+ }
1793
+ function handleEditorEscapeKey(event, request) {
1794
+ if (event.key !== "Escape") {
1795
+ return;
1796
+ }
1797
+ event.preventDefault();
1798
+ request.onCancel();
1799
+ }
1800
+ function toRangeTuple(value) {
1801
+ if (!Array.isArray(value)) {
1802
+ return ["", ""];
1803
+ }
1804
+ return [String(value[0] ?? ""), String(value[1] ?? "")];
1805
+ }
1806
+ function toNumberRangeTuple(value) {
1807
+ if (!Array.isArray(value)) {
1808
+ return [null, null];
1809
+ }
1810
+ return [toNumberValue(value[0]), toNumberValue(value[1])];
1811
+ }
1812
+ function handleEditorBlur(_event, skipBlurCommitRef, request) {
1813
+ if (skipBlurCommitRef.current) {
1814
+ skipBlurCommitRef.current = false;
1815
+ return;
1816
+ }
1817
+ request.onCommit();
1818
+ }
1819
+ function resolveNavigationDirection(event) {
1820
+ if (event.key === "ArrowUp") {
1821
+ return "up";
1822
+ }
1823
+ if (event.key === "ArrowDown") {
1824
+ return "down";
1825
+ }
1826
+ if (event.key === "Tab") {
1827
+ return event.shiftKey ? "prev" : "next";
1828
+ }
1829
+ return null;
1830
+ }
1831
+ function ReactTableFixedPopupView(props) {
1832
+ const { request } = props;
1833
+ if (!request) {
1834
+ return null;
1835
+ }
1836
+ const surfaceStyle = {
1837
+ minWidth: 160,
1838
+ padding: 8
1839
+ };
1840
+ return /* @__PURE__ */ jsx(
1841
+ ReactPopup,
1842
+ {
1843
+ open: true,
1844
+ anchorRect: request.anchorRect,
1845
+ offset: 8,
1846
+ minWidth: 160,
1847
+ onOpenChange: (open) => {
1848
+ if (!open) {
1849
+ request.onClose();
1850
+ }
1851
+ },
1852
+ surfaceStyle,
1853
+ children: /* @__PURE__ */ jsxs("div", { children: [
1854
+ /* @__PURE__ */ jsx(
1855
+ PopupAction,
1856
+ {
1857
+ active: request.currentFixed === "left",
1858
+ onClick: () => request.onSelect("left"),
1859
+ children: "\u56FA\u5B9A\u5230\u5DE6\u4FA7"
1860
+ }
1861
+ ),
1862
+ /* @__PURE__ */ jsx(
1863
+ PopupAction,
1864
+ {
1865
+ active: request.currentFixed === "right",
1866
+ onClick: () => request.onSelect("right"),
1867
+ children: "\u56FA\u5B9A\u5230\u53F3\u4FA7"
1868
+ }
1869
+ ),
1870
+ /* @__PURE__ */ jsx(PopupAction, { onClick: () => request.onSelect("none"), children: "\u53D6\u6D88\u56FA\u5B9A" })
1871
+ ] })
1872
+ }
1873
+ );
1874
+ }
1875
+ function PopupAction(props) {
1876
+ const { active = false, onClick, children } = props;
1877
+ const [hovered, setHovered] = useState(false);
1878
+ const backgroundColor = active ? hovered ? "#bae0ff" : "#e6f4ff" : hovered ? "#f5faff" : "transparent";
1879
+ return /* @__PURE__ */ jsx(
1880
+ "button",
1881
+ {
1882
+ type: "button",
1883
+ onClick,
1884
+ onMouseEnter: () => {
1885
+ setHovered(true);
1886
+ },
1887
+ onMouseLeave: () => {
1888
+ setHovered(false);
1889
+ },
1890
+ style: {
1891
+ display: "block",
1892
+ width: "100%",
1893
+ height: 32,
1894
+ marginBottom: 4,
1895
+ border: "none",
1896
+ borderRadius: 8,
1897
+ background: backgroundColor,
1898
+ color: active ? "#1677ff" : "#374151",
1899
+ textAlign: "left",
1900
+ padding: "0 10px",
1901
+ cursor: "pointer"
1902
+ },
1903
+ children
1904
+ }
1905
+ );
1906
+ }
1907
+ function ReactTableFilterPanelView(props) {
1908
+ return /* @__PURE__ */ jsx(
1909
+ ReactFilterPanel,
1910
+ {
1911
+ request: props.request
1912
+ }
1913
+ );
1914
+ }
1915
+ function ReactTablePaginationView(props) {
1916
+ const { config } = props;
1917
+ if (!config) {
1918
+ return null;
1919
+ }
1920
+ return /* @__PURE__ */ jsx(
1921
+ "div",
1922
+ {
1923
+ style: {
1924
+ position: "absolute",
1925
+ right: 0,
1926
+ bottom: 0,
1927
+ display: "flex",
1928
+ justifyContent: "flex-end",
1929
+ paddingTop: 12
1930
+ },
1931
+ children: /* @__PURE__ */ jsx(
1932
+ ReactPagination,
1933
+ {
1934
+ current: config.current,
1935
+ total: config.total,
1936
+ pageSize: config.pageSize,
1937
+ pageSizeOptions: config.pageSizeOptions,
1938
+ disabled: config.disabled,
1939
+ showSizeChanger: config.showSizeChanger,
1940
+ showQuickJumper: config.showQuickJumper,
1941
+ showLessItems: config.showLessItems,
1942
+ simple: config.simple,
1943
+ showTotal: config.showTotal,
1944
+ onChange: (page, pageSize) => {
1945
+ config.onChange?.(page, pageSize);
1946
+ },
1947
+ onPageSizeChange: (page, pageSize) => {
1948
+ config.onPageSizeChange?.(page, pageSize);
1949
+ }
1950
+ }
1951
+ )
1952
+ }
1953
+ );
1954
+ }
1955
+ function ReactTableDangerConfirmView(props) {
1956
+ const { request, onClose } = props;
1957
+ const confirmingRef = useRef(false);
1958
+ useEffect(() => {
1959
+ confirmingRef.current = false;
1960
+ }, [request]);
1961
+ if (!request) {
1962
+ return null;
1963
+ }
1964
+ return /* @__PURE__ */ jsx(
1965
+ ReactPopconfirm,
1966
+ {
1967
+ open: true,
1968
+ title: request.title,
1969
+ description: request.description,
1970
+ okText: request.okText,
1971
+ cancelText: request.cancelText,
1972
+ placement: "topLeft",
1973
+ onConfirm: () => {
1974
+ confirmingRef.current = true;
1975
+ try {
1976
+ request.onConfirm();
1977
+ } finally {
1978
+ onClose();
1979
+ }
1980
+ },
1981
+ onOpenChange: (open) => {
1982
+ if (open) {
1983
+ return;
1984
+ }
1985
+ if (confirmingRef.current) {
1986
+ confirmingRef.current = false;
1987
+ return;
1988
+ }
1989
+ request.onCancel();
1990
+ onClose();
1991
+ },
1992
+ style: {
1993
+ position: "fixed",
1994
+ left: request.anchorRect.x,
1995
+ top: request.anchorRect.y,
1996
+ width: Math.max(request.anchorRect.width, 1),
1997
+ height: Math.max(request.anchorRect.height, 1),
1998
+ pointerEvents: "none"
1999
+ },
2000
+ children: /* @__PURE__ */ jsx("span", { "aria-hidden": "true" })
2001
+ }
2002
+ );
2003
+ }
2004
+ function ReactTableTooltipView(props) {
2005
+ const { request } = props;
2006
+ if (!request) {
2007
+ return null;
2008
+ }
2009
+ const zoom = typeof request.contentZoom === "number" && Number.isFinite(request.contentZoom) && request.contentZoom > 0 ? request.contentZoom : 1;
2010
+ const fontSize = 12 * zoom;
2011
+ const paddingBlock = 6 * zoom;
2012
+ const paddingInline = 10 * zoom;
2013
+ const borderRadius = 6 * zoom;
2014
+ const maxWidth = 320 * zoom;
2015
+ const style = {
2016
+ position: "fixed",
2017
+ left: request.x,
2018
+ top: request.y,
2019
+ transform: "translate(-50%, 0)",
2020
+ maxWidth,
2021
+ padding: `${paddingBlock}px ${paddingInline}px`,
2022
+ borderRadius,
2023
+ background: request.variant === "error" ? "#ffffff" : "rgba(17, 24, 39, 0.92)",
2024
+ color: request.variant === "error" ? "#ff4d4f" : "#fff",
2025
+ fontSize,
2026
+ lineHeight: 1.5,
2027
+ boxShadow: request.variant === "error" ? "0 10px 30px rgba(255, 77, 79, 0.16)" : "0 10px 30px rgba(15, 23, 42, 0.18)",
2028
+ border: request.variant === "error" ? "1px solid rgba(255, 77, 79, 0.2)" : "none",
2029
+ pointerEvents: "none",
2030
+ zIndex: 1200,
2031
+ whiteSpace: "pre-wrap",
2032
+ wordBreak: "break-word"
2033
+ };
2034
+ return /* @__PURE__ */ jsx("div", { style, children: request.content });
2035
+ }
2036
+ function ToolbarIcon(props) {
2037
+ const { path, ...svgProps } = props;
2038
+ return /* @__PURE__ */ jsx(
2039
+ "svg",
2040
+ {
2041
+ viewBox: "64 64 896 896",
2042
+ width: "1em",
2043
+ height: "1em",
2044
+ fill: "currentColor",
2045
+ "aria-hidden": "true",
2046
+ focusable: "false",
2047
+ ...svgProps,
2048
+ children: /* @__PURE__ */ jsx("path", { d: path })
2049
+ }
2050
+ );
2051
+ }
2052
+ function FullscreenOutlined() {
2053
+ return /* @__PURE__ */ jsx(ToolbarIcon, { path: "M290 236.4l43.9-43.9a8.01 8.01 0 00-4.7-13.6L169 160c-5.1-.6-9.5 3.7-8.9 8.9L179 329.1c.8 6.6 8.9 9.4 13.6 4.7l43.7-43.7L370 423.7c3.1 3.1 8.2 3.1 11.3 0l42.4-42.3c3.1-3.1 3.1-8.2 0-11.3L290 236.4zm352.7 187.3c3.1 3.1 8.2 3.1 11.3 0l133.7-133.6 43.7 43.7a8.01 8.01 0 0013.6-4.7L863.9 169c.6-5.1-3.7-9.5-8.9-8.9L694.8 179c-6.6.8-9.4 8.9-4.7 13.6l43.9 43.9L600.3 370a8.03 8.03 0 000 11.3l42.4 42.4zM845 694.9c-.8-6.6-8.9-9.4-13.6-4.7l-43.7 43.7L654 600.3a8.03 8.03 0 00-11.3 0l-42.4 42.3a8.03 8.03 0 000 11.3L734 787.6l-43.9 43.9a8.01 8.01 0 004.7 13.6L855 864c5.1.6 9.5-3.7 8.9-8.9L845 694.9zm-463.7-94.6a8.03 8.03 0 00-11.3 0L236.3 733.9l-43.7-43.7a8.01 8.01 0 00-13.6 4.7L160.1 855c-.6 5.1 3.7 9.5 8.9 8.9L329.2 845c6.6-.8 9.4-8.9 4.7-13.6L290 787.6 423.7 654c3.1-3.1 3.1-8.2 0-11.3l-42.4-42.4z" });
2054
+ }
2055
+ function FullscreenExitOutlined() {
2056
+ return /* @__PURE__ */ jsx(ToolbarIcon, { path: "M391 240.9c-.8-6.6-8.9-9.4-13.6-4.7l-43.7 43.7L200 146.3a8.03 8.03 0 00-11.3 0l-42.4 42.3a8.03 8.03 0 000 11.3L280 333.6l-43.9 43.9a8.01 8.01 0 004.7 13.6L401 410c5.1.6 9.5-3.7 8.9-8.9L391 240.9zm10.1 373.2L240.8 633c-6.6.8-9.4 8.9-4.7 13.6l43.9 43.9L146.3 824a8.03 8.03 0 000 11.3l42.4 42.3c3.1 3.1 8.2 3.1 11.3 0L333.7 744l43.7 43.7A8.01 8.01 0 00391 783l18.9-160.1c.6-5.1-3.7-9.4-8.8-8.8zm221.8-204.2L783.2 391c6.6-.8 9.4-8.9 4.7-13.6L744 333.6 877.7 200c3.1-3.1 3.1-8.2 0-11.3l-42.4-42.3a8.03 8.03 0 00-11.3 0L690.3 279.9l-43.7-43.7a8.01 8.01 0 00-13.6 4.7L614.1 401c-.6 5.2 3.7 9.5 8.8 8.9zM744 690.4l43.9-43.9a8.01 8.01 0 00-4.7-13.6L623 614c-5.1-.6-9.5 3.7-8.9 8.9L633 783.1c.8 6.6 8.9 9.4 13.6 4.7l43.7-43.7L824 877.7c3.1 3.1 8.2 3.1 11.3 0l42.4-42.3c3.1-3.1 3.1-8.2 0-11.3L744 690.4z" });
2057
+ }
2058
+ function ReloadOutlined() {
2059
+ return /* @__PURE__ */ jsx(ToolbarIcon, { path: "M909.1 209.3l-56.4 44.1C775.8 155.1 656.2 92 521.9 92 290 92 102.3 279.5 102 511.5 101.7 743.7 289.8 932 521.9 932c181.3 0 335.8-115 394.6-276.1 1.5-4.2-.7-8.9-4.9-10.3l-56.7-19.5a8 8 0 00-10.1 4.8c-1.8 5-3.8 10-5.9 14.9-17.3 41-42.1 77.8-73.7 109.4A344.77 344.77 0 01655.9 829c-42.3 17.9-87.4 27-133.8 27-46.5 0-91.5-9.1-133.8-27A341.5 341.5 0 01279 755.2a342.16 342.16 0 01-73.7-109.4c-17.9-42.4-27-87.4-27-133.9s9.1-91.5 27-133.9c17.3-41 42.1-77.8 73.7-109.4 31.6-31.6 68.4-56.4 109.3-73.8 42.3-17.9 87.4-27 133.8-27 46.5 0 91.5 9.1 133.8 27a341.5 341.5 0 01109.3 73.8c9.9 9.9 19.2 20.4 27.8 31.4l-60.2 47a8 8 0 003 14.1l175.6 43c5 1.2 9.9-2.6 9.9-7.7l.8-180.9c-.1-6.6-7.8-10.3-13-6.2z" });
2060
+ }
2061
+ function ExportOutlined() {
2062
+ return /* @__PURE__ */ jsx(ToolbarIcon, { path: "M880 912H144c-17.7 0-32-14.3-32-32V144c0-17.7 14.3-32 32-32h360c4.4 0 8 3.6 8 8v56c0 4.4-3.6 8-8 8H184v656h656V520c0-4.4 3.6-8 8-8h56c4.4 0 8 3.6 8 8v360c0 17.7-14.3 32-32 32zM770.87 199.13l-52.2-52.2a8.01 8.01 0 014.7-13.6l179.4-21c5.1-.6 9.5 3.7 8.9 8.9l-21 179.4c-.8 6.6-8.9 9.4-13.6 4.7l-52.4-52.4-256.2 256.2a8.03 8.03 0 01-11.3 0l-42.4-42.4a8.03 8.03 0 010-11.3l256.1-256.3z" });
2063
+ }
2064
+ function ColumnHeightOutlined() {
2065
+ return /* @__PURE__ */ jsx(ToolbarIcon, { path: "M840 836H184c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h656c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8zm0-724H184c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h656c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8zM610.8 378c6 0 9.4-7 5.7-11.7L515.7 238.7a7.14 7.14 0 00-11.3 0L403.6 366.3a7.23 7.23 0 005.7 11.7H476v268h-62.8c-6 0-9.4 7-5.7 11.7l100.8 127.5c2.9 3.7 8.5 3.7 11.3 0l100.8-127.5c3.7-4.7.4-11.7-5.7-11.7H548V378h62.8z" });
2066
+ }
2067
+ function SettingOutlined() {
2068
+ return /* @__PURE__ */ jsx(ToolbarIcon, { path: "M924.8 625.7l-65.5-56c3.1-19 4.7-38.4 4.7-57.8s-1.6-38.8-4.7-57.8l65.5-56a32.03 32.03 0 009.3-35.2l-.9-2.6a443.74 443.74 0 00-79.7-137.9l-1.8-2.1a32.12 32.12 0 00-35.1-9.5l-81.3 28.9c-30-24.6-63.5-44-99.7-57.6l-15.7-85a32.05 32.05 0 00-25.8-25.7l-2.7-.5c-52.1-9.4-106.9-9.4-159 0l-2.7.5a32.05 32.05 0 00-25.8 25.7l-15.8 85.4a351.86 351.86 0 00-99 57.4l-81.9-29.1a32 32 0 00-35.1 9.5l-1.8 2.1a446.02 446.02 0 00-79.7 137.9l-.9 2.6c-4.5 12.5-.8 26.5 9.3 35.2l66.3 56.6c-3.1 18.8-4.6 38-4.6 57.1 0 19.2 1.5 38.4 4.6 57.1L99 625.5a32.03 32.03 0 00-9.3 35.2l.9 2.6c18.1 50.4 44.9 96.9 79.7 137.9l1.8 2.1a32.12 32.12 0 0035.1 9.5l81.9-29.1c29.8 24.5 63.1 43.9 99 57.4l15.8 85.4a32.05 32.05 0 0025.8 25.7l2.7.5a449.4 449.4 0 00159 0l2.7-.5a32.05 32.05 0 0025.8-25.7l15.7-85a350 350 0 0099.7-57.6l81.3 28.9a32 32 0 0035.1-9.5l1.8-2.1c34.8-41.1 61.6-87.5 79.7-137.9l.9-2.6c4.5-12.3.8-26.3-9.3-35zM788.3 465.9c2.5 15.1 3.8 30.6 3.8 46.1s-1.3 31-3.8 46.1l-6.6 40.1 74.7 63.9a370.03 370.03 0 01-42.6 73.6L721 702.8l-31.4 25.8c-23.9 19.6-50.5 35-79.3 45.8l-38.1 14.3-17.9 97a377.5 377.5 0 01-85 0l-17.9-97.2-37.8-14.5c-28.5-10.8-55-26.2-78.7-45.7l-31.4-25.9-93.4 33.2c-17-22.9-31.2-47.6-42.6-73.6l75.5-64.5-6.5-40c-2.4-14.9-3.7-30.3-3.7-45.5 0-15.3 1.2-30.6 3.7-45.5l6.5-40-75.5-64.5c11.3-26.1 25.6-50.7 42.6-73.6l93.4 33.2 31.4-25.9c23.7-19.5 50.2-34.9 78.7-45.7l37.9-14.3 17.9-97.2c28.1-3.2 56.8-3.2 85 0l17.9 97 38.1 14.3c28.7 10.8 55.4 26.2 79.3 45.8l31.4 25.8 92.8-32.9c17 22.9 31.2 47.6 42.6 73.6L781.8 426l6.5 39.9zM512 326c-97.2 0-176 78.8-176 176s78.8 176 176 176 176-78.8 176-176-78.8-176-176-176zm79.2 255.2A111.6 111.6 0 01512 614c-29.9 0-58-11.7-79.2-32.8A111.6 111.6 0 01400 502c0-29.9 11.7-58 32.8-79.2C454 401.6 482.1 390 512 390c29.9 0 58 11.6 79.2 32.8A111.6 111.6 0 01624 502c0 29.9-11.7 58-32.8 79.2z" });
2069
+ }
2070
+ function HolderOutlined() {
2071
+ return /* @__PURE__ */ jsx(ToolbarIcon, { path: "M300 276.5a56 56 0 1056-97 56 56 0 00-56 97zm0 284a56 56 0 1056-97 56 56 0 00-56 97zM640 228a56 56 0 10112 0 56 56 0 00-112 0zm0 284a56 56 0 10112 0 56 56 0 00-112 0zM300 844.5a56 56 0 1056-97 56 56 0 00-56 97zM640 796a56 56 0 10112 0 56 56 0 00-112 0z" });
2072
+ }
2073
+ function SortableList(props) {
2074
+ const { items, onOrderChange } = props;
2075
+ const rootRef = useRef(null);
2076
+ const dragRef = useRef(null);
2077
+ const [dragState, setDragState] = useState(null);
2078
+ useEffect(
2079
+ () => () => {
2080
+ document.body.classList.remove("react-list-table-sorting");
2081
+ document.body.style.removeProperty("user-select");
2082
+ },
2083
+ []
2084
+ );
2085
+ useEffect(() => {
2086
+ if (!dragState) return;
2087
+ const handleMove = (event) => {
2088
+ const current = dragRef.current;
2089
+ if (!current) return;
2090
+ const target = resolveClosestSortableItem({
2091
+ items,
2092
+ parentKey: current.source.parentKey,
2093
+ layouts: current.layouts,
2094
+ overlayCenterY: event.clientY - current.offsetY + current.height / 2
2095
+ });
2096
+ if (target) {
2097
+ current.target = target;
2098
+ }
2099
+ setDragState({
2100
+ sourceKey: current.source.key,
2101
+ targetKey: current.target.key,
2102
+ pointerY: event.clientY
2103
+ });
2104
+ };
2105
+ const handleEnd = () => {
2106
+ const current = dragRef.current;
2107
+ if (current && current.source.key !== current.target.key) {
2108
+ const siblings = items.filter(
2109
+ (item) => item.parentKey === current.source.parentKey
2110
+ );
2111
+ const orderedKeys = resolveNextSortableOrder(
2112
+ siblings.map((item) => item.key),
2113
+ current.source.key,
2114
+ current.target.key
2115
+ );
2116
+ if (orderedKeys) {
2117
+ onOrderChange(current.source.parentKey, orderedKeys);
2118
+ }
2119
+ }
2120
+ dragRef.current = null;
2121
+ setDragState(null);
2122
+ document.body.classList.remove("react-list-table-sorting");
2123
+ document.body.style.removeProperty("user-select");
2124
+ };
2125
+ window.addEventListener("pointermove", handleMove);
2126
+ window.addEventListener("pointerup", handleEnd, { once: true });
2127
+ window.addEventListener("pointercancel", handleEnd, { once: true });
2128
+ return () => {
2129
+ window.removeEventListener("pointermove", handleMove);
2130
+ window.removeEventListener("pointerup", handleEnd);
2131
+ window.removeEventListener("pointercancel", handleEnd);
2132
+ };
2133
+ }, [dragState != null, items, onOrderChange]);
2134
+ const sourceIndex = dragState ? items.findIndex((item) => item.key === dragState.sourceKey) : -1;
2135
+ const targetIndex = dragState ? items.findIndex((item) => item.key === dragState.targetKey) : -1;
2136
+ return /* @__PURE__ */ jsxs("div", { ref: rootRef, children: [
2137
+ items.map((item, index) => {
2138
+ const style = resolveSortableTransform(
2139
+ index,
2140
+ sourceIndex,
2141
+ targetIndex,
2142
+ dragRef.current?.height ?? 0
2143
+ );
2144
+ return /* @__PURE__ */ jsx(
2145
+ "div",
2146
+ {
2147
+ "data-sortable-key": item.key,
2148
+ className: dragState?.sourceKey === item.key ? "dragging" : "",
2149
+ style,
2150
+ children: props.renderItem(item, {
2151
+ onPointerDown: (event) => {
2152
+ if (event.button !== 0) return;
2153
+ const row = event.currentTarget.closest(
2154
+ "[data-sortable-key]"
2155
+ );
2156
+ if (!row) return;
2157
+ const rect = row.getBoundingClientRect();
2158
+ dragRef.current = {
2159
+ source: item,
2160
+ target: item,
2161
+ layouts: collectSortableItemLayouts(rootRef.current),
2162
+ offsetY: event.clientY - rect.top,
2163
+ width: rect.width,
2164
+ left: rect.left,
2165
+ height: rect.height
2166
+ };
2167
+ setDragState({
2168
+ sourceKey: item.key,
2169
+ targetKey: item.key,
2170
+ pointerY: event.clientY
2171
+ });
2172
+ document.body.classList.add("react-list-table-sorting");
2173
+ document.body.style.userSelect = "none";
2174
+ event.preventDefault();
2175
+ }
2176
+ })
2177
+ },
2178
+ item.key
2179
+ );
2180
+ }),
2181
+ dragState && dragRef.current ? createPortal(
2182
+ /* @__PURE__ */ jsx(
2183
+ "div",
2184
+ {
2185
+ className: "react-list-table-sort-overlay",
2186
+ style: {
2187
+ left: dragRef.current.left,
2188
+ top: dragState.pointerY - dragRef.current.offsetY,
2189
+ width: dragRef.current.width,
2190
+ height: dragRef.current.height
2191
+ },
2192
+ children: props.renderItem(dragRef.current.source, {
2193
+ onPointerDown: (event) => event.preventDefault()
2194
+ })
2195
+ }
2196
+ ),
2197
+ document.body
2198
+ ) : null
2199
+ ] });
2200
+ }
2201
+ function resolveNextSortableOrder(currentKeys, sourceKey, targetKey) {
2202
+ const sourceIndex = currentKeys.indexOf(sourceKey);
2203
+ const targetIndex = currentKeys.indexOf(targetKey);
2204
+ if (sourceIndex < 0 || targetIndex < 0 || sourceIndex === targetIndex) {
2205
+ return null;
2206
+ }
2207
+ const nextKeys = [...currentKeys];
2208
+ const [source] = nextKeys.splice(sourceIndex, 1);
2209
+ nextKeys.splice(targetIndex, 0, source);
2210
+ return nextKeys;
2211
+ }
2212
+ function collectSortableItemLayouts(root) {
2213
+ if (!root) return [];
2214
+ return Array.from(
2215
+ root.querySelectorAll("[data-sortable-key]")
2216
+ ).map((element) => {
2217
+ const rect = element.getBoundingClientRect();
2218
+ return {
2219
+ key: element.dataset.sortableKey ?? "",
2220
+ centerY: rect.top + rect.height / 2
2221
+ };
2222
+ });
2223
+ }
2224
+ function resolveClosestSortableItem(params) {
2225
+ let closestItem = null;
2226
+ let closestDistance = Number.POSITIVE_INFINITY;
2227
+ params.layouts.forEach((layout) => {
2228
+ const item = params.items.find((candidate) => candidate.key === layout.key);
2229
+ if (!item || item.parentKey !== params.parentKey) return;
2230
+ const distance = Math.abs(params.overlayCenterY - layout.centerY);
2231
+ if (distance < closestDistance) {
2232
+ closestDistance = distance;
2233
+ closestItem = item;
2234
+ }
2235
+ });
2236
+ return closestItem;
2237
+ }
2238
+ function resolveSortableTransform(index, sourceIndex, targetIndex, height) {
2239
+ let translateY = 0;
2240
+ if (sourceIndex < targetIndex && index > sourceIndex && index <= targetIndex) {
2241
+ translateY = -height;
2242
+ } else if (sourceIndex > targetIndex && index >= targetIndex && index < sourceIndex) {
2243
+ translateY = height;
2244
+ }
2245
+ return {
2246
+ transform: translateY ? `translate3d(0, ${translateY}px, 0)` : void 0,
2247
+ transition: sourceIndex >= 0 ? "transform 180ms ease" : void 0
2248
+ };
2249
+ }
2250
+
2251
+ // src/features/toolbar/style.css
2252
+ styleInject('.react-list-table-titlebar {\n height: 44px;\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 12px 0;\n box-sizing: border-box;\n background: #fff;\n}\n.react-list-table-title {\n min-width: 0;\n color: #1f2937;\n font-size: 14px;\n font-weight: 600;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n}\n.react-list-table-tools {\n display: flex;\n align-items: center;\n gap: 14px;\n color: #475569;\n}\n.react-list-table-tool-wrap {\n position: relative;\n display: inline-flex;\n}\n.react-list-table-tool {\n width: 20px;\n height: 24px;\n padding: 0;\n border: 0;\n color: inherit;\n background: transparent;\n font: 16px/24px sans-serif;\n cursor: pointer;\n}\n.react-list-table-tool:hover {\n color: #1677ff;\n}\n.react-list-table-tool-menu,\n.react-list-table-column-setting {\n position: absolute;\n z-index: 120;\n top: 28px;\n right: 0;\n min-width: 112px;\n padding: 6px;\n border: 1px solid #e5e7eb;\n border-radius: 6px;\n background: #fff;\n box-shadow: 0 8px 24px rgba(15, 23, 42, .14);\n}\n.react-list-table-tool-menu button {\n display: flex;\n align-items: center;\n justify-content: space-between;\n width: 100%;\n padding: 6px 10px;\n border: 0;\n border-radius: 4px;\n background: transparent;\n text-align: left;\n cursor: pointer;\n}\n.react-list-table-tool-menu button.active::after {\n content: "\\2713";\n margin-left: 12px;\n font-size: 12px;\n}\n.react-list-table-tool-menu button:hover,\n.react-list-table-tool-menu button.active {\n color: #1677ff;\n background: #e6f4ff;\n}\n.react-list-table-column-setting {\n width: 328px;\n max-height: 360px;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n}\n.react-list-table-column-setting-head {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 4px 6px 8px;\n border-bottom: 1px solid #f0f0f0;\n flex: 0 0 auto;\n}\n.react-list-table-column-setting-head button {\n border: 0;\n color: #1677ff;\n background: transparent;\n cursor: pointer;\n}\n.react-list-table-column-setting-body {\n flex: 1 1 auto;\n min-height: 0;\n overflow: auto;\n}\n.react-list-table-column-item {\n display: flex;\n align-items: center;\n gap: 8px;\n justify-content: space-between;\n padding: 7px 6px;\n box-sizing: border-box;\n cursor: pointer;\n}\n.react-list-table-column-main,\n.react-list-table-column-actions {\n display: inline-flex;\n align-items: center;\n gap: 8px;\n}\n.react-list-table-column-main {\n min-width: 0;\n}\n.react-list-table-column-actions {\n flex: 0 0 auto;\n}\n.react-list-table-column-actions > .canvas-react-select-wrap {\n flex: 0 0 96px;\n width: 96px;\n height: 24px;\n}\n.react-list-table-column-label {\n min-width: 64px;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n}\n.react-list-table-column-width-input {\n height: 22px;\n padding-inline: 5px;\n}\n.react-list-table-column-fixed-input {\n height: 22px;\n padding-inline: 6px;\n font-size: 12px;\n}\n.react-list-table-column-setting label.dragging {\n opacity: 0.45;\n background: #e6f4ff;\n}\n.react-list-table-column-setting [data-sortable-key].dragging {\n opacity: 0.28;\n}\n.react-list-table-column-drag {\n color: #94a3b8;\n display: inline-flex;\n font-size: 14px;\n cursor: grab;\n user-select: none;\n}\nbody.react-list-table-sorting,\nbody.react-list-table-sorting * {\n cursor: grabbing !important;\n}\n.react-list-table-sort-overlay {\n position: fixed;\n z-index: 1400;\n display: block;\n padding: 0;\n box-sizing: border-box;\n color: #334155;\n background: #fff;\n border: 1px solid #91caff;\n border-radius: 6px;\n box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);\n pointer-events: none;\n}\n.react-list-table-sort-overlay .react-list-table-column-item {\n width: 100%;\n height: 100%;\n}\n');
2253
+ function ReactTableToolbar(props) {
2254
+ const { toolbar, title } = props;
2255
+ const [densityOpen, setDensityOpen] = useState(false);
2256
+ const [settingOpen, setSettingOpen] = useState(false);
2257
+ const [isFullscreen, setIsFullscreen] = useState(false);
2258
+ const rootRef = useRef(null);
2259
+ const hasToolbar = toolbar !== void 0 && toolbar !== false;
2260
+ useEffect(() => {
2261
+ const close = (event) => {
2262
+ if (event.target?.closest(".canvas-react-popup")) {
2263
+ return;
2264
+ }
2265
+ if (!rootRef.current?.contains(event.target)) {
2266
+ setDensityOpen(false);
2267
+ setSettingOpen(false);
2268
+ }
2269
+ };
2270
+ document.addEventListener("mousedown", close);
2271
+ return () => document.removeEventListener("mousedown", close);
2272
+ }, []);
2273
+ useEffect(() => {
2274
+ const handleFullscreenChange = () => {
2275
+ const fullscreenNode = (typeof toolbar === "object" ? toolbar.getFullscreenNode?.() : null) ?? props.hostRef.current;
2276
+ setIsFullscreen(document.fullscreenElement === fullscreenNode);
2277
+ };
2278
+ document.addEventListener("fullscreenchange", handleFullscreenChange);
2279
+ return () => document.removeEventListener("fullscreenchange", handleFullscreenChange);
2280
+ }, [props.hostRef, toolbar]);
2281
+ if (!title && !hasToolbar) return null;
2282
+ const config = typeof toolbar === "object" ? toolbar : {};
2283
+ return /* @__PURE__ */ jsxs("div", { className: "react-list-table-titlebar", ref: rootRef, children: [
2284
+ /* @__PURE__ */ jsx("div", { className: "react-list-table-title", children: title }),
2285
+ hasToolbar ? /* @__PURE__ */ jsxs("div", { className: "react-list-table-tools", children: [
2286
+ config.extra,
2287
+ config.showFullscreen !== false ? /* @__PURE__ */ jsx(
2288
+ ToolButton,
2289
+ {
2290
+ label: isFullscreen ? "\u9000\u51FA\u5168\u5C4F" : "\u5168\u5C4F",
2291
+ onClick: () => {
2292
+ if (isFullscreen) {
2293
+ void document.exitFullscreen?.();
2294
+ } else {
2295
+ const fullscreenNode = config.getFullscreenNode?.() ?? props.hostRef.current;
2296
+ void fullscreenNode?.requestFullscreen?.();
2297
+ }
2298
+ },
2299
+ children: isFullscreen ? /* @__PURE__ */ jsx(FullscreenExitOutlined, {}) : /* @__PURE__ */ jsx(FullscreenOutlined, {})
2300
+ }
2301
+ ) : null,
2302
+ config.showRefresh !== false ? /* @__PURE__ */ jsx(ToolButton, { label: "\u5237\u65B0", iconSize: 14, onClick: () => config.onRefresh?.(), children: /* @__PURE__ */ jsx(ReloadOutlined, {}) }) : null,
2303
+ config.showExport ? /* @__PURE__ */ jsx(
2304
+ ToolButton,
2305
+ {
2306
+ label: "\u5BFC\u51FA",
2307
+ iconSize: 14,
2308
+ onClick: () => {
2309
+ if (config.onExport) {
2310
+ config.onExport();
2311
+ } else {
2312
+ props.onExport();
2313
+ }
2314
+ },
2315
+ children: /* @__PURE__ */ jsx(ExportOutlined, {})
2316
+ }
2317
+ ) : null,
2318
+ config.showDensity !== false ? /* @__PURE__ */ jsxs("div", { className: "react-list-table-tool-wrap", children: [
2319
+ /* @__PURE__ */ jsx(ToolButton, { label: "\u8868\u683C\u5BC6\u5EA6", onClick: () => setDensityOpen((v) => !v), children: /* @__PURE__ */ jsx(ColumnHeightOutlined, {}) }),
2320
+ densityOpen ? /* @__PURE__ */ jsx("div", { className: "react-list-table-tool-menu", children: [48, 40, 32].map((height) => /* @__PURE__ */ jsx(
2321
+ "button",
2322
+ {
2323
+ type: "button",
2324
+ className: props.density === height ? "active" : "",
2325
+ onClick: () => {
2326
+ props.onDensityChange(height);
2327
+ setDensityOpen(false);
2328
+ },
2329
+ children: height === 48 ? "\u5BBD\u677E" : height === 40 ? "\u4E2D\u7B49" : "\u7D27\u51D1"
2330
+ },
2331
+ height
2332
+ )) }) : null
2333
+ ] }) : null,
2334
+ config.showColumnSetting !== false ? /* @__PURE__ */ jsxs("div", { className: "react-list-table-tool-wrap", children: [
2335
+ /* @__PURE__ */ jsx(ToolButton, { label: "\u5217\u8BBE\u7F6E", onClick: () => setSettingOpen((v) => !v), children: /* @__PURE__ */ jsx(SettingOutlined, {}) }),
2336
+ settingOpen ? /* @__PURE__ */ jsxs(
2337
+ "div",
2338
+ {
2339
+ className: "react-list-table-column-setting",
2340
+ style: { width: config.columnSettingWidth },
2341
+ children: [
2342
+ /* @__PURE__ */ jsxs("div", { className: "react-list-table-column-setting-head", children: [
2343
+ /* @__PURE__ */ jsx("strong", { children: "\u5217\u8BBE\u7F6E" }),
2344
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: props.onResetColumns, children: "\u91CD\u7F6E" })
2345
+ ] }),
2346
+ /* @__PURE__ */ jsx("div", { className: "react-list-table-column-setting-body", children: /* @__PURE__ */ jsx(
2347
+ SortableList,
2348
+ {
2349
+ items: flattenColumns(props.columns),
2350
+ onOrderChange: props.onColumnOrderChange,
2351
+ renderItem: (column, handleProps) => /* @__PURE__ */ jsxs("div", { className: "react-list-table-column-item", children: [
2352
+ /* @__PURE__ */ jsxs(
2353
+ "span",
2354
+ {
2355
+ className: "react-list-table-column-main",
2356
+ style: { paddingLeft: column.level * 16 },
2357
+ children: [
2358
+ /* @__PURE__ */ jsx(
2359
+ "span",
2360
+ {
2361
+ className: "react-list-table-column-drag",
2362
+ ...handleProps,
2363
+ onClick: (event) => {
2364
+ event.preventDefault();
2365
+ event.stopPropagation();
2366
+ },
2367
+ children: /* @__PURE__ */ jsx(HolderOutlined, {})
2368
+ }
2369
+ ),
2370
+ /* @__PURE__ */ jsx(
2371
+ "input",
2372
+ {
2373
+ type: "checkbox",
2374
+ checked: !column.hidden,
2375
+ onChange: (event) => props.onColumnVisibilityChange(
2376
+ column.key,
2377
+ event.target.checked
2378
+ )
2379
+ }
2380
+ ),
2381
+ /* @__PURE__ */ jsx("span", { className: "react-list-table-column-label", children: column.label })
2382
+ ]
2383
+ }
2384
+ ),
2385
+ !column.isGroup ? /* @__PURE__ */ jsxs("span", { className: "react-list-table-column-actions", children: [
2386
+ /* @__PURE__ */ jsx(
2387
+ ReactNumberInput,
2388
+ {
2389
+ className: "react-list-table-column-width-input",
2390
+ min: column.minWidth,
2391
+ max: column.maxWidth,
2392
+ value: column.width,
2393
+ allowClear: false,
2394
+ "aria-label": `${column.label}\u5217\u5BBD`,
2395
+ style: { width: 80, height: 24 },
2396
+ onChange: (width) => {
2397
+ if (width != null && Number.isFinite(width) && width > 0 && (column.minWidth == null || width >= column.minWidth) && (column.maxWidth == null || width <= column.maxWidth)) {
2398
+ props.onColumnWidthChange(column.key, width);
2399
+ }
2400
+ }
2401
+ }
2402
+ ),
2403
+ /* @__PURE__ */ jsx(
2404
+ ReactSelect,
2405
+ {
2406
+ className: "react-list-table-column-fixed-input",
2407
+ value: column.fixed ?? "none",
2408
+ options: [
2409
+ { label: "\u4E0D\u56FA\u5B9A", value: "none" },
2410
+ { label: "\u56FA\u5B9A\u5DE6\u4FA7", value: "left" },
2411
+ { label: "\u56FA\u5B9A\u53F3\u4FA7", value: "right" }
2412
+ ],
2413
+ allowClear: false,
2414
+ showSearch: false,
2415
+ style: { width: "100%", height: 24 },
2416
+ "aria-label": `${column.label}\u56FA\u5B9A\u65B9\u5411`,
2417
+ onChange: (value) => {
2418
+ props.onColumnFixedChange(
2419
+ column.key,
2420
+ value === "left" || value === "right" ? value : void 0
2421
+ );
2422
+ }
2423
+ }
2424
+ )
2425
+ ] }) : null
2426
+ ] })
2427
+ }
2428
+ ) })
2429
+ ]
2430
+ }
2431
+ ) : null
2432
+ ] }) : null
2433
+ ] }) : null
2434
+ ] });
2435
+ }
2436
+ function ToolButton(props) {
2437
+ return /* @__PURE__ */ jsx("button", { type: "button", className: "react-list-table-tool", style: { fontSize: props.iconSize ?? 16 }, title: props.label, "aria-label": props.label, onClick: props.onClick, children: props.children });
2438
+ }
2439
+ function flattenColumns(columns, parentKey = "root", level = 0) {
2440
+ return columns.flatMap((column) => {
2441
+ const key = String(column.key ?? column.dataIndex);
2442
+ const label = typeof column.title === "string" ? column.title : key;
2443
+ const current = {
2444
+ key,
2445
+ label,
2446
+ hidden: column.hidden === true,
2447
+ parentKey,
2448
+ width: Number(column.width) || 160,
2449
+ minWidth: typeof column.minWidth === "number" ? column.minWidth : void 0,
2450
+ maxWidth: typeof column.maxWidth === "number" ? column.maxWidth : void 0,
2451
+ fixed: column.fixed,
2452
+ level,
2453
+ isGroup: Boolean(column.children?.length)
2454
+ };
2455
+ return column.children?.length ? [current, ...flattenColumns(column.children, key, level + 1)] : [current];
2456
+ });
2457
+ }
2458
+ function useReactListTableState(options) {
2459
+ const containerRef = useRef(null);
2460
+ const tableRef = useRef(null);
2461
+ const [editorRequest, setEditorRequest] = useState(null);
2462
+ const [paginationConfig, setPaginationConfig] = useState(null);
2463
+ const [tooltipRequest, setTooltipRequest] = useState(null);
2464
+ const [loadingRequest, setLoadingRequest] = useState(null);
2465
+ const [filterPanelRequest, setFilterPanelRequest] = useState(null);
2466
+ const [fixedPopupRequest, setFixedPopupRequest] = useState(null);
2467
+ const [headerContextMenuRequest, setHeaderContextMenuRequest] = useState(null);
2468
+ const [imagePreviewRequest, setImagePreviewRequest] = useState(null);
2469
+ const [dangerConfirmRequest, setDangerConfirmRequest] = useState(null);
2470
+ const uiOptions = useMemo(
2471
+ () => ({
2472
+ ...options.ui,
2473
+ onEditorRequest: (request) => {
2474
+ setEditorRequest(request);
2475
+ options.ui?.onEditorRequest?.(request);
2476
+ },
2477
+ onPaginationRender: (config) => {
2478
+ setPaginationConfig(config);
2479
+ options.ui?.onPaginationRender?.(config);
2480
+ },
2481
+ onTooltipRequest: (request) => {
2482
+ setTooltipRequest(request);
2483
+ options.ui?.onTooltipRequest?.(request);
2484
+ },
2485
+ onLoadingRequest: (request) => {
2486
+ setLoadingRequest(request);
2487
+ options.ui?.onLoadingRequest?.(request);
2488
+ },
2489
+ onFilterPanelRequest: (request) => {
2490
+ setFilterPanelRequest(request);
2491
+ options.ui?.onFilterPanelRequest?.(request);
2492
+ },
2493
+ onFixedPopupRequest: (request) => {
2494
+ setFixedPopupRequest(request);
2495
+ options.ui?.onFixedPopupRequest?.(request);
2496
+ },
2497
+ onHeaderContextMenuRequest: (request) => {
2498
+ setHeaderContextMenuRequest(request);
2499
+ options.ui?.onHeaderContextMenuRequest?.(request);
2500
+ },
2501
+ onImagePreviewRequest: (request) => {
2502
+ setImagePreviewRequest(request);
2503
+ options.ui?.onImagePreviewRequest?.(request);
2504
+ },
2505
+ onDangerConfirmRequest: (request) => {
2506
+ setDangerConfirmRequest(request);
2507
+ options.ui?.onDangerConfirmRequest?.(request);
2508
+ }
2509
+ }),
2510
+ [options.ui]
2511
+ );
2512
+ useEffect(() => {
2513
+ const container = containerRef.current;
2514
+ if (!container) {
2515
+ return;
2516
+ }
2517
+ const table = new ListTable(container, {
2518
+ ...options,
2519
+ ui: uiOptions
2520
+ });
2521
+ table.mount();
2522
+ tableRef.current = table;
2523
+ return () => {
2524
+ table.destroy();
2525
+ tableRef.current = null;
2526
+ setEditorRequest(null);
2527
+ setPaginationConfig(null);
2528
+ setTooltipRequest(null);
2529
+ setLoadingRequest(null);
2530
+ setFilterPanelRequest(null);
2531
+ setFixedPopupRequest(null);
2532
+ setHeaderContextMenuRequest(null);
2533
+ setImagePreviewRequest(null);
2534
+ setDangerConfirmRequest(null);
2535
+ };
2536
+ }, []);
2537
+ useEffect(() => {
2538
+ tableRef.current?.updateOptions({
2539
+ ...options,
2540
+ ui: uiOptions
2541
+ });
2542
+ }, [options, uiOptions]);
2543
+ return {
2544
+ containerRef,
2545
+ tableRef,
2546
+ editorRequest,
2547
+ paginationConfig,
2548
+ tooltipRequest,
2549
+ loadingRequest,
2550
+ filterPanelRequest,
2551
+ fixedPopupRequest,
2552
+ headerContextMenuRequest,
2553
+ imagePreviewRequest,
2554
+ dangerConfirmRequest,
2555
+ closeDangerConfirmRequest: () => {
2556
+ setDangerConfirmRequest(null);
2557
+ options.ui?.onDangerConfirmRequest?.(null);
2558
+ }
2559
+ };
2560
+ }
2561
+
2562
+ // src/components/build-list-table-options.ts
2563
+ function buildListTableOptions(props) {
2564
+ const {
2565
+ width,
2566
+ height,
2567
+ emptyText,
2568
+ scroll,
2569
+ locale,
2570
+ onChange,
2571
+ query,
2572
+ ...restProps
2573
+ } = props;
2574
+ return {
2575
+ type: "list",
2576
+ ...restProps,
2577
+ width: scroll?.x === true ? "100%" : scroll?.x ?? width,
2578
+ height: scroll?.y ?? height,
2579
+ emptyText: locale?.emptyText ?? emptyText,
2580
+ query: onChange ? {
2581
+ ...query,
2582
+ onChange
2583
+ } : query
2584
+ };
2585
+ }
2586
+ function ReactListTableInner(props, ref) {
2587
+ const {
2588
+ className,
2589
+ style,
2590
+ width,
2591
+ height,
2592
+ emptyText,
2593
+ scroll,
2594
+ locale,
2595
+ onChange,
2596
+ rowKey,
2597
+ columns,
2598
+ dataSource,
2599
+ theme,
2600
+ striped,
2601
+ highlightMode,
2602
+ contextMenu,
2603
+ rowHeight,
2604
+ headerRowHeight,
2605
+ summaryRowHeight,
2606
+ overscanRowCount,
2607
+ query,
2608
+ rowSelection,
2609
+ expandable,
2610
+ pagination,
2611
+ scrollbar,
2612
+ carouselScroll,
2613
+ stretchColumns,
2614
+ resizable,
2615
+ storageKey,
2616
+ draggable,
2617
+ tableId,
2618
+ rowDrag,
2619
+ debug,
2620
+ title,
2621
+ toolbar
2622
+ } = props;
2623
+ const shellRef = useRef(null);
2624
+ const [densityOverride, setDensityOverride] = useState(
2625
+ null
2626
+ );
2627
+ const [columnVisibility, setColumnVisibility] = useState(() => /* @__PURE__ */ new Map());
2628
+ const [columnOrders, setColumnOrders] = useState(
2629
+ () => /* @__PURE__ */ new Map()
2630
+ );
2631
+ const [columnConfig, setColumnConfig] = useState(() => /* @__PURE__ */ new Map());
2632
+ const resolvedColumns = useMemo(
2633
+ () => applyColumnManagerState(
2634
+ columns,
2635
+ columnVisibility,
2636
+ columnOrders,
2637
+ columnConfig
2638
+ ),
2639
+ [columns, columnVisibility, columnOrders, columnConfig]
2640
+ );
2641
+ const resolvedRowHeight = densityOverride ?? rowHeight;
2642
+ const options = useMemo(
2643
+ () => buildListTableOptions({
2644
+ width,
2645
+ height,
2646
+ emptyText,
2647
+ scroll,
2648
+ locale,
2649
+ onChange,
2650
+ rowKey,
2651
+ columns: resolvedColumns,
2652
+ dataSource,
2653
+ theme,
2654
+ striped,
2655
+ highlightMode,
2656
+ contextMenu,
2657
+ rowHeight: resolvedRowHeight,
2658
+ headerRowHeight,
2659
+ summaryRowHeight,
2660
+ overscanRowCount,
2661
+ query,
2662
+ rowSelection,
2663
+ expandable,
2664
+ pagination,
2665
+ scrollbar,
2666
+ carouselScroll,
2667
+ stretchColumns,
2668
+ resizable,
2669
+ storageKey,
2670
+ draggable,
2671
+ tableId,
2672
+ rowDrag,
2673
+ debug
2674
+ }),
2675
+ [
2676
+ width,
2677
+ height,
2678
+ emptyText,
2679
+ scroll,
2680
+ locale,
2681
+ onChange,
2682
+ rowKey,
2683
+ resolvedColumns,
2684
+ dataSource,
2685
+ theme,
2686
+ striped,
2687
+ highlightMode,
2688
+ contextMenu,
2689
+ resolvedRowHeight,
2690
+ headerRowHeight,
2691
+ summaryRowHeight,
2692
+ overscanRowCount,
2693
+ query,
2694
+ rowSelection,
2695
+ expandable,
2696
+ pagination,
2697
+ scrollbar,
2698
+ carouselScroll,
2699
+ stretchColumns,
2700
+ resizable,
2701
+ storageKey,
2702
+ draggable,
2703
+ tableId,
2704
+ rowDrag,
2705
+ debug
2706
+ ]
2707
+ );
2708
+ const {
2709
+ containerRef,
2710
+ tableRef,
2711
+ editorRequest,
2712
+ paginationConfig,
2713
+ tooltipRequest,
2714
+ loadingRequest,
2715
+ filterPanelRequest,
2716
+ fixedPopupRequest,
2717
+ headerContextMenuRequest,
2718
+ imagePreviewRequest,
2719
+ dangerConfirmRequest,
2720
+ closeDangerConfirmRequest
2721
+ } = useReactListTableState(options);
2722
+ const hasPagination = paginationConfig != null;
2723
+ useImperativeHandle(
2724
+ ref,
2725
+ () => ({
2726
+ validate: () => tableRef.current?.validate() ?? Promise.resolve([]),
2727
+ exportXlsx: () => {
2728
+ tableRef.current?.exportXlsx();
2729
+ },
2730
+ scrollTo: (options2) => {
2731
+ tableRef.current?.scrollTo(options2);
2732
+ },
2733
+ getDebugSnapshot: () => tableRef.current?.getDebugSnapshot() ?? null,
2734
+ resetSorter: () => {
2735
+ tableRef.current?.resetSorter();
2736
+ },
2737
+ resetFilter: () => {
2738
+ tableRef.current?.resetFilter();
2739
+ }
2740
+ }),
2741
+ []
2742
+ );
2743
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2744
+ /* @__PURE__ */ jsxs(
2745
+ "div",
2746
+ {
2747
+ ref: shellRef,
2748
+ className,
2749
+ style: {
2750
+ position: "relative",
2751
+ display: "flex",
2752
+ flexDirection: "column",
2753
+ paddingBottom: hasPagination ? 44 : void 0,
2754
+ ...style
2755
+ },
2756
+ children: [
2757
+ /* @__PURE__ */ jsx(
2758
+ ReactTableToolbar,
2759
+ {
2760
+ title,
2761
+ toolbar,
2762
+ columns: resolvedColumns,
2763
+ density: resolvedRowHeight === "auto" ? 40 : resolvedRowHeight ?? 40,
2764
+ hostRef: shellRef,
2765
+ onExport: () => tableRef.current?.exportXlsx(),
2766
+ onDensityChange: setDensityOverride,
2767
+ onColumnVisibilityChange: (columnKey, visible) => {
2768
+ setColumnVisibility((current) => {
2769
+ const next = new Map(current);
2770
+ next.set(columnKey, visible);
2771
+ return next;
2772
+ });
2773
+ },
2774
+ onColumnOrderChange: (parentKey, orderedKeys) => {
2775
+ setColumnOrders((current) => {
2776
+ const next = new Map(current);
2777
+ next.set(parentKey, orderedKeys);
2778
+ return next;
2779
+ });
2780
+ },
2781
+ onColumnWidthChange: (columnKey, width2) => {
2782
+ setColumnConfig((current) => {
2783
+ const next = new Map(current);
2784
+ next.set(columnKey, {
2785
+ ...next.get(columnKey),
2786
+ width: width2
2787
+ });
2788
+ return next;
2789
+ });
2790
+ },
2791
+ onColumnFixedChange: (columnKey, fixed) => {
2792
+ setColumnConfig((current) => {
2793
+ const next = new Map(current);
2794
+ next.set(columnKey, {
2795
+ ...next.get(columnKey),
2796
+ fixed: fixed ?? null
2797
+ });
2798
+ return next;
2799
+ });
2800
+ },
2801
+ onResetColumns: () => {
2802
+ setColumnVisibility(/* @__PURE__ */ new Map());
2803
+ setColumnOrders(/* @__PURE__ */ new Map());
2804
+ setColumnConfig(/* @__PURE__ */ new Map());
2805
+ }
2806
+ }
2807
+ ),
2808
+ /* @__PURE__ */ jsx(
2809
+ "div",
2810
+ {
2811
+ ref: containerRef,
2812
+ style: { flex: 1, minWidth: 0, width: "100%", minHeight: 0 },
2813
+ children: /* @__PURE__ */ jsx(ReactTablePaginationView, { config: paginationConfig })
2814
+ }
2815
+ ),
2816
+ loadingRequest ? /* @__PURE__ */ jsx(
2817
+ "div",
2818
+ {
2819
+ style: {
2820
+ position: "absolute",
2821
+ inset: 0,
2822
+ display: "flex",
2823
+ alignItems: "center",
2824
+ justifyContent: "center",
2825
+ background: "rgba(255, 255, 255, 0.68)",
2826
+ color: "#475569",
2827
+ fontSize: 14,
2828
+ pointerEvents: "auto",
2829
+ cursor: "progress"
2830
+ },
2831
+ children: loadingRequest.text ?? "\u5904\u7406\u4E2D\u2026"
2832
+ }
2833
+ ) : null
2834
+ ]
2835
+ }
2836
+ ),
2837
+ tooltipRequest ? createPortal(
2838
+ /* @__PURE__ */ jsx(ReactTableTooltipView, { request: tooltipRequest }),
2839
+ document.body
2840
+ ) : null,
2841
+ filterPanelRequest ? createPortal(
2842
+ /* @__PURE__ */ jsx(ReactTableFilterPanelView, { request: filterPanelRequest }),
2843
+ document.body
2844
+ ) : null,
2845
+ fixedPopupRequest ? createPortal(
2846
+ /* @__PURE__ */ jsx(ReactTableFixedPopupView, { request: fixedPopupRequest }),
2847
+ document.body
2848
+ ) : null,
2849
+ headerContextMenuRequest ? createPortal(
2850
+ /* @__PURE__ */ jsx(ReactTableContextMenuView, { request: headerContextMenuRequest }),
2851
+ document.body
2852
+ ) : null,
2853
+ dangerConfirmRequest ? createPortal(
2854
+ /* @__PURE__ */ jsx(
2855
+ ReactTableDangerConfirmView,
2856
+ {
2857
+ request: dangerConfirmRequest,
2858
+ onClose: closeDangerConfirmRequest
2859
+ }
2860
+ ),
2861
+ document.body
2862
+ ) : null,
2863
+ editorRequest ? createPortal(
2864
+ /* @__PURE__ */ jsx(ReactTableEditorOverlay, { request: editorRequest }),
2865
+ editorRequest.hostElement ?? document.body
2866
+ ) : null,
2867
+ imagePreviewRequest ? createPortal(
2868
+ /* @__PURE__ */ jsx(
2869
+ ReactImagePreview,
2870
+ {
2871
+ open: true,
2872
+ src: imagePreviewRequest.src,
2873
+ alt: imagePreviewRequest.alt,
2874
+ onClose: imagePreviewRequest.onClose
2875
+ }
2876
+ ),
2877
+ document.body
2878
+ ) : null
2879
+ ] });
2880
+ }
2881
+ function applyColumnManagerState(columns, visibility, orders, config, parentKey = "root") {
2882
+ const order = orders.get(parentKey);
2883
+ const sortedColumns = order ? [...columns].sort(
2884
+ (left, right) => order.indexOf(resolveColumnKey(left)) - order.indexOf(resolveColumnKey(right))
2885
+ ) : columns;
2886
+ return sortedColumns.map((column) => {
2887
+ const key = resolveColumnKey(column);
2888
+ const managedConfig = config.get(key);
2889
+ return {
2890
+ ...column,
2891
+ hidden: visibility.has(key) ? visibility.get(key) === false : column.hidden,
2892
+ width: managedConfig?.width ?? column.width,
2893
+ minWidth: column.minWidth,
2894
+ maxWidth: column.maxWidth,
2895
+ fixed: managedConfig?.fixed === null ? void 0 : managedConfig?.fixed ?? column.fixed,
2896
+ children: column.children ? applyColumnManagerState(
2897
+ column.children,
2898
+ visibility,
2899
+ orders,
2900
+ config,
2901
+ key
2902
+ ) : void 0
2903
+ };
2904
+ });
2905
+ }
2906
+ function resolveColumnKey(column) {
2907
+ return String(column.key ?? column.dataIndex);
2908
+ }
2909
+ var ReactListTable = forwardRef(ReactListTableInner);
2910
+
2911
+ export { ReactListTable };
2912
+ //# sourceMappingURL=index.js.map
2913
+ //# sourceMappingURL=index.js.map