Sfoglia il codice sorgente

Add Typescript types for Uppy's React components.

Matthias Bohlen 6 anni fa
parent
commit
421441824a

+ 6 - 0
packages/@uppy/react/src/CommonTypes.d.ts

@@ -0,0 +1,6 @@
+export { Uppy } from '../../core/types';
+
+export interface Locale {
+    strings: { [index: string]: string };
+    pluralize: (noun: string) => string;
+}

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

@@ -0,0 +1,33 @@
+import { Uppy, Locale } from './CommonTypes';
+
+interface MetaField {
+    id: string;
+    name: string;
+    placeholder?: string;
+}
+
+export interface DashboardProps {
+    uppy: Uppy;
+    inline?: boolean;
+    plugins?: Array<string>;
+    width?: number;
+    height?: number;
+    showProgressDetails?: boolean;
+    showLinkToFileUploadResult?: boolean;
+    hideUploadButton?: boolean;
+    hideProgressAfterFinish?: boolean;
+    note?: string;
+    metaFields?: Array<MetaField>;
+    proudlyDisplayPoweredByUppy?: boolean;
+    disableStatusBar?: boolean;
+    disableInformer?: boolean;
+    disableThumbnailGenerator?: boolean;
+    locale?: Locale;
+}
+
+/**
+ * React Component that renders a Dashboard for an Uppy instance. This component
+ * renders the Dashboard inline; so you can put it anywhere you want.
+ */
+declare const Dashboard: React.ComponentType<DashboardProps>;
+export default Dashboard;

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

@@ -0,0 +1,16 @@
+import { DashboardProps } from './Dashboard';
+
+export interface DashboardModalProps extends DashboardProps {
+    target?: HTMLElement;
+    open?: boolean;
+    onRequestClose?: VoidFunction;
+    closeModalOnClickOutside?: boolean;
+    disablePageScrollWhenModalOpen?: boolean;
+}
+
+/**
+ * React Component that renders a Dashboard for an Uppy instance in a Modal
+ * dialog. Visibility of the Modal is toggled using the `open` prop.
+ */
+declare const DashboardModal: React.ComponentType<DashboardModalProps>;
+export default DashboardModal;

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

@@ -0,0 +1,13 @@
+import { Uppy, Locale } from './CommonTypes';
+
+export interface DragDropProps {
+    uppy: Uppy;
+    locale?: Locale;
+}
+
+/**
+ * React component that renders an area in which files can be dropped to be
+ * uploaded.
+ */
+declare const DragDrop: React.ComponentType<DragDropProps>;
+export default DragDrop;

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

@@ -0,0 +1,13 @@
+import { Uppy } from './CommonTypes';
+
+export interface ProgressBarProps {
+    uppy: Uppy;
+    fixed?: boolean;
+    hideAfterFinish?: boolean;
+}
+
+/**
+ * React component that renders a progress bar at the top of the page.
+ */
+declare const ProgressBar: React.ComponentType<ProgressBarProps>;
+export default ProgressBar;

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

@@ -0,0 +1,14 @@
+import { Uppy } from './CommonTypes';
+
+export interface StatusBarProps {
+    uppy: Uppy;
+    showProgressDetails?: boolean;
+    hideAfterFinish?: boolean;
+}
+
+/**
+ * React component that renders a status bar containing upload progress and speed,
+ * processing progress and pause/resume/cancel controls.
+ */
+declare const StatusBar: React.ComponentType<StatusBarProps>;
+export default StatusBar;

+ 7 - 0
packages/@uppy/react/types/index.d.ts

@@ -0,0 +1,7 @@
+import * as React from 'react';
+
+export { default as Dashboard } from '../src/Dashboard';
+export { default as DashboardModal } from '../src/DashboardModal';
+export { default as DragDrop } from '../src/DragDrop';
+export { default as ProgressBar } from '../src/ProgressBar';
+export { default as StatusBar } from '../src/StatusBar';