@swiss-ai-hub/web 0.291.4 → 0.291.6

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.
@@ -25,28 +25,26 @@ export interface CategorizedElements {
25
25
  export type FormElement = Record<string, unknown>
26
26
 
27
27
  /**
28
- * Gets a nested value from an object using a dot-separated path.
29
- * Creates intermediate objects if they don't exist.
28
+ * Reads a nested array from an object using a dot-separated path. Pure read: never
29
+ * mutates `obj` (it is called from a render-time `:model-value` getter, where a write
30
+ * into reactive form data would trigger a recursive render loop). Returns an empty array
31
+ * when any path segment is missing or the value is not an array.
30
32
  */
31
33
  export function getNestedValue(
32
34
  obj: Record<string, unknown>,
33
35
  path: string,
34
36
  ): Record<string, unknown>[] {
35
37
  const parts = path.split('.')
36
- let current: Record<string, unknown> = obj
38
+ let current: unknown = obj
37
39
 
38
40
  for (let i = 0; i < parts.length - 1; i++) {
39
- const key = parts[i]
40
- current[key] ??= {}
41
- current = current[key] as Record<string, unknown>
42
- }
43
-
44
- const lastKey = parts[parts.length - 1]
45
- if (!Array.isArray(current[lastKey])) {
46
- current[lastKey] = []
41
+ if (!current || typeof current !== 'object') return []
42
+ current = (current as Record<string, unknown>)[parts[i]]
47
43
  }
48
44
 
49
- return current[lastKey] as Record<string, unknown>[]
45
+ if (!current || typeof current !== 'object') return []
46
+ const value = (current as Record<string, unknown>)[parts.at(-1)!]
47
+ return Array.isArray(value) ? value as Record<string, unknown>[] : []
50
48
  }
51
49
 
52
50
  /**
@@ -642,12 +640,19 @@ export function seedFormDefaults(
642
640
  : {}
643
641
  result[name] = seedFormDefaults(groupValue, children)
644
642
  }
645
- else if (formkitType === 'repeater' && Array.isArray(value)) {
646
- result[name] = value.map(item =>
647
- item && typeof item === 'object' && !Array.isArray(item)
648
- ? seedFormDefaults(item as Record<string, unknown>, children)
649
- : item,
650
- )
643
+ else if (formkitType === 'repeater') {
644
+ if (Array.isArray(value)) {
645
+ result[name] = value.map(item =>
646
+ item && typeof item === 'object' && !Array.isArray(item)
647
+ ? seedFormDefaults(item as Record<string, unknown>, children)
648
+ : item,
649
+ )
650
+ }
651
+ // Materialise an empty array for untouched repeaters here (load time) rather
652
+ // than lazily inside the render-time `:model-value` getter, which must stay pure.
653
+ else if (value === undefined) {
654
+ result[name] = []
655
+ }
651
656
  }
652
657
  else if (!(name in result) && element.value !== undefined) {
653
658
  result[name] = element.value
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "license": "AGPL-3.0-or-later",
4
4
  "author": "bbv Software Services AG (https://www.bbv.ch)",
5
5
  "type": "module",
6
- "version": "0.291.4",
6
+ "version": "0.291.6",
7
7
  "description": "Swiss AI Hub - Admin & Management UI (Nuxt 3 layer)",
8
8
  "main": "./nuxt.config.ts",
9
9
  "repository": {