@arim-aisdc/public-components 2.3.13 → 2.3.15
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/dist/components/ConfigProvider/context.d.ts +3 -0
- package/dist/components/ConfigProvider/context.js +2 -1
- package/dist/components/TableMax/TableBody/Row.js +4 -1
- package/dist/components/TableMax/TableHeader/utils.js +1 -1
- package/dist/components/TableMax/TableMax.js +0 -5
- package/dist/components/TableMax/components/ColumnFilterV2/index.js +0 -2
- package/dist/components/TableMax/hooks/useColumnWidth.js +3 -10
- package/package.json +1 -1
|
@@ -23,12 +23,15 @@ export interface ConfigConsumerProps {
|
|
|
23
23
|
themePackageName?: 'DefaultThemePackage' | 'DyImsBlueThemePackage';
|
|
24
24
|
/**语言 */
|
|
25
25
|
locale?: Locale;
|
|
26
|
+
/**tablemax dateFormat */
|
|
27
|
+
dateFormat?: string;
|
|
26
28
|
}
|
|
27
29
|
export declare const DEFAULT_CONTEXT: {
|
|
28
30
|
theme: string;
|
|
29
31
|
userId: string;
|
|
30
32
|
tableKeyPrefixCls: string;
|
|
31
33
|
locale: Locale;
|
|
34
|
+
dateFormat: string;
|
|
32
35
|
};
|
|
33
36
|
declare const ConfigContext: import("react").Context<ConfigConsumerProps>;
|
|
34
37
|
export default ConfigContext;
|
|
@@ -7,7 +7,8 @@ export var DEFAULT_CONTEXT = {
|
|
|
7
7
|
theme: 'light',
|
|
8
8
|
userId: '',
|
|
9
9
|
tableKeyPrefixCls: 'TableMax',
|
|
10
|
-
locale: public_zhCN
|
|
10
|
+
locale: public_zhCN,
|
|
11
|
+
dateFormat: 'YYYY-MM-DD HH:mm'
|
|
11
12
|
// locale: public_enUS
|
|
12
13
|
};
|
|
13
14
|
var ConfigContext = /*#__PURE__*/createContext(DEFAULT_CONTEXT);
|
|
@@ -21,6 +21,7 @@ import { getPinningStyle } from "../TableHeader/utils";
|
|
|
21
21
|
import { EditableCell } from "../components/ColumnEdit";
|
|
22
22
|
import "./index.less";
|
|
23
23
|
import dayjs from 'dayjs';
|
|
24
|
+
import { useConfig } from "../../ConfigProvider";
|
|
24
25
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
25
26
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
26
27
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -303,6 +304,8 @@ var Row = function Row(_ref) {
|
|
|
303
304
|
|
|
304
305
|
var rowCom = function rowCom() {
|
|
305
306
|
var _row;
|
|
307
|
+
var _useConfig = useConfig(),
|
|
308
|
+
dateFormat = _useConfig.dateFormat;
|
|
306
309
|
return /*#__PURE__*/_jsx("tr", {
|
|
307
310
|
id: rowEditing ? "".concat(tableId, "-tbody-tr-editing") : undefined,
|
|
308
311
|
ref: function ref(node) {
|
|
@@ -348,7 +351,7 @@ var Row = function Row(_ref) {
|
|
|
348
351
|
// 格式化值获取
|
|
349
352
|
getFormattedValue: function getFormattedValue() {
|
|
350
353
|
var _cell$column$columnDe2;
|
|
351
|
-
return isDateColumn(cell.column.columnDef) ? formatDate(rawValue, (_cell$column$columnDe2 = cell.column.columnDef) === null || _cell$column$columnDe2 === void 0 || (_cell$column$columnDe2 = _cell$column$columnDe2.meta) === null || _cell$column$columnDe2 === void 0 ? void 0 : _cell$column$columnDe2.dateFormat) : rawValue;
|
|
354
|
+
return isDateColumn(cell.column.columnDef) ? formatDate(rawValue, ((_cell$column$columnDe2 = cell.column.columnDef) === null || _cell$column$columnDe2 === void 0 || (_cell$column$columnDe2 = _cell$column$columnDe2.meta) === null || _cell$column$columnDe2 === void 0 ? void 0 : _cell$column$columnDe2.dateFormat) || dateFormat) : rawValue;
|
|
352
355
|
},
|
|
353
356
|
// 默认渲染使用格式化值
|
|
354
357
|
renderValue: function renderValue() {
|
|
@@ -437,7 +437,6 @@ var TableMax = function TableMax(_ref) {
|
|
|
437
437
|
onExpandedChange: setExpanded,
|
|
438
438
|
sortDescFirst: true // 首次排序为递减排序,不加这个属性的话,有些列的排序会有问题
|
|
439
439
|
});
|
|
440
|
-
console.log(tableColumns, 'table.columns');
|
|
441
440
|
|
|
442
441
|
// 暴露给外部的api
|
|
443
442
|
useImperativeHandle(refInstance, function () {
|
|
@@ -715,7 +714,6 @@ var TableMax = function TableMax(_ref) {
|
|
|
715
714
|
/**缓存table数据 */
|
|
716
715
|
useUpdateEffect(function () {
|
|
717
716
|
var tableState = table.getState();
|
|
718
|
-
// console.log('set cache data', compactMode);
|
|
719
717
|
localStorage.setItem(tableKey, JSON.stringify({
|
|
720
718
|
enableFilters: enableFilters,
|
|
721
719
|
headerRowNum: headerRowNum,
|
|
@@ -1051,9 +1049,6 @@ var TableMax = function TableMax(_ref) {
|
|
|
1051
1049
|
compactMode: compactMode,
|
|
1052
1050
|
onEditValueChange: onEditValueChange
|
|
1053
1051
|
};
|
|
1054
|
-
|
|
1055
|
-
// console.log('columnsSizeMap render');
|
|
1056
|
-
|
|
1057
1052
|
var changeCompactMode = function changeCompactMode() {
|
|
1058
1053
|
setCompactMode(!compactMode);
|
|
1059
1054
|
};
|
|
@@ -45,10 +45,8 @@ export function setDefaultFilterFn(columns) {
|
|
|
45
45
|
if (!column.meta) {
|
|
46
46
|
column.meta = {};
|
|
47
47
|
column.meta.isDate = true;
|
|
48
|
-
column.meta.dateFormat = 'YYYY-MM-DD HH:mm';
|
|
49
48
|
} else {
|
|
50
49
|
column.meta.isDate = column.meta.isDate || true;
|
|
51
|
-
column.meta.dateFormat = column.meta.dateFormat || 'YYYY-MM-DD HH:mm';
|
|
52
50
|
}
|
|
53
51
|
}
|
|
54
52
|
if (column.filterType && !column.filterFn && FILTER_FN_ENUM[column.filterType]) {
|
|
@@ -56,6 +56,7 @@ export var useColumnWidth = function useColumnWidth(_ref) {
|
|
|
56
56
|
var handleResize = useCallback(function () {
|
|
57
57
|
if (!tableContentRef.current) return;
|
|
58
58
|
var newWidth = getTableWidth();
|
|
59
|
+
if (!newWidth) return;
|
|
59
60
|
setState(function (prevState) {
|
|
60
61
|
// 计算可见列,排除特定列
|
|
61
62
|
var visibleColumns = Object.keys(prevState.columnSizing).filter(function (key) {
|
|
@@ -81,7 +82,6 @@ export var useColumnWidth = function useColumnWidth(_ref) {
|
|
|
81
82
|
visibleColumns.forEach(function (key) {
|
|
82
83
|
newVisibleColumnsSizing[key] = (newVisibleColumnsSizing[key] || 0) + averageWidth;
|
|
83
84
|
});
|
|
84
|
-
console.log(newVisibleColumnsSizing, 'newVisibleColumnsSizing');
|
|
85
85
|
return _objectSpread(_objectSpread({}, prevState), {}, {
|
|
86
86
|
columnSizing: newVisibleColumnsSizing,
|
|
87
87
|
allColumnSizing: _objectSpread(_objectSpread({}, prevState.allColumnSizing || {}), newVisibleColumnsSizing),
|
|
@@ -89,7 +89,7 @@ export var useColumnWidth = function useColumnWidth(_ref) {
|
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
} else if (prevState.tableContainerWidth > 0 && JSON.stringify(prevState.initColumnsSizeMap) !== '{}') {
|
|
92
|
+
} else if (prevState.tableContainerWidth > 0 && newWidth < prevState.tableContainerWidth && JSON.stringify(prevState.initColumnsSizeMap) !== '{}') {
|
|
93
93
|
// 容器变小时,重新计算
|
|
94
94
|
var reducedWidth = newWidth - totalVisibleWidth - 10;
|
|
95
95
|
var _unselectedCount = visibleColumns.length;
|
|
@@ -139,7 +139,7 @@ export var useColumnWidth = function useColumnWidth(_ref) {
|
|
|
139
139
|
setState(function (prevState) {
|
|
140
140
|
//列宽增加
|
|
141
141
|
if (value) {
|
|
142
|
-
console.log(prevState.allColumnSizing[key], prevState.allColumnSizing, 'prevState.allColumnSizing[key]')
|
|
142
|
+
// console.log(prevState.allColumnSizing[key], prevState.allColumnSizing, 'prevState.allColumnSizing[key]')
|
|
143
143
|
return _objectSpread(_objectSpread({}, prevState), {}, {
|
|
144
144
|
columnSizing: _objectSpread(_objectSpread({}, prevState.columnSizing), {}, {
|
|
145
145
|
key: prevState.allColumnSizing[key]
|
|
@@ -157,7 +157,6 @@ export var useColumnWidth = function useColumnWidth(_ref) {
|
|
|
157
157
|
var totalWidth = Object.values(newVisibleColumnsSizing).reduce(function (sum, width) {
|
|
158
158
|
return Number(sum || 0) + Number(width || 0);
|
|
159
159
|
}, 0);
|
|
160
|
-
console.log(newVisibleColumnsSizing, totalWidth, containerWidth, 'newVisibleColumnsSizing');
|
|
161
160
|
if (containerWidth < totalWidth) {
|
|
162
161
|
// 容器宽度小于增加列后的列总和,其他列宽度不变
|
|
163
162
|
return _objectSpread(_objectSpread({}, prevState), {}, {
|
|
@@ -173,7 +172,6 @@ export var useColumnWidth = function useColumnWidth(_ref) {
|
|
|
173
172
|
joinCalculateColumns === null || joinCalculateColumns === void 0 || joinCalculateColumns.forEach(function (key) {
|
|
174
173
|
newVisibleColumnsSizing[key] = (newVisibleColumnsSizing[key] || 0) + averageWidthIncrease;
|
|
175
174
|
});
|
|
176
|
-
console.log(newVisibleColumnsSizing, joinCalculateColumns, 'newVisibleColumnsSizing', averageWidthIncrease);
|
|
177
175
|
return _objectSpread(_objectSpread({}, prevState), {}, {
|
|
178
176
|
columnSizing: newVisibleColumnsSizing,
|
|
179
177
|
allColumnSizing: _objectSpread(_objectSpread({}, prevState.allColumnSizing), newVisibleColumnsSizing)
|
|
@@ -201,7 +199,6 @@ export var useColumnWidth = function useColumnWidth(_ref) {
|
|
|
201
199
|
}, 0);
|
|
202
200
|
var remainTableContainerWidth = currentWidth - allColumnWidth - 10;
|
|
203
201
|
var newColumnSizeMap = _objectSpread({}, columnsSizeMap);
|
|
204
|
-
console.log(remainColumnCount, 'remainColumnCount');
|
|
205
202
|
|
|
206
203
|
// 处理未设置宽度的列
|
|
207
204
|
if (remainColumnCount > 0) {
|
|
@@ -283,7 +280,6 @@ export var useColumnWidth = function useColumnWidth(_ref) {
|
|
|
283
280
|
});
|
|
284
281
|
setState(function (prevState) {
|
|
285
282
|
var columnSizing = calculateColumnSizing(visibleColumnsSizeMap, newAllColumnCount, prevState.tableContainerWidth);
|
|
286
|
-
console.log(columnSizing, _objectSpread(_objectSpread({}, initColumnsSizeMap), columnSizing), 'columnSizing11');
|
|
287
283
|
return {
|
|
288
284
|
columnSizing: columnSizing,
|
|
289
285
|
allColumnSizing: _objectSpread(_objectSpread({}, initColumnsSizeMap), columnSizing),
|
|
@@ -314,14 +310,12 @@ export var useColumnWidth = function useColumnWidth(_ref) {
|
|
|
314
310
|
|
|
315
311
|
// 创建新的列宽映射
|
|
316
312
|
var newVisibleColumnsSizing = _objectSpread(_objectSpread({}, prevState.columnSizing), changedColumn);
|
|
317
|
-
console.log(newVisibleColumnsSizing, 'newVisibleColumnsSizing');
|
|
318
313
|
|
|
319
314
|
// 计算当前总宽度
|
|
320
315
|
var totalWidth = Object.values(newVisibleColumnsSizing).reduce(function (sum, width) {
|
|
321
316
|
return Number(sum || 0) + Number(width || 0);
|
|
322
317
|
}, 0);
|
|
323
318
|
var containerWidth = getTableWidth() - 10 || 0;
|
|
324
|
-
console.log(widthDiff, newWidth, oldWidth, changedColumnKey, prevState, 3344);
|
|
325
319
|
|
|
326
320
|
// 处理列宽变大
|
|
327
321
|
if (widthDiff > 0) {
|
|
@@ -349,7 +343,6 @@ export var useColumnWidth = function useColumnWidth(_ref) {
|
|
|
349
343
|
} else {
|
|
350
344
|
targetColumnKey = columns[currentIndex + 1]; // 下一列
|
|
351
345
|
}
|
|
352
|
-
console.log(widthDifference, newVisibleColumnsSizing[targetColumnKey], 'newVisibleColumnsSizing');
|
|
353
346
|
// 增加目标列的宽度
|
|
354
347
|
if (targetColumnKey) {
|
|
355
348
|
newVisibleColumnsSizing[targetColumnKey] = (newVisibleColumnsSizing[targetColumnKey] || 0) + widthDifference;
|