@functionalcms/svelte-components 4.10.46 → 4.10.47
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.
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import Switch from './Switch.svelte';
|
|
7
7
|
import { Placement } from '../Styling.js';
|
|
8
8
|
import Button from './Button.svelte';
|
|
9
|
+
import { superForm } from 'sveltekit-superforms';
|
|
9
10
|
|
|
10
11
|
interface FormButton {
|
|
11
12
|
label: string;
|
|
@@ -17,6 +18,7 @@
|
|
|
17
18
|
buttons: Array<FormButton>;
|
|
18
19
|
action: string;
|
|
19
20
|
schema: Array<Field>;
|
|
21
|
+
superform: Record<string, unknown>;
|
|
20
22
|
buttonPosition: Placement;
|
|
21
23
|
buttonsContainer: string;
|
|
22
24
|
}
|
|
@@ -24,10 +26,13 @@
|
|
|
24
26
|
let {
|
|
25
27
|
buttons = [],
|
|
26
28
|
schema = [],
|
|
29
|
+
superform = {},
|
|
27
30
|
action = '',
|
|
28
31
|
buttonsContainer = '',
|
|
29
32
|
buttonPosition = Placement.Bottom
|
|
30
33
|
}: Partial<Props> = $props();
|
|
34
|
+
|
|
35
|
+
const { form, enhance } = superForm(superform);
|
|
31
36
|
</script>
|
|
32
37
|
|
|
33
38
|
{#snippet renderButtons()}
|
|
@@ -38,7 +43,7 @@
|
|
|
38
43
|
</div>
|
|
39
44
|
{/snippet}
|
|
40
45
|
|
|
41
|
-
<form method="POST" {action}>
|
|
46
|
+
<form method="POST" {action} use:enhance>
|
|
42
47
|
<fieldset>
|
|
43
48
|
{#if buttonPosition === Placement.Top}
|
|
44
49
|
{@render renderButtons()}
|
|
@@ -47,14 +52,19 @@
|
|
|
47
52
|
<div>
|
|
48
53
|
{#each schema as field}
|
|
49
54
|
{#if field.type === 'boolean'}
|
|
50
|
-
<Switch
|
|
55
|
+
<Switch
|
|
56
|
+
name={field.name}
|
|
57
|
+
id={field.name}
|
|
58
|
+
label={field.name}
|
|
59
|
+
isChecked={$form[field.name]}
|
|
60
|
+
/>
|
|
51
61
|
{:else if field.type === 'enum' && field.meta.type === 'select'}
|
|
52
62
|
<Select
|
|
53
63
|
name={field.name}
|
|
54
64
|
id={field.name}
|
|
55
65
|
label={field.name}
|
|
56
66
|
options={mapEntiresToOptions(field)}
|
|
57
|
-
singleSelected=
|
|
67
|
+
singleSelected={$form[field.name]}
|
|
58
68
|
/>
|
|
59
69
|
{:else if field.type === 'enum'}
|
|
60
70
|
<ChoiceInput
|
|
@@ -73,6 +83,7 @@
|
|
|
73
83
|
label={field.name}
|
|
74
84
|
type={field.meta.type}
|
|
75
85
|
isRequired={field.isRequired}
|
|
86
|
+
bind:value={$form[field.name]}
|
|
76
87
|
/>
|
|
77
88
|
{/if}
|
|
78
89
|
{/each}
|