mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-21 04:48:02 +08:00
67513cc71b
* fix: Select icon interactive * updat snasphot
72 lines
1.9 KiB
TypeScript
72 lines
1.9 KiB
TypeScript
import * as React from 'react';
|
|
import DownOutlined from '@ant-design/icons/DownOutlined';
|
|
import LoadingOutlined from '@ant-design/icons/LoadingOutlined';
|
|
import CheckOutlined from '@ant-design/icons/CheckOutlined';
|
|
import CloseOutlined from '@ant-design/icons/CloseOutlined';
|
|
import CloseCircleFilled from '@ant-design/icons/CloseCircleFilled';
|
|
import SearchOutlined from '@ant-design/icons/SearchOutlined';
|
|
|
|
export default function getIcons({
|
|
suffixIcon,
|
|
clearIcon,
|
|
menuItemSelectedIcon,
|
|
removeIcon,
|
|
loading,
|
|
multiple,
|
|
prefixCls,
|
|
}: {
|
|
suffixIcon?: React.ReactNode;
|
|
clearIcon?: React.ReactNode;
|
|
menuItemSelectedIcon?: React.ReactNode;
|
|
removeIcon?: React.ReactNode;
|
|
loading?: boolean;
|
|
multiple?: boolean;
|
|
prefixCls: string;
|
|
}) {
|
|
// Clear Icon
|
|
let mergedClearIcon = clearIcon;
|
|
if (!clearIcon) {
|
|
mergedClearIcon = <CloseCircleFilled />;
|
|
}
|
|
|
|
// Arrow item icon
|
|
let mergedSuffixIcon = null;
|
|
if (suffixIcon !== undefined) {
|
|
mergedSuffixIcon = suffixIcon;
|
|
} else if (loading) {
|
|
mergedSuffixIcon = <LoadingOutlined spin />;
|
|
} else {
|
|
const iconCls = `${prefixCls}-suffix`;
|
|
mergedSuffixIcon = ({ open, showSearch }: { open: boolean; showSearch: boolean }) => {
|
|
if (open && showSearch) {
|
|
return <SearchOutlined className={iconCls} />;
|
|
}
|
|
return <DownOutlined className={iconCls} />;
|
|
};
|
|
}
|
|
|
|
// Checked item icon
|
|
let mergedItemIcon = null;
|
|
if (menuItemSelectedIcon !== undefined) {
|
|
mergedItemIcon = menuItemSelectedIcon;
|
|
} else if (multiple) {
|
|
mergedItemIcon = <CheckOutlined />;
|
|
} else {
|
|
mergedItemIcon = null;
|
|
}
|
|
|
|
let mergedRemoveIcon = null;
|
|
if (removeIcon !== undefined) {
|
|
mergedRemoveIcon = removeIcon;
|
|
} else {
|
|
mergedRemoveIcon = <CloseOutlined />;
|
|
}
|
|
|
|
return {
|
|
clearIcon: mergedClearIcon,
|
|
suffixIcon: mergedSuffixIcon,
|
|
itemIcon: mergedItemIcon,
|
|
removeIcon: mergedRemoveIcon,
|
|
};
|
|
}
|