Browse Source

compatible with rc-form

pull/911/head
yiminghe 9 years ago
parent
commit
dc3b34510b
  1. 5
      components/checkbox/Group.jsx
  2. 4
      components/date-picker/PickerMixin.jsx
  3. 19
      components/time-picker/index.jsx
  4. 7
      package.json
  5. 1
      scripts/demo.js

5
components/checkbox/Group.jsx

@ -5,6 +5,7 @@ export default React.createClass({
getDefaultProps() {
return {
options: [],
defaultValue: [],
onChange() {},
};
},
@ -17,13 +18,13 @@ export default React.createClass({
getInitialState() {
const { value, defaultValue } = this.props;
return {
value: value || defaultValue || [],
value: value || defaultValue,
};
},
componentWillReceiveProps(nextProps) {
if ('value' in nextProps) {
this.setState({
value: nextProps.value,
value: nextProps.value || [],
});
}
},

4
components/date-picker/PickerMixin.jsx

@ -30,10 +30,8 @@ export default {
date.setTime(+value);
return date;
}
} else if (value === null) {
return value;
}
return undefined;
return value;
},
// remove input readonly warning

19
components/time-picker/index.jsx

@ -4,6 +4,7 @@ import TimePicker from 'rc-time-picker/lib/TimePicker';
import objectAssign from 'object-assign';
import defaultLocale from './locale/zh_CN';
import classNames from 'classnames';
import GregorianCalendar from 'gregorian-calendar';
const AntTimePicker = React.createClass({
getDefaultProps() {
@ -49,12 +50,18 @@ const AntTimePicker = React.createClass({
*/
parseTimeFromValue(value) {
if (value) {
return this.getFormatter().parse(value, {
locale: this.getLocale().calendar,
obeyCount: true,
});
if (typeof value === 'string') {
return this.getFormatter().parse(value, {
locale: this.getLocale().calendar,
obeyCount: true,
});
} else if (value instanceof Date) {
let date = new GregorianCalendar(this.getLocale().calendar);
date.setTime(+value);
return date;
}
}
return undefined;
return value;
},
handleChange(value) {
@ -77,8 +84,6 @@ const AntTimePicker = React.createClass({
}
if (props.value) {
props.value = this.parseTimeFromValue(props.value);
} else {
delete props.value;
}
let className = classNames({
[props.className]: !!props.className,

7
package.json

@ -1,6 +1,6 @@
{
"name": "antd",
"version": "0.12.0-beta8",
"version": "0.12.0-beta9",
"title": "Ant Design",
"description": "一个 UI 设计语言",
"homepage": "http://ant.design/",
@ -73,8 +73,6 @@
"warning": "~2.1.0"
},
"devDependencies": {
"rc-scroll-anim": "0.0.5",
"rc-tween-one": "0.1.5",
"autoprefixer-loader": "^3.1.0",
"babel-cli": "^6.2.0",
"babel-core": "^6.2.1",
@ -104,6 +102,9 @@
"lodash": "^3.10.0",
"nico-jsx": "~0.7.0",
"pre-commit": "1.x",
"rc-form": "^0.8.0",
"rc-scroll-anim": "0.0.5",
"rc-tween-one": "0.1.5",
"react": "0.14.x",
"react-addons-test-utils": "0.14.x",
"react-copy-to-clipboard": "^3.0.4",

1
scripts/demo.js

@ -25,6 +25,7 @@ window.require = function (path) {
require('../style/index.less');
window['css-animation'] = require('css-animation');
window['react-router'] = require('react-router');
window['rc-form'] = require('rc-form');
window.CopyToClipboard = require('react-copy-to-clipboard');
var antd = require('../index');
var React = require('react');

Loading…
Cancel
Save