@teamix/pro 1.2.20 → 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 (42) hide show
  1. package/dist/pro.js +115 -106
  2. package/dist/pro.min.js +1 -1
  3. package/es/form/Components/LightFilter/componentMap.js +2 -1
  4. package/es/form/Components/LightFilter/index.js +15 -3
  5. package/es/form/Filter/index2.js +8 -8
  6. package/es/form/ProForm/index.js +5 -4
  7. package/es/form/ProForm/useFormDisplayValues.js +4 -2
  8. package/es/form/SchemaForm/index.js +16 -10
  9. package/es/form/SchemaForm/initializeDataSource.d.ts +2 -2
  10. package/es/form/SchemaForm/initializeDataSource.js +4 -9
  11. package/es/form/SchemaForm/initializeRequest.d.ts +2 -2
  12. package/es/form/SchemaForm/initializeRequest.js +4 -10
  13. package/es/form/SchemaForm/initializeRules.d.ts +7 -1
  14. package/es/form/SchemaForm/initializeRules.js +9 -13
  15. package/es/form/SchemaForm/reactions.d.ts +5 -5
  16. package/es/form/SchemaForm/reactions.js +27 -29
  17. package/es/form/typing.d.ts +1 -1
  18. package/es/form/utils.d.ts +8 -7
  19. package/es/form/utils.js +5 -4
  20. package/es/index.d.ts +1 -1
  21. package/es/index.js +1 -1
  22. package/es/table/components/Filter/index.js +1 -0
  23. package/lib/form/Components/LightFilter/componentMap.js +2 -1
  24. package/lib/form/Components/LightFilter/index.js +14 -3
  25. package/lib/form/Filter/index2.js +9 -8
  26. package/lib/form/ProForm/index.js +5 -5
  27. package/lib/form/ProForm/useFormDisplayValues.js +3 -1
  28. package/lib/form/SchemaForm/index.js +16 -9
  29. package/lib/form/SchemaForm/initializeDataSource.d.ts +2 -2
  30. package/lib/form/SchemaForm/initializeDataSource.js +4 -11
  31. package/lib/form/SchemaForm/initializeRequest.d.ts +2 -2
  32. package/lib/form/SchemaForm/initializeRequest.js +4 -11
  33. package/lib/form/SchemaForm/initializeRules.d.ts +7 -1
  34. package/lib/form/SchemaForm/initializeRules.js +9 -16
  35. package/lib/form/SchemaForm/reactions.d.ts +5 -5
  36. package/lib/form/SchemaForm/reactions.js +29 -31
  37. package/lib/form/typing.d.ts +1 -1
  38. package/lib/form/utils.d.ts +8 -7
  39. package/lib/form/utils.js +6 -5
  40. package/lib/index.d.ts +1 -1
  41. package/lib/index.js +1 -1
  42. package/package.json +1 -1
@@ -1,6 +1,7 @@
1
1
  var componentMap = {
2
2
  Radio: 'Select',
3
- Checkbox: 'Select'
3
+ Checkbox: 'Select',
4
+ CheckboxGroup: 'MultipleSelect'
4
5
  };
5
6
  var inputCategory = ['Input', 'Password', 'TextArea', 'NumberPicker', 'Percent', 'Money'];
6
7
  export { componentMap, inputCategory };
@@ -23,19 +23,31 @@ import TeamixIcon from '@teamix/icon';
23
23
  import cls from 'classnames';
24
24
  import { usePrefixCls } from '@teamix/utils';
25
25
  import { componentMap, inputCategory } from './componentMap';
26
- import './index.scss'; // 主激活区内容
26
+ import './index.scss';
27
+
28
+ var formatComponent = function formatComponent(schema) {
29
+ var _schema$enum;
30
+
31
+ var component = schema['x-component'];
32
+
33
+ if (component === 'Checkbox' && ((_schema$enum = schema['enum']) === null || _schema$enum === void 0 ? void 0 : _schema$enum.length)) {
34
+ component = 'CheckboxGroup';
35
+ }
36
+
37
+ return componentMap[component] || component;
38
+ }; // 主激活区内容
39
+
27
40
 
28
41
  var useMain = function useMain(active) {
29
42
  var schema = useFieldSchema();
30
43
  var main = [];
31
44
  schema.mapProperties(function (schema, name) {
32
- // console.log(schema.required); // 添加 *
33
45
  if (schema.name === active) {
34
46
  main.push({
35
47
  name: name,
36
48
  schema: _objectSpread(_objectSpread({}, schema), {}, {
37
49
  title: '',
38
- 'x-component': componentMap[schema['x-component']] || schema['x-component']
50
+ 'x-component': formatComponent(schema)
39
51
  })
40
52
  });
41
53
  }
@@ -39,6 +39,7 @@ import { getFormDisplayValues } from '../ProForm/useFormDisplayValues';
39
39
  import SimpleFilter from './SimpleFilter';
40
40
  import LightFilter from './LightFilter';
41
41
  import AdvancedFilter from './AdvancedFilter';
42
+ import debounce from 'lodash.debounce';
42
43
  import './index2.scss'; // 获取Schema是否包含默认值、异步默认值、必选校验等
43
44
 
44
45
  var getSpecialProps = function getSpecialProps(props) {
@@ -162,6 +163,10 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
162
163
  onFormReact(function (form) {
163
164
  _onFormInit(form, props, configFilterItem);
164
165
  });
166
+ onFormInputChange(function (form) {
167
+ // 主动修改高级筛选值
168
+ setCurrentForm('advanced');
169
+ });
165
170
  }
166
171
  });
167
172
  }, []);
@@ -304,11 +309,7 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
304
309
  return function (_x2) {
305
310
  return _ref5.apply(this, arguments);
306
311
  };
307
- }(), [onFilter, currentForm.current]); // 高级筛选Change
308
-
309
- var onAdvancedChange = useCallback(function () {
310
- setCurrentForm('advanced');
311
- }, []); // 高级搜索Filter
312
+ }(), [onFilter, currentForm.current]); // 高级搜索Filter
312
313
 
313
314
  var onAdvancedFilter = useCallback(function (values) {
314
315
  setCurrentForm('advanced');
@@ -353,7 +354,7 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
353
354
  }, /*#__PURE__*/React.createElement(LightFilter, _objectSpread(_objectSpread({}, otherProps), {}, {
354
355
  defaultFilterValue: defaultFilterValue,
355
356
  form: lightForm,
356
- onChange: onLightFilter
357
+ onChange: debounce(onLightFilter, 300)
357
358
  }))), /*#__PURE__*/React.createElement("div", {
358
359
  className: "".concat(prefixCls, "-toggle")
359
360
  }, /*#__PURE__*/React.createElement(Badge, {
@@ -374,7 +375,7 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
374
375
  className: "".concat(prefixCls, "-inline-form")
375
376
  }, /*#__PURE__*/React.createElement(SimpleFilter, _objectSpread(_objectSpread({}, otherProps), {}, {
376
377
  form: simpleForm,
377
- onChange: onSimpleFilter,
378
+ onChange: debounce(onSimpleFilter, 300),
378
379
  onSubmit: onSimpleFilter
379
380
  })))), addonAfter ? /*#__PURE__*/React.createElement("div", {
380
381
  className: "".concat(prefixCls, "-addonAfter")
@@ -407,7 +408,6 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
407
408
  onComplete: onInitialRequestComplete
408
409
  }) : undefined,
409
410
  form: advancedForm,
410
- onChange: onAdvancedChange,
411
411
  onSubmit: onAdvancedFilter,
412
412
  onReset: onAdvancedReset
413
413
  })))) : null);
@@ -21,7 +21,6 @@ import { mergeArrayValue } from '../utils';
21
21
  import useAutoSubmit from './useAutoSubmit';
22
22
  import useInitialRequest from './useInitialRequest';
23
23
  import validateLocale from '../locales/validate';
24
- import debounce from 'lodash.debounce';
25
24
  import './index.scss';
26
25
  registerValidateLocale(validateLocale);
27
26
  var ProForm = /*#__PURE__*/memo(function (_ref) {
@@ -81,9 +80,11 @@ var ProForm = /*#__PURE__*/memo(function (_ref) {
81
80
  useEffect(function () {
82
81
  form.removeEffects('onFieldValueChange');
83
82
  form.addEffects('onFieldValueChange', function () {
84
- onFieldValueChange('*', debounce(function (field, form) {
85
- onChange && onChange(toJS(form.values), toJS(field.value), field.props.name);
86
- }, 300));
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
  }, [form, onChange]); // 配置表单默认值
89
90
 
@@ -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
 
@@ -239,15 +245,15 @@ export default /*#__PURE__*/memo(function (_ref) {
239
245
  });
240
246
  return schemaProperties;
241
247
  }, [mergedScope]);
242
- var proFormSchema = useMemo(function () {
248
+ var formilySchema = useMemo(function () {
243
249
  return {
244
250
  type: 'object',
245
251
  properties: formatSchema(schema)
246
252
  };
247
- }, [schema]); // console.log(proFormSchema);
253
+ }, [schema]); // console.log(formilySchema);
248
254
 
249
255
  return /*#__PURE__*/React.createElement(SchemaField, {
250
- schema: proFormSchema,
256
+ schema: formilySchema,
251
257
  components: components,
252
258
  scope: mergedScope
253
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 };
@@ -60,7 +60,7 @@ export interface ProFormProps extends IFormLayoutProps {
60
60
  initialValues?: AnyObject;
61
61
  initialRequest?: ProFormRequestConfig;
62
62
  previewTextPlaceholder?: ReactNode;
63
- onChange?: (values: any, fieldValue?: any, fieldName?: string) => 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
  }
@@ -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.19";
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.19';
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';
@@ -6,7 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.inputCategory = exports.componentMap = void 0;
7
7
  var componentMap = {
8
8
  Radio: 'Select',
9
- Checkbox: 'Select'
9
+ Checkbox: 'Select',
10
+ CheckboxGroup: 'MultipleSelect'
10
11
  };
11
12
  exports.componentMap = componentMap;
12
13
  var inputCategory = ['Input', 'Password', 'TextArea', 'NumberPicker', 'Percent', 'Money'];
@@ -47,18 +47,29 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
47
47
 
48
48
  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; }
49
49
 
50
- // 主激活区内容
50
+ var formatComponent = function formatComponent(schema) {
51
+ var _schema$enum;
52
+
53
+ var component = schema['x-component'];
54
+
55
+ if (component === 'Checkbox' && ((_schema$enum = schema['enum']) === null || _schema$enum === void 0 ? void 0 : _schema$enum.length)) {
56
+ component = 'CheckboxGroup';
57
+ }
58
+
59
+ return _componentMap.componentMap[component] || component;
60
+ }; // 主激活区内容
61
+
62
+
51
63
  var useMain = function useMain(active) {
52
64
  var schema = (0, _react2.useFieldSchema)();
53
65
  var main = [];
54
66
  schema.mapProperties(function (schema, name) {
55
- // console.log(schema.required); // 添加 *
56
67
  if (schema.name === active) {
57
68
  main.push({
58
69
  name: name,
59
70
  schema: _objectSpread(_objectSpread({}, schema), {}, {
60
71
  title: '',
61
- 'x-component': _componentMap.componentMap[schema['x-component']] || schema['x-component']
72
+ 'x-component': formatComponent(schema)
62
73
  })
63
74
  });
64
75
  }