@functionalcms/svelte-components 4.21.3 → 4.21.4
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} 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 {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
successMessage?: string;
|
|
10
10
|
submitButonText?: string;
|
|
11
11
|
fields?: Array<Field>;
|
|
12
|
-
|
|
12
|
+
onMessageSubmitted?: (result: SubmitResult) => void;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
let {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
css = '',
|
|
19
19
|
submitButonText = 'Submit',
|
|
20
20
|
successMessage = 'Your message has been delivered',
|
|
21
|
-
|
|
21
|
+
onMessageSubmitted = (result: SubmitResult) => {},
|
|
22
22
|
}: Props = $props();
|
|
23
23
|
|
|
24
24
|
let form: any;
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
body: formData
|
|
39
39
|
});
|
|
40
40
|
showMessage = response.status === 200;
|
|
41
|
-
|
|
41
|
+
onMessageSubmitted?.(showMessage ? SubmitResult.Success : SubmitResult.Error);
|
|
42
42
|
isSendingMessage = false;
|
|
43
43
|
} catch (error) {
|
|
44
44
|
console.error('Error submitting form:', error);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { type Field } from './form.js';
|
|
1
|
+
import { type Field, SubmitResult } from './form.js';
|
|
2
2
|
interface Props {
|
|
3
3
|
action: string;
|
|
4
4
|
css?: string;
|
|
5
5
|
successMessage?: string;
|
|
6
6
|
submitButonText?: string;
|
|
7
7
|
fields?: Array<Field>;
|
|
8
|
-
|
|
8
|
+
onMessageSubmitted?: (result: SubmitResult) => void;
|
|
9
9
|
}
|
|
10
10
|
declare const SmartForm: import("svelte").Component<Props, {}, "">;
|
|
11
11
|
type SmartForm = ReturnType<typeof SmartForm>;
|
|
@@ -28,3 +28,8 @@ export var LabelSize;
|
|
|
28
28
|
LabelSize["Large"] = "large";
|
|
29
29
|
LabelSize["None"] = "";
|
|
30
30
|
})(LabelSize || (LabelSize = {}));
|
|
31
|
+
export var SubmitResult;
|
|
32
|
+
(function (SubmitResult) {
|
|
33
|
+
SubmitResult["Success"] = "success";
|
|
34
|
+
SubmitResult["Error"] = "error";
|
|
35
|
+
})(SubmitResult || (SubmitResult = {}));
|
package/dist/index.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export { default as Button } from './components/form/Button.svelte';
|
|
|
29
29
|
export { default as Input } from './components/form/Input.svelte';
|
|
30
30
|
export { default as Switch } from './components/form/Switch.svelte';
|
|
31
31
|
export { default as ChoiceInput } from './components/form/ChoiceInput.svelte';
|
|
32
|
-
export { InputType, FieldType, LabelSize, type Field } from './components/form/form.js';
|
|
32
|
+
export { InputType, FieldType, LabelSize, type Field, SubmitResult } from './components/form/form.js';
|
|
33
33
|
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';
|
package/dist/index.js
CHANGED
|
@@ -42,7 +42,7 @@ export { default as Button } from './components/form/Button.svelte';
|
|
|
42
42
|
export { default as Input } from './components/form/Input.svelte';
|
|
43
43
|
export { default as Switch } from './components/form/Switch.svelte';
|
|
44
44
|
export { default as ChoiceInput } from './components/form/ChoiceInput.svelte';
|
|
45
|
-
export { InputType, FieldType, LabelSize } from './components/form/form.js';
|
|
45
|
+
export { InputType, FieldType, LabelSize, SubmitResult } from './components/form/form.js';
|
|
46
46
|
export { default as AntiBot } from './components/form/AntiBot.svelte';
|
|
47
47
|
export { default as Dropzone } from './components/form/Dropzone.svelte';
|
|
48
48
|
export { default as Select } from './components/form/Select.svelte';
|