@semcore/date-picker 4.20.1 → 4.21.0-prerelease.1

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.
Files changed (33) hide show
  1. package/CHANGELOG.md +20 -1
  2. package/lib/cjs/DateRangeComparator.js +1 -0
  3. package/lib/cjs/DateRangeComparator.js.map +1 -1
  4. package/lib/cjs/MonthDateRangeComparator.js +1 -0
  5. package/lib/cjs/MonthDateRangeComparator.js.map +1 -1
  6. package/lib/cjs/components/Calendar.js +21 -21
  7. package/lib/cjs/components/DateRangeComparatorAbstract.js +150 -170
  8. package/lib/cjs/components/DateRangeComparatorAbstract.js.map +1 -1
  9. package/lib/cjs/components/InputTrigger.js +26 -25
  10. package/lib/cjs/components/InputTrigger.js.map +1 -1
  11. package/lib/cjs/components/PickerAbstract.js +33 -26
  12. package/lib/cjs/components/PickerAbstract.js.map +1 -1
  13. package/lib/cjs/components/RangePickerAbstract.js +60 -58
  14. package/lib/cjs/components/RangePickerAbstract.js.map +1 -1
  15. package/lib/cjs/index.d.js.map +1 -1
  16. package/lib/cjs/style/date-picker.shadow.css +4 -0
  17. package/lib/es6/DateRangeComparator.js +1 -0
  18. package/lib/es6/DateRangeComparator.js.map +1 -1
  19. package/lib/es6/MonthDateRangeComparator.js +1 -0
  20. package/lib/es6/MonthDateRangeComparator.js.map +1 -1
  21. package/lib/es6/components/Calendar.js +21 -21
  22. package/lib/es6/components/DateRangeComparatorAbstract.js +150 -170
  23. package/lib/es6/components/DateRangeComparatorAbstract.js.map +1 -1
  24. package/lib/es6/components/InputTrigger.js +26 -25
  25. package/lib/es6/components/InputTrigger.js.map +1 -1
  26. package/lib/es6/components/PickerAbstract.js +33 -26
  27. package/lib/es6/components/PickerAbstract.js.map +1 -1
  28. package/lib/es6/components/RangePickerAbstract.js +60 -58
  29. package/lib/es6/components/RangePickerAbstract.js.map +1 -1
  30. package/lib/es6/index.d.js.map +1 -1
  31. package/lib/es6/style/date-picker.shadow.css +4 -0
  32. package/lib/types/index.d.ts +41 -1
  33. package/package.json +14 -14
@@ -20,31 +20,32 @@ import shortDateRangeFormat from '../utils/shortDateRangeFormat';
20
20
  import Checkbox from '@semcore/checkbox';
21
21
  import { LinkTrigger } from '@semcore/base-trigger';
22
22
  /*__reshadow-styles__:"../style/date-picker.shadow.css"*/
23
- var style = ( /*__reshadow_css_start__*/_sstyled.insert( /*__inner_css_start__*/".___SPopper_tb8u3_gg_{padding:var(--intergalactic-spacing-4x, 16px);outline:0}.___SPopper_tb8u3_gg_::-moz-focus-inner{border:0;padding:0}.___SPopper_tb8u3_gg_:active,.___SPopper_tb8u3_gg_:focus{outline:0;-webkit-text-decoration:none;text-decoration:none}@media (hover:hover){.___SPopper_tb8u3_gg_:hover{outline:0;-webkit-text-decoration:none;text-decoration:none}}.___SPopper_tb8u3_gg_:focus{box-shadow:var(--intergalactic-keyboard-focus, 0px 0px 0px 3px rgba(0, 143, 248, 0.5))}.___SHeader_tb8u3_gg_,.___STitle_tb8u3_gg_{display:flex;align-items:center}.___STitle_tb8u3_gg_{font-size:var(--intergalactic-fs-200, 14px);color:var(--intergalactic-text-primary, #191b23);height:32px;width:100%;justify-content:center}.___SToday_tb8u3_gg_{display:flex;margin-top:var(--intergalactic-spacing-3x, 12px);justify-content:center}.___SPeriod_tb8u3_gg_{display:flex;flex-direction:column;margin-bottom:var(--intergalactic-spacing-2x, 8px)}.___SButton_tb8u3_gg_ .___SInner_tb8u3_gg_{justify-content:flex-start}.___SInputMask_tb8u3_gg_{color:var(--intergalactic-text-primary, #191b23);line-height:normal}.___SIndicator_tb8u3_gg_{color:var(--intergalactic-text-secondary, #6c6e79)}.___SRangeIndicator_tb8u3_gg_{border-radius:50%;flex-shrink:0}.___SRangeIndicator_tb8u3_gg_._range_value_tb8u3_gg_{background-color:var(--intergalactic-date-picker-cell-active, #2bb3ff)}.___SRangeIndicator_tb8u3_gg_._range_compare_tb8u3_gg_{background-color:var(--intergalactic-date-picker-cell-comparison-active, #8649e1)}.___SHumanizedDate_tb8u3_gg_{position:absolute;pointer-events:none}.___SDateRange_tb8u3_gg_ .___SMask_tb8u3_gg_,.___SDateRange_tb8u3_gg_ .___SValue_tb8u3_gg_,.___SSingleDateInput_tb8u3_gg_ .___SMask_tb8u3_gg_,.___SSingleDateInput_tb8u3_gg_ .___SValue_tb8u3_gg_{opacity:0}.___SSingleDateInput_tb8u3_gg_:focus-within .___SHumanizedDate_tb8u3_gg_{opacity:0;z-index:var(--intergalactic-z-index-deep, -999)}.___SSingleDateInput_tb8u3_gg_:focus-within .___SMask_tb8u3_gg_,.___SSingleDateInput_tb8u3_gg_:focus-within .___SValue_tb8u3_gg_{opacity:1}.___SDateRange_tb8u3_gg_:focus-within .___SHumanizedDate_tb8u3_gg_{opacity:0;z-index:var(--intergalactic-z-index-deep, -999)}.___SDateRange_tb8u3_gg_:focus-within .___SMask_tb8u3_gg_,.___SDateRange_tb8u3_gg_:focus-within .___SValue_tb8u3_gg_{opacity:1}.___SInputMask_tb8u3_gg_.__noHumanizedDate_tb8u3_gg_ .___SMask_tb8u3_gg_,.___SInputMask_tb8u3_gg_.__noHumanizedDate_tb8u3_gg_ .___SValue_tb8u3_gg_{opacity:1}.___SDateRange_tb8u3_gg_ .___SInputMask_tb8u3_gg_:focus-within .___SMask_tb8u3_gg_{background-color:var(--intergalactic-bg-highlight-focus, rgba(0, 143, 248, 0.2))}.___SDateRange_tb8u3_gg_:focus-within .___SRangeSep_tb8u3_gg_,.___SRangeSep_tb8u3_gg_.__fulfilled_tb8u3_gg_{color:var(--intergalactic-text-primary, #191b23)}.___SRangeComparatorHeader_tb8u3_gg_{border-bottom:1px solid var(--intergalactic-border-primary, #c4c7cf)}.___SRangeCalendar_tb8u3_gg_,.___SRangeComparatorHeader_tb8u3_gg_{padding:var(--intergalactic-spacing-4x, 16px)}.___SFooter_tb8u3_gg_{border-top:1px solid var(--intergalactic-border-primary, #c4c7cf)}.___SFooter_tb8u3_gg_,.___SPeriodsList_tb8u3_gg_{padding:var(--intergalactic-spacing-4x, 16px)}" /*__inner_css_end__*/, "tb8u3_gg_") /*__reshadow_css_end__*/, {
24
- "__SHeader": "___SHeader_tb8u3_gg_",
25
- "__STitle": "___STitle_tb8u3_gg_",
26
- "__SToday": "___SToday_tb8u3_gg_",
27
- "__SPeriod": "___SPeriod_tb8u3_gg_",
28
- "__SButton": "___SButton_tb8u3_gg_",
29
- "__SInner": "___SInner_tb8u3_gg_",
30
- "__SInputMask": "___SInputMask_tb8u3_gg_",
31
- "__SIndicator": "___SIndicator_tb8u3_gg_",
32
- "__SRangeIndicator": "___SRangeIndicator_tb8u3_gg_",
33
- "_range_value": "_range_value_tb8u3_gg_",
34
- "_range_compare": "_range_compare_tb8u3_gg_",
35
- "__SHumanizedDate": "___SHumanizedDate_tb8u3_gg_",
36
- "__SSingleDateInput": "___SSingleDateInput_tb8u3_gg_",
37
- "__SValue": "___SValue_tb8u3_gg_",
38
- "__SDateRange": "___SDateRange_tb8u3_gg_",
39
- "__SMask": "___SMask_tb8u3_gg_",
40
- "_noHumanizedDate": "__noHumanizedDate_tb8u3_gg_",
41
- "__SRangeSep": "___SRangeSep_tb8u3_gg_",
42
- "_fulfilled": "__fulfilled_tb8u3_gg_",
43
- "__SRangeComparatorHeader": "___SRangeComparatorHeader_tb8u3_gg_",
44
- "__SRangeCalendar": "___SRangeCalendar_tb8u3_gg_",
45
- "__SFooter": "___SFooter_tb8u3_gg_",
46
- "__SPeriodsList": "___SPeriodsList_tb8u3_gg_",
47
- "__SPopper": "___SPopper_tb8u3_gg_"
23
+ var style = ( /*__reshadow_css_start__*/_sstyled.insert( /*__inner_css_start__*/".___SPopper_16lpn_gg_{padding:var(--intergalactic-spacing-4x, 16px);outline:0}.___SPopper_16lpn_gg_::-moz-focus-inner{border:0;padding:0}.___SPopper_16lpn_gg_:active,.___SPopper_16lpn_gg_:focus{outline:0;-webkit-text-decoration:none;text-decoration:none}@media (hover:hover){.___SPopper_16lpn_gg_:hover{outline:0;-webkit-text-decoration:none;text-decoration:none}}.___SPopper_16lpn_gg_:focus{box-shadow:var(--intergalactic-keyboard-focus, 0px 0px 0px 3px rgba(0, 143, 248, 0.5))}.___SHeader_16lpn_gg_,.___STitle_16lpn_gg_{display:flex;align-items:center}.___STitle_16lpn_gg_{font-size:var(--intergalactic-fs-200, 14px);color:var(--intergalactic-text-primary, #191b23);height:32px;width:100%;justify-content:center}.___SToday_16lpn_gg_{display:flex;margin-top:var(--intergalactic-spacing-3x, 12px);justify-content:center}.___SPeriod_16lpn_gg_{display:flex;flex-direction:column;margin-bottom:var(--intergalactic-spacing-2x, 8px)}.___SButton_16lpn_gg_ .___SInner_16lpn_gg_{justify-content:flex-start}.___SInputMask_16lpn_gg_{color:var(--intergalactic-text-primary, #191b23);line-height:normal}.___SIndicator_16lpn_gg_{color:var(--intergalactic-text-secondary, #6c6e79)}.___SRangeIndicator_16lpn_gg_{border-radius:50%;flex-shrink:0}.___SRangeIndicator_16lpn_gg_._range_value_16lpn_gg_{background-color:var(--intergalactic-date-picker-cell-active, #2bb3ff)}.___SRangeIndicator_16lpn_gg_._range_compare_16lpn_gg_{background-color:var(--intergalactic-date-picker-cell-comparison-active, #8649e1)}.___SRangeIndicator_16lpn_gg_.__disabled_16lpn_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3)}.___SHumanizedDate_16lpn_gg_{position:absolute;pointer-events:none}.___SDateRange_16lpn_gg_ .___SMask_16lpn_gg_,.___SDateRange_16lpn_gg_ .___SValue_16lpn_gg_,.___SSingleDateInput_16lpn_gg_ .___SMask_16lpn_gg_,.___SSingleDateInput_16lpn_gg_ .___SValue_16lpn_gg_{opacity:0}.___SSingleDateInput_16lpn_gg_:focus-within .___SHumanizedDate_16lpn_gg_{opacity:0;z-index:var(--intergalactic-z-index-deep, -999)}.___SSingleDateInput_16lpn_gg_:focus-within .___SMask_16lpn_gg_,.___SSingleDateInput_16lpn_gg_:focus-within .___SValue_16lpn_gg_{opacity:1}.___SDateRange_16lpn_gg_:focus-within .___SHumanizedDate_16lpn_gg_{opacity:0;z-index:var(--intergalactic-z-index-deep, -999)}.___SDateRange_16lpn_gg_:focus-within .___SMask_16lpn_gg_,.___SDateRange_16lpn_gg_:focus-within .___SValue_16lpn_gg_{opacity:1}.___SInputMask_16lpn_gg_.__noHumanizedDate_16lpn_gg_ .___SMask_16lpn_gg_,.___SInputMask_16lpn_gg_.__noHumanizedDate_16lpn_gg_ .___SValue_16lpn_gg_{opacity:1}.___SDateRange_16lpn_gg_ .___SInputMask_16lpn_gg_:focus-within .___SMask_16lpn_gg_{background-color:var(--intergalactic-bg-highlight-focus, rgba(0, 143, 248, 0.2))}.___SDateRange_16lpn_gg_:focus-within .___SRangeSep_16lpn_gg_,.___SRangeSep_16lpn_gg_.__fulfilled_16lpn_gg_{color:var(--intergalactic-text-primary, #191b23)}.___SRangeComparatorHeader_16lpn_gg_{border-bottom:1px solid var(--intergalactic-border-primary, #c4c7cf)}.___SRangeCalendar_16lpn_gg_,.___SRangeComparatorHeader_16lpn_gg_{padding:var(--intergalactic-spacing-4x, 16px)}.___SFooter_16lpn_gg_{border-top:1px solid var(--intergalactic-border-primary, #c4c7cf)}.___SFooter_16lpn_gg_,.___SPeriodsList_16lpn_gg_{padding:var(--intergalactic-spacing-4x, 16px)}" /*__inner_css_end__*/, "16lpn_gg_") /*__reshadow_css_end__*/, {
24
+ "__SHeader": "___SHeader_16lpn_gg_",
25
+ "__STitle": "___STitle_16lpn_gg_",
26
+ "__SToday": "___SToday_16lpn_gg_",
27
+ "__SPeriod": "___SPeriod_16lpn_gg_",
28
+ "__SButton": "___SButton_16lpn_gg_",
29
+ "__SInner": "___SInner_16lpn_gg_",
30
+ "__SInputMask": "___SInputMask_16lpn_gg_",
31
+ "__SIndicator": "___SIndicator_16lpn_gg_",
32
+ "__SRangeIndicator": "___SRangeIndicator_16lpn_gg_",
33
+ "_range_value": "_range_value_16lpn_gg_",
34
+ "_range_compare": "_range_compare_16lpn_gg_",
35
+ "_disabled": "__disabled_16lpn_gg_",
36
+ "__SHumanizedDate": "___SHumanizedDate_16lpn_gg_",
37
+ "__SSingleDateInput": "___SSingleDateInput_16lpn_gg_",
38
+ "__SValue": "___SValue_16lpn_gg_",
39
+ "__SDateRange": "___SDateRange_16lpn_gg_",
40
+ "__SMask": "___SMask_16lpn_gg_",
41
+ "_noHumanizedDate": "__noHumanizedDate_16lpn_gg_",
42
+ "__SRangeSep": "___SRangeSep_16lpn_gg_",
43
+ "_fulfilled": "__fulfilled_16lpn_gg_",
44
+ "__SRangeComparatorHeader": "___SRangeComparatorHeader_16lpn_gg_",
45
+ "__SRangeCalendar": "___SRangeCalendar_16lpn_gg_",
46
+ "__SFooter": "___SFooter_16lpn_gg_",
47
+ "__SPeriodsList": "___SPeriodsList_16lpn_gg_",
48
+ "__SPopper": "___SPopper_16lpn_gg_"
48
49
  });
49
50
  var defaultDisplayedPeriod = new Date(new Date().setHours(0, 0, 0, 0));
50
51
  var getLatestDate = function getLatestDate() {
@@ -71,12 +72,6 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
71
72
  args[_key2] = arguments[_key2];
72
73
  }
73
74
  _this = _super.call.apply(_super, [this].concat(args));
74
- _defineProperty(_assertThisInitialized(_this), "state", {
75
- dirtyValue: undefined,
76
- dirtyCompare: undefined,
77
- dirtyToggler: undefined,
78
- range: 'value' // 'value' | 'compare'
79
- });
80
75
  _defineProperty(_assertThisInitialized(_this), "navigateView", function (direction) {
81
76
  var displayedPeriod = _this.asProps.displayedPeriod;
82
77
  var action = direction >= 1 ? 'add' : 'subtract';
@@ -96,41 +91,35 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
96
91
  _this.handlers.visible(false);
97
92
  });
98
93
  _defineProperty(_assertThisInitialized(_this), "handleChange", function (date) {
99
- var _dirty, _dirty2, _dirty3;
100
- var _this$state = _this.state,
101
- dirtyValue = _this$state.dirtyValue,
102
- dirtyCompare = _this$state.dirtyCompare,
103
- range = _this$state.range;
94
+ var _value, _value2, _value3;
95
+ var _this$asProps = _this.asProps,
96
+ focusedRange = _this$asProps.focusedRange,
97
+ preselectedCompare = _this$asProps.preselectedCompare,
98
+ preselectedValue = _this$asProps.preselectedValue;
104
99
  var highlighted = [];
105
- var dirty = range === 'compare' ? dirtyCompare : dirtyValue;
100
+ var value = focusedRange === 'compare' ? preselectedCompare : preselectedValue;
106
101
  if (Array.isArray(date)) {
107
- dirty = date;
108
- } else if (!((_dirty = dirty) !== null && _dirty !== void 0 && _dirty.length)) {
109
- dirty = [date];
102
+ value = date;
103
+ } else if (!((_value = value) !== null && _value !== void 0 && _value.length)) {
104
+ value = [date];
110
105
  highlighted = [date];
111
- } else if (((_dirty2 = dirty) === null || _dirty2 === void 0 ? void 0 : _dirty2.length) >= 2) {
112
- dirty = [date];
106
+ } else if (((_value2 = value) === null || _value2 === void 0 ? void 0 : _value2.length) >= 2) {
107
+ value = [date];
113
108
  highlighted = [date];
114
- } else if (((_dirty3 = dirty) === null || _dirty3 === void 0 ? void 0 : _dirty3[0]) > date) {
115
- var _dirty4;
116
- dirty = [date, (_dirty4 = dirty) === null || _dirty4 === void 0 ? void 0 : _dirty4[0]];
109
+ } else if (((_value3 = value) === null || _value3 === void 0 ? void 0 : _value3[0]) > date) {
110
+ var _value4;
111
+ value = [date, (_value4 = value) === null || _value4 === void 0 ? void 0 : _value4[0]];
117
112
  } else {
118
- var _dirty5;
119
- dirty = [(_dirty5 = dirty) === null || _dirty5 === void 0 ? void 0 : _dirty5[0], date];
113
+ var _value5;
114
+ value = [(_value5 = value) === null || _value5 === void 0 ? void 0 : _value5[0], date];
120
115
  }
121
- var state = {};
122
- if (range === 'compare') {
123
- state['dirtyCompare'] = dirty;
116
+ if (focusedRange === 'compare') {
117
+ _this.handlers.preselectedCompare(value);
118
+ _this.handlers.compareHighlighted(highlighted);
124
119
  } else {
125
- state['dirtyValue'] = dirty;
120
+ _this.handlers.preselectedValue(value);
121
+ _this.handlers.highlighted(highlighted);
126
122
  }
127
- _this.setState(state, function () {
128
- if (range === 'compare') {
129
- _this.handlers.compareHighlighted(highlighted);
130
- } else {
131
- _this.handlers.highlighted(highlighted);
132
- }
133
- });
134
123
  });
135
124
  return _this;
136
125
  }
@@ -139,36 +128,31 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
139
128
  value: function getPeriodProps() {
140
129
  var _this$asProps$value,
141
130
  _this2 = this;
142
- var _this$asProps = this.asProps,
143
- _this$asProps$periods = _this$asProps.periods,
144
- periods = _this$asProps$periods === void 0 ? this.getDefaultPeriods() : _this$asProps$periods,
145
- onHighlightedChange = _this$asProps.onHighlightedChange,
146
- onCompareHighlightedChange = _this$asProps.onCompareHighlightedChange,
147
- onDisplayedPeriodChange = _this$asProps.onDisplayedPeriodChange;
148
- var _this$state2 = this.state,
149
- dirtyValue = _this$state2.dirtyValue,
150
- dirtyCompare = _this$state2.dirtyCompare,
151
- range = _this$state2.range;
152
- var value = dirtyValue !== null && dirtyValue !== void 0 ? dirtyValue : (_this$asProps$value = this.asProps.value) === null || _this$asProps$value === void 0 ? void 0 : _this$asProps$value.value;
153
- if (range === 'compare') {
131
+ var _this$asProps2 = this.asProps,
132
+ _this$asProps2$period = _this$asProps2.periods,
133
+ periods = _this$asProps2$period === void 0 ? this.getDefaultPeriods() : _this$asProps2$period,
134
+ onHighlightedChange = _this$asProps2.onHighlightedChange,
135
+ onCompareHighlightedChange = _this$asProps2.onCompareHighlightedChange,
136
+ onDisplayedPeriodChange = _this$asProps2.onDisplayedPeriodChange,
137
+ preselectedValue = _this$asProps2.preselectedValue,
138
+ preselectedCompare = _this$asProps2.preselectedCompare,
139
+ focusedRange = _this$asProps2.focusedRange;
140
+ var value = preselectedValue !== null && preselectedValue !== void 0 ? preselectedValue : (_this$asProps$value = this.asProps.value) === null || _this$asProps$value === void 0 ? void 0 : _this$asProps$value.value;
141
+ if (focusedRange === 'compare') {
154
142
  var _this$asProps$value2;
155
- value = dirtyCompare !== null && dirtyCompare !== void 0 ? dirtyCompare : (_this$asProps$value2 = this.asProps.value) === null || _this$asProps$value2 === void 0 ? void 0 : _this$asProps$value2.compare;
143
+ value = preselectedCompare !== null && preselectedCompare !== void 0 ? preselectedCompare : (_this$asProps$value2 = this.asProps.value) === null || _this$asProps$value2 === void 0 ? void 0 : _this$asProps$value2.compare;
156
144
  }
157
145
  return {
158
146
  periods: periods,
159
147
  value: value,
160
148
  onChange: function onChange(value) {
161
- if (range === 'compare') {
162
- _this2.setState({
163
- dirtyCompare: value
164
- });
149
+ if (focusedRange === 'compare') {
150
+ _this2.handlers.preselectedCompare(value);
165
151
  } else {
166
- _this2.setState({
167
- dirtyValue: value
168
- });
152
+ _this2.handlers.preselectedValue(value);
169
153
  }
170
154
  },
171
- onHighlightedChange: range === 'compare' ? onCompareHighlightedChange : onHighlightedChange,
155
+ onHighlightedChange: focusedRange === 'compare' ? onCompareHighlightedChange : onHighlightedChange,
172
156
  onDisplayedPeriodChange: onDisplayedPeriodChange
173
157
  };
174
158
  }
@@ -201,17 +185,26 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
201
185
  var _ref10, _this3$asProps$value$, _this3$asProps$value, _this3$asProps$value2;
202
186
  _this3.handlers.highlighted([]);
203
187
  _this3.handlers.compareHighlighted([]);
204
- _this3.setState({
205
- dirtyValue: undefined,
206
- dirtyCompare: undefined,
207
- dirtyToggler: undefined,
208
- range: 'value'
209
- });
188
+ _this3.handlers.preselectedValue(undefined);
189
+ _this3.handlers.preselectedCompare(undefined);
190
+ _this3.handlers.compareToggle(undefined);
191
+ _this3.handlers.focusedRange('value');
210
192
  _this3.handlers.displayedPeriod(getLatestDate((_ref10 = (_this3$asProps$value$ = (_this3$asProps$value = _this3.asProps.value) === null || _this3$asProps$value === void 0 ? void 0 : _this3$asProps$value.value) !== null && _this3$asProps$value$ !== void 0 ? _this3$asProps$value$ : (_this3$asProps$value2 = _this3.asProps.value) === null || _this3$asProps$value2 === void 0 ? void 0 : _this3$asProps$value2.compare) !== null && _ref10 !== void 0 ? _ref10 : []) || _this3.props.defaultDisplayedPeriod);
211
193
  }
194
+ var _this3$asProps = _this3.asProps,
195
+ value = _this3$asProps.value,
196
+ displayedPeriod = _this3$asProps.displayedPeriod;
197
+ var newDisplayedPeriod = value ? getLatestDate(value.value, value.compare) : undefined;
198
+ if (visible && newDisplayedPeriod && newDisplayedPeriod !== displayedPeriod) {
199
+ _this3.handlers.displayedPeriod(newDisplayedPeriod);
200
+ }
212
201
  }],
213
202
  highlighted: null,
214
203
  compareHighlighted: null,
204
+ preselectedValue: null,
205
+ preselectedCompare: null,
206
+ compareToggle: null,
207
+ focusedRange: null,
215
208
  value: [null, function (value) {
216
209
  var dates = [value === null || value === void 0 ? void 0 : value.value, value === null || value === void 0 ? void 0 : value.compare].flat(2).filter(function (date) {
217
210
  var _date$isValid;
@@ -225,16 +218,15 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
225
218
  key: "getApplyProps",
226
219
  value: function getApplyProps() {
227
220
  var _this4 = this;
228
- var _this$asProps2 = this.asProps,
229
- value = _this$asProps2.value,
230
- getI18nText = _this$asProps2.getI18nText;
231
- var _this$state3 = this.state,
232
- dirtyValue = _this$state3.dirtyValue,
233
- dirtyCompare = _this$state3.dirtyCompare;
221
+ var _this$asProps3 = this.asProps,
222
+ value = _this$asProps3.value,
223
+ getI18nText = _this$asProps3.getI18nText,
224
+ preselectedValue = _this$asProps3.preselectedValue,
225
+ preselectedCompare = _this$asProps3.preselectedCompare;
234
226
  return {
235
227
  getI18nText: getI18nText,
236
228
  onClick: function onClick() {
237
- return _this4.handleApply(dirtyValue !== null && dirtyValue !== void 0 ? dirtyValue : value === null || value === void 0 ? void 0 : value.value, dirtyCompare !== null && dirtyCompare !== void 0 ? dirtyCompare : value === null || value === void 0 ? void 0 : value.compare);
229
+ return _this4.handleApply(preselectedValue !== null && preselectedValue !== void 0 ? preselectedValue : value === null || value === void 0 ? void 0 : value.value, preselectedCompare !== null && preselectedCompare !== void 0 ? preselectedCompare : value === null || value === void 0 ? void 0 : value.compare);
238
230
  }
239
231
  };
240
232
  }
@@ -272,9 +264,9 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
272
264
  }, {
273
265
  key: "getTitleProps",
274
266
  value: function getTitleProps(props, index) {
275
- var _this$asProps3 = this.asProps,
276
- locale = _this$asProps3.locale,
277
- displayedPeriod = _this$asProps3.displayedPeriod;
267
+ var _this$asProps4 = this.asProps,
268
+ locale = _this$asProps4.locale,
269
+ displayedPeriod = _this$asProps4.displayedPeriod;
278
270
  return {
279
271
  children: new Intl.DateTimeFormat(locale, {
280
272
  month: 'long',
@@ -292,9 +284,9 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
292
284
  placeholder = _ref11$placeholder === void 0 ? 'Select date ranges' : _ref11$placeholder,
293
285
  _ref11$separator = _ref11.separator,
294
286
  separator = _ref11$separator === void 0 ? 'vs.' : _ref11$separator;
295
- var _this$asProps4 = this.asProps,
296
- locale = _this$asProps4.locale,
297
- visible = _this$asProps4.visible;
287
+ var _this$asProps5 = this.asProps,
288
+ locale = _this$asProps5.locale,
289
+ visible = _this$asProps5.visible;
298
290
  var value = (_this$asProps$value3 = this.asProps.value) === null || _this$asProps$value3 === void 0 ? void 0 : _this$asProps$value3.value;
299
291
  var compare = (_this$asProps$value4 = this.asProps.value) === null || _this$asProps$value4 === void 0 ? void 0 : _this$asProps$value4.compare;
300
292
  var formattingProps = {
@@ -327,23 +319,20 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
327
319
  key: "getValueDateRangeProps",
328
320
  value: function getValueDateRangeProps() {
329
321
  var _this7 = this;
330
- var _this$asProps5 = this.asProps,
331
- value = _this$asProps5.value,
332
- onDisplayedPeriodChange = _this$asProps5.onDisplayedPeriodChange,
333
- locale = _this$asProps5.locale,
334
- disabled = _this$asProps5.disabled,
335
- size = _this$asProps5.size,
336
- getI18nText = _this$asProps5.getI18nText;
337
- var _this$state4 = this.state,
338
- range = _this$state4.range,
339
- dirtyValue = _this$state4.dirtyValue;
322
+ var _this$asProps6 = this.asProps,
323
+ value = _this$asProps6.value,
324
+ onDisplayedPeriodChange = _this$asProps6.onDisplayedPeriodChange,
325
+ locale = _this$asProps6.locale,
326
+ disabled = _this$asProps6.disabled,
327
+ size = _this$asProps6.size,
328
+ getI18nText = _this$asProps6.getI18nText,
329
+ focusedRange = _this$asProps6.focusedRange,
330
+ preselectedValue = _this$asProps6.preselectedValue;
340
331
  return {
341
- focused: range === 'value' ? true : undefined,
342
- value: dirtyValue !== null && dirtyValue !== void 0 ? dirtyValue : value === null || value === void 0 ? void 0 : value.value,
332
+ focused: focusedRange === 'value' ? true : undefined,
333
+ value: preselectedValue !== null && preselectedValue !== void 0 ? preselectedValue : value === null || value === void 0 ? void 0 : value.value,
343
334
  onChange: function onChange(value) {
344
- return _this7.setState({
345
- dirtyValue: value
346
- });
335
+ return _this7.handlers.preselectedValue(value);
347
336
  },
348
337
  onDisplayedPeriodChange: onDisplayedPeriodChange,
349
338
  locale: locale,
@@ -352,9 +341,7 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
352
341
  children: this.getRangeInput(),
353
342
  getI18nText: getI18nText,
354
343
  onFocus: function onFocus() {
355
- _this7.setState({
356
- range: 'value'
357
- });
344
+ _this7.handlers.focusedRange('value');
358
345
  return false;
359
346
  }
360
347
  };
@@ -364,25 +351,22 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
364
351
  value: function getCompareDateRangeProps() {
365
352
  var _value$compare,
366
353
  _this8 = this;
367
- var _this$asProps6 = this.asProps,
368
- value = _this$asProps6.value,
369
- onDisplayedPeriodChange = _this$asProps6.onDisplayedPeriodChange,
370
- locale = _this$asProps6.locale,
371
- disabled = _this$asProps6.disabled,
372
- size = _this$asProps6.size,
373
- getI18nText = _this$asProps6.getI18nText;
374
- var _this$state5 = this.state,
375
- range = _this$state5.range,
376
- dirtyCompare = _this$state5.dirtyCompare,
377
- dirtyToggler = _this$state5.dirtyToggler;
354
+ var _this$asProps7 = this.asProps,
355
+ value = _this$asProps7.value,
356
+ onDisplayedPeriodChange = _this$asProps7.onDisplayedPeriodChange,
357
+ locale = _this$asProps7.locale,
358
+ disabled = _this$asProps7.disabled,
359
+ size = _this$asProps7.size,
360
+ getI18nText = _this$asProps7.getI18nText,
361
+ focusedRange = _this$asProps7.focusedRange,
362
+ preselectedCompare = _this$asProps7.preselectedCompare,
363
+ compareToggle = _this$asProps7.compareToggle;
378
364
  return {
379
- focused: range === 'compare' ? true : undefined,
380
- disabled: !(dirtyToggler !== null && dirtyToggler !== void 0 ? dirtyToggler : value === null || value === void 0 ? void 0 : (_value$compare = value.compare) === null || _value$compare === void 0 ? void 0 : _value$compare.length),
381
- value: dirtyCompare !== null && dirtyCompare !== void 0 ? dirtyCompare : value === null || value === void 0 ? void 0 : value.compare,
365
+ focused: focusedRange === 'compare' ? true : undefined,
366
+ disabled: !(compareToggle !== null && compareToggle !== void 0 ? compareToggle : value === null || value === void 0 ? void 0 : (_value$compare = value.compare) === null || _value$compare === void 0 ? void 0 : _value$compare.length),
367
+ value: preselectedCompare !== null && preselectedCompare !== void 0 ? preselectedCompare : value === null || value === void 0 ? void 0 : value.compare,
382
368
  onChange: function onChange(value) {
383
- return _this8.setState({
384
- dirtyCompare: value
385
- });
369
+ return _this8.handlers.preselectedCompare(value);
386
370
  },
387
371
  onDisplayedPeriodChange: onDisplayedPeriodChange,
388
372
  locale: locale,
@@ -391,9 +375,7 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
391
375
  children: this.getRangeInput(),
392
376
  getI18nText: getI18nText,
393
377
  onFocus: function onFocus() {
394
- _this8.setState({
395
- range: 'compare'
396
- });
378
+ _this8.handlers.focusedRange('compare');
397
379
  return false;
398
380
  }
399
381
  };
@@ -403,25 +385,20 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
403
385
  value: function getCompareToggleProps() {
404
386
  var _value$compare2,
405
387
  _this9 = this;
406
- var _this$asProps7 = this.asProps,
407
- getI18nText = _this$asProps7.getI18nText,
408
- value = _this$asProps7.value;
409
- var dirtyToggler = this.state.dirtyToggler;
388
+ var _this$asProps8 = this.asProps,
389
+ getI18nText = _this$asProps8.getI18nText,
390
+ value = _this$asProps8.value,
391
+ compareToggle = _this$asProps8.compareToggle;
410
392
  return {
411
393
  getI18nText: getI18nText,
412
- checked: dirtyToggler !== null && dirtyToggler !== void 0 ? dirtyToggler : value === null || value === void 0 ? void 0 : (_value$compare2 = value.compare) === null || _value$compare2 === void 0 ? void 0 : _value$compare2.length,
394
+ checked: compareToggle !== null && compareToggle !== void 0 ? compareToggle : value === null || value === void 0 ? void 0 : (_value$compare2 = value.compare) === null || _value$compare2 === void 0 ? void 0 : _value$compare2.length,
413
395
  onChange: function onChange(checked) {
414
396
  if (checked) {
415
- _this9.setState({
416
- range: 'compare',
417
- dirtyToggler: true
418
- });
397
+ _this9.handlers.compareToggle(true);
398
+ _this9.handlers.focusedRange('compare');
419
399
  } else {
420
- _this9.setState({
421
- range: 'value',
422
- dirtyCompare: [],
423
- dirtyToggler: false
424
- });
400
+ _this9.handlers.compareToggle(false);
401
+ _this9.handlers.focusedRange('value');
425
402
  }
426
403
  }
427
404
  };
@@ -429,19 +406,18 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
429
406
  }, {
430
407
  key: "getCalendarProps",
431
408
  value: function getCalendarProps(_props, index) {
432
- var _this$asProps8 = this.asProps,
433
- locale = _this$asProps8.locale,
434
- displayedPeriod = _this$asProps8.displayedPeriod,
435
- disabled = _this$asProps8.disabled,
436
- value = _this$asProps8.value,
437
- onCompareHighlightedChange = _this$asProps8.onCompareHighlightedChange,
438
- highlighted = _this$asProps8.highlighted,
439
- compareHighlighted = _this$asProps8.compareHighlighted,
440
- onHighlightedChange = _this$asProps8.onHighlightedChange;
441
- var _this$state6 = this.state,
442
- dirtyValue = _this$state6.dirtyValue,
443
- dirtyCompare = _this$state6.dirtyCompare,
444
- range = _this$state6.range;
409
+ var _this$asProps9 = this.asProps,
410
+ locale = _this$asProps9.locale,
411
+ displayedPeriod = _this$asProps9.displayedPeriod,
412
+ disabled = _this$asProps9.disabled,
413
+ value = _this$asProps9.value,
414
+ onCompareHighlightedChange = _this$asProps9.onCompareHighlightedChange,
415
+ highlighted = _this$asProps9.highlighted,
416
+ compareHighlighted = _this$asProps9.compareHighlighted,
417
+ onHighlightedChange = _this$asProps9.onHighlightedChange,
418
+ preselectedCompare = _this$asProps9.preselectedCompare,
419
+ preselectedValue = _this$asProps9.preselectedValue,
420
+ focusedRange = _this$asProps9.focusedRange;
445
421
  return {
446
422
  locale: locale,
447
423
  displayedPeriod: dayjs(displayedPeriod).add(index, this.navigateStep).startOf(this.navigateStep).toDate(),
@@ -451,9 +427,9 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
451
427
  compareHighlighted: compareHighlighted,
452
428
  onCompareHighlightedChange: onCompareHighlightedChange,
453
429
  onHighlightedChange: onHighlightedChange,
454
- range: range,
455
- value: dirtyValue !== null && dirtyValue !== void 0 ? dirtyValue : value === null || value === void 0 ? void 0 : value.value,
456
- compare: dirtyCompare !== null && dirtyCompare !== void 0 ? dirtyCompare : value === null || value === void 0 ? void 0 : value.compare
430
+ range: focusedRange,
431
+ value: preselectedValue !== null && preselectedValue !== void 0 ? preselectedValue : value === null || value === void 0 ? void 0 : value.value,
432
+ compare: preselectedCompare !== null && preselectedCompare !== void 0 ? preselectedCompare : value === null || value === void 0 ? void 0 : value.compare
457
433
  };
458
434
  }
459
435
  }, {
@@ -468,10 +444,10 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
468
444
  value: function render() {
469
445
  var _ref = this.asProps,
470
446
  _ref4;
471
- var _this$asProps9 = this.asProps,
472
- Children = _this$asProps9.Children,
473
- styles = _this$asProps9.styles,
474
- providedAriaLabel = _this$asProps9['aria-label'];
447
+ var _this$asProps10 = this.asProps,
448
+ Children = _this$asProps10.Children,
449
+ styles = _this$asProps10.styles,
450
+ providedAriaLabel = _this$asProps10['aria-label'];
475
451
  return /*#__PURE__*/React.createElement(React.Fragment, null, (_ref4 = sstyled(styles), /*#__PURE__*/React.createElement(Dropdown, _assignProps({
476
452
  "use:aria-label": providedAriaLabel,
477
453
  "__excludeProps": ['onChange', 'value']
@@ -492,6 +468,10 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
492
468
  defaultCompareHighlighted: [],
493
469
  defaultDisplayedPeriod: getLatestDate(primaryRange, defaultPrimaryRange, secondaryRange, defaultSecondaryRange) || defaultDisplayedPeriod,
494
470
  defaultVisible: false,
471
+ defaultPreselectedValue: null,
472
+ defaultPreselectedCompare: null,
473
+ defaultCompareToggle: null,
474
+ defaultFocusedRange: 'value',
495
475
  disabled: [],
496
476
  size: 'm'
497
477
  };