react-day-picker 7.3.2 → 7.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,22 @@
1
+ ## [v7.4](https://github.com/gpbl/react-day-picker/tree/v7.4.0) (2019-10-20)
2
+
3
+ #### DayPicker
4
+ * Fix text wrapping on `.DayPicker-Day` default style (#824)
5
+ * Add `focus()` method for focusing the `DayPicker` wrapper element (#761)
6
+
7
+ #### DayPickerInput
8
+
9
+ * When DayPicker input state is controlled, correctly set the input text if the `value` prop updates ([#816](https://github.com/gpbl/react-day-picker/issues/816) by [MitchRivet](https://github.com/MitchRivet))
10
+ * Fix DayPickerInput value does not recompute on `locale` change (fix #938) (#939)
11
+ * Set overlayHasFocus to false in hideAfterDayClick (#941)
12
+
13
+ #### Typings
14
+
15
+ * Improve typings, use TypeScript 3.1 (#929)
16
+ * Add formatDate and parseDate to typings (#873)
17
+ * Make `format` optional (#923)
18
+ * Remove `initialMonth` from `defaultProps` (#874)
19
+
1
20
  ### [v7.3.2](https://github.com/gpbl/react-day-picker/tree/v7.3.2) (2019-08-08)
2
21
 
3
22
  Updates for TypeScript users:
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2014 Giampaolo Bellavite
3
+ Copyright (c) 2014-2019 Giampaolo Bellavite
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
22
-
package/lib/daypicker.js CHANGED
@@ -1029,6 +1029,11 @@ var DayPicker = exports.DayPicker = function (_Component) {
1029
1029
  var nextMonth = DateUtils.addMonths(this.state.currentMonth, -12);
1030
1030
  this.showMonth(nextMonth);
1031
1031
  }
1032
+ }, {
1033
+ key: 'focus',
1034
+ value: function focus() {
1035
+ this.wrapper.focus();
1036
+ }
1032
1037
  }, {
1033
1038
  key: 'focusFirstDayOfMonth',
1034
1039
  value: function focusFirstDayOfMonth() {
@@ -1232,6 +1237,9 @@ var DayPicker = exports.DayPicker = function (_Component) {
1232
1237
  'div',
1233
1238
  {
1234
1239
  className: this.props.classNames.wrapper,
1240
+ ref: function ref(el) {
1241
+ return _this7.wrapper = el;
1242
+ },
1235
1243
  tabIndex: this.props.canChangeMonth && typeof this.props.tabIndex !== 'undefined' ? this.props.tabIndex : -1,
1236
1244
  onKeyDown: this.handleKeyDown,
1237
1245
  onFocus: this.props.onFocus,
@@ -1252,7 +1260,7 @@ var DayPicker = exports.DayPicker = function (_Component) {
1252
1260
  return DayPicker;
1253
1261
  }(_react.Component);
1254
1262
 
1255
- DayPicker.VERSION = '7.3.2';
1263
+ DayPicker.VERSION = '7.4.0';
1256
1264
  DayPicker.propTypes = {
1257
1265
  // Rendering months
1258
1266
  initialMonth: _propTypes2.default.instanceOf(Date),
@@ -2502,9 +2510,10 @@ var DayPickerInput = function (_React$Component) {
2502
2510
  format = _props.format,
2503
2511
  dayPickerProps = _props.dayPickerProps;
2504
2512
 
2505
- // Update the input value if the `value` prop has changed
2513
+ // Update the input value if `value`, `dayPickerProps.locale` or `format`
2514
+ // props have changed
2506
2515
 
2507
- if (value !== prevProps.value) {
2516
+ if (value !== prevProps.value || dayPickerProps.locale !== prevProps.dayPickerProps.locale || format !== prevProps.format) {
2508
2517
  if ((0, _DateUtils.isDate)(value)) {
2509
2518
  newState.value = formatDate(value, format, dayPickerProps.locale);
2510
2519
  } else {
@@ -2558,14 +2567,17 @@ var DayPickerInput = function (_React$Component) {
2558
2567
  value: function getInitialStateFromProps(props) {
2559
2568
  var dayPickerProps = props.dayPickerProps,
2560
2569
  formatDate = props.formatDate,
2561
- format = props.format;
2570
+ format = props.format,
2571
+ typedValue = props.typedValue;
2562
2572
  var value = props.value;
2563
2573
 
2564
2574
  if (props.value && (0, _DateUtils.isDate)(props.value)) {
2565
2575
  value = formatDate(props.value, format, dayPickerProps.locale);
2566
2576
  }
2577
+
2567
2578
  return {
2568
2579
  value: value,
2580
+ typedValue: typedValue,
2569
2581
  month: this.getInitialMonthFromProps(props),
2570
2582
  selectedDays: dayPickerProps.selectedDays
2571
2583
  };
@@ -2599,7 +2611,7 @@ var DayPickerInput = function (_React$Component) {
2599
2611
  dayPickerProps = _props2.dayPickerProps,
2600
2612
  onDayChange = _props2.onDayChange;
2601
2613
 
2602
- this.setState({ month: day, value: value, typedValue: undefined }, function () {
2614
+ this.setState({ month: day, value: value, typedValue: '' }, function () {
2603
2615
  if (callback) {
2604
2616
  callback();
2605
2617
  }
@@ -2679,7 +2691,8 @@ var DayPickerInput = function (_React$Component) {
2679
2691
  return;
2680
2692
  }
2681
2693
  this.hideTimeout = setTimeout(function () {
2682
- return _this5.hideDayPicker();
2694
+ _this5.overlayHasFocus = false;
2695
+ _this5.hideDayPicker();
2683
2696
  }, HIDE_TIMEOUT);
2684
2697
  }
2685
2698
  }, {
@@ -2768,7 +2781,7 @@ var DayPickerInput = function (_React$Component) {
2768
2781
  var value = e.target.value;
2769
2782
 
2770
2783
  if (value.trim() === '') {
2771
- this.setState({ value: value, typedValue: undefined });
2784
+ this.setState({ value: value, typedValue: '' });
2772
2785
  if (onDayChange) onDayChange(undefined, {}, this);
2773
2786
  return;
2774
2787
  }
@@ -2851,7 +2864,9 @@ var DayPickerInput = function (_React$Component) {
2851
2864
  } else if (selectedDays) {
2852
2865
  selectedDays = null;
2853
2866
  }
2854
- this.setState({ value: '', typedValue: undefined, selectedDays: selectedDays }, this.hideAfterDayClick);
2867
+
2868
+ this.setState({ value: '', typedValue: '', selectedDays: selectedDays }, this.hideAfterDayClick);
2869
+
2855
2870
  if (onDayChange) {
2856
2871
  onDayChange(undefined, modifiers, this);
2857
2872
  }
@@ -2939,7 +2954,7 @@ var DayPickerInput = function (_React$Component) {
2939
2954
  },
2940
2955
  placeholder: this.props.placeholder
2941
2956
  }, inputProps, {
2942
- value: this.state.typedValue || this.state.value,
2957
+ value: this.state.value || this.state.typedValue,
2943
2958
  onChange: this.handleInputChange,
2944
2959
  onFocus: this.handleInputFocus,
2945
2960
  onBlur: this.handleInputBlur,
@@ -2964,6 +2979,7 @@ DayPickerInput.propTypes = {
2964
2979
 
2965
2980
  formatDate: _propTypes2.default.func,
2966
2981
  parseDate: _propTypes2.default.func,
2982
+ typedValue: _propTypes2.default.string,
2967
2983
 
2968
2984
  showOverlay: _propTypes2.default.bool,
2969
2985
  dayPickerProps: _propTypes2.default.object,
@@ -2992,6 +3008,7 @@ DayPickerInput.propTypes = {
2992
3008
  DayPickerInput.defaultProps = {
2993
3009
  dayPickerProps: {},
2994
3010
  value: '',
3011
+ typedValue: '',
2995
3012
  placeholder: 'YYYY-M-D',
2996
3013
  format: 'L',
2997
3014
  formatDate: defaultFormat,