interface TreeNode { [key: string | number]: unknown | TreeNode[]; } export type getTreeMapProps = { tree: any[]; children?: string; hasChild?: boolean; }; /** * @description 将树平铺为数组 * @param { object } tree 数据 * @param { String } children 树形结构关联的属性 */ declare function getTreeMap({ tree, children, hasChild, }: getTreeMapProps): any[]; interface ArrayToTreeProps { tree: any[]; nodeKey?: string; parentKey?: string; children?: string; } /** * @description 将数组变成tree非递归 * @param {*} arr * @param {*} nodeKey 节点标识 * @param {*} parentKey 父节点标识 * @param {*} children 子节点属性 * @returns */ declare function arrayToTree({ tree, nodeKey, parentKey, children, }: ArrayToTreeProps): any[]; export interface GetNodePathProps { tree: any[]; key: string | number; nodeKey?: string; children?: string; resultKey?: string; } /** * @description 查找节点在树中的路径 * @param {*} tree 树的数据 * @param {*} id 查找的id * @param {*} nodeKey 节点标识符 * @param {*} children 子节点标识 * @returns */ declare const getNodePath: ({ tree, key, nodeKey, children, }: GetNodePathProps) => any[]; export interface FuzzyQueryTreeProps { tree: any[]; value: any; valueKey: string; children?: string; } /** * @description 模糊匹配树 * @param {*} arr 树数据 * @param {*} value 匹配的数据 * @param {*} nameKey 查询的属性 * @param {*} children 子节点属性 * @returns */ declare const fuzzyQueryTree: ({ tree, value, valueKey, children, }: FuzzyQueryTreeProps) => any[]; export interface ExactMatchTreeProps { tree: any[]; value: any; valueKey?: string; children?: string; } /** * @description 精确匹配树 * @param {*} tree 树数据 * @param {*} value 匹配的数据 * @param {*} nameKey 查询的属性 * @param {*} children 子节点属性 */ declare function exactMatchTree({ tree, value, valueKey, children, }: ExactMatchTreeProps): TreeNode | null; export interface TraverseTreeNodesProps { tree: any[]; callback: (node: any) => void; children?: string; } /** * @description 对树节点的属性进行操作 * @param {Array} tree 树节点数据 * @param { Function } callBack 回调函数 * @param { string } children 子节点 * @returns */ declare const traverseTreeNodes: ({ tree, callback, children, }: TraverseTreeNodesProps) => any[]; export interface FilterTreeProps { tree: any; filterFn: (node: any) => boolean; children?: string; } /** * @description 筛选树并返回新树 * @param tree * @param filterFn * @param children * @returns */ export declare function filterTree({ tree, filterFn, children, }: FilterTreeProps): any; /** * @description 递归遍历树 * @param {Array} tree 树节点数据 * @param { Function } callBack 回调函数 * @param { string } children 子节点 * @returns */ declare const traversalTree: (tree: any[], callback: (node: any) => void, children?: string) => any[]; /** * @description 删除树的空节点 * @param {*} tree 数据 * @param {*} children children = children * @returns */ declare function removeEmptyTreeNode(tree: any, children?: string): any; /** * @description 获取所有的叶子节点 * @param {*} tree * @param {*} children * @returns */ declare const getTreeLeaf: (tree: TreeNode[], children?: string) => TreeNode[]; export { getTreeMap, getNodePath, fuzzyQueryTree, traverseTreeNodes, removeEmptyTreeNode, getTreeLeaf, arrayToTree, traversalTree, exactMatchTree, };