Skip to content

Commit

Permalink
@uppy/status-bar: fix StatusBarOptions type (#4883)
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 authored Jan 23, 2024
1 parent 39e26e7 commit ca3928b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 26 deletions.
33 changes: 16 additions & 17 deletions packages/@uppy/status-bar/src/StatusBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,25 @@ function getUploadingState(
return state
}

// set default options, must be kept in sync with @uppy/react/src/StatusBar.js
const defaultOptions = {
target: 'body',
hideUploadButton: false,
hideRetryButton: false,
hidePauseResumeButton: false,
hideCancelButton: false,
showProgressDetails: false,
hideAfterFinish: true,
doneButtonHandler: null,
} satisfies StatusBarOptions

/**
* StatusBar: renders a status bar with upload/pause/resume/cancel/retry buttons,
* progress percentage and time remaining.
*/
export default class StatusBar<M extends Meta, B extends Body> extends UIPlugin<
StatusBarOptions,
StatusBarOptions &
Required<Pick<StatusBarOptions, keyof typeof defaultOptions>>,
M,
B
> {
Expand All @@ -74,28 +87,14 @@ export default class StatusBar<M extends Meta, B extends Body> extends UIPlugin<

#previousETA: number | null

constructor(uppy: Uppy<M, B>, opts?: Partial<StatusBarOptions>) {
super(uppy, opts)
constructor(uppy: Uppy<M, B>, opts?: StatusBarOptions) {
super(uppy, { ...defaultOptions, ...opts })
this.id = this.opts.id || 'StatusBar'
this.title = 'StatusBar'
this.type = 'progressindicator'

this.defaultLocale = locale

// set default options, must be kept in sync with @uppy/react/src/StatusBar.js
const defaultOptions = {
target: 'body',
hideUploadButton: false,
hideRetryButton: false,
hidePauseResumeButton: false,
hideCancelButton: false,
showProgressDetails: false,
hideAfterFinish: true,
doneButtonHandler: null,
}

this.opts = { ...defaultOptions, ...opts }

this.i18nInit()

this.render = this.render.bind(this)
Expand Down
18 changes: 9 additions & 9 deletions packages/@uppy/status-bar/src/StatusBarOptions.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type { UIPluginOptions } from '@uppy/core/src/UIPlugin.ts'
import type { UIPluginOptions } from '@uppy/core/lib/UIPlugin'
import type StatusBarLocale from './locale.ts'

export interface StatusBarOptions extends UIPluginOptions {
target: HTMLElement | string
showProgressDetails: boolean
hideUploadButton: boolean
hideAfterFinish: boolean
hideRetryButton: boolean
hidePauseResumeButton: boolean
hideCancelButton: boolean
doneButtonHandler: (() => void) | null
target?: HTMLElement | string
showProgressDetails?: boolean
hideUploadButton?: boolean
hideAfterFinish?: boolean
hideRetryButton?: boolean
hidePauseResumeButton?: boolean
hideCancelButton?: boolean
doneButtonHandler?: (() => void) | null
locale?: typeof StatusBarLocale
}

0 comments on commit ca3928b

Please sign in to comment.