@svadmin/ui 0.100.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.
Files changed (83) hide show
  1. package/README.md +1 -1
  2. package/dist/app.css +99 -0
  3. package/dist/app.theme.css +99 -0
  4. package/dist/components/AboutSettings.svelte +1 -1
  5. package/dist/components/AdminApp.svelte +13 -1
  6. package/dist/components/AdminApp.svelte.d.ts +7 -0
  7. package/dist/components/Affix.svelte +43 -0
  8. package/dist/components/Affix.svelte.d.ts +11 -0
  9. package/dist/components/Anchor.svelte +60 -0
  10. package/dist/components/Anchor.svelte.d.ts +14 -0
  11. package/dist/components/AutoTable.svelte +35 -16
  12. package/dist/components/AutoTable.svelte.d.ts +6 -0
  13. package/dist/components/Calendar.svelte +152 -0
  14. package/dist/components/Calendar.svelte.d.ts +20 -0
  15. package/dist/components/Carousel.svelte +107 -0
  16. package/dist/components/Carousel.svelte.d.ts +15 -0
  17. package/dist/components/Collapse.svelte +177 -0
  18. package/dist/components/Collapse.svelte.d.ts +32 -0
  19. package/dist/components/CommentThread.svelte +109 -0
  20. package/dist/components/CommentThread.svelte.d.ts +22 -0
  21. package/dist/components/CopyButton.svelte +148 -0
  22. package/dist/components/CopyButton.svelte.d.ts +19 -0
  23. package/dist/components/DataTableShell.svelte +140 -0
  24. package/dist/components/DataTableShell.svelte.d.ts +18 -0
  25. package/dist/components/Header.svelte +28 -0
  26. package/dist/components/Header.svelte.d.ts +8 -0
  27. package/dist/components/ImagePreview.svelte +83 -0
  28. package/dist/components/ImagePreview.svelte.d.ts +14 -0
  29. package/dist/components/Layout.svelte +86 -6
  30. package/dist/components/Layout.svelte.d.ts +6 -0
  31. package/dist/components/ListFooter.svelte +9 -3
  32. package/dist/components/ListFooter.svelte.d.ts +1 -0
  33. package/dist/components/ListPagination.svelte +25 -19
  34. package/dist/components/ListPagination.svelte.d.ts +4 -3
  35. package/dist/components/NotificationCenter.svelte +215 -0
  36. package/dist/components/NotificationCenter.svelte.d.ts +28 -0
  37. package/dist/components/ScrollableTable.svelte +211 -0
  38. package/dist/components/ScrollableTable.svelte.d.ts +14 -0
  39. package/dist/components/ThemeSettingsDrawer.svelte +212 -0
  40. package/dist/components/ThemeSettingsDrawer.svelte.d.ts +10 -0
  41. package/dist/components/TypographyEllipsis.svelte +123 -0
  42. package/dist/components/TypographyEllipsis.svelte.d.ts +18 -0
  43. package/dist/components/ViewModeToggle.svelte +47 -0
  44. package/dist/components/ViewModeToggle.svelte.d.ts +11 -0
  45. package/dist/components/list-i18n.d.ts +27 -0
  46. package/dist/components/list-i18n.js +53 -0
  47. package/dist/components/templates/AdvancedDetailTemplate.svelte +36 -0
  48. package/dist/components/templates/AdvancedDetailTemplate.svelte.d.ts +17 -0
  49. package/dist/components/templates/AdvancedFormTemplate.svelte +32 -0
  50. package/dist/components/templates/AdvancedFormTemplate.svelte.d.ts +15 -0
  51. package/dist/components/templates/AnalysisTemplate.svelte +34 -0
  52. package/dist/components/templates/AnalysisTemplate.svelte.d.ts +16 -0
  53. package/dist/components/templates/BasicDetailTemplate.svelte +32 -0
  54. package/dist/components/templates/BasicDetailTemplate.svelte.d.ts +15 -0
  55. package/dist/components/templates/CardListTemplate.svelte +29 -0
  56. package/dist/components/templates/CardListTemplate.svelte.d.ts +14 -0
  57. package/dist/components/templates/ExceptionTemplate.svelte +28 -0
  58. package/dist/components/templates/ExceptionTemplate.svelte.d.ts +11 -0
  59. package/dist/components/templates/GroupFormTemplate.svelte +30 -0
  60. package/dist/components/templates/GroupFormTemplate.svelte.d.ts +14 -0
  61. package/dist/components/templates/MonitorTemplate.svelte +39 -0
  62. package/dist/components/templates/MonitorTemplate.svelte.d.ts +15 -0
  63. package/dist/components/templates/ProfileTemplate.svelte +30 -0
  64. package/dist/components/templates/ProfileTemplate.svelte.d.ts +14 -0
  65. package/dist/components/templates/ResultTemplate.svelte +39 -0
  66. package/dist/components/templates/ResultTemplate.svelte.d.ts +14 -0
  67. package/dist/components/templates/SearchTableTemplate.svelte +31 -0
  68. package/dist/components/templates/SearchTableTemplate.svelte.d.ts +15 -0
  69. package/dist/components/templates/StepFormTemplate.svelte +62 -0
  70. package/dist/components/templates/StepFormTemplate.svelte.d.ts +23 -0
  71. package/dist/components/templates/TemplatePageShell.svelte +109 -0
  72. package/dist/components/templates/TemplatePageShell.svelte.d.ts +20 -0
  73. package/dist/components/templates/WorkplaceTemplate.svelte +34 -0
  74. package/dist/components/templates/WorkplaceTemplate.svelte.d.ts +16 -0
  75. package/dist/components/templates/index.d.ts +16 -0
  76. package/dist/components/templates/index.js +16 -0
  77. package/dist/design-system-components.d.ts +64 -0
  78. package/dist/design-system-components.js +72 -0
  79. package/dist/index.d.ts +23 -0
  80. package/dist/index.js +17 -0
  81. package/dist/ui-preferences.svelte.d.ts +19 -0
  82. package/dist/ui-preferences.svelte.js +69 -0
  83. 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,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;
@@ -28,6 +28,8 @@
28
28
  import { getComponentRegistry } from '../component-registry.svelte.js';
29
29
  import { Button } from './ui/button/index.js';
30
30
  import { cn } from '../utils.js';
31
+ import { uiPreferences } from '../ui-preferences.svelte.js';
32
+ import type { NotificationItem } from './NotificationCenter.svelte';
31
33
 
32
34
  const i18n = useTranslation();
33
35
 
@@ -42,6 +44,11 @@
42
44
  siteUrl?: string;
43
45
  routeMode?: 'hash' | 'path' | 'auto';
44
46
  aiAssistant?: Snippet<[LayoutAIAssistantProps]>;
47
+ notifications?: NotificationItem[];
48
+ notificationUnreadCount?: number;
49
+ onnotificationread?: (item: NotificationItem) => void | Promise<void>;
50
+ onnotificationreadall?: () => void | Promise<void>;
51
+ onnotificationopen?: (item: NotificationItem) => void | Promise<void>;
45
52
  class?: string;
46
53
  }
47
54
 
@@ -52,6 +59,11 @@
52
59
  siteUrl,
53
60
  routeMode = 'auto',
54
61
  aiAssistant,
62
+ notifications,
63
+ notificationUnreadCount,
64
+ onnotificationread,
65
+ onnotificationreadall,
66
+ onnotificationopen,
55
67
  class: className = '',
56
68
  }: Props = $props();
57
69
  const layoutId = $props.id();
@@ -59,6 +71,10 @@
59
71
  const mainContentId = `${layoutScope}-main`;
60
72
  const chatScope = `${layoutScope}-chat`;
61
73
  const adminContext = captureAdminContext();
74
+ const navigation = $derived(uiPreferences.navigation);
75
+ const showSidebar = $derived(navigation !== 'top');
76
+ const showTopNavigation = $derived(navigation === 'top' || navigation === 'mix');
77
+ const topLevelMenu = $derived((menu ?? []).filter((item) => !item.meta?.hidden));
62
78
 
63
79
  const auth = $derived(adminContext.authProvider);
64
80
  let loading = $state(true);
@@ -202,6 +218,8 @@
202
218
  data-svadmin-layout-scope={layoutScope}
203
219
  data-svadmin-layout
204
220
  data-svadmin-layout-state="ready"
221
+ data-svadmin-navigation={navigation}
222
+ data-svadmin-content-width={uiPreferences.contentWidth}
205
223
  aria-busy="false"
206
224
  class={cn('svadmin-u-60fbb7713999 svadmin-u-ef114b5f5ad1 svadmin-u-e6f9e383a762', className)}
207
225
  in:fade={{ duration: 200, delay: 50 }}
@@ -216,9 +234,11 @@
216
234
  </button>
217
235
 
218
236
  <!-- Desktop sidebar -->
219
- <div class="svadmin-u-99d72c7fc3e2 svadmin-u-9d60be3a6d80">
220
- <Sidebar {collapsed} {identity} {title} {...definedOptions({ "menu": menu })} {routeMode} onToggle={() => collapsed = !collapsed} onLogout={handleLogout} />
221
- </div>
237
+ {#if showSidebar}
238
+ <div class="svadmin-u-99d72c7fc3e2 svadmin-u-9d60be3a6d80">
239
+ <Sidebar {collapsed} {identity} {title} {...definedOptions({ "menu": menu })} {routeMode} onToggle={() => collapsed = !collapsed} onLogout={handleLogout} />
240
+ </div>
241
+ {/if}
222
242
 
223
243
  <!-- Mobile sidebar via Sheet -->
224
244
  <Sheet.Root
@@ -247,6 +267,11 @@
247
267
  {...definedOptions({ "menu": menu })}
248
268
  showSearch={true}
249
269
  showThemeToggle={true}
270
+ notificationItems={notifications ?? []}
271
+ {...(notificationUnreadCount === undefined ? {} : { notificationUnreadCount })}
272
+ {...(onnotificationread ? { onnotificationread } : {})}
273
+ {...(onnotificationreadall ? { onnotificationreadall } : {})}
274
+ {...(onnotificationopen ? { onnotificationopen } : {})}
250
275
  onSearchClick={() => { commandOpen = true; }}
251
276
  >
252
277
  {#snippet children()}
@@ -272,15 +297,32 @@
272
297
  {/snippet}
273
298
  </Header>
274
299
 
300
+ {#if showTopNavigation}
301
+ <nav class="svadmin-top-navigation" aria-label={title}>
302
+ {#each topLevelMenu as item (item.name)}
303
+ {@const active = item.href ? getPath().startsWith(item.href) : false}
304
+ <a class="svadmin-top-navigation__item" class:is-active={active} href={item.href ?? '#'}>
305
+ {item.label ?? i18n.t(`menu.${item.name}`)}
306
+ </a>
307
+ {/each}
308
+ </nav>
309
+ {/if}
310
+
275
311
  <!-- Content area: responsive padding + centered max-width container
276
312
  so wide screens don't stretch content indefinitely (avoids sparse layouts) -->
277
313
  <main id={mainContentId} tabindex="-1" data-svadmin-main data-svadmin-layout-content class="svadmin-u-36e579c0b41c svadmin-u-92bf82f493b1 svadmin-u-2859c861d7de svadmin-u-f0faeb26d656 svadmin-u-c9b99cd93450 svadmin-u-cc06a6575385 svadmin-u-daf5dc5fac2b svadmin-u-e86fadb84483">
278
314
  <div class="svadmin-u-0e12dc7de920 svadmin-u-6da6a3c3f741 svadmin-u-9e3dc30c26a3">
279
315
  {#key getPath()}
280
316
  <!-- 路由切换立即释放旧页面,避免退出期间继续读取已失效的路由派生状态。 -->
281
- <div in:fly={{ x: 20, duration: 150 }}>
282
- {@render children()}
283
- </div>
317
+ {#if uiPreferences.pageTransition && uiPreferences.motion !== 'reduced'}
318
+ <div in:fly={{ x: 20, duration: 150 }}>
319
+ {@render children()}
320
+ </div>
321
+ {:else}
322
+ <div>
323
+ {@render children()}
324
+ </div>
325
+ {/if}
284
326
  {/key}
285
327
  </div>
286
328
  </main>
@@ -297,3 +339,41 @@
297
339
  />
298
340
  <KeyboardShortcuts bind:open={shortcutsOpen} />
299
341
  {/if}
342
+
343
+ <style>
344
+ .svadmin-top-navigation {
345
+ display: flex;
346
+ align-items: center;
347
+ gap: var(--svadmin-space-1);
348
+ min-width: 0;
349
+ padding: var(--svadmin-space-2) var(--svadmin-space-5);
350
+ overflow-x: auto;
351
+ border-block-end: 1px solid var(--border);
352
+ background: var(--background);
353
+ }
354
+ .svadmin-top-navigation__item {
355
+ flex: 0 0 auto;
356
+ padding: var(--svadmin-space-2) var(--svadmin-space-3);
357
+ border-radius: var(--radius-sm);
358
+ color: var(--muted-foreground);
359
+ font-size: var(--svadmin-text-label);
360
+ font-weight: 500;
361
+ text-decoration: none;
362
+ white-space: nowrap;
363
+ }
364
+ .svadmin-top-navigation__item:hover {
365
+ background: var(--accent);
366
+ color: var(--accent-foreground);
367
+ }
368
+ .svadmin-top-navigation__item.is-active {
369
+ background: var(--accent);
370
+ color: var(--accent-foreground);
371
+ font-weight: 600;
372
+ }
373
+ :global([data-svadmin-layout][data-svadmin-content-width='fluid']) :global([data-svadmin-main] > div) {
374
+ max-width: none;
375
+ }
376
+ :global([data-svadmin-layout][data-svadmin-content-width='wide']) :global([data-svadmin-main] > div) {
377
+ max-width: 92rem;
378
+ }
379
+ </style>
@@ -5,6 +5,7 @@ export interface LayoutAIAssistantProps {
5
5
  }
6
6
  import type { Snippet } from 'svelte';
7
7
  import type { MenuItem } from '@svadmin/core';
8
+ import type { NotificationItem } from './NotificationCenter.svelte';
8
9
  interface Props {
9
10
  children: Snippet;
10
11
  title?: string;
@@ -12,6 +13,11 @@ interface Props {
12
13
  siteUrl?: string;
13
14
  routeMode?: 'hash' | 'path' | 'auto';
14
15
  aiAssistant?: Snippet<[LayoutAIAssistantProps]>;
16
+ notifications?: NotificationItem[];
17
+ notificationUnreadCount?: number;
18
+ onnotificationread?: (item: NotificationItem) => void | Promise<void>;
19
+ onnotificationreadall?: () => void | Promise<void>;
20
+ onnotificationopen?: (item: NotificationItem) => void | Promise<void>;
15
21
  class?: string;
16
22
  }
17
23
  declare const Layout: import("svelte").Component<Props, {}, "">;