UNPKG

choerodon-ui

Version:

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

161 lines (160 loc) 6.25 kB
import { AxiosError, AxiosInstance, AxiosPromise, AxiosRequestConfig, Method } from 'axios'; import { Moment } from 'moment'; import { LovConfig } from '../interface'; import { ExportMode, RecordStatus } from '../data-set/enum'; import { ValidationMessages } from '../validator/Validator'; import { TransportHookProps, TransportProps } from '../data-set/Transport'; import DataSet from '../data-set/DataSet'; import { FeedBack } from '../data-set/FeedBack'; import { defaultValidationMessageFormatter, defaultValidationMessageReportFormatter, ValidationMessageFormatter, ValidationMessageReportFormatter } from '../validator/ValidationMessageReportFormatter'; import Record from '../data-set/Record'; import { CacheOptions } from '../cache'; import AttachmentFile, { FileLike } from '../data-set/AttachmentFile'; export declare type TimeZone = string | ((moment: Moment) => string); export declare type Status = { [RecordStatus.add]: string; [RecordStatus.update]: string; [RecordStatus.delete]: string; }; export declare type Formatter = { jsonDate: string | null; date: string; dateTime: string; time: string; year: string; month: string; week: string; timeZone?: TimeZone; }; export interface AttachmentConfig { defaultFileKey: string; defaultFileSize: number; action?: AxiosRequestConfig | ((props: { attachment: AttachmentFile; bucketName?: string; bucketDirectory?: string; storageCode?: string; attachmentUUID: string; isPublic?: boolean; }) => AxiosRequestConfig); batchFetchCount?: <T extends string | number | symbol>(attachmentUUIDs: T[], props: { isPublic?: boolean; }) => Promise<{ [key in T]: number; }>; fetchList?: (props: { bucketName?: string; bucketDirectory?: string; storageCode?: string; attachmentUUID: string; isPublic?: boolean; }) => Promise<FileLike[]>; getPreviewUrl?: (props: { attachment: AttachmentFile; bucketName?: string; bucketDirectory?: string; storageCode?: string; attachmentUUID?: string; isPublic?: boolean; }) => string | undefined; getDownloadUrl?: (props: { attachment: AttachmentFile; bucketName?: string; bucketDirectory?: string; storageCode?: string; attachmentUUID?: string; isPublic?: boolean; }) => string | Function | undefined; getDownloadAllUrl?: (props: { bucketName?: string; bucketDirectory?: string; storageCode?: string; attachmentUUID: string; isPublic?: boolean; }) => string | Function | undefined; getAttachmentUUID?: (props: { isPublic?: boolean; }) => Promise<string> | string; onUploadSuccess?: (response: any, attachment: AttachmentFile) => void; onUploadError?: (error: AxiosError, attachment: AttachmentFile) => void; onOrderChange?: (props: { attachmentUUID: string; attachments: AttachmentFile[]; bucketName?: string; bucketDirectory?: string; storageCode?: string; isPublic?: boolean; }) => Promise<void>; onRemove?: (props: { attachment: AttachmentFile; attachmentUUID: string; bucketName?: string; bucketDirectory?: string; storageCode?: string; isPublic?: boolean; }) => Promise<boolean>; } export interface Config { lookupCache?: CacheOptions<string, AxiosPromise>; lookupUrl?: string | ((code: string) => string); lookupAxiosMethod?: Method; lookupAxiosConfig?: AxiosRequestConfig | ((props: { params?: any; dataSet?: DataSet; record?: Record; lookupCode?: string; }) => AxiosRequestConfig); lookupBatchAxiosConfig?: (codes: string[]) => AxiosRequestConfig; lovDefineUrl?: string | ((code: string) => string); lovDefineAxiosConfig?: AxiosRequestConfig | ((code: string) => AxiosRequestConfig); lovQueryUrl?: string | ((code: string, lovConfig: LovConfig | undefined, props: TransportHookProps) => string); lovQueryAxiosConfig?: AxiosRequestConfig | ((code: string, lovConfig: LovConfig | undefined, props: TransportHookProps) => AxiosRequestConfig); axios?: AxiosInstance; feedback?: FeedBack; dataKey?: string; totalKey?: string; statusKey?: string; tlsKey?: string; status?: Status; exportMode?: ExportMode; defaultValidationMessages?: ValidationMessages; validationMessageFormatter?: ValidationMessageFormatter; validationMessageReportFormatter?: ValidationMessageReportFormatter; transport?: TransportProps; generatePageQuery?: (pageParams: { page?: number; pageSize?: number; sortName?: string; sortOrder?: string; sort?: string[]; }) => object; formatter?: Formatter; attachment?: AttachmentConfig; numberFieldNonStrictStep?: boolean; confirm?: (message: any) => Promise<boolean>; } export declare type ConfigKeys = keyof Config; declare const defaultConfig: { lookupCache: CacheOptions<string, AxiosPromise<any>>; lookupUrl: (code: any) => string; lookupAxiosMethod: Method; lovDefineUrl: (code: any) => string; lovQueryUrl: (code: any) => string; dataKey: string; totalKey: string; statusKey: string; tlsKey: string; status: Status; feedback: Required<FeedBack>; formatter: Formatter; attachment: AttachmentConfig; confirm: (_: any) => Promise<boolean>; validationMessageFormatter: typeof defaultValidationMessageFormatter; validationMessageReportFormatter: typeof defaultValidationMessageReportFormatter; }; export declare type DefaultConfig = typeof defaultConfig; export declare function getConfig<C extends Config, T extends keyof C, D extends DefaultConfig>(key: T): T extends keyof D ? D[T] : C[T]; export declare function overwriteDefaultConfig<T extends Config>(config: T, mergeProps?: (keyof T)[] | null): void; export declare function overwriteConfigMergeProps<T extends Config>(customMergeProps: (keyof T)[]): void; export default function configure<T extends Config>(config: T, mergeProps?: (keyof T)[] | null): void; export {};