@arim-aisdc/public-components 2.3.52 → 2.3.53
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.
|
@@ -511,19 +511,45 @@ var TableMax = function TableMax(_ref) {
|
|
|
511
511
|
|
|
512
512
|
/**根据缓存数据设置一些状态 */
|
|
513
513
|
var setColumnInfoFromCache = function setColumnInfoFromCache(tableColumns) {
|
|
514
|
-
var _localStorage$getItem, _tableMaxConfig$cache;
|
|
514
|
+
var _localStorage$getItem, _tableMaxConfig$cache, _cache$columnPinning$, _cache$columnPinning, _cache$columnPinning$2, _cache$columnPinning2;
|
|
515
515
|
var cache = JSON.parse((_localStorage$getItem = localStorage.getItem(tableKey)) !== null && _localStorage$getItem !== void 0 ? _localStorage$getItem : '{}');
|
|
516
516
|
if (cache && cache !== null && cache !== void 0 && cache.editTime && +new Date() - cache.editTime > ((_tableMaxConfig$cache = tableMaxConfig.cacheMaxAge) !== null && _tableMaxConfig$cache !== void 0 ? _tableMaxConfig$cache : CACHE_MAX_AGE)) {
|
|
517
517
|
return;
|
|
518
518
|
}
|
|
519
|
-
var
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
519
|
+
var columnsIdSet = new Set(tableColumns.map(function (column) {
|
|
520
|
+
return column.id;
|
|
521
|
+
}));
|
|
522
|
+
|
|
523
|
+
// 工具函数
|
|
524
|
+
var pickByKeys = function pickByKeys(obj, keys) {
|
|
525
|
+
return Object.fromEntries(Object.entries(obj).filter(function (_ref3) {
|
|
526
|
+
var _ref4 = _slicedToArray(_ref3, 1),
|
|
527
|
+
key = _ref4[0];
|
|
528
|
+
return keys.has(key);
|
|
529
|
+
}));
|
|
530
|
+
};
|
|
531
|
+
var _ref5 = _objectSpread(_objectSpread({}, cache), {}, {
|
|
532
|
+
columnVisibility: cache.columnVisibility ? pickByKeys(cache.columnVisibility, columnsIdSet) : {},
|
|
533
|
+
columnPinning: cache.columnPinning ? {
|
|
534
|
+
left: (_cache$columnPinning$ = cache === null || cache === void 0 || (_cache$columnPinning = cache.columnPinning) === null || _cache$columnPinning === void 0 || (_cache$columnPinning = _cache$columnPinning.left) === null || _cache$columnPinning === void 0 ? void 0 : _cache$columnPinning.filter(function (id) {
|
|
535
|
+
return columnsIdSet.has(id);
|
|
536
|
+
})) !== null && _cache$columnPinning$ !== void 0 ? _cache$columnPinning$ : [],
|
|
537
|
+
right: (_cache$columnPinning$2 = cache === null || cache === void 0 || (_cache$columnPinning2 = cache.columnPinning) === null || _cache$columnPinning2 === void 0 || (_cache$columnPinning2 = _cache$columnPinning2.right) === null || _cache$columnPinning2 === void 0 ? void 0 : _cache$columnPinning2.filter(function (id) {
|
|
538
|
+
return columnsIdSet.has(id);
|
|
539
|
+
})) !== null && _cache$columnPinning$2 !== void 0 ? _cache$columnPinning$2 : []
|
|
540
|
+
} : {
|
|
541
|
+
left: [],
|
|
542
|
+
right: []
|
|
543
|
+
}
|
|
544
|
+
}),
|
|
545
|
+
cacheColumnVisibility = _ref5.columnVisibility,
|
|
546
|
+
cacheColumnOrder = _ref5.columnOrder,
|
|
547
|
+
cacheColumnPinning = _ref5.columnPinning,
|
|
548
|
+
cacheColumnFilters = _ref5.columnFilters,
|
|
549
|
+
cacheColumnSorting = _ref5.columnSorting,
|
|
550
|
+
cacheEnableFilters = _ref5.enableFilters,
|
|
551
|
+
cacheHeaderRowNum = _ref5.headerRowNum,
|
|
552
|
+
cacheCompactMode = _ref5.compactMode;
|
|
527
553
|
if (cacheHeaderRowNum) {
|
|
528
554
|
setheaderRowNum(cacheHeaderRowNum);
|
|
529
555
|
}
|
|
@@ -581,8 +607,8 @@ var TableMax = function TableMax(_ref) {
|
|
|
581
607
|
size: 40,
|
|
582
608
|
tooltip: false,
|
|
583
609
|
enableResizing: false,
|
|
584
|
-
cell: function cell(
|
|
585
|
-
var row =
|
|
610
|
+
cell: function cell(_ref6) {
|
|
611
|
+
var row = _ref6.row;
|
|
586
612
|
return row.getCanExpand() ? /*#__PURE__*/_jsx("div", {
|
|
587
613
|
onClick: function onClick(evt) {
|
|
588
614
|
evt.stopPropagation();
|
|
@@ -603,8 +629,8 @@ var TableMax = function TableMax(_ref) {
|
|
|
603
629
|
id: ColumnType.Selection,
|
|
604
630
|
tooltip: false,
|
|
605
631
|
enableResizing: false,
|
|
606
|
-
header: function header(
|
|
607
|
-
var table =
|
|
632
|
+
header: function header(_ref7) {
|
|
633
|
+
var table = _ref7.table;
|
|
608
634
|
return /*#__PURE__*/_jsx(Checkbox, {
|
|
609
635
|
checked: table.getIsAllRowsSelected(),
|
|
610
636
|
indeterminate: table.getIsSomePageRowsSelected(),
|
|
@@ -615,9 +641,9 @@ var TableMax = function TableMax(_ref) {
|
|
|
615
641
|
}
|
|
616
642
|
});
|
|
617
643
|
},
|
|
618
|
-
cell: function cell(
|
|
619
|
-
var row =
|
|
620
|
-
table =
|
|
644
|
+
cell: function cell(_ref8) {
|
|
645
|
+
var row = _ref8.row,
|
|
646
|
+
table = _ref8.table;
|
|
621
647
|
return /*#__PURE__*/_jsx(Checkbox, {
|
|
622
648
|
checked: row.getIsSelected(),
|
|
623
649
|
disabled: !row.getCanSelect(),
|
|
@@ -694,7 +720,9 @@ var TableMax = function TableMax(_ref) {
|
|
|
694
720
|
|
|
695
721
|
// 初始化列
|
|
696
722
|
useEffect(function () {
|
|
697
|
-
|
|
723
|
+
var _tableContentRef$curr;
|
|
724
|
+
if (!tableMaxRef.current || !tableContentRef.current) return;
|
|
725
|
+
console.log((_tableContentRef$curr = tableContentRef.current) === null || _tableContentRef$curr === void 0 ? void 0 : _tableContentRef$curr.offsetWidth, 'tableContentRef.current');
|
|
698
726
|
// 根据props,自动增加勾选列/展开列
|
|
699
727
|
var newColumns = setColumnsByProps().concat(columns);
|
|
700
728
|
initializeColumnSizing(newColumns);
|
|
@@ -960,7 +988,7 @@ var TableMax = function TableMax(_ref) {
|
|
|
960
988
|
|
|
961
989
|
// 保存编辑内容
|
|
962
990
|
var save = /*#__PURE__*/function () {
|
|
963
|
-
var
|
|
991
|
+
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
964
992
|
var _tableRows$find2;
|
|
965
993
|
var newRow, _table$getRowModel4, tableRows, originRow;
|
|
966
994
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
@@ -983,7 +1011,7 @@ var TableMax = function TableMax(_ref) {
|
|
|
983
1011
|
}, _callee);
|
|
984
1012
|
}));
|
|
985
1013
|
return function save() {
|
|
986
|
-
return
|
|
1014
|
+
return _ref9.apply(this, arguments);
|
|
987
1015
|
};
|
|
988
1016
|
}();
|
|
989
1017
|
var triggerSave = function triggerSave(e) {
|
|
@@ -156,6 +156,7 @@ export var useColumnWidth = function useColumnWidth(_ref) {
|
|
|
156
156
|
*/
|
|
157
157
|
var calculateColumnSizing = useCallback(function (columnsSizeMap, allColumnCount, containerWidth) {
|
|
158
158
|
var currentWidth = containerWidth || state.tableContainerWidth || getTableWidth();
|
|
159
|
+
// console.log(containerWidth, state.tableContainerWidth, getTableWidth())
|
|
159
160
|
if (!currentWidth) return columnsSizeMap;
|
|
160
161
|
var result = _objectSpread({}, columnsSizeMap);
|
|
161
162
|
var adjustableColumns = getAdjustableColumns(result);
|
|
@@ -229,9 +230,22 @@ export var useColumnWidth = function useColumnWidth(_ref) {
|
|
|
229
230
|
}
|
|
230
231
|
});
|
|
231
232
|
} else {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
233
|
+
var columnsIdSet = new Set(columns.map(function (column) {
|
|
234
|
+
return column.id;
|
|
235
|
+
}));
|
|
236
|
+
|
|
237
|
+
// 工具函数
|
|
238
|
+
var pickByKeys = function pickByKeys(obj, keys) {
|
|
239
|
+
return Object.fromEntries(Object.entries(obj).filter(function (_ref2) {
|
|
240
|
+
var _ref3 = _slicedToArray(_ref2, 1),
|
|
241
|
+
key = _ref3[0];
|
|
242
|
+
return keys.has(key);
|
|
243
|
+
}));
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
// 主逻辑
|
|
247
|
+
Object.assign(initColumnsSizeMap, pickByKeys(cache.columnSizing, columnsIdSet));
|
|
248
|
+
Object.assign(columnVisibleConfig, pickByKeys(cache.columnVisibility, columnsIdSet));
|
|
235
249
|
Object.keys(initColumnsSizeMap).forEach(function (key) {
|
|
236
250
|
if (columnVisibleConfig[key] !== false) {
|
|
237
251
|
visibleColumnsSizeMap[key] = initColumnsSizeMap[key];
|
|
@@ -244,7 +258,8 @@ export var useColumnWidth = function useColumnWidth(_ref) {
|
|
|
244
258
|
// initColumnsSizeMap,
|
|
245
259
|
// visibleColumnsSizeMap,
|
|
246
260
|
// cache,
|
|
247
|
-
// cacheMaxAge
|
|
261
|
+
// cacheMaxAge,
|
|
262
|
+
// tableContentRef: tableContentRef.current
|
|
248
263
|
|
|
249
264
|
// }, 'columnSizeMap123')
|
|
250
265
|
|
|
@@ -269,10 +284,10 @@ export var useColumnWidth = function useColumnWidth(_ref) {
|
|
|
269
284
|
if (!changedColumn || JSON.stringify(changedColumn) === '{}') return;
|
|
270
285
|
setState(produce(function (prevState) {
|
|
271
286
|
var _Object$entries;
|
|
272
|
-
var
|
|
273
|
-
|
|
274
|
-
changedKey =
|
|
275
|
-
newWidth =
|
|
287
|
+
var _ref4 = (_Object$entries = Object.entries(changedColumn)) === null || _Object$entries === void 0 ? void 0 : _Object$entries[0],
|
|
288
|
+
_ref5 = _slicedToArray(_ref4, 2),
|
|
289
|
+
changedKey = _ref5[0],
|
|
290
|
+
newWidth = _ref5[1];
|
|
276
291
|
if (!changedKey) return;
|
|
277
292
|
var oldWidth = prevState.columnSizing[changedKey] || 0;
|
|
278
293
|
var widthDiff = newWidth - oldWidth;
|