@webamoki/web-svelte 0.7.4 → 1.0.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.
Files changed (120) hide show
  1. package/README.md +83 -3
  2. package/dist/components/form/Button.svelte +24 -23
  3. package/dist/components/form/Button.svelte.d.ts +2 -2
  4. package/dist/components/form/Errors.svelte +13 -13
  5. package/dist/components/form/FieldWrapper.svelte +57 -55
  6. package/dist/components/form/FieldWrapper.svelte.d.ts +4 -4
  7. package/dist/components/form/Form.svelte +18 -14
  8. package/dist/components/form/Form.svelte.d.ts +31 -22
  9. package/dist/components/form/IconInputWrapper.svelte +30 -29
  10. package/dist/components/form/IconInputWrapper.svelte.d.ts +7 -7
  11. package/dist/components/form/fields/ChoiceField.svelte +45 -43
  12. package/dist/components/form/fields/ChoiceField.svelte.d.ts +28 -23
  13. package/dist/components/form/fields/ChoiceMultiField.svelte +44 -42
  14. package/dist/components/form/fields/ChoiceMultiField.svelte.d.ts +28 -23
  15. package/dist/components/form/fields/DateField.svelte +42 -40
  16. package/dist/components/form/fields/DateField.svelte.d.ts +29 -22
  17. package/dist/components/form/fields/HexColorField.svelte +21 -19
  18. package/dist/components/form/fields/HexColorField.svelte.d.ts +24 -19
  19. package/dist/components/form/fields/MessageField.svelte +39 -60
  20. package/dist/components/form/fields/MessageField.svelte.d.ts +33 -24
  21. package/dist/components/form/fields/NumberField.svelte +38 -36
  22. package/dist/components/form/fields/NumberField.svelte.d.ts +32 -23
  23. package/dist/components/form/fields/PasswordField.svelte +45 -39
  24. package/dist/components/form/fields/PasswordField.svelte.d.ts +28 -21
  25. package/dist/components/form/fields/SelectField.svelte +84 -79
  26. package/dist/components/form/fields/SelectField.svelte.d.ts +39 -26
  27. package/dist/components/form/fields/SelectMultiField.svelte +90 -85
  28. package/dist/components/form/fields/SelectMultiField.svelte.d.ts +38 -25
  29. package/dist/components/form/fields/TextField.svelte +31 -29
  30. package/dist/components/form/fields/TextField.svelte.d.ts +32 -23
  31. package/dist/components/form/fields/TextFieldNullable.svelte +49 -47
  32. package/dist/components/form/fields/TextFieldNullable.svelte.d.ts +32 -23
  33. package/dist/components/form/fields/TimeField.svelte +66 -64
  34. package/dist/components/form/fields/TimeField.svelte.d.ts +33 -24
  35. package/dist/components/form/fields/WeekdayChoiceField.svelte +37 -35
  36. package/dist/components/form/fields/WeekdayChoiceField.svelte.d.ts +27 -22
  37. package/dist/components/form/fields/WeekdayChoiceMultiField.svelte +37 -35
  38. package/dist/components/form/fields/WeekdayChoiceMultiField.svelte.d.ts +27 -22
  39. package/dist/components/showcase/CodeBlock.svelte +41 -41
  40. package/dist/components/showcase/Container.svelte +7 -7
  41. package/dist/components/showcase/Preview.svelte +4 -4
  42. package/dist/components/showcase/Sidebar.svelte +4 -4
  43. package/dist/components/showcase/SidebarLink.svelte +3 -3
  44. package/dist/components/ui/choice/Choice.svelte +25 -22
  45. package/dist/components/ui/choice/Choice.svelte.d.ts +7 -7
  46. package/dist/components/ui/choice/ChoiceInternal.svelte +73 -69
  47. package/dist/components/ui/choice/ChoiceInternal.svelte.d.ts +9 -9
  48. package/dist/components/ui/choice/ChoiceMulti.svelte +59 -53
  49. package/dist/components/ui/choice/ChoiceMulti.svelte.d.ts +7 -7
  50. package/dist/components/ui/choice/WeekdayChoice.svelte +22 -21
  51. package/dist/components/ui/choice/WeekdayChoice.svelte.d.ts +6 -6
  52. package/dist/components/ui/choice/WeekdayChoiceMulti.svelte +24 -22
  53. package/dist/components/ui/choice/WeekdayChoiceMulti.svelte.d.ts +6 -6
  54. package/dist/components/ui/context-menu/ContextMenu.svelte +51 -50
  55. package/dist/components/ui/context-menu/ContextMenu.svelte.d.ts +1 -1
  56. package/dist/components/ui/context-menu/ContextMenuContent.svelte +92 -91
  57. package/dist/components/ui/context-menu/ContextMenuItem.svelte +26 -25
  58. package/dist/components/ui/context-menu/ContextMenuItem.svelte.d.ts +1 -1
  59. package/dist/components/ui/context-menu/ContextMenuTrigger.svelte +16 -15
  60. package/dist/components/ui/context-menu/context-menu-state.svelte.d.ts +3 -3
  61. package/dist/components/ui/context-menu/context-menu-state.svelte.js +15 -15
  62. package/dist/components/ui/drag-drop/Draggable.svelte +73 -72
  63. package/dist/components/ui/drag-drop/Draggable.svelte.d.ts +2 -2
  64. package/dist/components/ui/drag-drop/Dropzone.svelte +56 -54
  65. package/dist/components/ui/drag-drop/Dropzone.svelte.d.ts +3 -3
  66. package/dist/components/ui/drag-drop/drag-manager.d.ts +2 -2
  67. package/dist/components/ui/drag-drop/drag-manager.js +9 -9
  68. package/dist/components/ui/index.d.ts +2 -2
  69. package/dist/components/ui/index.js +5 -5
  70. package/dist/components/ui/search/SearchBar.svelte +18 -18
  71. package/dist/components/ui/search/SearchBar.svelte.d.ts +2 -2
  72. package/dist/highlight.js +2 -2
  73. package/dist/server/form-handler.d.ts +12 -12
  74. package/dist/server/form-handler.js +17 -17
  75. package/dist/server/form-processor.d.ts +1 -1
  76. package/dist/server/form-processor.js +0 -1
  77. package/dist/shadcn/components/ui/button/button.svelte +72 -71
  78. package/dist/shadcn/components/ui/button/button.svelte.d.ts +23 -23
  79. package/dist/shadcn/components/ui/button/index.d.ts +1 -1
  80. package/dist/shadcn/components/ui/button/index.js +2 -2
  81. package/dist/shadcn/components/ui/input/index.d.ts +1 -1
  82. package/dist/shadcn/components/ui/input/index.js +2 -2
  83. package/dist/shadcn/components/ui/input/input.svelte +35 -32
  84. package/dist/shadcn/components/ui/input/input.svelte.d.ts +2 -2
  85. package/dist/shadcn/components/ui/select/index.d.ts +6 -6
  86. package/dist/shadcn/components/ui/select/index.js +7 -7
  87. package/dist/shadcn/components/ui/select/select-content.svelte +35 -34
  88. package/dist/shadcn/components/ui/select/select-content.svelte.d.ts +1 -1
  89. package/dist/shadcn/components/ui/select/select-group-heading.svelte +15 -14
  90. package/dist/shadcn/components/ui/select/select-group.svelte +2 -2
  91. package/dist/shadcn/components/ui/select/select-item.svelte +31 -31
  92. package/dist/shadcn/components/ui/select/select-label.svelte +14 -13
  93. package/dist/shadcn/components/ui/select/select-label.svelte.d.ts +1 -1
  94. package/dist/shadcn/components/ui/select/select-scroll-down-button.svelte +13 -13
  95. package/dist/shadcn/components/ui/select/select-scroll-up-button.svelte +13 -13
  96. package/dist/shadcn/components/ui/select/select-separator.svelte +13 -12
  97. package/dist/shadcn/components/ui/select/select-trigger.svelte +26 -26
  98. package/dist/shadcn/components/ui/select/select-trigger.svelte.d.ts +2 -2
  99. package/dist/shadcn/components/ui/separator/separator.svelte +14 -14
  100. package/dist/shadcn/components/ui/textarea/textarea.svelte +22 -21
  101. package/dist/shadcn/components/ui/textarea/textarea.svelte.d.ts +1 -1
  102. package/dist/shadcn/utils.d.ts +4 -4
  103. package/dist/utils/datetime/index.d.ts +68 -68
  104. package/dist/utils/datetime/index.js +124 -124
  105. package/dist/utils/email/README.md +60 -60
  106. package/dist/utils/email/aws-signer.d.ts +1 -1
  107. package/dist/utils/email/aws-signer.js +39 -39
  108. package/dist/utils/email/ses.d.ts +8 -10
  109. package/dist/utils/email/ses.js +15 -23
  110. package/dist/utils/form/index.d.ts +11 -11
  111. package/dist/utils/form/index.js +23 -24
  112. package/dist/utils/form/virtual-form.d.ts +5 -5
  113. package/dist/utils/form/virtual-form.js +58 -58
  114. package/dist/utils/search.d.ts +1 -1
  115. package/dist/utils/search.js +22 -22
  116. package/dist/utils/types/arktype.d.ts +2 -2
  117. package/dist/utils/types/arktype.js +3 -3
  118. package/dist/utils/types/db.d.ts +2 -1
  119. package/dist/utils/types/db.js +7 -7
  120. package/package.json +69 -54
package/README.md CHANGED
@@ -1,7 +1,87 @@
1
- # Setup
1
+ # Web-Svelte
2
2
 
3
- in the main css file, e.g. `app.css`, add the following line:
3
+ A shared Svelte UI components and utilities library.
4
+
5
+ ## 🚀 Setup
6
+
7
+ ### 1. Install Dependency
8
+
9
+ Install the library in your project via your preferred package manager:
10
+
11
+ ```bash
12
+ pnpm add @webamoki/web-svelte
13
+ ```
14
+
15
+ ---
16
+
17
+ ### 🎨 Styling
18
+
19
+ This library is built with Tailwind CSS. To ensure styles are applied correctly in your host project, follow these steps:
20
+
21
+ ### Theme Configuration
22
+
23
+ Create a `theme.css` file in your project (or update your existing one) to match the CSS variables required by the library's theme.
24
+
25
+ ### Main CSS Setup
26
+
27
+ In your project's main CSS entry point (e.g., `src/app.css`), include the following. Crucially, you must add the `@source` directive so Tailwind v4 scans the installed library's components for utility classes.
4
28
 
5
29
  ```css
6
- @source "../...path/node_modules/@webamoki/web-svelte/dist/**/*.{js,svelte,ts}";
30
+ @import 'tailwindcss';
31
+ @import './theme.css';
32
+
33
+ /* Tell Tailwind to scan the library for classes */
34
+ @source '../node_modules/@webamoki/web-svelte';
35
+
36
+ /* Required for the library's dark mode components */
37
+ @custom-variant dark (&:is(.dark *));
7
38
  ```
39
+
40
+ > [!NOTE]
41
+ > Adjust the relative path in `@source` if your `app.css` is deeply nested, e.g., `../../node_modules/...`.
42
+
43
+ ---
44
+
45
+ ## 🛠 Development Workflow
46
+
47
+ ### Local Development
48
+
49
+ If you want to make changes to `@webamoki/web-svelte` and test them in a host application simultaneously without publishing:
50
+
51
+ 1. Clone this repository:
52
+ ```bash
53
+ git clone git@github.com:Webamoki/Web-svelte.git
54
+ cd Web-svelte
55
+ pnpm install
56
+ ```
57
+ 2. Link the package globally:
58
+ ```bash
59
+ pnpm link --global
60
+ ```
61
+ 3. In your host application, link the local package:
62
+ ```bash
63
+ pnpm link --global @webamoki/web-svelte
64
+ ```
65
+ 4. Run the package watcher in the library directory to automatically rebuild on changes:
66
+ ```bash
67
+ pnpm watch
68
+ ```
69
+
70
+ Alternatively, to develop and test components in isolation, you can use the built-in SvelteKit app:
71
+
72
+ ```bash
73
+ pnpm dev
74
+ ```
75
+
76
+ ### Versioning & Releases
77
+
78
+ We use **Semantic Versioning** managed automatically by `semantic-release`.
79
+
80
+ Every merge to `main` is automatically analyzed based on the
81
+ **[Angular commit message format](https://github.com/angular/angular/blob/main/contributing-docs/commit-message-guidelines.md)**
82
+ to determine the correct version bump, generate a changelog, create a GitHub Release,
83
+ and publish the package to npm with OIDC provenance.
84
+
85
+ - **Patch Release (`v1.0.x`)**: `fix:`, `perf:`, etc. (Bug fixes, minor tweaks)
86
+ - **Minor Release (`v1.x.0`)**: `feat:` (New features added in a backwards-compatible manner)
87
+ - **Major Release (`vX.0.0`)**: Any commit that includes `BREAKING CHANGE:` in its footer.
@@ -1,29 +1,30 @@
1
1
  <script lang="ts">
2
- import Loader2Icon from '@lucide/svelte/icons/loader-2';
3
- import { Button } from '../../shadcn/components/ui/button/index.js';
4
- import type { ButtonProps } from '../../shadcn/components/ui/button/index.js';
2
+ import type { ButtonProps } from '../../shadcn/components/ui/button/index.js';
5
3
 
6
- type Props = ButtonProps & {
7
- loading?: boolean;
8
- class?: string;
9
- loadingMessage?: string;
10
- };
4
+ import { Button } from '../../shadcn/components/ui/button/index.js';
5
+ import Loader2Icon from '@lucide/svelte/icons/loader-2';
11
6
 
12
- let {
13
- disabled,
14
- loading,
15
- children,
16
- loadingMessage = 'Please wait',
17
- class: className,
18
- ...restProps
19
- }: Props = $props();
7
+ type Props = ButtonProps & {
8
+ class?: string;
9
+ loading?: boolean;
10
+ loadingMessage?: string;
11
+ };
12
+
13
+ let {
14
+ children,
15
+ class: className,
16
+ disabled,
17
+ loading,
18
+ loadingMessage = 'Please wait',
19
+ ...restProps
20
+ }: Props = $props();
20
21
  </script>
21
22
 
22
- <Button disabled={disabled || loading} class={className} {...restProps}>
23
- {#if loading}
24
- <Loader2Icon class="mr-2 animate-spin" />
25
- {loadingMessage}
26
- {:else}
27
- {@render children?.()}
28
- {/if}
23
+ <Button class={className} disabled={disabled || loading} {...restProps}>
24
+ {#if loading}
25
+ <Loader2Icon class="mr-2 animate-spin" />
26
+ {loadingMessage}
27
+ {:else}
28
+ {@render children?.()}
29
+ {/if}
29
30
  </Button>
@@ -1,8 +1,8 @@
1
- import { Button } from '../../shadcn/components/ui/button/index.js';
2
1
  import type { ButtonProps } from '../../shadcn/components/ui/button/index.js';
2
+ import { Button } from '../../shadcn/components/ui/button/index.js';
3
3
  type Props = ButtonProps & {
4
- loading?: boolean;
5
4
  class?: string;
5
+ loading?: boolean;
6
6
  loadingMessage?: string;
7
7
  };
8
8
  declare const Button: import("svelte").Component<Props, {}, "">;
@@ -1,20 +1,20 @@
1
1
  <script lang="ts">
2
- import { cn } from '../../shadcn/utils.js';
3
- import { FieldErrors } from 'formsnap';
2
+ import { cn } from '../../shadcn/utils.js';
3
+ import { FieldErrors } from 'formsnap';
4
4
 
5
- interface Props {
6
- class?: string;
7
- }
5
+ interface Props {
6
+ class?: string;
7
+ }
8
8
 
9
- let { class: className = '' }: Props = $props();
9
+ let { class: className = '' }: Props = $props();
10
10
  </script>
11
11
 
12
12
  <FieldErrors>
13
- {#snippet children({ errors, errorProps })}
14
- <div class={cn('space-y-1', className)}>
15
- {#each errors as error, i (i)}
16
- <span class="text-destructive" {...errorProps}>{error}</span>
17
- {/each}
18
- </div>
19
- {/snippet}
13
+ {#snippet children({ errorProps, errors })}
14
+ <div class={cn('space-y-1', className)}>
15
+ {#each errors as error, i (i)}
16
+ <span class="text-destructive" {...errorProps}>{error}</span>
17
+ {/each}
18
+ </div>
19
+ {/snippet}
20
20
  </FieldErrors>
@@ -1,64 +1,66 @@
1
1
  <script lang="ts" module>
2
- export interface FieldWrapperProps<T extends Record<string, unknown>, U extends FormPath<T>, M> {
3
- form: FsSuperForm<T, M>;
4
- name: U;
5
- label?: string;
6
- description?: string;
7
- class?: string;
8
- }
2
+ export interface FieldWrapperProps<T extends Record<string, unknown>, U extends FormPath<T>, M> {
3
+ class?: string;
4
+ description?: string;
5
+ form: FsSuperForm<T, M>;
6
+ label?: string;
7
+ name: U;
8
+ }
9
9
 
10
- export interface FormAttrs extends ControlAttrs {
11
- disabled?: HTMLInputAttributes['disabled'];
12
- readonly?: HTMLInputAttributes['readonly'];
13
- }
10
+ export interface FormAttrs extends ControlAttrs {
11
+ disabled?: HTMLInputAttributes['disabled'];
12
+ readonly?: HTMLInputAttributes['readonly'];
13
+ }
14
14
  </script>
15
15
 
16
- <script lang="ts" generics="T extends Record<string, unknown>, U extends FormPath<T>, M">
17
- import { cn } from '../../shadcn/utils.js';
18
- import {
19
- Control,
20
- Description,
21
- Field,
22
- Label,
23
- type ControlAttrs,
24
- type FsSuperForm
25
- } from 'formsnap';
26
- import type { Snippet } from 'svelte';
27
- import type { HTMLInputAttributes } from 'svelte/elements';
28
- import type { FormPath } from 'sveltekit-superforms';
29
- import Errors from './Errors.svelte';
16
+ <script generics="T extends Record<string, unknown>, U extends FormPath<T>, M" lang="ts">
17
+ import type { Snippet } from 'svelte';
18
+ import type { HTMLInputAttributes } from 'svelte/elements';
19
+ import type { FormPath } from 'sveltekit-superforms';
30
20
 
31
- interface Props extends FieldWrapperProps<T, U, M> {
32
- formElem: Snippet<[ControlAttrs]>;
33
- }
34
- let { form, name, label, description, formElem, class: className }: Props = $props();
21
+ import { cn } from '../../shadcn/utils.js';
22
+ import {
23
+ Control,
24
+ type ControlAttrs,
25
+ Description,
26
+ Field,
27
+ type FsSuperForm,
28
+ Label
29
+ } from 'formsnap';
30
+
31
+ import Errors from './Errors.svelte';
32
+
33
+ interface Props extends FieldWrapperProps<T, U, M> {
34
+ formElem: Snippet<[ControlAttrs]>;
35
+ }
36
+ let { class: className, description, form, formElem, label, name }: Props = $props();
35
37
  </script>
36
38
 
37
- <Field {form} {name}>
38
- <div class={cn('space-y-1', className)}>
39
- <Control>
40
- {#snippet children({ props })}
41
- <div class="w-full space-y-1">
42
- {#if label || description}
43
- <div>
44
- {#if label}
45
- <Label class="mb-2 text-sm font-medium">
46
- {label}
47
- {#if props['aria-required'] === 'true'}
48
- <span class="text-red-500">*</span>
49
- {/if}
50
- </Label>
51
- {/if}
52
- {#if description}
53
- <Description class="mb-2 text-sm font-medium">{description}</Description>
54
- {/if}
55
- </div>
56
- {/if}
57
- {@render formElem(props)}
58
- </div>
59
- {/snippet}
60
- </Control>
39
+ <Field {name} {form}>
40
+ <div class={cn('space-y-1', className)}>
41
+ <Control>
42
+ {#snippet children({ props })}
43
+ <div class="w-full space-y-1">
44
+ {#if label || description}
45
+ <div>
46
+ {#if label}
47
+ <Label class="mb-2 text-sm font-medium">
48
+ {label}
49
+ {#if props['aria-required'] === 'true'}
50
+ <span class="text-red-500">*</span>
51
+ {/if}
52
+ </Label>
53
+ {/if}
54
+ {#if description}
55
+ <Description class="mb-2 text-sm font-medium">{description}</Description>
56
+ {/if}
57
+ </div>
58
+ {/if}
59
+ {@render formElem(props)}
60
+ </div>
61
+ {/snippet}
62
+ </Control>
61
63
 
62
- <Errors />
63
- </div>
64
+ <Errors />
65
+ </div>
64
66
  </Field>
@@ -1,18 +1,18 @@
1
1
  export interface FieldWrapperProps<T extends Record<string, unknown>, U extends FormPath<T>, M> {
2
+ class?: string;
3
+ description?: string;
2
4
  form: FsSuperForm<T, M>;
3
- name: U;
4
5
  label?: string;
5
- description?: string;
6
- class?: string;
6
+ name: U;
7
7
  }
8
8
  export interface FormAttrs extends ControlAttrs {
9
9
  disabled?: HTMLInputAttributes['disabled'];
10
10
  readonly?: HTMLInputAttributes['readonly'];
11
11
  }
12
- import { type ControlAttrs, type FsSuperForm } from 'formsnap';
13
12
  import type { Snippet } from 'svelte';
14
13
  import type { HTMLInputAttributes } from 'svelte/elements';
15
14
  import type { FormPath } from 'sveltekit-superforms';
15
+ import { type ControlAttrs, type FsSuperForm } from 'formsnap';
16
16
  declare function $$render<T extends Record<string, unknown>, U extends FormPath<T>, M>(): {
17
17
  props: FieldWrapperProps<T, U, M> & {
18
18
  formElem: Snippet<[ControlAttrs]>;
@@ -1,19 +1,23 @@
1
- <script lang="ts" generics="T extends Record<string, unknown>, M">
2
- import type { FsSuperForm } from 'formsnap';
3
- import type { Snippet } from 'svelte';
1
+ <script generics="T extends Record<string, unknown>, M" lang="ts">
2
+ import type { FsSuperForm } from 'formsnap';
3
+ import type { Snippet } from 'svelte';
4
4
 
5
- interface Props {
6
- form: FsSuperForm<T, M>;
7
- action: string;
8
- actionName?: string;
9
- class?: string;
10
- children?: Snippet;
11
- }
5
+ interface Props {
6
+ actionName?: string;
7
+ actionPath: string;
8
+ children?: Snippet;
9
+ class?: string;
10
+ form: FsSuperForm<T, M>;
11
+ }
12
12
 
13
- let { form, action: _action, actionName, class: className, children }: Props = $props();
14
- actionName = actionName ? `?/${actionName}` : '';
13
+ let { actionName, actionPath, children, class: className, form }: Props = $props();
15
14
  </script>
16
15
 
17
- <form class={className} action="{_action}{actionName}" method="POST" use:form.enhance>
18
- {@render children?.()}
16
+ <form
17
+ class={className}
18
+ action="{actionPath ?? ''}{actionName ? `?/${actionName}` : ''}"
19
+ method="POST"
20
+ use:form.enhance
21
+ >
22
+ {@render children?.()}
19
23
  </form>
@@ -1,32 +1,41 @@
1
- import type { FsSuperForm } from 'formsnap';
2
- import type { Snippet } from 'svelte';
1
+ export default Form;
2
+ type Form<T extends Record<string, unknown>, M> = SvelteComponent<Props, {}, {}> & {
3
+ $$bindings?: "" | undefined;
4
+ } & {};
5
+ declare const Form: $$IsomorphicComponent;
6
+ type Props = {
7
+ actionName?: string | undefined;
8
+ actionPath: string;
9
+ children?: Snippet<[]> | undefined;
10
+ class?: string | undefined;
11
+ form: FsSuperForm<T, M>;
12
+ };
13
+ interface $$IsomorphicComponent {
14
+ new <T extends Record<string, unknown>, M>(options: import("svelte").ComponentConstructorOptions<ReturnType<__sveltets_Render<T, M>["props"]>>): import("svelte").SvelteComponent<ReturnType<__sveltets_Render<T, M>["props"]>, ReturnType<__sveltets_Render<T, M>["events"]>, ReturnType<__sveltets_Render<T, M>["slots"]>> & {
15
+ $$bindings?: ReturnType<__sveltets_Render<T, M>["bindings"]>;
16
+ } & ReturnType<__sveltets_Render<T, M>["exports"]>;
17
+ <T extends Record<string, unknown>, M>(internal: unknown, props: ReturnType<__sveltets_Render<T, M>["props"]> & {}): ReturnType<__sveltets_Render<T, M>["exports"]>;
18
+ z_$$bindings?: ReturnType<__sveltets_Render<any, any>["bindings"]>;
19
+ }
20
+ declare class __sveltets_Render<T extends Record<string, unknown>, M> {
21
+ props(): ReturnType<typeof $$render<T, M>>["props"];
22
+ events(): ReturnType<typeof $$render<T, M>>["events"];
23
+ slots(): ReturnType<typeof $$render<T, M>>["slots"];
24
+ bindings(): "";
25
+ exports(): {};
26
+ }
3
27
  declare function $$render<T extends Record<string, unknown>, M>(): {
4
28
  props: {
5
- form: FsSuperForm<T, M>;
6
- action: string;
7
29
  actionName?: string;
8
- class?: string;
30
+ actionPath: string;
9
31
  children?: Snippet;
32
+ class?: string;
33
+ form: FsSuperForm<T, M>;
10
34
  };
11
35
  exports: {};
12
36
  bindings: "";
13
37
  slots: {};
14
38
  events: {};
15
39
  };
16
- declare class __sveltets_Render<T extends Record<string, unknown>, M> {
17
- props(): ReturnType<typeof $$render<T, M>>['props'];
18
- events(): ReturnType<typeof $$render<T, M>>['events'];
19
- slots(): ReturnType<typeof $$render<T, M>>['slots'];
20
- bindings(): "";
21
- exports(): {};
22
- }
23
- interface $$IsomorphicComponent {
24
- new <T extends Record<string, unknown>, M>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T, M>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T, M>['props']>, ReturnType<__sveltets_Render<T, M>['events']>, ReturnType<__sveltets_Render<T, M>['slots']>> & {
25
- $$bindings?: ReturnType<__sveltets_Render<T, M>['bindings']>;
26
- } & ReturnType<__sveltets_Render<T, M>['exports']>;
27
- <T extends Record<string, unknown>, M>(internal: unknown, props: ReturnType<__sveltets_Render<T, M>['props']> & {}): ReturnType<__sveltets_Render<T, M>['exports']>;
28
- z_$$bindings?: ReturnType<__sveltets_Render<any, any>['bindings']>;
29
- }
30
- declare const Form: $$IsomorphicComponent;
31
- type Form<T extends Record<string, unknown>, M> = InstanceType<typeof Form<T, M>>;
32
- export default Form;
40
+ import { Snippet } from 'svelte';
41
+ import { FsSuperForm } from 'formsnap';
@@ -1,39 +1,40 @@
1
1
  <script lang="ts">
2
- import type { Component, Snippet } from 'svelte';
2
+ import type { Component, Snippet } from 'svelte';
3
3
 
4
- interface Props {
5
- icon?: Component;
6
- /**
7
- * Position of the icon vertically.
8
- * - 'center': Centers vertically (for single-line inputs)
9
- * - 'top': Aligns to top with padding (for multi-line inputs like textarea)
10
- */
11
- iconPosition?: 'center' | 'top';
12
- /**
13
- * Whether this wrapper should grow to fill flex container (used in layouts with buttons)
14
- */
15
- flex?: boolean;
16
- children: Snippet<[{ class: string }]>;
17
- }
4
+ interface Props {
5
+ children: Snippet<[{ class: string }]>;
6
+ /**
7
+ * Whether this wrapper should grow to fill flex container (used in layouts with buttons)
8
+ */
9
+ flex?: boolean;
10
+ icon?: Component;
11
+ /**
12
+ * Position of the icon vertically.
13
+ * - 'center': Centers vertically (for single-line inputs)
14
+ * - 'top': Aligns to top with padding (for multi-line inputs like textarea)
15
+ */
16
+ iconPosition?: 'center' | 'top';
17
+ }
18
18
 
19
- let { icon, iconPosition = 'center', flex = false, children }: Props = $props();
19
+ let { children, flex = false, icon, iconPosition = 'center' }: Props = $props();
20
20
 
21
- const iconClass =
22
- iconPosition === 'top'
23
- ? 'pointer-events-none absolute top-4 left-4 text-gray-500'
24
- : 'pointer-events-none absolute top-1/2 left-4 -translate-y-1/2 text-gray-500';
21
+ let iconClass = $derived(
22
+ iconPosition === 'top'
23
+ ? 'pointer-events-none absolute top-4 left-4 text-gray-500'
24
+ : 'pointer-events-none absolute top-1/2 left-4 -translate-y-1/2 text-gray-500'
25
+ );
25
26
 
26
- const wrapperClass = flex ? 'relative flex-1' : 'relative';
27
+ let wrapperClass = $derived(flex ? 'relative flex-1' : 'relative');
27
28
  </script>
28
29
 
29
30
  {#if icon}
30
- {@const Icon = icon}
31
- <div class={wrapperClass}>
32
- <div class={iconClass}>
33
- <Icon class="size-5" />
34
- </div>
35
- {@render children({ class: 'pl-12' })}
36
- </div>
31
+ {@const Icon = icon}
32
+ <div class={wrapperClass}>
33
+ <div class={iconClass}>
34
+ <Icon class="size-5" />
35
+ </div>
36
+ {@render children({ class: 'pl-12' })}
37
+ </div>
37
38
  {:else}
38
- {@render children({ class: '' })}
39
+ {@render children({ class: '' })}
39
40
  {/if}
@@ -1,5 +1,12 @@
1
1
  import type { Component, Snippet } from 'svelte';
2
2
  interface Props {
3
+ children: Snippet<[{
4
+ class: string;
5
+ }]>;
6
+ /**
7
+ * Whether this wrapper should grow to fill flex container (used in layouts with buttons)
8
+ */
9
+ flex?: boolean;
3
10
  icon?: Component;
4
11
  /**
5
12
  * Position of the icon vertically.
@@ -7,13 +14,6 @@ interface Props {
7
14
  * - 'top': Aligns to top with padding (for multi-line inputs like textarea)
8
15
  */
9
16
  iconPosition?: 'center' | 'top';
10
- /**
11
- * Whether this wrapper should grow to fill flex container (used in layouts with buttons)
12
- */
13
- flex?: boolean;
14
- children: Snippet<[{
15
- class: string;
16
- }]>;
17
17
  }
18
18
  declare const IconInputWrapper: Component<Props, {}, "">;
19
19
  type IconInputWrapper = ReturnType<typeof IconInputWrapper>;
@@ -1,51 +1,53 @@
1
1
  <script
2
- lang="ts"
3
- generics="V,I, K extends string | number | symbol,T extends Record<string, unknown>, U extends FormPath<T>, M"
2
+ generics="V,I, K extends number | string | symbol,T extends Record<string, unknown>, U extends FormPath<T>, M"
3
+ lang="ts"
4
4
  >
5
- import Choice, { type ChoiceProps } from '../../ui/choice/Choice.svelte';
6
- import type { FormPath } from 'sveltekit-superforms';
7
- import FieldWrapper, { type FieldWrapperProps } from '../FieldWrapper.svelte';
5
+ import type { FormPath } from 'sveltekit-superforms';
8
6
 
9
- type Props = {
10
- class?: string;
11
- } & FieldWrapperProps<T, U, M> &
12
- ChoiceProps<V, I, K>;
7
+ import Choice, { type ChoiceProps } from '../../ui/choice/Choice.svelte';
13
8
 
14
- let {
15
- items,
16
- getKey,
17
- getLabel,
18
- getValue,
19
- onChange,
20
- vertical,
21
- value = $bindable(undefined),
9
+ import FieldWrapper, { type FieldWrapperProps } from '../FieldWrapper.svelte';
22
10
 
23
- form,
24
- name,
25
- label,
26
- description,
27
- disabled,
28
- readonly,
29
- buttonContent,
30
- class: className
31
- }: Props = $props();
11
+ type Props = ChoiceProps<V, I, K> &
12
+ FieldWrapperProps<T, U, M> & {
13
+ class?: string;
14
+ };
15
+
16
+ let {
17
+ buttonContent,
18
+ class: className,
19
+ description,
20
+ disabled,
21
+ form,
22
+ getKey,
23
+ getLabel,
24
+
25
+ getValue,
26
+ items,
27
+ label,
28
+ name,
29
+ onChange,
30
+ readonly,
31
+ value = $bindable(undefined),
32
+ vertical
33
+ }: Props = $props();
32
34
  </script>
33
35
 
34
- <FieldWrapper {form} {name} {label} {description} class={className}>
35
- {#snippet formElem(props)}
36
- <Choice
37
- {items}
38
- {getKey}
39
- {getLabel}
40
- {getValue}
41
- {onChange}
42
- {buttonContent}
43
- {vertical}
44
- {disabled}
45
- {readonly}
46
- bind:value
47
- {...props}
48
- class="w-full"
49
- />
50
- {/snippet}
36
+ <FieldWrapper {name} class={className} {description} {form} {label}>
37
+ {#snippet formElem(props)}
38
+ <Choice
39
+ {buttonContent}
40
+ {disabled}
41
+ {getKey}
42
+ {getLabel}
43
+ {getValue}
44
+ {items}
45
+ {onChange}
46
+ {readonly}
47
+ {vertical}
48
+ bind:value
49
+ {...props}
50
+ class="w-full"
51
+ />
52
+ {/snippet}
51
53
  </FieldWrapper>