@functionalcms/svelte-components 4.19.2 → 4.19.5
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.
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import ChoiceInput from
|
|
3
|
-
import type { Field } from
|
|
4
|
-
import Input from
|
|
5
|
-
import Select from
|
|
6
|
-
import Switch from
|
|
2
|
+
import ChoiceInput from './ChoiceInput.svelte';
|
|
3
|
+
import type { Field } from './form.js';
|
|
4
|
+
import Input from './Input.svelte';
|
|
5
|
+
import Select from './Select.svelte';
|
|
6
|
+
import Switch from './Switch.svelte';
|
|
7
7
|
|
|
8
8
|
interface Props {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
action: string;
|
|
10
|
+
css?: string;
|
|
11
|
+
successMessage?: string;
|
|
12
|
+
submitButonText?: string;
|
|
13
|
+
fields?: Array<Field>;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
let {
|
|
17
|
+
action,
|
|
18
|
+
fields = [],
|
|
19
|
+
css = '',
|
|
20
|
+
submitButonText = 'Submit',
|
|
21
|
+
successMessage = 'Your message has been delivered'
|
|
22
|
+
}: Props = $props();
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
let form: any;
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
const showMessage = $state(false);
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
28
|
+
const submitContactForm = async (event: Event) => {
|
|
29
|
+
event.preventDefault();
|
|
30
|
+
const formData = new FormData(form);
|
|
31
|
+
const response = await fetch('/contact', {
|
|
32
|
+
method: 'POST',
|
|
33
|
+
body: formData
|
|
34
|
+
});
|
|
35
|
+
console.log('Form submitted', response);
|
|
36
|
+
};
|
|
37
37
|
</script>
|
|
38
38
|
|
|
39
|
-
<form method="POST"
|
|
39
|
+
<form method="POST" {action} class={css}>
|
|
40
40
|
<fieldset>
|
|
41
41
|
{#each fields as field}
|
|
42
42
|
<div>
|
|
@@ -49,5 +49,6 @@
|
|
|
49
49
|
/>
|
|
50
50
|
</div>
|
|
51
51
|
{/each}
|
|
52
|
+
<button onclick={submitContactForm}>{submitButonText}</button>
|
|
52
53
|
</fieldset>
|
|
53
54
|
</form>
|