/**
* @file Tree
* @description 树形组件
*
* 情况列举:
* 1. 选中父节点时,连带选中子节点 : autoChildren = true 前提条件
* 1.1 交互
* 1.1.1 子节点不可以取消勾选 cascade = false,
* 1.1.2 子节点可以取消勾选 cascade = true, withChildren 失效
* 1.2 数据(state.value)
* 1.2.1 只提交父节点数据 cascade = false
* 1.2.2 只提交子节点的数据 onlyChildren = true
* 1.2.3 全部数据提交 withChildren = true || cascade = true
*
* 2. 选中节点时,只选中当前节点,没有联动效果
*
* @author fex
*/
///
import React from 'react';
import { Option, Options } from './Select';
import { ThemeProps } from 'amis-core';
import { LocaleProps } from 'amis-core';
import { SpinnerExtraProps } from './Spinner';
import { ItemRenderStates } from './Selection';
interface IDropIndicator {
left: number;
top: number;
width: number;
height?: number;
}
export interface IDropInfo {
dragNode: Option | null;
node: Option;
position: 'top' | 'bottom' | 'self';
indicator: IDropIndicator;
}
interface TreeSelectorProps extends ThemeProps, LocaleProps, SpinnerExtraProps {
highlightTxt?: string;
onRef?: any;
showIcon?: boolean;
initiallyOpen?: boolean;
unfoldedLevel?: number;
showRadio?: boolean;
multiple?: boolean;
disabled?: boolean;
withChildren?: boolean;
onlyChildren?: boolean;
onlyLeaf?: boolean;
labelField: string;
valueField: string;
iconField: string;
deferField: string;
unfoldedField: string;
foldedField: string;
disabledField: string;
showOutline?: boolean;
className?: string;
itemClassName?: string;
joinValues?: boolean;
extractValue?: boolean;
delimiter?: string;
options: Options;
value: any;
onChange: Function;
placeholder?: string;
hideRoot?: boolean;
rootLabel?: string;
rootValue?: any;
enableNodePath?: boolean;
pathSeparator?: string;
nodePath: any[];
autoCheckChildren: boolean;
cascade?: boolean;
/**
* 是否使用 disable 字段
*/
selfDisabledAffectChildren?: boolean;
minLength?: number;
maxLength?: number;
bultinCUD?: boolean;
rootCreatable?: boolean;
rootCreateTip?: string;
creatable?: boolean;
createTip?: string;
virtualThreshold?: number;
itemHeight?: number;
onAdd?: (idx?: number | Array, value?: any, skipForm?: boolean) => void;
editable?: boolean;
editTip?: string;
onEdit?: (value: Option, origin?: Option, skipForm?: boolean) => void;
removable?: boolean;
removeTip?: string;
onDelete?: (value: Option) => void;
onDeferLoad?: (option: Option) => void;
onExpandTree?: (nodePathArr: any[]) => void;
draggable?: boolean;
onMove?: (dropInfo: IDropInfo) => void;
itemRender?: (option: Option, states: ItemRenderStates) => JSX.Element;
checkAll?: boolean;
checkAllLabel?: string;
enableDefaultIcon?: boolean;
}
interface TreeSelectorState {
value: Array;
valueSet: Set;
inputValue: string;
addingParent: Option | null;
isAdding: boolean;
isEditing: boolean;
editingItem: Option | null;
flattenedOptions: Option[];
dropIndicator?: IDropIndicator;
}
export declare class TreeSelector extends React.Component {
static defaultProps: {
showIcon: boolean;
showOutline: boolean;
initiallyOpen: boolean;
unfoldedLevel: number;
showRadio: boolean;
multiple: boolean;
disabled: boolean;
withChildren: boolean;
onlyChildren: boolean;
labelField: string;
valueField: string;
iconField: string;
deferField: string;
unfoldedField: string;
foldedField: string;
disabledField: string;
joinValues: boolean;
extractValue: boolean;
delimiter: string;
hideRoot: boolean;
rootLabel: string;
rootValue: number;
autoCheckChildren: boolean;
cascade: boolean;
selfDisabledAffectChildren: boolean;
rootCreateTip: string;
createTip: string;
editTip: string;
removeTip: string;
enableNodePath: boolean;
pathSeparator: string;
nodePath: never[];
virtualThreshold: number;
itemHeight: number;
enableDefaultIcon: boolean;
};
unfolded: WeakMap