diff --git a/.babelrc b/.babelrc index 36a371c9f7..991aecd776 100644 --- a/.babelrc +++ b/.babelrc @@ -1,6 +1,10 @@ { - "presets": ["es2015", "react", "stage-0"], - "plugins": [ - "add-module-exports" - ] + "env": { + "test": { + "presets": ["es2015", "react", "stage-0"], + "plugins": [ + "add-module-exports" + ] + } + } } diff --git a/.gitignore b/.gitignore index 2b33a93a27..babd76691f 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ _site _data dist /lib +/es elasticsearch-* config/base.yaml /.vscode/ diff --git a/CHANGELOG.en-US.md b/CHANGELOG.en-US.md index 1778cd8daf..40ba71e74d 100644 --- a/CHANGELOG.en-US.md +++ b/CHANGELOG.en-US.md @@ -17,6 +17,38 @@ If you want to read change logs before `2.0.0`, please visit [GitHub](https://gi --- +## 2.10.3 + +`2017-05-31` + +- **Calendar** + - Fix disabledDate not be supported, and make supplement for the types and documentation. [#6074](https://github.com/ant-design/ant-design/issues/6074) + - Upgrade rc-calendar to 8.4.0, support Bulgarian, and user can select end date first. [commit/a4a6db](https://github.com/ant-design/ant-design/commit/a4a6db76de57ac2559a2be80208121ab5e168fbf) +- **Alert** Remove default margin-bottom. [commit/5ef482](https://github.com/ant-design/ant-design/commit/5ef48289747409b6d962f75627ddb11e2765f965) +- **Tabs** Fix inactive tab panel behavious. [#6237](https://github.com/ant-design/ant-design/issues/6237) +- **Layout** Fix children in the collapsed Sider not be hidden. [#6131](https://github.com/ant-design/ant-design/issues/6131) +- **Table** Fix table filter menu overflow issue. [#6245](https://github.com/ant-design/ant-design/issues/6245) +- **InputNumber** Fix hasFeedback misplaced validated icon. [#6289](https://github.com/ant-design/ant-design/issues/6289) +- **Typescript** + - Upgrade TypeScript to 2.3.x. [#6263](https://github.com/ant-design/ant-design/issues/6263) + - Add missing props in Table. [commit/acdc56](https://github.com/ant-design/ant-design/commit/acdc563a547c49960521b2b48cd5c707ac1e4cf2) [pull/6291](https://github.com/ant-design/ant-design/pull/6291) [@jch254](https://github.com/jch254) + - Fix wrong type in Mention and Form. [pull/6268](https://github.com/ant-design/ant-design/pull/6268) [@jch254](https://github.com/jch254) + - Fix wrong type in Badge. [pull/6291](https://github.com/ant-design/ant-design/pull/6291) [@jch254](https://github.com/jch254) + - Add missing props in Input related Components. [pull/6276](https://github.com/ant-design/ant-design/pull/6276/commits/94901de2e8c0a2ed6f62f5aa50c98994aad71844) [@panjiesw](https://github.com/panjiesw) [commit/220264](https://github.com/ant-design/ant-design/commit/2202648d6e1c53409ade2141955232922b0040d6#diff-26cb6da96d10397e18e7dbd6c5d8f7a1L265) [@clinyong](https://github.com/clinyong) + +## 2.10.2 + +`2017-05-23` + +- Fix `prop-types` warnings which due to upgrading React. [#5678](https://github.com/ant-design/ant-design/issues/5678) +- Fix `defaultValue` issue of DatePicker and RangePicker in showTime mode. [#6160](https://github.com/ant-design/ant-design/pull/6160) +- Fix style issue of TreeSelect. [#6137](https://github.com/ant-design/ant-design/issues/6137) +- Fix style issue of Input with prefix and addon. [#6144](https://github.com/ant-design/ant-design/issues/6144) +- Fix some bugs of `notification.destroy`. [#6161](https://github.com/ant-design/ant-design/issues/6161) +- Fix missing translations of Upload and Table. [#6218](https://github.com/ant-design/ant-design/issues/6218) +- Fix style issue of Cascader inside Input.Group. [#6208](https://github.com/ant-design/ant-design/issues/6208) +- Increase click area of Tree icons. [#6120](https://github.com/ant-design/ant-design/issues/6120) + ## 2.10.1 `2017-05-14` diff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.md index f400246a21..24a63be939 100644 --- a/CHANGELOG.zh-CN.md +++ b/CHANGELOG.zh-CN.md @@ -17,6 +17,38 @@ timeline: true --- +## 2.10.3 + +`2017-05-31` + +- **Calendar** + - 修复了样式问题以支持 disabledDate,补充了 Type 定义及文档。[#6074](https://github.com/ant-design/ant-design/issues/6074) + - rc-calendar 依赖升级至 8.4.0,支持保加利亚语,支持首先选择结束日期。[commit/a4a6db](https://github.com/ant-design/ant-design/commit/a4a6db76de57ac2559a2be80208121ab5e168fbf) +- **Alert** 去掉了默认的下边距。[commit/5ef482](https://github.com/ant-design/ant-design/commit/5ef48289747409b6d962f75627ddb11e2765f965) +- **Tabs** 修复了隐藏标签下内容的表现问题。[#6237](https://github.com/ant-design/ant-design/issues/6237) +- **Layout** 修复了折叠侧边栏中的内容不能自动隐藏的问题。[#6131](https://github.com/ant-design/ant-design/issues/6131) +- **Table** 修复了 filter 被 Table 截断的问题。[#6245](https://github.com/ant-design/ant-design/issues/6245) +- **InputNumber** 修复了配置 hasFeedback 时校验结果图标位置有误的问题。[#6289](https://github.com/ant-design/ant-design/issues/6289) +- **Typescript** + - typescript 升级至 2.3.x。[#6263](https://github.com/ant-design/ant-design/issues/6263) + - 补充了 Table 的 type 定义. [commit/acdc56](https://github.com/ant-design/ant-design/commit/acdc563a547c49960521b2b48cd5c707ac1e4cf2) [pull/6291](https://github.com/ant-design/ant-design/pull/6291) [@jch254](https://github.com/jch254) + - 修复了 Mention、Form 组件中错误的 type 定义. [pull/6268](https://github.com/ant-design/ant-design/pull/6268) [@jch254](https://github.com/jch254) + - 修复了 Badge 组件中错误的 type 定义. [pull/6291](https://github.com/ant-design/ant-design/pull/6291) [@jch254](https://github.com/jch254) + - 补充了 Input 相关组件的 type 定义。[pull/6276](https://github.com/ant-design/ant-design/pull/6276/commits/94901de2e8c0a2ed6f62f5aa50c98994aad71844) [@panjiesw](https://github.com/panjiesw) [commit/220264](https://github.com/ant-design/ant-design/commit/2202648d6e1c53409ade2141955232922b0040d6#diff-26cb6da96d10397e18e7dbd6c5d8f7a1L265) [@clinyong](https://github.com/clinyong) + +## 2.10.2 + +`2017-05-23` + +- 修复了 React 升级引起的 `prop-types` 相关的 warning 问题。[#5678](https://github.com/ant-design/ant-design/issues/5678) +- 修复 DatePicker 和 RangePicker showTime 模式下 defaultValue 的问题。[#6160](https://github.com/ant-design/ant-design/pull/6160) +- 修复 TreeSelect 的样式问题。[#6137](https://github.com/ant-design/ant-design/issues/6137) +- 修复 包含 prefix 和 addon 的 Input 的样式问题。[#6144](https://github.com/ant-design/ant-design/issues/6144) +- 修复 `notification.destroy` 的 Bug。[#6161](https://github.com/ant-design/ant-design/issues/6161) +- 修复了 Upload 和 Table 组件中缺失的翻译。 +- 修复了在 Input.Group 中的 Cascader 的样式问题。[#6208](https://github.com/ant-design/ant-design/issues/6208) +- 增大了 Tree 图标的可点击区域面积。 + ## 2.10.1 `2017-05-14` diff --git a/README.md b/README.md index f2f8db8857..8b4ffe7d22 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ An enterprise-class UI design language and React-based implementation. ## Environment Support -* Browser: Modern browsers and Internet Explorer 9+ +* Modern browsers and Internet Explorer 9+ (with [polyfills](https://ant.design/docs/react/getting-started#Compatibility)) * Server-side Rendering * [Electron](http://electron.atom.io/) diff --git a/components/affix/index.tsx b/components/affix/index.tsx index 9543e99915..3877ef1331 100644 --- a/components/affix/index.tsx +++ b/components/affix/index.tsx @@ -40,7 +40,7 @@ function noop() {} function getDefaultTarget() { return typeof window !== 'undefined' ? window : null; -}; +} // Affix export interface AffixProps { diff --git a/components/alert/demo/basic.md b/components/alert/demo/basic.md index 02b0e57b58..cf4d174a25 100644 --- a/components/alert/demo/basic.md +++ b/components/alert/demo/basic.md @@ -20,3 +20,9 @@ ReactDOM.render( , mountNode); ```` + + diff --git a/components/alert/index.zh-CN.md b/components/alert/index.zh-CN.md index d47c93b967..de782408d3 100644 --- a/components/alert/index.zh-CN.md +++ b/components/alert/index.zh-CN.md @@ -24,4 +24,3 @@ title: Alert | onClose | 关闭时触发的回调函数 | Function | 无 | | showIcon | 是否显示辅助图标 | boolean | false,`banner` 模式下默认值为 true | | banner | 是否用作顶部公告 | boolean | false | - diff --git a/components/alert/style/index.less b/components/alert/style/index.less index eafd205b41..f37fa71d7c 100644 --- a/components/alert/style/index.less +++ b/components/alert/style/index.less @@ -12,7 +12,6 @@ color: @alert-text-color; font-size: @font-size-base; line-height: 16px; - margin-bottom: 10px; &&-no-icon { padding: 8px 48px 8px 16px; @@ -91,7 +90,6 @@ padding: 16px 16px 16px 60px; position: relative; border-radius: @border-radius-base; - margin-bottom: 10px; color: @text-color; line-height: 1.5; } diff --git a/components/auto-complete/index.tsx b/components/auto-complete/index.tsx index 559f456aee..8c27e70b75 100755 --- a/components/auto-complete/index.tsx +++ b/components/auto-complete/index.tsx @@ -5,7 +5,7 @@ import Select, { AbstractSelectProps, SelectValue, OptionProps, OptGroupProps } import Input from '../input'; import InputElement from './InputElement'; -export interface DataSourceItemObject { value: string; text: string; }; +export interface DataSourceItemObject { value: string; text: string; } export type DataSourceItemType = string | DataSourceItemObject; export interface InputProps { @@ -23,7 +23,6 @@ export interface AutoCompleteProps extends AbstractSelectProps { defaultValue?: SelectValue; dataSource: DataSourceItemType[]; optionLabelProp?: string; - filterOption?: boolean | ((inputValue: string, option: Object) => any); onChange?: (value: SelectValue) => void; onSelect?: (value: SelectValue, option: Object) => any; children?: ValidInputElement | diff --git a/components/auto-complete/style/index.less b/components/auto-complete/style/index.less index c4652aa54b..3b383a08ce 100644 --- a/components/auto-complete/style/index.less +++ b/components/auto-complete/style/index.less @@ -16,11 +16,11 @@ margin-left: 0; margin-right: 0; height: 100%; + line-height: @input-height-base; } &__placeholder { margin-left: 8px; margin-right: 8px; - top: @input-height-base / 2; } } } @@ -36,8 +36,8 @@ } &-lg { - .@{select-prefix-cls}-selection__placeholder { - top: @input-height-lg / 2; + .@{select-prefix-cls}-selection__rendered { + line-height: @input-height-lg; } .@{input-prefix-cls} { .input-lg(); @@ -45,8 +45,8 @@ } &-sm { - .@{select-prefix-cls}-selection__placeholder { - top: @input-height-sm / 2; + .@{select-prefix-cls}-selection__rendered { + line-height: @input-height-sm; } .@{input-prefix-cls} { .input-sm(); diff --git a/components/badge/index.tsx b/components/badge/index.tsx index 8859537459..4bce3e94ff 100644 --- a/components/badge/index.tsx +++ b/components/badge/index.tsx @@ -7,7 +7,7 @@ import warning from '../_util/warning'; export interface BadgeProps { /** Number to show in badge */ - count: number | string; + count?: number | string; showZero?: boolean; /** Max count to show */ overflowCount?: number; @@ -54,7 +54,7 @@ export default class Badge extends React.Component { ...restProps, } = this.props; const isDot = dot || status; - let displayCount = count > (overflowCount as number) ? `${overflowCount}+` : count; + let displayCount = (count as number) > (overflowCount as number) ? `${overflowCount}+` : count; // dot mode don't need count if (isDot) { displayCount = ''; diff --git a/components/breadcrumb/Breadcrumb.tsx b/components/breadcrumb/Breadcrumb.tsx index 03a4577636..1b561371b1 100755 --- a/components/breadcrumb/Breadcrumb.tsx +++ b/components/breadcrumb/Breadcrumb.tsx @@ -13,7 +13,7 @@ export interface BreadcrumbProps { itemRender?: (route: any, params: any, routes: Array, paths: Array) => React.ReactNode; style?: React.CSSProperties; className?: string; -}; +} function getBreadcrumbName(route, params) { if (!route.breadcrumbName) { diff --git a/components/calendar/index.en-US.md b/components/calendar/index.en-US.md index dc9fb8e7a3..2288847020 100644 --- a/components/calendar/index.en-US.md +++ b/components/calendar/index.en-US.md @@ -43,3 +43,4 @@ moment.locale('zh-cn'); | locale | set locale | object | [default](https://github.com/ant-design/ant-design/blob/master/components/date-picker/locale/example.json) | | onPanelChange| callback when panel change | function(date: moment, mode: string) | - | | onSelect | callback when select date | function(date: moment) | - | +| disabledDate | specify the date that cannot be selected | (currentDate: moment) => boolean | 无 | diff --git a/components/calendar/index.tsx b/components/calendar/index.tsx index 66909be9e5..b3a0d3c409 100644 --- a/components/calendar/index.tsx +++ b/components/calendar/index.tsx @@ -39,6 +39,7 @@ export interface CalendarProps { style?: React.CSSProperties; onPanelChange?: (date?: moment.Moment, mode?: CalendarMode) => void; onSelect?: (date?: moment.Moment) => void; + disabledDate?: (current: moment.Moment) => boolean; } export interface CalendarState { diff --git a/components/calendar/index.zh-CN.md b/components/calendar/index.zh-CN.md index 546a1cd000..7fbc659c79 100644 --- a/components/calendar/index.zh-CN.md +++ b/components/calendar/index.zh-CN.md @@ -45,3 +45,4 @@ moment.locale('zh-cn'); | locale | 国际化配置 | object | [默认配置](https://github.com/ant-design/ant-design/blob/master/components/date-picker/locale/example.json) | | onPanelChange| 日期面板变化回调 | function(date: moment, mode: string) | 无 | | onSelect | 点击选择日期回调 | function(date: moment) | 无 | +| disabledDate | 不可选择的日期 | (currentDate: moment) => boolean | 无 | diff --git a/components/calendar/style/index.less b/components/calendar/style/index.less index 7b458e26bd..649354be03 100644 --- a/components/calendar/style/index.less +++ b/components/calendar/style/index.less @@ -125,18 +125,6 @@ color: #fff; } - &-disabled-cell &-value { - cursor: not-allowed; - color: @disabled-color; - background: @disabled-bg; - border-radius: 0; - width: auto; - - &:hover { - background: @disabled-bg; - } - } - &-disabled-cell-first-of-row &-value { border-top-left-radius: @border-radius-base; border-bottom-left-radius: @border-radius-base; @@ -254,4 +242,25 @@ left: auto; bottom: auto; } + + &-disabled-cell &-date { + &, + &:hover { + cursor: not-allowed; + } + } + + &-disabled-cell:not(&-today) &-date { + &, + &:hover { + background: transparent; + } + } + + &-disabled-cell &-value { + color: @disabled-color; + border-radius: 0; + width: auto; + cursor: not-allowed; + } } diff --git a/components/card/index.en-US.md b/components/card/index.en-US.md index 30e8a30724..95e2909840 100644 --- a/components/card/index.en-US.md +++ b/components/card/index.en-US.md @@ -23,3 +23,4 @@ A card can be used to display content related to a single subject. The content c | extra | Content to render in the top-right corner of the card | string\|ReactNode | - | | bordered | Toggles rendering of the border around the card | boolean | true | | bodyStyle | Inline style to apply to the card content | object | - | +| loading | Shows a loading indicator while the contents of the card are being fetched | boolean | false | diff --git a/components/card/index.zh-CN.md b/components/card/index.zh-CN.md index e6877ce270..656a276eae 100644 --- a/components/card/index.zh-CN.md +++ b/components/card/index.zh-CN.md @@ -24,3 +24,4 @@ cols: 1 | extra | 卡片右上角的操作区域 | string\|ReactNode | - | | bordered | 是否有边框 | boolean | true | | bodyStyle | 内容区域自定义样式 | object | - | +| loading | 当卡片内容还在加载中时,可以用 loading 展示一个占位 | boolean | false | diff --git a/components/cascader/__tests__/__snapshots__/demo.test.js.snap b/components/cascader/__tests__/__snapshots__/demo.test.js.snap index ed55e3080e..2946a2c3eb 100644 --- a/components/cascader/__tests__/__snapshots__/demo.test.js.snap +++ b/components/cascader/__tests__/__snapshots__/demo.test.js.snap @@ -5,6 +5,9 @@ exports[`renders ./components/cascader/demo/basic.md correctly 1`] = ` class="ant-cascader-picker" tabindex="0" > + - @@ -27,6 +27,9 @@ exports[`renders ./components/cascader/demo/change-on-select.md correctly 1`] = class="ant-cascader-picker" tabindex="0" > + - @@ -50,13 +50,6 @@ exports[`renders ./components/cascader/demo/custom-render.md correctly 1`] = ` style="width:270px;" tabindex="0" > - @@ -74,6 +67,13 @@ exports[`renders ./components/cascader/demo/custom-render.md correctly 1`] = ` ) + @@ -100,6 +100,11 @@ exports[`renders ./components/cascader/demo/default-value.md correctly 1`] = ` class="ant-cascader-picker" tabindex="0" > + + Zhejiang / Hangzhou / West Lake + - - Zhejiang / Hangzhou / West Lake - @@ -126,6 +126,9 @@ exports[`renders ./components/cascader/demo/disabled-option.md correctly 1`] = ` class="ant-cascader-picker" tabindex="0" > + - @@ -148,6 +148,9 @@ exports[`renders ./components/cascader/demo/hover.md correctly 1`] = ` class="ant-cascader-picker" tabindex="0" > + - @@ -170,6 +170,9 @@ exports[`renders ./components/cascader/demo/lazy.md correctly 1`] = ` class="ant-cascader-picker" tabindex="0" > + - @@ -192,6 +192,9 @@ exports[`renders ./components/cascader/demo/search.md correctly 1`] = ` class="ant-cascader-picker" tabindex="0" > + - @@ -214,6 +214,9 @@ exports[`renders ./components/cascader/demo/size.md correctly 1`] = ` class="ant-cascader-picker" tabindex="0" > + - @@ -235,6 +235,9 @@ exports[`renders ./components/cascader/demo/size.md correctly 1`] = ` class="ant-cascader-picker" tabindex="0" > + - @@ -256,6 +256,9 @@ exports[`renders ./components/cascader/demo/size.md correctly 1`] = ` class="ant-cascader-picker" tabindex="0" > + - diff --git a/components/cascader/index.tsx b/components/cascader/index.tsx index ca037fa13f..3b3c163cac 100644 --- a/components/cascader/index.tsx +++ b/components/cascader/index.tsx @@ -330,6 +330,9 @@ export default class Cascader extends React.Component { style={style} className={pickerCls} > + + {this.getLabel()} + { onKeyDown={this.handleKeyDown} onChange={showSearch ? this.handleInputChange : undefined} /> - - {this.getLabel()} - {clearIcon} diff --git a/components/cascader/style/index.less b/components/cascader/style/index.less index f7caba073e..0e7b0cc582 100644 --- a/components/cascader/style/index.less +++ b/components/cascader/style/index.less @@ -13,7 +13,6 @@ background-color: transparent!important; cursor: pointer; width: 100%; - z-index: 1; display: block; } diff --git a/components/checkbox/Checkbox.tsx b/components/checkbox/Checkbox.tsx index 0d7e58c591..363aa5cb25 100644 --- a/components/checkbox/Checkbox.tsx +++ b/components/checkbox/Checkbox.tsx @@ -16,6 +16,7 @@ export interface AbstractCheckboxProps { onMouseEnter?: React.MouseEventHandler; onMouseLeave?: React.MouseEventHandler; value?: any; + name?: string; } export interface CheckboxProps extends AbstractCheckboxProps { diff --git a/components/date-picker/RangePicker.tsx b/components/date-picker/RangePicker.tsx index 703522308e..e2f257e29b 100644 --- a/components/date-picker/RangePicker.tsx +++ b/components/date-picker/RangePicker.tsx @@ -33,7 +33,7 @@ function pickerValueAdapter(value?: moment.Moment | moment.Moment[]): moment.Mom export default class RangePicker extends React.Component { static contextTypes = { - antLocale: PropTypes.object, + antLocale: PropTypes.object, }; static defaultProps = { prefixCls: 'ant-calendar', @@ -56,6 +56,7 @@ export default class RangePicker extends React.Component { this.state = { value, open: props.open, + hoverValue: [], }; } @@ -78,6 +79,8 @@ export default class RangePicker extends React.Component { this.handleChange([]); } + clearHoverValue = () => this.setState({ hoverValue: [] }); + handleChange = (value: moment.Moment[]) => { const props = this.props; if (!('value' in props)) { @@ -100,6 +103,8 @@ export default class RangePicker extends React.Component { handleShowDateChange = showDate => this.setState({ showDate }); + handleHoverChange = hoverValue => this.setState({ hoverValue }); + setValue(value) { this.handleChange(value); if (!this.props.showTime) { @@ -115,7 +120,16 @@ export default class RangePicker extends React.Component { const operations = Object.keys(ranges).map((range) => { const value = ranges[range]; - return this.setValue(value)}>{range}; + return ( + this.setValue(value)} + onMouseEnter={() => this.setState({ hoverValue: value })} + onMouseLeave={this.clearHoverValue} + > + {range} + + ); }); return (
@@ -126,7 +140,7 @@ export default class RangePicker extends React.Component { render() { const { state, props, context } = this; - const { value, showDate, open } = state; + const { value, showDate, hoverValue, open } = state; const localeCode = getLocaleCode(context); if (value && localeCode) { if (value[0]) { @@ -138,9 +152,10 @@ export default class RangePicker extends React.Component { } const { - disabledDate, disabledTime, showTime, showToday, - ranges, prefixCls, popupStyle, - style, onOk, locale, format, + prefixCls, popupStyle, style, + disabledDate, disabledTime, + showTime, showToday, + ranges, onOk, locale, format, } = props; warning(!('onOK' in props), 'It should be `RangePicker[onOk]`, instead of `onOK`!'); @@ -182,6 +197,8 @@ export default class RangePicker extends React.Component { onOk={onOk} value={showDate || pickerValueAdapter(props.defaultPickerValue) || pickerValueAdapter(moment())} onValueChange={this.handleShowDateChange} + hoverValue={hoverValue} + onHoverChange={this.handleHoverChange} showToday={showToday} /> ); diff --git a/components/date-picker/__tests__/RangePicker.test.js b/components/date-picker/__tests__/RangePicker.test.js index e6a518f4ae..7d782e2ae3 100644 --- a/components/date-picker/__tests__/RangePicker.test.js +++ b/components/date-picker/__tests__/RangePicker.test.js @@ -41,6 +41,25 @@ describe('RangePicker', () => { .toMatchSnapshot(); }); + it('highlight range when hover presetted range', () => { + const wrapper = mount( + trigger} + format="YYYY/MM/DD" + open + /> + ); + + let rangeCalendarWrapper = mount(wrapper.find('Trigger').node.getComponent()); + rangeCalendarWrapper.find('.ant-calendar-range-quick-selector a') + .simulate('mouseEnter'); + rangeCalendarWrapper = mount(wrapper.find('Trigger').node.getComponent()); + expect(rangeCalendarWrapper.find('.ant-calendar-selected-day').length).toBe(2); + }); + // issue: https://github.com/ant-design/ant-design/issues/5872 it('should not throw error when value is reset to `[]`', () => { const birthday = moment('2000-01-01', 'YYYY-MM-DD'); @@ -53,7 +72,7 @@ describe('RangePicker', () => { ); wrapper.setProps({ value: [] }); const rangeCalendarWrapper = mount(wrapper.find('Trigger').node.getComponent()); - expect(() => rangeCalendarWrapper.find('.ant-calendar-today').simulate('click').simulate('click')) + expect(() => rangeCalendarWrapper.find('.ant-calendar-today').at(0).simulate('click').simulate('click')) .not.toThrow(); }); }); diff --git a/components/date-picker/index.en-US.md b/components/date-picker/index.en-US.md index ffa9e247d2..f2c9d7a4b2 100644 --- a/components/date-picker/index.en-US.md +++ b/components/date-picker/index.en-US.md @@ -42,7 +42,7 @@ The following APIs are shared by DatePicker, MonthPicker, RangePicker. | popupStyle | to customize the style of the popup calendar | object | {} | | size | determine the size of the input box, the height of `large` and `small`, are 32px and 22px respectively, while default size is 28px | string | - | | locale | localization configuration | object | [default](https://github.com/ant-design/ant-design/blob/master/components/date-picker/locale/example.json) | -| disabledDate | to specify the date that cannot be selected | function | - | +| disabledDate | specify the date that cannot be selected | (currentDate: moment) => boolean | - | | getCalendarContainer | to set the container of the floating layer, while the default is to create a `div` element in `body` | function(trigger) | - | | open | open state of picker | boolean | - | | onOpenChange | a callback function, can be executed whether the popup calendar is popped up or closed | function(status) | - | diff --git a/components/date-picker/index.zh-CN.md b/components/date-picker/index.zh-CN.md index 6c2698fcb3..75f2a5847a 100644 --- a/components/date-picker/index.zh-CN.md +++ b/components/date-picker/index.zh-CN.md @@ -43,7 +43,7 @@ moment.locale('zh-cn'); | popupStyle | 格外的弹出日历样式 | object | {} | | size | 输入框大小,`large` 高度为 32px,`small` 为 22px,默认是 28px | string | 无 | | locale | 国际化配置 | object | [默认配置](https://github.com/ant-design/ant-design/blob/master/components/date-picker/locale/example.json) | -| disabledDate | 不可选择的日期 | function | 无 | +| disabledDate | 不可选择的日期 | (currentDate: moment) => boolean | 无 | | getCalendarContainer | 定义浮层的容器,默认为 body 上新建 div | function(trigger) | 无 | | open | 控制弹层是否展开 | boolean | - | | onOpenChange | 弹出日历和关闭日历的回调 | function(status) | 无 | diff --git a/components/form/Form.tsx b/components/form/Form.tsx index 24e4d3c3a2..1419a226b6 100755 --- a/components/form/Form.tsx +++ b/components/form/Form.tsx @@ -30,6 +30,31 @@ export interface FormProps { hideRequiredMark?: boolean; } +export type ValidationRule = { + /** validation error message */ + message?: string; + /** built-in validation type, available options: https://github.com/yiminghe/async-validator#type */ + type?: string; + /** indicates whether field is required */ + required?: boolean; + /** treat required fields that only contain whitespace as errors */ + whitespace?: boolean; + /** validate the exact length of a field */ + len?: number; + /** validate the min length of a field */ + min?: number; + /** validate the max length of a field */ + max?: number; + /** validate the value from a list of possible values */ + enum?: string | string[]; + /** validate from a regular expression */ + pattern?: RegExp; + /** transform a value before validation */ + transform?: (value: any) => any; + /** custom validate function (Note: callback must be called) */ + validator?: (rule: any, value: any, callback: any, source?: any, options?: any) => any; +}; + export type ValidateCallback = (erros: any, values: any) => void; // function create @@ -74,7 +99,7 @@ export type WrappedFormUtils = { /** 校验子节点值的时机 */ validateTrigger?: string | string[]; /** 校验规则,参见 [async-validator](https://github.com/yiminghe/async-validator) */ - rules?: Array; + rules?: ValidationRule[]; /** 是否和其他控件互斥,特别用于 Radio 单选控件 */ exclusive?: boolean; }): (node: React.ReactNode) => React.ReactNode; diff --git a/components/form/__tests__/__snapshots__/demo.test.js.snap b/components/form/__tests__/__snapshots__/demo.test.js.snap index bc3e792ce6..a7c1b06a18 100644 --- a/components/form/__tests__/__snapshots__/demo.test.js.snap +++ b/components/form/__tests__/__snapshots__/demo.test.js.snap @@ -1232,6 +1232,11 @@ exports[`renders ./components/form/demo/register.md correctly 1`] = ` class="ant-cascader-picker" tabindex="0" > + + Zhejiang / Hangzhou / West Lake + - - Zhejiang / Hangzhou / West Lake - @@ -1277,51 +1277,55 @@ exports[`renders ./components/form/demo/register.md correctly 1`] = ` class="ant-form-item-control " > -
-
+
+
-
diff --git a/components/input-number/index.tsx b/components/input-number/index.tsx index 3246c0d32c..d2880f49b1 100644 --- a/components/input-number/index.tsx +++ b/components/input-number/index.tsx @@ -17,6 +17,7 @@ export interface InputNumberProps { placeholder?: string; style?: React.CSSProperties; className?: string; + name?: string; } export default class InputNumber extends React.Component { diff --git a/components/input-number/style/index.less b/components/input-number/style/index.less index db26fe3cff..d772865178 100644 --- a/components/input-number/style/index.less +++ b/components/input-number/style/index.less @@ -113,6 +113,7 @@ opacity: 0; border-radius: 0 @border-radius-base @border-radius-base 0; transition: opacity 0.24s linear 0.1s; + z-index: 2; // https://github.com/ant-design/ant-design/issues/6289 } &-handler-wrap:hover &-handler { diff --git a/components/input/Input.tsx b/components/input/Input.tsx index efab5358df..cba15b1cf7 100644 --- a/components/input/Input.tsx +++ b/components/input/Input.tsx @@ -31,7 +31,7 @@ function clearNextFrameAction(nextFrameId) { export interface AutoSizeType { minRows?: number; maxRows?: number; -}; +} export interface InputProps { prefixCls?: string; @@ -59,6 +59,7 @@ export interface InputProps { prefix?: React.ReactNode; suffix?: React.ReactNode; spellCheck?: boolean; + autoFocus?: boolean; } export default class Input extends Component { @@ -175,18 +176,23 @@ export default class Input extends Component {
) : null; - const className = classNames({ - [`${props.prefixCls}-wrapper`]: true, + const className = classNames(`${props.prefixCls}-wrapper`, { [wrapperClassName]: (addonBefore || addonAfter), }); - return ( + const node = ( {addonBefore} {children} {addonAfter} ); + + // Need another wrapper for changing display:table to display:inline-block + if (addonBefore || addonAfter) { + return {node}; + } + return node; } renderLabeledIcon(children) { diff --git a/components/input/Search.tsx b/components/input/Search.tsx index 527dd045fe..b0501846dd 100644 --- a/components/input/Search.tsx +++ b/components/input/Search.tsx @@ -15,6 +15,7 @@ export interface SearchProps { size?: 'large' | 'default' | 'small'; disabled?: boolean; readOnly?: boolean; + name?: string; } export default class Search extends React.Component { diff --git a/components/input/__tests__/__snapshots__/demo.test.js.snap b/components/input/__tests__/__snapshots__/demo.test.js.snap index 14a1e91ecf..18a6a19439 100644 --- a/components/input/__tests__/__snapshots__/demo.test.js.snap +++ b/components/input/__tests__/__snapshots__/demo.test.js.snap @@ -6,129 +6,141 @@ exports[`renders ./components/input/demo/addon.md correctly 1`] = ` style="margin-bottom:16px;" > - Http:// - - - - .com - - - -
- - -
- -
-
- - -
- -
-
-
-
-
- - - - + + + .com + + + +
+
+ + + +
+ +
+
+ + +
+ +
+
+
+
+
+
+ + + + + +
@@ -615,6 +627,9 @@ exports[`renders ./components/input/demo/group.md correctly 1`] = ` style="width:70%;" tabindex="0" > + - diff --git a/components/input/style/index.less b/components/input/style/index.less index a1178012d9..be6083d2b1 100644 --- a/components/input/style/index.less +++ b/components/input/style/index.less @@ -11,6 +11,10 @@ //== Style for input-group: input with label, with button or dropdown... .@{ant-prefix}-input-group { .input-group(~"@{ant-prefix}-input"); + &-wrapper { + display: inline-block; + vertical-align: middle; + } } // Input with affix: prefix or suffix diff --git a/components/layout/Sider.tsx b/components/layout/Sider.tsx index 71c4fd09eb..b08f5188fb 100644 --- a/components/layout/Sider.tsx +++ b/components/layout/Sider.tsx @@ -168,7 +168,7 @@ export default class Sider extends React.Component { }); return (
- {this.props.children} +
{this.props.children}
{collapsible || (this.state.below && zeroWidthTrigger) ? triggerDom : null}
); diff --git a/components/layout/__tests__/__snapshots__/demo.test.js.snap b/components/layout/__tests__/__snapshots__/demo.test.js.snap index c36569d067..4cfb266790 100644 --- a/components/layout/__tests__/__snapshots__/demo.test.js.snap +++ b/components/layout/__tests__/__snapshots__/demo.test.js.snap @@ -36,7 +36,11 @@ exports[`renders ./components/layout/demo/basic.md correctly 1`] = ` class="ant-layout-sider" style="flex:0 0 200px;width:200px;" > - Sider +
+ Sider +
- Sider +
+ Sider +
- Sider +
+ Sider +
+ +
  • + +
  • + - + + +
    @@ -999,6 +1027,179 @@ exports[`renders ./components/layout/demo/top-side.md correctly 1`] = `
    +
    + +
    +
    +
    + Content +
    +
    + + + +`; + +exports[`renders ./components/layout/demo/top-side-2.md correctly 1`] = ` +
    +
    + +
    +
    +
    -
    - Content -
    -
    -
    - -
    -`; - -exports[`renders ./components/layout/demo/top-side-2.md correctly 1`] = ` -
    -
    - -
    -
    -
    { + return (Basic): any => { return class Adapter extends React.Component { static Header: any; static Footer: any; @@ -40,7 +41,12 @@ class Basic extends React.Component { } } -const Layout = generator({ +const Layout: React.ComponentClass & { + Header: React.ComponentClass; + Footer: React.ComponentClass; + Content: React.ComponentClass; + Sider: React.ComponentClass; +} = generator({ prefixCls: 'ant-layout', })(Basic); diff --git a/components/locale-provider/pt_BR.tsx b/components/locale-provider/pt_BR.tsx index 8ba326faa8..d06d61e96d 100644 --- a/components/locale-provider/pt_BR.tsx +++ b/components/locale-provider/pt_BR.tsx @@ -18,6 +18,8 @@ export default { filterConfirm: 'OK', filterReset: 'Resetar', emptyText: 'Não há dados', + selectAll: 'Selecionar página atual', + selectInvert: 'Inverter seleção', }, Modal: { okText: 'OK', @@ -37,4 +39,10 @@ export default { Select: { notFoundContent: 'Não encontrado', }, + Upload: { + uploading: 'Enviando...', + removeFile: 'Remover arquivo', + uploadError: 'Erro no envio', + previewFile: 'Visualizar arquivo', + }, }; diff --git a/components/mention/index.tsx b/components/mention/index.tsx index b975d8f7d4..ce56231edd 100644 --- a/components/mention/index.tsx +++ b/components/mention/index.tsx @@ -5,7 +5,7 @@ import shallowequal from 'shallowequal'; import Icon from '../icon'; export interface MentionProps { - prefixCls: string; + prefixCls?: string; suggestionStyle?: React.CSSProperties; suggestions?: Array; onSearchChange?: Function; @@ -54,7 +54,8 @@ export default class Mention extends React.Component }; } - componentWillReceiveProps({ suggestions }) { + componentWillReceiveProps(nextProps: MentionProps) { + const { suggestions } = nextProps; if (!shallowequal(suggestions, this.props.suggestions)) { this.setState({ suggestions, diff --git a/components/modal/Modal.tsx b/components/modal/Modal.tsx index c178f97465..ed8e5cb2c9 100644 --- a/components/modal/Modal.tsx +++ b/components/modal/Modal.tsx @@ -36,6 +36,7 @@ export interface ModalProps { maskTransitionName?: string; transitionName?: string; className?: string; + getContainer?: (instance: React.ReactInstance) => HTMLElement; } export interface ModalContext { diff --git a/components/modal/index.en-US.md b/components/modal/index.en-US.md index 47a765fd18..8090e1c7d0 100644 --- a/components/modal/index.en-US.md +++ b/components/modal/index.en-US.md @@ -32,6 +32,7 @@ and so on. | style | Style of floating layer, typically used at least for adjusting the position. | object | - | | wrapClassName | The class name of the container of the modal dialog | string | - | | afterClose | Specify a function that will be called when modal is closed completely. | function | - | +| getContainer | Return the mount node for Modal | (instance): HTMLElement | () => document.body | #### Destroy on close diff --git a/components/modal/index.tsx b/components/modal/index.tsx index 2d63a64823..2ef93f0951 100644 --- a/components/modal/index.tsx +++ b/components/modal/index.tsx @@ -2,7 +2,7 @@ import Modal, { ModalFuncProps } from './Modal'; import confirm from './confirm'; import assign from 'object-assign'; -export { ModalFuncProps } +export { ModalFuncProps }; Modal.info = function (props: ModalFuncProps) { const config = assign({}, { diff --git a/components/modal/index.zh-CN.md b/components/modal/index.zh-CN.md index d8f4ff0753..88ec7f1f56 100644 --- a/components/modal/index.zh-CN.md +++ b/components/modal/index.zh-CN.md @@ -31,6 +31,7 @@ title: Modal | style | 可用于设置浮层的样式,调整浮层位置等 | object | - | | wrapClassName | 对话框外层容器的类名 | string | - | | afterClose | Modal 完全关闭后的回调 | function | 无 | +| getContainer | 指定 Modal 挂载的 HTML 节点 | (instance): HTMLElement | () => document.body | #### 清空旧数据 diff --git a/components/pagination/Pagination.tsx b/components/pagination/Pagination.tsx index 8a736fe66c..5beda76961 100644 --- a/components/pagination/Pagination.tsx +++ b/components/pagination/Pagination.tsx @@ -33,7 +33,7 @@ abstract class Pagination extends React.Component { selectPrefixCls: 'ant-select', }; - abstract getLocale() + abstract getLocale(); render() { const { className, size, ...restProps } = this.props; diff --git a/components/popconfirm/index.tsx b/components/popconfirm/index.tsx index 786e3bf09a..23b3861580 100644 --- a/components/popconfirm/index.tsx +++ b/components/popconfirm/index.tsx @@ -28,7 +28,7 @@ abstract class Popconfirm extends React.Component { }; } - abstract getLocale() + abstract getLocale(); componentWillReceiveProps(nextProps: PopconfirmProps) { if ('visible' in nextProps) { diff --git a/components/select/index.tsx b/components/select/index.tsx index 4ade7cb16c..b9b214d0af 100755 --- a/components/select/index.tsx +++ b/components/select/index.tsx @@ -16,6 +16,11 @@ export interface AbstractSelectProps { disabled?: boolean; style?: React.CSSProperties; placeholder?: string; + dropdownClassName?: string; + dropdownStyle?: React.CSSProperties; + dropdownMenuStyle?: React.CSSProperties; + onSearch?: (value: string) => any; + filterOption?: boolean | ((inputValue: string, option: Object) => any); } export interface LabeledValue { @@ -33,18 +38,14 @@ export interface SelectProps extends AbstractSelectProps { tags?: boolean; combobox?: boolean; optionLabelProp?: string; - filterOption?: boolean | ((inputValue: string, option: Object) => any); onChange?: (value: SelectValue) => void; onSelect?: (value: SelectValue, option: Object) => any; onDeselect?: (value: SelectValue) => any; - onSearch?: (value: string) => any; dropdownMatchSelectWidth?: boolean; optionFilterProp?: string; defaultActiveFirstOption?: boolean; labelInValue?: boolean; getPopupContainer?: (triggerNode: Element) => HTMLElement; - dropdownStyle?: React.CSSProperties; - dropdownMenuStyle?: React.CSSProperties; tokenSeparators?: string[]; getInputElement?: () => React.ReactElement; } diff --git a/components/select/index.zh-CN.md b/components/select/index.zh-CN.md index 4a958864de..5e6944b9c7 100644 --- a/components/select/index.zh-CN.md +++ b/components/select/index.zh-CN.md @@ -44,7 +44,7 @@ title: Select | optionFilterProp | 搜索时过滤对应的 option 属性,如设置为 children 表示对内嵌内容进行搜索 | string | value | | optionLabelProp | 回填到选择框的 Option 的属性值,默认是 Option 的子元素。比如在子元素需要高亮效果时,此值可以设为 `value`。 | string | `children` (combobox 模式下为 `value`) | | size | 选择框大小,可选 `large` `small` | string | default | -| showSearch | 在选择框中显示搜索框 | boolean | false | +| showSearch | 使单选模式可搜索 | boolean | false | | disabled | 是否禁用 | boolean | false | | defaultActiveFirstOption | 是否默认高亮第一个选项。 | boolean | true | dropdownStyle | 下拉菜单的 style 属性 | object | - | diff --git a/components/select/style/index.less b/components/select/style/index.less index 7098e50cb2..6b18ec51d7 100644 --- a/components/select/style/index.less +++ b/components/select/style/index.less @@ -227,6 +227,7 @@ overflow: hidden; text-overflow: ellipsis; white-space: nowrap; + text-align: left; } &-search__field__placeholder { @@ -298,7 +299,8 @@ } .@{select-prefix-cls}-selection__choice { - background-color: #f3f3f3; + color: @tag-default-color; + background-color: @tag-default-bg; border-radius: 4px; cursor: default; float: left; diff --git a/components/spin/style/index.less b/components/spin/style/index.less index 9c44f3a6a5..846df54050 100644 --- a/components/spin/style/index.less +++ b/components/spin/style/index.less @@ -115,7 +115,7 @@ &-dot { position: relative; - display: block; + display: inline-block; .square(@spin-dot-size); transform: rotate(45deg); animation: antRotate 1.2s infinite linear; diff --git a/components/style/themes/default.less b/components/style/themes/default.less index ae8503ba64..089fca9ad2 100644 --- a/components/style/themes/default.less +++ b/components/style/themes/default.less @@ -294,6 +294,11 @@ @table-padding-vertical: 16px; @table-padding-horizontal: 8px; +// Tag +// -- +@tag-default-bg: #f3f3f3; +@tag-default-color: @text-color; + // TimePicker // --- @time-picker-panel-column-width: 56px; diff --git a/components/table/Column.tsx b/components/table/Column.tsx index 6767c2f733..177a1d3642 100644 --- a/components/table/Column.tsx +++ b/components/table/Column.tsx @@ -10,6 +10,8 @@ export interface ColumnProps { onFilter?: (value: any, record: T) => boolean; filterMultiple?: boolean; filterDropdown?: React.ReactNode; + filterDropdownVisible?: boolean; + onFilterDropdownVisibleChange?: (visible: boolean) => void; sorter?: boolean | ((a: any, b: any) => number); colSpan?: number; width?: string | number; @@ -19,6 +21,7 @@ export interface ColumnProps { filteredValue?: any[]; sortOrder?: boolean | ('ascend' | 'descend'); children?: ColumnProps[]; + onCellClick?: (record: T, event: any) => void; } export default class Column extends (RcTable.Column as React.ComponentClass>) {} diff --git a/components/table/SelectionCheckboxAll.tsx b/components/table/SelectionCheckboxAll.tsx index da7c802472..aeb6bee01d 100644 --- a/components/table/SelectionCheckboxAll.tsx +++ b/components/table/SelectionCheckboxAll.tsx @@ -22,6 +22,7 @@ export interface SelectionCheckboxAllProps { prefixCls: string | undefined; onSelect: (key: string, index: number, selectFunc: any) => void; selections?: SelectionDecorator[] | boolean; + getPopupContainer: (triggerNode?: Element) => HTMLElement; } export default class SelectionCheckboxAll extends React.Component { @@ -152,7 +153,7 @@ export default class SelectionCheckboxAll extends React.Component trigger.parentNode as HTMLElement} + getPopupContainer={getPopupContainer} >
    diff --git a/components/table/Table.tsx b/components/table/Table.tsx index 2941c5307b..ba1a4854d8 100755 --- a/components/table/Table.tsx +++ b/components/table/Table.tsx @@ -1,4 +1,5 @@ import React from 'react'; +import { findDOMNode } from 'react-dom'; import RcTable from 'rc-table'; import PropTypes from 'prop-types'; import classNames from 'classnames'; @@ -615,6 +616,10 @@ export default class Table extends React.Component, any> { return recordKey === undefined ? index : recordKey; } + getPopupContainer = () => { + return findDOMNode(this) as HTMLElement; + } + renderRowSelection() { const { prefixCls, rowSelection } = this.props; const columns = this.columns.concat(); @@ -646,6 +651,7 @@ export default class Table extends React.Component, any> { prefixCls={prefixCls} onSelect={this.handleSelectRow} selections={rowSelection.selections} + getPopupContainer={this.getPopupContainer} /> ); } @@ -700,6 +706,7 @@ export default class Table extends React.Component, any> { confirmFilter={this.handleFilter} prefixCls={`${prefixCls}-filter`} dropdownPrefixCls={dropdownPrefixCls || 'ant-dropdown'} + getPopupContainer={this.getPopupContainer} /> ); } @@ -939,7 +946,10 @@ export default class Table extends React.Component, any> { } return ( -
    +
    , filterDropdownVisible: this.state.filterDropdownVisible, - onFilterDropdownVisibleChange: visible => this.setState({ filterDropdownVisible: visible }, () => this.searchInput.focus()), + onFilterDropdownVisibleChange: (visible) => { + this.setState({ + filterDropdownVisible: visible, + }, () => this.searchInput.focus()); + }, }, { title: 'Age', dataIndex: 'age', diff --git a/components/table/filterDropdown.tsx b/components/table/filterDropdown.tsx index 67ffca526a..58a6d1c922 100755 --- a/components/table/filterDropdown.tsx +++ b/components/table/filterDropdown.tsx @@ -24,6 +24,7 @@ export interface FilterMenuProps { confirmFilter: (column: Object, selectedKeys: string[]) => any; prefixCls: string; dropdownPrefixCls: string; + getPopupContainer: (triggerNode?: Element) => HTMLElement; } export default class FilterMenu extends React.Component { @@ -182,7 +183,7 @@ export default class FilterMenu extends React.Component { }) : ; } render() { - const { column, locale, prefixCls, dropdownPrefixCls } = this.props; + const { column, locale, prefixCls, dropdownPrefixCls, getPopupContainer } = this.props; // default multiple selection in filter dropdown const multiple = ('filterMultiple' in column) ? column.filterMultiple : true; const dropdownMenuClass = classNames({ @@ -228,6 +229,7 @@ export default class FilterMenu extends React.Component { overlay={menus} visible={this.neverShown ? false : this.state.visible} onVisibleChange={this.onVisibleChange} + getPopupContainer={getPopupContainer} > {this.renderFilterIcon()} diff --git a/components/tabs/style/index.less b/components/tabs/style/index.less index e4a8a012a8..9dde90f3a4 100644 --- a/components/tabs/style/index.less +++ b/components/tabs/style/index.less @@ -200,6 +200,7 @@ opacity: 0; height: 0; padding: 0!important; + pointer-events: none; } } > .@{tab-prefix-cls}-content-animated { diff --git a/components/tag/style/index.less b/components/tag/style/index.less index f9b17fd749..3b977610e4 100644 --- a/components/tag/style/index.less +++ b/components/tag/style/index.less @@ -3,9 +3,6 @@ @tag-prefix-cls: ~"@{ant-prefix}-tag"; -@tag-default-bg: @background-color-base; -@tag-default-color: @text-color; - .@{tag-prefix-cls} { display: inline-block; line-height: 20px; diff --git a/components/time-picker/index.tsx b/components/time-picker/index.tsx index f46a8f6718..84e3329ae7 100644 --- a/components/time-picker/index.tsx +++ b/components/time-picker/index.tsx @@ -58,7 +58,7 @@ abstract class TimePicker extends React.Component { }; } - abstract getLocale() + abstract getLocale(); componentWillReceiveProps(nextProps: TimePickerProps) { if ('value' in nextProps) { diff --git a/components/tooltip/index.tsx b/components/tooltip/index.tsx index 4405af762b..80312cf934 100644 --- a/components/tooltip/index.tsx +++ b/components/tooltip/index.tsx @@ -27,7 +27,7 @@ export interface AbstractTooltipProps { // getTooltipContainer had been rename to getPopupContainer getTooltipContainer?: (triggerNode: Element) => HTMLElement; getPopupContainer?: (triggerNode: Element) => HTMLElement; - children?: React.ReactElement; + children?: React.ReactNode; } export interface TooltipProps extends AbstractTooltipProps { diff --git a/components/transfer/index.tsx b/components/transfer/index.tsx index ee015648d1..df3270ff6b 100644 --- a/components/transfer/index.tsx +++ b/components/transfer/index.tsx @@ -91,7 +91,7 @@ abstract class Transfer extends React.Component { }; } - abstract getLocale() + abstract getLocale(); componentWillReceiveProps(nextProps: TransferProps) { const { sourceSelectedKeys, targetSelectedKeys } = this.state; @@ -227,10 +227,10 @@ abstract class Transfer extends React.Component { handleLeftSelectAll = (filteredDataSource, checkAll) => ( this.handleSelectAll('left', filteredDataSource, checkAll) - ); + ) handleRightSelectAll = (filteredDataSource, checkAll) => ( this.handleSelectAll('right', filteredDataSource, checkAll) - ); + ) handleFilter = (direction, e) => { this.setState({ diff --git a/components/tree-select/index.tsx b/components/tree-select/index.tsx index d1b7177af7..ddd2dd0ba6 100644 --- a/components/tree-select/index.tsx +++ b/components/tree-select/index.tsx @@ -20,7 +20,7 @@ abstract class TreeSelect extends React.Component { dropdownClassName: 'ant-select-tree-dropdown', }; - abstract getLocale() + abstract getLocale(); render() { const locale = this.getLocale(); diff --git a/components/tree-select/style/index.less b/components/tree-select/style/index.less index 5ffa4af45c..7f54d381fd 100644 --- a/components/tree-select/style/index.less +++ b/components/tree-select/style/index.less @@ -27,9 +27,9 @@ margin: 0; padding: 0 0 0 18px; } - > span { + .@{select-tree-prefix-cls}-node-content-wrapper { display: inline-block; - padding: 1px 5px; + padding: 3px 5px; border-radius: 2px; margin: 0; cursor: pointer; @@ -41,22 +41,25 @@ background-color: @item-hover-bg; } &.@{select-tree-prefix-cls}-node-selected { - background-color: @item-active-bg; + background-color: @primary-2; } + } + > span { &.@{select-tree-prefix-cls}-checkbox { margin: 2px 4px 0 0; } &.@{select-tree-prefix-cls}-switcher, &.@{select-tree-prefix-cls}-iconEle { margin: 0; - width: 16px; - height: 16px; - line-height: 16px; + width: 24px; + height: 24px; + line-height: 24px; display: inline-block; vertical-align: middle; border: 0 none; cursor: pointer; outline: none; + text-align: center; } &.@{select-tree-prefix-cls}-icon_loading { &:after { diff --git a/components/tree/style/index.less b/components/tree/style/index.less index 65b78fa054..d11ccd9dc0 100644 --- a/components/tree/style/index.less +++ b/components/tree/style/index.less @@ -55,7 +55,7 @@ } .@{tree-prefix-cls}-node-content-wrapper { display: inline-block; - padding: 1px 5px; + padding: 3px 5px; border-radius: 2px; margin: 0; cursor: pointer; @@ -78,14 +78,15 @@ &.@{tree-prefix-cls}-switcher, &.@{tree-prefix-cls}-iconEle { margin: 0; - width: 16px; - height: 16px; - line-height: 16px; + width: 24px; + height: 24px; + line-height: 24px; display: inline-block; vertical-align: middle; border: 0 none; cursor: pointer; outline: none; + text-align: center; } &.@{tree-prefix-cls}-icon_loading { &:after { @@ -187,7 +188,7 @@ border-left: 1px solid @border-color-base; height: 100%; position: absolute; - left: 6px; + left: 12px; margin: 18px 0; } } diff --git a/docs/react/introduce.en-US.md b/docs/react/introduce.en-US.md index b86ba94a8f..65cb62ee0d 100644 --- a/docs/react/introduce.en-US.md +++ b/docs/react/introduce.en-US.md @@ -34,7 +34,7 @@ Following the Ant Design specification, we developed a React UI library `antd` t ## Environment Support -* Modern browsers and Internet Explorer 9+ +* Modern browsers and Internet Explorer 9+ (with [polyfills](https://ant.design/docs/react/getting-started#Compatibility)) * Server-side Rendering * [Electron](http://electron.atom.io/) diff --git a/docs/react/introduce.zh-CN.md b/docs/react/introduce.zh-CN.md index 0b330d9ab6..040b001272 100644 --- a/docs/react/introduce.zh-CN.md +++ b/docs/react/introduce.zh-CN.md @@ -34,7 +34,7 @@ title: Ant Design of React ## 支持环境 -* 现代浏览器和 IE9 及以上。 +* 现代浏览器和 IE9 及以上(需要 [polyfills](https://ant.design/docs/react/getting-started-cn#兼容性))。 * 支持服务端渲染。 * [Electron](http://electron.atom.io/) diff --git a/docs/react/use-with-create-react-app.en-US.md b/docs/react/use-with-create-react-app.en-US.md index 3c8dd5b708..a9c39f4cee 100644 --- a/docs/react/use-with-create-react-app.en-US.md +++ b/docs/react/use-with-create-react-app.en-US.md @@ -56,7 +56,7 @@ It is the default directory structure below. Now we install `antd` from yarn or npm. ```bash -$ yarn add antd --save +$ yarn add antd ``` Modify `src/App.js`, import Button component from `antd`. @@ -113,7 +113,7 @@ $ yarn run eject [babel-plugin-import](https://github.com/ant-design/babel-plugin-import) is a babel plugin for importing components on demand ([principle](/docs/react/getting-started#Import-on-Demand)). After eject all config files to antd-demo, we allowed to install it and modify `config/webpack.config.dev.js` now. ```bash -$ yarn add babel-plugin-import --save-dev +$ yarn add babel-plugin-import --dev ``` ```diff @@ -121,10 +121,10 @@ $ yarn add babel-plugin-import --save-dev { test: /\.(js|jsx)$/, include: paths.appSrc, - loader: 'babel', - query: { + loader: require.resolve('babel-loader'), + options: { + plugins: [ -+ ['import', [{ libraryName: "antd", style: 'css' }]], ++ ['import', { libraryName: 'antd', style: 'css' }], + ], // This is a feature of `babel-loader` for webpack (not Babel itself). // It enables caching results in ./node_modules/.cache/babel-loader/ @@ -145,22 +145,27 @@ Then reboot `yarn start` and visit demo page, you should find that the above war According to [Customize Theme documentation](/docs/react/customize-theme), we need `less` variables modify ability of [less-loader](https://github.com/webpack/less-loader), so we add it. ```bash -$ yarn add less less-loader --save-dev +$ yarn add less less-loader --dev ``` ```diff -loaders: [ { exclude: [ /\.html$/, /\.(js|jsx)$/, -+ /\.less$/, /\.css$/, ++ /\.less$/, /\.json$/, - /\.svg$/ + /\.bmp$/, + /\.gif$/, + /\.jpe?g$/, + /\.png$/, ], - loader: 'url', - }, + loader: require.resolve('file-loader'), + options: { + name: 'static/media/[name].[hash:8].[ext]', + }, + } ... @@ -169,21 +174,48 @@ loaders: [ test: /\.(js|jsx)$/, include: paths.appSrc, loader: 'babel', - query: { + options: { plugins: [ -- ['import', [{ libraryName: "antd", style: 'css' }]], -+ ['import', [{ libraryName: "antd", style: true }]], // import less +- ['import', [{ libraryName: 'antd', style: 'css' }]], ++ ['import', [{ libraryName: 'antd', style: true }]], // import less ], }, ... -+ // Parse less files and modify variables -+ { -+ test: /\.less$/, -+ loader: 'style!css!postcss!less?{modifyVars:{"@primary-color":"#1DA57A"}}' -+ }, -] ++ // Parse less files and modify variables ++ { ++ test: /\.less$/, ++ use: [ ++ require.resolve('style-loader'), ++ require.resolve('css-loader'), ++ { ++ loader: require.resolve('postcss-loader'), ++ options: { ++ ident: 'postcss', // https://webpack.js.org/guides/migrating/#complex-options ++ plugins: () => [ ++ require('postcss-flexbugs-fixes'), ++ autoprefixer({ ++ browsers: [ ++ '>1%', ++ 'last 4 versions', ++ 'Firefox ESR', ++ 'not ie < 9', // React doesn't support IE8 anyway ++ ], ++ flexbox: 'no-2009', ++ }), ++ ], ++ }, ++ }, ++ { ++ loader: require.resolve('less-loader'), ++ options: { ++ modifyVars: { "@primary-color": "#1DA57A" }, ++ }, ++ }, ++ ], ++ }, +], ``` We use `modifyVars` option of [less-loader](https://github.com/webpack/less-loader#less-options) here, you can see a green button rendered on the page after reboot start server. diff --git a/docs/react/use-with-create-react-app.zh-CN.md b/docs/react/use-with-create-react-app.zh-CN.md index 398d448808..e74233dbfa 100644 --- a/docs/react/use-with-create-react-app.zh-CN.md +++ b/docs/react/use-with-create-react-app.zh-CN.md @@ -55,7 +55,7 @@ $ yarn start 现在从 yarn 或 npm 安装并引入 antd。 ```bash -$ yarn add antd --save +$ yarn add antd ``` 修改 `src/App.js`,引入 antd 的按钮组件。 @@ -110,7 +110,7 @@ $ yarn run eject [babel-plugin-import](https://github.com/ant-design/babel-plugin-import) 是一个用于按需加载组件代码和样式的 babel 插件([原理](/docs/react/getting-started#按需加载)),现在我们尝试安装它并修改 `config/webpack.config.dev.js` 文件。 ```bash -$ yarn add babel-plugin-import --save-dev +$ yarn add babel-plugin-import --dev ``` ```diff @@ -118,10 +118,10 @@ $ yarn add babel-plugin-import --save-dev { test: /\.(js|jsx)$/, include: paths.appSrc, - loader: 'babel', - query: { + loader: require.resolve('babel-loader'), + options: { + plugins: [ -+ ['import', [{ libraryName: "antd", style: 'css' }]], ++ ['import', { libraryName: 'antd', style: 'css' }], + ], // This is a feature of `babel-loader` for webpack (not Babel itself). // It enables caching results in ./node_modules/.cache/babel-loader/ @@ -142,22 +142,27 @@ $ yarn add babel-plugin-import --save-dev 按照 [配置主题](/docs/react/customize-theme) 的要求,自定义主题需要用到 less 变量覆盖功能,因此首先我们需要引入 [less-loader](https://github.com/webpack/less-loader) 来加载 less 样式,同时修改 `config/webpack.config.dev.js` 文件。 ```bash -$ yarn add less less-loader --save-dev +$ yarn add less less-loader --dev ``` ```diff -loaders: [ { exclude: [ /\.html$/, /\.(js|jsx)$/, -+ /\.less$/, /\.css$/, ++ /\.less$/, /\.json$/, - /\.svg$/ + /\.bmp$/, + /\.gif$/, + /\.jpe?g$/, + /\.png$/, ], - loader: 'url', - }, + loader: require.resolve('file-loader'), + options: { + name: 'static/media/[name].[hash:8].[ext]', + }, + } ... @@ -166,21 +171,48 @@ loaders: [ test: /\.(js|jsx)$/, include: paths.appSrc, loader: 'babel', - query: { + options: { plugins: [ -- ['import', [{ libraryName: "antd", style: 'css' }]], -+ ['import', [{ libraryName: "antd", style: true }]], // 加载 less 文件 +- ['import', [{ libraryName: 'antd', style: 'css' }]], ++ ['import', [{ libraryName: 'antd', style: true }]], // import less ], }, ... -+ // 解析 less 文件,并加入变量覆盖配置 -+ { -+ test: /\.less$/, -+ loader: 'style!css!postcss!less?{modifyVars:{"@primary-color":"#1DA57A"}}' -+ }, -] ++ // Parse less files and modify variables ++ { ++ test: /\.less$/, ++ use: [ ++ require.resolve('style-loader'), ++ require.resolve('css-loader'), ++ { ++ loader: require.resolve('postcss-loader'), ++ options: { ++ ident: 'postcss', // https://webpack.js.org/guides/migrating/#complex-options ++ plugins: () => [ ++ require('postcss-flexbugs-fixes'), ++ autoprefixer({ ++ browsers: [ ++ '>1%', ++ 'last 4 versions', ++ 'Firefox ESR', ++ 'not ie < 9', // React doesn't support IE8 anyway ++ ], ++ flexbox: 'no-2009', ++ }), ++ ], ++ }, ++ }, ++ { ++ loader: require.resolve('less-loader'), ++ options: { ++ modifyVars: { "@primary-color": "#1DA57A" }, ++ }, ++ }, ++ ], ++ }, +], ``` 这里利用了 [less-loader](https://github.com/webpack/less-loader#less-options) 的 `modifyVars` 来进行主题配置, diff --git a/package.json b/package.json index 339df88bd2..1ffe860d0b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "antd", - "version": "2.10.1", + "version": "2.10.3", "title": "Ant Design", "description": "An enterprise-class UI design language and React-based implementation", "homepage": "http://ant.design/", @@ -26,9 +26,11 @@ "url": "https://github.com/ant-design/ant-design/issues" }, "main": "lib/index.js", + "module": "es/index.js", "files": [ "dist", - "lib" + "lib", + "es" ], "typings": "lib/index.d.ts", "license": "MIT", @@ -45,7 +47,7 @@ "omit.js": "^0.1.0", "prop-types": "^15.5.7", "rc-animate": "~2.3.0", - "rc-calendar": "~8.2.0", + "rc-calendar": "~8.4.0", "rc-cascader": "~0.11.0", "rc-checkbox": "~2.0.0", "rc-collapse": "~1.7.0", @@ -80,7 +82,7 @@ "@types/react": "^15.0.8", "@types/react-dom": "~0.14.18", "antd-demo-jest": "^1.0.5", - "antd-tools": "~0.19.1", + "antd-tools": "^1.4.2", "babel-cli": "^6.18.0", "babel-eslint": "^7.1.0", "babel-jest": "^19.0.0", @@ -138,7 +140,7 @@ "rimraf": "^2.5.4", "stylelint": "^7.8.0", "stylelint-config-standard": "^16.0.0", - "typescript": "~2.2.1", + "typescript": "~2.3.0", "typescript-babel-jest": "^1.0.2", "values.js": "^1.0.3", "xhr2": "^0.1.3" @@ -198,8 +200,8 @@ "/_site/" ], "testPathIgnorePatterns": [ - "dekko", "/node_modules/", + "dekko", "node" ], "transform": { @@ -210,11 +212,13 @@ "testRegex": ".*\\.test\\.js$", "collectCoverageFrom": [ "components/**/*.{ts,tsx}", - "!components/*/style/index.tsx" + "!components/*/style/index.tsx", + "!components/style/index.tsx", + "!components/*/locale/index.tsx" ], "transformIgnorePatterns": [ "/node_modules/", - "/dist/antd.js" + "/dist/" ], "snapshotSerializers": [ "enzyme-to-json/serializer" diff --git a/site/theme/static/demo.less b/site/theme/static/demo.less index b8a9e9dd9f..1363643a3a 100644 --- a/site/theme/static/demo.less +++ b/site/theme/static/demo.less @@ -62,6 +62,7 @@ transform: scale(0.9); background: #fff; padding-right: 6px; + text-decoration: none; } &-demo { diff --git a/site/theme/static/home.less b/site/theme/static/home.less index 7cdfc51ce4..af9879022a 100644 --- a/site/theme/static/home.less +++ b/site/theme/static/home.less @@ -50,6 +50,7 @@ font-weight: 500; border-radius: @border-radius-base; border: 1px solid @start-button-color; + text-decoration: none; color: #0ae; font-size: 15px; background: transparent; diff --git a/site/theme/static/markdown.less b/site/theme/static/markdown.less index 9fbd4c35b5..4c2f155bbb 100644 --- a/site/theme/static/markdown.less +++ b/site/theme/static/markdown.less @@ -164,6 +164,7 @@ display: inline-block; margin-left: 10px; height: 12px; + text-decoration: none; i { color: #999; diff --git a/site/theme/static/page-nav.less b/site/theme/static/page-nav.less index 7111223a3a..fdbeae444b 100644 --- a/site/theme/static/page-nav.less +++ b/site/theme/static/page-nav.less @@ -14,6 +14,7 @@ float: left; line-height: 72px; height: 72px; + text-decoration: none; } > a.prev-page { diff --git a/tests/index.test.js b/tests/index.test.js index 67bf37ff3b..e920ee205d 100644 --- a/tests/index.test.js +++ b/tests/index.test.js @@ -1,5 +1,3 @@ -import fs from 'fs'; -import path from 'path'; import pkg from '../package.json'; describe('antd dist files', () => { @@ -13,14 +11,6 @@ describe('antd dist files', () => { // https://github.com/ant-design/ant-design/issues/1970 // https://github.com/ant-design/ant-design/issues/1804 if (process.env.CI) { - it('should be compatible in IE8', () => { - const antdJsContent = fs.readFileSync(path.join(process.cwd(), 'dist', 'antd.js')); - expect( - antdJsContent.toString() - .indexOf('function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }') - ).toBe(-1); - }); - it('should have antd.version', () => { const antd = require('../dist/antd'); // eslint-disable-line global-require expect(antd.version).toBe(pkg.version); diff --git a/tsconfig.json b/tsconfig.json index fa6a181338..dd6df7d6d7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,6 +5,8 @@ "allowSyntheticDefaultImports": true, "experimentalDecorators": true, "jsx": "preserve", + "noUnusedParameters": true, + "noUnusedLocals": true, "target": "es6", "lib": [ "dom", @@ -12,6 +14,8 @@ ] }, "exclude": [ - "node_modules" + "node_modules", + "lib", + "es" ] } diff --git a/webpack.config.js b/webpack.config.js index c5fcd0f32e..ed5ec6f0a3 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -10,14 +10,6 @@ function ignoreMomentLocale(webpackConfig) { webpackConfig.plugins.push(new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)); } -// Fix ie8 compatibility -function es3ify(webpackConfig) { - webpackConfig.module.loaders.unshift({ - test: /\.(tsx|jsx?)$/, - loader: 'es3ify-loader', - }); -} - function addLocales(webpackConfig) { let packageName = 'antd-with-locales'; if (webpackConfig.entry['antd.min']) { @@ -28,10 +20,9 @@ function addLocales(webpackConfig) { } module.exports = function (webpackConfig) { - webpackConfig = getWebpackConfig(webpackConfig); + webpackConfig = getWebpackConfig(webpackConfig, true); if (process.env.RUN_ENV === 'PRODUCTION') { webpackConfig.forEach((config) => { - es3ify(config); ignoreMomentLocale(config); addLocales(config); });