Browse Source

Merge branch 'master' into master-to-merge-feature

pull/30870/head
afc163 4 years ago
parent
commit
e4bea72b88
  1. 18
      CHANGELOG.en-US.md
  2. 18
      CHANGELOG.zh-CN.md
  3. 144
      components/layout/__tests__/__snapshots__/demo.test.js.snap
  4. 7
      components/layout/demo/top.md
  5. 9
      components/menu/style/index.less
  6. 31
      components/typography/Base.tsx
  7. 197
      components/typography/__tests__/copy.test.tsx
  8. 2
      package.json
  9. 25
      site/theme/template/Home/RecommendPage.less

18
CHANGELOG.en-US.md

@ -15,6 +15,24 @@ timeline: true
---
## 4.16.2
`2021-06-07`
- 🐞 Fix Menu auto overflow with `horizontal` mod breaks by `float` element. [#30879](https://github.com/ant-design/ant-design/pull/30879)
- Typography
- 🐞 Fix the problem that Typography.Paragraph `copyable` will treat `React.Fragment` as an array. [#30869](https://github.com/ant-design/ant-design/pull/30869) [@crazyair](https://github.com/crazyair)
- 🐞 Fix Typography incorrect ellipsis width when customize `font-size`. [#30840](https://github.com/ant-design/ant-design/pull/30840)
- 🐞 Fix Progress `type="circle"` throws error `Rendered more hooks than during the previous render` sometimes. [#30855](https://github.com/ant-design/ant-design/pull/30855)
- 💄 Optimize Tooltip content width. [#30822](https://github.com/ant-design/ant-design/pull/30822) [@donysukardi](https://github.com/donysukardi)
- Table
- 🛠 Optimize state display logic of select all checkbox in Table. [#30811](https://github.com/ant-design/ant-design/pull/30811) [@kerm1it](https://github.com/kerm1it)
- 🐞 Fix Table column which contains filters or sorters cannot work with `onClick` and `ellipsis` property. [#30799](https://github.com/ant-design/ant-design/pull/30799)
- 💄 Fix Dropdown Item with link color style and click icon can also trigger link effect now. [#30802](https://github.com/ant-design/ant-design/pull/30802)
- 💄 Remove duplicated css reset styles for render performance. [#30660](https://github.com/ant-design/ant-design/pull/30660) [@renzhao1113](https://github.com/renzhao1113)
- TypeScript
- 🤖 Adjust Form, Input, Locale, PageHeader component definition. [#30776](https://github.com/ant-design/ant-design/pull/30776) [@qqabcv520](https://github.com/qqabcv520)
## 4.16.1
`2021-05-30`

18
CHANGELOG.zh-CN.md

@ -15,6 +15,24 @@ timeline: true
---
## 4.16.2
`2021-06-07`
- 🐞 修复 Menu `horizontal` 模式下的自动省略布局会被 `float` 破坏的问题。[#30879](https://github.com/ant-design/ant-design/pull/30879)
- Typography
- 🐞 修复 Typography.Paragraph 的 `copyable` 会将 React.Fragment 当做数组处理的问题。[#30869](https://github.com/ant-design/ant-design/pull/30869) [@crazyair](https://github.com/crazyair)
- 🐞 修复 Typography 自定义 `font-size` 时省略宽度不正确的问题。[#30840](https://github.com/ant-design/ant-design/pull/30840)
- 🐞 修复 Progress `type="circle"` 有时会报错 `Rendered more hooks than during the previous render` 的问题。[#30855](https://github.com/ant-design/ant-design/pull/30855)
- 💄 优化 Tooltip 内容的宽度。[#30822](https://github.com/ant-design/ant-design/pull/30822) [@donysukardi](https://github.com/donysukardi)
- Table
- 🛠 优化 Table 中全选复选框的状态显示逻辑。[#30811](https://github.com/ant-design/ant-design/pull/30811) [@kerm1it](https://github.com/kerm1it)
- 🐞 修复 Table 列筛选和排序时 `column.title` 设置 `onClick``ellipsis` 无效的问题。[#30799](https://github.com/ant-design/ant-design/pull/30799)
- 💄 修复 Dropdown 条目包含超链接时的颜色样式,另外现在点击图标也能触发超链接效果。[#30802](https://github.com/ant-design/ant-design/pull/30802)
- 💄 移除重复的通配符 reset 样式以优化样式渲染性能。[#30660](https://github.com/ant-design/ant-design/pull/30660) [@renzhao1113](https://github.com/renzhao1113)
- TypeScript
- 🤖 调整 Form, Input, Locale, PageHeader 组件类型定义使其更精确。[#30776](https://github.com/ant-design/ant-design/pull/30776) [@qqabcv520](https://github.com/qqabcv520)
## 4.16.1
`2021-05-30`

144
components/layout/__tests__/__snapshots__/demo.test.js.snap

@ -1351,6 +1351,150 @@ exports[`renders ./components/layout/demo/top.md correctly 1`] = `
nav 3
</span>
</li>
<li
class="ant-menu-overflow-item ant-menu-item ant-menu-item-only-child"
role="menuitem"
style="opacity:1;order:3"
tabindex="-1"
>
<span
class="ant-menu-title-content"
>
nav 4
</span>
</li>
<li
class="ant-menu-overflow-item ant-menu-item ant-menu-item-only-child"
role="menuitem"
style="opacity:1;order:4"
tabindex="-1"
>
<span
class="ant-menu-title-content"
>
nav 5
</span>
</li>
<li
class="ant-menu-overflow-item ant-menu-item ant-menu-item-only-child"
role="menuitem"
style="opacity:1;order:5"
tabindex="-1"
>
<span
class="ant-menu-title-content"
>
nav 6
</span>
</li>
<li
class="ant-menu-overflow-item ant-menu-item ant-menu-item-only-child"
role="menuitem"
style="opacity:1;order:6"
tabindex="-1"
>
<span
class="ant-menu-title-content"
>
nav 7
</span>
</li>
<li
class="ant-menu-overflow-item ant-menu-item ant-menu-item-only-child"
role="menuitem"
style="opacity:1;order:7"
tabindex="-1"
>
<span
class="ant-menu-title-content"
>
nav 8
</span>
</li>
<li
class="ant-menu-overflow-item ant-menu-item ant-menu-item-only-child"
role="menuitem"
style="opacity:1;order:8"
tabindex="-1"
>
<span
class="ant-menu-title-content"
>
nav 9
</span>
</li>
<li
class="ant-menu-overflow-item ant-menu-item ant-menu-item-only-child"
role="menuitem"
style="opacity:1;order:9"
tabindex="-1"
>
<span
class="ant-menu-title-content"
>
nav 10
</span>
</li>
<li
class="ant-menu-overflow-item ant-menu-item ant-menu-item-only-child"
role="menuitem"
style="opacity:1;order:10"
tabindex="-1"
>
<span
class="ant-menu-title-content"
>
nav 11
</span>
</li>
<li
class="ant-menu-overflow-item ant-menu-item ant-menu-item-only-child"
role="menuitem"
style="opacity:1;order:11"
tabindex="-1"
>
<span
class="ant-menu-title-content"
>
nav 12
</span>
</li>
<li
class="ant-menu-overflow-item ant-menu-item ant-menu-item-only-child"
role="menuitem"
style="opacity:1;order:12"
tabindex="-1"
>
<span
class="ant-menu-title-content"
>
nav 13
</span>
</li>
<li
class="ant-menu-overflow-item ant-menu-item ant-menu-item-only-child"
role="menuitem"
style="opacity:1;order:13"
tabindex="-1"
>
<span
class="ant-menu-title-content"
>
nav 14
</span>
</li>
<li
class="ant-menu-overflow-item ant-menu-item ant-menu-item-only-child"
role="menuitem"
style="opacity:1;order:14"
tabindex="-1"
>
<span
class="ant-menu-title-content"
>
nav 15
</span>
</li>
<li
aria-hidden="true"
class="ant-menu-overflow-item ant-menu-overflow-item-rest ant-menu-submenu ant-menu-submenu-horizontal"

7
components/layout/demo/top.md

@ -29,9 +29,10 @@ ReactDOM.render(
<Header>
<div className="logo" />
<Menu theme="dark" mode="horizontal" defaultSelectedKeys={['2']}>
<Menu.Item key="1">nav 1</Menu.Item>
<Menu.Item key="2">nav 2</Menu.Item>
<Menu.Item key="3">nav 3</Menu.Item>
{new Array(15).fill(null).map((_, index) => {
const key = index + 1;
return <Menu.Item key={key}>{`nav ${key}`}</Menu.Item>;
})}
</Menu>
</Header>
<Content style={{ padding: '0 50px' }}>

9
components/menu/style/index.less

@ -40,6 +40,15 @@
list-style: none;
}
// Overflow ellipsis
&-overflow {
display: flex;
&-item {
flex: none;
}
}
&-hidden,
&-submenu-hidden {
display: none;

31
components/typography/Base.tsx

@ -93,6 +93,13 @@ function wrapperDecorations(
return currentContent;
}
function getNode(dom: React.ReactNode, defaultNode: React.ReactNode, needDom?: boolean) {
if (dom === true || dom === undefined) {
return defaultNode;
}
return dom || (needDom && defaultNode);
}
interface InternalBlockProps extends BlockProps {
component: string;
}
@ -391,23 +398,27 @@ class Base extends React.Component<InternalBlockProps, BaseState> {
const prefixCls = this.getPrefixCls();
const { tooltips } = copyable as CopyConfig;
let tooltipNodes = toArray(tooltips) as React.ReactNode[];
if (tooltipNodes.length === 0) {
tooltipNodes = [this.copyStr, this.copiedStr];
}
const title = copied ? tooltipNodes[1] : tooltipNodes[0];
const ariaLabel = typeof title === 'string' ? title : '';
const icons = toArray((copyable as CopyConfig).icon);
const { tooltips, icon } = copyable as CopyConfig;
const tooltipNodes = Array.isArray(tooltips) ? tooltips : [tooltips];
const iconNodes = Array.isArray(icon) ? icon : [icon];
const title = copied
? getNode(tooltipNodes[1], this.copiedStr)
: getNode(tooltipNodes[0], this.copyStr);
const systemStr = copied ? this.copiedStr : this.copyStr;
const ariaLabel = typeof title === 'string' ? title : systemStr;
return (
<Tooltip key="copy" title={tooltips === false ? '' : title}>
<Tooltip key="copy" title={title}>
<TransButton
className={classNames(`${prefixCls}-copy`, copied && `${prefixCls}-copy-success`)}
onClick={this.onCopyClick}
aria-label={ariaLabel}
>
{copied ? icons[1] || <CheckOutlined /> : icons[0] || <CopyOutlined />}
{copied
? getNode(iconNodes[1], <CheckOutlined />, true)
: getNode(iconNodes[0], <CopyOutlined />, true)}
</TransButton>
</Tooltip>
);

197
components/typography/__tests__/copy.test.tsx

@ -0,0 +1,197 @@
import React from 'react';
import { mount } from 'enzyme';
import { SmileOutlined, LikeOutlined } from '@ant-design/icons';
import Base from '../Base';
describe('Typography copy', () => {
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
afterEach(() => {
errorSpy.mockReset();
});
describe('Base', () => {
describe('copyable', () => {
function copyTest({
name,
icon,
tooltips,
iconClassNames = [],
iconTexts = [],
tooltipTexts = [],
tooltipLength,
}: {
name: string;
icon?: boolean | React.ReactNode;
tooltips?: boolean | React.ReactNode;
iconClassNames?: string[];
iconTexts?: string[];
tooltipTexts?: string[];
tooltipLength?: number;
}) {
it(name, async () => {
jest.useFakeTimers();
const wrapper = mount(
<Base component="p" copyable={{ icon, tooltips }}>
test copy
</Base>,
);
if (iconClassNames[0] !== undefined) {
expect(wrapper.exists(iconClassNames[0])).toBeTruthy();
}
if (iconTexts[0] !== undefined) {
expect(wrapper.find('.ant-typography-copy').at(0).text()).toBe(iconTexts[0]);
}
wrapper.find('.ant-typography-copy').first().simulate('mouseenter');
jest.runAllTimers();
wrapper.update();
if (tooltipTexts[0] !== undefined) {
expect(wrapper.find('.ant-tooltip-inner').text()).toBe(tooltipTexts[0]);
}
if (tooltipLength !== undefined) {
expect(wrapper.find('.ant-tooltip-inner').length).toBe(tooltipLength);
}
wrapper.find('.ant-typography-copy').first().simulate('click');
jest.useRealTimers();
if (iconClassNames[1] !== undefined) {
expect(wrapper.exists(iconClassNames[1])).toBeTruthy();
}
wrapper.find('.ant-typography-copy').first().simulate('mouseenter');
wrapper.update();
wrapper.find('.ant-typography-copy').first().simulate('mouseenter');
if (tooltipTexts[1] !== undefined) {
expect(wrapper.find('.ant-tooltip-inner').text()).toBe(tooltipTexts[1]);
}
if (iconTexts[1] !== undefined) {
expect(wrapper.find('.ant-typography-copy').at(0).text()).toBe(iconTexts[1]);
}
jest.useFakeTimers();
wrapper.find('.ant-typography-copy').first().simulate('click');
jest.runAllTimers();
wrapper.update();
wrapper.unmount();
jest.useRealTimers();
});
}
const dom = (
<>
<span>1</span>2
</>
);
const dom2 = (
<>
<span>3</span>4
</>
);
const copy = '.anticon-copy';
const check = '.anticon-check';
copyTest({
name: 'icon basic copy',
iconClassNames: [copy, check],
tooltipTexts: ['Copy', 'Copied'],
});
copyTest({ name: 'icon true', icon: true, iconClassNames: [copy, check] });
copyTest({ name: 'icon two true', icon: [true, true], iconClassNames: [copy, check] });
copyTest({ name: 'icon false', icon: false, iconClassNames: [copy, check] });
copyTest({ name: 'icon custom text', icon: ['a', 'b'], iconTexts: ['a', 'b'] });
copyTest({ name: 'icon custom element', icon: [dom, dom2], iconTexts: ['12', '34'] });
copyTest({
name: 'icon custom icon',
icon: <SmileOutlined />,
iconClassNames: ['.anticon-smile', check],
});
copyTest({
name: 'icon custom icon2',
icon: [<SmileOutlined key="a" />, <LikeOutlined key="b" />],
iconClassNames: ['.anticon-smile', '.anticon-like'],
});
copyTest({
name: 'icon custom icon3',
icon: [
<>
<SmileOutlined />
<SmileOutlined />
</>,
<LikeOutlined key="b" />,
],
iconClassNames: ['.anticon-smile', '.anticon-like'],
});
copyTest({
name: 'icon custom icon4',
icon: (
<>
<SmileOutlined />
<LikeOutlined />
</>
),
iconClassNames: ['.anticon-smile', check],
});
copyTest({
name: 'icon custom icon5',
icon: (
<>
<SmileOutlined />
<LikeOutlined />
</>
),
iconClassNames: ['.anticon-like', check],
});
copyTest({
name: 'tooltips true',
tooltips: true,
tooltipLength: 1,
tooltipTexts: ['Copy', 'Copied'],
});
copyTest({ name: 'tooltips false', tooltips: false, tooltipLength: 0 });
copyTest({
name: 'tooltips custom text',
tooltips: ['a', 'b'],
tooltipLength: 1,
tooltipTexts: ['a', 'b'],
});
copyTest({
name: 'tooltips custom element ',
tooltips: [dom, dom2],
tooltipTexts: ['12', '34'],
});
copyTest({
name: 'tooltips first empty',
tooltips: ['', 'xxx'],
tooltipLength: 0,
});
copyTest({
name: 'tooltips first empty 2',
tooltips: [''],
tooltipLength: 0,
});
copyTest({
name: 'tooltips true true',
tooltips: [true, true],
tooltipTexts: ['Copy', 'Copied'],
});
copyTest({
name: 'tooltips true false',
tooltips: [true, false],
tooltipTexts: ['Copy', ''],
});
copyTest({
name: 'tooltips false true',
tooltips: [false, true],
tooltipLength: 0,
});
});
});
});

2
package.json

@ -1,6 +1,6 @@
{
"name": "antd",
"version": "4.16.1",
"version": "4.16.2",
"description": "An enterprise-class UI design language and React components implementation",
"title": "Ant Design",
"keywords": [

25
site/theme/template/Home/RecommendPage.less

@ -1,5 +1,13 @@
@import '../../../../components/style/themes/default.less';
.linear-gradient(@mid-pos, @end-pos) {
background: linear-gradient(
rgba(0, 0, 0, 0) 0%,
rgba(0, 0, 0, 0.25) @mid-pos,
rgba(0, 0, 0, 0.65) @end-pos
);
}
.recommend-block {
position: relative;
display: block;
@ -37,16 +45,15 @@
}
&::before {
.linear-gradient(40%, 100%);
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: linear-gradient(
rgba(0, 0, 0, 0) 0%,
rgba(0, 0, 0, 0, 0.25) 30%,
rgba(0, 0, 0, 0.5) 100%
);
opacity: 0.3;
transition: all 0.5s;
content: '';
pointer-events: none;
}
@ -107,9 +114,17 @@
.recommend-block {
&-main {
height: 408px;
&::before {
.linear-gradient(70%, 100%);
}
}
&:hover {
&::before {
opacity: 1;
}
.recommend-content {
transform: translateY(0);

Loading…
Cancel
Save