@arim-aisdc/public-components 2.3.62 → 2.3.63
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.
|
@@ -93,7 +93,6 @@ var VirtualTableBody = function VirtualTableBody(_ref) {
|
|
|
93
93
|
// 从 Provider 中获取虚拟化数据
|
|
94
94
|
var rowVirtualizer = state.rowVirtualizer;
|
|
95
95
|
var virtualRows = rowVirtualizer === null || rowVirtualizer === void 0 ? void 0 : rowVirtualizer.getVirtualItems();
|
|
96
|
-
console.log(rowVirtualizer, virtualRows, 'virtualRows');
|
|
97
96
|
var _useState = useState({
|
|
98
97
|
visible: false,
|
|
99
98
|
clientX: 0,
|
|
@@ -28,6 +28,8 @@ table {
|
|
|
28
28
|
height: 0;
|
|
29
29
|
border-bottom: 1px solid @tableColor2;
|
|
30
30
|
z-index: 210;
|
|
31
|
+
display: block;
|
|
32
|
+
box-sizing: border-box;
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
35
|
|
|
@@ -38,9 +40,10 @@ table {
|
|
|
38
40
|
left: 0;
|
|
39
41
|
top: 0;
|
|
40
42
|
width: 100%;
|
|
41
|
-
height:
|
|
43
|
+
height: var(--cell-height);
|
|
44
|
+
border-top: 1px solid @tableColor2;
|
|
42
45
|
border-bottom: 1px solid @tableColor2;
|
|
43
|
-
z-index:
|
|
46
|
+
z-index: 260;
|
|
44
47
|
}
|
|
45
48
|
}
|
|
46
49
|
.tbody-tr-highlight {
|
|
@@ -16,7 +16,7 @@ export declare const useColumnWidth: ({ tableContentRef, tableId, tableKeyPrefix
|
|
|
16
16
|
allColumnCount: number;
|
|
17
17
|
onColumnSizingChange: (updater: any) => void;
|
|
18
18
|
tableContainerWidth: number;
|
|
19
|
-
initializeColumnSizing: (columns: any) => void;
|
|
19
|
+
initializeColumnSizing: (columns: any) => () => void;
|
|
20
20
|
handleVisibleConfigChange: (key: string, value: boolean) => void;
|
|
21
21
|
};
|
|
22
22
|
export {};
|
|
@@ -163,7 +163,7 @@ export var useColumnWidth = function useColumnWidth(_ref) {
|
|
|
163
163
|
*/
|
|
164
164
|
var calculateColumnSizing = useCallback(function (columnsSizeMap, allColumnCount, containerWidth) {
|
|
165
165
|
var currentWidth = containerWidth || state.tableContainerWidth || getTableWidth();
|
|
166
|
-
|
|
166
|
+
console.log(containerWidth, tableContentRef.current.clientWidth, state.tableContainerWidth, getTableWidth());
|
|
167
167
|
if (!currentWidth) return columnsSizeMap;
|
|
168
168
|
var result = _objectSpread({}, columnsSizeMap);
|
|
169
169
|
var adjustableColumns = getAdjustableColumns(result);
|
|
@@ -217,71 +217,87 @@ export var useColumnWidth = function useColumnWidth(_ref) {
|
|
|
217
217
|
* 初始化列宽信息
|
|
218
218
|
*/
|
|
219
219
|
var initializeColumnSizing = useCallback(function (columns) {
|
|
220
|
-
var _localStorage$getItem;
|
|
221
220
|
if (!Array.isArray(columns) || columns.length === 0) return;
|
|
222
|
-
var
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
if (!(cache !== null && cache !== void 0 && cache.editTime) || now - cache.editTime > cacheMaxAge) {
|
|
234
|
-
Object.keys(initColumnsSizeMap).forEach(function (key) {
|
|
235
|
-
if (columnVisibleConfig[key] !== false) {
|
|
236
|
-
visibleColumnsSizeMap[key] = initColumnsSizeMap[key];
|
|
237
|
-
}
|
|
238
|
-
});
|
|
239
|
-
} else {
|
|
240
|
-
var _cache$columnSizing, _cache$columnVisibili;
|
|
241
|
-
var columnsIdSet = new Set(columns.map(function (column) {
|
|
242
|
-
return column.id;
|
|
243
|
-
}));
|
|
221
|
+
var initializeWithWidth = function initializeWithWidth(width) {
|
|
222
|
+
var _localStorage$getItem;
|
|
223
|
+
var _getSizeInfo = getSizeInfo(columns),
|
|
224
|
+
allCount = _getSizeInfo.allCount,
|
|
225
|
+
columnSizeMap = _getSizeInfo.columnSizeMap;
|
|
226
|
+
var cache = JSON.parse((_localStorage$getItem = localStorage.getItem(tableKey)) !== null && _localStorage$getItem !== void 0 ? _localStorage$getItem : '{}');
|
|
227
|
+
var now = +Date.now();
|
|
228
|
+
setState(produce(function (prevState) {
|
|
229
|
+
// 初始化列宽映射
|
|
230
|
+
var initColumnsSizeMap = _objectSpread({}, columnSizeMap);
|
|
231
|
+
var visibleColumnsSizeMap = {};
|
|
244
232
|
|
|
245
|
-
//
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
key =
|
|
250
|
-
|
|
233
|
+
// 处理缓存过期或无效的情况
|
|
234
|
+
if (!(cache !== null && cache !== void 0 && cache.editTime) || now - cache.editTime > cacheMaxAge) {
|
|
235
|
+
Object.keys(initColumnsSizeMap).forEach(function (key) {
|
|
236
|
+
if (columnVisibleConfig[key] !== false) {
|
|
237
|
+
visibleColumnsSizeMap[key] = initColumnsSizeMap[key];
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
} else {
|
|
241
|
+
var _cache$columnSizing, _cache$columnVisibili;
|
|
242
|
+
var columnsIdSet = new Set(columns.map(function (column) {
|
|
243
|
+
return column.id;
|
|
251
244
|
}));
|
|
252
|
-
};
|
|
253
245
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
}
|
|
246
|
+
// 工具函数
|
|
247
|
+
var pickByKeys = function pickByKeys(obj, keys) {
|
|
248
|
+
return Object.fromEntries(Object.entries(obj).filter(function (_ref2) {
|
|
249
|
+
var _ref3 = _slicedToArray(_ref2, 1),
|
|
250
|
+
key = _ref3[0];
|
|
251
|
+
return keys.has(key);
|
|
252
|
+
}));
|
|
253
|
+
};
|
|
263
254
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
255
|
+
// 主逻辑
|
|
256
|
+
Object.assign(initColumnsSizeMap, pickByKeys((_cache$columnSizing = cache.columnSizing) !== null && _cache$columnSizing !== void 0 ? _cache$columnSizing : {}, columnsIdSet));
|
|
257
|
+
Object.assign(columnVisibleConfig, pickByKeys((_cache$columnVisibili = cache.columnVisibility) !== null && _cache$columnVisibili !== void 0 ? _cache$columnVisibili : {}, columnsIdSet));
|
|
258
|
+
Object.keys(initColumnsSizeMap).forEach(function (key) {
|
|
259
|
+
if (columnVisibleConfig[key] !== false) {
|
|
260
|
+
visibleColumnsSizeMap[key] = initColumnsSizeMap[key];
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
}
|
|
271
264
|
|
|
272
|
-
|
|
265
|
+
// console.log({
|
|
266
|
+
// prevState,
|
|
267
|
+
// initColumnsSizeMap,
|
|
268
|
+
// visibleColumnsSizeMap,
|
|
269
|
+
// cache,
|
|
270
|
+
// cacheMaxAge,
|
|
271
|
+
// tableContentRef: tableContentRef.current
|
|
273
272
|
|
|
274
|
-
|
|
275
|
-
var visibleCount = allCount - Object.keys(columnVisibleConfig).filter(function (key) {
|
|
276
|
-
return !columnVisibleConfig[key];
|
|
277
|
-
}).length;
|
|
273
|
+
// }, 'columnSizeMap123')
|
|
278
274
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
275
|
+
// 计算可见列数
|
|
276
|
+
var visibleCount = allCount - Object.keys(columnVisibleConfig).filter(function (key) {
|
|
277
|
+
return !columnVisibleConfig[key];
|
|
278
|
+
}).length;
|
|
279
|
+
|
|
280
|
+
// 计算最终列宽
|
|
281
|
+
prevState.columnSizing = calculateColumnSizing(visibleColumnsSizeMap, visibleCount, width);
|
|
282
|
+
prevState.tableContainerWidth = width;
|
|
283
|
+
prevState.allColumnSizing = _objectSpread(_objectSpread({}, initColumnsSizeMap), prevState.columnSizing);
|
|
284
|
+
prevState.allColumnCount = visibleCount;
|
|
285
|
+
prevState.initColumnsSizeMap = columnSizeMap;
|
|
286
|
+
}));
|
|
287
|
+
};
|
|
288
|
+
var currentWidth = getTableWidth();
|
|
289
|
+
if (currentWidth) {
|
|
290
|
+
initializeWithWidth(currentWidth);
|
|
291
|
+
} else {
|
|
292
|
+
// 简单延迟重试
|
|
293
|
+
var timer = setTimeout(function () {
|
|
294
|
+
var retryWidth = getTableWidth() || 1000; // 回退默认宽度
|
|
295
|
+
initializeWithWidth(retryWidth);
|
|
296
|
+
}, 100);
|
|
297
|
+
return function () {
|
|
298
|
+
return clearTimeout(timer);
|
|
299
|
+
};
|
|
300
|
+
}
|
|
285
301
|
}, [calculateColumnSizing, columnVisibleConfig, tableKey, cacheMaxAge]);
|
|
286
302
|
|
|
287
303
|
/**
|