| | |
| | | import { createRef, useEffect, useState } from 'react' |
| | | import Cropper, { type Area, type CropperProps } from 'react-easy-crop' |
| | | import classNames from 'classnames' |
| | | import { useTranslation } from 'react-i18next' |
| | | |
| | | import { ImagePlus } from '../icons/src/vender/line/images' |
| | | import { useDraggableUploader } from './hooks' |
| | |
| | | cropShape, |
| | | onImageInput, |
| | | }) => { |
| | | const { t } = useTranslation() |
| | | const [inputImage, setInputImage] = useState<{ file: File; url: string }>() |
| | | const [isAnimatedImage, setIsAnimatedImage] = useState<boolean>(false) |
| | | useEffect(() => { |
| | |
| | | { |
| | | !inputImage |
| | | ? <> |
| | | <ImagePlus className="pointer-events-none mb-3 h-[30px] w-[30px]" /> |
| | | <div className="mb-[2px] text-sm font-medium"> |
| | | <span className="pointer-events-none">{t('common.imageInput.dropImageHere')} </span> |
| | | <button className="text-components-button-primary-bg" onClick={() => inputRef.current?.click()}>{t('common.imageInput.browse')}</button> |
| | | <ImagePlus className="w-[30px] h-[30px] mb-3 pointer-events-none" /> |
| | | <div className="text-sm font-medium mb-[2px]"> |
| | | <span className="pointer-events-none">Drop your image here, or </span> |
| | | <button className="text-components-button-primary-bg" onClick={() => inputRef.current?.click()}>browse</button> |
| | | <input |
| | | ref={inputRef} type="file" className="hidden" |
| | | onClick={e => ((e.target as HTMLInputElement).value = '')} |
| | |
| | | onChange={handleLocalFileInput} |
| | | /> |
| | | </div> |
| | | <div className="pointer-events-none">{t('common.imageInput.supportedFormats')}</div> |
| | | <div className="text-xs pointer-events-none">Supports PNG, JPG, JPEG, WEBP and GIF</div> |
| | | </> |
| | | : handleShowImage() |
| | | } |