svelte-json-schema-form 0.0.1-alpha1 → 0.0.1-alpha10

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,14 +1,16 @@
1
1
  {
2
2
  "name": "svelte-json-schema-form",
3
3
  "private": false,
4
- "version": "0.0.1-alpha1",
4
+ "version": "0.0.1-alpha10",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "check": "svelte-check --tsconfig ./tsconfig.json",
8
8
  "storybook": "storybook dev -p 6006",
9
9
  "build-storybook": "storybook build"
10
10
  },
11
- "main": "./src/exports.js",
11
+ "main": "src/exports.js",
12
+ "module": "src/exports.js",
13
+ "svelte": "src/exports.js",
12
14
  "devDependencies": {
13
15
  "@storybook/addon-essentials": "^7.6.16",
14
16
  "@storybook/addon-interactions": "^7.6.16",
@@ -31,6 +33,6 @@
31
33
  "vite": "^5.1.0"
32
34
  },
33
35
  "dependencies": {
34
- "json-form-core": "0.0.1-alpha1"
36
+ "json-form-core": "0.0.1-alpha15"
35
37
  }
36
38
  }
@@ -55,7 +55,7 @@
55
55
 
56
56
  <!-- More on args: https://storybook.js.org/docs/svelte/writing-stories/args-->
57
57
  <Story
58
- name="Primary"
58
+ name="Primary - Clone"
59
59
  args={{
60
60
  "schema": {
61
61
  "title": "Element",
@@ -87,7 +87,147 @@
87
87
  "properties": {
88
88
  "f1": {
89
89
  "title": "Array Obj Field 1",
90
+ "component": "textInput",
91
+ "automations": [
92
+ {
93
+ "condition":{
94
+ "and": {
95
+ "$[node_value]": {
96
+ "eq": "val"
97
+ }
98
+ }
99
+ },
100
+ "actions":[
101
+ {
102
+ "action":"set",
103
+ "args":[
104
+ "$[node_value]../f2",
105
+ "yyy"
106
+ ]
107
+ },
108
+ {
109
+ "action":"set",
110
+ "args":[
111
+ "$[root_value]data/title",
112
+ "xxx"
113
+ ]
114
+ }
115
+ ]
116
+ }
117
+ ]
118
+ },
119
+ "f2": {
120
+ "title": "Array Obj Field 2",
90
121
  "component": "textInput"
122
+ }
123
+ }
124
+ }
125
+ }
126
+ }
127
+ },
128
+ "value": {
129
+ "visual":[
130
+ {
131
+ "f2": "copied into the next item",
132
+ "f1": "this field will be"
133
+ }
134
+ ],
135
+ "data": {
136
+ "url": "xxxxxx"
137
+ }
138
+ },
139
+ "extras": {
140
+ "_extras": {},
141
+ "_children": {
142
+ "visual": {
143
+ "_extras": {},
144
+ "_children": [
145
+ {
146
+ "_children": {
147
+ "f1": {
148
+ "_extras": {"key": "val"}
149
+ }
150
+ }
151
+ }
152
+ ]
153
+ },
154
+ "data": {
155
+ "_extras": {},
156
+ "_children": {
157
+ "url": {
158
+ "_extras": {"key": "val"}
159
+ }
160
+ }
161
+ }
162
+ }
163
+ }
164
+ }}
165
+ />
166
+
167
+ <Story
168
+ name="Primary - No Clone"
169
+ args={{
170
+ "schema": {
171
+ "title": "Element",
172
+ "component": "objectInput",
173
+ "properties": {
174
+ "data": {
175
+ "title": "Data",
176
+ "component": "objectInput",
177
+ "properties": {
178
+ "title": {
179
+ "title": "Title",
180
+ "component": "textInput"
181
+ },
182
+ "url": {
183
+ "title": "Image URL",
184
+ "component": "textInput"
185
+ }
186
+ }
187
+ },
188
+ "visual": {
189
+ "title": "Visual",
190
+ "component": "arrayInput",
191
+ "options": {
192
+ "clone": false,
193
+ "default": {
194
+ "f1": "XXXX"
195
+ },
196
+ },
197
+ "items": {
198
+ "title": "Data",
199
+ "component": "objectInput",
200
+ "properties": {
201
+ "f1": {
202
+ "title": "Array Obj Field 1",
203
+ "component": "textInput",
204
+ "automations": [
205
+ {
206
+ "condition":{
207
+ "and": {
208
+ "$[node_value]": {
209
+ "eq": "val"
210
+ }
211
+ }
212
+ },
213
+ "actions":[
214
+ {
215
+ "action":"set",
216
+ "args":[
217
+ "$[node_value]../f2",
218
+ "yyy"
219
+ ]
220
+ },
221
+ {
222
+ "action":"set",
223
+ "args":[
224
+ "$[root_value]data/title",
225
+ "xxx"
226
+ ]
227
+ }
228
+ ]
229
+ }
230
+ ]
91
231
  },
92
232
  "f2": {
93
233
  "title": "Array Obj Field 2",
package/src/Form.svelte CHANGED
@@ -21,10 +21,6 @@
21
21
 
22
22
  export let paths = {};
23
23
 
24
- $: {
25
- console.log("PATHS!", paths);
26
- }
27
-
28
24
  export let components = {}; // svelte input components
29
25
 
30
26
  // TODO set in store, not here
@@ -64,18 +60,11 @@
64
60
  formController.logger = logger;
65
61
  }
66
62
 
67
- // TODO remove this
68
- $: {
69
- console.log("STORE VALUE!", JSON.stringify(value));
70
- }
71
-
72
63
  // svelte-compatible read-only store for components
73
64
  const componentsStore = {
74
65
  subscribe: (callback) => formController.subscribeComponents(callback)
75
66
  };
76
67
 
77
-
78
-
79
68
  setContext(context, formController); // make form controller available to all children
80
69
 
81
70
  /*
@@ -98,10 +87,8 @@
98
87
  */
99
88
 
100
89
  onMount(() => {
101
- console.log("MOUNT", formController);
102
-
90
+ window.formController = formController;
103
91
  const unsubscribeValue = formController.subscribeValue((storeValue) => {
104
- console.log("STORE VALUE", storeValue)
105
92
  value = storeValue;
106
93
  });
107
94
 
@@ -109,8 +96,6 @@
109
96
  unsubscribeValue();
110
97
  }
111
98
  });
112
-
113
-
114
99
  </script>
115
100
 
116
101
  <svelte:component
@@ -27,6 +27,8 @@
27
27
 
28
28
  spliceItems(newItemIndex, 0, {value: newItemValue, extrasTree: newItemExtrasTree});
29
29
  }
30
+ else if(schema.options?.default)
31
+ spliceItems(newItemIndex, 0, {value: structuredClone(schema.options?.default), extrasTree: {}});
30
32
  else
31
33
  spliceItems(newItemIndex, 0, {value: undefined, extrasTree: {}});
32
34
  }
@@ -1,4 +1,5 @@
1
1
  /**
2
+ * Svelte Object Store v0.0.2
2
3
  * Returns a Svelte-compatible writeable store from an object-subscriptions object store or object store child
3
4
  * @param nestedObject
4
5
  * @param pathOrPathParts
@@ -24,7 +25,7 @@ const svelteObjectStore = (nestedObject, pathOrPathParts = [], options = {}) =>
24
25
  ? mergedOptions.set(value)
25
26
  : value;
26
27
 
27
- nestedObject.set(pathParts, setValue);
28
+ nestedObject.set(pathParts, setValue, options);
28
29
  }
29
30
  }
30
31