fix: typography
parent
5771e505c7
commit
51cd49cf9c
|
@ -37,13 +37,13 @@ export type BaseType = 'secondary' | 'success' | 'warning' | 'danger';
|
|||
const isLineClampSupport = isStyleSupport('webkitLineClamp');
|
||||
const isTextOverflowSupport = isStyleSupport('textOverflow');
|
||||
|
||||
interface CopyConfig {
|
||||
export interface CopyConfig {
|
||||
text?: string;
|
||||
onCopy?: () => void;
|
||||
tooltip?: boolean;
|
||||
}
|
||||
|
||||
interface EditConfig {
|
||||
export interface EditConfig {
|
||||
editing?: boolean;
|
||||
tooltip?: boolean;
|
||||
onStart?: () => void;
|
||||
|
@ -58,7 +58,7 @@ export interface EllipsisConfig {
|
|||
rows?: number;
|
||||
expandable?: boolean;
|
||||
suffix?: string;
|
||||
symbol?: VNodeTypes;
|
||||
symbol?: string;
|
||||
onExpand?: EventHandlerNonNull;
|
||||
onEllipsis?: (ellipsis: boolean) => void;
|
||||
tooltip?: boolean;
|
||||
|
@ -348,13 +348,8 @@ const Base = defineComponent<InternalBlockProps>({
|
|||
|
||||
// force render expand icon for measure usage or it will cause dead loop
|
||||
if (!forceRender && (state.expanded || !state.isEllipsis)) return null;
|
||||
|
||||
let expandContent;
|
||||
if (symbol) {
|
||||
expandContent = symbol;
|
||||
} else {
|
||||
expandContent = state.expandStr;
|
||||
}
|
||||
const expandContent =
|
||||
(slots.ellipsisSymbol ? slots.ellipsisSymbol() : symbol) || state.expandStr;
|
||||
|
||||
return (
|
||||
<a
|
||||
|
@ -585,5 +580,4 @@ export const baseProps = () => ({
|
|||
});
|
||||
|
||||
Base.props = baseProps();
|
||||
|
||||
export default Base;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { FunctionalComponent } from 'vue';
|
||||
import omit from 'omit.js';
|
||||
import warning from '../_util/warning';
|
||||
import Base, { baseProps, BlockProps, EllipsisConfig } from './Base';
|
||||
import Omit from 'omit.js';
|
||||
|
@ -21,7 +20,7 @@ const Text: FunctionalComponent<TextProps> = (props, { slots, attrs }) => {
|
|||
...props,
|
||||
ellipsis:
|
||||
ellipsis && typeof ellipsis === 'object'
|
||||
? omit(ellipsis as any, ['expandable', 'rows'])
|
||||
? Omit(ellipsis as any, ['expandable', 'rows'])
|
||||
: ellipsis,
|
||||
component: 'span',
|
||||
...attrs,
|
||||
|
|
|
@ -2,7 +2,7 @@ import Text from './Text';
|
|||
import Title from './Title';
|
||||
import Paragraph from './Paragraph';
|
||||
import PropTypes from '../_util/vue-types';
|
||||
import { defineComponent, HTMLAttributes, App, Plugin, computed } from 'vue';
|
||||
import { defineComponent, HTMLAttributes, App, Plugin } from 'vue';
|
||||
import useConfigInject from '../_util/hooks/useConfigInject';
|
||||
import Link from './Link';
|
||||
import classNames from '../_util/classNames';
|
||||
|
@ -17,10 +17,10 @@ interface InternalTypographyProps extends TypographyProps {
|
|||
|
||||
const Typography = defineComponent<InternalTypographyProps>({
|
||||
name: 'ATypography',
|
||||
Text: Text,
|
||||
Title: Title,
|
||||
Paragraph: Paragraph,
|
||||
Link: Link,
|
||||
Text,
|
||||
Title,
|
||||
Paragraph,
|
||||
Link,
|
||||
inheritAttrs: false,
|
||||
setup(props, { slots, attrs }) {
|
||||
const { prefixCls } = useConfigInject('typography', props);
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import { mount } from '@vue/test-utils';
|
||||
import { asyncExpect, sleep } from '@/tests/utils';
|
||||
import KeyCode from '../../_util/KeyCode';
|
||||
import copy from '../_util/copy-to-clipboard';
|
||||
import copy from '../../_util/copy-to-clipboard';
|
||||
import Title from '../Title';
|
||||
import AParagraph from '../Paragraph';
|
||||
import Paragraph from '../Paragraph';
|
||||
import Link from '../Link';
|
||||
import Base from '../Base';
|
||||
import mountTest from '../../../tests/shared/mountTest';
|
||||
import { nextTick, createTextVNode, createVNode } from 'vue';
|
||||
|
@ -11,9 +12,10 @@ import { nextTick, createTextVNode, createVNode } from 'vue';
|
|||
jest.mock('copy-to-clipboard');
|
||||
|
||||
describe('Typography', () => {
|
||||
mountTest(AParagraph);
|
||||
mountTest(Paragraph);
|
||||
mountTest(Base);
|
||||
mountTest(Title);
|
||||
mountTest(Link);
|
||||
|
||||
const LINE_STR_COUNT = 20;
|
||||
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
||||
|
@ -272,7 +274,7 @@ describe('Typography', () => {
|
|||
const wrapper = mount(Component, {
|
||||
global: {
|
||||
components: {
|
||||
AParagraph,
|
||||
Paragraph,
|
||||
},
|
||||
},
|
||||
props: {
|
||||
|
@ -335,8 +337,8 @@ describe('Typography', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should focus at the end of textarea', async () => {
|
||||
const wrapper = mount(AParagraph, {
|
||||
fit('should focus at the end of textarea', async () => {
|
||||
const wrapper = mount(Paragraph, {
|
||||
props: {
|
||||
editable: true,
|
||||
},
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
</template>
|
||||
<script>
|
||||
import { defineComponent } from 'vue';
|
||||
import demo from '../v2-doc/src/docs/typography/demo/ellipsis.vue';
|
||||
import demo from '../v2-doc/src/docs/typography/demo/index.vue';
|
||||
// import Affix from '../components/affix';
|
||||
export default defineComponent({
|
||||
components: {
|
||||
|
|
2
v2-doc
2
v2-doc
|
@ -1 +1 @@
|
|||
Subproject commit a295627e3b35302ee9da1215fb102a42210e3ba3
|
||||
Subproject commit 77d4fda0cd6e2d56704a2d6d789631d269a56a46
|
Loading…
Reference in New Issue