@meleon/uni-ui
Version:
A uniapp components library written in vue3 and typescript
103 lines (102 loc) • 2.89 kB
TypeScript
export interface TreeDataEntity {
title: string;
key: string;
disabled?: boolean;
checkable?: boolean;
selectable?: boolean;
children?: TreeDataEntity[];
}
interface EmitPayload {
node: TreeNodeEntity;
nodeData: TreeDataEntity;
}
export interface TreeCheckPayload extends EmitPayload {
checked: boolean;
indeterminateKeys: string[];
}
export interface TreeExpandPayload extends EmitPayload {
expanded?: boolean;
}
export interface TreeSelectPayload extends EmitPayload {
selected: boolean;
}
export interface TreeEvents {
getExpandedNodes: () => TreeNodeEntity[];
expandNode: (key: string | string[], expanded: boolean) => void;
expandAll: (expandAll?: boolean) => void;
getSelectedNodes: () => TreeNodeEntity[];
selectNode: (key: string | string[], selected: boolean) => void;
selectAll: (selectAll?: boolean) => void;
getCheckedNodes: () => TreeNodeEntity[];
getIndeterminateNodes: () => TreeNodeEntity[];
checkNode: (key: string | string[], selected: boolean) => void;
checkAll: (selectAll?: boolean) => void;
}
export interface TreeNodeEntity extends TreeDataEntity {
level: number;
isLeaf: boolean;
parentNode?: TreeNodeEntity;
parentNodeKey?: string;
parentNodeKeysPath?: string[];
treeNodeData: TreeDataEntity;
treeNodeProps: Partial<TreeNodeEntity>;
children?: TreeNodeEntity[];
}
export interface TreeOptions {
checkable: boolean;
selectable: boolean;
loadMore: boolean;
}
export type Key2TreeNode = Map<string, TreeNodeEntity>;
export interface TreeProps {
data: TreeDataEntity[];
/**
* @description 展开节点的 key 值列表
*/
expandedKeys: string[];
/**
* @description 默认展开节点的 key 值列表
*/
defaultExpandedKeys: string[];
/**
* @description 是否自动展开父节点
*/
autoExpandParent: boolean;
/**
* @description 是否支持选择文本节点
*/
selectable: boolean;
/**
* @description 选中节点的 key 值列表
*/
selectedKeys: string[];
/**
* @description 默认选中节点的 key 值列表
*/
defaultSelectedKeys: string[];
/**
* @description 是否支持多选
*/
multiple: boolean;
/**
* @description 是否显示选择器
*/
checkable: boolean;
/**
* @description 选中复选框的节点的 key 值列表
*/
checkedKeys: string[];
/**
* @description 默认选中复选框的节点的 key 值列表
*/
defaultCheckedKeys: string[];
/**
* @description 半选的 key 值的列表
*/
indeterminateKeys: string[];
/**
* @description 是否支持异步加载
*/
loadMore: boolean;
}
export {};