From 25927c6a414511d80428940decf82853c0ef6fce Mon Sep 17 00:00:00 2001 From: Sagar Jain Date: Mon, 21 Oct 2019 16:37:02 +0530 Subject: [PATCH 01/11] Improve typing of `UploadFile` interface UploadFile interface made generic type so that a user can define a strongly typed response object if needed --- components/upload/interface.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/upload/interface.tsx b/components/upload/interface.tsx index e1f4c37c08..c80380a6d9 100755 --- a/components/upload/interface.tsx +++ b/components/upload/interface.tsx @@ -24,7 +24,7 @@ export interface RcCustomRequestOptions { headers: object; } -export interface UploadFile { +export interface UploadFile { uid: string; size: number; name: string; @@ -36,7 +36,7 @@ export interface UploadFile { percent?: number; thumbUrl?: string; originFileObj?: File | Blob; - response?: any; + response?: T; error?: any; linkProps?: any; type: string; From bb7eab65446d57ef2daca0865ed560deece05671 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=81=8F=E5=8F=B3?= Date: Mon, 21 Oct 2019 20:23:59 +0800 Subject: [PATCH 02/11] Update CHANGELOG.zh-CN.md --- CHANGELOG.zh-CN.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.md index c8f63b776a..e860846503 100644 --- a/CHANGELOG.zh-CN.md +++ b/CHANGELOG.zh-CN.md @@ -1862,7 +1862,7 @@ timeline: true `2018-05-13` - 🐞 修复 `Table` 过滤器和 `Transfer` 复选框无法点击的问题。[#10452](https://github.com/ant-design/ant-design/issues/10452) -- 🐞 修复 `Cascader` 的  `displayRender` 里的链接无法点击的问题。[#10433](https://github.com/ant-design/ant-design/issues/10433) +- 🐞 修复 `Cascader` 的 `displayRender` 里的链接无法点击的问题。[#10433](https://github.com/ant-design/ant-design/issues/10433) - 🐞 修复 `Button` ref 不兼容问题。[#10405](https://github.com/ant-design/ant-design/issues/10405) - 🐞 修复 `Form` 表单项校验位置高度时出现抖动问题。[#10445](https://github.com/ant-design/ant-design/issues/10445) - 🌟 设置 `Layout` 宽度时,允许使用任何的 CSS 单位。[#10479](https://github.com/ant-design/ant-design/pull/10479) @@ -1984,7 +1984,7 @@ timeline: true - 🌟 新增 `defaultExpandParent` 用于在第一次渲染时自动展开父节点。 - 🌟 新增 `disabled` 用于禁用整棵树。 - 🌟 TreeNode 新增 `icon` 用于设置自定义图标。 - - 🌟 优化了 TreeNode 设置 `disabled` 时的  勾选逻辑。 + - 🌟 优化了 TreeNode 设置 `disabled` 时的勾选逻辑。 - 🌟 Anchor 新增 `getContainer` 用于指定内容滚动的容器。 - 🌟 Table 新增 less 变量 `@table-expanded-row-bg`。[#9789](https://github.com/ant-design/ant-design/pull/9789) - 🐞 修复一处 less 语法错误。[#9832](https://github.com/ant-design/ant-design/pull/9832) [@jojoLockLock](https://github.com/jojoLockLock) From b770db4330f1e101274a6cdd2bbd5d15308c25e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=81=8F=E5=8F=B3?= Date: Mon, 21 Oct 2019 20:27:41 +0800 Subject: [PATCH 03/11] Update CHANGELOG.zh-CN.md --- CHANGELOG.zh-CN.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.md index e860846503..bcb32430f1 100644 --- a/CHANGELOG.zh-CN.md +++ b/CHANGELOG.zh-CN.md @@ -1720,7 +1720,7 @@ timeline: true - Upload 组件升级 `rc-upload` 到 `2.5.0` - 🌟 新增 `directory` 属性,支持上传一个文件夹。[#7315](https://github.com/ant-design/ant-design/issues/7315) - 🌟 `action` 属性支持作为一个返回 `Promise` 对象的函数,使用更加灵活。[fd96967](https://github.com/ant-design/ant-design/commit/fd96967c872600b79bb608e9ddf9f8c38814a704) -- Dropdown 增加新特性, 可以做为右键菜单来使用。 +- Dropdown 增加新特性,可以做为右键菜单来使用。 - 🌟 给菜单项的 icon 提供默认的外间距样式。[8e60a59](https://github.com/ant-design/ant-design/commit/8e60a591fd24f644de4f67d69c2210e9270be9cc) - 🌟 触发方式为 `contextMenu` 时自动调整菜单的位置。[16e4260](https://github.com/ant-design/ant-design/commit/16e42601d6772fc0830ee237a1e751a38a118676) - Table 组件升级 `rc-table` 到 `6.2.2`。[f2fddff](https://github.com/ant-design/ant-design/commit/f2fddff3fd0d6b36e8e6d8ee06bfcbcc85ead4f0) @@ -1851,7 +1851,7 @@ timeline: true - 💄 统一 less 的变量命名 [12d3046](https://github.com/ant-design/ant-design/commit/12d3046687a0dcdb51fece08dd2bea64f185cc40) - 💄 微调了 `Dropdown` 的样式 [8e2f72f](https://github.com/ant-design/ant-design/commit/8e2f72ffe0eb300f5997296726b02246bf990c8f) - 💄 现在中文文档的组件会用中文语言包进行演示。[9b17a94](https://github.com/ant-design/ant-design/commit/9b17a943f5d57d40d65041b7b0c247add09d2851) -- 💄 主站主题切换 修改为 `antd-theme-generato` ,感谢 [@mzohaibqc](https://github.com/mzohaibqc) 的工作. +- 💄 主站主题切换 修改为 `antd-theme-generator` ,感谢 [@mzohaibqc](https://github.com/mzohaibqc) 的工作. - TypeScript - 🐞 修复了 `Row` 中 gutter 属性的类型问题 [b7d508e](https://github.com/ant-design/ant-design/commit/b7d508e1662bf20a0cacbe6440a2ce31a65a8a59) - 💄 改进了 `Form` 组件类型 [#10564](https://github.com/ant-design/ant-design/pull/10564) From b919c23d0886800570b0813c052701e81908daae Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 22 Oct 2019 11:13:40 +0800 Subject: [PATCH 04/11] :bug: Fix small table bottom border radius issue https://github.com/ant-design/ant-design/issues/19287#issuecomment-544368967 --- components/table/style/size.less | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/components/table/style/size.less b/components/table/style/size.less index 12ad76b50e..8aaff11b39 100644 --- a/components/table/style/size.less +++ b/components/table/style/size.less @@ -102,7 +102,7 @@ .@{table-prefix-cls}-header { background-color: @component-background; - border-radius: @border-radius-base @border-radius-base 0 0; + border-radius: @table-border-radius-base @table-border-radius-base 0 0; } .@{table-prefix-cls}-placeholder, @@ -161,4 +161,12 @@ margin: -@table-padding-vertical-sm -@table-padding-horizontal / 2 -@table-padding-vertical-sm - 1px; } + + // https://github.com/ant-design/ant-design/issues/19287#issuecomment-544368967 + &.@{table-prefix-cls}-fixed-header + > .@{table-prefix-cls}-content + > .@{table-prefix-cls}-scroll + > .@{table-prefix-cls}-body { + border-radius: 0 0 @table-border-radius-base @table-border-radius-base; + } } From 884031afcc1e4cf4b6dea7ba25499021bbe5293a Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 22 Oct 2019 11:47:09 +0800 Subject: [PATCH 05/11] :white_check_mark: fix eslint console warning --- scripts/check-site.js | 1 + tests/setup.js | 1 + 2 files changed, 2 insertions(+) diff --git a/scripts/check-site.js b/scripts/check-site.js index 85f66a3cfb..493eff142a 100755 --- a/scripts/check-site.js +++ b/scripts/check-site.js @@ -59,6 +59,7 @@ describe('site test', () => { root: join(process.cwd(), '_site'), }); server.listen(host); + // eslint-disable-next-line no-console console.log('site static server run: http://localhost:3000'); }); diff --git a/tests/setup.js b/tests/setup.js index 681162e725..ff229e6365 100644 --- a/tests/setup.js +++ b/tests/setup.js @@ -1,5 +1,6 @@ const React = require('react'); +// eslint-disable-next-line no-console console.log('Current React Version:', React.version); /* eslint-disable global-require */ From 25788e69a8e8cad8cf9c239493293cf24e1b2176 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: Tue, 22 Oct 2019 11:54:03 +0800 Subject: [PATCH 06/11] omit withstore (#19343) --- components/table/Table.tsx | 10 +++++----- components/table/interface.tsx | 4 +++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/components/table/Table.tsx b/components/table/Table.tsx index 5a15e011cb..fb49eb849e 100755 --- a/components/table/Table.tsx +++ b/components/table/Table.tsx @@ -17,6 +17,7 @@ import { flatArray, treeMap, flatFilter, normalizeColumns } from './util'; import scrollTo from '../_util/scrollTo'; import { TableProps, + InternalTableProps, TableSize, TableState, TableComponents, @@ -34,7 +35,6 @@ import { PaginationConfig, PrepareParamsArgumentsReturn, ExpandIconProps, - WithStore, CheckboxPropsCache, } from './interface'; import Pagination from '../pagination'; @@ -133,7 +133,7 @@ function isFiltersChanged(state: TableState, filters: TableStateFilters): return Object.keys(filters).some(columnKey => filters[columnKey] !== state.filters[columnKey]); } -class Table extends React.Component, TableState> { +class Table extends React.Component, TableState> { static propTypes = { dataSource: PropTypes.array, columns: PropTypes.array, @@ -166,7 +166,7 @@ class Table extends React.Component, TableState> { childrenColumnName: 'children', }; - static getDerivedStateFromProps(nextProps: TableProps, prevState: TableState) { + static getDerivedStateFromProps(nextProps: InternalTableProps, prevState: TableState) { const { prevProps } = prevState; const columns = nextProps.columns || normalizeColumns(nextProps.children as React.ReactChildren); @@ -241,7 +241,7 @@ class Table extends React.Component, TableState> { rcTable: any; - constructor(props: TableProps) { + constructor(props: InternalTableProps) { super(props); const { expandedRowRender, columns: columnsProp = [] } = props; @@ -1366,7 +1366,7 @@ class Table extends React.Component, TableState> { polyfill(Table); -class StoreTable extends React.Component, keyof WithStore>> { +class StoreTable extends React.Component> { static displayName = 'withStore(Table)'; static Column = Column; diff --git a/components/table/interface.tsx b/components/table/interface.tsx index 02cb94424f..48fcc91ef4 100644 --- a/components/table/interface.tsx +++ b/components/table/interface.tsx @@ -161,7 +161,7 @@ export interface WithStore { setCheckboxPropsCache: (cache: CheckboxPropsCache) => void; } -export interface TableProps extends WithStore { +export interface TableProps { prefixCls?: string; dropdownPrefixCls?: string; rowSelection?: TableRowSelection; @@ -219,6 +219,8 @@ export interface TableProps extends WithStore { getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement; } +export type InternalTableProps = TableProps & WithStore; + export interface TableStateFilters { [key: string]: string[]; } From 6236537d1ddf440301163a1dea235e39b31d19dc 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: Tue, 22 Oct 2019 14:15:26 +0800 Subject: [PATCH 07/11] chore: Temporary lock eslint parser version (#19347) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9fde729e27..f7f7bfbf77 100644 --- a/package.json +++ b/package.json @@ -157,7 +157,7 @@ "@types/shallowequal": "^1.1.1", "@types/warning": "^3.0.0", "@typescript-eslint/eslint-plugin": "^2.0.0", - "@typescript-eslint/parser": "^2.0.0", + "@typescript-eslint/parser": "~2.4.0", "@yesmeck/offline-plugin": "^5.0.5", "antd-theme-generator": "^1.1.6", "babel-eslint": "^10.0.1", From b882b8dd2fbdb07fcbbfc6a94829b283955ff8d5 Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 22 Oct 2019 21:29:17 +0800 Subject: [PATCH 08/11] :bug: Fix `non-boolean attribute` and `unique key` warning close #19303 close #19354 --- components/input/Search.tsx | 31 ++++++++++++------- components/input/demo/align.md | 2 +- components/input/demo/search-input-loading.md | 3 +- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/components/input/Search.tsx b/components/input/Search.tsx index b2e0603436..1dd00532a6 100644 --- a/components/input/Search.tsx +++ b/components/input/Search.tsx @@ -68,7 +68,7 @@ export default class Search extends React.Component { ); } - return ; + return ; }; renderSuffix = (prefixCls: string) => { @@ -80,7 +80,7 @@ export default class Search extends React.Component { if (enterButton) return suffix; - const node = ( + const icon = ( { ); if (suffix) { - let cloneSuffix = suffix; - if (React.isValidElement(cloneSuffix) && !cloneSuffix.key) { - cloneSuffix = React.cloneElement(cloneSuffix, { - key: 'originSuffix', - }); - } - return [cloneSuffix, node]; + return [ + React.isValidElement(suffix) + ? React.cloneElement(suffix, { + key: 'suffix', + }) + : null, + icon, + ]; } - return node; + return icon; }; renderAddonAfter = (prefixCls: string) => { @@ -144,7 +145,14 @@ export default class Search extends React.Component { } if (addonAfter) { - return [button, addonAfter]; + return [ + button, + React.isValidElement(addonAfter) + ? React.cloneElement(addonAfter, { + key: 'addonAfter', + }) + : null, + ]; } return button; @@ -161,6 +169,7 @@ export default class Search extends React.Component { } = this.props; delete (restProps as any).onSearch; + delete (restProps as any).loading; const prefixCls = getPrefixCls('input-search', customizePrefixCls); const inputPrefixCls = getPrefixCls('input', customizeInputPrefixCls); diff --git a/components/input/demo/align.md b/components/input/demo/align.md index e0df965ae9..796186c39a 100644 --- a/components/input/demo/align.md +++ b/components/input/demo/align.md @@ -69,7 +69,7 @@ ReactDOM.render( - Ant Design + Ant Design diff --git a/components/input/demo/search-input-loading.md b/components/input/demo/search-input-loading.md index b89989e163..c2c1861e80 100644 --- a/components/input/demo/search-input-loading.md +++ b/components/input/demo/search-input-loading.md @@ -23,7 +23,7 @@ ReactDOM.render(

- +

@@ -33,7 +33,6 @@ ReactDOM.render( placeholder="input search loading with enterButton and addonAfter" loading enterButton - addonAfter="addonAfter" /> , mountNode, From 0604a0959018a2c2339aa9ce6a53b2cf380413a5 Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 22 Oct 2019 21:33:19 +0800 Subject: [PATCH 09/11] :white_check_mark: update demo and test case --- components/input/__tests__/Search.test.js | 12 + .../__snapshots__/Search.test.js.snap | 247 ++++++++++++++++++ .../__tests__/__snapshots__/demo.test.js.snap | 109 ++------ .../__snapshots__/index.test.js.snap | 3 +- components/input/demo/search-input-loading.md | 10 - 5 files changed, 288 insertions(+), 93 deletions(-) diff --git a/components/input/__tests__/Search.test.js b/components/input/__tests__/Search.test.js index 705506cbf1..14aff06123 100644 --- a/components/input/__tests__/Search.test.js +++ b/components/input/__tests__/Search.test.js @@ -166,4 +166,16 @@ describe('Input.Search', () => { expect(wrapper.render()).toMatchSnapshot(); expect(wrapperWithEnterButton.render()).toMatchSnapshot(); }); + + it('should support addonAfter and suffix for loading', () => { + const wrapper = mount(); + const wrapperWithEnterButton = mount(); + expect(wrapper.render()).toMatchSnapshot(); + expect(wrapperWithEnterButton.render()).toMatchSnapshot(); + }) + + it('should support invalid addonAfter and suffix', () => { + const wrapper = mount(); + expect(wrapper.render()).toMatchSnapshot(); + }) }); diff --git a/components/input/__tests__/__snapshots__/Search.test.js.snap b/components/input/__tests__/__snapshots__/Search.test.js.snap index a5ec6ef6d0..0d0114f6f6 100644 --- a/components/input/__tests__/__snapshots__/Search.test.js.snap +++ b/components/input/__tests__/__snapshots__/Search.test.js.snap @@ -98,6 +98,109 @@ exports[`Input.Search should support addonAfter 2`] = ` `; +exports[`Input.Search should support addonAfter and suffix for loading 1`] = ` + + + + + + suffix + + + + + + + addonAfter + + + +`; + +exports[`Input.Search should support addonAfter and suffix for loading 2`] = ` + + + + + + suffix + + + + + addonAfter + + + +`; + exports[`Input.Search should support custom Button 1`] = ` `; +exports[`Input.Search should support invalid addonAfter and suffix 1`] = ` + + + + + + + + + + + + + +`; + +exports[`Input.Search should support invalid addonAfter and suffix for loading 1`] = ` + + + + + + + + + + + + + +`; + +exports[`Input.Search should support invalid addonAfter and suffix for loading 2`] = ` + + + + + + + + + + + +`; + exports[`Input.Search should support loading 1`] = ` Ant Design +
+ + + +


- - - - suffix - - - - - -
-
@@ -1926,51 +1918,6 @@ exports[`renders ./components/input/demo/search-input-loading.md correctly 1`] =
-
-
- - - - - - addonAfter - - - `; diff --git a/components/input/__tests__/__snapshots__/index.test.js.snap b/components/input/__tests__/__snapshots__/index.test.js.snap index c9bfa9f3dc..81618423cd 100644 --- a/components/input/__tests__/__snapshots__/index.test.js.snap +++ b/components/input/__tests__/__snapshots__/index.test.js.snap @@ -258,7 +258,7 @@ exports[`Input.Search should support suffix 1`] = ` prefixCls="ant-input" suffix={ Array [ - "suffix", + null, - suffix

- -
-
-
-
- , mountNode, ); From f1cd910b4e6ca6f2f6753128f660963b871b7629 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 23 Oct 2019 11:07:22 +0800 Subject: [PATCH 10/11] :white_check_mark: update snapshots --- .../__snapshots__/Search.test.js.snap | 97 ------------------- 1 file changed, 97 deletions(-) diff --git a/components/input/__tests__/__snapshots__/Search.test.js.snap b/components/input/__tests__/__snapshots__/Search.test.js.snap index 0d0114f6f6..501a7f4c96 100644 --- a/components/input/__tests__/__snapshots__/Search.test.js.snap +++ b/components/input/__tests__/__snapshots__/Search.test.js.snap @@ -301,103 +301,6 @@ exports[`Input.Search should support invalid addonAfter and suffix 1`] = `
`; -exports[`Input.Search should support invalid addonAfter and suffix for loading 1`] = ` - - - - - - - - - - - - - -`; - -exports[`Input.Search should support invalid addonAfter and suffix for loading 2`] = ` - - - - - - - - - - - -`; - exports[`Input.Search should support loading 1`] = ` Date: Wed, 23 Oct 2019 11:40:09 +0800 Subject: [PATCH 11/11] :white_check_mark: increase code cov --- components/input/__tests__/Search.test.js | 13 ++-- .../__snapshots__/Search.test.js.snap | 65 ++++++++++++++----- 2 files changed, 58 insertions(+), 20 deletions(-) diff --git a/components/input/__tests__/Search.test.js b/components/input/__tests__/Search.test.js index 14aff06123..c1fb99ffda 100644 --- a/components/input/__tests__/Search.test.js +++ b/components/input/__tests__/Search.test.js @@ -172,10 +172,15 @@ describe('Input.Search', () => { const wrapperWithEnterButton = mount(); expect(wrapper.render()).toMatchSnapshot(); expect(wrapperWithEnterButton.render()).toMatchSnapshot(); - }) + }); - it('should support invalid addonAfter and suffix', () => { - const wrapper = mount(); + it('should support invalid suffix', () => { + const wrapper = mount(); expect(wrapper.render()).toMatchSnapshot(); - }) + }); + + it('should support invalid addonAfter', () => { + const wrapper = mount(); + expect(wrapper.render()).toMatchSnapshot(); + }); }); diff --git a/components/input/__tests__/__snapshots__/Search.test.js.snap b/components/input/__tests__/__snapshots__/Search.test.js.snap index 501a7f4c96..db5ceff787 100644 --- a/components/input/__tests__/__snapshots__/Search.test.js.snap +++ b/components/input/__tests__/__snapshots__/Search.test.js.snap @@ -254,28 +254,28 @@ exports[`Input.Search should support custom button 1`] = ` `; -exports[`Input.Search should support invalid addonAfter and suffix 1`] = ` +exports[`Input.Search should support invalid addonAfter 1`] = ` + - - - + - + + +`; + +exports[`Input.Search should support invalid suffix 1`] = ` + + + + + + `;