@ackplus/react-tanstack-data-table 1.0.23 → 1.0.24
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
|
@@ -18,6 +18,7 @@ const pagination_1 = require("../pagination");
|
|
|
18
18
|
const rows_1 = require("../rows");
|
|
19
19
|
const toolbar_1 = require("../toolbar");
|
|
20
20
|
const special_columns_utils_1 = require("../../utils/special-columns.utils");
|
|
21
|
+
const lodash_1 = require("lodash");
|
|
21
22
|
const DEFAULT_INITIAL_STATE = {
|
|
22
23
|
sorting: [],
|
|
23
24
|
pagination: {
|
|
@@ -143,6 +144,7 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
143
144
|
}), [tableWidth]);
|
|
144
145
|
const fetchData = (0, react_1.useCallback)((...args_1) => tslib_1.__awaiter(this, [...args_1], void 0, function* (overrides = {}) {
|
|
145
146
|
var _a, _b;
|
|
147
|
+
console.info('fetchData', (0, lodash_1.cloneDeep)(overrides), (0, lodash_1.cloneDeep)(columnFilter), (0, lodash_1.cloneDeep)(sorting), (0, lodash_1.cloneDeep)(pagination));
|
|
146
148
|
if (!onFetchData) {
|
|
147
149
|
if (fetchLogger.isLevelEnabled('debug')) {
|
|
148
150
|
fetchLogger.debug('onFetchData not provided, skipping fetch', { overrides });
|
|
@@ -452,9 +454,18 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
452
454
|
}, [columnOrder, enhancedColumns, handleColumnOrderChange]);
|
|
453
455
|
(0, react_1.useEffect)(() => {
|
|
454
456
|
if (initialLoadData && onFetchData) {
|
|
457
|
+
if (fetchLogger.isLevelEnabled('info')) {
|
|
458
|
+
fetchLogger.info('Initial data load triggered', { initialLoadData });
|
|
459
|
+
}
|
|
455
460
|
fetchData();
|
|
456
461
|
}
|
|
457
|
-
|
|
462
|
+
else if (fetchLogger.isLevelEnabled('debug')) {
|
|
463
|
+
fetchLogger.debug('Skipping initial data load', {
|
|
464
|
+
initialLoadData,
|
|
465
|
+
hasOnFetchData: !!onFetchData
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
}, []);
|
|
458
469
|
(0, react_1.useEffect)(() => {
|
|
459
470
|
if (enableColumnDragging && columnOrder.length === 0) {
|
|
460
471
|
const initialOrder = enhancedColumns.map((col, index) => {
|
|
@@ -469,8 +480,7 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
469
480
|
setColumnOrder(initialOrder);
|
|
470
481
|
}
|
|
471
482
|
}, [enableColumnDragging, enhancedColumns, columnOrder.length]);
|
|
472
|
-
(0, react_1.
|
|
473
|
-
(0, react_1.useImperativeHandle)(ref, () => ({
|
|
483
|
+
const dataTableApi = (0, react_1.useMemo)(() => ({
|
|
474
484
|
table: {
|
|
475
485
|
getTable: () => table,
|
|
476
486
|
},
|
|
@@ -718,11 +728,14 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
718
728
|
refresh: () => {
|
|
719
729
|
var _a, _b;
|
|
720
730
|
const filters = table.getState();
|
|
731
|
+
console.info('filters', (0, lodash_1.cloneDeep)(filters));
|
|
721
732
|
const pagination = {
|
|
722
733
|
pageIndex: 0,
|
|
723
734
|
pageSize: ((_a = filters.pagination) === null || _a === void 0 ? void 0 : _a.pageSize) || ((_b = initialStateConfig.pagination) === null || _b === void 0 ? void 0 : _b.pageSize) || 10,
|
|
724
735
|
};
|
|
736
|
+
console.info('pagination', (0, lodash_1.cloneDeep)(pagination));
|
|
725
737
|
const allState = table.getState();
|
|
738
|
+
console.info('allState', (0, lodash_1.cloneDeep)(allState));
|
|
726
739
|
setPagination(pagination);
|
|
727
740
|
onDataStateChange === null || onDataStateChange === void 0 ? void 0 : onDataStateChange(allState);
|
|
728
741
|
fetchData === null || fetchData === void 0 ? void 0 : fetchData({ pagination });
|
|
@@ -1136,6 +1149,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
1136
1149
|
selectMode,
|
|
1137
1150
|
onSelectionChange,
|
|
1138
1151
|
]);
|
|
1152
|
+
internalApiRef.current = dataTableApi;
|
|
1153
|
+
(0, react_1.useImperativeHandle)(ref, () => dataTableApi, [dataTableApi]);
|
|
1139
1154
|
const renderTableRows = (0, react_1.useCallback)(() => {
|
|
1140
1155
|
var _a, _b, _c, _d;
|
|
1141
1156
|
if (tableLoading) {
|
|
@@ -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');
|