diff --git a/packages/@uppy/dashboard/src/Dashboard.tsx b/packages/@uppy/dashboard/src/Dashboard.tsx index 62cf867db6..4b731173ea 100644 --- a/packages/@uppy/dashboard/src/Dashboard.tsx +++ b/packages/@uppy/dashboard/src/Dashboard.tsx @@ -170,7 +170,7 @@ interface DashboardMiscOptions thumbnailHeight?: number thumbnailType?: string thumbnailWidth?: number - trigger?: string | Element + trigger?: string | Element | null waitForThumbnailsBeforeUpload?: boolean } @@ -183,9 +183,6 @@ export type DashboardOptions< const defaultOptions = { target: 'body', metaFields: [], - inline: false as boolean, - width: 750, - height: 550, thumbnailWidth: 280, thumbnailType: 'image/jpeg', waitForThumbnailsBeforeUpload: false, @@ -198,19 +195,14 @@ const defaultOptions = { hidePauseResumeButton: false, hideProgressAfterFinish: false, note: null, - closeModalOnClickOutside: false, - closeAfterFinish: false, singleFileFullScreen: true, disableStatusBar: false, disableInformer: false, disableThumbnailGenerator: false, - disablePageScrollWhenModalOpen: true, - animateOpenClose: true, fileManagerSelectionType: 'files', proudlyDisplayPoweredByUppy: true, showSelectedFiles: true, showRemoveButtonAfterComplete: false, - browserBackButtonClose: false, showNativePhotoCameraButton: false, showNativeVideoCameraButton: false, theme: 'light', @@ -218,12 +210,29 @@ const defaultOptions = { disabled: false, disableLocalFiles: false, nativeCameraFacingMode: '', + onDragLeave: () => {}, + onDragOver: () => {}, + onDrop: () => {}, + plugins: [], // Dynamic default options, they have to be defined in the constructor (because // they require access to the `this` keyword), but we still want them to // appear in the default options so TS knows they'll be defined. doneButtonHandler: undefined as any, onRequestCloseModal: null as any, + + // defaultModalOptions + inline: false as boolean, + animateOpenClose: true, + browserBackButtonClose: false, + closeAfterFinish: false, + closeModalOnClickOutside: false, + disablePageScrollWhenModalOpen: true, + trigger: null, + + // defaultInlineOptions + width: 750, + height: 550, } satisfies Partial> /** @@ -828,7 +837,7 @@ export default class Dashboard extends UIPlugin< this.setPluginState({ isDraggingOver: true }) - this.opts.onDragOver?.(event) + this.opts.onDragOver(event) } private handleDragLeave = (event: DragEvent) => { @@ -837,7 +846,7 @@ export default class Dashboard extends UIPlugin< this.setPluginState({ isDraggingOver: false }) - this.opts.onDragLeave?.(event) + this.opts.onDragLeave(event) } private handleDrop = async (event: DragEvent) => { @@ -876,7 +885,7 @@ export default class Dashboard extends UIPlugin< this.addFiles(files) } - this.opts.onDrop?.(event) + this.opts.onDrop(event) } private handleRequestThumbnail = (file: UppyFile) => { @@ -1264,7 +1273,7 @@ export default class Dashboard extends UIPlugin< } #addSpecifiedPluginsFromOptions = () => { - const plugins = this.opts.plugins || [] + const { plugins } = this.opts plugins.forEach((pluginID) => { const plugin = this.uppy.getPlugin(pluginID) @@ -1470,7 +1479,7 @@ export default class Dashboard extends UIPlugin< if (thumbnail) this.uppy.removePlugin(thumbnail) } - const plugins = this.opts.plugins || [] + const { plugins } = this.opts plugins.forEach((pluginID) => { const plugin = this.uppy.getPlugin(pluginID) if (plugin) (plugin as any).unmount()