@functionalcms/svelte-components 4.26.0 → 4.27.0

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,6 +1,6 @@
1
1
  <script lang="ts">
2
2
  import Input from './Input.svelte';
3
- import { type Field, FieldType, InputType, SubmitResult} from './form.js';
3
+ import { type Field, FieldType, InputType, SubmitResult } from './form.js';
4
4
  import { fade } from 'svelte/transition';
5
5
 
6
6
  interface Props {
@@ -18,7 +18,7 @@
18
18
  css = '',
19
19
  submitButonText = 'Submit',
20
20
  successMessage,
21
- onMessageSubmitted,
21
+ onMessageSubmitted
22
22
  }: Props = $props();
23
23
 
24
24
  let form: any;
@@ -27,7 +27,7 @@
27
27
 
28
28
  const submitContactForm = async (event: Event) => {
29
29
  try {
30
- debugger
30
+ debugger;
31
31
  if (isSendingMessage) {
32
32
  return;
33
33
  }
@@ -64,6 +64,7 @@
64
64
  placeholder={field.placeholder}
65
65
  type={field.subType}
66
66
  isRequired={field.isRequired || false}
67
+ value={field.value}
67
68
  />
68
69
  {:else if field.type === FieldType.Textarea}
69
70
  <Input
@@ -73,25 +74,56 @@
73
74
  type={InputType.Textarea}
74
75
  placeholder={field.placeholder}
75
76
  isRequired={field.isRequired || false}
77
+ value={field.value}
78
+ />
79
+ {:else if field.type === FieldType.Hidden}
80
+ <input
81
+ id={field.name}
82
+ name={field.name}
83
+ value={field.value}
84
+ type="hidden"
85
+ required={field.isRequired || false}
76
86
  />
77
87
  {:else if field.type === FieldType.Radio}
78
88
  {#each field.options as option}
79
89
  <label>
80
90
  {#if option.checked}
81
- <input type="radio" name={field.name} value={option.value} required={field.isRequired} checked/>
91
+ <input
92
+ type="radio"
93
+ name={field.name}
94
+ value={option.value}
95
+ required={field.isRequired}
96
+ checked
97
+ />
82
98
  {:else}
83
- <input type="radio" name={field.name} value={option.value} required={field.isRequired}/>
99
+ <input
100
+ type="radio"
101
+ name={field.name}
102
+ value={option.value}
103
+ required={field.isRequired}
104
+ />
84
105
  {/if}
85
106
  {option.label}
86
- </label>
107
+ </label>
87
108
  {/each}
88
109
  {:else if field.type === FieldType.Checkbox}
89
110
  {#each field.options as option}
90
111
  <label>
91
112
  {#if option.checked}
92
- <input type="checkbox" name={field.name} value={option.value} required={field.isRequired} checked/>
113
+ <input
114
+ type="checkbox"
115
+ name={field.name}
116
+ value={option.value}
117
+ required={field.isRequired}
118
+ checked
119
+ />
93
120
  {:else}
94
- <input type="checkbox" name={field.name} value={option.value} required={field.isRequired} />
121
+ <input
122
+ type="checkbox"
123
+ name={field.name}
124
+ value={option.value}
125
+ required={field.isRequired}
126
+ />
95
127
  {/if}
96
128
  {option.label}
97
129
  </label>
@@ -2,7 +2,8 @@ export declare enum FieldType {
2
2
  Input = "input",
3
3
  Textarea = "textarea",
4
4
  Radio = "radio",
5
- Checkbox = "checkbox"
5
+ Checkbox = "checkbox",
6
+ Hidden = "hidden"
6
7
  }
7
8
  export declare enum InputType {
8
9
  Text = "text",
@@ -38,6 +39,7 @@ export interface Field {
38
39
  checked?: boolean;
39
40
  }>;
40
41
  checked?: boolean;
42
+ value?: string | number | boolean;
41
43
  }
42
44
  export declare enum SubmitResult {
43
45
  Success = "success",
@@ -4,6 +4,7 @@ export var FieldType;
4
4
  FieldType["Textarea"] = "textarea";
5
5
  FieldType["Radio"] = "radio";
6
6
  FieldType["Checkbox"] = "checkbox";
7
+ FieldType["Hidden"] = "hidden";
7
8
  })(FieldType || (FieldType = {}));
8
9
  export var InputType;
9
10
  (function (InputType) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@functionalcms/svelte-components",
3
- "version": "4.26.0",
3
+ "version": "4.27.0",
4
4
  "license": "MIT",
5
5
  "watch": {
6
6
  "build": {