@webamoki/web-svelte 0.1.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Webamoki
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # Svelte library
2
+
3
+ Everything you need to build a Svelte library, powered by [`sv`](https://npmjs.com/package/sv).
4
+
5
+ Read more about creating a library [in the docs](https://svelte.dev/docs/kit/packaging).
6
+
7
+ ## Creating a project
8
+
9
+ If you're seeing this, you've probably already done this step. Congrats!
10
+
11
+ ```sh
12
+ # create a new project in the current directory
13
+ npx sv create
14
+
15
+ # create a new project in my-app
16
+ npx sv create my-app
17
+ ```
18
+
19
+ ## Developing
20
+
21
+ Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
22
+
23
+ ```sh
24
+ npm run dev
25
+
26
+ # or start the server and open the app in a new browser tab
27
+ npm run dev -- --open
28
+ ```
29
+
30
+ Everything inside `src/lib` is part of your library, everything inside `src/routes` can be used as a showcase or preview app.
31
+
32
+ ## Building
33
+
34
+ To build your library:
35
+
36
+ ```sh
37
+ npm pack
38
+ ```
39
+
40
+ To create a production version of your showcase app:
41
+
42
+ ```sh
43
+ npm run build
44
+ ```
45
+
46
+ You can preview the production build with `npm run preview`.
47
+
48
+ > To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.
49
+
50
+ ## Publishing
51
+
52
+ Go into the `package.json` and give your package the desired name through the `"name"` option. Also consider adding a `"license"` field and point it to a `LICENSE` file which you can create from a template (one popular option is the [MIT license](https://opensource.org/license/mit/)).
53
+
54
+ To publish your library to [npm](https://www.npmjs.com):
55
+
56
+ ```sh
57
+ npm publish
58
+ ```
@@ -0,0 +1,20 @@
1
+ <script lang="ts">
2
+ import { cn } from '../../shadcn/utils.js';
3
+ import { FieldErrors } from 'formsnap';
4
+
5
+ interface Props {
6
+ class?: string;
7
+ }
8
+
9
+ let { class: className = '' }: Props = $props();
10
+ </script>
11
+
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}
20
+ </FieldErrors>
@@ -0,0 +1,6 @@
1
+ interface Props {
2
+ class?: string;
3
+ }
4
+ declare const Errors: import("svelte").Component<Props, {}, "">;
5
+ type Errors = ReturnType<typeof Errors>;
6
+ export default Errors;
@@ -0,0 +1,51 @@
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
+ }
8
+ </script>
9
+
10
+ <script lang="ts" generics="T extends Record<string, unknown>, U extends FormPath<T>, M">
11
+ import {
12
+ Control,
13
+ Description,
14
+ Field,
15
+ Label,
16
+ type ControlAttrs,
17
+ type FsSuperForm
18
+ } from 'formsnap';
19
+ import type { Snippet } from 'svelte';
20
+ import type { FormPath } from 'sveltekit-superforms';
21
+ import Errors from './Errors.svelte';
22
+
23
+ interface Props extends FieldWrapperProps<T, U, M> {
24
+ formElem: Snippet<[ControlAttrs]>;
25
+ }
26
+ let { form, name, label, description, formElem }: Props = $props();
27
+ </script>
28
+
29
+ <Field {form} {name}>
30
+ <div class="space-y-1">
31
+ <Control>
32
+ {#snippet children({ props })}
33
+ <div class="space-y-1">
34
+ {#if label || description}
35
+ <div>
36
+ {#if label}
37
+ <Label class="text-sm font-medium">{label}</Label>
38
+ {/if}
39
+ {#if description}
40
+ <Description class="text-sm font-medium">{description}</Description>
41
+ {/if}
42
+ </div>
43
+ {/if}
44
+ {@render formElem(props)}
45
+ </div>
46
+ {/snippet}
47
+ </Control>
48
+
49
+ <Errors />
50
+ </div>
51
+ </Field>
@@ -0,0 +1,35 @@
1
+ export interface FieldWrapperProps<T extends Record<string, unknown>, U extends FormPath<T>, M> {
2
+ form: FsSuperForm<T, M>;
3
+ name: U;
4
+ label?: string;
5
+ description?: string;
6
+ }
7
+ import { type ControlAttrs, type FsSuperForm } from 'formsnap';
8
+ import type { Snippet } from 'svelte';
9
+ import type { FormPath } from 'sveltekit-superforms';
10
+ declare function $$render<T extends Record<string, unknown>, U extends FormPath<T>, M>(): {
11
+ props: FieldWrapperProps<T, U, M> & {
12
+ formElem: Snippet<[ControlAttrs]>;
13
+ };
14
+ exports: {};
15
+ bindings: "";
16
+ slots: {};
17
+ events: {};
18
+ };
19
+ declare class __sveltets_Render<T extends Record<string, unknown>, U extends FormPath<T>, M> {
20
+ props(): ReturnType<typeof $$render<T, U, M>>['props'];
21
+ events(): ReturnType<typeof $$render<T, U, M>>['events'];
22
+ slots(): ReturnType<typeof $$render<T, U, M>>['slots'];
23
+ bindings(): "";
24
+ exports(): {};
25
+ }
26
+ interface $$IsomorphicComponent {
27
+ new <T extends Record<string, unknown>, U extends FormPath<T>, M>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T, U, M>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T, U, M>['props']>, ReturnType<__sveltets_Render<T, U, M>['events']>, ReturnType<__sveltets_Render<T, U, M>['slots']>> & {
28
+ $$bindings?: ReturnType<__sveltets_Render<T, U, M>['bindings']>;
29
+ } & ReturnType<__sveltets_Render<T, U, M>['exports']>;
30
+ <T extends Record<string, unknown>, U extends FormPath<T>, M>(internal: unknown, props: ReturnType<__sveltets_Render<T, U, M>['props']> & {}): ReturnType<__sveltets_Render<T, U, M>['exports']>;
31
+ z_$$bindings?: ReturnType<__sveltets_Render<any, any, any>['bindings']>;
32
+ }
33
+ declare const FieldWrapper: $$IsomorphicComponent;
34
+ type FieldWrapper<T extends Record<string, unknown>, U extends FormPath<T>, M> = InstanceType<typeof FieldWrapper<T, U, M>>;
35
+ export default FieldWrapper;
@@ -0,0 +1,37 @@
1
+ <script lang="ts" generics="T extends Record<string, unknown>, U extends FormPath<T>, M">
2
+ import type { FormPath } from 'sveltekit-superforms';
3
+ import FieldWrapper, { type FieldWrapperProps } from '../FieldWrapper.svelte';
4
+ import { Input } from '../../../shadcn/components/ui/input/index.js';
5
+ import { Eye, EyeOff } from '@lucide/svelte';
6
+
7
+ interface Props extends FieldWrapperProps<T, U, M> {
8
+ value?: string;
9
+ }
10
+ let { value = $bindable(), ...fieldProps }: Props = $props();
11
+
12
+ let show = $state(false);
13
+ let inputType = $derived(show ? 'text' : 'password');
14
+ </script>
15
+
16
+ <FieldWrapper {...fieldProps}>
17
+ {#snippet formElem(props)}
18
+ <div class="flex w-full items-center gap-2">
19
+ <!-- Input itself -->
20
+ <Input type={inputType} bind:value {...props} />
21
+
22
+ <!-- Show/hide button outside input -->
23
+ <button
24
+ type="button"
25
+ class="flex cursor-pointer items-center justify-center rounded-md border px-3 py-2 text-gray-500"
26
+ onclick={() => (show = !show)}
27
+ aria-label={show ? 'Hide password' : 'Show password'}
28
+ >
29
+ {#if show}
30
+ <EyeOff class="size-5" />
31
+ {:else}
32
+ <Eye class="size-5" />
33
+ {/if}
34
+ </button>
35
+ </div>
36
+ {/snippet}
37
+ </FieldWrapper>
@@ -0,0 +1,28 @@
1
+ import type { FormPath } from 'sveltekit-superforms';
2
+ import { type FieldWrapperProps } from '../FieldWrapper.svelte';
3
+ declare function $$render<T extends Record<string, unknown>, U extends FormPath<T>, M>(): {
4
+ props: FieldWrapperProps<T, U, M> & {
5
+ value?: string;
6
+ };
7
+ exports: {};
8
+ bindings: "value";
9
+ slots: {};
10
+ events: {};
11
+ };
12
+ declare class __sveltets_Render<T extends Record<string, unknown>, U extends FormPath<T>, M> {
13
+ props(): ReturnType<typeof $$render<T, U, M>>['props'];
14
+ events(): ReturnType<typeof $$render<T, U, M>>['events'];
15
+ slots(): ReturnType<typeof $$render<T, U, M>>['slots'];
16
+ bindings(): "value";
17
+ exports(): {};
18
+ }
19
+ interface $$IsomorphicComponent {
20
+ new <T extends Record<string, unknown>, U extends FormPath<T>, M>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T, U, M>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T, U, M>['props']>, ReturnType<__sveltets_Render<T, U, M>['events']>, ReturnType<__sveltets_Render<T, U, M>['slots']>> & {
21
+ $$bindings?: ReturnType<__sveltets_Render<T, U, M>['bindings']>;
22
+ } & ReturnType<__sveltets_Render<T, U, M>['exports']>;
23
+ <T extends Record<string, unknown>, U extends FormPath<T>, M>(internal: unknown, props: ReturnType<__sveltets_Render<T, U, M>['props']> & {}): ReturnType<__sveltets_Render<T, U, M>['exports']>;
24
+ z_$$bindings?: ReturnType<__sveltets_Render<any, any, any>['bindings']>;
25
+ }
26
+ declare const PasswordField: $$IsomorphicComponent;
27
+ type PasswordField<T extends Record<string, unknown>, U extends FormPath<T>, M> = InstanceType<typeof PasswordField<T, U, M>>;
28
+ export default PasswordField;
@@ -0,0 +1,17 @@
1
+ <script lang="ts" generics="T extends Record<string, unknown>, U extends FormPath<T>, M">
2
+ import type { FormPath } from 'sveltekit-superforms';
3
+ import FieldWrapper, { type FieldWrapperProps } from '../FieldWrapper.svelte';
4
+ import { Input } from '../../../shadcn/components/ui/input/index.js';
5
+
6
+ interface Props extends FieldWrapperProps<T, U, M> {
7
+ value?: string;
8
+ type?: HTMLInputElement['type'];
9
+ }
10
+ let { value = $bindable(), type = 'text', ...fieldProps }: Props = $props();
11
+ </script>
12
+
13
+ <FieldWrapper {...fieldProps}>
14
+ {#snippet formElem(props)}
15
+ <Input {type} bind:value {...props} />
16
+ {/snippet}
17
+ </FieldWrapper>
@@ -0,0 +1,29 @@
1
+ import type { FormPath } from 'sveltekit-superforms';
2
+ import { type FieldWrapperProps } from '../FieldWrapper.svelte';
3
+ declare function $$render<T extends Record<string, unknown>, U extends FormPath<T>, M>(): {
4
+ props: FieldWrapperProps<T, U, M> & {
5
+ value?: string;
6
+ type?: HTMLInputElement["type"];
7
+ };
8
+ exports: {};
9
+ bindings: "value";
10
+ slots: {};
11
+ events: {};
12
+ };
13
+ declare class __sveltets_Render<T extends Record<string, unknown>, U extends FormPath<T>, M> {
14
+ props(): ReturnType<typeof $$render<T, U, M>>['props'];
15
+ events(): ReturnType<typeof $$render<T, U, M>>['events'];
16
+ slots(): ReturnType<typeof $$render<T, U, M>>['slots'];
17
+ bindings(): "value";
18
+ exports(): {};
19
+ }
20
+ interface $$IsomorphicComponent {
21
+ new <T extends Record<string, unknown>, U extends FormPath<T>, M>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T, U, M>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T, U, M>['props']>, ReturnType<__sveltets_Render<T, U, M>['events']>, ReturnType<__sveltets_Render<T, U, M>['slots']>> & {
22
+ $$bindings?: ReturnType<__sveltets_Render<T, U, M>['bindings']>;
23
+ } & ReturnType<__sveltets_Render<T, U, M>['exports']>;
24
+ <T extends Record<string, unknown>, U extends FormPath<T>, M>(internal: unknown, props: ReturnType<__sveltets_Render<T, U, M>['props']> & {}): ReturnType<__sveltets_Render<T, U, M>['exports']>;
25
+ z_$$bindings?: ReturnType<__sveltets_Render<any, any, any>['bindings']>;
26
+ }
27
+ declare const TextField: $$IsomorphicComponent;
28
+ type TextField<T extends Record<string, unknown>, U extends FormPath<T>, M> = InstanceType<typeof TextField<T, U, M>>;
29
+ export default TextField;
@@ -0,0 +1,3 @@
1
+ import TextField from './form/fields/TextField.svelte';
2
+ import PasswordField from './form/fields/PasswordField.svelte';
3
+ export { TextField, PasswordField };
@@ -0,0 +1,3 @@
1
+ import TextField from './form/fields/TextField.svelte';
2
+ import PasswordField from './form/fields/PasswordField.svelte';
3
+ export { TextField, PasswordField };
@@ -0,0 +1,2 @@
1
+ import Root from './input.svelte';
2
+ export { Root, Root as Input };
@@ -0,0 +1,4 @@
1
+ import Root from './input.svelte';
2
+ export { Root,
3
+ //
4
+ Root as Input };
@@ -0,0 +1,51 @@
1
+ <script lang="ts">
2
+ import type { HTMLInputAttributes, HTMLInputTypeAttribute } from 'svelte/elements';
3
+ import { cn, type WithElementRef } from '../../../utils.js';
4
+
5
+ type InputType = Exclude<HTMLInputTypeAttribute, 'file'>;
6
+
7
+ type Props = WithElementRef<
8
+ Omit<HTMLInputAttributes, 'type'> &
9
+ ({ type: 'file'; files?: FileList } | { type?: InputType; files?: undefined })
10
+ >;
11
+
12
+ let {
13
+ ref = $bindable(null),
14
+ value = $bindable(),
15
+ type,
16
+ files = $bindable(),
17
+ class: className,
18
+ ...restProps
19
+ }: Props = $props();
20
+ </script>
21
+
22
+ {#if type === 'file'}
23
+ <input
24
+ bind:this={ref}
25
+ data-slot="input"
26
+ class={cn(
27
+ 'flex h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 pt-1.5 text-sm font-medium shadow-xs ring-offset-background transition-[color,box-shadow] outline-none selection:bg-primary selection:text-primary-foreground placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50 md:text-sm dark:bg-input/30',
28
+ 'focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50',
29
+ 'aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40',
30
+ className
31
+ )}
32
+ type="file"
33
+ bind:files
34
+ bind:value
35
+ {...restProps}
36
+ />
37
+ {:else}
38
+ <input
39
+ bind:this={ref}
40
+ data-slot="input"
41
+ class={cn(
42
+ 'flex h-9 w-full min-w-0 rounded-md border border-input bg-background px-3 py-1 text-base shadow-xs ring-offset-background transition-[color,box-shadow] outline-none selection:bg-primary selection:text-primary-foreground placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50 md:text-sm dark:bg-input/30',
43
+ 'focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50',
44
+ 'aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40',
45
+ className
46
+ )}
47
+ {type}
48
+ bind:value
49
+ {...restProps}
50
+ />
51
+ {/if}
@@ -0,0 +1,13 @@
1
+ import type { HTMLInputAttributes, HTMLInputTypeAttribute } from 'svelte/elements';
2
+ import { type WithElementRef } from '../../../utils.js';
3
+ type InputType = Exclude<HTMLInputTypeAttribute, 'file'>;
4
+ type Props = WithElementRef<Omit<HTMLInputAttributes, 'type'> & ({
5
+ type: 'file';
6
+ files?: FileList;
7
+ } | {
8
+ type?: InputType;
9
+ files?: undefined;
10
+ })>;
11
+ declare const Input: import("svelte").Component<Props, {}, "ref" | "files" | "value">;
12
+ type Input = ReturnType<typeof Input>;
13
+ export default Input;
@@ -0,0 +1,12 @@
1
+ import { type ClassValue } from 'clsx';
2
+ export declare function cn(...inputs: ClassValue[]): string;
3
+ export type WithoutChild<T> = T extends {
4
+ child?: any;
5
+ } ? Omit<T, 'child'> : T;
6
+ export type WithoutChildren<T> = T extends {
7
+ children?: any;
8
+ } ? Omit<T, 'children'> : T;
9
+ export type WithoutChildrenOrChild<T> = WithoutChildren<WithoutChild<T>>;
10
+ export type WithElementRef<T, U extends HTMLElement = HTMLElement> = T & {
11
+ ref?: U | null;
12
+ };
@@ -0,0 +1,5 @@
1
+ import { clsx } from 'clsx';
2
+ import { twMerge } from 'tailwind-merge';
3
+ export function cn(...inputs) {
4
+ return twMerge(clsx(inputs));
5
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ // Reexport your entry utils here
package/package.json ADDED
@@ -0,0 +1,93 @@
1
+ {
2
+ "name": "@webamoki/web-svelte",
3
+ "publishConfig": {
4
+ "access": "public"
5
+ },
6
+ "version": "0.1.0",
7
+ "files": [
8
+ "dist",
9
+ "!dist/**/*.test.*",
10
+ "!dist/**/*.spec.*"
11
+ ],
12
+ "sideEffects": [
13
+ "**/*.css"
14
+ ],
15
+ "type": "module",
16
+ "exports": {
17
+ "./components": {
18
+ "types": "./dist/components/index.d.ts",
19
+ "svelte": "./dist/components/index.js"
20
+ },
21
+ "./utils": {
22
+ "types": "./dist/utils/index.d.ts",
23
+ "svelte": "./dist/utils/index.js"
24
+ }
25
+ },
26
+ "peerDependencies": {
27
+ "@internationalized/date": "^3.9.0",
28
+ "@lucide/svelte": "^0.544.0",
29
+ "@tailwindcss/forms": "^0.5.9",
30
+ "@tailwindcss/typography": "^0.5.15",
31
+ "arktype": "^2.1.22",
32
+ "ramda": "^0.31.3",
33
+ "svelte": "^5.0.0",
34
+ "sveltekit-superforms": "^2.27.1",
35
+ "tailwindcss": "^4.0.0"
36
+ },
37
+ "devDependencies": {
38
+ "@changesets/cli": "^2.29.7",
39
+ "@eslint/compat": "^1.2.5",
40
+ "@eslint/js": "^9.22.0",
41
+ "@internationalized/date": "^3.9.0",
42
+ "@lucide/svelte": "^0.544.0",
43
+ "@sveltejs/adapter-static": "^3.0.8",
44
+ "@sveltejs/kit": "^2.22.0",
45
+ "@sveltejs/package": "^2.0.0",
46
+ "@sveltejs/vite-plugin-svelte": "^6.0.0",
47
+ "@tailwindcss/forms": "^0.5.9",
48
+ "@tailwindcss/typography": "^0.5.15",
49
+ "@tailwindcss/vite": "^4.0.0",
50
+ "@types/node": "^22",
51
+ "@types/ramda": "^0.31.1",
52
+ "arktype": "^2.1.22",
53
+ "clsx": "^2.1.1",
54
+ "eslint": "^9.22.0",
55
+ "eslint-config-prettier": "^10.0.1",
56
+ "eslint-plugin-svelte": "^3.0.0",
57
+ "globals": "^16.0.0",
58
+ "prettier": "^3.4.2",
59
+ "prettier-plugin-svelte": "^3.3.3",
60
+ "prettier-plugin-tailwindcss": "^0.6.11",
61
+ "publint": "^0.3.2",
62
+ "ramda": "^0.31.3",
63
+ "svelte": "^5.0.0",
64
+ "svelte-check": "^4.0.0",
65
+ "sveltekit-superforms": "^2.27.1",
66
+ "tailwind-merge": "^3.3.1",
67
+ "tailwind-variants": "^3.1.1",
68
+ "tailwindcss": "^4.0.0",
69
+ "tw-animate-css": "^1.3.8",
70
+ "typescript": "^5.0.0",
71
+ "typescript-eslint": "^8.20.0",
72
+ "vite": "^7.0.4",
73
+ "vitest": "^3.2.3"
74
+ },
75
+ "keywords": [
76
+ "svelte"
77
+ ],
78
+ "dependencies": {
79
+ "formsnap": "^2.0.1"
80
+ },
81
+ "scripts": {
82
+ "dev": "vite dev",
83
+ "build": "vite build && pnpm prepack",
84
+ "preview": "vite preview",
85
+ "check": "pnpm fmt && pnpm lint && pnpm test",
86
+ "fmt": "prettier --write --cache --cache-location=.cache/.prettier-cache --cache-strategy metadata --log-level warn .",
87
+ "lint": "pnpm lint:es && pnpm lint:svelte",
88
+ "lint:es": "eslint --cache --cache-location .cache/.eslintcache --cache-strategy metadata .",
89
+ "lint:svelte": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
90
+ "test:unit": "vitest run",
91
+ "test": "pnpm test:unit"
92
+ }
93
+ }