aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--HISTORY.md5
-rw-r--r--README.md1
-rw-r--r--examples/disabled.js3
-rw-r--r--examples/hidden.js3
-rw-r--r--examples/pick-time.js3
-rw-r--r--examples/value-and-defaultValue.js10
-rw-r--r--package.json2
-rw-r--r--src/TimePicker.jsx18
-rw-r--r--src/locale/en_US.js2
-rw-r--r--src/locale/zh_CN.js2
10 files changed, 24 insertions, 25 deletions
diff --git a/HISTORY.md b/HISTORY.md
index 2c90f67..00609e5 100644
--- a/HISTORY.md
+++ b/HISTORY.md
@@ -2,6 +2,11 @@
2 2
3--- 3---
4 4
51.1.0 / 2016-01-14
6---------------------------
7
8remove gregorianCalendarLocale prop, move to locale.calendar
9
51.0.0 / 2015-12-21 101.0.0 / 2015-12-21
6------------------------- 11-------------------------
7 12
diff --git a/README.md b/README.md
index ea0e034..483ee2b 100644
--- a/README.md
+++ b/README.md
@@ -56,7 +56,6 @@ API
56| open | Boolean | false | current open state of picker. controlled prop | 56| open | Boolean | false | current open state of picker. controlled prop |
57| defaultValue | GregorianCalendar | null | default initial value | 57| defaultValue | GregorianCalendar | null | default initial value |
58| value | GregorianCalendar | null | current value | 58| value | GregorianCalendar | null | current value |
59| gregorianCalendarLocale | GregorianCalendar locale object | null | if value and defaultValue not set, you should set this to your locale |
60| placeholder | String | '' | time input's placeholder | 59| placeholder | String | '' | time input's placeholder |
61| showHour | Boolean | whether show hour | | 60| showHour | Boolean | whether show hour | |
62| showSecond | Boolean | whether show second | | 61| showSecond | Boolean | whether show second | |
diff --git a/examples/disabled.js b/examples/disabled.js
index 633b8db..4b7c5eb 100644
--- a/examples/disabled.js
+++ b/examples/disabled.js
@@ -7,7 +7,6 @@ import ReactDom from 'react-dom';
7 7
8import GregorianCalendar from 'gregorian-calendar'; 8import GregorianCalendar from 'gregorian-calendar';
9import DateTimeFormat from 'gregorian-calendar-format'; 9import DateTimeFormat from 'gregorian-calendar-format';
10import zhCn from 'gregorian-calendar/lib/locale/zh_CN';
11 10
12import TimePicker from 'rc-time-picker'; 11import TimePicker from 'rc-time-picker';
13import TimePickerLocale from 'rc-time-picker/src/locale/zh_CN'; 12import TimePickerLocale from 'rc-time-picker/src/locale/zh_CN';
@@ -17,7 +16,7 @@ const str = showSecond ? 'HH:mm:ss' : 'HH:mm';
17 16
18const formatter = new DateTimeFormat(str); 17const formatter = new DateTimeFormat(str);
19 18
20const now = new GregorianCalendar(zhCn); 19const now = new GregorianCalendar(TimePickerLocale.calendar);
21now.setTime(Date.now()); 20now.setTime(Date.now());
22 21
23function generateOptions(length, excludedOptions) { 22function generateOptions(length, excludedOptions) {
diff --git a/examples/hidden.js b/examples/hidden.js
index da366cc..16abd2a 100644
--- a/examples/hidden.js
+++ b/examples/hidden.js
@@ -7,7 +7,6 @@ import ReactDom from 'react-dom';
7 7
8import GregorianCalendar from 'gregorian-calendar'; 8import GregorianCalendar from 'gregorian-calendar';
9import DateTimeFormat from 'gregorian-calendar-format'; 9import DateTimeFormat from 'gregorian-calendar-format';
10import zhCn from 'gregorian-calendar/lib/locale/zh_CN';
11 10
12import TimePicker from 'rc-time-picker'; 11import TimePicker from 'rc-time-picker';
13import TimePickerLocale from 'rc-time-picker/src/locale/zh_CN'; 12import TimePickerLocale from 'rc-time-picker/src/locale/zh_CN';
@@ -17,7 +16,7 @@ const str = showSecond ? 'HH:mm:ss' : 'HH:mm';
17 16
18const formatter = new DateTimeFormat(str); 17const formatter = new DateTimeFormat(str);
19 18
20const now = new GregorianCalendar(zhCn); 19const now = new GregorianCalendar(TimePickerLocale.calendar);
21now.setTime(Date.now()); 20now.setTime(Date.now());
22 21
23function onChange(value) { 22function onChange(value) {
diff --git a/examples/pick-time.js b/examples/pick-time.js
index dbe1c96..8fa7831 100644
--- a/examples/pick-time.js
+++ b/examples/pick-time.js
@@ -7,7 +7,6 @@ import ReactDom from 'react-dom';
7 7
8import GregorianCalendar from 'gregorian-calendar'; 8import GregorianCalendar from 'gregorian-calendar';
9import DateTimeFormat from 'gregorian-calendar-format'; 9import DateTimeFormat from 'gregorian-calendar-format';
10import zhCn from 'gregorian-calendar/lib/locale/zh_CN';
11 10
12import TimePicker from 'rc-time-picker'; 11import TimePicker from 'rc-time-picker';
13import TimePickerLocale from 'rc-time-picker/src/locale/zh_CN'; 12import TimePickerLocale from 'rc-time-picker/src/locale/zh_CN';
@@ -17,7 +16,7 @@ const str = showSecond ? 'HH:mm:ss' : 'HH:mm';
17 16
18const formatter = new DateTimeFormat(str); 17const formatter = new DateTimeFormat(str);
19 18
20const now = new GregorianCalendar(zhCn); 19const now = new GregorianCalendar(TimePickerLocale.calendar);
21now.setTime(Date.now()); 20now.setTime(Date.now());
22 21
23function onChange(value) { 22function onChange(value) {
diff --git a/examples/value-and-defaultValue.js b/examples/value-and-defaultValue.js
index 404c963..1be30cc 100644
--- a/examples/value-and-defaultValue.js
+++ b/examples/value-and-defaultValue.js
@@ -7,14 +7,12 @@ import ReactDom from 'react-dom';
7 7
8import GregorianCalendar from 'gregorian-calendar'; 8import GregorianCalendar from 'gregorian-calendar';
9import DateTimeFormat from 'gregorian-calendar-format'; 9import DateTimeFormat from 'gregorian-calendar-format';
10import zhCn from 'gregorian-calendar/lib/locale/zh_CN';
11
12import TimePicker from 'rc-time-picker'; 10import TimePicker from 'rc-time-picker';
13import TimePickerLocale from 'rc-time-picker/src/locale/zh_CN'; 11import TimePickerLocale from 'rc-time-picker/src/locale/zh_CN';
14 12
15const formatter = new DateTimeFormat('HH:mm:ss'); 13const formatter = new DateTimeFormat('HH:mm:ss');
16 14
17const now = new GregorianCalendar(zhCn); 15const now = new GregorianCalendar(TimePickerLocale.calendar);
18now.setTime(Date.now()); 16now.setTime(Date.now());
19 17
20const App = React.createClass({ 18const App = React.createClass({
@@ -27,6 +25,11 @@ const App = React.createClass({
27 console.log(value && formatter.format(value)); 25 console.log(value && formatter.format(value));
28 this.setState({ value }); 26 this.setState({ value });
29 }, 27 },
28 clear() {
29 this.setState({
30 value: undefined,
31 });
32 },
30 render() { 33 render() {
31 return ( 34 return (
32 <div> 35 <div>
@@ -35,6 +38,7 @@ const App = React.createClass({
35 <TimePicker formatter={formatter} locale={TimePickerLocale} 38 <TimePicker formatter={formatter} locale={TimePickerLocale}
36 value={this.state.value} 39 value={this.state.value}
37 onChange={this.handleValueChange}/> 40 onChange={this.handleValueChange}/>
41 <button onClick={this.clear}>clear</button>
38 </div> 42 </div>
39 ); 43 );
40 }, 44 },
diff --git a/package.json b/package.json
index 5fc5181..f2edee8 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
1{ 1{
2 "name": "rc-time-picker", 2 "name": "rc-time-picker",
3 "version": "1.0.0", 3 "version": "1.1.0",
4 "description": "React TimePicker", 4 "description": "React TimePicker",
5 "keywords": [ 5 "keywords": [
6 "react", 6 "react",
diff --git a/src/TimePicker.jsx b/src/TimePicker.jsx
index ad4e834..f9b9207 100644
--- a/src/TimePicker.jsx
+++ b/src/TimePicker.jsx
@@ -4,7 +4,6 @@ import Panel from './module/Panel';
4import placements from './util/placements'; 4import placements from './util/placements';
5import CommonMixin from './mixin/CommonMixin'; 5import CommonMixin from './mixin/CommonMixin';
6import {getFormatter} from './util/index'; 6import {getFormatter} from './util/index';
7import defaultGregorianCalendarLocale from 'gregorian-calendar/lib/locale/en_US';
8 7
9function noop() { 8function noop() {
10} 9}
@@ -27,7 +26,6 @@ const Picker = React.createClass({
27 placement: PropTypes.any, 26 placement: PropTypes.any,
28 transitionName: PropTypes.string, 27 transitionName: PropTypes.string,
29 getPopupContainer: PropTypes.func, 28 getPopupContainer: PropTypes.func,
30 gregorianCalendarLocale: PropTypes.object,
31 placeholder: PropTypes.string, 29 placeholder: PropTypes.string,
32 formatter: PropTypes.any, 30 formatter: PropTypes.any,
33 showHour: PropTypes.bool, 31 showHour: PropTypes.bool,
@@ -50,7 +48,6 @@ const Picker = React.createClass({
50 defaultOpen: false, 48 defaultOpen: false,
51 style: {}, 49 style: {},
52 className: '', 50 className: '',
53 gregorianCalendarLocale: defaultGregorianCalendarLocale,
54 align: {}, 51 align: {},
55 allowEmpty: true, 52 allowEmpty: true,
56 showHour: true, 53 showHour: true,
@@ -77,7 +74,7 @@ const Picker = React.createClass({
77 74
78 componentWillReceiveProps(nextProps) { 75 componentWillReceiveProps(nextProps) {
79 const { value, open } = nextProps; 76 const { value, open } = nextProps;
80 if (value !== undefined) { 77 if ('value' in nextProps) {
81 this.setState({ 78 this.setState({
82 value, 79 value,
83 }); 80 });
@@ -150,22 +147,15 @@ const Picker = React.createClass({
150 }, 147 },
151 148
152 getPanelElement() { 149 getPanelElement() {
153 const { prefixCls, defaultValue, locale, placeholder, disabledHours, disabledMinutes, disabledSeconds, hideDisabledOptions, allowEmpty, showHour, showSecond, gregorianCalendarLocale, value } = this.props; 150 const { prefixCls, defaultValue, locale, placeholder, disabledHours,
154 let calendarLocale; 151 disabledMinutes, disabledSeconds, hideDisabledOptions, allowEmpty, showHour, showSecond } = this.props;
155 if (value) {
156 calendarLocale = value.locale;
157 } else if (defaultValue) {
158 calendarLocale = defaultValue.locale;
159 } else {
160 calendarLocale = gregorianCalendarLocale;
161 }
162 return ( 152 return (
163 <Panel 153 <Panel
164 prefixCls={`${prefixCls}-panel`} 154 prefixCls={`${prefixCls}-panel`}
165 ref={this.savePanelRef} 155 ref={this.savePanelRef}
166 value={this.state.value} 156 value={this.state.value}
167 onChange={this.onPanelChange} 157 onChange={this.onPanelChange}
168 gregorianCalendarLocale={calendarLocale} 158 gregorianCalendarLocale={locale.calendar}
169 onClear={this.onPanelClear} 159 onClear={this.onPanelClear}
170 defaultValue={defaultValue} 160 defaultValue={defaultValue}
171 showHour={showHour} 161 showHour={showHour}
diff --git a/src/locale/en_US.js b/src/locale/en_US.js
index 488725c..506f4c9 100644
--- a/src/locale/en_US.js
+++ b/src/locale/en_US.js
@@ -1,6 +1,8 @@
1import enUs from 'gregorian-calendar-format/lib/locale/en_US'; 1import enUs from 'gregorian-calendar-format/lib/locale/en_US';
2import enUsCalendar from 'gregorian-calendar/lib/locale/en_US';
2 3
3export default { 4export default {
4 clear: 'Clear', 5 clear: 'Clear',
5 format: enUs, 6 format: enUs,
7 calendar: enUsCalendar,
6}; 8};
diff --git a/src/locale/zh_CN.js b/src/locale/zh_CN.js
index 8e02a08..1e977be 100644
--- a/src/locale/zh_CN.js
+++ b/src/locale/zh_CN.js
@@ -1,6 +1,8 @@
1import zhCn from 'gregorian-calendar-format/lib/locale/zh_CN'; 1import zhCn from 'gregorian-calendar-format/lib/locale/zh_CN';
2import zhCnCalendar from 'gregorian-calendar/lib/locale/zh_CN';
2 3
3export default { 4export default {
4 clear: '清除', 5 clear: '清除',
5 format: zhCn, 6 format: zhCn,
7 calendar: zhCnCalendar,
6}; 8};