aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/module/Panel.jsx
diff options
context:
space:
mode:
authoryiminghe <yiminghe@gmail.com>2016-08-04 19:53:55 +0800
committeryiminghe <yiminghe@gmail.com>2016-08-04 19:53:55 +0800
commit4984ed85e54f442998a335db70618d6184fa397e (patch)
tree6ae348b2cac5f48f3afb6f7b8dd0c2fd02f044fc /src/module/Panel.jsx
parentdeaa6062ea2e274d50d58c70251c1237c0c03c67 (diff)
downloadtime-picker-4984ed85e54f442998a335db70618d6184fa397e.tar.gz
time-picker-4984ed85e54f442998a335db70618d6184fa397e.tar.zst
time-picker-4984ed85e54f442998a335db70618d6184fa397e.zip
2.x :boom:2.0.0
Diffstat (limited to 'src/module/Panel.jsx')
-rw-r--r--src/module/Panel.jsx130
1 files changed, 0 insertions, 130 deletions
diff --git a/src/module/Panel.jsx b/src/module/Panel.jsx
deleted file mode 100644
index 137ec2f..0000000
--- a/src/module/Panel.jsx
+++ /dev/null
@@ -1,130 +0,0 @@
1import React, {PropTypes} from 'react';
2import CommonMixin from '../mixin/CommonMixin';
3import Header from './Header';
4import Combobox from './Combobox';
5
6function noop() {
7}
8
9function generateOptions(length, disabledOptions, hideDisabledOptions) {
10 const arr = [];
11 for (let value = 0; value < length; value++) {
12 if (!disabledOptions || disabledOptions.indexOf(value) < 0 || !hideDisabledOptions) {
13 arr.push(value);
14 }
15 }
16 return arr;
17}
18
19const Panel = React.createClass({
20 propTypes: {
21 prefixCls: PropTypes.string,
22 value: PropTypes.object,
23 locale: PropTypes.object,
24 placeholder: PropTypes.string,
25 gregorianCalendarLocale: PropTypes.object,
26 formatter: PropTypes.object,
27 disabledHours: PropTypes.func,
28 disabledMinutes: PropTypes.func,
29 disabledSeconds: PropTypes.func,
30 hideDisabledOptions: PropTypes.bool,
31 onChange: PropTypes.func,
32 onEsc: PropTypes.func,
33 allowEmpty: PropTypes.bool,
34 showHour: PropTypes.bool,
35 showSecond: PropTypes.bool,
36 onClear: PropTypes.func,
37 },
38
39 mixins: [CommonMixin],
40
41 getDefaultProps() {
42 return {
43 prefixCls: 'rc-time-picker-panel',
44 onChange: noop,
45 onClear: noop,
46 };
47 },
48
49 getInitialState() {
50 return {
51 value: this.props.value,
52 selectionRange: [],
53 };
54 },
55
56 componentWillReceiveProps(nextProps) {
57 const value = nextProps.value;
58 if (value) {
59 this.setState({
60 value,
61 });
62 }
63 },
64
65 onChange(newValue) {
66 this.setState({ value: newValue });
67 this.props.onChange(newValue);
68 },
69
70 onClear() {
71 this.props.onClear();
72 },
73
74 onCurrentSelectPanelChange(currentSelectPanel) {
75 this.setState({ currentSelectPanel });
76 },
77
78 render() {
79 const { locale, prefixCls, placeholder, disabledHours, disabledMinutes, disabledSeconds, hideDisabledOptions, allowEmpty, showHour, showSecond, formatter, gregorianCalendarLocale } = this.props;
80 const value = this.state.value;
81 const disabledHourOptions = disabledHours();
82 const disabledMinuteOptions = disabledMinutes(value ? value.getHourOfDay() : null);
83 const disabledSecondOptions = disabledSeconds(value ? value.getHourOfDay() : null, value ? value.getMinutes() : null);
84 const hourOptions = generateOptions(24, disabledHourOptions, hideDisabledOptions);
85 const minuteOptions = generateOptions(60, disabledMinuteOptions, hideDisabledOptions);
86 const secondOptions = generateOptions(60, disabledSecondOptions, hideDisabledOptions);
87
88 return (
89 <div className={`${prefixCls}-inner`}>
90 <Header
91 prefixCls={prefixCls}
92 gregorianCalendarLocale={gregorianCalendarLocale}
93 locale={locale}
94 value={value}
95 currentSelectPanel={this.state.currentSelectPanel}
96 onEsc={this.props.onEsc}
97 formatter={formatter}
98 placeholder={placeholder}
99 hourOptions={hourOptions}
100 minuteOptions={minuteOptions}
101 secondOptions={secondOptions}
102 disabledHours={disabledHours}
103 disabledMinutes={disabledMinutes}
104 disabledSeconds={disabledSeconds}
105 onChange={this.onChange}
106 onClear={this.onClear}
107 allowEmpty={allowEmpty}
108 />
109 <Combobox
110 prefixCls={prefixCls}
111 value={value}
112 gregorianCalendarLocale={gregorianCalendarLocale}
113 formatter={formatter}
114 onChange={this.onChange}
115 showHour={showHour}
116 showSecond={showSecond}
117 hourOptions={hourOptions}
118 minuteOptions={minuteOptions}
119 secondOptions={secondOptions}
120 disabledHours={disabledHours}
121 disabledMinutes={disabledMinutes}
122 disabledSeconds={disabledSeconds}
123 onCurrentSelectPanelChange={this.onCurrentSelectPanelChange}
124 />
125 </div>
126 );
127 },
128});
129
130export default Panel;