mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 02:59:58 +08:00
upgrade calendar/timePicker. Fixes #822
This commit is contained in:
parent
7aad7ba116
commit
fd1312803f
@ -10,7 +10,8 @@ const AntTimePicker = React.createClass({
|
||||
return {
|
||||
format: 'HH:mm:ss',
|
||||
prefixCls: 'ant-time-picker',
|
||||
onChange() {},
|
||||
onChange() {
|
||||
},
|
||||
locale: {},
|
||||
align: {
|
||||
offset: [0, -2],
|
||||
@ -49,7 +50,7 @@ const AntTimePicker = React.createClass({
|
||||
parseTimeFromValue(value) {
|
||||
if (value) {
|
||||
return this.getFormatter().parse(value, {
|
||||
locale: this.getLocale(),
|
||||
locale: this.getLocale().calendar,
|
||||
obeyCount: true,
|
||||
});
|
||||
}
|
||||
@ -62,15 +63,13 @@ const AntTimePicker = React.createClass({
|
||||
|
||||
getLocale() {
|
||||
// 统一合并为完整的 Locale
|
||||
let locale = objectAssign({}, defaultLocale, this.props.locale);
|
||||
locale.lang = objectAssign({}, defaultLocale.lang, this.props.locale.lang);
|
||||
return locale;
|
||||
return objectAssign({}, defaultLocale, this.props.locale);
|
||||
},
|
||||
|
||||
render() {
|
||||
const props = objectAssign({}, this.props);
|
||||
props.placeholder = ('placeholder' in this.props)
|
||||
? props.placeholder : this.getLocale().lang.placeholder;
|
||||
? props.placeholder : this.getLocale().placeholder;
|
||||
if (props.defaultValue) {
|
||||
props.defaultValue = this.parseTimeFromValue(props.defaultValue);
|
||||
} else {
|
||||
@ -96,7 +95,7 @@ const AntTimePicker = React.createClass({
|
||||
<TimePicker
|
||||
{...props}
|
||||
className={className}
|
||||
gregorianCalendarLocale={this.getLocale()}
|
||||
locale={this.getLocale()}
|
||||
formatter={this.getFormatter()}
|
||||
onChange={this.handleChange}
|
||||
/>
|
||||
|
@ -1,14 +1,8 @@
|
||||
import objectAssign from 'object-assign';
|
||||
import GregorianCalendarLocale from 'gregorian-calendar/lib/locale/en_US';
|
||||
import TimepickerLocale from 'rc-time-picker/lib/locale/en_US';
|
||||
|
||||
// 统一合并为完整的 Locale
|
||||
let locale = objectAssign({}, GregorianCalendarLocale);
|
||||
locale.lang = objectAssign({
|
||||
placeholder: 'Select a time'
|
||||
}, TimepickerLocale);
|
||||
|
||||
// All settings at:
|
||||
// https://github.com/ant-design/ant-design/issues/424
|
||||
const locale = {
|
||||
placeholder: 'Select a time',
|
||||
... TimepickerLocale,
|
||||
};
|
||||
|
||||
export default locale;
|
||||
|
@ -1,14 +1,8 @@
|
||||
import objectAssign from 'object-assign';
|
||||
import GregorianCalendarLocale from 'gregorian-calendar/lib/locale/zh_CN';
|
||||
import TimepickerLocale from 'rc-time-picker/lib/locale/zh_CN';
|
||||
|
||||
// 统一合并为完整的 Locale
|
||||
let locale = objectAssign({}, GregorianCalendarLocale);
|
||||
locale.lang = objectAssign({
|
||||
placeholder: '请选择时间'
|
||||
}, TimepickerLocale);
|
||||
|
||||
// All settings at:
|
||||
// https://github.com/ant-design/ant-design/issues/424
|
||||
const locale = {
|
||||
placeholder: '请选择时间',
|
||||
... TimepickerLocale,
|
||||
};
|
||||
|
||||
export default locale;
|
||||
|
@ -59,10 +59,10 @@
|
||||
"rc-switch": "~1.3.1",
|
||||
"rc-table": "~3.8.0",
|
||||
"rc-tabs": "~5.6.0",
|
||||
"rc-time-picker": "~1.0.0",
|
||||
"rc-time-picker": "~1.1.0",
|
||||
"rc-tooltip": "~3.3.0",
|
||||
"rc-tree": "~0.26.1",
|
||||
"rc-tree-select": "^0.3.3",
|
||||
"rc-tree-select": "~0.3.3",
|
||||
"rc-trigger": "~1.0.6",
|
||||
"rc-upload": "~1.7.0",
|
||||
"rc-util": "~3.0.1",
|
||||
|
Loading…
Reference in New Issue
Block a user