Skip to content

Commit

Permalink
feat: update types
Browse files Browse the repository at this point in the history
  • Loading branch information
ChuChencheng committed Aug 10, 2024
1 parent 4a2fdc9 commit 48e34c7
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 39 deletions.
2 changes: 1 addition & 1 deletion tsconfig.tsbuildinfo

Large diffs are not rendered by default.

20 changes: 11 additions & 9 deletions types/components/Tree.vue.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
filter: (keyword: string, filterMethod?: FilterFunctionType | undefined) => void;
showCheckedNodes: (showUnloadCheckedNodes?: boolean | undefined) => void;
loadRootNodes: () => Promise<void>;
scrollTo: (key: TreeNodeKeyType, verticalPosition?: number | "top" | "center" | "bottom") => void;
updateNode: (key: TreeNodeKeyType, newNode: import("../store/tree-node").ITreeNodeOptions) => void;
updateNodes: (newNodes: import("../store/tree-node").ITreeNodeOptions[]) => void;
scrollTo: (key: TreeNodeKeyType, verticalPosition?: number | "bottom" | "top" | "center") => void;
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
[x: string]: (...args: any[]) => void;
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<TreeProps>, {
Expand Down Expand Up @@ -211,25 +213,25 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
cascade: boolean;
defaultExpandAll: boolean;
expandOnFilter: boolean;
titleField: string;
checkable: boolean;
selectable: boolean;
unselectOnClick: boolean;
disableAll: boolean;
draggable: boolean;
droppable: boolean;
nodeIndent: number;
data: AnyPropsArrayType;
emptyText: string;
selectable: boolean;
checkable: boolean;
separator: string;
titleField: string;
showUnloadCheckedNodes: boolean;
unloadDataList: AnyPropsArrayType;
enableLeafOnly: boolean;
disableAll: boolean;
defaultExpandedKeys: TreeNodeKeyType[];
expandedKeys: TreeNodeKeyType[];
draggable: boolean;
droppable: boolean;
beforeDropMethod: (dragKey: TreeNodeKeyType, dropKey: TreeNodeKeyType, hoverPart: dragHoverPartEnum) => boolean;
autoLoad: boolean;
unselectOnClick: boolean;
loading: boolean;
nodeIndent: number;
renderNodeAmount: number;
nodeMinHeight: number;
bufferNodeAmount: number;
Expand Down
26 changes: 14 additions & 12 deletions types/components/TreeDrop.vue.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
renderNodeAmount: number;
bufferNodeAmount: number;
}>, {
filter: (keyword: string, filterMethod?: import("../store/tree-store.js").FilterFunctionType | undefined) => void;
search: (keyword1?: string | undefined) => Promise<void>;
setData: (data: import("../types").AnyPropsArrayType) => void;
setChecked: (key: TreeNodeKeyType, value: boolean) => void;
setCheckedKeys: (keys: TreeNodeKeyType[], value: boolean) => void;
Expand Down Expand Up @@ -143,11 +141,15 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
append: (insertedNode: TreeNodeKeyType | import("../store/tree-node.js").ITreeNodeOptions, parentKey: TreeNodeKeyType) => TreeNode | null;
prepend: (insertedNode: TreeNodeKeyType | import("../store/tree-node.js").ITreeNodeOptions, parentKey: TreeNodeKeyType) => TreeNode | null;
remove: (removedKey: TreeNodeKeyType) => TreeNode | null;
filter: (keyword: string, filterMethod?: import("../store/tree-store.js").FilterFunctionType | undefined) => void;
showCheckedNodes: (showUnloadCheckedNodes?: boolean | undefined) => void;
loadRootNodes: () => Promise<void>;
scrollTo: (key: TreeNodeKeyType, verticalPosition?: number | "top" | "center" | "bottom") => void;
updateNode: (key: TreeNodeKeyType, newNode: import("../store/tree-node.js").ITreeNodeOptions) => void;
updateNodes: (newNodes: import("../store/tree-node.js").ITreeNodeOptions[]) => void;
scrollTo: (key: TreeNodeKeyType, verticalPosition?: number | "bottom" | "top" | "center") => void;
clearKeyword: () => void;
getKeyword: () => string;
search: (keyword1?: string | undefined) => Promise<void>;
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
[x: string]: (...args: any[]) => void;
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<TreeDropProps>, {
Expand Down Expand Up @@ -202,25 +204,25 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
cascade: boolean;
defaultExpandAll: boolean;
expandOnFilter: boolean;
titleField: string;
checkable: boolean;
selectable: boolean;
unselectOnClick: boolean;
disableAll: boolean;
draggable: boolean;
droppable: boolean;
nodeIndent: number;
data: import("../types").AnyPropsArrayType;
emptyText: string;
selectable: boolean;
checkable: boolean;
separator: string;
titleField: string;
showUnloadCheckedNodes: boolean;
unloadDataList: import("../types").AnyPropsArrayType;
enableLeafOnly: boolean;
disableAll: boolean;
defaultExpandedKeys: TreeNodeKeyType[];
expandedKeys: TreeNodeKeyType[];
draggable: boolean;
droppable: boolean;
beforeDropMethod: (dragKey: TreeNodeKeyType, dropKey: TreeNodeKeyType, hoverPart: import("../constants").dragHoverPartEnum) => boolean;
autoLoad: boolean;
unselectOnClick: boolean;
loading: boolean;
nodeIndent: number;
renderNodeAmount: number;
nodeMinHeight: number;
bufferNodeAmount: number;
Expand All @@ -236,7 +238,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
dropHeight: number;
dropDisabled: boolean;
clearable: boolean;
placement: "top" | "bottom" | "bottom-start" | "bottom-end" | "top-start" | "top-end";
placement: "bottom-start" | "bottom-end" | "bottom" | "top-start" | "top-end" | "top";
transfer: boolean;
dropdownWidthFixed: boolean;
}, {}>, Partial<Record<NonNullable<string | number>, (_: any) => any>> & {
Expand Down
22 changes: 12 additions & 10 deletions types/components/TreeSearch.vue.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
clearKeyword: () => void;
getKeyword: () => string;
search: (keyword1?: string) => Promise<void>;
filter: (keyword: string, filterMethod?: import("../store/tree-store.js").FilterFunctionType | undefined) => void;
setData: (data: import("..").AnyPropsArrayType) => void;
setChecked: (key: import("..").TreeNodeKeyType, value: boolean) => void;
setCheckedKeys: (keys: import("..").TreeNodeKeyType[], value: boolean) => void;
Expand Down Expand Up @@ -131,9 +130,12 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
append: (insertedNode: import("..").TreeNodeKeyType | import("../store/tree-node.js").ITreeNodeOptions, parentKey: import("..").TreeNodeKeyType) => TreeNode | null;
prepend: (insertedNode: import("..").TreeNodeKeyType | import("../store/tree-node.js").ITreeNodeOptions, parentKey: import("..").TreeNodeKeyType) => TreeNode | null;
remove: (removedKey: import("..").TreeNodeKeyType) => TreeNode | null;
filter: (keyword: string, filterMethod?: import("../store/tree-store.js").FilterFunctionType | undefined) => void;
showCheckedNodes: (showUnloadCheckedNodes?: boolean | undefined) => void;
loadRootNodes: () => Promise<void>;
scrollTo: (key: import("..").TreeNodeKeyType, verticalPosition?: number | "top" | "center" | "bottom") => void;
updateNode: (key: import("..").TreeNodeKeyType, newNode: import("../store/tree-node.js").ITreeNodeOptions) => void;
updateNodes: (newNodes: import("../store/tree-node.js").ITreeNodeOptions[]) => void;
scrollTo: (key: import("..").TreeNodeKeyType, verticalPosition?: number | "bottom" | "top" | "center") => void;
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
[x: string]: (...args: any[]) => void;
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<TreeSearchProps>, {
Expand Down Expand Up @@ -181,25 +183,25 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
cascade: boolean;
defaultExpandAll: boolean;
expandOnFilter: boolean;
titleField: string;
checkable: boolean;
selectable: boolean;
unselectOnClick: boolean;
disableAll: boolean;
draggable: boolean;
droppable: boolean;
nodeIndent: number;
data: import("..").AnyPropsArrayType;
emptyText: string;
selectable: boolean;
checkable: boolean;
separator: string;
titleField: string;
showUnloadCheckedNodes: boolean;
unloadDataList: import("..").AnyPropsArrayType;
enableLeafOnly: boolean;
disableAll: boolean;
defaultExpandedKeys: import("..").TreeNodeKeyType[];
expandedKeys: import("..").TreeNodeKeyType[];
draggable: boolean;
droppable: boolean;
beforeDropMethod: (dragKey: import("..").TreeNodeKeyType, dropKey: import("..").TreeNodeKeyType, hoverPart: import("../constants").dragHoverPartEnum) => boolean;
autoLoad: boolean;
unselectOnClick: boolean;
loading: boolean;
nodeIndent: number;
renderNodeAmount: number;
nodeMinHeight: number;
bufferNodeAmount: number;
Expand Down
4 changes: 2 additions & 2 deletions types/constants/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ export declare enum ignoreEnum {
parents = "parents",
children = "children"
}
export declare const TREE_API_METHODS: readonly ["setData", "setChecked", "setCheckedKeys", "checkAll", "clearChecked", "setSelected", "clearSelected", "setExpand", "setExpandKeys", "setExpandAll", "getCheckedNodes", "getCheckedKeys", "getIndeterminateNodes", "getSelectedNode", "getSelectedKey", "getExpandNodes", "getExpandKeys", "getCurrentVisibleNodes", "getNode", "getTreeData", "getFlatData", "getNodesCount", "insertBefore", "insertAfter", "append", "prepend", "remove", "filter", "showCheckedNodes", "loadRootNodes", "scrollTo"];
export declare const TREE_SEARCH_API_METHODS: readonly ["setData", "setChecked", "setCheckedKeys", "checkAll", "clearChecked", "setSelected", "clearSelected", "setExpand", "setExpandKeys", "setExpandAll", "getCheckedNodes", "getCheckedKeys", "getIndeterminateNodes", "getSelectedNode", "getSelectedKey", "getExpandNodes", "getExpandKeys", "getCurrentVisibleNodes", "getNode", "getTreeData", "getFlatData", "getNodesCount", "insertBefore", "insertAfter", "append", "prepend", "remove", "filter", "showCheckedNodes", "loadRootNodes", "scrollTo", "clearKeyword", "getKeyword", "search"];
export declare const TREE_API_METHODS: readonly ["setData", "setChecked", "setCheckedKeys", "checkAll", "clearChecked", "setSelected", "clearSelected", "setExpand", "setExpandKeys", "setExpandAll", "getCheckedNodes", "getCheckedKeys", "getIndeterminateNodes", "getSelectedNode", "getSelectedKey", "getExpandNodes", "getExpandKeys", "getCurrentVisibleNodes", "getNode", "getTreeData", "getFlatData", "getNodesCount", "insertBefore", "insertAfter", "append", "prepend", "remove", "filter", "showCheckedNodes", "loadRootNodes", "updateNode", "updateNodes", "scrollTo"];
export declare const TREE_SEARCH_API_METHODS: readonly ["setData", "setChecked", "setCheckedKeys", "checkAll", "clearChecked", "setSelected", "clearSelected", "setExpand", "setExpandKeys", "setExpandAll", "getCheckedNodes", "getCheckedKeys", "getIndeterminateNodes", "getSelectedNode", "getSelectedKey", "getExpandNodes", "getExpandKeys", "getCurrentVisibleNodes", "getNode", "getTreeData", "getFlatData", "getNodesCount", "insertBefore", "insertAfter", "append", "prepend", "remove", "filter", "showCheckedNodes", "loadRootNodes", "updateNode", "updateNodes", "scrollTo", "clearKeyword", "getKeyword", "search"];
export declare enum placementEnum {
'bottom-start' = "bottom-start",
'bottom-end' = "bottom-end",
Expand Down
2 changes: 2 additions & 0 deletions types/hooks/usePublicTreeAPI.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,7 @@ export declare const usePublicTreeAPI: (nonReactive: INonReactiveData, props: IU
filter: (keyword: string, filterMethod?: FilterFunctionType) => void;
showCheckedNodes: (showUnloadCheckedNodes?: boolean) => void;
loadRootNodes: () => Promise<void>;
updateNode: (key: TreeNodeKeyType, newNode: ITreeNodeOptions) => void;
updateNodes: (newNodes: ITreeNodeOptions[]) => void;
};
export {};
22 changes: 17 additions & 5 deletions types/store/tree-store.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ export default class TreeStore extends TreeEventTarget {
* @param triggerDataChange 是否触发视图刷新
*/
private triggerCheckedChange;
/**
* 触发 selected-change 的快捷方法
* @param triggerEvent 是否触发事件
* @param triggerDataChange 是否触发视图刷新
*/
private triggerSelectedChange;
/**
* 设置单选选中
* @param key 选中节点 key
Expand Down Expand Up @@ -109,6 +115,9 @@ export default class TreeStore extends TreeEventTarget {
*/
setExpandKeys(keys: TreeNodeKeyType[], value: boolean, triggerDataChange?: boolean): void;
setExpandAll(value: boolean, triggerDataChange?: boolean): void;
private isChildrenChanged;
updateNode(key: TreeNodeKeyType, newNode: ITreeNodeOptions, triggerEvent?: boolean, triggerDataChange?: boolean): void;
updateNodes(newNodes: ITreeNodeOptions[]): void;
/**
* 获取多选选中节点
* @param ignoreMode 忽略模式,可选择忽略父节点或子节点,默认值是 VTree 的 ignoreMode Prop
Expand Down Expand Up @@ -148,15 +157,17 @@ export default class TreeStore extends TreeEventTarget {
* @param key 节点 key
*/
getNode(key: TreeNodeKeyType): TreeNode | null;
insertBefore(insertedNode: TreeNodeKeyType | ITreeNodeOptions, referenceKey: TreeNodeKeyType): TreeNode | null;
insertAfter(insertedNode: TreeNodeKeyType | ITreeNodeOptions, referenceKey: TreeNodeKeyType): TreeNode | null;
append(insertedNode: TreeNodeKeyType | ITreeNodeOptions, parentKey: TreeNodeKeyType): TreeNode | null;
prepend(insertedNode: TreeNodeKeyType | ITreeNodeOptions, parentKey: TreeNodeKeyType): TreeNode | null;
insertBefore(insertedNode: TreeNodeKeyType | ITreeNodeOptions, referenceKey: TreeNodeKeyType, triggerEvent?: boolean, triggerDataChange?: boolean): TreeNode | null;
insertAfter(insertedNode: TreeNodeKeyType | ITreeNodeOptions, referenceKey: TreeNodeKeyType, triggerEvent?: boolean, triggerDataChange?: boolean): TreeNode | null;
append(insertedNode: TreeNodeKeyType | ITreeNodeOptions, parentKey: TreeNodeKeyType, triggerEvent?: boolean, triggerDataChange?: boolean): TreeNode | null;
prepend(insertedNode: TreeNodeKeyType | ITreeNodeOptions, parentKey: TreeNodeKeyType, triggerEvent?: boolean, triggerDataChange?: boolean): TreeNode | null;
/**
* 删除节点
* @param removedKey 要删除的节点 key
*/
remove(removedKey: TreeNodeKeyType, triggerDataChange?: boolean): TreeNode | null;
remove(removedKey: TreeNodeKeyType, triggerEvent?: boolean, triggerDataChange?: boolean): TreeNode | null;
private removeChildren;
private loadChildren;
private getInsertedNode;
/**
* 将一个节点插入 store 记录中
Expand Down Expand Up @@ -200,6 +211,7 @@ export default class TreeStore extends TreeEventTarget {
/**
* 向上勾选/取消勾选父节点,不包括自身
* @param node 需要勾选的节点
* @param fromCurrentNode 是否从当前节点开始处理
*/
private checkNodeUpward;
/**
Expand Down
4 changes: 4 additions & 0 deletions types/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@ export interface INonReactiveData {
store: TreeStore;
blockNodes: TreeNode[];
}
type Enumerate<N extends number, Acc extends number[] = []> = Acc['length'] extends N ? Acc[number] : Enumerate<N, [...Acc, Acc['length']]>;
type IntRange<F extends number, T extends number> = Exclude<Enumerate<T>, Enumerate<F>>;
export interface ShowLine {
/** 连接线宽度,svg stroke-width, 默认 1px */
width?: number;
type?: showLineType;
color?: string;
polyline?: boolean;
dashDensity?: IntRange<1, 11>;
}
export {};

0 comments on commit 48e34c7

Please sign in to comment.