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