@bpmnkit/core 0.0.8

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.
Files changed (104) hide show
  1. package/README.md +185 -0
  2. package/dist/bpmn/auto-layout.d.ts +10 -0
  3. package/dist/bpmn/auto-layout.js +203 -0
  4. package/dist/bpmn/bpmn-builder.d.ts +381 -0
  5. package/dist/bpmn/bpmn-builder.js +1223 -0
  6. package/dist/bpmn/bpmn-model.d.ts +403 -0
  7. package/dist/bpmn/bpmn-model.js +2 -0
  8. package/dist/bpmn/bpmn-parser.d.ts +4 -0
  9. package/dist/bpmn/bpmn-parser.js +642 -0
  10. package/dist/bpmn/bpmn-serializer.d.ts +4 -0
  11. package/dist/bpmn/bpmn-serializer.js +515 -0
  12. package/dist/bpmn/compact.d.ts +91 -0
  13. package/dist/bpmn/compact.js +349 -0
  14. package/dist/bpmn/di-color.d.ts +9 -0
  15. package/dist/bpmn/di-color.js +32 -0
  16. package/dist/bpmn/index.d.ts +105 -0
  17. package/dist/bpmn/index.js +176 -0
  18. package/dist/bpmn/optimize/feel.d.ts +4 -0
  19. package/dist/bpmn/optimize/feel.js +186 -0
  20. package/dist/bpmn/optimize/flow.d.ts +4 -0
  21. package/dist/bpmn/optimize/flow.js +323 -0
  22. package/dist/bpmn/optimize/index.d.ts +5 -0
  23. package/dist/bpmn/optimize/index.js +51 -0
  24. package/dist/bpmn/optimize/naming.d.ts +8 -0
  25. package/dist/bpmn/optimize/naming.js +145 -0
  26. package/dist/bpmn/optimize/tasks.d.ts +4 -0
  27. package/dist/bpmn/optimize/tasks.js +273 -0
  28. package/dist/bpmn/optimize/types.d.ts +44 -0
  29. package/dist/bpmn/optimize/types.js +2 -0
  30. package/dist/bpmn/optimize/utils.d.ts +23 -0
  31. package/dist/bpmn/optimize/utils.js +129 -0
  32. package/dist/bpmn/rest-connector.d.ts +48 -0
  33. package/dist/bpmn/rest-connector.js +69 -0
  34. package/dist/bpmn/svg.d.ts +35 -0
  35. package/dist/bpmn/svg.js +557 -0
  36. package/dist/bpmn/type-guards.d.ts +136 -0
  37. package/dist/bpmn/type-guards.js +211 -0
  38. package/dist/bpmn/utils.d.ts +88 -0
  39. package/dist/bpmn/utils.js +207 -0
  40. package/dist/bpmn/zeebe-extensions.d.ts +72 -0
  41. package/dist/bpmn/zeebe-extensions.js +96 -0
  42. package/dist/dmn/compact.d.ts +44 -0
  43. package/dist/dmn/compact.js +125 -0
  44. package/dist/dmn/dmn-builder.d.ts +59 -0
  45. package/dist/dmn/dmn-builder.js +144 -0
  46. package/dist/dmn/dmn-layout.d.ts +57 -0
  47. package/dist/dmn/dmn-layout.js +256 -0
  48. package/dist/dmn/dmn-model.d.ts +158 -0
  49. package/dist/dmn/dmn-model.js +2 -0
  50. package/dist/dmn/dmn-parser.d.ts +4 -0
  51. package/dist/dmn/dmn-parser.js +275 -0
  52. package/dist/dmn/dmn-serializer.d.ts +4 -0
  53. package/dist/dmn/dmn-serializer.js +296 -0
  54. package/dist/dmn/index.d.ts +28 -0
  55. package/dist/dmn/index.js +51 -0
  56. package/dist/errors.d.ts +77 -0
  57. package/dist/errors.js +66 -0
  58. package/dist/form/compact.d.ts +20 -0
  59. package/dist/form/compact.js +146 -0
  60. package/dist/form/form-builder.d.ts +111 -0
  61. package/dist/form/form-builder.js +347 -0
  62. package/dist/form/form-model.d.ts +221 -0
  63. package/dist/form/form-model.js +2 -0
  64. package/dist/form/form-parser.d.ts +4 -0
  65. package/dist/form/form-parser.js +514 -0
  66. package/dist/form/form-serializer.d.ts +4 -0
  67. package/dist/form/form-serializer.js +240 -0
  68. package/dist/form/index.d.ts +27 -0
  69. package/dist/form/index.js +43 -0
  70. package/dist/index.d.ts +37 -0
  71. package/dist/index.js +19 -0
  72. package/dist/layout/bench.d.ts +86 -0
  73. package/dist/layout/bench.js +225 -0
  74. package/dist/layout/coordinates.d.ts +62 -0
  75. package/dist/layout/coordinates.js +868 -0
  76. package/dist/layout/crossing.d.ts +8 -0
  77. package/dist/layout/crossing.js +60 -0
  78. package/dist/layout/graph.d.ts +28 -0
  79. package/dist/layout/graph.js +126 -0
  80. package/dist/layout/index.d.ts +7 -0
  81. package/dist/layout/index.js +5 -0
  82. package/dist/layout/layers.d.ts +13 -0
  83. package/dist/layout/layers.js +49 -0
  84. package/dist/layout/layout-engine.d.ts +21 -0
  85. package/dist/layout/layout-engine.js +191 -0
  86. package/dist/layout/overlap.d.ts +10 -0
  87. package/dist/layout/overlap.js +70 -0
  88. package/dist/layout/routing.d.ts +26 -0
  89. package/dist/layout/routing.js +439 -0
  90. package/dist/layout/subprocess.d.ts +14 -0
  91. package/dist/layout/subprocess.js +77 -0
  92. package/dist/layout/types.d.ts +72 -0
  93. package/dist/layout/types.js +37 -0
  94. package/dist/types/id-generator.d.ts +8 -0
  95. package/dist/types/id-generator.js +31 -0
  96. package/dist/types/index.d.ts +3 -0
  97. package/dist/types/index.js +2 -0
  98. package/dist/types/xml-element.d.ts +12 -0
  99. package/dist/types/xml-element.js +2 -0
  100. package/dist/xml/index.d.ts +2 -0
  101. package/dist/xml/index.js +2 -0
  102. package/dist/xml/xml-parser.d.ts +13 -0
  103. package/dist/xml/xml-parser.js +271 -0
  104. package/package.json +38 -0
@@ -0,0 +1,514 @@
1
+ const KNOWN_COMPONENT_TYPES = new Set([
2
+ "text",
3
+ "textfield",
4
+ "textarea",
5
+ "select",
6
+ "radio",
7
+ "checkbox",
8
+ "checklist",
9
+ "group",
10
+ "number",
11
+ "datetime",
12
+ "button",
13
+ "taglist",
14
+ "table",
15
+ "image",
16
+ "dynamiclist",
17
+ "iframe",
18
+ "separator",
19
+ "spacer",
20
+ "documentPreview",
21
+ "html",
22
+ "expression",
23
+ "filepicker",
24
+ ]);
25
+ /** Parses a Camunda Form JSON string into a typed FormDefinition. */
26
+ export function parseForm(json) {
27
+ let raw;
28
+ try {
29
+ raw = JSON.parse(json);
30
+ }
31
+ catch (e) {
32
+ throw new Error(`Failed to parse form JSON: ${e.message}`);
33
+ }
34
+ if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
35
+ throw new Error("Form JSON must be an object");
36
+ }
37
+ const obj = raw;
38
+ if (typeof obj.id !== "string" || obj.id.length === 0) {
39
+ throw new Error("Form must have a non-empty 'id' string");
40
+ }
41
+ if (typeof obj.type !== "string") {
42
+ throw new Error("Form must have a 'type' string");
43
+ }
44
+ if (!Array.isArray(obj.components)) {
45
+ throw new Error("Form must have a 'components' array");
46
+ }
47
+ const definition = {
48
+ id: obj.id,
49
+ type: obj.type,
50
+ components: obj.components.map((c, i) => parseComponent(c, `components[${i}]`)),
51
+ };
52
+ if (typeof obj.executionPlatform === "string") {
53
+ definition.executionPlatform = obj.executionPlatform;
54
+ }
55
+ if (typeof obj.executionPlatformVersion === "string") {
56
+ definition.executionPlatformVersion = obj.executionPlatformVersion;
57
+ }
58
+ if (typeof obj.schemaVersion === "number") {
59
+ definition.schemaVersion = obj.schemaVersion;
60
+ }
61
+ if (typeof obj.generated === "boolean") {
62
+ definition.generated = obj.generated;
63
+ }
64
+ if (typeof obj.exporter === "object" && obj.exporter !== null) {
65
+ const exp = obj.exporter;
66
+ definition.exporter = {
67
+ name: String(exp.name ?? ""),
68
+ version: String(exp.version ?? ""),
69
+ };
70
+ }
71
+ return definition;
72
+ }
73
+ function parseComponent(raw, path) {
74
+ if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
75
+ throw new Error(`${path}: component must be an object`);
76
+ }
77
+ const obj = raw;
78
+ if (typeof obj.type !== "string") {
79
+ throw new Error(`${path}: component must have a 'type' string`);
80
+ }
81
+ if (typeof obj.id !== "string" || obj.id.length === 0) {
82
+ throw new Error(`${path}: component must have a non-empty 'id'`);
83
+ }
84
+ const layout = parseLayout(obj.layout, path);
85
+ if (!KNOWN_COMPONENT_TYPES.has(obj.type)) {
86
+ return parseUnknownComponent(obj, layout);
87
+ }
88
+ switch (obj.type) {
89
+ case "text": {
90
+ if (typeof obj.text !== "string") {
91
+ throw new Error(`${path}: text component must have a 'text' string`);
92
+ }
93
+ const c = { type: "text", id: obj.id, text: obj.text };
94
+ if (typeof obj.label === "string")
95
+ c.label = obj.label;
96
+ if (layout)
97
+ c.layout = layout;
98
+ return c;
99
+ }
100
+ case "textfield":
101
+ return parseFieldComponent(obj, "textfield", path, layout);
102
+ case "textarea":
103
+ return parseFieldComponent(obj, "textarea", path, layout);
104
+ case "select":
105
+ return parseSelectComponent(obj, path, layout);
106
+ case "radio":
107
+ return parseValuesComponent(obj, "radio", path, layout);
108
+ case "checkbox":
109
+ return parseCheckboxComponent(obj, path, layout);
110
+ case "checklist":
111
+ return parseValuesComponent(obj, "checklist", path, layout);
112
+ case "group":
113
+ return parseGroupComponent(obj, path, layout);
114
+ case "number":
115
+ return parseNumberComponent(obj, path, layout);
116
+ case "datetime":
117
+ return parseDatetimeComponent(obj, path, layout);
118
+ case "button":
119
+ return parseButtonComponent(obj, path, layout);
120
+ case "taglist":
121
+ return parseTaglistComponent(obj, path, layout);
122
+ case "table":
123
+ return parseTableComponent(obj, path, layout);
124
+ case "image":
125
+ return parseImageComponent(obj, path, layout);
126
+ case "dynamiclist":
127
+ return parseDynamicListComponent(obj, path, layout);
128
+ case "iframe":
129
+ return parseIframeComponent(obj, path, layout);
130
+ case "separator":
131
+ return parseSeparatorComponent(obj, layout);
132
+ case "spacer":
133
+ return parseSpacerComponent(obj, layout);
134
+ case "documentPreview":
135
+ return parseDocumentPreviewComponent(obj, layout);
136
+ case "html":
137
+ return parseHtmlComponent(obj, layout);
138
+ case "expression":
139
+ return parseExpressionComponent(obj, layout);
140
+ case "filepicker":
141
+ return parseFilepickerComponent(obj, layout);
142
+ default:
143
+ return parseUnknownComponent(obj, layout);
144
+ }
145
+ }
146
+ function parseLayout(raw, path) {
147
+ if (raw === undefined || raw === null)
148
+ return undefined;
149
+ if (typeof raw !== "object" || Array.isArray(raw)) {
150
+ throw new Error(`${path}.layout: must be an object`);
151
+ }
152
+ const obj = raw;
153
+ const layout = {};
154
+ if (typeof obj.row === "string")
155
+ layout.row = obj.row;
156
+ if (obj.columns === null) {
157
+ layout.columns = null;
158
+ }
159
+ else if (typeof obj.columns === "number") {
160
+ layout.columns = obj.columns;
161
+ }
162
+ return layout;
163
+ }
164
+ function parseValidation(raw, path) {
165
+ if (raw === undefined || raw === null)
166
+ return undefined;
167
+ if (typeof raw !== "object" || Array.isArray(raw)) {
168
+ throw new Error(`${path}.validate: must be an object`);
169
+ }
170
+ const obj = raw;
171
+ const v = {};
172
+ if (typeof obj.required === "boolean")
173
+ v.required = obj.required;
174
+ if (typeof obj.minLength === "number")
175
+ v.minLength = obj.minLength;
176
+ if (typeof obj.maxLength === "number")
177
+ v.maxLength = obj.maxLength;
178
+ return v;
179
+ }
180
+ function parseValues(raw, path) {
181
+ if (!Array.isArray(raw)) {
182
+ throw new Error(`${path}.values: must be an array`);
183
+ }
184
+ return raw.map((v, i) => {
185
+ if (typeof v !== "object" || v === null) {
186
+ throw new Error(`${path}.values[${i}]: must be an object`);
187
+ }
188
+ const vo = v;
189
+ return {
190
+ label: String(vo.label ?? ""),
191
+ value: String(vo.value ?? ""),
192
+ };
193
+ });
194
+ }
195
+ function parseFieldComponent(obj, type, path, layout) {
196
+ if (typeof obj.label !== "string") {
197
+ throw new Error(`${path}: ${type} must have a 'label' string`);
198
+ }
199
+ if (typeof obj.key !== "string") {
200
+ throw new Error(`${path}: ${type} must have a 'key' string`);
201
+ }
202
+ const validate = parseValidation(obj.validate, path);
203
+ const base = {
204
+ id: obj.id,
205
+ label: obj.label,
206
+ key: obj.key,
207
+ ...(validate ? { validate } : {}),
208
+ ...(typeof obj.defaultValue === "string" ? { defaultValue: obj.defaultValue } : {}),
209
+ ...(layout ? { layout } : {}),
210
+ };
211
+ if (type === "textfield")
212
+ return { type: "textfield", ...base };
213
+ return { type: "textarea", ...base };
214
+ }
215
+ function parseSelectComponent(obj, path, layout) {
216
+ if (typeof obj.label !== "string") {
217
+ throw new Error(`${path}: select must have a 'label' string`);
218
+ }
219
+ if (typeof obj.key !== "string") {
220
+ throw new Error(`${path}: select must have a 'key' string`);
221
+ }
222
+ const c = {
223
+ type: "select",
224
+ id: obj.id,
225
+ label: obj.label,
226
+ key: obj.key,
227
+ };
228
+ if (Array.isArray(obj.values)) {
229
+ c.values = parseValues(obj.values, path);
230
+ }
231
+ if (typeof obj.valuesKey === "string")
232
+ c.valuesKey = obj.valuesKey;
233
+ const validate = parseValidation(obj.validate, path);
234
+ if (validate)
235
+ c.validate = validate;
236
+ if (typeof obj.searchable === "boolean")
237
+ c.searchable = obj.searchable;
238
+ if (typeof obj.defaultValue === "string")
239
+ c.defaultValue = obj.defaultValue;
240
+ if (layout)
241
+ c.layout = layout;
242
+ return c;
243
+ }
244
+ function parseValuesComponent(obj, type, path, layout) {
245
+ if (typeof obj.label !== "string") {
246
+ throw new Error(`${path}: ${type} must have a 'label' string`);
247
+ }
248
+ if (typeof obj.key !== "string") {
249
+ throw new Error(`${path}: ${type} must have a 'key' string`);
250
+ }
251
+ const values = Array.isArray(obj.values) ? parseValues(obj.values, path) : undefined;
252
+ if (type === "radio") {
253
+ const c = {
254
+ type: "radio",
255
+ id: obj.id,
256
+ label: obj.label,
257
+ key: obj.key,
258
+ };
259
+ if (values)
260
+ c.values = values;
261
+ if (typeof obj.valuesExpression === "string")
262
+ c.valuesExpression = obj.valuesExpression;
263
+ const validate = parseValidation(obj.validate, path);
264
+ if (validate)
265
+ c.validate = validate;
266
+ if (typeof obj.defaultValue === "string")
267
+ c.defaultValue = obj.defaultValue;
268
+ if (layout)
269
+ c.layout = layout;
270
+ return c;
271
+ }
272
+ const c = {
273
+ type: "checklist",
274
+ id: obj.id,
275
+ label: obj.label,
276
+ key: obj.key,
277
+ };
278
+ if (values)
279
+ c.values = values;
280
+ if (typeof obj.valuesExpression === "string")
281
+ c.valuesExpression = obj.valuesExpression;
282
+ const validate = parseValidation(obj.validate, path);
283
+ if (validate)
284
+ c.validate = validate;
285
+ if (layout)
286
+ c.layout = layout;
287
+ return c;
288
+ }
289
+ function parseCheckboxComponent(obj, path, layout) {
290
+ if (typeof obj.label !== "string") {
291
+ throw new Error(`${path}: checkbox must have a 'label' string`);
292
+ }
293
+ if (typeof obj.key !== "string") {
294
+ throw new Error(`${path}: checkbox must have a 'key' string`);
295
+ }
296
+ const c = {
297
+ type: "checkbox",
298
+ id: obj.id,
299
+ label: obj.label,
300
+ key: obj.key,
301
+ };
302
+ const validate = parseValidation(obj.validate, path);
303
+ if (validate)
304
+ c.validate = validate;
305
+ if (typeof obj.defaultValue === "boolean")
306
+ c.defaultValue = obj.defaultValue;
307
+ if (layout)
308
+ c.layout = layout;
309
+ return c;
310
+ }
311
+ function parseGroupComponent(obj, path, layout) {
312
+ if (typeof obj.label !== "string") {
313
+ throw new Error(`${path}: group must have a 'label' string`);
314
+ }
315
+ if (!Array.isArray(obj.components)) {
316
+ throw new Error(`${path}: group must have a 'components' array`);
317
+ }
318
+ const components = obj.components.map((c, i) => parseComponent(c, `${path}.components[${i}]`));
319
+ const c = {
320
+ type: "group",
321
+ id: obj.id,
322
+ label: obj.label,
323
+ components,
324
+ };
325
+ if (typeof obj.showOutline === "boolean")
326
+ c.showOutline = obj.showOutline;
327
+ if (layout)
328
+ c.layout = layout;
329
+ return c;
330
+ }
331
+ function parseNumberComponent(obj, path, layout) {
332
+ if (typeof obj.label !== "string")
333
+ throw new Error(`${path}: number must have a 'label' string`);
334
+ if (typeof obj.key !== "string")
335
+ throw new Error(`${path}: number must have a 'key' string`);
336
+ const c = { type: "number", id: obj.id, label: obj.label, key: obj.key };
337
+ const validate = parseValidation(obj.validate, path);
338
+ if (validate)
339
+ c.validate = validate;
340
+ if (typeof obj.defaultValue === "number")
341
+ c.defaultValue = obj.defaultValue;
342
+ if (layout)
343
+ c.layout = layout;
344
+ return c;
345
+ }
346
+ function parseDatetimeComponent(obj, _path, layout) {
347
+ const c = { type: "datetime", id: obj.id, key: String(obj.key ?? "") };
348
+ if (typeof obj.subtype === "string")
349
+ c.subtype = obj.subtype;
350
+ if (typeof obj.dateLabel === "string")
351
+ c.dateLabel = obj.dateLabel;
352
+ if (typeof obj.timeLabel === "string")
353
+ c.timeLabel = obj.timeLabel;
354
+ if (layout)
355
+ c.layout = layout;
356
+ return c;
357
+ }
358
+ function parseButtonComponent(obj, path, layout) {
359
+ if (typeof obj.label !== "string")
360
+ throw new Error(`${path}: button must have a 'label' string`);
361
+ const c = { type: "button", id: obj.id, label: obj.label };
362
+ if (typeof obj.action === "string")
363
+ c.action = obj.action;
364
+ if (layout)
365
+ c.layout = layout;
366
+ return c;
367
+ }
368
+ function parseTaglistComponent(obj, path, layout) {
369
+ if (typeof obj.label !== "string")
370
+ throw new Error(`${path}: taglist must have a 'label' string`);
371
+ if (typeof obj.key !== "string")
372
+ throw new Error(`${path}: taglist must have a 'key' string`);
373
+ const c = {
374
+ type: "taglist",
375
+ id: obj.id,
376
+ label: obj.label,
377
+ key: obj.key,
378
+ };
379
+ if (Array.isArray(obj.values))
380
+ c.values = parseValues(obj.values, path);
381
+ if (typeof obj.valuesKey === "string")
382
+ c.valuesKey = obj.valuesKey;
383
+ if (layout)
384
+ c.layout = layout;
385
+ return c;
386
+ }
387
+ function parseTableComponent(obj, _path, layout) {
388
+ const c = { type: "table", id: obj.id };
389
+ if (typeof obj.label === "string")
390
+ c.label = obj.label;
391
+ if (typeof obj.dataSource === "string")
392
+ c.dataSource = obj.dataSource;
393
+ if (typeof obj.rowCount === "number")
394
+ c.rowCount = obj.rowCount;
395
+ if (Array.isArray(obj.columns)) {
396
+ c.columns = obj.columns.map((col) => {
397
+ const co = col;
398
+ return { label: String(co.label ?? ""), key: String(co.key ?? "") };
399
+ });
400
+ }
401
+ if (layout)
402
+ c.layout = layout;
403
+ return c;
404
+ }
405
+ function parseImageComponent(obj, _path, layout) {
406
+ const c = { type: "image", id: obj.id };
407
+ if (typeof obj.source === "string")
408
+ c.source = obj.source;
409
+ if (typeof obj.alt === "string")
410
+ c.alt = obj.alt;
411
+ if (layout)
412
+ c.layout = layout;
413
+ return c;
414
+ }
415
+ function parseDynamicListComponent(obj, path, layout) {
416
+ const components = Array.isArray(obj.components)
417
+ ? obj.components.map((c, i) => parseComponent(c, `${path}.components[${i}]`))
418
+ : [];
419
+ const c = { type: "dynamiclist", id: obj.id, components };
420
+ if (typeof obj.label === "string")
421
+ c.label = obj.label;
422
+ if (typeof obj.path === "string")
423
+ c.path = obj.path;
424
+ if (typeof obj.isRepeating === "boolean")
425
+ c.isRepeating = obj.isRepeating;
426
+ if (typeof obj.allowAddRemove === "boolean")
427
+ c.allowAddRemove = obj.allowAddRemove;
428
+ if (typeof obj.defaultRepetitions === "number")
429
+ c.defaultRepetitions = obj.defaultRepetitions;
430
+ if (typeof obj.showOutline === "boolean")
431
+ c.showOutline = obj.showOutline;
432
+ if (layout)
433
+ c.layout = layout;
434
+ return c;
435
+ }
436
+ function parseIframeComponent(obj, _path, layout) {
437
+ const c = { type: "iframe", id: obj.id };
438
+ if (typeof obj.label === "string")
439
+ c.label = obj.label;
440
+ if (typeof obj.url === "string")
441
+ c.url = obj.url;
442
+ if (typeof obj.height === "number")
443
+ c.height = obj.height;
444
+ if (typeof obj.security === "object" && obj.security !== null) {
445
+ const sec = obj.security;
446
+ c.security = {
447
+ allowScripts: typeof sec.allowScripts === "boolean" ? sec.allowScripts : undefined,
448
+ };
449
+ }
450
+ if (layout)
451
+ c.layout = layout;
452
+ return c;
453
+ }
454
+ function parseSeparatorComponent(obj, layout) {
455
+ const c = { type: "separator", id: obj.id };
456
+ if (layout)
457
+ c.layout = layout;
458
+ return c;
459
+ }
460
+ function parseSpacerComponent(obj, layout) {
461
+ const c = { type: "spacer", id: obj.id };
462
+ if (typeof obj.height === "number")
463
+ c.height = obj.height;
464
+ if (layout)
465
+ c.layout = layout;
466
+ return c;
467
+ }
468
+ function parseDocumentPreviewComponent(obj, layout) {
469
+ const c = { type: "documentPreview", id: obj.id };
470
+ if (typeof obj.label === "string")
471
+ c.label = obj.label;
472
+ if (layout)
473
+ c.layout = layout;
474
+ return c;
475
+ }
476
+ function parseHtmlComponent(obj, layout) {
477
+ const c = { type: "html", id: obj.id };
478
+ if (typeof obj.content === "string")
479
+ c.content = obj.content;
480
+ if (layout)
481
+ c.layout = layout;
482
+ return c;
483
+ }
484
+ function parseExpressionComponent(obj, layout) {
485
+ const c = { type: "expression", id: obj.id };
486
+ if (typeof obj.key === "string")
487
+ c.key = obj.key;
488
+ if (typeof obj.expression === "string")
489
+ c.expression = obj.expression;
490
+ if (typeof obj.computeOn === "string")
491
+ c.computeOn = obj.computeOn;
492
+ if (layout)
493
+ c.layout = layout;
494
+ return c;
495
+ }
496
+ function parseFilepickerComponent(obj, layout) {
497
+ const c = { type: "filepicker", id: obj.id };
498
+ if (typeof obj.label === "string")
499
+ c.label = obj.label;
500
+ if (typeof obj.key === "string")
501
+ c.key = obj.key;
502
+ if (typeof obj.multiple === "boolean")
503
+ c.multiple = obj.multiple;
504
+ if (layout)
505
+ c.layout = layout;
506
+ return c;
507
+ }
508
+ function parseUnknownComponent(obj, layout) {
509
+ const c = { ...obj, type: obj.type, id: obj.id };
510
+ if (layout)
511
+ c.layout = layout;
512
+ return c;
513
+ }
514
+ //# sourceMappingURL=form-parser.js.map
@@ -0,0 +1,4 @@
1
+ import type { FormDefinition } from "./form-model.js";
2
+ /** Serializes a FormDefinition to a JSON string. */
3
+ export declare function exportForm(form: FormDefinition): string;
4
+ //# sourceMappingURL=form-serializer.d.ts.map