mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-05 05:29:01 +08:00
00dc2add94
* feat: update prop type * feat: update ts type * feat: update ts type * feat: update ts type * feat: update ts type * test: update snap * feat: update ts type
52 lines
1.4 KiB
Vue
52 lines
1.4 KiB
Vue
import type { HTMLAttributes, PropType } from 'vue';
|
|
import { defineComponent } from 'vue';
|
|
import useConfigInject from '../_util/hooks/useConfigInject';
|
|
import classNames from '../_util/classNames';
|
|
import type { Direction } from '../config-provider';
|
|
|
|
export interface TypographyProps extends HTMLAttributes {
|
|
direction?: Direction;
|
|
prefixCls?: string;
|
|
}
|
|
|
|
export interface InternalTypographyProps extends TypographyProps {
|
|
component?: string;
|
|
}
|
|
export const typographyProps = () => ({
|
|
prefixCls: String,
|
|
direction: String as PropType<Direction>,
|
|
// Form Internal use
|
|
component: String,
|
|
});
|
|
const Typography = defineComponent<InternalTypographyProps>({
|
|
name: 'ATypography',
|
|
inheritAttrs: false,
|
|
props: typographyProps() as any,
|
|
setup(props, { slots, attrs }) {
|
|
const { prefixCls, direction } = useConfigInject('typography', props);
|
|
return () => {
|
|
const {
|
|
prefixCls: _prefixCls,
|
|
class: _className,
|
|
direction: _direction,
|
|
component: Component = 'article' as any,
|
|
...restProps
|
|
} = { ...props, ...attrs };
|
|
return (
|
|
<Component
|
|
class={classNames(
|
|
prefixCls.value,
|
|
{ [`${prefixCls.value}-rtl`]: direction.value === 'rtl' },
|
|
attrs.class,
|
|
)}
|
|
{...restProps}
|
|
>
|
|
{slots.default?.()}
|
|
</Component>
|
|
);
|
|
};
|
|
},
|
|
});
|
|
|
|
export default Typography;
|