@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.
Files changed (228) hide show
  1. package/dist/index.esm.css +323 -269
  2. package/dist/less.esm.css +5042 -0
  3. package/dist/less.esm.js +3 -0
  4. package/es/ProConfigProvider/index.d.ts +1 -1
  5. package/es/ProConfigProvider/index.js +24 -2
  6. package/es/ProEditLabel/style/index.less +1 -2
  7. package/es/ProEditTable/components/DndWrapper/index.js +1 -1
  8. package/es/ProEditTable/components/RenderField/index.js +44 -31
  9. package/es/ProEditTable/index.js +18 -12
  10. package/es/ProEditTable/propsType.d.ts +1 -1
  11. package/es/ProEditTable/style/index.less +1 -1
  12. package/es/ProEditTable/utils/config.js +5 -5
  13. package/es/ProEditTable/utils/index.js +67 -30
  14. package/es/ProEditTable/utils/tools.js +3 -1
  15. package/es/ProEnum/components/Group.d.ts +2 -0
  16. package/es/ProEnum/components/Group.js +20 -19
  17. package/es/ProEnum/index.js +4 -3
  18. package/es/ProEnum/style/index.less +12 -3
  19. package/es/ProForm/components/base/DatePicker/index.js +5 -3
  20. package/es/ProForm/components/combination/FormList/components/ActionButton.js +9 -8
  21. package/es/ProForm/components/combination/FormList/components/BlockFields.js +4 -0
  22. package/es/ProForm/components/combination/FormList/components/ToolbarButton.js +1 -1
  23. package/es/ProForm/components/combination/FormList/index.js +6 -3
  24. package/es/ProForm/components/combination/FormList/style/index.less +5 -0
  25. package/es/ProForm/components/combination/FormList/utils.d.ts +2 -1
  26. package/es/ProForm/components/combination/FormList/utils.js +5 -3
  27. package/es/ProForm/components/combination/Group/index.js +31 -17
  28. package/es/ProForm/components/combination/Group/propsType.d.ts +6 -0
  29. package/es/ProForm/components/combination/Group/style/index.less +4 -4
  30. package/es/ProForm/components/combination/Group/utils.d.ts +2 -0
  31. package/es/ProForm/components/combination/Group/utils.js +10 -0
  32. package/es/ProForm/components/combination/ProNumberRange/style/index.less +1 -1
  33. package/es/ProForm/components/combination/ProTimeLimit/index.js +8 -2
  34. package/es/ProForm/components/combination/ProTimeLimit/style/index.less +1 -1
  35. package/es/ProForm/components/index.d.ts +0 -1
  36. package/es/ProForm/components/index.js +1 -1
  37. package/es/ProForm/components/render/ConfirmWrapper.js +1 -1
  38. package/es/ProForm/components/render/Render.js +31 -22
  39. package/es/ProForm/components/render/RenderFields.d.ts +3 -2
  40. package/es/ProForm/components/render/RenderFields.js +7 -3
  41. package/es/ProForm/components/render/propsType.d.ts +2 -5
  42. package/es/ProForm/index.js +12 -11
  43. package/es/ProForm/propsType.d.ts +7 -3
  44. package/es/ProForm/style/index.less +36 -14
  45. package/es/ProForm/utils/{contrastOriginal.d.ts → diffOriginal.d.ts} +2 -1
  46. package/es/ProForm/utils/diffOriginal.js +46 -0
  47. package/es/ProForm/utils/index.d.ts +2 -2
  48. package/es/ProForm/utils/index.js +16 -6
  49. package/es/ProForm/utils/rulesCreator.d.ts +7 -1
  50. package/es/ProForm/utils/rulesCreator.js +45 -3
  51. package/es/ProForm/utils/transformNames.d.ts +1 -1
  52. package/es/ProForm/utils/transformNames.js +11 -4
  53. package/es/ProForm/utils/transformValue.js +2 -2
  54. package/es/ProForm/utils/useChanged.js +4 -3
  55. package/es/ProForm/utils/useListChanged.d.ts +1 -1
  56. package/es/ProForm/utils/useListChanged.js +5 -3
  57. package/es/ProForm/utils/useRules.js +36 -11
  58. package/es/ProForm/utils/useShouldUpdate.js +4 -4
  59. package/es/ProForm/utils/valueType.d.ts +10 -5
  60. package/es/ProForm/utils/valueType.js +20 -10
  61. package/es/ProIcon/config/index.d.ts +2 -1
  62. package/es/ProIcon/config/index.js +191 -133
  63. package/es/ProIcon/index.d.ts +0 -1
  64. package/es/ProIcon/index.js +21 -36
  65. package/es/ProIcon/propsTypes.d.ts +2 -1
  66. package/es/ProLayout/components/Layout/Header/style/index.less +1 -1
  67. package/es/ProLayout/components/Layout/Menu/OpenMenu/style/index.less +58 -55
  68. package/es/ProLayout/components/Layout/Menu/SideMenu/style/index.less +25 -20
  69. package/es/ProLayout/components/Layout/Menu/style/index.less +52 -56
  70. package/es/ProLayout/components/ProCollapse/PropTypes.d.ts +5 -0
  71. package/es/ProLayout/components/ProCollapse/index.js +45 -4
  72. package/es/ProLayout/components/ProCollapse/style/index.less +30 -12
  73. package/es/ProLayout/components/ProFooter/index.js +1 -1
  74. package/es/ProLayout/components/ProFooter/style/index.less +1 -1
  75. package/es/ProLayout/components/ProHeader/style/index.less +6 -5
  76. package/es/ProLayout/style/index.less +176 -88
  77. package/es/ProStep/components/Item/index.js +2 -1
  78. package/es/ProStep/style/index.less +71 -70
  79. package/es/ProTable/components/RenderColumn/index.d.ts +1 -1
  80. package/es/ProTable/components/RenderColumn/index.js +3 -3
  81. package/es/ProTable/propsType.d.ts +1 -1
  82. package/es/ProTable/style/index.less +2 -2
  83. package/es/ProTable/utils.js +9 -9
  84. package/es/ProTabs/style/index.less +3 -1
  85. package/es/ProThemeTools/component/PrdTools/index.d.ts +1 -1
  86. package/es/ProThemeTools/component/PrdTools/index.js +14 -52
  87. package/es/ProThemeTools/component/PrdTools/style/index.less +1 -1
  88. package/es/ProThemeTools/index.js +21 -29
  89. package/es/ProThemeTools/propsType.d.ts +1 -1
  90. package/es/ProThemeTools/style/index.less +25 -8
  91. package/es/{ProTreeSelect → ProTree/components/ProTreeSelect}/index.js +7 -11
  92. package/es/{ProTreeSelect → ProTree/components/ProTreeSelect}/propsType.d.ts +1 -1
  93. package/es/{ProTreeSelect → ProTree/components/ProTreeSelect}/style/index.less +1 -1
  94. package/es/ProTree/index.js +1 -1
  95. package/es/ProTree/style/index.less +5 -0
  96. package/es/ProTreeModal/style/index.less +2 -2
  97. package/es/ProUpload/style/fileItem.less +2 -2
  98. package/es/ProUpload/style/index.less +3 -3
  99. package/es/assets/catalog.svg +30 -1
  100. package/es/assets/fold.svg +27 -0
  101. package/es/assets/setting.svg +14 -0
  102. package/es/locale/en_US.d.ts +7 -2
  103. package/es/locale/en_US.js +7 -2
  104. package/es/locale/zh_CN.d.ts +7 -2
  105. package/es/locale/zh_CN.js +7 -2
  106. package/es/style/components.less +0 -4
  107. package/es/style/less.less +2 -0
  108. package/es/style/theme/antd.less +14 -29
  109. package/es/style/theme/index.less +2 -2
  110. package/es/style/theme/tokens.less +2 -2
  111. package/es/tokens.js +2 -2
  112. package/lib/ProConfigProvider/index.d.ts +1 -1
  113. package/lib/ProConfigProvider/index.js +23 -1
  114. package/lib/ProEditLabel/style/index.less +1 -2
  115. package/lib/ProEditTable/components/DndWrapper/index.js +1 -1
  116. package/lib/ProEditTable/components/RenderField/index.js +41 -28
  117. package/lib/ProEditTable/index.js +18 -12
  118. package/lib/ProEditTable/propsType.d.ts +1 -1
  119. package/lib/ProEditTable/style/index.less +1 -1
  120. package/lib/ProEditTable/utils/config.js +5 -5
  121. package/lib/ProEditTable/utils/index.js +67 -30
  122. package/lib/ProEditTable/utils/tools.js +3 -1
  123. package/lib/ProEnum/components/Group.d.ts +2 -0
  124. package/lib/ProEnum/components/Group.js +20 -19
  125. package/lib/ProEnum/index.js +4 -3
  126. package/lib/ProEnum/style/index.less +12 -3
  127. package/lib/ProForm/components/base/DatePicker/index.js +4 -2
  128. package/lib/ProForm/components/combination/FormList/components/ActionButton.js +9 -8
  129. package/lib/ProForm/components/combination/FormList/components/BlockFields.js +4 -0
  130. package/lib/ProForm/components/combination/FormList/components/ToolbarButton.js +1 -1
  131. package/lib/ProForm/components/combination/FormList/index.js +6 -3
  132. package/lib/ProForm/components/combination/FormList/style/index.less +5 -0
  133. package/lib/ProForm/components/combination/FormList/utils.d.ts +2 -1
  134. package/lib/ProForm/components/combination/FormList/utils.js +5 -3
  135. package/lib/ProForm/components/combination/Group/index.js +28 -14
  136. package/lib/ProForm/components/combination/Group/propsType.d.ts +6 -0
  137. package/lib/ProForm/components/combination/Group/style/index.less +4 -4
  138. package/lib/ProForm/components/combination/Group/utils.d.ts +2 -0
  139. package/lib/ProForm/components/combination/Group/utils.js +11 -1
  140. package/lib/ProForm/components/combination/ProNumberRange/style/index.less +1 -1
  141. package/lib/ProForm/components/combination/ProTimeLimit/index.js +7 -1
  142. package/lib/ProForm/components/combination/ProTimeLimit/style/index.less +1 -1
  143. package/lib/ProForm/components/index.d.ts +0 -1
  144. package/lib/ProForm/components/index.js +0 -7
  145. package/lib/ProForm/components/render/ConfirmWrapper.js +1 -1
  146. package/lib/ProForm/components/render/Render.js +31 -22
  147. package/lib/ProForm/components/render/RenderFields.d.ts +3 -2
  148. package/lib/ProForm/components/render/RenderFields.js +7 -3
  149. package/lib/ProForm/components/render/propsType.d.ts +2 -5
  150. package/lib/ProForm/index.js +11 -10
  151. package/lib/ProForm/propsType.d.ts +7 -3
  152. package/lib/ProForm/style/index.less +36 -14
  153. package/lib/ProForm/utils/{contrastOriginal.d.ts → diffOriginal.d.ts} +2 -1
  154. package/lib/ProForm/utils/diffOriginal.js +53 -0
  155. package/lib/ProForm/utils/index.d.ts +2 -2
  156. package/lib/ProForm/utils/index.js +17 -7
  157. package/lib/ProForm/utils/rulesCreator.d.ts +7 -1
  158. package/lib/ProForm/utils/rulesCreator.js +45 -2
  159. package/lib/ProForm/utils/transformNames.d.ts +1 -1
  160. package/lib/ProForm/utils/transformNames.js +10 -3
  161. package/lib/ProForm/utils/transformValue.js +1 -1
  162. package/lib/ProForm/utils/useChanged.js +4 -3
  163. package/lib/ProForm/utils/useListChanged.d.ts +1 -1
  164. package/lib/ProForm/utils/useListChanged.js +5 -3
  165. package/lib/ProForm/utils/useRules.js +36 -11
  166. package/lib/ProForm/utils/useShouldUpdate.js +4 -4
  167. package/lib/ProForm/utils/valueType.d.ts +10 -5
  168. package/lib/ProForm/utils/valueType.js +20 -10
  169. package/lib/ProIcon/config/index.d.ts +2 -1
  170. package/lib/ProIcon/config/index.js +191 -133
  171. package/lib/ProIcon/index.d.ts +0 -1
  172. package/lib/ProIcon/index.js +21 -37
  173. package/lib/ProIcon/propsTypes.d.ts +2 -1
  174. package/lib/ProLayout/components/Layout/Header/style/index.less +1 -1
  175. package/lib/ProLayout/components/Layout/Menu/OpenMenu/style/index.less +58 -55
  176. package/lib/ProLayout/components/Layout/Menu/SideMenu/style/index.less +25 -20
  177. package/lib/ProLayout/components/Layout/Menu/style/index.less +52 -56
  178. package/lib/ProLayout/components/ProCollapse/PropTypes.d.ts +5 -0
  179. package/lib/ProLayout/components/ProCollapse/index.js +43 -4
  180. package/lib/ProLayout/components/ProCollapse/style/index.less +30 -12
  181. package/lib/ProLayout/components/ProFooter/index.js +1 -1
  182. package/lib/ProLayout/components/ProFooter/style/index.less +1 -1
  183. package/lib/ProLayout/components/ProHeader/style/index.less +6 -5
  184. package/lib/ProLayout/style/index.less +176 -88
  185. package/lib/ProStep/components/Item/index.js +2 -1
  186. package/lib/ProStep/style/index.less +71 -70
  187. package/lib/ProTable/components/RenderColumn/index.d.ts +1 -1
  188. package/lib/ProTable/components/RenderColumn/index.js +3 -3
  189. package/lib/ProTable/propsType.d.ts +1 -1
  190. package/lib/ProTable/style/index.less +2 -2
  191. package/lib/ProTable/utils.js +9 -9
  192. package/lib/ProTabs/style/index.less +3 -1
  193. package/lib/ProThemeTools/component/PrdTools/index.d.ts +1 -1
  194. package/lib/ProThemeTools/component/PrdTools/index.js +14 -52
  195. package/lib/ProThemeTools/component/PrdTools/style/index.less +1 -1
  196. package/lib/ProThemeTools/index.js +19 -28
  197. package/lib/ProThemeTools/propsType.d.ts +1 -1
  198. package/lib/ProThemeTools/style/index.less +25 -8
  199. package/lib/{ProTreeSelect → ProTree/components/ProTreeSelect}/index.js +7 -11
  200. package/lib/{ProTreeSelect → ProTree/components/ProTreeSelect}/propsType.d.ts +1 -1
  201. package/lib/{ProTreeSelect → ProTree/components/ProTreeSelect}/style/index.less +1 -1
  202. package/lib/ProTree/index.js +1 -1
  203. package/lib/ProTree/style/index.less +5 -0
  204. package/lib/ProTreeModal/style/index.less +2 -2
  205. package/lib/ProUpload/style/fileItem.less +2 -2
  206. package/lib/ProUpload/style/index.less +3 -3
  207. package/lib/assets/catalog.svg +30 -1
  208. package/lib/assets/fold.svg +27 -0
  209. package/lib/assets/setting.svg +14 -0
  210. package/lib/locale/en_US.d.ts +7 -2
  211. package/lib/locale/en_US.js +7 -2
  212. package/lib/locale/zh_CN.d.ts +7 -2
  213. package/lib/locale/zh_CN.js +7 -2
  214. package/lib/style/components.less +0 -4
  215. package/lib/style/less.less +2 -0
  216. package/lib/style/theme/antd.less +14 -29
  217. package/lib/style/theme/index.less +2 -2
  218. package/lib/style/theme/tokens.less +2 -2
  219. package/lib/tokens.js +2 -2
  220. package/package.json +2 -2
  221. package/es/ProForm/utils/contrastOriginal.js +0 -24
  222. package/es/ProIcon/symbolIcon.js +0 -43
  223. package/lib/ProForm/utils/contrastOriginal.js +0 -30
  224. package/lib/ProIcon/symbolIcon.js +0 -45
  225. /package/es/{ProTreeSelect → ProTree/components/ProTreeSelect}/index.d.ts +0 -0
  226. /package/es/{ProTreeSelect → ProTree/components/ProTreeSelect}/propsType.js +0 -0
  227. /package/lib/{ProTreeSelect → ProTree/components/ProTreeSelect}/index.d.ts +0 -0
  228. /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
- originalTip = props.originalTip,
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, labelRequired || _required ? {
157
- required: labelRequired || _required
158
- } : null, otherProps.isView && !requiredOnView ? {
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
- // 优先级 formitem上【column.disabled】 > 组件上【fieldProps.disabled】 > 全局【formDisabled】
173
- var lastDisabled = (_ref2 = (_ref3 = _disabled !== null && _disabled !== void 0 ? _disabled : _fieldProps === null || _fieldProps === void 0 ? void 0 : _fieldProps.disabled) !== null && _ref3 !== void 0 ? _ref3 : componentProps === null || componentProps === void 0 ? void 0 : componentProps.disabled) !== null && _ref2 !== void 0 ? _ref2 : formDisabled;
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 _ref4 = otherProps || {},
202
- valueType = _ref4.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 (['ProTreeSelect', 'ProTree'].includes(type)) {
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 _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
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 _ref5.apply(this, arguments);
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 (!originalTip || ['FormList', 'ProEditTable'].includes(type)) {
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
- originalTip?: boolean;
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
- originalTip = props.originalTip;
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
- originalTip: originalTip
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 {};
@@ -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", "originalTip", "formKey"];
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, ProTreeSelect, ProTreeModal, ProTree, EnumSelect } from './components';
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
- _props$labelAlign = props.labelAlign,
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$originalTip = props.originalTip,
67
- originalTip = _props$originalTip === void 0 ? true : _props$originalTip,
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
- originalTip: originalTip
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
- originalTip?: boolean;
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: @zaui-contract-bg;
128
+ background: transparent;
139
129
  }
140
130
  .@{ant-prefix}-select-selection-placeholder {
141
131
  z-index: 9;
142
132
  }
143
133
  }
144
134
 
145
- .ant-form-item-control:has(.ant-switch-handle, .ant-checkbox-wrapper-in-form-item) {
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 > span, // 地址组件
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 contrastOriginal: (params: Params) => boolean;
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 contrast: (prevValues: any, curValues: any, names: NamePath[]) => boolean;
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 contrast = function contrast(prevValues, curValues, names) {
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 +1,7 @@
1
- export declare const rulesCreator: (rules: any, label: any, isSelect: any) => any[];
1
+ export declare const rulesCreator: ({ rules, label, isSelect, names, required }: {
2
+ rules: any;
3
+ label: any;
4
+ isSelect: any;
5
+ names: any;
6
+ required: any;
7
+ }) => any[];
@@ -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
- export var rulesCreator = function rulesCreator(rules, label, isSelect) {
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;