@semcore/date-picker 16.2.4 → 17.0.0-prerelease.18
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/DatePicker.js +116 -139
- package/lib/cjs/DatePicker.js.map +1 -1
- package/lib/cjs/DateRangeComparator.js +144 -149
- package/lib/cjs/DateRangeComparator.js.map +1 -1
- package/lib/cjs/DateRangePicker.js +86 -101
- package/lib/cjs/DateRangePicker.js.map +1 -1
- package/lib/cjs/MonthDateRangeComparator.js +173 -180
- package/lib/cjs/MonthDateRangeComparator.js.map +1 -1
- package/lib/cjs/MonthPicker.js +70 -87
- package/lib/cjs/MonthPicker.js.map +1 -1
- package/lib/cjs/MonthRangePicker.js +96 -111
- package/lib/cjs/MonthRangePicker.js.map +1 -1
- package/lib/cjs/components/ButtonTrigger.js +12 -11
- package/lib/cjs/components/ButtonTrigger.js.map +1 -1
- package/lib/cjs/components/Calendar.js +409 -466
- package/lib/cjs/components/Calendar.js.map +1 -1
- package/lib/cjs/components/DateRangeComparatorAbstract.js +574 -626
- package/lib/cjs/components/DateRangeComparatorAbstract.js.map +1 -1
- package/lib/cjs/components/InputTrigger.js +585 -677
- package/lib/cjs/components/InputTrigger.js.map +1 -1
- package/lib/cjs/components/PickerAbstract.js +254 -273
- package/lib/cjs/components/PickerAbstract.js.map +1 -1
- package/lib/cjs/components/RangePickerAbstract.js +407 -439
- package/lib/cjs/components/RangePickerAbstract.js.map +1 -1
- package/lib/cjs/components/index.js +92 -102
- package/lib/cjs/components/index.js.map +1 -1
- package/lib/cjs/index.d.js.map +1 -1
- package/lib/cjs/index.js +15 -15
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js +17 -17
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js.map +1 -1
- package/lib/cjs/utils/cronTabScheduler.js +13 -22
- package/lib/cjs/utils/cronTabScheduler.js.map +1 -1
- package/lib/cjs/utils/datesIntersects.js +12 -19
- package/lib/cjs/utils/datesIntersects.js.map +1 -1
- package/lib/cjs/utils/formatDate.js +11 -9
- package/lib/cjs/utils/formatDate.js.map +1 -1
- package/lib/cjs/utils/includesDate.js +11 -16
- package/lib/cjs/utils/includesDate.js.map +1 -1
- package/lib/cjs/utils/isBetweenPlugin.js +6 -6
- package/lib/cjs/utils/isBetweenPlugin.js.map +1 -1
- package/lib/cjs/utils/shortDateRangeFormat.js +29 -33
- package/lib/cjs/utils/shortDateRangeFormat.js.map +1 -1
- package/lib/es6/DatePicker.js +117 -141
- package/lib/es6/DatePicker.js.map +1 -1
- package/lib/es6/DateRangeComparator.js +130 -135
- package/lib/es6/DateRangeComparator.js.map +1 -1
- package/lib/es6/DateRangePicker.js +87 -102
- package/lib/es6/DateRangePicker.js.map +1 -1
- package/lib/es6/MonthDateRangeComparator.js +159 -166
- package/lib/es6/MonthDateRangeComparator.js.map +1 -1
- package/lib/es6/MonthPicker.js +72 -89
- package/lib/es6/MonthPicker.js.map +1 -1
- package/lib/es6/MonthRangePicker.js +97 -112
- package/lib/es6/MonthRangePicker.js.map +1 -1
- package/lib/es6/components/ButtonTrigger.js +4 -3
- package/lib/es6/components/ButtonTrigger.js.map +1 -1
- package/lib/es6/components/Calendar.js +400 -457
- package/lib/es6/components/Calendar.js.map +1 -1
- package/lib/es6/components/DateRangeComparatorAbstract.js +552 -604
- package/lib/es6/components/DateRangeComparatorAbstract.js.map +1 -1
- package/lib/es6/components/InputTrigger.js +568 -660
- package/lib/es6/components/InputTrigger.js.map +1 -1
- package/lib/es6/components/PickerAbstract.js +246 -265
- package/lib/es6/components/PickerAbstract.js.map +1 -1
- package/lib/es6/components/RangePickerAbstract.js +397 -429
- package/lib/es6/components/RangePickerAbstract.js.map +1 -1
- package/lib/es6/components/index.js +74 -85
- package/lib/es6/components/index.js.map +1 -1
- package/lib/es6/index.d.js.map +1 -1
- package/lib/es6/translations/__intergalactic-dynamic-locales.js +16 -16
- package/lib/es6/translations/__intergalactic-dynamic-locales.js.map +1 -1
- package/lib/es6/utils/cronTabScheduler.js +13 -21
- package/lib/es6/utils/cronTabScheduler.js.map +1 -1
- package/lib/es6/utils/datesIntersects.js +10 -18
- package/lib/es6/utils/datesIntersects.js.map +1 -1
- package/lib/es6/utils/formatDate.js +6 -6
- package/lib/es6/utils/formatDate.js.map +1 -1
- package/lib/es6/utils/includesDate.js +10 -15
- package/lib/es6/utils/includesDate.js.map +1 -1
- package/lib/es6/utils/isBetweenPlugin.js +4 -4
- package/lib/es6/utils/isBetweenPlugin.js.map +1 -1
- package/lib/es6/utils/shortDateRangeFormat.js +27 -31
- package/lib/es6/utils/shortDateRangeFormat.js.map +1 -1
- package/lib/esm/DatePicker.mjs +109 -114
- package/lib/esm/DateRangeComparator.mjs +112 -105
- package/lib/esm/DateRangePicker.mjs +76 -80
- package/lib/esm/MonthDateRangeComparator.mjs +141 -134
- package/lib/esm/MonthPicker.mjs +65 -70
- package/lib/esm/MonthRangePicker.mjs +86 -88
- package/lib/esm/components/ButtonTrigger.mjs +4 -3
- package/lib/esm/components/Calendar.mjs +397 -423
- package/lib/esm/components/DateRangeComparatorAbstract.mjs +559 -516
- package/lib/esm/components/InputTrigger.mjs +550 -557
- package/lib/esm/components/PickerAbstract.mjs +249 -244
- package/lib/esm/components/RangePickerAbstract.mjs +400 -384
- package/lib/esm/components/index.mjs +73 -69
- package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +1 -1
- package/lib/esm/utils/cronTabScheduler.mjs +13 -18
- package/lib/esm/utils/datesIntersects.mjs +10 -14
- package/lib/esm/utils/formatDate.mjs +6 -6
- package/lib/esm/utils/includesDate.mjs +10 -13
- package/lib/esm/utils/isBetweenPlugin.mjs +4 -4
- package/lib/esm/utils/shortDateRangeFormat.mjs +27 -27
- package/lib/types/index.d.ts +2 -44
- package/package.json +16 -17
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
@@ -11,21 +11,15 @@ exports.Footer = Footer;
|
|
|
11
11
|
exports.Header = Header;
|
|
12
12
|
exports.Reset = Reset;
|
|
13
13
|
exports.Trigger = Trigger;
|
|
14
|
-
exports
|
|
15
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
16
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
17
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
18
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
19
|
-
var _callSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/callSuper"));
|
|
20
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
14
|
+
exports.default = void 0;
|
|
21
15
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
22
16
|
var _core = require("@semcore/core");
|
|
17
|
+
var _baseComponents = require("@semcore/base-components");
|
|
23
18
|
var _baseTrigger = require("@semcore/base-trigger");
|
|
24
19
|
var _button = _interopRequireDefault(require("@semcore/button"));
|
|
25
20
|
var _checkbox = _interopRequireDefault(require("@semcore/checkbox"));
|
|
26
21
|
var _i18nEnhance = _interopRequireDefault(require("@semcore/core/lib/utils/enhances/i18nEnhance"));
|
|
27
22
|
var _dropdown = _interopRequireDefault(require("@semcore/dropdown"));
|
|
28
|
-
var _flexBox = require("@semcore/flex-box");
|
|
29
23
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
30
24
|
var _react = _interopRequireDefault(require("react"));
|
|
31
25
|
var _intergalacticDynamicLocales = require("../translations/__intergalactic-dynamic-locales");
|
|
@@ -33,645 +27,589 @@ var _formatDate = require("../utils/formatDate");
|
|
|
33
27
|
var _includesDate = require("../utils/includesDate");
|
|
34
28
|
var _shortDateRangeFormat = _interopRequireDefault(require("../utils/shortDateRangeFormat"));
|
|
35
29
|
/*!__reshadow-styles__:"../style/date-picker.shadow.css"*/
|
|
36
|
-
|
|
30
|
+
const style = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".___SPopper_9ubmf_gg_{padding:var(--intergalactic-spacing-4x, 16px);outline:0}.___SPopper_9ubmf_gg_::-moz-focus-inner{border:0;padding:0}.___SPopper_9ubmf_gg_:active,.___SPopper_9ubmf_gg_:focus{-webkit-text-decoration:none;text-decoration:none}@media (hover:hover){.___SPopper_9ubmf_gg_:hover{-webkit-text-decoration:none;text-decoration:none}}.___SHeader_9ubmf_gg_,.___STitle_9ubmf_gg_{display:flex;align-items:center}.___STitle_9ubmf_gg_{font-size:var(--intergalactic-fs-200, 14px);color:var(--intergalactic-text-primary, #191b23);height:32px;width:100%;justify-content:center}.___SToday_9ubmf_gg_{display:flex;margin-top:var(--intergalactic-spacing-3x, 12px);justify-content:center}.___SPeriod_9ubmf_gg_{display:flex;flex-direction:column;margin-bottom:var(--intergalactic-spacing-2x, 8px)}.___SButton_9ubmf_gg_ .___SInner_9ubmf_gg_{justify-content:flex-start}.___SInputMask_9ubmf_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_9ubmf_gg_.__animationsDisabled_9ubmf_gg_{transition:none}.___SInputMask_9ubmf_gg_ .___SValue_9ubmf_gg_{letter-spacing:0}.___SInputMask_9ubmf_gg_ .___SValue_9ubmf_gg_:focus{outline:0}.___SIndicator_9ubmf_gg_{color:var(--intergalactic-text-secondary, #6c6e79)}.___SRangeIndicator_9ubmf_gg_{border-radius:50%;flex-shrink:0}.___SRangeIndicator_9ubmf_gg_._range_value_9ubmf_gg_{background-color:var(--intergalactic-date-picker-cell-active, #2bb3ff)}.___SRangeIndicator_9ubmf_gg_._range_compare_9ubmf_gg_{background-color:var(--intergalactic-date-picker-cell-comparison-active, #8649e1)}.___SRangeIndicator_9ubmf_gg_.__disabled_9ubmf_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3)}.___SHumanizedDate_9ubmf_gg_{position:absolute;pointer-events:none;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;width:100%}.___SMask_9ubmf_gg_{letter-spacing:0;white-space:nowrap;overflow:hidden}.___SDateRange_9ubmf_gg_ .___SMask_9ubmf_gg_,.___SDateRange_9ubmf_gg_ .___SValue_9ubmf_gg_,.___SSingleDateInput_9ubmf_gg_ .___SMask_9ubmf_gg_,.___SSingleDateInput_9ubmf_gg_ .___SValue_9ubmf_gg_{opacity:0}.___SSingleDateInput_9ubmf_gg_:focus-within .___SHumanizedDate_9ubmf_gg_{opacity:0;z-index:var(--intergalactic-z-index-deep, -999)}.___SSingleDateInput_9ubmf_gg_:focus-within .___SMask_9ubmf_gg_,.___SSingleDateInput_9ubmf_gg_:focus-within .___SValue_9ubmf_gg_{opacity:1}.___SDateRange_9ubmf_gg_:focus-within .___SHumanizedDate_9ubmf_gg_{opacity:0;z-index:var(--intergalactic-z-index-deep, -999)}.___SDateRange_9ubmf_gg_:focus-within .___SMask_9ubmf_gg_,.___SDateRange_9ubmf_gg_:focus-within .___SValue_9ubmf_gg_{opacity:1}.___SInputMask_9ubmf_gg_.__noHumanizedDate_9ubmf_gg_ .___SMask_9ubmf_gg_,.___SInputMask_9ubmf_gg_.__noHumanizedDate_9ubmf_gg_ .___SValue_9ubmf_gg_{opacity:1}.___SDateRange_9ubmf_gg_ .___SInputMask_9ubmf_gg_:focus-within .___SMask_9ubmf_gg_{background-color:var(--intergalactic-bg-highlight-focus, rgba(0, 143, 248, 0.2))}.___SDateRange_9ubmf_gg_:focus-within .___SRangeSep_9ubmf_gg_,.___SRangeSep_9ubmf_gg_.__fulfilled_9ubmf_gg_{color:var(--intergalactic-text-primary, #191b23)}.___SRangeComparatorHeader_9ubmf_gg_{border-bottom:1px solid var(--intergalactic-border-primary, #c4c7cf)}.___SRangeCalendar_9ubmf_gg_,.___SRangeComparatorHeader_9ubmf_gg_{padding:var(--intergalactic-spacing-4x, 16px)}.___SFooter_9ubmf_gg_{border-top:1px solid var(--intergalactic-border-primary, #c4c7cf)}.___SFooter_9ubmf_gg_,.___SPeriodsList_9ubmf_gg_{padding:var(--intergalactic-spacing-4x, 16px)}.___STooltip_9ubmf_gg_{padding:var(--intergalactic-spacing-3x, 12px)}.___SCompareToggle_9ubmf_gg_{white-space:nowrap}@media (prefers-reduced-motion){.___SInputMask_9ubmf_gg_{transition:none}}", /*__inner_css_end__*/"9ubmf_gg_"),
|
|
37
31
|
/*__reshadow_css_end__*/
|
|
38
32
|
{
|
|
39
|
-
"__SHeader": "
|
|
40
|
-
"__STitle": "
|
|
41
|
-
"__SToday": "
|
|
42
|
-
"__SPeriod": "
|
|
43
|
-
"__SButton": "
|
|
44
|
-
"__SInner": "
|
|
45
|
-
"__SInputMask": "
|
|
46
|
-
"_animationsDisabled": "
|
|
47
|
-
"__SIndicator": "
|
|
48
|
-
"__SRangeIndicator": "
|
|
49
|
-
"_range_value": "
|
|
50
|
-
"_range_compare": "
|
|
51
|
-
"_disabled": "
|
|
52
|
-
"__SHumanizedDate": "
|
|
53
|
-
"__SMask": "
|
|
54
|
-
"__SSingleDateInput": "
|
|
55
|
-
"__SValue": "
|
|
56
|
-
"__SDateRange": "
|
|
57
|
-
"_noHumanizedDate": "
|
|
58
|
-
"__SRangeSep": "
|
|
59
|
-
"_fulfilled": "
|
|
60
|
-
"__SRangeComparatorHeader": "
|
|
61
|
-
"__SRangeCalendar": "
|
|
62
|
-
"__SFooter": "
|
|
63
|
-
"__SPeriodsList": "
|
|
64
|
-
"__STooltip": "
|
|
65
|
-
"__SCompareToggle": "
|
|
66
|
-
"__SPopper": "
|
|
33
|
+
"__SHeader": "___SHeader_9ubmf_gg_",
|
|
34
|
+
"__STitle": "___STitle_9ubmf_gg_",
|
|
35
|
+
"__SToday": "___SToday_9ubmf_gg_",
|
|
36
|
+
"__SPeriod": "___SPeriod_9ubmf_gg_",
|
|
37
|
+
"__SButton": "___SButton_9ubmf_gg_",
|
|
38
|
+
"__SInner": "___SInner_9ubmf_gg_",
|
|
39
|
+
"__SInputMask": "___SInputMask_9ubmf_gg_",
|
|
40
|
+
"_animationsDisabled": "__animationsDisabled_9ubmf_gg_",
|
|
41
|
+
"__SIndicator": "___SIndicator_9ubmf_gg_",
|
|
42
|
+
"__SRangeIndicator": "___SRangeIndicator_9ubmf_gg_",
|
|
43
|
+
"_range_value": "_range_value_9ubmf_gg_",
|
|
44
|
+
"_range_compare": "_range_compare_9ubmf_gg_",
|
|
45
|
+
"_disabled": "__disabled_9ubmf_gg_",
|
|
46
|
+
"__SHumanizedDate": "___SHumanizedDate_9ubmf_gg_",
|
|
47
|
+
"__SMask": "___SMask_9ubmf_gg_",
|
|
48
|
+
"__SSingleDateInput": "___SSingleDateInput_9ubmf_gg_",
|
|
49
|
+
"__SValue": "___SValue_9ubmf_gg_",
|
|
50
|
+
"__SDateRange": "___SDateRange_9ubmf_gg_",
|
|
51
|
+
"_noHumanizedDate": "__noHumanizedDate_9ubmf_gg_",
|
|
52
|
+
"__SRangeSep": "___SRangeSep_9ubmf_gg_",
|
|
53
|
+
"_fulfilled": "__fulfilled_9ubmf_gg_",
|
|
54
|
+
"__SRangeComparatorHeader": "___SRangeComparatorHeader_9ubmf_gg_",
|
|
55
|
+
"__SRangeCalendar": "___SRangeCalendar_9ubmf_gg_",
|
|
56
|
+
"__SFooter": "___SFooter_9ubmf_gg_",
|
|
57
|
+
"__SPeriodsList": "___SPeriodsList_9ubmf_gg_",
|
|
58
|
+
"__STooltip": "___STooltip_9ubmf_gg_",
|
|
59
|
+
"__SCompareToggle": "___SCompareToggle_9ubmf_gg_",
|
|
60
|
+
"__SPopper": "___SPopper_9ubmf_gg_"
|
|
67
61
|
});
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
dateRanges[_key] = arguments[_key];
|
|
74
|
-
}
|
|
75
|
-
var allDates = dateRanges.flat().filter(Boolean).filter(function (date) {
|
|
76
|
-
return !Number.isNaN(new Date(date).getTime());
|
|
77
|
-
});
|
|
62
|
+
const INTERACTION_TAGS = ['INPUT'];
|
|
63
|
+
const INTERACTION_KEYS = ['ArrowDown', 'Enter', ' '];
|
|
64
|
+
const defaultDisplayedPeriod = new Date(new Date().setHours(0, 0, 0, 0));
|
|
65
|
+
const getLatestDate = (...dateRanges) => {
|
|
66
|
+
const allDates = dateRanges.flat().filter(Boolean).filter(date => !Number.isNaN(new Date(date).getTime()));
|
|
78
67
|
if (!allDates.length) return null;
|
|
79
|
-
allDates.sort(
|
|
80
|
-
|
|
81
|
-
});
|
|
82
|
-
var latestDate = allDates[0];
|
|
68
|
+
allDates.sort((a, b) => new Date(b).getTime() - new Date(a).getTime());
|
|
69
|
+
const latestDate = allDates[0];
|
|
83
70
|
return latestDate;
|
|
84
71
|
};
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
(0,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
(0, _defineProperty2
|
|
94
|
-
(0, _defineProperty2
|
|
95
|
-
(0, _defineProperty2
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
var action = direction >= 1 ? 'add' : 'subtract';
|
|
103
|
-
var date = (0, _dayjs["default"])(displayedPeriod)[action](1, _this.navigateStep).toDate();
|
|
104
|
-
_this.handlers.displayedPeriod(date);
|
|
105
|
-
});
|
|
106
|
-
(0, _defineProperty2["default"])(_this, "bindHandlerNavigateClick", function (direction) {
|
|
107
|
-
return function () {
|
|
108
|
-
return _this.navigateView(direction);
|
|
109
|
-
};
|
|
72
|
+
class DateRangeComparatorAbstract extends _core.Component {
|
|
73
|
+
constructor(...args) {
|
|
74
|
+
super(...args);
|
|
75
|
+
(0, _defineProperty2.default)(this, "prevButtonRef", /*#__PURE__*/_react.default.createRef());
|
|
76
|
+
(0, _defineProperty2.default)(this, "nextButtonRef", /*#__PURE__*/_react.default.createRef());
|
|
77
|
+
(0, _defineProperty2.default)(this, "popperRef", /*#__PURE__*/_react.default.createRef());
|
|
78
|
+
(0, _defineProperty2.default)(this, "resetButtonRef", /*#__PURE__*/_react.default.createRef());
|
|
79
|
+
(0, _defineProperty2.default)(this, "applyButtonRef", /*#__PURE__*/_react.default.createRef());
|
|
80
|
+
(0, _defineProperty2.default)(this, "periodRefs", []);
|
|
81
|
+
(0, _defineProperty2.default)(this, "unitRefs", {});
|
|
82
|
+
(0, _defineProperty2.default)(this, "navigateView", direction => {
|
|
83
|
+
const {
|
|
84
|
+
displayedPeriod
|
|
85
|
+
} = this.asProps;
|
|
86
|
+
const action = direction >= 1 ? 'add' : 'subtract';
|
|
87
|
+
const date = (0, _dayjs.default)(displayedPeriod)[action](1, this.navigateStep).toDate();
|
|
88
|
+
this.handlers.displayedPeriod(date);
|
|
110
89
|
});
|
|
111
|
-
(0, _defineProperty2
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
90
|
+
(0, _defineProperty2.default)(this, "bindHandlerNavigateClick", direction => () => this.navigateView(direction));
|
|
91
|
+
(0, _defineProperty2.default)(this, "handleApplyClick", () => {
|
|
92
|
+
const {
|
|
93
|
+
value,
|
|
94
|
+
preselectedValue,
|
|
95
|
+
preselectedCompare
|
|
96
|
+
} = this.asProps;
|
|
97
|
+
return this.handleApply(preselectedValue ?? value?.value, preselectedCompare ?? value?.compare);
|
|
117
98
|
});
|
|
118
|
-
(0, _defineProperty2
|
|
119
|
-
|
|
120
|
-
value
|
|
121
|
-
compare
|
|
99
|
+
(0, _defineProperty2.default)(this, "handleApply", (value, compare) => {
|
|
100
|
+
this.handlers.value({
|
|
101
|
+
value,
|
|
102
|
+
compare
|
|
122
103
|
});
|
|
123
|
-
|
|
104
|
+
this.handlers.visible(false);
|
|
124
105
|
});
|
|
125
|
-
(0, _defineProperty2
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
var day = _this.keyDiff[key];
|
|
148
|
-
var setNextDisplayedPeriod = function setNextDisplayedPeriod(next_highlighted) {
|
|
149
|
-
var _next_highlighted = (0, _slicedToArray2["default"])(next_highlighted, 2),
|
|
150
|
-
startPeriod = _next_highlighted[0],
|
|
151
|
-
endPeriod = _next_highlighted[1];
|
|
152
|
-
var highlightedPeriod = endPeriod || startPeriod;
|
|
153
|
-
var displayedPeriodNormalized = displayedPeriod === null || displayedPeriod === void 0 ? void 0 : displayedPeriod.getDate();
|
|
154
|
-
var highlightedPeriodNormalized = highlightedPeriod === null || highlightedPeriod === void 0 ? void 0 : highlightedPeriod.getDate();
|
|
155
|
-
if (_this.navigateStep === 'month') {
|
|
156
|
-
displayedPeriodNormalized = displayedPeriod === null || displayedPeriod === void 0 ? void 0 : displayedPeriod.getMonth();
|
|
157
|
-
highlightedPeriodNormalized = highlightedPeriod === null || highlightedPeriod === void 0 ? void 0 : highlightedPeriod.getMonth();
|
|
158
|
-
}
|
|
159
|
-
if (_this.navigateStep === 'year') {
|
|
160
|
-
displayedPeriodNormalized = displayedPeriod === null || displayedPeriod === void 0 ? void 0 : displayedPeriod.getYear();
|
|
161
|
-
highlightedPeriodNormalized = highlightedPeriod === null || highlightedPeriod === void 0 ? void 0 : highlightedPeriod.getYear();
|
|
106
|
+
(0, _defineProperty2.default)(this, "handleKeydownDown", place => e => {
|
|
107
|
+
const {
|
|
108
|
+
displayedPeriod,
|
|
109
|
+
preselectedValue,
|
|
110
|
+
visible,
|
|
111
|
+
focusedRange
|
|
112
|
+
} = this.asProps;
|
|
113
|
+
const {
|
|
114
|
+
key,
|
|
115
|
+
target
|
|
116
|
+
} = e;
|
|
117
|
+
const highlighted = focusedRange === 'compare' ? this.asProps.compareHighlighted : this.asProps.highlighted;
|
|
118
|
+
if ([' ', 'Enter'].includes(key) && [this.prevButtonRef.current, this.nextButtonRef.current].includes(target)) return;
|
|
119
|
+
if (place === 'trigger' && INTERACTION_KEYS.includes(key)) {
|
|
120
|
+
e.preventDefault();
|
|
121
|
+
e.stopPropagation();
|
|
122
|
+
this.handlers.visible(!visible);
|
|
123
|
+
setTimeout(() => {
|
|
124
|
+
const popper = this.popperRef.current;
|
|
125
|
+
if (popper) {
|
|
126
|
+
popper.focus();
|
|
162
127
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
if (
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
128
|
+
}, 0);
|
|
129
|
+
}
|
|
130
|
+
const day = this.keyDiff[key];
|
|
131
|
+
const setNextDisplayedPeriod = next_highlighted => {
|
|
132
|
+
const [startPeriod, endPeriod] = next_highlighted;
|
|
133
|
+
const highlightedPeriod = endPeriod || startPeriod;
|
|
134
|
+
let displayedPeriodNormalized = displayedPeriod?.getDate();
|
|
135
|
+
let highlightedPeriodNormalized = highlightedPeriod?.getDate();
|
|
136
|
+
if (this.navigateStep === 'month') {
|
|
137
|
+
displayedPeriodNormalized = displayedPeriod?.getMonth();
|
|
138
|
+
highlightedPeriodNormalized = highlightedPeriod?.getMonth();
|
|
139
|
+
}
|
|
140
|
+
if (this.navigateStep === 'year') {
|
|
141
|
+
displayedPeriodNormalized = displayedPeriod?.getYear();
|
|
142
|
+
highlightedPeriodNormalized = highlightedPeriod?.getYear();
|
|
143
|
+
}
|
|
144
|
+
const offset = highlightedPeriodNormalized - displayedPeriodNormalized;
|
|
145
|
+
if (offset < 0 || offset > 1) {
|
|
146
|
+
return highlightedPeriod;
|
|
181
147
|
}
|
|
182
|
-
|
|
183
|
-
|
|
148
|
+
return displayedPeriod;
|
|
149
|
+
};
|
|
150
|
+
const isPeriodTarget = this.periodRefs.find(el => el === target);
|
|
151
|
+
const isResetButtonTarget = target === this.resetButtonRef.current;
|
|
152
|
+
const isApplyButtonTarget = target === this.applyButtonRef.current;
|
|
153
|
+
const areTargetedControls = isPeriodTarget || isResetButtonTarget || isApplyButtonTarget;
|
|
154
|
+
if (place === 'popper' && e.key === ' ' && highlighted.length && !areTargetedControls) {
|
|
155
|
+
const highlightedDate = highlighted[1] || highlighted[0];
|
|
156
|
+
if (!this.isDisabled(highlightedDate)) {
|
|
157
|
+
this.handleChange(highlightedDate);
|
|
184
158
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
_this.handlers.compareHighlighted(next_highlighted);
|
|
199
|
-
} else {
|
|
200
|
-
_this.handlers.highlighted(next_highlighted);
|
|
201
|
-
}
|
|
202
|
-
_this.handlers.displayedPeriod(setNextDisplayedPeriod(next_highlighted));
|
|
159
|
+
e.preventDefault();
|
|
160
|
+
}
|
|
161
|
+
if (place === 'popper' && e.key === 'Enter' && (e.metaKey || e.ctrlKey)) {
|
|
162
|
+
return this.handleApplyClick();
|
|
163
|
+
}
|
|
164
|
+
let changedDate = undefined;
|
|
165
|
+
if (day) {
|
|
166
|
+
if (INTERACTION_TAGS.includes(e.target.tagName)) return;
|
|
167
|
+
if (highlighted.length) {
|
|
168
|
+
let next_highlighted;
|
|
169
|
+
if (preselectedValue?.length === 1) {
|
|
170
|
+
next_highlighted = [preselectedValue[0], (0, _dayjs.default)(highlighted[1] || highlighted[0]).add(day, this.keyStep).toDate()];
|
|
171
|
+
changedDate = next_highlighted[1];
|
|
203
172
|
} else {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
_this.handlers.compareHighlighted(_highlighted);
|
|
207
|
-
} else {
|
|
208
|
-
_this.handlers.highlighted(_highlighted);
|
|
209
|
-
}
|
|
210
|
-
changedDate = _highlighted[0];
|
|
173
|
+
next_highlighted = [(0, _dayjs.default)(highlighted[0]).add(day, this.keyStep).toDate()];
|
|
174
|
+
changedDate = next_highlighted[0];
|
|
211
175
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
var formattedDate = formatter(changedDate, _this.asProps.locale);
|
|
217
|
-
(_this$unitRefs$format = _this.unitRefs[formattedDate]) === null || _this$unitRefs$format === void 0 || _this$unitRefs$format.focus();
|
|
176
|
+
if (focusedRange === 'compare') {
|
|
177
|
+
this.handlers.compareHighlighted(next_highlighted);
|
|
178
|
+
} else {
|
|
179
|
+
this.handlers.highlighted(next_highlighted);
|
|
218
180
|
}
|
|
181
|
+
this.handlers.displayedPeriod(setNextDisplayedPeriod(next_highlighted));
|
|
182
|
+
} else {
|
|
183
|
+
const highlighted = [displayedPeriod ? displayedPeriod : (0, _dayjs.default)().toDate()];
|
|
184
|
+
if (focusedRange === 'compare') {
|
|
185
|
+
this.handlers.compareHighlighted(highlighted);
|
|
186
|
+
} else {
|
|
187
|
+
this.handlers.highlighted(highlighted);
|
|
188
|
+
}
|
|
189
|
+
changedDate = highlighted[0];
|
|
219
190
|
}
|
|
220
|
-
|
|
191
|
+
e.preventDefault();
|
|
192
|
+
if (changedDate) {
|
|
193
|
+
const formatter = this.keyStep === 'month' ? _formatDate.formatMMYY : _formatDate.formatDDMMYY;
|
|
194
|
+
const formattedDate = formatter(changedDate, this.asProps.locale);
|
|
195
|
+
this.unitRefs[formattedDate]?.focus();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
221
198
|
});
|
|
222
|
-
(0, _defineProperty2
|
|
199
|
+
(0, _defineProperty2.default)(this, "triggerFormattingProps", {
|
|
223
200
|
day: 'numeric',
|
|
224
201
|
month: 'short',
|
|
225
202
|
year: 'numeric'
|
|
226
203
|
});
|
|
227
|
-
(0, _defineProperty2
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
204
|
+
(0, _defineProperty2.default)(this, "handleChange", date => {
|
|
205
|
+
const {
|
|
206
|
+
focusedRange,
|
|
207
|
+
preselectedCompare,
|
|
208
|
+
preselectedValue
|
|
209
|
+
} = this.asProps;
|
|
210
|
+
let highlighted = [];
|
|
211
|
+
let value = focusedRange === 'compare' ? preselectedCompare : preselectedValue;
|
|
235
212
|
if (Array.isArray(date)) {
|
|
236
213
|
value = date;
|
|
237
|
-
} else if (!
|
|
214
|
+
} else if (!value?.length) {
|
|
238
215
|
value = [date];
|
|
239
216
|
highlighted = [date];
|
|
240
|
-
} else if (
|
|
217
|
+
} else if (value?.length >= 2) {
|
|
241
218
|
value = [date];
|
|
242
219
|
highlighted = [date];
|
|
243
|
-
} else if (
|
|
244
|
-
|
|
245
|
-
value = [date, (_value4 = value) === null || _value4 === void 0 ? void 0 : _value4[0]];
|
|
220
|
+
} else if (value?.[0] > date) {
|
|
221
|
+
value = [date, value?.[0]];
|
|
246
222
|
} else {
|
|
247
|
-
|
|
248
|
-
value = [(_value5 = value) === null || _value5 === void 0 ? void 0 : _value5[0], date];
|
|
223
|
+
value = [value?.[0], date];
|
|
249
224
|
}
|
|
250
225
|
if (focusedRange === 'compare') {
|
|
251
|
-
|
|
252
|
-
|
|
226
|
+
this.handlers.preselectedCompare(value);
|
|
227
|
+
this.handlers.compareHighlighted(highlighted);
|
|
253
228
|
} else {
|
|
254
|
-
|
|
255
|
-
|
|
229
|
+
this.handlers.preselectedValue(value);
|
|
230
|
+
this.handlers.highlighted(highlighted);
|
|
256
231
|
}
|
|
257
232
|
});
|
|
258
|
-
return _this;
|
|
259
233
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
return function (element) {
|
|
297
|
-
if (!element) return;
|
|
298
|
-
_this2.periodRefs[index] = element;
|
|
299
|
-
};
|
|
300
|
-
}
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
|
-
}, {
|
|
304
|
-
key: "getPrevProps",
|
|
305
|
-
value: function getPrevProps() {
|
|
306
|
-
var getI18nText = this.asProps.getI18nText;
|
|
307
|
-
var navigateStep = this.navigateStep;
|
|
308
|
-
return {
|
|
309
|
-
getI18nText: getI18nText,
|
|
310
|
-
'ref': this.prevButtonRef,
|
|
311
|
-
'onClick': this.bindHandlerNavigateClick(-1),
|
|
312
|
-
'aria-label': navigateStep === 'month' ? getI18nText('prevMonth') : getI18nText('prevYear')
|
|
313
|
-
};
|
|
314
|
-
}
|
|
315
|
-
}, {
|
|
316
|
-
key: "getNextProps",
|
|
317
|
-
value: function getNextProps() {
|
|
318
|
-
var getI18nText = this.asProps.getI18nText;
|
|
319
|
-
var navigateStep = this.navigateStep;
|
|
320
|
-
return {
|
|
321
|
-
getI18nText: getI18nText,
|
|
322
|
-
'ref': this.nextButtonRef,
|
|
323
|
-
'onClick': this.bindHandlerNavigateClick(1),
|
|
324
|
-
'aria-label': navigateStep === 'month' ? getI18nText('nextMonth') : getI18nText('nextYear')
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
}, {
|
|
328
|
-
key: "uncontrolledProps",
|
|
329
|
-
value: function uncontrolledProps() {
|
|
330
|
-
var _this3 = this;
|
|
331
|
-
return {
|
|
332
|
-
displayedPeriod: null,
|
|
333
|
-
visible: [null, function (visible) {
|
|
334
|
-
if (!visible) {
|
|
335
|
-
_this3.handlers.highlighted([]);
|
|
336
|
-
_this3.handlers.compareHighlighted([]);
|
|
337
|
-
_this3.handlers.preselectedValue(undefined);
|
|
338
|
-
_this3.handlers.preselectedCompare(undefined);
|
|
339
|
-
_this3.handlers.compareToggle(undefined);
|
|
340
|
-
_this3.handlers.focusedRange('value');
|
|
341
|
-
} else {
|
|
342
|
-
var _this3$asProps$value;
|
|
343
|
-
_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));
|
|
344
|
-
}
|
|
345
|
-
var _this3$asProps = _this3.asProps,
|
|
346
|
-
value = _this3$asProps.value,
|
|
347
|
-
displayedPeriod = _this3$asProps.displayedPeriod;
|
|
348
|
-
var newDisplayedPeriod = value ? getLatestDate(value.value, value.compare) : undefined;
|
|
349
|
-
if (visible) {
|
|
350
|
-
if (newDisplayedPeriod && newDisplayedPeriod !== displayedPeriod) {
|
|
351
|
-
_this3.handlers.displayedPeriod(newDisplayedPeriod);
|
|
352
|
-
} else if (!newDisplayedPeriod) {
|
|
353
|
-
var _this3$props = _this3.props,
|
|
354
|
-
_displayedPeriod = _this3$props.displayedPeriod,
|
|
355
|
-
_defaultDisplayedPeriod = _this3$props.defaultDisplayedPeriod;
|
|
356
|
-
_this3.handlers.displayedPeriod(_displayedPeriod || _defaultDisplayedPeriod);
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
}],
|
|
360
|
-
highlighted: null,
|
|
361
|
-
compareHighlighted: null,
|
|
362
|
-
preselectedValue: null,
|
|
363
|
-
preselectedCompare: null,
|
|
364
|
-
compareToggle: null,
|
|
365
|
-
focusedRange: null,
|
|
366
|
-
value: [null, function (value) {
|
|
367
|
-
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) {
|
|
368
|
-
var _date$isValid;
|
|
369
|
-
return date === null || date === void 0 || (_date$isValid = date.isValid) === null || _date$isValid === void 0 ? void 0 : _date$isValid.call(date);
|
|
370
|
-
});
|
|
371
|
-
if (dates.length > 0) _this3.handlers.displayedPeriod(getLatestDate(value));
|
|
372
|
-
}]
|
|
373
|
-
};
|
|
374
|
-
}
|
|
375
|
-
}, {
|
|
376
|
-
key: "getApplyProps",
|
|
377
|
-
value: function getApplyProps() {
|
|
378
|
-
var getI18nText = this.asProps.getI18nText;
|
|
379
|
-
return {
|
|
380
|
-
getI18nText: getI18nText,
|
|
381
|
-
onClick: this.handleApplyClick,
|
|
382
|
-
ref: this.applyButtonRef
|
|
383
|
-
};
|
|
384
|
-
}
|
|
385
|
-
}, {
|
|
386
|
-
key: "getResetProps",
|
|
387
|
-
value: function getResetProps() {
|
|
388
|
-
var _this4 = this;
|
|
389
|
-
var getI18nText = this.asProps.getI18nText;
|
|
390
|
-
return {
|
|
391
|
-
getI18nText: getI18nText,
|
|
392
|
-
onClick: function onClick() {
|
|
393
|
-
return _this4.handleApply(null, null);
|
|
394
|
-
},
|
|
395
|
-
ref: this.resetButtonRef
|
|
396
|
-
};
|
|
397
|
-
}
|
|
398
|
-
}, {
|
|
399
|
-
key: "isDisabled",
|
|
400
|
-
value: function isDisabled(date) {
|
|
401
|
-
var disabled = this.asProps.disabled;
|
|
402
|
-
return disabled.some((0, _includesDate.includesDate)((0, _dayjs["default"])(date), 'date'));
|
|
403
|
-
}
|
|
404
|
-
}, {
|
|
405
|
-
key: "getDefaultPeriods",
|
|
406
|
-
value: function getDefaultPeriods() {
|
|
407
|
-
var getI18nText = this.asProps.getI18nText;
|
|
408
|
-
var today = new Date(new Date().setHours(0, 0, 0, 0));
|
|
409
|
-
return [{
|
|
410
|
-
children: getI18nText('lastMonth'),
|
|
411
|
-
value: [(0, _dayjs["default"])(today).subtract(1, 'month').startOf('month').toDate(), (0, _dayjs["default"])(today).startOf('month').toDate()]
|
|
412
|
-
}, {
|
|
413
|
-
children: getI18nText('last3Months'),
|
|
414
|
-
value: [(0, _dayjs["default"])(today).subtract(2, 'month').startOf('month').toDate(), (0, _dayjs["default"])(today).startOf('month').toDate()]
|
|
415
|
-
}, {
|
|
416
|
-
children: getI18nText('last6Months'),
|
|
417
|
-
value: [(0, _dayjs["default"])(today).subtract(5, 'month').startOf('month').toDate(), (0, _dayjs["default"])(today).startOf('month').toDate()]
|
|
418
|
-
}, {
|
|
419
|
-
children: getI18nText('last12Months'),
|
|
420
|
-
value: [(0, _dayjs["default"])(today).subtract(11, 'month').startOf('month').toDate(), (0, _dayjs["default"])(today).startOf('month').toDate()]
|
|
421
|
-
}];
|
|
422
|
-
}
|
|
423
|
-
}, {
|
|
424
|
-
key: "getTitleProps",
|
|
425
|
-
value: function getTitleProps(_props, index) {
|
|
426
|
-
var _this$asProps5 = this.asProps,
|
|
427
|
-
locale = _this$asProps5.locale,
|
|
428
|
-
displayedPeriod = _this$asProps5.displayedPeriod;
|
|
429
|
-
return {
|
|
430
|
-
children: new Intl.DateTimeFormat(locale, {
|
|
431
|
-
month: 'long',
|
|
432
|
-
year: 'numeric'
|
|
433
|
-
}).format((0, _dayjs["default"])(displayedPeriod).add(index, this.navigateStep).startOf(this.navigateStep).toDate())
|
|
434
|
-
};
|
|
234
|
+
static defaultProps({
|
|
235
|
+
primaryRange,
|
|
236
|
+
defaultPrimaryRange,
|
|
237
|
+
secondaryRange,
|
|
238
|
+
defaultSecondaryRange
|
|
239
|
+
}) {
|
|
240
|
+
return {
|
|
241
|
+
i18n: _intergalacticDynamicLocales.localizedMessages,
|
|
242
|
+
locale: 'en',
|
|
243
|
+
defaultValue: null,
|
|
244
|
+
defaultHighlighted: [],
|
|
245
|
+
defaultCompareHighlighted: [],
|
|
246
|
+
defaultDisplayedPeriod: getLatestDate(primaryRange, defaultPrimaryRange, secondaryRange, defaultSecondaryRange) || defaultDisplayedPeriod,
|
|
247
|
+
defaultVisible: false,
|
|
248
|
+
defaultPreselectedValue: null,
|
|
249
|
+
defaultPreselectedCompare: null,
|
|
250
|
+
defaultCompareToggle: null,
|
|
251
|
+
defaultFocusedRange: 'value',
|
|
252
|
+
disabled: [],
|
|
253
|
+
size: 'm'
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
getPeriodProps() {
|
|
257
|
+
const {
|
|
258
|
+
periods = this.getDefaultPeriods(),
|
|
259
|
+
onHighlightedChange,
|
|
260
|
+
onCompareHighlightedChange,
|
|
261
|
+
onDisplayedPeriodChange,
|
|
262
|
+
preselectedValue,
|
|
263
|
+
preselectedCompare,
|
|
264
|
+
focusedRange,
|
|
265
|
+
getI18nText
|
|
266
|
+
} = this.asProps;
|
|
267
|
+
let value = preselectedValue ?? this.asProps.value?.value;
|
|
268
|
+
if (focusedRange === 'compare') {
|
|
269
|
+
value = preselectedCompare ?? this.asProps.value?.compare;
|
|
435
270
|
}
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
}, this.triggerFormattingProps);
|
|
454
|
-
var children = placeholder;
|
|
455
|
-
if (value !== null && value !== void 0 && value[0] && value !== null && value !== void 0 && value[1]) {
|
|
456
|
-
children = (0, _shortDateRangeFormat["default"])(value, formattingProps);
|
|
457
|
-
}
|
|
458
|
-
if (compare !== null && compare !== void 0 && compare[0] && compare !== null && compare !== void 0 && compare[1]) {
|
|
459
|
-
children = "".concat(children || '', " ").concat(separator, " ").concat((0, _shortDateRangeFormat["default"])(compare, formattingProps));
|
|
271
|
+
return {
|
|
272
|
+
periods,
|
|
273
|
+
value,
|
|
274
|
+
'onChange': value => {
|
|
275
|
+
if (focusedRange === 'compare') {
|
|
276
|
+
this.handlers.preselectedCompare(value);
|
|
277
|
+
} else {
|
|
278
|
+
this.handlers.preselectedValue(value);
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
'onHighlightedChange': focusedRange === 'compare' ? onCompareHighlightedChange : onHighlightedChange,
|
|
282
|
+
onDisplayedPeriodChange,
|
|
283
|
+
'role': 'listbox',
|
|
284
|
+
'aria-label': getI18nText('periods'),
|
|
285
|
+
'periodRef': index => element => {
|
|
286
|
+
if (!element) return;
|
|
287
|
+
this.periodRefs[index] = element;
|
|
460
288
|
}
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
var _value$compare,
|
|
520
|
-
_this7 = this;
|
|
521
|
-
var _this$asProps8 = this.asProps,
|
|
522
|
-
value = _this$asProps8.value,
|
|
523
|
-
onDisplayedPeriodChange = _this$asProps8.onDisplayedPeriodChange,
|
|
524
|
-
locale = _this$asProps8.locale,
|
|
525
|
-
disabled = _this$asProps8.disabled,
|
|
526
|
-
disabledErrorText = _this$asProps8.disabledErrorText,
|
|
527
|
-
getI18nText = _this$asProps8.getI18nText,
|
|
528
|
-
focusedRange = _this$asProps8.focusedRange,
|
|
529
|
-
preselectedCompare = _this$asProps8.preselectedCompare,
|
|
530
|
-
compareToggle = _this$asProps8.compareToggle,
|
|
531
|
-
animationsDisabled = _this$asProps8.animationsDisabled,
|
|
532
|
-
visible = _this$asProps8.visible;
|
|
533
|
-
return {
|
|
534
|
-
popoverVisible: visible,
|
|
535
|
-
focused: focusedRange === 'compare' ? true : undefined,
|
|
536
|
-
disabled: !(compareToggle !== null && compareToggle !== void 0 ? compareToggle : value === null || value === void 0 || (_value$compare = value.compare) === null || _value$compare === void 0 ? void 0 : _value$compare.length),
|
|
537
|
-
value: preselectedCompare !== null && preselectedCompare !== void 0 ? preselectedCompare : value === null || value === void 0 ? void 0 : value.compare,
|
|
538
|
-
onChange: function onChange(value) {
|
|
539
|
-
return _this7.handlers.preselectedCompare(value);
|
|
540
|
-
},
|
|
541
|
-
onDisplayedPeriodChange: onDisplayedPeriodChange,
|
|
542
|
-
locale: locale,
|
|
543
|
-
disabledDates: disabled,
|
|
544
|
-
children: this.getRangeInput(),
|
|
545
|
-
getI18nText: getI18nText,
|
|
546
|
-
disabledErrorText: disabledErrorText,
|
|
547
|
-
onFocus: function onFocus() {
|
|
548
|
-
_this7.handlers.focusedRange('compare');
|
|
549
|
-
},
|
|
550
|
-
animationsDisabled: animationsDisabled
|
|
551
|
-
};
|
|
552
|
-
}
|
|
553
|
-
}, {
|
|
554
|
-
key: "getCompareToggleProps",
|
|
555
|
-
value: function getCompareToggleProps() {
|
|
556
|
-
var _this8 = this;
|
|
557
|
-
var _this$asProps9 = this.asProps,
|
|
558
|
-
getI18nText = _this$asProps9.getI18nText,
|
|
559
|
-
compareToggle = _this$asProps9.compareToggle;
|
|
560
|
-
return {
|
|
561
|
-
getI18nText: getI18nText,
|
|
562
|
-
checked: compareToggle,
|
|
563
|
-
onChange: function onChange(checked) {
|
|
564
|
-
if (checked) {
|
|
565
|
-
_this8.handlers.compareToggle(true);
|
|
566
|
-
_this8.handlers.focusedRange('compare');
|
|
567
|
-
} else {
|
|
568
|
-
_this8.handlers.compareToggle(false);
|
|
569
|
-
_this8.handlers.focusedRange('value');
|
|
570
|
-
_this8.handlers.preselectedCompare([]);
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
getPrevProps() {
|
|
292
|
+
const {
|
|
293
|
+
getI18nText
|
|
294
|
+
} = this.asProps;
|
|
295
|
+
const {
|
|
296
|
+
navigateStep
|
|
297
|
+
} = this;
|
|
298
|
+
return {
|
|
299
|
+
getI18nText,
|
|
300
|
+
'ref': this.prevButtonRef,
|
|
301
|
+
'onClick': this.bindHandlerNavigateClick(-1),
|
|
302
|
+
'aria-label': navigateStep === 'month' ? getI18nText('prevMonth') : getI18nText('prevYear')
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
getNextProps() {
|
|
306
|
+
const {
|
|
307
|
+
getI18nText
|
|
308
|
+
} = this.asProps;
|
|
309
|
+
const {
|
|
310
|
+
navigateStep
|
|
311
|
+
} = this;
|
|
312
|
+
return {
|
|
313
|
+
getI18nText,
|
|
314
|
+
'ref': this.nextButtonRef,
|
|
315
|
+
'onClick': this.bindHandlerNavigateClick(1),
|
|
316
|
+
'aria-label': navigateStep === 'month' ? getI18nText('nextMonth') : getI18nText('nextYear')
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
uncontrolledProps() {
|
|
320
|
+
return {
|
|
321
|
+
displayedPeriod: null,
|
|
322
|
+
visible: [null, visible => {
|
|
323
|
+
if (!visible) {
|
|
324
|
+
this.handlers.highlighted([]);
|
|
325
|
+
this.handlers.compareHighlighted([]);
|
|
326
|
+
this.handlers.preselectedValue(undefined);
|
|
327
|
+
this.handlers.preselectedCompare(undefined);
|
|
328
|
+
this.handlers.compareToggle(undefined);
|
|
329
|
+
this.handlers.focusedRange('value');
|
|
330
|
+
} else {
|
|
331
|
+
this.handlers.compareToggle(!!this.asProps.value?.compare?.length);
|
|
332
|
+
}
|
|
333
|
+
const {
|
|
334
|
+
value,
|
|
335
|
+
displayedPeriod
|
|
336
|
+
} = this.asProps;
|
|
337
|
+
const newDisplayedPeriod = value ? getLatestDate(value.value, value.compare) : undefined;
|
|
338
|
+
if (visible) {
|
|
339
|
+
if (newDisplayedPeriod && newDisplayedPeriod !== displayedPeriod) {
|
|
340
|
+
this.handlers.displayedPeriod(newDisplayedPeriod);
|
|
341
|
+
} else if (!newDisplayedPeriod) {
|
|
342
|
+
const {
|
|
343
|
+
displayedPeriod,
|
|
344
|
+
defaultDisplayedPeriod
|
|
345
|
+
} = this.props;
|
|
346
|
+
this.handlers.displayedPeriod(displayedPeriod || defaultDisplayedPeriod);
|
|
571
347
|
}
|
|
572
348
|
}
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
349
|
+
}],
|
|
350
|
+
highlighted: null,
|
|
351
|
+
compareHighlighted: null,
|
|
352
|
+
preselectedValue: null,
|
|
353
|
+
preselectedCompare: null,
|
|
354
|
+
compareToggle: null,
|
|
355
|
+
focusedRange: null,
|
|
356
|
+
value: [null, value => {
|
|
357
|
+
const dates = [value?.value, value?.compare].flat(2).filter(date => date?.isValid?.());
|
|
358
|
+
if (dates.length > 0) this.handlers.displayedPeriod(getLatestDate(value));
|
|
359
|
+
}]
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
getApplyProps() {
|
|
363
|
+
const {
|
|
364
|
+
getI18nText
|
|
365
|
+
} = this.asProps;
|
|
366
|
+
return {
|
|
367
|
+
getI18nText,
|
|
368
|
+
onClick: this.handleApplyClick,
|
|
369
|
+
ref: this.applyButtonRef
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
getResetProps() {
|
|
373
|
+
const {
|
|
374
|
+
getI18nText
|
|
375
|
+
} = this.asProps;
|
|
376
|
+
return {
|
|
377
|
+
getI18nText,
|
|
378
|
+
onClick: () => this.handleApply(null, null),
|
|
379
|
+
ref: this.resetButtonRef
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
isDisabled(date) {
|
|
383
|
+
const {
|
|
384
|
+
disabled
|
|
385
|
+
} = this.asProps;
|
|
386
|
+
return disabled.some((0, _includesDate.includesDate)((0, _dayjs.default)(date), 'date'));
|
|
387
|
+
}
|
|
388
|
+
getDefaultPeriods() {
|
|
389
|
+
const {
|
|
390
|
+
getI18nText
|
|
391
|
+
} = this.asProps;
|
|
392
|
+
const today = new Date(new Date().setHours(0, 0, 0, 0));
|
|
393
|
+
return [{
|
|
394
|
+
children: getI18nText('lastMonth'),
|
|
395
|
+
value: [(0, _dayjs.default)(today).subtract(1, 'month').startOf('month').toDate(), (0, _dayjs.default)(today).startOf('month').toDate()]
|
|
396
|
+
}, {
|
|
397
|
+
children: getI18nText('last3Months'),
|
|
398
|
+
value: [(0, _dayjs.default)(today).subtract(2, 'month').startOf('month').toDate(), (0, _dayjs.default)(today).startOf('month').toDate()]
|
|
399
|
+
}, {
|
|
400
|
+
children: getI18nText('last6Months'),
|
|
401
|
+
value: [(0, _dayjs.default)(today).subtract(5, 'month').startOf('month').toDate(), (0, _dayjs.default)(today).startOf('month').toDate()]
|
|
402
|
+
}, {
|
|
403
|
+
children: getI18nText('last12Months'),
|
|
404
|
+
value: [(0, _dayjs.default)(today).subtract(11, 'month').startOf('month').toDate(), (0, _dayjs.default)(today).startOf('month').toDate()]
|
|
405
|
+
}];
|
|
406
|
+
}
|
|
407
|
+
getTitleProps(_props, index) {
|
|
408
|
+
const {
|
|
409
|
+
locale,
|
|
410
|
+
displayedPeriod
|
|
411
|
+
} = this.asProps;
|
|
412
|
+
return {
|
|
413
|
+
children: new Intl.DateTimeFormat(locale, {
|
|
414
|
+
month: 'long',
|
|
415
|
+
year: 'numeric'
|
|
416
|
+
}).format((0, _dayjs.default)(displayedPeriod).add(index, this.navigateStep).startOf(this.navigateStep).toDate())
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
getTriggerProps({
|
|
420
|
+
placeholder = 'Select date ranges',
|
|
421
|
+
separator = 'vs.'
|
|
422
|
+
}) {
|
|
423
|
+
const {
|
|
424
|
+
locale,
|
|
425
|
+
visible
|
|
426
|
+
} = this.asProps;
|
|
427
|
+
const value = this.asProps.value?.value;
|
|
428
|
+
const compare = this.asProps.value?.compare;
|
|
429
|
+
const formattingProps = {
|
|
430
|
+
locale,
|
|
431
|
+
...this.triggerFormattingProps
|
|
432
|
+
};
|
|
433
|
+
let children = placeholder;
|
|
434
|
+
if (value?.[0] && value?.[1]) {
|
|
435
|
+
children = (0, _shortDateRangeFormat.default)(value, formattingProps);
|
|
631
436
|
}
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
value: function defaultProps(_ref1) {
|
|
635
|
-
var primaryRange = _ref1.primaryRange,
|
|
636
|
-
defaultPrimaryRange = _ref1.defaultPrimaryRange,
|
|
637
|
-
secondaryRange = _ref1.secondaryRange,
|
|
638
|
-
defaultSecondaryRange = _ref1.defaultSecondaryRange;
|
|
639
|
-
return {
|
|
640
|
-
i18n: _intergalacticDynamicLocales.localizedMessages,
|
|
641
|
-
locale: 'en',
|
|
642
|
-
defaultValue: null,
|
|
643
|
-
defaultHighlighted: [],
|
|
644
|
-
defaultCompareHighlighted: [],
|
|
645
|
-
defaultDisplayedPeriod: getLatestDate(primaryRange, defaultPrimaryRange, secondaryRange, defaultSecondaryRange) || defaultDisplayedPeriod,
|
|
646
|
-
defaultVisible: false,
|
|
647
|
-
defaultPreselectedValue: null,
|
|
648
|
-
defaultPreselectedCompare: null,
|
|
649
|
-
defaultCompareToggle: null,
|
|
650
|
-
defaultFocusedRange: 'value',
|
|
651
|
-
disabled: [],
|
|
652
|
-
size: 'm'
|
|
653
|
-
};
|
|
437
|
+
if (compare?.[0] && compare?.[1]) {
|
|
438
|
+
children = `${children || ''} ${separator} ${(0, _shortDateRangeFormat.default)(compare, formattingProps)}`;
|
|
654
439
|
}
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
(
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
440
|
+
return {
|
|
441
|
+
children,
|
|
442
|
+
visible,
|
|
443
|
+
onClick: () => this.handlers.visible(!visible),
|
|
444
|
+
onKeyDown: this.handleKeydownDown('trigger')
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
getRangeInput() {
|
|
448
|
+
throw new Error('not implemented');
|
|
449
|
+
}
|
|
450
|
+
getRangeInputProps() {
|
|
451
|
+
return {
|
|
452
|
+
inputRole: null
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
getValueDateRangeProps() {
|
|
456
|
+
const {
|
|
457
|
+
value,
|
|
458
|
+
onDisplayedPeriodChange,
|
|
459
|
+
locale,
|
|
460
|
+
disabled,
|
|
461
|
+
disabledErrorText,
|
|
462
|
+
getI18nText,
|
|
463
|
+
focusedRange,
|
|
464
|
+
preselectedValue,
|
|
465
|
+
animationsDisabled,
|
|
466
|
+
visible
|
|
467
|
+
} = this.asProps;
|
|
468
|
+
return {
|
|
469
|
+
popoverVisible: visible,
|
|
470
|
+
focused: focusedRange === 'value' ? true : undefined,
|
|
471
|
+
value: preselectedValue ?? value?.value,
|
|
472
|
+
onChange: value => this.handlers.preselectedValue(value),
|
|
473
|
+
onDisplayedPeriodChange,
|
|
474
|
+
locale,
|
|
475
|
+
disabledDates: disabled,
|
|
476
|
+
disabledErrorText,
|
|
477
|
+
children: this.getRangeInput(),
|
|
478
|
+
getI18nText,
|
|
479
|
+
onFocus: () => {
|
|
480
|
+
this.handlers.focusedRange('value');
|
|
481
|
+
},
|
|
482
|
+
animationsDisabled
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
getCompareDateRangeProps() {
|
|
486
|
+
const {
|
|
487
|
+
value,
|
|
488
|
+
onDisplayedPeriodChange,
|
|
489
|
+
locale,
|
|
490
|
+
disabled,
|
|
491
|
+
disabledErrorText,
|
|
492
|
+
getI18nText,
|
|
493
|
+
focusedRange,
|
|
494
|
+
preselectedCompare,
|
|
495
|
+
compareToggle,
|
|
496
|
+
animationsDisabled,
|
|
497
|
+
visible
|
|
498
|
+
} = this.asProps;
|
|
499
|
+
return {
|
|
500
|
+
popoverVisible: visible,
|
|
501
|
+
focused: focusedRange === 'compare' ? true : undefined,
|
|
502
|
+
disabled: !(compareToggle ?? value?.compare?.length),
|
|
503
|
+
value: preselectedCompare ?? value?.compare,
|
|
504
|
+
onChange: value => this.handlers.preselectedCompare(value),
|
|
505
|
+
onDisplayedPeriodChange,
|
|
506
|
+
locale,
|
|
507
|
+
disabledDates: disabled,
|
|
508
|
+
children: this.getRangeInput(),
|
|
509
|
+
getI18nText,
|
|
510
|
+
disabledErrorText,
|
|
511
|
+
onFocus: () => {
|
|
512
|
+
this.handlers.focusedRange('compare');
|
|
513
|
+
},
|
|
514
|
+
animationsDisabled
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
getCompareToggleProps() {
|
|
518
|
+
const {
|
|
519
|
+
getI18nText,
|
|
520
|
+
compareToggle
|
|
521
|
+
} = this.asProps;
|
|
522
|
+
return {
|
|
523
|
+
getI18nText,
|
|
524
|
+
checked: compareToggle,
|
|
525
|
+
onChange: checked => {
|
|
526
|
+
if (checked) {
|
|
527
|
+
this.handlers.compareToggle(true);
|
|
528
|
+
this.handlers.focusedRange('compare');
|
|
529
|
+
} else {
|
|
530
|
+
this.handlers.compareToggle(false);
|
|
531
|
+
this.handlers.focusedRange('value');
|
|
532
|
+
this.handlers.preselectedCompare([]);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
getCalendarProps(_props, index) {
|
|
538
|
+
const {
|
|
539
|
+
locale,
|
|
540
|
+
displayedPeriod,
|
|
541
|
+
disabled,
|
|
542
|
+
value,
|
|
543
|
+
onCompareHighlightedChange,
|
|
544
|
+
highlighted,
|
|
545
|
+
compareHighlighted,
|
|
546
|
+
onHighlightedChange,
|
|
547
|
+
preselectedCompare,
|
|
548
|
+
preselectedValue,
|
|
549
|
+
focusedRange,
|
|
550
|
+
getI18nText
|
|
551
|
+
} = this.asProps;
|
|
552
|
+
return {
|
|
553
|
+
locale,
|
|
554
|
+
displayedPeriod: (0, _dayjs.default)(displayedPeriod).add(index, this.navigateStep).startOf(this.navigateStep).toDate(),
|
|
555
|
+
disabled,
|
|
556
|
+
onChange: this.handleChange,
|
|
557
|
+
highlighted,
|
|
558
|
+
compareHighlighted,
|
|
559
|
+
onCompareHighlightedChange,
|
|
560
|
+
onHighlightedChange,
|
|
561
|
+
range: focusedRange,
|
|
562
|
+
value: preselectedValue ?? value?.value,
|
|
563
|
+
compare: preselectedCompare ?? value?.compare,
|
|
564
|
+
unitRefs: this.unitRefs,
|
|
565
|
+
getI18nText,
|
|
566
|
+
actionsDescribing: index === 0 ? 'range-compare' : null,
|
|
567
|
+
tabIndex: index === 0 ? 0 : -1
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
getPopperProps() {
|
|
571
|
+
return {
|
|
572
|
+
p: 0,
|
|
573
|
+
ref: this.popperRef,
|
|
574
|
+
onKeyDown: this.handleKeydownDown('popper')
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
render() {
|
|
578
|
+
var _ref = this.asProps,
|
|
579
|
+
_ref4;
|
|
580
|
+
const {
|
|
581
|
+
Children,
|
|
582
|
+
styles,
|
|
583
|
+
'aria-label': providedAriaLabel
|
|
584
|
+
} = this.asProps;
|
|
585
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, (_ref4 = (0, _core.sstyled)(styles), /*#__PURE__*/_react.default.createElement(_dropdown.default, (0, _core.assignProps)({
|
|
586
|
+
"use:aria-label": providedAriaLabel,
|
|
587
|
+
"__excludeProps": ['onChange', 'value']
|
|
588
|
+
}, _ref), /*#__PURE__*/_react.default.createElement(Children, _ref4.cn("Children", {})))));
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
(0, _defineProperty2.default)(DateRangeComparatorAbstract, "displayName", 'DateRangeComparator');
|
|
592
|
+
(0, _defineProperty2.default)(DateRangeComparatorAbstract, "style", style);
|
|
593
|
+
(0, _defineProperty2.default)(DateRangeComparatorAbstract, "enhance", [(0, _i18nEnhance.default)(_intergalacticDynamicLocales.localizedMessages)]);
|
|
594
|
+
(0, _defineProperty2.default)(DateRangeComparatorAbstract, "subtract", (date, amount, unit) => {
|
|
595
|
+
return (0, _dayjs.default)(date).subtract(amount, unit).toDate();
|
|
662
596
|
});
|
|
663
597
|
function Apply(props) {
|
|
664
598
|
var _ref2 = arguments[0];
|
|
665
|
-
|
|
666
|
-
|
|
599
|
+
const {
|
|
600
|
+
getI18nText
|
|
601
|
+
} = props;
|
|
602
|
+
return /*#__PURE__*/_react.default.createElement(_button.default, (0, _core.assignProps)({
|
|
667
603
|
"use": 'primary',
|
|
668
604
|
"children": getI18nText('apply')
|
|
669
605
|
}, _ref2));
|
|
670
606
|
}
|
|
671
607
|
function Reset(props) {
|
|
672
608
|
var _ref3 = arguments[0];
|
|
673
|
-
|
|
674
|
-
|
|
609
|
+
const {
|
|
610
|
+
getI18nText
|
|
611
|
+
} = props;
|
|
612
|
+
return /*#__PURE__*/_react.default.createElement(_button.default, (0, _core.assignProps)({
|
|
675
613
|
"use": 'tertiary',
|
|
676
614
|
"theme": 'muted',
|
|
677
615
|
"children": getI18nText('reset')
|
|
@@ -679,53 +617,63 @@ function Reset(props) {
|
|
|
679
617
|
}
|
|
680
618
|
function Trigger(props) {
|
|
681
619
|
var _ref5;
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
620
|
+
const {
|
|
621
|
+
Root: STrigger,
|
|
622
|
+
styles
|
|
623
|
+
} = props;
|
|
624
|
+
return _ref5 = (0, _core.sstyled)(styles), /*#__PURE__*/_react.default.createElement(STrigger, _ref5.cn("STrigger", {
|
|
625
|
+
"render": _dropdown.default.Trigger,
|
|
686
626
|
"tag": _baseTrigger.LinkTrigger
|
|
687
627
|
}));
|
|
688
628
|
}
|
|
689
629
|
function CompareToggle(props) {
|
|
690
630
|
var _ref6;
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
631
|
+
const {
|
|
632
|
+
Root: SCompareToggle,
|
|
633
|
+
styles,
|
|
634
|
+
getI18nText
|
|
635
|
+
} = props;
|
|
636
|
+
return _ref6 = (0, _core.sstyled)(styles), /*#__PURE__*/_react.default.createElement(SCompareToggle, _ref6.cn("SCompareToggle", {
|
|
637
|
+
"render": _checkbox.default,
|
|
696
638
|
"label": getI18nText('compare')
|
|
697
639
|
}));
|
|
698
640
|
}
|
|
699
641
|
function Header(props) {
|
|
700
642
|
var _ref7;
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
643
|
+
const {
|
|
644
|
+
Root: SRangeComparatorHeader,
|
|
645
|
+
Children,
|
|
646
|
+
styles
|
|
647
|
+
} = props;
|
|
648
|
+
return _ref7 = (0, _core.sstyled)(styles), /*#__PURE__*/_react.default.createElement(SRangeComparatorHeader, _ref7.cn("SRangeComparatorHeader", {
|
|
649
|
+
"render": _baseComponents.Flex,
|
|
706
650
|
"gap": 4,
|
|
707
651
|
"alignItems": 'center'
|
|
708
|
-
}), /*#__PURE__*/_react
|
|
652
|
+
}), /*#__PURE__*/_react.default.createElement(Children, _ref7.cn("Children", {})));
|
|
709
653
|
}
|
|
710
654
|
function Body(props) {
|
|
711
655
|
var _ref8;
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
656
|
+
const {
|
|
657
|
+
Root: SBody,
|
|
658
|
+
Children,
|
|
659
|
+
styles
|
|
660
|
+
} = props;
|
|
661
|
+
return _ref8 = (0, _core.sstyled)(styles), /*#__PURE__*/_react.default.createElement(SBody, _ref8.cn("SBody", {
|
|
662
|
+
"render": _baseComponents.Flex,
|
|
717
663
|
"gap": 4
|
|
718
|
-
}), /*#__PURE__*/_react
|
|
664
|
+
}), /*#__PURE__*/_react.default.createElement(Children, _ref8.cn("Children", {})));
|
|
719
665
|
}
|
|
720
666
|
function Footer(props) {
|
|
721
667
|
var _ref9;
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
668
|
+
const {
|
|
669
|
+
Root: SFooter,
|
|
670
|
+
styles,
|
|
671
|
+
Children
|
|
672
|
+
} = props;
|
|
673
|
+
return _ref9 = (0, _core.sstyled)(styles), /*#__PURE__*/_react.default.createElement(SFooter, _ref9.cn("SFooter", {
|
|
674
|
+
"render": _baseComponents.Flex,
|
|
727
675
|
"gap": 2
|
|
728
|
-
}), /*#__PURE__*/_react
|
|
676
|
+
}), /*#__PURE__*/_react.default.createElement(Children, _ref9.cn("Children", {})));
|
|
729
677
|
}
|
|
730
|
-
var _default = exports
|
|
678
|
+
var _default = exports.default = DateRangeComparatorAbstract;
|
|
731
679
|
//# sourceMappingURL=DateRangeComparatorAbstract.js.map
|