mountain-ui 1.0.12 → 1.0.14

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": "mountain-ui",
3
3
  "private": false,
4
- "version": "1.0.12",
4
+ "version": "1.0.14",
5
5
  "description": "A comprehensive UI component library for ERP systems with field types, entities, and registry management built with Svelte",
6
6
  "type": "module",
7
7
  "module": "index.js",
@@ -3,6 +3,7 @@
3
3
  import { entityRegistry } from '../../../entityRegistry/registry.svelte.js';
4
4
  import { Button, IconButton, ResponsiveTable } from 'hamzus-ui';
5
5
  import Label from '../../components/Label.svelte';
6
+ import { onMount } from 'svelte';
6
7
 
7
8
  let {
8
9
  value = $bindable(null),
@@ -18,15 +19,35 @@
18
19
  ...props
19
20
  } = $props();
20
21
 
21
- function createLine() {
22
+
23
+ let table = $state([createLine()]);
24
+
25
+ onMount(()=>{
26
+ if (value === null) return
27
+
28
+ const decodedValue = JSON.parse(value)
29
+
30
+ let newLines = []
31
+
32
+ for (const line of decodedValue) {
33
+ const lineId = line.id
34
+ delete line.id
35
+ const newLine = createLine(line.id, line)
36
+ newLines.push(newLine)
37
+ }
38
+
39
+ table = [...newLines]
40
+ })
41
+
42
+ function createLine(dbId = null, line = null) {
22
43
  return {
23
44
  id: crypto.randomUUID(),
24
- ctx: {},
45
+ dbId:dbId,
46
+ ctx: line??{},
25
47
  detailsCtx: {}
26
48
  };
27
49
  }
28
50
 
29
- let table = $state([createLine()]);
30
51
 
31
52
  function handleAddLine() {
32
53
  table = [...table, createLine()];
@@ -43,7 +64,15 @@
43
64
  onChangeDetails(table);
44
65
  }
45
66
  function handleChange() {
46
- const value = JSON.stringify(table.map((line) => line.ctx));
67
+ const value = JSON.stringify(table.map((line) => {
68
+ const data = {
69
+ ...line.ctx,
70
+ }
71
+
72
+ if (line.dbId) data['id'] = line.dbId
73
+
74
+ return data
75
+ } ));
47
76
 
48
77
  onChange(value);
49
78
  }