interface.d.ts 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /**
  2. * Use of this source code is governed by an MIT-style license that can be
  3. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  4. */
  5. import { TemplateRef } from '@angular/core';
  6. import { Observable, Subscription } from 'rxjs';
  7. import { IndexableObject, NzSafeAny } from 'ng-zorro-antd/core/types';
  8. /** Status */
  9. export type UploadFileStatus = 'error' | 'success' | 'done' | 'uploading' | 'removed';
  10. export type NzUploadType = 'select' | 'drag';
  11. /** Built-in styles of the uploading list. */
  12. export type NzUploadListType = 'text' | 'picture' | 'picture-card';
  13. export interface NzUploadFile {
  14. uid: string;
  15. size?: number;
  16. name: string;
  17. filename?: string;
  18. lastModified?: string;
  19. lastModifiedDate?: Date;
  20. url?: string;
  21. status?: UploadFileStatus;
  22. originFileObj?: File;
  23. percent?: number;
  24. thumbUrl?: string;
  25. response?: NzSafeAny;
  26. error?: NzSafeAny;
  27. linkProps?: {
  28. download: string;
  29. };
  30. type?: string;
  31. [key: string]: NzSafeAny;
  32. }
  33. export interface NzUploadChangeParam {
  34. file: NzUploadFile;
  35. fileList: NzUploadFile[];
  36. event?: {
  37. percent: number;
  38. };
  39. /** Callback type. */
  40. type?: string;
  41. }
  42. export interface NzShowUploadList {
  43. showRemoveIcon?: boolean;
  44. showPreviewIcon?: boolean;
  45. showDownloadIcon?: boolean;
  46. }
  47. export type NzUploadTransformFileType = string | Blob | NzUploadFile | Observable<string | Blob | File>;
  48. export interface ZipButtonOptions {
  49. disabled?: boolean;
  50. accept?: string | string[];
  51. action?: string | ((file: NzUploadFile) => string | Observable<string>);
  52. directory?: boolean;
  53. openFileDialogOnClick?: boolean;
  54. beforeUpload?(file: NzUploadFile, fileList: NzUploadFile[]): boolean | Observable<NzSafeAny>;
  55. customRequest?(item: NzSafeAny): Subscription;
  56. data?: {} | ((file: NzUploadFile) => {} | Observable<{}>);
  57. headers?: {} | ((file: NzUploadFile) => {} | Observable<{}>);
  58. name?: string;
  59. multiple?: boolean;
  60. withCredentials?: boolean;
  61. filters?: UploadFilter[];
  62. transformFile?(file: NzUploadFile): NzUploadTransformFileType;
  63. onStart?(file: NzUploadFile): void;
  64. onProgress?(e: NzSafeAny, file: NzUploadFile): void;
  65. onSuccess?(ret: NzSafeAny, file: NzUploadFile, xhr: NzSafeAny): void;
  66. onError?(err: NzSafeAny, file: NzUploadFile): void;
  67. }
  68. export interface UploadFilter {
  69. name: string;
  70. fn(fileList: NzUploadFile[]): NzUploadFile[] | Observable<NzUploadFile[]>;
  71. }
  72. export interface NzUploadXHRArgs {
  73. action?: string;
  74. name?: string;
  75. headers?: IndexableObject;
  76. file: NzUploadFile;
  77. postFile: string | Blob | File | NzUploadFile;
  78. data?: IndexableObject;
  79. withCredentials?: boolean;
  80. onProgress?(e: NzSafeAny, file: NzUploadFile): void;
  81. onSuccess?(ret: NzSafeAny, file: NzUploadFile, xhr: NzSafeAny): void;
  82. onError?(err: NzSafeAny, file: NzUploadFile): void;
  83. }
  84. export type NzIconRenderTemplate = TemplateRef<{
  85. $implicit: NzUploadFile;
  86. }>;