mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-12 23:35:38 +08:00
a21c1a88c1
* fix: Typography.Paragraph\Text\Title ts * feat: add doc * feat: title ts * feat: cr * chore: revert * chore: ts * feat: doc/sort & drop onChange
32 lines
966 B
TypeScript
32 lines
966 B
TypeScript
import * as React from 'react';
|
|
import omit from 'rc-util/lib/omit';
|
|
import devWarning from '../_util/devWarning';
|
|
import Base, { BlockProps, EllipsisConfig } from './Base';
|
|
|
|
export interface TextProps extends BlockProps {
|
|
ellipsis?: boolean | Omit<EllipsisConfig, 'expandable' | 'rows' | 'onExpand'>;
|
|
onClick?: (e?: React.MouseEvent<HTMLDivElement>) => void;
|
|
}
|
|
|
|
const Text: React.FC<TextProps> = ({ ellipsis, ...restProps }) => {
|
|
const mergedEllipsis = React.useMemo(() => {
|
|
if (ellipsis && typeof ellipsis === 'object') {
|
|
return omit(ellipsis as any, ['expandable', 'rows']);
|
|
}
|
|
|
|
return ellipsis;
|
|
}, [ellipsis]);
|
|
|
|
devWarning(
|
|
typeof ellipsis !== 'object' ||
|
|
!ellipsis ||
|
|
(!('expandable' in ellipsis) && !('rows' in ellipsis)),
|
|
'Typography.Text',
|
|
'`ellipsis` do not support `expandable` or `rows` props.',
|
|
);
|
|
|
|
return <Base {...restProps} ellipsis={mergedEllipsis} component="span" />;
|
|
};
|
|
|
|
export default Text;
|