mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-06 02:15:35 +08:00
29a15e2a5d
* refactor: use enum instead of multiple constants and refines types * fix: siganture and direction prop passing * Update Editable.tsx * refine types * test: update snap * style: prefer literal constants over enum * fix: refine types for typography * fix: restore ellipsis const * fix: restore ellipsis const * fix: restore textare importing
35 lines
992 B
TypeScript
35 lines
992 B
TypeScript
import * as React from 'react';
|
|
import warning from '../_util/warning';
|
|
import type { BlockProps } from './Base';
|
|
import Base from './Base';
|
|
|
|
export interface LinkProps
|
|
extends BlockProps<'a'>,
|
|
Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'type' | keyof BlockProps<'a'>> {
|
|
ellipsis?: boolean;
|
|
}
|
|
|
|
const Link = React.forwardRef<HTMLElement, LinkProps>(({ ellipsis, rel, ...restProps }, ref) => {
|
|
warning(
|
|
typeof ellipsis !== 'object',
|
|
'Typography.Link',
|
|
'`ellipsis` only supports boolean value.',
|
|
);
|
|
|
|
const baseRef = React.useRef<any>(null);
|
|
|
|
React.useImperativeHandle(ref, () => baseRef.current);
|
|
|
|
const mergedProps = {
|
|
...restProps,
|
|
rel: rel === undefined && restProps.target === '_blank' ? 'noopener noreferrer' : rel,
|
|
};
|
|
|
|
// @ts-expect-error: https://github.com/ant-design/ant-design/issues/26622
|
|
delete mergedProps.navigate;
|
|
|
|
return <Base {...mergedProps} ref={baseRef} ellipsis={!!ellipsis} component="a" />;
|
|
});
|
|
|
|
export default Link;
|