@webamoki/web-svelte 0.8.0 → 1.0.1
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.
- package/README.md +83 -3
- package/dist/components/form/Button.svelte +24 -23
- package/dist/components/form/Button.svelte.d.ts +2 -2
- package/dist/components/form/Errors.svelte +13 -13
- package/dist/components/form/FieldWrapper.svelte +57 -55
- package/dist/components/form/FieldWrapper.svelte.d.ts +4 -4
- package/dist/components/form/Form.svelte +18 -14
- package/dist/components/form/Form.svelte.d.ts +31 -22
- package/dist/components/form/IconInputWrapper.svelte +30 -29
- package/dist/components/form/IconInputWrapper.svelte.d.ts +7 -7
- package/dist/components/form/fields/ChoiceField.svelte +45 -43
- package/dist/components/form/fields/ChoiceField.svelte.d.ts +28 -23
- package/dist/components/form/fields/ChoiceMultiField.svelte +44 -42
- package/dist/components/form/fields/ChoiceMultiField.svelte.d.ts +28 -23
- package/dist/components/form/fields/DateField.svelte +42 -40
- package/dist/components/form/fields/DateField.svelte.d.ts +29 -22
- package/dist/components/form/fields/HexColorField.svelte +21 -19
- package/dist/components/form/fields/HexColorField.svelte.d.ts +24 -19
- package/dist/components/form/fields/MessageField.svelte +39 -60
- package/dist/components/form/fields/MessageField.svelte.d.ts +33 -24
- package/dist/components/form/fields/NumberField.svelte +38 -36
- package/dist/components/form/fields/NumberField.svelte.d.ts +32 -23
- package/dist/components/form/fields/PasswordField.svelte +45 -39
- package/dist/components/form/fields/PasswordField.svelte.d.ts +28 -21
- package/dist/components/form/fields/SelectField.svelte +84 -79
- package/dist/components/form/fields/SelectField.svelte.d.ts +39 -26
- package/dist/components/form/fields/SelectMultiField.svelte +90 -85
- package/dist/components/form/fields/SelectMultiField.svelte.d.ts +38 -25
- package/dist/components/form/fields/TextField.svelte +31 -29
- package/dist/components/form/fields/TextField.svelte.d.ts +32 -23
- package/dist/components/form/fields/TextFieldNullable.svelte +49 -47
- package/dist/components/form/fields/TextFieldNullable.svelte.d.ts +32 -23
- package/dist/components/form/fields/TimeField.svelte +66 -64
- package/dist/components/form/fields/TimeField.svelte.d.ts +33 -24
- package/dist/components/form/fields/WeekdayChoiceField.svelte +37 -35
- package/dist/components/form/fields/WeekdayChoiceField.svelte.d.ts +27 -22
- package/dist/components/form/fields/WeekdayChoiceMultiField.svelte +37 -35
- package/dist/components/form/fields/WeekdayChoiceMultiField.svelte.d.ts +27 -22
- package/dist/components/showcase/CodeBlock.svelte +41 -41
- package/dist/components/showcase/Container.svelte +7 -7
- package/dist/components/showcase/Preview.svelte +4 -4
- package/dist/components/showcase/Sidebar.svelte +4 -4
- package/dist/components/showcase/SidebarLink.svelte +3 -3
- package/dist/components/ui/choice/Choice.svelte +25 -25
- package/dist/components/ui/choice/Choice.svelte.d.ts +7 -7
- package/dist/components/ui/choice/ChoiceInternal.svelte +73 -72
- package/dist/components/ui/choice/ChoiceInternal.svelte.d.ts +9 -9
- package/dist/components/ui/choice/ChoiceMulti.svelte +59 -56
- package/dist/components/ui/choice/ChoiceMulti.svelte.d.ts +7 -7
- package/dist/components/ui/choice/WeekdayChoice.svelte +22 -21
- package/dist/components/ui/choice/WeekdayChoice.svelte.d.ts +6 -6
- package/dist/components/ui/choice/WeekdayChoiceMulti.svelte +24 -22
- package/dist/components/ui/choice/WeekdayChoiceMulti.svelte.d.ts +6 -6
- package/dist/components/ui/context-menu/ContextMenu.svelte +51 -50
- package/dist/components/ui/context-menu/ContextMenu.svelte.d.ts +1 -1
- package/dist/components/ui/context-menu/ContextMenuContent.svelte +92 -91
- package/dist/components/ui/context-menu/ContextMenuItem.svelte +26 -25
- package/dist/components/ui/context-menu/ContextMenuItem.svelte.d.ts +1 -1
- package/dist/components/ui/context-menu/ContextMenuTrigger.svelte +16 -15
- package/dist/components/ui/context-menu/context-menu-state.svelte.d.ts +3 -3
- package/dist/components/ui/context-menu/context-menu-state.svelte.js +15 -15
- package/dist/components/ui/drag-drop/Draggable.svelte +73 -72
- package/dist/components/ui/drag-drop/Draggable.svelte.d.ts +2 -2
- package/dist/components/ui/drag-drop/Dropzone.svelte +56 -54
- package/dist/components/ui/drag-drop/Dropzone.svelte.d.ts +3 -3
- package/dist/components/ui/drag-drop/drag-manager.d.ts +2 -2
- package/dist/components/ui/drag-drop/drag-manager.js +9 -9
- package/dist/components/ui/index.d.ts +2 -2
- package/dist/components/ui/index.js +5 -5
- package/dist/components/ui/search/SearchBar.svelte +18 -18
- package/dist/components/ui/search/SearchBar.svelte.d.ts +2 -2
- package/dist/highlight.js +2 -2
- package/dist/server/form-handler.d.ts +12 -12
- package/dist/server/form-handler.js +17 -17
- package/dist/server/form-processor.d.ts +1 -1
- package/dist/server/form-processor.js +0 -1
- package/dist/shadcn/components/ui/button/button.svelte +72 -71
- package/dist/shadcn/components/ui/button/button.svelte.d.ts +23 -23
- package/dist/shadcn/components/ui/button/index.d.ts +1 -1
- package/dist/shadcn/components/ui/button/index.js +2 -2
- package/dist/shadcn/components/ui/input/index.d.ts +1 -1
- package/dist/shadcn/components/ui/input/index.js +2 -2
- package/dist/shadcn/components/ui/input/input.svelte +35 -32
- package/dist/shadcn/components/ui/input/input.svelte.d.ts +2 -2
- package/dist/shadcn/components/ui/select/index.d.ts +6 -6
- package/dist/shadcn/components/ui/select/index.js +7 -7
- package/dist/shadcn/components/ui/select/select-content.svelte +35 -34
- package/dist/shadcn/components/ui/select/select-content.svelte.d.ts +1 -1
- package/dist/shadcn/components/ui/select/select-group-heading.svelte +15 -14
- package/dist/shadcn/components/ui/select/select-group.svelte +2 -2
- package/dist/shadcn/components/ui/select/select-item.svelte +31 -31
- package/dist/shadcn/components/ui/select/select-label.svelte +14 -13
- package/dist/shadcn/components/ui/select/select-label.svelte.d.ts +1 -1
- package/dist/shadcn/components/ui/select/select-scroll-down-button.svelte +13 -13
- package/dist/shadcn/components/ui/select/select-scroll-up-button.svelte +13 -13
- package/dist/shadcn/components/ui/select/select-separator.svelte +13 -12
- package/dist/shadcn/components/ui/select/select-trigger.svelte +26 -26
- package/dist/shadcn/components/ui/select/select-trigger.svelte.d.ts +2 -2
- package/dist/shadcn/components/ui/separator/separator.svelte +14 -14
- package/dist/shadcn/components/ui/textarea/textarea.svelte +22 -21
- package/dist/shadcn/components/ui/textarea/textarea.svelte.d.ts +1 -1
- package/dist/shadcn/utils.d.ts +4 -4
- package/dist/utils/datetime/index.d.ts +66 -66
- package/dist/utils/datetime/index.js +124 -124
- package/dist/utils/email/README.md +60 -60
- package/dist/utils/email/aws-signer.d.ts +1 -1
- package/dist/utils/email/aws-signer.js +39 -39
- package/dist/utils/email/ses.d.ts +8 -8
- package/dist/utils/email/ses.js +9 -9
- package/dist/utils/form/index.d.ts +11 -11
- package/dist/utils/form/index.js +23 -24
- package/dist/utils/form/virtual-form.d.ts +5 -5
- package/dist/utils/form/virtual-form.js +58 -58
- package/dist/utils/search.d.ts +1 -1
- package/dist/utils/search.js +22 -22
- package/dist/utils/types/arktype.d.ts +2 -2
- package/dist/utils/types/arktype.js +3 -3
- package/dist/utils/types/db.d.ts +2 -1
- package/dist/utils/types/db.js +7 -7
- package/package.json +47 -32
package/README.md
CHANGED
|
@@ -1,7 +1,87 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Web-Svelte
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@webamoki/web-svelte)
|
|
4
|
+
|
|
5
|
+
A shared Svelte UI components and utilities library.
|
|
6
|
+
|
|
7
|
+
## 🚀 Setup
|
|
8
|
+
|
|
9
|
+
### 1. Install Dependency
|
|
10
|
+
|
|
11
|
+
Install the library in your project via your preferred package manager:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pnpm add @webamoki/web-svelte
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### 2. 🎨 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
|
-
@
|
|
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
|
-
|
|
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
|
-
|
|
7
|
-
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
3
|
-
|
|
2
|
+
import { cn } from '../../shadcn/utils.js';
|
|
3
|
+
import { FieldErrors } from 'formsnap';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
interface Props {
|
|
6
|
+
class?: string;
|
|
7
|
+
}
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
let { class: className = '' }: Props = $props();
|
|
10
10
|
</script>
|
|
11
11
|
|
|
12
12
|
<FieldErrors>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
export interface FormAttrs extends ControlAttrs {
|
|
11
|
+
disabled?: HTMLInputAttributes['disabled'];
|
|
12
|
+
readonly?: HTMLInputAttributes['readonly'];
|
|
13
|
+
}
|
|
14
14
|
</script>
|
|
15
15
|
|
|
16
|
-
<script
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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 {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
|
|
63
|
-
|
|
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
|
-
|
|
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
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
14
|
-
actionName = actionName ? `?/${actionName}` : '';
|
|
13
|
+
let { actionName, actionPath, children, class: className, form }: Props = $props();
|
|
15
14
|
</script>
|
|
16
15
|
|
|
17
|
-
<form
|
|
18
|
-
|
|
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
|
-
|
|
2
|
-
|
|
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
|
-
|
|
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
|
-
|
|
17
|
-
|
|
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
|
-
|
|
2
|
+
import type { Component, Snippet } from 'svelte';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
19
|
+
let { children, flex = false, icon, iconPosition = 'center' }: Props = $props();
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
27
|
+
let wrapperClass = $derived(flex ? 'relative flex-1' : 'relative');
|
|
27
28
|
</script>
|
|
28
29
|
|
|
29
30
|
{#if icon}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
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
|
-
|
|
3
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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 {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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>
|