aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/module/Combobox.jsx
diff options
context:
space:
mode:
authoryiminghe <yiminghe@gmail.com>2015-11-27 16:15:05 +0800
committeryiminghe <yiminghe@gmail.com>2015-11-27 16:15:05 +0800
commit8133e8cf3b37b2be764616493ade7c7a7678fce1 (patch)
tree4321352889ab62f18ff8703adac8756ddb506dc0 /src/module/Combobox.jsx
parent7702bb67968104a64fa85ba7e893bf2393eeb3c5 (diff)
downloadtime-picker-8133e8cf3b37b2be764616493ade7c7a7678fce1.tar.gz
time-picker-8133e8cf3b37b2be764616493ade7c7a7678fce1.tar.zst
time-picker-8133e8cf3b37b2be764616493ade7c7a7678fce1.zip
add gregorianCalendarLocale prop1.0.0-alpha1
Diffstat (limited to 'src/module/Combobox.jsx')
-rw-r--r--src/module/Combobox.jsx24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/module/Combobox.jsx b/src/module/Combobox.jsx
index afce675..3dfd321 100644
--- a/src/module/Combobox.jsx
+++ b/src/module/Combobox.jsx
@@ -1,5 +1,6 @@
1import React, {PropTypes} from 'react'; 1import React, {PropTypes} from 'react';
2import Select from './Select'; 2import Select from './Select';
3import GregorianCalendar from 'gregorian-calendar';
3 4
4const formatOption = (option) => { 5const formatOption = (option) => {
5 if (option < 10) { 6 if (option < 10) {
@@ -15,6 +16,7 @@ const Combobox = React.createClass({
15 value: PropTypes.object, 16 value: PropTypes.object,
16 onChange: PropTypes.func, 17 onChange: PropTypes.func,
17 showHour: PropTypes.bool, 18 showHour: PropTypes.bool,
19 gregorianCalendarLocale: PropTypes.object,
18 showSecond: PropTypes.bool, 20 showSecond: PropTypes.bool,
19 hourOptions: PropTypes.array, 21 hourOptions: PropTypes.array,
20 minuteOptions: PropTypes.array, 22 minuteOptions: PropTypes.array,
@@ -22,7 +24,13 @@ const Combobox = React.createClass({
22 }, 24 },
23 25
24 onItemChange(type, itemValue) { 26 onItemChange(type, itemValue) {
25 const { value, onChange } = this.props; 27 const { onChange } = this.props;
28 let value = this.props.value;
29 if (value) {
30 value = value.clone();
31 } else {
32 value = this.getNow().clone();
33 }
26 if (type === 'hour') { 34 if (type === 'hour') {
27 value.setHourOfDay(itemValue); 35 value.setHourOfDay(itemValue);
28 } else if (type === 'minute') { 36 } else if (type === 'minute') {
@@ -78,9 +86,19 @@ const Combobox = React.createClass({
78 ); 86 );
79 }, 87 },
80 88
81 render() { 89 getNow() {
82 const { prefixCls, value } = this.props; 90 if (this.showNow) {
91 return this.showNow;
92 }
93 const value = new GregorianCalendar(this.props.gregorianCalendarLocale);
94 value.setTime(Date.now());
95 this.showNow = value;
96 return value;
97 },
83 98
99 render() {
100 const { prefixCls } = this.props;
101 const value = this.props.value || this.getNow();
84 return ( 102 return (
85 <div className={`${prefixCls}-combobox`}> 103 <div className={`${prefixCls}-combobox`}>
86 {this.getHourSelect(value.getHourOfDay())} 104 {this.getHourSelect(value.getHourOfDay())}