From 6fc4e0e8e2f7bd8bbcbb759a69bc7b94930f131c Mon Sep 17 00:00:00 2001 From: yiminghe Date: Thu, 14 Jan 2016 13:59:59 +0800 Subject: remove gregorianCalendarLocale --- HISTORY.md | 5 +++++ README.md | 1 - examples/disabled.js | 3 +-- examples/hidden.js | 3 +-- examples/pick-time.js | 3 +-- examples/value-and-defaultValue.js | 10 +++++++--- package.json | 2 +- src/TimePicker.jsx | 18 ++++-------------- src/locale/en_US.js | 2 ++ src/locale/zh_CN.js | 2 ++ 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 @@ --- +1.1.0 / 2016-01-14 +--------------------------- + +remove gregorianCalendarLocale prop, move to locale.calendar + 1.0.0 / 2015-12-21 ------------------------- diff --git a/README.md b/README.md index ea0e034..483ee2b 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,6 @@ API | open | Boolean | false | current open state of picker. controlled prop | | defaultValue | GregorianCalendar | null | default initial value | | value | GregorianCalendar | null | current value | -| gregorianCalendarLocale | GregorianCalendar locale object | null | if value and defaultValue not set, you should set this to your locale | | placeholder | String | '' | time input's placeholder | | showHour | Boolean | whether show hour | | | 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'; import GregorianCalendar from 'gregorian-calendar'; import DateTimeFormat from 'gregorian-calendar-format'; -import zhCn from 'gregorian-calendar/lib/locale/zh_CN'; import TimePicker from 'rc-time-picker'; import TimePickerLocale from 'rc-time-picker/src/locale/zh_CN'; @@ -17,7 +16,7 @@ const str = showSecond ? 'HH:mm:ss' : 'HH:mm'; const formatter = new DateTimeFormat(str); -const now = new GregorianCalendar(zhCn); +const now = new GregorianCalendar(TimePickerLocale.calendar); now.setTime(Date.now()); 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'; import GregorianCalendar from 'gregorian-calendar'; import DateTimeFormat from 'gregorian-calendar-format'; -import zhCn from 'gregorian-calendar/lib/locale/zh_CN'; import TimePicker from 'rc-time-picker'; import TimePickerLocale from 'rc-time-picker/src/locale/zh_CN'; @@ -17,7 +16,7 @@ const str = showSecond ? 'HH:mm:ss' : 'HH:mm'; const formatter = new DateTimeFormat(str); -const now = new GregorianCalendar(zhCn); +const now = new GregorianCalendar(TimePickerLocale.calendar); now.setTime(Date.now()); 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'; import GregorianCalendar from 'gregorian-calendar'; import DateTimeFormat from 'gregorian-calendar-format'; -import zhCn from 'gregorian-calendar/lib/locale/zh_CN'; import TimePicker from 'rc-time-picker'; import TimePickerLocale from 'rc-time-picker/src/locale/zh_CN'; @@ -17,7 +16,7 @@ const str = showSecond ? 'HH:mm:ss' : 'HH:mm'; const formatter = new DateTimeFormat(str); -const now = new GregorianCalendar(zhCn); +const now = new GregorianCalendar(TimePickerLocale.calendar); now.setTime(Date.now()); 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'; import GregorianCalendar from 'gregorian-calendar'; import DateTimeFormat from 'gregorian-calendar-format'; -import zhCn from 'gregorian-calendar/lib/locale/zh_CN'; - import TimePicker from 'rc-time-picker'; import TimePickerLocale from 'rc-time-picker/src/locale/zh_CN'; const formatter = new DateTimeFormat('HH:mm:ss'); -const now = new GregorianCalendar(zhCn); +const now = new GregorianCalendar(TimePickerLocale.calendar); now.setTime(Date.now()); const App = React.createClass({ @@ -27,6 +25,11 @@ const App = React.createClass({ console.log(value && formatter.format(value)); this.setState({ value }); }, + clear() { + this.setState({ + value: undefined, + }); + }, render() { return (
@@ -35,6 +38,7 @@ const App = React.createClass({ +
); }, diff --git a/package.json b/package.json index 5fc5181..f2edee8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rc-time-picker", - "version": "1.0.0", + "version": "1.1.0", "description": "React TimePicker", "keywords": [ "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'; import placements from './util/placements'; import CommonMixin from './mixin/CommonMixin'; import {getFormatter} from './util/index'; -import defaultGregorianCalendarLocale from 'gregorian-calendar/lib/locale/en_US'; function noop() { } @@ -27,7 +26,6 @@ const Picker = React.createClass({ placement: PropTypes.any, transitionName: PropTypes.string, getPopupContainer: PropTypes.func, - gregorianCalendarLocale: PropTypes.object, placeholder: PropTypes.string, formatter: PropTypes.any, showHour: PropTypes.bool, @@ -50,7 +48,6 @@ const Picker = React.createClass({ defaultOpen: false, style: {}, className: '', - gregorianCalendarLocale: defaultGregorianCalendarLocale, align: {}, allowEmpty: true, showHour: true, @@ -77,7 +74,7 @@ const Picker = React.createClass({ componentWillReceiveProps(nextProps) { const { value, open } = nextProps; - if (value !== undefined) { + if ('value' in nextProps) { this.setState({ value, }); @@ -150,22 +147,15 @@ const Picker = React.createClass({ }, getPanelElement() { - const { prefixCls, defaultValue, locale, placeholder, disabledHours, disabledMinutes, disabledSeconds, hideDisabledOptions, allowEmpty, showHour, showSecond, gregorianCalendarLocale, value } = this.props; - let calendarLocale; - if (value) { - calendarLocale = value.locale; - } else if (defaultValue) { - calendarLocale = defaultValue.locale; - } else { - calendarLocale = gregorianCalendarLocale; - } + const { prefixCls, defaultValue, locale, placeholder, disabledHours, + disabledMinutes, disabledSeconds, hideDisabledOptions, allowEmpty, showHour, showSecond } = this.props; return (