Antoine du Hamel преди 3 години
родител
ревизия
dcaef3173f

+ 3 - 2
packages/@uppy/angular/projects/angular/src/lib/components/dashboard-modal/dashboard-modal.component.ts

@@ -1,5 +1,6 @@
 import { Component, ChangeDetectionStrategy, ElementRef, Input, OnDestroy, OnChanges, SimpleChanges } from '@angular/core';
-import * as Dashboard from '@uppy/dashboard';
+import Dashboard from '@uppy/dashboard';
+import type { DashboardOptions } from '@uppy/dashboard';
 import { Uppy } from '@uppy/core';
 import { UppyAngularWrapper } from '../../utils/wrapper';
 
@@ -10,7 +11,7 @@ import { UppyAngularWrapper } from '../../utils/wrapper';
 })
 export class DashboardModalComponent extends UppyAngularWrapper<Dashboard> implements OnDestroy, OnChanges {
   @Input() uppy: Uppy;
-  @Input() props: Dashboard.DashboardOptions;
+  @Input() props: DashboardOptions;
   @Input() open: boolean;
 
   constructor(public el: ElementRef) {

+ 3 - 2
packages/@uppy/angular/projects/angular/src/lib/components/dashboard/dashboard.component.ts

@@ -1,5 +1,6 @@
 import { Component, ChangeDetectionStrategy, ElementRef, Input, OnDestroy, OnChanges, SimpleChanges } from '@angular/core';
-import * as Dashboard from '@uppy/dashboard';
+import Dashboard from '@uppy/dashboard';
+import type { DashboardOptions } from '@uppy/dashboard';
 import { Uppy } from '@uppy/core';
 import { UppyAngularWrapper } from '../../utils/wrapper';
 
@@ -10,7 +11,7 @@ import { UppyAngularWrapper } from '../../utils/wrapper';
 })
 export class DashboardComponent extends UppyAngularWrapper implements OnDestroy, OnChanges {
   @Input() uppy: Uppy;
-  @Input() props: Dashboard.DashboardOptions;
+  @Input() props: DashboardOptions;
 
   constructor(public el: ElementRef) {
     super();

+ 3 - 2
packages/@uppy/angular/projects/angular/src/lib/components/drag-drop/drag-drop.component.ts

@@ -1,6 +1,7 @@
 import { Component, ChangeDetectionStrategy, Input, OnDestroy, OnChanges, SimpleChanges, ElementRef } from '@angular/core';
 import { Uppy } from '@uppy/core';
-import * as DragDrop from '@uppy/drag-drop';
+import DragDrop from '@uppy/drag-drop';
+import type { DragDropOptions } from '@uppy/drag-drop';
 import { UppyAngularWrapper } from '../../utils/wrapper';
 
 @Component({
@@ -10,7 +11,7 @@ import { UppyAngularWrapper } from '../../utils/wrapper';
 })
 export class DragDropComponent extends UppyAngularWrapper implements OnDestroy, OnChanges {
   @Input() uppy: Uppy;
-  @Input() props: DragDrop.DragDropOptions;
+  @Input() props: DragDropOptions;
 
   constructor(public el: ElementRef) {
     super();

+ 3 - 2
packages/@uppy/angular/projects/angular/src/lib/components/progress-bar/progress-bar.component.ts

@@ -1,6 +1,7 @@
 import { Component, ChangeDetectionStrategy, ElementRef, Input, OnDestroy, OnChanges, SimpleChanges } from '@angular/core';
 import { Uppy } from '@uppy/core';
-import * as ProgressBar from '@uppy/progress-bar';
+import ProgressBar from '@uppy/progress-bar';
+import type { ProgressBarOptions } from '@uppy/progress-bar';
 import { UppyAngularWrapper } from '../../utils/wrapper';
 
 @Component({
@@ -10,7 +11,7 @@ import { UppyAngularWrapper } from '../../utils/wrapper';
 })
 export class ProgressBarComponent extends UppyAngularWrapper implements OnDestroy, OnChanges {
   @Input() uppy: Uppy;
-  @Input() props: ProgressBar.ProgressBarOptions;
+  @Input() props: ProgressBarOptions;
 
   constructor(public el: ElementRef) {
     super();

+ 3 - 2
packages/@uppy/angular/projects/angular/src/lib/components/status-bar/status-bar.component.ts

@@ -1,6 +1,7 @@
 import { Component, ChangeDetectionStrategy, Input, ElementRef, SimpleChange, OnDestroy, OnChanges, SimpleChanges } from '@angular/core';
 import { Uppy } from '@uppy/core';
-import * as StatusBar from '@uppy/status-bar';
+import StatusBar from '@uppy/status-bar';
+import type { StatusBarOptions } from '@uppy/status-bar';
 import { UppyAngularWrapper } from '../../utils/wrapper';
 
 @Component({
@@ -10,7 +11,7 @@ import { UppyAngularWrapper } from '../../utils/wrapper';
 })
 export class StatusBarComponent extends UppyAngularWrapper implements OnDestroy, OnChanges  {
   @Input() uppy: Uppy;
-  @Input() props: StatusBar.StatusBarOptions;
+  @Input() props: StatusBarOptions;
 
   constructor(public el: ElementRef) {
     super();

+ 2 - 2
packages/@uppy/angular/projects/angular/src/lib/utils/wrapper.ts

@@ -1,7 +1,7 @@
-import { Uppy, Plugin } from '@uppy/core';
+import { Uppy, UIPlugin } from '@uppy/core';
 import { ElementRef, SimpleChanges } from '@angular/core';
 
-export abstract class UppyAngularWrapper<PluginType extends Plugin  = Plugin> {
+export abstract class UppyAngularWrapper<PluginType extends UIPlugin  = UIPlugin> {
     abstract props;
     abstract el: ElementRef
     abstract uppy: Uppy;

+ 38 - 40
packages/@uppy/dashboard/types/index.d.ts

@@ -1,5 +1,5 @@
 import type { PluginOptions, UIPlugin, PluginTarget, UppyFile } from '@uppy/core'
-import type StatusBar from '@uppy/status-bar'
+import type { StatusBarLocale } from '@uppy/status-bar'
 import DashboardLocale from './generatedLocale'
 
 type FieldRenderOptions = {
@@ -16,48 +16,46 @@ interface MetaField {
   render?: (field: FieldRenderOptions, h: PreactRender) => any
 }
 
-declare module Dashboard {
-  interface DashboardOptions extends PluginOptions {
-    animateOpenClose?: boolean
-    browserBackButtonClose?: boolean
-    closeAfterFinish?: boolean
-    closeModalOnClickOutside?: boolean
-    disableInformer?: boolean
-    disablePageScrollWhenModalOpen?: boolean
-    disableStatusBar?: boolean
-    disableThumbnailGenerator?: boolean
-    doneButtonHandler?: () => void
-    height?: string | number
-    hideCancelButton?: boolean
-    hidePauseResumeButton?: boolean
-    hideProgressAfterFinish?: boolean
-    hideRetryButton?: boolean
-    hideUploadButton?: boolean
-    inline?: boolean
-    locale?: DashboardLocale & StatusBar.StatusBarLocale
-    metaFields?: MetaField[] | ((file: UppyFile) => MetaField[])
-    note?: string | null
-    onRequestCloseModal?: () => void
-    plugins?: string[]
-    fileManagerSelectionType?: 'files' | 'folders' | 'both';
-    proudlyDisplayPoweredByUppy?: boolean
-    showLinkToFileUploadResult?: boolean
-    showProgressDetails?: boolean
-    showSelectedFiles?: boolean
-    showRemoveButtonAfterComplete?: boolean
-    replaceTargetContent?: boolean
-    target?: PluginTarget
-    theme?: 'auto' | 'dark' | 'light'
-    thumbnailWidth?: number
-    trigger?: string
-    width?: string | number
-    autoOpenFileEditor?: boolean
-    disabled?: boolean
+export interface DashboardOptions extends PluginOptions {
+  animateOpenClose?: boolean
+  browserBackButtonClose?: boolean
+  closeAfterFinish?: boolean
+  closeModalOnClickOutside?: boolean
+  disableInformer?: boolean
+  disablePageScrollWhenModalOpen?: boolean
+  disableStatusBar?: boolean
+  disableThumbnailGenerator?: boolean
+  doneButtonHandler?: () => void
+  height?: string | number
+  hideCancelButton?: boolean
+  hidePauseResumeButton?: boolean
+  hideProgressAfterFinish?: boolean
+  hideRetryButton?: boolean
+  hideUploadButton?: boolean
+  inline?: boolean
+  locale?: DashboardLocale & StatusBarLocale
+  metaFields?: MetaField[] | ((file: UppyFile) => MetaField[])
+  note?: string | null
+  onRequestCloseModal?: () => void
+  plugins?: string[]
+  fileManagerSelectionType?: 'files' | 'folders' | 'both';
+  proudlyDisplayPoweredByUppy?: boolean
+  showLinkToFileUploadResult?: boolean
+  showProgressDetails?: boolean
+  showSelectedFiles?: boolean
+  showRemoveButtonAfterComplete?: boolean
+  replaceTargetContent?: boolean
+  target?: PluginTarget
+  theme?: 'auto' | 'dark' | 'light'
+  thumbnailWidth?: number
+  trigger?: string
+  width?: string | number
+  autoOpenFileEditor?: boolean
+  disabled?: boolean
     disableLocalFiles?: boolean
-  }
 }
 
-declare class Dashboard extends UIPlugin<Dashboard.DashboardOptions> {
+declare class Dashboard extends UIPlugin<DashboardOptions> {
   addTarget (plugin: UIPlugin): HTMLElement
   hideAllPanels (): void
   openModal (): void

+ 13 - 15
packages/@uppy/drag-drop/types/index.d.ts

@@ -1,22 +1,20 @@
 import type { PluginOptions, UIPlugin, PluginTarget } from '@uppy/core'
 import DragDropLocale from './generatedLocale'
 
-declare module DragDrop {
-  interface DragDropOptions extends PluginOptions {
-    replaceTargetContent?: boolean
-    target?: PluginTarget
-    inputName?: string
-    allowMultipleFiles?: boolean
-    width?: string | number
-    height?: string | number
-    note?: string
-    locale?: DragDropLocale
-    onDragOver?: (event: MouseEvent) => void
-    onDragLeave?: (event: MouseEvent) => void
-    onDrop?: (event: MouseEvent) => void
-  }
+export interface DragDropOptions extends PluginOptions {
+  replaceTargetContent?: boolean
+  target?: PluginTarget
+  inputName?: string
+  allowMultipleFiles?: boolean
+  width?: string | number
+  height?: string | number
+  note?: string
+  locale?: DragDropLocale
+  onDragOver?: (event: MouseEvent) => void
+  onDragLeave?: (event: MouseEvent) => void
+  onDrop?: (event: MouseEvent) => void
 }
 
-declare class DragDrop extends UIPlugin<DragDrop.DragDropOptions> {}
+declare class DragDrop extends UIPlugin<DragDropOptions> {}
 
 export default DragDrop

+ 7 - 8
packages/@uppy/progress-bar/types/index.d.ts

@@ -1,14 +1,13 @@
 import type { PluginOptions, UIPlugin, PluginTarget } from '@uppy/core'
 
-declare module ProgressBar {
-  interface ProgressBarOptions extends PluginOptions {
-    replaceTargetContent?: boolean
-    target?: PluginTarget
-    hideAfterFinish?: boolean
-    fixed?: boolean
-  }
+export interface ProgressBarOptions extends PluginOptions {
+  replaceTargetContent?: boolean
+  target?: PluginTarget
+  hideAfterFinish?: boolean
+  fixed?: boolean
 }
 
-declare class ProgressBar extends UIPlugin<ProgressBar.ProgressBarOptions> {}
+
+declare class ProgressBar extends UIPlugin<ProgressBarOptions> {}
 
 export default ProgressBar

+ 2 - 2
packages/@uppy/react/src/Dashboard.d.ts

@@ -1,10 +1,10 @@
 import * as React from 'react'
 import { Omit, ToUppyProps } from './CommonTypes'
-import Dashboard from '@uppy/dashboard'
+import type {DashboardOptions} from '@uppy/dashboard'
 
 // This type is mapped into `DashboardProps` below so IntelliSense doesn't display this big mess of nested types
 type DashboardPropsInner = Omit<
-  ToUppyProps<Dashboard.DashboardOptions>,
+  ToUppyProps<DashboardOptions>,
   // Remove the modal-only props
   'animateOpenClose' | 'browserBackButtonClose' | 'inline' | 'onRequestCloseModal' | 'trigger'
 > & React.BaseHTMLAttributes<HTMLDivElement>

+ 2 - 2
packages/@uppy/react/src/DashboardModal.d.ts

@@ -1,12 +1,12 @@
 import { Omit, ToUppyProps } from './CommonTypes'
-import Dashboard from '@uppy/dashboard'
+import type { DashboardOptions } from '@uppy/dashboard'
 
 // This type is mapped into `DashboardModalProps` below so IntelliSense doesn't display this big mess of nested types
 type DashboardModalPropsInner = {
   open?: boolean
   onRequestClose?: VoidFunction
 } & Omit<
-  ToUppyProps<Dashboard.DashboardOptions>,
+  ToUppyProps<DashboardOptions>,
   // Remove the inline-only and force-overridden props
   'inline' | 'onRequestCloseModal'
 > & React.BaseHTMLAttributes<HTMLDivElement>

+ 2 - 2
packages/@uppy/react/src/DragDrop.d.ts

@@ -1,7 +1,7 @@
 import { ToUppyProps } from './CommonTypes'
-import DragDrop from '@uppy/drag-drop'
+import type { DragDropOptions } from '@uppy/drag-drop'
 
-export type DragDropProps = ToUppyProps<DragDrop.DragDropOptions>  & React.BaseHTMLAttributes<HTMLDivElement>
+export type DragDropProps = ToUppyProps<DragDropOptions>  & React.BaseHTMLAttributes<HTMLDivElement>
 
 /**
  * React component that renders an area in which files can be dropped to be

+ 2 - 2
packages/@uppy/react/src/ProgressBar.d.ts

@@ -1,7 +1,7 @@
 import { ToUppyProps } from './CommonTypes'
-import ProgressBar from '@uppy/progress-bar'
+import type { ProgressBarOptions } from '@uppy/progress-bar'
 
-export type ProgressBarProps = ToUppyProps<ProgressBar.ProgressBarOptions> & React.BaseHTMLAttributes<HTMLDivElement>
+export type ProgressBarProps = ToUppyProps<ProgressBarOptions> & React.BaseHTMLAttributes<HTMLDivElement>
 
 /**
  * React component that renders a progress bar at the top of the page.

+ 2 - 2
packages/@uppy/react/src/StatusBar.d.ts

@@ -1,7 +1,7 @@
 import { ToUppyProps } from './CommonTypes'
-import StatusBar from '@uppy/status-bar'
+import type { StatusBarOptions } from '@uppy/status-bar'
 
-export type StatusBarProps = ToUppyProps<StatusBar.StatusBarOptions>  & React.BaseHTMLAttributes<HTMLDivElement>
+export type StatusBarProps = ToUppyProps<StatusBarOptions>  & React.BaseHTMLAttributes<HTMLDivElement>
 
 /**
  * React component that renders a status bar containing upload progress and speed,

+ 13 - 15
packages/@uppy/status-bar/types/index.d.ts

@@ -1,23 +1,21 @@
 import type { PluginOptions, UIPlugin, PluginTarget } from '@uppy/core'
 import GeneratedLocale from './generatedLocale'
 
-declare module StatusBar {
-  export type StatusBarLocale = GeneratedLocale
+export type StatusBarLocale = GeneratedLocale
 
-  export interface StatusBarOptions extends PluginOptions {
-    replaceTargetContent?: boolean
-    target?: PluginTarget
-    showProgressDetails?: boolean
-    hideUploadButton?: boolean
-    hideAfterFinish?: boolean
-    hideRetryButton?: boolean,
-    hidePauseResumeButton?: boolean,
-    hideCancelButton?: boolean,
-    doneButtonHandler?: () => void,
-    locale?: StatusBarLocale
-  }
+export interface StatusBarOptions extends PluginOptions {
+  replaceTargetContent?: boolean
+  target?: PluginTarget
+  showProgressDetails?: boolean
+  hideUploadButton?: boolean
+  hideAfterFinish?: boolean
+  hideRetryButton?: boolean,
+  hidePauseResumeButton?: boolean,
+  hideCancelButton?: boolean,
+  doneButtonHandler?: () => void,
+  locale?: StatusBarLocale
 }
 
-declare class StatusBar extends UIPlugin<StatusBar.StatusBarOptions> {}
+declare class StatusBar extends UIPlugin<StatusBarOptions> {}
 
 export default StatusBar

+ 1 - 1
test/endtoend/typescript/main.ts

@@ -14,7 +14,7 @@ import {
 const isOnTravis = !!(process.env.TRAVIS && process.env.CI)
 const TUS_ENDPOINT = `http://${isOnTravis ? 'companion.test' : 'localhost'}:1080/files/`
 
-const uppy = Core({
+const uppy = new Core({
   debug: true,
   meta: {
     username: 'John',