mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-05 13:37:52 +08:00
4907996b97
* use new rc-tree-select * support not found * add switch icon support * support function * support selection motion * show search icon if open * clean up * fix lint * fix lint
64 lines
1.4 KiB
TypeScript
64 lines
1.4 KiB
TypeScript
import React from 'react';
|
|
import { Down, Loading, Check, Close, CloseCircleFilled, Search } from '@ant-design/icons';
|
|
|
|
export default function getIcons({
|
|
suffixIcon,
|
|
clearIcon,
|
|
menuItemSelectedIcon,
|
|
removeIcon,
|
|
loading,
|
|
multiple,
|
|
}: {
|
|
suffixIcon?: React.ReactNode;
|
|
clearIcon?: React.ReactNode;
|
|
menuItemSelectedIcon?: React.ReactNode;
|
|
removeIcon?: React.ReactNode;
|
|
loading?: boolean;
|
|
multiple?: boolean;
|
|
}) {
|
|
// Clear Icon
|
|
let mergedClearIcon = clearIcon;
|
|
if (!clearIcon) {
|
|
mergedClearIcon = <CloseCircleFilled />;
|
|
}
|
|
|
|
// Arrow item icon
|
|
let mergedSuffixIcon = null;
|
|
if (suffixIcon !== undefined) {
|
|
mergedSuffixIcon = suffixIcon;
|
|
} else if (loading) {
|
|
mergedSuffixIcon = <Loading spin />;
|
|
} else {
|
|
mergedSuffixIcon = ({ open, showSearch }: { open: boolean; showSearch: boolean }) => {
|
|
if (open && showSearch) {
|
|
return <Search />;
|
|
}
|
|
return <Down />;
|
|
};
|
|
}
|
|
|
|
// Checked item icon
|
|
let mergedItemIcon = null;
|
|
if (menuItemSelectedIcon !== undefined) {
|
|
mergedItemIcon = menuItemSelectedIcon;
|
|
} else if (multiple) {
|
|
mergedItemIcon = <Check />;
|
|
} else {
|
|
mergedItemIcon = null;
|
|
}
|
|
|
|
let mergedRemoveIcon = null;
|
|
if (removeIcon !== undefined) {
|
|
mergedRemoveIcon = removeIcon;
|
|
} else {
|
|
mergedRemoveIcon = <Close />;
|
|
}
|
|
|
|
return {
|
|
clearIcon: mergedClearIcon,
|
|
suffixIcon: mergedSuffixIcon,
|
|
itemIcon: mergedItemIcon,
|
|
removeIcon: mergedRemoveIcon,
|
|
};
|
|
}
|