UNPKG

zent

Version:

一套前端设计语言和基于React的实现

83 lines (82 loc) 3.08 kB
import { Component } from 'react'; import { ICreateStateByPropsParams } from './utils/createStateByProps'; import { ITreeData, TreeRootIdArray, ITreeRootInfoMap, ITreeRenderKey } from './utils/common'; export declare type ITreeSize = 'medium' | 'small' | 'large'; export interface ITreeOperation { name: string; icon?: string | React.ReactNode; action: (data: ITreeData) => void; shouldRender?: (data: ITreeData) => boolean; } export interface ITreeOncheckHelpInfo { currentRoot: ITreeData; disabled: ITreeData[]; all: ITreeData[]; top: ITreeData[]; bottom: ITreeData[]; } export interface ITreeProps extends ICreateStateByPropsParams { render?: (data: ITreeData, isExpanded?: boolean) => React.ReactNode; operations?: ITreeOperation[]; foldable?: boolean; onCheck?: (selected: TreeRootIdArray, info: ITreeOncheckHelpInfo) => void; size?: ITreeSize; commonStyle?: React.CSSProperties; onExpand?: (data: ITreeData, config: { isExpanded: boolean; }) => void; autoExpandOnSelect?: boolean; onSelect?: (data: ITreeData, target: HTMLSpanElement) => void; selectable?: boolean; selectedKey?: string | number; disabledSelectedKeys?: TreeRootIdArray; disableSelectedStrictly?: boolean; onlyShowOneLine?: boolean; } export interface ITreeState { prevProps: ITreeProps; tree: ITreeData[]; rootInfoMap: ITreeRootInfoMap; expandNode: TreeRootIdArray; checkedNode: TreeRootIdArray; disabledNode: TreeRootIdArray; renderKey: ITreeRenderKey; loadingNode: TreeRootIdArray; selectedKey?: string | number; } export declare class Tree extends Component<ITreeProps, ITreeState> { static defaultProps: { autoExpandOnSelect: boolean; dataType: string; foldable: boolean; checkable: boolean; selectable: boolean; size: string; }; constructor(props: ITreeProps); get isSelectControlled(): boolean; get selectedKey(): string | number; get disabledSelectedKeys(): any[]; setSelectKeyState: (data: ITreeData, target: HTMLSpanElement) => void; static getDerivedStateFromProps(nextProps: ITreeProps, state: ITreeState): { prevProps: ITreeProps; tree?: ITreeData[]; rootInfoMap?: ITreeRootInfoMap; expandNode?: TreeRootIdArray; checkedNode?: TreeRootIdArray; disabledNode?: TreeRootIdArray; renderKey?: ITreeRenderKey; loadingNode?: TreeRootIdArray; selectedKey?: string | number; }; handleExpandIconClick(root: ITreeData, e: React.MouseEvent): void; handleExpand(root: ITreeData): void; handleCheckboxClick(root: ITreeData): void; renderSwitcher(root: ITreeData): JSX.Element; renderContent(root: ITreeData, isExpanded: boolean): JSX.Element; renderCheckbox(root: ITreeData): JSX.Element; renderOperations(root: ITreeData, isExpanded: boolean): JSX.Element; renderTreeNodes(roots: ITreeData[], layers?: number): JSX.Element[]; render(): JSX.Element; } export default Tree;