@stubber/form-fields 2.2.6 → 3.0.0

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 (126) hide show
  1. package/README.md +63 -25
  2. package/dist/form-fields/Autocomplete.svelte +261 -0
  3. package/dist/form-fields/Autocomplete.svelte.d.ts +43 -0
  4. package/dist/form-fields/CollapsibleSection.svelte +127 -0
  5. package/dist/form-fields/CollapsibleSection.svelte.d.ts +26 -0
  6. package/dist/form-fields/FieldLabel.svelte +18 -3
  7. package/dist/form-fields/FieldLabel.svelte.d.ts +1 -0
  8. package/dist/form-fields/FieldMessage.svelte +20 -9
  9. package/dist/form-fields/Form.svelte +19 -2
  10. package/dist/form-fields/Form.svelte.d.ts +2 -0
  11. package/dist/form-fields/UploadStatus.svelte +76 -0
  12. package/dist/form-fields/UploadStatus.svelte.d.ts +18 -0
  13. package/dist/form-fields/fields/_field-builder-reorder.svelte +35 -0
  14. package/dist/form-fields/fields/_field-builder-reorder.svelte.d.ts +22 -0
  15. package/dist/form-fields/{sub → fields}/array-builder-field.svelte +104 -38
  16. package/dist/form-fields/fields/checkbox-autocomplete.svelte +153 -0
  17. package/dist/form-fields/fields/checkbox-field.svelte +69 -0
  18. package/dist/form-fields/{sub → fields}/contact-selector-field.svelte +9 -6
  19. package/dist/form-fields/{sub → fields}/currency-field.svelte +108 -70
  20. package/dist/form-fields/fields/data-indication-field.svelte +39 -0
  21. package/dist/form-fields/fields/date-field.svelte +31 -0
  22. package/dist/form-fields/fields/date-time-field.svelte +31 -0
  23. package/dist/form-fields/{sub → fields}/email-field.svelte +25 -11
  24. package/dist/form-fields/fields/field-builder-field.svelte +568 -0
  25. package/dist/form-fields/fields/file-field.svelte +284 -0
  26. package/dist/form-fields/{sub → fields}/file-field.svelte.d.ts +2 -0
  27. package/dist/form-fields/fields/grid-field.svelte +152 -0
  28. package/dist/form-fields/{sub → fields}/heading-field.svelte +7 -4
  29. package/dist/form-fields/{sub → fields}/html-field.svelte +6 -4
  30. package/dist/form-fields/{sub → fields}/map-field.svelte +121 -78
  31. package/dist/form-fields/{sub → fields}/multi-checkbox-field.svelte +35 -20
  32. package/dist/form-fields/fields/multistep-field.svelte +135 -0
  33. package/dist/form-fields/fields/note-field.svelte +35 -0
  34. package/dist/form-fields/{sub → fields}/number-field.svelte +29 -14
  35. package/dist/form-fields/fields/object-builder-field.svelte +176 -0
  36. package/dist/form-fields/fields/qr-code-scanner-field.svelte +203 -0
  37. package/dist/form-fields/fields/radio-field.svelte +82 -0
  38. package/dist/form-fields/{sub → fields}/radio-field.svelte.d.ts +1 -1
  39. package/dist/form-fields/fields/screenrecorder-field.svelte +255 -0
  40. package/dist/form-fields/{sub → fields}/screenshot-field.svelte +101 -40
  41. package/dist/form-fields/{sub → fields}/scroll-and-read-display-field.svelte +43 -27
  42. package/dist/form-fields/fields/section-field.svelte +73 -0
  43. package/dist/form-fields/fields/select-field.svelte +104 -0
  44. package/dist/form-fields/{sub → fields}/signature-field.svelte +78 -22
  45. package/dist/form-fields/fields/slider-field.svelte +53 -0
  46. package/dist/form-fields/{sub → fields}/smart-text-field.svelte +62 -82
  47. package/dist/form-fields/fields/telephone-field.svelte +108 -0
  48. package/dist/form-fields/{sub → fields}/telephone-field.svelte.d.ts +1 -1
  49. package/dist/form-fields/{sub → fields}/text-field.svelte +28 -11
  50. package/dist/form-fields/{sub → fields}/voicenote-field.svelte +117 -46
  51. package/dist/form-fields/file_creation_options.d.ts +1 -1
  52. package/dist/form-fields/form-field.svelte +8 -1
  53. package/dist/form-fields/icons/ChevronDownIcon.svelte +21 -0
  54. package/dist/form-fields/icons/ChevronDownIcon.svelte.d.ts +20 -0
  55. package/dist/form-fields/icons/QrCodeScannerIcon.svelte +25 -0
  56. package/dist/form-fields/icons/QrCodeScannerIcon.svelte.d.ts +19 -0
  57. package/dist/form-fields/icons/ScreenRecordingIcon.svelte +21 -0
  58. package/dist/form-fields/icons/ScreenRecordingIcon.svelte.d.ts +19 -0
  59. package/dist/form-fields/icons/ScreenshotIcon.svelte +22 -0
  60. package/dist/form-fields/icons/ScreenshotIcon.svelte.d.ts +19 -0
  61. package/dist/form-fields/index.d.ts +5 -1
  62. package/dist/form-fields/index.js +3 -1
  63. package/dist/form-fields/interfaces.d.ts +63 -63
  64. package/dist/form-fields/interfaces.js +42 -39
  65. package/dist/form-fields/intl-tel-input.css +1 -0
  66. package/dist/form-fields/styles.d.ts +17 -0
  67. package/dist/form-fields/styles.js +4 -0
  68. package/package.json +2 -4
  69. package/dist/form-fields/sub/checkbox-autocomplete.svelte +0 -56
  70. package/dist/form-fields/sub/checkbox-field.svelte +0 -42
  71. package/dist/form-fields/sub/data-indication-field.svelte +0 -19
  72. package/dist/form-fields/sub/date-field.svelte +0 -31
  73. package/dist/form-fields/sub/date-time-field.svelte +0 -31
  74. package/dist/form-fields/sub/field-builder-field.svelte +0 -657
  75. package/dist/form-fields/sub/file-field.svelte +0 -159
  76. package/dist/form-fields/sub/grid-field.svelte +0 -69
  77. package/dist/form-fields/sub/multistep-field.svelte +0 -70
  78. package/dist/form-fields/sub/note-field.svelte +0 -18
  79. package/dist/form-fields/sub/object-builder-field.svelte +0 -134
  80. package/dist/form-fields/sub/qr-code-scanner-field.svelte +0 -84
  81. package/dist/form-fields/sub/radio-field.svelte +0 -69
  82. package/dist/form-fields/sub/screenrecorder-field.svelte +0 -178
  83. package/dist/form-fields/sub/section-field.svelte +0 -50
  84. package/dist/form-fields/sub/select-field.svelte +0 -150
  85. package/dist/form-fields/sub/slider-field.svelte +0 -28
  86. package/dist/form-fields/sub/telephone-field.svelte +0 -64
  87. /package/dist/form-fields/{sub → fields}/array-builder-field.svelte.d.ts +0 -0
  88. /package/dist/form-fields/{sub → fields}/checkbox-autocomplete.svelte.d.ts +0 -0
  89. /package/dist/form-fields/{sub → fields}/checkbox-field.svelte.d.ts +0 -0
  90. /package/dist/form-fields/{sub → fields}/code-field.svelte +0 -0
  91. /package/dist/form-fields/{sub → fields}/code-field.svelte.d.ts +0 -0
  92. /package/dist/form-fields/{sub → fields}/contact-selector-field.svelte.d.ts +0 -0
  93. /package/dist/form-fields/{sub → fields}/currency-field.svelte.d.ts +0 -0
  94. /package/dist/form-fields/{sub → fields}/data-indication-field.svelte.d.ts +0 -0
  95. /package/dist/form-fields/{sub → fields}/date-field.svelte.d.ts +0 -0
  96. /package/dist/form-fields/{sub → fields}/date-time-field.svelte.d.ts +0 -0
  97. /package/dist/form-fields/{sub → fields}/email-field.svelte.d.ts +0 -0
  98. /package/dist/form-fields/{sub → fields}/field-builder-field.svelte.d.ts +0 -0
  99. /package/dist/form-fields/{sub → fields}/grid-field.svelte.d.ts +0 -0
  100. /package/dist/form-fields/{sub → fields}/heading-field.svelte.d.ts +0 -0
  101. /package/dist/form-fields/{sub → fields}/hidden-field.svelte +0 -0
  102. /package/dist/form-fields/{sub → fields}/hidden-field.svelte.d.ts +0 -0
  103. /package/dist/form-fields/{sub → fields}/hidden-location-field.svelte +0 -0
  104. /package/dist/form-fields/{sub → fields}/hidden-location-field.svelte.d.ts +0 -0
  105. /package/dist/form-fields/{sub → fields}/html-field.svelte.d.ts +0 -0
  106. /package/dist/form-fields/{sub → fields}/jsoneditor-field.svelte +0 -0
  107. /package/dist/form-fields/{sub → fields}/jsoneditor-field.svelte.d.ts +0 -0
  108. /package/dist/form-fields/{sub → fields}/map-field.svelte.d.ts +0 -0
  109. /package/dist/form-fields/{sub → fields}/multi-checkbox-field.svelte.d.ts +0 -0
  110. /package/dist/form-fields/{sub → fields}/multistep-field.svelte.d.ts +0 -0
  111. /package/dist/form-fields/{sub → fields}/note-field.svelte.d.ts +0 -0
  112. /package/dist/form-fields/{sub → fields}/number-field.svelte.d.ts +0 -0
  113. /package/dist/form-fields/{sub → fields}/object-builder-field.svelte.d.ts +0 -0
  114. /package/dist/form-fields/{sub → fields}/qr-code-scanner-field.svelte.d.ts +0 -0
  115. /package/dist/form-fields/{sub → fields}/screenrecorder-field.svelte.d.ts +0 -0
  116. /package/dist/form-fields/{sub → fields}/screenshot-field.svelte.d.ts +0 -0
  117. /package/dist/form-fields/{sub → fields}/scroll-and-read-display-field.svelte.d.ts +0 -0
  118. /package/dist/form-fields/{sub → fields}/section-field.svelte.d.ts +0 -0
  119. /package/dist/form-fields/{sub → fields}/select-field.svelte.d.ts +0 -0
  120. /package/dist/form-fields/{sub → fields}/selectresource-field.svelte +0 -0
  121. /package/dist/form-fields/{sub → fields}/selectresource-field.svelte.d.ts +0 -0
  122. /package/dist/form-fields/{sub → fields}/signature-field.svelte.d.ts +0 -0
  123. /package/dist/form-fields/{sub → fields}/slider-field.svelte.d.ts +0 -0
  124. /package/dist/form-fields/{sub → fields}/smart-text-field.svelte.d.ts +0 -0
  125. /package/dist/form-fields/{sub → fields}/text-field.svelte.d.ts +0 -0
  126. /package/dist/form-fields/{sub → fields}/voicenote-field.svelte.d.ts +0 -0
@@ -1,657 +0,0 @@
1
- <script context="module">import { writable } from "svelte/store";
2
- import {
3
- fields,
4
- validation_types
5
- } from "../interfaces";
6
- import { text_field_param_spec } from "./text-field.svelte";
7
- const field_params_spec_lookup = {
8
- text: text_field_param_spec,
9
- checkbox: checkbox_field_param_spec,
10
- smart_text: smart_text_field_param_spec,
11
- file: file_field_param_spec,
12
- heading: heading_field_param_spec,
13
- hidden: hidden_field_param_spec,
14
- html: html_field_param_spec,
15
- map: map_field_param_spec,
16
- checkbox_autocomplete: merge({}, checkbox_field_param_spec, smart_text_field_param_spec),
17
- code: code_field_param_spec,
18
- currency: currency_field_param_spec,
19
- dataindication: null,
20
- telephone: null,
21
- email: null,
22
- arraybuilder: array_builder_field_param_spec,
23
- contactselector: contact_selector_field_param_spec,
24
- date: null,
25
- datetime: null,
26
- fieldbuilder: null,
27
- grid: grid_field_param_spec,
28
- hiddenlocation: null,
29
- jsoneditor: jsoneditor_field_param_spec,
30
- multicheckbox: multi_checkbox_field_param_spec,
31
- multistep: null,
32
- // todo: fields for multistep
33
- note: null,
34
- number: number_field_param_spec,
35
- objectbuilder: object_builder_field_param_spec,
36
- qrcodescanner: null,
37
- radio: radio_field_param_spec,
38
- screenrecorder: basic_files_field_param_spec,
39
- screenshot: basic_files_field_param_spec,
40
- voicenote: basic_files_field_param_spec,
41
- signature: signature_field_param_spec,
42
- scrollandreaddisplay: scroll_and_read_display_field_param_spec,
43
- section: null,
44
- // todo: fields for section
45
- select: select_field_param_spec,
46
- slider: number_field_param_spec,
47
- selectresource: select_resource_field_param_spec,
48
- unknown: null
49
- };
50
- </script>
51
-
52
- <script>import Form from "../Form.svelte";
53
- import { Button } from "@stubber/ui/button";
54
- import { Checkbox } from "@stubber/ui/checkbox";
55
- import * as Collapsible from "@stubber/ui/collapsible";
56
- import * as Command from "@stubber/ui/command";
57
- import { Input } from "@stubber/ui/input";
58
- import { Label } from "@stubber/ui/label";
59
- import * as Popover from "@stubber/ui/popover";
60
- import * as Select from "@stubber/ui/select";
61
- import { Textarea } from "@stubber/ui/textarea";
62
- import { cloneDeep, isEmpty, isEqual, isUndefined, merge, omitBy } from "lodash-es";
63
- import { tick } from "svelte";
64
- import FieldLabel from "../FieldLabel.svelte";
65
- import FieldMessage from "../FieldMessage.svelte";
66
- import { checkbox_field_param_spec } from "./checkbox-field.svelte";
67
- import { file_field_param_spec } from "./file-field.svelte";
68
- import { heading_field_param_spec } from "./heading-field.svelte";
69
- import { hidden_field_param_spec } from "./hidden-field.svelte";
70
- import { html_field_param_spec } from "./html-field.svelte";
71
- import { map_field_param_spec } from "./map-field.svelte";
72
- import { smart_text_field_param_spec } from "./smart-text-field.svelte";
73
- import { code_field_param_spec } from "./code-field.svelte";
74
- import { currency_field_param_spec } from "./currency-field.svelte";
75
- import { array_builder_field_param_spec } from "./array-builder-field.svelte";
76
- import { contact_selector_field_param_spec } from "./contact-selector-field.svelte";
77
- import { grid_field_param_spec } from "./grid-field.svelte";
78
- import { jsoneditor_field_param_spec } from "./jsoneditor-field.svelte";
79
- import { multi_checkbox_field_param_spec } from "./multi-checkbox-field.svelte";
80
- import { number_field_param_spec } from "./number-field.svelte";
81
- import { object_builder_field_param_spec } from "./object-builder-field.svelte";
82
- import { radio_field_param_spec } from "./radio-field.svelte";
83
- import { scroll_and_read_display_field_param_spec } from "./scroll-and-read-display-field.svelte";
84
- import { select_field_param_spec } from "./select-field.svelte";
85
- import { select_resource_field_param_spec } from "./selectresource-field.svelte";
86
- import { handle_editor_change_setter, handle_store_change } from "../../utils/json-editor-sync";
87
- import { basic_files_field_param_spec } from "../file_creation_options";
88
- import { signature_field_param_spec } from "./signature-field.svelte";
89
- export let fieldStore;
90
- let value = cloneDeep($fieldStore.value) || {
91
- details: {},
92
- initvalue: {}
93
- };
94
- if (!value.details) {
95
- value.details = {};
96
- }
97
- if (!value.initvalue) {
98
- value.initvalue = {};
99
- }
100
- let default_initvalue_editor;
101
- let override_initvalue_editor;
102
- $: update_fieldStore(value);
103
- function update_fieldStore(new_value) {
104
- const cleaned_value = omitBy(
105
- cloneDeep(new_value),
106
- (v) => isUndefined(v) || typeof v === "object" && isEmpty(v)
107
- );
108
- if (!isEqual($fieldStore, cleaned_value)) {
109
- $fieldStore.value = cleaned_value;
110
- }
111
- }
112
- $: update_value($fieldStore.value);
113
- function update_value(new_value) {
114
- if (!isEqual(value, new_value)) {
115
- value = {
116
- details: {},
117
- initvalue: {},
118
- ...cloneDeep(new_value)
119
- };
120
- update_params_from_value(value.params);
121
- update_subfields_from_value(value.fields);
122
- handle_store_change(value.initvalue.default, default_initvalue_editor);
123
- handle_store_change(value.initvalue.override, override_initvalue_editor);
124
- }
125
- }
126
- const field_types = Object.keys(fields).map((key) => ({
127
- label: key,
128
- value: key
129
- }));
130
- let open = false;
131
- $: selectedValue = field_types.find((f) => f.value === value.fieldtype)?.label ?? "Select a fieldtype";
132
- function closeAndFocusTrigger(trigger_id) {
133
- open = false;
134
- tick().then(() => {
135
- document.getElementById(trigger_id)?.focus();
136
- });
137
- }
138
- function add_condition() {
139
- if (!value.conditions) {
140
- value.conditions = [];
141
- }
142
- value.conditions = [...value.conditions, ""];
143
- }
144
- function move_condition_up(index) {
145
- if (index > 0 && value.conditions) {
146
- const temp = value.conditions[index];
147
- value.conditions[index] = value.conditions[index - 1];
148
- value.conditions[index - 1] = temp;
149
- value.conditions = [...value.conditions];
150
- }
151
- }
152
- function move_condition_down(index) {
153
- if (value.conditions && index < value.conditions.length - 1) {
154
- const temp = value.conditions[index];
155
- value.conditions[index] = value.conditions[index + 1];
156
- value.conditions[index + 1] = temp;
157
- value.conditions = [...value.conditions];
158
- }
159
- }
160
- function remove_condition(index) {
161
- if (value.conditions) {
162
- value.conditions = value.conditions.filter((_, i) => i !== index);
163
- }
164
- }
165
- function add_validation() {
166
- if (!value.validations) {
167
- value.validations = [];
168
- }
169
- value.validations = [...value.validations, { validationtype: "required", invalid_message: "" }];
170
- }
171
- function move_validation_up(index) {
172
- if (index > 0 && value.validations) {
173
- const temp = value.validations[index];
174
- value.validations[index] = value.validations[index - 1];
175
- value.validations[index - 1] = temp;
176
- value.validations = [...value.validations];
177
- }
178
- }
179
- function move_validation_down(index) {
180
- if (value.validations && index < value.validations.length - 1) {
181
- const temp = value.validations[index];
182
- value.validations[index] = value.validations[index + 1];
183
- value.validations[index + 1] = temp;
184
- value.validations = [...value.validations];
185
- }
186
- }
187
- function remove_validation(index) {
188
- if (value.validations) {
189
- value.validations = value.validations.filter((_, i) => i !== index);
190
- }
191
- }
192
- function handle_validation_selected(val, index) {
193
- if (val && value.validations) {
194
- let current_validation;
195
- let prev_validation = value.validations[index];
196
- if (val.value === "required") {
197
- current_validation = {
198
- validationtype: "required",
199
- invalid_message: prev_validation.invalid_message
200
- };
201
- } else if (val.value === "regex") {
202
- current_validation = {
203
- validationtype: "regex",
204
- invalid_message: prev_validation.invalid_message,
205
- params: { regex: prev_validation.params?.regex ?? "" }
206
- };
207
- } else {
208
- current_validation = {
209
- validationtype: "jsonata",
210
- invalid_message: prev_validation.invalid_message,
211
- params: { jsonata: prev_validation.params?.jsonata ?? "" }
212
- };
213
- }
214
- value.validations[index] = current_validation;
215
- }
216
- }
217
- const params_store = writable({});
218
- $: update_params($params_store);
219
- function update_params(new_params) {
220
- const cloned_new_params = cloneDeep(new_params);
221
- if (!isEqual(value.params, cloned_new_params) && !isEmpty(cloned_new_params)) {
222
- value.params = cloned_new_params;
223
- update_fieldStore(value);
224
- }
225
- }
226
- function update_params_from_value(new_value) {
227
- if (!isEqual(new_value, $params_store)) {
228
- params_store.set(cloneDeep(new_value) || {});
229
- }
230
- }
231
- function select_field_type(newValue, trigger) {
232
- value.fieldtype = newValue;
233
- field_param_spec = cloneDeep(field_params_spec_lookup[value.fieldtype ?? "unknown"]);
234
- closeAndFocusTrigger(trigger);
235
- }
236
- let field_param_spec = cloneDeep(field_params_spec_lookup[value.fieldtype ?? "unknown"]);
237
- const subfields_store = writable({});
238
- $: update_subfields($subfields_store.fields);
239
- function update_subfields(new_subfields) {
240
- const cloned_new_subfields = cloneDeep(new_subfields);
241
- if (!isEqual(value.fields, cloned_new_subfields) && !isEmpty(cloned_new_subfields)) {
242
- value.fields = cloned_new_subfields;
243
- update_fieldStore(value);
244
- }
245
- }
246
- function update_subfields_from_value(new_value) {
247
- if (!isEqual(new_value, $subfields_store)) {
248
- subfields_store.set({ fields: cloneDeep(new_value) || {} });
249
- }
250
- }
251
- let basic_info_open = true;
252
- let sub_fields_open = true;
253
- let params_open = false;
254
- let details_open = false;
255
- let initial_value_open = false;
256
- let conditions_open = false;
257
- let validations_open = false;
258
- </script>
259
-
260
- <FieldLabel {fieldStore} />
261
- <div class="flex flex-col gap-y-2">
262
- <!-- fieldtype picker -->
263
- <Popover.Root bind:open let:ids>
264
- <Popover.Trigger asChild let:builder>
265
- <Button
266
- builders={[builder]}
267
- variant="outline"
268
- role="combobox"
269
- aria-expanded={open}
270
- class="flex h-10 w-full justify-between rounded-md border border-input bg-white bg-opacity-[15] px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
271
- >
272
- {selectedValue}
273
- <i class="fas fa-sort ml-2 h-4 w-4 shrink-0 opacity-50" />
274
- </Button>
275
- </Popover.Trigger>
276
- <Popover.Content class="max-h-[50vh] overflow-y-scroll p-0" sameWidth>
277
- <Command.Root>
278
- <Command.Input placeholder="Search framework..." />
279
- <Command.Empty>No fieldtype found.</Command.Empty>
280
- <Command.Group>
281
- {#each field_types as fieldtype_item}
282
- <Command.Item
283
- value={fieldtype_item.value}
284
- onSelect={(newValue) => select_field_type(newValue, ids.trigger)}
285
- class={value.fieldtype === fieldtype_item.value ? "bg-primary-100" : ""}
286
- >
287
- {fieldtype_item.label}
288
- </Command.Item>
289
- {/each}
290
- </Command.Group>
291
- </Command.Root>
292
- </Popover.Content>
293
- </Popover.Root>
294
- <!-- basic props -->
295
- <Collapsible.Root bind:open={basic_info_open} class="w-full">
296
- <Collapsible.Trigger asChild let:builder>
297
- <Button builders={[builder]} variant="ghost" class="w-full justify-between pl-0">
298
- <Label>Basic Info</Label>
299
-
300
- <div class="flex items-center">
301
- {#if basic_info_open}
302
- <i class="fa fa-caret-down" />
303
- {:else}
304
- <i class="fa fa-caret-right" />
305
- {/if}
306
- </div>
307
- </Button>
308
- </Collapsible.Trigger>
309
-
310
- <Collapsible.Content class="flex flex-col gap-y-2 pl-2">
311
- <div>
312
- <Label for="title">Title</Label>
313
- <Input
314
- id="title"
315
- placeholder="Optional custom title for the field"
316
- bind:value={value.title}
317
- />
318
- </div>
319
- <div class="flex w-full items-center space-x-2">
320
- <Checkbox id="without_value_details" bind:checked={value.without_value_details} />
321
- <Label for="without_value_details">Without Value Details</Label>
322
- </div>
323
- <div class="flex w-full items-center space-x-2">
324
- <Checkbox id="hide_label" bind:checked={value.hide_label} />
325
- <Label for="hide_label">Hide Label</Label>
326
- </div>
327
- <div>
328
- <Label for="help">Help</Label>
329
- <Textarea
330
- id="help"
331
- placeholder="Optional help text for the field"
332
- bind:value={value.help}
333
- />
334
- </div>
335
- </Collapsible.Content>
336
- </Collapsible.Root>
337
- <hr />
338
- <!-- subfields -->
339
- {#if value.fieldtype === "section" || value.fieldtype === "multistep"}
340
- <Collapsible.Root bind:open={sub_fields_open} class="w-full">
341
- <Collapsible.Trigger asChild let:builder>
342
- <Button builders={[builder]} variant="ghost" class="w-full justify-between pl-0">
343
- <Label>Fields</Label>
344
-
345
- <div class="flex items-center">
346
- {#if sub_fields_open}
347
- <i class="fa fa-caret-down" />
348
- {:else}
349
- <i class="fa fa-caret-right" />
350
- {/if}
351
- </div>
352
- </Button>
353
- </Collapsible.Trigger>
354
-
355
- <Collapsible.Content class="flex flex-col gap-y-2 pl-2 pt-2">
356
- <Form
357
- form={subfields_store}
358
- initial_form={{
359
- spec: {
360
- fields: {
361
- fields: {
362
- hide_label: true,
363
- fieldtype: "objectbuilder",
364
- help: "Fields within this section/multistep",
365
- params: {
366
- value_field_spec: {
367
- fieldtype: "fieldbuilder",
368
- initvalue: {
369
- has_default: true,
370
- default: {
371
- fieldtype: "text",
372
- },
373
- },
374
- },
375
- },
376
- },
377
- },
378
- },
379
- }}
380
- />
381
- </Collapsible.Content>
382
- </Collapsible.Root>
383
- <hr />
384
- {/if}
385
-
386
- <!-- params -->
387
- <Collapsible.Root bind:open={params_open} class="w-full">
388
- <Collapsible.Trigger asChild let:builder>
389
- <Button builders={[builder]} variant="ghost" class="w-full justify-between pl-0">
390
- <Label>Params</Label>
391
-
392
- <div class="flex items-center">
393
- {#if params_open}
394
- <i class="fa fa-caret-down" />
395
- {:else}
396
- <i class="fa fa-caret-right" />
397
- {/if}
398
- </div>
399
- </Button>
400
- </Collapsible.Trigger>
401
-
402
- <Collapsible.Content class="flex flex-col gap-y-2 pl-2 pt-2">
403
- {#if field_param_spec}
404
- {#key value.fieldtype}
405
- <Form
406
- initial_form={field_param_spec}
407
- form={params_store}
408
- attachments={$fieldStore.attachmentsStore}
409
- />
410
- {/key}
411
- {:else}
412
- <span class="text-xs text-muted-foreground">No params available for this fieldtype.</span>
413
- {/if}
414
- </Collapsible.Content>
415
- </Collapsible.Root>
416
- <hr />
417
- <!-- details -->
418
- <Collapsible.Root bind:open={details_open} class="w-full">
419
- <Collapsible.Trigger asChild let:builder>
420
- <Button builders={[builder]} variant="ghost" class="w-full justify-between pl-0">
421
- <Label>Details</Label>
422
-
423
- <div class="flex items-center">
424
- {#if details_open}
425
- <i class="fa fa-caret-down" />
426
- {:else}
427
- <i class="fa fa-caret-right" />
428
- {/if}
429
- </div>
430
- </Button>
431
- </Collapsible.Trigger>
432
-
433
- <Collapsible.Content class="flex flex-col gap-y-2 pl-2">
434
- <div>
435
- <Label for="keyname">Keyname</Label>
436
- <Input
437
- id="keyname"
438
- placeholder="Custom key underwhich to store the value"
439
- bind:value={value.details.keyname}
440
- />
441
- </div>
442
- <div>
443
- <Label for="datapath">Data Path</Label>
444
- <Input
445
- id="datapath"
446
- placeholder="Optional custom data path for the field"
447
- bind:value={value.details.datapath}
448
- />
449
- </div>
450
- </Collapsible.Content>
451
- </Collapsible.Root>
452
- <hr />
453
- <!-- initial value -->
454
- <Collapsible.Root bind:open={initial_value_open} class="w-full">
455
- <Collapsible.Trigger asChild let:builder>
456
- <Button builders={[builder]} variant="ghost" class="w-full justify-between pl-0">
457
- <Label>Initial Value</Label>
458
-
459
- <div class="flex items-center">
460
- {#if initial_value_open}
461
- <i class="fa fa-caret-down" />
462
- {:else}
463
- <i class="fa fa-caret-right" />
464
- {/if}
465
- </div>
466
- </Button>
467
- </Collapsible.Trigger>
468
-
469
- <Collapsible.Content class="flex flex-col gap-y-2 pl-2">
470
- <div>
471
- <div class="flex w-full items-center space-x-2">
472
- <Checkbox id="has_default" bind:checked={value.initvalue.has_default} />
473
- <Label for="has_default">Has Default</Label>
474
- </div>
475
- {#await import("svelte-jsoneditor") then JSONEditorModule}
476
- <JSONEditorModule.JSONEditor
477
- bind:this={default_initvalue_editor}
478
- onChange={(content) =>
479
- handle_editor_change_setter(
480
- content,
481
- (new_val) => (value.initvalue.default = new_val)
482
- )}
483
- />
484
- {/await}
485
- </div>
486
- <div>
487
- <div class="flex w-full items-center space-x-2">
488
- <Checkbox id="has_override" bind:checked={value.initvalue.has_override} />
489
- <Label for="has_override">Has Override</Label>
490
- </div>
491
- {#await import("svelte-jsoneditor") then JSONEditorModule}
492
- <JSONEditorModule.JSONEditor
493
- bind:this={override_initvalue_editor}
494
- onChange={(content) =>
495
- handle_editor_change_setter(
496
- content,
497
- (new_val) => (value.initvalue.override = new_val)
498
- )}
499
- />
500
- {/await}
501
- </div>
502
- </Collapsible.Content>
503
- </Collapsible.Root>
504
- <hr />
505
- <!-- conditions -->
506
- <Collapsible.Root bind:open={conditions_open} class="w-full">
507
- <Collapsible.Trigger asChild let:builder>
508
- <Button builders={[builder]} variant="ghost" class="w-full justify-between pl-0">
509
- <Label>Conditions</Label>
510
-
511
- <div class="flex items-center">
512
- {#if conditions_open}
513
- <i class="fa fa-caret-down" />
514
- {:else}
515
- <i class="fa fa-caret-right" />
516
- {/if}
517
- </div>
518
- </Button>
519
- </Collapsible.Trigger>
520
-
521
- <Collapsible.Content class="flex flex-col gap-y-2 pl-2">
522
- <Button variant="outline" size="icon" class="self-start" on:click={add_condition}>
523
- <i class="fa fa-plus" />
524
- </Button>
525
-
526
- {#if value.conditions && value.conditions.length > 0}
527
- {#each value.conditions as condition, index}
528
- <div class="flex w-full items-center space-x-2">
529
- <!-- up and down sort buttons -->
530
- <div class="flex flex-col items-center">
531
- <Button
532
- variant="ghost"
533
- class="h-5 w-5 p-2"
534
- disabled={index === 0}
535
- on:click={() => move_condition_up(index)}
536
- >
537
- <i class="fa fa-chevron-up" />
538
- </Button>
539
- <Button
540
- variant="ghost"
541
- class="h-5 w-5 p-2"
542
- disabled={index === value.conditions.length - 1}
543
- on:click={() => move_condition_down(index)}
544
- >
545
- <i class="fa fa-chevron-down" />
546
- </Button>
547
- </div>
548
- <Input
549
- placeholder="JSONata condition"
550
- class="w-full"
551
- bind:value={value.conditions[index]}
552
- />
553
- <Button
554
- variant="destructive"
555
- class="h-5 w-5 p-2"
556
- on:click={() => remove_condition(index)}
557
- >
558
- <i class="fa fa-trash" />
559
- </Button>
560
- </div>
561
- {/each}
562
- {/if}
563
- </Collapsible.Content>
564
- </Collapsible.Root>
565
- <hr />
566
- <!-- validations -->
567
- <Collapsible.Root bind:open={validations_open} class="w-full">
568
- <Collapsible.Trigger asChild let:builder>
569
- <Button builders={[builder]} variant="ghost" class="w-full justify-between pl-0">
570
- <Label>Validations</Label>
571
-
572
- <div class="flex items-center">
573
- {#if validations_open}
574
- <i class="fa fa-caret-down" />
575
- {:else}
576
- <i class="fa fa-caret-right" />
577
- {/if}
578
- </div>
579
- </Button>
580
- </Collapsible.Trigger>
581
-
582
- <Collapsible.Content class="flex flex-col gap-y-2 pl-2">
583
- <Button variant="outline" size="icon" class="self-start" on:click={add_validation}>
584
- <i class="fa fa-plus" />
585
- </Button>
586
-
587
- {#if value.validations && value.validations.length > 0}
588
- {#each value.validations as validation, index}
589
- <div class="flex w-full items-start space-x-2">
590
- <!-- up and down sort buttons -->
591
- <div class="flex flex-col items-center">
592
- <Button
593
- variant="ghost"
594
- class="h-5 w-5 p-2"
595
- disabled={index === 0}
596
- on:click={() => move_validation_up(index)}
597
- >
598
- <i class="fa fa-chevron-up" />
599
- </Button>
600
- <Button
601
- variant="ghost"
602
- class="h-5 w-5 p-2"
603
- disabled={index === value.validations.length - 1}
604
- on:click={() => move_validation_down(index)}
605
- >
606
- <i class="fa fa-chevron-down" />
607
- </Button>
608
- </div>
609
- <div class="flex w-full flex-col items-stretch gap-1">
610
- <Select.Root
611
- selected={{
612
- label: value.validations[index].validationtype,
613
- value: value.validations[index].validationtype,
614
- }}
615
- onSelectedChange={(v) => handle_validation_selected(v, index)}
616
- >
617
- <Select.Trigger class="w-full">
618
- <Select.Value placeholder="Validation Type" />
619
- </Select.Trigger>
620
- <Select.Content>
621
- {#each validation_types as vt}
622
- <Select.Item value={vt}>{vt}</Select.Item>
623
- {/each}
624
- </Select.Content>
625
- </Select.Root>
626
- <Input
627
- placeholder="Invalid Message"
628
- bind:value={value.validations[index].invalid_message}
629
- />
630
- {#if value.validations[index].validationtype === "regex"}
631
- <Input
632
- placeholder="Regex Pattern"
633
- bind:value={value.validations[index].params.regex}
634
- />
635
- {/if}
636
- {#if value.validations[index].validationtype === "jsonata"}
637
- <Input
638
- placeholder="JSONata Expression"
639
- bind:value={value.validations[index].params.jsonata}
640
- />
641
- {/if}
642
- </div>
643
- <Button
644
- variant="destructive"
645
- class="h-5 w-5 p-2"
646
- on:click={() => remove_validation(index)}
647
- >
648
- <i class="fa fa-trash" />
649
- </Button>
650
- </div>
651
- {/each}
652
- {/if}
653
- </Collapsible.Content>
654
- </Collapsible.Root>
655
- <hr />
656
- </div>
657
- <FieldMessage {fieldStore} />