@teamix/pro 1.2.4 → 1.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/212.js +1 -1
- package/dist/pro.css +1 -1
- package/dist/pro.js +1182 -512
- package/dist/pro.min.css +1 -1
- package/dist/pro.min.js +1 -1
- package/es/actions/dialog-component.js +2 -1
- package/es/actions/dialog-form.js +2 -1
- package/es/actions/dialog.js +2 -1
- package/es/actions/index.js +3 -2
- package/es/actions/index.scss +3 -0
- package/es/actions/utils.d.ts +1 -0
- package/es/actions/utils.js +27 -0
- package/es/card/card-container.d.ts +18 -0
- package/es/card/card-container.js +24 -0
- package/es/card/divider.d.ts +6 -0
- package/es/card/divider.js +16 -0
- package/es/card/index.d.ts +68 -32
- package/es/card/index.js +194 -107
- package/es/card/index.scss +174 -9
- package/es/card/selectable.d.ts +13 -0
- package/es/card/selectable.js +45 -0
- package/es/card/utils.d.ts +9 -0
- package/es/card/utils.js +30 -0
- package/es/form/Components/ProField/index.js +2 -7
- package/es/form/Filter/index.js +5 -5
- package/es/form/ProForm/index.js +43 -17
- package/es/form/ProForm/index.scss +0 -1
- package/es/form/ProForm/useAutoSubmit.d.ts +1 -1
- package/es/form/ProForm/useAutoSubmit.js +3 -3
- package/es/form/ProForm/useInitialRequest.d.ts +1 -1
- package/es/form/ProForm/useInitialRequest.js +2 -2
- package/es/form/SchemaForm/initializeDataSource.js +1 -1
- package/es/form/SchemaForm/initializeFormButton.js +3 -2
- package/es/form/SchemaForm/initializeRequest.js +6 -3
- package/es/form/SchemaForm/initializeRules.js +1 -1
- package/es/form/SchemaForm/reactions.d.ts +5 -4
- package/es/form/SchemaForm/reactions.js +20 -11
- package/es/form/locales/validate.d.ts +159 -0
- package/es/form/locales/validate.js +158 -0
- package/es/form/typing.d.ts +4 -3
- package/es/index.d.ts +1 -1
- package/es/index.js +7 -4
- package/es/info/components/InfoGroup/index.js +5 -2
- package/es/info/components/InfoValueItem/index.js +4 -6
- package/es/info/components/baseInfo/index.js +4 -2
- package/es/info/components/tableInfo/index.js +10 -6
- package/es/info/index.js +25 -11
- package/es/info/typing.d.ts +6 -0
- package/es/nocode/configurators/Card.js +39 -12
- package/es/sidebar/components/sidebar-container/index.d.ts +5 -0
- package/es/sidebar/components/sidebar-container/index.js +77 -0
- package/es/sidebar/components/sidebar-container/index.scss +18 -0
- package/es/sidebar/components/tree/index.d.ts +4 -0
- package/es/sidebar/components/tree/index.js +95 -0
- package/es/sidebar/index.d.ts +5 -0
- package/es/sidebar/index.js +66 -0
- package/es/sidebar/index.scss +3 -0
- package/es/sidebar/typing.d.ts +51 -0
- package/es/sidebar/typing.js +1 -0
- package/es/table/components/Layout/index.js +1 -1
- package/es/table/components/ToolBar/FilterColumnIcon.js +2 -24
- package/es/table/components/ToolBar/index.scss +0 -3
- package/es/table/index.js +26 -9
- package/es/table/index.scss +1 -0
- package/es/table/typing.d.ts +6 -4
- package/lib/actions/dialog-component.js +3 -1
- package/lib/actions/dialog-form.js +3 -1
- package/lib/actions/dialog.js +3 -1
- package/lib/actions/index.js +3 -2
- package/lib/actions/index.scss +3 -0
- package/lib/actions/utils.d.ts +1 -0
- package/lib/actions/utils.js +33 -0
- package/lib/card/card-container.d.ts +18 -0
- package/lib/card/card-container.js +37 -0
- package/lib/card/divider.d.ts +6 -0
- package/lib/card/divider.js +26 -0
- package/lib/card/index.d.ts +68 -32
- package/lib/card/index.js +215 -110
- package/lib/card/index.scss +174 -9
- package/lib/card/selectable.d.ts +13 -0
- package/lib/card/selectable.js +60 -0
- package/lib/card/utils.d.ts +9 -0
- package/lib/card/utils.js +41 -0
- package/lib/form/Components/ProField/index.js +1 -6
- package/lib/form/Filter/index.js +5 -6
- package/lib/form/ProForm/index.js +41 -14
- package/lib/form/ProForm/index.scss +0 -1
- package/lib/form/ProForm/useAutoSubmit.d.ts +1 -1
- package/lib/form/ProForm/useAutoSubmit.js +3 -3
- package/lib/form/ProForm/useInitialRequest.d.ts +1 -1
- package/lib/form/ProForm/useInitialRequest.js +2 -2
- package/lib/form/SchemaForm/initializeDataSource.js +1 -1
- package/lib/form/SchemaForm/initializeFormButton.js +5 -2
- package/lib/form/SchemaForm/initializeRequest.js +5 -2
- package/lib/form/SchemaForm/initializeRules.js +1 -1
- package/lib/form/SchemaForm/reactions.d.ts +5 -4
- package/lib/form/SchemaForm/reactions.js +23 -12
- package/lib/form/locales/validate.d.ts +159 -0
- package/lib/form/locales/validate.js +165 -0
- package/lib/form/typing.d.ts +4 -3
- package/lib/index.d.ts +1 -1
- package/lib/index.js +3 -1
- package/lib/info/components/InfoGroup/index.js +5 -2
- package/lib/info/components/InfoValueItem/index.js +4 -6
- package/lib/info/components/baseInfo/index.js +4 -2
- package/lib/info/components/tableInfo/index.js +10 -6
- package/lib/info/index.js +24 -10
- package/lib/info/typing.d.ts +6 -0
- package/lib/nocode/configurators/Card.js +39 -12
- package/lib/sidebar/components/sidebar-container/index.d.ts +5 -0
- package/lib/sidebar/components/sidebar-container/index.js +93 -0
- package/lib/sidebar/components/sidebar-container/index.scss +18 -0
- package/lib/sidebar/components/tree/index.d.ts +4 -0
- package/lib/sidebar/components/tree/index.js +112 -0
- package/lib/sidebar/index.d.ts +5 -0
- package/lib/sidebar/index.js +87 -0
- package/lib/sidebar/index.scss +3 -0
- package/lib/sidebar/typing.d.ts +51 -0
- package/lib/sidebar/typing.js +5 -0
- package/lib/table/components/Layout/index.js +1 -1
- package/lib/table/components/ToolBar/FilterColumnIcon.js +2 -24
- package/lib/table/components/ToolBar/index.scss +0 -3
- package/lib/table/index.js +27 -9
- package/lib/table/index.scss +1 -0
- package/lib/table/typing.d.ts +6 -4
- package/package.json +4 -4
@@ -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
|
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,12 +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)
|
31
|
-
return /*#__PURE__*/React.createElement(ProField, _objectSpread(_objectSpread({}, props), {}, {
|
32
|
-
type: type,
|
33
|
-
mode: "read"
|
34
|
-
}));
|
35
|
-
}));
|
30
|
+
}, mapProps(mapSize, mapStatus, mapDataSource, mapMode));
|
36
31
|
};
|
37
32
|
|
38
33
|
export default (function () {
|
package/es/form/Filter/index.js
CHANGED
@@ -29,7 +29,6 @@ import { usePrefixCls, getMessage } from '@teamix/utils';
|
|
29
29
|
import { createForm } from '@formily/core';
|
30
30
|
import ProForm from '../ProForm';
|
31
31
|
import { mergeArrayValue } from '../utils';
|
32
|
-
var searchText = getMessage('search');
|
33
32
|
|
34
33
|
var getEventProps = function getEventProps(triggerType, onFilter) {
|
35
34
|
var keydownEvent = {
|
@@ -177,7 +176,8 @@ var AdvancedFilter = /*#__PURE__*/memo(function (props) {
|
|
177
176
|
onResetValidateSuccess: onReset,
|
178
177
|
style: _objectSpread({}, triggerType === 'submit' ? {} : {
|
179
178
|
marginRight: -16
|
180
|
-
})
|
179
|
+
}),
|
180
|
+
children: getMessage('reset')
|
181
181
|
}
|
182
182
|
}, {
|
183
183
|
component: 'Submit',
|
@@ -186,9 +186,9 @@ var AdvancedFilter = /*#__PURE__*/memo(function (props) {
|
|
186
186
|
marginRight: -8
|
187
187
|
} : {
|
188
188
|
display: 'none'
|
189
|
-
})
|
190
|
-
|
191
|
-
|
189
|
+
}),
|
190
|
+
children: getMessage('search')
|
191
|
+
}
|
192
192
|
}]
|
193
193
|
}]
|
194
194
|
}])
|
package/es/form/ProForm/index.js
CHANGED
@@ -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
|
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
|
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:
|
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,
|
@@ -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:
|
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 $
|
4
|
-
declare const $
|
5
|
-
|
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
|
-
}),
|
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 };
|
@@ -0,0 +1,159 @@
|
|
1
|
+
declare const _default: {
|
2
|
+
en: {
|
3
|
+
pattern: string;
|
4
|
+
required: string;
|
5
|
+
number: string;
|
6
|
+
integer: string;
|
7
|
+
url: string;
|
8
|
+
email: string;
|
9
|
+
ipv6: string;
|
10
|
+
ipv4: string;
|
11
|
+
idcard: string;
|
12
|
+
taodomain: string;
|
13
|
+
qq: string;
|
14
|
+
phone: string;
|
15
|
+
money: string;
|
16
|
+
zh: string;
|
17
|
+
date: string;
|
18
|
+
zip: string;
|
19
|
+
len: string;
|
20
|
+
min: string;
|
21
|
+
maximum: string;
|
22
|
+
exclusiveMaximum: string;
|
23
|
+
minimum: string;
|
24
|
+
exclusiveMinimum: string;
|
25
|
+
max: string;
|
26
|
+
whitespace: string;
|
27
|
+
};
|
28
|
+
'en-us': {
|
29
|
+
pattern: string;
|
30
|
+
required: string;
|
31
|
+
number: string;
|
32
|
+
integer: string;
|
33
|
+
url: string;
|
34
|
+
email: string;
|
35
|
+
ipv6: string;
|
36
|
+
ipv4: string;
|
37
|
+
idcard: string;
|
38
|
+
taodomain: string;
|
39
|
+
qq: string;
|
40
|
+
phone: string;
|
41
|
+
money: string;
|
42
|
+
zh: string;
|
43
|
+
date: string;
|
44
|
+
zip: string;
|
45
|
+
len: string;
|
46
|
+
min: string;
|
47
|
+
maximum: string;
|
48
|
+
exclusiveMaximum: string;
|
49
|
+
minimum: string;
|
50
|
+
exclusiveMinimum: string;
|
51
|
+
max: string;
|
52
|
+
whitespace: string;
|
53
|
+
};
|
54
|
+
zh: {
|
55
|
+
pattern: string;
|
56
|
+
required: string;
|
57
|
+
number: string;
|
58
|
+
integer: string;
|
59
|
+
url: string;
|
60
|
+
email: string;
|
61
|
+
ipv6: string;
|
62
|
+
ipv4: string;
|
63
|
+
idcard: string;
|
64
|
+
taodomain: string;
|
65
|
+
qq: string;
|
66
|
+
phone: string;
|
67
|
+
money: string;
|
68
|
+
zh: string;
|
69
|
+
date: string;
|
70
|
+
zip: string;
|
71
|
+
len: string;
|
72
|
+
min: string;
|
73
|
+
max: string;
|
74
|
+
maximum: string;
|
75
|
+
exclusiveMaximum: string;
|
76
|
+
minimum: string;
|
77
|
+
exclusiveMinimum: string;
|
78
|
+
whitespace: string;
|
79
|
+
};
|
80
|
+
'zh-cn': {
|
81
|
+
pattern: string;
|
82
|
+
required: string;
|
83
|
+
number: string;
|
84
|
+
integer: string;
|
85
|
+
url: string;
|
86
|
+
email: string;
|
87
|
+
ipv6: string;
|
88
|
+
ipv4: string;
|
89
|
+
idcard: string;
|
90
|
+
taodomain: string;
|
91
|
+
qq: string;
|
92
|
+
phone: string;
|
93
|
+
money: string;
|
94
|
+
zh: string;
|
95
|
+
date: string;
|
96
|
+
zip: string;
|
97
|
+
len: string;
|
98
|
+
min: string;
|
99
|
+
max: string;
|
100
|
+
maximum: string;
|
101
|
+
exclusiveMaximum: string;
|
102
|
+
minimum: string;
|
103
|
+
exclusiveMinimum: string;
|
104
|
+
whitespace: string;
|
105
|
+
};
|
106
|
+
'zh-tw': {
|
107
|
+
pattern: string;
|
108
|
+
required: string;
|
109
|
+
number: string;
|
110
|
+
integer: string;
|
111
|
+
url: string;
|
112
|
+
email: string;
|
113
|
+
ipv6: string;
|
114
|
+
ipv4: string;
|
115
|
+
idcard: string;
|
116
|
+
taodomain: string;
|
117
|
+
qq: string;
|
118
|
+
phone: string;
|
119
|
+
money: string;
|
120
|
+
zh: string;
|
121
|
+
date: string;
|
122
|
+
zip: string;
|
123
|
+
len: string;
|
124
|
+
min: string;
|
125
|
+
max: string;
|
126
|
+
maximum: string;
|
127
|
+
exclusiveMaximum: string;
|
128
|
+
minimum: string;
|
129
|
+
exclusiveMinimum: string;
|
130
|
+
whitespace: string;
|
131
|
+
};
|
132
|
+
ja: {
|
133
|
+
url: string;
|
134
|
+
whitespace: string;
|
135
|
+
zh: string;
|
136
|
+
zip: string;
|
137
|
+
date: string;
|
138
|
+
email: string;
|
139
|
+
exclusiveMaximum: string;
|
140
|
+
exclusiveMinimum: string;
|
141
|
+
idcard: string;
|
142
|
+
integer: string;
|
143
|
+
ipv4: string;
|
144
|
+
ipv6: string;
|
145
|
+
len: string;
|
146
|
+
max: string;
|
147
|
+
maximum: string;
|
148
|
+
min: string;
|
149
|
+
minimum: string;
|
150
|
+
money: string;
|
151
|
+
number: string;
|
152
|
+
pattern: string;
|
153
|
+
phone: string;
|
154
|
+
qq: string;
|
155
|
+
required: string;
|
156
|
+
taodomain: string;
|
157
|
+
};
|
158
|
+
};
|
159
|
+
export default _default;
|