Skip to content
This repository has been archived by the owner on Jan 29, 2019. It is now read-only.

Commit

Permalink
feat(events): adds file acceptance hooks & typescript integration (#2)
Browse files Browse the repository at this point in the history
* feat(typescript): set up TS toolchain and migrate core to typescript

* feat(events): added acceptance events

`accepted-file`: accept callback returns without error
`rejected-file`: accept callback returns error
`accept-complete`: accept callback completed

* feat(ts-declarations): export TS declarations
  • Loading branch information
alexsasharegan authored Oct 1, 2017
1 parent da97d4c commit 3dad7ec
Show file tree
Hide file tree
Showing 24 changed files with 768 additions and 716 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ Vue.use(VueTransmit)
|`drag-leave`| `DragEvent` | The `drag-leave` event is fired when a dragged element or text selection leaves a valid drop target. |
|`added-file`| `VTransmitFile` | Fired on change from the hidden file input after the Native File has been copied to VTransmitFile and added to the component data. _(status: 'added')_ |
|`added-files`| `VTransmitFile[]` | Fired on change from the hidden file input after the Native Files have been copied to VTransmitFiles and added to the component data. _(status: 'added')_ |
|`accepted-file`| `VTransmitFile` | Fired if the user-supplied accept function returns without error. _(status: 'added', accepted: true)_ |
|`rejected-file`| `VTransmitFile` | Fired if the user-supplied accept function returns an error. Fired AFTER the `error` event to ensure correct file status. _(status: 'error', accepted: false)_ |
|`accept-complete`| `VTransmitFile` | Fired after the user-supplied accept function has returned regardless of success/failure. Fired after `accepted-file` & `rejected-file`. _(status: ?, accepted: ?)_ |
|`removed-file`| `VTransmitFile` | Fired on the removal of a file. |
|`thumbnail`| `VTransmitFile, Blob\|URL` | Fires on creation of a thumbnail. |
|`error`| `VTransmitFile, message: String, XmlHttpRequest` | Fired on an ajax upload error. _(status: 'error')_ |
Expand Down
42 changes: 42 additions & 0 deletions dist/src/classes/VTransmitFile.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
export interface IUploadStats {
bytesSent: number;
progress: number;
total: number;
speed: ISpeedStats;
start: number;
end: number;
time: number;
}
export interface ISpeedStats {
kbps: number;
mbps: number;
}
export default class VTransmitFile {
private _nativeFile;
id: string;
accepted: boolean;
lastModified: number;
lastModifiedDate: Date;
name: string;
processing: boolean;
size: number;
status: string;
type: string;
upload: IUploadStats;
webkitRelativePath: USVString;
width: number;
height: number;
xhr: XMLHttpRequest;
dataUrl: string;
errorMessage: string;
constructor(...data: object[]);
set(...data: object[]): VTransmitFile;
copyNativeFile(file: File): VTransmitFile;
copyOwnAndInheritedProps(...data: object[]): VTransmitFile;
handleProgress(e: ProgressEvent): void;
startProgress(): VTransmitFile;
endProgress(): VTransmitFile;
nativeFile: File;
static fromNativeFile(file: File, ...data: any[]): VTransmitFile;
static idFactory(): string;
}
23 changes: 23 additions & 0 deletions dist/src/core/utils.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export declare const assign: {
<T, U>(target: T, source: U): T & U;
<T, U, V>(target: T, source1: U, source2: V): T & U & V;
<T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
(target: object, ...sources: any[]): any;
};
export declare function uniqueId(prefix: string): string;
export declare function copyOwnAndInheritedProps(obj: object): object;
export declare type Rounding = "round" | "ceil" | "floor" | "trunc";
export declare function round(number: number, decimals?: number, roundStyle?: Rounding): number;
export declare function fromBytesToKbit(bytes: number): number;
export declare function fromBytesToMbit(bytes: number): number;
export declare function toKbps(bytes: number, seconds: number): number;
export declare function toMbps(bytes: number, seconds: number): number;
export declare const hbsRegex: RegExp;
export declare function hbsReplacer(context?: object): (match: string, capture: string) => any;
export declare enum READY_STATES {
UNSENT = 0,
OPENED = 1,
HEADERS_RECEIVED = 2,
LOADING = 3,
DONE = 4,
}
Loading

0 comments on commit 3dad7ec

Please sign in to comment.