@teamix/pro 1.3.13 → 1.3.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/dist/pro.css +1 -1
  2. package/dist/pro.js +5531 -720
  3. package/dist/pro.min.css +1 -1
  4. package/dist/pro.min.js +1 -1
  5. package/es/actions/index.js +40 -4
  6. package/es/actions/index.scss +13 -0
  7. package/es/form/Filter/LightFilter.js +7 -5
  8. package/es/form/Filter/index.js +171 -55
  9. package/es/form/Filter/layout.scss +4 -0
  10. package/es/form/Filter/useBindUrl.d.ts +2 -0
  11. package/es/form/Filter/useBindUrl.js +118 -0
  12. package/es/form/ProForm/index.d.ts +2 -3
  13. package/es/form/ProForm/index.js +51 -10
  14. package/es/form/ProForm/index.scss +7 -0
  15. package/es/form/ProForm/useFieldSchema.d.ts +7 -0
  16. package/es/form/ProForm/useFieldSchema.js +109 -0
  17. package/es/form/SchemaForm/index.js +2 -38
  18. package/es/form/SchemaForm/initializeDataSource.d.ts +1 -2
  19. package/es/form/SchemaForm/initializeDataSource.js +14 -19
  20. package/es/form/SchemaForm/initializeRequest.js +25 -26
  21. package/es/form/SchemaForm/initializeRules.d.ts +2 -2
  22. package/es/form/SchemaForm/initializeRules.js +30 -23
  23. package/es/form/SchemaForm/initializeSelectTable.js +80 -6
  24. package/es/form/SchemaForm/reactions.d.ts +4 -4
  25. package/es/form/SchemaForm/reactions.js +30 -23
  26. package/es/form/typing.d.ts +16 -6
  27. package/es/form/utils.d.ts +16 -1
  28. package/es/form/utils.js +21 -2
  29. package/es/global.scss +45 -0
  30. package/es/index.d.ts +2 -1
  31. package/es/index.js +3 -2
  32. package/es/page-header/index.d.ts +2 -0
  33. package/es/page-header/index.js +13 -3
  34. package/es/page-header/index.scss +8 -0
  35. package/es/table/components/Layout/index.scss +5 -5
  36. package/es/table/components/ToolBar/Fullscreen.d.ts +1 -1
  37. package/es/table/utils/pureColumnRender.d.ts +9 -0
  38. package/es/table/utils/pureColumnRender.js +201 -0
  39. package/es/table/utils/pureGenProColumnToColumn.d.ts +7 -0
  40. package/es/table/utils/pureGenProColumnToColumn.js +36 -0
  41. package/es/timeline/ProTimeLineItem/index.js +8 -5
  42. package/es/timeline/typing.d.ts +5 -0
  43. package/lib/actions/index.js +40 -4
  44. package/lib/actions/index.scss +13 -0
  45. package/lib/form/Filter/LightFilter.js +7 -6
  46. package/lib/form/Filter/index.js +172 -55
  47. package/lib/form/Filter/layout.scss +4 -0
  48. package/lib/form/Filter/useBindUrl.d.ts +2 -0
  49. package/lib/form/Filter/useBindUrl.js +129 -0
  50. package/lib/form/ProForm/index.d.ts +2 -3
  51. package/lib/form/ProForm/index.js +57 -9
  52. package/lib/form/ProForm/index.scss +7 -0
  53. package/lib/form/ProForm/useFieldSchema.d.ts +7 -0
  54. package/lib/form/ProForm/useFieldSchema.js +118 -0
  55. package/lib/form/SchemaForm/index.js +2 -45
  56. package/lib/form/SchemaForm/initializeDataSource.d.ts +1 -2
  57. package/lib/form/SchemaForm/initializeDataSource.js +14 -19
  58. package/lib/form/SchemaForm/initializeRequest.js +26 -26
  59. package/lib/form/SchemaForm/initializeRules.d.ts +2 -2
  60. package/lib/form/SchemaForm/initializeRules.js +30 -22
  61. package/lib/form/SchemaForm/initializeSelectTable.js +85 -6
  62. package/lib/form/SchemaForm/reactions.d.ts +4 -4
  63. package/lib/form/SchemaForm/reactions.js +30 -23
  64. package/lib/form/typing.d.ts +16 -6
  65. package/lib/form/utils.d.ts +16 -1
  66. package/lib/form/utils.js +23 -2
  67. package/lib/global.scss +45 -0
  68. package/lib/index.d.ts +2 -1
  69. package/lib/index.js +3 -1
  70. package/lib/page-header/index.d.ts +2 -0
  71. package/lib/page-header/index.js +12 -2
  72. package/lib/page-header/index.scss +8 -0
  73. package/lib/table/components/Layout/index.scss +5 -5
  74. package/lib/table/components/ToolBar/Fullscreen.d.ts +1 -1
  75. package/lib/table/utils/pureColumnRender.d.ts +9 -0
  76. package/lib/table/utils/pureColumnRender.js +215 -0
  77. package/lib/table/utils/pureGenProColumnToColumn.d.ts +7 -0
  78. package/lib/table/utils/pureGenProColumnToColumn.js +43 -0
  79. package/lib/timeline/ProTimeLineItem/index.js +8 -5
  80. package/lib/timeline/typing.d.ts +5 -0
  81. package/package.json +1 -1
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _hooks = require("@teamix/hooks");
9
+
10
+ var _utils = require("@teamix/utils");
11
+
12
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
13
+
14
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
15
+
16
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
17
+
18
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
19
+
20
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
21
+
22
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
23
+
24
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
25
+
26
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
27
+
28
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
29
+
30
+ var _default = function _default(bindUrl, functions, formRef) {
31
+ // 预处理 bindUrl 参数(主要兼容 SelectGroup 组件)
32
+ var initializeBindUrl = function initializeBindUrl(options) {
33
+ return options ? _objectSpread(_objectSpread({}, options), {}, {
34
+ beforeStringify: function beforeStringify(values) {
35
+ var _Object$entries;
36
+
37
+ var beforeStringify = options.beforeStringify;
38
+
39
+ var newValues = _objectSpread({}, values);
40
+
41
+ (_Object$entries = Object.entries(values)) === null || _Object$entries === void 0 ? void 0 : _Object$entries.forEach(function (_ref) {
42
+ var _form$query;
43
+
44
+ var _ref2 = _slicedToArray(_ref, 2),
45
+ key = _ref2[0],
46
+ value = _ref2[1];
47
+
48
+ var form = formRef.current;
49
+ var field = (_form$query = form.query(key)) === null || _form$query === void 0 ? void 0 : _form$query.take();
50
+
51
+ if ((field === null || field === void 0 ? void 0 : field.component[0]) === 'SelectGroup') {
52
+ newValues[key] = value.map(function (_ref3) {
53
+ var key = _ref3.key,
54
+ value = _ref3.value;
55
+ return key && value ? "".concat(key, "||").concat(value === null || value === void 0 ? void 0 : value.join('|')) : '';
56
+ });
57
+ }
58
+ });
59
+ return beforeStringify ? beforeStringify(newValues) : newValues;
60
+ }
61
+ }) : options;
62
+ }; // 通过 useUrlState 获取 url 上的参数和 url 配置方法
63
+
64
+
65
+ var _useUrlState = (0, _hooks.useUrlState)(undefined, initializeBindUrl(bindUrl)),
66
+ _useUrlState2 = _slicedToArray(_useUrlState, 2),
67
+ urlState = _useUrlState2[0],
68
+ setUrlState = _useUrlState2[1]; // 输出配置url参数的函数
69
+
70
+
71
+ var initializedFunctions = Object.entries(functions).reduce(function (prev, _ref4) {
72
+ var _ref5 = _slicedToArray(_ref4, 2),
73
+ key = _ref5[0],
74
+ fun = _ref5[1];
75
+
76
+ prev[key] = function (values) {
77
+ fun === null || fun === void 0 ? void 0 : fun(values);
78
+ setUrlState(values);
79
+ };
80
+
81
+ return prev;
82
+ }, {}); // 使用 url 参数配置 QueryFilter 默认值(移除非表单值,兼容数组数据,兼容 SelectGroup 组件)
83
+
84
+ var setValuesByUrlState = function setValuesByUrlState(form) {
85
+ if (urlState) {
86
+ var _Object$entries2;
87
+
88
+ (_Object$entries2 = Object.entries(urlState)) === null || _Object$entries2 === void 0 ? void 0 : _Object$entries2.forEach(function (_ref6) {
89
+ var _form$query2;
90
+
91
+ var _ref7 = _slicedToArray(_ref6, 2),
92
+ key = _ref7[0],
93
+ value = _ref7[1];
94
+
95
+ var field = (_form$query2 = form.query(key)) === null || _form$query2 === void 0 ? void 0 : _form$query2.take();
96
+
97
+ if (field) {
98
+ var newValue = value;
99
+
100
+ if (field.displayName === 'ArrayField') {
101
+ newValue = [].concat((0, _utils.isUsable)(newValue) ? newValue : []);
102
+ }
103
+
104
+ if (field.component[0] === 'SelectGroup') {
105
+ newValue = newValue.map(function (item) {
106
+ var _item$split = item === null || item === void 0 ? void 0 : item.split('||'),
107
+ _item$split2 = _slicedToArray(_item$split, 2),
108
+ key = _item$split2[0],
109
+ value = _item$split2[1];
110
+
111
+ return {
112
+ key: key,
113
+ value: value === null || value === void 0 ? void 0 : value.split('|')
114
+ };
115
+ });
116
+ }
117
+
118
+ form.setValuesIn(key, newValue);
119
+ }
120
+ });
121
+ }
122
+ };
123
+
124
+ return _objectSpread({
125
+ setValuesByUrlState: setValuesByUrlState
126
+ }, initializedFunctions);
127
+ };
128
+
129
+ exports.default = _default;
@@ -1,5 +1,4 @@
1
- import React from 'react';
2
- import type { ProFormProps } from '../typing';
1
+ import type { ComposedProForm } from '../typing';
3
2
  import './index.scss';
4
- declare const ProForm: React.FC<ProFormProps>;
3
+ declare const ProForm: ComposedProForm;
5
4
  export default ProForm;
@@ -11,13 +11,25 @@ var _react = _interopRequireWildcard(require("react"));
11
11
 
12
12
  var _classnames = _interopRequireDefault(require("classnames"));
13
13
 
14
+ var _utils = require("@teamix/utils");
15
+
14
16
  var _core = require("@formily/core");
15
17
 
16
18
  var _reactive = require("@formily/reactive");
17
19
 
18
20
  var _formily = require("@teamix/formily");
19
21
 
20
- var _utils = require("@teamix/utils");
22
+ var _components = require("@alicloudfe/components");
23
+
24
+ var _ProField = _interopRequireDefault(require("../Components/ProField"));
25
+
26
+ var _Editable = require("../Components/Editable");
27
+
28
+ var _FormGroup = _interopRequireDefault(require("../Components/FormGroup"));
29
+
30
+ var _LightFilter = _interopRequireDefault(require("../Components/LightFilter"));
31
+
32
+ var _index = _interopRequireDefault(require("../Components/Text/index"));
21
33
 
22
34
  var _SchemaForm = _interopRequireDefault(require("../SchemaForm"));
23
35
 
@@ -27,11 +39,13 @@ var _useAutoSubmit = _interopRequireDefault(require("./useAutoSubmit"));
27
39
 
28
40
  var _useInitialRequest = _interopRequireDefault(require("./useInitialRequest"));
29
41
 
42
+ var _useFieldSchema = _interopRequireDefault(require("./useFieldSchema"));
43
+
30
44
  var _validate = _interopRequireDefault(require("../locales/validate"));
31
45
 
32
46
  require("./index.scss");
33
47
 
34
- var _excluded = ["form", "initialValues", "initialRequest", "schema", "scope", "context", "components", "children", "layout", "labelAlign", "wrapperAlign", "labelCol", "wrapperCol", "breakpoints", "onChange", "onChangeType", "onSubmit", "onSubmitFailed", "onInitialComplete", "className", "validateFirst"];
48
+ var _excluded = ["form", "initialValues", "initialRequest", "scope", "context", "components", "layout", "labelAlign", "wrapperAlign", "labelCol", "wrapperCol", "breakpoints", "onChange", "onChangeType", "onSubmit", "onSubmitFailed", "onInitialComplete", "className", "validateFirst"];
35
49
 
36
50
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
37
51
 
@@ -50,15 +64,41 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
50
64
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
51
65
 
52
66
  (0, _core.registerValidateLocale)(_validate.default);
67
+ var formilyComponents = {
68
+ FormLayout: _formily.FormLayout,
69
+ FormItem: _formily.FormItem,
70
+ ArrayCollapse: _formily.ArrayCollapse,
71
+ ArrayCards: _formily.ArrayCards,
72
+ ArrayItems: _formily.ArrayItems,
73
+ ArrayTable: _formily.ArrayTable,
74
+ Space: _formily.Space,
75
+ FormGrid: _formily.FormGrid,
76
+ FormTab: _formily.FormTab,
77
+ FormCollapse: _formily.FormCollapse,
78
+ FormStep: _formily.FormStep,
79
+ Editable: _formily.Editable,
80
+ FormDialogFooter: _formily.FormDialog.Footer,
81
+ FormDrawerFooter: _formily.FormDrawer.Footer,
82
+ FormButtonGroup: _formily.FormButtonGroup,
83
+ Submit: _formily.Submit,
84
+ Reset: _formily.Reset,
85
+ EditableDialog: _Editable.EditableDialog,
86
+ EditableDrawer: _Editable.EditableDrawer,
87
+ EditablePopover: _Editable.EditablePopover,
88
+ FormGroup: _FormGroup.default,
89
+ Upload: _formily.Upload,
90
+ SelectTable: _formily.SelectTable,
91
+ Affix: _components.Affix,
92
+ LightFilter: _LightFilter.default,
93
+ Text: _index.default
94
+ };
53
95
  var ProForm = /*#__PURE__*/(0, _react.memo)(function (_ref) {
54
96
  var outerForm = _ref.form,
55
97
  initialValues = _ref.initialValues,
56
98
  initialRequest = _ref.initialRequest,
57
- schema = _ref.schema,
58
99
  scope = _ref.scope,
59
100
  context = _ref.context,
60
101
  components = _ref.components,
61
- children = _ref.children,
62
102
  layout = _ref.layout,
63
103
  labelAlign = _ref.labelAlign,
64
104
  wrapperAlign = _ref.wrapperAlign,
@@ -93,9 +133,9 @@ var ProForm = /*#__PURE__*/(0, _react.memo)(function (_ref) {
93
133
  }); // context需要实名不能解构
94
134
 
95
135
 
96
- var mergedComponents = _objectSpread(_objectSpread({}, globalComponents), components);
136
+ var mergedComponents = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, globalComponents), components), formilyComponents), _ProField.default);
97
137
 
98
- var onAutoSubmit = (0, _useAutoSubmit.default)(onSubmit); // todo 需要formily支持断点下的属性更新
138
+ var onAutoSubmit = (0, _useAutoSubmit.default)(onSubmit, context); // todo 需要formily支持断点下的属性更新
99
139
 
100
140
  var getTeamixLayout = (0, _react.useMemo)(function () {
101
141
  return breakpoints ? {
@@ -114,12 +154,13 @@ var ProForm = /*#__PURE__*/(0, _react.memo)(function (_ref) {
114
154
  wrapperCol: (0, _utils2.mergeArrayValue)([24], wrapperCol)
115
155
  };
116
156
  }, [breakpoints, layout, labelAlign, wrapperAlign, labelCol, wrapperCol]);
157
+ var schema = (0, _useFieldSchema.default)(otherProps);
117
158
  (0, _react.useMemo)(function () {
118
159
  // 配置表单默认值
119
160
  if (initialValues) {
120
161
  form.setInitialValues(initialValues);
121
162
  } else if (initialRequest) {
122
- (0, _useInitialRequest.default)(initialRequest).then(function (values) {
163
+ (0, _useInitialRequest.default)(initialRequest, context).then(function (values) {
123
164
  form.setInitialValues(values);
124
165
  }).finally(function () {
125
166
  onInitialComplete === null || onInitialComplete === void 0 ? void 0 : onInitialComplete(form);
@@ -157,12 +198,19 @@ var ProForm = /*#__PURE__*/(0, _react.memo)(function (_ref) {
157
198
  form: form,
158
199
  onAutoSubmit: onAutoSubmit,
159
200
  onAutoSubmitFailed: onSubmitFailed
160
- }), /*#__PURE__*/_react.default.createElement(_SchemaForm.default, {
201
+ }), schema ? /*#__PURE__*/_react.default.createElement(_SchemaForm.default, {
161
202
  schema: schema,
162
203
  scope: mergedScope,
163
204
  components: mergedComponents
164
- }), children);
205
+ }) : null, otherProps === null || otherProps === void 0 ? void 0 : otherProps.children);
165
206
  });
207
+
208
+ var Field = function Field() {
209
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
210
+ };
211
+
212
+ Field.displayName = 'ProFormField';
213
+ ProForm.Field = Field;
166
214
  ProForm.defaultProps = {
167
215
  colon: false,
168
216
  labelAlign: 'left',
@@ -317,6 +317,13 @@
317
317
  }
318
318
  }
319
319
 
320
+ // SelectTable
321
+ .#{$teamix-pro-form}-select-table-column-tree
322
+ > .#{$css-prefix}table-cell-wrapper {
323
+ display: flex;
324
+ align-items: center;
325
+ }
326
+
320
327
  /* hack todo remove */
321
328
  .#{$form-item-cls}-control-content-component {
322
329
  .#{$teamix-pro-field}-tooltip.#{$teamix-pro-field}-checkbox {
@@ -0,0 +1,7 @@
1
+ declare const _default: ({ children, schema }: any) => any;
2
+ /**
3
+ * 获取 ProForm 的 schema 配置,通过合并 Field 字段 或者 schema 配置
4
+ * @param props ProForm 组件的 props
5
+ * @returns schema 配置
6
+ */
7
+ export default _default;
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _utils = require("@teamix/utils");
9
+
10
+ var _excluded = ["id", "children", "reactions"],
11
+ _excluded2 = ["id", "children", "reactions"];
12
+
13
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
14
+
15
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
16
+
17
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
18
+
19
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
20
+
21
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
22
+
23
+ /**
24
+ * 合并 Field 字段 props 和 ProForm schema 配置,生成完整的 Field 字段 schema
25
+ * @param field Field 字段
26
+ * @param extra 额外的 schema 配置(存在递归,可能是子级 schema )
27
+ * @param wholeExtra 完整的额外 schema 配置
28
+ * @returns schema 配置
29
+ */
30
+ var getMergedSchema = function getMergedSchema(field, extra, wholeExtra) {
31
+ return [].concat(field).reduce(function (prev, curr, index) {
32
+ var _curr$type;
33
+
34
+ var _ref = curr.props || {},
35
+ id = _ref.id,
36
+ _ref$children = _ref.children,
37
+ children = _ref$children === void 0 ? [] : _ref$children,
38
+ _ref$reactions = _ref.reactions,
39
+ reactions = _ref$reactions === void 0 ? [] : _ref$reactions,
40
+ rest = _objectWithoutProperties(_ref, _excluded);
41
+
42
+ var displayName = curr === null || curr === void 0 ? void 0 : (_curr$type = curr.type) === null || _curr$type === void 0 ? void 0 : _curr$type.displayName; // 自定义组件
43
+
44
+ var type = curr === null || curr === void 0 ? void 0 : curr.type; // 基本Dom元素
45
+
46
+ if (displayName === 'ProFormField') {
47
+ // 获取字段额外的 schema 配置(From ProForm)
48
+ var extraFieldProps = extra[index] || {};
49
+
50
+ if (id !== extraFieldProps.id) {
51
+ // 索引不匹配,通过 id 查找获取
52
+ extraFieldProps = (0, _utils.getValueByValue)(extra, id, {
53
+ inputKey: 'id',
54
+ outputKey: '__whole__'
55
+ }) || (0, _utils.getValueByValue)(wholeExtra, id, {
56
+ inputKey: 'id',
57
+ outputKey: '__whole__'
58
+ });
59
+
60
+ if (extraFieldProps) {
61
+ console.warn("Field id \"".concat(id, "\" is not found by index in ProForm schema props, Please pay attention to the order."));
62
+ }
63
+ }
64
+
65
+ var _ref2 = extraFieldProps || {},
66
+ extraId = _ref2.id,
67
+ _ref2$children = _ref2.children,
68
+ extraChildren = _ref2$children === void 0 ? [] : _ref2$children,
69
+ _ref2$reactions = _ref2.reactions,
70
+ extraReactions = _ref2$reactions === void 0 ? [] : _ref2$reactions,
71
+ extraRest = _objectWithoutProperties(_ref2, _excluded2);
72
+
73
+ var mergedReactions = [].concat(reactions, extraReactions);
74
+ var mergedChildren = children ? getMergedSchema(children, extraChildren, wholeExtra) : [];
75
+ prev.push(_objectSpread(_objectSpread(_objectSpread({}, (0, _utils.deepMerge)(rest, extraRest)), mergedReactions.length && {
76
+ reactions: mergedReactions
77
+ }), mergedChildren.length && {
78
+ children: mergedChildren
79
+ }));
80
+ } else if ((0, _utils.isStr)(type)) {
81
+ prev.push({
82
+ component: type,
83
+ props: curr.props
84
+ });
85
+ } else if ((0, _utils.isStr)(displayName)) {
86
+ prev.push({
87
+ decorator: displayName,
88
+ decoratorProps: _objectSpread({
89
+ id: id
90
+ }, rest),
91
+ children: children ? getMergedSchema(children, [], wholeExtra) : []
92
+ });
93
+ }
94
+
95
+ return prev;
96
+ }, []);
97
+ };
98
+ /**
99
+ * 获取 ProForm 的 schema 配置,通过合并 Field 字段 或者 schema 配置
100
+ * @param props ProForm 组件的 props
101
+ * @returns schema 配置
102
+ */
103
+
104
+
105
+ var _default = function _default(_ref3) {
106
+ var children = _ref3.children,
107
+ schema = _ref3.schema;
108
+ var field = [].concat(children !== null && children !== void 0 ? children : []); // 如果 ProForm 的 children 含有 Field 字段,则优先使用 Field 渲染表单(仅合并 ProForm 的 schema 属性 )
109
+
110
+ if (field.length) {
111
+ return getMergedSchema(field, schema !== null && schema !== void 0 ? schema : [], schema !== null && schema !== void 0 ? schema : []);
112
+ } // 正常使用 ProForm 的 schema 渲染表单
113
+
114
+
115
+ return schema;
116
+ };
117
+
118
+ exports.default = _default;
@@ -11,20 +11,6 @@ var _react = _interopRequireWildcard(require("react"));
11
11
 
12
12
  var _react2 = require("@formily/react");
13
13
 
14
- var _components = require("@alicloudfe/components");
15
-
16
- var _formily = require("@teamix/formily");
17
-
18
- var _ProField = _interopRequireDefault(require("../Components/ProField"));
19
-
20
- var _Editable = require("../Components/Editable");
21
-
22
- var _FormGroup = _interopRequireDefault(require("../Components/FormGroup"));
23
-
24
- var _LightFilter = _interopRequireDefault(require("../Components/LightFilter"));
25
-
26
- var _index = _interopRequireDefault(require("../Components/Text/index"));
27
-
28
14
  var _adapterType = _interopRequireDefault(require("./adapterType"));
29
15
 
30
16
  var _adapterComponent = _interopRequireDefault(require("./adapterComponent"));
@@ -109,39 +95,10 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref) {
109
95
  var schema = _ref.schema,
110
96
  scope = _ref.scope,
111
97
  components = _ref.components;
112
- var schemaScopeRef = (0, _react.useRef)({}); // 创建 SchemaField,添加内置组件
98
+ var schemaScopeRef = (0, _react.useRef)({}); // 创建 SchemaField
113
99
 
114
100
  var SchemaField = (0, _react.useMemo)(function () {
115
- return (0, _react2.createSchemaField)({
116
- components: _objectSpread(_objectSpread({}, _ProField.default), {}, {
117
- FormLayout: _formily.FormLayout,
118
- FormItem: _formily.FormItem,
119
- ArrayCollapse: _formily.ArrayCollapse,
120
- ArrayCards: _formily.ArrayCards,
121
- ArrayItems: _formily.ArrayItems,
122
- ArrayTable: _formily.ArrayTable,
123
- Space: _formily.Space,
124
- FormGrid: _formily.FormGrid,
125
- FormTab: _formily.FormTab,
126
- FormCollapse: _formily.FormCollapse,
127
- FormStep: _formily.FormStep,
128
- Editable: _formily.Editable,
129
- FormDialogFooter: _formily.FormDialog.Footer,
130
- FormDrawerFooter: _formily.FormDrawer.Footer,
131
- FormButtonGroup: _formily.FormButtonGroup,
132
- Submit: _formily.Submit,
133
- Reset: _formily.Reset,
134
- EditableDialog: _Editable.EditableDialog,
135
- EditableDrawer: _Editable.EditableDrawer,
136
- EditablePopover: _Editable.EditablePopover,
137
- FormGroup: _FormGroup.default,
138
- Upload: _formily.Upload,
139
- SelectTable: _formily.SelectTable,
140
- Affix: _components.Affix,
141
- LightFilter: _LightFilter.default,
142
- Text: _index.default
143
- })
144
- });
101
+ return (0, _react2.createSchemaField)();
145
102
  }, []); // 格式化 schema
146
103
 
147
104
  var formatSchema = (0, _react.useCallback)(function (schema) {
@@ -1,6 +1,5 @@
1
- import type { ProFormRequestConfig } from '../typing';
2
1
  interface IInitializeDataSource {
3
- (requestConfig?: ProFormRequestConfig | any, suffix?: string): {
2
+ (requestConfig: any, suffix: string): {
4
3
  dataSource?: any[];
5
4
  reactions: any[];
6
5
  scope: {
@@ -5,30 +5,25 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _utils = require("@teamix/utils");
9
-
10
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
+ var _utils = require("../utils");
11
9
 
12
10
  var initializeDataSource = function initializeDataSource(dataSource, suffix) {
13
- if ((0, _utils.isPlainObj)(dataSource)) {
14
- var _requestConfig$extraC;
11
+ var _dataSource$extraConf;
15
12
 
16
- var requestConfig = dataSource;
17
- var requestConfigName = "$requestConfig_".concat(suffix);
18
- return {
19
- reactions: ["{{$dataSource($request,".concat(requestConfigName, ",context)}}")],
20
- scope: _defineProperty({}, requestConfigName, requestConfig),
21
- // dataSource请求时,默认配置字段为只读
22
- data: {
23
- readOnlyOnLoading: (requestConfig === null || requestConfig === void 0 ? void 0 : (_requestConfig$extraC = requestConfig.extraConfig) === null || _requestConfig$extraC === void 0 ? void 0 : _requestConfig$extraC.readOnly) !== false
24
- }
25
- };
26
- }
13
+ var _initializeRequestExp = (0, _utils.initializeRequestExpression)(dataSource, '$dataSource', suffix),
14
+ expression = _initializeRequestExp.expression,
15
+ scope = _initializeRequestExp.scope;
27
16
 
28
- return {
29
- dataSource: dataSource,
17
+ return expression ? {
18
+ reactions: [expression],
19
+ scope: scope,
20
+ data: {
21
+ readOnlyOnLoading: (dataSource === null || dataSource === void 0 ? void 0 : (_dataSource$extraConf = dataSource.extraConfig) === null || _dataSource$extraConf === void 0 ? void 0 : _dataSource$extraConf.readOnly) !== false
22
+ }
23
+ } : {
30
24
  reactions: [],
31
- scope: {}
25
+ scope: {},
26
+ dataSource: dataSource
32
27
  };
33
28
  };
34
29
 
@@ -7,6 +7,8 @@ exports.default = void 0;
7
7
 
8
8
  var _utils = require("@teamix/utils");
9
9
 
10
+ var _utils2 = require("../utils");
11
+
10
12
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
11
13
 
12
14
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -25,37 +27,35 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
25
27
 
26
28
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
27
29
 
28
- var initializeRequest = function initializeRequest(requestConfig, suffix) {
29
- if (requestConfig) {
30
- if ((0, _utils.isArr)(requestConfig)) {
31
- var reactionsMap = [];
32
- var scopeMap = {};
33
- requestConfig.forEach(function (item, index) {
34
- var _initializeRequest = initializeRequest(item, "".concat(suffix).concat(index)),
35
- reactions = _initializeRequest.reactions,
36
- scope = _initializeRequest.scope;
37
-
38
- reactionsMap = [].concat(_toConsumableArray(reactionsMap), _toConsumableArray(reactions));
39
- scopeMap = _objectSpread(_objectSpread({}, scopeMap), scope);
40
- });
41
- return {
42
- reactions: reactionsMap,
43
- scope: scopeMap
44
- };
45
- } else {
46
- var requestConfigName = "$requestConfig_".concat(suffix);
47
- return {
48
- reactions: ["{{$common($request,".concat(requestConfigName, ",context)}}")],
49
- scope: _defineProperty({}, requestConfigName, requestConfig)
50
- };
51
- }
52
- }
30
+ var initializeItem = function initializeItem(request, suffix) {
31
+ var _initializeRequestExp = (0, _utils2.initializeRequestExpression)(request, '$common', suffix),
32
+ expression = _initializeRequestExp.expression,
33
+ scope = _initializeRequestExp.scope;
53
34
 
54
- return {
35
+ return expression ? {
36
+ reactions: [expression],
37
+ scope: scope
38
+ } : {
55
39
  reactions: [],
56
40
  scope: {}
57
41
  };
58
42
  };
59
43
 
44
+ var initializeRequest = function initializeRequest(request, suffix) {
45
+ if ((0, _utils.isArr)(request)) {
46
+ return request.reduce(function (prev, current, index) {
47
+ var result = initializeItem(current, "".concat(suffix, "_").concat(index));
48
+ prev.reactions = [].concat(_toConsumableArray(prev.reactions), _toConsumableArray(result.reactions));
49
+ prev.scope = _objectSpread(_objectSpread({}, prev.scope), result.scope);
50
+ return prev;
51
+ }, {
52
+ reactions: [],
53
+ scope: {}
54
+ });
55
+ }
56
+
57
+ return initializeItem(request, suffix);
58
+ };
59
+
60
60
  var _default = initializeRequest;
61
61
  exports.default = _default;
@@ -1,7 +1,7 @@
1
1
  interface IInitializeRules {
2
- (rules?: any, suffix?: string): {
2
+ (rules: any, suffix: string): {
3
3
  rules?: any;
4
- reactions: any[];
4
+ reactions?: any[];
5
5
  scope: {
6
6
  [x: string]: any;
7
7
  };