@functionalcms/svelte-components 4.10.28 → 4.10.31
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 { cn } from '../../utils.js';
|
|
3
|
-
import { Orientation } from '../Styling.
|
|
3
|
+
import { Orientation } from '../Styling.js';
|
|
4
4
|
import type { ChoiceInputOption, ChoiceInputSize, ChoiceInputType, HtmlParts } from './utils.js';
|
|
5
5
|
|
|
6
6
|
interface Props {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Orientation } from '../Styling.
|
|
1
|
+
import { Orientation } from '../Styling.js';
|
|
2
2
|
import type { ChoiceInputOption, ChoiceInputSize, ChoiceInputType, HtmlParts } from './utils.js';
|
|
3
3
|
declare const ChoiceInput: import("svelte").Component<Partial<{
|
|
4
4
|
isSkinned: boolean;
|
|
@@ -1,48 +1,84 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
import ChoiceInput from
|
|
4
|
-
import Input from
|
|
5
|
-
import Select from
|
|
6
|
-
import Switch from
|
|
2
|
+
import { mapEntiresToOptions, type Field } from './form.js';
|
|
3
|
+
import ChoiceInput from './ChoiceInput.svelte';
|
|
4
|
+
import Input from './Input.svelte';
|
|
5
|
+
import Select from './Select.svelte';
|
|
6
|
+
import Switch from './Switch.svelte';
|
|
7
|
+
import { Placement } from '../Styling.ts';
|
|
8
|
+
import { addTransactionSupport } from 'ioredis/built/transaction.js';
|
|
9
|
+
import Button from './Button.svelte';
|
|
7
10
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
interface FormButton {
|
|
12
|
+
label: string;
|
|
13
|
+
type: 'submit' | 'reset' | 'button';
|
|
14
|
+
click?: () => void;
|
|
15
|
+
}
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
interface Props {
|
|
18
|
+
buttons: Array<FormButton>;
|
|
19
|
+
formDestination: string;
|
|
20
|
+
schema: Array<Field>;
|
|
21
|
+
buttonPosition: Placement;
|
|
22
|
+
buttonsContainer: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let {
|
|
26
|
+
buttons = [],
|
|
27
|
+
schema,
|
|
28
|
+
formDestination = '',
|
|
29
|
+
buttonsContainer = '',
|
|
30
|
+
buttonPosition = Placement.Bottom
|
|
31
|
+
}: Partial<Props> = $props();
|
|
14
32
|
</script>
|
|
15
33
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
34
|
+
{#snippet renderButtons()}
|
|
35
|
+
<div class={buttonsContainer}>
|
|
36
|
+
{#each buttons as action}
|
|
37
|
+
<Button type={action.type} click={action.click}>{action.label}</Button>
|
|
38
|
+
{/each}
|
|
39
|
+
</div>
|
|
40
|
+
{/snippet}
|
|
41
|
+
|
|
42
|
+
<form method="POST" action={formDestination}>
|
|
43
|
+
<fieldset>
|
|
44
|
+
{#if buttonPosition === Placement.Top}
|
|
45
|
+
{@render renderButtons()}
|
|
46
|
+
{/if}
|
|
47
|
+
|
|
48
|
+
<div>
|
|
49
|
+
{#each schema as field}
|
|
50
|
+
{#if field.type === 'boolean'}
|
|
51
|
+
<Switch name={field.name} id={field.name} label={field.name} />
|
|
52
|
+
{:else if field.type === 'enum' && field.meta.type === 'select'}
|
|
53
|
+
<Select
|
|
54
|
+
name={field.name}
|
|
55
|
+
id={field.name}
|
|
56
|
+
label={field.name}
|
|
57
|
+
options={mapEntiresToOptions(field)}
|
|
58
|
+
singleSelected="LOW"
|
|
59
|
+
/>
|
|
60
|
+
{:else if field.type === 'enum'}
|
|
61
|
+
<ChoiceInput
|
|
62
|
+
name={field.name}
|
|
63
|
+
id={field.name}
|
|
64
|
+
label={field.name}
|
|
65
|
+
type={field.meta.type}
|
|
66
|
+
options={mapEntiresToOptions(field)}
|
|
67
|
+
/>
|
|
68
|
+
{:else if field.type === 'string' || field.type === 'number'}
|
|
69
|
+
<Input
|
|
70
|
+
name={field.name}
|
|
71
|
+
id={field.name}
|
|
72
|
+
label={field.name}
|
|
73
|
+
type={field.meta.type}
|
|
74
|
+
isRequired={field.isRequired}
|
|
75
|
+
/>
|
|
76
|
+
{/if}
|
|
77
|
+
{/each}
|
|
78
|
+
</div>
|
|
79
|
+
|
|
80
|
+
{#if buttonPosition !== Placement.Top}
|
|
81
|
+
{@render renderButtons()}
|
|
82
|
+
{/if}
|
|
83
|
+
</fieldset>
|
|
48
84
|
</form>
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import { type Field } from
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { type Field } from './form.js';
|
|
2
|
+
import { Placement } from '../Styling.ts';
|
|
3
|
+
declare const Form: import("svelte").Component<Partial<{
|
|
4
|
+
buttons: Array<{
|
|
5
|
+
label: string;
|
|
6
|
+
type: "submit" | "reset" | "button";
|
|
7
|
+
click?: () => void;
|
|
8
|
+
}>;
|
|
9
|
+
formDestination: string;
|
|
4
10
|
schema: Array<Field>;
|
|
5
|
-
|
|
6
|
-
|
|
11
|
+
buttonPosition: Placement;
|
|
12
|
+
buttonsContainer: string;
|
|
13
|
+
}>, {}, "">;
|
|
7
14
|
type Form = ReturnType<typeof Form>;
|
|
8
15
|
export default Form;
|