Match-id-e266428ff041c68ffd2851a12262c612f5a354c3

This commit is contained in:
* 2022-04-07 11:56:48 +08:00 committed by *
parent baf13b7c59
commit cc11ffd17f
1 changed files with 13 additions and 7 deletions

View File

@ -12,30 +12,36 @@ export interface IData {
userKey: string; userKey: string;
} }
type IItem = { interface IItem {
hasChild: boolean, hasChild: boolean,
onCollapse: (id: string) => void, onCollapse: (id: string) => void,
onClick: (id: string) => void, onClick: (id: string) => void,
isCollapsed: boolean, isCollapsed: boolean,
isSelect: boolean, isSelect: boolean,
highlightValue: string, highlightValue: string,
} & IData data: IData,
}
const indentationLength = 20; const indentationLength = 20;
function Item(props: IItem) { function Item(props: IItem) {
const { const {
name,
userKey,
hasChild, hasChild,
onCollapse, onCollapse,
isCollapsed, isCollapsed,
id, data,
indentation,
onClick, onClick,
isSelect, isSelect,
highlightValue = '', highlightValue = '',
} = props; } = props;
const {
name,
userKey,
id,
indentation,
} = data;
const isShowKey = userKey !== ''; const isShowKey = userKey !== '';
const showIcon = hasChild ? <Triangle director={isCollapsed ? 'right' : 'down'} /> : ''; const showIcon = hasChild ? <Triangle director={isCollapsed ? 'right' : 'down'} /> : '';
const handleClickCollapse = () => { const handleClickCollapse = () => {
@ -163,7 +169,7 @@ function VTree({ data, highlightValue, selectedId, onRendered }: {
onCollapse={changeCollapseNode} onCollapse={changeCollapseNode}
onClick={handleClickItem} onClick={handleClickItem}
highlightValue={highlightValue} highlightValue={highlightValue}
{...item} /> data={item} />
); );
}} }}
</VList> </VList>