ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
253 lines (244 loc) • 12 kB
TypeScript
import * as i0 from '@angular/core';
import { TemplateRef, OnInit, ElementRef, OnChanges, AfterViewInit, EventEmitter } from '@angular/core';
import { Observable, Subscription } from 'rxjs';
import { NzSafeAny, IndexableObject, BooleanInput } from 'ng-zorro-antd/core/types';
import { Direction } from '@angular/cdk/bidi';
import { NzUploadI18nInterface } from 'ng-zorro-antd/i18n';
/**
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/
/** Status */
type UploadFileStatus = 'error' | 'success' | 'done' | 'uploading' | 'removed';
type NzUploadType = 'select' | 'drag';
/** Built-in styles of the uploading list. */
type NzUploadListType = 'text' | 'picture' | 'picture-card';
interface NzUploadFile {
uid: string;
size?: number;
name: string;
filename?: string;
lastModified?: string;
lastModifiedDate?: Date;
url?: string;
status?: UploadFileStatus;
originFileObj?: File;
percent?: number;
thumbUrl?: string;
response?: NzSafeAny;
error?: NzSafeAny;
linkProps?: {
download: string;
};
type?: string;
[key: string]: NzSafeAny;
}
interface NzUploadChangeParam {
file: NzUploadFile;
fileList: NzUploadFile[];
event?: {
percent: number;
};
/** Callback type. */
type?: string;
}
interface NzShowUploadList {
showRemoveIcon?: boolean;
showPreviewIcon?: boolean;
showDownloadIcon?: boolean;
}
type NzUploadTransformFileType = string | Blob | NzUploadFile | Observable<string | Blob | File>;
interface ZipButtonOptions {
disabled?: boolean;
accept?: string | string[];
action?: string | ((file: NzUploadFile) => string | Observable<string>);
directory?: boolean;
openFileDialogOnClick?: boolean;
beforeUpload?(file: NzUploadFile, fileList: NzUploadFile[]): boolean | Observable<NzSafeAny>;
customRequest?(item: NzSafeAny): Subscription;
data?: {} | ((file: NzUploadFile) => {} | Observable<{}>);
headers?: {} | ((file: NzUploadFile) => {} | Observable<{}>);
name?: string;
multiple?: boolean;
withCredentials?: boolean;
filters?: UploadFilter[];
transformFile?(file: NzUploadFile): NzUploadTransformFileType;
onStart?(file: NzUploadFile): void;
onProgress?(e: NzSafeAny, file: NzUploadFile): void;
onSuccess?(ret: NzSafeAny, file: NzUploadFile, xhr: NzSafeAny): void;
onError?(err: NzSafeAny, file: NzUploadFile): void;
}
interface UploadFilter {
name: string;
fn(fileList: NzUploadFile[]): NzUploadFile[] | Observable<NzUploadFile[]>;
}
interface NzUploadXHRArgs {
action?: string;
name?: string;
headers?: IndexableObject;
file: NzUploadFile;
postFile: string | Blob | File | NzUploadFile;
data?: IndexableObject;
withCredentials?: boolean;
onProgress?(e: NzSafeAny, file: NzUploadFile): void;
onSuccess?(ret: NzSafeAny, file: NzUploadFile, xhr: NzSafeAny): void;
onError?(err: NzSafeAny, file: NzUploadFile): void;
}
type NzIconRenderTemplate = TemplateRef<{
$implicit: NzUploadFile;
}>;
declare class NzUploadBtnComponent implements OnInit {
reqs: Record<string, Subscription>;
private destroyed;
file: ElementRef<HTMLInputElement>;
options: ZipButtonOptions;
onClick(): void;
onFileDrop(e: DragEvent): void;
onChange(e: Event): void;
private traverseFileTree;
private attrAccept;
private attachUid;
uploadFiles(fileList: FileList | File[]): void;
private upload;
private post;
private xhr;
private clean;
abort(file?: NzUploadFile): void;
private http;
private elementRef;
private destroyRef;
constructor();
ngOnInit(): void;
static ɵfac: i0.ɵɵFactoryDeclaration<NzUploadBtnComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<NzUploadBtnComponent, "[nz-upload-btn]", ["nzUploadBtn"], { "options": { "alias": "options"; "required": false; }; }, {}, never, ["*"], true, never>;
}
type UploadListIconType = '' | 'uploading' | 'thumbnail';
interface UploadListFile extends NzUploadFile {
isImageUrl?: boolean;
isUploading?: boolean;
iconType?: UploadListIconType;
showDownload?: boolean;
}
declare class NzUploadListComponent implements OnChanges {
list: UploadListFile[];
private get showPic();
locale: NzSafeAny;
listType: NzUploadListType;
set items(list: NzUploadFile[]);
icons: NzShowUploadList;
onPreview?: (file: NzUploadFile) => void;
onRemove: (file: NzUploadFile) => void;
onDownload?: (file: NzUploadFile) => void;
previewFile?: (file: NzUploadFile) => Observable<string>;
previewIsImage?: (file: NzUploadFile) => boolean;
iconRender: NzIconRenderTemplate | null;
dir: Direction;
private document;
private destroyRef;
private ngZone;
private cdr;
private platform;
private genErr;
private extname;
isImageUrl(file: NzUploadFile): boolean;
private getIconType;
private previewImage;
private genThumb;
private showDownload;
private fixData;
handlePreview(file: NzUploadFile, e: Event): void;
handleRemove(file: NzUploadFile, e: Event): void;
handleDownload(file: NzUploadFile): void;
detectChanges(): void;
ngOnChanges(): void;
static ɵfac: i0.ɵɵFactoryDeclaration<NzUploadListComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<NzUploadListComponent, "nz-upload-list", ["nzUploadList"], { "locale": { "alias": "locale"; "required": false; }; "listType": { "alias": "listType"; "required": false; }; "items": { "alias": "items"; "required": false; }; "icons": { "alias": "icons"; "required": false; }; "onPreview": { "alias": "onPreview"; "required": false; }; "onRemove": { "alias": "onRemove"; "required": false; }; "onDownload": { "alias": "onDownload"; "required": false; }; "previewFile": { "alias": "previewFile"; "required": false; }; "previewIsImage": { "alias": "previewIsImage"; "required": false; }; "iconRender": { "alias": "iconRender"; "required": false; }; "dir": { "alias": "dir"; "required": false; }; }, {}, never, never, true, never>;
}
/**
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/
declare class NzUploadComponent implements OnInit, AfterViewInit, OnChanges {
static ngAcceptInputType_nzShowUploadList: BooleanInput | NzShowUploadList;
private cdr;
private i18n;
private directionality;
private destroyRef;
uploadComp: NzUploadBtnComponent;
listComp: NzUploadListComponent;
locale: NzUploadI18nInterface;
dir: Direction;
nzType: NzUploadType;
nzLimit: number;
nzSize: number;
nzFileType?: string;
nzAccept?: string | string[];
nzAction?: string | ((file: NzUploadFile) => string | Observable<string>);
nzDirectory: boolean;
nzOpenFileDialogOnClick: boolean;
nzBeforeUpload?: (file: NzUploadFile, fileList: NzUploadFile[]) => boolean | Observable<boolean>;
nzCustomRequest?: (item: NzUploadXHRArgs) => Subscription;
nzData?: {} | ((file: NzUploadFile) => {} | Observable<{}>);
nzFilter: UploadFilter[];
nzFileList: NzUploadFile[];
nzDisabled: boolean;
nzHeaders?: {} | ((file: NzUploadFile) => {} | Observable<{}>);
nzListType: NzUploadListType;
nzMultiple: boolean;
nzName: string;
private _showUploadList;
private document;
set nzShowUploadList(value: boolean | NzShowUploadList);
get nzShowUploadList(): boolean | NzShowUploadList;
nzShowButton: boolean;
nzWithCredentials: boolean;
nzRemove?: (file: NzUploadFile) => boolean | Observable<boolean>;
nzPreview?: (file: NzUploadFile) => void;
nzPreviewFile?: (file: NzUploadFile) => Observable<string>;
nzPreviewIsImage?: (file: NzUploadFile) => boolean;
nzTransformFile?: (file: NzUploadFile) => NzUploadTransformFileType;
nzDownload?: (file: NzUploadFile) => void;
nzIconRender: NzIconRenderTemplate | null;
nzFileListRender: TemplateRef<{
$implicit: NzUploadFile[];
}> | null;
readonly nzChange: EventEmitter<NzUploadChangeParam>;
readonly nzFileListChange: EventEmitter<NzUploadFile[]>;
_btnOptions?: ZipButtonOptions;
private zipOptions;
private readonly platform;
private fileToObject;
private getFileItem;
private removeFileItem;
private onStart;
private onProgress;
private onSuccess;
private onError;
private dragState?;
fileDrop(e: DragEvent): void;
private detectChangesList;
onRemove: (file: NzUploadFile) => void;
private prefixCls;
classList: string[];
private setClassMap;
ngOnInit(): void;
ngAfterViewInit(): void;
ngOnChanges(): void;
static ɵfac: i0.ɵɵFactoryDeclaration<NzUploadComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<NzUploadComponent, "nz-upload", ["nzUpload"], { "nzType": { "alias": "nzType"; "required": false; }; "nzLimit": { "alias": "nzLimit"; "required": false; }; "nzSize": { "alias": "nzSize"; "required": false; }; "nzFileType": { "alias": "nzFileType"; "required": false; }; "nzAccept": { "alias": "nzAccept"; "required": false; }; "nzAction": { "alias": "nzAction"; "required": false; }; "nzDirectory": { "alias": "nzDirectory"; "required": false; }; "nzOpenFileDialogOnClick": { "alias": "nzOpenFileDialogOnClick"; "required": false; }; "nzBeforeUpload": { "alias": "nzBeforeUpload"; "required": false; }; "nzCustomRequest": { "alias": "nzCustomRequest"; "required": false; }; "nzData": { "alias": "nzData"; "required": false; }; "nzFilter": { "alias": "nzFilter"; "required": false; }; "nzFileList": { "alias": "nzFileList"; "required": false; }; "nzDisabled": { "alias": "nzDisabled"; "required": false; }; "nzHeaders": { "alias": "nzHeaders"; "required": false; }; "nzListType": { "alias": "nzListType"; "required": false; }; "nzMultiple": { "alias": "nzMultiple"; "required": false; }; "nzName": { "alias": "nzName"; "required": false; }; "nzShowUploadList": { "alias": "nzShowUploadList"; "required": false; }; "nzShowButton": { "alias": "nzShowButton"; "required": false; }; "nzWithCredentials": { "alias": "nzWithCredentials"; "required": false; }; "nzRemove": { "alias": "nzRemove"; "required": false; }; "nzPreview": { "alias": "nzPreview"; "required": false; }; "nzPreviewFile": { "alias": "nzPreviewFile"; "required": false; }; "nzPreviewIsImage": { "alias": "nzPreviewIsImage"; "required": false; }; "nzTransformFile": { "alias": "nzTransformFile"; "required": false; }; "nzDownload": { "alias": "nzDownload"; "required": false; }; "nzIconRender": { "alias": "nzIconRender"; "required": false; }; "nzFileListRender": { "alias": "nzFileListRender"; "required": false; }; }, { "nzChange": "nzChange"; "nzFileListChange": "nzFileListChange"; }, never, ["*"], true, never>;
static ngAcceptInputType_nzLimit: unknown;
static ngAcceptInputType_nzSize: unknown;
static ngAcceptInputType_nzDirectory: unknown;
static ngAcceptInputType_nzOpenFileDialogOnClick: unknown;
static ngAcceptInputType_nzDisabled: unknown;
static ngAcceptInputType_nzMultiple: unknown;
static ngAcceptInputType_nzShowButton: unknown;
static ngAcceptInputType_nzWithCredentials: unknown;
}
declare class NzUploadModule {
static ɵfac: i0.ɵɵFactoryDeclaration<NzUploadModule, never>;
static ɵmod: i0.ɵɵNgModuleDeclaration<NzUploadModule, never, [typeof NzUploadComponent, typeof NzUploadBtnComponent, typeof NzUploadListComponent], [typeof NzUploadComponent]>;
static ɵinj: i0.ɵɵInjectorDeclaration<NzUploadModule>;
}
export { NzUploadBtnComponent, NzUploadComponent, NzUploadListComponent, NzUploadModule };
export type { NzIconRenderTemplate, NzShowUploadList, NzUploadChangeParam, NzUploadFile, NzUploadListType, NzUploadTransformFileType, NzUploadType, NzUploadXHRArgs, UploadFileStatus, UploadFilter, ZipButtonOptions };