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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bfg-common",
3
3
  "private": false,
4
- "version": "1.5.2",
4
+ "version": "1.5.4",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",
@@ -29,35 +29,37 @@ export default defineNuxtPlugin(() => {
29
29
  return result
30
30
  }
31
31
  self.findAndExpandPathToNode = function (
32
- nodes: any[],
33
- targetValue: any,
34
- valueProp: string,
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 nodes) {
39
+ for (const node of arr) {
39
40
  const newPath = [...path, node]
40
41
 
41
- // Раскрываем узел
42
- node.nodesShow = true
43
-
44
- if (node[valueProp] === targetValue) {
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
- targetValue,
52
- valueProp,
52
+ values,
53
+ valueProps,
53
54
  itemsProp,
55
+ expandProp,
54
56
  newPath
55
57
  )
56
- if (found) return 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
  }