mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +01:00
🛗 fix: Address Accessibility Issues - Axe Rating: Serious (#10521)
* feat: add light/dark differentiation on text color for login footer links for more accessible contrast in light mode * feat: add darker color focus ring on ThemeSelector in light mode for more accessible contrast * feat: increase contrast on text color for rendered error messages in light and dark mode so that they pass the 4.5:1 accessibility contrast threshold against their backgrounds * feat: add more accessible color vars to style.css for better contrast against light/dark backgrounds * feat: un-nest DropdownMenu from ListCard and make them siblings instead for better accessibility * feat: tweak --border-heavy in light mode so that it uses --gray-410 rather than --gray-400 so that the contrast ratio threshold is hit for accessibility * feat: switch email and password input border to border-heavy for more accessible contrast on Login page * fix: add proper focus ring for Action menu button in Prompts Sidenav * fix: align light and dark focus rings with surrounding elements on preview/edit menu dropdown button in Prompt Card * fix: remove aria-hidden on parent div with focusable child element according to accessibility guidelines * fix: add missing aria-readonly false property that should have been in previous accessibility PR * feat: add horizontal padding on rowRenderer's CellMeasurer div so that focus ring on rows doesnt clip behind virtualized table borders side-to-side (still need to figure out vertical clipping on final row / a better solution to be able to get overflows to work properly within the virtualized table) * feat: remove render prop override so that Share and Delete Buttons in Conversation dropdown can be pressed with Enter keystroke * fix: undo additional colors and changes to --surface-hover the initial changes came from a misunderstanding of contrast threshold requirements for hover effect accessibility * feat: better layout for non-nested prompt card / action menu combination * fix: add proper focus restoration behavior for Preview modal on close * fix: undo change to --border-heavy in light mode * fix: set borders for login input boxes back to light * feat: add announcement for state change when link copied to clipboard in conversation share modal * feat: add announcement to Refresh Link button * feat: add announcement for archiving chats * feat: make date sections in conversation history list <h2> rather than generic <div> for improved screen reader support * feat: ensure Share Link modal is accessible at high zoom percentage and low viewport width / height requirements by adding max height and overflow attributes to allow scrolling * feat: bold toast text so that it hits font size accessibility threshold (above 14 px when bolded - change makes text 16 px bold) so that the more disruptive contrast change of the toast background color is no longer necessary. The background color would need to achieve a 4.5:1 contrast ratio, which would significantly affect the established aesthetic of the current toast system if achieved. * fix: do not render side nav when it is hidden to avoid keyboard navigation with screen reader * fix: add side nav button state change announcements and don't render components that were previosuly reachable via keyboard navigation while in the side nav * feat: add tooltip anchor for Model Select * fix: only hide the model selector, export, and temp chat buttons when in mobile view and the sidenav is expanded * feat: add aria-haspopup support for MenuItems and add aria-haspopup: 'dialog' for Share and Delete buttons in ConvoOptions * feat: add label for DataTable search so that it does not rely on placeholder attribute for function identification * feat: make X buttons on dialogs 24x24px to achieve AA compliance * feat: add announcements for the search bar for model selector * feat: persistent label for DataTable * feat: make filter files text contrast compliant * feat: add non-color visual indicator to AudioRecorder listening state * feat: add aria-expanded attribute to tool call dropdown for screen reader * feat: add high contrast and rounded outlines for focus indicators on Run Code and Copy Code buttons for code blocks * fix: change Button to anchor tag in Shared Links component when linking to original conversation * fix: allow overflow in datatable cells so that focus indicators dont get cut off * feat: round out focus outline for link name in SharedLinks modal * feat: add aria-controls and aria-haspopup: "dialog" to SharedLinks delete button and modal * feat: add aria-controls for dropdown menu items on ConvoOptions for share and delete modals * feat: add trigger ref to 2FA button and modal in settings menu so focus returns to button on modal close * feat: add refs so that open sidebar and close sidebar buttons transfer focus to one another * chore: formatting * feat: make sure settings modal is accessible at 200% zoom for screen size 1366x768 viewport * feat: round out focus outline for link names in archived chats modal * feat: add result announcements for screen reader in DataTable search * feat: simplify layout for checkbox / api key components for better accessibility * feat: return focus to chat input on prompt variables modal close * feat: add persistent labels to TextareaAutosize Inputs in Variable form * feat: tighten max width so side scrolling not necessary at 400% zoom for VariableForm modal * feat: add persistent labels to prompt management page * feat: announce results found for search bars in prompts page and improve them in datatable * feat: de-nest DashGroupItem buttons in Prompts page to allow better navigation and comply with accessibility standard * feat: add heading for new prompt creation page for screen readers * feat: remove non-compliant description truncation for small screen sizes by making labels static on small enough viewport width * feat: add mobile view sidebar for prompts page * feat: add bolded text on select for AdvancedSwitch so that there is a visual indicator of selection and it does not rely solely on color as an indication of state * feat: add persistent labels to ModelSelector search inputs * feat: align aria-label with visual label for speech recognition users * feat: make MemoryCreateDialog accessible at 400% zoom (introduce max viewport height attr and make scrollable) * feat: add persistent label to Filter input for DataTable in file attach sidebar menu * feat: add persistent label for bookmark filter input in bookmarks sidebar menu * feat: add alert for screen readers for invalid inputs when editting bookmarks * feat: bold font in BookmarkForm error readout to pass contrast compliance thresholds for 14pt text * feat: align aria-label with visual label for BookmarkForm Ttile input * feat: add 400% zoom support for ALL modals utilizing OriginalDialog to prevent clipping * feat: remove state change on aria label and give consistent labelling for button, offload state change notification to the announcement div and make more assertive * feat: add aria-labels which convey that the buttons are sortable (divergence from visual text because iconography is used to signify sort functionality) * feat: add supplemental visuals to indicate link is clickable other than color in SharedLinks * feat: increase saturation to hit contrast threshold minimums on Link color in SharedLinks * feat: stop DataTable from disappearing at 400% zoom in SharedLinks * feat: increase contrast to hit contrast threshold minimums on Animated Search Input visual indicators * feat: add aria-label for AnimatedSearchInput (doesn't require explicit labelling because of Search icon) * fix: stop long example variable declaration from clipping at high zoom in variables info * feat: add aria-label to bettter describe sort button functionality for vision impaired users * chore: remove unused translation key * chore: address ESLint comments * fix: modify test to account for new alert on theme toggle switch for login page * chore: interpolate translation key
This commit is contained in:
parent
9786a7654e
commit
5ed1f2991e
62 changed files with 935 additions and 414 deletions
|
|
@ -568,6 +568,8 @@ export interface ModelItemProps {
|
||||||
export type ContextType = {
|
export type ContextType = {
|
||||||
navVisible: boolean;
|
navVisible: boolean;
|
||||||
setNavVisible: React.Dispatch<React.SetStateAction<boolean>>;
|
setNavVisible: React.Dispatch<React.SetStateAction<boolean>>;
|
||||||
|
openSidebarRef?: React.RefObject<HTMLButtonElement>;
|
||||||
|
closeSidebarRef?: React.RefObject<HTMLButtonElement>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface SwitcherProps {
|
export interface SwitcherProps {
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ function Footer({ startupConfig }: { startupConfig: TStartupConfig | null | unde
|
||||||
|
|
||||||
const privacyPolicyRender = privacyPolicy?.externalUrl && (
|
const privacyPolicyRender = privacyPolicy?.externalUrl && (
|
||||||
<a
|
<a
|
||||||
className="text-sm text-green-500"
|
className="text-sm text-green-600 dark:text-green-500"
|
||||||
href={privacyPolicy.externalUrl}
|
href={privacyPolicy.externalUrl}
|
||||||
target={privacyPolicy.openNewTab ? '_blank' : undefined}
|
target={privacyPolicy.openNewTab ? '_blank' : undefined}
|
||||||
rel="noreferrer"
|
rel="noreferrer"
|
||||||
|
|
@ -22,7 +22,7 @@ function Footer({ startupConfig }: { startupConfig: TStartupConfig | null | unde
|
||||||
|
|
||||||
const termsOfServiceRender = termsOfService?.externalUrl && (
|
const termsOfServiceRender = termsOfService?.externalUrl && (
|
||||||
<a
|
<a
|
||||||
className="text-sm text-green-500"
|
className="text-sm text-green-600 dark:text-green-500"
|
||||||
href={termsOfService.externalUrl}
|
href={termsOfService.externalUrl}
|
||||||
target={termsOfService.openNewTab ? '_blank' : undefined}
|
target={termsOfService.openNewTab ? '_blank' : undefined}
|
||||||
rel="noreferrer"
|
rel="noreferrer"
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ const LoginForm: React.FC<TLoginFormProps> = ({ onSubmit, startupConfig, error,
|
||||||
const renderError = (fieldName: string) => {
|
const renderError = (fieldName: string) => {
|
||||||
const errorMessage = errors[fieldName]?.message;
|
const errorMessage = errors[fieldName]?.message;
|
||||||
return errorMessage ? (
|
return errorMessage ? (
|
||||||
<span role="alert" className="mt-1 text-sm text-red-500 dark:text-red-900">
|
<span role="alert" className="mt-1 text-sm text-red-600 dark:text-red-500">
|
||||||
{String(errorMessage)}
|
{String(errorMessage)}
|
||||||
</span>
|
</span>
|
||||||
) : null;
|
) : null;
|
||||||
|
|
|
||||||
|
|
@ -191,12 +191,16 @@ test('shows validation error messages', async () => {
|
||||||
await userEvent.type(getByTestId('password'), 'pass');
|
await userEvent.type(getByTestId('password'), 'pass');
|
||||||
await userEvent.type(getByTestId('confirm_password'), 'password1');
|
await userEvent.type(getByTestId('confirm_password'), 'password1');
|
||||||
const alerts = getAllByRole('alert');
|
const alerts = getAllByRole('alert');
|
||||||
expect(alerts).toHaveLength(5);
|
expect(alerts).toHaveLength(6);
|
||||||
expect(alerts[0]).toHaveTextContent(/Name must be at least 3 characters/i);
|
|
||||||
expect(alerts[1]).toHaveTextContent(/Username must be at least 2 characters/i);
|
// This first alert is for the theme toggle, which is empty within this test but still picked up by getAllByRole as an alert
|
||||||
expect(alerts[2]).toHaveTextContent(/You must enter a valid email address/i);
|
expect(alerts[0]).toHaveTextContent('');
|
||||||
expect(alerts[3]).toHaveTextContent(/Password must be at least 8 characters/i);
|
|
||||||
expect(alerts[4]).toHaveTextContent(/Passwords do not match/i);
|
expect(alerts[1]).toHaveTextContent(/Name must be at least 3 characters/i);
|
||||||
|
expect(alerts[2]).toHaveTextContent(/Username must be at least 2 characters/i);
|
||||||
|
expect(alerts[3]).toHaveTextContent(/You must enter a valid email address/i);
|
||||||
|
expect(alerts[4]).toHaveTextContent(/Password must be at least 8 characters/i);
|
||||||
|
expect(alerts[5]).toHaveTextContent(/Passwords do not match/i);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('shows error message when registration fails', async () => {
|
test('shows error message when registration fails', async () => {
|
||||||
|
|
|
||||||
|
|
@ -100,9 +100,7 @@ const BookmarkForm = ({
|
||||||
<Input
|
<Input
|
||||||
type="text"
|
type="text"
|
||||||
id="bookmark-tag"
|
id="bookmark-tag"
|
||||||
aria-label={
|
aria-label={localize('com_ui_bookmarks_title')}
|
||||||
bookmark ? localize('com_ui_bookmarks_edit') : localize('com_ui_bookmarks_new')
|
|
||||||
}
|
|
||||||
{...register('tag', {
|
{...register('tag', {
|
||||||
required: localize('com_ui_field_required'),
|
required: localize('com_ui_field_required'),
|
||||||
maxLength: {
|
maxLength: {
|
||||||
|
|
@ -124,8 +122,13 @@ const BookmarkForm = ({
|
||||||
placeholder={
|
placeholder={
|
||||||
bookmark ? localize('com_ui_bookmarks_edit') : localize('com_ui_bookmarks_new')
|
bookmark ? localize('com_ui_bookmarks_edit') : localize('com_ui_bookmarks_new')
|
||||||
}
|
}
|
||||||
|
aria-describedby={errors.tag ? 'bookmark-tag-error' : undefined}
|
||||||
/>
|
/>
|
||||||
{errors.tag && <span className="text-sm text-red-500">{errors.tag.message}</span>}
|
{errors.tag && (
|
||||||
|
<span id="bookmark-tag-error" role="alert" className="text-sm font-bold text-red-500">
|
||||||
|
{errors.tag.message}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="mt-4 grid w-full items-center gap-2">
|
<div className="mt-4 grid w-full items-center gap-2">
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,8 @@ const defaultInterface = getConfigDefaults().interface;
|
||||||
|
|
||||||
export default function Header() {
|
export default function Header() {
|
||||||
const { data: startupConfig } = useGetStartupConfig();
|
const { data: startupConfig } = useGetStartupConfig();
|
||||||
const { navVisible, setNavVisible } = useOutletContext<ContextType>();
|
const { navVisible, setNavVisible, openSidebarRef, closeSidebarRef } =
|
||||||
|
useOutletContext<ContextType>();
|
||||||
|
|
||||||
const interfaceConfig = useMemo(
|
const interfaceConfig = useMemo(
|
||||||
() => startupConfig?.interface ?? defaultInterface,
|
() => startupConfig?.interface ?? defaultInterface,
|
||||||
|
|
@ -50,27 +51,38 @@ export default function Header() {
|
||||||
transition={{ duration: 0.2 }}
|
transition={{ duration: 0.2 }}
|
||||||
key="header-buttons"
|
key="header-buttons"
|
||||||
>
|
>
|
||||||
<OpenSidebar setNavVisible={setNavVisible} className="max-md:hidden" />
|
<OpenSidebar
|
||||||
|
ref={openSidebarRef}
|
||||||
|
setNavVisible={setNavVisible}
|
||||||
|
closeSidebarRef={closeSidebarRef}
|
||||||
|
className="max-md:hidden"
|
||||||
|
/>
|
||||||
<HeaderNewChat />
|
<HeaderNewChat />
|
||||||
</motion.div>
|
</motion.div>
|
||||||
)}
|
)}
|
||||||
</AnimatePresence>
|
</AnimatePresence>
|
||||||
|
{!isSmallScreen && !navVisible && (
|
||||||
<div className={navVisible ? 'flex items-center gap-2' : 'ml-2 flex items-center gap-2'}>
|
<div
|
||||||
<ModelSelector startupConfig={startupConfig} />
|
className={`flex items-center gap-2 ${
|
||||||
{interfaceConfig.presets === true && interfaceConfig.modelSelect && <PresetsMenu />}
|
!isSmallScreen ? 'transition-all duration-200 ease-in-out' : ''
|
||||||
{hasAccessToBookmarks === true && <BookmarkMenu />}
|
} `}
|
||||||
{hasAccessToMultiConvo === true && <AddMultiConvo />}
|
>
|
||||||
{isSmallScreen && (
|
<ModelSelector startupConfig={startupConfig} />
|
||||||
<>
|
{interfaceConfig.presets === true && interfaceConfig.modelSelect && <PresetsMenu />}
|
||||||
<ExportAndShareMenu
|
{hasAccessToBookmarks === true && <BookmarkMenu />}
|
||||||
isSharedButtonEnabled={startupConfig?.sharedLinksEnabled ?? false}
|
{hasAccessToMultiConvo === true && <AddMultiConvo />}
|
||||||
/>
|
{isSmallScreen && (
|
||||||
<TemporaryChat />
|
<>
|
||||||
</>
|
<ExportAndShareMenu
|
||||||
)}
|
isSharedButtonEnabled={startupConfig?.sharedLinksEnabled ?? false}
|
||||||
</div>
|
/>
|
||||||
|
<TemporaryChat />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{!isSmallScreen && (
|
{!isSmallScreen && (
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<ExportAndShareMenu
|
<ExportAndShareMenu
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { useCallback, useRef } from 'react';
|
import { useCallback, useRef } from 'react';
|
||||||
|
import { MicOff } from 'lucide-react';
|
||||||
import { useToastContext, TooltipAnchor, ListeningIcon, Spinner } from '@librechat/client';
|
import { useToastContext, TooltipAnchor, ListeningIcon, Spinner } from '@librechat/client';
|
||||||
import { useLocalize, useSpeechToText, useGetAudioSettings } from '~/hooks';
|
import { useLocalize, useSpeechToText, useGetAudioSettings } from '~/hooks';
|
||||||
import { useChatFormContext } from '~/Providers';
|
import { useChatFormContext } from '~/Providers';
|
||||||
|
|
@ -95,7 +96,7 @@ export default function AudioRecorder({
|
||||||
|
|
||||||
const renderIcon = () => {
|
const renderIcon = () => {
|
||||||
if (isListening === true) {
|
if (isListening === true) {
|
||||||
return <ListeningIcon className="stroke-red-500" />;
|
return <MicOff className="stroke-red-500" />;
|
||||||
}
|
}
|
||||||
if (isLoading === true) {
|
if (isLoading === true) {
|
||||||
return <Spinner className="stroke-text-secondary" />;
|
return <Spinner className="stroke-text-secondary" />;
|
||||||
|
|
|
||||||
|
|
@ -114,12 +114,18 @@ export default function DataTable<TData, TValue>({ columns, data }: DataTablePro
|
||||||
)}
|
)}
|
||||||
{!isSmallScreen && <span className="ml-2">{localize('com_ui_delete')}</span>}
|
{!isSmallScreen && <span className="ml-2">{localize('com_ui_delete')}</span>}
|
||||||
</Button>
|
</Button>
|
||||||
<Input
|
<div className="relative flex-1">
|
||||||
placeholder={localize('com_files_filter')}
|
<Input
|
||||||
value={(table.getColumn('filename')?.getFilterValue() as string | undefined) ?? ''}
|
placeholder=" "
|
||||||
onChange={(event) => table.getColumn('filename')?.setFilterValue(event.target.value)}
|
value={(table.getColumn('filename')?.getFilterValue() as string | undefined) ?? ''}
|
||||||
className="flex-1 text-sm"
|
onChange={(event) => table.getColumn('filename')?.setFilterValue(event.target.value)}
|
||||||
/>
|
className="peer w-full text-sm"
|
||||||
|
aria-label={localize('com_files_filter_input')}
|
||||||
|
/>
|
||||||
|
<label className="absolute left-2 top-1/2 -translate-y-1/2 text-sm text-text-primary transition-all duration-200 peer-focus:-top-2 peer-focus:text-xs peer-focus:text-text-primary peer-[:not(:placeholder-shown)]:-top-2 peer-[:not(:placeholder-shown)]:text-xs">
|
||||||
|
{localize('com_files_filter')}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
<Button
|
<Button
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,14 @@ const PopoverContainer = memo(
|
||||||
isVariableDialogOpen,
|
isVariableDialogOpen,
|
||||||
variableGroup,
|
variableGroup,
|
||||||
setVariableDialogOpen,
|
setVariableDialogOpen,
|
||||||
|
textAreaRef,
|
||||||
}: {
|
}: {
|
||||||
index: number;
|
index: number;
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
isVariableDialogOpen: boolean;
|
isVariableDialogOpen: boolean;
|
||||||
variableGroup: TPromptGroup | null;
|
variableGroup: TPromptGroup | null;
|
||||||
setVariableDialogOpen: (isOpen: boolean) => void;
|
setVariableDialogOpen: (isOpen: boolean) => void;
|
||||||
|
textAreaRef: React.MutableRefObject<HTMLTextAreaElement | null>;
|
||||||
}) => {
|
}) => {
|
||||||
const showPromptsPopover = useRecoilValue(store.showPromptsPopoverFamily(index));
|
const showPromptsPopover = useRecoilValue(store.showPromptsPopoverFamily(index));
|
||||||
return (
|
return (
|
||||||
|
|
@ -33,7 +35,12 @@ const PopoverContainer = memo(
|
||||||
{showPromptsPopover ? children : null}
|
{showPromptsPopover ? children : null}
|
||||||
<VariableDialog
|
<VariableDialog
|
||||||
open={isVariableDialogOpen}
|
open={isVariableDialogOpen}
|
||||||
onClose={() => setVariableDialogOpen(false)}
|
onClose={() => {
|
||||||
|
setVariableDialogOpen(false);
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
textAreaRef.current?.focus();
|
||||||
|
});
|
||||||
|
}}
|
||||||
group={variableGroup}
|
group={variableGroup}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
|
|
@ -167,6 +174,7 @@ function PromptsCommand({
|
||||||
isVariableDialogOpen={isVariableDialogOpen}
|
isVariableDialogOpen={isVariableDialogOpen}
|
||||||
variableGroup={variableGroup}
|
variableGroup={variableGroup}
|
||||||
setVariableDialogOpen={setVariableDialogOpen}
|
setVariableDialogOpen={setVariableDialogOpen}
|
||||||
|
textAreaRef={textAreaRef}
|
||||||
>
|
>
|
||||||
<div className="absolute bottom-28 z-10 w-full space-y-2">
|
<div className="absolute bottom-28 z-10 w-full space-y-2">
|
||||||
<div className="popover border-token-border-light rounded-2xl border bg-surface-tertiary-alt p-2 shadow-lg">
|
<div className="popover border-token-border-light rounded-2xl border bg-surface-tertiary-alt p-2 shadow-lg">
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ export interface CustomMenuProps extends Ariakit.MenuButtonProps<'div'> {
|
||||||
searchValue?: string;
|
searchValue?: string;
|
||||||
onSearch?: (value: string) => void;
|
onSearch?: (value: string) => void;
|
||||||
combobox?: Ariakit.ComboboxProps['render'];
|
combobox?: Ariakit.ComboboxProps['render'];
|
||||||
|
comboboxLabel?: string;
|
||||||
trigger?: Ariakit.MenuButtonProps['render'];
|
trigger?: Ariakit.MenuButtonProps['render'];
|
||||||
defaultOpen?: boolean;
|
defaultOpen?: boolean;
|
||||||
}
|
}
|
||||||
|
|
@ -22,6 +23,7 @@ export const CustomMenu = React.forwardRef<HTMLDivElement, CustomMenuProps>(func
|
||||||
searchValue,
|
searchValue,
|
||||||
onSearch,
|
onSearch,
|
||||||
combobox,
|
combobox,
|
||||||
|
comboboxLabel,
|
||||||
trigger,
|
trigger,
|
||||||
defaultOpen,
|
defaultOpen,
|
||||||
...props
|
...props
|
||||||
|
|
@ -73,15 +75,22 @@ export const CustomMenu = React.forwardRef<HTMLDivElement, CustomMenuProps>(func
|
||||||
{searchable ? (
|
{searchable ? (
|
||||||
<>
|
<>
|
||||||
<div className="sticky top-0 z-10 bg-inherit p-1">
|
<div className="sticky top-0 z-10 bg-inherit p-1">
|
||||||
<Ariakit.Combobox
|
<div className="relative">
|
||||||
autoSelect
|
<Ariakit.Combobox
|
||||||
render={combobox}
|
autoSelect
|
||||||
className={cn(
|
render={combobox}
|
||||||
'h-10 w-full rounded-lg border-none bg-transparent px-2 text-base',
|
className={cn(
|
||||||
'sm:h-8 sm:text-sm',
|
'peer mt-1 h-10 w-full rounded-lg border-none bg-transparent px-2 text-base',
|
||||||
'focus:outline-none focus:ring-0 focus-visible:ring-2 focus-visible:ring-white',
|
'sm:h-8 sm:text-sm',
|
||||||
|
'focus:outline-none focus:ring-0 focus-visible:ring-2 focus-visible:ring-white',
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
{comboboxLabel && (
|
||||||
|
<label className="pointer-events-none absolute left-2.5 top-2.5 text-sm text-text-secondary transition-all duration-200 peer-[:not(:placeholder-shown)]:-top-1.5 peer-[:not(:placeholder-shown)]:left-1.5 peer-[:not(:placeholder-shown)]:bg-surface-secondary peer-[:not(:placeholder-shown)]:text-xs">
|
||||||
|
{comboboxLabel}
|
||||||
|
</label>
|
||||||
)}
|
)}
|
||||||
/>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Ariakit.ComboboxList className="p-0.5 pt-0">{children}</Ariakit.ComboboxList>
|
<Ariakit.ComboboxList className="p-0.5 pt-0">{children}</Ariakit.ComboboxList>
|
||||||
</>
|
</>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import React, { useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
|
import { TooltipAnchor } from '@librechat/client';
|
||||||
import type { ModelSelectorProps } from '~/common';
|
import type { ModelSelectorProps } from '~/common';
|
||||||
import { ModelSelectorProvider, useModelSelectorContext } from './ModelSelectorContext';
|
import { ModelSelectorProvider, useModelSelectorContext } from './ModelSelectorContext';
|
||||||
import { ModelSelectorChatProvider } from './ModelSelectorChatContext';
|
import { ModelSelectorChatProvider } from './ModelSelectorChatContext';
|
||||||
|
|
@ -59,17 +60,23 @@ function ModelSelectorContent() {
|
||||||
);
|
);
|
||||||
|
|
||||||
const trigger = (
|
const trigger = (
|
||||||
<button
|
<TooltipAnchor
|
||||||
className="my-1 flex h-10 w-full max-w-[70vw] items-center justify-center gap-2 rounded-xl border border-border-light bg-surface-secondary px-3 py-2 text-sm text-text-primary hover:bg-surface-tertiary"
|
|
||||||
aria-label={localize('com_ui_select_model')}
|
aria-label={localize('com_ui_select_model')}
|
||||||
>
|
description={localize('com_ui_select_model')}
|
||||||
{selectedIcon && React.isValidElement(selectedIcon) && (
|
render={
|
||||||
<div className="flex flex-shrink-0 items-center justify-center overflow-hidden">
|
<button
|
||||||
{selectedIcon}
|
className="my-1 flex h-10 w-full max-w-[70vw] items-center justify-center gap-2 rounded-xl border border-border-light bg-surface-secondary px-3 py-2 text-sm text-text-primary hover:bg-surface-tertiary"
|
||||||
</div>
|
aria-label={localize('com_ui_select_model')}
|
||||||
)}
|
>
|
||||||
<span className="flex-grow truncate text-left">{selectedDisplayValue}</span>
|
{selectedIcon && React.isValidElement(selectedIcon) && (
|
||||||
</button>
|
<div className="flex flex-shrink-0 items-center justify-center overflow-hidden">
|
||||||
|
{selectedIcon}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<span className="flex-grow truncate text-left">{selectedDisplayValue}</span>
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -84,7 +91,8 @@ function ModelSelectorContent() {
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
onSearch={(value) => setSearchValue(value)}
|
onSearch={(value) => setSearchValue(value)}
|
||||||
combobox={<input placeholder={localize('com_endpoint_search_models')} />}
|
combobox={<input id="model-search" placeholder=" " />}
|
||||||
|
comboboxLabel={localize('com_endpoint_search_models')}
|
||||||
trigger={trigger}
|
trigger={trigger}
|
||||||
>
|
>
|
||||||
{searchResults ? (
|
{searchResults ? (
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,8 @@ export function EndpointItem({ endpoint }: EndpointItemProps) {
|
||||||
defaultOpen={endpoint.value === selectedEndpoint}
|
defaultOpen={endpoint.value === selectedEndpoint}
|
||||||
searchValue={searchValue}
|
searchValue={searchValue}
|
||||||
onSearch={(value) => setEndpointSearchValue(endpoint.value, value)}
|
onSearch={(value) => setEndpointSearchValue(endpoint.value, value)}
|
||||||
combobox={<input placeholder={placeholder} />}
|
combobox={<input placeholder=" " />}
|
||||||
|
comboboxLabel={placeholder}
|
||||||
label={
|
label={
|
||||||
<div
|
<div
|
||||||
onClick={() => handleSelectEndpoint(endpoint)}
|
onClick={() => handleSelectEndpoint(endpoint)}
|
||||||
|
|
|
||||||
|
|
@ -34,14 +34,24 @@ export function SearchResults({ results, localize, searchValue }: SearchResultsP
|
||||||
}
|
}
|
||||||
if (!results.length) {
|
if (!results.length) {
|
||||||
return (
|
return (
|
||||||
<div className="cursor-default p-2 sm:py-1 sm:text-sm">
|
<>
|
||||||
{localize('com_files_no_results')}
|
<div role="alert" aria-live="polite" className="sr-only">
|
||||||
</div>
|
{localize('com_files_no_results')}
|
||||||
|
</div>
|
||||||
|
<div className="cursor-default p-2 sm:py-1 sm:text-sm">
|
||||||
|
{localize('com_files_no_results')}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
<div role="alert" aria-live="polite" className="sr-only">
|
||||||
|
{results.length === 1
|
||||||
|
? localize('com_files_result_found', { count: results.length })
|
||||||
|
: localize('com_files_results_found', { count: results.length })}
|
||||||
|
</div>
|
||||||
{results.map((item, i) => {
|
{results.map((item, i) => {
|
||||||
if ('name' in item && 'label' in item) {
|
if ('name' in item && 'label' in item) {
|
||||||
// Render model spec
|
// Render model spec
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,53 @@
|
||||||
|
import { forwardRef } from 'react';
|
||||||
import { TooltipAnchor, Button, Sidebar } from '@librechat/client';
|
import { TooltipAnchor, Button, Sidebar } from '@librechat/client';
|
||||||
import { useLocalize } from '~/hooks';
|
import { useLocalize } from '~/hooks';
|
||||||
import { cn } from '~/utils';
|
import { cn } from '~/utils';
|
||||||
|
|
||||||
export default function OpenSidebar({
|
const OpenSidebar = forwardRef<
|
||||||
setNavVisible,
|
HTMLButtonElement,
|
||||||
className,
|
{
|
||||||
}: {
|
setNavVisible: React.Dispatch<React.SetStateAction<boolean>>;
|
||||||
setNavVisible: React.Dispatch<React.SetStateAction<boolean>>;
|
className?: string;
|
||||||
className?: string;
|
closeSidebarRef?: React.RefObject<HTMLButtonElement>;
|
||||||
}) {
|
}
|
||||||
|
>(({ setNavVisible, className, closeSidebarRef }, ref) => {
|
||||||
const localize = useLocalize();
|
const localize = useLocalize();
|
||||||
|
|
||||||
|
const handleClick = () => {
|
||||||
|
setNavVisible((prev) => {
|
||||||
|
localStorage.setItem('navVisible', JSON.stringify(!prev));
|
||||||
|
return !prev;
|
||||||
|
});
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
closeSidebarRef?.current?.focus();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TooltipAnchor
|
<TooltipAnchor
|
||||||
description={localize('com_nav_open_sidebar')}
|
description={localize('com_nav_open_sidebar')}
|
||||||
render={
|
render={
|
||||||
<Button
|
<Button
|
||||||
|
ref={ref}
|
||||||
size="icon"
|
size="icon"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
data-testid="open-sidebar-button"
|
data-testid="open-sidebar-button"
|
||||||
aria-label={localize('com_nav_open_sidebar')}
|
aria-label={localize('com_nav_open_sidebar')}
|
||||||
|
aria-expanded={false}
|
||||||
|
aria-controls="chat-history-nav"
|
||||||
className={cn(
|
className={cn(
|
||||||
'rounded-xl border border-border-light bg-surface-secondary p-2 hover:bg-surface-hover',
|
'rounded-xl border border-border-light bg-surface-secondary p-2 hover:bg-surface-hover',
|
||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
onClick={() =>
|
onClick={handleClick}
|
||||||
setNavVisible((prev) => {
|
|
||||||
localStorage.setItem('navVisible', JSON.stringify(!prev));
|
|
||||||
return !prev;
|
|
||||||
})
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<Sidebar aria-hidden="true" />
|
<Sidebar aria-hidden="true" />
|
||||||
</Button>
|
</Button>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
});
|
||||||
|
|
||||||
|
OpenSidebar.displayName = 'OpenSidebar';
|
||||||
|
|
||||||
|
export default OpenSidebar;
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,7 @@ export default function ProgressText({
|
||||||
)}
|
)}
|
||||||
disabled={!hasInput}
|
disabled={!hasInput}
|
||||||
onClick={hasInput ? onClick : undefined}
|
onClick={hasInput ? onClick : undefined}
|
||||||
|
aria-expanded={hasInput ? isExpanded : undefined}
|
||||||
>
|
>
|
||||||
{icon}
|
{icon}
|
||||||
<span className={showShimmer ? 'shimmer' : ''}>{text}</span>
|
<span className={showShimmer ? 'shimmer' : ''}>{text}</span>
|
||||||
|
|
|
||||||
|
|
@ -33,9 +33,9 @@ LoadingSpinner.displayName = 'LoadingSpinner';
|
||||||
const DateLabel: FC<{ groupName: string }> = memo(({ groupName }) => {
|
const DateLabel: FC<{ groupName: string }> = memo(({ groupName }) => {
|
||||||
const localize = useLocalize();
|
const localize = useLocalize();
|
||||||
return (
|
return (
|
||||||
<div className="mt-2 pl-2 pt-1 text-text-secondary" style={{ fontSize: '0.7rem' }}>
|
<h2 className="mt-2 pl-2 pt-1 text-text-secondary" style={{ fontSize: '0.7rem' }}>
|
||||||
{localize(groupName as TranslationKeys) || groupName}
|
{localize(groupName as TranslationKeys) || groupName}
|
||||||
</div>
|
</h2>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -150,7 +150,7 @@ const Conversations: FC<ConversationsProps> = ({
|
||||||
return (
|
return (
|
||||||
<CellMeasurer cache={cache} columnIndex={0} key={key} parent={parent} rowIndex={index}>
|
<CellMeasurer cache={cache} columnIndex={0} key={key} parent={parent} rowIndex={index}>
|
||||||
{({ registerChild }) => (
|
{({ registerChild }) => (
|
||||||
<div ref={registerChild} style={style}>
|
<div ref={registerChild} style={style} className="px-2">
|
||||||
{rendering}
|
{rendering}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
@ -199,6 +199,7 @@ const Conversations: FC<ConversationsProps> = ({
|
||||||
rowHeight={getRowHeight}
|
rowHeight={getRowHeight}
|
||||||
rowRenderer={rowRenderer}
|
rowRenderer={rowRenderer}
|
||||||
overscanRowCount={10}
|
overscanRowCount={10}
|
||||||
|
aria-readonly={false}
|
||||||
className="outline-none"
|
className="outline-none"
|
||||||
style={{ outline: 'none' }}
|
style={{ outline: 'none' }}
|
||||||
aria-label="Conversations"
|
aria-label="Conversations"
|
||||||
|
|
|
||||||
|
|
@ -191,7 +191,9 @@ export default function Conversation({ conversation, retainView, toggleNav }: Co
|
||||||
? 'pointer-events-auto max-w-[28px] scale-x-100 opacity-100'
|
? 'pointer-events-auto max-w-[28px] scale-x-100 opacity-100'
|
||||||
: 'pointer-events-none max-w-0 scale-x-0 opacity-0 group-focus-within:pointer-events-auto group-focus-within:max-w-[28px] group-focus-within:scale-x-100 group-focus-within:opacity-100 group-hover:pointer-events-auto group-hover:max-w-[28px] group-hover:scale-x-100 group-hover:opacity-100',
|
: 'pointer-events-none max-w-0 scale-x-0 opacity-0 group-focus-within:pointer-events-auto group-focus-within:max-w-[28px] group-focus-within:scale-x-100 group-focus-within:opacity-100 group-hover:pointer-events-auto group-hover:max-w-[28px] group-hover:scale-x-100 group-hover:opacity-100',
|
||||||
)}
|
)}
|
||||||
aria-hidden={!(isPopoverActive || isActiveConvo)}
|
// Removing aria-hidden to fix accessibility issue: ARIA hidden element must not be focusable or contain focusable elements
|
||||||
|
// but not sure what its original purpose was, so leaving the property commented out until it can be cleared safe to delete.
|
||||||
|
// aria-hidden={!(isPopoverActive || isActiveConvo)}
|
||||||
>
|
>
|
||||||
{!renaming && <ConvoOptions {...convoOptionsProps} />}
|
{!renaming && <ConvoOptions {...convoOptionsProps} />}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ function ConvoOptions({
|
||||||
const deleteButtonRef = useRef<HTMLButtonElement>(null);
|
const deleteButtonRef = useRef<HTMLButtonElement>(null);
|
||||||
const [showShareDialog, setShowShareDialog] = useState(false);
|
const [showShareDialog, setShowShareDialog] = useState(false);
|
||||||
const [showDeleteDialog, setShowDeleteDialog] = useState(false);
|
const [showDeleteDialog, setShowDeleteDialog] = useState(false);
|
||||||
|
const [announcement, setAnnouncement] = useState('');
|
||||||
|
|
||||||
const archiveConvoMutation = useArchiveConvoMutation();
|
const archiveConvoMutation = useArchiveConvoMutation();
|
||||||
|
|
||||||
|
|
@ -94,6 +95,10 @@ function ConvoOptions({
|
||||||
{ conversationId: convoId, isArchived: true },
|
{ conversationId: convoId, isArchived: true },
|
||||||
{
|
{
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
|
setAnnouncement(localize('com_ui_convo_archived'));
|
||||||
|
setTimeout(() => {
|
||||||
|
setAnnouncement('');
|
||||||
|
}, 10000);
|
||||||
if (currentConvoId === convoId || currentConvoId === 'new') {
|
if (currentConvoId === convoId || currentConvoId === 'new') {
|
||||||
newConversation();
|
newConversation();
|
||||||
navigate('/c/new', { replace: true });
|
navigate('/c/new', { replace: true });
|
||||||
|
|
@ -137,7 +142,8 @@ function ConvoOptions({
|
||||||
show: startupConfig && startupConfig.sharedLinksEnabled,
|
show: startupConfig && startupConfig.sharedLinksEnabled,
|
||||||
hideOnClick: false,
|
hideOnClick: false,
|
||||||
ref: shareButtonRef,
|
ref: shareButtonRef,
|
||||||
render: (props) => <button {...props} />,
|
ariaHasPopup: 'dialog' as const,
|
||||||
|
ariaControls: 'share-conversation-dialog',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: localize('com_ui_rename'),
|
label: localize('com_ui_rename'),
|
||||||
|
|
@ -170,7 +176,8 @@ function ConvoOptions({
|
||||||
icon: <Trash className="icon-sm mr-2 text-text-primary" />,
|
icon: <Trash className="icon-sm mr-2 text-text-primary" />,
|
||||||
hideOnClick: false,
|
hideOnClick: false,
|
||||||
ref: deleteButtonRef,
|
ref: deleteButtonRef,
|
||||||
render: (props) => <button {...props} />,
|
ariaHasPopup: 'dialog' as const,
|
||||||
|
ariaControls: 'delete-conversation-dialog',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
|
@ -190,6 +197,9 @@ function ConvoOptions({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
<span className="sr-only" aria-live="polite" aria-atomic="true">
|
||||||
|
{announcement}
|
||||||
|
</span>
|
||||||
<DropdownPopup
|
<DropdownPopup
|
||||||
portal={true}
|
portal={true}
|
||||||
mountByState={true}
|
mountByState={true}
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ export function DeleteConversationDialog({
|
||||||
<OGDialogHeader>
|
<OGDialogHeader>
|
||||||
<OGDialogTitle>{localize('com_ui_delete_conversation')}</OGDialogTitle>
|
<OGDialogTitle>{localize('com_ui_delete_conversation')}</OGDialogTitle>
|
||||||
</OGDialogHeader>
|
</OGDialogHeader>
|
||||||
<div className="w-full truncate">
|
<div id="delete-conversation-dialog" className="w-full truncate">
|
||||||
<Trans
|
<Trans
|
||||||
i18nKey="com_ui_delete_confirm_strong"
|
i18nKey="com_ui_delete_confirm_strong"
|
||||||
values={{ item: title }}
|
values={{ item: title }}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,15 @@ export default function ShareButton({
|
||||||
const [showQR, setShowQR] = useState(false);
|
const [showQR, setShowQR] = useState(false);
|
||||||
const [sharedLink, setSharedLink] = useState('');
|
const [sharedLink, setSharedLink] = useState('');
|
||||||
const [isCopying, setIsCopying] = useState(false);
|
const [isCopying, setIsCopying] = useState(false);
|
||||||
|
const [announcement, setAnnouncement] = useState('');
|
||||||
const copyLink = useCopyToClipboard({ text: sharedLink });
|
const copyLink = useCopyToClipboard({ text: sharedLink });
|
||||||
|
const copyLinkAndAnnounce = (setIsCopying: React.Dispatch<React.SetStateAction<boolean>>) => {
|
||||||
|
setAnnouncement(localize('com_ui_link_copied'));
|
||||||
|
copyLink(setIsCopying);
|
||||||
|
setTimeout(() => {
|
||||||
|
setAnnouncement('');
|
||||||
|
}, 1000);
|
||||||
|
};
|
||||||
const latestMessage = useRecoilValue(store.latestMessageFamily(0));
|
const latestMessage = useRecoilValue(store.latestMessageFamily(0));
|
||||||
const { data: share, isLoading } = useGetSharedLinkQuery(conversationId);
|
const { data: share, isLoading } = useGetSharedLinkQuery(conversationId);
|
||||||
|
|
||||||
|
|
@ -60,9 +68,9 @@ export default function ShareButton({
|
||||||
showCloseButton={true}
|
showCloseButton={true}
|
||||||
showCancelButton={false}
|
showCancelButton={false}
|
||||||
title={localize('com_ui_share_link_to_chat')}
|
title={localize('com_ui_share_link_to_chat')}
|
||||||
className="max-w-[550px]"
|
className="max-h-[90vh] max-w-[550px] overflow-y-auto"
|
||||||
main={
|
main={
|
||||||
<div>
|
<div id="share-conversation-dialog">
|
||||||
<div className="h-full py-2 text-text-primary">
|
<div className="h-full py-2 text-text-primary">
|
||||||
{(() => {
|
{(() => {
|
||||||
if (isLoading === true) {
|
if (isLoading === true) {
|
||||||
|
|
@ -74,7 +82,7 @@ export default function ShareButton({
|
||||||
: localize('com_ui_share_create_message');
|
: localize('com_ui_share_create_message');
|
||||||
})()}
|
})()}
|
||||||
</div>
|
</div>
|
||||||
<div className="relative items-center rounded-lg p-2">
|
<div className="relative items-center overflow-auto rounded-lg p-2">
|
||||||
{showQR && (
|
{showQR && (
|
||||||
<div className="mb-4 flex flex-col items-center">
|
<div className="mb-4 flex flex-col items-center">
|
||||||
<QRCodeSVG
|
<QRCodeSVG
|
||||||
|
|
@ -90,6 +98,9 @@ export default function ShareButton({
|
||||||
{shareId && (
|
{shareId && (
|
||||||
<div className="flex items-center gap-2 rounded-md bg-surface-secondary p-2">
|
<div className="flex items-center gap-2 rounded-md bg-surface-secondary p-2">
|
||||||
<div className="flex-1 break-all text-sm text-text-secondary">{sharedLink}</div>
|
<div className="flex-1 break-all text-sm text-text-secondary">{sharedLink}</div>
|
||||||
|
<span className="sr-only" aria-live="polite" aria-atomic="true">
|
||||||
|
{announcement}
|
||||||
|
</span>
|
||||||
<Button
|
<Button
|
||||||
size="sm"
|
size="sm"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
|
|
@ -98,7 +109,7 @@ export default function ShareButton({
|
||||||
if (isCopying) {
|
if (isCopying) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
copyLink(setIsCopying);
|
copyLinkAndAnnounce(setIsCopying);
|
||||||
}}
|
}}
|
||||||
className={cn('shrink-0', isCopying ? 'cursor-default' : '')}
|
className={cn('shrink-0', isCopying ? 'cursor-default' : '')}
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ export default function SharedLinkButton({
|
||||||
const localize = useLocalize();
|
const localize = useLocalize();
|
||||||
const { showToast } = useToastContext();
|
const { showToast } = useToastContext();
|
||||||
const [showDeleteDialog, setShowDeleteDialog] = useState(false);
|
const [showDeleteDialog, setShowDeleteDialog] = useState(false);
|
||||||
|
const [announcement, setAnnouncement] = useState('');
|
||||||
const shareId = share?.shareId ?? '';
|
const shareId = share?.shareId ?? '';
|
||||||
|
|
||||||
const { mutateAsync: mutate, isLoading: isCreateLoading } = useCreateSharedLinkMutation({
|
const { mutateAsync: mutate, isLoading: isCreateLoading } = useCreateSharedLinkMutation({
|
||||||
|
|
@ -85,6 +86,10 @@ export default function SharedLinkButton({
|
||||||
const updateShare = await mutateAsync({ shareId });
|
const updateShare = await mutateAsync({ shareId });
|
||||||
const newLink = generateShareLink(updateShare.shareId);
|
const newLink = generateShareLink(updateShare.shareId);
|
||||||
setSharedLink(newLink);
|
setSharedLink(newLink);
|
||||||
|
setAnnouncement(localize('com_ui_link_refreshed'));
|
||||||
|
setTimeout(() => {
|
||||||
|
setAnnouncement('');
|
||||||
|
}, 1000);
|
||||||
};
|
};
|
||||||
|
|
||||||
const createShareLink = async () => {
|
const createShareLink = async () => {
|
||||||
|
|
@ -129,19 +134,24 @@ export default function SharedLinkButton({
|
||||||
<TooltipAnchor
|
<TooltipAnchor
|
||||||
description={localize('com_ui_refresh_link')}
|
description={localize('com_ui_refresh_link')}
|
||||||
render={(props) => (
|
render={(props) => (
|
||||||
<Button
|
<>
|
||||||
{...props}
|
<span className="sr-only" aria-live="polite" aria-atomic="true">
|
||||||
onClick={() => updateSharedLink()}
|
{announcement}
|
||||||
aria-label={localize('com_ui_refresh_link')}
|
</span>
|
||||||
variant="outline"
|
<Button
|
||||||
disabled={isUpdateLoading}
|
{...props}
|
||||||
>
|
onClick={() => updateSharedLink()}
|
||||||
{isUpdateLoading ? (
|
variant="outline"
|
||||||
<Spinner className="size-4" />
|
disabled={isUpdateLoading}
|
||||||
) : (
|
aria-label={localize('com_ui_refresh_link')}
|
||||||
<RotateCw className="size-4" />
|
>
|
||||||
)}
|
{isUpdateLoading ? (
|
||||||
</Button>
|
<Spinner className="size-4" />
|
||||||
|
) : (
|
||||||
|
<RotateCw className="size-4" />
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ const CodeBar: React.FC<CodeBarProps> = React.memo(
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className={cn(
|
className={cn(
|
||||||
'ml-auto flex gap-2',
|
'ml-auto flex gap-2 rounded-sm focus:outline focus:outline-white',
|
||||||
error === true ? 'h-4 w-4 items-start text-white/50' : '',
|
error === true ? 'h-4 w-4 items-start text-white/50' : '',
|
||||||
)}
|
)}
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ const RunCode: React.FC<CodeBarProps> = React.memo(({ lang, codeRef, blockIndex
|
||||||
<>
|
<>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className={cn('ml-auto flex gap-2')}
|
className={cn('ml-auto flex gap-2 rounded-sm focus:outline focus:outline-white')}
|
||||||
onClick={debouncedExecute}
|
onClick={debouncedExecute}
|
||||||
disabled={execute.isLoading}
|
disabled={execute.isLoading}
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@ import { clearMessagesCache } from '~/utils';
|
||||||
import store from '~/store';
|
import store from '~/store';
|
||||||
|
|
||||||
export default function MobileNav({
|
export default function MobileNav({
|
||||||
navVisible,
|
|
||||||
setNavVisible,
|
setNavVisible,
|
||||||
|
navVisible,
|
||||||
}: {
|
}: {
|
||||||
navVisible: boolean;
|
navVisible: boolean;
|
||||||
setNavVisible: Dispatch<SetStateAction<boolean>>;
|
setNavVisible: Dispatch<SetStateAction<boolean>>;
|
||||||
|
|
@ -25,8 +25,11 @@ export default function MobileNav({
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
data-testid="mobile-header-new-chat-button"
|
data-testid="mobile-header-new-chat-button"
|
||||||
aria-label={localize('com_nav_open_sidebar')}
|
aria-label={
|
||||||
className={`m-1 inline-flex size-10 items-center justify-center rounded-full hover:bg-surface-hover ${navVisible ? 'invisible' : ''}`}
|
navVisible ? localize('com_nav_close_sidebar') : localize('com_nav_open_sidebar')
|
||||||
|
}
|
||||||
|
aria-live="polite"
|
||||||
|
className="m-1 inline-flex size-10 items-center justify-center rounded-full hover:bg-surface-hover"
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
setNavVisible((prev) => {
|
setNavVisible((prev) => {
|
||||||
localStorage.setItem('navVisible', JSON.stringify(!prev));
|
localStorage.setItem('navVisible', JSON.stringify(!prev));
|
||||||
|
|
@ -34,7 +37,9 @@ export default function MobileNav({
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<span className="sr-only">{localize('com_nav_open_sidebar')}</span>
|
<span className="sr-only">
|
||||||
|
{navVisible ? localize('com_nav_close_sidebar') : localize('com_nav_open_sidebar')}
|
||||||
|
</span>
|
||||||
<svg
|
<svg
|
||||||
width="24"
|
width="24"
|
||||||
height="24"
|
height="24"
|
||||||
|
|
|
||||||
|
|
@ -50,9 +50,13 @@ const Nav = memo(
|
||||||
({
|
({
|
||||||
navVisible,
|
navVisible,
|
||||||
setNavVisible,
|
setNavVisible,
|
||||||
|
openSidebarRef,
|
||||||
|
closeSidebarRef,
|
||||||
}: {
|
}: {
|
||||||
navVisible: boolean;
|
navVisible: boolean;
|
||||||
setNavVisible: React.Dispatch<React.SetStateAction<boolean>>;
|
setNavVisible: React.Dispatch<React.SetStateAction<boolean>>;
|
||||||
|
openSidebarRef?: React.RefObject<HTMLButtonElement>;
|
||||||
|
closeSidebarRef?: React.RefObject<HTMLButtonElement>;
|
||||||
}) => {
|
}) => {
|
||||||
const localize = useLocalize();
|
const localize = useLocalize();
|
||||||
const { isAuthenticated } = useAuthContext();
|
const { isAuthenticated } = useAuthContext();
|
||||||
|
|
@ -207,32 +211,36 @@ const Nav = memo(
|
||||||
>
|
>
|
||||||
<div className="h-full w-[320px] md:w-[260px]">
|
<div className="h-full w-[320px] md:w-[260px]">
|
||||||
<div className="flex h-full flex-col">
|
<div className="flex h-full flex-col">
|
||||||
<nav
|
{navVisible && (
|
||||||
id="chat-history-nav"
|
<nav
|
||||||
aria-label={localize('com_ui_chat_history')}
|
id="chat-history-nav"
|
||||||
className="flex h-full flex-col px-2 pb-3.5 md:px-3"
|
aria-label={localize('com_ui_chat_history')}
|
||||||
>
|
className="flex h-full flex-col px-2 pb-3.5 md:px-3"
|
||||||
<div className="flex flex-1 flex-col" ref={outerContainerRef}>
|
>
|
||||||
<MemoNewChat
|
<div className="flex flex-1 flex-col" ref={outerContainerRef}>
|
||||||
subHeaders={subHeaders}
|
<MemoNewChat
|
||||||
toggleNav={toggleNavVisible}
|
subHeaders={subHeaders}
|
||||||
headerButtons={headerButtons}
|
toggleNav={toggleNavVisible}
|
||||||
isSmallScreen={isSmallScreen}
|
headerButtons={headerButtons}
|
||||||
/>
|
isSmallScreen={isSmallScreen}
|
||||||
<Conversations
|
openSidebarRef={openSidebarRef}
|
||||||
conversations={conversations}
|
closeSidebarRef={closeSidebarRef}
|
||||||
moveToTop={moveToTop}
|
/>
|
||||||
toggleNav={itemToggleNav}
|
<Conversations
|
||||||
containerRef={listRef}
|
conversations={conversations}
|
||||||
loadMoreConversations={loadMoreConversations}
|
moveToTop={moveToTop}
|
||||||
isLoading={isFetchingNextPage || showLoading || isLoading}
|
toggleNav={itemToggleNav}
|
||||||
isSearchLoading={isSearchLoading}
|
containerRef={listRef}
|
||||||
/>
|
loadMoreConversations={loadMoreConversations}
|
||||||
</div>
|
isLoading={isFetchingNextPage || showLoading || isLoading}
|
||||||
<Suspense fallback={null}>
|
isSearchLoading={isSearchLoading}
|
||||||
<AccountSettings />
|
/>
|
||||||
</Suspense>
|
</div>
|
||||||
</nav>
|
<Suspense fallback={null}>
|
||||||
|
<AccountSettings />
|
||||||
|
</Suspense>
|
||||||
|
</nav>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,16 @@ export default function NewChat({
|
||||||
subHeaders,
|
subHeaders,
|
||||||
isSmallScreen,
|
isSmallScreen,
|
||||||
headerButtons,
|
headerButtons,
|
||||||
|
openSidebarRef,
|
||||||
|
closeSidebarRef,
|
||||||
}: {
|
}: {
|
||||||
index?: number;
|
index?: number;
|
||||||
toggleNav: () => void;
|
toggleNav: () => void;
|
||||||
isSmallScreen?: boolean;
|
isSmallScreen?: boolean;
|
||||||
subHeaders?: React.ReactNode;
|
subHeaders?: React.ReactNode;
|
||||||
headerButtons?: React.ReactNode;
|
headerButtons?: React.ReactNode;
|
||||||
|
openSidebarRef?: React.RefObject<HTMLButtonElement>;
|
||||||
|
closeSidebarRef?: React.RefObject<HTMLButtonElement>;
|
||||||
}) {
|
}) {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
/** Note: this component needs an explicit index passed if using more than one */
|
/** Note: this component needs an explicit index passed if using more than one */
|
||||||
|
|
@ -27,6 +31,13 @@ export default function NewChat({
|
||||||
const localize = useLocalize();
|
const localize = useLocalize();
|
||||||
const { conversation } = store.useCreateConversationAtom(index);
|
const { conversation } = store.useCreateConversationAtom(index);
|
||||||
|
|
||||||
|
const handleToggleNav = useCallback(() => {
|
||||||
|
toggleNav();
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
openSidebarRef?.current?.focus();
|
||||||
|
});
|
||||||
|
}, [toggleNav, openSidebarRef]);
|
||||||
|
|
||||||
const clickHandler: React.MouseEventHandler<HTMLButtonElement> = useCallback(
|
const clickHandler: React.MouseEventHandler<HTMLButtonElement> = useCallback(
|
||||||
(e) => {
|
(e) => {
|
||||||
if (e.button === 0 && (e.ctrlKey || e.metaKey)) {
|
if (e.button === 0 && (e.ctrlKey || e.metaKey)) {
|
||||||
|
|
@ -51,12 +62,14 @@ export default function NewChat({
|
||||||
description={localize('com_nav_close_sidebar')}
|
description={localize('com_nav_close_sidebar')}
|
||||||
render={
|
render={
|
||||||
<Button
|
<Button
|
||||||
|
ref={closeSidebarRef}
|
||||||
size="icon"
|
size="icon"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
data-testid="close-sidebar-button"
|
data-testid="close-sidebar-button"
|
||||||
aria-label={localize('com_nav_close_sidebar')}
|
aria-label={localize('com_nav_close_sidebar')}
|
||||||
|
aria-expanded={true}
|
||||||
className="rounded-full border-none bg-transparent p-2 hover:bg-surface-hover md:rounded-xl"
|
className="rounded-full border-none bg-transparent p-2 hover:bg-surface-hover md:rounded-xl"
|
||||||
onClick={toggleNav}
|
onClick={handleToggleNav}
|
||||||
>
|
>
|
||||||
<Sidebar aria-hidden="true" className="max-md:hidden" />
|
<Sidebar aria-hidden="true" className="max-md:hidden" />
|
||||||
<MobileSidebar
|
<MobileSidebar
|
||||||
|
|
|
||||||
|
|
@ -152,7 +152,7 @@ export default function Settings({ open, onOpenChange }: TDialogProps) {
|
||||||
<div className={cn('fixed inset-0 flex w-screen items-center justify-center p-4')}>
|
<div className={cn('fixed inset-0 flex w-screen items-center justify-center p-4')}>
|
||||||
<DialogPanel
|
<DialogPanel
|
||||||
className={cn(
|
className={cn(
|
||||||
'min-h-[600px] overflow-hidden rounded-xl rounded-b-lg bg-background pb-6 shadow-2xl backdrop-blur-2xl animate-in sm:rounded-2xl md:min-h-[373px] md:w-[680px]',
|
'max-h-[90vh] overflow-hidden rounded-xl rounded-b-lg bg-background pb-6 shadow-2xl backdrop-blur-2xl animate-in sm:rounded-2xl md:w-[680px]',
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<DialogTitle
|
<DialogTitle
|
||||||
|
|
@ -185,7 +185,7 @@ export default function Settings({ open, onOpenChange }: TDialogProps) {
|
||||||
<span className="sr-only">{localize('com_ui_close_settings')}</span>
|
<span className="sr-only">{localize('com_ui_close_settings')}</span>
|
||||||
</button>
|
</button>
|
||||||
</DialogTitle>
|
</DialogTitle>
|
||||||
<div className="max-h-[550px] overflow-auto px-6 md:max-h-[400px] md:min-h-[400px] md:w-[680px]">
|
<div className="max-h-[calc(90vh-120px)] overflow-auto px-6 md:w-[680px]">
|
||||||
<Tabs.Root
|
<Tabs.Root
|
||||||
value={activeTab}
|
value={activeTab}
|
||||||
onValueChange={handleTabChange}
|
onValueChange={handleTabChange}
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,14 @@ interface DisableTwoFactorToggleProps {
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
onChange: () => void;
|
onChange: () => void;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
|
buttonRef?: React.RefObject<HTMLButtonElement>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DisableTwoFactorToggle: React.FC<DisableTwoFactorToggleProps> = ({
|
export const DisableTwoFactorToggle: React.FC<DisableTwoFactorToggleProps> = ({
|
||||||
enabled,
|
enabled,
|
||||||
onChange,
|
onChange,
|
||||||
disabled,
|
disabled,
|
||||||
|
buttonRef,
|
||||||
}) => {
|
}) => {
|
||||||
const localize = useLocalize();
|
const localize = useLocalize();
|
||||||
|
|
||||||
|
|
@ -24,9 +26,12 @@ export const DisableTwoFactorToggle: React.FC<DisableTwoFactorToggleProps> = ({
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
<Button
|
<Button
|
||||||
|
ref={buttonRef}
|
||||||
variant={enabled ? 'destructive' : 'outline'}
|
variant={enabled ? 'destructive' : 'outline'}
|
||||||
onClick={onChange}
|
onClick={onChange}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
|
aria-haspopup="dialog"
|
||||||
|
aria-controls="two-factor-authentication-dialog"
|
||||||
>
|
>
|
||||||
{enabled ? localize('com_ui_2fa_disable') : localize('com_ui_2fa_enable')}
|
{enabled ? localize('com_ui_2fa_disable') : localize('com_ui_2fa_enable')}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import React, { useCallback, useState } from 'react';
|
import React, { useCallback, useState, useRef } from 'react';
|
||||||
import { useSetRecoilState } from 'recoil';
|
import { useSetRecoilState } from 'recoil';
|
||||||
import { SmartphoneIcon } from 'lucide-react';
|
import { SmartphoneIcon } from 'lucide-react';
|
||||||
import { motion, AnimatePresence } from 'framer-motion';
|
import { motion, AnimatePresence } from 'framer-motion';
|
||||||
|
|
@ -35,6 +35,7 @@ const TwoFactorAuthentication: React.FC = () => {
|
||||||
const { user } = useAuthContext();
|
const { user } = useAuthContext();
|
||||||
const setUser = useSetRecoilState(store.user);
|
const setUser = useSetRecoilState(store.user);
|
||||||
const { showToast } = useToastContext();
|
const { showToast } = useToastContext();
|
||||||
|
const buttonRef = useRef<HTMLButtonElement>(null);
|
||||||
|
|
||||||
const [secret, setSecret] = useState<string>('');
|
const [secret, setSecret] = useState<string>('');
|
||||||
const [otpauthUrl, setOtpauthUrl] = useState<string>('');
|
const [otpauthUrl, setOtpauthUrl] = useState<string>('');
|
||||||
|
|
@ -197,16 +198,19 @@ const TwoFactorAuthentication: React.FC = () => {
|
||||||
resetState();
|
resetState();
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
triggerRef={buttonRef}
|
||||||
>
|
>
|
||||||
<DisableTwoFactorToggle
|
<DisableTwoFactorToggle
|
||||||
enabled={!!user?.twoFactorEnabled}
|
enabled={!!user?.twoFactorEnabled}
|
||||||
onChange={() => setDialogOpen(true)}
|
onChange={() => setDialogOpen(true)}
|
||||||
disabled={isVerifying || isDisabling || isGenerating}
|
disabled={isVerifying || isDisabling || isGenerating}
|
||||||
|
buttonRef={buttonRef}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<OGDialogContent className="w-11/12 max-w-lg p-6">
|
<OGDialogContent className="w-11/12 max-w-lg p-6">
|
||||||
<AnimatePresence mode="wait">
|
<AnimatePresence mode="wait">
|
||||||
<motion.div
|
<motion.div
|
||||||
|
id="two-factor-authentication-dialog"
|
||||||
key={phase}
|
key={phase}
|
||||||
variants={phaseVariants}
|
variants={phaseVariants}
|
||||||
initial="initial"
|
initial="initial"
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,14 @@ import { useCallback, useState, useMemo, useEffect } from 'react';
|
||||||
import debounce from 'lodash/debounce';
|
import debounce from 'lodash/debounce';
|
||||||
import { useRecoilValue } from 'recoil';
|
import { useRecoilValue } from 'recoil';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { TrashIcon, MessageSquare, ArrowUpDown, ArrowUp, ArrowDown } from 'lucide-react';
|
import {
|
||||||
|
TrashIcon,
|
||||||
|
MessageSquare,
|
||||||
|
ArrowUpDown,
|
||||||
|
ArrowUp,
|
||||||
|
ArrowDown,
|
||||||
|
ExternalLink,
|
||||||
|
} from 'lucide-react';
|
||||||
import type { SharedLinkItem, SharedLinksListParams } from 'librechat-data-provider';
|
import type { SharedLinkItem, SharedLinksListParams } from 'librechat-data-provider';
|
||||||
import {
|
import {
|
||||||
OGDialog,
|
OGDialog,
|
||||||
|
|
@ -169,6 +176,7 @@ export default function SharedLinks() {
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
handleSort('title', isSorted && sortDirection === 'asc' ? 'desc' : 'asc')
|
handleSort('title', isSorted && sortDirection === 'asc' ? 'desc' : 'asc')
|
||||||
}
|
}
|
||||||
|
aria-label={localize('com_ui_name_sort')}
|
||||||
>
|
>
|
||||||
{localize('com_ui_name')}
|
{localize('com_ui_name')}
|
||||||
{isSorted && sortDirection === 'asc' && (
|
{isSorted && sortDirection === 'asc' && (
|
||||||
|
|
@ -189,10 +197,14 @@ export default function SharedLinks() {
|
||||||
to={`/share/${shareId}`}
|
to={`/share/${shareId}`}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
className="block truncate text-blue-500 hover:underline"
|
className="group flex items-center gap-1 truncate rounded-sm text-blue-600 underline decoration-1 underline-offset-2 hover:decoration-2 focus:outline-none focus:ring-2 focus:ring-ring"
|
||||||
title={title}
|
title={title}
|
||||||
>
|
>
|
||||||
{title}
|
<span className="truncate">{title}</span>
|
||||||
|
<ExternalLink
|
||||||
|
className="size-3 flex-shrink-0 opacity-70 group-hover:opacity-100"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
@ -214,6 +226,7 @@ export default function SharedLinks() {
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
handleSort('createdAt', isSorted && sortDirection === 'asc' ? 'desc' : 'asc')
|
handleSort('createdAt', isSorted && sortDirection === 'asc' ? 'desc' : 'asc')
|
||||||
}
|
}
|
||||||
|
aria-label={localize('com_ui_creation_date_sort')}
|
||||||
>
|
>
|
||||||
{localize('com_ui_date')}
|
{localize('com_ui_date')}
|
||||||
{isSorted && sortDirection === 'asc' && (
|
{isSorted && sortDirection === 'asc' && (
|
||||||
|
|
@ -245,18 +258,15 @@ export default function SharedLinks() {
|
||||||
},
|
},
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<Button
|
<a
|
||||||
variant="ghost"
|
href={`/c/${row.original.conversationId}`}
|
||||||
className="h-8 w-8 p-0 hover:bg-surface-hover"
|
target="_blank"
|
||||||
onClick={() => {
|
rel="noopener noreferrer"
|
||||||
window.open(`/c/${row.original.conversationId}`, '_blank');
|
className="flex h-8 w-8 items-center justify-center rounded-md p-0 transition-colors hover:bg-surface-hover focus:outline-none focus:ring-2 focus:ring-ring"
|
||||||
}}
|
aria-label={`${localize('com_ui_view_source')} - ${row.original.title || localize('com_ui_untitled')}`}
|
||||||
aria-label={localize('com_ui_view_source', {
|
|
||||||
title: row.original.title || localize('com_ui_untitled'),
|
|
||||||
})}
|
|
||||||
>
|
>
|
||||||
<MessageSquare className="size-4" aria-hidden="true" />
|
<MessageSquare className="size-4" aria-hidden="true" />
|
||||||
</Button>
|
</a>
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
className="h-8 w-8 p-0 hover:bg-surface-hover"
|
className="h-8 w-8 p-0 hover:bg-surface-hover"
|
||||||
|
|
@ -267,6 +277,8 @@ export default function SharedLinks() {
|
||||||
aria-label={localize('com_ui_delete_shared_link', {
|
aria-label={localize('com_ui_delete_shared_link', {
|
||||||
title: row.original.title || localize('com_ui_untitled'),
|
title: row.original.title || localize('com_ui_untitled'),
|
||||||
})}
|
})}
|
||||||
|
aria-haspopup="dialog"
|
||||||
|
aria-controls="delete-shared-link-dialog"
|
||||||
>
|
>
|
||||||
<TrashIcon className="size-4" aria-hidden="true" />
|
<TrashIcon className="size-4" aria-hidden="true" />
|
||||||
</Button>
|
</Button>
|
||||||
|
|
@ -318,7 +330,10 @@ export default function SharedLinks() {
|
||||||
className="max-w-[450px]"
|
className="max-w-[450px]"
|
||||||
main={
|
main={
|
||||||
<>
|
<>
|
||||||
<div className="flex w-full flex-col items-center gap-2">
|
<div
|
||||||
|
id="delete-shared-link-dialog"
|
||||||
|
className="flex w-full flex-col items-center gap-2"
|
||||||
|
>
|
||||||
<div className="grid w-full items-center gap-2">
|
<div className="grid w-full items-center gap-2">
|
||||||
<Label htmlFor="dialog-confirm-delete" className="text-left text-sm font-medium">
|
<Label htmlFor="dialog-confirm-delete" className="text-left text-sm font-medium">
|
||||||
{localize('com_ui_delete_confirm')} <strong>{deleteRow?.title}</strong>
|
{localize('com_ui_delete_confirm')} <strong>{deleteRow?.title}</strong>
|
||||||
|
|
|
||||||
|
|
@ -160,7 +160,7 @@ export default function ArchivedChatsTable({
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="flex items-center gap-2 truncate"
|
className="flex items-center gap-2 truncate rounded-sm"
|
||||||
onClick={() => window.open(`/c/${conversationId}`, '_blank')}
|
onClick={() => window.open(`/c/${conversationId}`, '_blank')}
|
||||||
>
|
>
|
||||||
<MinimalIcon
|
<MinimalIcon
|
||||||
|
|
@ -190,6 +190,7 @@ export default function ArchivedChatsTable({
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
handleSort('createdAt', isSorted && sortDirection === 'asc' ? 'desc' : 'asc')
|
handleSort('createdAt', isSorted && sortDirection === 'asc' ? 'desc' : 'asc')
|
||||||
}
|
}
|
||||||
|
aria-label={localize('com_nav_archive_created_at_sort')}
|
||||||
>
|
>
|
||||||
{localize('com_nav_archive_created_at')}
|
{localize('com_nav_archive_created_at')}
|
||||||
{isSorted && sortDirection === 'asc' && (
|
{isSorted && sortDirection === 'asc' && (
|
||||||
|
|
|
||||||
|
|
@ -32,9 +32,9 @@ const AdvancedSwitch = () => {
|
||||||
}}
|
}}
|
||||||
aria-pressed={mode === PromptsEditorMode.SIMPLE}
|
aria-pressed={mode === PromptsEditorMode.SIMPLE}
|
||||||
aria-label={localize('com_ui_simple')}
|
aria-label={localize('com_ui_simple')}
|
||||||
className={`relative z-10 flex-1 rounded-xl px-3 py-2 text-sm font-medium transition-all duration-300 md:px-6 ${
|
className={`relative z-10 flex-1 rounded-xl px-3 py-2 text-sm transition-all duration-300 md:px-6 ${
|
||||||
mode === PromptsEditorMode.SIMPLE
|
mode === PromptsEditorMode.SIMPLE
|
||||||
? 'text-text-primary'
|
? 'font-bold text-text-primary'
|
||||||
: 'text-text-secondary hover:text-text-primary'
|
: 'text-text-secondary hover:text-text-primary'
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
|
|
@ -47,9 +47,9 @@ const AdvancedSwitch = () => {
|
||||||
onClick={() => setMode(PromptsEditorMode.ADVANCED)}
|
onClick={() => setMode(PromptsEditorMode.ADVANCED)}
|
||||||
aria-pressed={mode === PromptsEditorMode.ADVANCED}
|
aria-pressed={mode === PromptsEditorMode.ADVANCED}
|
||||||
aria-label={localize('com_ui_advanced')}
|
aria-label={localize('com_ui_advanced')}
|
||||||
className={`relative z-10 flex-1 rounded-xl px-3 py-2 text-sm font-medium transition-all duration-300 md:px-6 ${
|
className={`relative z-10 flex-1 rounded-xl px-3 py-2 text-sm transition-all duration-300 md:px-6 ${
|
||||||
mode === PromptsEditorMode.ADVANCED
|
mode === PromptsEditorMode.ADVANCED
|
||||||
? 'text-text-primary'
|
? 'font-bold text-text-primary'
|
||||||
: 'text-text-secondary hover:text-text-primary'
|
: 'text-text-secondary hover:text-text-primary'
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -45,21 +45,37 @@ const Command = ({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="rounded-xl border border-border-light shadow-md">
|
<div className="rounded-xl border border-border-light shadow-md">
|
||||||
<h3 className="flex h-10 items-center gap-1 pl-4 text-sm text-text-secondary">
|
<label
|
||||||
<SquareSlash className="icon-sm" aria-hidden="true" />
|
htmlFor="prompt-command"
|
||||||
<Input
|
className="block px-4 pt-2 text-sm text-text-secondary md:hidden"
|
||||||
type="text"
|
>
|
||||||
tabIndex={tabIndex}
|
{localize('com_ui_command_placeholder')}
|
||||||
disabled={disabled}
|
</label>
|
||||||
placeholder={localize('com_ui_command_placeholder')}
|
<div className="relative flex h-10 items-center gap-1 pl-4 pr-2 text-sm text-text-secondary">
|
||||||
value={command}
|
<SquareSlash className="icon-sm shrink-0" aria-hidden="true" />
|
||||||
onChange={handleInputChange}
|
<div className="relative min-w-0 flex-1">
|
||||||
className="border-none"
|
<Input
|
||||||
/>
|
type="text"
|
||||||
|
id="prompt-command"
|
||||||
|
tabIndex={tabIndex}
|
||||||
|
disabled={disabled}
|
||||||
|
placeholder=" "
|
||||||
|
value={command}
|
||||||
|
onChange={handleInputChange}
|
||||||
|
className="peer w-full border-none pr-14"
|
||||||
|
aria-label={localize('com_ui_command_placeholder')}
|
||||||
|
/>
|
||||||
|
<label
|
||||||
|
htmlFor="prompt-command"
|
||||||
|
className="pointer-events-none absolute left-0 top-0.5 hidden max-w-[calc(100%-3.5rem)] origin-[0] translate-y-2 scale-100 rounded bg-white px-1 text-sm text-text-secondary transition-transform duration-200 peer-placeholder-shown:translate-y-2 peer-placeholder-shown:scale-100 peer-focus:-translate-y-3 peer-focus:scale-75 peer-focus:text-text-primary peer-[:not(:placeholder-shown)]:-translate-y-3 peer-[:not(:placeholder-shown)]:scale-75 dark:bg-gray-850 md:block"
|
||||||
|
>
|
||||||
|
{localize('com_ui_command_placeholder')}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
{disabled !== true && (
|
{disabled !== true && (
|
||||||
<span className="mr-4 w-10 text-xs text-text-secondary md:text-sm">{`${charCount}/${Constants.COMMANDS_MAX_LENGTH}`}</span>
|
<span className="absolute right-2 shrink-0 text-xs text-text-secondary md:text-sm">{`${charCount}/${Constants.COMMANDS_MAX_LENGTH}`}</span>
|
||||||
)}
|
)}
|
||||||
</h3>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -42,21 +42,37 @@ const Description = ({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="rounded-xl border border-border-light shadow-md">
|
<div className="rounded-xl border border-border-light shadow-md">
|
||||||
<h3 className="flex h-10 items-center gap-1 pl-4 text-sm text-text-secondary">
|
<label
|
||||||
<Info className="icon-sm" aria-hidden="true" />
|
htmlFor="prompt-description"
|
||||||
<Input
|
className="block px-4 pt-2 text-sm text-text-secondary md:hidden"
|
||||||
type="text"
|
>
|
||||||
tabIndex={tabIndex}
|
{localize('com_ui_description_placeholder')}
|
||||||
disabled={disabled}
|
</label>
|
||||||
placeholder={localize('com_ui_description_placeholder')}
|
<div className="relative flex h-10 items-center gap-1 pl-4 pr-2 text-sm text-text-secondary">
|
||||||
value={description}
|
<Info className="icon-sm shrink-0" aria-hidden="true" />
|
||||||
onChange={handleInputChange}
|
<div className="relative min-w-0 flex-1">
|
||||||
className="border-none"
|
<Input
|
||||||
/>
|
type="text"
|
||||||
|
id="prompt-description"
|
||||||
|
tabIndex={tabIndex}
|
||||||
|
disabled={disabled}
|
||||||
|
placeholder=" "
|
||||||
|
value={description}
|
||||||
|
onChange={handleInputChange}
|
||||||
|
className="peer w-full border-none pr-14"
|
||||||
|
aria-label={localize('com_ui_description_placeholder')}
|
||||||
|
/>
|
||||||
|
<label
|
||||||
|
htmlFor="prompt-description"
|
||||||
|
className="pointer-events-none absolute left-0 top-0.5 hidden max-w-[calc(100%-3.5rem)] origin-[0] translate-y-2 scale-100 rounded bg-white px-1 text-sm text-text-secondary transition-transform duration-200 peer-placeholder-shown:translate-y-2 peer-placeholder-shown:scale-100 peer-focus:-translate-y-3 peer-focus:scale-75 peer-focus:text-text-primary peer-[:not(:placeholder-shown)]:-translate-y-3 peer-[:not(:placeholder-shown)]:scale-75 dark:bg-gray-850 md:block"
|
||||||
|
>
|
||||||
|
{localize('com_ui_description_placeholder')}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
{!disabled && (
|
{!disabled && (
|
||||||
<span className="mr-4 w-10 text-xs text-text-secondary md:text-sm">{`${charCount}/${MAX_LENGTH}`}</span>
|
<span className="absolute right-2 shrink-0 text-xs text-text-secondary md:text-sm">{`${charCount}/${MAX_LENGTH}`}</span>
|
||||||
)}
|
)}
|
||||||
</h3>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { useState, useMemo, memo } from 'react';
|
import { useState, useMemo, memo, useRef } from 'react';
|
||||||
import { Menu as MenuIcon, Edit as EditIcon, EarthIcon, TextSearch } from 'lucide-react';
|
import { Menu as MenuIcon, Edit as EditIcon, EarthIcon, TextSearch } from 'lucide-react';
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
|
|
@ -37,6 +37,8 @@ function ChatGroupItem({
|
||||||
const { hasPermission } = useResourcePermissions('promptGroup', group._id || '');
|
const { hasPermission } = useResourcePermissions('promptGroup', group._id || '');
|
||||||
const canEdit = hasPermission(PermissionBits.EDIT);
|
const canEdit = hasPermission(PermissionBits.EDIT);
|
||||||
|
|
||||||
|
const triggerButtonRef = useRef<HTMLButtonElement | null>(null);
|
||||||
|
|
||||||
const onCardClick: React.MouseEventHandler<HTMLButtonElement> = () => {
|
const onCardClick: React.MouseEventHandler<HTMLButtonElement> = () => {
|
||||||
const text = group.productionPrompt?.prompt;
|
const text = group.productionPrompt?.prompt;
|
||||||
if (!text?.trim()) {
|
if (!text?.trim()) {
|
||||||
|
|
@ -53,23 +55,28 @@ function ChatGroupItem({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ListCard
|
<div className="relative my-2 items-stretch justify-between rounded-xl border border-border-light shadow-sm transition-all duration-300 ease-in-out hover:bg-surface-tertiary hover:shadow-lg">
|
||||||
name={group.name}
|
<ListCard
|
||||||
category={group.category ?? ''}
|
name={group.name}
|
||||||
onClick={onCardClick}
|
category={group.category ?? ''}
|
||||||
snippet={
|
onClick={onCardClick}
|
||||||
typeof group.oneliner === 'string' && group.oneliner.length > 0
|
snippet={
|
||||||
? group.oneliner
|
typeof group.oneliner === 'string' && group.oneliner.length > 0
|
||||||
: (group.productionPrompt?.prompt ?? '')
|
? group.oneliner
|
||||||
}
|
: (group.productionPrompt?.prompt ?? '')
|
||||||
>
|
}
|
||||||
<div className="flex flex-row items-center gap-2">
|
>
|
||||||
{groupIsGlobal === true && (
|
<div className="flex flex-row items-center gap-2">
|
||||||
<EarthIcon className="icon-md text-green-400" aria-label="Global prompt group" />
|
{groupIsGlobal === true && (
|
||||||
)}
|
<EarthIcon className="icon-md text-green-400" aria-label="Global prompt group" />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</ListCard>
|
||||||
|
<div className="absolute right-0 top-0 mr-1 mt-2.5 items-start pl-2">
|
||||||
<DropdownMenu modal={false}>
|
<DropdownMenu modal={false}>
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
<button
|
<button
|
||||||
|
ref={triggerButtonRef}
|
||||||
id={`prompt-actions-${group._id}`}
|
id={`prompt-actions-${group._id}`}
|
||||||
type="button"
|
type="button"
|
||||||
aria-label={localize('com_ui_sr_actions_menu', { name: group.name })}
|
aria-label={localize('com_ui_sr_actions_menu', { name: group.name })}
|
||||||
|
|
@ -81,7 +88,7 @@ function ChatGroupItem({
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
className="z-50 inline-flex h-8 w-8 items-center justify-center rounded-lg border border-border-medium bg-transparent p-0 text-sm font-medium transition-all duration-300 ease-in-out hover:border-border-heavy hover:bg-surface-hover focus:border-border-heavy focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"
|
className="z-50 mr-2 inline-flex h-8 w-8 items-center justify-center rounded-lg border border-border-medium bg-transparent p-0 text-sm font-medium transition-all duration-300 ease-in-out hover:border-border-heavy hover:bg-surface-hover focus:border-border-heavy focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"
|
||||||
>
|
>
|
||||||
<MenuIcon className="icon-md text-text-secondary" aria-hidden="true" />
|
<MenuIcon className="icon-md text-text-secondary" aria-hidden="true" />
|
||||||
</button>
|
</button>
|
||||||
|
|
@ -127,8 +134,17 @@ function ChatGroupItem({
|
||||||
</DropdownMenuContent>
|
</DropdownMenuContent>
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
</div>
|
</div>
|
||||||
</ListCard>
|
</div>
|
||||||
<PreviewPrompt group={group} open={isPreviewDialogOpen} onOpenChange={setPreviewDialogOpen} />
|
<PreviewPrompt
|
||||||
|
group={group}
|
||||||
|
open={isPreviewDialogOpen}
|
||||||
|
onOpenChange={setPreviewDialogOpen}
|
||||||
|
onCloseAutoFocus={() => {
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
triggerButtonRef.current?.focus({ preventScroll: true });
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
/>
|
||||||
<VariableDialog
|
<VariableDialog
|
||||||
open={isVariableDialogOpen}
|
open={isVariableDialogOpen}
|
||||||
onClose={() => setVariableDialogOpen(false)}
|
onClose={() => setVariableDialogOpen(false)}
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,7 @@ const CreatePromptForm = ({
|
||||||
return (
|
return (
|
||||||
<FormProvider {...methods}>
|
<FormProvider {...methods}>
|
||||||
<form onSubmit={handleSubmit(onSubmit)} className="w-full px-4 py-2">
|
<form onSubmit={handleSubmit(onSubmit)} className="w-full px-4 py-2">
|
||||||
|
<h1 className="sr-only">{localize('com_ui_create_prompt_page')}</h1>
|
||||||
<div className="mb-1 flex flex-col items-center justify-between font-bold sm:text-xl md:mb-0 md:text-2xl">
|
<div className="mb-1 flex flex-col items-center justify-between font-bold sm:text-xl md:mb-0 md:text-2xl">
|
||||||
<div className="flex w-full flex-col items-center justify-between sm:flex-row">
|
<div className="flex w-full flex-col items-center justify-between sm:flex-row">
|
||||||
<Controller
|
<Controller
|
||||||
|
|
@ -111,14 +112,22 @@ const CreatePromptForm = ({
|
||||||
control={control}
|
control={control}
|
||||||
rules={{ required: localize('com_ui_prompt_name_required') }}
|
rules={{ required: localize('com_ui_prompt_name_required') }}
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<div className="mb-1 flex items-center md:mb-0">
|
<div className="relative mb-1 flex flex-col md:mb-0">
|
||||||
<Input
|
<Input
|
||||||
{...field}
|
{...field}
|
||||||
|
id="prompt-name"
|
||||||
type="text"
|
type="text"
|
||||||
className="mr-2 w-full border border-border-medium p-2 text-2xl text-text-primary placeholder:text-text-tertiary dark:placeholder:text-text-secondary"
|
className="peer mr-2 w-full border border-border-medium p-2 text-2xl text-text-primary"
|
||||||
placeholder={`${localize('com_ui_prompt_name')}*`}
|
placeholder=" "
|
||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
|
aria-label={localize('com_ui_prompt_name')}
|
||||||
/>
|
/>
|
||||||
|
<label
|
||||||
|
htmlFor="prompt-name"
|
||||||
|
className="pointer-events-none absolute -top-1 left-3 origin-[0] translate-y-3 scale-100 rounded bg-white px-1 text-base text-text-secondary transition-transform duration-200 peer-placeholder-shown:translate-y-3 peer-placeholder-shown:scale-100 peer-focus:-translate-y-2 peer-focus:scale-75 peer-focus:text-text-primary peer-[:not(:placeholder-shown)]:-translate-y-2 peer-[:not(:placeholder-shown)]:scale-75 dark:bg-gray-850"
|
||||||
|
>
|
||||||
|
{localize('com_ui_prompt_name')}*
|
||||||
|
</label>
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
'mt-1 w-56 text-sm text-red-500',
|
'mt-1 w-56 text-sm text-red-500',
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import { memo, useState, useRef, useMemo, useCallback, KeyboardEvent } from 'react';
|
import { memo, useState, useRef, useMemo, useCallback, KeyboardEvent } from 'react';
|
||||||
import { EarthIcon, Pen } from 'lucide-react';
|
import { EarthIcon, Pen } from 'lucide-react';
|
||||||
import { useNavigate, useParams } from 'react-router-dom';
|
import { useNavigate, useParams } from 'react-router-dom';
|
||||||
|
import { Trans } from 'react-i18next';
|
||||||
import { PermissionBits, type TPromptGroup } from 'librechat-data-provider';
|
import { PermissionBits, type TPromptGroup } from 'librechat-data-provider';
|
||||||
import {
|
import {
|
||||||
Input,
|
Input,
|
||||||
Label,
|
Label,
|
||||||
Button,
|
|
||||||
OGDialog,
|
OGDialog,
|
||||||
OGDialogTrigger,
|
OGDialogTrigger,
|
||||||
OGDialogTemplate,
|
OGDialogTemplate,
|
||||||
|
|
@ -62,8 +62,8 @@ function DashGroupItemComponent({ group, instanceProjectId }: DashGroupItemProps
|
||||||
}, [group._id, nameInputValue, updateGroup]);
|
}, [group._id, nameInputValue, updateGroup]);
|
||||||
|
|
||||||
const handleKeyDown = useCallback(
|
const handleKeyDown = useCallback(
|
||||||
(e: KeyboardEvent<HTMLDivElement>) => {
|
(e: KeyboardEvent<HTMLButtonElement>) => {
|
||||||
if (e.key === 'Enter') {
|
if (e.key === 'Enter' || e.key === ' ') {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
navigate(`/d/prompts/${group._id}`, { replace: true });
|
navigate(`/d/prompts/${group._id}`, { replace: true });
|
||||||
}
|
}
|
||||||
|
|
@ -82,16 +82,26 @@ function DashGroupItemComponent({ group, instanceProjectId }: DashGroupItemProps
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
'mx-2 my-2 flex cursor-pointer rounded-lg border border-border-light bg-surface-primary p-3 shadow-sm transition-all duration-300 ease-in-out hover:bg-surface-secondary',
|
'relative mx-2 my-2 rounded-lg border border-border-light bg-surface-primary shadow-sm transition-all duration-300 ease-in-out hover:bg-surface-secondary',
|
||||||
params.promptId === group._id && 'bg-surface-hover',
|
params.promptId === group._id && 'bg-surface-hover',
|
||||||
)}
|
)}
|
||||||
onClick={handleContainerClick}
|
|
||||||
onKeyDown={handleKeyDown}
|
|
||||||
role="button"
|
|
||||||
tabIndex={0}
|
|
||||||
aria-label={`${group.name} Prompt, ${localize('com_ui_category')}: ${group.category ?? ''}`}
|
|
||||||
>
|
>
|
||||||
<div className="flex w-full items-center justify-between">
|
<button
|
||||||
|
type="button"
|
||||||
|
className="flex w-full cursor-pointer items-center justify-between rounded-lg p-3 text-left"
|
||||||
|
onClick={handleContainerClick}
|
||||||
|
onKeyDown={handleKeyDown}
|
||||||
|
aria-label={
|
||||||
|
group.category
|
||||||
|
? localize('com_ui_prompt_group_button', {
|
||||||
|
name: group.name,
|
||||||
|
category: group.category,
|
||||||
|
})
|
||||||
|
: localize('com_ui_prompt_group_button_no_category', {
|
||||||
|
name: group.name,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
>
|
||||||
<div className="flex items-center gap-2 truncate pr-2">
|
<div className="flex items-center gap-2 truncate pr-2">
|
||||||
<CategoryIcon category={group.category ?? ''} className="icon-lg" aria-hidden="true" />
|
<CategoryIcon category={group.category ?? ''} className="icon-lg" aria-hidden="true" />
|
||||||
|
|
||||||
|
|
@ -107,80 +117,97 @@ function DashGroupItemComponent({ group, instanceProjectId }: DashGroupItemProps
|
||||||
aria-label={localize('com_ui_global_group')}
|
aria-label={localize('com_ui_global_group')}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{canEdit && (
|
|
||||||
<OGDialog>
|
|
||||||
<OGDialogTrigger asChild>
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
onClick={(e) => e.stopPropagation()}
|
|
||||||
className="h-8 w-8 p-0 hover:bg-surface-hover"
|
|
||||||
aria-label={localize('com_ui_rename_prompt_name', { name: group.name })}
|
|
||||||
>
|
|
||||||
<Pen className="icon-sm text-text-primary" aria-hidden="true" />
|
|
||||||
</Button>
|
|
||||||
</OGDialogTrigger>
|
|
||||||
<OGDialogTemplate
|
|
||||||
showCloseButton={false}
|
|
||||||
title={localize('com_ui_rename_prompt')}
|
|
||||||
className="w-11/12 max-w-lg"
|
|
||||||
main={
|
|
||||||
<div className="flex w-full flex-col items-center gap-2">
|
|
||||||
<div className="grid w-full items-center gap-2">
|
|
||||||
<Input
|
|
||||||
value={nameInputValue}
|
|
||||||
onChange={(e) => setNameInputValue(e.target.value)}
|
|
||||||
className="w-full"
|
|
||||||
aria-label={localize('com_ui_rename_prompt_name', { name: group.name })}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
selection={{
|
|
||||||
selectHandler: handleSaveRename,
|
|
||||||
selectClasses:
|
|
||||||
'bg-surface-submit hover:bg-surface-submit-hover text-white disabled:hover:bg-surface-submit',
|
|
||||||
selectText: localize('com_ui_save'),
|
|
||||||
isLoading,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</OGDialog>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{canDelete && (
|
|
||||||
<OGDialog>
|
|
||||||
<OGDialogTrigger asChild>
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
className="h-8 w-8 p-0 hover:bg-surface-hover"
|
|
||||||
onClick={(e) => e.stopPropagation()}
|
|
||||||
aria-label={localize('com_ui_delete_prompt_name', { name: group.name })}
|
|
||||||
>
|
|
||||||
<TrashIcon className="icon-sm text-text-primary" aria-hidden="true" />
|
|
||||||
</Button>
|
|
||||||
</OGDialogTrigger>
|
|
||||||
<OGDialogTemplate
|
|
||||||
showCloseButton={false}
|
|
||||||
title={localize('com_ui_delete_prompt')}
|
|
||||||
className="w-11/12 max-w-lg"
|
|
||||||
main={
|
|
||||||
<div className="flex w-full flex-col items-center gap-2">
|
|
||||||
<div className="grid w-full items-center gap-2">
|
|
||||||
<Label htmlFor="confirm-delete" className="text-left text-sm font-medium">
|
|
||||||
{localize('com_ui_delete_confirm')} <strong>{group.name}</strong>
|
|
||||||
</Label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
selection={{
|
|
||||||
selectHandler: triggerDelete,
|
|
||||||
selectClasses:
|
|
||||||
'bg-red-600 dark:bg-red-600 hover:bg-red-700 dark:hover:bg-red-800 text-white',
|
|
||||||
selectText: localize('com_ui_delete'),
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</OGDialog>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div className="absolute right-0 top-0 mr-1 mt-2.5 flex items-start gap-1 pl-2">
|
||||||
|
{canEdit && (
|
||||||
|
<OGDialog>
|
||||||
|
<OGDialogTrigger asChild>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={(e) => e.stopPropagation()}
|
||||||
|
onKeyDown={(e) => {
|
||||||
|
if (e.key === 'Enter' || e.key === ' ') {
|
||||||
|
e.stopPropagation();
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
className="inline-flex h-8 w-8 items-center justify-center rounded-lg border border-border-medium bg-transparent p-0 text-sm font-medium transition-all duration-300 ease-in-out hover:border-border-heavy hover:bg-surface-hover focus:border-border-heavy focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"
|
||||||
|
aria-label={localize('com_ui_rename_prompt_name', { name: group.name })}
|
||||||
|
>
|
||||||
|
<Pen className="icon-sm text-text-primary" aria-hidden="true" />
|
||||||
|
</button>
|
||||||
|
</OGDialogTrigger>
|
||||||
|
<OGDialogTemplate
|
||||||
|
showCloseButton={false}
|
||||||
|
title={localize('com_ui_rename_prompt')}
|
||||||
|
className="w-11/12 max-w-lg"
|
||||||
|
main={
|
||||||
|
<div className="flex w-full flex-col items-center gap-2">
|
||||||
|
<div className="grid w-full items-center gap-2">
|
||||||
|
<Input
|
||||||
|
value={nameInputValue}
|
||||||
|
onChange={(e) => setNameInputValue(e.target.value)}
|
||||||
|
className="w-full"
|
||||||
|
aria-label={localize('com_ui_rename_prompt_name', { name: group.name })}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
selection={{
|
||||||
|
selectHandler: handleSaveRename,
|
||||||
|
selectClasses:
|
||||||
|
'bg-surface-submit hover:bg-surface-submit-hover text-white disabled:hover:bg-surface-submit',
|
||||||
|
selectText: localize('com_ui_save'),
|
||||||
|
isLoading,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</OGDialog>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{canDelete && (
|
||||||
|
<OGDialog>
|
||||||
|
<OGDialogTrigger asChild>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={(e) => e.stopPropagation()}
|
||||||
|
onKeyDown={(e) => {
|
||||||
|
if (e.key === 'Enter' || e.key === ' ') {
|
||||||
|
e.stopPropagation();
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
className="inline-flex h-8 w-8 items-center justify-center rounded-lg border border-border-medium bg-transparent p-0 text-sm font-medium transition-all duration-300 ease-in-out hover:border-border-heavy hover:bg-surface-hover focus:border-border-heavy focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"
|
||||||
|
aria-label={localize('com_ui_delete_prompt_name', { name: group.name })}
|
||||||
|
>
|
||||||
|
<TrashIcon className="icon-sm text-text-primary" aria-hidden="true" />
|
||||||
|
</button>
|
||||||
|
</OGDialogTrigger>
|
||||||
|
<OGDialogTemplate
|
||||||
|
showCloseButton={false}
|
||||||
|
title={localize('com_ui_delete_prompt')}
|
||||||
|
className="w-11/12 max-w-lg"
|
||||||
|
main={
|
||||||
|
<div className="flex w-full flex-col items-center gap-2">
|
||||||
|
<div className="grid w-full items-center gap-2">
|
||||||
|
<Label htmlFor="confirm-delete" className="text-left text-sm font-medium">
|
||||||
|
<Trans
|
||||||
|
i18nKey="com_ui_delete_confirm_strong"
|
||||||
|
values={{ title: group.name }}
|
||||||
|
components={{ strong: <strong /> }}
|
||||||
|
/>
|
||||||
|
</Label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
selection={{
|
||||||
|
selectHandler: triggerDelete,
|
||||||
|
selectClasses:
|
||||||
|
'bg-red-600 dark:bg-red-600 hover:bg-red-700 dark:hover:bg-red-800 text-white',
|
||||||
|
selectText: localize('com_ui_delete'),
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</OGDialog>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import { ListFilter, User, Share2 } from 'lucide-react';
|
||||||
import { SystemCategories } from 'librechat-data-provider';
|
import { SystemCategories } from 'librechat-data-provider';
|
||||||
import { Dropdown, AnimatedSearchInput } from '@librechat/client';
|
import { Dropdown, AnimatedSearchInput } from '@librechat/client';
|
||||||
import type { Option } from '~/common';
|
import type { Option } from '~/common';
|
||||||
|
import type { TranslationKeys } from '~/hooks';
|
||||||
import { useLocalize, useCategories } from '~/hooks';
|
import { useLocalize, useCategories } from '~/hooks';
|
||||||
import { usePromptGroupsContext } from '~/Providers';
|
import { usePromptGroupsContext } from '~/Providers';
|
||||||
import { cn } from '~/utils';
|
import { cn } from '~/utils';
|
||||||
|
|
@ -11,11 +12,12 @@ import store from '~/store';
|
||||||
|
|
||||||
export default function FilterPrompts({ className = '' }: { className?: string }) {
|
export default function FilterPrompts({ className = '' }: { className?: string }) {
|
||||||
const localize = useLocalize();
|
const localize = useLocalize();
|
||||||
const { name, setName, hasAccess } = usePromptGroupsContext();
|
const { name, setName, hasAccess, promptGroups } = usePromptGroupsContext();
|
||||||
const { categories } = useCategories({ className: 'h-4 w-4', hasAccess });
|
const { categories } = useCategories({ className: 'h-4 w-4', hasAccess });
|
||||||
const [displayName, setDisplayName] = useState(name || '');
|
const [displayName, setDisplayName] = useState(name || '');
|
||||||
const [isSearching, setIsSearching] = useState(false);
|
const [isSearching, setIsSearching] = useState(false);
|
||||||
const [categoryFilter, setCategory] = useRecoilState(store.promptsCategory);
|
const [categoryFilter, setCategory] = useRecoilState(store.promptsCategory);
|
||||||
|
const [searchResultsAnnouncement, setSearchResultsAnnouncement] = useState('');
|
||||||
|
|
||||||
const filterOptions = useMemo(() => {
|
const filterOptions = useMemo(() => {
|
||||||
const baseOptions: Option[] = [
|
const baseOptions: Option[] = [
|
||||||
|
|
@ -81,8 +83,34 @@ export default function FilterPrompts({ className = '' }: { className?: string }
|
||||||
return () => clearTimeout(timeout);
|
return () => clearTimeout(timeout);
|
||||||
}, [displayName, setName]);
|
}, [displayName, setName]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!displayName.trim() || isSearching) {
|
||||||
|
setSearchResultsAnnouncement('');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const resultCount = promptGroups?.length ?? 0;
|
||||||
|
const announcement =
|
||||||
|
resultCount === 1
|
||||||
|
? localize('com_ui_result_found' as TranslationKeys, {
|
||||||
|
count: resultCount,
|
||||||
|
})
|
||||||
|
: localize('com_ui_results_found' as TranslationKeys, {
|
||||||
|
count: resultCount,
|
||||||
|
});
|
||||||
|
|
||||||
|
const timeout = setTimeout(() => {
|
||||||
|
setSearchResultsAnnouncement(announcement);
|
||||||
|
}, 300);
|
||||||
|
|
||||||
|
return () => clearTimeout(timeout);
|
||||||
|
}, [promptGroups?.length, displayName, isSearching, localize]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={cn('flex w-full gap-2 text-text-primary', className)}>
|
<div className={cn('flex w-full gap-2 text-text-primary', className)}>
|
||||||
|
<div aria-live="polite" className="sr-only">
|
||||||
|
{searchResultsAnnouncement}
|
||||||
|
</div>
|
||||||
<Dropdown
|
<Dropdown
|
||||||
value={categoryFilter || SystemCategories.ALL}
|
value={categoryFilter || SystemCategories.ALL}
|
||||||
onChange={onSelect}
|
onChange={onSelect}
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,26 @@
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { useLocation } from 'react-router-dom';
|
import { useLocation } from 'react-router-dom';
|
||||||
import { useMediaQuery } from '@librechat/client';
|
import { Button, Sidebar, TooltipAnchor } from '@librechat/client';
|
||||||
import ManagePrompts from '~/components/Prompts/ManagePrompts';
|
import ManagePrompts from '~/components/Prompts/ManagePrompts';
|
||||||
import { usePromptGroupsContext } from '~/Providers';
|
import { usePromptGroupsContext } from '~/Providers';
|
||||||
import List from '~/components/Prompts/Groups/List';
|
import List from '~/components/Prompts/Groups/List';
|
||||||
import PanelNavigation from './PanelNavigation';
|
import PanelNavigation from './PanelNavigation';
|
||||||
|
import { useLocalize } from '~/hooks';
|
||||||
import { cn } from '~/utils';
|
import { cn } from '~/utils';
|
||||||
|
|
||||||
export default function GroupSidePanel({
|
export default function GroupSidePanel({
|
||||||
children,
|
children,
|
||||||
isDetailView,
|
|
||||||
className = '',
|
className = '',
|
||||||
|
closePanelRef,
|
||||||
|
onClose,
|
||||||
}: {
|
}: {
|
||||||
children?: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
isDetailView?: boolean;
|
|
||||||
className?: string;
|
className?: string;
|
||||||
|
closePanelRef?: React.RefObject<HTMLButtonElement>;
|
||||||
|
onClose?: () => void;
|
||||||
}) {
|
}) {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const isSmallerScreen = useMediaQuery('(max-width: 1024px)');
|
const localize = useLocalize();
|
||||||
const isChatRoute = useMemo(() => location.pathname?.startsWith('/c/'), [location.pathname]);
|
const isChatRoute = useMemo(() => location.pathname?.startsWith('/c/'), [location.pathname]);
|
||||||
|
|
||||||
const { promptGroups, groupsQuery, nextPage, prevPage, hasNextPage, hasPreviousPage } =
|
const { promptGroups, groupsQuery, nextPage, prevPage, hasNextPage, hasPreviousPage } =
|
||||||
|
|
@ -25,15 +28,42 @@ export default function GroupSidePanel({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
id="prompts-panel"
|
||||||
className={cn(
|
className={cn(
|
||||||
'flex h-full w-full flex-col gap-2 md:mr-2 md:w-auto md:min-w-72 lg:w-1/4 xl:w-1/4',
|
'flex h-full w-full flex-col md:mr-2 md:w-auto md:min-w-72 lg:w-1/4 xl:w-1/4',
|
||||||
isDetailView === true && isSmallerScreen ? 'hidden' : '',
|
|
||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{children}
|
{onClose && (
|
||||||
<div className={cn('flex-grow overflow-y-auto', isChatRoute ? '' : 'px-2 md:px-0')}>
|
<div className="flex items-center justify-between px-2 py-[2px] md:py-2">
|
||||||
<List groups={promptGroups} isChatRoute={isChatRoute} isLoading={!!groupsQuery.isLoading} />
|
<TooltipAnchor
|
||||||
|
description={localize('com_nav_close_sidebar')}
|
||||||
|
render={
|
||||||
|
<Button
|
||||||
|
ref={closePanelRef}
|
||||||
|
size="icon"
|
||||||
|
variant="outline"
|
||||||
|
data-testid="close-prompts-panel-button"
|
||||||
|
aria-label={localize('com_nav_close_sidebar')}
|
||||||
|
aria-expanded={true}
|
||||||
|
className="rounded-full border-none bg-transparent p-2 hover:bg-surface-hover md:rounded-xl"
|
||||||
|
onClick={onClose}
|
||||||
|
>
|
||||||
|
<Sidebar />
|
||||||
|
</Button>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div className="flex flex-1 flex-col gap-2 overflow-y-auto">
|
||||||
|
{children}
|
||||||
|
<div className={cn('relative flex h-full flex-col', isChatRoute ? '' : 'px-2 md:px-0')}>
|
||||||
|
<List
|
||||||
|
groups={promptGroups}
|
||||||
|
isChatRoute={isChatRoute}
|
||||||
|
isLoading={!!groupsQuery.isLoading}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className={cn(isChatRoute ? '' : 'px-2 pb-3 pt-2 md:px-0')}>
|
<div className={cn(isChatRoute ? '' : 'px-2 pb-3 pt-2 md:px-0')}>
|
||||||
<PanelNavigation
|
<PanelNavigation
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ export default function ListCard({
|
||||||
<div
|
<div
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
className="relative my-2 flex w-full cursor-pointer flex-col gap-2 rounded-xl border border-border-light px-3 pb-4 pt-3 text-start align-top text-[15px] shadow-sm transition-all duration-300 ease-in-out hover:bg-surface-tertiary hover:shadow-lg"
|
className="relative flex w-full cursor-pointer flex-col gap-2 rounded-xl px-3 pb-4 pt-3 text-start align-top text-[15px]"
|
||||||
role="button"
|
role="button"
|
||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
aria-labelledby={`card-title-${name}`}
|
aria-labelledby={`card-title-${name}`}
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,7 @@ export default function VariableForm({
|
||||||
return (
|
return (
|
||||||
<div className="mx-auto p-1 md:container">
|
<div className="mx-auto p-1 md:container">
|
||||||
<form onSubmit={handleSubmit(onSubmit)} className="space-y-4">
|
<form onSubmit={handleSubmit(onSubmit)} className="space-y-4">
|
||||||
<div className="mb-6 max-h-screen max-w-[90vw] overflow-auto rounded-md bg-surface-tertiary p-4 text-text-secondary dark:bg-surface-primary sm:max-w-full md:max-h-96">
|
<div className="mb-6 max-h-screen max-w-[80vw] overflow-auto rounded-md bg-surface-tertiary p-4 text-text-secondary dark:bg-surface-primary sm:max-w-full md:max-h-96">
|
||||||
<ReactMarkdown
|
<ReactMarkdown
|
||||||
/** @ts-ignore */
|
/** @ts-ignore */
|
||||||
remarkPlugins={[supersub, remarkGfm, [remarkMath, { singleDollarTextMath: false }]]}
|
remarkPlugins={[supersub, remarkGfm, [remarkMath, { singleDollarTextMath: false }]]}
|
||||||
|
|
@ -159,7 +159,7 @@ export default function VariableForm({
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
{fields.map((field, index) => (
|
{fields.map((field, index) => (
|
||||||
<div key={field.id} className="flex flex-col space-y-2">
|
<div key={field.id} className="relative flex flex-col space-y-2">
|
||||||
<Controller
|
<Controller
|
||||||
name={`fields.${index}.value`}
|
name={`fields.${index}.value`}
|
||||||
control={control}
|
control={control}
|
||||||
|
|
@ -171,7 +171,7 @@ export default function VariableForm({
|
||||||
placeholder={field.config.variable}
|
placeholder={field.config.variable}
|
||||||
className={cn(
|
className={cn(
|
||||||
defaultTextProps,
|
defaultTextProps,
|
||||||
'rounded px-3 py-2 focus:bg-surface-tertiary',
|
'mb-1 rounded px-3 py-2 focus:bg-surface-tertiary',
|
||||||
)}
|
)}
|
||||||
value={value}
|
value={value}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
|
|
@ -181,20 +181,28 @@ export default function VariableForm({
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TextareaAutosize
|
<>
|
||||||
ref={ref}
|
<TextareaAutosize
|
||||||
value={value}
|
ref={ref}
|
||||||
onChange={onChange}
|
value={value}
|
||||||
onBlur={onBlur}
|
onChange={onChange}
|
||||||
id={`fields.${index}.value`}
|
onBlur={onBlur}
|
||||||
className={cn(
|
id={`fields.${index}.value`}
|
||||||
defaultTextProps,
|
className={cn(
|
||||||
'rounded px-3 py-2 focus:bg-surface-tertiary',
|
defaultTextProps,
|
||||||
)}
|
'peer rounded px-3 py-2 focus:bg-surface-tertiary',
|
||||||
placeholder={field.config.variable}
|
)}
|
||||||
maxRows={8}
|
placeholder=""
|
||||||
aria-label={field.config.variable}
|
maxRows={8}
|
||||||
/>
|
aria-label={field.config.variable}
|
||||||
|
/>
|
||||||
|
<label
|
||||||
|
htmlFor={`fields.${index}.value`}
|
||||||
|
className="absolute left-3 top-0 text-sm text-text-secondary transition-all duration-200 peer-focus:-top-6 peer-focus:left-1 peer-focus:text-xs peer-focus:text-text-primary peer-[:not(:placeholder-shown)]:-top-6 peer-[:not(:placeholder-shown)]:left-1 peer-[:not(:placeholder-shown)]:text-xs"
|
||||||
|
>
|
||||||
|
{field.config.variable}
|
||||||
|
</label>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,19 @@ const PreviewPrompt = ({
|
||||||
group,
|
group,
|
||||||
open,
|
open,
|
||||||
onOpenChange,
|
onOpenChange,
|
||||||
|
onCloseAutoFocus,
|
||||||
}: {
|
}: {
|
||||||
group: TPromptGroup;
|
group: TPromptGroup;
|
||||||
open: boolean;
|
open: boolean;
|
||||||
onOpenChange: (open: boolean) => void;
|
onOpenChange: (open: boolean) => void;
|
||||||
|
onCloseAutoFocus?: () => void;
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<OGDialog open={open} onOpenChange={onOpenChange}>
|
<OGDialog open={open} onOpenChange={onOpenChange}>
|
||||||
<OGDialogContent className="max-h-[90vh] w-11/12 max-w-full overflow-y-auto md:max-w-[60vw]">
|
<OGDialogContent
|
||||||
|
className="max-h-[90vh] w-11/12 max-w-full overflow-y-auto md:max-w-[60vw]"
|
||||||
|
onCloseAutoFocus={onCloseAutoFocus}
|
||||||
|
>
|
||||||
<div>
|
<div>
|
||||||
<PromptDetails group={group} />
|
<PromptDetails group={group} />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ const PromptVariables = ({
|
||||||
<span className="text-sm font-medium text-text-primary">
|
<span className="text-sm font-medium text-text-primary">
|
||||||
{localize('com_ui_dropdown_variables')}
|
{localize('com_ui_dropdown_variables')}
|
||||||
</span>
|
</span>
|
||||||
<span className="text-sm text-text-secondary">
|
<span className="break-words text-sm text-text-secondary">
|
||||||
<ReactMarkdown components={components} className="markdown prose dark:prose-invert">
|
<ReactMarkdown components={components} className="markdown prose dark:prose-invert">
|
||||||
{localize('com_ui_dropdown_variables_info')}
|
{localize('com_ui_dropdown_variables_info')}
|
||||||
</ReactMarkdown>
|
</ReactMarkdown>
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,24 @@
|
||||||
import { useMemo, useEffect } from 'react';
|
import { useMemo, useEffect, useState, useCallback, useRef } from 'react';
|
||||||
import { Outlet, useParams, useNavigate } from 'react-router-dom';
|
import { Outlet, useParams, useNavigate } from 'react-router-dom';
|
||||||
import { PermissionTypes, Permissions } from 'librechat-data-provider';
|
import { PermissionTypes, Permissions } from 'librechat-data-provider';
|
||||||
import FilterPrompts from '~/components/Prompts/Groups/FilterPrompts';
|
import FilterPrompts from '~/components/Prompts/Groups/FilterPrompts';
|
||||||
import DashBreadcrumb from '~/routes/Layouts/DashBreadcrumb';
|
import DashBreadcrumb from '~/routes/Layouts/DashBreadcrumb';
|
||||||
import GroupSidePanel from './Groups/GroupSidePanel';
|
import GroupSidePanel from './Groups/GroupSidePanel';
|
||||||
|
import { useHasAccess, useLocalize } from '~/hooks';
|
||||||
import { PromptGroupsProvider } from '~/Providers';
|
import { PromptGroupsProvider } from '~/Providers';
|
||||||
import { useHasAccess } from '~/hooks';
|
import { useMediaQuery } from '@librechat/client';
|
||||||
import { cn } from '~/utils';
|
import { cn } from '~/utils';
|
||||||
|
|
||||||
export default function PromptsView() {
|
export default function PromptsView() {
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const isDetailView = useMemo(() => !!(params.promptId || params['*'] === 'new'), [params]);
|
const isDetailView = useMemo(() => !!(params.promptId || params['*'] === 'new'), [params]);
|
||||||
|
const isSmallerScreen = useMediaQuery('(max-width: 768px)');
|
||||||
|
const [panelVisible, setPanelVisible] = useState(!isSmallerScreen);
|
||||||
|
const openPanelRef = useRef<HTMLButtonElement>(null);
|
||||||
|
const closePanelRef = useRef<HTMLButtonElement>(null);
|
||||||
|
const localize = useLocalize();
|
||||||
|
|
||||||
const hasAccess = useHasAccess({
|
const hasAccess = useHasAccess({
|
||||||
permissionType: PermissionTypes.PROMPTS,
|
permissionType: PermissionTypes.PROMPTS,
|
||||||
permission: Permissions.USE,
|
permission: Permissions.USE,
|
||||||
|
|
@ -29,6 +36,26 @@ export default function PromptsView() {
|
||||||
};
|
};
|
||||||
}, [hasAccess, navigate]);
|
}, [hasAccess, navigate]);
|
||||||
|
|
||||||
|
const togglePanel = useCallback(() => {
|
||||||
|
setPanelVisible((prev) => {
|
||||||
|
const newValue = !prev;
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
if (newValue) {
|
||||||
|
closePanelRef?.current?.focus();
|
||||||
|
} else {
|
||||||
|
openPanelRef?.current?.focus();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return newValue;
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isSmallerScreen && isDetailView) {
|
||||||
|
setPanelVisible(false);
|
||||||
|
}
|
||||||
|
}, [isSmallerScreen, isDetailView]);
|
||||||
|
|
||||||
if (!hasAccess) {
|
if (!hasAccess) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
@ -36,13 +63,42 @@ export default function PromptsView() {
|
||||||
return (
|
return (
|
||||||
<PromptGroupsProvider>
|
<PromptGroupsProvider>
|
||||||
<div className="flex h-screen w-full flex-col bg-surface-primary p-0 lg:p-2">
|
<div className="flex h-screen w-full flex-col bg-surface-primary p-0 lg:p-2">
|
||||||
<DashBreadcrumb />
|
<DashBreadcrumb
|
||||||
<div className="flex w-full flex-grow flex-row divide-x overflow-hidden dark:divide-gray-600">
|
showToggle={isSmallerScreen && isDetailView}
|
||||||
<GroupSidePanel isDetailView={isDetailView}>
|
onToggle={togglePanel}
|
||||||
<div className="mt-1 flex flex-row items-center justify-between px-2 md:px-2">
|
openPanelRef={openPanelRef}
|
||||||
<FilterPrompts />
|
/>
|
||||||
|
<div className="flex w-full flex-grow flex-row overflow-hidden">
|
||||||
|
{isSmallerScreen && panelVisible && isDetailView && (
|
||||||
|
<div
|
||||||
|
className="fixed inset-0 z-40 bg-black/50 transition-opacity"
|
||||||
|
onClick={togglePanel}
|
||||||
|
role="button"
|
||||||
|
tabIndex={0}
|
||||||
|
aria-label={localize('com_nav_toggle_sidebar')}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{(!isSmallerScreen || !isDetailView || panelVisible) && (
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
'transition-transform duration-300 ease-in-out',
|
||||||
|
isSmallerScreen && isDetailView
|
||||||
|
? 'fixed left-0 top-0 z-50 h-full w-[320px] bg-surface-primary'
|
||||||
|
: 'flex',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<GroupSidePanel
|
||||||
|
closePanelRef={closePanelRef}
|
||||||
|
onClose={isSmallerScreen && isDetailView ? togglePanel : undefined}
|
||||||
|
>
|
||||||
|
<div className="mt-1 flex flex-row items-center justify-between px-2 md:px-2">
|
||||||
|
<FilterPrompts />
|
||||||
|
</div>
|
||||||
|
</GroupSidePanel>
|
||||||
</div>
|
</div>
|
||||||
</GroupSidePanel>
|
)}
|
||||||
|
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
'scrollbar-gutter-stable w-full overflow-y-auto lg:w-3/4 xl:w-3/4',
|
'scrollbar-gutter-stable w-full overflow-y-auto lg:w-3/4 xl:w-3/4',
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { useRef } from 'react';
|
||||||
import { KeyRoundIcon } from 'lucide-react';
|
import { KeyRoundIcon } from 'lucide-react';
|
||||||
import { AuthType, AgentCapabilities } from 'librechat-data-provider';
|
import { AuthType, AgentCapabilities } from 'librechat-data-provider';
|
||||||
import { useFormContext, Controller, useWatch } from 'react-hook-form';
|
import { useFormContext, Controller, useWatch } from 'react-hook-form';
|
||||||
|
|
@ -17,7 +18,8 @@ import { ESide } from '~/common';
|
||||||
export default function Action({ authType = '', isToolAuthenticated = false }) {
|
export default function Action({ authType = '', isToolAuthenticated = false }) {
|
||||||
const localize = useLocalize();
|
const localize = useLocalize();
|
||||||
const methods = useFormContext<AgentForm>();
|
const methods = useFormContext<AgentForm>();
|
||||||
const { control, setValue, getValues } = methods;
|
const { control, setValue } = methods;
|
||||||
|
const apiKeyButtonRef = useRef<HTMLButtonElement>(null);
|
||||||
const {
|
const {
|
||||||
onSubmit,
|
onSubmit,
|
||||||
isDialogOpen,
|
isDialogOpen,
|
||||||
|
|
@ -27,9 +29,11 @@ export default function Action({ authType = '', isToolAuthenticated = false }) {
|
||||||
} = useCodeApiKeyForm({
|
} = useCodeApiKeyForm({
|
||||||
onSubmit: () => {
|
onSubmit: () => {
|
||||||
setValue(AgentCapabilities.execute_code, true, { shouldDirty: true });
|
setValue(AgentCapabilities.execute_code, true, { shouldDirty: true });
|
||||||
|
setTimeout(() => apiKeyButtonRef.current?.focus(), 100);
|
||||||
},
|
},
|
||||||
onRevoke: () => {
|
onRevoke: () => {
|
||||||
setValue(AgentCapabilities.execute_code, false, { shouldDirty: true });
|
setValue(AgentCapabilities.execute_code, false, { shouldDirty: true });
|
||||||
|
setTimeout(() => apiKeyButtonRef.current?.focus(), 100);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -56,42 +60,44 @@ export default function Action({ authType = '', isToolAuthenticated = false }) {
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<Checkbox
|
<Checkbox
|
||||||
{...field}
|
{...field}
|
||||||
|
id="execute-code-checkbox"
|
||||||
checked={runCodeIsEnabled ? runCodeIsEnabled : isToolAuthenticated && field.value}
|
checked={runCodeIsEnabled ? runCodeIsEnabled : isToolAuthenticated && field.value}
|
||||||
onCheckedChange={handleCheckboxChange}
|
onCheckedChange={handleCheckboxChange}
|
||||||
className="relative float-left mr-2 inline-flex h-4 w-4 cursor-pointer"
|
className="relative float-left mr-2 inline-flex h-4 w-4 cursor-pointer"
|
||||||
value={field.value.toString()}
|
value={field.value.toString()}
|
||||||
disabled={runCodeIsEnabled ? false : !isToolAuthenticated}
|
disabled={runCodeIsEnabled ? false : !isToolAuthenticated}
|
||||||
aria-label={localize('com_ui_run_code')}
|
aria-labelledby="execute-code-label"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<button
|
<label
|
||||||
type="button"
|
id="execute-code-label"
|
||||||
className="flex items-center space-x-2"
|
htmlFor="execute-code-checkbox"
|
||||||
onClick={() => {
|
className="form-check-label text-token-text-primary cursor-pointer"
|
||||||
const value = !getValues(AgentCapabilities.execute_code);
|
|
||||||
handleCheckboxChange(value);
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<label
|
{localize('com_ui_run_code')}
|
||||||
className="form-check-label text-token-text-primary w-full cursor-pointer"
|
</label>
|
||||||
htmlFor={AgentCapabilities.execute_code}
|
|
||||||
>
|
|
||||||
{localize('com_ui_run_code')}
|
|
||||||
</label>
|
|
||||||
</button>
|
|
||||||
<div className="ml-2 flex gap-2">
|
<div className="ml-2 flex gap-2">
|
||||||
{isUserProvided && (isToolAuthenticated || runCodeIsEnabled) && (
|
{isUserProvided && (
|
||||||
<button
|
<button
|
||||||
|
ref={apiKeyButtonRef}
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => setIsDialogOpen(true)}
|
onClick={() => setIsDialogOpen(true)}
|
||||||
aria-label={localize('com_ui_add_api_key')}
|
aria-label={localize('com_ui_add_code_interpreter_api_key')}
|
||||||
|
aria-haspopup="dialog"
|
||||||
|
aria-expanded={isDialogOpen}
|
||||||
>
|
>
|
||||||
<KeyRoundIcon className="h-5 w-5 text-text-primary" />
|
<KeyRoundIcon className="h-5 w-5 text-text-primary" />
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
<HoverCardTrigger>
|
<HoverCardTrigger asChild>
|
||||||
<CircleHelpIcon className="h-4 w-4 text-text-tertiary" />
|
<button
|
||||||
|
type="button"
|
||||||
|
className="inline-flex items-center"
|
||||||
|
aria-label={localize('com_agents_code_interpreter')}
|
||||||
|
>
|
||||||
|
<CircleHelpIcon className="h-4 w-4 text-text-tertiary" />
|
||||||
|
</button>
|
||||||
</HoverCardTrigger>
|
</HoverCardTrigger>
|
||||||
</div>
|
</div>
|
||||||
<HoverCardPortal>
|
<HoverCardPortal>
|
||||||
|
|
@ -114,6 +120,7 @@ export default function Action({ authType = '', isToolAuthenticated = false }) {
|
||||||
isToolAuthenticated={isToolAuthenticated}
|
isToolAuthenticated={isToolAuthenticated}
|
||||||
handleSubmit={keyFormMethods.handleSubmit}
|
handleSubmit={keyFormMethods.handleSubmit}
|
||||||
isUserProvided={authType === AuthType.USER_PROVIDED}
|
isUserProvided={authType === AuthType.USER_PROVIDED}
|
||||||
|
triggerRef={apiKeyButtonRef}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ import { ESide } from '~/common';
|
||||||
function FileSearchCheckbox() {
|
function FileSearchCheckbox() {
|
||||||
const localize = useLocalize();
|
const localize = useLocalize();
|
||||||
const methods = useFormContext<AgentForm>();
|
const methods = useFormContext<AgentForm>();
|
||||||
const { control, setValue, getValues } = methods;
|
const { control } = methods;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
@ -28,33 +28,31 @@ function FileSearchCheckbox() {
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<Checkbox
|
<Checkbox
|
||||||
{...field}
|
{...field}
|
||||||
|
id="file-search-checkbox"
|
||||||
checked={field.value}
|
checked={field.value}
|
||||||
onCheckedChange={field.onChange}
|
onCheckedChange={field.onChange}
|
||||||
className="relative float-left mr-2 inline-flex h-4 w-4 cursor-pointer"
|
className="relative float-left mr-2 inline-flex h-4 w-4 cursor-pointer"
|
||||||
value={field.value.toString()}
|
value={field.value.toString()}
|
||||||
aria-label={localize('com_agents_enable_file_search')}
|
aria-labelledby="file-search-label"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<button
|
<label
|
||||||
type="button"
|
id="file-search-label"
|
||||||
className="flex items-center space-x-2"
|
htmlFor="file-search-checkbox"
|
||||||
onClick={() =>
|
className="form-check-label text-token-text-primary cursor-pointer"
|
||||||
setValue(AgentCapabilities.file_search, !getValues(AgentCapabilities.file_search), {
|
|
||||||
shouldDirty: true,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<label
|
{localize('com_agents_enable_file_search')}
|
||||||
className="form-check-label text-token-text-primary w-full cursor-pointer"
|
</label>
|
||||||
htmlFor={AgentCapabilities.file_search}
|
<HoverCardTrigger asChild className="ml-2">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="inline-flex items-center"
|
||||||
|
aria-label={localize('com_agents_file_search_info')}
|
||||||
>
|
>
|
||||||
{localize('com_agents_enable_file_search')}
|
|
||||||
</label>
|
|
||||||
<HoverCardTrigger>
|
|
||||||
<CircleHelpIcon className="h-4 w-4 text-text-tertiary" />
|
<CircleHelpIcon className="h-4 w-4 text-text-tertiary" />
|
||||||
</HoverCardTrigger>
|
</button>
|
||||||
</button>
|
</HoverCardTrigger>
|
||||||
<HoverCardPortal>
|
<HoverCardPortal>
|
||||||
<HoverCardContent side={ESide.Top} className="w-80">
|
<HoverCardContent side={ESide.Top} className="w-80">
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { KeyRoundIcon } from 'lucide-react';
|
import { KeyRoundIcon } from 'lucide-react';
|
||||||
|
import { useRef } from 'react';
|
||||||
import { AuthType, AgentCapabilities } from 'librechat-data-provider';
|
import { AuthType, AgentCapabilities } from 'librechat-data-provider';
|
||||||
import { useFormContext, Controller, useWatch } from 'react-hook-form';
|
import { useFormContext, Controller, useWatch } from 'react-hook-form';
|
||||||
import {
|
import {
|
||||||
|
|
@ -23,7 +24,8 @@ export default function Action({
|
||||||
}) {
|
}) {
|
||||||
const localize = useLocalize();
|
const localize = useLocalize();
|
||||||
const methods = useFormContext<AgentForm>();
|
const methods = useFormContext<AgentForm>();
|
||||||
const { control, setValue, getValues } = methods;
|
const { control, setValue } = methods;
|
||||||
|
const apiKeyButtonRef = useRef<HTMLButtonElement>(null);
|
||||||
const {
|
const {
|
||||||
onSubmit,
|
onSubmit,
|
||||||
isDialogOpen,
|
isDialogOpen,
|
||||||
|
|
@ -33,9 +35,11 @@ export default function Action({
|
||||||
} = useSearchApiKeyForm({
|
} = useSearchApiKeyForm({
|
||||||
onSubmit: () => {
|
onSubmit: () => {
|
||||||
setValue(AgentCapabilities.web_search, true, { shouldDirty: true });
|
setValue(AgentCapabilities.web_search, true, { shouldDirty: true });
|
||||||
|
setTimeout(() => apiKeyButtonRef.current?.focus(), 100);
|
||||||
},
|
},
|
||||||
onRevoke: () => {
|
onRevoke: () => {
|
||||||
setValue(AgentCapabilities.web_search, false, { shouldDirty: true });
|
setValue(AgentCapabilities.web_search, false, { shouldDirty: true });
|
||||||
|
setTimeout(() => apiKeyButtonRef.current?.focus(), 100);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -62,6 +66,7 @@ export default function Action({
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<Checkbox
|
<Checkbox
|
||||||
{...field}
|
{...field}
|
||||||
|
id="web-search-checkbox"
|
||||||
checked={
|
checked={
|
||||||
webSearchIsEnabled ? webSearchIsEnabled : isToolAuthenticated && field.value
|
webSearchIsEnabled ? webSearchIsEnabled : isToolAuthenticated && field.value
|
||||||
}
|
}
|
||||||
|
|
@ -69,33 +74,37 @@ export default function Action({
|
||||||
className="relative float-left mr-2 inline-flex h-4 w-4 cursor-pointer"
|
className="relative float-left mr-2 inline-flex h-4 w-4 cursor-pointer"
|
||||||
value={field.value.toString()}
|
value={field.value.toString()}
|
||||||
disabled={webSearchIsEnabled ? false : !isToolAuthenticated}
|
disabled={webSearchIsEnabled ? false : !isToolAuthenticated}
|
||||||
aria-label={localize('com_ui_web_search')}
|
aria-labelledby="web-search-label"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<button
|
<label
|
||||||
type="button"
|
id="web-search-label"
|
||||||
className="flex items-center space-x-2"
|
htmlFor="web-search-checkbox"
|
||||||
onClick={() => {
|
className="form-check-label text-token-text-primary cursor-pointer"
|
||||||
const value = !getValues(AgentCapabilities.web_search);
|
|
||||||
handleCheckboxChange(value);
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<label
|
{localize('com_ui_web_search')}
|
||||||
className="form-check-label text-token-text-primary w-full cursor-pointer"
|
</label>
|
||||||
htmlFor={AgentCapabilities.web_search}
|
|
||||||
>
|
|
||||||
{localize('com_ui_web_search')}
|
|
||||||
</label>
|
|
||||||
</button>
|
|
||||||
<div className="ml-2 flex gap-2">
|
<div className="ml-2 flex gap-2">
|
||||||
{isUserProvided && (isToolAuthenticated || webSearchIsEnabled) && (
|
{isUserProvided && (
|
||||||
<button type="button" onClick={() => setIsDialogOpen(true)}>
|
<button
|
||||||
|
ref={apiKeyButtonRef}
|
||||||
|
type="button"
|
||||||
|
onClick={() => setIsDialogOpen(true)}
|
||||||
|
aria-label={localize('com_ui_add_web_search_api_keys')}
|
||||||
|
aria-haspopup="dialog"
|
||||||
|
>
|
||||||
<KeyRoundIcon className="h-5 w-5 text-text-primary" />
|
<KeyRoundIcon className="h-5 w-5 text-text-primary" />
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
<HoverCardTrigger>
|
<HoverCardTrigger asChild>
|
||||||
<CircleHelpIcon className="h-4 w-4 text-text-tertiary" />
|
<button
|
||||||
|
type="button"
|
||||||
|
className="inline-flex items-center"
|
||||||
|
aria-label={localize('com_agents_search_info')}
|
||||||
|
>
|
||||||
|
<CircleHelpIcon className="h-4 w-4 text-text-tertiary" />
|
||||||
|
</button>
|
||||||
</HoverCardTrigger>
|
</HoverCardTrigger>
|
||||||
</div>
|
</div>
|
||||||
<HoverCardPortal>
|
<HoverCardPortal>
|
||||||
|
|
@ -116,6 +125,7 @@ export default function Action({
|
||||||
register={keyFormMethods.register}
|
register={keyFormMethods.register}
|
||||||
isToolAuthenticated={isToolAuthenticated}
|
isToolAuthenticated={isToolAuthenticated}
|
||||||
handleSubmit={keyFormMethods.handleSubmit}
|
handleSubmit={keyFormMethods.handleSubmit}
|
||||||
|
triggerRef={apiKeyButtonRef}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -66,13 +66,21 @@ const BookmarkTable = () => {
|
||||||
return (
|
return (
|
||||||
<BookmarkContext.Provider value={{ bookmarks }}>
|
<BookmarkContext.Provider value={{ bookmarks }}>
|
||||||
<div role="region" aria-label={localize('com_ui_bookmarks')} className="mt-2 space-y-2">
|
<div role="region" aria-label={localize('com_ui_bookmarks')} className="mt-2 space-y-2">
|
||||||
<div className="flex items-center gap-4">
|
<div className="relative flex items-center gap-4">
|
||||||
<Input
|
<Input
|
||||||
placeholder={localize('com_ui_bookmarks_filter')}
|
id="bookmarks-filter"
|
||||||
|
placeholder=" "
|
||||||
value={searchQuery}
|
value={searchQuery}
|
||||||
onChange={(e) => setSearchQuery(e.target.value)}
|
onChange={(e) => setSearchQuery(e.target.value)}
|
||||||
aria-label={localize('com_ui_bookmarks_filter')}
|
aria-label={localize('com_ui_bookmarks_filter')}
|
||||||
|
className="peer"
|
||||||
/>
|
/>
|
||||||
|
<label
|
||||||
|
htmlFor="bookmarks-filter"
|
||||||
|
className="pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-sm text-text-secondary transition-all duration-200 peer-focus:top-0 peer-focus:bg-background peer-focus:px-1 peer-focus:text-xs peer-[:not(:placeholder-shown)]:top-0 peer-[:not(:placeholder-shown)]:bg-background peer-[:not(:placeholder-shown)]:px-1 peer-[:not(:placeholder-shown)]:text-xs"
|
||||||
|
>
|
||||||
|
{localize('com_ui_bookmarks_filter')}
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="rounded-lg border border-border-light bg-transparent shadow-sm transition-colors">
|
<div className="rounded-lg border border-border-light bg-transparent shadow-sm transition-colors">
|
||||||
|
|
|
||||||
|
|
@ -182,13 +182,21 @@ export default function DataTable<TData, TValue>({ columns, data }: DataTablePro
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div role="region" aria-label={localize('com_files_table')} className="mt-2 space-y-2">
|
<div role="region" aria-label={localize('com_files_table')} className="mt-2 space-y-2">
|
||||||
<div className="flex items-center gap-4">
|
<div className="relative flex items-center gap-4">
|
||||||
<Input
|
<Input
|
||||||
placeholder={localize('com_files_filter')}
|
id="filename-filter"
|
||||||
|
placeholder=" "
|
||||||
value={filenameFilter ?? ''}
|
value={filenameFilter ?? ''}
|
||||||
onChange={(event) => table.getColumn('filename')?.setFilterValue(event.target.value)}
|
onChange={(event) => table.getColumn('filename')?.setFilterValue(event.target.value)}
|
||||||
aria-label={localize('com_files_filter')}
|
aria-label={localize('com_files_filter')}
|
||||||
|
className="peer"
|
||||||
/>
|
/>
|
||||||
|
<label
|
||||||
|
htmlFor="filename-filter"
|
||||||
|
className="pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-sm text-text-secondary transition-all duration-200 peer-focus:top-0 peer-focus:bg-background peer-focus:px-1 peer-focus:text-xs peer-[:not(:placeholder-shown)]:top-0 peer-[:not(:placeholder-shown)]:bg-background peer-[:not(:placeholder-shown)]:px-1 peer-[:not(:placeholder-shown)]:text-xs"
|
||||||
|
>
|
||||||
|
{localize('com_files_filter')}
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="rounded-lg border border-border-light bg-transparent shadow-sm transition-colors">
|
<div className="rounded-lg border border-border-light bg-transparent shadow-sm transition-colors">
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ export default function MemoryCreateDialog({
|
||||||
<OGDialogTemplate
|
<OGDialogTemplate
|
||||||
title={localize('com_ui_create_memory')}
|
title={localize('com_ui_create_memory')}
|
||||||
showCloseButton={false}
|
showCloseButton={false}
|
||||||
className="w-11/12 md:max-w-lg"
|
className="max-h-[90vh] w-11/12 overflow-y-auto md:max-w-lg"
|
||||||
main={
|
main={
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
|
|
|
||||||
|
|
@ -301,7 +301,7 @@ export default function MemoryViewer() {
|
||||||
<Switch
|
<Switch
|
||||||
checked={referenceSavedMemories}
|
checked={referenceSavedMemories}
|
||||||
onCheckedChange={handleMemoryToggle}
|
onCheckedChange={handleMemoryToggle}
|
||||||
aria-label={localize('com_ui_reference_saved_memories')}
|
aria-label={localize('com_ui_use_memory')}
|
||||||
disabled={updateMemoryPreferencesMutation.isLoading}
|
disabled={updateMemoryPreferencesMutation.isLoading}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -378,9 +378,12 @@
|
||||||
"com_files_downloading": "Downloading Files",
|
"com_files_downloading": "Downloading Files",
|
||||||
"com_files_filter": "Filter files...",
|
"com_files_filter": "Filter files...",
|
||||||
"com_files_filter_by": "Filter files by...",
|
"com_files_filter_by": "Filter files by...",
|
||||||
|
"com_files_filter_input": "Filter listed files by name...",
|
||||||
"com_files_no_results": "No results.",
|
"com_files_no_results": "No results.",
|
||||||
"com_files_number_selected": "{{0}} of {{1}} items(s) selected",
|
"com_files_number_selected": "{{0}} of {{1}} items(s) selected",
|
||||||
"com_files_preparing_download": "Preparing download...",
|
"com_files_preparing_download": "Preparing download...",
|
||||||
|
"com_files_result_found": "{{count}} result found",
|
||||||
|
"com_files_results_found": "{{count}} results found",
|
||||||
"com_files_sharepoint_picker_title": "Pick Files",
|
"com_files_sharepoint_picker_title": "Pick Files",
|
||||||
"com_files_table": "something needs to go here. was empty",
|
"com_files_table": "something needs to go here. was empty",
|
||||||
"com_files_upload_local_machine": "From Local Computer",
|
"com_files_upload_local_machine": "From Local Computer",
|
||||||
|
|
@ -392,6 +395,7 @@
|
||||||
"com_nav_account_settings": "Account Settings",
|
"com_nav_account_settings": "Account Settings",
|
||||||
"com_nav_always_make_prod": "Always make new versions production",
|
"com_nav_always_make_prod": "Always make new versions production",
|
||||||
"com_nav_archive_created_at": "Date Archived",
|
"com_nav_archive_created_at": "Date Archived",
|
||||||
|
"com_nav_archive_created_at_sort": "Sort by Date Archived",
|
||||||
"com_nav_archive_name": "Name",
|
"com_nav_archive_name": "Name",
|
||||||
"com_nav_archived_chats": "Archived chats",
|
"com_nav_archived_chats": "Archived chats",
|
||||||
"com_nav_at_command": "@-Command",
|
"com_nav_at_command": "@-Command",
|
||||||
|
|
@ -568,6 +572,7 @@
|
||||||
"com_nav_theme_dark": "Dark",
|
"com_nav_theme_dark": "Dark",
|
||||||
"com_nav_theme_light": "Light",
|
"com_nav_theme_light": "Light",
|
||||||
"com_nav_theme_system": "System",
|
"com_nav_theme_system": "System",
|
||||||
|
"com_nav_toggle_sidebar": "Toggle sidebar",
|
||||||
"com_nav_tool_dialog": "Assistant Tools",
|
"com_nav_tool_dialog": "Assistant Tools",
|
||||||
"com_nav_tool_dialog_agents": "Agent Tools",
|
"com_nav_tool_dialog_agents": "Agent Tools",
|
||||||
"com_nav_tool_dialog_description": "Assistant must be saved to persist tool selections.",
|
"com_nav_tool_dialog_description": "Assistant must be saved to persist tool selections.",
|
||||||
|
|
@ -619,7 +624,8 @@
|
||||||
"com_ui_action_button": "Action Button",
|
"com_ui_action_button": "Action Button",
|
||||||
"com_ui_active": "Active",
|
"com_ui_active": "Active",
|
||||||
"com_ui_add": "Add",
|
"com_ui_add": "Add",
|
||||||
"com_ui_add_api_key": "Add API Key",
|
"com_ui_add_code_interpreter_api_key": "Add Code Interpreter API Key",
|
||||||
|
"com_ui_add_web_search_api_keys": "Add Web Search API Keys",
|
||||||
"com_ui_add_mcp": "Add MCP",
|
"com_ui_add_mcp": "Add MCP",
|
||||||
"com_ui_add_mcp_server": "Add MCP Server",
|
"com_ui_add_mcp_server": "Add MCP Server",
|
||||||
"com_ui_add_model_preset": "Add a model or preset for an additional response",
|
"com_ui_add_model_preset": "Add a model or preset for an additional response",
|
||||||
|
|
@ -794,6 +800,7 @@
|
||||||
"com_ui_controls": "Controls",
|
"com_ui_controls": "Controls",
|
||||||
"com_ui_contact_admin_if_issue_persists": "Contact the Admin if the issue persists",
|
"com_ui_contact_admin_if_issue_persists": "Contact the Admin if the issue persists",
|
||||||
"com_ui_conversation_label": "{{title}} conversation",
|
"com_ui_conversation_label": "{{title}} conversation",
|
||||||
|
"com_ui_convo_archived": "Conversation archived",
|
||||||
"com_ui_convo_delete_error": "Failed to delete conversation",
|
"com_ui_convo_delete_error": "Failed to delete conversation",
|
||||||
"com_ui_convo_delete_success": "Conversation successfully deleted",
|
"com_ui_convo_delete_success": "Conversation successfully deleted",
|
||||||
"com_ui_copied": "Copied!",
|
"com_ui_copied": "Copied!",
|
||||||
|
|
@ -811,7 +818,9 @@
|
||||||
"com_ui_create_memory": "Create Memory",
|
"com_ui_create_memory": "Create Memory",
|
||||||
"com_ui_create_new_agent": "Create New Agent",
|
"com_ui_create_new_agent": "Create New Agent",
|
||||||
"com_ui_create_prompt": "Create Prompt",
|
"com_ui_create_prompt": "Create Prompt",
|
||||||
|
"com_ui_create_prompt_page": "New Prompt Configuration Page",
|
||||||
"com_ui_creating_image": "Creating image. May take a moment",
|
"com_ui_creating_image": "Creating image. May take a moment",
|
||||||
|
"com_ui_creation_date_sort": "Sort by Creation Date",
|
||||||
"com_ui_current": "Current",
|
"com_ui_current": "Current",
|
||||||
"com_ui_currently_production": "Currently in production",
|
"com_ui_currently_production": "Currently in production",
|
||||||
"com_ui_custom": "Custom",
|
"com_ui_custom": "Custom",
|
||||||
|
|
@ -1007,6 +1016,8 @@
|
||||||
"com_ui_librechat_code_api_key": "Get your LibreChat Code Interpreter API key",
|
"com_ui_librechat_code_api_key": "Get your LibreChat Code Interpreter API key",
|
||||||
"com_ui_librechat_code_api_subtitle": "Secure. Multi-language. Input/Output Files.",
|
"com_ui_librechat_code_api_subtitle": "Secure. Multi-language. Input/Output Files.",
|
||||||
"com_ui_librechat_code_api_title": "Run AI Code",
|
"com_ui_librechat_code_api_title": "Run AI Code",
|
||||||
|
"com_ui_link_copied": "Link copied",
|
||||||
|
"com_ui_link_refreshed": "Link refreshed",
|
||||||
"com_ui_loading": "Loading...",
|
"com_ui_loading": "Loading...",
|
||||||
"com_ui_locked": "Locked",
|
"com_ui_locked": "Locked",
|
||||||
"com_ui_logo": "{{0}} Logo",
|
"com_ui_logo": "{{0}} Logo",
|
||||||
|
|
@ -1059,6 +1070,7 @@
|
||||||
"com_ui_more_info": "More info",
|
"com_ui_more_info": "More info",
|
||||||
"com_ui_my_prompts": "My Prompts",
|
"com_ui_my_prompts": "My Prompts",
|
||||||
"com_ui_name": "Name",
|
"com_ui_name": "Name",
|
||||||
|
"com_ui_name_sort": "Sort by Name",
|
||||||
"com_ui_new": "New",
|
"com_ui_new": "New",
|
||||||
"com_ui_new_chat": "New chat",
|
"com_ui_new_chat": "New chat",
|
||||||
"com_ui_new_conversation_title": "New Conversation Title",
|
"com_ui_new_conversation_title": "New Conversation Title",
|
||||||
|
|
@ -1110,6 +1122,8 @@
|
||||||
"com_ui_privacy_policy": "Privacy policy",
|
"com_ui_privacy_policy": "Privacy policy",
|
||||||
"com_ui_privacy_policy_url": "Privacy Policy URL",
|
"com_ui_privacy_policy_url": "Privacy Policy URL",
|
||||||
"com_ui_prompt": "Prompt",
|
"com_ui_prompt": "Prompt",
|
||||||
|
"com_ui_prompt_group_button": "{{name}} prompt, {{category}} category",
|
||||||
|
"com_ui_prompt_group_button_no_category": "{{name}} prompt",
|
||||||
"com_ui_prompt_groups": "Prompt Groups List",
|
"com_ui_prompt_groups": "Prompt Groups List",
|
||||||
"com_ui_prompt_input": "Prompt input",
|
"com_ui_prompt_input": "Prompt input",
|
||||||
"com_ui_prompt_input_field": "Prompt text input field",
|
"com_ui_prompt_input_field": "Prompt text input field",
|
||||||
|
|
@ -1152,6 +1166,8 @@
|
||||||
"com_ui_resource": "resource",
|
"com_ui_resource": "resource",
|
||||||
"com_ui_response": "Response",
|
"com_ui_response": "Response",
|
||||||
"com_ui_result": "Result",
|
"com_ui_result": "Result",
|
||||||
|
"com_ui_result_found": "{{count}} result found",
|
||||||
|
"com_ui_results_found": "{{count}} results found",
|
||||||
"com_ui_revoke": "Revoke",
|
"com_ui_revoke": "Revoke",
|
||||||
"com_ui_revoke_info": "Revoke all user provided credentials",
|
"com_ui_revoke_info": "Revoke all user provided credentials",
|
||||||
"com_ui_revoke_key_confirm": "Are you sure you want to revoke this key?",
|
"com_ui_revoke_key_confirm": "Are you sure you want to revoke this key?",
|
||||||
|
|
@ -1258,6 +1274,9 @@
|
||||||
"com_ui_opens_new_tab": "(opens in new tab)",
|
"com_ui_opens_new_tab": "(opens in new tab)",
|
||||||
"com_ui_thinking": "Thinking...",
|
"com_ui_thinking": "Thinking...",
|
||||||
"com_ui_thoughts": "Thoughts",
|
"com_ui_thoughts": "Thoughts",
|
||||||
|
"com_ui_toggle_theme": "Toggle theme",
|
||||||
|
"com_ui_dark_theme_enabled": "Dark theme enabled",
|
||||||
|
"com_ui_light_theme_enabled": "Light theme enabled",
|
||||||
"com_ui_token": "token",
|
"com_ui_token": "token",
|
||||||
"com_ui_token_exchange_method": "Token Exchange Method",
|
"com_ui_token_exchange_method": "Token Exchange Method",
|
||||||
"com_ui_token_url": "Token URL",
|
"com_ui_token_url": "Token URL",
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
import { useMemo, useCallback } from 'react';
|
import { useMemo, useCallback } from 'react';
|
||||||
|
import { useSetRecoilState } from 'recoil';
|
||||||
import { useLocation } from 'react-router-dom';
|
import { useLocation } from 'react-router-dom';
|
||||||
import { SystemRoles } from 'librechat-data-provider';
|
import { SystemRoles } from 'librechat-data-provider';
|
||||||
import { useRecoilValue, useSetRecoilState } from 'recoil';
|
|
||||||
import { ArrowLeft, MessageSquareQuote } from 'lucide-react';
|
import { ArrowLeft, MessageSquareQuote } from 'lucide-react';
|
||||||
|
import { Sidebar } from '@librechat/client';
|
||||||
import {
|
import {
|
||||||
Breadcrumb,
|
Breadcrumb,
|
||||||
BreadcrumbItem,
|
BreadcrumbItem,
|
||||||
|
|
@ -33,7 +34,15 @@ const getConversationId = (prevLocationPath: string) => {
|
||||||
return lastPathnameParts[lastPathnameParts.length - 1];
|
return lastPathnameParts[lastPathnameParts.length - 1];
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function DashBreadcrumb() {
|
export default function DashBreadcrumb({
|
||||||
|
showToggle = false,
|
||||||
|
onToggle,
|
||||||
|
openPanelRef,
|
||||||
|
}: {
|
||||||
|
showToggle?: boolean;
|
||||||
|
onToggle?: () => void;
|
||||||
|
openPanelRef?: React.RefObject<HTMLButtonElement>;
|
||||||
|
}) {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const localize = useLocalize();
|
const localize = useLocalize();
|
||||||
const { user } = useAuthContext();
|
const { user } = useAuthContext();
|
||||||
|
|
@ -42,7 +51,6 @@ export default function DashBreadcrumb() {
|
||||||
|
|
||||||
const setPromptsName = useSetRecoilState(store.promptsName);
|
const setPromptsName = useSetRecoilState(store.promptsName);
|
||||||
const setPromptsCategory = useSetRecoilState(store.promptsCategory);
|
const setPromptsCategory = useSetRecoilState(store.promptsCategory);
|
||||||
const editorMode = useRecoilValue(store.promptsEditorMode);
|
|
||||||
|
|
||||||
const clickCallback = useCallback(() => {
|
const clickCallback = useCallback(() => {
|
||||||
setPromptsName('');
|
setPromptsName('');
|
||||||
|
|
@ -61,6 +69,24 @@ export default function DashBreadcrumb() {
|
||||||
<div className="mr-2 mt-2 flex h-10 items-center justify-between">
|
<div className="mr-2 mt-2 flex h-10 items-center justify-between">
|
||||||
<Breadcrumb className="mt-1 px-2 dark:text-gray-200">
|
<Breadcrumb className="mt-1 px-2 dark:text-gray-200">
|
||||||
<BreadcrumbList>
|
<BreadcrumbList>
|
||||||
|
{showToggle && onToggle && (
|
||||||
|
<>
|
||||||
|
<BreadcrumbItem>
|
||||||
|
<button
|
||||||
|
ref={openPanelRef}
|
||||||
|
type="button"
|
||||||
|
onClick={onToggle}
|
||||||
|
className="flex h-8 w-8 items-center justify-center rounded-lg border border-border-medium bg-surface-primary text-text-primary transition-all hover:bg-surface-hover"
|
||||||
|
aria-label={localize('com_nav_open_sidebar')}
|
||||||
|
aria-expanded={false}
|
||||||
|
aria-controls="prompts-panel"
|
||||||
|
>
|
||||||
|
<Sidebar className="h-4 w-4" />
|
||||||
|
</button>
|
||||||
|
</BreadcrumbItem>
|
||||||
|
<BreadcrumbSeparator />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
<BreadcrumbItem className="hover:dark:text-white">
|
<BreadcrumbItem className="hover:dark:text-white">
|
||||||
<BreadcrumbLink
|
<BreadcrumbLink
|
||||||
href="/"
|
href="/"
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect, useRef } from 'react';
|
||||||
import { Outlet } from 'react-router-dom';
|
import { Outlet } from 'react-router-dom';
|
||||||
import type { ContextType } from '~/common';
|
import type { ContextType } from '~/common';
|
||||||
import {
|
import {
|
||||||
|
|
@ -28,6 +28,8 @@ export default function Root() {
|
||||||
const savedNavVisible = localStorage.getItem('navVisible');
|
const savedNavVisible = localStorage.getItem('navVisible');
|
||||||
return savedNavVisible !== null ? JSON.parse(savedNavVisible) : true;
|
return savedNavVisible !== null ? JSON.parse(savedNavVisible) : true;
|
||||||
});
|
});
|
||||||
|
const openSidebarRef = useRef<HTMLButtonElement>(null);
|
||||||
|
const closeSidebarRef = useRef<HTMLButtonElement>(null);
|
||||||
|
|
||||||
const { isAuthenticated, logout } = useAuthContext();
|
const { isAuthenticated, logout } = useAuthContext();
|
||||||
|
|
||||||
|
|
@ -73,10 +75,24 @@ export default function Root() {
|
||||||
<Banner onHeightChange={setBannerHeight} />
|
<Banner onHeightChange={setBannerHeight} />
|
||||||
<div className="flex" style={{ height: `calc(100dvh - ${bannerHeight}px)` }}>
|
<div className="flex" style={{ height: `calc(100dvh - ${bannerHeight}px)` }}>
|
||||||
<div className="relative z-0 flex h-full w-full overflow-hidden">
|
<div className="relative z-0 flex h-full w-full overflow-hidden">
|
||||||
<Nav navVisible={navVisible} setNavVisible={setNavVisible} />
|
<Nav
|
||||||
|
navVisible={navVisible}
|
||||||
|
setNavVisible={setNavVisible}
|
||||||
|
openSidebarRef={openSidebarRef}
|
||||||
|
closeSidebarRef={closeSidebarRef}
|
||||||
|
/>
|
||||||
<div className="relative flex h-full max-w-full flex-1 flex-col overflow-hidden">
|
<div className="relative flex h-full max-w-full flex-1 flex-col overflow-hidden">
|
||||||
<MobileNav navVisible={navVisible} setNavVisible={setNavVisible} />
|
<MobileNav navVisible={navVisible} setNavVisible={setNavVisible} />
|
||||||
<Outlet context={{ navVisible, setNavVisible } satisfies ContextType} />
|
<Outlet
|
||||||
|
context={
|
||||||
|
{
|
||||||
|
navVisible,
|
||||||
|
setNavVisible,
|
||||||
|
openSidebarRef,
|
||||||
|
closeSidebarRef,
|
||||||
|
} satisfies ContextType
|
||||||
|
}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,17 @@ export interface MenuItemProps {
|
||||||
separate?: boolean;
|
separate?: boolean;
|
||||||
hideOnClick?: boolean;
|
hideOnClick?: boolean;
|
||||||
dialog?: React.ReactElement;
|
dialog?: React.ReactElement;
|
||||||
|
ariaHasPopup?:
|
||||||
|
| boolean
|
||||||
|
| 'dialog'
|
||||||
|
| 'menu'
|
||||||
|
| 'true'
|
||||||
|
| 'false'
|
||||||
|
| 'listbox'
|
||||||
|
| 'tree'
|
||||||
|
| 'grid'
|
||||||
|
| undefined;
|
||||||
|
ariaControls?: string;
|
||||||
ref?: React.Ref<any>;
|
ref?: React.Ref<any>;
|
||||||
render?:
|
render?:
|
||||||
| RenderProp<React.HTMLAttributes<any> & { ref?: React.Ref<any> | undefined }>
|
| RenderProp<React.HTMLAttributes<any> & { ref?: React.Ref<any> | undefined }>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Search } from 'lucide-react';
|
import { Search } from 'lucide-react';
|
||||||
|
import { TranslationKeys, useLocalize } from '~/hooks';
|
||||||
import { cn } from '~/utils';
|
import { cn } from '~/utils';
|
||||||
|
|
||||||
const AnimatedSearchInput = ({
|
const AnimatedSearchInput = ({
|
||||||
|
|
@ -15,6 +16,7 @@ const AnimatedSearchInput = ({
|
||||||
}) => {
|
}) => {
|
||||||
const isSearching = searching === true;
|
const isSearching = searching === true;
|
||||||
const hasValue = value != null && value.length > 0;
|
const hasValue = value != null && value.length > 0;
|
||||||
|
const localize = useLocalize();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="relative w-full">
|
<div className="relative w-full">
|
||||||
|
|
@ -25,7 +27,7 @@ const AnimatedSearchInput = ({
|
||||||
<Search
|
<Search
|
||||||
className={cn(
|
className={cn(
|
||||||
`h-4 w-4 transition-all duration-500 ease-in-out`,
|
`h-4 w-4 transition-all duration-500 ease-in-out`,
|
||||||
isSearching && hasValue ? 'text-blue-400' : 'text-gray-400',
|
isSearching && hasValue ? 'text-blue-400' : 'text-gray-500',
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -36,7 +38,8 @@ const AnimatedSearchInput = ({
|
||||||
value={value}
|
value={value}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
className={`peer relative z-20 w-full rounded-lg bg-surface-secondary px-10 py-2 outline-none backdrop-blur-sm transition-all duration-500 ease-in-out placeholder:text-gray-400 focus:ring-ring`}
|
aria-label={localize('com_ui_search')}
|
||||||
|
className={`peer relative z-20 w-full rounded-lg bg-surface-secondary py-2 pl-10 outline-none backdrop-blur-sm transition-all duration-500 ease-in-out placeholder:text-gray-500 focus:ring-ring`}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Gradient overlay */}
|
{/* Gradient overlay */}
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ import {
|
||||||
} from '@tanstack/react-table';
|
} from '@tanstack/react-table';
|
||||||
import type { Table as TTable } from '@tanstack/react-table';
|
import type { Table as TTable } from '@tanstack/react-table';
|
||||||
import { Table, TableRow, TableBody, TableCell, TableHead, TableHeader } from './Table';
|
import { Table, TableRow, TableBody, TableCell, TableHead, TableHeader } from './Table';
|
||||||
|
import { useMediaQuery, useLocalize, TranslationKeys } from '~/hooks';
|
||||||
import AnimatedSearchInput from './AnimatedSearchInput';
|
import AnimatedSearchInput from './AnimatedSearchInput';
|
||||||
import { useMediaQuery, useLocalize } from '~/hooks';
|
|
||||||
import { TrashIcon, Spinner } from '~/svgs';
|
import { TrashIcon, Spinner } from '~/svgs';
|
||||||
import { Skeleton } from './Skeleton';
|
import { Skeleton } from './Skeleton';
|
||||||
import { Checkbox } from './Checkbox';
|
import { Checkbox } from './Checkbox';
|
||||||
|
|
@ -129,7 +129,7 @@ const TableRowComponent = <TData, TValue>({
|
||||||
)}
|
)}
|
||||||
scope="row"
|
scope="row"
|
||||||
>
|
>
|
||||||
<div className="overflow-hidden text-ellipsis">
|
<div className="overflow-visible text-ellipsis">
|
||||||
{flexRender(cell.column.columnDef.cell, cell.getContext())}
|
{flexRender(cell.column.columnDef.cell, cell.getContext())}
|
||||||
</div>
|
</div>
|
||||||
</TableHead>
|
</TableHead>
|
||||||
|
|
@ -139,13 +139,13 @@ const TableRowComponent = <TData, TValue>({
|
||||||
return (
|
return (
|
||||||
<TableCell
|
<TableCell
|
||||||
key={cell.id}
|
key={cell.id}
|
||||||
className="w-0 max-w-0 px-2 py-1 align-middle text-xs transition-all duration-300 sm:px-4 sm:py-2 sm:text-sm"
|
className="w-0 max-w-0 overflow-visible px-2 py-1 align-middle text-xs transition-all duration-300 sm:px-4 sm:py-2 sm:text-sm"
|
||||||
style={getColumnStyle(
|
style={getColumnStyle(
|
||||||
cell.column.columnDef as TableColumn<TData, TValue>,
|
cell.column.columnDef as TableColumn<TData, TValue>,
|
||||||
isSmallScreen,
|
isSmallScreen,
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div className="overflow-hidden text-ellipsis">
|
<div className="overflow-visible text-ellipsis">
|
||||||
{flexRender(cell.column.columnDef.cell, cell.getContext())}
|
{flexRender(cell.column.columnDef.cell, cell.getContext())}
|
||||||
</div>
|
</div>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
|
@ -234,6 +234,7 @@ export default function DataTable<TData, TValue>({
|
||||||
const [columnVisibility, setColumnVisibility] = useState<VisibilityState>({});
|
const [columnVisibility, setColumnVisibility] = useState<VisibilityState>({});
|
||||||
const [searchTerm, setSearchTerm] = useState(filterValue ?? '');
|
const [searchTerm, setSearchTerm] = useState(filterValue ?? '');
|
||||||
const [isSearching, setIsSearching] = useState(false);
|
const [isSearching, setIsSearching] = useState(false);
|
||||||
|
const [searchResultsAnnouncement, setSearchResultsAnnouncement] = useState('');
|
||||||
|
|
||||||
const tableColumns = useMemo(() => {
|
const tableColumns = useMemo(() => {
|
||||||
if (!enableRowSelection || !showCheckboxes) {
|
if (!enableRowSelection || !showCheckboxes) {
|
||||||
|
|
@ -331,6 +332,29 @@ export default function DataTable<TData, TValue>({
|
||||||
return () => clearTimeout(timeout);
|
return () => clearTimeout(timeout);
|
||||||
}, [searchTerm, onFilterChange]);
|
}, [searchTerm, onFilterChange]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!searchTerm.trim() || isSearching) {
|
||||||
|
setSearchResultsAnnouncement('');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const resultCount = rows.length;
|
||||||
|
const announcement =
|
||||||
|
resultCount === 1
|
||||||
|
? localize('com_ui_result_found' as TranslationKeys, {
|
||||||
|
count: resultCount,
|
||||||
|
})
|
||||||
|
: localize('com_ui_results_found' as TranslationKeys, {
|
||||||
|
count: resultCount,
|
||||||
|
});
|
||||||
|
|
||||||
|
const timeout = setTimeout(() => {
|
||||||
|
setSearchResultsAnnouncement(announcement);
|
||||||
|
}, 300);
|
||||||
|
|
||||||
|
return () => clearTimeout(timeout);
|
||||||
|
}, [rows.length, searchTerm, isSearching, localize]);
|
||||||
|
|
||||||
const handleDelete = useCallback(async () => {
|
const handleDelete = useCallback(async () => {
|
||||||
if (!onDelete) {
|
if (!onDelete) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -373,6 +397,10 @@ export default function DataTable<TData, TValue>({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={cn('flex h-full flex-col gap-4', className)}>
|
<div className={cn('flex h-full flex-col gap-4', className)}>
|
||||||
|
<div aria-live="assertive" aria-atomic="true" className="sr-only">
|
||||||
|
{searchResultsAnnouncement}
|
||||||
|
</div>
|
||||||
|
|
||||||
{/* Table controls */}
|
{/* Table controls */}
|
||||||
<div className="flex flex-wrap items-center gap-2 sm:gap-4">
|
<div className="flex flex-wrap items-center gap-2 sm:gap-4">
|
||||||
{enableRowSelection && showCheckboxes && (
|
{enableRowSelection && showCheckboxes && (
|
||||||
|
|
@ -400,7 +428,7 @@ export default function DataTable<TData, TValue>({
|
||||||
<div
|
<div
|
||||||
ref={tableContainerRef}
|
ref={tableContainerRef}
|
||||||
className={cn(
|
className={cn(
|
||||||
'relative h-[calc(100vh-20rem)] max-w-full overflow-x-auto overflow-y-auto rounded-md border border-black/10 dark:border-white/10',
|
'relative min-h-0 max-w-full flex-1 overflow-x-auto overflow-y-auto rounded-md border border-black/10 dark:border-white/10',
|
||||||
'transition-all duration-300 ease-out',
|
'transition-all duration-300 ease-out',
|
||||||
isSearching && 'bg-surface-secondary/50',
|
isSearching && 'bg-surface-secondary/50',
|
||||||
className,
|
className,
|
||||||
|
|
|
||||||
|
|
@ -145,6 +145,8 @@ const Menu: React.FC<MenuProps> = ({
|
||||||
render={item.render}
|
render={item.render}
|
||||||
ref={item.ref}
|
ref={item.ref}
|
||||||
hideOnClick={item.hideOnClick}
|
hideOnClick={item.hideOnClick}
|
||||||
|
aria-haspopup={item.ariaHasPopup}
|
||||||
|
aria-controls={item.ariaControls}
|
||||||
onClick={(event) => {
|
onClick={(event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (item.onClick) {
|
if (item.onClick) {
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ const DialogContent = React.forwardRef<
|
||||||
<DialogPrimitive.Content
|
<DialogPrimitive.Content
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className={cn(
|
className={cn(
|
||||||
'max-w-11/12 fixed left-[50%] top-[50%] z-50 grid w-full translate-x-[-50%] translate-y-[-50%] gap-4 rounded-2xl bg-background p-6 text-text-primary shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]',
|
'max-w-11/12 fixed left-[50%] top-[50%] z-50 grid max-h-[90vh] w-full translate-x-[-50%] translate-y-[-50%] gap-4 overflow-y-auto rounded-2xl bg-background p-6 text-text-primary shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]',
|
||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
|
|
@ -80,7 +80,7 @@ const DialogContent = React.forwardRef<
|
||||||
{children}
|
{children}
|
||||||
{showCloseButton && (
|
{showCloseButton && (
|
||||||
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-ring-primary ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
|
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-ring-primary ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
|
||||||
<X className="h-4 w-4" />
|
<X className="h-6 w-6" />
|
||||||
{/* eslint-disable-next-line i18next/no-literal-string */}
|
{/* eslint-disable-next-line i18next/no-literal-string */}
|
||||||
<span className="sr-only">Close</span>
|
<span className="sr-only">Close</span>
|
||||||
</DialogPrimitive.Close>
|
</DialogPrimitive.Close>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import { useContext, useCallback, useEffect, useState } from 'react';
|
import { useContext, useCallback, useEffect, useState } from 'react';
|
||||||
import { Sun, Moon, Monitor } from 'lucide-react';
|
import { Sun, Moon, Monitor } from 'lucide-react';
|
||||||
import { ThemeContext, isDark } from '../theme';
|
import { ThemeContext, isDark } from '../theme';
|
||||||
|
import { useLocalize } from '../hooks';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
|
|
@ -11,6 +12,8 @@ declare global {
|
||||||
type ThemeType = 'system' | 'dark' | 'light';
|
type ThemeType = 'system' | 'dark' | 'light';
|
||||||
|
|
||||||
const Theme = ({ theme, onChange }: { theme: string; onChange: (value: string) => void }) => {
|
const Theme = ({ theme, onChange }: { theme: string; onChange: (value: string) => void }) => {
|
||||||
|
const localize = useLocalize();
|
||||||
|
|
||||||
const themeIcons: Record<ThemeType, JSX.Element> = {
|
const themeIcons: Record<ThemeType, JSX.Element> = {
|
||||||
system: <Monitor />,
|
system: <Monitor />,
|
||||||
dark: <Moon color="white" />,
|
dark: <Moon color="white" />,
|
||||||
|
|
@ -18,7 +21,6 @@ const Theme = ({ theme, onChange }: { theme: string; onChange: (value: string) =
|
||||||
};
|
};
|
||||||
|
|
||||||
const nextTheme = isDark(theme) ? 'light' : 'dark';
|
const nextTheme = isDark(theme) ? 'light' : 'dark';
|
||||||
const label = `Switch to ${nextTheme} theme`;
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleKeyPress = (e: KeyboardEvent) => {
|
const handleKeyPress = (e: KeyboardEvent) => {
|
||||||
|
|
@ -33,8 +35,8 @@ const Theme = ({ theme, onChange }: { theme: string; onChange: (value: string) =
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
className="flex items-center gap-2 rounded-lg p-2 transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2"
|
className="flex items-center gap-2 rounded-lg p-2 transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 dark:focus-visible:ring-0"
|
||||||
aria-label={label}
|
aria-label={localize('com_ui_toggle_theme')}
|
||||||
aria-keyshortcuts="Ctrl+Shift+T"
|
aria-keyshortcuts="Ctrl+Shift+T"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
@ -55,6 +57,7 @@ const Theme = ({ theme, onChange }: { theme: string; onChange: (value: string) =
|
||||||
const ThemeSelector = ({ returnThemeOnly }: { returnThemeOnly?: boolean }) => {
|
const ThemeSelector = ({ returnThemeOnly }: { returnThemeOnly?: boolean }) => {
|
||||||
const { theme, setTheme } = useContext(ThemeContext);
|
const { theme, setTheme } = useContext(ThemeContext);
|
||||||
const [announcement, setAnnouncement] = useState('');
|
const [announcement, setAnnouncement] = useState('');
|
||||||
|
const localize = useLocalize();
|
||||||
|
|
||||||
const changeTheme = useCallback(
|
const changeTheme = useCallback(
|
||||||
(value: string) => {
|
(value: string) => {
|
||||||
|
|
@ -65,9 +68,13 @@ const ThemeSelector = ({ returnThemeOnly }: { returnThemeOnly?: boolean }) => {
|
||||||
window.lastThemeChange = now;
|
window.lastThemeChange = now;
|
||||||
|
|
||||||
setTheme(value);
|
setTheme(value);
|
||||||
setAnnouncement(isDark(value) ? 'Dark theme enabled' : 'Light theme enabled');
|
setAnnouncement(
|
||||||
|
isDark(value)
|
||||||
|
? localize('com_ui_dark_theme_enabled')
|
||||||
|
: localize('com_ui_light_theme_enabled'),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
[setTheme],
|
[setTheme, localize],
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -93,11 +100,9 @@ const ThemeSelector = ({ returnThemeOnly }: { returnThemeOnly?: boolean }) => {
|
||||||
<div className="absolute bottom-0 left-0 m-4">
|
<div className="absolute bottom-0 left-0 m-4">
|
||||||
<Theme theme={theme} onChange={changeTheme} />
|
<Theme theme={theme} onChange={changeTheme} />
|
||||||
</div>
|
</div>
|
||||||
{announcement && (
|
<div role="alert" aria-live="assertive" aria-atomic="true" className="sr-only">
|
||||||
<div aria-live="polite" className="sr-only">
|
{announcement}
|
||||||
{announcement}
|
</div>
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ export function Toast() {
|
||||||
>
|
>
|
||||||
<div className="w-full p-1 text-center md:w-auto md:text-justify">
|
<div className="w-full p-1 text-center md:w-auto md:text-justify">
|
||||||
<div
|
<div
|
||||||
className={`alert-root pointer-events-auto inline-flex flex-row gap-2 rounded-md border px-3 py-2 text-white ${
|
className={`alert-root pointer-events-auto inline-flex flex-row gap-2 rounded-md border px-3 py-2 font-bold text-white ${
|
||||||
severityClassName[toast.severity]
|
severityClassName[toast.severity]
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -3,5 +3,9 @@
|
||||||
"com_ui_no_options": "No options available",
|
"com_ui_no_options": "No options available",
|
||||||
"com_ui_delete_selected_items": "Delete selected items",
|
"com_ui_delete_selected_items": "Delete selected items",
|
||||||
"com_ui_filter_by": "Filter by {{title}}",
|
"com_ui_filter_by": "Filter by {{title}}",
|
||||||
"com_ui_cancel_dialog": "Cancel dialog"
|
"com_ui_cancel_dialog": "Cancel dialog",
|
||||||
|
"com_ui_toggle_theme": "Toggle theme",
|
||||||
|
"com_ui_dark_theme_enabled": "Dark theme enabled",
|
||||||
|
"com_ui_light_theme_enabled": "Light theme enabled",
|
||||||
|
"com_ui_search": "Search..."
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue