@functionalcms/svelte-components 4.10.45 → 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 name={field.name} id={field.name} label={field.name} />
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="LOW"
67
+ singleSelected={$form[field.name]}
58
68
  />
59
69
  {:else if field.type === 'enum'}
60
70
  <ChoiceInput
@@ -63,7 +73,7 @@
63
73
  label={field.name}
64
74
  type={field.meta.type}
65
75
  options={mapEntiresToOptions(field)}
66
- selected={field.default}
76
+ checkedOptions={[field.default]}
67
77
  isFieldset={true}
68
78
  />
69
79
  {:else if field.type === 'string' || field.type === 'number'}
@@ -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}
@@ -8,6 +8,7 @@ declare const Form: import("svelte").Component<Partial<{
8
8
  }>;
9
9
  action: string;
10
10
  schema: Array<Field>;
11
+ superform: Record<string, unknown>;
11
12
  buttonPosition: Placement;
12
13
  buttonsContainer: string;
13
14
  }>, {}, "">;
@@ -60,7 +60,7 @@
60
60
  isUnderlined = false,
61
61
  labelSize = '',
62
62
  type = 'text',
63
- value = '',
63
+ value = $bindable(''),
64
64
  placeholder= '',
65
65
  ...restProps
66
66
  }: Partial<Props> = $props();
@@ -25,6 +25,6 @@ declare const Input: import("svelte").Component<Partial<{
25
25
  value: string | any;
26
26
  addonLeft: Snippet;
27
27
  addonRight: Snippet;
28
- }>, {}, "">;
28
+ }>, {}, "value">;
29
29
  type Input = ReturnType<typeof Input>;
30
30
  export default Input;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@functionalcms/svelte-components",
3
- "version": "4.10.45",
3
+ "version": "4.10.47",
4
4
  "watch": {
5
5
  "build": {
6
6
  "patterns": [