@ackplus/react-tanstack-data-table 1.0.19-beta-0.10 → 1.0.19-beta-0.13
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 +2 -2
- package/package.json +1 -1
- package/src/lib/components/table/data-table.d.ts +2 -1
- package/src/lib/components/table/data-table.js +128 -125
- package/src/lib/components/table/data-table.types.d.ts +9 -9
- package/src/lib/components/toolbar/bulk-actions-toolbar.d.ts +1 -1
- package/src/lib/components/toolbar/column-filter-control.d.ts +1 -0
- package/src/lib/components/toolbar/{column-custom-filter-control.js → column-filter-control.js} +22 -20
- package/src/lib/components/toolbar/data-table-toolbar.js +2 -2
- package/src/lib/components/toolbar/index.d.ts +1 -0
- package/src/lib/components/toolbar/index.js +3 -1
- package/src/lib/components/toolbar/table-export-control.d.ts +4 -4
- package/src/lib/contexts/data-table-context.d.ts +8 -8
- package/src/lib/contexts/data-table-context.js +5 -5
- package/src/lib/examples/server-side-fetching-example.js +12 -3
- package/src/lib/features/{custom-column-filter.feature.d.ts → column-filter.feature.d.ts} +14 -14
- package/src/lib/features/{custom-column-filter.feature.js → column-filter.feature.js} +51 -26
- package/src/lib/features/index.d.ts +2 -2
- package/src/lib/features/index.js +6 -6
- package/src/lib/features/{custom-selection.feature.d.ts → selection.feature.d.ts} +8 -8
- package/src/lib/features/{custom-selection.feature.js → selection.feature.js} +20 -8
- package/src/lib/hooks/use-data-table-api.d.ts +7 -19
- package/src/lib/hooks/use-data-table-api.js +84 -104
- package/src/lib/types/data-table-api.d.ts +4 -4
- package/src/lib/types/table.types.d.ts +4 -4
- package/src/lib/utils/column-helpers.d.ts +1 -2
- package/src/lib/utils/column-helpers.js +3 -2
- package/src/lib/utils/export-utils.d.ts +4 -4
- package/src/lib/utils/export-utils.js +32 -15
- package/src/lib/components/toolbar/column-custom-filter-control.d.ts +0 -1
|
@@ -48,25 +48,42 @@ function exportServerData(table, options) {
|
|
|
48
48
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
49
49
|
const { format, filename, fetchData, currentFilters, selection, onProgress, onComplete, onError } = options;
|
|
50
50
|
try {
|
|
51
|
-
onProgress === null || onProgress === void 0 ? void 0 : onProgress({
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
percentage: 0,
|
|
55
|
-
});
|
|
56
|
-
const { data } = yield fetchData(currentFilters, selection);
|
|
57
|
-
if (!data || !Array.isArray(data)) {
|
|
51
|
+
onProgress === null || onProgress === void 0 ? void 0 : onProgress({});
|
|
52
|
+
const initialResponse = yield fetchData(Object.assign(Object.assign({}, currentFilters), { pagination: { pageIndex: 0, pageSize: 1 } }), selection);
|
|
53
|
+
if (!initialResponse || !initialResponse.data || !Array.isArray(initialResponse.data)) {
|
|
58
54
|
throw new Error('Invalid data received from server');
|
|
59
55
|
}
|
|
56
|
+
const totalRows = initialResponse.total || initialResponse.data.length;
|
|
57
|
+
const CHUNK_SIZE = 1000;
|
|
58
|
+
const needsChunking = totalRows > CHUNK_SIZE;
|
|
59
|
+
let allData = [];
|
|
60
|
+
if (needsChunking) {
|
|
61
|
+
const totalPages = Math.ceil(totalRows / CHUNK_SIZE);
|
|
62
|
+
for (let page = 1; page <= totalPages; page++) {
|
|
63
|
+
const chunkFilters = Object.assign(Object.assign({}, currentFilters), { pagination: {
|
|
64
|
+
pageIndex: page - 1,
|
|
65
|
+
pageSize: CHUNK_SIZE,
|
|
66
|
+
} });
|
|
67
|
+
const chunkResponse = yield fetchData(chunkFilters, selection);
|
|
68
|
+
if (!chunkResponse || !chunkResponse.data || !Array.isArray(chunkResponse.data)) {
|
|
69
|
+
throw new Error(`Failed to fetch chunk ${page}`);
|
|
70
|
+
}
|
|
71
|
+
allData = [...allData, ...chunkResponse.data];
|
|
72
|
+
if (page < totalPages) {
|
|
73
|
+
yield new Promise(resolve => setTimeout(resolve, 100));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
allData = initialResponse.data;
|
|
79
|
+
}
|
|
60
80
|
const visibleColumns = table.getVisibleLeafColumns().filter(col => {
|
|
61
81
|
const columnDef = col.columnDef;
|
|
62
82
|
return col.getIsVisible() && columnDef.hideInExport !== true;
|
|
63
83
|
});
|
|
64
|
-
const exportData =
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
totalRows: data.length,
|
|
68
|
-
percentage: Math.round(((index + 1) / data.length) * 100),
|
|
69
|
-
});
|
|
84
|
+
const exportData = [];
|
|
85
|
+
for (let index = 0; index < allData.length; index++) {
|
|
86
|
+
const rowData = allData[index];
|
|
70
87
|
const exportRow = {};
|
|
71
88
|
visibleColumns.forEach(column => {
|
|
72
89
|
var _a;
|
|
@@ -90,8 +107,8 @@ function exportServerData(table, options) {
|
|
|
90
107
|
}
|
|
91
108
|
exportRow[header] = value;
|
|
92
109
|
});
|
|
93
|
-
|
|
94
|
-
}
|
|
110
|
+
exportData.push(exportRow);
|
|
111
|
+
}
|
|
95
112
|
yield exportToFile(exportData, format, filename);
|
|
96
113
|
onComplete === null || onComplete === void 0 ? void 0 : onComplete({
|
|
97
114
|
success: true,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function ColumnCustomFilterControl(): import("react/jsx-runtime").JSX.Element;
|