choerodon-ui
Version:
An enterprise-class UI design language and React-based implementation
220 lines (219 loc) • 10.3 kB
TypeScript
import { ReactElement, ReactNode } from 'react';
import PropTypes from 'prop-types';
import { AxiosError, AxiosInstance, AxiosRequestConfig } from 'axios';
import { Size } from '../../../lib/_util/enum';
import { ButtonProps } from '../button/Button';
import { FormField, FormFieldProps } from '../field/FormField';
import AttachmentFile, { FileLike } from '../data-set/AttachmentFile';
import { FieldType } from '../data-set/enum';
import { ValidatorProps } from '../validator/rules';
import { ValidationMessages } from '../validator/Validator';
import ValidationResult from '../validator/ValidationResult';
import { ShowHelp } from '../field/enum';
import { ShowValidation } from '../form/enum';
export declare type AttachmentListType = 'text' | 'picture' | 'picture-card';
export interface AttachmentProps extends FormFieldProps, ButtonProps {
/**
* 可接受的上传文件类型
*/
accept?: string[];
/**
* 上传文件路径
*/
action?: string;
/**
* 上传所需参数或者返回上传参数的方法
*/
data?: object | Function;
/**
* 设置上传的请求头部
*/
headers?: any;
withCredentials?: boolean;
listType?: AttachmentListType;
viewMode?: 'none' | 'list' | 'popup';
sortable?: boolean;
fileKey?: string;
fileSize?: number;
bucketName?: string;
bucketDirectory?: string;
storageCode?: string;
pictureWidth?: number;
count?: number;
max?: number;
listLimit?: number;
showHistory?: boolean;
showValidation?: ShowValidation;
attachments?: (AttachmentFile | FileLike)[];
onAttachmentsChange?: (attachments: AttachmentFile[]) => void;
beforeUpload?: (attachment: AttachmentFile, attachments: AttachmentFile[]) => boolean | undefined | PromiseLike<boolean | undefined>;
onUploadProgress?: (percent: number, attachment: AttachmentFile) => void;
onUploadSuccess?: (response: any, attachment: AttachmentFile) => void;
onUploadError?: (error: AxiosError, response: any, attachment: AttachmentFile) => void;
downloadAll?: ButtonProps;
}
export declare type Sort = {
type: 'time' | 'name';
order: 'asc' | 'desc';
custom?: boolean;
};
export default class Attachment extends FormField<AttachmentProps> {
static displayName: string;
static defaultProps: {
suffixCls: string;
multiple: boolean;
sortable: boolean;
downloadAll: boolean;
listType: string;
viewMode: string;
readOnly: boolean;
disabled: boolean;
noValidate: boolean;
showHelp: string;
trim: import("../data-set/enum").FieldTrim;
};
static propTypes: {
sortable: PropTypes.Requireable<boolean>;
listType: PropTypes.Requireable<string>;
viewMode: PropTypes.Requireable<string>;
id: PropTypes.Requireable<string>;
size: PropTypes.Requireable<Size>;
suffixCls: PropTypes.Requireable<string>;
prefixCls: PropTypes.Requireable<string>;
title: PropTypes.Requireable<PropTypes.ReactNodeLike>;
disabled: PropTypes.Requireable<boolean>;
hidden: PropTypes.Requireable<boolean>;
autoFocus: PropTypes.Requireable<boolean>;
accessKey: PropTypes.Requireable<string | boolean>;
dir: PropTypes.Requireable<string>;
contentEditable: PropTypes.Requireable<string | boolean>;
draggable: PropTypes.Requireable<string | boolean>;
style: PropTypes.Requireable<object>;
className: PropTypes.Requireable<string>;
tabIndex: PropTypes.Requireable<number>;
lang: PropTypes.Requireable<string>;
spellCheck: PropTypes.Requireable<boolean>;
onFocus: PropTypes.Requireable<(...args: any[]) => any>;
onBlur: PropTypes.Requireable<(...args: any[]) => any>;
onClick: PropTypes.Requireable<(...args: any[]) => any>;
onDoubleClick: PropTypes.Requireable<(...args: any[]) => any>;
onMouseUp: PropTypes.Requireable<(...args: any[]) => any>;
onMouseDown: PropTypes.Requireable<(...args: any[]) => any>;
onMouseMove: PropTypes.Requireable<(...args: any[]) => any>;
onMouseEnter: PropTypes.Requireable<(...args: any[]) => any>;
onMouseLeave: PropTypes.Requireable<(...args: any[]) => any>;
onMouseOver: PropTypes.Requireable<(...args: any[]) => any>;
onMouseOut: PropTypes.Requireable<(...args: any[]) => any>;
onContextMenu: PropTypes.Requireable<(...args: any[]) => any>;
onKeyDown: PropTypes.Requireable<(...args: any[]) => any>;
onKeyUp: PropTypes.Requireable<(...args: any[]) => any>;
onKeyPress: PropTypes.Requireable<(...args: any[]) => any>;
dataSet: PropTypes.Requireable<object>;
_inTable: PropTypes.Requireable<boolean>;
type: PropTypes.Requireable<string>;
name: PropTypes.Requireable<string>;
value: PropTypes.Requireable<any>;
defaultValue: PropTypes.Requireable<any>;
required: PropTypes.Requireable<boolean>;
readOnly: PropTypes.Requireable<boolean>;
form: PropTypes.Requireable<string>;
dataIndex: PropTypes.Requireable<number>;
multiple: PropTypes.Requireable<boolean>;
range: PropTypes.Requireable<boolean | (string | null | undefined)[]>;
rowSpan: PropTypes.Requireable<number>;
newLine: PropTypes.Requireable<boolean>;
colSpan: PropTypes.Requireable<number>;
validator: PropTypes.Requireable<(...args: any[]) => any>;
onInvalid: PropTypes.Requireable<(...args: any[]) => any>;
help: PropTypes.Requireable<string>;
showHelp: PropTypes.Requireable<ShowHelp>;
renderer: PropTypes.Requireable<(...args: any[]) => any>;
validationRenderer: PropTypes.Requireable<(...args: any[]) => any>;
maxTagPlaceholder: PropTypes.Requireable<string | number | boolean | {} | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
maxTagCount: PropTypes.Requireable<number>;
maxTagTextLength: PropTypes.Requireable<number>;
pristine: PropTypes.Requireable<boolean>;
trim: PropTypes.Requireable<import("../data-set/enum").FieldTrim>;
onBeforeChange: PropTypes.Requireable<(...args: any[]) => any>;
onChange: PropTypes.Requireable<(...args: any[]) => any>;
onInput: PropTypes.Requireable<(...args: any[]) => any>;
onEnterDown: PropTypes.Requireable<(...args: any[]) => any>;
fieldClassName: PropTypes.Requireable<string>;
highlight: PropTypes.Requireable<string | number | boolean | {} | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
highlightRenderer: PropTypes.Requireable<(...args: any[]) => any>;
useColon: PropTypes.Requireable<boolean>;
showValidation: PropTypes.Requireable<string>;
};
static __IS_IN_CELL_EDITOR: boolean;
sort?: Sort;
popup?: boolean;
tempAttachmentUUID?: string;
get help(): any;
get bucketName(): any;
get bucketDirectory(): any;
get storageCode(): any;
get attachments(): AttachmentFile[] | undefined;
set attachments(attachments: AttachmentFile[] | undefined);
get count(): number | undefined;
get axios(): AxiosInstance;
get defaultValidationMessages(): ValidationMessages;
processDataSetEventListener(on: boolean): void;
componentDidMount(): void;
componentDidUpdate(prevProps: AttachmentProps): void;
componentWillUnmount(): void;
getFieldType(): FieldType;
getObservableProps(props: any, context: any): any;
getValidAttachments(): AttachmentFile[] | undefined;
getValidatorProps(): ValidatorProps;
fetchCount(): void;
handleDataSetLoad(): void;
getOmitPropsKeys(): string[];
getUploadAxiosConfig(attachment: AttachmentFile, attachmentUUID: string): AxiosRequestConfig | undefined;
isAcceptFile(attachment: AttachmentFile, accept: string[]): boolean;
getAttachmentUUID(): string | Promise<string>;
uploadAttachments(attachments: AttachmentFile[]): Promise<void>;
uploadAttachment(attachment: AttachmentFile, attachmentUUID: string): Promise<void>;
upload(attachment: AttachmentFile, attachmentUUID: string): Promise<void>;
getOtherProps(): any;
handleProgress(percent: number, attachment: AttachmentFile): void;
handleSuccess(response: any, attachment: AttachmentFile): Promise<unknown>;
handleError(error: AxiosError, attachment: AttachmentFile): void;
handleChange(e: any): void;
doRemove(attachment: AttachmentFile): Promise<any> | undefined;
handleHistory(attachment: AttachmentFile, attachmentUUID: string): void;
handleRemove(attachment: AttachmentFile): Promise<any> | undefined;
handleFetchAttachment(fetchProps: {
bucketName?: string;
bucketDirectory?: string;
storageCode?: string;
attachmentUUID: string;
}): void;
handlePreview(): void;
removeAttachment(attachment: AttachmentFile): undefined;
beforeUpload(attachment: AttachmentFile, attachments: AttachmentFile[]): boolean | undefined | PromiseLike<boolean | undefined>;
handleClick(e: any): void;
getUid(index: number): string;
renderHeaderLabel(): JSX.Element | undefined;
isDisabled(): boolean;
renderUploadBtn(isCardButton: boolean, label?: ReactNode): ReactElement<ButtonProps>;
showTooltip(e: any): boolean;
renderViewButton(label?: ReactNode): ReactElement<ButtonProps>;
handleSort(sort: Sort): void;
handleOrderChange(props: any): void;
changeOrder(): void;
getSortSelectPopupContainer(): any;
renderSorter(): ReactNode;
renderUploadList(uploadButton?: ReactNode): JSX.Element | undefined;
renderHeader(uploadBtn?: ReactNode): JSX.Element;
renderWrapper(): ReactNode;
getTooltipValidationMessage(): ReactNode;
renderValidationResult(validationResult?: ValidationResult): ReactNode;
renderEmpty(): JSX.Element | undefined;
renderWrapperList(uploadBtn?: ReactNode): JSX.Element;
getPictureWidth(): number;
renderHelp(forceHelpMode?: ShowHelp): ReactNode;
get showValidation(): any;
handlePopupHiddenChange(hidden: any): void;
setPopup(popup: any): void;
render(): JSX.Element;
}