@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.
@@ -2958,10 +2958,8 @@ function yearFormatter(year) {
2958
2958
  return prefixWithZero(year, 4);
2959
2959
  }
2960
2960
 
2961
- function getDayInInterval(value, minDate, maxDate) {
2962
- const minValue = minDate ? minDate.getDate() : 1;
2963
- const maxValue = maxDate ? maxDate.getDate() : 31;
2964
- return value !== undefined ? Math.max(minValue, Math.min(maxValue, value)) : value;
2961
+ function getDayInInterval(value) {
2962
+ return value !== undefined ? Math.max(1, Math.min(31, value)) : value;
2965
2963
  }
2966
2964
  function getMonthInInterval(value, minDate, maxDate) {
2967
2965
  const minValue = minDate ? minDate.getMonth() + 1 : 1;
@@ -2985,6 +2983,8 @@ function onDatePartChange({
2985
2983
  month,
2986
2984
  year,
2987
2985
  validYearMinLength = 4,
2986
+ minDate,
2987
+ maxDate,
2988
2988
  onChange,
2989
2989
  onBlur,
2990
2990
  onFocus
@@ -3017,6 +3017,32 @@ function onDatePartChange({
3017
3017
  nextValue.setHours(0);
3018
3018
  nextValue.setSeconds(0);
3019
3019
  nextValue.setMilliseconds(0);
3020
+ if (minDate) {
3021
+ minDate.setMinutes(0);
3022
+ minDate.setHours(0);
3023
+ minDate.setSeconds(0);
3024
+ minDate.setMilliseconds(0);
3025
+ const isMinDateAfterNextValue = minDate.getTime() > nextValue.getTime();
3026
+ if (isMinDateAfterNextValue) {
3027
+ if (onFocus) onFocus();
3028
+ onChange(undefined);
3029
+ if (onBlur) onBlur();
3030
+ return;
3031
+ }
3032
+ }
3033
+ if (maxDate) {
3034
+ maxDate.setMinutes(0);
3035
+ maxDate.setHours(0);
3036
+ maxDate.setSeconds(0);
3037
+ maxDate.setMilliseconds(0);
3038
+ const isMaxDateBeforeNextValue = nextValue.getTime() > maxDate.getTime();
3039
+ if (isMaxDateBeforeNextValue) {
3040
+ if (onFocus) onFocus();
3041
+ onChange(undefined);
3042
+ if (onBlur) onBlur();
3043
+ return;
3044
+ }
3045
+ }
3020
3046
  if (onFocus) onFocus();
3021
3047
  onChange(nextValue);
3022
3048
  if (onBlur) onBlur();
@@ -3032,13 +3058,17 @@ const keyboardDatePickerReducer = (state, action) => {
3032
3058
  const {
3033
3059
  onFocus,
3034
3060
  onBlur,
3035
- onChange
3061
+ onChange,
3062
+ minDate,
3063
+ maxDate
3036
3064
  } = state;
3037
3065
  onDatePartChange({
3038
3066
  ...dateParts,
3039
3067
  onFocus,
3040
3068
  onBlur,
3041
- onChange
3069
+ onChange,
3070
+ minDate,
3071
+ maxDate
3042
3072
  });
3043
3073
  };
3044
3074
  switch (action.type) {
@@ -3107,11 +3137,7 @@ const keyboardDatePickerReducer = (state, action) => {
3107
3137
  }
3108
3138
  case 'day-blur':
3109
3139
  {
3110
- const {
3111
- minDate,
3112
- maxDate
3113
- } = state;
3114
- const nextCurrentDay = getDayInInterval(state.currentDay, minDate, maxDate);
3140
+ const nextCurrentDay = getDayInInterval(state.currentDay);
3115
3141
  return {
3116
3142
  ...state,
3117
3143
  displayedDay: nextCurrentDay ? dayFormatter(nextCurrentDay) : state.displayedDay