import React, { FC, MouseEvent } from 'react' import { ItemProps } from './types' import { Flex } from '../flex' import classNames from 'classnames' import { Checkbox } from '../checkbox' import { IconExpand } from '../icon_expand' const Item: FC = ({ expand, onExpand, checked, indeterminate, onCheck, flatItem: { isLeaf, level, data }, renderLeafItem = (data) => data.text, renderGroupItem = (data) => data.text, active = false, onActive, findActive, disabledCheckbox, style, }) => { const handleGroup = (e: MouseEvent) => { e.stopPropagation() onExpand() } const handleRadio = () => { onCheck() } const handleActive = () => { onActive(data) } return ( {!isLeaf && ( )} {level > 0 && isLeaf &&
} {!disabledCheckbox && ( )} {isLeaf ? renderLeafItem(data) : renderGroupItem(data)} ) } export default React.memo(Item)