@functionalcms/svelte-components 4.10.49 → 4.11.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.
@@ -7,6 +7,7 @@
7
7
  import { Placement } from '../Styling.js';
8
8
  import Button from './Button.svelte';
9
9
  import { superForm } from 'sveltekit-superforms';
10
+ import { translator } from '../../translations/translator.ts';
10
11
 
11
12
  interface FormButton {
12
13
  label: string;
@@ -21,6 +22,7 @@
21
22
  superform: Record<string, unknown>;
22
23
  buttonPosition: Placement;
23
24
  buttonsContainer: string;
25
+ translate: any;
24
26
  }
25
27
 
26
28
  let {
@@ -29,10 +31,12 @@
29
31
  superform = {},
30
32
  action = '',
31
33
  buttonsContainer = '',
32
- buttonPosition = Placement.Bottom
34
+ buttonPosition = Placement.Bottom,
35
+ translate
33
36
  }: Partial<Props> = $props();
34
37
 
35
38
  const { form, enhance } = superForm(superform);
39
+ const t = translator(translate);
36
40
  </script>
37
41
 
38
42
  {#snippet renderButtons()}
@@ -55,22 +59,23 @@
55
59
  <Switch
56
60
  name={field.name}
57
61
  id={field.name}
58
- label={field.name}
62
+ label={t(field.name)}
59
63
  isChecked={$form[field.name]}
60
64
  />
61
65
  {:else if field.type === 'enum' && field.meta.type === 'select'}
62
66
  <Select
63
67
  name={field.name}
64
68
  id={field.name}
65
- label={field.name}
69
+ label={t(field.name)}
66
70
  options={mapEntiresToOptions(field)}
67
71
  singleSelected={$form[field.name]}
72
+ defaultOptionLabel={t('selectOption')}
68
73
  />
69
74
  {:else if field.type === 'enum'}
70
75
  <ChoiceInput
71
76
  name={field.name}
72
77
  id={field.name}
73
- label={field.name}
78
+ label={t(field.name)}
74
79
  type={field.meta.type}
75
80
  options={mapEntiresToOptions(field)}
76
81
  checkedOptions={[field.default]}
@@ -80,7 +85,7 @@
80
85
  <Input
81
86
  name={field.name}
82
87
  id={field.name}
83
- label={field.name}
88
+ label={t(field.name)}
84
89
  type={field.meta.type}
85
90
  isRequired={field.isRequired}
86
91
  value={$form[field.name]}
@@ -11,6 +11,7 @@ declare const Form: import("svelte").Component<Partial<{
11
11
  superform: Record<string, unknown>;
12
12
  buttonPosition: Placement;
13
13
  buttonsContainer: string;
14
+ translate: any;
14
15
  }>, {}, "">;
15
16
  type Form = ReturnType<typeof Form>;
16
17
  export default Form;
@@ -22,7 +22,7 @@
22
22
  containerCss = '',
23
23
  leftCss = 'w50p',
24
24
  rightCss = 'w50p'
25
- }: TwoColumnLayoutProps = $props();
25
+ }: Partial<TwoColumnLayoutProps> = $props();
26
26
 
27
27
  let containerCssEx = cn(
28
28
  'flex flex-row-dynamic',
@@ -1,5 +1,5 @@
1
1
  import type { Snippet } from 'svelte';
2
- interface TwoColumnLayoutProps {
2
+ declare const TwoColumnsLayout: import("svelte").Component<Partial<{
3
3
  leftRender: Snippet;
4
4
  rightRender: Snippet;
5
5
  containerCss: string;
@@ -7,7 +7,6 @@ interface TwoColumnLayoutProps {
7
7
  rightCss: string;
8
8
  isFullWidth: boolean;
9
9
  isFullHeight: boolean;
10
- }
11
- declare const TwoColumnsLayout: import("svelte").Component<TwoColumnLayoutProps, {}, "">;
10
+ }>, {}, "">;
12
11
  type TwoColumnsLayout = ReturnType<typeof TwoColumnsLayout>;
13
12
  export default TwoColumnsLayout;
@@ -0,0 +1 @@
1
+ export declare const translator: (translations: any) => (key: string) => any;
@@ -0,0 +1,5 @@
1
+ export const translator = (translations) => {
2
+ return (key) => {
3
+ return translations[key] || key;
4
+ };
5
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@functionalcms/svelte-components",
3
- "version": "4.10.49",
3
+ "version": "4.11.0",
4
4
  "watch": {
5
5
  "build": {
6
6
  "patterns": [