@widgetic/file-browser 0.5.24 → 0.5.25
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 +225 -0
- package/dist/components/FolderTree.svelte +4 -1
- package/dist/components/FolderTree.svelte.d.ts +2 -6
- package/dist/components/core/FileBrowser.svelte +494 -120
- package/dist/components/core/FileBrowser.svelte.d.ts +25 -1
- package/dist/components/core/FileUploader.svelte +114 -45
- package/dist/components/core/Header.svelte +12 -1
- package/dist/components/core/Header.svelte.d.ts +1 -0
- package/dist/components/core/RecentFiles.svelte +34 -26
- package/dist/components/core/UploadStatus.svelte +8 -5
- package/dist/components/core/UploadStatusList.svelte +13 -21
- package/dist/components/items/FileItem.svelte +19 -10
- package/dist/components/items/FolderItem.svelte +6 -3
- package/dist/components/modals/MoveDialog.svelte +43 -32
- package/dist/components/modals/NewFolderButton.svelte +5 -2
- package/dist/components/modals/SearchModal.svelte +16 -21
- package/dist/components/modals/SearchModal.svelte.d.ts +1 -1
- package/dist/components/modals/SelectedFilesModal.svelte +14 -9
- package/dist/components/modals/SelectedFilesModal.svelte.d.ts +1 -1
- package/dist/components/previews/AudioPlayer.svelte +5 -2
- package/dist/components/previews/ErrorPreview.svelte +7 -4
- package/dist/components/previews/ErrorPreview.svelte.d.ts +1 -1
- package/dist/components/previews/FilePreview.svelte +17 -7
- package/dist/components/previews/FontPreview.svelte +18 -9
- package/dist/components/previews/FontPreview.svelte.d.ts +1 -1
- package/dist/components/previews/TextPreview.svelte +12 -5
- package/dist/components/previews/VideoPlayer.svelte +8 -5
- package/dist/components/ui/ControlToolbar.svelte +45 -23
- package/dist/components/ui/ControlToolbar.svelte.d.ts +1 -1
- package/dist/components/ui/DragSelect.svelte +2 -2
- package/dist/components/ui/DropdownMenu.svelte +35 -14
- package/dist/components/ui/FileIcon.svelte +8 -5
- package/dist/components/ui/FileIcon.svelte.d.ts +1 -0
- package/dist/components/ui/FileMetadata.svelte +12 -15
- package/dist/components/ui/SearchResults.svelte +4 -1
- package/dist/i18n/context.d.ts +38 -0
- package/dist/i18n/context.js +70 -0
- package/dist/i18n/errors.d.ts +11 -0
- package/dist/i18n/errors.js +19 -0
- package/dist/i18n/index.d.ts +11 -0
- package/dist/i18n/index.js +18 -0
- package/dist/i18n/messages.d.ts +277 -0
- package/dist/i18n/messages.js +290 -0
- package/dist/i18n/text.d.ts +19 -0
- package/dist/i18n/text.js +35 -0
- package/dist/i18n/translator.d.ts +75 -0
- package/dist/i18n/translator.js +317 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -0
- package/dist/mediaLibrary/capabilities.d.ts +22 -0
- package/dist/mediaLibrary/capabilities.js +42 -0
- package/dist/mediaLibrary/context.d.ts +17 -0
- package/dist/mediaLibrary/context.js +16 -0
- package/dist/mediaLibrary/errors.d.ts +42 -0
- package/dist/mediaLibrary/errors.js +114 -0
- package/dist/mediaLibrary/index.d.ts +10 -0
- package/dist/mediaLibrary/index.js +9 -0
- package/dist/mediaLibrary/normalize.d.ts +39 -0
- package/dist/mediaLibrary/normalize.js +139 -0
- package/dist/mediaLibrary/paging.d.ts +37 -0
- package/dist/mediaLibrary/paging.js +62 -0
- package/dist/mediaLibrary/resolve.d.ts +39 -0
- package/dist/mediaLibrary/resolve.js +137 -0
- package/dist/mediaLibrary/treeOps.d.ts +24 -0
- package/dist/mediaLibrary/treeOps.js +67 -0
- package/dist/mediaLibrary/types.d.ts +126 -0
- package/dist/mediaLibrary/types.js +11 -0
- package/dist/mediaLibrary/urls.d.ts +30 -0
- package/dist/mediaLibrary/urls.js +59 -0
- package/dist/mediaLibrary/widgetic.d.ts +39 -0
- package/dist/mediaLibrary/widgetic.js +89 -0
- package/dist/stores/fileStore.d.ts +2 -2
- package/dist/stores/folderCountStore.js +2 -2
- package/dist/stores/navigationStore.d.ts +1 -1
- package/dist/stores/persistentSelectStore.d.ts +11 -1
- package/dist/stores/persistentSelectStore.js +26 -0
- package/dist/utils/dateUtils.d.ts +11 -2
- package/dist/utils/dateUtils.js +20 -15
- package/dist/utils/fileKinds.d.ts +44 -0
- package/dist/utils/fileKinds.js +96 -0
- package/dist/utils/fileNames.d.ts +7 -0
- package/dist/utils/fileNames.js +19 -0
- package/dist/utils/fileOperations.js +2 -11
- package/dist/utils/fileTypes.d.ts +11 -2
- package/dist/utils/fileTypes.js +26 -14
- package/dist/utils/fileUtils.d.ts +8 -1
- package/dist/utils/fileUtils.js +22 -7
- package/dist/utils/folderUtils.js +3 -2
- package/dist/utils/safeText.d.ts +29 -0
- package/dist/utils/safeText.js +66 -0
- package/dist/utils/userUploadsStorage.d.ts +4 -1
- package/dist/utils/userUploadsStorage.js +5 -2
- package/dist/utils/widgeticTusUpload.d.ts +10 -0
- package/dist/utils/widgeticTusUpload.js +61 -3
- package/dist/utils/widgeticUpload.d.ts +3 -0
- package/dist/utils/widgeticUpload.js +7 -2
- package/package.json +4 -2
|
@@ -6,8 +6,11 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { FileSystemItem } from '../../types';
|
|
8
8
|
import { createEventDispatcher, onMount } from 'svelte';
|
|
9
|
-
import {
|
|
9
|
+
import { getFileIcon } from '../../utils/fileUtils';
|
|
10
|
+
import { getFileTypeOf } from '../../utils/fileKinds';
|
|
11
|
+
import { toCssUrlLiteral, toSafeFontFamilyName } from '../../utils/safeText';
|
|
10
12
|
import { formatRelativeDate } from '../../utils/dateUtils';
|
|
13
|
+
import { useI18n, type Translate } from '../../i18n';
|
|
11
14
|
import { DropdownMenu, FileIcon } from '../ui';
|
|
12
15
|
import { type FileFilterType } from '../../utils/fileTypes';
|
|
13
16
|
// import ThumbHashImage from '../previews/ThumbHashImage.svelte';
|
|
@@ -28,6 +31,8 @@
|
|
|
28
31
|
export let allowSelecting: boolean = false;
|
|
29
32
|
export let columnWidth: number = 40; // Default value if not provided
|
|
30
33
|
|
|
34
|
+
const { t } = useI18n();
|
|
35
|
+
|
|
31
36
|
/* STATE VARS */
|
|
32
37
|
// Responsive breakpoints from global.css
|
|
33
38
|
const DESKTOP_BREAKPOINT = 1156;
|
|
@@ -91,7 +96,7 @@
|
|
|
91
96
|
|
|
92
97
|
function shouldUseFileIcon(file: FileSystemItem): boolean {
|
|
93
98
|
if (file.isMissing || errorStates.get(file.id)) return false;
|
|
94
|
-
const fileType =
|
|
99
|
+
const fileType = getFileTypeOf(file);
|
|
95
100
|
return fileType === 'font' && !isFontCached(file);
|
|
96
101
|
}
|
|
97
102
|
|
|
@@ -130,13 +135,13 @@
|
|
|
130
135
|
* @returns Promise resolving to boolean indicating if font is cached
|
|
131
136
|
*/
|
|
132
137
|
async function checkFontCached(file: FileSystemItem): Promise<boolean> {
|
|
133
|
-
const fileType =
|
|
138
|
+
const fileType = getFileTypeOf(file);
|
|
134
139
|
if (fileType !== 'font') return false;
|
|
135
140
|
|
|
136
141
|
try {
|
|
137
142
|
// Try to check if font is in document.fonts
|
|
138
143
|
if (document.fonts) {
|
|
139
|
-
const fontName = file.name
|
|
144
|
+
const fontName = toSafeFontFamilyName(file.name); // Font name without extension, safe inside CSS
|
|
140
145
|
// Try multiple font checks to ensure accurate detection
|
|
141
146
|
const checks = [
|
|
142
147
|
document.fonts.check(`1em "${fontName}"`),
|
|
@@ -161,7 +166,7 @@
|
|
|
161
166
|
* @returns Promise resolving to boolean indicating if SVG is cached
|
|
162
167
|
*/
|
|
163
168
|
async function checkSvgCached(file: FileSystemItem): Promise<boolean> {
|
|
164
|
-
const fileType =
|
|
169
|
+
const fileType = getFileTypeOf(file);
|
|
165
170
|
if (fileType !== 'svg' || !file.url) return false;
|
|
166
171
|
|
|
167
172
|
try {
|
|
@@ -216,7 +221,9 @@
|
|
|
216
221
|
async function loadFontForDisplay(file: FileSystemItem): Promise<void> {
|
|
217
222
|
if (!file.url) return;
|
|
218
223
|
|
|
219
|
-
|
|
224
|
+
// Both the name and the address come from someone else, and this text becomes a style sheet in the page's
|
|
225
|
+
// <head>: the name is reduced to safe characters and the address is written so it cannot leave its quotes.
|
|
226
|
+
const fontName = toSafeFontFamilyName(file.name);
|
|
220
227
|
const fontId = `font-${file.id}`;
|
|
221
228
|
|
|
222
229
|
// Skip if we already added this font
|
|
@@ -229,7 +236,7 @@
|
|
|
229
236
|
style.textContent = `
|
|
230
237
|
@font-face {
|
|
231
238
|
font-family: "${fontName}";
|
|
232
|
-
src:
|
|
239
|
+
src: ${toCssUrlLiteral(file.url)} format("opentype");
|
|
233
240
|
font-weight: normal;
|
|
234
241
|
font-style: normal;
|
|
235
242
|
font-display: block;
|
|
@@ -249,7 +256,7 @@
|
|
|
249
256
|
async function checkFiles() {
|
|
250
257
|
const promises = recentFiles.map(async (file) => {
|
|
251
258
|
try {
|
|
252
|
-
const fileType =
|
|
259
|
+
const fileType = getFileTypeOf(file);
|
|
253
260
|
const isFont = fileType === 'font';
|
|
254
261
|
|
|
255
262
|
// Load font for display if needed
|
|
@@ -305,7 +312,7 @@
|
|
|
305
312
|
function getThumbnailOrIcon(file: FileSystemItem): string {
|
|
306
313
|
if (isLoading(file)) return '';
|
|
307
314
|
|
|
308
|
-
const fileType =
|
|
315
|
+
const fileType = getFileTypeOf(file);
|
|
309
316
|
const isVideo = fileType === 'video';
|
|
310
317
|
const isSvg = fileType === 'svg';
|
|
311
318
|
const isAudio = fileType === 'audio';
|
|
@@ -339,7 +346,7 @@
|
|
|
339
346
|
* @returns boolean indicating if file is media
|
|
340
347
|
*/
|
|
341
348
|
function isMediaFile(file: FileSystemItem): boolean {
|
|
342
|
-
const fileType =
|
|
349
|
+
const fileType = getFileTypeOf(file);
|
|
343
350
|
return fileType === 'video' || fileType === 'audio';
|
|
344
351
|
}
|
|
345
352
|
|
|
@@ -351,7 +358,7 @@
|
|
|
351
358
|
*/
|
|
352
359
|
function getBackgroundColor(file: FileSystemItem): string {
|
|
353
360
|
if (file.isMissing || errorStates.get(file.id)) return '#FFF5F5';
|
|
354
|
-
const fileType =
|
|
361
|
+
const fileType = getFileTypeOf(file);
|
|
355
362
|
if (fileType === 'audio') return '#A7FF68';
|
|
356
363
|
if (fileType === 'document') return '#FFDC68';
|
|
357
364
|
return 'bg-gray-100';
|
|
@@ -363,7 +370,7 @@
|
|
|
363
370
|
* @returns boolean indicating if SVG icon should be used
|
|
364
371
|
*/
|
|
365
372
|
function isSvgIcon(file: FileSystemItem): boolean {
|
|
366
|
-
const fileType =
|
|
373
|
+
const fileType = getFileTypeOf(file);
|
|
367
374
|
return fileType === 'svg';
|
|
368
375
|
}
|
|
369
376
|
|
|
@@ -407,10 +414,11 @@
|
|
|
407
414
|
/**
|
|
408
415
|
* Formats file modification date
|
|
409
416
|
* @param date Date to format
|
|
417
|
+
* @param translate The `t` of the screen, so the words follow the page's language (and the text is written again when it changes)
|
|
410
418
|
* @returns Formatted date string
|
|
411
419
|
*/
|
|
412
|
-
function getFormattedDate(date: string | Date): string {
|
|
413
|
-
return formatRelativeDate(date);
|
|
420
|
+
function getFormattedDate(date: string | Date, translate: Translate): string {
|
|
421
|
+
return formatRelativeDate(date, translate);
|
|
414
422
|
}
|
|
415
423
|
|
|
416
424
|
/**
|
|
@@ -480,7 +488,7 @@
|
|
|
480
488
|
*/
|
|
481
489
|
function isCachedFontPreview(file: FileSystemItem): boolean {
|
|
482
490
|
if (file.isMissing || errorStates.get(file.id)) return false;
|
|
483
|
-
const fileType =
|
|
491
|
+
const fileType = getFileTypeOf(file);
|
|
484
492
|
return fileType === 'font' && isFontCached(file);
|
|
485
493
|
}
|
|
486
494
|
|
|
@@ -499,7 +507,7 @@
|
|
|
499
507
|
style="{style ? style + ' ' : ''}display:flex;"
|
|
500
508
|
>
|
|
501
509
|
<!-- Section Header -->
|
|
502
|
-
<h2 class="h5 text-[hsl(var(--grey7))] mb-4">
|
|
510
|
+
<h2 class="h5 text-[hsl(var(--grey7))] mb-4">{$t('recent.title')}</h2>
|
|
503
511
|
|
|
504
512
|
<!-- Files Grid Layout - Using CSS Grid with responsive columns -->
|
|
505
513
|
<div class="grid gap-5 w-full" style="grid-template-columns: repeat({numberOfColumns}, minmax(0, 1fr));">
|
|
@@ -562,11 +570,11 @@
|
|
|
562
570
|
<div class="w-full h-full flex flex-col items-center justify-center bg-[hsl(var(--grey1))] rounded-large widgetic-radius cached-font-preview">
|
|
563
571
|
<div class="flex flex-col items-center justify-center h-full w-full">
|
|
564
572
|
<!-- Use inline style with !important to force font application -->
|
|
565
|
-
<div style="font-family: {file.name
|
|
573
|
+
<div style="font-family: '{toSafeFontFamilyName(file.name)}' !important;" class="text-8xl mb-4 text-[hsl(var(--grey7))] widgetic-colors">
|
|
566
574
|
aA
|
|
567
575
|
</div>
|
|
568
|
-
<div style="font-family: {file.name
|
|
569
|
-
|
|
576
|
+
<div style="font-family: '{toSafeFontFamilyName(file.name)}' !important;" class="text-xl text-[hsl(var(--grey7))] widgetic-colors">
|
|
577
|
+
{$t('fontPreview.sampleShort')}
|
|
570
578
|
</div>
|
|
571
579
|
</div>
|
|
572
580
|
</div>
|
|
@@ -583,14 +591,14 @@
|
|
|
583
591
|
{:else if isMediaFile(file) && file.hash && file.url}
|
|
584
592
|
<div class="absolute inset-0">
|
|
585
593
|
<ThumbHashImage
|
|
586
|
-
src={
|
|
594
|
+
src={getFileTypeOf(file) === 'video' ? (file.thumbnail || file.url) : file.url}
|
|
587
595
|
alt={file.name}
|
|
588
596
|
thumbhash={file.hash}
|
|
589
597
|
class_="w-full h-full object-cover"
|
|
590
598
|
/>
|
|
591
599
|
</div>
|
|
592
600
|
<img
|
|
593
|
-
src={
|
|
601
|
+
src={getFileTypeOf(file) === 'video' ? (file.thumbnail || '') : file.url}
|
|
594
602
|
alt={file.name}
|
|
595
603
|
class="w-full h-full absolute inset-0 object-cover fade-in"
|
|
596
604
|
onload={() => imageLoaded = true}
|
|
@@ -609,7 +617,7 @@
|
|
|
609
617
|
<!-- Play Button Overlay for Media Files -->
|
|
610
618
|
{#if isMediaFile(file) && !file.isMissing && !errorStates.get(file.id)}
|
|
611
619
|
<div class="absolute inset-0 flex items-center justify-center transition-transform duration-200 {isSelected(file) ? 'scale-[0.8]' : ''}">
|
|
612
|
-
<img src={getAssetUrl('/icons/player-play.svg')} alt=
|
|
620
|
+
<img src={getAssetUrl('/icons/player-play.svg')} alt={$t('action.play')} class="w-36 h-36" />
|
|
613
621
|
</div>
|
|
614
622
|
{/if}
|
|
615
623
|
{/if}
|
|
@@ -628,18 +636,18 @@
|
|
|
628
636
|
|
|
629
637
|
<!-- File Modification Date -->
|
|
630
638
|
<p class="subtext text-[hsl({file.isMissing ? 'var(--error)' : 'var(--grey5)'})] truncate">
|
|
631
|
-
{getFormattedDate(file.modified || new Date())}
|
|
639
|
+
{getFormattedDate(file.modified || new Date(), $t)}
|
|
632
640
|
</p>
|
|
633
641
|
</div>
|
|
634
642
|
|
|
635
643
|
<!-- Selection Check Icon -->
|
|
636
644
|
{#if isSelected(file) && allowSelecting}
|
|
637
645
|
<div class="ml-2 mt-1 flex-shrink-0">
|
|
638
|
-
<img src={getAssetUrl('/icons/checked.svg')} alt=
|
|
646
|
+
<img src={getAssetUrl('/icons/checked.svg')} alt={$t('action.selected')} class="w-5 h-5" />
|
|
639
647
|
</div>
|
|
640
648
|
{:else if !file.isMissing && allowSelecting}
|
|
641
649
|
<div class="ml-2 mt-1 opacity-0 group-hover:opacity-20 transition-all duration-200 flex-shrink-0">
|
|
642
|
-
<img src={getAssetUrl('/icons/checked.svg')} alt=
|
|
650
|
+
<img src={getAssetUrl('/icons/checked.svg')} alt={$t('action.select')} class="w-5 h-5" />
|
|
643
651
|
</div>
|
|
644
652
|
{/if}
|
|
645
653
|
</div>
|
|
@@ -655,7 +663,7 @@
|
|
|
655
663
|
<div class="flex items-center justify-center h-[197px]">
|
|
656
664
|
<div class="flex items-center gap-2">
|
|
657
665
|
<IconExclamationCircle class="w-6 h-6 text-[hsl(var(--grey3))]" />
|
|
658
|
-
<p class="text-[hsl(var(--grey3))] subtext">
|
|
666
|
+
<p class="text-[hsl(var(--grey3))] subtext">{$t('recent.empty')}</p>
|
|
659
667
|
</div>
|
|
660
668
|
</div>
|
|
661
669
|
{/if}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
// Design system imports
|
|
3
3
|
import { IconTrash, IconRefresh } from '@widgetic/design-system/icons';
|
|
4
|
+
import { useI18n } from '../../i18n';
|
|
5
|
+
|
|
6
|
+
const { t } = useI18n();
|
|
4
7
|
|
|
5
8
|
// Component props
|
|
6
9
|
export let file: File;
|
|
@@ -67,12 +70,12 @@
|
|
|
67
70
|
<span>{fileSize}</span>
|
|
68
71
|
{#if timeRemaining}
|
|
69
72
|
<span class="mx-1">•</span>
|
|
70
|
-
<span>{timeRemaining}
|
|
73
|
+
<span>{$t('upload.timeLeft', { time: timeRemaining })}</span>
|
|
71
74
|
{/if}
|
|
72
75
|
{:else if status === 'failed'}
|
|
73
76
|
<span class="text-[hsl(var(--error))]">{fileSize}</span>
|
|
74
77
|
{:else}
|
|
75
|
-
<span class="text-[hsl(var(--sage-green))]">
|
|
78
|
+
<span class="text-[hsl(var(--sage-green))]">{$t('upload.complete')}</span>
|
|
76
79
|
{/if}
|
|
77
80
|
</div>
|
|
78
81
|
</div>
|
|
@@ -83,7 +86,7 @@
|
|
|
83
86
|
<button
|
|
84
87
|
class="p-2 text-[hsl(var(--grey3))] hover:text-[hsl(var(--error))] transition-colors"
|
|
85
88
|
onclick={onCancel}
|
|
86
|
-
aria-label=
|
|
89
|
+
aria-label={$t('upload.cancel')}
|
|
87
90
|
>
|
|
88
91
|
<IconTrash class="w-5 h-5" />
|
|
89
92
|
</button>
|
|
@@ -92,14 +95,14 @@
|
|
|
92
95
|
<button
|
|
93
96
|
class="p-2 text-[hsl(var(--grey3))] hover:text-[hsl(var(--error))] transition-colors"
|
|
94
97
|
onclick={onCancel}
|
|
95
|
-
aria-label=
|
|
98
|
+
aria-label={$t('upload.removeFile')}
|
|
96
99
|
>
|
|
97
100
|
<IconTrash class="w-5 h-5" />
|
|
98
101
|
</button>
|
|
99
102
|
<button
|
|
100
103
|
class="p-2 text-[hsl(var(--grey3))] hover:text-[hsl(var(--deep-forest-green))] transition-colors"
|
|
101
104
|
onclick={onRetry}
|
|
102
|
-
aria-label=
|
|
105
|
+
aria-label={$t('upload.retry')}
|
|
103
106
|
>
|
|
104
107
|
<IconRefresh class="w-5 h-5" />
|
|
105
108
|
</button>
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import UploadStatus from './UploadStatus.svelte';
|
|
3
3
|
import { createEventDispatcher } from 'svelte';
|
|
4
|
+
import { useI18n } from '../../i18n';
|
|
5
|
+
import { formatFileSize } from '../../utils/fileUtils';
|
|
4
6
|
|
|
5
7
|
const dispatch = createEventDispatcher();
|
|
8
|
+
const { t, locale } = useI18n();
|
|
6
9
|
|
|
7
10
|
// Types
|
|
8
11
|
type UploadItem = {
|
|
@@ -21,17 +24,6 @@
|
|
|
21
24
|
export let onCancel: (id: string) => void;
|
|
22
25
|
export let onRetry: (id: string) => void;
|
|
23
26
|
|
|
24
|
-
// Helper function to format file size
|
|
25
|
-
function formatFileSize(bytes: number): string {
|
|
26
|
-
if (bytes === 0) return '0 B';
|
|
27
|
-
|
|
28
|
-
const k = 1024;
|
|
29
|
-
const sizes = ['B', 'KB', 'MB', 'GB'];
|
|
30
|
-
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
31
|
-
|
|
32
|
-
return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + ' ' + sizes[i];
|
|
33
|
-
}
|
|
34
|
-
|
|
35
27
|
// Group uploads by status for better organization
|
|
36
28
|
$: completedUploads = uploads.filter(u => u.status === 'complete');
|
|
37
29
|
$: activeUploads = uploads.filter(u => u.status === 'uploading');
|
|
@@ -57,23 +49,23 @@
|
|
|
57
49
|
<div class="flex justify-between items-center mb-2">
|
|
58
50
|
<h3 class="font-medium flex items-center">
|
|
59
51
|
{#if failedCount > 0 && completedCount > 0}
|
|
60
|
-
{completedCount
|
|
52
|
+
{$t('upload.progress', { done: completedCount, total: totalUploads })}
|
|
61
53
|
{:else if uploadingCount > 0}
|
|
62
|
-
|
|
54
|
+
{$t('upload.uploadingProgress', { done: uploadingCount, total: totalUploads })}
|
|
63
55
|
{:else if completedCount === totalUploads}
|
|
64
|
-
{totalUploads}
|
|
56
|
+
{$t('upload.filesTotal', { count: totalUploads })}
|
|
65
57
|
{:else}
|
|
66
|
-
{totalUploads}
|
|
58
|
+
{$t('upload.filesTotal', { count: totalUploads })}
|
|
67
59
|
{/if}
|
|
68
60
|
</h3>
|
|
69
61
|
|
|
70
62
|
<div class="text-sm text-[hsl(var(--grey3))] flex items-center">
|
|
71
63
|
{#if failedCount > 0}
|
|
72
|
-
<span class="text-[hsl(var(--error))]">{failedCount}
|
|
64
|
+
<span class="text-[hsl(var(--error))]">{$t('upload.failedCount', { count: failedCount })}</span>
|
|
73
65
|
{:else if completedCount === totalUploads}
|
|
74
|
-
<span class="text-[hsl(var(--sage-green))]">
|
|
66
|
+
<span class="text-[hsl(var(--sage-green))]">{$t('upload.complete')}</span>
|
|
75
67
|
{:else}
|
|
76
|
-
<span>{completedCount
|
|
68
|
+
<span>{$t('upload.completeCount', { done: completedCount, total: totalUploads })}</span>
|
|
77
69
|
{/if}
|
|
78
70
|
</div>
|
|
79
71
|
</div>
|
|
@@ -94,7 +86,7 @@
|
|
|
94
86
|
class="text-[hsl(var(--deep-forest-green))] hover:underline"
|
|
95
87
|
onclick={() => failedUploads.forEach(u => onRetry(u.id))}
|
|
96
88
|
>
|
|
97
|
-
|
|
89
|
+
{$t('upload.retryFailed')}
|
|
98
90
|
</button>
|
|
99
91
|
</div>
|
|
100
92
|
{/if}
|
|
@@ -108,7 +100,7 @@
|
|
|
108
100
|
file={upload.file}
|
|
109
101
|
progress={upload.progress}
|
|
110
102
|
status={upload.status}
|
|
111
|
-
fileSize={formatFileSize(upload.file.size)}
|
|
103
|
+
fileSize={formatFileSize(upload.file.size, $t, $locale)}
|
|
112
104
|
timeRemaining={upload.timeRemaining || ''}
|
|
113
105
|
errorMessage={upload.errorMessage || ''}
|
|
114
106
|
previewUrl={upload.previewUrl}
|
|
@@ -130,7 +122,7 @@
|
|
|
130
122
|
dispatch('uploadsCleared');
|
|
131
123
|
}}
|
|
132
124
|
>
|
|
133
|
-
|
|
125
|
+
{$t('action.done')}
|
|
134
126
|
</button>
|
|
135
127
|
</div>
|
|
136
128
|
{/if}
|
|
@@ -22,6 +22,9 @@
|
|
|
22
22
|
|
|
23
23
|
import type { FileSystemItem } from '../../types';
|
|
24
24
|
import { getFileIcon, getItemFileType, formatFileSize } from '../../utils/fileUtils';
|
|
25
|
+
import { useI18n } from '../../i18n';
|
|
26
|
+
import { isKnownNonImageFile } from '../../utils/fileKinds';
|
|
27
|
+
import { toCssUrlLiteral, toSafeFontFamilyName } from '../../utils/safeText';
|
|
25
28
|
import { addMissingFile, removeMissingFile } from '../../stores/missingFilesStore';
|
|
26
29
|
import { browser } from '$app/environment';
|
|
27
30
|
import { IconTrash } from '@tabler/icons-svelte';
|
|
@@ -47,6 +50,7 @@
|
|
|
47
50
|
$: isSelected = allowSelecting && selected;
|
|
48
51
|
|
|
49
52
|
const dispatch = createEventDispatcher();
|
|
53
|
+
const { t, locale } = useI18n();
|
|
50
54
|
|
|
51
55
|
|
|
52
56
|
// Reactive declarations for file type handling
|
|
@@ -57,10 +61,14 @@
|
|
|
57
61
|
$: isSvg = fileType === 'svg';
|
|
58
62
|
$: isFont = fileType === 'font';
|
|
59
63
|
$: fileIcon = getFileIcon(item.name);
|
|
60
|
-
|
|
64
|
+
// The name a font is registered and styled under; safe to put inside CSS (see safeText.ts).
|
|
65
|
+
$: fontName = toSafeFontFamilyName(item.name);
|
|
61
66
|
$: previewSrc = item.thumbnail || item.url || '';
|
|
62
67
|
$: isLikelyRemoteImage = !!(previewSrc && /^(https?:|blob:|data:image)/i.test(previewSrc));
|
|
63
|
-
|
|
68
|
+
// A PDF or a text file without a thumbnail gets the file-type icon: drawing the file itself as a picture
|
|
69
|
+
// fails and would show it as "missing", which also makes it impossible to select (see fileKinds.ts).
|
|
70
|
+
$: isKnownNonPicture = !item.thumbnail && isKnownNonImageFile(item);
|
|
71
|
+
$: showImageThumb = isImage || isSvg || (isLikelyRemoteImage && !isAudio && !isVideo && !isFont && !isKnownNonPicture);
|
|
64
72
|
|
|
65
73
|
// State for file availability and loading
|
|
66
74
|
let isLoading = true;
|
|
@@ -154,7 +162,7 @@
|
|
|
154
162
|
}
|
|
155
163
|
|
|
156
164
|
// Create and load the font
|
|
157
|
-
fontFace = new FontFace(fontName,
|
|
165
|
+
fontFace = new FontFace(fontName, toCssUrlLiteral(item.url ?? ''));
|
|
158
166
|
|
|
159
167
|
// Set a timeout to catch hanging loads
|
|
160
168
|
const fontLoadPromise = fontFace.load();
|
|
@@ -478,7 +486,8 @@
|
|
|
478
486
|
height: 54px;
|
|
479
487
|
"
|
|
480
488
|
onclick={handleIconClick}
|
|
481
|
-
|
|
489
|
+
data-fb-action="preview"
|
|
490
|
+
aria-label={$t('item.previewLabel', { name: item.name })}
|
|
482
491
|
disabled={isMissing}
|
|
483
492
|
>
|
|
484
493
|
<div class="w-full h-full flex items-center justify-center relative">
|
|
@@ -511,7 +520,7 @@
|
|
|
511
520
|
{#if isAudio || (fileType === 'document' && !showImageThumb)}
|
|
512
521
|
<img
|
|
513
522
|
src={getAssetUrl(getFileIcon(item.name))}
|
|
514
|
-
alt={isAudio ? '
|
|
523
|
+
alt={isAudio ? $t('item.audioFile') : $t('item.documentFile')}
|
|
515
524
|
class="audio-doc-icon-image w-full h-full rounded-[var(--radius-large)] object-contain {isImageCached ? 'no-fade' : 'fade-in'}"
|
|
516
525
|
/>
|
|
517
526
|
<!-- Image -->
|
|
@@ -575,7 +584,7 @@
|
|
|
575
584
|
<div class="play-icon-bg bg-white rounded-full p-2 shadow-lg">
|
|
576
585
|
<img
|
|
577
586
|
src={getAssetUrl('/icons/player-play.svg')}
|
|
578
|
-
alt=
|
|
587
|
+
alt={$t('action.play')}
|
|
579
588
|
class="play-icon-image w-4 h-4"
|
|
580
589
|
/>
|
|
581
590
|
</div>
|
|
@@ -593,19 +602,19 @@
|
|
|
593
602
|
{item.name}
|
|
594
603
|
</h3>
|
|
595
604
|
<p class="subtext cursor-default mt-0.5" class:truncate={!gridLayout} class:text-center={gridLayout} class:text-[hsl(var(--error))]={isMissing} class:text-[hsl(var(--grey5))]={!isMissing}>
|
|
596
|
-
{formatFileSize(item.size ?? 0)}
|
|
605
|
+
{formatFileSize(item.size ?? 0, $t, $locale)}
|
|
597
606
|
</p>
|
|
598
607
|
</div>
|
|
599
608
|
|
|
600
609
|
<!-- Checkbox/Actions -->
|
|
601
610
|
{#if !isMissing && allowSelecting && !selected}
|
|
602
611
|
<div class="absolute top-[17px] right-4 z-10 opacity-0 group-hover:opacity-20 transition-all duration-200">
|
|
603
|
-
<img src={getAssetUrl('/icons/checked.svg')} alt=
|
|
612
|
+
<img src={getAssetUrl('/icons/checked.svg')} alt={$t('action.select')} class="w-5 h-5" />
|
|
604
613
|
</div>
|
|
605
614
|
{/if}
|
|
606
615
|
{#if selected}
|
|
607
616
|
<div class="absolute top-[17px] right-4 z-10 opacity-100">
|
|
608
|
-
<img src={getAssetUrl('/icons/checked.svg')} alt=
|
|
617
|
+
<img src={getAssetUrl('/icons/checked.svg')} alt={$t('action.selected')} class="w-5 h-5" />
|
|
609
618
|
</div>
|
|
610
619
|
{/if}
|
|
611
620
|
{#if isMissing}
|
|
@@ -617,7 +626,7 @@
|
|
|
617
626
|
e.stopPropagation();
|
|
618
627
|
dispatch('delete', { item });
|
|
619
628
|
}}
|
|
620
|
-
aria-label=
|
|
629
|
+
aria-label={$t('item.deleteMissing')}
|
|
621
630
|
>
|
|
622
631
|
<IconTrash size={20} />
|
|
623
632
|
</button>
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { type FileFilterType } from '../../utils/fileTypes';
|
|
6
6
|
import { DropdownMenu } from '../ui';
|
|
7
7
|
import { isMobileStore } from '../../stores/viewportStore';
|
|
8
|
+
import { useI18n } from '../../i18n';
|
|
8
9
|
|
|
9
10
|
export let item: FolderItemWithCount;
|
|
10
11
|
export let currentFilter: FileFilterType = 'all';
|
|
@@ -12,6 +13,7 @@
|
|
|
12
13
|
export let isMobile: boolean | undefined = undefined;
|
|
13
14
|
|
|
14
15
|
const dispatch = createEventDispatcher();
|
|
16
|
+
const { t } = useI18n();
|
|
15
17
|
|
|
16
18
|
$: effectiveIsMobile = isMobile !== undefined ? isMobile : $isMobileStore;
|
|
17
19
|
|
|
@@ -46,16 +48,17 @@
|
|
|
46
48
|
class="w-[62px] h-[54px] flex items-center justify-center cursor-pointer hover:opacity-80 transition-opacity shrink-0"
|
|
47
49
|
style="background-color: #FFFFFF;"
|
|
48
50
|
on:click={handleIconClick}
|
|
49
|
-
|
|
51
|
+
data-fb-action="open-folder"
|
|
52
|
+
aria-label={$t('folder.open', { name: item.name })}
|
|
50
53
|
>
|
|
51
|
-
<img src={icon} alt=
|
|
54
|
+
<img src={icon} alt={$t('item.folder')} class="w-full h-full object-contain" />
|
|
52
55
|
</button>
|
|
53
56
|
|
|
54
57
|
<div class="fb-folder-content-ct flex flex-col min-w-0 relative w-full" class:items-center={gridLayout} class:text-center={gridLayout} class:justify-between={!gridLayout} class:min-h-[54px]={!gridLayout} class:pt-[5px]={!gridLayout}>
|
|
55
58
|
<div class="w-full" class:pr-10={!gridLayout} class:px-1={gridLayout}>
|
|
56
59
|
<h3 class="fb-folder-title body-medium text-[hsl(var(--grey7))] text-sm leading-snug line-clamp-2 break-words cursor-default" class:text-center={gridLayout}>{item.name}</h3>
|
|
57
60
|
<p class="subtext text-[hsl(var(--grey5))] cursor-default mt-0.5" class:truncate={!gridLayout} class:text-center={gridLayout}>
|
|
58
|
-
{isEmpty ? '
|
|
61
|
+
{isEmpty ? $t('folder.empty') : $t('folder.itemCount', { count: item.matchingFileCount })}
|
|
59
62
|
</p>
|
|
60
63
|
</div>
|
|
61
64
|
|