UNPKG

16.3 kBTypeScriptView Raw
1import { AxiosError, AxiosInstance, AxiosPromise, AxiosRequestConfig, Method } from 'axios';
2import { CSSProperties, ReactNode } from 'react';
3import noop from 'lodash/noop';
4import { Tooltip } from '../../pro/es/core/enum';
5import { LovConfig } from '../../pro/es/lov/Lov';
6import { ExportMode, RecordStatus } from '../../pro/es/data-set/enum';
7import { expandIconProps, Suffixes, TableCustomized, TablePaginationConfig, TableProps, TableQueryBarHook } from '../../pro/es/table/Table';
8import { PerformanceTableCustomized } from '../../pro/es/performance-table/Table.d.ts';
9import { ValidationMessages } from '../../pro/es/validator/Validator';
10import { ButtonProps } from '../../pro/es/button/Button';
11import { ColumnAlign, DragColumnAlign, HighLightRowType, TableQueryBarType } from '../../pro/es/table/enum';
12import { TransportHookProps, TransportProps } from '../../pro/es/data-set/Transport';
13import DataSet from '../../pro/es/data-set/DataSet';
14import { FeedBack } from '../../pro/es/data-set/FeedBack';
15import Record from '../../pro/es/data-set/Record';
16import Field from '../../pro/es/data-set/Field';
17import { CacheOptions } from '../../pro/es/_util/Cache';
18import { LabelLayout, ShowValidation } from '../../pro/es/form/enum';
19import { ButtonColor, FuncType } from '../../pro/es/button/enum';
20import { HighlightRenderer } from '../../pro/es/field/FormField';
21import { FormatNumberFunc, FormatNumberFuncOptions } from '../../pro/es/number-field/NumberField';
22import { ModalProps } from '../../pro/es/modal/interface';
23import { ColumnProps, onCellProps } from '../../pro/es/table/Column';
24import { TimeZone } from '../../pro/es/date-picker/DatePicker';
25import { AttachmentListType } from '../../pro/es/attachment/Attachment';
26import AttachmentFile, { FileLike } from '../../pro/es/data-set/AttachmentFile';
27import { Action } from '../trigger/enum';
28import { TooltipTheme } from '../tooltip';
29import { SpinProps } from '../spin';
30import { PanelProps } from '../collapse';
31import { Size } from '../_util/enum';
32import { TabsCustomized } from '../tabs/Tabs';
33export declare type Status = {
34 [RecordStatus.add]: string;
35 [RecordStatus.update]: string;
36 [RecordStatus.delete]: string;
37};
38export declare type renderEmptyHandler = (componentName?: string) => ReactNode;
39export declare type PerformanceEvents = {
40 Table: {
41 name: string;
42 url: string | undefined;
43 size: number;
44 timing: {
45 fetchStart: number;
46 fetchEnd: number;
47 loadStart: number;
48 loadEnd: number;
49 renderStart: number;
50 renderEnd: number;
51 };
52 };
53};
54export declare type PerformanceEventHook<T extends keyof PerformanceEvents> = (key: T, event: PerformanceEvents[T]) => void;
55export declare type TooltipTarget = 'table-cell' | 'output' | 'label' | 'button' | 'select-option' | 'validation' | 'help';
56export declare type TooltipHook = (target?: TooltipTarget) => Tooltip | undefined;
57export declare type TooltipThemeHook = (target?: TooltipTarget) => TooltipTheme;
58export declare type TableFilterAdapterProps = ({ type, config, searchCode, queryDataSet }: {
59 type: any;
60 config: any;
61 searchCode: any;
62 queryDataSet: any;
63}) => AxiosRequestConfig;
64export declare type Customizable = {
65 Table?: boolean;
66 PerformanceTable?: boolean;
67 Tabs?: boolean;
68};
69export interface Customized {
70 Table?: TableCustomized;
71 PerformanceTable?: PerformanceTableCustomized;
72 Tabs?: TabsCustomized;
73}
74export declare type CustomizedSave = <T extends keyof Customized>(code: string, customized: Customized[T], component: T) => void;
75export declare type CustomizedLoad = <T extends keyof Customized>(code: string, component: T) => Promise<Customized[T] | null>;
76export declare type Formatter = {
77 jsonDate: string | null;
78 date: string;
79 dateTime: string;
80 time: string;
81 year: string;
82 month: string;
83 week: string;
84 timeZone?: TimeZone;
85};
86export declare type AttachmentConfig = {
87 defaultFileKey: string;
88 defaultFileSize: number;
89 action?: AxiosRequestConfig | ((props: {
90 attachment: AttachmentFile;
91 bucketName?: string;
92 bucketDirectory?: string;
93 storageCode?: string;
94 attachmentUUID: string;
95 }) => AxiosRequestConfig);
96 batchFetchCount?: <T extends string | number | symbol>(attachmentUUIDs: T[]) => Promise<{
97 [key in T]: number;
98 }>;
99 fetchList?: (props: {
100 bucketName?: string;
101 bucketDirectory?: string;
102 storageCode?: string;
103 attachmentUUID: string;
104 }) => Promise<FileLike[]>;
105 getPreviewUrl?: (props: {
106 attachment: AttachmentFile;
107 bucketName?: string;
108 bucketDirectory?: string;
109 storageCode?: string;
110 attachmentUUID: string;
111 }) => string;
112 getDownloadUrl?: (props: {
113 attachment: AttachmentFile;
114 bucketName?: string;
115 bucketDirectory?: string;
116 storageCode?: string;
117 attachmentUUID: string;
118 }) => string;
119 getDownloadAllUrl?: (props: {
120 bucketName?: string;
121 bucketDirectory?: string;
122 storageCode?: string;
123 attachmentUUID: string;
124 }) => string;
125 getAttachmentUUID?: () => Promise<string> | string;
126 renderIcon?: (attachment: AttachmentFile, listType: AttachmentListType, defaultIcon: ReactNode) => ReactNode;
127 renderHistory?: (props: {
128 attachment: AttachmentFile;
129 bucketName?: string;
130 bucketDirectory?: string;
131 storageCode?: string;
132 attachmentUUID: string;
133 }) => ReactNode;
134 onUploadSuccess?: (response: any, attachment: AttachmentFile) => void;
135 onUploadError?: (error: AxiosError, attachment: AttachmentFile) => void;
136 onOrderChange?: (props: {
137 attachmentUUID: string;
138 attachments: AttachmentFile[];
139 bucketName?: string;
140 bucketDirectory?: string;
141 storageCode?: string;
142 }) => Promise<void>;
143 onRemove?: (props: {
144 attachment: AttachmentFile;
145 attachmentUUID: string;
146 bucketName?: string;
147 bucketDirectory?: string;
148 storageCode?: string;
149 }) => Promise<boolean>;
150};
151export declare type Config = {
152 prefixCls?: string;
153 proPrefixCls?: string;
154 iconfontPrefix?: string;
155 ripple?: boolean;
156 collapseExpandIconPosition?: string;
157 collapseExpandIcon?: (panelProps: PanelProps) => ReactNode | 'text';
158 collapseTrigger?: string;
159 lookupCache?: CacheOptions<string, AxiosPromise>;
160 lookupUrl?: string | ((code: string) => string);
161 lookupAxiosMethod?: Method;
162 lookupAxiosConfig?: AxiosRequestConfig | ((props: {
163 params?: any;
164 dataSet?: DataSet;
165 record?: Record;
166 lookupCode?: string;
167 }) => AxiosRequestConfig);
168 lookupBatchAxiosConfig?: (codes: string[]) => AxiosRequestConfig;
169 lovDefineUrl?: string | ((code: string) => string);
170 lovDefineAxiosConfig?: AxiosRequestConfig | ((code: string) => AxiosRequestConfig);
171 lovQueryUrl?: string | ((code: string, lovConfig: LovConfig | undefined, props: TransportHookProps) => string);
172 lovQueryAxiosConfig?: AxiosRequestConfig | ((code: string, lovConfig: LovConfig | undefined, props: TransportHookProps) => AxiosRequestConfig);
173 lovQueryCachedSelected?: (code: string, cachedSelected: Map<string, Record>) => Promise<object[]>;
174 lovTableProps?: Partial<TableProps>;
175 lovModalProps?: Partial<ModalProps>;
176 lovAutoSelectSingle?: boolean;
177 lovQueryBar?: TableQueryBarType | TableQueryBarHook;
178 lovQueryBarProps?: object;
179 axios?: AxiosInstance;
180 feedback?: FeedBack;
181 dataKey?: string;
182 totalKey?: string;
183 statusKey?: string;
184 tlsKey?: string;
185 status?: Status;
186 exportMode?: ExportMode;
187 labelLayout?: LabelLayout;
188 queryBar?: TableQueryBarType | TableQueryBarHook;
189 queryBarProps?: object;
190 tableVirtual?: boolean;
191 tableVirtualCell?: boolean;
192 tableBorder?: boolean;
193 tableColumnEditorBorder?: boolean;
194 tableHighLightRow?: boolean | HighLightRowType;
195 tableParityRow?: boolean;
196 tableSelectedHighLightRow?: boolean;
197 tableRowHeight?: 'auto' | number;
198 tableColumnResizable?: boolean;
199 tableColumnHideable?: boolean;
200 performanceTableColumnHideable?: boolean;
201 tableColumnTitleEditable?: boolean;
202 performanceTableColumnTitleEditable?: boolean;
203 tableDragColumnAlign?: DragColumnAlign;
204 tableColumnDraggable?: boolean;
205 performanceTableColumnDraggable?: boolean;
206 tableRowDraggable?: boolean;
207 tableExpandIcon?: (props: expandIconProps) => ReactNode;
208 tableSpinProps?: SpinProps;
209 tableButtonProps?: ButtonProps;
210 tableCommandProps?: ButtonProps;
211 tableColumnOnCell?: (props: onCellProps) => object;
212 tableColumnAlign?: (column: ColumnProps, field?: Field) => ColumnAlign | undefined;
213 tableShowSelectionTips?: boolean;
214 tableAlwaysShowRowBox?: boolean;
215 tableUseMouseBatchChoose?: boolean;
216 tableEditorNextKeyEnterDown?: boolean;
217 tableAutoFocus?: boolean;
218 tableKeyboard?: boolean;
219 tableFilterAdapter?: TableFilterAdapterProps;
220 tableFilterSuffix?: Suffixes[];
221 tableFilterSearchText?: string;
222 tableAutoHeightDiff?: number;
223 tableShowRemovedRow?: boolean;
224 tableButtonsLimit?: number;
225 pagination?: TablePaginationConfig | false;
226 modalSectionBorder?: boolean;
227 drawerSectionBorder?: boolean;
228 drawerTransitionName?: string;
229 modalAutoCenter?: boolean;
230 modalOkFirst?: boolean;
231 drawerOkFirst?: boolean;
232 modalButtonProps?: ButtonProps;
233 modalKeyboard?: boolean;
234 modalMaskClosable?: string | boolean;
235 buttonFuncType?: FuncType;
236 buttonColor?: ButtonColor;
237 renderEmpty?: renderEmptyHandler;
238 highlightRenderer?: HighlightRenderer;
239 defaultValidationMessages?: ValidationMessages;
240 transport?: TransportProps;
241 icons?: {
242 [key: string]: string[];
243 } | string[];
244 generatePageQuery?: (pageParams: {
245 page?: number;
246 pageSize?: number;
247 sortName?: string;
248 sortOrder?: string;
249 sort?: string[];
250 }) => object;
251 formatter?: Formatter;
252 dropdownMatchSelectWidth?: boolean;
253 selectReverse?: boolean;
254 selectPagingOptionContent?: string | ReactNode;
255 selectSearchable?: boolean;
256 selectTrigger?: Action[];
257 useColon?: boolean;
258 textFieldAutoComplete?: string;
259 resultStatusRenderer?: object;
260 numberFieldNonStrictStep?: boolean;
261 numberFieldFormatter?: FormatNumberFunc;
262 numberFieldFormatterOptions?: FormatNumberFuncOptions;
263 currencyFormatter?: FormatNumberFunc;
264 currencyFormatterOptions?: FormatNumberFuncOptions;
265 /**
266 * 是否显示长度信息
267 */
268 showLengthInfo?: boolean;
269 /**
270 * moment非法时显示Invalid date
271 */
272 showInvalidDate?: boolean;
273 /**
274 * 只有在空值时显示必填背景色和边框色
275 */
276 showRequiredColorsOnlyEmpty?: boolean;
277 /**
278 * 性能监控钩子
279 */
280 onPerformance?: PerformanceEventHook<keyof PerformanceEvents>;
281 /**
282 * 开启性能监控
283 */
284 performanceEnabled?: {
285 [key in keyof PerformanceEvents]: boolean;
286 };
287 /**
288 * tooltip
289 */
290 tooltip?: Tooltip | TooltipHook;
291 /**
292 * tooltip 主题
293 */
294 tooltipTheme?: TooltipTheme | TooltipThemeHook;
295 /**
296 * 附件相关配置
297 */
298 attachment?: AttachmentConfig;
299 /**
300 * 表单校验提示方式
301 */
302 showValidation?: ShowValidation;
303 /**
304 * Tabs 墨条样式
305 */
306 tabsInkBarStyle?: CSSProperties;
307 /**
308 * 个性化开关
309 */
310 customizable?: boolean | Customizable;
311 customizedSave?: CustomizedSave;
312 customizedLoad?: CustomizedLoad;
313 /**
314 * @deprecated
315 */
316 validationTooltipTheme?: TooltipTheme;
317 /**
318 * @deprecated
319 */
320 tableColumnTooltip?: Tooltip;
321 /**
322 * @deprecated
323 */
324 buttonTooltip?: Tooltip;
325 /**
326 * @deprecated
327 */
328 selectOptionTooltip?: Tooltip;
329 /**
330 * @deprecated
331 */
332 labelTooltip?: Tooltip;
333 /**
334 * @deprecated
335 */
336 excludeUseColonTagList?: string[];
337 /**
338 * @deprecated
339 */
340 tableDefaultRenderer?: ReactNode;
341 /**
342 * @deprecated
343 * 同 tableColumnDraggable
344 */
345 tableDragColumn?: boolean;
346 /**
347 * @deprecated
348 * 同 tableRowDraggable
349 */
350 tableDragRow?: boolean;
351 /**
352 * @deprecated
353 */
354 lovTableCustomizable?: boolean;
355 /**
356 * @deprecated
357 */
358 tableCustomizable?: boolean;
359 /**
360 * @deprecated
361 */
362 performanceTableCustomizable?: boolean;
363 /**
364 * @deprecated
365 */
366 tableCustomizedSave?: CustomizedSave;
367 /**
368 * @deprecated
369 */
370 tableCustomizedLoad?: CustomizedLoad;
371};
372export declare type ConfigKeys = keyof Config;
373declare const defaultConfig: {
374 prefixCls: string;
375 proPrefixCls: string;
376 iconfontPrefix: string;
377 ripple: boolean;
378 collapseExpandIconPosition: string;
379 collapseTrigger: string;
380 lookupCache: CacheOptions<string, AxiosPromise<any>>;
381 lookupUrl: (code: any) => string;
382 lookupAxiosMethod: Method;
383 lovDefineUrl: (code: any) => string;
384 lovQueryUrl: (code: any) => string;
385 lovTableProps: {};
386 lovModalProps: {};
387 lovAutoSelectSingle: boolean;
388 dataKey: string;
389 totalKey: string;
390 statusKey: string;
391 tlsKey: string;
392 status: Status;
393 labelLayout: LabelLayout;
394 queryBar: TableQueryBarType;
395 tableBorder: boolean;
396 tableHighLightRow: boolean;
397 tableSelectedHighLightRow: boolean;
398 tableRowHeight: number;
399 tableDefaultRenderer: string;
400 tableColumnResizable: boolean;
401 tableColumnHideable: boolean;
402 performanceTableColumnHideable: boolean;
403 tableRowDraggable: boolean;
404 tableColumnDraggable: boolean;
405 performanceTableColumnDraggable: boolean;
406 tableColumnAlign: (_column: ColumnProps, field?: Field | undefined) => ColumnAlign | undefined;
407 tableSpinProps: {
408 size: Size;
409 wrapperClassName: string;
410 };
411 tableButtonProps: ButtonProps;
412 tableCommandProps: ButtonProps;
413 tableAlwaysShowRowBox: boolean;
414 tableUseMouseBatchChoose: boolean;
415 tableEditorNextKeyEnterDown: boolean;
416 tableAutoFocus: boolean;
417 tableKeyboard: boolean;
418 tableFilterSearchText: string;
419 tableAutoHeightDiff: number;
420 customizedSave: CustomizedSave;
421 customizedLoad: CustomizedLoad;
422 tableShowRemovedRow: boolean;
423 modalSectionBorder: boolean;
424 drawerSectionBorder: boolean;
425 drawerTransitionName: string;
426 modalOkFirst: boolean;
427 modalAutoCenter: boolean;
428 modalKeyboard: boolean;
429 modalMaskClosable: boolean;
430 buttonColor: ButtonColor;
431 buttonFuncType: FuncType;
432 feedback: {
433 loadSuccess(_result: any): void;
434 loadFailed(error: any): void;
435 submitSuccess(_result: any): void;
436 submitFailed(error: any): void;
437 };
438 renderEmpty: renderEmptyHandler;
439 icons: {
440 whatsNew: string[];
441 direction: string[];
442 suggestion: string[];
443 edit: string[];
444 data: string[];
445 other: string[];
446 series: string[];
447 };
448 formatter: Formatter;
449 dropdownMatchSelectWidth: boolean;
450 selectReverse: boolean;
451 selectPagingOptionContent: string;
452 selectSearchable: boolean;
453 selectTrigger: Action[];
454 useColon: boolean;
455 excludeUseColonTagList: string[];
456 numberFieldNonStrictStep: boolean;
457 showInvalidDate: boolean;
458 highlightRenderer: HighlightRenderer;
459 onPerformance: typeof noop;
460 performanceEnabled: {
461 Table: boolean;
462 };
463 tooltipTheme: TooltipThemeHook;
464 showValidation: ShowValidation;
465 attachment: AttachmentConfig;
466};
467export declare type DefaultConfig = typeof defaultConfig;
468export declare function getConfig<T extends ConfigKeys>(key: T): T extends keyof DefaultConfig ? DefaultConfig[T] : Config[T];
469export declare function getPrefixCls(suffixCls: string, customizePrefixCls?: string): string;
470export declare function getProPrefixCls(suffixCls: string, customizePrefixCls?: string): string;
471export declare function getCustomizable<T extends keyof Customizable>(component: T): boolean | undefined;
472export default function configure(config: Config, merge?: boolean): void;
473export {};