@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.
@@ -3433,10 +3433,8 @@ function yearFormatter(year) {
3433
3433
  return prefixWithZero(year, 4);
3434
3434
  }
3435
3435
 
3436
- function getDayInInterval(value, minDate, maxDate) {
3437
- var minValue = minDate ? minDate.getDate() : 1;
3438
- var maxValue = maxDate ? maxDate.getDate() : 31;
3439
- return value !== undefined ? Math.max(minValue, Math.min(maxValue, value)) : value;
3436
+ function getDayInInterval(value) {
3437
+ return value !== undefined ? Math.max(1, Math.min(31, value)) : value;
3440
3438
  }
3441
3439
  function getMonthInInterval(value, minDate, maxDate) {
3442
3440
  var minValue = minDate ? minDate.getMonth() + 1 : 1;
@@ -3461,6 +3459,8 @@ function onDatePartChange(_ref) {
3461
3459
  year = _ref.year,
3462
3460
  _ref$validYearMinLeng = _ref.validYearMinLength,
3463
3461
  validYearMinLength = _ref$validYearMinLeng === void 0 ? 4 : _ref$validYearMinLeng,
3462
+ minDate = _ref.minDate,
3463
+ maxDate = _ref.maxDate,
3464
3464
  onChange = _ref.onChange,
3465
3465
  onBlur = _ref.onBlur,
3466
3466
  onFocus = _ref.onFocus;
@@ -3494,6 +3494,32 @@ function onDatePartChange(_ref) {
3494
3494
  nextValue.setHours(0);
3495
3495
  nextValue.setSeconds(0);
3496
3496
  nextValue.setMilliseconds(0);
3497
+ if (minDate) {
3498
+ minDate.setMinutes(0);
3499
+ minDate.setHours(0);
3500
+ minDate.setSeconds(0);
3501
+ minDate.setMilliseconds(0);
3502
+ var isMinDateAfterNextValue = minDate.getTime() > nextValue.getTime();
3503
+ if (isMinDateAfterNextValue) {
3504
+ if (onFocus) onFocus();
3505
+ onChange(undefined);
3506
+ if (onBlur) onBlur();
3507
+ return;
3508
+ }
3509
+ }
3510
+ if (maxDate) {
3511
+ maxDate.setMinutes(0);
3512
+ maxDate.setHours(0);
3513
+ maxDate.setSeconds(0);
3514
+ maxDate.setMilliseconds(0);
3515
+ var isMaxDateBeforeNextValue = nextValue.getTime() > maxDate.getTime();
3516
+ if (isMaxDateBeforeNextValue) {
3517
+ if (onFocus) onFocus();
3518
+ onChange(undefined);
3519
+ if (onBlur) onBlur();
3520
+ return;
3521
+ }
3522
+ }
3497
3523
  if (onFocus) onFocus();
3498
3524
  onChange(nextValue);
3499
3525
  if (onBlur) onBlur();
@@ -3508,11 +3534,15 @@ var keyboardDatePickerReducer = function (state, action) {
3508
3534
  var handleChange = function (dateParts) {
3509
3535
  var onFocus = state.onFocus,
3510
3536
  onBlur = state.onBlur,
3511
- onChange = state.onChange;
3537
+ onChange = state.onChange,
3538
+ minDate = state.minDate,
3539
+ maxDate = state.maxDate;
3512
3540
  onDatePartChange(_objectSpread(_objectSpread({}, dateParts), {}, {
3513
3541
  onFocus: onFocus,
3514
3542
  onBlur: onBlur,
3515
- onChange: onChange
3543
+ onChange: onChange,
3544
+ minDate: minDate,
3545
+ maxDate: maxDate
3516
3546
  }));
3517
3547
  };
3518
3548
  switch (action.type) {
@@ -3575,18 +3605,16 @@ var keyboardDatePickerReducer = function (state, action) {
3575
3605
  }
3576
3606
  case 'day-blur':
3577
3607
  {
3578
- var minDate = state.minDate,
3579
- maxDate = state.maxDate;
3580
- var nextCurrentDay = getDayInInterval(state.currentDay, minDate, maxDate);
3608
+ var nextCurrentDay = getDayInInterval(state.currentDay);
3581
3609
  return _objectSpread(_objectSpread({}, state), {}, {
3582
3610
  displayedDay: nextCurrentDay ? dayFormatter(nextCurrentDay) : state.displayedDay
3583
3611
  });
3584
3612
  }
3585
3613
  case 'month-blur':
3586
3614
  {
3587
- var _minDate = state.minDate,
3588
- _maxDate = state.maxDate;
3589
- var nextCurrentMonth = getMonthInInterval(state.currentMonth, _minDate, _maxDate);
3615
+ var minDate = state.minDate,
3616
+ maxDate = state.maxDate;
3617
+ var nextCurrentMonth = getMonthInInterval(state.currentMonth, minDate, maxDate);
3590
3618
  return _objectSpread(_objectSpread({}, state), {}, {
3591
3619
  currentMonth: nextCurrentMonth,
3592
3620
  displayedMonth: nextCurrentMonth !== undefined ? monthFormatter(nextCurrentMonth) : state.displayedMonth
@@ -3594,9 +3622,9 @@ var keyboardDatePickerReducer = function (state, action) {
3594
3622
  }
3595
3623
  case 'year-blur':
3596
3624
  {
3597
- var _minDate2 = state.minDate,
3598
- _maxDate2 = state.maxDate;
3599
- var nextCurrentYear = getYearInInterval(state.currentYear, _minDate2, _maxDate2);
3625
+ var _minDate = state.minDate,
3626
+ _maxDate = state.maxDate;
3627
+ var nextCurrentYear = getYearInInterval(state.currentYear, _minDate, _maxDate);
3600
3628
  return _objectSpread(_objectSpread({}, state), {}, {
3601
3629
  currentYear: nextCurrentYear,
3602
3630
  displayedYear: nextCurrentYear !== undefined ? yearFormatter(nextCurrentYear) : state.displayedYear