UNPKG

choerodon-ui

Version:

An enterprise-class UI design language and React-based implementation

147 lines (146 loc) 5.91 kB
/** * 裁剪头像上传 */ import React, { Component } from 'react'; import { AxiosRequestConfig } from 'axios'; import PropTypes from 'prop-types'; import { ModalProps } from '../modal'; import { UploadProps } from '../upload'; import { ConfigContextValue } from '../config-provider/ConfigContext'; export interface Limit { size: number; type: string; } export interface AvatarArea { rotate: number; startX: number; startY: number; endX: number; endY: number; file?: File; } export interface AvatarUploadProps { visible: boolean; onClose?: (visible: boolean) => void; onUploadOk?: (res: any) => void; uploadUrl?: string; uploadFaild?: () => void; uploadError?: (error: any) => void; handleUpload?: (area: AvatarArea) => void; cropComplete?: (imageState: any) => void; title?: string | React.ReactElement; previewTitle?: string | React.ReactElement; reloadTitle?: string | React.ReactElement; uploadProps?: UploadProps; modalProps?: ModalProps; limit: Limit; previewList: number[]; editorWidth: number; editorHeight: number; rectSize: number; axiosConfig?: AxiosRequestConfig; prefixCls?: string; } export default class AvatarUploader extends Component<AvatarUploadProps, any> { static get contextType(): React.Context<ConfigContextValue>; static propTypes: { visible: PropTypes.Validator<boolean>; onClose: PropTypes.Requireable<(...args: any[]) => any>; onUploadOk: PropTypes.Requireable<(...args: any[]) => any>; limit: PropTypes.Requireable<object>; uploadUrl: PropTypes.Requireable<string>; previewList: PropTypes.Requireable<any[]>; editorWidth: PropTypes.Requireable<number>; editorHeight: PropTypes.Requireable<number>; rectSize: PropTypes.Requireable<number>; prefixCls: PropTypes.Requireable<string>; handleUpload: PropTypes.Requireable<(...args: any[]) => any>; axiosConfig: PropTypes.Requireable<object>; cropComplete: PropTypes.Requireable<(...args: any[]) => any>; title: PropTypes.Requireable<string | object>; previewTitle: PropTypes.Requireable<string | object>; reloadTitle: PropTypes.Requireable<string | object>; uploadProps: PropTypes.Requireable<object>; modalProps: PropTypes.Requireable<object>; reloadText: PropTypes.Requireable<(...args: any[]) => any>; uploadFaild: PropTypes.Requireable<(...args: any[]) => any>; uploadError: PropTypes.Requireable<(...args: any[]) => any>; }; static defaultProps: { limit: { type: string; size: number; }; previewList: number[]; editorWidth: number; editorHeight: number; rectSize: number; }; context: ConfigContextValue; constructor(props: any, context: ConfigContextValue); zoomImage: (type: any) => void; handleOk: () => void; close(): void; uploadOk(res: any): void; handleCancel: () => void; initImageSize(img: any, rotate?: number): void; onComplete(imgState: any): void; loadImage(src: any): void; getPreviewProps(previewSize: any): object; renderPreviewItem(previewSizeList: any): any; renderEditor(props: any): JSX.Element; getUploadProps(): { beforeUpload: (file: any) => boolean; onChange: ({ file }: { file: any; }) => void; multiple: boolean; name: string; accept: string; headers: { Authorization: string; }; showUploadList: boolean; } | { beforeUpload: (file: any) => boolean; onChange: ({ file }: { file: any; }) => void; type?: "select" | "drag" | undefined; name: string; defaultFileList?: import("../upload/interface").UploadFile[] | undefined; fileList?: import("../upload/interface").UploadFile[] | undefined; action?: string | undefined; data?: Record<string, any> | ((file: import("../upload/interface").UploadFile) => any) | undefined; headers: import("../upload/interface").HttpRequestHeader | { Authorization: string; }; showUploadList: boolean | import("../upload/interface").ShowUploadListInterface; multiple: boolean; dragUploadList?: boolean | undefined; accept: string; listType?: "picture" | "text" | "picture-card" | undefined; className?: string | undefined; onStart?: ((file: import("../upload/interface").UploadFile) => void) | undefined; onPreview?: ((file: import("../upload/interface").UploadFile) => void) | undefined; onDragEnd?: ((files: import("../upload/interface").UploadFile[]) => boolean | void) | undefined; onRemove?: ((file: import("../upload/interface").UploadFile) => boolean | void) | undefined; onSuccess?: ((response: any, file: import("../upload/interface").UploadFile) => void) | undefined; onProgress?: ((e: { percent: number; }, file: import("../upload/interface").UploadFile) => void) | undefined; onError?: ((error: Error, response: any, file: import("../upload/interface").UploadFile) => void) | undefined; supportServerRender?: boolean | undefined; style?: React.CSSProperties | undefined; disabled?: boolean | undefined; prefixCls?: string | undefined; customRequest?: ((option: any) => void) | undefined; previewFile?: ((file: Blob | File) => PromiseLike<string>) | undefined; withCredentials?: boolean | undefined; locale?: import("../upload/interface").UploadLocale | undefined; requestFileKeys?: string | string[] | undefined; showFileSize?: boolean | undefined; }; renderContainer(): JSX.Element; render(): JSX.Element; }