diff --git a/web/app/components/base/chat/chat/chat-input-area/index.tsx b/web/app/components/base/chat/chat/chat-input-area/index.tsx index c8a4fcf59d..f96d15b8ac 100644 --- a/web/app/components/base/chat/chat/chat-input-area/index.tsx +++ b/web/app/components/base/chat/chat/chat-input-area/index.tsx @@ -15,7 +15,7 @@ import type { Theme } from '../../embedded-chatbot/theme/theme-context' import { useTextAreaHeight } from './hooks' import Operation from './operation' import cn from '@/utils/classnames' -import { FileListFlexOperation } from '@/app/components/base/file-uploader' +import { FileListInChatInput } from '@/app/components/base/file-uploader' import { FileContextProvider } from '@/app/components/base/file-uploader/store' import VoiceInput from '@/app/components/base/voice-input' import { useToastContext } from '@/app/components/base/toast' @@ -111,7 +111,7 @@ const ChatInputArea = ({ )} >
- +
{ - if (isFile) { - return ( -
-
-
-
- - PDF -
·
- 3.9 MB -
- - - -
-
- ) - } - - return ( -
- ) -} - -export default memo(FileListFlexItem) diff --git a/web/app/components/base/file-uploader/file-list-flex/file-list-flex-operation.tsx b/web/app/components/base/file-uploader/file-list-flex/file-list-flex-operation.tsx deleted file mode 100644 index eb3bafc847..0000000000 --- a/web/app/components/base/file-uploader/file-list-flex/file-list-flex-operation.tsx +++ /dev/null @@ -1,58 +0,0 @@ -import { - forwardRef, - memo, -} from 'react' -import { RiCloseLine } from '@remixicon/react' -import { useStore } from '../store' -import { useFile } from '../hooks' -import FileListItem from './file-list-flex-item' -import Button from '@/app/components/base/button' -import ProgressCircle from '@/app/components/base/progress-bar/progress-circle' - -const FileListFlexOperation = forwardRef((_, ref) => { - const files = useStore(s => s.files) - const { handleRemoveFile } = useFile() - - return ( -
- { - files.map(file => ( -
- - { - file.progress !== 100 && ( -
- -
- ) - } - -
- )) - } -
- ) -}) -FileListFlexOperation.displayName = 'FileListFlexOperation' - -export default memo(FileListFlexOperation) diff --git a/web/app/components/base/file-uploader/file-list-flex/file-list-flex-preview.tsx b/web/app/components/base/file-uploader/file-list-flex/file-list-flex-preview.tsx deleted file mode 100644 index ca22f67dfd..0000000000 --- a/web/app/components/base/file-uploader/file-list-flex/file-list-flex-preview.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import { - forwardRef, - memo, -} from 'react' -import FileListFlexItem from './file-list-flex-item' - -const FileListFlexPreview = forwardRef((_, ref) => { - return ( -
- - - - -
- ) -}) -FileListFlexPreview.displayName = 'FileListFlexPreview' - -export default memo(FileListFlexPreview) diff --git a/web/app/components/base/file-uploader/file-uploader-in-attachment/file-in-attachment-item.tsx b/web/app/components/base/file-uploader/file-uploader-in-attachment/file-in-attachment-item.tsx index 4e617b8841..621fbca6c0 100644 --- a/web/app/components/base/file-uploader/file-uploader-in-attachment/file-in-attachment-item.tsx +++ b/web/app/components/base/file-uploader/file-uploader-in-attachment/file-in-attachment-item.tsx @@ -1,8 +1,5 @@ import { memo } from 'react' -import { - RiDeleteBinLine, - RiEditCircleFill, -} from '@remixicon/react' +import { RiDeleteBinLine } from '@remixicon/react' import FileTypeIcon from '../file-type-icon' import type { FileEntity } from '../types' import { useFile } from '../hooks' @@ -16,6 +13,7 @@ import ActionButton from '@/app/components/base/action-button' import ProgressCircle from '@/app/components/base/progress-bar/progress-circle' import { formatFileSize } from '@/utils/format' import cn from '@/utils/classnames' +import { ReplayLine } from '@/app/components/base/icons/src/vender/other' type FileInAttachmentItemProps = { file: FileEntity @@ -80,8 +78,11 @@ const FileInAttachmentItem = ({ } { file.progress === -1 && ( - handleReUploadFile(file.id)}> - + handleReUploadFile(file.id)} + > + ) } diff --git a/web/app/components/base/file-uploader/file-uploader-in-chat-input/file-image-item.tsx b/web/app/components/base/file-uploader/file-uploader-in-chat-input/file-image-item.tsx new file mode 100644 index 0000000000..2b0a86120d --- /dev/null +++ b/web/app/components/base/file-uploader/file-uploader-in-chat-input/file-image-item.tsx @@ -0,0 +1,54 @@ +import { RiCloseLine } from '@remixicon/react' +import FileImageRender from '../file-image-render' +import type { FileEntity } from '../types' +import { useFile } from '../hooks' +import Button from '@/app/components/base/button' +import ProgressCircle from '@/app/components/base/progress-bar/progress-circle' +import { ReplayLine } from '@/app/components/base/icons/src/vender/other' + +type FileImageItemProps = { + file: FileEntity + className?: string +} +const FileImageItem = ({ + file, +}: FileImageItemProps) => { + const { handleRemoveFile } = useFile() + + return ( +
+ + + { + file.progress > 0 && file.progress < 100 && ( +
+ +
+ ) + } + { + file.progress === -1 && ( +
+ +
+ ) + } +
+ ) +} + +export default FileImageItem diff --git a/web/app/components/base/file-uploader/file-uploader-in-chat-input/file-item.tsx b/web/app/components/base/file-uploader/file-uploader-in-chat-input/file-item.tsx new file mode 100644 index 0000000000..853f618587 --- /dev/null +++ b/web/app/components/base/file-uploader/file-uploader-in-chat-input/file-item.tsx @@ -0,0 +1,96 @@ +import { + RiCloseLine, + RiDownloadLine, +} from '@remixicon/react' +import type { FileEntity } from '../types' +import { + getFileAppearanceType, + getFileExtension, +} from '../utils' +import { useFile } from '../hooks' +import FileTypeIcon from '../file-type-icon' +import cn from '@/utils/classnames' +import { formatFileSize } from '@/utils/format' +import ProgressCircle from '@/app/components/base/progress-bar/progress-circle' +import { ReplayLine } from '@/app/components/base/icons/src/vender/other' +import ActionButton from '@/app/components/base/action-button' +import Button from '@/app/components/base/button' + +type FileItemProps = { + file: FileEntity + showDownload?: boolean + className?: string +} +const FileItem = ({ + file, + showDownload, +}: FileItemProps) => { + const { handleRemoveFile } = useFile() + const ext = getFileExtension(file.file) + const uploadError = file.progress === -1 + + return ( +
+ +
+ {file.file?.name} +
+
+
+ + { + ext && ( + <> + {ext} +
·
+ + ) + } + {formatFileSize(file.file?.size || 0)} +
+ { + showDownload && ( + + + + ) + } + { + file.progress > 0 && file.progress < 100 && ( + + ) + } + { + file.progress === -1 && ( + + ) + } +
+
+ ) +} + +export default FileItem diff --git a/web/app/components/base/file-uploader/file-uploader-in-chat-input/file-list.tsx b/web/app/components/base/file-uploader/file-uploader-in-chat-input/file-list.tsx new file mode 100644 index 0000000000..33fd4443e8 --- /dev/null +++ b/web/app/components/base/file-uploader/file-uploader-in-chat-input/file-list.tsx @@ -0,0 +1,34 @@ +import { isImage } from '../utils' +import { useStore } from '../store' +import FileImageItem from './file-image-item' +import FileItem from './file-item' + +const FileList = () => { + const files = useStore(s => s.files) + + return ( +
+ { + files.map((file) => { + if (isImage(file.file)) { + return ( + + ) + } + + return ( + + ) + }) + } +
+ ) +} + +export default FileList diff --git a/web/app/components/base/file-uploader/index.ts b/web/app/components/base/file-uploader/index.ts index 6ee9ec65fb..8d95504bf1 100644 --- a/web/app/components/base/file-uploader/index.ts +++ b/web/app/components/base/file-uploader/index.ts @@ -1,4 +1,4 @@ export { default as FileUploaderInAttachmentWrapper } from './file-uploader-in-attachment' export { default as FileUploaderInChatInput } from './file-uploader-in-chat-input' export { default as FileTypeIcon } from './file-type-icon' -export { default as FileListFlexOperation } from './file-list-flex/file-list-flex-operation' +export { default as FileListInChatInput } from './file-uploader-in-chat-input/file-list' diff --git a/web/app/components/base/icons/assets/vender/other/replay-line.svg b/web/app/components/base/icons/assets/vender/other/replay-line.svg new file mode 100644 index 0000000000..c22074729e --- /dev/null +++ b/web/app/components/base/icons/assets/vender/other/replay-line.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/web/app/components/base/icons/src/public/files/Unknown.json b/web/app/components/base/icons/src/public/files/Unknow.json similarity index 99% rename from web/app/components/base/icons/src/public/files/Unknown.json rename to web/app/components/base/icons/src/public/files/Unknow.json index c39df990d0..33067fa96f 100644 --- a/web/app/components/base/icons/src/public/files/Unknown.json +++ b/web/app/components/base/icons/src/public/files/Unknow.json @@ -195,5 +195,5 @@ } ] }, - "name": "Unknown" + "name": "Unknow" } \ No newline at end of file diff --git a/web/app/components/base/icons/src/public/files/Unknown.tsx b/web/app/components/base/icons/src/public/files/Unknow.tsx similarity index 87% rename from web/app/components/base/icons/src/public/files/Unknown.tsx rename to web/app/components/base/icons/src/public/files/Unknow.tsx index de909ed65e..ce84d344bf 100644 --- a/web/app/components/base/icons/src/public/files/Unknown.tsx +++ b/web/app/components/base/icons/src/public/files/Unknow.tsx @@ -2,7 +2,7 @@ // DON NOT EDIT IT MANUALLY import * as React from 'react' -import data from './Unknown.json' +import data from './Unknow.json' import IconBase from '@/app/components/base/icons/IconBase' import type { IconBaseProps, IconData } from '@/app/components/base/icons/IconBase' @@ -11,6 +11,6 @@ const Icon = React.forwardRef, Omit ) -Icon.displayName = 'Unknown' +Icon.displayName = 'Unknow' export default Icon diff --git a/web/app/components/base/icons/src/public/files/index.ts b/web/app/components/base/icons/src/public/files/index.ts index f38c28cbdb..2814c4ae39 100644 --- a/web/app/components/base/icons/src/public/files/index.ts +++ b/web/app/components/base/icons/src/public/files/index.ts @@ -6,6 +6,6 @@ export { default as Json } from './Json' export { default as Md } from './Md' export { default as Pdf } from './Pdf' export { default as Txt } from './Txt' -export { default as Unknown } from './Unknown' +export { default as Unknow } from './Unknow' export { default as Xlsx } from './Xlsx' export { default as Yaml } from './Yaml' diff --git a/web/app/components/base/icons/src/vender/other/ReplayLine.json b/web/app/components/base/icons/src/vender/other/ReplayLine.json new file mode 100644 index 0000000000..0fffbc98f5 --- /dev/null +++ b/web/app/components/base/icons/src/vender/other/ReplayLine.json @@ -0,0 +1,36 @@ +{ + "icon": { + "type": "element", + "isRootNode": true, + "name": "svg", + "attributes": { + "width": "20", + "height": "20", + "viewBox": "0 0 20 20", + "fill": "none", + "xmlns": "http://www.w3.org/2000/svg" + }, + "children": [ + { + "type": "element", + "name": "g", + "attributes": { + "id": "Retry" + }, + "children": [ + { + "type": "element", + "name": "path", + "attributes": { + "id": "Vector", + "d": "M9.99996 1.66669C14.6023 1.66669 18.3333 5.39765 18.3333 10C18.3333 14.6024 14.6023 18.3334 9.99996 18.3334C5.39758 18.3334 1.66663 14.6024 1.66663 10H3.33329C3.33329 13.6819 6.31806 16.6667 9.99996 16.6667C13.6819 16.6667 16.6666 13.6819 16.6666 10C16.6666 6.31812 13.6819 3.33335 9.99996 3.33335C7.70848 3.33335 5.68702 4.48947 4.48705 6.25022L6.66663 6.25002V7.91669H1.66663V2.91669H3.33329L3.3332 4.99934C4.85358 2.97565 7.2739 1.66669 9.99996 1.66669Z", + "fill": "currentColor" + }, + "children": [] + } + ] + } + ] + }, + "name": "ReplayLine" +} \ No newline at end of file diff --git a/web/app/components/base/icons/src/vender/solid/communication/CuteRobot.tsx b/web/app/components/base/icons/src/vender/other/ReplayLine.tsx similarity index 86% rename from web/app/components/base/icons/src/vender/solid/communication/CuteRobot.tsx rename to web/app/components/base/icons/src/vender/other/ReplayLine.tsx index 49994048b7..7dabfc71af 100644 --- a/web/app/components/base/icons/src/vender/solid/communication/CuteRobot.tsx +++ b/web/app/components/base/icons/src/vender/other/ReplayLine.tsx @@ -2,7 +2,7 @@ // DON NOT EDIT IT MANUALLY import * as React from 'react' -import data from './CuteRobot.json' +import data from './ReplayLine.json' import IconBase from '@/app/components/base/icons/IconBase' import type { IconBaseProps, IconData } from '@/app/components/base/icons/IconBase' @@ -11,6 +11,6 @@ const Icon = React.forwardRef, Omit ) -Icon.displayName = 'CuteRobot' +Icon.displayName = 'ReplayLine' export default Icon diff --git a/web/app/components/base/icons/src/vender/other/index.ts b/web/app/components/base/icons/src/vender/other/index.ts index db6fd9e3f1..1982dcfa3a 100644 --- a/web/app/components/base/icons/src/vender/other/index.ts +++ b/web/app/components/base/icons/src/vender/other/index.ts @@ -1 +1,2 @@ export { default as Generator } from './Generator' +export { default as ReplayLine } from './ReplayLine' diff --git a/web/app/components/base/icons/src/vender/solid/communication/CuteRobot.json b/web/app/components/base/icons/src/vender/solid/communication/CuteRobote.json similarity index 98% rename from web/app/components/base/icons/src/vender/solid/communication/CuteRobot.json rename to web/app/components/base/icons/src/vender/solid/communication/CuteRobote.json index 5b36575f56..389d044a9b 100644 --- a/web/app/components/base/icons/src/vender/solid/communication/CuteRobot.json +++ b/web/app/components/base/icons/src/vender/solid/communication/CuteRobote.json @@ -34,5 +34,5 @@ } ] }, - "name": "CuteRobot" + "name": "CuteRobote" } \ No newline at end of file diff --git a/web/app/components/base/icons/src/vender/solid/communication/CuteRobote.tsx b/web/app/components/base/icons/src/vender/solid/communication/CuteRobote.tsx new file mode 100644 index 0000000000..d416fb5b66 --- /dev/null +++ b/web/app/components/base/icons/src/vender/solid/communication/CuteRobote.tsx @@ -0,0 +1,16 @@ +// GENERATE BY script +// DON NOT EDIT IT MANUALLY + +import * as React from 'react' +import data from './CuteRobote.json' +import IconBase from '@/app/components/base/icons/IconBase' +import type { IconBaseProps, IconData } from '@/app/components/base/icons/IconBase' + +const Icon = React.forwardRef, Omit>(( + props, + ref, +) => ) + +Icon.displayName = 'CuteRobote' + +export default Icon diff --git a/web/app/components/base/icons/src/vender/solid/communication/index.ts b/web/app/components/base/icons/src/vender/solid/communication/index.ts index 673de27463..854953c116 100644 --- a/web/app/components/base/icons/src/vender/solid/communication/index.ts +++ b/web/app/components/base/icons/src/vender/solid/communication/index.ts @@ -1,6 +1,6 @@ export { default as AiText } from './AiText' export { default as ChatBot } from './ChatBot' -export { default as CuteRobot } from './CuteRobot' +export { default as CuteRobote } from './CuteRobote' export { default as EditList } from './EditList' export { default as MessageDotsCircle } from './MessageDotsCircle' export { default as MessageFast } from './MessageFast'