svelte-firekit 0.0.13 → 0.0.15

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.
Files changed (39) hide show
  1. package/dist/auth/require-auth.svelte +52 -0
  2. package/dist/auth/require-auth.svelte.d.ts +11 -0
  3. package/dist/auth/require-no-auth.svelte +42 -0
  4. package/dist/auth/require-no-auth.svelte.d.ts +6 -0
  5. package/dist/auth/reset-password.svelte +11 -10
  6. package/dist/auth/reset-password.svelte.d.ts +5 -5
  7. package/dist/auth/sign-in.svelte +14 -11
  8. package/dist/auth/sign-in.svelte.d.ts +12 -11
  9. package/dist/auth/sign-up.svelte +17 -14
  10. package/dist/auth/sign-up.svelte.d.ts +15 -14
  11. package/dist/components/app/nav/app-sidebar.svelte +1 -1
  12. package/dist/components/auth/sign-in-form.svelte +70 -72
  13. package/dist/components/auth/sign-in-form.svelte.d.ts +1 -0
  14. package/dist/components/auth/sign-up-form.svelte +6 -4
  15. package/dist/components/auth/sign-up-form.svelte.d.ts +1 -0
  16. package/dist/components/auth/user-button/profile-section/phone-user.svelte +1 -1
  17. package/dist/components/auth/user-button/settings-dialog.svelte +3 -3
  18. package/dist/components/auth/user-button/user-button.svelte +2 -2
  19. package/dist/components/auth/user-button/user-button.svelte.d.ts +1 -0
  20. package/dist/components/ui/select/index.js +13 -0
  21. package/dist/components/ui/select/select-content.svelte +38 -0
  22. package/dist/components/ui/select/select-content.svelte.d.ts +5 -0
  23. package/dist/components/ui/select/select-group-heading.svelte +16 -0
  24. package/dist/components/ui/select/select-group-heading.svelte.d.ts +3 -0
  25. package/dist/components/ui/select/select-item.svelte +37 -0
  26. package/dist/components/ui/select/select-item.svelte.d.ts +3 -0
  27. package/dist/components/ui/select/select-scroll-down-button.svelte +19 -0
  28. package/dist/components/ui/select/select-scroll-down-button.svelte.d.ts +3 -0
  29. package/dist/components/ui/select/select-scroll-up-button.svelte +19 -0
  30. package/dist/components/ui/select/select-scroll-up-button.svelte.d.ts +3 -0
  31. package/dist/components/ui/select/select-separator.svelte +13 -0
  32. package/dist/components/ui/select/select-separator.svelte.d.ts +3 -0
  33. package/dist/components/ui/select/select-trigger.svelte +24 -0
  34. package/dist/components/ui/select/select-trigger.svelte.d.ts +3 -0
  35. package/dist/firebase/auth/auth-manager.svelte.d.ts +1 -3
  36. package/dist/firebase/auth/auth-manager.svelte.js +0 -15
  37. package/dist/index.d.ts +2 -0
  38. package/dist/index.js +2 -0
  39. package/package.json +1 -1
@@ -0,0 +1,52 @@
1
+ <script lang="ts">
2
+ import type { DocumentData } from "firebase/firestore";
3
+ import { firekitAuthManager } from "../firebase/auth/auth-manager.svelte.js";
4
+
5
+ interface Props {
6
+ redirectTo?: string;
7
+ redirectParams?: Record<string, string>;
8
+ requiredClaims?: string[];
9
+ requiredData?: (data: DocumentData | null) => boolean;
10
+ allowIf?: (manager: typeof firekitAuthManager) => boolean;
11
+ children: () => any;
12
+ }
13
+
14
+ let {
15
+ redirectTo = "/login",
16
+ redirectParams,
17
+ requiredClaims = [],
18
+ requiredData,
19
+ allowIf,
20
+ children,
21
+ }: Props = $props();
22
+
23
+ let isAuthorized = $state(false);
24
+ let isValidating = $state(true);
25
+
26
+ async function validateAccess() {
27
+ isValidating = true;
28
+ isAuthorized = await firekitAuthManager.validateAuth({
29
+ authRequired: true,
30
+ redirectTo,
31
+ redirectParams,
32
+ requiredClaims,
33
+ requiredData,
34
+ allowIf,
35
+ });
36
+ isValidating = false;
37
+ }
38
+
39
+ $effect(() => {
40
+ if (firekitAuthManager.initialized) {
41
+ validateAccess();
42
+ }
43
+ });
44
+ </script>
45
+
46
+ {#if isValidating || firekitAuthManager.loading}
47
+ <div class="flex items-center justify-center p-4">
48
+ <span class="text-gray-500">Loading...</span>
49
+ </div>
50
+ {:else if isAuthorized}
51
+ {@render children()}
52
+ {/if}
@@ -0,0 +1,11 @@
1
+ import type { DocumentData } from "firebase/firestore";
2
+ import { firekitAuthManager } from "../firebase/auth/auth-manager.svelte.js";
3
+ declare const RequireAuth: import("svelte").Component<{
4
+ redirectTo?: string;
5
+ redirectParams?: Record<string, string>;
6
+ requiredClaims?: string[];
7
+ requiredData?: (data: DocumentData | null) => boolean;
8
+ allowIf?: (manager: typeof firekitAuthManager) => boolean;
9
+ children: () => any;
10
+ }, {}, "">;
11
+ export default RequireAuth;
@@ -0,0 +1,42 @@
1
+ <script lang="ts">
2
+ import { firekitAuthManager } from "../firebase/auth/auth-manager.svelte.js";
3
+
4
+ interface Props {
5
+ redirectTo?: string;
6
+ redirectParams?: Record<string, string>;
7
+ children: () => any;
8
+ }
9
+
10
+ let {
11
+ redirectTo = "/dashboard",
12
+ redirectParams,
13
+ children,
14
+ }: Props = $props();
15
+
16
+ let isAuthorized = $state(false);
17
+ let isValidating = $state(true);
18
+
19
+ async function validateAccess() {
20
+ isValidating = true;
21
+ isAuthorized = await firekitAuthManager.validateAuth({
22
+ authRequired: false,
23
+ redirectTo,
24
+ redirectParams,
25
+ });
26
+ isValidating = false;
27
+ }
28
+
29
+ $effect(() => {
30
+ if (firekitAuthManager.initialized) {
31
+ validateAccess();
32
+ }
33
+ });
34
+ </script>
35
+
36
+ {#if isValidating || firekitAuthManager.loading}
37
+ <div class="flex items-center justify-center p-4">
38
+ <span class="text-gray-500">Loading...</span>
39
+ </div>
40
+ {:else if isAuthorized}
41
+ {@render children()}
42
+ {/if}
@@ -0,0 +1,6 @@
1
+ declare const RequireNoAuth: import("svelte").Component<{
2
+ redirectTo?: string;
3
+ redirectParams?: Record<string, string>;
4
+ children: () => any;
5
+ }, {}, "">;
6
+ export default RequireNoAuth;
@@ -3,18 +3,19 @@
3
3
  import Button from "../components/ui/button/button.svelte";
4
4
  import * as Card from "../components/ui/card/index.js";
5
5
 
6
+
6
7
  let {
7
- title,
8
- subtitle,
9
- labelLink,
10
- link,
11
- redirect,
8
+ title="Forgot password?",
9
+ subtitle="Remember your password?",
10
+ labelLink="Sign in here",
11
+ link="/sign-in",
12
+ redirect="/sign-in"
12
13
  }: {
13
- title: string;
14
- subtitle: string;
15
- labelLink: string;
16
- link: string;
17
- redirect: string;
14
+ title?: string;
15
+ subtitle?: string;
16
+ labelLink?: string;
17
+ link?: string;
18
+ redirect?: string;
18
19
  } = $props();
19
20
  </script>
20
21
 
@@ -1,8 +1,8 @@
1
1
  declare const ResetPassword: import("svelte").Component<{
2
- title: string;
3
- subtitle: string;
4
- labelLink: string;
5
- link: string;
6
- redirect: string;
2
+ title?: string;
3
+ subtitle?: string;
4
+ labelLink?: string;
5
+ link?: string;
6
+ redirect?: string;
7
7
  }, {}, "">;
8
8
  export default ResetPassword;
@@ -8,6 +8,7 @@
8
8
  subtitle = "Don't have an account yet?",
9
9
  textLink = "Sign up here",
10
10
  link = "/sign-up",
11
+ redirectTo = "/dashboard",
11
12
  labelBtnGoogle = "Sign in with",
12
13
  labelEmail = "Email",
13
14
  labelPassword = "Password",
@@ -16,17 +17,18 @@
16
17
  labelBtnFormEmail = "Sign",
17
18
  labelDivider = "Or",
18
19
  }: {
19
- title: string;
20
- subtitle: string;
21
- textLink: string;
22
- link: string;
23
- labelBtnGoogle: string;
24
- labelEmail: string;
25
- labelPassword: string;
26
- labellLinkEmailForm: string;
27
- linkForgetPassword: string;
28
- labelBtnFormEmail: string;
29
- labelDivider: string;
20
+ title?: string;
21
+ subtitle?: string;
22
+ textLink?: string;
23
+ link?: string;
24
+ redirectTo?: string;
25
+ labelBtnGoogle?: string;
26
+ labelEmail?: string;
27
+ labelPassword?: string;
28
+ labellLinkEmailForm?: string;
29
+ linkForgetPassword?: string;
30
+ labelBtnFormEmail?: string;
31
+ labelDivider?: string;
30
32
  } = $props();
31
33
  </script>
32
34
 
@@ -53,6 +55,7 @@
53
55
  {labellLinkEmailForm}
54
56
  {linkForgetPassword}
55
57
  {labelBtnFormEmail}
58
+ {redirectTo}
56
59
  />
57
60
  </Card.Content>
58
61
  </Card.Root>
@@ -1,14 +1,15 @@
1
1
  declare const SignIn: import("svelte").Component<{
2
- title: string;
3
- subtitle: string;
4
- textLink: string;
5
- link: string;
6
- labelBtnGoogle: string;
7
- labelEmail: string;
8
- labelPassword: string;
9
- labellLinkEmailForm: string;
10
- linkForgetPassword: string;
11
- labelBtnFormEmail: string;
12
- labelDivider: string;
2
+ title?: string;
3
+ subtitle?: string;
4
+ textLink?: string;
5
+ link?: string;
6
+ redirectTo?: string;
7
+ labelBtnGoogle?: string;
8
+ labelEmail?: string;
9
+ labelPassword?: string;
10
+ labellLinkEmailForm?: string;
11
+ linkForgetPassword?: string;
12
+ labelBtnFormEmail?: string;
13
+ labelDivider?: string;
13
14
  }, {}, "">;
14
15
  export default SignIn;
@@ -20,21 +20,23 @@
20
20
  labelLinkTerms = "Terms and Conditions",
21
21
  labelBtnFormEmail = "Sign up",
22
22
  labelDivider = "Or",
23
+ redirectTo = "/dashboard",
23
24
  }: {
24
- title: string;
25
- subtitle: string;
26
- labelLink: string;
27
- link: string;
28
- labelBtnGoogle: string;
29
- labelFisrtName: string;
30
- labelLastName: string;
31
- labelEmail: string;
32
- labelPassword: string;
33
- linkTerms: string;
34
- labelTerms: string;
35
- labelLinkTerms: string;
36
- labelBtnFormEmail: string;
37
- labelDivider: string;
25
+ title?: string;
26
+ subtitle?: string;
27
+ labelLink?: string;
28
+ link?: string;
29
+ labelBtnGoogle?: string;
30
+ labelFisrtName?: string;
31
+ labelLastName?: string;
32
+ labelEmail?: string;
33
+ labelPassword?: string;
34
+ linkTerms?: string;
35
+ labelTerms?: string;
36
+ labelLinkTerms?: string;
37
+ labelBtnFormEmail?: string;
38
+ labelDivider?: string;
39
+ redirectTo?: string;
38
40
  } = $props();
39
41
  </script>
40
42
 
@@ -64,6 +66,7 @@
64
66
  {labelTerms}
65
67
  {labelLinkTerms}
66
68
  {labelBtnFormEmail}
69
+ {redirectTo}
67
70
  />
68
71
  </Card.Content>
69
72
  </Card.Root>
@@ -1,17 +1,18 @@
1
1
  declare const SignUp: import("svelte").Component<{
2
- title: string;
3
- subtitle: string;
4
- labelLink: string;
5
- link: string;
6
- labelBtnGoogle: string;
7
- labelFisrtName: string;
8
- labelLastName: string;
9
- labelEmail: string;
10
- labelPassword: string;
11
- linkTerms: string;
12
- labelTerms: string;
13
- labelLinkTerms: string;
14
- labelBtnFormEmail: string;
15
- labelDivider: string;
2
+ title?: string;
3
+ subtitle?: string;
4
+ labelLink?: string;
5
+ link?: string;
6
+ labelBtnGoogle?: string;
7
+ labelFisrtName?: string;
8
+ labelLastName?: string;
9
+ labelEmail?: string;
10
+ labelPassword?: string;
11
+ linkTerms?: string;
12
+ labelTerms?: string;
13
+ labelLinkTerms?: string;
14
+ labelBtnFormEmail?: string;
15
+ labelDivider?: string;
16
+ redirectTo?: string;
16
17
  }, {}, "">;
17
18
  export default SignUp;
@@ -16,7 +16,7 @@
16
16
  <Sidebar.Root bind:ref {collapsible} {...restProps}>
17
17
  <Sidebar.Header>
18
18
  <section class="flex justify-center items-center gap-2 my-4">
19
- <UserButton></UserButton>
19
+ <UserButton redirectTo="/sign-in"></UserButton>
20
20
  <div class="flex flex-col">
21
21
  <small>{firekitAuthManager.data?.displayName}</small>
22
22
  <small>{firekitAuthManager.data?.email}</small>
@@ -1,94 +1,92 @@
1
1
  <script lang="ts">
2
- import { firekitAuth } from "../../firebase/auth/auth.js";
3
- import { signInSchema } from "../../schemas/sign-in.js";
4
- import { superForm, defaults } from "sveltekit-superforms";
5
- import { Input } from "../ui/input/index.js";
6
- import Button from "../ui/button/button.svelte";
7
- import { valibot } from "sveltekit-superforms/adapters";
2
+ import { firekitAuth } from "../../firebase/auth/auth.js";
3
+ import { signInSchema } from "../../schemas/sign-in.js";
4
+ import { superForm, defaults } from "sveltekit-superforms";
5
+ import { Input } from "../ui/input/index.js";
6
+ import Button from "../ui/button/button.svelte";
7
+ import { valibot } from "sveltekit-superforms/adapters";
8
8
 
9
- let {
9
+ let {
10
10
  labelEmail = "Email",
11
11
  labelPassword = "Password",
12
12
  labellLinkEmailForm = "I forgot my password",
13
13
  linkForgetPassword = "/reset-password",
14
+ redirectTo = "/dashboard",
14
15
  labelBtnFormEmail = "Sign",
15
16
  }: {
16
17
  labelEmail: string;
17
18
  labelPassword: string;
18
19
  labellLinkEmailForm: string;
19
20
  linkForgetPassword: string;
21
+ redirectTo: string;
20
22
  labelBtnFormEmail: string;
21
23
  } = $props();
22
24
 
23
- const data = defaults(valibot(signInSchema));
25
+ const data = defaults(valibot(signInSchema));
24
26
 
25
- import * as Form from "../ui/form/index.js";
26
- import { toast } from "svelte-sonner";
27
+ import * as Form from "../ui/form/index.js";
28
+ import { toast } from "svelte-sonner";
29
+ import { goto } from "$app/navigation";
27
30
 
28
- const form = superForm(data, {
29
- validators: valibot(signInSchema),
30
- dataType: "json",
31
- SPA: true,
32
- resetForm: false,
33
- clearOnSubmit: "errors-and-message",
34
- async onUpdate({ form }) {
35
- if (!form.valid) return;
36
- try {
37
- const { data } = form;
38
- const { email, password } = data;
39
- await firekitAuth.signInWithEmail(email, password);
40
- toast.success("Signed in successfully");
41
- } catch (error) {
42
- if (error instanceof Error) {
43
- toast.error(error.message);
44
- } else {
45
- toast.error("An error occurred");
46
- }
47
- }
48
- },
49
- });
31
+ const form = superForm(data, {
32
+ validators: valibot(signInSchema),
33
+ dataType: "json",
34
+ SPA: true,
35
+ resetForm: false,
36
+ clearOnSubmit: "errors-and-message",
37
+ async onUpdate({ form }) {
38
+ if (!form.valid) return;
39
+ try {
40
+ const { data } = form;
41
+ const { email, password } = data;
42
+ await firekitAuth.signInWithEmail(email, password);
43
+ toast.success("Signed in successfully");
44
+ goto(redirectTo);
45
+ } catch (error) {
46
+ if (error instanceof Error) {
47
+ toast.error(error.message);
48
+ } else {
49
+ toast.error("An error occurred");
50
+ }
51
+ }
52
+ },
53
+ });
50
54
 
51
- const { form: formData, enhance } = form;
52
-
53
-
55
+ const { form: formData, enhance } = form;
54
56
  </script>
55
57
 
56
58
  <form method="POST" use:enhance class="space-y-2">
57
- <Form.Field {form} name="email">
58
- <Form.Control>
59
- {#snippet children({ props })}
60
- <Form.Label>{labelEmail}</Form.Label>
61
- <Input
62
- {...props}
63
- bind:value={$formData.email}
64
- placeholder="you@email.com"
65
- />
66
- {/snippet}
67
- </Form.Control>
68
- <Form.FieldErrors />
69
- </Form.Field>
70
- <Form.Field {form} name="password">
71
- <Form.Control>
72
- {#snippet children({ props })}
73
- <div class="flex w-full items-center justify-between">
74
- <Form.Label>{labelPassword}</Form.Label>
75
- <Button
76
- variant="link"
77
- class="text-sm"
78
- href={linkForgetPassword}
79
- >
80
- {labellLinkEmailForm}
81
- </Button>
82
- </div>
83
- <Input
84
- {...props}
85
- bind:value={$formData.password}
86
- placeholder="*********"
87
- type="password"
88
- />
89
- {/snippet}
90
- </Form.Control>
91
- <Form.FieldErrors />
92
- </Form.Field>
93
- <Form.Button class="w-full">{labelBtnFormEmail}</Form.Button>
59
+ <Form.Field {form} name="email">
60
+ <Form.Control>
61
+ {#snippet children({ props })}
62
+ <Form.Label>{labelEmail}</Form.Label>
63
+ <Input
64
+ {...props}
65
+ bind:value={$formData.email}
66
+ placeholder="you@email.com"
67
+ />
68
+ {/snippet}
69
+ </Form.Control>
70
+ <Form.FieldErrors />
71
+ </Form.Field>
72
+ <Form.Field {form} name="password">
73
+ <Form.Control>
74
+ {#snippet children({ props })}
75
+ <div class="flex w-full items-center justify-between">
76
+ <Form.Label>{labelPassword}</Form.Label>
77
+ <Button variant="link" class="text-sm" href={linkForgetPassword}>
78
+ {labellLinkEmailForm}
79
+ </Button>
80
+ </div>
81
+ <Input
82
+ {...props}
83
+ bind:value={$formData.password}
84
+ placeholder="*********"
85
+ type="password"
86
+ />
87
+ {/snippet}
88
+ </Form.Control>
89
+ <Form.FieldErrors />
90
+ </Form.Field>
91
+ <Form.Button class="w-full">{labelBtnFormEmail}</Form.Button>
94
92
  </form>
@@ -3,6 +3,7 @@ declare const SignInForm: import("svelte").Component<{
3
3
  labelPassword: string;
4
4
  labellLinkEmailForm: string;
5
5
  linkForgetPassword: string;
6
+ redirectTo: string;
6
7
  labelBtnFormEmail: string;
7
8
  }, {}, "">;
8
9
  export default SignInForm;
@@ -9,6 +9,7 @@
9
9
  import { valibot } from "sveltekit-superforms/adapters";
10
10
  import Button from "../ui/button/button.svelte";
11
11
  import Checkbox from "../ui/checkbox/checkbox.svelte";
12
+ import { goto } from "$app/navigation";
12
13
 
13
14
  let {
14
15
  labelFisrtName,
@@ -16,9 +17,10 @@
16
17
  labelEmail,
17
18
  labelPassword,
18
19
  linkTerms,
19
- labelTerms,
20
- labelLinkTerms,
20
+ labelTerms,
21
+ labelLinkTerms,
21
22
  labelBtnFormEmail,
23
+ redirectTo,
22
24
  }: {
23
25
  labelFisrtName: string;
24
26
  labelLastName: string;
@@ -28,6 +30,7 @@
28
30
  labelTerms: string;
29
31
  labelLinkTerms: string;
30
32
  labelBtnFormEmail: string;
33
+ redirectTo: string;
31
34
  } = $props();
32
35
 
33
36
  const data = defaults(valibot(signUpSchema));
@@ -46,6 +49,7 @@
46
49
  const displayName = `${firstName} ${lastName}`;
47
50
  await firekitAuth.registerWithEmail(email, password, displayName);
48
51
  toast.success("Account created successfully");
52
+ goto(redirectTo)
49
53
  } catch (error) {
50
54
  if (error instanceof Error) {
51
55
  toast.error(error.message);
@@ -57,8 +61,6 @@
57
61
  });
58
62
 
59
63
  const { form: formData, enhance } = form;
60
-
61
-
62
64
  </script>
63
65
 
64
66
  <form method="POST" use:enhance class="space-y-2">
@@ -7,5 +7,6 @@ declare const SignUpForm: import("svelte").Component<{
7
7
  labelTerms: string;
8
8
  labelLinkTerms: string;
9
9
  labelBtnFormEmail: string;
10
+ redirectTo: string;
10
11
  }, {}, "">;
11
12
  export default SignUpForm;
@@ -80,7 +80,7 @@
80
80
  </p>
81
81
  </div>
82
82
 
83
- <div class="sm:col-span-8 xl:col-span-9">
83
+ <div class="sm:col-span-8 lg:col-span-6">
84
84
  <div class="flex flex-wrap j items-center gap-3 sm:gap-5">
85
85
  <div class="flex gap-2 items-center w-full">
86
86
  <div class="flex flex-col gap-2 text-sm leading-tight">
@@ -26,7 +26,7 @@
26
26
  {/snippet}
27
27
  </Dialog.Trigger>
28
28
  <Dialog.Content
29
- class="overflow-hidden p-0 md:max-h-[500px] md:max-w-[700px] lg:max-w-[800px]"
29
+ class="overflow-y-auto md:overflow-hidden p-0 max-h-[80dvh] md:max-h-[500px] md:max-w-[700px] lg:max-w-[800px]"
30
30
  >
31
31
  <Dialog.Title class="sr-only">Settings</Dialog.Title>
32
32
  <Dialog.Description class="sr-only"
@@ -58,7 +58,7 @@
58
58
  </Sidebar.Group>
59
59
  </Sidebar.Content>
60
60
  </Sidebar.Root>
61
- <main class="flex h-[480px] flex-1 flex-col overflow-hidden">
61
+ <main class="flex sm:h-auto md:h-[480px] flex-1 flex-col overflow-hidden">
62
62
  <header
63
63
  class="flex h-16 shrink-0 items-center gap-2 transition-[width,height] ease-linear group-has-[[data-collapsible=icon]]/sidebar-wrapper:h-12"
64
64
  >
@@ -76,7 +76,7 @@
76
76
  </Breadcrumb.Root>
77
77
  </div>
78
78
  </header>
79
- <div class="flex flex-1 flex-col gap-4 overflow-y-auto p-4 pt-0">
79
+ <div class="flex flex-1 flex-col gap-4 overflow-y-auto p-4 pt-0 ">
80
80
  {#if section === "Profile"}
81
81
  <ProfileSection></ProfileSection>
82
82
  {/if}
@@ -13,9 +13,9 @@
13
13
 
14
14
  let isOpen = $state(false);
15
15
 
16
- let { nav }: { nav?: NavItem[] } = $props();
16
+ let { nav, redirectTo="/sign-in" }: { nav?: NavItem[], redirectTo:string } = $props();
17
17
  async function handleLogout() {
18
- await firekitAuth.logOut();
18
+ await firekitAuth.logOut(redirectTo);
19
19
  }
20
20
  </script>
21
21
 
@@ -1,5 +1,6 @@
1
1
  import type { NavItem } from "../../../types/nav.js";
2
2
  declare const UserButton: import("svelte").Component<{
3
3
  nav?: NavItem[];
4
+ redirectTo: string;
4
5
  }, {}, "">;
5
6
  export default UserButton;
@@ -0,0 +1,13 @@
1
+ import { Select as SelectPrimitive } from "bits-ui";
2
+ import GroupHeading from "./select-group-heading.svelte";
3
+ import Item from "./select-item.svelte";
4
+ import Content from "./select-content.svelte";
5
+ import Trigger from "./select-trigger.svelte";
6
+ import Separator from "./select-separator.svelte";
7
+ import ScrollDownButton from "./select-scroll-down-button.svelte";
8
+ import ScrollUpButton from "./select-scroll-up-button.svelte";
9
+ const Root = SelectPrimitive.Root;
10
+ const Group = SelectPrimitive.Group;
11
+ export { Root, Item, Group, GroupHeading, Content, Trigger, Separator, ScrollDownButton, ScrollUpButton,
12
+ //
13
+ Root as Select, Item as SelectItem, Group as SelectGroup, GroupHeading as SelectGroupHeading, Content as SelectContent, Trigger as SelectTrigger, Separator as SelectSeparator, ScrollDownButton as SelectScrollDownButton, ScrollUpButton as SelectScrollUpButton, };
@@ -0,0 +1,38 @@
1
+ <script lang="ts">
2
+ import { Select as SelectPrimitive, type WithoutChild } from "bits-ui";
3
+ import * as Select from "./index.js";
4
+ import { cn } from "../../../utils.js";
5
+
6
+ let {
7
+ ref = $bindable(null),
8
+ class: className,
9
+ sideOffset = 4,
10
+ portalProps,
11
+ children,
12
+ ...restProps
13
+ }: WithoutChild<SelectPrimitive.ContentProps> & {
14
+ portalProps?: SelectPrimitive.PortalProps;
15
+ } = $props();
16
+ </script>
17
+
18
+ <SelectPrimitive.Portal {...portalProps}>
19
+ <SelectPrimitive.Content
20
+ bind:ref
21
+ {sideOffset}
22
+ class={cn(
23
+ "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 bg-popover text-popover-foreground relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border shadow-md data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
24
+ className
25
+ )}
26
+ {...restProps}
27
+ >
28
+ <Select.ScrollUpButton />
29
+ <SelectPrimitive.Viewport
30
+ class={cn(
31
+ "h-[var(--bits-select-anchor-height)] w-full min-w-[var(--bits-select-anchor-width)] p-1"
32
+ )}
33
+ >
34
+ {@render children?.()}
35
+ </SelectPrimitive.Viewport>
36
+ <Select.ScrollDownButton />
37
+ </SelectPrimitive.Content>
38
+ </SelectPrimitive.Portal>
@@ -0,0 +1,5 @@
1
+ import { Select as SelectPrimitive } from "bits-ui";
2
+ declare const SelectContent: import("svelte").Component<Omit<SelectPrimitive.ContentProps, "child"> & {
3
+ portalProps?: SelectPrimitive.PortalProps;
4
+ }, {}, "ref">;
5
+ export default SelectContent;
@@ -0,0 +1,16 @@
1
+ <script lang="ts">
2
+ import { Select as SelectPrimitive } from "bits-ui";
3
+ import { cn } from "../../../utils.js";
4
+
5
+ let {
6
+ ref = $bindable(null),
7
+ class: className,
8
+ ...restProps
9
+ }: SelectPrimitive.GroupHeadingProps = $props();
10
+ </script>
11
+
12
+ <SelectPrimitive.GroupHeading
13
+ bind:ref
14
+ class={cn("px-2 py-1.5 text-sm font-semibold", className)}
15
+ {...restProps}
16
+ />
@@ -0,0 +1,3 @@
1
+ import { Select as SelectPrimitive } from "bits-ui";
2
+ declare const SelectGroupHeading: import("svelte").Component<SelectPrimitive.GroupHeadingProps, {}, "ref">;
3
+ export default SelectGroupHeading;
@@ -0,0 +1,37 @@
1
+ <script lang="ts">
2
+ import { Select as SelectPrimitive, type WithoutChild } from "bits-ui";
3
+ import Check from "lucide-svelte/icons/check";
4
+ import { cn } from "../../../utils.js";
5
+
6
+ let {
7
+ ref = $bindable(null),
8
+ class: className,
9
+ value,
10
+ label,
11
+ children: childrenProp,
12
+ ...restProps
13
+ }: WithoutChild<SelectPrimitive.ItemProps> = $props();
14
+ </script>
15
+
16
+ <SelectPrimitive.Item
17
+ bind:ref
18
+ {value}
19
+ class={cn(
20
+ "data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
21
+ className
22
+ )}
23
+ {...restProps}
24
+ >
25
+ {#snippet children({ selected, highlighted })}
26
+ <span class="absolute right-2 flex size-3.5 items-center justify-center">
27
+ {#if selected}
28
+ <Check class="size-4" />
29
+ {/if}
30
+ </span>
31
+ {#if childrenProp}
32
+ {@render childrenProp({ selected, highlighted })}
33
+ {:else}
34
+ {label || value}
35
+ {/if}
36
+ {/snippet}
37
+ </SelectPrimitive.Item>
@@ -0,0 +1,3 @@
1
+ import { Select as SelectPrimitive } from "bits-ui";
2
+ declare const SelectItem: import("svelte").Component<Omit<SelectPrimitive.ItemProps, "child">, {}, "ref">;
3
+ export default SelectItem;
@@ -0,0 +1,19 @@
1
+ <script lang="ts">
2
+ import ChevronDown from "lucide-svelte/icons/chevron-down";
3
+ import { Select as SelectPrimitive, type WithoutChildrenOrChild } from "bits-ui";
4
+ import { cn } from "../../../utils.js";
5
+
6
+ let {
7
+ ref = $bindable(null),
8
+ class: className,
9
+ ...restProps
10
+ }: WithoutChildrenOrChild<SelectPrimitive.ScrollDownButtonProps> = $props();
11
+ </script>
12
+
13
+ <SelectPrimitive.ScrollDownButton
14
+ bind:ref
15
+ class={cn("flex cursor-default items-center justify-center py-1", className)}
16
+ {...restProps}
17
+ >
18
+ <ChevronDown class="size-4" />
19
+ </SelectPrimitive.ScrollDownButton>
@@ -0,0 +1,3 @@
1
+ import { Select as SelectPrimitive } from "bits-ui";
2
+ declare const SelectScrollDownButton: import("svelte").Component<Omit<Omit<SelectPrimitive.ScrollDownButtonProps, "child">, "children">, {}, "ref">;
3
+ export default SelectScrollDownButton;
@@ -0,0 +1,19 @@
1
+ <script lang="ts">
2
+ import ChevronUp from "lucide-svelte/icons/chevron-up";
3
+ import { Select as SelectPrimitive, type WithoutChildrenOrChild } from "bits-ui";
4
+ import { cn } from "../../../utils.js";
5
+
6
+ let {
7
+ ref = $bindable(null),
8
+ class: className,
9
+ ...restProps
10
+ }: WithoutChildrenOrChild<SelectPrimitive.ScrollDownButtonProps> = $props();
11
+ </script>
12
+
13
+ <SelectPrimitive.ScrollUpButton
14
+ bind:ref
15
+ class={cn("flex cursor-default items-center justify-center py-1", className)}
16
+ {...restProps}
17
+ >
18
+ <ChevronUp class="size-4" />
19
+ </SelectPrimitive.ScrollUpButton>
@@ -0,0 +1,3 @@
1
+ import { Select as SelectPrimitive } from "bits-ui";
2
+ declare const SelectScrollUpButton: import("svelte").Component<Omit<Omit<SelectPrimitive.ScrollDownButtonProps, "child">, "children">, {}, "ref">;
3
+ export default SelectScrollUpButton;
@@ -0,0 +1,13 @@
1
+ <script lang="ts">
2
+ import type { Separator as SeparatorPrimitive } from "bits-ui";
3
+ import { Separator } from "../separator/index.js";
4
+ import { cn } from "../../../utils.js";
5
+
6
+ let {
7
+ ref = $bindable(null),
8
+ class: className,
9
+ ...restProps
10
+ }: SeparatorPrimitive.RootProps = $props();
11
+ </script>
12
+
13
+ <Separator bind:ref class={cn("bg-muted -mx-1 my-1 h-px", className)} {...restProps} />
@@ -0,0 +1,3 @@
1
+ import type { Separator as SeparatorPrimitive } from "bits-ui";
2
+ declare const SelectSeparator: import("svelte").Component<SeparatorPrimitive.RootProps, {}, "ref">;
3
+ export default SelectSeparator;
@@ -0,0 +1,24 @@
1
+ <script lang="ts">
2
+ import { Select as SelectPrimitive, type WithoutChild } from "bits-ui";
3
+ import ChevronDown from "lucide-svelte/icons/chevron-down";
4
+ import { cn } from "../../../utils.js";
5
+
6
+ let {
7
+ ref = $bindable(null),
8
+ class: className,
9
+ children,
10
+ ...restProps
11
+ }: WithoutChild<SelectPrimitive.TriggerProps> = $props();
12
+ </script>
13
+
14
+ <SelectPrimitive.Trigger
15
+ bind:ref
16
+ class={cn(
17
+ "border-input ring-offset-background data-[placeholder]:text-muted-foreground focus:ring-ring flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border bg-transparent px-3 py-2 text-sm shadow-sm focus:outline-none focus:ring-1 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
18
+ className
19
+ )}
20
+ {...restProps}
21
+ >
22
+ {@render children?.()}
23
+ <ChevronDown class="size-4 opacity-50" />
24
+ </SelectPrimitive.Trigger>
@@ -0,0 +1,3 @@
1
+ import { Select as SelectPrimitive } from "bits-ui";
2
+ declare const SelectTrigger: import("svelte").Component<Omit<SelectPrimitive.TriggerProps, "child">, {}, "ref">;
3
+ export default SelectTrigger;
@@ -61,7 +61,7 @@ export declare class FirekitAuthManager {
61
61
  private generateDeviceId;
62
62
  private getPlatformInfo;
63
63
  private validateClaims;
64
- private handleRedirect;
64
+ handleRedirect(redirectTo: string, params?: Record<string, string>): Promise<void>;
65
65
  validateAuth({ authRequired, redirectTo, requiredClaims, requiredData, allowIf, redirectParams, }?: GuardConfig): Promise<boolean>;
66
66
  updateEmailUser(email: string): Promise<void>;
67
67
  updatePassword(password: string): Promise<void>;
@@ -76,8 +76,6 @@ export declare class FirekitAuthManager {
76
76
  hasRequiredClaims(requiredClaims: string[]): boolean;
77
77
  isAdmin(): boolean;
78
78
  isPremium(): boolean;
79
- requireAuth(redirectTo?: string, redirectParams?: Record<string, string>): Promise<boolean>;
80
- requireNoAuth(redirectTo?: string, redirectParams?: Record<string, string>): Promise<boolean>;
81
79
  requireClaims(claims: string[], redirectTo?: string, redirectParams?: Record<string, string>): Promise<boolean>;
82
80
  requireData(validator: (data: DocumentData | null) => boolean, redirectTo?: string, redirectParams?: Record<string, string>): Promise<boolean>;
83
81
  logOut(): Promise<void>;
@@ -353,21 +353,6 @@ export class FirekitAuthManager {
353
353
  isPremium() {
354
354
  return Boolean(this._claims.premium);
355
355
  }
356
- // Convenience methods for route guards
357
- async requireAuth(redirectTo = "/login", redirectParams) {
358
- return this.validateAuth({
359
- authRequired: true,
360
- redirectTo,
361
- redirectParams,
362
- });
363
- }
364
- async requireNoAuth(redirectTo = "/dashboard", redirectParams) {
365
- return this.validateAuth({
366
- authRequired: false,
367
- redirectTo,
368
- redirectParams,
369
- });
370
- }
371
356
  async requireClaims(claims, redirectTo = "/login", redirectParams) {
372
357
  return this.validateAuth({
373
358
  requiredClaims: claims,
package/dist/index.d.ts CHANGED
@@ -12,6 +12,8 @@ export { default as SignInPage } from './auth/sign-in.svelte';
12
12
  export { default as SignUpPage } from './auth/sign-up.svelte';
13
13
  export { default as ResetPassWordPage } from './auth/reset-password.svelte';
14
14
  export { default as AuthPage } from './auth/auth.svelte';
15
+ export { default as RequireAuth } from './auth/require-auth.svelte';
16
+ export { default as RequireNoAuth } from './auth/require-no-auth.svelte';
15
17
  export { default as ResetPassWordForm } from './components/auth/reset-password-form.svelte';
16
18
  export { default as SignInForm } from './components/auth/sign-in-form.svelte';
17
19
  export { default as SignUpForm } from './components/auth/sign-up-form.svelte';
package/dist/index.js CHANGED
@@ -19,6 +19,8 @@ export { default as SignInPage } from './auth/sign-in.svelte';
19
19
  export { default as SignUpPage } from './auth/sign-up.svelte';
20
20
  export { default as ResetPassWordPage } from './auth/reset-password.svelte';
21
21
  export { default as AuthPage } from './auth/auth.svelte';
22
+ export { default as RequireAuth } from './auth/require-auth.svelte';
23
+ export { default as RequireNoAuth } from './auth/require-no-auth.svelte';
22
24
  export { default as ResetPassWordForm } from './components/auth/reset-password-form.svelte';
23
25
  export { default as SignInForm } from './components/auth/sign-in-form.svelte';
24
26
  export { default as SignUpForm } from './components/auth/sign-up-form.svelte';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-firekit",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "license": "MIT",
5
5
  "scripts": {
6
6
  "dev": "vite dev",