Skip to content

Commit

Permalink
Merge branch 'master' into feature
Browse files Browse the repository at this point in the history
  • Loading branch information
chenshuai2144 committed Jun 28, 2019
2 parents 95c0a4e + c3a3db3 commit 722b39e
Show file tree
Hide file tree
Showing 24 changed files with 262 additions and 385 deletions.
5 changes: 0 additions & 5 deletions .remarkrc.js

This file was deleted.

11 changes: 10 additions & 1 deletion components/checkbox/Group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,16 @@ class CheckboxGroup extends React.Component<CheckboxGroupProps, CheckboxGroupSta
}
const onChange = this.props.onChange;
if (onChange) {
onChange(value.filter(val => registeredValues.indexOf(val) !== -1));
const options = this.getOptions();
onChange(
value
.filter(val => registeredValues.indexOf(val) !== -1)
.sort((a, b) => {
const indexA = options.findIndex(opt => opt.value === a);
const indexB = options.findIndex(opt => opt.value === b);
return indexA - indexB;
}),
);
}
};

Expand Down
34 changes: 34 additions & 0 deletions components/checkbox/__tests__/group.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,38 @@ describe('CheckboxGroup', () => {

expect(onChange).toHaveBeenCalledWith([2]);
});

// https://github.com/ant-design/ant-design/issues/17297
it('onChange should keep the order of the original values', () => {
const onChange = jest.fn();
const wrapper = mount(
<Checkbox.Group onChange={onChange}>
<Checkbox key={1} value={1} />
<Checkbox key={2} value={2} />
<Checkbox key={3} value={3} />
<Checkbox key={4} value={4} />
</Checkbox.Group>,
);

wrapper
.find('.ant-checkbox-input')
.at(0)
.simulate('change');
expect(onChange).toHaveBeenCalledWith([1]);
wrapper
.find('.ant-checkbox-input')
.at(1)
.simulate('change');
expect(onChange).toHaveBeenCalledWith([1, 2]);
wrapper
.find('.ant-checkbox-input')
.at(0)
.simulate('change');
expect(onChange).toHaveBeenCalledWith([2]);
wrapper
.find('.ant-checkbox-input')
.at(0)
.simulate('change');
expect(onChange).toHaveBeenCalledWith([1, 2]);
});
});
3 changes: 2 additions & 1 deletion components/date-picker/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ The following APIs are shared by DatePicker, MonthPicker, RangePicker, WeekPicke
| dropdownClassName | to customize the className of the popup calendar | string | - |
| getCalendarContainer | to set the container of the floating layer, while the default is to create a `div` element in `body` | function(trigger) | - |
| locale | localization configuration | object | [default](https://github.com/ant-design/ant-design/blob/master/components/date-picker/locale/example.json) |
| mode | picker panel mode | `time|date|month|year|decade` | 'date' |
| mode | picker panel mode[Cannot select year or month anymore?](/docs/react/faq#When-set-mode-to-DatePicker/RangePicker,-cannot-select-year-or-month-anymore?) | `time|date|month|year|decade` | 'date' |
| open | open state of picker | boolean | - |
| placeholder | placeholder of date input | string\|RangePicker\[] | - |
| popupStyle | to customize the style of the popup calendar | object | {} |
Expand Down Expand Up @@ -88,6 +88,7 @@ The following APIs are shared by DatePicker, MonthPicker, RangePicker, WeekPicke
| value | to set date | [moment](http://momentjs.com/) | - |
| onChange | a callback function, can be executed when the selected time is changing | function(date: moment, dateString: string) | - |
| onOk | callback when click ok button | function() | - |
| onPanelChange | Callback function for panel changing | function(value, mode) | - |

### MonthPicker

Expand Down
4 changes: 2 additions & 2 deletions components/date-picker/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ moment.locale('zh-cn');
| dropdownClassName | 额外的弹出日历 className | string | - |
| getCalendarContainer | 定义浮层的容器,默认为 body 上新建 div | function(trigger) ||
| locale | 国际化配置 | object | [默认配置](https://github.com/ant-design/ant-design/blob/master/components/date-picker/locale/example.json) |
| mode | 日期面板的状态([设置后无法选择年份/月份?](/docs/react/faq#当我指定了-DatePicker/RangePicker-的-mode-属性后,点击后无法选择年份/月份?)| `time|date|month|year|decade` | 'date' |
| open | 控制弹层是否展开 | boolean | - |
| placeholder | 输入框提示文字 | string\|RangePicker\[] | - |
| popupStyle | 额外的弹出日历样式 | object | {} |
Expand All @@ -82,7 +83,6 @@ moment.locale('zh-cn');
| defaultPickerValue | 默认面板日期 | [moment](http://momentjs.com/) ||
| disabledTime | 不可选择的时间 | function(date) ||
| format | 设置日期格式,为数组时支持多格式匹配,展示以第一个为准。配置参考 [moment.js](http://momentjs.com/) | string \| string[] | "YYYY-MM-DD" |
| mode | 日期面板的状态 | `time|date|month|year|decade` | 'date' |
| renderExtraFooter | 在面板中添加额外的页脚 | (mode) => React.ReactNode | - |
| showTime | 增加时间选择功能 | Object\|boolean | [TimePicker Options](/components/time-picker/#API) |
| showTime.defaultValue | 设置用户选择日期时默认的时分秒,[例子](#components-date-picker-demo-disabled-date) | [moment](http://momentjs.com/) | moment() |
Expand Down Expand Up @@ -141,4 +141,4 @@ moment.locale('zh-cn');

## FAQ

- [当我指定了 DatePicker/RangePicker 的 `mode` 属性后,点击后无法选择年份/月份?](/docs/react/faq-cn#当我指定了-DatePicker/RangePicker-的-mode-属性后,点击后无法选择年份/月份?)
- [当我指定了 DatePicker/RangePicker 的 mode 属性后,点击后无法选择年份/月份?](/docs/react/faq#当我指定了-DatePicker/RangePicker-的-mode-属性后,点击后无法选择年份/月份?)
72 changes: 36 additions & 36 deletions components/descriptions/__tests__/__snapshots__/demo.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ exports[`renders ./components/descriptions/demo/basic.md correctly 1`] = `

exports[`renders ./components/descriptions/demo/border.md correctly 1`] = `
<div
class="ant-descriptions bordered"
class="ant-descriptions ant-descriptions-bordered"
>
<div
class="ant-descriptions-title"
Expand All @@ -120,33 +120,33 @@ exports[`renders ./components/descriptions/demo/border.md correctly 1`] = `
<tr
class="ant-descriptions-row"
>
<td
<th
class="ant-descriptions-item-label"
>
Product
</td>
</th>
<td
class="ant-descriptions-item-content"
colspan="1"
>
Cloud Database
</td>
<td
<th
class="ant-descriptions-item-label"
>
Billing Mode
</td>
</th>
<td
class="ant-descriptions-item-content"
colspan="1"
>
Prepaid
</td>
<td
<th
class="ant-descriptions-item-label"
>
Automatic Renewal
</td>
</th>
<td
class="ant-descriptions-item-content"
colspan="1"
Expand All @@ -157,22 +157,22 @@ exports[`renders ./components/descriptions/demo/border.md correctly 1`] = `
<tr
class="ant-descriptions-row"
>
<td
<th
class="ant-descriptions-item-label"
>
Order time
</td>
</th>
<td
class="ant-descriptions-item-content"
colspan="1"
>
2018-04-24 18:00:00
</td>
<td
<th
class="ant-descriptions-item-label"
>
Usage Time
</td>
</th>
<td
class="ant-descriptions-item-content"
colspan="5"
Expand All @@ -183,11 +183,11 @@ exports[`renders ./components/descriptions/demo/border.md correctly 1`] = `
<tr
class="ant-descriptions-row"
>
<td
<th
class="ant-descriptions-item-label"
>
Status
</td>
</th>
<td
class="ant-descriptions-item-content"
colspan="5"
Expand All @@ -209,33 +209,33 @@ exports[`renders ./components/descriptions/demo/border.md correctly 1`] = `
<tr
class="ant-descriptions-row"
>
<td
<th
class="ant-descriptions-item-label"
>
Negotiated Amount
</td>
</th>
<td
class="ant-descriptions-item-content"
colspan="1"
>
$80.00
</td>
<td
<th
class="ant-descriptions-item-label"
>
Discount
</td>
</th>
<td
class="ant-descriptions-item-content"
colspan="1"
>
$20.00
</td>
<td
<th
class="ant-descriptions-item-label"
>
Official Receipts
</td>
</th>
<td
class="ant-descriptions-item-content"
colspan="1"
Expand All @@ -246,11 +246,11 @@ exports[`renders ./components/descriptions/demo/border.md correctly 1`] = `
<tr
class="ant-descriptions-row"
>
<td
<th
class="ant-descriptions-item-label"
>
Config Info
</td>
</th>
<td
class="ant-descriptions-item-content"
colspan="5"
Expand Down Expand Up @@ -491,7 +491,7 @@ exports[`renders ./components/descriptions/demo/size.md correctly 1`] = `
<br />
<br />
<div
class="ant-descriptions bordered"
class="ant-descriptions ant-descriptions-bordered"
>
<div
class="ant-descriptions-title"
Expand All @@ -506,33 +506,33 @@ exports[`renders ./components/descriptions/demo/size.md correctly 1`] = `
<tr
class="ant-descriptions-row"
>
<td
<th
class="ant-descriptions-item-label"
>
Product
</td>
</th>
<td
class="ant-descriptions-item-content"
colspan="1"
>
Cloud Database
</td>
<td
<th
class="ant-descriptions-item-label"
>
Billing
</td>
</th>
<td
class="ant-descriptions-item-content"
colspan="1"
>
Prepaid
</td>
<td
<th
class="ant-descriptions-item-label"
>
time
</td>
</th>
<td
class="ant-descriptions-item-content"
colspan="1"
Expand All @@ -543,33 +543,33 @@ exports[`renders ./components/descriptions/demo/size.md correctly 1`] = `
<tr
class="ant-descriptions-row"
>
<td
<th
class="ant-descriptions-item-label"
>
Amount
</td>
</th>
<td
class="ant-descriptions-item-content"
colspan="1"
>
$80.00
</td>
<td
<th
class="ant-descriptions-item-label"
>
Discount
</td>
</th>
<td
class="ant-descriptions-item-content"
colspan="1"
>
$20.00
</td>
<td
<th
class="ant-descriptions-item-label"
>
Official
</td>
</th>
<td
class="ant-descriptions-item-content"
colspan="1"
Expand All @@ -580,11 +580,11 @@ exports[`renders ./components/descriptions/demo/size.md correctly 1`] = `
<tr
class="ant-descriptions-row"
>
<td
<th
class="ant-descriptions-item-label"
>
Config Info
</td>
</th>
<td
class="ant-descriptions-item-content"
colspan="5"
Expand Down
Loading

0 comments on commit 722b39e

Please sign in to comment.