zzz-pc-view 0.0.1

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.
Files changed (71) hide show
  1. package/package.json +29 -0
  2. package/src/api/org/list +96 -0
  3. package/src/api/org/type/list +18 -0
  4. package/src/api/own +3831 -0
  5. package/src/decorators/CurdKey/CurdApi.d.ts +221 -0
  6. package/src/decorators/CurdKey/RequestUtil.d.ts +55 -0
  7. package/src/decorators/CurdKey/index.d.ts +752 -0
  8. package/src/decorators/DeclareType.d.ts +35 -0
  9. package/src/decorators/Decorators.d.ts +5 -0
  10. package/src/decorators/FilterKey/index.d.ts +283 -0
  11. package/src/decorators/Loader/index.d.ts +179 -0
  12. package/src/decorators/NameKey/index.d.ts +68 -0
  13. package/src/decorators/PrimaryKey/index.d.ts +68 -0
  14. package/src/decorators/api.d.ts +21 -0
  15. package/src/decorators/decoratorStoreUtil.d.ts +68 -0
  16. package/src/decorators/index.d.ts +6 -0
  17. package/src/decorators/loadStore.d.ts +6 -0
  18. package/src/decorators/loadUtil.d.ts +25 -0
  19. package/src/decorators/util.d.ts +27 -0
  20. package/src/favicon.ico +0 -0
  21. package/src/index-decorators.d.ts +3 -0
  22. package/src/index.d.ts +10 -0
  23. package/src/index.es.js +10035 -0
  24. package/src/index.umd.js +2 -0
  25. package/src/pcViews/components/curd/CurdTableView.vue.d.ts +18 -0
  26. package/src/pcViews/components/curd/CurdView.vue.d.ts +22 -0
  27. package/src/pcViews/components/curd/CurdViewHandler.d.ts +1208 -0
  28. package/src/pcViews/components/curd/FilterView.vue.d.ts +19 -0
  29. package/src/pcViews/components/curd/FilterViewHandler.d.ts +6 -0
  30. package/src/pcViews/components/curd/index.d.ts +2 -0
  31. package/src/pcViews/components/forms/RadioButtonGroupView.vue.d.ts +19 -0
  32. package/src/pcViews/components/forms/SelectView.vue.d.ts +19 -0
  33. package/src/pcViews/components/forms/VModelView.vue.d.ts +20 -0
  34. package/src/pcViews/components/forms/index.d.ts +3 -0
  35. package/src/pcViews/components/index.d.ts +5 -0
  36. package/src/pcViews/components/layout/DataWrapperView.vue.d.ts +23 -0
  37. package/src/pcViews/components/layout/LayoutHeader.vue.d.ts +2 -0
  38. package/src/pcViews/components/layout/LayoutMainView.vue.d.ts +2 -0
  39. package/src/pcViews/components/layout/index.d.ts +2 -0
  40. package/src/pcViews/components/slots/VSlotView.vue.d.ts +20 -0
  41. package/src/pcViews/components/slots/index.d.ts +1 -0
  42. package/src/pcViews/components/utils.d.ts +33 -0
  43. package/src/pcViews/index.d.ts +1 -0
  44. package/src/utils/Date/ZDate.d.ts +557 -0
  45. package/src/utils/DeclareType.d.ts +39 -0
  46. package/src/utils/class/bind.d.ts +43 -0
  47. package/src/utils/class/combine.d.ts +109 -0
  48. package/src/utils/crypto/index.d.ts +44 -0
  49. package/src/utils/empty/index.d.ts +18 -0
  50. package/src/utils/httpRequest/HttpRequestError.d.ts +14 -0
  51. package/src/utils/httpRequest/httpRequestCreator.d.ts +61 -0
  52. package/src/utils/httpRequest/httpRequestUtil.d.ts +24 -0
  53. package/src/utils/httpRequest/index.d.ts +3 -0
  54. package/src/utils/index.d.ts +11 -0
  55. package/src/utils/math/toFixed.d.ts +11 -0
  56. package/src/utils/math/unitConvertor.d.ts +34 -0
  57. package/src/utils/mock/HttpResponse.d.ts +30 -0
  58. package/src/utils/mock/createDataTimes.d.ts +20 -0
  59. package/src/utils/mock/index.d.ts +2 -0
  60. package/src/utils/reduce/completeByDate.d.ts +51 -0
  61. package/src/utils/reduce/index.d.ts +9 -0
  62. package/src/utils/reduce/mappingBuilder.d.ts +69 -0
  63. package/src/utils/reduce/ratio.d.ts +104 -0
  64. package/src/utils/reduce/sort.d.ts +12 -0
  65. package/src/utils/reduce/sumByGroup.d.ts +53 -0
  66. package/src/utils/reduce/toGroup.d.ts +79 -0
  67. package/src/utils/reduce/tree.d.ts +570 -0
  68. package/src/utils/reduce/util.d.ts +14 -0
  69. package/src/utils/reduce/valueConvertor.d.ts +65 -0
  70. package/src/utils/reduce/verticalToHorizontal.d.ts +80 -0
  71. package/src/zzz-frame.css +7 -0
@@ -0,0 +1,53 @@
1
+ import { KeyMatch, KeyValType } from '../DeclareType';
2
+ /**
3
+ * 定义一个函数 `verticalSumByGroup`,它接受一个包含以下属性的对象作为参数:
4
+ * - `list`: 原始数据数组,类型为 `T[]`。
5
+ * - `dataKeys`: 一个包含三个元素的数组,分别表示基础维度键、值维度键和值键,类型为 `[KeyMatch<T, KeyValType>, KeyMatch<T, KeyValType>, KeyMatch<T, number>]`。
6
+ * - `groupMap`: 一个记录对象,用于将值维度键映射到分组对象,类型为 `Record<KeyValType, U>`。
7
+ * - `groupKeys`: 一个包含两个元素的数组,分别表示分组键和小数位数键,类型为 `[KeyMatch<U, KeyValType>, KeyMatch<U, number | undefined | null>?]`。
8
+ * - `formatter`: 一个可选的格式化函数,用于在计算总和后对数据进行格式化,类型为 `(sumData: T, calcItems: T[]) => void`。
9
+ * - `enableFourRoundSix`: 一个可选的布尔值,用于指定是否启用四舍六入五成双规则,类型为 `boolean`,默认值为 `true`。
10
+ * 这个函数通常用于根据指定的分组键对数据进行分组,并计算每个分组的总和。
11
+ *
12
+ * @param option - 包含计算总和所需的所有参数的对象。
13
+ * @returns 一个包含原始数据和计算得到的总和的数组,类型为 `T[]`。
14
+ *
15
+ * @example
16
+ verticalSumByGroup({
17
+ list: [
18
+ { dataTime: '2000/01/01 00:00:00', factorId: '1001', value: 8 },
19
+ { dataTime: '2000/01/01 00:00:00', factorId: '1002', value: 1.9368984375 },
20
+ { dataTime: '2000/01/02 00:00:00', factorId: '1001', value: 4 },
21
+ { dataTime: '2000/01/02 00:00:00', factorId: '1002', value: 7.171923084374999 }
22
+ ],
23
+ dataKeys: [ 'dataTime', 'factorId', 'value' ],
24
+ groupMap: {
25
+ '1001': {
26
+ id: '1000',
27
+ digits: 2
28
+ },
29
+ '1002': {
30
+ id: '1000',
31
+ digits: 2
32
+ }
33
+ },
34
+ groupKeys: ['id', 'digits']
35
+ })
36
+ * // 输出
37
+ [
38
+ { dataTime: '2000/01/01 00:00:00', factorId: '1001', value: 8 },
39
+ { dataTime: '2000/01/01 00:00:00', factorId: '1002', value: 1.9368984375 },
40
+ { dataTime: '2000/01/01 00:00:00', factorId: '1000', value: 9.94 },
41
+ { dataTime: '2000/01/02 00:00:00', factorId: '1001', value: 4 },
42
+ { dataTime: '2000/01/02 00:00:00', factorId: '1002', value: 7.171923084374999 },
43
+ { dataTime: '2000/01/02 00:00:00', factorId: '1000', value: 11.17 },
44
+ ]
45
+ */
46
+ export declare const verticalSumByGroup: <T, U>(option: {
47
+ list: T[];
48
+ dataKeys: [KeyMatch<T, KeyValType>, KeyMatch<T, KeyValType>, KeyMatch<T, number>];
49
+ groupMap: Record<KeyValType, U>;
50
+ groupKeys: [KeyMatch<U, KeyValType>, KeyMatch<U, number | undefined | null>?];
51
+ formatter?: (sumData: T, calcItems: T[]) => void;
52
+ enableFourRoundSix?: boolean;
53
+ }) => T[];
@@ -0,0 +1,79 @@
1
+ import { KeyMatch } from '../DeclareType';
2
+ /**
3
+ * 根据 `U` 和 `K` 的类型,生成一个交集类型。
4
+ *
5
+ * @template U - 输入的对象类型。
6
+ * @template K - 键的类型,可以是单个键、键数组或键元组。
7
+ * @returns 生成的交集类型。
8
+ */
9
+ type IntersectionOf<U, K> = K extends [keyof U, PropertyKey] ? {
10
+ [k in K[1]]: U[K[0]];
11
+ } : K extends keyof U ? {
12
+ [k in K]: U[K];
13
+ } : K extends [infer FirstKey, ...infer Intermediate] ? IntersectionOf<U, FirstKey> & IntersectionOf<U, Intermediate> : unknown;
14
+ /**
15
+ * 垂直分组映射响应的类型定义。
16
+ *
17
+ * @template T - 输入的对象类型。
18
+ * @template P - 分组键的类型。
19
+ * @template U - 映射对象的类型。
20
+ * @template K - 映射数据键的类型。
21
+ * @returns 垂直分组映射响应的类型。
22
+ */
23
+ type VerticalToGroupByMapResponse<T, P extends PropertyKey, U, K> = {
24
+ [k in P]: T[];
25
+ } & IntersectionOf<U, K>;
26
+ /**
27
+ * 根据指定的键将数组中的对象垂直分组,并映射到另一个对象。
28
+ *
29
+ * @template T - 输入的对象类型。
30
+ * @template P - 分组键的类型。
31
+ * @template U - 映射对象的类型。
32
+ * @template K - 映射数据键的类型。
33
+ * @param {T[]} list - 要分组的对象数组。
34
+ * @param {P} groupKey - 用于分组的键。
35
+ * @param {KeyMatch<T, PropertyKey>} dataGroupKey - 用于匹配分组键的对象键。
36
+ * @param {Record<PropertyKey, U>} map - 映射对象。
37
+ * @param {K} mapDataKeys - 映射数据键的数组。
38
+ * @returns {VerticalToGroupByMapResponse<T, P, U, K>[]} 分组和映射后的对象数组。
39
+ *
40
+ * @example
41
+ verticalByMap(
42
+ [
43
+ { factorId: '1001', value: 3},
44
+ { factorId: '1001', value: 8},
45
+ { factorId: '1002', value: 2.208140625},
46
+ { factorId: '1002', value: 2.941640625}
47
+ ],
48
+ 'list',
49
+ 'factorId',
50
+ {
51
+ '1001': { id: '1001', 'name': 'SO₂', defaultUnit: 'μg/m³' },
52
+ '1002': { id: '1002', 'name': 'NO', defaultUnit: 'μg/m³' },
53
+ },
54
+ ['id', 'name', ['defaultUnit', 'unit']] as const
55
+ )
56
+ * // 输出
57
+ [
58
+ {
59
+ id: '1001',
60
+ name: 'SO₂',
61
+ unit: 'μg/m³',
62
+ list: [
63
+ { factorId: '1001', value: 3},
64
+ { factorId: '1001', value: 8}
65
+ ]
66
+ },
67
+ {
68
+ id: '1002',
69
+ name: 'NO',
70
+ unit: 'μg/m³',
71
+ list: [
72
+ { factorId: '1002', value: 2.208140625},
73
+ { factorId: '1002', value: 2.941640625}
74
+ ]
75
+ }
76
+ ]
77
+ */
78
+ export declare const verticalByMap: <T, P extends PropertyKey, U, K extends ([keyof U, PropertyKey] | keyof U)[]>(list: T[], groupKey: P, dataGroupKey: KeyMatch<T, PropertyKey>, map: Record<PropertyKey, U>, mapDataKeys: K) => VerticalToGroupByMapResponse<T, P, U, K>[];
79
+ export {};
@@ -0,0 +1,570 @@
1
+ import { KeyMatch, KeyValType } from '../DeclareType';
2
+ /**
3
+ * 定义树节点的接口
4
+ * @template T 树节点中数据的类型
5
+ */
6
+ interface TreeNode<T> {
7
+ id: KeyValType;
8
+ name: string;
9
+ parentId: KeyValType | undefined | null;
10
+ isLeaf: boolean;
11
+ children?: this[];
12
+ data: T;
13
+ [K: PropertyKey]: any;
14
+ }
15
+ /**
16
+ * 将一个扁平的列表转换为树形结构
17
+ * @template T 列表中元素的类型
18
+ * @param {Object} option - 转换选项
19
+ * @param {T[]} option.list - 要转换的列表
20
+ * @param {KeyMatch<T, KeyValType>} option.idKey - 用于获取元素唯一标识的键匹配函数
21
+ * @param {KeyMatch<T, string>} option.nameKey - 用于获取元素名称的键匹配函数
22
+ * @param {KeyMatch<T, KeyValType | null | undefined>} option.parentKey - 用于获取元素父节点唯一标识的键匹配函数
23
+ * @param {KeyMatch<T, boolean | undefined>} [option.leafKey] - 用于判断元素是否为叶子节点的键匹配函数,可选
24
+ * @param {KeyMatch<T, number>} [option.sortKey] - 用于排序元素的键匹配函数,可选
25
+ * @param {(treeNode: TreeNode<T>, data: T, parentTreeNode?: TreeNode<T>, parentData?: T) => void} [option.formatter] - 用于格式化树节点的函数,可选
26
+ * @returns {TreeNode<T>[]} 转换后的树形结构
27
+ *
28
+ * @example
29
+ crate({
30
+ list: [
31
+ {
32
+ id: '1-1-1',
33
+ name: '1-1-1',
34
+ parentId: '1-1',
35
+ sortNo: 3,
36
+ isLeaf: true,
37
+ },
38
+ {
39
+ id: '1-1-2',
40
+ name: '1-1-2',
41
+ parentId: '1-1',
42
+ sortNo: 2,
43
+ isLeaf: true,
44
+ },
45
+ {
46
+ id: '2',
47
+ name: '2',
48
+ sortNo: 2,
49
+ isLeaf: false,
50
+ },
51
+ {
52
+ id: '2-1',
53
+ name: '2-1',
54
+ parentId: '2',
55
+ sortNo: 2,
56
+ isLeaf: false,
57
+ },
58
+ {
59
+ id: '3',
60
+ name: '3',
61
+ sortNo: 3,
62
+ isLeaf: true,
63
+ },
64
+ {
65
+ id: '1',
66
+ name: '1',
67
+ sortNo: 1,
68
+ isLeaf: false,
69
+ },
70
+ {
71
+ id: '1-1',
72
+ name: '1-1',
73
+ parentId: '1',
74
+ sortNo: 1,
75
+ isLeaf: false,
76
+ },
77
+ ],
78
+ idKey: 'id',
79
+ nameKey: 'name',
80
+ parentKey: 'parentId',
81
+ sortKey: 'sortNo',
82
+ leafKey: 'isLeaf',
83
+ formatter: (node, data, parentNode) => {
84
+ node.path = `${parentNode?.path || ''}/${node.id}`
85
+ },
86
+ })
87
+
88
+ // 输出:
89
+ [
90
+ {
91
+ "id": "1",
92
+ "name": "1",
93
+ "data": {
94
+ "id": "1",
95
+ "name": "1",
96
+ "sortNo": 1,
97
+ "isLeaf": false
98
+ },
99
+ "isLeaf": false,
100
+ "children": [
101
+ {
102
+ "id": "1-1",
103
+ "name": "1-1",
104
+ "parentId": "1",
105
+ "data": {
106
+ "id": "1-1",
107
+ "name": "1-1",
108
+ "parentId": "1",
109
+ "sortNo": 1,
110
+ "isLeaf": false
111
+ },
112
+ "isLeaf": false,
113
+ "children": [
114
+ {
115
+ "id": "1-1-2",
116
+ "name": "1-1-2",
117
+ "parentId": "1-1",
118
+ "data": {
119
+ "id": "1-1-2",
120
+ "name": "1-1-2",
121
+ "parentId": "1-1",
122
+ "sortNo": 2,
123
+ "isLeaf": true
124
+ },
125
+ "isLeaf": true,
126
+ "path": "/1/1-1/1-1-2"
127
+ },
128
+ {
129
+ "id": "1-1-1",
130
+ "name": "1-1-1",
131
+ "parentId": "1-1",
132
+ "data": {
133
+ "id": "1-1-1",
134
+ "name": "1-1-1",
135
+ "parentId": "1-1",
136
+ "sortNo": 3,
137
+ "isLeaf": true
138
+ },
139
+ "isLeaf": true,
140
+ "path": "/1/1-1/1-1-1"
141
+ }
142
+ ],
143
+ "path": "/1/1-1"
144
+ }
145
+ ],
146
+ "path": "/1"
147
+ },
148
+ {
149
+ "id": "3",
150
+ "name": "3",
151
+ "data": {
152
+ "id": "3",
153
+ "name": "3",
154
+ "sortNo": 3,
155
+ "isLeaf": true
156
+ },
157
+ "isLeaf": true,
158
+ "path": "/3"
159
+ }
160
+ ]
161
+ */
162
+ export declare const create: <T>(option: {
163
+ list: T[];
164
+ idKey: KeyMatch<T, KeyValType>;
165
+ nameKey: KeyMatch<T, string>;
166
+ parentKey: KeyMatch<T, KeyValType | null | undefined>;
167
+ leafKey?: KeyMatch<T, boolean | undefined>;
168
+ sortKey?: KeyMatch<T, number>;
169
+ formatter?: (treeNode: TreeNode<T>, data: T, parentTreeNode?: TreeNode<T>, parentData?: T) => void;
170
+ }) => TreeNode<T>[];
171
+ /**
172
+ * 根据指定的主键、父键和子键创建树形结构。
173
+ * @template T - 树节点的数据类型。
174
+ * @param {T[]} list - 包含树节点的数组。
175
+ * @param {KeyMatch<T, PropertyKey>} primaryKey - 用于获取节点唯一标识的键匹配函数。
176
+ * @param {KeyMatch<T, PropertyKey | undefined | null>} parentIdKey - 用于获取节点父节点唯一标识的键匹配函数。
177
+ * @param {KeyMatch<T, undefined | T[]>} childrenKey - 用于获取节点子节点的键匹配函数。
178
+ * @param {KeyMatch<T, undefined | number>} [sortKey] - 用于排序节点的键匹配函数。
179
+ * @returns {T[]} 返回创建的树形结构的根节点数组。
180
+ */
181
+ export declare const createBySelf: <T>(list: T[], primaryKey: KeyMatch<T, PropertyKey>, parentIdKey: KeyMatch<T, undefined | null | PropertyKey>, childrenKey: KeyMatch<T, undefined | T[]>, sortKey?: KeyMatch<T, undefined | number>) => T[];
182
+ /**
183
+ * 对树形结构的节点进行排序。
184
+ * @template T 树节点的数据类型。
185
+ * @param {T[]} nodes 要排序的节点列表。
186
+ * @param {KeyMatch<T, undefined | T[]>} childrenKey 用于获取节点子节点的键匹配函数。
187
+ * @param {KeyMatch<T, undefined | number>} sortKey 用于排序的键匹配函数。
188
+ * @returns {T[]} 返回排序后的节点列表。
189
+ *
190
+ * @example
191
+ const nodes = [
192
+ {
193
+ id: '1',
194
+ children: [
195
+ { id: '1-1', sortNo: 2 },
196
+ { id: '1-2', sortNo: 1 }
197
+ ]
198
+ },
199
+ {
200
+ id: '2',
201
+ children: [
202
+ { id: '2-1', sortNo: 3 },
203
+ { id: '2-2', sortNo: 4 }
204
+ ]
205
+ }
206
+ ]
207
+ sortTree(nodes, 'children', 'sortNo')
208
+ * // 输出
209
+ [
210
+ {
211
+ id: '1',
212
+ children: [
213
+ { id: '1-2', sortNo: 1 },
214
+ { id: '1-1', sortNo: 2 }
215
+ ]
216
+ },
217
+ {
218
+ id: '2',
219
+ children: [
220
+ { id: '2-1', sortNo: 3 },
221
+ { id: '2-2', sortNo: 4 }
222
+ ]
223
+ }
224
+ ]
225
+ */
226
+ export declare const sortTree: <T>(nodes: T[], childrenKey: KeyMatch<T, undefined | T[]>, sortKey: KeyMatch<T, undefined | number>) => T[];
227
+ /**
228
+ * 将嵌套的树形结构数据展平为一维数组。
229
+ * @template T 树节点的数据类型。
230
+ * @param {T[]} list 包含树节点的数组。
231
+ * @param {KeyMatch<T, T[] | undefined>} childrenKey 用于获取节点子节点的键匹配函数。
232
+ * @returns {T[]} 返回展平后的一维数组。
233
+ *
234
+ * @example
235
+ toFlat(
236
+ [
237
+ {
238
+ id: '1',
239
+ name: 'Node 1',
240
+ children: [
241
+ {
242
+ id: '1-1',
243
+ name: 'Node 1-1',
244
+ children: [
245
+ { id: '1-1-1', name: 'Node 1-1-1' },
246
+ { id: '1-1-2', name: 'Node 1-1-2' },
247
+ ],
248
+ },
249
+ {
250
+ id: '1-2',
251
+ name: 'Node 1-2',
252
+ },
253
+ ],
254
+ },
255
+ {
256
+ id: '2',
257
+ name: 'Node 2',
258
+ children: [
259
+ { id: '2-1', name: 'Node 2-1' },
260
+ { id: '2-2', name: 'Node 2-2' },
261
+ ],
262
+ },
263
+ ],
264
+ 'children'
265
+ )
266
+
267
+ // 输出:
268
+ [
269
+ {
270
+ "id": "1",
271
+ "name": "Node 1",
272
+ "children": [
273
+ {
274
+ "id": "1-1",
275
+ "name": "Node 1-1",
276
+ "children": [
277
+ { "id": "1-1-1", "name": "Node 1-1-1" },
278
+ { "id": "1-1-2", "name": "Node 1-1-2" }
279
+ ]
280
+ },
281
+ { "id": "1-2", "name": "Node 1-2" }
282
+ ]
283
+ },
284
+ {
285
+ "id": "1-1",
286
+ "name": "Node 1-1",
287
+ "children": [
288
+ { "id": "1-1-1", "name": "Node 1-1-1" },
289
+ { "id": "1-1-2", "name": "Node 1-1-2" }
290
+ ]
291
+ },
292
+ { "id": "1-1-1", "name": "Node 1-1-1" },
293
+ { "id": "1-1-2", "name": "Node 1-1-2" },
294
+ { "id": "1-2", "name": "Node 1-2" },
295
+ {
296
+ "id": "2",
297
+ "name": "Node 2",
298
+ "children": [
299
+ { "id": "2-1", "name": "Node 2-1" },
300
+ { "id": "2-2", "name": "Node 2-2" }
301
+ ]
302
+ },
303
+ { "id": "2-1", "name": "Node 2-1" },
304
+ { "id": "2-2", "name": "Node 2-2" }
305
+ ]
306
+ */
307
+ export declare const toFlat: <T>(list: T[], childrenKey: KeyMatch<T, T[] | undefined>) => T[];
308
+ /**
309
+ * 在给定的列表中查找第一个叶子节点。
310
+ * @template T 树节点的数据类型。
311
+ * @param {T[]} list 要搜索的节点列表。
312
+ * @param {KeyMatch<T, T[] | undefined>} childrenKey 用于获取节点子节点的键匹配函数。
313
+ * @param {KeyMatch<T, boolean | undefined> | ((node: T) => boolean)} [leafNodeFilter] 用于判断节点是否为叶子节点的键匹配函数或自定义函数,可选。
314
+ * @returns {T | null} 返回找到的第一个叶子节点,如果没有找到则返回 null。
315
+ *
316
+ * @example
317
+ findLeafNode(
318
+ [
319
+ {
320
+ id: '1',
321
+ isLeaf: false,
322
+ children: [
323
+ {
324
+ id: '1-1',
325
+ isLeaf: false,
326
+ children: [
327
+ {
328
+ id: '1-1-1',
329
+ isLeaf: true
330
+ }
331
+ ]
332
+ }
333
+ ]
334
+ },
335
+ {
336
+ id: '2',
337
+ isLeaf: false,
338
+ children: [
339
+ {
340
+ id: '2-1',
341
+ isLeaf: true
342
+ }
343
+ ]
344
+ },
345
+ {
346
+ id: '3',
347
+ isLeaf: false
348
+ }
349
+ ],
350
+ 'children'
351
+ )
352
+ * // 输出 { id: '1-1-1', isLeaf: true }
353
+
354
+ * @example
355
+ findLeafNode(
356
+ [
357
+ {
358
+ id: '1',
359
+ isLeaf: false,
360
+ children: [
361
+ {
362
+ id: '1-1',
363
+ isLeaf: false,
364
+ children: [
365
+ {
366
+ id: '1-1-1',
367
+ isLeaf: true
368
+ }
369
+ ]
370
+ }
371
+ ]
372
+ },
373
+ {
374
+ id: '2',
375
+ isLeaf: false,
376
+ children: [
377
+ {
378
+ id: '2-1',
379
+ isLeaf: true
380
+ }
381
+ ]
382
+ },
383
+ {
384
+ id: '3',
385
+ isLeaf: false
386
+ }
387
+ ],
388
+ 'children',
389
+ 'isLeaf'
390
+ )
391
+ * // 输出 { id: '1-1-1', isLeaf: true }
392
+
393
+ * @example
394
+ findLeafNode(
395
+ [
396
+ {
397
+ id: '1',
398
+ isLeaf: false,
399
+ children: [
400
+ {
401
+ id: '1-1',
402
+ isLeaf: false,
403
+ children: [
404
+ {
405
+ id: '1-1-1',
406
+ isLeaf: true
407
+ }
408
+ ]
409
+ }
410
+ ]
411
+ },
412
+ {
413
+ id: '2',
414
+ isLeaf: false,
415
+ children: [
416
+ {
417
+ id: '2-1',
418
+ isLeaf: true
419
+ }
420
+ ]
421
+ },
422
+ {
423
+ id: '3',
424
+ isLeaf: false
425
+ }
426
+ ],
427
+ 'children',
428
+ (node) => node.id === '2-1'
429
+ )
430
+ * // 输出 { id: '2-1', isLeaf: true }
431
+ */
432
+ export declare const findLeafNode: <T>(list: T[], childrenKey: KeyMatch<T, T[] | undefined>, leafNodeFilter?: KeyMatch<T, boolean | undefined> | ((node: T) => boolean)) => T | null;
433
+ /**
434
+ * 在给定的列表中查找所有叶子节点。
435
+ * @template T 树节点的数据类型。
436
+ * @param {T[]} list 要搜索的节点列表。
437
+ * @param {KeyMatch<T, T[] | undefined>} childrenKey 用于获取节点子节点的键匹配函数。
438
+ * @param {KeyMatch<T, boolean | undefined> | ((node: T) => boolean)} [leafNodeFilter] 用于判断节点是否为叶子节点的键匹配函数或自定义函数,可选。
439
+ * @returns {T[]} 返回找到的所有叶子节点的数组。
440
+ *
441
+ * @example
442
+ findAllLeafNodes(
443
+ [
444
+ {
445
+ id: '1',
446
+ isLeaf: false,
447
+ children: [
448
+ {
449
+ id: '1-1',
450
+ isLeaf: false,
451
+ children: [
452
+ {
453
+ id: '1-1-1',
454
+ isLeaf: true
455
+ }
456
+ ]
457
+ }
458
+ ]
459
+ },
460
+ {
461
+ id: '2',
462
+ isLeaf: false,
463
+ children: [
464
+ {
465
+ id: '2-1',
466
+ isLeaf: true
467
+ }
468
+ ]
469
+ },
470
+ {
471
+ id: '3',
472
+ isLeaf: false
473
+ }
474
+ ],
475
+ 'children'
476
+ )
477
+ * // 输出
478
+ [
479
+ { id: '1-1-1', isLeaf: true },
480
+ { id: '2-1', isLeaf: true },
481
+ { id: '3', isLeaf: false }
482
+ ]
483
+
484
+ * @example
485
+ findAllLeafNodes(
486
+ [
487
+ {
488
+ id: '1',
489
+ isLeaf: false,
490
+ children: [
491
+ {
492
+ id: '1-1',
493
+ isLeaf: false,
494
+ children: [
495
+ {
496
+ id: '1-1-1',
497
+ isLeaf: true
498
+ }
499
+ ]
500
+ }
501
+ ]
502
+ },
503
+ {
504
+ id: '2',
505
+ isLeaf: false,
506
+ children: [
507
+ {
508
+ id: '2-1',
509
+ isLeaf: true
510
+ }
511
+ ]
512
+ },
513
+ {
514
+ id: '3',
515
+ isLeaf: false
516
+ }
517
+ ],
518
+ 'children',
519
+ 'isLeaf'
520
+ )
521
+ * // 输出
522
+ [
523
+ { id: '1-1-1', isLeaf: true },
524
+ { id: '2-1', isLeaf: true }
525
+ ]
526
+
527
+ * @example
528
+ findAllLeafNodes(
529
+ [
530
+ {
531
+ id: '1',
532
+ isLeaf: false,
533
+ children: [
534
+ {
535
+ id: '1-1',
536
+ isLeaf: false,
537
+ children: [
538
+ {
539
+ id: '1-1-1',
540
+ isLeaf: true
541
+ }
542
+ ]
543
+ }
544
+ ]
545
+ },
546
+ {
547
+ id: '2',
548
+ isLeaf: false,
549
+ children: [
550
+ {
551
+ id: '2-1',
552
+ isLeaf: true
553
+ }
554
+ ]
555
+ },
556
+ {
557
+ id: '3',
558
+ isLeaf: false
559
+ }
560
+ ],
561
+ 'children',
562
+ (node) => node.id === '1-1-1'
563
+ )
564
+ * // 输出
565
+ [
566
+ { id: '1-1-1', isLeaf: true }
567
+ ]
568
+ */
569
+ export declare const findAllLeafNodes: <T>(list: T[], childrenKey: KeyMatch<T, T[] | undefined>, leafNodeFilter?: KeyMatch<T, boolean | undefined> | ((node: T) => boolean)) => T[];
570
+ export {};