@teamix/pro 1.1.31 → 1.1.35

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 (89) hide show
  1. package/dist/pro.css +1 -1
  2. package/dist/pro.js +1357 -771
  3. package/dist/pro.min.css +1 -1
  4. package/dist/pro.min.js +1 -1
  5. package/es/actions/dialog-form.d.ts +8 -1
  6. package/es/actions/dialog-form.js +32 -15
  7. package/es/actions/dialog-info.d.ts +9 -0
  8. package/es/actions/dialog-info.js +23 -0
  9. package/es/actions/dialog.d.ts +2 -0
  10. package/es/actions/dialog.js +11 -4
  11. package/es/actions/drawer-info.d.ts +6 -0
  12. package/es/actions/drawer-info.js +7 -0
  13. package/es/actions/index.d.ts +11 -5
  14. package/es/actions/index.js +40 -19
  15. package/es/actions/index.scss +8 -0
  16. package/es/actions/link.d.ts +2 -2
  17. package/es/actions/link.js +2 -12
  18. package/es/form/Components/ProField/index.d.ts +4 -0
  19. package/es/form/ProForm/index.js +2 -2
  20. package/es/form/ProForm/useFormDisplayValues.d.ts +6 -0
  21. package/es/form/ProForm/useFormDisplayValues.js +65 -0
  22. package/es/form/SchemaForm/adapterType.js +2 -1
  23. package/es/form/SchemaForm/initializeProField.js +1 -0
  24. package/es/form/SchemaForm/initializeReactions.js +82 -6
  25. package/es/form/SchemaForm/reactions.js +4 -2
  26. package/es/form/index.d.ts +3 -3
  27. package/es/form/index.js +3 -3
  28. package/es/form/typing.d.ts +2 -2
  29. package/es/form/utils.d.ts +31 -8
  30. package/es/form/utils.js +27 -44
  31. package/es/index.d.ts +1 -1
  32. package/es/index.js +1 -1
  33. package/es/info/components/InfoValueItem/index.js +108 -26
  34. package/es/info/components/baseInfo/index.d.ts +3 -1
  35. package/es/info/components/baseInfo/index.js +6 -33
  36. package/es/info/components/headerInfo/index.d.ts +3 -1
  37. package/es/info/components/headerInfo/index.js +8 -39
  38. package/es/info/components/tableInfo/index.js +4 -21
  39. package/es/info/index.js +50 -28
  40. package/es/info/index.scss +0 -4
  41. package/es/info/typing.d.ts +14 -5
  42. package/es/page-header/index.js +1 -1
  43. package/es/table/components/Filter/index.js +6 -2
  44. package/es/table/index.js +3 -1
  45. package/es/table/typing.d.ts +8 -4
  46. package/es/table/utils/columnRender.js +38 -11
  47. package/lib/actions/dialog-form.d.ts +8 -1
  48. package/lib/actions/dialog-form.js +32 -15
  49. package/lib/actions/dialog-info.d.ts +9 -0
  50. package/lib/actions/dialog-info.js +37 -0
  51. package/lib/actions/dialog.d.ts +2 -0
  52. package/lib/actions/dialog.js +11 -4
  53. package/lib/actions/drawer-info.d.ts +6 -0
  54. package/lib/actions/drawer-info.js +18 -0
  55. package/lib/actions/index.d.ts +11 -5
  56. package/lib/actions/index.js +41 -18
  57. package/lib/actions/index.scss +8 -0
  58. package/lib/actions/link.d.ts +2 -2
  59. package/lib/actions/link.js +2 -12
  60. package/lib/form/Components/ProField/index.d.ts +4 -0
  61. package/lib/form/ProForm/index.js +1 -1
  62. package/lib/form/ProForm/useFormDisplayValues.d.ts +6 -0
  63. package/lib/form/ProForm/useFormDisplayValues.js +74 -0
  64. package/lib/form/SchemaForm/adapterType.js +2 -1
  65. package/lib/form/SchemaForm/initializeProField.js +1 -0
  66. package/lib/form/SchemaForm/initializeReactions.js +87 -7
  67. package/lib/form/SchemaForm/reactions.js +4 -2
  68. package/lib/form/index.d.ts +3 -3
  69. package/lib/form/index.js +15 -8
  70. package/lib/form/typing.d.ts +2 -2
  71. package/lib/form/utils.d.ts +31 -8
  72. package/lib/form/utils.js +28 -54
  73. package/lib/index.d.ts +1 -1
  74. package/lib/index.js +1 -1
  75. package/lib/info/components/InfoValueItem/index.js +107 -25
  76. package/lib/info/components/baseInfo/index.d.ts +3 -1
  77. package/lib/info/components/baseInfo/index.js +5 -40
  78. package/lib/info/components/headerInfo/index.d.ts +3 -1
  79. package/lib/info/components/headerInfo/index.js +7 -46
  80. package/lib/info/components/tableInfo/index.js +4 -22
  81. package/lib/info/index.js +52 -28
  82. package/lib/info/index.scss +0 -4
  83. package/lib/info/typing.d.ts +14 -5
  84. package/lib/page-header/index.js +1 -1
  85. package/lib/table/components/Filter/index.js +6 -2
  86. package/lib/table/index.js +3 -1
  87. package/lib/table/typing.d.ts +8 -4
  88. package/lib/table/utils/columnRender.js +38 -11
  89. package/package.json +1 -1
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ exports.useDialogInfoAction = useDialogInfoAction;
8
+
9
+ var _dialog = _interopRequireDefault(require("./dialog"));
10
+
11
+ var _ = require("..");
12
+
13
+ var _excluded = ["schema"];
14
+
15
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
+
17
+ 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; }
18
+
19
+ 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; }
20
+
21
+ function useDialogInfoAction(action, context) {
22
+ var schema = action.schema,
23
+ others = _objectWithoutProperties(action, _excluded);
24
+
25
+ return (0, _dialog.default)(Object.assign({
26
+ component: _.ProInfo,
27
+ closeable: true,
28
+ size: 'mini',
29
+ schema: Object.assign({
30
+ backgroundColor: 'grey',
31
+ compacted: false
32
+ }, schema)
33
+ }, others), context);
34
+ }
35
+
36
+ var _default = useDialogInfoAction;
37
+ exports.default = _default;
@@ -7,6 +7,8 @@ export interface DialogAction extends Omit<RequestAction, 'url'>, Omit<QuickShow
7
7
  dialogType?: 'dialog' | 'drawer';
8
8
  dialogQuickShowType?: 'alert' | 'confirm';
9
9
  messageType?: 'success' | 'warning' | 'error' | 'notice' | 'help' | 'loading';
10
+ beforeContent?: React.ReactNode;
11
+ afterContent?: React.ReactNode;
10
12
  }
11
13
  export declare function useDialogAction(action: DialogAction, context?: any): {
12
14
  [x: string]: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void;
@@ -21,7 +21,7 @@ var _base = require("./base");
21
21
  var _request = require("./request");
22
22
 
23
23
  var _excluded = ["url", "method", "params", "data", "extendParams", "successMsg", "errorMsg", "formatParams", "formatResult", "onSuccess", "onError"],
24
- _excluded2 = ["title", "content", "component", "schema", "onFinish", "dialogType", "dialogQuickShowType", "messageType", "beforeRequest", "onTrigger", "link"];
24
+ _excluded2 = ["title", "content", "component", "schema", "onFinish", "dialogType", "dialogQuickShowType", "messageType", "beforeRequest", "onTrigger", "link", "beforeContent", "afterContent"];
25
25
 
26
26
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
27
27
 
@@ -96,6 +96,8 @@ function useDialogAction(action, context) {
96
96
  beforeRequest = _getTargetValue.beforeRequest,
97
97
  onTrigger = _getTargetValue.onTrigger,
98
98
  link = _getTargetValue.link,
99
+ beforeContent = _getTargetValue.beforeContent,
100
+ afterContent = _getTargetValue.afterContent,
99
101
  dialogOtherProps = _objectWithoutProperties(_getTargetValue, _excluded2);
100
102
 
101
103
  var dialogMethod = dialogType === 'drawer' ? _components.Drawer : _components.Dialog;
@@ -171,13 +173,18 @@ function useDialogAction(action, context) {
171
173
  var dialogContext = Object.assign({}, context, {
172
174
  hide: hide
173
175
  });
176
+ var dialogContent = Component ? /*#__PURE__*/_react.default.createElement(Component, _objectSpread({
177
+ key: (0, _utils.uuid)()
178
+ }, componentProps)) : addContextForReactNode(content, dialogContext);
174
179
  var ret = dialogMethod.show(_objectSpread(_objectSpread({
175
180
  // @ts-ignore
176
181
  onOk: onOk,
177
182
  title: addContextForReactNode(title, dialogContext),
178
- content: Component ? /*#__PURE__*/_react.default.createElement(Component, _objectSpread({
179
- key: (0, _utils.uuid)()
180
- }, componentProps)) : addContextForReactNode(content, dialogContext),
183
+ content: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, beforeContent && /*#__PURE__*/_react.default.createElement("div", {
184
+ className: "teamix-pro-dialog-before-content"
185
+ }, beforeContent), dialogContent, afterContent && /*#__PURE__*/_react.default.createElement("div", {
186
+ className: "teamix-pro-dialog-after-content"
187
+ }, afterContent)),
181
188
  closeable: !loading
182
189
  }, dialogProps), dialogOtherProps));
183
190
  store.hide = ret.hide;
@@ -0,0 +1,6 @@
1
+ import { DialogInfoAction } from './dialog-info';
2
+ export declare type DrawerInfoAction = DialogInfoAction;
3
+ export declare function useDrawerInfoAction(action: DrawerInfoAction, context?: any): {
4
+ [x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => void;
5
+ };
6
+ export default useDrawerInfoAction;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ exports.useDrawerInfoAction = useDrawerInfoAction;
8
+
9
+ var _dialogInfo = require("./dialog-info");
10
+
11
+ function useDrawerInfoAction(action, context) {
12
+ return (0, _dialogInfo.useDialogInfoAction)(Object.assign({
13
+ dialogType: 'drawer'
14
+ }, action), context);
15
+ }
16
+
17
+ var _default = useDrawerInfoAction;
18
+ exports.default = _default;
@@ -10,17 +10,17 @@ import { NoticeAction } from './notice';
10
10
  import { ErrorAction } from './error';
11
11
  import { DialogFormAction } from './dialog-form';
12
12
  import { DialogTableAction } from './dialog-table';
13
+ import { DialogInfoAction } from './dialog-info';
13
14
  import { DrawerAction } from './drawer';
14
15
  import { DrawerFormAction } from './drawer-form';
15
16
  import { DrawerTableAction } from './drawer-table';
17
+ import { DrawerInfoAction } from './drawer-info';
16
18
  import './index.scss';
17
19
  export declare type ActionConfig = ({
18
20
  type: 'link';
19
21
  } & LinkAction) | ({
20
22
  type: 'request';
21
23
  } & RequestAction) | ({
22
- type: 'dialog';
23
- } & DialogAction) | ({
24
24
  type: 'confirm';
25
25
  } & ConfirmAction) | ({
26
26
  type: 'danger-confirm';
@@ -29,16 +29,22 @@ export declare type ActionConfig = ({
29
29
  } & NoticeAction) | ({
30
30
  type: 'error';
31
31
  } & ErrorAction) | ({
32
+ type: 'dialog';
33
+ } & DialogAction) | ({
32
34
  type: 'dialog-form';
33
35
  } & DialogFormAction) | ({
36
+ type: 'dialog-table';
37
+ } & DialogTableAction) | ({
38
+ type: 'dialog-info';
39
+ } & DialogInfoAction) | ({
34
40
  type: 'drawer';
35
41
  } & DrawerAction) | ({
36
42
  type: 'drawer-form';
37
43
  } & DrawerFormAction) | ({
38
- type: 'dialog-table';
39
- } & DialogTableAction) | ({
40
44
  type: 'drawer-table';
41
- } & DrawerTableAction);
45
+ } & DrawerTableAction) | ({
46
+ type: 'drawer-info';
47
+ } & DrawerInfoAction);
42
48
  export declare function registerActionHandler(id: string, extendActionId: string, defaultConfig: any): void;
43
49
  export declare const useAction: any;
44
50
  export interface IActionButton extends ButtonProps {
@@ -37,12 +37,16 @@ var _dialogForm = require("./dialog-form");
37
37
 
38
38
  var _dialogTable = require("./dialog-table");
39
39
 
40
+ var _dialogInfo = require("./dialog-info");
41
+
40
42
  var _drawer = require("./drawer");
41
43
 
42
44
  var _drawerForm = require("./drawer-form");
43
45
 
44
46
  var _drawerTable = require("./drawer-table");
45
47
 
48
+ var _drawerInfo = require("./drawer-info");
49
+
46
50
  require("./index.scss");
47
51
 
48
52
  var _excluded = ["type"],
@@ -131,6 +135,10 @@ var useAction = function useAction(config, context) {
131
135
  return (0, _dialogTable.useDialogTableAction)(others, context);
132
136
  }
133
137
 
138
+ if (type === 'dialog-info') {
139
+ return (0, _dialogInfo.useDialogInfoAction)(others, context);
140
+ }
141
+
134
142
  if (type === 'drawer') {
135
143
  return (0, _drawer.useDrawerAction)(others, context);
136
144
  }
@@ -143,6 +151,10 @@ var useAction = function useAction(config, context) {
143
151
  return (0, _drawerTable.useDrawerTableAction)(others, context);
144
152
  }
145
153
 
154
+ if (type === 'drawer-info') {
155
+ return (0, _drawerInfo.useDrawerInfoAction)(others, context);
156
+ }
157
+
146
158
  var registedAction = RegistedActions.get(type);
147
159
 
148
160
  if (!registedAction) {
@@ -156,16 +168,18 @@ var useAction = function useAction(config, context) {
156
168
 
157
169
  exports.useAction = useAction;
158
170
 
159
- var buttonContent = function buttonContent(content, iconType, iconSize) {
171
+ var buttonContent = function buttonContent(content, iconType, iconSize, context) {
172
+ var renderedContent = typeof content === 'function' ? content(context) : content;
173
+
160
174
  if (!iconType) {
161
- return content;
175
+ return renderedContent;
162
176
  }
163
177
 
164
178
  return [/*#__PURE__*/_react.default.createElement(_icon.default, {
165
179
  type: iconType,
166
180
  size: iconSize,
167
181
  key: "teamix-button-icon"
168
- }), content];
182
+ }), renderedContent];
169
183
  };
170
184
 
171
185
  var ActionButton = function ActionButton(props) {
@@ -189,39 +203,45 @@ var ActionButton = function ActionButton(props) {
189
203
  }) : _objectSpread(_objectSpread({}, actionProps), others);
190
204
  return /*#__PURE__*/_react.default.createElement(_components.Button, _objectSpread({
191
205
  type: type
192
- }, buttonProps), buttonContent(children, icon, iconSize));
206
+ }, buttonProps), buttonContent(children, icon, iconSize, context));
193
207
  };
194
208
 
195
209
  exports.ActionButton = ActionButton;
196
210
 
197
211
  function renderMenuButtonItem(item, key, context) {
198
- var menuItemActionConfig = Object.assign({}, item.config, {
212
+ var config = item.config,
213
+ btnContext = item.context,
214
+ _onClick2 = item.onClick,
215
+ children = item.children,
216
+ icon = item.icon,
217
+ disabled = item.disabled;
218
+ var menuItemActionConfig = Object.assign({}, config, {
199
219
  trigger: 'onClick'
200
220
  });
201
221
 
202
- var _useAction = useAction(menuItemActionConfig, item.context || context),
222
+ var _useAction = useAction(menuItemActionConfig, btnContext || context),
203
223
  loading = _useAction.loading,
204
224
  menuItemProps = _objectWithoutProperties(_useAction, _excluded3);
205
225
 
206
- var buttonProps = item.onClick ? _objectSpread(_objectSpread({}, menuItemProps), {}, {
226
+ var buttonProps = _onClick2 ? _objectSpread(_objectSpread({}, menuItemProps), {}, {
207
227
  onClick: function onClick(e) {
208
- return item.onClick(e, context);
228
+ return _onClick2(e, context);
209
229
  }
210
230
  }) : _objectSpread({}, menuItemProps);
211
231
  return /*#__PURE__*/_react.default.createElement(_components.MenuButton.Item, _objectSpread({
212
- key: key
213
- }, buttonProps), buttonContent(item.children, item.icon));
232
+ key: key,
233
+ disabled: disabled
234
+ }, buttonProps), buttonContent(children, icon, undefined, context));
214
235
  }
215
236
 
216
237
  function renderCommonActionButtonMenuItem(action, key, context) {
217
- // @ts-ignore
218
- if (action.actions && action.actions.length) {
238
+ var menuBtn = action;
239
+
240
+ if (menuBtn.actions && menuBtn.actions.length && menuBtn.disabled !== true) {
219
241
  return /*#__PURE__*/_react.default.createElement(_components.Menu.SubMenu, {
220
242
  key: key,
221
- label: // @ts-ignore
222
- action.label || action.children
223
- }, //@ts-ignore
224
- action.actions.map(function (a, j) {
243
+ label: menuBtn.label || menuBtn.children
244
+ }, menuBtn.actions.map(function (a, j) {
225
245
  return renderCommonActionButtonMenuItem(a, j, context);
226
246
  }));
227
247
  }
@@ -246,8 +266,11 @@ var ActionMenuButton = function ActionMenuButton(props) {
246
266
  mode: 'popup',
247
267
  triggerType: 'hover'
248
268
  },
269
+ popupProps: {
270
+ shouldUpdatePosition: true
271
+ },
249
272
  type: type,
250
- label: buttonContent(label || children, icon, iconSize)
273
+ label: buttonContent(label || children, icon, iconSize, context)
251
274
  }, others), actions.map(function (action, i) {
252
275
  return renderCommonActionButtonMenuItem(action, i, context);
253
276
  }));
@@ -295,7 +318,7 @@ function renderCommonActionButton(button, context, isTypeText) {
295
318
  function getDefaultMoreButton(type, moreText) {
296
319
  if (type === 'button') {
297
320
  return {
298
- label: moreText || '更多'
321
+ label: moreText || (0, _utils.getMessage)('more')
299
322
  };
300
323
  }
301
324
 
@@ -29,6 +29,14 @@
29
29
  }
30
30
  }
31
31
 
32
+ .teamix-pro-dialog-before-content {
33
+ margin-bottom: var(--s-2);
34
+ }
35
+
36
+ .teamix-pro-dialog-after-content {
37
+ margin-top: var(--s-2);
38
+ }
39
+
32
40
  .next-menu-divider + .next-menu-divider {
33
41
  display: none;
34
42
  }
@@ -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;
@@ -17,19 +17,9 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
17
17
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
18
18
 
19
19
  function useLinkAction(action, context) {
20
- var _getTargetValue = (0, _utils.getTargetValue)(action, context),
21
- to = _getTargetValue.to,
22
- search = _getTargetValue.search,
23
- hash = _getTargetValue.hash,
24
- blank = _getTargetValue.blank;
25
-
20
+ var linkAction = (0, _utils.getTargetValue)(action, context);
26
21
  return _objectSpread({}, (0, _base.eventHandler)(action, function () {
27
- (0, _utils.goToLink)({
28
- to: to,
29
- search: search,
30
- hash: hash,
31
- blank: blank
32
- });
22
+ (0, _utils.goToLink)(linkAction);
33
23
  }));
34
24
  }
35
25
 
@@ -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
  } & {
@@ -98,7 +98,7 @@ var ProForm = /*#__PURE__*/(0, _react.memo)(function (_ref) {
98
98
  form.addEffects('onChange', function () {
99
99
  (0, _core.onFormValuesChange)(function (form) {
100
100
  if (onChange) {
101
- onChange((0, _reactive.toJS)(form.values), (0, _utils2.getDisplayValues)(form, form.values));
101
+ onChange((0, _reactive.toJS)(form.values));
102
102
  }
103
103
  });
104
104
  });
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 获取表单值的可显示值
3
+ * @returns 如果某字段有dataSource,则返回value对应label
4
+ */
5
+ declare const useFormDisplayValues: () => any;
6
+ export default useFormDisplayValues;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = require("@formily/react");
9
+
10
+ var _utils = require("@teamix/utils");
11
+
12
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
13
+
14
+ 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."); }
15
+
16
+ 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); }
17
+
18
+ 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; }
19
+
20
+ 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; }
21
+
22
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
23
+
24
+ /**
25
+ * 获取表单值的可显示值
26
+ * @returns 如果某字段有dataSource,则返回value对应label
27
+ */
28
+ var useFormDisplayValues = function useFormDisplayValues() {
29
+ var form = (0, _react.useForm)();
30
+ var values = form.values; // 判断值的类型,递归获取每个值在该结构中的完整路径
31
+
32
+ var getDisplayValues = function getDisplayValues(values) {
33
+ var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
34
+ var displayValues;
35
+
36
+ if ((0, _utils.isPlainObj)(values)) {
37
+ displayValues = {};
38
+ Object.entries(values).forEach(function (_ref) {
39
+ var _ref2 = _slicedToArray(_ref, 2),
40
+ key = _ref2[0],
41
+ value = _ref2[1];
42
+
43
+ var path = prefix ? "".concat(prefix, ".").concat(key) : "".concat(key);
44
+ displayValues[key] = getDisplayValues(value, path);
45
+ });
46
+ } else if ((0, _utils.isArr)(values)) {
47
+ displayValues = [];
48
+ values.map(function (value, index) {
49
+ var path = prefix ? "".concat(prefix, ".").concat(index) : "".concat(index);
50
+ displayValues[index] = getDisplayValues(value, path);
51
+ });
52
+ } else {
53
+ // 通过值的完整路径获取字段address(从form实例的indexes中),然后获取该字段的value在该字段dataSource中对应的label
54
+ var address = form.indexes[prefix];
55
+ var field = form.query(address).take();
56
+ displayValues = (0, _utils.getValueByValue)(field === null || field === void 0 ? void 0 : field.dataSource, values) || values;
57
+ }
58
+
59
+ return displayValues;
60
+ }; // 测试样例
61
+ // const example = {
62
+ // a: [
63
+ // [{ b: 'a.0.0.b', c: 'a.0.0.c' }, { d: 'a.0.1.d' }],
64
+ // { e: [{ f: { g: [{ h: 'a.1.e.0.f.g.0.h' }] } }, 'a.1.e.1'] },
65
+ // ],
66
+ // };
67
+ // console.log(getDisplayValues(example));
68
+
69
+
70
+ return getDisplayValues(values);
71
+ };
72
+
73
+ var _default = useFormDisplayValues;
74
+ exports.default = _default;
@@ -48,7 +48,8 @@ var typeMap = (_typeMap = {
48
48
  ColorRadio: 'string',
49
49
  IconPicker: 'string',
50
50
  JsonInput: 'object',
51
- TagPicker: 'array',
51
+ TagPicker: 'string',
52
+ MultipleTagPicker: 'array',
52
53
  Range: 'string',
53
54
  Search: 'array',
54
55
  ArrayCollapse: 'array',
@@ -52,6 +52,7 @@ var proFieldTypeMap = {
52
52
  IconPicker: 'icon',
53
53
  JsonInput: 'json',
54
54
  TagPicker: 'tagPicker',
55
+ MultipleTagPicker: 'multipleTagPicker',
55
56
  Range: 'range',
56
57
  Search: 'search' // Upload: 'upload',
57
58
 
@@ -5,16 +5,96 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _utils = require("../utils");
8
+ var _utils = require("@teamix/utils");
9
9
 
10
- var initializeReactions = function initializeReactions(reactions, innerReactions) {
11
- if (reactions && innerReactions.length) {
12
- return (0, _utils.mergeArrayValue)(innerReactions, reactions);
13
- } else if (innerReactions.length) {
14
- return innerReactions;
10
+ var _utils2 = require("../utils");
11
+
12
+ var _schemaNameMap = _interopRequireDefault(require("../schemaNameMap"));
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ 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; }
17
+
18
+ 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; }
19
+
20
+ 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; }
21
+
22
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
23
+
24
+ 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."); }
25
+
26
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
27
+
28
+ function _toArray(arr) { return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); }
29
+
30
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
31
+
32
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
33
+
34
+ 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."); }
35
+
36
+ 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); }
37
+
38
+ 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; }
39
+
40
+ 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; }
41
+
42
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
43
+
44
+ var mapSchemaName = function mapSchemaName(schema) {
45
+ if ((0, _utils.isPlainObj)(schema)) {
46
+ var newSchema = {};
47
+ Object.entries(schema).forEach(function (_ref) {
48
+ var _ref2 = _slicedToArray(_ref, 2),
49
+ key = _ref2[0],
50
+ value = _ref2[1];
51
+
52
+ var _key$split = key.split('.'),
53
+ _key$split2 = _toArray(_key$split),
54
+ firstKey = _key$split2[0],
55
+ otherKey = _key$split2.slice(1);
56
+
57
+ var newFirstKey = (0, _utils.getValueByValue)(_schemaNameMap.default, firstKey, {
58
+ inputKey: 'proForm',
59
+ outputKey: 'formily'
60
+ }) || firstKey;
61
+ var newKey = [newFirstKey].concat(_toConsumableArray(otherKey)).join('.');
62
+ newSchema[newKey] = value;
63
+ });
64
+ return newSchema;
15
65
  }
16
66
 
17
- return reactions;
67
+ return schema;
68
+ };
69
+
70
+ var initializeReactions = function initializeReactions(reactions, innerReactions) {
71
+ var temp = innerReactions; // 合并reactions
72
+
73
+ if (reactions) {
74
+ temp = (0, _utils2.mergeArrayValue)(innerReactions, reactions);
75
+ } // schema名称映射,由ProFormSchema映射为formilySchema
76
+
77
+
78
+ temp = temp.map(function (item) {
79
+ var _item$fulfill, _item$otherwise;
80
+
81
+ var fulfillSchema = mapSchemaName(item === null || item === void 0 ? void 0 : (_item$fulfill = item.fulfill) === null || _item$fulfill === void 0 ? void 0 : _item$fulfill.schema);
82
+ var otherwiseSchema = mapSchemaName(item === null || item === void 0 ? void 0 : (_item$otherwise = item.otherwise) === null || _item$otherwise === void 0 ? void 0 : _item$otherwise.schema);
83
+
84
+ if (fulfillSchema || otherwiseSchema) {
85
+ return _objectSpread(_objectSpread({}, item), {}, {
86
+ fulfill: _objectSpread(_objectSpread({}, item === null || item === void 0 ? void 0 : item.fulfill), {}, {
87
+ schema: fulfillSchema
88
+ }),
89
+ otherwise: _objectSpread(_objectSpread({}, item === null || item === void 0 ? void 0 : item.otherwise), {}, {
90
+ schema: otherwiseSchema
91
+ })
92
+ });
93
+ }
94
+
95
+ return item;
96
+ });
97
+ return temp;
18
98
  };
19
99
 
20
100
  var _default = initializeReactions;
@@ -16,6 +16,8 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
16
16
  // 配置请求
17
17
  var useRequest = function useRequest(requestConfig) {
18
18
  return function (field) {
19
+ var _field$form;
20
+
19
21
  var beforeRequest = requestConfig.beforeRequest,
20
22
  onSuccess = requestConfig.onSuccess;
21
23
  var beforeRequestResult = (0, _utils.isFn)(beforeRequest) ? beforeRequest(field) : {};
@@ -29,8 +31,8 @@ var useRequest = function useRequest(requestConfig) {
29
31
  } : onSuccess
30
32
  }), {
31
33
  $self: field,
32
- $form: field.form,
33
- $values: field.form.values
34
+ $form: field === null || field === void 0 ? void 0 : field.form,
35
+ $values: field === null || field === void 0 ? void 0 : (_field$form = field.form) === null || _field$form === void 0 ? void 0 : _field$form.values
34
36
  });
35
37
  };
36
38
  }; // 配置校验
@@ -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
  */