@widgetic/file-browser 0.5.24 → 0.5.26
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 +279 -0
- package/dist/components/FolderTree.svelte +16 -9
- package/dist/components/FolderTree.svelte.d.ts +2 -6
- package/dist/components/core/FileBrowser.svelte +529 -127
- package/dist/components/core/FileBrowser.svelte.d.ts +40 -1
- package/dist/components/core/FileUploader.svelte +130 -57
- package/dist/components/core/Header.svelte +13 -2
- package/dist/components/core/Header.svelte.d.ts +1 -0
- package/dist/components/core/RecentFiles.svelte +41 -29
- package/dist/components/core/UploadStatus.svelte +14 -7
- package/dist/components/core/UploadStatusList.svelte +13 -21
- package/dist/components/items/FileItem.svelte +28 -15
- package/dist/components/items/FolderItem.svelte +13 -6
- package/dist/components/modals/MoveDialog.svelte +49 -38
- package/dist/components/modals/NewFolderButton.svelte +5 -2
- package/dist/components/modals/SearchModal.svelte +25 -26
- package/dist/components/modals/SearchModal.svelte.d.ts +1 -1
- package/dist/components/modals/SelectedFilesModal.svelte +23 -14
- 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 +25 -9
- 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 +11 -7
- package/dist/components/ui/ControlToolbar.svelte +50 -28
- package/dist/components/ui/ControlToolbar.svelte.d.ts +1 -1
- package/dist/components/ui/DragSelect.svelte +3 -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 +16 -15
- package/dist/components/ui/SearchResults.svelte +9 -2
- package/dist/i18n/context.d.ts +28 -0
- package/dist/i18n/context.js +17 -0
- package/dist/i18n/errors.d.ts +11 -0
- package/dist/i18n/errors.js +19 -0
- package/dist/i18n/index.d.ts +15 -0
- package/dist/i18n/index.js +18 -0
- package/dist/i18n/messages.d.ts +281 -0
- package/dist/i18n/messages.js +294 -0
- package/dist/i18n/text.d.ts +19 -0
- package/dist/i18n/text.js +35 -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/previewKeys.d.ts +12 -0
- package/dist/utils/previewKeys.js +14 -0
- 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 +5 -2
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Svelte imports
|
|
3
3
|
import { createEventDispatcher } from 'svelte';
|
|
4
4
|
const dispatch = createEventDispatcher();
|
|
5
|
+
const { t } = useI18n();
|
|
5
6
|
|
|
6
7
|
// Design system imports
|
|
7
8
|
import { Button, toast, BaseModal, WScrollArea } from '@widgetic/design-system/components';
|
|
@@ -17,6 +18,8 @@
|
|
|
17
18
|
import { getFileType } from '../../utils/fileUtils';
|
|
18
19
|
import { moveItem, findItemById } from '../../utils/fileOperations';
|
|
19
20
|
import { ENDPOINTS, logApiRequest } from '../../utils/apiConfig';
|
|
21
|
+
import { useI18n, messageForVisitor } from '../../i18n';
|
|
22
|
+
import { MediaLibraryError } from '../../mediaLibrary/errors';
|
|
20
23
|
|
|
21
24
|
// Local stores imports
|
|
22
25
|
import { folderCounts, updateFolderCounts } from '../../stores/folderCountStore';
|
|
@@ -122,6 +125,19 @@
|
|
|
122
125
|
return getFolderIcon(folderWithCount, currentFilter);
|
|
123
126
|
}
|
|
124
127
|
|
|
128
|
+
/** A name as the dialog's title shows it: cut at 30 characters. */
|
|
129
|
+
function shortNameOf(name: string | undefined): string {
|
|
130
|
+
const text = name ?? '';
|
|
131
|
+
return text.length > 30 ? text.slice(0, 30) + '...' : text;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** The headline of a failed move: about the folder when one folder was being moved, else about the items. */
|
|
135
|
+
function failedMoveTitle(): string {
|
|
136
|
+
return sourceItems.length === 1 && sourceItems[0]?.type === 'folder'
|
|
137
|
+
? $t('moveDialog.failedFolder')
|
|
138
|
+
: $t('moveDialog.failedItems');
|
|
139
|
+
}
|
|
140
|
+
|
|
125
141
|
/**
|
|
126
142
|
* Handles the move operation and triggers animations
|
|
127
143
|
* @param targetFolderId ID of the destination folder
|
|
@@ -135,11 +151,9 @@
|
|
|
135
151
|
|
|
136
152
|
if (!targetFolderId) {
|
|
137
153
|
toast.error(
|
|
138
|
-
|
|
139
|
-
? 'Failed to move folder'
|
|
140
|
-
: 'Failed to move items',
|
|
154
|
+
failedMoveTitle(),
|
|
141
155
|
{
|
|
142
|
-
description: '
|
|
156
|
+
description: $t('moveDialog.noTarget'),
|
|
143
157
|
position: 'bottom-center',
|
|
144
158
|
class: 'file-browser-sonar',
|
|
145
159
|
duration: 2000
|
|
@@ -150,9 +164,9 @@
|
|
|
150
164
|
|
|
151
165
|
if (sourceItems.length === 0) {
|
|
152
166
|
toast.error(
|
|
153
|
-
'
|
|
167
|
+
$t('moveDialog.failedItems'),
|
|
154
168
|
{
|
|
155
|
-
description: '
|
|
169
|
+
description: $t('moveDialog.noItems'),
|
|
156
170
|
position: 'bottom-center',
|
|
157
171
|
class: 'file-browser-sonar',
|
|
158
172
|
duration: 2000
|
|
@@ -243,8 +257,8 @@
|
|
|
243
257
|
if (movedItems.length > 0) {
|
|
244
258
|
// Show appropriate toast based on success/partial success
|
|
245
259
|
if (movedItems.length < sourceItems.length) {
|
|
246
|
-
toast.warning('
|
|
247
|
-
description:
|
|
260
|
+
toast.warning($t('moveDialog.partialTitle'), {
|
|
261
|
+
description: $t('moveDialog.partialDetail', { moved: movedItems.length, total: sourceItems.length }),
|
|
248
262
|
position: 'bottom-center',
|
|
249
263
|
class: 'file-browser-sonar',
|
|
250
264
|
duration: 2000
|
|
@@ -252,11 +266,11 @@
|
|
|
252
266
|
} else {
|
|
253
267
|
const isFolder = sourceItems.length === 1 && sourceItems[0].type === 'folder';
|
|
254
268
|
toast.success(
|
|
255
|
-
isFolder ?
|
|
269
|
+
isFolder ? $t('moveDialog.doneFolder') : sourceItems.length === 1 ? $t('moveDialog.doneOne') : $t('moveDialog.doneMany'),
|
|
256
270
|
{
|
|
257
271
|
description: isFolder
|
|
258
|
-
?
|
|
259
|
-
:
|
|
272
|
+
? $t('moveDialog.doneFolderDetail', { name: sourceItems[0].name })
|
|
273
|
+
: $t('moveDialog.doneItemsDetail', { count: sourceItems.length }),
|
|
260
274
|
position: 'bottom-center',
|
|
261
275
|
class: 'file-browser-sonar',
|
|
262
276
|
duration: 2000
|
|
@@ -274,15 +288,15 @@
|
|
|
274
288
|
selectedFolder = undefined;
|
|
275
289
|
isOpen = false;
|
|
276
290
|
} else {
|
|
277
|
-
|
|
291
|
+
// The File Browser's own sentence: the visitor reads it in the page's language, the console keeps the English
|
|
292
|
+
throw new MediaLibraryError('FAILED', 'No items were moved successfully', { messageKey: 'moveDialog.noneMoved' });
|
|
278
293
|
}
|
|
279
294
|
} catch (error) {
|
|
280
295
|
console.error('Error moving items:', error);
|
|
281
|
-
const isFolder = sourceItems.length === 1 && sourceItems[0].type === 'folder';
|
|
282
296
|
toast.error(
|
|
283
|
-
|
|
297
|
+
failedMoveTitle(),
|
|
284
298
|
{
|
|
285
|
-
description: error
|
|
299
|
+
description: messageForVisitor(error, $t),
|
|
286
300
|
position: 'bottom-center',
|
|
287
301
|
class: 'file-browser-sonar',
|
|
288
302
|
duration: 2000
|
|
@@ -296,11 +310,9 @@
|
|
|
296
310
|
handleMove(selectedFolder.id);
|
|
297
311
|
} else {
|
|
298
312
|
toast.error(
|
|
299
|
-
|
|
300
|
-
? 'Failed to move folder'
|
|
301
|
-
: 'Failed to move items',
|
|
313
|
+
failedMoveTitle(),
|
|
302
314
|
{
|
|
303
|
-
description: '
|
|
315
|
+
description: $t('moveDialog.pickDestination'),
|
|
304
316
|
position: 'bottom-center',
|
|
305
317
|
class: 'file-browser-sonar',
|
|
306
318
|
duration: 2000
|
|
@@ -324,17 +336,16 @@
|
|
|
324
336
|
<BaseModal class="move-modal"
|
|
325
337
|
bind:open={isOpen}
|
|
326
338
|
on:close={handleClose}
|
|
339
|
+
closeLabel={$t('dialog.close')}
|
|
327
340
|
{target}
|
|
328
341
|
width="566px"
|
|
329
342
|
height="496px"
|
|
330
343
|
titlePadding="small"
|
|
331
344
|
showScroll={false}
|
|
332
345
|
title={
|
|
333
|
-
sourceItems.length === 1
|
|
334
|
-
?
|
|
335
|
-
: sourceItems.length
|
|
336
|
-
? `Move "${sourceItems[0]?.name.length > 30 ? sourceItems[0]?.name.slice(0, 30) + '...' : sourceItems[0]?.name}"`
|
|
337
|
-
: `Move ${sourceItems.length} items`
|
|
346
|
+
sourceItems.length === 1
|
|
347
|
+
? $t('moveDialog.titleOne', { name: shortNameOf(sourceItems[0]?.name) })
|
|
348
|
+
: $t('moveDialog.titleMany', { count: sourceItems.length })
|
|
338
349
|
}
|
|
339
350
|
modalType="move"
|
|
340
351
|
modalData={{
|
|
@@ -363,7 +374,7 @@
|
|
|
363
374
|
<!-- Current Folder Button -->
|
|
364
375
|
<div class="folder-item widgetic-colors widgetic-radius group">
|
|
365
376
|
<button
|
|
366
|
-
class="folder-button flex items-center gap-4 w-full min-h-[70px]
|
|
377
|
+
class="folder-button flex items-center gap-4 w-full min-h-[70px] ps-2 rounded-large cursor-pointer
|
|
367
378
|
{selectedFolder?.id === 'root' ? 'bg-[hsl(var(--light-green))] light-green-bg' : ''}
|
|
368
379
|
{immediateParentId === null ? 'relative' : ''}"
|
|
369
380
|
onclick={() => {
|
|
@@ -400,7 +411,7 @@
|
|
|
400
411
|
size: 0,
|
|
401
412
|
matchingFileCount: counts.get('root') || 0
|
|
402
413
|
}, currentFilter)}
|
|
403
|
-
alt=
|
|
414
|
+
alt={$t('moveDialog.rootName')}
|
|
404
415
|
width="62"
|
|
405
416
|
height="54"
|
|
406
417
|
style="width: 62px; height: 54px; object-fit: contain;"
|
|
@@ -408,20 +419,20 @@
|
|
|
408
419
|
/>
|
|
409
420
|
</div>
|
|
410
421
|
</div>
|
|
411
|
-
<span class="body-medium truncate flex-grow text-
|
|
412
|
-
<div class="flex items-center
|
|
422
|
+
<span class="body-medium truncate flex-grow text-start {immediateParentId === null ? 'text-[hsl(var(--grey3))]' : 'text-[hsl(var(--grey7))]'} {selectedFolder?.id === 'root' ? 'font-bold' : 'font-normal'}">{$t('moveDialog.rootName')}</span>
|
|
423
|
+
<div class="flex items-center ms-auto">
|
|
413
424
|
{#if immediateParentId === null}
|
|
414
|
-
<span class="h6 text-[hsl(var(--sage-green))] relative z-10
|
|
425
|
+
<span class="h6 text-[hsl(var(--sage-green))] relative z-10 me-6">{$t('folder.currentLocation')}</span>
|
|
415
426
|
{/if}
|
|
416
427
|
{#if selectedFolder?.id === 'root'}
|
|
417
|
-
<IconArrowBounce class="w-6 h-6 text-[hsl(var(--info))]
|
|
428
|
+
<IconArrowBounce class="w-6 h-6 text-[hsl(var(--info))] me-6 rtl:-scale-x-100" />
|
|
418
429
|
{/if}
|
|
419
430
|
</div>
|
|
420
431
|
</button>
|
|
421
432
|
</div>
|
|
422
433
|
|
|
423
434
|
<!-- Folder Items Container -->
|
|
424
|
-
<div class="folder-tree-container
|
|
435
|
+
<div class="folder-tree-container ps-8 flex flex-col">
|
|
425
436
|
{#each folders as folder}
|
|
426
437
|
{#if folder.type === 'folder'}
|
|
427
438
|
<FolderTree
|
|
@@ -434,7 +445,7 @@
|
|
|
434
445
|
iconSize="40"
|
|
435
446
|
textClass="body-medium truncate text-[hsl(var(--grey7))]"
|
|
436
447
|
selectedIconClass="w-6 h-6 text-[hsl(var(--info))]"
|
|
437
|
-
currentLocationClass="text-sm text-[hsl(var(--info))]
|
|
448
|
+
currentLocationClass="text-sm text-[hsl(var(--info))] me-2"
|
|
438
449
|
selectedIcon={IconArrowBounce}
|
|
439
450
|
/>
|
|
440
451
|
{/if}
|
|
@@ -450,7 +461,7 @@
|
|
|
450
461
|
<!-- Results Count -->
|
|
451
462
|
<div class="results-count text-[hsl(var(--grey5))] subtext">
|
|
452
463
|
{#if selectedFolder && selectedFolder.id !== immediateParentId}
|
|
453
|
-
|
|
464
|
+
{$t('moveDialog.movingTo', { name: selectedFolder.name })}
|
|
454
465
|
{/if}
|
|
455
466
|
</div>
|
|
456
467
|
|
|
@@ -461,7 +472,7 @@
|
|
|
461
472
|
class="modal-btn-secondary !h-[34px]"
|
|
462
473
|
onclick={handleClose}
|
|
463
474
|
>
|
|
464
|
-
<span>
|
|
475
|
+
<span>{$t('action.cancel')}</span>
|
|
465
476
|
</Button>
|
|
466
477
|
|
|
467
478
|
<!-- Move Button -->
|
|
@@ -471,11 +482,11 @@
|
|
|
471
482
|
class="modal-btn-primary !h-[34px]"
|
|
472
483
|
>
|
|
473
484
|
{#if sourceItems.length === 1 && sourceItems[0]?.type === 'folder'}
|
|
474
|
-
<span>
|
|
485
|
+
<span>{$t('moveDialog.confirmFolder')}</span>
|
|
475
486
|
{:else if sourceItems.length === 1}
|
|
476
|
-
<span>
|
|
487
|
+
<span>{$t('moveDialog.confirmItem')}</span>
|
|
477
488
|
{:else}
|
|
478
|
-
<span>
|
|
489
|
+
<span>{$t('moveDialog.confirmMany', { count: sourceItems.length })}</span>
|
|
479
490
|
{/if}
|
|
480
491
|
</Button>
|
|
481
492
|
</div>
|
|
@@ -493,7 +504,7 @@
|
|
|
493
504
|
.folder-item::before {
|
|
494
505
|
content: '';
|
|
495
506
|
position: absolute;
|
|
496
|
-
|
|
507
|
+
inset-inline-start: 0;
|
|
497
508
|
top: 0;
|
|
498
509
|
bottom: 0;
|
|
499
510
|
width: 2px;
|
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
|
|
6
6
|
// Local utils imports
|
|
7
7
|
import { getAssetUrl } from '../../utils/fileUtils';
|
|
8
|
+
import { useI18n } from '../../i18n';
|
|
9
|
+
|
|
10
|
+
const { t } = useI18n();
|
|
8
11
|
|
|
9
12
|
// Event handlers
|
|
10
13
|
function handleClick() {
|
|
@@ -18,8 +21,8 @@
|
|
|
18
21
|
on:click={handleClick}
|
|
19
22
|
>
|
|
20
23
|
<div class="new-folder-icon-ct w-[62px] h-[54px] flex items-center justify-center shrink-0">
|
|
21
|
-
<img src={getAssetUrl('/icons/new-folder.svg')} alt=
|
|
24
|
+
<img src={getAssetUrl('/icons/new-folder.svg')} alt={$t('newFolder.alt')} class="w-full h-full object-contain" />
|
|
22
25
|
</div>
|
|
23
|
-
<h3 class="new-folder-label body-medium text-[hsl(var(--deep-forest-green))] text-sm text-center line-clamp-2 break-words px-1">
|
|
26
|
+
<h3 class="new-folder-label body-medium text-[hsl(var(--deep-forest-green))] text-sm text-center line-clamp-2 break-words px-1">{$t('newFolder.label')}</h3>
|
|
24
27
|
</button>
|
|
25
28
|
</div>
|
|
@@ -31,11 +31,20 @@
|
|
|
31
31
|
import type { FileSystemItem } from '../../types';
|
|
32
32
|
|
|
33
33
|
// Local utils imports
|
|
34
|
-
import {
|
|
34
|
+
import { getFileIcon } from '../../utils/fileUtils';
|
|
35
|
+
import { getFileTypeOf } from '../../utils/fileKinds';
|
|
35
36
|
import { getFolderIcon } from '../../utils/folderUtils';
|
|
36
37
|
import { type FileFilterType } from '../../utils/fileTypes';
|
|
37
38
|
//
|
|
38
39
|
import { getAssetUrl } from '../../utils/fileUtils';
|
|
40
|
+
import { highlightMatchesAsHtml } from '../../utils/safeText';
|
|
41
|
+
import { useI18n } from '../../i18n';
|
|
42
|
+
import { dirForUserText, useTextDirection } from '@widgetic/design-system/components/textDirection';
|
|
43
|
+
|
|
44
|
+
const { t } = useI18n();
|
|
45
|
+
// The reading direction of the screen: a name a visitor wrote keeps a direction of its own on a right to left screen.
|
|
46
|
+
const textDirection = useTextDirection();
|
|
47
|
+
$: nameDirection = dirForUserText($textDirection);
|
|
39
48
|
|
|
40
49
|
// Props for filtering search results
|
|
41
50
|
export let currentFilter: FileFilterType = 'all';
|
|
@@ -163,20 +172,9 @@
|
|
|
163
172
|
* @returns Safely escaped HTML string with highlighted match
|
|
164
173
|
*/
|
|
165
174
|
function highlightMatch(name: string, term: string): string {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
'&': '&',
|
|
170
|
-
'<': '<',
|
|
171
|
-
'>': '>',
|
|
172
|
-
'"': '"',
|
|
173
|
-
"'": '''
|
|
174
|
-
}[char] || char));
|
|
175
|
-
|
|
176
|
-
const escapedTerm = term.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
177
|
-
const regex = new RegExp(`(${escapedTerm})`, 'gi');
|
|
178
|
-
|
|
179
|
-
return escapedName.replace(regex, '<span class="text-[hsl(var(--sage-green))]">$1</span>');
|
|
175
|
+
// The name is escaped on every path, including an empty term: it is written by someone else and is rendered
|
|
176
|
+
// with {@html}, so it must never reach the page as markup.
|
|
177
|
+
return highlightMatchesAsHtml(name, term, 'text-[hsl(var(--sage-green))]');
|
|
180
178
|
}
|
|
181
179
|
|
|
182
180
|
/**
|
|
@@ -241,7 +239,7 @@
|
|
|
241
239
|
// console.log('Checking filter for item:', item.name, 'Type:', item.type, 'Current filter:', currentFilter);
|
|
242
240
|
if (currentFilter === 'all') return true;
|
|
243
241
|
if (item.type === 'folder') return true; // Always include folders in search results
|
|
244
|
-
const fileType =
|
|
242
|
+
const fileType = getFileTypeOf(item);
|
|
245
243
|
const matches = fileType === currentFilter;
|
|
246
244
|
if (fileType === 'font') {
|
|
247
245
|
// console.log('Font file found in search:', item.name, 'URL:', item.url);
|
|
@@ -282,7 +280,7 @@
|
|
|
282
280
|
if (file.type === 'folder') {
|
|
283
281
|
return getFolderIcon(file, currentFilter);
|
|
284
282
|
}
|
|
285
|
-
const fileType =
|
|
283
|
+
const fileType = getFileTypeOf(file);
|
|
286
284
|
if ((fileType === 'image' || fileType === 'video') &&
|
|
287
285
|
!file.name.toLowerCase().endsWith('.svg') &&
|
|
288
286
|
file.thumbnail) {
|
|
@@ -330,6 +328,7 @@
|
|
|
330
328
|
<BaseModal class="search-modal"
|
|
331
329
|
bind:open
|
|
332
330
|
on:close={handleClose}
|
|
331
|
+
closeLabel={$t('dialog.close')}
|
|
333
332
|
{target}
|
|
334
333
|
width="566px"
|
|
335
334
|
height={$searchTermStore ? "auto" : "88px"}
|
|
@@ -362,7 +361,7 @@
|
|
|
362
361
|
}
|
|
363
362
|
}
|
|
364
363
|
}}
|
|
365
|
-
placeholder=
|
|
364
|
+
placeholder={$t('searchModal.placeholder')}
|
|
366
365
|
class="search-modal-input-el w-full
|
|
367
366
|
!h5 !text-[24px] !text-[hsl(var(--grey7))]
|
|
368
367
|
placeholder:!text-[24px] placeholder:!text-[hsl(var(--grey3))]
|
|
@@ -394,12 +393,12 @@
|
|
|
394
393
|
on:click={() => handleResultClick(result)}
|
|
395
394
|
>
|
|
396
395
|
{#if result.type === 'folder'}
|
|
397
|
-
<div class="flex items-center gap-4 min-w-0
|
|
398
|
-
<img src={getFolderIcon(result, currentFilter)} alt=
|
|
399
|
-
<span class="body-medium text-[hsl(var(--grey7))] truncate">{@html highlightMatch(result.name, $searchTermStore)}</span>
|
|
396
|
+
<div class="flex items-center gap-4 min-w-0 pe-12">
|
|
397
|
+
<img src={getFolderIcon(result, currentFilter)} alt={$t('item.folder')} class="w-[62px] h-[54px] object-contain shrink-0" />
|
|
398
|
+
<span dir={nameDirection} class="body-medium text-[hsl(var(--grey7))] truncate">{@html highlightMatch(result.name, $searchTermStore)}</span>
|
|
400
399
|
</div>
|
|
401
400
|
{:else}
|
|
402
|
-
<div class="flex items-center gap-4 min-w-0
|
|
401
|
+
<div class="flex items-center gap-4 min-w-0 pe-12">
|
|
403
402
|
<div class="w-[62px] shrink-0 flex items-center justify-center">
|
|
404
403
|
<FileItem
|
|
405
404
|
item={result}
|
|
@@ -410,7 +409,7 @@
|
|
|
410
409
|
on:action
|
|
411
410
|
/>
|
|
412
411
|
</div>
|
|
413
|
-
<span class="body-medium text-[hsl(var(--grey7))] truncate {result.isMissing ? 'text-[hsl(var(--error))]' : 'text-[hsl(var(--grey7))]'}">{@html highlightMatch(result.name, $searchTermStore)}</span>
|
|
412
|
+
<span dir={nameDirection} class="body-medium text-[hsl(var(--grey7))] truncate {result.isMissing ? 'text-[hsl(var(--error))]' : 'text-[hsl(var(--grey7))]'}">{@html highlightMatch(result.name, $searchTermStore)}</span>
|
|
414
413
|
</div>
|
|
415
414
|
{/if}
|
|
416
415
|
</button>
|
|
@@ -418,8 +417,8 @@
|
|
|
418
417
|
<!-- Jump to Folder Icon -->
|
|
419
418
|
<img
|
|
420
419
|
src={getAssetUrl('/icons/jump-to-folder.svg')}
|
|
421
|
-
alt=
|
|
422
|
-
class="jump-to-folder-icon w-6 h-6 absolute
|
|
420
|
+
alt={$t('searchModal.jumpToFolder')}
|
|
421
|
+
class="jump-to-folder-icon w-6 h-6 absolute end-6 top-1/2 transform -translate-y-1/2 z-20 pointer-events-none rtl:-scale-x-100"
|
|
423
422
|
class:active={index === activeIndex}
|
|
424
423
|
/>
|
|
425
424
|
</div>
|
|
@@ -429,7 +428,7 @@
|
|
|
429
428
|
<!-- End of Search Results Container -->
|
|
430
429
|
{:else if $searchTermStore}
|
|
431
430
|
<div style="height: {scrolledAreaMaxHeight}px; min-height: 70px;" class="overflow-hidden flex flex-col items-center justify-center">
|
|
432
|
-
<EmptyState class="!relative" message=
|
|
431
|
+
<EmptyState class="!relative" message={$t('searchModal.empty')} />
|
|
433
432
|
</div>
|
|
434
433
|
{/if}
|
|
435
434
|
|
|
@@ -20,12 +20,20 @@
|
|
|
20
20
|
|
|
21
21
|
// Local utils imports
|
|
22
22
|
import { getAllowedFileTypes, type FileFilterType } from '../../utils/fileTypes';
|
|
23
|
+
import { useI18n } from '../../i18n';
|
|
24
|
+
import { dirForUserText, useTextDirection } from '@widgetic/design-system/components/textDirection';
|
|
25
|
+
|
|
26
|
+
const { t } = useI18n();
|
|
27
|
+
// The reading direction of the screen: a name a visitor wrote keeps a direction of its own on a right to left screen.
|
|
28
|
+
const textDirection = useTextDirection();
|
|
29
|
+
$: nameDirection = dirForUserText($textDirection);
|
|
23
30
|
|
|
24
31
|
export let open = true;
|
|
25
32
|
export let currentFilter: FileFilterType = 'all';
|
|
26
33
|
export let allFiles: FileSystemItem[] = [];
|
|
27
34
|
export let showAddToEditor = true;
|
|
28
|
-
|
|
35
|
+
/** The words of the button that sends the files on. Left out, the File Browser's own ("Add to Editor", or the page's language's). */
|
|
36
|
+
export let addToEditorLabel: string | undefined = undefined;
|
|
29
37
|
export let target: string = 'selected-files-modal'; // target for Portal
|
|
30
38
|
|
|
31
39
|
// Consts
|
|
@@ -40,8 +48,8 @@
|
|
|
40
48
|
$: allowedTypes = getAllowedFileTypes(currentFilter);
|
|
41
49
|
$: confirmAddLabel =
|
|
42
50
|
selectedFiles.length <= 1
|
|
43
|
-
? addToEditorLabel
|
|
44
|
-
:
|
|
51
|
+
? (addToEditorLabel ?? $t('action.addToEditor'))
|
|
52
|
+
: $t('selectedFiles.confirmMany', { count: selectedFiles.length });
|
|
45
53
|
|
|
46
54
|
function handleClose() {
|
|
47
55
|
open = false;
|
|
@@ -59,8 +67,8 @@
|
|
|
59
67
|
});
|
|
60
68
|
|
|
61
69
|
// Show sonar toast instead of alert
|
|
62
|
-
toast.success('
|
|
63
|
-
description:
|
|
70
|
+
toast.success($t('toast.filesAdded'), {
|
|
71
|
+
description: $t('toast.filesAddedDetail', { count: selectedFiles.length })
|
|
64
72
|
});
|
|
65
73
|
|
|
66
74
|
// Clear selections and close modal
|
|
@@ -143,7 +151,8 @@
|
|
|
143
151
|
|
|
144
152
|
<BaseModal
|
|
145
153
|
bind:open
|
|
146
|
-
title=
|
|
154
|
+
title={$t('selectedFiles.title')}
|
|
155
|
+
closeLabel={$t('dialog.close')}
|
|
147
156
|
on:close={handleClose}
|
|
148
157
|
width="566px"
|
|
149
158
|
height="496px"
|
|
@@ -163,16 +172,16 @@
|
|
|
163
172
|
|
|
164
173
|
{#if selectedFiles.length === 0}
|
|
165
174
|
<div style="height: {scrolledAreaMaxHeight}px; min-height: 70px;" class="overflow-hidden flex flex-col items-center justify-center">
|
|
166
|
-
<EmptyState class="!relative" message=
|
|
175
|
+
<EmptyState class="!relative" message={$t('selectedFiles.empty')} />
|
|
167
176
|
</div>
|
|
168
177
|
{:else}
|
|
169
178
|
<!-- Selected Files Container -->
|
|
170
179
|
<WScrollArea class="selected-files-container flex-grow" style="height: {scrolledAreaMaxHeight}px;" scrollOutside={true} type="always">
|
|
171
|
-
<div class="file-items-container
|
|
180
|
+
<div class="file-items-container pe-4">
|
|
172
181
|
{#each selectedFiles as file (file.id)}
|
|
173
182
|
<div class="selected-file-item relative overflow-hidden rounded-large transition-colors duration-200 hover:bg-[hsl(var(--grey2))]">
|
|
174
183
|
<div
|
|
175
|
-
class="selected-file-item-row flex items-center justify-between min-h-[70px] cursor-pointer
|
|
184
|
+
class="selected-file-item-row flex items-center justify-between min-h-[70px] cursor-pointer pe-2 focus-visible:ring-0 focus-visible:ring-offset-0"
|
|
176
185
|
onclick={() => jumpToFolder(file)}
|
|
177
186
|
onkeydown={(e) => e.key === 'Enter' && jumpToFolder(file)}
|
|
178
187
|
role="button"
|
|
@@ -187,12 +196,12 @@
|
|
|
187
196
|
thumbnailOnly={true}
|
|
188
197
|
/>
|
|
189
198
|
</div>
|
|
190
|
-
<span class="body-medium truncate {file.isMissing ? 'text-[hsl(var(--error))]' : 'text-[hsl(var(--grey7))]'}">{file.name}</span>
|
|
199
|
+
<span dir={nameDirection} class="body-medium truncate {file.isMissing ? 'text-[hsl(var(--error))]' : 'text-[hsl(var(--grey7))]'}">{file.name}</span>
|
|
191
200
|
</div>
|
|
192
201
|
|
|
193
|
-
<div class="selected-file-item-actions flex shrink-0 items-center gap-3
|
|
202
|
+
<div class="selected-file-item-actions flex shrink-0 items-center gap-3 ps-2">
|
|
194
203
|
<IconCornerUpRight
|
|
195
|
-
class="h-6 w-6 shrink-0 text-[hsl(var(--grey7))]"
|
|
204
|
+
class="h-6 w-6 shrink-0 text-[hsl(var(--grey7))] rtl:-scale-x-100"
|
|
196
205
|
/>
|
|
197
206
|
|
|
198
207
|
<button
|
|
@@ -220,7 +229,7 @@
|
|
|
220
229
|
<!-- Results Count -->
|
|
221
230
|
<div class="results-count text-[hsl(var(--grey5))] subtext">
|
|
222
231
|
{#if selectedFiles.length > 0}
|
|
223
|
-
{selectedFiles.
|
|
232
|
+
{$t('selectedFiles.count', { count: selectedFiles.length })}
|
|
224
233
|
{/if}
|
|
225
234
|
</div>
|
|
226
235
|
|
|
@@ -231,7 +240,7 @@
|
|
|
231
240
|
class="modal-btn-secondary !h-[34px]"
|
|
232
241
|
onclick={handleClose}
|
|
233
242
|
>
|
|
234
|
-
<span>
|
|
243
|
+
<span>{$t('action.cancel')}</span>
|
|
235
244
|
</Button>
|
|
236
245
|
|
|
237
246
|
<!-- Add to Editor Button -->
|
|
@@ -18,7 +18,7 @@ declare const SelectedFilesModal: $$__sveltets_2_IsomorphicComponent<{
|
|
|
18
18
|
currentFilter?: FileFilterType;
|
|
19
19
|
allFiles?: FileSystemItem[];
|
|
20
20
|
showAddToEditor?: boolean;
|
|
21
|
-
addToEditorLabel?: string;
|
|
21
|
+
/** The words of the button that sends the files on. Left out, the File Browser's own ("Add to Editor", or the page's language's). */ addToEditorLabel?: string | undefined;
|
|
22
22
|
target?: string;
|
|
23
23
|
}, {
|
|
24
24
|
close: CustomEvent<any>;
|
|
@@ -9,6 +9,9 @@
|
|
|
9
9
|
// Local components imports
|
|
10
10
|
import ErrorPreview from './ErrorPreview.svelte';
|
|
11
11
|
import WaveformVisualizer from './WaveformVisualizer.svelte';
|
|
12
|
+
import { useI18n } from '../../i18n';
|
|
13
|
+
|
|
14
|
+
const { t } = useI18n();
|
|
12
15
|
|
|
13
16
|
export let src: string;
|
|
14
17
|
export let autoplay = false;
|
|
@@ -66,7 +69,7 @@
|
|
|
66
69
|
</script>
|
|
67
70
|
|
|
68
71
|
{#if hasError}
|
|
69
|
-
<ErrorPreview message=
|
|
72
|
+
<ErrorPreview message={$t('preview.audioFailed')} />
|
|
70
73
|
{:else}
|
|
71
74
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
72
75
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
@@ -111,7 +114,7 @@
|
|
|
111
114
|
onplay={handlePlay}
|
|
112
115
|
onpause={handlePause}
|
|
113
116
|
>
|
|
114
|
-
|
|
117
|
+
{$t('preview.audioUnsupported')}
|
|
115
118
|
</audio>
|
|
116
119
|
</div>
|
|
117
120
|
{/if}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
// Local utils imports
|
|
3
3
|
import { getAssetUrl } from '../../utils/fileUtils';
|
|
4
|
+
import { useI18n } from '../../i18n';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
const { t } = useI18n();
|
|
7
|
+
|
|
8
|
+
// Component props: the sentence under the icon. Left out, "File not found" (in the page's language).
|
|
9
|
+
export let message: string | undefined = undefined;
|
|
7
10
|
</script>
|
|
8
11
|
|
|
9
12
|
<div class="error-preview-container flex flex-col items-center justify-center h-[60vh] space-y-4">
|
|
10
|
-
<img src={getAssetUrl('/icons/error.svg')} alt=
|
|
11
|
-
<p class="text-gray-600">{message}</p>
|
|
13
|
+
<img src={getAssetUrl('/icons/error.svg')} alt={$t('preview.errorAlt')} class="w-16 h-16" />
|
|
14
|
+
<p class="text-gray-600">{message ?? $t('preview.fileNotFound')}</p>
|
|
12
15
|
</div>
|
|
@@ -12,7 +12,7 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
|
|
|
12
12
|
z_$$bindings?: Bindings;
|
|
13
13
|
}
|
|
14
14
|
declare const ErrorPreview: $$__sveltets_2_IsomorphicComponent<{
|
|
15
|
-
message?: string;
|
|
15
|
+
message?: string | undefined;
|
|
16
16
|
}, {
|
|
17
17
|
[evt: string]: CustomEvent<any>;
|
|
18
18
|
}, {}, {}, string>;
|