iconUtil.js
2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import _typeof from "@babel/runtime/helpers/typeof";
import * as React from 'react';
import classNames from 'classnames';
import LoadingOutlined from '@ant-design/icons/LoadingOutlined';
import FileOutlined from '@ant-design/icons/FileOutlined';
import MinusSquareOutlined from '@ant-design/icons/MinusSquareOutlined';
import PlusSquareOutlined from '@ant-design/icons/PlusSquareOutlined';
import CaretDownFilled from '@ant-design/icons/CaretDownFilled';
import { isValidElement, cloneElement } from '../../_util/reactNode';
export default function renderSwitcherIcon(prefixCls, switcherIcon, showLine, _ref) {
var isLeaf = _ref.isLeaf,
expanded = _ref.expanded,
loading = _ref.loading;
if (loading) {
return /*#__PURE__*/React.createElement(LoadingOutlined, {
className: "".concat(prefixCls, "-switcher-loading-icon")
});
}
var showLeafIcon;
if (showLine && _typeof(showLine) === 'object') {
showLeafIcon = showLine.showLeafIcon;
}
if (isLeaf) {
if (showLine) {
if (_typeof(showLine) === 'object' && !showLeafIcon) {
return /*#__PURE__*/React.createElement("span", {
className: "".concat(prefixCls, "-switcher-leaf-line")
});
}
return /*#__PURE__*/React.createElement(FileOutlined, {
className: "".concat(prefixCls, "-switcher-line-icon")
});
}
return null;
}
var switcherCls = "".concat(prefixCls, "-switcher-icon");
if (isValidElement(switcherIcon)) {
return cloneElement(switcherIcon, {
className: classNames(switcherIcon.props.className || '', switcherCls)
});
}
if (switcherIcon) {
return switcherIcon;
}
if (showLine) {
return expanded ? /*#__PURE__*/React.createElement(MinusSquareOutlined, {
className: "".concat(prefixCls, "-switcher-line-icon")
}) : /*#__PURE__*/React.createElement(PlusSquareOutlined, {
className: "".concat(prefixCls, "-switcher-line-icon")
});
}
return /*#__PURE__*/React.createElement(CaretDownFilled, {
className: switcherCls
});
}