diff options
-rw-r--r-- | HISTORY.md | 5 | ||||
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | examples/disabled.js | 3 | ||||
-rw-r--r-- | examples/hidden.js | 3 | ||||
-rw-r--r-- | examples/pick-time.js | 3 | ||||
-rw-r--r-- | examples/value-and-defaultValue.js | 10 | ||||
-rw-r--r-- | package.json | 2 | ||||
-rw-r--r-- | src/TimePicker.jsx | 18 | ||||
-rw-r--r-- | src/locale/en_US.js | 2 | ||||
-rw-r--r-- | src/locale/zh_CN.js | 2 |
10 files changed, 24 insertions, 25 deletions
@@ -2,6 +2,11 @@ | |||
2 | 2 | ||
3 | --- | 3 | --- |
4 | 4 | ||
5 | 1.1.0 / 2016-01-14 | ||
6 | --------------------------- | ||
7 | |||
8 | remove gregorianCalendarLocale prop, move to locale.calendar | ||
9 | |||
5 | 1.0.0 / 2015-12-21 | 10 | 1.0.0 / 2015-12-21 |
6 | ------------------------- | 11 | ------------------------- |
7 | 12 | ||
@@ -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 | ||
8 | import GregorianCalendar from 'gregorian-calendar'; | 8 | import GregorianCalendar from 'gregorian-calendar'; |
9 | import DateTimeFormat from 'gregorian-calendar-format'; | 9 | import DateTimeFormat from 'gregorian-calendar-format'; |
10 | import zhCn from 'gregorian-calendar/lib/locale/zh_CN'; | ||
11 | 10 | ||
12 | import TimePicker from 'rc-time-picker'; | 11 | import TimePicker from 'rc-time-picker'; |
13 | import TimePickerLocale from 'rc-time-picker/src/locale/zh_CN'; | 12 | import TimePickerLocale from 'rc-time-picker/src/locale/zh_CN'; |
@@ -17,7 +16,7 @@ const str = showSecond ? 'HH:mm:ss' : 'HH:mm'; | |||
17 | 16 | ||
18 | const formatter = new DateTimeFormat(str); | 17 | const formatter = new DateTimeFormat(str); |
19 | 18 | ||
20 | const now = new GregorianCalendar(zhCn); | 19 | const now = new GregorianCalendar(TimePickerLocale.calendar); |
21 | now.setTime(Date.now()); | 20 | now.setTime(Date.now()); |
22 | 21 | ||
23 | function generateOptions(length, excludedOptions) { | 22 | function 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 | ||
8 | import GregorianCalendar from 'gregorian-calendar'; | 8 | import GregorianCalendar from 'gregorian-calendar'; |
9 | import DateTimeFormat from 'gregorian-calendar-format'; | 9 | import DateTimeFormat from 'gregorian-calendar-format'; |
10 | import zhCn from 'gregorian-calendar/lib/locale/zh_CN'; | ||
11 | 10 | ||
12 | import TimePicker from 'rc-time-picker'; | 11 | import TimePicker from 'rc-time-picker'; |
13 | import TimePickerLocale from 'rc-time-picker/src/locale/zh_CN'; | 12 | import TimePickerLocale from 'rc-time-picker/src/locale/zh_CN'; |
@@ -17,7 +16,7 @@ const str = showSecond ? 'HH:mm:ss' : 'HH:mm'; | |||
17 | 16 | ||
18 | const formatter = new DateTimeFormat(str); | 17 | const formatter = new DateTimeFormat(str); |
19 | 18 | ||
20 | const now = new GregorianCalendar(zhCn); | 19 | const now = new GregorianCalendar(TimePickerLocale.calendar); |
21 | now.setTime(Date.now()); | 20 | now.setTime(Date.now()); |
22 | 21 | ||
23 | function onChange(value) { | 22 | function 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 | ||
8 | import GregorianCalendar from 'gregorian-calendar'; | 8 | import GregorianCalendar from 'gregorian-calendar'; |
9 | import DateTimeFormat from 'gregorian-calendar-format'; | 9 | import DateTimeFormat from 'gregorian-calendar-format'; |
10 | import zhCn from 'gregorian-calendar/lib/locale/zh_CN'; | ||
11 | 10 | ||
12 | import TimePicker from 'rc-time-picker'; | 11 | import TimePicker from 'rc-time-picker'; |
13 | import TimePickerLocale from 'rc-time-picker/src/locale/zh_CN'; | 12 | import TimePickerLocale from 'rc-time-picker/src/locale/zh_CN'; |
@@ -17,7 +16,7 @@ const str = showSecond ? 'HH:mm:ss' : 'HH:mm'; | |||
17 | 16 | ||
18 | const formatter = new DateTimeFormat(str); | 17 | const formatter = new DateTimeFormat(str); |
19 | 18 | ||
20 | const now = new GregorianCalendar(zhCn); | 19 | const now = new GregorianCalendar(TimePickerLocale.calendar); |
21 | now.setTime(Date.now()); | 20 | now.setTime(Date.now()); |
22 | 21 | ||
23 | function onChange(value) { | 22 | function 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 | ||
8 | import GregorianCalendar from 'gregorian-calendar'; | 8 | import GregorianCalendar from 'gregorian-calendar'; |
9 | import DateTimeFormat from 'gregorian-calendar-format'; | 9 | import DateTimeFormat from 'gregorian-calendar-format'; |
10 | import zhCn from 'gregorian-calendar/lib/locale/zh_CN'; | ||
11 | |||
12 | import TimePicker from 'rc-time-picker'; | 10 | import TimePicker from 'rc-time-picker'; |
13 | import TimePickerLocale from 'rc-time-picker/src/locale/zh_CN'; | 11 | import TimePickerLocale from 'rc-time-picker/src/locale/zh_CN'; |
14 | 12 | ||
15 | const formatter = new DateTimeFormat('HH:mm:ss'); | 13 | const formatter = new DateTimeFormat('HH:mm:ss'); |
16 | 14 | ||
17 | const now = new GregorianCalendar(zhCn); | 15 | const now = new GregorianCalendar(TimePickerLocale.calendar); |
18 | now.setTime(Date.now()); | 16 | now.setTime(Date.now()); |
19 | 17 | ||
20 | const App = React.createClass({ | 18 | const 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'; | |||
4 | import placements from './util/placements'; | 4 | import placements from './util/placements'; |
5 | import CommonMixin from './mixin/CommonMixin'; | 5 | import CommonMixin from './mixin/CommonMixin'; |
6 | import {getFormatter} from './util/index'; | 6 | import {getFormatter} from './util/index'; |
7 | import defaultGregorianCalendarLocale from 'gregorian-calendar/lib/locale/en_US'; | ||
8 | 7 | ||
9 | function noop() { | 8 | function 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 @@ | |||
1 | import enUs from 'gregorian-calendar-format/lib/locale/en_US'; | 1 | import enUs from 'gregorian-calendar-format/lib/locale/en_US'; |
2 | import enUsCalendar from 'gregorian-calendar/lib/locale/en_US'; | ||
2 | 3 | ||
3 | export default { | 4 | export 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 @@ | |||
1 | import zhCn from 'gregorian-calendar-format/lib/locale/zh_CN'; | 1 | import zhCn from 'gregorian-calendar-format/lib/locale/zh_CN'; |
2 | import zhCnCalendar from 'gregorian-calendar/lib/locale/zh_CN'; | ||
2 | 3 | ||
3 | export default { | 4 | export default { |
4 | clear: '清除', | 5 | clear: '清除', |
5 | format: zhCn, | 6 | format: zhCn, |
7 | calendar: zhCnCalendar, | ||
6 | }; | 8 | }; |