]> git.immae.eu Git - github/fretlink/time-picker.git/commitdiff
remove gregorianCalendarLocale 1.1.0
authoryiminghe <yiminghe@gmail.com>
Thu, 14 Jan 2016 05:59:59 +0000 (13:59 +0800)
committeryiminghe <yiminghe@gmail.com>
Thu, 14 Jan 2016 05:59:59 +0000 (13:59 +0800)
HISTORY.md
README.md
examples/disabled.js
examples/hidden.js
examples/pick-time.js
examples/value-and-defaultValue.js
package.json
src/TimePicker.jsx
src/locale/en_US.js
src/locale/zh_CN.js

index 2c90f678d96719940e5ccac4db9081133197b362..00609e5957e11fae27fa460a315462a9cca4b163 100644 (file)
@@ -2,6 +2,11 @@
 
 ---
 
+1.1.0 / 2016-01-14
+---------------------------
+
+remove gregorianCalendarLocale prop, move to locale.calendar
+
 1.0.0 / 2015-12-21
 -------------------------
 
index ea0e0346a40263964922c2fa241545de75831c0c..483ee2b737ff16d2189a6771b7c93c17cca2ecd0 100644 (file)
--- 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                           |                                                                                            |
index 633b8db9279e47e3b9ea45220327b4798383aa5e..4b7c5eb4b33ea082a29319710bc2538dc436a0f3 100644 (file)
@@ -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) {
index da366ccc672defe6395c46e3e40329169c692fca..16abd2acca7c369443b04d79384f54365a13d9c7 100644 (file)
@@ -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) {
index dbe1c966d3295c73e360e58abf9e5bef56311e56..8fa7831e6419ebfc176e0340d27ea659397be536 100644 (file)
@@ -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) {
index 404c963850b5a6972fcd697df6e3dcfcf3b79d69..1be30cc1f9fe854e6c07f116a830c61dad8b49e4 100644 (file)
@@ -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 (
       <div>
@@ -35,6 +38,7 @@ const App = React.createClass({
         <TimePicker formatter={formatter} locale={TimePickerLocale}
               value={this.state.value}
               onChange={this.handleValueChange}/>
+        <button onClick={this.clear}>clear</button>
       </div>
     );
   },
index 5fc51810b83b62f45ffb7c4174f26335708cbdb6..f2edee84a4b94c49a00e9af2aec875ab1a1b1961 100644 (file)
@@ -1,6 +1,6 @@
 {
   "name": "rc-time-picker",
-  "version": "1.0.0",
+  "version": "1.1.0",
   "description": "React TimePicker",
   "keywords": [
     "react",
index ad4e834a60277cdc8d0795efd6e142a23461fc37..f9b92078c9be3714681704795ced2c28339c41fa 100644 (file)
@@ -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 (
       <Panel
         prefixCls={`${prefixCls}-panel`}
         ref={this.savePanelRef}
         value={this.state.value}
         onChange={this.onPanelChange}
-        gregorianCalendarLocale={calendarLocale}
+        gregorianCalendarLocale={locale.calendar}
         onClear={this.onPanelClear}
         defaultValue={defaultValue}
         showHour={showHour}
index 488725c0a3e8a2c3754ea0845ef52419eec5ef60..506f4c9855e33ca3a71809be59816b23090f7fc0 100644 (file)
@@ -1,6 +1,8 @@
 import enUs from 'gregorian-calendar-format/lib/locale/en_US';
+import enUsCalendar from 'gregorian-calendar/lib/locale/en_US';
 
 export default {
   clear: 'Clear',
   format: enUs,
+  calendar: enUsCalendar,
 };
index 8e02a08cf98d14c037353c5bd6233b12df695b17..1e977be48d3e3c088d4282b01eb9c5fe7e9b8075 100644 (file)
@@ -1,6 +1,8 @@
 import zhCn from 'gregorian-calendar-format/lib/locale/zh_CN';
+import zhCnCalendar from 'gregorian-calendar/lib/locale/zh_CN';
 
 export default {
   clear: '清除',
   format: zhCn,
+  calendar: zhCnCalendar,
 };