@functionalcms/svelte-components 4.21.1 → 4.21.3
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.
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
successMessage?: string;
|
|
10
10
|
submitButonText?: string;
|
|
11
11
|
fields?: Array<Field>;
|
|
12
|
+
onSubmit?: () => void;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
let {
|
|
@@ -16,7 +17,8 @@
|
|
|
16
17
|
fields = [],
|
|
17
18
|
css = '',
|
|
18
19
|
submitButonText = 'Submit',
|
|
19
|
-
successMessage = 'Your message has been delivered'
|
|
20
|
+
successMessage = 'Your message has been delivered',
|
|
21
|
+
onSubmit = null,
|
|
20
22
|
}: Props = $props();
|
|
21
23
|
|
|
22
24
|
let form: any;
|
|
@@ -36,6 +38,7 @@
|
|
|
36
38
|
body: formData
|
|
37
39
|
});
|
|
38
40
|
showMessage = response.status === 200;
|
|
41
|
+
onSubmit?.();
|
|
39
42
|
isSendingMessage = false;
|
|
40
43
|
} catch (error) {
|
|
41
44
|
console.error('Error submitting form:', error);
|
|
@@ -72,14 +75,22 @@
|
|
|
72
75
|
{:else if field.type === FieldType.Radio}
|
|
73
76
|
{#each field.options as option}
|
|
74
77
|
<label>
|
|
75
|
-
|
|
78
|
+
{#if option.checked}
|
|
79
|
+
<input type="radio" name={field.name} value={option.value} required={field.isRequired} checked/>
|
|
80
|
+
{:else}
|
|
81
|
+
<input type="radio" name={field.name} value={option.value} required={field.isRequired}/>
|
|
82
|
+
{/if}
|
|
76
83
|
{option.label}
|
|
77
84
|
</label>
|
|
78
85
|
{/each}
|
|
79
86
|
{:else if field.type === FieldType.Checkbox}
|
|
80
87
|
{#each field.options as option}
|
|
81
88
|
<label>
|
|
89
|
+
{#if option.checked}
|
|
90
|
+
<input type="checkbox" name={field.name} value={option.value} required={field.isRequired} checked/>
|
|
91
|
+
{:else}
|
|
82
92
|
<input type="checkbox" name={field.name} value={option.value} required={field.isRequired} />
|
|
93
|
+
{/if}
|
|
83
94
|
{option.label}
|
|
84
95
|
</label>
|
|
85
96
|
{/each}
|