Vendor SharedCode locally
This commit is contained in:
1 parent
a8c51b8484
commit
6eb8f4ad60
88 files changed
+9708
-275
No files matched your search
@@ -0,0 +1,3 @@
|
||||
# `@gabriel20xx/web-ui`
|
||||
|
||||
Reusable Svelte 5 components for the shared application shell and account UI. See the workspace [README](../../README.md) for installation, publishing, and integration examples.
|
||||
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "@gabriel20xx/web-ui",
|
||||
"version": "0.1.1",
|
||||
"description": "Shared Svelte UI, layout, authentication, and account components for Gabriel20xx web projects.",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"files": [
|
||||
"src",
|
||||
"README.md"
|
||||
],
|
||||
"sideEffects": [
|
||||
"**/*.css"
|
||||
],
|
||||
"peerDependencies": {
|
||||
"svelte": "^5.0.0"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"@sveltejs/package": "^2.5.0",
|
||||
"@sveltejs/vite-plugin-svelte": "^6.0.0",
|
||||
"svelte": "^5.0.0",
|
||||
"svelte-check": "^4.0.0",
|
||||
"typescript": "^5.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"check": "svelte-check --tsconfig ./tsconfig.json",
|
||||
"package": "svelte-package"
|
||||
},
|
||||
"svelte": "./src/index.ts",
|
||||
"types": "./src/index.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./src/index.ts",
|
||||
"svelte": "./src/index.ts",
|
||||
"import": "./src/index.ts"
|
||||
},
|
||||
"./styles.css": "./src/lib/styles.css",
|
||||
"./package.json": "./package.json"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export * from './lib/index.js';
|
||||
@@ -0,0 +1,48 @@
|
||||
<script lang="ts">
|
||||
import type { Snippet } from 'svelte';
|
||||
import type { AboutLink } from '../types';
|
||||
import Dialog from './Dialog.svelte';
|
||||
|
||||
let {
|
||||
brand = 'Application',
|
||||
children,
|
||||
description = '',
|
||||
links = [],
|
||||
open = $bindable(false),
|
||||
version = ''
|
||||
}: {
|
||||
brand?: string;
|
||||
children?: Snippet;
|
||||
description?: string;
|
||||
links?: AboutLink[];
|
||||
open?: boolean;
|
||||
version?: string;
|
||||
} = $props();
|
||||
</script>
|
||||
|
||||
<Dialog bind:open title={`About ${brand}`}>
|
||||
<div class="sc-auth-brand">
|
||||
<span aria-hidden="true" class="sc-brand-mark">{brand.slice(0, 1).toUpperCase()}</span>
|
||||
<strong>{brand}</strong>
|
||||
</div>
|
||||
|
||||
{#if version}
|
||||
<p class="sc-muted">Version {version}</p>
|
||||
{/if}
|
||||
|
||||
{#if description}
|
||||
<p class="sc-muted">{description}</p>
|
||||
{/if}
|
||||
|
||||
{#if children}
|
||||
{@render children()}
|
||||
{/if}
|
||||
|
||||
{#if links.length > 0}
|
||||
<div class="sc-about-links">
|
||||
{#each links as link}
|
||||
<a href={link.href} rel="noreferrer" target="_blank">{link.label}</a>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</Dialog>
|
||||
@@ -0,0 +1,57 @@
|
||||
<script lang="ts">
|
||||
import type { Snippet } from 'svelte';
|
||||
import type { NavItem } from '../types';
|
||||
import Header from './Header.svelte';
|
||||
|
||||
let {
|
||||
brand = 'Application',
|
||||
brandHref = '/',
|
||||
children,
|
||||
class: className = '',
|
||||
currentPath = '',
|
||||
headerActions,
|
||||
navItems = [],
|
||||
onLogout,
|
||||
onNavigate,
|
||||
onProfile,
|
||||
onSettings,
|
||||
showSettings = true,
|
||||
theme = 'dark',
|
||||
username = ''
|
||||
}: {
|
||||
brand?: string;
|
||||
brandHref?: string;
|
||||
children?: Snippet;
|
||||
class?: string;
|
||||
currentPath?: string;
|
||||
headerActions?: Snippet;
|
||||
navItems?: NavItem[];
|
||||
onLogout?: () => void | Promise<void>;
|
||||
onNavigate?: (item: NavItem) => void;
|
||||
onProfile?: () => void;
|
||||
onSettings?: () => void;
|
||||
showSettings?: boolean;
|
||||
theme?: 'dark' | 'light' | 'system';
|
||||
username?: string;
|
||||
} = $props();
|
||||
</script>
|
||||
|
||||
<div class={`sc-root sc-app-shell ${className}`} data-theme={theme === 'system' ? undefined : theme}>
|
||||
<Header
|
||||
{brand}
|
||||
{brandHref}
|
||||
{currentPath}
|
||||
actions={headerActions}
|
||||
{navItems}
|
||||
{onLogout}
|
||||
{onNavigate}
|
||||
{onProfile}
|
||||
{onSettings}
|
||||
{showSettings}
|
||||
{username}
|
||||
/>
|
||||
|
||||
<main class="sc-main">
|
||||
{@render children?.()}
|
||||
</main>
|
||||
</div>
|
||||
@@ -0,0 +1,245 @@
|
||||
<script lang="ts">
|
||||
import type { Snippet } from 'svelte';
|
||||
import type {
|
||||
AuthLoginInput,
|
||||
AuthResetConfirm,
|
||||
AuthResetRequest,
|
||||
AuthSetupInput
|
||||
} from '../types';
|
||||
import Button from './Button.svelte';
|
||||
|
||||
let {
|
||||
brand = 'Application',
|
||||
children,
|
||||
error = '',
|
||||
loading = false,
|
||||
onLogin,
|
||||
onConfirmReset,
|
||||
onRequestReset,
|
||||
onSetup,
|
||||
showTotp = true,
|
||||
setupRequired = false,
|
||||
tagline = ''
|
||||
}: {
|
||||
brand?: string;
|
||||
children?: Snippet;
|
||||
error?: string;
|
||||
loading?: boolean;
|
||||
onLogin?: (input: AuthLoginInput) => void | Promise<void>;
|
||||
onConfirmReset?: AuthResetConfirm;
|
||||
onRequestReset?: AuthResetRequest;
|
||||
onSetup?: (input: AuthSetupInput) => void | Promise<void>;
|
||||
showTotp?: boolean;
|
||||
setupRequired?: boolean;
|
||||
tagline?: string;
|
||||
} = $props();
|
||||
|
||||
let username = $state('');
|
||||
let email = $state('');
|
||||
let identifier = $state('');
|
||||
let password = $state('');
|
||||
let totpToken = $state('');
|
||||
let confirmPassword = $state('');
|
||||
let submitError = $state('');
|
||||
let submitting = $state(false);
|
||||
let resetCode = $state('');
|
||||
let resetError = $state('');
|
||||
let resetOpen = $state(false);
|
||||
let resetting = $state(false);
|
||||
|
||||
async function submit(event: SubmitEvent): Promise<void> {
|
||||
event.preventDefault();
|
||||
submitError = '';
|
||||
|
||||
if (setupRequired && password !== confirmPassword) {
|
||||
submitError = 'Passwords do not match.';
|
||||
return;
|
||||
}
|
||||
|
||||
submitting = true;
|
||||
|
||||
try {
|
||||
if (setupRequired) {
|
||||
if (!onSetup) throw new Error('The application has not configured its setup handler.');
|
||||
await onSetup({ username, email, password });
|
||||
} else {
|
||||
if (!onLogin) throw new Error('The application has not configured its login handler.');
|
||||
await onLogin({ identifier, password, totpToken: totpToken.trim() });
|
||||
}
|
||||
} catch (caught) {
|
||||
submitError = caught instanceof Error ? caught.message : 'Authentication failed.';
|
||||
} finally {
|
||||
submitting = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function requestReset(): Promise<void> {
|
||||
resetError = '';
|
||||
resetCode = '';
|
||||
resetOpen = true;
|
||||
|
||||
try {
|
||||
if (!onRequestReset) throw new Error('The application has not configured its reset handler.');
|
||||
await onRequestReset();
|
||||
} catch (caught) {
|
||||
resetError = caught instanceof Error ? caught.message : 'Unable to request an account reset.';
|
||||
}
|
||||
}
|
||||
|
||||
async function confirmReset(): Promise<void> {
|
||||
resetError = '';
|
||||
const code = resetCode.trim();
|
||||
if (!code) {
|
||||
resetError = 'Enter the code printed in the server console.';
|
||||
return;
|
||||
}
|
||||
|
||||
resetting = true;
|
||||
try {
|
||||
if (!onConfirmReset) throw new Error('The application has not configured its reset handler.');
|
||||
await onConfirmReset(code);
|
||||
} catch (caught) {
|
||||
resetError = caught instanceof Error ? caught.message : 'Unable to reset the admin account.';
|
||||
} finally {
|
||||
resetting = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="sc-root sc-auth-page">
|
||||
<section aria-labelledby="sc-auth-title" class="sc-auth-card">
|
||||
<div class="sc-auth-brand">
|
||||
<span aria-hidden="true" class="sc-brand-mark">{brand.slice(0, 1).toUpperCase()}</span>
|
||||
<span>{brand}</span>
|
||||
</div>
|
||||
|
||||
<h1 id="sc-auth-title">{setupRequired ? 'Create your account' : 'Welcome back'}</h1>
|
||||
{#if tagline}
|
||||
<p class="sc-auth-subtitle">{tagline}</p>
|
||||
{/if}
|
||||
|
||||
<form class="sc-form sc-auth-form" onsubmit={submit}>
|
||||
{#if setupRequired}
|
||||
<label class="sc-field">
|
||||
<span class="sc-label">Username</span>
|
||||
<input
|
||||
autocomplete="username"
|
||||
class="sc-input"
|
||||
name="username"
|
||||
required
|
||||
type="text"
|
||||
bind:value={username}
|
||||
/>
|
||||
</label>
|
||||
|
||||
<label class="sc-field">
|
||||
<span class="sc-label">Email</span>
|
||||
<input
|
||||
autocomplete="email"
|
||||
class="sc-input"
|
||||
name="email"
|
||||
required
|
||||
type="email"
|
||||
bind:value={email}
|
||||
/>
|
||||
</label>
|
||||
{:else}
|
||||
<label class="sc-field">
|
||||
<span class="sc-label">Username or email</span>
|
||||
<input
|
||||
autocomplete="username"
|
||||
class="sc-input"
|
||||
name="identifier"
|
||||
required
|
||||
type="text"
|
||||
bind:value={identifier}
|
||||
/>
|
||||
</label>
|
||||
{/if}
|
||||
|
||||
<label class="sc-field">
|
||||
<span class="sc-label">Password</span>
|
||||
<input
|
||||
autocomplete={setupRequired ? 'new-password' : 'current-password'}
|
||||
class="sc-input"
|
||||
minlength="8"
|
||||
name="password"
|
||||
required
|
||||
type="password"
|
||||
bind:value={password}
|
||||
/>
|
||||
</label>
|
||||
|
||||
{#if showTotp && !setupRequired}
|
||||
<label class="sc-field">
|
||||
<span class="sc-label">Authenticator code <span class="sc-label-optional">(if enabled)</span></span>
|
||||
<input
|
||||
autocomplete="one-time-code"
|
||||
class="sc-input"
|
||||
inputmode="numeric"
|
||||
name="totpToken"
|
||||
type="text"
|
||||
bind:value={totpToken}
|
||||
/>
|
||||
</label>
|
||||
{/if}
|
||||
|
||||
{#if setupRequired}
|
||||
<label class="sc-field">
|
||||
<span class="sc-label">Confirm password</span>
|
||||
<input
|
||||
autocomplete="new-password"
|
||||
class="sc-input"
|
||||
minlength="8"
|
||||
name="confirmPassword"
|
||||
required
|
||||
type="password"
|
||||
bind:value={confirmPassword}
|
||||
/>
|
||||
</label>
|
||||
{/if}
|
||||
|
||||
{#if error || submitError}
|
||||
<p aria-live="polite" class="sc-error">{submitError || error}</p>
|
||||
{/if}
|
||||
|
||||
<Button disabled={loading || submitting} fullWidth size="lg" type="submit">
|
||||
{loading || submitting ? 'Please wait…' : setupRequired ? 'Create account' : 'Log in'}
|
||||
</Button>
|
||||
</form>
|
||||
|
||||
{#if children}
|
||||
<div class="sc-auth-extra">{@render children()}</div>
|
||||
{/if}
|
||||
|
||||
{#if !setupRequired && onRequestReset && onConfirmReset}
|
||||
{#if resetOpen}
|
||||
<div class="sc-auth-reset" aria-live="polite">
|
||||
<p class="sc-auth-reset-hint">A reset code has been printed to the server console.</p>
|
||||
<input
|
||||
aria-label="Reset code"
|
||||
autocomplete="off"
|
||||
class="sc-input"
|
||||
placeholder="Enter reset code"
|
||||
type="text"
|
||||
bind:value={resetCode}
|
||||
/>
|
||||
{#if resetError}<p class="sc-error">{resetError}</p>{/if}
|
||||
<Button
|
||||
disabled={resetting}
|
||||
fullWidth
|
||||
size="sm"
|
||||
variant="danger"
|
||||
onclick={() => void confirmReset()}
|
||||
>
|
||||
{resetting ? 'Resetting…' : 'Confirm reset'}
|
||||
</Button>
|
||||
</div>
|
||||
{:else}
|
||||
<button class="sc-auth-reset-link" type="button" onclick={() => void requestReset()}>
|
||||
Reset admin account
|
||||
</button>
|
||||
{/if}
|
||||
{/if}
|
||||
</section>
|
||||
</div>
|
||||
@@ -0,0 +1,19 @@
|
||||
<script lang="ts">
|
||||
import type { Snippet } from 'svelte';
|
||||
|
||||
type BadgeVariant = 'default' | 'success' | 'warning' | 'danger';
|
||||
|
||||
let {
|
||||
children,
|
||||
class: className = '',
|
||||
variant = 'default'
|
||||
}: {
|
||||
children?: Snippet;
|
||||
class?: string;
|
||||
variant?: BadgeVariant;
|
||||
} = $props();
|
||||
</script>
|
||||
|
||||
<span class={`sc-badge ${className}`} data-variant={variant}>
|
||||
{@render children?.()}
|
||||
</span>
|
||||
@@ -0,0 +1,35 @@
|
||||
<script lang="ts">
|
||||
import type { Snippet } from 'svelte';
|
||||
|
||||
type ButtonVariant = 'primary' | 'secondary' | 'ghost' | 'danger';
|
||||
type ButtonSize = 'sm' | 'md' | 'lg';
|
||||
|
||||
let {
|
||||
children,
|
||||
class: className = '',
|
||||
disabled = false,
|
||||
fullWidth = false,
|
||||
onclick,
|
||||
size = 'md',
|
||||
type = 'button',
|
||||
variant = 'primary'
|
||||
}: {
|
||||
children?: Snippet;
|
||||
class?: string;
|
||||
disabled?: boolean;
|
||||
fullWidth?: boolean;
|
||||
onclick?: (event: MouseEvent) => void;
|
||||
size?: ButtonSize;
|
||||
type?: 'button' | 'submit' | 'reset';
|
||||
variant?: ButtonVariant;
|
||||
} = $props();
|
||||
</script>
|
||||
|
||||
<button
|
||||
class={`sc-button sc-button-${variant} sc-button-${size}${fullWidth ? ' sc-button-full' : ''} ${className}`}
|
||||
{disabled}
|
||||
{onclick}
|
||||
{type}
|
||||
>
|
||||
{@render children?.()}
|
||||
</button>
|
||||
@@ -0,0 +1,15 @@
|
||||
<script lang="ts">
|
||||
import type { Snippet } from 'svelte';
|
||||
|
||||
let {
|
||||
children,
|
||||
class: className = ''
|
||||
}: {
|
||||
children?: Snippet;
|
||||
class?: string;
|
||||
} = $props();
|
||||
</script>
|
||||
|
||||
<section class={`sc-card ${className}`}>
|
||||
{@render children?.()}
|
||||
</section>
|
||||
@@ -0,0 +1,54 @@
|
||||
<script lang="ts">
|
||||
import type { Snippet } from 'svelte';
|
||||
|
||||
let {
|
||||
children,
|
||||
description = '',
|
||||
footer,
|
||||
open = $bindable(false),
|
||||
title
|
||||
}: {
|
||||
children?: Snippet;
|
||||
description?: string;
|
||||
footer?: Snippet;
|
||||
open?: boolean;
|
||||
title: string;
|
||||
} = $props();
|
||||
|
||||
function close(): void {
|
||||
open = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if open}
|
||||
<div
|
||||
aria-label={title}
|
||||
class="sc-dialog-backdrop"
|
||||
role="presentation"
|
||||
onclick={(event) => {
|
||||
if (event.target === event.currentTarget) close();
|
||||
}}
|
||||
>
|
||||
<section aria-modal="true" class="sc-dialog" role="dialog">
|
||||
<div class="sc-dialog-header">
|
||||
<div>
|
||||
<h2 class="sc-dialog-title">{title}</h2>
|
||||
{#if description}
|
||||
<p class="sc-dialog-description">{description}</p>
|
||||
{/if}
|
||||
</div>
|
||||
<button aria-label="Close" class="sc-dialog-close" type="button" onclick={close}>×</button>
|
||||
</div>
|
||||
|
||||
<div class="sc-dialog-body">
|
||||
{@render children?.()}
|
||||
</div>
|
||||
|
||||
{#if footer}
|
||||
<div class="sc-dialog-footer">
|
||||
{@render footer()}
|
||||
</div>
|
||||
{/if}
|
||||
</section>
|
||||
</div>
|
||||
{/if}
|
||||
@@ -0,0 +1,93 @@
|
||||
<script lang="ts">
|
||||
import type { Snippet } from 'svelte';
|
||||
import type { NavItem } from '../types';
|
||||
|
||||
let {
|
||||
brand = 'Application',
|
||||
brandHref = '/',
|
||||
currentPath = '',
|
||||
navItems = [],
|
||||
actions,
|
||||
onLogout,
|
||||
onNavigate,
|
||||
onProfile,
|
||||
onSettings,
|
||||
showSettings = true,
|
||||
username = ''
|
||||
}: {
|
||||
brand?: string;
|
||||
brandHref?: string;
|
||||
currentPath?: string;
|
||||
navItems?: NavItem[];
|
||||
actions?: Snippet;
|
||||
onLogout?: () => void | Promise<void>;
|
||||
onNavigate?: (item: NavItem) => void;
|
||||
onProfile?: () => void;
|
||||
onSettings?: () => void;
|
||||
showSettings?: boolean;
|
||||
username?: string;
|
||||
} = $props();
|
||||
|
||||
let navOpen = $state(false);
|
||||
|
||||
function isActive(item: NavItem): boolean {
|
||||
return item.href === '/'
|
||||
? currentPath === '/'
|
||||
: currentPath === item.href || currentPath.startsWith(`${item.href}/`);
|
||||
}
|
||||
</script>
|
||||
|
||||
<header class="sc-header">
|
||||
<a class="sc-brand" href={brandHref} onclick={() => (navOpen = false)}>
|
||||
<span aria-hidden="true" class="sc-brand-mark">{brand.slice(0, 1).toUpperCase()}</span>
|
||||
<span>{brand}</span>
|
||||
</a>
|
||||
|
||||
<nav aria-label="Primary navigation" class="sc-nav" data-open={navOpen}>
|
||||
{#each navItems as item}
|
||||
<a
|
||||
aria-current={isActive(item) ? 'page' : undefined}
|
||||
class="sc-nav-link"
|
||||
data-active={isActive(item)}
|
||||
href={item.href}
|
||||
onclick={(event) => {
|
||||
if (onNavigate) {
|
||||
event.preventDefault();
|
||||
onNavigate(item);
|
||||
}
|
||||
navOpen = false;
|
||||
}}
|
||||
>
|
||||
{item.label}
|
||||
</a>
|
||||
{/each}
|
||||
</nav>
|
||||
|
||||
<div class="sc-header-actions">
|
||||
{#if actions}{@render actions()}{/if}
|
||||
|
||||
{#if showSettings && onSettings}
|
||||
<button aria-label="Open settings" class="sc-icon-button" type="button" onclick={onSettings}>⚙</button>
|
||||
{/if}
|
||||
|
||||
{#if username && onProfile}
|
||||
<button class="sc-profile-button" type="button" onclick={onProfile}>{username}</button>
|
||||
{/if}
|
||||
|
||||
{#if onLogout}
|
||||
<button class="sc-button sc-button-ghost sc-button-sm" type="button" onclick={() => void onLogout?.()}>
|
||||
Log out
|
||||
</button>
|
||||
{/if}
|
||||
|
||||
<button
|
||||
aria-expanded={navOpen}
|
||||
aria-label={navOpen ? 'Close navigation menu' : 'Open navigation menu'}
|
||||
class="sc-icon-button sc-mobile-menu-button"
|
||||
type="button"
|
||||
onclick={() => (navOpen = !navOpen)}
|
||||
>
|
||||
{navOpen ? '×' : '☰'}
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
@@ -0,0 +1,35 @@
|
||||
<script lang="ts">
|
||||
import type { Snippet } from 'svelte';
|
||||
|
||||
let {
|
||||
actions,
|
||||
children,
|
||||
description = '',
|
||||
subtitle = '',
|
||||
title
|
||||
}: {
|
||||
actions?: Snippet;
|
||||
children?: Snippet;
|
||||
description?: string;
|
||||
subtitle?: string;
|
||||
title: string;
|
||||
} = $props();
|
||||
|
||||
const supportingText = $derived(description || subtitle);
|
||||
</script>
|
||||
|
||||
<div class="sc-page-header">
|
||||
<div>
|
||||
<h1>{title}</h1>
|
||||
{#if supportingText}
|
||||
<p>{supportingText}</p>
|
||||
{/if}
|
||||
{@render children?.()}
|
||||
</div>
|
||||
|
||||
{#if actions}
|
||||
<div>
|
||||
{@render actions()}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -0,0 +1,170 @@
|
||||
<script lang="ts">
|
||||
import type {
|
||||
ProfileUpdateInput,
|
||||
TotpSetupRequest,
|
||||
TotpStatusRequest,
|
||||
TotpTokenAction,
|
||||
UserCreateRequest,
|
||||
UserDeleteRequest,
|
||||
UserId,
|
||||
UserListRequest,
|
||||
UserRole,
|
||||
UserUpdateRequest
|
||||
} from '../types';
|
||||
import Button from './Button.svelte';
|
||||
import Dialog from './Dialog.svelte';
|
||||
import TotpSettings from './TotpSettings.svelte';
|
||||
import UserManagement from './UserManagement.svelte';
|
||||
|
||||
let {
|
||||
currentEmail = '',
|
||||
currentRole = 'user',
|
||||
currentUserId,
|
||||
onCreateUser,
|
||||
onDeleteUser,
|
||||
onListUsers,
|
||||
currentUsername = '',
|
||||
onSave,
|
||||
onTotpDisable,
|
||||
onTotpEnable,
|
||||
onTotpSetup,
|
||||
onTotpStatus,
|
||||
onUpdateUser,
|
||||
totpEnabled = false,
|
||||
open = $bindable(false)
|
||||
}: {
|
||||
currentEmail?: string;
|
||||
currentRole?: UserRole;
|
||||
currentUserId?: UserId;
|
||||
onCreateUser?: UserCreateRequest;
|
||||
onDeleteUser?: UserDeleteRequest;
|
||||
onListUsers?: UserListRequest;
|
||||
currentUsername?: string;
|
||||
onSave?: (input: ProfileUpdateInput) => void | Promise<void>;
|
||||
onTotpDisable?: TotpTokenAction;
|
||||
onTotpEnable?: TotpTokenAction;
|
||||
onTotpSetup?: TotpSetupRequest;
|
||||
onTotpStatus?: TotpStatusRequest;
|
||||
onUpdateUser?: UserUpdateRequest;
|
||||
totpEnabled?: boolean;
|
||||
open?: boolean;
|
||||
} = $props();
|
||||
|
||||
let username = $state('');
|
||||
let email = $state('');
|
||||
let password = $state('');
|
||||
let confirmPassword = $state('');
|
||||
let error = $state('');
|
||||
let saving = $state(false);
|
||||
|
||||
$effect(() => {
|
||||
if (open) {
|
||||
username = currentUsername;
|
||||
email = currentEmail;
|
||||
password = '';
|
||||
confirmPassword = '';
|
||||
error = '';
|
||||
}
|
||||
});
|
||||
|
||||
async function save(event: SubmitEvent): Promise<void> {
|
||||
event.preventDefault();
|
||||
error = '';
|
||||
|
||||
if (password && password !== confirmPassword) {
|
||||
error = 'Passwords do not match.';
|
||||
return;
|
||||
}
|
||||
|
||||
if (!onSave) {
|
||||
error = 'The application has not configured its profile update handler.';
|
||||
return;
|
||||
}
|
||||
|
||||
saving = true;
|
||||
try {
|
||||
await onSave({ username, email, password: password || undefined });
|
||||
open = false;
|
||||
} catch (caught) {
|
||||
error = caught instanceof Error ? caught.message : 'Profile update failed.';
|
||||
} finally {
|
||||
saving = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<Dialog bind:open title="Profile">
|
||||
<div class="sc-profile-summary">
|
||||
<strong>{currentUsername || 'Your profile'}</strong>
|
||||
{#if currentEmail}
|
||||
<span>{currentEmail}</span>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<form class="sc-form" onsubmit={save}>
|
||||
<label class="sc-field">
|
||||
<span class="sc-label">Username</span>
|
||||
<input autocomplete="username" class="sc-input" required type="text" bind:value={username} />
|
||||
</label>
|
||||
|
||||
<label class="sc-field">
|
||||
<span class="sc-label">Email</span>
|
||||
<input autocomplete="email" class="sc-input" required type="email" bind:value={email} />
|
||||
</label>
|
||||
|
||||
<label class="sc-field">
|
||||
<span class="sc-label">New password</span>
|
||||
<input
|
||||
autocomplete="new-password"
|
||||
class="sc-input"
|
||||
minlength="8"
|
||||
placeholder="Leave blank to keep the current password"
|
||||
type="password"
|
||||
bind:value={password}
|
||||
/>
|
||||
</label>
|
||||
|
||||
{#if password}
|
||||
<label class="sc-field">
|
||||
<span class="sc-label">Confirm new password</span>
|
||||
<input
|
||||
autocomplete="new-password"
|
||||
class="sc-input"
|
||||
minlength="8"
|
||||
required
|
||||
type="password"
|
||||
bind:value={confirmPassword}
|
||||
/>
|
||||
</label>
|
||||
{/if}
|
||||
|
||||
{#if error}
|
||||
<p aria-live="polite" class="sc-error">{error}</p>
|
||||
{/if}
|
||||
|
||||
<div class="sc-form-actions">
|
||||
<Button variant="secondary" type="button" onclick={() => (open = false)}>Cancel</Button>
|
||||
<Button disabled={saving} type="submit">{saving ? 'Saving…' : 'Save changes'}</Button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
{#if onTotpSetup && onTotpEnable && onTotpDisable}
|
||||
<TotpSettings
|
||||
{open}
|
||||
onDisable={onTotpDisable}
|
||||
onEnable={onTotpEnable}
|
||||
onSetup={onTotpSetup}
|
||||
onStatus={onTotpStatus}
|
||||
enabled={totpEnabled}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
<UserManagement
|
||||
currentRole={currentRole}
|
||||
currentUserId={currentUserId}
|
||||
onCreate={onCreateUser}
|
||||
onDelete={onDeleteUser}
|
||||
onList={onListUsers}
|
||||
onUpdate={onUpdateUser}
|
||||
/>
|
||||
</Dialog>
|
||||
@@ -0,0 +1,53 @@
|
||||
<script lang="ts">
|
||||
import type { Snippet } from 'svelte';
|
||||
import type {
|
||||
UserCreateRequest,
|
||||
UserDeleteRequest,
|
||||
UserId,
|
||||
UserListRequest,
|
||||
UserRole,
|
||||
UserUpdateRequest
|
||||
} from '../types';
|
||||
import Dialog from './Dialog.svelte';
|
||||
import UserManagement from './UserManagement.svelte';
|
||||
|
||||
let {
|
||||
children,
|
||||
description = '',
|
||||
currentRole = 'user',
|
||||
currentUserId,
|
||||
onCreateUser,
|
||||
onDeleteUser,
|
||||
onListUsers,
|
||||
onUpdateUser,
|
||||
open = $bindable(false),
|
||||
title = 'Settings'
|
||||
}: {
|
||||
children?: Snippet;
|
||||
description?: string;
|
||||
currentRole?: UserRole;
|
||||
currentUserId?: UserId;
|
||||
onCreateUser?: UserCreateRequest;
|
||||
onDeleteUser?: UserDeleteRequest;
|
||||
onListUsers?: UserListRequest;
|
||||
onUpdateUser?: UserUpdateRequest;
|
||||
open?: boolean;
|
||||
title?: string;
|
||||
} = $props();
|
||||
</script>
|
||||
|
||||
<Dialog bind:open {description} {title}>
|
||||
{#if children}
|
||||
{@render children()}
|
||||
{:else}
|
||||
<p class="sc-muted">No settings have been configured for this application yet.</p>
|
||||
{/if}
|
||||
<UserManagement
|
||||
currentRole={currentRole}
|
||||
currentUserId={currentUserId}
|
||||
onCreate={onCreateUser}
|
||||
onDelete={onDeleteUser}
|
||||
onList={onListUsers}
|
||||
onUpdate={onUpdateUser}
|
||||
/>
|
||||
</Dialog>
|
||||
@@ -0,0 +1,167 @@
|
||||
<script lang="ts">
|
||||
import type {
|
||||
TotpSetupRequest,
|
||||
TotpStatusRequest,
|
||||
TotpTokenAction,
|
||||
TotpSetupResponse
|
||||
} from '../types';
|
||||
import Button from './Button.svelte';
|
||||
|
||||
let {
|
||||
enabled = false,
|
||||
onDisable,
|
||||
onEnable,
|
||||
onSetup,
|
||||
onStatus,
|
||||
open = false
|
||||
}: {
|
||||
enabled?: boolean;
|
||||
onDisable?: TotpTokenAction;
|
||||
onEnable?: TotpTokenAction;
|
||||
onSetup?: TotpSetupRequest;
|
||||
onStatus?: TotpStatusRequest;
|
||||
open?: boolean;
|
||||
} = $props();
|
||||
|
||||
let currentEnabled = $state(false);
|
||||
let setup = $state<TotpSetupResponse | null>(null);
|
||||
let token = $state('');
|
||||
let error = $state('');
|
||||
let busy = $state(false);
|
||||
|
||||
$effect(() => {
|
||||
currentEnabled = enabled;
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
if (!open || !onStatus) return;
|
||||
void refreshStatus();
|
||||
});
|
||||
|
||||
async function refreshStatus(): Promise<void> {
|
||||
try {
|
||||
currentEnabled = await onStatus?.() ?? currentEnabled;
|
||||
} catch {
|
||||
// The explicit setup controls remain usable if status is unavailable.
|
||||
}
|
||||
}
|
||||
|
||||
async function beginSetup(): Promise<void> {
|
||||
if (!onSetup) return;
|
||||
error = '';
|
||||
busy = true;
|
||||
try {
|
||||
setup = await onSetup();
|
||||
token = '';
|
||||
} catch (caught) {
|
||||
error = caught instanceof Error ? caught.message : 'Unable to start two-factor setup.';
|
||||
} finally {
|
||||
busy = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function confirmEnable(): Promise<void> {
|
||||
const normalized = token.trim();
|
||||
if (!/^\d{6}$/.test(normalized)) {
|
||||
error = 'Enter the six-digit code from your authenticator app.';
|
||||
return;
|
||||
}
|
||||
if (!onEnable) return;
|
||||
error = '';
|
||||
busy = true;
|
||||
try {
|
||||
await onEnable(normalized);
|
||||
currentEnabled = true;
|
||||
setup = null;
|
||||
token = '';
|
||||
} catch (caught) {
|
||||
error = caught instanceof Error ? caught.message : 'Unable to enable two-factor authentication.';
|
||||
} finally {
|
||||
busy = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function disable(): Promise<void> {
|
||||
const normalized = token.trim();
|
||||
if (!/^\d{6}$/.test(normalized)) {
|
||||
error = 'Enter the current six-digit authenticator code.';
|
||||
return;
|
||||
}
|
||||
if (!onDisable) return;
|
||||
error = '';
|
||||
busy = true;
|
||||
try {
|
||||
await onDisable(normalized);
|
||||
currentEnabled = false;
|
||||
token = '';
|
||||
} catch (caught) {
|
||||
error = caught instanceof Error ? caught.message : 'Unable to disable two-factor authentication.';
|
||||
} finally {
|
||||
busy = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<section class="sc-totp-settings" aria-labelledby="sc-totp-title">
|
||||
<div class="sc-totp-heading">
|
||||
<div>
|
||||
<h3 id="sc-totp-title">Two-factor authentication</h3>
|
||||
<p class="sc-muted">Protect sign-in with a time-based authenticator code.</p>
|
||||
</div>
|
||||
<span class:sc-totp-enabled={currentEnabled} class="sc-totp-status">
|
||||
{currentEnabled ? 'Enabled' : 'Optional'}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{#if currentEnabled}
|
||||
<label class="sc-field">
|
||||
<span class="sc-label">Current authenticator code</span>
|
||||
<input
|
||||
autocomplete="one-time-code"
|
||||
class="sc-input"
|
||||
inputmode="numeric"
|
||||
maxlength="6"
|
||||
pattern="[0-9]{6}"
|
||||
placeholder="123456"
|
||||
type="text"
|
||||
bind:value={token}
|
||||
/>
|
||||
</label>
|
||||
<Button disabled={busy} variant="danger" onclick={() => void disable()}>
|
||||
{busy ? 'Disabling…' : 'Disable two-factor authentication'}
|
||||
</Button>
|
||||
{:else if setup}
|
||||
<div class="sc-totp-secret">
|
||||
<p>Scan this address in your authenticator app, or enter the secret manually.</p>
|
||||
<code>{setup.otpauthUrl}</code>
|
||||
<p><span class="sc-label">Manual secret:</span> <code>{setup.secret}</code></p>
|
||||
</div>
|
||||
<label class="sc-field">
|
||||
<span class="sc-label">Authenticator code</span>
|
||||
<input
|
||||
autocomplete="one-time-code"
|
||||
class="sc-input"
|
||||
inputmode="numeric"
|
||||
maxlength="6"
|
||||
pattern="[0-9]{6}"
|
||||
placeholder="123456"
|
||||
type="text"
|
||||
bind:value={token}
|
||||
/>
|
||||
</label>
|
||||
<div class="sc-form-actions">
|
||||
<Button disabled={busy} variant="secondary" onclick={() => (setup = null)}>Cancel</Button>
|
||||
<Button disabled={busy} onclick={() => void confirmEnable()}>
|
||||
{busy ? 'Enabling…' : 'Enable two-factor authentication'}
|
||||
</Button>
|
||||
</div>
|
||||
{:else}
|
||||
<Button disabled={busy} onclick={() => void beginSetup()}>
|
||||
{busy ? 'Preparing…' : 'Set up authenticator'}
|
||||
</Button>
|
||||
{/if}
|
||||
|
||||
{#if error}
|
||||
<p aria-live="polite" class="sc-error">{error}</p>
|
||||
{/if}
|
||||
</section>
|
||||
@@ -0,0 +1,196 @@
|
||||
<script lang="ts">
|
||||
import type {
|
||||
ManagedUser,
|
||||
UserCreateInput,
|
||||
UserCreateRequest,
|
||||
UserDeleteRequest,
|
||||
UserId,
|
||||
UserListRequest,
|
||||
UserRole,
|
||||
UserUpdateInput,
|
||||
UserUpdateRequest
|
||||
} from '../types';
|
||||
import Button from './Button.svelte';
|
||||
|
||||
let {
|
||||
currentRole = 'user',
|
||||
currentUserId,
|
||||
onCreate,
|
||||
onDelete,
|
||||
onList,
|
||||
onUpdate
|
||||
}: {
|
||||
currentRole?: UserRole;
|
||||
currentUserId?: UserId;
|
||||
onCreate?: UserCreateRequest;
|
||||
onDelete?: UserDeleteRequest;
|
||||
onList?: UserListRequest;
|
||||
onUpdate?: UserUpdateRequest;
|
||||
} = $props();
|
||||
|
||||
let users = $state<ManagedUser[]>([]);
|
||||
let loading = $state(false);
|
||||
let saving = $state(false);
|
||||
let error = $state('');
|
||||
let notice = $state('');
|
||||
let loaded = $state(false);
|
||||
let newUser = $state<UserCreateInput>({ username: '', email: '', password: '', role: 'user' });
|
||||
let editingId = $state<UserId | null>(null);
|
||||
let editUser = $state<UserUpdateInput>({});
|
||||
|
||||
const canManage = $derived(currentRole === 'admin' || currentRole === 'superadmin');
|
||||
const canAssignAdmin = $derived(currentRole === 'superadmin');
|
||||
|
||||
function roleForForm(role: UserRole | undefined): UserRole {
|
||||
return canAssignAdmin && role ? role : 'user';
|
||||
}
|
||||
|
||||
async function loadUsers(): Promise<void> {
|
||||
if (!onList || !canManage) return;
|
||||
loading = true;
|
||||
error = '';
|
||||
try {
|
||||
users = await onList();
|
||||
loaded = true;
|
||||
} catch (caught) {
|
||||
error = caught instanceof Error ? caught.message : 'Unable to load users.';
|
||||
} finally {
|
||||
loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
if (canManage && onList && !loaded) void loadUsers();
|
||||
});
|
||||
|
||||
async function createUser(event: SubmitEvent): Promise<void> {
|
||||
event.preventDefault();
|
||||
if (!onCreate) return;
|
||||
saving = true;
|
||||
error = '';
|
||||
notice = '';
|
||||
try {
|
||||
await onCreate({ ...newUser, role: roleForForm(newUser.role) });
|
||||
newUser = { username: '', email: '', password: '', role: 'user' };
|
||||
notice = 'User created.';
|
||||
await loadUsers();
|
||||
} catch (caught) {
|
||||
error = caught instanceof Error ? caught.message : 'Unable to create user.';
|
||||
} finally {
|
||||
saving = false;
|
||||
}
|
||||
}
|
||||
|
||||
function startEditing(user: ManagedUser): void {
|
||||
editingId = user.id;
|
||||
editUser = { username: user.username, email: user.email, role: roleForForm(user.role) };
|
||||
error = '';
|
||||
notice = '';
|
||||
}
|
||||
|
||||
function stopEditing(): void {
|
||||
editingId = null;
|
||||
editUser = {};
|
||||
}
|
||||
|
||||
async function updateUser(event: SubmitEvent): Promise<void> {
|
||||
event.preventDefault();
|
||||
if (!onUpdate || editingId === null) return;
|
||||
saving = true;
|
||||
error = '';
|
||||
notice = '';
|
||||
try {
|
||||
const input = { ...editUser, role: roleForForm(editUser.role) };
|
||||
if (!input.password) delete input.password;
|
||||
await onUpdate(editingId, input);
|
||||
stopEditing();
|
||||
notice = 'User updated.';
|
||||
await loadUsers();
|
||||
} catch (caught) {
|
||||
error = caught instanceof Error ? caught.message : 'Unable to update user.';
|
||||
} finally {
|
||||
saving = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteUser(user: ManagedUser): Promise<void> {
|
||||
if (!onDelete || String(user.id) === String(currentUserId)) return;
|
||||
if (!window.confirm(`Delete user ${user.username}?`)) return;
|
||||
saving = true;
|
||||
error = '';
|
||||
notice = '';
|
||||
try {
|
||||
await onDelete(user.id);
|
||||
notice = 'User deleted.';
|
||||
await loadUsers();
|
||||
} catch (caught) {
|
||||
error = caught instanceof Error ? caught.message : 'Unable to delete user.';
|
||||
} finally {
|
||||
saving = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if canManage && onList && onCreate && onUpdate && onDelete}
|
||||
<section class="sc-user-management" aria-labelledby="sc-user-management-title">
|
||||
<div class="sc-user-management-header">
|
||||
<div>
|
||||
<h3 id="sc-user-management-title">User management</h3>
|
||||
<p class="sc-muted">Add, edit, or remove accounts for this project.</p>
|
||||
</div>
|
||||
<Button disabled={loading || saving} size="sm" type="button" variant="secondary" onclick={() => void loadUsers()}>
|
||||
Refresh
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<form class="sc-user-form" onsubmit={createUser}>
|
||||
<strong>Add user</strong>
|
||||
<div class="sc-user-grid">
|
||||
<input aria-label="New username" class="sc-input" placeholder="Username" required type="text" bind:value={newUser.username} />
|
||||
<input aria-label="New email" class="sc-input" placeholder="Email" required type="email" bind:value={newUser.email} />
|
||||
<input aria-label="New password" class="sc-input" minlength="8" placeholder="Password" required type="password" bind:value={newUser.password} />
|
||||
<select aria-label="New role" class="sc-input" disabled={!canAssignAdmin} bind:value={newUser.role}>
|
||||
<option value="user">User</option>
|
||||
{#if canAssignAdmin}<option value="admin">Admin</option>{/if}
|
||||
</select>
|
||||
</div>
|
||||
<div class="sc-form-actions"><Button disabled={saving} type="submit">Add user</Button></div>
|
||||
</form>
|
||||
|
||||
{#if error}<p aria-live="polite" class="sc-error">{error}</p>{/if}
|
||||
{#if notice}<p aria-live="polite" class="sc-success">{notice}</p>{/if}
|
||||
|
||||
{#if loading && users.length === 0}
|
||||
<p class="sc-muted">Loading users...</p>
|
||||
{:else if users.length === 0}
|
||||
<p class="sc-muted">No users found.</p>
|
||||
{:else}
|
||||
<div class="sc-user-list">
|
||||
{#each users as user (user.id)}
|
||||
{#if String(editingId) === String(user.id)}
|
||||
<form class="sc-user-row sc-user-edit-row" onsubmit={updateUser}>
|
||||
<input aria-label="Username" class="sc-input" required type="text" bind:value={editUser.username} />
|
||||
<input aria-label="Email" class="sc-input" required type="email" bind:value={editUser.email} />
|
||||
<input aria-label="New password" class="sc-input" minlength="8" placeholder="Keep password" type="password" bind:value={editUser.password} />
|
||||
<select aria-label="Role" class="sc-input" disabled={!canAssignAdmin || user.role === 'superadmin'} bind:value={editUser.role}>
|
||||
<option value="user">User</option>
|
||||
{#if canAssignAdmin}<option value="admin">Admin</option>{/if}
|
||||
{#if user.role === 'superadmin'}<option value="superadmin">Superadmin</option>{/if}
|
||||
</select>
|
||||
<div class="sc-user-actions"><Button disabled={saving} size="sm" type="submit">Save</Button><Button disabled={saving} size="sm" type="button" variant="secondary" onclick={stopEditing}>Cancel</Button></div>
|
||||
</form>
|
||||
{:else}
|
||||
<div class="sc-user-row">
|
||||
<div><strong>{user.username}</strong><span>{user.email}</span></div>
|
||||
<span class="sc-user-role">{user.role}</span>
|
||||
<div class="sc-user-actions">
|
||||
<Button disabled={saving} size="sm" type="button" variant="secondary" onclick={() => startEditing(user)}>Edit</Button>
|
||||
<Button disabled={saving || String(user.id) === String(currentUserId) || user.role === 'superadmin'} size="sm" type="button" variant="danger" onclick={() => void deleteUser(user)}>Remove</Button>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</section>
|
||||
{/if}
|
||||
@@ -0,0 +1,37 @@
|
||||
export { default as AboutDialog } from './components/AboutDialog.svelte';
|
||||
export { default as AppShell } from './components/AppShell.svelte';
|
||||
export { default as AuthPage } from './components/AuthPage.svelte';
|
||||
export { default as Badge } from './components/Badge.svelte';
|
||||
export { default as Button } from './components/Button.svelte';
|
||||
export { default as Card } from './components/Card.svelte';
|
||||
export { default as Dialog } from './components/Dialog.svelte';
|
||||
export { default as Header } from './components/Header.svelte';
|
||||
export { default as PageHeader } from './components/PageHeader.svelte';
|
||||
export { default as ProfileDialog } from './components/ProfileDialog.svelte';
|
||||
export { default as SettingsDialog } from './components/SettingsDialog.svelte';
|
||||
export { default as TotpSettings } from './components/TotpSettings.svelte';
|
||||
export { default as UserManagement } from './components/UserManagement.svelte';
|
||||
export type {
|
||||
AboutLink,
|
||||
AsyncAction,
|
||||
AuthLoginInput,
|
||||
AuthResetConfirm,
|
||||
AuthResetRequest,
|
||||
AuthSetupInput,
|
||||
ContentSnippet,
|
||||
NavItem,
|
||||
ProfileUpdateInput,
|
||||
ManagedUser,
|
||||
UserCreateInput,
|
||||
UserCreateRequest,
|
||||
UserDeleteRequest,
|
||||
UserId,
|
||||
UserListRequest,
|
||||
UserRole,
|
||||
UserUpdateInput,
|
||||
UserUpdateRequest,
|
||||
TotpSetupRequest,
|
||||
TotpSetupResponse,
|
||||
TotpStatusRequest,
|
||||
TotpTokenAction
|
||||
} from './types';
|
||||
@@ -0,0 +1,776 @@
|
||||
@import '../../../design-tokens/theme.css';
|
||||
|
||||
:where(.sc-root, .sc-root *) {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.sc-root {
|
||||
min-height: 100%;
|
||||
color: var(--sc-fg);
|
||||
background: var(--sc-bg);
|
||||
font-family: var(--sc-font-sans);
|
||||
}
|
||||
|
||||
.sc-root button,
|
||||
.sc-root input,
|
||||
.sc-root textarea,
|
||||
.sc-root select {
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
.sc-root a {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.sc-app-shell {
|
||||
min-height: 100vh;
|
||||
color: var(--sc-fg);
|
||||
background: var(--sc-bg);
|
||||
}
|
||||
|
||||
.sc-main {
|
||||
width: min(100% - 2rem, 90rem);
|
||||
margin: 0 auto;
|
||||
padding: 2rem 0 3rem;
|
||||
}
|
||||
|
||||
.sc-header {
|
||||
position: sticky;
|
||||
z-index: 20;
|
||||
top: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1.25rem;
|
||||
min-height: 4rem;
|
||||
padding: 0 1rem;
|
||||
color: var(--sc-fg);
|
||||
background: color-mix(in srgb, var(--sc-surface) 92%, transparent);
|
||||
border-bottom: 1px solid var(--sc-border);
|
||||
backdrop-filter: blur(14px);
|
||||
}
|
||||
|
||||
.sc-brand {
|
||||
display: inline-flex;
|
||||
flex: 0 0 auto;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
color: var(--sc-fg);
|
||||
font-size: 1rem;
|
||||
font-weight: 750;
|
||||
text-decoration: none;
|
||||
letter-spacing: -0.01em;
|
||||
}
|
||||
|
||||
.sc-brand-mark {
|
||||
display: grid;
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
place-items: center;
|
||||
color: var(--sc-primary-fg);
|
||||
background: var(--sc-primary);
|
||||
border-radius: var(--sc-radius-md);
|
||||
font-size: 0.875rem;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.sc-nav {
|
||||
display: flex;
|
||||
flex: 1 1 auto;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
|
||||
.sc-nav-link,
|
||||
.sc-profile-button,
|
||||
.sc-icon-button {
|
||||
border: 1px solid transparent;
|
||||
border-radius: var(--sc-radius-md);
|
||||
transition: color 140ms ease, background 140ms ease, border-color 140ms ease;
|
||||
}
|
||||
|
||||
.sc-nav-link {
|
||||
padding: 0.5rem 0.75rem;
|
||||
color: var(--sc-muted-fg);
|
||||
font-size: 0.9rem;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.sc-nav-link:hover,
|
||||
.sc-nav-link[data-active='true'] {
|
||||
color: var(--sc-fg);
|
||||
background: var(--sc-surface-hover);
|
||||
border-color: var(--sc-border);
|
||||
}
|
||||
|
||||
.sc-header-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.sc-icon-button,
|
||||
.sc-profile-button {
|
||||
color: var(--sc-muted-fg);
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.sc-icon-button {
|
||||
display: grid;
|
||||
width: 2.25rem;
|
||||
height: 2.25rem;
|
||||
place-items: center;
|
||||
font-size: 1.15rem;
|
||||
}
|
||||
|
||||
.sc-profile-button {
|
||||
padding: 0.5rem 0.75rem;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.sc-icon-button:hover,
|
||||
.sc-profile-button:hover {
|
||||
color: var(--sc-fg);
|
||||
background: var(--sc-surface-hover);
|
||||
border-color: var(--sc-border);
|
||||
}
|
||||
|
||||
.sc-mobile-menu-button {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.sc-page-header {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.sc-page-header h1,
|
||||
.sc-page-header h2,
|
||||
.sc-dialog-title,
|
||||
.sc-auth-card h1 {
|
||||
margin: 0;
|
||||
color: var(--sc-fg);
|
||||
font-weight: 750;
|
||||
letter-spacing: -0.025em;
|
||||
}
|
||||
|
||||
.sc-page-header h1 {
|
||||
font-size: clamp(1.5rem, 3vw, 2.25rem);
|
||||
}
|
||||
|
||||
.sc-page-header p,
|
||||
.sc-dialog-description,
|
||||
.sc-auth-subtitle,
|
||||
.sc-muted {
|
||||
margin: 0.5rem 0 0;
|
||||
color: var(--sc-muted-fg);
|
||||
line-height: 1.55;
|
||||
}
|
||||
|
||||
.sc-card {
|
||||
padding: 1.25rem;
|
||||
color: var(--sc-fg);
|
||||
background: var(--sc-surface);
|
||||
border: 1px solid var(--sc-border);
|
||||
border-radius: var(--sc-radius-lg);
|
||||
box-shadow: var(--sc-shadow-sm);
|
||||
}
|
||||
|
||||
.sc-card-header {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.sc-card-header h2,
|
||||
.sc-card-header h3 {
|
||||
margin: 0;
|
||||
font-size: 1.05rem;
|
||||
}
|
||||
|
||||
.sc-card-header p {
|
||||
margin: 0.375rem 0 0;
|
||||
color: var(--sc-muted-fg);
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.sc-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
min-height: 1.5rem;
|
||||
padding: 0.125rem 0.5rem;
|
||||
color: var(--sc-secondary-fg);
|
||||
background: var(--sc-secondary);
|
||||
border: 1px solid var(--sc-border);
|
||||
border-radius: 999px;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 650;
|
||||
}
|
||||
|
||||
.sc-badge[data-variant='success'] {
|
||||
color: var(--sc-success-fg);
|
||||
background: var(--sc-success);
|
||||
border-color: transparent;
|
||||
}
|
||||
|
||||
.sc-badge[data-variant='warning'] {
|
||||
color: var(--sc-warning-fg);
|
||||
background: var(--sc-warning);
|
||||
border-color: transparent;
|
||||
}
|
||||
|
||||
.sc-badge[data-variant='danger'] {
|
||||
color: var(--sc-danger-fg);
|
||||
background: var(--sc-danger);
|
||||
border-color: transparent;
|
||||
}
|
||||
|
||||
.sc-button {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.5rem;
|
||||
min-height: 2.5rem;
|
||||
padding: 0.625rem 1rem;
|
||||
border: 1px solid transparent;
|
||||
border-radius: var(--sc-radius-md);
|
||||
font-size: 0.9rem;
|
||||
font-weight: 650;
|
||||
line-height: 1;
|
||||
cursor: pointer;
|
||||
transition: color 140ms ease, background 140ms ease, border-color 140ms ease, opacity 140ms ease;
|
||||
}
|
||||
|
||||
.sc-button:hover:not(:disabled) {
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.sc-button:disabled {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.55;
|
||||
}
|
||||
|
||||
.sc-button:focus-visible,
|
||||
.sc-icon-button:focus-visible,
|
||||
.sc-profile-button:focus-visible,
|
||||
.sc-nav-link:focus-visible,
|
||||
.sc-dialog-close:focus-visible {
|
||||
outline: 3px solid color-mix(in srgb, var(--sc-ring) 45%, transparent);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.sc-button-primary {
|
||||
color: var(--sc-primary-fg);
|
||||
background: var(--sc-primary);
|
||||
}
|
||||
|
||||
.sc-button-primary:hover:not(:disabled) {
|
||||
background: var(--sc-primary-hover);
|
||||
}
|
||||
|
||||
.sc-button-secondary {
|
||||
color: var(--sc-secondary-fg);
|
||||
background: var(--sc-secondary);
|
||||
border-color: var(--sc-border);
|
||||
}
|
||||
|
||||
.sc-button-secondary:hover:not(:disabled) {
|
||||
background: var(--sc-secondary-hover);
|
||||
}
|
||||
|
||||
.sc-button-ghost {
|
||||
color: var(--sc-muted-fg);
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.sc-button-ghost:hover:not(:disabled) {
|
||||
color: var(--sc-fg);
|
||||
background: var(--sc-surface-hover);
|
||||
}
|
||||
|
||||
.sc-button-danger {
|
||||
color: var(--sc-danger-fg);
|
||||
background: var(--sc-danger);
|
||||
}
|
||||
|
||||
.sc-button-danger:hover:not(:disabled) {
|
||||
background: var(--sc-danger-hover);
|
||||
}
|
||||
|
||||
.sc-button-sm {
|
||||
min-height: 2rem;
|
||||
padding: 0.45rem 0.75rem;
|
||||
font-size: 0.8125rem;
|
||||
}
|
||||
|
||||
.sc-button-lg {
|
||||
min-height: 2.875rem;
|
||||
padding: 0.75rem 1.25rem;
|
||||
}
|
||||
|
||||
.sc-button-full {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.sc-form {
|
||||
display: grid;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.sc-field {
|
||||
display: grid;
|
||||
gap: 0.4rem;
|
||||
}
|
||||
|
||||
.sc-label {
|
||||
color: var(--sc-fg);
|
||||
font-size: 0.85rem;
|
||||
font-weight: 650;
|
||||
}
|
||||
|
||||
.sc-label-optional {
|
||||
color: var(--sc-muted-fg);
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.sc-totp-settings {
|
||||
display: grid;
|
||||
gap: 0.75rem;
|
||||
margin-top: 1.5rem;
|
||||
padding-top: 1.25rem;
|
||||
border-top: 1px solid var(--sc-border);
|
||||
}
|
||||
|
||||
.sc-totp-heading {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.sc-totp-heading h3 {
|
||||
margin: 0;
|
||||
font-size: 0.95rem;
|
||||
}
|
||||
|
||||
.sc-totp-heading p {
|
||||
margin: 0.25rem 0 0;
|
||||
}
|
||||
|
||||
.sc-totp-status {
|
||||
flex: 0 0 auto;
|
||||
border: 1px solid var(--sc-border);
|
||||
border-radius: 999px;
|
||||
padding: 0.2rem 0.55rem;
|
||||
color: var(--sc-muted-fg);
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.sc-totp-status.sc-totp-enabled {
|
||||
border-color: var(--sc-success);
|
||||
color: var(--sc-success);
|
||||
}
|
||||
|
||||
.sc-totp-secret {
|
||||
display: grid;
|
||||
gap: 0.5rem;
|
||||
color: var(--sc-muted-fg);
|
||||
font-size: 0.8rem;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.sc-totp-secret p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.sc-totp-secret code {
|
||||
display: block;
|
||||
border-radius: 0.4rem;
|
||||
background: var(--sc-input-bg);
|
||||
padding: 0.6rem;
|
||||
color: var(--sc-fg);
|
||||
font-size: 0.7rem;
|
||||
}
|
||||
|
||||
.sc-input,
|
||||
.sc-select,
|
||||
.sc-textarea {
|
||||
width: 100%;
|
||||
min-height: 2.6rem;
|
||||
padding: 0.625rem 0.75rem;
|
||||
color: var(--sc-fg);
|
||||
background: var(--sc-bg);
|
||||
border: 1px solid var(--sc-border);
|
||||
border-radius: var(--sc-radius-md);
|
||||
outline: none;
|
||||
transition: border-color 140ms ease, box-shadow 140ms ease;
|
||||
}
|
||||
|
||||
.sc-textarea {
|
||||
min-height: 7rem;
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
.sc-input::placeholder,
|
||||
.sc-textarea::placeholder {
|
||||
color: var(--sc-subtle-fg);
|
||||
}
|
||||
|
||||
.sc-input:focus,
|
||||
.sc-select:focus,
|
||||
.sc-textarea:focus {
|
||||
border-color: var(--sc-ring);
|
||||
box-shadow: 0 0 0 3px color-mix(in srgb, var(--sc-ring) 22%, transparent);
|
||||
}
|
||||
|
||||
.sc-form-actions,
|
||||
.sc-dialog-footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 0.625rem;
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
.sc-error {
|
||||
padding: 0.75rem;
|
||||
color: var(--sc-danger);
|
||||
background: color-mix(in srgb, var(--sc-danger) 12%, transparent);
|
||||
border: 1px solid color-mix(in srgb, var(--sc-danger) 35%, transparent);
|
||||
border-radius: var(--sc-radius-md);
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.sc-success {
|
||||
color: var(--sc-success);
|
||||
}
|
||||
|
||||
.sc-user-management {
|
||||
display: grid;
|
||||
gap: 1rem;
|
||||
margin-top: 1.5rem;
|
||||
padding-top: 1.5rem;
|
||||
border-top: 1px solid var(--sc-border);
|
||||
}
|
||||
|
||||
.sc-user-management-header,
|
||||
.sc-user-row,
|
||||
.sc-user-edit-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.sc-user-management-header {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.sc-user-management-header h3 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.sc-user-management-header p {
|
||||
margin: 0.25rem 0 0;
|
||||
}
|
||||
|
||||
.sc-user-form,
|
||||
.sc-user-list {
|
||||
display: grid;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.sc-user-form {
|
||||
padding: 0.9rem;
|
||||
border: 1px solid var(--sc-border);
|
||||
border-radius: 0.6rem;
|
||||
background: var(--sc-surface-raised);
|
||||
}
|
||||
|
||||
.sc-user-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 0.6rem;
|
||||
}
|
||||
|
||||
.sc-user-row {
|
||||
min-width: 0;
|
||||
justify-content: space-between;
|
||||
padding: 0.7rem 0;
|
||||
border-bottom: 1px solid var(--sc-border);
|
||||
}
|
||||
|
||||
.sc-user-row > div:first-child {
|
||||
display: grid;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.sc-user-row > div:first-child span {
|
||||
overflow: hidden;
|
||||
color: var(--sc-muted-fg);
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.sc-user-role {
|
||||
color: var(--sc-muted-fg);
|
||||
font-size: 0.8rem;
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
.sc-user-actions {
|
||||
display: flex;
|
||||
flex-shrink: 0;
|
||||
gap: 0.4rem;
|
||||
}
|
||||
|
||||
.sc-user-edit-row {
|
||||
align-items: stretch;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.sc-user-edit-row .sc-input {
|
||||
flex: 1 1 10rem;
|
||||
min-width: 8rem;
|
||||
}
|
||||
|
||||
@media (max-width: 620px) {
|
||||
.sc-user-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.sc-user-row {
|
||||
align-items: flex-start;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.sc-user-actions {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.sc-auth-page {
|
||||
display: grid;
|
||||
min-height: 100vh;
|
||||
place-items: center;
|
||||
padding: 1.5rem;
|
||||
color: var(--sc-fg);
|
||||
background:
|
||||
radial-gradient(circle at 15% 10%, color-mix(in srgb, var(--sc-primary) 18%, transparent), transparent 35%),
|
||||
var(--sc-bg);
|
||||
}
|
||||
|
||||
.sc-auth-card {
|
||||
width: min(100%, 28rem);
|
||||
padding: clamp(1.5rem, 5vw, 2.5rem);
|
||||
background: var(--sc-surface);
|
||||
border: 1px solid var(--sc-border);
|
||||
border-radius: var(--sc-radius-xl);
|
||||
box-shadow: var(--sc-shadow-lg);
|
||||
}
|
||||
|
||||
.sc-auth-brand {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
margin-bottom: 1.5rem;
|
||||
font-weight: 750;
|
||||
}
|
||||
|
||||
.sc-auth-card h1 {
|
||||
font-size: 1.7rem;
|
||||
}
|
||||
|
||||
.sc-auth-form {
|
||||
margin-top: 1.5rem;
|
||||
}
|
||||
|
||||
.sc-auth-extra {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.sc-auth-reset {
|
||||
display: grid;
|
||||
gap: 0.625rem;
|
||||
margin-top: 1.25rem;
|
||||
padding-top: 1rem;
|
||||
border-top: 1px solid var(--sc-border);
|
||||
}
|
||||
|
||||
.sc-auth-reset-hint {
|
||||
color: var(--sc-subtle-fg);
|
||||
font-size: 0.75rem;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.sc-auth-reset-link {
|
||||
display: block;
|
||||
margin: 1.25rem auto 0;
|
||||
padding: 0;
|
||||
color: var(--sc-subtle-fg);
|
||||
font: inherit;
|
||||
font-size: 0.75rem;
|
||||
text-decoration: underline;
|
||||
background: none;
|
||||
border: 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.sc-auth-reset-link:hover {
|
||||
color: var(--sc-fg);
|
||||
}
|
||||
|
||||
.sc-dialog-backdrop {
|
||||
position: fixed;
|
||||
z-index: 100;
|
||||
inset: 0;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
padding: 1rem;
|
||||
background: var(--sc-backdrop);
|
||||
backdrop-filter: blur(5px);
|
||||
}
|
||||
|
||||
.sc-dialog {
|
||||
width: min(100%, 34rem);
|
||||
max-height: min(90vh, 48rem);
|
||||
overflow: auto;
|
||||
color: var(--sc-fg);
|
||||
background: var(--sc-surface-raised);
|
||||
border: 1px solid var(--sc-border);
|
||||
border-radius: var(--sc-radius-xl);
|
||||
box-shadow: var(--sc-shadow-lg);
|
||||
}
|
||||
|
||||
.sc-dialog-header {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
padding: 1.25rem 1.25rem 0;
|
||||
}
|
||||
|
||||
.sc-dialog-title {
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
|
||||
.sc-dialog-close {
|
||||
display: grid;
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
place-items: center;
|
||||
color: var(--sc-muted-fg);
|
||||
background: transparent;
|
||||
border: 1px solid transparent;
|
||||
border-radius: var(--sc-radius-sm);
|
||||
font-size: 1.35rem;
|
||||
line-height: 1;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.sc-dialog-close:hover {
|
||||
color: var(--sc-fg);
|
||||
background: var(--sc-surface-hover);
|
||||
border-color: var(--sc-border);
|
||||
}
|
||||
|
||||
.sc-dialog-body {
|
||||
padding: 1.25rem;
|
||||
}
|
||||
|
||||
.sc-dialog-footer {
|
||||
padding: 0 1.25rem 1.25rem;
|
||||
}
|
||||
|
||||
.sc-about-links {
|
||||
display: grid;
|
||||
gap: 0.5rem;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.sc-about-links a {
|
||||
color: var(--sc-primary);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.sc-about-links a:hover {
|
||||
color: var(--sc-primary-hover);
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.sc-profile-summary {
|
||||
display: grid;
|
||||
gap: 0.25rem;
|
||||
margin-bottom: 1.25rem;
|
||||
padding: 0.875rem;
|
||||
background: var(--sc-bg);
|
||||
border: 1px solid var(--sc-border);
|
||||
border-radius: var(--sc-radius-md);
|
||||
}
|
||||
|
||||
.sc-profile-summary strong {
|
||||
color: var(--sc-fg);
|
||||
}
|
||||
|
||||
.sc-profile-summary span {
|
||||
color: var(--sc-muted-fg);
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
@media (max-width: 45rem) {
|
||||
.sc-header {
|
||||
flex-wrap: wrap;
|
||||
gap: 0.75rem;
|
||||
padding: 0.75rem 1rem;
|
||||
}
|
||||
|
||||
.sc-mobile-menu-button {
|
||||
display: grid;
|
||||
order: 3;
|
||||
width: 2.25rem;
|
||||
height: 2.25rem;
|
||||
margin-left: auto;
|
||||
place-items: center;
|
||||
}
|
||||
|
||||
.sc-nav {
|
||||
display: none;
|
||||
flex-basis: 100%;
|
||||
order: 4;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
padding-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.sc-nav[data-open='true'] {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.sc-nav-link {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.sc-header-actions {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.sc-profile-button {
|
||||
max-width: 9rem;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 30rem) {
|
||||
.sc-main {
|
||||
width: min(100% - 1.25rem, 90rem);
|
||||
padding-top: 1.25rem;
|
||||
}
|
||||
|
||||
.sc-page-header {
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
import type { Snippet } from 'svelte';
|
||||
|
||||
export type AsyncAction<T = void> = (value: T) => void | Promise<void>;
|
||||
|
||||
export interface NavItem {
|
||||
href: string;
|
||||
label: string;
|
||||
}
|
||||
|
||||
export interface AuthSetupInput {
|
||||
username: string;
|
||||
email: string;
|
||||
password: string;
|
||||
}
|
||||
|
||||
export interface AuthLoginInput {
|
||||
identifier: string;
|
||||
password: string;
|
||||
totpToken?: string;
|
||||
}
|
||||
|
||||
export interface TotpSetupResponse {
|
||||
secret: string;
|
||||
otpauthUrl: string;
|
||||
enabled?: boolean;
|
||||
}
|
||||
|
||||
export type TotpStatusRequest = () => boolean | Promise<boolean>;
|
||||
|
||||
export type TotpSetupRequest = () => TotpSetupResponse | Promise<TotpSetupResponse>;
|
||||
|
||||
export type TotpTokenAction = (token: string) => void | Promise<void>;
|
||||
|
||||
export type AuthResetRequest = () => void | Promise<unknown>;
|
||||
|
||||
export type AuthResetConfirm = (code: string) => void | Promise<unknown>;
|
||||
|
||||
export interface ProfileUpdateInput {
|
||||
username: string;
|
||||
email: string;
|
||||
password?: string;
|
||||
}
|
||||
|
||||
export type UserRole = 'superadmin' | 'admin' | 'user';
|
||||
|
||||
export type UserId = string | number;
|
||||
|
||||
export interface ManagedUser {
|
||||
id: UserId;
|
||||
username: string;
|
||||
email: string;
|
||||
role: UserRole;
|
||||
totpEnabled?: boolean;
|
||||
createdAt?: string;
|
||||
updatedAt?: string;
|
||||
}
|
||||
|
||||
export interface UserCreateInput {
|
||||
username: string;
|
||||
email: string;
|
||||
password: string;
|
||||
role?: UserRole;
|
||||
}
|
||||
|
||||
export interface UserUpdateInput {
|
||||
username?: string;
|
||||
email?: string;
|
||||
password?: string;
|
||||
role?: UserRole;
|
||||
}
|
||||
|
||||
export type UserListRequest = () => ManagedUser[] | Promise<ManagedUser[]>;
|
||||
|
||||
export type UserCreateRequest = (input: UserCreateInput) => void | Promise<void | ManagedUser>;
|
||||
|
||||
export type UserUpdateRequest = (id: UserId, input: UserUpdateInput) => void | Promise<void | ManagedUser>;
|
||||
|
||||
export type UserDeleteRequest = (id: UserId) => void | Promise<void>;
|
||||
|
||||
export interface AboutLink {
|
||||
label: string;
|
||||
href: string;
|
||||
}
|
||||
|
||||
export type ContentSnippet = Snippet;
|
||||
@@ -0,0 +1 @@
|
||||
export default {};
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"allowJs": true,
|
||||
"checkJs": true,
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"moduleResolution": "bundler",
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
"target": "ES2022",
|
||||
"verbatimModuleSyntax": true
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.d.ts",
|
||||
"src/**/*.ts",
|
||||
"src/**/*.svelte"
|
||||
]
|
||||
}
|
||||
Reference in new issue
Block a user