@ackplus/react-tanstack-data-table 1.0.27 → 1.0.29
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,7 +18,6 @@ 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");
|
|
22
21
|
const DEFAULT_INITIAL_STATE = {
|
|
23
22
|
sorting: [],
|
|
24
23
|
pagination: {
|
|
@@ -66,8 +65,12 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
66
65
|
};
|
|
67
66
|
}, [logger, dataMode, paginationMode, filterMode, sortingMode]);
|
|
68
67
|
const initialStateConfig = (0, react_1.useMemo)(() => {
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
const config = Object.assign(Object.assign({}, DEFAULT_INITIAL_STATE), initialState);
|
|
69
|
+
if (logger.isLevelEnabled('info')) {
|
|
70
|
+
logger.info('initialStateConfig', { config });
|
|
71
|
+
}
|
|
72
|
+
return config;
|
|
73
|
+
}, [initialState, logger]);
|
|
71
74
|
const [sorting, setSorting] = (0, react_1.useState)((initialState === null || initialState === void 0 ? void 0 : initialState.sorting) || DEFAULT_INITIAL_STATE.sorting);
|
|
72
75
|
const [pagination, setPagination] = (0, react_1.useState)((initialState === null || initialState === void 0 ? void 0 : initialState.pagination) || DEFAULT_INITIAL_STATE.pagination);
|
|
73
76
|
const [globalFilter, setGlobalFilter] = (0, react_1.useState)((initialState === null || initialState === void 0 ? void 0 : initialState.globalFilter) || DEFAULT_INITIAL_STATE.globalFilter);
|
|
@@ -96,7 +99,11 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
96
99
|
const selectionColumnMap = (0, special_columns_utils_1.createSelectionColumn)(Object.assign(Object.assign({}, ((slotProps === null || slotProps === void 0 ? void 0 : slotProps.selectionColumn) && typeof slotProps.selectionColumn === 'object' ? slotProps.selectionColumn : {})), { multiSelect: enableMultiRowSelection }));
|
|
97
100
|
columnsMap = [selectionColumnMap, ...columnsMap];
|
|
98
101
|
}
|
|
99
|
-
|
|
102
|
+
const enhancedColumns = (0, utils_1.withIdsDeep)(columnsMap);
|
|
103
|
+
if (logger.isLevelEnabled('info')) {
|
|
104
|
+
logger.info('enhancedColumns', { enhancedColumns });
|
|
105
|
+
}
|
|
106
|
+
return enhancedColumns;
|
|
100
107
|
}, [columns, enableExpanding, enableRowSelection, enableMultiRowSelection, slotProps === null || slotProps === void 0 ? void 0 : slotProps.expandColumn, slotProps === null || slotProps === void 0 ? void 0 : slotProps.selectionColumn]);
|
|
101
108
|
const isExporting = (0, react_1.useMemo)(() => exportController !== null, [exportController]);
|
|
102
109
|
const isSomeRowsSelected = (0, react_1.useMemo)(() => {
|
|
@@ -137,10 +144,9 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
137
144
|
}), [tableWidth]);
|
|
138
145
|
const fetchData = (0, react_1.useCallback)((...args_1) => tslib_1.__awaiter(this, [...args_1], void 0, function* (overrides = {}) {
|
|
139
146
|
var _a, _b;
|
|
140
|
-
console.info('fetchData', (0, lodash_1.cloneDeep)(overrides), (0, lodash_1.cloneDeep)(columnFilter), (0, lodash_1.cloneDeep)(sorting), (0, lodash_1.cloneDeep)(pagination));
|
|
141
147
|
if (!onFetchData) {
|
|
142
148
|
if (fetchLogger.isLevelEnabled('debug')) {
|
|
143
|
-
fetchLogger.debug('onFetchData not provided, skipping fetch', { overrides });
|
|
149
|
+
fetchLogger.debug('onFetchData not provided, skipping fetch', { overrides, columnFilter, sorting, pagination });
|
|
144
150
|
}
|
|
145
151
|
return;
|
|
146
152
|
}
|
|
@@ -148,13 +154,13 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
148
154
|
pagination,
|
|
149
155
|
columnFilter,
|
|
150
156
|
sorting }, overrides);
|
|
151
|
-
if (fetchLogger.isLevelEnabled('
|
|
152
|
-
fetchLogger.
|
|
157
|
+
if (fetchLogger.isLevelEnabled('info')) {
|
|
158
|
+
fetchLogger.info('Requesting data', { filters });
|
|
153
159
|
}
|
|
154
160
|
try {
|
|
155
161
|
const result = yield debouncedFetch(filters);
|
|
156
|
-
if (fetchLogger.isLevelEnabled('
|
|
157
|
-
fetchLogger.
|
|
162
|
+
if (fetchLogger.isLevelEnabled('info')) {
|
|
163
|
+
fetchLogger.info('Fetch resolved', {
|
|
158
164
|
rows: (_b = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0,
|
|
159
165
|
total: result === null || result === void 0 ? void 0 : result.total,
|
|
160
166
|
});
|
|
@@ -723,19 +729,16 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
|
|
|
723
729
|
refresh: () => {
|
|
724
730
|
var _a, _b;
|
|
725
731
|
const filters = table.getState();
|
|
726
|
-
console.info('filters', (0, lodash_1.cloneDeep)(filters));
|
|
727
732
|
const pagination = {
|
|
728
733
|
pageIndex: 0,
|
|
729
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,
|
|
730
735
|
};
|
|
731
|
-
console.info('pagination', (0, lodash_1.cloneDeep)(pagination));
|
|
732
736
|
const allState = table.getState();
|
|
733
|
-
console.info('allState', (0, lodash_1.cloneDeep)(allState));
|
|
734
737
|
setPagination(pagination);
|
|
735
738
|
onDataStateChange === null || onDataStateChange === void 0 ? void 0 : onDataStateChange(allState);
|
|
736
739
|
fetchData === null || fetchData === void 0 ? void 0 : fetchData({ pagination });
|
|
737
740
|
if (fetchLogger.isLevelEnabled('debug')) {
|
|
738
|
-
fetchLogger.debug('Refreshing data', { pagination, allState });
|
|
741
|
+
fetchLogger.debug('Refreshing data using Ref', { pagination, allState });
|
|
739
742
|
}
|
|
740
743
|
},
|
|
741
744
|
reload: () => {
|