From 98e715fe3fa81824e2b4e76231a0707b929a87d7 Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 23 Sep 2019 17:05:56 +0800 Subject: [PATCH 01/29] :memo: Add recommendation for vedio components --- docs/react/recommendation.en-US.md | 1 + docs/react/recommendation.zh-CN.md | 1 + 2 files changed, 2 insertions(+) diff --git a/docs/react/recommendation.en-US.md b/docs/react/recommendation.en-US.md index bcfb3161dc..911476a7f2 100644 --- a/docs/react/recommendation.en-US.md +++ b/docs/react/recommendation.en-US.md @@ -27,6 +27,7 @@ title: Third-Party Libraries | Markdown renderer | [react-markdown](http://rexxars.github.io/react-markdown/) | | Infinite Scroll | [react-virtualized](https://github.com/bvaughn/react-virtualized) [antd-table-infinity](https://github.com/Leonard-Li777/antd-table-infinity) | | Map | [react-google-maps](https://github.com/tomchentw/react-google-maps) [google-map-react](https://github.com/istarkov/google-map-react) [react-amap](https://github.com/ElemeFE/react-amap) | +| Video | [react-player](https://github.com/CookPete/react-player) [video-react](https://github.com/video-react/video-react) [video.js](http://docs.videojs.com/tutorial-react.html) | | Context Menu | [react-contextmenu](https://github.com/vkbansal/react-contextmenu/) [react-contexify](https://github.com/fkhadra/react-contexify) | | Emoji | [emoji-mart](https://github.com/missive/emoji-mart) | | Split View | [react-split-pane](https://github.com/tomkp/react-split-pane) | diff --git a/docs/react/recommendation.zh-CN.md b/docs/react/recommendation.zh-CN.md index 171de62636..ba4c06efa4 100644 --- a/docs/react/recommendation.zh-CN.md +++ b/docs/react/recommendation.zh-CN.md @@ -27,6 +27,7 @@ title: 社区精选组件 | Markdown 渲染 | [react-markdown](http://rexxars.github.io/react-markdown/) | | 无限滚动 | [react-virtualized](https://github.com/bvaughn/react-virtualized) [antd-table-infinity](https://github.com/Leonard-Li777/antd-table-infinity) | | 地图 | [react-google-maps](https://github.com/tomchentw/react-google-maps) [google-map-react](https://github.com/istarkov/google-map-react) [react-amap 高德](https://github.com/ElemeFE/react-amap) | +| 视频播放 | [react-player](https://github.com/CookPete/react-player) [video-react](https://github.com/video-react/video-react) [video.js](http://docs.videojs.com/tutorial-react.html) | | 右键菜单 | [react-contextmenu](https://github.com/vkbansal/react-contextmenu/) [react-contexify](https://github.com/fkhadra/react-contexify) | | Emoji | [emoji-mart](https://github.com/missive/emoji-mart) | | 分割面板 | [react-split-pane](https://github.com/tomkp/react-split-pane) | From 02ed4bd6b1029f510a49c135fdea9f6889dc85be Mon Sep 17 00:00:00 2001 From: sosohime Date: Mon, 23 Sep 2019 18:49:13 +0800 Subject: [PATCH 02/29] fix: TreeSelect removeIcon and clearIcon not working (#18949) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add tree-select async demo * TreeSelect支持clearIcon和removeIcon * remove docs and demo * run test * clear code * add ui test --- .../__snapshots__/index.test.js.snap | 93 +++++++++++++++++++ .../tree-select/__tests__/index.test.js | 28 +++++- components/tree-select/index.tsx | 28 ++++-- components/tree-select/interface.tsx | 2 + 4 files changed, 141 insertions(+), 10 deletions(-) create mode 100644 components/tree-select/__tests__/__snapshots__/index.test.js.snap diff --git a/components/tree-select/__tests__/__snapshots__/index.test.js.snap b/components/tree-select/__tests__/__snapshots__/index.test.js.snap new file mode 100644 index 0000000000..83b601ea64 --- /dev/null +++ b/components/tree-select/__tests__/__snapshots__/index.test.js.snap @@ -0,0 +1,93 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`TreeSelect TreeSelect Custom Icons should support customized icons 1`] = ` + + + + + + clear + + + + + +`; diff --git a/components/tree-select/__tests__/index.test.js b/components/tree-select/__tests__/index.test.js index d6270bcc7d..9cc7a520ea 100644 --- a/components/tree-select/__tests__/index.test.js +++ b/components/tree-select/__tests__/index.test.js @@ -1,6 +1,6 @@ import React from 'react'; import { mount } from 'enzyme'; -import TreeSelect from '..'; +import TreeSelect, { TreeNode } from '..'; import focusTest from '../../../tests/shared/focusTest'; import mountTest from '../../../tests/shared/mountTest'; @@ -17,4 +17,30 @@ describe('TreeSelect', () => { expect(multiple.find('.ant-select-search__field').length).toBeTruthy(); }); }); + + describe('TreeSelect Custom Icons', () => { + it('should support customized icons', () => { + const wrapper = mount( + clear} + removeIcon={remove} + value={['leaf1', 'leaf2']} + placeholder="Please select" + multiple + allowClear + treeDefaultExpandAll + > + + + + + + + , + ); + + expect(wrapper.render()).toMatchSnapshot(); + }); + }); }); diff --git a/components/tree-select/index.tsx b/components/tree-select/index.tsx index 189a9878ea..61432c6f8a 100644 --- a/components/tree-select/index.tsx +++ b/components/tree-select/index.tsx @@ -5,6 +5,7 @@ import omit from 'omit.js'; import { TreeSelectProps, TreeNodeValue } from './interface'; import { ConfigConsumer, ConfigConsumerProps } from '../config-provider'; import warning from '../_util/warning'; +import { cloneElement } from '../_util/reactNode'; import Icon from '../icon'; import { AntTreeNodeProps } from '../tree'; @@ -74,6 +75,8 @@ export default class TreeSelect extends React.Component dropdownStyle, dropdownClassName, suffixIcon, + removeIcon, + clearIcon, getPopupContainer, ...restProps } = this.props; @@ -99,15 +102,22 @@ export default class TreeSelect extends React.Component checkable = ; } - const inputIcon = (suffixIcon && - (React.isValidElement<{ className?: string }>(suffixIcon) - ? React.cloneElement(suffixIcon) - : suffixIcon)) || ; + const inputIcon = suffixIcon ? ( + cloneElement(suffixIcon) + ) : ( + + ); - const removeIcon = ; + const finalRemoveIcon = removeIcon ? ( + cloneElement(removeIcon) + ) : ( + + ); - const clearIcon = ( - + const finalClearIcon = clearIcon ? ( + cloneElement(clearIcon) + ) : ( + ); return ( @@ -116,8 +126,8 @@ export default class TreeSelect extends React.Component this.renderSwitcherIcon(prefixCls, nodeProps) } inputIcon={inputIcon} - removeIcon={removeIcon} - clearIcon={clearIcon} + removeIcon={finalRemoveIcon} + clearIcon={finalClearIcon} {...rest} showSearch={showSearch} getPopupContainer={getPopupContainer || getContextPopupContainer} diff --git a/components/tree-select/interface.tsx b/components/tree-select/interface.tsx index 9484cb878f..34cf3aa01b 100644 --- a/components/tree-select/interface.tsx +++ b/components/tree-select/interface.tsx @@ -52,6 +52,8 @@ export interface TreeSelectProps extends AbstractSelect searchValue?: string; showCheckedStrategy?: 'SHOW_ALL' | 'SHOW_PARENT' | 'SHOW_CHILD'; suffixIcon?: React.ReactNode; + removeIcon?: React.ReactNode; + clearIcon?: React.ReactNode; treeCheckable?: boolean | React.ReactNode; treeCheckStrictly?: boolean; treeData?: Array; From 0e52f9a891bfee6f8d6fed05677826879ac9fa80 Mon Sep 17 00:00:00 2001 From: MrHeer Date: Mon, 16 Sep 2019 19:08:46 +0800 Subject: [PATCH 03/29] :bug: fix Tree switcherIcon prop not working when showLine close #18810 --- components/tree/Tree.tsx | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/components/tree/Tree.tsx b/components/tree/Tree.tsx index 8e530860eb..3703d4cb78 100644 --- a/components/tree/Tree.tsx +++ b/components/tree/Tree.tsx @@ -194,10 +194,20 @@ export default class Tree extends React.Component { if (loading) { return ; } - if (showLine) { - if (isLeaf) { + if (isLeaf) { + if (showLine) { return ; } + return null; + } + const switcherCls = `${prefixCls}-switcher-icon`; + if (switcherIcon) { + const switcherOriginCls = switcherIcon.props.className || ''; + return React.cloneElement(switcherIcon, { + className: classNames(switcherOriginCls, switcherCls), + }); + } + if (showLine) { return ( { /> ); } - const switcherCls = `${prefixCls}-switcher-icon`; - if (isLeaf) { - return null; - } - if (switcherIcon) { - const switcherOriginCls = switcherIcon.props.className || ''; - return React.cloneElement(switcherIcon, { - className: classNames(switcherOriginCls, switcherCls), - }); - } return ; }; From 75d5dff1f9c3a68cc9a72fa07d38163f1bbbb65e Mon Sep 17 00:00:00 2001 From: MrHeer Date: Mon, 16 Sep 2019 21:03:29 +0800 Subject: [PATCH 04/29] :ok_hand: add use case --- .../__tests__/__snapshots__/demo.test.js.snap | 287 ++++++++++++++++++ components/tree/demo/switcher-icon.md | 54 ++++ 2 files changed, 341 insertions(+) create mode 100644 components/tree/demo/switcher-icon.md diff --git a/components/tree/__tests__/__snapshots__/demo.test.js.snap b/components/tree/__tests__/__snapshots__/demo.test.js.snap index 6d57def92c..73e3574e7a 100644 --- a/components/tree/__tests__/__snapshots__/demo.test.js.snap +++ b/components/tree/__tests__/__snapshots__/demo.test.js.snap @@ -1950,3 +1950,290 @@ exports[`renders ./components/tree/demo/search.md correctly 1`] = ` `; + +exports[`renders ./components/tree/demo/switcher-icon.md correctly 1`] = ` +
    +
  • + + + + + + + + parent 1 + + +
      +
    • + + + + + + + + parent 1-0 + + +
        +
      • + + + + + + + + leaf + + +
      • +
      • + + + + + + + + leaf + + +
      • +
      • + + + + + + + + leaf + + +
      • +
      +
    • +
    • + + + + + + + + parent 1-1 + + +
    • +
    • + + + + + + + + parent 1-2 + + +
    • +
    +
  • +
+`; diff --git a/components/tree/demo/switcher-icon.md b/components/tree/demo/switcher-icon.md new file mode 100644 index 0000000000..7b4c1e1648 --- /dev/null +++ b/components/tree/demo/switcher-icon.md @@ -0,0 +1,54 @@ +--- +order: 8 +title: + zh-CN: 自定义展开/折叠图标 + en-US: Customize collapse/expand icon +--- + +## zh-CN + +自定义展开/折叠图标。 + +## en-US + +customize collapse/expand icon of tree node + +```jsx +import { Tree, Icon } from 'antd'; + +const { TreeNode } = Tree; + +class Demo extends React.Component { + onSelect = (selectedKeys, info) => { + console.log('selected', selectedKeys, info); + }; + + render() { + return ( + } + defaultExpandedKeys={['0-0-0']} + onSelect={this.onSelect} + > + + + + + + + + + + + + + + + + ); + } +} + +ReactDOM.render(, mountNode); +``` From d0d181b6b813fc669bb28d97b78c1d8d393f5b47 Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 23 Sep 2019 19:40:46 +0800 Subject: [PATCH 05/29] :lipstick: improve home page button style --- site/theme/static/home.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/theme/static/home.less b/site/theme/static/home.less index 5781959a27..0300830a64 100644 --- a/site/theme/static/home.less +++ b/site/theme/static/home.less @@ -111,7 +111,7 @@ padding: 0 24px; font-size: 16px; font-family: Avenir, @font-family, sans-serif; - line-height: 38px; + line-height: 40px; text-align: center; text-decoration: none; border: 1px solid #2f54eb; From bd8d6d3e98115598a2b8b00a8d51aaa7da0bf5fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=AA=E6=8D=B1=E5=AE=85?= Date: Mon, 23 Sep 2019 20:55:23 +0800 Subject: [PATCH 06/29] Delete publish-to-github-package.yml --- .../workflows/publish-to-github-package.yml | 76 ------------------- 1 file changed, 76 deletions(-) delete mode 100644 .github/workflows/publish-to-github-package.yml diff --git a/.github/workflows/publish-to-github-package.yml b/.github/workflows/publish-to-github-package.yml deleted file mode 100644 index 80ebd2041c..0000000000 --- a/.github/workflows/publish-to-github-package.yml +++ /dev/null @@ -1,76 +0,0 @@ -name: Publish to github-package -on: - release: - types: [published] - -jobs: - compile: - runs-on: ubuntu-latest - - steps: - - name: checkout - uses: actions/checkout@master - - - uses: actions/setup-node@v1 - with: - node-version: '12.x' - registry-url: 'https://registry.npmjs.org' - - - name: install - run: npm install - - - name: compile - run: npm run compile - - - name: dist - run: npm run dist - - - uses: actions/upload-artifact@master - with: - name: esm - path: es - - - uses: actions/upload-artifact@master - with: - name: cjs - path: lib - - - uses: actions/upload-artifact@master - with: - name: dist - path: dist - - - uses: actions/upload-artifact@master - with: - name: package - path: package.json - - publish: - runs-on: ubuntu-latest - - steps: - - uses: actions/download-artifact@master - with: - name: esm - - - uses: actions/download-artifact@master - with: - name: cjs - - - uses: actions/download-artifact@master - with: - name: dist - - - uses: actions/download-artifact@master - with: - name: package - - - uses: actions/setup-node@v1 - with: - node-version: '12.x' - registry-url: 'https://npm.pkg.github.com' - - - name: publish - run: npm publish - env: - NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} From b87fc9526a2822923413fbc4688edf6396c9b8c0 Mon Sep 17 00:00:00 2001 From: orzyyyy Date: Tue, 24 Sep 2019 07:04:53 +0800 Subject: [PATCH 07/29] feat(actions): Automatic Rebase --- .github/workflows/rebase.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .github/workflows/rebase.yml diff --git a/.github/workflows/rebase.yml b/.github/workflows/rebase.yml new file mode 100644 index 0000000000..8b1b974364 --- /dev/null +++ b/.github/workflows/rebase.yml @@ -0,0 +1,14 @@ +on: + issue_comment: + types: [created] +name: Automatic Rebase +jobs: + rebase: + name: Rebase + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Automatic Rebase + uses: cirrus-actions/rebase@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From d3e01385b50b459b0d5e8916e50fc8393eaf5c18 Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 24 Sep 2019 12:31:50 +0800 Subject: [PATCH 08/29] :up: upgrade stylelint-config-prettier --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 60ec96d1c9..9f2fc9fa10 100644 --- a/package.json +++ b/package.json @@ -227,7 +227,7 @@ "scrollama": "^2.0.0", "simple-git": "^1.113.0", "stylelint": "^11.0.0", - "stylelint-config-prettier": "^5.2.0", + "stylelint-config-prettier": "^6.0.0", "stylelint-config-rational-order": "^0.1.2", "stylelint-config-standard": "^19.0.0", "stylelint-declaration-block-no-ignored-properties": "^2.1.0", From acbd1a9d28694ceba97b06d3e5304a44d0297b31 Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 24 Sep 2019 14:42:58 +0800 Subject: [PATCH 09/29] :wrench: update typescript definites of third libs --- package.json | 3 +++ typings/custom-typings.d.ts | 24 ++---------------------- 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/package.json b/package.json index 9f2fc9fa10..d766f714f6 100644 --- a/package.json +++ b/package.json @@ -147,9 +147,12 @@ "@sentry/browser": "^5.4.0", "@types/classnames": "^2.2.8", "@types/gtag.js": "^0.0.3", + "@types/lodash": "^4.14.139", "@types/prop-types": "^15.7.1", + "@types/raf": "^3.4.0", "@types/react": "^16.9.0", "@types/react-dom": "^16.8.4", + "@types/shallowequal": "^1.1.1", "@types/warning": "^3.0.0", "@typescript-eslint/eslint-plugin": "^2.0.0", "@typescript-eslint/parser": "^2.0.0", diff --git a/typings/custom-typings.d.ts b/typings/custom-typings.d.ts index c1386acd1f..2c4890a49f 100644 --- a/typings/custom-typings.d.ts +++ b/typings/custom-typings.d.ts @@ -4,7 +4,7 @@ declare module 'rc-calendar*'; declare module 'rc-time-picker*'; -declare module 'rc-pagination*'; +declare module 'rc-pagination/*'; declare module 'omit.js'; @@ -12,16 +12,12 @@ declare module 'rc-animate'; declare module 'rc-util*'; -declare module 'shallowequal'; - declare module 'css-animation*'; declare module 'rc-select'; declare module 'rc-cascader'; -declare module 'array-tree-filter'; - declare module 'rc-checkbox'; declare module 'rc-radio'; @@ -47,7 +43,7 @@ declare module 'rc-calendar'; declare module 'rc-input-number'; -declare module 'rc-pagination'; +declare module 'rc-collapse'; declare module 'rc-notification'; @@ -75,8 +71,6 @@ declare module 'rc-tree-select'; declare module 'rc-upload'; -declare module 'rc-collapse'; - declare module 'rc-form*'; declare module 'react-lazy-load'; @@ -89,20 +83,6 @@ declare module '*.json' { export default value; } -declare module 'lodash/debounce'; - -declare module 'lodash/padStart'; - -declare module 'lodash/padEnd'; - -declare module 'lodash/repeat'; - -declare module 'lodash/uniqBy'; - -declare module 'lodash/findIndex'; - -declare module 'raf'; - declare module 'react-lifecycles-compat'; declare module 'react-copy-to-clipboard'; From 136387fdb70a21ab4476fe6c7f44f3b149f4885e Mon Sep 17 00:00:00 2001 From: Hsuan Lee Date: Tue, 24 Sep 2019 18:07:54 +0800 Subject: [PATCH 10/29] docs: fix API link --- components/page-header/index.zh-CN.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/page-header/index.zh-CN.md b/components/page-header/index.zh-CN.md index 2a8fb59bf8..78b0a6aa3f 100644 --- a/components/page-header/index.zh-CN.md +++ b/components/page-header/index.zh-CN.md @@ -18,7 +18,7 @@ subtitle: 页头 | --- | --- | --- | --- | --- | | title | 自定义标题文字 | ReactNode | - | 3.14.0 | | subTitle | 自定义的二级标题文字 | ReactNode | - | 3.14.0 | -| avatar | 标题栏旁的头像 | [avatar props](/components/avatar-cn/) | - | 3.22.0 | +| avatar | 标题栏旁的头像 | [avatar props](/components/avatar/) | - | 3.22.0 | | backIcon | 自定义 back icon ,如果为 false 不渲染 back icon | ReactNode | `` | 3.14.0 | | tags | title 旁的 tag 列表 | [Tag](https://ant.design/components/tag-cn/)[] \| [Tag](https://ant.design/components/tag-cn/) | - | 3.14.0 | | extra | 操作区,位于 title 行的行尾 | ReactNode | - | 3.14.0 | From c9a30ef766c418ea381aa8bba1d21e25579a8ff0 Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 24 Sep 2019 19:08:51 +0800 Subject: [PATCH 11/29] :memo: Add recommendation for Visualization --- docs/react/recommendation.en-US.md | 2 +- docs/react/recommendation.zh-CN.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/react/recommendation.en-US.md b/docs/react/recommendation.en-US.md index 911476a7f2..fb60373d7e 100644 --- a/docs/react/recommendation.en-US.md +++ b/docs/react/recommendation.en-US.md @@ -7,6 +7,7 @@ title: Third-Party Libraries | Category | Recommended Components | | --- | --- | +| Visualization and charts | [🔥 AntV 数据可视化解决方案](https://antv.alipay.com) [BizCharts](https://github.com/alibaba/BizCharts) [recharts](https://github.com/recharts/recharts/) [viser](https://viserjs.github.io/) | | Router | [react-router](https://github.com/ReactTraining/react-router) | | Layout | [@rebass/grid](https://github.com/rebassjs/grid) [react-blocks](http://whoisandy.github.io/react-blocks/) [react-flexbox-grid](https://github.com/roylee0704/react-flexbox-grid) | | Drag and drop | [react-beautiful-dnd](https://github.com/atlassian/react-beautiful-dnd/) [react-dnd](https://github.com/gaearon/react-dnd) [react-sortable-hoc](https://github.com/clauderic/react-sortable-hoc) | @@ -19,7 +20,6 @@ title: Third-Party Libraries | Document head manager | [react-helmet](https://github.com/nfl/react-helmet) [react-document-title](https://github.com/gaearon/react-document-title) | | Icons | [react-fa](https://github.com/andreypopp/react-fa) [react-icons](https://github.com/gorangajic/react-icons) | | QR Code | [qrcode.react](https://github.com/zpao/qrcode.react) | -| Charts | [BizCharts](https://github.com/alibaba/BizCharts) [recharts](https://github.com/recharts/recharts/) [victory](https://github.com/FormidableLabs/victory) | | Visual Graph Editor | [GGEditor](https://github.com/gaoli/GGEditor) | | Top Progress Bar | [nprogress](https://github.com/rstacruz/nprogress) | | i18n | [react-intl](https://github.com/yahoo/react-intl) | diff --git a/docs/react/recommendation.zh-CN.md b/docs/react/recommendation.zh-CN.md index ba4c06efa4..53c14d134f 100644 --- a/docs/react/recommendation.zh-CN.md +++ b/docs/react/recommendation.zh-CN.md @@ -7,6 +7,7 @@ title: 社区精选组件 | 类型 | 推荐组件 | | --- | --- | +| 可视化图表 | [🔥 AntV 数据可视化解决方案](https://antv.alipay.com) [BizCharts](https://github.com/alibaba/BizCharts) [recharts](https://github.com/recharts/recharts/) [viser](https://viserjs.github.io/) | | 路由 | [react-router](https://github.com/ReactTraining/react-router) | | 布局 | [@rebass/grid](https://github.com/rebassjs/grid) [react-blocks](https://github.com/whoisandy/react-blocks) [react-flexbox-grid](https://github.com/roylee0704/react-flexbox-grid) | | 拖拽 | [react-beautiful-dnd](https://github.com/atlassian/react-beautiful-dnd/) [react-dnd](https://github.com/gaearon/react-dnd) [react-sortable-hoc](https://github.com/clauderic/react-sortable-hoc) | @@ -19,7 +20,6 @@ title: 社区精选组件 | 页面 meta 属性 | [react-helmet](https://github.com/nfl/react-helmet) [react-document-title](https://github.com/gaearon/react-document-title) | | 图标 | [react-fa](https://github.com/andreypopp/react-fa) [react-icons](https://github.com/gorangajic/react-icons) | | 二维码 | [qrcode.react](https://github.com/zpao/qrcode.react) | -| 可视化图表 | [BizCharts](https://github.com/alibaba/BizCharts) [recharts](https://github.com/recharts/recharts/) [victory](https://github.com/FormidableLabs/victory) | | 可视化图编辑器 | [GGEditor](https://github.com/gaoli/GGEditor) | | 顶部进度条 | [nprogress](https://github.com/rstacruz/nprogress) | | 应用国际化 | [react-intl](https://github.com/yahoo/react-intl) | From 2de1a15da977a5c7ce0bffa3b8ba19cea704023d Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 24 Sep 2019 22:37:34 +0800 Subject: [PATCH 12/29] :memo: Add instruction for dropdownRender --- .../select/demo/custom-dropdown-menu.md | 67 +++++++++++++------ components/select/index.en-US.md | 6 ++ components/select/index.zh-CN.md | 6 ++ 3 files changed, 58 insertions(+), 21 deletions(-) diff --git a/components/select/demo/custom-dropdown-menu.md b/components/select/demo/custom-dropdown-menu.md index a39b4071c0..cbd03743a1 100644 --- a/components/select/demo/custom-dropdown-menu.md +++ b/components/select/demo/custom-dropdown-menu.md @@ -7,34 +7,59 @@ title: ## zh-CN -使用 `dropdownRender` 对下拉菜单进行自由扩展。 +使用 `dropdownRender` 对下拉菜单进行自由扩展。自定义内容点击时会关闭浮层,如果不喜欢关闭,可以添加 `onMouseDown={e => e.preventDefault()}` 进行阻止(更多详情见 [#13448](https://github.com/ant-design/ant-design/issues/13448))。 ## en-US -Customize the dropdown menu via `dropdownRender`. +Customize the dropdown menu via `dropdownRender`. The selection will be closed if click `dropdownRender` area, you can prevent it by wrapping `onMouseDown={e => e.preventDefault()}` (see more at [#13448](https://github.com/ant-design/ant-design/issues/13448)). ```jsx import { Select, Icon, Divider } from 'antd'; const { Option } = Select; -ReactDOM.render( - , - mountNode, -); +let index = 0; + +class App extends React.Component { + state = { + items: ['jack', 'lucy'], + }; + + addItem = () => { + console.log('addItem'); + const { items } = this.state; + this.setState({ + items: [...items, `New item ${index++}`], + }); + }; + + render() { + const { items } = this.state; + return ( + + ); + } +} + +ReactDOM.render(, mountNode); ``` diff --git a/components/select/index.en-US.md b/components/select/index.en-US.md index 9150382372..3392595de6 100644 --- a/components/select/index.en-US.md +++ b/components/select/index.en-US.md @@ -94,3 +94,9 @@ Select component to select value from options. | -------- | ----------- | --------------------- | ------- | ------- | | key | | string | - | | | label | Group label | string\|React.Element | - | | + +## FAQ + +### The dropdown is closed when click `dropdownRender` area? + +See the [dropdownRender example](/components/select/#components-select-demo-custom-dropdown-menu). diff --git a/components/select/index.zh-CN.md b/components/select/index.zh-CN.md index 16b8532517..3d32e38ee8 100644 --- a/components/select/index.zh-CN.md +++ b/components/select/index.zh-CN.md @@ -97,3 +97,9 @@ title: Select | ----- | ---- | --------------------- | ------ | ---- | | key | | string | - | | | label | 组名 | string\|React.Element | 无 | | + +## FAQ + +### 点击 `dropdownRender` 里的内容浮层关闭怎么办? + +看下 [dropdownRender 例子](/components/select-cn/#components-select-demo-custom-dropdown-menu) 里的说明。 From d3b8bfa5116c321f387533cc27a8c6d4f96eb111 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 25 Sep 2019 10:46:59 +0800 Subject: [PATCH 13/29] :white_check_mark: react-router@5.1 cannot work in React 15 https://github.com/ReactTraining/react-router/releases/tag/v5.1.0 --- .../breadcrumb/__tests__/router.test.js | 63 +++++++++---------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/components/breadcrumb/__tests__/router.test.js b/components/breadcrumb/__tests__/router.test.js index efacfa5892..7ccd0e1728 100644 --- a/components/breadcrumb/__tests__/router.test.js +++ b/components/breadcrumb/__tests__/router.test.js @@ -22,37 +22,6 @@ const breadcrumbNameMap = { '/apps/2/detail': 'Detail', }; -const Home = withRouter(props => { - const { location, history } = props; - const pathSnippets = location.pathname.split('/').filter(i => i); - const extraBreadcrumbItems = pathSnippets.map((_, index) => { - const url = `/${pathSnippets.slice(0, index + 1).join('/')}`; - return ( - - {breadcrumbNameMap[url]} - - ); - }); - const breadcrumbItems = [ - - Home - , - ].concat(extraBreadcrumbItems); - return ( -
- - - - Home Page} /> - - {breadcrumbItems} -
- ); -}); - describe('react router', () => { beforeAll(() => { jest.useFakeTimers(); @@ -62,7 +31,37 @@ describe('react router', () => { jest.useRealTimers(); }); // https://github.com/airbnb/enzyme/issues/875 - it('react router 4', () => { + (process.env.REACT === '15' ? it.skip : it)('react router 4', () => { + const Home = withRouter(props => { + const { location, history } = props; + const pathSnippets = location.pathname.split('/').filter(i => i); + const extraBreadcrumbItems = pathSnippets.map((_, index) => { + const url = `/${pathSnippets.slice(0, index + 1).join('/')}`; + return ( + + {breadcrumbNameMap[url]} + + ); + }); + const breadcrumbItems = [ + + Home + , + ].concat(extraBreadcrumbItems); + return ( +
+ + + + Home Page} /> + + {breadcrumbItems} +
+ ); + }); const wrapper = mount( From 6d7a87e7e065ff30be208978e09259e098676f7d Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 25 Sep 2019 11:16:10 +0800 Subject: [PATCH 14/29] :white_check_mark: update select test snapshot --- .../select/__tests__/__snapshots__/demo.test.js.snap | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/select/__tests__/__snapshots__/demo.test.js.snap b/components/select/__tests__/__snapshots__/demo.test.js.snap index 2659fb7edc..77bd74d00d 100644 --- a/components/select/__tests__/__snapshots__/demo.test.js.snap +++ b/components/select/__tests__/__snapshots__/demo.test.js.snap @@ -315,7 +315,7 @@ exports[`renders ./components/select/demo/coordinate.md correctly 1`] = ` exports[`renders ./components/select/demo/custom-dropdown-menu.md correctly 1`] = `
- Lucy + custom dropdown render
Date: Tue, 24 Sep 2019 22:33:35 -0500 Subject: [PATCH 15/29] chore: Put origin img size to fill the box (#18990) --- components/upload/style/index.less | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/upload/style/index.less b/components/upload/style/index.less index 3282783359..afde460e03 100644 --- a/components/upload/style/index.less +++ b/components/upload/style/index.less @@ -161,6 +161,8 @@ > span { display: block; + width: 100%; + height: 100%; } .@{iconfont-css-prefix}-loading, @@ -378,6 +380,7 @@ display: block; width: 100%; height: 100%; + object-fit: cover; } .@{upload-item}-name { From 913c5bbc4701c5235197fa0f435cb6c6fa5cd831 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 25 Sep 2019 14:10:22 +0800 Subject: [PATCH 16/29] :bug: Fix Button.Group large="size" icon only style close #18993 --- components/button/style/mixin.less | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/components/button/style/mixin.less b/components/button/style/mixin.less index 6e34f138f0..9fa89d6236 100644 --- a/components/button/style/mixin.less +++ b/components/button/style/mixin.less @@ -130,6 +130,11 @@ .button-size(@btn-height-lg; @btn-padding-lg; @btn-font-size-lg; 0); line-height: @btn-height-lg - 2px; } + &-lg > .@{btnClassName}.@{btnClassName}-icon-only { + .square(@btn-height-lg); + padding-right: 0; + padding-left: 0; + } &-sm > .@{btnClassName}, &-sm > span > .@{btnClassName} { .button-size(@btn-height-sm; @btn-padding-sm; @font-size-base; 0); @@ -138,6 +143,11 @@ font-size: @font-size-base; } } + &-sm > .@{btnClassName}.@{btnClassName}-icon-only { + .square(@btn-height-sm); + padding-right: 0; + padding-left: 0; + } } // Base styles of buttons // -------------------------------------------------- From 7961bb335c8d46fc8fa86ff8f7a8993432a6e9df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=81=8F=E5=8F=B3?= Date: Wed, 25 Sep 2019 18:03:41 +0800 Subject: [PATCH 17/29] =?UTF-8?q?=F0=9F=97=91=20Remove=20useless=20prop=20?= =?UTF-8?q?`searchValue`=20(#19003)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit from typescript and documentation close #18847 --- components/select/__tests__/index.test.js | 13 ------------- components/select/index.en-US.md | 1 - components/select/index.tsx | 12 ------------ components/select/index.zh-CN.md | 1 - 4 files changed, 27 deletions(-) diff --git a/components/select/__tests__/index.test.js b/components/select/__tests__/index.test.js index 19e2055b60..165eac9d83 100644 --- a/components/select/__tests__/index.test.js +++ b/components/select/__tests__/index.test.js @@ -4,7 +4,6 @@ import Select from '..'; import Icon from '../../icon'; import focusTest from '../../../tests/shared/focusTest'; import mountTest from '../../../tests/shared/mountTest'; -import { resetWarned } from '../../_util/warning'; const { Option } = Select; @@ -133,16 +132,4 @@ describe('Select', () => { expect(wrapper.render()).toMatchSnapshot(); }); }); - - it('warning if user use `inputValue`', () => { - resetWarned(); - const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); - - mount( + + + + + + + + 1 + + item + + + +
+
+ + [Function] + + } + onItemSelect={[Function]} + onItemSelectAll={[Function]} + onScroll={[Function]} + prefixCls="ant-transfer-list" + render={[Function]} + searchPlaceholder="Search here" + selectedKeys={Array []} + showSearch={false} + titleText="" + titles={ + Array [ + "", + "", + ] + } + > + +
    + + + +
    + + + +
+
+
+
+ + + +
+ + + + + + +
+
+ + [Function] + + } + onItemSelect={[Function]} + onItemSelectAll={[Function]} + onScroll={[Function]} + prefixCls="ant-transfer-list" + render={[Function]} + searchPlaceholder="Search here" + showSearch={false} + titleText="" + titles={ + Array [ + "", + "", + ] + } + > +
+
+ + + + + + 0 + + item + + + +
+
+
+ } + > + +
+
+ + + + + + + + + + + +
+

+ No Data +

+
+
+
+
+
+
+
+ + + +`; diff --git a/components/transfer/__tests__/index.test.js b/components/transfer/__tests__/index.test.js index 73fa4a3130..0aeb83e1e4 100644 --- a/components/transfer/__tests__/index.test.js +++ b/components/transfer/__tests__/index.test.js @@ -113,6 +113,24 @@ describe('Transfer', () => { expect(handleChange).toHaveBeenCalledWith(['a', 'b'], 'right', ['a']); }); + it('should move selected keys to left list', () => { + const handleChange = jest.fn(); + const wrapper = mount( + + ); + wrapper + .find(TransferOperation) + .find(Button) + .at(1) + .simulate('click'); // move selected keys to left list + expect(handleChange).toHaveBeenCalledWith([], 'left', ['a']); + }); + it('should move selected keys expect disabled to corresponding list', () => { const handleChange = jest.fn(); const wrapper = mount(); @@ -450,4 +468,44 @@ describe('Transfer', () => { expect(listTarget.prop('style')).toHaveProperty('backgroundColor', 'blue'); expect(operation.prop('style')).toHaveProperty('backgroundColor', 'yellow'); }); + + it('should support onScroll', () => { + const onScroll = jest.fn(); + const component = mount( + , + ); + component.find('.ant-transfer-list').at(0).find('.ant-transfer-list-content').at(0).simulate('scroll'); + expect(onScroll).toHaveBeenLastCalledWith('left', expect.anything()); + component.find('.ant-transfer-list').at(1).find('.ant-transfer-list-content').at(0).simulate('scroll'); + expect(onScroll).toHaveBeenLastCalledWith('right', expect.anything()); + }); + + it('should support rowKey is function', () => { + expect(() => { + mount( + record.key} + />, + ); + }).not.toThrow(); + }); + + it('should support render value and label in item', () => { + const component = mount( + ({ value: `${record.title} value`, label: 'label' })} + />, + ); + expect(component).toMatchSnapshot(); + }); }); diff --git a/components/transfer/__tests__/search.test.js b/components/transfer/__tests__/search.test.js index 8c31668c5c..73c93d3d32 100644 --- a/components/transfer/__tests__/search.test.js +++ b/components/transfer/__tests__/search.test.js @@ -25,6 +25,7 @@ describe('Transfer.Search', () => { }); it('onSearch', () => { + jest.useFakeTimers(); const dataSource = [ { key: 'a', @@ -59,6 +60,7 @@ describe('Transfer.Search', () => { .find('.ant-input') .at(0) .simulate('change', { target: { value: 'a' } }); + jest.runAllTimers(); expect(onSearch).toHaveBeenCalledWith('left', 'a'); onSearch.mockReset(); @@ -68,9 +70,11 @@ describe('Transfer.Search', () => { .at(0) .simulate('click'); expect(onSearch).toHaveBeenCalledWith('left', ''); + jest.useRealTimers(); }); it('legacy onSearchChange', () => { + jest.useFakeTimers(); const onSearchChange = jest.fn(); const wrapper = mount( @@ -81,11 +85,13 @@ describe('Transfer.Search', () => { .find('.ant-input') .at(0) .simulate('change', { target: { value: 'a' } }); + jest.runAllTimers(); expect(errorSpy.mock.calls[0][0]).toMatch( 'Warning: [antd: Transfer] `onSearchChange` is deprecated. Please use `onSearch` instead.', ); expect(onSearchChange.mock.calls[0][0]).toEqual('left'); expect(onSearchChange.mock.calls[0][1].target.value).toEqual('a'); + jest.useRealTimers(); }); }); From e9b0c29f559e6e435f1b89c54addd9caf03482b1 Mon Sep 17 00:00:00 2001 From: fkysly Date: Thu, 26 Sep 2019 13:44:43 +0800 Subject: [PATCH 21/29] Rename algin.md to align.md --- components/input/demo/{algin.md => align.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename components/input/demo/{algin.md => align.md} (100%) diff --git a/components/input/demo/algin.md b/components/input/demo/align.md similarity index 100% rename from components/input/demo/algin.md rename to components/input/demo/align.md From 46d0ff3e00bebe1b91ea640bbcc3035be1e759db Mon Sep 17 00:00:00 2001 From: afc163 Date: Thu, 26 Sep 2019 14:03:17 +0800 Subject: [PATCH 22/29] :white_check_mark: update snapshot --- components/input/__tests__/__snapshots__/demo.test.js.snap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/input/__tests__/__snapshots__/demo.test.js.snap b/components/input/__tests__/__snapshots__/demo.test.js.snap index 8fbb408082..e0e18c531e 100644 --- a/components/input/__tests__/__snapshots__/demo.test.js.snap +++ b/components/input/__tests__/__snapshots__/demo.test.js.snap @@ -201,7 +201,7 @@ exports[`renders ./components/input/demo/addon.md correctly 1`] = ` `; -exports[`renders ./components/input/demo/algin.md correctly 1`] = ` +exports[`renders ./components/input/demo/align.md correctly 1`] = `
Date: Thu, 26 Sep 2019 22:07:34 +0800 Subject: [PATCH 23/29] =?UTF-8?q?Input.tsx=E7=9A=84otherProps=E4=B8=BA?= =?UTF-8?q?=E4=BB=80=E4=B9=88=E4=B8=8D=E5=8E=BB=E6=8E=89size?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 我觉得你们的otherProps推导竟然是any,所以不写size没报错 --- components/input/Input.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/components/input/Input.tsx b/components/input/Input.tsx index f92060c01b..7823ca97fb 100644 --- a/components/input/Input.tsx +++ b/components/input/Input.tsx @@ -290,6 +290,7 @@ class Input extends React.Component { // Input elements must be either controlled or uncontrolled, // specify either the value prop, or the defaultValue prop, but not both. 'defaultValue', + 'size', ]); return this.renderLabeledIcon( From 7ae663da6df38aa9dcc3d9440945f843145dd954 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: Fri, 27 Sep 2019 01:17:42 -0500 Subject: [PATCH 24/29] fix: ssr should not render string at first (#19029) * fix: ssr should not render string at first * update snapshot --- .../avatar/__tests__/__snapshots__/demo.test.js.snap | 6 ++++++ components/avatar/index.tsx | 12 +++++++++++- .../__tests__/__snapshots__/components.test.js.snap | 3 +++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/components/avatar/__tests__/__snapshots__/demo.test.js.snap b/components/avatar/__tests__/__snapshots__/demo.test.js.snap index 1b650ba917..bcbedba0e2 100644 --- a/components/avatar/__tests__/__snapshots__/demo.test.js.snap +++ b/components/avatar/__tests__/__snapshots__/demo.test.js.snap @@ -433,6 +433,7 @@ exports[`renders ./components/avatar/demo/dynamic.md correctly 1`] = ` > U @@ -486,6 +487,7 @@ exports[`renders ./components/avatar/demo/toggle-debug.md correctly 1`] = ` > Avatar @@ -507,6 +509,7 @@ exports[`renders ./components/avatar/demo/toggle-debug.md correctly 1`] = ` > Avatar @@ -554,6 +557,7 @@ exports[`renders ./components/avatar/demo/type.md correctly 1`] = ` > U @@ -563,6 +567,7 @@ exports[`renders ./components/avatar/demo/type.md correctly 1`] = ` > USER @@ -580,6 +585,7 @@ exports[`renders ./components/avatar/demo/type.md correctly 1`] = ` > U diff --git a/components/avatar/index.tsx b/components/avatar/index.tsx index f3d0536cbe..36829690e9 100644 --- a/components/avatar/index.tsx +++ b/components/avatar/index.tsx @@ -29,6 +29,7 @@ export interface AvatarProps { export interface AvatarState { scale: number; + mounted: boolean; isImgExist: boolean; } @@ -40,6 +41,7 @@ export default class Avatar extends React.Component { state = { scale: 1, + mounted: false, isImgExist: true, }; @@ -53,6 +55,7 @@ export default class Avatar extends React.Component { componentDidMount() { this.setScale(); + this.setState({ mounted: true }); } componentDidUpdate(prevProps: AvatarProps) { @@ -105,7 +108,7 @@ export default class Avatar extends React.Component { ...others } = this.props; - const { isImgExist, scale } = this.state; + const { isImgExist, scale, mounted } = this.state; const prefixCls = getPrefixCls('avatar', customizePrefixCls); @@ -144,6 +147,7 @@ export default class Avatar extends React.Component { WebkitTransform: transformString, transform: transformString, }; + const sizeChildrenStyle: React.CSSProperties = typeof size === 'number' ? { @@ -160,9 +164,15 @@ export default class Avatar extends React.Component { ); } else { + const childrenStyle: React.CSSProperties = {}; + if (!mounted) { + childrenStyle.opacity = 0; + } + children = ( (this.avatarChildren = node)} > {children} diff --git a/components/config-provider/__tests__/__snapshots__/components.test.js.snap b/components/config-provider/__tests__/__snapshots__/components.test.js.snap index b159a27c42..0799794609 100644 --- a/components/config-provider/__tests__/__snapshots__/components.test.js.snap +++ b/components/config-provider/__tests__/__snapshots__/components.test.js.snap @@ -360,6 +360,7 @@ exports[`ConfigProvider components Avatar configProvider 1`] = ` > `; @@ -370,6 +371,7 @@ exports[`ConfigProvider components Avatar normal 1`] = ` > `; @@ -380,6 +382,7 @@ exports[`ConfigProvider components Avatar prefixCls 1`] = ` > `; From 49ecf9b738a1562e114439f369ab0c1882a66211 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 27 Sep 2019 14:41:55 +0800 Subject: [PATCH 25/29] :white_check_mark: add more test cases for DatePicker --- components/date-picker/WeekPicker.tsx | 2 +- .../date-picker/__tests__/WeekPicker.test.js | 13 +++++ .../date-picker/__tests__/invalid.test.js | 52 +++++++++++++++++++ 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 components/date-picker/__tests__/invalid.test.js diff --git a/components/date-picker/WeekPicker.tsx b/components/date-picker/WeekPicker.tsx index 035e22fa4b..92c20dd2d8 100644 --- a/components/date-picker/WeekPicker.tsx +++ b/components/date-picker/WeekPicker.tsx @@ -47,7 +47,7 @@ class WeekPicker extends React.Component { const value = props.value || props.defaultValue; if (value && !interopDefault(moment).isMoment(value)) { throw new Error( - 'The value/defaultValue of DatePicker or MonthPicker must be ' + + 'The value/defaultValue of WeekPicker must be ' + 'a moment object after `antd@2.0`, see: https://u.ant.design/date-picker-value', ); } diff --git a/components/date-picker/__tests__/WeekPicker.test.js b/components/date-picker/__tests__/WeekPicker.test.js index 951e5bfe2f..7d08d99425 100644 --- a/components/date-picker/__tests__/WeekPicker.test.js +++ b/components/date-picker/__tests__/WeekPicker.test.js @@ -1,5 +1,6 @@ import React from 'react'; import { mount, render } from 'enzyme'; +import moment from 'moment'; import { setMockDate, resetMockDate } from '../../../tests/utils'; import DatePicker from '..'; import focusTest from '../../../tests/shared/focusTest'; @@ -71,4 +72,16 @@ describe('WeekPicker', () => { ), ).toMatchSnapshot(); }); + + it('should support allowClear', () => { + const onChange = jest.fn(); + const wrapper = mount( + , + ); + wrapper + .find('.ant-calendar-picker-clear') + .hostNodes() + .simulate('click'); + expect(onChange).toHaveBeenCalledWith(null, ''); + }); }); diff --git a/components/date-picker/__tests__/invalid.test.js b/components/date-picker/__tests__/invalid.test.js new file mode 100644 index 0000000000..ff8ff6d6c5 --- /dev/null +++ b/components/date-picker/__tests__/invalid.test.js @@ -0,0 +1,52 @@ +import React from 'react'; +import { mount } from 'enzyme'; +import DatePicker from '..'; + +const { MonthPicker, WeekPicker, RangePicker } = DatePicker; + +describe('invalid value or defaultValue', () => { + beforeAll(() => { + jest.spyOn(console, 'error').mockImplementation(() => undefined); + }); + + afterAll(() => { + // eslint-disable-next-line no-console + console.error.mockRestore(); + }); + + it('DatePicker should throw error when value or defaultValue is not moment object', () => { + expect(() => { + mount(); + }).toThrow('The value/defaultValue of DatePicker or MonthPicker must be a moment object after `antd@2.0`, see: https://u.ant.design/date-picker-value'); + expect(() => { + mount(); + }).toThrow('The value/defaultValue of DatePicker or MonthPicker must be a moment object after `antd@2.0`, see: https://u.ant.design/date-picker-value') + }); + + it('WeekPicker should throw error when value or defaultValue is not moment object', () => { + expect(() => { + mount(); + }).toThrow('The value/defaultValue of WeekPicker must be a moment object after `antd@2.0`, see: https://u.ant.design/date-picker-value'); + expect(() => { + mount(); + }).toThrow('The value/defaultValue of WeekPicker must be a moment object after `antd@2.0`, see: https://u.ant.design/date-picker-value'); + }); + + it('RangePicker should throw error when value or defaultValue is not moment object', () => { + expect(() => { + mount(); + }).toThrow('The value/defaultValue of RangePicker must be a moment object array after `antd@2.0`, see: https://u.ant.design/date-picker-value'); + expect(() => { + mount(); + }).toThrow('The value/defaultValue of RangePicker must be a moment object array after `antd@2.0`, see: https://u.ant.design/date-picker-value') + }); + + it('MonthPicker should throw error when value or defaultValue is not moment object', () => { + expect(() => { + mount(); + }).toThrow('The value/defaultValue of DatePicker or MonthPicker must be a moment object after `antd@2.0`, see: https://u.ant.design/date-picker-value'); + expect(() => { + mount(); + }).toThrow('The value/defaultValue of DatePicker or MonthPicker must be a moment object after `antd@2.0`, see: https://u.ant.design/date-picker-value') + }); +}); From b536643f761ce3856fe54e8481fdefd26e41e3e7 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 27 Sep 2019 23:24:02 +0800 Subject: [PATCH 26/29] :white_check_mark: add test case for Collapse --- components/collapse/__tests__/index.test.js | 34 ++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/components/collapse/__tests__/index.test.js b/components/collapse/__tests__/index.test.js index 41ab35b98f..35a065e9f8 100644 --- a/components/collapse/__tests__/index.test.js +++ b/components/collapse/__tests__/index.test.js @@ -1,9 +1,21 @@ import React from 'react'; import { mount } from 'enzyme'; -import Collapse from '..'; import mountTest from '../../../tests/shared/mountTest'; describe('Collapse', () => { + // Fix css-animation deps on these + // https://github.com/yiminghe/css-animation/blob/a5986d73fd7dfce75665337f39b91483d63a4c8c/src/Event.js#L44 + window.AnimationEvent = window.AnimationEvent || (() => {}); + window.TransitionEvent = window.TransitionEvent || (() => {}); + + afterAll(() => { + // restore it + delete window.AnimationEvent; + delete window.TransitionEvent; + }); + + // eslint-disable-next-line global-require + const Collapse = require('..').default; mountTest(Collapse); it('should support remove expandIcon', () => { @@ -24,4 +36,24 @@ describe('Collapse', () => { ); expect(wrapper.render()).toMatchSnapshot(); }); + + it('could be expand and collapse', () => { + jest.useFakeTimers(); + const wrapper = mount( + + + content + + , + ); + expect(wrapper.find('.ant-collapse-item').hasClass('ant-collapse-item-active')).toBe(false); + wrapper + .find('.ant-collapse-header') + .at(0) + .simulate('click'); + expect(wrapper.find('.ant-collapse-item').hasClass('ant-collapse-item-active')).toBe(true); + jest.runAllTimers(); + expect(wrapper.find('.ant-collapse-item').hasClass('ant-collapse-item-active')).toBe(true); + jest.useRealTimers(); + }); }); From 049799ed0f443eef2dec48aea085740f486b35bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BB=AF=E4=B8=80?= Date: Sat, 28 Sep 2019 10:20:47 +0800 Subject: [PATCH 27/29] fix: detect antd button by children.type.[staticProperty] instead of same class for HOC case (#19042) --- components/input/Search.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/input/Search.tsx b/components/input/Search.tsx index 1802248687..9ec2d2b1b3 100644 --- a/components/input/Search.tsx +++ b/components/input/Search.tsx @@ -92,7 +92,10 @@ export default class Search extends React.Component { let button: React.ReactNode; const enterButtonAsElement = enterButton as React.ReactElement; - if (enterButtonAsElement.type === Button || enterButtonAsElement.type === 'button') { + const isAntdButton = + enterButtonAsElement.type && + (enterButtonAsElement.type as typeof Button).__ANT_BUTTON === true; + if (isAntdButton || enterButtonAsElement.type === 'button') { button = React.cloneElement(enterButtonAsElement, { onClick: this.onSearch, key: 'enterButton', From 5728763dcc17dfbb23e512128f40fe1e89651655 Mon Sep 17 00:00:00 2001 From: shaodahong Date: Sat, 28 Sep 2019 11:58:09 +0800 Subject: [PATCH 28/29] fix: IE11 syntax error --- site/bisheng.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/site/bisheng.config.js b/site/bisheng.config.js index ae06141ab0..22d00bcf93 100644 --- a/site/bisheng.config.js +++ b/site/bisheng.config.js @@ -100,6 +100,7 @@ module.exports = { antd: path.join(process.cwd(), 'index'), site: path.join(process.cwd(), 'site'), 'react-router': 'react-router/umd/ReactRouter', + 'react-intl': 'react-intl/dist', }; // eslint-disable-next-line From 8219438ecde3c123d5ef58cbcd6a27983dabb458 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BB=AF=E4=B8=80?= Date: Sat, 28 Sep 2019 13:52:59 +0800 Subject: [PATCH 29/29] Fix/detect antd button by static (#19045) * fix: detect antd button by children.type.[staticProperty] instead of same class for HOC case * fix: chore --- components/input/Search.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/input/Search.tsx b/components/input/Search.tsx index 9ec2d2b1b3..5e41606b87 100644 --- a/components/input/Search.tsx +++ b/components/input/Search.tsx @@ -99,7 +99,7 @@ export default class Search extends React.Component { button = React.cloneElement(enterButtonAsElement, { onClick: this.onSearch, key: 'enterButton', - ...(enterButtonAsElement.type === Button + ...(isAntdButton ? { className: btnClassName, size,