@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.
- package/dist/pro.css +1 -1
- package/dist/pro.js +1103 -123
- package/dist/pro.min.css +1 -1
- package/dist/pro.min.js +1 -1
- package/es/actions/index.d.ts +4 -0
- package/es/actions/index.js +34 -9
- package/es/actions/index.scss +5 -0
- package/es/card/index.scss +7 -0
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/sidebar/components/tree-node/components/IconSwitch/index.d.ts +2 -2
- package/es/sidebar/components/tree-node/components/IconSwitch/index.scss +1 -1
- package/es/sidebar/index.d.ts +2 -0
- package/es/sidebar/index.js +3 -1
- package/es/table/components/CardView/index.d.ts +5 -0
- package/es/table/components/CardView/index.js +446 -0
- package/es/table/components/CardView/index.scss +46 -0
- package/es/table/components/Filter/index.d.ts +1 -0
- package/es/table/components/Filter/index.js +21 -14
- package/es/table/components/Layout/index.js +4 -2
- package/es/table/components/LoadMore/index.d.ts +20 -0
- package/es/table/components/LoadMore/index.js +107 -0
- package/es/table/components/LoadMore/index.scss +19 -0
- package/es/table/components/QuickAction/index.d.ts +1 -0
- package/es/table/components/ToolBar/CardSwitch.d.ts +8 -0
- package/es/table/components/ToolBar/CardSwitch.js +63 -0
- package/es/table/components/ToolBar/FilterColumnIcon.js +13 -2
- package/es/table/components/ToolBar/Fullscreen.js +15 -2
- package/es/table/components/ToolBar/index.js +64 -33
- package/es/table/components/ToolBar/index.scss +10 -1
- package/es/table/index.js +132 -34
- package/es/table/typing.d.ts +69 -0
- package/es/table/utils/columnRender.d.ts +1 -1
- package/es/table/utils/columnRender.js +4 -2
- package/es/table/utils/genProColumnToColumn.d.ts +1 -1
- package/es/table/utils/genProColumnToColumn.js +3 -1
- package/lib/actions/index.d.ts +4 -0
- package/lib/actions/index.js +33 -9
- package/lib/actions/index.scss +5 -0
- package/lib/card/index.scss +7 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/sidebar/components/tree-node/components/IconSwitch/index.d.ts +2 -2
- package/lib/sidebar/components/tree-node/components/IconSwitch/index.scss +1 -1
- package/lib/sidebar/index.d.ts +2 -0
- package/lib/sidebar/index.js +12 -1
- package/lib/table/components/CardView/index.d.ts +5 -0
- package/lib/table/components/CardView/index.js +468 -0
- package/lib/table/components/CardView/index.scss +46 -0
- package/lib/table/components/Filter/index.d.ts +1 -0
- package/lib/table/components/Filter/index.js +21 -14
- package/lib/table/components/Layout/index.js +4 -2
- package/lib/table/components/LoadMore/index.d.ts +20 -0
- package/lib/table/components/LoadMore/index.js +128 -0
- package/lib/table/components/LoadMore/index.scss +19 -0
- package/lib/table/components/QuickAction/index.d.ts +1 -0
- package/lib/table/components/ToolBar/CardSwitch.d.ts +8 -0
- package/lib/table/components/ToolBar/CardSwitch.js +82 -0
- package/lib/table/components/ToolBar/FilterColumnIcon.js +13 -2
- package/lib/table/components/ToolBar/Fullscreen.js +15 -2
- package/lib/table/components/ToolBar/index.js +65 -32
- package/lib/table/components/ToolBar/index.scss +10 -1
- package/lib/table/index.js +134 -34
- package/lib/table/typing.d.ts +69 -0
- package/lib/table/utils/columnRender.d.ts +1 -1
- package/lib/table/utils/columnRender.js +4 -2
- package/lib/table/utils/genProColumnToColumn.d.ts +1 -1
- package/lib/table/utils/genProColumnToColumn.js +3 -1
- package/package.json +1 -1
@@ -0,0 +1,107 @@
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
2
|
+
|
3
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
4
|
+
|
5
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
6
|
+
|
7
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
8
|
+
|
9
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
10
|
+
|
11
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
12
|
+
|
13
|
+
import React, { useEffect, useRef, useState } from 'react';
|
14
|
+
import { usePrefixCls } from '@teamix/utils';
|
15
|
+
import './index.scss';
|
16
|
+
import TeamixIcon from '@teamix/icon';
|
17
|
+
import debounce from 'lodash.debounce';
|
18
|
+
var cls = usePrefixCls('teamix-pro-load-more');
|
19
|
+
|
20
|
+
var LoadMore = function LoadMore(props) {
|
21
|
+
var children = props.children,
|
22
|
+
onChangeLoadState = props.onChangeLoadState,
|
23
|
+
onLoadMore = props.onLoadMore,
|
24
|
+
scrollHeight = props.scrollHeight,
|
25
|
+
onScrollBottom = props.onScrollBottom,
|
26
|
+
loadStateProp = props.loadState,
|
27
|
+
scrollPositionProp = props.scrollPosition;
|
28
|
+
var scrollDom = useRef(null); // 加载状态
|
29
|
+
|
30
|
+
var _useState = useState('loadMore'),
|
31
|
+
_useState2 = _slicedToArray(_useState, 2),
|
32
|
+
loadState = _useState2[0],
|
33
|
+
setLoadState = _useState2[1];
|
34
|
+
|
35
|
+
useEffect(function () {
|
36
|
+
var _scrollDom$current;
|
37
|
+
|
38
|
+
scrollDom === null || scrollDom === void 0 ? void 0 : (_scrollDom$current = scrollDom.current) === null || _scrollDom$current === void 0 ? void 0 : _scrollDom$current.addEventListener('scroll', debounce(function (e) {
|
39
|
+
var _e$target, _e$target2, _e$target3;
|
40
|
+
|
41
|
+
var scrollTop = e === null || e === void 0 ? void 0 : (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.scrollTop;
|
42
|
+
var clientHeight = e === null || e === void 0 ? void 0 : (_e$target2 = e.target) === null || _e$target2 === void 0 ? void 0 : _e$target2.clientHeight;
|
43
|
+
var scrollHeight = e === null || e === void 0 ? void 0 : (_e$target3 = e.target) === null || _e$target3 === void 0 ? void 0 : _e$target3.scrollHeight;
|
44
|
+
|
45
|
+
if (scrollTop + clientHeight + 5 >= scrollHeight) {
|
46
|
+
onScrollBottom === null || onScrollBottom === void 0 ? void 0 : onScrollBottom();
|
47
|
+
}
|
48
|
+
}, 100));
|
49
|
+
}, []);
|
50
|
+
useEffect(function () {
|
51
|
+
setLoadState(loadStateProp);
|
52
|
+
}, [loadStateProp]); // 更改加载状态
|
53
|
+
|
54
|
+
var onLoadState = function onLoadState(state) {
|
55
|
+
setLoadState(state);
|
56
|
+
|
57
|
+
if (state === 'loading') {
|
58
|
+
onLoadMore === null || onLoadMore === void 0 ? void 0 : onLoadMore();
|
59
|
+
}
|
60
|
+
|
61
|
+
onChangeLoadState === null || onChangeLoadState === void 0 ? void 0 : onChangeLoadState(state);
|
62
|
+
}; // 渲染加载更多和正在加载区域
|
63
|
+
|
64
|
+
|
65
|
+
var renderLoadMore = function renderLoadMore() {
|
66
|
+
if (loadState === 'loadMore') {
|
67
|
+
return /*#__PURE__*/React.createElement("div", {
|
68
|
+
className: cls('bottom-text'),
|
69
|
+
onClick: function onClick() {
|
70
|
+
return onLoadState('loading');
|
71
|
+
}
|
72
|
+
}, /*#__PURE__*/React.createElement(TeamixIcon, {
|
73
|
+
type: "down-line",
|
74
|
+
size: "small",
|
75
|
+
className: cls('bottom-text-icon')
|
76
|
+
}), "\u52A0\u8F7D\u66F4\u591A");
|
77
|
+
}
|
78
|
+
|
79
|
+
if (loadState === 'loading') {
|
80
|
+
return /*#__PURE__*/React.createElement("div", {
|
81
|
+
className: cls('bottom-text')
|
82
|
+
}, /*#__PURE__*/React.createElement(TeamixIcon, {
|
83
|
+
type: "loading-line",
|
84
|
+
size: "small",
|
85
|
+
className: cls('bottom-text-icon')
|
86
|
+
}), "\u52A0\u8F7D\u4E2D");
|
87
|
+
}
|
88
|
+
|
89
|
+
if (loadState === 'noMore') {
|
90
|
+
return /*#__PURE__*/React.createElement("div", {
|
91
|
+
className: cls('bottom-text')
|
92
|
+
}, "\u6CA1\u6709\u66F4\u591A\u4E86");
|
93
|
+
}
|
94
|
+
|
95
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
96
|
+
};
|
97
|
+
|
98
|
+
return /*#__PURE__*/React.createElement("div", {
|
99
|
+
className: cls(),
|
100
|
+
style: {
|
101
|
+
height: scrollHeight !== null && scrollHeight !== void 0 ? scrollHeight : 'auto'
|
102
|
+
},
|
103
|
+
ref: scrollDom
|
104
|
+
}, children, renderLoadMore());
|
105
|
+
};
|
106
|
+
|
107
|
+
export default LoadMore;
|
@@ -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,63 @@
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
2
|
+
|
3
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
4
|
+
|
5
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
6
|
+
|
7
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
8
|
+
|
9
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
10
|
+
|
11
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
12
|
+
|
13
|
+
/**
|
14
|
+
* 切换 table card 视角
|
15
|
+
*/
|
16
|
+
import React, { useState } from 'react';
|
17
|
+
import { Radio } from '@alicloudfe/components';
|
18
|
+
import TeamixIcon from '@teamix/icon';
|
19
|
+
import { usePrefixCls } from '@teamix/utils';
|
20
|
+
import './index.scss';
|
21
|
+
import { emit } from '../../utils';
|
22
|
+
var RadioGroup = Radio.Group;
|
23
|
+
var cls = usePrefixCls('teamix-pro-table-toolbar-switch-card');
|
24
|
+
|
25
|
+
var CardSwitch = function CardSwitch(props) {
|
26
|
+
var actionRef = props.actionRef,
|
27
|
+
defaultView = props.defaultView; // 选择视角
|
28
|
+
|
29
|
+
var _useState = useState(defaultView !== null && defaultView !== void 0 ? defaultView : 'table'),
|
30
|
+
_useState2 = _slicedToArray(_useState, 2),
|
31
|
+
radioView = _useState2[0],
|
32
|
+
setRadioView = _useState2[1]; // 选择视角回调
|
33
|
+
|
34
|
+
|
35
|
+
var onRadioViewChange = function onRadioViewChange(value) {
|
36
|
+
var _actionRef$current, _actionRef$current$sw;
|
37
|
+
|
38
|
+
setRadioView(value);
|
39
|
+
(_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);
|
40
|
+
emit('cardSwitchChange', value);
|
41
|
+
};
|
42
|
+
|
43
|
+
return /*#__PURE__*/React.createElement(RadioGroup, {
|
44
|
+
shape: "button",
|
45
|
+
value: radioView,
|
46
|
+
onChange: onRadioViewChange,
|
47
|
+
className: cls()
|
48
|
+
}, /*#__PURE__*/React.createElement(Radio, {
|
49
|
+
id: "banana",
|
50
|
+
value: "table"
|
51
|
+
}, /*#__PURE__*/React.createElement(TeamixIcon, {
|
52
|
+
type: "menu-line",
|
53
|
+
size: "small"
|
54
|
+
})), /*#__PURE__*/React.createElement(Radio, {
|
55
|
+
id: "watermelon",
|
56
|
+
value: "card"
|
57
|
+
}, /*#__PURE__*/React.createElement(TeamixIcon, {
|
58
|
+
type: "all-line",
|
59
|
+
size: "small"
|
60
|
+
})));
|
61
|
+
};
|
62
|
+
|
63
|
+
export default CardSwitch;
|
@@ -90,7 +90,13 @@ var FilterColumnIcon = function FilterColumnIcon(props) {
|
|
90
90
|
var _useState9 = useState(false),
|
91
91
|
_useState10 = _slicedToArray(_useState9, 2),
|
92
92
|
dropdownVisible = _useState10[0],
|
93
|
-
setDropdownVisible = _useState10[1];
|
93
|
+
setDropdownVisible = _useState10[1]; // 视角
|
94
|
+
|
95
|
+
|
96
|
+
var _useState11 = useState('table'),
|
97
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
98
|
+
cardView = _useState12[0],
|
99
|
+
setCardView = _useState12[1];
|
94
100
|
|
95
101
|
useEffect(function () {
|
96
102
|
on === null || on === void 0 ? void 0 : on(function (stateFilterColumns) {
|
@@ -108,8 +114,12 @@ var FilterColumnIcon = function FilterColumnIcon(props) {
|
|
108
114
|
setNewColumns(stateColumns);
|
109
115
|
}
|
110
116
|
}, 'refreshFilterState');
|
117
|
+
on === null || on === void 0 ? void 0 : on(function (view) {
|
118
|
+
setCardView(view);
|
119
|
+
}, 'cardSwitchChange');
|
111
120
|
return function () {
|
112
121
|
off('refreshFilterState');
|
122
|
+
off('cardSwitchChange');
|
113
123
|
};
|
114
124
|
});
|
115
125
|
useEffect(function () {
|
@@ -276,7 +286,8 @@ var FilterColumnIcon = function FilterColumnIcon(props) {
|
|
276
286
|
}, /*#__PURE__*/React.createElement(CheckboxItem, {
|
277
287
|
indeterminate: indeterminate,
|
278
288
|
checked: allVisible,
|
279
|
-
onChange: onChangeAllColumns
|
289
|
+
onChange: onChangeAllColumns,
|
290
|
+
disabled: cardView === 'card'
|
280
291
|
}, getMessage('selectAll'), /*#__PURE__*/React.createElement(Button, {
|
281
292
|
onClick: restColumns,
|
282
293
|
className: cls({
|
@@ -29,6 +29,8 @@ var FullScreen = function FullScreen(props) {
|
|
29
29
|
}, [visible, actionRef]);
|
30
30
|
|
31
31
|
var afterClose = function afterClose() {
|
32
|
+
var _document;
|
33
|
+
|
32
34
|
// 判断全屏前后筛选表单值是否有改变
|
33
35
|
var n = JSON.stringify(getValidValues(normalDataFilterForm === null || normalDataFilterForm === void 0 ? void 0 : normalDataFilterForm.values));
|
34
36
|
var f = JSON.stringify(getValidValues(fullscreenDataFilterForm === null || fullscreenDataFilterForm === void 0 ? void 0 : fullscreenDataFilterForm.values));
|
@@ -42,11 +44,17 @@ var FullScreen = function FullScreen(props) {
|
|
42
44
|
} // 关闭全屏后,关闭全屏表单onFilter
|
43
45
|
|
44
46
|
|
45
|
-
filterEnableRef.current.fullscreen = false;
|
47
|
+
filterEnableRef.current.fullscreen = false; // 移除类名
|
48
|
+
|
49
|
+
if (document && ((_document = document) === null || _document === void 0 ? void 0 : _document.body)) {
|
50
|
+
document.body.classList.remove('teamix-pro-table-fullscreen');
|
51
|
+
}
|
46
52
|
}; // 全屏开启之后
|
47
53
|
|
48
54
|
|
49
55
|
var afterOpen = function afterOpen() {
|
56
|
+
var _document2;
|
57
|
+
|
50
58
|
// 判断全屏前后筛选表单值是否有改变
|
51
59
|
var n = JSON.stringify(getValidValues(normalDataFilterForm === null || normalDataFilterForm === void 0 ? void 0 : normalDataFilterForm.values));
|
52
60
|
var f = JSON.stringify(getValidValues(fullscreenDataFilterForm === null || fullscreenDataFilterForm === void 0 ? void 0 : fullscreenDataFilterForm.values));
|
@@ -60,7 +68,12 @@ var FullScreen = function FullScreen(props) {
|
|
60
68
|
} // 全屏后,关闭普通表单onFilter
|
61
69
|
|
62
70
|
|
63
|
-
filterEnableRef.current.normal = false; //
|
71
|
+
filterEnableRef.current.normal = false; // 为 body 添加类名,用于判断是否全屏
|
72
|
+
|
73
|
+
if (document && ((_document2 = document) === null || _document2 === void 0 ? void 0 : _document2.body)) {
|
74
|
+
document.body.classList.add('teamix-pro-table-fullscreen');
|
75
|
+
} // 消息提示
|
76
|
+
|
64
77
|
|
65
78
|
Message.show({
|
66
79
|
type: 'notice',
|
@@ -17,7 +17,7 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
17
17
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
18
18
|
|
19
19
|
import { usePrefixCls } from '@teamix/utils';
|
20
|
-
import React, { useEffect, useRef } from 'react';
|
20
|
+
import React, { useEffect, useMemo, useRef } from 'react';
|
21
21
|
import { Button, Balloon } from '@alicloudfe/components';
|
22
22
|
import TeamixIcon from '@teamix/icon';
|
23
23
|
import FullScreenIcon from './FullScreenIcon';
|
@@ -27,12 +27,15 @@ import RefreshIcon from './RefreshIcon';
|
|
27
27
|
import { useSize, useSafeState } from '@teamix/hooks';
|
28
28
|
import debounce from 'lodash.debounce';
|
29
29
|
import './index.scss';
|
30
|
+
import CardSwitch from './CardSwitch';
|
31
|
+
import cloneDeep from 'lodash.clonedeep';
|
30
32
|
var cls = usePrefixCls('teamix-pro-table-toolbar');
|
31
33
|
var presetToolBarMap = {
|
32
34
|
refresh: RefreshIcon,
|
33
35
|
density: DensityIcon,
|
34
36
|
filtercolumn: FilterColumnIcon,
|
35
|
-
fullscreen: FullScreenIcon
|
37
|
+
fullscreen: FullScreenIcon,
|
38
|
+
switchcard: CardSwitch
|
36
39
|
};
|
37
40
|
var presetToolBarName = ['refresh', 'density', 'filtercolumn', 'fullscreen'];
|
38
41
|
var presetToolBar = [{
|
@@ -57,7 +60,10 @@ var ToolBar = function ToolBar(props) {
|
|
57
60
|
var _toolBarRef$current, _toolBarRef$current$p, _toolBarRef$current$p2;
|
58
61
|
|
59
62
|
var toolBar = props.toolBar,
|
60
|
-
fullScreenState = props.fullScreenState
|
63
|
+
fullScreenState = props.fullScreenState,
|
64
|
+
switchCardView = props.switchCardView,
|
65
|
+
_props$toolBarAutoWid = props.toolBarAutoWidth,
|
66
|
+
toolBarAutoWidth = _props$toolBarAutoWid === void 0 ? true : _props$toolBarAutoWid;
|
61
67
|
var toolBarRef = useRef(null); // const toolBarSize = useSize(toolBarRef);
|
62
68
|
// 用于获取内容宽度
|
63
69
|
|
@@ -77,44 +83,69 @@ var ToolBar = function ToolBar(props) {
|
|
77
83
|
|
78
84
|
|
79
85
|
useEffect(debounce(function () {
|
80
|
-
|
81
|
-
// layoutInlineSize?.width,
|
82
|
-
// leftWidth,
|
83
|
-
// toolBarContentRef.current?.clientWidth,
|
84
|
-
// );
|
85
|
-
if ((layoutInlineSize === null || layoutInlineSize === void 0 ? void 0 : layoutInlineSize.width) && leftWidth && toolBarContentRef.current) {
|
86
|
+
if ((layoutInlineSize === null || layoutInlineSize === void 0 ? void 0 : layoutInlineSize.width) && leftWidth && toolBarContentRef.current && toolBarAutoWidth) {
|
86
87
|
var _toolBarContentRef$cu;
|
87
88
|
|
88
|
-
var width = layoutInlineSize.width
|
89
|
+
var width = layoutInlineSize.width,
|
90
|
+
height = layoutInlineSize.height;
|
89
91
|
|
90
|
-
if (width - leftWidth <= ((_toolBarContentRef$cu = toolBarContentRef.current) === null || _toolBarContentRef$cu === void 0 ? void 0 : _toolBarContentRef$cu.clientWidth) + 8) {
|
92
|
+
if (width - leftWidth <= ((_toolBarContentRef$cu = toolBarContentRef.current) === null || _toolBarContentRef$cu === void 0 ? void 0 : _toolBarContentRef$cu.clientWidth) + 8 || height > 40) {
|
91
93
|
setFlat(false);
|
92
|
-
} else {
|
94
|
+
} else if (height === 40) {
|
93
95
|
setFlat(true);
|
94
96
|
}
|
95
97
|
}
|
96
|
-
}, 300));
|
97
|
-
|
98
|
+
}, 300)); // 初始态
|
99
|
+
|
100
|
+
useEffect(function () {
|
101
|
+
if (!((layoutInlineSize === null || layoutInlineSize === void 0 ? void 0 : layoutInlineSize.width) && leftWidth)) {
|
102
|
+
setFlat(true);
|
103
|
+
}
|
104
|
+
}, []);
|
105
|
+
var toolBarList = useMemo(function () {
|
106
|
+
var result = toolBar !== false ? cloneDeep(presetToolBar) : [];
|
107
|
+
|
108
|
+
if (switchCardView && !result.find(function (item) {
|
109
|
+
return item.name === 'switchCard';
|
110
|
+
})) {
|
111
|
+
result.push({
|
112
|
+
type: 'preset',
|
113
|
+
name: 'switchCard',
|
114
|
+
component: presetToolBarMap['switchcard']
|
115
|
+
});
|
116
|
+
}
|
117
|
+
|
118
|
+
if (Array.isArray(toolBar)) {
|
119
|
+
result = toolBar.map(function (item, index) {
|
120
|
+
if (typeof item === 'string' && presetToolBarName.includes(item.toLowerCase())) {
|
121
|
+
return {
|
122
|
+
type: 'preset',
|
123
|
+
name: item,
|
124
|
+
component: presetToolBarMap[item.toLowerCase()]
|
125
|
+
};
|
126
|
+
}
|
98
127
|
|
99
|
-
if (Array.isArray(toolBar)) {
|
100
|
-
toolBarList = toolBar.map(function (item, index) {
|
101
|
-
if (typeof item === 'string' && presetToolBarName.includes(item.toLowerCase())) {
|
102
128
|
return {
|
103
|
-
type: '
|
104
|
-
name:
|
105
|
-
component:
|
129
|
+
type: 'custom',
|
130
|
+
name: "custom".concat(index),
|
131
|
+
component: item
|
106
132
|
};
|
107
|
-
}
|
133
|
+
});
|
108
134
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
135
|
+
if (!toolBar.includes('switchCard') && switchCardView && !result.find(function (item) {
|
136
|
+
return item.name === 'switchCard';
|
137
|
+
})) {
|
138
|
+
result.push({
|
139
|
+
type: 'preset',
|
140
|
+
name: 'switchCard',
|
141
|
+
component: presetToolBarMap['switchcard']
|
142
|
+
});
|
143
|
+
}
|
144
|
+
}
|
116
145
|
|
117
|
-
|
146
|
+
return result;
|
147
|
+
}, [toolBar]);
|
148
|
+
var renderFlatShape = useMemo(function () {
|
118
149
|
return /*#__PURE__*/React.createElement("div", {
|
119
150
|
className: cls('content')
|
120
151
|
}, toolBarList.map(function (_ref) {
|
@@ -130,7 +161,7 @@ var ToolBar = function ToolBar(props) {
|
|
130
161
|
})
|
131
162
|
}, Component));
|
132
163
|
}));
|
133
|
-
};
|
164
|
+
}, [toolBarList]);
|
134
165
|
|
135
166
|
var renderUnFlatShape = function renderUnFlatShape() {
|
136
167
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Balloon.Tooltip, {
|
@@ -145,7 +176,7 @@ var ToolBar = function ToolBar(props) {
|
|
145
176
|
type: "more-line"
|
146
177
|
})),
|
147
178
|
align: "tr"
|
148
|
-
}, renderFlatShape
|
179
|
+
}, renderFlatShape));
|
149
180
|
};
|
150
181
|
|
151
182
|
return /*#__PURE__*/React.createElement("div", {
|
@@ -153,10 +184,10 @@ var ToolBar = function ToolBar(props) {
|
|
153
184
|
flat: flat
|
154
185
|
}),
|
155
186
|
ref: toolBarRef
|
156
|
-
}, !flat && !fullScreenState ? renderUnFlatShape() : renderFlatShape
|
187
|
+
}, !flat && !fullScreenState ? renderUnFlatShape() : renderFlatShape, /*#__PURE__*/React.createElement("div", {
|
157
188
|
className: cls('shadow'),
|
158
189
|
ref: toolBarContentRef
|
159
|
-
}, renderFlatShape
|
190
|
+
}, renderFlatShape));
|
160
191
|
};
|
161
192
|
|
162
193
|
export 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
|
+
}
|