Browse Source

chore: fix ts

pull/34974/head
zombiej 3 years ago
parent
commit
65cec1458f
  1. 2
      components/tree/Tree.tsx
  2. 7
      components/tree/utils/iconUtil.tsx

2
components/tree/Tree.tsx

@ -9,6 +9,8 @@ import collapseMotion from '../_util/motion';
import renderSwitcherIcon from './utils/iconUtil';
import dropIndicatorRender from './utils/dropIndicator';
export type SwitcherIcon = React.ReactNode | ((props: { expanded: boolean }) => React.ReactNode);
export interface AntdTreeNodeAttribute {
eventKey: string;
prefixCls: string;

7
components/tree/utils/iconUtil.tsx

@ -5,12 +5,12 @@ import FileOutlined from '@ant-design/icons/FileOutlined';
import MinusSquareOutlined from '@ant-design/icons/MinusSquareOutlined';
import PlusSquareOutlined from '@ant-design/icons/PlusSquareOutlined';
import CaretDownFilled from '@ant-design/icons/CaretDownFilled';
import { AntTreeNodeProps } from '../Tree';
import type { AntTreeNodeProps, SwitcherIcon } from '../Tree';
import { isValidElement, cloneElement } from '../../_util/reactNode';
export default function renderSwitcherIcon(
prefixCls: string,
switcherIcon: React.ReactNode | ((props: any) => React.ReactNode),
switcherIcon: SwitcherIcon,
showLine: boolean | { showLeafIcon: boolean } | undefined,
treeNodeProps: AntTreeNodeProps,
): React.ReactNode {
@ -35,7 +35,8 @@ export default function renderSwitcherIcon(
const switcherCls = `${prefixCls}-switcher-icon`;
const switcher = typeof switcherIcon === 'function' ? switcherIcon({ expanded }) : switcherIcon;
const switcher =
typeof switcherIcon === 'function' ? switcherIcon({ expanded: !!expanded }) : switcherIcon;
if (isValidElement(switcher)) {
return cloneElement(switcher, {

Loading…
Cancel
Save