import React from "react"; import { ControlledProps } from "../form/controlled"; import { CheckChangeContext } from "../check"; export interface CheckTreeChangeContext extends CheckChangeContext { /** * 连选相关信息 */ shiftSelect?: { /** * 起始节点名 */ startName: string; /** * 结束 */ endName: string; }; } export declare type ValueMode = "all" | "onlyLeaf" | "parentFirst"; export interface CheckTreeProps extends ControlledProps { /** * 已勾选的叶子节点的 name 集合 */ value?: string[]; /** * 勾选的节点变更时回调 */ onChange?: (value: string[], context: CheckTreeChangeContext) => void; /** * 提供树的节点关系,每个子节点对应其父节点 */ relations: CheckTreeRelation; /** * 组件树内容,内部的 状态将被托管 */ children?: React.ReactNode; /** * 禁用的控件 name */ disabledNames?: string[]; /** * 是否支持按 Shift 快捷键时多选 * * - `"virtualized"` - 适配虚拟滚动,`onChange` 不直接返回变更后的 `value` * * @default true */ shiftSelect?: boolean | "virtualized"; /** * 结点选择值的描述方式 * * - `"all"` - 使用全部层级 * - `"onlyLeaf"` - 仅使用子节点 * - `"parentFirst"` - 当子节点全部选中时,仅使用父节点 * * @default "onlyLeaf" * @since 2.7.0 */ valueMode?: ValueMode; } /** * CheckTree 关系定义 interface ```ts interface CheckTreeRelation { [child: string]: string; } ``` */ export interface CheckTreeRelation { [child: string]: string; } /** * CheckTree 转换 * * 节点 -> 全部选中节点 */ export declare function getAllIds(selectedIds: string[], parentMap: Map, childrenMap: Map>): string[]; /** * 值模式转换 */ export declare function useValueMode(rawValue: string[], rawOnChange: (value: string[], context?: any) => void, parentMap: Map, childrenMap: Map>, mode?: ValueMode): [string[], (value: string[], context?: any) => void]; export declare function getRelationMap(relations: CheckTreeRelation): { parentMap: Map; childrenMap: Map>; }; export declare function CheckTree(props: CheckTreeProps): JSX.Element; export declare function completeDisabledNames(names: string[], childrenMap: Map>): Set;