@svadmin/ui 0.128.0 → 0.130.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 (51) hide show
  1. package/dist/app.css +156 -36
  2. package/dist/app.theme.css +156 -36
  3. package/dist/components/AboutSettings.svelte +1 -1
  4. package/dist/components/AppFooter.svelte +1 -1
  5. package/dist/components/BoundRecordDetailDrawer.svelte +1 -1
  6. package/dist/components/CodeEditor.svelte +1 -1
  7. package/dist/components/ColorPicker.svelte +2 -2
  8. package/dist/components/FeatureFlagStudio.svelte +583 -0
  9. package/dist/components/FeatureFlagStudio.svelte.d.ts +12 -0
  10. package/dist/components/FloatButton.svelte +1 -1
  11. package/dist/components/HotkeysHelpModal.svelte +286 -0
  12. package/dist/components/HotkeysHelpModal.svelte.d.ts +21 -0
  13. package/dist/components/JsonEditor.svelte +1 -1
  14. package/dist/components/ListPagination.svelte +19 -12
  15. package/dist/components/MediaGallery.svelte +575 -0
  16. package/dist/components/MediaGallery.svelte.d.ts +34 -0
  17. package/dist/components/Menu.svelte +6 -6
  18. package/dist/components/NotificationCenter.svelte +20 -1
  19. package/dist/components/NotificationCenter.svelte.d.ts +2 -0
  20. package/dist/components/NotificationDrawer.svelte +242 -0
  21. package/dist/components/NotificationDrawer.svelte.d.ts +40 -0
  22. package/dist/components/NotificationHost.svelte +1 -1
  23. package/dist/components/PhoneInput.svelte +1 -1
  24. package/dist/components/RadioGroup.svelte +8 -0
  25. package/dist/components/Rate.svelte +2 -2
  26. package/dist/components/RelationPicker.svelte +2 -2
  27. package/dist/components/ResizableGrid.svelte +1 -1
  28. package/dist/components/ResizableSplitter.svelte +246 -0
  29. package/dist/components/ResizableSplitter.svelte.d.ts +18 -0
  30. package/dist/components/ResizeBox.svelte +1 -1
  31. package/dist/components/SegmentedControl.svelte +2 -2
  32. package/dist/components/Steps.svelte +12 -11
  33. package/dist/components/SvarDataGrid.svelte +1 -1
  34. package/dist/components/SvarResourceTableView.svelte +3 -3
  35. package/dist/components/Tag.svelte +5 -4
  36. package/dist/components/TagsInput.svelte +2 -2
  37. package/dist/components/Tour.svelte +1 -1
  38. package/dist/components/Tree.svelte +1 -1
  39. package/dist/components/TreeSelect.svelte +2 -2
  40. package/dist/components/TypographyEllipsis.svelte +1 -1
  41. package/dist/components/TypographyText.svelte +2 -2
  42. package/dist/components/ViewModeToggle.svelte +1 -1
  43. package/dist/components/ui/alert/alert.svelte +1 -1
  44. package/dist/components/ui/tooltip/tooltip-content.svelte +2 -2
  45. package/dist/components/useFeatureFlag.d.svelte.ts +1 -0
  46. package/dist/components/useFeatureFlag.svelte.d.ts +45 -0
  47. package/dist/components/useFeatureFlag.svelte.js +94 -0
  48. package/dist/index.d.ts +6 -0
  49. package/dist/index.js +9 -0
  50. package/dist/styles/recipes.css +4 -4
  51. package/package.json +1 -1
@@ -0,0 +1,575 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+ import * as Dialog from './ui/dialog/index.js';
4
+
5
+ export interface MediaGalleryItem {
6
+ id: string | number;
7
+ src: string;
8
+ thumbSrc?: string;
9
+ type?: 'image' | 'video' | 'audio' | 'document';
10
+ title?: string;
11
+ description?: string;
12
+ size?: string;
13
+ dimensions?: string;
14
+ uploadDate?: string;
15
+ uploader?: string;
16
+ metadata?: Record<string, string>;
17
+ }
18
+
19
+ export interface MediaGalleryProps {
20
+ items: MediaGalleryItem[];
21
+ maxDisplay?: number;
22
+ gridCols?: 2 | 3 | 4 | 6;
23
+ watermarkText?: string;
24
+ enableZoom?: boolean;
25
+ enableRotate?: boolean;
26
+ enableDownload?: boolean;
27
+ enableMetadataDrawer?: boolean;
28
+ class?: string;
29
+ onItemClick?: (item: MediaGalleryItem, index: number) => void;
30
+ onDownload?: (item: MediaGalleryItem) => void;
31
+ customThumbnail?: Snippet<[{ item: MediaGalleryItem; index: number }]>;
32
+ }
33
+
34
+ const {
35
+ items = [],
36
+ maxDisplay = 9,
37
+ gridCols = 3,
38
+ watermarkText = '',
39
+ enableZoom = true,
40
+ enableRotate = true,
41
+ enableDownload = true,
42
+ enableMetadataDrawer = true,
43
+ class: className = '',
44
+ onItemClick,
45
+ onDownload,
46
+ customThumbnail,
47
+ }: MediaGalleryProps = $props();
48
+
49
+ let activeId = $state<MediaGalleryItem['id'] | null>(null);
50
+ const activeIndex = $derived(activeId === null ? null : items.findIndex(item => item.id === activeId));
51
+ let showDrawer = $state<boolean>(false);
52
+ let scale = $state<number>(1);
53
+ let rotate = $state<number>(0);
54
+ let translateX = $state<number>(0);
55
+ let translateY = $state<number>(0);
56
+ let isDragging = $state<boolean>(false);
57
+ let startX = $state<number>(0);
58
+ let startY = $state<number>(0);
59
+
60
+ const displayItems = $derived(
61
+ items.length <= maxDisplay ? items : items.slice(0, maxDisplay)
62
+ );
63
+
64
+ const hiddenCount = $derived(
65
+ items.length <= maxDisplay ? 0 : items.length - maxDisplay
66
+ );
67
+
68
+ const currentItem = $derived<MediaGalleryItem | null>(
69
+ activeIndex !== null && activeIndex >= 0 && activeIndex < items.length
70
+ ? items[activeIndex] ?? null
71
+ : null
72
+ );
73
+
74
+ $effect(() => {
75
+ if (activeIndex === -1) closeLightbox();
76
+ });
77
+
78
+ const gridClass = $derived(
79
+ gridCols === 2
80
+ ? 'grid-cols-2'
81
+ : gridCols === 4
82
+ ? 'grid-cols-2 sm:grid-cols-3 md:grid-cols-4'
83
+ : gridCols === 6
84
+ ? 'grid-cols-3 sm:grid-cols-4 md:grid-cols-6'
85
+ : 'grid-cols-2 sm:grid-cols-3'
86
+ );
87
+
88
+ function openLightbox(index: number) {
89
+ activeId = items[index]?.id ?? null;
90
+ scale = 1;
91
+ rotate = 0;
92
+ translateX = 0;
93
+ translateY = 0;
94
+ const item = items[index];
95
+ if (item) {
96
+ onItemClick?.(item, index);
97
+ }
98
+ }
99
+
100
+ function closeLightbox() {
101
+ activeId = null;
102
+ scale = 1;
103
+ rotate = 0;
104
+ translateX = 0;
105
+ translateY = 0;
106
+ showDrawer = false;
107
+ isDragging = false;
108
+ }
109
+
110
+ function prevItem() {
111
+ if (activeIndex === null || items.length === 0) return;
112
+ activeId = items[(activeIndex - 1 + items.length) % items.length]?.id ?? null;
113
+ scale = 1;
114
+ rotate = 0;
115
+ translateX = 0;
116
+ translateY = 0;
117
+ }
118
+
119
+ function nextItem() {
120
+ if (activeIndex === null || items.length === 0) return;
121
+ activeId = items[(activeIndex + 1) % items.length]?.id ?? null;
122
+ scale = 1;
123
+ rotate = 0;
124
+ translateX = 0;
125
+ translateY = 0;
126
+ }
127
+
128
+ function zoomIn() {
129
+ if (!enableZoom) return;
130
+ scale = Math.min(5, Number((scale + 0.25).toFixed(2)));
131
+ }
132
+
133
+ function zoomOut() {
134
+ if (!enableZoom) return;
135
+ scale = Math.max(0.2, Number((scale - 0.25).toFixed(2)));
136
+ }
137
+
138
+ function resetZoom() {
139
+ scale = 1;
140
+ rotate = 0;
141
+ translateX = 0;
142
+ translateY = 0;
143
+ }
144
+
145
+ function rotateLeft() {
146
+ if (!enableRotate) return;
147
+ rotate = (rotate - 90) % 360;
148
+ }
149
+
150
+ function rotateRight() {
151
+ if (!enableRotate) return;
152
+ rotate = (rotate + 90) % 360;
153
+ }
154
+
155
+ function handleWheel(e: WheelEvent) {
156
+ if (!enableZoom || activeIndex === null || (currentItem?.type && currentItem.type !== 'image')) return;
157
+ e.preventDefault();
158
+ if (e.deltaY < 0) {
159
+ zoomIn();
160
+ } else {
161
+ zoomOut();
162
+ }
163
+ }
164
+
165
+ function handleMouseDown(e: MouseEvent) {
166
+ if (e.button !== 0 || scale <= 1 || (currentItem?.type && currentItem.type !== 'image')) return;
167
+ isDragging = true;
168
+ startX = e.clientX - translateX;
169
+ startY = e.clientY - translateY;
170
+ }
171
+
172
+ function handleMouseMove(e: MouseEvent) {
173
+ if (!isDragging) return;
174
+ translateX = e.clientX - startX;
175
+ translateY = e.clientY - startY;
176
+ }
177
+
178
+ function handleMouseUp() {
179
+ isDragging = false;
180
+ }
181
+
182
+ function handleKeyDown(e: KeyboardEvent) {
183
+ if (activeIndex === null || e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey || e.isComposing) return;
184
+ const target = e.target;
185
+ if (target instanceof Element && target.closest('video, audio, input, textarea, select, [contenteditable="true"]')) return;
186
+ if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') {
187
+ e.preventDefault();
188
+ if (e.key === 'ArrowLeft') prevItem();
189
+ else nextItem();
190
+ }
191
+ }
192
+ function downloadUrl(src: string): string | undefined {
193
+ try {
194
+ const url = new URL(src, typeof document === 'undefined' ? 'https://svadmin.invalid' : document.baseURI);
195
+ return ['http:', 'https:', 'blob:'].includes(url.protocol) ? url.href : undefined;
196
+ } catch { return undefined; }
197
+ }
198
+
199
+ function handleDownloadClick(item: MediaGalleryItem) {
200
+ if (!enableDownload) return;
201
+ if (onDownload) {
202
+ onDownload(item);
203
+ return;
204
+ }
205
+ const href = downloadUrl(item.src);
206
+ if (!href) return;
207
+ const a = document.createElement('a');
208
+ a.href = href;
209
+ a.download = item.title || `media-${item.id}`;
210
+ document.body.appendChild(a);
211
+ a.click();
212
+ document.body.removeChild(a);
213
+ }
214
+ </script>
215
+
216
+ <svelte:window onmouseup={handleMouseUp} onmousemove={handleMouseMove} />
217
+
218
+ <div
219
+ class="media-gallery relative w-full {className}"
220
+ data-svadmin-component="MediaGallery"
221
+ >
222
+ <!-- Grid thumbnails -->
223
+ <div class="grid gap-3.5 {gridClass}">
224
+ {#each displayItems as item, idx (item.id)}
225
+ {@const isLastWithMore = idx === maxDisplay - 1 && hiddenCount > 0}
226
+ <button
227
+ type="button"
228
+ aria-label={item.title || `预览媒体 ${item.id}`}
229
+ class="group relative aspect-video cursor-pointer overflow-hidden rounded-xl border border-border bg-muted/30 shadow-xs transition-all hover:border-primary/50 hover:shadow-md"
230
+ onclick={() => openLightbox(idx)}
231
+ >
232
+ {#if customThumbnail}
233
+ {@render customThumbnail({ item, index: idx })}
234
+ {:else if item.type === 'video'}
235
+ <div class="flex h-full w-full items-center justify-center bg-card">
236
+ <span class="flex h-10 w-10 items-center justify-center rounded-full bg-primary/20 text-primary">
237
+ <svg class="h-5 w-5 fill-current" viewBox="0 0 24 24"><path d="M8 5v14l11-7z" /></svg>
238
+ </span>
239
+ </div>
240
+ {:else if item.type === 'audio'}
241
+ <div class="flex h-full w-full flex-col items-center justify-center bg-card p-3 text-center">
242
+ <span class="flex h-10 w-10 items-center justify-center rounded-full bg-primary/20 text-primary">
243
+ <svg class="h-5 w-5 stroke-current" fill="none" viewBox="0 0 24 24" stroke-width="2">
244
+ <path stroke-linecap="round" stroke-linejoin="round" d="M9 19V6l12-3v13M9 19c0 1.105-1.343 2-3 2s-3-.895-3-2 1.343-2 3-2 3 .895 3 2zm12-3c0 1.105-1.343 2-3 2s-3-.895-3-2 1.343-2 3-2 3 .895 3 2zM9 10l12-3" />
245
+ </svg>
246
+ </span>
247
+ <span class="mt-2 line-clamp-1 text-xs font-medium text-foreground">{item.title || '音频文件'}</span>
248
+ </div>
249
+ {:else if item.type === 'document'}
250
+ <div class="flex h-full w-full flex-col items-center justify-center bg-card p-3 text-center">
251
+ <span class="flex h-10 w-10 items-center justify-center rounded-full bg-muted text-muted-foreground">
252
+ <svg class="h-5 w-5 stroke-current" fill="none" viewBox="0 0 24 24" stroke-width="2">
253
+ <path stroke-linecap="round" stroke-linejoin="round" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z" />
254
+ </svg>
255
+ </span>
256
+ <span class="mt-2 line-clamp-1 text-xs font-medium text-foreground">{item.title || '文档'}</span>
257
+ </div>
258
+ {:else}
259
+ <img
260
+ src={item.thumbSrc || item.src}
261
+ alt={item.title || '媒体文件'}
262
+ loading="lazy"
263
+ class="h-full w-full object-cover transition-transform duration-300 group-hover:scale-105"
264
+ />
265
+ {/if}
266
+
267
+ <!-- Hover caption badge -->
268
+ {#if item.title && !isLastWithMore}
269
+ <div class="pointer-events-none absolute inset-x-0 bottom-0 bg-gradient-to-t from-background/90 via-background/40 to-transparent p-2 pt-6 opacity-0 transition-opacity duration-200 group-hover:opacity-100">
270
+ <p class="truncate text-xs font-medium text-foreground">{item.title}</p>
271
+ </div>
272
+ {/if}
273
+
274
+ <!-- Overflow Badge -->
275
+ {#if isLastWithMore}
276
+ <div class="absolute inset-0 flex items-center justify-center bg-background/80 backdrop-blur-xs">
277
+ <span class="text-xl font-bold tracking-tight text-primary">+{hiddenCount + 1}</span>
278
+ </div>
279
+ {/if}
280
+ </button>
281
+ {/each}
282
+ </div>
283
+
284
+ <!-- Lightbox Modal -->
285
+ <Dialog.Root open={currentItem !== null} onOpenChange={(value) => { if (!value) closeLightbox(); }}>
286
+ {#if activeIndex !== null && currentItem}
287
+ {@const item = currentItem}
288
+ <Dialog.Content
289
+ showCloseButton={false}
290
+ class="flex flex-col bg-background/95 backdrop-blur-md"
291
+ style="inset: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none; transform: none; padding: 0; gap: 0; border-radius: 0;"
292
+ onkeydown={handleKeyDown}
293
+ >
294
+ <!-- Watermark Protection Layer -->
295
+ {#if watermarkText}
296
+ <div class="pointer-events-none absolute inset-0 select-none overflow-hidden opacity-10">
297
+ <div class="grid h-full w-full grid-cols-3 items-center justify-items-center gap-12 p-8 sm:grid-cols-4">
298
+ {#each Array(16) as _, i (i)}
299
+ <div class="rotate-[-25deg] text-base font-semibold tracking-widest text-foreground">
300
+ {watermarkText}
301
+ </div>
302
+ {/each}
303
+ </div>
304
+ </div>
305
+ {/if}
306
+
307
+ <!-- Top Toolbar -->
308
+ <div class="relative z-10 flex h-14 shrink-0 items-center justify-between border-b border-border/60 px-4">
309
+ <!-- Title & Counter -->
310
+ <div class="flex items-center gap-3">
311
+ <span class="text-xs font-semibold tabular-nums text-muted-foreground">
312
+ {activeIndex + 1} / {items.length}
313
+ </span>
314
+ <Dialog.Title class="max-w-[200px] truncate text-sm font-medium text-foreground sm:max-w-md">
315
+ {item.title || `媒体资源 #${item.id}`}
316
+ </Dialog.Title>
317
+ <Dialog.Description class="sr-only">媒体预览,可查看详情并切换资源</Dialog.Description>
318
+ </div>
319
+
320
+ <!-- Controls -->
321
+ <div class="flex items-center gap-1 sm:gap-2">
322
+ {#if enableZoom && item.type !== 'video' && item.type !== 'audio' && item.type !== 'document'}
323
+ <button
324
+ type="button"
325
+ class="flex h-8 w-8 items-center justify-center rounded-lg text-muted-foreground hover:bg-muted hover:text-foreground"
326
+ title="缩小 (Zoom Out)"
327
+ onclick={zoomOut}
328
+ >
329
+ <svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M20 12H4" /></svg>
330
+ </button>
331
+ <button
332
+ type="button"
333
+ class="px-1.5 py-1 text-xs font-mono font-medium text-muted-foreground hover:text-foreground"
334
+ title="双击或点击复位 (Reset)"
335
+ onclick={resetZoom}
336
+ >
337
+ {Math.round(scale * 100)}%
338
+ </button>
339
+ <button
340
+ type="button"
341
+ class="flex h-8 w-8 items-center justify-center rounded-lg text-muted-foreground hover:bg-muted hover:text-foreground"
342
+ title="放大 (Zoom In)"
343
+ onclick={zoomIn}
344
+ >
345
+ <svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M12 4v16m8-8H4" /></svg>
346
+ </button>
347
+ {/if}
348
+
349
+ {#if enableRotate && item.type !== 'video' && item.type !== 'audio' && item.type !== 'document'}
350
+ <div class="h-4 w-px bg-border"></div>
351
+ <button
352
+ type="button"
353
+ class="flex h-8 w-8 items-center justify-center rounded-lg text-muted-foreground hover:bg-muted hover:text-foreground"
354
+ title="向左旋转 90°"
355
+ onclick={rotateLeft}
356
+ >
357
+ <svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M3 10h10a5 5 0 015 5v2m-15-7l4-4m-4 4l4 4" /></svg>
358
+ </button>
359
+ <button
360
+ type="button"
361
+ class="flex h-8 w-8 items-center justify-center rounded-lg text-muted-foreground hover:bg-muted hover:text-foreground"
362
+ title="向右旋转 90°"
363
+ onclick={rotateRight}
364
+ >
365
+ <svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M21 10H11a5 5 0 00-5 5v2m15-7l-4-4m4 4l-4 4" /></svg>
366
+ </button>
367
+ {/if}
368
+
369
+ {#if enableDownload}
370
+ <button
371
+ type="button"
372
+ class="flex h-8 w-8 items-center justify-center rounded-lg text-muted-foreground hover:bg-muted hover:text-foreground"
373
+ title="下载文件"
374
+ disabled={!onDownload && !downloadUrl(item.src)}
375
+ onclick={() => handleDownloadClick(item)}
376
+ >
377
+ <svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" /></svg>
378
+ </button>
379
+ {/if}
380
+
381
+ {#if enableMetadataDrawer}
382
+ <button
383
+ type="button"
384
+ class="flex h-8 w-8 items-center justify-center rounded-lg transition-colors {showDrawer ? 'bg-primary/10 text-primary' : 'text-muted-foreground hover:bg-muted hover:text-foreground'}"
385
+ title="详情信息"
386
+ onclick={() => (showDrawer = !showDrawer)}
387
+ >
388
+ <svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>
389
+ </button>
390
+ {/if}
391
+
392
+ <div class="h-4 w-px bg-border"></div>
393
+
394
+ <button
395
+ type="button"
396
+ class="flex h-8 w-8 items-center justify-center rounded-lg text-muted-foreground hover:bg-destructive/10 hover:text-destructive"
397
+ title="关闭 (Esc)"
398
+ onclick={closeLightbox}
399
+ >
400
+ <svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" /></svg>
401
+ </button>
402
+ </div>
403
+ </div>
404
+
405
+ <!-- Main Stage Area -->
406
+ <div class="relative flex flex-1 items-stretch overflow-hidden">
407
+ <!-- Navigation Prev -->
408
+ {#if items.length > 1}
409
+ <button
410
+ type="button"
411
+ class="absolute left-4 top-1/2 z-20 -translate-y-1/2 flex h-10 w-10 items-center justify-center rounded-full border border-border bg-background/80 text-foreground shadow-md backdrop-blur-xs transition-all hover:bg-background hover:scale-105 active:scale-95"
412
+ title="上一张 (←)"
413
+ onclick={prevItem}
414
+ >
415
+ <svg class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M15 19l-7-7 7-7" /></svg>
416
+ </button>
417
+ {/if}
418
+
419
+ <!-- Center Viewport -->
420
+ <!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
421
+ <div
422
+ class="relative flex flex-1 items-center justify-center overflow-hidden p-4 select-none"
423
+ onwheel={handleWheel}
424
+ onmousedown={handleMouseDown}
425
+ ondblclick={resetZoom}
426
+ role="region"
427
+ aria-label="媒体视口"
428
+ >
429
+ {#if item.type === 'video'}
430
+ <!-- svelte-ignore a11y_media_has_caption -->
431
+ <video
432
+ src={item.src}
433
+ controls
434
+ autoplay
435
+ class="max-h-[85vh] max-w-full rounded-lg shadow-xl"
436
+ ></video>
437
+ {:else if item.type === 'audio'}
438
+ <div class="flex flex-col items-center gap-6 rounded-2xl border border-border bg-card p-8 shadow-xl">
439
+ <span class="flex h-20 w-20 items-center justify-center rounded-full bg-primary/20 text-primary">
440
+ <svg class="h-10 w-10 stroke-current" fill="none" viewBox="0 0 24 24" stroke-width="2">
441
+ <path stroke-linecap="round" stroke-linejoin="round" d="M9 19V6l12-3v13M9 19c0 1.105-1.343 2-3 2s-3-.895-3-2 1.343-2 3-2 3 .895 3 2zm12-3c0 1.105-1.343 2-3 2s-3-.895-3-2 1.343-2 3-2 3 .895 3 2zM9 10l12-3" />
442
+ </svg>
443
+ </span>
444
+ <div class="text-center">
445
+ <h4 class="text-base font-semibold text-foreground">{item.title || '音频'}</h4>
446
+ <p class="text-xs text-muted-foreground">{item.uploader || '企业多媒体'}</p>
447
+ </div>
448
+ <audio src={item.src} controls class="w-72 sm:w-80"></audio>
449
+ </div>
450
+ {:else if item.type === 'document'}
451
+ <div class="flex flex-col items-center gap-4 rounded-2xl border border-border bg-card p-10 text-center shadow-xl">
452
+ <span class="flex h-20 w-20 items-center justify-center rounded-full bg-muted text-muted-foreground">
453
+ <svg class="h-10 w-10 stroke-current" fill="none" viewBox="0 0 24 24" stroke-width="2">
454
+ <path stroke-linecap="round" stroke-linejoin="round" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z" />
455
+ </svg>
456
+ </span>
457
+ <h4 class="text-base font-semibold text-foreground">{item.title || '文档文件'}</h4>
458
+ <p class="text-xs text-muted-foreground">该文件暂不支持内嵌预览,请下载查看</p>
459
+ {#if enableDownload}
460
+ <button
461
+ type="button"
462
+ disabled={!onDownload && !downloadUrl(item.src)}
463
+ class="mt-2 inline-flex items-center gap-2 rounded-lg bg-primary px-4 py-2 text-xs font-medium text-primary-foreground hover:bg-primary/90"
464
+ onclick={() => handleDownloadClick(item)}
465
+ >
466
+ 下载此文档
467
+ </button>
468
+ {/if}
469
+ </div>
470
+ {:else}
471
+ <!-- Image with interactive scale & rotate -->
472
+ <img
473
+ src={item.src}
474
+ alt={item.title || '媒体大图'}
475
+ class="max-h-[85vh] max-w-full rounded-md shadow-2xl transition-transform duration-75 {isDragging ? 'cursor-grabbing' : scale > 1 ? 'cursor-grab' : 'cursor-default'}"
476
+ style="transform: translate({translateX}px, {translateY}px) scale({scale}) rotate({rotate}deg);"
477
+ draggable="false"
478
+ />
479
+ {/if}
480
+ </div>
481
+
482
+ <!-- Navigation Next -->
483
+ {#if items.length > 1}
484
+ <button
485
+ type="button"
486
+ class="absolute right-4 top-1/2 z-20 -translate-y-1/2 flex h-10 w-10 items-center justify-center rounded-full border border-border bg-background/80 text-foreground shadow-md backdrop-blur-xs transition-all hover:bg-background hover:scale-105 active:scale-95"
487
+ title="下一张 (→)"
488
+ onclick={nextItem}
489
+ >
490
+ <svg class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M9 5l7 7-7 7" /></svg>
491
+ </button>
492
+ {/if}
493
+
494
+ <!-- Right Metadata Drawer -->
495
+ {#if showDrawer}
496
+ <aside class="relative z-20 flex w-72 sm:w-80 flex-col border-l border-border bg-card/95 p-4 backdrop-blur-sm transition-all duration-200">
497
+ <div class="mb-4 flex items-center justify-between border-b border-border/60 pb-3">
498
+ <h3 class="text-sm font-semibold text-foreground">资源元数据</h3>
499
+ <button
500
+ type="button"
501
+ class="rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground"
502
+ aria-label="关闭信息抽屉"
503
+ onclick={() => (showDrawer = false)}
504
+ >
505
+ <svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" /></svg>
506
+ </button>
507
+ </div>
508
+
509
+ <div class="flex-1 space-y-4 overflow-y-auto text-xs">
510
+ <div>
511
+ <span class="text-muted-foreground">文件名称</span>
512
+ <p class="mt-0.5 break-all font-medium text-foreground">{item.title || `媒体 #${item.id}`}</p>
513
+ </div>
514
+
515
+ {#if item.description}
516
+ <div>
517
+ <span class="text-muted-foreground">详细说明</span>
518
+ <p class="mt-0.5 text-foreground">{item.description}</p>
519
+ </div>
520
+ {/if}
521
+
522
+ <div>
523
+ <span class="text-muted-foreground">资源类型</span>
524
+ <p class="mt-0.5 font-medium uppercase text-foreground">{item.type || 'IMAGE'}</p>
525
+ </div>
526
+
527
+ {#if item.dimensions}
528
+ <div>
529
+ <span class="text-muted-foreground">图像分辨率</span>
530
+ <p class="mt-0.5 font-mono text-foreground">{item.dimensions}</p>
531
+ </div>
532
+ {/if}
533
+
534
+ {#if item.size}
535
+ <div>
536
+ <span class="text-muted-foreground">文件大小</span>
537
+ <p class="mt-0.5 font-mono text-foreground">{item.size}</p>
538
+ </div>
539
+ {/if}
540
+
541
+ {#if item.uploadDate}
542
+ <div>
543
+ <span class="text-muted-foreground">上传时间</span>
544
+ <p class="mt-0.5 font-mono text-foreground">{item.uploadDate}</p>
545
+ </div>
546
+ {/if}
547
+
548
+ {#if item.uploader}
549
+ <div>
550
+ <span class="text-muted-foreground">操作人员</span>
551
+ <p class="mt-0.5 text-foreground">{item.uploader}</p>
552
+ </div>
553
+ {/if}
554
+
555
+ {#if item.metadata && Object.keys(item.metadata).length > 0}
556
+ <div class="border-t border-border/60 pt-3">
557
+ <span class="font-medium text-foreground">自定义扩展属性</span>
558
+ <dl class="mt-2 space-y-1.5">
559
+ {#each Object.entries(item.metadata) as [k, v] (k)}
560
+ <div class="flex justify-between gap-2">
561
+ <dt class="text-muted-foreground">{k}:</dt>
562
+ <dd class="truncate font-mono text-foreground" title={String(v)}>{String(v)}</dd>
563
+ </div>
564
+ {/each}
565
+ </dl>
566
+ </div>
567
+ {/if}
568
+ </div>
569
+ </aside>
570
+ {/if}
571
+ </div>
572
+ </Dialog.Content>
573
+ {/if}
574
+ </Dialog.Root>
575
+ </div>
@@ -0,0 +1,34 @@
1
+ import type { Snippet } from 'svelte';
2
+ export interface MediaGalleryItem {
3
+ id: string | number;
4
+ src: string;
5
+ thumbSrc?: string;
6
+ type?: 'image' | 'video' | 'audio' | 'document';
7
+ title?: string;
8
+ description?: string;
9
+ size?: string;
10
+ dimensions?: string;
11
+ uploadDate?: string;
12
+ uploader?: string;
13
+ metadata?: Record<string, string>;
14
+ }
15
+ export interface MediaGalleryProps {
16
+ items: MediaGalleryItem[];
17
+ maxDisplay?: number;
18
+ gridCols?: 2 | 3 | 4 | 6;
19
+ watermarkText?: string;
20
+ enableZoom?: boolean;
21
+ enableRotate?: boolean;
22
+ enableDownload?: boolean;
23
+ enableMetadataDrawer?: boolean;
24
+ class?: string;
25
+ onItemClick?: (item: MediaGalleryItem, index: number) => void;
26
+ onDownload?: (item: MediaGalleryItem) => void;
27
+ customThumbnail?: Snippet<[{
28
+ item: MediaGalleryItem;
29
+ index: number;
30
+ }]>;
31
+ }
32
+ declare const MediaGallery: import("svelte").Component<MediaGalleryProps, {}, "">;
33
+ type MediaGallery = ReturnType<typeof MediaGallery>;
34
+ export default MediaGallery;
@@ -190,7 +190,7 @@
190
190
  align-items: center;
191
191
  gap: var(--svadmin-space-2);
192
192
  width: 100%;
193
- min-height: var(--svadmin-control-h);
193
+ min-height: 2.5rem;
194
194
  padding-inline: var(--svadmin-space-3);
195
195
  border: 0;
196
196
  border-radius: var(--radius-sm);
@@ -201,16 +201,16 @@
201
201
  text-decoration: none;
202
202
  cursor: pointer;
203
203
  }
204
- .svadmin-menu__link:hover { background: var(--muted); color: var(--foreground); }
205
- .svadmin-menu__link[data-selected='true'] { background: var(--accent); color: var(--accent-foreground); font-weight: 600; }
206
- .svadmin-menu__link[data-disabled='true'] { opacity: 0.45; cursor: not-allowed; }
207
- .svadmin-menu__link:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
204
+ .svadmin-menu__link:hover { background: var(--svadmin-fill-2, var(--muted)); color: var(--foreground); }
205
+ .svadmin-menu__link[data-selected='true'] { background: var(--svadmin-fill-2, var(--muted)); color: var(--primary); font-weight: 500; }
206
+ .svadmin-menu__link[data-disabled='true'] { opacity: 1; color: var(--svadmin-text-4); cursor: not-allowed; }
207
+ .svadmin-menu__link:focus-visible { outline: var(--svadmin-focus-width) solid color-mix(in oklch, var(--ring) 48%, transparent); outline-offset: var(--svadmin-focus-offset); }
208
208
  .svadmin-menu__icon { display: inline-flex; flex: 0 0 auto; }
209
209
  .svadmin-menu__label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
210
210
  .svadmin-menu__badge { margin-inline-start: auto; padding-inline: var(--svadmin-space-2); border-radius: 999px; background: var(--muted); color: var(--muted-foreground); font-size: var(--svadmin-text-caption); }
211
211
  .svadmin-menu__chevron { margin-inline-start: auto; transition: transform 120ms ease; }
212
212
  .svadmin-menu__item[data-open='true'] > .svadmin-menu__link .svadmin-menu__chevron { transform: rotate(180deg); }
213
- .svadmin-menu__list[data-depth]:not([data-depth='0']) { margin-block-start: var(--svadmin-space-1); margin-inline-start: var(--svadmin-space-4); }
213
+ .svadmin-menu__list[data-depth]:not([data-depth='0']) { margin-block-start: var(--svadmin-space-1); margin-inline-start: 1.25rem; }
214
214
  .svadmin-menu[data-collapsed='true'] .svadmin-menu__label,
215
215
  .svadmin-menu[data-collapsed='true'] .svadmin-menu__badge,
216
216
  .svadmin-menu[data-collapsed='true'] .svadmin-menu__chevron { display: none; }