@semcore/date-picker 4.57.0 → 4.57.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 +6 -0
- package/lib/cjs/components/Calendar.js +24 -22
- package/lib/cjs/components/Calendar.js.map +1 -1
- package/lib/cjs/components/DateRangeComparatorAbstract.js +32 -30
- package/lib/cjs/components/DateRangeComparatorAbstract.js.map +1 -1
- package/lib/cjs/components/InputTrigger.js +32 -30
- package/lib/cjs/components/InputTrigger.js.map +1 -1
- package/lib/cjs/components/PickerAbstract.js +32 -30
- package/lib/cjs/components/PickerAbstract.js.map +1 -1
- package/lib/cjs/components/RangePickerAbstract.js +32 -30
- package/lib/cjs/components/RangePickerAbstract.js.map +1 -1
- package/lib/es6/components/Calendar.js +24 -22
- package/lib/es6/components/Calendar.js.map +1 -1
- package/lib/es6/components/DateRangeComparatorAbstract.js +32 -30
- package/lib/es6/components/DateRangeComparatorAbstract.js.map +1 -1
- package/lib/es6/components/InputTrigger.js +32 -30
- package/lib/es6/components/InputTrigger.js.map +1 -1
- package/lib/es6/components/PickerAbstract.js +32 -30
- package/lib/es6/components/PickerAbstract.js.map +1 -1
- package/lib/es6/components/RangePickerAbstract.js +32 -30
- package/lib/es6/components/RangePickerAbstract.js.map +1 -1
- package/lib/esm/DatePicker.mjs +114 -103
- package/lib/esm/DateRangeComparator.mjs +166 -149
- package/lib/esm/DateRangePicker.mjs +85 -77
- package/lib/esm/MonthDateRangeComparator.mjs +187 -169
- package/lib/esm/MonthPicker.mjs +78 -71
- package/lib/esm/MonthRangePicker.mjs +94 -85
- package/lib/esm/components/ButtonTrigger.mjs +16 -15
- package/lib/esm/components/Calendar.mjs +409 -287
- package/lib/esm/components/DateRangeComparatorAbstract.mjs +458 -330
- package/lib/esm/components/InputTrigger.mjs +762 -519
- package/lib/esm/components/PickerAbstract.mjs +196 -149
- package/lib/esm/components/RangePickerAbstract.mjs +310 -221
- package/lib/esm/components/index.mjs +127 -109
- package/lib/esm/index.mjs +13 -13
- package/lib/esm/style/calendar.shadow.css +259 -0
- package/lib/esm/style/date-picker.shadow.css +179 -0
- package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +32 -32
- package/lib/esm/translations/de.json.mjs +83 -56
- package/lib/esm/translations/en.json.mjs +95 -64
- package/lib/esm/translations/es.json.mjs +83 -56
- package/lib/esm/translations/fr.json.mjs +83 -56
- package/lib/esm/translations/it.json.mjs +83 -56
- package/lib/esm/translations/ja.json.mjs +83 -56
- package/lib/esm/translations/ko.json.mjs +83 -56
- package/lib/esm/translations/nl.json.mjs +83 -56
- package/lib/esm/translations/pl.json.mjs +83 -56
- package/lib/esm/translations/pt.json.mjs +83 -56
- package/lib/esm/translations/ru.json.mjs +35 -24
- package/lib/esm/translations/sv.json.mjs +83 -56
- package/lib/esm/translations/tr.json.mjs +83 -56
- package/lib/esm/translations/vi.json.mjs +83 -56
- package/lib/esm/translations/zh.json.mjs +83 -56
- package/lib/esm/utils/cronTabScheduler.mjs +58 -52
- package/lib/esm/utils/datesIntersects.mjs +15 -11
- package/lib/esm/utils/formatDate.mjs +25 -18
- package/lib/esm/utils/includesDate.mjs +13 -9
- package/lib/esm/utils/shortDateRangeFormat.mjs +53 -31
- package/package.json +15 -15
|
@@ -1,213 +1,308 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { sstyled
|
|
10
|
-
import { sstyled as
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import { Flex
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import { localizedMessages
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import { LinkTrigger
|
|
21
|
-
import { includesDate
|
|
22
|
-
import { formatMMYY
|
|
23
|
-
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
5
|
+
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
6
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
7
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
8
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
9
|
+
import { sstyled } from "@semcore/utils/lib/core/index";
|
|
10
|
+
import { sstyled as sstyled$1, assignProps, Component } from "@semcore/core";
|
|
11
|
+
import React from "react";
|
|
12
|
+
import dayjs from "dayjs";
|
|
13
|
+
import Button from "@semcore/button";
|
|
14
|
+
import { Flex } from "@semcore/flex-box";
|
|
15
|
+
import Dropdown from "@semcore/dropdown";
|
|
16
|
+
import i18nEnhance from "@semcore/utils/lib/enhances/i18nEnhance";
|
|
17
|
+
import { localizedMessages } from "../translations/__intergalactic-dynamic-locales.mjs";
|
|
18
|
+
import shortDateRangeFormat from "../utils/shortDateRangeFormat.mjs";
|
|
19
|
+
import Checkbox from "@semcore/checkbox";
|
|
20
|
+
import { LinkTrigger } from "@semcore/base-trigger";
|
|
21
|
+
import { includesDate } from "../utils/includesDate.mjs";
|
|
22
|
+
import { formatMMYY, formatDDMMYY } from "../utils/formatDate.mjs";
|
|
23
|
+
/*!__reshadow-styles__:"../style/date-picker.shadow.css"*/
|
|
24
|
+
var style = (
|
|
24
25
|
/*__reshadow_css_start__*/
|
|
25
|
-
(
|
|
26
|
+
(sstyled.insert(
|
|
26
27
|
/*__inner_css_start__*/
|
|
27
|
-
".
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
28
|
+
".___SPopper_svfjr_gg_{padding:var(--intergalactic-spacing-4x, 16px);outline:0}.___SPopper_svfjr_gg_::-moz-focus-inner{border:0;padding:0}.___SPopper_svfjr_gg_:active,.___SPopper_svfjr_gg_:focus{outline:0;-webkit-text-decoration:none;text-decoration:none}@media (hover:hover){.___SPopper_svfjr_gg_:hover{outline:0;-webkit-text-decoration:none;text-decoration:none}}.___SPopper_svfjr_gg_:focus{box-shadow:var(--intergalactic-keyboard-focus, 0px 0px 0px 3px rgba(0, 143, 248, 0.5))}.___SHeader_svfjr_gg_,.___STitle_svfjr_gg_{display:flex;align-items:center}.___STitle_svfjr_gg_{font-size:var(--intergalactic-fs-200, 14px);color:var(--intergalactic-text-primary, #191b23);height:32px;width:100%;justify-content:center}.___SToday_svfjr_gg_{display:flex;margin-top:var(--intergalactic-spacing-3x, 12px);justify-content:center}.___SPeriod_svfjr_gg_{display:flex;flex-direction:column;margin-bottom:var(--intergalactic-spacing-2x, 8px)}.___SButton_svfjr_gg_ .___SInner_svfjr_gg_{justify-content:flex-start}.___SInputMask_svfjr_gg_{color:var(--intergalactic-text-primary, #191b23);line-height:normal;padding-right:var(--intergalactic-spacing-2x, 8px);transition:width calc(var(--intergalactic-duration-medium, 300)*1ms) ease,min-width calc(var(--intergalactic-duration-medium, 300)*1ms) ease}.___SInputMask_svfjr_gg_.__animationsDisabled_svfjr_gg_{transition:none}.___SInputMask_svfjr_gg_ .___SValue_svfjr_gg_{letter-spacing:0}.___SIndicator_svfjr_gg_{color:var(--intergalactic-text-secondary, #6c6e79)}.___SRangeIndicator_svfjr_gg_{border-radius:50%;flex-shrink:0}.___SRangeIndicator_svfjr_gg_._range_value_svfjr_gg_{background-color:var(--intergalactic-date-picker-cell-active, #2bb3ff)}.___SRangeIndicator_svfjr_gg_._range_compare_svfjr_gg_{background-color:var(--intergalactic-date-picker-cell-comparison-active, #8649e1)}.___SRangeIndicator_svfjr_gg_.__disabled_svfjr_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3)}.___SHumanizedDate_svfjr_gg_{position:absolute;pointer-events:none;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;width:100%}.___SMask_svfjr_gg_{letter-spacing:0;white-space:nowrap;overflow:hidden}.___SDateRange_svfjr_gg_ .___SMask_svfjr_gg_,.___SDateRange_svfjr_gg_ .___SValue_svfjr_gg_,.___SSingleDateInput_svfjr_gg_ .___SMask_svfjr_gg_,.___SSingleDateInput_svfjr_gg_ .___SValue_svfjr_gg_{opacity:0}.___SSingleDateInput_svfjr_gg_:focus-within .___SHumanizedDate_svfjr_gg_{opacity:0;z-index:var(--intergalactic-z-index-deep, -999)}.___SSingleDateInput_svfjr_gg_:focus-within .___SMask_svfjr_gg_,.___SSingleDateInput_svfjr_gg_:focus-within .___SValue_svfjr_gg_{opacity:1}.___SDateRange_svfjr_gg_:focus-within .___SHumanizedDate_svfjr_gg_{opacity:0;z-index:var(--intergalactic-z-index-deep, -999)}.___SDateRange_svfjr_gg_:focus-within .___SMask_svfjr_gg_,.___SDateRange_svfjr_gg_:focus-within .___SValue_svfjr_gg_{opacity:1}.___SInputMask_svfjr_gg_.__noHumanizedDate_svfjr_gg_ .___SMask_svfjr_gg_,.___SInputMask_svfjr_gg_.__noHumanizedDate_svfjr_gg_ .___SValue_svfjr_gg_{opacity:1}.___SDateRange_svfjr_gg_ .___SInputMask_svfjr_gg_:focus-within .___SMask_svfjr_gg_{background-color:var(--intergalactic-bg-highlight-focus, rgba(0, 143, 248, 0.2))}.___SDateRange_svfjr_gg_:focus-within .___SRangeSep_svfjr_gg_,.___SRangeSep_svfjr_gg_.__fulfilled_svfjr_gg_{color:var(--intergalactic-text-primary, #191b23)}.___SRangeComparatorHeader_svfjr_gg_{border-bottom:1px solid var(--intergalactic-border-primary, #c4c7cf)}.___SRangeCalendar_svfjr_gg_,.___SRangeComparatorHeader_svfjr_gg_{padding:var(--intergalactic-spacing-4x, 16px)}.___SFooter_svfjr_gg_{border-top:1px solid var(--intergalactic-border-primary, #c4c7cf)}.___SFooter_svfjr_gg_,.___SPeriodsList_svfjr_gg_{padding:var(--intergalactic-spacing-4x, 16px)}.___STooltip_svfjr_gg_{padding:var(--intergalactic-spacing-3x, 12px)}.___SCompareToggle_svfjr_gg_{white-space:nowrap}@media (prefers-reduced-motion){.___SInputMask_svfjr_gg_{transition:none}}",
|
|
29
|
+
/*__inner_css_end__*/
|
|
30
|
+
"svfjr_gg_"
|
|
31
|
+
), /*__reshadow_css_end__*/
|
|
32
|
+
{
|
|
33
|
+
"__SHeader": "___SHeader_svfjr_gg_",
|
|
34
|
+
"__STitle": "___STitle_svfjr_gg_",
|
|
35
|
+
"__SToday": "___SToday_svfjr_gg_",
|
|
36
|
+
"__SPeriod": "___SPeriod_svfjr_gg_",
|
|
37
|
+
"__SButton": "___SButton_svfjr_gg_",
|
|
38
|
+
"__SInner": "___SInner_svfjr_gg_",
|
|
39
|
+
"__SInputMask": "___SInputMask_svfjr_gg_",
|
|
40
|
+
"_animationsDisabled": "__animationsDisabled_svfjr_gg_",
|
|
41
|
+
"__SValue": "___SValue_svfjr_gg_",
|
|
42
|
+
"__SIndicator": "___SIndicator_svfjr_gg_",
|
|
43
|
+
"__SRangeIndicator": "___SRangeIndicator_svfjr_gg_",
|
|
44
|
+
"_range_value": "_range_value_svfjr_gg_",
|
|
45
|
+
"_range_compare": "_range_compare_svfjr_gg_",
|
|
46
|
+
"_disabled": "__disabled_svfjr_gg_",
|
|
47
|
+
"__SHumanizedDate": "___SHumanizedDate_svfjr_gg_",
|
|
48
|
+
"__SMask": "___SMask_svfjr_gg_",
|
|
49
|
+
"__SSingleDateInput": "___SSingleDateInput_svfjr_gg_",
|
|
50
|
+
"__SDateRange": "___SDateRange_svfjr_gg_",
|
|
51
|
+
"_noHumanizedDate": "__noHumanizedDate_svfjr_gg_",
|
|
52
|
+
"__SRangeSep": "___SRangeSep_svfjr_gg_",
|
|
53
|
+
"_fulfilled": "__fulfilled_svfjr_gg_",
|
|
54
|
+
"__SRangeComparatorHeader": "___SRangeComparatorHeader_svfjr_gg_",
|
|
55
|
+
"__SRangeCalendar": "___SRangeCalendar_svfjr_gg_",
|
|
56
|
+
"__SFooter": "___SFooter_svfjr_gg_",
|
|
57
|
+
"__SPeriodsList": "___SPeriodsList_svfjr_gg_",
|
|
58
|
+
"__STooltip": "___STooltip_svfjr_gg_",
|
|
59
|
+
"__SCompareToggle": "___SCompareToggle_svfjr_gg_",
|
|
60
|
+
"__SPopper": "___SPopper_svfjr_gg_"
|
|
58
61
|
})
|
|
59
|
-
)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
);
|
|
63
|
+
var INTERACTION_TAGS = ["INPUT"];
|
|
64
|
+
var INTERACTION_KEYS = ["ArrowDown", "Enter", " "];
|
|
65
|
+
var defaultDisplayedPeriod = new Date((/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0));
|
|
66
|
+
var getLatestDate = function getLatestDate2() {
|
|
67
|
+
for (var _len = arguments.length, dateRanges = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
68
|
+
dateRanges[_key] = arguments[_key];
|
|
69
|
+
}
|
|
70
|
+
var allDates = dateRanges.flat().filter(Boolean).filter(function(date) {
|
|
71
|
+
return !Number.isNaN(new Date(date).getTime());
|
|
64
72
|
});
|
|
65
|
-
if (!
|
|
66
|
-
|
|
67
|
-
return new Date(
|
|
73
|
+
if (!allDates.length) return null;
|
|
74
|
+
allDates.sort(function(a, b) {
|
|
75
|
+
return new Date(b).getTime() - new Date(a).getTime();
|
|
68
76
|
});
|
|
69
|
-
var
|
|
70
|
-
return
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
77
|
+
var latestDate = allDates[0];
|
|
78
|
+
return latestDate;
|
|
79
|
+
};
|
|
80
|
+
var DateRangeComparatorAbstract = /* @__PURE__ */ function(_Component) {
|
|
81
|
+
_inherits(DateRangeComparatorAbstract2, _Component);
|
|
82
|
+
var _super = _createSuper(DateRangeComparatorAbstract2);
|
|
83
|
+
function DateRangeComparatorAbstract2() {
|
|
84
|
+
var _this;
|
|
85
|
+
_classCallCheck(this, DateRangeComparatorAbstract2);
|
|
86
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
87
|
+
args[_key2] = arguments[_key2];
|
|
88
|
+
}
|
|
89
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
90
|
+
_defineProperty(_assertThisInitialized(_this), "popperRef", /* @__PURE__ */ React.createRef());
|
|
91
|
+
_defineProperty(_assertThisInitialized(_this), "unitRefs", {});
|
|
92
|
+
_defineProperty(_assertThisInitialized(_this), "navigateView", function(direction) {
|
|
93
|
+
var displayedPeriod = _this.asProps.displayedPeriod;
|
|
94
|
+
var action = direction >= 1 ? "add" : "subtract";
|
|
95
|
+
var date = dayjs(displayedPeriod)[action](1, _this.navigateStep).toDate();
|
|
96
|
+
_this.handlers.displayedPeriod(date);
|
|
97
|
+
});
|
|
98
|
+
_defineProperty(_assertThisInitialized(_this), "bindHandlerNavigateClick", function(direction) {
|
|
83
99
|
return function() {
|
|
84
|
-
return
|
|
100
|
+
return _this.navigateView(direction);
|
|
85
101
|
};
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
var
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
102
|
+
});
|
|
103
|
+
_defineProperty(_assertThisInitialized(_this), "handleApplyClick", function() {
|
|
104
|
+
var _this$asProps = _this.asProps, value = _this$asProps.value, preselectedValue = _this$asProps.preselectedValue, preselectedCompare = _this$asProps.preselectedCompare;
|
|
105
|
+
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);
|
|
106
|
+
});
|
|
107
|
+
_defineProperty(_assertThisInitialized(_this), "handleApply", function(value, compare) {
|
|
108
|
+
_this.handlers.value({
|
|
109
|
+
value,
|
|
110
|
+
compare
|
|
111
|
+
});
|
|
112
|
+
_this.handlers.visible(false);
|
|
113
|
+
});
|
|
114
|
+
_defineProperty(_assertThisInitialized(_this), "handleKeydownDown", function(place) {
|
|
115
|
+
return function(e) {
|
|
116
|
+
var _this$asProps2 = _this.asProps, displayedPeriod = _this$asProps2.displayedPeriod, preselectedValue = _this$asProps2.preselectedValue, visible = _this$asProps2.visible, focusedRange = _this$asProps2.focusedRange;
|
|
117
|
+
var key = e.key;
|
|
118
|
+
var highlighted = focusedRange === "compare" ? _this.asProps.compareHighlighted : _this.asProps.highlighted;
|
|
119
|
+
if (place === "trigger" && INTERACTION_KEYS.includes(key)) {
|
|
120
|
+
e.preventDefault();
|
|
121
|
+
e.stopPropagation();
|
|
122
|
+
_this.handlers.visible(!visible);
|
|
123
|
+
setTimeout(function() {
|
|
124
|
+
var popper = _this.popperRef.current;
|
|
125
|
+
if (popper) {
|
|
126
|
+
popper.focus();
|
|
127
|
+
}
|
|
128
|
+
}, 0);
|
|
129
|
+
}
|
|
130
|
+
var day = _this.keyDiff[key];
|
|
131
|
+
var setNextDisplayedPeriod = function setNextDisplayedPeriod2(next_highlighted2) {
|
|
132
|
+
var _next_highlighted = _slicedToArray(next_highlighted2, 2), startPeriod = _next_highlighted[0], endPeriod = _next_highlighted[1];
|
|
133
|
+
var highlightedPeriod = endPeriod || startPeriod;
|
|
134
|
+
var displayedPeriodNormalized = displayedPeriod === null || displayedPeriod === void 0 ? void 0 : displayedPeriod.getDate();
|
|
135
|
+
var highlightedPeriodNormalized = highlightedPeriod === null || highlightedPeriod === void 0 ? void 0 : highlightedPeriod.getDate();
|
|
136
|
+
if (_this.navigateStep === "month") {
|
|
137
|
+
displayedPeriodNormalized = displayedPeriod === null || displayedPeriod === void 0 ? void 0 : displayedPeriod.getMonth();
|
|
138
|
+
highlightedPeriodNormalized = highlightedPeriod === null || highlightedPeriod === void 0 ? void 0 : highlightedPeriod.getMonth();
|
|
139
|
+
}
|
|
140
|
+
if (_this.navigateStep === "year") {
|
|
141
|
+
displayedPeriodNormalized = displayedPeriod === null || displayedPeriod === void 0 ? void 0 : displayedPeriod.getYear();
|
|
142
|
+
highlightedPeriodNormalized = highlightedPeriod === null || highlightedPeriod === void 0 ? void 0 : highlightedPeriod.getYear();
|
|
143
|
+
}
|
|
144
|
+
var offset = highlightedPeriodNormalized - displayedPeriodNormalized;
|
|
145
|
+
if (offset < 0 || offset > 1) {
|
|
146
|
+
return highlightedPeriod;
|
|
147
|
+
}
|
|
148
|
+
return displayedPeriod;
|
|
106
149
|
};
|
|
107
|
-
if (
|
|
108
|
-
var
|
|
109
|
-
|
|
150
|
+
if (place === "popper" && e.key === " " && highlighted.length) {
|
|
151
|
+
var highlightedDate = highlighted[1] || highlighted[0];
|
|
152
|
+
if (!_this.isDisabled(highlightedDate)) {
|
|
153
|
+
_this.handleChange(highlightedDate);
|
|
154
|
+
}
|
|
155
|
+
e.preventDefault();
|
|
110
156
|
}
|
|
111
|
-
if (
|
|
112
|
-
return
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
if (
|
|
117
|
-
|
|
118
|
-
|
|
157
|
+
if (place === "popper" && e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
|
|
158
|
+
return _this.handleApplyClick();
|
|
159
|
+
}
|
|
160
|
+
var changedDate = void 0;
|
|
161
|
+
if (day) {
|
|
162
|
+
if (INTERACTION_TAGS.includes(e.target.tagName)) return;
|
|
163
|
+
if (highlighted.length) {
|
|
164
|
+
var next_highlighted;
|
|
165
|
+
if ((preselectedValue === null || preselectedValue === void 0 ? void 0 : preselectedValue.length) === 1) {
|
|
166
|
+
next_highlighted = [preselectedValue[0], dayjs(highlighted[1] || highlighted[0]).add(day, _this.keyStep).toDate()];
|
|
167
|
+
changedDate = next_highlighted[1];
|
|
168
|
+
} else {
|
|
169
|
+
next_highlighted = [dayjs(highlighted[0]).add(day, _this.keyStep).toDate()];
|
|
170
|
+
changedDate = next_highlighted[0];
|
|
171
|
+
}
|
|
172
|
+
if (focusedRange === "compare") {
|
|
173
|
+
_this.handlers.compareHighlighted(next_highlighted);
|
|
174
|
+
} else {
|
|
175
|
+
_this.handlers.highlighted(next_highlighted);
|
|
176
|
+
}
|
|
177
|
+
_this.handlers.displayedPeriod(setNextDisplayedPeriod(next_highlighted));
|
|
119
178
|
} else {
|
|
120
|
-
var
|
|
121
|
-
|
|
179
|
+
var _highlighted = [displayedPeriod ? displayedPeriod : dayjs().toDate()];
|
|
180
|
+
if (focusedRange === "compare") {
|
|
181
|
+
_this.handlers.compareHighlighted(_highlighted);
|
|
182
|
+
} else {
|
|
183
|
+
_this.handlers.highlighted(_highlighted);
|
|
184
|
+
}
|
|
185
|
+
changedDate = _highlighted[0];
|
|
122
186
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
187
|
+
e.preventDefault();
|
|
188
|
+
if (changedDate) {
|
|
189
|
+
var _this$unitRefs$format;
|
|
190
|
+
var formatter = _this.keyStep === "month" ? formatMMYY : formatDDMMYY;
|
|
191
|
+
var formattedDate = formatter(changedDate, _this.asProps.locale);
|
|
192
|
+
(_this$unitRefs$format = _this.unitRefs[formattedDate]) === null || _this$unitRefs$format === void 0 ? void 0 : _this$unitRefs$format.focus();
|
|
126
193
|
}
|
|
127
194
|
}
|
|
128
195
|
};
|
|
129
|
-
})
|
|
196
|
+
});
|
|
197
|
+
_defineProperty(_assertThisInitialized(_this), "triggerFormattingProps", {
|
|
130
198
|
day: "numeric",
|
|
131
199
|
month: "short",
|
|
132
200
|
year: "numeric"
|
|
133
|
-
})
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
else if (((
|
|
142
|
-
|
|
143
|
-
|
|
201
|
+
});
|
|
202
|
+
_defineProperty(_assertThisInitialized(_this), "handleChange", function(date) {
|
|
203
|
+
var _value, _value2, _value3;
|
|
204
|
+
var _this$asProps3 = _this.asProps, focusedRange = _this$asProps3.focusedRange, preselectedCompare = _this$asProps3.preselectedCompare, preselectedValue = _this$asProps3.preselectedValue;
|
|
205
|
+
var highlighted = [];
|
|
206
|
+
var value = focusedRange === "compare" ? preselectedCompare : preselectedValue;
|
|
207
|
+
if (Array.isArray(date)) {
|
|
208
|
+
value = date;
|
|
209
|
+
} else if (!((_value = value) !== null && _value !== void 0 && _value.length)) {
|
|
210
|
+
value = [date];
|
|
211
|
+
highlighted = [date];
|
|
212
|
+
} else if (((_value2 = value) === null || _value2 === void 0 ? void 0 : _value2.length) >= 2) {
|
|
213
|
+
value = [date];
|
|
214
|
+
highlighted = [date];
|
|
215
|
+
} else if (((_value3 = value) === null || _value3 === void 0 ? void 0 : _value3[0]) > date) {
|
|
216
|
+
var _value4;
|
|
217
|
+
value = [date, (_value4 = value) === null || _value4 === void 0 ? void 0 : _value4[0]];
|
|
218
|
+
} else {
|
|
219
|
+
var _value5;
|
|
220
|
+
value = [(_value5 = value) === null || _value5 === void 0 ? void 0 : _value5[0], date];
|
|
221
|
+
}
|
|
222
|
+
if (focusedRange === "compare") {
|
|
223
|
+
_this.handlers.preselectedCompare(value);
|
|
224
|
+
_this.handlers.compareHighlighted(highlighted);
|
|
144
225
|
} else {
|
|
145
|
-
|
|
146
|
-
|
|
226
|
+
_this.handlers.preselectedValue(value);
|
|
227
|
+
_this.handlers.highlighted(highlighted);
|
|
147
228
|
}
|
|
148
|
-
|
|
149
|
-
|
|
229
|
+
});
|
|
230
|
+
return _this;
|
|
150
231
|
}
|
|
151
|
-
|
|
232
|
+
_createClass(DateRangeComparatorAbstract2, [{
|
|
152
233
|
key: "getPeriodProps",
|
|
153
|
-
value: function() {
|
|
154
|
-
var
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
234
|
+
value: function getPeriodProps() {
|
|
235
|
+
var _this$asProps$value, _this2 = this;
|
|
236
|
+
var _this$asProps4 = this.asProps, _this$asProps4$period = _this$asProps4.periods, periods = _this$asProps4$period === void 0 ? this.getDefaultPeriods() : _this$asProps4$period, onHighlightedChange = _this$asProps4.onHighlightedChange, onCompareHighlightedChange = _this$asProps4.onCompareHighlightedChange, onDisplayedPeriodChange = _this$asProps4.onDisplayedPeriodChange, preselectedValue = _this$asProps4.preselectedValue, preselectedCompare = _this$asProps4.preselectedCompare, focusedRange = _this$asProps4.focusedRange, getI18nText = _this$asProps4.getI18nText;
|
|
237
|
+
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;
|
|
238
|
+
if (focusedRange === "compare") {
|
|
239
|
+
var _this$asProps$value2;
|
|
240
|
+
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;
|
|
158
241
|
}
|
|
159
242
|
return {
|
|
160
|
-
periods
|
|
161
|
-
value
|
|
162
|
-
onChange: function(
|
|
163
|
-
|
|
243
|
+
periods,
|
|
244
|
+
value,
|
|
245
|
+
onChange: function onChange(value2) {
|
|
246
|
+
if (focusedRange === "compare") {
|
|
247
|
+
_this2.handlers.preselectedCompare(value2);
|
|
248
|
+
} else {
|
|
249
|
+
_this2.handlers.preselectedValue(value2);
|
|
250
|
+
}
|
|
164
251
|
},
|
|
165
|
-
onHighlightedChange:
|
|
166
|
-
onDisplayedPeriodChange
|
|
252
|
+
onHighlightedChange: focusedRange === "compare" ? onCompareHighlightedChange : onHighlightedChange,
|
|
253
|
+
onDisplayedPeriodChange,
|
|
167
254
|
role: "listbox",
|
|
168
|
-
"aria-label":
|
|
255
|
+
"aria-label": getI18nText("periods")
|
|
169
256
|
};
|
|
170
257
|
}
|
|
171
258
|
}, {
|
|
172
259
|
key: "getPrevProps",
|
|
173
|
-
value: function() {
|
|
174
|
-
var
|
|
260
|
+
value: function getPrevProps() {
|
|
261
|
+
var getI18nText = this.asProps.getI18nText;
|
|
262
|
+
var navigateStep = this.navigateStep;
|
|
175
263
|
return {
|
|
176
|
-
getI18nText
|
|
264
|
+
getI18nText,
|
|
177
265
|
onClick: this.bindHandlerNavigateClick(-1),
|
|
178
|
-
"aria-label":
|
|
266
|
+
"aria-label": navigateStep === "month" ? getI18nText("prevMonth") : getI18nText("prevYear")
|
|
179
267
|
};
|
|
180
268
|
}
|
|
181
269
|
}, {
|
|
182
270
|
key: "getNextProps",
|
|
183
|
-
value: function() {
|
|
184
|
-
var
|
|
271
|
+
value: function getNextProps() {
|
|
272
|
+
var getI18nText = this.asProps.getI18nText;
|
|
273
|
+
var navigateStep = this.navigateStep;
|
|
185
274
|
return {
|
|
186
|
-
getI18nText
|
|
275
|
+
getI18nText,
|
|
187
276
|
onClick: this.bindHandlerNavigateClick(1),
|
|
188
|
-
"aria-label":
|
|
277
|
+
"aria-label": navigateStep === "month" ? getI18nText("nextMonth") : getI18nText("nextYear")
|
|
189
278
|
};
|
|
190
279
|
}
|
|
191
280
|
}, {
|
|
192
281
|
key: "uncontrolledProps",
|
|
193
|
-
value: function() {
|
|
194
|
-
var
|
|
282
|
+
value: function uncontrolledProps() {
|
|
283
|
+
var _this3 = this;
|
|
195
284
|
return {
|
|
196
285
|
displayedPeriod: null,
|
|
197
|
-
visible: [null, function(
|
|
198
|
-
if (!
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
286
|
+
visible: [null, function(visible) {
|
|
287
|
+
if (!visible) {
|
|
288
|
+
_this3.handlers.highlighted([]);
|
|
289
|
+
_this3.handlers.compareHighlighted([]);
|
|
290
|
+
_this3.handlers.preselectedValue(void 0);
|
|
291
|
+
_this3.handlers.preselectedCompare(void 0);
|
|
292
|
+
_this3.handlers.compareToggle(void 0);
|
|
293
|
+
_this3.handlers.focusedRange("value");
|
|
294
|
+
} else {
|
|
295
|
+
var _this3$asProps$value, _this3$asProps$value$;
|
|
296
|
+
_this3.handlers.compareToggle(!!((_this3$asProps$value = _this3.asProps.value) !== null && _this3$asProps$value !== void 0 && (_this3$asProps$value$ = _this3$asProps$value.compare) !== null && _this3$asProps$value$ !== void 0 && _this3$asProps$value$.length));
|
|
203
297
|
}
|
|
204
|
-
var
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
298
|
+
var _this3$asProps = _this3.asProps, value = _this3$asProps.value, displayedPeriod = _this3$asProps.displayedPeriod;
|
|
299
|
+
var newDisplayedPeriod = value ? getLatestDate(value.value, value.compare) : void 0;
|
|
300
|
+
if (visible) {
|
|
301
|
+
if (newDisplayedPeriod && newDisplayedPeriod !== displayedPeriod) {
|
|
302
|
+
_this3.handlers.displayedPeriod(newDisplayedPeriod);
|
|
303
|
+
} else if (!newDisplayedPeriod) {
|
|
304
|
+
var _this3$props = _this3.props, _displayedPeriod = _this3$props.displayedPeriod, _defaultDisplayedPeriod = _this3$props.defaultDisplayedPeriod;
|
|
305
|
+
_this3.handlers.displayedPeriod(_displayedPeriod || _defaultDisplayedPeriod);
|
|
211
306
|
}
|
|
212
307
|
}
|
|
213
308
|
}],
|
|
@@ -217,183 +312,207 @@ var le = (
|
|
|
217
312
|
preselectedCompare: null,
|
|
218
313
|
compareToggle: null,
|
|
219
314
|
focusedRange: null,
|
|
220
|
-
value: [null, function(
|
|
221
|
-
var
|
|
222
|
-
var
|
|
223
|
-
return
|
|
315
|
+
value: [null, function(value) {
|
|
316
|
+
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) {
|
|
317
|
+
var _date$isValid;
|
|
318
|
+
return date === null || date === void 0 ? void 0 : (_date$isValid = date.isValid) === null || _date$isValid === void 0 ? void 0 : _date$isValid.call(date);
|
|
224
319
|
});
|
|
225
|
-
|
|
320
|
+
if (dates.length > 0) _this3.handlers.displayedPeriod(getLatestDate(value));
|
|
226
321
|
}]
|
|
227
322
|
};
|
|
228
323
|
}
|
|
229
324
|
}, {
|
|
230
325
|
key: "getApplyProps",
|
|
231
|
-
value: function() {
|
|
232
|
-
var
|
|
326
|
+
value: function getApplyProps() {
|
|
327
|
+
var getI18nText = this.asProps.getI18nText;
|
|
233
328
|
return {
|
|
234
|
-
getI18nText
|
|
329
|
+
getI18nText,
|
|
235
330
|
onClick: this.handleApplyClick
|
|
236
331
|
};
|
|
237
332
|
}
|
|
238
333
|
}, {
|
|
239
334
|
key: "getResetProps",
|
|
240
|
-
value: function() {
|
|
241
|
-
var
|
|
335
|
+
value: function getResetProps() {
|
|
336
|
+
var _this4 = this;
|
|
337
|
+
var getI18nText = this.asProps.getI18nText;
|
|
242
338
|
return {
|
|
243
|
-
getI18nText
|
|
244
|
-
onClick: function() {
|
|
245
|
-
return
|
|
339
|
+
getI18nText,
|
|
340
|
+
onClick: function onClick() {
|
|
341
|
+
return _this4.handleApply(null, null);
|
|
246
342
|
}
|
|
247
343
|
};
|
|
248
344
|
}
|
|
249
345
|
}, {
|
|
250
346
|
key: "isDisabled",
|
|
251
|
-
value: function(
|
|
252
|
-
var
|
|
253
|
-
return
|
|
347
|
+
value: function isDisabled(date) {
|
|
348
|
+
var disabled = this.asProps.disabled;
|
|
349
|
+
return disabled.some(includesDate(dayjs(date), "date"));
|
|
254
350
|
}
|
|
255
351
|
}, {
|
|
256
352
|
key: "getDefaultPeriods",
|
|
257
|
-
value: function() {
|
|
258
|
-
var
|
|
353
|
+
value: function getDefaultPeriods() {
|
|
354
|
+
var getI18nText = this.asProps.getI18nText;
|
|
355
|
+
var today = new Date((/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0));
|
|
259
356
|
return [{
|
|
260
|
-
children:
|
|
261
|
-
value: [
|
|
357
|
+
children: getI18nText("lastMonth"),
|
|
358
|
+
value: [dayjs(today).subtract(1, "month").startOf("month").toDate(), dayjs(today).startOf("month").toDate()]
|
|
262
359
|
}, {
|
|
263
|
-
children:
|
|
264
|
-
value: [
|
|
360
|
+
children: getI18nText("last3Months"),
|
|
361
|
+
value: [dayjs(today).subtract(2, "month").startOf("month").toDate(), dayjs(today).startOf("month").toDate()]
|
|
265
362
|
}, {
|
|
266
|
-
children:
|
|
267
|
-
value: [
|
|
363
|
+
children: getI18nText("last6Months"),
|
|
364
|
+
value: [dayjs(today).subtract(5, "month").startOf("month").toDate(), dayjs(today).startOf("month").toDate()]
|
|
268
365
|
}, {
|
|
269
|
-
children:
|
|
270
|
-
value: [
|
|
366
|
+
children: getI18nText("last12Months"),
|
|
367
|
+
value: [dayjs(today).subtract(11, "month").startOf("month").toDate(), dayjs(today).startOf("month").toDate()]
|
|
271
368
|
}];
|
|
272
369
|
}
|
|
273
370
|
}, {
|
|
274
371
|
key: "getTitleProps",
|
|
275
|
-
value: function(
|
|
276
|
-
var
|
|
372
|
+
value: function getTitleProps(props, index) {
|
|
373
|
+
var _this$asProps5 = this.asProps, locale = _this$asProps5.locale, displayedPeriod = _this$asProps5.displayedPeriod;
|
|
277
374
|
return {
|
|
278
|
-
children: new Intl.DateTimeFormat(
|
|
375
|
+
children: new Intl.DateTimeFormat(locale, {
|
|
279
376
|
month: "long",
|
|
280
377
|
year: "numeric"
|
|
281
|
-
}).format(
|
|
378
|
+
}).format(dayjs(displayedPeriod).add(index, this.navigateStep).startOf(this.navigateStep).toDate())
|
|
282
379
|
};
|
|
283
380
|
}
|
|
284
381
|
}, {
|
|
285
382
|
key: "getTriggerProps",
|
|
286
|
-
value: function(
|
|
287
|
-
var
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
383
|
+
value: function getTriggerProps(_ref10) {
|
|
384
|
+
var _this$asProps$value3, _this$asProps$value4, _this5 = this;
|
|
385
|
+
var _ref10$placeholder = _ref10.placeholder, placeholder = _ref10$placeholder === void 0 ? "Select date ranges" : _ref10$placeholder, _ref10$separator = _ref10.separator, separator = _ref10$separator === void 0 ? "vs." : _ref10$separator;
|
|
386
|
+
var _this$asProps6 = this.asProps, locale = _this$asProps6.locale, visible = _this$asProps6.visible;
|
|
387
|
+
var value = (_this$asProps$value3 = this.asProps.value) === null || _this$asProps$value3 === void 0 ? void 0 : _this$asProps$value3.value;
|
|
388
|
+
var compare = (_this$asProps$value4 = this.asProps.value) === null || _this$asProps$value4 === void 0 ? void 0 : _this$asProps$value4.compare;
|
|
389
|
+
var formattingProps = _objectSpread({
|
|
390
|
+
locale
|
|
391
|
+
}, this.triggerFormattingProps);
|
|
392
|
+
var children = placeholder;
|
|
393
|
+
if (value !== null && value !== void 0 && value[0] && value !== null && value !== void 0 && value[1]) {
|
|
394
|
+
children = shortDateRangeFormat(value, formattingProps);
|
|
395
|
+
}
|
|
396
|
+
if (compare !== null && compare !== void 0 && compare[0] && compare !== null && compare !== void 0 && compare[1]) {
|
|
397
|
+
children = "".concat(children || "", " ").concat(separator, " ").concat(shortDateRangeFormat(compare, formattingProps));
|
|
398
|
+
}
|
|
399
|
+
return {
|
|
400
|
+
children,
|
|
401
|
+
visible,
|
|
402
|
+
onClick: function onClick() {
|
|
403
|
+
return _this5.handlers.visible(!visible);
|
|
295
404
|
},
|
|
296
405
|
onKeyDown: this.handleKeydownDown("trigger")
|
|
297
406
|
};
|
|
298
407
|
}
|
|
299
408
|
}, {
|
|
300
409
|
key: "getRangeInput",
|
|
301
|
-
value: function() {
|
|
410
|
+
value: function getRangeInput() {
|
|
302
411
|
throw new Error("not implemented");
|
|
303
412
|
}
|
|
304
413
|
}, {
|
|
305
414
|
key: "getRangeInputProps",
|
|
306
|
-
value: function() {
|
|
415
|
+
value: function getRangeInputProps() {
|
|
307
416
|
return {
|
|
308
417
|
inputRole: null
|
|
309
418
|
};
|
|
310
419
|
}
|
|
311
420
|
}, {
|
|
312
421
|
key: "getValueDateRangeProps",
|
|
313
|
-
value: function() {
|
|
314
|
-
var
|
|
422
|
+
value: function getValueDateRangeProps() {
|
|
423
|
+
var _this6 = this;
|
|
424
|
+
var _this$asProps7 = this.asProps, value = _this$asProps7.value, onDisplayedPeriodChange = _this$asProps7.onDisplayedPeriodChange, locale = _this$asProps7.locale, disabled = _this$asProps7.disabled, disabledErrorText = _this$asProps7.disabledErrorText, getI18nText = _this$asProps7.getI18nText, focusedRange = _this$asProps7.focusedRange, preselectedValue = _this$asProps7.preselectedValue, animationsDisabled = _this$asProps7.animationsDisabled, visible = _this$asProps7.visible;
|
|
315
425
|
return {
|
|
316
|
-
popoverVisible:
|
|
317
|
-
focused:
|
|
318
|
-
value:
|
|
319
|
-
onChange: function(
|
|
320
|
-
return
|
|
426
|
+
popoverVisible: visible,
|
|
427
|
+
focused: focusedRange === "value" ? true : void 0,
|
|
428
|
+
value: preselectedValue !== null && preselectedValue !== void 0 ? preselectedValue : value === null || value === void 0 ? void 0 : value.value,
|
|
429
|
+
onChange: function onChange(value2) {
|
|
430
|
+
return _this6.handlers.preselectedValue(value2);
|
|
321
431
|
},
|
|
322
|
-
onDisplayedPeriodChange
|
|
323
|
-
locale
|
|
324
|
-
disabledDates:
|
|
325
|
-
disabledErrorText
|
|
432
|
+
onDisplayedPeriodChange,
|
|
433
|
+
locale,
|
|
434
|
+
disabledDates: disabled,
|
|
435
|
+
disabledErrorText,
|
|
326
436
|
children: this.getRangeInput(),
|
|
327
|
-
getI18nText
|
|
328
|
-
onFocus: function() {
|
|
329
|
-
|
|
437
|
+
getI18nText,
|
|
438
|
+
onFocus: function onFocus() {
|
|
439
|
+
_this6.handlers.focusedRange("value");
|
|
330
440
|
},
|
|
331
|
-
animationsDisabled
|
|
441
|
+
animationsDisabled
|
|
332
442
|
};
|
|
333
443
|
}
|
|
334
444
|
}, {
|
|
335
445
|
key: "getCompareDateRangeProps",
|
|
336
|
-
value: function() {
|
|
337
|
-
var
|
|
446
|
+
value: function getCompareDateRangeProps() {
|
|
447
|
+
var _value$compare, _this7 = this;
|
|
448
|
+
var _this$asProps8 = this.asProps, value = _this$asProps8.value, onDisplayedPeriodChange = _this$asProps8.onDisplayedPeriodChange, locale = _this$asProps8.locale, disabled = _this$asProps8.disabled, disabledErrorText = _this$asProps8.disabledErrorText, getI18nText = _this$asProps8.getI18nText, focusedRange = _this$asProps8.focusedRange, preselectedCompare = _this$asProps8.preselectedCompare, compareToggle = _this$asProps8.compareToggle, animationsDisabled = _this$asProps8.animationsDisabled, visible = _this$asProps8.visible;
|
|
338
449
|
return {
|
|
339
|
-
popoverVisible:
|
|
340
|
-
focused:
|
|
341
|
-
disabled: !(
|
|
342
|
-
value:
|
|
343
|
-
onChange: function(
|
|
344
|
-
return
|
|
450
|
+
popoverVisible: visible,
|
|
451
|
+
focused: focusedRange === "compare" ? true : void 0,
|
|
452
|
+
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),
|
|
453
|
+
value: preselectedCompare !== null && preselectedCompare !== void 0 ? preselectedCompare : value === null || value === void 0 ? void 0 : value.compare,
|
|
454
|
+
onChange: function onChange(value2) {
|
|
455
|
+
return _this7.handlers.preselectedCompare(value2);
|
|
345
456
|
},
|
|
346
|
-
onDisplayedPeriodChange
|
|
347
|
-
locale
|
|
348
|
-
disabledDates:
|
|
457
|
+
onDisplayedPeriodChange,
|
|
458
|
+
locale,
|
|
459
|
+
disabledDates: disabled,
|
|
349
460
|
children: this.getRangeInput(),
|
|
350
|
-
getI18nText
|
|
351
|
-
disabledErrorText
|
|
352
|
-
onFocus: function() {
|
|
353
|
-
|
|
461
|
+
getI18nText,
|
|
462
|
+
disabledErrorText,
|
|
463
|
+
onFocus: function onFocus() {
|
|
464
|
+
_this7.handlers.focusedRange("compare");
|
|
354
465
|
},
|
|
355
|
-
animationsDisabled
|
|
466
|
+
animationsDisabled
|
|
356
467
|
};
|
|
357
468
|
}
|
|
358
469
|
}, {
|
|
359
470
|
key: "getCompareToggleProps",
|
|
360
|
-
value: function() {
|
|
361
|
-
var
|
|
362
|
-
|
|
363
|
-
|
|
471
|
+
value: function getCompareToggleProps() {
|
|
472
|
+
var _this8 = this;
|
|
473
|
+
var _this$asProps9 = this.asProps, getI18nText = _this$asProps9.getI18nText;
|
|
474
|
+
_this$asProps9.value;
|
|
475
|
+
var compareToggle = _this$asProps9.compareToggle;
|
|
364
476
|
return {
|
|
365
|
-
getI18nText
|
|
366
|
-
checked:
|
|
367
|
-
onChange: function(
|
|
368
|
-
|
|
477
|
+
getI18nText,
|
|
478
|
+
checked: compareToggle,
|
|
479
|
+
onChange: function onChange(checked) {
|
|
480
|
+
if (checked) {
|
|
481
|
+
_this8.handlers.compareToggle(true);
|
|
482
|
+
_this8.handlers.focusedRange("compare");
|
|
483
|
+
} else {
|
|
484
|
+
_this8.handlers.compareToggle(false);
|
|
485
|
+
_this8.handlers.focusedRange("value");
|
|
486
|
+
_this8.handlers.preselectedCompare([]);
|
|
487
|
+
}
|
|
369
488
|
}
|
|
370
489
|
};
|
|
371
490
|
}
|
|
372
491
|
}, {
|
|
373
492
|
key: "getCalendarProps",
|
|
374
|
-
value: function(
|
|
375
|
-
var
|
|
493
|
+
value: function getCalendarProps(_props, index) {
|
|
494
|
+
var _this$asProps10 = this.asProps, locale = _this$asProps10.locale, displayedPeriod = _this$asProps10.displayedPeriod, disabled = _this$asProps10.disabled, value = _this$asProps10.value, onCompareHighlightedChange = _this$asProps10.onCompareHighlightedChange, highlighted = _this$asProps10.highlighted, compareHighlighted = _this$asProps10.compareHighlighted, onHighlightedChange = _this$asProps10.onHighlightedChange, preselectedCompare = _this$asProps10.preselectedCompare, preselectedValue = _this$asProps10.preselectedValue, focusedRange = _this$asProps10.focusedRange, getI18nText = _this$asProps10.getI18nText;
|
|
376
495
|
return {
|
|
377
|
-
locale
|
|
378
|
-
displayedPeriod:
|
|
379
|
-
disabled
|
|
496
|
+
locale,
|
|
497
|
+
displayedPeriod: dayjs(displayedPeriod).add(index, this.navigateStep).startOf(this.navigateStep).toDate(),
|
|
498
|
+
disabled,
|
|
380
499
|
onChange: this.handleChange,
|
|
381
|
-
highlighted
|
|
382
|
-
compareHighlighted
|
|
383
|
-
onCompareHighlightedChange
|
|
384
|
-
onHighlightedChange
|
|
385
|
-
range:
|
|
386
|
-
value:
|
|
387
|
-
compare:
|
|
500
|
+
highlighted,
|
|
501
|
+
compareHighlighted,
|
|
502
|
+
onCompareHighlightedChange,
|
|
503
|
+
onHighlightedChange,
|
|
504
|
+
range: focusedRange,
|
|
505
|
+
value: preselectedValue !== null && preselectedValue !== void 0 ? preselectedValue : value === null || value === void 0 ? void 0 : value.value,
|
|
506
|
+
compare: preselectedCompare !== null && preselectedCompare !== void 0 ? preselectedCompare : value === null || value === void 0 ? void 0 : value.compare,
|
|
388
507
|
unitRefs: this.unitRefs,
|
|
389
|
-
getI18nText
|
|
390
|
-
actionsDescribing:
|
|
391
|
-
tabIndex:
|
|
508
|
+
getI18nText,
|
|
509
|
+
actionsDescribing: index === 0 ? "range-compare" : null,
|
|
510
|
+
tabIndex: index === 0 ? 0 : -1
|
|
392
511
|
};
|
|
393
512
|
}
|
|
394
513
|
}, {
|
|
395
514
|
key: "getPopperProps",
|
|
396
|
-
value: function() {
|
|
515
|
+
value: function getPopperProps() {
|
|
397
516
|
return {
|
|
398
517
|
p: 0,
|
|
399
518
|
ref: this.popperRef,
|
|
@@ -402,25 +521,26 @@ var le = (
|
|
|
402
521
|
}
|
|
403
522
|
}, {
|
|
404
523
|
key: "render",
|
|
405
|
-
value: function() {
|
|
406
|
-
var
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
524
|
+
value: function render() {
|
|
525
|
+
var _ref = this.asProps, _ref4;
|
|
526
|
+
var _this$asProps11 = this.asProps, Children = _this$asProps11.Children, styles = _this$asProps11.styles, providedAriaLabel = _this$asProps11["aria-label"];
|
|
527
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, (_ref4 = sstyled$1(styles), /* @__PURE__ */ React.createElement(Dropdown, assignProps({
|
|
528
|
+
"use:aria-label": providedAriaLabel,
|
|
529
|
+
"__excludeProps": ["onChange", "value"]
|
|
530
|
+
}, _ref), /* @__PURE__ */ React.createElement(Children, _ref4.cn("Children", {})))));
|
|
411
531
|
}
|
|
412
532
|
}], [{
|
|
413
533
|
key: "defaultProps",
|
|
414
|
-
value: function(
|
|
415
|
-
var
|
|
534
|
+
value: function defaultProps(_ref11) {
|
|
535
|
+
var primaryRange = _ref11.primaryRange, defaultPrimaryRange = _ref11.defaultPrimaryRange, secondaryRange = _ref11.secondaryRange, defaultSecondaryRange = _ref11.defaultSecondaryRange;
|
|
416
536
|
return {
|
|
417
|
-
i18n:
|
|
537
|
+
i18n: localizedMessages,
|
|
418
538
|
locale: "en",
|
|
419
539
|
defaultValue: null,
|
|
420
540
|
defaultHighlighted: [],
|
|
421
541
|
defaultCompareHighlighted: [],
|
|
422
|
-
defaultDisplayedPeriod:
|
|
423
|
-
defaultVisible:
|
|
542
|
+
defaultDisplayedPeriod: getLatestDate(primaryRange, defaultPrimaryRange, secondaryRange, defaultSecondaryRange) || defaultDisplayedPeriod,
|
|
543
|
+
defaultVisible: false,
|
|
424
544
|
defaultPreselectedValue: null,
|
|
425
545
|
defaultPreselectedCompare: null,
|
|
426
546
|
defaultCompareToggle: null,
|
|
@@ -429,72 +549,80 @@ var le = (
|
|
|
429
549
|
size: "m"
|
|
430
550
|
};
|
|
431
551
|
}
|
|
432
|
-
}])
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
552
|
+
}]);
|
|
553
|
+
return DateRangeComparatorAbstract2;
|
|
554
|
+
}(Component);
|
|
555
|
+
_defineProperty(DateRangeComparatorAbstract, "displayName", "DateRangeComparator");
|
|
556
|
+
_defineProperty(DateRangeComparatorAbstract, "style", style);
|
|
557
|
+
_defineProperty(DateRangeComparatorAbstract, "enhance", [i18nEnhance(localizedMessages)]);
|
|
558
|
+
_defineProperty(DateRangeComparatorAbstract, "subtract", function(date, amount, unit) {
|
|
559
|
+
return dayjs(date).subtract(amount, unit).toDate();
|
|
439
560
|
});
|
|
440
|
-
function
|
|
441
|
-
var
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
561
|
+
function Apply(props) {
|
|
562
|
+
var _ref2 = arguments[0];
|
|
563
|
+
var getI18nText = props.getI18nText;
|
|
564
|
+
return /* @__PURE__ */ React.createElement(Button, assignProps({
|
|
565
|
+
"use": "primary",
|
|
566
|
+
"children": getI18nText("apply")
|
|
567
|
+
}, _ref2));
|
|
446
568
|
}
|
|
447
|
-
function
|
|
448
|
-
var
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
569
|
+
function Reset(props) {
|
|
570
|
+
var _ref3 = arguments[0];
|
|
571
|
+
var getI18nText = props.getI18nText;
|
|
572
|
+
return /* @__PURE__ */ React.createElement(Button, assignProps({
|
|
573
|
+
"use": "tertiary",
|
|
574
|
+
"theme": "muted",
|
|
575
|
+
"children": getI18nText("reset")
|
|
576
|
+
}, _ref3));
|
|
454
577
|
}
|
|
455
|
-
function
|
|
456
|
-
var
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
578
|
+
function Trigger(props) {
|
|
579
|
+
var _ref5;
|
|
580
|
+
var STrigger = props.Root, styles = props.styles;
|
|
581
|
+
return _ref5 = sstyled$1(styles), /* @__PURE__ */ React.createElement(STrigger, _ref5.cn("STrigger", {
|
|
582
|
+
"render": Dropdown.Trigger,
|
|
583
|
+
"tag": LinkTrigger
|
|
460
584
|
}));
|
|
461
585
|
}
|
|
462
|
-
function
|
|
463
|
-
var
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
586
|
+
function CompareToggle(props) {
|
|
587
|
+
var _ref6;
|
|
588
|
+
var SCompareToggle = props.Root, styles = props.styles, getI18nText = props.getI18nText;
|
|
589
|
+
return _ref6 = sstyled$1(styles), /* @__PURE__ */ React.createElement(SCompareToggle, _ref6.cn("SCompareToggle", {
|
|
590
|
+
"render": Checkbox,
|
|
591
|
+
"label": getI18nText("compare")
|
|
467
592
|
}));
|
|
468
593
|
}
|
|
469
|
-
function
|
|
470
|
-
var
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
594
|
+
function Header(props) {
|
|
595
|
+
var _ref7;
|
|
596
|
+
var SRangeComparatorHeader = props.Root, Children = props.Children, styles = props.styles;
|
|
597
|
+
return _ref7 = sstyled$1(styles), /* @__PURE__ */ React.createElement(SRangeComparatorHeader, _ref7.cn("SRangeComparatorHeader", {
|
|
598
|
+
"render": Flex,
|
|
599
|
+
"gap": 4,
|
|
600
|
+
"alignItems": "center"
|
|
601
|
+
}), /* @__PURE__ */ React.createElement(Children, _ref7.cn("Children", {})));
|
|
476
602
|
}
|
|
477
|
-
function
|
|
478
|
-
var
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
603
|
+
function Body(props) {
|
|
604
|
+
var _ref8;
|
|
605
|
+
var SBody = props.Root, Children = props.Children, styles = props.styles;
|
|
606
|
+
return _ref8 = sstyled$1(styles), /* @__PURE__ */ React.createElement(SBody, _ref8.cn("SBody", {
|
|
607
|
+
"render": Flex,
|
|
608
|
+
"gap": 4
|
|
609
|
+
}), /* @__PURE__ */ React.createElement(Children, _ref8.cn("Children", {})));
|
|
483
610
|
}
|
|
484
|
-
function
|
|
485
|
-
var
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
611
|
+
function Footer(props) {
|
|
612
|
+
var _ref9;
|
|
613
|
+
var SFooter = props.Root, styles = props.styles, Children = props.Children;
|
|
614
|
+
return _ref9 = sstyled$1(styles), /* @__PURE__ */ React.createElement(SFooter, _ref9.cn("SFooter", {
|
|
615
|
+
"render": Flex,
|
|
616
|
+
"gap": 2
|
|
617
|
+
}), /* @__PURE__ */ React.createElement(Children, _ref9.cn("Children", {})));
|
|
490
618
|
}
|
|
491
619
|
export {
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
620
|
+
Apply,
|
|
621
|
+
Body,
|
|
622
|
+
CompareToggle,
|
|
623
|
+
Footer,
|
|
624
|
+
Header,
|
|
625
|
+
Reset,
|
|
626
|
+
Trigger,
|
|
627
|
+
DateRangeComparatorAbstract as default
|
|
500
628
|
};
|