UNPKG

2.81 kBTypeScriptView Raw
1import * as React from 'react';
2import { ConfigConsumerProps } from '../config-provider';
3import TransButton from '../_util/transButton';
4import { TypographyProps } from './Typography';
5export declare type BaseType = 'secondary' | 'danger' | 'warning';
6interface CopyConfig {
7 text?: string;
8 onCopy?: () => void;
9}
10interface EditConfig {
11 editing?: boolean;
12 onStart?: () => void;
13 onChange?: (value: string) => void;
14}
15interface EllipsisConfig {
16 rows?: number;
17 expandable?: boolean;
18 suffix?: string;
19 symbol?: React.ReactNode;
20 onExpand?: React.MouseEventHandler<HTMLElement>;
21 onEllipsis?: (ellipsis: boolean) => void;
22}
23export interface BlockProps extends TypographyProps {
24 title?: string;
25 editable?: boolean | EditConfig;
26 copyable?: boolean | CopyConfig;
27 type?: BaseType;
28 disabled?: boolean;
29 ellipsis?: boolean | EllipsisConfig;
30 code?: boolean;
31 mark?: boolean;
32 underline?: boolean;
33 delete?: boolean;
34 strong?: boolean;
35 keyboard?: boolean;
36}
37interface InternalBlockProps extends BlockProps {
38 component: string;
39}
40interface BaseState {
41 edit: boolean;
42 copied: boolean;
43 ellipsisText: string;
44 ellipsisContent: React.ReactNode;
45 isEllipsis: boolean;
46 expanded: boolean;
47 clientRendered: boolean;
48}
49declare class Base extends React.Component<InternalBlockProps, BaseState> {
50 static contextType: React.Context<ConfigConsumerProps>;
51 static defaultProps: {
52 children: string;
53 };
54 static getDerivedStateFromProps(nextProps: BlockProps): {};
55 context: ConfigConsumerProps;
56 editIcon?: TransButton;
57 contentRef: React.RefObject<HTMLElement>;
58 copyId?: number;
59 rafId?: number;
60 expandStr?: string;
61 copyStr?: string;
62 copiedStr?: string;
63 editStr?: string;
64 state: BaseState;
65 componentDidMount(): void;
66 componentDidUpdate(prevProps: BlockProps): void;
67 componentWillUnmount(): void;
68 getPrefixCls: () => string;
69 onExpandClick: React.MouseEventHandler<HTMLElement>;
70 onEditClick: () => void;
71 onEditChange: (value: string) => void;
72 onEditCancel: () => void;
73 onCopyClick: () => void;
74 getEditable(props?: BlockProps): EditConfig;
75 getEllipsis(props?: BlockProps): EllipsisConfig;
76 setEditRef: (node: TransButton) => void;
77 triggerEdit: (edit: boolean) => void;
78 resizeOnNextFrame: () => void;
79 canUseCSSEllipsis(): boolean;
80 syncEllipsis(): void;
81 renderExpand(forceRender?: boolean): JSX.Element | null;
82 renderEdit(): JSX.Element | undefined;
83 renderCopy(): JSX.Element | undefined;
84 renderEditInput(): JSX.Element;
85 renderOperations(forceRenderExpanded?: boolean): (JSX.Element | null | undefined)[];
86 renderContent(): JSX.Element;
87 render(): JSX.Element;
88}
89export default Base;