@svadmin/ui 0.99.0 → 0.102.0
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/app.css +99 -0
- package/dist/app.theme.css +99 -0
- package/dist/components/AboutSettings.svelte +1 -1
- package/dist/components/AdminApp.svelte +13 -1
- package/dist/components/AdminApp.svelte.d.ts +7 -0
- package/dist/components/Affix.svelte +43 -0
- package/dist/components/Affix.svelte.d.ts +11 -0
- package/dist/components/Anchor.svelte +60 -0
- package/dist/components/Anchor.svelte.d.ts +14 -0
- package/dist/components/AutoTable.svelte +35 -16
- package/dist/components/AutoTable.svelte.d.ts +6 -0
- package/dist/components/Calendar.svelte +152 -0
- package/dist/components/Calendar.svelte.d.ts +20 -0
- package/dist/components/Carousel.svelte +107 -0
- package/dist/components/Carousel.svelte.d.ts +15 -0
- package/dist/components/Collapse.svelte +177 -0
- package/dist/components/Collapse.svelte.d.ts +32 -0
- package/dist/components/CommentThread.svelte +109 -0
- package/dist/components/CommentThread.svelte.d.ts +22 -0
- package/dist/components/CopyButton.svelte +148 -0
- package/dist/components/CopyButton.svelte.d.ts +19 -0
- package/dist/components/DataTableShell.svelte +140 -0
- package/dist/components/DataTableShell.svelte.d.ts +18 -0
- package/dist/components/DetailDrawer.svelte +9 -3
- package/dist/components/DetailDrawer.svelte.d.ts +2 -0
- package/dist/components/Header.svelte +28 -0
- package/dist/components/Header.svelte.d.ts +8 -0
- package/dist/components/ImagePreview.svelte +83 -0
- package/dist/components/ImagePreview.svelte.d.ts +14 -0
- package/dist/components/Layout.svelte +86 -6
- package/dist/components/Layout.svelte.d.ts +6 -0
- package/dist/components/ListFooter.svelte +82 -0
- package/dist/components/ListFooter.svelte.d.ts +23 -0
- package/dist/components/ListPagination.svelte +109 -0
- package/dist/components/ListPagination.svelte.d.ts +19 -0
- package/dist/components/NotificationCenter.svelte +215 -0
- package/dist/components/NotificationCenter.svelte.d.ts +28 -0
- package/dist/components/ScrollableTable.svelte +211 -0
- package/dist/components/ScrollableTable.svelte.d.ts +14 -0
- package/dist/components/ThemeSettingsDrawer.svelte +212 -0
- package/dist/components/ThemeSettingsDrawer.svelte.d.ts +10 -0
- package/dist/components/TypographyEllipsis.svelte +123 -0
- package/dist/components/TypographyEllipsis.svelte.d.ts +18 -0
- package/dist/components/ViewModeToggle.svelte +47 -0
- package/dist/components/ViewModeToggle.svelte.d.ts +11 -0
- package/dist/components/list-i18n.d.ts +27 -0
- package/dist/components/list-i18n.js +53 -0
- package/dist/components/list-pagination.d.ts +3 -0
- package/dist/components/list-pagination.js +18 -0
- package/dist/components/templates/AdvancedDetailTemplate.svelte +36 -0
- package/dist/components/templates/AdvancedDetailTemplate.svelte.d.ts +17 -0
- package/dist/components/templates/AdvancedFormTemplate.svelte +32 -0
- package/dist/components/templates/AdvancedFormTemplate.svelte.d.ts +15 -0
- package/dist/components/templates/AnalysisTemplate.svelte +34 -0
- package/dist/components/templates/AnalysisTemplate.svelte.d.ts +16 -0
- package/dist/components/templates/BasicDetailTemplate.svelte +32 -0
- package/dist/components/templates/BasicDetailTemplate.svelte.d.ts +15 -0
- package/dist/components/templates/CardListTemplate.svelte +29 -0
- package/dist/components/templates/CardListTemplate.svelte.d.ts +14 -0
- package/dist/components/templates/ExceptionTemplate.svelte +28 -0
- package/dist/components/templates/ExceptionTemplate.svelte.d.ts +11 -0
- package/dist/components/templates/GroupFormTemplate.svelte +30 -0
- package/dist/components/templates/GroupFormTemplate.svelte.d.ts +14 -0
- package/dist/components/templates/MonitorTemplate.svelte +39 -0
- package/dist/components/templates/MonitorTemplate.svelte.d.ts +15 -0
- package/dist/components/templates/ProfileTemplate.svelte +30 -0
- package/dist/components/templates/ProfileTemplate.svelte.d.ts +14 -0
- package/dist/components/templates/ResultTemplate.svelte +39 -0
- package/dist/components/templates/ResultTemplate.svelte.d.ts +14 -0
- package/dist/components/templates/SearchTableTemplate.svelte +31 -0
- package/dist/components/templates/SearchTableTemplate.svelte.d.ts +15 -0
- package/dist/components/templates/StepFormTemplate.svelte +62 -0
- package/dist/components/templates/StepFormTemplate.svelte.d.ts +23 -0
- package/dist/components/templates/TemplatePageShell.svelte +109 -0
- package/dist/components/templates/TemplatePageShell.svelte.d.ts +20 -0
- package/dist/components/templates/WorkplaceTemplate.svelte +34 -0
- package/dist/components/templates/WorkplaceTemplate.svelte.d.ts +16 -0
- package/dist/components/templates/index.d.ts +16 -0
- package/dist/components/templates/index.js +16 -0
- package/dist/design-system-components.d.ts +64 -0
- package/dist/design-system-components.js +72 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +20 -0
- package/dist/ui-preferences.svelte.d.ts +19 -0
- package/dist/ui-preferences.svelte.js +69 -0
- package/package.json +1 -1
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onDestroy } from 'svelte';
|
|
3
|
+
import { Check, CircleAlert, Copy } from '@lucide/svelte';
|
|
4
|
+
import { cn } from '../utils.js';
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
value?: string | number | null | undefined;
|
|
8
|
+
/** Human-readable name used in the accessible label and feedback. */
|
|
9
|
+
description?: string | undefined;
|
|
10
|
+
label?: string | undefined;
|
|
11
|
+
copiedLabel?: string | undefined;
|
|
12
|
+
errorLabel?: string | undefined;
|
|
13
|
+
title?: string | undefined;
|
|
14
|
+
copiedTitle?: string | undefined;
|
|
15
|
+
errorTitle?: string | undefined;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
/** How long the copied/error state stays visible. */
|
|
18
|
+
resetDelayMs?: number | undefined;
|
|
19
|
+
oncopy?: ((value: string) => void) | undefined;
|
|
20
|
+
class?: string | undefined;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let {
|
|
24
|
+
value,
|
|
25
|
+
description = '内容',
|
|
26
|
+
label = undefined,
|
|
27
|
+
copiedLabel = undefined,
|
|
28
|
+
errorLabel = '复制失败,请检查剪贴板权限。',
|
|
29
|
+
title = undefined,
|
|
30
|
+
copiedTitle = undefined,
|
|
31
|
+
errorTitle = undefined,
|
|
32
|
+
disabled = false,
|
|
33
|
+
resetDelayMs = 1500,
|
|
34
|
+
oncopy,
|
|
35
|
+
class: className = '',
|
|
36
|
+
}: Props = $props();
|
|
37
|
+
|
|
38
|
+
let copied = $state(false);
|
|
39
|
+
let copying = $state(false);
|
|
40
|
+
let error = $state('');
|
|
41
|
+
let timeoutId: ReturnType<typeof setTimeout> | null = null;
|
|
42
|
+
let destroyed = false;
|
|
43
|
+
|
|
44
|
+
const rawValue = $derived(value != null && value !== '' ? String(value) : '');
|
|
45
|
+
const accessibleLabel = $derived(label ?? `复制${description}`);
|
|
46
|
+
const copiedFeedback = $derived(copiedLabel ?? `已复制${description}`);
|
|
47
|
+
const buttonTitle = $derived(error ? (errorTitle ?? error)
|
|
48
|
+
: copied ? (copiedTitle ?? copiedFeedback)
|
|
49
|
+
: rawValue ? (title ?? accessibleLabel) : '没有可复制的内容');
|
|
50
|
+
const isDisabled = $derived(Boolean(disabled || !rawValue || copying));
|
|
51
|
+
const statusText = $derived(error || (copied ? copiedFeedback : ''));
|
|
52
|
+
|
|
53
|
+
function clearTimer(): void {
|
|
54
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
55
|
+
timeoutId = null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function scheduleReset(): void {
|
|
59
|
+
clearTimer();
|
|
60
|
+
timeoutId = setTimeout(() => {
|
|
61
|
+
if (!destroyed) {
|
|
62
|
+
copied = false;
|
|
63
|
+
error = '';
|
|
64
|
+
}
|
|
65
|
+
timeoutId = null;
|
|
66
|
+
}, resetDelayMs);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async function copyValue(): Promise<void> {
|
|
70
|
+
if (isDisabled || !rawValue) return;
|
|
71
|
+
const target = rawValue;
|
|
72
|
+
copying = true;
|
|
73
|
+
copied = false;
|
|
74
|
+
error = '';
|
|
75
|
+
clearTimer();
|
|
76
|
+
try {
|
|
77
|
+
const writeText = globalThis.navigator?.clipboard?.writeText;
|
|
78
|
+
if (!writeText) throw new Error('Clipboard unavailable');
|
|
79
|
+
await writeText.call(globalThis.navigator.clipboard, target);
|
|
80
|
+
if (destroyed) return;
|
|
81
|
+
copied = true;
|
|
82
|
+
} catch {
|
|
83
|
+
if (!destroyed) error = errorLabel;
|
|
84
|
+
} finally {
|
|
85
|
+
if (!destroyed) {
|
|
86
|
+
copying = false;
|
|
87
|
+
scheduleReset();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (copied && !destroyed) {
|
|
91
|
+
try {
|
|
92
|
+
oncopy?.(target);
|
|
93
|
+
} catch {
|
|
94
|
+
// 宿主通知失败不改变已经成功完成的剪贴板操作。
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
onDestroy(() => {
|
|
100
|
+
destroyed = true;
|
|
101
|
+
clearTimer();
|
|
102
|
+
});
|
|
103
|
+
</script>
|
|
104
|
+
|
|
105
|
+
<button
|
|
106
|
+
type="button"
|
|
107
|
+
class={cn('svadmin-copy-button', className)}
|
|
108
|
+
data-svadmin-copy-button
|
|
109
|
+
data-state={error ? 'error' : copied ? 'copied' : 'idle'}
|
|
110
|
+
disabled={isDisabled}
|
|
111
|
+
aria-label={accessibleLabel}
|
|
112
|
+
title={buttonTitle}
|
|
113
|
+
onclick={() => void copyValue()}
|
|
114
|
+
>
|
|
115
|
+
{#if error}
|
|
116
|
+
<CircleAlert size={14} aria-hidden="true" />
|
|
117
|
+
{:else if copied}
|
|
118
|
+
<Check size={14} aria-hidden="true" />
|
|
119
|
+
{:else}
|
|
120
|
+
<Copy size={14} aria-hidden="true" />
|
|
121
|
+
{/if}
|
|
122
|
+
</button>
|
|
123
|
+
<span class="svadmin-sr-only" role="status" aria-live="polite">{statusText}</span>
|
|
124
|
+
|
|
125
|
+
<style>
|
|
126
|
+
.svadmin-copy-button {
|
|
127
|
+
display: inline-flex;
|
|
128
|
+
flex: 0 0 auto;
|
|
129
|
+
align-items: center;
|
|
130
|
+
justify-content: center;
|
|
131
|
+
width: 1.75rem;
|
|
132
|
+
height: 1.75rem;
|
|
133
|
+
padding: 0;
|
|
134
|
+
border: 0;
|
|
135
|
+
border-radius: 0.25rem;
|
|
136
|
+
background: transparent;
|
|
137
|
+
color: var(--muted-foreground);
|
|
138
|
+
cursor: pointer;
|
|
139
|
+
}
|
|
140
|
+
.svadmin-copy-button:hover:not(:disabled),
|
|
141
|
+
.svadmin-copy-button:focus-visible {
|
|
142
|
+
background: var(--muted);
|
|
143
|
+
color: var(--foreground);
|
|
144
|
+
}
|
|
145
|
+
.svadmin-copy-button:disabled { opacity: 0.5; cursor: not-allowed; }
|
|
146
|
+
.svadmin-copy-button[data-state='copied'] { color: var(--primary); }
|
|
147
|
+
.svadmin-copy-button[data-state='error'] { color: var(--destructive); }
|
|
148
|
+
</style>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
value?: string | number | null | undefined;
|
|
3
|
+
/** Human-readable name used in the accessible label and feedback. */
|
|
4
|
+
description?: string | undefined;
|
|
5
|
+
label?: string | undefined;
|
|
6
|
+
copiedLabel?: string | undefined;
|
|
7
|
+
errorLabel?: string | undefined;
|
|
8
|
+
title?: string | undefined;
|
|
9
|
+
copiedTitle?: string | undefined;
|
|
10
|
+
errorTitle?: string | undefined;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
/** How long the copied/error state stays visible. */
|
|
13
|
+
resetDelayMs?: number | undefined;
|
|
14
|
+
oncopy?: ((value: string) => void) | undefined;
|
|
15
|
+
class?: string | undefined;
|
|
16
|
+
}
|
|
17
|
+
declare const CopyButton: import("svelte").Component<Props, {}, "">;
|
|
18
|
+
type CopyButton = ReturnType<typeof CopyButton>;
|
|
19
|
+
export default CopyButton;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import { cn } from '../utils.js';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
/** Optional table heading. Omit it when the page already owns the heading. */
|
|
7
|
+
title?: string | undefined;
|
|
8
|
+
/** Optional record count rendered beside the heading. */
|
|
9
|
+
count?: number | undefined;
|
|
10
|
+
/** Accessible name for the table region. */
|
|
11
|
+
caption: string;
|
|
12
|
+
/** Keep the last column visible while the table scrolls horizontally. */
|
|
13
|
+
stickyActions?: boolean;
|
|
14
|
+
/** Toolbar content rendered opposite the heading. */
|
|
15
|
+
toolbar?: Snippet | undefined;
|
|
16
|
+
children: Snippet;
|
|
17
|
+
class?: string | undefined;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let {
|
|
21
|
+
title,
|
|
22
|
+
count,
|
|
23
|
+
caption,
|
|
24
|
+
stickyActions = false,
|
|
25
|
+
toolbar,
|
|
26
|
+
children,
|
|
27
|
+
class: className = '',
|
|
28
|
+
}: Props = $props();
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<section
|
|
32
|
+
class={cn('svadmin-data-table-shell', className)}
|
|
33
|
+
class:svadmin-data-table-shell--sticky-actions={stickyActions}
|
|
34
|
+
aria-label={caption}
|
|
35
|
+
data-svadmin-data-table-shell
|
|
36
|
+
>
|
|
37
|
+
{#if title || toolbar}
|
|
38
|
+
<header class="svadmin-data-table-shell__header" data-slot="data-table-shell-header">
|
|
39
|
+
{#if title}
|
|
40
|
+
<div class="svadmin-data-table-shell__heading">
|
|
41
|
+
<h2 class="svadmin-data-table-shell__title">{title}</h2>
|
|
42
|
+
{#if count !== undefined}
|
|
43
|
+
<span class="svadmin-data-table-shell__count" data-svadmin-data-table-count>{count} 条</span>
|
|
44
|
+
{/if}
|
|
45
|
+
</div>
|
|
46
|
+
{/if}
|
|
47
|
+
{#if toolbar}
|
|
48
|
+
<div class="svadmin-data-table-shell__toolbar" data-slot="data-table-shell-toolbar">{@render toolbar()}</div>
|
|
49
|
+
{/if}
|
|
50
|
+
</header>
|
|
51
|
+
{/if}
|
|
52
|
+
<div class="svadmin-data-table-shell__viewport" data-slot="data-table-shell-viewport">
|
|
53
|
+
{@render children()}
|
|
54
|
+
</div>
|
|
55
|
+
</section>
|
|
56
|
+
|
|
57
|
+
<style>
|
|
58
|
+
.svadmin-data-table-shell {
|
|
59
|
+
min-width: 0;
|
|
60
|
+
overflow: hidden;
|
|
61
|
+
border: 1px solid var(--border);
|
|
62
|
+
border-radius: var(--radius, 0.5rem);
|
|
63
|
+
background: var(--card, var(--background));
|
|
64
|
+
}
|
|
65
|
+
.svadmin-data-table-shell__header {
|
|
66
|
+
display: flex;
|
|
67
|
+
flex-wrap: wrap;
|
|
68
|
+
align-items: center;
|
|
69
|
+
justify-content: space-between;
|
|
70
|
+
gap: 0.875rem 1.25rem;
|
|
71
|
+
min-height: 4rem;
|
|
72
|
+
border-bottom: 1px solid var(--border);
|
|
73
|
+
padding: 0.875rem 1.25rem;
|
|
74
|
+
background: var(--card, var(--background));
|
|
75
|
+
}
|
|
76
|
+
.svadmin-data-table-shell__heading {
|
|
77
|
+
display: inline-flex;
|
|
78
|
+
align-items: baseline;
|
|
79
|
+
gap: 0.6rem;
|
|
80
|
+
min-width: 0;
|
|
81
|
+
}
|
|
82
|
+
.svadmin-data-table-shell__title {
|
|
83
|
+
margin: 0;
|
|
84
|
+
color: var(--foreground);
|
|
85
|
+
font-size: 1rem;
|
|
86
|
+
font-weight: 700;
|
|
87
|
+
line-height: 1.35;
|
|
88
|
+
}
|
|
89
|
+
.svadmin-data-table-shell__count {
|
|
90
|
+
color: var(--muted-foreground);
|
|
91
|
+
font-size: 0.8125rem;
|
|
92
|
+
font-variant-numeric: tabular-nums;
|
|
93
|
+
}
|
|
94
|
+
.svadmin-data-table-shell__toolbar {
|
|
95
|
+
display: flex;
|
|
96
|
+
flex-wrap: wrap;
|
|
97
|
+
align-items: center;
|
|
98
|
+
gap: 0.625rem;
|
|
99
|
+
}
|
|
100
|
+
.svadmin-data-table-shell__viewport {
|
|
101
|
+
display: block;
|
|
102
|
+
width: 100%;
|
|
103
|
+
min-width: 0;
|
|
104
|
+
max-width: 100%;
|
|
105
|
+
overflow-x: auto;
|
|
106
|
+
overscroll-behavior-inline: contain;
|
|
107
|
+
scrollbar-width: thin;
|
|
108
|
+
}
|
|
109
|
+
:global(.svadmin-data-table-shell__viewport [data-slot='table-container']) {
|
|
110
|
+
width: 100%;
|
|
111
|
+
max-width: 100%;
|
|
112
|
+
min-width: 0;
|
|
113
|
+
overflow: visible;
|
|
114
|
+
}
|
|
115
|
+
:global(.svadmin-data-table-shell__viewport > table > thead > tr > th),
|
|
116
|
+
:global(.svadmin-data-table-shell__viewport > [data-slot='table-container'] > table > thead > tr > th) {
|
|
117
|
+
position: sticky;
|
|
118
|
+
top: 0;
|
|
119
|
+
z-index: 1;
|
|
120
|
+
border-bottom: 1px solid var(--border);
|
|
121
|
+
background: var(--muted);
|
|
122
|
+
}
|
|
123
|
+
:global(.svadmin-data-table-shell--sticky-actions > .svadmin-data-table-shell__viewport > table > :is(thead, tbody, tfoot) > tr > :is(th, td):last-child),
|
|
124
|
+
:global(.svadmin-data-table-shell--sticky-actions > .svadmin-data-table-shell__viewport > [data-slot='table-container'] > table > :is(thead, tbody, tfoot) > tr > :is(th, td):last-child) {
|
|
125
|
+
position: sticky;
|
|
126
|
+
right: 0;
|
|
127
|
+
z-index: 2;
|
|
128
|
+
background: var(--card, var(--background));
|
|
129
|
+
box-shadow: -1px 0 var(--border);
|
|
130
|
+
}
|
|
131
|
+
:global(.svadmin-data-table-shell--sticky-actions > .svadmin-data-table-shell__viewport > table > thead > tr > th:last-child),
|
|
132
|
+
:global(.svadmin-data-table-shell--sticky-actions > .svadmin-data-table-shell__viewport > [data-slot='table-container'] > table > thead > tr > th:last-child) {
|
|
133
|
+
z-index: 3;
|
|
134
|
+
background: var(--muted);
|
|
135
|
+
}
|
|
136
|
+
@media (max-width: 640px) {
|
|
137
|
+
.svadmin-data-table-shell__header { align-items: stretch; }
|
|
138
|
+
.svadmin-data-table-shell__toolbar { width: 100%; }
|
|
139
|
+
}
|
|
140
|
+
</style>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
interface Props {
|
|
3
|
+
/** Optional table heading. Omit it when the page already owns the heading. */
|
|
4
|
+
title?: string | undefined;
|
|
5
|
+
/** Optional record count rendered beside the heading. */
|
|
6
|
+
count?: number | undefined;
|
|
7
|
+
/** Accessible name for the table region. */
|
|
8
|
+
caption: string;
|
|
9
|
+
/** Keep the last column visible while the table scrolls horizontally. */
|
|
10
|
+
stickyActions?: boolean;
|
|
11
|
+
/** Toolbar content rendered opposite the heading. */
|
|
12
|
+
toolbar?: Snippet | undefined;
|
|
13
|
+
children: Snippet;
|
|
14
|
+
class?: string | undefined;
|
|
15
|
+
}
|
|
16
|
+
declare const DataTableShell: import("svelte").Component<Props, {}, "">;
|
|
17
|
+
type DataTableShell = ReturnType<typeof DataTableShell>;
|
|
18
|
+
export default DataTableShell;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import type { HTMLAttributes } from "svelte/elements";
|
|
5
5
|
import { cn, type WithElementRef } from "../utils.js";
|
|
6
6
|
import * as Sheet from "./ui/sheet/index.js";
|
|
7
|
+
import StatusBadge from "./content/StatusBadge.svelte";
|
|
7
8
|
|
|
8
9
|
type Props = WithElementRef<HTMLAttributes<HTMLDivElement>, HTMLDivElement> & {
|
|
9
10
|
open?: boolean;
|
|
@@ -12,6 +13,8 @@
|
|
|
12
13
|
description?: string;
|
|
13
14
|
descriptionId?: string;
|
|
14
15
|
closeLabel?: string;
|
|
16
|
+
statusLabel?: string;
|
|
17
|
+
statusTone?: 'neutral' | 'success' | 'warning' | 'danger' | 'info';
|
|
15
18
|
side?: "left" | "right";
|
|
16
19
|
width?: string;
|
|
17
20
|
onClose?: () => void;
|
|
@@ -35,6 +38,8 @@
|
|
|
35
38
|
titleId,
|
|
36
39
|
descriptionId,
|
|
37
40
|
closeLabel = "Close",
|
|
41
|
+
statusLabel = "",
|
|
42
|
+
statusTone = 'neutral',
|
|
38
43
|
onClose,
|
|
39
44
|
onCloseRequest,
|
|
40
45
|
children,
|
|
@@ -65,7 +70,7 @@
|
|
|
65
70
|
{...restProps}
|
|
66
71
|
>
|
|
67
72
|
<Sheet.Content class="svadmin-u-60fbb7713999 svadmin-u-668b21aa5409 svadmin-u-8dddea0773ed svadmin-u-63a285be6490 svadmin-u-8a539c7fe216">
|
|
68
|
-
{#if title || description || extra}
|
|
73
|
+
{#if title || description || statusLabel || extra}
|
|
69
74
|
<Sheet.Header class="svadmin-u-2074a75bf2e7 svadmin-u-65fdbade2025 svadmin-u-18049387f0af svadmin-u-f92d02360b8f svadmin-u-cb11fec3bb46 svadmin-u-ab82c25c24ec">
|
|
70
75
|
<div class="svadmin-u-60fbb7713999 svadmin-u-60541e1e26f8 svadmin-u-8ef2268efbbc svadmin-u-0c3bc98565dd">
|
|
71
76
|
<div class="svadmin-u-60fbb7713999 svadmin-u-7e0b7cdf1a94 svadmin-u-36e579c0b41c svadmin-u-8dddea0773ed svadmin-u-58284b4ea568">
|
|
@@ -76,9 +81,10 @@
|
|
|
76
81
|
<Sheet.Description id={descriptionId}>{description}</Sheet.Description>
|
|
77
82
|
{/if}
|
|
78
83
|
</div>
|
|
79
|
-
{#if extra}
|
|
84
|
+
{#if statusLabel || extra}
|
|
80
85
|
<div class="svadmin-u-60fbb7713999 svadmin-u-2074a75bf2e7 svadmin-u-3960ffc248d9 svadmin-u-77a2a20e90d4">
|
|
81
|
-
{
|
|
86
|
+
{#if statusLabel}<StatusBadge status={statusTone} label={statusLabel} />{/if}
|
|
87
|
+
{#if extra}{@render extra()}{/if}
|
|
82
88
|
</div>
|
|
83
89
|
{/if}
|
|
84
90
|
</div>
|
|
@@ -8,6 +8,8 @@ type Props = WithElementRef<HTMLAttributes<HTMLDivElement>, HTMLDivElement> & {
|
|
|
8
8
|
description?: string;
|
|
9
9
|
descriptionId?: string;
|
|
10
10
|
closeLabel?: string;
|
|
11
|
+
statusLabel?: string;
|
|
12
|
+
statusTone?: 'neutral' | 'success' | 'warning' | 'danger' | 'info';
|
|
11
13
|
side?: "left" | "right";
|
|
12
14
|
width?: string;
|
|
13
15
|
onClose?: () => void;
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
import TooltipButton from './TooltipButton.svelte';
|
|
5
5
|
import { getResolvedTheme, toggleTheme, type MenuItem } from '@svadmin/core';
|
|
6
6
|
import Breadcrumbs from './Breadcrumbs.svelte';
|
|
7
|
+
import NotificationCenter, { type NotificationItem } from './NotificationCenter.svelte';
|
|
8
|
+
import ThemeSettingsDrawer from './ThemeSettingsDrawer.svelte';
|
|
7
9
|
import { useTranslation } from '@svadmin/core/i18n';
|
|
8
10
|
|
|
9
11
|
import { getComponentRegistry } from '../component-registry.svelte.js';
|
|
@@ -12,6 +14,13 @@
|
|
|
12
14
|
|
|
13
15
|
let {
|
|
14
16
|
showThemeToggle = false,
|
|
17
|
+
showThemeSettings = true,
|
|
18
|
+
showNotifications = true,
|
|
19
|
+
notificationItems = [],
|
|
20
|
+
notificationUnreadCount,
|
|
21
|
+
onnotificationread,
|
|
22
|
+
onnotificationreadall,
|
|
23
|
+
onnotificationopen,
|
|
15
24
|
showBreadcrumbs = true,
|
|
16
25
|
showSearch = true,
|
|
17
26
|
onSearchClick,
|
|
@@ -22,6 +31,13 @@
|
|
|
22
31
|
menu,
|
|
23
32
|
} = $props<{
|
|
24
33
|
showThemeToggle?: boolean;
|
|
34
|
+
showThemeSettings?: boolean;
|
|
35
|
+
showNotifications?: boolean;
|
|
36
|
+
notificationItems?: NotificationItem[];
|
|
37
|
+
notificationUnreadCount?: number;
|
|
38
|
+
onnotificationread?: (item: NotificationItem) => void | Promise<void>;
|
|
39
|
+
onnotificationreadall?: () => void | Promise<void>;
|
|
40
|
+
onnotificationopen?: (item: NotificationItem) => void | Promise<void>;
|
|
25
41
|
showBreadcrumbs?: boolean;
|
|
26
42
|
showSearch?: boolean;
|
|
27
43
|
onSearchClick?: () => void;
|
|
@@ -65,6 +81,18 @@
|
|
|
65
81
|
|
|
66
82
|
{#if CustomNotificationPanel}
|
|
67
83
|
<CustomNotificationPanel />
|
|
84
|
+
{:else if showNotifications}
|
|
85
|
+
<NotificationCenter
|
|
86
|
+
items={notificationItems}
|
|
87
|
+
unreadCount={notificationUnreadCount}
|
|
88
|
+
onread={onnotificationread}
|
|
89
|
+
onreadall={onnotificationreadall}
|
|
90
|
+
onopen={onnotificationopen}
|
|
91
|
+
/>
|
|
92
|
+
{/if}
|
|
93
|
+
|
|
94
|
+
{#if showThemeSettings}
|
|
95
|
+
<ThemeSettingsDrawer />
|
|
68
96
|
{/if}
|
|
69
97
|
|
|
70
98
|
{#if showSearch && onSearchClick}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { type MenuItem } from '@svadmin/core';
|
|
2
|
+
import { type NotificationItem } from './NotificationCenter.svelte';
|
|
2
3
|
type $$ComponentProps = {
|
|
3
4
|
showThemeToggle?: boolean;
|
|
5
|
+
showThemeSettings?: boolean;
|
|
6
|
+
showNotifications?: boolean;
|
|
7
|
+
notificationItems?: NotificationItem[];
|
|
8
|
+
notificationUnreadCount?: number;
|
|
9
|
+
onnotificationread?: (item: NotificationItem) => void | Promise<void>;
|
|
10
|
+
onnotificationreadall?: () => void | Promise<void>;
|
|
11
|
+
onnotificationopen?: (item: NotificationItem) => void | Promise<void>;
|
|
4
12
|
showBreadcrumbs?: boolean;
|
|
5
13
|
showSearch?: boolean;
|
|
6
14
|
onSearchClick?: () => void;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { ChevronLeft, ChevronRight, X, ZoomIn } from '@lucide/svelte';
|
|
3
|
+
import { Button } from './ui/button/index.js';
|
|
4
|
+
import * as Dialog from './ui/dialog/index.js';
|
|
5
|
+
import { cn } from '../utils.js';
|
|
6
|
+
|
|
7
|
+
export interface PreviewImage {
|
|
8
|
+
src: string;
|
|
9
|
+
alt: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface Props {
|
|
13
|
+
src: string;
|
|
14
|
+
alt?: string;
|
|
15
|
+
images?: PreviewImage[];
|
|
16
|
+
open?: boolean;
|
|
17
|
+
class?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let { src, alt = '', images = [], open = $bindable(false), class: className = '' }: Props = $props();
|
|
21
|
+
const gallery = $derived(images.length > 0 ? images : [{ src, alt }]);
|
|
22
|
+
let index = $state(0);
|
|
23
|
+
const current = $derived(gallery[Math.max(0, Math.min(index, gallery.length - 1))] ?? { src, alt });
|
|
24
|
+
|
|
25
|
+
function show(target = 0): void {
|
|
26
|
+
index = target;
|
|
27
|
+
open = true;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function move(delta: number): void {
|
|
31
|
+
index = (index + delta + gallery.length) % gallery.length;
|
|
32
|
+
}
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<button type="button" class={cn('svadmin-image-preview__trigger', className)} aria-label={`Open ${alt || 'image'} preview`} onclick={() => show()}>
|
|
36
|
+
<img {src} {alt} loading="lazy" />
|
|
37
|
+
<span class="svadmin-image-preview__overlay" aria-hidden="true"><ZoomIn size={18} /></span>
|
|
38
|
+
</button>
|
|
39
|
+
|
|
40
|
+
<Dialog.Root bind:open>
|
|
41
|
+
<Dialog.Content class="svadmin-image-preview">
|
|
42
|
+
<Dialog.Title class="svadmin-image-preview__title">{current.alt || alt || 'Image preview'}</Dialog.Title>
|
|
43
|
+
<div class="svadmin-image-preview__stage">
|
|
44
|
+
<img src={current.src} alt={current.alt || alt} />
|
|
45
|
+
{#if gallery.length > 1}
|
|
46
|
+
<Button variant="secondary" size="icon-sm" class="svadmin-image-preview__prev" aria-label="Previous image" onclick={() => move(-1)}><ChevronLeft size={18} /></Button>
|
|
47
|
+
<Button variant="secondary" size="icon-sm" class="svadmin-image-preview__next" aria-label="Next image" onclick={() => move(1)}><ChevronRight size={18} /></Button>
|
|
48
|
+
{/if}
|
|
49
|
+
</div>
|
|
50
|
+
{#if gallery.length > 1}
|
|
51
|
+
<div class="svadmin-image-preview__thumbs">
|
|
52
|
+
{#each gallery as image, item (image.src)}
|
|
53
|
+
<button type="button" aria-label={image.alt} aria-pressed={item === index} onclick={() => (index = item)}>
|
|
54
|
+
<img src={image.src} alt="" />
|
|
55
|
+
</button>
|
|
56
|
+
{/each}
|
|
57
|
+
</div>
|
|
58
|
+
{/if}
|
|
59
|
+
<Dialog.Close>
|
|
60
|
+
{#snippet child({ props })}
|
|
61
|
+
<Button {...props} variant="ghost" size="icon-sm" class="svadmin-image-preview__close" aria-label="Close preview"><X size={18} /></Button>
|
|
62
|
+
{/snippet}
|
|
63
|
+
</Dialog.Close>
|
|
64
|
+
</Dialog.Content>
|
|
65
|
+
</Dialog.Root>
|
|
66
|
+
|
|
67
|
+
<style>
|
|
68
|
+
.svadmin-image-preview__trigger { position: relative; display: block; overflow: hidden; width: 100%; max-width: 100%; padding: 0; border: 0; border-radius: var(--radius-md); background: var(--muted); cursor: zoom-in; }
|
|
69
|
+
.svadmin-image-preview__trigger img { display: block; width: 100%; height: auto; }
|
|
70
|
+
.svadmin-image-preview__overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgb(0 0 0 / 0.25); color: var(--primary-foreground); opacity: 0; transition: opacity 120ms ease; }
|
|
71
|
+
.svadmin-image-preview__trigger:hover .svadmin-image-preview__overlay, .svadmin-image-preview__trigger:focus-visible .svadmin-image-preview__overlay { opacity: 1; }
|
|
72
|
+
.svadmin-image-preview { width: min(64rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); overflow: auto; }
|
|
73
|
+
.svadmin-image-preview__title { padding-inline-end: var(--svadmin-space-6); font-size: var(--svadmin-text-body); }
|
|
74
|
+
.svadmin-image-preview__stage { position: relative; display: grid; place-items: center; aspect-ratio: 16 / 9; max-height: 70vh; background: var(--muted); border-radius: var(--radius-md); }
|
|
75
|
+
.svadmin-image-preview__stage img { max-width: 100%; max-height: 70vh; object-fit: contain; }
|
|
76
|
+
.svadmin-image-preview__prev { position: absolute; inset-inline-start: var(--svadmin-space-2); }
|
|
77
|
+
.svadmin-image-preview__next { position: absolute; inset-inline-end: var(--svadmin-space-2); }
|
|
78
|
+
.svadmin-image-preview__thumbs { display: flex; gap: var(--svadmin-space-2); padding-block-start: var(--svadmin-space-2); overflow-x: auto; }
|
|
79
|
+
.svadmin-image-preview__thumbs button { flex: 0 0 auto; width: 3.5rem; height: 3.5rem; padding: 0; border: 2px solid transparent; border-radius: var(--radius-sm); background: var(--muted); overflow: hidden; }
|
|
80
|
+
.svadmin-image-preview__thumbs button[aria-pressed='true'] { border-color: var(--primary); }
|
|
81
|
+
.svadmin-image-preview__thumbs img { width: 100%; height: 100%; object-fit: cover; }
|
|
82
|
+
.svadmin-image-preview__close { position: absolute; inset-block-start: var(--svadmin-space-2); inset-inline-end: var(--svadmin-space-2); }
|
|
83
|
+
</style>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface PreviewImage {
|
|
2
|
+
src: string;
|
|
3
|
+
alt: string;
|
|
4
|
+
}
|
|
5
|
+
interface Props {
|
|
6
|
+
src: string;
|
|
7
|
+
alt?: string;
|
|
8
|
+
images?: PreviewImage[];
|
|
9
|
+
open?: boolean;
|
|
10
|
+
class?: string;
|
|
11
|
+
}
|
|
12
|
+
declare const ImagePreview: import("svelte").Component<Props, {}, "open">;
|
|
13
|
+
type ImagePreview = ReturnType<typeof ImagePreview>;
|
|
14
|
+
export default ImagePreview;
|