Merge from master

This commit is contained in:
afc163 2017-08-21 21:02:57 +08:00
commit dc7dfd38c6
18 changed files with 194 additions and 28 deletions

View File

@ -17,6 +17,29 @@ If you want to read change logs before `2.0.0`, please visit [GitHub](https://gi
---
## 2.12.7
`2017-08-21`
- antd of Angular@4.0, [ng-zorro-antd](https://ng.ant.design) is open sourcing.
- Affix supports more scenes. [01d4acb](https://github.com/ant-design/ant-design/commit/01d4acb7a9b030be3552b4ca19b4e899dc2bb7c7)
- Fix that AutoComplete children ref doesn't work. [#6814](https://github.com/ant-design/ant-design/issues/6814)
- Button
- Improve the logic to insert space in Chinese characters. [59b11f3](https://github.com/ant-design/ant-design/commit/59b11f3b480d43cb32fb24e351cb4c4dd569243c)
- Fix that `event.target` of click is not `button`. [#7034](https://github.com/ant-design/ant-design/issues/7034)
- Fix that Carousel's `innerSlider` doesn't exist. [#7191](https://github.com/ant-design/ant-design/issues/7191)
- Fix the style of button in DatePicker. [ad6dbcb](https://github.com/ant-design/ant-design/commit/ad6dbcb9c6dac407a38f2391d3e5fa1d8ae1cfab)
- Fix TypeScript definition of Form.[#7245](https://github.com/ant-design/ant-design/pull/7245)
- Fix TypeScript definition of InputNumber. [#7257](https://github.com/ant-design/ant-design/issues/7257)
- Fix missing collapse animation of `Layout.Sider` in IE11. [#6349](https://github.com/ant-design/ant-design/issues/6349)
- Fix typo of Spanish locale of LocaleProvider. [#7234](https://github.com/ant-design/ant-design/pull/7234) [@ramsesmoreno](https://github.com/ramsesmoreno)
- Fix that notification's default placement should not be overrided. [#5895](https://github.com/ant-design/ant-design/issues/5895)
- Fix disabled style of button in Pagination. [cf3c0aa](https://github.com/ant-design/ant-design/commit/cf3c0aac43e2825bfd85ca3b8abbf4742e504260)
- Fix that wrong exports of Select which cause webpack build error. [#7222](https://github.com/ant-design/ant-design/issues/7222)
- Fix that Tabs should show arrow buttons while resize its container. [#7231](https://github.com/ant-design/ant-design/issues/7231) [#7210](https://github.com/ant-design/ant-design/issues/7210)
- Fix style of Timeline which has only one `Timeline.Item`. [#7214](https://github.com/ant-design/ant-design/issues/7214)
- Fix wrong behavior of Upload when uid is 0. [#7269](https://github.com/ant-design/ant-design/issues/7269)
## 2.12.6
`2017-08-11`

View File

@ -17,6 +17,29 @@ timeline: true
---
## 2.12.7
`2017-08-21`
- Angular@4.0 版 antd [ng-zorro-antd](https://ng.ant.design) 开源。
- 优化 Affix 支持的场景。[01d4acb](https://github.com/ant-design/ant-design/commit/01d4acb7a9b030be3552b4ca19b4e899dc2bb7c7)
- 修复 AutoComplete children ref 失效的问题。[#6814](https://github.com/ant-design/ant-design/issues/6814)
- Button
- 优化自动在中文字符中间插入空格的逻辑。[59b11f3](https://github.com/ant-design/ant-design/commit/59b11f3b480d43cb32fb24e351cb4c4dd569243c)
- 修复点击事件的 `event.target` 不是 button 的问题。[#7034](https://github.com/ant-design/ant-design/issues/7034)
- 修复 Carousel 的 `innerSlider` 引用问题。[#7191](https://github.com/ant-design/ant-design/issues/7191)
- 修复 DatePicker 中的按钮样式。[ad6dbcb](https://github.com/ant-design/ant-design/commit/ad6dbcb9c6dac407a38f2391d3e5fa1d8ae1cfab)
- 修复 Form TypeScript definition。[#7245](https://github.com/ant-design/ant-design/pull/7245)
- 修复 InputNumber 的 TypeScript definition。[#7257](https://github.com/ant-design/ant-design/issues/7257)
- 修复 `Layout.Sider` 在 IE11 下没有折叠动画的问题。[#6349](https://github.com/ant-design/ant-design/issues/6349)
- 修复 LocaleProvider 西班牙语的拼写问题。[#7234](https://github.com/ant-design/ant-design/pull/7234) [@ramsesmoreno](https://github.com/ramsesmoreno)
- 修复 notification 默认 placement 会被覆盖的问题。[#5895](https://github.com/ant-design/ant-design/issues/5895)
- 修复 Pagination 按钮的 disabled 样式。[cf3c0aa](https://github.com/ant-design/ant-design/commit/cf3c0aac43e2825bfd85ca3b8abbf4742e504260)
- 修复 Select exports 导致的 webpack 构建错误的问题。[#7222](https://github.com/ant-design/ant-design/issues/7222)
- 修复 Tabs 在父容器宽度动态变化时切换按钮没有出现的问题。[#7231](https://github.com/ant-design/ant-design/issues/7231) [#7210](https://github.com/ant-design/ant-design/issues/7210)
- 修复 Timeline 在只有一个 `Timeline.Item` 时的样式问题。[#7214](https://github.com/ant-design/ant-design/issues/7214)
- 修复 Upload 在 uid 为 0 时的错误行为。[#7269](https://github.com/ant-design/ant-design/issues/7269)
## 2.12.6
`2017-08-11`

View File

@ -27,7 +27,7 @@ You can get the menu list by `antd.Menu`, and set a callback function `onSelect`
> Warning: You must set a unique `key` for `Menu.Item`.
> Remove the highlighted style after click menu item via `<Menu selectedKey={[]}>`.
> Remove the highlighted style after click menu item via `<Menu selectedKeys={[]}>`.
### Dropdown.Button

View File

@ -28,7 +28,7 @@ title: Dropdown
> 注意: Menu.Item 必须设置唯一的 key 属性。
> 如果希望去掉菜单选中的背景效果,可以指定 `<Menu selectedKey={[]}>`.
> 如果希望去掉菜单选中的背景效果,可以指定 `<Menu selectedKeys={[]}>`.
### Dropdown.Button

View File

@ -59,7 +59,7 @@ The following `options` are available:
| Property | Description | Type |
|-----------|------------------------------------------|------------|
| onFieldsChange | Specify a function that will be called when the value a `Form.Item` gets changed. Usage example: saving the field's value to Redux store. | Function(props, fields) |
| mapPropsToFields | Convert props to corresponding field value. Usage example: reading the values from Redux store. | Function(props): Object{ fieldName: Object{ value } } |
| mapPropsToFields | Convert props to field value. Usage example: reading the values from Redux store. | Function(props): Object{ fieldName: Object{ value } } |
| onValuesChange | A handler while value of any field is changed | (props, values) => void |
If the form has been decorated by `Form.create` then it has `this.props.form` property. `this.props.form` provides some APIs as follows:
@ -87,9 +87,9 @@ If the form has been decorated by `Form.create` then it has `this.props.form` pr
After wrapped by `getFieldDecorator`, `value`(or other property defined by `valuePropName`) `onChange`(or other property defined by `trigger`) props will be added to form controlsthe flow of form data will be handled by Form which will cause:
1. You don't need to use `onChange` to collect data, but you still can listen to `onChange`(and so on) events.
1. You shouldn't to use `onChange` to collect data, but you still can listen to `onChange`(and so on) events.
2. You can not set value of form control via `value` `defaultValue` prop, and you should set default value with `initialValue` in `getFieldDecorator` instead.
3. You don't need to call `setState` manually, please use `this.props.form.setFieldsValue` to change value programmatically.
3. You shouldn't to call `setState` manually, please use `this.props.form.setFieldsValue` to change value programmatically.
#### Special attention

View File

@ -61,7 +61,7 @@ CustomizedForm = Form.create({})(CustomizedForm);
| 参数 | 说明 | 类型 |
|-----------|------------------------------------------|------------|
| onFieldsChange | 当 `Form.Item` 子节点的值发生改变时触发,可以把对应的值转存到 Redux store | Function(props, fields) |
| mapPropsToFields | 把 props 转为对应的值,可用于把 Redux store 中的值读出 | Function(props): Object{ fieldName: Object{ value } } |
| mapPropsToFields | 把父组件的属性映射到表单项上(可用于把 Redux store 中的值读出) | Function(props): Object{ fieldName: Object{ value } } |
| onValuesChange | 任一表单域的值发生改变时的回调 | (props, values) => void |
经过 `Form.create` 包装的组件将会自带 `this.props.form` 属性,`this.props.form` 提供的 API 如下:
@ -88,9 +88,9 @@ CustomizedForm = Form.create({})(CustomizedForm);
经过 `getFieldDecorator` 包装的控件,表单控件会自动添加 `value`(或 `valuePropName` 指定的其他属性) `onChange`(或 `trigger` 指定的其他属性),数据同步将被 Form 接管,这会导致以下结果:
1. 你不再需要用 `onChange` 来做同步,但还是可以继续监听 `onChange` 等事件。
1. 你**不再需要也不应该**`onChange` 来做同步,但还是可以继续监听 `onChange` 等事件。
2. 你不能用控件的 `value` `defaultValue` 等属性来设置表单域的值,默认值可以用 `getFieldDecorator` 里的 `initialValue`
3. 你不需要`setState`,可以使用 `this.props.form.setFieldsValue` 来动态改变表单值。
3. 你不应该`setState`,可以使用 `this.props.form.setFieldsValue` 来动态改变表单值。
#### 特别注意

View File

@ -116,7 +116,7 @@ const columns = [{
选择功能的配置。
| 参数 | 说明 | 类型 | 默认值 |
|------------------|--------------------------|-----------------|---------------------|---------|
|------------------|--------------------------|-----------------|---------------------|
| type | 多选/单选,`checkbox` or `radio` | string | `checkbox` |
| selectedRowKeys | 指定选中项的 key 数组,需要和 onChange 进行配合 | string[] | [] |
| onChange | 选中项发生变化的时的回调 | Function(selectedRowKeys, selectedRows) | - |
@ -124,12 +124,12 @@ const columns = [{
| onSelect | 用户手动选择/取消选择某列的回调 | Function(record, selected, selectedRows) | - |
| onSelectAll | 用户手动选择/取消选择所有列的回调 | Function(selected, selectedRows, changeRows) | - |
| onSelectInvert | 用户手动选择反选的回调 | Function(selectedRows) | - |
| selections | 自定义选择项 [配置项](#selection), 设为 `true` 时显示默认选择项 | object[] | true | - |
| selections | 自定义选择项 [配置项](#selection), 设为 `true` 时显示默认选择项 | object[] | true |
### selection
| 参数 | 说明 | 类型 | 默认值 |
|------------------|--------------------------|-----------------|---------------------|---------|
|------------------|--------------------------|-----------------|---------------------|
| key | React 需要的 key建议设置 | string | - |
| text | 选择项显示的文字 | string\|React.ReactNode | - |
| onSelect | 选择项点击回调 | Function(changeableRowKeys) | - |

View File

@ -97,7 +97,6 @@ exports[`renders ./components/tabs/demo/basic.md correctly 1`] = `
exports[`renders ./components/tabs/demo/card.md correctly 1`] = `
<div
class="ant-tabs ant-tabs-top ant-tabs-card ant-tabs-no-animation"
type="card"
>
<div
class="ant-tabs-bar"
@ -194,7 +193,6 @@ exports[`renders ./components/tabs/demo/card-top.md correctly 1`] = `
>
<div
class="ant-tabs ant-tabs-top ant-tabs-card ant-tabs-no-animation"
type="card"
>
<div
class="ant-tabs-bar"
@ -310,7 +308,6 @@ exports[`renders ./components/tabs/demo/custom-add-trigger.md correctly 1`] = `
</div>
<div
class="ant-tabs ant-tabs-top ant-tabs-card ant-tabs-editable-card ant-tabs-no-animation"
type="editable-card"
>
<div
class="ant-tabs-bar"
@ -482,7 +479,6 @@ exports[`renders ./components/tabs/demo/disabled.md correctly 1`] = `
<div
aria-hidden="true"
class="ant-tabs-tabpane ant-tabs-tabpane-inactive"
disabled=""
role="tabpanel"
/>
<div
@ -497,7 +493,6 @@ exports[`renders ./components/tabs/demo/disabled.md correctly 1`] = `
exports[`renders ./components/tabs/demo/editable-card.md correctly 1`] = `
<div
class="ant-tabs ant-tabs-top ant-tabs-card ant-tabs-editable-card ant-tabs-no-animation"
type="editable-card"
>
<div
class="ant-tabs-bar"

View File

@ -22,7 +22,6 @@ exports[`Tabs tabPosition remove card 1`] = `
>
<div
className="ant-tabs ant-tabs-left ant-tabs-vertical ant-tabs-line"
onChange={[Function]}
style={Object {}}
>
<ScrollableInkTabBar

View File

@ -86,6 +86,45 @@ exports[`renders ./components/tree-select/demo/checkable.md correctly 1`] = `
</span>
`;
exports[`renders ./components/tree-select/demo/multiple.md correctly 1`] = `
<span
class="ant-select ant-select-enabled ant-select-allow-clear"
style="width:300px;"
>
<span
aria-autocomplete="list"
aria-haspopup="true"
class="ant-select-selection
ant-select-selection--multiple"
role="combobox"
>
<ul
class="ant-select-selection__rendered"
>
<li
class="ant-select-search ant-select-search--inline"
>
<span
class="ant-select-search__field__wrap"
>
<input
class="ant-select-search__field"
role="textbox"
value=""
/>
</span>
</li>
</ul>
<span
class="ant-select-search__field__placeholder"
style="display:block;"
>
Please select
</span>
</span>
</span>
`;
exports[`renders ./components/tree-select/demo/treeData.md correctly 1`] = `
<span
class="ant-select ant-select-enabled"

View File

@ -1,13 +1,13 @@
---
order: 2
order: 3
title:
zh-CN:
en-US: Multiple
zh-CN: 可勾
en-US: Checkable
---
## zh-CN
多选和勾选框功能。
使用勾选框实现多选功能。
## en-US
@ -58,7 +58,6 @@ class Demo extends React.Component {
treeData,
value: this.state.value,
onChange: this.onChange,
multiple: true,
treeCheckable: true,
showCheckedStrategy: SHOW_PARENT,
searchPlaceholder: 'Please select',

View File

@ -0,0 +1,56 @@
---
order: 1
title:
zh-CN: 多选
en-US: Multiple Selection
---
## zh-CN
多选的树选择。
## en-US
Multiple selection usage.
````jsx
import { TreeSelect } from 'antd';
const TreeNode = TreeSelect.TreeNode;
class Demo extends React.Component {
state = {
value: undefined,
}
onChange = (value) => {
console.log(arguments);
this.setState({ value });
}
render() {
return (
<TreeSelect
showSearch
style={{ width: 300 }}
value={this.state.value}
dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
placeholder="Please select"
allowClear
multiple
treeDefaultExpandAll
onChange={this.onChange}
>
<TreeNode value="parent 1" title="parent 1" key="0-1">
<TreeNode value="parent 1-0" title="parent 1-0" key="0-1-1">
<TreeNode value="leaf1" title="my leaf" key="random" />
<TreeNode value="leaf2" title="your leaf" key="random1" />
</TreeNode>
<TreeNode value="parent 1-1" title="parent 1-1" key="random2">
<TreeNode value="sss" title={<b style={{ color: '#08c' }}>sss</b>} key="random3" />
</TreeNode>
</TreeNode>
</TreeSelect>
);
}
}
ReactDOM.render(<Demo />, mountNode);
````

View File

@ -1,5 +1,5 @@
---
order: 1
order: 2
title:
zh-CN: 从数据直接生成
en-US: Generate form tree data

View File

@ -2,6 +2,8 @@ import React from 'react';
import { mount } from 'enzyme';
import Upload from '..';
const delay = timeout => new Promise(resolve => setTimeout(resolve, timeout));
const fileList = [{
uid: -1,
name: 'xxx.png',
@ -31,4 +33,30 @@ describe('Upload List', () => {
expect(imgNode.prop('src')).toBe(file.thumbUrl);
});
});
// https://github.com/ant-design/ant-design/issues/7269
it('should remove correct item when uid is 0', async () => {
const list = [{
uid: 0,
name: 'xxx.png',
status: 'done',
url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
thumbUrl: 'https://zos.alipayobjects.com/rmsportal/IQKRngzUuFzJzGzRJXUs.png',
}, {
uid: 1,
name: 'xxx.png',
status: 'done',
url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
thumbUrl: 'https://zos.alipayobjects.com/rmsportal/IQKRngzUuFzJzGzRJXUs.png',
}];
const wrapper = mount(
<Upload defaultFileList={list}>
<button>upload</button>
</Upload>
);
expect(wrapper.find('.ant-upload-list-item').length).toBe(2);
wrapper.find('.ant-upload-list-item').at(0).find('.anticon-cross').simulate('click');
await delay(400);
expect(wrapper.find('.ant-upload-list-item').length).toBe(1);
});
});

View File

@ -44,12 +44,12 @@ export function genPercentAdd() {
}
export function getFileItem(file, fileList) {
const matchKey = file.uid ? 'uid' : 'name';
const matchKey = file.uid !== undefined ? 'uid' : 'name';
return fileList.filter(item => item[matchKey] === file[matchKey])[0];
}
export function removeFileItem(file, fileList) {
const matchKey = file.uid ? 'uid' : 'name';
const matchKey = file.uid !== undefined ? 'uid' : 'name';
const removed = fileList.filter(item => item[matchKey] !== file[matchKey]);
if (removed.length === fileList.length) {
return null;

View File

@ -41,7 +41,7 @@ Following the Ant Design specification, we developed a React UI library `antd` t
## Version
- Stable: [![npm package](https://img.shields.io/npm/v/antd.svg?style=flat-square)](https://www.npmjs.org/package/antd)
- Beta: [![](https://cnpmjs.org/badge/v/antd.svg?&tag=beta&subject=npm)](https://www.npmjs.org/package/antd)
- Next: [![](https://cnpmjs.org/badge/v/antd.svg?&tag=next&subject=npm)](https://www.npmjs.org/package/antd)
You can subscribe to this feed for new version notifications: https://github.com/ant-design/ant-design/releases.atom

View File

@ -41,7 +41,7 @@ title: Ant Design of React
## 版本
- 稳定版:[![npm package](https://img.shields.io/npm/v/antd.svg?style=flat-square)](https://www.npmjs.org/package/antd)
- 开发版:[![](https://cnpmjs.org/badge/v/antd.svg?&tag=beta&subject=npm)](https://www.npmjs.org/package/antd)
- 预览版:[![](https://cnpmjs.org/badge/v/antd.svg?&tag=next&subject=npm)](https://www.npmjs.org/package/antd)
你可以订阅https://github.com/ant-design/ant-design/releases.atom 来获得稳定版发布的通知。

View File

@ -1,6 +1,10 @@
{
"name": "antd",
<<<<<<< HEAD
"version": "3.0.0-alpha.3",
=======
"version": "2.12.7",
>>>>>>> master
"title": "Ant Design",
"description": "An enterprise-class UI design language and React-based implementation",
"homepage": "http://ant.design/",
@ -80,7 +84,7 @@
"devDependencies": {
"@types/react": "^15.0.38",
"@types/react-dom": "~0.14.18",
"antd-tools": "~1.7.0",
"antd-tools": "~1.8.0",
"babel-cli": "^6.18.0",
"babel-eslint": "^7.1.0",
"babel-plugin-import": "^1.0.0",