LibreChat/packages/client/src/utils/composer.ts
Marco Beretta b2da59f08d 🚦 feat: Give Pressed and Disabled States Their Own Theme Roles (#16487)
* feat: Give Pressed and Disabled States Their Own Theme Roles

Add surface-pressed and surface-inverted-pressed, which IconButton takes
while held under a hover. They default to the hover fills a pointer
press has always shown, and a theme that names only its hovers presses
in them, so the default theme is unchanged.

Add surface-disabled, text-disabled and border-disabled, and a
disabledStyle appearance role: dim keeps the half-opacity treatment,
fill paints a disabled Checkbox, Switch, Field or IconButton in the
disabled roles through the theme-disabled variant. The root mirrors
the choice as data-theme-disabled. ClickHouse fills from Click UI's
disabled and active tokens, cited in the drift guard.

* fix: Ink Disabled Placeholders and Press the Submit Button in the State Roles

* fix: Ignore Color Roles a Client Predates and Fill Every Disabled Composer Slot

A cached client reading a newer server's inline theme rejected the
whole definition over one color role it did not know. The client
reader now ignores a well-formed rgb- role holding a triplet with a
warning, as it already did for appearance keys; the server keeps
rejecting unknown roles, where one is a typo in librechat.yaml.

The disabled fill moves into composerSubmitClasses, so the plain send
and stop buttons in Composer and DuringRunSendButton take it too.

* fix: Share One Disabled Fill Recipe Across Every Shared Control

Select, InputNumber, SecretInput, FilterInput and the Slider thumb only
dimmed under a fill theme. The theme-disabled classes now live in one
disabledFillClasses recipe that every shared control composes, and the
variant also matches Radix's data-disabled so a disabled slider thumb
takes the fill.

The deployment-theme scenario for an invalid theme now serves a
malformed color value, since a well-formed role the client predates is
ignored rather than rejected.

* fix: Fill a Disabled InputNumber Through Its Wrapper

rc-input-number puts the component's classes on a wrapper around the
disabled input, so the theme-disabled variant never matched it. Add a
theme-disabled-within variant for a wrapper that contains a disabled
control, and a disabledWithinFillClasses recipe InputNumber composes;
the input inherits the ink and shows the fill through its transparent
background. The default theme's disabled InputNumber is unchanged.

* fix: Carry the Disabled Roles to Every Shared Disabled Surface

Sweep every shared component that dims when disabled. Button-like
controls (AlertDialog and Dialog footer buttons, DialogTemplate's
select, the MultiSelect trigger) compose the fill recipe. Menu items,
tabs and the send-actions rows keep their surface and take the ink
through disabledInkClasses, as Click UI's genericMenu does, and Label
and FilterInput's floating label follow their control through
peerDisabledInkClasses. The variant also matches aria-disabled rows.
OGDialogTemplate and Button stay with the open PR that owns them.

* fix: Gray the Icons of Disabled Menu Rows Under a Fill Theme

A send-action or menu row's icon owns its color (text-status-warning,
text-text-secondary), so the inherited disabled ink left it bright.
The item ink recipe now recolors descendant icons too.

* fix: Fill the Dropdown Trigger and the OTP Group Under a Fill Theme

The default Dropdown trigger only dimmed, and its disabled:hover resets
tied with the fill; the shared recipe now pins the disabled hover fill
and ink too, and the trigger composes it. InputOTP dims its group with
has-[:disabled], so it takes the wrapper recipe.

* fix: Reach Child-Owned Ink and Slot Edges in the Disabled Recipes

A disabled control's own children, the SelectDropDown labels or a
checkbox glyph, kept their explicit ink, and a disabled OTP group's
slots kept their border. The fill and item recipes now carry the
disabled ink to descendants, the wrapper recipe carries the disabled
edge and ink to the group's parts, and SelectDropDown composes the fill
recipe.

* test: Probe Disabled Row Icons With the Recipe's Descendant Selector

* fix: Give Radio Segments, SecretInput Actions and DropdownPopup Items the Disabled Ink

These three dim their disabled state through a JS branch or Ariakit's
aria-disabled rather than a disabled: utility, so the earlier sweep
missed them. Each composes the item ink recipe, whose opacity reset
outranks the branch's opacity-50.

(cherry picked from commit 83d7afb0d1)

Original-PR: https://github.com/LibreChat-AI/LibreChat/pull/16487
2026-10-01 03:46:18 +00:00

62 lines
2.9 KiB
TypeScript

import { disabledFillClasses } from './theme';
import { cn } from './utils';
/**
* Shared composer-surface appearance: every input surface that should read as
* "the composer" (main chat form, subagent control footer) draws its border,
* background, and text colors from this one semantic decision. Layout, radius,
* padding, and feature-specific overrides stay with each owner.
*/
export const composerSurfaceClasses = (): string =>
cn('border border-border-light bg-surface-chat text-text-primary transition-all duration-200');
/** Elevation states for the composer surface. `within` is the CSS-only
* equivalent of the managed focused/blurred pair for surfaces that do not
* track focus in state. */
export const composerSurfaceShadow = {
focused: 'shadow-lg',
blurred: 'shadow-md',
within: 'shadow-md focus-within:shadow-lg',
} as const;
/**
* The composer's submit slot: send, stop, and the during-run send button that
* takes their place while a run generates. One recipe because all three swap
* into the same position and must be indistinguishable in everything but the
* icon they carry.
*
* Wherever touch is reachable it is the row's one 44px target. `size-theme-control` is
* 36px, which a thumb aimed at the bottom corner of a phone clips or misses
* outright, and below `sm` the composer surface runs to the viewport floor by
* design, so the target has to grow upward instead of gaining a band of padding
* beneath it. Centering is `flex` rather than the icon's fit inside
* `p-theme-compact`, which only held while the box was exactly icon-sized.
*/
export const composerSubmitClasses = (): string =>
cn(
'flex items-center justify-center',
'size-theme-control touch:size-theme-control-touch',
'rounded-theme-control-round bg-text-primary p-theme-compact text-text-primary',
'outline-offset-4 transition-all duration-theme-normal',
'disabled:cursor-not-allowed disabled:text-text-secondary disabled:opacity-10',
disabledFillClasses,
);
/**
* Shared appearance for a labeled control in the composer's action row — the
* capability checkboxes, the MCP selector, the code-approval selector. Border,
* radius, height, spacing and elevation are one decision here so a row of them
* reads as a single set of controls no matter which primitive each is built
* from. Width, responsive label collapsing and selected/open fills stay with
* each owner.
*/
export const composerControlClasses = (): string =>
cn(
'group relative inline-flex items-center justify-center gap-theme-compact',
'h-theme-control rounded-theme-control-round border border-border-medium',
'bg-transparent text-sm font-medium text-text-primary transition-all',
/** No elevation: a row of raised pills inside the composer competes with the
* composer itself. The edge stays, because a fill alone against the composer
* surface is under 1.2:1 and would leave the control with no visible boundary. */
'hover:bg-surface-hover',
);