svelte-firekit 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +82 -34
- package/dist/auth/reset-password.svelte +1 -1
- package/dist/auth/sign-in.svelte +2 -2
- package/dist/auth/sign-in.svelte.d.ts +1 -1
- package/dist/components/auth/google-sign-in.svelte +15 -1
- package/dist/components/auth/reset-password-form.svelte +16 -17
- package/dist/components/auth/sign-in-form.svelte +24 -23
- package/dist/components/auth/sign-up-form.svelte +52 -45
- package/dist/{auth → components/auth}/user-button.svelte +35 -34
- package/dist/{auth → components/auth}/user-button.svelte.d.ts +2 -2
- package/dist/components/firestore/collection.svelte +45 -0
- package/dist/components/firestore/collection.svelte.d.ts +25 -0
- package/dist/components/firestore/doc.svelte +39 -0
- package/dist/components/firestore/doc.svelte.d.ts +25 -0
- package/dist/components/nav/app-sidebar.svelte +46 -0
- package/dist/components/nav/app-sidebar.svelte.d.ts +8 -0
- package/dist/components/nav/breadcrumb.svelte +42 -0
- package/dist/components/nav/breadcrumb.svelte.d.ts +19 -0
- package/dist/components/nav/dark-mode-toggle.svelte +16 -0
- package/dist/components/nav/dark-mode-toggle.svelte.d.ts +18 -0
- package/dist/components/nav/nav.d.ts +11 -0
- package/dist/components/nav/nav.js +157 -0
- package/dist/components/nav/search-form.svelte +21 -0
- package/dist/components/nav/search-form.svelte.d.ts +4 -0
- package/dist/components/nav/version-switcher.svelte +48 -0
- package/dist/components/nav/version-switcher.svelte.d.ts +5 -0
- package/dist/components/public/footer-main.svelte +0 -0
- package/dist/components/public/footer-main.svelte.d.ts +26 -0
- package/dist/components/public/nav-main.svelte +136 -0
- package/dist/components/public/nav-main.svelte.d.ts +18 -0
- package/dist/components/storage/upload.svelte +134 -0
- package/dist/components/storage/upload.svelte.d.ts +11 -0
- package/dist/components/ui/breadcrumb/breadcrumb-ellipsis.svelte +23 -0
- package/dist/components/ui/breadcrumb/breadcrumb-ellipsis.svelte.d.ts +4 -0
- package/dist/components/ui/breadcrumb/breadcrumb-item.svelte +16 -0
- package/dist/components/ui/breadcrumb/breadcrumb-item.svelte.d.ts +4 -0
- package/dist/components/ui/breadcrumb/breadcrumb-link.svelte +31 -0
- package/dist/components/ui/breadcrumb/breadcrumb-link.svelte.d.ts +10 -0
- package/dist/components/ui/breadcrumb/breadcrumb-list.svelte +23 -0
- package/dist/components/ui/breadcrumb/breadcrumb-list.svelte.d.ts +4 -0
- package/dist/components/ui/breadcrumb/breadcrumb-page.svelte +23 -0
- package/dist/components/ui/breadcrumb/breadcrumb-page.svelte.d.ts +4 -0
- package/dist/components/ui/breadcrumb/breadcrumb-separator.svelte +27 -0
- package/dist/components/ui/breadcrumb/breadcrumb-separator.svelte.d.ts +4 -0
- package/dist/components/ui/breadcrumb/breadcrumb.svelte +15 -0
- package/dist/components/ui/breadcrumb/breadcrumb.svelte.d.ts +4 -0
- package/dist/components/ui/breadcrumb/index.d.ts +8 -0
- package/dist/components/ui/breadcrumb/index.js +10 -0
- package/dist/components/ui/dropdown-menu/dropdown-menu-checkbox-item.svelte +10 -7
- package/dist/components/ui/dropdown-menu/dropdown-menu-checkbox-item.svelte.d.ts +4 -3
- package/dist/components/ui/dropdown-menu/dropdown-menu-item.svelte.d.ts +1 -0
- package/dist/components/ui/input/input.svelte.d.ts +1 -1
- package/dist/components/ui/separator/index.d.ts +2 -0
- package/dist/components/ui/separator/index.js +4 -0
- package/dist/components/ui/separator/separator.svelte +22 -0
- package/dist/components/ui/separator/separator.svelte.d.ts +3 -0
- package/dist/components/ui/sheet/index.js +14 -0
- package/dist/components/ui/sheet/sheet-content.svelte +52 -0
- package/dist/components/ui/sheet/sheet-content.svelte.d.ts +59 -0
- package/dist/components/ui/sheet/sheet-description.svelte +16 -0
- package/dist/components/ui/sheet/sheet-description.svelte.d.ts +3 -0
- package/dist/components/ui/sheet/sheet-footer.svelte +20 -0
- package/dist/components/ui/sheet/sheet-footer.svelte.d.ts +4 -0
- package/dist/components/ui/sheet/sheet-header.svelte +20 -0
- package/dist/components/ui/sheet/sheet-header.svelte.d.ts +4 -0
- package/dist/components/ui/sheet/sheet-overlay.svelte +19 -0
- package/dist/components/ui/sheet/sheet-overlay.svelte.d.ts +3 -0
- package/dist/components/ui/sheet/sheet-title.svelte +16 -0
- package/dist/components/ui/sheet/sheet-title.svelte.d.ts +3 -0
- package/dist/components/ui/sidebar/constants.d.ts +6 -0
- package/dist/components/ui/sidebar/constants.js +6 -0
- package/dist/components/ui/sidebar/context.svelte.d.ts +42 -0
- package/dist/components/ui/sidebar/context.svelte.js +54 -0
- package/dist/components/ui/sidebar/index.d.ts +25 -0
- package/dist/components/ui/sidebar/index.js +27 -0
- package/dist/components/ui/sidebar/sidebar-content.svelte +24 -0
- package/dist/components/ui/sidebar/sidebar-content.svelte.d.ts +4 -0
- package/dist/components/ui/sidebar/sidebar-footer.svelte +21 -0
- package/dist/components/ui/sidebar/sidebar-footer.svelte.d.ts +4 -0
- package/dist/components/ui/sidebar/sidebar-group-action.svelte +36 -0
- package/dist/components/ui/sidebar/sidebar-group-action.svelte.d.ts +10 -0
- package/dist/components/ui/sidebar/sidebar-group-content.svelte +21 -0
- package/dist/components/ui/sidebar/sidebar-group-content.svelte.d.ts +4 -0
- package/dist/components/ui/sidebar/sidebar-group-label.svelte +34 -0
- package/dist/components/ui/sidebar/sidebar-group-label.svelte.d.ts +10 -0
- package/dist/components/ui/sidebar/sidebar-group.svelte +21 -0
- package/dist/components/ui/sidebar/sidebar-group.svelte.d.ts +4 -0
- package/dist/components/ui/sidebar/sidebar-header.svelte +21 -0
- package/dist/components/ui/sidebar/sidebar-header.svelte.d.ts +4 -0
- package/dist/components/ui/sidebar/sidebar-input.svelte +23 -0
- package/dist/components/ui/sidebar/sidebar-input.svelte.d.ts +4 -0
- package/dist/components/ui/sidebar/sidebar-inset.svelte +24 -0
- package/dist/components/ui/sidebar/sidebar-inset.svelte.d.ts +4 -0
- package/dist/components/ui/sidebar/sidebar-menu-action.svelte +43 -0
- package/dist/components/ui/sidebar/sidebar-menu-action.svelte.d.ts +11 -0
- package/dist/components/ui/sidebar/sidebar-menu-badge.svelte +29 -0
- package/dist/components/ui/sidebar/sidebar-menu-badge.svelte.d.ts +4 -0
- package/dist/components/ui/sidebar/sidebar-menu-button.svelte +97 -0
- package/dist/components/ui/sidebar/sidebar-menu-button.svelte.d.ts +91 -0
- package/dist/components/ui/sidebar/sidebar-menu-item.svelte +21 -0
- package/dist/components/ui/sidebar/sidebar-menu-item.svelte.d.ts +4 -0
- package/dist/components/ui/sidebar/sidebar-menu-skeleton.svelte +36 -0
- package/dist/components/ui/sidebar/sidebar-menu-skeleton.svelte.d.ts +7 -0
- package/dist/components/ui/sidebar/sidebar-menu-sub-button.svelte +43 -0
- package/dist/components/ui/sidebar/sidebar-menu-sub-button.svelte.d.ts +12 -0
- package/dist/components/ui/sidebar/sidebar-menu-sub-item.svelte +14 -0
- package/dist/components/ui/sidebar/sidebar-menu-sub-item.svelte.d.ts +4 -0
- package/dist/components/ui/sidebar/sidebar-menu-sub.svelte +25 -0
- package/dist/components/ui/sidebar/sidebar-menu-sub.svelte.d.ts +4 -0
- package/dist/components/ui/sidebar/sidebar-menu.svelte +21 -0
- package/dist/components/ui/sidebar/sidebar-menu.svelte.d.ts +4 -0
- package/dist/components/ui/sidebar/sidebar-provider.svelte +59 -0
- package/dist/components/ui/sidebar/sidebar-provider.svelte.d.ts +9 -0
- package/dist/components/ui/sidebar/sidebar-rail.svelte +36 -0
- package/dist/components/ui/sidebar/sidebar-rail.svelte.d.ts +4 -0
- package/dist/components/ui/sidebar/sidebar-separator.svelte +18 -0
- package/dist/components/ui/sidebar/sidebar-separator.svelte.d.ts +12 -0
- package/dist/components/ui/sidebar/sidebar-trigger.svelte +34 -0
- package/dist/components/ui/sidebar/sidebar-trigger.svelte.d.ts +9 -0
- package/dist/components/ui/sidebar/sidebar.svelte +98 -0
- package/dist/components/ui/sidebar/sidebar.svelte.d.ts +9 -0
- package/dist/components/ui/skeleton/index.d.ts +2 -0
- package/dist/components/ui/skeleton/index.js +4 -0
- package/dist/components/ui/skeleton/skeleton.svelte +17 -0
- package/dist/components/ui/skeleton/skeleton.svelte.d.ts +4 -0
- package/dist/components/ui/tooltip/index.js +8 -0
- package/dist/components/ui/tooltip/tooltip-content.svelte +21 -0
- package/dist/components/ui/tooltip/tooltip-content.svelte.d.ts +3 -0
- package/dist/firebase/auth/auth-guard.svelte.d.ts +25 -0
- package/dist/firebase/auth/auth-guard.svelte.js +79 -0
- package/dist/firebase/auth/auth.d.ts +21 -0
- package/dist/firebase/auth/auth.js +71 -0
- package/dist/firebase/auth/user.svelte.d.ts +50 -0
- package/dist/firebase/auth/user.svelte.js +115 -0
- package/dist/firebase/config.js +44 -0
- package/dist/firebase/firebase.d.ts +28 -0
- package/dist/firebase/firebase.js +86 -0
- package/dist/firebase/firestore/awaitable-doc.svelte.d.ts +15 -0
- package/dist/firebase/firestore/awaitable-doc.svelte.js +57 -0
- package/dist/firebase/firestore/collection.svelte.d.ts +17 -0
- package/dist/firebase/firestore/collection.svelte.js +58 -0
- package/dist/firebase/firestore/doc.svelte.d.ts +16 -0
- package/dist/firebase/firestore/doc.svelte.js +56 -0
- package/dist/firebase/firestore/document-mutations.svelte.d.ts +18 -0
- package/dist/firebase/firestore/document-mutations.svelte.js +58 -0
- package/dist/firebase/storage/download-url.svelte.d.ts +14 -0
- package/dist/firebase/storage/download-url.svelte.js +45 -0
- package/dist/firebase/storage/storage-list.svelte.d.ts +17 -0
- package/dist/firebase/storage/storage-list.svelte.js +51 -0
- package/dist/firebase/storage/upload-task.svelte.d.ts +22 -0
- package/dist/firebase/storage/upload-task.svelte.js +65 -0
- package/dist/hooks/is-mobile.svelte.d.ts +5 -0
- package/dist/hooks/is-mobile.svelte.js +23 -0
- package/dist/index.d.ts +22 -2
- package/dist/index.js +29 -3
- package/dist/types/docs.d.ts +50 -0
- package/dist/utils.d.ts +27 -1
- package/dist/utils.js +85 -9
- package/package.json +9 -7
- package/dist/auth/uid.js +0 -7
- package/dist/auth/user.svelte.d.ts +0 -10
- package/dist/auth/user.svelte.js +0 -21
- package/dist/auth.d.ts +0 -39
- package/dist/auth.js +0 -100
- package/dist/config.js +0 -39
- package/dist/firebase.d.ts +0 -43
- package/dist/firebase.js +0 -110
- package/dist/firestore/Collection.svelte +0 -148
- package/dist/firestore/Collection.svelte.d.ts +0 -27
- package/dist/firestore/collection.svelte.js +0 -207
- package/dist/firestore/doc.svelte.d.ts +0 -1
- package/dist/firestore/doc.svelte.js +0 -1
- package/dist/firestore/firestore.d.ts +0 -31
- package/dist/firestore/firestore.js +0 -100
- package/dist/firestore/perf.d.ts +0 -3
- package/dist/firestore/perf.js +0 -12
- /package/dist/{config.d.ts → firebase/config.d.ts} +0 -0
- /package/dist/{auth/uid.d.ts → types/docs.js} +0 -0
package/README.md
CHANGED
|
@@ -1,58 +1,106 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Firekit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Firekit is a powerful Firebase toolkit for SvelteKit applications, providing a comprehensive set of utilities, stores, and components for Firebase integration.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Features
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- 🔥 **Firebase Integration** - Seamless Firebase setup and configuration
|
|
8
|
+
- 🔐 **Authentication** - Complete auth system with built-in components
|
|
9
|
+
- 📚 **Firestore** - Reactive data stores and CRUD operations
|
|
10
|
+
- 📦 **Storage** - File upload and management utilities
|
|
11
|
+
- 🛡️ **Route Guards** - Protected routes and authorization
|
|
12
|
+
- ⚡ **SSR Compatible** - Full server-side rendering support
|
|
13
|
+
- 🎯 **Type Safe** - Built with TypeScript for better development experience
|
|
8
14
|
|
|
9
|
-
|
|
15
|
+
## Quick Start
|
|
10
16
|
|
|
11
17
|
```bash
|
|
12
|
-
#
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
npx sv create my-app
|
|
18
|
+
# Install with your package manager of choice
|
|
19
|
+
npm install @firekit/sveltekit
|
|
20
|
+
pnpm install @firekit/sveltekit
|
|
21
|
+
yarn add @firekit/sveltekit
|
|
17
22
|
```
|
|
18
23
|
|
|
19
|
-
##
|
|
24
|
+
## Basic Usage
|
|
20
25
|
|
|
21
|
-
|
|
26
|
+
```typescript
|
|
27
|
+
// Configure Firebase
|
|
28
|
+
import { firebaseConfig } from '@firekit/sveltekit';
|
|
29
|
+
firebaseConfig.init({
|
|
30
|
+
apiKey: 'your-api-key',
|
|
31
|
+
// ... other firebase config
|
|
32
|
+
});
|
|
22
33
|
|
|
23
|
-
|
|
24
|
-
|
|
34
|
+
// Use Authentication
|
|
35
|
+
import { firekitAuth } from '@firekit/sveltekit';
|
|
36
|
+
await firekitAuth.signInWithEmail(email, password);
|
|
37
|
+
|
|
38
|
+
// Access User State
|
|
39
|
+
import { firekitUser } from '@firekit/sveltekit';
|
|
40
|
+
isLoggedIn = $derived(firekitUser.isLoggedIn);
|
|
41
|
+
|
|
42
|
+
// Protect Routes
|
|
43
|
+
import { firekitAuthGuard } from '@firekit/sveltekit';
|
|
44
|
+
await firekitAuthGuard.requireAuth();
|
|
25
45
|
|
|
26
|
-
|
|
27
|
-
|
|
46
|
+
// Use Firestore
|
|
47
|
+
import { firekitDoc, firekitCollection } from '@firekit/sveltekit';
|
|
48
|
+
const document = firekitDoc<UserData>('users/123');
|
|
49
|
+
const collection = firekitCollection<PostData>('posts');
|
|
50
|
+
|
|
51
|
+
// Handle File Uploads
|
|
52
|
+
import { firekitUploadTask } from '@firekit/sveltekit';
|
|
53
|
+
const uploadTask = firekitUploadTask('path/to/file', file);
|
|
28
54
|
```
|
|
29
55
|
|
|
30
|
-
|
|
56
|
+
## Available Services
|
|
31
57
|
|
|
32
|
-
|
|
58
|
+
### Firebase Configuration
|
|
59
|
+
- `firebaseConfig` - Firebase app configuration
|
|
60
|
+
- `firebaseService` - Core Firebase service initialization
|
|
33
61
|
|
|
34
|
-
|
|
62
|
+
### Authentication
|
|
63
|
+
- `firekitUser` - User state management
|
|
64
|
+
- `firekitAuth` - Authentication methods
|
|
65
|
+
- `firekitAuthGuard` - Route protection
|
|
35
66
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
67
|
+
### Firestore
|
|
68
|
+
- `firekitDoc` - Real-time document subscription
|
|
69
|
+
- `firekitAwaitableDoc` - Promise-based document operations
|
|
70
|
+
- `firekitCollection` - Real-time collection subscription
|
|
71
|
+
- `firekitDocMutations` - Document CRUD operations
|
|
39
72
|
|
|
40
|
-
|
|
73
|
+
### Storage
|
|
74
|
+
- `firekitDownloadUrl` - File URL management
|
|
75
|
+
- `firekitStorageList` - Storage browsing
|
|
76
|
+
- `firekitUploadTask` - File upload handling
|
|
41
77
|
|
|
42
|
-
|
|
43
|
-
npm run build
|
|
44
|
-
```
|
|
78
|
+
## Built-in Components
|
|
45
79
|
|
|
46
|
-
|
|
80
|
+
### Authentication
|
|
81
|
+
- `SignInPage` - Complete sign-in page
|
|
82
|
+
- `SignUpPage` - User registration page
|
|
83
|
+
- `ResetPasswordPage` - Password reset flow
|
|
84
|
+
- `SignInForm` - Reusable sign-in form
|
|
85
|
+
- `SignUpForm` - Reusable registration form
|
|
86
|
+
- `ResetPasswordForm` - Password reset form
|
|
87
|
+
- `UserButton` - User profile button
|
|
47
88
|
|
|
48
|
-
|
|
89
|
+
### Firestore
|
|
90
|
+
- `Collection` - Collection data display
|
|
91
|
+
- `Doc` - Document data display
|
|
49
92
|
|
|
50
|
-
|
|
93
|
+
### Storage
|
|
94
|
+
- `Upload` - File upload component
|
|
51
95
|
|
|
52
|
-
|
|
96
|
+
## Documentation
|
|
53
97
|
|
|
54
|
-
|
|
98
|
+
Visit our [documentation site](https://firekit.codegio.com) for detailed guides and API references.
|
|
55
99
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
100
|
+
## Contributing
|
|
101
|
+
|
|
102
|
+
We welcome contributions! Please see our [contributing guidelines](CONTRIBUTING.md) for details.
|
|
103
|
+
|
|
104
|
+
## License
|
|
105
|
+
|
|
106
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import ResetPasswordForm from "../components/auth/reset-password-form.svelte";
|
|
3
3
|
import Button from "../components/ui/button/button.svelte";
|
|
4
|
-
import * as Card from "../components/ui/card";
|
|
4
|
+
import * as Card from "../components/ui/card/index.js";
|
|
5
5
|
</script>
|
|
6
6
|
|
|
7
7
|
<Card.Root class="sm:w-[448px]">
|
package/dist/auth/sign-in.svelte
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import SignInWithGoogle from "../components/auth/google-sign-in.svelte";
|
|
3
3
|
import SignInForm from "../components/auth/sign-in-form.svelte";
|
|
4
4
|
import Button from "../components/ui/button/button.svelte";
|
|
5
|
-
import * as Card from "../components/ui/card";
|
|
6
|
-
let { title = "Sign in" }: { title
|
|
5
|
+
import * as Card from "../components/ui/card/index.js";
|
|
6
|
+
let { title = "Sign in" }: { title?: string } = $props();
|
|
7
7
|
</script>
|
|
8
8
|
|
|
9
9
|
<Card.Root class="sm:w-[448px]">
|
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import { firekitAuth } from "../../firebase/auth/auth.js";
|
|
3
|
+
import { toast } from "svelte-sonner";
|
|
4
|
+
|
|
3
5
|
import Button from "../ui/button/button.svelte";
|
|
4
6
|
let { label = "Sign in" }: { label: string } = $props();
|
|
7
|
+
|
|
8
|
+
async function signInWithGoogle() {
|
|
9
|
+
try {
|
|
10
|
+
await firekitAuth.signInWithGoogle();
|
|
11
|
+
} catch (error) {
|
|
12
|
+
if (error instanceof Error) {
|
|
13
|
+
toast.error(error.message);
|
|
14
|
+
} else {
|
|
15
|
+
toast.error("An error occurred");
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
5
19
|
</script>
|
|
6
20
|
|
|
7
21
|
<Button onclick={signInWithGoogle} class="w-full gap-2" variant="outline">
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { goto } from "$app/navigation";
|
|
3
|
-
import {
|
|
3
|
+
import { firekitAuth } from "../../firebase/auth/auth.js";
|
|
4
|
+
|
|
4
5
|
import * as Form from "../ui/form/index.js";
|
|
5
6
|
import { Input } from "../ui/input/index.js";
|
|
6
|
-
import {
|
|
7
|
-
resetPasswordSchema,
|
|
8
|
-
} from "../../schemas/reset-password.js";
|
|
7
|
+
import { resetPasswordSchema } from "../../schemas/reset-password.js";
|
|
9
8
|
import { toast } from "svelte-sonner";
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
} from "sveltekit-superforms";
|
|
13
|
-
import { zodClient } from "sveltekit-superforms/adapters";
|
|
14
|
-
import { valibot } from 'sveltekit-superforms/adapters';
|
|
9
|
+
import { superForm, defaults } from "sveltekit-superforms";
|
|
10
|
+
import { valibot } from "sveltekit-superforms/adapters";
|
|
15
11
|
|
|
16
|
-
const data = defaults(valibot(resetPasswordSchema));
|
|
12
|
+
const data = defaults(valibot(resetPasswordSchema));
|
|
17
13
|
|
|
18
14
|
const form = superForm(data, {
|
|
19
15
|
validators: valibot(resetPasswordSchema),
|
|
@@ -26,7 +22,7 @@ const data = defaults(valibot(resetPasswordSchema));
|
|
|
26
22
|
try {
|
|
27
23
|
const { data } = form;
|
|
28
24
|
const { email } = data;
|
|
29
|
-
await sendPasswordReset(email);
|
|
25
|
+
await firekitAuth.sendPasswordReset(email);
|
|
30
26
|
toast.success("Password reset email sent");
|
|
31
27
|
goto("/sign-in");
|
|
32
28
|
} catch (error) {
|
|
@@ -44,12 +40,15 @@ const data = defaults(valibot(resetPasswordSchema));
|
|
|
44
40
|
|
|
45
41
|
<form method="POST" use:enhance class="space-y-4">
|
|
46
42
|
<Form.Field {form} name="email">
|
|
47
|
-
<Form.Control
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
43
|
+
<Form.Control>
|
|
44
|
+
{#snippet children({ props })}
|
|
45
|
+
<Form.Label>Email address</Form.Label>
|
|
46
|
+
<Input
|
|
47
|
+
{...props}
|
|
48
|
+
bind:value={$formData.email}
|
|
49
|
+
placeholder="you@email.com"
|
|
50
|
+
/>
|
|
51
|
+
{/snippet}
|
|
53
52
|
</Form.Control>
|
|
54
53
|
<Form.FieldErrors />
|
|
55
54
|
</Form.Field>
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import { firekitAuth } from "../../firebase/auth/auth.js";
|
|
3
3
|
import { signInSchema } from "../../schemas/sign-in.js";
|
|
4
|
-
import {
|
|
5
|
-
superForm, defaults
|
|
6
|
-
} from "sveltekit-superforms";
|
|
4
|
+
import { superForm, defaults } from "sveltekit-superforms";
|
|
7
5
|
import { Input } from "../ui/input/index.js";
|
|
8
6
|
import Button from "../ui/button/button.svelte";
|
|
9
|
-
import { valibot } from
|
|
7
|
+
import { valibot } from "sveltekit-superforms/adapters";
|
|
10
8
|
|
|
11
|
-
const data = defaults(valibot(signInSchema));
|
|
9
|
+
const data = defaults(valibot(signInSchema));
|
|
12
10
|
|
|
13
11
|
import * as Form from "../ui/form/index.js";
|
|
14
12
|
import { toast } from "svelte-sonner";
|
|
15
13
|
|
|
16
14
|
const form = superForm(data, {
|
|
17
|
-
|
|
15
|
+
validators: valibot(signInSchema),
|
|
18
16
|
dataType: "json",
|
|
19
17
|
SPA: true,
|
|
20
18
|
resetForm: false,
|
|
@@ -24,7 +22,7 @@ const data = defaults(valibot(signInSchema));
|
|
|
24
22
|
try {
|
|
25
23
|
const { data } = form;
|
|
26
24
|
const { email, password } = data;
|
|
27
|
-
await signInWithEmail(email, password);
|
|
25
|
+
await firekitAuth.signInWithEmail(email, password);
|
|
28
26
|
toast.success("Signed in successfully");
|
|
29
27
|
} catch (error) {
|
|
30
28
|
if (error instanceof Error) {
|
|
@@ -41,35 +39,38 @@ const data = defaults(valibot(signInSchema));
|
|
|
41
39
|
|
|
42
40
|
<form method="POST" use:enhance class="space-y-2">
|
|
43
41
|
<Form.Field {form} name="email">
|
|
44
|
-
<Form.Control
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
42
|
+
<Form.Control>
|
|
43
|
+
{#snippet children({ props })}
|
|
44
|
+
<Form.Label>Email</Form.Label>
|
|
45
|
+
<Input
|
|
46
|
+
{...props}
|
|
47
|
+
bind:value={$formData.email}
|
|
48
|
+
placeholder="you@email.com"
|
|
49
|
+
/>
|
|
50
|
+
{/snippet}
|
|
50
51
|
</Form.Control>
|
|
51
52
|
<Form.FieldErrors />
|
|
52
53
|
</Form.Field>
|
|
53
54
|
<Form.Field {form} name="password">
|
|
54
|
-
<Form.Control
|
|
55
|
+
<Form.Control>
|
|
55
56
|
{#snippet children({ props })}
|
|
56
|
-
|
|
57
57
|
<div class="flex w-full items-center justify-between">
|
|
58
58
|
<Form.Label>Password</Form.Label>
|
|
59
|
-
<Button
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
<Button
|
|
60
|
+
variant="link"
|
|
61
|
+
class="text-sm"
|
|
62
|
+
href="/reset-password "
|
|
63
63
|
>
|
|
64
|
+
I forgot my password
|
|
65
|
+
</Button>
|
|
64
66
|
</div>
|
|
65
67
|
<Input
|
|
66
|
-
{...props}
|
|
68
|
+
{...props}
|
|
67
69
|
bind:value={$formData.password}
|
|
68
70
|
placeholder="*********"
|
|
69
71
|
type="password"
|
|
70
72
|
/>
|
|
71
|
-
|
|
72
|
-
|
|
73
|
+
{/snippet}
|
|
73
74
|
</Form.Control>
|
|
74
75
|
<Form.FieldErrors />
|
|
75
76
|
</Form.Field>
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import { firekitAuth } from "../../firebase/auth/auth.js";
|
|
3
|
+
|
|
3
4
|
import * as Form from "../ui/form/index.js";
|
|
4
5
|
import { Input } from "../ui/input/index.js";
|
|
5
6
|
import { signUpSchema } from "../../schemas/sign-up.js";
|
|
6
7
|
import { toast } from "svelte-sonner";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
import Checkbox from "../ui/checkbox/checkbox.svelte";
|
|
13
|
-
const data = defaults(valibot(signUpSchema));
|
|
8
|
+
import { superForm, defaults } from "sveltekit-superforms";
|
|
9
|
+
import { valibot } from "sveltekit-superforms/adapters";
|
|
10
|
+
import Button from "../ui/button/button.svelte";
|
|
11
|
+
import Checkbox from "../ui/checkbox/checkbox.svelte";
|
|
12
|
+
const data = defaults(valibot(signUpSchema));
|
|
14
13
|
|
|
15
14
|
const form = superForm(data, {
|
|
16
|
-
|
|
15
|
+
validators: valibot(signUpSchema),
|
|
17
16
|
dataType: "json",
|
|
18
17
|
SPA: true,
|
|
19
18
|
resetForm: false,
|
|
@@ -24,7 +23,11 @@ const data = defaults(valibot(signUpSchema));
|
|
|
24
23
|
const { data } = form;
|
|
25
24
|
const { email, password, firstName, lastName } = data;
|
|
26
25
|
const displayName = `${firstName} ${lastName}`;
|
|
27
|
-
await registerWithEmail(
|
|
26
|
+
await firekitAuth.registerWithEmail(
|
|
27
|
+
email,
|
|
28
|
+
password,
|
|
29
|
+
displayName,
|
|
30
|
+
);
|
|
28
31
|
toast.success("Account created successfully");
|
|
29
32
|
} catch (error) {
|
|
30
33
|
if (error instanceof Error) {
|
|
@@ -42,7 +45,7 @@ const data = defaults(valibot(signUpSchema));
|
|
|
42
45
|
<form method="POST" use:enhance class="space-y-2">
|
|
43
46
|
<div class="grid grid-cols-2 gap-4">
|
|
44
47
|
<Form.Field {form} name="firstName">
|
|
45
|
-
<Form.Control
|
|
48
|
+
<Form.Control>
|
|
46
49
|
{#snippet children({ props })}
|
|
47
50
|
<Form.Label>First Name</Form.Label>
|
|
48
51
|
<Input
|
|
@@ -50,60 +53,64 @@ const data = defaults(valibot(signUpSchema));
|
|
|
50
53
|
bind:value={$formData.firstName}
|
|
51
54
|
placeholder="John"
|
|
52
55
|
/>
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
{/snippet}
|
|
55
57
|
</Form.Control>
|
|
56
58
|
<Form.FieldErrors />
|
|
57
59
|
</Form.Field>
|
|
58
60
|
<Form.Field {form} name="lastName">
|
|
59
|
-
<Form.Control
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
/>
|
|
61
|
+
<Form.Control>
|
|
62
|
+
{#snippet children({ props })}
|
|
63
|
+
<Form.Label>First Name</Form.Label>
|
|
64
|
+
<Input
|
|
65
|
+
{...props}
|
|
66
|
+
bind:value={$formData.lastName}
|
|
67
|
+
placeholder="Smith"
|
|
68
|
+
/>
|
|
68
69
|
{/snippet}
|
|
69
70
|
</Form.Control>
|
|
70
71
|
<Form.FieldErrors />
|
|
71
72
|
</Form.Field>
|
|
72
73
|
</div>
|
|
73
74
|
<Form.Field {form} name="email">
|
|
74
|
-
<Form.Control
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
<Form.Control>
|
|
76
|
+
{#snippet children({ props })}
|
|
77
|
+
<Form.Label>Email</Form.Label>
|
|
78
|
+
<Input
|
|
79
|
+
{...props}
|
|
80
|
+
bind:value={$formData.email}
|
|
81
|
+
placeholder="you@email.com"
|
|
82
|
+
/>
|
|
83
|
+
{/snippet}
|
|
79
84
|
</Form.Control>
|
|
80
85
|
<Form.FieldErrors />
|
|
81
86
|
</Form.Field>
|
|
82
87
|
<Form.Field {form} name="password">
|
|
83
|
-
<Form.Control
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
/>
|
|
88
|
+
<Form.Control>
|
|
89
|
+
{#snippet children({ props })}
|
|
90
|
+
<Form.Label>Password</Form.Label>
|
|
91
|
+
<Input
|
|
92
|
+
{...props}
|
|
93
|
+
bind:value={$formData.password}
|
|
94
|
+
placeholder="*********"
|
|
95
|
+
type="password"
|
|
96
|
+
/>
|
|
93
97
|
{/snippet}
|
|
94
98
|
</Form.Control>
|
|
95
99
|
<Form.FieldErrors />
|
|
96
100
|
</Form.Field>
|
|
97
101
|
<Form.Field {form} name="agreeToTerms">
|
|
98
|
-
<Form.Control
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
<Form.Label>
|
|
103
|
-
I accept the
|
|
104
|
-
<Button variant="link" href="/terms-and-conditions" class="p-0">Terms and Conditions</Button>
|
|
105
|
-
</Form.Label>
|
|
102
|
+
<Form.Control>
|
|
103
|
+
{#snippet children({ props })}
|
|
104
|
+
<Checkbox {...props} bind:checked={$formData.agreeToTerms} />
|
|
106
105
|
|
|
106
|
+
<Form.Label>
|
|
107
|
+
I accept the
|
|
108
|
+
<Button
|
|
109
|
+
variant="link"
|
|
110
|
+
href="/terms-and-conditions"
|
|
111
|
+
class="p-0">Terms and Conditions</Button
|
|
112
|
+
>
|
|
113
|
+
</Form.Label>
|
|
107
114
|
{/snippet}
|
|
108
115
|
</Form.Control>
|
|
109
116
|
<Form.FieldErrors />
|
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import * as DropdownMenu from "../
|
|
3
|
-
import * as Avatar from "../
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import * as DropdownMenu from "../ui/dropdown-menu/index.js";
|
|
3
|
+
import * as Avatar from "../ui/avatar/index.js";
|
|
4
|
+
import { getInitials } from "../../utils.js";
|
|
5
|
+
import type { NavItem } from "../../types/nav.js";
|
|
6
|
+
let { nav }: { nav?: NavItem[] } = $props();
|
|
7
|
+
import * as AlertDialog from "../ui/alert-dialog/index.js";
|
|
8
|
+
import Button from "../ui/button/button.svelte";
|
|
9
|
+
import { firekitUser } from "../../firebase/auth/user.svelte.js";
|
|
10
|
+
import { firekitAuth } from "../../firebase/auth/auth.js";
|
|
6
11
|
import { LogOut } from "lucide-svelte";
|
|
7
|
-
import { logOut } from "../auth.js";
|
|
8
|
-
import type { NavItem } from "../types/nav.js";
|
|
9
|
-
let { nav }: { nav: NavItem[] } = $props();
|
|
10
|
-
import * as AlertDialog from "../components/ui/alert-dialog/index.js";
|
|
11
|
-
import Button from "../components/ui/button/button.svelte";
|
|
12
12
|
let isOpen = $state(false);
|
|
13
|
+
|
|
14
|
+
async function handleLogout() {
|
|
15
|
+
await firekitAuth.logOut();
|
|
16
|
+
}
|
|
13
17
|
</script>
|
|
14
18
|
|
|
15
|
-
{#if
|
|
19
|
+
{#if firekitUser.user}
|
|
16
20
|
<DropdownMenu.Root>
|
|
17
21
|
<DropdownMenu.Trigger>
|
|
18
22
|
<Avatar.Root>
|
|
19
|
-
<Avatar.Image
|
|
20
|
-
src={authUser.currentUser?.photoURL}
|
|
21
|
-
alt="Avatar"
|
|
22
|
-
/>
|
|
23
|
+
<Avatar.Image src={firekitUser.photoURL} alt="Avatar" />
|
|
23
24
|
<Avatar.Fallback>
|
|
24
|
-
{getInitials(
|
|
25
|
+
{getInitials(firekitUser.displayName)}
|
|
25
26
|
</Avatar.Fallback>
|
|
26
27
|
</Avatar.Root>
|
|
27
28
|
</DropdownMenu.Trigger>
|
|
@@ -31,21 +32,21 @@
|
|
|
31
32
|
<div class="flex items-center gap-3">
|
|
32
33
|
<Avatar.Root>
|
|
33
34
|
<Avatar.Image
|
|
34
|
-
src={
|
|
35
|
+
src={firekitUser.photoURL}
|
|
35
36
|
alt="Avatar"
|
|
36
37
|
/>
|
|
37
38
|
<Avatar.Fallback>
|
|
38
|
-
{getInitials(
|
|
39
|
+
{getInitials(firekitUser.displayName)}
|
|
39
40
|
</Avatar.Fallback>
|
|
40
41
|
</Avatar.Root>
|
|
41
42
|
<div class="grow">
|
|
42
43
|
<span
|
|
43
44
|
class="block font-medium text-sm text-gray-800 dark:text-neutral-200"
|
|
44
45
|
>
|
|
45
|
-
{
|
|
46
|
+
{firekitUser.displayName}
|
|
46
47
|
</span>
|
|
47
48
|
<p class="text-xs text-foreground-500">
|
|
48
|
-
{
|
|
49
|
+
{firekitUser.email}
|
|
49
50
|
</p>
|
|
50
51
|
</div>
|
|
51
52
|
</div>
|
|
@@ -54,16 +55,18 @@
|
|
|
54
55
|
<DropdownMenu.Item onclick={() => (isOpen = true)}>
|
|
55
56
|
Profile
|
|
56
57
|
</DropdownMenu.Item>
|
|
57
|
-
{#
|
|
58
|
-
|
|
59
|
-
<
|
|
60
|
-
{
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
{#if nav}
|
|
59
|
+
{#each nav as { href, label }}
|
|
60
|
+
<DropdownMenu.Item>
|
|
61
|
+
<a {href}>
|
|
62
|
+
{label}
|
|
63
|
+
</a>
|
|
64
|
+
</DropdownMenu.Item>
|
|
65
|
+
{/each}
|
|
66
|
+
{/if}
|
|
64
67
|
|
|
65
68
|
<DropdownMenu.Separator />
|
|
66
|
-
<DropdownMenu.Item onclick={
|
|
69
|
+
<DropdownMenu.Item onclick={handleLogout}>
|
|
67
70
|
<LogOut /> Logout
|
|
68
71
|
</DropdownMenu.Item>
|
|
69
72
|
</DropdownMenu.Group>
|
|
@@ -77,27 +80,25 @@
|
|
|
77
80
|
<div class="flex items-center gap-3">
|
|
78
81
|
<Avatar.Root>
|
|
79
82
|
<Avatar.Image
|
|
80
|
-
src={
|
|
83
|
+
src={firekitUser.photoURL}
|
|
81
84
|
alt="Avatar"
|
|
82
85
|
/>
|
|
83
86
|
<Avatar.Fallback>
|
|
84
|
-
{getInitials(
|
|
85
|
-
authUser.currentUser?.displayName,
|
|
86
|
-
)}
|
|
87
|
+
{getInitials(firekitUser.displayName)}
|
|
87
88
|
</Avatar.Fallback>
|
|
88
89
|
</Avatar.Root>
|
|
89
90
|
<div class="grow">
|
|
90
91
|
<span
|
|
91
92
|
class="block font-medium text-sm text-gray-800 dark:text-neutral-200"
|
|
92
93
|
>
|
|
93
|
-
{
|
|
94
|
+
{firekitUser.displayName}
|
|
94
95
|
</span>
|
|
95
96
|
<p class="text-xs text-foreground-500">
|
|
96
|
-
{
|
|
97
|
+
{firekitUser.email}
|
|
97
98
|
</p>
|
|
98
99
|
</div>
|
|
99
100
|
</div>
|
|
100
|
-
<Button onclick={
|
|
101
|
+
<Button onclick={handleLogout} variant="link">
|
|
101
102
|
<LogOut />Logout
|
|
102
103
|
</Button>
|
|
103
104
|
</div>
|