@zendeskgarden/react-datepickers 8.49.1 → 8.49.4

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.
package/dist/index.cjs.js CHANGED
@@ -195,6 +195,9 @@ function _nonIterableRest() {
195
195
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
196
196
  }
197
197
 
198
+ var SHARED_PLACEMENT = ['auto', 'top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end'];
199
+ var PLACEMENT = [].concat(SHARED_PLACEMENT, ['end', 'end-top', 'end-bottom', 'start', 'start-top', 'start-bottom']);
200
+
198
201
  function getPopperPlacement(gardenPlacement) {
199
202
  switch (gardenPlacement) {
200
203
  case 'end':
@@ -416,7 +419,7 @@ function getDate(dirtyDate) {
416
419
  var COMPONENT_ID$b = 'datepickers.menu';
417
420
  var StyledMenu = styled__default["default"].div.attrs({
418
421
  'data-garden-id': COMPONENT_ID$b,
419
- 'data-garden-version': '8.49.1'
422
+ 'data-garden-version': '8.49.4'
420
423
  }).withConfig({
421
424
  displayName: "StyledMenu",
422
425
  componentId: "sc-1npbkk0-0"
@@ -3441,7 +3444,7 @@ Datepicker.propTypes = {
3441
3444
  isCompact: PropTypes__default["default"].bool,
3442
3445
  customParseDate: PropTypes__default["default"].any,
3443
3446
  refKey: PropTypes__default["default"].string,
3444
- placement: PropTypes__default["default"].oneOf(['auto', 'top', 'top-start', 'top-end', 'end', 'end-top', 'end-bottom', 'bottom', 'bottom-start', 'bottom-end', 'start', 'start-top', 'start-bottom']),
3447
+ placement: PropTypes__default["default"].oneOf(PLACEMENT),
3445
3448
  popperModifiers: PropTypes__default["default"].any,
3446
3449
  isAnimated: PropTypes__default["default"].bool,
3447
3450
  eventsEnabled: PropTypes__default["default"].bool,
@@ -3510,7 +3513,6 @@ var datepickerRangeReducer = function datepickerRangeReducer(_ref3) {
3510
3513
  endValue = _ref3.endValue,
3511
3514
  locale = _ref3.locale,
3512
3515
  formatDate = _ref3.formatDate,
3513
- onChange = _ref3.onChange,
3514
3516
  customParseDate = _ref3.customParseDate;
3515
3517
  return function (state, action) {
3516
3518
  switch (action.type) {
@@ -3556,12 +3558,6 @@ var datepickerRangeReducer = function datepickerRangeReducer(_ref3) {
3556
3558
  inputValue: state.startInputValue
3557
3559
  });
3558
3560
  }
3559
- if (onChange && parsedDate && isValid(parsedDate) && !isSameDay(parsedDate, startValue)) {
3560
- onChange({
3561
- startValue: parsedDate,
3562
- endValue: endValue
3563
- });
3564
- }
3565
3561
  var startInputValue = formatValue({
3566
3562
  value: parsedDate,
3567
3563
  locale: locale,
@@ -3586,12 +3582,6 @@ var datepickerRangeReducer = function datepickerRangeReducer(_ref3) {
3586
3582
  inputValue: state.endInputValue
3587
3583
  });
3588
3584
  }
3589
- if (onChange && _parsedDate && isValid(_parsedDate) && !isSameDay(_parsedDate, endValue)) {
3590
- onChange({
3591
- startValue: startValue,
3592
- endValue: _parsedDate
3593
- });
3594
- }
3595
3585
  var endInputValue = formatValue({
3596
3586
  value: _parsedDate,
3597
3587
  locale: locale,
@@ -3649,54 +3639,54 @@ var datepickerRangeReducer = function datepickerRangeReducer(_ref3) {
3649
3639
  });
3650
3640
  }
3651
3641
  case 'CLICK_DATE':
3652
- if (onChange) {
3653
- if (state.isStartFocused) {
3654
- if (endValue !== undefined && (isBefore(action.value, endValue) || isSameDay(action.value, endValue))) {
3655
- onChange({
3656
- startValue: action.value,
3657
- endValue: endValue
3658
- });
3659
- } else {
3660
- onChange({
3661
- startValue: action.value,
3662
- endValue: undefined
3663
- });
3664
- }
3665
- } else if (state.isEndFocused) {
3666
- if (startValue !== undefined && (isAfter(action.value, startValue) || isSameDay(action.value, startValue))) {
3667
- onChange({
3668
- startValue: startValue,
3669
- endValue: action.value
3670
- });
3671
- } else {
3672
- onChange({
3673
- startValue: action.value,
3674
- endValue: undefined
3675
- });
3676
- }
3677
- } else if (startValue === undefined) {
3678
- onChange({
3679
- startValue: action.value,
3680
- endValue: undefined
3642
+ if (state.isStartFocused) {
3643
+ if (endValue !== undefined && (isBefore(action.value, endValue) || isSameDay(action.value, endValue))) {
3644
+ return _objectSpread2(_objectSpread2({}, state), {}, {
3645
+ startInputValue: formatValue({
3646
+ value: action.value
3647
+ })
3681
3648
  });
3682
- } else if (endValue === undefined) {
3683
- if (isBefore(action.value, startValue)) {
3684
- onChange({
3685
- startValue: action.value,
3686
- endValue: undefined
3687
- });
3688
- } else {
3689
- onChange({
3690
- startValue: startValue,
3691
- endValue: action.value
3692
- });
3693
- }
3694
- } else {
3695
- onChange({
3696
- startValue: action.value,
3697
- endValue: undefined
3649
+ }
3650
+ return _objectSpread2(_objectSpread2({}, state), {}, {
3651
+ startInputValue: formatValue({
3652
+ value: action.value
3653
+ }),
3654
+ endInputValue: undefined
3655
+ });
3656
+ } else if (state.isEndFocused) {
3657
+ if (startValue !== undefined && (isAfter(action.value, startValue) || isSameDay(action.value, startValue))) {
3658
+ return _objectSpread2(_objectSpread2({}, state), {}, {
3659
+ endInputValue: formatValue({
3660
+ value: action.value
3661
+ })
3662
+ });
3663
+ }
3664
+ return _objectSpread2(_objectSpread2({}, state), {}, {
3665
+ startInputValue: formatValue({
3666
+ value: action.value
3667
+ })
3668
+ });
3669
+ } else if (startValue === undefined) {
3670
+ return _objectSpread2(_objectSpread2({}, state), {}, {
3671
+ startInputValue: formatValue({
3672
+ value: action.value
3673
+ }),
3674
+ endInputValue: undefined
3675
+ });
3676
+ } else if (endValue === undefined) {
3677
+ if (isBefore(action.value, startValue)) {
3678
+ return _objectSpread2(_objectSpread2({}, state), {}, {
3679
+ startInputValue: formatValue({
3680
+ value: action.value
3681
+ }),
3682
+ endInputValue: undefined
3698
3683
  });
3699
3684
  }
3685
+ return _objectSpread2(_objectSpread2({}, state), {}, {
3686
+ endInputValue: formatValue({
3687
+ value: action.value
3688
+ })
3689
+ });
3700
3690
  }
3701
3691
  return state;
3702
3692
  case 'START_INPUT_ONCHANGE':
@@ -3769,7 +3759,11 @@ var Start = function Start(props) {
3769
3759
  var _useDatepickerRangeCo = useDatepickerContext(),
3770
3760
  state = _useDatepickerRangeCo.state,
3771
3761
  dispatch = _useDatepickerRangeCo.dispatch,
3772
- startInputRef = _useDatepickerRangeCo.startInputRef;
3762
+ onChange = _useDatepickerRangeCo.onChange,
3763
+ startValue = _useDatepickerRangeCo.startValue,
3764
+ endValue = _useDatepickerRangeCo.endValue,
3765
+ startInputRef = _useDatepickerRangeCo.startInputRef,
3766
+ customParseDate = _useDatepickerRangeCo.customParseDate;
3773
3767
  var onChangeCallback = React.useCallback(function (e) {
3774
3768
  dispatch({
3775
3769
  type: 'START_INPUT_ONCHANGE',
@@ -3783,24 +3777,39 @@ var Start = function Start(props) {
3783
3777
  });
3784
3778
  props.children.props.onFocus && props.children.props.onFocus(e);
3785
3779
  }, [dispatch, props.children]);
3780
+ var handleBlur = React.useCallback(function () {
3781
+ var parsedDate;
3782
+ if (customParseDate) {
3783
+ parsedDate = customParseDate(state.startInputValue);
3784
+ } else {
3785
+ parsedDate = parseInputValue({
3786
+ inputValue: state.startInputValue
3787
+ });
3788
+ }
3789
+ dispatch({
3790
+ type: 'START_BLUR'
3791
+ });
3792
+ if (parsedDate && isValid(parsedDate) && !isSameDay(parsedDate, startValue)) {
3793
+ onChange && onChange({
3794
+ startValue: parsedDate,
3795
+ endValue: endValue
3796
+ });
3797
+ }
3798
+ }, [dispatch, onChange, startValue, endValue, customParseDate, state.startInputValue]);
3786
3799
  var onKeyDownCallback = React.useCallback(function (e) {
3787
3800
  if (e.keyCode === containerUtilities.KEY_CODES.ENTER) {
3788
- dispatch({
3789
- type: 'START_BLUR'
3790
- });
3791
3801
  e.preventDefault();
3802
+ handleBlur();
3792
3803
  }
3793
3804
  props.children.props.onKeyDown && props.children.props.onKeyDown(e);
3794
- }, [dispatch, props.children]);
3805
+ }, [handleBlur, props.children]);
3795
3806
  var onBlurCallback = React.useCallback(function (e) {
3796
- dispatch({
3797
- type: 'START_BLUR'
3798
- });
3807
+ handleBlur();
3799
3808
  props.children.props.onBlur && props.children.props.onBlur(e);
3800
- }, [dispatch, props.children]);
3809
+ }, [handleBlur, props.children]);
3801
3810
  var childElement = React__default["default"].Children.only(props.children);
3802
3811
  return React__default["default"].cloneElement(childElement, {
3803
- value: state.startInputValue,
3812
+ value: state.startInputValue || '',
3804
3813
  ref: startInputRef,
3805
3814
  onChange: containerUtilities.composeEventHandlers(childElement.props.onChange, onChangeCallback),
3806
3815
  onFocus: containerUtilities.composeEventHandlers(childElement.props.onFocus, onFocusCallback),
@@ -3814,7 +3823,11 @@ var End = function End(props) {
3814
3823
  var _useDatepickerRangeCo = useDatepickerContext(),
3815
3824
  state = _useDatepickerRangeCo.state,
3816
3825
  dispatch = _useDatepickerRangeCo.dispatch,
3817
- endInputRef = _useDatepickerRangeCo.endInputRef;
3826
+ onChange = _useDatepickerRangeCo.onChange,
3827
+ startValue = _useDatepickerRangeCo.startValue,
3828
+ endValue = _useDatepickerRangeCo.endValue,
3829
+ endInputRef = _useDatepickerRangeCo.endInputRef,
3830
+ customParseDate = _useDatepickerRangeCo.customParseDate;
3818
3831
  var onChangeCallback = React.useCallback(function (e) {
3819
3832
  dispatch({
3820
3833
  type: 'END_INPUT_ONCHANGE',
@@ -3828,24 +3841,39 @@ var End = function End(props) {
3828
3841
  });
3829
3842
  props.children.props.onFocus && props.children.props.onFocus(e);
3830
3843
  }, [dispatch, props.children]);
3844
+ var handleBlur = React.useCallback(function () {
3845
+ dispatch({
3846
+ type: 'END_BLUR'
3847
+ });
3848
+ var parsedDate;
3849
+ if (customParseDate) {
3850
+ parsedDate = customParseDate(state.endInputValue);
3851
+ } else {
3852
+ parsedDate = parseInputValue({
3853
+ inputValue: state.endInputValue
3854
+ });
3855
+ }
3856
+ if (onChange && parsedDate && isValid(parsedDate) && !isSameDay(parsedDate, endValue)) {
3857
+ onChange && onChange({
3858
+ startValue: startValue,
3859
+ endValue: parsedDate
3860
+ });
3861
+ }
3862
+ }, [dispatch, onChange, startValue, endValue, customParseDate, state.endInputValue]);
3831
3863
  var onKeydownCallback = React.useCallback(function (e) {
3832
3864
  if (e.keyCode === containerUtilities.KEY_CODES.ENTER) {
3833
- dispatch({
3834
- type: 'END_BLUR'
3835
- });
3865
+ handleBlur();
3836
3866
  e.preventDefault();
3837
3867
  }
3838
3868
  props.children.props.onKeyDown && props.children.props.onKeyDown(e);
3839
- }, [dispatch, props.children]);
3869
+ }, [handleBlur, props.children]);
3840
3870
  var onBlurCallback = React.useCallback(function (e) {
3841
- dispatch({
3842
- type: 'END_BLUR'
3843
- });
3871
+ handleBlur();
3844
3872
  props.children.props.onBlur && props.children.props.onBlur(e);
3845
- }, [dispatch, props.children]);
3873
+ }, [handleBlur, props.children]);
3846
3874
  var childElement = React__default["default"].Children.only(props.children);
3847
3875
  return React__default["default"].cloneElement(childElement, {
3848
- value: state.endInputValue,
3876
+ value: state.endInputValue || '',
3849
3877
  ref: endInputRef,
3850
3878
  onChange: containerUtilities.composeEventHandlers(childElement.props.onChange, onChangeCallback),
3851
3879
  onFocus: containerUtilities.composeEventHandlers(childElement.props.onFocus, onFocusCallback),
@@ -3862,17 +3890,19 @@ function subDays(dirtyDate, dirtyAmount) {
3862
3890
  }
3863
3891
 
3864
3892
  var Month = React.forwardRef(function (_ref, ref) {
3865
- var locale = _ref.locale,
3866
- displayDate = _ref.displayDate,
3867
- isCompact = _ref.isCompact,
3893
+ var displayDate = _ref.displayDate,
3868
3894
  isPreviousHidden = _ref.isPreviousHidden,
3869
- isNextHidden = _ref.isNextHidden,
3870
- dispatch = _ref.dispatch,
3871
- minValue = _ref.minValue,
3872
- maxValue = _ref.maxValue,
3873
- startValue = _ref.startValue,
3874
- endValue = _ref.endValue,
3875
- hoverDate = _ref.hoverDate;
3895
+ isNextHidden = _ref.isNextHidden;
3896
+ var _useDatepickerRangeCo = useDatepickerContext(),
3897
+ state = _useDatepickerRangeCo.state,
3898
+ dispatch = _useDatepickerRangeCo.dispatch,
3899
+ locale = _useDatepickerRangeCo.locale,
3900
+ isCompact = _useDatepickerRangeCo.isCompact,
3901
+ minValue = _useDatepickerRangeCo.minValue,
3902
+ maxValue = _useDatepickerRangeCo.maxValue,
3903
+ startValue = _useDatepickerRangeCo.startValue,
3904
+ endValue = _useDatepickerRangeCo.endValue,
3905
+ onChange = _useDatepickerRangeCo.onChange;
3876
3906
  var headerLabelFormatter = React.useCallback(function (date) {
3877
3907
  var formatter = new Intl.DateTimeFormat(locale, {
3878
3908
  month: 'long',
@@ -3947,11 +3977,11 @@ var Month = React.forwardRef(function (_ref, ref) {
3947
3977
  var isHighlighted = false;
3948
3978
  if (startValue !== undefined && endValue !== undefined) {
3949
3979
  isHighlighted = (isAfter(date, startValue) || isSameDay(date, startValue)) && (isBefore(date, endValue) || isSameDay(date, endValue)) && !isSameDay(startValue, endValue);
3950
- } else if (startValue !== undefined && hoverDate !== undefined) {
3951
- isHighlighted = (isAfter(date, startValue) || isSameDay(date, startValue)) && (isBefore(date, hoverDate) || isSameDay(date, hoverDate));
3980
+ } else if (startValue !== undefined && state.hoverDate !== undefined) {
3981
+ isHighlighted = (isAfter(date, startValue) || isSameDay(date, startValue)) && (isBefore(date, state.hoverDate) || isSameDay(date, state.hoverDate));
3952
3982
  }
3953
3983
  var isHighlightStart = isHighlighted && startValue && isSameDay(date, startValue) || false;
3954
- var isHighlightEnd = isHighlighted && endValue && isSameDay(date, endValue) || hoverDate && isSameDay(date, hoverDate) && !isBefore(date, endValue) || false;
3984
+ var isHighlightEnd = isHighlighted && endValue && isSameDay(date, endValue) || state.hoverDate && isSameDay(date, state.hoverDate) && !isBefore(date, endValue) || false;
3955
3985
  var isInvalidDateRange = endValue && startValue && compareAsc(endValue, startValue) === -1 || false;
3956
3986
  if (minValue) {
3957
3987
  if (startValue) {
@@ -3988,6 +4018,55 @@ var Month = React.forwardRef(function (_ref, ref) {
3988
4018
  type: 'CLICK_DATE',
3989
4019
  value: date
3990
4020
  });
4021
+ if (onChange) {
4022
+ if (state.isStartFocused) {
4023
+ if (endValue !== undefined && (isBefore(date, endValue) || isSameDay(date, endValue))) {
4024
+ onChange({
4025
+ startValue: date,
4026
+ endValue: endValue
4027
+ });
4028
+ } else {
4029
+ onChange({
4030
+ startValue: date,
4031
+ endValue: undefined
4032
+ });
4033
+ }
4034
+ } else if (state.isEndFocused) {
4035
+ if (startValue !== undefined && (isAfter(date, startValue) || isSameDay(date, startValue))) {
4036
+ onChange({
4037
+ startValue: startValue,
4038
+ endValue: date
4039
+ });
4040
+ } else {
4041
+ onChange({
4042
+ startValue: date,
4043
+ endValue: undefined
4044
+ });
4045
+ }
4046
+ } else if (startValue === undefined) {
4047
+ onChange({
4048
+ startValue: date,
4049
+ endValue: undefined
4050
+ });
4051
+ } else if (endValue === undefined) {
4052
+ if (isBefore(date, startValue)) {
4053
+ onChange({
4054
+ startValue: date,
4055
+ endValue: undefined
4056
+ });
4057
+ } else {
4058
+ onChange({
4059
+ startValue: startValue,
4060
+ endValue: date
4061
+ });
4062
+ }
4063
+ } else {
4064
+ onChange({
4065
+ startValue: date,
4066
+ endValue: undefined
4067
+ });
4068
+ }
4069
+ }
3991
4070
  }
3992
4071
  },
3993
4072
  onMouseEnter: function onMouseEnter() {
@@ -4040,43 +4119,17 @@ Month.displayName = 'Month';
4040
4119
 
4041
4120
  var Calendar = React.forwardRef(function (props, ref) {
4042
4121
  var _useDatepickerRangeCo = useDatepickerContext(),
4043
- state = _useDatepickerRangeCo.state,
4044
- dispatch = _useDatepickerRangeCo.dispatch,
4045
- locale = _useDatepickerRangeCo.locale,
4046
- isCompact = _useDatepickerRangeCo.isCompact,
4047
- minValue = _useDatepickerRangeCo.minValue,
4048
- maxValue = _useDatepickerRangeCo.maxValue,
4049
- startValue = _useDatepickerRangeCo.startValue,
4050
- endValue = _useDatepickerRangeCo.endValue,
4051
- onChange = _useDatepickerRangeCo.onChange;
4122
+ state = _useDatepickerRangeCo.state;
4052
4123
  return React__default["default"].createElement(StyledRangeCalendar, _extends$2({
4053
4124
  ref: ref,
4054
4125
  "data-garden-id": "datepickers.range",
4055
- "data-garden-version": '8.49.1'
4126
+ "data-garden-version": '8.49.4'
4056
4127
  }, props), React__default["default"].createElement(Month, {
4057
- locale: locale,
4058
4128
  displayDate: state.previewDate,
4059
- isCompact: isCompact,
4060
- isNextHidden: true,
4061
- dispatch: dispatch,
4062
- minValue: minValue,
4063
- maxValue: maxValue,
4064
- startValue: startValue,
4065
- endValue: endValue,
4066
- onChange: onChange,
4067
- hoverDate: state.hoverDate
4129
+ isNextHidden: true
4068
4130
  }), React__default["default"].createElement(Month, {
4069
- locale: locale,
4070
4131
  displayDate: addMonths(state.previewDate, 1),
4071
- isCompact: isCompact,
4072
- isPreviousHidden: true,
4073
- dispatch: dispatch,
4074
- minValue: minValue,
4075
- maxValue: maxValue,
4076
- startValue: startValue,
4077
- endValue: endValue,
4078
- onChange: onChange,
4079
- hoverDate: state.hoverDate
4132
+ isPreviousHidden: true
4080
4133
  }));
4081
4134
  });
4082
4135
  Calendar.displayName = 'DatepickerRange.Calendar';
@@ -4097,7 +4150,6 @@ var DatepickerRangeComponent = function DatepickerRangeComponent(props) {
4097
4150
  locale: locale,
4098
4151
  formatDate: formatDate,
4099
4152
  endValue: endValue,
4100
- onChange: onChange,
4101
4153
  customParseDate: customParseDate
4102
4154
  }), [startValue, endValue, locale, formatDate, onChange, customParseDate]);
4103
4155
  var _useReducer = React.useReducer(reducer, retrieveInitialState(props)),
@@ -4140,9 +4192,10 @@ var DatepickerRangeComponent = function DatepickerRangeComponent(props) {
4140
4192
  endValue: endValue,
4141
4193
  onChange: onChange,
4142
4194
  startInputRef: startInputRef,
4143
- endInputRef: endInputRef
4195
+ endInputRef: endInputRef,
4196
+ customParseDate: customParseDate
4144
4197
  };
4145
- }, [state, dispatch, isCompact, locale, minValue, maxValue, startValue, endValue, onChange, startInputRef, endInputRef]);
4198
+ }, [state, dispatch, isCompact, locale, minValue, maxValue, startValue, endValue, onChange, startInputRef, endInputRef, customParseDate]);
4146
4199
  return React__default["default"].createElement(DatepickerRangeContext.Provider, {
4147
4200
  value: value
4148
4201
  }, children);
package/dist/index.esm.js CHANGED
@@ -167,6 +167,9 @@ function _nonIterableRest() {
167
167
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
168
168
  }
169
169
 
170
+ var SHARED_PLACEMENT = ['auto', 'top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end'];
171
+ var PLACEMENT = [].concat(SHARED_PLACEMENT, ['end', 'end-top', 'end-bottom', 'start', 'start-top', 'start-bottom']);
172
+
170
173
  function getPopperPlacement(gardenPlacement) {
171
174
  switch (gardenPlacement) {
172
175
  case 'end':
@@ -388,7 +391,7 @@ function getDate(dirtyDate) {
388
391
  var COMPONENT_ID$b = 'datepickers.menu';
389
392
  var StyledMenu = styled.div.attrs({
390
393
  'data-garden-id': COMPONENT_ID$b,
391
- 'data-garden-version': '8.49.1'
394
+ 'data-garden-version': '8.49.4'
392
395
  }).withConfig({
393
396
  displayName: "StyledMenu",
394
397
  componentId: "sc-1npbkk0-0"
@@ -3413,7 +3416,7 @@ Datepicker.propTypes = {
3413
3416
  isCompact: PropTypes.bool,
3414
3417
  customParseDate: PropTypes.any,
3415
3418
  refKey: PropTypes.string,
3416
- placement: PropTypes.oneOf(['auto', 'top', 'top-start', 'top-end', 'end', 'end-top', 'end-bottom', 'bottom', 'bottom-start', 'bottom-end', 'start', 'start-top', 'start-bottom']),
3419
+ placement: PropTypes.oneOf(PLACEMENT),
3417
3420
  popperModifiers: PropTypes.any,
3418
3421
  isAnimated: PropTypes.bool,
3419
3422
  eventsEnabled: PropTypes.bool,
@@ -3482,7 +3485,6 @@ var datepickerRangeReducer = function datepickerRangeReducer(_ref3) {
3482
3485
  endValue = _ref3.endValue,
3483
3486
  locale = _ref3.locale,
3484
3487
  formatDate = _ref3.formatDate,
3485
- onChange = _ref3.onChange,
3486
3488
  customParseDate = _ref3.customParseDate;
3487
3489
  return function (state, action) {
3488
3490
  switch (action.type) {
@@ -3528,12 +3530,6 @@ var datepickerRangeReducer = function datepickerRangeReducer(_ref3) {
3528
3530
  inputValue: state.startInputValue
3529
3531
  });
3530
3532
  }
3531
- if (onChange && parsedDate && isValid(parsedDate) && !isSameDay(parsedDate, startValue)) {
3532
- onChange({
3533
- startValue: parsedDate,
3534
- endValue: endValue
3535
- });
3536
- }
3537
3533
  var startInputValue = formatValue({
3538
3534
  value: parsedDate,
3539
3535
  locale: locale,
@@ -3558,12 +3554,6 @@ var datepickerRangeReducer = function datepickerRangeReducer(_ref3) {
3558
3554
  inputValue: state.endInputValue
3559
3555
  });
3560
3556
  }
3561
- if (onChange && _parsedDate && isValid(_parsedDate) && !isSameDay(_parsedDate, endValue)) {
3562
- onChange({
3563
- startValue: startValue,
3564
- endValue: _parsedDate
3565
- });
3566
- }
3567
3557
  var endInputValue = formatValue({
3568
3558
  value: _parsedDate,
3569
3559
  locale: locale,
@@ -3621,54 +3611,54 @@ var datepickerRangeReducer = function datepickerRangeReducer(_ref3) {
3621
3611
  });
3622
3612
  }
3623
3613
  case 'CLICK_DATE':
3624
- if (onChange) {
3625
- if (state.isStartFocused) {
3626
- if (endValue !== undefined && (isBefore(action.value, endValue) || isSameDay(action.value, endValue))) {
3627
- onChange({
3628
- startValue: action.value,
3629
- endValue: endValue
3630
- });
3631
- } else {
3632
- onChange({
3633
- startValue: action.value,
3634
- endValue: undefined
3635
- });
3636
- }
3637
- } else if (state.isEndFocused) {
3638
- if (startValue !== undefined && (isAfter(action.value, startValue) || isSameDay(action.value, startValue))) {
3639
- onChange({
3640
- startValue: startValue,
3641
- endValue: action.value
3642
- });
3643
- } else {
3644
- onChange({
3645
- startValue: action.value,
3646
- endValue: undefined
3647
- });
3648
- }
3649
- } else if (startValue === undefined) {
3650
- onChange({
3651
- startValue: action.value,
3652
- endValue: undefined
3614
+ if (state.isStartFocused) {
3615
+ if (endValue !== undefined && (isBefore(action.value, endValue) || isSameDay(action.value, endValue))) {
3616
+ return _objectSpread2(_objectSpread2({}, state), {}, {
3617
+ startInputValue: formatValue({
3618
+ value: action.value
3619
+ })
3653
3620
  });
3654
- } else if (endValue === undefined) {
3655
- if (isBefore(action.value, startValue)) {
3656
- onChange({
3657
- startValue: action.value,
3658
- endValue: undefined
3659
- });
3660
- } else {
3661
- onChange({
3662
- startValue: startValue,
3663
- endValue: action.value
3664
- });
3665
- }
3666
- } else {
3667
- onChange({
3668
- startValue: action.value,
3669
- endValue: undefined
3621
+ }
3622
+ return _objectSpread2(_objectSpread2({}, state), {}, {
3623
+ startInputValue: formatValue({
3624
+ value: action.value
3625
+ }),
3626
+ endInputValue: undefined
3627
+ });
3628
+ } else if (state.isEndFocused) {
3629
+ if (startValue !== undefined && (isAfter(action.value, startValue) || isSameDay(action.value, startValue))) {
3630
+ return _objectSpread2(_objectSpread2({}, state), {}, {
3631
+ endInputValue: formatValue({
3632
+ value: action.value
3633
+ })
3634
+ });
3635
+ }
3636
+ return _objectSpread2(_objectSpread2({}, state), {}, {
3637
+ startInputValue: formatValue({
3638
+ value: action.value
3639
+ })
3640
+ });
3641
+ } else if (startValue === undefined) {
3642
+ return _objectSpread2(_objectSpread2({}, state), {}, {
3643
+ startInputValue: formatValue({
3644
+ value: action.value
3645
+ }),
3646
+ endInputValue: undefined
3647
+ });
3648
+ } else if (endValue === undefined) {
3649
+ if (isBefore(action.value, startValue)) {
3650
+ return _objectSpread2(_objectSpread2({}, state), {}, {
3651
+ startInputValue: formatValue({
3652
+ value: action.value
3653
+ }),
3654
+ endInputValue: undefined
3670
3655
  });
3671
3656
  }
3657
+ return _objectSpread2(_objectSpread2({}, state), {}, {
3658
+ endInputValue: formatValue({
3659
+ value: action.value
3660
+ })
3661
+ });
3672
3662
  }
3673
3663
  return state;
3674
3664
  case 'START_INPUT_ONCHANGE':
@@ -3741,7 +3731,11 @@ var Start = function Start(props) {
3741
3731
  var _useDatepickerRangeCo = useDatepickerContext(),
3742
3732
  state = _useDatepickerRangeCo.state,
3743
3733
  dispatch = _useDatepickerRangeCo.dispatch,
3744
- startInputRef = _useDatepickerRangeCo.startInputRef;
3734
+ onChange = _useDatepickerRangeCo.onChange,
3735
+ startValue = _useDatepickerRangeCo.startValue,
3736
+ endValue = _useDatepickerRangeCo.endValue,
3737
+ startInputRef = _useDatepickerRangeCo.startInputRef,
3738
+ customParseDate = _useDatepickerRangeCo.customParseDate;
3745
3739
  var onChangeCallback = useCallback(function (e) {
3746
3740
  dispatch({
3747
3741
  type: 'START_INPUT_ONCHANGE',
@@ -3755,24 +3749,39 @@ var Start = function Start(props) {
3755
3749
  });
3756
3750
  props.children.props.onFocus && props.children.props.onFocus(e);
3757
3751
  }, [dispatch, props.children]);
3752
+ var handleBlur = useCallback(function () {
3753
+ var parsedDate;
3754
+ if (customParseDate) {
3755
+ parsedDate = customParseDate(state.startInputValue);
3756
+ } else {
3757
+ parsedDate = parseInputValue({
3758
+ inputValue: state.startInputValue
3759
+ });
3760
+ }
3761
+ dispatch({
3762
+ type: 'START_BLUR'
3763
+ });
3764
+ if (parsedDate && isValid(parsedDate) && !isSameDay(parsedDate, startValue)) {
3765
+ onChange && onChange({
3766
+ startValue: parsedDate,
3767
+ endValue: endValue
3768
+ });
3769
+ }
3770
+ }, [dispatch, onChange, startValue, endValue, customParseDate, state.startInputValue]);
3758
3771
  var onKeyDownCallback = useCallback(function (e) {
3759
3772
  if (e.keyCode === KEY_CODES.ENTER) {
3760
- dispatch({
3761
- type: 'START_BLUR'
3762
- });
3763
3773
  e.preventDefault();
3774
+ handleBlur();
3764
3775
  }
3765
3776
  props.children.props.onKeyDown && props.children.props.onKeyDown(e);
3766
- }, [dispatch, props.children]);
3777
+ }, [handleBlur, props.children]);
3767
3778
  var onBlurCallback = useCallback(function (e) {
3768
- dispatch({
3769
- type: 'START_BLUR'
3770
- });
3779
+ handleBlur();
3771
3780
  props.children.props.onBlur && props.children.props.onBlur(e);
3772
- }, [dispatch, props.children]);
3781
+ }, [handleBlur, props.children]);
3773
3782
  var childElement = React__default.Children.only(props.children);
3774
3783
  return React__default.cloneElement(childElement, {
3775
- value: state.startInputValue,
3784
+ value: state.startInputValue || '',
3776
3785
  ref: startInputRef,
3777
3786
  onChange: composeEventHandlers(childElement.props.onChange, onChangeCallback),
3778
3787
  onFocus: composeEventHandlers(childElement.props.onFocus, onFocusCallback),
@@ -3786,7 +3795,11 @@ var End = function End(props) {
3786
3795
  var _useDatepickerRangeCo = useDatepickerContext(),
3787
3796
  state = _useDatepickerRangeCo.state,
3788
3797
  dispatch = _useDatepickerRangeCo.dispatch,
3789
- endInputRef = _useDatepickerRangeCo.endInputRef;
3798
+ onChange = _useDatepickerRangeCo.onChange,
3799
+ startValue = _useDatepickerRangeCo.startValue,
3800
+ endValue = _useDatepickerRangeCo.endValue,
3801
+ endInputRef = _useDatepickerRangeCo.endInputRef,
3802
+ customParseDate = _useDatepickerRangeCo.customParseDate;
3790
3803
  var onChangeCallback = useCallback(function (e) {
3791
3804
  dispatch({
3792
3805
  type: 'END_INPUT_ONCHANGE',
@@ -3800,24 +3813,39 @@ var End = function End(props) {
3800
3813
  });
3801
3814
  props.children.props.onFocus && props.children.props.onFocus(e);
3802
3815
  }, [dispatch, props.children]);
3816
+ var handleBlur = useCallback(function () {
3817
+ dispatch({
3818
+ type: 'END_BLUR'
3819
+ });
3820
+ var parsedDate;
3821
+ if (customParseDate) {
3822
+ parsedDate = customParseDate(state.endInputValue);
3823
+ } else {
3824
+ parsedDate = parseInputValue({
3825
+ inputValue: state.endInputValue
3826
+ });
3827
+ }
3828
+ if (onChange && parsedDate && isValid(parsedDate) && !isSameDay(parsedDate, endValue)) {
3829
+ onChange && onChange({
3830
+ startValue: startValue,
3831
+ endValue: parsedDate
3832
+ });
3833
+ }
3834
+ }, [dispatch, onChange, startValue, endValue, customParseDate, state.endInputValue]);
3803
3835
  var onKeydownCallback = useCallback(function (e) {
3804
3836
  if (e.keyCode === KEY_CODES.ENTER) {
3805
- dispatch({
3806
- type: 'END_BLUR'
3807
- });
3837
+ handleBlur();
3808
3838
  e.preventDefault();
3809
3839
  }
3810
3840
  props.children.props.onKeyDown && props.children.props.onKeyDown(e);
3811
- }, [dispatch, props.children]);
3841
+ }, [handleBlur, props.children]);
3812
3842
  var onBlurCallback = useCallback(function (e) {
3813
- dispatch({
3814
- type: 'END_BLUR'
3815
- });
3843
+ handleBlur();
3816
3844
  props.children.props.onBlur && props.children.props.onBlur(e);
3817
- }, [dispatch, props.children]);
3845
+ }, [handleBlur, props.children]);
3818
3846
  var childElement = React__default.Children.only(props.children);
3819
3847
  return React__default.cloneElement(childElement, {
3820
- value: state.endInputValue,
3848
+ value: state.endInputValue || '',
3821
3849
  ref: endInputRef,
3822
3850
  onChange: composeEventHandlers(childElement.props.onChange, onChangeCallback),
3823
3851
  onFocus: composeEventHandlers(childElement.props.onFocus, onFocusCallback),
@@ -3834,17 +3862,19 @@ function subDays(dirtyDate, dirtyAmount) {
3834
3862
  }
3835
3863
 
3836
3864
  var Month = forwardRef(function (_ref, ref) {
3837
- var locale = _ref.locale,
3838
- displayDate = _ref.displayDate,
3839
- isCompact = _ref.isCompact,
3865
+ var displayDate = _ref.displayDate,
3840
3866
  isPreviousHidden = _ref.isPreviousHidden,
3841
- isNextHidden = _ref.isNextHidden,
3842
- dispatch = _ref.dispatch,
3843
- minValue = _ref.minValue,
3844
- maxValue = _ref.maxValue,
3845
- startValue = _ref.startValue,
3846
- endValue = _ref.endValue,
3847
- hoverDate = _ref.hoverDate;
3867
+ isNextHidden = _ref.isNextHidden;
3868
+ var _useDatepickerRangeCo = useDatepickerContext(),
3869
+ state = _useDatepickerRangeCo.state,
3870
+ dispatch = _useDatepickerRangeCo.dispatch,
3871
+ locale = _useDatepickerRangeCo.locale,
3872
+ isCompact = _useDatepickerRangeCo.isCompact,
3873
+ minValue = _useDatepickerRangeCo.minValue,
3874
+ maxValue = _useDatepickerRangeCo.maxValue,
3875
+ startValue = _useDatepickerRangeCo.startValue,
3876
+ endValue = _useDatepickerRangeCo.endValue,
3877
+ onChange = _useDatepickerRangeCo.onChange;
3848
3878
  var headerLabelFormatter = useCallback(function (date) {
3849
3879
  var formatter = new Intl.DateTimeFormat(locale, {
3850
3880
  month: 'long',
@@ -3919,11 +3949,11 @@ var Month = forwardRef(function (_ref, ref) {
3919
3949
  var isHighlighted = false;
3920
3950
  if (startValue !== undefined && endValue !== undefined) {
3921
3951
  isHighlighted = (isAfter(date, startValue) || isSameDay(date, startValue)) && (isBefore(date, endValue) || isSameDay(date, endValue)) && !isSameDay(startValue, endValue);
3922
- } else if (startValue !== undefined && hoverDate !== undefined) {
3923
- isHighlighted = (isAfter(date, startValue) || isSameDay(date, startValue)) && (isBefore(date, hoverDate) || isSameDay(date, hoverDate));
3952
+ } else if (startValue !== undefined && state.hoverDate !== undefined) {
3953
+ isHighlighted = (isAfter(date, startValue) || isSameDay(date, startValue)) && (isBefore(date, state.hoverDate) || isSameDay(date, state.hoverDate));
3924
3954
  }
3925
3955
  var isHighlightStart = isHighlighted && startValue && isSameDay(date, startValue) || false;
3926
- var isHighlightEnd = isHighlighted && endValue && isSameDay(date, endValue) || hoverDate && isSameDay(date, hoverDate) && !isBefore(date, endValue) || false;
3956
+ var isHighlightEnd = isHighlighted && endValue && isSameDay(date, endValue) || state.hoverDate && isSameDay(date, state.hoverDate) && !isBefore(date, endValue) || false;
3927
3957
  var isInvalidDateRange = endValue && startValue && compareAsc(endValue, startValue) === -1 || false;
3928
3958
  if (minValue) {
3929
3959
  if (startValue) {
@@ -3960,6 +3990,55 @@ var Month = forwardRef(function (_ref, ref) {
3960
3990
  type: 'CLICK_DATE',
3961
3991
  value: date
3962
3992
  });
3993
+ if (onChange) {
3994
+ if (state.isStartFocused) {
3995
+ if (endValue !== undefined && (isBefore(date, endValue) || isSameDay(date, endValue))) {
3996
+ onChange({
3997
+ startValue: date,
3998
+ endValue: endValue
3999
+ });
4000
+ } else {
4001
+ onChange({
4002
+ startValue: date,
4003
+ endValue: undefined
4004
+ });
4005
+ }
4006
+ } else if (state.isEndFocused) {
4007
+ if (startValue !== undefined && (isAfter(date, startValue) || isSameDay(date, startValue))) {
4008
+ onChange({
4009
+ startValue: startValue,
4010
+ endValue: date
4011
+ });
4012
+ } else {
4013
+ onChange({
4014
+ startValue: date,
4015
+ endValue: undefined
4016
+ });
4017
+ }
4018
+ } else if (startValue === undefined) {
4019
+ onChange({
4020
+ startValue: date,
4021
+ endValue: undefined
4022
+ });
4023
+ } else if (endValue === undefined) {
4024
+ if (isBefore(date, startValue)) {
4025
+ onChange({
4026
+ startValue: date,
4027
+ endValue: undefined
4028
+ });
4029
+ } else {
4030
+ onChange({
4031
+ startValue: startValue,
4032
+ endValue: date
4033
+ });
4034
+ }
4035
+ } else {
4036
+ onChange({
4037
+ startValue: date,
4038
+ endValue: undefined
4039
+ });
4040
+ }
4041
+ }
3963
4042
  }
3964
4043
  },
3965
4044
  onMouseEnter: function onMouseEnter() {
@@ -4012,43 +4091,17 @@ Month.displayName = 'Month';
4012
4091
 
4013
4092
  var Calendar = forwardRef(function (props, ref) {
4014
4093
  var _useDatepickerRangeCo = useDatepickerContext(),
4015
- state = _useDatepickerRangeCo.state,
4016
- dispatch = _useDatepickerRangeCo.dispatch,
4017
- locale = _useDatepickerRangeCo.locale,
4018
- isCompact = _useDatepickerRangeCo.isCompact,
4019
- minValue = _useDatepickerRangeCo.minValue,
4020
- maxValue = _useDatepickerRangeCo.maxValue,
4021
- startValue = _useDatepickerRangeCo.startValue,
4022
- endValue = _useDatepickerRangeCo.endValue,
4023
- onChange = _useDatepickerRangeCo.onChange;
4094
+ state = _useDatepickerRangeCo.state;
4024
4095
  return React__default.createElement(StyledRangeCalendar, _extends$2({
4025
4096
  ref: ref,
4026
4097
  "data-garden-id": "datepickers.range",
4027
- "data-garden-version": '8.49.1'
4098
+ "data-garden-version": '8.49.4'
4028
4099
  }, props), React__default.createElement(Month, {
4029
- locale: locale,
4030
4100
  displayDate: state.previewDate,
4031
- isCompact: isCompact,
4032
- isNextHidden: true,
4033
- dispatch: dispatch,
4034
- minValue: minValue,
4035
- maxValue: maxValue,
4036
- startValue: startValue,
4037
- endValue: endValue,
4038
- onChange: onChange,
4039
- hoverDate: state.hoverDate
4101
+ isNextHidden: true
4040
4102
  }), React__default.createElement(Month, {
4041
- locale: locale,
4042
4103
  displayDate: addMonths(state.previewDate, 1),
4043
- isCompact: isCompact,
4044
- isPreviousHidden: true,
4045
- dispatch: dispatch,
4046
- minValue: minValue,
4047
- maxValue: maxValue,
4048
- startValue: startValue,
4049
- endValue: endValue,
4050
- onChange: onChange,
4051
- hoverDate: state.hoverDate
4104
+ isPreviousHidden: true
4052
4105
  }));
4053
4106
  });
4054
4107
  Calendar.displayName = 'DatepickerRange.Calendar';
@@ -4069,7 +4122,6 @@ var DatepickerRangeComponent = function DatepickerRangeComponent(props) {
4069
4122
  locale: locale,
4070
4123
  formatDate: formatDate,
4071
4124
  endValue: endValue,
4072
- onChange: onChange,
4073
4125
  customParseDate: customParseDate
4074
4126
  }), [startValue, endValue, locale, formatDate, onChange, customParseDate]);
4075
4127
  var _useReducer = useReducer(reducer, retrieveInitialState(props)),
@@ -4112,9 +4164,10 @@ var DatepickerRangeComponent = function DatepickerRangeComponent(props) {
4112
4164
  endValue: endValue,
4113
4165
  onChange: onChange,
4114
4166
  startInputRef: startInputRef,
4115
- endInputRef: endInputRef
4167
+ endInputRef: endInputRef,
4168
+ customParseDate: customParseDate
4116
4169
  };
4117
- }, [state, dispatch, isCompact, locale, minValue, maxValue, startValue, endValue, onChange, startInputRef, endInputRef]);
4170
+ }, [state, dispatch, isCompact, locale, minValue, maxValue, startValue, endValue, onChange, startInputRef, endInputRef, customParseDate]);
4118
4171
  return React__default.createElement(DatepickerRangeContext.Provider, {
4119
4172
  value: value
4120
4173
  }, children);
@@ -4,77 +4,9 @@
4
4
  * Use of this source code is governed under the Apache License, Version 2.0
5
5
  * found at http://www.apache.org/licenses/LICENSE-2.0.
6
6
  */
7
- import React, { HTMLAttributes } from 'react';
8
- import { Modifiers } from 'popper.js';
9
- import { GARDEN_PLACEMENT } from './utils/garden-placements';
7
+ import React from 'react';
8
+ import { IDatepickerProps } from '../../types';
10
9
  /**
11
10
  * @extends HTMLAttributes<HTMLDivElement>
12
11
  */
13
- export interface IDatepickerProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
14
- /**
15
- * Sets the selected date
16
- */
17
- value?: Date;
18
- /**
19
- * Handles date change
20
- *
21
- * @param {Date} date The selected date
22
- */
23
- onChange?: (date: Date) => void;
24
- /**
25
- * Customizes the input element's date formatting
26
- *
27
- * @param {Date} date The selected date
28
- * @returns {string} a formatted date string
29
- */
30
- formatDate?: (date: Date) => string;
31
- /**
32
- * Applies locale-based formatting.
33
- * Accepts all valid `Intl` [locales](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation).
34
- */
35
- locale?: string;
36
- /**
37
- * Disables dates before this value on the calendar
38
- */
39
- minValue?: Date;
40
- /**
41
- * Disables dates after this value on the calendar
42
- */
43
- maxValue?: Date;
44
- /**
45
- * Applies compact styling
46
- */
47
- isCompact?: boolean;
48
- /**
49
- * Overrides default date parsing
50
- *
51
- * @param {string} inputValue A localized input value
52
- * @returns {Date} the parsed date
53
- */
54
- customParseDate?: (inputValue: string) => Date;
55
- /**
56
- * Defines the ref key used to position the calendar
57
- */
58
- refKey?: string;
59
- /**
60
- * Adjusts the position of the calendar
61
- **/
62
- placement?: GARDEN_PLACEMENT;
63
- /**
64
- * Passes configuration options to the [Popper instance](https://popper.js.org/docs/v2/modifiers/)
65
- */
66
- popperModifiers?: Modifiers;
67
- /**
68
- * Animates the calendar
69
- */
70
- isAnimated?: boolean;
71
- /**
72
- * Allows the calendar to reposition during browser resize events
73
- */
74
- eventsEnabled?: boolean;
75
- /**
76
- * Sets the `z-index` of the calendar
77
- */
78
- zIndex?: number;
79
- }
80
12
  export declare const Datepicker: React.ForwardRefExoticComponent<IDatepickerProps & React.RefAttributes<HTMLDivElement>>;
@@ -4,7 +4,7 @@
4
4
  * Use of this source code is governed under the Apache License, Version 2.0
5
5
  * found at http://www.apache.org/licenses/LICENSE-2.0.
6
6
  */
7
- import { IDatepickerProps } from '../Datepicker';
7
+ import { IDatepickerProps } from '../../../types';
8
8
  export interface IDatepickerState {
9
9
  isOpen: boolean;
10
10
  previewDate: Date;
@@ -4,22 +4,18 @@
4
4
  * Use of this source code is governed under the Apache License, Version 2.0
5
5
  * found at http://www.apache.org/licenses/LICENSE-2.0.
6
6
  */
7
- import { MENU_POSITION } from '@zendeskgarden/react-theming';
8
- declare type SHARED_PLACEMENT = 'auto' | 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end';
9
- export declare type GARDEN_PLACEMENT = SHARED_PLACEMENT | 'end' | 'end-top' | 'end-bottom' | 'start' | 'start-top' | 'start-bottom';
10
- export declare type POPPER_PLACEMENT = SHARED_PLACEMENT | 'right' | 'right-start' | 'right-end' | 'left' | 'left-start' | 'left-end';
7
+ import { GardenPlacement, PopperPlacement } from '../../../types';
11
8
  /**
12
9
  * Convert Garden RTL aware placement to Popper.JS valid placement
13
10
  */
14
- export declare function getPopperPlacement(gardenPlacement: GARDEN_PLACEMENT): POPPER_PLACEMENT;
11
+ export declare function getPopperPlacement(gardenPlacement: GardenPlacement): PopperPlacement;
15
12
  /**
16
13
  * Convert Garden RTL aware placement to RTL equivalent Popper.JS placement
17
14
  * @param {String} gardenPlacement
18
15
  */
19
- export declare function getRtlPopperPlacement(gardenPlacement: GARDEN_PLACEMENT): POPPER_PLACEMENT;
16
+ export declare function getRtlPopperPlacement(gardenPlacement: GardenPlacement): PopperPlacement;
20
17
  /**
21
18
  * Convert Popper.JS placement to corresponding menu position
22
19
  * @param {String} popperPlacement
23
20
  */
24
- export declare function getMenuPosition(popperPlacement?: POPPER_PLACEMENT): MENU_POSITION;
25
- export {};
21
+ export declare function getMenuPosition(popperPlacement?: PopperPlacement): "top" | "bottom" | "right" | "left";
@@ -6,61 +6,10 @@
6
6
  */
7
7
  import { PropsWithChildren } from 'react';
8
8
  import PropTypes from 'prop-types';
9
+ import { IDatepickerRangeProps } from '../../types';
9
10
  import { Start } from './components/Start';
10
11
  import { End } from './components/End';
11
12
  import { Calendar } from './components/Calendar';
12
- export interface IDatepickerRangeProps {
13
- /**
14
- * Applies locale-based formatting.
15
- * Accepts all valid `Intl` [locales](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation).
16
- */
17
- locale?: string;
18
- /**
19
- * Sets the start date
20
- */
21
- startValue?: Date;
22
- /**
23
- * Sets the end date
24
- */
25
- endValue?: Date;
26
- /**
27
- * Disables dates before this value on the calendar
28
- */
29
- minValue?: Date;
30
- /**
31
- * Disables dates after this value on the calendar
32
- */
33
- maxValue?: Date;
34
- /**
35
- * Handles start and end date changes
36
- *
37
- * @param {Object} values The selected dates
38
- * @param {Date} [values.startValue] Optional start date
39
- * @param {Date} [values.endValue] Optional end date
40
- */
41
- onChange?: (values: {
42
- startValue?: Date;
43
- endValue?: Date;
44
- }) => void;
45
- /**
46
- * Adjusts the input element's date formatting
47
- *
48
- * @param {Date} date The selected date
49
- * @returns {string} a formatted date string
50
- */
51
- formatDate?: (date: Date) => string;
52
- /**
53
- * Overrides the default date parsing
54
- *
55
- * @param {string} inputValue A date string
56
- * @returns {Date} the parsed date
57
- */
58
- customParseDate?: (inputValue?: string) => Date;
59
- /**
60
- * Applies compact styling
61
- */
62
- isCompact?: boolean;
63
- }
64
13
  export declare const DatepickerRange: {
65
14
  (props: PropsWithChildren<IDatepickerRangeProps>): JSX.Element;
66
15
  propTypes: {
@@ -5,23 +5,10 @@
5
5
  * found at http://www.apache.org/licenses/LICENSE-2.0.
6
6
  */
7
7
  import React, { HTMLAttributes } from 'react';
8
- import { DatepickerRangeAction } from '../utils/datepicker-range-reducer';
9
8
  interface IMonthProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
10
- locale?: string;
11
9
  displayDate: Date;
12
- isCompact?: boolean;
13
10
  isPreviousHidden?: boolean;
14
11
  isNextHidden?: boolean;
15
- dispatch: React.Dispatch<DatepickerRangeAction>;
16
- minValue?: Date;
17
- maxValue?: Date;
18
- startValue?: Date;
19
- endValue?: Date;
20
- onChange?: (values: {
21
- startValue?: Date;
22
- endValue?: Date;
23
- }) => void;
24
- hoverDate?: Date;
25
12
  }
26
13
  export declare const Month: React.ForwardRefExoticComponent<IMonthProps & React.RefAttributes<HTMLDivElement>>;
27
14
  export {};
@@ -4,7 +4,7 @@
4
4
  * Use of this source code is governed under the Apache License, Version 2.0
5
5
  * found at http://www.apache.org/licenses/LICENSE-2.0.
6
6
  */
7
- import { IDatepickerRangeProps } from '../DatepickerRange';
7
+ import { IDatepickerRangeProps } from '../../../types';
8
8
  export interface IDatepickerRangeState {
9
9
  previewDate: Date;
10
10
  hoverDate?: Date;
@@ -13,6 +13,20 @@ export interface IDatepickerRangeState {
13
13
  startInputValue?: string;
14
14
  endInputValue?: string;
15
15
  }
16
+ /**
17
+ * Format date value to a localized string
18
+ */
19
+ export declare function formatValue({ value, locale, formatDate }: {
20
+ value?: Date;
21
+ formatDate?: any;
22
+ locale?: string;
23
+ }): string;
24
+ /**
25
+ * Parse string input value using current locale and date formats
26
+ */
27
+ export declare function parseInputValue({ inputValue }: {
28
+ inputValue?: string;
29
+ }): Date;
16
30
  export declare type DatepickerRangeAction = {
17
31
  type: 'HOVER_DATE';
18
32
  value?: Date;
@@ -44,15 +58,11 @@ export declare type DatepickerRangeAction = {
44
58
  type: 'CONTROLLED_END_VALUE_CHANGE';
45
59
  value?: Date;
46
60
  };
47
- export declare const datepickerRangeReducer: ({ startValue, endValue, locale, formatDate, onChange, customParseDate }: {
61
+ export declare const datepickerRangeReducer: ({ startValue, endValue, locale, formatDate, customParseDate }: {
48
62
  startValue?: Date | undefined;
49
63
  endValue?: Date | undefined;
50
64
  locale?: string | undefined;
51
65
  formatDate?: any;
52
- onChange?: ((values: {
53
- startValue?: Date | undefined;
54
- endValue?: Date | undefined;
55
- }) => void) | undefined;
56
66
  customParseDate?: ((inputValue?: string | undefined) => Date) | undefined;
57
67
  }) => (state: IDatepickerRangeState, action: DatepickerRangeAction) => IDatepickerRangeState;
58
68
  /**
@@ -21,6 +21,7 @@ export interface IDatepickerRangeContext {
21
21
  }) => void;
22
22
  startInputRef: MutableRefObject<HTMLInputElement | undefined>;
23
23
  endInputRef: MutableRefObject<HTMLInputElement | undefined>;
24
+ customParseDate?: (inputValue?: string) => Date;
24
25
  }
25
26
  export declare const DatepickerRangeContext: import("react").Context<IDatepickerRangeContext | undefined>;
26
27
  /**
@@ -5,7 +5,7 @@
5
5
  * found at http://www.apache.org/licenses/LICENSE-2.0.
6
6
  */
7
7
  export { Datepicker } from './elements/Datepicker/Datepicker';
8
- export type { IDatepickerProps } from './elements/Datepicker/Datepicker';
9
8
  export { DatepickerRange } from './elements/DatepickerRange/DatepickerRange';
10
- export type { IDatepickerRangeProps } from './elements/DatepickerRange/DatepickerRange';
11
- export type { GARDEN_PLACEMENT } from './elements/Datepicker/utils/garden-placements';
9
+ export type { IDatepickerProps, IDatepickerRangeProps,
10
+ /** @deprecated type can be dereferenced via IDatePickerProps['placement'] */
11
+ GardenPlacement as GARDEN_PLACEMENT } from './types';
@@ -4,12 +4,12 @@
4
4
  * Use of this source code is governed under the Apache License, Version 2.0
5
5
  * found at http://www.apache.org/licenses/LICENSE-2.0.
6
6
  */
7
- import { POPPER_PLACEMENT } from '../elements/Datepicker/utils/garden-placements';
7
+ import { PopperPlacement } from '../types';
8
8
  interface IStyledMenuWrapperProps {
9
9
  isHidden?: boolean;
10
10
  isAnimated?: boolean;
11
11
  zIndex?: number;
12
- placement?: POPPER_PLACEMENT;
12
+ placement?: PopperPlacement;
13
13
  }
14
14
  export declare const StyledMenuWrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, IStyledMenuWrapperProps, never>;
15
15
  export {};
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import { HTMLAttributes } from 'react';
8
+ import { Modifiers } from 'popper.js';
9
+ export declare const PLACEMENT: readonly ["auto", "top", "top-start", "top-end", "bottom", "bottom-start", "bottom-end", "end", "end-top", "end-bottom", "start", "start-top", "start-bottom"];
10
+ export declare const POPPER_PLACEMENT: readonly ["auto", "top", "top-start", "top-end", "bottom", "bottom-start", "bottom-end", "right", "right-start", "right-end", "left", "left-start", "left-end"];
11
+ export declare type GardenPlacement = typeof PLACEMENT[number];
12
+ export declare type PopperPlacement = typeof POPPER_PLACEMENT[number];
13
+ export interface IDatepickerProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
14
+ /**
15
+ * Sets the selected date
16
+ */
17
+ value?: Date;
18
+ /**
19
+ * Handles date change
20
+ *
21
+ * @param {Date} date The selected date
22
+ */
23
+ onChange?: (date: Date) => void;
24
+ /**
25
+ * Customizes the input element's date formatting
26
+ *
27
+ * @param {Date} date The selected date
28
+ * @returns {string} a formatted date string
29
+ */
30
+ formatDate?: (date: Date) => string;
31
+ /**
32
+ * Applies locale-based formatting.
33
+ * Accepts all valid `Intl` [locales](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation).
34
+ */
35
+ locale?: string;
36
+ /**
37
+ * Disables dates before this value on the calendar
38
+ */
39
+ minValue?: Date;
40
+ /**
41
+ * Disables dates after this value on the calendar
42
+ */
43
+ maxValue?: Date;
44
+ /**
45
+ * Applies compact styling
46
+ */
47
+ isCompact?: boolean;
48
+ /**
49
+ * Overrides default date parsing
50
+ *
51
+ * @param {string} inputValue A localized input value
52
+ * @returns {Date} the parsed date
53
+ */
54
+ customParseDate?: (inputValue: string) => Date;
55
+ /**
56
+ * Defines the ref key used to position the calendar
57
+ */
58
+ refKey?: string;
59
+ /**
60
+ * Adjusts the position of the calendar
61
+ **/
62
+ placement?: GardenPlacement;
63
+ /**
64
+ * Passes configuration options to the [Popper instance](https://popper.js.org/docs/v2/modifiers/)
65
+ */
66
+ popperModifiers?: Modifiers;
67
+ /**
68
+ * Animates the calendar
69
+ */
70
+ isAnimated?: boolean;
71
+ /**
72
+ * Allows the calendar to reposition during browser resize events
73
+ */
74
+ eventsEnabled?: boolean;
75
+ /**
76
+ * Sets the `z-index` of the calendar
77
+ */
78
+ zIndex?: number;
79
+ }
80
+ export interface IDatepickerRangeProps extends Pick<IDatepickerProps, 'locale' | 'minValue' | 'maxValue' | 'formatDate' | 'isCompact'> {
81
+ /**
82
+ * Sets the start date
83
+ */
84
+ startValue?: Date;
85
+ /**
86
+ * Sets the end date
87
+ */
88
+ endValue?: Date;
89
+ /**
90
+ * Handles start and end date changes
91
+ *
92
+ * @param {Object} values The selected dates
93
+ * @param {Date} [values.startValue] Optional start date
94
+ * @param {Date} [values.endValue] Optional end date
95
+ */
96
+ onChange?: (values: {
97
+ startValue?: Date;
98
+ endValue?: Date;
99
+ }) => void;
100
+ /**
101
+ * Overrides the default date parsing
102
+ *
103
+ * @param {string} inputValue A date string
104
+ * @returns {Date} the parsed date
105
+ */
106
+ customParseDate?: (inputValue?: string) => Date;
107
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zendeskgarden/react-datepickers",
3
- "version": "8.49.1",
3
+ "version": "8.49.4",
4
4
  "description": "Components relating to datepickers in the Garden Design System",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Zendesk Garden <garden@zendesk.com>",
@@ -33,8 +33,8 @@
33
33
  "styled-components": "^4.2.0 || ^5.0.0"
34
34
  },
35
35
  "devDependencies": {
36
- "@zendeskgarden/react-theming": "^8.49.1",
37
- "@zendeskgarden/svg-icons": "6.30.2"
36
+ "@zendeskgarden/react-theming": "^8.49.4",
37
+ "@zendeskgarden/svg-icons": "6.31.1"
38
38
  },
39
39
  "keywords": [
40
40
  "components",
@@ -46,5 +46,5 @@
46
46
  "access": "public"
47
47
  },
48
48
  "zendeskgarden:src": "src/index.ts",
49
- "gitHead": "40c9f918b5517480f73fc0ed4a47ffde212b28b6"
49
+ "gitHead": "7d8cf45fb734c345fac9e0673236578b2ac9c03b"
50
50
  }