2022-03-26 22:52:54 +08:00
|
|
|
import type { AnchorHTMLAttributes, ExtractPropTypes, FunctionalComponent } from 'vue';
|
2021-03-16 12:54:22 +08:00
|
|
|
import warning from '../_util/warning';
|
2021-06-26 09:35:40 +08:00
|
|
|
import Base, { baseProps } from './Base';
|
2021-09-25 16:51:32 +08:00
|
|
|
import omit from '../_util/omit';
|
2021-03-16 12:54:22 +08:00
|
|
|
|
2022-03-26 22:52:54 +08:00
|
|
|
export const linkProps = () =>
|
|
|
|
omit({ ...baseProps(), ellipsis: { type: Boolean, default: undefined } }, ['component']);
|
|
|
|
|
|
|
|
export type LinkProps = Partial<ExtractPropTypes<ReturnType<typeof linkProps>>> &
|
|
|
|
AnchorHTMLAttributes;
|
2021-03-16 12:54:22 +08:00
|
|
|
|
|
|
|
const Link: FunctionalComponent<LinkProps> = (props, { slots, attrs }) => {
|
|
|
|
const { ellipsis, rel, ...restProps } = { ...props, ...attrs };
|
|
|
|
warning(
|
|
|
|
typeof ellipsis !== 'object',
|
|
|
|
'Typography.Link',
|
|
|
|
'`ellipsis` only supports boolean value.',
|
|
|
|
);
|
|
|
|
const mergedProps = {
|
|
|
|
...restProps,
|
|
|
|
rel: rel === undefined && restProps.target === '_blank' ? 'noopener noreferrer' : rel,
|
|
|
|
ellipsis: !!ellipsis,
|
|
|
|
component: 'a',
|
|
|
|
};
|
|
|
|
// https://github.com/ant-design/ant-design/issues/26622
|
|
|
|
// @ts-ignore
|
|
|
|
delete mergedProps.navigate;
|
|
|
|
|
|
|
|
return <Base {...mergedProps} v-slots={slots}></Base>;
|
|
|
|
};
|
|
|
|
|
|
|
|
Link.displayName = 'ATypographyLink';
|
|
|
|
Link.inheritAttrs = false;
|
2022-03-26 22:52:54 +08:00
|
|
|
Link.props = linkProps();
|
2021-03-16 12:54:22 +08:00
|
|
|
|
|
|
|
export default Link;
|