@functionalcms/svelte-components 5.17.0 → 5.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -36,8 +36,10 @@
36
36
  let container: HTMLElement | undefined = undefined;
37
37
  const helpers = uiHelpers();
38
38
  let isCollapsed = $state(false);
39
- let icon = $derived(isCollapsed ? OutlinedIcons.ChevronDoubleRight : OutlinedIcons.ChevronDoubleLeft);
40
-
39
+ let icon = $derived(
40
+ isCollapsed ? OutlinedIcons.ChevronDoubleRight : OutlinedIcons.ChevronDoubleLeft
41
+ );
42
+
41
43
  afterNavigate(() => {
42
44
  window.scrollTo({ top: 0, behavior: 'instant' });
43
45
  });
@@ -63,11 +65,11 @@
63
65
  class="rounded-lg p-2 hover:bg-gray-100 dark:hover:bg-gray-700"
64
66
  title={isCollapsed ? 'Expand menu' : 'Collapse menu'}
65
67
  >
66
- <Icon icon={icon} />
68
+ <Icon {icon} />
67
69
  </button>
68
70
  </div>
69
- {#if !isCollapsed}
70
- {#each menuItems as item}
71
+ {#each menuItems as item}
72
+ {#if !isCollapsed}
71
73
  {#if 'items' in item}
72
74
  <SidebarDropdownWrapper label={item.label}>
73
75
  {#each item.items as subItem}
@@ -81,21 +83,22 @@
81
83
  {/snippet}
82
84
  </SidebarItem>
83
85
  {/if}
84
- {/each}
85
- {:else}
86
- {#each menuItems as item}
87
- {#if !('items' in item)}
88
- <SidebarItem label="" href={item.href} class="justify-center" title={item.label}>
89
- {#snippet icon()}
90
- <Icon icon={item.icon} />
91
- {/snippet}
92
- </SidebarItem>
93
- {/if}
94
- {/each}
95
- {/if}
86
+ {:else}
87
+ <SidebarItem label="" href={item.href} class="justify-center" title={item.label}>
88
+ {#snippet icon()}
89
+ <Icon icon={item.icon} />
90
+ {/snippet}
91
+ </SidebarItem>
92
+ {/if}
93
+ {/each}
96
94
  </SidebarGroup>
97
95
  </Sidebar>
98
- <div class="content h-full overflow-auto px-4 transition-all duration-300 {isCollapsed ? 'md:ml-16' : 'md:ml-64'}" style:flex="1">
96
+ <div
97
+ class="content h-full overflow-auto px-4 transition-all duration-300 {isCollapsed
98
+ ? 'md:ml-16'
99
+ : 'md:ml-64'}"
100
+ style:flex="1"
101
+ >
99
102
  {@render children?.()}
100
103
  </div>
101
104
  </main>
@@ -1,3 +1,4 @@
1
1
  import { type Handle } from '@sveltejs/kit';
2
- export declare const sessionStorageHandler: (url: string, token: string, contentName: string) => Handle;
2
+ import { Redis } from '@upstash/redis';
3
+ export declare const sessionStorageHandler: (redis: Redis, contentName: string) => Handle;
3
4
  export default sessionStorageHandler;
@@ -1,15 +1,11 @@
1
1
  import {} from '@sveltejs/kit';
2
2
  import { Redis } from '@upstash/redis';
3
- export const sessionStorageHandler = (url, token, contentName) => {
4
- const redis = new Redis({
5
- url: url,
6
- token: token
7
- });
3
+ export const sessionStorageHandler = (redis, contentName) => {
8
4
  return async ({ event, resolve }) => {
9
5
  try {
10
6
  const user = event.locals?.user;
11
- const uniqueKey = `${user?.id}_${contentName}`;
12
7
  if (user) {
8
+ const uniqueKey = `${user?.id}_${contentName}`;
13
9
  const itemContent = await redis.get(uniqueKey);
14
10
  if (itemContent != ''
15
11
  && (Array.isArray(itemContent) != [] && itemContent.length > 0)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@functionalcms/svelte-components",
3
- "version": "5.17.0",
3
+ "version": "5.18.1",
4
4
  "license": "MIT",
5
5
  "watch": {
6
6
  "build": {
@@ -0,0 +1,20 @@
1
+ import { DOMAIN } from '$env/static/private';
2
+ import { getUsersService } from '@functionalcms/svelte-components/index-server.js';
3
+ import { fail } from '@sveltejs/kit';
4
+
5
+ /** @type {import('./$types').PageServerLoad} */
6
+ export async function load({ params }) {
7
+ const code = params.email;
8
+
9
+ return { code };
10
+ }
11
+
12
+ export const actions = {
13
+ setup: async ({ request, locals, params }) => {
14
+ const userService = getUsersService(locals);
15
+
16
+ const result = await userService.setup(DOMAIN, params.email);
17
+
18
+ return { success: true };
19
+ },
20
+ };
@@ -0,0 +1,56 @@
1
+ <script lang="ts">
2
+ import { Button, Input, Label } from "@functionalcms/svelte-components";
3
+ import * as m from "$lib/paraglide/messages.js";
4
+ import { goto } from "$app/navigation";
5
+ import { deserialize } from "$app/forms";
6
+
7
+ interface Props {
8
+ data: {
9
+ code: string | null;
10
+ };
11
+ }
12
+
13
+ let { data } = $props();
14
+
15
+ let password = $state("");
16
+ let confirmPassword = $state("");
17
+ let submitError = $state(false);
18
+
19
+ async function resetPassword() {
20
+ submitError = false;
21
+
22
+ const response = await fetch("?/setup", {
23
+ method: "POST",
24
+ body: "",
25
+ });
26
+
27
+ const result = deserialize(await response.text());
28
+
29
+ if (result.type === "success") {
30
+ goto("/auth/login");
31
+ } else {
32
+ submitError = true;
33
+ }
34
+ }
35
+ </script>
36
+
37
+ <article>
38
+ <main class="flex flex-col justify-around items-center gap-4 w-full m-auto p-4">
39
+ <h1>{m.auth_setup_title()}</h1>
40
+
41
+ {#if !data.code}
42
+ <p>{m.auth_setup_missing_code()}</p>
43
+ {:else}
44
+ <Button onclick={resetPassword}>
45
+ {m.auth_setup_submit()}
46
+ </Button>
47
+
48
+ {#if submitError}
49
+ <p class="text-red-600">{m.auth_setup_error()}</p>
50
+ {/if}
51
+ {/if}
52
+ </main>
53
+ </article>
54
+
55
+ <style>
56
+ </style>