@zat-design/sisyphus-react 3.4.2 → 3.4.3-beta.10
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/index.esm.css +323 -269
- package/dist/less.esm.css +5042 -0
- package/dist/less.esm.js +3 -0
- package/es/ProConfigProvider/index.d.ts +1 -1
- package/es/ProConfigProvider/index.js +24 -2
- package/es/ProEditLabel/style/index.less +1 -2
- package/es/ProEditTable/components/DndWrapper/index.js +1 -1
- package/es/ProEditTable/components/RenderField/index.js +44 -31
- package/es/ProEditTable/index.js +18 -12
- package/es/ProEditTable/propsType.d.ts +1 -1
- package/es/ProEditTable/style/index.less +1 -1
- package/es/ProEditTable/utils/config.js +5 -5
- package/es/ProEditTable/utils/index.js +67 -30
- package/es/ProEditTable/utils/tools.js +3 -1
- package/es/ProEnum/components/Group.d.ts +2 -0
- package/es/ProEnum/components/Group.js +20 -19
- package/es/ProEnum/index.js +4 -3
- package/es/ProEnum/style/index.less +12 -3
- package/es/ProForm/components/base/DatePicker/index.js +5 -3
- package/es/ProForm/components/combination/FormList/components/ActionButton.js +9 -8
- package/es/ProForm/components/combination/FormList/components/BlockFields.js +4 -0
- package/es/ProForm/components/combination/FormList/components/ToolbarButton.js +1 -1
- package/es/ProForm/components/combination/FormList/index.js +6 -3
- package/es/ProForm/components/combination/FormList/style/index.less +5 -0
- package/es/ProForm/components/combination/FormList/utils.d.ts +2 -1
- package/es/ProForm/components/combination/FormList/utils.js +5 -3
- package/es/ProForm/components/combination/Group/index.js +31 -17
- package/es/ProForm/components/combination/Group/propsType.d.ts +6 -0
- package/es/ProForm/components/combination/Group/style/index.less +4 -4
- package/es/ProForm/components/combination/Group/utils.d.ts +2 -0
- package/es/ProForm/components/combination/Group/utils.js +10 -0
- package/es/ProForm/components/combination/ProNumberRange/style/index.less +1 -1
- package/es/ProForm/components/combination/ProTimeLimit/index.js +8 -2
- package/es/ProForm/components/combination/ProTimeLimit/style/index.less +1 -1
- package/es/ProForm/components/index.d.ts +0 -1
- package/es/ProForm/components/index.js +1 -1
- package/es/ProForm/components/render/ConfirmWrapper.js +1 -1
- package/es/ProForm/components/render/Render.js +31 -22
- package/es/ProForm/components/render/RenderFields.d.ts +3 -2
- package/es/ProForm/components/render/RenderFields.js +7 -3
- package/es/ProForm/components/render/propsType.d.ts +2 -5
- package/es/ProForm/index.js +12 -11
- package/es/ProForm/propsType.d.ts +7 -3
- package/es/ProForm/style/index.less +36 -14
- package/es/ProForm/utils/{contrastOriginal.d.ts → diffOriginal.d.ts} +2 -1
- package/es/ProForm/utils/diffOriginal.js +46 -0
- package/es/ProForm/utils/index.d.ts +2 -2
- package/es/ProForm/utils/index.js +16 -6
- package/es/ProForm/utils/rulesCreator.d.ts +7 -1
- package/es/ProForm/utils/rulesCreator.js +45 -3
- package/es/ProForm/utils/transformNames.d.ts +1 -1
- package/es/ProForm/utils/transformNames.js +11 -4
- package/es/ProForm/utils/transformValue.js +2 -2
- package/es/ProForm/utils/useChanged.js +4 -3
- package/es/ProForm/utils/useListChanged.d.ts +1 -1
- package/es/ProForm/utils/useListChanged.js +5 -3
- package/es/ProForm/utils/useRules.js +36 -11
- package/es/ProForm/utils/useShouldUpdate.js +4 -4
- package/es/ProForm/utils/valueType.d.ts +10 -5
- package/es/ProForm/utils/valueType.js +20 -10
- package/es/ProIcon/config/index.d.ts +2 -1
- package/es/ProIcon/config/index.js +191 -133
- package/es/ProIcon/index.d.ts +0 -1
- package/es/ProIcon/index.js +21 -36
- package/es/ProIcon/propsTypes.d.ts +2 -1
- package/es/ProLayout/components/Layout/Header/style/index.less +1 -1
- package/es/ProLayout/components/Layout/Menu/OpenMenu/style/index.less +58 -55
- package/es/ProLayout/components/Layout/Menu/SideMenu/style/index.less +25 -20
- package/es/ProLayout/components/Layout/Menu/style/index.less +52 -56
- package/es/ProLayout/components/ProCollapse/PropTypes.d.ts +5 -0
- package/es/ProLayout/components/ProCollapse/index.js +45 -4
- package/es/ProLayout/components/ProCollapse/style/index.less +30 -12
- package/es/ProLayout/components/ProFooter/index.js +1 -1
- package/es/ProLayout/components/ProFooter/style/index.less +1 -1
- package/es/ProLayout/components/ProHeader/style/index.less +6 -5
- package/es/ProLayout/style/index.less +176 -88
- package/es/ProStep/components/Item/index.js +2 -1
- package/es/ProStep/style/index.less +71 -70
- package/es/ProTable/components/RenderColumn/index.d.ts +1 -1
- package/es/ProTable/components/RenderColumn/index.js +3 -3
- package/es/ProTable/propsType.d.ts +1 -1
- package/es/ProTable/style/index.less +2 -2
- package/es/ProTable/utils.js +9 -9
- package/es/ProTabs/style/index.less +3 -1
- package/es/ProThemeTools/component/PrdTools/index.d.ts +1 -1
- package/es/ProThemeTools/component/PrdTools/index.js +14 -52
- package/es/ProThemeTools/component/PrdTools/style/index.less +1 -1
- package/es/ProThemeTools/index.js +21 -29
- package/es/ProThemeTools/propsType.d.ts +1 -1
- package/es/ProThemeTools/style/index.less +25 -8
- package/es/{ProTreeSelect → ProTree/components/ProTreeSelect}/index.js +7 -11
- package/es/{ProTreeSelect → ProTree/components/ProTreeSelect}/propsType.d.ts +1 -1
- package/es/{ProTreeSelect → ProTree/components/ProTreeSelect}/style/index.less +1 -1
- package/es/ProTree/index.js +1 -1
- package/es/ProTree/style/index.less +5 -0
- package/es/ProTreeModal/style/index.less +2 -2
- package/es/ProUpload/style/fileItem.less +2 -2
- package/es/ProUpload/style/index.less +3 -3
- package/es/assets/catalog.svg +30 -1
- package/es/assets/fold.svg +27 -0
- package/es/assets/setting.svg +14 -0
- package/es/locale/en_US.d.ts +7 -2
- package/es/locale/en_US.js +7 -2
- package/es/locale/zh_CN.d.ts +7 -2
- package/es/locale/zh_CN.js +7 -2
- package/es/style/components.less +0 -4
- package/es/style/less.less +2 -0
- package/es/style/theme/antd.less +14 -29
- package/es/style/theme/index.less +2 -2
- package/es/style/theme/tokens.less +2 -2
- package/es/tokens.js +2 -2
- package/lib/ProConfigProvider/index.d.ts +1 -1
- package/lib/ProConfigProvider/index.js +23 -1
- package/lib/ProEditLabel/style/index.less +1 -2
- package/lib/ProEditTable/components/DndWrapper/index.js +1 -1
- package/lib/ProEditTable/components/RenderField/index.js +41 -28
- package/lib/ProEditTable/index.js +18 -12
- package/lib/ProEditTable/propsType.d.ts +1 -1
- package/lib/ProEditTable/style/index.less +1 -1
- package/lib/ProEditTable/utils/config.js +5 -5
- package/lib/ProEditTable/utils/index.js +67 -30
- package/lib/ProEditTable/utils/tools.js +3 -1
- package/lib/ProEnum/components/Group.d.ts +2 -0
- package/lib/ProEnum/components/Group.js +20 -19
- package/lib/ProEnum/index.js +4 -3
- package/lib/ProEnum/style/index.less +12 -3
- package/lib/ProForm/components/base/DatePicker/index.js +4 -2
- package/lib/ProForm/components/combination/FormList/components/ActionButton.js +9 -8
- package/lib/ProForm/components/combination/FormList/components/BlockFields.js +4 -0
- package/lib/ProForm/components/combination/FormList/components/ToolbarButton.js +1 -1
- package/lib/ProForm/components/combination/FormList/index.js +6 -3
- package/lib/ProForm/components/combination/FormList/style/index.less +5 -0
- package/lib/ProForm/components/combination/FormList/utils.d.ts +2 -1
- package/lib/ProForm/components/combination/FormList/utils.js +5 -3
- package/lib/ProForm/components/combination/Group/index.js +28 -14
- package/lib/ProForm/components/combination/Group/propsType.d.ts +6 -0
- package/lib/ProForm/components/combination/Group/style/index.less +4 -4
- package/lib/ProForm/components/combination/Group/utils.d.ts +2 -0
- package/lib/ProForm/components/combination/Group/utils.js +11 -1
- package/lib/ProForm/components/combination/ProNumberRange/style/index.less +1 -1
- package/lib/ProForm/components/combination/ProTimeLimit/index.js +7 -1
- package/lib/ProForm/components/combination/ProTimeLimit/style/index.less +1 -1
- package/lib/ProForm/components/index.d.ts +0 -1
- package/lib/ProForm/components/index.js +0 -7
- package/lib/ProForm/components/render/ConfirmWrapper.js +1 -1
- package/lib/ProForm/components/render/Render.js +31 -22
- package/lib/ProForm/components/render/RenderFields.d.ts +3 -2
- package/lib/ProForm/components/render/RenderFields.js +7 -3
- package/lib/ProForm/components/render/propsType.d.ts +2 -5
- package/lib/ProForm/index.js +11 -10
- package/lib/ProForm/propsType.d.ts +7 -3
- package/lib/ProForm/style/index.less +36 -14
- package/lib/ProForm/utils/{contrastOriginal.d.ts → diffOriginal.d.ts} +2 -1
- package/lib/ProForm/utils/diffOriginal.js +53 -0
- package/lib/ProForm/utils/index.d.ts +2 -2
- package/lib/ProForm/utils/index.js +17 -7
- package/lib/ProForm/utils/rulesCreator.d.ts +7 -1
- package/lib/ProForm/utils/rulesCreator.js +45 -2
- package/lib/ProForm/utils/transformNames.d.ts +1 -1
- package/lib/ProForm/utils/transformNames.js +10 -3
- package/lib/ProForm/utils/transformValue.js +1 -1
- package/lib/ProForm/utils/useChanged.js +4 -3
- package/lib/ProForm/utils/useListChanged.d.ts +1 -1
- package/lib/ProForm/utils/useListChanged.js +5 -3
- package/lib/ProForm/utils/useRules.js +36 -11
- package/lib/ProForm/utils/useShouldUpdate.js +4 -4
- package/lib/ProForm/utils/valueType.d.ts +10 -5
- package/lib/ProForm/utils/valueType.js +20 -10
- package/lib/ProIcon/config/index.d.ts +2 -1
- package/lib/ProIcon/config/index.js +191 -133
- package/lib/ProIcon/index.d.ts +0 -1
- package/lib/ProIcon/index.js +21 -37
- package/lib/ProIcon/propsTypes.d.ts +2 -1
- package/lib/ProLayout/components/Layout/Header/style/index.less +1 -1
- package/lib/ProLayout/components/Layout/Menu/OpenMenu/style/index.less +58 -55
- package/lib/ProLayout/components/Layout/Menu/SideMenu/style/index.less +25 -20
- package/lib/ProLayout/components/Layout/Menu/style/index.less +52 -56
- package/lib/ProLayout/components/ProCollapse/PropTypes.d.ts +5 -0
- package/lib/ProLayout/components/ProCollapse/index.js +43 -4
- package/lib/ProLayout/components/ProCollapse/style/index.less +30 -12
- package/lib/ProLayout/components/ProFooter/index.js +1 -1
- package/lib/ProLayout/components/ProFooter/style/index.less +1 -1
- package/lib/ProLayout/components/ProHeader/style/index.less +6 -5
- package/lib/ProLayout/style/index.less +176 -88
- package/lib/ProStep/components/Item/index.js +2 -1
- package/lib/ProStep/style/index.less +71 -70
- package/lib/ProTable/components/RenderColumn/index.d.ts +1 -1
- package/lib/ProTable/components/RenderColumn/index.js +3 -3
- package/lib/ProTable/propsType.d.ts +1 -1
- package/lib/ProTable/style/index.less +2 -2
- package/lib/ProTable/utils.js +9 -9
- package/lib/ProTabs/style/index.less +3 -1
- package/lib/ProThemeTools/component/PrdTools/index.d.ts +1 -1
- package/lib/ProThemeTools/component/PrdTools/index.js +14 -52
- package/lib/ProThemeTools/component/PrdTools/style/index.less +1 -1
- package/lib/ProThemeTools/index.js +19 -28
- package/lib/ProThemeTools/propsType.d.ts +1 -1
- package/lib/ProThemeTools/style/index.less +25 -8
- package/lib/{ProTreeSelect → ProTree/components/ProTreeSelect}/index.js +7 -11
- package/lib/{ProTreeSelect → ProTree/components/ProTreeSelect}/propsType.d.ts +1 -1
- package/lib/{ProTreeSelect → ProTree/components/ProTreeSelect}/style/index.less +1 -1
- package/lib/ProTree/index.js +1 -1
- package/lib/ProTree/style/index.less +5 -0
- package/lib/ProTreeModal/style/index.less +2 -2
- package/lib/ProUpload/style/fileItem.less +2 -2
- package/lib/ProUpload/style/index.less +3 -3
- package/lib/assets/catalog.svg +30 -1
- package/lib/assets/fold.svg +27 -0
- package/lib/assets/setting.svg +14 -0
- package/lib/locale/en_US.d.ts +7 -2
- package/lib/locale/en_US.js +7 -2
- package/lib/locale/zh_CN.d.ts +7 -2
- package/lib/locale/zh_CN.js +7 -2
- package/lib/style/components.less +0 -4
- package/lib/style/less.less +2 -0
- package/lib/style/theme/antd.less +14 -29
- package/lib/style/theme/index.less +2 -2
- package/lib/style/theme/tokens.less +2 -2
- package/lib/tokens.js +2 -2
- package/package.json +2 -2
- package/es/ProForm/utils/contrastOriginal.js +0 -24
- package/es/ProIcon/symbolIcon.js +0 -43
- package/lib/ProForm/utils/contrastOriginal.js +0 -30
- package/lib/ProIcon/symbolIcon.js +0 -45
- /package/es/{ProTreeSelect → ProTree/components/ProTreeSelect}/index.d.ts +0 -0
- /package/es/{ProTreeSelect → ProTree/components/ProTreeSelect}/propsType.js +0 -0
- /package/lib/{ProTreeSelect → ProTree/components/ProTreeSelect}/index.d.ts +0 -0
- /package/lib/{ProTreeSelect → ProTree/components/ProTreeSelect}/propsType.js +0 -0
|
@@ -34,7 +34,7 @@ import useRules from '../../utils/useRules';
|
|
|
34
34
|
import ConfirmWrapper from './ConfirmWrapper';
|
|
35
35
|
// 这个组件只管渲染, 参数的整理在外部处理
|
|
36
36
|
var Render = function Render(props) {
|
|
37
|
-
var _ref2, _ref3, _otherProps$names2;
|
|
37
|
+
var _ref2, _ref3, _ref4, _ref5, _otherProps$names2;
|
|
38
38
|
var component = props.component,
|
|
39
39
|
originComponent = props.originComponent,
|
|
40
40
|
_props$formItemProps = props.formItemProps,
|
|
@@ -52,8 +52,9 @@ var Render = function Render(props) {
|
|
|
52
52
|
originalValues = props.originalValues,
|
|
53
53
|
equalWith = props.equalWith,
|
|
54
54
|
requiredOnView = props.requiredOnView,
|
|
55
|
-
|
|
56
|
-
confirm = props.confirm
|
|
55
|
+
originalDiffTip = props.originalDiffTip,
|
|
56
|
+
confirm = props.confirm,
|
|
57
|
+
globalControl = props.globalControl;
|
|
57
58
|
var colProps = props.colProps;
|
|
58
59
|
// 剔除一些不是FormItem的属性, 防止控制台报warning
|
|
59
60
|
var labelWidth = formItemProps.labelWidth,
|
|
@@ -149,13 +150,13 @@ var Render = function Render(props) {
|
|
|
149
150
|
*/
|
|
150
151
|
var transforms = Array.isArray(otherProps === null || otherProps === void 0 ? void 0 : otherProps.names) ? transformNames(_objectSpread(_objectSpread({}, otherFormItemProps), valueTypeTransform()),
|
|
151
152
|
// 合并valueType的transform
|
|
152
|
-
form, otherProps.names, namesStr) : valueTypeTransform();
|
|
153
|
+
form, otherProps.names, namesStr, otherProps.type) : valueTypeTransform();
|
|
153
154
|
// ↑↑↑↑↑↑ formItem参数整理 ↑↑↑↑↑↑
|
|
154
155
|
Object.assign(otherFormItemProps, transforms, {
|
|
155
156
|
names: otherProps.names
|
|
156
|
-
}, internalRule,
|
|
157
|
-
required: labelRequired
|
|
158
|
-
}
|
|
157
|
+
}, internalRule, {
|
|
158
|
+
required: typeof labelRequired === 'boolean' ? labelRequired : _required
|
|
159
|
+
}, otherProps.isView && !requiredOnView ? {
|
|
159
160
|
required: false
|
|
160
161
|
} : null, _objectSpread({}, isTrim(type, trim, useProConfig())), // 优先取传进来的,其次取ProConfigProvider配置的
|
|
161
162
|
_objectSpread({}, isUpperCase(type, upperCase)), {
|
|
@@ -169,8 +170,12 @@ var Render = function Render(props) {
|
|
|
169
170
|
}
|
|
170
171
|
/** 移除多余参数,防止透传给formItem报错 */
|
|
171
172
|
var _otherFormItemProps = omit(otherFormItemProps, ['component', 'names', 'format', 'toISOString', 'switchValue', 'precision', 'clearNotShow']);
|
|
172
|
-
|
|
173
|
-
|
|
173
|
+
/**
|
|
174
|
+
* globalControl 全局控制优先
|
|
175
|
+
* globalControl true时,优先级 全局【formDisabled】> formitem上【column.disabled】 > 组件上【fieldProps.disabled】
|
|
176
|
+
* globalControl false时,优先级 组件上【fieldProps.disabled】 > formitem上【column.disabled】 > 全局【formDisabled】
|
|
177
|
+
*/
|
|
178
|
+
var lastDisabled = globalControl ? (_ref2 = (_ref3 = formDisabled !== null && formDisabled !== void 0 ? formDisabled : _disabled) !== null && _ref3 !== void 0 ? _ref3 : _fieldProps === null || _fieldProps === void 0 ? void 0 : _fieldProps.disabled) !== null && _ref2 !== void 0 ? _ref2 : componentProps === null || componentProps === void 0 ? void 0 : componentProps.disabled : (_ref4 = (_ref5 = _disabled !== null && _disabled !== void 0 ? _disabled : _fieldProps === null || _fieldProps === void 0 ? void 0 : _fieldProps.disabled) !== null && _ref5 !== void 0 ? _ref5 : componentProps === null || componentProps === void 0 ? void 0 : componentProps.disabled) !== null && _ref4 !== void 0 ? _ref4 : formDisabled;
|
|
174
179
|
/**
|
|
175
180
|
* 最新fieldProps: 更新后的组件Props
|
|
176
181
|
*/
|
|
@@ -198,8 +203,8 @@ var Render = function Render(props) {
|
|
|
198
203
|
var functionArgs = function functionArgs(args) {
|
|
199
204
|
var _otherFormItemProps$n;
|
|
200
205
|
var _args = _toConsumableArray(args);
|
|
201
|
-
var
|
|
202
|
-
valueType =
|
|
206
|
+
var _ref6 = otherProps || {},
|
|
207
|
+
valueType = _ref6.valueType;
|
|
203
208
|
_args[1] = form.getFieldsValue();
|
|
204
209
|
_args[2] = {
|
|
205
210
|
form: form
|
|
@@ -217,12 +222,8 @@ var Render = function Render(props) {
|
|
|
217
222
|
if (valueType) {
|
|
218
223
|
_args[2].transformValue = form.getFieldValue(_otherFormItemProps === null || _otherFormItemProps === void 0 ? void 0 : _otherFormItemProps.name) || undefined;
|
|
219
224
|
}
|
|
225
|
+
_args[2].option = args[1];
|
|
220
226
|
switch (type) {
|
|
221
|
-
case 'ProSelect':
|
|
222
|
-
case 'ProModalSelect':
|
|
223
|
-
case 'ProEnum':
|
|
224
|
-
_args[2].option = args[1];
|
|
225
|
-
break;
|
|
226
227
|
case 'ProAddressBar':
|
|
227
228
|
_args[2].selectedOptions = args[1];
|
|
228
229
|
break;
|
|
@@ -239,7 +240,7 @@ var Render = function Render(props) {
|
|
|
239
240
|
* onChange参数重置 (value, record, { form, index, namePath, option }) => void
|
|
240
241
|
*/
|
|
241
242
|
var handleChange = function handleChange() {
|
|
242
|
-
var _lastComponentProps$c2;
|
|
243
|
+
var _otherFormItemProps$n3, _lastComponentProps$c2;
|
|
243
244
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
244
245
|
args[_key] = arguments[_key];
|
|
245
246
|
}
|
|
@@ -257,6 +258,11 @@ var Render = function Render(props) {
|
|
|
257
258
|
((_AutoComponent$props$ = (_AutoComponent$props = AutoComponent === null || AutoComponent === void 0 ? void 0 : AutoComponent.props)[changeKey]) === null || _AutoComponent$props$ === void 0 ? void 0 : _AutoComponent$props$.call.apply(_AutoComponent$props$, [_AutoComponent$props].concat(_toConsumableArray(_args)))) || ((_lastComponentProps$c = lastComponentProps[changeKey]) === null || _lastComponentProps$c === void 0 ? void 0 : _lastComponentProps$c.call.apply(_lastComponentProps$c, [lastComponentProps].concat(_toConsumableArray(_args))));
|
|
258
259
|
return false;
|
|
259
260
|
}
|
|
261
|
+
var inList = _otherFormItemProps === null || _otherFormItemProps === void 0 ? void 0 : (_otherFormItemProps$n3 = _otherFormItemProps.namePath) === null || _otherFormItemProps$n3 === void 0 ? void 0 : _otherFormItemProps$n3.length;
|
|
262
|
+
// FormList 和 Group场景 对比值改变的话, 回显到表单上
|
|
263
|
+
if (inList) {
|
|
264
|
+
form.setFieldsValue(_args[1]);
|
|
265
|
+
}
|
|
260
266
|
// Group默认校验, 延时与重新setFieldValue,为了解决校验值未同步最新的问题,
|
|
261
267
|
if (formItemProps === null || formItemProps === void 0 ? void 0 : formItemProps.parentNames) {
|
|
262
268
|
setTimeout(function () {
|
|
@@ -266,7 +272,7 @@ var Render = function Render(props) {
|
|
|
266
272
|
}, 60);
|
|
267
273
|
}
|
|
268
274
|
// ProTreeSelect返回option
|
|
269
|
-
if (['
|
|
275
|
+
if (['ProTree'].includes(type)) {
|
|
270
276
|
var _args2, _args2$;
|
|
271
277
|
_args[2].option = findOptionByValue(lastComponentProps === null || lastComponentProps === void 0 ? void 0 : lastComponentProps.dataSource, (_args2 = _args) === null || _args2 === void 0 ? void 0 : (_args2$ = _args2[0]) === null || _args2$ === void 0 ? void 0 : _args2$[0]);
|
|
272
278
|
}
|
|
@@ -276,7 +282,7 @@ var Render = function Render(props) {
|
|
|
276
282
|
* onBlur参数重置 (value, record, { form, index, namePath, option }) => void
|
|
277
283
|
*/
|
|
278
284
|
var handleBlur = /*#__PURE__*/function () {
|
|
279
|
-
var
|
|
285
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
280
286
|
var _len2,
|
|
281
287
|
args,
|
|
282
288
|
_key2,
|
|
@@ -303,7 +309,7 @@ var Render = function Render(props) {
|
|
|
303
309
|
}, _callee);
|
|
304
310
|
}));
|
|
305
311
|
return function handleBlur() {
|
|
306
|
-
return
|
|
312
|
+
return _ref7.apply(this, arguments);
|
|
307
313
|
};
|
|
308
314
|
}();
|
|
309
315
|
var renderItem = function renderItem() {
|
|
@@ -380,7 +386,7 @@ var Render = function Render(props) {
|
|
|
380
386
|
};
|
|
381
387
|
}
|
|
382
388
|
// 需要过滤掉的form_item的key
|
|
383
|
-
var filterFormItemKey = ['onFieldChange', 'shouldUpdate', 'namePath', 'isView', 'parentNames', 'space', 'before', 'after'];
|
|
389
|
+
var filterFormItemKey = ['onFieldChange', 'shouldUpdate', 'namePath', 'isView', 'parentNames', 'space', 'before', 'after', 'globalControl'];
|
|
384
390
|
if (type === 'FormList') {
|
|
385
391
|
lastComponentProps.disabled = lastDisabled;
|
|
386
392
|
var lessMode = lastComponentProps.mode === 'less';
|
|
@@ -429,7 +435,7 @@ var Render = function Render(props) {
|
|
|
429
435
|
});
|
|
430
436
|
}
|
|
431
437
|
// 不渲染tooltip
|
|
432
|
-
if (!
|
|
438
|
+
if (!originalDiffTip || ['FormList', 'ProEditTable'].includes(type)) {
|
|
433
439
|
return formItem;
|
|
434
440
|
}
|
|
435
441
|
var title = _jsxs(_Space, {
|
|
@@ -442,6 +448,9 @@ var Render = function Render(props) {
|
|
|
442
448
|
return _jsx(_Tooltip, {
|
|
443
449
|
title: title,
|
|
444
450
|
visible: changed ? undefined : false,
|
|
451
|
+
getPopupContainer: function getPopupContainer(target) {
|
|
452
|
+
return target.parentElement;
|
|
453
|
+
},
|
|
445
454
|
children: formItem
|
|
446
455
|
});
|
|
447
456
|
};
|
|
@@ -16,8 +16,9 @@ interface Props<T = any> {
|
|
|
16
16
|
originalValues?: ProFormProps<T>['originalValues'];
|
|
17
17
|
clearNotShow?: boolean;
|
|
18
18
|
requiredOnView?: boolean;
|
|
19
|
-
required?: boolean | (() => boolean);
|
|
20
|
-
|
|
19
|
+
required?: boolean | boolean[] | (() => boolean | boolean[]);
|
|
20
|
+
originalDiffTip?: boolean;
|
|
21
|
+
globalControl?: boolean;
|
|
21
22
|
}
|
|
22
23
|
declare const RenderFields: React.FC<Props>;
|
|
23
24
|
export default RenderFields;
|
|
@@ -25,7 +25,8 @@ var RenderFields = function RenderFields(props) {
|
|
|
25
25
|
outerClearNotShow = props.clearNotShow,
|
|
26
26
|
requiredOnView = props.requiredOnView,
|
|
27
27
|
required = props.required,
|
|
28
|
-
|
|
28
|
+
originalDiffTip = props.originalDiffTip,
|
|
29
|
+
globalControl = props.globalControl;
|
|
29
30
|
// 是否包含隐藏字段
|
|
30
31
|
var hiddenData = columns.filter(function (item) {
|
|
31
32
|
return Array.isArray(item.hiddenNames);
|
|
@@ -175,7 +176,9 @@ var RenderFields = function RenderFields(props) {
|
|
|
175
176
|
form: form,
|
|
176
177
|
type: _type,
|
|
177
178
|
hiddenNames: column.hiddenNames,
|
|
178
|
-
colProps: _colProps
|
|
179
|
+
colProps: _colProps,
|
|
180
|
+
mode: componentProps.mode,
|
|
181
|
+
namePath: column.namePath
|
|
179
182
|
};
|
|
180
183
|
if (outerClearNotShow !== false && show === false && (column === null || column === void 0 ? void 0 : column.name) && form.getFieldValue(column === null || column === void 0 ? void 0 : column.name)) {
|
|
181
184
|
setTimeout(function () {
|
|
@@ -204,7 +207,8 @@ var RenderFields = function RenderFields(props) {
|
|
|
204
207
|
originalValues: originalValues,
|
|
205
208
|
equalWith: equalWith,
|
|
206
209
|
requiredOnView: requiredOnView,
|
|
207
|
-
|
|
210
|
+
originalDiffTip: originalDiffTip,
|
|
211
|
+
globalControl: globalControl
|
|
208
212
|
})
|
|
209
213
|
}, "".concat(_formItemProps.name || _formItemProps.label).concat(index));
|
|
210
214
|
});
|
|
@@ -26,7 +26,6 @@ import { Props as ProRangeLimitProps } from '../combination/ProRangeLimit';
|
|
|
26
26
|
import { CheckboxPropsMap, ProEnum, PropProSelectsMap, PropRadioPropsMap } from '../../../ProEnum/propsType';
|
|
27
27
|
import { PropSelectProps as ProSelectProps } from '../../../ProSelect/propsType';
|
|
28
28
|
import { ProEditTableProps } from '../../../ProEditTable/propsType';
|
|
29
|
-
import { PropTreeSelectProps } from '../../../ProTreeSelect/propsType';
|
|
30
29
|
import { ProTreeModalProps } from '../../../ProTreeModal/propsType';
|
|
31
30
|
import { ProUploadProps } from '../../../ProUpload/propsType';
|
|
32
31
|
import { ProTreeProps } from '../../../ProTree/propsType';
|
|
@@ -150,9 +149,6 @@ export type ColumnPropsMap<Values = any, T = 'ProForm'> = {
|
|
|
150
149
|
} | {
|
|
151
150
|
type?: 'ProEditTable';
|
|
152
151
|
fieldProps?: FieldProps<ProEditTableProps, Values, T>;
|
|
153
|
-
} | {
|
|
154
|
-
type?: 'ProTreeSelect';
|
|
155
|
-
fieldProps?: FieldProps<PropTreeSelectProps, Values, T>;
|
|
156
152
|
} | {
|
|
157
153
|
type?: 'ProTreeModal';
|
|
158
154
|
fieldProps?: FieldProps<ProTreeModalProps, Values, T>;
|
|
@@ -210,7 +206,7 @@ export interface ProFormColumnProps<Values = any> extends Omit<FormItemProps<Val
|
|
|
210
206
|
hiddenNames?: string[] | any[];
|
|
211
207
|
rules?: ProRule[] | ReactiveFunction<Values, ProRule[]>;
|
|
212
208
|
equalWith?: (originValue: any, currentValue: any) => boolean;
|
|
213
|
-
required?: boolean | ReactiveFunction<Values, boolean>;
|
|
209
|
+
required?: boolean | boolean[] | ReactiveFunction<Values, boolean | boolean[]>;
|
|
214
210
|
labelRequired?: boolean;
|
|
215
211
|
toISOString?: boolean;
|
|
216
212
|
clearNotShow?: boolean;
|
|
@@ -270,6 +266,7 @@ export interface RenderProps<Values = any> {
|
|
|
270
266
|
originalValues?: Values;
|
|
271
267
|
requiredOnView?: boolean;
|
|
272
268
|
confirm?: ProFormColumnProps['confirm'];
|
|
269
|
+
globalControl?: boolean;
|
|
273
270
|
[name: string]: any;
|
|
274
271
|
}
|
|
275
272
|
export {};
|
package/es/ProForm/index.js
CHANGED
|
@@ -12,13 +12,13 @@ import _Space from "antd/es/space";
|
|
|
12
12
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
13
13
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
14
14
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
15
|
-
var _excluded = ["mode", "span", "disabled", "isView", "columns", "footer", "onOk", "okText", "onCancel", "confirmLoading", "cancelText", "form", "children", "rowProps", "className", "expand", "expandOpen", "expandOpenChange", "viewEmpty", "labelAlign", "labelWidth", "onValuesChange", "onFinish", "originalValues", "submitOnEnter", "clearNotShow", "initialValues", "requiredOnView", "formId", "required", "
|
|
15
|
+
var _excluded = ["mode", "span", "disabled", "isView", "columns", "footer", "onOk", "okText", "onCancel", "confirmLoading", "cancelText", "form", "children", "rowProps", "className", "expand", "expandOpen", "expandOpenChange", "viewEmpty", "labelAlign", "labelWidth", "onValuesChange", "onFinish", "originalValues", "submitOnEnter", "clearNotShow", "initialValues", "requiredOnView", "formId", "required", "originalDiffTip", "formKey", "globalControl"];
|
|
16
16
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
17
|
import { DoubleLeftOutlined } from '@ant-design/icons';
|
|
18
18
|
import classnames from 'classnames';
|
|
19
19
|
import React, { forwardRef, useImperativeHandle, useMemo } from 'react';
|
|
20
20
|
import { isObject, isString, merge } from 'lodash';
|
|
21
|
-
import { FormFooter, InputRange, ProAddress, ProAddressBar, ProCertNo, ProCertValidity, ProCombination, ProModalSelect, ProNumberRange, ProRangeBox, ProTimeLimit, transferAddressInfoToRegion, ProUpload,
|
|
21
|
+
import { FormFooter, InputRange, ProAddress, ProAddressBar, ProCertNo, ProCertValidity, ProCombination, ProModalSelect, ProNumberRange, ProRangeBox, ProTimeLimit, transferAddressInfoToRegion, ProUpload, ProTreeModal, ProTree, EnumSelect } from './components';
|
|
22
22
|
import RenderFields from './components/render/RenderFields';
|
|
23
23
|
import { useProConfig, useContextForms } from '../ProConfigProvider';
|
|
24
24
|
import { getLayout, splitNameStr, useControlled, initialValuesToNames } from './utils/index';
|
|
@@ -26,7 +26,7 @@ import { useForm } from './utils/useForm';
|
|
|
26
26
|
import { useFieldProps } from './utils/useFieldProps';
|
|
27
27
|
import locale from '../locale';
|
|
28
28
|
var ProForm = function ProForm(props, ref) {
|
|
29
|
-
var _forms$formKey, _localStorage;
|
|
29
|
+
var _forms$formKey, _localStorage, _ref;
|
|
30
30
|
var _props$mode = props.mode,
|
|
31
31
|
mode = _props$mode === void 0 ? 'search' : _props$mode,
|
|
32
32
|
span = props.span,
|
|
@@ -49,8 +49,7 @@ var ProForm = function ProForm(props, ref) {
|
|
|
49
49
|
expandOpenChange = props.expandOpenChange,
|
|
50
50
|
_props$viewEmpty = props.viewEmpty,
|
|
51
51
|
viewEmpty = _props$viewEmpty === void 0 ? '-' : _props$viewEmpty,
|
|
52
|
-
|
|
53
|
-
labelAlign = _props$labelAlign === void 0 ? 'left' : _props$labelAlign,
|
|
52
|
+
labelAlign = props.labelAlign,
|
|
54
53
|
labelWidth = props.labelWidth,
|
|
55
54
|
onValuesChange = props.onValuesChange,
|
|
56
55
|
onFinish = props.onFinish,
|
|
@@ -63,9 +62,10 @@ var ProForm = function ProForm(props, ref) {
|
|
|
63
62
|
requiredOnView = _props$requiredOnView === void 0 ? true : _props$requiredOnView,
|
|
64
63
|
formId = props.formId,
|
|
65
64
|
required = props.required,
|
|
66
|
-
_props$
|
|
67
|
-
|
|
65
|
+
_props$originalDiffTi = props.originalDiffTip,
|
|
66
|
+
originalDiffTip = _props$originalDiffTi === void 0 ? true : _props$originalDiffTi,
|
|
68
67
|
formKey = props.formKey,
|
|
68
|
+
globalControl = props.globalControl,
|
|
69
69
|
otherProps = _objectWithoutProperties(props, _excluded);
|
|
70
70
|
var _useProConfig = useProConfig(),
|
|
71
71
|
state = _useProConfig.state,
|
|
@@ -230,9 +230,9 @@ var ProForm = function ProForm(props, ref) {
|
|
|
230
230
|
}
|
|
231
231
|
},
|
|
232
232
|
className: cls,
|
|
233
|
-
form: form
|
|
234
|
-
labelAlign: labelAlign
|
|
233
|
+
form: form
|
|
235
234
|
}, formProps), config), otherProps), {}, {
|
|
235
|
+
labelAlign: (_ref = labelAlign !== null && labelAlign !== void 0 ? labelAlign : config.labelAlign) !== null && _ref !== void 0 ? _ref : 'left',
|
|
236
236
|
onValuesChange: handleValuesChange,
|
|
237
237
|
onFinish: handleFinish,
|
|
238
238
|
initialValues: _initialValues,
|
|
@@ -253,7 +253,8 @@ var ProForm = function ProForm(props, ref) {
|
|
|
253
253
|
clearNotShow: clearNotShow,
|
|
254
254
|
requiredOnView: requiredOnView,
|
|
255
255
|
required: required,
|
|
256
|
-
|
|
256
|
+
originalDiffTip: originalDiffTip,
|
|
257
|
+
globalControl: globalControl
|
|
257
258
|
}), children, footerRender()]
|
|
258
259
|
}))
|
|
259
260
|
}));
|
|
@@ -318,7 +319,7 @@ ProFormForward.ProNumberRange = ProNumberRange;
|
|
|
318
319
|
ProFormForward.ProModalSelect = ProModalSelect;
|
|
319
320
|
ProFormForward.ProTimeLimit = ProTimeLimit;
|
|
320
321
|
ProFormForward.ProUpload = ProUpload;
|
|
321
|
-
ProFormForward.ProTreeSelect = ProTreeSelect;
|
|
322
|
+
// ProFormForward.ProTreeSelect = ProTreeSelect;
|
|
322
323
|
ProFormForward.ProTreeModal = ProTreeModal;
|
|
323
324
|
ProFormForward.ProTree = ProTree;
|
|
324
325
|
// 待废弃
|
|
@@ -38,10 +38,14 @@ export interface ProFormOtherProps {
|
|
|
38
38
|
colProps: ColProps;
|
|
39
39
|
disabled: boolean;
|
|
40
40
|
show?: boolean | (() => boolean);
|
|
41
|
-
required?: boolean | (() => boolean);
|
|
41
|
+
required?: boolean | boolean[] | (() => boolean | boolean[]);
|
|
42
|
+
mode?: string;
|
|
43
|
+
namePath?: any[] | string | number;
|
|
42
44
|
}
|
|
43
45
|
export interface ProFormProps<Values = any> extends FormProps<Values> {
|
|
44
46
|
disabled?: boolean;
|
|
47
|
+
/** 全局控制优先 */
|
|
48
|
+
globalControl?: boolean;
|
|
45
49
|
mode?: ModeEnum;
|
|
46
50
|
formKey?: string;
|
|
47
51
|
/** 是否查看 */
|
|
@@ -66,8 +70,8 @@ export interface ProFormProps<Values = any> extends FormProps<Values> {
|
|
|
66
70
|
clearNotShow?: boolean;
|
|
67
71
|
requiredOnView?: boolean;
|
|
68
72
|
formId?: string;
|
|
69
|
-
required?: boolean;
|
|
70
|
-
|
|
73
|
+
required?: boolean | boolean[];
|
|
74
|
+
originalDiffTip?: boolean;
|
|
71
75
|
}
|
|
72
76
|
export interface Transform<T = any> {
|
|
73
77
|
normalize?: (value: StoreValue, prevValue: StoreValue, allValues: Store) => StoreValue;
|
|
@@ -31,16 +31,6 @@
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
&.@{ant-prefix}-form {
|
|
35
|
-
margin-bottom: calc(var(--zaui-space-size-md; 16px) * var(--zaui-size; 1));
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.pro-collapse-level2 {
|
|
39
|
-
.@{ant-prefix}-collapse-item {
|
|
40
|
-
margin-bottom: 0 !important;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
34
|
.@{ant-prefix}-form-item-control-input {
|
|
45
35
|
flex-grow: 1;
|
|
46
36
|
max-width: 100%;
|
|
@@ -135,20 +125,35 @@
|
|
|
135
125
|
background: @zaui-contract-bg !important;
|
|
136
126
|
|
|
137
127
|
input {
|
|
138
|
-
background:
|
|
128
|
+
background: transparent;
|
|
139
129
|
}
|
|
140
130
|
.@{ant-prefix}-select-selection-placeholder {
|
|
141
131
|
z-index: 9;
|
|
142
132
|
}
|
|
143
133
|
}
|
|
144
134
|
|
|
145
|
-
|
|
135
|
+
.@{ant-prefix}-form-item-control:has(.@{ant-prefix}-switch-handle),
|
|
136
|
+
.@{ant-prefix}-form-item-control:has(.@{ant-prefix}-checkbox-wrapper-in-form-item) {
|
|
146
137
|
background: @zaui-contract-bg;
|
|
147
138
|
border-radius: 4px;
|
|
148
139
|
}
|
|
149
140
|
|
|
150
|
-
//
|
|
151
|
-
.@{ant-prefix}-form-item-control-input-content
|
|
141
|
+
// 地址组件
|
|
142
|
+
.@{ant-prefix}-form-item-control-input-content {
|
|
143
|
+
& > .pro-address {
|
|
144
|
+
.@{ant-prefix}-select-selector,
|
|
145
|
+
.@{ant-prefix}-input-affix-wrapper,
|
|
146
|
+
.@{ant-prefix}-input-disabled {
|
|
147
|
+
background: @zaui-contract-bg;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
& > .@{ant-prefix}-input-group {
|
|
151
|
+
.forever-checkbox {
|
|
152
|
+
background: @zaui-contract-bg;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
152
157
|
.pro-form-view-container {
|
|
153
158
|
padding: 4px 8px;
|
|
154
159
|
background: @zaui-contract-bg;
|
|
@@ -342,4 +347,21 @@
|
|
|
342
347
|
.delete-icon {
|
|
343
348
|
width: 18px;
|
|
344
349
|
}
|
|
350
|
+
.pro-form-list-tool-btn {
|
|
351
|
+
margin-left: 8px;
|
|
352
|
+
padding: 0;
|
|
353
|
+
cursor: pointer;
|
|
354
|
+
.anticon {
|
|
355
|
+
color: var(--zaui-text-weak, #a0a0a0);
|
|
356
|
+
font-size: 16px;
|
|
357
|
+
vertical-align: middle;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
.pro-form-list-mode-block{
|
|
361
|
+
.pro-collapse-content{
|
|
362
|
+
.@{ant-prefix}-row{
|
|
363
|
+
width: auto;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
345
367
|
}
|
|
@@ -3,7 +3,8 @@ interface Params {
|
|
|
3
3
|
originalValue: any;
|
|
4
4
|
value: any;
|
|
5
5
|
form: FormInstance;
|
|
6
|
+
name?: string | any[];
|
|
6
7
|
equalWith?: (originalValue: any, currentValue: any) => boolean;
|
|
7
8
|
}
|
|
8
|
-
export declare const
|
|
9
|
+
export declare const diffOriginal: (params: Params) => boolean;
|
|
9
10
|
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import { isEqual, isFunction, isString } from 'lodash';
|
|
3
|
+
var nullValue = [null, undefined, '']; // 输入框空值时可能存在的三种值 视为相等
|
|
4
|
+
/** 将解构后的name值,反向转回names,例如 formData {a:1, b:2} names ['a', 'b'] 返回 [1,2] */
|
|
5
|
+
var extractValues = function extractValues(form, pathString) {
|
|
6
|
+
var _pathString;
|
|
7
|
+
var result = [];
|
|
8
|
+
var PrefixesName = isString(pathString) ? [] : pathString.slice(0, -1);
|
|
9
|
+
if (isString(pathString)) {
|
|
10
|
+
pathString.split('-').forEach(function (item) {
|
|
11
|
+
result.push(form.getFieldValue([].concat(_toConsumableArray(PrefixesName), [item])));
|
|
12
|
+
});
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
15
|
+
(_pathString = pathString[pathString.length - 1]) === null || _pathString === void 0 ? void 0 : _pathString.split('-').forEach(function (item) {
|
|
16
|
+
result.push(form.getFieldValue([].concat(_toConsumableArray(PrefixesName), [item])));
|
|
17
|
+
});
|
|
18
|
+
return result;
|
|
19
|
+
};
|
|
20
|
+
export var diffOriginal = function diffOriginal(params) {
|
|
21
|
+
var _name$join;
|
|
22
|
+
var originalValue = params.originalValue,
|
|
23
|
+
_value = params.value,
|
|
24
|
+
equalWith = params.equalWith,
|
|
25
|
+
form = params.form,
|
|
26
|
+
name = params.name;
|
|
27
|
+
var isNames = Array.isArray(name) && ((_name$join = name.join(',')) === null || _name$join === void 0 ? void 0 : _name$join.includes('-')) || (name === null || name === void 0 ? void 0 : name.includes('-'));
|
|
28
|
+
var value = !isNames ? _value : extractValues(form, name);
|
|
29
|
+
// 支持传入自定义比较事件
|
|
30
|
+
if (isFunction(equalWith)) {
|
|
31
|
+
return !equalWith(originalValue, value);
|
|
32
|
+
}
|
|
33
|
+
if (Array.isArray(originalValue)) {
|
|
34
|
+
return originalValue.some(function (valueItem, index) {
|
|
35
|
+
// 如果两个值有一个不是空值, 则进行深比较
|
|
36
|
+
if (!nullValue.includes(value === null || value === void 0 ? void 0 : value[index]) || !nullValue.includes(valueItem)) {
|
|
37
|
+
return !isEqual(value === null || value === void 0 ? void 0 : value[index], valueItem);
|
|
38
|
+
}
|
|
39
|
+
return false;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
if (!nullValue.includes(value) || !nullValue.includes(originalValue)) {
|
|
43
|
+
return !isEqual(value, originalValue);
|
|
44
|
+
}
|
|
45
|
+
return false;
|
|
46
|
+
};
|
|
@@ -26,7 +26,7 @@ export declare const isTrim: (type: string, trim: boolean, configData: any) => a
|
|
|
26
26
|
*/
|
|
27
27
|
export declare const isUpperCase: (type: string, upperCase: boolean) => any;
|
|
28
28
|
export declare const weedOutProps: (data: Record<string, any>, keys: string[]) => {}[];
|
|
29
|
-
export declare const
|
|
29
|
+
export declare const diffField: (prevValues: any, curValues: any, names: NamePath[]) => boolean;
|
|
30
30
|
export declare const splitNameStr: (name: string) => NamePath[];
|
|
31
31
|
export declare const filterInternalFields: (values: any) => any;
|
|
32
32
|
export declare const getAllNamePath: (object: Record<string, any>, currentPath?: InternalNamePath) => InternalNamePath[];
|
|
@@ -36,7 +36,7 @@ export declare const isNullValue: (value: any) => boolean;
|
|
|
36
36
|
* @param arr 值
|
|
37
37
|
* @returns boole
|
|
38
38
|
*/
|
|
39
|
-
export declare const isNotFullArray: (arr: any, length: any) => boolean;
|
|
39
|
+
export declare const isNotFullArray: (arr: any, length: any, required: any) => boolean;
|
|
40
40
|
/**
|
|
41
41
|
* 判断数组中值是否都为空 全部为空则为true
|
|
42
42
|
* @param arr 值
|
|
@@ -5,6 +5,7 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
|
5
5
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
6
6
|
import { useState } from 'react';
|
|
7
7
|
import _, { isObject, isFunction, cloneDeep, get, set, omit, isNaN } from 'lodash';
|
|
8
|
+
import moment from 'moment';
|
|
8
9
|
export var getLayout = function getLayout(params) {
|
|
9
10
|
var _params$span = params.span,
|
|
10
11
|
span = _params$span === void 0 ? 8 : _params$span,
|
|
@@ -42,7 +43,7 @@ export var useControlled = function useControlled(props) {
|
|
|
42
43
|
export var isSelect = function isSelect(props) {
|
|
43
44
|
var dataSource = props.dataSource,
|
|
44
45
|
type = props.type;
|
|
45
|
-
return (dataSource === null || dataSource === void 0 ? void 0 : dataSource.length) || ['Select', 'ProSelect', 'ProEnum', 'DatePicker', 'RangePicker', 'ProAddressBar', 'ProTimeLimit', 'ProModalSelect', 'ProTreeModal', 'ProUpload'].includes(type);
|
|
46
|
+
return (dataSource === null || dataSource === void 0 ? void 0 : dataSource.length) || ['Select', 'ProSelect', 'ProEnum', 'DatePicker', 'RangePicker', 'ProAddressBar', 'ProTimeLimit', 'ProModalSelect', 'ProTreeModal', 'ProUpload', 'TimePicker'].includes(type);
|
|
46
47
|
};
|
|
47
48
|
/**
|
|
48
49
|
* Input TextArea 移除前后空格
|
|
@@ -108,7 +109,7 @@ export var weedOutProps = function weedOutProps(data, keys) {
|
|
|
108
109
|
return [obj, weedOut];
|
|
109
110
|
};
|
|
110
111
|
// 对比字段变化
|
|
111
|
-
export var
|
|
112
|
+
export var diffField = function diffField(prevValues, curValues, names) {
|
|
112
113
|
return names.some(function (name) {
|
|
113
114
|
return _.get(prevValues, name) !== _.get(curValues, name);
|
|
114
115
|
});
|
|
@@ -122,8 +123,8 @@ export var splitNameStr = function splitNameStr(name) {
|
|
|
122
123
|
// 过滤掉字段名中包含 '-' 的字段
|
|
123
124
|
export var filterInternalFields = function filterInternalFields(values) {
|
|
124
125
|
var nextValues = values;
|
|
125
|
-
// fix: braft-editor对象不可遍历
|
|
126
|
-
if (values === null || values === void 0 ? void 0 : values._immutable) {
|
|
126
|
+
// fix: braft-editor对象不可遍历 Moment不过滤
|
|
127
|
+
if ((values === null || values === void 0 ? void 0 : values._immutable) || moment.isMoment(values)) {
|
|
127
128
|
return nextValues;
|
|
128
129
|
}
|
|
129
130
|
if (Array.isArray(nextValues)) {
|
|
@@ -134,7 +135,7 @@ export var filterInternalFields = function filterInternalFields(values) {
|
|
|
134
135
|
if (isObject(nextValues)) {
|
|
135
136
|
var result = {};
|
|
136
137
|
Object.keys(nextValues).forEach(function (key) {
|
|
137
|
-
if (key.includes('-')) return;
|
|
138
|
+
// if (key.includes('-')) return;
|
|
138
139
|
result[key] = filterInternalFields(nextValues[key]);
|
|
139
140
|
});
|
|
140
141
|
return result;
|
|
@@ -171,10 +172,15 @@ export var isNullValue = function isNullValue(value) {
|
|
|
171
172
|
* @param arr 值
|
|
172
173
|
* @returns boole
|
|
173
174
|
*/
|
|
174
|
-
export var isNotFullArray = function isNotFullArray(arr, length) {
|
|
175
|
+
export var isNotFullArray = function isNotFullArray(arr, length, required) {
|
|
175
176
|
if (!Array.isArray(arr)) {
|
|
176
177
|
return false;
|
|
177
178
|
}
|
|
179
|
+
if (Array.isArray(required) && required.some(function (item) {
|
|
180
|
+
return item === false;
|
|
181
|
+
})) {
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
178
184
|
if (arr.length < length) return true;
|
|
179
185
|
return arr.some(function (item) {
|
|
180
186
|
if (item === undefined || item === null) {
|
|
@@ -295,6 +301,10 @@ export function initialValuesToNames() {
|
|
|
295
301
|
values[key] = formInitialValue;
|
|
296
302
|
}
|
|
297
303
|
}
|
|
304
|
+
// 给FormList默认增加一行
|
|
305
|
+
if (item.type === 'FormList' && !item.initialValue && !get(values, item.name)) {
|
|
306
|
+
item.initialValue = [{}];
|
|
307
|
+
}
|
|
298
308
|
});
|
|
299
309
|
return values;
|
|
300
310
|
}
|
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
2
|
import { validate, regExp } from '@zat-design/utils';
|
|
3
|
-
import { isString } from 'lodash';
|
|
3
|
+
import { isString, isNumber } from 'lodash';
|
|
4
4
|
import { isNullValue } from './index';
|
|
5
|
-
import locale from '../../locale';
|
|
6
|
-
|
|
5
|
+
import locale, { formatMessage } from '../../locale';
|
|
6
|
+
var getNonEmptyValuesByIndex = function getNonEmptyValuesByIndex(required, valueArray) {
|
|
7
|
+
var result = [];
|
|
8
|
+
required.forEach(function (item, index) {
|
|
9
|
+
if (item && !valueArray[index] && !isNumber(valueArray[index])) {
|
|
10
|
+
result.push(index + 1);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
return result;
|
|
14
|
+
};
|
|
15
|
+
export var rulesCreator = function rulesCreator(_ref) {
|
|
7
16
|
var _result;
|
|
17
|
+
var rules = _ref.rules,
|
|
18
|
+
label = _ref.label,
|
|
19
|
+
isSelect = _ref.isSelect,
|
|
20
|
+
names = _ref.names,
|
|
21
|
+
required = _ref.required;
|
|
8
22
|
var message = "".concat(isSelect ? "".concat(locale.ProForm.selectPlaceHolder) : "".concat(locale.ProForm.inputPlaceholder)).concat(locale.ProForm.ruleText).concat(isString(label) ? label : '');
|
|
9
23
|
var result = [];
|
|
10
24
|
result = rules.map(function (ruleItem) {
|
|
@@ -29,6 +43,34 @@ export var rulesCreator = function rulesCreator(rules, label, isSelect) {
|
|
|
29
43
|
}
|
|
30
44
|
return rule;
|
|
31
45
|
});
|
|
46
|
+
if ((names === null || names === void 0 ? void 0 : names.length) && (required === null || required === void 0 ? void 0 : required.length)) {
|
|
47
|
+
var customRequired = {
|
|
48
|
+
validator: function validator(rules, value) {
|
|
49
|
+
var _errorValues3;
|
|
50
|
+
var errorValues = getNonEmptyValuesByIndex(required, value);
|
|
51
|
+
if ((value === null || value === void 0 ? void 0 : value.length) === 2) {
|
|
52
|
+
var _errorValues;
|
|
53
|
+
errorValues = errorValues.map(function (item) {
|
|
54
|
+
var _locale$ProForm;
|
|
55
|
+
return locale === null || locale === void 0 ? void 0 : (_locale$ProForm = locale.ProForm) === null || _locale$ProForm === void 0 ? void 0 : _locale$ProForm.ruleStartEndText[item - 1];
|
|
56
|
+
});
|
|
57
|
+
if ((_errorValues = errorValues) === null || _errorValues === void 0 ? void 0 : _errorValues.length) {
|
|
58
|
+
var _locale$ProForm2, _errorValues2;
|
|
59
|
+
return Promise.reject(new Error("".concat(locale === null || locale === void 0 ? void 0 : (_locale$ProForm2 = locale.ProForm) === null || _locale$ProForm2 === void 0 ? void 0 : _locale$ProForm2.inputPlaceholder).concat((_errorValues2 = errorValues) === null || _errorValues2 === void 0 ? void 0 : _errorValues2.join(','))));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// 校验为true的值是否存在
|
|
63
|
+
if (Array.isArray(value) && ((_errorValues3 = errorValues) === null || _errorValues3 === void 0 ? void 0 : _errorValues3.length)) {
|
|
64
|
+
var _locale$ProForm3, _errorValues4;
|
|
65
|
+
return Promise.reject(new Error("".concat(formatMessage(locale === null || locale === void 0 ? void 0 : (_locale$ProForm3 = locale.ProForm) === null || _locale$ProForm3 === void 0 ? void 0 : _locale$ProForm3.halfRuleText, {
|
|
66
|
+
total: (_errorValues4 = errorValues) === null || _errorValues4 === void 0 ? void 0 : _errorValues4.join(',')
|
|
67
|
+
}))));
|
|
68
|
+
}
|
|
69
|
+
return Promise.resolve();
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
result.push(customRequired);
|
|
73
|
+
}
|
|
32
74
|
if (!((_result = result) === null || _result === void 0 ? void 0 : _result.length)) {
|
|
33
75
|
result = [{
|
|
34
76
|
required: false
|
|
@@ -6,5 +6,5 @@ interface TransformProps extends FormItemProps {
|
|
|
6
6
|
namePath: any[];
|
|
7
7
|
}
|
|
8
8
|
type TransformFun = 'normalize' | 'getValueProps' | 'shouldUpdate' | 'name';
|
|
9
|
-
declare const transformNames: (formItem: TransformProps, form: FormInstance, names: NamePath[], fieldName: string) => Pick<TransformProps, TransformFun>;
|
|
9
|
+
declare const transformNames: (formItem: TransformProps, form: FormInstance, names: NamePath[], fieldName: string, type?: string) => Pick<TransformProps, TransformFun>;
|
|
10
10
|
export default transformNames;
|