@ornikar/kitt-universal 9.34.0 → 9.34.2

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.
@@ -2995,10 +2995,8 @@ function yearFormatter(year) {
2995
2995
  return prefixWithZero(year, 4);
2996
2996
  }
2997
2997
 
2998
- function getDayInInterval(value, minDate, maxDate) {
2999
- var minValue = minDate ? minDate.getDate() : 1;
3000
- var maxValue = maxDate ? maxDate.getDate() : 31;
3001
- return value !== undefined ? Math.max(minValue, Math.min(maxValue, value)) : value;
2998
+ function getDayInInterval(value) {
2999
+ return value !== undefined ? Math.max(1, Math.min(31, value)) : value;
3002
3000
  }
3003
3001
  function getMonthInInterval(value, minDate, maxDate) {
3004
3002
  var minValue = minDate ? minDate.getMonth() + 1 : 1;
@@ -3023,6 +3021,8 @@ function onDatePartChange(_ref) {
3023
3021
  year = _ref.year,
3024
3022
  _ref$validYearMinLeng = _ref.validYearMinLength,
3025
3023
  validYearMinLength = _ref$validYearMinLeng === void 0 ? 4 : _ref$validYearMinLeng,
3024
+ minDate = _ref.minDate,
3025
+ maxDate = _ref.maxDate,
3026
3026
  onChange = _ref.onChange,
3027
3027
  onBlur = _ref.onBlur,
3028
3028
  onFocus = _ref.onFocus;
@@ -3056,6 +3056,32 @@ function onDatePartChange(_ref) {
3056
3056
  nextValue.setHours(0);
3057
3057
  nextValue.setSeconds(0);
3058
3058
  nextValue.setMilliseconds(0);
3059
+ if (minDate) {
3060
+ minDate.setMinutes(0);
3061
+ minDate.setHours(0);
3062
+ minDate.setSeconds(0);
3063
+ minDate.setMilliseconds(0);
3064
+ var isMinDateAfterNextValue = minDate.getTime() > nextValue.getTime();
3065
+ if (isMinDateAfterNextValue) {
3066
+ if (onFocus) onFocus();
3067
+ onChange(undefined);
3068
+ if (onBlur) onBlur();
3069
+ return;
3070
+ }
3071
+ }
3072
+ if (maxDate) {
3073
+ maxDate.setMinutes(0);
3074
+ maxDate.setHours(0);
3075
+ maxDate.setSeconds(0);
3076
+ maxDate.setMilliseconds(0);
3077
+ var isMaxDateBeforeNextValue = nextValue.getTime() > maxDate.getTime();
3078
+ if (isMaxDateBeforeNextValue) {
3079
+ if (onFocus) onFocus();
3080
+ onChange(undefined);
3081
+ if (onBlur) onBlur();
3082
+ return;
3083
+ }
3084
+ }
3059
3085
  if (onFocus) onFocus();
3060
3086
  onChange(nextValue);
3061
3087
  if (onBlur) onBlur();
@@ -3070,11 +3096,15 @@ var keyboardDatePickerReducer = function (state, action) {
3070
3096
  var handleChange = function (dateParts) {
3071
3097
  var onFocus = state.onFocus,
3072
3098
  onBlur = state.onBlur,
3073
- onChange = state.onChange;
3099
+ onChange = state.onChange,
3100
+ minDate = state.minDate,
3101
+ maxDate = state.maxDate;
3074
3102
  onDatePartChange(_objectSpread(_objectSpread({}, dateParts), {}, {
3075
3103
  onFocus: onFocus,
3076
3104
  onBlur: onBlur,
3077
- onChange: onChange
3105
+ onChange: onChange,
3106
+ minDate: minDate,
3107
+ maxDate: maxDate
3078
3108
  }));
3079
3109
  };
3080
3110
  switch (action.type) {
@@ -3137,18 +3167,16 @@ var keyboardDatePickerReducer = function (state, action) {
3137
3167
  }
3138
3168
  case 'day-blur':
3139
3169
  {
3140
- var minDate = state.minDate,
3141
- maxDate = state.maxDate;
3142
- var nextCurrentDay = getDayInInterval(state.currentDay, minDate, maxDate);
3170
+ var nextCurrentDay = getDayInInterval(state.currentDay);
3143
3171
  return _objectSpread(_objectSpread({}, state), {}, {
3144
3172
  displayedDay: nextCurrentDay ? dayFormatter(nextCurrentDay) : state.displayedDay
3145
3173
  });
3146
3174
  }
3147
3175
  case 'month-blur':
3148
3176
  {
3149
- var _minDate = state.minDate,
3150
- _maxDate = state.maxDate;
3151
- var nextCurrentMonth = getMonthInInterval(state.currentMonth, _minDate, _maxDate);
3177
+ var minDate = state.minDate,
3178
+ maxDate = state.maxDate;
3179
+ var nextCurrentMonth = getMonthInInterval(state.currentMonth, minDate, maxDate);
3152
3180
  return _objectSpread(_objectSpread({}, state), {}, {
3153
3181
  currentMonth: nextCurrentMonth,
3154
3182
  displayedMonth: nextCurrentMonth !== undefined ? monthFormatter(nextCurrentMonth) : state.displayedMonth
@@ -3156,9 +3184,9 @@ var keyboardDatePickerReducer = function (state, action) {
3156
3184
  }
3157
3185
  case 'year-blur':
3158
3186
  {
3159
- var _minDate2 = state.minDate,
3160
- _maxDate2 = state.maxDate;
3161
- var nextCurrentYear = getYearInInterval(state.currentYear, _minDate2, _maxDate2);
3187
+ var _minDate = state.minDate,
3188
+ _maxDate = state.maxDate;
3189
+ var nextCurrentYear = getYearInInterval(state.currentYear, _minDate, _maxDate);
3162
3190
  return _objectSpread(_objectSpread({}, state), {}, {
3163
3191
  currentYear: nextCurrentYear,
3164
3192
  displayedYear: nextCurrentYear !== undefined ? yearFormatter(nextCurrentYear) : state.displayedYear