|
1 | | -/* -------------------------------------------------------------------------- */ |
2 | | -/* Imports */ |
3 | | -/* -------------------------------------------------------------------------- */ |
4 | | - |
5 | 1 | import type { ComputedRef, Reactive } from "vue"; |
6 | 2 |
|
7 | 3 | import { v4 } from "uuid"; |
8 | 4 | import { computed, isReactive, reactive } from "vue"; |
9 | 5 |
|
10 | | -/* -------------------------------------------------------------------------- */ |
11 | | -/* Constants */ |
12 | | -/* -------------------------------------------------------------------------- */ |
13 | | - |
14 | | -const configurable = true; |
15 | | - |
16 | | -/* -------------------------------------------------------------------------- */ |
17 | | -/* Functions */ |
18 | | -/* -------------------------------------------------------------------------- */ |
19 | | - |
20 | | -function useFlatJsonTree( |
| 6 | +export default ( |
21 | 7 | tree: Reactive<Record<string, unknown>[]> | Record<string, unknown>[], |
22 | 8 | { |
23 | 9 | branch: keyBranch = "branch", |
@@ -46,7 +32,13 @@ function useFlatJsonTree( |
46 | 32 | remove: (pId: string) => null | string; |
47 | 33 | right: (pId: string) => null | string; |
48 | 34 | up: (pId: string) => void; |
49 | | -} { |
| 35 | +} => { |
| 36 | + /* -------------------------------------------------------------------------- */ |
| 37 | + /* Constants */ |
| 38 | + /* -------------------------------------------------------------------------- */ |
| 39 | + |
| 40 | + const configurable = true; |
| 41 | + |
50 | 42 | /* -------------------------------------------------------------------------- */ |
51 | 43 | /* Objects */ |
52 | 44 | /* -------------------------------------------------------------------------- */ |
@@ -118,7 +110,7 @@ function useFlatJsonTree( |
118 | 110 | } |
119 | 111 |
|
120 | 112 | /* -------------------------------------------------------------------------- */ |
121 | | - /* Constants */ |
| 113 | + /* Reactives */ |
122 | 114 | /* -------------------------------------------------------------------------- */ |
123 | 115 |
|
124 | 116 | const value: Reactive<Record<string, unknown>[]> = isReactive(tree) |
@@ -288,15 +280,11 @@ function useFlatJsonTree( |
288 | 280 | } |
289 | 281 | } |
290 | 282 |
|
| 283 | + /* -------------------------------------------------------------------------- */ |
| 284 | + /* Main */ |
291 | 285 | /* -------------------------------------------------------------------------- */ |
292 | 286 |
|
293 | 287 | return { add, down, leaves, left, remove, right, up }; |
294 | | -} |
295 | 288 |
|
296 | | -/* -------------------------------------------------------------------------- */ |
297 | | -/* Exports */ |
298 | | -/* -------------------------------------------------------------------------- */ |
299 | | - |
300 | | -export default useFlatJsonTree; |
301 | | - |
302 | | -/* -------------------------------------------------------------------------- */ |
| 289 | + /* -------------------------------------------------------------------------- */ |
| 290 | +}; |
0 commit comments