diff options
author | MG12 <wuzhao.mail@gmail.com> | 2015-11-16 14:44:26 +0800 |
---|---|---|
committer | MG12 <wuzhao.mail@gmail.com> | 2015-11-16 14:44:26 +0800 |
commit | 78637ac02ce6a469d2021736d3cb12e98c5edbe7 (patch) | |
tree | 68de02afaa15b90be1fcc1dd191edb6f48ebb293 /src | |
parent | 02de449a0474765a4796fa607e7e3922252f574f (diff) | |
download | time-picker-78637ac02ce6a469d2021736d3cb12e98c5edbe7.tar.gz time-picker-78637ac02ce6a469d2021736d3cb12e98c5edbe7.tar.zst time-picker-78637ac02ce6a469d2021736d3cb12e98c5edbe7.zip |
remove toggle feature because rc-trigger included; update example and document0.2.0
Diffstat (limited to 'src')
-rw-r--r-- | src/TimePanel.jsx | 2 | ||||
-rw-r--r-- | src/TimePicker.jsx (renamed from src/Picker.jsx) | 18 | ||||
-rw-r--r-- | src/index.js | 2 | ||||
-rw-r--r-- | src/mixin/CommonMixin.js | 2 | ||||
-rw-r--r-- | src/module/Header.jsx | 20 |
5 files changed, 8 insertions, 36 deletions
diff --git a/src/TimePanel.jsx b/src/TimePanel.jsx index dad8036..110ca1e 100644 --- a/src/TimePanel.jsx +++ b/src/TimePanel.jsx | |||
@@ -90,7 +90,7 @@ const TimePanel = React.createClass({ | |||
90 | <div className={`${prefixCls}-panel ${cls}`}> | 90 | <div className={`${prefixCls}-panel ${cls}`}> |
91 | <Header | 91 | <Header |
92 | prefixCls={prefixCls} | 92 | prefixCls={prefixCls} |
93 | gregorianTimepickerLocale={defaultValue.locale} | 93 | gregorianTimePickerLocale={defaultValue.locale} |
94 | locale={locale} | 94 | locale={locale} |
95 | value={value} | 95 | value={value} |
96 | formatter={this.getFormatter()} | 96 | formatter={this.getFormatter()} |
diff --git a/src/Picker.jsx b/src/TimePicker.jsx index f15434a..6bb97a1 100644 --- a/src/Picker.jsx +++ b/src/TimePicker.jsx | |||
@@ -47,10 +47,6 @@ const Picker = React.createClass({ | |||
47 | return { open, value }; | 47 | return { open, value }; |
48 | }, | 48 | }, |
49 | 49 | ||
50 | componentWillMount() { | ||
51 | document.addEventListener('click', this.handleDocumentClick, false); | ||
52 | }, | ||
53 | |||
54 | componentWillReceiveProps(nextProps) { | 50 | componentWillReceiveProps(nextProps) { |
55 | const { value, open } = nextProps; | 51 | const { value, open } = nextProps; |
56 | if (value !== undefined) { | 52 | if (value !== undefined) { |
@@ -61,10 +57,6 @@ const Picker = React.createClass({ | |||
61 | } | 57 | } |
62 | }, | 58 | }, |
63 | 59 | ||
64 | componentWillUnmount() { | ||
65 | document.removeEventListener('click', this.handleDocumentClick, false); | ||
66 | }, | ||
67 | |||
68 | onPanelChange(value) { | 60 | onPanelChange(value) { |
69 | const props = this.props; | 61 | const props = this.props; |
70 | this.setState({ | 62 | this.setState({ |
@@ -114,16 +106,6 @@ const Picker = React.createClass({ | |||
114 | } | 106 | } |
115 | }, | 107 | }, |
116 | 108 | ||
117 | handleDocumentClick(event) { | ||
118 | // hide popup when click outside | ||
119 | if (this.state.open && ReactDOM.findDOMNode(this.panelInstance).contains(event.target)) { | ||
120 | return; | ||
121 | } | ||
122 | this.setState({ | ||
123 | open: false, | ||
124 | }); | ||
125 | }, | ||
126 | |||
127 | focus() { | 109 | focus() { |
128 | if (!this.state.open) { | 110 | if (!this.state.open) { |
129 | ReactDOM.findDOMNode(this).focus(); | 111 | ReactDOM.findDOMNode(this).focus(); |
diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..f72be4f --- /dev/null +++ b/src/index.js | |||
@@ -0,0 +1,2 @@ | |||
1 | import TimePicker from './TimePicker'; | ||
2 | export default TimePicker; | ||
diff --git a/src/mixin/CommonMixin.js b/src/mixin/CommonMixin.js index 4203a9e..0e8ed32 100644 --- a/src/mixin/CommonMixin.js +++ b/src/mixin/CommonMixin.js | |||
@@ -10,7 +10,7 @@ export default { | |||
10 | 10 | ||
11 | getDefaultProps() { | 11 | getDefaultProps() { |
12 | return { | 12 | return { |
13 | prefixCls: 'rc-timepicker', | 13 | prefixCls: 'rc-time-picker', |
14 | locale: enUs, | 14 | locale: enUs, |
15 | }; | 15 | }; |
16 | }, | 16 | }, |
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 ( |