@semcore/date-picker 4.29.2 → 4.30.0
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 +16 -1
- package/lib/cjs/DatePicker.js +1 -1
- package/lib/cjs/DatePicker.js.map +1 -1
- package/lib/cjs/DateRangeComparator.js +11 -8
- package/lib/cjs/DateRangeComparator.js.map +1 -1
- package/lib/cjs/MonthDateRangeComparator.js +7 -6
- package/lib/cjs/MonthDateRangeComparator.js.map +1 -1
- package/lib/cjs/components/Calendar.js +156 -72
- package/lib/cjs/components/Calendar.js.map +1 -1
- package/lib/cjs/components/DateRangeComparatorAbstract.js +206 -123
- package/lib/cjs/components/DateRangeComparatorAbstract.js.map +1 -1
- package/lib/cjs/components/InputTrigger.js +50 -38
- package/lib/cjs/components/InputTrigger.js.map +1 -1
- package/lib/cjs/components/PickerAbstract.js +38 -29
- package/lib/cjs/components/PickerAbstract.js.map +1 -1
- package/lib/cjs/components/RangePickerAbstract.js +105 -79
- package/lib/cjs/components/RangePickerAbstract.js.map +1 -1
- package/lib/cjs/components/index.js +4 -4
- package/lib/cjs/components/index.js.map +1 -1
- package/lib/cjs/style/calendar.shadow.css +7 -3
- package/lib/cjs/translations/en.json +8 -1
- package/lib/cjs/utils/formatDate.js +19 -7
- package/lib/cjs/utils/formatDate.js.map +1 -1
- package/lib/es6/DatePicker.js +2 -2
- package/lib/es6/DatePicker.js.map +1 -1
- package/lib/es6/DateRangeComparator.js +11 -8
- package/lib/es6/DateRangeComparator.js.map +1 -1
- package/lib/es6/MonthDateRangeComparator.js +7 -6
- package/lib/es6/MonthDateRangeComparator.js.map +1 -1
- package/lib/es6/components/Calendar.js +157 -73
- package/lib/es6/components/Calendar.js.map +1 -1
- package/lib/es6/components/DateRangeComparatorAbstract.js +206 -123
- package/lib/es6/components/DateRangeComparatorAbstract.js.map +1 -1
- package/lib/es6/components/InputTrigger.js +50 -38
- package/lib/es6/components/InputTrigger.js.map +1 -1
- package/lib/es6/components/PickerAbstract.js +38 -29
- package/lib/es6/components/PickerAbstract.js.map +1 -1
- package/lib/es6/components/RangePickerAbstract.js +105 -79
- package/lib/es6/components/RangePickerAbstract.js.map +1 -1
- package/lib/es6/components/index.js +4 -4
- package/lib/es6/components/index.js.map +1 -1
- package/lib/es6/style/calendar.shadow.css +7 -3
- package/lib/es6/translations/en.json +8 -1
- package/lib/es6/utils/formatDate.js +16 -5
- package/lib/es6/utils/formatDate.js.map +1 -1
- package/package.json +14 -14
|
@@ -12,6 +12,7 @@ exports.Header = Header;
|
|
|
12
12
|
exports.Reset = Reset;
|
|
13
13
|
exports.Trigger = Trigger;
|
|
14
14
|
exports["default"] = void 0;
|
|
15
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
16
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
16
17
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
17
18
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
@@ -29,34 +30,36 @@ var _intergalacticDynamicLocales = require("../translations/__intergalactic-dyna
|
|
|
29
30
|
var _shortDateRangeFormat = _interopRequireDefault(require("../utils/shortDateRangeFormat"));
|
|
30
31
|
var _checkbox = _interopRequireDefault(require("@semcore/checkbox"));
|
|
31
32
|
var _baseTrigger = require("@semcore/base-trigger");
|
|
33
|
+
var _formatDate = require("../utils/formatDate");
|
|
32
34
|
/*__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
|
-
"_disabled": "
|
|
46
|
-
"__SHumanizedDate": "
|
|
47
|
-
"__SSingleDateInput": "
|
|
48
|
-
"__SValue": "
|
|
49
|
-
"__SDateRange": "
|
|
50
|
-
"__SMask": "
|
|
51
|
-
"_noHumanizedDate": "
|
|
52
|
-
"__SRangeSep": "
|
|
53
|
-
"_fulfilled": "
|
|
54
|
-
"__SRangeComparatorHeader": "
|
|
55
|
-
"__SRangeCalendar": "
|
|
56
|
-
"__SFooter": "
|
|
57
|
-
"__SPeriodsList": "
|
|
58
|
-
"__SPopper": "
|
|
35
|
+
var style = ( /*__reshadow_css_start__*/_core.sstyled.insert( /*__inner_css_start__*/".___SPopper_hw5in_gg_{padding:var(--intergalactic-spacing-4x, 16px);outline:0}.___SPopper_hw5in_gg_::-moz-focus-inner{border:0;padding:0}.___SPopper_hw5in_gg_:active,.___SPopper_hw5in_gg_:focus{outline:0;-webkit-text-decoration:none;text-decoration:none}@media (hover:hover){.___SPopper_hw5in_gg_:hover{outline:0;-webkit-text-decoration:none;text-decoration:none}}.___SPopper_hw5in_gg_:focus{box-shadow:var(--intergalactic-keyboard-focus, 0px 0px 0px 3px rgba(0, 143, 248, 0.5))}.___SHeader_hw5in_gg_,.___STitle_hw5in_gg_{display:flex;align-items:center}.___STitle_hw5in_gg_{font-size:var(--intergalactic-fs-200, 14px);color:var(--intergalactic-text-primary, #191b23);height:32px;width:100%;justify-content:center}.___SToday_hw5in_gg_{display:flex;margin-top:var(--intergalactic-spacing-3x, 12px);justify-content:center}.___SPeriod_hw5in_gg_{display:flex;flex-direction:column;margin-bottom:var(--intergalactic-spacing-2x, 8px)}.___SButton_hw5in_gg_ .___SInner_hw5in_gg_{justify-content:flex-start}.___SInputMask_hw5in_gg_{color:var(--intergalactic-text-primary, #191b23);line-height:normal}.___SIndicator_hw5in_gg_{color:var(--intergalactic-text-secondary, #6c6e79)}.___SRangeIndicator_hw5in_gg_{border-radius:50%;flex-shrink:0}.___SRangeIndicator_hw5in_gg_._range_value_hw5in_gg_{background-color:var(--intergalactic-date-picker-cell-active, #2bb3ff)}.___SRangeIndicator_hw5in_gg_._range_compare_hw5in_gg_{background-color:var(--intergalactic-date-picker-cell-comparison-active, #8649e1)}.___SRangeIndicator_hw5in_gg_.__disabled_hw5in_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3)}.___SHumanizedDate_hw5in_gg_{position:absolute;pointer-events:none}.___SDateRange_hw5in_gg_ .___SMask_hw5in_gg_,.___SDateRange_hw5in_gg_ .___SValue_hw5in_gg_,.___SSingleDateInput_hw5in_gg_ .___SMask_hw5in_gg_,.___SSingleDateInput_hw5in_gg_ .___SValue_hw5in_gg_{opacity:0}.___SSingleDateInput_hw5in_gg_:focus-within .___SHumanizedDate_hw5in_gg_{opacity:0;z-index:var(--intergalactic-z-index-deep, -999)}.___SSingleDateInput_hw5in_gg_:focus-within .___SMask_hw5in_gg_,.___SSingleDateInput_hw5in_gg_:focus-within .___SValue_hw5in_gg_{opacity:1}.___SDateRange_hw5in_gg_:focus-within .___SHumanizedDate_hw5in_gg_{opacity:0;z-index:var(--intergalactic-z-index-deep, -999)}.___SDateRange_hw5in_gg_:focus-within .___SMask_hw5in_gg_,.___SDateRange_hw5in_gg_:focus-within .___SValue_hw5in_gg_{opacity:1}.___SInputMask_hw5in_gg_.__noHumanizedDate_hw5in_gg_ .___SMask_hw5in_gg_,.___SInputMask_hw5in_gg_.__noHumanizedDate_hw5in_gg_ .___SValue_hw5in_gg_{opacity:1}.___SDateRange_hw5in_gg_ .___SInputMask_hw5in_gg_:focus-within .___SMask_hw5in_gg_{background-color:var(--intergalactic-bg-highlight-focus, rgba(0, 143, 248, 0.2))}.___SDateRange_hw5in_gg_:focus-within .___SRangeSep_hw5in_gg_,.___SRangeSep_hw5in_gg_.__fulfilled_hw5in_gg_{color:var(--intergalactic-text-primary, #191b23)}.___SRangeComparatorHeader_hw5in_gg_{border-bottom:1px solid var(--intergalactic-border-primary, #c4c7cf)}.___SRangeCalendar_hw5in_gg_,.___SRangeComparatorHeader_hw5in_gg_{padding:var(--intergalactic-spacing-4x, 16px)}.___SFooter_hw5in_gg_{border-top:1px solid var(--intergalactic-border-primary, #c4c7cf)}.___SFooter_hw5in_gg_,.___SPeriodsList_hw5in_gg_{padding:var(--intergalactic-spacing-4x, 16px)}" /*__inner_css_end__*/, "hw5in_gg_") /*__reshadow_css_end__*/, {
|
|
36
|
+
"__SHeader": "___SHeader_hw5in_gg_",
|
|
37
|
+
"__STitle": "___STitle_hw5in_gg_",
|
|
38
|
+
"__SToday": "___SToday_hw5in_gg_",
|
|
39
|
+
"__SPeriod": "___SPeriod_hw5in_gg_",
|
|
40
|
+
"__SButton": "___SButton_hw5in_gg_",
|
|
41
|
+
"__SInner": "___SInner_hw5in_gg_",
|
|
42
|
+
"__SInputMask": "___SInputMask_hw5in_gg_",
|
|
43
|
+
"__SIndicator": "___SIndicator_hw5in_gg_",
|
|
44
|
+
"__SRangeIndicator": "___SRangeIndicator_hw5in_gg_",
|
|
45
|
+
"_range_value": "_range_value_hw5in_gg_",
|
|
46
|
+
"_range_compare": "_range_compare_hw5in_gg_",
|
|
47
|
+
"_disabled": "__disabled_hw5in_gg_",
|
|
48
|
+
"__SHumanizedDate": "___SHumanizedDate_hw5in_gg_",
|
|
49
|
+
"__SSingleDateInput": "___SSingleDateInput_hw5in_gg_",
|
|
50
|
+
"__SValue": "___SValue_hw5in_gg_",
|
|
51
|
+
"__SDateRange": "___SDateRange_hw5in_gg_",
|
|
52
|
+
"__SMask": "___SMask_hw5in_gg_",
|
|
53
|
+
"_noHumanizedDate": "__noHumanizedDate_hw5in_gg_",
|
|
54
|
+
"__SRangeSep": "___SRangeSep_hw5in_gg_",
|
|
55
|
+
"_fulfilled": "__fulfilled_hw5in_gg_",
|
|
56
|
+
"__SRangeComparatorHeader": "___SRangeComparatorHeader_hw5in_gg_",
|
|
57
|
+
"__SRangeCalendar": "___SRangeCalendar_hw5in_gg_",
|
|
58
|
+
"__SFooter": "___SFooter_hw5in_gg_",
|
|
59
|
+
"__SPeriodsList": "___SPeriodsList_hw5in_gg_",
|
|
60
|
+
"__SPopper": "___SPopper_hw5in_gg_"
|
|
59
61
|
});
|
|
62
|
+
var INTERACTION_TAGS = ['INPUT'];
|
|
60
63
|
var INTERACTION_KEYS = ['ArrowDown', 'Enter', 'Space'];
|
|
61
64
|
var defaultDisplayedPeriod = new Date(new Date().setHours(0, 0, 0, 0));
|
|
62
65
|
var getLatestDate = function getLatestDate() {
|
|
@@ -84,6 +87,7 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
84
87
|
}
|
|
85
88
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
86
89
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "popperRef", /*#__PURE__*/_react["default"].createRef());
|
|
90
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "unitRefs", {});
|
|
87
91
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "navigateView", function (direction) {
|
|
88
92
|
var displayedPeriod = _this.asProps.displayedPeriod;
|
|
89
93
|
var action = direction >= 1 ? 'add' : 'subtract';
|
|
@@ -95,6 +99,13 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
95
99
|
return _this.navigateView(direction);
|
|
96
100
|
};
|
|
97
101
|
});
|
|
102
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleApplyClick", function () {
|
|
103
|
+
var _this$asProps = _this.asProps,
|
|
104
|
+
value = _this$asProps.value,
|
|
105
|
+
preselectedValue = _this$asProps.preselectedValue,
|
|
106
|
+
preselectedCompare = _this$asProps.preselectedCompare;
|
|
107
|
+
return _this.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);
|
|
108
|
+
});
|
|
98
109
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleApply", function (value, compare) {
|
|
99
110
|
_this.handlers.value({
|
|
100
111
|
value: value,
|
|
@@ -102,26 +113,97 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
102
113
|
});
|
|
103
114
|
_this.handlers.visible(false);
|
|
104
115
|
});
|
|
105
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
116
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleKeydownDown", function (place) {
|
|
117
|
+
return function (e) {
|
|
118
|
+
var _this$asProps2 = _this.asProps,
|
|
119
|
+
displayedPeriod = _this$asProps2.displayedPeriod,
|
|
120
|
+
preselectedValue = _this$asProps2.preselectedValue,
|
|
121
|
+
visible = _this$asProps2.visible,
|
|
122
|
+
focusedRange = _this$asProps2.focusedRange;
|
|
123
|
+
var key = e.code;
|
|
124
|
+
var highlighted = focusedRange === 'compare' ? _this.asProps.compareHighlighted : _this.asProps.highlighted;
|
|
125
|
+
if (place === 'trigger' && INTERACTION_KEYS.includes(key)) {
|
|
126
|
+
e.stopPropagation();
|
|
127
|
+
_this.handlers.visible(!visible);
|
|
128
|
+
setTimeout(function () {
|
|
129
|
+
var popper = _this.popperRef.current;
|
|
130
|
+
if (popper) {
|
|
131
|
+
popper.focus();
|
|
132
|
+
}
|
|
133
|
+
}, 0);
|
|
134
|
+
}
|
|
135
|
+
var day = _this.keyDiff[key];
|
|
136
|
+
var setNextDisplayedPeriod = function setNextDisplayedPeriod(next_highlighted) {
|
|
137
|
+
var _next_highlighted = (0, _slicedToArray2["default"])(next_highlighted, 2),
|
|
138
|
+
left_period = _next_highlighted[0],
|
|
139
|
+
right_period = _next_highlighted[1];
|
|
140
|
+
var monthDisplayedPeriod = displayedPeriod === null || displayedPeriod === void 0 ? void 0 : displayedPeriod.getMonth();
|
|
141
|
+
var period = right_period || left_period;
|
|
142
|
+
if (period) {
|
|
143
|
+
if (!monthDisplayedPeriod) {
|
|
144
|
+
return period;
|
|
145
|
+
}
|
|
146
|
+
if (period.getMonth() - monthDisplayedPeriod > 1) {
|
|
147
|
+
return DateRangeComparatorAbstract.subtract(period, 1, 'month');
|
|
148
|
+
} else if (period.getMonth() - monthDisplayedPeriod < 0) {
|
|
149
|
+
return period;
|
|
150
|
+
}
|
|
115
151
|
}
|
|
116
|
-
|
|
117
|
-
|
|
152
|
+
return displayedPeriod;
|
|
153
|
+
};
|
|
154
|
+
if (place === 'popper' && e.code === 'Space' && highlighted.length) {
|
|
155
|
+
var highlightedDate = highlighted[1] || highlighted[0];
|
|
156
|
+
if (!_this.isDisabled(highlightedDate)) {
|
|
157
|
+
_this.handleChange(highlightedDate);
|
|
158
|
+
}
|
|
159
|
+
e.preventDefault();
|
|
160
|
+
}
|
|
161
|
+
if (place === 'popper' && e.code === 'Enter' && (e.metaKey || e.ctrlKey)) {
|
|
162
|
+
return _this.handleApplyClick();
|
|
163
|
+
}
|
|
164
|
+
var changedDate = undefined;
|
|
165
|
+
if (day) {
|
|
166
|
+
if (INTERACTION_TAGS.includes(e.target.tagName)) return;
|
|
167
|
+
if (highlighted.length) {
|
|
168
|
+
var next_highlighted;
|
|
169
|
+
if ((preselectedValue === null || preselectedValue === void 0 ? void 0 : preselectedValue.length) === 1) {
|
|
170
|
+
next_highlighted = [preselectedValue[0], (0, _dayjs["default"])(highlighted[1] || highlighted[0]).add(day, _this.keyStep).toDate()];
|
|
171
|
+
changedDate = next_highlighted[1];
|
|
172
|
+
} else {
|
|
173
|
+
next_highlighted = [(0, _dayjs["default"])(highlighted[0]).add(day, _this.keyStep).toDate()];
|
|
174
|
+
changedDate = next_highlighted[0];
|
|
175
|
+
}
|
|
176
|
+
if (focusedRange === 'compare') {
|
|
177
|
+
_this.handlers.compareHighlighted(next_highlighted);
|
|
178
|
+
} else {
|
|
179
|
+
_this.handlers.highlighted(next_highlighted);
|
|
180
|
+
}
|
|
181
|
+
_this.handlers.displayedPeriod(setNextDisplayedPeriod(next_highlighted));
|
|
182
|
+
} else {
|
|
183
|
+
var _highlighted = [displayedPeriod ? displayedPeriod : (0, _dayjs["default"])().toDate()];
|
|
184
|
+
if (focusedRange === 'compare') {
|
|
185
|
+
_this.handlers.compareHighlighted(_highlighted);
|
|
186
|
+
} else {
|
|
187
|
+
_this.handlers.highlighted(_highlighted);
|
|
188
|
+
}
|
|
189
|
+
changedDate = _highlighted[0];
|
|
190
|
+
}
|
|
191
|
+
e.preventDefault();
|
|
192
|
+
if (changedDate) {
|
|
193
|
+
var _this$unitRefs$format;
|
|
194
|
+
var formatter = _this.keyStep === 'month' ? _formatDate.formatMMYY : _formatDate.formatDDMMYY;
|
|
195
|
+
var formattedDate = formatter(changedDate, _this.asProps.locale);
|
|
196
|
+
(_this$unitRefs$format = _this.unitRefs[formattedDate]) === null || _this$unitRefs$format === void 0 ? void 0 : _this$unitRefs$format.focus();
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
};
|
|
118
200
|
});
|
|
119
201
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleChange", function (date) {
|
|
120
202
|
var _value, _value2, _value3;
|
|
121
|
-
var _this$
|
|
122
|
-
focusedRange = _this$
|
|
123
|
-
preselectedCompare = _this$
|
|
124
|
-
preselectedValue = _this$
|
|
203
|
+
var _this$asProps3 = _this.asProps,
|
|
204
|
+
focusedRange = _this$asProps3.focusedRange,
|
|
205
|
+
preselectedCompare = _this$asProps3.preselectedCompare,
|
|
206
|
+
preselectedValue = _this$asProps3.preselectedValue;
|
|
125
207
|
var highlighted = [];
|
|
126
208
|
var value = focusedRange === 'compare' ? preselectedCompare : preselectedValue;
|
|
127
209
|
if (Array.isArray(date)) {
|
|
@@ -154,15 +236,15 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
154
236
|
value: function getPeriodProps() {
|
|
155
237
|
var _this$asProps$value,
|
|
156
238
|
_this2 = this;
|
|
157
|
-
var _this$
|
|
158
|
-
_this$
|
|
159
|
-
periods = _this$
|
|
160
|
-
onHighlightedChange = _this$
|
|
161
|
-
onCompareHighlightedChange = _this$
|
|
162
|
-
onDisplayedPeriodChange = _this$
|
|
163
|
-
preselectedValue = _this$
|
|
164
|
-
preselectedCompare = _this$
|
|
165
|
-
focusedRange = _this$
|
|
239
|
+
var _this$asProps4 = this.asProps,
|
|
240
|
+
_this$asProps4$period = _this$asProps4.periods,
|
|
241
|
+
periods = _this$asProps4$period === void 0 ? this.getDefaultPeriods() : _this$asProps4$period,
|
|
242
|
+
onHighlightedChange = _this$asProps4.onHighlightedChange,
|
|
243
|
+
onCompareHighlightedChange = _this$asProps4.onCompareHighlightedChange,
|
|
244
|
+
onDisplayedPeriodChange = _this$asProps4.onDisplayedPeriodChange,
|
|
245
|
+
preselectedValue = _this$asProps4.preselectedValue,
|
|
246
|
+
preselectedCompare = _this$asProps4.preselectedCompare,
|
|
247
|
+
focusedRange = _this$asProps4.focusedRange;
|
|
166
248
|
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;
|
|
167
249
|
if (focusedRange === 'compare') {
|
|
168
250
|
var _this$asProps$value2;
|
|
@@ -248,28 +330,21 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
248
330
|
}, {
|
|
249
331
|
key: "getApplyProps",
|
|
250
332
|
value: function getApplyProps() {
|
|
251
|
-
var
|
|
252
|
-
var _this$asProps3 = this.asProps,
|
|
253
|
-
value = _this$asProps3.value,
|
|
254
|
-
getI18nText = _this$asProps3.getI18nText,
|
|
255
|
-
preselectedValue = _this$asProps3.preselectedValue,
|
|
256
|
-
preselectedCompare = _this$asProps3.preselectedCompare;
|
|
333
|
+
var getI18nText = this.asProps.getI18nText;
|
|
257
334
|
return {
|
|
258
335
|
getI18nText: getI18nText,
|
|
259
|
-
onClick:
|
|
260
|
-
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);
|
|
261
|
-
}
|
|
336
|
+
onClick: this.handleApplyClick
|
|
262
337
|
};
|
|
263
338
|
}
|
|
264
339
|
}, {
|
|
265
340
|
key: "getResetProps",
|
|
266
341
|
value: function getResetProps() {
|
|
267
|
-
var
|
|
342
|
+
var _this4 = this;
|
|
268
343
|
var getI18nText = this.asProps.getI18nText;
|
|
269
344
|
return {
|
|
270
345
|
getI18nText: getI18nText,
|
|
271
346
|
onClick: function onClick() {
|
|
272
|
-
return
|
|
347
|
+
return _this4.handleApply(null, null);
|
|
273
348
|
}
|
|
274
349
|
};
|
|
275
350
|
}
|
|
@@ -295,9 +370,9 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
295
370
|
}, {
|
|
296
371
|
key: "getTitleProps",
|
|
297
372
|
value: function getTitleProps(props, index) {
|
|
298
|
-
var _this$
|
|
299
|
-
locale = _this$
|
|
300
|
-
displayedPeriod = _this$
|
|
373
|
+
var _this$asProps5 = this.asProps,
|
|
374
|
+
locale = _this$asProps5.locale,
|
|
375
|
+
displayedPeriod = _this$asProps5.displayedPeriod;
|
|
301
376
|
return {
|
|
302
377
|
children: new Intl.DateTimeFormat(locale, {
|
|
303
378
|
month: 'long',
|
|
@@ -310,14 +385,14 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
310
385
|
value: function getTriggerProps(_ref10) {
|
|
311
386
|
var _this$asProps$value3,
|
|
312
387
|
_this$asProps$value4,
|
|
313
|
-
|
|
388
|
+
_this5 = this;
|
|
314
389
|
var _ref10$placeholder = _ref10.placeholder,
|
|
315
390
|
placeholder = _ref10$placeholder === void 0 ? 'Select date ranges' : _ref10$placeholder,
|
|
316
391
|
_ref10$separator = _ref10.separator,
|
|
317
392
|
separator = _ref10$separator === void 0 ? 'vs.' : _ref10$separator;
|
|
318
|
-
var _this$
|
|
319
|
-
locale = _this$
|
|
320
|
-
visible = _this$
|
|
393
|
+
var _this$asProps6 = this.asProps,
|
|
394
|
+
locale = _this$asProps6.locale,
|
|
395
|
+
visible = _this$asProps6.visible;
|
|
321
396
|
var value = (_this$asProps$value3 = this.asProps.value) === null || _this$asProps$value3 === void 0 ? void 0 : _this$asProps$value3.value;
|
|
322
397
|
var compare = (_this$asProps$value4 = this.asProps.value) === null || _this$asProps$value4 === void 0 ? void 0 : _this$asProps$value4.compare;
|
|
323
398
|
var formattingProps = {
|
|
@@ -337,9 +412,9 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
337
412
|
children: children,
|
|
338
413
|
visible: visible,
|
|
339
414
|
onClick: function onClick() {
|
|
340
|
-
return
|
|
415
|
+
return _this5.handlers.visible(!visible);
|
|
341
416
|
},
|
|
342
|
-
onKeyDown: this.
|
|
417
|
+
onKeyDown: this.handleKeydownDown('trigger')
|
|
343
418
|
};
|
|
344
419
|
}
|
|
345
420
|
}, {
|
|
@@ -350,21 +425,21 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
350
425
|
}, {
|
|
351
426
|
key: "getValueDateRangeProps",
|
|
352
427
|
value: function getValueDateRangeProps() {
|
|
353
|
-
var
|
|
354
|
-
var _this$
|
|
355
|
-
value = _this$
|
|
356
|
-
onDisplayedPeriodChange = _this$
|
|
357
|
-
locale = _this$
|
|
358
|
-
disabled = _this$
|
|
359
|
-
size = _this$
|
|
360
|
-
getI18nText = _this$
|
|
361
|
-
focusedRange = _this$
|
|
362
|
-
preselectedValue = _this$
|
|
428
|
+
var _this6 = this;
|
|
429
|
+
var _this$asProps7 = this.asProps,
|
|
430
|
+
value = _this$asProps7.value,
|
|
431
|
+
onDisplayedPeriodChange = _this$asProps7.onDisplayedPeriodChange,
|
|
432
|
+
locale = _this$asProps7.locale,
|
|
433
|
+
disabled = _this$asProps7.disabled,
|
|
434
|
+
size = _this$asProps7.size,
|
|
435
|
+
getI18nText = _this$asProps7.getI18nText,
|
|
436
|
+
focusedRange = _this$asProps7.focusedRange,
|
|
437
|
+
preselectedValue = _this$asProps7.preselectedValue;
|
|
363
438
|
return {
|
|
364
439
|
focused: focusedRange === 'value' ? true : undefined,
|
|
365
440
|
value: preselectedValue !== null && preselectedValue !== void 0 ? preselectedValue : value === null || value === void 0 ? void 0 : value.value,
|
|
366
441
|
onChange: function onChange(value) {
|
|
367
|
-
return
|
|
442
|
+
return _this6.handlers.preselectedValue(value);
|
|
368
443
|
},
|
|
369
444
|
onDisplayedPeriodChange: onDisplayedPeriodChange,
|
|
370
445
|
locale: locale,
|
|
@@ -373,7 +448,7 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
373
448
|
children: this.getRangeInput(),
|
|
374
449
|
getI18nText: getI18nText,
|
|
375
450
|
onFocus: function onFocus() {
|
|
376
|
-
|
|
451
|
+
_this6.handlers.focusedRange('value');
|
|
377
452
|
return false;
|
|
378
453
|
}
|
|
379
454
|
};
|
|
@@ -382,23 +457,23 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
382
457
|
key: "getCompareDateRangeProps",
|
|
383
458
|
value: function getCompareDateRangeProps() {
|
|
384
459
|
var _value$compare,
|
|
385
|
-
|
|
386
|
-
var _this$
|
|
387
|
-
value = _this$
|
|
388
|
-
onDisplayedPeriodChange = _this$
|
|
389
|
-
locale = _this$
|
|
390
|
-
disabled = _this$
|
|
391
|
-
size = _this$
|
|
392
|
-
getI18nText = _this$
|
|
393
|
-
focusedRange = _this$
|
|
394
|
-
preselectedCompare = _this$
|
|
395
|
-
compareToggle = _this$
|
|
460
|
+
_this7 = this;
|
|
461
|
+
var _this$asProps8 = this.asProps,
|
|
462
|
+
value = _this$asProps8.value,
|
|
463
|
+
onDisplayedPeriodChange = _this$asProps8.onDisplayedPeriodChange,
|
|
464
|
+
locale = _this$asProps8.locale,
|
|
465
|
+
disabled = _this$asProps8.disabled,
|
|
466
|
+
size = _this$asProps8.size,
|
|
467
|
+
getI18nText = _this$asProps8.getI18nText,
|
|
468
|
+
focusedRange = _this$asProps8.focusedRange,
|
|
469
|
+
preselectedCompare = _this$asProps8.preselectedCompare,
|
|
470
|
+
compareToggle = _this$asProps8.compareToggle;
|
|
396
471
|
return {
|
|
397
472
|
focused: focusedRange === 'compare' ? true : undefined,
|
|
398
473
|
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),
|
|
399
474
|
value: preselectedCompare !== null && preselectedCompare !== void 0 ? preselectedCompare : value === null || value === void 0 ? void 0 : value.compare,
|
|
400
475
|
onChange: function onChange(value) {
|
|
401
|
-
return
|
|
476
|
+
return _this7.handlers.preselectedCompare(value);
|
|
402
477
|
},
|
|
403
478
|
onDisplayedPeriodChange: onDisplayedPeriodChange,
|
|
404
479
|
locale: locale,
|
|
@@ -407,7 +482,7 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
407
482
|
children: this.getRangeInput(),
|
|
408
483
|
getI18nText: getI18nText,
|
|
409
484
|
onFocus: function onFocus() {
|
|
410
|
-
|
|
485
|
+
_this7.handlers.focusedRange('compare');
|
|
411
486
|
return false;
|
|
412
487
|
}
|
|
413
488
|
};
|
|
@@ -416,21 +491,21 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
416
491
|
key: "getCompareToggleProps",
|
|
417
492
|
value: function getCompareToggleProps() {
|
|
418
493
|
var _value$compare2,
|
|
419
|
-
|
|
420
|
-
var _this$
|
|
421
|
-
getI18nText = _this$
|
|
422
|
-
value = _this$
|
|
423
|
-
compareToggle = _this$
|
|
494
|
+
_this8 = this;
|
|
495
|
+
var _this$asProps9 = this.asProps,
|
|
496
|
+
getI18nText = _this$asProps9.getI18nText,
|
|
497
|
+
value = _this$asProps9.value,
|
|
498
|
+
compareToggle = _this$asProps9.compareToggle;
|
|
424
499
|
return {
|
|
425
500
|
getI18nText: getI18nText,
|
|
426
501
|
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,
|
|
427
502
|
onChange: function onChange(checked) {
|
|
428
503
|
if (checked) {
|
|
429
|
-
|
|
430
|
-
|
|
504
|
+
_this8.handlers.compareToggle(true);
|
|
505
|
+
_this8.handlers.focusedRange('compare');
|
|
431
506
|
} else {
|
|
432
|
-
|
|
433
|
-
|
|
507
|
+
_this8.handlers.compareToggle(false);
|
|
508
|
+
_this8.handlers.focusedRange('value');
|
|
434
509
|
}
|
|
435
510
|
}
|
|
436
511
|
};
|
|
@@ -438,18 +513,19 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
438
513
|
}, {
|
|
439
514
|
key: "getCalendarProps",
|
|
440
515
|
value: function getCalendarProps(_props, index) {
|
|
441
|
-
var _this$
|
|
442
|
-
locale = _this$
|
|
443
|
-
displayedPeriod = _this$
|
|
444
|
-
disabled = _this$
|
|
445
|
-
value = _this$
|
|
446
|
-
onCompareHighlightedChange = _this$
|
|
447
|
-
highlighted = _this$
|
|
448
|
-
compareHighlighted = _this$
|
|
449
|
-
onHighlightedChange = _this$
|
|
450
|
-
preselectedCompare = _this$
|
|
451
|
-
preselectedValue = _this$
|
|
452
|
-
focusedRange = _this$
|
|
516
|
+
var _this$asProps10 = this.asProps,
|
|
517
|
+
locale = _this$asProps10.locale,
|
|
518
|
+
displayedPeriod = _this$asProps10.displayedPeriod,
|
|
519
|
+
disabled = _this$asProps10.disabled,
|
|
520
|
+
value = _this$asProps10.value,
|
|
521
|
+
onCompareHighlightedChange = _this$asProps10.onCompareHighlightedChange,
|
|
522
|
+
highlighted = _this$asProps10.highlighted,
|
|
523
|
+
compareHighlighted = _this$asProps10.compareHighlighted,
|
|
524
|
+
onHighlightedChange = _this$asProps10.onHighlightedChange,
|
|
525
|
+
preselectedCompare = _this$asProps10.preselectedCompare,
|
|
526
|
+
preselectedValue = _this$asProps10.preselectedValue,
|
|
527
|
+
focusedRange = _this$asProps10.focusedRange,
|
|
528
|
+
getI18nText = _this$asProps10.getI18nText;
|
|
453
529
|
return {
|
|
454
530
|
locale: locale,
|
|
455
531
|
displayedPeriod: (0, _dayjs["default"])(displayedPeriod).add(index, this.navigateStep).startOf(this.navigateStep).toDate(),
|
|
@@ -461,7 +537,10 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
461
537
|
onHighlightedChange: onHighlightedChange,
|
|
462
538
|
range: focusedRange,
|
|
463
539
|
value: preselectedValue !== null && preselectedValue !== void 0 ? preselectedValue : value === null || value === void 0 ? void 0 : value.value,
|
|
464
|
-
compare: preselectedCompare !== null && preselectedCompare !== void 0 ? preselectedCompare : value === null || value === void 0 ? void 0 : value.compare
|
|
540
|
+
compare: preselectedCompare !== null && preselectedCompare !== void 0 ? preselectedCompare : value === null || value === void 0 ? void 0 : value.compare,
|
|
541
|
+
unitRefs: this.unitRefs,
|
|
542
|
+
getI18nText: getI18nText,
|
|
543
|
+
actionsDescribing: index === 0 ? 'range-compare' : null
|
|
465
544
|
};
|
|
466
545
|
}
|
|
467
546
|
}, {
|
|
@@ -469,7 +548,8 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
469
548
|
value: function getPopperProps() {
|
|
470
549
|
return {
|
|
471
550
|
p: 0,
|
|
472
|
-
ref: this.popperRef
|
|
551
|
+
ref: this.popperRef,
|
|
552
|
+
onKeyDown: this.handleKeydownDown('popper')
|
|
473
553
|
};
|
|
474
554
|
}
|
|
475
555
|
}, {
|
|
@@ -477,10 +557,10 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
477
557
|
value: function render() {
|
|
478
558
|
var _ref = this.asProps,
|
|
479
559
|
_ref4;
|
|
480
|
-
var _this$
|
|
481
|
-
Children = _this$
|
|
482
|
-
styles = _this$
|
|
483
|
-
providedAriaLabel = _this$
|
|
560
|
+
var _this$asProps11 = this.asProps,
|
|
561
|
+
Children = _this$asProps11.Children,
|
|
562
|
+
styles = _this$asProps11.styles,
|
|
563
|
+
providedAriaLabel = _this$asProps11['aria-label'];
|
|
484
564
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, (_ref4 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(_dropdown["default"], (0, _core.assignProps)({
|
|
485
565
|
"use:aria-label": providedAriaLabel,
|
|
486
566
|
"__excludeProps": ['onChange', 'value']
|
|
@@ -515,6 +595,9 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
515
595
|
(0, _defineProperty2["default"])(DateRangeComparatorAbstract, "displayName", 'DateRangeComparator');
|
|
516
596
|
(0, _defineProperty2["default"])(DateRangeComparatorAbstract, "style", style);
|
|
517
597
|
(0, _defineProperty2["default"])(DateRangeComparatorAbstract, "enhance", [(0, _i18nEnhance["default"])(_intergalacticDynamicLocales.localizedMessages)]);
|
|
598
|
+
(0, _defineProperty2["default"])(DateRangeComparatorAbstract, "subtract", function (date, amount, unit) {
|
|
599
|
+
return (0, _dayjs["default"])(date).subtract(amount, unit).toDate();
|
|
600
|
+
});
|
|
518
601
|
function Apply(props) {
|
|
519
602
|
var _ref2 = arguments[0];
|
|
520
603
|
var getI18nText = props.getI18nText;
|