From 435558b63e758ccf8e64651630a95e2241f69ed4 Mon Sep 17 00:00:00 2001 From: Wei Zhu Date: Tue, 10 Jul 2018 12:29:20 +0800 Subject: [PATCH 01/17] fix: Layout.Sider string width Close #11211 --- components/layout/Sider.tsx | 6 +++++- .../__tests__/__snapshots__/index.test.js.snap | 14 ++++++++++++++ components/layout/__tests__/index.test.js | 9 ++++++++- 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 components/layout/__tests__/__snapshots__/index.test.js.snap diff --git a/components/layout/Sider.tsx b/components/layout/Sider.tsx index 3444739f89..93ef93495e 100644 --- a/components/layout/Sider.tsx +++ b/components/layout/Sider.tsx @@ -65,6 +65,10 @@ const generateId = (() => { }; })(); +const isNumeric = (n: any) => { + return !isNaN(parseFloat(n)) && isFinite(n); +}; + export default class Sider extends React.Component { static __ANT_LAYOUT_SIDER: any = true; @@ -186,7 +190,7 @@ export default class Sider extends React.Component { 'defaultCollapsed', 'onCollapse', 'breakpoint']); const rawWidth = this.state.collapsed ? collapsedWidth : width; // use "px" as fallback unit for width - const siderWidth = typeof rawWidth === 'number' ? `${rawWidth}px` : String(rawWidth || 0); + const siderWidth = isNumeric(rawWidth) ? `${rawWidth}px` : String(rawWidth); // special trigger when collapsedWidth == 0 const zeroWidthTrigger = parseFloat(String(collapsedWidth || 0)) === 0 ? ( diff --git a/components/layout/__tests__/__snapshots__/index.test.js.snap b/components/layout/__tests__/__snapshots__/index.test.js.snap new file mode 100644 index 0000000000..1d87628e5a --- /dev/null +++ b/components/layout/__tests__/__snapshots__/index.test.js.snap @@ -0,0 +1,14 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Layout renders string width correctly 1`] = ` +
+
+ Sider +
+
+`; diff --git a/components/layout/__tests__/index.test.js b/components/layout/__tests__/index.test.js index 62563aa073..6340f1ffb2 100644 --- a/components/layout/__tests__/index.test.js +++ b/components/layout/__tests__/index.test.js @@ -1,5 +1,5 @@ import React from 'react'; -import { mount } from 'enzyme'; +import { mount, render } from 'enzyme'; import Layout from '..'; const { Sider, Content } = Layout; @@ -69,4 +69,11 @@ describe('Layout', () => { ); expect(wrapper.find('.ant-layout-sider').hasClass('ant-layout-sider-light')); }); + + it('renders string width correctly', () => { + const wrapper = render( + Sider + ); + expect(wrapper).toMatchSnapshot(); + }); }); From 779abfaf9f6426ac3379f47c8a289f65f1a93dbd Mon Sep 17 00:00:00 2001 From: "zhenbao.xy" Date: Wed, 4 Jul 2018 16:40:41 +0800 Subject: [PATCH 02/17] fix the relation between @alert-text-color & @text-color --- components/alert/style/index.less | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/alert/style/index.less b/components/alert/style/index.less index dfcf65789c..a5654533a6 100644 --- a/components/alert/style/index.less +++ b/components/alert/style/index.less @@ -5,6 +5,7 @@ @alert-message-color: @heading-color; @alert-text-color: @text-color; +@alert-close-color: @text-color-secondary; .@{alert-prefix-cls} { .reset-component; @@ -70,7 +71,7 @@ cursor: pointer; .@{iconfont-css-prefix}-cross { - color: @text-color-secondary; + color: @alert-close-color; transition: color .3s; &:hover { color: #404040; @@ -87,7 +88,7 @@ padding: 15px 15px 15px 64px; position: relative; border-radius: @border-radius-base; - color: @text-color; + color: @alert-text-color; line-height: @line-height-base; } From 52d736a0ee019e61b68bb75844e8592cde197f6f Mon Sep 17 00:00:00 2001 From: Daewoong Moon Date: Mon, 9 Jul 2018 23:22:27 -0700 Subject: [PATCH 03/17] Added missing ko_KR locale --- components/locale-provider/ko_KR.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/locale-provider/ko_KR.tsx b/components/locale-provider/ko_KR.tsx index aed47144a9..b0a26748db 100644 --- a/components/locale-provider/ko_KR.tsx +++ b/components/locale-provider/ko_KR.tsx @@ -14,6 +14,8 @@ export default { filterConfirm: '확인', filterReset: '초기화', emptyText: '데이터 없음', + selectAll: '모두 선택', + selectInvert: '선택 반전', }, Modal: { okText: '확인', From b3f4e5e3da29812ca798fd3a57d271910ce4f4db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Thu, 5 Jul 2018 10:28:38 +0800 Subject: [PATCH 04/17] bugfix: fixed #11152 silder trigger no white theme --- components/layout/style/light.less | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/layout/style/light.less b/components/layout/style/light.less index 56835f8a67..bf9e53d931 100644 --- a/components/layout/style/light.less +++ b/components/layout/style/light.less @@ -3,7 +3,11 @@ &-light { background: @layout-sider-background-light; } - &-light > &-trigger { + &-light &-trigger { + color: @layout-trigger-color-light; + background: @layout-trigger-background-light; + } + &-light &-zero-width-trigger { color: @layout-trigger-color-light; background: @layout-trigger-background-light; } From af49a1806b37e97d7d189b2832dfca465f2a5fd2 Mon Sep 17 00:00:00 2001 From: Wei Zhu Date: Tue, 10 Jul 2018 21:10:48 +0800 Subject: [PATCH 05/17] docs: rewrite editable demo --- .../__tests__/__snapshots__/demo.test.js.snap | 44 ++-- components/table/demo/edit-cell.md | 222 +++++++++++------- 2 files changed, 157 insertions(+), 109 deletions(-) diff --git a/components/table/__tests__/__snapshots__/demo.test.js.snap b/components/table/__tests__/__snapshots__/demo.test.js.snap index 0a2b23be80..7e43d47d36 100644 --- a/components/table/__tests__/__snapshots__/demo.test.js.snap +++ b/components/table/__tests__/__snapshots__/demo.test.js.snap @@ -2746,26 +2746,20 @@ exports[`renders ./components/table/demo/edit-cell.md correctly 1`] = ` class="ant-table-tbody" > -
-
- Edward King 0 - -
+ + Edward King 0
-
-
- Edward King 1 - -
+ + Edward King 1
( + + + +); + +const EditableFormRow = Form.create()(EditableRow); class EditableCell extends React.Component { state = { - value: this.props.value, - editable: false, + editing: false, } - handleChange = (e) => { - const value = e.target.value; - this.setState({ value }); - } - - check = () => { - this.setState({ editable: false }); - if (this.props.onChange) { - this.props.onChange(this.state.value); + componentDidMount() { + if (this.props.editable) { + document.addEventListener('click', this.handleClickOutside, true); } } - edit = () => { - this.setState({ editable: true }); + componentWillUnmount() { + if (this.props.editable) { + document.removeEventListener('click', this.handleClickOutside, true); + } + } + + toggleEdit = () => { + const editing = !this.state.editing; + this.setState({ editing }, () => { + if (editing) { + this.input.focus(); + } + }); + } + + handleClickOutside = (e) => { + const { editing } = this.state; + if (editing && this.cell !== e.target && !this.cell.contains(e.target)) { + this.save(); + } + } + + save = () => { + const { record, handleSave } = this.props; + this.form.validateFields((error, values) => { + if (error) { + return; + } + this.toggleEdit(); + handleSave({ ...record, ...values }); + }); } render() { - const { value, editable } = this.state; + const { editing } = this.state; + const { + editable, + dataIndex, + title, + record, + index, + handleSave, + ...restProps + } = this.props; return ( -
- { - editable ? ( - -)} - /> - ) : ( -
- {value || ' '} - -
- ) - } -
+ (this.cell = node)} {...restProps}> + {editable ? ( + + {(form) => { + this.form = form; + return ( + editing ? ( + + {form.getFieldDecorator(dataIndex, { + rules: [{ + required: true, + message: `${title} is required.`, + }], + initialValue: record[dataIndex], + })( + (this.input = node)} + onPressEnter={this.save} + /> + )} + + ) : ( +
+ {restProps.children} +
+ ) + ); + }} +
+ ) : restProps.children} + ); } } @@ -79,12 +130,7 @@ class EditableTable extends React.Component { title: 'name', dataIndex: 'name', width: '30%', - render: (text, record) => ( - - ), + editable: true, }, { title: 'age', dataIndex: 'age', @@ -98,7 +144,7 @@ class EditableTable extends React.Component { return ( this.state.dataSource.length > 1 ? ( - this.onDelete(record.key)}> + this.handleDelete(record.key)}> Delete ) : null @@ -122,18 +168,7 @@ class EditableTable extends React.Component { }; } - onCellChange = (key, dataIndex) => { - return (value) => { - const dataSource = [...this.state.dataSource]; - const target = dataSource.find(item => item.key === key); - if (target) { - target[dataIndex] = value; - this.setState({ dataSource }); - } - }; - } - - onDelete = (key) => { + handleDelete = (key) => { const dataSource = [...this.state.dataSource]; this.setState({ dataSource: dataSource.filter(item => item.key !== key) }); } @@ -152,15 +187,52 @@ class EditableTable extends React.Component { }); } + handleSave = (row) => { + const newData = [...this.state.dataSource]; + const index = newData.findIndex(item => row.key === item.key); + const item = newData[index]; + newData.splice(index, 1, { + ...item, + ...row, + }); + this.setState({ dataSource: newData }); + } + render() { const { dataSource } = this.state; - const columns = this.columns; + const components = { + body: { + row: EditableFormRow, + cell: EditableCell, + }, + }; + const columns = this.columns.map((col) => { + if (!col.editable) { + return col; + } + return { + ...col, + onCell: record => ({ + record, + editable: col.editable, + dataIndex: col.dataIndex, + title: col.title, + handleSave: this.handleSave, + }), + }; + }); return (
- +
'editable-row'} + bordered + dataSource={dataSource} + columns={columns} + /> ); } @@ -174,26 +246,14 @@ ReactDOM.render(, mountNode); position: relative; } -.editable-cell-icon, -.editable-cell-icon-check { +.editable-cell-value-wrap { + padding: 5px 12px; cursor: pointer; } -.editable-cell-icon { - line-height: 14px; - position: absolute; - right: 0; - top: 50%; - margin-top: -7px; - display: none; -} - -td:hover .editable-cell-icon { - display: inline-block; -} - -.editable-cell-icon:hover, -.editable-cell-icon-check:hover { - color: #108ee9; +.editable-row:hover .editable-cell-value-wrap { + border: 1px solid #d9d9d9; + border-radius: 4px; + padding: 4px 11px; } ```` From 9f1c8bc18413b066dc4b0ff65ce74cc59c2cb99f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=B1=E5=B8=83?= Date: Thu, 5 Jul 2018 10:48:15 +0800 Subject: [PATCH 06/17] =?UTF-8?q?dva=20=E7=9B=B8=E5=85=B3=E5=A4=96?= =?UTF-8?q?=E9=93=BE=E6=9B=B4=E6=96=B0=E5=88=B0=20dva=20=E5=AE=98=E7=BD=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 理解 dva 的 [8 个概念]、查看 [dva 知识地图] 的链接都404了,顺便更新到 dva 官网去 --- docs/react/practical-projects.zh-CN.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/react/practical-projects.zh-CN.md b/docs/react/practical-projects.zh-CN.md index 3ae7dafcd9..ec0ddd4c2b 100644 --- a/docs/react/practical-projects.zh-CN.md +++ b/docs/react/practical-projects.zh-CN.md @@ -270,9 +270,9 @@ File sizes after gzip: 你可以: -- 访问 [dva 官网](https://github.com/dvajs/dva) -- 理解 dva 的 [8 个概念](https://github.com/dvajs/dva/blob/master/docs/Concepts_zh-CN.md) ,以及他们是如何串起来的 -- 掌握 dva 的[所有 API](https://github.com/dvajs/dva/blob/master/docs/API_zh-CN.md) -- 查看 [dva 知识地图](https://github.com/dvajs/dva-knowledgemap) ,包含 ES6, React, dva 等所有基础知识 +- 访问 [dva 官网](https://dvajs.com/) +- 理解 dva 的 [8 个概念](https://dvajs.com/guide/concepts.html) ,以及他们是如何串起来的 +- 掌握 dva 的[所有 API](https://dvajs.com/api/) +- 查看 [dva 知识地图](https://dvajs.com/knowledgemap/) ,包含 ES6, React, dva 等所有基础知识 - 查看 [更多 FAQ](https://github.com/dvajs/dva/issues?q=is%3Aissue+is%3Aclosed+label%3Afaq),看看别人通常会遇到什么问题 - 如果你基于 dva-cli 创建项目,最好了解他的 [配置方式](https://github.com/sorrycc/roadhog/blob/master/README_zh-cn.md#配置) From e47b82d22a12faa37dd3808aacf5e939310e1e4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=B1=E5=B8=83?= Date: Tue, 10 Jul 2018 22:18:35 +0800 Subject: [PATCH 07/17] Update dva related links for English docs Update dva related links for English docs --- docs/react/practical-projects.en-US.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/react/practical-projects.en-US.md b/docs/react/practical-projects.en-US.md index cd30ad2687..91c4bec8dc 100644 --- a/docs/react/practical-projects.en-US.md +++ b/docs/react/practical-projects.en-US.md @@ -268,9 +268,9 @@ We have completed a simple application, but you may still have lots of questions You can: -- Visit [dva official website](https://github.com/dvajs/dva). -- Be familiar with the [8 Concepts](https://github.com/dvajs/dva/blob/master/docs/Concepts.md), and understand how they are connected together -- Know all [dva APIs](https://github.com/dvajs/dva/blob/master/docs/API.md) -- Checkout [dva knowledgemap](https://github.com/dvajs/dva-knowledgemap), including all the basic knowledge with ES6, React, dva +- Visit [dva official website](https://dvajs.com/). +- Be familiar with the [8 Concepts](https://dvajs.com/guide/concepts.html), and understand how they are connected together +- Know all [dva APIs](https://dvajs.com/api/) +- Checkout [dva knowledgemap](https://dvajs.com/knowledgemap/), including all the basic knowledge with ES6, React, dva - Checkout [more FAQ](https://github.com/dvajs/dva/issues?q=is%3Aissue+is%3Aclosed+label%3Afaq) - If your project is created with [dva-cli](https://github.com/dvajs/dva-cli) , checkout how to [Configure it](https://github.com/sorrycc/roadhog#configuration) From 47884320efe81f1603f5444c611bb73278625fda Mon Sep 17 00:00:00 2001 From: Wei Zhu Date: Wed, 11 Jul 2018 10:36:24 +0800 Subject: [PATCH 08/17] docs: remove only --- components/table/demo/edit-cell.md | 1 - 1 file changed, 1 deletion(-) diff --git a/components/table/demo/edit-cell.md b/components/table/demo/edit-cell.md index fac7ee250e..da61046cd0 100644 --- a/components/table/demo/edit-cell.md +++ b/components/table/demo/edit-cell.md @@ -3,7 +3,6 @@ order: 22 title: en-US: Editable Cells zh-CN: 可编辑单元格 -only: true --- ## zh-CN From ea42973ace6699b31eaec46fdb34f3ead55f4e8a Mon Sep 17 00:00:00 2001 From: Wei Zhu Date: Wed, 11 Jul 2018 11:16:37 +0800 Subject: [PATCH 09/17] mock React.createContext --- tests/__mocks__/react.js | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 tests/__mocks__/react.js diff --git a/tests/__mocks__/react.js b/tests/__mocks__/react.js new file mode 100644 index 0000000000..072da8061c --- /dev/null +++ b/tests/__mocks__/react.js @@ -0,0 +1,11 @@ +const React = require.requireActual('react'); + +if (!React.createContext) { + React.createContext = () => { + const Provider = ({ children }) => children; + const Consumer = ({ children }) => children(); + return { Provider, Consumer }; + }; +} + +module.exports = React; From e3ef74c3e79ec75688ddf323afdc3095a8420910 Mon Sep 17 00:00:00 2001 From: mofelee Date: Wed, 11 Jul 2018 13:12:12 +0800 Subject: [PATCH 10/17] fix "Cannot find module './locale'" bug --- components/locale-provider/index.zh-CN.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/locale-provider/index.zh-CN.md b/components/locale-provider/index.zh-CN.md index 07031eb080..6be36f4435 100644 --- a/components/locale-provider/index.zh-CN.md +++ b/components/locale-provider/index.zh-CN.md @@ -15,7 +15,7 @@ LocaleProvider 使用 React 的 [context](https://facebook.github.io/react/docs/ ```jsx import { LocaleProvider } from 'antd'; import zh_CN from 'antd/lib/locale-provider/zh_CN'; -import 'moment/src/locale/zh-cn'; +import 'moment/locale/zh-cn'; // import 'moment/locale/zh-cn'; if you are using webpack 1 ... From 4b045fc43f1a82b8bbdfcb958a78e2ed77306df8 Mon Sep 17 00:00:00 2001 From: Wei Zhu Date: Wed, 11 Jul 2018 15:17:15 +0800 Subject: [PATCH 11/17] Revert "docs: update moment locale usage" This reverts commit 89228118afa6d8a5562dbf5a4572567c9be1f53a. The original purpose to import locale from src is that some projects adding `jsnext:main` to the `resolve.mainFields` config of webpack which leads webpack load moment from `src/moment.js`. But import from `locale` should works for most projects. --- components/date-picker/index.en-US.md | 3 +-- components/date-picker/index.zh-CN.md | 3 +-- components/locale-provider/index.en-US.md | 3 +-- components/locale-provider/index.zh-CN.md | 2 -- 4 files changed, 3 insertions(+), 8 deletions(-) diff --git a/components/date-picker/index.en-US.md b/components/date-picker/index.en-US.md index d00c854470..4db4a5ba28 100644 --- a/components/date-picker/index.en-US.md +++ b/components/date-picker/index.en-US.md @@ -36,8 +36,7 @@ import locale from 'antd/lib/date-picker/locale/zh_CN'; ```jsx // The default locale is en-US, if you want to use other locale, just set locale in entry file globaly. import moment from 'moment'; -import 'moment/src/locale/zh-cn'; -// import 'moment/locale/zh-cn'; if you are using webpack 1 +import 'moment/locale/zh-cn'; ``` diff --git a/components/date-picker/index.zh-CN.md b/components/date-picker/index.zh-CN.md index 566559df4e..e9ae8f292c 100644 --- a/components/date-picker/index.zh-CN.md +++ b/components/date-picker/index.zh-CN.md @@ -37,8 +37,7 @@ import locale from 'antd/lib/date-picker/locale/zh_CN'; ```jsx // 默认语言为 en-US,如果你需要设置其他语言,推荐在入口文件全局设置 locale import moment from 'moment'; -import 'moment/src/locale/zh-cn'; -// import 'moment/locale/zh-cn'; if you are using webpack 1 +mport 'moment/locale/zh-cn'; ``` diff --git a/components/locale-provider/index.en-US.md b/components/locale-provider/index.en-US.md index f8784b83db..b77be089e8 100644 --- a/components/locale-provider/index.en-US.md +++ b/components/locale-provider/index.en-US.md @@ -14,8 +14,7 @@ title: LocaleProvider ```jsx import { LocaleProvider } from 'antd'; import fr_FR from 'antd/lib/locale-provider/fr_FR'; -import 'moment/src/locale/fr'; -// import 'moment/locale/fr'; if you are using webpack 1 +import 'moment/locale/fr'; ... diff --git a/components/locale-provider/index.zh-CN.md b/components/locale-provider/index.zh-CN.md index 6be36f4435..80b6f2c9e3 100644 --- a/components/locale-provider/index.zh-CN.md +++ b/components/locale-provider/index.zh-CN.md @@ -16,8 +16,6 @@ LocaleProvider 使用 React 的 [context](https://facebook.github.io/react/docs/ import { LocaleProvider } from 'antd'; import zh_CN from 'antd/lib/locale-provider/zh_CN'; import 'moment/locale/zh-cn'; -// import 'moment/locale/zh-cn'; if you are using webpack 1 - ... return ; From 46add091cadca0b833679b3e45d40ec970403b88 Mon Sep 17 00:00:00 2001 From: Gao Jiangmiao Date: Wed, 11 Jul 2018 01:40:31 +0800 Subject: [PATCH 12/17] Fix typo in in use-in-typescript.md --- docs/react/use-in-typescript.en-US.md | 9 +++++---- docs/react/use-in-typescript.zh-CN.md | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/docs/react/use-in-typescript.en-US.md b/docs/react/use-in-typescript.en-US.md index 5d3d34689a..89ddf54ab3 100644 --- a/docs/react/use-in-typescript.en-US.md +++ b/docs/react/use-in-typescript.en-US.md @@ -14,7 +14,8 @@ Ensure your system has installed latest version of [yarn](https://yarnpkg.com) o Create a new project named `antd-demo-ts` using yarn. ```bash -$ yarn create react-app antd-demo-ts --scripts-version=react-scripts-ts +$ yarn global add create-react-app +$ create-react-app antd-demo-ts --scripts-version=react-scripts-ts ``` If you are using npm (we will use yarn in the following instructions, it's ok to replace yarn with npm) @@ -90,11 +91,11 @@ $ yarn add react-app-rewired --dev ```diff /* package.json */ "scripts": { -- "start": "react-scripts start", +- "start": "react-scripts-ts start", + "start": "react-app-rewired start --scripts-version react-scripts-ts", -- "build": "react-scripts build", +- "build": "react-scripts-ts build", + "build": "react-app-rewired build --scripts-version react-scripts-ts", -- "test": "react-scripts test --env=jsdom", +- "test": "react-scripts-ts test --env=jsdom", + "test": "react-app-rewired test --env=jsdom --scripts-version react-scripts-ts", } ``` diff --git a/docs/react/use-in-typescript.zh-CN.md b/docs/react/use-in-typescript.zh-CN.md index fc6c102697..83ed810266 100644 --- a/docs/react/use-in-typescript.zh-CN.md +++ b/docs/react/use-in-typescript.zh-CN.md @@ -14,7 +14,8 @@ title: 在 TypeScript 中使用 使用 yarn 创建项目。 ```bash -$ yarn create react-app antd-demo-ts --scripts-version=react-scripts-ts +$ yarn global add create-react-app +$ create-react-app antd-demo-ts --scripts-version=react-scripts-ts ``` 如果你使用的是 npm(接下来我们都会用 yarn 作为例子,如果你习惯用 npm 也没问题)。 @@ -89,11 +90,11 @@ $ yarn add react-app-rewired --dev ```diff /* package.json */ "scripts": { -- "start": "react-scripts start", +- "start": "react-scripts-ts start", + "start": "react-app-rewired start --scripts-version react-scripts-ts", -- "build": "react-scripts build", +- "build": "react-scripts-ts build", + "build": "react-app-rewired build --scripts-version react-scripts-ts", -- "test": "react-scripts test --env=jsdom", +- "test": "react-scripts-ts test --env=jsdom", + "test": "react-app-rewired test --env=jsdom --scripts-version react-scripts-ts", } ``` From 690804d3104c31a18e811c828172716b0feda6d7 Mon Sep 17 00:00:00 2001 From: Gao Jiangmiao Date: Wed, 11 Jul 2018 15:51:07 +0800 Subject: [PATCH 13/17] Revert yarn command in use-in-typescript.md --- docs/react/use-in-typescript.en-US.md | 3 +-- docs/react/use-in-typescript.zh-CN.md | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/react/use-in-typescript.en-US.md b/docs/react/use-in-typescript.en-US.md index 89ddf54ab3..1b925ab416 100644 --- a/docs/react/use-in-typescript.en-US.md +++ b/docs/react/use-in-typescript.en-US.md @@ -14,8 +14,7 @@ Ensure your system has installed latest version of [yarn](https://yarnpkg.com) o Create a new project named `antd-demo-ts` using yarn. ```bash -$ yarn global add create-react-app -$ create-react-app antd-demo-ts --scripts-version=react-scripts-ts +$ yarn create react-app antd-demo-ts --scripts-version=react-scripts-ts ``` If you are using npm (we will use yarn in the following instructions, it's ok to replace yarn with npm) diff --git a/docs/react/use-in-typescript.zh-CN.md b/docs/react/use-in-typescript.zh-CN.md index 83ed810266..667d64b548 100644 --- a/docs/react/use-in-typescript.zh-CN.md +++ b/docs/react/use-in-typescript.zh-CN.md @@ -14,8 +14,7 @@ title: 在 TypeScript 中使用 使用 yarn 创建项目。 ```bash -$ yarn global add create-react-app -$ create-react-app antd-demo-ts --scripts-version=react-scripts-ts +$ yarn create react-app antd-demo-ts --scripts-version=react-scripts-ts ``` 如果你使用的是 npm(接下来我们都会用 yarn 作为例子,如果你习惯用 npm 也没问题)。 From 2d5949f31dbb84df2263a836adc1e6c43f6b331d Mon Sep 17 00:00:00 2001 From: Wei Zhu Date: Wed, 11 Jul 2018 19:31:36 +0800 Subject: [PATCH 14/17] test: use render for snapshot --- .../__snapshots__/index.test.js.snap | 200 +++++------------- components/tabs/__tests__/index.test.js | 4 +- 2 files changed, 57 insertions(+), 147 deletions(-) diff --git a/components/tabs/__tests__/__snapshots__/index.test.js.snap b/components/tabs/__tests__/__snapshots__/index.test.js.snap index cbff9960bc..208252aaa0 100644 --- a/components/tabs/__tests__/__snapshots__/index.test.js.snap +++ b/components/tabs/__tests__/__snapshots__/index.test.js.snap @@ -1,164 +1,74 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Tabs tabPosition remove card 1`] = ` - -
- - xxx -
- } - inkBarAnimated={true} - key="tabBar" - onKeyDown={[Function]} - onNextClick={[Function]} - onPrevClick={[Function]} - onTabClick={[Function]} - panels={ - - foo - - } - prefixCls="ant-tabs" - scrollAnimated={true} - styles={Object {}} - tabBarPosition="left" + + + + + + +
- - - - - - -
-
-
-
-
- foo -
-
-
-
-
-
- xxx -
-
- - -
-
+ - +
-
+
-
-
+
+ xxx +
+ +
+
+ foo +
+
+ `; diff --git a/components/tabs/__tests__/index.test.js b/components/tabs/__tests__/index.test.js index b0e89b051c..e07a530f47 100644 --- a/components/tabs/__tests__/index.test.js +++ b/components/tabs/__tests__/index.test.js @@ -1,5 +1,5 @@ import React from 'react'; -import { mount } from 'enzyme'; +import { mount, render } from 'enzyme'; import Tabs from '..'; const { TabPane } = Tabs; @@ -31,7 +31,7 @@ describe('Tabs', () => { describe('tabPosition', () => { it('remove card', () => { - const wrapper = mount( + const wrapper = render( foo From 722b24b813fcc90b9846b8fcad19df7ede01d8fc Mon Sep 17 00:00:00 2001 From: Zhiqiang Gong Date: Wed, 11 Jul 2018 19:39:41 +0800 Subject: [PATCH 15/17] add disabled prop (#11188) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit First of all, thank you for your contribution! :-) Please makes sure that these checkboxes are checked before submitting your PR, thank you! * [x] Make sure that you propose PR to right branch: bugfix for `master`, feature for latest active branch `feature-x.x`. * [x] Make sure that you follow antd's [code convention](https://github.com/ant-design/ant-design/wiki/Code-convention-for-antd). * [x] Run `npm run lint` and fix those errors before submitting in order to keep consistent code style. * [x] Rebase before creating a PR to keep commit history clear. * [x] Add some descriptions and refer relative issues for you PR. Extra checklist: **if** *isBugFix* **:** * [x] Make sure that you add at least one unit test for the bug which you had fixed. **elif** *isNewFeature* **:** * [ ] Update API docs for the component. * [ ] Update/Add demo to demonstrate new feature. * [ ] Update TypeScript definition for the component. * [ ] Add unit tests for the feature. tslint检测时报错 类型“IntrinsicAttributes & IntrinsicClassAttributes & Readonly<{ children?: ReactNode; }> & Read...”上不存在属性“disabled”。 --- components/tree/index.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/tree/index.tsx b/components/tree/index.tsx index 70ed6963d4..ef9ac3d25d 100644 --- a/components/tree/index.tsx +++ b/components/tree/index.tsx @@ -59,6 +59,8 @@ export interface TreeProps { checkStrictly?: boolean; /** 是否支持选中 */ checkable?: boolean; + /** 是否禁用树 */ + disabled?: boolean; /** 默认展开所有树节点 */ defaultExpandAll?: boolean; /** 默认展开指定的树节点 */ From 00afce3a4bf3085fe8309435a03d2597a519bef8 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 11 Jul 2018 20:09:58 +0800 Subject: [PATCH 16/17] Improve design of RangePicker presets link --- components/date-picker/RangePicker.tsx | 6 ++++-- components/date-picker/__tests__/RangePicker.test.js | 10 +++++----- .../__tests__/__snapshots__/RangePicker.test.js.snap | 7 +++++-- components/date-picker/style/index.tsx | 1 + 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/components/date-picker/RangePicker.tsx b/components/date-picker/RangePicker.tsx index b9bebcc887..111fe4bee9 100644 --- a/components/date-picker/RangePicker.tsx +++ b/components/date-picker/RangePicker.tsx @@ -5,6 +5,7 @@ import RangeCalendar from 'rc-calendar/lib/RangeCalendar'; import RcDatePicker from 'rc-calendar/lib/Picker'; import classNames from 'classnames'; import Icon from '../icon'; +import Tag from '../tag'; import warning from '../_util/warning'; import interopDefault from '../_util/interopDefault'; import { RangePickerValue, RangePickerPresetRange } from './interface'; @@ -211,14 +212,15 @@ export default class RangePicker extends React.Component const operations = Object.keys(ranges || {}).map((range) => { const value = ranges[range]; return ( - this.handleRangeClick(value)} onMouseEnter={() => this.setState({ hoverValue: value })} onMouseLeave={this.handleRangeMouseLeave} > {range} - + ); }); const rangeNode = ( diff --git a/components/date-picker/__tests__/RangePicker.test.js b/components/date-picker/__tests__/RangePicker.test.js index 0678230a71..c26114c284 100644 --- a/components/date-picker/__tests__/RangePicker.test.js +++ b/components/date-picker/__tests__/RangePicker.test.js @@ -50,7 +50,7 @@ describe('RangePicker', () => { ); const rangeCalendarWrapper = mount(wrapper.find('Trigger').instance().getComponent()); - rangeCalendarWrapper.find('.ant-calendar-range-quick-selector a') + rangeCalendarWrapper.find('.ant-calendar-range-quick-selector Tag') .simulate('click'); expect(render(wrapper.find('Trigger').instance().getComponent())) .toMatchSnapshot(); @@ -69,7 +69,7 @@ describe('RangePicker', () => { ); let rangeCalendarWrapper = mount(wrapper.find('Trigger').instance().getComponent()); - rangeCalendarWrapper.find('.ant-calendar-range-quick-selector a') + rangeCalendarWrapper.find('.ant-calendar-range-quick-selector Tag') .simulate('mouseEnter'); rangeCalendarWrapper = mount(wrapper.find('Trigger').instance().getComponent()); expect(rangeCalendarWrapper.find('.ant-calendar-selected-day').length).toBe(2); @@ -152,7 +152,7 @@ describe('RangePicker', () => { /> ); wrapper.find('.ant-calendar-picker-input').simulate('click'); - wrapper.find('.ant-calendar-range-quick-selector a').simulate('click'); + wrapper.find('.ant-calendar-range-quick-selector Tag').simulate('click'); expect( wrapper.find('.ant-calendar-range-picker-input').first().getDOMNode().value ).toBe(range[0].format(format)); @@ -171,7 +171,7 @@ describe('RangePicker', () => { /> ); wrapper.find('.ant-calendar-picker-input').simulate('click'); - wrapper.find('.ant-calendar-range-quick-selector a').simulate('click'); + wrapper.find('.ant-calendar-range-quick-selector Tag').simulate('click'); expect( wrapper.find('.ant-calendar-range-picker-input').first().getDOMNode().value ).toBe(range[0].format(format)); @@ -200,7 +200,7 @@ describe('RangePicker', () => { /> ); wrapper.find('.ant-calendar-picker-input').simulate('click'); - wrapper.find('.ant-calendar-range-quick-selector a').simulate('click'); + wrapper.find('.ant-calendar-range-quick-selector Tag').simulate('click'); expect(handleOk).toBeCalledWith(range); }); diff --git a/components/date-picker/__tests__/__snapshots__/RangePicker.test.js.snap b/components/date-picker/__tests__/__snapshots__/RangePicker.test.js.snap index 0f1af11395..ba622d9acf 100644 --- a/components/date-picker/__tests__/__snapshots__/RangePicker.test.js.snap +++ b/components/date-picker/__tests__/__snapshots__/RangePicker.test.js.snap @@ -2990,9 +2990,12 @@ exports[`RangePicker switch to corresponding month panel when click presetted ra