@tanglemedia/svelte-starter-auth-shadcn 0.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/LICENSE +7 -0
- package/README.md +21 -0
- package/dist/app.html +13 -0
- package/dist/lib/components/ui/auth-layout/auth-layout.svelte +91 -0
- package/dist/lib/components/ui/auth-layout/auth-layout.svelte.d.ts +16 -0
- package/dist/lib/components/ui/auth-layout/index.d.ts +2 -0
- package/dist/lib/components/ui/auth-layout/index.js +2 -0
- package/dist/lib/components/ui/forgot-password/forgot-password-form.svelte +102 -0
- package/dist/lib/components/ui/forgot-password/forgot-password-form.svelte.d.ts +16 -0
- package/dist/lib/components/ui/forgot-password/index.d.ts +2 -0
- package/dist/lib/components/ui/forgot-password/index.js +2 -0
- package/dist/lib/components/ui/login-form/index.d.ts +2 -0
- package/dist/lib/components/ui/login-form/index.js +2 -0
- package/dist/lib/components/ui/login-form/login-form.svelte +138 -0
- package/dist/lib/components/ui/login-form/login-form.svelte.d.ts +18 -0
- package/dist/lib/components/ui/register-form/index.d.ts +2 -0
- package/dist/lib/components/ui/register-form/index.js +2 -0
- package/dist/lib/components/ui/register-form/register-form.svelte +197 -0
- package/dist/lib/components/ui/register-form/register-form.svelte.d.ts +15 -0
- package/dist/lib/components/ui/reset-password/index.d.ts +2 -0
- package/dist/lib/components/ui/reset-password/index.js +2 -0
- package/dist/lib/components/ui/reset-password/reset-form.svelte +120 -0
- package/dist/lib/components/ui/reset-password/reset-form.svelte.d.ts +16 -0
- package/dist/lib/hooks/is-mobile.svelte.d.ts +4 -0
- package/dist/lib/hooks/is-mobile.svelte.js +7 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/lib/utils.js +5 -0
- package/package.json +105 -0
- package/src/app.html +13 -0
- package/src/lib/components/ui/auth-layout/auth-layout.svelte +91 -0
- package/src/lib/components/ui/auth-layout/index.ts +3 -0
- package/src/lib/components/ui/forgot-password/forgot-password-form.svelte +102 -0
- package/src/lib/components/ui/forgot-password/index.ts +3 -0
- package/src/lib/components/ui/login-form/index.ts +3 -0
- package/src/lib/components/ui/login-form/login-form.svelte +138 -0
- package/src/lib/components/ui/register-form/index.ts +3 -0
- package/src/lib/components/ui/register-form/register-form.svelte +197 -0
- package/src/lib/components/ui/reset-password/index.ts +3 -0
- package/src/lib/components/ui/reset-password/reset-form.svelte +120 -0
- package/src/lib/hooks/is-mobile.svelte.ts +9 -0
- package/src/lib/utils.ts +6 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2024 Tangle Media
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# @tanglemedia/svelte-starter-auth-shadcn
|
|
2
|
+
|
|
3
|
+
<p align="center" style="align: center;">
|
|
4
|
+
<a href="https://npm.im/@tanglemedia/svelte-starter-auth-shadcn">
|
|
5
|
+
<img src="https://img.shields.io/badge/TypeScript-blue?style=flat-square" alt="TypeScript" />
|
|
6
|
+
</a>
|
|
7
|
+
|
|
8
|
+
<img alt="NPM Version" src="https://img.shields.io/npm/v/%40tanglemedia%2Fsvelte-starter-auth-shadcn">
|
|
9
|
+
|
|
10
|
+
<a href="https://bitbucket.org/tanglemediainc/svelte-starter/src/master/packages/core/">
|
|
11
|
+
<img alt="Repo Bitbucket" src="https://img.shields.io/badge/repo-bitbucket-blue">
|
|
12
|
+
</a>
|
|
13
|
+
|
|
14
|
+
<img alt="Bitbucket open pull requests " src="https://img.shields.io/bitbucket/pr/tanglemediainc/svelte-starter">
|
|
15
|
+
|
|
16
|
+
<a href="https://choosealicense.com/licenses/mit/">
|
|
17
|
+
<img alt="NPM License" src="https://img.shields.io/npm/l/%40tanglemedia%2Fsvelte-starter-auth-shadcn">
|
|
18
|
+
</a>
|
|
19
|
+
</p>
|
|
20
|
+
|
|
21
|
+
The [Auth-Shadcn](https://tanglemedia-svelte-docs.netlify.app) package is responsible for the main UI of unauthorized routes components of your app. This specific package uses ui components and component api from Shadcn and Bits-UI.
|
package/dist/app.html
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/app.html
|
|
2
|
+
<!doctype html>
|
|
3
|
+
<html lang="en">
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="utf-8" />
|
|
6
|
+
<title>Auth</title>
|
|
7
|
+
%sveltekit.head%
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<!-- your auth editor content here -->
|
|
11
|
+
<div style="display: contents">%sveltekit.body%</div>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Button } from '@tanglemedia/svelte-starter-ui-shadcn/Button';
|
|
3
|
+
// import { getConfig } from '@tanglemedia/svelte-starter-core';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
logo?: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
quote?: string;
|
|
9
|
+
quoteAuthor?: string;
|
|
10
|
+
layoutMode?: string;
|
|
11
|
+
leftSideBackground?: string;
|
|
12
|
+
rightSideBackground?: string;
|
|
13
|
+
opacity?: number;
|
|
14
|
+
logoClass?: string;
|
|
15
|
+
filterClass?: string;
|
|
16
|
+
imageClass?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let {
|
|
20
|
+
logo,
|
|
21
|
+
name,
|
|
22
|
+
quote,
|
|
23
|
+
quoteAuthor,
|
|
24
|
+
layoutMode,
|
|
25
|
+
leftSideBackground,
|
|
26
|
+
rightSideBackground,
|
|
27
|
+
opacity,
|
|
28
|
+
logoClass,
|
|
29
|
+
filterClass,
|
|
30
|
+
imageClass,
|
|
31
|
+
children
|
|
32
|
+
}: Props = $props();
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<div
|
|
36
|
+
class="container relative h-[100vh] flex-col items-center justify-center grid lg:max-w-none lg:grid-cols-2 lg:px-0"
|
|
37
|
+
>
|
|
38
|
+
<div class="bg-muted relative hidden h-full flex-col p-10 text-white lg:flex dark:border-r">
|
|
39
|
+
<div
|
|
40
|
+
class="absolute inset-0 bg-background"
|
|
41
|
+
style="
|
|
42
|
+
background-image:
|
|
43
|
+
url(https://images.unsplash.com/photo-1590069261209-f8e9b8642343?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1376&q=80);"
|
|
44
|
+
></div>
|
|
45
|
+
<div class="relative z-20 flex items-center text-lg font-medium text-shadow-lg">
|
|
46
|
+
Acme Inc
|
|
47
|
+
</div>
|
|
48
|
+
<div class="relative z-20 mt-auto">
|
|
49
|
+
<blockquote class="space-y-2">
|
|
50
|
+
<p class="text-lg text-shadow-lg">
|
|
51
|
+
“This library has saved me countless hours of work and helped me deliver
|
|
52
|
+
stunning designs to my clients faster than ever before. Highly
|
|
53
|
+
recommended!”
|
|
54
|
+
</p>
|
|
55
|
+
<footer class="text-sm text-shadow-lg">Sofia Davis</footer>
|
|
56
|
+
</blockquote>
|
|
57
|
+
</div>
|
|
58
|
+
<div class="absolute top-0 bottom-0 left-0 right-0 bg-primary-500/10 filter blur(2px)"></div>
|
|
59
|
+
</div>
|
|
60
|
+
<div class="lg:hidden absolute top-0 left-0 right-0 bottom-1/2 z-[-1]" style="
|
|
61
|
+
mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
|
|
62
|
+
background-image:
|
|
63
|
+
url(https://images.unsplash.com/photo-1590069261209-f8e9b8642343?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx);
|
|
64
|
+
background-size: cover;
|
|
65
|
+
background-position: center">
|
|
66
|
+
<div class="text-white top-6 left-6 absolute text-lg font-medium z-20 text-shadow-lg">
|
|
67
|
+
Acme Inc
|
|
68
|
+
<blockquote class="space-y-2 mt-2 mr-4">
|
|
69
|
+
<p class="text-sm text-shadow-lg">
|
|
70
|
+
“This library has saved me countless hours of work and helped me deliver
|
|
71
|
+
stunning designs to my clients faster than ever before. Highly
|
|
72
|
+
recommended!”
|
|
73
|
+
</p>
|
|
74
|
+
<footer class="text-xs text-shadow-lg">Sofia Davis</footer>
|
|
75
|
+
</blockquote>
|
|
76
|
+
</div>
|
|
77
|
+
<div class="absolute top-0 bottom-0 left-0 right-0 bg-primary-500/10 filter blur(2px)"></div>
|
|
78
|
+
<div class="absolute bottom-0 left-0 right-0 h-20 bg-gradient-to-b from-gray-900/10 to-background transition duration-500 ease-in-out"></div>
|
|
79
|
+
</div>
|
|
80
|
+
<div class="lg:p-8">
|
|
81
|
+
<div class="mx-auto flex w-full flex-col justify-center space-y-6">
|
|
82
|
+
{@render children()}
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
<style>
|
|
88
|
+
.text-shadow-lg {
|
|
89
|
+
text-shadow: 0 2px 2px rgb(0 0 0 / 0.4);
|
|
90
|
+
}
|
|
91
|
+
</style>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
logo?: string;
|
|
3
|
+
name?: string;
|
|
4
|
+
quote?: string;
|
|
5
|
+
quoteAuthor?: string;
|
|
6
|
+
layoutMode?: string;
|
|
7
|
+
leftSideBackground?: string;
|
|
8
|
+
rightSideBackground?: string;
|
|
9
|
+
opacity?: number;
|
|
10
|
+
logoClass?: string;
|
|
11
|
+
filterClass?: string;
|
|
12
|
+
imageClass?: string;
|
|
13
|
+
}
|
|
14
|
+
declare const AuthLayout: import("svelte").Component<Props, {}, "">;
|
|
15
|
+
type AuthLayout = ReturnType<typeof AuthLayout>;
|
|
16
|
+
export default AuthLayout;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import * as Card from '@tanglemedia/svelte-starter-ui-shadcn/Card';
|
|
3
|
+
import { Button } from '@tanglemedia/svelte-starter-ui-shadcn/Button';
|
|
4
|
+
import { Input } from '@tanglemedia/svelte-starter-ui-shadcn/Input';
|
|
5
|
+
import { Label } from '@tanglemedia/svelte-starter-ui-shadcn/Label';
|
|
6
|
+
import * as Form from '@tanglemedia/svelte-starter-ui-shadcn/Form';
|
|
7
|
+
import type { Snippet } from 'svelte';
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
superform: any;
|
|
11
|
+
card?: boolean;
|
|
12
|
+
cardClass?: string;
|
|
13
|
+
title?: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
login?: boolean;
|
|
16
|
+
loginLink?: string;
|
|
17
|
+
formTail?: Snippet;
|
|
18
|
+
formHead?: Snippet;
|
|
19
|
+
children?: Snippet;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let {
|
|
23
|
+
superform,
|
|
24
|
+
card = false,
|
|
25
|
+
cardClass = "mx-auto max-w-sm",
|
|
26
|
+
title = "Forgot Password",
|
|
27
|
+
description = "Enter your email below to request a password reset",
|
|
28
|
+
login = true,
|
|
29
|
+
loginLink = "/login",
|
|
30
|
+
formTail,
|
|
31
|
+
formHead,
|
|
32
|
+
children
|
|
33
|
+
}: Props = $props();
|
|
34
|
+
|
|
35
|
+
const { form: formData, enhance } = superform;
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
{#if card}
|
|
39
|
+
<Card.Root class={cardClass}>
|
|
40
|
+
<Card.Header>
|
|
41
|
+
<Card.Title class="text-2xl">{title}</Card.Title>
|
|
42
|
+
<Card.Description>{description}</Card.Description>
|
|
43
|
+
</Card.Header>
|
|
44
|
+
<Card.Content>
|
|
45
|
+
<form method="POST" use:enhance class="grid gap-4">
|
|
46
|
+
{@render formHead?.()}
|
|
47
|
+
{#if children}
|
|
48
|
+
{@render children?.()}
|
|
49
|
+
{:else}
|
|
50
|
+
<Form.Field form={superform} name="email">
|
|
51
|
+
<Form.Control>
|
|
52
|
+
{#snippet children({ props })}
|
|
53
|
+
<Form.Label>Email</Form.Label>
|
|
54
|
+
<Input {...props} bind:value={$formData.email} type="email" required />
|
|
55
|
+
{/snippet}
|
|
56
|
+
</Form.Control>
|
|
57
|
+
<Form.FieldErrors />
|
|
58
|
+
</Form.Field>
|
|
59
|
+
{/if}
|
|
60
|
+
<Form.Button type="submit" class="w-full">Request Password</Form.Button>
|
|
61
|
+
{@render formTail?.()}
|
|
62
|
+
</form>
|
|
63
|
+
{#if login}
|
|
64
|
+
<div class="mt-4 text-center text-sm">
|
|
65
|
+
Remember your password?
|
|
66
|
+
<a href={loginLink} class="underline"> Sign in </a>
|
|
67
|
+
</div>
|
|
68
|
+
{/if}
|
|
69
|
+
</Card.Content>
|
|
70
|
+
</Card.Root>
|
|
71
|
+
{:else}
|
|
72
|
+
<div class={cardClass}>
|
|
73
|
+
<div class="flex flex-col space-y-1.5 p-6 pb-0">
|
|
74
|
+
<h3 class="font-semibold tracking-tight text-2xl">{title}</h3>
|
|
75
|
+
<p class="text-muted-foreground text-sm">{description}</p>
|
|
76
|
+
</div>
|
|
77
|
+
<form method="POST" use:enhance class="grid gap-4 p-6">
|
|
78
|
+
{@render formHead?.()}
|
|
79
|
+
{#if children}
|
|
80
|
+
{@render children?.()}
|
|
81
|
+
{:else}
|
|
82
|
+
<Form.Field form={superform} name="email">
|
|
83
|
+
<Form.Control>
|
|
84
|
+
{#snippet children({ props })}
|
|
85
|
+
<Form.Label>Email</Form.Label>
|
|
86
|
+
<Input {...props} bind:value={$formData.email} type="email" required />
|
|
87
|
+
{/snippet}
|
|
88
|
+
</Form.Control>
|
|
89
|
+
<Form.FieldErrors />
|
|
90
|
+
</Form.Field>
|
|
91
|
+
{/if}
|
|
92
|
+
<Form.Button type="submit" class="w-full">Request Password</Form.Button>
|
|
93
|
+
{@render formTail?.()}
|
|
94
|
+
</form>
|
|
95
|
+
{#if login}
|
|
96
|
+
<div class="mt-4 text-center text-sm">
|
|
97
|
+
Remember your password?
|
|
98
|
+
<a href={loginLink} class="underline"> Sign in </a>
|
|
99
|
+
</div>
|
|
100
|
+
{/if}
|
|
101
|
+
</div>
|
|
102
|
+
{/if}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
interface Props {
|
|
3
|
+
superform: any;
|
|
4
|
+
card?: boolean;
|
|
5
|
+
cardClass?: string;
|
|
6
|
+
title?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
login?: boolean;
|
|
9
|
+
loginLink?: string;
|
|
10
|
+
formTail?: Snippet;
|
|
11
|
+
formHead?: Snippet;
|
|
12
|
+
children?: Snippet;
|
|
13
|
+
}
|
|
14
|
+
declare const ForgotPasswordForm: import("svelte").Component<Props, {}, "">;
|
|
15
|
+
type ForgotPasswordForm = ReturnType<typeof ForgotPasswordForm>;
|
|
16
|
+
export default ForgotPasswordForm;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import * as Card from '@tanglemedia/svelte-starter-ui-shadcn/Card';
|
|
3
|
+
import { Button } from '@tanglemedia/svelte-starter-ui-shadcn/Button';
|
|
4
|
+
import { Input } from '@tanglemedia/svelte-starter-ui-shadcn/Input';
|
|
5
|
+
import { Label } from '@tanglemedia/svelte-starter-ui-shadcn/Label';
|
|
6
|
+
import * as Form from '@tanglemedia/svelte-starter-ui-shadcn/Form';
|
|
7
|
+
import type { Snippet } from 'svelte';
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
superform: any;
|
|
11
|
+
card?: boolean;
|
|
12
|
+
cardClass?: string;
|
|
13
|
+
title?: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
forgotPassword?: boolean;
|
|
16
|
+
forgotPasswordLink?: string;
|
|
17
|
+
register?: boolean;
|
|
18
|
+
registerLink?: string;
|
|
19
|
+
formTail?: Snippet;
|
|
20
|
+
formHead?: Snippet;
|
|
21
|
+
children?: Snippet;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let {
|
|
25
|
+
superform,
|
|
26
|
+
card = false,
|
|
27
|
+
cardClass = "mx-auto max-w-sm",
|
|
28
|
+
title = "Login",
|
|
29
|
+
description = "Enter your information below to register a new account",
|
|
30
|
+
forgotPassword = true,
|
|
31
|
+
forgotPasswordLink = "/forgot-password",
|
|
32
|
+
register = true,
|
|
33
|
+
registerLink = "/register",
|
|
34
|
+
formTail,
|
|
35
|
+
formHead,
|
|
36
|
+
children
|
|
37
|
+
}: Props = $props();
|
|
38
|
+
|
|
39
|
+
const { form: formData, enhance } = superform;
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
{#if card}
|
|
43
|
+
<Card.Root class={cardClass}>
|
|
44
|
+
<Card.Header>
|
|
45
|
+
<Card.Title class="text-2xl">{title}</Card.Title>
|
|
46
|
+
<Card.Description>{description}</Card.Description>
|
|
47
|
+
</Card.Header>
|
|
48
|
+
<Card.Content>
|
|
49
|
+
<form method="POST" use:enhance class="grid gap-4">
|
|
50
|
+
{@render formHead?.()}
|
|
51
|
+
{#if children}
|
|
52
|
+
{@render children?.()}
|
|
53
|
+
{:else}
|
|
54
|
+
<Form.Field form={superform} name="email">
|
|
55
|
+
<Form.Control>
|
|
56
|
+
{#snippet children({ props })}
|
|
57
|
+
<Form.Label>Email</Form.Label>
|
|
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>
|
|
83
|
+
{#if register}
|
|
84
|
+
<div class="mt-4 text-center text-sm">
|
|
85
|
+
Don't have an account?
|
|
86
|
+
<a href={registerLink} class="underline"> Sign up </a>
|
|
87
|
+
</div>
|
|
88
|
+
{/if}
|
|
89
|
+
</Card.Content>
|
|
90
|
+
</Card.Root>
|
|
91
|
+
{:else}
|
|
92
|
+
<div class={cardClass}>
|
|
93
|
+
<div class="flex flex-col space-y-1.5 p-6 pb-0">
|
|
94
|
+
<h3 class="font-semibold tracking-tight text-2xl">{title}</h3>
|
|
95
|
+
<p class="text-muted-foreground text-sm">{description}</p>
|
|
96
|
+
</div>
|
|
97
|
+
<form method="POST" use:enhance class="grid gap-4 p-6">
|
|
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>
|
|
127
|
+
{/if}
|
|
128
|
+
<Form.Button type="submit" class="w-full">Login</Form.Button>
|
|
129
|
+
{@render formTail?.()}
|
|
130
|
+
</form>
|
|
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}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
interface Props {
|
|
3
|
+
superform: any;
|
|
4
|
+
card?: boolean;
|
|
5
|
+
cardClass?: string;
|
|
6
|
+
title?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
forgotPassword?: boolean;
|
|
9
|
+
forgotPasswordLink?: string;
|
|
10
|
+
register?: boolean;
|
|
11
|
+
registerLink?: string;
|
|
12
|
+
formTail?: Snippet;
|
|
13
|
+
formHead?: Snippet;
|
|
14
|
+
children?: Snippet;
|
|
15
|
+
}
|
|
16
|
+
declare const LoginForm: import("svelte").Component<Props, {}, "">;
|
|
17
|
+
type LoginForm = ReturnType<typeof LoginForm>;
|
|
18
|
+
export default LoginForm;
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import * as Card from '@tanglemedia/svelte-starter-ui-shadcn/Card';
|
|
3
|
+
import { Button } from '@tanglemedia/svelte-starter-ui-shadcn/Button';
|
|
4
|
+
import { Input } from '@tanglemedia/svelte-starter-ui-shadcn/Input';
|
|
5
|
+
import { Label } from '@tanglemedia/svelte-starter-ui-shadcn/Label';
|
|
6
|
+
import * as Form from '@tanglemedia/svelte-starter-ui-shadcn/Form';
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
superform: any;
|
|
10
|
+
card?: boolean;
|
|
11
|
+
cardClass?: string;
|
|
12
|
+
title?: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
login?: boolean;
|
|
15
|
+
loginLink?: string;
|
|
16
|
+
formTail?: Snippet;
|
|
17
|
+
formHead?: Snippet;
|
|
18
|
+
children?: Snippet;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let {
|
|
22
|
+
superform,
|
|
23
|
+
card = false,
|
|
24
|
+
cardClass = "mx-auto max-w-sm",
|
|
25
|
+
title = "Register",
|
|
26
|
+
description = "Enter your information below to register a new account",
|
|
27
|
+
login = true,
|
|
28
|
+
loginLink = "/login",
|
|
29
|
+
formTail,
|
|
30
|
+
formHead,
|
|
31
|
+
children
|
|
32
|
+
}: Props = $props();
|
|
33
|
+
|
|
34
|
+
const { form: formData, enhance } = superform;
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
{#if card}
|
|
38
|
+
<Card.Root class={cardClass}>
|
|
39
|
+
<Card.Header>
|
|
40
|
+
<Card.Title class="text-2xl">{title}</Card.Title>
|
|
41
|
+
<Card.Description>{description}</Card.Description>
|
|
42
|
+
</Card.Header>
|
|
43
|
+
<Card.Content>
|
|
44
|
+
<form method="POST" use:enhance class="grid gap-4">
|
|
45
|
+
{@render formHead?.()}
|
|
46
|
+
{#if children}
|
|
47
|
+
{@render children?.()}
|
|
48
|
+
{:else}
|
|
49
|
+
<div class="grid grid-cols-2 gap-4">
|
|
50
|
+
<Form.Field form={superform} name="first_name">
|
|
51
|
+
<Form.Control >
|
|
52
|
+
{#snippet children({ props })}
|
|
53
|
+
<Form.Label>
|
|
54
|
+
First Name
|
|
55
|
+
</Form.Label>
|
|
56
|
+
<Input {...props} bind:value={$formData.first_name} />
|
|
57
|
+
{/snippet}
|
|
58
|
+
</Form.Control>
|
|
59
|
+
<Form.FieldErrors />
|
|
60
|
+
</Form.Field>
|
|
61
|
+
<Form.Field form={superform} name="last_name">
|
|
62
|
+
<Form.Control >
|
|
63
|
+
{#snippet children({ props })}
|
|
64
|
+
<Form.Label>
|
|
65
|
+
Last Name
|
|
66
|
+
</Form.Label>
|
|
67
|
+
<Input {...props} bind:value={$formData.last_name} />
|
|
68
|
+
{/snippet}
|
|
69
|
+
</Form.Control>
|
|
70
|
+
<Form.FieldErrors />
|
|
71
|
+
</Form.Field>
|
|
72
|
+
</div>
|
|
73
|
+
<Form.Field form={superform} name="email">
|
|
74
|
+
<Form.Control >
|
|
75
|
+
{#snippet children({ props })}
|
|
76
|
+
<Form.Label>
|
|
77
|
+
Email
|
|
78
|
+
</Form.Label>
|
|
79
|
+
<Input {...props} bind:value={$formData.email} type="email" />
|
|
80
|
+
{/snippet}
|
|
81
|
+
</Form.Control>
|
|
82
|
+
<Form.FieldErrors />
|
|
83
|
+
</Form.Field>
|
|
84
|
+
<Form.Field form={superform} name="password">
|
|
85
|
+
<Form.Control >
|
|
86
|
+
{#snippet children({ props })}
|
|
87
|
+
<Form.Label>
|
|
88
|
+
Password
|
|
89
|
+
</Form.Label>
|
|
90
|
+
<Input {...props} bind:value={$formData.password} type="password" />
|
|
91
|
+
{/snippet}
|
|
92
|
+
</Form.Control>
|
|
93
|
+
<Form.FieldErrors />
|
|
94
|
+
</Form.Field>
|
|
95
|
+
<Form.Field form={superform} name="confirm_password">
|
|
96
|
+
<Form.Control >
|
|
97
|
+
{#snippet children({ props })}
|
|
98
|
+
<Form.Label>
|
|
99
|
+
Confirm Password
|
|
100
|
+
</Form.Label>
|
|
101
|
+
<Input {...props} bind:value={$formData.confirm_password} type="password" />
|
|
102
|
+
{/snippet}
|
|
103
|
+
</Form.Control>
|
|
104
|
+
<Form.FieldErrors />
|
|
105
|
+
</Form.Field>
|
|
106
|
+
{/if}
|
|
107
|
+
<Form.Button type="submit" class="w-full">Register</Form.Button>
|
|
108
|
+
{@render formTail?.()}
|
|
109
|
+
</form>
|
|
110
|
+
{#if login}
|
|
111
|
+
<div class="mt-4 text-center text-sm">
|
|
112
|
+
Already have an account?
|
|
113
|
+
<a href={loginLink} class="underline"> Sign in </a>
|
|
114
|
+
</div>
|
|
115
|
+
{/if}
|
|
116
|
+
</Card.Content>
|
|
117
|
+
</Card.Root>
|
|
118
|
+
{:else}
|
|
119
|
+
<div class={cardClass}>
|
|
120
|
+
<div class="flex flex-col space-y-1.5">
|
|
121
|
+
<h3 class="font-semibold tracking-tight text-2xl">{title}</h3>
|
|
122
|
+
<p class="text-muted-foreground text-sm">{description}</p>
|
|
123
|
+
</div>
|
|
124
|
+
<form method="POST" use:enhance class="grid gap-4">
|
|
125
|
+
{@render formHead?.()}
|
|
126
|
+
{#if children}
|
|
127
|
+
{@render children?.()}
|
|
128
|
+
{:else}
|
|
129
|
+
<div class="grid grid-cols-2 gap-4">
|
|
130
|
+
<Form.Field form={superform} name="first_name">
|
|
131
|
+
<Form.Control >
|
|
132
|
+
{#snippet children({ props })}
|
|
133
|
+
<Form.Label>
|
|
134
|
+
First Name
|
|
135
|
+
</Form.Label>
|
|
136
|
+
<Input {...props} bind:value={$formData.first_name} />
|
|
137
|
+
{/snippet}
|
|
138
|
+
</Form.Control>
|
|
139
|
+
<Form.FieldErrors />
|
|
140
|
+
</Form.Field>
|
|
141
|
+
<Form.Field form={superform} name="last_name">
|
|
142
|
+
<Form.Control >
|
|
143
|
+
{#snippet children({ props })}
|
|
144
|
+
<Form.Label>
|
|
145
|
+
Last Name
|
|
146
|
+
</Form.Label>
|
|
147
|
+
<Input {...props} bind:value={$formData.last_name} />
|
|
148
|
+
{/snippet}
|
|
149
|
+
</Form.Control>
|
|
150
|
+
<Form.FieldErrors />
|
|
151
|
+
</Form.Field>
|
|
152
|
+
</div>
|
|
153
|
+
<Form.Field form={superform} name="email">
|
|
154
|
+
<Form.Control >
|
|
155
|
+
{#snippet children({ props })}
|
|
156
|
+
<Form.Label>
|
|
157
|
+
Email
|
|
158
|
+
</Form.Label>
|
|
159
|
+
<Input {...props} bind:value={$formData.email} type="email" />
|
|
160
|
+
{/snippet}
|
|
161
|
+
</Form.Control>
|
|
162
|
+
<Form.FieldErrors />
|
|
163
|
+
</Form.Field>
|
|
164
|
+
<Form.Field form={superform} name="password">
|
|
165
|
+
<Form.Control >
|
|
166
|
+
{#snippet children({ props })}
|
|
167
|
+
<Form.Label>
|
|
168
|
+
Password
|
|
169
|
+
</Form.Label>
|
|
170
|
+
<Input {...props} bind:value={$formData.password} type="password" />
|
|
171
|
+
{/snippet}
|
|
172
|
+
</Form.Control>
|
|
173
|
+
<Form.FieldErrors />
|
|
174
|
+
</Form.Field>
|
|
175
|
+
<Form.Field form={superform} name="confirm_password">
|
|
176
|
+
<Form.Control >
|
|
177
|
+
{#snippet children({ props })}
|
|
178
|
+
<Form.Label>
|
|
179
|
+
Confirm Password
|
|
180
|
+
</Form.Label>
|
|
181
|
+
<Input {...props} bind:value={$formData.confirm_password} type="password" />
|
|
182
|
+
{/snippet}
|
|
183
|
+
</Form.Control>
|
|
184
|
+
<Form.FieldErrors />
|
|
185
|
+
</Form.Field>
|
|
186
|
+
{/if}
|
|
187
|
+
<Form.Button type="submit" class="w-full">Register</Form.Button>
|
|
188
|
+
{@render formTail?.()}
|
|
189
|
+
</form>
|
|
190
|
+
{#if login}
|
|
191
|
+
<div class="mt-4 text-center text-sm">
|
|
192
|
+
Already have an account?
|
|
193
|
+
<a href={loginLink} class="underline"> Sign in </a>
|
|
194
|
+
</div>
|
|
195
|
+
{/if}
|
|
196
|
+
</div>
|
|
197
|
+
{/if}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
superform: any;
|
|
3
|
+
card?: boolean;
|
|
4
|
+
cardClass?: string;
|
|
5
|
+
title?: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
login?: boolean;
|
|
8
|
+
loginLink?: string;
|
|
9
|
+
formTail?: Snippet;
|
|
10
|
+
formHead?: Snippet;
|
|
11
|
+
children?: Snippet;
|
|
12
|
+
}
|
|
13
|
+
declare const RegisterForm: import("svelte").Component<Props, {}, "">;
|
|
14
|
+
type RegisterForm = ReturnType<typeof RegisterForm>;
|
|
15
|
+
export default RegisterForm;
|