svelte-json-schema-form 0.0.1-alpha8 → 0.0.2

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": "svelte-json-schema-form",
3
3
  "private": false,
4
- "version": "0.0.1-alpha8",
4
+ "version": "0.0.2",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "check": "svelte-check --tsconfig ./tsconfig.json",
@@ -33,6 +33,6 @@
33
33
  "vite": "^5.1.0"
34
34
  },
35
35
  "dependencies": {
36
- "json-form-core": "0.0.1-alpha13"
36
+ "json-form-core": "^0.0.3"
37
37
  }
38
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",
@@ -164,6 +164,119 @@
164
164
  }}
165
165
  />
166
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
+ ]
231
+ },
232
+ "f2": {
233
+ "title": "Array Obj Field 2",
234
+ "component": "textInput"
235
+ }
236
+ }
237
+ }
238
+ }
239
+ }
240
+ },
241
+ "value": {
242
+ "visual":[
243
+ {
244
+ "f2": "copied into the next item",
245
+ "f1": "this field will be"
246
+ }
247
+ ],
248
+ "data": {
249
+ "url": "xxxxxx"
250
+ }
251
+ },
252
+ "extras": {
253
+ "_extras": {},
254
+ "_children": {
255
+ "visual": {
256
+ "_extras": {},
257
+ "_children": [
258
+ {
259
+ "_children": {
260
+ "f1": {
261
+ "_extras": {"key": "val"}
262
+ }
263
+ }
264
+ }
265
+ ]
266
+ },
267
+ "data": {
268
+ "_extras": {},
269
+ "_children": {
270
+ "url": {
271
+ "_extras": {"key": "val"}
272
+ }
273
+ }
274
+ }
275
+ }
276
+ }
277
+ }}
278
+ />
279
+
167
280
  <Story
168
281
  name="Biz Grid"
169
282
  args={{
package/src/Form.svelte CHANGED
@@ -37,7 +37,8 @@
37
37
  components: {
38
38
  ...defaultComponents,
39
39
  ...components
40
- }
40
+ },
41
+ logger: logger
41
42
  });
42
43
 
43
44
  // dispatch all events from form controller
@@ -57,6 +58,7 @@
57
58
  }
58
59
 
59
60
  $: if(logger) {
61
+ console.log("SETTING LOGGER!")
60
62
  formController.logger = logger;
61
63
  }
62
64
 
@@ -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
  }