UNPKG

@appbuckets/react-ui

Version:
54 lines (51 loc) 1.46 kB
import * as React from 'react'; import Button from '../../Button/Button.js'; import Column from '../../Column/Column.js'; import Divider from '../../Divider/Divider.js'; import Row from '../../Row/Row.js'; import { useDropzone } from '../Dropzone.context.js'; /* -------- * Component Definition * -------- */ var DropzoneController = function () { var dropzone = useDropzone(); if (!dropzone.files.length) { return null; } var hasFilesToUpload = dropzone.files.some(function (file) { return !file.state.success; }); return React.createElement( React.Fragment, null, React.createElement(Divider, null), React.createElement( Row, null, React.createElement( Column, { textAlign: 'right' }, Button.create(dropzone.props.clearButton, { autoGenerateKey: false, overrideProps: { disabled: dropzone.isDisabled, onClick: dropzone.clearFiles, }, }), Button.create(dropzone.props.uploadButton, { autoGenerateKey: false, defaultProps: { primary: true, }, overrideProps: { loading: dropzone.isUploading, disabled: dropzone.isDisabled || !hasFilesToUpload, onClick: dropzone.startUpload, }, }) ) ) ); }; DropzoneController.displayName = 'DropzoneController'; export { DropzoneController as default };