You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
897 B
30 lines
897 B
import * as React from 'react';
|
|
import omit from 'omit.js';
|
|
import devWarning from '../_util/devWarning';
|
|
import Base, { BlockProps, EllipsisConfig } from './Base';
|
|
|
|
export interface TextProps extends BlockProps {
|
|
ellipsis?: boolean | Omit<EllipsisConfig, 'expandable' | 'rows' | 'onExpand'>;
|
|
}
|
|
|
|
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;
|
|
|