aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/module/Header.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/module/Header.jsx')
-rw-r--r--src/module/Header.jsx20
1 files changed, 4 insertions, 16 deletions
diff --git a/src/module/Header.jsx b/src/module/Header.jsx
index f7e443f..92a0089 100644
--- a/src/module/Header.jsx
+++ b/src/module/Header.jsx
@@ -4,7 +4,7 @@ const Header = React.createClass({
4 propTypes: { 4 propTypes: {
5 formatter: PropTypes.object, 5 formatter: PropTypes.object,
6 prefixCls: PropTypes.string, 6 prefixCls: PropTypes.string,
7 gregorianTimepickerLocale: PropTypes.object, 7 gregorianTimePickerLocale: PropTypes.object,
8 locale: PropTypes.object, 8 locale: PropTypes.object,
9 disabledDate: PropTypes.func, 9 disabledDate: PropTypes.func,
10 placeholder: PropTypes.string, 10 placeholder: PropTypes.string,
@@ -26,7 +26,7 @@ const Header = React.createClass({
26 }, 26 },
27 27
28 componentWillReceiveProps(nextProps) { 28 componentWillReceiveProps(nextProps) {
29 const value = this.formatValue(nextProps.value); 29 const value = nextProps.value;
30 this.setState({ 30 this.setState({
31 str: value && nextProps.formatter.format(value) || '', 31 str: value && nextProps.formatter.format(value) || '',
32 invalid: false, 32 invalid: false,
@@ -39,16 +39,15 @@ const Header = React.createClass({
39 str, 39 str,
40 }); 40 });
41 let value = null; 41 let value = null;
42 const {formatter, gregorianTimepickerLocale, hourOptions, minuteOptions, secondOptions, onChange} = this.props; 42 const {formatter, gregorianTimePickerLocale, hourOptions, minuteOptions, secondOptions, onChange} = this.props;
43 43
44 if (str) { 44 if (str) {
45 const originalValue = this.props.value; 45 const originalValue = this.props.value;
46 try { 46 try {
47 value = formatter.parse(str, { 47 value = formatter.parse(str, {
48 locale: gregorianTimepickerLocale, 48 locale: gregorianTimePickerLocale,
49 obeyCount: true, 49 obeyCount: true,
50 }); 50 });
51 value = this.formatValue(value);
52 } catch (ex) { 51 } catch (ex) {
53 this.setState({ 52 this.setState({
54 invalid: true, 53 invalid: true,
@@ -114,17 +113,6 @@ const Header = React.createClass({
114 return <input className={`${prefixCls}-input ${invalidClass}`} value={str} placeholder={placeholder} onChange={this.onInputChange} />; 113 return <input className={`${prefixCls}-input ${invalidClass}`} value={str} placeholder={placeholder} onChange={this.onInputChange} />;
115 }, 114 },
116 115
117 formatValue(value) {
118 const newValue = this.props.value.clone();
119 if (!value) {
120 return newValue;
121 }
122 newValue.fields[4] = value.fields[4];
123 newValue.fields[5] = value.fields[5];
124 newValue.fields[6] = value.fields[6];
125 return newValue;
126 },
127
128 render() { 116 render() {
129 const { prefixCls } = this.props; 117 const { prefixCls } = this.props;
130 return ( 118 return (