@zat-design/sisyphus-react 3.8.2 → 3.8.3-beta.1

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.
Files changed (81) hide show
  1. package/coverage/lcov-report/src/.umi/core/devScripts.ts.html +241 -0
  2. package/coverage/lcov-report/src/.umi/core/history.ts.html +148 -0
  3. package/coverage/lcov-report/src/.umi/core/index.html +206 -0
  4. package/coverage/lcov-report/src/.umi/core/plugin.ts.html +109 -0
  5. package/coverage/lcov-report/src/.umi/core/pluginRegister.ts.html +160 -0
  6. package/coverage/lcov-report/src/.umi/core/polyfill.ts.html +97 -0
  7. package/coverage/lcov-report/src/.umi/core/routes.ts.html +26050 -0
  8. package/coverage/lcov-report/src/.umi/core/umiExports.ts.html +112 -0
  9. package/coverage/lcov-report/src/.umi/dumi/demos/index.html +116 -0
  10. package/coverage/lcov-report/src/.umi/dumi/demos/index.ts.html +6340 -0
  11. package/coverage/lcov-report/src/.umi/dumi/index.html +116 -0
  12. package/coverage/lcov-report/src/.umi/dumi/layout.tsx.html +109 -0
  13. package/coverage/lcov-report/src/.umi/index.html +116 -0
  14. package/coverage/lcov-report/src/.umi/plugin-antd/index.html +116 -0
  15. package/coverage/lcov-report/src/.umi/plugin-antd/runtime.tsx.html +172 -0
  16. package/coverage/lcov-report/src/.umi/plugin-helmet/exports.ts.html +94 -0
  17. package/coverage/lcov-report/src/.umi/plugin-helmet/index.html +116 -0
  18. package/coverage/lcov-report/src/.umi/plugin-initial-state/Provider.tsx.html +196 -0
  19. package/coverage/lcov-report/src/.umi/plugin-initial-state/exports.ts.html +106 -0
  20. package/coverage/lcov-report/src/.umi/plugin-initial-state/index.html +146 -0
  21. package/coverage/lcov-report/src/.umi/plugin-initial-state/models/index.html +116 -0
  22. package/coverage/lcov-report/src/.umi/plugin-initial-state/models/initialState.ts.html +88 -0
  23. package/coverage/lcov-report/src/.umi/plugin-initial-state/runtime.tsx.html +124 -0
  24. package/coverage/lcov-report/src/.umi/plugin-locale/SelectLang.tsx.html +1246 -0
  25. package/coverage/lcov-report/src/.umi/plugin-locale/index.html +161 -0
  26. package/coverage/lcov-report/src/.umi/plugin-locale/locale.tsx.html +268 -0
  27. package/coverage/lcov-report/src/.umi/plugin-locale/localeExports.ts.html +778 -0
  28. package/coverage/lcov-report/src/.umi/plugin-locale/runtime.tsx.html +115 -0
  29. package/coverage/lcov-report/src/.umi/plugin-model/Provider.tsx.html +202 -0
  30. package/coverage/lcov-report/src/.umi/plugin-model/helpers/constant.tsx.html +97 -0
  31. package/coverage/lcov-report/src/.umi/plugin-model/helpers/dispatcher.tsx.html +142 -0
  32. package/coverage/lcov-report/src/.umi/plugin-model/helpers/executor.tsx.html +334 -0
  33. package/coverage/lcov-report/src/.umi/plugin-model/helpers/index.html +146 -0
  34. package/coverage/lcov-report/src/.umi/plugin-model/index.html +146 -0
  35. package/coverage/lcov-report/src/.umi/plugin-model/runtime.tsx.html +121 -0
  36. package/coverage/lcov-report/src/.umi/plugin-model/useModel.tsx.html +298 -0
  37. package/coverage/lcov-report/src/.umi/plugin-request/index.html +116 -0
  38. package/coverage/lcov-report/src/.umi/plugin-request/request.ts.html +919 -0
  39. package/coverage/lcov-report/src/.umi/umi.ts.html +268 -0
  40. package/dist/index.esm.css +16 -8
  41. package/dist/less.esm.css +16 -8
  42. package/es/ProEditTable/components/RenderField/ListChangedWrapper.js +7 -6
  43. package/es/ProEditTable/components/RenderField/index.js +1 -0
  44. package/es/ProEnum/hooks/useEnumRequest.js +1 -1
  45. package/es/ProEnum/index.js +2 -2
  46. package/es/ProForm/components/base/InputNumber/index.js +1 -1
  47. package/es/ProForm/components/combination/Group/component/ComRender.d.ts +1 -0
  48. package/es/ProForm/components/combination/Group/component/ComRender.js +4 -2
  49. package/es/ProForm/components/combination/Group/index.js +6 -3
  50. package/es/ProForm/components/render/ChangedWrapper.js +8 -2
  51. package/es/ProForm/components/render/Render.js +3 -2
  52. package/es/ProForm/components/render/propsType.d.ts +4 -0
  53. package/es/ProForm/style/index.less +15 -2
  54. package/es/ProForm/utils/useShouldUpdate.js +21 -6
  55. package/es/ProTable/components/FormatColumn/index.d.ts +3 -1
  56. package/es/ProTable/components/FormatColumn/index.js +134 -24
  57. package/es/ProTable/components/RenderColumn/index.d.ts +1 -0
  58. package/es/ProTable/components/RenderColumn/index.js +22 -7
  59. package/es/ProTable/index.js +20 -5
  60. package/es/ProTable/style/index.less +8 -6
  61. package/lib/ProEditTable/components/RenderField/ListChangedWrapper.js +10 -9
  62. package/lib/ProEditTable/components/RenderField/index.js +1 -0
  63. package/lib/ProEnum/hooks/useEnumRequest.js +1 -1
  64. package/lib/ProEnum/index.js +2 -2
  65. package/lib/ProForm/components/base/InputNumber/index.js +1 -1
  66. package/lib/ProForm/components/combination/Group/component/ComRender.d.ts +1 -0
  67. package/lib/ProForm/components/combination/Group/component/ComRender.js +4 -2
  68. package/lib/ProForm/components/combination/Group/index.js +6 -3
  69. package/lib/ProForm/components/render/ChangedWrapper.js +8 -2
  70. package/lib/ProForm/components/render/Render.js +3 -2
  71. package/lib/ProForm/components/render/propsType.d.ts +4 -0
  72. package/lib/ProForm/style/index.less +15 -2
  73. package/lib/ProForm/utils/useShouldUpdate.js +19 -4
  74. package/lib/ProTable/components/FormatColumn/index.d.ts +3 -1
  75. package/lib/ProTable/components/FormatColumn/index.js +133 -23
  76. package/lib/ProTable/components/RenderColumn/index.d.ts +1 -0
  77. package/lib/ProTable/components/RenderColumn/index.js +22 -7
  78. package/lib/ProTable/index.js +20 -5
  79. package/lib/ProTable/style/index.less +8 -6
  80. package/package.json +4 -3
  81. package/.vscode/extensions.json +0 -5
@@ -54,8 +54,8 @@ var ProEnum = function ProEnum(props) {
54
54
  showCodeName = _ref2.showCodeName,
55
55
  resProps = (0, _objectWithoutProperties2.default)(_ref2, _excluded2);
56
56
  enumProps.showCodeName = (_enumProps$showCodeNa = enumProps.showCodeName) !== null && _enumProps$showCodeNa !== void 0 ? _enumProps$showCodeNa : showCodeName;
57
- var label = '';
58
- var fieldValue = '';
57
+ var label = 'label';
58
+ var fieldValue = 'value';
59
59
  var _useState = (0, _react.useState)(dataSource || []),
60
60
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
61
61
  dataList = _useState2[0],
@@ -86,7 +86,7 @@ var InputNumber = function InputNumber(props) {
86
86
  var _parser = function parser(value, precision) {
87
87
  if (value === '') return value;
88
88
  var num = Number(value.replace(/[\s,]+/g, ''));
89
- return Number.isNaN(num) || !precision && precision !== 0 ? Number.isNaN(Number(value)) ? null : value : num.toFixed(precision);
89
+ return Number.isNaN(num) || !precision && precision !== 0 ? Number.isNaN(Number(value)) ? null : Number(value) : Number(num.toFixed(precision));
90
90
  };
91
91
  if (valueType) {
92
92
  switch (valueType) {
@@ -14,6 +14,7 @@ interface Props {
14
14
  name?: NamePath;
15
15
  valueType: string;
16
16
  valuePropName?: string;
17
+ isView?: boolean;
17
18
  getValueProps?: (value: any) => Record<string, unknown>;
18
19
  }
19
20
  /** 渲染组件 */
@@ -15,7 +15,7 @@ var _ConfirmWrapper = _interopRequireDefault(require("../../../../components/ren
15
15
  var _useFieldProps = require("../../../../utils/useFieldProps");
16
16
  var componentMap = _interopRequireWildcard(require("../../../../../index"));
17
17
  var _AddonWrapper = _interopRequireDefault(require("./AddonWrapper"));
18
- var _excluded = ["type", "confirm", "component", "fieldProps", "contextProps", "before", "after", "getValueProps", "valuePropName", "valueType"];
18
+ var _excluded = ["type", "confirm", "component", "fieldProps", "contextProps", "before", "after", "getValueProps", "valuePropName", "valueType", "isView"];
19
19
  // 这里的key与组件内参数一致, 决定使用哪个包裹组件
20
20
  var wrapperMap = {
21
21
  confirm: _ConfirmWrapper.default,
@@ -49,6 +49,7 @@ var ComRender = function ComRender(props) {
49
49
  _props$valuePropName = props.valuePropName,
50
50
  valuePropName = _props$valuePropName === void 0 ? 'value' : _props$valuePropName,
51
51
  valueType = props.valueType,
52
+ isView = props.isView,
52
53
  rest = (0, _objectWithoutProperties2.default)(props, _excluded);
53
54
  var TypeComponent = componentMap[type];
54
55
  var mergedGetValueProps = getValueProps || function (val) {
@@ -61,7 +62,8 @@ var ComRender = function ComRender(props) {
61
62
  return (0, _jsxRuntime.jsx)(_useFieldProps.FieldProvider, {
62
63
  value: (0, _objectSpread3.default)((0, _objectSpread3.default)({}, contextProps), {}, {
63
64
  valueType: valueType,
64
- type: type
65
+ type: type,
66
+ isView: isView
65
67
  }),
66
68
  children: Com
67
69
  });
@@ -33,7 +33,8 @@ var Group = function Group(props) {
33
33
  onChange = props.onChange,
34
34
  otherProps = props.otherProps,
35
35
  disabled = props.disabled,
36
- id = props.id;
36
+ id = props.id,
37
+ isView = props.isView;
37
38
  var contextProps = _ProForm.default.useFieldProps() || {};
38
39
  var names = contextProps.names,
39
40
  name = contextProps.name,
@@ -76,7 +77,8 @@ var Group = function Group(props) {
76
77
  children: space.compact || (space === null || space === void 0 ? void 0 : space.separator) ? (0, _jsxRuntime.jsx)(_antd.Space.Compact, {
77
78
  children: columns.map(function (column, index) {
78
79
  return (0, _jsxRuntime.jsx)(_ComRender.default, (0, _objectSpread2.default)((0, _objectSpread2.default)({
79
- contextProps: contextProps
80
+ contextProps: contextProps,
81
+ isView: isView
80
82
  }, column), {}, {
81
83
  otherProps: otherProps
82
84
  }), column.name);
@@ -86,7 +88,8 @@ var Group = function Group(props) {
86
88
  }, (0, _lodash.omit)(space, ['separator', 'compact'])), {}, {
87
89
  children: columns.map(function (column, index) {
88
90
  return (0, _jsxRuntime.jsx)(_ComRender.default, (0, _objectSpread2.default)((0, _objectSpread2.default)({
89
- contextProps: contextProps
91
+ contextProps: contextProps,
92
+ isView: isView
90
93
  }, column), {}, {
91
94
  otherProps: otherProps
92
95
  }), column.name);
@@ -17,7 +17,7 @@ var _react = _interopRequireWildcard(require("react"));
17
17
  var _diffOriginal = require("../../utils/diffOriginal");
18
18
  var _ProConfigProvider = require("../../../ProConfigProvider");
19
19
  var _utils = require("../../../utils");
20
- var _excluded = ["name", "names", "namesStr", "form", "equalWith", "children", "type", "diffConfig", "valuePropName", "normalize"];
20
+ var _excluded = ["name", "names", "namesStr", "form", "equalWith", "children", "type", "diffConfig", "valuePropName", "normalize", "getValueProps"];
21
21
  var ChangedWrapper = function ChangedWrapper(props) {
22
22
  var _diffConfig$toolTip, _children$props, _children$props2, _children$props3;
23
23
  var name = props.name,
@@ -31,6 +31,7 @@ var ChangedWrapper = function ChangedWrapper(props) {
31
31
  _props$valuePropName = props.valuePropName,
32
32
  valuePropName = _props$valuePropName === void 0 ? 'value' : _props$valuePropName,
33
33
  normalize = props.normalize,
34
+ getValueProps = props.getValueProps,
34
35
  rest = (0, _objectWithoutProperties2.default)(props, _excluded);
35
36
  var _useProConfig = (0, _ProConfigProvider.useProConfig)('ProForm'),
36
37
  isDiffAll = _useProConfig.isDiffAll;
@@ -58,9 +59,10 @@ var ChangedWrapper = function ChangedWrapper(props) {
58
59
  var isChanged = diffType === 'changed';
59
60
  var tipContent = (0, _react.useMemo)(function () {
60
61
  if (!isWatch || noChange) return undefined;
62
+ var valueProps = getValueProps ? getValueProps(originalValue) : originalValue;
61
63
  return /*#__PURE__*/_react.default.isValidElement(children) ? /*#__PURE__*/_react.default.cloneElement(children, (0, _objectSpread3.default)((0, _objectSpread3.default)({}, children.props), {}, (0, _defineProperty2.default)({
62
64
  isView: true
63
- }, valuePropName, originalValue))) : undefined;
65
+ }, valuePropName, valueProps === null || valueProps === void 0 ? void 0 : valueProps.value))) : undefined;
64
66
  }, [originalValue, children]);
65
67
  if (!isWatch || noChange) {
66
68
  // 嵌套子组件
@@ -92,9 +94,13 @@ var ChangedWrapper = function ChangedWrapper(props) {
92
94
  },
93
95
  title: (0, _jsxRuntime.jsxs)(_antd.Space, {
94
96
  direction: "vertical",
97
+ className: "changed-tooltip",
95
98
  children: [(0, _jsxRuntime.jsxs)(_antd.Space, {
99
+ align: "start",
100
+ className: "original-value-container",
96
101
  children: ["\u521D\u59CB\u503C\uFF1A", tipContent]
97
102
  }), _showEllipse && (0, _jsxRuntime.jsxs)(_antd.Space, {
103
+ className: "current-value-container",
98
104
  children: ["\u5F53\u524D\u503C\uFF1A", /*#__PURE__*/_react.default.isValidElement(children) ? /*#__PURE__*/_react.default.cloneElement(children, (0, _objectSpread3.default)((0, _objectSpread3.default)((0, _objectSpread3.default)({}, children.props), rest), {}, {
99
105
  isView: true
100
106
  })) : undefined]
@@ -155,7 +155,7 @@ var Render = function Render(props) {
155
155
  };
156
156
  }
157
157
  /** 移除多余参数,防止透传给formItem报错 */
158
- var _otherFormItemProps = (0, _lodash.omit)(otherFormItemProps, ['component', 'names', 'format', 'toISOString', 'toCSTString', 'switchValue', 'precision', 'clearNotShow']);
158
+ var _otherFormItemProps = (0, _lodash.omit)(otherFormItemProps, ['component', 'names', 'format', 'toISOString', 'toCSTString', 'switchValue', 'precision', 'clearNotShow', 'dependNames']);
159
159
  /**
160
160
  * globalControl 全局控制优先
161
161
  * globalControl true时,优先级 全局【formDisabled】> formitem上【column.disabled】 > 组件上【fieldProps.disabled】
@@ -426,7 +426,7 @@ var Render = function Render(props) {
426
426
  span: 24 // 默认占一行
427
427
  });
428
428
  }
429
- if (diffConfig) {
429
+ if (diffConfig === null || diffConfig === void 0 ? void 0 : diffConfig.originalValues) {
430
430
  child = (0, _jsxRuntime.jsx)(_ChangedWrapper.default, {
431
431
  name: formItemProps.name,
432
432
  names: otherProps.names,
@@ -438,6 +438,7 @@ var Render = function Render(props) {
438
438
  onChange: handleChange,
439
439
  valuePropName: _otherFormItemProps.valuePropName,
440
440
  normalize: _otherFormItemProps.normalize,
441
+ getValueProps: _otherFormItemProps.getValueProps,
441
442
  children: child
442
443
  });
443
444
  }
@@ -182,6 +182,8 @@ export interface ProFormColumnProps<Values = any> extends Omit<FormItemProps<Val
182
182
  }) => React.ReactElement<any, any> | string | undefined | null;
183
183
  viewType?: ViewType;
184
184
  colProps?: ColProps;
185
+ /** 依赖刷新字段列表 */
186
+ dependNames?: NamePath[];
185
187
  /**
186
188
  * @description 表单item的props属性
187
189
  * @deprecated 将于下个版本 4.0.0 被弃用
@@ -190,6 +192,8 @@ export interface ProFormColumnProps<Values = any> extends Omit<FormItemProps<Val
190
192
  formItemProps?: FormItemProps<Values> & {
191
193
  index?: number;
192
194
  namePath?: NamePath;
195
+ /** 依赖刷新字段列表 */
196
+ dependNames?: NamePath[];
193
197
  };
194
198
  /**
195
199
  * @description 表单props属性
@@ -387,7 +387,7 @@
387
387
 
388
388
  // textArea
389
389
  .@{ant-prefix}-input-textarea > textarea {
390
- background: @zaui-contract-bg;
390
+ background: @zaui-contract-bg !important;
391
391
  }
392
392
 
393
393
  .pro-form-view-container {
@@ -461,7 +461,7 @@
461
461
 
462
462
  // textArea
463
463
  .@{ant-prefix}-input-textarea > textarea {
464
- background: @zaui-contract-bg-add;
464
+ background: @zaui-contract-bg-add !important;
465
465
  }
466
466
 
467
467
 
@@ -472,3 +472,16 @@
472
472
  }
473
473
  }
474
474
  }
475
+
476
+ .changed-tooltip {
477
+ .original-value-container {
478
+ .ant-space-item:nth-child(1) {
479
+ white-space: nowrap;
480
+ }
481
+ }
482
+ .current-value-container {
483
+ .ant-space-item:nth-child(1) {
484
+ white-space: nowrap;
485
+ }
486
+ }
487
+ }
@@ -27,7 +27,7 @@ var useShouldUpdate = function useShouldUpdate(props) {
27
27
  index = formItemProps.index,
28
28
  namePath = formItemProps.namePath,
29
29
  names = formItemProps.names,
30
- dependencies = formItemProps.dependencies;
30
+ dependNames = formItemProps.dependNames;
31
31
  var timerRef = (0, _react.useRef)();
32
32
  var needClear = (0, _react.useRef)(); // 是否需要执行清值操作
33
33
  var showRef = (0, _react.useRef)();
@@ -36,13 +36,14 @@ var useShouldUpdate = function useShouldUpdate(props) {
36
36
  var rulesRef = (0, _react.useRef)();
37
37
  var fieldPropsRef = (0, _react.useRef)();
38
38
  var originComponentRef = (0, _react.useRef)();
39
+ var dependNamesRef = (0, _react.useRef)();
39
40
  var newComponent = originComponent || component; // 解决component默认赋值污染问题,需要使用originComponent
40
41
  var _useState = (0, _react.useState)({}),
41
42
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
42
43
  reRender = _useState2[1];
43
44
  var values = {};
44
45
  // 不是动态函数直接返回
45
- if (!(0, _lodash.isFunction)(show) && !(0, _lodash.isFunction)(disabled) && !(0, _lodash.isFunction)(required) && !(0, _lodash.isFunction)(rules) && !(0, _lodash.isFunction)(fieldProps) && !(0, _lodash.isFunction)(originComponent)) {
46
+ if (!(dependNames === null || dependNames === void 0 ? void 0 : dependNames.length) && !(0, _lodash.isFunction)(show) && !(0, _lodash.isFunction)(disabled) && !(0, _lodash.isFunction)(required) && !(0, _lodash.isFunction)(rules) && !(0, _lodash.isFunction)(fieldProps) && !(0, _lodash.isFunction)(originComponent)) {
46
47
  return {
47
48
  shouldUpdate: _shouldUpdate,
48
49
  show: show,
@@ -126,9 +127,22 @@ var useShouldUpdate = function useShouldUpdate(props) {
126
127
  } else {
127
128
  fieldPropsRef.current = fieldProps;
128
129
  }
130
+ if (dependNames === null || dependNames === void 0 ? void 0 : dependNames.length) {
131
+ dependNamesRef.current = dependNames.map(function (name) {
132
+ return (0, _lodash.get)(values, name);
133
+ });
134
+ }
129
135
  return {
130
136
  shouldUpdate: function shouldUpdate(prevValues, currentValues) {
131
137
  // @ts-ignore formList场景取当前行数据,不取shouldUpdate变更后值
138
+ if (dependNames === null || dependNames === void 0 ? void 0 : dependNames.length) {
139
+ var curDependNamesValue = dependNames.map(function (name) {
140
+ return (0, _lodash.get)(currentValues, name);
141
+ });
142
+ var dependNamesChanged = !(0, _lodash.isEqualWith)(dependNamesRef.current, curDependNamesValue, _index.customEqualForFun);
143
+ dependNamesRef.current = curDependNamesValue;
144
+ if (!dependNamesChanged) return false;
145
+ }
132
146
  var _currentValues;
133
147
  if (namePath) {
134
148
  // formList场景values取当前行数据
@@ -189,11 +203,12 @@ var useShouldUpdate = function useShouldUpdate(props) {
189
203
  }
190
204
  var equalRes = (0, _lodash.isEqualWith)(rulesRef.current, _rules, _index.customEqualForFun);
191
205
  var proEqualRes = (0, _lodash.isEqualWith)(fieldPropsRef.current, _fieldProps, _index.customEqualForFun);
192
- if (_show !== showRef.current || _disabled !== disabledRef.current || _required !== requiredRef.current || !equalRes || !proEqualRes ||
206
+ if (_show !== showRef.current || _disabled !== disabledRef.current || _required !== requiredRef.current || !equalRes || !proEqualRes
193
207
  // 值变更,需要同步更新函数式的fieldProps
194
208
  // (isEqualWith(fieldPropsRef.current, _fieldProps, customEqualForFun) && !isEqual(prevValues, currentValues)) ||
195
209
  // !isEqualWith(originComponentRef.current, _component, customEqualForFun) ||
196
- (0, _index.equalDependencies)(dependencies, prevValues, _currentValues)) {
210
+ // equalDependencies(dependencies, prevValues, _currentValues)
211
+ ) {
197
212
  showRef.current = _show;
198
213
  disabledRef.current = _disabled;
199
214
  requiredRef.current = _required;
@@ -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 formatColumn = exports.formatColumn = function formatColumn(_ref) {
22
- var column = _ref.column,
23
- originalObj = _ref.originalObj,
24
- dataSourceObj = _ref.dataSourceObj,
25
- rowKey = _ref.rowKey,
26
- diffToolTip = _ref.diffToolTip,
27
- wrapToolTipProps = _ref.wrapToolTipProps;
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,
@@ -43,7 +76,17 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref) {
43
76
  _column$originalDiffT = column.originalDiffTip,
44
77
  originalDiffTip = _column$originalDiffT === void 0 ? true : _column$originalDiffT,
45
78
  _column$toolTipProps = column.toolTipProps,
46
- toolTipProps = _column$toolTipProps === void 0 ? {} : _column$toolTipProps;
79
+ toolTipProps = _column$toolTipProps === void 0 ? {} : _column$toolTipProps,
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
+ });
47
90
  var _toolTipProps = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, toolTipProps), wrapToolTipProps);
48
91
  var _originalDiffTip = diffToolTip !== null && diffToolTip !== void 0 ? diffToolTip : originalDiffTip;
49
92
  // 前缀处理
@@ -71,6 +114,30 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref) {
71
114
  }
72
115
  };
73
116
  if (column === null || column === void 0 ? void 0 : column.render) {
117
+ if (!originalObj && Object.keys(originalObj !== null && originalObj !== void 0 ? originalObj : {}).length === 0) {
118
+ return;
119
+ }
120
+ var originalRender = column.render; // 保存原始的 render 方法
121
+ // 自定义render 手动重载下
122
+ column.render = function (value, record, index) {
123
+ var _originalObj$record$r;
124
+ var isFn = (0, _lodash.isFunction)(originalRender);
125
+ var _value = isFn ? originalRender === null || originalRender === void 0 ? void 0 : originalRender(value, record !== null && record !== void 0 ? record : {}, index) : undefined;
126
+ var originalValue = (0, _utils2.getOriginalValue)(value, record !== null && record !== void 0 ? record : {}, originalObj, rowKey, dataIndex);
127
+ var originalRenderValue = isFn ? originalRender === null || originalRender === void 0 ? void 0 : originalRender(originalValue, (_originalObj$record$r = originalObj === null || originalObj === void 0 ? void 0 : originalObj[record === null || record === void 0 ? void 0 : record[rowKey]]) !== null && _originalObj$record$r !== void 0 ? _originalObj$record$r : {}, index) : undefined;
128
+ return (0, _jsxRuntime.jsx)(_RenderColumn.default, {
129
+ valueType: valueType,
130
+ originalValue: originalValue === undefined ? undefined : originalRenderValue,
131
+ ellipsis: ellipsis,
132
+ width: width,
133
+ value: _value,
134
+ node: _value,
135
+ currentValue: _value,
136
+ originalDiffTip: _originalDiffTip,
137
+ toolTipProps: _toolTipProps,
138
+ minWidth: minWidth
139
+ });
140
+ };
74
141
  return;
75
142
  }
76
143
  if (tooltip) {
@@ -99,7 +166,12 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref) {
99
166
  originalRenderValue = '-';
100
167
  }
101
168
  if (!value && value !== 0 && renderValue === originalRenderValue) {
102
- return '-';
169
+ return (0, _jsxRuntime.jsx)("div", {
170
+ style: {
171
+ minWidth: minWidth
172
+ },
173
+ children: "-"
174
+ });
103
175
  }
104
176
  var node = (0, _jsxRuntime.jsxs)(_antd.Space, {
105
177
  size: 8,
@@ -114,7 +186,8 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref) {
114
186
  value: value,
115
187
  currentValue: renderValue,
116
188
  originalDiffTip: _originalDiffTip,
117
- toolTipProps: _toolTipProps
189
+ toolTipProps: _toolTipProps,
190
+ minWidth: minWidth
118
191
  });
119
192
  };
120
193
  // 千分位, 千分位带CNY前缀
@@ -133,7 +206,12 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref) {
133
206
  children: [prefixNode(value, record, index), renderValue, suffixNode(value, record, index)]
134
207
  });
135
208
  if (!value && value !== 0 && renderValue === originalRenderValue) {
136
- return '-';
209
+ (0, _jsxRuntime.jsx)("div", {
210
+ style: {
211
+ minWidth: minWidth
212
+ },
213
+ children: "-"
214
+ });
137
215
  }
138
216
  return (0, _jsxRuntime.jsx)(_RenderColumn.default, {
139
217
  valueType: valueType,
@@ -144,7 +222,8 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref) {
144
222
  value: value,
145
223
  currentValue: renderValue,
146
224
  originalDiffTip: _originalDiffTip,
147
- toolTipProps: _toolTipProps
225
+ toolTipProps: _toolTipProps,
226
+ minWidth: minWidth
148
227
  });
149
228
  };
150
229
  } else if (['datePicker', 'date', 'dateTime', 'dateStartTime', 'dateEndTime', 'dateStartEndTime'].includes(valueType)) {
@@ -186,7 +265,12 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref) {
186
265
  children: [prefixNode(value, record, index), renderValue, suffixNode(value, record, index)]
187
266
  });
188
267
  if (!value && renderValue === originalRenderValue) {
189
- return '-';
268
+ (0, _jsxRuntime.jsx)("div", {
269
+ style: {
270
+ minWidth: minWidth
271
+ },
272
+ children: "-"
273
+ });
190
274
  }
191
275
  return (0, _jsxRuntime.jsx)(_RenderColumn.default, {
192
276
  valueType: valueType,
@@ -197,7 +281,8 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref) {
197
281
  value: value,
198
282
  currentValue: renderValue,
199
283
  originalDiffTip: _originalDiffTip,
200
- toolTipProps: _toolTipProps
284
+ toolTipProps: _toolTipProps,
285
+ minWidth: minWidth
201
286
  });
202
287
  };
203
288
  } else if (['enumName', 'enumCodeName'].includes(valueType)) {
@@ -235,7 +320,8 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref) {
235
320
  value: value,
236
321
  currentValue: renderValue,
237
322
  originalDiffTip: _originalDiffTip,
238
- toolTipProps: _toolTipProps
323
+ toolTipProps: _toolTipProps,
324
+ minWidth: minWidth
239
325
  });
240
326
  };
241
327
  } else if (precision || prefix || suffix) {
@@ -251,7 +337,12 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref) {
251
337
  originalRenderValue = '-';
252
338
  }
253
339
  if (!value && value !== 0 && renderValue === originalRenderValue) {
254
- return '-';
340
+ (0, _jsxRuntime.jsx)("div", {
341
+ style: {
342
+ minWidth: minWidth
343
+ },
344
+ children: "-"
345
+ });
255
346
  }
256
347
  return (0, _jsxRuntime.jsx)(_RenderColumn.default, {
257
348
  valueType: valueType,
@@ -262,7 +353,8 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref) {
262
353
  value: value,
263
354
  currentValue: renderValue,
264
355
  originalDiffTip: _originalDiffTip,
265
- toolTipProps: _toolTipProps
356
+ toolTipProps: _toolTipProps,
357
+ minWidth: minWidth
266
358
  });
267
359
  };
268
360
  } else if (valueType === 'address') {
@@ -275,7 +367,12 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref) {
275
367
  return !!item;
276
368
  })) === null || _realValue$filter === void 0 ? void 0 : _realValue$filter.length) === 0;
277
369
  if ((0, _lodash.isEqual)(value, originalValue) && isEmpty) {
278
- return '-';
370
+ (0, _jsxRuntime.jsx)("div", {
371
+ style: {
372
+ minWidth: minWidth
373
+ },
374
+ children: "-"
375
+ });
279
376
  }
280
377
  var className = (0, _classnames.default)({
281
378
  'varied-cell': originalValue !== undefined,
@@ -318,7 +415,8 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref) {
318
415
  node: value,
319
416
  value: value,
320
417
  currentValue: value,
321
- toolTipProps: _toolTipProps
418
+ toolTipProps: _toolTipProps,
419
+ minWidth: minWidth
322
420
  }), suffixNode(value, record, index)]
323
421
  });
324
422
  };
@@ -326,7 +424,12 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref) {
326
424
  column.render = function (value, record, index) {
327
425
  var originalValue = (0, _utils2.getOriginalValue)(value, record, originalObj, rowKey, dataIndex);
328
426
  if (!value && value !== 0 && value === originalValue) {
329
- return '-';
427
+ (0, _jsxRuntime.jsx)("div", {
428
+ style: {
429
+ minWidth: minWidth
430
+ },
431
+ children: "-"
432
+ });
330
433
  }
331
434
  return (0, _jsxRuntime.jsxs)(_antd.Space, {
332
435
  size: 8,
@@ -339,7 +442,8 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref) {
339
442
  value: value,
340
443
  currentValue: value || '-',
341
444
  originalDiffTip: _originalDiffTip,
342
- toolTipProps: _toolTipProps
445
+ toolTipProps: _toolTipProps,
446
+ minWidth: minWidth
343
447
  }), suffixNode(value, record, index)]
344
448
  });
345
449
  };
@@ -351,7 +455,12 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref) {
351
455
  children: [prefixNode(value, record, index), value, suffixNode(value, record, index)]
352
456
  });
353
457
  if (!value && value !== 0 && value === originalValue) {
354
- return '-';
458
+ (0, _jsxRuntime.jsx)("div", {
459
+ style: {
460
+ minWidth: minWidth
461
+ },
462
+ children: "-"
463
+ });
355
464
  }
356
465
  return (0, _jsxRuntime.jsx)(_RenderColumn.default, {
357
466
  valueType: valueType,
@@ -362,7 +471,8 @@ var formatColumn = exports.formatColumn = function formatColumn(_ref) {
362
471
  value: value,
363
472
  currentValue: value || '-',
364
473
  originalDiffTip: _originalDiffTip,
365
- toolTipProps: _toolTipProps
474
+ toolTipProps: _toolTipProps,
475
+ minWidth: minWidth
366
476
  });
367
477
  };
368
478
  }
@@ -11,6 +11,7 @@ interface Props {
11
11
  width?: number | string;
12
12
  originalValue?: any;
13
13
  toolTipProps?: TooltipProps & React.RefAttributes<unknown>;
14
+ minWidth?: number;
14
15
  }
15
16
  declare const RenderColumn: FC<Props>;
16
17
  export default RenderColumn;
@@ -27,7 +27,8 @@ var RenderColumn = function RenderColumn(props) {
27
27
  originalValue = props.originalValue,
28
28
  originalDiffTip = props.originalDiffTip,
29
29
  _props$toolTipProps = props.toolTipProps,
30
- toolTipProps = _props$toolTipProps === void 0 ? {} : _props$toolTipProps;
30
+ toolTipProps = _props$toolTipProps === void 0 ? {} : _props$toolTipProps,
31
+ minWidth = props.minWidth;
31
32
  var _useSetState = (0, _ahooks.useSetState)({
32
33
  tooltip: false
33
34
  }),
@@ -40,7 +41,8 @@ var RenderColumn = function RenderColumn(props) {
40
41
  if (ellipsis) {
41
42
  renderNode = (0, _jsxRuntime.jsx)(Text, {
42
43
  style: {
43
- width: currentValue === '-' ? 32.5 : width
44
+ width: currentValue === '-' ? 32.5 : width,
45
+ minWidth: minWidth
44
46
  },
45
47
  ellipsis: {
46
48
  tooltip: false
@@ -51,7 +53,8 @@ var RenderColumn = function RenderColumn(props) {
51
53
  return (0, _jsxRuntime.jsx)(_antd.Tooltip, (0, _objectSpread2.default)((0, _objectSpread2.default)({
52
54
  className: "varied-cell",
53
55
  style: {
54
- width: width
56
+ width: width,
57
+ minWidth: minWidth
55
58
  },
56
59
  title: originalDiffTip ? (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
57
60
  children: ["\u521D\u59CB\u503C\uFF1A", originalValue, (0, _jsxRuntime.jsx)("br", {}), ellipsis ? "\u5F53\u524D\u503C\uFF1A".concat(currentValue) : undefined]
@@ -66,7 +69,8 @@ var RenderColumn = function RenderColumn(props) {
66
69
  return (0, _jsxRuntime.jsx)("span", {
67
70
  className: "varied-cell",
68
71
  style: {
69
- width: width
72
+ width: width,
73
+ minWidth: minWidth
70
74
  },
71
75
  children: renderNode
72
76
  });
@@ -137,7 +141,12 @@ var RenderColumn = function RenderColumn(props) {
137
141
  }
138
142
  }, toolTipProps);
139
143
  if (!value) {
140
- return '-';
144
+ return (0, _jsxRuntime.jsx)("div", {
145
+ style: {
146
+ minWidth: minWidth
147
+ },
148
+ children: "-"
149
+ });
141
150
  }
142
151
  return (0, _jsxRuntime.jsx)(_antd.Tooltip, (0, _objectSpread2.default)((0, _objectSpread2.default)({
143
152
  title: value,
@@ -150,7 +159,8 @@ var RenderColumn = function RenderColumn(props) {
150
159
  }, tooltipProps), {}, {
151
160
  children: (0, _jsxRuntime.jsx)(Text, {
152
161
  style: {
153
- width: width
162
+ width: width,
163
+ minWidth: minWidth
154
164
  },
155
165
  ellipsis: true,
156
166
  onMouseOver: handleMouseOver,
@@ -159,6 +169,11 @@ var RenderColumn = function RenderColumn(props) {
159
169
  })
160
170
  }));
161
171
  }
162
- return value || value === 0 ? node : '-';
172
+ return (0, _jsxRuntime.jsx)("div", {
173
+ style: {
174
+ minWidth: minWidth
175
+ },
176
+ children: value || value === 0 ? node : '-'
177
+ });
163
178
  };
164
179
  var _default = exports.default = RenderColumn;