sandcms 0.6.2 → 0.6.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 +1 -1
- package/dist/admin/Account.svelte +284 -83
- package/dist/admin/ApiKeys.svelte +146 -79
- package/dist/admin/AssetAttachment.svelte +9 -9
- package/dist/admin/BlueprintFields.svelte +20 -2
- package/dist/admin/BlueprintFields.svelte.d.ts +2 -0
- package/dist/admin/Collection.svelte +111 -54
- package/dist/admin/Dashboard.svelte +3 -37
- package/dist/admin/DateField.svelte +75 -0
- package/dist/admin/DateField.svelte.d.ts +11 -0
- package/dist/admin/Editor.svelte +71 -65
- package/dist/admin/Fields.svelte +24 -16
- package/dist/admin/FocusPicker.svelte +1 -2
- package/dist/admin/Gallery.svelte +0 -1
- package/dist/admin/GlobalSearch.svelte +54 -26
- package/dist/admin/HoverHint.svelte +37 -0
- package/dist/admin/HoverHint.svelte.d.ts +8 -0
- package/dist/admin/Inbox.svelte +6 -11
- package/dist/admin/LinkField.svelte +129 -64
- package/dist/admin/Login.svelte +0 -1
- package/dist/admin/MediaLibrary.svelte +61 -50
- package/dist/admin/MediaPicker.svelte +57 -42
- package/dist/admin/NotificationSettings.svelte +35 -27
- package/dist/admin/RichText.svelte +2 -2
- package/dist/admin/RowMenu.svelte +28 -0
- package/dist/admin/RowMenu.svelte.d.ts +10 -0
- package/dist/admin/SearchList.svelte +51 -14
- package/dist/admin/Shell.svelte +64 -29
- package/dist/admin/Users.svelte +106 -50
- package/dist/admin/client.d.ts +2 -0
- package/dist/admin/client.js +18 -0
- package/dist/admin/components/ui/calendar/calendar-caption.svelte +76 -0
- package/dist/admin/components/ui/calendar/calendar-caption.svelte.d.ts +19 -0
- package/dist/admin/components/ui/calendar/calendar-cell.svelte +19 -0
- package/dist/admin/components/ui/calendar/calendar-cell.svelte.d.ts +4 -0
- package/dist/admin/components/ui/calendar/calendar-day.svelte +33 -0
- package/dist/admin/components/ui/calendar/calendar-day.svelte.d.ts +4 -0
- package/dist/admin/components/ui/calendar/calendar-grid-body.svelte +12 -0
- package/dist/admin/components/ui/calendar/calendar-grid-body.svelte.d.ts +4 -0
- package/dist/admin/components/ui/calendar/calendar-grid-head.svelte +12 -0
- package/dist/admin/components/ui/calendar/calendar-grid-head.svelte.d.ts +4 -0
- package/dist/admin/components/ui/calendar/calendar-grid-row.svelte +12 -0
- package/dist/admin/components/ui/calendar/calendar-grid-row.svelte.d.ts +4 -0
- package/dist/admin/components/ui/calendar/calendar-grid.svelte +16 -0
- package/dist/admin/components/ui/calendar/calendar-grid.svelte.d.ts +4 -0
- package/dist/admin/components/ui/calendar/calendar-head-cell.svelte +19 -0
- package/dist/admin/components/ui/calendar/calendar-head-cell.svelte.d.ts +4 -0
- package/dist/admin/components/ui/calendar/calendar-header.svelte +19 -0
- package/dist/admin/components/ui/calendar/calendar-header.svelte.d.ts +4 -0
- package/dist/admin/components/ui/calendar/calendar-heading.svelte +16 -0
- package/dist/admin/components/ui/calendar/calendar-heading.svelte.d.ts +4 -0
- package/dist/admin/components/ui/calendar/calendar-month-select.svelte +48 -0
- package/dist/admin/components/ui/calendar/calendar-month-select.svelte.d.ts +4 -0
- package/dist/admin/components/ui/calendar/calendar-month.svelte +15 -0
- package/dist/admin/components/ui/calendar/calendar-month.svelte.d.ts +5 -0
- package/dist/admin/components/ui/calendar/calendar-months.svelte +19 -0
- package/dist/admin/components/ui/calendar/calendar-months.svelte.d.ts +5 -0
- package/dist/admin/components/ui/calendar/calendar-nav.svelte +19 -0
- package/dist/admin/components/ui/calendar/calendar-nav.svelte.d.ts +5 -0
- package/dist/admin/components/ui/calendar/calendar-next-button.svelte +37 -0
- package/dist/admin/components/ui/calendar/calendar-next-button.svelte.d.ts +8 -0
- package/dist/admin/components/ui/calendar/calendar-prev-button.svelte +37 -0
- package/dist/admin/components/ui/calendar/calendar-prev-button.svelte.d.ts +8 -0
- package/dist/admin/components/ui/calendar/calendar-year-select.svelte +47 -0
- package/dist/admin/components/ui/calendar/calendar-year-select.svelte.d.ts +4 -0
- package/dist/admin/components/ui/calendar/calendar.svelte +115 -0
- package/dist/admin/components/ui/calendar/calendar.svelte.d.ts +21 -0
- package/dist/admin/components/ui/calendar/index.d.ts +19 -0
- package/dist/admin/components/ui/calendar/index.js +21 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-checkbox-group.svelte +16 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-checkbox-group.svelte.d.ts +4 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-checkbox-item.svelte +46 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-checkbox-item.svelte.d.ts +9 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-content.svelte +31 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-content.svelte.d.ts +10 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-group-heading.svelte +22 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-group-heading.svelte.d.ts +8 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-group.svelte +7 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-group.svelte.d.ts +4 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-item.svelte +27 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-item.svelte.d.ts +8 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-label.svelte +24 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-label.svelte.d.ts +8 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-portal.svelte +7 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-portal.svelte.d.ts +3 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-radio-group.svelte +16 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-radio-group.svelte.d.ts +4 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-radio-item.svelte +36 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-radio-item.svelte.d.ts +4 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-separator.svelte +17 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-separator.svelte.d.ts +4 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-shortcut.svelte +23 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-shortcut.svelte.d.ts +5 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-sub-content.svelte +31 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-sub-content.svelte.d.ts +10 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-sub-trigger.svelte +29 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-sub-trigger.svelte.d.ts +7 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-sub.svelte +7 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-sub.svelte.d.ts +3 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-trigger.svelte +7 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu-trigger.svelte.d.ts +4 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu.svelte +7 -0
- package/dist/admin/components/ui/dropdown-menu/dropdown-menu.svelte.d.ts +3 -0
- package/dist/admin/components/ui/dropdown-menu/index.d.ts +18 -0
- package/dist/admin/components/ui/dropdown-menu/index.js +18 -0
- package/dist/admin/components/ui/input-otp/index.d.ts +5 -0
- package/dist/admin/components/ui/input-otp/index.js +5 -0
- package/dist/admin/components/ui/input-otp/input-otp-group.svelte +23 -0
- package/dist/admin/components/ui/input-otp/input-otp-group.svelte.d.ts +5 -0
- package/dist/admin/components/ui/input-otp/input-otp-separator.svelte +27 -0
- package/dist/admin/components/ui/input-otp/input-otp-separator.svelte.d.ts +5 -0
- package/dist/admin/components/ui/input-otp/input-otp-slot.svelte +29 -0
- package/dist/admin/components/ui/input-otp/input-otp-slot.svelte.d.ts +4 -0
- package/dist/admin/components/ui/input-otp/input-otp.svelte +24 -0
- package/dist/admin/components/ui/input-otp/input-otp.svelte.d.ts +4 -0
- package/dist/admin/components/ui/popover/index.d.ts +9 -0
- package/dist/admin/components/ui/popover/index.js +11 -0
- package/dist/admin/components/ui/popover/popover-close.svelte +7 -0
- package/dist/admin/components/ui/popover/popover-close.svelte.d.ts +4 -0
- package/dist/admin/components/ui/popover/popover-content.svelte +31 -0
- package/dist/admin/components/ui/popover/popover-content.svelte.d.ts +10 -0
- package/dist/admin/components/ui/popover/popover-description.svelte +20 -0
- package/dist/admin/components/ui/popover/popover-description.svelte.d.ts +5 -0
- package/dist/admin/components/ui/popover/popover-header.svelte +20 -0
- package/dist/admin/components/ui/popover/popover-header.svelte.d.ts +5 -0
- package/dist/admin/components/ui/popover/popover-portal.svelte +7 -0
- package/dist/admin/components/ui/popover/popover-portal.svelte.d.ts +3 -0
- package/dist/admin/components/ui/popover/popover-title.svelte +20 -0
- package/dist/admin/components/ui/popover/popover-title.svelte.d.ts +5 -0
- package/dist/admin/components/ui/popover/popover-trigger.svelte +17 -0
- package/dist/admin/components/ui/popover/popover-trigger.svelte.d.ts +4 -0
- package/dist/admin/components/ui/popover/popover.svelte +7 -0
- package/dist/admin/components/ui/popover/popover.svelte.d.ts +3 -0
- package/dist/admin/components/ui/switch/switch.svelte +2 -2
- package/dist/admin/components/ui/tooltip/index.d.ts +6 -0
- package/dist/admin/components/ui/tooltip/index.js +8 -0
- package/dist/admin/components/ui/tooltip/tooltip-content.svelte +48 -0
- package/dist/admin/components/ui/tooltip/tooltip-content.svelte.d.ts +11 -0
- package/dist/admin/components/ui/tooltip/tooltip-portal.svelte +7 -0
- package/dist/admin/components/ui/tooltip/tooltip-portal.svelte.d.ts +4 -0
- package/dist/admin/components/ui/tooltip/tooltip-provider.svelte +7 -0
- package/dist/admin/components/ui/tooltip/tooltip-provider.svelte.d.ts +4 -0
- package/dist/admin/components/ui/tooltip/tooltip-trigger.svelte +7 -0
- package/dist/admin/components/ui/tooltip/tooltip-trigger.svelte.d.ts +25 -0
- package/dist/admin/components/ui/tooltip/tooltip.svelte +7 -0
- package/dist/admin/components/ui/tooltip/tooltip.svelte.d.ts +25 -0
- package/dist/admin/generated/admin.css +774 -138
- package/dist/admin/slug.d.ts +1 -0
- package/dist/admin/slug.js +6 -0
- package/dist/cli/index.js +0 -0
- package/dist/server/admin-load.js +2 -2
- package/dist/server/api.js +6 -1
- package/dist/server/auth.d.ts +1 -0
- package/dist/server/auth.js +23 -0
- package/docs/api.md +1 -1
- package/docs/package.md +4 -4
- package/docs/releases.md +10 -0
- package/docs/upgrades.md +9 -0
- package/package.json +5 -3
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import Ellipsis from '@lucide/svelte/icons/ellipsis';
|
|
4
|
+
import { Button } from './components/ui/button/index.js';
|
|
5
|
+
import * as DropdownMenu from './components/ui/dropdown-menu/index.js';
|
|
6
|
+
let {
|
|
7
|
+
label,
|
|
8
|
+
size = 'icon-sm',
|
|
9
|
+
variant = 'ghost',
|
|
10
|
+
children
|
|
11
|
+
}: {
|
|
12
|
+
label: string;
|
|
13
|
+
size?: 'icon-sm' | 'icon';
|
|
14
|
+
variant?: 'ghost' | 'outline';
|
|
15
|
+
children: Snippet;
|
|
16
|
+
} = $props();
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<DropdownMenu.Root>
|
|
20
|
+
<DropdownMenu.Trigger>
|
|
21
|
+
{#snippet child({ props })}<Button {...props} {variant} {size} aria-label={label}
|
|
22
|
+
><Ellipsis /></Button
|
|
23
|
+
>{/snippet}
|
|
24
|
+
</DropdownMenu.Trigger>
|
|
25
|
+
<DropdownMenu.Content portalProps={{ disabled: true }} align="end" class="cms-row-menu">
|
|
26
|
+
{@render children()}
|
|
27
|
+
</DropdownMenu.Content>
|
|
28
|
+
</DropdownMenu.Root>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
label: string;
|
|
4
|
+
size?: 'icon-sm' | 'icon';
|
|
5
|
+
variant?: 'ghost' | 'outline';
|
|
6
|
+
children: Snippet;
|
|
7
|
+
};
|
|
8
|
+
declare const RowMenu: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
9
|
+
type RowMenu = ReturnType<typeof RowMenu>;
|
|
10
|
+
export default RowMenu;
|
|
@@ -3,11 +3,26 @@
|
|
|
3
3
|
import { Input } from './components/ui/input/index.js';
|
|
4
4
|
import { Button } from './components/ui/button/index.js';
|
|
5
5
|
import { message } from './client.js';
|
|
6
|
-
let {
|
|
7
|
-
path
|
|
6
|
+
let {
|
|
7
|
+
path,
|
|
8
|
+
initial,
|
|
9
|
+
label,
|
|
10
|
+
children,
|
|
11
|
+
empty = 'No matches found.',
|
|
12
|
+
refreshKey = ''
|
|
13
|
+
}: {
|
|
14
|
+
path: string;
|
|
15
|
+
initial: T[];
|
|
16
|
+
label: string;
|
|
17
|
+
children: Snippet<[T[]]>;
|
|
18
|
+
empty?: string;
|
|
19
|
+
refreshKey?: string;
|
|
8
20
|
} = $props();
|
|
9
|
-
let query = $state(''),
|
|
10
|
-
|
|
21
|
+
let query = $state(''),
|
|
22
|
+
results = $state<T[]>([]),
|
|
23
|
+
cursor = $state<string | null>(null),
|
|
24
|
+
loading = $state(false),
|
|
25
|
+
error = $state('');
|
|
11
26
|
let controller: AbortController | undefined;
|
|
12
27
|
const searching = $derived(!!query.trim());
|
|
13
28
|
const items = $derived(searching ? results : initial);
|
|
@@ -30,26 +45,48 @@
|
|
|
30
45
|
}
|
|
31
46
|
}
|
|
32
47
|
$effect(() => {
|
|
33
|
-
const current = query,
|
|
48
|
+
const current = query,
|
|
49
|
+
route = path,
|
|
50
|
+
revision = refreshKey;
|
|
34
51
|
controller?.abort();
|
|
35
52
|
controller = new AbortController();
|
|
36
53
|
const active = controller;
|
|
37
|
-
results = [];
|
|
54
|
+
results = [];
|
|
55
|
+
cursor = null;
|
|
56
|
+
error = '';
|
|
57
|
+
loading = !!current.trim();
|
|
38
58
|
if (!current.trim()) return () => active.abort();
|
|
39
59
|
const timer = setTimeout(() => void request(active.signal), 200);
|
|
40
|
-
return () => {
|
|
60
|
+
return () => {
|
|
61
|
+
clearTimeout(timer);
|
|
62
|
+
active.abort();
|
|
63
|
+
};
|
|
41
64
|
});
|
|
42
65
|
</script>
|
|
43
66
|
|
|
44
67
|
<div class="cms-stack">
|
|
45
68
|
<Input aria-label={label} placeholder={label} type="search" maxlength={200} bind:value={query} />
|
|
46
69
|
{#if loading}<p role="status" class="cms-muted">Searching…</p>{/if}
|
|
47
|
-
{#if error}<p role="alert" class="cms-error">{error}</p
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
70
|
+
{#if error}<p role="alert" class="cms-error">{error}</p>
|
|
71
|
+
<Button
|
|
72
|
+
variant="outline"
|
|
73
|
+
onclick={() => {
|
|
74
|
+
error = '';
|
|
75
|
+
loading = true;
|
|
76
|
+
void request(controller!.signal);
|
|
77
|
+
}}>Retry search</Button
|
|
78
|
+
>{/if}
|
|
79
|
+
{#if searching && !loading && !error && !items.length}<p role="status" class="cms-muted">
|
|
80
|
+
{empty}
|
|
81
|
+
</p>{/if}
|
|
51
82
|
{@render children(items)}
|
|
52
|
-
{#if searching && cursor}<Button
|
|
53
|
-
|
|
54
|
-
|
|
83
|
+
{#if searching && cursor}<Button
|
|
84
|
+
variant="outline"
|
|
85
|
+
disabled={loading}
|
|
86
|
+
onclick={() => {
|
|
87
|
+
loading = true;
|
|
88
|
+
error = '';
|
|
89
|
+
void request(controller!.signal, cursor!);
|
|
90
|
+
}}>Load more results</Button
|
|
91
|
+
>{/if}
|
|
55
92
|
</div>
|
package/dist/admin/Shell.svelte
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
3
|
import type { AdminData } from './types.js';
|
|
4
|
-
import { afterNavigate } from '$app/navigation';
|
|
4
|
+
import { afterNavigate, goto } from '$app/navigation';
|
|
5
5
|
import { page } from '$app/state';
|
|
6
6
|
import { authClient } from './client.js';
|
|
7
7
|
import { Button } from './components/ui/button/index.js';
|
|
8
8
|
import * as Avatar from './components/ui/avatar/index.js';
|
|
9
|
+
import * as DropdownMenu from './components/ui/dropdown-menu/index.js';
|
|
9
10
|
import Navigation from './Navigation.svelte';
|
|
10
11
|
import GlobalSearch from './GlobalSearch.svelte';
|
|
11
12
|
import Layers from '@lucide/svelte/icons/layers';
|
|
@@ -14,6 +15,9 @@
|
|
|
14
15
|
import Users from '@lucide/svelte/icons/users';
|
|
15
16
|
import ArrowUpRight from '@lucide/svelte/icons/arrow-up-right';
|
|
16
17
|
import Menu from '@lucide/svelte/icons/menu';
|
|
18
|
+
import ChevronsUpDown from '@lucide/svelte/icons/chevrons-up-down';
|
|
19
|
+
import UserRound from '@lucide/svelte/icons/user-round';
|
|
20
|
+
import LogOut from '@lucide/svelte/icons/log-out';
|
|
17
21
|
let { data, children }: { data: AdminData; children: Snippet } = $props();
|
|
18
22
|
let open = $state(false);
|
|
19
23
|
afterNavigate(() => (open = false));
|
|
@@ -21,6 +25,28 @@
|
|
|
21
25
|
href === '/admin'
|
|
22
26
|
? String(page.url.pathname) === '/admin'
|
|
23
27
|
: page.url.pathname === href || page.url.pathname.startsWith(href + '/');
|
|
28
|
+
const crumbs = $derived.by(() => {
|
|
29
|
+
const list: { label: string; href?: string }[] = [];
|
|
30
|
+
const blueprint = data.blueprint;
|
|
31
|
+
if (blueprint) {
|
|
32
|
+
const href = (blueprint.kind === 'form' ? '/admin/forms/' : '/admin/content/') + blueprint.id;
|
|
33
|
+
list.push({ label: blueprint.label, href });
|
|
34
|
+
if (data.editing && blueprint.kind === 'collection')
|
|
35
|
+
list.push({
|
|
36
|
+
label: String(data.entry?.draft.title ?? (data.entry ? 'Untitled' : 'New entry'))
|
|
37
|
+
});
|
|
38
|
+
} else {
|
|
39
|
+
const label = (
|
|
40
|
+
{ media: 'Media library', users: 'Users', account: 'Your account' } as Record<
|
|
41
|
+
string,
|
|
42
|
+
string
|
|
43
|
+
>
|
|
44
|
+
)[data.screen];
|
|
45
|
+
if (label) list.push({ label });
|
|
46
|
+
}
|
|
47
|
+
if (!list.length) list.push({ label: 'Overview' });
|
|
48
|
+
return list;
|
|
49
|
+
});
|
|
24
50
|
async function logout() {
|
|
25
51
|
const result = await authClient.signOut();
|
|
26
52
|
if (!result.error) window.location.assign('/admin/login');
|
|
@@ -30,16 +56,14 @@
|
|
|
30
56
|
<!-- Singleton editor loads create drafts, so wait for navigation before loading data. -->
|
|
31
57
|
<div class="cms-shell" data-sveltekit-preload-data={false}>
|
|
32
58
|
<aside class:cms-open={open} class="cms-sidebar">
|
|
33
|
-
<a href="/admin" class="cms-wordmark"
|
|
34
|
-
><Layers size={23} /> SandCMS <span class="cms-version">V1</span></a
|
|
35
|
-
>
|
|
59
|
+
<a href="/admin" class="cms-wordmark"><Layers size={21} /> SandCMS</a>
|
|
36
60
|
<div class="cms-site">
|
|
37
61
|
<span class="cms-site-icon">{data.site?.slice(0, 1) ?? 'S'}</span>
|
|
38
|
-
<
|
|
62
|
+
<strong>{data.site}</strong>
|
|
39
63
|
</div>
|
|
40
64
|
<nav aria-label="Admin navigation">
|
|
41
65
|
<a href="/admin" class:active={selected('/admin')}><LayoutDashboard size={17} /> Overview</a>
|
|
42
|
-
<p class="cms-nav-label">
|
|
66
|
+
<p class="cms-nav-label">Content</p>
|
|
43
67
|
<Navigation
|
|
44
68
|
blueprints={(data.blueprints ?? []).filter(
|
|
45
69
|
(b) => b.kind === 'page' || b.kind === 'collection'
|
|
@@ -48,7 +72,7 @@
|
|
|
48
72
|
<a href="/admin/media" class:active={selected('/admin/media')}
|
|
49
73
|
><Image size={17} /> Media library</a
|
|
50
74
|
>
|
|
51
|
-
<p class="cms-nav-label">
|
|
75
|
+
<p class="cms-nav-label">Workspace</p>
|
|
52
76
|
<Navigation
|
|
53
77
|
blueprints={(data.blueprints ?? []).filter((b) => b.kind === 'form' || b.kind === 'site')}
|
|
54
78
|
/>
|
|
@@ -58,14 +82,28 @@
|
|
|
58
82
|
>{/if}
|
|
59
83
|
</nav>
|
|
60
84
|
<div class="cms-sidebar-bottom">
|
|
61
|
-
<a href="/" target="_blank" rel="noreferrer"
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
<
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
85
|
+
<a href="/" target="_blank" rel="noreferrer" class="cms-view-site"
|
|
86
|
+
>View website <ArrowUpRight size={16} /></a
|
|
87
|
+
>
|
|
88
|
+
<DropdownMenu.Root>
|
|
89
|
+
<DropdownMenu.Trigger class="cms-profile" aria-label="Account menu"
|
|
90
|
+
><Avatar.Root
|
|
91
|
+
><Avatar.Fallback>{data.user?.name.slice(0, 1)}</Avatar.Fallback></Avatar.Root
|
|
92
|
+
>
|
|
93
|
+
<div class="cms-profile-text">
|
|
94
|
+
<strong>{data.user?.name}</strong><span class="cms-profile-role">{data.user?.role}</span
|
|
95
|
+
>
|
|
96
|
+
</div>
|
|
97
|
+
<ChevronsUpDown size={15} /></DropdownMenu.Trigger
|
|
98
|
+
>
|
|
99
|
+
<DropdownMenu.Content portalProps={{ disabled: true }} side="top" class="cms-profile-menu">
|
|
100
|
+
<DropdownMenu.Item onSelect={() => goto('/admin/account')}
|
|
101
|
+
><UserRound /> Account settings</DropdownMenu.Item
|
|
102
|
+
>
|
|
103
|
+
<DropdownMenu.Separator />
|
|
104
|
+
<DropdownMenu.Item onSelect={logout}><LogOut /> Sign out</DropdownMenu.Item>
|
|
105
|
+
</DropdownMenu.Content>
|
|
106
|
+
</DropdownMenu.Root>
|
|
69
107
|
</div>
|
|
70
108
|
</aside>
|
|
71
109
|
<div class="cms-main">
|
|
@@ -77,21 +115,18 @@
|
|
|
77
115
|
aria-label="Toggle navigation"
|
|
78
116
|
aria-expanded={open}
|
|
79
117
|
onclick={() => (open = !open)}><Menu size={20} /></Button
|
|
80
|
-
><span
|
|
81
|
-
>Workspace <span class="cms-slash">/</span>
|
|
82
|
-
<strong
|
|
83
|
-
>{data.blueprint?.label ??
|
|
84
|
-
{
|
|
85
|
-
media: 'Media library',
|
|
86
|
-
forms: 'Submissions',
|
|
87
|
-
users: 'Users',
|
|
88
|
-
account: 'Your account'
|
|
89
|
-
}[data.screen] ??
|
|
90
|
-
'Overview'}</strong
|
|
91
|
-
></span
|
|
92
|
-
>{#if !data.user?.mustChangePassword}<GlobalSearch />{/if}<a href="/" target="_blank" rel="noreferrer" class="cms-live"
|
|
93
|
-
><span></span> View website <ArrowUpRight size={14} /></a
|
|
94
118
|
>
|
|
119
|
+
<nav class="cms-breadcrumb" aria-label="Breadcrumb">
|
|
120
|
+
<ol>
|
|
121
|
+
{#each crumbs as crumb, i}<li>
|
|
122
|
+
{#if crumb.href && i < crumbs.length - 1}<a href={crumb.href}>{crumb.label}</a
|
|
123
|
+
>{:else}<span aria-current={i === crumbs.length - 1 ? 'page' : undefined}
|
|
124
|
+
>{crumb.label}</span
|
|
125
|
+
>{/if}
|
|
126
|
+
</li>{/each}
|
|
127
|
+
</ol>
|
|
128
|
+
</nav>
|
|
129
|
+
{#if !data.user?.mustChangePassword}<GlobalSearch />{/if}
|
|
95
130
|
</header>
|
|
96
131
|
<main id="cms-main" class="cms-content">{@render children()}</main>
|
|
97
132
|
</div>
|
package/dist/admin/Users.svelte
CHANGED
|
@@ -10,8 +10,28 @@
|
|
|
10
10
|
import { Label } from './components/ui/label/index.js';
|
|
11
11
|
import * as Dialog from './components/ui/dialog/index.js';
|
|
12
12
|
import SelectField from './SelectField.svelte';
|
|
13
|
+
import RowMenu from './RowMenu.svelte';
|
|
14
|
+
import * as DropdownMenu from './components/ui/dropdown-menu/index.js';
|
|
15
|
+
import Trash2 from '@lucide/svelte/icons/trash-2';
|
|
16
|
+
import Send from '@lucide/svelte/icons/send';
|
|
17
|
+
import X from '@lucide/svelte/icons/x';
|
|
13
18
|
let { data }: { data: AdminData } = $props();
|
|
14
|
-
let inviting = $state(false)
|
|
19
|
+
let inviting = $state(false),
|
|
20
|
+
removing = $state<NonNullable<AdminData['users']>[number] | null>(null);
|
|
21
|
+
async function remove() {
|
|
22
|
+
if (!removing) return;
|
|
23
|
+
busy = true;
|
|
24
|
+
error = '';
|
|
25
|
+
try {
|
|
26
|
+
await api('users/delete', { id: removing.id });
|
|
27
|
+
removing = null;
|
|
28
|
+
await refreshAll();
|
|
29
|
+
} catch (e) {
|
|
30
|
+
error = message(e);
|
|
31
|
+
} finally {
|
|
32
|
+
busy = false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
15
35
|
async function invitationAction(path: string, id: string) {
|
|
16
36
|
busy = true;
|
|
17
37
|
error = '';
|
|
@@ -50,11 +70,7 @@
|
|
|
50
70
|
</script>
|
|
51
71
|
|
|
52
72
|
<div class="cms-page-heading">
|
|
53
|
-
<
|
|
54
|
-
<div class="cms-eyebrow">WORKSPACE ACCESS</div>
|
|
55
|
-
<h1>Users</h1>
|
|
56
|
-
<p class="cms-muted">A small team. A shared space to create.</p>
|
|
57
|
-
</div>
|
|
73
|
+
<h1>Users</h1>
|
|
58
74
|
<div class="flex gap-2">
|
|
59
75
|
{#if data.emailEnabled}<Button
|
|
60
76
|
onclick={() => {
|
|
@@ -78,65 +94,105 @@
|
|
|
78
94
|
<Table.Header
|
|
79
95
|
><Table.Row
|
|
80
96
|
><Table.Head>Name</Table.Head><Table.Head>Email</Table.Head><Table.Head>Role</Table.Head
|
|
81
|
-
><Table.Head>Two-factor</Table.Head
|
|
97
|
+
><Table.Head>Two-factor</Table.Head><Table.Head
|
|
98
|
+
><span class="sr-only">Actions</span></Table.Head
|
|
99
|
+
></Table.Row
|
|
82
100
|
></Table.Header
|
|
83
101
|
><Table.Body
|
|
84
|
-
>{#each data.users ?? [] as user}<Table.Row
|
|
85
|
-
><Table.Cell
|
|
102
|
+
>{#each data.users ?? [] as user (user.id)}<Table.Row
|
|
103
|
+
><Table.Cell class="font-medium"
|
|
104
|
+
>{user.name}{#if user.id === data.user?.id}{' '}<span class="cms-muted">(you)</span
|
|
105
|
+
>{/if}</Table.Cell
|
|
106
|
+
><Table.Cell>{user.email}</Table.Cell><Table.Cell class="capitalize"
|
|
86
107
|
>{user.role}</Table.Cell
|
|
87
|
-
><Table.Cell>{user.twoFactorEnabled ? 'Enabled' : '
|
|
108
|
+
><Table.Cell>{user.twoFactorEnabled ? 'Enabled' : 'Off'}</Table.Cell><Table.Cell
|
|
109
|
+
class="text-right"
|
|
110
|
+
>{#if user.id !== data.user?.id}<RowMenu label={'Actions for ' + user.name}
|
|
111
|
+
><DropdownMenu.Item variant="destructive" onSelect={() => (removing = user)}
|
|
112
|
+
><Trash2 /> Remove user</DropdownMenu.Item
|
|
113
|
+
></RowMenu
|
|
114
|
+
>{/if}</Table.Cell
|
|
115
|
+
></Table.Row
|
|
88
116
|
>{/each}</Table.Body
|
|
89
117
|
>
|
|
90
118
|
</Table.Root>
|
|
91
119
|
</Card.Root>
|
|
92
|
-
{#if error && !open}<p class="cms-error" role="alert">{error}</p>{/if}
|
|
120
|
+
{#if error && !open && !removing}<p class="cms-error" role="alert">{error}</p>{/if}
|
|
93
121
|
{#if data.invitations?.length}
|
|
94
|
-
<h2>Pending invitations</h2>
|
|
95
|
-
<
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
122
|
+
<h2 class="cms-subheading">Pending invitations</h2>
|
|
123
|
+
<Card.Root class="gap-0 py-0">
|
|
124
|
+
<Table.Root>
|
|
125
|
+
<Table.Header
|
|
126
|
+
><Table.Row
|
|
127
|
+
><Table.Head>Email</Table.Head><Table.Head>Role</Table.Head><Table.Head
|
|
128
|
+
>Expires</Table.Head
|
|
129
|
+
><Table.Head>Email status</Table.Head><Table.Head
|
|
130
|
+
><span class="sr-only">Actions</span></Table.Head
|
|
131
|
+
></Table.Row
|
|
132
|
+
></Table.Header
|
|
133
|
+
><Table.Body
|
|
134
|
+
>{#each data.invitations as invitation (invitation.id)}<Table.Row
|
|
135
|
+
><Table.Cell class="font-medium">{invitation.email}</Table.Cell><Table.Cell
|
|
136
|
+
class="capitalize">{invitation.role}</Table.Cell
|
|
137
|
+
><Table.Cell
|
|
138
|
+
>{invitation.expiresAt <= Date.now()
|
|
139
|
+
? 'Expired'
|
|
140
|
+
: new Date(invitation.expiresAt).toLocaleDateString()}</Table.Cell
|
|
141
|
+
><Table.Cell class="whitespace-normal"
|
|
142
|
+
>{invitation.status === 'sending'
|
|
143
|
+
? 'Sending or outcome unknown'
|
|
144
|
+
: invitation.status === 'accepted'
|
|
145
|
+
? 'Accepted by mail server'
|
|
146
|
+
: 'Failed'}{#if invitation.status === 'failed'}<span class="cms-error">
|
|
147
|
+
— {emailFailureMessage(invitation.failureReason)}</span
|
|
148
|
+
>{/if}</Table.Cell
|
|
149
|
+
><Table.Cell class="text-right"
|
|
150
|
+
><RowMenu label={'Actions for invitation to ' + invitation.email}
|
|
151
|
+
><DropdownMenu.Item
|
|
152
|
+
disabled={busy || !data.emailEnabled}
|
|
153
|
+
onSelect={() => invitationAction('users/resend-invite', invitation.id)}
|
|
154
|
+
><Send /> Resend invitation</DropdownMenu.Item
|
|
155
|
+
><DropdownMenu.Item
|
|
156
|
+
variant="destructive"
|
|
157
|
+
disabled={busy}
|
|
158
|
+
onSelect={() => invitationAction('users/revoke-invite', invitation.id)}
|
|
159
|
+
><X /> Revoke</DropdownMenu.Item
|
|
160
|
+
></RowMenu
|
|
161
|
+
></Table.Cell
|
|
162
|
+
></Table.Row
|
|
163
|
+
>{/each}</Table.Body
|
|
164
|
+
>
|
|
165
|
+
</Table.Root>
|
|
166
|
+
</Card.Root>
|
|
131
167
|
{/if}
|
|
168
|
+
<Dialog.Root
|
|
169
|
+
open={!!removing}
|
|
170
|
+
onOpenChange={(value) => {
|
|
171
|
+
if (!value) removing = null;
|
|
172
|
+
}}
|
|
173
|
+
><Dialog.Content portalProps={{ disabled: true }}
|
|
174
|
+
><Dialog.Header
|
|
175
|
+
><Dialog.Title>Remove {removing?.name}?</Dialog.Title><Dialog.Description
|
|
176
|
+
>They’ll be signed out and lose access immediately. Their API keys are revoked. Content they
|
|
177
|
+
edited stays.</Dialog.Description
|
|
178
|
+
></Dialog.Header
|
|
179
|
+
>{#if error}<p class="cms-error" role="alert">{error}</p>{/if}<Dialog.Footer
|
|
180
|
+
><Button variant="outline" onclick={() => (removing = null)}>Cancel</Button><Button
|
|
181
|
+
variant="destructive"
|
|
182
|
+
disabled={busy}
|
|
183
|
+
onclick={remove}>Remove user</Button
|
|
184
|
+
></Dialog.Footer
|
|
185
|
+
></Dialog.Content
|
|
186
|
+
></Dialog.Root
|
|
187
|
+
>
|
|
132
188
|
<Dialog.Root bind:open
|
|
133
189
|
><Dialog.Content portalProps={{ disabled: true }}
|
|
134
190
|
><Dialog.Header
|
|
135
191
|
><Dialog.Title>{inviting ? 'Invite a teammate' : 'Add a teammate'}</Dialog.Title
|
|
136
192
|
><Dialog.Description
|
|
137
193
|
>{inviting
|
|
138
|
-
? 'They
|
|
139
|
-
: '
|
|
194
|
+
? 'They’ll get a link to set up their account. Invitations expire after seven days.'
|
|
195
|
+
: 'They’ll change this temporary password at first sign-in.'}</Dialog.Description
|
|
140
196
|
></Dialog.Header
|
|
141
197
|
>
|
|
142
198
|
<form
|
package/dist/admin/client.d.ts
CHANGED
|
@@ -715,6 +715,8 @@ export declare class ApiError extends Error {
|
|
|
715
715
|
constructor(message: string, fields?: Record<string, string>);
|
|
716
716
|
}
|
|
717
717
|
export declare function api<T = unknown>(path: string, body: unknown): Promise<T>;
|
|
718
|
+
/** Copy text, falling back to a hidden textarea when the Clipboard API is unavailable. */
|
|
719
|
+
export declare function copyText(value: string): Promise<void>;
|
|
718
720
|
export declare const message: (e: unknown) => string;
|
|
719
721
|
export declare function assetUrl(asset: import('./types.js').Asset, _workerUrl: string): string;
|
|
720
722
|
export declare const date: (timestamp: number) => string;
|
package/dist/admin/client.js
CHANGED
|
@@ -22,6 +22,24 @@ export async function api(path, body) {
|
|
|
22
22
|
throw new ApiError(data.error ?? data.message ?? 'Request failed', data.fields);
|
|
23
23
|
return data;
|
|
24
24
|
}
|
|
25
|
+
/** Copy text, falling back to a hidden textarea when the Clipboard API is unavailable. */
|
|
26
|
+
export async function copyText(value) {
|
|
27
|
+
try {
|
|
28
|
+
if (navigator.clipboard)
|
|
29
|
+
return await navigator.clipboard.writeText(value);
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
// The Clipboard API needs a secure context and permission; fall through.
|
|
33
|
+
}
|
|
34
|
+
const area = document.createElement('textarea');
|
|
35
|
+
area.value = value;
|
|
36
|
+
area.style.position = 'fixed';
|
|
37
|
+
area.style.opacity = '0';
|
|
38
|
+
document.body.appendChild(area);
|
|
39
|
+
area.select();
|
|
40
|
+
document.execCommand('copy');
|
|
41
|
+
area.remove();
|
|
42
|
+
}
|
|
25
43
|
export const message = (e) => e instanceof Error ? e.message : 'Something went wrong. Please try again.';
|
|
26
44
|
export function assetUrl(asset, _workerUrl) {
|
|
27
45
|
const preview = asset.variants.find((v) => v.preset === 'sandcms-preview') ?? asset.variants[0];
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { DateFormatter, getLocalTimeZone, type DateValue } from '@internationalized/date';
|
|
3
|
+
import CalendarMonthSelect from './calendar-month-select.svelte';
|
|
4
|
+
import CalendarYearSelect from './calendar-year-select.svelte';
|
|
5
|
+
import type Calendar from './calendar.svelte';
|
|
6
|
+
import type { ComponentProps } from 'svelte';
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
captionLayout,
|
|
10
|
+
months,
|
|
11
|
+
monthFormat,
|
|
12
|
+
years,
|
|
13
|
+
yearFormat,
|
|
14
|
+
month,
|
|
15
|
+
locale,
|
|
16
|
+
placeholder = $bindable(),
|
|
17
|
+
monthIndex = 0
|
|
18
|
+
}: {
|
|
19
|
+
captionLayout: ComponentProps<typeof Calendar>['captionLayout'];
|
|
20
|
+
months: ComponentProps<typeof CalendarMonthSelect>['months'];
|
|
21
|
+
monthFormat: ComponentProps<typeof CalendarMonthSelect>['monthFormat'];
|
|
22
|
+
years: ComponentProps<typeof CalendarYearSelect>['years'];
|
|
23
|
+
yearFormat: ComponentProps<typeof CalendarYearSelect>['yearFormat'];
|
|
24
|
+
month: DateValue;
|
|
25
|
+
placeholder: DateValue | undefined;
|
|
26
|
+
locale: string;
|
|
27
|
+
monthIndex: number;
|
|
28
|
+
} = $props();
|
|
29
|
+
|
|
30
|
+
function formatYear(date: DateValue) {
|
|
31
|
+
const dateObj = date.toDate(getLocalTimeZone());
|
|
32
|
+
if (typeof yearFormat === 'function') return yearFormat(dateObj.getFullYear());
|
|
33
|
+
return new DateFormatter(locale, { year: yearFormat }).format(dateObj);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function formatMonth(date: DateValue) {
|
|
37
|
+
const dateObj = date.toDate(getLocalTimeZone());
|
|
38
|
+
if (typeof monthFormat === 'function') return monthFormat(dateObj.getMonth() + 1);
|
|
39
|
+
return new DateFormatter(locale, { month: monthFormat }).format(dateObj);
|
|
40
|
+
}
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
{#snippet MonthSelect()}
|
|
44
|
+
<CalendarMonthSelect
|
|
45
|
+
{months}
|
|
46
|
+
{monthFormat}
|
|
47
|
+
value={month.month}
|
|
48
|
+
onchange={(e) => {
|
|
49
|
+
if (!placeholder) return;
|
|
50
|
+
const v = Number.parseInt(e.currentTarget.value);
|
|
51
|
+
const newPlaceholder = placeholder.set({ month: v });
|
|
52
|
+
placeholder = newPlaceholder.subtract({ months: monthIndex });
|
|
53
|
+
}}
|
|
54
|
+
/>
|
|
55
|
+
{/snippet}
|
|
56
|
+
|
|
57
|
+
{#snippet YearSelect()}
|
|
58
|
+
<CalendarYearSelect {years} {yearFormat} value={month.year} />
|
|
59
|
+
{/snippet}
|
|
60
|
+
|
|
61
|
+
{#if captionLayout === 'dropdown'}
|
|
62
|
+
{@render MonthSelect()}
|
|
63
|
+
{@render YearSelect()}
|
|
64
|
+
{:else if captionLayout === 'dropdown-months'}
|
|
65
|
+
{@render MonthSelect()}
|
|
66
|
+
{#if placeholder}
|
|
67
|
+
{formatYear(placeholder)}
|
|
68
|
+
{/if}
|
|
69
|
+
{:else if captionLayout === 'dropdown-years'}
|
|
70
|
+
{#if placeholder}
|
|
71
|
+
{formatMonth(placeholder)}
|
|
72
|
+
{/if}
|
|
73
|
+
{@render YearSelect()}
|
|
74
|
+
{:else}
|
|
75
|
+
{formatMonth(month)} {formatYear(month)}
|
|
76
|
+
{/if}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type DateValue } from '@internationalized/date';
|
|
2
|
+
import CalendarMonthSelect from './calendar-month-select.svelte';
|
|
3
|
+
import CalendarYearSelect from './calendar-year-select.svelte';
|
|
4
|
+
import type Calendar from './calendar.svelte';
|
|
5
|
+
import type { ComponentProps } from 'svelte';
|
|
6
|
+
type $$ComponentProps = {
|
|
7
|
+
captionLayout: ComponentProps<typeof Calendar>['captionLayout'];
|
|
8
|
+
months: ComponentProps<typeof CalendarMonthSelect>['months'];
|
|
9
|
+
monthFormat: ComponentProps<typeof CalendarMonthSelect>['monthFormat'];
|
|
10
|
+
years: ComponentProps<typeof CalendarYearSelect>['years'];
|
|
11
|
+
yearFormat: ComponentProps<typeof CalendarYearSelect>['yearFormat'];
|
|
12
|
+
month: DateValue;
|
|
13
|
+
placeholder: DateValue | undefined;
|
|
14
|
+
locale: string;
|
|
15
|
+
monthIndex: number;
|
|
16
|
+
};
|
|
17
|
+
declare const CalendarCaption: import("svelte").Component<$$ComponentProps, {}, "placeholder">;
|
|
18
|
+
type CalendarCaption = ReturnType<typeof CalendarCaption>;
|
|
19
|
+
export default CalendarCaption;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Calendar as CalendarPrimitive } from 'bits-ui';
|
|
3
|
+
import { cn } from '../../../utils.js';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
ref = $bindable(null),
|
|
7
|
+
class: className,
|
|
8
|
+
...restProps
|
|
9
|
+
}: CalendarPrimitive.CellProps = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<CalendarPrimitive.Cell
|
|
13
|
+
bind:ref
|
|
14
|
+
class={cn(
|
|
15
|
+
'relative size-(--cell-size) p-0 text-center text-sm focus-within:z-20 [&:first-child[data-selected]_[data-bits-day]]:rounded-s-(--cell-radius) [&:last-child[data-selected]_[data-bits-day]]:rounded-e-(--cell-radius)',
|
|
16
|
+
className
|
|
17
|
+
)}
|
|
18
|
+
{...restProps}
|
|
19
|
+
/>
|