import type { Body, Meta, State, Uppy, UppyFile } from '@uppy/core' import type { I18n } from '@uppy/utils' import type { ComponentChild } from 'preact' interface Props { uppy: Uppy file: UppyFile isUploaded: boolean error: string | false recoveredState: State['recoveredState'] hideRetryButton: boolean hidePauseResumeButton: boolean hideCancelButton: boolean resumableUploads: boolean individualCancellation: boolean i18n: I18n } function onPauseResumeCancelRetry( props: Props, ) { if (props.isUploaded) return if (props.error && !props.hideRetryButton) { props.uppy.retryUpload(props.file.id) return } if (props.resumableUploads && !props.hidePauseResumeButton) { props.uppy.pauseResume(props.file.id) } else if (props.individualCancellation && !props.hideCancelButton) { props.uppy.removeFile(props.file.id) } } function progressIndicatorTitle( props: Props, ) { if (props.isUploaded) { return props.i18n('uploadComplete') } if (props.error) { return props.i18n('retryUpload') } if (props.resumableUploads) { if (props.file.isPaused) { return props.i18n('resumeUpload') } return props.i18n('pauseUpload') } if (props.individualCancellation) { return props.i18n('cancelUpload') } return '' } function ProgressIndicatorButton( props: Props & { children: ComponentChild }, ) { return (
) } function ProgressCircleContainer({ children }: { children: ComponentChild }) { return ( ) } function ProgressCircle({ progress }: { progress: number }) { // circle length equals 2 * PI * R const circleLength = 2 * Math.PI * 15 return ( ) } export default function FileProgress( props: Props, ) { // Nothing if upload has not started if (!props.file.progress.uploadStarted) { return null } if (props.file.progress.percentage === undefined) { return null } // Green checkmark when complete if (props.isUploaded) { return (
) } if (props.recoveredState) { return null } // Retry button for error if (props.error && !props.hideRetryButton) { return ( ) } // Pause/resume button for resumable uploads if (props.resumableUploads && !props.hidePauseResumeButton) { return ( {props.file.isPaused ? ( ) : ( )} ) } // Cancel button for non-resumable uploads if individualCancellation is supported (not bundled) if ( !props.resumableUploads && props.individualCancellation && !props.hideCancelButton ) { return ( ) } // Just progress when buttons are disabled return (
) }