antd 3.0.0
2017-12-04
Learn more in the Ant Design 3.0 announcement post!
Major Changes
- New color system, We changed our primary color from 『
#108EE9』 to 『#1890FF』, we called the new primary color "拂晓蓝(Daybreak blue)" which means the color of the sky at daybreak. - New design of components.
- Increased the base font size from 12px to 14px.
- Changed default locale to en_US.
- Support React 16.
- Better TypeScript support.
- New List component.
- New Divider component.
- 30 New icons.
Breaking Changes
We provide a migration tool to help you find deprecated usages in your codebase.
-
Card's
noHoveringhas been renamed tohoverable,and its default value now istrue. -
Added new Grid breakpoints. #7230
-
Form
getFieldDecorator'sexclusiveoption has been removeed. -
Added
Form.createFormField, and you must use it to wrap field data returned inoption.mapPropsToFields:import { Form } from 'antd'; Form.create({ mapPropsToFields() { return { - name: { value: 'antd' }, + name: Form.createFormField({ value: 'antd' }), }; }, }) -
Improved global reset style, if you encounter style problem after upgrading, you can try import our v2 compatible style.
import 'antd/lib/style/v2-compatible-reset';Or use less
@import '~antd/lib/style/v2-compatible-reset.css'; -
Since we changed default locale to en_US, LocalProvider is not required any more for English users.
-
We don't set
size="large"toInputinFormby default any more. -
UMD version of
dist/antd.jsdoesn't include moment any more, you need add moment by yourself if you are using the UMD version.<html> <head> + <script src="https://unpkg.com/moment@2.19.3/moment.js"></script> <script src="https://unpkg.com/antd@3.0.0/dist/antd.js"></script> </head> </html>
Removed Deprecations
- 🗑 DatePicker.Calendar has been removed, you can use Calendar directly.
- 🗑 DatePicker's
toggleOpenprop has been removed, useonOpenChangeinstead. - 🗑 Form's
inline,horizontal,verticalprops has been removed, uselayoutinstead. - 🗑 Input's
typeprop has dropped textarea support, please use Input.TextArea instead. - 🗑 Mention's
toEditorStatehas been removed. - 🗑 Select's
multiple,combobox,tagsprops has been removed, usemodeinstead.
Features and Improvements
- 🌟 Tabs added new size
size="large"。 - 🌟 Row's
gutternow support responsive setting, you can writegutter={{ sm: 16, lg: 32 }}. - 🌟 Spin added new
indicatorprop to allow setting custom indicator. #7977 @kossel - 🌟 Input.Search added new
enterButtonprop to allow setting custom search button.#7596 - 🌟 Mention added new
placementprop to allow setting the popup direction. - 🌟 Carousel added new
next(),prev(),goTo(slideNumber)methods to allow controlling slides programmatically. - 🌟 Button added link support,Button with
hrefprop will render to<a>. #8343 - 🌟 Steps was refactored, first rendering won't flash. #6010
- 🌟 Switch added new
loadingprop to show a loading status. - Menu
- 🌟 Added new
subMenuOpenDelayandsubMenuCloseDelayprops to allow setting delay time for submenu toggling. - 🌟 Added new
forceSubMenuRenderprop to render submenu even if it's collapsed. #5586
- 🌟 Added new
- Form
- 🌟 Added animations for validation message showing.
- 🌟 Added field conditional rendering support. #react-component/117
- Message
- 🌟 Allow
durationoptional. #7857 @monkindey
- 🌟 Allow
- Badge
- 🌟 Added new
offsetprop to allow setting the offset of status point. - 🌟
statuscan use whithchildrennow. #8164
- 🌟 Added new
- Card
- DatePicker
- TimePicker
- 🌟 Added new
hourStep,minuteStep,secondStepprops to allow customizing time setps. Demo - 🌟 Added new
focusOnOpenprop to focus input after panel is open.
- 🌟 Added new
- Table
- 🌟 Added new
componentsprop to allow overriding default table elements.// You can override following elements const components = { table: MyTable, header: { wrapper: HeaderWrapper, row: HeaderRow, cell: HeaderCell, }, body: { wrapper: BodyWrapper, row: BodyRow, cell: BodyCell, }, }; <Table components={components} columns={columns data={data}} /> - 🌟 Added new
onRowprop to allow passing custom props to table body row. - 🌟 Added new
onHeaderRowprops to allow passing custom props to table header row. - 🌟 Added
column[onCell]to allow passing custom props to table body cell. - 🌟 Added
column[onHeaderCell]to allow passing custom props to table header cell. - 🌟 Added
column[align]to allow setting how text aligns. - 🌟 Added
column[defaultSortOrder]to allow setting default sort order. #8111 @megawac - 🌟 Added
rowSelection[fixed]to allow fixing the selection column.。 - 🙅 Deprecated
getBodyWrapper, please usecomponentsinstead. - 🙅 Deprecated
onRowClick,onRowDoubleClick、onRowContextMenu、onRowMouseEnter、onRowMouseLeave, please useonRowinstead.<Table onRow={(record) => ({ onClick: () => {}, onDoubleClick: () => {}, onContextMenu: () => {}, onMouseEnter: () => {}, onMouseLeave: () => {}, })} />
- 🌟 Added new
- Select
- 🌟 Option's value can be a number in single or multiple mode.
- 🌟 Added new
maxTagCountandmaxTagPlaceholderprops. - 🌟 Added new
showActionprop to allow setting the trigger action for popup. - 🌟 Added new
onMouseEnterandonMouseLeavecallback.
- LocaleProvider
- 🇮🇸 Added Icelandic. #7561 @paunovic-stefan
- 🇪🇬 Added Egyptian Arabic. #7888 @mohamed-seada-1994
- 🇺🇦 Added Ukrainian. #8169 @anxolerd
Bug fixes
- Form
- 🐞 Fixed issue result in Input icon is hovered by feedback icon.
- 🐞 Fixed feedback icon not centered in large input.
- 🐞 Fix Menu key press error. #8089
Other things
- Don't need set
allowSyntheticDefaultImportswhen using in TypeScript. - We removed
react@0.14andreact@15frompeerDependencies, thoughantd@3.0still works on old React versions, but we highly recommend you upgrading to React 16 since we may use the new features only exists in React 16 in the future. See React 16 - Fully es module support, if you are using webpack 3, you can set babel-import-plugin's
libraryDirectorytoesto enable tree shaking . - We will support 2.x branch until July in next year.
更多内容见 Ant Design 3.0 发布公告!
主要变化
- 全新的色彩系统, 组件主色由 『
#108EE9』 改为 『#1890FF』,新主色我们称之为“拂晓蓝”。 - 全新的视觉样式和组件尺寸,更现代更美观。
- 基础字体大小由
12px增大到14px。 - 默认语言由中文改为英文。
- 全面支持 React 16。
- 更友好的 TypeScript 支持。
- 新的 List 组件。
- 新的 Divider 组件。
- 新增 30 个图标。
不兼容改动
此版本有部分不兼容的改动,升级时确保修改相应的使用代码。另外由于人肉查找代码中的废弃用法过于低效,所以我们提供了 antd-migration-helper 用于扫描代码中的废弃用法。
-
Card 的
noHovering属性重命名为hoverable,且默认值改为true。 -
调整了 Grid 的响应式断点值。详见 #7230
-
Form
getFieldDecorator的exclusive参数被移除,此类场景应该由 Radio.Group、Checkbox.Group 之类的组件来完成。 -
新增
Form.createFormField方法,mapPropsToFields返回的字段都需要由该方法创建。import { Form } from 'antd'; Form.create({ mapPropsToFields() { return { - name: { value: 'antd' }, + name: Form.createFormField({ value: 'antd' }), }; }, }) -
优化了全局的重置样式,如果升级后你的全局样式有问题,可以引入我们提供的 2.x 兼容样式。
import 'antd/style/v2-compatible-reset';或者在 less 里引入
@import '~antd/style/v2-compatible-reset.css'; -
由于默认语言改为英文,如果你需要显示中文,现在需要配置
LocalProvider。import { LocaleProvider } from 'antd'; import zhCN from 'antd/lib/locale-provider/zh_CN'; ReactDOM.render( <LocaleProvider locale={zhCN}><YourApp /></LocaleProvider>, document.getElementById('root') ); -
Form 下的表单控件不再默认为 size="large"。
<html> <head> + <script src="https://unpkg.com/moment@2.19.3/moment.js"></script> <script src="https://unpkg.com/antd@3.0.0/dist/antd.js"></script> </head> </html>
以下在 2.x 中废弃的特性被移除
- 🗑 移除了 DatePicker.Calendar, 请直接使用 Calendar 组件。
- 🗑 移除了 DatePicker 的
toggleOpen属性, 请使用onOpenChange代替。 - 🗑 移除了 Form 的
inline、horizontal、vertical属性,请使用layout代替。 - 🗑 移除了 Select 的
multiple、tags、combobox属性,请使用mode代替。 - 🗑 移除了 Input 对
type='textarea'的支持,请直接使用Input.TextArea组件。 - 🗑 移除了 Mention 的
toEditorState方法,请使用toContentState代替。
新增功能及改进
- 🌟 Tabs 新增
size="large"。 - 🌟 Row 的
gutter属性新增响应式断点的支持,可以使用诸如gutter={{ sm: 16, lg: 32 }}的设置。 - 🌟 Spin 新增
indicator属性,用于设置自定义的加载指示符。 #7977 @kossel - 🌟 Input.Search 新增
enterButton用于设置自定义的搜索图标。#7596 - 🌟 Mention 新增
placement, 用于设置下拉框的弹出方向。 - 🌟 Carousel 新增
next()、prev()、goTo(slideNumber)方法,用于控制面板展示。 - 🌟 Button 新增链接支持,当提供
href时会自动渲染为<a>。#8343 - 🌟 Steps 进行了重构,首次渲染的时候不会再闪烁。 #6010
- 🌟 Switch 新增
loading属性,用于表现加载中的状态。 - Menu
- 🌟 新增
subMenuOpenDelay和subMenuCloseDelay,用于设置子菜单打开和关闭的延迟。 - 🌟 新增
forceSubMenuRender,用于强制渲染子菜单。#5586
- 🌟 新增
- Form
- 🌟 新增显示验证信息时的动画效果。
- 🌟 新增按条件渲染表单项的支持。#react-component/117
- Message
- 🌟
duration允许可选 #7857 @monkindey
- 🌟
- Badge
- 🌟 新增
offset属性,用于设置状态点的位置偏移。 - 🌟
status允许与children同时使用。#8164
- 🌟 新增
- Card
- DatePicker
- TimePicker
- 🌟 新增
hourStep、minuteStep、secondStep,用于设置时间步长。例子 - 🌟 新增
focusOnOpen,用于设置在打开面板的时候是否聚焦输入框。
- 🌟 新增
- Table
- 🌟 新增
components属性,用于覆盖表格元素的默认标签。// 支持覆盖的元素 const components = { table: MyTable, header: { wrapper: HeaderWrapper, row: HeaderRow, cell: HeaderCell, }, body: { wrapper: BodyWrapper, row: BodyRow, cell: BodyCell, }, }; <Table components={components} columns={columns data={data}} /> - 🌟 新增
onRow属性,用于设置表格列的属性。 - 🌟 新增
onHeaderRow,用户设置表格头部列的属性。 - 🌟 新增
column[onCell],用户设置单元格的属性。 - 🌟 新增
column[onHeaderCell],用于设置头部单元格的属性。 - 🌟 新增
column[align],用于设置列内文字的对其方向。 - 🌟 新增
column[defaultSortOrder],用于设置列的默认排序。#8111 @megawac - 🌟 新增
rowSelection[fixed],用于固定选择列。 - 🙅 废弃
getBodyWrapper,请使用components属性代替。 - 🙅 废弃以下属性
onRowClick,onRowDoubleClick、onRowContextMenu、onRowMouseEnter、onRowMouseLeave,请使用onRow代替。<Table onRow={(record) => ({ onClick: () => {}, onDoubleClick: () => {}, onContextMenu: () => {}, onMouseEnter: () => {}, onMouseLeave: () => {}, })} />
- 🌟 新增
- Select
- 🌟 默认和多选模式下 Option 的值允许使用 number。
- 🌟 新增
maxTagCount 和maxTagPlaceholder`,用与设置最多可显示的选中项。 - 🌟 新增
showAction,用于设置出发下拉框打开的事件。 - 🌟 新增
onMouseEnter和onMouseLeave事件回调。
- LocaleProvider
- 🇮🇸 新增冰岛语。#7561 @paunovic-stefan
- 🇪🇬 新增埃及语。#7888 @mohamed-seada-1994
- 🇺🇦 新增乌克兰语。#8169 @anxolerd
Bug 修复
- Form
- 🐞 修复输入框的图标会被验证图标覆盖的问题。
- 🐞 修复使用大尺寸输入框时,验证图标不居中的问题。
- 🐞 修复 Menu 按键时的报错。#8089
其他
- 在 TypeScript 中使用时不再需要设置
allowSyntheticDefaultImports。 - 从
peerDependencies中移除了react@0.14和react@15,虽然目前 antd 3.0.0 依然可以在旧版本的 React 上使用,但是我们在未来有可能使用 React 16 的新特性,所以强烈建议升级到 React 16,见升级文档。 - 全面支持 ES Module ,antd 及其依赖的底层 react-component 组件全部提供了 ES Module 的构建版本,如果你使用 webpack 3,可以把
babel-import-plugin的libraryDirectory设置为es,以获得 Tree Shaking 的优化效果。 - 最后,我们会继续维护 2.x 的分支到明年 6 月份。