choerodon-ui
Version:
An enterprise-class UI design language and React-based implementation
157 lines (156 loc) • 6.55 kB
TypeScript
import React, { ReactElement, ReactNode } from 'react';
import { Uploader } from 'choerodon-ui/dataset';
import { AttachmentValue, AttachmentFileProps } from 'choerodon-ui/dataset/configure';
import { UploaderProps } from 'choerodon-ui/dataset/uploader/Uploader';
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 { ValidationMessages } from '../validator/Validator';
import ValidationResult from '../validator/ValidationResult';
import Dragger from './Dragger';
import { ShowHelp } from '../field/enum';
import { ShowValidation } from '../form/enum';
export declare type AttachmentListType = 'text' | 'picture' | 'picture-card';
export declare enum AttachmentButtonType {
download = "download",
remove = "remove",
history = "history"
}
export declare type AttachmentButtons = AttachmentButtonType | [AttachmentButtonType, ButtonProps] | ReactElement<ButtonProps>;
export interface AttachmentProps extends FormFieldProps, ButtonProps, UploaderProps {
listType?: AttachmentListType;
viewMode?: 'none' | 'list' | 'popup';
sortable?: boolean;
pictureWidth?: number;
count?: number;
max?: number;
listLimit?: number;
showHistory?: boolean;
showSize?: boolean;
showValidation?: ShowValidation;
attachments?: (AttachmentFile | FileLike)[];
onAttachmentsChange?: (attachments: AttachmentFile[]) => void;
onRemove?: (attachment: AttachmentFile) => boolean | void;
getUUID?: () => Promise<string> | string;
downloadAll?: ButtonProps | boolean;
previewTarget?: string;
dragUpload?: boolean;
dragBoxRender?: ReactNode[];
template?: AttachmentValue;
buttons?: AttachmentButtons[];
__inGroup?: boolean;
getPreviewUrl?: (props: AttachmentFileProps) => (string | (() => string | Promise<string>) | undefined);
}
export declare type Sort = {
type: 'time' | 'name';
order: 'asc' | 'desc';
custom?: boolean;
};
export default class Attachment extends FormField<AttachmentProps> {
static displayName: string;
static Dragger: typeof Dragger;
static defaultProps: {
suffixCls: string;
multiple: boolean;
sortable: boolean;
showSize: boolean;
downloadAll: boolean;
listType: string;
viewMode: string;
dragUpload: boolean;
readOnly: boolean;
disabled: boolean;
noValidate: boolean;
trim: import("../data-set/enum").FieldTrim;
};
static __IS_IN_CELL_EDITOR: boolean;
static __PRO_ATTACHMENT: boolean;
static Group: React.FunctionComponent<import("./AttachmentGroup").AttachmentGroupProps>;
sort?: Sort;
popup?: boolean;
dragState?: string;
uploader?: Uploader;
tempAttachmentUUID?: string | undefined;
get help(): any;
get showAttachmentHelp(): ShowHelp.tooltip | ShowHelp.newLine | ShowHelp.none;
get bucketName(): any;
get bucketDirectory(): any;
get storageCode(): any;
get fileKey(): any;
get isPublic(): any;
get attachments(): AttachmentFile[] | undefined;
set attachments(attachments: AttachmentFile[] | undefined);
get count(): number | undefined;
get defaultValidationMessages(): ValidationMessages;
get accept(): string[] | undefined;
private reaction?;
componentDidMount(): void;
componentDidUpdate(prevProps: AttachmentProps): void;
componentWillUnmount(): void;
getFieldType(): FieldType;
getObservableProps(props: any, context: any): any;
getValidAttachments(): AttachmentFile[] | undefined;
getValidatorProp(key: string): any;
fetchCount(): void;
handleDataSetLoad(): void;
getOmitPropsKeys(): string[];
isAcceptFile(attachment: AttachmentFile, accept: string[]): boolean;
getAttachmentUUID(): Promise<string>;
fetchAttachmentUUID(): Promise<string> | string;
uploadAttachments(attachments: AttachmentFile[]): Promise<void>;
uploadAttachment(attachment: AttachmentFile): Promise<void>;
getUploaderProps(): UploaderProps;
upload(attachment: AttachmentFile): Promise<void>;
getOtherProps(): any;
processFiles(files: File[], attachmentUUID: string): AttachmentFile[];
handleChange(e: any): void;
doRemove(attachment: AttachmentFile): Promise<any> | undefined;
handleHistory(attachment: AttachmentFile, attachmentUUID: string): void;
handleRemove(attachment: AttachmentFile): Promise<any> | undefined;
handleAttachmentsChange(attachments: AttachmentFile[] | undefined): void;
handleFetchAttachment(fetchProps: {
bucketName?: string;
bucketDirectory?: string;
storageCode?: string;
attachmentUUID: string;
isPublic?: boolean;
}): void;
handlePreview(): void;
removeAttachment(attachment: AttachmentFile): undefined;
handleDragUpload: (file: File, files: File[]) => boolean;
handleClick(e: any): void;
getUid(index: number): string;
renderHeaderLabel(): JSX.Element | undefined;
isDisabled(): boolean;
isValid(): boolean;
renderTemplateDownloadButton(): ReactElement<ButtonProps> | undefined;
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 | undefined;
renderWrapper(): ReactNode;
getTooltipValidationMessage(): ReactNode;
renderValidationResult(validationResult?: ValidationResult): ReactNode;
renderEmpty(): JSX.Element | undefined;
getWrapperClassNames(): string;
renderWrapperList(uploadBtn?: ReactNode): JSX.Element;
getPictureWidth(): number;
handleHelpMouseEnter(e: any): void;
handleHelpMouseLeave(): void;
renderHelp(): ReactNode;
get showValidation(): ShowValidation.tooltip | ShowValidation | ShowValidation.newLine;
handlePopupHiddenChange(hidden: any): void;
setPopup(popup: any): void;
setDragState(state: any): void;
handleFileDrop(e: any): void;
renderDefaultDragBox(): JSX.Element;
renderDragUploadArea(): JSX.Element | undefined;
render(): JSX.Element;
}