@teamix/pro 1.1.30 → 1.1.34

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 (59) hide show
  1. package/dist/pro.css +1 -1
  2. package/dist/pro.js +1113 -474
  3. package/dist/pro.min.css +1 -1
  4. package/dist/pro.min.js +1 -1
  5. package/es/actions/index.js +13 -8
  6. package/es/actions/link.d.ts +2 -2
  7. package/es/form/Components/FormGroup/index.scss +1 -1
  8. package/es/form/Components/ProField/index.d.ts +4 -0
  9. package/es/form/Components/Query/index.scss +1 -6
  10. package/es/form/Components/Text/index.scss +4 -2
  11. package/es/form/ProForm/index.js +2 -2
  12. package/es/form/ProForm/index.scss +4 -11
  13. package/es/form/ProForm/useFormDisplayValues.d.ts +6 -0
  14. package/es/form/ProForm/useFormDisplayValues.js +65 -0
  15. package/es/form/SchemaForm/adapterType.js +2 -1
  16. package/es/form/SchemaForm/index.js +5 -15
  17. package/es/form/SchemaForm/initializeProField.js +1 -0
  18. package/es/form/SchemaForm/initializeReactions.d.ts +2 -0
  19. package/es/form/SchemaForm/initializeReactions.js +89 -0
  20. package/es/form/global.scss +12 -0
  21. package/es/form/index.d.ts +3 -3
  22. package/es/form/index.js +3 -3
  23. package/es/form/typing.d.ts +2 -2
  24. package/es/form/utils.d.ts +31 -8
  25. package/es/form/utils.js +27 -44
  26. package/es/index.d.ts +1 -1
  27. package/es/index.js +1 -1
  28. package/es/table/components/Filter/index.js +6 -2
  29. package/es/table/index.js +4 -1
  30. package/es/table/typing.d.ts +8 -4
  31. package/es/table/utils/columnRender.js +38 -11
  32. package/lib/actions/index.js +12 -7
  33. package/lib/actions/link.d.ts +2 -2
  34. package/lib/form/Components/FormGroup/index.scss +1 -1
  35. package/lib/form/Components/ProField/index.d.ts +4 -0
  36. package/lib/form/Components/Query/index.scss +1 -6
  37. package/lib/form/Components/Text/index.scss +4 -2
  38. package/lib/form/ProForm/index.js +1 -1
  39. package/lib/form/ProForm/index.scss +4 -11
  40. package/lib/form/ProForm/useFormDisplayValues.d.ts +6 -0
  41. package/lib/form/ProForm/useFormDisplayValues.js +74 -0
  42. package/lib/form/SchemaForm/adapterType.js +2 -1
  43. package/lib/form/SchemaForm/index.js +5 -14
  44. package/lib/form/SchemaForm/initializeProField.js +1 -0
  45. package/lib/form/SchemaForm/initializeReactions.d.ts +2 -0
  46. package/lib/form/SchemaForm/initializeReactions.js +101 -0
  47. package/lib/form/global.scss +12 -0
  48. package/lib/form/index.d.ts +3 -3
  49. package/lib/form/index.js +15 -8
  50. package/lib/form/typing.d.ts +2 -2
  51. package/lib/form/utils.d.ts +31 -8
  52. package/lib/form/utils.js +28 -54
  53. package/lib/index.d.ts +1 -1
  54. package/lib/index.js +1 -1
  55. package/lib/table/components/Filter/index.js +6 -2
  56. package/lib/table/index.js +4 -1
  57. package/lib/table/typing.d.ts +8 -4
  58. package/lib/table/utils/columnRender.js +38 -11
  59. package/package.json +1 -1
@@ -33,7 +33,7 @@ import React from 'react';
33
33
  import cls from 'classnames';
34
34
  import { Button, MenuButton, Menu, Divider } from '@alicloudfe/components';
35
35
  import Icon from '@teamix/icon';
36
- import { getTargetValue } from '@teamix/utils';
36
+ import { getTargetValue, getMessage } from '@teamix/utils';
37
37
  import { useLinkAction } from './link';
38
38
  import { useRequestAction } from './request';
39
39
  import { useDialogAction } from './dialog';
@@ -121,16 +121,18 @@ export var useAction = function useAction(config, context) {
121
121
  }, registedAction.defaultConfig), others), context);
122
122
  };
123
123
 
124
- var buttonContent = function buttonContent(content, iconType, iconSize) {
124
+ var buttonContent = function buttonContent(content, iconType, iconSize, context) {
125
+ var renderedContent = typeof content === 'function' ? content(context) : content;
126
+
125
127
  if (!iconType) {
126
- return content;
128
+ return renderedContent;
127
129
  }
128
130
 
129
131
  return [/*#__PURE__*/React.createElement(Icon, {
130
132
  type: iconType,
131
133
  size: iconSize,
132
134
  key: "teamix-button-icon"
133
- }), content];
135
+ }), renderedContent];
134
136
  };
135
137
 
136
138
  export var ActionButton = function ActionButton(props) {
@@ -154,7 +156,7 @@ export var ActionButton = function ActionButton(props) {
154
156
  }) : _objectSpread(_objectSpread({}, actionProps), others);
155
157
  return /*#__PURE__*/React.createElement(Button, _objectSpread({
156
158
  type: type
157
- }, buttonProps), buttonContent(children, icon, iconSize));
159
+ }, buttonProps), buttonContent(children, icon, iconSize, context));
158
160
  };
159
161
 
160
162
  function renderMenuButtonItem(item, key, context) {
@@ -173,7 +175,7 @@ function renderMenuButtonItem(item, key, context) {
173
175
  }) : _objectSpread({}, menuItemProps);
174
176
  return /*#__PURE__*/React.createElement(MenuButton.Item, _objectSpread({
175
177
  key: key
176
- }, buttonProps), buttonContent(item.children, item.icon));
178
+ }, buttonProps), buttonContent(item.children, item.icon, undefined, context));
177
179
  }
178
180
 
179
181
  function renderCommonActionButtonMenuItem(action, key, context) {
@@ -209,8 +211,11 @@ export var ActionMenuButton = function ActionMenuButton(props) {
209
211
  mode: 'popup',
210
212
  triggerType: 'hover'
211
213
  },
214
+ popupProps: {
215
+ shouldUpdatePosition: true
216
+ },
212
217
  type: type,
213
- label: buttonContent(label || children, icon, iconSize)
218
+ label: buttonContent(label || children, icon, iconSize, context)
214
219
  }, others), actions.map(function (action, i) {
215
220
  return renderCommonActionButtonMenuItem(action, i, context);
216
221
  }));
@@ -255,7 +260,7 @@ function renderCommonActionButton(button, context, isTypeText) {
255
260
  function getDefaultMoreButton(type, moreText) {
256
261
  if (type === 'button') {
257
262
  return {
258
- label: moreText || '更多'
263
+ label: moreText || getMessage('more')
259
264
  };
260
265
  }
261
266
 
@@ -1,6 +1,6 @@
1
- import { LinkPath } from '@teamix/utils';
1
+ import { LocationHistory } from '@teamix/utils';
2
2
  import { BaseAction } from './base';
3
- export interface LinkAction extends BaseAction, LinkPath {
3
+ export interface LinkAction extends BaseAction, LocationHistory {
4
4
  }
5
5
  export declare function useLinkAction(action: LinkAction, context?: any): {
6
6
  [x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => void;
@@ -1,4 +1,4 @@
1
- @import '~@alifd/next/lib/core/index-noreset.scss';
1
+ @import '../../global.scss';
2
2
 
3
3
  $formily-group: #{$css-prefix}formily-group;
4
4
 
@@ -143,6 +143,10 @@ declare const _default: React.ForwardRefExoticComponent<(Partial<import("@teamix
143
143
  type: "tagFilter";
144
144
  } & {
145
145
  children?: React.ReactNode;
146
+ }> | Partial<import("@teamix/pro-field/lib/components/FieldTagFilter").IProFieldMultipleTagFilter & {
147
+ type: "multipleTagPicker";
148
+ } & {
149
+ children?: React.ReactNode;
146
150
  }> | Partial<import("@teamix/pro-field/lib/components/FieldMenuSelect").IProFieldMenuSelect & {
147
151
  type: "menuSelect";
148
152
  } & {
@@ -1,9 +1,4 @@
1
- @import '~@alifd/next/lib/core/index-noreset.scss';
2
-
3
- $form-item-cls: #{$css-prefix}formily-item;
4
- $noborder-font-weight-medium: calc(
5
- var(--form-element-medium-height, 32px) - var(--input-border-width, 1px) * 2
6
- );
1
+ @import '../../global.scss';
7
2
 
8
3
  // Query样式
9
4
  .#{$css-prefix}filter {
@@ -1,6 +1,8 @@
1
- $teamix-pro-form: teamix-pro-form;
1
+ @import '../../global.scss';
2
2
 
3
- .#{$teamix-pro-form}-text {
3
+ $teamix-pro-form-text: #{$teamix-pro-form}-text;
4
+
5
+ .#{$teamix-pro-form-text} {
4
6
  line-height: var(--form-element-medium-height, 32px);
5
7
  color: var(--color-fill1-6, #848484);
6
8
  }
@@ -18,7 +18,7 @@ import { Form, FormLayout } from '@teamix/formily';
18
18
  import TeamixIcon from '@teamix/icon';
19
19
  import { usePrefixCls } from '@teamix/utils';
20
20
  import SchemaForm from '../SchemaForm';
21
- import { mergeArrayValue, getDisplayValues } from '../utils';
21
+ import { mergeArrayValue } from '../utils';
22
22
  import useAutoSubmit from './useAutoSubmit';
23
23
  import useInitialRequest from './useInitialRequest';
24
24
  import './index.scss';
@@ -71,7 +71,7 @@ var ProForm = /*#__PURE__*/memo(function (_ref) {
71
71
  form.addEffects('onChange', function () {
72
72
  onFormValuesChange(function (form) {
73
73
  if (onChange) {
74
- onChange(toJS(form.values), getDisplayValues(form, form.values));
74
+ onChange(toJS(form.values));
75
75
  }
76
76
  });
77
77
  });
@@ -1,14 +1,11 @@
1
- @import '~@alifd/next/lib/core/index-noreset.scss';
2
-
3
- $form-item-cls: #{$css-prefix}formily-item;
4
- $teamix-pro-form: teamix-pro-form;
1
+ @import '../global.scss';
5
2
 
6
3
  // FormItem 样式重写
7
4
  .#{$form-item-cls} {
8
5
  // 标签加粗 主题颜色
9
6
  .#{$form-item-cls}-label label {
10
7
  color: var(--form-label-color, #333333);
11
- font-weight: $font-weight-medium;
8
+ font-weight: var(--font-weight-medium, 500);
12
9
  }
13
10
 
14
11
  // 溢出label样式
@@ -126,10 +123,6 @@ $teamix-pro-form: teamix-pro-form;
126
123
  }
127
124
  }
128
125
 
129
- // 内嵌模式
130
- $inset-font-weight-medium: calc(
131
- var(--form-element-medium-height, 32px) - var(--input-border-width, 1px) * 2
132
- );
133
126
  // 内嵌模式 - 行高
134
127
  .#{$form-item-cls}-inset {
135
128
  line-height: $inset-font-weight-medium;
@@ -155,7 +148,7 @@ $inset-font-weight-medium: calc(
155
148
  .#{$form-item-cls}-label-content {
156
149
  label {
157
150
  color: var(--color-text1-8, #848484);
158
- font-weight: $font-weight-2;
151
+ font-weight: normal;
159
152
  }
160
153
  }
161
154
  .#{$form-item-cls}-colon {
@@ -193,7 +186,7 @@ $inset-font-weight-medium: calc(
193
186
 
194
187
  // Editable预览态行高
195
188
  .#{$css-prefix}formily-editable-content {
196
- line-height: $s-8;
189
+ line-height: var(--form-element-medium-height, 32px);
197
190
  }
198
191
 
199
192
  // 折叠面板
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 获取表单值的可显示值
3
+ * @returns 如果某字段有dataSource,则返回value对应label
4
+ */
5
+ declare const useFormDisplayValues: () => any;
6
+ export default useFormDisplayValues;
@@ -0,0 +1,65 @@
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
+ import { useForm } from '@formily/react';
14
+ import { isArr, isPlainObj, getValueByValue } from '@teamix/utils';
15
+ /**
16
+ * 获取表单值的可显示值
17
+ * @returns 如果某字段有dataSource,则返回value对应label
18
+ */
19
+
20
+ var useFormDisplayValues = function useFormDisplayValues() {
21
+ var form = useForm();
22
+ var values = form.values; // 判断值的类型,递归获取每个值在该结构中的完整路径
23
+
24
+ var getDisplayValues = function getDisplayValues(values) {
25
+ var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
26
+ var displayValues;
27
+
28
+ if (isPlainObj(values)) {
29
+ displayValues = {};
30
+ Object.entries(values).forEach(function (_ref) {
31
+ var _ref2 = _slicedToArray(_ref, 2),
32
+ key = _ref2[0],
33
+ value = _ref2[1];
34
+
35
+ var path = prefix ? "".concat(prefix, ".").concat(key) : "".concat(key);
36
+ displayValues[key] = getDisplayValues(value, path);
37
+ });
38
+ } else if (isArr(values)) {
39
+ displayValues = [];
40
+ values.map(function (value, index) {
41
+ var path = prefix ? "".concat(prefix, ".").concat(index) : "".concat(index);
42
+ displayValues[index] = getDisplayValues(value, path);
43
+ });
44
+ } else {
45
+ // 通过值的完整路径获取字段address(从form实例的indexes中),然后获取该字段的value在该字段dataSource中对应的label
46
+ var address = form.indexes[prefix];
47
+ var field = form.query(address).take();
48
+ displayValues = getValueByValue(field === null || field === void 0 ? void 0 : field.dataSource, values) || values;
49
+ }
50
+
51
+ return displayValues;
52
+ }; // 测试样例
53
+ // const example = {
54
+ // a: [
55
+ // [{ b: 'a.0.0.b', c: 'a.0.0.c' }, { d: 'a.0.1.d' }],
56
+ // { e: [{ f: { g: [{ h: 'a.1.e.0.f.g.0.h' }] } }, 'a.1.e.1'] },
57
+ // ],
58
+ // };
59
+ // console.log(getDisplayValues(example));
60
+
61
+
62
+ return getDisplayValues(values);
63
+ };
64
+
65
+ export default useFormDisplayValues;
@@ -41,7 +41,8 @@ var typeMap = (_typeMap = {
41
41
  ColorRadio: 'string',
42
42
  IconPicker: 'string',
43
43
  JsonInput: 'object',
44
- TagPicker: 'array',
44
+ TagPicker: 'string',
45
+ MultipleTagPicker: 'array',
45
46
  Range: 'string',
46
47
  Search: 'array',
47
48
  ArrayCollapse: 'array',
@@ -44,6 +44,7 @@ import adapterType from './adapterType';
44
44
  import adapterComponent from './adapterComponent';
45
45
  import adapterDecorator from './adapterDecorator';
46
46
  import initializeRequest from './initializeRequest';
47
+ import initializeReactions from './initializeReactions';
47
48
  import initializeDataSource from './initializeDataSource';
48
49
  import initializeRules from './initializeRules';
49
50
  import initializeProField, { proFieldTypeMap } from './initializeProField';
@@ -57,7 +58,7 @@ import initializeFormStep from './initializeFormStep';
57
58
  import initializeFormTab from './initializeFormTab';
58
59
  import initializeFormCollapse from './initializeFormCollapse';
59
60
  import initializeArrayIcon from './initializeArrayIcon';
60
- import { getRandomName, mergeArrayValue, mapSchemaName } from '../utils';
61
+ import { getRandomName, mapSchemaName } from '../utils';
61
62
  import warning from '../warning';
62
63
  export default /*#__PURE__*/memo(function (_ref) {
63
64
  var schema = _ref.schema,
@@ -211,21 +212,10 @@ export default /*#__PURE__*/memo(function (_ref) {
211
212
 
212
213
  var _initializeRules = initializeRules(rules),
213
214
  defaultRules = _initializeRules.rules,
214
- rulesScope = _initializeRules.scope; // 合并reactions
215
+ rulesScope = _initializeRules.scope; // 合并reactions,初始化reactions
215
216
 
216
217
 
217
- var mergedReactions = function () {
218
- var innerReactions = [].concat(_toConsumableArray(requestReactions), _toConsumableArray(dataSourceReactions));
219
-
220
- if (reactions && innerReactions.length) {
221
- return mergeArrayValue(innerReactions, reactions);
222
- } else if (innerReactions.length) {
223
- return innerReactions;
224
- }
225
-
226
- return reactions;
227
- }(); // 合并scope
228
-
218
+ var defaultReactions = initializeReactions(reactions, [].concat(_toConsumableArray(requestReactions), _toConsumableArray(dataSourceReactions))); // 合并scope
229
219
 
230
220
  Object.entries(_objectSpread(_objectSpread(_objectSpread({}, requestScope), dataSourceScope), rulesScope)).map(function (_ref2) {
231
221
  var _ref3 = _slicedToArray(_ref2, 2),
@@ -240,7 +230,7 @@ export default /*#__PURE__*/memo(function (_ref) {
240
230
  decorator: defaultDecorator,
241
231
  decoratorProps: defaultDecoratorProps,
242
232
  rules: defaultRules,
243
- reactions: mergedReactions,
233
+ reactions: defaultReactions,
244
234
  dataSource: defaultDataSource
245
235
  })); // 递归子组件
246
236
 
@@ -46,6 +46,7 @@ var proFieldTypeMap = {
46
46
  IconPicker: 'icon',
47
47
  JsonInput: 'json',
48
48
  TagPicker: 'tagPicker',
49
+ MultipleTagPicker: 'multipleTagPicker',
49
50
  Range: 'range',
50
51
  Search: 'search' // Upload: 'upload',
51
52
 
@@ -0,0 +1,2 @@
1
+ declare const initializeReactions: (reactions: any, innerReactions: any) => any;
2
+ export default initializeReactions;
@@ -0,0 +1,89 @@
1
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
2
+
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
4
+
5
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+
7
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
8
+
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."); }
10
+
11
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
12
+
13
+ function _toArray(arr) { return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); }
14
+
15
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
16
+
17
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
18
+
19
+ 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."); }
20
+
21
+ 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); }
22
+
23
+ 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; }
24
+
25
+ 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; }
26
+
27
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
28
+
29
+ import { isPlainObj, getValueByValue } from '@teamix/utils';
30
+ import { mergeArrayValue } from '../utils';
31
+ import schemaNameMap from '../schemaNameMap';
32
+
33
+ var mapSchemaName = function mapSchemaName(schema) {
34
+ if (isPlainObj(schema)) {
35
+ var newSchema = {};
36
+ Object.entries(schema).forEach(function (_ref) {
37
+ var _ref2 = _slicedToArray(_ref, 2),
38
+ key = _ref2[0],
39
+ value = _ref2[1];
40
+
41
+ var _key$split = key.split('.'),
42
+ _key$split2 = _toArray(_key$split),
43
+ firstKey = _key$split2[0],
44
+ otherKey = _key$split2.slice(1);
45
+
46
+ var newFirstKey = getValueByValue(schemaNameMap, firstKey, {
47
+ inputKey: 'proForm',
48
+ outputKey: 'formily'
49
+ }) || firstKey;
50
+ var newKey = [newFirstKey].concat(_toConsumableArray(otherKey)).join('.');
51
+ newSchema[newKey] = value;
52
+ });
53
+ return newSchema;
54
+ }
55
+
56
+ return schema;
57
+ };
58
+
59
+ var initializeReactions = function initializeReactions(reactions, innerReactions) {
60
+ var temp = innerReactions; // 合并reactions
61
+
62
+ if (reactions) {
63
+ temp = mergeArrayValue(innerReactions, reactions);
64
+ } // schema名称映射,由ProFormSchema映射为formilySchema
65
+
66
+
67
+ temp = temp.map(function (item) {
68
+ var _item$fulfill, _item$otherwise;
69
+
70
+ var fulfillSchema = mapSchemaName(item === null || item === void 0 ? void 0 : (_item$fulfill = item.fulfill) === null || _item$fulfill === void 0 ? void 0 : _item$fulfill.schema);
71
+ var otherwiseSchema = mapSchemaName(item === null || item === void 0 ? void 0 : (_item$otherwise = item.otherwise) === null || _item$otherwise === void 0 ? void 0 : _item$otherwise.schema);
72
+
73
+ if (fulfillSchema || otherwiseSchema) {
74
+ return _objectSpread(_objectSpread({}, item), {}, {
75
+ fulfill: _objectSpread(_objectSpread({}, item === null || item === void 0 ? void 0 : item.fulfill), {}, {
76
+ schema: fulfillSchema
77
+ }),
78
+ otherwise: _objectSpread(_objectSpread({}, item === null || item === void 0 ? void 0 : item.otherwise), {}, {
79
+ schema: otherwiseSchema
80
+ })
81
+ });
82
+ }
83
+
84
+ return item;
85
+ });
86
+ return temp;
87
+ };
88
+
89
+ export default initializeReactions;
@@ -0,0 +1,12 @@
1
+ @import '~@alicloudfe/components/lib/common-var.scss';
2
+
3
+ $form-item-cls: #{$css-prefix}formily-item;
4
+ $teamix-pro-form: teamix-pro-form;
5
+
6
+ $inset-font-weight-medium: calc(
7
+ var(--form-element-medium-height, 32px) - var(--input-border-width, 1px) * 2
8
+ );
9
+
10
+ $noborder-font-weight-medium: calc(
11
+ var(--form-element-medium-height, 32px) - var(--input-border-width, 1px) * 2
12
+ );
@@ -13,10 +13,10 @@ export * as formilyTeamix from '@teamix/formily';
13
13
  * 导出常用formily内容,需谨慎限制
14
14
  */
15
15
  import { createForm, registerValidateRules as registerRules, registerValidateFormats as registerFormats, registerValidateLocale, setValidateLanguage } from '@formily/core';
16
- import { FormConsumer } from '@formily/react';
16
+ import { FormConsumer, useForm } from '@formily/react';
17
17
  import { FormDialog, FormDrawer, FormStep, FormTab, FormCollapse } from '@teamix/formily';
18
- import { getDisplayValues } from './utils';
19
- export { createForm, FormConsumer, FormDialog, FormDrawer, FormStep, FormTab, FormCollapse, registerRules, registerFormats, registerValidateLocale, setValidateLanguage, getDisplayValues, };
18
+ import useFormDisplayValues from './ProForm/useFormDisplayValues';
19
+ export { createForm, FormConsumer, FormDialog, FormDrawer, FormStep, FormTab, FormCollapse, registerRules, registerFormats, registerValidateLocale, setValidateLanguage, useForm, useFormDisplayValues, };
20
20
  /**
21
21
  * 导出 Filter 组件
22
22
  */
package/es/form/index.js CHANGED
@@ -19,10 +19,10 @@ export { _formilyTeamix as formilyTeamix };
19
19
  */
20
20
 
21
21
  import { createForm, registerValidateRules as registerRules, registerValidateFormats as registerFormats, registerValidateLocale, setValidateLanguage } from '@formily/core';
22
- import { FormConsumer } from '@formily/react';
22
+ import { FormConsumer, useForm } from '@formily/react';
23
23
  import { FormDialog, FormDrawer, FormStep, FormTab, FormCollapse } from '@teamix/formily';
24
- import { getDisplayValues } from './utils';
25
- export { createForm, FormConsumer, FormDialog, FormDrawer, FormStep, FormTab, FormCollapse, registerRules, registerFormats, registerValidateLocale, setValidateLanguage, getDisplayValues };
24
+ import useFormDisplayValues from './ProForm/useFormDisplayValues';
25
+ export { createForm, FormConsumer, FormDialog, FormDrawer, FormStep, FormTab, FormCollapse, registerRules, registerFormats, registerValidateLocale, setValidateLanguage, useForm, useFormDisplayValues };
26
26
  /**
27
27
  * 导出 Filter 组件
28
28
  */
@@ -6,7 +6,7 @@ export interface anyObject {
6
6
  [propName: string]: any;
7
7
  }
8
8
  declare type FieldDisplayTypes = 'none' | 'hidden' | 'visible';
9
- export declare type IBaseComponent = 'Input' | 'Password' | 'TextArea' | 'NumberPicker' | 'Percent' | 'Money' | 'Select' | 'MultipleSelect' | 'TreeSelect' | 'Cascader' | 'MultipleCascader' | 'ArbitraryCascader' | 'Radio' | 'Checkbox' | 'Switch' | 'DatePicker' | 'TimePicker' | 'DateTimePicker' | 'WeekPicker' | 'MonthPicker' | 'YearPicker' | 'QuarterPicker' | 'DateRangePicker' | 'TimeRangePicker' | 'DateTimeRangePicker' | 'WeekRangePicker' | 'MonthRangePicker' | 'YearRangePicker' | 'QuarterRangePicker' | 'Transfer' | 'Upload' | 'ColorPicker' | 'ColorRadio' | 'IconPicker' | 'JsonInput' | 'TagPicker' | 'Range' | 'Search';
9
+ export declare type IBaseComponent = 'Input' | 'Password' | 'TextArea' | 'NumberPicker' | 'Percent' | 'Money' | 'Select' | 'MultipleSelect' | 'TreeSelect' | 'Cascader' | 'MultipleCascader' | 'ArbitraryCascader' | 'Radio' | 'Checkbox' | 'Switch' | 'DatePicker' | 'TimePicker' | 'DateTimePicker' | 'WeekPicker' | 'MonthPicker' | 'YearPicker' | 'QuarterPicker' | 'DateRangePicker' | 'TimeRangePicker' | 'DateTimeRangePicker' | 'WeekRangePicker' | 'MonthRangePicker' | 'YearRangePicker' | 'QuarterRangePicker' | 'Transfer' | 'Upload' | 'ColorPicker' | 'ColorRadio' | 'IconPicker' | 'JsonInput' | 'TagPicker' | 'MultipleTagPicker' | 'Range' | 'Search';
10
10
  export declare type IButtonComponent = 'Submit' | 'Reset';
11
11
  export 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';
12
12
  export 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';
@@ -57,7 +57,7 @@ export interface IFormProps extends IFormLayoutProps {
57
57
  initialValues?: anyObject;
58
58
  initialRequest?: CommonRequestConfig;
59
59
  previewTextPlaceholder?: ReactNode;
60
- onChange?: (values: any, displayValues: any) => any;
60
+ onChange?: (values: any, displayValues?: any) => any;
61
61
  onSubmit?: ((values: any) => any) | CommonRequestConfig;
62
62
  onSubmitFailed?: (feedbacks: IFormFeedback[]) => void;
63
63
  }
@@ -1,14 +1,37 @@
1
- import { getValueByValue } from '@teamix/utils';
1
+ /**
2
+ * 映射字段size,主要是default转medium
3
+ * @param props component的props
4
+ * @param field 当前字段实例
5
+ * @returns 映射后的字段属性
6
+ */
7
+ declare const mapSize: (props: any, field: any) => any;
8
+ /**
9
+ * 映射字段state
10
+ * @param props component的props
11
+ * @param field 当前字段实例
12
+ * @returns 映射后的字段属性
13
+ */
14
+ declare const mapStatus: (props: any, field: any) => any;
15
+ /**
16
+ * 为未配置name的字段添加随机字段名称
17
+ * @param prefix 随机字段名称前缀,默认为name
18
+ * @returns 随机字段名称
19
+ */
2
20
  interface IGetRandomName {
3
21
  (prefix?: string): string;
4
22
  }
5
- declare const mapSize: (props: any, field: any) => any;
6
- declare const mapStatus: (props: any, field: any) => any;
7
23
  declare const getRandomName: IGetRandomName;
24
+ /**
25
+ * 将ProForm的key映射为formily的key,然后筛除掉无效的key/value
26
+ * @param obj
27
+ * @returns
28
+ */
8
29
  declare const mapSchemaName: (obj: any) => any;
30
+ /**
31
+ * 合并数组或非数组,不移除无效值
32
+ * @param arr 数组
33
+ * @param v 数组或其他
34
+ * @returns 合并数组或合并其他值
35
+ */
9
36
  declare const mergeArrayValue: (arr: any[], v?: any) => any[];
10
- interface IGetDisplayValues {
11
- (form: any, values: any, prefix?: string): any;
12
- }
13
- declare const getDisplayValues: IGetDisplayValues;
14
- export { getRandomName, getValueByValue, getDisplayValues, mapSize, mapStatus, mergeArrayValue, mapSchemaName, };
37
+ export { getRandomName, mapSize, mapStatus, mergeArrayValue, mapSchemaName };
package/es/form/utils.js CHANGED
@@ -27,6 +27,12 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
27
27
  import { useFormLayout, useFormShallowLayout } from '@teamix/formily';
28
28
  import { isArr, isObj, getValueByValue } from '@teamix/utils';
29
29
  import schemaNameMap from './schemaNameMap';
30
+ /**
31
+ * 映射字段size,主要是default转medium
32
+ * @param props component的props
33
+ * @param field 当前字段实例
34
+ * @returns 映射后的字段属性
35
+ */
30
36
 
31
37
  var mapSize = function mapSize(props, field) {
32
38
  var layout = _objectSpread(_objectSpread({}, useFormShallowLayout()), useFormLayout());
@@ -39,6 +45,13 @@ var mapSize = function mapSize(props, field) {
39
45
  size: props.size || takeSize()
40
46
  });
41
47
  };
48
+ /**
49
+ * 映射字段state
50
+ * @param props component的props
51
+ * @param field 当前字段实例
52
+ * @returns 映射后的字段属性
53
+ */
54
+
42
55
 
43
56
  var mapStatus = function mapStatus(props, field) {
44
57
  var takeStatus = function takeStatus() {
@@ -66,7 +79,12 @@ var mapStatus = function mapStatus(props, field) {
66
79
  var getRandomName = function getRandomName() {
67
80
  var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'name';
68
81
  return "".concat(prefix, "_").concat(Math.floor(Math.random() * Math.pow(10, 18)));
69
- }; // 将ProForm的key映射为formily的key,然后筛除掉无效的keyvalue
82
+ };
83
+ /**
84
+ * 将ProForm的key映射为formily的key,然后筛除掉无效的key/value
85
+ * @param obj
86
+ * @returns
87
+ */
70
88
 
71
89
 
72
90
  var mapSchemaName = function mapSchemaName(obj) {
@@ -97,6 +115,13 @@ var mapSchemaName = function mapSchemaName(obj) {
97
115
  });
98
116
  return temp;
99
117
  };
118
+ /**
119
+ * 合并数组或非数组,不移除无效值
120
+ * @param arr 数组
121
+ * @param v 数组或其他
122
+ * @returns 合并数组或合并其他值
123
+ */
124
+
100
125
 
101
126
  var mergeArrayValue = function mergeArrayValue(arr, v) {
102
127
  if (isArr(v)) {
@@ -104,48 +129,6 @@ var mergeArrayValue = function mergeArrayValue(arr, v) {
104
129
  }
105
130
 
106
131
  return [].concat(_toConsumableArray(arr), [v]);
107
- }; // 获取form的displayValues
108
-
109
-
110
- var getDisplayValues = function getDisplayValues(form, values) {
111
- var prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
112
- var displayValues = {}; // 在form实例中,通过name获取该field的值在dataSource对应的label
113
-
114
- var getLabelByKey = function getLabelByKey(name, value) {
115
- var address = form.indexes[name] || '';
116
- var field = form.query(address).take() || {};
117
- var dataSource = field.dataSource;
118
- return getValueByValue(dataSource, value);
119
- };
120
-
121
- Object.entries(values).forEach(function (_ref3) {
122
- var _ref4 = _slicedToArray(_ref3, 2),
123
- key = _ref4[0],
124
- value = _ref4[1];
125
-
126
- var label;
127
-
128
- if (isArr(value)) {
129
- value.map(function (v, i) {
130
- if (isObj(v)) {
131
- // 值是对象数组
132
- label = getDisplayValues(form, v, "".concat(prefix).concat(key, ".").concat(i, "."));
133
- } else if (isArr(v)) {
134
- // 值是多重数组
135
- console.warn('Multiple array, Please dingding qilou.zhl.');
136
- } else if (v !== undefined && v !== null) {
137
- label = getLabelByKey("".concat(prefix).concat(key, ".").concat(i), value);
138
- }
139
- });
140
- } else if (isObj(value)) {
141
- label = getDisplayValues(form, value, "".concat(key, "."));
142
- } else {
143
- label = getLabelByKey("".concat(prefix).concat(key), value);
144
- }
145
-
146
- displayValues[key] = label;
147
- });
148
- return displayValues;
149
132
  };
150
133
 
151
- export { getRandomName, getValueByValue, getDisplayValues, mapSize, mapStatus, mergeArrayValue, mapSchemaName };
134
+ export { getRandomName, mapSize, mapStatus, mergeArrayValue, mapSchemaName };
package/es/index.d.ts CHANGED
@@ -21,5 +21,5 @@ export * from './page-container';
21
21
  export * from './page-header';
22
22
  export * from './skeleton';
23
23
  export * from './table';
24
- declare const version = "1.1.29";
24
+ declare const version = "1.1.33";
25
25
  export { version, ProAction, ProCard, ProField, ProForm, ProInfo, ProPageContainer, ProPageHeader, ProSkeleton, ProTable, hooks, nocode, templates, utils, };