diff --git a/src/components/Dropdown.tsx b/src/components/Dropdown.tsx index a8c8ea1..66b485b 100644 --- a/src/components/Dropdown.tsx +++ b/src/components/Dropdown.tsx @@ -4,6 +4,7 @@ import { isDev } from '../config'; import { classNames } from '../utils'; import { Button } from './Button'; import { Icon } from './Icon'; +import { Input } from './Input'; export interface DropdownOption { value: string | number; @@ -120,10 +121,10 @@ export function Dropdown({ {/* dropdown content */}
{filterable && ( - setFilter(e.target.value)} autoFocus diff --git a/src/components/Input.tsx b/src/components/Input.tsx new file mode 100644 index 0000000..1394dd9 --- /dev/null +++ b/src/components/Input.tsx @@ -0,0 +1,53 @@ +import { cva, VariantProps } from 'class-variance-authority'; +import * as React from 'react'; +import { cn } from '../utils'; + +const inputVariants = cva('', { + variants: { + variant: { + text: '', + file: '', + input: 'input', + bordered: 'input input-bordered', + toggle: 'toggle', + range: 'range', + }, + size: {}, + }, +}); + +export type InputProps = React.InputHTMLAttributes & + VariantProps; + +const Input = React.forwardRef( + ({ className, variant, size, ...props }, ref) => { + let type = props.type; + if (!type) { + switch (variant) { + case 'file': + type = 'file'; + break; + case 'toggle': + type = 'checkbox'; + break; + case 'range': + type = 'range'; + break; + default: + type = 'text'; + } + } + + return ( + + ); + } +); +Input.displayName = 'Input'; + +export { Input }; diff --git a/src/components/index.tsx b/src/components/index.tsx index 20b4c44..132df04 100644 --- a/src/components/index.tsx +++ b/src/components/index.tsx @@ -3,6 +3,7 @@ export * from './Dropdown'; export * from './Footer'; export * from './Header'; export * from './Icon'; +export * from './Input'; export * from './Label'; export * from './Sidebar'; export * from './Textarea'; diff --git a/src/pages/Chat/components/DropzoneArea.tsx b/src/pages/Chat/components/DropzoneArea.tsx index 6230b08..c25088d 100644 --- a/src/pages/Chat/components/DropzoneArea.tsx +++ b/src/pages/Chat/components/DropzoneArea.tsx @@ -1,5 +1,6 @@ import { ClipboardEvent, useState } from 'react'; import Dropzone from 'react-dropzone'; +import { Input } from '../../../components'; import { FileUploadApi } from '../../../hooks/useFileUpload'; import { useAppContext } from '../../../store/app'; import { classNames } from '../../../utils'; @@ -73,9 +74,9 @@ export function DropzoneArea({ }} {...getRootProps()} > - void }) { {t('settings.importExport.exportBtnLabel')} - {label}
-
- (