@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.
Files changed (103) hide show
  1. package/dist/212.js +49 -49
  2. package/dist/pro.css +1 -1
  3. package/dist/pro.js +2173 -744
  4. package/dist/pro.min.css +1 -1
  5. package/dist/pro.min.js +1 -1
  6. package/es/actions/base.d.ts +2 -1
  7. package/es/actions/base.js +1 -1
  8. package/es/actions/danger-pop-confirm.d.ts +5 -0
  9. package/es/actions/danger-pop-confirm.js +10 -0
  10. package/es/actions/dialog.d.ts +1 -1
  11. package/es/actions/dialog.js +34 -36
  12. package/es/actions/index.d.ts +3 -0
  13. package/es/actions/index.js +10 -0
  14. package/es/actions/pop-confirm.d.ts +9 -0
  15. package/es/actions/pop-confirm.js +9 -0
  16. package/es/form/Components/LightFilter/componentMap.d.ts +2 -1
  17. package/es/form/Components/LightFilter/componentMap.js +4 -2
  18. package/es/form/Components/LightFilter/index.d.ts +1 -0
  19. package/es/form/Components/LightFilter/index.js +34 -16
  20. package/es/form/Components/LightFilter/index.scss +14 -4
  21. package/es/form/Filter/AdvancedFilter.d.ts +7 -0
  22. package/es/form/Filter/AdvancedFilter.js +113 -0
  23. package/es/form/Filter/LightFilter.d.ts +7 -0
  24. package/es/form/Filter/LightFilter.js +79 -0
  25. package/es/form/Filter/SimpleFilter.d.ts +7 -0
  26. package/es/form/Filter/SimpleFilter.js +74 -0
  27. package/es/form/Filter/index2.js +288 -235
  28. package/es/form/Filter/index2.scss +3 -0
  29. package/es/form/ProForm/index.js +11 -7
  30. package/es/form/ProForm/index.scss +3 -0
  31. package/es/form/ProForm/useFieldRequest.js +1 -8
  32. package/es/form/ProForm/useFormDisplayValues.js +4 -2
  33. package/es/form/SchemaForm/index.js +19 -11
  34. package/es/form/SchemaForm/initializeDataSource.d.ts +2 -2
  35. package/es/form/SchemaForm/initializeDataSource.js +4 -9
  36. package/es/form/SchemaForm/initializeRequest.d.ts +2 -2
  37. package/es/form/SchemaForm/initializeRequest.js +4 -10
  38. package/es/form/SchemaForm/initializeRules.d.ts +7 -1
  39. package/es/form/SchemaForm/initializeRules.js +9 -13
  40. package/es/form/SchemaForm/reactions.d.ts +5 -5
  41. package/es/form/SchemaForm/reactions.js +27 -29
  42. package/es/form/typing.d.ts +11 -2
  43. package/es/form/utils.d.ts +8 -7
  44. package/es/form/utils.js +5 -4
  45. package/es/index.d.ts +1 -1
  46. package/es/index.js +1 -1
  47. package/es/table/components/Filter/index.js +1 -0
  48. package/es/table/components/Pagination/index.d.ts +3 -0
  49. package/es/table/components/Pagination/index.js +82 -0
  50. package/es/table/components/ToolBar/FilterColumnIcon.js +18 -5
  51. package/es/table/components/ToolBar/index.scss +8 -2
  52. package/es/table/index.js +71 -18
  53. package/es/table/index.scss +7 -1
  54. package/es/table/typing.d.ts +5 -0
  55. package/lib/actions/base.d.ts +2 -1
  56. package/lib/actions/base.js +1 -1
  57. package/lib/actions/danger-pop-confirm.d.ts +5 -0
  58. package/lib/actions/danger-pop-confirm.js +22 -0
  59. package/lib/actions/dialog.d.ts +1 -1
  60. package/lib/actions/dialog.js +35 -36
  61. package/lib/actions/index.d.ts +3 -0
  62. package/lib/actions/index.js +12 -0
  63. package/lib/actions/pop-confirm.d.ts +9 -0
  64. package/lib/actions/pop-confirm.js +23 -0
  65. package/lib/form/Components/LightFilter/componentMap.d.ts +2 -1
  66. package/lib/form/Components/LightFilter/componentMap.js +6 -4
  67. package/lib/form/Components/LightFilter/index.d.ts +1 -0
  68. package/lib/form/Components/LightFilter/index.js +31 -14
  69. package/lib/form/Components/LightFilter/index.scss +14 -4
  70. package/lib/form/Filter/AdvancedFilter.d.ts +7 -0
  71. package/lib/form/Filter/AdvancedFilter.js +133 -0
  72. package/lib/form/Filter/LightFilter.d.ts +7 -0
  73. package/lib/form/Filter/LightFilter.js +99 -0
  74. package/lib/form/Filter/SimpleFilter.d.ts +7 -0
  75. package/lib/form/Filter/SimpleFilter.js +93 -0
  76. package/lib/form/Filter/index2.js +291 -234
  77. package/lib/form/Filter/index2.scss +3 -0
  78. package/lib/form/ProForm/index.js +10 -6
  79. package/lib/form/ProForm/index.scss +3 -0
  80. package/lib/form/ProForm/useFieldRequest.js +1 -9
  81. package/lib/form/ProForm/useFormDisplayValues.js +3 -1
  82. package/lib/form/SchemaForm/index.js +19 -10
  83. package/lib/form/SchemaForm/initializeDataSource.d.ts +2 -2
  84. package/lib/form/SchemaForm/initializeDataSource.js +4 -11
  85. package/lib/form/SchemaForm/initializeRequest.d.ts +2 -2
  86. package/lib/form/SchemaForm/initializeRequest.js +4 -11
  87. package/lib/form/SchemaForm/initializeRules.d.ts +7 -1
  88. package/lib/form/SchemaForm/initializeRules.js +9 -16
  89. package/lib/form/SchemaForm/reactions.d.ts +5 -5
  90. package/lib/form/SchemaForm/reactions.js +29 -31
  91. package/lib/form/typing.d.ts +11 -2
  92. package/lib/form/utils.d.ts +8 -7
  93. package/lib/form/utils.js +6 -5
  94. package/lib/index.d.ts +1 -1
  95. package/lib/index.js +1 -1
  96. package/lib/table/components/Pagination/index.d.ts +3 -0
  97. package/lib/table/components/Pagination/index.js +95 -0
  98. package/lib/table/components/ToolBar/FilterColumnIcon.js +18 -5
  99. package/lib/table/components/ToolBar/index.scss +8 -2
  100. package/lib/table/index.js +69 -17
  101. package/lib/table/index.scss +7 -1
  102. package/lib/table/typing.d.ts +5 -0
  103. package/package.json +3 -3
@@ -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, onFormValuesChange, registerValidateLocale, setValidateLanguage } from '@formily/core';
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('onChange');
82
- form.addEffects('onChange', function () {
83
- onFormValuesChange(function (form) {
84
- if (onChange) {
85
- onChange(toJS(form.values));
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
  }, []); // 配置国际化
@@ -180,6 +180,9 @@
180
180
  border: 0;
181
181
  }
182
182
  }
183
+ .#{$css-prefix}input-control:last-child {
184
+ padding-right: 0;
185
+ }
183
186
  }
184
187
 
185
188
  // 数组类组件添加按钮
@@ -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
- if (!isPlainObj(field.data)) {
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 (isPlainObj(values) && isLayoutValue(values)) {
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 { getRandomName, mapSchemaName } from '../utils';
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 ? getRandomName(component === null || component === void 0 ? void 0 : component.replace(/\./g, '')) : _newItem2$name,
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 proFormSchema = useMemo(function () {
248
+ var formilySchema = useMemo(function () {
241
249
  return {
242
250
  type: 'object',
243
251
  properties: formatSchema(schema)
244
252
  };
245
- }, [schema]); // console.log(proFormSchema);
253
+ }, [schema]); // console.log(formilySchema);
246
254
 
247
255
  return /*#__PURE__*/React.createElement(SchemaField, {
248
- schema: proFormSchema,
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 requestScopeName = getRandomName('$request');
13
- var dataSourceScopeName = getRandomName('$dataSource');
8
+ var requestConfigName = "$requestConfig_".concat(index);
14
9
  return {
15
- reactions: ["{{".concat(dataSourceScopeName, "(").concat(requestScopeName, ",").concat(requestConfig.onComplete, ",context)}}")],
16
- scope: (_scope = {}, _defineProperty(_scope, requestScopeName, $request(requestConfig)), _defineProperty(_scope, dataSourceScopeName, $dataSource), _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
- import { $request, $context } from '../SchemaForm/reactions';
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 _scope;
9
-
10
- var requestScopeName = getRandomName('$request');
11
- var contextScopeName = getRandomName('$context');
5
+ var requestConfigName = "$requestConfig_".concat(index);
12
6
  return {
13
- reactions: ["{{".concat(contextScopeName, "(").concat(requestScopeName, ",").concat(requestConfig.onComplete, ",context)}}")],
14
- scope: (_scope = {}, _defineProperty(_scope, requestScopeName, $request(requestConfig)), _defineProperty(_scope, contextScopeName, $context), _scope)
7
+ reactions: ["{{$common($request,".concat(requestConfigName, ",context)}}")],
8
+ scope: _defineProperty({}, requestConfigName, requestConfig)
15
9
  };
16
10
  }
17
11
 
@@ -1,5 +1,11 @@
1
1
  interface IInitializeRules {
2
- (rules?: any): any;
2
+ (rules?: any, index?: number): {
3
+ rules?: any;
4
+ reactions: any[];
5
+ scope: {
6
+ [x: string]: any;
7
+ };
8
+ };
3
9
  }
4
10
  declare const initializeRules: IInitializeRules;
5
11
  export default initializeRules;
@@ -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
- if (isPlainObj(rule === null || rule === void 0 ? void 0 : rule.validator)) {
27
- var _scope;
23
+ var subIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
28
24
 
29
- var validator = rule.validator;
30
- var requestScopeName = getRandomName('$request');
31
- var validatorScopeName = getRandomName('$validator');
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: "{{".concat(validatorScopeName, "(").concat(requestScopeName, ",").concat(validator.onComplete, ",context)}}")
30
+ validator: "{{$validator($request,".concat(requestConfigName, ",context)}}")
35
31
  }),
36
- scope: (_scope = {}, _defineProperty(_scope, requestScopeName, $request(validator)), _defineProperty(_scope, validatorScopeName, $validator), _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: (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 };
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
- return function (field, context) {
11
- var _field$data;
9
+ var $request = function $request(field, requestConfig, context) {
10
+ var _field$data;
12
11
 
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
- var beforeRequest = requestConfig.beforeRequest,
15
- onSuccess = requestConfig.onSuccess;
16
- var refreshResult = isPlainObj(refresh) ? refresh : {};
17
- var beforeRequestResult = isFn(beforeRequest) ? beforeRequest(field, context) : {};
18
- return doCommonRequest(_objectSpread(_objectSpread({}, requestConfig), {}, {
19
- params: _objectSpread(_objectSpread(_objectSpread({}, requestConfig.params), beforeRequestResult), refreshResult),
20
- beforeRequest: function beforeRequest() {
21
- return beforeRequestResult;
22
- },
23
- onSuccess: isFn(onSuccess) ? function (res) {
24
- return onSuccess(res, field, context);
25
- } : onSuccess
26
- }), context);
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 $context = function $context(services, onComplete, context) {
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, onComplete, context) {
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, onComplete, context) {
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, $context, $dataSource, $validator };
74
+ export { $request, $common, $dataSource, $validator };
@@ -58,12 +58,18 @@ export interface ProFormProps extends IFormLayoutProps {
58
58
  };
59
59
  children?: React.ReactNode;
60
60
  initialValues?: AnyObject;
61
- initialRequest?: CommonRequestConfig;
61
+ initialRequest?: ProFormRequestConfig;
62
62
  previewTextPlaceholder?: ReactNode;
63
- onChange?: (values: any, displayValues?: any) => 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
  }
@@ -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
- * 为未配置name的字段添加随机字段名称
19
- * @param prefix 随机字段名称前缀,默认为name
20
- * @returns 随机字段名称
18
+ * 创建字段名称
19
+ * @param prefix 字段名称前缀,接收字段component名称,默认为FieldName
20
+ * @param index 字段索引
21
+ * @returns 字段唯一名称
21
22
  */
22
- interface IGetRandomName {
23
- (prefix?: string): string;
23
+ interface IGetFieldName {
24
+ (prefix: string, index?: number): string;
24
25
  }
25
- declare const getRandomName: IGetRandomName;
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, getRandomName, mapSchemaName, };
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 getRandomName = function getRandomName() {
117
- var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'name';
118
- return "".concat(prefix, "_").concat(Math.floor(Math.random() * Math.pow(10, 18)));
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, getRandomName, mapSchemaName };
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.16";
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.16';
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,3 @@
1
+ import { PaginationProps } from '@alicloudfe/components/types/pagination';
2
+ declare const _default: (props: PaginationProps) => JSX.Element;
3
+ export default _default;
@@ -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
+ });