From a52567bee63e819be2f3273a079a6b65f04d6378 Mon Sep 17 00:00:00 2001 From: jljsj Date: Thu, 19 Nov 2015 16:58:56 +0800 Subject: [PATCH 01/56] add badge the number scroll anim --- components/badge/AntNumber.jsx | 97 +++++++++++++++++++++++++++++++++ components/badge/demo/change.md | 12 ++++ components/badge/index.jsx | 5 +- components/badge/utils.js | 9 +++ style/components/badge.less | 10 ++++ 5 files changed, 130 insertions(+), 3 deletions(-) create mode 100644 components/badge/AntNumber.jsx create mode 100644 components/badge/utils.js diff --git a/components/badge/AntNumber.jsx b/components/badge/AntNumber.jsx new file mode 100644 index 0000000000..c94d4dfa8a --- /dev/null +++ b/components/badge/AntNumber.jsx @@ -0,0 +1,97 @@ +import React, {createElement, cloneElement} from 'react'; +import {findDOMNode} from 'react-dom'; +import {toArrayChildren} from './utils'; +import assign from 'object-assign'; + +class AntNumber extends React.Component { + constructor(props) { + super(props); + const children = toArrayChildren(this.props.children); + this.state = { + children, + }; + } + + getNumberOnly(c) { + const childrenToReturn = []; + for (let i = -1; i < 11; i++) { + let count = i >= 10 ? i - 10 : i; + count = i === -1 ? 9 : count; + const children =

{count}

; + childrenToReturn.push(children); + } + const key = 'only_' + c; + return createElement('span', {className: `${this.props.prefixCls}-only`, key: key}, childrenToReturn); + } + + getNumberElement(props) { + const count = props.count; + if (!count || count === '') { + return null; + } + let length = count.toString().length; + let childrenWap = []; + const a = childrenWap.length || 0; + if (length < a) { + childrenWap.splice(0, 1); + } + let i = a;//length - 1; + while (i < length) { + const children = this.getNumberOnly(i); + childrenWap.unshift(children); + i++; + } + const height = findDOMNode(this).offsetHeight; + childrenWap = childrenWap.map((child, j)=> { + let oneData = Number(count.toString()[j]); + let offsetTop = -(oneData + 1) * height; + return cloneElement(child, {style: {transform: 'translateY(' + offsetTop + 'px)'}}); + }); + return childrenWap; + } + + + updateChildren(props) { + if (typeof props.count === 'string') { + return this.setState({ + children: [props.count] + }); + } + let newChildren = this.getNumberElement(props); + //newChildren = this.addStyle(props, newChildren); + if (newChildren && newChildren.length) { + this.setState({ + children: newChildren + }); + } + } + + componentDidMount() { + this.updateChildren(this.props); + } + + componentWillReceiveProps(nextProps) { + this.updateChildren(nextProps); + } + + render() { + const childrenToRender = this.state.children; + const props = assign({}, this.props, {className: this.props.prefixCls + ' ' + this.props.className}); + return createElement(this.props.component, props, childrenToRender); + } +} +AntNumber.defaultProps = { + prefixCls: 'ant-number', + count: null, + component: 'sup' +}; + +AntNumber.propTypes = { + count: React.PropTypes.oneOfType([ + React.PropTypes.string, + React.PropTypes.number + ]), + component: React.PropTypes.string +}; + +export default AntNumber; diff --git a/components/badge/demo/change.md b/components/badge/demo/change.md index 4ce034bdab..411f19b2ee 100644 --- a/components/badge/demo/change.md +++ b/components/badge/demo/change.md @@ -67,3 +67,15 @@ ReactDOM.render( , document.getElementById('components-badge-demo-change')); ```` +````css +.ant-badge { + margin-right: 16px; +} +.head-example { + width: 42px; + height: 42px; + border-radius: 6px; + background: #eee; + display: inline-block; +} +```` diff --git a/components/badge/index.jsx b/components/badge/index.jsx index 5c1f659d54..7444eb06d2 100644 --- a/components/badge/index.jsx +++ b/components/badge/index.jsx @@ -1,5 +1,6 @@ import React from 'react'; import Animate from 'rc-animate'; +import AntNumber from './AntNumber'; class AntBadge extends React.Component { constructor(props) { @@ -30,9 +31,7 @@ class AntBadge extends React.Component { transitionAppear={true}> { hidden ? null : - - {count} - + } diff --git a/components/badge/utils.js b/components/badge/utils.js new file mode 100644 index 0000000000..04d1574f43 --- /dev/null +++ b/components/badge/utils.js @@ -0,0 +1,9 @@ +import React from 'react'; + +export function toArrayChildren(children) { + const ret = []; + React.Children.forEach(children, (c) => { + ret.push(c); + }); + return ret; +} diff --git a/style/components/badge.less b/style/components/badge.less index 0a99910403..91066ccf5b 100644 --- a/style/components/badge.less +++ b/style/components/badge.less @@ -1,4 +1,5 @@ @badge-prefix-cls: ~"@{css-prefix}badge"; +@number-prefix-cls: ~"@{css-prefix}number"; .@{badge-prefix-cls} { position: relative; @@ -62,6 +63,15 @@ a .@{badge-prefix-cls} { } } +.@{number-prefix-cls}{ + overflow: hidden; + &-only{ + display: inline-block; + + transition: transform .3s @ease-in-out; + } +} + @keyframes antZoomBadgeIn { 0% { opacity: 0; From 57cde4ab1836494fb8149219b20ef25aa4ba9f7a Mon Sep 17 00:00:00 2001 From: jljsj Date: Thu, 19 Nov 2015 17:02:28 +0800 Subject: [PATCH 02/56] update badge number --- components/badge/AntNumber.jsx | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/components/badge/AntNumber.jsx b/components/badge/AntNumber.jsx index c94d4dfa8a..50e82b8899 100644 --- a/components/badge/AntNumber.jsx +++ b/components/badge/AntNumber.jsx @@ -31,11 +31,7 @@ class AntNumber extends React.Component { } let length = count.toString().length; let childrenWap = []; - const a = childrenWap.length || 0; - if (length < a) { - childrenWap.splice(0, 1); - } - let i = a;//length - 1; + let i = 0; while (i < length) { const children = this.getNumberOnly(i); childrenWap.unshift(children); @@ -50,7 +46,6 @@ class AntNumber extends React.Component { return childrenWap; } - updateChildren(props) { if (typeof props.count === 'string') { return this.setState({ From ae287a2b68148f53270c83ac823228e487b15d6c Mon Sep 17 00:00:00 2001 From: jljsj Date: Thu, 19 Nov 2015 17:07:16 +0800 Subject: [PATCH 03/56] update badge change.md --- components/badge/demo/change.md | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/components/badge/demo/change.md b/components/badge/demo/change.md index 411f19b2ee..4ce034bdab 100644 --- a/components/badge/demo/change.md +++ b/components/badge/demo/change.md @@ -67,15 +67,3 @@ ReactDOM.render( , document.getElementById('components-badge-demo-change')); ```` -````css -.ant-badge { - margin-right: 16px; -} -.head-example { - width: 42px; - height: 42px; - border-radius: 6px; - background: #eee; - display: inline-block; -} -```` From 0a1c8ba811edc09d71ae8eeada8520c0c09ce95a Mon Sep 17 00:00:00 2001 From: jljsj Date: Fri, 20 Nov 2015 14:41:11 +0800 Subject: [PATCH 04/56] update badge anim 0-9, 9-0 --- components/badge/AntNumber.jsx | 67 ++++++++++++++++++++++++++------- components/badge/demo/change.md | 7 ++-- components/badge/index.jsx | 10 +++-- components/badge/utils.js | 61 ++++++++++++++++++++++++++++++ style/components/badge.less | 2 +- 5 files changed, 125 insertions(+), 22 deletions(-) diff --git a/components/badge/AntNumber.jsx b/components/badge/AntNumber.jsx index 50e82b8899..2f49cc9d4c 100644 --- a/components/badge/AntNumber.jsx +++ b/components/badge/AntNumber.jsx @@ -1,12 +1,16 @@ import React, {createElement, cloneElement} from 'react'; import {findDOMNode} from 'react-dom'; -import {toArrayChildren} from './utils'; +import {toArrayChildren, getPartNumber, getTranslateY} from './utils'; import assign from 'object-assign'; class AntNumber extends React.Component { constructor(props) { super(props); const children = toArrayChildren(this.props.children); + this.endSetState = false; + this.count = this.props.count; + this.data = getPartNumber(this.count); + this.timeout = null; this.state = { children, }; @@ -14,9 +18,8 @@ class AntNumber extends React.Component { getNumberOnly(c) { const childrenToReturn = []; - for (let i = -1; i < 11; i++) { - let count = i >= 10 ? i - 10 : i; - count = i === -1 ? 9 : count; + for (let i = 0; i < 30; i++) { + let count = i >= 10 ? i % 10 : i; const children =

{count}

; childrenToReturn.push(children); } @@ -24,12 +27,18 @@ class AntNumber extends React.Component { return createElement('span', {className: `${this.props.prefixCls}-only`, key: key}, childrenToReturn); } + setEndState(style) { + this.endSetState = true; + style.transition = 'none'; + } + getNumberElement(props) { const count = props.count; if (!count || count === '') { return null; } - let length = count.toString().length; + const length = count.toString().length; + const data = getPartNumber(count); let childrenWap = []; let i = 0; while (i < length) { @@ -38,35 +47,61 @@ class AntNumber extends React.Component { i++; } const height = findDOMNode(this).offsetHeight; + const _length = childrenWap.length - 1; childrenWap = childrenWap.map((child, j)=> { - let oneData = Number(count.toString()[j]); - let offsetTop = -(oneData + 1) * height; - return cloneElement(child, {style: {transform: 'translateY(' + offsetTop + 'px)'}}); + const oneData = Number(count.toString()[j]); + const style = {}; + let translateY = -(oneData + 10) * height; + //判断状态 + translateY = getTranslateY(count, this.count, data, this.data, j, height, _length) || translateY; + if (count !== this.count) { + this.setEndState(style); + } + style.transform = 'translateY(' + translateY + 'px)'; + return cloneElement(child, {style: style}); }); + this.data = data; + this.count = count; return childrenWap; } updateChildren(props) { if (typeof props.count === 'string') { + this.data = getPartNumber(this.props.max); + this.count = this.props.max; return this.setState({ - children: [props.count] + children: [props.count], }); } - let newChildren = this.getNumberElement(props); - //newChildren = this.addStyle(props, newChildren); + const newChildren = this.getNumberElement(props); if (newChildren && newChildren.length) { this.setState({ - children: newChildren + children: newChildren, + }, ()=> { + if (this.endSetState) { + this.updateChildren(props); + this.endSetState = false; + } }); } } + animEnd() { + clearTimeout(this.timeout); + this.timeout = setTimeout(()=> { + if (typeof this.props.callback === 'function') { + this.props.callback(); + } + }, 300); + } + componentDidMount() { this.updateChildren(this.props); } componentWillReceiveProps(nextProps) { this.updateChildren(nextProps); + this.animEnd(); } render() { @@ -78,7 +113,9 @@ class AntNumber extends React.Component { AntNumber.defaultProps = { prefixCls: 'ant-number', count: null, - component: 'sup' + max: 99, + component: 'sup', + callback: null, }; AntNumber.propTypes = { @@ -86,7 +123,9 @@ AntNumber.propTypes = { React.PropTypes.string, React.PropTypes.number ]), - component: React.PropTypes.string + component: React.PropTypes.string, + callback: React.PropTypes.func, + max: React.PropTypes.number, }; export default AntNumber; diff --git a/components/badge/demo/change.md b/components/badge/demo/change.md index 4ce034bdab..a023bf5756 100644 --- a/components/badge/demo/change.md +++ b/components/badge/demo/change.md @@ -13,16 +13,16 @@ const ButtonGroup = Button.Group; const Test = React.createClass({ getInitialState() { return { - count: 5, + count: 691, show: true, }; }, increase() { - const count = this.state.count + 1; + const count = this.state.count + 117; this.setState({ count }); }, decline() { - let count = this.state.count - 1; + let count = this.state.count - 111; if (count < 0) { count = 0; } @@ -40,6 +40,7 @@ const Test = React.createClass({ }); }, render() { + console.log(this.state.count) return
diff --git a/components/badge/index.jsx b/components/badge/index.jsx index 7444eb06d2..7d31a37a0c 100644 --- a/components/badge/index.jsx +++ b/components/badge/index.jsx @@ -11,7 +11,7 @@ class AntBadge extends React.Component { let { count, prefixCls } = this.props; const dot = this.props.dot; - count = count >= 100 ? '99+' : count; + //count = count >= 100 ? '99+' : count; // dot mode don't need count if (dot) { @@ -31,7 +31,7 @@ class AntBadge extends React.Component { transitionAppear={true}> { hidden ? null : - + } @@ -42,7 +42,8 @@ class AntBadge extends React.Component { AntBadge.defaultProps = { prefixCls: 'ant-badge', count: null, - dot: false + dot: false, + animEnd: null }; AntBadge.propTypes = { @@ -50,7 +51,8 @@ AntBadge.propTypes = { React.PropTypes.string, React.PropTypes.number ]), - dot: React.PropTypes.bool + dot: React.PropTypes.bool, + animEnd: React.PropTypes.func }; export default AntBadge; diff --git a/components/badge/utils.js b/components/badge/utils.js index 04d1574f43..c84b44a54a 100644 --- a/components/badge/utils.js +++ b/components/badge/utils.js @@ -7,3 +7,64 @@ export function toArrayChildren(children) { }); return ret; } + +export function getPartNumber(num) { + const countStr = num.toString(); + const obj = {}; + for (let i = 0; i < countStr.length; i++) { + obj[countStr.length - 1 - i] = Number(countStr[i]); + } + return obj; +} + +export function getTranslateY(count, preCount, data, preData, j, height, _length) { + let translateY = 0; + const oneData = Number(count.toString()[j]); + const on = preData[_length - j]; + const to = data[_length - j]; + const preOn = preData[_length - j + 1]; + const preTo = data[_length - j + 1]; + if (count === preCount) { + const add = preData[(_length - j) + '_add']; + const rem = preData[(_length - j) + '_rem']; + if (add) { + translateY = -(oneData + 20) * height; + } + if (rem) { + translateY = -oneData * height; + } + } + if (count > preCount) { + if (on > to) { + translateY = -(oneData - (to - on)) * height; + data[(_length - j) + '_add'] = true; + } else if (on < to) { + translateY = -(oneData + 10 - (to - on)) * height; + if (preTo - preOn) { + translateY = -(oneData - (to - on)) * height; + } + } else { + if (typeof preOn === 'number' && typeof preTo === 'number') { + translateY = -oneData * height; + } + } + } else if (count < preCount) { + if (on < to) { + translateY = -(oneData + 20 - ( to - on)) * height; + data[(_length - j) + '_rem'] = true; + } else if (on > to) { + translateY = -(oneData + 10 - (to - on)) * height; + if (preOn - preTo) { + translateY = -(oneData + 20 - (to - on)) * height; + } + } else { + if (typeof preOn === 'number' && typeof preTo === 'number') { + translateY = -(oneData + 20) * height; + } + } + } + if (on !== 0 && !on) { + translateY = -10 * height; + } + return translateY; +} diff --git a/style/components/badge.less b/style/components/badge.less index 91066ccf5b..0b1d3d878b 100644 --- a/style/components/badge.less +++ b/style/components/badge.less @@ -68,7 +68,7 @@ a .@{badge-prefix-cls} { &-only{ display: inline-block; - transition: transform .3s @ease-in-out; + transition: transform 2.3s @ease-in-out; } } From 55b9ec3feb789bbf58932e87af1b6a7587f8997e Mon Sep 17 00:00:00 2001 From: jljsj Date: Fri, 20 Nov 2015 14:42:17 +0800 Subject: [PATCH 05/56] update badge open max 99 --- components/badge/index.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/badge/index.jsx b/components/badge/index.jsx index 7d31a37a0c..0057221ed8 100644 --- a/components/badge/index.jsx +++ b/components/badge/index.jsx @@ -11,7 +11,7 @@ class AntBadge extends React.Component { let { count, prefixCls } = this.props; const dot = this.props.dot; - //count = count >= 100 ? '99+' : count; + count = count >= 100 ? '99+' : count; // dot mode don't need count if (dot) { From de1316433079b2ee8ddc731ae03de14bf76d9899 Mon Sep 17 00:00:00 2001 From: jljsj Date: Fri, 20 Nov 2015 14:43:35 +0800 Subject: [PATCH 06/56] update badge transition --- style/components/badge.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/style/components/badge.less b/style/components/badge.less index 0b1d3d878b..91066ccf5b 100644 --- a/style/components/badge.less +++ b/style/components/badge.less @@ -68,7 +68,7 @@ a .@{badge-prefix-cls} { &-only{ display: inline-block; - transition: transform 2.3s @ease-in-out; + transition: transform .3s @ease-in-out; } } From 75d2d21b0b8ba03a99c130e2d9da1df5409bd1dd Mon Sep 17 00:00:00 2001 From: jljsj Date: Fri, 20 Nov 2015 15:08:17 +0800 Subject: [PATCH 07/56] update badge anim --- components/badge/demo/change.md | 5 ++--- components/badge/index.jsx | 2 +- components/badge/utils.js | 11 ++++++++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/components/badge/demo/change.md b/components/badge/demo/change.md index a023bf5756..1d6f75e706 100644 --- a/components/badge/demo/change.md +++ b/components/badge/demo/change.md @@ -18,11 +18,11 @@ const Test = React.createClass({ }; }, increase() { - const count = this.state.count + 117; + const count = this.state.count + 114; this.setState({ count }); }, decline() { - let count = this.state.count - 111; + let count = this.state.count - 121; if (count < 0) { count = 0; } @@ -40,7 +40,6 @@ const Test = React.createClass({ }); }, render() { - console.log(this.state.count) return
diff --git a/components/badge/index.jsx b/components/badge/index.jsx index 0057221ed8..7d31a37a0c 100644 --- a/components/badge/index.jsx +++ b/components/badge/index.jsx @@ -11,7 +11,7 @@ class AntBadge extends React.Component { let { count, prefixCls } = this.props; const dot = this.props.dot; - count = count >= 100 ? '99+' : count; + //count = count >= 100 ? '99+' : count; // dot mode don't need count if (dot) { diff --git a/components/badge/utils.js b/components/badge/utils.js index c84b44a54a..65546ed488 100644 --- a/components/badge/utils.js +++ b/components/badge/utils.js @@ -37,11 +37,14 @@ export function getTranslateY(count, preCount, data, preData, j, height, _length if (count > preCount) { if (on > to) { translateY = -(oneData - (to - on)) * height; - data[(_length - j) + '_add'] = true; + if (typeof preOn === 'number') { + data[(_length - j) + '_add'] = true; + } } else if (on < to) { translateY = -(oneData + 10 - (to - on)) * height; if (preTo - preOn) { - translateY = -(oneData - (to - on)) * height; + //translateY = -(oneData + 20 - (to - on)) * height; + data[(_length - j) + '_add'] = true; } } else { if (typeof preOn === 'number' && typeof preTo === 'number') { @@ -51,7 +54,9 @@ export function getTranslateY(count, preCount, data, preData, j, height, _length } else if (count < preCount) { if (on < to) { translateY = -(oneData + 20 - ( to - on)) * height; - data[(_length - j) + '_rem'] = true; + if (typeof preTo === 'number') { + data[(_length - j) + '_rem'] = true; + } } else if (on > to) { translateY = -(oneData + 10 - (to - on)) * height; if (preOn - preTo) { From a834a9f83e5c9ff99214e1d2879313af8472ddf7 Mon Sep 17 00:00:00 2001 From: jljsj Date: Fri, 20 Nov 2015 15:09:28 +0800 Subject: [PATCH 08/56] update badge anim demo --- components/badge/demo/change.md | 6 +++--- components/badge/index.jsx | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/badge/demo/change.md b/components/badge/demo/change.md index 1d6f75e706..4ce034bdab 100644 --- a/components/badge/demo/change.md +++ b/components/badge/demo/change.md @@ -13,16 +13,16 @@ const ButtonGroup = Button.Group; const Test = React.createClass({ getInitialState() { return { - count: 691, + count: 5, show: true, }; }, increase() { - const count = this.state.count + 114; + const count = this.state.count + 1; this.setState({ count }); }, decline() { - let count = this.state.count - 121; + let count = this.state.count - 1; if (count < 0) { count = 0; } diff --git a/components/badge/index.jsx b/components/badge/index.jsx index 7d31a37a0c..0057221ed8 100644 --- a/components/badge/index.jsx +++ b/components/badge/index.jsx @@ -11,7 +11,7 @@ class AntBadge extends React.Component { let { count, prefixCls } = this.props; const dot = this.props.dot; - //count = count >= 100 ? '99+' : count; + count = count >= 100 ? '99+' : count; // dot mode don't need count if (dot) { From b08513a082b3b5f111421993c2ebf9cbc10746f5 Mon Sep 17 00:00:00 2001 From: jljsj Date: Fri, 20 Nov 2015 15:18:16 +0800 Subject: [PATCH 09/56] update badge number utils --- components/badge/demo/change.md | 2 +- components/badge/utils.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/badge/demo/change.md b/components/badge/demo/change.md index 4ce034bdab..962472164d 100644 --- a/components/badge/demo/change.md +++ b/components/badge/demo/change.md @@ -13,7 +13,7 @@ const ButtonGroup = Button.Group; const Test = React.createClass({ getInitialState() { return { - count: 5, + count: 19, show: true, }; }, diff --git a/components/badge/utils.js b/components/badge/utils.js index 65546ed488..357d213fd4 100644 --- a/components/badge/utils.js +++ b/components/badge/utils.js @@ -37,7 +37,7 @@ export function getTranslateY(count, preCount, data, preData, j, height, _length if (count > preCount) { if (on > to) { translateY = -(oneData - (to - on)) * height; - if (typeof preOn === 'number') { + if (typeof preOn === 'number' && preTo - preOn > 1) { data[(_length - j) + '_add'] = true; } } else if (on < to) { @@ -54,7 +54,7 @@ export function getTranslateY(count, preCount, data, preData, j, height, _length } else if (count < preCount) { if (on < to) { translateY = -(oneData + 20 - ( to - on)) * height; - if (typeof preTo === 'number') { + if (typeof preTo === 'number' && preOn - preTo > 1) { data[(_length - j) + '_rem'] = true; } } else if (on > to) { From 7ce4a11d628793ba6dfcb9042b8fb82cf4a41cea Mon Sep 17 00:00:00 2001 From: jljsj Date: Fri, 20 Nov 2015 16:00:59 +0800 Subject: [PATCH 10/56] update badge number --- components/badge/AntNumber.jsx | 28 ++++++++++++---------------- components/badge/demo/change.md | 2 +- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/components/badge/AntNumber.jsx b/components/badge/AntNumber.jsx index 2f49cc9d4c..b6dd706991 100644 --- a/components/badge/AntNumber.jsx +++ b/components/badge/AntNumber.jsx @@ -1,4 +1,4 @@ -import React, {createElement, cloneElement} from 'react'; +import React, {createElement} from 'react'; import {findDOMNode} from 'react-dom'; import {toArrayChildren, getPartNumber, getTranslateY} from './utils'; import assign from 'object-assign'; @@ -16,7 +16,7 @@ class AntNumber extends React.Component { }; } - getNumberOnly(c) { + getNumberOnly(c, style) { const childrenToReturn = []; for (let i = 0; i < 30; i++) { let count = i >= 10 ? i % 10 : i; @@ -24,7 +24,7 @@ class AntNumber extends React.Component { childrenToReturn.push(children); } const key = 'only_' + c; - return createElement('span', {className: `${this.props.prefixCls}-only`, key: key}, childrenToReturn); + return createElement('span', {className: `${this.props.prefixCls}-only`, style: style, key: key}, childrenToReturn); } setEndState(style) { @@ -39,27 +39,23 @@ class AntNumber extends React.Component { } const length = count.toString().length; const data = getPartNumber(count); + const height = findDOMNode(this).offsetHeight; let childrenWap = []; let i = 0; while (i < length) { - const children = this.getNumberOnly(i); - childrenWap.unshift(children); - i++; - } - const height = findDOMNode(this).offsetHeight; - const _length = childrenWap.length - 1; - childrenWap = childrenWap.map((child, j)=> { - const oneData = Number(count.toString()[j]); + const oneData = Number(count.toString()[i]); const style = {}; let translateY = -(oneData + 10) * height; //判断状态 - translateY = getTranslateY(count, this.count, data, this.data, j, height, _length) || translateY; + translateY = getTranslateY(count, this.count, data, this.data, i, height, length - 1) || translateY; if (count !== this.count) { this.setEndState(style); } - style.transform = 'translateY(' + translateY + 'px)'; - return cloneElement(child, {style: style}); - }); + style.transform = `translateY(${translateY}px)`; + const children = this.getNumberOnly(i, style); + childrenWap.push(children); + i++; + } this.data = data; this.count = count; return childrenWap; @@ -106,7 +102,7 @@ class AntNumber extends React.Component { render() { const childrenToRender = this.state.children; - const props = assign({}, this.props, {className: this.props.prefixCls + ' ' + this.props.className}); + const props = assign({}, this.props, {className: `${this.props.prefixCls} ${this.props.className}`}); return createElement(this.props.component, props, childrenToRender); } } diff --git a/components/badge/demo/change.md b/components/badge/demo/change.md index 962472164d..4ce034bdab 100644 --- a/components/badge/demo/change.md +++ b/components/badge/demo/change.md @@ -13,7 +13,7 @@ const ButtonGroup = Button.Group; const Test = React.createClass({ getInitialState() { return { - count: 19, + count: 5, show: true, }; }, From 21dc8811c9906932441a8f0f5750d01b62a7f255 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 20 Nov 2015 17:16:56 +0800 Subject: [PATCH 11/56] update table doc --- components/table/index.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/table/index.md b/components/table/index.md index 314dc81240..3f1b67cad4 100644 --- a/components/table/index.md +++ b/components/table/index.md @@ -40,6 +40,8 @@ var dataSource = [{ **远程数据模式**是更常见的业务场景,是一次只从服务端读取一页的数据放在前端,执行筛选、排序、切换页码等操作时均向后台发送请求,后台返回当页的数据和相关分页信息。 +> 远程数据模式后续可能删除,目前不推荐使用。 + 通过指定表格的数据源 `dataSource` 为一个 DataSource 的实例如下。 ```jsx From 97b6ff7f92d77a333b9b4c9d635f3518ed8d1b67 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 20 Nov 2015 18:01:02 +0800 Subject: [PATCH 12/56] update timepicker index.md --- components/timepicker/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/timepicker/index.md b/components/timepicker/index.md index a8e1d86eef..054a8ca079 100644 --- a/components/timepicker/index.md +++ b/components/timepicker/index.md @@ -17,7 +17,7 @@ API --- ```html - + ``` | 参数 | 说明 | 类型 | 默认值 | From 184e378e7945a376bb1a407defa609e7636dcca2 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 20 Nov 2015 18:21:59 +0800 Subject: [PATCH 13/56] move col row input into indepent dirctories, remove antd.ButtonGroup --- components/col/index.js | 2 ++ components/form/index.jsx | 6 +----- components/{form/Input.jsx => input/index.jsx} | 0 components/row/index.js | 2 ++ index.js | 9 ++++----- 5 files changed, 9 insertions(+), 10 deletions(-) create mode 100644 components/col/index.js rename components/{form/Input.jsx => input/index.jsx} (100%) create mode 100644 components/row/index.js diff --git a/components/col/index.js b/components/col/index.js new file mode 100644 index 0000000000..752938c58d --- /dev/null +++ b/components/col/index.js @@ -0,0 +1,2 @@ +import { Col } from '../layout'; +export default Col; diff --git a/components/form/index.jsx b/components/form/index.jsx index 59220bd943..6aca8b0a4a 100644 --- a/components/form/index.jsx +++ b/components/form/index.jsx @@ -1,11 +1,7 @@ import Form from './Form'; import FormItem from './FormItem'; import ValueMixin from './ValueMixin'; -import Input from './Input'; Form.Item = FormItem; Form.ValueMixin = ValueMixin; -export default { - Form, - Input -}; +export default Form; diff --git a/components/form/Input.jsx b/components/input/index.jsx similarity index 100% rename from components/form/Input.jsx rename to components/input/index.jsx diff --git a/components/row/index.js b/components/row/index.js new file mode 100644 index 0000000000..a17e1a2c22 --- /dev/null +++ b/components/row/index.js @@ -0,0 +1,2 @@ +import { Row } from '../layout'; +export default Row; diff --git a/index.js b/index.js index 61b54e3125..15568140ae 100644 --- a/index.js +++ b/index.js @@ -36,13 +36,12 @@ const antd = { Menu: require('./components/menu'), Timeline: require('./components/timeline'), Button: require('./components/button'), - ButtonGroup: require('./components/button').Group, Icon: require('./components/icon'), - Row: require('./components/layout').Row, - Col: require('./components/layout').Col, + Row: require('./components/row'), + Col: require('./components/col'), Spin: require('./components/spin'), - Form: require('./components/form').Form, - Input: require('./components/form').Input, + Form: require('./components/form'), + Input: require('./components/input'), Calendar: require('./components/calendar'), Timepicker: require('./components/timepicker'), }; From 7eb2f5b58a1c404ed7c3d78d5f8b386f6b075e64 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 20 Nov 2015 18:51:12 +0800 Subject: [PATCH 14/56] Add support for degrade usage of form --- components/form/index.jsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/form/index.jsx b/components/form/index.jsx index 6aca8b0a4a..a21b5ac902 100644 --- a/components/form/index.jsx +++ b/components/form/index.jsx @@ -1,7 +1,15 @@ import Form from './Form'; import FormItem from './FormItem'; import ValueMixin from './ValueMixin'; +import Input from '../input'; Form.Item = FormItem; Form.ValueMixin = ValueMixin; + +// 对于 import { Form, Input } from 'antd/lib/form/'; +// 的方式做向下兼容 +// https://github.com/ant-design/ant-design/pull/566 +Form.Form = Form; +Form.Input = Input; + export default Form; From c416d40b81df8edc765d501da678b305cacc45b3 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 20 Nov 2015 21:05:46 +0800 Subject: [PATCH 15/56] Fix datepicker style prop, close #564 --- components/datepicker/index.jsx | 1 + components/datepicker/index.md | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/components/datepicker/index.jsx b/components/datepicker/index.jsx index 64099ffb1a..38fd031c9e 100644 --- a/components/datepicker/index.jsx +++ b/components/datepicker/index.jsx @@ -139,6 +139,7 @@ function createPicker(TheCalendar) { onChange={this.handleInputChange} value={value && this.getFormatter().format(value)} placeholder={placeholder} + style={this.props.style} className={'ant-calendar-picker-input ant-input' + sizeClass}/> diff --git a/components/datepicker/index.md b/components/datepicker/index.md index 985bb8af02..b8d8915f1d 100644 --- a/components/datepicker/index.md +++ b/components/datepicker/index.md @@ -27,7 +27,8 @@ | onChange | 时间发生变化的回调,发生在用户选择时间时 | function(Date value) | 无 | | showTime | 显示时间选择条 | boolean | false | | disabled | 禁用 | bool | false | -| calendarStyle | 格外的弹出日历样式,例如 zIndex | object | {} | +| style | 自定义输入框样式 | object | {} | +| popupStyle | 格外的弹出日历样式 | object | {} | | size | 输入框大小,`large` 高度为 32px,`small` 为 22px,默认是 28px | string | 无 | | locale | 国际化配置 | object | [默认配置](https://github.com/ant-design/ant-design/issues/424) | From bb897c17ecf67d39304a1e135e148e8fe662f850 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 20 Nov 2015 21:07:29 +0800 Subject: [PATCH 16/56] fix datepicker placeholder --- components/datepicker/index.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/datepicker/index.jsx b/components/datepicker/index.jsx index 38fd031c9e..73f68b5027 100644 --- a/components/datepicker/index.jsx +++ b/components/datepicker/index.jsx @@ -94,7 +94,7 @@ function createPicker(TheCalendar) { defaultCalendarValue.setTime(Date.now()); const placeholder = ('placeholder' in this.props) - ? this.placeholder : this.getLocale().lang.placeholder; + ? this.props.placeholder : this.getLocale().lang.placeholder; const calendar = ( Date: Fri, 20 Nov 2015 21:09:47 +0800 Subject: [PATCH 17/56] update upgrade-to-0.10.md --- docs/upgrade-to-0.10.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/upgrade-to-0.10.md b/docs/upgrade-to-0.10.md index 56a0db5a36..e8e27f331d 100644 --- a/docs/upgrade-to-0.10.md +++ b/docs/upgrade-to-0.10.md @@ -5,7 +5,7 @@ --- -`0.10.0` 版本有大量改动,是一个不完全向下兼容的版本。以下文档尽力列出了 `0.9.x` 到 `0.10.0` 的不兼容变动,以帮助开发者升级。 +`0.10.x` 版本有大量改动,是一个不完全向下兼容的版本。以下文档尽力列出了 `0.9.x` 到 `0.10.x` 的不兼容变动,以帮助开发者升级。 - `0.10.x` 文档:http://ant.design - `0.9.x` 文档:http://09x.ant.design @@ -52,6 +52,7 @@ - Carousel 升级依赖,参考新的[新的 API 和使用方式](/components/carousel/)进行修改。 - `antd.Notification()` 修改为小写的 `antd.notification()`。 - Datepicker 的 `onSelect` 属性修改为 `onChange` 属性。 +- Datepicker 的 `calendarStyle` 属性修改为 `popupStyle` 属性。 - Dropdown 的 `onSelect` 属性应修正为 `onClick` 属性,因为原有的 onSelect 只在变化时触发。 - Slider 的 `withDots` `isIncluded` 属性修改为 `dots` `included`。 - iconfont 的基线更新,可能导致原有图标的位置偏移。 From 44404f8a599eb12d35f46421a36940111fefdd49 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 20 Nov 2015 21:24:44 +0800 Subject: [PATCH 18/56] update CHANGELOG --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 845c0ffc59..1d5a795635 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ --- +## 0.10.1 `2015-11-20` + +- 修改内部组件的引用结构,方便工具优化。[#566](https://github.com/ant-design/ant-design/pull/566) + - 移除了演示中没有使用过的 `antd.ButtonGroup`,依然用 `const ButtonGroup = Button.Group` 来使用。 + - Form 和 Input 目录分离,`import { Form, Input } from 'ant/lib/form'` 的引用方式被废弃,现在可以 `import Form from 'ant/lib/form'` 和 `import Input from 'ant/lib/input'`。原有的 `import { form, input } from 'antd'` 则不受影响。 +- 修复 Datepicker 的 `style` 和 `calendarStyle` 属性失效的问题,并将 `calendarStyle` 更名为 `popStyle`。 + + ## 0.10.0 `2015-11-20` - 全面兼容 `react@0.14.x`。 From 250836371bfb38e7a10235a0be1c623a5d8ddc0e Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 20 Nov 2015 21:44:05 +0800 Subject: [PATCH 19/56] improve code style --- components/badge/AntNumber.jsx | 19 +++++++++++-------- components/badge/demo/change.md | 12 ++++++++---- components/badge/index.jsx | 4 +--- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/components/badge/AntNumber.jsx b/components/badge/AntNumber.jsx index b6dd706991..aefc786cd7 100644 --- a/components/badge/AntNumber.jsx +++ b/components/badge/AntNumber.jsx @@ -1,6 +1,6 @@ -import React, {createElement} from 'react'; -import {findDOMNode} from 'react-dom'; -import {toArrayChildren, getPartNumber, getTranslateY} from './utils'; +import React, { createElement } from 'react'; +import { findDOMNode } from 'react-dom'; +import { toArrayChildren, getPartNumber, getTranslateY } from './utils'; import assign from 'object-assign'; class AntNumber extends React.Component { @@ -16,15 +16,17 @@ class AntNumber extends React.Component { }; } - getNumberOnly(c, style) { + getNumberOnly(index, style) { const childrenToReturn = []; for (let i = 0; i < 30; i++) { let count = i >= 10 ? i % 10 : i; - const children =

{count}

; - childrenToReturn.push(children); + childrenToReturn.push(

{count}

); } - const key = 'only_' + c; - return createElement('span', {className: `${this.props.prefixCls}-only`, style: style, key: key}, childrenToReturn); + return createElement('span', { + className: `${this.props.prefixCls}-only`, + style: style, + key: index, + }, childrenToReturn); } setEndState(style) { @@ -106,6 +108,7 @@ class AntNumber extends React.Component { return createElement(this.props.component, props, childrenToRender); } } + AntNumber.defaultProps = { prefixCls: 'ant-number', count: null, diff --git a/components/badge/demo/change.md b/components/badge/demo/change.md index 4ce034bdab..59b7b9878e 100644 --- a/components/badge/demo/change.md +++ b/components/badge/demo/change.md @@ -33,7 +33,7 @@ const Test = React.createClass({ show: !this.state.show }); }, - onNumberClick(){ + onNumberClick() { const count = this.state.count; this.setState({ count: count ? 0 : 5 @@ -45,9 +45,15 @@ const Test = React.createClass({
- 一个链接 +
+ + - -
; } diff --git a/components/badge/index.jsx b/components/badge/index.jsx index 0057221ed8..06e3a59614 100644 --- a/components/badge/index.jsx +++ b/components/badge/index.jsx @@ -31,7 +31,7 @@ class AntBadge extends React.Component { transitionAppear={true}> { hidden ? null : - + } @@ -43,7 +43,6 @@ AntBadge.defaultProps = { prefixCls: 'ant-badge', count: null, dot: false, - animEnd: null }; AntBadge.propTypes = { @@ -52,7 +51,6 @@ AntBadge.propTypes = { React.PropTypes.number ]), dot: React.PropTypes.bool, - animEnd: React.PropTypes.func }; export default AntBadge; From 05ef4a62d1434d39d1219703efa7ff89cf4ea301 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 20 Nov 2015 21:47:55 +0800 Subject: [PATCH 20/56] bump 0.10.1 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index a175bc4135..7d866feab0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "antd", - "version": "0.10.0", - "stableVersion": "0.10.0", + "version": "0.10.1", + "stableVersion": "0.10.1", "title": "Ant Design", "description": "一个 UI 设计语言", "homepage": "http://ant.design/", From 12888147800ad41c23425fdc949836ff3cadb60c Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 20 Nov 2015 22:02:30 +0800 Subject: [PATCH 21/56] update Changelog --- CHANGELOG.md | 7 ++++++- site/static/style.css | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d5a795635..0c1c3da3a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,12 @@ - 修改内部组件的引用结构,方便工具优化。[#566](https://github.com/ant-design/ant-design/pull/566) - 移除了演示中没有使用过的 `antd.ButtonGroup`,依然用 `const ButtonGroup = Button.Group` 来使用。 - - Form 和 Input 目录分离,`import { Form, Input } from 'ant/lib/form'` 的引用方式被废弃,现在可以 `import Form from 'ant/lib/form'` 和 `import Input from 'ant/lib/input'`。原有的 `import { form, input } from 'antd'` 则不受影响。 + - Form 和 Input 目录分离,`import { Form, Input } from 'ant/lib/form'` 的引用方式被废弃。 + + 现在可以 `import Form from 'ant/lib/form'` 和 `import Input from 'ant/lib/input'`。 + + 原有的 `import { Form, Input } from 'antd'` 则不受影响。 + - 修复 Datepicker 的 `style` 和 `calendarStyle` 属性失效的问题,并将 `calendarStyle` 更名为 `popStyle`。 diff --git a/site/static/style.css b/site/static/style.css index cc3db26679..8c411d0463 100644 --- a/site/static/style.css +++ b/site/static/style.css @@ -558,6 +558,11 @@ footer ul li > a { padding-left: 8px; } +.markdown > ul li p, +.markdown > ol li p { + margin: 0.6em 0; +} + .markdown > ol li { list-style: decimal; margin-left: 20px; From 6329c75d761f249702dc4f0f77045a9ec2410c69 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 20 Nov 2015 22:04:56 +0800 Subject: [PATCH 22/56] update Changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c1c3da3a8..96e34bbfb8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ 原有的 `import { Form, Input } from 'antd'` 则不受影响。 -- 修复 Datepicker 的 `style` 和 `calendarStyle` 属性失效的问题,并将 `calendarStyle` 更名为 `popStyle`。 +- 修复 Datepicker 的 `style` 和 `calendarStyle` 属性失效的问题,并将 `calendarStyle` 更名为 `popupStyle`。 ## 0.10.0 `2015-11-20` From 47dab2d18ef6ee9abedbc3ee358e6cc722ca2a34 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 20 Nov 2015 22:43:01 +0800 Subject: [PATCH 23/56] update style --- site/static/style.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/site/static/style.css b/site/static/style.css index 8c411d0463..f45de6d817 100644 --- a/site/static/style.css +++ b/site/static/style.css @@ -1670,8 +1670,8 @@ footer ul li > a { .component-demos { margin: 2em 0 1em; - color: #5C6B77; - font-weight: 600; + color: #404040; + font-weight: 500; } .component-demos .anticon-appstore { From dc9dd43e39692c536d64d82fa787ce6b8c78780b Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 20 Nov 2015 22:46:52 +0800 Subject: [PATCH 24/56] fix doc style --- site/static/style.css | 1 + 1 file changed, 1 insertion(+) diff --git a/site/static/style.css b/site/static/style.css index f45de6d817..176530e684 100644 --- a/site/static/style.css +++ b/site/static/style.css @@ -1672,6 +1672,7 @@ footer ul li > a { margin: 2em 0 1em; color: #404040; font-weight: 500; + font-size: 24px; } .component-demos .anticon-appstore { From bbadcc34c1ce87540c4cbc2f7fb6bd8302f67faf Mon Sep 17 00:00:00 2001 From: Benjy Cui Date: Sat, 21 Nov 2015 16:48:35 +0800 Subject: [PATCH 25/56] refactor: cache the result of `getLocale()` --- components/datepicker/index.jsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/datepicker/index.jsx b/components/datepicker/index.jsx index 73f68b5027..1793c3bb92 100644 --- a/components/datepicker/index.jsx +++ b/components/datepicker/index.jsx @@ -87,18 +87,19 @@ function createPicker(TheCalendar) { this.props.onChange(timeValue); }, render() { + const locale = this.getLocale(); // 以下两行代码 // 给没有初始值的日期选择框提供本地化信息 // 否则会以周日开始排 - let defaultCalendarValue = new GregorianCalendar(this.getLocale()); + let defaultCalendarValue = new GregorianCalendar(locale); defaultCalendarValue.setTime(Date.now()); const placeholder = ('placeholder' in this.props) - ? this.props.placeholder : this.getLocale().lang.placeholder; + ? this.props.placeholder : locale.lang.placeholder; const calendar = ( Date: Sat, 21 Nov 2015 23:57:11 +0800 Subject: [PATCH 26/56] fix links, #572 --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96e34bbfb8..85ad4457fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,7 +44,7 @@ #### 组件变更 - Table - - 支持单选。[演示](/components/table/#demo-row-selection-radio-props) + - 支持单选。[演示](http://ant.design/components/table/#demo-row-selection-radio-props) - 选择模式支持默认选中和不可用效果。[演示](/components/table/#demo-row-selection-props) - 列支持了 `colSpan` 和 `rowSpan` 配置。[演示](/components/table/#demo-colspan-rowspan) - 新增 `loading` 属性。 @@ -83,7 +83,7 @@ > 备注: > > - [计划和推进 issue](https://github.com/ant-design/ant-design/issues/276) -> - [0.10 升级指南](/docs/upgrade-to-0.10) +> - [0.10 升级指南](http://ant.design/docs/upgrade-to-0.10) ## 0.9.3 ~ 0.9.5 `2015-11-04` From c14dcc7e40e4edf398caee58cd5e91a1977ac315 Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 23 Nov 2015 11:01:17 +0800 Subject: [PATCH 27/56] fix #571 --- components/breadcrumb/index.jsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/breadcrumb/index.jsx b/components/breadcrumb/index.jsx index 48d4442d05..546b39b5e8 100644 --- a/components/breadcrumb/index.jsx +++ b/components/breadcrumb/index.jsx @@ -30,6 +30,9 @@ let Breadcrumb = React.createClass({ if (routes && routes.length > 0 && ReactRouter) { let Link = ReactRouter.Link; crumbs = routes.map(function(route, i) { + if (!route.breadcrumbName) { + return null; + } let name = route.breadcrumbName.replace(/\:(.*)/g, function(replacement, key) { return params[key] || replacement; }); From 5d68d9469902a722e3120705224a305b3c658af7 Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 23 Nov 2015 14:53:20 +0800 Subject: [PATCH 28/56] fix #532 --- site/static/style.css | 1 + 1 file changed, 1 insertion(+) diff --git a/site/static/style.css b/site/static/style.css index 176530e684..e2b98e03f0 100644 --- a/site/static/style.css +++ b/site/static/style.css @@ -16,6 +16,7 @@ body { font-size: 14px; background: #fff; transition: background 1s cubic-bezier(0.075, 0.82, 0.165, 1); + overflow-x: hidden; } *, From 23b5bf0cb0f2897df211b71a289a02f9f6f853de Mon Sep 17 00:00:00 2001 From: jljsj Date: Mon, 23 Nov 2015 15:08:19 +0800 Subject: [PATCH 29/56] update badge getTranslateY --- components/badge/AntNumber.jsx | 10 ++-- components/badge/demo/change.md | 6 +-- components/badge/index.jsx | 2 +- components/badge/utils.js | 84 ++++++++++++++++----------------- style/components/badge.less | 2 +- 5 files changed, 52 insertions(+), 52 deletions(-) diff --git a/components/badge/AntNumber.jsx b/components/badge/AntNumber.jsx index b6dd706991..bd7a12a622 100644 --- a/components/badge/AntNumber.jsx +++ b/components/badge/AntNumber.jsx @@ -40,20 +40,22 @@ class AntNumber extends React.Component { const length = count.toString().length; const data = getPartNumber(count); const height = findDOMNode(this).offsetHeight; + const differ = count - this.count; let childrenWap = []; let i = 0; while (i < length) { - const oneData = Number(count.toString()[i]); + const oneData = data[i]; const style = {}; let translateY = -(oneData + 10) * height; //判断状态 - translateY = getTranslateY(count, this.count, data, this.data, i, height, length - 1) || translateY; + const Y = getTranslateY(differ, data, this.data, height, i); + translateY = typeof Y === 'number' ? Y : translateY; if (count !== this.count) { this.setEndState(style); } style.transform = `translateY(${translateY}px)`; const children = this.getNumberOnly(i, style); - childrenWap.push(children); + childrenWap.unshift(children); i++; } this.data = data; @@ -109,7 +111,7 @@ class AntNumber extends React.Component { AntNumber.defaultProps = { prefixCls: 'ant-number', count: null, - max: 99, + max: null, component: 'sup', callback: null, }; diff --git a/components/badge/demo/change.md b/components/badge/demo/change.md index 4ce034bdab..a3bd4fb62a 100644 --- a/components/badge/demo/change.md +++ b/components/badge/demo/change.md @@ -13,16 +13,16 @@ const ButtonGroup = Button.Group; const Test = React.createClass({ getInitialState() { return { - count: 5, + count: 227, show: true, }; }, increase() { - const count = this.state.count + 1; + const count = this.state.count + 13; this.setState({ count }); }, decline() { - let count = this.state.count - 1; + let count = this.state.count - 71; if (count < 0) { count = 0; } diff --git a/components/badge/index.jsx b/components/badge/index.jsx index 0057221ed8..7d31a37a0c 100644 --- a/components/badge/index.jsx +++ b/components/badge/index.jsx @@ -11,7 +11,7 @@ class AntBadge extends React.Component { let { count, prefixCls } = this.props; const dot = this.props.dot; - count = count >= 100 ? '99+' : count; + //count = count >= 100 ? '99+' : count; // dot mode don't need count if (dot) { diff --git a/components/badge/utils.js b/components/badge/utils.js index 357d213fd4..90a3b1ec37 100644 --- a/components/badge/utils.js +++ b/components/badge/utils.js @@ -9,6 +9,9 @@ export function toArrayChildren(children) { } export function getPartNumber(num) { + if (!num) { + return null; + } const countStr = num.toString(); const obj = {}; for (let i = 0; i < countStr.length; i++) { @@ -17,59 +20,54 @@ export function getPartNumber(num) { return obj; } -export function getTranslateY(count, preCount, data, preData, j, height, _length) { +export function getTranslateY(differ, data, _data, height, i) { let translateY = 0; - const oneData = Number(count.toString()[j]); - const on = preData[_length - j]; - const to = data[_length - j]; - const preOn = preData[_length - j + 1]; - const preTo = data[_length - j + 1]; - if (count === preCount) { - const add = preData[(_length - j) + '_add']; - const rem = preData[(_length - j) + '_rem']; - if (add) { - translateY = -(oneData + 20) * height; + if (!differ) { + //不想插入40个,改变要滚到的距离; + if (_data[i + '_add']) { + return -(data[i] + 20) * height; } - if (rem) { - translateY = -oneData * height; + if (_data[i + '_rem']) { + return -data[i] * height; } + return false; } - if (count > preCount) { - if (on > to) { - translateY = -(oneData - (to - on)) * height; - if (typeof preOn === 'number' && preTo - preOn > 1) { - data[(_length - j) + '_add'] = true; - } - } else if (on < to) { - translateY = -(oneData + 10 - (to - on)) * height; - if (preTo - preOn) { - //translateY = -(oneData + 20 - (to - on)) * height; - data[(_length - j) + '_add'] = true; + //判断相差的位数来驱动数字;差个位滚动一格,差10的部分及以上个位滚动一周; + const countToString = Math.abs(differ).toString(); + const countLength = countToString.length; + const on = _data[i]; + const to = data[i]; + if (differ > 0) { + if (countLength - 1 > i) { + translateY = -(to - (to - on)) * height; + //on大于to且differ大于10,如9->0,需要设计滚动到的位置+10; + if (on > to) { + data[i + '_add'] = true; } + } else if (countLength - 1 < i && to === on) { + //参数不变动; + translateY = null; + } else if (typeof on === 'undefined') { + //新增加入时设为0; + translateY = -10 * height; } else { - if (typeof preOn === 'number' && typeof preTo === 'number') { - translateY = -oneData * height; - } + //如果开始大于到达,到达(to)加10; + const _to = on > to ? to + 10 : to; + translateY = -(to - (_to - on) + 10) * height; } - } else if (count < preCount) { - if (on < to) { - translateY = -(oneData + 20 - ( to - on)) * height; - if (typeof preTo === 'number' && preOn - preTo > 1) { - data[(_length - j) + '_rem'] = true; - } - } else if (on > to) { - translateY = -(oneData + 10 - (to - on)) * height; - if (preOn - preTo) { - translateY = -(oneData + 20 - (to - on)) * height; + } else { + if (countLength - 1 > i) { + translateY = -(to + (on - to) + 20) * height; + //同上,differ大于10时,且to在于on + if (to > on) { + data[i + '_rem'] = true; } + } else if (countLength - 1 < i && to === on) { + translateY = null; } else { - if (typeof preOn === 'number' && typeof preTo === 'number') { - translateY = -(oneData + 20) * height; - } + const _on = on < to ? on + 10 : on; + translateY = -(to + (_on - to) + 10) * height; } } - if (on !== 0 && !on) { - translateY = -10 * height; - } return translateY; } diff --git a/style/components/badge.less b/style/components/badge.less index 91066ccf5b..c0c310fe73 100644 --- a/style/components/badge.less +++ b/style/components/badge.less @@ -68,7 +68,7 @@ a .@{badge-prefix-cls} { &-only{ display: inline-block; - transition: transform .3s @ease-in-out; + transition: transform 1.3s @ease-in-out; } } From e47e1c8db6d591f110e83c4eac40565a68905c0b Mon Sep 17 00:00:00 2001 From: yiminghe Date: Mon, 23 Nov 2015 15:20:42 +0800 Subject: [PATCH 30/56] add jsfiddle demo --- docs/getting-started.md | 8 ++++++++ package.json | 2 +- webpack.antd.config.js | 21 +++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 webpack.antd.config.js diff --git a/docs/getting-started.md b/docs/getting-started.md index ed9894f41b..a89d8755d5 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -7,6 +7,14 @@ Ant Design React 致力于提供给程序员**愉悦**的开发体验。 +## JSFiddle + +最简单尝试 antd 的方式是使用以下 JSFiddle 例子, 也推荐 fork 这个例子来进行 bug report, 注意不要在实际项目中使用 + +- [antd JSFiddle](http://jsfiddle.net/yiminghe/a0pzy83a/1/) + +## Using antd from npm + 实际项目开发中,你会需要对 ES2015 和 JSX 代码的构建、调试、代理、打包部署等一系列工程化的需求。 我们提供了一套 `npm` + `webpack` 的开发工具链来辅助开发,下面我们用一个简单的实例来说明。 diff --git a/package.json b/package.json index 7d866feab0..f77ad129b1 100644 --- a/package.json +++ b/package.json @@ -108,7 +108,7 @@ "start": "npm run clean && nico server --watch", "clean": "rm -rf _site dist", "deploy": "rm -rf node_modules && node scripts/install.js && npm run just-deploy", - "just-deploy": "npm run clean && webpack --config webpack.deploy.config.js && NODE_ENV=PRODUCTION nico build && node scripts/deploy.js", + "just-deploy": "npm run clean && webpack --config webpack.deploy.config.js && webpack --config webpack.antd.config.js && NODE_ENV=PRODUCTION nico build && node scripts/deploy.js", "lint": "eslint components test index.js --ext '.js,.jsx'", "test": "npm run lint && webpack && npm run jest", "jest": "jest", diff --git a/webpack.antd.config.js b/webpack.antd.config.js new file mode 100644 index 0000000000..877ab9d096 --- /dev/null +++ b/webpack.antd.config.js @@ -0,0 +1,21 @@ +var config = require('./webpack.config'); +config.entry = { + 'antd': ['./index.js'] +}; +config.externals = { + 'react': { + root: 'React', + commonjs2: 'react', + commonjs: 'react', + amd: 'react' + }, + 'react-dom': { + root: 'ReactDOM', + commonjs2: 'react-dom', + commonjs: 'react-dom', + amd: 'react-dom' + } +}; +config.output.library = 'antd'; +config.output.libraryTarget = 'umd'; +module.exports = config; \ No newline at end of file From 64be14e89e0e8d9642c3add1437b6b166636e265 Mon Sep 17 00:00:00 2001 From: jljsj Date: Mon, 23 Nov 2015 15:21:52 +0800 Subject: [PATCH 31/56] update --- components/badge/demo/change.md | 6 +++--- components/badge/index.jsx | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/badge/demo/change.md b/components/badge/demo/change.md index b96c7c5027..59b7b9878e 100644 --- a/components/badge/demo/change.md +++ b/components/badge/demo/change.md @@ -13,16 +13,16 @@ const ButtonGroup = Button.Group; const Test = React.createClass({ getInitialState() { return { - count: 227, + count: 5, show: true, }; }, increase() { - const count = this.state.count + 13; + const count = this.state.count + 1; this.setState({ count }); }, decline() { - let count = this.state.count - 71; + let count = this.state.count - 1; if (count < 0) { count = 0; } diff --git a/components/badge/index.jsx b/components/badge/index.jsx index 8da011e7f6..f5cc0713f8 100644 --- a/components/badge/index.jsx +++ b/components/badge/index.jsx @@ -11,7 +11,7 @@ class AntBadge extends React.Component { let { count, prefixCls } = this.props; const dot = this.props.dot; - //count = count >= 100 ? '99+' : count; + count = count >= 100 ? '99+' : count; // dot mode don't need count if (dot) { @@ -31,7 +31,7 @@ class AntBadge extends React.Component { transitionAppear={true}> { hidden ? null : - + } From a1542c7495d7d4f186c2897885a928504f603f40 Mon Sep 17 00:00:00 2001 From: yiminghe Date: Mon, 23 Nov 2015 15:39:49 +0800 Subject: [PATCH 32/56] update antd at jsfiddle --- docs/getting-started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index a89d8755d5..5e1dc8d53e 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -11,7 +11,7 @@ Ant Design React 致力于提供给程序员**愉悦**的开发体验。 最简单尝试 antd 的方式是使用以下 JSFiddle 例子, 也推荐 fork 这个例子来进行 bug report, 注意不要在实际项目中使用 -- [antd JSFiddle](http://jsfiddle.net/yiminghe/a0pzy83a/1/) +- [antd JSFiddle](http://jsfiddle.net/yiminghe/9zrstuto/) ## Using antd from npm From 8026a92974b7433aac546afe3f55bb1810f47b10 Mon Sep 17 00:00:00 2001 From: jljsj Date: Mon, 23 Nov 2015 15:39:55 +0800 Subject: [PATCH 33/56] update transition-duration --- components/badge/utils.js | 11 +++++++++++ style/components/badge.less | 3 +-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/components/badge/utils.js b/components/badge/utils.js index 90a3b1ec37..c6280b89f8 100644 --- a/components/badge/utils.js +++ b/components/badge/utils.js @@ -33,12 +33,19 @@ export function getTranslateY(differ, data, _data, height, i) { return false; } //判断相差的位数来驱动数字;差个位滚动一格,差10的部分及以上个位滚动一周; + /* + * 区域段 + * 0-9:0 + * 0-9:1 + * 0-9:2 + * */ const countToString = Math.abs(differ).toString(); const countLength = countToString.length; const on = _data[i]; const to = data[i]; if (differ > 0) { if (countLength - 1 > i) { + //差值位数大于1时,参数的位置,到达减去两个参数的差,在0区域段; translateY = -(to - (to - on)) * height; //on大于to且differ大于10,如9->0,需要设计滚动到的位置+10; if (on > to) { @@ -53,10 +60,12 @@ export function getTranslateY(differ, data, _data, height, i) { } else { //如果开始大于到达,到达(to)加10; const _to = on > to ? to + 10 : to; + //差值为一位数时,到达减去两个参数的差,在1区域段,加10; translateY = -(to - (_to - on) + 10) * height; } } else { if (countLength - 1 > i) { + //差值位数大于1时,参数的位置,到达加上两个参数的差,在2区域段,加20,需要滚动一周; translateY = -(to + (on - to) + 20) * height; //同上,differ大于10时,且to在于on if (to > on) { @@ -65,7 +74,9 @@ export function getTranslateY(differ, data, _data, height, i) { } else if (countLength - 1 < i && to === on) { translateY = null; } else { + //如果到达大于开始,开始(on)加10; const _on = on < to ? on + 10 : on; + //差值位数小于1时,参数的位置,到达减去两个参数的差,在1区域段,加10,往上滚回差值; translateY = -(to + (_on - to) + 10) * height; } } diff --git a/style/components/badge.less b/style/components/badge.less index c0c310fe73..c4d83c0cc7 100644 --- a/style/components/badge.less +++ b/style/components/badge.less @@ -67,8 +67,7 @@ a .@{badge-prefix-cls} { overflow: hidden; &-only{ display: inline-block; - - transition: transform 1.3s @ease-in-out; + transition: transform .3s @ease-in-out; } } From 780e89e73a63430122221dba5b3ffcf60603ca06 Mon Sep 17 00:00:00 2001 From: yiminghe Date: Mon, 23 Nov 2015 15:42:56 +0800 Subject: [PATCH 34/56] update antd at jsfiddle --- docs/getting-started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index 5e1dc8d53e..0538071451 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -11,7 +11,7 @@ Ant Design React 致力于提供给程序员**愉悦**的开发体验。 最简单尝试 antd 的方式是使用以下 JSFiddle 例子, 也推荐 fork 这个例子来进行 bug report, 注意不要在实际项目中使用 -- [antd JSFiddle](http://jsfiddle.net/yiminghe/9zrstuto/) +- [antd JSFiddle](http://jsfiddle.net/yiminghe/9zrstuto/1/) ## Using antd from npm From ac48019452949b3529d10eb1038d800bde61d001 Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 23 Nov 2015 15:46:42 +0800 Subject: [PATCH 35/56] update footer link --- site/templates/footer.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/templates/footer.html b/site/templates/footer.html index 1becf341f2..88160e741c 100644 --- a/site/templates/footer.html +++ b/site/templates/footer.html @@ -14,7 +14,7 @@

联系我们

反馈和建议 讨论 - 报告 Bug + 报告 Bug
  • ©2015 蚂蚁金服体验技术部出品

    From b261262f8e32d13b35aacf08b3cda1549c269b82 Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 23 Nov 2015 16:02:31 +0800 Subject: [PATCH 36/56] update doc --- docs/getting-started.md | 7 ++++--- site/templates/footer.html | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index 0538071451..5ba8ccaeb3 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -7,13 +7,14 @@ Ant Design React 致力于提供给程序员**愉悦**的开发体验。 -## JSFiddle +## 第一个例子 -最简单尝试 antd 的方式是使用以下 JSFiddle 例子, 也推荐 fork 这个例子来进行 bug report, 注意不要在实际项目中使用 +最简单的试用方式参照以下 JSFiddle 演示, 也推荐 Fork 本例来进行 Bug Report, 注意不要在实际项目中这样使用。 - [antd JSFiddle](http://jsfiddle.net/yiminghe/9zrstuto/1/) -## Using antd from npm + +## 标准开发 实际项目开发中,你会需要对 ES2015 和 JSX 代码的构建、调试、代理、打包部署等一系列工程化的需求。 我们提供了一套 `npm` + `webpack` 的开发工具链来辅助开发,下面我们用一个简单的实例来说明。 diff --git a/site/templates/footer.html b/site/templates/footer.html index 88160e741c..5fe80df7ab 100644 --- a/site/templates/footer.html +++ b/site/templates/footer.html @@ -14,7 +14,7 @@

    联系我们

    反馈和建议 讨论 - 报告 Bug + 报告 Bug
  • ©2015 蚂蚁金服体验技术部出品

    From 5bbf9369fb568c98cafe992e0daa36bf23125ae7 Mon Sep 17 00:00:00 2001 From: Benjy Cui Date: Mon, 23 Nov 2015 16:16:54 +0800 Subject: [PATCH 37/56] deps: update rc-slider and demo --- components/slider/demo/input-number.md | 33 ++++++++++++++++++++++++-- package.json | 2 +- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/components/slider/demo/input-number.md b/components/slider/demo/input-number.md index d5f3407458..cd9d8c30a7 100644 --- a/components/slider/demo/input-number.md +++ b/components/slider/demo/input-number.md @@ -9,7 +9,7 @@ ````jsx import { Slider, InputNumber } from 'antd'; -const Test = React.createClass({ +const IntegerStep = React.createClass({ getInitialState() { return { inputValue: 1 @@ -35,5 +35,34 @@ const Test = React.createClass({ } }); -ReactDOM.render(, document.getElementById('components-slider-demo-input-number')); +const DecimalStep = React.createClass({ + getInitialState() { + return { + inputValue: 0 + }; + }, + onChange(value) { + this.setState({ + inputValue: value + }); + }, + render() { + return ( +
    +
    + +
    +
    + +
    +
    + ); + } +}); + +ReactDOM.render(
    + + +
    , document.getElementById('components-slider-demo-input-number')); ```` diff --git a/package.json b/package.json index f77ad129b1..c93028f047 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "rc-queue-anim": "~0.11.2", "rc-radio": "~2.0.0", "rc-select": "~5.1.2", - "rc-slider": "~3.1.0", + "rc-slider": "~3.1.2", "rc-steps": "~1.4.1", "rc-switch": "~1.3.1", "rc-table": "~3.6.1", From 3768e49597987247a61e913e99dbe9b79b8d201d Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 23 Nov 2015 17:19:35 +0800 Subject: [PATCH 38/56] improve code style --- components/badge/AntNumber.jsx | 33 +++++++++++++++--------------- components/badge/utils.js | 37 +++++++++------------------------- 2 files changed, 26 insertions(+), 44 deletions(-) diff --git a/components/badge/AntNumber.jsx b/components/badge/AntNumber.jsx index db2c90473e..a64675d69c 100644 --- a/components/badge/AntNumber.jsx +++ b/components/badge/AntNumber.jsx @@ -1,12 +1,13 @@ import React, { createElement } from 'react'; import { findDOMNode } from 'react-dom'; -import { toArrayChildren, getPartNumber, getTranslateY } from './utils'; +import { getPartNumber, getTranslateY } from './utils'; import assign from 'object-assign'; +import { Children } from 'rc-util'; class AntNumber extends React.Component { constructor(props) { super(props); - const children = toArrayChildren(this.props.children); + const children = Children.toArray(this.props.children); this.endSetState = false; this.count = this.props.count; this.data = getPartNumber(this.count); @@ -46,12 +47,9 @@ class AntNumber extends React.Component { let childrenWap = []; let i = 0; while (i < length) { - const oneData = data[i]; const style = {}; - let translateY = -(oneData + 10) * height; - //判断状态 - const Y = getTranslateY(differ, data, this.data, height, i); - translateY = typeof Y === 'number' ? Y : translateY; + const Y = getTranslateY(differ, data, this.data, i) || -(data[i] + 10); + const translateY = Y * height; if (count !== this.count) { this.setEndState(style); } @@ -77,7 +75,7 @@ class AntNumber extends React.Component { if (newChildren && newChildren.length) { this.setState({ children: newChildren, - }, ()=> { + }, () => { if (this.endSetState) { this.updateChildren(props); this.endSetState = false; @@ -88,11 +86,7 @@ class AntNumber extends React.Component { animEnd() { clearTimeout(this.timeout); - this.timeout = setTimeout(()=> { - if (typeof this.props.callback === 'function') { - this.props.callback(); - } - }, 300); + this.timeout = setTimeout(this.props.callback, 300); } componentDidMount() { @@ -105,9 +99,14 @@ class AntNumber extends React.Component { } render() { - const childrenToRender = this.state.children; - const props = assign({}, this.props, {className: `${this.props.prefixCls} ${this.props.className}`}); - return createElement(this.props.component, props, childrenToRender); + const props = assign({}, this.props, { + className: `${this.props.prefixCls} ${this.props.className}` + }); + return createElement( + this.props.component, + props, + this.state.children + ); } } @@ -116,7 +115,7 @@ AntNumber.defaultProps = { count: null, max: null, component: 'sup', - callback: null, + callback: function() {}, }; AntNumber.propTypes = { diff --git a/components/badge/utils.js b/components/badge/utils.js index c6280b89f8..465ad95522 100644 --- a/components/badge/utils.js +++ b/components/badge/utils.js @@ -1,34 +1,17 @@ -import React from 'react'; - -export function toArrayChildren(children) { - const ret = []; - React.Children.forEach(children, (c) => { - ret.push(c); - }); - return ret; -} - export function getPartNumber(num) { - if (!num) { - return null; - } - const countStr = num.toString(); - const obj = {}; - for (let i = 0; i < countStr.length; i++) { - obj[countStr.length - 1 - i] = Number(countStr[i]); - } - return obj; + return num ? + num.toString().split('').map(i => Number(i)).reverse() : []; } -export function getTranslateY(differ, data, _data, height, i) { +export function getTranslateY(differ, data, _data, i) { let translateY = 0; if (!differ) { //不想插入40个,改变要滚到的距离; if (_data[i + '_add']) { - return -(data[i] + 20) * height; + return -(data[i] + 20); } if (_data[i + '_rem']) { - return -data[i] * height; + return -data[i]; } return false; } @@ -46,7 +29,7 @@ export function getTranslateY(differ, data, _data, height, i) { if (differ > 0) { if (countLength - 1 > i) { //差值位数大于1时,参数的位置,到达减去两个参数的差,在0区域段; - translateY = -(to - (to - on)) * height; + translateY = -(to - (to - on)); //on大于to且differ大于10,如9->0,需要设计滚动到的位置+10; if (on > to) { data[i + '_add'] = true; @@ -56,17 +39,17 @@ export function getTranslateY(differ, data, _data, height, i) { translateY = null; } else if (typeof on === 'undefined') { //新增加入时设为0; - translateY = -10 * height; + translateY = -10; } else { //如果开始大于到达,到达(to)加10; const _to = on > to ? to + 10 : to; //差值为一位数时,到达减去两个参数的差,在1区域段,加10; - translateY = -(to - (_to - on) + 10) * height; + translateY = -(to - (_to - on) + 10); } } else { if (countLength - 1 > i) { //差值位数大于1时,参数的位置,到达加上两个参数的差,在2区域段,加20,需要滚动一周; - translateY = -(to + (on - to) + 20) * height; + translateY = -(to + (on - to) + 20); //同上,differ大于10时,且to在于on if (to > on) { data[i + '_rem'] = true; @@ -77,7 +60,7 @@ export function getTranslateY(differ, data, _data, height, i) { //如果到达大于开始,开始(on)加10; const _on = on < to ? on + 10 : on; //差值位数小于1时,参数的位置,到达减去两个参数的差,在1区域段,加10,往上滚回差值; - translateY = -(to + (_on - to) + 10) * height; + translateY = -(to + (_on - to) + 10); } } return translateY; From 9d4aa291f33884b9302ddd03c8a59f45ab411531 Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 23 Nov 2015 22:58:11 +0800 Subject: [PATCH 39/56] Refactor ant scroll number --- components/badge/AntNumber.jsx | 131 ------------------------------ components/badge/ScrollNumber.jsx | 118 +++++++++++++++++++++++++++ components/badge/index.jsx | 4 +- components/badge/utils.js | 67 --------------- style/components/badge.less | 5 +- 5 files changed, 123 insertions(+), 202 deletions(-) delete mode 100644 components/badge/AntNumber.jsx create mode 100644 components/badge/ScrollNumber.jsx delete mode 100644 components/badge/utils.js diff --git a/components/badge/AntNumber.jsx b/components/badge/AntNumber.jsx deleted file mode 100644 index a64675d69c..0000000000 --- a/components/badge/AntNumber.jsx +++ /dev/null @@ -1,131 +0,0 @@ -import React, { createElement } from 'react'; -import { findDOMNode } from 'react-dom'; -import { getPartNumber, getTranslateY } from './utils'; -import assign from 'object-assign'; -import { Children } from 'rc-util'; - -class AntNumber extends React.Component { - constructor(props) { - super(props); - const children = Children.toArray(this.props.children); - this.endSetState = false; - this.count = this.props.count; - this.data = getPartNumber(this.count); - this.timeout = null; - this.state = { - children, - }; - } - - getNumberOnly(index, style) { - const childrenToReturn = []; - for (let i = 0; i < 30; i++) { - let count = i >= 10 ? i % 10 : i; - childrenToReturn.push(

    {count}

    ); - } - return createElement('span', { - className: `${this.props.prefixCls}-only`, - style: style, - key: index, - }, childrenToReturn); - } - - setEndState(style) { - this.endSetState = true; - style.transition = 'none'; - } - - getNumberElement(props) { - const count = props.count; - if (!count || count === '') { - return null; - } - const length = count.toString().length; - const data = getPartNumber(count); - const height = findDOMNode(this).offsetHeight; - const differ = count - this.count; - let childrenWap = []; - let i = 0; - while (i < length) { - const style = {}; - const Y = getTranslateY(differ, data, this.data, i) || -(data[i] + 10); - const translateY = Y * height; - if (count !== this.count) { - this.setEndState(style); - } - style.transform = `translateY(${translateY}px)`; - const children = this.getNumberOnly(i, style); - childrenWap.unshift(children); - i++; - } - this.data = data; - this.count = count; - return childrenWap; - } - - updateChildren(props) { - if (typeof props.count === 'string') { - this.data = getPartNumber(this.props.max); - this.count = this.props.max; - return this.setState({ - children: [props.count], - }); - } - const newChildren = this.getNumberElement(props); - if (newChildren && newChildren.length) { - this.setState({ - children: newChildren, - }, () => { - if (this.endSetState) { - this.updateChildren(props); - this.endSetState = false; - } - }); - } - } - - animEnd() { - clearTimeout(this.timeout); - this.timeout = setTimeout(this.props.callback, 300); - } - - componentDidMount() { - this.updateChildren(this.props); - } - - componentWillReceiveProps(nextProps) { - this.updateChildren(nextProps); - this.animEnd(); - } - - render() { - const props = assign({}, this.props, { - className: `${this.props.prefixCls} ${this.props.className}` - }); - return createElement( - this.props.component, - props, - this.state.children - ); - } -} - -AntNumber.defaultProps = { - prefixCls: 'ant-number', - count: null, - max: null, - component: 'sup', - callback: function() {}, -}; - -AntNumber.propTypes = { - count: React.PropTypes.oneOfType([ - React.PropTypes.string, - React.PropTypes.number - ]), - component: React.PropTypes.string, - callback: React.PropTypes.func, - max: React.PropTypes.number, -}; - -export default AntNumber; diff --git a/components/badge/ScrollNumber.jsx b/components/badge/ScrollNumber.jsx new file mode 100644 index 0000000000..0ba49d76f8 --- /dev/null +++ b/components/badge/ScrollNumber.jsx @@ -0,0 +1,118 @@ +import React, { createElement } from 'react'; +import assign from 'object-assign'; + +function getNumberArray(num) { + return num ? + num.toString().split('').map(i => Number(i)) : []; +} + +class AntScrollNumber extends React.Component { + constructor(props) { + super(props); + this.state = { + animated: true + }; + } + + getPositionByNum(num, i) { + if (this.state.animated) { + return 10 + num; + } + const currentDigit = getNumberArray(this.props.count)[i]; + const lastDigit = getNumberArray(this.lastCount)[i]; + // 同方向则在同一侧切换数字 + if (this.props.count > this.lastCount) { + if (currentDigit >= lastDigit) { + return 10 + num; + } else { + return 20 + num; + } + } else { + if (currentDigit <= lastDigit) { + return 10 + num; + } else { + return num; + } + } + } + + componentWillReceiveProps(nextProps) { + if ('count' in nextProps && nextProps.count) { + if (this.lastCount !== this.props.count) { + this.lastCount = this.props.count; + this.setState({ + animated: false + }, () => { + setTimeout(() => { + this.setState({ + animated: true + }); + this.props.callback(); + }, 300); + }); + } + } + } + + renderNumberList() { + const childrenToReturn = []; + for (let i = 0; i < 30; i++) { + childrenToReturn.push(

    {i % 10}

    ); + } + return childrenToReturn; + } + + renderCurrentNumber(num, i) { + const position = this.getPositionByNum(num, i); + const height = this.props.height; + return createElement('span', { + className: `${this.props.prefixCls}-only`, + style: { + transition: this.state.animated && 'none', + transform: 'translate3d(0, ' + (-position * height) + 'px, 0)', + height: height, + }, + key: i, + }, this.renderNumberList()); + } + + renderNumberElement() { + const props = this.props; + if (!props.count || isNaN(props.count)) { + return props.count; + } + return getNumberArray(props.count) + .map((num, i) => this.renderCurrentNumber(num, i)); + } + + render() { + const props = assign({}, this.props, { + className: `${this.props.prefixCls} ${this.props.className}` + }); + return createElement( + this.props.component, + props, + this.renderNumberElement() + ); + } +} + +AntScrollNumber.defaultProps = { + prefixCls: 'ant-scroll-number', + count: null, + component: 'sup', + callback: function() {}, + height: 20 +}; + +AntScrollNumber.propTypes = { + count: React.PropTypes.oneOfType([ + React.PropTypes.string, + React.PropTypes.number + ]), + component: React.PropTypes.string, + callback: React.PropTypes.func, + height: React.PropTypes.number, +}; + +export default AntScrollNumber; diff --git a/components/badge/index.jsx b/components/badge/index.jsx index f5cc0713f8..06f1546437 100644 --- a/components/badge/index.jsx +++ b/components/badge/index.jsx @@ -1,6 +1,6 @@ import React from 'react'; import Animate from 'rc-animate'; -import AntNumber from './AntNumber'; +import ScrollNumber from './ScrollNumber'; class AntBadge extends React.Component { constructor(props) { @@ -31,7 +31,7 @@ class AntBadge extends React.Component { transitionAppear={true}> { hidden ? null : - + } diff --git a/components/badge/utils.js b/components/badge/utils.js deleted file mode 100644 index 465ad95522..0000000000 --- a/components/badge/utils.js +++ /dev/null @@ -1,67 +0,0 @@ -export function getPartNumber(num) { - return num ? - num.toString().split('').map(i => Number(i)).reverse() : []; -} - -export function getTranslateY(differ, data, _data, i) { - let translateY = 0; - if (!differ) { - //不想插入40个,改变要滚到的距离; - if (_data[i + '_add']) { - return -(data[i] + 20); - } - if (_data[i + '_rem']) { - return -data[i]; - } - return false; - } - //判断相差的位数来驱动数字;差个位滚动一格,差10的部分及以上个位滚动一周; - /* - * 区域段 - * 0-9:0 - * 0-9:1 - * 0-9:2 - * */ - const countToString = Math.abs(differ).toString(); - const countLength = countToString.length; - const on = _data[i]; - const to = data[i]; - if (differ > 0) { - if (countLength - 1 > i) { - //差值位数大于1时,参数的位置,到达减去两个参数的差,在0区域段; - translateY = -(to - (to - on)); - //on大于to且differ大于10,如9->0,需要设计滚动到的位置+10; - if (on > to) { - data[i + '_add'] = true; - } - } else if (countLength - 1 < i && to === on) { - //参数不变动; - translateY = null; - } else if (typeof on === 'undefined') { - //新增加入时设为0; - translateY = -10; - } else { - //如果开始大于到达,到达(to)加10; - const _to = on > to ? to + 10 : to; - //差值为一位数时,到达减去两个参数的差,在1区域段,加10; - translateY = -(to - (_to - on) + 10); - } - } else { - if (countLength - 1 > i) { - //差值位数大于1时,参数的位置,到达加上两个参数的差,在2区域段,加20,需要滚动一周; - translateY = -(to + (on - to) + 20); - //同上,differ大于10时,且to在于on - if (to > on) { - data[i + '_rem'] = true; - } - } else if (countLength - 1 < i && to === on) { - translateY = null; - } else { - //如果到达大于开始,开始(on)加10; - const _on = on < to ? on + 10 : on; - //差值位数小于1时,参数的位置,到达减去两个参数的差,在1区域段,加10,往上滚回差值; - translateY = -(to + (_on - to) + 10); - } - } - return translateY; -} diff --git a/style/components/badge.less b/style/components/badge.less index c4d83c0cc7..f66cab04b7 100644 --- a/style/components/badge.less +++ b/style/components/badge.less @@ -1,5 +1,5 @@ @badge-prefix-cls: ~"@{css-prefix}badge"; -@number-prefix-cls: ~"@{css-prefix}number"; +@number-prefix-cls: ~"@{css-prefix}scroll-number"; .@{badge-prefix-cls} { position: relative; @@ -67,7 +67,7 @@ a .@{badge-prefix-cls} { overflow: hidden; &-only{ display: inline-block; - transition: transform .3s @ease-in-out; + transition: transform .3s @ease-in-out;//transform .3s @ease-in-out; } } @@ -90,3 +90,4 @@ a .@{badge-prefix-cls} { transform: scale(0) translateX(-50%); } } + From 47c8f3de69cf28558416e9c056898e97784a8007 Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 24 Nov 2015 15:29:57 +0800 Subject: [PATCH 40/56] improve badge anim --- components/badge/ScrollNumber.jsx | 59 ++++++++++++++++++------------- style/components/badge.less | 2 +- 2 files changed, 35 insertions(+), 26 deletions(-) diff --git a/components/badge/ScrollNumber.jsx b/components/badge/ScrollNumber.jsx index 0ba49d76f8..630ee12334 100644 --- a/components/badge/ScrollNumber.jsx +++ b/components/badge/ScrollNumber.jsx @@ -3,25 +3,26 @@ import assign from 'object-assign'; function getNumberArray(num) { return num ? - num.toString().split('').map(i => Number(i)) : []; + num.toString().split('').reverse().map(i => Number(i)) : []; } class AntScrollNumber extends React.Component { constructor(props) { super(props); this.state = { - animated: true + animateStarted: true, + count: props.count }; } getPositionByNum(num, i) { - if (this.state.animated) { + if (this.state.animateStarted) { return 10 + num; } - const currentDigit = getNumberArray(this.props.count)[i]; + const currentDigit = getNumberArray(this.state.count)[i]; const lastDigit = getNumberArray(this.lastCount)[i]; // 同方向则在同一侧切换数字 - if (this.props.count > this.lastCount) { + if (this.state.count > this.lastCount) { if (currentDigit >= lastDigit) { return 10 + num; } else { @@ -38,19 +39,25 @@ class AntScrollNumber extends React.Component { componentWillReceiveProps(nextProps) { if ('count' in nextProps && nextProps.count) { - if (this.lastCount !== this.props.count) { - this.lastCount = this.props.count; - this.setState({ - animated: false - }, () => { - setTimeout(() => { - this.setState({ - animated: true - }); - this.props.callback(); - }, 300); - }); + if (this.lastCount === this.state.count) { + return; } + this.lastCount = this.state.count; + // 复原数字初始位置 + this.setState({ + animateStarted: true, + }, () => { + // 等待数字位置复原完毕 + // 开始设置完整的数字 + setTimeout(() => { + this.setState({ + animateStarted: false, + count: nextProps.count, + }, () => { + this.props.onAnimated(); + }); + }, 5); + }); } } @@ -65,10 +72,12 @@ class AntScrollNumber extends React.Component { renderCurrentNumber(num, i) { const position = this.getPositionByNum(num, i); const height = this.props.height; + const removeTransition = this.state.animateStarted || + (getNumberArray(this.lastCount)[i] === undefined); return createElement('span', { className: `${this.props.prefixCls}-only`, style: { - transition: this.state.animated && 'none', + transition: removeTransition && 'none', transform: 'translate3d(0, ' + (-position * height) + 'px, 0)', height: height, }, @@ -77,12 +86,12 @@ class AntScrollNumber extends React.Component { } renderNumberElement() { - const props = this.props; - if (!props.count || isNaN(props.count)) { - return props.count; + const state = this.state; + if (!state.count || isNaN(state.count)) { + return state.count; } - return getNumberArray(props.count) - .map((num, i) => this.renderCurrentNumber(num, i)); + return getNumberArray(state.count) + .map((num, i) => this.renderCurrentNumber(num, i)).reverse(); } render() { @@ -101,7 +110,7 @@ AntScrollNumber.defaultProps = { prefixCls: 'ant-scroll-number', count: null, component: 'sup', - callback: function() {}, + onAnimated: function() {}, height: 20 }; @@ -111,7 +120,7 @@ AntScrollNumber.propTypes = { React.PropTypes.number ]), component: React.PropTypes.string, - callback: React.PropTypes.func, + onAnimated: React.PropTypes.func, height: React.PropTypes.number, }; diff --git a/style/components/badge.less b/style/components/badge.less index f66cab04b7..51ac45855f 100644 --- a/style/components/badge.less +++ b/style/components/badge.less @@ -67,7 +67,7 @@ a .@{badge-prefix-cls} { overflow: hidden; &-only{ display: inline-block; - transition: transform .3s @ease-in-out;//transform .3s @ease-in-out; + transition: transform .3s @ease-in-out; } } From aca1736a68b2044709b72ef9e1c8d94298c84e5f Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 24 Nov 2015 16:27:12 +0800 Subject: [PATCH 41/56] fix filter dropdown width, close #581 --- style/components/table.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/style/components/table.less b/style/components/table.less index 7c9228c4fc..2b70639615 100644 --- a/style/components/table.less +++ b/style/components/table.less @@ -214,7 +214,7 @@ margin-top: -6px; .ant-dropdown-menu-item { overflow: hidden; - padding: 7px 8px; + padding: 7px 24px 8px 7px; &.ant-dropdown-menu-item-selected { .selected_icon(); } From 871be19528fef1769020aede1a5f6e40872e2b5e Mon Sep 17 00:00:00 2001 From: "xiaosheng.lj" Date: Tue, 24 Nov 2015 17:00:34 +0800 Subject: [PATCH 42/56] fix upload multiple #579 --- components/upload/index.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/upload/index.jsx b/components/upload/index.jsx index 0a68b40053..554545bba5 100644 --- a/components/upload/index.jsx +++ b/components/upload/index.jsx @@ -62,7 +62,7 @@ const AntUpload = React.createClass({ f.status = 'uploading'; return f; }); - nextFileList = nextFileList.concat(file); + nextFileList = nextFileList.concat(targetItem); } else { targetItem = fileToObject(file); targetItem.status = 'uploading'; From 83d047466bb428ab1ef96c304ae5926d92485478 Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 24 Nov 2015 17:25:32 +0800 Subject: [PATCH 43/56] Add datepicker and timepicer usage demo --- components/datepicker/demo/time.md | 37 +++++++++++++++++++++++++----- components/datepicker/index.md | 1 - 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/components/datepicker/demo/time.md b/components/datepicker/demo/time.md index d72c4de844..7dd481742e 100644 --- a/components/datepicker/demo/time.md +++ b/components/datepicker/demo/time.md @@ -1,15 +1,40 @@ -# 时间选择 +# 日期时间选择 - order: 4 -准确到秒的时间选择面板。 +和 [时间选择框](/components/timepicer) 配合使用。 --- ````jsx -import { Datepicker } from 'antd'; +import { Datepicker, Timepicker } from 'antd'; -ReactDOM.render( - -, document.getElementById('components-datepicker-demo-time')); +let result = new Date(); +let selectdDate, selectdTime; +function handleChange(from, value) { + if (!value) { + from === 'date' ? + (selectdDate = false) : (selectdTime = false); + return; + } + if (from === 'date') { + result.setFullYear(value.getFullYear()); + result.setMonth(value.getMonth()); + result.setDate(value.getDate()); + selectdDate = true; + } else { + result.setHours(value.getHours()); + result.setMinutes(value.getMinutes()); + result.setSeconds(value.getSeconds()); + selectdTime = true; + } + if (selectdDate && selectdTime) { + console.log('选择结果是:' + result); + } +} + +ReactDOM.render(
    + + +
    , document.getElementById('components-datepicker-demo-time')); ```` diff --git a/components/datepicker/index.md b/components/datepicker/index.md index b8d8915f1d..2f12f7978e 100644 --- a/components/datepicker/index.md +++ b/components/datepicker/index.md @@ -25,7 +25,6 @@ | format | 展示的日期格式 | string | "yyyy-MM-dd" | | disabledDate | 不可选择的日期 | function | 无 | | onChange | 时间发生变化的回调,发生在用户选择时间时 | function(Date value) | 无 | -| showTime | 显示时间选择条 | boolean | false | | disabled | 禁用 | bool | false | | style | 自定义输入框样式 | object | {} | | popupStyle | 格外的弹出日历样式 | object | {} | From 8cd65dcdba4fd2d680f8dc903b8a97a3da2a153d Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 24 Nov 2015 17:33:14 +0800 Subject: [PATCH 44/56] update timepicker demo --- components/timepicker/index.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/components/timepicker/index.md b/components/timepicker/index.md index 054a8ca079..db245b0642 100644 --- a/components/timepicker/index.md +++ b/components/timepicker/index.md @@ -30,8 +30,5 @@ API | hourOptions | 特定可选择的小时 | array | 0 到 24 组成的数组 | | minuteOptions | 特定可选择的分钟 | array | 0 到 60 组成的数组 | | secondOptions | 特定可选择的秒 | array | 0 到 60 组成的数组 | -| inputClassName | 输入框的样式 | string | | -| placement | 显示位置 | string | bottomLeft | -| transitionName | 显示动画 | string | slide-up | - + From 62b50c76d70068a244b8f40b0073f5187fff35e0 Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 24 Nov 2015 17:43:58 +0800 Subject: [PATCH 45/56] adjust datepicker and timepicker style to fit each other --- components/datepicker/index.jsx | 2 +- components/timepicker/index.jsx | 2 +- style/components/datepicker/Calendar.less | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/datepicker/index.jsx b/components/datepicker/index.jsx index 1793c3bb92..81d2d7d759 100644 --- a/components/datepicker/index.jsx +++ b/components/datepicker/index.jsx @@ -20,7 +20,7 @@ function createPicker(TheCalendar) { }, // onChange 可用于 Validator locale: {}, align: { - offset: [0, -10], + offset: [0, -9], }, open: false }; diff --git a/components/timepicker/index.jsx b/components/timepicker/index.jsx index 8e7c334584..8e18f9eb65 100644 --- a/components/timepicker/index.jsx +++ b/components/timepicker/index.jsx @@ -12,7 +12,7 @@ const AntTimepicker = React.createClass({ onChange() {}, locale: {}, align: { - offset: [0, -1], + offset: [0, -2], }, open: false, disabled: false, diff --git a/style/components/datepicker/Calendar.less b/style/components/datepicker/Calendar.less index b8219fe87d..fab776734b 100644 --- a/style/components/datepicker/Calendar.less +++ b/style/components/datepicker/Calendar.less @@ -81,7 +81,7 @@ line-height: @line-height-base; &-input-wrap { - padding: 8px; + padding: 6px; border-bottom: 1px solid #e9e9e9; } @@ -236,14 +236,14 @@ .@{calendar-prefix-cls}-clear-btn { position: absolute; - right: 6px; + right: 5px; text-indent: -76px; overflow: hidden; width: 20px; height: 20px; text-align: center; line-height: 20px; - top: 7px; + top: 6px; margin: 0; } From ce76ebfe9b69e54e3d2b0509f11fc4545c674efc Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 24 Nov 2015 20:03:57 +0800 Subject: [PATCH 46/56] replace rcUtil.classSet by classnames, ref react-component/util#1 --- components/affix/index.jsx | 3 +- components/button/button-group.jsx | 4 +-- components/button/button.jsx | 4 +-- components/form/Form.jsx | 6 ++-- components/form/FormItem.jsx | 8 ++---- components/layout/col.jsx | 4 +-- components/layout/row.jsx | 4 +-- components/spin/index.jsx | 4 +-- components/validation/demo/customize.md | 37 ++++++++++--------------- package.json | 1 + scripts/demo.js | 1 + 11 files changed, 33 insertions(+), 43 deletions(-) diff --git a/components/affix/index.jsx b/components/affix/index.jsx index 32e3cf939b..eaa9c11bcd 100644 --- a/components/affix/index.jsx +++ b/components/affix/index.jsx @@ -1,6 +1,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; import rcUtil from 'rc-util'; +import classNames from 'classnames'; function getScroll(w, top) { let ret = w['page' + (top ? 'Y' : 'X') + 'Offset']; @@ -89,7 +90,7 @@ let Affix = React.createClass({ }, render() { - const className = rcUtil.classSet({ + const className = classNames({ [this.props.className]: this.props.className, 'ant-affix': this.state.affix }); diff --git a/components/button/button-group.jsx b/components/button/button-group.jsx index 4fa7390a3a..082ee4d577 100644 --- a/components/button/button-group.jsx +++ b/components/button/button-group.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import rcUtil from 'rc-util'; +import classNames from 'classnames'; const prefix = 'ant-btn-group-'; @@ -14,7 +14,7 @@ export default class ButtonGroup extends React.Component { 'small': 'sm' })[size] || ''; - const classes = rcUtil.classSet({ + const classes = classNames({ 'ant-btn-group': true, [prefix + sizeCls]: sizeCls, [className]: className diff --git a/components/button/button.jsx b/components/button/button.jsx index 2e7247678d..c9760872b6 100644 --- a/components/button/button.jsx +++ b/components/button/button.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import rcUtil from 'rc-util'; +import classNames from 'classnames'; import { findDOMNode } from 'react-dom'; const rxTwoCNChar = /^[\u4e00-\u9fa5]{2,2}$/; @@ -41,7 +41,7 @@ export default class Button extends React.Component { 'small': 'sm' })[size] || ''; - const classes = rcUtil.classSet({ + const classes = classNames({ 'ant-btn': true, [prefix + type]: type, [prefix + shape]: shape, diff --git a/components/form/Form.jsx b/components/form/Form.jsx index 95afeb4235..0236bc4546 100644 --- a/components/form/Form.jsx +++ b/components/form/Form.jsx @@ -1,7 +1,5 @@ import React from 'react'; -import rcUtil from 'rc-util'; - -const cx = rcUtil.classSet; +import classNames from 'classnames'; class Form extends React.Component { render() { @@ -10,7 +8,7 @@ class Form extends React.Component { [`${prefixCls}-horizontal`]: this.props.horizontal, [`${prefixCls}-inline`]: this.props.inline, }; - const classes = cx(formClassName); + const classes = classNames(formClassName); return (
    diff --git a/components/form/FormItem.jsx b/components/form/FormItem.jsx index 9bcf47a6a0..ff0d9cec4e 100644 --- a/components/form/FormItem.jsx +++ b/components/form/FormItem.jsx @@ -1,7 +1,5 @@ import React from 'react'; -import rcUtil from 'rc-util'; - -const cx = rcUtil.classSet; +import classNames from 'classnames'; function prefixClsFn(prefixCls, ...args) { return args.map((s)=> { @@ -32,7 +30,7 @@ class FormItem extends React.Component { renderValidateWrapper(c1, c2) { let classes = ''; if (this.props.validateStatus) { - classes = cx( + classes = classNames( { 'has-feedback': this.props.hasFeedback, 'has-success': this.props.validateStatus === 'success', @@ -113,7 +111,7 @@ class FormItem extends React.Component { }; return ( -
    +
    {children}
    ); diff --git a/components/layout/col.jsx b/components/layout/col.jsx index cf335820d3..338e950ab5 100644 --- a/components/layout/col.jsx +++ b/components/layout/col.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import rcUtil from 'rc-util'; +import classNames from 'classnames'; const Col = React.createClass({ propTypes: { @@ -13,7 +13,7 @@ const Col = React.createClass({ }, render() { const {span, order, offset, push, pull, className, ...others} = this.props; - const classes = rcUtil.classSet({ + const classes = classNames({ ['col-' + span]: span, ['col-order-' + order]: order, ['col-offset-' + offset]: offset, diff --git a/components/layout/row.jsx b/components/layout/row.jsx index c67bafd618..6f11214020 100644 --- a/components/layout/row.jsx +++ b/components/layout/row.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import rcUtil from 'rc-util'; +import classNames from 'classnames'; const Row = React.createClass({ propTypes: { @@ -11,7 +11,7 @@ const Row = React.createClass({ }, render() { const { type, justify, align, className, ...others } = this.props; - const classes = rcUtil.classSet({ + const classes = classNames({ 'row': true, ['row-' + type]: type, ['row-' + type + '-' + justify]: justify, diff --git a/components/spin/index.jsx b/components/spin/index.jsx index efdbeae679..6e14d764e6 100644 --- a/components/spin/index.jsx +++ b/components/spin/index.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { classSet } from 'rc-util'; +import classNames from 'classnames'; import { isCssAnimationSupported } from 'css-animation'; const AntSpin = React.createClass({ @@ -23,7 +23,7 @@ const AntSpin = React.createClass({ render() { const { className, size, prefixCls } = this.props; - let spinClassName = classSet({ + let spinClassName = classNames({ [prefixCls]: true, [`${prefixCls}-${size}`]: size, [className]: !!className, diff --git a/components/validation/demo/customize.md b/components/validation/demo/customize.md index 07518ee45b..878fe4f8f8 100644 --- a/components/validation/demo/customize.md +++ b/components/validation/demo/customize.md @@ -9,20 +9,11 @@ --- ````jsx -import {Validation, Button, Form, Input, Row, Col} from 'antd'; +import { Validation, Button, Form, Input, Row, Col } from 'antd'; +import classNames from 'classnames'; const Validator = Validation.Validator; const FormItem = Form.Item; -function cx(classNames) { - if (typeof classNames === 'object') { - return Object.keys(classNames).filter(function(className) { - return classNames[className]; - }).join(' '); - } else { - return Array.prototype.join.call(arguments, ' '); - } -} - function noop() { return false; } @@ -71,7 +62,7 @@ const Demo = React.createClass({ const formData = this.state.formData; const status = this.state.status; - const classes = cx({ + const classes = classNames({ 'error': status[item].errors, 'validating': status[item].isValidating, 'success': formData[item] && !status[item].errors && !status[item].isValidating @@ -119,7 +110,7 @@ const Demo = React.createClass({ renderPassStrengthBar(type) { const strength = type === 'pass' ? this.state.passStrength : this.state.rePassStrength; - const classSet = cx({ + const classSet = classNames({ 'ant-pwd-strength': true, 'ant-pwd-strength-low': strength === 'L', 'ant-pwd-strength-medium': strength === 'M', @@ -132,16 +123,16 @@ const Demo = React.createClass({ }; return ( -
    -
      -
    • -
    • -
    • - - {level[strength]} - -
    -
    +
    +
      +
    • +
    • +
    • + + {level[strength]} + +
    +
    ); }, diff --git a/package.json b/package.json index c93028f047..1da3fd18b9 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ ], "license": "MIT", "dependencies": { + "classnames": "~2.2.0", "css-animation": "1.1.x", "gregorian-calendar": "~4.0.1", "gregorian-calendar-format": "~4.0.4", diff --git a/scripts/demo.js b/scripts/demo.js index f2935c1f77..998101eec5 100644 --- a/scripts/demo.js +++ b/scripts/demo.js @@ -10,6 +10,7 @@ window.antd = antd; window.React = React; window.ReactDOM = ReactDOM; window['object-assign'] = require('object-assign'); +window['classnames'] = require('classnames'); antd.Datepicker.locale = { en_US: require('../components/datepicker/locale/en_US'), From a86a3b9a5b4c864218819dab131dacfe1a820e99 Mon Sep 17 00:00:00 2001 From: SimaQ Date: Wed, 25 Nov 2015 10:46:38 +0800 Subject: [PATCH 47/56] fix: fixes #586. --- components/form/index.md | 2 +- components/input/index.jsx | 2 +- components/validation/demo/other-items.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/form/index.md b/components/form/index.md index 80c300c6f1..064a2d1d3e 100644 --- a/components/form/index.md +++ b/components/form/index.md @@ -25,7 +25,7 @@ ```html {children} -`; + ``` ## Input 输入框 diff --git a/components/input/index.jsx b/components/input/index.jsx index c2d93f2afc..6094923abe 100644 --- a/components/input/index.jsx +++ b/components/input/index.jsx @@ -79,7 +79,7 @@ class Input extends React.Component { } switch (props.type) { case 'textarea': - return

    随便写点什么

  • , -
    +
    , -
    +
    diff --git a/components/queue-anim/demo/page.md b/components/queue-anim/demo/page.md index b26d4d6714..4b66af34a7 100644 --- a/components/queue-anim/demo/page.md +++ b/components/queue-anim/demo/page.md @@ -28,45 +28,45 @@ const Test = React.createClass({

    {this.state.show ? [ -
    -
    - - logo -
    - -
  • -
  • -
  • -
  • -
  • -
    -
    , - -
    我是标题
    -
    +
    +
    + + logo +
  • +
  • +
  • -
    -
    我是标题
    -
    - -
    - +
    , + +
    我是标题
    +
    +
  • -
  • -
  • - -
    -
    , - -
    -
    +
    +
    我是标题
    +
    + +
    + +
  • +
  • +
  • +
  • +
  • +
    +
    +
    +
    , + +
    +
    ] : null}
    diff --git a/components/queue-anim/demo/router.md b/components/queue-anim/demo/router.md index b1a9524af1..7925294e58 100644 --- a/components/queue-anim/demo/router.md +++ b/components/queue-anim/demo/router.md @@ -29,7 +29,7 @@ const App = React.createClass({ - {React.cloneElement(this.props.children||, {key: key})} + {React.cloneElement(this.props.children || , {key: key})}
    ); @@ -83,7 +83,7 @@ const Page1 = React.createClass({
    - +
  • @@ -104,7 +104,7 @@ const Page2 = React.createClass({
    - +
  • diff --git a/components/radio/demo/disable.md b/components/radio/demo/disable.md index 59da63660b..fa2c8f8013 100644 --- a/components/radio/demo/disable.md +++ b/components/radio/demo/disable.md @@ -9,10 +9,6 @@ Radio 不可用。 ````jsx import { Radio, Button } from 'antd'; -function toggleDisabled() { - disabled = !disabled; -} - const App = React.createClass({ getInitialState() { return { diff --git a/components/slider/demo/icon-slider.md b/components/slider/demo/icon-slider.md index 5e1595416f..e8cf9f1874 100644 --- a/components/slider/demo/icon-slider.md +++ b/components/slider/demo/icon-slider.md @@ -24,13 +24,11 @@ const IconSlider = React.createClass({ }, handleChange(v) { - this.setState( - { - preIconClass: v >= this.state.mid ? '' : 'anticon-highlight', - nextIconClass: v >= this.state.mid ? 'anticon-highlight': '', - sliderValue: v - } - ); + this.setState({ + preIconClass: v >= this.state.mid ? '' : 'anticon-highlight', + nextIconClass: v >= this.state.mid ? 'anticon-highlight' : '', + sliderValue: v + }); }, render() { diff --git a/components/spin/demo/nested.md b/components/spin/demo/nested.md index d8a68d25f1..99c0978270 100644 --- a/components/spin/demo/nested.md +++ b/components/spin/demo/nested.md @@ -21,7 +21,7 @@ const Card = React.createClass({ }); }, render() { - const container = ; return
    diff --git a/components/steps/demo/icon.md b/components/steps/demo/icon.md index 2741492a74..3a440eecd4 100644 --- a/components/steps/demo/icon.md +++ b/components/steps/demo/icon.md @@ -12,8 +12,8 @@ const Step = Steps.Step; const container = document.getElementById('components-steps-demo-icon'); ReactDOM.render( - - - + + + , container); ```` diff --git a/components/steps/demo/step-next.md b/components/steps/demo/step-next.md index 9600853f09..5992fbf652 100644 --- a/components/steps/demo/step-next.md +++ b/components/steps/demo/step-next.md @@ -27,7 +27,7 @@ const App = React.createClass({ getInitialState() { return { currentStep: Math.floor(Math.random() * steps.length) - } + }; }, next() { let s = this.state.currentStep + 1; diff --git a/components/steps/demo/vertical-small.md b/components/steps/demo/vertical-small.md index 4d6f2d961f..6b0586300f 100644 --- a/components/steps/demo/vertical-small.md +++ b/components/steps/demo/vertical-small.md @@ -7,7 +7,7 @@ --- ````jsx -import { Steps, Button } from 'antd'; +import { Steps } from 'antd'; const Step = Steps.Step; const container = document.getElementById('components-steps-demo-vertical-small'); diff --git a/components/steps/demo/vertical.md b/components/steps/demo/vertical.md index b840b50ef0..5dd3f4e33f 100644 --- a/components/steps/demo/vertical.md +++ b/components/steps/demo/vertical.md @@ -7,7 +7,7 @@ --- ````jsx -import { Steps, Button } from 'antd'; +import { Steps } from 'antd'; const Step = Steps.Step; const container = document.getElementById('components-steps-demo-vertical'); diff --git a/components/switch/demo/disabled.md b/components/switch/demo/disabled.md index 2490b42bab..5a340eb4b7 100644 --- a/components/switch/demo/disabled.md +++ b/components/switch/demo/disabled.md @@ -14,7 +14,7 @@ const Test = React.createClass({ getInitialState() { return { disabled: true - } + }; }, toggle(){ this.setState({ diff --git a/components/table/demo/ajax.md b/components/table/demo/ajax.md index 35323b8f08..341b026c0d 100644 --- a/components/table/demo/ajax.md +++ b/components/table/demo/ajax.md @@ -31,7 +31,7 @@ const columns = [{ }]; const dataSource = new Table.DataSource({ - url: "/components/table/demo/data.json", + url: '/components/table/demo/data.json', resolve: function(result) { return result.data; }, @@ -41,7 +41,7 @@ const dataSource = new Table.DataSource({ return { total: result.totalCount, pageSize: result.pageSize - } + }; }, // 和后台接口接收的参数进行适配 // 参数里提供了分页、筛选、排序的信息 diff --git a/components/table/demo/basic.md b/components/table/demo/basic.md index 40b87d05b0..47a9cb71fe 100644 --- a/components/table/demo/basic.md +++ b/components/table/demo/basic.md @@ -13,7 +13,7 @@ const columns = [{ title: '姓名', dataIndex: 'name', render: function(text) { - return {text}; + return {text}; } }, { title: '年龄', @@ -26,11 +26,11 @@ const columns = [{ dataIndex: '', render: function(text, record) { return - 操作一 + 操作一 - 操作二 + 操作二 - + 更多 ; diff --git a/components/table/demo/bordered.md b/components/table/demo/bordered.md index a80b265390..4e1c7fbfe1 100644 --- a/components/table/demo/bordered.md +++ b/components/table/demo/bordered.md @@ -13,7 +13,7 @@ const columns = [{ title: '姓名', dataIndex: 'name', render: function(text) { - return {text}; + return {text}; } }, { title: '资产', diff --git a/components/table/demo/colspan-rowspan.md b/components/table/demo/colspan-rowspan.md index 234dc32311..b967f2dafe 100644 --- a/components/table/demo/colspan-rowspan.md +++ b/components/table/demo/colspan-rowspan.md @@ -17,7 +17,7 @@ const renderContent = function(value, row, index) { let obj = { children: value, props: {} - } + }; if (index === 4) { obj.props.colSpan = 0; } @@ -29,14 +29,14 @@ const columns = [{ dataIndex: 'name', render: function(text, row, index) { if (index < 4) { - return {text}; + return {text}; } else { return { - children: {text}, + children: {text}, props: { colSpan: 5 } - } + }; } } }, { @@ -51,7 +51,7 @@ const columns = [{ let obj = { children: value, props:{} - } + }; // 第三列的第三行行合并 if (index === 2) { obj.props.rowSpan = 2; @@ -107,13 +107,13 @@ const data = [{ phone: 18900010002, address: '西湖区湖底公园1号' }, { - key: '5', - name: '习大大', - age: 18, - tel: '0575-22098909', - phone: 18900010002, - address: '西湖区湖底公园1号' - }]; + key: '5', + name: '习大大', + age: 18, + tel: '0575-22098909', + phone: 18900010002, + address: '西湖区湖底公园1号' +}]; ReactDOM.render( , document.getElementById('components-table-demo-colspan-rowspan')); diff --git a/components/table/demo/expand.md b/components/table/demo/expand.md index 107d522be6..cd86d3ad15 100644 --- a/components/table/demo/expand.md +++ b/components/table/demo/expand.md @@ -10,7 +10,7 @@ import { Table } from 'antd'; function renderAction() { - return 删除; + return 删除; } function expandedRowRender(record) { diff --git a/components/table/demo/loading.md b/components/table/demo/loading.md index cb68d0bdbe..3db9091be5 100644 --- a/components/table/demo/loading.md +++ b/components/table/demo/loading.md @@ -53,7 +53,7 @@ const App = React.createClass({ ; } -}) +}); ReactDOM.render(, document.getElementById('components-table-demo-loading')); ```` diff --git a/components/table/demo/local-data.md b/components/table/demo/local-data.md index 1f8151edb7..4a7b5b16a1 100644 --- a/components/table/demo/local-data.md +++ b/components/table/demo/local-data.md @@ -13,7 +13,7 @@ const columns = [{ title: '姓名', dataIndex: 'name', render: function(text) { - return {text}; + return {text}; } }, { title: '年龄', @@ -79,9 +79,8 @@ const App = React.createClass({ ; } -}) +}); ReactDOM.render( , document.getElementById('components-table-demo-local-data')); ```` - diff --git a/components/table/demo/paging.md b/components/table/demo/paging.md index 3d0d47473e..76655dae2b 100644 --- a/components/table/demo/paging.md +++ b/components/table/demo/paging.md @@ -13,7 +13,7 @@ const columns = [{ title: '姓名', dataIndex: 'name', render: function(text) { - return {text}; + return {text}; } }, { title: '年龄', @@ -24,7 +24,7 @@ const columns = [{ }]; const data = []; -for (let i=0; i<46; i++) { +for (let i = 0; i < 46; i++) { data.push({ key: i, name: '李大嘴' + i, diff --git a/components/table/demo/row-selection-props.md b/components/table/demo/row-selection-props.md index 8ba5c1875b..0a448addaf 100644 --- a/components/table/demo/row-selection-props.md +++ b/components/table/demo/row-selection-props.md @@ -13,7 +13,7 @@ const columns = [{ title: '姓名', dataIndex: 'name', render: function(text) { - return {text}; + return {text}; } }, { title: '年龄', diff --git a/components/table/demo/row-selection-radio-props.md b/components/table/demo/row-selection-radio-props.md index 0392a3bcda..bcfbdc5069 100644 --- a/components/table/demo/row-selection-radio-props.md +++ b/components/table/demo/row-selection-radio-props.md @@ -13,7 +13,7 @@ const columns = [{ title: '姓名', dataIndex: 'name', render: function(text) { - return {text}; + return {text}; } }, { title: '年龄', diff --git a/components/table/demo/row-selection.md b/components/table/demo/row-selection.md index 7f3dabc498..e20827d195 100644 --- a/components/table/demo/row-selection.md +++ b/components/table/demo/row-selection.md @@ -13,7 +13,7 @@ const columns = [{ title: '姓名', dataIndex: 'name', render: function(text) { - return {text}; + return {text}; } }, { title: '年龄', diff --git a/components/tabs/demo/add.md b/components/tabs/demo/add.md index bb7b98a832..6155d90f18 100644 --- a/components/tabs/demo/add.md +++ b/components/tabs/demo/add.md @@ -37,7 +37,7 @@ const Test = React.createClass({ activeKey: index.toString() }; }, - remove(index, e) { + remove(targetIndex, e) { e.stopPropagation(); let tabs = this.state.tabs; let activeKey = this.state.activeKey; @@ -49,15 +49,15 @@ const Test = React.createClass({ } const newTabs = tabs.filter(tab => { - if (tab.index !== index) { + if (tab.index !== targetIndex) { return true; } else { - foundIndex = index; + foundIndex = targetIndex; return false; } }); - if (activeKey === index) { + if (activeKey === targetIndex) { activeKey = tabs[foundIndex - 1].index; } @@ -101,7 +101,7 @@ const Test = React.createClass({ ); } -}) +}); ReactDOM.render(, document.getElementById('components-tabs-demo-add')); ```` diff --git a/components/tabs/demo/icon.md b/components/tabs/demo/icon.md index 9e391b5595..2d14a86119 100644 --- a/components/tabs/demo/icon.md +++ b/components/tabs/demo/icon.md @@ -10,7 +10,7 @@ import { Tabs, Icon } from 'antd'; const TabPane = Tabs.TabPane; -var tabContent = [ +const tabContent = [ 选项卡一, 选项卡二, 选项卡三, diff --git a/components/tree/demo/dynamic.md b/components/tree/demo/dynamic.md index a85694093e..e877bc1d43 100644 --- a/components/tree/demo/dynamic.md +++ b/components/tree/demo/dynamic.md @@ -10,22 +10,23 @@ import { Tree } from 'antd'; const TreeNode = Tree.TreeNode; -const asyncTree = [ - {name: "pNode 01", key: "0-0"}, -]; +const asyncTree = [{ + name: 'pNode 01', + key: '0-0' +}]; const generateTreeNodes = () => { - const arr = [ - {name: "伯约", key: "0-0-0"}, - ]; - return arr; -} + return [{ + name: '伯约', + key: '0-0-0' + }]; +}; const TreeDemo = React.createClass({ timeout(duration = 0) { return new Promise((resolve, reject) => { - setTimeout(resolve.bind(this), duration); - }) + setTimeout(resolve.bind(this), duration); + }); }, getInitialState() { return { @@ -62,19 +63,19 @@ const TreeDemo = React.createClass({ if (item.children) { return {loop(item.children)}; } else { - return ; + return ; } - }) + }); }; const parseTreeNode = data => loop(data); let treeNodes = parseTreeNode(this.state.treeData); return ( - - {treeNodes} - - ) + + {treeNodes} + + ); } -}) +}); ReactDOM.render(, document.getElementById('components-tree-demo-dynamic')); ```` diff --git a/components/tree/demo/special.md b/components/tree/demo/special.md index cd9e2d606e..129a5cf6f5 100644 --- a/components/tree/demo/special.md +++ b/components/tree/demo/special.md @@ -19,45 +19,45 @@ class TreeDemo extends React.Component { this.state = { checkedKeys: [], selectedKeys: [] - } + }; } handleClick() { this.setState({ checkedKeys: ['p11'], selectedKeys: ['p21', 'p11'] - }) + }); } handleCheck(info) { console.log('check: ', info); this.setState({ checkedKeys: ['p21'], selectedKeys: ['p1', 'p21'] - }) + }); } handleSelect(info) { console.log('selected: ', info); this.setState({ checkedKeys: ['p21'], selectedKeys: ['p21'] - }) + }); } render() { return (
    - - - - - - test - sss}/> - - + + + + + + test + sss}/> + - - + + +
    ); } diff --git a/components/upload/demo/fileList.md b/components/upload/demo/fileList.md index a89fc35667..f2651a7fe4 100644 --- a/components/upload/demo/fileList.md +++ b/components/upload/demo/fileList.md @@ -15,17 +15,15 @@ ````jsx import { Upload, Button, Icon } from 'antd'; -const fileList = [{ - uid: -1, - name: 'xxx.png', - status: 'done', - url: 'http://www.baidu.com/xxx.png' -}]; - const MyUpload = React.createClass({ getInitialState() { return { - fileList: fileList + fileList: [{ + uid: -1, + name: 'xxx.png', + status: 'done', + url: 'http://www.baidu.com/xxx.png' + }] }; }, handleChange(info) { @@ -52,9 +50,7 @@ const MyUpload = React.createClass({ return true; }); - this.setState({ - fileList: fileList - }); + this.setState({ fileList }); }, render() { const props = { diff --git a/components/validation/demo/basic.md b/components/validation/demo/basic.md index 61dfceb436..01d671b9ee 100644 --- a/components/validation/demo/basic.md +++ b/components/validation/demo/basic.md @@ -147,7 +147,7 @@ const Demo = React.createClass({ wrapperCol={{span: 12}} validateStatus={this.renderValidateStyle('name')} hasFeedback - help={status.name.isValidating ? "正在校验中.." : status.name.errors ? status.name.errors.join(',') : null} + help={status.name.isValidating ? '正在校验中..' : (status.name.errors && status.name.errors.join(','))} required> @@ -164,7 +164,7 @@ const Demo = React.createClass({ help={status.email.errors ? status.email.errors.join(',') : null} required> - + diff --git a/components/validation/demo/customize.md b/components/validation/demo/customize.md index 878fe4f8f8..3eb88a5414 100644 --- a/components/validation/demo/customize.md +++ b/components/validation/demo/customize.md @@ -40,7 +40,7 @@ const Demo = React.createClass({ handleSubmit(e) { e.preventDefault(); - var validation = this.refs.validation; + const validation = this.refs.validation; validation.validate((valid) => { if (!valid) { console.log('error in form'); @@ -82,9 +82,17 @@ const Demo = React.createClass({ } else { strength = 'H'; } - type === 'pass' ? this.setState({ passBarShow: true, passStrength: strength }) : this.setState({ rePassBarShow: true, rePassStrength: strength }); + if (type === 'pass') { + this.setState({ passBarShow: true, passStrength: strength }); + } else { + this.setState({ rePassBarShow: true, rePassStrength: strength }); + } } else { - type === 'pass' ? this.setState({ passBarShow: false }) : this.setState({ rePassBarShow: false }); + if (type === 'pass') { + this.setState({ passBarShow: false }); + } else { + this.setState({ rePassBarShow: false }); + } } }, diff --git a/components/validation/demo/other-items.md b/components/validation/demo/other-items.md index c2aa3b6239..852c15b1cf 100644 --- a/components/validation/demo/other-items.md +++ b/components/validation/demo/other-items.md @@ -25,10 +25,6 @@ function cx(classNames) { } } -function noop() { - return false; -} - const Demo = React.createClass({ mixins: [Validation.FieldMixin], @@ -119,7 +115,7 @@ const Demo = React.createClass({ help={status.select.errors ? status.select.errors.join(',') : null} required> - @@ -137,7 +133,7 @@ const Demo = React.createClass({ help={status.multiSelect.errors ? status.multiSelect.errors.join(',') : null} required> - @@ -176,7 +172,7 @@ const Demo = React.createClass({ type: 'date', message: '你的生日是什么呢?' }, {validator: this.checkBirthday}]}> - + @@ -189,7 +185,7 @@ const Demo = React.createClass({ help={status.primeNumber.errors ? status.primeNumber.errors.join(',') : null} required> - + From d1d3329674e8b915857e24145a1b8a1a3ed1b752 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 25 Nov 2015 17:47:55 +0800 Subject: [PATCH 55/56] fix boolean attribute lint errors --- .eslintrc | 1 - components/badge/demo/dot.md | 4 ++-- components/badge/index.jsx | 2 +- components/button/demo/loading.md | 6 +++--- components/checkbox/demo/disable.md | 6 +++--- components/collapse/demo/accordion.md | 2 +- components/collapse/demo/mix.md | 2 +- components/datepicker/demo/disabled.md | 2 +- components/datepicker/demo/locale.md | 2 +- components/datepicker/index.jsx | 2 +- components/form/demo/disabled.md | 4 ++-- components/form/demo/form-controls.md | 2 +- components/form/demo/horizontal-form.md | 10 +++++----- components/form/demo/mix.md | 12 ++++++------ components/form/demo/validate.md | 8 ++++---- components/modal/confirm.jsx | 2 +- components/pagination/demo/changer.md | 2 +- components/pagination/demo/jump.md | 2 +- components/queue-anim/demo/form.md | 2 +- components/radio/demo/disable.md | 2 +- components/select/demo/search.md | 2 +- components/table/demo/bordered.md | 4 ++-- components/table/demo/colspan-rowspan.md | 2 +- components/tabs/demo/disabled.md | 2 +- components/timeline/demo/pending.md | 2 +- components/tree/demo/checkbox.md | 2 +- components/tree/demo/special.md | 2 +- 27 files changed, 45 insertions(+), 46 deletions(-) diff --git a/.eslintrc b/.eslintrc index f7926788ce..780aa12746 100644 --- a/.eslintrc +++ b/.eslintrc @@ -31,7 +31,6 @@ "no-undef": 2, "no-unused-vars": [2, { "vars": "all", "args": "none" }], "babel/object-shorthand": 0, - "react/jsx-boolean-value": 0, "react/jsx-no-duplicate-props": 2, "react/sort-comp": 0, "react/wrap-multilines": 0, diff --git a/components/badge/demo/dot.md b/components/badge/demo/dot.md index bb380924b4..22c26a6154 100644 --- a/components/badge/demo/dot.md +++ b/components/badge/demo/dot.md @@ -10,10 +10,10 @@ import { Badge, Icon } from 'antd'; ReactDOM.render(
    - + - + 一个链接
    , document.getElementById('components-badge-demo-dot')); diff --git a/components/badge/index.jsx b/components/badge/index.jsx index 06f1546437..3aaa743053 100644 --- a/components/badge/index.jsx +++ b/components/badge/index.jsx @@ -28,7 +28,7 @@ class AntBadge extends React.Component { + transitionAppear> { hidden ? null : diff --git a/components/button/demo/loading.md b/components/button/demo/loading.md index 588c83ac4f..ea83ce7791 100644 --- a/components/button/demo/loading.md +++ b/components/button/demo/loading.md @@ -22,13 +22,13 @@ const App = React.createClass({ }, render() { return
    - - -
    diff --git a/components/checkbox/demo/disable.md b/components/checkbox/demo/disable.md index 3a7865bf56..d5f40b43c5 100644 --- a/components/checkbox/demo/disable.md +++ b/components/checkbox/demo/disable.md @@ -1,4 +1,4 @@ -# 不可用 + 不可用 - order: 1 @@ -11,8 +11,8 @@ import { Checkbox } from 'antd'; const container = document.getElementById('components-checkbox-demo-disable'); ReactDOM.render(
    - +
    - +
    , container); ```` diff --git a/components/collapse/demo/accordion.md b/components/collapse/demo/accordion.md index 3025a40e11..f55966563f 100644 --- a/components/collapse/demo/accordion.md +++ b/components/collapse/demo/accordion.md @@ -17,7 +17,7 @@ const text = ` `; ReactDOM.render( - +

    {text}

    diff --git a/components/collapse/demo/mix.md b/components/collapse/demo/mix.md index aee70adecc..494a4619f0 100644 --- a/components/collapse/demo/mix.md +++ b/components/collapse/demo/mix.md @@ -21,7 +21,7 @@ const text = ` `; ReactDOM.render( - + diff --git a/components/datepicker/demo/disabled.md b/components/datepicker/demo/disabled.md index 390158066a..e482822244 100644 --- a/components/datepicker/demo/disabled.md +++ b/components/datepicker/demo/disabled.md @@ -10,6 +10,6 @@ import { Datepicker } from 'antd'; ReactDOM.render( - + , document.getElementById('components-datepicker-demo-disabled')); ```` diff --git a/components/datepicker/demo/locale.md b/components/datepicker/demo/locale.md index 6d4ba4caca..6d18da5f11 100644 --- a/components/datepicker/demo/locale.md +++ b/components/datepicker/demo/locale.md @@ -22,7 +22,7 @@ const App = React.createClass({ }; }, render() { - return ; + return ; } }); diff --git a/components/datepicker/index.jsx b/components/datepicker/index.jsx index 81d2d7d759..3cbc77446f 100644 --- a/components/datepicker/index.jsx +++ b/components/datepicker/index.jsx @@ -105,7 +105,7 @@ function createPicker(TheCalendar) { showTime={this.props.showTime} prefixCls="ant-calendar" showOk={this.props.showTime} - showClear={true}/> + showClear /> ); let sizeClass = ''; diff --git a/components/form/demo/disabled.md b/components/form/demo/disabled.md index b77845001a..8bff67eda1 100644 --- a/components/form/demo/disabled.md +++ b/components/form/demo/disabled.md @@ -28,7 +28,7 @@ ReactDOM.render( label="用户名:" labelCol={{span:5}} wrapperCol={{span:12}} - required={true} > + required>

    大眼萌 minion

    + required> diff --git a/components/form/demo/form-controls.md b/components/form/demo/form-controls.md index 5dbcd2e4b9..e763876701 100644 --- a/components/form/demo/form-controls.md +++ b/components/form/demo/form-controls.md @@ -60,7 +60,7 @@ ReactDOM.render( 选项二 diff --git a/components/form/demo/horizontal-form.md b/components/form/demo/horizontal-form.md index 73d50f84f4..820a8c88a1 100644 --- a/components/form/demo/horizontal-form.md +++ b/components/form/demo/horizontal-form.md @@ -46,7 +46,7 @@ const Demo = React.createClass({ label="用户名:" labelCol={{span: 6}} wrapperCol={{span: 6}} - required={true} > + required>

    大眼萌 minion

    + required> + required> 男的 女的 @@ -72,8 +72,8 @@ const Demo = React.createClass({ label="备注:" labelCol={{span: 6}} wrapperCol={{span: 14}} - required={true} - help="随便写点什么" > + required + help="随便写点什么"> + required> 台机器 @@ -55,7 +55,7 @@ const Demo = React.createClass({ label="我是标题:" labelCol={{span: 8}} wrapperCol={{span: 10}} - required={true} > + required>

    唧唧复唧唧木兰当户织呀

    链接文字 @@ -66,7 +66,7 @@ const Demo = React.createClass({ label="Switch 开关:" labelCol={{span: 8}} wrapperCol={{span: 10}} - required={true} > + required> @@ -74,7 +74,7 @@ const Demo = React.createClass({ label="Slider 滑动输入条:" labelCol={{span: 8}} wrapperCol={{span: 10}} - required={true}> + required> @@ -82,7 +82,7 @@ const Demo = React.createClass({ label="Select 选择器:" labelCol={{span: 8}} wrapperCol={{span: 16}} - required={true}> + required> @@ -49,7 +49,7 @@ ReactDOM.render( label="成功校验:" labelCol={{span: 5}} wrapperCol={{span: 12}} - hasFeedback={true} + hasFeedback validateStatus="success"> @@ -58,7 +58,7 @@ ReactDOM.render( label="警告校验:" labelCol={{span: 5}} wrapperCol={{span: 12}} - hasFeedback={true} + hasFeedback validateStatus="warning"> @@ -67,7 +67,7 @@ ReactDOM.render( label="失败校验:" labelCol={{span: 5}} wrapperCol={{span: 12}} - hasFeedback={true} + hasFeedback validateStatus="error" help="请输入数字和字母组合"> diff --git a/components/modal/confirm.jsx b/components/modal/confirm.jsx index 62004b8b13..0a065099e7 100644 --- a/components/modal/confirm.jsx +++ b/components/modal/confirm.jsx @@ -91,7 +91,7 @@ export default function (props) { ReactDOM.render(

    , + , document.getElementById('components-pagination-demo-changer')); ```` diff --git a/components/pagination/demo/jump.md b/components/pagination/demo/jump.md index a33b1bc998..24882baddb 100644 --- a/components/pagination/demo/jump.md +++ b/components/pagination/demo/jump.md @@ -14,6 +14,6 @@ function onChange(page) { } ReactDOM.render( - , + , document.getElementById('components-pagination-demo-jump')); ```` diff --git a/components/queue-anim/demo/form.md b/components/queue-anim/demo/form.md index 2c03d927ff..6f415ae261 100644 --- a/components/queue-anim/demo/form.md +++ b/components/queue-anim/demo/form.md @@ -27,7 +27,7 @@ const Test = React.createClass({

    - + {this.state.show ? [
    diff --git a/components/radio/demo/disable.md b/components/radio/demo/disable.md index fa2c8f8013..af4f90b8d3 100644 --- a/components/radio/demo/disable.md +++ b/components/radio/demo/disable.md @@ -24,7 +24,7 @@ const App = React.createClass({ return
    不可用
    - 不可用 + 不可用
    +ReactDOM.render(
    , document.getElementById('components-table-demo-bordered')); ```` diff --git a/components/table/demo/colspan-rowspan.md b/components/table/demo/colspan-rowspan.md index b967f2dafe..9fc13ca753 100644 --- a/components/table/demo/colspan-rowspan.md +++ b/components/table/demo/colspan-rowspan.md @@ -115,6 +115,6 @@ const data = [{ address: '西湖区湖底公园1号' }]; -ReactDOM.render(
    +ReactDOM.render(
    , document.getElementById('components-table-demo-colspan-rowspan')); ```` diff --git a/components/tabs/demo/disabled.md b/components/tabs/demo/disabled.md index 127941cae0..0a181fe367 100644 --- a/components/tabs/demo/disabled.md +++ b/components/tabs/demo/disabled.md @@ -15,7 +15,7 @@ function callback(key) {} ReactDOM.render( 选项卡一 - 选项卡二 + 选项卡二 选项卡三 , document.getElementById('components-tabs-demo-disabled')); diff --git a/components/timeline/demo/pending.md b/components/timeline/demo/pending.md index 66038da972..a777df607b 100644 --- a/components/timeline/demo/pending.md +++ b/components/timeline/demo/pending.md @@ -11,7 +11,7 @@ import { Timeline } from 'antd'; const container = document.getElementById('components-timeline-demo-pending'); ReactDOM.render( - + 创建服务现场 2015-09-01 初步排除网络异常 2015-09-01 技术测试异常 2015-09-01 diff --git a/components/tree/demo/checkbox.md b/components/tree/demo/checkbox.md index 76c82e9438..1015859dfb 100644 --- a/components/tree/demo/checkbox.md +++ b/components/tree/demo/checkbox.md @@ -15,7 +15,7 @@ function handleCheck(info) { } ReactDOM.render(
    - + diff --git a/components/tree/demo/special.md b/components/tree/demo/special.md index 129a5cf6f5..d6892c7b2b 100644 --- a/components/tree/demo/special.md +++ b/components/tree/demo/special.md @@ -43,7 +43,7 @@ class TreeDemo extends React.Component { } render() { return (
    - From e6baea33a663fd0685c4e0a757a4f3b7177c1213 Mon Sep 17 00:00:00 2001 From: Benjy Cui Date: Wed, 25 Nov 2015 18:19:45 +0800 Subject: [PATCH 56/56] fix: import CSS instead of LESS --- scripts/prenpm.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/prenpm.js b/scripts/prenpm.js index d5762460b8..ca97b8f68a 100644 --- a/scripts/prenpm.js +++ b/scripts/prenpm.js @@ -7,7 +7,7 @@ var originalIndex = fs.readFileSync(path.join(cwd, 'lib/index.js'), 'utf-8'); var newIndex = originalIndex .replace(/\/components\//g, '/') .replace(/require\(\'\.\/package.json\'\)/g, "require('./package')") - .replace("require('./style/index.less')", "require('../style/index.less')"); + .replace("require('./style/index.less')", "require('./index.css')"); fs.writeFileSync(path.join(cwd, 'lib/index.js'), newIndex, 'utf-8'); fs.writeFileSync( path.join(cwd, 'lib/package.js'),