@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.
Files changed (97) hide show
  1. package/README.md +279 -0
  2. package/dist/components/FolderTree.svelte +16 -9
  3. package/dist/components/FolderTree.svelte.d.ts +2 -6
  4. package/dist/components/core/FileBrowser.svelte +529 -127
  5. package/dist/components/core/FileBrowser.svelte.d.ts +40 -1
  6. package/dist/components/core/FileUploader.svelte +130 -57
  7. package/dist/components/core/Header.svelte +13 -2
  8. package/dist/components/core/Header.svelte.d.ts +1 -0
  9. package/dist/components/core/RecentFiles.svelte +41 -29
  10. package/dist/components/core/UploadStatus.svelte +14 -7
  11. package/dist/components/core/UploadStatusList.svelte +13 -21
  12. package/dist/components/items/FileItem.svelte +28 -15
  13. package/dist/components/items/FolderItem.svelte +13 -6
  14. package/dist/components/modals/MoveDialog.svelte +49 -38
  15. package/dist/components/modals/NewFolderButton.svelte +5 -2
  16. package/dist/components/modals/SearchModal.svelte +25 -26
  17. package/dist/components/modals/SearchModal.svelte.d.ts +1 -1
  18. package/dist/components/modals/SelectedFilesModal.svelte +23 -14
  19. package/dist/components/modals/SelectedFilesModal.svelte.d.ts +1 -1
  20. package/dist/components/previews/AudioPlayer.svelte +5 -2
  21. package/dist/components/previews/ErrorPreview.svelte +7 -4
  22. package/dist/components/previews/ErrorPreview.svelte.d.ts +1 -1
  23. package/dist/components/previews/FilePreview.svelte +25 -9
  24. package/dist/components/previews/FontPreview.svelte +18 -9
  25. package/dist/components/previews/FontPreview.svelte.d.ts +1 -1
  26. package/dist/components/previews/TextPreview.svelte +12 -5
  27. package/dist/components/previews/VideoPlayer.svelte +11 -7
  28. package/dist/components/ui/ControlToolbar.svelte +50 -28
  29. package/dist/components/ui/ControlToolbar.svelte.d.ts +1 -1
  30. package/dist/components/ui/DragSelect.svelte +3 -2
  31. package/dist/components/ui/DropdownMenu.svelte +35 -14
  32. package/dist/components/ui/FileIcon.svelte +8 -5
  33. package/dist/components/ui/FileIcon.svelte.d.ts +1 -0
  34. package/dist/components/ui/FileMetadata.svelte +16 -15
  35. package/dist/components/ui/SearchResults.svelte +9 -2
  36. package/dist/i18n/context.d.ts +28 -0
  37. package/dist/i18n/context.js +17 -0
  38. package/dist/i18n/errors.d.ts +11 -0
  39. package/dist/i18n/errors.js +19 -0
  40. package/dist/i18n/index.d.ts +15 -0
  41. package/dist/i18n/index.js +18 -0
  42. package/dist/i18n/messages.d.ts +281 -0
  43. package/dist/i18n/messages.js +294 -0
  44. package/dist/i18n/text.d.ts +19 -0
  45. package/dist/i18n/text.js +35 -0
  46. package/dist/index.d.ts +3 -0
  47. package/dist/index.js +4 -0
  48. package/dist/mediaLibrary/capabilities.d.ts +22 -0
  49. package/dist/mediaLibrary/capabilities.js +42 -0
  50. package/dist/mediaLibrary/context.d.ts +17 -0
  51. package/dist/mediaLibrary/context.js +16 -0
  52. package/dist/mediaLibrary/errors.d.ts +42 -0
  53. package/dist/mediaLibrary/errors.js +114 -0
  54. package/dist/mediaLibrary/index.d.ts +10 -0
  55. package/dist/mediaLibrary/index.js +9 -0
  56. package/dist/mediaLibrary/normalize.d.ts +39 -0
  57. package/dist/mediaLibrary/normalize.js +139 -0
  58. package/dist/mediaLibrary/paging.d.ts +37 -0
  59. package/dist/mediaLibrary/paging.js +62 -0
  60. package/dist/mediaLibrary/resolve.d.ts +39 -0
  61. package/dist/mediaLibrary/resolve.js +137 -0
  62. package/dist/mediaLibrary/treeOps.d.ts +24 -0
  63. package/dist/mediaLibrary/treeOps.js +67 -0
  64. package/dist/mediaLibrary/types.d.ts +126 -0
  65. package/dist/mediaLibrary/types.js +11 -0
  66. package/dist/mediaLibrary/urls.d.ts +30 -0
  67. package/dist/mediaLibrary/urls.js +59 -0
  68. package/dist/mediaLibrary/widgetic.d.ts +39 -0
  69. package/dist/mediaLibrary/widgetic.js +89 -0
  70. package/dist/stores/fileStore.d.ts +2 -2
  71. package/dist/stores/folderCountStore.js +2 -2
  72. package/dist/stores/navigationStore.d.ts +1 -1
  73. package/dist/stores/persistentSelectStore.d.ts +11 -1
  74. package/dist/stores/persistentSelectStore.js +26 -0
  75. package/dist/utils/dateUtils.d.ts +11 -2
  76. package/dist/utils/dateUtils.js +20 -15
  77. package/dist/utils/fileKinds.d.ts +44 -0
  78. package/dist/utils/fileKinds.js +96 -0
  79. package/dist/utils/fileNames.d.ts +7 -0
  80. package/dist/utils/fileNames.js +19 -0
  81. package/dist/utils/fileOperations.js +2 -11
  82. package/dist/utils/fileTypes.d.ts +11 -2
  83. package/dist/utils/fileTypes.js +26 -14
  84. package/dist/utils/fileUtils.d.ts +8 -1
  85. package/dist/utils/fileUtils.js +22 -7
  86. package/dist/utils/folderUtils.js +3 -2
  87. package/dist/utils/previewKeys.d.ts +12 -0
  88. package/dist/utils/previewKeys.js +14 -0
  89. package/dist/utils/safeText.d.ts +29 -0
  90. package/dist/utils/safeText.js +66 -0
  91. package/dist/utils/userUploadsStorage.d.ts +4 -1
  92. package/dist/utils/userUploadsStorage.js +5 -2
  93. package/dist/utils/widgeticTusUpload.d.ts +10 -0
  94. package/dist/utils/widgeticTusUpload.js +61 -3
  95. package/dist/utils/widgeticUpload.d.ts +3 -0
  96. package/dist/utils/widgeticUpload.js +7 -2
  97. 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
- sourceItems.length === 1 && sourceItems[0]?.type === 'folder'
139
- ? 'Failed to move folder'
140
- : 'Failed to move items',
154
+ failedMoveTitle(),
141
155
  {
142
- description: 'No target folder selected',
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
- 'Failed to move items',
167
+ $t('moveDialog.failedItems'),
154
168
  {
155
- description: 'No items selected to move',
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('Some items moved', {
247
- description: `Moved ${movedItems.length} out of ${sourceItems.length} items`,
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 ? `Folder moved` : `${sourceItems.length === 1 ? 'Item' : 'Items'} moved`,
269
+ isFolder ? $t('moveDialog.doneFolder') : sourceItems.length === 1 ? $t('moveDialog.doneOne') : $t('moveDialog.doneMany'),
256
270
  {
257
271
  description: isFolder
258
- ? `Moved folder "${sourceItems[0].name}" successfully`
259
- : `Moved ${sourceItems.length} ${sourceItems.length === 1 ? 'item' : 'items'} successfully`,
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
- throw new Error('No items were moved successfully');
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
- isFolder ? 'Failed to move folder' : 'Failed to move items',
297
+ failedMoveTitle(),
284
298
  {
285
- description: error instanceof Error ? error.message : 'Unknown error occurred',
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
- sourceItems.length === 1 && sourceItems[0]?.type === 'folder'
300
- ? 'Failed to move folder'
301
- : 'Failed to move items',
313
+ failedMoveTitle(),
302
314
  {
303
- description: 'Please select a destination folder',
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 && sourceItems[0]?.type === 'folder'
334
- ? `Move "${sourceItems[0]?.name.length > 30 ? sourceItems[0]?.name.slice(0, 30) + '...' : sourceItems[0]?.name}"`
335
- : sourceItems.length === 1
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] pl-2 rounded-large cursor-pointer
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="File browser"
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-left {immediateParentId === null ? 'text-[hsl(var(--grey3))]' : 'text-[hsl(var(--grey7))]'} {selectedFolder?.id === 'root' ? 'font-bold' : 'font-normal'}">File browser</span>
412
- <div class="flex items-center ml-auto">
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 mr-6">current location</span>
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))] mr-6" />
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 pl-8 flex flex-col">
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))] mr-2"
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
- Moving to {selectedFolder.name}
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>Cancel</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>Move folder</span>
485
+ <span>{$t('moveDialog.confirmFolder')}</span>
475
486
  {:else if sourceItems.length === 1}
476
- <span>Move to folder</span>
487
+ <span>{$t('moveDialog.confirmItem')}</span>
477
488
  {:else}
478
- <span>Move {sourceItems.length} items</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
- left: 0;
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="New Folder" class="w-full h-full object-contain" />
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">New folder</h3>
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 { getFileType, getFileIcon } from '../../utils/fileUtils';
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
- if (!name || !term) return name || '';
167
-
168
- const escapedName = name.replace(/[&<>"']/g, char => ({
169
- '&': '&amp;',
170
- '<': '&lt;',
171
- '>': '&gt;',
172
- '"': '&quot;',
173
- "'": '&#39;'
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 = getFileType(item.url || item.name);
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 = getFileType(file.url || file.name);
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="Search files and folders..."
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 pr-12">
398
- <img src={getFolderIcon(result, currentFilter)} alt="Folder" class="w-[62px] h-[54px] object-contain shrink-0" />
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 pr-12">
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="Jump to folder"
422
- class="jump-to-folder-icon w-6 h-6 absolute right-6 top-1/2 transform -translate-y-1/2 z-20 pointer-events-none"
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="No files found" />
431
+ <EmptyState class="!relative" message={$t('searchModal.empty')} />
433
432
  </div>
434
433
  {/if}
435
434
 
@@ -17,7 +17,7 @@ declare const SearchModal: $$__sveltets_2_IsomorphicComponent<{
17
17
  open?: boolean;
18
18
  target?: string;
19
19
  }, {
20
- action: CustomEvent<any>;
20
+ action: any;
21
21
  close: CustomEvent<any>;
22
22
  preview: CustomEvent<any>;
23
23
  navigate: CustomEvent<any>;
@@ -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
- export let addToEditorLabel = 'Add to Editor';
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
- : `Use ${selectedFiles.length} files`;
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('Files added', {
63
- description: `Added ${selectedFiles.length} ${selectedFiles.length === 1 ? 'file' : 'files'} to the editor`
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="Selected files"
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="No files selected" />
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 pr-4">
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 pr-2 focus-visible:ring-0 focus-visible:ring-offset-0"
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 pl-2">
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.length} {selectedFiles.length === 1 ? 'file' : 'files'} selected
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>Cancel</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="Audio failed to load" />
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
- Your browser does not support the audio element.
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
- // Component props
6
- export let message = "File not found";
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="Error" class="w-16 h-16" />
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>;