@zat-design/sisyphus-react 3.4.6-beta.6 → 3.4.6-beta.8

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 (97) hide show
  1. package/es/ProEditTable/components/RenderField/index.js +4 -8
  2. package/es/ProForm/components/combination/FormList/index.js +1 -1
  3. package/es/ProForm/components/combination/FormList/utils.js +2 -3
  4. package/es/ProForm/components/combination/Group/index.d.ts +8 -2
  5. package/es/ProForm/components/combination/Group/index.js +59 -76
  6. package/es/ProForm/components/combination/Group/propsType.d.ts +27 -14
  7. package/es/ProForm/components/combination/Group/utils.d.ts +60 -7
  8. package/es/ProForm/components/combination/Group/utils.js +209 -19
  9. package/es/ProForm/components/combination/_Group/index.d.ts +4 -0
  10. package/es/ProForm/components/combination/_Group/index.js +109 -0
  11. package/es/ProForm/components/combination/_Group/propsType.d.ts +35 -0
  12. package/es/ProForm/components/combination/_Group/utils.d.ts +10 -0
  13. package/es/ProForm/components/combination/_Group/utils.js +46 -0
  14. package/es/ProForm/components/render/Render.js +10 -8
  15. package/es/ProForm/components/render/propsType.d.ts +3 -3
  16. package/es/ProForm/utils/transformNames.js +3 -10
  17. package/es/ProForm/utils/useDeepCompareMemo.d.ts +2 -0
  18. package/es/ProForm/utils/useDeepCompareMemo.js +14 -0
  19. package/es/ProForm/utils/useRules.js +2 -20
  20. package/lib/ProEditTable/components/RenderField/index.js +4 -8
  21. package/lib/ProForm/components/combination/FormList/index.js +1 -1
  22. package/lib/ProForm/components/combination/FormList/utils.js +2 -3
  23. package/lib/ProForm/components/combination/Group/index.d.ts +8 -2
  24. package/lib/ProForm/components/combination/Group/index.js +58 -72
  25. package/lib/ProForm/components/combination/Group/propsType.d.ts +27 -14
  26. package/lib/ProForm/components/combination/Group/utils.d.ts +60 -7
  27. package/lib/ProForm/components/combination/Group/utils.js +210 -20
  28. package/lib/ProForm/components/combination/_Group/index.d.ts +4 -0
  29. package/lib/ProForm/components/combination/_Group/index.js +113 -0
  30. package/lib/ProForm/components/combination/_Group/propsType.d.ts +35 -0
  31. package/lib/ProForm/components/combination/_Group/utils.d.ts +10 -0
  32. package/lib/ProForm/components/combination/_Group/utils.js +53 -0
  33. package/lib/ProForm/components/render/Render.js +9 -7
  34. package/lib/ProForm/components/render/propsType.d.ts +3 -3
  35. package/lib/ProForm/utils/transformNames.js +2 -9
  36. package/lib/ProForm/utils/useDeepCompareMemo.d.ts +2 -0
  37. package/lib/ProForm/utils/useDeepCompareMemo.js +20 -0
  38. package/lib/ProForm/utils/useRules.js +2 -20
  39. package/menu.json +5504 -0
  40. package/package.json +1 -1
  41. package/coverage/lcov-report/src/.umi/core/devScripts.ts.html +0 -241
  42. package/coverage/lcov-report/src/.umi/core/history.ts.html +0 -148
  43. package/coverage/lcov-report/src/.umi/core/index.html +0 -206
  44. package/coverage/lcov-report/src/.umi/core/plugin.ts.html +0 -109
  45. package/coverage/lcov-report/src/.umi/core/pluginRegister.ts.html +0 -160
  46. package/coverage/lcov-report/src/.umi/core/polyfill.ts.html +0 -97
  47. package/coverage/lcov-report/src/.umi/core/routes.ts.html +0 -26050
  48. package/coverage/lcov-report/src/.umi/core/umiExports.ts.html +0 -112
  49. package/coverage/lcov-report/src/.umi/dumi/demos/index.html +0 -116
  50. package/coverage/lcov-report/src/.umi/dumi/demos/index.ts.html +0 -6340
  51. package/coverage/lcov-report/src/.umi/dumi/index.html +0 -116
  52. package/coverage/lcov-report/src/.umi/dumi/layout.tsx.html +0 -109
  53. package/coverage/lcov-report/src/.umi/index.html +0 -116
  54. package/coverage/lcov-report/src/.umi/plugin-antd/index.html +0 -116
  55. package/coverage/lcov-report/src/.umi/plugin-antd/runtime.tsx.html +0 -172
  56. package/coverage/lcov-report/src/.umi/plugin-helmet/exports.ts.html +0 -94
  57. package/coverage/lcov-report/src/.umi/plugin-helmet/index.html +0 -116
  58. package/coverage/lcov-report/src/.umi/plugin-initial-state/Provider.tsx.html +0 -196
  59. package/coverage/lcov-report/src/.umi/plugin-initial-state/exports.ts.html +0 -106
  60. package/coverage/lcov-report/src/.umi/plugin-initial-state/index.html +0 -146
  61. package/coverage/lcov-report/src/.umi/plugin-initial-state/models/index.html +0 -116
  62. package/coverage/lcov-report/src/.umi/plugin-initial-state/models/initialState.ts.html +0 -88
  63. package/coverage/lcov-report/src/.umi/plugin-initial-state/runtime.tsx.html +0 -124
  64. package/coverage/lcov-report/src/.umi/plugin-locale/SelectLang.tsx.html +0 -1246
  65. package/coverage/lcov-report/src/.umi/plugin-locale/index.html +0 -161
  66. package/coverage/lcov-report/src/.umi/plugin-locale/locale.tsx.html +0 -268
  67. package/coverage/lcov-report/src/.umi/plugin-locale/localeExports.ts.html +0 -778
  68. package/coverage/lcov-report/src/.umi/plugin-locale/runtime.tsx.html +0 -115
  69. package/coverage/lcov-report/src/.umi/plugin-model/Provider.tsx.html +0 -202
  70. package/coverage/lcov-report/src/.umi/plugin-model/helpers/constant.tsx.html +0 -97
  71. package/coverage/lcov-report/src/.umi/plugin-model/helpers/dispatcher.tsx.html +0 -142
  72. package/coverage/lcov-report/src/.umi/plugin-model/helpers/executor.tsx.html +0 -334
  73. package/coverage/lcov-report/src/.umi/plugin-model/helpers/index.html +0 -146
  74. package/coverage/lcov-report/src/.umi/plugin-model/index.html +0 -146
  75. package/coverage/lcov-report/src/.umi/plugin-model/runtime.tsx.html +0 -121
  76. package/coverage/lcov-report/src/.umi/plugin-model/useModel.tsx.html +0 -298
  77. package/coverage/lcov-report/src/.umi/plugin-request/index.html +0 -116
  78. package/coverage/lcov-report/src/.umi/plugin-request/request.ts.html +0 -919
  79. package/coverage/lcov-report/src/.umi/umi.ts.html +0 -268
  80. package/es/ProForm/components/combination/GroupCopy/index.d.ts +0 -10
  81. package/es/ProForm/components/combination/GroupCopy/index.js +0 -84
  82. package/es/ProForm/components/combination/GroupCopy/propsType.d.ts +0 -47
  83. package/es/ProForm/components/combination/GroupCopy/utils.d.ts +0 -53
  84. package/es/ProForm/components/combination/GroupCopy/utils.js +0 -180
  85. package/lib/ProForm/components/combination/GroupCopy/index.d.ts +0 -10
  86. package/lib/ProForm/components/combination/GroupCopy/index.js +0 -91
  87. package/lib/ProForm/components/combination/GroupCopy/propsType.d.ts +0 -47
  88. package/lib/ProForm/components/combination/GroupCopy/utils.d.ts +0 -53
  89. package/lib/ProForm/components/combination/GroupCopy/utils.js +0 -187
  90. /package/es/ProForm/components/combination/{GroupCopy → Group}/component/ComRender.d.ts +0 -0
  91. /package/es/ProForm/components/combination/{GroupCopy → Group}/component/ComRender.js +0 -0
  92. /package/es/ProForm/components/combination/{GroupCopy → _Group}/propsType.js +0 -0
  93. /package/es/ProForm/components/combination/{GroupCopy → _Group}/style/index.less +0 -0
  94. /package/lib/ProForm/components/combination/{GroupCopy → Group}/component/ComRender.d.ts +0 -0
  95. /package/lib/ProForm/components/combination/{GroupCopy → Group}/component/ComRender.js +0 -0
  96. /package/lib/ProForm/components/combination/{GroupCopy → _Group}/propsType.js +0 -0
  97. /package/lib/ProForm/components/combination/{GroupCopy → _Group}/style/index.less +0 -0
@@ -315,7 +315,7 @@ var RenderField = function RenderField(_ref) {
315
315
  }
316
316
  _args = [].concat(args);
317
317
  rowPath = [].concat(_toConsumableArray(namePath), [index]);
318
- row = type === 'Group' ? _args[1] : form.getFieldValue(rowPath, true);
318
+ row = form.getFieldValue(rowPath, true);
319
319
  orgRow = cloneDeep(row);
320
320
  if (!onFieldChange) {
321
321
  _context.next = 18;
@@ -360,7 +360,7 @@ var RenderField = function RenderField(_ref) {
360
360
  return onChange.apply(void 0, _toConsumableArray(_args));
361
361
  case 27:
362
362
  // 判断属性是否变动
363
- type !== 'Group' && form.setFieldValue(rowPath, row);
363
+ form.setFieldValue(rowPath, row);
364
364
  if (!isEqual(orgRow, row)) {
365
365
  diff = difference(row, orgRow) || {};
366
366
  validateFieldKeys = (_Object$keys = Object.keys(diff)) === null || _Object$keys === void 0 ? void 0 : (_Object$keys$map = _Object$keys.map) === null || _Object$keys$map === void 0 ? void 0 : _Object$keys$map.call(_Object$keys, function (key) {
@@ -406,7 +406,7 @@ var RenderField = function RenderField(_ref) {
406
406
  }
407
407
  _args = formatArgs([].concat(args));
408
408
  rowPath = [].concat(_toConsumableArray(namePath), [index]);
409
- row = type === 'Group' ? _args[1] : form.getFieldValue(rowPath, true);
409
+ row = type === form.getFieldValue(rowPath, true);
410
410
  orgRow = cloneDeep(row);
411
411
  _args[1] = row;
412
412
  _context2.t0 = (_TargetComponent3 = TargetComponent) === null || _TargetComponent3 === void 0 ? void 0 : (_TargetComponent3$pro = _TargetComponent3.props) === null || _TargetComponent3$pro === void 0 ? void 0 : _TargetComponent3$pro.onBlur;
@@ -497,11 +497,7 @@ var RenderField = function RenderField(_ref) {
497
497
  isView: isView
498
498
  }
499
499
  });
500
- if (type === 'Group') {
501
- componentProps.onFieldChange = _onchange;
502
- } else {
503
- componentProps = omit(componentProps, ['onFieldChange', 'namePath', 'index']);
504
- }
500
+ componentProps = omit(componentProps, ['onFieldChange', 'namePath', 'index']);
505
501
  // 单元格编辑时,设置各个单元格disabled属性
506
502
  if (isCell) {
507
503
  record["".concat(dataIndex, "-Disabled")] = _disabled;
@@ -48,7 +48,7 @@ var FormList = function FormList(props, ref) {
48
48
  name: _name,
49
49
  names: (item === null || item === void 0 ? void 0 : item.names) ? item.names.map(function (nameItem) {
50
50
  // 传给Group的names会被渲染成真实FormItem 不能传完整name
51
- return item.type === 'Group' ? [fieldName].concat(_toConsumableArray(toArray(nameItem))) : [].concat(_toConsumableArray(namePath), _toConsumableArray(toArray(nameItem)));
51
+ return [].concat(_toConsumableArray(namePath), _toConsumableArray(toArray(nameItem)));
52
52
  }) : item.names,
53
53
  index: fieldName,
54
54
  namePath: namePath,
@@ -8,12 +8,11 @@ export var namesPathTransform = function namesPathTransform(_ref) {
8
8
  var names = _ref.names,
9
9
  prefixNamePath = _ref.prefixNamePath,
10
10
  type = _ref.type;
11
- if (!Array.isArray(names) || type !== 'Group' && !Array.isArray(prefixNamePath)) {
11
+ if (!Array.isArray(names) || !Array.isArray(prefixNamePath)) {
12
12
  return '';
13
13
  }
14
- var _prefixNamePath = type === 'Group' ? '' : prefixNamePath;
15
14
  var newNamePath = names.map(function (val) {
16
- return _prefixNamePath.concat(val);
15
+ return prefixNamePath.concat(val);
17
16
  });
18
17
  return newNamePath === null || newNamePath === void 0 ? void 0 : newNamePath.map(function (name) {
19
18
  return Array.isArray(name) ? name.join('_') : name;
@@ -1,4 +1,10 @@
1
1
  import React from 'react';
2
2
  import { GroupProps } from './propsType';
3
- declare const Group: React.FC<GroupProps>;
4
- export default Group;
3
+ /**
4
+ * 1. 外层过滤FormItem相关属性, 但是子元素上的 required [disabled] [show] rules [fieldProps] [component] 需要取到并
5
+ * 2.
6
+ *
7
+ * render内部能力 show, component, value, onChange, disabled, clearNotShow, fieldProps
8
+ */
9
+ declare const GroupCopy: React.FC<GroupProps>;
10
+ export default GroupCopy;
@@ -1,61 +1,61 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
1
2
  import "antd/es/space/style";
2
3
  import _Space from "antd/es/space";
3
4
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
- import "antd/es/button/style";
5
- import _Button from "antd/es/button";
6
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
5
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
7
6
  import { jsx as _jsx } from "react/jsx-runtime";
8
- import { useMemo } from 'react';
9
- import { omit, isFunction, union, isNumber } from 'lodash';
10
- import { useDeepCompareEffect } from 'ahooks';
7
+ import React, { useMemo } from 'react';
8
+ import { omit } from 'lodash';
11
9
  import classnames from 'classnames';
12
- import RenderFields from '../../render/RenderFields';
13
- import { insertSeparator, transformNamesString } from './utils';
10
+ import { insertSeparator, transformColumns } from './utils';
14
11
  import ProForm from '../../../../ProForm';
15
- var Group = function Group(props) {
16
- var columns = props.children,
17
- otherProps = props.otherProps,
12
+ import ComRender from './component/ComRender';
13
+ /**
14
+ * 1. 外层过滤FormItem相关属性, 但是子元素上的 required [disabled] [show] rules [fieldProps] [component] 需要取到并
15
+ * 2.
16
+ *
17
+ * render内部能力 show, component, value, onChange, disabled, clearNotShow, fieldProps
18
+ */
19
+ var GroupCopy = function GroupCopy(props) {
20
+ console.log('🚀 ~~> props:', props);
21
+ var children = props.children,
18
22
  className = props.className,
19
23
  _props$space = props.space,
20
24
  space = _props$space === void 0 ? {
21
25
  size: 12
22
26
  } : _props$space,
23
- id = props.id,
24
27
  value = props.value,
25
- isView = props.isView,
26
- index = props.index,
27
- onFieldChange = props.onFieldChange,
28
- namePath = props.namePath;
29
- var _ref = ProForm.useFieldProps() || {},
30
- names = _ref.names,
31
- name = _ref.name,
32
- form = _ref.form,
33
- _namePath = _ref.namePath;
34
- var newNamePath = namePath || _namePath || [];
35
- if (!Array.isArray(names)) {
36
- console.error('Warning: Composite form components whose type is Group must be configured with names');
37
- }
38
- var data = useMemo(function () {
39
- var fieldList = [];
40
- var result = columns.map(function (item) {
41
- return _objectSpread(_objectSpread({
42
- disabled: Boolean(props === null || props === void 0 ? void 0 : props.disabled)
43
- }, item), {}, {
44
- isView: isView !== null && isView !== void 0 ? isView : item.isView,
45
- noStyle: (space === null || space === void 0 ? void 0 : space.compact) || (space === null || space === void 0 ? void 0 : space.separator),
46
- parentNames: id,
47
- namePath: newNamePath
48
- });
49
- });
50
- var node = _jsx(_Button, {
51
- className: "group-separator",
52
- children: space.separator
28
+ onChange = props.onChange,
29
+ otherProps = props.otherProps,
30
+ disabled = props.disabled;
31
+ var contextProps = ProForm.useFieldProps() || {};
32
+ var names = contextProps.names,
33
+ name = contextProps.name,
34
+ form = contextProps.form,
35
+ namePath = contextProps.namePath,
36
+ index = contextProps.index;
37
+ var _option = React.useRef([]);
38
+ // 组合onChange
39
+ var handleChange = function handleChange(value, option, index) {
40
+ var _value = props.value ? _toConsumableArray(props.value) : [];
41
+ _value[index] = value;
42
+ _option.current[index] = option;
43
+ onChange(_value, _option.current);
44
+ };
45
+ var columns = useMemo(function () {
46
+ var columnsProps = transformColumns({
47
+ columns: children,
48
+ name: name,
49
+ names: names,
50
+ onChange: handleChange,
51
+ namePath: namePath,
52
+ form: form,
53
+ index: index,
54
+ value: value,
55
+ groupProps: props
53
56
  });
54
- return {
55
- columns: insertSeparator(result, space, node, otherProps),
56
- fieldList: fieldList
57
- };
58
- }, [name, columns, space, props, names]);
57
+ return insertSeparator(columnsProps, space);
58
+ }, [name, value, children, space, names, namePath, index]);
59
59
  var _className = classnames(_defineProperty({
60
60
  'pro-group': true,
61
61
  'pro-group-diy-width': columns.some(function (item) {
@@ -66,44 +66,27 @@ var Group = function Group(props) {
66
66
  return ['Radio', 'Checkbox', 'Switch'].includes(item.type);
67
67
  })
68
68
  }, "".concat(className), className));
69
- // 用于formList场景下names移除掉了前缀,需要再次合并回来
70
- var _names = names.map(function (item) {
71
- if (isNumber(item === null || item === void 0 ? void 0 : item[0])) {
72
- return union(newNamePath, item);
73
- }
74
- return item;
75
- });
76
- useDeepCompareEffect(function () {
77
- var _document, _document$activeEleme;
78
- // 焦点激活的表单
79
- var touchName = ((_document = document) === null || _document === void 0 ? void 0 : (_document$activeEleme = _document.activeElement) === null || _document$activeEleme === void 0 ? void 0 : _document$activeEleme.id) || '';
80
- // 模拟change,初始化不执行onFieldChange
81
- if (isFunction(onFieldChange) && form.isFieldsTouched(_names) && transformNamesString(_names).includes(touchName)) {
82
- onFieldChange(value, (newNamePath === null || newNamePath === void 0 ? void 0 : newNamePath.length) ? form.getFieldValue(newNamePath, true) : form.getFieldsValue(), {
83
- form: form,
84
- namePath: newNamePath,
85
- index: index
86
- });
87
- }
88
- }, [value]);
89
- var _otherProps = omit(otherProps, ['colProps', 'required']);
90
69
  return _jsx("div", {
91
70
  className: _className,
92
71
  children: space.compact || (space === null || space === void 0 ? void 0 : space.separator) ? _jsx(_Space.Compact, {
93
- children: _jsx(RenderFields, _objectSpread({
94
- columns: data.columns,
95
- form: form
96
- }, _otherProps))
72
+ children: columns.map(function (column) {
73
+ return _jsx(ComRender, _objectSpread(_objectSpread({
74
+ contextProps: contextProps
75
+ }, column), {}, {
76
+ otherProps: otherProps
77
+ }));
78
+ })
97
79
  }) : _jsx(_Space, _objectSpread(_objectSpread({
98
80
  align: "start"
99
81
  }, omit(space, ['separator', 'compact'])), {}, {
100
- children: data.columns.map(function (column, index) {
101
- return _jsx(RenderFields, _objectSpread({
102
- columns: [column],
103
- form: form
104
- }, _otherProps), (column === null || column === void 0 ? void 0 : column.name) || index);
82
+ children: columns.map(function (column, index) {
83
+ return _jsx(ComRender, _objectSpread(_objectSpread({
84
+ contextProps: contextProps
85
+ }, column), {}, {
86
+ otherProps: otherProps
87
+ }));
105
88
  })
106
89
  }))
107
90
  });
108
91
  };
109
- export default Group;
92
+ export default GroupCopy;
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
- import { RowProps, SpaceProps } from 'antd';
2
+ import { FormItemProps, ModalFuncProps, SpaceProps } from 'antd';
3
3
  import { FormInstance } from 'antd/es/form/Form';
4
4
  import { NamePath } from 'antd/lib/form/interface';
5
- import { ProColumnProps, ProFormOtherProps } from '../../../propsType';
5
+ import { ColumnPropsMap, FunctionArgs, ProFormValueType, ReactiveFunction, ViewType } from '../../../propsType';
6
6
  export interface SpaceType extends SpaceProps {
7
7
  /**
8
8
  * 是否紧凑合并
@@ -16,20 +16,33 @@ export interface SpaceType extends SpaceProps {
16
16
  size?: number;
17
17
  }
18
18
  export interface GroupProps {
19
- children?: ProColumnProps[];
19
+ children?: GroupColumnProps[];
20
20
  space?: SpaceType;
21
- otherProps?: ProFormOtherProps;
22
- rowProps?: RowProps;
23
21
  className?: string;
24
- value?: any;
25
22
  id?: string;
26
- disabled?: boolean | (() => void);
23
+ disabled?: boolean;
27
24
  isView?: boolean;
28
- namePath?: NamePath;
29
- index?: number;
30
- onFieldChange?: (value: any[] | null, record: any, { form, }: {
31
- form: FormInstance;
32
- namePath?: NamePath;
33
- index?: number;
34
- }) => any;
25
+ value?: any[];
26
+ onChange?: (value: any[] | null, options?: any[]) => void;
27
+ otherProps?: any;
35
28
  }
29
+ export type GroupColumnProps<Values = any> = {
30
+ component?: React.ReactNode | ReactiveFunction<Values, React.ReactNode>;
31
+ names?: NamePath[];
32
+ show?: boolean | ReactiveFunction<Values, boolean>;
33
+ valueType?: ProFormValueType;
34
+ switchValue?: [any, any];
35
+ isView?: boolean;
36
+ viewRender?: (value: any, record: Values, { form, index, namePath, }: {
37
+ form: FormInstance<Values>;
38
+ index?: number | undefined;
39
+ [key: string]: any;
40
+ }) => React.ReactElement<any, any> | string | undefined | null;
41
+ viewType?: ViewType;
42
+ disabled?: boolean | ReactiveFunction<Values, boolean>;
43
+ trim?: boolean;
44
+ upperCase?: boolean;
45
+ toISOString?: boolean;
46
+ clearNotShow?: boolean;
47
+ confirm?: boolean | ModalFuncProps | FunctionArgs<Values, boolean | ModalFuncProps>;
48
+ } & ColumnPropsMap & FormItemProps;
@@ -1,10 +1,63 @@
1
- import { ReactNode } from 'react';
2
- import { SpaceType } from './propsType';
1
+ /// <reference types="react" />
2
+ import { InternalNamePath, NamePath } from 'antd/lib/form/interface';
3
+ import { FormInstance } from 'antd';
4
+ import { GroupColumnProps, GroupProps, SpaceType } from './propsType';
5
+ import { ProFormColumnProps, ReactiveFunction } from '../../render/propsType';
6
+ export type EventArgs = any[];
3
7
  /**
4
- * 插入间隔符
5
- * @param columns 表单配置数组
6
- * @returns
7
- */
8
- export declare const insertSeparator: (columns: any, space?: SpaceType, separatorNode?: ReactNode, otherProps?: any) => any;
8
+ * 插入间隔符
9
+ * @param columns 表单配置数组
10
+ * @returns
11
+ */
12
+ export declare const insertSeparator: (columns: GroupColumnProps[], space?: SpaceType) => any[];
13
+ /** 带出event的组件默认取值方法 */
14
+ export declare function defaultGetValueFromEvent(valuePropName: string, ...args: EventArgs): any;
9
15
  /** 转换names */
10
16
  export declare const transformNamesString: (arr: (string | string[])[]) => (string | string[])[];
17
+ /**
18
+ * Input TextArea 小写自动转大写
19
+ * @param type 组件类型
20
+ * @param upperCase 是否小写转大写
21
+ * @returns {}
22
+ */
23
+ export declare const isUpperCase: (type: string, upperCase: boolean) => any;
24
+ interface Params {
25
+ form?: FormInstance;
26
+ index?: number;
27
+ type?: string;
28
+ namePath?: InternalNamePath;
29
+ disabled?: boolean | ReactiveFunction<any, boolean>;
30
+ show?: boolean | ReactiveFunction<any, boolean>;
31
+ component?: React.ReactNode | ReactiveFunction<any, React.ReactNode>;
32
+ fieldProps?: boolean | ReactiveFunction<any, boolean>;
33
+ name?: NamePath;
34
+ }
35
+ /** 计算响应式参数的值 */
36
+ export declare const getReactiveProps: (params: Params) => {
37
+ disabled: boolean;
38
+ show: boolean;
39
+ component: any;
40
+ fieldProps: boolean;
41
+ };
42
+ type ValueTypeGetterParams = Pick<ProFormColumnProps, 'valueType' | 'switchValue' | 'toISOString'> & {
43
+ type?: any;
44
+ mode?: string;
45
+ };
46
+ /** 获取当前字段的转换函数 */
47
+ export declare const getValueTypeTrans: (params: ValueTypeGetterParams) => any;
48
+ /** 执行所有中间件 返回处理后的值 */
49
+ export declare const getValueMiddleware: (value: any, callbacks?: any[]) => any;
50
+ interface ColumnsTransformerParams {
51
+ columns: GroupColumnProps[];
52
+ name?: NamePath;
53
+ names?: NamePath[];
54
+ value?: any[];
55
+ onChange: any;
56
+ namePath?: InternalNamePath;
57
+ form: FormInstance;
58
+ index?: number;
59
+ groupProps: GroupProps;
60
+ }
61
+ /** 转换columns */
62
+ export declare const transformColumns: (params: ColumnsTransformerParams) => any[];
63
+ export {};
@@ -1,31 +1,31 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
+ import _typeof from "@babel/runtime/helpers/esm/typeof";
4
+ import "antd/es/button/style";
5
+ import _Button from "antd/es/button";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ import { isFunction } from 'lodash';
8
+ import valueTypeMap from '../../../utils/valueType';
9
+ import { useDeepCompareMemo } from '@/ProForm/utils/useDeepCompareMemo';
2
10
  /**
3
- * 插入间隔符
4
- * @param columns 表单配置数组
5
- * @returns
6
- */
7
- export var insertSeparator = function insertSeparator(columns, space, separatorNode, otherProps) {
8
- var _columns = columns;
9
- var _ref = otherProps || {},
10
- names = _ref.names;
11
- // 紧凑模式存在names时,自动给下级拆解name
12
- if (names) {
13
- _columns = _columns.map(function (column, index) {
14
- return _objectSpread(_objectSpread({}, column), {}, {
15
- name: names[index]
16
- });
17
- });
18
- }
11
+ * 插入间隔符
12
+ * @param columns 表单配置数组
13
+ * @returns
14
+ */
15
+ export var insertSeparator = function insertSeparator(columns, space) {
19
16
  if (!(space === null || space === void 0 ? void 0 : space.separator)) {
20
- return _columns;
17
+ return columns;
21
18
  }
22
- return _columns.reduce(function (result, current, index, array) {
19
+ return columns.reduce(function (result, current, index, array) {
23
20
  // 将当前元素添加到结果数组中
24
21
  result.push(current);
25
22
  // 如果当前元素不是最后一个元素,则添加间隔符
26
23
  if (index < array.length - 1) {
27
24
  result.push({
28
- component: separatorNode,
25
+ component: _jsx(_Button, {
26
+ className: "group-separator",
27
+ children: space.separator
28
+ }),
29
29
  fieldProps: {
30
30
  disabled: true
31
31
  }
@@ -34,6 +34,14 @@ export var insertSeparator = function insertSeparator(columns, space, separatorN
34
34
  return result;
35
35
  }, []);
36
36
  };
37
+ /** 带出event的组件默认取值方法 */
38
+ export function defaultGetValueFromEvent(valuePropName) {
39
+ var event = arguments.length <= 1 ? undefined : arguments[1];
40
+ if (event && event.target && _typeof(event.target) === 'object' && valuePropName in event.target) {
41
+ return event.target[valuePropName];
42
+ }
43
+ return event;
44
+ }
37
45
  /** 转换names */
38
46
  export var transformNamesString = function transformNamesString(arr) {
39
47
  var result = arr.map(function (subArr) {
@@ -43,4 +51,186 @@ export var transformNamesString = function transformNamesString(arr) {
43
51
  return subArr;
44
52
  });
45
53
  return result;
54
+ };
55
+ /**
56
+ * Input TextArea 小写自动转大写
57
+ * @param type 组件类型
58
+ * @param upperCase 是否小写转大写
59
+ * @returns {}
60
+ */
61
+ export var isUpperCase = function isUpperCase(type, upperCase) {
62
+ var result = {};
63
+ if (['Input', 'TextArea', 'ProCombination'].includes(type) && upperCase) {
64
+ result.getValueFromEvent = function (event) {
65
+ var _event$target, _event$target$value;
66
+ if (Array.isArray(event)) {
67
+ return event.map(function (value) {
68
+ var newValue = value === null || value === void 0 ? void 0 : value.replace(/[^a-zA-Z]/g, '');
69
+ return (newValue === null || newValue === void 0 ? void 0 : newValue.toUpperCase()) || '';
70
+ });
71
+ }
72
+ var newValue = (_event$target = event.target) === null || _event$target === void 0 ? void 0 : (_event$target$value = _event$target.value) === null || _event$target$value === void 0 ? void 0 : _event$target$value.replace(/[^a-zA-Z]/g, '');
73
+ return newValue.toUpperCase() || '';
74
+ };
75
+ }
76
+ return result;
77
+ };
78
+ /** 计算响应式参数的值 */
79
+ export var getReactiveProps = function getReactiveProps(params) {
80
+ var form = params.form,
81
+ index = params.index,
82
+ namePath = params.namePath,
83
+ disabled = params.disabled,
84
+ show = params.show,
85
+ component = params.component,
86
+ fieldProps = params.fieldProps,
87
+ name = params.name;
88
+ var values = form.getFieldsValue(namePath || undefined);
89
+ var _disabled = isFunction(disabled) ? disabled(values, {
90
+ form: form,
91
+ index: index,
92
+ namePath: namePath
93
+ }) : disabled;
94
+ var _show = isFunction(show) ? show(values, {
95
+ form: form,
96
+ index: index,
97
+ namePath: namePath
98
+ }) : show;
99
+ var _component = isFunction(component) ? component(values, {
100
+ form: form,
101
+ index: index,
102
+ namePath: namePath
103
+ }) : component;
104
+ var _fieldProps = isFunction(fieldProps) ? fieldProps(values, {
105
+ form: form,
106
+ index: index,
107
+ namePath: namePath
108
+ }) : fieldProps;
109
+ return {
110
+ disabled: _disabled,
111
+ show: _show,
112
+ component: _component,
113
+ fieldProps: _fieldProps
114
+ };
115
+ };
116
+ /** 获取当前字段的转换函数 */
117
+ export var getValueTypeTrans = function getValueTypeTrans(params) {
118
+ var _valueTypeMap$valueTy;
119
+ var valueType = params.valueType;
120
+ var transform = (_valueTypeMap$valueTy = valueTypeMap[valueType]) === null || _valueTypeMap$valueTy === void 0 ? void 0 : _valueTypeMap$valueTy.call(valueTypeMap, params);
121
+ return transform;
122
+ };
123
+ var getTrim = function getTrim(value) {
124
+ return (value === null || value === void 0 ? void 0 : value.trim()) || '';
125
+ };
126
+ var getUpperCase = function getUpperCase(value) {
127
+ var _value = value === null || value === void 0 ? void 0 : value.replace(/[^a-zA-Z]/g, '');
128
+ return _value.toUpperCase() || '';
129
+ };
130
+ /** 执行所有中间件 返回处理后的值 */
131
+ export var getValueMiddleware = function getValueMiddleware(value) {
132
+ var callbacks = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
133
+ return callbacks.reduce(function (preValue, cb) {
134
+ return cb === null || cb === void 0 ? void 0 : cb(preValue);
135
+ }, value);
136
+ };
137
+ /** 获取中间件处理后的value */
138
+ var valueFromEventWrapper = function valueFromEventWrapper(column, args) {
139
+ var getValueFromEvent = column.getValueFromEvent,
140
+ _column$valuePropName = column.valuePropName,
141
+ valuePropName = _column$valuePropName === void 0 ? 'value' : _column$valuePropName,
142
+ trim = column.trim,
143
+ upperCase = column.upperCase;
144
+ var newValue;
145
+ if (getValueFromEvent) {
146
+ newValue = getValueFromEvent.apply(void 0, _toConsumableArray(args));
147
+ } else {
148
+ newValue = defaultGetValueFromEvent.apply(void 0, [valuePropName].concat(_toConsumableArray(args)));
149
+ }
150
+ var list = [];
151
+ if (trim) list.push(getTrim);
152
+ if (upperCase) list.push(getUpperCase);
153
+ return getValueMiddleware(newValue, list);
154
+ };
155
+ /** 转换columns */
156
+ export var transformColumns = function transformColumns(params) {
157
+ var form = params.form,
158
+ columns = params.columns,
159
+ name = params.name,
160
+ names = params.names,
161
+ outerIndex = params.index,
162
+ namePath = params.namePath,
163
+ value = params.value,
164
+ internalChange = params.onChange,
165
+ groupProps = params.groupProps;
166
+ return columns === null || columns === void 0 ? void 0 : columns.flatMap(function (column, index) {
167
+ var type = column.type,
168
+ valueType = column.valueType,
169
+ switchValue = column.switchValue,
170
+ toISOString = column.toISOString,
171
+ fieldProps = column.fieldProps,
172
+ normalize = column.normalize,
173
+ disabled = column.disabled,
174
+ show = column.show,
175
+ component = column.component;
176
+ var _ref = fieldProps || {},
177
+ mode = _ref.mode,
178
+ onChange = _ref.onChange,
179
+ onFieldChange = _ref.onFieldChange,
180
+ comDisabled = _ref.disabled;
181
+ var _disabled = disabled || comDisabled;
182
+ var columnName = names ? names[index] : [].concat(name, index);
183
+ // 响应式字段
184
+ var reactiveProps = useDeepCompareMemo(function () {
185
+ return getReactiveProps({
186
+ form: form,
187
+ index: index,
188
+ type: type,
189
+ namePath: namePath,
190
+ disabled: _disabled,
191
+ show: show,
192
+ component: component,
193
+ fieldProps: fieldProps,
194
+ name: columnName
195
+ });
196
+ }, [value, show, fieldProps, columnName, type]);
197
+ if (reactiveProps.show === false) {
198
+ return [];
199
+ }
200
+ var transform = getValueTypeTrans({
201
+ type: type,
202
+ valueType: valueType,
203
+ switchValue: switchValue,
204
+ toISOString: toISOString,
205
+ mode: mode
206
+ });
207
+ var newValue;
208
+ var handleChange = function handleChange() {
209
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
210
+ args[_key] = arguments[_key];
211
+ }
212
+ newValue = valueFromEventWrapper(column, args);
213
+ if ((transform === null || transform === void 0 ? void 0 : transform.normalize) || normalize) {
214
+ var _transform$normalize;
215
+ // @ts-ignore
216
+ newValue = ((_transform$normalize = transform.normalize) === null || _transform$normalize === void 0 ? void 0 : _transform$normalize.call(transform, newValue)) || (normalize === null || normalize === void 0 ? void 0 : normalize(newValue));
217
+ }
218
+ internalChange === null || internalChange === void 0 ? void 0 : internalChange(newValue, args[1], index);
219
+ onChange === null || onChange === void 0 ? void 0 : onChange.apply(void 0, args);
220
+ onFieldChange === null || onFieldChange === void 0 ? void 0 : onFieldChange(newValue, form.getFieldValue(namePath), {
221
+ index: outerIndex,
222
+ namePath: namePath,
223
+ form: form
224
+ });
225
+ };
226
+ return _objectSpread(_objectSpread(_objectSpread({}, column), {}, {
227
+ name: columnName
228
+ }, reactiveProps), {}, {
229
+ disabled: reactiveProps.disabled || groupProps.disabled,
230
+ fieldProps: _objectSpread(_objectSpread({}, column === null || column === void 0 ? void 0 : column.fieldProps), {}, {
231
+ onChange: handleChange,
232
+ value: value === null || value === void 0 ? void 0 : value[index]
233
+ })
234
+ });
235
+ });
46
236
  };
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { GroupProps } from './propsType';
3
+ declare const Group: React.FC<GroupProps>;
4
+ export default Group;