|
@@ -1,4 +1,4 @@
|
|
|
-import { h, Component } from 'preact'
|
|
|
+import { h, Component, Fragment } from 'preact'
|
|
|
|
|
|
class AddFiles extends Component {
|
|
|
triggerFileInputClick = () => {
|
|
@@ -9,6 +9,14 @@ class AddFiles extends Component {
|
|
|
this.folderInput.click()
|
|
|
}
|
|
|
|
|
|
+ triggerVideoCameraInputClick = () => {
|
|
|
+ this.mobileVideoFileInput.click()
|
|
|
+ }
|
|
|
+
|
|
|
+ triggerPhotoCameraInputClick = () => {
|
|
|
+ this.mobilePhotoFileInput.click()
|
|
|
+ }
|
|
|
+
|
|
|
onFileInputChange = (event) => {
|
|
|
this.props.handleInputChange(event)
|
|
|
|
|
@@ -39,6 +47,26 @@ class AddFiles extends Component {
|
|
|
)
|
|
|
}
|
|
|
|
|
|
+ renderHiddenCameraInput = (type, refCallback) => {
|
|
|
+ const typeToAccept = { photo: 'image/*', video: 'video/*' }
|
|
|
+ const accept = typeToAccept[type]
|
|
|
+
|
|
|
+ return (
|
|
|
+ <input
|
|
|
+ className="uppy-Dashboard-input"
|
|
|
+ hidden
|
|
|
+ aria-hidden="true"
|
|
|
+ tabIndex={-1}
|
|
|
+ type="file"
|
|
|
+ name={`camera-${type}`}
|
|
|
+ onChange={this.onFileInputChange}
|
|
|
+ capture="user"
|
|
|
+ accept={accept}
|
|
|
+ ref={refCallback}
|
|
|
+ />
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
renderMyDeviceAcquirer = () => {
|
|
|
return (
|
|
|
<div
|
|
@@ -66,6 +94,58 @@ class AddFiles extends Component {
|
|
|
)
|
|
|
}
|
|
|
|
|
|
+ renderPhotoCamera = () => {
|
|
|
+ return (
|
|
|
+ <div
|
|
|
+ className="uppy-DashboardTab"
|
|
|
+ role="presentation"
|
|
|
+ data-uppy-acquirer-id="MobilePhotoCamera"
|
|
|
+ >
|
|
|
+ <button
|
|
|
+ type="button"
|
|
|
+ className="uppy-u-reset uppy-c-btn uppy-DashboardTab-btn"
|
|
|
+ role="tab"
|
|
|
+ tabIndex={0}
|
|
|
+ data-uppy-super-focusable
|
|
|
+ onClick={this.triggerPhotoCameraInputClick}
|
|
|
+ >
|
|
|
+ <svg aria-hidden="true" focusable="false" width="32" height="32" viewBox="0 0 32 32">
|
|
|
+ <g fill="none" fillRule="evenodd">
|
|
|
+ <rect className="uppy-ProviderIconBg" fill="#03BFEF" width="32" height="32" rx="16" />
|
|
|
+ <path d="M22 11c1.133 0 2 .867 2 2v7.333c0 1.134-.867 2-2 2H10c-1.133 0-2-.866-2-2V13c0-1.133.867-2 2-2h2.333l1.134-1.733C13.6 9.133 13.8 9 14 9h4c.2 0 .4.133.533.267L19.667 11H22zm-6 1.533a3.764 3.764 0 0 0-3.8 3.8c0 2.129 1.672 3.801 3.8 3.801s3.8-1.672 3.8-3.8c0-2.13-1.672-3.801-3.8-3.801zm0 6.261c-1.395 0-2.46-1.066-2.46-2.46 0-1.395 1.065-2.461 2.46-2.461s2.46 1.066 2.46 2.46c0 1.395-1.065 2.461-2.46 2.461z" fill="#FFF" fillRule="nonzero" />
|
|
|
+ </g>
|
|
|
+ </svg>
|
|
|
+ <div className="uppy-DashboardTab-name">{this.props.i18n('takePictureBtn')}</div>
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ renderVideoCamera = () => {
|
|
|
+ return (
|
|
|
+ <div
|
|
|
+ className="uppy-DashboardTab"
|
|
|
+ role="presentation"
|
|
|
+ data-uppy-acquirer-id="MobileVideoCamera"
|
|
|
+ >
|
|
|
+ <button
|
|
|
+ type="button"
|
|
|
+ className="uppy-u-reset uppy-c-btn uppy-DashboardTab-btn"
|
|
|
+ role="tab"
|
|
|
+ tabIndex={0}
|
|
|
+ data-uppy-super-focusable
|
|
|
+ onClick={this.triggerVideoCameraInputClick}
|
|
|
+ >
|
|
|
+ <svg aria-hidden="true" width="32" height="32" viewBox="0 0 32 32">
|
|
|
+ <rect fill="#1abc9c" width="32" height="32" rx="16" />
|
|
|
+ <path fill="#FFF" fillRule="nonzero" d="m21.254 14.277 2.941-2.588c.797-.313 1.243.818 1.09 1.554-.01 2.094.02 4.189-.017 6.282-.126.915-1.145 1.08-1.58.34l-2.434-2.142c-.192.287-.504 1.305-.738.468-.104-1.293-.028-2.596-.05-3.894.047-.312.381.823.426 1.069.063-.384.206-.744.362-1.09zm-12.939-3.73c3.858.013 7.717-.025 11.574.02.912.129 1.492 1.237 1.351 2.217-.019 2.412.04 4.83-.03 7.239-.17 1.025-1.166 1.59-2.029 1.429-3.705-.012-7.41.025-11.114-.019-.913-.129-1.492-1.237-1.352-2.217.018-2.404-.036-4.813.029-7.214.136-.82.83-1.473 1.571-1.454z " />
|
|
|
+ </svg>
|
|
|
+ <div className="uppy-DashboardTab-name">{this.props.i18n('recordVideoBtn')}</div>
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
renderBrowseButton = (text, onClickFn) => {
|
|
|
const numberOfAcquirers = this.props.acquirers.length
|
|
|
return (
|
|
@@ -138,19 +218,31 @@ class AddFiles extends Component {
|
|
|
)
|
|
|
}
|
|
|
|
|
|
- renderAcquirers = (acquirers, disableLocalFiles) => {
|
|
|
+ renderAcquirers = (acquirers) => {
|
|
|
// Group last two buttons, so we don’t end up with
|
|
|
// just one button on a new line
|
|
|
const acquirersWithoutLastTwo = [...acquirers]
|
|
|
const lastTwoAcquirers = acquirersWithoutLastTwo.splice(acquirers.length - 2, acquirers.length)
|
|
|
|
|
|
return (
|
|
|
- <div className="uppy-Dashboard-AddFiles-list" role="tablist">
|
|
|
- {!disableLocalFiles && this.renderMyDeviceAcquirer()}
|
|
|
+ <Fragment>
|
|
|
{acquirersWithoutLastTwo.map((acquirer) => this.renderAcquirer(acquirer))}
|
|
|
<span role="presentation" style={{ 'white-space': 'nowrap' }}>
|
|
|
{lastTwoAcquirers.map((acquirer) => this.renderAcquirer(acquirer))}
|
|
|
</span>
|
|
|
+ </Fragment>
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ renderSourcesList = (acquirers, disableLocalFiles) => {
|
|
|
+ const { showNativePhotoCameraButton, showNativeVideoCameraButton } = this.props
|
|
|
+
|
|
|
+ return (
|
|
|
+ <div className="uppy-Dashboard-AddFiles-list" role="tablist">
|
|
|
+ {!disableLocalFiles && this.renderMyDeviceAcquirer()}
|
|
|
+ {!disableLocalFiles && showNativePhotoCameraButton && this.renderPhotoCamera()}
|
|
|
+ {!disableLocalFiles && showNativeVideoCameraButton && this.renderVideoCamera()}
|
|
|
+ {acquirers.length > 0 && this.renderAcquirers(acquirers)}
|
|
|
</div>
|
|
|
)
|
|
|
}
|
|
@@ -183,12 +275,16 @@ class AddFiles extends Component {
|
|
|
}
|
|
|
|
|
|
render () {
|
|
|
+ const { showNativePhotoCameraButton, showNativeVideoCameraButton } = this.props
|
|
|
+
|
|
|
return (
|
|
|
<div className="uppy-Dashboard-AddFiles">
|
|
|
{this.renderHiddenInput(false, (ref) => { this.fileInput = ref })}
|
|
|
{this.renderHiddenInput(true, (ref) => { this.folderInput = ref })}
|
|
|
+ {showNativePhotoCameraButton && this.renderHiddenCameraInput('photo', (ref) => { this.mobilePhotoFileInput = ref })}
|
|
|
+ {showNativeVideoCameraButton && this.renderHiddenCameraInput('video', (ref) => { this.mobileVideoFileInput = ref })}
|
|
|
{this.renderDropPasteBrowseTagline()}
|
|
|
- {this.props.acquirers.length > 0 && this.renderAcquirers(this.props.acquirers, this.props.disableLocalFiles)}
|
|
|
+ {this.renderSourcesList(this.props.acquirers, this.props.disableLocalFiles)}
|
|
|
<div className="uppy-Dashboard-AddFiles-info">
|
|
|
{this.props.note && <div className="uppy-Dashboard-note">{this.props.note}</div>}
|
|
|
{this.props.proudlyDisplayPoweredByUppy && this.renderPoweredByUppy(this.props)}
|