@teamix/pro 1.2.8 → 1.2.12

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 (117) hide show
  1. package/dist/pro.css +1 -1
  2. package/dist/pro.js +1787 -812
  3. package/dist/pro.min.css +1 -1
  4. package/dist/pro.min.js +1 -1
  5. package/es/actions/base.d.ts +16 -6
  6. package/es/actions/base.js +66 -12
  7. package/es/actions/confirm.d.ts +1 -1
  8. package/es/actions/danger-confirm.d.ts +1 -1
  9. package/es/actions/dialog-component.d.ts +1 -1
  10. package/es/actions/dialog-form.d.ts +1 -1
  11. package/es/actions/dialog-form.js +4 -4
  12. package/es/actions/dialog-info.d.ts +1 -1
  13. package/es/actions/dialog-table.d.ts +1 -1
  14. package/es/actions/dialog.d.ts +6 -2
  15. package/es/actions/dialog.js +19 -24
  16. package/es/actions/drawer-form.d.ts +1 -1
  17. package/es/actions/drawer-info.d.ts +1 -1
  18. package/es/actions/drawer-table.d.ts +1 -1
  19. package/es/actions/drawer.d.ts +1 -1
  20. package/es/actions/error.d.ts +1 -1
  21. package/es/actions/index.js +25 -22
  22. package/es/actions/index.scss +28 -7
  23. package/es/actions/link.d.ts +2 -2
  24. package/es/actions/link.js +2 -2
  25. package/es/actions/notice.d.ts +1 -1
  26. package/es/actions/request.d.ts +1 -1
  27. package/es/actions/request.js +2 -2
  28. package/es/card/index.d.ts +10 -1
  29. package/es/card/index.js +20 -6
  30. package/es/card/index.scss +19 -0
  31. package/es/card/tab.d.ts +6 -0
  32. package/es/card/tab.js +27 -0
  33. package/es/form/Filter/index.d.ts +2 -5
  34. package/es/form/Filter/index.js +3 -44
  35. package/es/form/Filter/index.scss +71 -0
  36. package/es/form/Filter/index2.d.ts +8 -0
  37. package/es/form/Filter/index2.js +318 -0
  38. package/es/form/ProForm/index.js +3 -23
  39. package/es/form/ProForm/index.scss +10 -19
  40. package/es/form/ProForm/useFormDisplayValues.d.ts +3 -5
  41. package/es/form/ProForm/useFormDisplayValues.js +44 -38
  42. package/es/form/SchemaForm/index.js +7 -6
  43. package/es/form/index.d.ts +2 -1
  44. package/es/form/index.js +3 -2
  45. package/es/form/typing.d.ts +3 -0
  46. package/es/index.d.ts +1 -1
  47. package/es/index.js +1 -1
  48. package/es/page-header/index.d.ts +20 -11
  49. package/es/page-header/index.js +23 -47
  50. package/es/page-header/index.scss +0 -11
  51. package/es/sidebar/components/tree/index.js +85 -18
  52. package/es/sidebar/index.js +9 -5
  53. package/es/sidebar/typing.d.ts +14 -1
  54. package/es/table/components/Filter/index.js +11 -9
  55. package/es/table/components/Filter/index.scss +7 -3
  56. package/es/table/components/Layout/index.js +10 -1
  57. package/es/table/index.js +3 -4
  58. package/es/utils/components/tags/index.d.ts +11 -0
  59. package/es/utils/components/tags/index.js +50 -0
  60. package/es/utils/components/tags/index.scss +12 -0
  61. package/lib/actions/base.d.ts +16 -6
  62. package/lib/actions/base.js +67 -12
  63. package/lib/actions/confirm.d.ts +1 -1
  64. package/lib/actions/danger-confirm.d.ts +1 -1
  65. package/lib/actions/dialog-component.d.ts +1 -1
  66. package/lib/actions/dialog-form.d.ts +1 -1
  67. package/lib/actions/dialog-form.js +3 -3
  68. package/lib/actions/dialog-info.d.ts +1 -1
  69. package/lib/actions/dialog-table.d.ts +1 -1
  70. package/lib/actions/dialog.d.ts +6 -2
  71. package/lib/actions/dialog.js +18 -23
  72. package/lib/actions/drawer-form.d.ts +1 -1
  73. package/lib/actions/drawer-info.d.ts +1 -1
  74. package/lib/actions/drawer-table.d.ts +1 -1
  75. package/lib/actions/drawer.d.ts +1 -1
  76. package/lib/actions/error.d.ts +1 -1
  77. package/lib/actions/index.js +25 -22
  78. package/lib/actions/index.scss +28 -7
  79. package/lib/actions/link.d.ts +2 -2
  80. package/lib/actions/link.js +2 -2
  81. package/lib/actions/notice.d.ts +1 -1
  82. package/lib/actions/request.d.ts +1 -1
  83. package/lib/actions/request.js +2 -2
  84. package/lib/card/index.d.ts +10 -1
  85. package/lib/card/index.js +22 -5
  86. package/lib/card/index.scss +19 -0
  87. package/lib/card/tab.d.ts +6 -0
  88. package/lib/card/tab.js +39 -0
  89. package/lib/form/Filter/index.d.ts +2 -5
  90. package/lib/form/Filter/index.js +4 -45
  91. package/lib/form/Filter/index.scss +71 -0
  92. package/lib/form/Filter/index2.d.ts +8 -0
  93. package/lib/form/Filter/index2.js +342 -0
  94. package/lib/form/ProForm/index.js +3 -23
  95. package/lib/form/ProForm/index.scss +10 -19
  96. package/lib/form/ProForm/useFormDisplayValues.d.ts +3 -5
  97. package/lib/form/ProForm/useFormDisplayValues.js +51 -44
  98. package/lib/form/SchemaForm/index.js +7 -6
  99. package/lib/form/index.d.ts +2 -1
  100. package/lib/form/index.js +5 -3
  101. package/lib/form/typing.d.ts +3 -0
  102. package/lib/index.d.ts +1 -1
  103. package/lib/index.js +1 -1
  104. package/lib/page-header/index.d.ts +20 -11
  105. package/lib/page-header/index.js +22 -45
  106. package/lib/page-header/index.scss +0 -11
  107. package/lib/sidebar/components/tree/index.js +83 -16
  108. package/lib/sidebar/index.js +9 -5
  109. package/lib/sidebar/typing.d.ts +14 -1
  110. package/lib/table/components/Filter/index.js +10 -8
  111. package/lib/table/components/Filter/index.scss +7 -3
  112. package/lib/table/components/Layout/index.js +10 -1
  113. package/lib/table/index.js +2 -3
  114. package/lib/utils/components/tags/index.d.ts +11 -0
  115. package/lib/utils/components/tags/index.js +66 -0
  116. package/lib/utils/components/tags/index.scss +12 -0
  117. package/package.json +4 -4
@@ -1,4 +1,4 @@
1
- var _excluded = ["dataSource", "className", "style", "searchOnChange", "showSearch"];
1
+ var _excluded = ["dataSource", "className", "style", "searchOnChange", "showSearch", "onSelect", "treeProps", "cardProps"];
2
2
 
3
3
  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; }
4
4
 
@@ -36,6 +36,9 @@ var ProSidebar = function ProSidebar(props) {
36
36
  _searchOnChange = props.searchOnChange,
37
37
  _props$showSearch = props.showSearch,
38
38
  showSearch = _props$showSearch === void 0 ? true : _props$showSearch,
39
+ onSelect = props.onSelect,
40
+ treeProps = props.treeProps,
41
+ cardProps = props.cardProps,
39
42
  others = _objectWithoutProperties(props, _excluded); // 搜索的关键词
40
43
 
41
44
 
@@ -49,7 +52,7 @@ var ProSidebar = function ProSidebar(props) {
49
52
  '': true
50
53
  }, className, true)),
51
54
  style: style
52
- }, /*#__PURE__*/React.createElement(ProSidebarContainer, _objectSpread({
55
+ }, /*#__PURE__*/React.createElement(ProSidebarContainer, _objectSpread(_objectSpread({
53
56
  searchOnChange: function searchOnChange(value) {
54
57
  if (showSearch) {
55
58
  _searchOnChange === null || _searchOnChange === void 0 ? void 0 : _searchOnChange(value);
@@ -57,10 +60,11 @@ var ProSidebar = function ProSidebar(props) {
57
60
  }
58
61
  },
59
62
  showSearch: showSearch
60
- }, others), /*#__PURE__*/React.createElement(ProSidebarTree, {
63
+ }, others), cardProps), /*#__PURE__*/React.createElement(ProSidebarTree, _objectSpread({
61
64
  dataSource: dataSource,
62
- searchKey: searchKey
63
- })));
65
+ searchKey: searchKey,
66
+ onSelect: onSelect
67
+ }, treeProps))));
64
68
  };
65
69
 
66
70
  export default ProSidebar;
@@ -6,7 +6,13 @@ import { ProCardProps, ProFieldProps } from '..';
6
6
  export declare type ProSidebarProps = {
7
7
  /** 数据源 */
8
8
  dataSource?: ProSidebarDataSource;
9
- } & React.HTMLAttributes<HTMLElement> & ProSidebarContainerProps;
9
+ /** 节点点击回调 */
10
+ onSelect?: TreeProps['onSelect'];
11
+ /** 树配置 */
12
+ treeProps?: TreeProps;
13
+ /** 卡片配置 */
14
+ cardProps?: ProCardProps;
15
+ } & Omit<React.HTMLAttributes<HTMLElement>, 'onSelect'> & Omit<ProSidebarContainerProps, 'onSelect'>;
10
16
  /** 数据源定义 */
11
17
  export declare type ProSidebarDataSource = ProSidebarDataSourceItem[];
12
18
  export declare type ProSidebarDataSourceItem = {
@@ -23,6 +29,11 @@ export declare type ProSidebarDataSourceItem = {
23
29
  /** 子项 */
24
30
  children?: ProSidebarDataSourceItem[];
25
31
  };
32
+ /** tag 定义 */
33
+ export declare type ProSidebarDataSourceTag = {
34
+ /** 显示值 */
35
+ value: string;
36
+ };
26
37
  /** sidebar 容器定义 */
27
38
  export declare type ProSidebarContainerProps = {
28
39
  children?: React.ReactNode;
@@ -48,4 +59,6 @@ export declare type ProSidebarTreeProps = {
48
59
  dataSource?: ProSidebarDataSource;
49
60
  /** 搜索过滤关键词 */
50
61
  searchKey?: string;
62
+ /** 节点点击回调 */
63
+ onChange?: ProSidebarProps['onChange'];
51
64
  } & TreeProps;
@@ -27,7 +27,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
27
27
  import React, { useEffect, useMemo, useState } from 'react';
28
28
  import TeamixIcon from '@teamix/icon';
29
29
  import { Button, Dropdown, Menu } from '@alicloudfe/components';
30
- import { baseClass } from '@teamix/utils';
30
+ import { baseClass, getMessage } from '@teamix/utils';
31
31
  import './index.scss';
32
32
  var CheckboxItem = Menu.CheckboxItem;
33
33
  var cls = baseClass('teamix-pro-table-toolbar-filter');
@@ -171,7 +171,7 @@ var Filter = function Filter(props) {
171
171
  btn: true
172
172
  }),
173
173
  onClick: function onClick() {
174
- var _actionRef$current2, _actionRef$current2$f, _actionRef$current$ge5, _actionRef$current3, _actionRef$current3$g, _actionRef$current3$g2, _actionRef$current4, _actionRef$current5, _actionRef$current5$s, _actionRef$current6, _actionRef$current6$r, _actionRef$current7, _actionRef$current7$r;
174
+ var _actionRef$current2, _actionRef$current2$f, _actionRef$current$ge5, _actionRef$current3, _actionRef$current3$g, _actionRef$current3$g2, _actionRef$current4, _actionRef$current5, _actionRef$current5$s, _actionRef$current6, _actionRef$current6$r, _actionRef$current7, _actionRef$current7$r, _actionRef$current8, _actionRef$current8$c;
175
175
 
176
176
  (_actionRef$current2 = actionRef.current) === null || _actionRef$current2 === void 0 ? void 0 : (_actionRef$current2$f = _actionRef$current2.filterDataSource) === null || _actionRef$current2$f === void 0 ? void 0 : _actionRef$current2$f.call(_actionRef$current2, column.dataIndex); // 先获取此列的param
177
177
 
@@ -214,27 +214,29 @@ var Filter = function Filter(props) {
214
214
  }))); // 发送请求
215
215
 
216
216
  (_actionRef$current6 = actionRef.current) === null || _actionRef$current6 === void 0 ? void 0 : (_actionRef$current6$r = _actionRef$current6.request) === null || _actionRef$current6$r === void 0 ? void 0 : _actionRef$current6$r.call(_actionRef$current6, _objectSpread(_objectSpread({}, params), {}, _defineProperty({}, targetPageKey, 1)));
217
- (_actionRef$current7 = actionRef.current) === null || _actionRef$current7 === void 0 ? void 0 : (_actionRef$current7$r = _actionRef$current7.resetPage) === null || _actionRef$current7$r === void 0 ? void 0 : _actionRef$current7$r.call(_actionRef$current7);
217
+ (_actionRef$current7 = actionRef.current) === null || _actionRef$current7 === void 0 ? void 0 : (_actionRef$current7$r = _actionRef$current7.resetPage) === null || _actionRef$current7$r === void 0 ? void 0 : _actionRef$current7$r.call(_actionRef$current7); // 清空表格选择
218
+
219
+ (_actionRef$current8 = actionRef.current) === null || _actionRef$current8 === void 0 ? void 0 : (_actionRef$current8$c = _actionRef$current8.clearRowSelection) === null || _actionRef$current8$c === void 0 ? void 0 : _actionRef$current8$c.call(_actionRef$current8);
218
220
  setVisible(false);
219
221
  }
220
- }, "\u786E\u5B9A"), /*#__PURE__*/React.createElement(Button, {
222
+ }, getMessage('ok')), /*#__PURE__*/React.createElement(Button, {
221
223
  type: "normal",
222
224
  size: "small",
223
225
  className: cls({
224
226
  btn: true
225
227
  }),
226
228
  onClick: function onClick() {
227
- var _actionRef$current$ge6, _actionRef$current8, _actionRef$current8$g, _actionRef$current8$g2, _actionRef$current9, _actionRef$current9$s, _actionRef$current10, _actionRef$current10$;
229
+ var _actionRef$current$ge6, _actionRef$current9, _actionRef$current9$g, _actionRef$current9$g2, _actionRef$current10, _actionRef$current10$, _actionRef$current11, _actionRef$current11$;
228
230
 
229
231
  setSelected([]);
230
- var rules = (_actionRef$current$ge6 = (_actionRef$current8 = actionRef.current) === null || _actionRef$current8 === void 0 ? void 0 : (_actionRef$current8$g = _actionRef$current8.getState) === null || _actionRef$current8$g === void 0 ? void 0 : (_actionRef$current8$g2 = _actionRef$current8$g.call(_actionRef$current8)) === null || _actionRef$current8$g2 === void 0 ? void 0 : _actionRef$current8$g2.filterRules) !== null && _actionRef$current$ge6 !== void 0 ? _actionRef$current$ge6 : {};
231
- (_actionRef$current9 = actionRef.current) === null || _actionRef$current9 === void 0 ? void 0 : (_actionRef$current9$s = _actionRef$current9.setFilterRules) === null || _actionRef$current9$s === void 0 ? void 0 : _actionRef$current9$s.call(_actionRef$current9, _objectSpread(_objectSpread({}, rules), {}, _defineProperty({}, column.dataIndex, {
232
+ var rules = (_actionRef$current$ge6 = (_actionRef$current9 = actionRef.current) === null || _actionRef$current9 === void 0 ? void 0 : (_actionRef$current9$g = _actionRef$current9.getState) === null || _actionRef$current9$g === void 0 ? void 0 : (_actionRef$current9$g2 = _actionRef$current9$g.call(_actionRef$current9)) === null || _actionRef$current9$g2 === void 0 ? void 0 : _actionRef$current9$g2.filterRules) !== null && _actionRef$current$ge6 !== void 0 ? _actionRef$current$ge6 : {};
233
+ (_actionRef$current10 = actionRef.current) === null || _actionRef$current10 === void 0 ? void 0 : (_actionRef$current10$ = _actionRef$current10.setFilterRules) === null || _actionRef$current10$ === void 0 ? void 0 : _actionRef$current10$.call(_actionRef$current10, _objectSpread(_objectSpread({}, rules), {}, _defineProperty({}, column.dataIndex, {
232
234
  rules: [],
233
235
  params: ''
234
236
  })));
235
- (_actionRef$current10 = actionRef.current) === null || _actionRef$current10 === void 0 ? void 0 : (_actionRef$current10$ = _actionRef$current10.filterDataSource) === null || _actionRef$current10$ === void 0 ? void 0 : _actionRef$current10$.call(_actionRef$current10, column.dataIndex); // setVisible(!visible);
237
+ (_actionRef$current11 = actionRef.current) === null || _actionRef$current11 === void 0 ? void 0 : (_actionRef$current11$ = _actionRef$current11.filterDataSource) === null || _actionRef$current11$ === void 0 ? void 0 : _actionRef$current11$.call(_actionRef$current11, column.dataIndex); // setVisible(!visible);
236
238
  }
237
- }, "\u91CD\u7F6E")))));
239
+ }, getMessage('reset'))))));
238
240
  };
239
241
 
240
242
  export default Filter;
@@ -12,12 +12,16 @@
12
12
  }
13
13
  .teamix-pro-table-toolbar-filter-btn-box {
14
14
  display: flex;
15
- justify-content: space-around;
15
+ justify-content: center;
16
16
  margin-top: 10px;
17
17
  padding-bottom: 5px;
18
+ padding-left: 4px;
19
+ padding-right: 4px;
18
20
  }
19
21
  .teamix-pro-table-toolbar-filter-btn.teamix-pro-table-toolbar-filter-btn {
20
- width: 48px !important;
21
- min-width: unset !important;
22
+ min-width: 48px !important;
23
+ &:first-child {
24
+ margin-right: 8px;
25
+ }
22
26
  }
23
27
  }
@@ -70,7 +70,16 @@ var Layout = function Layout(props) {
70
70
  var _mainAction$actions;
71
71
 
72
72
  if (_typeof(mainAction) === 'object' && (mainAction === null || mainAction === void 0 ? void 0 : (_mainAction$actions = mainAction.actions) === null || _mainAction$actions === void 0 ? void 0 : _mainAction$actions.length) > 0) {
73
- // 默认 context
73
+ // 判断 actions 是否 visible 都为 false,是的话也不渲染
74
+ var isEmptyActions = mainAction === null || mainAction === void 0 ? void 0 : mainAction.actions.every(function (action) {
75
+ return (action === null || action === void 0 ? void 0 : action.visible) === false;
76
+ });
77
+
78
+ if (isEmptyActions) {
79
+ return;
80
+ } // 默认 context
81
+
82
+
74
83
  var defaultContext = {
75
84
  action: actionRef.current,
76
85
  rowSelection: rowSelection
package/es/table/index.js CHANGED
@@ -33,7 +33,7 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
33
33
  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; }
34
34
 
35
35
  import React, { useState, useEffect, useRef, useMemo } from 'react';
36
- import { Table, Pagination, Message, Checkbox } from '@alicloudfe/components';
36
+ import { Table, Pagination, Checkbox } from '@alicloudfe/components';
37
37
  import genProColumnToColumn from './utils/genProColumnToColumn';
38
38
  import { baseClass, useRequest, request as utilResquest, getDeepValue, getMessage, pickProps } from '@teamix/utils';
39
39
  import { ProSkeletonRaw as Skeleton } from '../skeleton';
@@ -481,8 +481,7 @@ var ProTable = function ProTable(props) {
481
481
 
482
482
  if (props.onError) {
483
483
  props.onError(error);
484
- } else {
485
- Message.error(error.toString());
484
+ } else {// Message.error(error.toString());
486
485
  } // 重新计算是否需要吸底
487
486
 
488
487
 
@@ -773,7 +772,7 @@ var ProTable = function ProTable(props) {
773
772
 
774
773
  }),
775
774
  ref: tableRef
776
- }, renderTable(), footerSuctionState && footerSuction && /*#__PURE__*/React.createElement(ProPageContainer.FixedFooter, null, renderFooter()), !(footerSuctionState && footerSuction) && renderFooter()));
775
+ }, renderTable(), footerSuctionState && footerSuction && !fullscreenState && /*#__PURE__*/React.createElement(ProPageContainer.FixedFooter, null, renderFooter()), !(footerSuctionState && footerSuction) && !fullscreenState && renderFooter(), fullscreenState && renderFooter()));
777
776
  };
778
777
 
779
778
  export default ProTable;
@@ -0,0 +1,11 @@
1
+ import { TagProps, CloseableProps } from '@alicloudfe/components/types/tag';
2
+ import './index.scss';
3
+ export declare type ProTagItem = (TagProps | (CloseableProps & {
4
+ closable: true;
5
+ })) & {
6
+ /**
7
+ * @deprecated 建议使用 children 代替
8
+ */
9
+ text?: string;
10
+ };
11
+ export declare const renderTags: (tags?: ProTagItem[] | undefined, size?: "small" | "large" | "medium" | undefined) => JSX.Element | null;
@@ -0,0 +1,50 @@
1
+ var _excluded = ["text", "children", "closable"];
2
+
3
+ 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; }
4
+
5
+ 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; }
6
+
7
+ 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; }
8
+
9
+ 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; }
10
+
11
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
12
+
13
+ import React from 'react';
14
+ import { Tag } from '@alicloudfe/components';
15
+ import { baseClass } from '@teamix/utils';
16
+ import './index.scss';
17
+ var cls = baseClass('teamix-pro-tags');
18
+ export var renderTags = function renderTags(tags, size) {
19
+ if (!tags || !tags.length) {
20
+ return null;
21
+ }
22
+
23
+ return /*#__PURE__*/React.createElement(Tag.Group, {
24
+ className: cls('')
25
+ }, tags.map(function (tag, i) {
26
+ // @ts-ignore
27
+ var text = tag.text,
28
+ children = tag.children,
29
+ closable = tag.closable,
30
+ others = _objectWithoutProperties(tag, _excluded);
31
+
32
+ if (closable) {
33
+ return /*#__PURE__*/React.createElement(Tag.Closeable, _objectSpread({
34
+ key: i,
35
+ size: size,
36
+ style: {
37
+ marginBottom: 0
38
+ }
39
+ }, others), text || children);
40
+ }
41
+
42
+ return /*#__PURE__*/React.createElement(Tag, _objectSpread({
43
+ key: i,
44
+ size: size,
45
+ style: {
46
+ marginBottom: 0
47
+ }
48
+ }, others), text || children);
49
+ }));
50
+ };
@@ -0,0 +1,12 @@
1
+ .teamix-pro-tags {
2
+ display: inline-flex;
3
+ align-items: center;
4
+
5
+ & > div.next-tag {
6
+ margin-right: var(--s-2, 8px);
7
+
8
+ &:last-child {
9
+ margin-right: 0;
10
+ }
11
+ }
12
+ }
@@ -1,13 +1,23 @@
1
+ import { MaybePromise } from '@teamix/utils';
1
2
  export interface BaseAction {
3
+ /** 事件触发方式,默认是 onClick */
2
4
  trigger?: string;
3
- onTrigger?: () => void;
4
- onFinish?: (prams?: any) => any;
5
+ /** 事件发生时,是否执行 e.preventDefault() 方法 */
5
6
  preventDefault?: boolean;
7
+ /** 事件发生时,是否执行 e.stopPropagation() 方法 */
6
8
  stopPropagation?: boolean;
7
- schema?: any;
8
- component?: any;
9
+ /** 事件执行前的处理函数
10
+ * 如果返回 false 或者 Promise<false>,则停止 Action 执行。
11
+ * 如果返回 true 或者 Promise<true>,则正常执行 Action。
12
+ * 如果返回其他对象,则正常执行 Action,并把返回的对象放到接下来 Action 的上下文中。
13
+ */
14
+ beforeAction?: () => MaybePromise<any>;
15
+ /** 事件开始执行后的回调函数 */
16
+ onTrigger?: () => void;
17
+ /** 事件开始执行完毕的回调函数 */
18
+ onFinish?: (params?: any) => any;
9
19
  }
10
- export declare function eventHandler(action: BaseAction, onTrigger: () => void): {
11
- [x: string]: (e: React.MouseEvent<HTMLElement>) => void;
20
+ export declare function eventHandler(action: BaseAction, actionContext: any, onTrigger: (context: any) => void): {
21
+ [x: string]: (e: React.MouseEvent<HTMLElement>) => Promise<void>;
12
22
  };
13
23
  export default eventHandler;
@@ -6,27 +6,82 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  exports.eventHandler = eventHandler;
8
8
 
9
+ var _utils = require("@teamix/utils");
10
+
9
11
  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; }
10
12
 
11
- function eventHandler(action, onTrigger) {
13
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
14
+
15
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
16
+
17
+ function eventHandler(action, actionContext, onTrigger) {
12
18
  var _action$trigger = action.trigger,
13
19
  trigger = _action$trigger === void 0 ? 'onClick' : _action$trigger,
14
20
  preventDefault = action.preventDefault,
15
- stopPropagation = action.stopPropagation;
16
- return _defineProperty({}, "".concat(trigger), function _(e) {
17
- var _action$onTrigger;
21
+ stopPropagation = action.stopPropagation,
22
+ beforeAction = action.beforeAction;
23
+ return _defineProperty({}, "".concat(trigger), function () {
24
+ var _2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(e) {
25
+ var _action$onTrigger;
18
26
 
19
- if (preventDefault) {
20
- e.preventDefault();
21
- }
27
+ var beforeActionContext;
28
+ return regeneratorRuntime.wrap(function _callee$(_context) {
29
+ while (1) {
30
+ switch (_context.prev = _context.next) {
31
+ case 0:
32
+ if (preventDefault) {
33
+ e.preventDefault();
34
+ }
35
+
36
+ if (stopPropagation) {
37
+ e.stopPropagation();
38
+ }
39
+
40
+ if (!beforeAction) {
41
+ _context.next = 14;
42
+ break;
43
+ }
44
+
45
+ _context.prev = 3;
46
+ _context.next = 6;
47
+ return (0, _utils.resolveMaybePromiseMethod)(beforeAction, actionContext);
48
+
49
+ case 6:
50
+ beforeActionContext = _context.sent;
51
+ _context.next = 12;
52
+ break;
53
+
54
+ case 9:
55
+ _context.prev = 9;
56
+ _context.t0 = _context["catch"](3);
57
+ beforeActionContext = false;
58
+
59
+ case 12:
60
+ if (!(beforeActionContext === false)) {
61
+ _context.next = 14;
62
+ break;
63
+ }
64
+
65
+ return _context.abrupt("return");
66
+
67
+ case 14:
68
+ onTrigger(Object.assign({}, beforeActionContext, actionContext));
69
+ (_action$onTrigger = action.onTrigger) === null || _action$onTrigger === void 0 ? void 0 : _action$onTrigger.call(action);
70
+
71
+ case 16:
72
+ case "end":
73
+ return _context.stop();
74
+ }
75
+ }
76
+ }, _callee, null, [[3, 9]]);
77
+ }));
22
78
 
23
- if (stopPropagation) {
24
- e.stopPropagation();
79
+ function _(_x) {
80
+ return _2.apply(this, arguments);
25
81
  }
26
82
 
27
- onTrigger();
28
- (_action$onTrigger = action.onTrigger) === null || _action$onTrigger === void 0 ? void 0 : _action$onTrigger.call(action);
29
- });
83
+ return _;
84
+ }());
30
85
  }
31
86
 
32
87
  var _default = eventHandler;
@@ -2,6 +2,6 @@ import { DialogAction } from './dialog';
2
2
  export interface ConfirmAction extends DialogAction {
3
3
  }
4
4
  export declare function useConfirmAction(action: DialogAction, context?: any): {
5
- [x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => void;
5
+ [x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => Promise<void>;
6
6
  };
7
7
  export default useConfirmAction;
@@ -2,6 +2,6 @@ import { DialogAction } from './dialog';
2
2
  export interface DangerConfirmAction extends DialogAction {
3
3
  }
4
4
  export declare function useDangerConfirmAction(action: DialogAction, context?: any): {
5
- [x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => void;
5
+ [x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => Promise<void>;
6
6
  };
7
7
  export default useDangerConfirmAction;
@@ -5,6 +5,6 @@ export interface DialogComponentAction extends DialogAction {
5
5
  component: React.FC<any>;
6
6
  }
7
7
  export declare function useDialogComponentAction(action: DialogComponentAction, context?: any): {
8
- [x: string]: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void;
8
+ [x: string]: (e: React.MouseEvent<HTMLElement, MouseEvent>) => Promise<void>;
9
9
  };
10
10
  export default useDialogComponentAction;
@@ -17,6 +17,6 @@ export interface DialogFormAction extends DialogAction {
17
17
  schema: ProFormSchema | ProFormProps;
18
18
  }
19
19
  export declare function useDialogFormAction(action: DialogFormAction, context?: any): {
20
- [x: string]: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void;
20
+ [x: string]: (e: React.MouseEvent<HTMLElement, MouseEvent>) => Promise<void>;
21
21
  };
22
22
  export default useDialogFormAction;
@@ -159,18 +159,18 @@ function useDialogFormAction(action, context) {
159
159
  _onFinish = action.onFinish,
160
160
  others = _objectWithoutProperties(action, _excluded2);
161
161
 
162
- var formRef = (0, _react.useRef)();
162
+ var formRef = /*#__PURE__*/(0, _react.createRef)();
163
163
  return (0, _dialog.default)(Object.assign({
164
164
  size: size,
165
165
  closeable: true,
166
- content: function content() {
166
+ content: function content(contentContext) {
167
167
  var dialogFormProps = {
168
168
  initialValues: initialValues,
169
169
  initialRequest: initialRequest,
170
170
  schema: schema,
171
171
  size: size,
172
172
  formProps: formProps,
173
- context: context
173
+ context: contentContext
174
174
  };
175
175
  return /*#__PURE__*/_react.default.createElement(DialogForm, _objectSpread({
176
176
  formRef: formRef
@@ -4,6 +4,6 @@ export interface DialogInfoAction extends DialogAction {
4
4
  schema: ProInfoProps;
5
5
  }
6
6
  export declare function useDialogInfoAction(action: DialogInfoAction, context?: any): {
7
- [x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => void;
7
+ [x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => Promise<void>;
8
8
  };
9
9
  export default useDialogInfoAction;
@@ -4,6 +4,6 @@ export interface DialogTableAction extends DialogAction {
4
4
  schema: ProTableProps;
5
5
  }
6
6
  export declare function useDialogTableAction(action: DialogTableAction, context?: any): {
7
- [x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => void;
7
+ [x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => Promise<void>;
8
8
  };
9
9
  export default useDialogTableAction;
@@ -21,8 +21,12 @@ export interface DialogAction extends Omit<RequestAction, 'url'>, Omit<QuickShow
21
21
  afterContent?: React.ReactNode;
22
22
  /** 弹窗页脚描述区,位于按钮组的对面 */
23
23
  footerDescription?: React.ReactNode | ProFormSchema | ProFormSchemaItem;
24
+ /** 弹窗内容组件的 schema */
25
+ schema?: any;
26
+ /** 弹窗内容区的组件 */
27
+ component?: any;
24
28
  }
25
- export declare function useDialogAction(action: DialogAction, context?: any): {
26
- [x: string]: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void;
29
+ export declare function useDialogAction(action: DialogAction, actionContext?: any): {
30
+ [x: string]: (e: React.MouseEvent<HTMLElement, MouseEvent>) => Promise<void>;
27
31
  };
28
32
  export default useDialogAction;
@@ -29,8 +29,7 @@ var _request = require("./request");
29
29
  var _utils2 = require("./utils");
30
30
 
31
31
  var _excluded = ["url", "method", "params", "data", "extendParams", "successMsg", "errorMsg", "formatParams", "formatResult", "onSuccess", "onError"],
32
- _excluded2 = ["title", "content", "component", "schema", "onFinish", "dialogType", "dialogQuickShowType", "messageType", "beforeRequest", "onTrigger", "link", "beforeContent", "afterContent", "message", "footerDescription", "footerAlign", "overlayProps"],
33
- _excluded3 = ["className"];
32
+ _excluded2 = ["title", "content", "component", "schema", "onFinish", "dialogType", "dialogQuickShowType", "messageType", "beforeRequest", "onTrigger", "link", "beforeContent", "afterContent", "message", "footerDescription", "footerAlign", "className"];
34
33
 
35
34
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
36
35
 
@@ -38,16 +37,16 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
38
37
 
39
38
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
40
39
 
41
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
42
-
43
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
44
-
45
40
  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; }
46
41
 
47
42
  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; }
48
43
 
49
44
  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; }
50
45
 
46
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
47
+
48
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
49
+
51
50
  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; }
52
51
 
53
52
  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; }
@@ -94,7 +93,7 @@ function getFooterAlignClass(isDrawer, align) {
94
93
  } // 弹窗 -> 请求(点击确认,发送数据请求)
95
94
 
96
95
 
97
- function useDialogAction(action, context) {
96
+ function useDialogAction(action, actionContext) {
98
97
  var _useState = (0, _react.useState)(false),
99
98
  _useState2 = _slicedToArray(_useState, 2),
100
99
  loading = _useState2[0],
@@ -103,7 +102,7 @@ function useDialogAction(action, context) {
103
102
  var footerDescriptionRef = (0, _react.useRef)();
104
103
  var history = (0, _reactRouterDom.useHistory)();
105
104
 
106
- var onActionStart = function onActionStart() {
105
+ var onActionStart = function onActionStart(context) {
107
106
  var url = action.url,
108
107
  method = action.method,
109
108
  params = action.params,
@@ -135,28 +134,21 @@ function useDialogAction(action, context) {
135
134
  message = _getTargetValue.message,
136
135
  footerDescription = _getTargetValue.footerDescription,
137
136
  footerAlign = _getTargetValue.footerAlign,
138
- _getTargetValue$overl = _getTargetValue.overlayProps,
139
- overlayProps = _getTargetValue$overl === void 0 ? {} : _getTargetValue$overl,
137
+ className = _getTargetValue.className,
140
138
  containerProps = _objectWithoutProperties(_getTargetValue, _excluded2);
141
139
 
142
140
  var isDrawer = dialogType === 'drawer';
143
141
  var container = isDrawer ? _components.Drawer : _components.Dialog;
144
-
145
- var overlayClassName = overlayProps.className,
146
- overlayOtherProps = _objectWithoutProperties(overlayProps, _excluded3);
147
-
148
142
  var dialogOnlyProps = {
149
143
  type: dialogQuickShowType,
150
144
  messageProps: {
151
145
  type: messageType
152
- },
153
- overlayProps: _objectSpread({
154
- className: (0, _classnames.default)('teamix-pro-action-dialog', overlayClassName, {
155
- 'has-footer-description': !!footerDescription
156
- })
157
- }, overlayOtherProps)
146
+ }
158
147
  };
159
- var containerOtherProps = isDrawer ? {} : dialogOnlyProps;
148
+ var containerOtherProps = isDrawer ? {
149
+ okText: (0, _utils.getMessage)('ok'),
150
+ cancelText: (0, _utils.getMessage)('cancel')
151
+ } : dialogOnlyProps;
160
152
 
161
153
  var renderDialogFooterDescription = function renderDialogFooterDescription(footer) {
162
154
  if (footer instanceof Array || footer.component) {
@@ -265,14 +257,17 @@ function useDialogAction(action, context) {
265
257
  className: (0, _classnames.default)('teamix-pro-dialog-footer-description', getFooterAlignClass(isDrawer, footerAlign))
266
258
  }, renderDialogFooterDescription(footerDescription))),
267
259
  closeable: !loading,
268
- footerAlign: footerAlign
260
+ footerAlign: footerAlign,
261
+ className: (0, _classnames.default)('teamix-pro-action-dialog', {
262
+ 'has-footer-description': !!footerDescription
263
+ })
269
264
  }, containerOtherProps), containerProps);
270
265
 
271
266
  var ret = container.show(quickShowProps);
272
267
  store.hide = ret.hide;
273
268
  };
274
269
 
275
- return _objectSpread({}, (0, _base.eventHandler)(action, onActionStart));
270
+ return _objectSpread({}, (0, _base.eventHandler)(action, actionContext, onActionStart));
276
271
  }
277
272
 
278
273
  var _default = useDialogAction;
@@ -1,6 +1,6 @@
1
1
  import { DialogFormAction } from './dialog-form';
2
2
  export declare type DrawerFormAction = DialogFormAction;
3
3
  export declare function useDrawerFormAction(action: DrawerFormAction, context?: any): {
4
- [x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => void;
4
+ [x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => Promise<void>;
5
5
  };
6
6
  export default useDrawerFormAction;
@@ -1,6 +1,6 @@
1
1
  import { DialogInfoAction } from './dialog-info';
2
2
  export declare type DrawerInfoAction = DialogInfoAction;
3
3
  export declare function useDrawerInfoAction(action: DrawerInfoAction, context?: any): {
4
- [x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => void;
4
+ [x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => Promise<void>;
5
5
  };
6
6
  export default useDrawerInfoAction;
@@ -1,6 +1,6 @@
1
1
  import { DialogTableAction } from './dialog-table';
2
2
  export declare type DrawerTableAction = DialogTableAction;
3
3
  export declare function useDrawerTableAction(action: DrawerTableAction, context?: any): {
4
- [x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => void;
4
+ [x: string]: (e: import("react").MouseEvent<HTMLElement, MouseEvent>) => Promise<void>;
5
5
  };
6
6
  export default useDrawerTableAction;