@teamix/pro 1.2.0 → 1.2.5

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 (94) hide show
  1. package/dist/212.js +1 -1
  2. package/dist/pro.css +1 -1
  3. package/dist/pro.js +1072 -507
  4. package/dist/pro.min.css +1 -1
  5. package/dist/pro.min.js +1 -1
  6. package/es/actions/dialog-component.js +2 -1
  7. package/es/actions/dialog-form.js +2 -1
  8. package/es/actions/dialog.js +2 -1
  9. package/es/actions/index.js +1 -1
  10. package/es/actions/utils.d.ts +1 -0
  11. package/es/actions/utils.js +27 -0
  12. package/es/card/card-container.d.ts +18 -0
  13. package/es/card/card-container.js +24 -0
  14. package/es/card/divider.d.ts +6 -0
  15. package/es/card/divider.js +16 -0
  16. package/es/card/index.d.ts +59 -32
  17. package/es/card/index.js +191 -107
  18. package/es/card/index.scss +124 -9
  19. package/es/card/utils.d.ts +9 -0
  20. package/es/card/utils.js +30 -0
  21. package/es/form/Components/ProField/index.js +2 -6
  22. package/es/form/ProForm/index.js +43 -17
  23. package/es/form/ProForm/index.scss +0 -1
  24. package/es/form/ProForm/useAutoSubmit.d.ts +1 -1
  25. package/es/form/ProForm/useAutoSubmit.js +3 -3
  26. package/es/form/ProForm/useInitialRequest.d.ts +1 -1
  27. package/es/form/ProForm/useInitialRequest.js +2 -2
  28. package/es/form/SchemaForm/initializeDataSource.js +1 -1
  29. package/es/form/SchemaForm/initializeFormButton.js +3 -2
  30. package/es/form/SchemaForm/initializeRequest.js +6 -3
  31. package/es/form/SchemaForm/initializeRules.js +1 -1
  32. package/es/form/SchemaForm/reactions.d.ts +5 -4
  33. package/es/form/SchemaForm/reactions.js +20 -11
  34. package/es/form/locales/validate.d.ts +159 -0
  35. package/es/form/locales/validate.js +158 -0
  36. package/es/form/typing.d.ts +4 -3
  37. package/es/index.d.ts +1 -1
  38. package/es/index.js +1 -1
  39. package/es/info/components/InfoGroup/index.js +5 -2
  40. package/es/info/components/InfoValueItem/index.js +5 -7
  41. package/es/info/components/baseInfo/index.js +4 -2
  42. package/es/info/index.js +25 -11
  43. package/es/info/typing.d.ts +6 -0
  44. package/es/nocode/configurators/Card.js +8 -4
  45. package/es/table/components/Layout/index.js +1 -1
  46. package/es/table/components/ToolBar/FilterColumnIcon.js +2 -24
  47. package/es/table/components/ToolBar/index.scss +0 -3
  48. package/es/table/index.js +15 -7
  49. package/es/table/typing.d.ts +4 -4
  50. package/lib/actions/dialog-component.js +3 -1
  51. package/lib/actions/dialog-form.js +3 -1
  52. package/lib/actions/dialog.js +3 -1
  53. package/lib/actions/index.js +1 -1
  54. package/lib/actions/utils.d.ts +1 -0
  55. package/lib/actions/utils.js +33 -0
  56. package/lib/card/card-container.d.ts +18 -0
  57. package/lib/card/card-container.js +37 -0
  58. package/lib/card/divider.d.ts +6 -0
  59. package/lib/card/divider.js +26 -0
  60. package/lib/card/index.d.ts +59 -32
  61. package/lib/card/index.js +211 -110
  62. package/lib/card/index.scss +124 -9
  63. package/lib/card/utils.d.ts +9 -0
  64. package/lib/card/utils.js +41 -0
  65. package/lib/form/Components/ProField/index.js +1 -5
  66. package/lib/form/ProForm/index.js +41 -14
  67. package/lib/form/ProForm/index.scss +0 -1
  68. package/lib/form/ProForm/useAutoSubmit.d.ts +1 -1
  69. package/lib/form/ProForm/useAutoSubmit.js +3 -3
  70. package/lib/form/ProForm/useInitialRequest.d.ts +1 -1
  71. package/lib/form/ProForm/useInitialRequest.js +2 -2
  72. package/lib/form/SchemaForm/initializeDataSource.js +1 -1
  73. package/lib/form/SchemaForm/initializeFormButton.js +5 -2
  74. package/lib/form/SchemaForm/initializeRequest.js +5 -2
  75. package/lib/form/SchemaForm/initializeRules.js +1 -1
  76. package/lib/form/SchemaForm/reactions.d.ts +5 -4
  77. package/lib/form/SchemaForm/reactions.js +23 -12
  78. package/lib/form/locales/validate.d.ts +159 -0
  79. package/lib/form/locales/validate.js +165 -0
  80. package/lib/form/typing.d.ts +4 -3
  81. package/lib/index.d.ts +1 -1
  82. package/lib/index.js +1 -1
  83. package/lib/info/components/InfoGroup/index.js +5 -2
  84. package/lib/info/components/InfoValueItem/index.js +5 -7
  85. package/lib/info/components/baseInfo/index.js +4 -2
  86. package/lib/info/index.js +24 -10
  87. package/lib/info/typing.d.ts +6 -0
  88. package/lib/nocode/configurators/Card.js +8 -4
  89. package/lib/table/components/Layout/index.js +1 -1
  90. package/lib/table/components/ToolBar/FilterColumnIcon.js +2 -24
  91. package/lib/table/components/ToolBar/index.scss +0 -3
  92. package/lib/table/index.js +16 -7
  93. package/lib/table/typing.d.ts +4 -4
  94. package/package.json +5 -4
@@ -40,12 +40,130 @@
40
40
  }
41
41
  }
42
42
 
43
+ &-title {
44
+ display: flex;
45
+ align-items: center;
46
+
47
+ & > div {
48
+ display: flex;
49
+ align-items: center;
50
+ &:not(:last-child) {
51
+ margin-right: var(--s-2, 8px);
52
+ }
53
+ }
54
+
55
+ &-collapse {
56
+ cursor: pointer;
57
+
58
+ & > i {
59
+ transition: transform 0.2s;
60
+ color: var(--color-text1-8, #848484);
61
+ margin-right: var(--s-2, 8px);
62
+ }
63
+
64
+ &.collapsed {
65
+ & > i {
66
+ transform: rotate(-90deg);
67
+ }
68
+ }
69
+ }
70
+
71
+ &-description,
72
+ &-tooltip {
73
+ color: var(--color-text1-8, #848484);
74
+ font-weight: normal;
75
+ }
76
+
77
+ &-description {
78
+ font-size: 12px;
79
+ }
80
+ }
81
+
82
+ &-divider {
83
+ flex: none;
84
+ background-color: var(--color-line1-1, #eaeaea);
85
+ }
86
+
43
87
  &-content {
44
88
  &.centered {
45
89
  display: flex;
46
90
  align-items: center;
47
91
  justify-content: center;
48
92
  }
93
+
94
+ &.contain-pro-card {
95
+ display: flex;
96
+
97
+ &.flex-wrap {
98
+ flex-wrap: wrap;
99
+ }
100
+
101
+ &.flex-direction {
102
+ &-row {
103
+ flex-direction: row;
104
+
105
+ .teamix-pro-card-divider {
106
+ width: 1px;
107
+ }
108
+ }
109
+
110
+ &-row-reverse {
111
+ flex-direction: row-reverse;
112
+ .teamix-pro-card-divider {
113
+ width: 1px;
114
+ }
115
+ }
116
+
117
+ &-column {
118
+ flex-direction: column;
119
+ .teamix-pro-card-divider {
120
+ height: 1px;
121
+ }
122
+ }
123
+
124
+ &-column-reverse {
125
+ flex-direction: column-reverse;
126
+ .teamix-pro-card-divider {
127
+ height: 1px;
128
+ }
129
+ }
130
+ }
131
+
132
+ &.split-horizontal,
133
+ &.split-vertical {
134
+ & > .teamix-pro-card-col > .teamix-pro-card {
135
+ border: none;
136
+ }
137
+ }
138
+
139
+ &.split-horizontal {
140
+ & > .teamix-pro-card-col {
141
+ &:not(:last-child) {
142
+ border-right: 1px solid var(--color-line1-1, #eaeaea);
143
+ }
144
+ }
145
+ }
146
+ &.split-vertical {
147
+ & > .teamix-pro-card-col {
148
+ &:not(:last-child) {
149
+ border-bottom: 1px solid var(--color-line1-1, #eaeaea);
150
+ }
151
+ }
152
+ }
153
+ }
154
+ }
155
+
156
+ & > .next-card-actions {
157
+ & > .teamix-pro-actions {
158
+ & > .next-btn {
159
+ margin-right: 0;
160
+ flex-grow: 1;
161
+ }
162
+
163
+ & > .next-divider {
164
+ margin: 0;
165
+ }
166
+ }
49
167
  }
50
168
 
51
169
  &.noBorder {
@@ -54,17 +172,14 @@
54
172
 
55
173
  &.compacted {
56
174
  border: none;
57
- --card-body-padding-bottom: 0px;
58
- --card-padding-lr: 0px;
59
175
 
60
- .next-card-content-container {
61
- --card-body-show-divider-padding-top: 0px;
176
+ & > .next-card-header {
177
+ margin-top: 0;
178
+ padding: 0;
62
179
  }
63
- }
64
-
65
- &.noHoveredShadow {
66
- &:hover {
67
- box-shadow: none;
180
+ & > .next-card-content-container {
181
+ margin: 0;
182
+ padding: 0;
68
183
  }
69
184
  }
70
185
 
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ export declare function formatSpacing(spacing?: [number, number] | number): {
3
+ horizonal: number;
4
+ vertical: number;
5
+ };
6
+ export declare function getColClassAndStyle(col?: number | string): {
7
+ className?: string;
8
+ style: React.CSSProperties;
9
+ };
@@ -0,0 +1,30 @@
1
+ import { baseClass } from '@teamix/utils';
2
+ var cls = baseClass('teamix-pro-card');
3
+ export function formatSpacing(spacing) {
4
+ var spacingArray = spacing instanceof Array ? spacing : [spacing || 0, spacing || 0];
5
+ return {
6
+ horizonal: spacingArray[0] / 2,
7
+ vertical: spacingArray[1] / 2
8
+ };
9
+ }
10
+ export function getColClassAndStyle(col) {
11
+ if (!col) {
12
+ return {
13
+ style: {}
14
+ };
15
+ }
16
+
17
+ if (typeof col === 'number') {
18
+ return {
19
+ className: cls("col-".concat(col)),
20
+ style: {}
21
+ };
22
+ }
23
+
24
+ return {
25
+ style: {
26
+ width: col,
27
+ flexShrink: 0
28
+ }
29
+ };
30
+ }
@@ -17,7 +17,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
17
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
18
 
19
19
  import React from 'react';
20
- import { connect, mapProps, mapReadPretty } from '@formily/react';
20
+ import { connect, mapProps } from '@formily/react';
21
21
  import { mapSize, mapStatus, mapDataSource, mapMode } from '../../utils';
22
22
  import ProField from '../../../field';
23
23
  import fieldTypeMap from '../../fieldTypeMap';
@@ -27,11 +27,7 @@ var componentBuilder = function componentBuilder(type) {
27
27
  return /*#__PURE__*/React.createElement(ProField, _objectSpread(_objectSpread({}, props), {}, {
28
28
  type: type
29
29
  }));
30
- }, mapProps(mapSize, mapStatus, mapDataSource, mapMode), mapReadPretty(function (props) {
31
- return /*#__PURE__*/React.createElement(ProField, _objectSpread(_objectSpread({}, props), {}, {
32
- mode: "read"
33
- }));
34
- }));
30
+ }, mapProps(mapSize, mapStatus, mapDataSource, mapMode));
35
31
  };
36
32
 
37
33
  export default (function () {
@@ -1,4 +1,4 @@
1
- var _excluded = ["form", "initialValues", "initialRequest", "schema", "scope", "components", "children", "layout", "labelAlign", "wrapperAlign", "labelCol", "wrapperCol", "breakpoints", "onChange", "onSubmit", "onSubmitFailed", "className"];
1
+ var _excluded = ["form", "initialValues", "initialRequest", "schema", "scope", "context", "components", "children", "layout", "labelAlign", "wrapperAlign", "labelCol", "wrapperCol", "breakpoints", "onChange", "onSubmit", "onSubmitFailed", "className"];
2
2
 
3
3
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
4
4
 
@@ -12,21 +12,24 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
12
12
 
13
13
  import React, { memo, useEffect, useMemo } from 'react';
14
14
  import cls from 'classnames';
15
- import { createForm, onFormValuesChange } from '@formily/core';
15
+ import { createForm, onFormValuesChange, registerValidateLocale, setValidateLanguage } from '@formily/core';
16
16
  import { toJS } from '@formily/reactive';
17
- import { Form, FormLayout } from '@teamix/formily';
18
- import { usePrefixCls } from '@teamix/utils';
17
+ import { Form } from '@teamix/formily';
18
+ import { usePrefixCls, getLanguage } from '@teamix/utils';
19
19
  import SchemaForm from '../SchemaForm';
20
20
  import { mergeArrayValue } from '../utils';
21
21
  import useAutoSubmit from './useAutoSubmit';
22
22
  import useInitialRequest from './useInitialRequest';
23
+ import validateLocale from '../locales/validate';
23
24
  import './index.scss';
25
+ registerValidateLocale(validateLocale);
24
26
  var ProForm = /*#__PURE__*/memo(function (_ref) {
25
27
  var outerForm = _ref.form,
26
28
  initialValues = _ref.initialValues,
27
29
  initialRequest = _ref.initialRequest,
28
30
  schema = _ref.schema,
29
31
  scope = _ref.scope,
32
+ context = _ref.context,
30
33
  components = _ref.components,
31
34
  children = _ref.children,
32
35
  layout = _ref.layout,
@@ -42,11 +45,18 @@ var ProForm = /*#__PURE__*/memo(function (_ref) {
42
45
  otherProps = _objectWithoutProperties(_ref, _excluded);
43
46
 
44
47
  var form = useMemo(function () {
45
- return outerForm || createForm();
48
+ return outerForm || createForm({
49
+ validateFirst: true
50
+ });
46
51
  }, []);
47
52
  var prefixCls = usePrefixCls('', {
48
53
  prefix: 'teamix-pro-form'
49
54
  });
55
+ var mergedScope = useMemo(function () {
56
+ return _objectSpread(_objectSpread({}, scope), {}, {
57
+ context: context
58
+ });
59
+ }, [scope, context]);
50
60
  var onAutoSubmit = useAutoSubmit(onSubmit);
51
61
  var getTeamixLayout = useMemo(function () {
52
62
  return breakpoints ? {
@@ -84,17 +94,12 @@ var ProForm = /*#__PURE__*/memo(function (_ref) {
84
94
  form.setInitialValues(values);
85
95
  });
86
96
  }
97
+ }, []); // 配置国际化
98
+
99
+ useEffect(function () {
100
+ setValidateLanguage(getLanguage() || 'zh-cn');
87
101
  }, []);
88
- return outerForm === false ?
89
- /*#__PURE__*/
90
- // 特殊表单,无需渲染form实例,例如FormDialog等
91
- React.createElement(FormLayout, _objectSpread(_objectSpread({
92
- className: cls(prefixCls, className)
93
- }, otherProps), getTeamixLayout), /*#__PURE__*/React.createElement(SchemaForm, {
94
- schema: schema,
95
- scope: scope,
96
- components: components
97
- }), children) : /*#__PURE__*/React.createElement(Form, _objectSpread(_objectSpread(_objectSpread({
102
+ return /*#__PURE__*/React.createElement(Form, _objectSpread(_objectSpread(_objectSpread({
98
103
  className: cls(prefixCls, className)
99
104
  }, otherProps), getTeamixLayout), {}, {
100
105
  form: form,
@@ -102,9 +107,30 @@ var ProForm = /*#__PURE__*/memo(function (_ref) {
102
107
  onAutoSubmitFailed: onSubmitFailed
103
108
  }), /*#__PURE__*/React.createElement(SchemaForm, {
104
109
  schema: schema,
105
- scope: scope,
110
+ scope: mergedScope,
106
111
  components: components
107
- }), children);
112
+ }), children); // return outerForm === false ? ( // 特殊表单,无需渲染form实例,例如FormDialog等
113
+ // <FormLayout
114
+ // className={cls(prefixCls, className)}
115
+ // {...otherProps}
116
+ // {...getTeamixLayout}
117
+ // >
118
+ // <SchemaForm schema={schema} scope={scope} components={components} />
119
+ // {children}
120
+ // </FormLayout>
121
+ // ) : (
122
+ // <Form
123
+ // className={cls(prefixCls, className)}
124
+ // {...otherProps}
125
+ // {...getTeamixLayout}
126
+ // form={form}
127
+ // onAutoSubmit={onAutoSubmit}
128
+ // onAutoSubmitFailed={onSubmitFailed}
129
+ // >
130
+ // <SchemaForm schema={schema} scope={scope} components={components} />
131
+ // {children}
132
+ // </Form>
133
+ // );
108
134
  });
109
135
  ProForm.defaultProps = {
110
136
  colon: false,
@@ -244,7 +244,6 @@
244
244
  right: 0;
245
245
  width: 100% !important;
246
246
  height: 56px !important;
247
- padding-left: 24px;
248
247
  background: var(--color-fill1-1, #fff) !important;
249
248
  box-shadow: 0 -1px 5px 0 rgba(38, 38, 38, 0.14);
250
249
  z-index: 2;
@@ -1,6 +1,6 @@
1
1
  import { CommonRequestConfig } from '@teamix/utils';
2
2
  interface IUseAutoSubmit {
3
- (onSubmit?: ((values: any) => any) | CommonRequestConfig): any;
3
+ (onSubmit?: ((values: any) => any) | CommonRequestConfig, context?: any): any;
4
4
  }
5
5
  declare const useAutoSubmit: IUseAutoSubmit;
6
6
  export default useAutoSubmit;
@@ -7,7 +7,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
7
7
  import { useHistory } from 'react-router-dom';
8
8
  import { doCommonRequest, isObj } from '@teamix/utils';
9
9
 
10
- var useAutoSubmit = function useAutoSubmit(onSubmit) {
10
+ var useAutoSubmit = function useAutoSubmit(onSubmit, context) {
11
11
  if (isObj(onSubmit)) {
12
12
  var history = useHistory();
13
13
  var submitConfig = onSubmit;
@@ -16,9 +16,9 @@ var useAutoSubmit = function useAutoSubmit(onSubmit) {
16
16
  method: 'POST'
17
17
  }, submitConfig), {}, {
18
18
  params: _objectSpread(_objectSpread({}, values), submitConfig.params || {})
19
- }), {
19
+ }), _objectSpread({
20
20
  fields: values
21
- }, history);
21
+ }, context), history);
22
22
  };
23
23
  }
24
24
 
@@ -1,6 +1,6 @@
1
1
  import { CommonRequestConfig } from '@teamix/utils';
2
2
  interface IUseInitialRequest {
3
- (initialRequest: CommonRequestConfig): Promise<any>;
3
+ (initialRequest: CommonRequestConfig, context?: any): Promise<any>;
4
4
  }
5
5
  declare const useInitialRequest: IUseInitialRequest;
6
6
  export default useInitialRequest;
@@ -6,10 +6,10 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
6
6
 
7
7
  import { doCommonRequest } from '@teamix/utils';
8
8
 
9
- var useInitialRequest = function useInitialRequest(initialRequest) {
9
+ var useInitialRequest = function useInitialRequest(initialRequest, context) {
10
10
  return doCommonRequest(_objectSpread({
11
11
  method: 'GET'
12
- }, initialRequest));
12
+ }, initialRequest), context);
13
13
  };
14
14
 
15
15
  export default useInitialRequest;
@@ -12,7 +12,7 @@ var initializeDataSource = function initializeDataSource(dataSource) {
12
12
  var requestScopeName = getRandomName('$request');
13
13
  var dataSourceScopeName = getRandomName('$dataSource');
14
14
  return {
15
- reactions: ["{{".concat(dataSourceScopeName, "(").concat(requestScopeName, ",").concat(requestConfig.onComplete, ")}}")],
15
+ reactions: ["{{".concat(dataSourceScopeName, "(").concat(requestScopeName, ",").concat(requestConfig.onComplete, ",context)}}")],
16
16
  scope: (_scope = {}, _defineProperty(_scope, requestScopeName, $request(requestConfig)), _defineProperty(_scope, dataSourceScopeName, $dataSource), _scope)
17
17
  };
18
18
  }
@@ -10,9 +10,10 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
10
10
 
11
11
  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; }
12
12
 
13
+ import { getMessage } from '@teamix/utils';
13
14
  var buttonTextMap = {
14
- Submit: '提交',
15
- Reset: '重置'
15
+ Submit: getMessage('submit'),
16
+ Reset: getMessage('reset')
16
17
  };
17
18
 
18
19
  var initializeButton = function initializeButton(item) {
@@ -1,14 +1,17 @@
1
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
2
 
3
- import { $request } from '../SchemaForm/reactions';
3
+ import { $request, $context } from '../SchemaForm/reactions';
4
4
  import { getRandomName } from '../utils';
5
5
 
6
6
  var initializeRequest = function initializeRequest(requestConfig) {
7
7
  if (requestConfig) {
8
+ var _scope;
9
+
8
10
  var requestScopeName = getRandomName('$request');
11
+ var contextScopeName = getRandomName('$context');
9
12
  return {
10
- reactions: ["{{".concat(requestScopeName, "}}")],
11
- scope: _defineProperty({}, requestScopeName, $request(requestConfig))
13
+ reactions: ["{{".concat(contextScopeName, "(").concat(requestScopeName, ",").concat(requestConfig.onComplete, ",context)}}")],
14
+ scope: (_scope = {}, _defineProperty(_scope, requestScopeName, $request(requestConfig)), _defineProperty(_scope, contextScopeName, $context), _scope)
12
15
  };
13
16
  }
14
17
 
@@ -31,7 +31,7 @@ var initializeRules = function initializeRules(rules) {
31
31
  var validatorScopeName = getRandomName('$validator');
32
32
  return {
33
33
  rules: _objectSpread(_objectSpread({}, rule), {}, {
34
- validator: "{{".concat(validatorScopeName, "(").concat(requestScopeName, ",").concat(validator.onComplete, ")}}")
34
+ validator: "{{".concat(validatorScopeName, "(").concat(requestScopeName, ",").concat(validator.onComplete, ",context)}}")
35
35
  }),
36
36
  scope: (_scope = {}, _defineProperty(_scope, requestScopeName, $request(validator)), _defineProperty(_scope, validatorScopeName, $validator), _scope)
37
37
  };
@@ -1,5 +1,6 @@
1
1
  import type { ProFormRequestConfig } from '../typing';
2
- declare const $request: (requestConfig: ProFormRequestConfig) => (field: any) => Promise<unknown>;
3
- declare const $validator: (services: any, onComplete?: any) => (value: any, rules: any, { field }: any) => any;
4
- declare const $dataSource: (services: any, onComplete?: any) => (field: any) => any;
5
- export { $request, $dataSource, $validator };
2
+ declare const $request: (requestConfig: ProFormRequestConfig) => (field: any, context: any) => Promise<unknown>;
3
+ declare const $context: (services: any, onComplete: any, context: any) => (field: any) => any;
4
+ declare const $validator: (services: any, onComplete: any, context: any) => (value: any, rules: any, { field }: any) => any;
5
+ declare const $dataSource: (services: any, onComplete: any, context: any) => (field: any) => any;
6
+ export { $request, $context, $dataSource, $validator };
@@ -7,44 +7,53 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
7
7
  import { isFn, isPlainObj, doCommonRequest } from '@teamix/utils'; // 配置请求
8
8
 
9
9
  var $request = function $request(requestConfig) {
10
- return function (field) {
10
+ return function (field, context) {
11
11
  var _field$data;
12
12
 
13
13
  var refresh = field === null || field === void 0 ? void 0 : (_field$data = field.data) === null || _field$data === void 0 ? void 0 : _field$data.refresh;
14
14
  var beforeRequest = requestConfig.beforeRequest,
15
15
  onSuccess = requestConfig.onSuccess;
16
16
  var refreshResult = isPlainObj(refresh) ? refresh : {};
17
- var beforeRequestResult = isFn(beforeRequest) ? beforeRequest(field) : {};
17
+ var beforeRequestResult = isFn(beforeRequest) ? beforeRequest(field, context) : {};
18
18
  return doCommonRequest(_objectSpread(_objectSpread({}, requestConfig), {}, {
19
19
  params: _objectSpread(_objectSpread(_objectSpread({}, requestConfig.params), beforeRequestResult), refreshResult),
20
20
  beforeRequest: function beforeRequest() {
21
21
  return beforeRequestResult;
22
22
  },
23
23
  onSuccess: isFn(onSuccess) ? function (res) {
24
- return onSuccess(res, field);
24
+ return onSuccess(res, field, context);
25
25
  } : onSuccess
26
- }), field);
26
+ }), context);
27
+ };
28
+ }; // 配置上下文
29
+
30
+
31
+ var $context = function $context(services, onComplete, context) {
32
+ return function (field) {
33
+ return services(field, context).then(function (res) {
34
+ return onComplete && onComplete(res, field, context);
35
+ });
27
36
  };
28
37
  }; // 配置校验
29
38
 
30
39
 
31
- var $validator = function $validator(services, onComplete) {
40
+ var $validator = function $validator(services, onComplete, context) {
32
41
  return function (value, rules, _ref) {
33
42
  var field = _ref.field;
34
- return services(field).then(function (res) {
35
- return onComplete && onComplete(res, field);
43
+ return services(field, context).then(function (res) {
44
+ return onComplete && onComplete(res, field, context);
36
45
  });
37
46
  };
38
47
  }; // 配置DataSource
39
48
 
40
49
 
41
- var $dataSource = function $dataSource(services, onComplete) {
50
+ var $dataSource = function $dataSource(services, onComplete, context) {
42
51
  return function (field) {
43
52
  field.setState({
44
53
  loading: true,
45
54
  readOnly: true
46
55
  });
47
- return services(field).then(function (res) {
56
+ return services(field, context).then(function (res) {
48
57
  var _res$map;
49
58
 
50
59
  var isValueInDataSource = res === null || res === void 0 ? void 0 : (_res$map = res.map(function (v) {
@@ -58,7 +67,7 @@ var $dataSource = function $dataSource(services, onComplete) {
58
67
  loading: false,
59
68
  readOnly: false
60
69
  }, clearValue));
61
- return onComplete && onComplete(res, field);
70
+ return onComplete && onComplete(res, field, context);
62
71
  }).catch(function () {
63
72
  field.setState({
64
73
  loading: false,
@@ -68,4 +77,4 @@ var $dataSource = function $dataSource(services, onComplete) {
68
77
  };
69
78
  };
70
79
 
71
- export { $request, $dataSource, $validator };
80
+ export { $request, $context, $dataSource, $validator };