@tanglemedia/svelte-starter-auth-shadcn 0.0.2 → 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/dist/app.css +174 -0
- package/dist/app.html +0 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/lib/components/types.d.ts +13 -0
- package/dist/lib/components/types.js +1 -0
- package/dist/lib/components/ui/auth-layout/auth-layout-content-top.svelte +15 -0
- package/dist/lib/components/ui/auth-layout/auth-layout-content-top.svelte.d.ts +8 -0
- package/dist/lib/components/ui/auth-layout/auth-layout-content.svelte +15 -0
- package/dist/lib/components/ui/auth-layout/auth-layout-content.svelte.d.ts +8 -0
- package/dist/lib/components/ui/auth-layout/auth-layout-feature-info.svelte +45 -0
- package/dist/lib/components/ui/auth-layout/auth-layout-feature-info.svelte.d.ts +12 -0
- package/dist/lib/components/ui/auth-layout/auth-layout-feature.svelte +24 -0
- package/dist/lib/components/ui/auth-layout/auth-layout-feature.svelte.d.ts +8 -0
- package/dist/lib/components/ui/auth-layout/auth-layout-logo.svelte +99 -0
- package/dist/lib/components/ui/auth-layout/auth-layout-logo.svelte.d.ts +63 -0
- package/dist/lib/components/ui/auth-layout/auth-layout-main.svelte +17 -0
- package/dist/lib/components/ui/auth-layout/auth-layout-main.svelte.d.ts +8 -0
- package/dist/lib/components/ui/auth-layout/auth-layout.svelte +22 -82
- package/dist/lib/components/ui/auth-layout/auth-layout.svelte.d.ts +4 -11
- package/dist/lib/components/ui/auth-layout/index.d.ts +8 -2
- package/dist/lib/components/ui/auth-layout/index.js +10 -2
- package/dist/lib/components/ui/forgot-password/forgot-password-container.svelte +27 -0
- package/dist/lib/components/ui/forgot-password/forgot-password-container.svelte.d.ts +8 -0
- package/dist/lib/components/ui/forgot-password/forgot-password-form.svelte +70 -81
- package/dist/lib/components/ui/forgot-password/forgot-password-form.svelte.d.ts +12 -7
- package/dist/lib/components/ui/forgot-password/forgot-password-header.svelte +34 -0
- package/dist/lib/components/ui/forgot-password/forgot-password-header.svelte.d.ts +13 -0
- package/dist/lib/components/ui/forgot-password/forgot-password-login.svelte +19 -0
- package/dist/lib/components/ui/forgot-password/forgot-password-login.svelte.d.ts +9 -0
- package/dist/lib/components/ui/forgot-password/forgot-password-provider.svelte +13 -0
- package/dist/lib/components/ui/forgot-password/forgot-password-provider.svelte.d.ts +25 -0
- package/dist/lib/components/ui/forgot-password/forgot-password-submit.svelte +17 -0
- package/dist/lib/components/ui/forgot-password/forgot-password-submit.svelte.d.ts +7 -0
- package/dist/lib/components/ui/forgot-password/forgot-password-user-input.svelte +21 -0
- package/dist/lib/components/ui/forgot-password/forgot-password-user-input.svelte.d.ts +26 -0
- package/dist/lib/components/ui/forgot-password/forgot-password.schema.d.ts +5 -0
- package/dist/lib/components/ui/forgot-password/forgot-password.schema.js +4 -0
- package/dist/lib/components/ui/forgot-password/index.d.ts +9 -2
- package/dist/lib/components/ui/forgot-password/index.js +9 -2
- package/dist/lib/components/ui/index.d.ts +5 -0
- package/dist/lib/components/ui/index.js +6 -0
- package/dist/lib/components/ui/login-form/index.d.ts +11 -2
- package/dist/lib/components/ui/login-form/index.js +13 -2
- package/dist/lib/components/ui/login-form/login-container.svelte +27 -0
- package/dist/lib/components/ui/login-form/login-container.svelte.d.ts +8 -0
- package/dist/lib/components/ui/login-form/login-context.d.ts +2 -0
- package/dist/lib/components/ui/login-form/login-context.js +13 -0
- package/dist/lib/components/ui/login-form/login-forgot-password.svelte +19 -0
- package/dist/lib/components/ui/login-form/login-forgot-password.svelte.d.ts +9 -0
- package/dist/lib/components/ui/login-form/login-form.svelte +68 -111
- package/dist/lib/components/ui/login-form/login-form.svelte.d.ts +10 -7
- package/dist/lib/components/ui/login-form/login-header.svelte +34 -0
- package/dist/lib/components/ui/login-form/login-header.svelte.d.ts +13 -0
- package/dist/lib/components/ui/login-form/login-password-input.svelte +21 -0
- package/dist/lib/components/ui/login-form/login-password-input.svelte.d.ts +26 -0
- package/dist/lib/components/ui/login-form/login-provider.svelte +13 -0
- package/dist/lib/components/ui/login-form/login-provider.svelte.d.ts +25 -0
- package/dist/lib/components/ui/login-form/login-submit.svelte +17 -0
- package/dist/lib/components/ui/login-form/login-submit.svelte.d.ts +7 -0
- package/dist/lib/components/ui/login-form/login-user-input.svelte +21 -0
- package/dist/lib/components/ui/login-form/login-user-input.svelte.d.ts +26 -0
- package/dist/lib/components/ui/login-form/login.schema.d.ts +6 -0
- package/dist/lib/components/ui/login-form/login.schema.js +5 -0
- package/dist/lib/components/ui/register-form/index.d.ts +10 -2
- package/dist/lib/components/ui/register-form/index.js +10 -2
- package/dist/lib/components/ui/register-form/register-container.svelte +27 -0
- package/dist/lib/components/ui/register-form/register-container.svelte.d.ts +8 -0
- package/dist/lib/components/ui/register-form/register-form.svelte +67 -170
- package/dist/lib/components/ui/register-form/register-form.svelte.d.ts +10 -5
- package/dist/lib/components/ui/register-form/register-header.svelte +34 -0
- package/dist/lib/components/ui/register-form/register-header.svelte.d.ts +13 -0
- package/dist/lib/components/ui/register-form/register-name-input.svelte +21 -0
- package/dist/lib/components/ui/register-form/register-name-input.svelte.d.ts +26 -0
- package/dist/lib/components/ui/register-form/register-password-input.svelte +21 -0
- package/dist/lib/components/ui/register-form/register-password-input.svelte.d.ts +26 -0
- package/dist/lib/components/ui/register-form/register-provider.svelte +13 -0
- package/dist/lib/components/ui/register-form/register-provider.svelte.d.ts +25 -0
- package/dist/lib/components/ui/register-form/register-submit.svelte +17 -0
- package/dist/lib/components/ui/register-form/register-submit.svelte.d.ts +7 -0
- package/dist/lib/components/ui/register-form/register-user-input.svelte +21 -0
- package/dist/lib/components/ui/register-form/register-user-input.svelte.d.ts +26 -0
- package/dist/lib/components/ui/register-form/register.schema.d.ts +8 -0
- package/dist/lib/components/ui/register-form/register.schema.js +7 -0
- package/dist/lib/components/ui/reset-password/index.d.ts +8 -2
- package/dist/lib/components/ui/reset-password/index.js +8 -2
- package/dist/lib/components/ui/reset-password/reset-password-container.svelte +27 -0
- package/dist/lib/components/ui/reset-password/reset-password-container.svelte.d.ts +8 -0
- package/dist/lib/components/ui/reset-password/reset-password-form.svelte +91 -0
- package/dist/lib/components/ui/reset-password/reset-password-form.svelte.d.ts +20 -0
- package/dist/lib/components/ui/reset-password/reset-password-header.svelte +34 -0
- package/dist/lib/components/ui/reset-password/reset-password-header.svelte.d.ts +13 -0
- package/dist/lib/components/ui/reset-password/reset-password-password-input.svelte +21 -0
- package/dist/lib/components/ui/reset-password/reset-password-password-input.svelte.d.ts +26 -0
- package/dist/lib/components/ui/reset-password/reset-password-provider.svelte +13 -0
- package/dist/lib/components/ui/reset-password/reset-password-provider.svelte.d.ts +25 -0
- package/dist/lib/components/ui/reset-password/reset-password-submit.svelte +17 -0
- package/dist/lib/components/ui/reset-password/reset-password-submit.svelte.d.ts +7 -0
- package/dist/lib/components/ui/reset-password/reset-password.schema.d.ts +6 -0
- package/dist/lib/components/ui/reset-password/reset-password.schema.js +9 -0
- package/dist/lib/hooks/index.d.ts +1 -0
- package/dist/lib/hooks/index.js +1 -0
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/index.js +3 -0
- package/dist/lib/utils.d.ts +10 -0
- package/package.json +40 -69
- package/src/app.css +174 -0
- package/src/app.html +0 -1
- package/src/index.ts +1 -0
- package/src/lib/components/types.ts +24 -0
- package/src/lib/components/ui/auth-layout/auth-layout-content-top.svelte +15 -0
- package/src/lib/components/ui/auth-layout/auth-layout-content.svelte +15 -0
- package/src/lib/components/ui/auth-layout/auth-layout-feature-info.svelte +45 -0
- package/src/lib/components/ui/auth-layout/auth-layout-feature.svelte +24 -0
- package/src/lib/components/ui/auth-layout/auth-layout-logo.svelte +99 -0
- package/src/lib/components/ui/auth-layout/auth-layout-main.svelte +17 -0
- package/src/lib/components/ui/auth-layout/auth-layout.svelte +22 -88
- package/src/lib/components/ui/auth-layout/index.ts +20 -2
- package/src/lib/components/ui/forgot-password/forgot-password-container.svelte +27 -0
- package/src/lib/components/ui/forgot-password/forgot-password-form.svelte +70 -81
- package/src/lib/components/ui/forgot-password/forgot-password-header.svelte +34 -0
- package/src/lib/components/ui/forgot-password/forgot-password-login.svelte +19 -0
- package/src/lib/components/ui/forgot-password/forgot-password-provider.svelte +13 -0
- package/src/lib/components/ui/forgot-password/forgot-password-submit.svelte +17 -0
- package/src/lib/components/ui/forgot-password/forgot-password-user-input.svelte +21 -0
- package/src/lib/components/ui/forgot-password/forgot-password.schema.ts +7 -0
- package/src/lib/components/ui/forgot-password/index.ts +19 -2
- package/src/lib/components/ui/index.ts +6 -0
- package/src/lib/components/ui/login-form/index.ts +26 -2
- package/src/lib/components/ui/login-form/login-container.svelte +27 -0
- package/src/lib/components/ui/login-form/login-context.ts +16 -0
- package/src/lib/components/ui/login-form/login-forgot-password.svelte +19 -0
- package/src/lib/components/ui/login-form/login-form.svelte +68 -111
- package/src/lib/components/ui/login-form/login-header.svelte +34 -0
- package/src/lib/components/ui/login-form/login-password-input.svelte +21 -0
- package/src/lib/components/ui/login-form/login-provider.svelte +13 -0
- package/src/lib/components/ui/login-form/login-submit.svelte +17 -0
- package/src/lib/components/ui/login-form/login-user-input.svelte +21 -0
- package/src/lib/components/ui/login-form/login.schema.ts +8 -0
- package/src/lib/components/ui/register-form/index.ts +21 -2
- package/src/lib/components/ui/register-form/register-container.svelte +27 -0
- package/src/lib/components/ui/register-form/register-form.svelte +67 -170
- package/src/lib/components/ui/register-form/register-header.svelte +34 -0
- package/src/lib/components/ui/register-form/register-name-input.svelte +21 -0
- package/src/lib/components/ui/register-form/register-password-input.svelte +21 -0
- package/src/lib/components/ui/register-form/register-provider.svelte +13 -0
- package/src/lib/components/ui/register-form/register-submit.svelte +17 -0
- package/src/lib/components/ui/register-form/register-user-input.svelte +21 -0
- package/src/lib/components/ui/register-form/register.schema.ts +10 -0
- package/src/lib/components/ui/reset-password/index.ts +17 -2
- package/src/lib/components/ui/reset-password/reset-password-container.svelte +27 -0
- package/src/lib/components/ui/reset-password/reset-password-form.svelte +91 -0
- package/src/lib/components/ui/reset-password/reset-password-header.svelte +34 -0
- package/src/lib/components/ui/reset-password/reset-password-password-input.svelte +21 -0
- package/src/lib/components/ui/reset-password/reset-password-provider.svelte +13 -0
- package/src/lib/components/ui/reset-password/reset-password-submit.svelte +17 -0
- package/src/lib/components/ui/reset-password/reset-password.schema.ts +12 -0
- package/src/lib/hooks/index.ts +1 -0
- package/src/lib/index.ts +3 -0
- package/src/lib/utils.ts +8 -1
- package/dist/lib/components/ui/reset-password/reset-form.svelte +0 -120
- package/dist/lib/components/ui/reset-password/reset-form.svelte.d.ts +0 -16
- package/src/lib/components/ui/reset-password/reset-form.svelte +0 -120
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Form } from "@tanglemedia/svelte-starter-form-shadcn";
|
|
3
|
+
import type { Snippet } from "svelte";
|
|
4
|
+
|
|
5
|
+
type LoginSubmitProps = {
|
|
6
|
+
children?: Snippet;
|
|
7
|
+
};
|
|
8
|
+
const { children }: LoginSubmitProps = $props();
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<Form.Submit class="w-full">
|
|
12
|
+
{#if children}
|
|
13
|
+
{@render children?.()}
|
|
14
|
+
{:else}
|
|
15
|
+
Submit
|
|
16
|
+
{/if}
|
|
17
|
+
</Form.Submit>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import { type FormPathLeaves as _FormPathLeaves } from 'sveltekit-superforms';
|
|
3
|
+
|
|
4
|
+
type T = Record<string, unknown>;
|
|
5
|
+
type U = _FormPathLeaves<T, any>;
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<script
|
|
9
|
+
lang="ts"
|
|
10
|
+
generics="T extends Record<string, unknown>, U extends _FormPathLeaves<T, any>"
|
|
11
|
+
>
|
|
12
|
+
import {
|
|
13
|
+
Field,
|
|
14
|
+
type InputFieldProps,
|
|
15
|
+
} from '@tanglemedia/svelte-starter-form-shadcn';
|
|
16
|
+
|
|
17
|
+
type LoginUserInputProps = InputFieldProps<T, U>;
|
|
18
|
+
const { name = 'email' as U, label, ...rest }: LoginUserInputProps = $props();
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<Field.Input type={'email'} {name} label={label || 'Email'} {...rest}></Field.Input>
|
|
@@ -1,3 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Form from './forgot-password-form.svelte';
|
|
2
|
+
import Provider from './forgot-password-provider.svelte';
|
|
3
|
+
import Header from './forgot-password-header.svelte';
|
|
4
|
+
import { forgotPasswordSchema as schema, type ForgotPasswordSchema } from './forgot-password.schema.ts';
|
|
5
|
+
import Container from './forgot-password-container.svelte';
|
|
6
|
+
import ForgotPasswordLogin from './forgot-password-login.svelte';
|
|
7
|
+
import Submit from './forgot-password-submit.svelte';
|
|
8
|
+
import UserInput from './forgot-password-user-input.svelte';
|
|
2
9
|
|
|
3
|
-
export {
|
|
10
|
+
export {
|
|
11
|
+
Form,
|
|
12
|
+
Provider,
|
|
13
|
+
Header,
|
|
14
|
+
Container,
|
|
15
|
+
schema,
|
|
16
|
+
ForgotPasswordLogin,
|
|
17
|
+
Submit,
|
|
18
|
+
UserInput,
|
|
19
|
+
type ForgotPasswordSchema,
|
|
20
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * as Auth from './auth-layout/index.ts';
|
|
2
|
+
export * as Login from './login-form/index.ts';
|
|
3
|
+
export * as ForgotPassword from './forgot-password/index.ts';
|
|
4
|
+
export * as Register from './register-form/index.ts';
|
|
5
|
+
export * as ResetPassword from './reset-password/index.ts';
|
|
6
|
+
// export * from './forgot-password/index.ts';
|
|
@@ -1,3 +1,27 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Form from './login-form.svelte';
|
|
2
|
+
import Provider from './login-provider.svelte';
|
|
3
|
+
import Header from './login-header.svelte';
|
|
4
|
+
import { loginSchema as schema, type LoginSchema } from './login.schema.ts';
|
|
5
|
+
import Container from './login-container.svelte';
|
|
6
|
+
import ForgotPasswordLink from './login-forgot-password.svelte';
|
|
7
|
+
import Submit from './login-submit.svelte';
|
|
8
|
+
import UserInput from './login-user-input.svelte';
|
|
9
|
+
import PasswordInput from './login-password-input.svelte';
|
|
10
|
+
// import { Field } from '@tanglemedia/svelte-starter-form-shadcn';
|
|
2
11
|
|
|
3
|
-
export
|
|
12
|
+
export * from './login-context.ts';
|
|
13
|
+
|
|
14
|
+
// const PasswordField = Field.PasswordField;
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
Form,
|
|
18
|
+
Provider,
|
|
19
|
+
Header,
|
|
20
|
+
Container,
|
|
21
|
+
schema,
|
|
22
|
+
ForgotPasswordLink,
|
|
23
|
+
Submit,
|
|
24
|
+
UserInput,
|
|
25
|
+
PasswordInput,
|
|
26
|
+
type LoginSchema,
|
|
27
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Card } from '@tanglemedia/svelte-starter-ui-shadcn';
|
|
3
|
+
import type { WithChild } from 'svelte-toolbelt';
|
|
4
|
+
import { cn } from '../../../utils.js';
|
|
5
|
+
|
|
6
|
+
type LoginContainerProps = Omit<WithChild, 'child'> & {
|
|
7
|
+
class?: string;
|
|
8
|
+
card?: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const {
|
|
12
|
+
children,
|
|
13
|
+
class: cls,
|
|
14
|
+
card = true,
|
|
15
|
+
...rest
|
|
16
|
+
}: LoginContainerProps = $props();
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
{#if !card}
|
|
20
|
+
<div class={cn('mx-auto max-w-sm', cls)} {...rest}>
|
|
21
|
+
{@render children?.()}
|
|
22
|
+
</div>
|
|
23
|
+
{:else}
|
|
24
|
+
<Card.Root class={cn('mx-auto max-w-sm', cls)} {...rest}>
|
|
25
|
+
{@render children?.()}
|
|
26
|
+
</Card.Root>
|
|
27
|
+
{/if}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useForm } from '@tanglemedia/svelte-starter-form-shadcn';
|
|
2
|
+
export { useForm };
|
|
3
|
+
// import { getContext, setContext } from 'svelte';
|
|
4
|
+
// import type { SuperForm } from 'sveltekit-superforms';
|
|
5
|
+
|
|
6
|
+
// const ctx = '--auth-superform';
|
|
7
|
+
|
|
8
|
+
// export function setForm<T extends Record<string, unknown>>(
|
|
9
|
+
// superform: SuperForm<T>
|
|
10
|
+
// ) {
|
|
11
|
+
// setContext(ctx, superform);
|
|
12
|
+
// }
|
|
13
|
+
|
|
14
|
+
// export function useForm<T extends Record<string, unknown>>() {
|
|
15
|
+
// return getContext<SuperForm<T>>(ctx);
|
|
16
|
+
// }
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from "$lib/utils.js";
|
|
3
|
+
import type { Snippet } from "svelte";
|
|
4
|
+
|
|
5
|
+
type LoginForgotPasswordProps = {
|
|
6
|
+
href: string;
|
|
7
|
+
class?: string;
|
|
8
|
+
children?: Snippet;
|
|
9
|
+
};
|
|
10
|
+
const { href, class: cls, children }: LoginForgotPasswordProps = $props();
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<a {href} class={cn("ml-auto inline-block text-sm underline", cls)}>
|
|
14
|
+
{#if children}
|
|
15
|
+
{@render children?.()}
|
|
16
|
+
{:else}
|
|
17
|
+
Forgot your password?
|
|
18
|
+
{/if}
|
|
19
|
+
</a>
|
|
@@ -1,138 +1,95 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { Card } from "@tanglemedia/svelte-starter-ui-shadcn";
|
|
3
|
+
import type { Snippet } from "svelte";
|
|
4
|
+
import SuperDebug, {
|
|
5
|
+
defaults,
|
|
6
|
+
superForm,
|
|
7
|
+
type Infer,
|
|
8
|
+
type SuperForm,
|
|
9
|
+
type SuperValidated,
|
|
10
|
+
} from "sveltekit-superforms";
|
|
11
|
+
import { zod4 } from "sveltekit-superforms/adapters";
|
|
12
|
+
import LoginContainer from "./login-container.svelte";
|
|
13
|
+
import LoginForgotPassword from "./login-forgot-password.svelte";
|
|
14
|
+
import LoginHeader from "./login-header.svelte";
|
|
15
|
+
import LoginPasswordInput from "./login-password-input.svelte";
|
|
16
|
+
import LoginProvider from "./login-provider.svelte";
|
|
17
|
+
import LoginSubmit from "./login-submit.svelte";
|
|
18
|
+
import LoginUserInput from "./login-user-input.svelte";
|
|
19
|
+
import { loginSchema, type LoginSchema } from "./login.schema.js";
|
|
20
|
+
import { ServerError } from "@tanglemedia/svelte-starter-form-shadcn";
|
|
21
|
+
// import { Field } from "@tanglemedia/svelte-starter-form-shadcn";
|
|
8
22
|
|
|
9
23
|
interface Props {
|
|
10
|
-
superform
|
|
24
|
+
superform?: SuperForm<Infer<LoginSchema>> | null;
|
|
11
25
|
card?: boolean;
|
|
12
|
-
cardClass?: string;
|
|
26
|
+
// cardClass?: string;
|
|
13
27
|
title?: string;
|
|
14
28
|
description?: string;
|
|
15
|
-
forgotPassword?: boolean;
|
|
29
|
+
// forgotPassword?: boolean;
|
|
16
30
|
forgotPasswordLink?: string;
|
|
17
31
|
register?: boolean;
|
|
18
32
|
registerLink?: string;
|
|
19
|
-
|
|
20
|
-
|
|
33
|
+
lead?: Snippet;
|
|
34
|
+
tail?: Snippet;
|
|
21
35
|
children?: Snippet;
|
|
36
|
+
form?: SuperValidated<Infer<LoginSchema>>;
|
|
37
|
+
action?: string;
|
|
38
|
+
|
|
39
|
+
debug?: boolean;
|
|
22
40
|
}
|
|
23
41
|
|
|
24
|
-
let {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
42
|
+
let {
|
|
43
|
+
debug = false,
|
|
44
|
+
form,
|
|
45
|
+
superform: superforms = $bindable(null),
|
|
46
|
+
card = true,
|
|
47
|
+
title = "Login",
|
|
48
|
+
description = "Enter your credentails below",
|
|
49
|
+
// forgotPassword = true,
|
|
31
50
|
forgotPasswordLink = "/forgot-password",
|
|
32
51
|
register = true,
|
|
33
52
|
registerLink = "/register",
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
53
|
+
lead,
|
|
54
|
+
tail,
|
|
55
|
+
action = "?/login",
|
|
37
56
|
}: Props = $props();
|
|
38
57
|
|
|
39
|
-
|
|
58
|
+
// https://github.com/ciscoheat/sveltekit-superforms/issues/630
|
|
59
|
+
superforms = superforms || superForm(form || defaults(zod4(loginSchema)));
|
|
60
|
+
|
|
61
|
+
const { errors, message } = superforms;
|
|
40
62
|
</script>
|
|
41
63
|
|
|
42
|
-
{
|
|
43
|
-
<
|
|
44
|
-
<
|
|
45
|
-
<Card.Title class="text-2xl">{title}</Card.Title>
|
|
46
|
-
<Card.Description>{description}</Card.Description>
|
|
47
|
-
</Card.Header>
|
|
64
|
+
<LoginProvider {superforms} {action}>
|
|
65
|
+
<LoginContainer {card}>
|
|
66
|
+
<LoginHeader text={title} desc={description} />
|
|
48
67
|
<Card.Content>
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
{
|
|
54
|
-
<
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
<Input {...props} bind:value={$formData.email} type="email" required />
|
|
59
|
-
{/snippet}
|
|
60
|
-
</Form.Control>
|
|
61
|
-
<Form.FieldErrors />
|
|
62
|
-
</Form.Field>
|
|
63
|
-
<Form.Field form={superform} name="password">
|
|
64
|
-
<Form.Control>
|
|
65
|
-
{#snippet children({ props })}
|
|
66
|
-
<div class="flex items-center">
|
|
67
|
-
<Form.Label>Password</Form.Label>
|
|
68
|
-
{#if forgotPassword}
|
|
69
|
-
<a href={forgotPasswordLink} class="ml-auto inline-block text-sm underline">
|
|
70
|
-
Forgot your password?
|
|
71
|
-
</a>
|
|
72
|
-
{/if}
|
|
73
|
-
</div>
|
|
74
|
-
<Input {...props} bind:value={$formData.password} type="password" required />
|
|
75
|
-
{/snippet}
|
|
76
|
-
</Form.Control>
|
|
77
|
-
<Form.FieldErrors />
|
|
78
|
-
</Form.Field>
|
|
79
|
-
{/if}
|
|
80
|
-
<Form.Button type="submit" class="w-full">Login</Form.Button>
|
|
81
|
-
{@render formTail?.()}
|
|
82
|
-
</form>
|
|
68
|
+
{@render lead?.()}
|
|
69
|
+
<ServerError class="mb-4" />
|
|
70
|
+
<LoginUserInput autocomplete="username" name={"username"} />
|
|
71
|
+
<LoginPasswordInput name={"password"} label={"Password"}>
|
|
72
|
+
{#snippet asideLabel()}
|
|
73
|
+
<LoginForgotPassword href={forgotPasswordLink} />
|
|
74
|
+
{/snippet}
|
|
75
|
+
</LoginPasswordInput>
|
|
76
|
+
<LoginSubmit />
|
|
83
77
|
{#if register}
|
|
84
78
|
<div class="mt-4 text-center text-sm">
|
|
85
79
|
Don't have an account?
|
|
86
80
|
<a href={registerLink} class="underline"> Sign up </a>
|
|
87
81
|
</div>
|
|
88
82
|
{/if}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
{
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
{@render formHead?.()}
|
|
99
|
-
{#if children}
|
|
100
|
-
{@render children?.()}
|
|
101
|
-
{:else}
|
|
102
|
-
<Form.Field form={superform} name="email">
|
|
103
|
-
<Form.Control>
|
|
104
|
-
{#snippet children({ props })}
|
|
105
|
-
<Form.Label>Email</Form.Label>
|
|
106
|
-
<Input {...props} bind:value={$formData.email} type="email" required />
|
|
107
|
-
{/snippet}
|
|
108
|
-
</Form.Control>
|
|
109
|
-
<Form.FieldErrors />
|
|
110
|
-
</Form.Field>
|
|
111
|
-
<Form.Field form={superform} name="password">
|
|
112
|
-
<Form.Control>
|
|
113
|
-
{#snippet children({ props })}
|
|
114
|
-
<div class="flex items-center">
|
|
115
|
-
<Form.Label>Password</Form.Label>
|
|
116
|
-
{#if forgotPassword}
|
|
117
|
-
<a href={forgotPasswordLink} class="ml-auto inline-block text-sm underline">
|
|
118
|
-
Forgot your password?
|
|
119
|
-
</a>
|
|
120
|
-
{/if}
|
|
121
|
-
</div>
|
|
122
|
-
<Input {...props} bind:value={$formData.password} type="password" required />
|
|
123
|
-
{/snippet}
|
|
124
|
-
</Form.Control>
|
|
125
|
-
<Form.FieldErrors />
|
|
126
|
-
</Form.Field>
|
|
83
|
+
{@render tail?.()}
|
|
84
|
+
|
|
85
|
+
{#if debug}
|
|
86
|
+
<div class="mb-6">
|
|
87
|
+
<h4>Errors</h4>
|
|
88
|
+
<SuperDebug data={errors} />
|
|
89
|
+
</div>
|
|
90
|
+
<h4>Message</h4>
|
|
91
|
+
<SuperDebug data={$message} />
|
|
127
92
|
{/if}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
{#if register}
|
|
132
|
-
<div class="mt-4 text-center text-sm">
|
|
133
|
-
Don't have an account?
|
|
134
|
-
<a href={registerLink} class="underline"> Sign up </a>
|
|
135
|
-
</div>
|
|
136
|
-
{/if}
|
|
137
|
-
</div>
|
|
138
|
-
{/if}
|
|
93
|
+
</Card.Content>
|
|
94
|
+
</LoginContainer>
|
|
95
|
+
</LoginProvider>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Card } from '@tanglemedia/svelte-starter-ui-shadcn';
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
4
|
+
|
|
5
|
+
type LoginHeaderAttr = {
|
|
6
|
+
text?: string;
|
|
7
|
+
desc?: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
type LoginHeaderProps = LoginHeaderAttr & {
|
|
11
|
+
title?: Snippet<[LoginHeaderAttr]>;
|
|
12
|
+
description?: Snippet<[LoginHeaderAttr]>;
|
|
13
|
+
children?: Snippet<[LoginHeaderAttr]>;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
let { title, children, description, ...restProps }: LoginHeaderProps = $props();
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<Card.Header>
|
|
20
|
+
<Card.Title class="text-2xl">
|
|
21
|
+
{#if title}
|
|
22
|
+
{@render title(restProps)}
|
|
23
|
+
{:else if children}
|
|
24
|
+
{@render children?.(restProps)}
|
|
25
|
+
{:else}
|
|
26
|
+
{restProps.text}
|
|
27
|
+
{/if}
|
|
28
|
+
</Card.Title>
|
|
29
|
+
{#if description}
|
|
30
|
+
<Card.Description>{@render description(restProps)}</Card.Description>
|
|
31
|
+
{:else if restProps.desc}
|
|
32
|
+
<Card.Description>{restProps.desc}</Card.Description>
|
|
33
|
+
{/if}
|
|
34
|
+
</Card.Header>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import { type FormPathLeaves as _FormPathLeaves } from 'sveltekit-superforms';
|
|
3
|
+
|
|
4
|
+
type T = Record<string, unknown>;
|
|
5
|
+
type U = _FormPathLeaves<T, any>;
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<script
|
|
9
|
+
lang="ts"
|
|
10
|
+
generics="T extends Record<string, unknown>, U extends _FormPathLeaves<T, any>"
|
|
11
|
+
>
|
|
12
|
+
import {
|
|
13
|
+
Field,
|
|
14
|
+
type PasswordFieldProps,
|
|
15
|
+
} from '@tanglemedia/svelte-starter-form-shadcn';
|
|
16
|
+
|
|
17
|
+
type LoginPasswordInputProps = PasswordFieldProps<T, U>;
|
|
18
|
+
const { name = 'password' as U, ...rest }: LoginPasswordInputProps = $props();
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<Field.Password {name} {...rest}></Field.Password>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
type T = Record<string, unknown>;
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<script lang="ts" generics="T extends Record<string, unknown>">
|
|
6
|
+
import {
|
|
7
|
+
Form,
|
|
8
|
+
type FormProviderProps,
|
|
9
|
+
} from "@tanglemedia/svelte-starter-form-shadcn";
|
|
10
|
+
let rest: FormProviderProps<T> = $props();
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<Form.Provider {...rest} />
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Form } from "@tanglemedia/svelte-starter-form-shadcn";
|
|
3
|
+
import type { Snippet } from "svelte";
|
|
4
|
+
|
|
5
|
+
type LoginSubmitProps = {
|
|
6
|
+
children?: Snippet;
|
|
7
|
+
};
|
|
8
|
+
const { children }: LoginSubmitProps = $props();
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<Form.Submit class="w-full">
|
|
12
|
+
{#if children}
|
|
13
|
+
{@render children?.()}
|
|
14
|
+
{:else}
|
|
15
|
+
Login
|
|
16
|
+
{/if}
|
|
17
|
+
</Form.Submit>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import { type FormPathLeaves as _FormPathLeaves } from 'sveltekit-superforms';
|
|
3
|
+
|
|
4
|
+
type T = Record<string, unknown>;
|
|
5
|
+
type U = _FormPathLeaves<T, any>;
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<script
|
|
9
|
+
lang="ts"
|
|
10
|
+
generics="T extends Record<string, unknown>, U extends _FormPathLeaves<T, any>"
|
|
11
|
+
>
|
|
12
|
+
import {
|
|
13
|
+
Field,
|
|
14
|
+
type InputFieldProps,
|
|
15
|
+
} from '@tanglemedia/svelte-starter-form-shadcn';
|
|
16
|
+
|
|
17
|
+
type LoginUserInputProps = InputFieldProps<T, U>;
|
|
18
|
+
const { name = 'username' as U, label, ...rest }: LoginUserInputProps = $props();
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<Field.Input type={'email'} {name} label={label || 'Username'} {...rest}></Field.Input>
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Form from './register-form.svelte';
|
|
2
|
+
import Provider from './register-provider.svelte';
|
|
3
|
+
import Header from './register-header.svelte';
|
|
4
|
+
import { registerSchema as schema, type RegisterSchema } from './register.schema.ts';
|
|
5
|
+
import Container from './register-container.svelte';
|
|
6
|
+
import Submit from './register-submit.svelte';
|
|
7
|
+
import UserInput from './register-user-input.svelte';
|
|
8
|
+
import PasswordInput from './register-password-input.svelte';
|
|
9
|
+
import NameInput from './register-name-input.svelte';
|
|
2
10
|
|
|
3
|
-
export {
|
|
11
|
+
export {
|
|
12
|
+
Form,
|
|
13
|
+
Provider,
|
|
14
|
+
Header,
|
|
15
|
+
Container,
|
|
16
|
+
schema,
|
|
17
|
+
Submit,
|
|
18
|
+
UserInput,
|
|
19
|
+
PasswordInput,
|
|
20
|
+
NameInput,
|
|
21
|
+
type RegisterSchema,
|
|
22
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Card } from '@tanglemedia/svelte-starter-ui-shadcn';
|
|
3
|
+
import type { WithChild } from 'svelte-toolbelt';
|
|
4
|
+
import { cn } from '../../../utils.js';
|
|
5
|
+
|
|
6
|
+
type LoginContainerProps = Omit<WithChild, 'child'> & {
|
|
7
|
+
class?: string;
|
|
8
|
+
card?: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const {
|
|
12
|
+
children,
|
|
13
|
+
class: cls,
|
|
14
|
+
card = true,
|
|
15
|
+
...rest
|
|
16
|
+
}: LoginContainerProps = $props();
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
{#if !card}
|
|
20
|
+
<div class={cn('mx-auto max-w-sm', cls)} {...rest}>
|
|
21
|
+
{@render children?.()}
|
|
22
|
+
</div>
|
|
23
|
+
{:else}
|
|
24
|
+
<Card.Root class={cn('mx-auto max-w-sm', cls)} {...rest}>
|
|
25
|
+
{@render children?.()}
|
|
26
|
+
</Card.Root>
|
|
27
|
+
{/if}
|