This commit is contained in:
2022-11-14 11:59:26 +08:00
parent 0a63adba99
commit 492d0963fe
336 changed files with 70636 additions and 7 deletions

4
types/component/tree/index.d.ts vendored Normal file
View File

@@ -0,0 +1,4 @@
import { WithInstallType } from "../../utils";
import Component from "./index.vue";
declare const component: WithInstallType<typeof Component>;
export default component;

49
types/component/tree/tree.d.ts vendored Normal file
View File

@@ -0,0 +1,49 @@
import { OriginalTreeData, StringOrNumber } from "./tree.type";
import { Nullable } from "../../types";
declare type CustomKey = string | number;
declare type CustomString = (() => string) | string;
export interface TreeData {
id: CustomKey;
title: CustomString;
children: TreeData[];
parentKey: Nullable<StringOrNumber>;
isRoot: boolean;
isChecked: boolean;
isDisabled: boolean;
isLeaf: boolean;
hasNextSibling: boolean;
parentNode: Nullable<TreeData>;
}
interface ReplaceFields {
id: string;
title: string;
children: string;
}
interface TreeConfig {
checkStrictly: boolean | string;
showCheckbox: boolean;
checkedKeys: StringOrNumber[];
expandKeys: StringOrNumber[];
nodeMap: Map<StringOrNumber, TreeData>;
originMap: Map<StringOrNumber, OriginalTreeData>;
replaceFields: ReplaceFields;
}
declare class Tree {
protected config: TreeConfig;
protected treeData: TreeData[];
constructor(config: TreeConfig, origin: OriginalTreeData | OriginalTreeData[]);
init(origin: OriginalTreeData | OriginalTreeData[]): void;
createTree(origin: OriginalTreeData | OriginalTreeData[], parentKey?: StringOrNumber): TreeData[];
getNode(origin: OriginalTreeData, parentKey: StringOrNumber, hasNextSibling: boolean): TreeData;
treeForeach(tree: any, func: Function): void;
setChildrenChecked(checked: boolean, nodes: TreeData[]): void;
setParentChecked(checked: boolean, parent: TreeData): void;
setCheckedKeys(checked: boolean, checkStrictly: boolean | string, node: TreeData): void;
getData(): TreeData[];
getKeys(): {
checkedKeys: any[];
expandKeys: any[];
};
getOriginData(key: StringOrNumber): OriginalTreeData;
}
export { Tree };

35
types/component/tree/tree.type.d.ts vendored Normal file
View File

@@ -0,0 +1,35 @@
export declare type StringFn = () => string;
export declare type StringOrNumber = string | number;
export declare type KeysType = (number | string)[];
export declare type EditType = boolean | ("add" | "update" | "delete");
export interface OriginalTreeData {
title: StringFn | string;
id: StringOrNumber;
field: StringFn | string;
children?: OriginalTreeData[];
disabled?: boolean;
}
export interface ReplaceFieldsOptions {
id?: string;
children?: string;
title?: string;
}
export interface TreeProps {
checkedKeys?: KeysType;
expandKeys?: KeysType;
data: OriginalTreeData;
checkStrictly?: boolean | string;
showCheckbox?: boolean;
edit?: EditType;
collapseTransition?: boolean;
onlyIconControl?: boolean;
showLine?: boolean;
replaceFields?: ReplaceFieldsOptions;
}
export interface TreeEmits {
(e: "update:checkedKeys", keys: KeysType): void;
(e: "update:expandKeys", keys: KeysType): void;
(e: "node-click", node: OriginalTreeData, event: Event): void;
}
export declare type CustomKey = string | number;
export declare type CustomString = (() => string) | string;

8
types/component/tree/useTree.d.ts vendored Normal file
View File

@@ -0,0 +1,8 @@
import { TreeEmits, TreeProps } from "./tree.type";
import { ComputedRef } from "vue";
import { Tree, TreeData } from "./tree";
export declare type UseTree = (props: TreeProps, emit: TreeEmits) => {
tree: Tree;
nodeList: ComputedRef<TreeData[]>;
};
export declare const useTree: UseTree;