a2bei4-utils 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/types/tree.d.ts CHANGED
@@ -25,6 +25,18 @@ declare function flatCompleteTree2NestedTree<T>(nodes: T[], parentId?: number |
25
25
  parentKey?: string | undefined;
26
26
  childrenKey?: string | undefined;
27
27
  }): (T & { [k in typeof childrenKey]: T[]; })[];
28
+ /**
29
+ * 在嵌套树中按 `id` 递归查找节点,并返回其指定属性值。
30
+ *
31
+ * @template T extends Record<PropertyKey, any>
32
+ * @param {string | number} id - 要查找的 id
33
+ * @param {T[]} arr - 嵌套树森林
34
+ * @param {string} [resultKey='name'] - 需要返回的字段
35
+ * @param {string} [idKey='id'] - 主键字段
36
+ * @param {string} [childrenKey='children'] - 子节点字段
37
+ * @returns {any} 找到的值;未找到返回 `undefined`
38
+ */
39
+ declare function findObjAttrValueById<T>(id: string | number, arr: T[], resultKey?: string, idKey?: string, childrenKey?: string): any;
28
40
  /**
29
41
  * 从服务端返回的已选 id 数组里,提取出
30
42
  * 1. 叶子节点
@@ -41,6 +53,6 @@ declare function extractFullyCheckedKeys(treeData: any[], selectedKeys: any[], i
41
53
  checked: string[];
42
54
  halfChecked: string[];
43
55
  };
44
- declare function findObjAttrValueById<T>(id: string | number, arr: T[], resultKey?: string, idKey?: string, childrenKey?: string): any;
56
+ declare function findTreeNodeById<T>(id: string | number, arr: T[], idKey?: string, childrenKey?: string): any;
45
57
 
46
- export { extractFullyCheckedKeys, findObjAttrValueById, flatCompleteTree2NestedTree, nestedTree2IdMap };
58
+ export { extractFullyCheckedKeys, findObjAttrValueById, findTreeNodeById, flatCompleteTree2NestedTree, nestedTree2IdMap };