@expcat/tigercat-react 2.0.0-preview.4 → 2.0.0-preview.6
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/{chunk-AGTXDHQJ.mjs → chunk-2DCKVGQ3.mjs} +12 -6
- package/dist/{chunk-D4LASFVY.mjs → chunk-2HNUN6OM.mjs} +49 -68
- package/dist/chunk-OVE2ZUJJ.mjs +98 -0
- package/dist/{chunk-IPJLQSAF.mjs → chunk-RM2LACNK.mjs} +1 -1
- package/dist/{chunk-Z47SG5L5.mjs → chunk-U3TW75H3.mjs} +65 -86
- package/dist/{chunk-532RNNPH.mjs → chunk-VDI4T62S.mjs} +1 -1
- package/dist/components/DataExport.d.mts +17 -0
- package/dist/components/DataExport.mjs +10 -0
- package/dist/components/DataTableWithToolbar.mjs +4 -3
- package/dist/components/List.mjs +2 -1
- package/dist/components/NotificationCenter.mjs +3 -2
- package/dist/components/Pagination.mjs +1 -1
- package/dist/components/Table.mjs +2 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.mjs +7 -0
- package/package.json +7 -2
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
resolveTigerLocale,
|
|
32
32
|
mergeTigerLocale
|
|
33
33
|
} from "@expcat/tigercat-core";
|
|
34
|
-
import { jsx
|
|
34
|
+
import { jsx } from "react/jsx-runtime";
|
|
35
35
|
var Pagination = ({
|
|
36
36
|
current: controlledCurrent,
|
|
37
37
|
defaultCurrent = 1,
|
|
@@ -44,6 +44,7 @@ var Pagination = ({
|
|
|
44
44
|
showTotal = true,
|
|
45
45
|
totalText,
|
|
46
46
|
simple = false,
|
|
47
|
+
pageIndicatorText,
|
|
47
48
|
size = "medium",
|
|
48
49
|
align = "center",
|
|
49
50
|
disabled = false,
|
|
@@ -210,12 +211,17 @@ var Pagination = ({
|
|
|
210
211
|
)
|
|
211
212
|
);
|
|
212
213
|
if (simple) {
|
|
214
|
+
const indicatorText = pageIndicatorText ? pageIndicatorText(validatedCurrentPage, totalPages) : `${validatedCurrentPage} / ${totalPages}`;
|
|
213
215
|
elements.push(
|
|
214
|
-
/* @__PURE__ */
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
216
|
+
/* @__PURE__ */ jsx(
|
|
217
|
+
"span",
|
|
218
|
+
{
|
|
219
|
+
className: classNames("mx-2", getSizeTextClasses(size)),
|
|
220
|
+
"aria-label": indicatorText,
|
|
221
|
+
children: indicatorText
|
|
222
|
+
},
|
|
223
|
+
"current"
|
|
224
|
+
)
|
|
219
225
|
);
|
|
220
226
|
} else {
|
|
221
227
|
getPageNumbers(validatedCurrentPage, totalPages, showLessItems).forEach((pageNum, index) => {
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Pagination
|
|
3
|
+
} from "./chunk-2DCKVGQ3.mjs";
|
|
1
4
|
import {
|
|
2
5
|
VirtualList
|
|
3
6
|
} from "./chunk-Y5X3G2LD.mjs";
|
|
@@ -30,13 +33,8 @@ import {
|
|
|
30
33
|
listGridContainerClasses,
|
|
31
34
|
getSpinnerSVG,
|
|
32
35
|
getLoadingOverlaySpinnerClasses,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
getSimplePaginationControlsClasses,
|
|
36
|
-
getSimplePaginationSelectClasses,
|
|
37
|
-
getSimplePaginationButtonClasses,
|
|
38
|
-
getSimplePaginationPageIndicatorClasses,
|
|
39
|
-
getSimplePaginationButtonsWrapperClasses,
|
|
36
|
+
getBuiltInPaginationContainerClasses,
|
|
37
|
+
resolvePaginationDisplayMode,
|
|
40
38
|
getPaginationLabels,
|
|
41
39
|
formatPaginationTotal,
|
|
42
40
|
formatPaginationPageIndicator
|
|
@@ -89,26 +87,31 @@ var List = ({
|
|
|
89
87
|
() => mergeTigerLocale(config.locale, locale),
|
|
90
88
|
[config.locale, locale]
|
|
91
89
|
);
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
);
|
|
90
|
+
const paginationCfg = pagination !== false && typeof pagination === "object" ? pagination : null;
|
|
91
|
+
const isRemotePagination = paginationCfg?.remote === true;
|
|
92
|
+
const [internalCurrentPage, setInternalCurrentPage] = useState(paginationCfg?.current || 1);
|
|
95
93
|
const dragIndexRef = React.useRef(null);
|
|
96
|
-
const [
|
|
97
|
-
|
|
94
|
+
const [internalCurrentPageSize, setInternalCurrentPageSize] = useState(
|
|
95
|
+
paginationCfg?.pageSize || 10
|
|
98
96
|
);
|
|
97
|
+
const currentPage = isRemotePagination ? paginationCfg?.current ?? internalCurrentPage : internalCurrentPage;
|
|
98
|
+
const currentPageSize = isRemotePagination ? paginationCfg?.pageSize ?? internalCurrentPageSize : internalCurrentPageSize;
|
|
99
99
|
const paginatedData = useMemo(() => {
|
|
100
100
|
if (pagination === false) {
|
|
101
101
|
return dataSource;
|
|
102
102
|
}
|
|
103
|
+
if (isRemotePagination) {
|
|
104
|
+
return dataSource;
|
|
105
|
+
}
|
|
103
106
|
return paginateData(dataSource, currentPage, currentPageSize);
|
|
104
|
-
}, [dataSource, currentPage, currentPageSize, pagination]);
|
|
107
|
+
}, [dataSource, currentPage, currentPageSize, pagination, isRemotePagination]);
|
|
108
|
+
const paginationTotal = isRemotePagination ? paginationCfg?.total ?? dataSource.length : dataSource.length;
|
|
105
109
|
const paginationInfo = useMemo(() => {
|
|
106
110
|
if (pagination === false) {
|
|
107
111
|
return null;
|
|
108
112
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}, [dataSource.length, currentPage, currentPageSize, pagination]);
|
|
113
|
+
return calculatePagination(paginationTotal, currentPage, currentPageSize);
|
|
114
|
+
}, [paginationTotal, currentPage, currentPageSize, pagination]);
|
|
112
115
|
const listClasses = useMemo(() => {
|
|
113
116
|
return classNames(getListClasses(bordered), listSizeClasses[size], className);
|
|
114
117
|
}, [bordered, size, className]);
|
|
@@ -120,12 +123,12 @@ var List = ({
|
|
|
120
123
|
);
|
|
121
124
|
}, [grid]);
|
|
122
125
|
const handlePageChange = (page) => {
|
|
123
|
-
|
|
126
|
+
setInternalCurrentPage(page);
|
|
124
127
|
onPageChange?.({ current: page, pageSize: currentPageSize });
|
|
125
128
|
};
|
|
126
129
|
const handlePageSizeChange = (pageSize) => {
|
|
127
|
-
|
|
128
|
-
|
|
130
|
+
setInternalCurrentPageSize(pageSize);
|
|
131
|
+
setInternalCurrentPage(1);
|
|
129
132
|
onPageChange?.({ current: 1, pageSize });
|
|
130
133
|
};
|
|
131
134
|
const handleItemClick = (item, index) => {
|
|
@@ -278,60 +281,38 @@ var List = ({
|
|
|
278
281
|
if (pagination === false || !paginationInfo) {
|
|
279
282
|
return null;
|
|
280
283
|
}
|
|
281
|
-
const { totalPages
|
|
282
|
-
const total =
|
|
284
|
+
const { totalPages } = paginationInfo;
|
|
285
|
+
const total = paginationTotal;
|
|
283
286
|
const paginationConfig = pagination;
|
|
284
287
|
const paginationLabels = getPaginationLabels(mergedLocale);
|
|
285
288
|
const localeCode = mergedLocale?.locale;
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
+
const { simple, showQuickJumper } = resolvePaginationDisplayMode(totalPages, paginationConfig);
|
|
290
|
+
const totalText = paginationConfig.totalText ?? ((value, range) => formatPaginationTotal(paginationLabels.totalText, value, range, localeCode));
|
|
291
|
+
const pageIndicatorText = (current, pages) => formatPaginationPageIndicator(paginationLabels.pageIndicatorText, current, pages, localeCode);
|
|
292
|
+
return /* @__PURE__ */ jsx("div", { className: getBuiltInPaginationContainerClasses(), children: /* @__PURE__ */ jsx(
|
|
293
|
+
Pagination,
|
|
294
|
+
{
|
|
295
|
+
size: "small",
|
|
296
|
+
align: "right",
|
|
297
|
+
current: currentPage,
|
|
298
|
+
pageSize: currentPageSize,
|
|
289
299
|
total,
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
size2,
|
|
302
|
-
" ",
|
|
303
|
-
paginationLabels.itemsPerPageText
|
|
304
|
-
] }, size2))
|
|
300
|
+
simple,
|
|
301
|
+
showQuickJumper,
|
|
302
|
+
showSizeChanger: paginationConfig.showSizeChanger !== false,
|
|
303
|
+
showTotal: paginationConfig.showTotal !== false,
|
|
304
|
+
totalText,
|
|
305
|
+
pageIndicatorText,
|
|
306
|
+
pageSizeOptions: paginationConfig.pageSizeOptions || [10, 20, 50, 100],
|
|
307
|
+
locale: mergedLocale,
|
|
308
|
+
onChange: (page, pageSize) => {
|
|
309
|
+
if (pageSize === currentPageSize) {
|
|
310
|
+
handlePageChange(page);
|
|
305
311
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
{
|
|
311
|
-
className: getSimplePaginationButtonClasses(!hasPrev),
|
|
312
|
-
disabled: !hasPrev,
|
|
313
|
-
onClick: () => handlePageChange(currentPage - 1),
|
|
314
|
-
children: paginationLabels.prevPageAriaLabel
|
|
315
|
-
}
|
|
316
|
-
),
|
|
317
|
-
/* @__PURE__ */ jsx("span", { className: getSimplePaginationPageIndicatorClasses(), children: formatPaginationPageIndicator(
|
|
318
|
-
paginationLabels.pageIndicatorText,
|
|
319
|
-
currentPage,
|
|
320
|
-
totalPages,
|
|
321
|
-
localeCode
|
|
322
|
-
) }),
|
|
323
|
-
/* @__PURE__ */ jsx(
|
|
324
|
-
"button",
|
|
325
|
-
{
|
|
326
|
-
className: getSimplePaginationButtonClasses(!hasNext),
|
|
327
|
-
disabled: !hasNext,
|
|
328
|
-
onClick: () => handlePageChange(currentPage + 1),
|
|
329
|
-
children: paginationLabels.nextPageAriaLabel
|
|
330
|
-
}
|
|
331
|
-
)
|
|
332
|
-
] })
|
|
333
|
-
] })
|
|
334
|
-
] });
|
|
312
|
+
},
|
|
313
|
+
onPageSizeChange: (_page, pageSize) => handlePageSizeChange(pageSize)
|
|
314
|
+
}
|
|
315
|
+
) });
|
|
335
316
|
};
|
|
336
317
|
return /* @__PURE__ */ jsxs("div", { className: listWrapperClasses, children: [
|
|
337
318
|
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Dropdown,
|
|
3
|
+
DropdownItem,
|
|
4
|
+
DropdownMenu
|
|
5
|
+
} from "./chunk-YI7NQWUV.mjs";
|
|
6
|
+
import {
|
|
7
|
+
useTigerConfig
|
|
8
|
+
} from "./chunk-YSIXURBW.mjs";
|
|
9
|
+
|
|
10
|
+
// src/components/DataExport.tsx
|
|
11
|
+
import { useCallback, useMemo, useState } from "react";
|
|
12
|
+
import {
|
|
13
|
+
classNames,
|
|
14
|
+
getDataExportLabels,
|
|
15
|
+
mergeTigerLocale,
|
|
16
|
+
tableExportButtonClasses
|
|
17
|
+
} from "@expcat/tigercat-core";
|
|
18
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
19
|
+
var dataExportModulePromise = null;
|
|
20
|
+
function loadDataExportModule() {
|
|
21
|
+
dataExportModulePromise ??= import("@expcat/tigercat-core/utils/data-export");
|
|
22
|
+
return dataExportModulePromise;
|
|
23
|
+
}
|
|
24
|
+
var DEFAULT_FORMATS = ["xlsx", "markdown"];
|
|
25
|
+
var DataExport = ({
|
|
26
|
+
columns,
|
|
27
|
+
dataSource,
|
|
28
|
+
formats = DEFAULT_FORMATS,
|
|
29
|
+
fileName = "export",
|
|
30
|
+
sheetName,
|
|
31
|
+
cellFormatter,
|
|
32
|
+
disabled = false,
|
|
33
|
+
locale,
|
|
34
|
+
labels,
|
|
35
|
+
className,
|
|
36
|
+
onExport,
|
|
37
|
+
onError
|
|
38
|
+
}) => {
|
|
39
|
+
const config = useTigerConfig();
|
|
40
|
+
const mergedLocale = useMemo(
|
|
41
|
+
() => mergeTigerLocale(config.locale, locale),
|
|
42
|
+
[config.locale, locale]
|
|
43
|
+
);
|
|
44
|
+
const resolvedLabels = useMemo(
|
|
45
|
+
() => getDataExportLabels(mergedLocale, labels),
|
|
46
|
+
[mergedLocale, labels]
|
|
47
|
+
);
|
|
48
|
+
const [exporting, setExporting] = useState(false);
|
|
49
|
+
const handleExport = useCallback(
|
|
50
|
+
async (format) => {
|
|
51
|
+
if (disabled || exporting) return;
|
|
52
|
+
setExporting(true);
|
|
53
|
+
try {
|
|
54
|
+
const mod = await loadDataExportModule();
|
|
55
|
+
const content = mod.exportData(columns, dataSource, format, { sheetName, cellFormatter });
|
|
56
|
+
mod.downloadDataExport(content, fileName, format);
|
|
57
|
+
onExport?.(format);
|
|
58
|
+
} catch (error) {
|
|
59
|
+
onError?.(error);
|
|
60
|
+
} finally {
|
|
61
|
+
setExporting(false);
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
[columns, dataSource, sheetName, cellFormatter, fileName, disabled, exporting, onExport, onError]
|
|
65
|
+
);
|
|
66
|
+
const formatLabel = (format) => format === "xlsx" ? resolvedLabels.xlsxText : resolvedLabels.markdownText;
|
|
67
|
+
if (formats.length === 0) return null;
|
|
68
|
+
if (formats.length === 1) {
|
|
69
|
+
return /* @__PURE__ */ jsx(
|
|
70
|
+
"button",
|
|
71
|
+
{
|
|
72
|
+
type: "button",
|
|
73
|
+
className: classNames(tableExportButtonClasses, className),
|
|
74
|
+
"aria-label": resolvedLabels.triggerAriaLabel,
|
|
75
|
+
disabled: disabled || exporting,
|
|
76
|
+
onClick: () => void handleExport(formats[0]),
|
|
77
|
+
children: exporting ? resolvedLabels.exportingText : formatLabel(formats[0])
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
return /* @__PURE__ */ jsxs(Dropdown, { trigger: "click", disabled: disabled || exporting, className, children: [
|
|
82
|
+
/* @__PURE__ */ jsx(
|
|
83
|
+
"button",
|
|
84
|
+
{
|
|
85
|
+
type: "button",
|
|
86
|
+
className: tableExportButtonClasses,
|
|
87
|
+
"aria-label": resolvedLabels.triggerAriaLabel,
|
|
88
|
+
disabled: disabled || exporting,
|
|
89
|
+
children: exporting ? resolvedLabels.exportingText : resolvedLabels.triggerText
|
|
90
|
+
}
|
|
91
|
+
),
|
|
92
|
+
/* @__PURE__ */ jsx(DropdownMenu, { children: formats.map((format) => /* @__PURE__ */ jsx(DropdownItem, { onClick: () => void handleExport(format), children: formatLabel(format) }, format)) })
|
|
93
|
+
] });
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export {
|
|
97
|
+
DataExport
|
|
98
|
+
};
|
|
@@ -4,6 +4,9 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
Radio
|
|
6
6
|
} from "./chunk-IIWUQK2P.mjs";
|
|
7
|
+
import {
|
|
8
|
+
Pagination
|
|
9
|
+
} from "./chunk-2DCKVGQ3.mjs";
|
|
7
10
|
import {
|
|
8
11
|
Empty
|
|
9
12
|
} from "./chunk-W7BC4I2Y.mjs";
|
|
@@ -297,8 +300,11 @@ function useTableState(input) {
|
|
|
297
300
|
if (pagination === false) {
|
|
298
301
|
return processedData;
|
|
299
302
|
}
|
|
303
|
+
if (paginationConfig?.remote) {
|
|
304
|
+
return processedData;
|
|
305
|
+
}
|
|
300
306
|
return paginateData(processedData, currentPage, currentPageSize);
|
|
301
|
-
}, [processedData, currentPage, currentPageSize, pagination]);
|
|
307
|
+
}, [processedData, currentPage, currentPageSize, pagination, paginationConfig?.remote]);
|
|
302
308
|
const pageRowKeys = useMemo(
|
|
303
309
|
() => createTableRowKeyCache(rowKey).getMany(paginatedData),
|
|
304
310
|
[paginatedData, rowKey]
|
|
@@ -937,100 +943,73 @@ function renderSummaryRow(ctx, view) {
|
|
|
937
943
|
|
|
938
944
|
// src/components/Table/render-pagination.tsx
|
|
939
945
|
import {
|
|
940
|
-
formatIntlNumber,
|
|
941
|
-
formatPaginationTotal,
|
|
942
946
|
formatPaginationPageIndicator,
|
|
947
|
+
formatPaginationTotal,
|
|
948
|
+
getBuiltInPaginationContainerClasses,
|
|
943
949
|
getPaginationLabels,
|
|
944
|
-
|
|
945
|
-
getSimplePaginationTotalClasses,
|
|
946
|
-
getSimplePaginationControlsClasses,
|
|
947
|
-
getSimplePaginationSelectClasses,
|
|
948
|
-
getSimplePaginationButtonClasses,
|
|
949
|
-
getSimplePaginationPageIndicatorClasses,
|
|
950
|
-
getSimplePaginationButtonsWrapperClasses
|
|
950
|
+
resolvePaginationDisplayMode
|
|
951
951
|
} from "@expcat/tigercat-core";
|
|
952
|
-
import { jsx as jsx5
|
|
952
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
953
953
|
function renderPagination(ctx, view) {
|
|
954
954
|
const { pagination } = view;
|
|
955
955
|
if (pagination === false || !ctx.paginationInfo) {
|
|
956
956
|
return null;
|
|
957
957
|
}
|
|
958
|
-
const { totalPages
|
|
958
|
+
const { totalPages } = ctx.paginationInfo;
|
|
959
959
|
const paginationConfig = pagination;
|
|
960
960
|
const total = paginationConfig.total !== void 0 && paginationConfig.total > 0 ? paginationConfig.total : ctx.processedData.length;
|
|
961
961
|
const locale = view.disableI18n ? void 0 : view.locale;
|
|
962
962
|
const labels = getPaginationLabels(locale);
|
|
963
963
|
const localeCode = locale?.locale;
|
|
964
|
-
const
|
|
965
|
-
const
|
|
966
|
-
const
|
|
967
|
-
const
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
);
|
|
973
|
-
const finalPrevAriaLabel = view.disableI18n ? finalPrevText : labels.prevPageAriaLabel;
|
|
974
|
-
const finalNextAriaLabel = view.disableI18n ? finalNextText : labels.nextPageAriaLabel;
|
|
975
|
-
const normalizedPageSizeOptions = paginationConfig.pageSizeOptions || [
|
|
964
|
+
const { simple, showQuickJumper } = resolvePaginationDisplayMode(totalPages, paginationConfig);
|
|
965
|
+
const totalText = paginationConfig.totalText ?? ((value, range) => formatPaginationTotal(labels.totalText, value, range, localeCode));
|
|
966
|
+
const pageIndicatorText = paginationConfig.pageIndicatorText ?? ((current, pages) => formatPaginationPageIndicator(labels.pageIndicatorText, current, pages, localeCode));
|
|
967
|
+
const overrides = view.disableI18n ? { ...labels } : {};
|
|
968
|
+
if (paginationConfig.prevText) overrides.prevPageAriaLabel = paginationConfig.prevText;
|
|
969
|
+
if (paginationConfig.nextText) overrides.nextPageAriaLabel = paginationConfig.nextText;
|
|
970
|
+
const labelsOverride = Object.keys(overrides).length > 0 ? overrides : void 0;
|
|
971
|
+
const pageSizeOptions = paginationConfig.pageSizeOptions ?? [
|
|
976
972
|
10,
|
|
977
973
|
20,
|
|
978
974
|
50,
|
|
979
975
|
100
|
|
980
976
|
];
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
977
|
+
const pageSizeText = paginationConfig.pageSizeText;
|
|
978
|
+
const normalizedPageSizeOptions = pageSizeText ? pageSizeOptions.map((option) => {
|
|
979
|
+
if (typeof option === "number") {
|
|
980
|
+
return { value: option, label: pageSizeText(option) };
|
|
981
|
+
}
|
|
982
|
+
return { value: option.value, label: option.label ?? pageSizeText(option.value) };
|
|
983
|
+
}) : pageSizeOptions;
|
|
984
|
+
return /* @__PURE__ */ jsx5("div", { className: getBuiltInPaginationContainerClasses(), children: /* @__PURE__ */ jsx5(
|
|
985
|
+
Pagination,
|
|
986
|
+
{
|
|
987
|
+
size: "small",
|
|
988
|
+
align: "right",
|
|
989
|
+
current: ctx.currentPage,
|
|
990
|
+
pageSize: ctx.currentPageSize,
|
|
991
|
+
total,
|
|
992
|
+
simple,
|
|
993
|
+
showQuickJumper,
|
|
994
|
+
showSizeChanger: paginationConfig.showSizeChanger !== false,
|
|
995
|
+
showTotal: paginationConfig.showTotal !== false,
|
|
996
|
+
totalText,
|
|
997
|
+
pageIndicatorText,
|
|
998
|
+
pageSizeOptions: normalizedPageSizeOptions,
|
|
999
|
+
locale,
|
|
1000
|
+
labels: labelsOverride,
|
|
1001
|
+
onChange: (page, pageSize) => {
|
|
1002
|
+
if (pageSize === ctx.currentPageSize) {
|
|
1003
|
+
ctx.handlePageChange(page);
|
|
996
1004
|
}
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
{
|
|
1002
|
-
className: getSimplePaginationButtonClasses(!hasPrev),
|
|
1003
|
-
disabled: !hasPrev,
|
|
1004
|
-
"aria-label": finalPrevAriaLabel,
|
|
1005
|
-
onClick: () => ctx.handlePageChange(ctx.currentPage - 1),
|
|
1006
|
-
children: finalPrevText
|
|
1007
|
-
}
|
|
1008
|
-
),
|
|
1009
|
-
/* @__PURE__ */ jsx5(
|
|
1010
|
-
"span",
|
|
1011
|
-
{
|
|
1012
|
-
className: getSimplePaginationPageIndicatorClasses(),
|
|
1013
|
-
"aria-label": finalPageIndicatorText,
|
|
1014
|
-
children: finalPageIndicatorText
|
|
1015
|
-
}
|
|
1016
|
-
),
|
|
1017
|
-
/* @__PURE__ */ jsx5(
|
|
1018
|
-
"button",
|
|
1019
|
-
{
|
|
1020
|
-
className: getSimplePaginationButtonClasses(!hasNext),
|
|
1021
|
-
disabled: !hasNext,
|
|
1022
|
-
"aria-label": finalNextAriaLabel,
|
|
1023
|
-
onClick: () => ctx.handlePageChange(ctx.currentPage + 1),
|
|
1024
|
-
children: finalNextText
|
|
1025
|
-
}
|
|
1026
|
-
)
|
|
1027
|
-
] })
|
|
1028
|
-
] })
|
|
1029
|
-
] });
|
|
1005
|
+
},
|
|
1006
|
+
onPageSizeChange: (_page, pageSize) => ctx.handlePageSizeChange(pageSize)
|
|
1007
|
+
}
|
|
1008
|
+
) });
|
|
1030
1009
|
}
|
|
1031
1010
|
|
|
1032
1011
|
// src/components/Table.tsx
|
|
1033
|
-
import { Fragment, jsx as jsx6, jsxs as
|
|
1012
|
+
import { Fragment, jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1034
1013
|
function Table({
|
|
1035
1014
|
columns,
|
|
1036
1015
|
columnLockable = false,
|
|
@@ -1266,7 +1245,7 @@ function Table({
|
|
|
1266
1245
|
controller.observe(wrapper, tableRef.current);
|
|
1267
1246
|
return () => controller.disconnect();
|
|
1268
1247
|
}, [ctx.displayColumns.length, ctx.paginatedData.length]);
|
|
1269
|
-
return /* @__PURE__ */
|
|
1248
|
+
return /* @__PURE__ */ jsxs4(
|
|
1270
1249
|
"div",
|
|
1271
1250
|
{
|
|
1272
1251
|
ref: wrapperRef,
|
|
@@ -1292,7 +1271,7 @@ function Table({
|
|
|
1292
1271
|
children: exportFormat === "excel" ? tableLabels.exportExcelText : tableLabels.exportCsvText
|
|
1293
1272
|
}
|
|
1294
1273
|
) }),
|
|
1295
|
-
/* @__PURE__ */
|
|
1274
|
+
/* @__PURE__ */ jsxs4(
|
|
1296
1275
|
"table",
|
|
1297
1276
|
{
|
|
1298
1277
|
ref: tableRef,
|
|
@@ -1355,7 +1334,7 @@ function Table({
|
|
|
1355
1334
|
]
|
|
1356
1335
|
}
|
|
1357
1336
|
),
|
|
1358
|
-
responsiveMode === "card" && /* @__PURE__ */
|
|
1337
|
+
responsiveMode === "card" && /* @__PURE__ */ jsxs4(
|
|
1359
1338
|
"div",
|
|
1360
1339
|
{
|
|
1361
1340
|
className: getTableResponsiveCardListClasses(cardBreakpoint),
|
|
@@ -1421,7 +1400,7 @@ function Table({
|
|
|
1421
1400
|
};
|
|
1422
1401
|
const customCard = renderCard?.(renderContext);
|
|
1423
1402
|
const resolvedCardClassName = typeof cardClassName === "function" ? cardClassName(record, index) : cardClassName;
|
|
1424
|
-
const controlsNode = internalRowSelection?.showCheckbox !== false && internalRowSelection || internalExpandable && isRowExpandable ? /* @__PURE__ */
|
|
1403
|
+
const controlsNode = internalRowSelection?.showCheckbox !== false && internalRowSelection || internalExpandable && isRowExpandable ? /* @__PURE__ */ jsxs4(Fragment, { children: [
|
|
1425
1404
|
internalRowSelection && internalRowSelection.showCheckbox !== false && /* @__PURE__ */ jsx6("span", { onClick: (event) => event.stopPropagation(), children: internalRowSelection.type === "radio" ? /* @__PURE__ */ jsx6(
|
|
1426
1405
|
Radio,
|
|
1427
1406
|
{
|
|
@@ -1471,7 +1450,7 @@ function Table({
|
|
|
1471
1450
|
resolvedCardClassName
|
|
1472
1451
|
),
|
|
1473
1452
|
onClick: () => ctx.handleRowClick(record, index, key),
|
|
1474
|
-
children: customCard !== void 0 && customCard !== null ? customCard : /* @__PURE__ */
|
|
1453
|
+
children: customCard !== void 0 && customCard !== null ? customCard : /* @__PURE__ */ jsxs4(Fragment, { children: [
|
|
1475
1454
|
(() => {
|
|
1476
1455
|
const { titleColumn, bodyColumns } = getCardColumns(ctx.displayColumns);
|
|
1477
1456
|
const renderCellContent = (column) => {
|
|
@@ -1479,8 +1458,8 @@ function Table({
|
|
|
1479
1458
|
return column.render ? column.render(record, index) : record[dataKey];
|
|
1480
1459
|
};
|
|
1481
1460
|
if (hasCustomCardLayout) {
|
|
1482
|
-
return /* @__PURE__ */
|
|
1483
|
-
titleColumn && /* @__PURE__ */
|
|
1461
|
+
return /* @__PURE__ */ jsxs4(Fragment, { children: [
|
|
1462
|
+
titleColumn && /* @__PURE__ */ jsxs4(
|
|
1484
1463
|
"div",
|
|
1485
1464
|
{
|
|
1486
1465
|
className: classNames3(
|
|
@@ -1511,7 +1490,7 @@ function Table({
|
|
|
1511
1490
|
);
|
|
1512
1491
|
}
|
|
1513
1492
|
if (gridInfo.labelPosition === "top") {
|
|
1514
|
-
return /* @__PURE__ */
|
|
1493
|
+
return /* @__PURE__ */ jsxs4(
|
|
1515
1494
|
"div",
|
|
1516
1495
|
{
|
|
1517
1496
|
className: classNames3(
|
|
@@ -1544,7 +1523,7 @@ function Table({
|
|
|
1544
1523
|
column.key
|
|
1545
1524
|
);
|
|
1546
1525
|
}
|
|
1547
|
-
return /* @__PURE__ */
|
|
1526
|
+
return /* @__PURE__ */ jsxs4(
|
|
1548
1527
|
"div",
|
|
1549
1528
|
{
|
|
1550
1529
|
className: classNames3(
|
|
@@ -1580,8 +1559,8 @@ function Table({
|
|
|
1580
1559
|
}) })
|
|
1581
1560
|
] });
|
|
1582
1561
|
}
|
|
1583
|
-
return /* @__PURE__ */
|
|
1584
|
-
titleColumn && /* @__PURE__ */
|
|
1562
|
+
return /* @__PURE__ */ jsxs4(Fragment, { children: [
|
|
1563
|
+
titleColumn && /* @__PURE__ */ jsxs4(
|
|
1585
1564
|
"div",
|
|
1586
1565
|
{
|
|
1587
1566
|
className: classNames3(
|
|
@@ -1595,7 +1574,7 @@ function Table({
|
|
|
1595
1574
|
}
|
|
1596
1575
|
),
|
|
1597
1576
|
(!titleColumn || cardSelectionPosition !== "title-inline") && controlsNode && /* @__PURE__ */ jsx6("div", { className: "mb-2 flex items-center gap-3", children: controlsNode }),
|
|
1598
|
-
bodyColumns.map((column) => /* @__PURE__ */
|
|
1577
|
+
bodyColumns.map((column) => /* @__PURE__ */ jsxs4("div", { className: tableResponsiveCardRowClasses, children: [
|
|
1599
1578
|
/* @__PURE__ */ jsx6("div", { className: tableResponsiveCardLabelClasses, children: column.title }),
|
|
1600
1579
|
/* @__PURE__ */ jsx6("div", { className: tableResponsiveCardValueClasses, children: renderCellContent(column) })
|
|
1601
1580
|
] }, column.key))
|
|
@@ -1610,7 +1589,7 @@ function Table({
|
|
|
1610
1589
|
]
|
|
1611
1590
|
}
|
|
1612
1591
|
),
|
|
1613
|
-
loading && /* @__PURE__ */
|
|
1592
|
+
loading && /* @__PURE__ */ jsxs4(
|
|
1614
1593
|
"div",
|
|
1615
1594
|
{
|
|
1616
1595
|
className: tableLoadingOverlayClasses,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { DataExportProps as DataExportProps$1, TigerLocale, TigerLocaleDataExport, DataExportFormat } from '@expcat/tigercat-core';
|
|
3
|
+
|
|
4
|
+
interface DataExportProps<T = Record<string, unknown>> extends DataExportProps$1<T> {
|
|
5
|
+
/** Locale overrides merged on top of ConfigProvider locale */
|
|
6
|
+
locale?: Partial<TigerLocale>;
|
|
7
|
+
/** UI labels for custom text. Takes precedence over locale and ConfigProvider text. */
|
|
8
|
+
labels?: Partial<TigerLocaleDataExport>;
|
|
9
|
+
className?: string;
|
|
10
|
+
/** Called after the download for the given format has been triggered */
|
|
11
|
+
onExport?: (format: DataExportFormat) => void;
|
|
12
|
+
/** Called when serialization or download fails */
|
|
13
|
+
onError?: (error: unknown) => void;
|
|
14
|
+
}
|
|
15
|
+
declare const DataExport: <T extends Record<string, unknown>>({ columns, dataSource, formats, fileName, sheetName, cellFormatter, disabled, locale, labels, className, onExport, onError }: DataExportProps<T>) => React__default.ReactElement | null;
|
|
16
|
+
|
|
17
|
+
export { DataExport, type DataExportProps };
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DataTableWithToolbar,
|
|
3
3
|
DataTableWithToolbar_default
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-RM2LACNK.mjs";
|
|
5
|
+
import "../chunk-U3TW75H3.mjs";
|
|
6
6
|
import "../chunk-PAN256RW.mjs";
|
|
7
|
+
import "../chunk-QWUDJC6K.mjs";
|
|
7
8
|
import "../chunk-IIWUQK2P.mjs";
|
|
8
9
|
import "../chunk-AKNWUI7K.mjs";
|
|
9
|
-
import "../chunk-
|
|
10
|
+
import "../chunk-2DCKVGQ3.mjs";
|
|
10
11
|
import "../chunk-S7IB6YST.mjs";
|
|
11
12
|
import "../chunk-F6WV53BS.mjs";
|
|
12
13
|
import "../chunk-W7BC4I2Y.mjs";
|
package/dist/components/List.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
NotificationCenter,
|
|
3
3
|
NotificationCenter_default
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-VDI4T62S.mjs";
|
|
5
5
|
import "../chunk-Z3CRHC5F.mjs";
|
|
6
|
-
import "../chunk-
|
|
6
|
+
import "../chunk-2HNUN6OM.mjs";
|
|
7
|
+
import "../chunk-2DCKVGQ3.mjs";
|
|
7
8
|
import "../chunk-Y5X3G2LD.mjs";
|
|
8
9
|
import "../chunk-5TE7KLE5.mjs";
|
|
9
10
|
import "../chunk-ZJWUBR2X.mjs";
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Table
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-U3TW75H3.mjs";
|
|
4
4
|
import "../chunk-PAN256RW.mjs";
|
|
5
5
|
import "../chunk-IIWUQK2P.mjs";
|
|
6
6
|
import "../chunk-AKNWUI7K.mjs";
|
|
7
|
+
import "../chunk-2DCKVGQ3.mjs";
|
|
7
8
|
import "../chunk-W7BC4I2Y.mjs";
|
|
8
9
|
import "../chunk-EPWAROC2.mjs";
|
|
9
10
|
import "../chunk-OL3RXYMG.mjs";
|
package/dist/index.d.mts
CHANGED
|
@@ -39,6 +39,7 @@ export { DatePicker, DatePickerProps } from './components/DatePicker.mjs';
|
|
|
39
39
|
export { TimePicker, TimePickerProps } from './components/TimePicker.mjs';
|
|
40
40
|
export { Upload, UploadProps } from './components/Upload.mjs';
|
|
41
41
|
export { Table } from './components/Table.mjs';
|
|
42
|
+
export { DataExport, DataExportProps } from './components/DataExport.mjs';
|
|
42
43
|
export { Tag, TagProps } from './components/Tag.mjs';
|
|
43
44
|
export { Badge, BadgeProps } from './components/Badge.mjs';
|
|
44
45
|
export { Card, CardProps } from './components/Card.mjs';
|
|
@@ -149,6 +150,6 @@ import 'react';
|
|
|
149
150
|
* React components for Tigercat UI library
|
|
150
151
|
*/
|
|
151
152
|
|
|
152
|
-
declare const version = "2.0.0-preview.
|
|
153
|
+
declare const version = "2.0.0-preview.6";
|
|
153
154
|
|
|
154
155
|
export { version };
|
package/dist/index.mjs
CHANGED
|
@@ -12,6 +12,7 @@ export {
|
|
|
12
12
|
DEFAULT_CHART_COLORS,
|
|
13
13
|
DEFAULT_CHART_LABELS,
|
|
14
14
|
DEFAULT_CRON_EDITOR_LABELS,
|
|
15
|
+
DEFAULT_DATA_EXPORT_LABELS,
|
|
15
16
|
DEFAULT_FILE_MANAGER_LABELS,
|
|
16
17
|
DEFAULT_FORM_VALIDATION_LABELS,
|
|
17
18
|
DEFAULT_FORM_WIZARD_LABELS,
|
|
@@ -60,6 +61,7 @@ export {
|
|
|
60
61
|
MOTION_DURATION_TOKEN_VARS,
|
|
61
62
|
MOTION_EASING_TOKEN_FALLBACKS,
|
|
62
63
|
MOTION_EASING_TOKEN_VARS,
|
|
64
|
+
PAGINATION_FULL_MODE_PAGE_THRESHOLD,
|
|
63
65
|
PIE_BASE_SHADOW,
|
|
64
66
|
PIE_EMPHASIS_SHADOW,
|
|
65
67
|
POPOVER_TEXT_CLASSES,
|
|
@@ -95,6 +97,7 @@ export {
|
|
|
95
97
|
ZH_CN_CAROUSEL_LABELS,
|
|
96
98
|
ZH_CN_CHART_LABELS,
|
|
97
99
|
ZH_CN_CRON_EDITOR_LABELS,
|
|
100
|
+
ZH_CN_DATA_EXPORT_LABELS,
|
|
98
101
|
ZH_CN_FILE_MANAGER_LABELS,
|
|
99
102
|
ZH_CN_FORM_VALIDATION_LABELS,
|
|
100
103
|
ZH_CN_FORM_WIZARD_LABELS,
|
|
@@ -710,6 +713,7 @@ export {
|
|
|
710
713
|
getBreadcrumbItemClasses,
|
|
711
714
|
getBreadcrumbLinkClasses,
|
|
712
715
|
getBreadcrumbSeparatorClasses,
|
|
716
|
+
getBuiltInPaginationContainerClasses,
|
|
713
717
|
getButtonGroupClasses,
|
|
714
718
|
getButtonVariantClasses,
|
|
715
719
|
getCalendarContainerClasses,
|
|
@@ -789,6 +793,7 @@ export {
|
|
|
789
793
|
getCurrentActiveTourStep,
|
|
790
794
|
getCurrentTime,
|
|
791
795
|
getCyclicIndex,
|
|
796
|
+
getDataExportLabels,
|
|
792
797
|
getDatePickerCalendarCellState,
|
|
793
798
|
getDatePickerDayCellClasses,
|
|
794
799
|
getDatePickerIconButtonClasses,
|
|
@@ -1655,6 +1660,7 @@ export {
|
|
|
1655
1660
|
resolveMotionDuration,
|
|
1656
1661
|
resolveMotionEasing,
|
|
1657
1662
|
resolveMultiSeriesTooltipContent,
|
|
1663
|
+
resolvePaginationDisplayMode,
|
|
1658
1664
|
resolvePanGesture,
|
|
1659
1665
|
resolvePinchScale,
|
|
1660
1666
|
resolveResponsiveChartSize,
|
|
@@ -2067,6 +2073,7 @@ export { DatePicker } from './components/DatePicker.mjs';
|
|
|
2067
2073
|
export { TimePicker } from './components/TimePicker.mjs';
|
|
2068
2074
|
export { Upload } from './components/Upload.mjs';
|
|
2069
2075
|
export { Table } from './components/Table.mjs';
|
|
2076
|
+
export { DataExport } from './components/DataExport.mjs';
|
|
2070
2077
|
export { Tag } from './components/Tag.mjs';
|
|
2071
2078
|
export { Badge } from './components/Badge.mjs';
|
|
2072
2079
|
export { Card } from './components/Card.mjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expcat/tigercat-react",
|
|
3
|
-
"version": "2.0.0-preview.
|
|
3
|
+
"version": "2.0.0-preview.6",
|
|
4
4
|
"description": "React components for Tigercat UI library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Yizhe Wang",
|
|
@@ -244,6 +244,11 @@
|
|
|
244
244
|
"import": "./dist/components/CropUpload.mjs",
|
|
245
245
|
"default": "./dist/components/CropUpload.mjs"
|
|
246
246
|
},
|
|
247
|
+
"./DataExport": {
|
|
248
|
+
"types": "./dist/components/DataExport.d.mts",
|
|
249
|
+
"import": "./dist/components/DataExport.mjs",
|
|
250
|
+
"default": "./dist/components/DataExport.mjs"
|
|
251
|
+
},
|
|
247
252
|
"./DataTableWithToolbar": {
|
|
248
253
|
"types": "./dist/components/DataTableWithToolbar.d.mts",
|
|
249
254
|
"import": "./dist/components/DataTableWithToolbar.mjs",
|
|
@@ -777,7 +782,7 @@
|
|
|
777
782
|
"access": "public"
|
|
778
783
|
},
|
|
779
784
|
"dependencies": {
|
|
780
|
-
"@expcat/tigercat-core": "2.0.0-preview.
|
|
785
|
+
"@expcat/tigercat-core": "2.0.0-preview.6"
|
|
781
786
|
},
|
|
782
787
|
"devDependencies": {
|
|
783
788
|
"@types/node": "^22.20.0",
|