Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
🪞 fix: Mirror Shared Primitives for Right-to-Left Layouts (#17265)
Marco Berettaf2be28de6a5a
diff --git a/client/package.json b/client/package.jsonindex a07bb8cded..f4faa06668 100644--- a/client/package.json+++ b/client/package.json@@ -165,6 +165,7 @@"jest-environment-jsdom": "^30.2.0","jest-file-loader": "^1.0.3","jest-junit": "^17.0.0",+ "lightningcss": "^1.33.0","micromark-util-types": "^2.0.0","postcss": "^8.5.18","tailwindcss": "^4.3.3",diff --git a/client/vite.config.ts b/client/vite.config.tsindex d9858ea3cb..76e8a6e3fb 100644--- a/client/vite.config.ts+++ b/client/vite.config.ts@@ -3,6 +3,7 @@ import fs from 'fs';import path from 'path';import { constants } from 'zlib';import { defineConfig } from 'vite';+import { Features } from 'lightningcss';import { THEME_BOOT_FILE } from 'librechat-data-provider';import { createRequire } from 'module';import { VitePWA } from 'vite-plugin-pwa';@@ -216,6 +217,12 @@ export default defineConfig(({ command }) => ({],},publicDir: command === 'serve' ? './public' : false,+ css: {+ /** The CSS minifier lowers `:dir()` for `build.cssTarget` browsers into a `:lang()` list,+ * which mirrors by UI language instead of the element's direction and breaks LTR islands+ * in an RTL page. Tailwind keeps `:dir()` for the same reason; the minifier has to agree. */+ lightningcss: { exclude: Features.DirSelector },+ },build: {sourcemap: buildSourceMap,outDir: './dist',diff --git a/e2e/specs/mock/scenarios/input-number-reset.spec.ts b/e2e/specs/mock/scenarios/input-number-reset.spec.tsindex defb8e0de8..5d456e36b8 100644--- a/e2e/specs/mock/scenarios/input-number-reset.spec.ts+++ b/e2e/specs/mock/scenarios/input-number-reset.spec.ts@@ -44,7 +44,8 @@ const EXPECTED: Reset = {width: '120px',borderStyle: 'none',background: 'rgba(0, 0, 0, 0)',- textAlign: 'right',+ /** The trailing edge: the right in an LTR page, the left in RTL. */+ textAlign: 'end',};test.describe('InputNumber option reset', () => {diff --git a/e2e/specs/mock/scenarios/rtl-floating-label.spec.ts b/e2e/specs/mock/scenarios/rtl-floating-label.spec.tsnew file mode 100644index 0000000000..674dfbd4fc--- /dev/null+++ b/e2e/specs/mock/scenarios/rtl-floating-label.spec.ts@@ -0,0 +1,52 @@+import { expect, test } from '@playwright/test';+import type { Page } from '@playwright/test';++/**+ * The sign-in field's label shrinks into the field's top edge on focus. It scales from its+ * inline-start corner, so in RTL it shrinks toward the right edge it starts from and stays inside+ * the field instead of being pushed past it.+ */+test.use({ storageState: { cookies: [], origins: [] } });++async function focusedLabel(page: Page, dir: 'ltr' | 'rtl') {+ await page.goto('/login');+ await expect(page.getByTestId('login-button')).toBeVisible({ timeout: 20000 });+ await page.evaluate((value) => {+ document.documentElement.dir = value;+ }, dir);+ const input = page.locator('input#email');+ await input.focus();+ const label = page.locator('label[for="email"]');+ /** Reads once the scale transition settles. */+ let previous = '';+ await expect+ .poll(async () => {+ const next = JSON.stringify(+ await label.evaluate((node) => {+ const field = (document.getElementById('email') as HTMLElement).getBoundingClientRect();+ const box = node.getBoundingClientRect();+ return {+ fromLeft: Math.round(box.left - field.left),+ fromRight: Math.round(field.right - box.right),+ };+ }),+ );+ const settled = next === previous;+ previous = next;+ return settled;+ })+ .toBe(true);+ return JSON.parse(previous) as { fromLeft: number; fromRight: number };+}++test('a focused sign-in label stays inside its field on the reading edge in RTL and LTR @scenario:rtl-floating-label-stays-in-field', async ({+ page,+}) => {+ const rtl = await focusedLabel(page, 'rtl');+ expect(rtl.fromRight).toBeGreaterThanOrEqual(0);+ expect(rtl.fromLeft).toBeGreaterThan(rtl.fromRight);++ const ltr = await focusedLabel(page, 'ltr');+ expect(ltr.fromLeft).toBeGreaterThanOrEqual(0);+ expect(ltr.fromRight).toBeGreaterThan(ltr.fromLeft);+});diff --git a/e2e/specs/mock/scenarios/rtl-primitives.spec.ts b/e2e/specs/mock/scenarios/rtl-primitives.spec.tsnew file mode 100644index 0000000000..8863854d8c--- /dev/null+++ b/e2e/specs/mock/scenarios/rtl-primitives.spec.ts@@ -0,0 +1,220 @@+import { expect, test } from '@playwright/test';+import type { Locator, Page } from '@playwright/test';+import { NEW_CHAT_PATH } from '../helpers';++/**+ * The shared primitives place their parts on logical sides, so the same markup lays out mirrored+ * under `dir="rtl"`. The document direction is set by hand after load: the language that flips it+ * belongs to the i18n layer, and what these scenarios hold is how the primitives follow it.+ */+test.describe.configure({ timeout: 120_000 });+test.use({ viewport: { width: 1280, height: 800 } });++type Direction = 'ltr' | 'rtl';++/** Pins the document direction the way an RTL language would. The app's language sync stamps+ * `dir` from the UI language whenever it runs (at boot, and again as settings mount), so the+ * pin re-applies the value after any such write. */+async function setDirection(page: Page, dir: Direction) {+ await page.evaluate((value) => {+ const root = document.documentElement;+ const state = window as unknown as { __e2eDirPin?: MutationObserver };+ state.__e2eDirPin?.disconnect();+ root.dir = value;+ const pin = new MutationObserver(() => {+ if (root.dir !== value) {+ root.dir = value;+ }+ });+ pin.observe(root, { attributes: true, attributeFilter: ['dir'] });+ state.__e2eDirPin = pin;+ }, dir);+ await expect(page.locator('html')).toHaveAttribute('dir', dir);+}++async function openGeneralSettings(page: Page, dir: Direction): Promise<Locator> {+ await page.goto(NEW_CHAT_PATH, { timeout: 15000 });+ await page.getByTestId('nav-user').click();+ await page.getByRole('menuitem', { name: 'Settings' }).click();+ const dialog = page.getByRole('dialog', { name: 'Settings' });+ await expect(dialog.getByRole('heading', { name: 'Settings', exact: true })).toBeVisible({+ timeout: 15000,+ });+ await dialog.getByRole('tab', { name: 'General' }).click();+ await setDirection(page, dir);+ return dialog;+}++/** Where the thumb sits inside its track once its transition settles, in track pixels. */+async function thumbOffsets(control: Locator) {+ let previous = '';+ await expect+ .poll(async () => {+ const next = JSON.stringify(await readThumb(control));+ const settled = next === previous;+ previous = next;+ return settled;+ })+ .toBe(true);+ return JSON.parse(previous) as Awaited<ReturnType<typeof readThumb>>;+}++function readThumb(control: Locator) {+ return control.evaluate((node: HTMLElement) => {+ const track = node.getBoundingClientRect();+ const thumb = (node.firstElementChild as HTMLElement).getBoundingClientRect();+ return {+ state: node.getAttribute('data-state'),+ fromLeft: Math.round(thumb.left - track.left),+ fromRight: Math.round(track.right - thumb.right),+ };+ });+}++/** Toggles the switch, reads both states, and leaves it as it was. */+async function bothStates(control: Locator) {+ const first = await thumbOffsets(control);+ await control.click();+ const second = await thumbOffsets(control);+ await control.click();+ await expect(control).toHaveAttribute('data-state', first.state ?? '');+ const checked = first.state === 'checked' ? first : second;+ const unchecked = first.state === 'checked' ? second : first;+ return { checked, unchecked };+}++async function openArchivedChats(page: Page, dir: Direction): Promise<Locator> {+ await page.goto(NEW_CHAT_PATH, { timeout: 15000 });+ await page.getByTestId('nav-user').click();+ await page.getByRole('menuitem', { name: 'Archived chats' }).click();+ const dialog = page.getByRole('dialog', { name: 'Archived chats' });+ await expect(dialog.getByRole('heading', { name: 'Archived chats' })).toBeVisible({+ timeout: 15000,+ });+ await setDirection(page, dir);+ return dialog;+}++async function archivedLayout(dialog: Locator) {+ return dialog.evaluate((node: HTMLElement) => {+ const box = node.getBoundingClientRect();+ const close = Array.from(node.querySelectorAll('button')).find(+ (button) => button.textContent?.trim() === 'Close',+ ) as HTMLElement;+ const closeBox = close.getBoundingClientRect();+ const heading = node.querySelector('h2') as HTMLElement;+ const range = document.createRange();+ range.selectNodeContents(heading);+ const text = range.getBoundingClientRect();+ return {+ closeCenter: (closeBox.left + closeBox.right) / 2 - box.left,+ dialogWidth: box.width,+ textOverlapsClose: text.right > closeBox.left && text.left < closeBox.right,+ };+ });+}++/** Hovers the sidebar's new-chat button, whose tooltip asks for the physical `right` side. */+async function newChatTooltip(page: Page) {+ const anchor = page.getByTestId('new-chat-button');+ await page.mouse.move(0, 0);+ await expect(page.locator('.tooltip')).toBeHidden();+ await anchor.hover();+ const tooltip = page.locator('.tooltip');+ await expect(tooltip).toBeVisible({ timeout: 10000 });+ /** Read once the popover has settled where it opens. */+ let previous = '';+ await expect+ .poll(async () => {+ const [a, t] = await Promise.all([anchor.boundingBox(), tooltip.boundingBox()]);+ const next = JSON.stringify({+ anchorLeft: Math.round(a?.x ?? 0),+ anchorRight: Math.round((a?.x ?? 0) + (a?.width ?? 0)),+ tooltipLeft: Math.round(t?.x ?? 0),+ tooltipRight: Math.round((t?.x ?? 0) + (t?.width ?? 0)),+ });+ const settled = next === previous;+ previous = next;+ return settled;+ })+ .toBe(true);+ return JSON.parse(previous) as {+ anchorLeft: number;+ anchorRight: number;+ tooltipLeft: number;+ tooltipRight: number;+ };+}++test.describe('RTL shared primitives', () => {+ test('a switch thumb travels toward the inline end and stays inside its track in RTL @scenario:rtl-switch-thumb-stays-in-track', async ({+ page,+ }) => {+ const dialog = await openGeneralSettings(page, 'rtl');+ const control = dialog.getByRole('switch').first();+ await expect(control).toBeVisible();+ /** Radix Tabs stamps its resolved direction on the settings panel, which stays `ltr` until the+ * app mounts a direction provider, so the switch's own container carries the RTL direction. */+ await control.evaluate((node) => node.parentElement?.setAttribute('dir', 'rtl'));++ const { checked, unchecked } = await bothStates(control);+ /** Unchecked rests on the inline start (the right in RTL), checked on the inline end. */+ expect(unchecked.fromRight).toBeLessThanOrEqual(unchecked.fromLeft);+ expect(checked.fromLeft).toBeLessThan(checked.fromRight);+ for (const reading of [checked, unchecked]) {+ expect(reading.fromLeft).toBeGreaterThanOrEqual(0);+ expect(reading.fromRight).toBeGreaterThanOrEqual(0);+ }++ /** An LTR island inside the RTL page keeps the LTR travel. */+ await control.evaluate((node) => node.parentElement?.setAttribute('dir', 'ltr'));+ const island = await bothStates(control);+ expect(island.checked.fromRight).toBeLessThan(island.checked.fromLeft);+ expect(island.checked.fromRight).toBeGreaterThanOrEqual(0);+ });++ test('a dialog puts its close button on the inline end, clear of its title, in RTL @scenario:rtl-dialog-close-button-mirrors', async ({+ page,+ }) => {+ const dialog = await openArchivedChats(page, 'rtl');+ const layout = await archivedLayout(dialog);++ expect(layout.closeCenter).toBeLessThan(layout.dialogWidth / 2);+ expect(layout.textOverlapsClose).toBe(false);+ });++ test('an LTR page keeps the switch thumb and dialog close button on their physical sides @scenario:ltr-primitives-keep-physical-sides', async ({+ page,+ }) => {+ const settings = await openGeneralSettings(page, 'ltr');+ const control = settings.getByRole('switch').first();+ await expect(control).toBeVisible();+ const { checked, unchecked } = await bothStates(control);+ expect(unchecked.fromLeft).toBeLessThanOrEqual(unchecked.fromRight);+ expect(checked.fromRight).toBeLessThan(checked.fromLeft);+ for (const reading of [checked, unchecked]) {+ expect(reading.fromLeft).toBeGreaterThanOrEqual(0);+ expect(reading.fromRight).toBeGreaterThanOrEqual(0);+ }++ const dialog = await openArchivedChats(page, 'ltr');+ const layout = await archivedLayout(dialog);+ expect(layout.closeCenter).toBeGreaterThan(layout.dialogWidth / 2);+ expect(layout.textOverlapsClose).toBe(false);+ });++ test('a side tooltip follows the writing direction when it flips without a reload @scenario:rtl-side-tooltip-follows-direction-switch', async ({+ page,+ }) => {+ await page.goto(NEW_CHAT_PATH, { timeout: 15000 });+ await expect(page.getByTestId('new-chat-button')).toBeVisible({ timeout: 15000 });+ await setDirection(page, 'ltr');+ const ltr = await newChatTooltip(page);+ expect(ltr.tooltipLeft).toBeGreaterThanOrEqual(ltr.anchorRight);++ /** The same mounted anchor, after the document turns RTL the way a language switch does. */+ await setDirection(page, 'rtl');+ const rtl = await newChatTooltip(page);+ expect(rtl.tooltipRight).toBeLessThanOrEqual(rtl.anchorLeft);+ });+});diff --git a/package-lock.json b/package-lock.jsonindex c2ffa9352a..94cdd55455 100644--- a/package-lock.json+++ b/package-lock.json@@ -994,6 +994,7 @@"jest-environment-jsdom": "^30.2.0","jest-file-loader": "^1.0.3","jest-junit": "^17.0.0",+ "lightningcss": "^1.33.0","micromark-util-types": "^2.0.0","postcss": "^8.5.18","tailwindcss": "^4.3.3",diff --git a/packages/client/src/components/AlertDialog.tsx b/packages/client/src/components/AlertDialog.tsxindex ab45a502ef..7834202687 100644--- a/packages/client/src/components/AlertDialog.tsx+++ b/packages/client/src/components/AlertDialog.tsx@@ -83,7 +83,7 @@ const AlertDialogHeader: {({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): JSX.Element;displayName: string;} = ({ className = '', ...props }: React.HTMLAttributes<HTMLDivElement>): JSX.Element => (- <div className={cn('flex flex-col space-y-2 text-center sm:text-left', className)} {...props} />+ <div className={cn('flex flex-col space-y-2 text-center sm:text-start', className)} {...props} />);AlertDialogHeader.displayName = 'AlertDialogHeader';diff --git a/packages/client/src/components/AnimatePopover.css b/packages/client/src/components/AnimatePopover.cssindex 809e895bd1..6fa46d7390 100644--- a/packages/client/src/components/AnimatePopover.css+++ b/packages/client/src/components/AnimatePopover.css@@ -47,3 +47,47 @@transform: none;}}++.animate-popover-left:dir(rtl) {+ transform-origin: right;+ transform: scale(0.95) translateX(0.5rem);+}++.animate-popover-left:dir(rtl)[data-enter] {+ transform: scale(1) translateX(0);+}++.animate-popover-bottom:dir(rtl) {+ transform-origin: bottom right;+}++@media (prefers-reduced-motion: reduce) {+ .animate-popover-bottom:dir(rtl) {+ transform: none;+ }+}++/* Chrome and Edge before 120 drop the `:dir()` rules; they read the nearest direction from the+ * `--dir-fallback` property tokens.css sets on every `dir` attribute. */+@supports not selector(:dir(rtl)) {+ @container style(--dir-fallback: rtl) {+ .animate-popover-left:not([dir='ltr']) {+ transform-origin: right;+ transform: scale(0.95) translateX(0.5rem);+ }++ .animate-popover-left:not([dir='ltr'])[data-enter] {+ transform: scale(1) translateX(0);+ }++ .animate-popover-bottom:not([dir='ltr']) {+ transform-origin: bottom right;+ }++ @media (prefers-reduced-motion: reduce) {+ .animate-popover-bottom:not([dir='ltr']) {+ transform: none;+ }+ }+ }+}diff --git a/packages/client/src/components/AnimatedSearchInput.tsx b/packages/client/src/components/AnimatedSearchInput.tsxindex 158c4a7058..e7e44b25e1 100644--- a/packages/client/src/components/AnimatedSearchInput.tsx+++ b/packages/client/src/components/AnimatedSearchInput.tsx@@ -24,7 +24,7 @@ const AnimatedSearchInput = ({<div className="relative rounded-lg transition-all duration-500 ease-in-out"><div className="relative">{/* Icon on the left */}- <div className="absolute top-1/2 left-3 z-50 -translate-y-1/2">+ <div className="absolute inset-s-3 top-1/2 z-50 -translate-y-1/2"><SearchclassName={cn(`h-4 w-4 transition-all duration-500 ease-in-out`,@@ -40,7 +40,7 @@ const AnimatedSearchInput = ({onChange={onChange}placeholder={placeholder}aria-label={localize('com_ui_search')}- className={`peer bg-surface-secondary placeholder:text-text-secondary focus:ring-focus-control relative z-20 w-full rounded-lg py-2 pl-10 outline-hidden backdrop-blur-xs transition-all duration-500 ease-in-out`}+ className={`peer bg-surface-secondary placeholder:text-text-secondary focus:ring-focus-control relative z-20 w-full rounded-lg py-2 ps-10 outline-hidden backdrop-blur-xs transition-all duration-500 ease-in-out`}/>{/* Gradient overlay */}@@ -50,7 +50,7 @@ const AnimatedSearchInput = ({{/* Animated loading indicator */}<div- className={`absolute top-1/2 right-3 z-20 -translate-y-1/2 transition-all duration-500 ease-in-out ${isSearching && hasValue ? 'scale-100 opacity-100' : 'scale-0 opacity-0'} `}+ className={`absolute inset-e-3 top-1/2 z-20 -translate-y-1/2 transition-all duration-500 ease-in-out ${isSearching && hasValue ? 'scale-100 opacity-100' : 'scale-0 opacity-0'} `}><div className="relative h-2 w-2"><div className="bg-accent-primary/60 absolute inset-0 animate-ping rounded-full" />diff --git a/packages/client/src/components/AnimatedTabs.css b/packages/client/src/components/AnimatedTabs.cssindex 4f16a965ca..375879fe68 100644--- a/packages/client/src/components/AnimatedTabs.css+++ b/packages/client/src/components/AnimatedTabs.css@@ -55,3 +55,28 @@.animated-panels [data-open] ~ .animated-tab-panel {translate: 100%;}++.animated-panels:dir(rtl):has(> [data-was-open]) > .animated-tab-panel {+ translate: 100%;+}++.animated-panels:dir(rtl) [data-was-open] ~ .animated-tab-panel,+.animated-panels:dir(rtl) [data-open] ~ .animated-tab-panel {+ translate: -100%;+}++/* Chrome and Edge before 120 drop the `:dir()` rules; they read the nearest direction from the+ * `--dir-fallback` property tokens.css sets on every `dir` attribute. A panel's container is+ * `.animated-panels`, so the query reads the panels' direction. */+@supports not selector(:dir(rtl)) {+ @container style(--dir-fallback: rtl) {+ .animated-panels:has(> [data-was-open]) > .animated-tab-panel:not([dir='ltr']) {+ translate: 100%;+ }++ .animated-panels [data-was-open] ~ .animated-tab-panel:not([dir='ltr']),+ .animated-panels [data-open] ~ .animated-tab-panel:not([dir='ltr']) {+ translate: -100%;+ }+ }+}diff --git a/packages/client/src/components/Badge.tsx b/packages/client/src/components/Badge.tsxindex 627235d33c..e25155ba7f 100644--- a/packages/client/src/components/Badge.tsx+++ b/packages/client/src/components/Badge.tsx@@ -94,7 +94,7 @@ export default function Badge({{isEditing && !isDragging && (<motion.buttontype="button"- className="bg-surface-secondary-alt text-text-primary absolute -top-1 -right-1 flex h-6 w-6 items-center justify-center rounded-full shadow-xs"+ className="bg-surface-secondary-alt text-text-primary absolute -inset-e-1 -top-1 flex h-6 w-6 items-center justify-center rounded-full shadow-xs"aria-label={isAvailable ? `Remove ${label}` : `Restore ${label}`}initial={{ opacity: 0, scale: 0.8 }}animate={{ opacity: 1, scale: 1 }}diff --git a/packages/client/src/components/Breadcrumb.tsx b/packages/client/src/components/Breadcrumb.tsxindex 0629254313..6405686024 100644--- a/packages/client/src/components/Breadcrumb.tsx+++ b/packages/client/src/components/Breadcrumb.tsx@@ -24,7 +24,7 @@ const BreadcrumbList: React.ForwardRefExoticComponent<<olref={ref}className={cn(- 'flex flex-wrap items-center gap-1.5 break-words text-sm text-text-secondary sm:gap-2.5',+ 'text-text-secondary flex flex-wrap items-center gap-1.5 text-sm break-words sm:gap-2.5',className,)}{...props}@@ -61,7 +61,7 @@ const BreadcrumbLink: React.ForwardRefExoticComponent<return (<Compref={ref}- className={cn('transition-colors hover:text-text-primary', className)}+ className={cn('hover:text-text-primary transition-colors', className)}{...props}/>);@@ -78,7 +78,7 @@ const BreadcrumbPage: React.ForwardRefExoticComponent<role="link"aria-disabled="true"aria-current="page"- className={cn('font-normal text-text-primary', className)}+ className={cn('text-text-primary font-normal', className)}{...props}/>),@@ -95,7 +95,7 @@ const BreadcrumbSeparator: {className={cn('[&>svg]:size-3.5', className)}{...props}>- {children ?? <ChevronRight />}+ {children ?? <ChevronRight className="dir-rtl:-scale-x-100" />}</li>);BreadcrumbSeparator.displayName = 'BreadcrumbSeparator';diff --git a/packages/client/src/components/Button.tsx b/packages/client/src/components/Button.tsxindex b65ef75f93..574e0e0015 100644--- a/packages/client/src/components/Button.tsx+++ b/packages/client/src/components/Button.tsx@@ -205,7 +205,7 @@ const buttonVariantRecipe = cva(* fill and the focus ring that mark it as a control.*/'inline-edit':- 'justify-start whitespace-normal text-left hover:bg-surface-hover focus-visible:ring-inset focus-visible:ring-offset-0',+ 'justify-start whitespace-normal text-start hover:bg-surface-hover focus-visible:ring-inset focus-visible:ring-offset-0',/*** A whole card or list row that is one click target, such as a project* tile or a chat row. It carries no fill of its own because the card@@ -232,8 +232,8 @@ const buttonVariantRecipe = cva(* `data-selected` marks the highlighted or chosen row.*/option:- 'w-full select-none justify-start gap-2.5 whitespace-normal text-left font-normal text-text-primary transition-opacity enabled:duration-500 disabled:duration-500 disabled:transition-all motion-reduce:transition-none motion-reduce:disabled:transition-none hover:bg-surface-hover hover:active:bg-surface-pressed data-[selected=true]:bg-surface-active data-[selected=true]:hover:bg-surface-active',- card: 'justify-start whitespace-normal rounded-2xl text-left font-normal hover:bg-surface-hover focus-visible:ring-inset focus-visible:ring-offset-0',+ 'w-full select-none justify-start gap-2.5 whitespace-normal text-start font-normal text-text-primary transition-opacity enabled:duration-500 disabled:duration-500 disabled:transition-all motion-reduce:transition-none motion-reduce:disabled:transition-none hover:bg-surface-hover hover:active:bg-surface-pressed data-[selected=true]:bg-surface-active data-[selected=true]:hover:bg-surface-active',+ card: 'justify-start whitespace-normal rounded-2xl text-start font-normal hover:bg-surface-hover focus-visible:ring-inset focus-visible:ring-offset-0',/** A small text action in the secondary ink beside a status line, such as a failed* steer's Retry or a pending one's Cancel; it rises to the primary ink under the pointer. */'text-action':@@ -241,7 +241,7 @@ const buttonVariantRecipe = cva(/** The content of a list row whose row owns the highlight, such as a composer palette* entry: it lays the row out and takes the pointer, and leaves fill and ink to the row. */'row-content':- 'flex cursor-pointer justify-start gap-2.5 px-2 text-left font-normal transition-none',+ 'flex cursor-pointer justify-start gap-2.5 px-2 text-start font-normal transition-none',/** An outlined chip that toggles a mode, its pressed state marked with `aria-pressed`. */'chip-toggle':'min-h-theme-target shrink-0 rounded-full border border-border-medium text-xs font-normal text-text-secondary hover:bg-surface-hover hover:text-text-primary focus-visible:ring-offset-0 aria-pressed:border-transparent aria-pressed:bg-surface-active-alt aria-pressed:text-text-primary aria-pressed:hover:bg-surface-active-alt',@@ -298,7 +298,7 @@ const buttonVariantRecipe = cva(/** The padding of a list row that is itself the click target. */row: 'h-auto gap-3 px-3.5 py-3',/** The padding of a tile that reserves a corner for an overflow menu. */- tile: 'h-auto gap-0 p-4 pr-12',+ tile: 'h-auto gap-0 p-4 pe-12',},shape: {default: 'rounded-lg',diff --git a/packages/client/src/components/Chip.tsx b/packages/client/src/components/Chip.tsxindex cf649c183c..9708459e3a 100644--- a/packages/client/src/components/Chip.tsx+++ b/packages/client/src/components/Chip.tsx@@ -78,7 +78,7 @@ const Chip: React.ForwardRefExoticComponent<ChipProps & React.RefAttributes<HTMLlabel={removeLabel}size="xs"shape={shape === 'theme' ? 'theme' : 'round'}- className="hover:bg-surface-hover/50 -mr-1 text-current"+ className="hover:bg-surface-hover/50 -me-1 text-current"onClick={(event) => {event.stopPropagation();onRemove(event);diff --git a/packages/client/src/components/Combobox.tsx b/packages/client/src/components/Combobox.tsxindex 6d7ed7312f..1e43f19c74 100644--- a/packages/client/src/components/Combobox.tsx+++ b/packages/client/src/components/Combobox.tsx@@ -91,7 +91,7 @@ export default function ComboboxComponent({<div className="assistant-item flex items-center justify-center overflow-hidden rounded-full">{SelectIcon ? SelectIcon : <ChevronDownIcon />}</div>- <span className={cn('ml-2 select-none', isCollapsed ? 'hidden' : '')}>+ <span className={cn('ms-2 select-none', isCollapsed ? 'hidden' : '')}>{selectedValue? (displayValue ?? selectedValue): selectPlaceholder && selectPlaceholder}@@ -111,7 +111,7 @@ export default function ComboboxComponent({)}><RadixSelect.Viewport className="mb-5 h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]">- <div className="group bg-surface-secondary text-text-primary sticky top-0 left-0 z-10 flex h-12 items-center gap-2 px-3 py-2 duration-300">+ <div className="group bg-surface-secondary text-text-primary sticky inset-s-0 top-0 z-10 flex h-12 items-center gap-2 px-3 py-2 duration-300"><SearchIcon className="text-text-secondary group-focus-within:text-text-primary group-hover:text-text-primary h-4 w-4 transition-colors duration-300" /><ComboboxautoSelect@@ -141,7 +141,7 @@ export default function ComboboxComponent({<RadixSelect.Item key={value} value={`${value ?? ''}`} asChild><ComboboxItemclassName={cn(- 'focus:bg-surface-hover focus:text-text-primary relative flex w-full cursor-pointer items-center rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50',+ 'focus:bg-surface-hover focus:text-text-primary relative flex w-full cursor-pointer items-center rounded-sm py-1.5 ps-2 pe-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50',disabledInkClasses,'hover:bg-surface-hover rounded-lg',)}@@ -151,7 +151,7 @@ export default function ComboboxComponent({setOpen(false);}}>- <span className="absolute right-2 flex h-3.5 w-3.5 items-center justify-center">+ <span className="absolute inset-e-2 flex h-3.5 w-3.5 items-center justify-center"><RadixSelect.ItemIndicator><CheckIcon className="size-theme-icon" /></RadixSelect.ItemIndicator>diff --git a/packages/client/src/components/Composer.tsx b/packages/client/src/components/Composer.tsxindex 97a91a829e..b2e2f97f53 100644--- a/packages/client/src/components/Composer.tsx+++ b/packages/client/src/components/Composer.tsx@@ -136,7 +136,7 @@ const Composer: ForwardRefExoticComponent<disabled={disabled || !canSubmit}onClick={() => onSubmit()}data-testid="composer-send-button"- className={cn(CONTROL_CLASS, offeredActions.length > 0 && 'ml-auto')}+ className={cn(CONTROL_CLASS, offeredActions.length > 0 && 'ms-auto')}><SendIcon className="size-6" /></button>@@ -207,7 +207,7 @@ const Composer: ForwardRefExoticComponent<{showStop ? (<TooltipAnchordescription={stopLabel}- className="ml-auto"+ className="ms-auto"render={<buttontype="button"@@ -242,7 +242,7 @@ const Composer: ForwardRefExoticComponent<offeredActions.length > 0 ? (sendButton) : (- <TooltipAnchor description={submitLabel} className="ml-auto" render={sendButton} />+ <TooltipAnchor description={submitLabel} className="ms-auto" render={sendButton} />)}/>diff --git a/packages/client/src/components/ControlCombobox.tsx b/packages/client/src/components/ControlCombobox.tsxindex 5fe81c5c21..82a7cdb7e4 100644--- a/packages/client/src/components/ControlCombobox.tsx+++ b/packages/client/src/components/ControlCombobox.tsx@@ -1,4 +1,12 @@-import { useMemo, useState, useRef, memo, useEffect, MemoExoticComponent } from 'react';+import {+ useMemo,+ useState,+ useRef,+ memo,+ useEffect,+ useLayoutEffect,+ MemoExoticComponent,+} from 'react';import * as Ariakit from '@ariakit/react';import { matchSorter } from 'match-sorter';import { Search, ChevronDown } from 'lucide-react';@@ -9,7 +17,7 @@ import useRemScale from '~/hooks/useRemScale';import { fieldControl } from './Field';import './AnimatePopover.css';import { JSX } from 'react/jsx-runtime';-import { cn, pxToRem } from '~/utils';+import { cn, pxToRem, resolveSide } from '~/utils';interface ControlComboboxProps {selectedValue: string;@@ -113,16 +121,24 @@ function ControlCombobox({setValue: setSearchValue,});+ /** Ariakit syncs the `placement` option into its store on every render, so the mirrored side+ * has to be the option itself, or the next render (a keystroke in the search) restores it. */+ const [resolvedPlacement, setResolvedPlacement] = useState(placement);const select = Ariakit.useSelectStore({combobox,defaultItems: items.map(getItem),value: selectedValue,setValue,setOpen: onOpenChange,- placement,+ placement: resolvedPlacement,});const selectOpen = select.useState('open');+ const selectAnchor = select.useState('anchorElement');+ /** Re-resolved on each open: a language switch flips the direction without remounting. */+ useLayoutEffect(() => {+ setResolvedPlacement(placement ? resolveSide(placement, selectAnchor) : placement);+ }, [placement, selectAnchor, selectOpen]);useEffect(() => {// The select owns the popover; hiding it does not hide the combobox store.if (!selectOpen) {@@ -183,8 +199,10 @@ function ControlCombobox({'flex h-5 w-5 items-center justify-center overflow-hidden rounded-full',iconClassName,);+ /** The gap sits between the icon and the label, whichever side of it the icon takes. */const optionIconClassName = cn(- 'mr-2 flex h-5 w-5 items-center justify-center overflow-hidden rounded-full',+ iconSide === 'right' ? 'ms-2' : 'me-2',+ 'flex h-5 w-5 items-center justify-center overflow-hidden rounded-full',iconClassName,);@@ -222,7 +240,7 @@ function ControlCombobox({{!isCollapsed && (<><span- className="grow truncate text-left"+ className="grow truncate text-start"title={(displayValue != null ? displayValue : selectedValue) || undefined}>{displayValue != null@@ -266,12 +284,12 @@ function ControlCombobox({><div className="shrink-0 py-1.5"><div className="relative">- <Search className="text-text-primary absolute top-1/2 left-3 h-4 w-4 -translate-y-1/2" />+ <Search className="text-text-primary absolute inset-s-3 top-1/2 h-4 w-4 -translate-y-1/2" /><Ariakit.Comboboxstore={combobox}autoSelectplaceholder={searchPlaceholder}- className="bg-surface-secondary text-text-primary w-full rounded-md py-2 pr-3 pl-9 text-sm focus:outline-hidden"+ className="bg-surface-secondary text-text-primary w-full rounded-md py-2 ps-9 pe-3 text-sm focus:outline-hidden"/></div></div>@@ -303,7 +321,7 @@ function ControlCombobox({{icon != null && iconSide === 'left' && (<div className={optionIconClassName}>{icon}</div>)}- <span className="grow truncate text-left">{label}</span>+ <span className="grow truncate text-start">{label}</span>{icon != null && iconSide === 'right' && (<div className={optionIconClassName}>{icon}</div>)}diff --git a/packages/client/src/components/DataTable.tsx b/packages/client/src/components/DataTable.tsxindex 7d0013d77f..1b9632be3f 100644--- a/packages/client/src/components/DataTable.tsx+++ b/packages/client/src/components/DataTable.tsx@@ -213,7 +213,7 @@ const DeleteButton = memo() : (<><TrashIcon className="text-text-destructive size-3.5 sm:size-4" />- {!isSmallScreen && <span className="ml-2">Delete</span>}+ {!isSmallScreen && <span className="ms-2">Delete</span>}</>)}</Button>@@ -469,7 +469,7 @@ export default function DataTable<TData, TValue>({{headerGroup.headers.map((header) => (<TableHeadkey={header.id}- className="bg-surface-secondary text-table-header-text px-2 text-left text-sm font-medium whitespace-nowrap sm:px-4"+ className="bg-surface-secondary text-table-header-text px-2 text-start text-sm font-medium whitespace-nowrap sm:px-4"style={getColumnStyle(header.column.columnDef as TableColumn<TData, TValue>,isSmallScreen,diff --git a/packages/client/src/components/DataTable/DataTable.tsx b/packages/client/src/components/DataTable/DataTable.tsxindex eb2ca513e7..a25fb22a47 100644--- a/packages/client/src/components/DataTable/DataTable.tsx+++ b/packages/client/src/components/DataTable/DataTable.tsx@@ -599,7 +599,7 @@ function DataTable<TData extends Record<string, unknown>, TValue>({aria-label={localize('com_ui_data_table')}>{showToolbar && (- <div className="border-border-light flex w-full shrink-0 items-center gap-2 border-b pr-2 md:gap-3">+ <div className="border-border-light flex w-full shrink-0 items-center gap-2 border-b pe-2 md:gap-3">{shouldShowSearch && <DataTableSearch value={searchTerm} onChange={setSearchTerm} />}{customActionsRenderer &&customActionsRenderer({diff --git a/packages/client/src/components/DataTable/DataTableComponents.tsx b/packages/client/src/components/DataTable/DataTableComponents.tsxindex dea3c81b78..5ebda7205b 100644--- a/packages/client/src/components/DataTable/DataTableComponents.tsx+++ b/packages/client/src/components/DataTable/DataTableComponents.tsx@@ -60,7 +60,7 @@ const TableRowComponent = <TData extends Record<string, unknown>>(/* The highlight is painted by the cells, not the row: `border-radius` has noeffect on a table row, so rounding the outer cells is what gives the hoverits pill shape. */- className="group border-0 hover:bg-transparent [&>*:first-child]:rounded-l-lg [&>*:last-child]:rounded-r-lg"+ className="group border-0 hover:bg-transparent [&>*:first-child]:rounded-s-lg [&>*:last-child]:rounded-e-lg"style={style}>{row.getVisibleCells().map((cell) => {diff --git a/packages/client/src/components/DataTable/DataTableSearch.spec.tsx b/packages/client/src/components/DataTable/DataTableSearch.spec.tsxindex 80e20c5b98..bae6a1bd7a 100644--- a/packages/client/src/components/DataTable/DataTableSearch.spec.tsx+++ b/packages/client/src/components/DataTable/DataTableSearch.spec.tsx@@ -131,7 +131,7 @@ describe('DataTableSearch', () => {its own and leaves room for the leading search icon. */expect(input.className).toContain('bg-transparent');expect(input.className).toContain('border-0');- expect(input.className).toContain('pl-9');+ expect(input.className).toContain('ps-9');});it('should have correct id for label association', () => {diff --git a/packages/client/src/components/DataTable/DataTableSearch.tsx b/packages/client/src/components/DataTable/DataTableSearch.tsxindex 4a42f67054..5662f86580 100644--- a/packages/client/src/components/DataTable/DataTableSearch.tsx+++ b/packages/client/src/components/DataTable/DataTableSearch.tsx@@ -26,7 +26,7 @@ export const DataTableSearch: MemoExoticComponent<{localize('com_ui_search_table')}</label><Search- className="pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-text-tertiary"+ className="text-text-tertiary pointer-events-none absolute inset-s-3 top-1/2 size-4 -translate-y-1/2"aria-hidden="true"/><Input@@ -40,7 +40,7 @@ export const DataTableSearch: MemoExoticComponent<aria-describedby={descriptionId}placeholder={placeholder || localize('com_ui_search')}className={cn(- 'h-11 rounded-none border-0 bg-transparent pl-9 text-sm placeholder:text-text-tertiary focus-visible:ring-inset',+ 'placeholder:text-text-tertiary h-11 rounded-none border-0 bg-transparent ps-9 text-sm focus-visible:ring-inset',className,)}/>diff --git a/packages/client/src/components/Dialog.tsx b/packages/client/src/components/Dialog.tsxindex ab9b95a6a7..c33aa819c1 100644--- a/packages/client/src/components/Dialog.tsx+++ b/packages/client/src/components/Dialog.tsx@@ -73,7 +73,7 @@ const DialogContent: React.ForwardRefExoticComponent<>{children}{showCloseButton && (- <DialogPrimitive.Close className="focus:ring-focus-control data-[state=open]:bg-surface-hover min-h-theme-target min-w-theme-target absolute top-[1.6rem] right-6 -mt-0.5 -mr-0.5 inline-flex items-center justify-center rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none">+ <DialogPrimitive.Close className="focus:ring-focus-control data-[state=open]:bg-surface-hover min-h-theme-target min-w-theme-target absolute inset-e-6 top-[1.6rem] -me-0.5 -mt-0.5 inline-flex items-center justify-center rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none"><X className="text-text-primary size-theme-icon-md" aria-hidden="true" /><span className="sr-only">Close</span></DialogPrimitive.Close>@@ -89,7 +89,7 @@ const DialogHeader: {({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): JSX.Element;displayName: string;} = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): JSX.Element => (- <div className={cn('flex flex-col space-y-2 p-6 pb-4 text-left', className ?? '')} {...props} />+ <div className={cn('flex flex-col space-y-2 p-6 pb-4 text-start', className ?? '')} {...props} />);DialogHeader.displayName = 'DialogHeader';diff --git a/packages/client/src/components/Dropdown.css b/packages/client/src/components/Dropdown.cssindex e559b0f8cc..b1c9707baa 100644--- a/packages/client/src/components/Dropdown.css+++ b/packages/client/src/components/Dropdown.css@@ -25,7 +25,7 @@transition-duration: 150ms;scale: 0.95;margin-top: 4px;- margin-right: -2px;+ margin-inline-end: -2px;}/* Elevation here is a black shadow, which carries no separation at all againstdiff --git a/packages/client/src/components/Dropdown.tsx b/packages/client/src/components/Dropdown.tsxindex 972d91266c..b9fe26a702 100644--- a/packages/client/src/components/Dropdown.tsx+++ b/packages/client/src/components/Dropdown.tsx@@ -141,7 +141,7 @@ const Dropdown: React.FC<DropdownProps> = ({{option.icon != null && <span>{option.icon as React.ReactNode}</span>}<span className="block truncate">{option.label}</span>{selectedValue === option.value && (- <span className="ml-auto pl-2">+ <span className="ms-auto ps-2"><svgwidth="24"height="24"@@ -236,7 +236,7 @@ const Dropdown: React.FC<DropdownProps> = ({<div className="sticky -top-2 z-10 -mx-2 -mt-2 mb-1 bg-inherit px-2 pt-2 pb-1.5"><div className="relative"><Search- className="text-text-tertiary size-theme-icon pointer-events-none absolute top-1/2 left-2 -translate-y-1/2"+ className="text-text-tertiary size-theme-icon pointer-events-none absolute inset-s-2 top-1/2 -translate-y-1/2"aria-hidden="true"/><Combobox.Combobox@@ -244,7 +244,7 @@ const Dropdown: React.FC<DropdownProps> = ({autoSelectplaceholder={searchPlaceholder}aria-label={searchPlaceholder}- className="border-border-control text-text-primary placeholder:text-text-secondary w-full rounded-lg border bg-inherit py-1.5 pr-2 pl-8 text-sm focus:outline-hidden"+ className="border-border-control text-text-primary placeholder:text-text-secondary w-full rounded-lg border bg-inherit py-1.5 ps-8 pe-2 text-sm focus:outline-hidden"/></div></div>diff --git a/packages/client/src/components/DropdownMenu.tsx b/packages/client/src/components/DropdownMenu.tsxindex e77f3e2a10..4e3ed859ef 100644--- a/packages/client/src/components/DropdownMenu.tsx+++ b/packages/client/src/components/DropdownMenu.tsx@@ -67,7 +67,7 @@ function DropdownMenuItem({data-inset={inset}data-variant={variant}className={cn(- "focus:bg-surface-hover focus:text-text-primary data-[variant=destructive]:text-text-destructive data-[variant=destructive]:focus:bg-status-error-subtle data-[variant=destructive]:focus:text-text-destructive [&_svg:not([class*='text-'])]:text-text-secondary data-[variant=destructive]:*:[svg]:text-text-destructive! relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",+ "focus:bg-surface-hover focus:text-text-primary data-[variant=destructive]:text-text-destructive data-[variant=destructive]:focus:bg-status-error-subtle data-[variant=destructive]:focus:text-text-destructive [&_svg:not([class*='text-'])]:text-text-secondary data-[variant=destructive]:*:[svg]:text-text-destructive! relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:ps-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",disabledInkClasses,className,)}@@ -86,14 +86,14 @@ function DropdownMenuCheckboxItem({<DropdownMenuPrimitive.CheckboxItemdata-slot="dropdown-menu-checkbox-item"className={cn(- "focus:bg-surface-hover focus:text-text-primary relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",+ "focus:bg-surface-hover focus:text-text-primary relative flex cursor-default items-center gap-2 rounded-sm py-1.5 ps-8 pe-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",disabledInkClasses,className,)}checked={checked}{...props}>- <span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">+ <span className="pointer-events-none absolute inset-s-2 flex size-3.5 items-center justify-center"><DropdownMenuPrimitive.ItemIndicator><CheckIcon className="size-4" /></DropdownMenuPrimitive.ItemIndicator>@@ -118,13 +118,13 @@ function DropdownMenuRadioItem({<DropdownMenuPrimitive.RadioItemdata-slot="dropdown-menu-radio-item"className={cn(- "focus:bg-surface-hover focus:text-text-primary relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",+ "focus:bg-surface-hover focus:text-text-primary relative flex cursor-default items-center gap-2 rounded-sm py-1.5 ps-8 pe-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",disabledInkClasses,className,)}{...props}>- <span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">+ <span className="pointer-events-none absolute inset-s-2 flex size-3.5 items-center justify-center"><DropdownMenuPrimitive.ItemIndicator><CircleIcon className="size-2 fill-current" /></DropdownMenuPrimitive.ItemIndicator>@@ -145,7 +145,7 @@ function DropdownMenuLabel({<DropdownMenuPrimitive.Labeldata-slot="dropdown-menu-label"data-inset={inset}- className={cn('px-2 py-1.5 text-sm font-medium data-[inset]:pl-8', className)}+ className={cn('px-2 py-1.5 text-sm font-medium data-[inset]:ps-8', className)}{...props}/>);@@ -168,7 +168,7 @@ function DropdownMenuShortcut({ className, ...props }: React.ComponentProps<'spareturn (<spandata-slot="dropdown-menu-shortcut"- className={cn('text-text-secondary ml-auto text-xs tracking-widest', className)}+ className={cn('text-text-secondary ms-auto text-xs tracking-widest', className)}{...props}/>);@@ -193,13 +193,13 @@ function DropdownMenuSubTrigger({data-slot="dropdown-menu-sub-trigger"data-inset={inset}className={cn(- 'focus:bg-surface-hover focus:text-text-primary data-[state=open]:bg-surface-hover data-[state=open]:text-text-primary flex cursor-default items-center rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[inset]:pl-8',+ 'focus:bg-surface-hover focus:text-text-primary data-[state=open]:bg-surface-hover data-[state=open]:text-text-primary flex cursor-default items-center rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[inset]:ps-8',className,)}{...props}>{children}- <ChevronRightIcon className="ml-auto size-4" />+ <ChevronRightIcon className="dir-rtl:-scale-x-100 ms-auto size-4" /></DropdownMenuPrimitive.SubTrigger>);}diff --git a/packages/client/src/components/DropdownPopup.tsx b/packages/client/src/components/DropdownPopup.tsxindex 947a72e169..5c5f9f29b1 100644--- a/packages/client/src/components/DropdownPopup.tsx+++ b/packages/client/src/components/DropdownPopup.tsx@@ -189,7 +189,7 @@ const Menu: React.FC<MenuProps> = ({>{item.icon != null && (<span- className={cn('size-theme-icon mr-2 [&>svg]:size-full', iconClassName)}+ className={cn('size-theme-icon me-2 [&>svg]:size-full', iconClassName)}aria-hidden="true">{item.icon}@@ -197,7 +197,7 @@ const Menu: React.FC<MenuProps> = ({)}{item.label}{item.kbd != null && (- <kbd className="text-text-tertiary ml-auto hidden font-sans text-xs group-hover:inline group-focus:inline">+ <kbd className="text-text-tertiary ms-auto hidden font-sans text-xs group-hover:inline group-focus:inline">⌘{item.kbd}</kbd>)}@@ -245,7 +245,7 @@ const SubMenuItem: React.FC<{<span className="flex items-center gap-2">{item.icon != null && (<span- className={cn('size-theme-icon mr-2 [&>svg]:size-full', iconClassName)}+ className={cn('size-theme-icon me-2 [&>svg]:size-full', iconClassName)}aria-hidden="true">{item.icon}diff --git a/packages/client/src/components/FilterInput.tsx b/packages/client/src/components/FilterInput.tsxindex d11b4be058..cfb0e3d716 100644--- a/packages/client/src/components/FilterInput.tsx+++ b/packages/client/src/components/FilterInput.tsx@@ -57,7 +57,7 @@ const FilterInput: React.ForwardRefExoticComponent<htmlFor={inputId}className={cn(peerDisabledInkClasses,- 'text-text-secondary pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-sm transition-all duration-200 peer-focus:top-0 peer-focus:bg-inherit peer-focus:px-1 peer-focus:text-xs peer-[:not(:placeholder-shown)]:top-0 peer-[:not(:placeholder-shown)]:bg-inherit peer-[:not(:placeholder-shown)]:px-1 peer-[:not(:placeholder-shown)]:text-xs',+ 'text-text-secondary pointer-events-none absolute inset-s-3 top-1/2 -translate-y-1/2 text-sm transition-all duration-200 peer-focus:top-0 peer-focus:bg-inherit peer-focus:px-1 peer-focus:text-xs peer-[:not(:placeholder-shown)]:top-0 peer-[:not(:placeholder-shown)]:bg-inherit peer-[:not(:placeholder-shown)]:px-1 peer-[:not(:placeholder-shown)]:text-xs',)}>{label}diff --git a/packages/client/src/components/FormInput.tsx b/packages/client/src/components/FormInput.tsxindex c1dc0f3982..7ac1b466c7 100644--- a/packages/client/src/components/FormInput.tsx+++ b/packages/client/src/components/FormInput.tsx@@ -47,7 +47,7 @@ export default function FormInput<<div className="flex w-full items-center justify-start gap-2"><LabelhtmlFor={`${field.name}-input`}- className={cn('text-left text-sm font-semibold text-text-primary', labelClass)}+ className={cn('text-text-primary text-start text-sm font-semibold', labelClass)}>{label}</Label>@@ -59,7 +59,7 @@ export default function FormInput<onChange={handleChange}placeholder={placeholder}className={cn(- 'flex h-10 max-h-10 w-full resize-none border-none bg-surface-secondary px-3 py-2',+ 'bg-surface-secondary flex h-10 max-h-10 w-full resize-none border-none px-3 py-2',inputClass,)}/>diff --git a/packages/client/src/components/InfoHoverCard.tsx b/packages/client/src/components/InfoHoverCard.tsxindex b4536ca3e0..8753a6dce0 100644--- a/packages/client/src/components/InfoHoverCard.tsx+++ b/packages/client/src/components/InfoHoverCard.tsx@@ -1,8 +1,10 @@-import { useState } from 'react';+import { useRef, useState } from 'react';import { JSX } from 'react/jsx-runtime';import { CircleHelpIcon, InfoIcon } from 'lucide-react';import type { ReactNode } from 'react';import { HoverCard, HoverCardTrigger, HoverCardPortal, HoverCardContent } from './HoverCard';+/* Relative: client/tsconfig.json also compiles this file, where `~` is the app's own src. */+import { resolveSide } from '../utils/direction';import { ESide } from '~/common';type InfoHoverCardProps = {@@ -21,12 +23,14 @@ const InfoHoverCard = ({children,}: InfoHoverCardProps): JSX.Element => {const [isOpen, setIsOpen] = useState(false);+ const triggerRef = useRef<HTMLButtonElement>(null);const Icon = icon === 'info' ? InfoIcon : CircleHelpIcon;return (<HoverCard openDelay={50} open={isOpen} onOpenChange={setIsOpen}><HoverCardTrigger asChild><button+ ref={triggerRef}type="button"className="focus-visible:ring-focus-control inline-flex cursor-help items-center justify-center rounded-sm focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden"onFocus={() => setIsOpen(true)}@@ -37,7 +41,10 @@ const InfoHoverCard = ({</button></HoverCardTrigger><HoverCardPortal>- <HoverCardContent side={side} className="z-[999] w-80">+ <HoverCardContent+ side={side && resolveSide(side, triggerRef.current)}+ className="z-[999] w-80"+ ><div className="max-h-[80vh] space-y-2 overflow-y-auto"><span className="text-text-secondary text-sm">{text}</span></div>diff --git a/packages/client/src/components/InputCombobox.tsx b/packages/client/src/components/InputCombobox.tsxindex 7aba7a8a7a..1728f4fab1 100644--- a/packages/client/src/components/InputCombobox.tsx+++ b/packages/client/src/components/InputCombobox.tsx@@ -96,7 +96,7 @@ export const InputCombobox: React.FC<ComboboxProps> = ({value={isOptionObject(option) ? `${option.value ?? ''}` : option}>{isOptionObject(option) && option.icon != null && (- <span className="mr-2 shrink-0">{option.icon}</span>+ <span className="me-2 shrink-0">{option.icon}</span>)}{isOptionObject(option) ? option.label : option}</Ariakit.ComboboxItem>diff --git a/packages/client/src/components/InputNumber.css b/packages/client/src/components/InputNumber.cssindex 64e3a70c6a..418ff44d9d 100644--- a/packages/client/src/components/InputNumber.css+++ b/packages/client/src/components/InputNumber.css@@ -7,5 +7,5 @@}.reset-rc-number-input-text-right input {- text-align: right;+ text-align: end;}diff --git a/packages/client/src/components/InputNumber.spec.tsx b/packages/client/src/components/InputNumber.spec.tsxindex 57593207e7..b7210b894e 100644--- a/packages/client/src/components/InputNumber.spec.tsx+++ b/packages/client/src/components/InputNumber.spec.tsx@@ -31,7 +31,7 @@ describe('InputNumber', () => {render(<InputNumber aria-label="count" variant="option" className="w-12" />);const wrapper = screen.getByRole('spinbutton').closest('.rc-input-number');- expect(wrapper).toHaveClass('border-0', 'reset-rc-number-input', 'text-right', 'w-12');+ expect(wrapper).toHaveClass('border-0', 'reset-rc-number-input', 'text-end', 'w-12');expect(wrapper).not.toHaveClass('w-full');});diff --git a/packages/client/src/components/InputNumber.tsx b/packages/client/src/components/InputNumber.tsxindex 0a6084b631..015833f4e3 100644--- a/packages/client/src/components/InputNumber.tsx+++ b/packages/client/src/components/InputNumber.tsx@@ -18,7 +18,7 @@ import './InputNumber.css';const INPUT_NUMBER_VARIANTS: Record<'default' | 'option', string> = {default: '',option:- 'h-auto border-0 border-transparent p-0 pr-1 text-right shadow-none outline-hidden transition-colors hover:not-focus-within:bg-surface-hover focus-within:bg-surface-secondary [&_input]:placeholder:text-text-secondary [&_input:focus]:placeholder:text-text-primary group-hover/temp:border-border-light reset-rc-number-input reset-rc-number-input-text-right',+ 'h-auto border-0 border-transparent p-0 pe-1 text-end shadow-none outline-hidden transition-colors hover:not-focus-within:bg-surface-hover focus-within:bg-surface-secondary [&_input]:placeholder:text-text-secondary [&_input:focus]:placeholder:text-text-primary group-hover/temp:border-border-light reset-rc-number-input reset-rc-number-input-text-right',};export type InputNumberProps = InputNumberPrimitive.InputNumberProps<ValueType> & {diff --git a/packages/client/src/components/InputOTP.tsx b/packages/client/src/components/InputOTP.tsxindex 8048b5cdfc..648b99c4ff 100644--- a/packages/client/src/components/InputOTP.tsx+++ b/packages/client/src/components/InputOTP.tsx@@ -110,7 +110,7 @@ const InputOTPSlot: React.ForwardRefExoticComponent<<divref={ref}className={cn(- 'border-border-control relative flex h-11 w-11 items-center justify-center border-y border-r text-base shadow-xs transition-all first:rounded-l-xl first:border-l last:rounded-r-xl',+ 'border-border-control relative flex h-11 w-11 items-center justify-center border-y border-e text-base shadow-xs transition-all first:rounded-s-xl first:border-s last:rounded-e-xl',isActive && 'ring-focus-control z-10 ring-1',className,)}diff --git a/packages/client/src/components/InputWithDropDown.tsx b/packages/client/src/components/InputWithDropDown.tsxindex d2d437c221..e91f6e12d8 100644--- a/packages/client/src/components/InputWithDropDown.tsx+++ b/packages/client/src/components/InputWithDropDown.tsx@@ -97,7 +97,7 @@ const InputWithDropdown: React.ForwardRefExoticComponent</><buttontype="button"- className="text-text-tertiary hover:text-text-secondary focus-visible:ring-focus-control absolute inset-y-0 right-0 flex items-center rounded-md px-2 focus-visible:ring-1 focus-visible:outline-hidden"+ className="text-text-tertiary hover:text-text-secondary focus-visible:ring-focus-control absolute inset-y-0 inset-e-0 flex items-center rounded-md px-2 focus-visible:ring-1 focus-visible:outline-hidden"onClick={() => setIsOpen(!isOpen)}aria-label={isOpen ? 'Close dropdown' : 'Open dropdown'}>diff --git a/packages/client/src/components/MultiSearch.tsx b/packages/client/src/components/MultiSearch.tsxindex d3519cb1c1..2c522f9acb 100644--- a/packages/client/src/components/MultiSearch.tsx+++ b/packages/client/src/components/MultiSearch.tsx@@ -32,7 +32,7 @@ export default function MultiSearch({return (<divclassName={cn(- 'focus:to-surface-primary/50 group from-surface-tertiary-alt text-text-primary focus:from-surface-primary sticky top-0 left-0 z-10 flex h-12 items-center gap-2 bg-gradient-to-b from-65% to-transparent px-3 py-2 transition-colors duration-300 focus:bg-gradient-to-b',+ 'focus:to-surface-primary/50 group from-surface-tertiary-alt text-text-primary focus:from-surface-primary sticky inset-s-0 top-0 z-10 flex h-12 items-center gap-2 bg-gradient-to-b from-65% to-transparent px-3 py-2 transition-colors duration-300 focus:bg-gradient-to-b',className,)}>diff --git a/packages/client/src/components/MultiSelect.tsx b/packages/client/src/components/MultiSelect.tsxindex cd485ec608..0ef689af8c 100644--- a/packages/client/src/components/MultiSelect.tsx+++ b/packages/client/src/components/MultiSelect.tsx@@ -159,12 +159,12 @@ export default function MultiSelect<T extends string>({onChange={(e) => e.stopPropagation()}>{selectIcon && <span>{selectIcon as React.JSX.Element}</span>}- <span className={cn('mr-auto truncate', !showSelectedValues && 'hidden md:block')}>+ <span className={cn('me-auto truncate', !showSelectedValues && 'hidden md:block')}>{renderSelectedValues(selectedValues, placeholder, items)}</span><SelectArrowclassName={cn(- 'ml-1 stroke-1 text-base opacity-75 transition-transform duration-300',+ 'ms-1 stroke-1 text-base opacity-75 transition-transform duration-300',!showSelectedValues && 'hidden md:block',isPopoverOpen && 'rotate-180',)}@@ -221,7 +221,7 @@ export default function MultiSelect<T extends string>({{isCurrentItemSelected && <Check className="size-3.5" strokeWidth={2} />}</span>) : (- <SelectItemCheck className="text-text-primary mr-0.5" />+ <SelectItemCheck className="text-text-primary me-0.5" />)}<span className="truncate">{label}</span></>diff --git a/packages/client/src/components/OGDialogTemplate.tsx b/packages/client/src/components/OGDialogTemplate.tsxindex 5a14384145..29e06f496a 100644--- a/packages/client/src/components/OGDialogTemplate.tsx+++ b/packages/client/src/components/OGDialogTemplate.tsx@@ -150,7 +150,7 @@ const OGDialogTemplate: ForwardRefExoticComponent<<div className={cn('px-0 py-2', mainClassName)}>{main != null ? main : null}</div><OGDialogFooter className={footerClassName}>{leftButtons != null ? (- <div className="mr-auto flex flex-row gap-2">{leftButtons}</div>+ <div className="me-auto flex flex-row gap-2">{leftButtons}</div>) : null}{showCancelButton && (<OGDialogClose asChild>diff --git a/packages/client/src/components/OriginalDialog.tsx b/packages/client/src/components/OriginalDialog.tsxindex e8fae0fb23..c9bdf13956 100644--- a/packages/client/src/components/OriginalDialog.tsx+++ b/packages/client/src/components/OriginalDialog.tsx@@ -381,7 +381,7 @@ const DialogContent: React.ForwardRefExoticComponent<aria-hidden="true"/>{showCloseButton && (- <DialogPrimitive.Close className="ring-ring-primary ring-offset-surface-dialog focus:ring-focus-control data-[state=open]:bg-surface-hover data-[state=open]:text-text-secondary min-h-theme-target min-w-theme-target absolute top-4 right-4 inline-flex items-center justify-center rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none">+ <DialogPrimitive.Close className="ring-ring-primary ring-offset-surface-dialog focus:ring-focus-control data-[state=open]:bg-surface-hover data-[state=open]:text-text-secondary min-h-theme-target min-w-theme-target absolute inset-e-4 top-4 inline-flex items-center justify-center rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none"><X className="size-theme-icon-lg" aria-hidden="true" /><span className="sr-only">Close</span></DialogPrimitive.Close>@@ -398,7 +398,7 @@ const DialogHeader: {displayName: string;} = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): JSX.Element => (<div- className={cn('space-y-theme-dialog-header flex flex-col text-center sm:text-left', className)}+ className={cn('space-y-theme-dialog-header flex flex-col text-center sm:text-start', className)}{...props}/>);diff --git a/packages/client/src/components/Pagination.tsx b/packages/client/src/components/Pagination.tsxindex 259cc5bbec..e613f2f3be 100644--- a/packages/client/src/components/Pagination.tsx+++ b/packages/client/src/components/Pagination.tsx@@ -73,10 +73,10 @@ const PaginationPrevious: {<PaginationLinkaria-label="Go to previous page"size="default"- className={cn('gap-1 pl-2.5', className)}+ className={cn('gap-1 ps-2.5', className)}{...props}>- <ChevronLeft className="h-4 w-4" aria-hidden="true" />+ <ChevronLeft className="dir-rtl:-scale-x-100 h-4 w-4" aria-hidden="true" /><span>Previous</span></PaginationLink>);@@ -89,11 +89,11 @@ const PaginationNext: {<PaginationLinkaria-label="Go to next page"size="default"- className={cn('gap-1 pr-2.5', className)}+ className={cn('gap-1 pe-2.5', className)}{...props}><span>Next</span>- <ChevronRight className="h-4 w-4" aria-hidden="true" />+ <ChevronRight className="dir-rtl:-scale-x-100 h-4 w-4" aria-hidden="true" /></PaginationLink>);PaginationNext.displayName = 'PaginationNext';diff --git a/packages/client/src/components/Progress.tsx b/packages/client/src/components/Progress.tsxindex 47dcdd6854..121b8453dc 100644--- a/packages/client/src/components/Progress.tsx+++ b/packages/client/src/components/Progress.tsx@@ -36,7 +36,7 @@ const Progress: React.ForwardRefExoticComponent<ref={ref}value={value}className={cn(- 'bg-surface-tertiary relative h-2 w-full overflow-hidden rounded-full',+ 'bg-surface-tertiary dir-rtl:-scale-x-100 relative h-2 w-full overflow-hidden rounded-full',className,)}{...props}diff --git a/packages/client/src/components/QuestionMark.tsx b/packages/client/src/components/QuestionMark.tsxindex dc675e6027..4f64151773 100644--- a/packages/client/src/components/QuestionMark.tsx+++ b/packages/client/src/components/QuestionMark.tsx@@ -10,7 +10,7 @@ export const QuestionMark = ({<span><divclassName={cn(- 'border-border-medium text-text-tertiary ml-2 flex h-3.5 w-3.5 cursor-default items-center justify-center rounded-full border text-[0.5rem] leading-none font-medium',+ 'border-border-medium text-text-tertiary ms-2 flex h-3.5 w-3.5 cursor-default items-center justify-center rounded-full border text-[0.5rem] leading-none font-medium',className,)}>diff --git a/packages/client/src/components/Radio.spec.tsx b/packages/client/src/components/Radio.spec.tsxindex c518aa95e7..502dc4cfa3 100644--- a/packages/client/src/components/Radio.spec.tsx+++ b/packages/client/src/components/Radio.spec.tsx@@ -79,6 +79,24 @@ describe('Radio keyboard navigation', () => {expect(document.activeElement).toBe(weekdays);});+ it('swaps ArrowLeft and ArrowRight inside an RTL container', () => {+ const onChange = jest.fn();+ render(+ <div dir="rtl" style={{ direction: 'rtl' }}>+ <Radio options={FIVE} value="daily" onChange={onChange} />+ </div>,+ );++ const daily = screen.getByRole('radio', { name: 'Daily' });+ daily.focus();+ fireEvent.keyDown(daily, { key: 'ArrowLeft' });+ expect(onChange).toHaveBeenLastCalledWith('weekdays');++ screen.getByRole('radio', { name: 'Weekdays' }).focus();+ fireEvent.keyDown(screen.getByRole('radio', { name: 'Weekdays' }), { key: 'ArrowRight' });+ expect(onChange).toHaveBeenLastCalledWith('daily');+ });+it('moves backward with ArrowLeft and ArrowUp, wrapping in both directions', () => {const onChange = jest.fn();render(<Radio options={FIVE} value="daily" onChange={onChange} />);diff --git a/packages/client/src/components/Radio.tsx b/packages/client/src/components/Radio.tsxindex 97148c1137..b6c38dd3ea 100644--- a/packages/client/src/components/Radio.tsx+++ b/packages/client/src/components/Radio.tsx@@ -1,5 +1,5 @@import React, { useState, useRef, useLayoutEffect, useCallback, memo } from 'react';-import { disabledInkClasses } from '~/utils';+import { disabledInkClasses, resolveArrowKey } from '~/utils';import { useLocalize } from '~/hooks';/** Matches the `inset-y-1` the single-row indicator uses. */@@ -75,7 +75,7 @@ const Radio: React.NamedExoticComponent<RadioProps> = memo(function Radio({Home: 0,End: options.length - 1,};- const target = moves[event.key];+ const target = moves[resolveArrowKey(event.key, event.currentTarget)];if (target == null) {return;}diff --git a/packages/client/src/components/SecretInput.spec.tsx b/packages/client/src/components/SecretInput.spec.tsxindex cc267c841a..75d2714433 100644--- a/packages/client/src/components/SecretInput.spec.tsx+++ b/packages/client/src/components/SecretInput.spec.tsx@@ -60,7 +60,7 @@ describe('SecretInput', () => {'h-theme-field','focus-visible:ring-focus-control','theme-field-border:focus:border-border-field-focus',- 'pr-20',+ 'pe-20',);expect(field).not.toHaveClass('h-10');});@@ -71,7 +71,7 @@ describe('SecretInput', () => {render(<SecretInput id="pw" variant="floating" label="Password" />);const field = document.getElementById('pw');- expect(field).toHaveClass('peer', 'rounded-theme-auth-control', 'pr-11');+ expect(field).toHaveClass('peer', 'rounded-theme-auth-control', 'pe-11');expect(field).toHaveAttribute('placeholder', ' ');expect(screen.getByText('Password')).toHaveClass('peer-placeholder-shown:top-1/2');expect(screen.getByRole('button', { name: 'Show secret' })).toHaveClass(diff --git a/packages/client/src/components/SecretInput.tsx b/packages/client/src/components/SecretInput.tsxindex 04df4a2e57..f1fa20f450 100644--- a/packages/client/src/components/SecretInput.tsx+++ b/packages/client/src/components/SecretInput.tsx@@ -96,7 +96,7 @@ const SecretInput: React.ForwardRefExoticComponent<fieldInvalid,INPUT_VARIANTS[variant],className ?? '',- copyButton != null || showCopy ? 'pr-20' : 'pr-11',+ copyButton != null || showCopy ? 'pe-20' : 'pe-11',)}ref={ref}disabled={disabled}@@ -113,8 +113,8 @@ const SecretInput: React.ForwardRefExoticComponent<)}<divclassName={cn(- 'pointer-events-none absolute inset-y-0 right-1.5 flex items-center gap-0.5 [&_button]:pointer-events-auto',- isFloating && 'right-2',+ 'pointer-events-none absolute inset-y-0 inset-e-1.5 flex items-center gap-0.5 [&_button]:pointer-events-auto',+ isFloating && 'inset-e-2',controlsOnHover &&'opacity-0 transition-opacity duration-150 group-focus-within/secret-input:opacity-100 group-hover/secret-input:opacity-100',controlsClassName,diff --git a/packages/client/src/components/Select.tsx b/packages/client/src/components/Select.tsxindex edb656ffee..8baf238c1a 100644--- a/packages/client/src/components/Select.tsx+++ b/packages/client/src/components/Select.tsx@@ -146,14 +146,14 @@ const SelectItem: React.ForwardRefExoticComponent<<SelectPrimitive.Itemref={ref}className={cn(- 'focus:bg-surface-hover focus:text-text-primary relative flex w-full cursor-pointer items-center rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50',+ 'focus:bg-surface-hover focus:text-text-primary relative flex w-full cursor-pointer items-center rounded-sm py-1.5 ps-2 pe-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50',disabledInkClasses,'hover:bg-surface-hover rounded-lg',className,)}{...props}>- <span className="size-theme-icon absolute right-2 flex items-center justify-center">+ <span className="size-theme-icon absolute inset-e-2 flex items-center justify-center"><SelectPrimitive.ItemIndicator><CheckIcon className="size-theme-icon" /></SelectPrimitive.ItemIndicator>diff --git a/packages/client/src/components/SelectDropDown.tsx b/packages/client/src/components/SelectDropDown.tsxindex 46a8a7d05d..bff99b1670 100644--- a/packages/client/src/components/SelectDropDown.tsx+++ b/packages/client/src/components/SelectDropDown.tsx@@ -24,8 +24,8 @@ type SelectDropDownProps = {emptyTitle?: boolean;showAbove?: boolean;showLabel?: boolean;- iconSide?: 'left' | 'right';- optionIconSide?: 'left' | 'right';+ iconSide?: IconSide;+ optionIconSide?: IconSide;renderOption?: () => React.ReactNode;containerClassName?: string;currentValueClass?: string;@@ -39,6 +39,27 @@ type SelectDropDownProps = {showOptionIcon?: boolean;};+/** `left` and `right` are physical edges in every direction; `start` and `end` follow the+ * reading direction, so they mirror in RTL. */+type IconSide = 'left' | 'right' | 'start' | 'end';++const checkMarkSide: Record<IconSide, string> = {+ left: 'left-0 pl-2',+ right: 'right-0 pr-3',+ start: 'inset-s-0 ps-2',+ end: 'inset-e-0 pe-3',+};++/** Room for a check mark that sits before the label. */+const labelCheckGap: Record<IconSide, string> = { left: 'ml-4', right: '', start: 'ms-4', end: '' };++const trailingOptionIcon: Record<IconSide, string> = {+ left: '',+ right: 'absolute right-0 pr-2',+ start: '',+ end: 'absolute inset-e-0 pe-2',+};+function getOptionText(option: string | Option | OptionWithIcon): string {if (typeof option === 'string') {return option;@@ -61,8 +82,8 @@ function SelectDropDown({showAbove = false,showLabel = true,emptyTitle = false,- iconSide = 'right',- optionIconSide = 'left',+ iconSide = 'end',+ optionIconSide = 'start',placeholder,containerClassName,optionsListClass,@@ -98,6 +119,8 @@ function SelectDropDown({const hasSearchRender = searchRender != null;const options = hasSearchRender ? filteredValues : values;const renderIcon = showOptionIcon && value != null && (value as OptionWithIcon).icon != null;+ /** The wide padding keeps the label clear of a trailing check mark, on the same axis as it. */+ const optionPadding = iconSide === 'left' || iconSide === 'right' ? 'pr-9 pl-3' : 'ps-3 pe-9';return (<div className={cn('flex items-center justify-center gap-2', containerClassName ?? '')}>@@ -119,7 +142,7 @@ function SelectDropDown({}}}className={cn(- 'border-border-control bg-surface-secondary focus-visible:ring-focus-control disabled:bg-surface-secondary relative flex w-full cursor-default flex-col rounded-md border py-2 pr-10 pl-3 text-left focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden sm:text-sm',+ 'border-border-control bg-surface-secondary focus-visible:ring-focus-control disabled:bg-surface-secondary relative flex w-full cursor-default flex-col rounded-md border py-2 ps-3 pe-10 text-start focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden sm:text-sm',disabledFillClasses,className ?? '',)}@@ -144,13 +167,13 @@ function SelectDropDown({{!showLabel && !emptyTitle && (<span className="text-text-secondary text-xs">{title}:</span>)}- {renderIcon && optionIconSide !== 'right' && (+ {renderIcon && trailingOptionIcon[optionIconSide] === '' && (<span className="icon-md flex items-center">{(value as OptionWithIcon).icon}</span>)}{renderIcon && (- <span className="icon-md absolute right-0 mr-8 flex items-center">+ <span className="icon-md absolute inset-e-0 me-8 flex items-center">{(value as OptionWithIcon).icon}</span>)}@@ -165,7 +188,7 @@ function SelectDropDown({})()}</span></span>- <span className="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2">+ <span className="pointer-events-none absolute inset-y-0 inset-e-0 flex items-center pe-2"><svgstroke="currentColor"fill="none"@@ -202,7 +225,8 @@ function SelectDropDown({key={'listbox-render-option'}value={null}className={cn(- 'group text-text-primary hover:bg-surface-hover relative flex h-[2.625rem] cursor-pointer items-center overflow-hidden pr-9 pl-3 select-none',+ 'group text-text-primary hover:bg-surface-hover relative flex h-[2.625rem] cursor-pointer items-center overflow-hidden select-none',+ optionPadding,optionsClass ?? '',)}>@@ -231,7 +255,8 @@ function SelectDropDown({value={option}className={({ active }) =>cn(- 'group text-text-primary hover:bg-surface-hover relative flex h-[2.625rem] cursor-pointer items-center overflow-hidden pr-9 pl-3 select-none',+ 'group text-text-primary hover:bg-surface-hover relative flex h-[2.625rem] cursor-pointer items-center overflow-hidden select-none',+ optionPadding,active ? 'bg-surface-active text-text-primary' : '',optionsClass ?? '',)@@ -242,16 +267,11 @@ function SelectDropDown({className={cn('text-text-primary flex h-6 items-center gap-1',option === value ? 'font-semibold' : '',- iconSide === 'left' ? 'ml-4' : '',+ labelCheckGap[iconSide],)}>{currentIcon != null && (- <span- className={cn(- 'mr-1',- optionIconSide === 'right' ? 'absolute right-0 pr-2' : '',- )}- >+ <span className={cn('me-1', trailingOptionIcon[optionIconSide])}>{currentIcon}</span>)}@@ -261,7 +281,7 @@ function SelectDropDown({<spanclassName={cn('text-text-primary absolute inset-y-0 flex items-center',- iconSide === 'left' ? 'left-0 pl-2' : 'right-0 pr-3',+ checkMarkSide[iconSide],)}><CheckMark />diff --git a/packages/client/src/components/SendActions.tsx b/packages/client/src/components/SendActions.tsxindex 213ff23260..8d46ed1b98 100644--- a/packages/client/src/components/SendActions.tsx+++ b/packages/client/src/components/SendActions.tsx@@ -24,7 +24,7 @@ const ROW_CLASS = cn(function Kbd({ children }: { children: ReactNode }): JSX.Element {return (- <kbd className="bg-surface-tertiary text-text-secondary ml-auto rounded-md px-1.5 py-0.5 font-sans text-xs">+ <kbd className="bg-surface-tertiary text-text-secondary ms-auto rounded-md px-1.5 py-0.5 font-sans text-xs">{children}</kbd>);diff --git a/packages/client/src/components/Switch.tsx b/packages/client/src/components/Switch.tsxindex bbed41918f..b96e74781c 100644--- a/packages/client/src/components/Switch.tsx+++ b/packages/client/src/components/Switch.tsx@@ -36,7 +36,7 @@ const Switch: React.ForwardRefExoticComponent<><SwitchPrimitives.ThumbclassName={cn(- 'bg-switch-thumb size-theme-switch-thumb data-[state=checked]:translate-x-theme-switch-travel pointer-events-none block rounded-full shadow-lg ring-0 transition-transform data-[state=unchecked]:translate-x-0',+ 'bg-switch-thumb size-theme-switch-thumb data-[state=checked]:translate-x-theme-switch-travel dir-rtl:data-[state=checked]:-translate-x-theme-switch-travel pointer-events-none block rounded-full shadow-lg ring-0 transition-transform data-[state=unchecked]:translate-x-0',)}/></SwitchPrimitives.Root>diff --git a/packages/client/src/components/Table.tsx b/packages/client/src/components/Table.tsxindex f974e717b6..4898556d69 100644--- a/packages/client/src/components/Table.tsx+++ b/packages/client/src/components/Table.tsx@@ -135,7 +135,7 @@ const TableHead: React.ForwardRefExoticComponent<ref={ref}className={cn(tableCellRule,- 'text-table-header-text h-theme-table-head px-4 text-left align-middle font-medium [&:has([role=checkbox])]:pr-0',+ 'text-table-header-text h-theme-table-head px-4 text-start align-middle font-medium [&:has([role=checkbox])]:pe-0',tableHeadVariants({ size }),className,)}@@ -173,7 +173,7 @@ const TableCell: React.ForwardRefExoticComponent<ref={ref}className={cn(tableCellRule,- 'px-4 align-middle [&:has([role=checkbox])]:pr-0',+ 'px-4 align-middle [&:has([role=checkbox])]:pe-0',tableCellVariants({ size }),className,)}@@ -194,7 +194,7 @@ const TableRowHeader: React.ForwardRefExoticComponent<scope="row"className={cn(tableCellRule,- 'px-4 text-left align-middle font-medium [&:has([role=checkbox])]:pr-0',+ 'px-4 text-start align-middle font-medium [&:has([role=checkbox])]:pe-0',tableCellVariants({ size }),className,)}diff --git a/packages/client/src/components/Tag.tsx b/packages/client/src/components/Tag.tsxindex aedebc39d5..5f0337de2e 100644--- a/packages/client/src/components/Tag.tsx+++ b/packages/client/src/components/Tag.tsx@@ -46,7 +46,7 @@ const TagPrimitiveRoot = React.forwardRef<HTMLDivElement, TagProps>(className,)}>- <div className={cn('ml-1 whitespace-pre-wrap px-2 py-1', labelClassName)}>+ <div className={cn('ms-1 px-2 py-1 whitespace-pre-wrap', labelClassName)}>{LabelNode ? <>{LabelNode} </> : null}{label}</div>@@ -56,7 +56,7 @@ const TagPrimitiveRoot = React.forwardRef<HTMLDivElement, TagProps>(<IconButtonlabel={`Remove ${label}`}size="xs"- className="mr-0.5 text-current hover:bg-surface-hover/50"+ className="hover:bg-surface-hover/50 me-0.5 text-current"onClick={(e) => {e.stopPropagation();onRemove(e);diff --git a/packages/client/src/components/ThemeSelector.tsx b/packages/client/src/components/ThemeSelector.tsxindex 00666e36bf..de71d5fb9a 100644--- a/packages/client/src/components/ThemeSelector.tsx+++ b/packages/client/src/components/ThemeSelector.tsx@@ -67,7 +67,7 @@ const Theme = ({<Buttonvariant="ghost"size="icon"- className="h-auto w-auto p-2 text-text-primary"+ className="text-text-primary h-auto w-auto p-2"aria-label={localize('com_ui_toggle_theme')}aria-keyshortcuts="Ctrl+Shift+T"onClick={(e) => {@@ -110,7 +110,7 @@ const ContrastToggle = ({<Buttonvariant="ghost"size="icon"- className="h-auto w-auto p-2 text-text-primary"+ className="text-text-primary h-auto w-auto p-2"aria-label={localize('com_ui_toggle_high_contrast')}aria-pressed={highContrast}onClick={(e) => {@@ -174,8 +174,8 @@ const ThemeSelector = ({ returnThemeOnly }: { returnThemeOnly?: boolean }): JSX.}return (- <div className="flex flex-col items-center justify-center bg-surface-primary pt-6 sm:pt-0">- <div className="absolute bottom-0 left-0 m-4 flex items-center">+ <div className="bg-surface-primary flex flex-col items-center justify-center pt-6 sm:pt-0">+ <div className="absolute inset-s-0 bottom-0 m-4 flex items-center"><Theme theme={theme} highContrast={highContrast} onChange={changeScheme} /><ContrastToggle theme={theme} highContrast={highContrast} onChange={changeContrast} /></div>diff --git a/packages/client/src/components/TimePicker.spec.tsx b/packages/client/src/components/TimePicker.spec.tsxindex c01989640c..a40ee31eb4 100644--- a/packages/client/src/components/TimePicker.spec.tsx+++ b/packages/client/src/components/TimePicker.spec.tsx@@ -1,6 +1,6 @@import { useState } from 'react';import userEvent from '@testing-library/user-event';-import { render, screen, within } from '@testing-library/react';+import { fireEvent, render, screen, within } from '@testing-library/react';import TimePicker, { MinutePicker } from './TimePicker';const LABELS = { hour: 'Hour', minute: 'Minute', meridiem: 'AM or PM', am: 'AM', pm: 'PM' };@@ -172,4 +172,22 @@ describe('MinutePicker', () => {await user.click(within(minutes).getByRole('radio', { name: '30' }));expect(screen.getByTestId('minute')).toHaveTextContent('30');});++ it('keeps ArrowRight advancing like ArrowDown in an RTL document, since the column is vertical', async () => {+ const user = userEvent.setup();+ document.documentElement.setAttribute('dir', 'rtl');+ try {+ render(<MinuteHarness />);+ await user.click(screen.getByRole('button', { name: 'Minutes past the hour 00' }));+ const minutes = screen.getByRole('radiogroup', { name: 'Minute' });+ const options = within(minutes).getAllByRole('radio');++ fireEvent.keyDown(options[0], { key: 'ArrowRight' });+ expect(screen.getByTestId('minute')).toHaveTextContent(+ options[1].getAttribute('data-value') ?? '',+ );+ } finally {+ document.documentElement.removeAttribute('dir');+ }+ });});diff --git a/packages/client/src/components/Toast.tsx b/packages/client/src/components/Toast.tsxindex d9e7bf85cd..01b13cb9ae 100644--- a/packages/client/src/components/Toast.tsx+++ b/packages/client/src/components/Toast.tsx@@ -74,12 +74,12 @@ export function Toast(): JSX.Element {</div>)}<RadixToast.Description className="flex-1 justify-center gap-2">- <div className="text-left whitespace-pre-wrap">{toast.message}</div>+ <div className="text-start whitespace-pre-wrap">{toast.message}</div></RadixToast.Description>{persistent && (<RadixToast.Closearia-label={localize('com_ui_close')}- className="ml-2 inline-flex shrink-0 grow-0 items-center justify-center self-center rounded-sm opacity-80 transition-opacity hover:opacity-100 focus-visible:ring-2 focus-visible:ring-current focus-visible:outline-hidden"+ className="ms-2 inline-flex shrink-0 grow-0 items-center justify-center self-center rounded-sm opacity-80 transition-opacity hover:opacity-100 focus-visible:ring-2 focus-visible:ring-current focus-visible:outline-hidden"><X className="h-4 w-4" strokeWidth={3} /></RadixToast.Close>diff --git a/packages/client/src/components/Tooltip.css b/packages/client/src/components/Tooltip.cssindex 87b793734b..fed00d3c0b 100644--- a/packages/client/src/components/Tooltip.css+++ b/packages/client/src/components/Tooltip.css@@ -6,8 +6,8 @@background-color: rgb(var(--surface-tooltip, var(--surface-primary)));padding-top: var(--theme-tooltip-padding-y, 0.25rem);padding-bottom: var(--theme-tooltip-padding-y, 0.25rem);- padding-left: var(--theme-tooltip-padding-x, 0.5rem);- padding-right: var(--theme-tooltip-padding-x, 0.5rem);+ padding-inline-start: var(--theme-tooltip-padding-x, 0.5rem);+ padding-inline-end: var(--theme-tooltip-padding-x, 0.5rem);font-size: var(--theme-tooltip-text-size, 1rem);line-height: 1.5;color: rgb(var(--text-tooltip, var(--text-primary)));@@ -15,7 +15,7 @@/* Enhanced layout for longer descriptions */max-width: 320px;word-wrap: break-word;- text-align: left;+ text-align: start;}@media (max-width: 640px) {diff --git a/packages/client/src/components/Tooltip.tsx b/packages/client/src/components/Tooltip.tsxindex 13367c9945..d62e786dd6 100644--- a/packages/client/src/components/Tooltip.tsx+++ b/packages/client/src/components/Tooltip.tsx@@ -2,6 +2,7 @@ import {memo,forwardRef,useCallback,+ useLayoutEffect,useMemo,RefAttributes,ForwardRefExoticComponent,@@ -12,7 +13,7 @@ import { AnimatePresence, motion } from 'framer-motion';import type { FocusOutline } from './Focus';import { useDialogDepth, usePopoverZIndex } from './OriginalDialog';import { focusOutlineVariants } from './Focus';-import { cn } from '~/utils';+import { cn, resolveSide } from '~/utils';import './Tooltip.css';interface TooltipAnchorProps extends Ariakit.TooltipAnchorProps {@@ -149,6 +150,15 @@ export const TooltipAnchor: ForwardRefExoticComponent<ref,) {const tooltip = Ariakit.useTooltipStore({ placement: side });+ const anchorElement = Ariakit.useStoreState(tooltip, 'anchorElement');+ const open = Ariakit.useStoreState(tooltip, 'open');++ /** `side` is physical; resolve it against the anchor's own direction so `right` stays the+ * inline-end side in an RTL layout without every caller having to know. Re-resolved on each+ * open, since a language switch flips the document direction without remounting. */+ useLayoutEffect(() => {+ tooltip.setState('placement', resolveSide(side, anchorElement));+ }, [tooltip, side, anchorElement, open]);/*** `role="button"` renders a plain element with no native activation, so Enter anddiff --git a/packages/client/src/components/floating.ts b/packages/client/src/components/floating.tsindex 2b0d7e62bd..a6283d7109 100644--- a/packages/client/src/components/floating.ts+++ b/packages/client/src/components/floating.ts@@ -10,7 +10,7 @@ export const floatingField: string ='webkit-dark-styles peer h-theme-auth-field w-full rounded-theme-auth-control border px-3.5 pb-0 pt-0.5 text-text-primary duration-200 motion-reduce:transition-none focus:border-accent-primary focus-visible:border-accent-primary';export const floatingLabel: string =- 'absolute start-3 top-1.5 z-10 origin-[0] -translate-y-4 scale-75 transform bg-surface-primary px-2 theme-field-fill:bg-field-fill text-sm text-text-secondary-alt duration-200 peer-placeholder-shown:top-1/2 peer-placeholder-shown:-translate-y-1/2 peer-placeholder-shown:scale-100 peer-focus:top-1.5 peer-focus:-translate-y-4 peer-focus:scale-75 peer-focus:px-2 peer-focus:text-accent-primary motion-reduce:transition-none rtl:peer-focus:left-auto rtl:peer-focus:translate-x-1/4';+ 'absolute start-3 top-1.5 z-10 origin-[0] dir-rtl:origin-right -translate-y-4 scale-75 transform bg-surface-primary px-2 theme-field-fill:bg-field-fill text-sm text-text-secondary-alt duration-200 peer-placeholder-shown:top-1/2 peer-placeholder-shown:-translate-y-1/2 peer-placeholder-shown:scale-100 peer-focus:top-1.5 peer-focus:-translate-y-4 peer-focus:scale-75 peer-focus:px-2 peer-focus:text-accent-primary motion-reduce:transition-none';export const floatingSecretButton: string ='size-theme-auth-field-action rounded-xl text-text-secondary-alt hover:bg-transparent hover:text-text-primary';diff --git a/packages/client/src/theme/tailwind.spec.js b/packages/client/src/theme/tailwind.spec.jsindex b5bcc74d5a..c1bad6ac98 100644--- a/packages/client/src/theme/tailwind.spec.js+++ b/packages/client/src/theme/tailwind.spec.js@@ -94,6 +94,27 @@ describe('LibreChat Tailwind preset', () => {expect(rule(css, 'animate-loading-dot')).toContain('1.2s ease-in-out');});+ it('negates the switch thumb travel so an RTL track can mirror it', async () => {+ const css = await generate(['-translate-x-theme-switch-travel']);++ expect(rule(css, '-translate-x-theme-switch-travel')).toContain('--theme-switch-width');+ expect(rule(css, '-translate-x-theme-switch-travel')).toContain('* -1)');+ });++ it('mirrors the switch thumb by the element direction, not any RTL ancestor', async () => {+ const candidate = 'dir-rtl:data-[state=checked]:-translate-x-theme-switch-travel';+ const css = await generate([candidate]);+ const [modern, fallback] = css.split('@supports not selector(:dir(rtl))');++ /** Tailwind's `rtl:` also matches `[dir="rtl"] *`, which reaches into an LTR island. */+ expect(modern).toContain(':dir(rtl)');+ expect(modern).toContain('--theme-switch-width');+ expect(modern).not.toContain("[dir='rtl']");+ /** Only a browser without `:dir()` falls back to the attribute. */+ expect(fallback).toContain('@container style(--dir-fallback: rtl)');+ expect(fallback).toContain('--theme-switch-width');+ });+it('generates every component animation and its keyframes together', async () => {const names = ['loading-dot', 'accordion-down', 'accordion-up', 'caret-blink'];const css = await generate(names.map((name) => `animate-${name}`));diff --git a/packages/client/src/theme/tokens.css b/packages/client/src/theme/tokens.cssindex b91358f093..b5ecae9d05 100644--- a/packages/client/src/theme/tokens.css+++ b/packages/client/src/theme/tokens.css@@ -366,3 +366,32 @@@slot;}}++/* Mirrors by the element's own direction, so an LTR island inside an RTL page stays unmirrored,+ * which Tailwind's `rtl:` (it also matches `[dir='rtl'] *`) does not. A browser without `:dir()`+ * (Chrome and Edge before 120) drops that rule and reads `--dir-fallback` instead: it inherits+ * from the nearest `dir` attribute, and a container style query reads it off the parent, so the+ * nearest direction wins at any nesting depth, as `:dir()` resolves it. */+[dir='rtl'] {+ --dir-fallback: rtl;+}++[dir='ltr'] {+ --dir-fallback: ltr;+}++@custom-variant dir-rtl {+ &:dir(rtl) {+ @slot;+ }+ @supports not selector(:dir(rtl)) {+ &[dir='rtl'] {+ @slot;+ }+ @container style(--dir-fallback: rtl) {+ &:not([dir='ltr']) {+ @slot;+ }+ }+ }+}diff --git a/packages/client/src/utils/direction.spec.ts b/packages/client/src/utils/direction.spec.tsnew file mode 100644index 0000000000..42e538a8e1--- /dev/null+++ b/packages/client/src/utils/direction.spec.ts@@ -0,0 +1,48 @@+import { isRtl, resolveSide, resolveArrowKey } from './direction';++function mount(dir: 'ltr' | 'rtl'): HTMLElement {+ const el = document.createElement('div');+ el.setAttribute('dir', dir);+ el.style.direction = dir;+ document.body.appendChild(el);+ return el;+}++describe('direction helpers', () => {+ afterEach(() => {+ document.body.innerHTML = '';+ });++ it('reads the direction from the element, not the document', () => {+ expect(isRtl(mount('rtl'))).toBe(true);+ expect(isRtl(mount('ltr'))).toBe(false);+ expect(isRtl(null)).toBe(false);+ });++ it('lets a CSS direction override win over an ancestor dir attribute', () => {+ const island = document.createElement('div');+ island.style.direction = 'rtl';+ mount('ltr').appendChild(island);+ expect(isRtl(island)).toBe(true);+ });++ it('swaps left and right placements for an RTL anchor only', () => {+ const rtl = mount('rtl');+ const ltr = mount('ltr');+ expect(resolveSide('right', rtl)).toBe('left');+ expect(resolveSide('left-start', rtl)).toBe('right-start');+ expect(resolveSide('top-end', rtl)).toBe('top-end');+ expect(resolveSide('bottom', rtl)).toBe('bottom');+ expect(resolveSide('right', ltr)).toBe('right');+ expect(resolveSide('left-end', undefined)).toBe('left-end');+ });++ it('swaps horizontal arrow keys for an RTL element only', () => {+ const rtl = mount('rtl');+ const ltr = mount('ltr');+ expect(resolveArrowKey('ArrowRight', rtl)).toBe('ArrowLeft');+ expect(resolveArrowKey('ArrowLeft', rtl)).toBe('ArrowRight');+ expect(resolveArrowKey('ArrowUp', rtl)).toBe('ArrowUp');+ expect(resolveArrowKey('ArrowRight', ltr)).toBe('ArrowRight');+ });+});diff --git a/packages/client/src/utils/direction.ts b/packages/client/src/utils/direction.tsnew file mode 100644index 0000000000..9689ad587d--- /dev/null+++ b/packages/client/src/utils/direction.ts@@ -0,0 +1,39 @@+const OPPOSITE: Record<string, string> = { left: 'right', right: 'left' };++/** Reads the writing direction the browser resolved for the element itself (a `dir` attribute,+ * `dir="auto"`, or a CSS `direction` override), so an LTR island inside an RTL page (and the+ * reverse) resolves correctly instead of following the document. Without a computed value (a+ * non-rendering DOM such as jsdom) the nearest `dir` attribute decides. */+export function isRtl(element?: Element | null): boolean {+ if (!element || typeof window === 'undefined') {+ return false;+ }+ const computed = window.getComputedStyle(element).direction;+ if (computed === 'rtl' || computed === 'ltr') {+ return computed === 'rtl';+ }+ return element.closest('[dir]')?.getAttribute('dir') === 'rtl';+}++/** Maps a physical `left`/`right` side or placement (`right`, `left-start`) to the side that+ * is visually equivalent under RTL; `top`/`bottom` and LTR anchors pass through unchanged.+ * The `-start`/`-end` suffix is left alone: floating positioning already resolves it per direction. */+export function resolveSide<T extends string>(side: T, element?: Element | null): T {+ if (!isRtl(element)) {+ return side;+ }+ const [base, ...rest] = side.split('-');+ const opposite = OPPOSITE[base];+ return (opposite ? [opposite, ...rest].join('-') : side) as T;+}++/** Swaps ArrowLeft and ArrowRight for horizontal navigation when the element is RTL. */+export function resolveArrowKey(key: string, element?: Element | null): string {+ if (!isRtl(element)) {+ return key;+ }+ if (key === 'ArrowLeft') {+ return 'ArrowRight';+ }+ return key === 'ArrowRight' ? 'ArrowLeft' : key;+}diff --git a/packages/client/src/utils/index.ts b/packages/client/src/utils/index.tsindex ba8e0cbb60..657d5f459b 100644--- a/packages/client/src/utils/index.ts+++ b/packages/client/src/utils/index.ts@@ -4,3 +4,4 @@ export * from './composer';export * from './remScale';export * from './cloudfront';export { default as logger } from './logger';+export * from './direction';