From 64f6fd1cf24b1e8b7c11cd91c5efe70dbd077104 Mon Sep 17 00:00:00 2001 From: zombiej Date: Wed, 19 Jan 2022 15:26:45 +0800 Subject: [PATCH 01/11] chore: Add DingDing release bot --- .github/workflows/release-helper.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/release-helper.yml b/.github/workflows/release-helper.yml index d53ea4b21a..66d96a6e6b 100644 --- a/.github/workflows/release-helper.yml +++ b/.github/workflows/release-helper.yml @@ -27,3 +27,16 @@ jobs: msg-footer: '💬 前往 [**Ant Design Releases**]({{url}}) 查看更新日志' prettier: true prerelease-filter: '-, a, b, A, B' + + - name: make release - Bigfish + uses: actions-cool/release-helper@v1 + with: + triger: 'tag' + changelogs: 'CHANGELOG.en-US.md, CHANGELOG.zh-CN.md' + branch: 'master' + dingding-token: ${{ secrets.DINGDING_BOT_BIGFISH_TOKEN }} + dingding-msg: 'CHANGELOG.zh-CN.md' + msg-poster: 'https://gw.alipayobjects.com/mdn/rms_08e378/afts/img/A*zx7LTI_ECSAAAAAAAAAAAABkARQnAQ' + msg-footer: '💬 前往 [**Ant Design Releases**]({{url}}) 查看更新日志' + prettier: true + prerelease-filter: '-, a, b, A, B' From 0d114752134c0540a5f22d48cde6c7223213f9c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E6=9C=BA=E5=99=A8=E4=BA=BA?= Date: Wed, 19 Jan 2022 15:27:05 +0800 Subject: [PATCH 02/11] chore: conch script (#33766) --- package.json | 2 ++ scripts/post-script.js | 67 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 scripts/post-script.js diff --git a/package.json b/package.json index be893e1d03..8b805d61d5 100644 --- a/package.json +++ b/package.json @@ -83,6 +83,7 @@ "pretty-quick": "pretty-quick", "pub": "npm run version && antd-tools run pub", "prepublishOnly": "antd-tools run guard", + "postpublish": "node ./scripts/post-script.js", "site:theme": "npm run site:theme-dark && npm run site:theme-compact", "site:theme-dark": "cross-env ESBUILD=1 ANT_THEME=dark bisheng build -c ./site/bisheng.config.js", "site:theme-compact": "cross-env ESBUILD=1 ANT_THEME=compact bisheng build -c ./site/bisheng.config.js", @@ -270,6 +271,7 @@ "remove-files-webpack-plugin": "^1.4.5", "rimraf": "^3.0.0", "scrollama": "^3.0.0", + "semver": "^7.3.5", "simple-git": "^2.23.0", "string-replace-loader": "^3.0.3", "stylelint": "^14.0.0", diff --git a/scripts/post-script.js b/scripts/post-script.js new file mode 100644 index 0000000000..477fbf4c25 --- /dev/null +++ b/scripts/post-script.js @@ -0,0 +1,67 @@ +const fetch = require('isomorphic-fetch'); +const semver = require('semver'); +const moment = require('moment'); +const inquirer = require('inquirer'); +const chalk = require('chalk'); +const { spawnSync } = require('child_process'); + +const SAFE_DAYS_DIFF = 1000 * 60 * 60 * 24 * 15; // 15 days + +(async function process() { + console.log(chalk.cyan('🤖 Post Publish Scripting...\n')); + const { time, 'dist-tags': distTags } = await fetch('http://registry.npmjs.org/antd').then(res => + res.json(), + ); + + console.log('🐚 Latest Conch Version:', chalk.green(distTags.conch || 'null'), '\n'); + + // Sort and get the latest versions + const versionList = Object.keys(time) + .filter(version => semver.valid(version) && !semver.prerelease(version)) + .sort((v1, v2) => { + const time1 = moment(time[v1]).valueOf(); + const time2 = moment(time[v2]).valueOf(); + + return time2 - time1; + }); + + // Slice for choosing the latest versions + const latestVersions = versionList.slice(0, 10).map(version => ({ + publishTime: time[version], + timeDiff: moment().diff(moment(time[version])), + value: version, + })); + + const defaultVersionObj = latestVersions.find(({ timeDiff }) => timeDiff >= SAFE_DAYS_DIFF); + const defaultVersion = defaultVersionObj ? defaultVersionObj.value : null; + + // Selection + const { conchVersion } = await inquirer.prompt([ + { + type: 'list', + name: 'conchVersion', + default: defaultVersion, + message: 'Please select Conch Version:', + choices: latestVersions.map(info => { + const { value, publishTime } = info; + const desc = moment(publishTime).fromNow(); + + return { + ...info, + name: `${value} (${desc}) ${value === defaultVersion ? '(default)' : ''}`, + }; + }), + }, + ]); + + // Check if need to update + if (distTags.conch === conchVersion) { + console.log(`🎃 Conch Version not change. Safe to ${chalk.green('ignore')}.`); + } else { + console.log('💾 Tagging Conch Version:', chalk.green(conchVersion)); + spawnSync('npm', ['dist-tag', 'add', `antd@${conchVersion}`, 'conch'], { + stdio: 'inherit', + stdin: 'inherit', + }); + } +})(); From 85c96251d36330f90ce7a4e00fd95fba812c68cf Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 19 Jan 2022 15:38:48 +0800 Subject: [PATCH 03/11] fix: Tag color in dark theme (#33751) * docs: update dark theme doc * fix: dark tag theme --- components/style/themes/dark.less | 11 +++++++++++ docs/react/contributing.en-US.md | 2 ++ docs/react/contributing.zh-CN.md | 2 ++ 3 files changed, 15 insertions(+) diff --git a/components/style/themes/dark.less b/components/style/themes/dark.less index 00ec8c7bdd..59a9b69f20 100644 --- a/components/style/themes/dark.less +++ b/components/style/themes/dark.less @@ -320,6 +320,17 @@ @table-filter-dropdown-bg: @popover-background; @table-expand-icon-bg: transparent; +// Tag +// --- +@info-color-deprecated-bg: @primary-1; +@info-color-deprecated-border: @primary-3; +@success-color-deprecated-bg: @green-1; +@success-color-deprecated-border: @green-3; +@warning-color-deprecated-bg: @orange-1; +@warning-color-deprecated-border: @orange-3; +@error-color-deprecated-bg: @red-1; +@error-color-deprecated-border: @red-3; + // TimePicker // --- @picker-basic-cell-hover-with-range-color: darken(@primary-color, 35%); diff --git a/docs/react/contributing.en-US.md b/docs/react/contributing.en-US.md index 0c19b32572..6788342897 100644 --- a/docs/react/contributing.en-US.md +++ b/docs/react/contributing.en-US.md @@ -79,6 +79,8 @@ Use `DEV_THEME` to change start theme: DEV_THEME=dark npm start ``` +Visit [http://127.0.0.1:8001/components/button-cn/?theme=dark](http://127.0.0.1:8001/components/button-cn/?theme=dark). + ## Being a collaborator If you are an active contributor and are willing to work with Ant Design Team in our opensource workflow, you can [apply to be a outside collaborator](https://github.com/ant-design/ant-design/wiki/Collaborators#how-to-apply-for-being-a-collaborator). diff --git a/docs/react/contributing.zh-CN.md b/docs/react/contributing.zh-CN.md index 7d73e8b486..14a9aeecd6 100644 --- a/docs/react/contributing.zh-CN.md +++ b/docs/react/contributing.zh-CN.md @@ -79,6 +79,8 @@ Ant Design 团队会关注所有的 pull request,我们会 review 以及合并 DEV_THEME=dark npm start ``` +访问 [http://127.0.0.1:8001/components/button-cn/?theme=dark](http://127.0.0.1:8001/components/button-cn/?theme=dark)。 + ## 加入社区 如果你贡献度足够活跃,希望和 Ant Design 团队一起参与维护工作,你可以[申请成为社区协作者](https://github.com/ant-design/ant-design/wiki/Collaborators#how-to-apply-for-being-a-collaborator)。 From 30086db63fdbc796294fe5d0d689e0a1f3480e34 Mon Sep 17 00:00:00 2001 From: dengqing <1247748612@qq.com> Date: Wed, 19 Jan 2022 19:05:25 +0800 Subject: [PATCH 04/11] =?UTF-8?q?docs:=20=E2=9C=8F=EF=B8=8F=20add=20note?= =?UTF-8?q?=20comment=20(#33771)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: dengqing --- components/typography/index.en-US.md | 2 ++ components/typography/index.zh-CN.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/components/typography/index.en-US.md b/components/typography/index.en-US.md index a8b897c5fe..58796086c4 100644 --- a/components/typography/index.en-US.md +++ b/components/typography/index.en-US.md @@ -144,3 +144,5 @@ Basic text writing, including headings, body text, lists, and more. ```tsx ``` + +**Note:** This is not equivalent to the execution logic of react-router's Link [reference](https://github.com/ant-design/ant-design/pull/26737/files#r488769888) diff --git a/components/typography/index.zh-CN.md b/components/typography/index.zh-CN.md index 26b9253f25..1a1fdaa9dc 100644 --- a/components/typography/index.zh-CN.md +++ b/components/typography/index.zh-CN.md @@ -145,3 +145,5 @@ cover: https://gw.alipayobjects.com/zos/alicdn/GOM1KQ24O/Typography.svg ```tsx ``` + +**注意:** 这并不是和 react-router 的 Link 的执行逻辑等价 [参考](https://github.com/ant-design/ant-design/pull/26737/files#r488769888) From d777a5430ccfc8550a0c484b150aecb579c7b277 Mon Sep 17 00:00:00 2001 From: MadCcc <1075746765@qq.com> Date: Thu, 20 Jan 2022 10:15:42 +0800 Subject: [PATCH 05/11] fix: update prevValue of checkbox if value changed (#33753) --- components/checkbox/Checkbox.tsx | 1 + components/checkbox/__tests__/group.test.js | 39 ++++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/components/checkbox/Checkbox.tsx b/components/checkbox/Checkbox.tsx index a4df83fd0d..8834aed75a 100644 --- a/components/checkbox/Checkbox.tsx +++ b/components/checkbox/Checkbox.tsx @@ -78,6 +78,7 @@ const InternalCheckbox: React.ForwardRefRenderFunction checkboxGroup?.cancelValue(restProps.value); }, [restProps.value]); diff --git a/components/checkbox/__tests__/group.test.js b/components/checkbox/__tests__/group.test.js index b944b5bce8..8d7059ffcc 100644 --- a/components/checkbox/__tests__/group.test.js +++ b/components/checkbox/__tests__/group.test.js @@ -1,10 +1,11 @@ -import React from 'react'; +import React, { useState } from 'react'; import { mount, render } from 'enzyme'; import Collapse from '../../collapse'; import Table from '../../table'; import Checkbox from '../index'; import mountTest from '../../../tests/shared/mountTest'; import rtlTest from '../../../tests/shared/rtlTest'; +import Input from '../../input'; describe('CheckboxGroup', () => { mountTest(Checkbox.Group); @@ -222,4 +223,40 @@ describe('CheckboxGroup', () => { wrapper.find('.ant-checkbox-input').at(0).simulate('change'); expect(onChange).toHaveBeenCalledWith([1]); }); + + it('should store latest checkbox value if changed', () => { + const onChange = jest.fn(); + + const Demo = () => { + const [v, setV] = useState(''); + + React.useEffect(() => { + setTimeout(setV('1'), 1000); + }, []); + + return ( +
+ setV(e.target.value)} /> + + + A + + +
+ ); + }; + + const wrapper = mount(); + + wrapper.find('.ant-checkbox-input').first().simulate('change'); + expect(onChange).toHaveBeenCalledWith([]); + wrapper.find('.ant-checkbox-input').first().simulate('change'); + expect(onChange).toHaveBeenCalledWith(['length1']); + wrapper + .find('.ant-input') + .first() + .simulate('change', { target: { value: '' } }); + wrapper.find('.ant-checkbox-input').first().simulate('change'); + expect(onChange).toHaveBeenCalledWith(['A']); + }); }); From 6063916394c5c8126aa2294b3547b3d47834900b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E6=9C=BA=E5=99=A8=E4=BA=BA?= Date: Thu, 20 Jan 2022 13:27:57 +0800 Subject: [PATCH 06/11] fix: Cascader auto placement & scroll (#33777) * fix: Cascader auto placement & scroll * chore: bump rc-tree-select --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8b805d61d5..fbc0dde298 100644 --- a/package.json +++ b/package.json @@ -121,7 +121,7 @@ "lodash": "^4.17.21", "memoize-one": "^6.0.0", "moment": "^2.25.3", - "rc-cascader": "~3.0.0-alpha.8", + "rc-cascader": "~3.2.1", "rc-checkbox": "~2.3.0", "rc-collapse": "~3.1.0", "rc-dialog": "~8.6.0", @@ -148,7 +148,7 @@ "rc-textarea": "~0.3.0", "rc-tooltip": "~5.1.1", "rc-tree": "~5.4.3", - "rc-tree-select": "~5.1.0", + "rc-tree-select": "~5.1.1", "rc-trigger": "^5.2.10", "rc-upload": "~4.3.0", "rc-util": "^5.14.0", From 222d1b7095d11602d5727c5d3440b2c33d7c7df1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E6=9C=BA=E5=99=A8=E4=BA=BA?= Date: Thu, 20 Jan 2022 15:36:03 +0800 Subject: [PATCH 07/11] chore: try to find safe version (#33783) --- scripts/post-script.js | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/scripts/post-script.js b/scripts/post-script.js index 477fbf4c25..2f8c50a638 100644 --- a/scripts/post-script.js +++ b/scripts/post-script.js @@ -5,7 +5,8 @@ const inquirer = require('inquirer'); const chalk = require('chalk'); const { spawnSync } = require('child_process'); -const SAFE_DAYS_DIFF = 1000 * 60 * 60 * 24 * 15; // 15 days +const SAFE_DAYS_START = 1000 * 60 * 60 * 24 * 15; // 15 days +const SAFE_DAYS_DIFF = 1000 * 60 * 60 * 24 * 3; // 3 days not update seems to be stable (async function process() { console.log(chalk.cyan('🤖 Post Publish Scripting...\n')); @@ -26,13 +27,32 @@ const SAFE_DAYS_DIFF = 1000 * 60 * 60 * 24 * 15; // 15 days }); // Slice for choosing the latest versions - const latestVersions = versionList.slice(0, 10).map(version => ({ + const latestVersions = versionList.slice(0, 20).map(version => ({ publishTime: time[version], timeDiff: moment().diff(moment(time[version])), value: version, })); - const defaultVersionObj = latestVersions.find(({ timeDiff }) => timeDiff >= SAFE_DAYS_DIFF); + const startDefaultVersionIndex = latestVersions.findIndex( + ({ timeDiff }) => timeDiff >= SAFE_DAYS_START, + ); + const defaultVersionList = latestVersions.slice(0, startDefaultVersionIndex + 1).reverse(); + + // Find safe version + let defaultVersionObj; + for (let i = 0; i < defaultVersionList.length - 1; i += 1) { + defaultVersionObj = defaultVersionList[i]; + const nextVersionObj = defaultVersionList[i + 1]; + + if (defaultVersionObj.timeDiff - nextVersionObj.timeDiff > SAFE_DAYS_DIFF) { + break; + } + + defaultVersionObj = null; + } + + // Not find to use the latest version instead + defaultVersionObj = defaultVersionObj || defaultVersionList[defaultVersionList.length - 1]; const defaultVersion = defaultVersionObj ? defaultVersionObj.value : null; // Selection From 3c76de74cef138684a708fcf671ca232e59c3294 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Long=20Hao=20=28=E9=BE=99=E6=BF=A0=29?= <45565100+LongHaoo@users.noreply.github.com> Date: Thu, 20 Jan 2022 18:05:36 +0800 Subject: [PATCH 08/11] fix: Get ref of Card component #33730 (#33784) * fix: Get ref of Card component #33730 * add test to the card ref Co-authored-by: zengguhao.zgh --- components/card/__tests__/index.test.js | 18 ++++++++++++++++++ components/card/index.tsx | 8 ++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/components/card/__tests__/index.test.js b/components/card/__tests__/index.test.js index 8e1cade399..da9a0979c0 100644 --- a/components/card/__tests__/index.test.js +++ b/components/card/__tests__/index.test.js @@ -82,4 +82,22 @@ describe('Card', () => { ); expect(wrapper.find('Tabs').get(0).props.size).toBe('small'); }); + + it('get ref of card', () => { + class WrapperComponent extends React.Component { + render() { + return ( + +

Card content

+
+ ); + } + } + const wrapper = mount(); + expect(wrapper.ref('firstRef').className.includes('ant-card')).toBe(true); + }); }); diff --git a/components/card/index.tsx b/components/card/index.tsx index 983eb92c89..b4b39ac0db 100644 --- a/components/card/index.tsx +++ b/components/card/index.tsx @@ -56,12 +56,12 @@ export interface CardProps extends Omit, 't tabProps?: TabsProps; } -export interface CardInterface extends React.FC { +export interface CardInterface extends React.ForwardRefExoticComponent { Grid: typeof Grid; Meta: typeof Meta; } -const Card: CardInterface = props => { +const Card = React.forwardRef((props: CardProps, ref: React.Ref) => { const { getPrefixCls, direction } = React.useContext(ConfigContext); const size = React.useContext(SizeContext); @@ -196,14 +196,14 @@ const Card: CardInterface = props => { ); return ( -
+
{head} {coverDom} {body} {actionDom}
); -}; +}) as CardInterface; Card.Grid = Grid; Card.Meta = Meta; From 6dd39c1f89b4d6632e6ed022ff1bc275ca1e0f1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=B5=A9?= Date: Thu, 20 Jan 2022 19:23:14 +0800 Subject: [PATCH 09/11] fix(checkbox): disabled checkbox should works well with tooltip (#33772) Co-authored-by: wanghao --- components/checkbox/style/mixin.less | 1 + .../__snapshots__/tooltip.test.js.snap | 26 ------------------- components/tooltip/__tests__/tooltip.test.js | 2 -- components/tooltip/index.tsx | 9 ++++--- 4 files changed, 6 insertions(+), 32 deletions(-) diff --git a/components/checkbox/style/mixin.less b/components/checkbox/style/mixin.less index 60c8201a5e..c16a3f091a 100644 --- a/components/checkbox/style/mixin.less +++ b/components/checkbox/style/mixin.less @@ -122,6 +122,7 @@ .@{checkbox-prefix-cls}-input { cursor: not-allowed; + pointer-events: none; } .@{checkbox-inner-prefix-cls} { diff --git a/components/tooltip/__tests__/__snapshots__/tooltip.test.js.snap b/components/tooltip/__tests__/__snapshots__/tooltip.test.js.snap index 718c3d35ee..776998c5f7 100644 --- a/components/tooltip/__tests__/__snapshots__/tooltip.test.js.snap +++ b/components/tooltip/__tests__/__snapshots__/tooltip.test.js.snap @@ -16,32 +16,6 @@ exports[`Tooltip should hide when mouse leave antd disabled component Button 1`] `; -exports[`Tooltip should hide when mouse leave antd disabled component Checkbox 1`] = ` - - - -`; - exports[`Tooltip should hide when mouse leave antd disabled component Switch 1`] = ` { testComponent('Button', Button); testComponent('Switch', Switch); - testComponent('Checkbox', Checkbox); }); it('should render disabled Button style properly', () => { diff --git a/components/tooltip/index.tsx b/components/tooltip/index.tsx index 8842bb7c84..ee5beaf753 100644 --- a/components/tooltip/index.tsx +++ b/components/tooltip/index.tsx @@ -87,7 +87,6 @@ function getDisabledCompatibleChildren(element: React.ReactElement, prefixC if ( (elementType.__ANT_BUTTON === true || elementType.__ANT_SWITCH === true || - elementType.__ANT_CHECKBOX === true || element.type === 'button') && element.props.disabled ) { @@ -130,9 +129,11 @@ function getDisabledCompatibleChildren(element: React.ReactElement, prefixC } const Tooltip = React.forwardRef((props, ref) => { - const { getPopupContainer: getContextPopupContainer, getPrefixCls, direction } = React.useContext( - ConfigContext, - ); + const { + getPopupContainer: getContextPopupContainer, + getPrefixCls, + direction, + } = React.useContext(ConfigContext); const [visible, setVisible] = useMergedState(false, { value: props.visible, From 5d2994ec128ed81b7c55c1955e2e47010ef0db34 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 21 Jan 2022 10:40:34 +0800 Subject: [PATCH 10/11] style: Cascader loading icon (#33799) --- components/cascader/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/cascader/index.tsx b/components/cascader/index.tsx index 18881e52fd..f38029f626 100644 --- a/components/cascader/index.tsx +++ b/components/cascader/index.tsx @@ -10,7 +10,7 @@ import type { } from 'rc-cascader'; import omit from 'rc-util/lib/omit'; import RightOutlined from '@ant-design/icons/RightOutlined'; -import RedoOutlined from '@ant-design/icons/RedoOutlined'; +import LoadingOutlined from '@ant-design/icons/LoadingOutlined'; import LeftOutlined from '@ant-design/icons/LeftOutlined'; import devWarning from '../_util/devWarning'; import { ConfigContext } from '../config-provider'; @@ -193,7 +193,7 @@ const Cascader = React.forwardRef((props: CascaderProps, ref: React.Ref - + ); From 9cf0dca8fcba49b3dfdda9a9d0836732df14bd4d Mon Sep 17 00:00:00 2001 From: MadCcc <1075746765@qq.com> Date: Fri, 21 Jan 2022 11:49:07 +0800 Subject: [PATCH 11/11] test: fix cascader test coverage (#33802) --- components/cascader/__tests__/index.test.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/cascader/__tests__/index.test.js b/components/cascader/__tests__/index.test.js index 72c409ffb6..91013cd1e3 100644 --- a/components/cascader/__tests__/index.test.js +++ b/components/cascader/__tests__/index.test.js @@ -475,6 +475,12 @@ describe('Cascader', () => { expect(onChange).toHaveBeenCalledWith(['Zhejiang', 'Hangzhou', 'West Lake'], expect.anything()); }); + it('rtl should work well with placement', () => { + const wrapper = mount(); + + expect(wrapper.find('Trigger').prop('popupPlacement')).toEqual('bottomRight'); + }); + describe('legacy props', () => { it('popupClassName', () => { const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});