@canvas-components/react-list-table 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +137 -128
- package/dist/index.cjs +259 -61
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +259 -61
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { CSSProperties, ReactNode, ForwardedRef } from 'react';
|
|
3
|
-
import { ListTableOptions, ListTableQueryChange, ListTableScrollToOptions, ListTable, ListTableColumn, ListTablePaginationOptions, ListTableQueryOptions, ListTableRowSelectionOptions } from '@canvas-components/list-table';
|
|
3
|
+
import { ListTableOptions, ListTableQueryChange, ListTableExportXlsxOptions, ListTableScrollToOptions, ListTable, ListTableColumn, ListTablePaginationOptions, ListTableQueryOptions, ListTableRowSelectionOptions } from '@canvas-components/list-table';
|
|
4
4
|
|
|
5
5
|
interface ReactListTableScrollConfig {
|
|
6
6
|
x?: number | string | true;
|
|
@@ -30,8 +30,14 @@ interface ReactListTableToolbarOptions {
|
|
|
30
30
|
showColumnSetting?: boolean;
|
|
31
31
|
/** 列设置弹层宽度,数字值按像素处理。 */
|
|
32
32
|
columnSettingWidth?: number | string;
|
|
33
|
+
/** 列设置标题栏中位于重置按钮前的扩展内容。 */
|
|
34
|
+
columnSettingHeaderExtra?: ReactNode;
|
|
33
35
|
showExport?: boolean;
|
|
36
|
+
/** 默认导出行为使用的文件名和汇总行配置。 */
|
|
37
|
+
exportOptions?: ListTableExportXlsxOptions;
|
|
34
38
|
onRefresh?: () => void;
|
|
39
|
+
/** 表格密度变化回调,依次对应紧凑、中等和宽松。 */
|
|
40
|
+
onDensityChange?: (density: 32 | 40 | 48) => void;
|
|
35
41
|
/** 自定义导出行为;未配置时默认异步导出全量 XLSX 数据。 */
|
|
36
42
|
onExport?: () => void;
|
|
37
43
|
/** 自定义全屏节点,默认使用表格根容器。 */
|
|
@@ -43,7 +49,7 @@ interface ReactListTableToolbarOptions {
|
|
|
43
49
|
*/
|
|
44
50
|
interface ReactListTableRef<RecordType = Record<string, unknown>> {
|
|
45
51
|
validate: () => Promise<RecordType[]>;
|
|
46
|
-
exportXlsx: () => void;
|
|
52
|
+
exportXlsx: (options?: ListTableExportXlsxOptions) => void;
|
|
47
53
|
scrollTo: (options: ListTableScrollToOptions) => void;
|
|
48
54
|
getDebugSnapshot: () => ReturnType<ListTable<RecordType>["getDebugSnapshot"]>;
|
|
49
55
|
resetSorter: () => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { CSSProperties, ReactNode, ForwardedRef } from 'react';
|
|
3
|
-
import { ListTableOptions, ListTableQueryChange, ListTableScrollToOptions, ListTable, ListTableColumn, ListTablePaginationOptions, ListTableQueryOptions, ListTableRowSelectionOptions } from '@canvas-components/list-table';
|
|
3
|
+
import { ListTableOptions, ListTableQueryChange, ListTableExportXlsxOptions, ListTableScrollToOptions, ListTable, ListTableColumn, ListTablePaginationOptions, ListTableQueryOptions, ListTableRowSelectionOptions } from '@canvas-components/list-table';
|
|
4
4
|
|
|
5
5
|
interface ReactListTableScrollConfig {
|
|
6
6
|
x?: number | string | true;
|
|
@@ -30,8 +30,14 @@ interface ReactListTableToolbarOptions {
|
|
|
30
30
|
showColumnSetting?: boolean;
|
|
31
31
|
/** 列设置弹层宽度,数字值按像素处理。 */
|
|
32
32
|
columnSettingWidth?: number | string;
|
|
33
|
+
/** 列设置标题栏中位于重置按钮前的扩展内容。 */
|
|
34
|
+
columnSettingHeaderExtra?: ReactNode;
|
|
33
35
|
showExport?: boolean;
|
|
36
|
+
/** 默认导出行为使用的文件名和汇总行配置。 */
|
|
37
|
+
exportOptions?: ListTableExportXlsxOptions;
|
|
34
38
|
onRefresh?: () => void;
|
|
39
|
+
/** 表格密度变化回调,依次对应紧凑、中等和宽松。 */
|
|
40
|
+
onDensityChange?: (density: 32 | 40 | 48) => void;
|
|
35
41
|
/** 自定义导出行为;未配置时默认异步导出全量 XLSX 数据。 */
|
|
36
42
|
onExport?: () => void;
|
|
37
43
|
/** 自定义全屏节点,默认使用表格根容器。 */
|
|
@@ -43,7 +49,7 @@ interface ReactListTableToolbarOptions {
|
|
|
43
49
|
*/
|
|
44
50
|
interface ReactListTableRef<RecordType = Record<string, unknown>> {
|
|
45
51
|
validate: () => Promise<RecordType[]>;
|
|
46
|
-
exportXlsx: () => void;
|
|
52
|
+
exportXlsx: (options?: ListTableExportXlsxOptions) => void;
|
|
47
53
|
scrollTo: (options: ListTableScrollToOptions) => void;
|
|
48
54
|
getDebugSnapshot: () => ReturnType<ListTable<RecordType>["getDebugSnapshot"]>;
|
|
49
55
|
resetSorter: () => void;
|
package/dist/index.js
CHANGED
|
@@ -162,6 +162,8 @@ function ReactTableContextMenuView(props) {
|
|
|
162
162
|
}
|
|
163
163
|
),
|
|
164
164
|
/* @__PURE__ */ jsx(SummaryMenu, { request }),
|
|
165
|
+
/* @__PURE__ */ jsx(AlignmentMenu, { request }),
|
|
166
|
+
/* @__PURE__ */ jsx(DataFormatMenu, { request }),
|
|
165
167
|
/* @__PURE__ */ jsx(
|
|
166
168
|
MenuSubmenu,
|
|
167
169
|
{
|
|
@@ -215,13 +217,7 @@ function ReactTableContextMenuView(props) {
|
|
|
215
217
|
onChange: request.onChangeDensity
|
|
216
218
|
}
|
|
217
219
|
),
|
|
218
|
-
/* @__PURE__ */ jsx(
|
|
219
|
-
ZoomMenu,
|
|
220
|
-
{
|
|
221
|
-
value: request.zoom ?? 1,
|
|
222
|
-
onChange: request.onChangeZoom
|
|
223
|
-
}
|
|
224
|
-
),
|
|
220
|
+
/* @__PURE__ */ jsx(ZoomMenu, { value: request.zoom ?? 1, onChange: request.onChangeZoom }),
|
|
225
221
|
request.columns?.length && request.onToggleColumn ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
226
222
|
/* @__PURE__ */ jsx(MenuDivider, {}),
|
|
227
223
|
/* @__PURE__ */ jsx(
|
|
@@ -522,11 +518,11 @@ function ZoomMenu(props) {
|
|
|
522
518
|
anchorRef: triggerRef,
|
|
523
519
|
placement: "rightTop",
|
|
524
520
|
offset: 2,
|
|
525
|
-
minWidth:
|
|
521
|
+
minWidth: 280,
|
|
526
522
|
onOpenChange: setOpen,
|
|
527
523
|
surfaceStyle: {
|
|
528
524
|
...CONTEXT_MENU_SURFACE_STYLE,
|
|
529
|
-
width:
|
|
525
|
+
width: 280
|
|
530
526
|
},
|
|
531
527
|
children: /* @__PURE__ */ jsxs(
|
|
532
528
|
"div",
|
|
@@ -555,45 +551,58 @@ function ZoomMenu(props) {
|
|
|
555
551
|
children: "\u8868\u683C\u7F29\u653E\uFF0850% - 200%\uFF09"
|
|
556
552
|
}
|
|
557
553
|
),
|
|
558
|
-
/* @__PURE__ */
|
|
559
|
-
|
|
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",
|
|
554
|
+
/* @__PURE__ */ jsxs(
|
|
555
|
+
"div",
|
|
577
556
|
{
|
|
578
|
-
type: "button",
|
|
579
|
-
disabled: percent === 100,
|
|
580
|
-
onClick: () => {
|
|
581
|
-
onChange(1);
|
|
582
|
-
},
|
|
583
|
-
className: "react-list-table-menu-action",
|
|
584
557
|
style: {
|
|
585
|
-
display: "
|
|
586
|
-
|
|
587
|
-
|
|
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"
|
|
558
|
+
display: "flex",
|
|
559
|
+
alignItems: "stretch",
|
|
560
|
+
gap: 6,
|
|
561
|
+
padding: "0 8px 4px"
|
|
595
562
|
},
|
|
596
|
-
children:
|
|
563
|
+
children: [
|
|
564
|
+
/* @__PURE__ */ jsx(
|
|
565
|
+
ReactInputNumber,
|
|
566
|
+
{
|
|
567
|
+
value: percent,
|
|
568
|
+
min: CONTEXT_MENU_ZOOM_MIN,
|
|
569
|
+
max: CONTEXT_MENU_ZOOM_MAX,
|
|
570
|
+
step: CONTEXT_MENU_ZOOM_STEP,
|
|
571
|
+
precision: 0,
|
|
572
|
+
addonAfter: "%",
|
|
573
|
+
style: { flex: "1 1 auto", minWidth: 0 },
|
|
574
|
+
onChange: (next) => {
|
|
575
|
+
if (next == null || !Number.isFinite(next)) {
|
|
576
|
+
return;
|
|
577
|
+
}
|
|
578
|
+
onChange(Math.round(next) / 100);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
),
|
|
582
|
+
/* @__PURE__ */ jsx(
|
|
583
|
+
"button",
|
|
584
|
+
{
|
|
585
|
+
type: "button",
|
|
586
|
+
disabled: percent === 100,
|
|
587
|
+
onClick: () => {
|
|
588
|
+
onChange(1);
|
|
589
|
+
},
|
|
590
|
+
className: "react-list-table-menu-action",
|
|
591
|
+
style: {
|
|
592
|
+
flex: "0 0 52px",
|
|
593
|
+
height: 32,
|
|
594
|
+
padding: 0,
|
|
595
|
+
border: "1px solid #d1d5db",
|
|
596
|
+
borderRadius: 6,
|
|
597
|
+
background: "#ffffff",
|
|
598
|
+
color: percent === 100 ? "#9ca3af" : "#374151",
|
|
599
|
+
textAlign: "center",
|
|
600
|
+
cursor: percent === 100 ? "not-allowed" : "pointer"
|
|
601
|
+
},
|
|
602
|
+
children: "\u91CD\u7F6E"
|
|
603
|
+
}
|
|
604
|
+
)
|
|
605
|
+
]
|
|
597
606
|
}
|
|
598
607
|
)
|
|
599
608
|
]
|
|
@@ -1059,6 +1068,129 @@ function SummaryMenu(props) {
|
|
|
1059
1068
|
}
|
|
1060
1069
|
);
|
|
1061
1070
|
}
|
|
1071
|
+
function AlignmentMenu(props) {
|
|
1072
|
+
const { request } = props;
|
|
1073
|
+
if (!request.alignment || !request.onChangeAlignment) {
|
|
1074
|
+
return null;
|
|
1075
|
+
}
|
|
1076
|
+
return /* @__PURE__ */ jsx(
|
|
1077
|
+
MenuSubmenu,
|
|
1078
|
+
{
|
|
1079
|
+
label: "\u5BF9\u9F50\u65B9\u5F0F",
|
|
1080
|
+
items: [],
|
|
1081
|
+
footer: /* @__PURE__ */ jsxs("div", { style: { display: "grid", gap: 10, padding: "4px 8px" }, children: [
|
|
1082
|
+
/* @__PURE__ */ jsx(
|
|
1083
|
+
AlignmentGroup,
|
|
1084
|
+
{
|
|
1085
|
+
label: "\u8868\u5934",
|
|
1086
|
+
horizontal: request.alignment.headerHorizontal,
|
|
1087
|
+
vertical: request.alignment.headerVertical,
|
|
1088
|
+
onHorizontalChange: (value) => request.onChangeAlignment?.("header", "horizontal", value),
|
|
1089
|
+
onVerticalChange: (value) => request.onChangeAlignment?.("header", "vertical", value)
|
|
1090
|
+
}
|
|
1091
|
+
),
|
|
1092
|
+
/* @__PURE__ */ jsx(
|
|
1093
|
+
AlignmentGroup,
|
|
1094
|
+
{
|
|
1095
|
+
label: "\u8868\u4F53",
|
|
1096
|
+
horizontal: request.alignment.bodyHorizontal,
|
|
1097
|
+
vertical: request.alignment.bodyVertical,
|
|
1098
|
+
onHorizontalChange: (value) => request.onChangeAlignment?.("body", "horizontal", value),
|
|
1099
|
+
onVerticalChange: (value) => request.onChangeAlignment?.("body", "vertical", value)
|
|
1100
|
+
}
|
|
1101
|
+
)
|
|
1102
|
+
] })
|
|
1103
|
+
}
|
|
1104
|
+
);
|
|
1105
|
+
}
|
|
1106
|
+
function AlignmentGroup(props) {
|
|
1107
|
+
return /* @__PURE__ */ jsxs("div", { style: { display: "grid", gap: 6 }, children: [
|
|
1108
|
+
/* @__PURE__ */ jsx("strong", { style: { color: "#374151", fontSize: 13 }, children: props.label }),
|
|
1109
|
+
/* @__PURE__ */ jsx(
|
|
1110
|
+
AlignmentSegment,
|
|
1111
|
+
{
|
|
1112
|
+
label: "\u6C34\u5E73",
|
|
1113
|
+
value: props.horizontal,
|
|
1114
|
+
options: [
|
|
1115
|
+
{ label: "\u5DE6", value: "left" },
|
|
1116
|
+
{ label: "\u4E2D", value: "center" },
|
|
1117
|
+
{ label: "\u53F3", value: "right" }
|
|
1118
|
+
],
|
|
1119
|
+
onChange: props.onHorizontalChange
|
|
1120
|
+
}
|
|
1121
|
+
),
|
|
1122
|
+
/* @__PURE__ */ jsx(
|
|
1123
|
+
AlignmentSegment,
|
|
1124
|
+
{
|
|
1125
|
+
label: "\u5782\u76F4",
|
|
1126
|
+
value: props.vertical,
|
|
1127
|
+
options: [
|
|
1128
|
+
{ label: "\u4E0A", value: "top" },
|
|
1129
|
+
{ label: "\u4E2D", value: "middle" },
|
|
1130
|
+
{ label: "\u4E0B", value: "bottom" }
|
|
1131
|
+
],
|
|
1132
|
+
onChange: props.onVerticalChange
|
|
1133
|
+
}
|
|
1134
|
+
)
|
|
1135
|
+
] });
|
|
1136
|
+
}
|
|
1137
|
+
function AlignmentSegment(props) {
|
|
1138
|
+
return /* @__PURE__ */ jsxs(
|
|
1139
|
+
"div",
|
|
1140
|
+
{
|
|
1141
|
+
style: {
|
|
1142
|
+
display: "grid",
|
|
1143
|
+
gridTemplateColumns: "40px repeat(3, 1fr)",
|
|
1144
|
+
gap: 4,
|
|
1145
|
+
alignItems: "center"
|
|
1146
|
+
},
|
|
1147
|
+
children: [
|
|
1148
|
+
/* @__PURE__ */ jsx("span", { style: { color: "#6b7280", fontSize: 12 }, children: props.label }),
|
|
1149
|
+
props.options.map((option) => /* @__PURE__ */ jsx(
|
|
1150
|
+
"button",
|
|
1151
|
+
{
|
|
1152
|
+
type: "button",
|
|
1153
|
+
className: "react-list-table-menu-action",
|
|
1154
|
+
style: {
|
|
1155
|
+
height: 28,
|
|
1156
|
+
border: "1px solid #d1d5db",
|
|
1157
|
+
borderRadius: 4,
|
|
1158
|
+
background: props.value === option.value ? "#e8f3ff" : "#ffffff",
|
|
1159
|
+
color: props.value === option.value ? "#1677ff" : "#374151",
|
|
1160
|
+
cursor: "pointer"
|
|
1161
|
+
},
|
|
1162
|
+
onClick: () => props.onChange(option.value),
|
|
1163
|
+
children: option.label
|
|
1164
|
+
},
|
|
1165
|
+
option.value
|
|
1166
|
+
))
|
|
1167
|
+
]
|
|
1168
|
+
}
|
|
1169
|
+
);
|
|
1170
|
+
}
|
|
1171
|
+
function DataFormatMenu(props) {
|
|
1172
|
+
const { request } = props;
|
|
1173
|
+
if (!request.onChangeDataFormat) {
|
|
1174
|
+
return null;
|
|
1175
|
+
}
|
|
1176
|
+
return /* @__PURE__ */ jsx(
|
|
1177
|
+
MenuSubmenu,
|
|
1178
|
+
{
|
|
1179
|
+
label: "\u6570\u636E\u683C\u5F0F",
|
|
1180
|
+
items: [
|
|
1181
|
+
{ key: "default", label: "\u9ED8\u8BA4", value: "default" },
|
|
1182
|
+
{ key: "number", label: "\u666E\u901A\u6570\u5B57", value: "number" },
|
|
1183
|
+
{ key: "thousands", label: "\u5343\u4F4D\u5206\u9694", value: "thousands" },
|
|
1184
|
+
{ key: "money", label: "\u91D1\u989D\uFF08\u4E24\u4F4D\u5C0F\u6570\uFF09", value: "money" }
|
|
1185
|
+
].map((item) => ({
|
|
1186
|
+
key: `data-format-${item.key}`,
|
|
1187
|
+
label: item.label,
|
|
1188
|
+
selected: request.dataFormat === item.value,
|
|
1189
|
+
onClick: () => request.onChangeDataFormat?.(item.value)
|
|
1190
|
+
}))
|
|
1191
|
+
}
|
|
1192
|
+
);
|
|
1193
|
+
}
|
|
1062
1194
|
|
|
1063
1195
|
// src/features/editor/utils.ts
|
|
1064
1196
|
function toNumberValue(value) {
|
|
@@ -2299,7 +2431,15 @@ function ReactTableToolbar(props) {
|
|
|
2299
2431
|
children: isFullscreen ? /* @__PURE__ */ jsx(FullscreenExitOutlined, {}) : /* @__PURE__ */ jsx(FullscreenOutlined, {})
|
|
2300
2432
|
}
|
|
2301
2433
|
) : null,
|
|
2302
|
-
config.showRefresh !== false ? /* @__PURE__ */ jsx(
|
|
2434
|
+
config.showRefresh !== false ? /* @__PURE__ */ jsx(
|
|
2435
|
+
ToolButton,
|
|
2436
|
+
{
|
|
2437
|
+
label: "\u5237\u65B0",
|
|
2438
|
+
iconSize: 14,
|
|
2439
|
+
onClick: () => config.onRefresh?.(),
|
|
2440
|
+
children: /* @__PURE__ */ jsx(ReloadOutlined, {})
|
|
2441
|
+
}
|
|
2442
|
+
) : null,
|
|
2303
2443
|
config.showExport ? /* @__PURE__ */ jsx(
|
|
2304
2444
|
ToolButton,
|
|
2305
2445
|
{
|
|
@@ -2309,14 +2449,21 @@ function ReactTableToolbar(props) {
|
|
|
2309
2449
|
if (config.onExport) {
|
|
2310
2450
|
config.onExport();
|
|
2311
2451
|
} else {
|
|
2312
|
-
props.onExport();
|
|
2452
|
+
props.onExport(config.exportOptions);
|
|
2313
2453
|
}
|
|
2314
2454
|
},
|
|
2315
2455
|
children: /* @__PURE__ */ jsx(ExportOutlined, {})
|
|
2316
2456
|
}
|
|
2317
2457
|
) : null,
|
|
2318
2458
|
config.showDensity !== false ? /* @__PURE__ */ jsxs("div", { className: "react-list-table-tool-wrap", children: [
|
|
2319
|
-
/* @__PURE__ */ jsx(
|
|
2459
|
+
/* @__PURE__ */ jsx(
|
|
2460
|
+
ToolButton,
|
|
2461
|
+
{
|
|
2462
|
+
label: "\u8868\u683C\u5BC6\u5EA6",
|
|
2463
|
+
onClick: () => setDensityOpen((v) => !v),
|
|
2464
|
+
children: /* @__PURE__ */ jsx(ColumnHeightOutlined, {})
|
|
2465
|
+
}
|
|
2466
|
+
),
|
|
2320
2467
|
densityOpen ? /* @__PURE__ */ jsx("div", { className: "react-list-table-tool-menu", children: [48, 40, 32].map((height) => /* @__PURE__ */ jsx(
|
|
2321
2468
|
"button",
|
|
2322
2469
|
{
|
|
@@ -2332,7 +2479,14 @@ function ReactTableToolbar(props) {
|
|
|
2332
2479
|
)) }) : null
|
|
2333
2480
|
] }) : null,
|
|
2334
2481
|
config.showColumnSetting !== false ? /* @__PURE__ */ jsxs("div", { className: "react-list-table-tool-wrap", children: [
|
|
2335
|
-
/* @__PURE__ */ jsx(
|
|
2482
|
+
/* @__PURE__ */ jsx(
|
|
2483
|
+
ToolButton,
|
|
2484
|
+
{
|
|
2485
|
+
label: "\u5217\u8BBE\u7F6E",
|
|
2486
|
+
onClick: () => setSettingOpen((v) => !v),
|
|
2487
|
+
children: /* @__PURE__ */ jsx(SettingOutlined, {})
|
|
2488
|
+
}
|
|
2489
|
+
),
|
|
2336
2490
|
settingOpen ? /* @__PURE__ */ jsxs(
|
|
2337
2491
|
"div",
|
|
2338
2492
|
{
|
|
@@ -2341,6 +2495,7 @@ function ReactTableToolbar(props) {
|
|
|
2341
2495
|
children: [
|
|
2342
2496
|
/* @__PURE__ */ jsxs("div", { className: "react-list-table-column-setting-head", children: [
|
|
2343
2497
|
/* @__PURE__ */ jsx("strong", { children: "\u5217\u8BBE\u7F6E" }),
|
|
2498
|
+
/* @__PURE__ */ jsx("span", { style: { marginLeft: "auto" }, children: config.columnSettingHeaderExtra }),
|
|
2344
2499
|
/* @__PURE__ */ jsx("button", { type: "button", onClick: props.onResetColumns, children: "\u91CD\u7F6E" })
|
|
2345
2500
|
] }),
|
|
2346
2501
|
/* @__PURE__ */ jsx("div", { className: "react-list-table-column-setting-body", children: /* @__PURE__ */ jsx(
|
|
@@ -2372,6 +2527,7 @@ function ReactTableToolbar(props) {
|
|
|
2372
2527
|
{
|
|
2373
2528
|
type: "checkbox",
|
|
2374
2529
|
checked: !column.hidden,
|
|
2530
|
+
disabled: column.disableHide,
|
|
2375
2531
|
onChange: (event) => props.onColumnVisibilityChange(
|
|
2376
2532
|
column.key,
|
|
2377
2533
|
event.target.checked
|
|
@@ -2395,7 +2551,10 @@ function ReactTableToolbar(props) {
|
|
|
2395
2551
|
style: { width: 80, height: 24 },
|
|
2396
2552
|
onChange: (width) => {
|
|
2397
2553
|
if (width != null && Number.isFinite(width) && width > 0 && (column.minWidth == null || width >= column.minWidth) && (column.maxWidth == null || width <= column.maxWidth)) {
|
|
2398
|
-
props.onColumnWidthChange(
|
|
2554
|
+
props.onColumnWidthChange(
|
|
2555
|
+
column.key,
|
|
2556
|
+
width
|
|
2557
|
+
);
|
|
2399
2558
|
}
|
|
2400
2559
|
}
|
|
2401
2560
|
}
|
|
@@ -2434,12 +2593,26 @@ function ReactTableToolbar(props) {
|
|
|
2434
2593
|
] });
|
|
2435
2594
|
}
|
|
2436
2595
|
function ToolButton(props) {
|
|
2437
|
-
return /* @__PURE__ */ jsx(
|
|
2596
|
+
return /* @__PURE__ */ jsx(
|
|
2597
|
+
"button",
|
|
2598
|
+
{
|
|
2599
|
+
type: "button",
|
|
2600
|
+
className: "react-list-table-tool",
|
|
2601
|
+
style: { fontSize: props.iconSize ?? 16 },
|
|
2602
|
+
title: props.label,
|
|
2603
|
+
"aria-label": props.label,
|
|
2604
|
+
onClick: props.onClick,
|
|
2605
|
+
children: props.children
|
|
2606
|
+
}
|
|
2607
|
+
);
|
|
2438
2608
|
}
|
|
2439
2609
|
function flattenColumns(columns, parentKey = "root", level = 0) {
|
|
2440
2610
|
return columns.flatMap((column) => {
|
|
2611
|
+
if (column.hideInSetting) {
|
|
2612
|
+
return [];
|
|
2613
|
+
}
|
|
2441
2614
|
const key = String(column.key ?? column.dataIndex);
|
|
2442
|
-
const label = typeof column.title === "string" ? column.title : key;
|
|
2615
|
+
const label = column.settingTitle ?? (typeof column.title === "string" ? column.title : key);
|
|
2443
2616
|
const current = {
|
|
2444
2617
|
key,
|
|
2445
2618
|
label,
|
|
@@ -2450,7 +2623,8 @@ function flattenColumns(columns, parentKey = "root", level = 0) {
|
|
|
2450
2623
|
maxWidth: typeof column.maxWidth === "number" ? column.maxWidth : void 0,
|
|
2451
2624
|
fixed: column.fixed,
|
|
2452
2625
|
level,
|
|
2453
|
-
isGroup: Boolean(column.children?.length)
|
|
2626
|
+
isGroup: Boolean(column.children?.length),
|
|
2627
|
+
disableHide: column.disableHide === true
|
|
2454
2628
|
};
|
|
2455
2629
|
return column.children?.length ? [current, ...flattenColumns(column.children, key, level + 1)] : [current];
|
|
2456
2630
|
});
|
|
@@ -2596,6 +2770,7 @@ function ReactListTableInner(props, ref) {
|
|
|
2596
2770
|
rowKey,
|
|
2597
2771
|
columns,
|
|
2598
2772
|
dataSource,
|
|
2773
|
+
onRow,
|
|
2599
2774
|
theme,
|
|
2600
2775
|
striped,
|
|
2601
2776
|
highlightMode,
|
|
@@ -2650,6 +2825,7 @@ function ReactListTableInner(props, ref) {
|
|
|
2650
2825
|
rowKey,
|
|
2651
2826
|
columns: resolvedColumns,
|
|
2652
2827
|
dataSource,
|
|
2828
|
+
onRow,
|
|
2653
2829
|
theme,
|
|
2654
2830
|
striped,
|
|
2655
2831
|
highlightMode,
|
|
@@ -2682,6 +2858,7 @@ function ReactListTableInner(props, ref) {
|
|
|
2682
2858
|
rowKey,
|
|
2683
2859
|
resolvedColumns,
|
|
2684
2860
|
dataSource,
|
|
2861
|
+
onRow,
|
|
2685
2862
|
theme,
|
|
2686
2863
|
striped,
|
|
2687
2864
|
highlightMode,
|
|
@@ -2724,8 +2901,8 @@ function ReactListTableInner(props, ref) {
|
|
|
2724
2901
|
ref,
|
|
2725
2902
|
() => ({
|
|
2726
2903
|
validate: () => tableRef.current?.validate() ?? Promise.resolve([]),
|
|
2727
|
-
exportXlsx: () => {
|
|
2728
|
-
tableRef.current?.exportXlsx();
|
|
2904
|
+
exportXlsx: (options2) => {
|
|
2905
|
+
tableRef.current?.exportXlsx(options2);
|
|
2729
2906
|
},
|
|
2730
2907
|
scrollTo: (options2) => {
|
|
2731
2908
|
tableRef.current?.scrollTo(options2);
|
|
@@ -2762,8 +2939,13 @@ function ReactListTableInner(props, ref) {
|
|
|
2762
2939
|
columns: resolvedColumns,
|
|
2763
2940
|
density: resolvedRowHeight === "auto" ? 40 : resolvedRowHeight ?? 40,
|
|
2764
2941
|
hostRef: shellRef,
|
|
2765
|
-
onExport: () => tableRef.current?.exportXlsx(),
|
|
2766
|
-
onDensityChange:
|
|
2942
|
+
onExport: (options2) => tableRef.current?.exportXlsx(options2),
|
|
2943
|
+
onDensityChange: (density) => {
|
|
2944
|
+
setDensityOverride(density);
|
|
2945
|
+
if (toolbar) {
|
|
2946
|
+
toolbar.onDensityChange?.(density);
|
|
2947
|
+
}
|
|
2948
|
+
},
|
|
2767
2949
|
onColumnVisibilityChange: (columnKey, visible) => {
|
|
2768
2950
|
setColumnVisibility((current) => {
|
|
2769
2951
|
const next = new Map(current);
|
|
@@ -2880,15 +3062,13 @@ function ReactListTableInner(props, ref) {
|
|
|
2880
3062
|
}
|
|
2881
3063
|
function applyColumnManagerState(columns, visibility, orders, config, parentKey = "root") {
|
|
2882
3064
|
const order = orders.get(parentKey);
|
|
2883
|
-
const sortedColumns = order ?
|
|
2884
|
-
(left, right) => order.indexOf(resolveColumnKey(left)) - order.indexOf(resolveColumnKey(right))
|
|
2885
|
-
) : columns;
|
|
3065
|
+
const sortedColumns = order ? applyManagedColumnOrder(columns, order) : columns;
|
|
2886
3066
|
return sortedColumns.map((column) => {
|
|
2887
3067
|
const key = resolveColumnKey(column);
|
|
2888
3068
|
const managedConfig = config.get(key);
|
|
2889
3069
|
return {
|
|
2890
3070
|
...column,
|
|
2891
|
-
hidden: visibility.has(key) ? visibility.get(key) === false : column.hidden,
|
|
3071
|
+
hidden: visibility.has(key) ? visibility.get(key) === false : column.hidden ?? column.initialHide,
|
|
2892
3072
|
width: managedConfig?.width ?? column.width,
|
|
2893
3073
|
minWidth: column.minWidth,
|
|
2894
3074
|
maxWidth: column.maxWidth,
|
|
@@ -2903,6 +3083,24 @@ function applyColumnManagerState(columns, visibility, orders, config, parentKey
|
|
|
2903
3083
|
};
|
|
2904
3084
|
});
|
|
2905
3085
|
}
|
|
3086
|
+
function applyManagedColumnOrder(columns, orderedKeys) {
|
|
3087
|
+
const managedKeySet = new Set(orderedKeys);
|
|
3088
|
+
const managedSlots = columns.map(
|
|
3089
|
+
(column, index) => managedKeySet.has(resolveColumnKey(column)) ? index : -1
|
|
3090
|
+
).filter((index) => index >= 0);
|
|
3091
|
+
const columnByKey = new Map(
|
|
3092
|
+
columns.map((column) => [resolveColumnKey(column), column])
|
|
3093
|
+
);
|
|
3094
|
+
const next = [...columns];
|
|
3095
|
+
orderedKeys.forEach((key, index) => {
|
|
3096
|
+
const slot = managedSlots[index];
|
|
3097
|
+
const column = columnByKey.get(key);
|
|
3098
|
+
if (slot != null && column) {
|
|
3099
|
+
next[slot] = column;
|
|
3100
|
+
}
|
|
3101
|
+
});
|
|
3102
|
+
return next;
|
|
3103
|
+
}
|
|
2906
3104
|
function resolveColumnKey(column) {
|
|
2907
3105
|
return String(column.key ?? column.dataIndex);
|
|
2908
3106
|
}
|