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