@ackplus/react-tanstack-data-table 1.1.10 → 1.1.12
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/lib/components/toolbar/data-table-toolbar.d.ts.map +1 -1
- package/dist/lib/components/toolbar/data-table-toolbar.js +5 -2
- package/dist/lib/components/toolbar/table-refresh-control.d.ts +15 -0
- package/dist/lib/components/toolbar/table-refresh-control.d.ts.map +1 -0
- package/dist/lib/components/toolbar/table-refresh-control.js +61 -0
- package/dist/lib/data-table.d.ts.map +1 -1
- package/dist/lib/data-table.js +752 -922
- package/dist/lib/types/data-table-api.d.ts +1 -0
- package/dist/lib/types/data-table-api.d.ts.map +1 -1
- package/dist/lib/types/data-table.types.d.ts +1 -0
- package/dist/lib/types/data-table.types.d.ts.map +1 -1
- package/dist/lib/types/slots.types.d.ts +9 -0
- package/dist/lib/types/slots.types.d.ts.map +1 -1
- package/dist/lib/utils/slot-helpers.d.ts +1 -1
- package/dist/lib/utils/slot-helpers.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/lib/components/toolbar/data-table-toolbar.tsx +15 -1
- package/src/lib/components/toolbar/table-refresh-control.tsx +58 -0
- package/src/lib/data-table.tsx +776 -910
- package/src/lib/types/data-table-api.ts +4 -0
- package/src/lib/types/data-table.types.ts +1 -0
- package/src/lib/types/slots.types.ts +8 -0
- package/src/lib/utils/slot-helpers.tsx +1 -1
package/dist/lib/data-table.js
CHANGED
|
@@ -119,7 +119,7 @@ enableStickyHeaderOrFooter = false, maxHeight = '400px',
|
|
|
119
119
|
// Virtualization props
|
|
120
120
|
enableVirtualization = false, estimateRowHeight = 52,
|
|
121
121
|
// Toolbar props
|
|
122
|
-
enableTableSizeControl = true, enableExport = false, enableReset = true,
|
|
122
|
+
enableTableSizeControl = true, enableExport = false, enableReset = true, enableRefresh = false,
|
|
123
123
|
// Loading and empty states
|
|
124
124
|
loading = false, emptyMessage = 'No data available', skeletonRows = 5,
|
|
125
125
|
// Column filters props
|
|
@@ -239,7 +239,7 @@ logging, }, ref) {
|
|
|
239
239
|
// Callback hooks (grouped together)
|
|
240
240
|
// -------------------------------
|
|
241
241
|
const fetchData = (0, react_1.useCallback)(async (overrides = {}, options) => {
|
|
242
|
-
var _a, _b;
|
|
242
|
+
var _a, _b, _c;
|
|
243
243
|
if (!onFetchData) {
|
|
244
244
|
if (logger.isLevelEnabled('debug')) {
|
|
245
245
|
logger.debug('onFetchData not provided, skipping fetch', { overrides, columnFilter, sorting, pagination });
|
|
@@ -253,14 +253,16 @@ logging, }, ref) {
|
|
|
253
253
|
sorting,
|
|
254
254
|
...overrides,
|
|
255
255
|
};
|
|
256
|
+
console.log('Fetching data', filters);
|
|
256
257
|
if (logger.isLevelEnabled('info')) {
|
|
257
258
|
logger.info('Requesting data', { filters });
|
|
258
259
|
}
|
|
259
260
|
try {
|
|
260
|
-
const
|
|
261
|
+
const delay = (_a = options === null || options === void 0 ? void 0 : options.delay) !== null && _a !== void 0 ? _a : 300; // respects 0
|
|
262
|
+
const result = await debouncedFetch(filters, delay);
|
|
261
263
|
if (logger.isLevelEnabled('info')) {
|
|
262
264
|
logger.info('Fetch resolved', {
|
|
263
|
-
rows: (
|
|
265
|
+
rows: (_c = (_b = result === null || result === void 0 ? void 0 : result.data) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0,
|
|
264
266
|
total: result === null || result === void 0 ? void 0 : result.total,
|
|
265
267
|
});
|
|
266
268
|
}
|
|
@@ -286,67 +288,20 @@ logging, }, ref) {
|
|
|
286
288
|
debouncedFetch,
|
|
287
289
|
logger,
|
|
288
290
|
]);
|
|
289
|
-
const tableStateChange = (0, react_1.useCallback)((overrides = {}) => {
|
|
290
|
-
if (!onDataStateChange) {
|
|
291
|
-
if (logger.isLevelEnabled('debug')) {
|
|
292
|
-
logger.debug('No onDataStateChange handler registered; skipping state update notification', { overrides });
|
|
293
|
-
}
|
|
294
|
-
return;
|
|
295
|
-
}
|
|
296
|
-
const currentState = {
|
|
297
|
-
globalFilter,
|
|
298
|
-
columnFilter,
|
|
299
|
-
sorting,
|
|
300
|
-
pagination,
|
|
301
|
-
columnOrder,
|
|
302
|
-
columnPinning,
|
|
303
|
-
columnVisibility,
|
|
304
|
-
columnSizing,
|
|
305
|
-
...overrides,
|
|
306
|
-
};
|
|
307
|
-
if (logger.isLevelEnabled('debug')) {
|
|
308
|
-
logger.debug('Emitting tableStateChange', currentState);
|
|
309
|
-
}
|
|
310
|
-
onDataStateChange === null || onDataStateChange === void 0 ? void 0 : onDataStateChange(currentState);
|
|
311
|
-
}, [
|
|
312
|
-
onDataStateChange,
|
|
313
|
-
globalFilter,
|
|
314
|
-
columnFilter,
|
|
315
|
-
sorting,
|
|
316
|
-
pagination,
|
|
317
|
-
columnOrder,
|
|
318
|
-
columnPinning,
|
|
319
|
-
columnVisibility,
|
|
320
|
-
columnSizing,
|
|
321
|
-
logger,
|
|
322
|
-
]);
|
|
323
291
|
const handleSelectionStateChange = (0, react_1.useCallback)((updaterOrValue) => {
|
|
324
292
|
setSelectionState((prevState) => {
|
|
325
|
-
const
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
setTimeout(() => {
|
|
329
|
-
if (onSelectionChange) {
|
|
330
|
-
onSelectionChange(newSelectionState);
|
|
331
|
-
}
|
|
332
|
-
if (onDataStateChange) {
|
|
333
|
-
tableStateChange({ selectionState: newSelectionState });
|
|
334
|
-
}
|
|
335
|
-
}, 0);
|
|
336
|
-
return newSelectionState;
|
|
293
|
+
const next = typeof updaterOrValue === 'function' ? updaterOrValue(prevState) : updaterOrValue;
|
|
294
|
+
onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange(next);
|
|
295
|
+
return next;
|
|
337
296
|
});
|
|
338
|
-
}, [onSelectionChange
|
|
297
|
+
}, [onSelectionChange]);
|
|
339
298
|
const handleColumnFilterStateChange = (0, react_1.useCallback)((filterState) => {
|
|
340
299
|
if (!filterState || typeof filterState !== 'object')
|
|
341
300
|
return;
|
|
342
301
|
setColumnFilter(filterState);
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
if (onDataStateChange) {
|
|
347
|
-
setTimeout(() => tableStateChange({ columnFilter: filterState }), 0);
|
|
348
|
-
}
|
|
349
|
-
}, [onColumnFiltersChange, onDataStateChange, tableStateChange]);
|
|
302
|
+
onColumnFiltersChange === null || onColumnFiltersChange === void 0 ? void 0 : onColumnFiltersChange(filterState);
|
|
303
|
+
return filterState;
|
|
304
|
+
}, [onColumnFiltersChange]);
|
|
350
305
|
const resetPageToFirst = (0, react_1.useCallback)(() => {
|
|
351
306
|
if (logger.isLevelEnabled('info')) {
|
|
352
307
|
logger.info('Resetting to first page due to state change', {
|
|
@@ -360,40 +315,17 @@ logging, }, ref) {
|
|
|
360
315
|
return newPagination;
|
|
361
316
|
}, [pagination, logger, onPaginationChange]);
|
|
362
317
|
const handleSortingChange = (0, react_1.useCallback)((updaterOrValue) => {
|
|
363
|
-
|
|
364
|
-
? updaterOrValue(
|
|
365
|
-
:
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
logger.debug('Sorting change applied', {
|
|
371
|
-
sorting: newSorting,
|
|
372
|
-
serverMode: isServerMode,
|
|
373
|
-
serverSorting: isServerSorting,
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
if (isServerMode || isServerSorting) {
|
|
377
|
-
const pagination = resetPageToFirst();
|
|
378
|
-
if (logger.isLevelEnabled('debug')) {
|
|
379
|
-
logger.debug('Sorting change triggered server fetch', { pagination, sorting: newSorting });
|
|
318
|
+
setSorting((prev) => {
|
|
319
|
+
const next = typeof updaterOrValue === 'function' ? updaterOrValue(prev) : updaterOrValue;
|
|
320
|
+
const cleaned = next.filter((s) => s === null || s === void 0 ? void 0 : s.id);
|
|
321
|
+
onSortingChange === null || onSortingChange === void 0 ? void 0 : onSortingChange(cleaned);
|
|
322
|
+
const nextPagination = resetPageToFirst();
|
|
323
|
+
if (isServerMode || isServerSorting) {
|
|
324
|
+
fetchData({ sorting: cleaned, pagination: nextPagination }, { delay: 0 });
|
|
380
325
|
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
pagination,
|
|
385
|
-
});
|
|
386
|
-
}
|
|
387
|
-
else if (onDataStateChange) {
|
|
388
|
-
const pagination = resetPageToFirst();
|
|
389
|
-
setTimeout(() => {
|
|
390
|
-
if (logger.isLevelEnabled('debug')) {
|
|
391
|
-
logger.debug('Sorting change notified client state change', { pagination, sorting: newSorting });
|
|
392
|
-
}
|
|
393
|
-
tableStateChange({ sorting: newSorting, pagination });
|
|
394
|
-
}, 0);
|
|
395
|
-
}
|
|
396
|
-
}, [sorting, onSortingChange, logger, isServerMode, isServerSorting, onDataStateChange, resetPageToFirst, tableStateChange, fetchData]);
|
|
326
|
+
return cleaned;
|
|
327
|
+
});
|
|
328
|
+
}, [onSortingChange, isServerMode, isServerSorting, resetPageToFirst, fetchData]);
|
|
397
329
|
const handleColumnOrderChange = (0, react_1.useCallback)((updatedColumnOrder) => {
|
|
398
330
|
const newColumnOrder = typeof updatedColumnOrder === 'function'
|
|
399
331
|
? updatedColumnOrder(columnOrder)
|
|
@@ -403,131 +335,52 @@ logging, }, ref) {
|
|
|
403
335
|
onColumnDragEnd(newColumnOrder);
|
|
404
336
|
}
|
|
405
337
|
}, [onColumnDragEnd, columnOrder]);
|
|
406
|
-
const handleColumnPinningChange = (0, react_1.useCallback)((
|
|
407
|
-
|
|
408
|
-
?
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
}, [onColumnPinningChange, columnPinning]);
|
|
338
|
+
const handleColumnPinningChange = (0, react_1.useCallback)((updater) => {
|
|
339
|
+
setColumnPinning((prev) => {
|
|
340
|
+
const next = typeof updater === "function" ? updater(prev) : updater;
|
|
341
|
+
// keep direct callback here (optional)
|
|
342
|
+
onColumnPinningChange === null || onColumnPinningChange === void 0 ? void 0 : onColumnPinningChange(next);
|
|
343
|
+
return next;
|
|
344
|
+
});
|
|
345
|
+
}, [onColumnPinningChange]);
|
|
415
346
|
// Column visibility change handler - same pattern as column order
|
|
416
347
|
const handleColumnVisibilityChange = (0, react_1.useCallback)((updater) => {
|
|
417
|
-
|
|
418
|
-
? updater(
|
|
419
|
-
:
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
onColumnVisibilityChange(newVisibility);
|
|
424
|
-
}, 0);
|
|
425
|
-
}
|
|
426
|
-
if (onDataStateChange) {
|
|
427
|
-
setTimeout(() => {
|
|
428
|
-
tableStateChange({ columnVisibility: newVisibility });
|
|
429
|
-
}, 0);
|
|
430
|
-
}
|
|
431
|
-
}, [onColumnVisibilityChange, onDataStateChange, tableStateChange, columnVisibility]);
|
|
348
|
+
setColumnVisibility((prev) => {
|
|
349
|
+
const next = typeof updater === 'function' ? updater(prev) : updater;
|
|
350
|
+
onColumnVisibilityChange === null || onColumnVisibilityChange === void 0 ? void 0 : onColumnVisibilityChange(next);
|
|
351
|
+
return next;
|
|
352
|
+
});
|
|
353
|
+
}, [onColumnVisibilityChange]);
|
|
432
354
|
// Column sizing change handler - same pattern as column order
|
|
433
355
|
const handleColumnSizingChange = (0, react_1.useCallback)((updater) => {
|
|
434
|
-
|
|
435
|
-
? updater(
|
|
436
|
-
:
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
onColumnSizingChange(newSizing);
|
|
441
|
-
}, 0);
|
|
442
|
-
}
|
|
443
|
-
if (onDataStateChange) {
|
|
444
|
-
setTimeout(() => {
|
|
445
|
-
tableStateChange({ columnSizing: newSizing });
|
|
446
|
-
}, 0);
|
|
447
|
-
}
|
|
448
|
-
}, [onColumnSizingChange, onDataStateChange, tableStateChange, columnSizing]);
|
|
356
|
+
setColumnSizing((prev) => {
|
|
357
|
+
const next = typeof updater === 'function' ? updater(prev) : updater;
|
|
358
|
+
onColumnSizingChange === null || onColumnSizingChange === void 0 ? void 0 : onColumnSizingChange(next);
|
|
359
|
+
return next;
|
|
360
|
+
});
|
|
361
|
+
}, [onColumnSizingChange]);
|
|
449
362
|
const handlePaginationChange = (0, react_1.useCallback)((updater) => {
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
next:
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
setPagination(newPagination);
|
|
460
|
-
onPaginationChange === null || onPaginationChange === void 0 ? void 0 : onPaginationChange(newPagination);
|
|
461
|
-
if (logger.isLevelEnabled('debug')) {
|
|
462
|
-
logger.debug('Pagination state updated', newPagination);
|
|
463
|
-
}
|
|
464
|
-
// Notify state change and fetch data if needed
|
|
465
|
-
if (isServerMode || isServerPagination) {
|
|
466
|
-
setTimeout(() => {
|
|
467
|
-
if (logger.isLevelEnabled('debug')) {
|
|
468
|
-
logger.debug('Notifying server-side pagination change', newPagination);
|
|
469
|
-
}
|
|
470
|
-
tableStateChange({ pagination: newPagination });
|
|
471
|
-
fetchData({ pagination: newPagination });
|
|
472
|
-
}, 0);
|
|
473
|
-
}
|
|
474
|
-
else if (onDataStateChange) {
|
|
475
|
-
setTimeout(() => {
|
|
476
|
-
if (logger.isLevelEnabled('debug')) {
|
|
477
|
-
logger.debug('Notifying client-side pagination change', newPagination);
|
|
478
|
-
}
|
|
479
|
-
tableStateChange({ pagination: newPagination });
|
|
480
|
-
}, 0);
|
|
481
|
-
}
|
|
482
|
-
}, [
|
|
483
|
-
pagination,
|
|
484
|
-
isServerMode,
|
|
485
|
-
isServerPagination,
|
|
486
|
-
onDataStateChange,
|
|
487
|
-
fetchData,
|
|
488
|
-
tableStateChange,
|
|
489
|
-
logger,
|
|
490
|
-
onPaginationChange,
|
|
491
|
-
]);
|
|
363
|
+
setPagination((prev) => {
|
|
364
|
+
const next = typeof updater === 'function' ? updater(prev) : updater;
|
|
365
|
+
onPaginationChange === null || onPaginationChange === void 0 ? void 0 : onPaginationChange(next);
|
|
366
|
+
if (isServerMode || isServerPagination) {
|
|
367
|
+
fetchData({ pagination: next }, { delay: 0 });
|
|
368
|
+
}
|
|
369
|
+
return next;
|
|
370
|
+
});
|
|
371
|
+
}, [isServerMode, isServerPagination, fetchData, onPaginationChange]);
|
|
492
372
|
const handleGlobalFilterChange = (0, react_1.useCallback)((updaterOrValue) => {
|
|
493
|
-
|
|
494
|
-
? updaterOrValue(
|
|
495
|
-
:
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
if (isServerMode || isServerFiltering) {
|
|
505
|
-
const pagination = resetPageToFirst();
|
|
506
|
-
setTimeout(() => {
|
|
507
|
-
if (logger.isLevelEnabled('debug')) {
|
|
508
|
-
logger.debug('Global filter change triggering server fetch', {
|
|
509
|
-
pagination,
|
|
510
|
-
value: newFilter,
|
|
511
|
-
});
|
|
512
|
-
}
|
|
513
|
-
tableStateChange({ globalFilter: newFilter, pagination });
|
|
514
|
-
fetchData({ globalFilter: newFilter, pagination });
|
|
515
|
-
}, 0);
|
|
516
|
-
}
|
|
517
|
-
else if (onDataStateChange) {
|
|
518
|
-
const pagination = resetPageToFirst();
|
|
519
|
-
setTimeout(() => {
|
|
520
|
-
if (logger.isLevelEnabled('debug')) {
|
|
521
|
-
logger.debug('Global filter change notifying client listeners', {
|
|
522
|
-
pagination,
|
|
523
|
-
value: newFilter,
|
|
524
|
-
});
|
|
525
|
-
}
|
|
526
|
-
tableStateChange({ globalFilter: newFilter, pagination });
|
|
527
|
-
}, 0);
|
|
528
|
-
}
|
|
529
|
-
onGlobalFilterChange === null || onGlobalFilterChange === void 0 ? void 0 : onGlobalFilterChange(newFilter);
|
|
530
|
-
}, [globalFilter, logger, isServerMode, isServerFiltering, onDataStateChange, onGlobalFilterChange, resetPageToFirst, tableStateChange, fetchData]);
|
|
373
|
+
setGlobalFilter((prev) => {
|
|
374
|
+
const next = typeof updaterOrValue === 'function' ? updaterOrValue(prev) : updaterOrValue;
|
|
375
|
+
onGlobalFilterChange === null || onGlobalFilterChange === void 0 ? void 0 : onGlobalFilterChange(next);
|
|
376
|
+
if (isServerMode || isServerFiltering) {
|
|
377
|
+
const nextPagination = { pageIndex: 0, pageSize: pagination.pageSize };
|
|
378
|
+
setPagination(nextPagination);
|
|
379
|
+
fetchData({ globalFilter: next, pagination: nextPagination }, { delay: 0 });
|
|
380
|
+
}
|
|
381
|
+
return next;
|
|
382
|
+
});
|
|
383
|
+
}, [isServerMode, isServerFiltering, onGlobalFilterChange, fetchData, pagination.pageSize]);
|
|
531
384
|
const onColumnFilterChangeHandler = (0, react_1.useCallback)((updater) => {
|
|
532
385
|
const currentState = columnFilter;
|
|
533
386
|
const newState = typeof updater === 'function'
|
|
@@ -544,22 +397,13 @@ logging, }, ref) {
|
|
|
544
397
|
const onColumnFilterApplyHandler = (0, react_1.useCallback)((appliedState) => {
|
|
545
398
|
const pagination = resetPageToFirst();
|
|
546
399
|
if (isServerFiltering) {
|
|
547
|
-
tableStateChange({
|
|
548
|
-
columnFilter: appliedState,
|
|
549
|
-
pagination,
|
|
550
|
-
});
|
|
551
400
|
fetchData({
|
|
552
401
|
columnFilter: appliedState,
|
|
553
402
|
pagination,
|
|
554
403
|
});
|
|
555
404
|
}
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
}
|
|
559
|
-
setTimeout(() => {
|
|
560
|
-
onColumnFiltersChange === null || onColumnFiltersChange === void 0 ? void 0 : onColumnFiltersChange(appliedState);
|
|
561
|
-
}, 0);
|
|
562
|
-
}, [resetPageToFirst, isServerFiltering, onDataStateChange, tableStateChange, fetchData, onColumnFiltersChange]);
|
|
405
|
+
onColumnFiltersChange === null || onColumnFiltersChange === void 0 ? void 0 : onColumnFiltersChange(appliedState);
|
|
406
|
+
}, [resetPageToFirst, isServerFiltering, fetchData, onColumnFiltersChange]);
|
|
563
407
|
// -------------------------------
|
|
564
408
|
// Table creation (after callbacks/memo)
|
|
565
409
|
// -------------------------------
|
|
@@ -603,7 +447,8 @@ logging, }, ref) {
|
|
|
603
447
|
getCoreRowModel: (0, react_table_1.getCoreRowModel)(),
|
|
604
448
|
...(enableSorting ? { getSortedRowModel: (0, react_table_1.getSortedRowModel)() } : {}),
|
|
605
449
|
...(enableColumnFilter || enableGlobalFilter ? { getFilteredRowModel: (0, column_filter_feature_1.getCombinedFilteredRowModel)() } : {}),
|
|
606
|
-
|
|
450
|
+
// Only use getPaginationRowModel for client-side pagination
|
|
451
|
+
...(enablePagination && !isServerPagination ? { getPaginationRowModel: (0, react_table_1.getPaginationRowModel)() } : {}),
|
|
607
452
|
// Sorting
|
|
608
453
|
enableSorting: enableSorting,
|
|
609
454
|
manualSorting: isServerSorting,
|
|
@@ -647,11 +492,7 @@ logging, }, ref) {
|
|
|
647
492
|
// -------------------------------
|
|
648
493
|
// Note: globalFilter is needed in dependencies to trigger recalculation when filter changes
|
|
649
494
|
// The table object is stable, so we need to depend on the filter state directly
|
|
650
|
-
const rows =
|
|
651
|
-
const rowModel = table.getRowModel();
|
|
652
|
-
return (rowModel === null || rowModel === void 0 ? void 0 : rowModel.rows) || [];
|
|
653
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
654
|
-
}, [table, tableData, globalFilter, enableGlobalFilter, enableColumnFilter, enablePagination]);
|
|
495
|
+
const rows = table.getRowModel().rows;
|
|
655
496
|
const rowVirtualizer = (0, react_virtual_1.useVirtualizer)({
|
|
656
497
|
count: rows.length,
|
|
657
498
|
getScrollElement: () => tableContainerRef.current,
|
|
@@ -713,502 +554,526 @@ logging, }, ref) {
|
|
|
713
554
|
setColumnOrder(initialOrder);
|
|
714
555
|
}
|
|
715
556
|
}, [enableColumnDragging, enhancedColumns, columnOrder.length]);
|
|
716
|
-
const
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
557
|
+
const lastSentRef = (0, react_1.useRef)("");
|
|
558
|
+
const emitTableState = (0, react_1.useCallback)(() => {
|
|
559
|
+
if (!onDataStateChange)
|
|
560
|
+
return;
|
|
561
|
+
const live = table.getState();
|
|
562
|
+
// only keep what you persist/store
|
|
563
|
+
const payload = {
|
|
564
|
+
sorting: live.sorting,
|
|
565
|
+
pagination: live.pagination,
|
|
566
|
+
globalFilter: live.globalFilter,
|
|
567
|
+
columnFilter: live.columnFilter,
|
|
568
|
+
columnVisibility: live.columnVisibility,
|
|
569
|
+
columnSizing: live.columnSizing,
|
|
570
|
+
columnOrder: live.columnOrder,
|
|
571
|
+
columnPinning: live.columnPinning,
|
|
572
|
+
};
|
|
573
|
+
const key = JSON.stringify(payload);
|
|
574
|
+
if (key === lastSentRef.current)
|
|
575
|
+
return;
|
|
576
|
+
lastSentRef.current = key;
|
|
577
|
+
onDataStateChange(payload);
|
|
578
|
+
}, [onDataStateChange, table]);
|
|
579
|
+
(0, react_1.useEffect)(() => {
|
|
580
|
+
emitTableState();
|
|
581
|
+
}, [
|
|
582
|
+
emitTableState,
|
|
583
|
+
sorting,
|
|
584
|
+
pagination,
|
|
585
|
+
globalFilter,
|
|
586
|
+
columnFilter,
|
|
587
|
+
columnVisibility,
|
|
588
|
+
columnSizing,
|
|
589
|
+
columnOrder,
|
|
590
|
+
columnPinning,
|
|
591
|
+
]);
|
|
592
|
+
const getResetState = (0, react_1.useCallback)(() => {
|
|
593
|
+
var _a;
|
|
594
|
+
const resetSorting = initialStateConfig.sorting || [];
|
|
595
|
+
const resetGlobalFilter = (_a = initialStateConfig.globalFilter) !== null && _a !== void 0 ? _a : '';
|
|
596
|
+
const resetColumnFilter = initialStateConfig.columnFilter || { filters: [], logic: 'AND', pendingFilters: [], pendingLogic: 'AND' };
|
|
597
|
+
const resetPagination = enablePagination
|
|
598
|
+
? (initialStateConfig.pagination || { pageIndex: 0, pageSize: 10 })
|
|
599
|
+
: undefined;
|
|
600
|
+
return {
|
|
601
|
+
sorting: resetSorting,
|
|
602
|
+
globalFilter: resetGlobalFilter,
|
|
603
|
+
columnFilter: resetColumnFilter,
|
|
604
|
+
...(resetPagination ? { pagination: resetPagination } : {}),
|
|
605
|
+
};
|
|
606
|
+
}, [initialStateConfig, enablePagination]);
|
|
607
|
+
const resetAllAndReload = (0, react_1.useCallback)(() => {
|
|
608
|
+
var _a;
|
|
609
|
+
const resetState = getResetState();
|
|
610
|
+
setSorting(resetState.sorting || []);
|
|
611
|
+
setGlobalFilter((_a = resetState.globalFilter) !== null && _a !== void 0 ? _a : '');
|
|
612
|
+
setColumnFilter(resetState.columnFilter);
|
|
613
|
+
if (resetState.pagination)
|
|
614
|
+
setPagination(resetState.pagination);
|
|
615
|
+
setSelectionState(initialSelectionState);
|
|
616
|
+
setExpanded({});
|
|
617
|
+
// layout state
|
|
618
|
+
setColumnVisibility(initialStateConfig.columnVisibility || {});
|
|
619
|
+
setColumnSizing(initialStateConfig.columnSizing || {});
|
|
620
|
+
setColumnOrder(initialStateConfig.columnOrder || []);
|
|
621
|
+
setColumnPinning(initialStateConfig.columnPinning || { left: [], right: [] });
|
|
622
|
+
if (onFetchData)
|
|
623
|
+
fetchData(resetState, { delay: 0 });
|
|
624
|
+
}, [getResetState, initialSelectionState, initialStateConfig, onFetchData, fetchData]);
|
|
625
|
+
const dataTableApi = (0, react_1.useMemo)(() => {
|
|
626
|
+
// helpers (avoid repeating boilerplate)
|
|
627
|
+
const buildInitialOrder = () => enhancedColumns.map((col, index) => {
|
|
628
|
+
if (col.id)
|
|
629
|
+
return col.id;
|
|
630
|
+
const anyCol = col;
|
|
631
|
+
if (anyCol.accessorKey && typeof anyCol.accessorKey === "string")
|
|
632
|
+
return anyCol.accessorKey;
|
|
633
|
+
return `column_${index}`;
|
|
634
|
+
});
|
|
635
|
+
const applyColumnOrder = (next) => {
|
|
636
|
+
// handleColumnOrderChange supports both Updater<ColumnOrderState> and array in your impl
|
|
637
|
+
handleColumnOrderChange(next);
|
|
638
|
+
};
|
|
639
|
+
const applyPinning = (next) => {
|
|
640
|
+
handleColumnPinningChange(next);
|
|
641
|
+
};
|
|
642
|
+
const applyVisibility = (next) => {
|
|
643
|
+
handleColumnVisibilityChange(next);
|
|
644
|
+
};
|
|
645
|
+
const applySizing = (next) => {
|
|
646
|
+
handleColumnSizingChange(next);
|
|
647
|
+
};
|
|
648
|
+
const applyPagination = (next) => {
|
|
649
|
+
handlePaginationChange(next);
|
|
650
|
+
};
|
|
651
|
+
const applySorting = (next) => {
|
|
652
|
+
handleSortingChange(next);
|
|
653
|
+
};
|
|
654
|
+
const applyGlobalFilter = (next) => {
|
|
655
|
+
handleGlobalFilterChange(next);
|
|
656
|
+
};
|
|
657
|
+
return {
|
|
658
|
+
table: {
|
|
659
|
+
getTable: () => table,
|
|
660
|
+
},
|
|
661
|
+
// -------------------------------
|
|
662
|
+
// Column Management
|
|
663
|
+
// -------------------------------
|
|
664
|
+
columnVisibility: {
|
|
665
|
+
showColumn: (columnId) => {
|
|
666
|
+
applyVisibility({ ...table.getState().columnVisibility, [columnId]: true });
|
|
667
|
+
},
|
|
668
|
+
hideColumn: (columnId) => {
|
|
669
|
+
applyVisibility({ ...table.getState().columnVisibility, [columnId]: false });
|
|
670
|
+
},
|
|
671
|
+
toggleColumn: (columnId) => {
|
|
672
|
+
var _a, _b;
|
|
673
|
+
const curr = (_b = (_a = table.getState().columnVisibility) === null || _a === void 0 ? void 0 : _a[columnId]) !== null && _b !== void 0 ? _b : true;
|
|
674
|
+
applyVisibility({ ...table.getState().columnVisibility, [columnId]: !curr });
|
|
675
|
+
},
|
|
676
|
+
showAllColumns: () => {
|
|
677
|
+
// set all known columns true
|
|
678
|
+
const all = {};
|
|
679
|
+
table.getAllLeafColumns().forEach((c) => (all[c.id] = true));
|
|
680
|
+
applyVisibility(all);
|
|
681
|
+
},
|
|
682
|
+
hideAllColumns: () => {
|
|
683
|
+
const all = {};
|
|
684
|
+
table.getAllLeafColumns().forEach((c) => (all[c.id] = false));
|
|
685
|
+
applyVisibility(all);
|
|
686
|
+
},
|
|
687
|
+
resetColumnVisibility: () => {
|
|
688
|
+
const initialVisibility = initialStateConfig.columnVisibility || {};
|
|
689
|
+
applyVisibility(initialVisibility);
|
|
690
|
+
},
|
|
691
|
+
},
|
|
692
|
+
// -------------------------------
|
|
693
|
+
// Column Ordering
|
|
694
|
+
// -------------------------------
|
|
695
|
+
columnOrdering: {
|
|
696
|
+
setColumnOrder: (nextOrder) => {
|
|
697
|
+
applyColumnOrder(nextOrder);
|
|
698
|
+
},
|
|
699
|
+
moveColumn: (columnId, toIndex) => {
|
|
700
|
+
var _a;
|
|
701
|
+
const currentOrder = (((_a = table.getState().columnOrder) === null || _a === void 0 ? void 0 : _a.length) ? table.getState().columnOrder : buildInitialOrder()) || [];
|
|
702
|
+
const fromIndex = currentOrder.indexOf(columnId);
|
|
703
|
+
if (fromIndex === -1)
|
|
704
|
+
return;
|
|
705
|
+
const next = [...currentOrder];
|
|
706
|
+
next.splice(fromIndex, 1);
|
|
707
|
+
next.splice(toIndex, 0, columnId);
|
|
708
|
+
applyColumnOrder(next);
|
|
709
|
+
},
|
|
710
|
+
resetColumnOrder: () => {
|
|
711
|
+
applyColumnOrder(buildInitialOrder());
|
|
712
|
+
},
|
|
713
|
+
},
|
|
714
|
+
// -------------------------------
|
|
715
|
+
// Column Pinning
|
|
716
|
+
// -------------------------------
|
|
717
|
+
columnPinning: {
|
|
718
|
+
pinColumnLeft: (columnId) => {
|
|
719
|
+
const current = table.getState().columnPinning || { left: [], right: [] };
|
|
720
|
+
const next = {
|
|
721
|
+
left: [...(current.left || []).filter((id) => id !== columnId), columnId],
|
|
722
|
+
right: (current.right || []).filter((id) => id !== columnId),
|
|
723
|
+
};
|
|
724
|
+
applyPinning(next);
|
|
725
|
+
},
|
|
726
|
+
pinColumnRight: (columnId) => {
|
|
727
|
+
const current = table.getState().columnPinning || { left: [], right: [] };
|
|
728
|
+
const next = {
|
|
729
|
+
left: (current.left || []).filter((id) => id !== columnId),
|
|
730
|
+
// keep your "prepend" behavior
|
|
731
|
+
right: [columnId, ...(current.right || []).filter((id) => id !== columnId)],
|
|
732
|
+
};
|
|
733
|
+
applyPinning(next);
|
|
734
|
+
},
|
|
735
|
+
unpinColumn: (columnId) => {
|
|
736
|
+
const current = table.getState().columnPinning || { left: [], right: [] };
|
|
737
|
+
const next = {
|
|
738
|
+
left: (current.left || []).filter((id) => id !== columnId),
|
|
739
|
+
right: (current.right || []).filter((id) => id !== columnId),
|
|
740
|
+
};
|
|
741
|
+
applyPinning(next);
|
|
742
|
+
},
|
|
743
|
+
setPinning: (pinning) => {
|
|
744
|
+
applyPinning(pinning);
|
|
745
|
+
},
|
|
746
|
+
resetColumnPinning: () => {
|
|
747
|
+
const initialPinning = initialStateConfig.columnPinning || { left: [], right: [] };
|
|
748
|
+
applyPinning(initialPinning);
|
|
749
|
+
},
|
|
750
|
+
},
|
|
751
|
+
// -------------------------------
|
|
752
|
+
// Column Resizing
|
|
753
|
+
// -------------------------------
|
|
754
|
+
columnResizing: {
|
|
755
|
+
resizeColumn: (columnId, width) => {
|
|
756
|
+
const currentSizing = table.getState().columnSizing || {};
|
|
757
|
+
applySizing({ ...currentSizing, [columnId]: width });
|
|
758
|
+
},
|
|
759
|
+
autoSizeColumn: (columnId) => {
|
|
760
|
+
// safe to call tanstack helper; it will feed into onColumnSizingChange if wired,
|
|
761
|
+
// but since you're controlled, we still prefer to update through handler:
|
|
762
|
+
const col = table.getColumn(columnId);
|
|
763
|
+
if (!col)
|
|
764
|
+
return;
|
|
765
|
+
col.resetSize();
|
|
766
|
+
// after resetSize, read state and emit via handler so controlled stays synced
|
|
767
|
+
applySizing({ ...(table.getState().columnSizing || {}) });
|
|
768
|
+
},
|
|
769
|
+
autoSizeAllColumns: () => {
|
|
770
|
+
const initialSizing = initialStateConfig.columnSizing || {};
|
|
771
|
+
applySizing(initialSizing);
|
|
772
|
+
},
|
|
773
|
+
resetColumnSizing: () => {
|
|
774
|
+
const initialSizing = initialStateConfig.columnSizing || {};
|
|
775
|
+
applySizing(initialSizing);
|
|
776
|
+
},
|
|
777
|
+
},
|
|
778
|
+
// -------------------------------
|
|
779
|
+
// Filtering
|
|
780
|
+
// -------------------------------
|
|
781
|
+
filtering: {
|
|
782
|
+
setGlobalFilter: (filter) => {
|
|
783
|
+
applyGlobalFilter(filter);
|
|
784
|
+
},
|
|
785
|
+
clearGlobalFilter: () => {
|
|
786
|
+
applyGlobalFilter("");
|
|
787
|
+
},
|
|
788
|
+
setColumnFilters: (filters) => {
|
|
789
|
+
handleColumnFilterStateChange(filters);
|
|
790
|
+
},
|
|
791
|
+
addColumnFilter: (columnId, operator, value) => {
|
|
792
|
+
const newFilter = {
|
|
793
|
+
id: `filter_${Date.now()}`,
|
|
794
|
+
columnId,
|
|
795
|
+
operator,
|
|
796
|
+
value,
|
|
797
|
+
};
|
|
798
|
+
const current = table.getState().columnFilter;
|
|
799
|
+
const currentFilters = (current === null || current === void 0 ? void 0 : current.filters) || [];
|
|
800
|
+
const nextFilters = [...currentFilters, newFilter];
|
|
801
|
+
handleColumnFilterStateChange({
|
|
802
|
+
filters: nextFilters,
|
|
803
|
+
logic: current === null || current === void 0 ? void 0 : current.logic,
|
|
804
|
+
pendingFilters: (current === null || current === void 0 ? void 0 : current.pendingFilters) || [],
|
|
805
|
+
pendingLogic: (current === null || current === void 0 ? void 0 : current.pendingLogic) || "AND",
|
|
806
|
+
});
|
|
807
|
+
if (logger.isLevelEnabled("debug")) {
|
|
808
|
+
logger.debug(`Adding column filter ${columnId} ${operator} ${value}`, nextFilters);
|
|
769
809
|
}
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
newPinning.right = (newPinning.right || []).filter(id => id !== columnId);
|
|
784
|
-
// Add to left if not exists
|
|
785
|
-
newPinning.left = [...(newPinning.left || []).filter(id => id !== columnId), columnId];
|
|
786
|
-
table.setColumnPinning(newPinning);
|
|
787
|
-
},
|
|
788
|
-
pinColumnRight: (columnId) => {
|
|
789
|
-
const currentPinning = table.getState().columnPinning;
|
|
790
|
-
const newPinning = { ...currentPinning };
|
|
791
|
-
// Remove from left if exists
|
|
792
|
-
newPinning.left = (newPinning.left || []).filter(id => id !== columnId);
|
|
793
|
-
// Add to right if not exists - prepend to beginning (appears rightmost to leftmost)
|
|
794
|
-
// First column pinned appears rightmost, second appears to its left, etc.
|
|
795
|
-
newPinning.right = [columnId, ...(newPinning.right || []).filter(id => id !== columnId)];
|
|
796
|
-
table.setColumnPinning(newPinning);
|
|
797
|
-
},
|
|
798
|
-
unpinColumn: (columnId) => {
|
|
799
|
-
const currentPinning = table.getState().columnPinning;
|
|
800
|
-
const newPinning = {
|
|
801
|
-
left: (currentPinning.left || []).filter(id => id !== columnId),
|
|
802
|
-
right: (currentPinning.right || []).filter(id => id !== columnId),
|
|
803
|
-
};
|
|
804
|
-
table.setColumnPinning(newPinning);
|
|
805
|
-
},
|
|
806
|
-
setPinning: (pinning) => {
|
|
807
|
-
table.setColumnPinning(pinning);
|
|
808
|
-
},
|
|
809
|
-
resetColumnPinning: () => {
|
|
810
|
-
const initialPinning = initialStateConfig.columnPinning || { left: [], right: [] };
|
|
811
|
-
table.setColumnPinning(initialPinning);
|
|
812
|
-
// Manually trigger handler to ensure callbacks are called
|
|
813
|
-
handleColumnPinningChange(initialPinning);
|
|
814
|
-
},
|
|
815
|
-
},
|
|
816
|
-
// Column Resizing
|
|
817
|
-
columnResizing: {
|
|
818
|
-
resizeColumn: (columnId, width) => {
|
|
819
|
-
// Use table's setColumnSizing method
|
|
820
|
-
const currentSizing = table.getState().columnSizing;
|
|
821
|
-
table.setColumnSizing({
|
|
822
|
-
...currentSizing,
|
|
823
|
-
[columnId]: width,
|
|
824
|
-
});
|
|
825
|
-
},
|
|
826
|
-
autoSizeColumn: (columnId) => {
|
|
827
|
-
var _a;
|
|
828
|
-
// TanStack doesn't have built-in auto-size, so reset to default
|
|
829
|
-
(_a = table.getColumn(columnId)) === null || _a === void 0 ? void 0 : _a.resetSize();
|
|
830
|
-
},
|
|
831
|
-
autoSizeAllColumns: () => {
|
|
832
|
-
const initialSizing = initialStateConfig.columnSizing || {};
|
|
833
|
-
table.setColumnSizing(initialSizing);
|
|
834
|
-
// Manually trigger handler to ensure callbacks are called
|
|
835
|
-
handleColumnSizingChange(initialSizing);
|
|
836
|
-
},
|
|
837
|
-
resetColumnSizing: () => {
|
|
838
|
-
const initialSizing = initialStateConfig.columnSizing || {};
|
|
839
|
-
table.setColumnSizing(initialSizing);
|
|
840
|
-
// Manually trigger handler to ensure callbacks are called
|
|
841
|
-
handleColumnSizingChange(initialSizing);
|
|
842
|
-
},
|
|
843
|
-
},
|
|
844
|
-
// Filtering
|
|
845
|
-
filtering: {
|
|
846
|
-
setGlobalFilter: (filter) => {
|
|
847
|
-
table.setGlobalFilter(filter);
|
|
848
|
-
},
|
|
849
|
-
clearGlobalFilter: () => {
|
|
850
|
-
table.setGlobalFilter('');
|
|
851
|
-
},
|
|
852
|
-
setColumnFilters: (filters) => {
|
|
853
|
-
handleColumnFilterStateChange(filters);
|
|
854
|
-
},
|
|
855
|
-
addColumnFilter: (columnId, operator, value) => {
|
|
856
|
-
const newFilter = {
|
|
857
|
-
id: `filter_${Date.now()}`,
|
|
858
|
-
columnId,
|
|
859
|
-
operator,
|
|
860
|
-
value,
|
|
861
|
-
};
|
|
862
|
-
const columnFilter = table.getState().columnFilter;
|
|
863
|
-
const currentFilters = columnFilter.filters || [];
|
|
864
|
-
const newFilters = [...currentFilters, newFilter];
|
|
865
|
-
handleColumnFilterStateChange({
|
|
866
|
-
filters: newFilters,
|
|
867
|
-
logic: columnFilter.logic,
|
|
868
|
-
pendingFilters: columnFilter.pendingFilters || [],
|
|
869
|
-
pendingLogic: columnFilter.pendingLogic || 'AND',
|
|
870
|
-
});
|
|
871
|
-
if (logger.isLevelEnabled('debug')) {
|
|
872
|
-
logger.debug(`Adding column filter ${columnId} ${operator} ${value}`, newFilters);
|
|
873
|
-
}
|
|
874
|
-
},
|
|
875
|
-
removeColumnFilter: (filterId) => {
|
|
876
|
-
const columnFilter = table.getState().columnFilter;
|
|
877
|
-
const currentFilters = columnFilter.filters || [];
|
|
878
|
-
const newFilters = currentFilters.filter((f) => f.id !== filterId);
|
|
879
|
-
handleColumnFilterStateChange({
|
|
880
|
-
filters: newFilters,
|
|
881
|
-
logic: columnFilter.logic,
|
|
882
|
-
pendingFilters: columnFilter.pendingFilters || [],
|
|
883
|
-
pendingLogic: columnFilter.pendingLogic || 'AND',
|
|
884
|
-
});
|
|
885
|
-
if (logger.isLevelEnabled('debug')) {
|
|
886
|
-
logger.debug(`Removing column filter ${filterId}`, newFilters);
|
|
887
|
-
}
|
|
888
|
-
},
|
|
889
|
-
clearAllFilters: () => {
|
|
890
|
-
table.setGlobalFilter('');
|
|
891
|
-
handleColumnFilterStateChange({
|
|
892
|
-
filters: [],
|
|
893
|
-
logic: 'AND',
|
|
894
|
-
pendingFilters: [],
|
|
895
|
-
pendingLogic: 'AND',
|
|
896
|
-
});
|
|
897
|
-
},
|
|
898
|
-
resetFilters: () => {
|
|
899
|
-
handleColumnFilterStateChange({
|
|
900
|
-
filters: [],
|
|
901
|
-
logic: 'AND',
|
|
902
|
-
pendingFilters: [],
|
|
903
|
-
pendingLogic: 'AND',
|
|
904
|
-
});
|
|
905
|
-
if (logger.isLevelEnabled('debug')) {
|
|
906
|
-
logger.debug('Resetting filters');
|
|
907
|
-
}
|
|
908
|
-
},
|
|
909
|
-
},
|
|
910
|
-
// Sorting
|
|
911
|
-
sorting: {
|
|
912
|
-
setSorting: (sortingState) => {
|
|
913
|
-
table.setSorting(sortingState);
|
|
914
|
-
if (logger.isLevelEnabled('debug')) {
|
|
915
|
-
logger.debug(`Setting sorting`, sortingState);
|
|
916
|
-
}
|
|
917
|
-
},
|
|
918
|
-
sortColumn: (columnId, direction) => {
|
|
919
|
-
const column = table.getColumn(columnId);
|
|
920
|
-
if (!column)
|
|
921
|
-
return;
|
|
922
|
-
if (direction === false) {
|
|
923
|
-
column.clearSorting();
|
|
924
|
-
}
|
|
925
|
-
else {
|
|
926
|
-
column.toggleSorting(direction === 'desc');
|
|
927
|
-
}
|
|
928
|
-
},
|
|
929
|
-
clearSorting: () => {
|
|
930
|
-
table.setSorting([]);
|
|
931
|
-
// Manually trigger handler to ensure callbacks are called
|
|
932
|
-
handleSortingChange([]);
|
|
933
|
-
},
|
|
934
|
-
resetSorting: () => {
|
|
935
|
-
const initialSorting = initialStateConfig.sorting || [];
|
|
936
|
-
table.setSorting(initialSorting);
|
|
937
|
-
// Manually trigger handler to ensure callbacks are called
|
|
938
|
-
handleSortingChange(initialSorting);
|
|
939
|
-
},
|
|
940
|
-
},
|
|
941
|
-
// Pagination
|
|
942
|
-
pagination: {
|
|
943
|
-
goToPage: (pageIndex) => {
|
|
944
|
-
table.setPageIndex(pageIndex);
|
|
945
|
-
if (logger.isLevelEnabled('debug')) {
|
|
946
|
-
logger.debug(`Going to page ${pageIndex}`);
|
|
947
|
-
}
|
|
948
|
-
},
|
|
949
|
-
nextPage: () => {
|
|
950
|
-
table.nextPage();
|
|
951
|
-
if (logger.isLevelEnabled('debug')) {
|
|
952
|
-
logger.debug('Next page');
|
|
953
|
-
}
|
|
954
|
-
},
|
|
955
|
-
previousPage: () => {
|
|
956
|
-
table.previousPage();
|
|
957
|
-
if (logger.isLevelEnabled('debug')) {
|
|
958
|
-
logger.debug('Previous page');
|
|
959
|
-
}
|
|
960
|
-
},
|
|
961
|
-
setPageSize: (pageSize) => {
|
|
962
|
-
table.setPageSize(pageSize);
|
|
963
|
-
if (logger.isLevelEnabled('debug')) {
|
|
964
|
-
logger.debug(`Setting page size to ${pageSize}`);
|
|
965
|
-
}
|
|
966
|
-
},
|
|
967
|
-
goToFirstPage: () => {
|
|
968
|
-
table.setPageIndex(0);
|
|
969
|
-
if (logger.isLevelEnabled('debug')) {
|
|
970
|
-
logger.debug('Going to first page');
|
|
971
|
-
}
|
|
972
|
-
},
|
|
973
|
-
goToLastPage: () => {
|
|
974
|
-
const pageCount = table.getPageCount();
|
|
975
|
-
if (pageCount > 0) {
|
|
976
|
-
table.setPageIndex(pageCount - 1);
|
|
977
|
-
if (logger.isLevelEnabled('debug')) {
|
|
978
|
-
logger.debug(`Going to last page ${pageCount - 1}`);
|
|
810
|
+
},
|
|
811
|
+
removeColumnFilter: (filterId) => {
|
|
812
|
+
const current = table.getState().columnFilter;
|
|
813
|
+
const currentFilters = (current === null || current === void 0 ? void 0 : current.filters) || [];
|
|
814
|
+
const nextFilters = currentFilters.filter((f) => f.id !== filterId);
|
|
815
|
+
handleColumnFilterStateChange({
|
|
816
|
+
filters: nextFilters,
|
|
817
|
+
logic: current === null || current === void 0 ? void 0 : current.logic,
|
|
818
|
+
pendingFilters: (current === null || current === void 0 ? void 0 : current.pendingFilters) || [],
|
|
819
|
+
pendingLogic: (current === null || current === void 0 ? void 0 : current.pendingLogic) || "AND",
|
|
820
|
+
});
|
|
821
|
+
if (logger.isLevelEnabled("debug")) {
|
|
822
|
+
logger.debug(`Removing column filter ${filterId}`, nextFilters);
|
|
979
823
|
}
|
|
980
|
-
}
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
getSelectedCount: () => table.getSelectedCount(),
|
|
1000
|
-
isRowSelected: (rowId) => table.getIsRowSelected(rowId) || false,
|
|
1001
|
-
},
|
|
1002
|
-
// Data Management
|
|
1003
|
-
data: {
|
|
1004
|
-
refresh: (resetPagination = false) => {
|
|
1005
|
-
var _a, _b, _c;
|
|
1006
|
-
const filters = table.getState();
|
|
1007
|
-
const pagination = {
|
|
1008
|
-
pageIndex: resetPagination ? 0 : ((_a = initialStateConfig.pagination) === null || _a === void 0 ? void 0 : _a.pageIndex) || 0,
|
|
1009
|
-
pageSize: ((_b = filters.pagination) === null || _b === void 0 ? void 0 : _b.pageSize) || ((_c = initialStateConfig.pagination) === null || _c === void 0 ? void 0 : _c.pageSize) || 10,
|
|
1010
|
-
};
|
|
1011
|
-
const allState = table.getState();
|
|
1012
|
-
setPagination(pagination);
|
|
1013
|
-
onDataStateChange === null || onDataStateChange === void 0 ? void 0 : onDataStateChange({ ...allState, pagination });
|
|
1014
|
-
fetchData === null || fetchData === void 0 ? void 0 : fetchData({ pagination });
|
|
1015
|
-
if (logger.isLevelEnabled('debug')) {
|
|
1016
|
-
logger.debug('Refreshing data using Ref', { pagination, allState });
|
|
1017
|
-
}
|
|
1018
|
-
},
|
|
1019
|
-
reload: () => {
|
|
1020
|
-
const allState = table.getState();
|
|
1021
|
-
onDataStateChange === null || onDataStateChange === void 0 ? void 0 : onDataStateChange(allState);
|
|
1022
|
-
fetchData === null || fetchData === void 0 ? void 0 : fetchData({});
|
|
1023
|
-
if (logger.isLevelEnabled('debug')) {
|
|
1024
|
-
logger.info('Reloading data', allState);
|
|
1025
|
-
}
|
|
1026
|
-
},
|
|
1027
|
-
// Data CRUD operations
|
|
1028
|
-
getAllData: () => {
|
|
1029
|
-
var _a;
|
|
1030
|
-
return ((_a = table.getRowModel().rows) === null || _a === void 0 ? void 0 : _a.map(row => row.original)) || [];
|
|
1031
|
-
},
|
|
1032
|
-
getRowData: (rowId) => {
|
|
1033
|
-
var _a, _b;
|
|
1034
|
-
return (_b = (_a = table.getRowModel().rows) === null || _a === void 0 ? void 0 : _a.find(row => String(row.original[idKey]) === rowId)) === null || _b === void 0 ? void 0 : _b.original;
|
|
1035
|
-
},
|
|
1036
|
-
getRowByIndex: (index) => {
|
|
1037
|
-
var _a, _b;
|
|
1038
|
-
return (_b = (_a = table.getRowModel().rows) === null || _a === void 0 ? void 0 : _a[index]) === null || _b === void 0 ? void 0 : _b.original;
|
|
1039
|
-
},
|
|
1040
|
-
updateRow: (rowId, updates) => {
|
|
1041
|
-
var _a;
|
|
1042
|
-
const newData = (_a = table.getRowModel().rows) === null || _a === void 0 ? void 0 : _a.map(row => String(row.original[idKey]) === rowId
|
|
1043
|
-
? {
|
|
1044
|
-
...row.original,
|
|
1045
|
-
...updates,
|
|
824
|
+
},
|
|
825
|
+
clearAllFilters: () => {
|
|
826
|
+
applyGlobalFilter("");
|
|
827
|
+
handleColumnFilterStateChange({
|
|
828
|
+
filters: [],
|
|
829
|
+
logic: "AND",
|
|
830
|
+
pendingFilters: [],
|
|
831
|
+
pendingLogic: "AND",
|
|
832
|
+
});
|
|
833
|
+
},
|
|
834
|
+
resetFilters: () => {
|
|
835
|
+
handleColumnFilterStateChange({
|
|
836
|
+
filters: [],
|
|
837
|
+
logic: "AND",
|
|
838
|
+
pendingFilters: [],
|
|
839
|
+
pendingLogic: "AND",
|
|
840
|
+
});
|
|
841
|
+
if (logger.isLevelEnabled("debug")) {
|
|
842
|
+
logger.debug("Resetting filters");
|
|
1046
843
|
}
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
844
|
+
},
|
|
845
|
+
},
|
|
846
|
+
// -------------------------------
|
|
847
|
+
// Sorting
|
|
848
|
+
// -------------------------------
|
|
849
|
+
sorting: {
|
|
850
|
+
setSorting: (sortingState) => {
|
|
851
|
+
applySorting(sortingState);
|
|
852
|
+
if (logger.isLevelEnabled("debug"))
|
|
853
|
+
logger.debug("Setting sorting", sortingState);
|
|
854
|
+
},
|
|
855
|
+
// NOTE: toggleSorting is okay, but can become "one behind" in controlled server mode.
|
|
856
|
+
// So we implement deterministic sorting through handler.
|
|
857
|
+
sortColumn: (columnId, direction) => {
|
|
858
|
+
const current = table.getState().sorting || [];
|
|
859
|
+
const filtered = current.filter((s) => s.id !== columnId);
|
|
860
|
+
if (direction === false) {
|
|
861
|
+
applySorting(filtered);
|
|
862
|
+
return;
|
|
1064
863
|
}
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
logger.debug
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
},
|
|
1114
|
-
// Bulk operations
|
|
1115
|
-
updateMultipleRows: (updates) => {
|
|
1116
|
-
var _a;
|
|
1117
|
-
const updateMap = new Map(updates.map(u => [u.rowId, u.data]));
|
|
1118
|
-
const newData = (_a = (table.getRowModel().rows || [])) === null || _a === void 0 ? void 0 : _a.map(row => {
|
|
1119
|
-
const rowId = String(row.original[idKey]);
|
|
1120
|
-
const updateData = updateMap.get(rowId);
|
|
1121
|
-
return updateData ? {
|
|
1122
|
-
...row.original,
|
|
1123
|
-
...updateData,
|
|
1124
|
-
} : row.original;
|
|
1125
|
-
});
|
|
1126
|
-
setServerData(newData || []);
|
|
1127
|
-
},
|
|
1128
|
-
insertMultipleRows: (newRows, startIndex) => {
|
|
1129
|
-
var _a;
|
|
1130
|
-
const newData = (_a = (table.getRowModel().rows || [])) === null || _a === void 0 ? void 0 : _a.map(row => row.original);
|
|
1131
|
-
if (startIndex !== undefined) {
|
|
1132
|
-
newData.splice(startIndex, 0, ...newRows);
|
|
1133
|
-
}
|
|
1134
|
-
else {
|
|
1135
|
-
newData.push(...newRows);
|
|
1136
|
-
}
|
|
1137
|
-
setServerData === null || setServerData === void 0 ? void 0 : setServerData(newData);
|
|
1138
|
-
},
|
|
1139
|
-
deleteMultipleRows: (rowIds) => {
|
|
1140
|
-
var _a, _b;
|
|
1141
|
-
const idsToDelete = new Set(rowIds);
|
|
1142
|
-
const newData = (_b = (_a = (table.getRowModel().rows || [])) === null || _a === void 0 ? void 0 : _a.filter(row => !idsToDelete.has(String(row.original[idKey])))) === null || _b === void 0 ? void 0 : _b.map(row => row.original);
|
|
1143
|
-
setServerData(newData);
|
|
1144
|
-
},
|
|
1145
|
-
// Field-specific updates
|
|
1146
|
-
updateField: (rowId, fieldName, value) => {
|
|
1147
|
-
var _a;
|
|
1148
|
-
const newData = (_a = (table.getRowModel().rows || [])) === null || _a === void 0 ? void 0 : _a.map(row => String(row.original[idKey]) === rowId
|
|
1149
|
-
? {
|
|
1150
|
-
...row.original,
|
|
1151
|
-
[fieldName]: value,
|
|
864
|
+
applySorting([{ id: columnId, desc: direction === "desc" }, ...filtered]);
|
|
865
|
+
},
|
|
866
|
+
clearSorting: () => {
|
|
867
|
+
applySorting([]);
|
|
868
|
+
},
|
|
869
|
+
resetSorting: () => {
|
|
870
|
+
const initialSorting = initialStateConfig.sorting || [];
|
|
871
|
+
applySorting(initialSorting);
|
|
872
|
+
},
|
|
873
|
+
},
|
|
874
|
+
// -------------------------------
|
|
875
|
+
// Pagination
|
|
876
|
+
// -------------------------------
|
|
877
|
+
pagination: {
|
|
878
|
+
goToPage: (pageIndex) => {
|
|
879
|
+
applyPagination((prev) => ({ ...prev, pageIndex }));
|
|
880
|
+
if (logger.isLevelEnabled("debug"))
|
|
881
|
+
logger.debug(`Going to page ${pageIndex}`);
|
|
882
|
+
},
|
|
883
|
+
nextPage: () => {
|
|
884
|
+
applyPagination((prev) => { var _a; return ({ ...prev, pageIndex: ((_a = prev === null || prev === void 0 ? void 0 : prev.pageIndex) !== null && _a !== void 0 ? _a : 0) + 1 }); });
|
|
885
|
+
if (logger.isLevelEnabled("debug"))
|
|
886
|
+
logger.debug("Next page");
|
|
887
|
+
},
|
|
888
|
+
previousPage: () => {
|
|
889
|
+
applyPagination((prev) => { var _a; return ({ ...prev, pageIndex: Math.max(0, ((_a = prev === null || prev === void 0 ? void 0 : prev.pageIndex) !== null && _a !== void 0 ? _a : 0) - 1) }); });
|
|
890
|
+
if (logger.isLevelEnabled("debug"))
|
|
891
|
+
logger.debug("Previous page");
|
|
892
|
+
},
|
|
893
|
+
setPageSize: (pageSize) => {
|
|
894
|
+
// usually want pageIndex reset
|
|
895
|
+
applyPagination(() => ({ pageIndex: 0, pageSize }));
|
|
896
|
+
if (logger.isLevelEnabled("debug"))
|
|
897
|
+
logger.debug(`Setting page size to ${pageSize}`);
|
|
898
|
+
},
|
|
899
|
+
goToFirstPage: () => {
|
|
900
|
+
applyPagination((prev) => ({ ...prev, pageIndex: 0 }));
|
|
901
|
+
if (logger.isLevelEnabled("debug"))
|
|
902
|
+
logger.debug("Going to first page");
|
|
903
|
+
},
|
|
904
|
+
goToLastPage: () => {
|
|
905
|
+
var _a, _b;
|
|
906
|
+
// pageCount can be derived; keep safe fallback
|
|
907
|
+
const pageCount = (_b = (_a = table.getPageCount) === null || _a === void 0 ? void 0 : _a.call(table)) !== null && _b !== void 0 ? _b : 0;
|
|
908
|
+
if (pageCount > 0) {
|
|
909
|
+
applyPagination((prev) => ({ ...prev, pageIndex: pageCount - 1 }));
|
|
910
|
+
if (logger.isLevelEnabled("debug"))
|
|
911
|
+
logger.debug(`Going to last page ${pageCount - 1}`);
|
|
1152
912
|
}
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
913
|
+
},
|
|
914
|
+
resetPagination: () => {
|
|
915
|
+
const initialPagination = initialStateConfig.pagination || { pageIndex: 0, pageSize: 10 };
|
|
916
|
+
applyPagination(initialPagination);
|
|
917
|
+
},
|
|
918
|
+
},
|
|
919
|
+
// -------------------------------
|
|
920
|
+
// Selection
|
|
921
|
+
// -------------------------------
|
|
922
|
+
selection: {
|
|
923
|
+
selectRow: (rowId) => { var _a; return (_a = table.selectRow) === null || _a === void 0 ? void 0 : _a.call(table, rowId); },
|
|
924
|
+
deselectRow: (rowId) => { var _a; return (_a = table.deselectRow) === null || _a === void 0 ? void 0 : _a.call(table, rowId); },
|
|
925
|
+
toggleRowSelection: (rowId) => { var _a; return (_a = table.toggleRowSelected) === null || _a === void 0 ? void 0 : _a.call(table, rowId); },
|
|
926
|
+
selectAll: () => { var _a; return (_a = table.selectAll) === null || _a === void 0 ? void 0 : _a.call(table); },
|
|
927
|
+
deselectAll: () => { var _a; return (_a = table.deselectAll) === null || _a === void 0 ? void 0 : _a.call(table); },
|
|
928
|
+
toggleSelectAll: () => { var _a; return (_a = table.toggleAllRowsSelected) === null || _a === void 0 ? void 0 : _a.call(table); },
|
|
929
|
+
getSelectionState: () => { var _a; return ((_a = table.getSelectionState) === null || _a === void 0 ? void 0 : _a.call(table)) || { ids: [], type: "include" }; },
|
|
930
|
+
getSelectedRows: () => table.getSelectedRows(),
|
|
931
|
+
getSelectedCount: () => table.getSelectedCount(),
|
|
932
|
+
isRowSelected: (rowId) => table.getIsRowSelected(rowId) || false,
|
|
933
|
+
},
|
|
934
|
+
// -------------------------------
|
|
935
|
+
// Data Management (kept same, but ensure state changes go through handlers)
|
|
936
|
+
// -------------------------------
|
|
937
|
+
data: {
|
|
938
|
+
refresh: (resetPagination = false) => {
|
|
939
|
+
var _a, _b, _c, _d;
|
|
940
|
+
const allState = table.getState();
|
|
941
|
+
const current = allState.pagination;
|
|
942
|
+
const nextPagination = {
|
|
943
|
+
pageIndex: resetPagination ? 0 : (_a = current === null || current === void 0 ? void 0 : current.pageIndex) !== null && _a !== void 0 ? _a : 0,
|
|
944
|
+
pageSize: (_d = (_b = current === null || current === void 0 ? void 0 : current.pageSize) !== null && _b !== void 0 ? _b : (_c = initialStateConfig.pagination) === null || _c === void 0 ? void 0 : _c.pageSize) !== null && _d !== void 0 ? _d : 10,
|
|
1163
945
|
};
|
|
946
|
+
// must go through handler so server fetch triggers
|
|
947
|
+
applyPagination(nextPagination);
|
|
948
|
+
// emit persisted state (your emitTableState effect will also do it)
|
|
949
|
+
onDataStateChange === null || onDataStateChange === void 0 ? void 0 : onDataStateChange({ ...allState, pagination: nextPagination });
|
|
950
|
+
fetchData === null || fetchData === void 0 ? void 0 : fetchData({ pagination: nextPagination });
|
|
951
|
+
if (logger.isLevelEnabled("debug")) {
|
|
952
|
+
logger.debug("Refreshing data", { nextPagination, allState });
|
|
953
|
+
}
|
|
954
|
+
},
|
|
955
|
+
reload: () => {
|
|
956
|
+
const allState = table.getState();
|
|
957
|
+
onDataStateChange === null || onDataStateChange === void 0 ? void 0 : onDataStateChange(allState);
|
|
958
|
+
fetchData === null || fetchData === void 0 ? void 0 : fetchData();
|
|
959
|
+
if (logger.isLevelEnabled("debug")) {
|
|
960
|
+
logger.info("Reloading data", allState);
|
|
961
|
+
}
|
|
962
|
+
},
|
|
963
|
+
resetAll: () => resetAllAndReload({ resetLayout: true }),
|
|
964
|
+
getAllData: () => { var _a; return ((_a = table.getRowModel().rows) === null || _a === void 0 ? void 0 : _a.map((row) => row.original)) || []; },
|
|
965
|
+
getRowData: (rowId) => { var _a, _b; return (_b = (_a = table.getRowModel().rows) === null || _a === void 0 ? void 0 : _a.find((row) => String(row.original[idKey]) === rowId)) === null || _b === void 0 ? void 0 : _b.original; },
|
|
966
|
+
getRowByIndex: (index) => { var _a, _b; return (_b = (_a = table.getRowModel().rows) === null || _a === void 0 ? void 0 : _a[index]) === null || _b === void 0 ? void 0 : _b.original; },
|
|
967
|
+
updateRow: (rowId, updates) => {
|
|
968
|
+
var _a;
|
|
969
|
+
const newData = (_a = table.getRowModel().rows) === null || _a === void 0 ? void 0 : _a.map((row) => String(row.original[idKey]) === rowId ? { ...row.original, ...updates } : row.original);
|
|
970
|
+
setServerData === null || setServerData === void 0 ? void 0 : setServerData(newData || []);
|
|
971
|
+
if (logger.isLevelEnabled("debug"))
|
|
972
|
+
logger.debug(`Updating row ${rowId}`, updates);
|
|
973
|
+
},
|
|
974
|
+
updateRowByIndex: (index, updates) => {
|
|
975
|
+
var _a;
|
|
976
|
+
const newData = ((_a = table.getRowModel().rows) === null || _a === void 0 ? void 0 : _a.map((row) => row.original)) || [];
|
|
977
|
+
if (newData[index]) {
|
|
978
|
+
newData[index] = { ...newData[index], ...updates };
|
|
979
|
+
setServerData(newData);
|
|
980
|
+
if (logger.isLevelEnabled("debug"))
|
|
981
|
+
logger.debug(`Updating row by index ${index}`, updates);
|
|
982
|
+
}
|
|
983
|
+
},
|
|
984
|
+
insertRow: (newRow, index) => {
|
|
985
|
+
var _a;
|
|
986
|
+
const newData = ((_a = table.getRowModel().rows) === null || _a === void 0 ? void 0 : _a.map((row) => row.original)) || [];
|
|
987
|
+
if (index !== undefined)
|
|
988
|
+
newData.splice(index, 0, newRow);
|
|
989
|
+
else
|
|
990
|
+
newData.push(newRow);
|
|
991
|
+
setServerData(newData || []);
|
|
992
|
+
if (logger.isLevelEnabled("debug"))
|
|
993
|
+
logger.debug("Inserting row", newRow);
|
|
994
|
+
},
|
|
995
|
+
deleteRow: (rowId) => {
|
|
996
|
+
const newData = (table.getRowModel().rows || []).filter((row) => String(row.original[idKey]) !== rowId);
|
|
997
|
+
setServerData === null || setServerData === void 0 ? void 0 : setServerData(newData.map((r) => r.original) || []);
|
|
998
|
+
if (logger.isLevelEnabled("debug"))
|
|
999
|
+
logger.debug(`Deleting row ${rowId}`);
|
|
1000
|
+
},
|
|
1001
|
+
deleteRowByIndex: (index) => {
|
|
1002
|
+
const newData = (table.getRowModel().rows || []).map((row) => row.original);
|
|
1003
|
+
newData.splice(index, 1);
|
|
1004
|
+
setServerData(newData);
|
|
1005
|
+
if (logger.isLevelEnabled("debug"))
|
|
1006
|
+
logger.debug(`Deleting row by index ${index}`);
|
|
1007
|
+
},
|
|
1008
|
+
deleteSelectedRows: () => {
|
|
1009
|
+
var _a, _b;
|
|
1010
|
+
const selectedRows = ((_a = table.getSelectedRows) === null || _a === void 0 ? void 0 : _a.call(table)) || [];
|
|
1011
|
+
if (selectedRows.length === 0)
|
|
1012
|
+
return;
|
|
1013
|
+
const selectedIds = new Set(selectedRows.map((row) => String(row.original[idKey])));
|
|
1014
|
+
const newData = (table.getRowModel().rows || [])
|
|
1015
|
+
.filter((row) => !selectedIds.has(String(row.original[idKey])))
|
|
1016
|
+
.map((row) => row.original);
|
|
1017
|
+
setServerData(newData);
|
|
1018
|
+
(_b = table.deselectAll) === null || _b === void 0 ? void 0 : _b.call(table);
|
|
1019
|
+
if (logger.isLevelEnabled("debug"))
|
|
1020
|
+
logger.debug("Deleting selected rows");
|
|
1021
|
+
},
|
|
1022
|
+
replaceAllData: (newData) => setServerData === null || setServerData === void 0 ? void 0 : setServerData(newData),
|
|
1023
|
+
updateMultipleRows: (updates) => {
|
|
1024
|
+
const updateMap = new Map(updates.map((u) => [u.rowId, u.data]));
|
|
1025
|
+
const newData = (table.getRowModel().rows || []).map((row) => {
|
|
1026
|
+
const rowId = String(row.original[idKey]);
|
|
1027
|
+
const updateData = updateMap.get(rowId);
|
|
1028
|
+
return updateData ? { ...row.original, ...updateData } : row.original;
|
|
1029
|
+
});
|
|
1030
|
+
setServerData(newData || []);
|
|
1031
|
+
},
|
|
1032
|
+
insertMultipleRows: (newRows, startIndex) => {
|
|
1033
|
+
const newData = (table.getRowModel().rows || []).map((row) => row.original);
|
|
1034
|
+
if (startIndex !== undefined)
|
|
1035
|
+
newData.splice(startIndex, 0, ...newRows);
|
|
1036
|
+
else
|
|
1037
|
+
newData.push(...newRows);
|
|
1164
1038
|
setServerData === null || setServerData === void 0 ? void 0 : setServerData(newData);
|
|
1165
|
-
}
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
table.
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
if (enablePagination) {
|
|
1204
|
-
table.setPagination(initialStateConfig.pagination || { pageIndex: 0, pageSize: 10 });
|
|
1205
|
-
}
|
|
1206
|
-
if (enableColumnPinning) {
|
|
1207
|
-
table.setColumnPinning(initialStateConfig.columnPinning || { left: [], right: [] });
|
|
1208
|
-
}
|
|
1209
|
-
},
|
|
1210
|
-
saveLayout: () => {
|
|
1211
|
-
return {
|
|
1039
|
+
},
|
|
1040
|
+
deleteMultipleRows: (rowIds) => {
|
|
1041
|
+
const idsToDelete = new Set(rowIds);
|
|
1042
|
+
const newData = (table.getRowModel().rows || [])
|
|
1043
|
+
.filter((row) => !idsToDelete.has(String(row.original[idKey])))
|
|
1044
|
+
.map((row) => row.original);
|
|
1045
|
+
setServerData(newData);
|
|
1046
|
+
},
|
|
1047
|
+
updateField: (rowId, fieldName, value) => {
|
|
1048
|
+
const newData = (table.getRowModel().rows || []).map((row) => String(row.original[idKey]) === rowId ? { ...row.original, [fieldName]: value } : row.original);
|
|
1049
|
+
setServerData === null || setServerData === void 0 ? void 0 : setServerData(newData);
|
|
1050
|
+
},
|
|
1051
|
+
updateFieldByIndex: (index, fieldName, value) => {
|
|
1052
|
+
const newData = (table.getRowModel().rows || []).map((row) => row.original);
|
|
1053
|
+
if (newData[index]) {
|
|
1054
|
+
newData[index] = { ...newData[index], [fieldName]: value };
|
|
1055
|
+
setServerData === null || setServerData === void 0 ? void 0 : setServerData(newData);
|
|
1056
|
+
}
|
|
1057
|
+
},
|
|
1058
|
+
findRows: (predicate) => (table.getRowModel().rows || []).filter((row) => predicate(row.original)).map((row) => row.original),
|
|
1059
|
+
findRowIndex: (predicate) => (table.getRowModel().rows || []).findIndex((row) => predicate(row.original)),
|
|
1060
|
+
getDataCount: () => (table.getRowModel().rows || []).length || 0,
|
|
1061
|
+
getFilteredDataCount: () => table.getFilteredRowModel().rows.length,
|
|
1062
|
+
},
|
|
1063
|
+
// -------------------------------
|
|
1064
|
+
// Layout Management
|
|
1065
|
+
// -------------------------------
|
|
1066
|
+
layout: {
|
|
1067
|
+
resetLayout: () => {
|
|
1068
|
+
var _a;
|
|
1069
|
+
// go through handlers so controlled state updates + emit works
|
|
1070
|
+
applySizing(initialStateConfig.columnSizing || {});
|
|
1071
|
+
applyVisibility(initialStateConfig.columnVisibility || {});
|
|
1072
|
+
applySorting(initialStateConfig.sorting || []);
|
|
1073
|
+
applyGlobalFilter((_a = initialStateConfig.globalFilter) !== null && _a !== void 0 ? _a : "");
|
|
1074
|
+
},
|
|
1075
|
+
resetAll: () => resetAllAndReload({ resetLayout: true }),
|
|
1076
|
+
saveLayout: () => ({
|
|
1212
1077
|
columnVisibility: table.getState().columnVisibility,
|
|
1213
1078
|
columnSizing: table.getState().columnSizing,
|
|
1214
1079
|
columnOrder: table.getState().columnOrder,
|
|
@@ -1217,132 +1082,156 @@ logging, }, ref) {
|
|
|
1217
1082
|
pagination: table.getState().pagination,
|
|
1218
1083
|
globalFilter: table.getState().globalFilter,
|
|
1219
1084
|
columnFilter: table.getState().columnFilter,
|
|
1220
|
-
}
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1085
|
+
}),
|
|
1086
|
+
restoreLayout: (layout) => {
|
|
1087
|
+
if (layout.columnVisibility)
|
|
1088
|
+
applyVisibility(layout.columnVisibility);
|
|
1089
|
+
if (layout.columnSizing)
|
|
1090
|
+
applySizing(layout.columnSizing);
|
|
1091
|
+
if (layout.columnOrder)
|
|
1092
|
+
applyColumnOrder(layout.columnOrder);
|
|
1093
|
+
if (layout.columnPinning)
|
|
1094
|
+
applyPinning(layout.columnPinning);
|
|
1095
|
+
if (layout.sorting)
|
|
1096
|
+
applySorting(layout.sorting);
|
|
1097
|
+
if (layout.pagination && enablePagination)
|
|
1098
|
+
applyPagination(layout.pagination);
|
|
1099
|
+
if (layout.globalFilter !== undefined)
|
|
1100
|
+
applyGlobalFilter(layout.globalFilter);
|
|
1101
|
+
if (layout.columnFilter)
|
|
1102
|
+
handleColumnFilterStateChange(layout.columnFilter);
|
|
1103
|
+
},
|
|
1104
|
+
},
|
|
1105
|
+
// -------------------------------
|
|
1106
|
+
// Table State
|
|
1107
|
+
// -------------------------------
|
|
1108
|
+
state: {
|
|
1109
|
+
getTableState: () => table.getState(),
|
|
1110
|
+
getCurrentFilters: () => table.getState().columnFilter,
|
|
1111
|
+
getCurrentSorting: () => table.getState().sorting,
|
|
1112
|
+
getCurrentPagination: () => table.getState().pagination,
|
|
1113
|
+
getCurrentSelection: () => { var _a; return (_a = table.getSelectionState) === null || _a === void 0 ? void 0 : _a.call(table); },
|
|
1114
|
+
},
|
|
1115
|
+
// -------------------------------
|
|
1116
|
+
// Export (unchanged mostly)
|
|
1117
|
+
// -------------------------------
|
|
1118
|
+
export: {
|
|
1119
|
+
exportCSV: async (options = {}) => {
|
|
1120
|
+
var _a;
|
|
1121
|
+
const { filename = exportFilename } = options;
|
|
1122
|
+
try {
|
|
1123
|
+
const controller = new AbortController();
|
|
1124
|
+
setExportController === null || setExportController === void 0 ? void 0 : setExportController(controller);
|
|
1125
|
+
if (dataMode === "server" && onServerExport) {
|
|
1126
|
+
const currentFilters = {
|
|
1127
|
+
globalFilter: table.getState().globalFilter,
|
|
1128
|
+
columnFilter: table.getState().columnFilter,
|
|
1129
|
+
sorting: table.getState().sorting,
|
|
1130
|
+
pagination: table.getState().pagination,
|
|
1131
|
+
};
|
|
1132
|
+
if (logger.isLevelEnabled("debug"))
|
|
1133
|
+
logger.debug("Server export CSV", { currentFilters });
|
|
1134
|
+
await (0, utils_1.exportServerData)(table, {
|
|
1135
|
+
format: "csv",
|
|
1136
|
+
filename,
|
|
1137
|
+
fetchData: (filters, selection) => onServerExport(filters, selection),
|
|
1138
|
+
currentFilters,
|
|
1139
|
+
selection: (_a = table.getSelectionState) === null || _a === void 0 ? void 0 : _a.call(table),
|
|
1140
|
+
onProgress: onExportProgress,
|
|
1141
|
+
onComplete: onExportComplete,
|
|
1142
|
+
onError: onExportError,
|
|
1143
|
+
});
|
|
1144
|
+
}
|
|
1145
|
+
else {
|
|
1146
|
+
await (0, utils_1.exportClientData)(table, {
|
|
1147
|
+
format: "csv",
|
|
1148
|
+
filename,
|
|
1149
|
+
onProgress: onExportProgress,
|
|
1150
|
+
onComplete: onExportComplete,
|
|
1151
|
+
onError: onExportError,
|
|
1152
|
+
});
|
|
1153
|
+
if (logger.isLevelEnabled("debug"))
|
|
1154
|
+
logger.debug("Client export CSV", filename);
|
|
1288
1155
|
}
|
|
1289
|
-
await (0, utils_1.exportServerData)(table, {
|
|
1290
|
-
format: 'csv',
|
|
1291
|
-
filename,
|
|
1292
|
-
fetchData: (filters, selection) => onServerExport(filters, selection),
|
|
1293
|
-
currentFilters,
|
|
1294
|
-
selection: (_a = table.getSelectionState) === null || _a === void 0 ? void 0 : _a.call(table),
|
|
1295
|
-
onProgress: onExportProgress,
|
|
1296
|
-
onComplete: onExportComplete,
|
|
1297
|
-
onError: onExportError,
|
|
1298
|
-
});
|
|
1299
1156
|
}
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1157
|
+
catch (error) {
|
|
1158
|
+
onExportError === null || onExportError === void 0 ? void 0 : onExportError({ message: error.message || "Export failed", code: "EXPORT_ERROR" });
|
|
1159
|
+
}
|
|
1160
|
+
finally {
|
|
1161
|
+
setExportController === null || setExportController === void 0 ? void 0 : setExportController(null);
|
|
1162
|
+
}
|
|
1163
|
+
},
|
|
1164
|
+
exportExcel: async (options = {}) => {
|
|
1165
|
+
var _a;
|
|
1166
|
+
const { filename = exportFilename } = options;
|
|
1167
|
+
try {
|
|
1168
|
+
const controller = new AbortController();
|
|
1169
|
+
setExportController === null || setExportController === void 0 ? void 0 : setExportController(controller);
|
|
1170
|
+
if (dataMode === "server" && onServerExport) {
|
|
1171
|
+
const currentFilters = {
|
|
1172
|
+
globalFilter: table.getState().globalFilter,
|
|
1173
|
+
columnFilter: table.getState().columnFilter,
|
|
1174
|
+
sorting: table.getState().sorting,
|
|
1175
|
+
pagination: table.getState().pagination,
|
|
1176
|
+
};
|
|
1177
|
+
if (logger.isLevelEnabled("debug"))
|
|
1178
|
+
logger.debug("Server export Excel", { currentFilters });
|
|
1179
|
+
await (0, utils_1.exportServerData)(table, {
|
|
1180
|
+
format: "excel",
|
|
1181
|
+
filename,
|
|
1182
|
+
fetchData: (filters, selection) => onServerExport(filters, selection),
|
|
1183
|
+
currentFilters,
|
|
1184
|
+
selection: (_a = table.getSelectionState) === null || _a === void 0 ? void 0 : _a.call(table),
|
|
1185
|
+
onProgress: onExportProgress,
|
|
1186
|
+
onComplete: onExportComplete,
|
|
1187
|
+
onError: onExportError,
|
|
1188
|
+
});
|
|
1189
|
+
}
|
|
1190
|
+
else {
|
|
1191
|
+
await (0, utils_1.exportClientData)(table, {
|
|
1192
|
+
format: "excel",
|
|
1193
|
+
filename,
|
|
1194
|
+
onProgress: onExportProgress,
|
|
1195
|
+
onComplete: onExportComplete,
|
|
1196
|
+
onError: onExportError,
|
|
1197
|
+
});
|
|
1198
|
+
if (logger.isLevelEnabled("debug"))
|
|
1199
|
+
logger.debug("Client export Excel", filename);
|
|
1311
1200
|
}
|
|
1312
1201
|
}
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1202
|
+
catch (error) {
|
|
1203
|
+
onExportError === null || onExportError === void 0 ? void 0 : onExportError({ message: error.message || "Export failed", code: "EXPORT_ERROR" });
|
|
1204
|
+
if (logger.isLevelEnabled("debug"))
|
|
1205
|
+
logger.debug("Server export Excel failed", error);
|
|
1206
|
+
}
|
|
1207
|
+
finally {
|
|
1208
|
+
setExportController === null || setExportController === void 0 ? void 0 : setExportController(null);
|
|
1209
|
+
}
|
|
1210
|
+
},
|
|
1211
|
+
exportServerData: async (options) => {
|
|
1212
|
+
var _a;
|
|
1213
|
+
const { format, filename = exportFilename, fetchData: fetchFn = onServerExport } = options;
|
|
1214
|
+
if (!fetchFn) {
|
|
1215
|
+
onExportError === null || onExportError === void 0 ? void 0 : onExportError({ message: "No server export function provided", code: "NO_SERVER_EXPORT" });
|
|
1216
|
+
if (logger.isLevelEnabled("debug"))
|
|
1217
|
+
logger.debug("Server export data failed", "No server export function provided");
|
|
1218
|
+
return;
|
|
1219
|
+
}
|
|
1220
|
+
try {
|
|
1221
|
+
const controller = new AbortController();
|
|
1222
|
+
setExportController === null || setExportController === void 0 ? void 0 : setExportController(controller);
|
|
1333
1223
|
const currentFilters = {
|
|
1334
1224
|
globalFilter: table.getState().globalFilter,
|
|
1335
1225
|
columnFilter: table.getState().columnFilter,
|
|
1336
1226
|
sorting: table.getState().sorting,
|
|
1337
1227
|
pagination: table.getState().pagination,
|
|
1338
1228
|
};
|
|
1339
|
-
if (logger.isLevelEnabled(
|
|
1340
|
-
logger.debug(
|
|
1341
|
-
}
|
|
1229
|
+
if (logger.isLevelEnabled("debug"))
|
|
1230
|
+
logger.debug("Server export data", { currentFilters });
|
|
1342
1231
|
await (0, utils_1.exportServerData)(table, {
|
|
1343
|
-
format
|
|
1232
|
+
format,
|
|
1344
1233
|
filename,
|
|
1345
|
-
fetchData: (filters, selection) =>
|
|
1234
|
+
fetchData: (filters, selection) => fetchFn(filters, selection),
|
|
1346
1235
|
currentFilters,
|
|
1347
1236
|
selection: (_a = table.getSelectionState) === null || _a === void 0 ? void 0 : _a.call(table),
|
|
1348
1237
|
onProgress: onExportProgress,
|
|
@@ -1350,116 +1239,52 @@ logging, }, ref) {
|
|
|
1350
1239
|
onError: onExportError,
|
|
1351
1240
|
});
|
|
1352
1241
|
}
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
filename,
|
|
1358
|
-
onProgress: onExportProgress,
|
|
1359
|
-
onComplete: onExportComplete,
|
|
1360
|
-
onError: onExportError,
|
|
1361
|
-
});
|
|
1362
|
-
if (logger.isLevelEnabled('debug')) {
|
|
1363
|
-
logger.debug('Client export Excel', filename);
|
|
1364
|
-
}
|
|
1242
|
+
catch (error) {
|
|
1243
|
+
onExportError === null || onExportError === void 0 ? void 0 : onExportError({ message: error.message || "Export failed", code: "EXPORT_ERROR" });
|
|
1244
|
+
if (logger.isLevelEnabled("debug"))
|
|
1245
|
+
logger.debug("Server export data failed", error);
|
|
1365
1246
|
}
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
onExportError === null || onExportError === void 0 ? void 0 : onExportError({
|
|
1369
|
-
message: error.message || 'Export failed',
|
|
1370
|
-
code: 'EXPORT_ERROR',
|
|
1371
|
-
});
|
|
1372
|
-
if (logger.isLevelEnabled('debug')) {
|
|
1373
|
-
logger.debug('Server export Excel failed', error);
|
|
1247
|
+
finally {
|
|
1248
|
+
setExportController === null || setExportController === void 0 ? void 0 : setExportController(null);
|
|
1374
1249
|
}
|
|
1375
|
-
}
|
|
1376
|
-
|
|
1250
|
+
},
|
|
1251
|
+
isExporting: () => isExporting || false,
|
|
1252
|
+
cancelExport: () => {
|
|
1253
|
+
exportController === null || exportController === void 0 ? void 0 : exportController.abort();
|
|
1377
1254
|
setExportController === null || setExportController === void 0 ? void 0 : setExportController(null);
|
|
1378
|
-
|
|
1255
|
+
if (logger.isLevelEnabled("debug"))
|
|
1256
|
+
logger.debug("Export cancelled");
|
|
1257
|
+
},
|
|
1379
1258
|
},
|
|
1380
|
-
|
|
1381
|
-
var _a;
|
|
1382
|
-
const { format, filename = exportFilename, fetchData = onServerExport, } = options;
|
|
1383
|
-
if (!fetchData) {
|
|
1384
|
-
onExportError === null || onExportError === void 0 ? void 0 : onExportError({
|
|
1385
|
-
message: 'No server export function provided',
|
|
1386
|
-
code: 'NO_SERVER_EXPORT',
|
|
1387
|
-
});
|
|
1388
|
-
if (logger.isLevelEnabled('debug')) {
|
|
1389
|
-
logger.debug('Server export data failed', 'No server export function provided');
|
|
1390
|
-
}
|
|
1391
|
-
return;
|
|
1392
|
-
}
|
|
1393
|
-
try {
|
|
1394
|
-
// Create abort controller for this export
|
|
1395
|
-
const controller = new AbortController();
|
|
1396
|
-
setExportController === null || setExportController === void 0 ? void 0 : setExportController(controller);
|
|
1397
|
-
const currentFilters = {
|
|
1398
|
-
globalFilter: table.getState().globalFilter,
|
|
1399
|
-
columnFilter: table.getState().columnFilter,
|
|
1400
|
-
sorting: table.getState().sorting,
|
|
1401
|
-
pagination: table.getState().pagination,
|
|
1402
|
-
};
|
|
1403
|
-
if (logger.isLevelEnabled('debug')) {
|
|
1404
|
-
logger.debug('Server export data', { currentFilters });
|
|
1405
|
-
}
|
|
1406
|
-
await (0, utils_1.exportServerData)(table, {
|
|
1407
|
-
format,
|
|
1408
|
-
filename,
|
|
1409
|
-
fetchData: (filters, selection) => fetchData(filters, selection),
|
|
1410
|
-
currentFilters,
|
|
1411
|
-
selection: (_a = table.getSelectionState) === null || _a === void 0 ? void 0 : _a.call(table),
|
|
1412
|
-
onProgress: onExportProgress,
|
|
1413
|
-
onComplete: onExportComplete,
|
|
1414
|
-
onError: onExportError,
|
|
1415
|
-
});
|
|
1416
|
-
}
|
|
1417
|
-
catch (error) {
|
|
1418
|
-
onExportError === null || onExportError === void 0 ? void 0 : onExportError({
|
|
1419
|
-
message: error.message || 'Export failed',
|
|
1420
|
-
code: 'EXPORT_ERROR',
|
|
1421
|
-
});
|
|
1422
|
-
if (logger.isLevelEnabled('debug')) {
|
|
1423
|
-
logger.debug('Server export data failed', error);
|
|
1424
|
-
}
|
|
1425
|
-
}
|
|
1426
|
-
finally {
|
|
1427
|
-
setExportController === null || setExportController === void 0 ? void 0 : setExportController(null);
|
|
1428
|
-
}
|
|
1429
|
-
},
|
|
1430
|
-
// Export state
|
|
1431
|
-
isExporting: () => isExporting || false,
|
|
1432
|
-
cancelExport: () => {
|
|
1433
|
-
exportController === null || exportController === void 0 ? void 0 : exportController.abort();
|
|
1434
|
-
setExportController === null || setExportController === void 0 ? void 0 : setExportController(null);
|
|
1435
|
-
if (logger.isLevelEnabled('debug')) {
|
|
1436
|
-
logger.debug('Export cancelled');
|
|
1437
|
-
}
|
|
1438
|
-
},
|
|
1439
|
-
},
|
|
1259
|
+
};
|
|
1440
1260
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1441
|
-
}
|
|
1261
|
+
}, [
|
|
1442
1262
|
table,
|
|
1443
1263
|
enhancedColumns,
|
|
1264
|
+
handleColumnOrderChange,
|
|
1265
|
+
handleColumnPinningChange,
|
|
1266
|
+
handleColumnVisibilityChange,
|
|
1267
|
+
handleColumnSizingChange,
|
|
1268
|
+
handlePaginationChange,
|
|
1269
|
+
handleSortingChange,
|
|
1270
|
+
handleGlobalFilterChange,
|
|
1444
1271
|
handleColumnFilterStateChange,
|
|
1272
|
+
initialStateConfig,
|
|
1273
|
+
enablePagination,
|
|
1445
1274
|
idKey,
|
|
1446
1275
|
onDataStateChange,
|
|
1447
1276
|
fetchData,
|
|
1448
|
-
|
|
1449
|
-
enablePagination,
|
|
1450
|
-
// Export dependencies
|
|
1277
|
+
// export
|
|
1451
1278
|
exportFilename,
|
|
1452
1279
|
onExportProgress,
|
|
1453
1280
|
onExportComplete,
|
|
1454
1281
|
onExportError,
|
|
1455
1282
|
onServerExport,
|
|
1456
1283
|
exportController,
|
|
1457
|
-
setExportController,
|
|
1458
1284
|
isExporting,
|
|
1459
1285
|
dataMode,
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
// Note: custom selection removed from dependency array
|
|
1286
|
+
logger,
|
|
1287
|
+
resetAllAndReload,
|
|
1463
1288
|
]);
|
|
1464
1289
|
internalApiRef.current = dataTableApi;
|
|
1465
1290
|
(0, react_1.useImperativeHandle)(ref, () => dataTableApi, [dataTableApi]);
|
|
@@ -1542,7 +1367,12 @@ logging, }, ref) {
|
|
|
1542
1367
|
// -------------------------------
|
|
1543
1368
|
return ((0, jsx_runtime_1.jsx)(data_table_context_1.DataTableProvider, { table: table, apiRef: internalApiRef, dataMode: dataMode, tableSize: tableSize, onTableSizeChange: (size) => {
|
|
1544
1369
|
setTableSize(size);
|
|
1545
|
-
}, columnFilter: columnFilter, onChangeColumnFilter: handleColumnFilterStateChange, slots: slots, slotProps: slotProps, isExporting: isExporting, exportController: exportController, onCancelExport: handleCancelExport, exportFilename: exportFilename, onExportProgress: onExportProgress, onExportComplete: onExportComplete, onExportError: onExportError, onServerExport: onServerExport, children: (0, jsx_runtime_1.jsxs)(RootComponent, { ...rootSlotProps, children: [(enableGlobalFilter || extraFilter) ? ((0, jsx_runtime_1.jsx)(ToolbarComponent, { extraFilter: extraFilter, enableGlobalFilter: enableGlobalFilter, enableColumnVisibility: enableColumnVisibility, enableColumnFilter: enableColumnFilter, enableExport: enableExport, enableReset: enableReset, enableTableSizeControl: enableTableSizeControl, enableColumnPinning: enableColumnPinning,
|
|
1370
|
+
}, columnFilter: columnFilter, onChangeColumnFilter: handleColumnFilterStateChange, slots: slots, slotProps: slotProps, isExporting: isExporting, exportController: exportController, onCancelExport: handleCancelExport, exportFilename: exportFilename, onExportProgress: onExportProgress, onExportComplete: onExportComplete, onExportError: onExportError, onServerExport: onServerExport, children: (0, jsx_runtime_1.jsxs)(RootComponent, { ...rootSlotProps, children: [(enableGlobalFilter || extraFilter) ? ((0, jsx_runtime_1.jsx)(ToolbarComponent, { extraFilter: extraFilter, enableGlobalFilter: enableGlobalFilter, enableColumnVisibility: enableColumnVisibility, enableColumnFilter: enableColumnFilter, enableExport: enableExport, enableReset: enableReset, enableTableSizeControl: enableTableSizeControl, enableColumnPinning: enableColumnPinning, enableRefresh: enableRefresh, ...toolbarSlotProps, refreshButtonProps: {
|
|
1371
|
+
loading: tableLoading, // disable while fetching
|
|
1372
|
+
showSpinnerWhileLoading: false,
|
|
1373
|
+
onRefresh: () => { var _a, _b, _c; return (_c = (_b = (_a = internalApiRef.current) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.refresh) === null || _c === void 0 ? void 0 : _c.call(_b, true); },
|
|
1374
|
+
...toolbarSlotProps.refreshButtonProps,
|
|
1375
|
+
} })) : null, enableBulkActions && enableRowSelection && isSomeRowsSelected ? ((0, jsx_runtime_1.jsx)(BulkActionsComponent, { selectionState: selectionState, selectedRowCount: selectedRowCount, bulkActions: bulkActions, sx: {
|
|
1546
1376
|
position: 'relative',
|
|
1547
1377
|
zIndex: 2,
|
|
1548
1378
|
...bulkActionsSlotProps.sx,
|