inputTree的icon显示修复 (#2851)

* inputTree的icon显示修复;并补充文档

* 防止使用fa的时候多次渲染

* 兼容了下使用其他图标

Co-authored-by: zhyc <zhyc@hzsuoyi.com>
This commit is contained in:
decarp 2021-11-04 13:54:26 +08:00 committed by GitHub
parent a9446ed34c
commit 6d40875b67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,7 +19,7 @@ import {
import {Option, Options, value2array} from './Select';
import {ClassNamesFn, themeable, ThemeProps} from '../theme';
import {highlight} from '../renderers/Form/Options';
import {Icon} from './icons';
import {Icon, getIcon} from './icons';
import Checkbox from './Checkbox';
import {LocaleProps, localeable} from '../locale';
import Spinner from './Spinner';
@ -710,6 +710,8 @@ export class TreeSelector extends React.Component<
const isLeaf =
(!item.children || !item.children.length) && !item.placeholder;
const iconValue = item[iconField] || (childrenItems ? 'folder' : 'file');
return (
<li
key={key}
@ -754,7 +756,6 @@ export class TreeSelector extends React.Component<
<i
className={cx(
`Tree-itemIcon ${
item[iconField] ||
(childrenItems ? 'Tree-folderIcon' : 'Tree-leafIcon')
}`
)}
@ -765,10 +766,9 @@ export class TreeSelector extends React.Component<
: this.handleSelect(item))
}
>
<Icon
icon={item[iconField] || (childrenItems ? 'folder' : 'file')}
className="icon"
/>
{getIcon(iconValue)
? <Icon icon={iconValue} className="icon"/>
: <i className={iconValue}></i>}
</i>
) : null}