@zat-design/sisyphus-react 3.8.2-beta.16 → 3.8.2-beta.18
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/es/ProTable/components/FormatColumn/index.d.ts +3 -1
- package/es/ProTable/components/FormatColumn/index.js +50 -8
- package/es/ProTable/index.js +7 -3
- package/lib/ProTable/components/FormatColumn/index.d.ts +3 -1
- package/lib/ProTable/components/FormatColumn/index.js +49 -7
- package/lib/ProTable/index.js +7 -3
- package/package.json +1 -1
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ProTableColumn } from '../../propsType';
|
|
3
|
-
export declare const formatColumn: ({ column, originalObj, dataSourceObj, rowKey, diffToolTip, wrapToolTipProps, }: {
|
|
3
|
+
export declare const formatColumn: ({ column, originalObj, dataSourceObj, rowKey, diffToolTip, wrapToolTipProps, scroll, onUpdateMinWidth, }: {
|
|
4
4
|
column: ProTableColumn;
|
|
5
5
|
originalObj: any;
|
|
6
6
|
dataSourceObj: any;
|
|
7
7
|
rowKey: any;
|
|
8
8
|
diffToolTip?: boolean;
|
|
9
9
|
wrapToolTipProps?: any;
|
|
10
|
+
scroll?: any;
|
|
11
|
+
onUpdateMinWidth?: any;
|
|
10
12
|
}) => void;
|
|
11
13
|
/**
|
|
12
14
|
* 查找最近的父级className
|
|
@@ -5,20 +5,53 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
5
5
|
import { isValidElement } from 'react';
|
|
6
6
|
import moment from 'moment';
|
|
7
7
|
import classnames from 'classnames';
|
|
8
|
-
import
|
|
8
|
+
import ReactDOM from 'react-dom';
|
|
9
|
+
import { isEqual, isFunction, isString, isObject } from 'lodash';
|
|
9
10
|
import { tools } from '@zat-design/utils';
|
|
10
11
|
import TooltipTitle from '../TooltipTitle';
|
|
11
12
|
import RenderColumn from '../RenderColumn';
|
|
12
13
|
import { getDecimalDigits, getOriginalValue } from '../../utils';
|
|
13
14
|
import getEnumLabel from '../../../ProEnum/utils/getEnumLabel';
|
|
14
15
|
import ProForm from '../../../ProForm';
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
var isReactElement = function isReactElement(element) {
|
|
17
|
+
return /*#__PURE__*/isValidElement(element);
|
|
18
|
+
};
|
|
19
|
+
var calcMinWidth = function calcMinWidth(_ref) {
|
|
20
|
+
var minWidth = _ref.minWidth,
|
|
21
|
+
width = _ref.width,
|
|
22
|
+
title = _ref.title,
|
|
23
|
+
isMaxContentOverFlow = _ref.isMaxContentOverFlow,
|
|
24
|
+
callback = _ref.callback;
|
|
25
|
+
if (!minWidth && !width && isMaxContentOverFlow) {
|
|
26
|
+
var tempEl = document.createElement('div');
|
|
27
|
+
tempEl.style.display = 'inline-block';
|
|
28
|
+
document.body.appendChild(tempEl);
|
|
29
|
+
if (isFunction(title)) {
|
|
30
|
+
var component = title();
|
|
31
|
+
ReactDOM.render(component, tempEl);
|
|
32
|
+
} else if (isReactElement(title)) {
|
|
33
|
+
ReactDOM.render(title, tempEl);
|
|
34
|
+
} else {
|
|
35
|
+
tempEl.innerHTML = title;
|
|
36
|
+
}
|
|
37
|
+
// 使用 requestAnimationFrame 确保在下一个浏览器重绘周期中获取宽度
|
|
38
|
+
requestAnimationFrame(function () {
|
|
39
|
+
var _width = tempEl.offsetWidth;
|
|
40
|
+
ReactDOM.unmountComponentAtNode(tempEl);
|
|
41
|
+
tempEl.remove();
|
|
42
|
+
callback(_width);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
export var formatColumn = function formatColumn(_ref2) {
|
|
47
|
+
var column = _ref2.column,
|
|
48
|
+
originalObj = _ref2.originalObj,
|
|
49
|
+
dataSourceObj = _ref2.dataSourceObj,
|
|
50
|
+
rowKey = _ref2.rowKey,
|
|
51
|
+
diffToolTip = _ref2.diffToolTip,
|
|
52
|
+
wrapToolTipProps = _ref2.wrapToolTipProps,
|
|
53
|
+
scroll = _ref2.scroll,
|
|
54
|
+
onUpdateMinWidth = _ref2.onUpdateMinWidth;
|
|
22
55
|
var title = column.title,
|
|
23
56
|
valueType = column.valueType,
|
|
24
57
|
_column$format = column.format,
|
|
@@ -39,6 +72,15 @@ export var formatColumn = function formatColumn(_ref) {
|
|
|
39
72
|
_column$toolTipProps = column.toolTipProps,
|
|
40
73
|
toolTipProps = _column$toolTipProps === void 0 ? {} : _column$toolTipProps,
|
|
41
74
|
minWidth = column.minWidth;
|
|
75
|
+
// 仅在 {x: 'max-content', y: 300 } 且 column无指定 width minWidth 情况下 才开启 minWidth的自动计算
|
|
76
|
+
var isMaxContentOverFlow = isObject(scroll) ? (scroll === null || scroll === void 0 ? void 0 : scroll.x) === 'max-content' && Reflect.ownKeys(scroll).includes('y') : false;
|
|
77
|
+
calcMinWidth({
|
|
78
|
+
minWidth: minWidth,
|
|
79
|
+
width: width,
|
|
80
|
+
title: title,
|
|
81
|
+
isMaxContentOverFlow: isMaxContentOverFlow,
|
|
82
|
+
callback: onUpdateMinWidth
|
|
83
|
+
});
|
|
42
84
|
var _toolTipProps = _objectSpread(_objectSpread({}, toolTipProps), wrapToolTipProps);
|
|
43
85
|
var _originalDiffTip = diffToolTip !== null && diffToolTip !== void 0 ? diffToolTip : originalDiffTip;
|
|
44
86
|
// 前缀处理
|
package/es/ProTable/index.js
CHANGED
|
@@ -204,18 +204,22 @@ function ProTable(props) {
|
|
|
204
204
|
}).filter(function (item) {
|
|
205
205
|
return !(item === null || item === void 0 ? void 0 : item.delete);
|
|
206
206
|
});
|
|
207
|
-
newColumns === null || newColumns === void 0 ? void 0 : newColumns.forEach(function (item) {
|
|
207
|
+
newColumns === null || newColumns === void 0 ? void 0 : newColumns.forEach(function (item, index) {
|
|
208
208
|
formatColumn({
|
|
209
209
|
column: item,
|
|
210
210
|
originalObj: originalObj,
|
|
211
211
|
dataSourceObj: dataSourceObj,
|
|
212
212
|
rowKey: 'rowKey',
|
|
213
213
|
diffToolTip: toolTip,
|
|
214
|
-
wrapToolTipProps: wrapToolTipProps
|
|
214
|
+
wrapToolTipProps: wrapToolTipProps,
|
|
215
|
+
scroll: _scroll,
|
|
216
|
+
onUpdateMinWidth: function onUpdateMinWidth(w) {
|
|
217
|
+
curColumns[index].minWidth = w;
|
|
218
|
+
}
|
|
215
219
|
});
|
|
216
220
|
});
|
|
217
221
|
return newColumns;
|
|
218
|
-
}, [curColumns, handleResize]);
|
|
222
|
+
}, [curColumns, handleResize, _scroll]);
|
|
219
223
|
var _columns = useMemo(function () {
|
|
220
224
|
return columns === null || columns === void 0 ? void 0 : columns.filter(function (item, index) {
|
|
221
225
|
var show = item.show;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ProTableColumn } from '../../propsType';
|
|
3
|
-
export declare const formatColumn: ({ column, originalObj, dataSourceObj, rowKey, diffToolTip, wrapToolTipProps, }: {
|
|
3
|
+
export declare const formatColumn: ({ column, originalObj, dataSourceObj, rowKey, diffToolTip, wrapToolTipProps, scroll, onUpdateMinWidth, }: {
|
|
4
4
|
column: ProTableColumn;
|
|
5
5
|
originalObj: any;
|
|
6
6
|
dataSourceObj: any;
|
|
7
7
|
rowKey: any;
|
|
8
8
|
diffToolTip?: boolean;
|
|
9
9
|
wrapToolTipProps?: any;
|
|
10
|
+
scroll?: any;
|
|
11
|
+
onUpdateMinWidth?: any;
|
|
10
12
|
}) => void;
|
|
11
13
|
/**
|
|
12
14
|
* 查找最近的父级className
|
|
@@ -10,6 +10,7 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
10
10
|
var _react = require("react");
|
|
11
11
|
var _moment15 = _interopRequireDefault(require("moment"));
|
|
12
12
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
+
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
13
14
|
var _antd = require("antd");
|
|
14
15
|
var _lodash = require("lodash");
|
|
15
16
|
var _utils = require("@zat-design/utils");
|
|
@@ -18,13 +19,45 @@ var _RenderColumn = _interopRequireDefault(require("../RenderColumn"));
|
|
|
18
19
|
var _utils2 = require("../../utils");
|
|
19
20
|
var _getEnumLabel = _interopRequireDefault(require("../../../ProEnum/utils/getEnumLabel"));
|
|
20
21
|
var _ProForm = _interopRequireDefault(require("../../../ProForm"));
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
var isReactElement = function isReactElement(element) {
|
|
23
|
+
return /*#__PURE__*/(0, _react.isValidElement)(element);
|
|
24
|
+
};
|
|
25
|
+
var calcMinWidth = function calcMinWidth(_ref) {
|
|
26
|
+
var minWidth = _ref.minWidth,
|
|
27
|
+
width = _ref.width,
|
|
28
|
+
title = _ref.title,
|
|
29
|
+
isMaxContentOverFlow = _ref.isMaxContentOverFlow,
|
|
30
|
+
callback = _ref.callback;
|
|
31
|
+
if (!minWidth && !width && isMaxContentOverFlow) {
|
|
32
|
+
var tempEl = document.createElement('div');
|
|
33
|
+
tempEl.style.display = 'inline-block';
|
|
34
|
+
document.body.appendChild(tempEl);
|
|
35
|
+
if ((0, _lodash.isFunction)(title)) {
|
|
36
|
+
var component = title();
|
|
37
|
+
_reactDom.default.render(component, tempEl);
|
|
38
|
+
} else if (isReactElement(title)) {
|
|
39
|
+
_reactDom.default.render(title, tempEl);
|
|
40
|
+
} else {
|
|
41
|
+
tempEl.innerHTML = title;
|
|
42
|
+
}
|
|
43
|
+
// 使用 requestAnimationFrame 确保在下一个浏览器重绘周期中获取宽度
|
|
44
|
+
requestAnimationFrame(function () {
|
|
45
|
+
var _width = tempEl.offsetWidth;
|
|
46
|
+
_reactDom.default.unmountComponentAtNode(tempEl);
|
|
47
|
+
tempEl.remove();
|
|
48
|
+
callback(_width);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
var formatColumn = exports.formatColumn = function formatColumn(_ref2) {
|
|
53
|
+
var column = _ref2.column,
|
|
54
|
+
originalObj = _ref2.originalObj,
|
|
55
|
+
dataSourceObj = _ref2.dataSourceObj,
|
|
56
|
+
rowKey = _ref2.rowKey,
|
|
57
|
+
diffToolTip = _ref2.diffToolTip,
|
|
58
|
+
wrapToolTipProps = _ref2.wrapToolTipProps,
|
|
59
|
+
scroll = _ref2.scroll,
|
|
60
|
+
onUpdateMinWidth = _ref2.onUpdateMinWidth;
|
|
28
61
|
var title = column.title,
|
|
29
62
|
valueType = column.valueType,
|
|
30
63
|
_column$format = column.format,
|
|
@@ -45,6 +78,15 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref) {
|
|
|
45
78
|
_column$toolTipProps = column.toolTipProps,
|
|
46
79
|
toolTipProps = _column$toolTipProps === void 0 ? {} : _column$toolTipProps,
|
|
47
80
|
minWidth = column.minWidth;
|
|
81
|
+
// 仅在 {x: 'max-content', y: 300 } 且 column无指定 width minWidth 情况下 才开启 minWidth的自动计算
|
|
82
|
+
var isMaxContentOverFlow = (0, _lodash.isObject)(scroll) ? (scroll === null || scroll === void 0 ? void 0 : scroll.x) === 'max-content' && Reflect.ownKeys(scroll).includes('y') : false;
|
|
83
|
+
calcMinWidth({
|
|
84
|
+
minWidth: minWidth,
|
|
85
|
+
width: width,
|
|
86
|
+
title: title,
|
|
87
|
+
isMaxContentOverFlow: isMaxContentOverFlow,
|
|
88
|
+
callback: onUpdateMinWidth
|
|
89
|
+
});
|
|
48
90
|
var _toolTipProps = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, toolTipProps), wrapToolTipProps);
|
|
49
91
|
var _originalDiffTip = diffToolTip !== null && diffToolTip !== void 0 ? diffToolTip : originalDiffTip;
|
|
50
92
|
// 前缀处理
|
package/lib/ProTable/index.js
CHANGED
|
@@ -211,18 +211,22 @@ function ProTable(props) {
|
|
|
211
211
|
}).filter(function (item) {
|
|
212
212
|
return !(item === null || item === void 0 ? void 0 : item.delete);
|
|
213
213
|
});
|
|
214
|
-
newColumns === null || newColumns === void 0 ? void 0 : newColumns.forEach(function (item) {
|
|
214
|
+
newColumns === null || newColumns === void 0 ? void 0 : newColumns.forEach(function (item, index) {
|
|
215
215
|
(0, _FormatColumn.formatColumn)({
|
|
216
216
|
column: item,
|
|
217
217
|
originalObj: originalObj,
|
|
218
218
|
dataSourceObj: dataSourceObj,
|
|
219
219
|
rowKey: 'rowKey',
|
|
220
220
|
diffToolTip: toolTip,
|
|
221
|
-
wrapToolTipProps: wrapToolTipProps
|
|
221
|
+
wrapToolTipProps: wrapToolTipProps,
|
|
222
|
+
scroll: _scroll,
|
|
223
|
+
onUpdateMinWidth: function onUpdateMinWidth(w) {
|
|
224
|
+
curColumns[index].minWidth = w;
|
|
225
|
+
}
|
|
222
226
|
});
|
|
223
227
|
});
|
|
224
228
|
return newColumns;
|
|
225
|
-
}, [curColumns, handleResize]);
|
|
229
|
+
}, [curColumns, handleResize, _scroll]);
|
|
226
230
|
var _columns = (0, _react.useMemo)(function () {
|
|
227
231
|
return columns === null || columns === void 0 ? void 0 : columns.filter(function (item, index) {
|
|
228
232
|
var show = item.show;
|