bfg-common 1.5.2 → 1.5.4
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/package.json +1 -1
- package/plugins/recursion.ts +16 -14
package/package.json
CHANGED
package/plugins/recursion.ts
CHANGED
|
@@ -29,35 +29,37 @@ export default defineNuxtPlugin(() => {
|
|
|
29
29
|
return result
|
|
30
30
|
}
|
|
31
31
|
self.findAndExpandPathToNode = function (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
arr: any[],
|
|
33
|
+
values: any[],
|
|
34
|
+
valueProps: string[],
|
|
35
35
|
itemsProp: string,
|
|
36
|
+
expandProp: string = 'nodesShow',
|
|
36
37
|
path: any[] = []
|
|
37
38
|
): any[] | null {
|
|
38
|
-
for (const node of
|
|
39
|
+
for (const node of arr) {
|
|
39
40
|
const newPath = [...path, node]
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (
|
|
42
|
+
const isMatch = values.every(
|
|
43
|
+
(val, index) => node[valueProps[index]] === val
|
|
44
|
+
)
|
|
45
|
+
if (isMatch) {
|
|
45
46
|
return newPath
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
if (node[itemsProp]?.length) {
|
|
49
50
|
const found = self.findAndExpandPathToNode(
|
|
50
51
|
node[itemsProp],
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
values,
|
|
53
|
+
valueProps,
|
|
53
54
|
itemsProp,
|
|
55
|
+
expandProp,
|
|
54
56
|
newPath
|
|
55
57
|
)
|
|
56
|
-
if (found)
|
|
58
|
+
if (found) {
|
|
59
|
+
node[expandProp] = true // раскрываем только тех, кто участвует в пути
|
|
60
|
+
return found
|
|
61
|
+
}
|
|
57
62
|
}
|
|
58
|
-
|
|
59
|
-
// Если не найден — скрываем обратно
|
|
60
|
-
node.nodesShow = false
|
|
61
63
|
}
|
|
62
64
|
return null
|
|
63
65
|
}
|