@widgetic/file-browser 0.5.25 → 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 CHANGED
@@ -121,8 +121,10 @@ then lists, uploads, renames and deletes through those functions and never talks
121
121
  - **The library's own failures are shown as they are.** The message of the error you throw reaches the visitor (cut
122
122
  at 300 characters): a screen with "Try again" when the first page cannot be read, a notice when a later page fails,
123
123
  a message in the upload panel, a toast for rename and delete. Toasts are drawn by the design system's
124
- `<ToasterModal />`, which **the app around the File Browser has to render** (the Widgetic site's layout does): without
125
- one, a refused rename or delete shows the visitor nothing and the `error` event is the only sign.
124
+ `<ToasterModal />`: **pass `renderToaster` and the File Browser draws one itself**, in the language of `locale` and
125
+ `messages` (`toast.regionLabel` and `toast.closeLabel` are what a screen reader hears). An app that renders its own
126
+ `<ToasterModal />` (the Widgetic site's layout does) leaves `renderToaster` off, or its toasts would be drawn twice.
127
+ With neither, a refused rename or delete shows the visitor nothing and the `error` event is the only sign.
126
128
  - **Calls are given 30 seconds** (`list`, `rename`, `delete`). An upload has no time limit, the visitor can cancel it.
127
129
  `signal` is aborted when the visitor cancels, or the File Browser is closed: stop your request then.
128
130
 
@@ -187,8 +189,8 @@ tried once more. It has no Rename or Delete: the API cannot do them yet.
187
189
 
188
190
  ## Languages
189
191
 
190
- The File Browser shows English until it is told otherwise. Two props change that, and both can change while the File
191
- Browser is open:
192
+ The File Browser shows English until it is told otherwise. Two props change that, a third says which way it is read, and
193
+ all of them can change while the File Browser is open:
192
194
 
193
195
  ```svelte
194
196
  <FileBrowser
@@ -207,6 +209,10 @@ Browser is open:
207
209
  - **`messages`** replaces words. Every word the File Browser shows is a message with a key; give the keys you want
208
210
  to change and every key you leave out stays English, so a language can be added one screen at a time. A key that does
209
211
  not exist is ignored and the console says which key you probably meant.
212
+ - **`dir`** is `'ltr'` or `'rtl'`. It is not a word and it is not taken from `locale`: it says which way the screen is
213
+ read, and `dir="rtl"` turns the File Browser around for a language that is written right to left. Left out, the File
214
+ Browser is read the way the screen around it is (inside the composition editor it turns around with it), and left to right
215
+ when nothing around it says. See "Right to left" below.
210
216
 
211
217
  `FILE_BROWSER_MESSAGES` is the list: an object of every key and its English text (the keys are grouped by where the words
212
218
  appear), and it is the list to hand to a translator:
@@ -270,6 +276,52 @@ expect(checkFileBrowserMessages(german).map(describeMessageProblem)).toEqual([])
270
276
  While the File Browser runs, a message that cannot be used is never thrown: the English text of that key is shown and
271
277
  the console says `[FileBrowser] ...` once.
272
278
 
279
+ ### Right to left
280
+
281
+ Arabic, Hebrew, Persian, Urdu and the other languages that are written from right to left start a line on the right.
282
+ `dir="rtl"` makes the File Browser read that way, and `resolveTextDirection(locale)` from `@widgetic/design-system/i18n`
283
+ answers "which way is this language written" (`'rtl'` or `'ltr'`, never an error, `'ltr'` for a blank or unreadable tag):
284
+
285
+ ```svelte
286
+ <script>
287
+ import { FileBrowser } from '@widgetic/file-browser';
288
+ import { resolveTextDirection } from '@widgetic/design-system/i18n';
289
+
290
+ export let locale = 'ar';
291
+ </script>
292
+
293
+ <FileBrowser {locale} dir={resolveTextDirection(locale)} />
294
+ ```
295
+
296
+ - **`dir` is a prop of its own.** The File Browser is also a part of other screens (the file picker of the composition
297
+ editor, and so the widget creator), and the screen around it decides, not the words: the File Browser in a picker inside
298
+ an Arabic editor is read right to left whatever its own `locale`, and one inside an English editor left to right. Left out,
299
+ it follows that screen (a component above it that calls `provideTextDirection(store)` from
300
+ `@widgetic/design-system/components/textDirection`); a `dir` that is given wins over it. The page around it does not
301
+ decide either: a File Browser on a page that is written right to left stays left to right until it is given
302
+ `dir="rtl"` or sits in a screen that is.
303
+ - **What turns around.** The list starts on the right and the row that does not fit goes on under it. The search box, the
304
+ sort and filter controls, the selection bar, the path bar, the upload panel and the windows (Rename, New folder, Delete,
305
+ Move, search, the selected files and the preview) are laid out from the right, and the close button of a window is in the
306
+ corner where a line starts. Menus open toward the end of the line, and the pop-up of an action comes up in the bottom
307
+ corner where a line starts. Arrows that mean back and forward are mirrored; in the preview the arrow key that points
308
+ toward the end of the line goes on to the next file.
309
+ - **Names of files and folders** are read by their own first letter (`dir="auto"`), so a Latin name such as
310
+ `2024 report.pdf` is not put in the wrong order in a row of Arabic ones. On a left to right screen nothing is added.
311
+ - **A name inside a sentence** ("Failed to delete 2024 report.pdf") sits between two invisible marks, the Unicode
312
+ isolates U+2068 and U+2069, whenever `locale` is a language written right to left, so the words around it cannot turn it
313
+ around (a name that starts with a digit or has a hyphen would be). A screen reader does not say them; a test that
314
+ compares the text of a pop-up has to leave them out. The translator does this for every package that uses it, whatever
315
+ `dir` says.
316
+ - **What stays left to right on purpose:** the time line of the video player, because time runs from left to right in every
317
+ language.
318
+ - **Not looked at in a browser yet:** the folder tree, the Move window, the search window and the list of recent files use
319
+ the same placement as the rest and are covered by the source check below, but no browser test opens them in Arabic.
320
+ - **Keeping it so.** `tests/rtl/sourcePlacement.test.ts` reads the whole source with `auditPhysicalPlacement` from
321
+ `@widgetic/design-system/rtl/audit` and fails on a class or a style that puts something on a physical side (`left`,
322
+ `right`, `ml-`, `pr-`, `text-left`, `border-l`, `rounded-tl` ...). Write the logical one (`start`, `end`, `ms-`, `pe-`,
323
+ `text-start`, `border-s`, `rounded-ss`) or say why with the note `rtl-ok` on the same line or the line above.
324
+
273
325
  ### What stays as it is
274
326
 
275
327
  - **Words that belong to someone else.** The File Browser shows what your media library says as it says it: the message
@@ -277,11 +329,13 @@ the console says `[FileBrowser] ...` once.
277
329
  only used when the library gave no reason), and neither are your file names, your library's `label`, or the names
278
330
  of folders a visitor made. The same goes for a sentence Widgetic's API sends back.
279
331
  - **`error` events.** `event.detail.message` stays English: it is for your logs, not for the visitor.
280
- - **Right to left.** Arabic and Hebrew words show, and numbers and dates follow the locale, but the layout does not
281
- flip: this version is made for left to right languages.
282
- - **The design system.** The words of the Rename and New folder windows, the close button of every window, the path
283
- bar and the PDF viewer come from `@widgetic/design-system` **0.5.16 or newer**; with an older one those words stay
284
- English (nothing breaks). The File Browser's own words are not affected.
332
+ - **Right to left.** The words and the numbers follow `locale` and the layout follows `dir`; the two are set apart on
333
+ purpose (see "Right to left" above), so a page that gives a right to left `locale` and no `dir` has the words in
334
+ Arabic and a layout that reads left to right.
335
+ - **The design system.** The File Browser needs `@widgetic/design-system` **0.5.16 or newer**. Its words are made by the
336
+ design system's `@widgetic/design-system/i18n` (the same translator the editor and the other packages use), and the
337
+ words of the Rename and New folder windows, the close button of every window, the path bar and the PDF viewer come
338
+ from the design system too. With an older one the File Browser does not load: update the design system.
285
339
 
286
340
  The `@widgetic/ui-sdk` module of the File Browser takes the same `locale` and `messages`, and adds `setLanguage()`; see
287
341
  its README, "Speaking your visitors' language".
@@ -2,6 +2,7 @@
2
2
  import type { FileSystemItem } from '../types';
3
3
  import { getFolderIcon } from '../utils/folderUtils';
4
4
  import { useI18n } from '../i18n';
5
+ import { dirForUserText, useTextDirection } from '@widgetic/design-system/components/textDirection';
5
6
  // Import IconArrowBounce
6
7
  import { IconArrowBounce } from '@widgetic/design-system/icons';
7
8
 
@@ -18,12 +19,15 @@
18
19
  // New props for custom styling
19
20
  export let customClasses = "";
20
21
  export let iconSize = "40"; // Now expecting a number string for direct width/height
21
- export let textClass = "text-base flex-grow text-left";
22
+ export let textClass = "text-base flex-grow text-start";
22
23
  export let selectedIconClass = "w-5 h-5 text-[hsl(var(--info))]";
23
- export let currentLocationClass = "text-sm text-[hsl(var(--info))] mr-2";
24
+ export let currentLocationClass = "text-sm text-[hsl(var(--info))] me-2";
24
25
  export let selectedIcon = IconArrowBounce;
25
26
 
26
27
  const { t } = useI18n();
28
+ // The reading direction of the screen: a name a visitor wrote keeps a direction of its own on a right to left screen.
29
+ const textDirection = useTextDirection();
30
+ $: nameDirection = dirForUserText($textDirection);
27
31
 
28
32
  // Filter children to only include folders
29
33
  $: folderChildren = folder.children?.filter(item => item.type === 'folder') || [];
@@ -66,18 +70,18 @@
66
70
  />
67
71
  </div>
68
72
  </div>
69
- <span class="flex-grow text-left {isCurrentLocation ? 'text-[hsl(var(--grey3))]' : 'text-[hsl(var(--grey7))]'} {isSelected ? 'font-bold' : 'font-normal'} body-medium truncate">{folder.name}</span>
70
- <div class="flex items-center ml-auto">
73
+ <span dir={nameDirection} class="flex-grow text-start {isCurrentLocation ? 'text-[hsl(var(--grey3))]' : 'text-[hsl(var(--grey7))]'} {isSelected ? 'font-bold' : 'font-normal'} body-medium truncate">{folder.name}</span>
74
+ <div class="flex items-center ms-auto">
71
75
  {#if isCurrentLocation}
72
76
  <span class="h6 text-[hsl(var(--sage-green))] relative z-10">{$t('folder.currentLocation')}</span>
73
77
  {/if}
74
78
  {#if isSelected}
75
- <svelte:component this={selectedIcon} class="{selectedIconClass}" />
79
+ <svelte:component this={selectedIcon} class="{selectedIconClass} rtl:-scale-x-100" />
76
80
  {/if}
77
81
  </div>
78
82
  </button>
79
83
  {#if folderChildren.length > 0}
80
- <div class="pl-8">
84
+ <div class="ps-8">
81
85
  {#each folderChildren as child}
82
86
  <svelte:self
83
87
  folder={child}
@@ -105,7 +109,7 @@
105
109
  .folder-item::before {
106
110
  content: '';
107
111
  position: absolute;
108
- left: 0;
112
+ inset-inline-start: 0;
109
113
  top: 0;
110
114
  bottom: 0;
111
115
  width: 2px;
@@ -115,7 +119,7 @@
115
119
 
116
120
  /* Apply appropriate padding for icon placement */
117
121
  .folder-button {
118
- padding-right: 24px;
122
+ padding-inline-end: 24px;
119
123
  }
120
124
 
121
125
  /* Explicitly handle the selected state to override the default hover */
@@ -57,12 +57,12 @@
57
57
  createUserUploadsFileSystemRoot,
58
58
  } from '../../utils/userUploadsStorage';
59
59
  import { fetchUserUploadsFromApi } from '../../utils/widgeticUpload';
60
- import { get } from 'svelte/store';
60
+ import { get, writable } from 'svelte/store';
61
61
  import { resolveFileItemUrl } from '../../utils/resolveFileUrl';
62
62
  import { dev } from '$app/environment';
63
63
  import demoContentData from '../../data/demoContent.json';
64
64
  // import { showToast } from '../../utils/toastUtils';
65
- import { showToast } from '@widgetic/design-system/components';
65
+ import { showToast, ToasterModal } from '@widgetic/design-system/components';
66
66
 
67
67
  // Constants for localStorage keys
68
68
  const FILTER_STORAGE_KEY = (id: string) => `file-browser-filter-${id}`;
@@ -104,7 +104,9 @@
104
104
  // I18N IMPORTS (the words of the File Browser, in the page's language)
105
105
  import { provideI18n } from '../../i18n/context';
106
106
  import { messageForVisitor } from '../../i18n/errors';
107
- import type { MessageOverrides } from '../../i18n/translator';
107
+ import type { MessageOverrides } from '@widgetic/design-system/i18n';
108
+ // The reading direction the screen is laid out in, shared with the parts below (see the `dir` prop)
109
+ import { shareTextDirection, type TextDirection } from '@widgetic/design-system/components/textDirection';
108
110
 
109
111
  // logs flags
110
112
  let showLogs = false;
@@ -174,6 +176,22 @@
174
176
  * its English text. Can change while the File Browser is open.
175
177
  */
176
178
  export let messages: MessageOverrides | null = null;
179
+ /**
180
+ * Which way the File Browser is read: "ltr" or "rtl". The page that puts it on screen sets `dir` on an element
181
+ * around it, and the browser turns the layout around. This prop says the same to the parts that wrap a library that
182
+ * writes a `dir` of its own (the scroll areas, the menus, the toaster) and to the code that follows the reading
183
+ * direction (the arrow keys of the file preview). It is NOT worked out from `locale`: a File Browser inside an editor
184
+ * that is laid out left to right can speak Arabic and still be left to right. Left out, the File Browser is read the way
185
+ * the screen around it is (a File Browser inside the composition editor turns around with it, whatever the page's
186
+ * `locale`), and left to right when nothing around it says. Can change while the File Browser is open.
187
+ */
188
+ export let dir: TextDirection | undefined = undefined;
189
+ /**
190
+ * Draws the pop-ups ("Folder created", "Rename failed" ...) itself, in the language of `locale` and `messages`. They are
191
+ * shown with the design system's `showToast`, which draws into a `<ToasterModal>`: leave this false when the app around
192
+ * the File Browser already renders one (the Widgetic site does, in its layout), true when nothing does.
193
+ */
194
+ export let renderToaster = false;
177
195
  /** When false, skips bundled demo tree (use with Widgetic upload config). */
178
196
  export let useDemoContent = true;
179
197
  /**
@@ -425,6 +443,11 @@
425
443
  const i18n = provideI18n({ locale, messages });
426
444
  const { t } = i18n;
427
445
  $: i18n.update({ locale, messages });
446
+ // The reading direction: the parts below read it from Svelte's context, and follow when the page changes `dir`, or, with
447
+ // no `dir`, when the screen around the File Browser turns around.
448
+ const givenDirection = writable<TextDirection | undefined>(dir);
449
+ shareTextDirection(givenDirection);
450
+ $: givenDirection.set(dir);
428
451
  // The text of the confirm button: the page's label, or the message of the language in use.
429
452
  $: addToEditorText = addToEditorLabel ?? $t('action.addToEditor');
430
453
 
@@ -2686,13 +2709,13 @@ mainGridClass="app-main-grid"
2686
2709
  }}
2687
2710
  >
2688
2711
  <span>{$t('filter.by', { type: $t(`filterName.${filter}`) })}</span>
2689
- <IconAdjustmentsHorizontal class="h-5 w-5 text-[hsl(var(--grey5))] ml-1 transition-colors duration-200 group-hover:text-[hsl(var(--grey7))]" />
2712
+ <IconAdjustmentsHorizontal class="h-5 w-5 text-[hsl(var(--grey5))] ms-1 transition-colors duration-200 group-hover:text-[hsl(var(--grey7))]" />
2690
2713
  </button>
2691
2714
 
2692
2715
  <!-- Filter Dropdown -->
2693
2716
  {#if filterDropdownOpen}
2694
2717
  <div
2695
- class="filter-dropdown absolute right-0 mt-2 w-48 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 focus:outline-none z-50"
2718
+ class="filter-dropdown absolute end-0 mt-2 w-48 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 focus:outline-none z-50"
2696
2719
  role="menu"
2697
2720
  aria-orientation="vertical"
2698
2721
  aria-labelledby="filter-menu"
@@ -2745,7 +2768,7 @@ mainGridClass="app-main-grid"
2745
2768
  </div>
2746
2769
 
2747
2770
  <!-- FILE BROWSER CONTENT -->
2748
- <div class="file-browser-content flex min-h-0 flex-col grow mr-[4px] overflow-hidden relative widgetic-colors">
2771
+ <div class="file-browser-content flex min-h-0 flex-col grow me-[4px] overflow-hidden relative widgetic-colors">
2749
2772
  <!-- Media library notice: the list on screen is not the whole library -->
2750
2773
  {#if libraryNotice}
2751
2774
  <div class="library-notice mx-6 mt-3 flex shrink-0 items-center justify-between gap-3 rounded-md bg-[hsl(var(--grey1))] px-3 py-2 subtext text-[hsl(var(--grey7))]" role="status">
@@ -2762,7 +2785,7 @@ mainGridClass="app-main-grid"
2762
2785
  <div class="grid grid-cols-3 gap-8">
2763
2786
  {#each Array(skeletonCount) as _}
2764
2787
  <div class="flex items-start">
2765
- <LoadingSkeleton width="62px" height="54px" className="mr-4" />
2788
+ <LoadingSkeleton width="62px" height="54px" className="me-4" />
2766
2789
  <div class="grow">
2767
2790
  <LoadingSkeleton width="100%" height="20px" className="mb-2" />
2768
2791
  <LoadingSkeleton width="60%" height="16px" />
@@ -2790,7 +2813,7 @@ mainGridClass="app-main-grid"
2790
2813
  {:else}
2791
2814
  <!-- Main content container with Files Inside --> <!-- {!showAddToEditor ? 'overflow-y-auto px-6' : ''} -->
2792
2815
  <WScrollArea class="scroll-area-container min-h-0 flex-1" bind:element={scrollContainer} type="always">
2793
- <div class="main-content-container flex flex-col p-6 pr-1" bind:this={contentContainer}>
2816
+ <div class="main-content-container flex flex-col p-6 pe-1" bind:this={contentContainer}>
2794
2817
 
2795
2818
  <!-- Drag Select for selecting files -->
2796
2819
  {#if allowSelecting}
@@ -3130,6 +3153,11 @@ mainGridClass="app-main-grid"
3130
3153
  />
3131
3154
  {/if}
3132
3155
 
3156
+ <!-- POP-UPS (only for an app that has no toaster of its own) -->
3157
+ {#if renderToaster}
3158
+ <ToasterModal containerAriaLabel={$t('toast.regionLabel')} closeButtonAriaLabel={$t('toast.closeLabel')} />
3159
+ {/if}
3160
+
3133
3161
  <!-- STYLES -->
3134
3162
  <style>
3135
3163
 
@@ -2,7 +2,8 @@ import './FileBrowser.css';
2
2
  import '@widgetic/design-system/styles';
3
3
  import { type FileFilterType } from '../../utils/fileTypes';
4
4
  import type { MediaLibraryProvider } from '../../mediaLibrary/types';
5
- import type { MessageOverrides } from '../../i18n/translator';
5
+ import type { MessageOverrides } from '@widgetic/design-system/i18n';
6
+ import { type TextDirection } from '@widgetic/design-system/components/textDirection';
6
7
  interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
7
8
  new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
8
9
  $$bindings?: Bindings;
@@ -59,6 +60,20 @@ declare const FileBrowser: $$__sveltets_2_IsomorphicComponent<{
59
60
  * The page's own words: any of the keys of FILE_BROWSER_MESSAGES (see the README, "Languages"). A key left out keeps
60
61
  * its English text. Can change while the File Browser is open.
61
62
  */ messages?: MessageOverrides | null;
63
+ /**
64
+ * Which way the File Browser is read: "ltr" or "rtl". The page that puts it on screen sets `dir` on an element
65
+ * around it, and the browser turns the layout around. This prop says the same to the parts that wrap a library that
66
+ * writes a `dir` of its own (the scroll areas, the menus, the toaster) and to the code that follows the reading
67
+ * direction (the arrow keys of the file preview). It is NOT worked out from `locale`: a File Browser inside an editor
68
+ * that is laid out left to right can speak Arabic and still be left to right. Left out, the File Browser is read the way
69
+ * the screen around it is (a File Browser inside the composition editor turns around with it, whatever the page's
70
+ * `locale`), and left to right when nothing around it says. Can change while the File Browser is open.
71
+ */ dir?: TextDirection | undefined;
72
+ /**
73
+ * Draws the pop-ups ("Folder created", "Rename failed" ...) itself, in the language of `locale` and `messages`. They are
74
+ * shown with the design system's `showToast`, which draws into a `<ToasterModal>`: leave this false when the app around
75
+ * the File Browser already renders one (the Widgetic site does, in its layout), true when nothing does.
76
+ */ renderToaster?: boolean;
62
77
  /** When false, skips bundled demo tree (use with Widgetic upload config). */ useDemoContent?: boolean;
63
78
  /**
64
79
  * Opt-in Dexie L1 (`@widgetic/cache-layer`). Default false.
@@ -29,6 +29,7 @@
29
29
  import { useMediaLibraryContext } from '../../mediaLibrary/context';
30
30
  import { MediaLibraryError, isCancellation } from '../../mediaLibrary/errors';
31
31
  import { useI18n } from '../../i18n/context';
32
+ import { dirForUserText, useTextDirection } from '@widgetic/design-system/components/textDirection';
32
33
  import { messageForVisitor } from '../../i18n/errors';
33
34
  import { formatKilobytes } from '../../utils/fileUtils';
34
35
  import { kindWord, splitAround } from '../../i18n/text';
@@ -40,6 +41,9 @@ import { translateEnglish } from '../../i18n/context';
40
41
  const { library } = useMediaLibraryContext();
41
42
  // The language of the File Browser this uploader is part of.
42
43
  const { t, locale } = useI18n();
44
+ // The reading direction of the screen: a name a visitor wrote keeps a direction of its own on a right to left screen.
45
+ const textDirection = useTextDirection();
46
+ $: nameDirection = dirForUserText($textDirection);
43
47
 
44
48
  // Component props variables
45
49
  export let allowedTypes: string[] = [];
@@ -857,7 +861,7 @@ import { translateEnglish } from '../../i18n/context';
857
861
  bind:this={uploaderRootEl}
858
862
  >
859
863
  <!-- Add help icon with tooltip -->
860
- <div class="help-icon-container absolute {isSmallScreen ? 'top-2 right-2' : 'top-4 right-4'} z-10">
864
+ <div class="help-icon-container absolute {isSmallScreen ? 'top-2 end-2' : 'top-4 end-4'} z-10">
861
865
  <Tooltip.Provider>
862
866
  <Tooltip.Root open={showHelp}>
863
867
  <Tooltip.Trigger class="focus:outline-none focus-visible:outline-none inline-block">
@@ -871,10 +875,10 @@ import { translateEnglish } from '../../i18n/context';
871
875
  </div>
872
876
  </Tooltip.Trigger>
873
877
  <Tooltip.Content
874
- side="left"
878
+ side={/* rtl-ok: the tooltip is put where the pointer is, by the style below */ 'left'}
875
879
  sideOffset={5}
876
880
  class="bg-[hsl(var(--dark))] text-white z-[99999] overflow-hidden rounded-md px-3 py-1.5 shadow-md max-w-[250px] whitespace-normal break-words"
877
- style="position: fixed; left: {mouseX - 20}px; top: {mouseY}px;"
881
+ style="position: fixed; left: {mouseX - 20}px; top: {mouseY}px; /* rtl-ok: put where the pointer is, measured from the left edge of the page */"
878
882
  >
879
883
  <p class="caption text-white whitespace-pre-line">{tooltipTypesText}</p>
880
884
  </Tooltip.Content>
@@ -963,7 +967,7 @@ import { translateEnglish } from '../../i18n/context';
963
967
 
964
968
  <!-- Uploads Drawer -->
965
969
  <div
966
- class="uploads-drawer absolute bottom-0 left-0 right-0 bg-white transition-all duration-300 z-[9990] flex flex-col rounded-t-large widgetic-radius modal-shadow"
970
+ class="uploads-drawer absolute bottom-0 inset-x-0 bg-white transition-all duration-300 z-[9990] flex flex-col rounded-t-large widgetic-radius modal-shadow"
967
971
  style="max-height: 80vh; transform: translateY({isUploadsDrawerCollapsed ? 'calc(100% - 70px)' : '0'}); border: 1px solid hsl(var(--forest-green)); border-bottom: none;"
968
972
  >
969
973
  <!-- Header with toggle -->
@@ -973,7 +977,7 @@ import { translateEnglish } from '../../i18n/context';
973
977
  <p class="subtext text-[hsl(var(--grey5))]">
974
978
  {$t('upload.progress', { done: uploadItems.filter(item => item.status === 'complete').length, total: uploadItems.length })}
975
979
  {#if uploadItems.filter(item => item.status === 'failed').length > 0}
976
- <span class="ml-2 caption text-[hsl(var(--error))]">
980
+ <span class="ms-2 caption text-[hsl(var(--error))]">
977
981
  {$t('upload.failedCount', { count: uploadItems.filter(item => item.status === 'failed').length })}
978
982
  </span>
979
983
  {/if}
@@ -1002,10 +1006,10 @@ import { translateEnglish } from '../../i18n/context';
1002
1006
  </button>
1003
1007
  </Tooltip.Trigger>
1004
1008
  <Tooltip.Content
1005
- side="left"
1009
+ side={/* rtl-ok: the tooltip is put where the pointer is, by the style below */ 'left'}
1006
1010
  sideOffset={5}
1007
1011
  class="bg-[hsl(var(--dark))] text-white z-[99999] overflow-hidden rounded-md px-3 py-1.5 shadow-md"
1008
- style="position: fixed; left: {mouseX - 20}px; top: {mouseY}px;"
1012
+ style="position: fixed; left: {mouseX - 20}px; top: {mouseY}px; /* rtl-ok: put where the pointer is, measured from the left edge of the page */"
1009
1013
  >
1010
1014
  <p class="caption text-white">{isUploadsDrawerCollapsed ? $t('upload.expandUploader') : $t('upload.collapseUploader')}</p>
1011
1015
  </Tooltip.Content>
@@ -1028,10 +1032,10 @@ import { translateEnglish } from '../../i18n/context';
1028
1032
  </button>
1029
1033
  </Tooltip.Trigger>
1030
1034
  <Tooltip.Content
1031
- side="left"
1035
+ side={/* rtl-ok: the tooltip is put where the pointer is, by the style below */ 'left'}
1032
1036
  sideOffset={5}
1033
1037
  class="bg-[hsl(var(--dark))] text-white z-[99999] overflow-hidden rounded-md px-3 py-1.5 shadow-md"
1034
- style="position: fixed; left: {mouseX - 20}px; top: {mouseY}px;"
1038
+ style="position: fixed; left: {mouseX - 20}px; top: {mouseY}px; /* rtl-ok: put where the pointer is, measured from the left edge of the page */"
1035
1039
  >
1036
1040
  <p class="caption text-white">{$t('upload.closeUploader')}</p>
1037
1041
  </Tooltip.Content>
@@ -1070,7 +1074,7 @@ import { translateEnglish } from '../../i18n/context';
1070
1074
  </div>
1071
1075
  {/if}
1072
1076
  <div class="flex flex-col">
1073
- <span class="body-medium truncate {item.status === 'failed' ? 'text-[hsl(var(--error))]' : 'text-[hsl(var(--grey7))]'}">{item.file.name}</span>
1077
+ <span dir={nameDirection} class="body-medium truncate {item.status === 'failed' ? 'text-[hsl(var(--error))]' : 'text-[hsl(var(--grey7))]'}">{item.file.name}</span>
1074
1078
  <span class="subtext truncate text-[hsl(var(--grey5))]">{formatKilobytes(item.file.size, $t, $locale)}</span>
1075
1079
  </div>
1076
1080
  </div>
@@ -1207,8 +1211,8 @@ import { translateEnglish } from '../../i18n/context';
1207
1211
  box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.1);
1208
1212
  display: flex;
1209
1213
  flex-direction: column;
1210
- border-top-left-radius: var(--radius-large);
1211
- border-top-right-radius: var(--radius-large);
1214
+ border-start-start-radius: var(--radius-large);
1215
+ border-start-end-radius: var(--radius-large);
1212
1216
  }
1213
1217
 
1214
1218
  /* Fix footer position */
@@ -122,7 +122,7 @@
122
122
  />
123
123
  {#if selectedFilesCount > 0}
124
124
  <div
125
- class="absolute top-[-8px] left-[-8px] h-5 rounded-full bg-[hsl(var(--deep-forest-green))] flex items-center justify-center z-10"
125
+ class="absolute top-[-8px] start-[-8px] h-5 rounded-full bg-[hsl(var(--deep-forest-green))] flex items-center justify-center z-10"
126
126
  style="min-width: 20px; padding: 0 4px;"
127
127
  >
128
128
  <span class="h6 text-white leading-none mx-[1px]">{selectedFilesCount}</span>
@@ -11,6 +11,7 @@
11
11
  import { toCssUrlLiteral, toSafeFontFamilyName } from '../../utils/safeText';
12
12
  import { formatRelativeDate } from '../../utils/dateUtils';
13
13
  import { useI18n, type Translate } from '../../i18n';
14
+ import { dirForUserText, useTextDirection } from '@widgetic/design-system/components/textDirection';
14
15
  import { DropdownMenu, FileIcon } from '../ui';
15
16
  import { type FileFilterType } from '../../utils/fileTypes';
16
17
  // import ThumbHashImage from '../previews/ThumbHashImage.svelte';
@@ -32,6 +33,9 @@
32
33
  export let columnWidth: number = 40; // Default value if not provided
33
34
 
34
35
  const { t } = useI18n();
36
+ // The reading direction of the screen: a name a visitor wrote keeps a direction of its own on a right to left screen.
37
+ const textDirection = useTextDirection();
38
+ $: nameDirection = dirForUserText($textDirection);
35
39
 
36
40
  /* STATE VARS */
37
41
  // Responsive breakpoints from global.css
@@ -630,7 +634,7 @@
630
634
  <div class="flex items-start justify-between mb-1">
631
635
  <div class="flex-1 min-w-0">
632
636
  <!-- File Name -->
633
- <h3 class="body-medium text-[hsl({file.isMissing ? 'var(--error)' : 'var(--grey7)'})] truncate">
637
+ <h3 dir={nameDirection} class="body-medium text-[hsl({file.isMissing ? 'var(--error)' : 'var(--grey7)'})] truncate">
634
638
  {file.name}
635
639
  </h3>
636
640
 
@@ -642,11 +646,11 @@
642
646
 
643
647
  <!-- Selection Check Icon -->
644
648
  {#if isSelected(file) && allowSelecting}
645
- <div class="ml-2 mt-1 flex-shrink-0">
649
+ <div class="ms-2 mt-1 flex-shrink-0">
646
650
  <img src={getAssetUrl('/icons/checked.svg')} alt={$t('action.selected')} class="w-5 h-5" />
647
651
  </div>
648
652
  {:else if !file.isMissing && allowSelecting}
649
- <div class="ml-2 mt-1 opacity-0 group-hover:opacity-20 transition-all duration-200 flex-shrink-0">
653
+ <div class="ms-2 mt-1 opacity-0 group-hover:opacity-20 transition-all duration-200 flex-shrink-0">
650
654
  <img src={getAssetUrl('/icons/checked.svg')} alt={$t('action.select')} class="w-5 h-5" />
651
655
  </div>
652
656
  {/if}
@@ -2,8 +2,12 @@
2
2
  // Design system imports
3
3
  import { IconTrash, IconRefresh } from '@widgetic/design-system/icons';
4
4
  import { useI18n } from '../../i18n';
5
+ import { dirForUserText, useTextDirection } from '@widgetic/design-system/components/textDirection';
5
6
 
6
7
  const { t } = useI18n();
8
+ // The reading direction of the screen: a name a visitor wrote keeps a direction of its own on a right to left screen.
9
+ const textDirection = useTextDirection();
10
+ $: nameDirection = dirForUserText($textDirection);
7
11
 
8
12
  // Component props
9
13
  export let file: File;
@@ -63,8 +67,8 @@
63
67
  <!-- File info and progress -->
64
68
  <div class="flex-grow min-w-0">
65
69
  <div class="flex justify-between items-start">
66
- <div class="truncate pr-2">
67
- <p class="font-medium truncate">{file.name}</p>
70
+ <div class="truncate pe-2">
71
+ <p dir={nameDirection} class="font-medium truncate">{file.name}</p>
68
72
  <div class="flex items-center text-sm text-[hsl(var(--grey3))]">
69
73
  {#if status === 'uploading'}
70
74
  <span>{fileSize}</span>
@@ -23,6 +23,7 @@
23
23
  import type { FileSystemItem } from '../../types';
24
24
  import { getFileIcon, getItemFileType, formatFileSize } from '../../utils/fileUtils';
25
25
  import { useI18n } from '../../i18n';
26
+ import { dirForUserText, useTextDirection } from '@widgetic/design-system/components/textDirection';
26
27
  import { isKnownNonImageFile } from '../../utils/fileKinds';
27
28
  import { toCssUrlLiteral, toSafeFontFamilyName } from '../../utils/safeText';
28
29
  import { addMissingFile, removeMissingFile } from '../../stores/missingFilesStore';
@@ -51,6 +52,9 @@
51
52
 
52
53
  const dispatch = createEventDispatcher();
53
54
  const { t, locale } = useI18n();
55
+ // The reading direction of the screen: a name a visitor wrote keeps a direction of its own on a right to left screen.
56
+ const textDirection = useTextDirection();
57
+ $: nameDirection = dirForUserText($textDirection);
54
58
 
55
59
 
56
60
  // Reactive declarations for file type handling
@@ -597,8 +601,8 @@
597
601
  <!-- Content Column -->
598
602
  {#if !thumbnailOnly}
599
603
  <div class="fb-file-content-ct flex flex-col justify-center min-w-0 relative w-full" class:items-center={gridLayout} class:text-center={gridLayout}>
600
- <div class="widgetic-colors pointer-events-none w-full" class:pr-10={!gridLayout} class:px-1={gridLayout}>
601
- <h3 class="fb-file-title body-medium text-sm leading-snug line-clamp-2 break-words cursor-default" class:text-center={gridLayout} class:text-[hsl(var(--error))]={isMissing} class:text-[hsl(var(--grey7))]={!isMissing}>
604
+ <div class="widgetic-colors pointer-events-none w-full" class:pe-10={!gridLayout} class:px-1={gridLayout}>
605
+ <h3 dir={nameDirection} class="fb-file-title body-medium text-sm leading-snug line-clamp-2 break-words cursor-default" class:text-center={gridLayout} class:text-[hsl(var(--error))]={isMissing} class:text-[hsl(var(--grey7))]={!isMissing}>
602
606
  {item.name}
603
607
  </h3>
604
608
  <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}>
@@ -608,17 +612,17 @@
608
612
 
609
613
  <!-- Checkbox/Actions -->
610
614
  {#if !isMissing && allowSelecting && !selected}
611
- <div class="absolute top-[17px] right-4 z-10 opacity-0 group-hover:opacity-20 transition-all duration-200">
615
+ <div class="absolute top-[17px] end-4 z-10 opacity-0 group-hover:opacity-20 transition-all duration-200">
612
616
  <img src={getAssetUrl('/icons/checked.svg')} alt={$t('action.select')} class="w-5 h-5" />
613
617
  </div>
614
618
  {/if}
615
619
  {#if selected}
616
- <div class="absolute top-[17px] right-4 z-10 opacity-100">
620
+ <div class="absolute top-[17px] end-4 z-10 opacity-100">
617
621
  <img src={getAssetUrl('/icons/checked.svg')} alt={$t('action.selected')} class="w-5 h-5" />
618
622
  </div>
619
623
  {/if}
620
624
  {#if isMissing}
621
- <div class="absolute top-[17px] right-4 z-10">
625
+ <div class="absolute top-[17px] end-4 z-10">
622
626
  <button
623
627
  class="w-5 h-5 text-[hsl(var(--error))] opacity-0 group-hover:opacity-100 transition-opacity duration-200"
624
628
  class:!opacity-100={effectiveIsMobile}
@@ -6,6 +6,7 @@
6
6
  import { DropdownMenu } from '../ui';
7
7
  import { isMobileStore } from '../../stores/viewportStore';
8
8
  import { useI18n } from '../../i18n';
9
+ import { dirForUserText, useTextDirection } from '@widgetic/design-system/components/textDirection';
9
10
 
10
11
  export let item: FolderItemWithCount;
11
12
  export let currentFilter: FileFilterType = 'all';
@@ -14,6 +15,9 @@
14
15
 
15
16
  const dispatch = createEventDispatcher();
16
17
  const { t } = useI18n();
18
+ // The reading direction of the screen: a name a visitor wrote keeps a direction of its own on a right to left screen.
19
+ const textDirection = useTextDirection();
20
+ $: nameDirection = dirForUserText($textDirection);
17
21
 
18
22
  $: effectiveIsMobile = isMobile !== undefined ? isMobile : $isMobileStore;
19
23
 
@@ -55,15 +59,15 @@
55
59
  </button>
56
60
 
57
61
  <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}>
58
- <div class="w-full" class:pr-10={!gridLayout} class:px-1={gridLayout}>
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>
62
+ <div class="w-full" class:pe-10={!gridLayout} class:px-1={gridLayout}>
63
+ <h3 dir={nameDirection} 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>
60
64
  <p class="subtext text-[hsl(var(--grey5))] cursor-default mt-0.5" class:truncate={!gridLayout} class:text-center={gridLayout}>
61
65
  {isEmpty ? $t('folder.empty') : $t('folder.itemCount', { count: item.matchingFileCount })}
62
66
  </p>
63
67
  </div>
64
68
 
65
69
  <div
66
- class="fb-folder-menu-ct opacity-0 group-hover:opacity-100 transition-opacity duration-200 w-5 h-5 {effectiveIsMobile ? '!opacity-100' : ''} {gridLayout ? 'mt-0.5' : 'absolute right-4 top-1/2 -translate-y-1/2'}"
70
+ class="fb-folder-menu-ct opacity-0 group-hover:opacity-100 transition-opacity duration-200 w-5 h-5 {effectiveIsMobile ? '!opacity-100' : ''} {gridLayout ? 'mt-0.5' : 'absolute end-4 top-1/2 -translate-y-1/2'}"
67
71
  >
68
72
  <DropdownMenu isFolder={true} on:action={handleDropdownAction} />
69
73
  </div>