mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-19 18:00:15 +01:00
refactor(DialogTemplate): convert to typescript
refactor(ui): import multiple components from ui folder in several files
This commit is contained in:
parent
544d72ee1d
commit
c661276888
4 changed files with 27 additions and 15 deletions
|
|
@ -1,9 +1,6 @@
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { useRecoilValue } from 'recoil';
|
import { useRecoilValue } from 'recoil';
|
||||||
import DialogTemplate from '../ui/DialogTemplate';
|
import {Dialog, DialogTemplate, Input, Label} from '../ui/';
|
||||||
import { Dialog } from '../ui/Dialog.tsx';
|
|
||||||
import { Input } from '../ui/Input.tsx';
|
|
||||||
import { Label } from '../ui/Label.tsx';
|
|
||||||
import { cn } from '~/utils/';
|
import { cn } from '~/utils/';
|
||||||
import cleanupPreset from '~/utils/cleanupPreset';
|
import cleanupPreset from '~/utils/cleanupPreset';
|
||||||
import { useCreatePresetMutation } from '~/data-provider';
|
import { useCreatePresetMutation } from '~/data-provider';
|
||||||
|
|
|
||||||
|
|
@ -10,17 +10,17 @@ import FileUpload from './FileUpload';
|
||||||
import getIcon from '~/utils/getIcon';
|
import getIcon from '~/utils/getIcon';
|
||||||
import getDefaultConversation from '~/utils/getDefaultConversation';
|
import getDefaultConversation from '~/utils/getDefaultConversation';
|
||||||
import { useDeletePresetMutation, useCreatePresetMutation } from '~/data-provider';
|
import { useDeletePresetMutation, useCreatePresetMutation } from '~/data-provider';
|
||||||
import { Button } from '../../ui/Button.tsx';
|
|
||||||
import {
|
import {
|
||||||
|
Button,
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
DropdownMenuLabel,
|
DropdownMenuLabel,
|
||||||
DropdownMenuRadioGroup,
|
DropdownMenuRadioGroup,
|
||||||
DropdownMenuSeparator,
|
DropdownMenuSeparator,
|
||||||
DropdownMenuTrigger
|
DropdownMenuTrigger,
|
||||||
} from '../../ui/DropdownMenu.tsx';
|
DialogTemplate,
|
||||||
import { Dialog, DialogTrigger } from '../../ui/Dialog.tsx';
|
Dialog, DialogTrigger
|
||||||
import DialogTemplate from '../../ui/DialogTemplate';
|
} from '../../ui/';
|
||||||
import { cn } from '~/utils/';
|
import { cn } from '~/utils/';
|
||||||
|
|
||||||
import store from '~/store';
|
import store from '~/store';
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
/* eslint-disable react-hooks/exhaustive-deps */
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import DialogTemplate from '../../ui/DialogTemplate';
|
import { Dialog, DialogTemplate } from '../../ui';
|
||||||
import { Dialog } from '../../ui/Dialog.tsx';
|
|
||||||
import * as Checkbox from '@radix-ui/react-checkbox';
|
import * as Checkbox from '@radix-ui/react-checkbox';
|
||||||
import { CheckIcon } from '@radix-ui/react-icons';
|
import { CheckIcon } from '@radix-ui/react-icons';
|
||||||
import FileUpload from '../NewConversationMenu/FileUpload';
|
import FileUpload from '../NewConversationMenu/FileUpload';
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { forwardRef } from 'react';
|
import { forwardRef, ReactNode, Ref } from 'react';
|
||||||
import {
|
import {
|
||||||
DialogClose,
|
DialogClose,
|
||||||
DialogContent,
|
DialogContent,
|
||||||
|
|
@ -6,10 +6,26 @@ import {
|
||||||
DialogFooter,
|
DialogFooter,
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle
|
DialogTitle
|
||||||
} from './Dialog.tsx';
|
} from './';
|
||||||
import { cn } from '~/utils/';
|
import { cn } from '~/utils/';
|
||||||
|
|
||||||
const DialogTemplate = forwardRef((props, ref) => {
|
type SelectionProps = {
|
||||||
|
selectHandler?: () => void;
|
||||||
|
selectClasses?: string;
|
||||||
|
selectText?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type DialogTemplateProps = {
|
||||||
|
title: string;
|
||||||
|
description?: string;
|
||||||
|
main?: ReactNode;
|
||||||
|
buttons?: ReactNode;
|
||||||
|
leftButtons?: ReactNode;
|
||||||
|
selection?: SelectionProps;
|
||||||
|
className?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
const DialogTemplate = forwardRef((props: DialogTemplateProps, ref: Ref<HTMLDivElement>) => {
|
||||||
const { title, description, main, buttons, leftButtons, selection, className } = props;
|
const { title, description, main, buttons, leftButtons, selection, className } = props;
|
||||||
const { selectHandler, selectClasses, selectText } = selection || {};
|
const { selectHandler, selectClasses, selectText } = selection || {};
|
||||||
|
|
||||||
|
|
@ -18,7 +34,7 @@ const DialogTemplate = forwardRef((props, ref) => {
|
||||||
return (
|
return (
|
||||||
<DialogContent ref={ref} className={cn('shadow-2xl dark:bg-gray-900', className || '')}>
|
<DialogContent ref={ref} className={cn('shadow-2xl dark:bg-gray-900', className || '')}>
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle className="text-gray-800 dark:text-white">{title}</DialogTitle>
|
<DialogTitle className="text-lg font-medium leading-6 text-gray-900 dark:text-gray-200">{title}</DialogTitle>
|
||||||
{description && (
|
{description && (
|
||||||
<DialogDescription className="text-gray-600 dark:text-gray-300">
|
<DialogDescription className="text-gray-600 dark:text-gray-300">
|
||||||
{description}
|
{description}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue