@teamix/pro 1.3.12 → 1.3.15

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 (67) hide show
  1. package/dist/pro.css +1 -1
  2. package/dist/pro.js +1520 -929
  3. package/dist/pro.min.css +1 -1
  4. package/dist/pro.min.js +1 -1
  5. package/es/actions/index.js +40 -4
  6. package/es/actions/index.scss +13 -0
  7. package/es/form/Filter/LightFilter.js +7 -5
  8. package/es/form/Filter/index.js +139 -40
  9. package/es/form/ProForm/index.d.ts +2 -3
  10. package/es/form/ProForm/index.js +47 -8
  11. package/es/form/ProForm/index.scss +7 -0
  12. package/es/form/ProForm/useFieldSchema.d.ts +7 -0
  13. package/es/form/ProForm/useFieldSchema.js +88 -0
  14. package/es/form/SchemaForm/index.js +2 -38
  15. package/es/form/SchemaForm/initializeDataSource.d.ts +1 -2
  16. package/es/form/SchemaForm/initializeDataSource.js +14 -19
  17. package/es/form/SchemaForm/initializeRequest.js +25 -26
  18. package/es/form/SchemaForm/initializeRules.d.ts +2 -2
  19. package/es/form/SchemaForm/initializeRules.js +30 -23
  20. package/es/form/SchemaForm/initializeSelectTable.js +80 -6
  21. package/es/form/SchemaForm/reactions.d.ts +4 -4
  22. package/es/form/SchemaForm/reactions.js +22 -21
  23. package/es/form/typing.d.ts +13 -6
  24. package/es/form/utils.d.ts +8 -1
  25. package/es/form/utils.js +45 -2
  26. package/es/index.d.ts +1 -1
  27. package/es/index.js +1 -1
  28. package/es/table/components/ToolBar/Fullscreen.d.ts +1 -1
  29. package/es/table/index.js +5 -3
  30. package/es/table/utils/pureColumnRender.d.ts +9 -0
  31. package/es/table/utils/pureColumnRender.js +201 -0
  32. package/es/table/utils/pureGenProColumnToColumn.d.ts +7 -0
  33. package/es/table/utils/pureGenProColumnToColumn.js +36 -0
  34. package/es/timeline/ProTimeLineItem/index.js +8 -5
  35. package/es/timeline/typing.d.ts +5 -0
  36. package/lib/actions/index.js +40 -4
  37. package/lib/actions/index.scss +13 -0
  38. package/lib/form/Filter/LightFilter.js +7 -6
  39. package/lib/form/Filter/index.js +139 -40
  40. package/lib/form/ProForm/index.d.ts +2 -3
  41. package/lib/form/ProForm/index.js +53 -7
  42. package/lib/form/ProForm/index.scss +7 -0
  43. package/lib/form/ProForm/useFieldSchema.d.ts +7 -0
  44. package/lib/form/ProForm/useFieldSchema.js +97 -0
  45. package/lib/form/SchemaForm/index.js +2 -45
  46. package/lib/form/SchemaForm/initializeDataSource.d.ts +1 -2
  47. package/lib/form/SchemaForm/initializeDataSource.js +14 -19
  48. package/lib/form/SchemaForm/initializeRequest.js +26 -26
  49. package/lib/form/SchemaForm/initializeRules.d.ts +2 -2
  50. package/lib/form/SchemaForm/initializeRules.js +30 -22
  51. package/lib/form/SchemaForm/initializeSelectTable.js +85 -6
  52. package/lib/form/SchemaForm/reactions.d.ts +4 -4
  53. package/lib/form/SchemaForm/reactions.js +22 -21
  54. package/lib/form/typing.d.ts +13 -6
  55. package/lib/form/utils.d.ts +8 -1
  56. package/lib/form/utils.js +47 -2
  57. package/lib/index.d.ts +1 -1
  58. package/lib/index.js +1 -1
  59. package/lib/table/components/ToolBar/Fullscreen.d.ts +1 -1
  60. package/lib/table/index.js +5 -3
  61. package/lib/table/utils/pureColumnRender.d.ts +9 -0
  62. package/lib/table/utils/pureColumnRender.js +215 -0
  63. package/lib/table/utils/pureGenProColumnToColumn.d.ts +7 -0
  64. package/lib/table/utils/pureGenProColumnToColumn.js +43 -0
  65. package/lib/timeline/ProTimeLineItem/index.js +8 -5
  66. package/lib/timeline/typing.d.ts +5 -0
  67. package/package.json +1 -1
@@ -32,13 +32,6 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
32
32
 
33
33
  import React, { memo, useCallback, useRef, useMemo } from 'react';
34
34
  import { createSchemaField } from '@formily/react';
35
- import { Affix } from '@alicloudfe/components';
36
- import { Upload, SelectTable, FormLayout, FormItem, ArrayCollapse, ArrayCards, ArrayItems, ArrayTable, Space, FormGrid, FormTab, FormCollapse, FormStep, Editable, FormDialog, FormDrawer, FormButtonGroup, Submit, Reset } from '@teamix/formily';
37
- import ProFieldComponents from '../Components/ProField';
38
- import { EditableDialog, EditableDrawer, EditablePopover } from '../Components/Editable';
39
- import FormGroup from '../Components/FormGroup';
40
- import LightFilter from '../Components/LightFilter';
41
- import Text from '../Components/Text/index';
42
35
  import adapterType from './adapterType';
43
36
  import adapterComponent from './adapterComponent';
44
37
  import adapterDecorator from './adapterDecorator';
@@ -64,39 +57,10 @@ export default /*#__PURE__*/memo(function (_ref) {
64
57
  var schema = _ref.schema,
65
58
  scope = _ref.scope,
66
59
  components = _ref.components;
67
- var schemaScopeRef = useRef({}); // 创建 SchemaField,添加内置组件
60
+ var schemaScopeRef = useRef({}); // 创建 SchemaField
68
61
 
69
62
  var SchemaField = useMemo(function () {
70
- return createSchemaField({
71
- components: _objectSpread(_objectSpread({}, ProFieldComponents), {}, {
72
- FormLayout: FormLayout,
73
- FormItem: FormItem,
74
- ArrayCollapse: ArrayCollapse,
75
- ArrayCards: ArrayCards,
76
- ArrayItems: ArrayItems,
77
- ArrayTable: ArrayTable,
78
- Space: Space,
79
- FormGrid: FormGrid,
80
- FormTab: FormTab,
81
- FormCollapse: FormCollapse,
82
- FormStep: FormStep,
83
- Editable: Editable,
84
- FormDialogFooter: FormDialog.Footer,
85
- FormDrawerFooter: FormDrawer.Footer,
86
- FormButtonGroup: FormButtonGroup,
87
- Submit: Submit,
88
- Reset: Reset,
89
- EditableDialog: EditableDialog,
90
- EditableDrawer: EditableDrawer,
91
- EditablePopover: EditablePopover,
92
- FormGroup: FormGroup,
93
- Upload: Upload,
94
- SelectTable: SelectTable,
95
- Affix: Affix,
96
- LightFilter: LightFilter,
97
- Text: Text
98
- })
99
- });
63
+ return createSchemaField();
100
64
  }, []); // 格式化 schema
101
65
 
102
66
  var formatSchema = useCallback(function (schema) {
@@ -1,6 +1,5 @@
1
- import type { ProFormRequestConfig } from '../typing';
2
1
  interface IInitializeDataSource {
3
- (requestConfig?: ProFormRequestConfig | any, suffix?: string): {
2
+ (requestConfig: any, suffix: string): {
4
3
  dataSource?: any[];
5
4
  reactions: any[];
6
5
  scope: {
@@ -1,27 +1,22 @@
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
-
3
- import { isPlainObj } from '@teamix/utils';
1
+ import { initializeRequestExpression } from '../utils';
4
2
 
5
3
  var initializeDataSource = function initializeDataSource(dataSource, suffix) {
6
- if (isPlainObj(dataSource)) {
7
- var _requestConfig$extraC;
4
+ var _dataSource$extraConf;
8
5
 
9
- var requestConfig = dataSource;
10
- var requestConfigName = "$requestConfig_".concat(suffix);
11
- return {
12
- reactions: ["{{$dataSource($request,".concat(requestConfigName, ",context)}}")],
13
- scope: _defineProperty({}, requestConfigName, requestConfig),
14
- // dataSource请求时,默认配置字段为只读
15
- data: {
16
- readOnlyOnLoading: (requestConfig === null || requestConfig === void 0 ? void 0 : (_requestConfig$extraC = requestConfig.extraConfig) === null || _requestConfig$extraC === void 0 ? void 0 : _requestConfig$extraC.readOnly) !== false
17
- }
18
- };
19
- }
6
+ var _initializeRequestExp = initializeRequestExpression(dataSource, '$dataSource', suffix),
7
+ expression = _initializeRequestExp.expression,
8
+ scope = _initializeRequestExp.scope;
20
9
 
21
- return {
22
- dataSource: dataSource,
10
+ return expression ? {
11
+ reactions: [expression],
12
+ scope: scope,
13
+ data: {
14
+ readOnlyOnLoading: (dataSource === null || dataSource === void 0 ? void 0 : (_dataSource$extraConf = dataSource.extraConfig) === null || _dataSource$extraConf === void 0 ? void 0 : _dataSource$extraConf.readOnly) !== false
15
+ }
16
+ } : {
23
17
  reactions: [],
24
- scope: {}
18
+ scope: {},
19
+ dataSource: dataSource
25
20
  };
26
21
  };
27
22
 
@@ -17,37 +17,36 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
17
17
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
18
18
 
19
19
  import { isArr } from '@teamix/utils';
20
+ import { initializeRequestExpression } from '../utils';
20
21
 
21
- var initializeRequest = function initializeRequest(requestConfig, suffix) {
22
- if (requestConfig) {
23
- if (isArr(requestConfig)) {
24
- var reactionsMap = [];
25
- var scopeMap = {};
26
- requestConfig.forEach(function (item, index) {
27
- var _initializeRequest = initializeRequest(item, "".concat(suffix).concat(index)),
28
- reactions = _initializeRequest.reactions,
29
- scope = _initializeRequest.scope;
30
-
31
- reactionsMap = [].concat(_toConsumableArray(reactionsMap), _toConsumableArray(reactions));
32
- scopeMap = _objectSpread(_objectSpread({}, scopeMap), scope);
33
- });
34
- return {
35
- reactions: reactionsMap,
36
- scope: scopeMap
37
- };
38
- } else {
39
- var requestConfigName = "$requestConfig_".concat(suffix);
40
- return {
41
- reactions: ["{{$common($request,".concat(requestConfigName, ",context)}}")],
42
- scope: _defineProperty({}, requestConfigName, requestConfig)
43
- };
44
- }
45
- }
22
+ var initializeItem = function initializeItem(request, suffix) {
23
+ var _initializeRequestExp = initializeRequestExpression(request, '$common', suffix),
24
+ expression = _initializeRequestExp.expression,
25
+ scope = _initializeRequestExp.scope;
46
26
 
47
- return {
27
+ return expression ? {
28
+ reactions: [expression],
29
+ scope: scope
30
+ } : {
48
31
  reactions: [],
49
32
  scope: {}
50
33
  };
51
34
  };
52
35
 
36
+ var initializeRequest = function initializeRequest(request, suffix) {
37
+ if (isArr(request)) {
38
+ return request.reduce(function (prev, current, index) {
39
+ var result = initializeItem(current, "".concat(suffix, "_").concat(index));
40
+ prev.reactions = [].concat(_toConsumableArray(prev.reactions), _toConsumableArray(result.reactions));
41
+ prev.scope = _objectSpread(_objectSpread({}, prev.scope), result.scope);
42
+ return prev;
43
+ }, {
44
+ reactions: [],
45
+ scope: {}
46
+ });
47
+ }
48
+
49
+ return initializeItem(request, suffix);
50
+ };
51
+
53
52
  export default initializeRequest;
@@ -1,7 +1,7 @@
1
1
  interface IInitializeRules {
2
- (rules?: any, suffix?: string): {
2
+ (rules: any, suffix: string): {
3
3
  rules?: any;
4
- reactions: any[];
4
+ reactions?: any[];
5
5
  scope: {
6
6
  [x: string]: any;
7
7
  };
@@ -1,3 +1,5 @@
1
+ var _excluded = ["validator"];
2
+
1
3
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
4
 
3
5
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -16,32 +18,37 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
16
18
 
17
19
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
18
20
 
19
- import { isArr, isPlainObj } from '@teamix/utils';
21
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
20
22
 
21
- var initializeRules = function initializeRules(rules, suffix) {
22
- var initializeValidator = function initializeValidator(rule) {
23
- var index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
24
-
25
- if (isPlainObj(rule === null || rule === void 0 ? void 0 : rule.validator)) {
26
- var requestConfig = rule.validator;
27
- var requestConfigName = "$requestConfig_".concat(suffix).concat(index);
28
- return {
29
- rules: _objectSpread(_objectSpread({}, rule), {}, {
30
- validator: "{{$validator($request,".concat(requestConfigName, ",context)}}")
31
- }),
32
- scope: _defineProperty({}, requestConfigName, requestConfig)
33
- };
34
- }
35
-
36
- return {
37
- rules: rule,
38
- scope: {}
39
- };
23
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
24
+
25
+ import { isArr } from '@teamix/utils';
26
+ import { initializeRequestExpression } from '../utils';
27
+
28
+ var initializeRule = function initializeRule(rule, suffix) {
29
+ var _ref = rule || {},
30
+ validator = _ref.validator,
31
+ rest = _objectWithoutProperties(_ref, _excluded);
32
+
33
+ var _initializeRequestExp = initializeRequestExpression(validator, '$validator', suffix),
34
+ expression = _initializeRequestExp.expression,
35
+ scope = _initializeRequestExp.scope;
36
+
37
+ return expression ? {
38
+ scope: scope,
39
+ rules: _objectSpread({
40
+ validator: expression
41
+ }, rest)
42
+ } : {
43
+ scope: {},
44
+ rules: rule
40
45
  };
46
+ };
41
47
 
48
+ var initializeRules = function initializeRules(rules, suffix) {
42
49
  if (isArr(rules)) {
43
- return rules.reduce(function (prev, current, subIndex) {
44
- var result = initializeValidator(current, subIndex);
50
+ return rules.reduce(function (prev, current, index) {
51
+ var result = initializeRule(current, "".concat(suffix, "_").concat(index));
45
52
  prev.rules = [].concat(_toConsumableArray(prev.rules), [result.rules]);
46
53
  prev.scope = _objectSpread(_objectSpread({}, prev.scope), result.scope);
47
54
  return prev;
@@ -51,7 +58,7 @@ var initializeRules = function initializeRules(rules, suffix) {
51
58
  });
52
59
  }
53
60
 
54
- return initializeValidator(rules);
61
+ return initializeRule(rules, suffix);
55
62
  };
56
63
 
57
64
  export default initializeRules;
@@ -1,4 +1,4 @@
1
- var _excluded = ["name", "title", "children"];
1
+ var _excluded = ["name", "children", "props"];
2
2
 
3
3
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
4
 
@@ -10,25 +10,99 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
10
10
 
11
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
12
 
13
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
14
+
15
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
16
+
17
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
18
+
19
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
20
+
21
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
22
+
23
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
24
+
25
+ import cls from 'classnames';
26
+ import { usePrefixCls, isStr, isPlainObj, isArr } from '@teamix/utils';
27
+ import pureGenProColumnToColumn from '../../table/utils/pureGenProColumnToColumn';
28
+ /**
29
+ * 将可被 ProForm 识别的上下文转换为仅被 ProTable 识别的上下文
30
+ * @param value
31
+ * @returns
32
+ */
33
+
34
+ var adapterContext = function adapterContext(value) {
35
+ if (isStr(value)) {
36
+ var contextReg = /^\{\{.*?\}\}$/;
37
+
38
+ if (contextReg.test(value)) {
39
+ return "\0".concat(value, "\0");
40
+ }
41
+
42
+ return value;
43
+ }
44
+
45
+ if (isPlainObj(value)) {
46
+ var temp = {};
47
+ Object.entries(value).forEach(function (_ref) {
48
+ var _ref2 = _slicedToArray(_ref, 2),
49
+ key = _ref2[0],
50
+ val = _ref2[1];
51
+
52
+ temp[key] = adapterContext(val);
53
+ });
54
+ return temp;
55
+ }
56
+
57
+ if (isArr(value)) {
58
+ return value.map(function (item) {
59
+ return adapterContext(item);
60
+ });
61
+ }
62
+
63
+ return value;
64
+ };
65
+
13
66
  var initializeTableColumn = function initializeTableColumn(item) {
14
67
  var name = item.name,
15
- title = item.title,
16
68
  children = item.children,
69
+ props = item.props,
17
70
  otherProps = _objectWithoutProperties(item, _excluded);
18
71
 
19
72
  return {
20
73
  name: name,
21
- title: title,
22
74
  component: 'SelectTable.Column',
23
- children: children,
24
- props: _objectSpread({}, otherProps)
75
+ children: children === null || children === void 0 ? void 0 : children.map(function (item) {
76
+ return initializeTableColumn(item);
77
+ }),
78
+ props: _objectSpread(_objectSpread({}, otherProps), props)
25
79
  };
26
80
  };
27
81
 
28
82
  var initialize = function initialize(item) {
83
+ var _props$columns;
84
+
29
85
  var _item$children = item.children,
30
- children = _item$children === void 0 ? [] : _item$children;
86
+ children = _item$children === void 0 ? [] : _item$children,
87
+ props = item.props;
88
+ var prefixCls = usePrefixCls('', {
89
+ prefix: 'teamix-pro-form-select-table-column-tree'
90
+ });
91
+ var columns = props === null || props === void 0 ? void 0 : (_props$columns = props.columns) === null || _props$columns === void 0 ? void 0 : _props$columns.map(function (value, index) {
92
+ var column = adapterContext(value);
93
+
94
+ if ((props === null || props === void 0 ? void 0 : props.isTree) && index === 0) {
95
+ return _objectSpread(_objectSpread({}, column), {}, {
96
+ className: cls(column.className, prefixCls)
97
+ });
98
+ }
99
+
100
+ return column;
101
+ });
31
102
  return _objectSpread(_objectSpread({}, item), {}, {
103
+ props: _objectSpread(_objectSpread({}, props), {}, {
104
+ columns: columns && pureGenProColumnToColumn(columns)
105
+ }),
32
106
  children: children.map(function (item) {
33
107
  return initializeTableColumn(item);
34
108
  })
@@ -1,6 +1,6 @@
1
1
  import type { ProFormRequestConfig } from '../typing';
2
- declare const $request: (field: any, { extraConfig, ...requestConfig }: ProFormRequestConfig, context: any, type: 'request' | 'validator' | 'dataSource') => 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;
2
+ declare const $request: (field: any, context: any, { extraConfig, onComplete, ...rest }: ProFormRequestConfig, type: 'request' | 'validator' | 'dataSource') => Promise<unknown>;
3
+ declare const $common: (services: any, context: any, requestConfig: ProFormRequestConfig) => (field: any) => any;
4
+ declare const $validator: (services: any, context: any, requestConfig: ProFormRequestConfig) => (value: any, rules: any, { field }: any) => any;
5
+ declare const $dataSource: (services: any, context: any, requestConfig: ProFormRequestConfig) => (field: any) => any;
6
6
  export { $request, $common, $dataSource, $validator };
@@ -1,4 +1,4 @@
1
- var _excluded = ["extraConfig"];
1
+ var _excluded = ["extraConfig", "onComplete"];
2
2
 
3
3
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
4
 
@@ -12,24 +12,23 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
12
12
 
13
13
  import { isFn, isPlainObj, doCommonRequest, getValueByValue } from '@teamix/utils'; // 配置请求
14
14
 
15
- var $request = function $request(field, _ref, context, type) {
15
+ var $request = function $request(field, context, _ref, type) {
16
16
  var _field$data;
17
17
 
18
18
  var extraConfig = _ref.extraConfig,
19
- requestConfig = _objectWithoutProperties(_ref, _excluded);
19
+ onComplete = _ref.onComplete,
20
+ rest = _objectWithoutProperties(_ref, _excluded);
20
21
 
22
+ var requestConfig = rest;
21
23
  var params = requestConfig.params,
22
24
  beforeRequest = requestConfig.beforeRequest,
23
25
  formatResult = requestConfig.formatResult,
24
26
  onSuccess = requestConfig.onSuccess;
25
- var beforeRequestResult = isFn(beforeRequest) ? beforeRequest(field, context) : {};
26
- /**
27
- * 主动触发的请求刷新
28
- */
29
- // 触发所有配置的请求
27
+ var beforeRequestResult = isFn(beforeRequest) ? beforeRequest(field, context) : {}; // 通过字段 data 的 refresh 主动触发的请求刷新
30
28
 
31
29
  var refresh = (_field$data = field.data) === null || _field$data === void 0 ? void 0 : _field$data.refresh;
32
- var refreshResult = isPlainObj(refresh) ? refresh : {};
30
+ var refreshResult = isPlainObj(refresh) ? refresh : {}; // 执行通用数据请求
31
+
33
32
  return doCommonRequest(_objectSpread(_objectSpread({}, requestConfig), {}, {
34
33
  params: _objectSpread(_objectSpread(_objectSpread({}, params), beforeRequestResult), refreshResult),
35
34
  beforeRequest: function beforeRequest() {
@@ -45,36 +44,38 @@ var $request = function $request(field, _ref, context, type) {
45
44
  }; // 通用请求配置上下文
46
45
 
47
46
 
48
- var $common = function $common(services, requestConfig, context) {
47
+ var $common = function $common(services, context, requestConfig) {
49
48
  return function (field) {
50
- return services(field, requestConfig, context, 'request').then(function (res) {
49
+ return services(field, context, requestConfig, 'request').then(function (res) {
51
50
  var _requestConfig$onComp;
52
51
 
53
- return (_requestConfig$onComp = requestConfig.onComplete) === null || _requestConfig$onComp === void 0 ? void 0 : _requestConfig$onComp.call(requestConfig, res, field, context);
52
+ return requestConfig === null || requestConfig === void 0 ? void 0 : (_requestConfig$onComp = requestConfig.onComplete) === null || _requestConfig$onComp === void 0 ? void 0 : _requestConfig$onComp.call(requestConfig, res, field, context);
54
53
  });
55
54
  };
56
55
  }; // 配置校验
57
56
 
58
57
 
59
- var $validator = function $validator(services, requestConfig, context) {
58
+ var $validator = function $validator(services, context, requestConfig) {
60
59
  return function (value, rules, _ref2) {
61
60
  var field = _ref2.field;
62
- return services(field, requestConfig, context, 'validator').then(function (res) {
63
- var _requestConfig$onComp2;
64
-
65
- return (_requestConfig$onComp2 = requestConfig.onComplete) === null || _requestConfig$onComp2 === void 0 ? void 0 : _requestConfig$onComp2.call(requestConfig, res, field, context);
61
+ return services(field, context, requestConfig, 'validator').then(function (res) {
62
+ if (requestConfig === null || requestConfig === void 0 ? void 0 : requestConfig.onComplete) {
63
+ return requestConfig.onComplete(res, field, context);
64
+ } else {
65
+ return res;
66
+ }
66
67
  });
67
68
  };
68
69
  }; // 配置DataSource
69
70
 
70
71
 
71
- var $dataSource = function $dataSource(services, requestConfig, context) {
72
+ var $dataSource = function $dataSource(services, context, requestConfig) {
72
73
  return function (field) {
73
74
  field.setState({
74
75
  loading: true
75
76
  });
76
- return services(field, requestConfig, context, 'dataSource').then(function (res) {
77
- var _requestConfig$extraC, _requestConfig$onComp3;
77
+ return services(field, context, requestConfig, 'dataSource').then(function (res) {
78
+ var _requestConfig$extraC, _requestConfig$onComp2;
78
79
 
79
80
  var isValueInDataSource = getValueByValue(res, field.value);
80
81
  var clearResult = !isValueInDataSource && (requestConfig === null || requestConfig === void 0 ? void 0 : (_requestConfig$extraC = requestConfig.extraConfig) === null || _requestConfig$extraC === void 0 ? void 0 : _requestConfig$extraC.clearInvalidValue) !== false ? {
@@ -84,7 +85,7 @@ var $dataSource = function $dataSource(services, requestConfig, context) {
84
85
  dataSource: res,
85
86
  loading: false
86
87
  }, clearResult));
87
- return (_requestConfig$onComp3 = requestConfig.onComplete) === null || _requestConfig$onComp3 === void 0 ? void 0 : _requestConfig$onComp3.call(requestConfig, res, field, context);
88
+ return requestConfig === null || requestConfig === void 0 ? void 0 : (_requestConfig$onComp2 = requestConfig.onComplete) === null || _requestConfig$onComp2 === void 0 ? void 0 : _requestConfig$onComp2.call(requestConfig, res, field, context);
88
89
  }).catch(function () {
89
90
  field.setState({
90
91
  loading: false
@@ -1,7 +1,7 @@
1
1
  import type { ReactNode } from 'react';
2
2
  import type { IFormFeedback, Form as FormType, FieldPatternTypes } from '@formily/core';
3
3
  import type { IFormLayoutProps } from '@teamix/formily';
4
- import { CommonRequestConfig } from '@teamix/utils';
4
+ import type { CommonRequestConfig } from '@teamix/utils';
5
5
  import React from 'react';
6
6
  interface AnyObject {
7
7
  [propName: string]: any;
@@ -18,12 +18,16 @@ declare type IBaseComponent = 'Input' | 'Password' | 'TextArea' | 'NumberPicker'
18
18
  declare type IButtonComponent = 'Submit' | 'Reset';
19
19
  declare type IComboComponent = 'ArrayCards' | 'ArrayCards.Addition' | 'ArrayCards.Remove' | 'ArrayCards.MoveUp' | 'ArrayCards.MoveDown' | 'ArrayCards.Index' | 'ArrayCollapse' | 'ArrayCollapse.CollapsePanel' | 'ArrayCollapse.Addition' | 'ArrayCollapse.Remove' | 'ArrayCollapse.MoveUp' | 'ArrayCollapse.MoveDown' | 'ArrayCollapse.Index' | 'ArrayTable' | 'ArrayTable.Column' | 'ArrayTable.SortHandle' | 'ArrayTable.Addition' | 'ArrayTable.Remove' | 'ArrayTable.MoveDown' | 'ArrayTable.MoveUp' | 'ArrayTable.Index' | 'ArrayItems' | 'ArrayItems.Item' | 'ArrayItems.SortHandle' | 'ArrayItems.Addition' | 'ArrayItems.Remove' | 'ArrayItems.MoveDown' | 'ArrayItems.MoveUp' | 'ArrayItems.Index' | 'Editable' | 'Editable.Popover' | 'Editable.Dialog' | 'Editable.Drawer';
20
20
  declare type ILayoutComponent = 'FormFlex' | 'FormGrid' | 'FormGroup' | 'FormGroup.GroupPanel' | 'Search' | 'Search.SearchPanel' | 'FormTab' | 'FormTab.TabPane' | 'FormStep' | 'FormStep.StepPane' | 'FormCollapse' | 'FormCollapse.CollapsePanel' | 'FormButtonGroup' | 'FormDialog' | 'FormDrawer' | 'FormDialog.Footer' | 'FormDrawer.Footer';
21
- export interface ProFormRequestConfig extends CommonRequestConfig {
21
+ export interface ProFormCommonRequestConfig extends CommonRequestConfig {
22
22
  beforeRequest?: (field?: any, context?: any) => any;
23
23
  formatResult?: (res?: any, field?: any, context?: any) => any;
24
24
  onSuccess?: (res?: any, field?: any, context?: any) => any;
25
- onComplete?: (res?: any, field?: any, context?: any) => any;
25
+ }
26
+ export interface ProFormRequestConfig extends Omit<ProFormCommonRequestConfig, 'url'> {
27
+ url?: string;
28
+ customRequest?: (field?: any, context?: any) => Promise<any>;
26
29
  extraConfig?: AnyObject;
30
+ onComplete?: (res?: any, field?: any, context?: any) => any;
27
31
  }
28
32
  export interface ProFormSchemaItem {
29
33
  type?: string;
@@ -56,7 +60,7 @@ export interface ProFormSchemaItem {
56
60
  export declare type ProFormSchema = ProFormSchemaItem[];
57
61
  export interface ProFormProps extends IFormLayoutProps {
58
62
  form?: FormType | false;
59
- schema: ProFormSchema;
63
+ schema?: ProFormSchema;
60
64
  scope?: any;
61
65
  context?: any;
62
66
  components?: {
@@ -64,7 +68,7 @@ export interface ProFormProps extends IFormLayoutProps {
64
68
  };
65
69
  children?: React.ReactNode;
66
70
  initialValues?: AnyObject;
67
- initialRequest?: ProFormRequestConfig;
71
+ initialRequest?: ProFormCommonRequestConfig;
68
72
  previewTextPlaceholder?: ReactNode;
69
73
  validateFirst?: boolean;
70
74
  onChangeType?: 'form';
@@ -73,6 +77,9 @@ export interface ProFormProps extends IFormLayoutProps {
73
77
  onSubmitFailed?: (feedbacks: IFormFeedback[]) => void;
74
78
  onInitialComplete?: (form: FormType) => void;
75
79
  }
80
+ export declare type ComposedProForm = React.FC<ProFormProps> & {
81
+ Field?: React.FC<any>;
82
+ };
76
83
  export interface FilterProps extends ProFormProps {
77
84
  form: FormType;
78
85
  defaultFilterValue?: string;
@@ -118,7 +125,7 @@ export interface QueryFilterProps extends ProFormProps {
118
125
  /** onChange事件的防抖时间 */
119
126
  filterDebounce?: number;
120
127
  /** 表单初始化(含异步默认值)后回调函数 */
121
- onInit?: (values: any) => boolean;
128
+ onInit?: (values: any) => void;
122
129
  /** 表单筛选回调函数 */
123
130
  onFilter?: (values: any) => void;
124
131
  /** 表单重置回调函数 */
@@ -37,4 +37,11 @@ declare const mapSchemaName: (obj: any) => any;
37
37
  * @returns 合并数组或合并其他值
38
38
  */
39
39
  declare const mergeArrayValue: (arr: any[], v?: any) => any[];
40
- export { mapSize, mapStatus, mapDataSource, mapMode, mergeArrayValue, getFieldName, mapSchemaName, };
40
+ /**
41
+ * 初始化请求配置为表达式
42
+ * @param config 请求配置
43
+ * @param suffix scope名称后缀
44
+ * @returns 表达式和scope上下文
45
+ */
46
+ declare const initializeRequestExpression: (config?: any, mode?: string | undefined, suffix?: string | undefined) => any;
47
+ export { mapSize, mapStatus, mapDataSource, mapMode, mergeArrayValue, getFieldName, mapSchemaName, initializeRequestExpression, };
package/es/form/utils.js CHANGED
@@ -1,3 +1,9 @@
1
+ var _excluded = ["customRequest"];
2
+
3
+ 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; }
4
+
5
+ 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; }
6
+
1
7
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
8
 
3
9
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -26,7 +32,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
26
32
 
27
33
  import { isVoidField } from '@formily/core';
28
34
  import { useFormLayout, useFormShallowLayout } from '@teamix/formily';
29
- import { isArr, isObj, getValueByValue } from '@teamix/utils';
35
+ import { isArr, isObj, getValueByValue, isPlainObj, isFn } from '@teamix/utils';
30
36
  import schemaNameMap from './schemaNameMap';
31
37
  /**
32
38
  * 映射字段size,主要是default转medium
@@ -177,5 +183,42 @@ var mergeArrayValue = function mergeArrayValue(arr, v) {
177
183
 
178
184
  return [].concat(_toConsumableArray(arr), [v]);
179
185
  };
186
+ /**
187
+ * 初始化请求配置为表达式
188
+ * @param config 请求配置
189
+ * @param suffix scope名称后缀
190
+ * @returns 表达式和scope上下文
191
+ */
192
+
193
+
194
+ var initializeRequestExpression = function initializeRequestExpression(config, mode, suffix) {
195
+ var schema = {};
196
+
197
+ if (isPlainObj(config)) {
198
+ var customRequest = config.customRequest,
199
+ requestConfig = _objectWithoutProperties(config, _excluded);
200
+
201
+ var requestConfigName = "$requestConfig_".concat(suffix);
202
+
203
+ if (isFn(customRequest)) {
204
+ var _scope;
205
+
206
+ // 自定义请求方法 customRequest
207
+ var customRequestName = "$customRequest_".concat(suffix);
208
+ schema = {
209
+ expression: "{{".concat(mode, "(").concat(customRequestName, ",context,").concat(requestConfigName, ")}}"),
210
+ scope: (_scope = {}, _defineProperty(_scope, customRequestName, customRequest), _defineProperty(_scope, requestConfigName, requestConfig), _scope)
211
+ };
212
+ } else {
213
+ // pro 通用数据请求 $request
214
+ schema = {
215
+ expression: "{{".concat(mode, "($request,context,").concat(requestConfigName, ")}}"),
216
+ scope: _defineProperty({}, requestConfigName, requestConfig)
217
+ };
218
+ }
219
+ }
220
+
221
+ return schema;
222
+ };
180
223
 
181
- export { mapSize, mapStatus, mapDataSource, mapMode, mergeArrayValue, getFieldName, mapSchemaName };
224
+ export { mapSize, mapStatus, mapDataSource, mapMode, mergeArrayValue, getFieldName, mapSchemaName, initializeRequestExpression };
package/es/index.d.ts CHANGED
@@ -26,5 +26,5 @@ export * from './table';
26
26
  export * from './sidebar';
27
27
  export * from './utils';
28
28
  export * from './timeline';
29
- declare const version = "1.3.12";
29
+ declare const version = "1.3.15";
30
30
  export { version, ProAction, ProCard, ProField, ProForm, ProInfo, ProPageContainer, ProPageHeader, ProSkeleton, ProTable, ProSidebar, ProTimeline, hooks, nocode, templates, utils, };
package/es/index.js CHANGED
@@ -31,6 +31,6 @@ export * from './sidebar';
31
31
  export * from './utils'; // export * from './sidebar';
32
32
 
33
33
  export * from './timeline';
34
- var version = '1.3.12';
34
+ var version = '1.3.15';
35
35
  export { version, ProAction, ProCard, ProField, ProForm, ProInfo, // ProLayout,
36
36
  ProPageContainer, ProPageHeader, ProSkeleton, ProTable, ProSidebar, ProTimeline, hooks, nocode, templates, utils };
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import './index.scss';
3
3
  import { ProTableActionType } from '../../typing';
4
4
  declare type ProTableFullScreenProps = {
5
- children: React.ReactNode;
5
+ children: (isFullScreen: boolean) => React.ReactNode | React.ReactNode;
6
6
  visible: boolean;
7
7
  actionRef: React.MutableRefObject<ProTableActionType | undefined>;
8
8
  };