components.controls.ImageUploader.ImageUpload.jsx Maven / Gradle / Ivy
The newest version!
import React from 'react'
import PropTypes from 'prop-types'
import Dropzone from 'react-dropzone'
import classNames from 'classnames'
import isEmpty from 'lodash/isEmpty'
import { Button } from 'reactstrap'
import ImageUploaderList from './ImageUploaderList'
function ImageUpload({
uploading,
statusBarColor,
onRemove,
autoUpload,
showSize,
showName,
disabled,
children,
onImagesDrop,
onDragEnter,
onDragLeave,
multiple,
visible,
className,
files,
componentClass,
onStartUpload,
uploaderClass,
saveBtnStyle,
lightbox,
listType,
imgError,
showTooltip,
customUploaderSize,
canDelete,
shape,
accept,
}) {
const showControl = multiple || (!multiple && isEmpty(files))
const componentClassContainer = `${componentClass}-container`
if (!visible) {
return null
}
const defaultClassName = 'n2o-image-uploader-control'
const compiledClassName = shape
? `${defaultClassName}--shape-${shape}`
: defaultClassName
return (
{visible && (
{children}
)}
{!isEmpty(files) && (
)}
{!autoUpload && (
)}
)
}
ImageUpload.propTypes = {
uploading: PropTypes.object,
statusBarColor: PropTypes.string,
onRemove: PropTypes.func,
autoUpload: PropTypes.bool,
showSize: PropTypes.bool,
showName: PropTypes.bool,
disabled: PropTypes.bool,
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
onImagesDrop: PropTypes.func,
onDragEnter: PropTypes.func,
onDragLeave: PropTypes.func,
multiple: PropTypes.bool,
visible: PropTypes.bool,
className: PropTypes.string,
files: PropTypes.arrayOf(PropTypes.object),
componentClass: PropTypes.string,
onStartUpload: PropTypes.func,
uploaderClass: PropTypes.string,
saveBtnStyle: PropTypes.object,
lightbox: PropTypes.bool,
listType: PropTypes.string,
imgError: PropTypes.string,
showTooltip: PropTypes.bool,
customUploaderSize: PropTypes.number,
canDelete: PropTypes.bool,
shape: PropTypes.string,
accept: PropTypes.string,
}
export default ImageUpload