@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
@@ -1,4 +1,4 @@
1
- var _excluded = ["form", "initialValues", "initialRequest", "schema", "scope", "context", "components", "children", "layout", "labelAlign", "wrapperAlign", "labelCol", "wrapperCol", "breakpoints", "onChange", "onChangeType", "onSubmit", "onSubmitFailed", "onInitialComplete", "className", "validateFirst"];
1
+ var _excluded = ["form", "initialValues", "initialRequest", "scope", "context", "components", "layout", "labelAlign", "wrapperAlign", "labelCol", "wrapperCol", "breakpoints", "onChange", "onChangeType", "onSubmit", "onSubmitFailed", "onInitialComplete", "className", "validateFirst"];
2
2
 
3
3
  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; }
4
4
 
@@ -12,26 +12,59 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
12
12
 
13
13
  import React, { memo, useMemo } from 'react';
14
14
  import cls from 'classnames';
15
+ import { usePrefixCls, getLanguage, getGlobalConfig } from '@teamix/utils';
15
16
  import { createForm, onFieldValueChange, onFormValuesChange, registerValidateLocale, setValidateLanguage } from '@formily/core';
16
17
  import { toJS } from '@formily/reactive';
17
- import { Form } from '@teamix/formily';
18
- import { usePrefixCls, getLanguage, getGlobalConfig } from '@teamix/utils';
18
+ import { Form, Upload, SelectTable, FormLayout, FormItem, ArrayCollapse, ArrayCards, ArrayItems, ArrayTable, Space, FormGrid, FormTab, FormCollapse, FormStep, Editable, FormDialog, FormDrawer, FormButtonGroup, Submit, Reset } from '@teamix/formily';
19
+ import { Affix } from '@alicloudfe/components';
20
+ import ProFieldComponents from '../Components/ProField';
21
+ import { EditableDialog, EditableDrawer, EditablePopover } from '../Components/Editable';
22
+ import FormGroup from '../Components/FormGroup';
23
+ import LightFilter from '../Components/LightFilter';
24
+ import Text from '../Components/Text/index';
19
25
  import SchemaForm from '../SchemaForm';
20
26
  import { mergeArrayValue } from '../utils';
21
27
  import useAutoSubmit from './useAutoSubmit';
22
28
  import useInitialRequest from './useInitialRequest';
29
+ import useFieldSchema from './useFieldSchema';
23
30
  import validateLocale from '../locales/validate';
24
31
  import './index.scss';
25
32
  registerValidateLocale(validateLocale);
33
+ var formilyComponents = {
34
+ FormLayout: FormLayout,
35
+ FormItem: FormItem,
36
+ ArrayCollapse: ArrayCollapse,
37
+ ArrayCards: ArrayCards,
38
+ ArrayItems: ArrayItems,
39
+ ArrayTable: ArrayTable,
40
+ Space: Space,
41
+ FormGrid: FormGrid,
42
+ FormTab: FormTab,
43
+ FormCollapse: FormCollapse,
44
+ FormStep: FormStep,
45
+ Editable: Editable,
46
+ FormDialogFooter: FormDialog.Footer,
47
+ FormDrawerFooter: FormDrawer.Footer,
48
+ FormButtonGroup: FormButtonGroup,
49
+ Submit: Submit,
50
+ Reset: Reset,
51
+ EditableDialog: EditableDialog,
52
+ EditableDrawer: EditableDrawer,
53
+ EditablePopover: EditablePopover,
54
+ FormGroup: FormGroup,
55
+ Upload: Upload,
56
+ SelectTable: SelectTable,
57
+ Affix: Affix,
58
+ LightFilter: LightFilter,
59
+ Text: Text
60
+ };
26
61
  var ProForm = /*#__PURE__*/memo(function (_ref) {
27
62
  var outerForm = _ref.form,
28
63
  initialValues = _ref.initialValues,
29
64
  initialRequest = _ref.initialRequest,
30
- schema = _ref.schema,
31
65
  scope = _ref.scope,
32
66
  context = _ref.context,
33
67
  components = _ref.components,
34
- children = _ref.children,
35
68
  layout = _ref.layout,
36
69
  labelAlign = _ref.labelAlign,
37
70
  wrapperAlign = _ref.wrapperAlign,
@@ -66,9 +99,9 @@ var ProForm = /*#__PURE__*/memo(function (_ref) {
66
99
  }); // context需要实名不能解构
67
100
 
68
101
 
69
- var mergedComponents = _objectSpread(_objectSpread({}, globalComponents), components);
102
+ var mergedComponents = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, globalComponents), components), formilyComponents), ProFieldComponents);
70
103
 
71
- var onAutoSubmit = useAutoSubmit(onSubmit); // todo 需要formily支持断点下的属性更新
104
+ var onAutoSubmit = useAutoSubmit(onSubmit, context); // todo 需要formily支持断点下的属性更新
72
105
 
73
106
  var getTeamixLayout = useMemo(function () {
74
107
  return breakpoints ? {
@@ -87,12 +120,13 @@ var ProForm = /*#__PURE__*/memo(function (_ref) {
87
120
  wrapperCol: mergeArrayValue([24], wrapperCol)
88
121
  };
89
122
  }, [breakpoints, layout, labelAlign, wrapperAlign, labelCol, wrapperCol]);
123
+ var schema = useFieldSchema(otherProps);
90
124
  useMemo(function () {
91
125
  // 配置表单默认值
92
126
  if (initialValues) {
93
127
  form.setInitialValues(initialValues);
94
128
  } else if (initialRequest) {
95
- useInitialRequest(initialRequest).then(function (values) {
129
+ useInitialRequest(initialRequest, context).then(function (values) {
96
130
  form.setInitialValues(values);
97
131
  }).finally(function () {
98
132
  onInitialComplete === null || onInitialComplete === void 0 ? void 0 : onInitialComplete(form);
@@ -130,12 +164,19 @@ var ProForm = /*#__PURE__*/memo(function (_ref) {
130
164
  form: form,
131
165
  onAutoSubmit: onAutoSubmit,
132
166
  onAutoSubmitFailed: onSubmitFailed
133
- }), /*#__PURE__*/React.createElement(SchemaForm, {
167
+ }), schema ? /*#__PURE__*/React.createElement(SchemaForm, {
134
168
  schema: schema,
135
169
  scope: mergedScope,
136
170
  components: mergedComponents
137
- }), children);
171
+ }) : null, otherProps === null || otherProps === void 0 ? void 0 : otherProps.children);
138
172
  });
173
+
174
+ var Field = function Field() {
175
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
176
+ };
177
+
178
+ Field.displayName = 'ProFormField';
179
+ ProForm.Field = Field;
139
180
  ProForm.defaultProps = {
140
181
  colon: false,
141
182
  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,109 @@
1
+ var _excluded = ["id", "children", "reactions"],
2
+ _excluded2 = ["id", "children", "reactions"];
3
+
4
+ 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; }
5
+
6
+ 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; }
7
+
8
+ 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; }
9
+
10
+ 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; }
11
+
12
+ 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; }
13
+
14
+ import { getValueByValue, deepMerge, isStr } from '@teamix/utils';
15
+ /**
16
+ * 合并 Field 字段 props 和 ProForm schema 配置,生成完整的 Field 字段 schema
17
+ * @param field Field 字段
18
+ * @param extra 额外的 schema 配置(存在递归,可能是子级 schema )
19
+ * @param wholeExtra 完整的额外 schema 配置
20
+ * @returns schema 配置
21
+ */
22
+
23
+ var getMergedSchema = function getMergedSchema(field, extra, wholeExtra) {
24
+ return [].concat(field).reduce(function (prev, curr, index) {
25
+ var _curr$type;
26
+
27
+ var _ref = curr.props || {},
28
+ id = _ref.id,
29
+ _ref$children = _ref.children,
30
+ children = _ref$children === void 0 ? [] : _ref$children,
31
+ _ref$reactions = _ref.reactions,
32
+ reactions = _ref$reactions === void 0 ? [] : _ref$reactions,
33
+ rest = _objectWithoutProperties(_ref, _excluded);
34
+
35
+ var displayName = curr === null || curr === void 0 ? void 0 : (_curr$type = curr.type) === null || _curr$type === void 0 ? void 0 : _curr$type.displayName; // 自定义组件
36
+
37
+ var type = curr === null || curr === void 0 ? void 0 : curr.type; // 基本Dom元素
38
+
39
+ if (displayName === 'ProFormField') {
40
+ // 获取字段额外的 schema 配置(From ProForm)
41
+ var extraFieldProps = extra[index] || {};
42
+
43
+ if (id !== extraFieldProps.id) {
44
+ // 索引不匹配,通过 id 查找获取
45
+ extraFieldProps = getValueByValue(extra, id, {
46
+ inputKey: 'id',
47
+ outputKey: '__whole__'
48
+ }) || getValueByValue(wholeExtra, id, {
49
+ inputKey: 'id',
50
+ outputKey: '__whole__'
51
+ });
52
+
53
+ if (extraFieldProps) {
54
+ console.warn("Field id \"".concat(id, "\" is not found by index in ProForm schema props, Please pay attention to the order."));
55
+ }
56
+ }
57
+
58
+ var _ref2 = extraFieldProps || {},
59
+ extraId = _ref2.id,
60
+ _ref2$children = _ref2.children,
61
+ extraChildren = _ref2$children === void 0 ? [] : _ref2$children,
62
+ _ref2$reactions = _ref2.reactions,
63
+ extraReactions = _ref2$reactions === void 0 ? [] : _ref2$reactions,
64
+ extraRest = _objectWithoutProperties(_ref2, _excluded2);
65
+
66
+ var mergedReactions = [].concat(reactions, extraReactions);
67
+ var mergedChildren = children ? getMergedSchema(children, extraChildren, wholeExtra) : [];
68
+ prev.push(_objectSpread(_objectSpread(_objectSpread({}, deepMerge(rest, extraRest)), mergedReactions.length && {
69
+ reactions: mergedReactions
70
+ }), mergedChildren.length && {
71
+ children: mergedChildren
72
+ }));
73
+ } else if (isStr(type)) {
74
+ prev.push({
75
+ component: type,
76
+ props: curr.props
77
+ });
78
+ } else if (isStr(displayName)) {
79
+ prev.push({
80
+ decorator: displayName,
81
+ decoratorProps: _objectSpread({
82
+ id: id
83
+ }, rest),
84
+ children: children ? getMergedSchema(children, [], wholeExtra) : []
85
+ });
86
+ }
87
+
88
+ return prev;
89
+ }, []);
90
+ };
91
+ /**
92
+ * 获取 ProForm 的 schema 配置,通过合并 Field 字段 或者 schema 配置
93
+ * @param props ProForm 组件的 props
94
+ * @returns schema 配置
95
+ */
96
+
97
+
98
+ export default (function (_ref3) {
99
+ var children = _ref3.children,
100
+ schema = _ref3.schema;
101
+ var field = [].concat(children !== null && children !== void 0 ? children : []); // 如果 ProForm 的 children 含有 Field 字段,则优先使用 Field 渲染表单(仅合并 ProForm 的 schema 属性 )
102
+
103
+ if (field.length) {
104
+ return getMergedSchema(field, schema !== null && schema !== void 0 ? schema : [], schema !== null && schema !== void 0 ? schema : []);
105
+ } // 正常使用 ProForm 的 schema 渲染表单
106
+
107
+
108
+ return schema;
109
+ });
@@ -32,13 +32,6 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
32
32
 
33
33
  import React, { memo, useCallback, useRef, useMemo } from 'react';
34
34
  import { createSchemaField } from '@formily/react';
35
- import { Affix } from '@alicloudfe/components';
36
- import { Upload, SelectTable, FormLayout, FormItem, ArrayCollapse, ArrayCards, ArrayItems, ArrayTable, Space, FormGrid, FormTab, FormCollapse, FormStep, Editable, FormDialog, FormDrawer, FormButtonGroup, Submit, Reset } from '@teamix/formily';
37
- import ProFieldComponents from '../Components/ProField';
38
- import { EditableDialog, EditableDrawer, EditablePopover } from '../Components/Editable';
39
- import FormGroup from '../Components/FormGroup';
40
- import LightFilter from '../Components/LightFilter';
41
- import Text from '../Components/Text/index';
42
35
  import adapterType from './adapterType';
43
36
  import adapterComponent from './adapterComponent';
44
37
  import adapterDecorator from './adapterDecorator';
@@ -64,39 +57,10 @@ export default /*#__PURE__*/memo(function (_ref) {
64
57
  var schema = _ref.schema,
65
58
  scope = _ref.scope,
66
59
  components = _ref.components;
67
- var schemaScopeRef = useRef({}); // 创建 SchemaField,添加内置组件
60
+ var schemaScopeRef = useRef({}); // 创建 SchemaField
68
61
 
69
62
  var SchemaField = useMemo(function () {
70
- return createSchemaField({
71
- components: _objectSpread(_objectSpread({}, ProFieldComponents), {}, {
72
- FormLayout: FormLayout,
73
- FormItem: FormItem,
74
- ArrayCollapse: ArrayCollapse,
75
- ArrayCards: ArrayCards,
76
- ArrayItems: ArrayItems,
77
- ArrayTable: ArrayTable,
78
- Space: Space,
79
- FormGrid: FormGrid,
80
- FormTab: FormTab,
81
- FormCollapse: FormCollapse,
82
- FormStep: FormStep,
83
- Editable: Editable,
84
- FormDialogFooter: FormDialog.Footer,
85
- FormDrawerFooter: FormDrawer.Footer,
86
- FormButtonGroup: FormButtonGroup,
87
- Submit: Submit,
88
- Reset: Reset,
89
- EditableDialog: EditableDialog,
90
- EditableDrawer: EditableDrawer,
91
- EditablePopover: EditablePopover,
92
- FormGroup: FormGroup,
93
- Upload: Upload,
94
- SelectTable: SelectTable,
95
- Affix: Affix,
96
- LightFilter: LightFilter,
97
- Text: Text
98
- })
99
- });
63
+ return createSchemaField();
100
64
  }, []); // 格式化 schema
101
65
 
102
66
  var formatSchema = 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: {
@@ -1,27 +1,22 @@
1
- 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; }
2
-
3
- import { isPlainObj } from '@teamix/utils';
1
+ import { initializeRequestExpression } from '../utils';
4
2
 
5
3
  var initializeDataSource = function initializeDataSource(dataSource, suffix) {
6
- if (isPlainObj(dataSource)) {
7
- var _requestConfig$extraC;
4
+ var _dataSource$extraConf;
8
5
 
9
- var requestConfig = dataSource;
10
- var requestConfigName = "$requestConfig_".concat(suffix);
11
- return {
12
- reactions: ["{{$dataSource($request,".concat(requestConfigName, ",context)}}")],
13
- scope: _defineProperty({}, requestConfigName, requestConfig),
14
- // dataSource请求时,默认配置字段为只读
15
- data: {
16
- readOnlyOnLoading: (requestConfig === null || requestConfig === void 0 ? void 0 : (_requestConfig$extraC = requestConfig.extraConfig) === null || _requestConfig$extraC === void 0 ? void 0 : _requestConfig$extraC.readOnly) !== false
17
- }
18
- };
19
- }
6
+ var _initializeRequestExp = initializeRequestExpression(dataSource, '$dataSource', suffix),
7
+ expression = _initializeRequestExp.expression,
8
+ scope = _initializeRequestExp.scope;
20
9
 
21
- return {
22
- dataSource: dataSource,
10
+ return expression ? {
11
+ reactions: [expression],
12
+ scope: scope,
13
+ data: {
14
+ readOnlyOnLoading: (dataSource === null || dataSource === void 0 ? void 0 : (_dataSource$extraConf = dataSource.extraConfig) === null || _dataSource$extraConf === void 0 ? void 0 : _dataSource$extraConf.readOnly) !== false
15
+ }
16
+ } : {
23
17
  reactions: [],
24
- scope: {}
18
+ scope: {},
19
+ dataSource: dataSource
25
20
  };
26
21
  };
27
22
 
@@ -17,37 +17,36 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
17
17
  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; }
18
18
 
19
19
  import { isArr } from '@teamix/utils';
20
+ import { initializeRequestExpression } from '../utils';
20
21
 
21
- var initializeRequest = function initializeRequest(requestConfig, suffix) {
22
- if (requestConfig) {
23
- if (isArr(requestConfig)) {
24
- var reactionsMap = [];
25
- var scopeMap = {};
26
- requestConfig.forEach(function (item, index) {
27
- var _initializeRequest = initializeRequest(item, "".concat(suffix).concat(index)),
28
- reactions = _initializeRequest.reactions,
29
- scope = _initializeRequest.scope;
30
-
31
- reactionsMap = [].concat(_toConsumableArray(reactionsMap), _toConsumableArray(reactions));
32
- scopeMap = _objectSpread(_objectSpread({}, scopeMap), scope);
33
- });
34
- return {
35
- reactions: reactionsMap,
36
- scope: scopeMap
37
- };
38
- } else {
39
- var requestConfigName = "$requestConfig_".concat(suffix);
40
- return {
41
- reactions: ["{{$common($request,".concat(requestConfigName, ",context)}}")],
42
- scope: _defineProperty({}, requestConfigName, requestConfig)
43
- };
44
- }
45
- }
22
+ var initializeItem = function initializeItem(request, suffix) {
23
+ var _initializeRequestExp = initializeRequestExpression(request, '$common', suffix),
24
+ expression = _initializeRequestExp.expression,
25
+ scope = _initializeRequestExp.scope;
46
26
 
47
- return {
27
+ return expression ? {
28
+ reactions: [expression],
29
+ scope: scope
30
+ } : {
48
31
  reactions: [],
49
32
  scope: {}
50
33
  };
51
34
  };
52
35
 
36
+ var initializeRequest = function initializeRequest(request, suffix) {
37
+ if (isArr(request)) {
38
+ return request.reduce(function (prev, current, index) {
39
+ var result = initializeItem(current, "".concat(suffix, "_").concat(index));
40
+ prev.reactions = [].concat(_toConsumableArray(prev.reactions), _toConsumableArray(result.reactions));
41
+ prev.scope = _objectSpread(_objectSpread({}, prev.scope), result.scope);
42
+ return prev;
43
+ }, {
44
+ reactions: [],
45
+ scope: {}
46
+ });
47
+ }
48
+
49
+ return initializeItem(request, suffix);
50
+ };
51
+
53
52
  export default initializeRequest;
@@ -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
  };
@@ -1,3 +1,5 @@
1
+ var _excluded = ["validator"];
2
+
1
3
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
4
 
3
5
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -16,32 +18,37 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
16
18
 
17
19
  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
20
 
19
- import { isArr, isPlainObj } from '@teamix/utils';
21
+ 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
22
 
21
- var initializeRules = function initializeRules(rules, suffix) {
22
- var initializeValidator = function initializeValidator(rule) {
23
- var index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
24
-
25
- if (isPlainObj(rule === null || rule === void 0 ? void 0 : rule.validator)) {
26
- var requestConfig = rule.validator;
27
- var requestConfigName = "$requestConfig_".concat(suffix).concat(index);
28
- return {
29
- rules: _objectSpread(_objectSpread({}, rule), {}, {
30
- validator: "{{$validator($request,".concat(requestConfigName, ",context)}}")
31
- }),
32
- scope: _defineProperty({}, requestConfigName, requestConfig)
33
- };
34
- }
35
-
36
- return {
37
- rules: rule,
38
- scope: {}
39
- };
23
+ 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; }
24
+
25
+ import { isArr } from '@teamix/utils';
26
+ import { initializeRequestExpression } from '../utils';
27
+
28
+ var initializeRule = function initializeRule(rule, suffix) {
29
+ var _ref = rule || {},
30
+ validator = _ref.validator,
31
+ rest = _objectWithoutProperties(_ref, _excluded);
32
+
33
+ var _initializeRequestExp = initializeRequestExpression(validator, '$validator', suffix),
34
+ expression = _initializeRequestExp.expression,
35
+ scope = _initializeRequestExp.scope;
36
+
37
+ return expression ? {
38
+ scope: scope,
39
+ rules: _objectSpread({
40
+ validator: expression
41
+ }, rest)
42
+ } : {
43
+ scope: {},
44
+ rules: rule
40
45
  };
46
+ };
41
47
 
48
+ var initializeRules = function initializeRules(rules, suffix) {
42
49
  if (isArr(rules)) {
43
- return rules.reduce(function (prev, current, subIndex) {
44
- var result = initializeValidator(current, subIndex);
50
+ return rules.reduce(function (prev, current, index) {
51
+ var result = initializeRule(current, "".concat(suffix, "_").concat(index));
45
52
  prev.rules = [].concat(_toConsumableArray(prev.rules), [result.rules]);
46
53
  prev.scope = _objectSpread(_objectSpread({}, prev.scope), result.scope);
47
54
  return prev;
@@ -51,7 +58,7 @@ var initializeRules = function initializeRules(rules, suffix) {
51
58
  });
52
59
  }
53
60
 
54
- return initializeValidator(rules);
61
+ return initializeRule(rules, suffix);
55
62
  };
56
63
 
57
64
  export default initializeRules;
@@ -1,4 +1,4 @@
1
- var _excluded = ["name", "title", "children"];
1
+ var _excluded = ["name", "children", "props"];
2
2
 
3
3
  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; }
4
4
 
@@ -10,25 +10,99 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
10
10
 
11
11
  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; }
12
12
 
13
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
14
+
15
+ 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."); }
16
+
17
+ 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); }
18
+
19
+ 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; }
20
+
21
+ 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; }
22
+
23
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
24
+
25
+ import cls from 'classnames';
26
+ import { usePrefixCls, isStr, isPlainObj, isArr } from '@teamix/utils';
27
+ import pureGenProColumnToColumn from '../../table/utils/pureGenProColumnToColumn';
28
+ /**
29
+ * 将可被 ProForm 识别的上下文转换为仅被 ProTable 识别的上下文
30
+ * @param value
31
+ * @returns
32
+ */
33
+
34
+ var adapterContext = function adapterContext(value) {
35
+ if (isStr(value)) {
36
+ var contextReg = /^\{\{.*?\}\}$/;
37
+
38
+ if (contextReg.test(value)) {
39
+ return "\0".concat(value, "\0");
40
+ }
41
+
42
+ return value;
43
+ }
44
+
45
+ if (isPlainObj(value)) {
46
+ var temp = {};
47
+ Object.entries(value).forEach(function (_ref) {
48
+ var _ref2 = _slicedToArray(_ref, 2),
49
+ key = _ref2[0],
50
+ val = _ref2[1];
51
+
52
+ temp[key] = adapterContext(val);
53
+ });
54
+ return temp;
55
+ }
56
+
57
+ if (isArr(value)) {
58
+ return value.map(function (item) {
59
+ return adapterContext(item);
60
+ });
61
+ }
62
+
63
+ return value;
64
+ };
65
+
13
66
  var initializeTableColumn = function initializeTableColumn(item) {
14
67
  var name = item.name,
15
- title = item.title,
16
68
  children = item.children,
69
+ props = item.props,
17
70
  otherProps = _objectWithoutProperties(item, _excluded);
18
71
 
19
72
  return {
20
73
  name: name,
21
- title: title,
22
74
  component: 'SelectTable.Column',
23
- children: children,
24
- props: _objectSpread({}, otherProps)
75
+ children: children === null || children === void 0 ? void 0 : children.map(function (item) {
76
+ return initializeTableColumn(item);
77
+ }),
78
+ props: _objectSpread(_objectSpread({}, otherProps), props)
25
79
  };
26
80
  };
27
81
 
28
82
  var initialize = function initialize(item) {
83
+ var _props$columns;
84
+
29
85
  var _item$children = item.children,
30
- children = _item$children === void 0 ? [] : _item$children;
86
+ children = _item$children === void 0 ? [] : _item$children,
87
+ props = item.props;
88
+ var prefixCls = usePrefixCls('', {
89
+ prefix: 'teamix-pro-form-select-table-column-tree'
90
+ });
91
+ var columns = props === null || props === void 0 ? void 0 : (_props$columns = props.columns) === null || _props$columns === void 0 ? void 0 : _props$columns.map(function (value, index) {
92
+ var column = adapterContext(value);
93
+
94
+ if ((props === null || props === void 0 ? void 0 : props.isTree) && index === 0) {
95
+ return _objectSpread(_objectSpread({}, column), {}, {
96
+ className: cls(column.className, prefixCls)
97
+ });
98
+ }
99
+
100
+ return column;
101
+ });
31
102
  return _objectSpread(_objectSpread({}, item), {}, {
103
+ props: _objectSpread(_objectSpread({}, props), {}, {
104
+ columns: columns && pureGenProColumnToColumn(columns)
105
+ }),
32
106
  children: children.map(function (item) {
33
107
  return initializeTableColumn(item);
34
108
  })
@@ -1,6 +1,6 @@
1
1
  import type { ProFormRequestConfig } from '../typing';
2
- declare const $request: (field: any, { extraConfig, ...requestConfig }: ProFormRequestConfig, context: any, type: 'request' | 'validator' | 'dataSource') => Promise<unknown>;
3
- declare const $common: (services: any, requestConfig: ProFormRequestConfig, context: any) => (field: any) => any;
4
- declare const $validator: (services: any, requestConfig: ProFormRequestConfig, context: any) => (value: any, rules: any, { field }: any) => any;
5
- declare const $dataSource: (services: any, requestConfig: ProFormRequestConfig, context: any) => (field: any) => any;
2
+ declare const $request: (field: any, context: any, { extraConfig, onComplete, ...rest }: ProFormRequestConfig, type: 'request' | 'validator' | 'dataSource') => Promise<unknown>;
3
+ declare const $common: (services: any, context: any, requestConfig: ProFormRequestConfig) => (field: any) => any;
4
+ declare const $validator: (services: any, context: any, requestConfig: ProFormRequestConfig) => (value: any, rules: any, { field }: any) => any;
5
+ declare const $dataSource: (services: any, context: any, requestConfig: ProFormRequestConfig) => (field: any) => any;
6
6
  export { $request, $common, $dataSource, $validator };