mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-16 01:41:15 +08:00
b0025d9e79
* feat: add typography * fix: review typography * fix: review typography * feat: update typography * feat: update typography * fix: typography * test: update typography Co-authored-by: zkwolf <chenhao5866@gmail.com>
36 lines
1.1 KiB
Vue
36 lines
1.1 KiB
Vue
import { AnchorHTMLAttributes, FunctionalComponent } from 'vue';
|
|
import warning from '../_util/warning';
|
|
import Base, { baseProps, BlockProps } from './Base';
|
|
import Omit from 'omit.js';
|
|
import PropTypes from '../_util/vue-types';
|
|
|
|
export interface LinkProps extends BlockProps, Omit<AnchorHTMLAttributes, 'type'> {
|
|
ellipsis?: boolean;
|
|
}
|
|
|
|
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;
|
|
Link.props = Omit({ ...baseProps(), ellipsis: PropTypes.looseBool }, ['component']);
|
|
|
|
export default Link;
|