@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
|
@@ -1,197 +1,94 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
+
|
|
13
|
+
import RegisterProvider from "./register-provider.svelte";
|
|
14
|
+
import RegisterContainer from "./register-container.svelte";
|
|
15
|
+
import RegisterHeader from "./register-header.svelte";
|
|
16
|
+
import RegisterSubmit from "./register-submit.svelte";
|
|
17
|
+
import RegisterUserInput from "./register-user-input.svelte";
|
|
18
|
+
import RegisterPasswordInput from "./register-password-input.svelte";
|
|
19
|
+
import RegisterNameInput from "./register-name-input.svelte";
|
|
20
|
+
import { registerSchema, type RegisterSchema } from "./register.schema.js";
|
|
21
|
+
|
|
22
|
+
import { ServerError } from "@tanglemedia/svelte-starter-form-shadcn";
|
|
23
|
+
// import { Field } from "@tanglemedia/svelte-starter-form-shadcn";
|
|
7
24
|
|
|
8
25
|
interface Props {
|
|
9
|
-
superform
|
|
26
|
+
superform?: SuperForm<Infer<RegisterSchema>> | null;
|
|
10
27
|
card?: boolean;
|
|
11
|
-
cardClass?: string;
|
|
28
|
+
// cardClass?: string;
|
|
12
29
|
title?: string;
|
|
13
30
|
description?: string;
|
|
31
|
+
// forgotPassword?: boolean;
|
|
14
32
|
login?: boolean;
|
|
15
33
|
loginLink?: string;
|
|
16
|
-
|
|
17
|
-
|
|
34
|
+
lead?: Snippet;
|
|
35
|
+
tail?: Snippet;
|
|
18
36
|
children?: Snippet;
|
|
37
|
+
form?: SuperValidated<Infer<RegisterSchema>>;
|
|
38
|
+
action?: string;
|
|
39
|
+
|
|
40
|
+
debug?: boolean;
|
|
19
41
|
}
|
|
20
42
|
|
|
21
|
-
let {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
43
|
+
let {
|
|
44
|
+
debug = false,
|
|
45
|
+
form,
|
|
46
|
+
superform: superforms = $bindable(null),
|
|
47
|
+
card = true,
|
|
48
|
+
title = "Register",
|
|
26
49
|
description = "Enter your information below to register a new account",
|
|
50
|
+
// forgotPassword = true,
|
|
27
51
|
login = true,
|
|
28
52
|
loginLink = "/login",
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
53
|
+
lead,
|
|
54
|
+
tail,
|
|
55
|
+
action = "?/register",
|
|
32
56
|
}: Props = $props();
|
|
33
57
|
|
|
34
|
-
|
|
58
|
+
superforms = superforms || superForm(form || defaults(zod4(registerSchema)));
|
|
59
|
+
|
|
60
|
+
const { errors, message } = superforms;
|
|
35
61
|
</script>
|
|
36
62
|
|
|
37
|
-
{
|
|
38
|
-
<
|
|
39
|
-
<
|
|
40
|
-
<Card.Title class="text-2xl">{title}</Card.Title>
|
|
41
|
-
<Card.Description>{description}</Card.Description>
|
|
42
|
-
</Card.Header>
|
|
63
|
+
<RegisterProvider {superforms} {action}>
|
|
64
|
+
<RegisterContainer {card}>
|
|
65
|
+
<RegisterHeader text={title} desc={description} />
|
|
43
66
|
<Card.Content>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
{
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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>
|
|
67
|
+
{@render lead?.()}
|
|
68
|
+
<ServerError class="mb-4" />
|
|
69
|
+
<div class="flex items-start gap-4 *:mb-0">
|
|
70
|
+
<RegisterNameInput name={"first_name"} label={"First Name"} />
|
|
71
|
+
<RegisterNameInput name={"last_name"} label={"Last Name"} />
|
|
72
|
+
</div>
|
|
73
|
+
<RegisterUserInput name={"username"} />
|
|
74
|
+
<RegisterPasswordInput name={"password"} label={"Password"} />
|
|
75
|
+
<RegisterSubmit />
|
|
110
76
|
{#if login}
|
|
111
77
|
<div class="mt-4 text-center text-sm">
|
|
112
78
|
Already have an account?
|
|
113
79
|
<a href={loginLink} class="underline"> Sign in </a>
|
|
114
80
|
</div>
|
|
115
81
|
{/if}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
{
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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>
|
|
82
|
+
{@render tail?.()}
|
|
83
|
+
|
|
84
|
+
{#if debug}
|
|
85
|
+
<div class="mb-6">
|
|
86
|
+
<h4>Errors</h4>
|
|
87
|
+
<SuperDebug data={errors} />
|
|
152
88
|
</div>
|
|
153
|
-
<
|
|
154
|
-
|
|
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>
|
|
89
|
+
<h4>Message</h4>
|
|
90
|
+
<SuperDebug data={$message} />
|
|
186
91
|
{/if}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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}
|
|
92
|
+
</Card.Content>
|
|
93
|
+
</RegisterContainer>
|
|
94
|
+
</RegisterProvider>
|
|
@@ -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 InputFieldProps,
|
|
15
|
+
} from '@tanglemedia/svelte-starter-form-shadcn';
|
|
16
|
+
|
|
17
|
+
type LoginUserInputProps = InputFieldProps<T, U>;
|
|
18
|
+
const { name = 'first_name' as U, label, ...rest }: LoginUserInputProps = $props();
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<Field.Input type={'text'} {name} label={label || 'Name'} {...rest}></Field.Input>
|
|
@@ -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
|
+
Register
|
|
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>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
export const registerSchema = z.object({
|
|
4
|
+
first_name: z.string().min(1, { error: "First name is required" }),
|
|
5
|
+
last_name: z.string().min(1, { error: "Last name is required" }),
|
|
6
|
+
username: z.string().min(1, { error: "Username is required" }),
|
|
7
|
+
password: z.string().min(1, { error: "Password is required" }),
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export type RegisterSchema = typeof registerSchema;
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Form from './reset-password-form.svelte';
|
|
2
|
+
import Provider from './reset-password-provider.svelte';
|
|
3
|
+
import Header from './reset-password-header.svelte';
|
|
4
|
+
import { resetPasswordSchema as schema, type ResetPasswordSchema } from './reset-password.schema.ts';
|
|
5
|
+
import Container from './reset-password-container.svelte';
|
|
6
|
+
import Submit from './reset-password-submit.svelte';
|
|
7
|
+
import PasswordInput from './reset-password-password-input.svelte';
|
|
2
8
|
|
|
3
|
-
export {
|
|
9
|
+
export {
|
|
10
|
+
Form,
|
|
11
|
+
Provider,
|
|
12
|
+
Header,
|
|
13
|
+
Container,
|
|
14
|
+
schema,
|
|
15
|
+
Submit,
|
|
16
|
+
PasswordInput,
|
|
17
|
+
type ResetPasswordSchema,
|
|
18
|
+
};
|
|
@@ -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,91 @@
|
|
|
1
|
+
<!-- title = "Reset Password",
|
|
2
|
+
description = "Enter your new password below to reset your password", -->
|
|
3
|
+
|
|
4
|
+
<script lang="ts">
|
|
5
|
+
import { Card } from "@tanglemedia/svelte-starter-ui-shadcn";
|
|
6
|
+
import type { Snippet } from "svelte";
|
|
7
|
+
import SuperDebug, {
|
|
8
|
+
defaults,
|
|
9
|
+
superForm,
|
|
10
|
+
type Infer,
|
|
11
|
+
type SuperForm,
|
|
12
|
+
type SuperValidated,
|
|
13
|
+
} from "sveltekit-superforms";
|
|
14
|
+
import { zod4 } from "sveltekit-superforms/adapters";
|
|
15
|
+
|
|
16
|
+
import ResetPasswordProvider from "./reset-password-provider.svelte";
|
|
17
|
+
import ResetPasswordContainer from "./reset-password-container.svelte";
|
|
18
|
+
import ResetPasswordHeader from "./reset-password-header.svelte";
|
|
19
|
+
import ResetPasswordSubmit from "./reset-password-submit.svelte";
|
|
20
|
+
import ResetPasswordPasswordInput from "./reset-password-password-input.svelte";
|
|
21
|
+
import { resetPasswordSchema, type ResetPasswordSchema } from "./reset-password.schema.js";
|
|
22
|
+
|
|
23
|
+
import { ServerError } from "@tanglemedia/svelte-starter-form-shadcn";
|
|
24
|
+
// import { Field } from "@tanglemedia/svelte-starter-form-shadcn";
|
|
25
|
+
|
|
26
|
+
interface Props {
|
|
27
|
+
superform?: SuperForm<Infer<ResetPasswordSchema>> | null;
|
|
28
|
+
card?: boolean;
|
|
29
|
+
// cardClass?: string;
|
|
30
|
+
title?: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
// forgotPassword?: boolean;
|
|
33
|
+
login?: boolean;
|
|
34
|
+
loginLink?: string;
|
|
35
|
+
lead?: Snippet;
|
|
36
|
+
tail?: Snippet;
|
|
37
|
+
children?: Snippet;
|
|
38
|
+
form?: SuperValidated<Infer<ResetPasswordSchema>>;
|
|
39
|
+
action?: string;
|
|
40
|
+
|
|
41
|
+
debug?: boolean;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let {
|
|
45
|
+
debug = false,
|
|
46
|
+
form,
|
|
47
|
+
superform: superforms = $bindable(null),
|
|
48
|
+
card = true,
|
|
49
|
+
title = "Reset Password",
|
|
50
|
+
description = "Enter your new password below to reset your password",
|
|
51
|
+
// forgotPassword = true,
|
|
52
|
+
login = true,
|
|
53
|
+
loginLink = "/login",
|
|
54
|
+
lead,
|
|
55
|
+
tail,
|
|
56
|
+
action = "?/register",
|
|
57
|
+
}: Props = $props();
|
|
58
|
+
|
|
59
|
+
superforms = superforms || superForm(form || defaults(zod4(resetPasswordSchema)));
|
|
60
|
+
|
|
61
|
+
const { errors, message } = superforms;
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
<ResetPasswordProvider {superforms} {action}>
|
|
65
|
+
<ResetPasswordContainer {card}>
|
|
66
|
+
<ResetPasswordHeader text={title} desc={description} />
|
|
67
|
+
<Card.Content>
|
|
68
|
+
{@render lead?.()}
|
|
69
|
+
<ServerError class="mb-4" />
|
|
70
|
+
<ResetPasswordPasswordInput name={"password"} label={"New Password"} />
|
|
71
|
+
<ResetPasswordPasswordInput name={"confirm_password"} label={"Confirm Password"} />
|
|
72
|
+
<ResetPasswordSubmit />
|
|
73
|
+
{#if login}
|
|
74
|
+
<div class="mt-4 text-center text-sm">
|
|
75
|
+
Remembered your password?
|
|
76
|
+
<a href={loginLink} class="underline"> Sign in </a>
|
|
77
|
+
</div>
|
|
78
|
+
{/if}
|
|
79
|
+
{@render tail?.()}
|
|
80
|
+
|
|
81
|
+
{#if debug}
|
|
82
|
+
<div class="mb-6">
|
|
83
|
+
<h4>Errors</h4>
|
|
84
|
+
<SuperDebug data={errors} />
|
|
85
|
+
</div>
|
|
86
|
+
<h4>Message</h4>
|
|
87
|
+
<SuperDebug data={$message} />
|
|
88
|
+
{/if}
|
|
89
|
+
</Card.Content>
|
|
90
|
+
</ResetPasswordContainer>
|
|
91
|
+
</ResetPasswordProvider>
|
|
@@ -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
|
+
Reset
|
|
16
|
+
{/if}
|
|
17
|
+
</Form.Submit>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
export const resetPasswordSchema = z.object({
|
|
4
|
+
password: z.string().min(1, { error: "Password is required" }),
|
|
5
|
+
confirm_password: z
|
|
6
|
+
.string()
|
|
7
|
+
.min(1, { error: "Confirm password is required" })
|
|
8
|
+
}).refine((schema) => {
|
|
9
|
+
return schema.password === schema.confirm_password
|
|
10
|
+
}, "Passwords do not match")
|
|
11
|
+
|
|
12
|
+
export type ResetPasswordSchema = typeof resetPasswordSchema;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './is-mobile.svelte';
|
package/src/lib/index.ts
ADDED