mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 17:00:15 +01:00
* refactor(useDebouncedInput): make object as input arg and accept setter
* refactor(ChatForm/Textarea): consolidate textarea/form logic to one component, use react-hook-form, programmatically click send button instead of passing submitMessage, forwardRef and memoize SendButton
* refactor(Textarea): use Controller field value to avoid manual update of ref
* chore: remove forms provider
* chore: memoize AttachFile
* refactor(ChatForm/SendButton): only re-render SendButton when there is text input
* chore: make iconURL bigger
* chore: optimize Root/Nav
* refactor(SendButton): memoize disabled prop based on text
* chore: memoize Nav and ChatForm
* chore: remove textarea ref text on submission
* feat(EditMessage): Make Esc exit the edit mode and dismiss changes when editing a message
* style(MenuItem): Display the ☑️ icon only on the selected model
51 lines
1.4 KiB
TypeScript
51 lines
1.4 KiB
TypeScript
import React from 'react';
|
|
import {
|
|
EModelEndpoint,
|
|
supportsFiles,
|
|
fileConfig as defaultFileConfig,
|
|
mergeFileConfig,
|
|
} from 'librechat-data-provider';
|
|
import { useGetFileConfig } from '~/data-provider';
|
|
import { AttachmentIcon } from '~/components/svg';
|
|
import { FileUpload } from '~/components/ui';
|
|
import { useFileHandling } from '~/hooks';
|
|
|
|
const AttachFile = ({
|
|
endpoint,
|
|
endpointType,
|
|
disabled = false,
|
|
}: {
|
|
endpoint: EModelEndpoint | '';
|
|
endpointType?: EModelEndpoint;
|
|
disabled?: boolean | null;
|
|
}) => {
|
|
const { handleFileChange } = useFileHandling();
|
|
const { data: fileConfig = defaultFileConfig } = useGetFileConfig({
|
|
select: (data) => mergeFileConfig(data),
|
|
});
|
|
const endpointFileConfig = fileConfig.endpoints[endpoint ?? ''];
|
|
|
|
if (!supportsFiles[endpointType ?? endpoint ?? ''] || endpointFileConfig?.disabled) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<div className="absolute bottom-2 left-2 md:bottom-3 md:left-4">
|
|
<FileUpload handleFileChange={handleFileChange} className="flex">
|
|
<button
|
|
disabled={!!disabled}
|
|
type="button"
|
|
className="btn relative p-0 text-black dark:text-white"
|
|
aria-label="Attach files"
|
|
style={{ padding: 0 }}
|
|
>
|
|
<div className="flex w-full items-center justify-center gap-2">
|
|
<AttachmentIcon />
|
|
</div>
|
|
</button>
|
|
</FileUpload>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default React.memo(AttachFile);
|