@zat-design/sisyphus-react 3.4.6 → 3.4.8-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/dist/index.esm.css +17 -1
  2. package/dist/less.esm.css +17 -1
  3. package/es/ProEditTable/components/RenderField/index.js +5 -8
  4. package/es/ProEditTable/style/index.less +5 -2
  5. package/es/ProForm/components/base/TextArea/index.d.ts +1 -0
  6. package/es/ProForm/components/base/TextArea/index.js +4 -2
  7. package/es/ProForm/components/combination/FormList/components/BlockFields.d.ts +1 -1
  8. package/es/ProForm/components/combination/FormList/index.js +2 -1
  9. package/es/ProForm/components/combination/FormList/propsType.d.ts +1 -1
  10. package/es/ProForm/components/combination/FormList/utils.js +2 -3
  11. package/es/ProForm/components/combination/{GroupCopy → Group}/component/ComRender.js +2 -2
  12. package/es/ProForm/components/combination/Group/index.d.ts +8 -2
  13. package/es/ProForm/components/combination/Group/index.js +58 -76
  14. package/es/ProForm/components/combination/Group/propsType.d.ts +27 -14
  15. package/es/ProForm/components/combination/Group/utils.d.ts +60 -7
  16. package/es/ProForm/components/combination/Group/utils.js +209 -19
  17. package/es/ProForm/components/combination/ProModalSelect/index.js +35 -29
  18. package/es/ProForm/components/combination/_Group/index.d.ts +4 -0
  19. package/es/ProForm/components/combination/_Group/index.js +109 -0
  20. package/es/ProForm/components/combination/_Group/propsType.d.ts +35 -0
  21. package/es/ProForm/components/combination/_Group/utils.d.ts +10 -0
  22. package/es/ProForm/components/combination/_Group/utils.js +46 -0
  23. package/es/ProForm/components/render/Render.js +8 -6
  24. package/es/ProForm/components/render/RenderFields.js +1 -0
  25. package/es/ProForm/components/render/propsType.d.ts +4 -3
  26. package/es/ProForm/propsType.d.ts +1 -0
  27. package/es/ProForm/style/index.less +7 -0
  28. package/es/ProForm/utils/diffOriginal.js +2 -1
  29. package/es/ProForm/utils/index.d.ts +6 -1
  30. package/es/ProForm/utils/index.js +5 -5
  31. package/es/ProForm/utils/transformNames.js +3 -10
  32. package/es/ProForm/utils/useDeepCompareMemo.d.ts +2 -0
  33. package/es/ProForm/utils/useDeepCompareMemo.js +14 -0
  34. package/es/ProForm/utils/useForm.js +2 -1
  35. package/es/ProForm/utils/useListChanged.js +2 -2
  36. package/es/ProForm/utils/useRules.js +2 -20
  37. package/es/ProSelect/index.js +14 -2
  38. package/es/ProSelect/propsType.d.ts +2 -0
  39. package/es/ProSelect/utils/index.d.ts +9 -0
  40. package/es/ProSelect/utils/index.js +60 -0
  41. package/es/ProTree/components/ProTreeSelect/index.js +3 -3
  42. package/es/ProTree/components/ProTreeSelect/style/index.less +6 -8
  43. package/es/ProTree/style/index.less +15 -0
  44. package/es/ProUpload/index.js +5 -6
  45. package/es/ProUpload/propsType.d.ts +1 -1
  46. package/es/global.less +40 -25
  47. package/es/locale/zh_CN.js +1 -1
  48. package/lib/ProEditTable/components/RenderField/index.js +5 -8
  49. package/lib/ProEditTable/style/index.less +5 -2
  50. package/lib/ProForm/components/base/TextArea/index.d.ts +1 -0
  51. package/lib/ProForm/components/base/TextArea/index.js +4 -2
  52. package/lib/ProForm/components/combination/FormList/components/BlockFields.d.ts +1 -1
  53. package/lib/ProForm/components/combination/FormList/index.js +2 -1
  54. package/lib/ProForm/components/combination/FormList/propsType.d.ts +1 -1
  55. package/lib/ProForm/components/combination/FormList/utils.js +2 -3
  56. package/lib/ProForm/components/combination/{GroupCopy → Group}/component/ComRender.js +2 -2
  57. package/lib/ProForm/components/combination/Group/index.d.ts +8 -2
  58. package/lib/ProForm/components/combination/Group/index.js +57 -72
  59. package/lib/ProForm/components/combination/Group/propsType.d.ts +27 -14
  60. package/lib/ProForm/components/combination/Group/utils.d.ts +60 -7
  61. package/lib/ProForm/components/combination/Group/utils.js +210 -20
  62. package/lib/ProForm/components/combination/ProModalSelect/index.js +35 -29
  63. package/lib/ProForm/components/combination/_Group/index.d.ts +4 -0
  64. package/lib/ProForm/components/combination/_Group/index.js +113 -0
  65. package/lib/ProForm/components/combination/_Group/propsType.d.ts +35 -0
  66. package/lib/ProForm/components/combination/_Group/utils.d.ts +10 -0
  67. package/lib/ProForm/components/combination/_Group/utils.js +53 -0
  68. package/lib/ProForm/components/render/Render.js +7 -5
  69. package/lib/ProForm/components/render/RenderFields.js +1 -0
  70. package/lib/ProForm/components/render/propsType.d.ts +4 -3
  71. package/lib/ProForm/propsType.d.ts +1 -0
  72. package/lib/ProForm/style/index.less +7 -0
  73. package/lib/ProForm/utils/diffOriginal.js +2 -1
  74. package/lib/ProForm/utils/index.d.ts +6 -1
  75. package/lib/ProForm/utils/index.js +5 -5
  76. package/lib/ProForm/utils/transformNames.js +2 -9
  77. package/lib/ProForm/utils/useDeepCompareMemo.d.ts +2 -0
  78. package/lib/ProForm/utils/useDeepCompareMemo.js +20 -0
  79. package/lib/ProForm/utils/useForm.js +2 -1
  80. package/lib/ProForm/utils/useListChanged.js +1 -1
  81. package/lib/ProForm/utils/useRules.js +2 -20
  82. package/lib/ProSelect/index.js +14 -2
  83. package/lib/ProSelect/propsType.d.ts +2 -0
  84. package/lib/ProSelect/utils/index.d.ts +9 -0
  85. package/lib/ProSelect/utils/index.js +68 -0
  86. package/lib/ProTree/components/ProTreeSelect/index.js +3 -3
  87. package/lib/ProTree/components/ProTreeSelect/style/index.less +6 -8
  88. package/lib/ProTree/style/index.less +15 -0
  89. package/lib/ProUpload/index.js +5 -6
  90. package/lib/ProUpload/propsType.d.ts +1 -1
  91. package/lib/global.less +40 -25
  92. package/lib/locale/zh_CN.js +1 -1
  93. package/package.json +1 -1
  94. package/es/ProForm/components/combination/GroupCopy/index.d.ts +0 -10
  95. package/es/ProForm/components/combination/GroupCopy/index.js +0 -84
  96. package/es/ProForm/components/combination/GroupCopy/propsType.d.ts +0 -47
  97. package/es/ProForm/components/combination/GroupCopy/utils.d.ts +0 -53
  98. package/es/ProForm/components/combination/GroupCopy/utils.js +0 -180
  99. package/lib/ProForm/components/combination/GroupCopy/index.d.ts +0 -10
  100. package/lib/ProForm/components/combination/GroupCopy/index.js +0 -91
  101. package/lib/ProForm/components/combination/GroupCopy/propsType.d.ts +0 -47
  102. package/lib/ProForm/components/combination/GroupCopy/utils.d.ts +0 -53
  103. package/lib/ProForm/components/combination/GroupCopy/utils.js +0 -187
  104. /package/es/ProForm/components/combination/{GroupCopy → Group}/component/ComRender.d.ts +0 -0
  105. /package/es/ProForm/components/combination/{GroupCopy → _Group}/propsType.js +0 -0
  106. /package/es/ProForm/components/combination/{GroupCopy → _Group}/style/index.less +0 -0
  107. /package/lib/ProForm/components/combination/{GroupCopy → Group}/component/ComRender.d.ts +0 -0
  108. /package/lib/ProForm/components/combination/{GroupCopy → _Group}/propsType.js +0 -0
  109. /package/lib/ProForm/components/combination/{GroupCopy → _Group}/style/index.less +0 -0
@@ -17,12 +17,14 @@ var _locale = _interopRequireDefault(require("../../../../locale"));
17
17
  var _ProForm = _interopRequireDefault(require("../../../../ProForm"));
18
18
  var _Container = _interopRequireDefault(require("../../Container"));
19
19
  require("./index.less");
20
- var _excluded = ["placeholder", "otherProps", "className"];
20
+ var _excluded = ["placeholder", "otherProps", "className", "tooltip"];
21
21
  var TextArea = _antd.Input.TextArea;
22
22
  var TextAreaDef = function TextAreaDef(props) {
23
23
  var placeholder = props.placeholder,
24
24
  otherProps = props.otherProps,
25
25
  className = props.className,
26
+ _props$tooltip = props.tooltip,
27
+ tooltip = _props$tooltip === void 0 ? true : _props$tooltip,
26
28
  rest = (0, _objectWithoutProperties2.default)(props, _excluded);
27
29
  var _ref = _ProForm.default.useFieldProps() || {},
28
30
  label = _ref.label,
@@ -33,7 +35,7 @@ var TextAreaDef = function TextAreaDef(props) {
33
35
  if (isView) {
34
36
  return (0, _jsxRuntime.jsx)(_Container.default, {
35
37
  nowrap: false,
36
- tooltip: true,
38
+ tooltip: tooltip,
37
39
  viewEmpty: viewEmpty,
38
40
  children: rest.value
39
41
  });
@@ -1,7 +1,7 @@
1
1
  import { ColProps, FormListFieldData } from 'antd';
2
2
  import React from 'react';
3
3
  import { InternalNamePath } from 'antd/es/form/interface';
4
- import type { levelType } from '@/ProLayout/components/ProCollapse/PropTypes';
4
+ import type { levelType } from '../../../../../ProLayout/components/ProCollapse/PropTypes';
5
5
  import type { FormListProps } from '../propsType';
6
6
  interface Props extends Omit<FormListProps, 'toolbarProps'> {
7
7
  index: number;
@@ -54,10 +54,11 @@ var FormList = function FormList(props, ref) {
54
54
  name: _name,
55
55
  names: (item === null || item === void 0 ? void 0 : item.names) ? item.names.map(function (nameItem) {
56
56
  // 传给Group的names会被渲染成真实FormItem 不能传完整name
57
- return item.type === 'Group' ? [fieldName].concat((0, _toConsumableArray2.default)((0, _utils.toArray)(nameItem))) : [].concat((0, _toConsumableArray2.default)(namePath), (0, _toConsumableArray2.default)((0, _utils.toArray)(nameItem)));
57
+ return [].concat((0, _toConsumableArray2.default)(namePath), (0, _toConsumableArray2.default)((0, _utils.toArray)(nameItem)));
58
58
  }) : item.names,
59
59
  index: fieldName,
60
60
  namePath: namePath,
61
+ listName: [].concat((0, _toConsumableArray2.default)(namePath), [item.name]),
61
62
  label: mode === 'less' ? undefined : item.label
62
63
  });
63
64
  return column;
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import type { FormInstance } from 'antd/es/form/Form';
3
3
  import type { ButtonProps, FormListFieldData, FormListOperation, PopconfirmProps } from 'antd';
4
4
  import type { InternalNamePath } from 'antd/es/form/interface';
5
- import type { levelType } from '@/ProLayout/components/ProCollapse/PropTypes';
5
+ import type { levelType } from '../../../../ProLayout/components/ProCollapse/PropTypes';
6
6
  import type { ProColumnProps, ProFormOtherProps } from '../../../propsType';
7
7
  export type TitleRender = (record: Record<string, any>, index: number, form: FormInstance) => any;
8
8
  export type TitleType = string | React.ReactNode | TitleRender;
@@ -14,12 +14,11 @@ var namesPathTransform = exports.namesPathTransform = function namesPathTransfor
14
14
  var names = _ref.names,
15
15
  prefixNamePath = _ref.prefixNamePath,
16
16
  type = _ref.type;
17
- if (!Array.isArray(names) || type !== 'Group' && !Array.isArray(prefixNamePath)) {
17
+ if (!Array.isArray(names) || !Array.isArray(prefixNamePath)) {
18
18
  return '';
19
19
  }
20
- var _prefixNamePath = type === 'Group' ? '' : prefixNamePath;
21
20
  var newNamePath = names.map(function (val) {
22
- return _prefixNamePath.concat(val);
21
+ return prefixNamePath.concat(val);
23
22
  });
24
23
  return newNamePath === null || newNamePath === void 0 ? void 0 : newNamePath.map(function (name) {
25
24
  return Array.isArray(name) ? name.join('_') : name;
@@ -10,8 +10,8 @@ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/obje
10
10
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
11
11
  var _jsxRuntime = require("react/jsx-runtime");
12
12
  var _react = _interopRequireDefault(require("react"));
13
- var _ConfirmWrapper = _interopRequireDefault(require("@/ProForm/components/render/ConfirmWrapper"));
14
- var _useFieldProps = require("@/ProForm/utils/useFieldProps");
13
+ var _ConfirmWrapper = _interopRequireDefault(require("../../../../components/render/ConfirmWrapper"));
14
+ var _useFieldProps = require("../../../../utils/useFieldProps");
15
15
  var componentMap = _interopRequireWildcard(require("../../../../../index"));
16
16
  var _excluded = ["type", "confirm", "component", "fieldProps", "contextProps"];
17
17
  /** 渲染组件 */
@@ -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,65 +1,67 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
3
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.default = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
12
  var _jsxRuntime = require("react/jsx-runtime");
11
13
  var _antd = require("antd");
12
- var _react = require("react");
14
+ var _react = _interopRequireWildcard(require("react"));
13
15
  var _lodash = require("lodash");
14
- var _ahooks = require("ahooks");
15
16
  var _classnames2 = _interopRequireDefault(require("classnames"));
16
- var _RenderFields = _interopRequireDefault(require("../../render/RenderFields"));
17
17
  var _utils = require("./utils");
18
18
  var _ProForm = _interopRequireDefault(require("../../../../ProForm"));
19
- var Group = function Group(props) {
20
- var columns = props.children,
21
- otherProps = props.otherProps,
19
+ var _ComRender = _interopRequireDefault(require("./component/ComRender"));
20
+ /**
21
+ * 1. 外层过滤FormItem相关属性, 但是子元素上的 required [disabled] [show] rules [fieldProps] [component] 需要取到并
22
+ * 2.
23
+ *
24
+ * render内部能力 show, component, value, onChange, disabled, clearNotShow, fieldProps
25
+ */
26
+ var GroupCopy = function GroupCopy(props) {
27
+ var children = props.children,
22
28
  className = props.className,
23
29
  _props$space = props.space,
24
30
  space = _props$space === void 0 ? {
25
31
  size: 12
26
32
  } : _props$space,
27
- id = props.id,
28
33
  value = props.value,
29
- isView = props.isView,
30
- index = props.index,
31
- onFieldChange = props.onFieldChange,
32
- namePath = props.namePath;
33
- var _ref = _ProForm.default.useFieldProps() || {},
34
- names = _ref.names,
35
- name = _ref.name,
36
- form = _ref.form,
37
- _namePath = _ref.namePath;
38
- var newNamePath = namePath || _namePath || [];
39
- if (!Array.isArray(names)) {
40
- console.error('Warning: Composite form components whose type is Group must be configured with names');
41
- }
42
- var data = (0, _react.useMemo)(function () {
43
- var fieldList = [];
44
- var result = columns.map(function (item) {
45
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({
46
- disabled: Boolean(props === null || props === void 0 ? void 0 : props.disabled)
47
- }, item), {}, {
48
- isView: isView !== null && isView !== void 0 ? isView : item.isView,
49
- noStyle: (space === null || space === void 0 ? void 0 : space.compact) || (space === null || space === void 0 ? void 0 : space.separator),
50
- parentNames: id,
51
- namePath: newNamePath
52
- });
53
- });
54
- var node = (0, _jsxRuntime.jsx)(_antd.Button, {
55
- className: "group-separator",
56
- children: space.separator
34
+ onChange = props.onChange,
35
+ otherProps = props.otherProps,
36
+ disabled = props.disabled;
37
+ var contextProps = _ProForm.default.useFieldProps() || {};
38
+ var names = contextProps.names,
39
+ name = contextProps.name,
40
+ form = contextProps.form,
41
+ namePath = contextProps.namePath,
42
+ index = contextProps.index;
43
+ var _option = _react.default.useRef([]);
44
+ // 组合onChange
45
+ var handleChange = function handleChange(value, option, index) {
46
+ var _value = props.value ? (0, _toConsumableArray2.default)(props.value) : [];
47
+ _value[index] = value;
48
+ _option.current[index] = option;
49
+ onChange(_value, _option.current);
50
+ };
51
+ var columns = (0, _react.useMemo)(function () {
52
+ var columnsProps = (0, _utils.transformColumns)({
53
+ columns: children,
54
+ name: name,
55
+ names: names,
56
+ onChange: handleChange,
57
+ namePath: namePath,
58
+ form: form,
59
+ index: index,
60
+ value: value,
61
+ groupProps: props
57
62
  });
58
- return {
59
- columns: (0, _utils.insertSeparator)(result, space, node, otherProps),
60
- fieldList: fieldList
61
- };
62
- }, [name, columns, space, props, names]);
63
+ return (0, _utils.insertSeparator)(columnsProps, space);
64
+ }, [name, value, children, space, names, namePath, index]);
63
65
  var _className = (0, _classnames2.default)((0, _defineProperty2.default)({
64
66
  'pro-group': true,
65
67
  'pro-group-diy-width': columns.some(function (item) {
@@ -70,44 +72,27 @@ var Group = function Group(props) {
70
72
  return ['Radio', 'Checkbox', 'Switch'].includes(item.type);
71
73
  })
72
74
  }, "".concat(className), className));
73
- // 用于formList场景下names移除掉了前缀,需要再次合并回来
74
- var _names = names.map(function (item) {
75
- if ((0, _lodash.isNumber)(item === null || item === void 0 ? void 0 : item[0])) {
76
- return (0, _lodash.union)(newNamePath, item);
77
- }
78
- return item;
79
- });
80
- (0, _ahooks.useDeepCompareEffect)(function () {
81
- var _document, _document$activeEleme;
82
- // 焦点激活的表单
83
- var touchName = ((_document = document) === null || _document === void 0 ? void 0 : (_document$activeEleme = _document.activeElement) === null || _document$activeEleme === void 0 ? void 0 : _document$activeEleme.id) || '';
84
- // 模拟change,初始化不执行onFieldChange
85
- if ((0, _lodash.isFunction)(onFieldChange) && form.isFieldsTouched(_names) && (0, _utils.transformNamesString)(_names).includes(touchName)) {
86
- onFieldChange(value, (newNamePath === null || newNamePath === void 0 ? void 0 : newNamePath.length) ? form.getFieldValue(newNamePath, true) : form.getFieldsValue(), {
87
- form: form,
88
- namePath: newNamePath,
89
- index: index
90
- });
91
- }
92
- }, [value]);
93
- var _otherProps = (0, _lodash.omit)(otherProps, ['colProps', 'required']);
94
75
  return (0, _jsxRuntime.jsx)("div", {
95
76
  className: _className,
96
77
  children: space.compact || (space === null || space === void 0 ? void 0 : space.separator) ? (0, _jsxRuntime.jsx)(_antd.Space.Compact, {
97
- children: (0, _jsxRuntime.jsx)(_RenderFields.default, (0, _objectSpread2.default)({
98
- columns: data.columns,
99
- form: form
100
- }, _otherProps))
78
+ children: columns.map(function (column) {
79
+ return (0, _jsxRuntime.jsx)(_ComRender.default, (0, _objectSpread2.default)((0, _objectSpread2.default)({
80
+ contextProps: contextProps
81
+ }, column), {}, {
82
+ otherProps: otherProps
83
+ }));
84
+ })
101
85
  }) : (0, _jsxRuntime.jsx)(_antd.Space, (0, _objectSpread2.default)((0, _objectSpread2.default)({
102
86
  align: "start"
103
87
  }, (0, _lodash.omit)(space, ['separator', 'compact'])), {}, {
104
- children: data.columns.map(function (column, index) {
105
- return (0, _jsxRuntime.jsx)(_RenderFields.default, (0, _objectSpread2.default)({
106
- columns: [column],
107
- form: form
108
- }, _otherProps), (column === null || column === void 0 ? void 0 : column.name) || index);
88
+ children: columns.map(function (column, index) {
89
+ return (0, _jsxRuntime.jsx)(_ComRender.default, (0, _objectSpread2.default)((0, _objectSpread2.default)({
90
+ contextProps: contextProps
91
+ }, column), {}, {
92
+ otherProps: otherProps
93
+ }));
109
94
  })
110
95
  }))
111
96
  });
112
97
  };
113
- var _default = exports.default = Group;
98
+ var _default = exports.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 {};
@@ -4,35 +4,35 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.transformNamesString = exports.insertSeparator = void 0;
7
+ exports.defaultGetValueFromEvent = defaultGetValueFromEvent;
8
+ exports.transformNamesString = exports.transformColumns = exports.isUpperCase = exports.insertSeparator = exports.getValueTypeTrans = exports.getValueMiddleware = exports.getReactiveProps = void 0;
8
9
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
10
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
12
+ var _jsxRuntime = require("react/jsx-runtime");
13
+ var _lodash = require("lodash");
14
+ var _antd = require("antd");
15
+ var _valueType = _interopRequireDefault(require("../../../utils/valueType"));
16
+ var _useDeepCompareMemo = require("../../../utils/useDeepCompareMemo");
9
17
  /**
10
- * 插入间隔符
11
- * @param columns 表单配置数组
12
- * @returns
13
- */
14
- var insertSeparator = exports.insertSeparator = function insertSeparator(columns, space, separatorNode, otherProps) {
15
- var _columns = columns;
16
- var _ref = otherProps || {},
17
- names = _ref.names;
18
- // 紧凑模式存在names时,自动给下级拆解name
19
- if (names) {
20
- _columns = _columns.map(function (column, index) {
21
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, column), {}, {
22
- name: names[index]
23
- });
24
- });
25
- }
18
+ * 插入间隔符
19
+ * @param columns 表单配置数组
20
+ * @returns
21
+ */
22
+ var insertSeparator = exports.insertSeparator = function insertSeparator(columns, space) {
26
23
  if (!(space === null || space === void 0 ? void 0 : space.separator)) {
27
- return _columns;
24
+ return columns;
28
25
  }
29
- return _columns.reduce(function (result, current, index, array) {
26
+ return columns.reduce(function (result, current, index, array) {
30
27
  // 将当前元素添加到结果数组中
31
28
  result.push(current);
32
29
  // 如果当前元素不是最后一个元素,则添加间隔符
33
30
  if (index < array.length - 1) {
34
31
  result.push({
35
- component: separatorNode,
32
+ component: (0, _jsxRuntime.jsx)(_antd.Button, {
33
+ className: "group-separator",
34
+ children: space.separator
35
+ }),
36
36
  fieldProps: {
37
37
  disabled: true
38
38
  }
@@ -41,6 +41,14 @@ var insertSeparator = exports.insertSeparator = function insertSeparator(columns
41
41
  return result;
42
42
  }, []);
43
43
  };
44
+ /** 带出event的组件默认取值方法 */
45
+ function defaultGetValueFromEvent(valuePropName) {
46
+ var event = arguments.length <= 1 ? undefined : arguments[1];
47
+ if (event && event.target && (0, _typeof2.default)(event.target) === 'object' && valuePropName in event.target) {
48
+ return event.target[valuePropName];
49
+ }
50
+ return event;
51
+ }
44
52
  /** 转换names */
45
53
  var transformNamesString = exports.transformNamesString = function transformNamesString(arr) {
46
54
  var result = arr.map(function (subArr) {
@@ -50,4 +58,186 @@ var transformNamesString = exports.transformNamesString = function transformName
50
58
  return subArr;
51
59
  });
52
60
  return result;
61
+ };
62
+ /**
63
+ * Input TextArea 小写自动转大写
64
+ * @param type 组件类型
65
+ * @param upperCase 是否小写转大写
66
+ * @returns {}
67
+ */
68
+ var isUpperCase = exports.isUpperCase = function isUpperCase(type, upperCase) {
69
+ var result = {};
70
+ if (['Input', 'TextArea', 'ProCombination'].includes(type) && upperCase) {
71
+ result.getValueFromEvent = function (event) {
72
+ var _event$target, _event$target$value;
73
+ if (Array.isArray(event)) {
74
+ return event.map(function (value) {
75
+ var newValue = value === null || value === void 0 ? void 0 : value.replace(/[^a-zA-Z]/g, '');
76
+ return (newValue === null || newValue === void 0 ? void 0 : newValue.toUpperCase()) || '';
77
+ });
78
+ }
79
+ 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, '');
80
+ return newValue.toUpperCase() || '';
81
+ };
82
+ }
83
+ return result;
84
+ };
85
+ /** 计算响应式参数的值 */
86
+ var getReactiveProps = exports.getReactiveProps = function getReactiveProps(params) {
87
+ var form = params.form,
88
+ index = params.index,
89
+ namePath = params.namePath,
90
+ disabled = params.disabled,
91
+ show = params.show,
92
+ component = params.component,
93
+ fieldProps = params.fieldProps,
94
+ name = params.name;
95
+ var values = form.getFieldsValue(namePath || undefined);
96
+ var _disabled = (0, _lodash.isFunction)(disabled) ? disabled(values, {
97
+ form: form,
98
+ index: index,
99
+ namePath: namePath
100
+ }) : disabled;
101
+ var _show = (0, _lodash.isFunction)(show) ? show(values, {
102
+ form: form,
103
+ index: index,
104
+ namePath: namePath
105
+ }) : show;
106
+ var _component = (0, _lodash.isFunction)(component) ? component(values, {
107
+ form: form,
108
+ index: index,
109
+ namePath: namePath
110
+ }) : component;
111
+ var _fieldProps = (0, _lodash.isFunction)(fieldProps) ? fieldProps(values, {
112
+ form: form,
113
+ index: index,
114
+ namePath: namePath
115
+ }) : fieldProps;
116
+ return {
117
+ disabled: _disabled,
118
+ show: _show,
119
+ component: _component,
120
+ fieldProps: _fieldProps
121
+ };
122
+ };
123
+ /** 获取当前字段的转换函数 */
124
+ var getValueTypeTrans = exports.getValueTypeTrans = function getValueTypeTrans(params) {
125
+ var _valueTypeMap$valueTy;
126
+ var valueType = params.valueType;
127
+ var transform = (_valueTypeMap$valueTy = _valueType.default[valueType]) === null || _valueTypeMap$valueTy === void 0 ? void 0 : _valueTypeMap$valueTy.call(_valueType.default, params);
128
+ return transform;
129
+ };
130
+ var getTrim = function getTrim(value) {
131
+ return (value === null || value === void 0 ? void 0 : value.trim()) || '';
132
+ };
133
+ var getUpperCase = function getUpperCase(value) {
134
+ var _value = value === null || value === void 0 ? void 0 : value.replace(/[^a-zA-Z]/g, '');
135
+ return _value.toUpperCase() || '';
136
+ };
137
+ /** 执行所有中间件 返回处理后的值 */
138
+ var getValueMiddleware = exports.getValueMiddleware = function getValueMiddleware(value) {
139
+ var callbacks = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
140
+ return callbacks.reduce(function (preValue, cb) {
141
+ return cb === null || cb === void 0 ? void 0 : cb(preValue);
142
+ }, value);
143
+ };
144
+ /** 获取中间件处理后的value */
145
+ var valueFromEventWrapper = function valueFromEventWrapper(column, args) {
146
+ var getValueFromEvent = column.getValueFromEvent,
147
+ _column$valuePropName = column.valuePropName,
148
+ valuePropName = _column$valuePropName === void 0 ? 'value' : _column$valuePropName,
149
+ trim = column.trim,
150
+ upperCase = column.upperCase;
151
+ var newValue;
152
+ if (getValueFromEvent) {
153
+ newValue = getValueFromEvent.apply(void 0, (0, _toConsumableArray2.default)(args));
154
+ } else {
155
+ newValue = defaultGetValueFromEvent.apply(void 0, [valuePropName].concat((0, _toConsumableArray2.default)(args)));
156
+ }
157
+ var list = [];
158
+ if (trim) list.push(getTrim);
159
+ if (upperCase) list.push(getUpperCase);
160
+ return getValueMiddleware(newValue, list);
161
+ };
162
+ /** 转换columns */
163
+ var transformColumns = exports.transformColumns = function transformColumns(params) {
164
+ var form = params.form,
165
+ columns = params.columns,
166
+ name = params.name,
167
+ names = params.names,
168
+ outerIndex = params.index,
169
+ namePath = params.namePath,
170
+ value = params.value,
171
+ internalChange = params.onChange,
172
+ groupProps = params.groupProps;
173
+ return columns === null || columns === void 0 ? void 0 : columns.flatMap(function (column, index) {
174
+ var type = column.type,
175
+ valueType = column.valueType,
176
+ switchValue = column.switchValue,
177
+ toISOString = column.toISOString,
178
+ fieldProps = column.fieldProps,
179
+ normalize = column.normalize,
180
+ disabled = column.disabled,
181
+ show = column.show,
182
+ component = column.component;
183
+ var _ref = fieldProps || {},
184
+ mode = _ref.mode,
185
+ onChange = _ref.onChange,
186
+ onFieldChange = _ref.onFieldChange,
187
+ comDisabled = _ref.disabled;
188
+ var _disabled = disabled || comDisabled;
189
+ var columnName = names ? names[index] : [].concat(name, index);
190
+ // 响应式字段
191
+ var reactiveProps = (0, _useDeepCompareMemo.useDeepCompareMemo)(function () {
192
+ return getReactiveProps({
193
+ form: form,
194
+ index: index,
195
+ type: type,
196
+ namePath: namePath,
197
+ disabled: _disabled,
198
+ show: show,
199
+ component: component,
200
+ fieldProps: fieldProps,
201
+ name: columnName
202
+ });
203
+ }, [value, show, fieldProps, columnName, type]);
204
+ if (reactiveProps.show === false) {
205
+ return [];
206
+ }
207
+ var transform = getValueTypeTrans({
208
+ type: type,
209
+ valueType: valueType,
210
+ switchValue: switchValue,
211
+ toISOString: toISOString,
212
+ mode: mode
213
+ });
214
+ var newValue;
215
+ var handleChange = function handleChange() {
216
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
217
+ args[_key] = arguments[_key];
218
+ }
219
+ newValue = valueFromEventWrapper(column, args);
220
+ if ((transform === null || transform === void 0 ? void 0 : transform.normalize) || normalize) {
221
+ var _transform$normalize;
222
+ // @ts-ignore
223
+ 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));
224
+ }
225
+ internalChange === null || internalChange === void 0 ? void 0 : internalChange(newValue, args[1], index);
226
+ onChange === null || onChange === void 0 ? void 0 : onChange.apply(void 0, args);
227
+ onFieldChange === null || onFieldChange === void 0 ? void 0 : onFieldChange(newValue, form.getFieldValue(namePath), {
228
+ index: outerIndex,
229
+ namePath: namePath,
230
+ form: form
231
+ });
232
+ };
233
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, column), {}, {
234
+ name: columnName
235
+ }, reactiveProps), {}, {
236
+ disabled: reactiveProps.disabled || groupProps.disabled,
237
+ fieldProps: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, column === null || column === void 0 ? void 0 : column.fieldProps), {}, {
238
+ onChange: handleChange,
239
+ value: value === null || value === void 0 ? void 0 : value[index]
240
+ })
241
+ });
242
+ });
53
243
  };