@functionalcms/svelte-components 4.10.28 → 4.10.29

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