From a1298463be3abc12b765be95b8216cc4b3bc89f6 Mon Sep 17 00:00:00 2001 From: jiang Date: Thu, 4 Jul 2019 20:53:55 +0800 Subject: [PATCH 01/16] rm drawer config consumer props (#17390) * rm drawer config consumer props * Update index.tsx --- components/drawer/index.tsx | 8 ++++++++ components/drawer/style/index.tsx | 1 + 2 files changed, 9 insertions(+) diff --git a/components/drawer/index.tsx b/components/drawer/index.tsx index 4d4869219f..e7ef9bc1c6 100644 --- a/components/drawer/index.tsx +++ b/components/drawer/index.tsx @@ -219,6 +219,14 @@ class Drawer extends React.Component Date: Thu, 4 Jul 2019 23:36:32 +0800 Subject: [PATCH 02/16] :lipstick: change another arrow style --- components/date-picker/style/Calendar.less | 81 +++++++++++++++---- components/date-picker/style/RangePicker.less | 3 +- 2 files changed, 66 insertions(+), 18 deletions(-) diff --git a/components/date-picker/style/Calendar.less b/components/date-picker/style/Calendar.less index 95eb1601aa..e9fc0477fa 100644 --- a/components/date-picker/style/Calendar.less +++ b/components/date-picker/style/Calendar.less @@ -1,3 +1,64 @@ +.calendarLeftArrow() { + height: 100%; + + &::before, + &::after { + position: relative; + top: -1px; + display: inline-block; + width: 8px; + height: 8px; + vertical-align: middle; + border: 0 solid #aaa; + border-width: 1.5px 0 0 1.5px; + border-radius: 1px; + transform: rotate(-45deg) scale(.8); + transition: all .3s; + content: ''; + } + + &:hover::before, + &:hover::after { + border-color: @text-color; + } + + &::after { + display: none; + } +} + +.calendarLeftDoubleArrow() { + .calendarLeftArrow; + + &::after { + position: relative; + left: -3px; + display: inline-block; + } +} + +.calendarRightArrow() { + .calendarLeftArrow; + + &::before, + &::after { + transform: rotate(135deg) scale(.8); + } +} + +.calendarRightDoubleArrow() { + .calendarRightArrow; + + &::before { + position: relative; + left: 3px; + } + + &::after { + display: inline-block; + } +} + .calendarPanelHeader(@calendar-prefix-cls) { height: 40px; line-height: 40px; @@ -49,36 +110,24 @@ .@{calendar-prefix-cls}-prev-decade-btn, .@{calendar-prefix-cls}-prev-year-btn { left: 7px; - - &::after { - content: '«'; - } + .calendarLeftDoubleArrow; } .@{calendar-prefix-cls}-next-century-btn, .@{calendar-prefix-cls}-next-decade-btn, .@{calendar-prefix-cls}-next-year-btn { right: 7px; - - &::after { - content: '»'; - } + .calendarRightDoubleArrow; } .@{calendar-prefix-cls}-prev-month-btn { left: 29px; - - &::after { - content: '‹'; - } + .calendarLeftArrow; } .@{calendar-prefix-cls}-next-month-btn { right: 29px; - - &::after { - content: '›'; - } + .calendarRightArrow; } } diff --git a/components/date-picker/style/RangePicker.less b/components/date-picker/style/RangePicker.less index df1a156f30..0421f55570 100644 --- a/components/date-picker/style/RangePicker.less +++ b/components/date-picker/style/RangePicker.less @@ -96,11 +96,10 @@ .@{calendar-prefix-cls}-input, .@{calendar-timepicker-prefix-cls}-input { .input; - height: @input-height-sm; - line-height: @input-height-sm; padding-right: 0; padding-left: 0; + line-height: @input-height-sm; border: 0; box-shadow: none; From a517a9e01b3f0f0ad7020a78ec7bfe69b4c1ee46 Mon Sep 17 00:00:00 2001 From: zombieJ Date: Fri, 5 Jul 2019 14:27:57 +0800 Subject: [PATCH 03/16] chore: Lock @babel/plugin-transform-typescript version (#17486) * lock @babel/plugin-transform-typescript * pined 7.4.x --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index e74c266935..3b648bd933 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "@ant-design/create-react-context": "^0.2.4", "@ant-design/icons": "~2.1.1", "@ant-design/icons-react": "~2.0.1", + "@babel/plugin-transform-typescript": "~7.4.5", "@types/react-slick": "^0.23.4", "array-tree-filter": "^2.1.0", "babel-runtime": "6.x", From c484fdf0e968dcc08d9374200633a72436040a60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=81=8F=E5=8F=B3?= Date: Sat, 6 Jul 2019 22:14:01 +0800 Subject: [PATCH 04/16] :zap: Remove @babel/plugin-transform-typescript dep https://github.com/babel/babel/pull/10167 --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 3b648bd933..e74c266935 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,6 @@ "@ant-design/create-react-context": "^0.2.4", "@ant-design/icons": "~2.1.1", "@ant-design/icons-react": "~2.0.1", - "@babel/plugin-transform-typescript": "~7.4.5", "@types/react-slick": "^0.23.4", "array-tree-filter": "^2.1.0", "babel-runtime": "6.x", From 6b7ad105c6bf059ad1e713d49b0038b0e483db07 Mon Sep 17 00:00:00 2001 From: DiamondYuan Date: Sat, 6 Jul 2019 22:16:17 +0800 Subject: [PATCH 05/16] fix: fix type of SwitchProps --- components/switch/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/switch/index.tsx b/components/switch/index.tsx index 5a833fbb0b..23ef111f4a 100755 --- a/components/switch/index.tsx +++ b/components/switch/index.tsx @@ -18,7 +18,7 @@ export interface SwitchProps { checked?: boolean; defaultChecked?: boolean; onChange?: SwitchChangeEventHandler; - onClick?: SwitchChangeEventHandler; + onClick?: SwitchClickEventHandler; checkedChildren?: React.ReactNode; unCheckedChildren?: React.ReactNode; disabled?: boolean; From 0f6b8c80598b9e34d64944cd59b6515d2fce9877 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=81=8F=E5=8F=B3?= Date: Sat, 6 Jul 2019 22:25:21 +0800 Subject: [PATCH 06/16] :up: upgrade react-dnd --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e74c266935..3ba86519f6 100644 --- a/package.json +++ b/package.json @@ -159,8 +159,8 @@ "react": "^16.5.2", "react-color": "^2.17.3", "react-copy-to-clipboard": "^5.0.1", - "react-dnd": "^8.0.0", - "react-dnd-html5-backend": "^8.0.0", + "react-dnd": "^9.0.0", + "react-dnd-html5-backend": "^9.0.0", "react-document-title": "^2.0.3", "react-dom": "^16.5.2", "react-github-button": "^0.1.11", From e9b370d0c042104974e2432d7ced991e2d8f12d2 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 6 Jul 2019 23:40:03 +0800 Subject: [PATCH 07/16] :memo: Add documentation for LocaleProvider and List close #17399 --- components/list/index.en-US.md | 2 ++ components/list/index.zh-CN.md | 2 ++ components/locale-provider/index.en-US.md | 6 ++++++ components/locale-provider/index.zh-CN.md | 6 ++++++ 4 files changed, 16 insertions(+) diff --git a/components/list/index.en-US.md b/components/list/index.en-US.md index 3e52de9293..55bf3364dd 100644 --- a/components/list/index.en-US.md +++ b/components/list/index.en-US.md @@ -28,6 +28,8 @@ A list can be used to display content related to a single subject. The content c | locale | i18n text including empty text | object | emptyText: 'No Data'
| | pagination | Pagination [config](https://ant.design/components/pagination/), hide it by setting it to false | boolean \| object | false | | split | Toggles rendering of the split under the list item | boolean | true | +| dataSource | dataSource array for list | any[] | - | +| renderItem | customize list item when using `dataSource` | `item => ReactNode` | - | ### pagination diff --git a/components/list/index.zh-CN.md b/components/list/index.zh-CN.md index 5179f9137f..569cbf059e 100644 --- a/components/list/index.zh-CN.md +++ b/components/list/index.zh-CN.md @@ -29,6 +29,8 @@ cols: 1 | pagination | 对应的 `pagination` 配置, 设置 `false` 不显示 | boolean\|object | false | | size | list 的尺寸 | `default` \| `middle` \| `small` | `default` | | split | 是否展示分割线 | boolean | true | +| dataSource | 列表数据源 | any[] | - | +| renderItem | 当使用 dataSource 时,可以用 `renderItem` 自定义渲染列表项 | `item => ReactNode` | - | ### pagination diff --git a/components/locale-provider/index.en-US.md b/components/locale-provider/index.en-US.md index ec3f1b13af..4bda2c3db3 100644 --- a/components/locale-provider/index.en-US.md +++ b/components/locale-provider/index.en-US.md @@ -48,3 +48,9 @@ This component aims to provide localization of the built-in text. If you want to | Property | Description | Type | Default | | --- | --- | --- | --- | | locale | language package setting, you can find the packages in [antd/lib/locale-provider](http://unpkg.com/antd/lib/locale-provider/) | object | - | + +## FAQ + +#### Locale problem is still existed even LocaleProvider is used? + +Please make sure you set moment locale by `moment.locale('zh-cn')`, or you don't have two moment of different version. diff --git a/components/locale-provider/index.zh-CN.md b/components/locale-provider/index.zh-CN.md index 87ef692b95..d4d0471370 100644 --- a/components/locale-provider/index.zh-CN.md +++ b/components/locale-provider/index.zh-CN.md @@ -49,3 +49,9 @@ return ; | 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | | locale | 语言包配置,语言包可到 [antd/lib/locale-provider](http://unpkg.com/antd/lib/locale-provider/) 目录下寻找 | object | - | + +## FAQ + +#### 为什么我使用了 LocaleProvider 还有问题? + +请检查是否设置了 `moment.locale('zh-cn')`,或者是否有两个版本的 moment 共存。 From 4d1fe600938feb362405d2e5b27499ad9a256f21 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 7 Jul 2019 11:11:41 +0800 Subject: [PATCH 08/16] lock @babel/plugin-transform-typescript again 7.5.1 still has bug https://github.com/babel/babel/issues/10156#issuecomment-508924725 --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 3ba86519f6..0fe1644c9a 100644 --- a/package.json +++ b/package.json @@ -97,6 +97,7 @@ }, "devDependencies": { "@ant-design/colors": "^3.1.0", + "@babel/plugin-transform-typescript": "^7.4.5", "@packtracker/webpack-plugin": "^2.0.1", "@sentry/browser": "^5.4.0", "@types/classnames": "^2.2.8", From 47b85c9d8b9785f487ca8763bb6bee31468cbcbe Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 7 Jul 2019 11:16:51 +0800 Subject: [PATCH 09/16] lock @babel/plugin-transform-typescript to ~7.4.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0fe1644c9a..e1c615d663 100644 --- a/package.json +++ b/package.json @@ -97,7 +97,7 @@ }, "devDependencies": { "@ant-design/colors": "^3.1.0", - "@babel/plugin-transform-typescript": "^7.4.5", + "@babel/plugin-transform-typescript": "~7.4.5", "@packtracker/webpack-plugin": "^2.0.1", "@sentry/browser": "^5.4.0", "@types/classnames": "^2.2.8", From 1d2bc0792b262d1eff907474849b44e4fc3f3f8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=81=8F=E5=8F=B3?= Date: Sun, 7 Jul 2019 12:04:40 +0800 Subject: [PATCH 10/16] fix: some tabs style (#17500) * :bug: Fix Tabs disabled tab style close #17468 * :bug: Fix Tabs next icon right 2px bug close #17477 --- components/tabs/style/card-style.less | 4 ++++ components/tabs/style/index.less | 22 +++++++++------------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/components/tabs/style/card-style.less b/components/tabs/style/card-style.less index 3cea4d72a7..ea100406e5 100644 --- a/components/tabs/style/card-style.less +++ b/components/tabs/style/card-style.less @@ -29,6 +29,10 @@ border-color: @border-color-split; border-bottom: @border-width-base solid @component-background; } + &&-card &-card-bar &-tab-disabled { + color: @tabs-card-active-color; + color: @disabled-color; + } &&-card &-card-bar &-tab-inactive { padding: 0; } diff --git a/components/tabs/style/index.less b/components/tabs/style/index.less index 66782d4a62..bd2f5f203f 100644 --- a/components/tabs/style/index.less +++ b/components/tabs/style/index.less @@ -197,6 +197,11 @@ margin-right: 8px; } + &-active { + color: @tabs-highlight-color; + font-weight: 500; + } + &-disabled { &, &:hover { @@ -204,11 +209,6 @@ cursor: not-allowed; } } - - &-active { - color: @tabs-highlight-color; - font-weight: 500; - } } } @@ -259,14 +259,9 @@ .@{tab-prefix-cls}-right-bar { height: 100%; border-bottom: 0; - &-tab-prev, - &-tab-next { - width: @tabs-scrolling-size; - height: 0; - transition: height 0.3s @ease-in-out, opacity 0.3s @ease-in-out, color 0.3s @ease-in-out; - } - &-tab-prev.@{tab-prefix-cls}-tab-arrow-show, - &-tab-next.@{tab-prefix-cls}-tab-arrow-show { + + .@{tab-prefix-cls}-tab-arrow-show, + .@{tab-prefix-cls}-tab-arrow-show { width: 100%; height: @tabs-scrolling-size; } @@ -320,6 +315,7 @@ } .@{tab-prefix-cls}-tab-next { + right: 0; bottom: 0; width: 100%; height: @tabs-scrolling-size; From bc6c0f14605a5b17e27b5cea7c984f9fd8ddd778 Mon Sep 17 00:00:00 2001 From: Yu Date: Sun, 7 Jul 2019 13:57:28 +0800 Subject: [PATCH 11/16] chore: changelog for 3.20.1 (#17499) --- CHANGELOG.en-US.md | 18 +++++++++++++++++- CHANGELOG.zh-CN.md | 18 +++++++++++++++++- package.json | 2 +- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.en-US.md b/CHANGELOG.en-US.md index c25ed85a4c..2da46651c7 100644 --- a/CHANGELOG.en-US.md +++ b/CHANGELOG.en-US.md @@ -15,12 +15,28 @@ timeline: true --- +## 3.20.1 + +- 💄 Optimize TimePicker focus style. [#17447](https://github.com/ant-design/ant-design/pull/17447) +- 💄 Optimize DatePicker arrow style for resolve messy when not use utf-8. [#17480](https://github.com/ant-design/ant-design/pull/17480) +- 🐞 Remove useless props which Drawer pass to rc-drawer for avoid error. [#17390](https://github.com/ant-design/ant-design/pull/17390) +- 🐞 Fix Tabs disabled tab and next icon style. [#17500](https://github.com/ant-design/ant-design/pull/17500) +- 🐞 Fix Result's problem that the `className` is empty and the class name is wrong. [#17389](https://github.com/ant-design/ant-design/pull/17389) +- 🐞 Fix DatePicker's input box is obscured on safari. [#17421](https://github.com/ant-design/ant-design/pull/17421) +- 🐞 Fix typo icon name `colum-height` to `column-height`. [#17458](https://github.com/ant-design/ant-design/pull/17458) +- TypeScript + - 🐞 Fix Form `onSubmit` type. [#17412](https://github.com/ant-design/ant-design/pull/17412) + - 🐞 Fix omit AutoComplete `loading` type. [#17433](https://github.com/ant-design/ant-design/pull/17433) + - 🐞 Fix Switch `onClick` type. [#17502](https://github.com/ant-design/ant-design/pull/17502) [@DiamondYuan](https://github.com/DiamondYuan) + ## 3.20.0 - 🔥🔥🔥 Add [Result](https://ant.design/components/result) Used to feed back the results of a series of operational tasks. - 🔥 Descriptions support vertical layout. [#17330](https://github.com/ant-design/ant-design/pull/17330) [@hengkx](https://github.com/hengkx) - 🔥 Progress.Circle support gradient line color. [#17315](https://github.com/ant-design/ant-design/pull/17315) [@hengkx](https://github.com/hengkx) - Progress + +Progress + - 🔥 Optimize PageHeader className naming. [#17321](https://github.com/ant-design/ant-design/pull/17321) - 🐞 Drawer fixes `maskCloseble` to false, keyboard ESC closes invalid. [#17316](https://github.com/ant-design/ant-design/pull/17316) - 🐞 Fixed an issue where Drawer closes not calling `afterVisibleChange` in Edge. [#17311](https://github.com/ant-design/ant-design/pull/17311) diff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.md index e0144cc6c7..bb1057e489 100644 --- a/CHANGELOG.zh-CN.md +++ b/CHANGELOG.zh-CN.md @@ -15,13 +15,29 @@ timeline: true --- +## 3.20.1 + +- 💄 优化 TimePicker 聚焦状态的样式。[#17447](https://github.com/ant-design/ant-design/pull/17447) +- 💄 优化 DatePicker 箭头样式,解决非 utf-8 编码下箭头样式乱码的问题。[#17480](https://github.com/ant-design/ant-design/pull/17480) +- 🐞 删除 Drawer 中传给 rc-drawer 的不必要的属性避免报错。[#17390](https://github.com/ant-design/ant-design/pull/17390) +- 🐞 修复 Tabs 当前失效页签样式以及切换图标错位 2px 的问题。[#17500](https://github.com/ant-design/ant-design/pull/17500) +- 🐞 修复 Result 组件 `className` 为空造成类名错误的问题。[#17389](https://github.com/ant-design/ant-design/pull/17389) +- 🐞 修复 safari 浏览器 DatePicker 组件输入框被遮挡的问题。[#17421](https://github.com/ant-design/ant-design/pull/17421) +- 🐞 修复图标名 `colum-height` 为 `column-height`。[#17458](https://github.com/ant-design/ant-design/pull/17458) +- TypeScript + - 🐞 修复 Form `onSubmit` TypeScript 定义。[#17412](https://github.com/ant-design/ant-design/pull/17412) + - 🐞 修复 AutoComplete 多余的 `loading` 属性 TypeScript 定义。[#17433](https://github.com/ant-design/ant-design/pull/17433) + - 🐞 修复 Switch 的 `onClick` 的 TypeScript 定义。[#17502](https://github.com/ant-design/ant-design/pull/17502) [@DiamondYuan](https://github.com/DiamondYuan) + ## 3.20.0 - 🔥🔥🔥 新增 [Result](https://ant.design/components/result) 用于反馈一系列操作任务的处理结果。 - 🔥 Descriptions 支持垂直布局。[#17330](https://github.com/ant-design/ant-design/pull/17330) [@hengkx](https://github.com/hengkx) - 🔥 优化 PageHeader 的 `className` 定义。[#17321](https://github.com/ant-design/ant-design/pull/17321) - 🔥 Progress.Circle 支持渐变色。[#17315](https://github.com/ant-design/ant-design/pull/17315) [@hengkx](https://github.com/hengkx) - Progress + +Progress + - 🐞 Drawer 修复 `maskCloseble` 为 false,键盘 ESC 关闭无效的问题。[#17316](https://github.com/ant-design/ant-design/pull/17316) - 🐞 修复在 Edge 下 Drawer 关闭后没有调用 `afterVisibleChange` 的问题。[#17311](https://github.com/ant-design/ant-design/pull/17311) - 🌟 Drawer 新增 `keyboard`,允许打开关闭对键盘事件的响应。[#17316](https://github.com/ant-design/ant-design/pull/17316) diff --git a/package.json b/package.json index e1c615d663..d5dc143f52 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "antd", - "version": "3.20.0", + "version": "3.20.1", "title": "Ant Design", "description": "An enterprise-class UI design language and React components implementation", "homepage": "http://ant.design/", From 76db651080f9569d67f0de325d0ebabdf1b97ecb Mon Sep 17 00:00:00 2001 From: Michael Salaverry Date: Sun, 7 Jul 2019 17:08:46 +0300 Subject: [PATCH 12/16] fix: typo in console.error --- components/icon/__tests__/index.test.js | 10 +++++----- components/icon/utils.ts | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/icon/__tests__/index.test.js b/components/icon/__tests__/index.test.js index 5a2469de2a..43eb7beb1f 100644 --- a/components/icon/__tests__/index.test.js +++ b/components/icon/__tests__/index.test.js @@ -227,23 +227,23 @@ describe('utils', () => { ]); }); - it('should depracate typo icon name', () => { + it('should report an error when there are deprecated typos in icon names', () => { const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); render(); expect(errorSpy).toHaveBeenLastCalledWith( - "Warning: [antd: Icon] Icon 'interation' is typo and depracated, please use 'interaction' instead.", + "Warning: [antd: Icon] Icon 'interation' was a typo and is now deprecated, please use 'interaction' instead.", ); render(); expect(errorSpy).toHaveBeenLastCalledWith( - "Warning: [antd: Icon] Icon 'cross' is typo and depracated, please use 'close' instead.", + "Warning: [antd: Icon] Icon 'cross' was a typo and is now deprecated, please use 'close' instead.", ); render(); expect(errorSpy).toHaveBeenLastCalledWith( - "Warning: [antd: Icon] Icon 'canlendar' is typo and depracated, please use 'calendar' instead.", + "Warning: [antd: Icon] Icon 'canlendar' was a typo and is now deprecated, please use 'calendar' instead.", ); render(); expect(errorSpy).toHaveBeenLastCalledWith( - "Warning: [antd: Icon] Icon 'colum-height' is typo and depracated, please use 'column-height' instead.", + "Warning: [antd: Icon] Icon 'colum-height' was a typo and is now deprecated, please use 'column-height' instead.", ); expect(errorSpy).toHaveBeenCalledTimes(4); errorSpy.mockRestore(); diff --git a/components/icon/utils.ts b/components/icon/utils.ts index 9717a17199..275e75185f 100644 --- a/components/icon/utils.ts +++ b/components/icon/utils.ts @@ -72,7 +72,7 @@ export function alias(type: string) { warning( newType === type, 'Icon', - `Icon '${type}' is typo and depracated, please use '${newType}' instead.`, + `Icon '${type}' was a typo and is now deprecated, please use '${newType}' instead.`, ); return newType; } From 9691d2bee1f931e421b97dc521507b14c25e5c0a Mon Sep 17 00:00:00 2001 From: riho <873435892@qq.com> Date: Sun, 7 Jul 2019 22:24:37 +0800 Subject: [PATCH 13/16] fix: optimize Input presuffix style(#17414) --- components/input/style/mixin.less | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/input/style/mixin.less b/components/input/style/mixin.less index d98c2a5290..ad1c2f74c2 100644 --- a/components/input/style/mixin.less +++ b/components/input/style/mixin.less @@ -373,9 +373,17 @@ color: @input-color; line-height: 0; transform: translateY(-50%); + background-color: #fff; + height: calc(100% - 2px); :not(.anticon) { line-height: @line-height-base; } + .anticon { + position: relative; + vertical-align: top; + top: 50%; + transform: translateY(-50%); + } } .@{inputClass}-prefix { From 4a1d68c87f3cc034a2edcea85ae4468ce5764a36 Mon Sep 17 00:00:00 2001 From: zombieJ Date: Mon, 8 Jul 2019 10:57:34 +0800 Subject: [PATCH 14/16] chore: Add warn of `value` not provided in Cascader (#17511) * add warn of `value` not provided * adjust desc & logic --- components/cascader/__tests__/index.test.js | 9 +++++++++ components/cascader/index.tsx | 12 ++++++++++++ 2 files changed, 21 insertions(+) diff --git a/components/cascader/__tests__/index.test.js b/components/cascader/__tests__/index.test.js index 973c991338..57be6c141f 100644 --- a/components/cascader/__tests__/index.test.js +++ b/components/cascader/__tests__/index.test.js @@ -429,4 +429,13 @@ describe('Cascader', () => { ); }); }); + + it('should warning if not find `value` in `options`', () => { + const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); + mount(); + expect(errorSpy).toHaveBeenCalledWith( + 'Warning: [antd: Cascader] Not found `value` in `options`.', + ); + errorSpy.mockRestore(); + }); }); diff --git a/components/cascader/index.tsx b/components/cascader/index.tsx index 17fc1dbbe5..8b617ae33c 100644 --- a/components/cascader/index.tsx +++ b/components/cascader/index.tsx @@ -204,6 +204,14 @@ function flattenTree( const defaultDisplayRender = (label: string[]) => label.join(' / '); +function warningValueNotExist(list: CascaderOptionType[], fieldNames: FieldNamesType = {}) { + (list || []).forEach(item => { + const valueFieldName = fieldNames.value || 'value'; + warning(valueFieldName in item, 'Cascader', 'Not found `value` in `options`.'); + warningValueNotExist(item[fieldNames.children || 'children'], fieldNames); + }); +} + class Cascader extends React.Component { static defaultProps = { placeholder: 'Please select', @@ -229,6 +237,10 @@ class Cascader extends React.Component { newState.flattenOptions = flattenTree(nextProps.options, nextProps); } + if (process.env.NODE_ENV !== 'production' && nextProps.options) { + warningValueNotExist(nextProps.options, getFieldNames(nextProps)); + } + return newState; } From a614b54c286d34ec2e74b3450195705157b6b3ed Mon Sep 17 00:00:00 2001 From: ztplz Date: Mon, 8 Jul 2019 17:42:36 +0800 Subject: [PATCH 15/16] Improve code style --- 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 8b617ae33c..4ae394d981 100644 --- a/components/cascader/index.tsx +++ b/components/cascader/index.tsx @@ -204,8 +204,8 @@ function flattenTree( const defaultDisplayRender = (label: string[]) => label.join(' / '); -function warningValueNotExist(list: CascaderOptionType[], fieldNames: FieldNamesType = {}) { - (list || []).forEach(item => { +function warningValueNotExist(list: CascaderOptionType[] = [], fieldNames: FieldNamesType = {}) { + list.forEach(item => { const valueFieldName = fieldNames.value || 'value'; warning(valueFieldName in item, 'Cascader', 'Not found `value` in `options`.'); warningValueNotExist(item[fieldNames.children || 'children'], fieldNames); From 390807605e9316f950721d032c81d105c4357994 Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 8 Jul 2019 14:04:49 +0800 Subject: [PATCH 16/16] :wrench: use none-dist icons entry --- components/badge/__tests__/__snapshots__/demo.test.js.snap | 1 + components/drawer/__tests__/__snapshots__/demo.test.js.snap | 1 + components/form/__tests__/__snapshots__/demo.test.js.snap | 1 + components/icon/index.tsx | 2 +- components/progress/__tests__/__snapshots__/demo.test.js.snap | 2 ++ components/tabs/__tests__/__snapshots__/demo.test.js.snap | 1 + components/tag/__tests__/__snapshots__/demo.test.js.snap | 2 ++ 7 files changed, 9 insertions(+), 1 deletion(-) diff --git a/components/badge/__tests__/__snapshots__/demo.test.js.snap b/components/badge/__tests__/__snapshots__/demo.test.js.snap index 83389a3f4f..88465de1a7 100644 --- a/components/badge/__tests__/__snapshots__/demo.test.js.snap +++ b/components/badge/__tests__/__snapshots__/demo.test.js.snap @@ -437,6 +437,7 @@ exports[`renders ./components/badge/demo/change.md correctly 1`] = ` viewBox="64 64 896 896" width="1em" > + diff --git a/components/drawer/__tests__/__snapshots__/demo.test.js.snap b/components/drawer/__tests__/__snapshots__/demo.test.js.snap index 632c9d9079..b84e1197e7 100644 --- a/components/drawer/__tests__/__snapshots__/demo.test.js.snap +++ b/components/drawer/__tests__/__snapshots__/demo.test.js.snap @@ -33,6 +33,7 @@ exports[`renders ./components/drawer/demo/form-in-drawer.md correctly 1`] = ` viewBox="64 64 896 896" width="1em" > + diff --git a/components/form/__tests__/__snapshots__/demo.test.js.snap b/components/form/__tests__/__snapshots__/demo.test.js.snap index 50bb94e91a..3665bf4846 100644 --- a/components/form/__tests__/__snapshots__/demo.test.js.snap +++ b/components/form/__tests__/__snapshots__/demo.test.js.snap @@ -779,6 +779,7 @@ exports[`renders ./components/form/demo/dynamic-form-item.md correctly 1`] = ` viewBox="64 64 896 896" width="1em" > + diff --git a/components/icon/index.tsx b/components/icon/index.tsx index 6306872ed5..f55c962a3a 100755 --- a/components/icon/index.tsx +++ b/components/icon/index.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import classNames from 'classnames'; -import * as allIcons from '@ant-design/icons/lib/dist'; +import * as allIcons from '@ant-design/icons'; import ReactIcon from '@ant-design/icons-react'; import createFromIconfontCN from './IconFont'; import { diff --git a/components/progress/__tests__/__snapshots__/demo.test.js.snap b/components/progress/__tests__/__snapshots__/demo.test.js.snap index 2a46083d21..87abf7ca8c 100644 --- a/components/progress/__tests__/__snapshots__/demo.test.js.snap +++ b/components/progress/__tests__/__snapshots__/demo.test.js.snap @@ -254,6 +254,7 @@ exports[`renders ./components/progress/demo/circle-dynamic.md correctly 1`] = ` viewBox="64 64 896 896" width="1em" > + @@ -548,6 +549,7 @@ exports[`renders ./components/progress/demo/dynamic.md correctly 1`] = ` viewBox="64 64 896 896" width="1em" > + diff --git a/components/tabs/__tests__/__snapshots__/demo.test.js.snap b/components/tabs/__tests__/__snapshots__/demo.test.js.snap index ffc31bb3f4..7eaf99a6a7 100644 --- a/components/tabs/__tests__/__snapshots__/demo.test.js.snap +++ b/components/tabs/__tests__/__snapshots__/demo.test.js.snap @@ -1182,6 +1182,7 @@ exports[`renders ./components/tabs/demo/editable-card.md correctly 1`] = ` viewBox="64 64 896 896" width="1em" > + diff --git a/components/tag/__tests__/__snapshots__/demo.test.js.snap b/components/tag/__tests__/__snapshots__/demo.test.js.snap index 9fcf8edf6a..4ee461cf2c 100644 --- a/components/tag/__tests__/__snapshots__/demo.test.js.snap +++ b/components/tag/__tests__/__snapshots__/demo.test.js.snap @@ -113,6 +113,7 @@ exports[`renders ./components/tag/demo/animation.md correctly 1`] = ` viewBox="64 64 896 896" width="1em" > + @@ -388,6 +389,7 @@ exports[`renders ./components/tag/demo/control.md correctly 1`] = ` viewBox="64 64 896 896" width="1em" > +