@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.
- package/CHANGELOG.md +20 -1
- package/lib/cjs/DateRangeComparator.js +1 -0
- package/lib/cjs/DateRangeComparator.js.map +1 -1
- package/lib/cjs/MonthDateRangeComparator.js +1 -0
- package/lib/cjs/MonthDateRangeComparator.js.map +1 -1
- package/lib/cjs/components/Calendar.js +21 -21
- package/lib/cjs/components/DateRangeComparatorAbstract.js +150 -170
- package/lib/cjs/components/DateRangeComparatorAbstract.js.map +1 -1
- package/lib/cjs/components/InputTrigger.js +26 -25
- package/lib/cjs/components/InputTrigger.js.map +1 -1
- package/lib/cjs/components/PickerAbstract.js +33 -26
- package/lib/cjs/components/PickerAbstract.js.map +1 -1
- package/lib/cjs/components/RangePickerAbstract.js +60 -58
- package/lib/cjs/components/RangePickerAbstract.js.map +1 -1
- package/lib/cjs/index.d.js.map +1 -1
- package/lib/cjs/style/date-picker.shadow.css +4 -0
- package/lib/es6/DateRangeComparator.js +1 -0
- package/lib/es6/DateRangeComparator.js.map +1 -1
- package/lib/es6/MonthDateRangeComparator.js +1 -0
- package/lib/es6/MonthDateRangeComparator.js.map +1 -1
- package/lib/es6/components/Calendar.js +21 -21
- package/lib/es6/components/DateRangeComparatorAbstract.js +150 -170
- package/lib/es6/components/DateRangeComparatorAbstract.js.map +1 -1
- package/lib/es6/components/InputTrigger.js +26 -25
- package/lib/es6/components/InputTrigger.js.map +1 -1
- package/lib/es6/components/PickerAbstract.js +33 -26
- package/lib/es6/components/PickerAbstract.js.map +1 -1
- package/lib/es6/components/RangePickerAbstract.js +60 -58
- package/lib/es6/components/RangePickerAbstract.js.map +1 -1
- package/lib/es6/index.d.js.map +1 -1
- package/lib/es6/style/date-picker.shadow.css +4 -0
- package/lib/types/index.d.ts +41 -1
- package/package.json +14 -14
|
@@ -30,31 +30,32 @@ var _shortDateRangeFormat = _interopRequireDefault(require("../utils/shortDateRa
|
|
|
30
30
|
var _checkbox = _interopRequireDefault(require("@semcore/checkbox"));
|
|
31
31
|
var _baseTrigger = require("@semcore/base-trigger");
|
|
32
32
|
/*__reshadow-styles__:"../style/date-picker.shadow.css"*/
|
|
33
|
-
var style = ( /*__reshadow_css_start__*/_core.sstyled.insert( /*__inner_css_start__*/".
|
|
34
|
-
"__SHeader": "
|
|
35
|
-
"__STitle": "
|
|
36
|
-
"__SToday": "
|
|
37
|
-
"__SPeriod": "
|
|
38
|
-
"__SButton": "
|
|
39
|
-
"__SInner": "
|
|
40
|
-
"__SInputMask": "
|
|
41
|
-
"__SIndicator": "
|
|
42
|
-
"__SRangeIndicator": "
|
|
43
|
-
"_range_value": "
|
|
44
|
-
"_range_compare": "
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
33
|
+
var style = ( /*__reshadow_css_start__*/_core.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__*/, {
|
|
34
|
+
"__SHeader": "___SHeader_16lpn_gg_",
|
|
35
|
+
"__STitle": "___STitle_16lpn_gg_",
|
|
36
|
+
"__SToday": "___SToday_16lpn_gg_",
|
|
37
|
+
"__SPeriod": "___SPeriod_16lpn_gg_",
|
|
38
|
+
"__SButton": "___SButton_16lpn_gg_",
|
|
39
|
+
"__SInner": "___SInner_16lpn_gg_",
|
|
40
|
+
"__SInputMask": "___SInputMask_16lpn_gg_",
|
|
41
|
+
"__SIndicator": "___SIndicator_16lpn_gg_",
|
|
42
|
+
"__SRangeIndicator": "___SRangeIndicator_16lpn_gg_",
|
|
43
|
+
"_range_value": "_range_value_16lpn_gg_",
|
|
44
|
+
"_range_compare": "_range_compare_16lpn_gg_",
|
|
45
|
+
"_disabled": "__disabled_16lpn_gg_",
|
|
46
|
+
"__SHumanizedDate": "___SHumanizedDate_16lpn_gg_",
|
|
47
|
+
"__SSingleDateInput": "___SSingleDateInput_16lpn_gg_",
|
|
48
|
+
"__SValue": "___SValue_16lpn_gg_",
|
|
49
|
+
"__SDateRange": "___SDateRange_16lpn_gg_",
|
|
50
|
+
"__SMask": "___SMask_16lpn_gg_",
|
|
51
|
+
"_noHumanizedDate": "__noHumanizedDate_16lpn_gg_",
|
|
52
|
+
"__SRangeSep": "___SRangeSep_16lpn_gg_",
|
|
53
|
+
"_fulfilled": "__fulfilled_16lpn_gg_",
|
|
54
|
+
"__SRangeComparatorHeader": "___SRangeComparatorHeader_16lpn_gg_",
|
|
55
|
+
"__SRangeCalendar": "___SRangeCalendar_16lpn_gg_",
|
|
56
|
+
"__SFooter": "___SFooter_16lpn_gg_",
|
|
57
|
+
"__SPeriodsList": "___SPeriodsList_16lpn_gg_",
|
|
58
|
+
"__SPopper": "___SPopper_16lpn_gg_"
|
|
58
59
|
});
|
|
59
60
|
var defaultDisplayedPeriod = new Date(new Date().setHours(0, 0, 0, 0));
|
|
60
61
|
var getLatestDate = function getLatestDate() {
|
|
@@ -81,12 +82,6 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
81
82
|
args[_key2] = arguments[_key2];
|
|
82
83
|
}
|
|
83
84
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
84
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {
|
|
85
|
-
dirtyValue: undefined,
|
|
86
|
-
dirtyCompare: undefined,
|
|
87
|
-
dirtyToggler: undefined,
|
|
88
|
-
range: 'value' // 'value' | 'compare'
|
|
89
|
-
});
|
|
90
85
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "navigateView", function (direction) {
|
|
91
86
|
var displayedPeriod = _this.asProps.displayedPeriod;
|
|
92
87
|
var action = direction >= 1 ? 'add' : 'subtract';
|
|
@@ -106,41 +101,35 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
106
101
|
_this.handlers.visible(false);
|
|
107
102
|
});
|
|
108
103
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleChange", function (date) {
|
|
109
|
-
var
|
|
110
|
-
var _this$
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
104
|
+
var _value, _value2, _value3;
|
|
105
|
+
var _this$asProps = _this.asProps,
|
|
106
|
+
focusedRange = _this$asProps.focusedRange,
|
|
107
|
+
preselectedCompare = _this$asProps.preselectedCompare,
|
|
108
|
+
preselectedValue = _this$asProps.preselectedValue;
|
|
114
109
|
var highlighted = [];
|
|
115
|
-
var
|
|
110
|
+
var value = focusedRange === 'compare' ? preselectedCompare : preselectedValue;
|
|
116
111
|
if (Array.isArray(date)) {
|
|
117
|
-
|
|
118
|
-
} else if (!((
|
|
119
|
-
|
|
112
|
+
value = date;
|
|
113
|
+
} else if (!((_value = value) !== null && _value !== void 0 && _value.length)) {
|
|
114
|
+
value = [date];
|
|
120
115
|
highlighted = [date];
|
|
121
|
-
} else if (((
|
|
122
|
-
|
|
116
|
+
} else if (((_value2 = value) === null || _value2 === void 0 ? void 0 : _value2.length) >= 2) {
|
|
117
|
+
value = [date];
|
|
123
118
|
highlighted = [date];
|
|
124
|
-
} else if (((
|
|
125
|
-
var
|
|
126
|
-
|
|
119
|
+
} else if (((_value3 = value) === null || _value3 === void 0 ? void 0 : _value3[0]) > date) {
|
|
120
|
+
var _value4;
|
|
121
|
+
value = [date, (_value4 = value) === null || _value4 === void 0 ? void 0 : _value4[0]];
|
|
127
122
|
} else {
|
|
128
|
-
var
|
|
129
|
-
|
|
123
|
+
var _value5;
|
|
124
|
+
value = [(_value5 = value) === null || _value5 === void 0 ? void 0 : _value5[0], date];
|
|
130
125
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
126
|
+
if (focusedRange === 'compare') {
|
|
127
|
+
_this.handlers.preselectedCompare(value);
|
|
128
|
+
_this.handlers.compareHighlighted(highlighted);
|
|
134
129
|
} else {
|
|
135
|
-
|
|
130
|
+
_this.handlers.preselectedValue(value);
|
|
131
|
+
_this.handlers.highlighted(highlighted);
|
|
136
132
|
}
|
|
137
|
-
_this.setState(state, function () {
|
|
138
|
-
if (range === 'compare') {
|
|
139
|
-
_this.handlers.compareHighlighted(highlighted);
|
|
140
|
-
} else {
|
|
141
|
-
_this.handlers.highlighted(highlighted);
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
133
|
});
|
|
145
134
|
return _this;
|
|
146
135
|
}
|
|
@@ -149,36 +138,31 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
149
138
|
value: function getPeriodProps() {
|
|
150
139
|
var _this$asProps$value,
|
|
151
140
|
_this2 = this;
|
|
152
|
-
var _this$
|
|
153
|
-
_this$
|
|
154
|
-
periods = _this$
|
|
155
|
-
onHighlightedChange = _this$
|
|
156
|
-
onCompareHighlightedChange = _this$
|
|
157
|
-
onDisplayedPeriodChange = _this$
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
if (range === 'compare') {
|
|
141
|
+
var _this$asProps2 = this.asProps,
|
|
142
|
+
_this$asProps2$period = _this$asProps2.periods,
|
|
143
|
+
periods = _this$asProps2$period === void 0 ? this.getDefaultPeriods() : _this$asProps2$period,
|
|
144
|
+
onHighlightedChange = _this$asProps2.onHighlightedChange,
|
|
145
|
+
onCompareHighlightedChange = _this$asProps2.onCompareHighlightedChange,
|
|
146
|
+
onDisplayedPeriodChange = _this$asProps2.onDisplayedPeriodChange,
|
|
147
|
+
preselectedValue = _this$asProps2.preselectedValue,
|
|
148
|
+
preselectedCompare = _this$asProps2.preselectedCompare,
|
|
149
|
+
focusedRange = _this$asProps2.focusedRange;
|
|
150
|
+
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;
|
|
151
|
+
if (focusedRange === 'compare') {
|
|
164
152
|
var _this$asProps$value2;
|
|
165
|
-
value =
|
|
153
|
+
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;
|
|
166
154
|
}
|
|
167
155
|
return {
|
|
168
156
|
periods: periods,
|
|
169
157
|
value: value,
|
|
170
158
|
onChange: function onChange(value) {
|
|
171
|
-
if (
|
|
172
|
-
_this2.
|
|
173
|
-
dirtyCompare: value
|
|
174
|
-
});
|
|
159
|
+
if (focusedRange === 'compare') {
|
|
160
|
+
_this2.handlers.preselectedCompare(value);
|
|
175
161
|
} else {
|
|
176
|
-
_this2.
|
|
177
|
-
dirtyValue: value
|
|
178
|
-
});
|
|
162
|
+
_this2.handlers.preselectedValue(value);
|
|
179
163
|
}
|
|
180
164
|
},
|
|
181
|
-
onHighlightedChange:
|
|
165
|
+
onHighlightedChange: focusedRange === 'compare' ? onCompareHighlightedChange : onHighlightedChange,
|
|
182
166
|
onDisplayedPeriodChange: onDisplayedPeriodChange
|
|
183
167
|
};
|
|
184
168
|
}
|
|
@@ -211,17 +195,26 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
211
195
|
var _ref10, _this3$asProps$value$, _this3$asProps$value, _this3$asProps$value2;
|
|
212
196
|
_this3.handlers.highlighted([]);
|
|
213
197
|
_this3.handlers.compareHighlighted([]);
|
|
214
|
-
_this3.
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
range: 'value'
|
|
219
|
-
});
|
|
198
|
+
_this3.handlers.preselectedValue(undefined);
|
|
199
|
+
_this3.handlers.preselectedCompare(undefined);
|
|
200
|
+
_this3.handlers.compareToggle(undefined);
|
|
201
|
+
_this3.handlers.focusedRange('value');
|
|
220
202
|
_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);
|
|
221
203
|
}
|
|
204
|
+
var _this3$asProps = _this3.asProps,
|
|
205
|
+
value = _this3$asProps.value,
|
|
206
|
+
displayedPeriod = _this3$asProps.displayedPeriod;
|
|
207
|
+
var newDisplayedPeriod = value ? getLatestDate(value.value, value.compare) : undefined;
|
|
208
|
+
if (visible && newDisplayedPeriod && newDisplayedPeriod !== displayedPeriod) {
|
|
209
|
+
_this3.handlers.displayedPeriod(newDisplayedPeriod);
|
|
210
|
+
}
|
|
222
211
|
}],
|
|
223
212
|
highlighted: null,
|
|
224
213
|
compareHighlighted: null,
|
|
214
|
+
preselectedValue: null,
|
|
215
|
+
preselectedCompare: null,
|
|
216
|
+
compareToggle: null,
|
|
217
|
+
focusedRange: null,
|
|
225
218
|
value: [null, function (value) {
|
|
226
219
|
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) {
|
|
227
220
|
var _date$isValid;
|
|
@@ -235,16 +228,15 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
235
228
|
key: "getApplyProps",
|
|
236
229
|
value: function getApplyProps() {
|
|
237
230
|
var _this4 = this;
|
|
238
|
-
var _this$
|
|
239
|
-
value = _this$
|
|
240
|
-
getI18nText = _this$
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
dirtyCompare = _this$state3.dirtyCompare;
|
|
231
|
+
var _this$asProps3 = this.asProps,
|
|
232
|
+
value = _this$asProps3.value,
|
|
233
|
+
getI18nText = _this$asProps3.getI18nText,
|
|
234
|
+
preselectedValue = _this$asProps3.preselectedValue,
|
|
235
|
+
preselectedCompare = _this$asProps3.preselectedCompare;
|
|
244
236
|
return {
|
|
245
237
|
getI18nText: getI18nText,
|
|
246
238
|
onClick: function onClick() {
|
|
247
|
-
return _this4.handleApply(
|
|
239
|
+
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);
|
|
248
240
|
}
|
|
249
241
|
};
|
|
250
242
|
}
|
|
@@ -282,9 +274,9 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
282
274
|
}, {
|
|
283
275
|
key: "getTitleProps",
|
|
284
276
|
value: function getTitleProps(props, index) {
|
|
285
|
-
var _this$
|
|
286
|
-
locale = _this$
|
|
287
|
-
displayedPeriod = _this$
|
|
277
|
+
var _this$asProps4 = this.asProps,
|
|
278
|
+
locale = _this$asProps4.locale,
|
|
279
|
+
displayedPeriod = _this$asProps4.displayedPeriod;
|
|
288
280
|
return {
|
|
289
281
|
children: new Intl.DateTimeFormat(locale, {
|
|
290
282
|
month: 'long',
|
|
@@ -302,9 +294,9 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
302
294
|
placeholder = _ref11$placeholder === void 0 ? 'Select date ranges' : _ref11$placeholder,
|
|
303
295
|
_ref11$separator = _ref11.separator,
|
|
304
296
|
separator = _ref11$separator === void 0 ? 'vs.' : _ref11$separator;
|
|
305
|
-
var _this$
|
|
306
|
-
locale = _this$
|
|
307
|
-
visible = _this$
|
|
297
|
+
var _this$asProps5 = this.asProps,
|
|
298
|
+
locale = _this$asProps5.locale,
|
|
299
|
+
visible = _this$asProps5.visible;
|
|
308
300
|
var value = (_this$asProps$value3 = this.asProps.value) === null || _this$asProps$value3 === void 0 ? void 0 : _this$asProps$value3.value;
|
|
309
301
|
var compare = (_this$asProps$value4 = this.asProps.value) === null || _this$asProps$value4 === void 0 ? void 0 : _this$asProps$value4.compare;
|
|
310
302
|
var formattingProps = {
|
|
@@ -337,23 +329,20 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
337
329
|
key: "getValueDateRangeProps",
|
|
338
330
|
value: function getValueDateRangeProps() {
|
|
339
331
|
var _this7 = this;
|
|
340
|
-
var _this$
|
|
341
|
-
value = _this$
|
|
342
|
-
onDisplayedPeriodChange = _this$
|
|
343
|
-
locale = _this$
|
|
344
|
-
disabled = _this$
|
|
345
|
-
size = _this$
|
|
346
|
-
getI18nText = _this$
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
dirtyValue = _this$state4.dirtyValue;
|
|
332
|
+
var _this$asProps6 = this.asProps,
|
|
333
|
+
value = _this$asProps6.value,
|
|
334
|
+
onDisplayedPeriodChange = _this$asProps6.onDisplayedPeriodChange,
|
|
335
|
+
locale = _this$asProps6.locale,
|
|
336
|
+
disabled = _this$asProps6.disabled,
|
|
337
|
+
size = _this$asProps6.size,
|
|
338
|
+
getI18nText = _this$asProps6.getI18nText,
|
|
339
|
+
focusedRange = _this$asProps6.focusedRange,
|
|
340
|
+
preselectedValue = _this$asProps6.preselectedValue;
|
|
350
341
|
return {
|
|
351
|
-
focused:
|
|
352
|
-
value:
|
|
342
|
+
focused: focusedRange === 'value' ? true : undefined,
|
|
343
|
+
value: preselectedValue !== null && preselectedValue !== void 0 ? preselectedValue : value === null || value === void 0 ? void 0 : value.value,
|
|
353
344
|
onChange: function onChange(value) {
|
|
354
|
-
return _this7.
|
|
355
|
-
dirtyValue: value
|
|
356
|
-
});
|
|
345
|
+
return _this7.handlers.preselectedValue(value);
|
|
357
346
|
},
|
|
358
347
|
onDisplayedPeriodChange: onDisplayedPeriodChange,
|
|
359
348
|
locale: locale,
|
|
@@ -362,9 +351,7 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
362
351
|
children: this.getRangeInput(),
|
|
363
352
|
getI18nText: getI18nText,
|
|
364
353
|
onFocus: function onFocus() {
|
|
365
|
-
_this7.
|
|
366
|
-
range: 'value'
|
|
367
|
-
});
|
|
354
|
+
_this7.handlers.focusedRange('value');
|
|
368
355
|
return false;
|
|
369
356
|
}
|
|
370
357
|
};
|
|
@@ -374,25 +361,22 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
374
361
|
value: function getCompareDateRangeProps() {
|
|
375
362
|
var _value$compare,
|
|
376
363
|
_this8 = this;
|
|
377
|
-
var _this$
|
|
378
|
-
value = _this$
|
|
379
|
-
onDisplayedPeriodChange = _this$
|
|
380
|
-
locale = _this$
|
|
381
|
-
disabled = _this$
|
|
382
|
-
size = _this$
|
|
383
|
-
getI18nText = _this$
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
dirtyToggler = _this$state5.dirtyToggler;
|
|
364
|
+
var _this$asProps7 = this.asProps,
|
|
365
|
+
value = _this$asProps7.value,
|
|
366
|
+
onDisplayedPeriodChange = _this$asProps7.onDisplayedPeriodChange,
|
|
367
|
+
locale = _this$asProps7.locale,
|
|
368
|
+
disabled = _this$asProps7.disabled,
|
|
369
|
+
size = _this$asProps7.size,
|
|
370
|
+
getI18nText = _this$asProps7.getI18nText,
|
|
371
|
+
focusedRange = _this$asProps7.focusedRange,
|
|
372
|
+
preselectedCompare = _this$asProps7.preselectedCompare,
|
|
373
|
+
compareToggle = _this$asProps7.compareToggle;
|
|
388
374
|
return {
|
|
389
|
-
focused:
|
|
390
|
-
disabled: !(
|
|
391
|
-
value:
|
|
375
|
+
focused: focusedRange === 'compare' ? true : undefined,
|
|
376
|
+
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),
|
|
377
|
+
value: preselectedCompare !== null && preselectedCompare !== void 0 ? preselectedCompare : value === null || value === void 0 ? void 0 : value.compare,
|
|
392
378
|
onChange: function onChange(value) {
|
|
393
|
-
return _this8.
|
|
394
|
-
dirtyCompare: value
|
|
395
|
-
});
|
|
379
|
+
return _this8.handlers.preselectedCompare(value);
|
|
396
380
|
},
|
|
397
381
|
onDisplayedPeriodChange: onDisplayedPeriodChange,
|
|
398
382
|
locale: locale,
|
|
@@ -401,9 +385,7 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
401
385
|
children: this.getRangeInput(),
|
|
402
386
|
getI18nText: getI18nText,
|
|
403
387
|
onFocus: function onFocus() {
|
|
404
|
-
_this8.
|
|
405
|
-
range: 'compare'
|
|
406
|
-
});
|
|
388
|
+
_this8.handlers.focusedRange('compare');
|
|
407
389
|
return false;
|
|
408
390
|
}
|
|
409
391
|
};
|
|
@@ -413,25 +395,20 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
413
395
|
value: function getCompareToggleProps() {
|
|
414
396
|
var _value$compare2,
|
|
415
397
|
_this9 = this;
|
|
416
|
-
var _this$
|
|
417
|
-
getI18nText = _this$
|
|
418
|
-
value = _this$
|
|
419
|
-
|
|
398
|
+
var _this$asProps8 = this.asProps,
|
|
399
|
+
getI18nText = _this$asProps8.getI18nText,
|
|
400
|
+
value = _this$asProps8.value,
|
|
401
|
+
compareToggle = _this$asProps8.compareToggle;
|
|
420
402
|
return {
|
|
421
403
|
getI18nText: getI18nText,
|
|
422
|
-
checked:
|
|
404
|
+
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,
|
|
423
405
|
onChange: function onChange(checked) {
|
|
424
406
|
if (checked) {
|
|
425
|
-
_this9.
|
|
426
|
-
|
|
427
|
-
dirtyToggler: true
|
|
428
|
-
});
|
|
407
|
+
_this9.handlers.compareToggle(true);
|
|
408
|
+
_this9.handlers.focusedRange('compare');
|
|
429
409
|
} else {
|
|
430
|
-
_this9.
|
|
431
|
-
|
|
432
|
-
dirtyCompare: [],
|
|
433
|
-
dirtyToggler: false
|
|
434
|
-
});
|
|
410
|
+
_this9.handlers.compareToggle(false);
|
|
411
|
+
_this9.handlers.focusedRange('value');
|
|
435
412
|
}
|
|
436
413
|
}
|
|
437
414
|
};
|
|
@@ -439,19 +416,18 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
439
416
|
}, {
|
|
440
417
|
key: "getCalendarProps",
|
|
441
418
|
value: function getCalendarProps(_props, index) {
|
|
442
|
-
var _this$
|
|
443
|
-
locale = _this$
|
|
444
|
-
displayedPeriod = _this$
|
|
445
|
-
disabled = _this$
|
|
446
|
-
value = _this$
|
|
447
|
-
onCompareHighlightedChange = _this$
|
|
448
|
-
highlighted = _this$
|
|
449
|
-
compareHighlighted = _this$
|
|
450
|
-
onHighlightedChange = _this$
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
range = _this$state6.range;
|
|
419
|
+
var _this$asProps9 = this.asProps,
|
|
420
|
+
locale = _this$asProps9.locale,
|
|
421
|
+
displayedPeriod = _this$asProps9.displayedPeriod,
|
|
422
|
+
disabled = _this$asProps9.disabled,
|
|
423
|
+
value = _this$asProps9.value,
|
|
424
|
+
onCompareHighlightedChange = _this$asProps9.onCompareHighlightedChange,
|
|
425
|
+
highlighted = _this$asProps9.highlighted,
|
|
426
|
+
compareHighlighted = _this$asProps9.compareHighlighted,
|
|
427
|
+
onHighlightedChange = _this$asProps9.onHighlightedChange,
|
|
428
|
+
preselectedCompare = _this$asProps9.preselectedCompare,
|
|
429
|
+
preselectedValue = _this$asProps9.preselectedValue,
|
|
430
|
+
focusedRange = _this$asProps9.focusedRange;
|
|
455
431
|
return {
|
|
456
432
|
locale: locale,
|
|
457
433
|
displayedPeriod: (0, _dayjs["default"])(displayedPeriod).add(index, this.navigateStep).startOf(this.navigateStep).toDate(),
|
|
@@ -461,9 +437,9 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
461
437
|
compareHighlighted: compareHighlighted,
|
|
462
438
|
onCompareHighlightedChange: onCompareHighlightedChange,
|
|
463
439
|
onHighlightedChange: onHighlightedChange,
|
|
464
|
-
range:
|
|
465
|
-
value:
|
|
466
|
-
compare:
|
|
440
|
+
range: focusedRange,
|
|
441
|
+
value: preselectedValue !== null && preselectedValue !== void 0 ? preselectedValue : value === null || value === void 0 ? void 0 : value.value,
|
|
442
|
+
compare: preselectedCompare !== null && preselectedCompare !== void 0 ? preselectedCompare : value === null || value === void 0 ? void 0 : value.compare
|
|
467
443
|
};
|
|
468
444
|
}
|
|
469
445
|
}, {
|
|
@@ -478,10 +454,10 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
478
454
|
value: function render() {
|
|
479
455
|
var _ref = this.asProps,
|
|
480
456
|
_ref4;
|
|
481
|
-
var _this$
|
|
482
|
-
Children = _this$
|
|
483
|
-
styles = _this$
|
|
484
|
-
providedAriaLabel = _this$
|
|
457
|
+
var _this$asProps10 = this.asProps,
|
|
458
|
+
Children = _this$asProps10.Children,
|
|
459
|
+
styles = _this$asProps10.styles,
|
|
460
|
+
providedAriaLabel = _this$asProps10['aria-label'];
|
|
485
461
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, (_ref4 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(_dropdown["default"], (0, _core.assignProps)({
|
|
486
462
|
"use:aria-label": providedAriaLabel,
|
|
487
463
|
"__excludeProps": ['onChange', 'value']
|
|
@@ -502,6 +478,10 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
502
478
|
defaultCompareHighlighted: [],
|
|
503
479
|
defaultDisplayedPeriod: getLatestDate(primaryRange, defaultPrimaryRange, secondaryRange, defaultSecondaryRange) || defaultDisplayedPeriod,
|
|
504
480
|
defaultVisible: false,
|
|
481
|
+
defaultPreselectedValue: null,
|
|
482
|
+
defaultPreselectedCompare: null,
|
|
483
|
+
defaultCompareToggle: null,
|
|
484
|
+
defaultFocusedRange: 'value',
|
|
505
485
|
disabled: [],
|
|
506
486
|
size: 'm'
|
|
507
487
|
};
|