@teamix/pro 1.2.17 → 1.2.21
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 +49 -49
- package/dist/pro.css +1 -1
- package/dist/pro.js +2173 -744
- package/dist/pro.min.css +1 -1
- package/dist/pro.min.js +1 -1
- package/es/actions/base.d.ts +2 -1
- package/es/actions/base.js +1 -1
- package/es/actions/danger-pop-confirm.d.ts +5 -0
- package/es/actions/danger-pop-confirm.js +10 -0
- package/es/actions/dialog.d.ts +1 -1
- package/es/actions/dialog.js +34 -36
- package/es/actions/index.d.ts +3 -0
- package/es/actions/index.js +10 -0
- package/es/actions/pop-confirm.d.ts +9 -0
- package/es/actions/pop-confirm.js +9 -0
- package/es/form/Components/LightFilter/componentMap.d.ts +2 -1
- package/es/form/Components/LightFilter/componentMap.js +4 -2
- package/es/form/Components/LightFilter/index.d.ts +1 -0
- package/es/form/Components/LightFilter/index.js +34 -16
- package/es/form/Components/LightFilter/index.scss +14 -4
- package/es/form/Filter/AdvancedFilter.d.ts +7 -0
- package/es/form/Filter/AdvancedFilter.js +113 -0
- package/es/form/Filter/LightFilter.d.ts +7 -0
- package/es/form/Filter/LightFilter.js +79 -0
- package/es/form/Filter/SimpleFilter.d.ts +7 -0
- package/es/form/Filter/SimpleFilter.js +74 -0
- package/es/form/Filter/index2.js +288 -235
- package/es/form/Filter/index2.scss +3 -0
- package/es/form/ProForm/index.js +11 -7
- package/es/form/ProForm/index.scss +3 -0
- package/es/form/ProForm/useFieldRequest.js +1 -8
- package/es/form/ProForm/useFormDisplayValues.js +4 -2
- package/es/form/SchemaForm/index.js +19 -11
- package/es/form/SchemaForm/initializeDataSource.d.ts +2 -2
- package/es/form/SchemaForm/initializeDataSource.js +4 -9
- package/es/form/SchemaForm/initializeRequest.d.ts +2 -2
- package/es/form/SchemaForm/initializeRequest.js +4 -10
- package/es/form/SchemaForm/initializeRules.d.ts +7 -1
- package/es/form/SchemaForm/initializeRules.js +9 -13
- package/es/form/SchemaForm/reactions.d.ts +5 -5
- package/es/form/SchemaForm/reactions.js +27 -29
- package/es/form/typing.d.ts +11 -2
- package/es/form/utils.d.ts +8 -7
- package/es/form/utils.js +5 -4
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/table/components/Filter/index.js +1 -0
- package/es/table/components/Pagination/index.d.ts +3 -0
- package/es/table/components/Pagination/index.js +82 -0
- package/es/table/components/ToolBar/FilterColumnIcon.js +18 -5
- package/es/table/components/ToolBar/index.scss +8 -2
- package/es/table/index.js +71 -18
- package/es/table/index.scss +7 -1
- package/es/table/typing.d.ts +5 -0
- package/lib/actions/base.d.ts +2 -1
- package/lib/actions/base.js +1 -1
- package/lib/actions/danger-pop-confirm.d.ts +5 -0
- package/lib/actions/danger-pop-confirm.js +22 -0
- package/lib/actions/dialog.d.ts +1 -1
- package/lib/actions/dialog.js +35 -36
- package/lib/actions/index.d.ts +3 -0
- package/lib/actions/index.js +12 -0
- package/lib/actions/pop-confirm.d.ts +9 -0
- package/lib/actions/pop-confirm.js +23 -0
- package/lib/form/Components/LightFilter/componentMap.d.ts +2 -1
- package/lib/form/Components/LightFilter/componentMap.js +6 -4
- package/lib/form/Components/LightFilter/index.d.ts +1 -0
- package/lib/form/Components/LightFilter/index.js +31 -14
- package/lib/form/Components/LightFilter/index.scss +14 -4
- package/lib/form/Filter/AdvancedFilter.d.ts +7 -0
- package/lib/form/Filter/AdvancedFilter.js +133 -0
- package/lib/form/Filter/LightFilter.d.ts +7 -0
- package/lib/form/Filter/LightFilter.js +99 -0
- package/lib/form/Filter/SimpleFilter.d.ts +7 -0
- package/lib/form/Filter/SimpleFilter.js +93 -0
- package/lib/form/Filter/index2.js +291 -234
- package/lib/form/Filter/index2.scss +3 -0
- package/lib/form/ProForm/index.js +10 -6
- package/lib/form/ProForm/index.scss +3 -0
- package/lib/form/ProForm/useFieldRequest.js +1 -9
- package/lib/form/ProForm/useFormDisplayValues.js +3 -1
- package/lib/form/SchemaForm/index.js +19 -10
- package/lib/form/SchemaForm/initializeDataSource.d.ts +2 -2
- package/lib/form/SchemaForm/initializeDataSource.js +4 -11
- package/lib/form/SchemaForm/initializeRequest.d.ts +2 -2
- package/lib/form/SchemaForm/initializeRequest.js +4 -11
- package/lib/form/SchemaForm/initializeRules.d.ts +7 -1
- package/lib/form/SchemaForm/initializeRules.js +9 -16
- package/lib/form/SchemaForm/reactions.d.ts +5 -5
- package/lib/form/SchemaForm/reactions.js +29 -31
- package/lib/form/typing.d.ts +11 -2
- package/lib/form/utils.d.ts +8 -7
- package/lib/form/utils.js +6 -5
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/table/components/Pagination/index.d.ts +3 -0
- package/lib/table/components/Pagination/index.js +95 -0
- package/lib/table/components/ToolBar/FilterColumnIcon.js +18 -5
- package/lib/table/components/ToolBar/index.scss +8 -2
- package/lib/table/index.js +69 -17
- package/lib/table/index.scss +7 -1
- package/lib/table/typing.d.ts +5 -0
- package/package.json +3 -3
package/es/form/ProForm/index.js
CHANGED
@@ -12,7 +12,7 @@ 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,
|
15
|
+
import { createForm, onFieldValueChange, registerValidateLocale, setValidateLanguage } from '@formily/core';
|
16
16
|
import { toJS } from '@formily/reactive';
|
17
17
|
import { Form } from '@teamix/formily';
|
18
18
|
import { usePrefixCls, getLanguage } from '@teamix/utils';
|
@@ -78,12 +78,12 @@ var ProForm = /*#__PURE__*/memo(function (_ref) {
|
|
78
78
|
}, [breakpoints, layout, labelAlign, wrapperAlign, labelCol, wrapperCol]); // 添加onChange
|
79
79
|
|
80
80
|
useEffect(function () {
|
81
|
-
form.removeEffects('
|
82
|
-
form.addEffects('
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
81
|
+
form.removeEffects('onFieldValueChange');
|
82
|
+
form.addEffects('onFieldValueChange', function () {
|
83
|
+
onFieldValueChange('*', function (field, form) {
|
84
|
+
var _field$props;
|
85
|
+
|
86
|
+
onChange && onChange(toJS(form.values), toJS(field.value), (_field$props = field.props) === null || _field$props === void 0 ? void 0 : _field$props.name);
|
87
87
|
});
|
88
88
|
});
|
89
89
|
}, [form, onChange]); // 配置表单默认值
|
@@ -94,6 +94,10 @@ var ProForm = /*#__PURE__*/memo(function (_ref) {
|
|
94
94
|
} else if (initialRequest) {
|
95
95
|
useInitialRequest(initialRequest).then(function (values) {
|
96
96
|
form.setInitialValues(values);
|
97
|
+
}).finally(function () {
|
98
|
+
initialRequest.onComplete && initialRequest.onComplete(undefined, undefined, {
|
99
|
+
form: form
|
100
|
+
});
|
97
101
|
});
|
98
102
|
}
|
99
103
|
}, []); // 配置国际化
|
@@ -5,18 +5,11 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
5
5
|
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; }
|
6
6
|
|
7
7
|
import { useField } from '@formily/react';
|
8
|
-
import { isPlainObj } from '@teamix/utils';
|
9
8
|
export default (function () {
|
10
9
|
var field = useField();
|
11
10
|
|
12
11
|
var refresh = function refresh() {
|
13
|
-
|
14
|
-
field.data = {
|
15
|
-
refresh: {}
|
16
|
-
};
|
17
|
-
} else {
|
18
|
-
field.data.refresh = _objectSpread({}, field.data.refresh);
|
19
|
-
}
|
12
|
+
field.data.refresh = _objectSpread({}, field.data.refresh);
|
20
13
|
};
|
21
14
|
|
22
15
|
return {
|
@@ -12,7 +12,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
12
|
|
13
13
|
import { useForm } from '@formily/react';
|
14
14
|
import { toJS } from '@formily/reactive';
|
15
|
-
import { isArr, isPlainObj, getValueByValue } from '@teamix/utils';
|
15
|
+
import { isArr, isPlainObj, isSignificative, getValueByValue } from '@teamix/utils';
|
16
16
|
/**
|
17
17
|
* 获取表单值的可显示值
|
18
18
|
* @returns 如果某字段有dataSource,则返回value对应label
|
@@ -56,7 +56,9 @@ var getDisplayValues = function getDisplayValues(form, values) {
|
|
56
56
|
}; // 判断值的类型,递归获取每个值在该结构中的完整路径
|
57
57
|
|
58
58
|
|
59
|
-
if (
|
59
|
+
if (!isSignificative(values)) {
|
60
|
+
displayValues = {};
|
61
|
+
} else if (isPlainObj(values) && isLayoutValue(values)) {
|
60
62
|
// 如果值是对象且是布局对象的值
|
61
63
|
displayValues = {};
|
62
64
|
Object.entries(values).forEach(function (_ref) {
|
@@ -55,8 +55,9 @@ import initializeFormGroup from './initializeFormGroup';
|
|
55
55
|
import initializeFormStep from './initializeFormStep';
|
56
56
|
import initializeFormTab from './initializeFormTab';
|
57
57
|
import initializeFormCollapse from './initializeFormCollapse';
|
58
|
+
import { $request, $common, $dataSource, $validator } from './reactions';
|
58
59
|
import fieldTypeMap from '../fieldTypeMap';
|
59
|
-
import {
|
60
|
+
import { getFieldName, mapSchemaName } from '../utils';
|
60
61
|
import warning from '../warning';
|
61
62
|
export default /*#__PURE__*/memo(function (_ref) {
|
62
63
|
var schema = _ref.schema,
|
@@ -96,12 +97,17 @@ export default /*#__PURE__*/memo(function (_ref) {
|
|
96
97
|
}, []); // 合并 schema 中 request 的 scope
|
97
98
|
|
98
99
|
var mergedScope = useMemo(function () {
|
99
|
-
return _objectSpread({}, scope)
|
100
|
+
return _objectSpread(_objectSpread({}, scope), {}, {
|
101
|
+
$request: $request,
|
102
|
+
$common: $common,
|
103
|
+
$dataSource: $dataSource,
|
104
|
+
$validator: $validator
|
105
|
+
});
|
100
106
|
}, [scope]); // 格式化 schema
|
101
107
|
|
102
108
|
var formatSchema = useCallback(function (schema) {
|
103
109
|
var schemaProperties = {};
|
104
|
-
schema === null || schema === void 0 ? void 0 : schema.forEach(function (item) {
|
110
|
+
schema === null || schema === void 0 ? void 0 : schema.forEach(function (item, index) {
|
105
111
|
var newItem = warning(item);
|
106
112
|
var _newItem = newItem,
|
107
113
|
originalComponent = _newItem.component; // 根据component的不同,初始化为内置的item
|
@@ -165,7 +171,7 @@ export default /*#__PURE__*/memo(function (_ref) {
|
|
165
171
|
component = _newItem2.component,
|
166
172
|
type = _newItem2.type,
|
167
173
|
_newItem2$name = _newItem2.name,
|
168
|
-
name = _newItem2$name === void 0 ?
|
174
|
+
name = _newItem2$name === void 0 ? getFieldName(component === null || component === void 0 ? void 0 : component.replace(/\./g, ''), index) : _newItem2$name,
|
169
175
|
decorator = _newItem2.decorator,
|
170
176
|
decoratorProps = _newItem2.decoratorProps,
|
171
177
|
dataSource = _newItem2.dataSource,
|
@@ -190,18 +196,18 @@ export default /*#__PURE__*/memo(function (_ref) {
|
|
190
196
|
var defaultDecoratorProps = _objectSpread(_objectSpread({}, tooltipProps), decoratorProps); // 初始化request
|
191
197
|
|
192
198
|
|
193
|
-
var _initializeRequest = initializeRequest(request),
|
199
|
+
var _initializeRequest = initializeRequest(request, index),
|
194
200
|
requestReactions = _initializeRequest.reactions,
|
195
201
|
requestScope = _initializeRequest.scope; // 初始化dataSource
|
196
202
|
|
197
203
|
|
198
|
-
var _initializeDataSource = initializeDataSource(dataSource),
|
204
|
+
var _initializeDataSource = initializeDataSource(dataSource, index),
|
199
205
|
defaultDataSource = _initializeDataSource.dataSource,
|
200
206
|
dataSourceReactions = _initializeDataSource.reactions,
|
201
207
|
dataSourceScope = _initializeDataSource.scope; // 初始化rules
|
202
208
|
|
203
209
|
|
204
|
-
var _initializeRules = initializeRules(rules),
|
210
|
+
var _initializeRules = initializeRules(rules, index),
|
205
211
|
defaultRules = _initializeRules.rules,
|
206
212
|
rulesScope = _initializeRules.scope; // 合并reactions,初始化reactions
|
207
213
|
|
@@ -223,7 +229,9 @@ export default /*#__PURE__*/memo(function (_ref) {
|
|
223
229
|
rules: defaultRules,
|
224
230
|
reactions: defaultReactions,
|
225
231
|
dataSource: defaultDataSource,
|
226
|
-
data: data
|
232
|
+
data: data || {
|
233
|
+
placeholder: true
|
234
|
+
}
|
227
235
|
})); // 递归子组件
|
228
236
|
|
229
237
|
var recursiveProperties = (children === null || children === void 0 ? void 0 : children.length) ? {
|
@@ -237,15 +245,15 @@ export default /*#__PURE__*/memo(function (_ref) {
|
|
237
245
|
});
|
238
246
|
return schemaProperties;
|
239
247
|
}, [mergedScope]);
|
240
|
-
var
|
248
|
+
var formilySchema = useMemo(function () {
|
241
249
|
return {
|
242
250
|
type: 'object',
|
243
251
|
properties: formatSchema(schema)
|
244
252
|
};
|
245
|
-
}, [schema]); // console.log(
|
253
|
+
}, [schema]); // console.log(formilySchema);
|
246
254
|
|
247
255
|
return /*#__PURE__*/React.createElement(SchemaField, {
|
248
|
-
schema:
|
256
|
+
schema: formilySchema,
|
249
257
|
components: components,
|
250
258
|
scope: mergedScope
|
251
259
|
});
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import type { ProFormRequestConfig } from '../';
|
1
|
+
import type { ProFormRequestConfig } from '../typing';
|
2
2
|
interface IInitializeDataSource {
|
3
|
-
(requestConfig?: ProFormRequestConfig | any): {
|
3
|
+
(requestConfig?: ProFormRequestConfig | any, index?: number): {
|
4
4
|
dataSource?: any[];
|
5
5
|
reactions: any[];
|
6
6
|
scope: {
|
@@ -1,19 +1,14 @@
|
|
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
3
|
import { isPlainObj } from '@teamix/utils';
|
4
|
-
import { $request, $dataSource } from './reactions';
|
5
|
-
import { getRandomName } from '../utils';
|
6
4
|
|
7
|
-
var initializeDataSource = function initializeDataSource(dataSource) {
|
5
|
+
var initializeDataSource = function initializeDataSource(dataSource, index) {
|
8
6
|
if (isPlainObj(dataSource)) {
|
9
|
-
var _scope;
|
10
|
-
|
11
7
|
var requestConfig = dataSource;
|
12
|
-
var
|
13
|
-
var dataSourceScopeName = getRandomName('$dataSource');
|
8
|
+
var requestConfigName = "$requestConfig_".concat(index);
|
14
9
|
return {
|
15
|
-
reactions: ["{{
|
16
|
-
scope: (
|
10
|
+
reactions: ["{{$dataSource($request,".concat(requestConfigName, ",context)}}")],
|
11
|
+
scope: _defineProperty({}, requestConfigName, requestConfig)
|
17
12
|
};
|
18
13
|
}
|
19
14
|
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import type { ProFormRequestConfig } from '../';
|
1
|
+
import type { ProFormRequestConfig } from '../typing';
|
2
2
|
interface IInitializeRequest {
|
3
|
-
(requestConfig?: ProFormRequestConfig): {
|
3
|
+
(requestConfig?: ProFormRequestConfig, index?: number): {
|
4
4
|
reactions: any[];
|
5
5
|
scope: {
|
6
6
|
[x: string]: any;
|
@@ -1,17 +1,11 @@
|
|
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
|
-
|
4
|
-
import { getRandomName } from '../utils';
|
5
|
-
|
6
|
-
var initializeRequest = function initializeRequest(requestConfig) {
|
3
|
+
var initializeRequest = function initializeRequest(requestConfig, index) {
|
7
4
|
if (requestConfig) {
|
8
|
-
var
|
9
|
-
|
10
|
-
var requestScopeName = getRandomName('$request');
|
11
|
-
var contextScopeName = getRandomName('$context');
|
5
|
+
var requestConfigName = "$requestConfig_".concat(index);
|
12
6
|
return {
|
13
|
-
reactions: ["{{
|
14
|
-
scope: (
|
7
|
+
reactions: ["{{$common($request,".concat(requestConfigName, ",context)}}")],
|
8
|
+
scope: _defineProperty({}, requestConfigName, requestConfig)
|
15
9
|
};
|
16
10
|
}
|
17
11
|
|
@@ -17,23 +17,19 @@ 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 { isArr, isPlainObj } from '@teamix/utils';
|
20
|
-
import { $request } from '../SchemaForm/reactions';
|
21
|
-
import { getRandomName } from '../utils';
|
22
|
-
import { $validator } from './reactions';
|
23
20
|
|
24
|
-
var initializeRules = function initializeRules(rules) {
|
21
|
+
var initializeRules = function initializeRules(rules, index) {
|
25
22
|
var initializeValidator = function initializeValidator(rule) {
|
26
|
-
|
27
|
-
var _scope;
|
23
|
+
var subIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
28
24
|
|
29
|
-
|
30
|
-
var
|
31
|
-
var
|
25
|
+
if (isPlainObj(rule === null || rule === void 0 ? void 0 : rule.validator)) {
|
26
|
+
var requestConfig = rule.validator;
|
27
|
+
var requestConfigName = "$requestConfig_".concat(index, "_").concat(subIndex);
|
32
28
|
return {
|
33
29
|
rules: _objectSpread(_objectSpread({}, rule), {}, {
|
34
|
-
validator: "{{
|
30
|
+
validator: "{{$validator($request,".concat(requestConfigName, ",context)}}")
|
35
31
|
}),
|
36
|
-
scope: (
|
32
|
+
scope: _defineProperty({}, requestConfigName, requestConfig)
|
37
33
|
};
|
38
34
|
}
|
39
35
|
|
@@ -44,8 +40,8 @@ var initializeRules = function initializeRules(rules) {
|
|
44
40
|
};
|
45
41
|
|
46
42
|
if (isArr(rules)) {
|
47
|
-
return rules.reduce(function (prev, current) {
|
48
|
-
var result = initializeValidator(current);
|
43
|
+
return rules.reduce(function (prev, current, subIndex) {
|
44
|
+
var result = initializeValidator(current, subIndex);
|
49
45
|
prev.rules = [].concat(_toConsumableArray(prev.rules), [result.rules]);
|
50
46
|
prev.scope = _objectSpread(_objectSpread({}, prev.scope), result.scope);
|
51
47
|
return prev;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { ProFormRequestConfig } from '../typing';
|
2
|
-
declare const $request: (
|
3
|
-
declare const $
|
4
|
-
declare const $validator: (services: any,
|
5
|
-
declare const $dataSource: (services: any,
|
6
|
-
export { $request, $
|
2
|
+
declare const $request: (field: any, requestConfig: ProFormRequestConfig, context: any) => 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;
|
6
|
+
export { $request, $common, $dataSource, $validator };
|
@@ -6,54 +6,52 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
6
6
|
|
7
7
|
import { isFn, isPlainObj, doCommonRequest, getValueByValue } from '@teamix/utils'; // 配置请求
|
8
8
|
|
9
|
-
var $request = function $request(requestConfig) {
|
10
|
-
|
11
|
-
var _field$data;
|
9
|
+
var $request = function $request(field, requestConfig, context) {
|
10
|
+
var _field$data;
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
}; // 配置上下文
|
12
|
+
var refresh = field === null || field === void 0 ? void 0 : (_field$data = field.data) === null || _field$data === void 0 ? void 0 : _field$data.refresh;
|
13
|
+
var beforeRequest = requestConfig.beforeRequest,
|
14
|
+
onSuccess = requestConfig.onSuccess;
|
15
|
+
var refreshResult = isPlainObj(refresh) ? refresh : {};
|
16
|
+
var beforeRequestResult = isFn(beforeRequest) ? beforeRequest(field, context) : {};
|
17
|
+
return doCommonRequest(_objectSpread(_objectSpread({}, requestConfig), {}, {
|
18
|
+
params: _objectSpread(_objectSpread(_objectSpread({}, requestConfig.params), beforeRequestResult), refreshResult),
|
19
|
+
beforeRequest: function beforeRequest() {
|
20
|
+
return beforeRequestResult;
|
21
|
+
},
|
22
|
+
onSuccess: isFn(onSuccess) ? function (res) {
|
23
|
+
return onSuccess(res, field, context);
|
24
|
+
} : onSuccess
|
25
|
+
}), context);
|
26
|
+
}; // 通用请求配置上下文
|
29
27
|
|
30
28
|
|
31
|
-
var $
|
29
|
+
var $common = function $common(services, requestConfig, context) {
|
32
30
|
return function (field) {
|
33
|
-
return services(field, context).then(function (res) {
|
34
|
-
return onComplete && onComplete(res, field, context);
|
31
|
+
return services(field, requestConfig, context).then(function (res) {
|
32
|
+
return requestConfig.onComplete && requestConfig.onComplete(res, field, context);
|
35
33
|
});
|
36
34
|
};
|
37
35
|
}; // 配置校验
|
38
36
|
|
39
37
|
|
40
|
-
var $validator = function $validator(services,
|
38
|
+
var $validator = function $validator(services, requestConfig, context) {
|
41
39
|
return function (value, rules, _ref) {
|
42
40
|
var field = _ref.field;
|
43
|
-
return services(field, context).then(function (res) {
|
44
|
-
return onComplete && onComplete(res, field, context);
|
41
|
+
return services(field, requestConfig, context).then(function (res) {
|
42
|
+
return requestConfig.onComplete && requestConfig.onComplete(res, field, context);
|
45
43
|
});
|
46
44
|
};
|
47
45
|
}; // 配置DataSource
|
48
46
|
|
49
47
|
|
50
|
-
var $dataSource = function $dataSource(services,
|
48
|
+
var $dataSource = function $dataSource(services, requestConfig, context) {
|
51
49
|
return function (field) {
|
52
50
|
field.setState({
|
53
51
|
loading: true,
|
54
52
|
readOnly: true
|
55
53
|
});
|
56
|
-
return services(field, context).then(function (res) {
|
54
|
+
return services(field, requestConfig, context).then(function (res) {
|
57
55
|
var isValueInDataSource = getValueByValue(res, field.value);
|
58
56
|
var clearValue = isValueInDataSource ? {} : {
|
59
57
|
value: undefined
|
@@ -63,7 +61,7 @@ var $dataSource = function $dataSource(services, onComplete, context) {
|
|
63
61
|
loading: false,
|
64
62
|
readOnly: false
|
65
63
|
}, clearValue));
|
66
|
-
return onComplete && onComplete(res, field, context);
|
64
|
+
return requestConfig.onComplete && requestConfig.onComplete(res, field, context);
|
67
65
|
}).catch(function () {
|
68
66
|
field.setState({
|
69
67
|
loading: false,
|
@@ -73,4 +71,4 @@ var $dataSource = function $dataSource(services, onComplete, context) {
|
|
73
71
|
};
|
74
72
|
};
|
75
73
|
|
76
|
-
export { $request, $
|
74
|
+
export { $request, $common, $dataSource, $validator };
|
package/es/form/typing.d.ts
CHANGED
@@ -58,12 +58,18 @@ export interface ProFormProps extends IFormLayoutProps {
|
|
58
58
|
};
|
59
59
|
children?: React.ReactNode;
|
60
60
|
initialValues?: AnyObject;
|
61
|
-
initialRequest?:
|
61
|
+
initialRequest?: ProFormRequestConfig;
|
62
62
|
previewTextPlaceholder?: ReactNode;
|
63
|
-
onChange?: (values: any,
|
63
|
+
onChange?: (values: any, fieldValue?: any, fieldName?: any) => any;
|
64
64
|
onSubmit?: ((values: any) => any) | CommonRequestConfig;
|
65
65
|
onSubmitFailed?: (feedbacks: IFormFeedback[]) => void;
|
66
66
|
}
|
67
|
+
export interface FilterProps extends ProFormProps {
|
68
|
+
form: FormType;
|
69
|
+
defaultFilterValue?: string;
|
70
|
+
onReset?: (payload?: any) => void;
|
71
|
+
onResetClick?: () => void;
|
72
|
+
}
|
67
73
|
export interface QueryFilterProps extends ProFormProps {
|
68
74
|
/**
|
69
75
|
* @deprecated triggerType已弃用
|
@@ -73,6 +79,9 @@ export interface QueryFilterProps extends ProFormProps {
|
|
73
79
|
expand?: boolean;
|
74
80
|
addonBefore?: ReactNode;
|
75
81
|
addonAfter?: ReactNode;
|
82
|
+
defaultFilterValue?: string;
|
83
|
+
formRef?: React.MutableRefObject<any>;
|
84
|
+
onInit?: (values: any) => boolean;
|
76
85
|
onFilter?: (values: any) => void;
|
77
86
|
onReset?: (payload?: any) => void;
|
78
87
|
}
|
package/es/form/utils.d.ts
CHANGED
@@ -15,14 +15,15 @@ declare const mapStatus: (props: any, field: any) => any;
|
|
15
15
|
declare const mapDataSource: (props: any, field: any) => any;
|
16
16
|
declare const mapMode: (props: any, field: any) => any;
|
17
17
|
/**
|
18
|
-
*
|
19
|
-
* @param prefix
|
20
|
-
* @
|
18
|
+
* 创建字段名称
|
19
|
+
* @param prefix 字段名称前缀,接收字段component名称,默认为FieldName
|
20
|
+
* @param index 字段索引
|
21
|
+
* @returns 字段唯一名称
|
21
22
|
*/
|
22
|
-
interface
|
23
|
-
(prefix?:
|
23
|
+
interface IGetFieldName {
|
24
|
+
(prefix: string, index?: number): string;
|
24
25
|
}
|
25
|
-
declare const
|
26
|
+
declare const getFieldName: IGetFieldName;
|
26
27
|
/**
|
27
28
|
* 将ProForm的key映射为formily的key,然后筛除掉无效的key/value
|
28
29
|
* @param obj
|
@@ -36,4 +37,4 @@ declare const mapSchemaName: (obj: any) => any;
|
|
36
37
|
* @returns 合并数组或合并其他值
|
37
38
|
*/
|
38
39
|
declare const mergeArrayValue: (arr: any[], v?: any) => any[];
|
39
|
-
export { mapSize, mapStatus, mapDataSource, mapMode, mergeArrayValue,
|
40
|
+
export { mapSize, mapStatus, mapDataSource, mapMode, mergeArrayValue, getFieldName, mapSchemaName, };
|
package/es/form/utils.js
CHANGED
@@ -113,9 +113,10 @@ var mapMode = function mapMode(props, field) {
|
|
113
113
|
});
|
114
114
|
};
|
115
115
|
|
116
|
-
var
|
117
|
-
var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '
|
118
|
-
|
116
|
+
var getFieldName = function getFieldName() {
|
117
|
+
var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'FieldName';
|
118
|
+
var index = arguments.length > 1 ? arguments[1] : undefined;
|
119
|
+
return "".concat(prefix, "-").concat(index);
|
119
120
|
};
|
120
121
|
/**
|
121
122
|
* 将ProForm的key映射为formily的key,然后筛除掉无效的key/value
|
@@ -168,4 +169,4 @@ var mergeArrayValue = function mergeArrayValue(arr, v) {
|
|
168
169
|
return [].concat(_toConsumableArray(arr), [v]);
|
169
170
|
};
|
170
171
|
|
171
|
-
export { mapSize, mapStatus, mapDataSource, mapMode, mergeArrayValue,
|
172
|
+
export { mapSize, mapStatus, mapDataSource, mapMode, mergeArrayValue, getFieldName, mapSchemaName };
|
package/es/index.d.ts
CHANGED
@@ -21,5 +21,5 @@ export * from './page-container';
|
|
21
21
|
export * from './page-header';
|
22
22
|
export * from './skeleton';
|
23
23
|
export * from './table';
|
24
|
-
declare const version = "1.2.
|
24
|
+
declare const version = "1.2.20";
|
25
25
|
export { version, ProAction, ProCard, ProField, ProForm, ProInfo, ProPageContainer, ProPageHeader, ProSkeleton, ProTable, hooks, nocode, templates, utils, };
|
package/es/index.js
CHANGED
@@ -27,7 +27,7 @@ export * from './page-header';
|
|
27
27
|
export * from './skeleton';
|
28
28
|
export * from './table'; // export * from './sidebar';
|
29
29
|
|
30
|
-
var version = '1.2.
|
30
|
+
var version = '1.2.20';
|
31
31
|
export { version, ProAction, ProCard, ProField, ProForm, ProInfo, // ProLayout,
|
32
32
|
ProPageContainer, ProPageHeader, ProSkeleton, ProTable, // ProSidebar,
|
33
33
|
hooks, nocode, templates, utils };
|
@@ -24,6 +24,7 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
24
24
|
|
25
25
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
26
26
|
|
27
|
+
// 表格项列筛选
|
27
28
|
import React, { useEffect, useMemo, useState } from 'react';
|
28
29
|
import TeamixIcon from '@teamix/icon';
|
29
30
|
import { Button, Dropdown, Menu } from '@alicloudfe/components';
|
@@ -0,0 +1,82 @@
|
|
1
|
+
var _excluded = ["className", "onChange", "total", "totalRender", "pageSize", "current", "pageSizeList", "pageSizeSelector", "type", "onPageSizeChange"];
|
2
|
+
|
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
|
+
|
5
|
+
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; }
|
6
|
+
|
7
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
8
|
+
|
9
|
+
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; }
|
10
|
+
|
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
|
+
|
13
|
+
// 自适应宽度的翻页器
|
14
|
+
import React from 'react';
|
15
|
+
import { Pagination } from '@alicloudfe/components';
|
16
|
+
import { useResponsiveProps } from '@teamix/hooks';
|
17
|
+
export default (function (props) {
|
18
|
+
var className = props.className,
|
19
|
+
onChange = props.onChange,
|
20
|
+
total = props.total,
|
21
|
+
totalRender = props.totalRender,
|
22
|
+
pageSize = props.pageSize,
|
23
|
+
current = props.current,
|
24
|
+
pageSizeList = props.pageSizeList,
|
25
|
+
pageSizeSelector = props.pageSizeSelector,
|
26
|
+
type = props.type,
|
27
|
+
onPageSizeChange = props.onPageSizeChange,
|
28
|
+
otherProps = _objectWithoutProperties(props, _excluded);
|
29
|
+
|
30
|
+
var _useResponsiveProps = useResponsiveProps([480, 580, 680], ['mini', 'small', 'simple', 'normal']),
|
31
|
+
responsiveProps = _useResponsiveProps.responsiveProps,
|
32
|
+
paginationWrapperRef = _useResponsiveProps.ref;
|
33
|
+
|
34
|
+
var commonPaginationProps = {
|
35
|
+
className: className,
|
36
|
+
onChange: onChange,
|
37
|
+
total: total,
|
38
|
+
pageSize: pageSize,
|
39
|
+
current: current,
|
40
|
+
shape: 'arrow-only',
|
41
|
+
pageSizeList: pageSizeList,
|
42
|
+
pageSizeSelector: pageSizeSelector,
|
43
|
+
pageSizePosition: 'end',
|
44
|
+
onPageSizeChange: onPageSizeChange
|
45
|
+
};
|
46
|
+
|
47
|
+
var renderPagination = function renderPagination() {
|
48
|
+
switch (responsiveProps) {
|
49
|
+
case 'normal':
|
50
|
+
return /*#__PURE__*/React.createElement(Pagination, _objectSpread(_objectSpread({}, commonPaginationProps), otherProps));
|
51
|
+
|
52
|
+
case 'simple':
|
53
|
+
return /*#__PURE__*/React.createElement(Pagination, _objectSpread(_objectSpread({}, commonPaginationProps), {}, {
|
54
|
+
pageShowCount: 3
|
55
|
+
}, otherProps));
|
56
|
+
|
57
|
+
case 'small':
|
58
|
+
return /*#__PURE__*/React.createElement(Pagination, _objectSpread(_objectSpread({}, commonPaginationProps), {}, {
|
59
|
+
pageSizeSelector: false,
|
60
|
+
type: "simple"
|
61
|
+
}, otherProps));
|
62
|
+
|
63
|
+
case 'mini':
|
64
|
+
return /*#__PURE__*/React.createElement(Pagination, _objectSpread(_objectSpread({}, commonPaginationProps), {}, {
|
65
|
+
pageSizeSelector: false,
|
66
|
+
type: "mini"
|
67
|
+
}, otherProps));
|
68
|
+
|
69
|
+
default:
|
70
|
+
return /*#__PURE__*/React.createElement(Pagination, _objectSpread(_objectSpread({}, commonPaginationProps), otherProps));
|
71
|
+
}
|
72
|
+
};
|
73
|
+
|
74
|
+
return (
|
75
|
+
/*#__PURE__*/
|
76
|
+
// 用于获取翻页器响应式 ref
|
77
|
+
React.createElement("div", {
|
78
|
+
ref: paginationWrapperRef,
|
79
|
+
className: "pagination-wrapper"
|
80
|
+
}, renderPagination())
|
81
|
+
);
|
82
|
+
});
|