@teamix/pro 1.5.0 → 1.5.1

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 (69) hide show
  1. package/dist/pro.css +1 -1
  2. package/dist/pro.js +1103 -123
  3. package/dist/pro.min.css +1 -1
  4. package/dist/pro.min.js +1 -1
  5. package/es/actions/index.d.ts +4 -0
  6. package/es/actions/index.js +34 -9
  7. package/es/actions/index.scss +5 -0
  8. package/es/card/index.scss +7 -0
  9. package/es/index.d.ts +1 -1
  10. package/es/index.js +1 -1
  11. package/es/sidebar/components/tree-node/components/IconSwitch/index.d.ts +2 -2
  12. package/es/sidebar/components/tree-node/components/IconSwitch/index.scss +1 -1
  13. package/es/sidebar/index.d.ts +2 -0
  14. package/es/sidebar/index.js +3 -1
  15. package/es/table/components/CardView/index.d.ts +5 -0
  16. package/es/table/components/CardView/index.js +446 -0
  17. package/es/table/components/CardView/index.scss +46 -0
  18. package/es/table/components/Filter/index.d.ts +1 -0
  19. package/es/table/components/Filter/index.js +21 -14
  20. package/es/table/components/Layout/index.js +4 -2
  21. package/es/table/components/LoadMore/index.d.ts +20 -0
  22. package/es/table/components/LoadMore/index.js +107 -0
  23. package/es/table/components/LoadMore/index.scss +19 -0
  24. package/es/table/components/QuickAction/index.d.ts +1 -0
  25. package/es/table/components/ToolBar/CardSwitch.d.ts +8 -0
  26. package/es/table/components/ToolBar/CardSwitch.js +63 -0
  27. package/es/table/components/ToolBar/FilterColumnIcon.js +13 -2
  28. package/es/table/components/ToolBar/Fullscreen.js +15 -2
  29. package/es/table/components/ToolBar/index.js +64 -33
  30. package/es/table/components/ToolBar/index.scss +10 -1
  31. package/es/table/index.js +132 -34
  32. package/es/table/typing.d.ts +69 -0
  33. package/es/table/utils/columnRender.d.ts +1 -1
  34. package/es/table/utils/columnRender.js +4 -2
  35. package/es/table/utils/genProColumnToColumn.d.ts +1 -1
  36. package/es/table/utils/genProColumnToColumn.js +3 -1
  37. package/lib/actions/index.d.ts +4 -0
  38. package/lib/actions/index.js +33 -9
  39. package/lib/actions/index.scss +5 -0
  40. package/lib/card/index.scss +7 -0
  41. package/lib/index.d.ts +1 -1
  42. package/lib/index.js +1 -1
  43. package/lib/sidebar/components/tree-node/components/IconSwitch/index.d.ts +2 -2
  44. package/lib/sidebar/components/tree-node/components/IconSwitch/index.scss +1 -1
  45. package/lib/sidebar/index.d.ts +2 -0
  46. package/lib/sidebar/index.js +12 -1
  47. package/lib/table/components/CardView/index.d.ts +5 -0
  48. package/lib/table/components/CardView/index.js +468 -0
  49. package/lib/table/components/CardView/index.scss +46 -0
  50. package/lib/table/components/Filter/index.d.ts +1 -0
  51. package/lib/table/components/Filter/index.js +21 -14
  52. package/lib/table/components/Layout/index.js +4 -2
  53. package/lib/table/components/LoadMore/index.d.ts +20 -0
  54. package/lib/table/components/LoadMore/index.js +128 -0
  55. package/lib/table/components/LoadMore/index.scss +19 -0
  56. package/lib/table/components/QuickAction/index.d.ts +1 -0
  57. package/lib/table/components/ToolBar/CardSwitch.d.ts +8 -0
  58. package/lib/table/components/ToolBar/CardSwitch.js +82 -0
  59. package/lib/table/components/ToolBar/FilterColumnIcon.js +13 -2
  60. package/lib/table/components/ToolBar/Fullscreen.js +15 -2
  61. package/lib/table/components/ToolBar/index.js +65 -32
  62. package/lib/table/components/ToolBar/index.scss +10 -1
  63. package/lib/table/index.js +134 -34
  64. package/lib/table/typing.d.ts +69 -0
  65. package/lib/table/utils/columnRender.d.ts +1 -1
  66. package/lib/table/utils/columnRender.js +4 -2
  67. package/lib/table/utils/genProColumnToColumn.d.ts +1 -1
  68. package/lib/table/utils/genProColumnToColumn.js +3 -1
  69. package/package.json +1 -1
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _react = _interopRequireWildcard(require("react"));
11
+
12
+ var _utils = require("@teamix/utils");
13
+
14
+ require("./index.scss");
15
+
16
+ var _icon = _interopRequireDefault(require("@teamix/icon"));
17
+
18
+ var _lodash = _interopRequireDefault(require("lodash.debounce"));
19
+
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
+
22
+ 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); }
23
+
24
+ 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; }
25
+
26
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
27
+
28
+ 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."); }
29
+
30
+ 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); }
31
+
32
+ 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; }
33
+
34
+ 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; }
35
+
36
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
37
+
38
+ var cls = (0, _utils.usePrefixCls)('teamix-pro-load-more');
39
+
40
+ var LoadMore = function LoadMore(props) {
41
+ var children = props.children,
42
+ onChangeLoadState = props.onChangeLoadState,
43
+ onLoadMore = props.onLoadMore,
44
+ scrollHeight = props.scrollHeight,
45
+ onScrollBottom = props.onScrollBottom,
46
+ loadStateProp = props.loadState,
47
+ scrollPositionProp = props.scrollPosition;
48
+ var scrollDom = (0, _react.useRef)(null); // 加载状态
49
+
50
+ var _useState = (0, _react.useState)('loadMore'),
51
+ _useState2 = _slicedToArray(_useState, 2),
52
+ loadState = _useState2[0],
53
+ setLoadState = _useState2[1];
54
+
55
+ (0, _react.useEffect)(function () {
56
+ var _scrollDom$current;
57
+
58
+ scrollDom === null || scrollDom === void 0 ? void 0 : (_scrollDom$current = scrollDom.current) === null || _scrollDom$current === void 0 ? void 0 : _scrollDom$current.addEventListener('scroll', (0, _lodash.default)(function (e) {
59
+ var _e$target, _e$target2, _e$target3;
60
+
61
+ var scrollTop = e === null || e === void 0 ? void 0 : (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.scrollTop;
62
+ var clientHeight = e === null || e === void 0 ? void 0 : (_e$target2 = e.target) === null || _e$target2 === void 0 ? void 0 : _e$target2.clientHeight;
63
+ var scrollHeight = e === null || e === void 0 ? void 0 : (_e$target3 = e.target) === null || _e$target3 === void 0 ? void 0 : _e$target3.scrollHeight;
64
+
65
+ if (scrollTop + clientHeight + 5 >= scrollHeight) {
66
+ onScrollBottom === null || onScrollBottom === void 0 ? void 0 : onScrollBottom();
67
+ }
68
+ }, 100));
69
+ }, []);
70
+ (0, _react.useEffect)(function () {
71
+ setLoadState(loadStateProp);
72
+ }, [loadStateProp]); // 更改加载状态
73
+
74
+ var onLoadState = function onLoadState(state) {
75
+ setLoadState(state);
76
+
77
+ if (state === 'loading') {
78
+ onLoadMore === null || onLoadMore === void 0 ? void 0 : onLoadMore();
79
+ }
80
+
81
+ onChangeLoadState === null || onChangeLoadState === void 0 ? void 0 : onChangeLoadState(state);
82
+ }; // 渲染加载更多和正在加载区域
83
+
84
+
85
+ var renderLoadMore = function renderLoadMore() {
86
+ if (loadState === 'loadMore') {
87
+ return /*#__PURE__*/_react.default.createElement("div", {
88
+ className: cls('bottom-text'),
89
+ onClick: function onClick() {
90
+ return onLoadState('loading');
91
+ }
92
+ }, /*#__PURE__*/_react.default.createElement(_icon.default, {
93
+ type: "down-line",
94
+ size: "small",
95
+ className: cls('bottom-text-icon')
96
+ }), "\u52A0\u8F7D\u66F4\u591A");
97
+ }
98
+
99
+ if (loadState === 'loading') {
100
+ return /*#__PURE__*/_react.default.createElement("div", {
101
+ className: cls('bottom-text')
102
+ }, /*#__PURE__*/_react.default.createElement(_icon.default, {
103
+ type: "loading-line",
104
+ size: "small",
105
+ className: cls('bottom-text-icon')
106
+ }), "\u52A0\u8F7D\u4E2D");
107
+ }
108
+
109
+ if (loadState === 'noMore') {
110
+ return /*#__PURE__*/_react.default.createElement("div", {
111
+ className: cls('bottom-text')
112
+ }, "\u6CA1\u6709\u66F4\u591A\u4E86");
113
+ }
114
+
115
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
116
+ };
117
+
118
+ return /*#__PURE__*/_react.default.createElement("div", {
119
+ className: cls(),
120
+ style: {
121
+ height: scrollHeight !== null && scrollHeight !== void 0 ? scrollHeight : 'auto'
122
+ },
123
+ ref: scrollDom
124
+ }, children, renderLoadMore());
125
+ };
126
+
127
+ var _default = LoadMore;
128
+ exports.default = _default;
@@ -0,0 +1,19 @@
1
+ .teamix-pro-load-more {
2
+ overflow-y: auto;
3
+ overflow-x: hidden;
4
+
5
+ &-bottom-text {
6
+ text-align: center;
7
+ margin-top: 16px;
8
+ margin-bottom: 16px;
9
+ cursor: pointer;
10
+ color: var(--color-brand1-5);
11
+ display: flex;
12
+ align-items: center;
13
+ justify-content: center;
14
+ }
15
+
16
+ &-bottom-text-icon {
17
+ margin-right: 4px;
18
+ }
19
+ }
@@ -5,6 +5,7 @@ interface QuickActionProps {
5
5
  quickAction?: ProActionButtonProps | React.ReactNode | React.ReactNode[];
6
6
  actionRef: React.MutableRefObject<ProTableActionType | undefined>;
7
7
  rowSelection?: innerRowSelectionType | rowSelectionType;
8
+ dataTeamixSpm?: string;
8
9
  }
9
10
  declare const QuickAction: React.FC<QuickActionProps>;
10
11
  export default QuickAction;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 切换 table card 视角
3
+ */
4
+ import React from 'react';
5
+ import { ProTableLayoutProps } from '../../typing';
6
+ import './index.scss';
7
+ declare const CardSwitch: React.FC<ProTableLayoutProps>;
8
+ export default CardSwitch;
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _react = _interopRequireWildcard(require("react"));
11
+
12
+ var _components = require("@alicloudfe/components");
13
+
14
+ var _icon = _interopRequireDefault(require("@teamix/icon"));
15
+
16
+ var _utils = require("@teamix/utils");
17
+
18
+ require("./index.scss");
19
+
20
+ var _utils2 = require("../../utils");
21
+
22
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
+
24
+ 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); }
25
+
26
+ 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; }
27
+
28
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
29
+
30
+ 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."); }
31
+
32
+ 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); }
33
+
34
+ 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; }
35
+
36
+ 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; }
37
+
38
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
39
+
40
+ var RadioGroup = _components.Radio.Group;
41
+ var cls = (0, _utils.usePrefixCls)('teamix-pro-table-toolbar-switch-card');
42
+
43
+ var CardSwitch = function CardSwitch(props) {
44
+ var actionRef = props.actionRef,
45
+ defaultView = props.defaultView; // 选择视角
46
+
47
+ var _useState = (0, _react.useState)(defaultView !== null && defaultView !== void 0 ? defaultView : 'table'),
48
+ _useState2 = _slicedToArray(_useState, 2),
49
+ radioView = _useState2[0],
50
+ setRadioView = _useState2[1]; // 选择视角回调
51
+
52
+
53
+ var onRadioViewChange = function onRadioViewChange(value) {
54
+ var _actionRef$current, _actionRef$current$sw;
55
+
56
+ setRadioView(value);
57
+ (_actionRef$current = actionRef.current) === null || _actionRef$current === void 0 ? void 0 : (_actionRef$current$sw = _actionRef$current.switchView) === null || _actionRef$current$sw === void 0 ? void 0 : _actionRef$current$sw.call(_actionRef$current, value);
58
+ (0, _utils2.emit)('cardSwitchChange', value);
59
+ };
60
+
61
+ return /*#__PURE__*/_react.default.createElement(RadioGroup, {
62
+ shape: "button",
63
+ value: radioView,
64
+ onChange: onRadioViewChange,
65
+ className: cls()
66
+ }, /*#__PURE__*/_react.default.createElement(_components.Radio, {
67
+ id: "banana",
68
+ value: "table"
69
+ }, /*#__PURE__*/_react.default.createElement(_icon.default, {
70
+ type: "menu-line",
71
+ size: "small"
72
+ })), /*#__PURE__*/_react.default.createElement(_components.Radio, {
73
+ id: "watermelon",
74
+ value: "card"
75
+ }, /*#__PURE__*/_react.default.createElement(_icon.default, {
76
+ type: "all-line",
77
+ size: "small"
78
+ })));
79
+ };
80
+
81
+ var _default = CardSwitch;
82
+ exports.default = _default;
@@ -109,7 +109,13 @@ var FilterColumnIcon = function FilterColumnIcon(props) {
109
109
  var _useState9 = (0, _react.useState)(false),
110
110
  _useState10 = _slicedToArray(_useState9, 2),
111
111
  dropdownVisible = _useState10[0],
112
- setDropdownVisible = _useState10[1];
112
+ setDropdownVisible = _useState10[1]; // 视角
113
+
114
+
115
+ var _useState11 = (0, _react.useState)('table'),
116
+ _useState12 = _slicedToArray(_useState11, 2),
117
+ cardView = _useState12[0],
118
+ setCardView = _useState12[1];
113
119
 
114
120
  (0, _react.useEffect)(function () {
115
121
  _utils2.on === null || _utils2.on === void 0 ? void 0 : (0, _utils2.on)(function (stateFilterColumns) {
@@ -127,8 +133,12 @@ var FilterColumnIcon = function FilterColumnIcon(props) {
127
133
  setNewColumns(stateColumns);
128
134
  }
129
135
  }, 'refreshFilterState');
136
+ _utils2.on === null || _utils2.on === void 0 ? void 0 : (0, _utils2.on)(function (view) {
137
+ setCardView(view);
138
+ }, 'cardSwitchChange');
130
139
  return function () {
131
140
  (0, _utils2.off)('refreshFilterState');
141
+ (0, _utils2.off)('cardSwitchChange');
132
142
  };
133
143
  });
134
144
  (0, _react.useEffect)(function () {
@@ -295,7 +305,8 @@ var FilterColumnIcon = function FilterColumnIcon(props) {
295
305
  }, /*#__PURE__*/_react.default.createElement(CheckboxItem, {
296
306
  indeterminate: indeterminate,
297
307
  checked: allVisible,
298
- onChange: onChangeAllColumns
308
+ onChange: onChangeAllColumns,
309
+ disabled: cardView === 'card'
299
310
  }, (0, _utils.getMessage)('selectAll'), /*#__PURE__*/_react.default.createElement(_components.Button, {
300
311
  onClick: restColumns,
301
312
  className: cls({
@@ -45,6 +45,8 @@ var FullScreen = function FullScreen(props) {
45
45
  }, [visible, actionRef]);
46
46
 
47
47
  var afterClose = function afterClose() {
48
+ var _document;
49
+
48
50
  // 判断全屏前后筛选表单值是否有改变
49
51
  var n = JSON.stringify((0, _utils.getValidValues)(normalDataFilterForm === null || normalDataFilterForm === void 0 ? void 0 : normalDataFilterForm.values));
50
52
  var f = JSON.stringify((0, _utils.getValidValues)(fullscreenDataFilterForm === null || fullscreenDataFilterForm === void 0 ? void 0 : fullscreenDataFilterForm.values));
@@ -58,11 +60,17 @@ var FullScreen = function FullScreen(props) {
58
60
  } // 关闭全屏后,关闭全屏表单onFilter
59
61
 
60
62
 
61
- filterEnableRef.current.fullscreen = false;
63
+ filterEnableRef.current.fullscreen = false; // 移除类名
64
+
65
+ if (document && ((_document = document) === null || _document === void 0 ? void 0 : _document.body)) {
66
+ document.body.classList.remove('teamix-pro-table-fullscreen');
67
+ }
62
68
  }; // 全屏开启之后
63
69
 
64
70
 
65
71
  var afterOpen = function afterOpen() {
72
+ var _document2;
73
+
66
74
  // 判断全屏前后筛选表单值是否有改变
67
75
  var n = JSON.stringify((0, _utils.getValidValues)(normalDataFilterForm === null || normalDataFilterForm === void 0 ? void 0 : normalDataFilterForm.values));
68
76
  var f = JSON.stringify((0, _utils.getValidValues)(fullscreenDataFilterForm === null || fullscreenDataFilterForm === void 0 ? void 0 : fullscreenDataFilterForm.values));
@@ -76,7 +84,12 @@ var FullScreen = function FullScreen(props) {
76
84
  } // 全屏后,关闭普通表单onFilter
77
85
 
78
86
 
79
- filterEnableRef.current.normal = false; // 消息提示
87
+ filterEnableRef.current.normal = false; // 为 body 添加类名,用于判断是否全屏
88
+
89
+ if (document && ((_document2 = document) === null || _document2 === void 0 ? void 0 : _document2.body)) {
90
+ document.body.classList.add('teamix-pro-table-fullscreen');
91
+ } // 消息提示
92
+
80
93
 
81
94
  _components.Message.show({
82
95
  type: 'notice',
@@ -29,6 +29,10 @@ var _lodash = _interopRequireDefault(require("lodash.debounce"));
29
29
 
30
30
  require("./index.scss");
31
31
 
32
+ var _CardSwitch = _interopRequireDefault(require("./CardSwitch"));
33
+
34
+ var _lodash2 = _interopRequireDefault(require("lodash.clonedeep"));
35
+
32
36
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
33
37
 
34
38
  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); }
@@ -58,7 +62,8 @@ var presetToolBarMap = {
58
62
  refresh: _RefreshIcon.default,
59
63
  density: _DensityIcon.default,
60
64
  filtercolumn: _FilterColumnIcon.default,
61
- fullscreen: _FullScreenIcon.default
65
+ fullscreen: _FullScreenIcon.default,
66
+ switchcard: _CardSwitch.default
62
67
  };
63
68
  var presetToolBarName = ['refresh', 'density', 'filtercolumn', 'fullscreen'];
64
69
  var presetToolBar = [{
@@ -83,7 +88,10 @@ var ToolBar = function ToolBar(props) {
83
88
  var _toolBarRef$current, _toolBarRef$current$p, _toolBarRef$current$p2;
84
89
 
85
90
  var toolBar = props.toolBar,
86
- fullScreenState = props.fullScreenState;
91
+ fullScreenState = props.fullScreenState,
92
+ switchCardView = props.switchCardView,
93
+ _props$toolBarAutoWid = props.toolBarAutoWidth,
94
+ toolBarAutoWidth = _props$toolBarAutoWid === void 0 ? true : _props$toolBarAutoWid;
87
95
  var toolBarRef = (0, _react.useRef)(null); // const toolBarSize = useSize(toolBarRef);
88
96
  // 用于获取内容宽度
89
97
 
@@ -103,44 +111,69 @@ var ToolBar = function ToolBar(props) {
103
111
 
104
112
 
105
113
  (0, _react.useEffect)((0, _lodash.default)(function () {
106
- // console.log(
107
- // layoutInlineSize?.width,
108
- // leftWidth,
109
- // toolBarContentRef.current?.clientWidth,
110
- // );
111
- if ((layoutInlineSize === null || layoutInlineSize === void 0 ? void 0 : layoutInlineSize.width) && leftWidth && toolBarContentRef.current) {
114
+ if ((layoutInlineSize === null || layoutInlineSize === void 0 ? void 0 : layoutInlineSize.width) && leftWidth && toolBarContentRef.current && toolBarAutoWidth) {
112
115
  var _toolBarContentRef$cu;
113
116
 
114
- var width = layoutInlineSize.width; // console.log('layoutInlineSize-width', width);
117
+ var width = layoutInlineSize.width,
118
+ height = layoutInlineSize.height;
115
119
 
116
- if (width - leftWidth <= ((_toolBarContentRef$cu = toolBarContentRef.current) === null || _toolBarContentRef$cu === void 0 ? void 0 : _toolBarContentRef$cu.clientWidth) + 8) {
120
+ if (width - leftWidth <= ((_toolBarContentRef$cu = toolBarContentRef.current) === null || _toolBarContentRef$cu === void 0 ? void 0 : _toolBarContentRef$cu.clientWidth) + 8 || height > 40) {
117
121
  setFlat(false);
118
- } else {
122
+ } else if (height === 40) {
119
123
  setFlat(true);
120
124
  }
121
125
  }
122
- }, 300));
123
- var toolBarList = toolBar !== false ? presetToolBar : [];
126
+ }, 300)); // 初始态
127
+
128
+ (0, _react.useEffect)(function () {
129
+ if (!((layoutInlineSize === null || layoutInlineSize === void 0 ? void 0 : layoutInlineSize.width) && leftWidth)) {
130
+ setFlat(true);
131
+ }
132
+ }, []);
133
+ var toolBarList = (0, _react.useMemo)(function () {
134
+ var result = toolBar !== false ? (0, _lodash2.default)(presetToolBar) : [];
135
+
136
+ if (switchCardView && !result.find(function (item) {
137
+ return item.name === 'switchCard';
138
+ })) {
139
+ result.push({
140
+ type: 'preset',
141
+ name: 'switchCard',
142
+ component: presetToolBarMap['switchcard']
143
+ });
144
+ }
145
+
146
+ if (Array.isArray(toolBar)) {
147
+ result = toolBar.map(function (item, index) {
148
+ if (typeof item === 'string' && presetToolBarName.includes(item.toLowerCase())) {
149
+ return {
150
+ type: 'preset',
151
+ name: item,
152
+ component: presetToolBarMap[item.toLowerCase()]
153
+ };
154
+ }
124
155
 
125
- if (Array.isArray(toolBar)) {
126
- toolBarList = toolBar.map(function (item, index) {
127
- if (typeof item === 'string' && presetToolBarName.includes(item.toLowerCase())) {
128
156
  return {
129
- type: 'preset',
130
- name: item,
131
- component: presetToolBarMap[item.toLowerCase()]
157
+ type: 'custom',
158
+ name: "custom".concat(index),
159
+ component: item
132
160
  };
133
- }
161
+ });
134
162
 
135
- return {
136
- type: 'custom',
137
- name: "custom".concat(index),
138
- component: item
139
- };
140
- });
141
- }
163
+ if (!toolBar.includes('switchCard') && switchCardView && !result.find(function (item) {
164
+ return item.name === 'switchCard';
165
+ })) {
166
+ result.push({
167
+ type: 'preset',
168
+ name: 'switchCard',
169
+ component: presetToolBarMap['switchcard']
170
+ });
171
+ }
172
+ }
142
173
 
143
- var renderFlatShape = function renderFlatShape() {
174
+ return result;
175
+ }, [toolBar]);
176
+ var renderFlatShape = (0, _react.useMemo)(function () {
144
177
  return /*#__PURE__*/_react.default.createElement("div", {
145
178
  className: cls('content')
146
179
  }, toolBarList.map(function (_ref) {
@@ -156,7 +189,7 @@ var ToolBar = function ToolBar(props) {
156
189
  })
157
190
  }, Component));
158
191
  }));
159
- };
192
+ }, [toolBarList]);
160
193
 
161
194
  var renderUnFlatShape = function renderUnFlatShape() {
162
195
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_components.Balloon.Tooltip, {
@@ -171,7 +204,7 @@ var ToolBar = function ToolBar(props) {
171
204
  type: "more-line"
172
205
  })),
173
206
  align: "tr"
174
- }, renderFlatShape()));
207
+ }, renderFlatShape));
175
208
  };
176
209
 
177
210
  return /*#__PURE__*/_react.default.createElement("div", {
@@ -179,10 +212,10 @@ var ToolBar = function ToolBar(props) {
179
212
  flat: flat
180
213
  }),
181
214
  ref: toolBarRef
182
- }, !flat && !fullScreenState ? renderUnFlatShape() : renderFlatShape(), /*#__PURE__*/_react.default.createElement("div", {
215
+ }, !flat && !fullScreenState ? renderUnFlatShape() : renderFlatShape, /*#__PURE__*/_react.default.createElement("div", {
183
216
  className: cls('shadow'),
184
217
  ref: toolBarContentRef
185
- }, renderFlatShape()));
218
+ }, renderFlatShape));
186
219
  };
187
220
 
188
221
  var _default = ToolBar;
@@ -1,7 +1,7 @@
1
1
  .teamix-pro-table-toolbar {
2
2
  width: 100%;
3
3
  text-align: right;
4
- margin-bottom: 8px;
4
+ // margin-bottom: 8px;
5
5
  &-flat {
6
6
  margin-left: 8px;
7
7
  }
@@ -149,3 +149,12 @@
149
149
  }
150
150
  }
151
151
  }
152
+
153
+ // switch card
154
+ .teamix-pro-table-toolbar-switch-card {
155
+ margin-left: 8px;
156
+ label {
157
+ padding-left: 8px;
158
+ padding-right: 8px;
159
+ }
160
+ }