@arim-aisdc/public-components 2.3.82 → 2.3.83
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.
|
@@ -17,7 +17,7 @@ export declare const foramtBaseInfoField: (data: any, dataField: BaseInfoFieldTy
|
|
|
17
17
|
value: any;
|
|
18
18
|
field: string;
|
|
19
19
|
label?: string;
|
|
20
|
-
text: string |
|
|
20
|
+
text: string | Element | JSX.Element;
|
|
21
21
|
units?: string;
|
|
22
22
|
width?: string;
|
|
23
23
|
labelWidth?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { ThemeType } from "../../../
|
|
2
|
+
import { ThemeType } from "../../../node_modules/@arim-aisdc/public-components";
|
|
3
3
|
import type { VariablesJsonType } from './type';
|
|
4
4
|
import { Locale } from '../../locales';
|
|
5
5
|
export interface ConfigConsumerProps {
|
|
@@ -641,14 +641,11 @@ var TableMax = function TableMax(_ref) {
|
|
|
641
641
|
enableResizing: false,
|
|
642
642
|
cell: function cell(_ref7) {
|
|
643
643
|
var row = _ref7.row;
|
|
644
|
-
console.log(row.getIsExpanded(), '3333');
|
|
645
644
|
return row.getCanExpand() ? /*#__PURE__*/_jsx("div", {
|
|
646
645
|
onClick: function onClick(evt) {
|
|
647
646
|
evt.stopPropagation();
|
|
648
647
|
row.getToggleExpandedHandler()();
|
|
649
648
|
// row.toggleExpanded()
|
|
650
|
-
|
|
651
|
-
console.log(row.getIsExpanded(), table.getExpandedRowModel(), '3333');
|
|
652
649
|
},
|
|
653
650
|
style: {
|
|
654
651
|
cursor: 'pointer'
|
|
@@ -759,7 +756,8 @@ var TableMax = function TableMax(_ref) {
|
|
|
759
756
|
|
|
760
757
|
// 初始化列
|
|
761
758
|
useEffect(function () {
|
|
762
|
-
if (!tableMaxRef.current || !tableContentRef.current) return;
|
|
759
|
+
if (!tableMaxRef.current || !tableContentRef.current || !tableId) return;
|
|
760
|
+
if (!Array.isArray(columns) || columns.length === 0) return;
|
|
763
761
|
// 根据props,自动增加勾选列/展开列
|
|
764
762
|
var newColumns = setColumnsByProps().concat(columns);
|
|
765
763
|
initializeColumnSizing(newColumns);
|
|
@@ -774,7 +772,6 @@ var TableMax = function TableMax(_ref) {
|
|
|
774
772
|
}, [columns, tableId]);
|
|
775
773
|
var _rowSelectionChange = useCallback(debounce(function (rowOriginal, row) {
|
|
776
774
|
if (rowSelectionChange) {
|
|
777
|
-
// console.log(rowOriginal, row, 'rowSelectionChange1')
|
|
778
775
|
rowSelectionChange(rowOriginal, row);
|
|
779
776
|
}
|
|
780
777
|
}, 100), [rowSelectionChange]);
|
|
@@ -843,25 +840,30 @@ var TableMax = function TableMax(_ref) {
|
|
|
843
840
|
// tableMaxRef.current && myObserver.disconnect();
|
|
844
841
|
// };
|
|
845
842
|
// }, [tableId]);
|
|
846
|
-
|
|
843
|
+
var cacheTimer = useRef(null);
|
|
847
844
|
/**缓存table数据 */
|
|
848
845
|
useUpdateEffect(function () {
|
|
849
846
|
if (!tableId) return;
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
847
|
+
cacheTimer.current = setTimeout(function () {
|
|
848
|
+
var tableState = table.getState();
|
|
849
|
+
localStorage.setItem(tableKey, JSON.stringify({
|
|
850
|
+
enableFilters: enableFilters,
|
|
851
|
+
headerRowNum: headerRowNum,
|
|
852
|
+
compactMode: compactMode,
|
|
853
|
+
columnVisibility: tableState.columnVisibility,
|
|
854
|
+
columnPinning: tableState.columnPinning,
|
|
855
|
+
columnOrder: tableState.columnOrder,
|
|
856
|
+
columnFilters: tableState.columnFilters,
|
|
857
|
+
columnSorting: tableState.sorting,
|
|
858
|
+
columnSizing: columnSizing,
|
|
859
|
+
editTime: +new Date(),
|
|
860
|
+
editTimeCh: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
|
861
|
+
version: version
|
|
862
|
+
}));
|
|
863
|
+
}, 100);
|
|
864
|
+
return function () {
|
|
865
|
+
clearTimeout(cacheTimer.current);
|
|
866
|
+
};
|
|
865
867
|
}, [table.getState().columnVisibility, table.getState().columnPinning, table.getState().columnOrder, table.getState().columnFilters, table.getState().sorting, enableFilters, headerRowNum, compactMode, columnSizing, tableId]);
|
|
866
868
|
var reorderRow = useCallback(function (fromDatas, toDatas) {
|
|
867
869
|
var draggedRow = fromDatas.draggedRow,
|
|
@@ -58,6 +58,13 @@ export var useColumnWidth = function useColumnWidth(_ref) {
|
|
|
58
58
|
_useState2 = _slicedToArray(_useState, 2),
|
|
59
59
|
state = _useState2[0],
|
|
60
60
|
setState = _useState2[1];
|
|
61
|
+
// 使用 ref 保存最新的状态值
|
|
62
|
+
var stateRef = useRef(state);
|
|
63
|
+
|
|
64
|
+
// 同步更新 ref
|
|
65
|
+
useEffect(function () {
|
|
66
|
+
stateRef.current = state;
|
|
67
|
+
}, [state]);
|
|
61
68
|
var getTableWidth = useCallback(function () {
|
|
62
69
|
if (!tableContentRef.current) return 0;
|
|
63
70
|
var width = tableContentRef.current.getBoundingClientRect().width;
|
|
@@ -94,32 +101,44 @@ export var useColumnWidth = function useColumnWidth(_ref) {
|
|
|
94
101
|
if (!newWidth) return;
|
|
95
102
|
setState(function (prevState) {
|
|
96
103
|
return produce(prevState, function (draft) {
|
|
97
|
-
|
|
98
|
-
|
|
104
|
+
// console.log('handleResize', 111122, draft.columnSizing)
|
|
105
|
+
// 使用最新的状态值(来自 ref)
|
|
106
|
+
var currentState = stateRef.current;
|
|
107
|
+
var columnSizing = currentState.columnSizing || {};
|
|
108
|
+
var initColumnsSizeMap = currentState.initColumnsSizeMap || {};
|
|
109
|
+
// console.log('handleResize', 111122, draft.columnSizing, newWidth, currentState)
|
|
110
|
+
|
|
111
|
+
var visibleColumns = getVisibleColumns(columnSizing);
|
|
112
|
+
var adjustableColumns = getAdjustableColumns(initColumnsSizeMap);
|
|
99
113
|
var totalVisibleWidth = visibleColumns.reduce(function (sum, key) {
|
|
100
|
-
return sum + (
|
|
114
|
+
return sum + (columnSizing[key] || DEFAULT_MIN_SIZE);
|
|
101
115
|
}, 0);
|
|
102
116
|
|
|
103
117
|
// 容器变大时的逻辑
|
|
104
|
-
if (
|
|
118
|
+
if (currentState.tableContainerWidth && newWidth > currentState.tableContainerWidth) {
|
|
105
119
|
if (totalVisibleWidth < newWidth - DEFAULT_TABLE_PADDING) {
|
|
106
120
|
var remainWidth = newWidth - totalVisibleWidth - DEFAULT_TABLE_PADDING;
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
121
|
+
var addColumns = Object.keys(adjustableColumns).filter(function (key) {
|
|
122
|
+
return columnSizing[key] < DEFAULT_MAX_SIZE;
|
|
123
|
+
});
|
|
124
|
+
if (addColumns.length > 0) {
|
|
125
|
+
var averageWidth = remainWidth / addColumns.length;
|
|
126
|
+
addColumns.forEach(function (key) {
|
|
127
|
+
draft.columnSizing[key] = Math.min((columnSizing[key] || 0) + averageWidth, DEFAULT_MAX_SIZE);
|
|
111
128
|
});
|
|
112
129
|
}
|
|
113
130
|
}
|
|
114
131
|
}
|
|
115
132
|
// 容器变小时的逻辑
|
|
116
|
-
else if (
|
|
133
|
+
else if (currentState.tableContainerWidth && newWidth < currentState.tableContainerWidth) {
|
|
117
134
|
var reducedWidth = newWidth - totalVisibleWidth - DEFAULT_TABLE_PADDING;
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
135
|
+
var reduceColumns = Object.keys(adjustableColumns).filter(function (key) {
|
|
136
|
+
return columnSizing[key] > DEFAULT_MIN_SIZE;
|
|
137
|
+
});
|
|
138
|
+
if (reduceColumns.length > 0) {
|
|
139
|
+
var _averageWidth = reducedWidth / reduceColumns.length;
|
|
140
|
+
reduceColumns.forEach(function (key) {
|
|
141
|
+
draft.columnSizing[key] = Math.max((columnSizing[key] || 0) + _averageWidth, Math.max((initColumnsSizeMap === null || initColumnsSizeMap === void 0 ? void 0 : initColumnsSizeMap[key]) || 0, DEFAULT_MIN_SIZE));
|
|
123
142
|
});
|
|
124
143
|
}
|
|
125
144
|
}
|
|
@@ -134,6 +153,7 @@ export var useColumnWidth = function useColumnWidth(_ref) {
|
|
|
134
153
|
var handleVisibleConfigChange = useCallback(function (key, value) {
|
|
135
154
|
setState(function (prevState) {
|
|
136
155
|
return produce(prevState, function (draft) {
|
|
156
|
+
// console.log(111122, 'handleVisibleConfigChange')
|
|
137
157
|
if (value) {
|
|
138
158
|
// 显示列
|
|
139
159
|
draft.columnSizing[key] = draft.allColumnSizing[key] || DEFAULT_MIN_SIZE;
|
|
@@ -198,6 +218,14 @@ export var useColumnWidth = function useColumnWidth(_ref) {
|
|
|
198
218
|
result[key] = Math.min(result[key] + averageExtra, DEFAULT_MAX_SIZE);
|
|
199
219
|
});
|
|
200
220
|
}
|
|
221
|
+
// debugger
|
|
222
|
+
// console.log({
|
|
223
|
+
// hasWidthColumns,
|
|
224
|
+
// noWidthColumns,
|
|
225
|
+
// totalWidth,
|
|
226
|
+
// remainWidth,
|
|
227
|
+
// result
|
|
228
|
+
// }, 1111222)
|
|
201
229
|
return result;
|
|
202
230
|
}, [getAdjustableColumns, getTableWidth, state.tableContainerWidth]);
|
|
203
231
|
|
|
@@ -215,6 +243,7 @@ export var useColumnWidth = function useColumnWidth(_ref) {
|
|
|
215
243
|
var now = +Date.now();
|
|
216
244
|
setState(produce(function (prevState) {
|
|
217
245
|
// 初始化列宽映射
|
|
246
|
+
// console.log(111122, 'initializeWithWidth')
|
|
218
247
|
var initColumnsSizeMap = _objectSpread({}, columnSizeMap);
|
|
219
248
|
var visibleColumnsSizeMap = {};
|
|
220
249
|
|
|
@@ -254,6 +283,11 @@ export var useColumnWidth = function useColumnWidth(_ref) {
|
|
|
254
283
|
var visibleCount = allCount - Object.keys(columnVisibleConfig).filter(function (key) {
|
|
255
284
|
return !columnVisibleConfig[key];
|
|
256
285
|
}).length;
|
|
286
|
+
// debugger
|
|
287
|
+
// console.log({
|
|
288
|
+
// initColumnsSizeMap,
|
|
289
|
+
// visibleColumnsSizeMap
|
|
290
|
+
// }, 1111222)
|
|
257
291
|
|
|
258
292
|
// 计算最终列宽
|
|
259
293
|
prevState.columnSizing = calculateColumnSizing(visibleColumnsSizeMap, visibleCount, width);
|
|
@@ -286,6 +320,7 @@ export var useColumnWidth = function useColumnWidth(_ref) {
|
|
|
286
320
|
if (!changedColumn || JSON.stringify(changedColumn) === '{}') return;
|
|
287
321
|
setState(produce(function (prevState) {
|
|
288
322
|
var _Object$entries;
|
|
323
|
+
// console.log(111122, 'handleColumnSizingChange')
|
|
289
324
|
var _ref4 = (_Object$entries = Object.entries(changedColumn)) === null || _Object$entries === void 0 ? void 0 : _Object$entries[0],
|
|
290
325
|
_ref5 = _slicedToArray(_ref4, 2),
|
|
291
326
|
changedKey = _ref5[0],
|
|
@@ -328,7 +363,10 @@ export var useColumnWidth = function useColumnWidth(_ref) {
|
|
|
328
363
|
var height = (_entries$2 = entries[0]) === null || _entries$2 === void 0 ? void 0 : _entries$2.contentRect.height;
|
|
329
364
|
if (newWidth || height) {
|
|
330
365
|
var _tableContentRef$curr, _tableContentRef$curr2;
|
|
331
|
-
|
|
366
|
+
var currentState = stateRef.current;
|
|
367
|
+
if (currentState.columnSizing && Object.keys(currentState.columnSizing).length > 0) {
|
|
368
|
+
debouncedHandleResizeRef.current(newWidth);
|
|
369
|
+
}
|
|
332
370
|
(_tableContentRef$curr = tableContentRef.current) === null || _tableContentRef$curr === void 0 || (_tableContentRef$curr = _tableContentRef$curr.style) === null || _tableContentRef$curr === void 0 || _tableContentRef$curr.setProperty('--table-body-width', "".concat(newWidth - 12, "px"));
|
|
333
371
|
(_tableContentRef$curr2 = tableContentRef.current) === null || _tableContentRef$curr2 === void 0 || (_tableContentRef$curr2 = _tableContentRef$curr2.style) === null || _tableContentRef$curr2 === void 0 || _tableContentRef$curr2.setProperty('--table-body-height', "".concat(height - 54, "px"));
|
|
334
372
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arim-aisdc/public-components",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.83",
|
|
4
4
|
"description": "前端组件库",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@ant-design/icons": "^5.3.7",
|
|
50
50
|
"@ant-design/pro-components": "^2.7.10",
|
|
51
|
+
"@arim-aisdc/public-components": "^2.3.82",
|
|
51
52
|
"@tanstack/match-sorter-utils": "^8.8.4",
|
|
52
53
|
"@tanstack/react-table": "^8.9.1",
|
|
53
54
|
"@tanstack/react-virtual": "^3.13.12",
|