Created
November 26, 2018 11:12
-
-
Save hgenru/7a7aa4af2dc0e9e704777655e9182cc8 to your computer and use it in GitHub Desktop.
FilePond typing draft
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare module 'filepond' { | |
type Func = (...args: any[]) => any | |
type Source = string | File | Blob | |
type Headers = {[header: string]: string} | |
type Process = ( | |
isFinite: boolean, | |
loaded: number, | |
total: number, | |
) => void | |
type Query = number | string | |
type ServerApiObjProcessFuncReturns = { | |
abort: () => void | |
} | |
type ServerApiObjProcessFunc = ( | |
fieldName: string, | |
file: File, | |
metadata: any, | |
load: (requestId: string | object) => void, | |
error: (errorText: string) => void, | |
progress: Process, | |
abort: () => void, | |
) => ServerApiObjProcessFuncReturns | |
type ServerApiObjRevertFunc = { | |
uniqueFileId: string | |
load: () => void | |
error: () => void | |
} | |
type ServerApiObjLoadAndRestoreFunc = ( | |
uniqueFileId: string, | |
load: () => void, | |
error: () => void, | |
progress: Process, | |
abort: () => void, | |
headers: Headers, | |
) => void | |
type ServerApiObjFetchFunc = ( | |
url: string, | |
load: (file: File) => void, | |
error: () => void, | |
progress: Process, | |
abort: () => void, | |
headers: (headersString: string) => void, | |
) => void | |
type ServerApiObjProcessObj = { | |
url: string | |
method?: string | |
withCredentials?: boolean | |
headers?: Headers | |
timeout?: number | |
onload?: (response: any) => void | |
onerror?: (response: any) => void | |
} | |
type ServerApiObj = { | |
url?: string | |
process?: | |
| string | |
| ServerApiObjProcessObj | |
| ServerApiObjProcessFunc | |
revert?: string | ServerApiObjRevertFunc | |
restore?: string | ServerApiObjLoadAndRestoreFunc | |
load?: string | ServerApiObjLoadAndRestoreFunc | |
fetch?: string | ServerApiObjFetchFunc | |
} | |
type FilePondOptionsServerApi = string | ServerApiObj | |
export type FilePondOptions = { | |
acceptedFileTypes?: string[] | |
allowBrowse?: boolean | |
allowDrop?: boolean | |
allowFileEncode?: boolean | |
allowFileSizeValidation?: boolean | |
allowFileTypeValidation?: boolean | |
allowImageCrop?: boolean | |
allowImageEdit?: boolean | |
allowImageExifOrientation?: boolean | |
allowImagePreview?: boolean | |
allowImageResize?: boolean | |
allowImageTransform?: boolean | |
allowMultiple?: boolean | |
allowPaste?: boolean | |
allowReplace?: boolean | |
allowRevert?: boolean | |
beforeRemoveFile?: Func | |
captureMethod?: string | |
className?: string | |
dropOnElement?: boolean | |
dropOnPage?: boolean | |
dropValidation?: boolean | |
fileValidateTypeDetectType?: Func | |
fileValidateTypeLabelExpectedTypes?: string | |
fileValidateTypeLabelExpectedTypesMap?: { | |
[key: string]: string | |
} | |
files?: Array<string | File | Blob> | |
iconDone?: string | |
iconProcess?: string | |
iconRemove?: string | |
iconRetry?: string | |
iconUndo?: string | |
id?: string | |
ignoredFiles?: string[] | |
imageCropAspectRatio?: string | |
imageEditAllowEdit?: boolean | |
imageEditIconEdit?: string | |
imageEditImageTurnRight?: boolean | |
imageEditInstantEdit?: boolean | |
imageEditResizeKeyCodes?: any | |
imagePreviewHeight?: number | |
imagePreviewMaxFileSize?: number | |
imagePreviewMaxHeight?: number | |
imagePreviewMinHeight?: number | |
imagePreviewTransparencyIndicator?: string | |
imageResizeMode?: string | |
imageResizeTargetHeight?: number | |
imageResizeTargetWidth?: number | |
imageResizeUpscale?: boolean | |
imageTransformOutputMimeType?: string | |
imageTransformOutputQuality?: number | |
imageTransformOutputQualityMode?: string | |
instantUpload?: boolean | |
labelButtonAbortItemLoad?: string | |
labelButtonAbortItemProcessing?: string | |
labelButtonProcessItem?: string | |
labelButtonRemoveItem?: string | |
labelButtonRetryItemLoad?: string | |
labelButtonRetryItemProcessing?: string | |
labelButtonUndoItemProcessing?: string | |
labelDecimalSeparator?: string | |
labelFileAdded?: string | |
labelFileCountPlural?: string | |
labelFileCountSingular?: string | |
labelFileLoadError?: string | |
labelFileLoading?: string | |
labelFileProcessing?: string | |
labelFileProcessingAborted?: string | |
labelFileProcessingComplete?: string | |
labelFileProcessingError?: string | |
labelFileRemoved?: string | |
labelFileSizeNotAvailable?: string | |
labelFileTypeNotAllowed?: string | |
labelFileWaitingForSize?: string | |
labelIdle?: string | |
labelMaxFileSize?: string | |
labelMaxFileSizeExceeded?: string | |
labelMaxTotalFileSize?: string | |
labelMaxTotalFileSizeExceeded?: string | |
labelTapToCancel?: string | |
labelTapToRetry?: string | |
labelTapToUndo?: string | |
labelThousandsSeparator?: string | |
maxFileSize?: number | |
maxFiles?: number | |
maxTotalFileSize?: number | |
name?: string | |
onaddfile?: Func | |
onaddfileprogress?: Func | |
onaddfilestart?: Func | |
onerror?: Func | |
oninit?: Func | |
onpreparefile?: Func | |
onprocessfile?: Func | |
onprocessfileabort?: Func | |
onprocessfileprogress?: Func | |
onprocessfilerevert?: Func | |
onprocessfilestart?: Func | |
onremovefile?: Func | |
onupdatefiles?: Func | |
onwarning?: Func | |
required?: boolean | |
server?: FilePondOptionsServerApi | |
styleButtonProcessItemPosition?: string | |
styleButtonRemoveItemPosition?: string | |
styleImageEditButtonEditItemPosition?: string | |
styleLoadIndicatorPosition?: string | |
stylePanelAspectRatio?: string | |
stylePanelLayout?: string | |
styleProgressIndicatorPosition?: string | |
} | |
type FileStatuses = | |
| 'IDLE' | |
| 'INIT' | |
| 'LOADING' | |
| 'LOAD_ERROR' | |
| 'PROCESSING' | |
| 'PROCESSING_COMPLETE' | |
| 'PROCESSING_ERROR' | |
| 'PROCESSING_PAUSED' | |
| 'PROCESSING_QUEUED' | |
type FileOrigins = 'INPUT' | 'LIMBO' | 'LOCAL' | |
type AddFileOptions = { | |
index: number | |
} | |
type FilePondInstance = { | |
setOptions: (filePondOptions: FilePondOptions) => void | |
addFile: ( | |
source: Source, | |
options: AddFileOptions, | |
) => Promise<File> | |
addFiles: ( | |
sources: Source[], | |
options: AddFileOptions, | |
) => void | |
removeFile: (query: Query) => void | |
processFile: (query: Query) => Promise<File> | |
processFiles: ( | |
sources: Source[], | |
options: AddFileOptions, | |
) => void | |
getFile: (query: Query) => File | |
getFiles: () => File[] | |
browse: () => void | |
destroy: () => void | |
} | |
const supported: () => boolean | |
const FileStatus: {[status in FileStatuses]: number} | |
const FileOrigin: {[origin in FileOrigins]: number} | |
const OptionTypes: {[option in keyof FilePondOptions]: string} | |
const create: Func | |
const destroy: Func | |
const parse: Func | |
const find: Func | |
const getOptions: Func | |
const setOptions: Func | |
const registerPlugin: Func | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// tslint:disable:max-classes-per-file | |
declare module 'react-filepond' { | |
import * as React from 'react' | |
import { | |
registerPlugin as fpRegisterPlugin, | |
FilePondOptions, | |
FilePondInstance, | |
} from 'filepond' | |
class FilePondElement extends HTMLElement { | |
public pond: FilePondInstance | |
} | |
type FilePondProps = | |
| { | |
ref: React.RefObject<FilePondElement> | |
} | |
| FilePondOptions | |
class FilePond extends React.Component<FilePondProps> {} | |
const registerPlugin: typeof fpRegisterPlugin | |
const File: any // it's a filepond's react component | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello! Has your sample been used for creation an official typings for FilePond? If not, can You help me with this one, for ex. how to use it in my project?