ant-design-vue/components/vc-tree/interface.tsx

89 lines
2.0 KiB
Vue
Raw Normal View History

2021-08-20 06:29:18 +00:00
import type { ComputedRef, CSSProperties, Ref, VNode } from 'vue';
2021-08-21 14:55:19 +00:00
import type { TreeNodeProps } from './props';
2021-08-17 06:36:46 +00:00
export type { ScrollTo } from '../vc-virtual-list/List';
export interface DataNode {
checkable?: boolean;
children?: DataNode[];
disabled?: boolean;
disableCheckbox?: boolean;
icon?: IconType;
isLeaf?: boolean;
key: string | number;
title?: any;
selectable?: boolean;
switcherIcon?: IconType;
/** Set style of TreeNode. This is not recommend if you don't have any force requirement */
2021-08-17 14:03:49 +00:00
class?: string;
style?: CSSProperties;
2021-08-17 14:52:28 +00:00
slots?: Record<string, string>;
2021-08-17 06:36:46 +00:00
}
export interface EventDataNode extends DataNode {
2021-08-21 14:51:32 +00:00
expanded?: boolean;
selected?: boolean;
2021-08-17 06:36:46 +00:00
checked: boolean;
2021-08-21 14:51:32 +00:00
loaded?: boolean;
loading?: boolean;
halfChecked?: boolean;
dragOver?: boolean;
dragOverGapTop?: boolean;
dragOverGapBottom?: boolean;
pos?: string;
active?: boolean;
dataRef?: DataNode;
eventKey?: Key; // 兼容 v2 推荐直接用 key
2021-08-17 06:36:46 +00:00
}
export type IconType = any;
export type Key = string | number;
2021-08-20 06:29:18 +00:00
export type NodeElement = VNode<TreeNodeProps>;
2021-08-17 06:36:46 +00:00
2021-08-18 02:48:16 +00:00
export type DragNodeEvent = {
eventData: ComputedRef<EventDataNode>;
eventKey: ComputedRef<Key>;
selectHandle: Ref<HTMLSpanElement>;
pos: ComputedRef<string>;
2021-08-17 06:36:46 +00:00
};
export interface Entity {
node: NodeElement;
index: number;
key: Key;
pos: string;
parent?: Entity;
children?: Entity[];
}
export interface DataEntity extends Omit<Entity, 'node' | 'parent' | 'children'> {
node: DataNode;
parent?: DataEntity;
children?: DataEntity[];
level: number;
}
export interface FlattenNode {
parent: FlattenNode | null;
children: FlattenNode[];
pos: string;
data: DataNode;
title: any;
key: Key;
isStart: boolean[];
isEnd: boolean[];
}
export type GetKey<RecordType> = (record: RecordType, index?: number) => Key;
export type GetCheckDisabled<RecordType> = (record: RecordType) => boolean;
export type Direction = 'ltr' | 'rtl' | undefined;
export interface FieldNames {
title?: string;
key?: string;
children?: string;
}