@teamix/pro 1.3.15 → 1.3.16

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 (39) hide show
  1. package/dist/pro.css +1 -1
  2. package/dist/pro.js +4953 -730
  3. package/dist/pro.min.css +1 -1
  4. package/dist/pro.min.js +1 -1
  5. package/es/form/Filter/index.js +46 -29
  6. package/es/form/Filter/layout.scss +4 -0
  7. package/es/form/Filter/useBindUrl.d.ts +2 -0
  8. package/es/form/Filter/useBindUrl.js +118 -0
  9. package/es/form/ProForm/index.js +5 -3
  10. package/es/form/ProForm/useFieldSchema.js +53 -32
  11. package/es/form/SchemaForm/reactions.js +9 -3
  12. package/es/form/typing.d.ts +3 -0
  13. package/es/form/utils.d.ts +9 -1
  14. package/es/form/utils.js +6 -30
  15. package/es/global.scss +45 -0
  16. package/es/index.d.ts +2 -1
  17. package/es/index.js +3 -2
  18. package/es/page-header/index.d.ts +2 -0
  19. package/es/page-header/index.js +13 -3
  20. package/es/page-header/index.scss +8 -0
  21. package/es/table/components/Layout/index.scss +5 -5
  22. package/lib/form/Filter/index.js +47 -29
  23. package/lib/form/Filter/layout.scss +4 -0
  24. package/lib/form/Filter/useBindUrl.d.ts +2 -0
  25. package/lib/form/Filter/useBindUrl.js +129 -0
  26. package/lib/form/ProForm/index.js +5 -3
  27. package/lib/form/ProForm/useFieldSchema.js +52 -31
  28. package/lib/form/SchemaForm/reactions.js +9 -3
  29. package/lib/form/typing.d.ts +3 -0
  30. package/lib/form/utils.d.ts +9 -1
  31. package/lib/form/utils.js +5 -29
  32. package/lib/global.scss +45 -0
  33. package/lib/index.d.ts +2 -1
  34. package/lib/index.js +3 -1
  35. package/lib/page-header/index.d.ts +2 -0
  36. package/lib/page-header/index.js +12 -2
  37. package/lib/page-header/index.scss +8 -0
  38. package/lib/table/components/Layout/index.scss +5 -5
  39. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- var _excluded = ["addonAfter", "addonBefore", "mode", "purePanel", "expand", "formRef", "defaultFilterValue", "filterValues", "filterDebounce", "onFilter", "onInit", "onReset", "onExpand", "onChange"];
1
+ var _excluded = ["addonAfter", "addonBefore", "mode", "purePanel", "expand", "formRef", "defaultFilterValue", "filterValues", "filterDebounce", "bindUrl", "onFilter", "onInit", "onReset", "onExpand", "onChange"];
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
 
@@ -49,6 +49,7 @@ import LightFilter from './LightFilter';
49
49
  import AdvancedFilter from './AdvancedFilter';
50
50
  import { QueryFilterLayout } from './Layout';
51
51
  import useSpecialProps from './useSpecialProps';
52
+ import useBindUrl from './useBindUrl';
52
53
  import './index.scss';
53
54
  /**
54
55
  * 查询筛选
@@ -64,9 +65,10 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
64
65
  defaultFilterValue = props.defaultFilterValue,
65
66
  filterValues = props.filterValues,
66
67
  filterDebounce = props.filterDebounce,
67
- onFilter = props.onFilter,
68
- onInit = props.onInit,
69
- onReset = props.onReset,
68
+ bindUrl = props.bindUrl,
69
+ outerFilter = props.onFilter,
70
+ outerInit = props.onInit,
71
+ outerReset = props.onReset,
70
72
  onExpand = props.onExpand,
71
73
  onChange = props.onChange,
72
74
  otherProps = _objectWithoutProperties(props, _excluded);
@@ -85,15 +87,27 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
85
87
  setTagDataSource = _useState4[1];
86
88
 
87
89
  var filterItem = useRef([]);
88
- var defaultForm = mode === 'panel' ? 'advanced' : 'simple';
89
- var currentForm = useRef(defaultForm);
90
+ var defaultFormName = mode === 'panel' ? 'advanced' : 'simple';
91
+ var currentFormName = useRef(defaultFormName);
92
+ var currentForm = useRef();
90
93
  var activeFilterValueRef = useRef();
91
94
  var prefixCls = usePrefixCls('', {
92
95
  prefix: 'teamix-pro-form-query-filter'
93
96
  });
94
97
  var debounceFun = debounce(function (fun, props) {
95
98
  return fun(props);
96
- }, filterDebounce); // onInit
99
+ }, filterDebounce); // 绑定URL
100
+
101
+ var _useBindUrl = useBindUrl(bindUrl, {
102
+ onInit: outerInit,
103
+ onFilter: outerFilter,
104
+ onReset: outerReset
105
+ }, currentForm),
106
+ setValuesByUrlState = _useBindUrl.setValuesByUrlState,
107
+ onInit = _useBindUrl.onInit,
108
+ onFilter = _useBindUrl.onFilter,
109
+ onReset = _useBindUrl.onReset; // onInit
110
+
97
111
 
98
112
  var initialRequestRef = useRef(!!(props === null || props === void 0 ? void 0 : props.initialRequest));
99
113
  var filterEnable = useRef('waiting');
@@ -114,29 +128,31 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
114
128
  }); // 等待mounted + 字段loading结束 + initialRequest结束 => 表单默认值初始化完成
115
129
 
116
130
  if (!(form.mounted && !loadingField.length && !form.loading)) {
117
- _context.next = 9;
131
+ _context.next = 10;
118
132
  break;
119
133
  }
120
134
 
121
135
  onFormInit = undefined; // init后销毁 isFormInit 方法
122
136
 
123
- if (!onInit) {
124
- _context.next = 9;
137
+ setValuesByUrlState(form); // 配置URL参数到表单
138
+
139
+ if (!outerInit) {
140
+ _context.next = 10;
125
141
  break;
126
142
  }
127
143
 
128
- _context.next = 7;
144
+ _context.next = 8;
129
145
  return form.validate();
130
146
 
131
- case 7:
132
- onInit === null || onInit === void 0 ? void 0 : onInit(toJS(form.values)); // 设置Tag
147
+ case 8:
148
+ onInit(toJS(form.values)); // 设置Tag
133
149
 
134
150
  if (mode === 'panel') {
135
151
  configFilterItem(advancedForm);
136
152
  !panelVisible && configTag();
137
153
  }
138
154
 
139
- case 9:
155
+ case 10:
140
156
  case "end":
141
157
  return _context.stop();
142
158
  }
@@ -151,10 +167,11 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
151
167
 
152
168
 
153
169
  var setCurrentForm = function setCurrentForm(formName) {
154
- currentForm.current = formName;
170
+ currentFormName.current = formName;
171
+ currentForm.current = formMap[formName];
172
+ var form = currentForm.current;
155
173
 
156
174
  if (formRef) {
157
- var form = formMap[formName];
158
175
  formRef.current = form; // 自定义updateTags方法
159
176
 
160
177
  if (!formRef.current.updateTags) {
@@ -182,7 +199,7 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
182
199
  return form.validate();
183
200
 
184
201
  case 4:
185
- onFilter === null || onFilter === void 0 ? void 0 : onFilter(toJS(form.values));
202
+ onFilter(toJS(form.values));
186
203
  updateTags(form);
187
204
 
188
205
  case 6:
@@ -210,7 +227,7 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
210
227
  return form.validate();
211
228
 
212
229
  case 2:
213
- onFilter === null || onFilter === void 0 ? void 0 : onFilter(toJS(form.values));
230
+ onFilter(toJS(form.values));
214
231
 
215
232
  if (formName === 'advanced') {
216
233
  updateTags(form);
@@ -238,7 +255,7 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
238
255
  advancedForm.reset('*', config);
239
256
 
240
257
  if (formName === 'advanced') {
241
- onReset === null || onReset === void 0 ? void 0 : onReset(toJS(advancedForm.values));
258
+ onReset(toJS(advancedForm.values));
242
259
  updateTags(form);
243
260
  }
244
261
 
@@ -368,7 +385,7 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
368
385
 
369
386
  if (result) {
370
387
  // 展开高级筛选,Light回填Advanced
371
- if (currentForm.current === 'light') {
388
+ if (currentFormName.current === 'light') {
372
389
  var key = activeFilterValueRef.current;
373
390
  var value = lightForm.values[key];
374
391
  advancedForm.setValuesIn(key, value);
@@ -392,7 +409,7 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
392
409
  return simpleForm.validate();
393
410
 
394
411
  case 2:
395
- onFilter === null || onFilter === void 0 ? void 0 : onFilter(values);
412
+ onFilter(values);
396
413
 
397
414
  case 3:
398
415
  case "end":
@@ -408,7 +425,7 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
408
425
  }(), [onFilter]); // 简单搜索Change
409
426
 
410
427
  var onSimpleChange = useCallback(function (values, fieldValue, fieldName) {
411
- if (currentForm.current === 'simple') {
428
+ if (currentFormName.current === 'simple') {
412
429
  onChange === null || onChange === void 0 ? void 0 : onChange(values, fieldValue, fieldName);
413
430
 
414
431
  if (filterEnable.current === 'filter') {
@@ -420,7 +437,7 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
420
437
  var onLightFilter = useCallback(function (values) {
421
438
  var _Object$keys;
422
439
 
423
- onFilter === null || onFilter === void 0 ? void 0 : onFilter(values); // 清空advancedForm的值
440
+ onFilter(values); // 清空advancedForm的值
424
441
 
425
442
  var clearKeys = {};
426
443
  (_Object$keys = Object.keys(advancedForm.values)) === null || _Object$keys === void 0 ? void 0 : _Object$keys.forEach(function (key) {
@@ -431,7 +448,7 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
431
448
  }, [onFilter]); // 轻量搜索Change
432
449
 
433
450
  var onLightChange = useCallback(function (values, fieldValue, fieldName) {
434
- if (currentForm.current === 'light') {
451
+ if (currentFormName.current === 'light') {
435
452
  onChange === null || onChange === void 0 ? void 0 : onChange(values, fieldValue, fieldName);
436
453
 
437
454
  if (filterEnable.current === 'filter') {
@@ -442,7 +459,7 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
442
459
 
443
460
  var onAdvancedFilter = useCallback(function (values) {
444
461
  setCurrentForm('advanced');
445
- onFilter === null || onFilter === void 0 ? void 0 : onFilter(values);
462
+ onFilter(values);
446
463
  configFilterItem(advancedForm); // 清空lightForm的值
447
464
 
448
465
  lightForm.reset('*', {
@@ -452,7 +469,7 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
452
469
 
453
470
  var onAdvancedReset = useCallback(function () {
454
471
  setCurrentForm('advanced');
455
- onReset === null || onReset === void 0 ? void 0 : onReset(toJS(advancedForm.values));
472
+ onReset(toJS(advancedForm.values));
456
473
  configFilterItem(advancedForm); // 清空lightForm的值
457
474
 
458
475
  lightForm.reset('*', {
@@ -461,7 +478,7 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
461
478
  }, [onReset]); // 高级搜索Change
462
479
 
463
480
  var onAdvancedChange = useCallback(function (values, fieldValue, fieldName) {
464
- if (currentForm.current === 'advanced') {
481
+ if (currentFormName.current === 'advanced') {
465
482
  onChange === null || onChange === void 0 ? void 0 : onChange(values, fieldValue, fieldName);
466
483
  }
467
484
  }, [onChange]); // 关闭标签清空表单字段值
@@ -476,7 +493,7 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
476
493
 
477
494
  advancedForm.setValuesIn(key, newValue);
478
495
  updateTags(advancedForm);
479
- onFilter === null || onFilter === void 0 ? void 0 : onFilter(toJS(advancedForm.values));
496
+ onFilter(toJS(advancedForm.values));
480
497
  }, [onFilter]); // initialRequest 的回调
481
498
 
482
499
  var onInitialComplete = useCallback(function (form) {
@@ -487,7 +504,7 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
487
504
  }, []); // 组件挂载
488
505
 
489
506
  useEffect(function () {
490
- setCurrentForm(currentForm.current);
507
+ setCurrentForm(currentFormName.current);
491
508
  }, []);
492
509
  return /*#__PURE__*/React.createElement(QueryFilterLayout, {
493
510
  className: cls(prefixCls, props.className),
@@ -6,6 +6,10 @@ $query-filter-layout: #{$teamix-pro-form}-query-filter-layout;
6
6
  --panel-filter-bg: #1f1f1f;
7
7
  }
8
8
 
9
+ .theme-hybridcloud {
10
+ --panel-filter-bg: var(--color-fill1-2);
11
+ }
12
+
9
13
  .#{$query-filter-layout} {
10
14
  .#{$query-filter-layout}-inline {
11
15
  display: flex;
@@ -0,0 +1,2 @@
1
+ declare const _default: (bindUrl: any, functions: any, formRef: any) => any;
2
+ export default _default;
@@ -0,0 +1,118 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+
3
+ 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."); }
4
+
5
+ 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); }
6
+
7
+ 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; }
8
+
9
+ 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; }
10
+
11
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
+
13
+ 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; }
14
+
15
+ 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; }
16
+
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
+
19
+ import { useUrlState } from '@teamix/hooks';
20
+ import { isUsable } from '@teamix/utils';
21
+ export default (function (bindUrl, functions, formRef) {
22
+ // 预处理 bindUrl 参数(主要兼容 SelectGroup 组件)
23
+ var initializeBindUrl = function initializeBindUrl(options) {
24
+ return options ? _objectSpread(_objectSpread({}, options), {}, {
25
+ beforeStringify: function beforeStringify(values) {
26
+ var _Object$entries;
27
+
28
+ var beforeStringify = options.beforeStringify;
29
+
30
+ var newValues = _objectSpread({}, values);
31
+
32
+ (_Object$entries = Object.entries(values)) === null || _Object$entries === void 0 ? void 0 : _Object$entries.forEach(function (_ref) {
33
+ var _form$query;
34
+
35
+ var _ref2 = _slicedToArray(_ref, 2),
36
+ key = _ref2[0],
37
+ value = _ref2[1];
38
+
39
+ var form = formRef.current;
40
+ var field = (_form$query = form.query(key)) === null || _form$query === void 0 ? void 0 : _form$query.take();
41
+
42
+ if ((field === null || field === void 0 ? void 0 : field.component[0]) === 'SelectGroup') {
43
+ newValues[key] = value.map(function (_ref3) {
44
+ var key = _ref3.key,
45
+ value = _ref3.value;
46
+ return key && value ? "".concat(key, "||").concat(value === null || value === void 0 ? void 0 : value.join('|')) : '';
47
+ });
48
+ }
49
+ });
50
+ return beforeStringify ? beforeStringify(newValues) : newValues;
51
+ }
52
+ }) : options;
53
+ }; // 通过 useUrlState 获取 url 上的参数和 url 配置方法
54
+
55
+
56
+ var _useUrlState = useUrlState(undefined, initializeBindUrl(bindUrl)),
57
+ _useUrlState2 = _slicedToArray(_useUrlState, 2),
58
+ urlState = _useUrlState2[0],
59
+ setUrlState = _useUrlState2[1]; // 输出配置url参数的函数
60
+
61
+
62
+ var initializedFunctions = Object.entries(functions).reduce(function (prev, _ref4) {
63
+ var _ref5 = _slicedToArray(_ref4, 2),
64
+ key = _ref5[0],
65
+ fun = _ref5[1];
66
+
67
+ prev[key] = function (values) {
68
+ fun === null || fun === void 0 ? void 0 : fun(values);
69
+ setUrlState(values);
70
+ };
71
+
72
+ return prev;
73
+ }, {}); // 使用 url 参数配置 QueryFilter 默认值(移除非表单值,兼容数组数据,兼容 SelectGroup 组件)
74
+
75
+ var setValuesByUrlState = function setValuesByUrlState(form) {
76
+ if (urlState) {
77
+ var _Object$entries2;
78
+
79
+ (_Object$entries2 = Object.entries(urlState)) === null || _Object$entries2 === void 0 ? void 0 : _Object$entries2.forEach(function (_ref6) {
80
+ var _form$query2;
81
+
82
+ var _ref7 = _slicedToArray(_ref6, 2),
83
+ key = _ref7[0],
84
+ value = _ref7[1];
85
+
86
+ var field = (_form$query2 = form.query(key)) === null || _form$query2 === void 0 ? void 0 : _form$query2.take();
87
+
88
+ if (field) {
89
+ var newValue = value;
90
+
91
+ if (field.displayName === 'ArrayField') {
92
+ newValue = [].concat(isUsable(newValue) ? newValue : []);
93
+ }
94
+
95
+ if (field.component[0] === 'SelectGroup') {
96
+ newValue = newValue.map(function (item) {
97
+ var _item$split = item === null || item === void 0 ? void 0 : item.split('||'),
98
+ _item$split2 = _slicedToArray(_item$split, 2),
99
+ key = _item$split2[0],
100
+ value = _item$split2[1];
101
+
102
+ return {
103
+ key: key,
104
+ value: value === null || value === void 0 ? void 0 : value.split('|')
105
+ };
106
+ });
107
+ }
108
+
109
+ form.setValuesIn(key, newValue);
110
+ }
111
+ });
112
+ }
113
+ };
114
+
115
+ return _objectSpread({
116
+ setValuesByUrlState: setValuesByUrlState
117
+ }, initializedFunctions);
118
+ });
@@ -101,7 +101,7 @@ var ProForm = /*#__PURE__*/memo(function (_ref) {
101
101
 
102
102
  var mergedComponents = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, globalComponents), components), formilyComponents), ProFieldComponents);
103
103
 
104
- var onAutoSubmit = useAutoSubmit(onSubmit); // todo 需要formily支持断点下的属性更新
104
+ var onAutoSubmit = useAutoSubmit(onSubmit, context); // todo 需要formily支持断点下的属性更新
105
105
 
106
106
  var getTeamixLayout = useMemo(function () {
107
107
  return breakpoints ? {
@@ -126,7 +126,7 @@ var ProForm = /*#__PURE__*/memo(function (_ref) {
126
126
  if (initialValues) {
127
127
  form.setInitialValues(initialValues);
128
128
  } else if (initialRequest) {
129
- useInitialRequest(initialRequest).then(function (values) {
129
+ useInitialRequest(initialRequest, context).then(function (values) {
130
130
  form.setInitialValues(values);
131
131
  }).finally(function () {
132
132
  onInitialComplete === null || onInitialComplete === void 0 ? void 0 : onInitialComplete(form);
@@ -171,10 +171,12 @@ var ProForm = /*#__PURE__*/memo(function (_ref) {
171
171
  }) : null, otherProps === null || otherProps === void 0 ? void 0 : otherProps.children);
172
172
  });
173
173
 
174
- ProForm.Field = function () {
174
+ var Field = function Field() {
175
175
  return /*#__PURE__*/React.createElement(React.Fragment, null);
176
176
  };
177
177
 
178
+ Field.displayName = 'ProFormField';
179
+ ProForm.Field = Field;
178
180
  ProForm.defaultProps = {
179
181
  colon: false,
180
182
  labelAlign: 'left',
@@ -11,7 +11,7 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
11
11
 
12
12
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
13
13
 
14
- import { getValueByValue, deepMerge } from '@teamix/utils';
14
+ import { getValueByValue, deepMerge, isStr } from '@teamix/utils';
15
15
  /**
16
16
  * 合并 Field 字段 props 和 ProForm schema 配置,生成完整的 Field 字段 schema
17
17
  * @param field Field 字段
@@ -21,45 +21,70 @@ import { getValueByValue, deepMerge } from '@teamix/utils';
21
21
  */
22
22
 
23
23
  var getMergedSchema = function getMergedSchema(field, extra, wholeExtra) {
24
- return field.reduce(function (prev, curr, index) {
24
+ return [].concat(field).reduce(function (prev, curr, index) {
25
+ var _curr$type;
26
+
25
27
  var _ref = curr.props || {},
26
28
  id = _ref.id,
27
29
  _ref$children = _ref.children,
28
30
  children = _ref$children === void 0 ? [] : _ref$children,
29
31
  _ref$reactions = _ref.reactions,
30
32
  reactions = _ref$reactions === void 0 ? [] : _ref$reactions,
31
- rest = _objectWithoutProperties(_ref, _excluded); // 获取字段额外的 schema 配置(From ProForm)
33
+ rest = _objectWithoutProperties(_ref, _excluded);
32
34
 
35
+ var displayName = curr === null || curr === void 0 ? void 0 : (_curr$type = curr.type) === null || _curr$type === void 0 ? void 0 : _curr$type.displayName; // 自定义组件
33
36
 
34
- var extraFieldProps = extra[index] || {};
37
+ var type = curr === null || curr === void 0 ? void 0 : curr.type; // 基本Dom元素
35
38
 
36
- if (id !== extraFieldProps.id) {
37
- // 索引不匹配,通过 id 查找获取
38
- extraFieldProps = getValueByValue(extra, id, {
39
- inputKey: 'id',
40
- outputKey: '__whole__'
41
- }) || getValueByValue(wholeExtra, id, {
42
- inputKey: 'id',
43
- outputKey: '__whole__'
44
- });
39
+ if (displayName === 'ProFormField') {
40
+ // 获取字段额外的 schema 配置(From ProForm)
41
+ var extraFieldProps = extra[index] || {};
45
42
 
46
- if (extraFieldProps) {
47
- console.warn("Field id \"".concat(id, "\" is not found by index in ProForm schema props, Please pay attention to the order."));
43
+ if (id !== extraFieldProps.id) {
44
+ // 索引不匹配,通过 id 查找获取
45
+ extraFieldProps = getValueByValue(extra, id, {
46
+ inputKey: 'id',
47
+ outputKey: '__whole__'
48
+ }) || getValueByValue(wholeExtra, id, {
49
+ inputKey: 'id',
50
+ outputKey: '__whole__'
51
+ });
52
+
53
+ if (extraFieldProps) {
54
+ console.warn("Field id \"".concat(id, "\" is not found by index in ProForm schema props, Please pay attention to the order."));
55
+ }
48
56
  }
57
+
58
+ var _ref2 = extraFieldProps || {},
59
+ extraId = _ref2.id,
60
+ _ref2$children = _ref2.children,
61
+ extraChildren = _ref2$children === void 0 ? [] : _ref2$children,
62
+ _ref2$reactions = _ref2.reactions,
63
+ extraReactions = _ref2$reactions === void 0 ? [] : _ref2$reactions,
64
+ extraRest = _objectWithoutProperties(_ref2, _excluded2);
65
+
66
+ var mergedReactions = [].concat(reactions, extraReactions);
67
+ var mergedChildren = children ? getMergedSchema(children, extraChildren, wholeExtra) : [];
68
+ prev.push(_objectSpread(_objectSpread(_objectSpread({}, deepMerge(rest, extraRest)), mergedReactions.length && {
69
+ reactions: mergedReactions
70
+ }), mergedChildren.length && {
71
+ children: mergedChildren
72
+ }));
73
+ } else if (isStr(type)) {
74
+ prev.push({
75
+ component: type,
76
+ props: curr.props
77
+ });
78
+ } else if (isStr(displayName)) {
79
+ prev.push({
80
+ decorator: displayName,
81
+ decoratorProps: _objectSpread({
82
+ id: id
83
+ }, rest),
84
+ children: children ? getMergedSchema(children, [], wholeExtra) : []
85
+ });
49
86
  }
50
87
 
51
- var _ref2 = extraFieldProps || {},
52
- extraId = _ref2.id,
53
- _ref2$children = _ref2.children,
54
- extraChildren = _ref2$children === void 0 ? [] : _ref2$children,
55
- _ref2$reactions = _ref2.reactions,
56
- extraReactions = _ref2$reactions === void 0 ? [] : _ref2$reactions,
57
- extraRest = _objectWithoutProperties(_ref2, _excluded2);
58
-
59
- prev.push(_objectSpread(_objectSpread({}, deepMerge(rest, extraRest)), {}, {
60
- reactions: [].concat(reactions, extraReactions),
61
- children: (children === null || children === void 0 ? void 0 : children.length) ? getMergedSchema(children, extraChildren, wholeExtra) : []
62
- }));
63
88
  return prev;
64
89
  }, []);
65
90
  };
@@ -73,11 +98,7 @@ var getMergedSchema = function getMergedSchema(field, extra, wholeExtra) {
73
98
  export default (function (_ref3) {
74
99
  var children = _ref3.children,
75
100
  schema = _ref3.schema;
76
- var field = [].concat(children !== null && children !== void 0 ? children : []).filter(function (item) {
77
- var _item$type, _item$props;
78
-
79
- return (item === null || item === void 0 ? void 0 : (_item$type = item.type) === null || _item$type === void 0 ? void 0 : _item$type.name) === '' && (item === null || item === void 0 ? void 0 : (_item$props = item.props) === null || _item$props === void 0 ? void 0 : _item$props.component);
80
- }); // 如果 ProForm 的 children 含有 Field 字段,则优先使用 Field 渲染表单(仅合并 ProForm 的 schema 属性 )
101
+ var field = [].concat(children !== null && children !== void 0 ? children : []); // 如果 ProForm 的 children 含有 Field 字段,则优先使用 Field 渲染表单(仅合并 ProForm 的 schema 属性 )
81
102
 
82
103
  if (field.length) {
83
104
  return getMergedSchema(field, schema !== null && schema !== void 0 ? schema : [], schema !== null && schema !== void 0 ? schema : []);
@@ -27,10 +27,13 @@ var $request = function $request(field, context, _ref, type) {
27
27
  var beforeRequestResult = isFn(beforeRequest) ? beforeRequest(field, context) : {}; // 通过字段 data 的 refresh 主动触发的请求刷新
28
28
 
29
29
  var refresh = (_field$data = field.data) === null || _field$data === void 0 ? void 0 : _field$data.refresh;
30
- var refreshResult = isPlainObj(refresh) ? refresh : {}; // 执行通用数据请求
30
+ var refreshResult = isPlainObj(refresh) ? refresh : {}; // 合并请求参数
31
+
32
+ var mergedParams = _objectSpread(_objectSpread(_objectSpread({}, params), beforeRequestResult), refreshResult); // 执行通用数据请求
33
+
31
34
 
32
35
  return doCommonRequest(_objectSpread(_objectSpread({}, requestConfig), {}, {
33
- params: _objectSpread(_objectSpread(_objectSpread({}, params), beforeRequestResult), refreshResult),
36
+ params: mergedParams,
34
37
  beforeRequest: function beforeRequest() {
35
38
  return beforeRequestResult;
36
39
  },
@@ -40,7 +43,10 @@ var $request = function $request(field, context, _ref, type) {
40
43
  onSuccess: isFn(onSuccess) ? function (res) {
41
44
  return onSuccess(res, field, context);
42
45
  } : onSuccess
43
- }), context);
46
+ }), _objectSpread(_objectSpread({}, context), {}, {
47
+ field: field,
48
+ params: mergedParams
49
+ }));
44
50
  }; // 通用请求配置上下文
45
51
 
46
52
 
@@ -2,6 +2,7 @@ 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
4
  import type { CommonRequestConfig } from '@teamix/utils';
5
+ import type { UrlStateOptions } from '@teamix/hooks';
5
6
  import React from 'react';
6
7
  interface AnyObject {
7
8
  [propName: string]: any;
@@ -124,6 +125,8 @@ export interface QueryFilterProps extends ProFormProps {
124
125
  formRef?: React.MutableRefObject<any>;
125
126
  /** onChange事件的防抖时间 */
126
127
  filterDebounce?: number;
128
+ /** 绑定URL参数 */
129
+ bindUrl?: boolean | UrlStateOptions;
127
130
  /** 表单初始化(含异步默认值)后回调函数 */
128
131
  onInit?: (values: any) => void;
129
132
  /** 表单筛选回调函数 */
@@ -43,5 +43,13 @@ declare const mergeArrayValue: (arr: any[], v?: any) => any[];
43
43
  * @param suffix scope名称后缀
44
44
  * @returns 表达式和scope上下文
45
45
  */
46
- declare const initializeRequestExpression: (config?: any, mode?: string | undefined, suffix?: string | undefined) => any;
46
+ declare const initializeRequestExpression: (config?: any, mode?: string | undefined, suffix?: string | undefined) => {
47
+ expression: string;
48
+ scope: {
49
+ [x: string]: object;
50
+ };
51
+ } | {
52
+ expression?: undefined;
53
+ scope?: undefined;
54
+ };
47
55
  export { mapSize, mapStatus, mapDataSource, mapMode, mergeArrayValue, getFieldName, mapSchemaName, initializeRequestExpression, };
package/es/form/utils.js CHANGED
@@ -1,9 +1,3 @@
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
-
7
1
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
8
2
 
9
3
  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."); }
@@ -32,7 +26,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
32
26
 
33
27
  import { isVoidField } from '@formily/core';
34
28
  import { useFormLayout, useFormShallowLayout } from '@teamix/formily';
35
- import { isArr, isObj, getValueByValue, isPlainObj, isFn } from '@teamix/utils';
29
+ import { isArr, isObj, getValueByValue, isPlainObj } from '@teamix/utils';
36
30
  import schemaNameMap from './schemaNameMap';
37
31
  /**
38
32
  * 映射字段size,主要是default转medium
@@ -192,33 +186,15 @@ var mergeArrayValue = function mergeArrayValue(arr, v) {
192
186
 
193
187
 
194
188
  var initializeRequestExpression = function initializeRequestExpression(config, mode, suffix) {
195
- var schema = {};
196
-
197
189
  if (isPlainObj(config)) {
198
- var customRequest = config.customRequest,
199
- requestConfig = _objectWithoutProperties(config, _excluded);
200
-
201
190
  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
- }
191
+ return {
192
+ expression: "{{".concat(mode, "($request,context,").concat(requestConfigName, ")}}"),
193
+ scope: _defineProperty({}, requestConfigName, config)
194
+ };
219
195
  }
220
196
 
221
- return schema;
197
+ return {};
222
198
  };
223
199
 
224
200
  export { mapSize, mapStatus, mapDataSource, mapMode, mergeArrayValue, getFieldName, mapSchemaName, initializeRequestExpression };