aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorWei Zhu <yesmeck@gmail.com>2018-02-01 14:20:33 +0800
committerWei Zhu <yesmeck@gmail.com>2018-02-01 14:20:33 +0800
commitc50a40056d80c52f328566d51cc49cbcdc5f0a95 (patch)
tree571e224e324c18164323917778c1a202c7c36068
parent73a24157501c8d75aac94b3f6c913c754d46e94f (diff)
parent4e70ea0da45e572cd660f79ac98b6a25c640cb36 (diff)
downloadtime-picker-c50a40056d80c52f328566d51cc49cbcdc5f0a95.tar.gz
time-picker-c50a40056d80c52f328566d51cc49cbcdc5f0a95.tar.zst
time-picker-c50a40056d80c52f328566d51cc49cbcdc5f0a95.zip
Merge branch 'abyr-readonly_header_input'
-rw-r--r--examples/12hours.js1
-rw-r--r--src/Header.jsx8
-rw-r--r--src/Panel.jsx5
-rw-r--r--src/TimePicker.jsx5
4 files changed, 16 insertions, 3 deletions
diff --git a/examples/12hours.js b/examples/12hours.js
index 72d6950..6281210 100644
--- a/examples/12hours.js
+++ b/examples/12hours.js
@@ -25,6 +25,7 @@ ReactDom.render(
25 onChange={onChange} 25 onChange={onChange}
26 format={format} 26 format={format}
27 use12Hours 27 use12Hours
28 inputReadOnly
28 />, 29 />,
29 document.getElementById('__react-content') 30 document.getElementById('__react-content')
30); 31);
diff --git a/src/Header.jsx b/src/Header.jsx
index 1520d25..21d557e 100644
--- a/src/Header.jsx
+++ b/src/Header.jsx
@@ -10,6 +10,7 @@ class Header extends Component {
10 placeholder: PropTypes.string, 10 placeholder: PropTypes.string,
11 clearText: PropTypes.string, 11 clearText: PropTypes.string,
12 value: PropTypes.object, 12 value: PropTypes.object,
13 inputReadOnly: PropTypes.bool,
13 hourOptions: PropTypes.array, 14 hourOptions: PropTypes.array,
14 minuteOptions: PropTypes.array, 15 minuteOptions: PropTypes.array,
15 secondOptions: PropTypes.array, 16 secondOptions: PropTypes.array,
@@ -26,6 +27,10 @@ class Header extends Component {
26 onKeyDown: PropTypes.func, 27 onKeyDown: PropTypes.func,
27 }; 28 };
28 29
30 static defaultProps = {
31 inputReadOnly: false,
32 }
33
29 constructor(props) { 34 constructor(props) {
30 super(props); 35 super(props);
31 const { value, format } = props; 36 const { value, format } = props;
@@ -166,7 +171,7 @@ class Header extends Component {
166 } 171 }
167 172
168 getInput() { 173 getInput() {
169 const { prefixCls, placeholder } = this.props; 174 const { prefixCls, placeholder, inputReadOnly } = this.props;
170 const { invalid, str } = this.state; 175 const { invalid, str } = this.state;
171 const invalidClass = invalid ? `${prefixCls}-input-invalid` : ''; 176 const invalidClass = invalid ? `${prefixCls}-input-invalid` : '';
172 return ( 177 return (
@@ -177,6 +182,7 @@ class Header extends Component {
177 value={str} 182 value={str}
178 placeholder={placeholder} 183 placeholder={placeholder}
179 onChange={this.onInputChange} 184 onChange={this.onInputChange}
185 readOnly={!!inputReadOnly}
180 /> 186 />
181 ); 187 );
182 } 188 }
diff --git a/src/Panel.jsx b/src/Panel.jsx
index a1b7c77..1adb19a 100644
--- a/src/Panel.jsx
+++ b/src/Panel.jsx
@@ -27,6 +27,7 @@ class Panel extends Component {
27 value: PropTypes.object, 27 value: PropTypes.object,
28 placeholder: PropTypes.string, 28 placeholder: PropTypes.string,
29 format: PropTypes.string, 29 format: PropTypes.string,
30 inputReadOnly: PropTypes.bool,
30 disabledHours: PropTypes.func, 31 disabledHours: PropTypes.func,
31 disabledMinutes: PropTypes.func, 32 disabledMinutes: PropTypes.func,
32 disabledSeconds: PropTypes.func, 33 disabledSeconds: PropTypes.func,
@@ -58,6 +59,7 @@ class Panel extends Component {
58 use12Hours: false, 59 use12Hours: false,
59 addon: noop, 60 addon: noop,
60 onKeyDown: noop, 61 onKeyDown: noop,
62 inputReadOnly: false,
61 }; 63 };
62 64
63 constructor(props) { 65 constructor(props) {
@@ -96,7 +98,7 @@ class Panel extends Component {
96 prefixCls, className, placeholder, disabledHours, disabledMinutes, 98 prefixCls, className, placeholder, disabledHours, disabledMinutes,
97 disabledSeconds, hideDisabledOptions, allowEmpty, showHour, showMinute, showSecond, 99 disabledSeconds, hideDisabledOptions, allowEmpty, showHour, showMinute, showSecond,
98 format, defaultOpenValue, clearText, onEsc, addon, use12Hours, onClear, 100 format, defaultOpenValue, clearText, onEsc, addon, use12Hours, onClear,
99 focusOnOpen, onKeyDown, hourStep, minuteStep, secondStep, 101 focusOnOpen, onKeyDown, hourStep, minuteStep, secondStep, inputReadOnly,
100 } = this.props; 102 } = this.props;
101 const { 103 const {
102 value, currentSelectPanel, 104 value, currentSelectPanel,
@@ -137,6 +139,7 @@ class Panel extends Component {
137 allowEmpty={allowEmpty} 139 allowEmpty={allowEmpty}
138 focusOnOpen={focusOnOpen} 140 focusOnOpen={focusOnOpen}
139 onKeyDown={onKeyDown} 141 onKeyDown={onKeyDown}
142 inputReadOnly={inputReadOnly}
140 /> 143 />
141 <Combobox 144 <Combobox
142 prefixCls={prefixCls} 145 prefixCls={prefixCls}
diff --git a/src/TimePicker.jsx b/src/TimePicker.jsx
index e3c5a79..7659bc7 100644
--- a/src/TimePicker.jsx
+++ b/src/TimePicker.jsx
@@ -18,6 +18,7 @@ export default class Picker extends Component {
18 clearText: PropTypes.string, 18 clearText: PropTypes.string,
19 value: PropTypes.object, 19 value: PropTypes.object,
20 defaultOpenValue: PropTypes.object, 20 defaultOpenValue: PropTypes.object,
21 inputReadOnly: PropTypes.bool,
21 disabled: PropTypes.bool, 22 disabled: PropTypes.bool,
22 allowEmpty: PropTypes.bool, 23 allowEmpty: PropTypes.bool,
23 defaultValue: PropTypes.object, 24 defaultValue: PropTypes.object,
@@ -60,6 +61,7 @@ export default class Picker extends Component {
60 clearText: 'clear', 61 clearText: 'clear',
61 prefixCls: 'rc-time-picker', 62 prefixCls: 'rc-time-picker',
62 defaultOpen: false, 63 defaultOpen: false,
64 inputReadOnly: false,
63 style: {}, 65 style: {},
64 className: '', 66 className: '',
65 popupClassName: '', 67 popupClassName: '',
@@ -167,7 +169,7 @@ export default class Picker extends Component {
167 getPanelElement() { 169 getPanelElement() {
168 const { 170 const {
169 prefixCls, placeholder, disabledHours, 171 prefixCls, placeholder, disabledHours,
170 disabledMinutes, disabledSeconds, hideDisabledOptions, 172 disabledMinutes, disabledSeconds, hideDisabledOptions, inputReadOnly,
171 allowEmpty, showHour, showMinute, showSecond, defaultOpenValue, clearText, 173 allowEmpty, showHour, showMinute, showSecond, defaultOpenValue, clearText,
172 addon, use12Hours, focusOnOpen, onKeyDown, hourStep, minuteStep, secondStep, 174 addon, use12Hours, focusOnOpen, onKeyDown, hourStep, minuteStep, secondStep,
173 } = this.props; 175 } = this.props;
@@ -177,6 +179,7 @@ export default class Picker extends Component {
177 prefixCls={`${prefixCls}-panel`} 179 prefixCls={`${prefixCls}-panel`}
178 ref={this.savePanelRef} 180 ref={this.savePanelRef}
179 value={this.state.value} 181 value={this.state.value}
182 inputReadOnly={inputReadOnly}
180 onChange={this.onPanelChange} 183 onChange={this.onPanelChange}
181 onClear={this.onPanelClear} 184 onClear={this.onPanelClear}
182 defaultOpenValue={defaultOpenValue} 185 defaultOpenValue={defaultOpenValue}