@functionalcms/svelte-components 4.10.46 → 4.10.48

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
@@ -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;
@@ -7,6 +7,7 @@ export interface Field {
7
7
  }
8
8
  export declare function serialize(schema: any): Promise<Field[]>;
9
9
  export declare function createForm(schema: any): Promise<import("sveltekit-superforms").SuperValidated<{}, any, {}>>;
10
+ export declare function readForm(formRequest: any, schema: any): Promise<import("sveltekit-superforms").SuperValidated<{}, any, {}>>;
10
11
  export declare function mapEntiresToOptions(field: Field): {
11
12
  label: string;
12
13
  value: string;
@@ -21,6 +21,10 @@ export async function createForm(schema) {
21
21
  const form = await superValidate(yup(schema), {});
22
22
  return form;
23
23
  }
24
+ export async function readForm(formRequest, schema) {
25
+ const form = await superValidate(formRequest, yup(schema));
26
+ return form;
27
+ }
24
28
  export function mapEntiresToOptions(field) {
25
29
  return (field?.entries?.map((entry) => ({
26
30
  label: entry,
package/dist/index.d.ts CHANGED
@@ -34,7 +34,7 @@ export { default as AntiBot } from './components/form/AntiBot.svelte';
34
34
  export { default as Dropzone } from './components/form/Dropzone.svelte';
35
35
  export { default as Select } from './components/form/Select.svelte';
36
36
  export { default as Form } from './components/form/Form.svelte';
37
- export { type Field, serialize, createForm, mapEntiresToOptions } from './components/form/form.js';
37
+ export { type Field, serialize, createForm, readForm, mapEntiresToOptions } from './components/form/form.js';
38
38
  export { default as Markdown } from './components/content/Markdown.svelte';
39
39
  export { type BlogPost, listAllPosts, importPost } from './components/blog/blog.js';
40
40
  export { default as EasyTools } from './components/integrations/EasyTools.svelte';
package/dist/index.js CHANGED
@@ -46,7 +46,7 @@ export { default as AntiBot } from './components/form/AntiBot.svelte';
46
46
  export { default as Dropzone } from './components/form/Dropzone.svelte';
47
47
  export { default as Select } from './components/form/Select.svelte';
48
48
  export { default as Form } from './components/form/Form.svelte';
49
- export { serialize, createForm, mapEntiresToOptions } from './components/form/form.js';
49
+ export { serialize, createForm, readForm, mapEntiresToOptions } from './components/form/form.js';
50
50
  /*
51
51
  * Content
52
52
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@functionalcms/svelte-components",
3
- "version": "4.10.46",
3
+ "version": "4.10.48",
4
4
  "watch": {
5
5
  "build": {
6
6
  "patterns": [