@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.
@@ -3381,10 +3381,8 @@ function yearFormatter(year) {
3381
3381
  return prefixWithZero(year, 4);
3382
3382
  }
3383
3383
 
3384
- function getDayInInterval(value, minDate, maxDate) {
3385
- const minValue = minDate ? minDate.getDate() : 1;
3386
- const maxValue = maxDate ? maxDate.getDate() : 31;
3387
- return value !== undefined ? Math.max(minValue, Math.min(maxValue, value)) : value;
3384
+ function getDayInInterval(value) {
3385
+ return value !== undefined ? Math.max(1, Math.min(31, value)) : value;
3388
3386
  }
3389
3387
  function getMonthInInterval(value, minDate, maxDate) {
3390
3388
  const minValue = minDate ? minDate.getMonth() + 1 : 1;
@@ -3408,6 +3406,8 @@ function onDatePartChange({
3408
3406
  month,
3409
3407
  year,
3410
3408
  validYearMinLength = 4,
3409
+ minDate,
3410
+ maxDate,
3411
3411
  onChange,
3412
3412
  onBlur,
3413
3413
  onFocus
@@ -3440,6 +3440,32 @@ function onDatePartChange({
3440
3440
  nextValue.setHours(0);
3441
3441
  nextValue.setSeconds(0);
3442
3442
  nextValue.setMilliseconds(0);
3443
+ if (minDate) {
3444
+ minDate.setMinutes(0);
3445
+ minDate.setHours(0);
3446
+ minDate.setSeconds(0);
3447
+ minDate.setMilliseconds(0);
3448
+ const isMinDateAfterNextValue = minDate.getTime() > nextValue.getTime();
3449
+ if (isMinDateAfterNextValue) {
3450
+ if (onFocus) onFocus();
3451
+ onChange(undefined);
3452
+ if (onBlur) onBlur();
3453
+ return;
3454
+ }
3455
+ }
3456
+ if (maxDate) {
3457
+ maxDate.setMinutes(0);
3458
+ maxDate.setHours(0);
3459
+ maxDate.setSeconds(0);
3460
+ maxDate.setMilliseconds(0);
3461
+ const isMaxDateBeforeNextValue = nextValue.getTime() > maxDate.getTime();
3462
+ if (isMaxDateBeforeNextValue) {
3463
+ if (onFocus) onFocus();
3464
+ onChange(undefined);
3465
+ if (onBlur) onBlur();
3466
+ return;
3467
+ }
3468
+ }
3443
3469
  if (onFocus) onFocus();
3444
3470
  onChange(nextValue);
3445
3471
  if (onBlur) onBlur();
@@ -3455,13 +3481,17 @@ const keyboardDatePickerReducer = (state, action) => {
3455
3481
  const {
3456
3482
  onFocus,
3457
3483
  onBlur,
3458
- onChange
3484
+ onChange,
3485
+ minDate,
3486
+ maxDate
3459
3487
  } = state;
3460
3488
  onDatePartChange({
3461
3489
  ...dateParts,
3462
3490
  onFocus,
3463
3491
  onBlur,
3464
- onChange
3492
+ onChange,
3493
+ minDate,
3494
+ maxDate
3465
3495
  });
3466
3496
  };
3467
3497
  switch (action.type) {
@@ -3530,11 +3560,7 @@ const keyboardDatePickerReducer = (state, action) => {
3530
3560
  }
3531
3561
  case 'day-blur':
3532
3562
  {
3533
- const {
3534
- minDate,
3535
- maxDate
3536
- } = state;
3537
- const nextCurrentDay = getDayInInterval(state.currentDay, minDate, maxDate);
3563
+ const nextCurrentDay = getDayInInterval(state.currentDay);
3538
3564
  return {
3539
3565
  ...state,
3540
3566
  displayedDay: nextCurrentDay ? dayFormatter(nextCurrentDay) : state.displayedDay