UNPKG

2.25 kBTypeScriptView Raw
1/// <reference types="react" />
2
3import * as React from 'react';
4
5export interface ConfigProviderProps {
6 /**
7 * 样式类名的品牌前缀
8 */
9 prefix?: string;
10
11 /**
12 * 国际化文案对象,属性为组件的 displayName
13 */
14 locale?: Record<string, unknown>;
15
16 /**
17 * 是否开启错误捕捉 errorBoundary
18 * 如需自定义参数,请传入对象 对象接受参数列表如下:
19 *
20 * fallbackUI `Function(error?: {}, errorInfo?: {}) => Element` 捕获错误后的展示
21 * afterCatch `Function(error?: {}, errorInfo?: {})` 捕获错误后的行为, 比如埋点上传
22 */
23 errorBoundary?:
24 | boolean
25 | {
26 afterCatch?: (error: Error, errorInfo: React.ErrorInfo) => void;
27 fallbackUI?: (error: Error, errorInfo: React.ErrorInfo) => React.ReactElement<any>;
28 };
29
30 /**
31 * 是否开启 Pure Render 模式,会提高性能,但是也会带来副作用
32 */
33 pure?: boolean;
34
35 /**
36 * 是否在开发模式下显示组件属性被废弃的 warning 提示
37 */
38 warning?: boolean;
39
40 /**
41 * 是否开启 rtl 模式
42 */
43
44 rtl?: boolean;
45 /**
46 * 设备类型,针对不同的设备类型组件做出对应的响应式变化
47 */
48 device?: 'tablet' | 'desktop' | 'phone';
49 /**
50 * 组件树
51 */
52 children?: React.ReactNode;
53 /**
54 * 弹层挂载的容器节点
55 */
56 popupContainer?: string | HTMLElement | ((target: HTMLElement) => HTMLElement);
57 /**
58 * 组件 API 的默认配置
59 */
60 defaultPropsConfig?: Record<string, any>;
61}
62
63export default class ConfigProvider extends React.Component<ConfigProviderProps, any> {
64 static config(Component: any, options?: any): any;
65 static getContextProps(props: {}, displayName: string): any;
66 static initLocales(locales: any): any;
67 static setLanguage(language: string): any;
68 static setLocale(locale: any): any;
69 static setDirection(dir: string): any;
70 static getLocale(): any;
71 static getLanguage(): string;
72 static getDirection(): string;
73 static clearCache(): any;
74 static Consumer(props: { children: (ctx: ConfigProviderProps) => React.ReactNode }): JSX.Element;
75}
76
\No newline at end of file