import LoadingOutlined from '@ant-design/icons-vue/LoadingOutlined';
import FileOutlined from '@ant-design/icons-vue/FileOutlined';
import MinusSquareOutlined from '@ant-design/icons-vue/MinusSquareOutlined';
import PlusSquareOutlined from '@ant-design/icons-vue/PlusSquareOutlined';
import CaretDownFilled from '@ant-design/icons-vue/CaretDownFilled';
import type { AntTreeNodeProps } from '../Tree';
import { isValidElement } from '../../_util/props-util';
import { cloneVNode } from 'vue';
export default function renderSwitcherIcon(
prefixCls: string,
switcherIcon: any,
showLine: boolean | { showLeafIcon: boolean } | undefined,
props: AntTreeNodeProps,
) {
const { isLeaf, expanded, loading } = props;
let icon = switcherIcon;
if (loading) {
return ;
}
let showLeafIcon: boolean;
if (showLine && typeof showLine === 'object') {
showLeafIcon = showLine.showLeafIcon;
}
let defaultIcon = null;
const switcherCls = `${prefixCls}-switcher-icon`;
if (isLeaf) {
if (showLine) {
if (typeof showLine === 'object' && !showLeafIcon) {
defaultIcon = ;
} else {
defaultIcon = ;
}
}
return defaultIcon;
} else {
defaultIcon = ;
if (showLine) {
defaultIcon = expanded ? (
) : (
);
}
}
if (typeof switcherIcon === 'function') {
icon = switcherIcon({ ...props, defaultIcon, switcherCls });
} else if (isValidElement(icon)) {
icon = cloneVNode(icon, {
class: switcherCls,
});
}
return icon || defaultIcon;
}