Skip to content

chore: fix tree type #3598

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 25 additions & 10 deletions components/tree/Tree.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineComponent, inject, VNode, PropType } from 'vue';
import { defineComponent, inject, VNode, PropType, CSSProperties } from 'vue';
import classNames from '../_util/classNames';
import LoadingOutlined from '@ant-design/icons-vue/LoadingOutlined';
import FileOutlined from '@ant-design/icons-vue/FileOutlined';
Expand All @@ -24,22 +24,22 @@ export interface TreeDataItem {
disableCheckbox?: boolean;
disabled?: boolean;
class?: string;
style?: any;
style?: CSSProperties;
checkable?: boolean;
icon?: any;
slots?: any;
switcherIcon?: any;
icon?: VNode;
slots?: Record<string, string>;
switcherIcon?: VNode;
}

interface DefaultEvent {
nativeEvent: MouseEvent;
node: any;
node: Record<string, any>;
}

export interface CheckEvent extends DefaultEvent {
checked: boolean;
checkedNodes: VNode[];
checkedNodesPositions: { node: VNode; pos: string | number }[];
checkedNodes: Array<Record<string, any>>;
checkedNodesPositions: { node: Record<string, any>; pos: string | number }[];
event: string;
halfCheckedKeys: (string | number)[];
}
Expand All @@ -51,7 +51,22 @@ export interface ExpendEvent extends DefaultEvent {
export interface SelectEvent extends DefaultEvent {
event: string;
selected: boolean;
selectedNodes: VNode[];
selectedNodes: Array<Record<string, any>>;
}

export interface TreeDragEvent {
event: DragEvent;
expandedKeys: (string | number)[];
node: Record<string, any>;
}

export interface DropEvent {
dragNode: Record<string, any>;
dragNodesKeys: (string | number)[];
dropPosition: number;
dropToGap: boolean;
event: DragEvent;
node: Record<string, any>;
}

function TreeProps() {
Expand Down Expand Up @@ -263,7 +278,7 @@ export default defineComponent({
onCheck: this.handleCheck,
onExpand: this.handleExpand,
onSelect: this.handleSelect,
} as any;
} as Record<string, any>;
if (treeData) {
vcTreeProps.treeData = treeData;
}
Expand Down