@ackplus/react-tanstack-data-table 1.0.24-b-1 → 1.0.25
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
|
@@ -454,9 +454,18 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
454
454
|
}, [columnOrder, enhancedColumns, handleColumnOrderChange]);
|
|
455
455
|
(0, react_1.useEffect)(() => {
|
|
456
456
|
if (initialLoadData && onFetchData) {
|
|
457
|
+
if (fetchLogger.isLevelEnabled('info')) {
|
|
458
|
+
fetchLogger.info('Initial data load triggered', { initialLoadData });
|
|
459
|
+
}
|
|
457
460
|
fetchData();
|
|
458
461
|
}
|
|
459
|
-
|
|
462
|
+
else if (fetchLogger.isLevelEnabled('debug')) {
|
|
463
|
+
fetchLogger.debug('Skipping initial data load', {
|
|
464
|
+
initialLoadData,
|
|
465
|
+
hasOnFetchData: !!onFetchData
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
}, []);
|
|
460
469
|
(0, react_1.useEffect)(() => {
|
|
461
470
|
if (enableColumnDragging && columnOrder.length === 0) {
|
|
462
471
|
const initialOrder = enhancedColumns.map((col, index) => {
|
|
@@ -471,8 +480,7 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
471
480
|
setColumnOrder(initialOrder);
|
|
472
481
|
}
|
|
473
482
|
}, [enableColumnDragging, enhancedColumns, columnOrder.length]);
|
|
474
|
-
(0, react_1.
|
|
475
|
-
(0, react_1.useImperativeHandle)(ref, () => ({
|
|
483
|
+
const dataTableApi = (0, react_1.useMemo)(() => ({
|
|
476
484
|
table: {
|
|
477
485
|
getTable: () => table,
|
|
478
486
|
},
|
|
@@ -626,7 +634,6 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
626
634
|
});
|
|
627
635
|
},
|
|
628
636
|
resetFilters: () => {
|
|
629
|
-
table.resetGlobalFilter();
|
|
630
637
|
handleColumnFilterStateChange({
|
|
631
638
|
filters: [],
|
|
632
639
|
logic: 'AND',
|
|
@@ -660,7 +667,7 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
660
667
|
table.resetSorting();
|
|
661
668
|
},
|
|
662
669
|
resetSorting: () => {
|
|
663
|
-
table.
|
|
670
|
+
table.setSorting(initialStateConfig.sorting || []);
|
|
664
671
|
},
|
|
665
672
|
},
|
|
666
673
|
pagination: {
|
|
@@ -703,6 +710,9 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
703
710
|
}
|
|
704
711
|
}
|
|
705
712
|
},
|
|
713
|
+
resetPagination: () => {
|
|
714
|
+
table.setPagination(initialStateConfig.pagination || { pageIndex: 0, pageSize: 10 });
|
|
715
|
+
},
|
|
706
716
|
},
|
|
707
717
|
selection: {
|
|
708
718
|
selectRow: (rowId) => { var _a; return (_a = table.selectRow) === null || _a === void 0 ? void 0 : _a.call(table, rowId); },
|
|
@@ -1141,6 +1151,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
1141
1151
|
selectMode,
|
|
1142
1152
|
onSelectionChange,
|
|
1143
1153
|
]);
|
|
1154
|
+
internalApiRef.current = dataTableApi;
|
|
1155
|
+
(0, react_1.useImperativeHandle)(ref, () => dataTableApi, [dataTableApi]);
|
|
1144
1156
|
const renderTableRows = (0, react_1.useCallback)(() => {
|
|
1145
1157
|
var _a, _b, _c, _d;
|
|
1146
1158
|
if (tableLoading) {
|
|
@@ -7,32 +7,34 @@ const material_1 = require("@mui/material");
|
|
|
7
7
|
const data_table_context_1 = require("../../contexts/data-table-context");
|
|
8
8
|
const slot_helpers_1 = require("../../utils/slot-helpers");
|
|
9
9
|
function ColumnResetControl(props = {}) {
|
|
10
|
-
const { table, slots, slotProps } = (0, data_table_context_1.useDataTableContext)();
|
|
10
|
+
const { apiRef, table, slots, slotProps } = (0, data_table_context_1.useDataTableContext)();
|
|
11
11
|
const resetIconSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'resetIcon');
|
|
12
12
|
const ResetIconSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'resetIcon', icons_material_1.Autorenew);
|
|
13
13
|
const handleResetLayout = () => {
|
|
14
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
14
15
|
const actions = props.resetActions || ['columnOrder', 'columnPinning', 'columnSizing'];
|
|
16
|
+
if (!(apiRef === null || apiRef === void 0 ? void 0 : apiRef.current))
|
|
17
|
+
return;
|
|
15
18
|
if (actions.includes('columnOrder')) {
|
|
16
|
-
|
|
19
|
+
(_b = (_a = apiRef === null || apiRef === void 0 ? void 0 : apiRef.current) === null || _a === void 0 ? void 0 : _a.columnOrdering) === null || _b === void 0 ? void 0 : _b.resetColumnOrder();
|
|
17
20
|
}
|
|
18
21
|
if (actions.includes('columnPinning')) {
|
|
19
|
-
|
|
22
|
+
(_d = (_c = apiRef === null || apiRef === void 0 ? void 0 : apiRef.current) === null || _c === void 0 ? void 0 : _c.columnPinning) === null || _d === void 0 ? void 0 : _d.resetColumnPinning();
|
|
20
23
|
}
|
|
21
24
|
if (actions.includes('columnSizing')) {
|
|
22
|
-
|
|
25
|
+
(_f = (_e = apiRef === null || apiRef === void 0 ? void 0 : apiRef.current) === null || _e === void 0 ? void 0 : _e.columnResizing) === null || _f === void 0 ? void 0 : _f.resetColumnSizing();
|
|
23
26
|
}
|
|
24
27
|
if (actions.includes('columnVisibility')) {
|
|
25
|
-
|
|
28
|
+
(_h = (_g = apiRef === null || apiRef === void 0 ? void 0 : apiRef.current) === null || _g === void 0 ? void 0 : _g.columnVisibility) === null || _h === void 0 ? void 0 : _h.resetColumnVisibility();
|
|
26
29
|
}
|
|
27
30
|
if (actions.includes('filters')) {
|
|
28
|
-
|
|
29
|
-
table.resetGlobalFilter();
|
|
31
|
+
(_k = (_j = apiRef === null || apiRef === void 0 ? void 0 : apiRef.current) === null || _j === void 0 ? void 0 : _j.filtering) === null || _k === void 0 ? void 0 : _k.clearAllFilters();
|
|
30
32
|
}
|
|
31
33
|
if (actions.includes('sorting')) {
|
|
32
|
-
|
|
34
|
+
(_m = (_l = apiRef === null || apiRef === void 0 ? void 0 : apiRef.current) === null || _l === void 0 ? void 0 : _l.sorting) === null || _m === void 0 ? void 0 : _m.resetSorting();
|
|
33
35
|
}
|
|
34
36
|
if (actions.includes('pagination')) {
|
|
35
|
-
|
|
37
|
+
(_p = (_o = apiRef === null || apiRef === void 0 ? void 0 : apiRef.current) === null || _o === void 0 ? void 0 : _o.pagination) === null || _p === void 0 ? void 0 : _p.resetPagination();
|
|
36
38
|
}
|
|
37
39
|
};
|
|
38
40
|
const mergedIconButtonProps = (0, slot_helpers_1.mergeSlotProps)({
|
|
@@ -11,12 +11,8 @@ const icons_1 = require("../../icons");
|
|
|
11
11
|
const slot_helpers_1 = require("../../utils/slot-helpers");
|
|
12
12
|
function TableExportControl(props = {}) {
|
|
13
13
|
const { exportFilename: propsExportFilename, onServerExport: propsOnServerExport, onExportProgress: propsOnExportProgress, onExportComplete: propsOnExportComplete, onExportError: propsOnExportError, iconButtonProps, tooltipProps, menuSx, menuItemProps } = props, otherProps = tslib_1.__rest(props, ["exportFilename", "onServerExport", "onExportProgress", "onExportComplete", "onExportError", "iconButtonProps", "tooltipProps", "menuSx", "menuItemProps"]);
|
|
14
|
-
const {
|
|
14
|
+
const { apiRef, slots, slotProps, isExporting, exportFilename: contextExportFilename, } = (0, data_table_context_1.useDataTableContext)();
|
|
15
15
|
const exportFilename = propsExportFilename || contextExportFilename || 'export';
|
|
16
|
-
const onServerExport = propsOnServerExport || contextOnServerExport;
|
|
17
|
-
const onExportProgress = propsOnExportProgress || contextOnExportProgress;
|
|
18
|
-
const onExportComplete = propsOnExportComplete || contextOnExportComplete;
|
|
19
|
-
const onExportError = propsOnExportError || contextOnExportError;
|
|
20
16
|
const exportIconSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'exportIcon');
|
|
21
17
|
const csvIconSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'csvIcon');
|
|
22
18
|
const excelIconSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'excelIcon');
|