@teamix/pro 1.3.14 → 1.3.17
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/pro.css +1 -1
- package/dist/pro.js +22026 -9580
- package/dist/pro.min.css +1 -1
- package/dist/pro.min.js +1 -1
- package/es/actions/index.scss +13 -0
- package/es/form/Filter/index.js +169 -53
- package/es/form/Filter/layout.scss +4 -0
- package/es/form/Filter/useBindUrl.d.ts +2 -0
- package/es/form/Filter/useBindUrl.js +118 -0
- package/es/form/ProForm/index.js +5 -3
- package/es/form/ProForm/useFieldSchema.js +53 -32
- package/es/form/SchemaForm/initializeDataSource.d.ts +1 -2
- package/es/form/SchemaForm/initializeDataSource.js +14 -19
- package/es/form/SchemaForm/initializeRequest.js +25 -26
- package/es/form/SchemaForm/initializeRules.d.ts +2 -2
- package/es/form/SchemaForm/initializeRules.js +30 -23
- package/es/form/SchemaForm/reactions.d.ts +4 -4
- package/es/form/SchemaForm/reactions.js +30 -23
- package/es/form/typing.d.ts +12 -5
- package/es/form/utils.d.ts +16 -1
- package/es/form/utils.js +21 -2
- package/es/global.scss +45 -0
- package/es/index.d.ts +2 -1
- package/es/index.js +3 -2
- package/es/page-header/index.d.ts +2 -0
- package/es/page-header/index.js +13 -3
- package/es/page-header/index.scss +8 -0
- package/es/table/components/Layout/index.scss +5 -5
- package/lib/actions/index.scss +13 -0
- package/lib/form/Filter/index.js +170 -53
- package/lib/form/Filter/layout.scss +4 -0
- package/lib/form/Filter/useBindUrl.d.ts +2 -0
- package/lib/form/Filter/useBindUrl.js +129 -0
- package/lib/form/ProForm/index.js +5 -3
- package/lib/form/ProForm/useFieldSchema.js +52 -31
- package/lib/form/SchemaForm/initializeDataSource.d.ts +1 -2
- package/lib/form/SchemaForm/initializeDataSource.js +14 -19
- package/lib/form/SchemaForm/initializeRequest.js +26 -26
- package/lib/form/SchemaForm/initializeRules.d.ts +2 -2
- package/lib/form/SchemaForm/initializeRules.js +30 -22
- package/lib/form/SchemaForm/reactions.d.ts +4 -4
- package/lib/form/SchemaForm/reactions.js +30 -23
- package/lib/form/typing.d.ts +12 -5
- package/lib/form/utils.d.ts +16 -1
- package/lib/form/utils.js +23 -2
- package/lib/global.scss +45 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +3 -1
- package/lib/page-header/index.d.ts +2 -0
- package/lib/page-header/index.js +12 -2
- package/lib/page-header/index.scss +8 -0
- package/lib/table/components/Layout/index.scss +5 -5
- package/package.json +1 -1
@@ -11,7 +11,7 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
11
11
|
|
12
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
13
|
|
14
|
-
import { getValueByValue, deepMerge } from '@teamix/utils';
|
14
|
+
import { getValueByValue, deepMerge, isStr } from '@teamix/utils';
|
15
15
|
/**
|
16
16
|
* 合并 Field 字段 props 和 ProForm schema 配置,生成完整的 Field 字段 schema
|
17
17
|
* @param field Field 字段
|
@@ -21,45 +21,70 @@ import { getValueByValue, deepMerge } from '@teamix/utils';
|
|
21
21
|
*/
|
22
22
|
|
23
23
|
var getMergedSchema = function getMergedSchema(field, extra, wholeExtra) {
|
24
|
-
return field.reduce(function (prev, curr, index) {
|
24
|
+
return [].concat(field).reduce(function (prev, curr, index) {
|
25
|
+
var _curr$type;
|
26
|
+
|
25
27
|
var _ref = curr.props || {},
|
26
28
|
id = _ref.id,
|
27
29
|
_ref$children = _ref.children,
|
28
30
|
children = _ref$children === void 0 ? [] : _ref$children,
|
29
31
|
_ref$reactions = _ref.reactions,
|
30
32
|
reactions = _ref$reactions === void 0 ? [] : _ref$reactions,
|
31
|
-
rest = _objectWithoutProperties(_ref, _excluded);
|
33
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
32
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; // 自定义组件
|
33
36
|
|
34
|
-
var
|
37
|
+
var type = curr === null || curr === void 0 ? void 0 : curr.type; // 基本Dom元素
|
35
38
|
|
36
|
-
if (
|
37
|
-
//
|
38
|
-
extraFieldProps =
|
39
|
-
inputKey: 'id',
|
40
|
-
outputKey: '__whole__'
|
41
|
-
}) || getValueByValue(wholeExtra, id, {
|
42
|
-
inputKey: 'id',
|
43
|
-
outputKey: '__whole__'
|
44
|
-
});
|
39
|
+
if (displayName === 'ProFormField') {
|
40
|
+
// 获取字段额外的 schema 配置(From ProForm)
|
41
|
+
var extraFieldProps = extra[index] || {};
|
45
42
|
|
46
|
-
if (extraFieldProps) {
|
47
|
-
|
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
|
+
}
|
48
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
|
+
});
|
49
86
|
}
|
50
87
|
|
51
|
-
var _ref2 = extraFieldProps || {},
|
52
|
-
extraId = _ref2.id,
|
53
|
-
_ref2$children = _ref2.children,
|
54
|
-
extraChildren = _ref2$children === void 0 ? [] : _ref2$children,
|
55
|
-
_ref2$reactions = _ref2.reactions,
|
56
|
-
extraReactions = _ref2$reactions === void 0 ? [] : _ref2$reactions,
|
57
|
-
extraRest = _objectWithoutProperties(_ref2, _excluded2);
|
58
|
-
|
59
|
-
prev.push(_objectSpread(_objectSpread({}, deepMerge(rest, extraRest)), {}, {
|
60
|
-
reactions: [].concat(reactions, extraReactions),
|
61
|
-
children: (children === null || children === void 0 ? void 0 : children.length) ? getMergedSchema(children, extraChildren, wholeExtra) : []
|
62
|
-
}));
|
63
88
|
return prev;
|
64
89
|
}, []);
|
65
90
|
};
|
@@ -73,11 +98,7 @@ var getMergedSchema = function getMergedSchema(field, extra, wholeExtra) {
|
|
73
98
|
export default (function (_ref3) {
|
74
99
|
var children = _ref3.children,
|
75
100
|
schema = _ref3.schema;
|
76
|
-
var field = [].concat(children !== null && children !== void 0 ? children : [])
|
77
|
-
var _item$type, _item$props;
|
78
|
-
|
79
|
-
return (item === null || item === void 0 ? void 0 : (_item$type = item.type) === null || _item$type === void 0 ? void 0 : _item$type.name) === '' && (item === null || item === void 0 ? void 0 : (_item$props = item.props) === null || _item$props === void 0 ? void 0 : _item$props.component);
|
80
|
-
}); // 如果 ProForm 的 children 含有 Field 字段,则优先使用 Field 渲染表单(仅合并 ProForm 的 schema 属性 )
|
101
|
+
var field = [].concat(children !== null && children !== void 0 ? children : []); // 如果 ProForm 的 children 含有 Field 字段,则优先使用 Field 渲染表单(仅合并 ProForm 的 schema 属性 )
|
81
102
|
|
82
103
|
if (field.length) {
|
83
104
|
return getMergedSchema(field, schema !== null && schema !== void 0 ? schema : [], schema !== null && schema !== void 0 ? schema : []);
|
@@ -1,27 +1,22 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
import { isPlainObj } from '@teamix/utils';
|
1
|
+
import { initializeRequestExpression } from '../utils';
|
4
2
|
|
5
3
|
var initializeDataSource = function initializeDataSource(dataSource, suffix) {
|
6
|
-
|
7
|
-
var _requestConfig$extraC;
|
4
|
+
var _dataSource$extraConf;
|
8
5
|
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
-
|
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
|
22
|
-
|
23
|
-
|
24
|
-
|
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,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
|
-
|
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
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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,
|
44
|
-
var result =
|
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
|
61
|
+
return initializeRule(rules, suffix);
|
55
62
|
};
|
56
63
|
|
57
64
|
export default initializeRules;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { ProFormRequestConfig } from '../typing';
|
2
|
-
declare const $request: (field: any, { extraConfig, ...
|
3
|
-
declare const $common: (services: any,
|
4
|
-
declare const $validator: (services: any,
|
5
|
-
declare const $dataSource: (services: 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 };
|
@@ -1,4 +1,4 @@
|
|
1
|
-
var _excluded = ["extraConfig"];
|
1
|
+
var _excluded = ["extraConfig", "onComplete"];
|
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,28 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
12
12
|
|
13
13
|
import { isFn, isPlainObj, doCommonRequest, getValueByValue } from '@teamix/utils'; // 配置请求
|
14
14
|
|
15
|
-
var $request = function $request(field,
|
15
|
+
var $request = function $request(field, context, _ref, type) {
|
16
16
|
var _field$data;
|
17
17
|
|
18
18
|
var extraConfig = _ref.extraConfig,
|
19
|
-
|
19
|
+
onComplete = _ref.onComplete,
|
20
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
20
21
|
|
22
|
+
var requestConfig = rest;
|
21
23
|
var params = requestConfig.params,
|
22
24
|
beforeRequest = requestConfig.beforeRequest,
|
23
25
|
formatResult = requestConfig.formatResult,
|
24
26
|
onSuccess = requestConfig.onSuccess;
|
25
|
-
var beforeRequestResult = isFn(beforeRequest) ? beforeRequest(field, context) : {};
|
26
|
-
/**
|
27
|
-
* 主动触发的请求刷新
|
28
|
-
*/
|
29
|
-
// 触发所有配置的请求
|
27
|
+
var beforeRequestResult = isFn(beforeRequest) ? beforeRequest(field, context) : {}; // 通过字段 data 的 refresh 主动触发的请求刷新
|
30
28
|
|
31
29
|
var refresh = (_field$data = field.data) === null || _field$data === void 0 ? void 0 : _field$data.refresh;
|
32
|
-
var refreshResult = isPlainObj(refresh) ? refresh : {};
|
30
|
+
var refreshResult = isPlainObj(refresh) ? refresh : {}; // 合并请求参数
|
31
|
+
|
32
|
+
var mergedParams = _objectSpread(_objectSpread(_objectSpread({}, params), beforeRequestResult), refreshResult); // 执行通用数据请求
|
33
|
+
|
34
|
+
|
33
35
|
return doCommonRequest(_objectSpread(_objectSpread({}, requestConfig), {}, {
|
34
|
-
params:
|
36
|
+
params: mergedParams,
|
35
37
|
beforeRequest: function beforeRequest() {
|
36
38
|
return beforeRequestResult;
|
37
39
|
},
|
@@ -41,40 +43,45 @@ var $request = function $request(field, _ref, context, type) {
|
|
41
43
|
onSuccess: isFn(onSuccess) ? function (res) {
|
42
44
|
return onSuccess(res, field, context);
|
43
45
|
} : onSuccess
|
44
|
-
}), context)
|
46
|
+
}), _objectSpread(_objectSpread({}, context), {}, {
|
47
|
+
field: field,
|
48
|
+
params: mergedParams
|
49
|
+
}));
|
45
50
|
}; // 通用请求配置上下文
|
46
51
|
|
47
52
|
|
48
|
-
var $common = function $common(services,
|
53
|
+
var $common = function $common(services, context, requestConfig) {
|
49
54
|
return function (field) {
|
50
|
-
return services(field,
|
55
|
+
return services(field, context, requestConfig, 'request').then(function (res) {
|
51
56
|
var _requestConfig$onComp;
|
52
57
|
|
53
|
-
return (_requestConfig$onComp = requestConfig.onComplete) === null || _requestConfig$onComp === void 0 ? void 0 : _requestConfig$onComp.call(requestConfig, res, field, context);
|
58
|
+
return requestConfig === null || requestConfig === void 0 ? void 0 : (_requestConfig$onComp = requestConfig.onComplete) === null || _requestConfig$onComp === void 0 ? void 0 : _requestConfig$onComp.call(requestConfig, res, field, context);
|
54
59
|
});
|
55
60
|
};
|
56
61
|
}; // 配置校验
|
57
62
|
|
58
63
|
|
59
|
-
var $validator = function $validator(services,
|
64
|
+
var $validator = function $validator(services, context, requestConfig) {
|
60
65
|
return function (value, rules, _ref2) {
|
61
66
|
var field = _ref2.field;
|
62
|
-
return services(field,
|
63
|
-
|
64
|
-
|
65
|
-
|
67
|
+
return services(field, context, requestConfig, 'validator').then(function (res) {
|
68
|
+
if (requestConfig === null || requestConfig === void 0 ? void 0 : requestConfig.onComplete) {
|
69
|
+
return requestConfig.onComplete(res, field, context);
|
70
|
+
} else {
|
71
|
+
return res;
|
72
|
+
}
|
66
73
|
});
|
67
74
|
};
|
68
75
|
}; // 配置DataSource
|
69
76
|
|
70
77
|
|
71
|
-
var $dataSource = function $dataSource(services,
|
78
|
+
var $dataSource = function $dataSource(services, context, requestConfig) {
|
72
79
|
return function (field) {
|
73
80
|
field.setState({
|
74
81
|
loading: true
|
75
82
|
});
|
76
|
-
return services(field,
|
77
|
-
var _requestConfig$extraC, _requestConfig$
|
83
|
+
return services(field, context, requestConfig, 'dataSource').then(function (res) {
|
84
|
+
var _requestConfig$extraC, _requestConfig$onComp2;
|
78
85
|
|
79
86
|
var isValueInDataSource = getValueByValue(res, field.value);
|
80
87
|
var clearResult = !isValueInDataSource && (requestConfig === null || requestConfig === void 0 ? void 0 : (_requestConfig$extraC = requestConfig.extraConfig) === null || _requestConfig$extraC === void 0 ? void 0 : _requestConfig$extraC.clearInvalidValue) !== false ? {
|
@@ -84,7 +91,7 @@ var $dataSource = function $dataSource(services, requestConfig, context) {
|
|
84
91
|
dataSource: res,
|
85
92
|
loading: false
|
86
93
|
}, clearResult));
|
87
|
-
return (_requestConfig$
|
94
|
+
return requestConfig === null || requestConfig === void 0 ? void 0 : (_requestConfig$onComp2 = requestConfig.onComplete) === null || _requestConfig$onComp2 === void 0 ? void 0 : _requestConfig$onComp2.call(requestConfig, res, field, context);
|
88
95
|
}).catch(function () {
|
89
96
|
field.setState({
|
90
97
|
loading: false
|
package/es/form/typing.d.ts
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
import type { ReactNode } from 'react';
|
2
2
|
import type { IFormFeedback, Form as FormType, FieldPatternTypes } from '@formily/core';
|
3
3
|
import type { IFormLayoutProps } from '@teamix/formily';
|
4
|
-
import { CommonRequestConfig } from '@teamix/utils';
|
4
|
+
import type { CommonRequestConfig } from '@teamix/utils';
|
5
|
+
import type { UrlStateOptions } from '@teamix/hooks';
|
5
6
|
import React from 'react';
|
6
7
|
interface AnyObject {
|
7
8
|
[propName: string]: any;
|
@@ -18,12 +19,16 @@ declare type IBaseComponent = 'Input' | 'Password' | 'TextArea' | 'NumberPicker'
|
|
18
19
|
declare type IButtonComponent = 'Submit' | 'Reset';
|
19
20
|
declare type IComboComponent = 'ArrayCards' | 'ArrayCards.Addition' | 'ArrayCards.Remove' | 'ArrayCards.MoveUp' | 'ArrayCards.MoveDown' | 'ArrayCards.Index' | 'ArrayCollapse' | 'ArrayCollapse.CollapsePanel' | 'ArrayCollapse.Addition' | 'ArrayCollapse.Remove' | 'ArrayCollapse.MoveUp' | 'ArrayCollapse.MoveDown' | 'ArrayCollapse.Index' | 'ArrayTable' | 'ArrayTable.Column' | 'ArrayTable.SortHandle' | 'ArrayTable.Addition' | 'ArrayTable.Remove' | 'ArrayTable.MoveDown' | 'ArrayTable.MoveUp' | 'ArrayTable.Index' | 'ArrayItems' | 'ArrayItems.Item' | 'ArrayItems.SortHandle' | 'ArrayItems.Addition' | 'ArrayItems.Remove' | 'ArrayItems.MoveDown' | 'ArrayItems.MoveUp' | 'ArrayItems.Index' | 'Editable' | 'Editable.Popover' | 'Editable.Dialog' | 'Editable.Drawer';
|
20
21
|
declare type ILayoutComponent = 'FormFlex' | 'FormGrid' | 'FormGroup' | 'FormGroup.GroupPanel' | 'Search' | 'Search.SearchPanel' | 'FormTab' | 'FormTab.TabPane' | 'FormStep' | 'FormStep.StepPane' | 'FormCollapse' | 'FormCollapse.CollapsePanel' | 'FormButtonGroup' | 'FormDialog' | 'FormDrawer' | 'FormDialog.Footer' | 'FormDrawer.Footer';
|
21
|
-
export interface
|
22
|
+
export interface ProFormCommonRequestConfig extends CommonRequestConfig {
|
22
23
|
beforeRequest?: (field?: any, context?: any) => any;
|
23
24
|
formatResult?: (res?: any, field?: any, context?: any) => any;
|
24
25
|
onSuccess?: (res?: any, field?: any, context?: any) => any;
|
25
|
-
|
26
|
+
}
|
27
|
+
export interface ProFormRequestConfig extends Omit<ProFormCommonRequestConfig, 'url'> {
|
28
|
+
url?: string;
|
29
|
+
customRequest?: (field?: any, context?: any) => Promise<any>;
|
26
30
|
extraConfig?: AnyObject;
|
31
|
+
onComplete?: (res?: any, field?: any, context?: any) => any;
|
27
32
|
}
|
28
33
|
export interface ProFormSchemaItem {
|
29
34
|
type?: string;
|
@@ -64,7 +69,7 @@ export interface ProFormProps extends IFormLayoutProps {
|
|
64
69
|
};
|
65
70
|
children?: React.ReactNode;
|
66
71
|
initialValues?: AnyObject;
|
67
|
-
initialRequest?:
|
72
|
+
initialRequest?: ProFormCommonRequestConfig;
|
68
73
|
previewTextPlaceholder?: ReactNode;
|
69
74
|
validateFirst?: boolean;
|
70
75
|
onChangeType?: 'form';
|
@@ -120,8 +125,10 @@ export interface QueryFilterProps extends ProFormProps {
|
|
120
125
|
formRef?: React.MutableRefObject<any>;
|
121
126
|
/** onChange事件的防抖时间 */
|
122
127
|
filterDebounce?: number;
|
128
|
+
/** 绑定URL参数 */
|
129
|
+
bindUrl?: boolean | UrlStateOptions;
|
123
130
|
/** 表单初始化(含异步默认值)后回调函数 */
|
124
|
-
onInit?: (values: any) =>
|
131
|
+
onInit?: (values: any) => void;
|
125
132
|
/** 表单筛选回调函数 */
|
126
133
|
onFilter?: (values: any) => void;
|
127
134
|
/** 表单重置回调函数 */
|
package/es/form/utils.d.ts
CHANGED
@@ -37,4 +37,19 @@ declare const mapSchemaName: (obj: any) => any;
|
|
37
37
|
* @returns 合并数组或合并其他值
|
38
38
|
*/
|
39
39
|
declare const mergeArrayValue: (arr: any[], v?: any) => any[];
|
40
|
-
|
40
|
+
/**
|
41
|
+
* 初始化请求配置为表达式
|
42
|
+
* @param config 请求配置
|
43
|
+
* @param suffix scope名称后缀
|
44
|
+
* @returns 表达式和scope上下文
|
45
|
+
*/
|
46
|
+
declare const initializeRequestExpression: (config?: any, mode?: string | undefined, suffix?: string | undefined) => {
|
47
|
+
expression: string;
|
48
|
+
scope: {
|
49
|
+
[x: string]: object;
|
50
|
+
};
|
51
|
+
} | {
|
52
|
+
expression?: undefined;
|
53
|
+
scope?: undefined;
|
54
|
+
};
|
55
|
+
export { mapSize, mapStatus, mapDataSource, mapMode, mergeArrayValue, getFieldName, mapSchemaName, initializeRequestExpression, };
|
package/es/form/utils.js
CHANGED
@@ -26,7 +26,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
26
26
|
|
27
27
|
import { isVoidField } from '@formily/core';
|
28
28
|
import { useFormLayout, useFormShallowLayout } from '@teamix/formily';
|
29
|
-
import { isArr, isObj, getValueByValue } from '@teamix/utils';
|
29
|
+
import { isArr, isObj, getValueByValue, isPlainObj } from '@teamix/utils';
|
30
30
|
import schemaNameMap from './schemaNameMap';
|
31
31
|
/**
|
32
32
|
* 映射字段size,主要是default转medium
|
@@ -177,5 +177,24 @@ var mergeArrayValue = function mergeArrayValue(arr, v) {
|
|
177
177
|
|
178
178
|
return [].concat(_toConsumableArray(arr), [v]);
|
179
179
|
};
|
180
|
+
/**
|
181
|
+
* 初始化请求配置为表达式
|
182
|
+
* @param config 请求配置
|
183
|
+
* @param suffix scope名称后缀
|
184
|
+
* @returns 表达式和scope上下文
|
185
|
+
*/
|
186
|
+
|
187
|
+
|
188
|
+
var initializeRequestExpression = function initializeRequestExpression(config, mode, suffix) {
|
189
|
+
if (isPlainObj(config)) {
|
190
|
+
var requestConfigName = "$requestConfig_".concat(suffix);
|
191
|
+
return {
|
192
|
+
expression: "{{".concat(mode, "($request,context,").concat(requestConfigName, ")}}"),
|
193
|
+
scope: _defineProperty({}, requestConfigName, config)
|
194
|
+
};
|
195
|
+
}
|
196
|
+
|
197
|
+
return {};
|
198
|
+
};
|
180
199
|
|
181
|
-
export { mapSize, mapStatus, mapDataSource, mapMode, mergeArrayValue, getFieldName, mapSchemaName };
|
200
|
+
export { mapSize, mapStatus, mapDataSource, mapMode, mergeArrayValue, getFieldName, mapSchemaName, initializeRequestExpression };
|
package/es/global.scss
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
// transition 切换主题优化,暂时先写到 pro 里,后面加到基础组件里
|
2
|
+
|
3
|
+
// table 行背景色
|
4
|
+
tr.next-table-row{
|
5
|
+
transition: color 0s;
|
6
|
+
}
|
7
|
+
|
8
|
+
// normal 按钮
|
9
|
+
button.next-btn.next-medium.next-btn-normal {
|
10
|
+
transition: color 0s;
|
11
|
+
}
|
12
|
+
|
13
|
+
// input 背景色
|
14
|
+
.next-input.next-medium {
|
15
|
+
transition: color 0s;
|
16
|
+
}
|
17
|
+
|
18
|
+
// radio 背景色
|
19
|
+
.next-radio-wrapper.checked .next-radio-inner:after {
|
20
|
+
transition: color 0s;
|
21
|
+
}
|
22
|
+
|
23
|
+
.next-radio-wrapper .next-radio-inner {
|
24
|
+
transition: color 0s;
|
25
|
+
}
|
26
|
+
|
27
|
+
// checkbox 背景色
|
28
|
+
.next-checkbox-wrapper .next-checkbox-inner {
|
29
|
+
transition: color 0s;
|
30
|
+
}
|
31
|
+
|
32
|
+
// 侧导背景色
|
33
|
+
.next-menu-item.next-nav-item {
|
34
|
+
transition: color 0s;
|
35
|
+
}
|
36
|
+
|
37
|
+
// 标签背景色
|
38
|
+
.next-tag {
|
39
|
+
transition: color 0s;
|
40
|
+
}
|
41
|
+
|
42
|
+
// 可关闭tag
|
43
|
+
.next-tag.next-tag.next-tag.next-tag-closable.next-tag-level-normal.next-tag-closable {
|
44
|
+
transition: color 0s;
|
45
|
+
}
|
package/es/index.d.ts
CHANGED
@@ -13,6 +13,7 @@ import ProSidebar from './sidebar';
|
|
13
13
|
import { ProTimeline } from './timeline';
|
14
14
|
import * as nocode from './nocode';
|
15
15
|
import * as templates from './templates';
|
16
|
+
import './global.scss';
|
16
17
|
export * from './actions';
|
17
18
|
export * from './card';
|
18
19
|
export * from './field';
|
@@ -26,5 +27,5 @@ export * from './table';
|
|
26
27
|
export * from './sidebar';
|
27
28
|
export * from './utils';
|
28
29
|
export * from './timeline';
|
29
|
-
declare const version = "1.3.
|
30
|
+
declare const version = "1.3.17";
|
30
31
|
export { version, ProAction, ProCard, ProField, ProForm, ProInfo, ProPageContainer, ProPageHeader, ProSkeleton, ProTable, ProSidebar, ProTimeline, hooks, nocode, templates, utils, };
|
package/es/index.js
CHANGED
@@ -14,7 +14,8 @@ import ProSidebar from './sidebar';
|
|
14
14
|
import { ProTimeline } from './timeline';
|
15
15
|
import * as nocode from './nocode';
|
16
16
|
import * as templates from './templates';
|
17
|
-
import TeamixIcon from '@teamix/icon';
|
17
|
+
import TeamixIcon from '@teamix/icon';
|
18
|
+
import './global.scss'; // 设置图标源
|
18
19
|
|
19
20
|
TeamixIcon.setConfig(utils.getTeamixIconConfig());
|
20
21
|
export * from './actions';
|
@@ -31,6 +32,6 @@ export * from './sidebar';
|
|
31
32
|
export * from './utils'; // export * from './sidebar';
|
32
33
|
|
33
34
|
export * from './timeline';
|
34
|
-
var version = '1.3.
|
35
|
+
var version = '1.3.17';
|
35
36
|
export { version, ProAction, ProCard, ProField, ProForm, ProInfo, // ProLayout,
|
36
37
|
ProPageContainer, ProPageHeader, ProSkeleton, ProTable, ProSidebar, ProTimeline, hooks, nocode, templates, utils };
|