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