@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
@@ -193,8 +193,18 @@ export var ProActionButton = function ProActionButton(props) {
193
193
  }, tooltipProps);
194
194
 
195
195
  if (tooltip || disabledTooltip) {
196
- var showToolTip = disabled ? disabledTooltip : tooltip;
197
- content = /*#__PURE__*/React.createElement(Balloon.Tooltip, _objectSpread({}, baseToolTipProps), showToolTip);
196
+ if (tooltip && !disabledTooltip) {
197
+ if (!disabled) {
198
+ content = /*#__PURE__*/React.createElement(Balloon.Tooltip, _objectSpread({}, baseToolTipProps), tooltip);
199
+ }
200
+ } else if (!tooltip && disabledTooltip) {
201
+ if (disabled) {
202
+ content = /*#__PURE__*/React.createElement(Balloon.Tooltip, _objectSpread({}, baseToolTipProps), disabledTooltip);
203
+ }
204
+ } else if (tooltip && disabledTooltip) {
205
+ var showToolTip = disabled ? disabledTooltip : tooltip;
206
+ content = /*#__PURE__*/React.createElement(Balloon.Tooltip, _objectSpread({}, baseToolTipProps), showToolTip);
207
+ }
198
208
  }
199
209
 
200
210
  return content;
@@ -208,7 +218,10 @@ var ProActionMenuButtonItem = function ProActionMenuButtonItem(props) {
208
218
  _onClick2 = action.onClick,
209
219
  children = action.children,
210
220
  icon = action.icon,
211
- disabled = action.disabled;
221
+ disabled = action.disabled,
222
+ tooltip = action.tooltip,
223
+ disabledTooltip = action.disabledTooltip,
224
+ tooltipProps = action.tooltipProps;
212
225
  var menuItemActionConfig = Object.assign({}, config, {
213
226
  trigger: 'onClick'
214
227
  });
@@ -222,9 +235,32 @@ var ProActionMenuButtonItem = function ProActionMenuButtonItem(props) {
222
235
  return _onClick2(e, context);
223
236
  }
224
237
  }) : _objectSpread({}, menuItemProps);
238
+ var content = buttonContent(children, icon, undefined, context);
239
+
240
+ var baseToolTipProps = _objectSpread({
241
+ triggerType: 'hover',
242
+ align: 't',
243
+ trigger: content
244
+ }, tooltipProps);
245
+
246
+ if (tooltip || disabledTooltip) {
247
+ if (tooltip && !disabledTooltip) {
248
+ if (!disabled) {
249
+ content = /*#__PURE__*/React.createElement(Balloon.Tooltip, _objectSpread({}, baseToolTipProps), tooltip);
250
+ }
251
+ } else if (!tooltip && disabledTooltip) {
252
+ if (disabled) {
253
+ content = /*#__PURE__*/React.createElement(Balloon.Tooltip, _objectSpread({}, baseToolTipProps), disabledTooltip);
254
+ }
255
+ } else if (tooltip && disabledTooltip) {
256
+ var showToolTip = disabled ? disabledTooltip : tooltip;
257
+ content = /*#__PURE__*/React.createElement(Balloon.Tooltip, _objectSpread({}, baseToolTipProps), showToolTip);
258
+ }
259
+ }
260
+
225
261
  return /*#__PURE__*/React.createElement("div", _objectSpread({
226
262
  className: cls('teamix-pro-action-menu-item', "".concat(usePrefixCls(), "menu-item"), _defineProperty({}, "".concat(usePrefixCls(), "disabled"), disabled))
227
- }, buttonProps), buttonContent(children, icon, undefined, context));
263
+ }, buttonProps), content);
228
264
  };
229
265
 
230
266
  function renderCommonActionButtonMenuItem(action, key, context) {
@@ -121,3 +121,16 @@
121
121
  }
122
122
  }
123
123
  }
124
+
125
+ // 针对弹层内的 table 在暗色模式下适配
126
+ .next-dialog-body {
127
+ .teamix-pro-table, .next-table-empty {
128
+ background: var(--dialog-bg);
129
+ }
130
+ }
131
+
132
+ .next-drawer-body {
133
+ .teamix-pro-table, .next-table-empty {
134
+ background: var(--drawer-bg);
135
+ }
136
+ }
@@ -15,9 +15,6 @@ import cls from 'classnames';
15
15
  import { observable } from '@formily/reactive';
16
16
  import { usePrefixCls } from '@teamix/utils';
17
17
  import ProForm from '../ProForm';
18
- var lightFilterObs = observable({
19
- onFilter: function onFilter() {}
20
- });
21
18
  /**
22
19
  * 轻量筛选
23
20
  */
@@ -34,10 +31,15 @@ var LightFilter = /*#__PURE__*/memo(function (props) {
34
31
  activeFilterValueRef = props.activeFilterValueRef,
35
32
  otherProps = _objectWithoutProperties(props, _excluded);
36
33
 
37
- var filterValue = useRef(defaultFilterValue || ((_schema$ = schema[0]) === null || _schema$ === void 0 ? void 0 : _schema$.name));
34
+ var filterValue = useRef(defaultFilterValue || (schema === null || schema === void 0 ? void 0 : (_schema$ = schema[0]) === null || _schema$ === void 0 ? void 0 : _schema$.name));
38
35
  var prefixCls = usePrefixCls('', {
39
36
  prefix: 'teamix-pro-form-query-filter-light'
40
37
  });
38
+ var lightFilterObs = useMemo(function () {
39
+ return observable({
40
+ onFilter: function onFilter() {}
41
+ });
42
+ }, []);
41
43
  useEffect(function () {
42
44
  if (activeFilterValueRef) {
43
45
  activeFilterValueRef.current = filterValue.current;
@@ -88,7 +90,7 @@ var LightFilter = /*#__PURE__*/memo(function (props) {
88
90
  }, [schema, onFilterChange, defaultFilterValue]);
89
91
  useEffect(function () {
90
92
  lightFilterObs.onFilter = onFilter;
91
- }, [onChange]);
93
+ }, [onFilter]);
92
94
  return /*#__PURE__*/React.createElement(ProForm, _objectSpread(_objectSpread({}, otherProps), {}, {
93
95
  scope: _objectSpread(_objectSpread({}, otherProps === null || otherProps === void 0 ? void 0 : otherProps.scope), {}, {
94
96
  lightFilterObs: lightFilterObs
@@ -114,24 +114,21 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
114
114
  }); // 等待mounted + 字段loading结束 + initialRequest结束 => 表单默认值初始化完成
115
115
 
116
116
  if (!(form.mounted && !loadingField.length && !form.loading)) {
117
- _context.next = 10;
117
+ _context.next = 9;
118
118
  break;
119
119
  }
120
120
 
121
- onFormInit = function onFormInit() {}; // init后销毁 isFormInit 方法
122
-
123
-
124
- filterEnable.current = 'filter';
121
+ onFormInit = undefined; // init后销毁 isFormInit 方法
125
122
 
126
123
  if (!onInit) {
127
- _context.next = 10;
124
+ _context.next = 9;
128
125
  break;
129
126
  }
130
127
 
131
- _context.next = 8;
128
+ _context.next = 7;
132
129
  return form.validate();
133
130
 
134
- case 8:
131
+ case 7:
135
132
  onInit === null || onInit === void 0 ? void 0 : onInit(toJS(form.values)); // 设置Tag
136
133
 
137
134
  if (mode === 'panel') {
@@ -139,7 +136,7 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
139
136
  !panelVisible && configTag();
140
137
  }
141
138
 
142
- case 10:
139
+ case 9:
143
140
  case "end":
144
141
  return _context.stop();
145
142
  }
@@ -158,13 +155,105 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
158
155
 
159
156
  if (formRef) {
160
157
  var form = formMap[formName];
161
- formRef.current = form;
158
+ formRef.current = form; // 自定义updateTags方法
162
159
 
163
160
  if (!formRef.current.updateTags) {
164
161
  formRef.current.updateTags = function () {
165
- configFilterItem(form);
166
- configTag();
162
+ updateTags(form);
167
163
  };
164
+ } // 自定义setAsyncValues方法
165
+
166
+
167
+ if (!formRef.current.setAsyncValues) {
168
+ formRef.current.setAsyncValues = /*#__PURE__*/function () {
169
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(values) {
170
+ return regeneratorRuntime.wrap(function _callee2$(_context2) {
171
+ while (1) {
172
+ switch (_context2.prev = _context2.next) {
173
+ case 0:
174
+ form.setValues(values);
175
+
176
+ if (!(filterEnable.current === 'filter' && formName === 'advanced')) {
177
+ _context2.next = 6;
178
+ break;
179
+ }
180
+
181
+ _context2.next = 4;
182
+ return form.validate();
183
+
184
+ case 4:
185
+ onFilter === null || onFilter === void 0 ? void 0 : onFilter(toJS(form.values));
186
+ updateTags(form);
187
+
188
+ case 6:
189
+ case "end":
190
+ return _context2.stop();
191
+ }
192
+ }
193
+ }, _callee2);
194
+ }));
195
+
196
+ return function (_x2) {
197
+ return _ref2.apply(this, arguments);
198
+ };
199
+ }();
200
+ } // 自定义triggerFilter方法
201
+
202
+
203
+ if (!formRef.current.triggerFilter) {
204
+ formRef.current.triggerFilter = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
205
+ return regeneratorRuntime.wrap(function _callee3$(_context3) {
206
+ while (1) {
207
+ switch (_context3.prev = _context3.next) {
208
+ case 0:
209
+ _context3.next = 2;
210
+ return form.validate();
211
+
212
+ case 2:
213
+ onFilter === null || onFilter === void 0 ? void 0 : onFilter(toJS(form.values));
214
+
215
+ if (formName === 'advanced') {
216
+ updateTags(form);
217
+ }
218
+
219
+ case 4:
220
+ case "end":
221
+ return _context3.stop();
222
+ }
223
+ }
224
+ }, _callee3);
225
+ }));
226
+ } // 自定义triggerReset方法
227
+
228
+
229
+ if (!formRef.current.triggerReset) {
230
+ formRef.current.triggerReset = /*#__PURE__*/function () {
231
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(config) {
232
+ return regeneratorRuntime.wrap(function _callee4$(_context4) {
233
+ while (1) {
234
+ switch (_context4.prev = _context4.next) {
235
+ case 0:
236
+ simpleForm.reset('*', config);
237
+ lightForm.reset('*', config);
238
+ advancedForm.reset('*', config);
239
+
240
+ if (formName === 'advanced') {
241
+ onReset === null || onReset === void 0 ? void 0 : onReset(toJS(advancedForm.values));
242
+ updateTags(form);
243
+ }
244
+
245
+ case 4:
246
+ case "end":
247
+ return _context4.stop();
248
+ }
249
+ }
250
+ }, _callee4);
251
+ }));
252
+
253
+ return function (_x3) {
254
+ return _ref4.apply(this, arguments);
255
+ };
256
+ }();
168
257
  }
169
258
  }
170
259
  }; // 创建简单筛选表单实例
@@ -176,7 +265,11 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
176
265
  effects: function effects() {
177
266
  onFormReact(function (form) {
178
267
  if (mode === 'inline') {
179
- onFormInit(form);
268
+ var _onFormInit;
269
+
270
+ (_onFormInit = onFormInit) === null || _onFormInit === void 0 ? void 0 : _onFormInit(form).finally(function () {
271
+ return filterEnable.current = 'filter';
272
+ });
180
273
  }
181
274
  });
182
275
  }
@@ -200,7 +293,11 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
200
293
  effects: function effects() {
201
294
  onFormReact(function (form) {
202
295
  if (mode === 'panel') {
203
- onFormInit(form);
296
+ var _onFormInit2;
297
+
298
+ (_onFormInit2 = onFormInit) === null || _onFormInit2 === void 0 ? void 0 : _onFormInit2(form).finally(function () {
299
+ return filterEnable.current = 'filter';
300
+ });
204
301
  }
205
302
  });
206
303
  onFormInputChange(function (form) {
@@ -219,12 +316,12 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
219
316
  var displayValues = getFormDisplayValues(form);
220
317
  var originalData = Object.entries(displayValues);
221
318
  var filterData = [];
222
- originalData.forEach(function (_ref2) {
319
+ originalData.forEach(function (_ref5) {
223
320
  var _data$displayValue;
224
321
 
225
- var _ref3 = _slicedToArray(_ref2, 2),
226
- key = _ref3[0],
227
- data = _ref3[1];
322
+ var _ref6 = _slicedToArray(_ref5, 2),
323
+ key = _ref6[0],
324
+ data = _ref6[1];
228
325
 
229
326
  var value = (_data$displayValue = data.displayValue) !== null && _data$displayValue !== void 0 ? _data$displayValue : data.value;
230
327
  var component = data.component;
@@ -259,6 +356,11 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
259
356
 
260
357
  var configTag = useCallback(function () {
261
358
  setTagDataSource(filterItem.current);
359
+ }, []); // 更新标签数据
360
+
361
+ var updateTags = useCallback(function (form) {
362
+ configFilterItem(form);
363
+ configTag();
262
364
  }, []); // 展开收起高级筛选
263
365
 
264
366
  var toggleAdvancedFilter = useCallback(function () {
@@ -281,12 +383,12 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
281
383
  }, [panelVisible, configTag]); // 简单搜索Filter
282
384
 
283
385
  var onSimpleFilter = useCallback( /*#__PURE__*/function () {
284
- var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(values) {
285
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
386
+ var _ref7 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(values) {
387
+ return regeneratorRuntime.wrap(function _callee5$(_context5) {
286
388
  while (1) {
287
- switch (_context2.prev = _context2.next) {
389
+ switch (_context5.prev = _context5.next) {
288
390
  case 0:
289
- _context2.next = 2;
391
+ _context5.next = 2;
290
392
  return simpleForm.validate();
291
393
 
292
394
  case 2:
@@ -294,14 +396,14 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
294
396
 
295
397
  case 3:
296
398
  case "end":
297
- return _context2.stop();
399
+ return _context5.stop();
298
400
  }
299
401
  }
300
- }, _callee2);
402
+ }, _callee5);
301
403
  }));
302
404
 
303
- return function (_x2) {
304
- return _ref4.apply(this, arguments);
405
+ return function (_x4) {
406
+ return _ref7.apply(this, arguments);
305
407
  };
306
408
  }(), [onFilter]); // 简单搜索Change
307
409
 
@@ -313,7 +415,7 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
313
415
  debounceFun(onSimpleFilter, values);
314
416
  }
315
417
  }
316
- }, [onChange]); // 轻量搜索Filter
418
+ }, [onChange, onSimpleFilter]); // 轻量搜索Filter
317
419
 
318
420
  var onLightFilter = useCallback(function (values) {
319
421
  var _Object$keys;
@@ -324,10 +426,8 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
324
426
  (_Object$keys = Object.keys(advancedForm.values)) === null || _Object$keys === void 0 ? void 0 : _Object$keys.forEach(function (key) {
325
427
  clearKeys[key] = undefined;
326
428
  });
327
- advancedForm.setValues(clearKeys); // 配置Tag
328
-
329
- configFilterItem(advancedForm);
330
- configTag();
429
+ advancedForm.setValues(clearKeys);
430
+ updateTags(advancedForm);
331
431
  }, [onFilter]); // 轻量搜索Change
332
432
 
333
433
  var onLightChange = useCallback(function (values, fieldValue, fieldName) {
@@ -338,7 +438,7 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
338
438
  debounceFun(onLightFilter, values);
339
439
  }
340
440
  }
341
- }, [onChange]); // 高级搜索Filter
441
+ }, [onChange, onLightFilter]); // 高级搜索Filter
342
442
 
343
443
  var onAdvancedFilter = useCallback(function (values) {
344
444
  setCurrentForm('advanced');
@@ -375,8 +475,7 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
375
475
  }
376
476
 
377
477
  advancedForm.setValuesIn(key, newValue);
378
- configFilterItem(advancedForm);
379
- configTag();
478
+ updateTags(advancedForm);
380
479
  onFilter === null || onFilter === void 0 ? void 0 : onFilter(toJS(advancedForm.values));
381
480
  }, [onFilter]); // initialRequest 的回调
382
481
 
@@ -420,12 +519,12 @@ var QueryFilter = /*#__PURE__*/memo(function (props) {
420
519
  onReset: onAdvancedReset,
421
520
  onInitialComplete: onInitialComplete
422
521
  })) : null
423
- }, mode === 'panel' && !panelVisible ? /*#__PURE__*/React.createElement(Tag.Group, null, tagDataSource.map(function (_ref5) {
424
- var key = _ref5.key,
425
- label = _ref5.label,
426
- value = _ref5.value,
427
- type = _ref5.type,
428
- index = _ref5.index;
522
+ }, mode === 'panel' && !panelVisible ? /*#__PURE__*/React.createElement(Tag.Group, null, tagDataSource.map(function (_ref8) {
523
+ var key = _ref8.key,
524
+ label = _ref8.label,
525
+ value = _ref8.value,
526
+ type = _ref8.type,
527
+ index = _ref8.index;
429
528
  return /*#__PURE__*/React.createElement(Tag.Closeable, {
430
529
  key: isNum(index) ? key + label : key,
431
530
  afterClose: function afterClose() {
@@ -1,5 +1,4 @@
1
- import React from 'react';
2
- import type { ProFormProps } from '../typing';
1
+ import type { ComposedProForm } from '../typing';
3
2
  import './index.scss';
4
- declare const ProForm: React.FC<ProFormProps>;
3
+ declare const ProForm: ComposedProForm;
5
4
  export default ProForm;
@@ -1,4 +1,4 @@
1
- var _excluded = ["form", "initialValues", "initialRequest", "schema", "scope", "context", "components", "children", "layout", "labelAlign", "wrapperAlign", "labelCol", "wrapperCol", "breakpoints", "onChange", "onChangeType", "onSubmit", "onSubmitFailed", "onInitialComplete", "className", "validateFirst"];
1
+ var _excluded = ["form", "initialValues", "initialRequest", "scope", "context", "components", "layout", "labelAlign", "wrapperAlign", "labelCol", "wrapperCol", "breakpoints", "onChange", "onChangeType", "onSubmit", "onSubmitFailed", "onInitialComplete", "className", "validateFirst"];
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,26 +12,59 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
12
12
 
13
13
  import React, { memo, useMemo } from 'react';
14
14
  import cls from 'classnames';
15
+ import { usePrefixCls, getLanguage, getGlobalConfig } from '@teamix/utils';
15
16
  import { createForm, onFieldValueChange, onFormValuesChange, registerValidateLocale, setValidateLanguage } from '@formily/core';
16
17
  import { toJS } from '@formily/reactive';
17
- import { Form } from '@teamix/formily';
18
- import { usePrefixCls, getLanguage, getGlobalConfig } from '@teamix/utils';
18
+ import { Form, Upload, SelectTable, FormLayout, FormItem, ArrayCollapse, ArrayCards, ArrayItems, ArrayTable, Space, FormGrid, FormTab, FormCollapse, FormStep, Editable, FormDialog, FormDrawer, FormButtonGroup, Submit, Reset } from '@teamix/formily';
19
+ import { Affix } from '@alicloudfe/components';
20
+ import ProFieldComponents from '../Components/ProField';
21
+ import { EditableDialog, EditableDrawer, EditablePopover } from '../Components/Editable';
22
+ import FormGroup from '../Components/FormGroup';
23
+ import LightFilter from '../Components/LightFilter';
24
+ import Text from '../Components/Text/index';
19
25
  import SchemaForm from '../SchemaForm';
20
26
  import { mergeArrayValue } from '../utils';
21
27
  import useAutoSubmit from './useAutoSubmit';
22
28
  import useInitialRequest from './useInitialRequest';
29
+ import useFieldSchema from './useFieldSchema';
23
30
  import validateLocale from '../locales/validate';
24
31
  import './index.scss';
25
32
  registerValidateLocale(validateLocale);
33
+ var formilyComponents = {
34
+ FormLayout: FormLayout,
35
+ FormItem: FormItem,
36
+ ArrayCollapse: ArrayCollapse,
37
+ ArrayCards: ArrayCards,
38
+ ArrayItems: ArrayItems,
39
+ ArrayTable: ArrayTable,
40
+ Space: Space,
41
+ FormGrid: FormGrid,
42
+ FormTab: FormTab,
43
+ FormCollapse: FormCollapse,
44
+ FormStep: FormStep,
45
+ Editable: Editable,
46
+ FormDialogFooter: FormDialog.Footer,
47
+ FormDrawerFooter: FormDrawer.Footer,
48
+ FormButtonGroup: FormButtonGroup,
49
+ Submit: Submit,
50
+ Reset: Reset,
51
+ EditableDialog: EditableDialog,
52
+ EditableDrawer: EditableDrawer,
53
+ EditablePopover: EditablePopover,
54
+ FormGroup: FormGroup,
55
+ Upload: Upload,
56
+ SelectTable: SelectTable,
57
+ Affix: Affix,
58
+ LightFilter: LightFilter,
59
+ Text: Text
60
+ };
26
61
  var ProForm = /*#__PURE__*/memo(function (_ref) {
27
62
  var outerForm = _ref.form,
28
63
  initialValues = _ref.initialValues,
29
64
  initialRequest = _ref.initialRequest,
30
- schema = _ref.schema,
31
65
  scope = _ref.scope,
32
66
  context = _ref.context,
33
67
  components = _ref.components,
34
- children = _ref.children,
35
68
  layout = _ref.layout,
36
69
  labelAlign = _ref.labelAlign,
37
70
  wrapperAlign = _ref.wrapperAlign,
@@ -66,7 +99,7 @@ var ProForm = /*#__PURE__*/memo(function (_ref) {
66
99
  }); // context需要实名不能解构
67
100
 
68
101
 
69
- var mergedComponents = _objectSpread(_objectSpread({}, globalComponents), components);
102
+ var mergedComponents = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, globalComponents), components), formilyComponents), ProFieldComponents);
70
103
 
71
104
  var onAutoSubmit = useAutoSubmit(onSubmit); // todo 需要formily支持断点下的属性更新
72
105
 
@@ -87,6 +120,7 @@ var ProForm = /*#__PURE__*/memo(function (_ref) {
87
120
  wrapperCol: mergeArrayValue([24], wrapperCol)
88
121
  };
89
122
  }, [breakpoints, layout, labelAlign, wrapperAlign, labelCol, wrapperCol]);
123
+ var schema = useFieldSchema(otherProps);
90
124
  useMemo(function () {
91
125
  // 配置表单默认值
92
126
  if (initialValues) {
@@ -130,12 +164,17 @@ var ProForm = /*#__PURE__*/memo(function (_ref) {
130
164
  form: form,
131
165
  onAutoSubmit: onAutoSubmit,
132
166
  onAutoSubmitFailed: onSubmitFailed
133
- }), /*#__PURE__*/React.createElement(SchemaForm, {
167
+ }), schema ? /*#__PURE__*/React.createElement(SchemaForm, {
134
168
  schema: schema,
135
169
  scope: mergedScope,
136
170
  components: mergedComponents
137
- }), children);
171
+ }) : null, otherProps === null || otherProps === void 0 ? void 0 : otherProps.children);
138
172
  });
173
+
174
+ ProForm.Field = function () {
175
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
176
+ };
177
+
139
178
  ProForm.defaultProps = {
140
179
  colon: false,
141
180
  labelAlign: 'left',
@@ -317,6 +317,13 @@
317
317
  }
318
318
  }
319
319
 
320
+ // SelectTable
321
+ .#{$teamix-pro-form}-select-table-column-tree
322
+ > .#{$css-prefix}table-cell-wrapper {
323
+ display: flex;
324
+ align-items: center;
325
+ }
326
+
320
327
  /* hack todo remove */
321
328
  .#{$form-item-cls}-control-content-component {
322
329
  .#{$teamix-pro-field}-tooltip.#{$teamix-pro-field}-checkbox {
@@ -0,0 +1,7 @@
1
+ declare const _default: ({ children, schema }: any) => any;
2
+ /**
3
+ * 获取 ProForm 的 schema 配置,通过合并 Field 字段 或者 schema 配置
4
+ * @param props ProForm 组件的 props
5
+ * @returns schema 配置
6
+ */
7
+ export default _default;
@@ -0,0 +1,88 @@
1
+ var _excluded = ["id", "children", "reactions"],
2
+ _excluded2 = ["id", "children", "reactions"];
3
+
4
+ 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; }
5
+
6
+ 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; }
7
+
8
+ 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; }
9
+
10
+ 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; }
11
+
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
+
14
+ import { getValueByValue, deepMerge } from '@teamix/utils';
15
+ /**
16
+ * 合并 Field 字段 props 和 ProForm schema 配置,生成完整的 Field 字段 schema
17
+ * @param field Field 字段
18
+ * @param extra 额外的 schema 配置(存在递归,可能是子级 schema )
19
+ * @param wholeExtra 完整的额外 schema 配置
20
+ * @returns schema 配置
21
+ */
22
+
23
+ var getMergedSchema = function getMergedSchema(field, extra, wholeExtra) {
24
+ return field.reduce(function (prev, curr, index) {
25
+ var _ref = curr.props || {},
26
+ id = _ref.id,
27
+ _ref$children = _ref.children,
28
+ children = _ref$children === void 0 ? [] : _ref$children,
29
+ _ref$reactions = _ref.reactions,
30
+ reactions = _ref$reactions === void 0 ? [] : _ref$reactions,
31
+ rest = _objectWithoutProperties(_ref, _excluded); // 获取字段额外的 schema 配置(From ProForm)
32
+
33
+
34
+ var extraFieldProps = extra[index] || {};
35
+
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
+ });
45
+
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."));
48
+ }
49
+ }
50
+
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
+ return prev;
64
+ }, []);
65
+ };
66
+ /**
67
+ * 获取 ProForm 的 schema 配置,通过合并 Field 字段 或者 schema 配置
68
+ * @param props ProForm 组件的 props
69
+ * @returns schema 配置
70
+ */
71
+
72
+
73
+ export default (function (_ref3) {
74
+ var children = _ref3.children,
75
+ 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 属性 )
81
+
82
+ if (field.length) {
83
+ return getMergedSchema(field, schema !== null && schema !== void 0 ? schema : [], schema !== null && schema !== void 0 ? schema : []);
84
+ } // 正常使用 ProForm 的 schema 渲染表单
85
+
86
+
87
+ return schema;
88
+ });