From 44d5fc6fd2a2f0ab7181932cbc30f50afd6e1569 Mon Sep 17 00:00:00 2001 From: Benjy Cui Date: Sat, 10 Sep 2016 14:28:40 +0800 Subject: [PATCH 01/24] fix: both of undefined and null means no input, close: #2959 --- components/form/FormItem.tsx | 2 +- site/theme/template/Layout/Header.jsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/form/FormItem.tsx b/components/form/FormItem.tsx index 3e6714e44d..66475dece9 100644 --- a/components/form/FormItem.tsx +++ b/components/form/FormItem.tsx @@ -120,7 +120,7 @@ export default class FormItem extends React.Component { return 'validating'; } else if (!!getFieldError(field)) { return 'error'; - } else if (getFieldValue(field) !== undefined) { + } else if (getFieldValue(field) !== undefined && getFieldValue(field) !== null) { return 'success'; } return ''; diff --git a/site/theme/template/Layout/Header.jsx b/site/theme/template/Layout/Header.jsx index e91f370d93..1dea7c3ff3 100644 --- a/site/theme/template/Layout/Header.jsx +++ b/site/theme/template/Layout/Header.jsx @@ -109,7 +109,7 @@ export default class Header extends React.Component { const url = `/components/${pathSnippet}`; const subtitle = meta.subtitle || meta.chinese; return ( - From 1dac1370decd103ab0339136edc3f7e097000a24 Mon Sep 17 00:00:00 2001 From: Benjy Cui Date: Sat, 10 Sep 2016 17:17:55 +0800 Subject: [PATCH 02/24] deps: replace obejct.omit with omit.js, close: #2988 (#2994) --- components/back-top/index.tsx | 2 +- components/badge/ScrollNumber.tsx | 2 +- components/cascader/index.tsx | 2 +- components/form/Form.tsx | 2 +- components/input/Input.tsx | 4 ++-- components/spin/index.tsx | 2 +- components/tag/index.tsx | 2 +- custom-typings.d.ts | 4 ++-- package.json | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/components/back-top/index.tsx b/components/back-top/index.tsx index f8a5873056..8a4885ebe1 100644 --- a/components/back-top/index.tsx +++ b/components/back-top/index.tsx @@ -3,7 +3,7 @@ import Animate from 'rc-animate'; import Icon from '../icon'; import addEventListener from 'rc-util/lib/Dom/addEventListener'; import classNames from 'classnames'; -import omit from 'object.omit'; +import omit from 'omit.js'; function getScroll(target, top) { if (typeof window === 'undefined') { diff --git a/components/badge/ScrollNumber.tsx b/components/badge/ScrollNumber.tsx index 76ed566eea..b5ca04fdab 100644 --- a/components/badge/ScrollNumber.tsx +++ b/components/badge/ScrollNumber.tsx @@ -3,7 +3,7 @@ import { createElement, Component } from 'react'; import {findDOMNode} from 'react-dom'; import isCssAnimationSupported from '../_util/isCssAnimationSupported'; import assign from 'object-assign'; -import omit from 'object.omit'; +import omit from 'omit.js'; function getNumberArray(num) { return num ? diff --git a/components/cascader/index.tsx b/components/cascader/index.tsx index fc23058077..be1f9ec0ec 100644 --- a/components/cascader/index.tsx +++ b/components/cascader/index.tsx @@ -5,7 +5,7 @@ import Icon from '../icon'; import arrayTreeFilter from 'array-tree-filter'; import classNames from 'classnames'; import splitObject from '../_util/splitObject'; -import omit from 'object.omit'; +import omit from 'omit.js'; export interface CascaderOptionType { value: string; diff --git a/components/form/Form.tsx b/components/form/Form.tsx index 9e93fa3340..a196360f0b 100644 --- a/components/form/Form.tsx +++ b/components/form/Form.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import { PropTypes } from 'react'; import classNames from 'classnames'; import PureRenderMixin from 'react-addons-pure-render-mixin'; -import omit from 'object.omit'; +import omit from 'omit.js'; import warning from 'warning'; import assign from 'object-assign'; import FormItem from './FormItem'; diff --git a/components/input/Input.tsx b/components/input/Input.tsx index ab94a7eb09..317def73ec 100644 --- a/components/input/Input.tsx +++ b/components/input/Input.tsx @@ -3,7 +3,7 @@ import { Component, PropTypes } from 'react'; import classNames from 'classnames'; import calculateNodeHeight from './calculateNodeHeight'; import assign from 'object-assign'; -import omit from 'object.omit'; +import omit from 'omit.js'; function fixControlledValue(value) { if (typeof value === 'undefined' || value === null) { @@ -35,7 +35,7 @@ interface AutoSizeType { export interface InputProps { prefixCls?: string; className?: string; - type: string; + type?: string; id?: number | string; value?: any; defaultValue?: any; diff --git a/components/spin/index.tsx b/components/spin/index.tsx index 495f13e6e9..ea83735eef 100644 --- a/components/spin/index.tsx +++ b/components/spin/index.tsx @@ -4,7 +4,7 @@ import { findDOMNode } from 'react-dom'; import classNames from 'classnames'; import isCssAnimationSupported from '../_util/isCssAnimationSupported'; import splitObject from '../_util/splitObject'; -import omit from 'object.omit'; +import omit from 'omit.js'; export interface SpinProps { prefixCls?: string; diff --git a/components/tag/index.tsx b/components/tag/index.tsx index f2a8e8f237..2afe61ecdc 100644 --- a/components/tag/index.tsx +++ b/components/tag/index.tsx @@ -4,7 +4,7 @@ import Animate from 'rc-animate'; import Icon from '../icon'; import classNames from 'classnames'; import splitObject from '../_util/splitObject'; -import omit from 'object.omit'; +import omit from 'omit.js'; export interface TagProps { /** 标签是否可以关闭 */ diff --git a/custom-typings.d.ts b/custom-typings.d.ts index af6ffcca02..7d0d9c765f 100644 --- a/custom-typings.d.ts +++ b/custom-typings.d.ts @@ -67,8 +67,8 @@ declare module "object-assign" { export default function(target: any, ...sources: any[]): any; } -declare module "object.omit" { - export default function(target: any, ...sources: any[]): any; +declare module "omit.js" { + export default function(obj: Object, fields: string[]): any; } declare module 'rc-animate' { diff --git a/package.json b/package.json index 77d8e8d3fc..6f57b41ce3 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "gregorian-calendar": "~4.1.0", "gregorian-calendar-format": "~4.1.0", "object-assign": "~4.1.0", - "object.omit": "^2.0.0", + "omit.js": "^0.1.0", "rc-animate": "~2.3.0", "rc-calendar": "^7.0.3", "rc-cascader": "~0.10.1", From ab11f5e0927212b5d54f478100aea3dfab6bf88a Mon Sep 17 00:00:00 2001 From: Benjy Cui Date: Sat, 10 Sep 2016 17:35:37 +0800 Subject: [PATCH 03/24] bump 2.0.0-beta.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6f57b41ce3..032aad338f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "antd", - "version": "2.0.0-beta.0", + "version": "2.0.0-beta.1", "title": "Ant Design", "description": "An enterprise-class UI design language and React-based implementation", "homepage": "http://ant.design/", From 9777c7d0659b0c757f52d2bb2e9b6fe2313ac5da Mon Sep 17 00:00:00 2001 From: Shawn Sit Date: Sat, 10 Sep 2016 18:00:51 +0800 Subject: [PATCH 04/24] docs: translate demo (#2996) --- components/checkbox/demo/check-all.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/checkbox/demo/check-all.md b/components/checkbox/demo/check-all.md index 08e3c2ae91..9b4f6d50f8 100644 --- a/components/checkbox/demo/check-all.md +++ b/components/checkbox/demo/check-all.md @@ -37,7 +37,7 @@ const App = React.createClass({ onChange={this.onCheckAllChange} checked={this.state.checkAll} > - 全选 + Check all
From 25cb3e2d300b28d4f9e4edb9882cd80a95b969b2 Mon Sep 17 00:00:00 2001 From: Benjy Cui Date: Sat, 10 Sep 2016 18:14:23 +0800 Subject: [PATCH 05/24] docs: update demo to catch errors, close: #2912 --- components/modal/demo/confirm-promise.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/modal/demo/confirm-promise.md b/components/modal/demo/confirm-promise.md index e5265cd1ce..78de048eca 100644 --- a/components/modal/demo/confirm-promise.md +++ b/components/modal/demo/confirm-promise.md @@ -23,9 +23,9 @@ function showConfirm() { title: 'Are you sure you want to delete this item ?', content: 'When clicked the OK button, this dialog will be closed after 1 second', onOk() { - return new Promise((resolve) => { - setTimeout(resolve, 1000); - }); + return new Promise((resolve, reject) => { + setTimeout(Math.random() > 0.5 ? resolve : reject, 1000); + }).catch(() => console.log('Oops errors!')); }, onCancel() {}, }); From 57cdbe1a6bbf998e4356ed9c9e3fe27f7e0ab916 Mon Sep 17 00:00:00 2001 From: Shawn Sit Date: Sat, 10 Sep 2016 18:23:24 +0800 Subject: [PATCH 06/24] docs: translated cascader demo (#2997) --- components/cascader/demo/basic.md | 14 +++++++------- components/cascader/demo/change-on-select.md | 12 ++++++------ components/cascader/demo/custom-render.md | 14 +++++++------- components/cascader/demo/default-value.md | 12 ++++++------ components/cascader/demo/disabled-option.md | 12 ++++++------ components/cascader/demo/hover.md | 14 +++++++------- components/cascader/demo/search.md | 14 +++++++------- components/cascader/demo/size.md | 12 ++++++------ 8 files changed, 52 insertions(+), 52 deletions(-) diff --git a/components/cascader/demo/basic.md b/components/cascader/demo/basic.md index 2c093c06ff..d99ed25930 100644 --- a/components/cascader/demo/basic.md +++ b/components/cascader/demo/basic.md @@ -18,24 +18,24 @@ import { Cascader } from 'antd'; const options = [{ value: 'zhejiang', - label: '浙江', + label: 'Zhejiang', children: [{ value: 'hangzhou', - label: '杭州', + label: 'Hangzhou', children: [{ value: 'xihu', - label: '西湖', + label: 'West Lake', }], }], }, { value: 'jiangsu', - label: '江苏', + label: 'Jiangsu', children: [{ value: 'nanjing', - label: '南京', + label: 'Nanjing', children: [{ value: 'zhonghuamen', - label: '中华门', + label: 'Zhong Hua Men', }], }], }]; @@ -45,6 +45,6 @@ function onChange(value) { } ReactDOM.render( - + , mountNode); ```` diff --git a/components/cascader/demo/change-on-select.md b/components/cascader/demo/change-on-select.md index 718937d79d..1a25b4f583 100644 --- a/components/cascader/demo/change-on-select.md +++ b/components/cascader/demo/change-on-select.md @@ -18,24 +18,24 @@ import { Cascader } from 'antd'; const options = [{ value: 'zhejiang', - label: '浙江', + label: 'Zhejiang', children: [{ value: 'hangzhou', - label: '杭州', + label: 'Hanzhou', children: [{ value: 'xihu', - label: '西湖', + label: 'West Lake', }], }], }, { value: 'jiangsu', - label: '江苏', + label: 'Jiangsu', children: [{ value: 'nanjing', - label: '南京', + label: 'Nanjing', children: [{ value: 'zhonghuamen', - label: '中华门', + label: 'Zhong Hua Men', }], }], }]; diff --git a/components/cascader/demo/custom-render.md b/components/cascader/demo/custom-render.md index 953b7e53f0..918f0cfd7e 100644 --- a/components/cascader/demo/custom-render.md +++ b/components/cascader/demo/custom-render.md @@ -18,25 +18,25 @@ import { Cascader } from 'antd'; const options = [{ value: 'zhejiang', - label: '浙江', + label: 'Zhejiang', children: [{ value: 'hangzhou', - label: '杭州', + label: 'Hangzhou', children: [{ value: 'xihu', - label: '西湖', + label: 'West Lake', code: 752100, }], }], }, { value: 'jiangsu', - label: '江苏', + label: 'Jiangsu', children: [{ value: 'nanjing', - label: '南京', + label: 'Nanjing', children: [{ value: 'zhonghuamen', - label: '中华门', + label: 'Zhong Hua Men', code: 453400, }], }], @@ -44,7 +44,7 @@ const options = [{ function handleAreaClick(e, label, option) { e.stopPropagation(); - console.log('点击了', label, option); + console.log('clicked', label, option); } const displayRender = (labels, selectedOptions) => labels.map((label, i) => { diff --git a/components/cascader/demo/default-value.md b/components/cascader/demo/default-value.md index c454a673a4..3773c06407 100644 --- a/components/cascader/demo/default-value.md +++ b/components/cascader/demo/default-value.md @@ -18,24 +18,24 @@ import { Cascader } from 'antd'; const options = [{ value: 'zhejiang', - label: '浙江', + label: 'Zhejiang', children: [{ value: 'hangzhou', - label: '杭州', + label: 'Hangzhou', children: [{ value: 'xihu', - label: '西湖', + label: 'West Lake', }], }], }, { value: 'jiangsu', - label: '江苏', + label: 'Jiangsu', children: [{ value: 'nanjing', - label: '南京', + label: 'Nanjing', children: [{ value: 'zhonghuamen', - label: '中华门', + label: 'Zhong Hua Men', }], }], }]; diff --git a/components/cascader/demo/disabled-option.md b/components/cascader/demo/disabled-option.md index 9731d6b668..7fd0664b06 100644 --- a/components/cascader/demo/disabled-option.md +++ b/components/cascader/demo/disabled-option.md @@ -18,25 +18,25 @@ import { Cascader } from 'antd'; const options = [{ value: 'zhejiang', - label: '浙江', + label: 'Zhejiang', children: [{ value: 'hangzhou', - label: '杭州', + label: 'Hangzhou', children: [{ value: 'xihu', - label: '西湖', + label: 'West Lake', }], }], }, { value: 'jiangsu', - label: '江苏', + label: 'Jiangsu', disabled: true, children: [{ value: 'nanjing', - label: '南京', + label: 'Nanjing', children: [{ value: 'zhonghuamen', - label: '中华门', + label: 'Zhong Hua Men', }], }], }]; diff --git a/components/cascader/demo/hover.md b/components/cascader/demo/hover.md index 6acfe66d15..35ece136e7 100644 --- a/components/cascader/demo/hover.md +++ b/components/cascader/demo/hover.md @@ -18,24 +18,24 @@ import { Cascader } from 'antd'; const options = [{ value: 'zhejiang', - label: '浙江', + label: 'Zhejiang', children: [{ value: 'hangzhou', - label: '杭州', + label: 'Hangzhou', children: [{ value: 'xihu', - label: '西湖', + label: 'West Lake', }], }], }, { value: 'jiangsu', - label: '江苏', + label: 'Jiangsu', children: [{ value: 'nanjing', - label: '南京', + label: 'Nanjing', children: [{ value: 'zhonghuamen', - label: '中华门', + label: 'Zhong Hua Men', }], }], }]; @@ -44,7 +44,7 @@ function onChange(value) { console.log(value); } -// 只展示最后一项 +// Just show the latest item. function displayRender(label) { return label[label.length - 1]; } diff --git a/components/cascader/demo/search.md b/components/cascader/demo/search.md index 0df9ce8957..0f4d042e81 100644 --- a/components/cascader/demo/search.md +++ b/components/cascader/demo/search.md @@ -18,24 +18,24 @@ import { Cascader } from 'antd'; const options = [{ value: 'zhejiang', - label: '浙江', + label: 'Zhejiang', children: [{ value: 'hangzhou', - label: '杭州', + label: 'Hangzhou', children: [{ value: 'xihu', - label: '西湖', + label: 'West Lake', }], }], }, { value: 'jiangsu', - label: '江苏', + label: 'Jiangsu', children: [{ value: 'nanjing', - label: '南京', + label: 'Nanjing', children: [{ value: 'zhonghuamen', - label: '中华门', + label: 'Zhong Hua men', }], }], }]; @@ -45,6 +45,6 @@ function onChange(value) { } ReactDOM.render( - + , mountNode); ```` diff --git a/components/cascader/demo/size.md b/components/cascader/demo/size.md index 1e26b2fcde..a7e004315d 100644 --- a/components/cascader/demo/size.md +++ b/components/cascader/demo/size.md @@ -18,24 +18,24 @@ import { Cascader } from 'antd'; const options = [{ value: 'zhejiang', - label: '浙江', + label: 'Zhejiang', children: [{ value: 'hangzhou', - label: '杭州', + label: 'Hangzhou', children: [{ value: 'xihu', - label: '西湖', + label: 'West Lake', }], }], }, { value: 'jiangsu', - label: '江苏', + label: 'Jiangsu', children: [{ value: 'nanjing', - label: '南京', + label: 'Nanjing', children: [{ value: 'zhonghuamen', - label: '中华门', + label: 'Zhong Hua Men', }], }], }]; From 10709251ec050335b77bfec3cc8b0193c89e5a0a Mon Sep 17 00:00:00 2001 From: kvetoslavnovak Date: Sat, 10 Sep 2016 18:30:08 +0200 Subject: [PATCH 07/24] #1471 (#3000) #1471 --- components/button/demo/icon.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/button/demo/icon.md b/components/button/demo/icon.md index 1c3c2322f3..2c46d0764c 100644 --- a/components/button/demo/icon.md +++ b/components/button/demo/icon.md @@ -23,7 +23,7 @@ import { Button } from 'antd'; ReactDOM.render(
+
From 23d68cad197d0e100ec0cafcf774522c5ed88b78 Mon Sep 17 00:00:00 2001 From: Marius Ileana Date: Sun, 11 Sep 2016 16:22:53 +0300 Subject: [PATCH 08/24] input/demo/basic.md - placeholder translated (#3005) placeholder value translated to english. --- components/input/demo/basic.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/input/demo/basic.md b/components/input/demo/basic.md index aa8f8a916c..14f5cb8782 100644 --- a/components/input/demo/basic.md +++ b/components/input/demo/basic.md @@ -16,5 +16,5 @@ Basic usage example ````jsx import { Input } from 'antd'; -ReactDOM.render(, mountNode); +ReactDOM.render(, mountNode); ```` From 00ac554e41896ee32174e77403548c9b308dcc69 Mon Sep 17 00:00:00 2001 From: Marius Ileana Date: Sun, 11 Sep 2016 16:23:57 +0300 Subject: [PATCH 09/24] docs/react/install.en-US.md - small typo update (#3004) --- docs/react/install.en-US.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/react/install.en-US.md b/docs/react/install.en-US.md index 2ebd35231c..1a983d3028 100644 --- a/docs/react/install.en-US.md +++ b/docs/react/install.en-US.md @@ -51,7 +51,7 @@ We provide `antd.js` `antd.css` and `antd.min.js` `antd.min.css` under `antd/dis - https://unpkg.com/antd@beta/dist/antd.min.js - https://unpkg.com/antd@beta/dist/antd.min.css -> Here is an [example](https://github.com/ant-design/antd-init/tree/master/examples/build-antd-standalone) about how to build your own antd.js if you are using antd@<1.0.0. +> Here is an [example](https://github.com/ant-design/antd-init/tree/master/examples/build-antd-standalone) of how to build your own antd.js if you are using antd@<1.0.0. ## Development tool @@ -63,6 +63,6 @@ $ npm install antd-init -g Inside an empty folder run `antd-init` to init. -You can explore the latest structure of scaffold [there]((https://github.com/ant-design/antd-init/tree/master/boilerplates)), it is a good habit to watch this repo to get the latest features. +You can explore the latest structure of scaffold [here](https://github.com/ant-design/antd-init/tree/master/boilerplates), it is a good habit to watch this repo to get the latest features. > [More development tools](http://ant-tool.github.io/)。 From df856b9d9a0110796f6b35fb79904f0b70858441 Mon Sep 17 00:00:00 2001 From: Marius Ileana Date: Mon, 12 Sep 2016 05:08:40 +0300 Subject: [PATCH 10/24] docs: radio/demo/radiobutton.md - English translation (#3007) English translation of labels --- components/radio/demo/radiobutton.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/components/radio/demo/radiobutton.md b/components/radio/demo/radiobutton.md index cf2d279634..1c69605eb2 100644 --- a/components/radio/demo/radiobutton.md +++ b/components/radio/demo/radiobutton.md @@ -25,26 +25,26 @@ function onChange(e) { ReactDOM.render(
- 杭州 - 上海 - 北京 - 成都 + Hangzhou + Shanghai + Beijing + Chengdu
- 杭州 + Hangzhou 上海 - 北京 - 成都 + Beijing + Chengdu
- 杭州 - 上海 - 北京 - 成都 + Hangzhou + Shanghai + Beijing + Chengdu
, mountNode); From 8e7fc057e6c47f2ccf7adb5a89b97cd9c8108ba2 Mon Sep 17 00:00:00 2001 From: Marius Ileana Date: Mon, 12 Sep 2016 05:09:03 +0300 Subject: [PATCH 11/24] docs: radio/demo/size.md - English translation (#3008) English translation of labels. --- components/radio/demo/size.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/components/radio/demo/size.md b/components/radio/demo/size.md index 0dcab55ef8..860c72d68b 100644 --- a/components/radio/demo/size.md +++ b/components/radio/demo/size.md @@ -11,7 +11,7 @@ title: ## en-US -There are three kinds of combination, large medium and small. It can coordinate with input box. +There are three sizes available: large, medium, and small. It can coordinate with input box. ```jsx import { Radio } from 'antd'; @@ -21,26 +21,26 @@ const RadioGroup = Radio.Group; ReactDOM.render(
- 杭州 - 上海 - 北京 - 成都 + Hangzhou + Shanghai + Beijing + Chengdu
- 杭州 - 上海 - 北京 - 成都 + Hangzhou + Shanghai + Beijing + Chengdu
- 杭州 - 上海 - 北京 - 成都 + Hangzhou + Shanghai + Beijing + Chengdu
, mountNode); From ced5c9a9ed333cf7e5052b16582450d19bf33ef7 Mon Sep 17 00:00:00 2001 From: Marius Ileana Date: Mon, 12 Sep 2016 05:09:22 +0300 Subject: [PATCH 12/24] docs: select/demo/search.md - English translation (#3009) English translation of labels. --- components/select/demo/search.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/select/demo/search.md b/components/select/demo/search.md index 58a62930ca..5304836401 100644 --- a/components/select/demo/search.md +++ b/components/select/demo/search.md @@ -22,14 +22,14 @@ function handleChange(value) { ReactDOM.render( , mountNode); ```` From bde1711597e9e993946f0c8d9785f66c6001e441 Mon Sep 17 00:00:00 2001 From: Marius Ileana Date: Mon, 12 Sep 2016 05:10:07 +0300 Subject: [PATCH 13/24] docs: select/demo/combobox.md - English translation (#3010) English translation of labels and comments --- components/select/demo/combobox.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/select/demo/combobox.md b/components/select/demo/combobox.md index e3f3a93110..9570fc1f08 100644 --- a/components/select/demo/combobox.md +++ b/components/select/demo/combobox.md @@ -41,13 +41,13 @@ const Test = React.createClass({ this.setState({ options }); }, render() { - // filterOption 需要设置为 false,数据是动态设置的 + // filterOption needs to be false,as the value is dynamically generated return ( From a8cc57cd1306a8bd30895d45e5fb6aa4807a5f9e Mon Sep 17 00:00:00 2001 From: Marius Ileana Date: Mon, 12 Sep 2016 05:10:27 +0300 Subject: [PATCH 14/24] docs: select/demo/coordinate.md - English translation (#3011) English translation of labels/data --- components/select/demo/coordinate.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/select/demo/coordinate.md b/components/select/demo/coordinate.md index 735e0f700f..4285426eb3 100644 --- a/components/select/demo/coordinate.md +++ b/components/select/demo/coordinate.md @@ -22,10 +22,10 @@ Using the [Cascader](/components/cascader) component is strongly recommended ins import { Select } from 'antd'; const Option = Select.Option; -const provinceData = ['浙江', '江苏']; +const provinceData = ['Zhejiang', 'Jiangsu']; const cityData = { - 浙江: ['杭州', '宁波', '温州'], - 江苏: ['南京', '苏州', '镇江'], + Zhejiang: ['Hangzhou', 'Ningbo', 'Wenzhou'], + Jiangsu: ['Nanjing', 'Suzhou', 'Zhenjiang'], }; const App = React.createClass({ From 71683f0cf6fb445ebeed60932ac04c1fc53c80da Mon Sep 17 00:00:00 2001 From: Marius Ileana Date: Mon, 12 Sep 2016 05:10:43 +0300 Subject: [PATCH 15/24] docs: radio/demo/disable.md - English translation (#3006) English translation of labels --- components/radio/demo/disable.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/radio/demo/disable.md b/components/radio/demo/disable.md index f7a4ddb589..990f341588 100644 --- a/components/radio/demo/disable.md +++ b/components/radio/demo/disable.md @@ -30,9 +30,9 @@ const App = React.createClass({ render() { return (
- 不可用 + Disabled
- 不可用 + Disabled
-#### Ant Design 十大设计原则 +#### Ant Design Principles -- [亲密性 Proximity](/docs/spec/proximity) -- [对齐 Alignment](/docs/spec/alignment) -- [对比 Contrast](/docs/spec/contrast) -- [重复 Repetition](/docs/spec/repetition) -- [直截了当 Make it Direct](/docs/spec/direct) -- [简化交互 Keep it Lightweight](/docs/spec/lightweight) -- [足不出户 Stay on the Page](/docs/spec/stay) -- [提供邀请 Provide Invitation](/docs/spec/invitation) -- [巧用过渡 Use Transition](/docs/spec/transition) -- [即时反应 React Immediately](/docs/spec/reaction) +- [Proximity](/docs/spec/proximity) +- [Alignment](/docs/spec/alignment) +- [Contrast](/docs/spec/contrast) +- [Repetition](/docs/spec/repetition) +- [Make it Direct](/docs/spec/direct) +- [Keep it Lightweight](/docs/spec/lightweight) +- [Stay on the Page](/docs/spec/stay) +- [Provide Invitation](/docs/spec/invitation) +- [Use Transition](/docs/spec/transition) +- [React Immediately](/docs/spec/reaction) From a94ccc442100ebf5754241972cfb45bea22b370e Mon Sep 17 00:00:00 2001 From: Marius Ileana Date: Mon, 12 Sep 2016 10:44:42 +0300 Subject: [PATCH 17/24] docs: Translation (and review) of docs/practice section (#2998) * translation (and review) of docs/practice secion * included the corrections of benjycui and afc comments/corrections included. --- docs/practice/bussiness.en-US.md | 7 ++ .../{bussiness.md => bussiness.zh-CN.md} | 0 docs/practice/cases.en-US.md | 86 +++++++++++++++++++ docs/practice/{cases.md => cases.zh-CN.md} | 0 4 files changed, 93 insertions(+) create mode 100644 docs/practice/bussiness.en-US.md rename docs/practice/{bussiness.md => bussiness.zh-CN.md} (100%) create mode 100644 docs/practice/cases.en-US.md rename docs/practice/{cases.md => cases.zh-CN.md} (100%) diff --git a/docs/practice/bussiness.en-US.md b/docs/practice/bussiness.en-US.md new file mode 100644 index 0000000000..dc77bb0a69 --- /dev/null +++ b/docs/practice/bussiness.en-US.md @@ -0,0 +1,7 @@ +--- +order: 1 +disabled: true +title: Business +--- + +TBD Content ... diff --git a/docs/practice/bussiness.md b/docs/practice/bussiness.zh-CN.md similarity index 100% rename from docs/practice/bussiness.md rename to docs/practice/bussiness.zh-CN.md diff --git a/docs/practice/cases.en-US.md b/docs/practice/cases.en-US.md new file mode 100644 index 0000000000..8105ab979c --- /dev/null +++ b/docs/practice/cases.en-US.md @@ -0,0 +1,86 @@ +--- +order: 0 +title: Cases +--- + +Ant Design is a design language for enterprise-like complex UIs. + +Starting in April 2015, more and more products of Ant Financial follow Ant Design specification, covering multiple business lines and more than 40 systems. +Designed for enterprise-like complex UIs, used by both professional and non-professional designers, +Ant Design has a low learning curve that helps you getting started fast and achieve rapid results. + +With a strong focus on proof-based design and user experience, +Ant Design provides a complete front-end development solution that can greatly enhance the design and development efficiency. + +Currently, there are many products and sites using Ant Design. +References to some of these implementations can be found [here](https://github.com/ant-design/ant-design/issues/477). +If your solutions are using Ant Design, please leave us a message. + +## Best Practices + +--- + +### Financial Cloud + + + + + +Cloud-oriented financial services, used by financial institutions that benefit from customized business cloud computing services. +It assists financial institutions to upgrade to a new financial restructuring, promotion of capacity platforms, data and technology. + +

Website

+ +--- + +### OceanBase Cloud Platform + + + + + +OceanBase Cloud is a distributed relational database in a real sense, but OceanBase Cloud Platform is the OceanBase cloud-based database service that can help users quickly create and use OceanBase service. + +

Website

+ +--- + +### Service Experience Platform + + + + + + + +Experience Platform is used for collecting all the points of contact and information of the user (including microblogging and other channels). +Through data mining, it exposes the users's experience and it helps the company's internal business team / product managers, facilitating the experience problem solving, in order to achieve healthy functioning streams. + +

Website

+ +--- + +### AntV + + + + + +AntV is a graphical library that is based on the work of a data group team +whose results of exploring data visualization were summarized +and shared them together with the required data visualization theory. + +

Website

+ + diff --git a/docs/practice/cases.md b/docs/practice/cases.zh-CN.md similarity index 100% rename from docs/practice/cases.md rename to docs/practice/cases.zh-CN.md From e5a0e13d70047285cfe8423e41ff325ddea9ada9 Mon Sep 17 00:00:00 2001 From: Benjy Cui Date: Mon, 12 Sep 2016 17:55:26 +0800 Subject: [PATCH 18/24] fix: message && notification should be lowercase --- index.js | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index 2ffa0ae04e..4898a3ab53 100644 --- a/index.js +++ b/index.js @@ -1,25 +1,34 @@ /* eslint no-console:0 */ +// this file is not used if use https://github.com/ant-design/babel-plugin-antd function camelCase(name) { return name.charAt(0).toUpperCase() + - name.slice(1).replace(/-(\w)/g, (m, n) => n.toUpperCase()); + name.slice(1).replace(/-(\w)/g, (m, n) => { + return n.toUpperCase(); + }); } -var req = require.context('./components', true, /^\.\/[^_][\w-]+\/(style\/)?index\.tsx?$/); +const req = require.context('./components', true, /^\.\/[^_][\w-]+\/(style\/)?index\.tsx?$/); req.keys().forEach((mod) => { - var v = req(mod); + let v = req(mod); if (v && v.default) { v = v.default; } - var match = mod.match(/^\.\/([^_][\w-]+)\/index\.tsx?$/); + const match = mod.match(/^\.\/([^_][\w-]+)\/index\.tsx?$/); if (match && match[1]) { - exports[camelCase(match[1])] = v; + if (match[1] === 'message' || match[1] === 'notification') { + // message & notification should not be capitalized + exports[match[1]] = v; + } else { + exports[camelCase(match[1])] = v; + } } }); - -if (typeof console !== 'undefined' && console.warn) { - console.warn('you are using prebuild antd,\ -please use https://github.com/ant-design/babel-plugin-antd to reduce app bundle size.'); +if (process.env.NODE_ENV !== 'production') { + if (typeof console !== 'undefined' && console.warn) { + console.warn(`You are using prebuilt antd, +please use https://github.com/ant-design/babel-plugin-antd to reduce app bundle size.`); + } } From 7156083c7a3261f403c0f8ed542501c4af78989e Mon Sep 17 00:00:00 2001 From: Benjy Cui Date: Mon, 12 Sep 2016 17:58:57 +0800 Subject: [PATCH 19/24] bump 2.0.0-beta.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 032aad338f..0a13edaaf6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "antd", - "version": "2.0.0-beta.1", + "version": "2.0.0-beta.2", "title": "Ant Design", "description": "An enterprise-class UI design language and React-based implementation", "homepage": "http://ant.design/", From 969cbed2ca11036333e40cef2e0b51a426044e08 Mon Sep 17 00:00:00 2001 From: Benjy Cui Date: Tue, 13 Sep 2016 10:27:16 +0800 Subject: [PATCH 20/24] docs: update demo of Badge --- components/badge/demo/status.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/badge/demo/status.md b/components/badge/demo/status.md index de0ca28b84..256850559c 100644 --- a/components/badge/demo/status.md +++ b/components/badge/demo/status.md @@ -18,7 +18,7 @@ import { Badge } from 'antd'; ReactDOM.render(
-
Status:  
+ Status:   From 58745edecf4f0f3841db979ffea8aad6c8eda274 Mon Sep 17 00:00:00 2001 From: Benjy Cui Date: Tue, 13 Sep 2016 11:51:34 +0800 Subject: [PATCH 21/24] docs: update --- components/cascader/demo/search.md | 11 +++++++++-- components/date-picker/index.en-US.md | 2 -- components/spin/demo/tip.md | 10 +++++----- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/components/cascader/demo/search.md b/components/cascader/demo/search.md index 0f4d042e81..994a88575f 100644 --- a/components/cascader/demo/search.md +++ b/components/cascader/demo/search.md @@ -45,6 +45,13 @@ function onChange(value) { } ReactDOM.render( - -, mountNode); + , + mountNode +); ```` diff --git a/components/date-picker/index.en-US.md b/components/date-picker/index.en-US.md index b41ecac935..13eb4b562e 100644 --- a/components/date-picker/index.en-US.md +++ b/components/date-picker/index.en-US.md @@ -25,8 +25,6 @@ moment.tz.setDefault('Aisa/Shanghai'); ``` -> Note: `Datepicker` is renamed to `DatePicker` after `0.11`. - | Property | Description | Type | Default | |--------------|----------------|----------|--------------| | value | to set date | [moment](http://momentjs.com/) | - | diff --git a/components/spin/demo/tip.md b/components/spin/demo/tip.md index 1b819b48eb..78e686dd63 100644 --- a/components/spin/demo/tip.md +++ b/components/spin/demo/tip.md @@ -1,23 +1,23 @@ --- order: 4 -title: +title: zh-CN: 自定义描述文案 - en-US: Customize description + en-US: Customized description --- ## zh-CN -自定义描述文案,指定的 tip 文案会直接代替 `...`。 +自定义描述文案。 ## en-US -Customize description content, specified tip content will replace the dots in `Spin`. +Customized description content. ````jsx import { Spin, Alert } from 'antd'; ReactDOM.render( - + Date: Tue, 13 Sep 2016 14:47:05 +0800 Subject: [PATCH 22/24] site: fix site in IE9, WTF --- package.json | 1 + site/bisheng.config.js | 2 ++ 2 files changed, 3 insertions(+) diff --git a/package.json b/package.json index 0a13edaaf6..af5222c05d 100644 --- a/package.json +++ b/package.json @@ -86,6 +86,7 @@ "bisheng-plugin-description": "^0.1.1", "bisheng-plugin-react": "^0.2.0", "bisheng-plugin-toc": "^0.3.0", + "css-split-webpack-plugin": "^0.2.1", "dora-plugin-upload": "^0.3.1", "enquire.js": "^2.1.1", "es6-shim": "^0.35.0", diff --git a/site/bisheng.config.js b/site/bisheng.config.js index bf89254fec..f56c4a4da0 100644 --- a/site/bisheng.config.js +++ b/site/bisheng.config.js @@ -1,4 +1,5 @@ const path = require('path'); +const CSSSplitWebpackPlugin = require('css-split-webpack-plugin').default; function pickerGenerator(module) { const tester = new RegExp(`^docs/${module}`); @@ -68,6 +69,7 @@ module.exports = { site: path.join(process.cwd(), 'site'), 'react-router': 'react-router/umd/ReactRouter', }; + config.plugins.push(new CSSSplitWebpackPlugin({ imports: true })); config.babel.plugins.push([ require.resolve('babel-plugin-transform-runtime'), From 8db2b795052b09c40acfa687d460b9236005caed Mon Sep 17 00:00:00 2001 From: Benjy Cui Date: Tue, 13 Sep 2016 15:31:29 +0800 Subject: [PATCH 23/24] chore: fix compile errors --- components/alert/index.tsx | 2 +- components/back-top/index.tsx | 2 +- components/badge/index.tsx | 2 +- components/breadcrumb/BreadcrumbItem.tsx | 2 +- components/button/button-group.tsx | 4 ++-- components/button/button.tsx | 8 ++++---- components/calendar/index.tsx | 2 +- components/card/index.tsx | 2 +- components/date-picker/index.tsx | 4 ++-- components/form/Form.tsx | 2 +- components/input/Input.tsx | 2 +- components/layout/col.tsx | 2 +- components/menu/index.tsx | 4 ++-- components/message/index.tsx | 2 +- components/select/index.tsx | 2 +- components/slider/index.tsx | 4 ++-- components/table/Table.tsx | 6 +++--- components/tabs/index.tsx | 4 ++-- components/tooltip/index.tsx | 2 +- components/tree-select/interface.tsx | 2 +- components/upload/interface.tsx | 4 ++-- custom-typings.d.ts => typings/custom-typings.d.ts | 0 22 files changed, 32 insertions(+), 32 deletions(-) rename custom-typings.d.ts => typings/custom-typings.d.ts (100%) diff --git a/components/alert/index.tsx b/components/alert/index.tsx index 680a504294..e814faea56 100644 --- a/components/alert/index.tsx +++ b/components/alert/index.tsx @@ -4,7 +4,7 @@ import Animate from 'rc-animate'; import Icon from '../icon'; import classNames from 'classnames'; -interface AlertProps { +export interface AlertProps { /** * Type of Alert styles, options:`success`, `info`, `warning`, `error` */ diff --git a/components/back-top/index.tsx b/components/back-top/index.tsx index 8a4885ebe1..2b6d6deecb 100644 --- a/components/back-top/index.tsx +++ b/components/back-top/index.tsx @@ -23,7 +23,7 @@ function getScroll(target, top) { return ret; } -interface BackTopProps { +export interface BackTopProps { visibilityHeight?: number; onClick?: (event) => void; target?: () => HTMLElement | Window; diff --git a/components/badge/index.tsx b/components/badge/index.tsx index 3864a63294..0280c07f18 100644 --- a/components/badge/index.tsx +++ b/components/badge/index.tsx @@ -3,7 +3,7 @@ import Animate from 'rc-animate'; import ScrollNumber from './ScrollNumber'; import classNames from 'classnames'; -interface BadgeProps { +export interface BadgeProps { /** Number to show in badge */ count: number | string; /** Max count to show */ diff --git a/components/breadcrumb/BreadcrumbItem.tsx b/components/breadcrumb/BreadcrumbItem.tsx index 580d9d9d0e..81d56f4d5e 100644 --- a/components/breadcrumb/BreadcrumbItem.tsx +++ b/components/breadcrumb/BreadcrumbItem.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import splitObject from '../_util/splitObject'; -interface BreadcrumbItemProps { +export interface BreadcrumbItemProps { separator?: React.ReactNode; href?: string; } diff --git a/components/button/button-group.tsx b/components/button/button-group.tsx index 8bb5b9d71f..36405a0406 100644 --- a/components/button/button-group.tsx +++ b/components/button/button-group.tsx @@ -4,9 +4,9 @@ import splitObject from '../_util/splitObject'; const prefix = 'ant-btn-group-'; -type ButtonSize = 'small' | 'large' +export type ButtonSize = 'small' | 'large' -interface ButtonGroupProps { +export interface ButtonGroupProps { size?: ButtonSize; style?: React.CSSProperties; className?: string; diff --git a/components/button/button.tsx b/components/button/button.tsx index b95679b4ec..4228a26904 100644 --- a/components/button/button.tsx +++ b/components/button/button.tsx @@ -24,11 +24,11 @@ function insertSpace(child) { return child; } -type ButtonType = 'primary' | 'ghost' | 'dashed' -type ButtonShape = 'circle' | 'circle-outline' -type ButtonSize = 'small' | 'large' +export type ButtonType = 'primary' | 'ghost' | 'dashed' +export type ButtonShape = 'circle' | 'circle-outline' +export type ButtonSize = 'small' | 'large' -interface ButtonProps { +export interface ButtonProps { type?: ButtonType; htmlType?: string; icon?: string; diff --git a/components/calendar/index.tsx b/components/calendar/index.tsx index e7864ca9f6..7d50e289d4 100644 --- a/components/calendar/index.tsx +++ b/components/calendar/index.tsx @@ -16,7 +16,7 @@ function zerofixed(v) { return `${v}`; } -interface CalendarContext { +export interface CalendarContext { antLocale?: { Calendar?: any }; diff --git a/components/card/index.tsx b/components/card/index.tsx index 094495151c..75612d3c15 100644 --- a/components/card/index.tsx +++ b/components/card/index.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import classNames from 'classnames'; import splitObject from '../_util/splitObject'; -interface CardProps { +export interface CardProps { title?: React.ReactNode; extra?: React.ReactNode; bordered?: boolean; diff --git a/components/date-picker/index.tsx b/components/date-picker/index.tsx index 145dd2af34..fab7f54567 100644 --- a/components/date-picker/index.tsx +++ b/components/date-picker/index.tsx @@ -9,7 +9,7 @@ import RangePicker from './RangePicker'; import Calendar from './Calendar'; import { TimePickerProps } from '../time-picker'; -interface PickerProps { +export interface PickerProps { format?: string; disabled?: boolean; style?: React.CSSProperties; @@ -19,7 +19,7 @@ interface PickerProps { getCalendarContainer?: (trigger) => React.ReactNode; } -interface SinglePickerProps { +export interface SinglePickerProps { value?: moment.Moment; defaultValue?: moment.Moment; defaultPickerValue?: moment.Moment; diff --git a/components/form/Form.tsx b/components/form/Form.tsx index a196360f0b..461f6dbed5 100644 --- a/components/form/Form.tsx +++ b/components/form/Form.tsx @@ -70,7 +70,7 @@ export interface FormComponentProps { form: WrappedFormUtils; } -class FormComponent extends React.Component { +export class FormComponent extends React.Component { } export interface ComponentDecorator { diff --git a/components/input/Input.tsx b/components/input/Input.tsx index 317def73ec..459fe0e4df 100644 --- a/components/input/Input.tsx +++ b/components/input/Input.tsx @@ -27,7 +27,7 @@ function clearNextFrameAction(nextFrameId) { } } -interface AutoSizeType { +export interface AutoSizeType { minRows?: number; maxRows?: number; }; diff --git a/components/layout/col.tsx b/components/layout/col.tsx index bad0db3a6f..b939cb5e69 100644 --- a/components/layout/col.tsx +++ b/components/layout/col.tsx @@ -7,7 +7,7 @@ import splitObject from '../_util/splitObject'; const stringOrNumber = PropTypes.oneOfType([PropTypes.string, PropTypes.number]); const objectOrNumber = PropTypes.oneOfType([PropTypes.object, PropTypes.number]); -interface ColSize { +export interface ColSize { span?: number; order?: number; offset?: number; diff --git a/components/menu/index.tsx b/components/menu/index.tsx index 645786319a..e329f5f3a3 100644 --- a/components/menu/index.tsx +++ b/components/menu/index.tsx @@ -5,7 +5,7 @@ import animation from '../_util/openAnimation'; function noop() { } -interface SelectParam { +export interface SelectParam { key: string; keyPath: Array; item: any; @@ -13,7 +13,7 @@ interface SelectParam { selectedKeys: Array; } -interface ClickParam { +export interface ClickParam { key: string; keyPath: Array; item: any; diff --git a/components/message/index.tsx b/components/message/index.tsx index 727977a434..3d831ebc75 100644 --- a/components/message/index.tsx +++ b/components/message/index.tsx @@ -57,7 +57,7 @@ type ConfigContent = React.ReactNode; type ConfigDuration = number; type ConfigOnClose = () => void; -interface ConfigOptions { +export interface ConfigOptions { top?: number; duration?: number; prefixCls?: string; diff --git a/components/select/index.tsx b/components/select/index.tsx index 8eb00c61a1..738fb4bdeb 100644 --- a/components/select/index.tsx +++ b/components/select/index.tsx @@ -3,7 +3,7 @@ import { PropTypes } from 'react'; import RcSelect, { Option, OptGroup } from 'rc-select'; import classNames from 'classnames'; -type SelectValue = string | string[] | Array<{ key: string, label: React.ReactNode }>; +export type SelectValue = string | string[] | Array<{ key: string, label: React.ReactNode }>; export interface SelectProps { prefixCls?: string; diff --git a/components/slider/index.tsx b/components/slider/index.tsx index b1b0e01d13..b44227b22b 100644 --- a/components/slider/index.tsx +++ b/components/slider/index.tsx @@ -2,14 +2,14 @@ import * as React from 'react'; import { PropTypes } from 'react'; import RcSlider from 'rc-slider'; -interface SliderMarks { +export interface SliderMarks { [key: number]: React.ReactNode | { style: React.CSSProperties, label: React.ReactNode, }; } -type SliderValue = number | [number, number]; +export type SliderValue = number | [number, number]; export interface SliderProps { range?: boolean; diff --git a/components/table/Table.tsx b/components/table/Table.tsx index aeca192fae..9f36dbfcf1 100644 --- a/components/table/Table.tsx +++ b/components/table/Table.tsx @@ -33,7 +33,7 @@ const defaultPagination = { onShowSizeChange: noop, }; -interface TableRowSelection { +export interface TableRowSelection { type?: 'checkbox' | 'radio'; selectedRowKeys?: string[]; onChange?: (selectedRowKeys: string[], selectedRows: Object[]) => any; @@ -42,7 +42,7 @@ interface TableRowSelection { onSelectAll?: (selected: boolean, selectedRows: Object[], changeRows: Object[]) => any; } -interface TableColumnConfig { +export interface TableColumnConfig { title?: React.ReactNode; key?: string; dataIndex?: string; @@ -87,7 +87,7 @@ export interface TableProps { childrenColumnName?: 'string'; } -interface TableContext { +export interface TableContext { antLocale?: { Table?: any, }; diff --git a/components/tabs/index.tsx b/components/tabs/index.tsx index 1a612c2170..59bc2880e6 100644 --- a/components/tabs/index.tsx +++ b/components/tabs/index.tsx @@ -4,8 +4,8 @@ import { cloneElement } from 'react'; import classNames from 'classnames'; import Icon from '../icon'; -type TabsType = 'line' | 'card' | 'editable-card' -type TabsPosition = 'top' | 'right' | 'bottom' | 'left'; +export type TabsType = 'line' | 'card' | 'editable-card' +export type TabsPosition = 'top' | 'right' | 'bottom' | 'left'; export interface TabsProps { activeKey?: string; diff --git a/components/tooltip/index.tsx b/components/tooltip/index.tsx index 3e282d7c83..9601cf1de7 100644 --- a/components/tooltip/index.tsx +++ b/components/tooltip/index.tsx @@ -4,7 +4,7 @@ import RcTooltip from 'rc-tooltip'; import getPlacements from '../popover/placements'; import classNames from 'classnames'; -type PopoverPlacement = +export type PopoverPlacement = 'top' | 'left' | 'right' | 'bottom' | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom' diff --git a/components/tree-select/interface.tsx b/components/tree-select/interface.tsx index 2004183a92..ca17c1b302 100644 --- a/components/tree-select/interface.tsx +++ b/components/tree-select/interface.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; -interface TreeData { +export interface TreeData { key: string; value: string; label: React.ReactNode; diff --git a/components/upload/interface.tsx b/components/upload/interface.tsx index 902a077e1a..dcd5be8eb0 100644 --- a/components/upload/interface.tsx +++ b/components/upload/interface.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; -type UploadFileStatus = 'error' | 'success' | 'done' | 'uploading' | 'removed' +export type UploadFileStatus = 'error' | 'success' | 'done' | 'uploading' | 'removed' export interface HttpRequestHeader { [key: string]: string; @@ -18,7 +18,7 @@ export interface File { originFileObj?: File; } -interface UploadChangeParam { +export interface UploadChangeParam { file: File; fileList: Array; event?: { percent: number }; diff --git a/custom-typings.d.ts b/typings/custom-typings.d.ts similarity index 100% rename from custom-typings.d.ts rename to typings/custom-typings.d.ts From 656ab0e3f3d14f2bce36de2b20aea15f64be8aa8 Mon Sep 17 00:00:00 2001 From: jiang <155259966@qq.com> Date: Tue, 13 Sep 2016 17:10:08 +0800 Subject: [PATCH 24/24] feat: add back to top animation (#3021) * add back to top animation * update currentScrollTop * use date now --- components/back-top/index.tsx | 39 +++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/components/back-top/index.tsx b/components/back-top/index.tsx index 2b6d6deecb..c9feded350 100644 --- a/components/back-top/index.tsx +++ b/components/back-top/index.tsx @@ -5,6 +5,30 @@ import addEventListener from 'rc-util/lib/Dom/addEventListener'; import classNames from 'classnames'; import omit from 'omit.js'; +const reqAnimFrame = (() => { + if (window.requestAnimationFrame) { + return window.requestAnimationFrame; + } + const a = ['moz', 'ms', 'webkit']; + const raf = a.filter(key => `${key}RequestAnimationFrame` in window); + return raf[0] ? window[`${raf[0]}RequestAnimationFrame`] : + ((callback) => window.setTimeout(callback, 1000 / 60)); +})(); + +const currentScrollTop = () => { + return window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop; +}; + +const easeInOutCubic = (t, b, c, d) => { + const cc = c - b; + t /= d / 2; + if (t < 1) { + return cc / 2 * t * t * t + b; + } else { + return cc / 2 * ((t -= 2) * t * t + 2) + b; + } +}; + function getScroll(target, top) { if (typeof window === 'undefined') { return 0; @@ -52,10 +76,17 @@ export default class BackTop extends React.Component { } scrollToTop = (e) => { - if (e) { - e.preventDefault(); - } - this.setScrollTop(0); + const scrollTop = currentScrollTop(); + const startTime = Date.now(); + const frameFunc = () => { + const timestamp = Date.now(); + const time = timestamp - startTime; + this.setScrollTop(easeInOutCubic(time, scrollTop, 0, 450)); + if (time < 450) { + reqAnimFrame(frameFunc); + } + }; + reqAnimFrame(frameFunc); this.props.onClick(e); }