components.controls.FileUploader.FileUploaderItem.jsx Maven / Gradle / Ivy
The newest version!
import React from 'react'
import classNames from 'classnames'
import { Progress } from 'reactstrap'
import PropTypes from 'prop-types'
import isEmpty from 'lodash/isEmpty'
import { Tooltip } from '../../snippets/Tooltip/TooltipHOC'
import { Spinner } from '../../snippets/Spinner/Spinner'
import { convertSize } from './utils'
function FileUploaderItem({
file,
percentage,
statusBarColor,
onRemove,
showSize,
disabled,
index,
loading,
autoUpload,
deleteIcon,
}) {
const error = (!isEmpty(file.error) || !isEmpty(file.response)) && (file.response || file.error)
// eslint-disable-next-line react/no-unstable-nested-components
const Component = ({ forwardedRef }) => (
{file.name}
{file.link && (
)}
)
return (
{showSize && {convertSize(file.size)}}
{!disabled && (
onRemove(index, file.id)}
className={classNames('n2o-file-uploader-remove ml-2', deleteIcon || 'fa fa-times')}
/>
)}
{loading && }
{loading ||
(!autoUpload && !file.status && (
))}
)
}
FileUploaderItem.propTypes = {
file: PropTypes.object,
percentage: PropTypes.number,
statusBarColor: PropTypes.string,
deleteIcon: PropTypes.string,
onRemove: PropTypes.func,
showSize: PropTypes.bool,
disabled: PropTypes.bool,
autoUpload: PropTypes.bool,
index: PropTypes.number,
loading: PropTypes.bool,
}
FileUploaderItem.defaultProps = {
statusBarColor: 'success',
}
export default FileUploaderItem