@ackplus/react-tanstack-data-table 1.0.29 → 1.0.30
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/package.json
CHANGED
|
@@ -46,9 +46,6 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
46
46
|
const isServerFiltering = filterMode === 'server' || isServerMode;
|
|
47
47
|
const isServerSorting = sortingMode === 'server' || isServerMode;
|
|
48
48
|
const logger = (0, react_1.useMemo)(() => (0, utils_1.createLogger)('DataTable', logging), [logging]);
|
|
49
|
-
const fetchLogger = (0, react_1.useMemo)(() => logger.child('fetch'), [logger]);
|
|
50
|
-
const paginationLogger = (0, react_1.useMemo)(() => logger.child('pagination'), [logger]);
|
|
51
|
-
const stateLogger = (0, react_1.useMemo)(() => logger.child('state'), [logger]);
|
|
52
49
|
(0, react_1.useEffect)(() => {
|
|
53
50
|
if (logger.isLevelEnabled('info')) {
|
|
54
51
|
logger.info('mounted', {
|
|
@@ -71,6 +68,7 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
71
68
|
}
|
|
72
69
|
return config;
|
|
73
70
|
}, [initialState, logger]);
|
|
71
|
+
console.log('initialStateConfig', initialStateConfig);
|
|
74
72
|
const [sorting, setSorting] = (0, react_1.useState)((initialState === null || initialState === void 0 ? void 0 : initialState.sorting) || DEFAULT_INITIAL_STATE.sorting);
|
|
75
73
|
const [pagination, setPagination] = (0, react_1.useState)((initialState === null || initialState === void 0 ? void 0 : initialState.pagination) || DEFAULT_INITIAL_STATE.pagination);
|
|
76
74
|
const [globalFilter, setGlobalFilter] = (0, react_1.useState)((initialState === null || initialState === void 0 ? void 0 : initialState.globalFilter) || DEFAULT_INITIAL_STATE.globalFilter);
|
|
@@ -145,8 +143,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
145
143
|
const fetchData = (0, react_1.useCallback)((...args_1) => tslib_1.__awaiter(this, [...args_1], void 0, function* (overrides = {}) {
|
|
146
144
|
var _a, _b;
|
|
147
145
|
if (!onFetchData) {
|
|
148
|
-
if (
|
|
149
|
-
|
|
146
|
+
if (logger.isLevelEnabled('debug')) {
|
|
147
|
+
logger.debug('onFetchData not provided, skipping fetch', { overrides, columnFilter, sorting, pagination });
|
|
150
148
|
}
|
|
151
149
|
return;
|
|
152
150
|
}
|
|
@@ -154,13 +152,14 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
154
152
|
pagination,
|
|
155
153
|
columnFilter,
|
|
156
154
|
sorting }, overrides);
|
|
157
|
-
|
|
158
|
-
|
|
155
|
+
console.log('filters', filters);
|
|
156
|
+
if (logger.isLevelEnabled('info')) {
|
|
157
|
+
logger.info('Requesting data', { filters });
|
|
159
158
|
}
|
|
160
159
|
try {
|
|
161
160
|
const result = yield debouncedFetch(filters);
|
|
162
|
-
if (
|
|
163
|
-
|
|
161
|
+
if (logger.isLevelEnabled('info')) {
|
|
162
|
+
logger.info('Fetch resolved', {
|
|
164
163
|
rows: (_b = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0,
|
|
165
164
|
total: result === null || result === void 0 ? void 0 : result.total,
|
|
166
165
|
});
|
|
@@ -169,13 +168,13 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
169
168
|
setServerData(result.data);
|
|
170
169
|
setServerTotal(result.total);
|
|
171
170
|
}
|
|
172
|
-
else if (
|
|
173
|
-
|
|
171
|
+
else if (logger.isLevelEnabled('warn')) {
|
|
172
|
+
logger.warn('Fetch handler returned unexpected shape', result);
|
|
174
173
|
}
|
|
175
174
|
return result;
|
|
176
175
|
}
|
|
177
176
|
catch (error) {
|
|
178
|
-
|
|
177
|
+
logger.error('Fetch failed', error);
|
|
179
178
|
throw error;
|
|
180
179
|
}
|
|
181
180
|
}), [
|
|
@@ -185,7 +184,7 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
185
184
|
columnFilter,
|
|
186
185
|
sorting,
|
|
187
186
|
debouncedFetch,
|
|
188
|
-
|
|
187
|
+
logger,
|
|
189
188
|
]);
|
|
190
189
|
const handleSelectionStateChange = (0, react_1.useCallback)((updaterOrValue) => {
|
|
191
190
|
setSelectionState((prevState) => {
|
|
@@ -207,8 +206,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
207
206
|
}, [onColumnFiltersChange]);
|
|
208
207
|
const tableStateChange = (0, react_1.useCallback)((overrides = {}) => {
|
|
209
208
|
if (!onDataStateChange) {
|
|
210
|
-
if (
|
|
211
|
-
|
|
209
|
+
if (logger.isLevelEnabled('debug')) {
|
|
210
|
+
logger.debug('No onDataStateChange handler registered; skipping state update notification', { overrides });
|
|
212
211
|
}
|
|
213
212
|
return;
|
|
214
213
|
}
|
|
@@ -218,8 +217,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
218
217
|
pagination,
|
|
219
218
|
columnOrder,
|
|
220
219
|
columnPinning }, overrides);
|
|
221
|
-
if (
|
|
222
|
-
|
|
220
|
+
if (logger.isLevelEnabled('debug')) {
|
|
221
|
+
logger.debug('Emitting tableStateChange', currentState);
|
|
223
222
|
}
|
|
224
223
|
onDataStateChange(currentState);
|
|
225
224
|
}, [
|
|
@@ -230,7 +229,7 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
230
229
|
pagination,
|
|
231
230
|
columnOrder,
|
|
232
231
|
columnPinning,
|
|
233
|
-
|
|
232
|
+
logger,
|
|
234
233
|
]);
|
|
235
234
|
const handleSortingChange = (0, react_1.useCallback)((updaterOrValue) => {
|
|
236
235
|
let newSorting = typeof updaterOrValue === 'function'
|
|
@@ -239,8 +238,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
239
238
|
newSorting = newSorting.filter((sort) => sort.id);
|
|
240
239
|
setSorting(newSorting);
|
|
241
240
|
onSortingChange === null || onSortingChange === void 0 ? void 0 : onSortingChange(newSorting);
|
|
242
|
-
if (
|
|
243
|
-
|
|
241
|
+
if (logger.isLevelEnabled('debug')) {
|
|
242
|
+
logger.debug('Sorting change applied', {
|
|
244
243
|
sorting: newSorting,
|
|
245
244
|
serverMode: isServerMode,
|
|
246
245
|
serverSorting: isServerSorting,
|
|
@@ -248,8 +247,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
248
247
|
}
|
|
249
248
|
if (isServerMode || isServerSorting) {
|
|
250
249
|
const pagination = resetPageToFirst();
|
|
251
|
-
if (
|
|
252
|
-
|
|
250
|
+
if (logger.isLevelEnabled('debug')) {
|
|
251
|
+
logger.debug('Sorting change triggered server fetch', { pagination, sorting: newSorting });
|
|
253
252
|
}
|
|
254
253
|
tableStateChange({ sorting: newSorting, pagination });
|
|
255
254
|
fetchData({
|
|
@@ -260,8 +259,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
260
259
|
else if (onDataStateChange) {
|
|
261
260
|
const pagination = resetPageToFirst();
|
|
262
261
|
setTimeout(() => {
|
|
263
|
-
if (
|
|
264
|
-
|
|
262
|
+
if (logger.isLevelEnabled('debug')) {
|
|
263
|
+
logger.debug('Sorting change notified client state change', { pagination, sorting: newSorting });
|
|
265
264
|
}
|
|
266
265
|
tableStateChange({ sorting: newSorting, pagination });
|
|
267
266
|
}, 0);
|
|
@@ -274,7 +273,7 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
274
273
|
isServerSorting,
|
|
275
274
|
onDataStateChange,
|
|
276
275
|
tableStateChange,
|
|
277
|
-
|
|
276
|
+
logger,
|
|
278
277
|
]);
|
|
279
278
|
const handleColumnOrderChange = (0, react_1.useCallback)((updatedColumnOrder) => {
|
|
280
279
|
const newColumnOrder = typeof updatedColumnOrder === 'function'
|
|
@@ -296,22 +295,23 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
296
295
|
}, [onColumnPinningChange, columnPinning]);
|
|
297
296
|
const handlePaginationChange = (0, react_1.useCallback)((updater) => {
|
|
298
297
|
const newPagination = typeof updater === 'function' ? updater(pagination) : updater;
|
|
299
|
-
if (
|
|
300
|
-
|
|
298
|
+
if (logger.isLevelEnabled('debug')) {
|
|
299
|
+
logger.debug('Pagination change requested', {
|
|
301
300
|
previous: pagination,
|
|
302
301
|
next: newPagination,
|
|
303
302
|
serverSide: isServerMode || isServerPagination,
|
|
304
303
|
});
|
|
305
304
|
}
|
|
305
|
+
console.log('newPagination', newPagination);
|
|
306
306
|
setPagination(newPagination);
|
|
307
307
|
onPaginationChange === null || onPaginationChange === void 0 ? void 0 : onPaginationChange(newPagination);
|
|
308
|
-
if (
|
|
309
|
-
|
|
308
|
+
if (logger.isLevelEnabled('debug')) {
|
|
309
|
+
logger.debug('Pagination state updated', newPagination);
|
|
310
310
|
}
|
|
311
311
|
if (isServerMode || isServerPagination) {
|
|
312
312
|
setTimeout(() => {
|
|
313
|
-
if (
|
|
314
|
-
|
|
313
|
+
if (logger.isLevelEnabled('debug')) {
|
|
314
|
+
logger.debug('Notifying server-side pagination change', newPagination);
|
|
315
315
|
}
|
|
316
316
|
tableStateChange({ pagination: newPagination });
|
|
317
317
|
fetchData({ pagination: newPagination });
|
|
@@ -319,8 +319,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
319
319
|
}
|
|
320
320
|
else if (onDataStateChange) {
|
|
321
321
|
setTimeout(() => {
|
|
322
|
-
if (
|
|
323
|
-
|
|
322
|
+
if (logger.isLevelEnabled('debug')) {
|
|
323
|
+
logger.debug('Notifying client-side pagination change', newPagination);
|
|
324
324
|
}
|
|
325
325
|
tableStateChange({ pagination: newPagination });
|
|
326
326
|
}, 0);
|
|
@@ -332,7 +332,7 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
332
332
|
onDataStateChange,
|
|
333
333
|
fetchData,
|
|
334
334
|
tableStateChange,
|
|
335
|
-
|
|
335
|
+
logger,
|
|
336
336
|
onPaginationChange,
|
|
337
337
|
]);
|
|
338
338
|
const handleGlobalFilterChange = (0, react_1.useCallback)((updaterOrValue) => {
|
|
@@ -340,8 +340,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
340
340
|
? updaterOrValue(globalFilter)
|
|
341
341
|
: updaterOrValue;
|
|
342
342
|
setGlobalFilter(newFilter);
|
|
343
|
-
if (
|
|
344
|
-
|
|
343
|
+
if (logger.isLevelEnabled('debug')) {
|
|
344
|
+
logger.debug('Global filter change applied', {
|
|
345
345
|
value: newFilter,
|
|
346
346
|
serverMode: isServerMode,
|
|
347
347
|
serverFiltering: isServerFiltering,
|
|
@@ -350,8 +350,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
350
350
|
if (isServerMode || isServerFiltering) {
|
|
351
351
|
const pagination = resetPageToFirst();
|
|
352
352
|
setTimeout(() => {
|
|
353
|
-
if (
|
|
354
|
-
|
|
353
|
+
if (logger.isLevelEnabled('debug')) {
|
|
354
|
+
logger.debug('Global filter change triggering server fetch', {
|
|
355
355
|
pagination,
|
|
356
356
|
value: newFilter,
|
|
357
357
|
});
|
|
@@ -363,8 +363,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
363
363
|
else if (onDataStateChange) {
|
|
364
364
|
const pagination = resetPageToFirst();
|
|
365
365
|
setTimeout(() => {
|
|
366
|
-
if (
|
|
367
|
-
|
|
366
|
+
if (logger.isLevelEnabled('debug')) {
|
|
367
|
+
logger.debug('Global filter change notifying client listeners', {
|
|
368
368
|
pagination,
|
|
369
369
|
value: newFilter,
|
|
370
370
|
});
|
|
@@ -373,7 +373,7 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
373
373
|
}, 0);
|
|
374
374
|
}
|
|
375
375
|
onGlobalFilterChange === null || onGlobalFilterChange === void 0 ? void 0 : onGlobalFilterChange(newFilter);
|
|
376
|
-
}, [globalFilter, isServerMode, isServerFiltering, onDataStateChange, fetchData, tableStateChange,
|
|
376
|
+
}, [globalFilter, isServerMode, isServerFiltering, onDataStateChange, fetchData, tableStateChange, logger]);
|
|
377
377
|
const onColumnFilterChangeHandler = (0, react_1.useCallback)((updater) => {
|
|
378
378
|
const currentState = columnFilter;
|
|
379
379
|
const newState = typeof updater === 'function'
|
|
@@ -421,8 +421,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
421
421
|
enabled: enableVirtualization && !enablePagination && rows.length > 0,
|
|
422
422
|
});
|
|
423
423
|
const resetPageToFirst = () => {
|
|
424
|
-
if (
|
|
425
|
-
|
|
424
|
+
if (logger.isLevelEnabled('info')) {
|
|
425
|
+
logger.info('Resetting to first page due to state change', {
|
|
426
426
|
previousPageIndex: pagination.pageIndex,
|
|
427
427
|
pageSize: pagination.pageSize,
|
|
428
428
|
});
|
|
@@ -430,6 +430,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
430
430
|
const newPagination = { pageIndex: 0, pageSize: pagination.pageSize };
|
|
431
431
|
setPagination(newPagination);
|
|
432
432
|
onPaginationChange === null || onPaginationChange === void 0 ? void 0 : onPaginationChange(newPagination);
|
|
433
|
+
console.log('newPagination', newPagination);
|
|
434
|
+
console.log('onPaginationChange', onPaginationChange);
|
|
433
435
|
return newPagination;
|
|
434
436
|
};
|
|
435
437
|
const handleColumnReorder = (0, react_1.useCallback)((draggedColumnId, targetColumnId) => {
|
|
@@ -453,13 +455,13 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
453
455
|
}, [columnOrder, enhancedColumns, handleColumnOrderChange]);
|
|
454
456
|
(0, react_1.useEffect)(() => {
|
|
455
457
|
if (initialLoadData && onFetchData) {
|
|
456
|
-
if (
|
|
457
|
-
|
|
458
|
+
if (logger.isLevelEnabled('info')) {
|
|
459
|
+
logger.info('Initial data load triggered', { initialLoadData });
|
|
458
460
|
}
|
|
459
461
|
fetchData();
|
|
460
462
|
}
|
|
461
|
-
else if (
|
|
462
|
-
|
|
463
|
+
else if (logger.isLevelEnabled('debug')) {
|
|
464
|
+
logger.debug('Skipping initial data load', {
|
|
463
465
|
initialLoadData,
|
|
464
466
|
hasOnFetchData: !!onFetchData
|
|
465
467
|
});
|
|
@@ -605,8 +607,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
605
607
|
pendingFilters: columnFilter.pendingFilters || [],
|
|
606
608
|
pendingLogic: columnFilter.pendingLogic || 'AND',
|
|
607
609
|
});
|
|
608
|
-
if (
|
|
609
|
-
|
|
610
|
+
if (logger.isLevelEnabled('debug')) {
|
|
611
|
+
logger.debug(`Adding column filter ${columnId} ${operator} ${value}`, newFilters);
|
|
610
612
|
}
|
|
611
613
|
},
|
|
612
614
|
removeColumnFilter: (filterId) => {
|
|
@@ -619,8 +621,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
619
621
|
pendingFilters: columnFilter.pendingFilters || [],
|
|
620
622
|
pendingLogic: columnFilter.pendingLogic || 'AND',
|
|
621
623
|
});
|
|
622
|
-
if (
|
|
623
|
-
|
|
624
|
+
if (logger.isLevelEnabled('debug')) {
|
|
625
|
+
logger.debug(`Removing column filter ${filterId}`, newFilters);
|
|
624
626
|
}
|
|
625
627
|
},
|
|
626
628
|
clearAllFilters: () => {
|
|
@@ -639,16 +641,16 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
639
641
|
pendingFilters: [],
|
|
640
642
|
pendingLogic: 'AND',
|
|
641
643
|
});
|
|
642
|
-
if (
|
|
643
|
-
|
|
644
|
+
if (logger.isLevelEnabled('debug')) {
|
|
645
|
+
logger.debug('Resetting filters');
|
|
644
646
|
}
|
|
645
647
|
},
|
|
646
648
|
},
|
|
647
649
|
sorting: {
|
|
648
650
|
setSorting: (sortingState) => {
|
|
649
651
|
table.setSorting(sortingState);
|
|
650
|
-
if (
|
|
651
|
-
|
|
652
|
+
if (logger.isLevelEnabled('debug')) {
|
|
653
|
+
logger.debug(`Setting sorting`, sortingState);
|
|
652
654
|
}
|
|
653
655
|
},
|
|
654
656
|
sortColumn: (columnId, direction) => {
|
|
@@ -672,40 +674,40 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
672
674
|
pagination: {
|
|
673
675
|
goToPage: (pageIndex) => {
|
|
674
676
|
table.setPageIndex(pageIndex);
|
|
675
|
-
if (
|
|
676
|
-
|
|
677
|
+
if (logger.isLevelEnabled('debug')) {
|
|
678
|
+
logger.debug(`Going to page ${pageIndex}`);
|
|
677
679
|
}
|
|
678
680
|
},
|
|
679
681
|
nextPage: () => {
|
|
680
682
|
table.nextPage();
|
|
681
|
-
if (
|
|
682
|
-
|
|
683
|
+
if (logger.isLevelEnabled('debug')) {
|
|
684
|
+
logger.debug('Next page');
|
|
683
685
|
}
|
|
684
686
|
},
|
|
685
687
|
previousPage: () => {
|
|
686
688
|
table.previousPage();
|
|
687
|
-
if (
|
|
688
|
-
|
|
689
|
+
if (logger.isLevelEnabled('debug')) {
|
|
690
|
+
logger.debug('Previous page');
|
|
689
691
|
}
|
|
690
692
|
},
|
|
691
693
|
setPageSize: (pageSize) => {
|
|
692
694
|
table.setPageSize(pageSize);
|
|
693
|
-
if (
|
|
694
|
-
|
|
695
|
+
if (logger.isLevelEnabled('debug')) {
|
|
696
|
+
logger.debug(`Setting page size to ${pageSize}`);
|
|
695
697
|
}
|
|
696
698
|
},
|
|
697
699
|
goToFirstPage: () => {
|
|
698
700
|
table.setPageIndex(0);
|
|
699
|
-
if (
|
|
700
|
-
|
|
701
|
+
if (logger.isLevelEnabled('debug')) {
|
|
702
|
+
logger.debug('Going to first page');
|
|
701
703
|
}
|
|
702
704
|
},
|
|
703
705
|
goToLastPage: () => {
|
|
704
706
|
const pageCount = table.getPageCount();
|
|
705
707
|
if (pageCount > 0) {
|
|
706
708
|
table.setPageIndex(pageCount - 1);
|
|
707
|
-
if (
|
|
708
|
-
|
|
709
|
+
if (logger.isLevelEnabled('debug')) {
|
|
710
|
+
logger.debug(`Going to last page ${pageCount - 1}`);
|
|
709
711
|
}
|
|
710
712
|
}
|
|
711
713
|
},
|
|
@@ -726,27 +728,27 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
726
728
|
isRowSelected: (rowId) => table.getIsRowSelected(rowId) || false,
|
|
727
729
|
},
|
|
728
730
|
data: {
|
|
729
|
-
refresh: () => {
|
|
730
|
-
var _a, _b;
|
|
731
|
+
refresh: (resetPagination = false) => {
|
|
732
|
+
var _a, _b, _c;
|
|
731
733
|
const filters = table.getState();
|
|
732
734
|
const pagination = {
|
|
733
|
-
pageIndex: 0,
|
|
734
|
-
pageSize: ((
|
|
735
|
+
pageIndex: resetPagination ? 0 : ((_a = initialStateConfig.pagination) === null || _a === void 0 ? void 0 : _a.pageIndex) || 0,
|
|
736
|
+
pageSize: ((_b = filters.pagination) === null || _b === void 0 ? void 0 : _b.pageSize) || ((_c = initialStateConfig.pagination) === null || _c === void 0 ? void 0 : _c.pageSize) || 10,
|
|
735
737
|
};
|
|
736
738
|
const allState = table.getState();
|
|
737
739
|
setPagination(pagination);
|
|
738
|
-
onDataStateChange === null || onDataStateChange === void 0 ? void 0 : onDataStateChange(allState);
|
|
740
|
+
onDataStateChange === null || onDataStateChange === void 0 ? void 0 : onDataStateChange(Object.assign(Object.assign({}, allState), { pagination }));
|
|
739
741
|
fetchData === null || fetchData === void 0 ? void 0 : fetchData({ pagination });
|
|
740
|
-
if (
|
|
741
|
-
|
|
742
|
+
if (logger.isLevelEnabled('debug')) {
|
|
743
|
+
logger.debug('Refreshing data using Ref', { pagination, allState });
|
|
742
744
|
}
|
|
743
745
|
},
|
|
744
746
|
reload: () => {
|
|
745
747
|
const allState = table.getState();
|
|
746
748
|
onDataStateChange === null || onDataStateChange === void 0 ? void 0 : onDataStateChange(allState);
|
|
747
749
|
onFetchData === null || onFetchData === void 0 ? void 0 : onFetchData({});
|
|
748
|
-
if (
|
|
749
|
-
|
|
750
|
+
if (logger.isLevelEnabled('debug')) {
|
|
751
|
+
logger.info('Reloading data', allState);
|
|
750
752
|
}
|
|
751
753
|
},
|
|
752
754
|
getAllData: () => {
|
|
@@ -766,8 +768,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
766
768
|
const newData = (_a = table.getRowModel().rows) === null || _a === void 0 ? void 0 : _a.map(row => String(row.original[idKey]) === rowId
|
|
767
769
|
? Object.assign(Object.assign({}, row.original), updates) : row.original);
|
|
768
770
|
setServerData === null || setServerData === void 0 ? void 0 : setServerData(newData || []);
|
|
769
|
-
if (
|
|
770
|
-
|
|
771
|
+
if (logger.isLevelEnabled('debug')) {
|
|
772
|
+
logger.debug(`Updating row ${rowId}`, updates);
|
|
771
773
|
}
|
|
772
774
|
},
|
|
773
775
|
updateRowByIndex: (index, updates) => {
|
|
@@ -776,8 +778,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
776
778
|
if (newData === null || newData === void 0 ? void 0 : newData[index]) {
|
|
777
779
|
newData[index] = Object.assign(Object.assign({}, newData[index]), updates);
|
|
778
780
|
setServerData(newData);
|
|
779
|
-
if (
|
|
780
|
-
|
|
781
|
+
if (logger.isLevelEnabled('debug')) {
|
|
782
|
+
logger.debug(`Updating row by index ${index}`, updates);
|
|
781
783
|
}
|
|
782
784
|
}
|
|
783
785
|
},
|
|
@@ -791,16 +793,16 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
791
793
|
newData.push(newRow);
|
|
792
794
|
}
|
|
793
795
|
setServerData(newData || []);
|
|
794
|
-
if (
|
|
795
|
-
|
|
796
|
+
if (logger.isLevelEnabled('debug')) {
|
|
797
|
+
logger.debug(`Inserting row`, newRow);
|
|
796
798
|
}
|
|
797
799
|
},
|
|
798
800
|
deleteRow: (rowId) => {
|
|
799
801
|
var _a;
|
|
800
802
|
const newData = (_a = (table.getRowModel().rows || [])) === null || _a === void 0 ? void 0 : _a.filter(row => String(row.original[idKey]) !== rowId);
|
|
801
803
|
setServerData === null || setServerData === void 0 ? void 0 : setServerData((newData === null || newData === void 0 ? void 0 : newData.map(row => row.original)) || []);
|
|
802
|
-
if (
|
|
803
|
-
|
|
804
|
+
if (logger.isLevelEnabled('debug')) {
|
|
805
|
+
logger.debug(`Deleting row ${rowId}`);
|
|
804
806
|
}
|
|
805
807
|
},
|
|
806
808
|
deleteRowByIndex: (index) => {
|
|
@@ -808,8 +810,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
808
810
|
const newData = (_a = (table.getRowModel().rows || [])) === null || _a === void 0 ? void 0 : _a.map(row => row.original);
|
|
809
811
|
newData.splice(index, 1);
|
|
810
812
|
setServerData(newData);
|
|
811
|
-
if (
|
|
812
|
-
|
|
813
|
+
if (logger.isLevelEnabled('debug')) {
|
|
814
|
+
logger.debug(`Deleting row by index ${index}`);
|
|
813
815
|
}
|
|
814
816
|
},
|
|
815
817
|
deleteSelectedRows: () => {
|
|
@@ -819,8 +821,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
819
821
|
const newData = (_a = (table.getRowModel().rows || [])) === null || _a === void 0 ? void 0 : _a.filter(row => !selectedRowIds.includes(String(row.original[idKey])));
|
|
820
822
|
setServerData((newData === null || newData === void 0 ? void 0 : newData.map(row => row.original)) || []);
|
|
821
823
|
table.resetRowSelection();
|
|
822
|
-
if (
|
|
823
|
-
|
|
824
|
+
if (logger.isLevelEnabled('debug')) {
|
|
825
|
+
logger.debug('Deleting selected rows');
|
|
824
826
|
}
|
|
825
827
|
},
|
|
826
828
|
replaceAllData: (newData) => {
|
|
@@ -978,8 +980,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
978
980
|
sorting: table.getState().sorting,
|
|
979
981
|
pagination: table.getState().pagination,
|
|
980
982
|
};
|
|
981
|
-
if (
|
|
982
|
-
|
|
983
|
+
if (logger.isLevelEnabled('debug')) {
|
|
984
|
+
logger.debug('Server export CSV', { currentFilters });
|
|
983
985
|
}
|
|
984
986
|
yield (0, utils_1.exportServerData)(table, {
|
|
985
987
|
format: 'csv',
|
|
@@ -1000,8 +1002,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
1000
1002
|
onComplete: onExportComplete,
|
|
1001
1003
|
onError: onExportError,
|
|
1002
1004
|
});
|
|
1003
|
-
if (
|
|
1004
|
-
|
|
1005
|
+
if (logger.isLevelEnabled('debug')) {
|
|
1006
|
+
logger.debug('Client export CSV', filename);
|
|
1005
1007
|
}
|
|
1006
1008
|
}
|
|
1007
1009
|
}
|
|
@@ -1028,8 +1030,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
1028
1030
|
sorting: table.getState().sorting,
|
|
1029
1031
|
pagination: table.getState().pagination,
|
|
1030
1032
|
};
|
|
1031
|
-
if (
|
|
1032
|
-
|
|
1033
|
+
if (logger.isLevelEnabled('debug')) {
|
|
1034
|
+
logger.debug('Server export Excel', { currentFilters });
|
|
1033
1035
|
}
|
|
1034
1036
|
yield (0, utils_1.exportServerData)(table, {
|
|
1035
1037
|
format: 'excel',
|
|
@@ -1050,8 +1052,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
1050
1052
|
onComplete: onExportComplete,
|
|
1051
1053
|
onError: onExportError,
|
|
1052
1054
|
});
|
|
1053
|
-
if (
|
|
1054
|
-
|
|
1055
|
+
if (logger.isLevelEnabled('debug')) {
|
|
1056
|
+
logger.debug('Client export Excel', filename);
|
|
1055
1057
|
}
|
|
1056
1058
|
}
|
|
1057
1059
|
}
|
|
@@ -1060,8 +1062,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
1060
1062
|
message: error.message || 'Export failed',
|
|
1061
1063
|
code: 'EXPORT_ERROR',
|
|
1062
1064
|
});
|
|
1063
|
-
if (
|
|
1064
|
-
|
|
1065
|
+
if (logger.isLevelEnabled('debug')) {
|
|
1066
|
+
logger.debug('Server export Excel failed', error);
|
|
1065
1067
|
}
|
|
1066
1068
|
}
|
|
1067
1069
|
finally {
|
|
@@ -1076,8 +1078,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
1076
1078
|
message: 'No server export function provided',
|
|
1077
1079
|
code: 'NO_SERVER_EXPORT',
|
|
1078
1080
|
});
|
|
1079
|
-
if (
|
|
1080
|
-
|
|
1081
|
+
if (logger.isLevelEnabled('debug')) {
|
|
1082
|
+
logger.debug('Server export data failed', 'No server export function provided');
|
|
1081
1083
|
}
|
|
1082
1084
|
return;
|
|
1083
1085
|
}
|
|
@@ -1090,8 +1092,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
1090
1092
|
sorting: table.getState().sorting,
|
|
1091
1093
|
pagination: table.getState().pagination,
|
|
1092
1094
|
};
|
|
1093
|
-
if (
|
|
1094
|
-
|
|
1095
|
+
if (logger.isLevelEnabled('debug')) {
|
|
1096
|
+
logger.debug('Server export data', { currentFilters });
|
|
1095
1097
|
}
|
|
1096
1098
|
yield (0, utils_1.exportServerData)(table, {
|
|
1097
1099
|
format,
|
|
@@ -1109,8 +1111,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
1109
1111
|
message: error.message || 'Export failed',
|
|
1110
1112
|
code: 'EXPORT_ERROR',
|
|
1111
1113
|
});
|
|
1112
|
-
if (
|
|
1113
|
-
|
|
1114
|
+
if (logger.isLevelEnabled('debug')) {
|
|
1115
|
+
logger.debug('Server export data failed', error);
|
|
1114
1116
|
}
|
|
1115
1117
|
}
|
|
1116
1118
|
finally {
|
|
@@ -1121,8 +1123,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
1121
1123
|
cancelExport: () => {
|
|
1122
1124
|
exportController === null || exportController === void 0 ? void 0 : exportController.abort();
|
|
1123
1125
|
setExportController === null || setExportController === void 0 ? void 0 : setExportController(null);
|
|
1124
|
-
if (
|
|
1125
|
-
|
|
1126
|
+
if (logger.isLevelEnabled('debug')) {
|
|
1127
|
+
logger.debug('Export cancelled');
|
|
1126
1128
|
}
|
|
1127
1129
|
},
|
|
1128
1130
|
},
|
|
@@ -68,7 +68,7 @@ export interface DataTableApi<T = any> {
|
|
|
68
68
|
isRowSelected: (rowId: string) => boolean;
|
|
69
69
|
};
|
|
70
70
|
data: {
|
|
71
|
-
refresh: () => void;
|
|
71
|
+
refresh: (resetPagination?: boolean) => void;
|
|
72
72
|
reload: () => void;
|
|
73
73
|
getAllData: () => T[];
|
|
74
74
|
getRowData: (rowId: string) => T | undefined;
|