iconUtil.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
  2. import _typeof from "@babel/runtime/helpers/esm/typeof";
  3. import { createVNode as _createVNode } from "vue";
  4. import LoadingOutlined from "@ant-design/icons-vue/es/icons/LoadingOutlined";
  5. import FileOutlined from "@ant-design/icons-vue/es/icons/FileOutlined";
  6. import MinusSquareOutlined from "@ant-design/icons-vue/es/icons/MinusSquareOutlined";
  7. import PlusSquareOutlined from "@ant-design/icons-vue/es/icons/PlusSquareOutlined";
  8. import CaretDownFilled from "@ant-design/icons-vue/es/icons/CaretDownFilled";
  9. import { isValidElement } from '../../_util/props-util';
  10. import { cloneVNode } from 'vue';
  11. export default function renderSwitcherIcon(prefixCls, switcherIcon, showLine, props) {
  12. var isLeaf = props.isLeaf,
  13. expanded = props.expanded,
  14. loading = props.loading;
  15. var icon = switcherIcon;
  16. if (loading) {
  17. return _createVNode(LoadingOutlined, {
  18. "class": "".concat(prefixCls, "-switcher-loading-icon")
  19. }, null);
  20. }
  21. var showLeafIcon;
  22. if (showLine && _typeof(showLine) === 'object') {
  23. showLeafIcon = showLine.showLeafIcon;
  24. }
  25. var defaultIcon = null;
  26. var switcherCls = "".concat(prefixCls, "-switcher-icon");
  27. if (isLeaf) {
  28. if (showLine) {
  29. if (_typeof(showLine) === 'object' && !showLeafIcon) {
  30. defaultIcon = _createVNode("span", {
  31. "class": "".concat(prefixCls, "-switcher-leaf-line")
  32. }, null);
  33. } else {
  34. defaultIcon = _createVNode(FileOutlined, {
  35. "class": "".concat(prefixCls, "-switcher-line-icon")
  36. }, null);
  37. }
  38. }
  39. return defaultIcon;
  40. } else {
  41. defaultIcon = _createVNode(CaretDownFilled, {
  42. "class": switcherCls
  43. }, null);
  44. if (showLine) {
  45. defaultIcon = expanded ? _createVNode(MinusSquareOutlined, {
  46. "class": "".concat(prefixCls, "-switcher-line-icon")
  47. }, null) : _createVNode(PlusSquareOutlined, {
  48. "class": "".concat(prefixCls, "-switcher-line-icon")
  49. }, null);
  50. }
  51. }
  52. if (typeof switcherIcon === 'function') {
  53. icon = switcherIcon(_objectSpread(_objectSpread({}, props), {}, {
  54. defaultIcon: defaultIcon,
  55. switcherCls: switcherCls
  56. }));
  57. } else if (isValidElement(icon)) {
  58. icon = cloneVNode(icon, {
  59. class: switcherCls
  60. });
  61. }
  62. return icon || defaultIcon;
  63. }