@semcore/date-picker 4.29.2 → 4.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -1
- package/lib/cjs/DatePicker.js +1 -1
- package/lib/cjs/DatePicker.js.map +1 -1
- package/lib/cjs/DateRangeComparator.js +11 -8
- package/lib/cjs/DateRangeComparator.js.map +1 -1
- package/lib/cjs/MonthDateRangeComparator.js +7 -6
- package/lib/cjs/MonthDateRangeComparator.js.map +1 -1
- package/lib/cjs/components/Calendar.js +156 -72
- package/lib/cjs/components/Calendar.js.map +1 -1
- package/lib/cjs/components/DateRangeComparatorAbstract.js +206 -123
- package/lib/cjs/components/DateRangeComparatorAbstract.js.map +1 -1
- package/lib/cjs/components/InputTrigger.js +50 -38
- package/lib/cjs/components/InputTrigger.js.map +1 -1
- package/lib/cjs/components/PickerAbstract.js +38 -29
- package/lib/cjs/components/PickerAbstract.js.map +1 -1
- package/lib/cjs/components/RangePickerAbstract.js +105 -79
- package/lib/cjs/components/RangePickerAbstract.js.map +1 -1
- package/lib/cjs/components/index.js +4 -4
- package/lib/cjs/components/index.js.map +1 -1
- package/lib/cjs/style/calendar.shadow.css +7 -3
- package/lib/cjs/translations/en.json +8 -1
- package/lib/cjs/utils/formatDate.js +19 -7
- package/lib/cjs/utils/formatDate.js.map +1 -1
- package/lib/es6/DatePicker.js +2 -2
- package/lib/es6/DatePicker.js.map +1 -1
- package/lib/es6/DateRangeComparator.js +11 -8
- package/lib/es6/DateRangeComparator.js.map +1 -1
- package/lib/es6/MonthDateRangeComparator.js +7 -6
- package/lib/es6/MonthDateRangeComparator.js.map +1 -1
- package/lib/es6/components/Calendar.js +157 -73
- package/lib/es6/components/Calendar.js.map +1 -1
- package/lib/es6/components/DateRangeComparatorAbstract.js +206 -123
- package/lib/es6/components/DateRangeComparatorAbstract.js.map +1 -1
- package/lib/es6/components/InputTrigger.js +50 -38
- package/lib/es6/components/InputTrigger.js.map +1 -1
- package/lib/es6/components/PickerAbstract.js +38 -29
- package/lib/es6/components/PickerAbstract.js.map +1 -1
- package/lib/es6/components/RangePickerAbstract.js +105 -79
- package/lib/es6/components/RangePickerAbstract.js.map +1 -1
- package/lib/es6/components/index.js +4 -4
- package/lib/es6/components/index.js.map +1 -1
- package/lib/es6/style/calendar.shadow.css +7 -3
- package/lib/es6/translations/en.json +8 -1
- package/lib/es6/utils/formatDate.js +16 -5
- package/lib/es6/utils/formatDate.js.map +1 -1
- package/package.json +14 -14
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
1
2
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
3
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
4
|
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
@@ -19,34 +20,36 @@ import { localizedMessages } from '../translations/__intergalactic-dynamic-local
|
|
|
19
20
|
import shortDateRangeFormat from '../utils/shortDateRangeFormat';
|
|
20
21
|
import Checkbox from '@semcore/checkbox';
|
|
21
22
|
import { LinkTrigger } from '@semcore/base-trigger';
|
|
23
|
+
import { formatDDMMYY, formatMMYY } from '../utils/formatDate';
|
|
22
24
|
/*__reshadow-styles__:"../style/date-picker.shadow.css"*/
|
|
23
|
-
var style = ( /*__reshadow_css_start__*/_sstyled.insert( /*__inner_css_start__*/".
|
|
24
|
-
"__SHeader": "
|
|
25
|
-
"__STitle": "
|
|
26
|
-
"__SToday": "
|
|
27
|
-
"__SPeriod": "
|
|
28
|
-
"__SButton": "
|
|
29
|
-
"__SInner": "
|
|
30
|
-
"__SInputMask": "
|
|
31
|
-
"__SIndicator": "
|
|
32
|
-
"__SRangeIndicator": "
|
|
33
|
-
"_range_value": "
|
|
34
|
-
"_range_compare": "
|
|
35
|
-
"_disabled": "
|
|
36
|
-
"__SHumanizedDate": "
|
|
37
|
-
"__SSingleDateInput": "
|
|
38
|
-
"__SValue": "
|
|
39
|
-
"__SDateRange": "
|
|
40
|
-
"__SMask": "
|
|
41
|
-
"_noHumanizedDate": "
|
|
42
|
-
"__SRangeSep": "
|
|
43
|
-
"_fulfilled": "
|
|
44
|
-
"__SRangeComparatorHeader": "
|
|
45
|
-
"__SRangeCalendar": "
|
|
46
|
-
"__SFooter": "
|
|
47
|
-
"__SPeriodsList": "
|
|
48
|
-
"__SPopper": "
|
|
25
|
+
var style = ( /*__reshadow_css_start__*/_sstyled.insert( /*__inner_css_start__*/".___SPopper_hw5in_gg_{padding:var(--intergalactic-spacing-4x, 16px);outline:0}.___SPopper_hw5in_gg_::-moz-focus-inner{border:0;padding:0}.___SPopper_hw5in_gg_:active,.___SPopper_hw5in_gg_:focus{outline:0;-webkit-text-decoration:none;text-decoration:none}@media (hover:hover){.___SPopper_hw5in_gg_:hover{outline:0;-webkit-text-decoration:none;text-decoration:none}}.___SPopper_hw5in_gg_:focus{box-shadow:var(--intergalactic-keyboard-focus, 0px 0px 0px 3px rgba(0, 143, 248, 0.5))}.___SHeader_hw5in_gg_,.___STitle_hw5in_gg_{display:flex;align-items:center}.___STitle_hw5in_gg_{font-size:var(--intergalactic-fs-200, 14px);color:var(--intergalactic-text-primary, #191b23);height:32px;width:100%;justify-content:center}.___SToday_hw5in_gg_{display:flex;margin-top:var(--intergalactic-spacing-3x, 12px);justify-content:center}.___SPeriod_hw5in_gg_{display:flex;flex-direction:column;margin-bottom:var(--intergalactic-spacing-2x, 8px)}.___SButton_hw5in_gg_ .___SInner_hw5in_gg_{justify-content:flex-start}.___SInputMask_hw5in_gg_{color:var(--intergalactic-text-primary, #191b23);line-height:normal}.___SIndicator_hw5in_gg_{color:var(--intergalactic-text-secondary, #6c6e79)}.___SRangeIndicator_hw5in_gg_{border-radius:50%;flex-shrink:0}.___SRangeIndicator_hw5in_gg_._range_value_hw5in_gg_{background-color:var(--intergalactic-date-picker-cell-active, #2bb3ff)}.___SRangeIndicator_hw5in_gg_._range_compare_hw5in_gg_{background-color:var(--intergalactic-date-picker-cell-comparison-active, #8649e1)}.___SRangeIndicator_hw5in_gg_.__disabled_hw5in_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3)}.___SHumanizedDate_hw5in_gg_{position:absolute;pointer-events:none}.___SDateRange_hw5in_gg_ .___SMask_hw5in_gg_,.___SDateRange_hw5in_gg_ .___SValue_hw5in_gg_,.___SSingleDateInput_hw5in_gg_ .___SMask_hw5in_gg_,.___SSingleDateInput_hw5in_gg_ .___SValue_hw5in_gg_{opacity:0}.___SSingleDateInput_hw5in_gg_:focus-within .___SHumanizedDate_hw5in_gg_{opacity:0;z-index:var(--intergalactic-z-index-deep, -999)}.___SSingleDateInput_hw5in_gg_:focus-within .___SMask_hw5in_gg_,.___SSingleDateInput_hw5in_gg_:focus-within .___SValue_hw5in_gg_{opacity:1}.___SDateRange_hw5in_gg_:focus-within .___SHumanizedDate_hw5in_gg_{opacity:0;z-index:var(--intergalactic-z-index-deep, -999)}.___SDateRange_hw5in_gg_:focus-within .___SMask_hw5in_gg_,.___SDateRange_hw5in_gg_:focus-within .___SValue_hw5in_gg_{opacity:1}.___SInputMask_hw5in_gg_.__noHumanizedDate_hw5in_gg_ .___SMask_hw5in_gg_,.___SInputMask_hw5in_gg_.__noHumanizedDate_hw5in_gg_ .___SValue_hw5in_gg_{opacity:1}.___SDateRange_hw5in_gg_ .___SInputMask_hw5in_gg_:focus-within .___SMask_hw5in_gg_{background-color:var(--intergalactic-bg-highlight-focus, rgba(0, 143, 248, 0.2))}.___SDateRange_hw5in_gg_:focus-within .___SRangeSep_hw5in_gg_,.___SRangeSep_hw5in_gg_.__fulfilled_hw5in_gg_{color:var(--intergalactic-text-primary, #191b23)}.___SRangeComparatorHeader_hw5in_gg_{border-bottom:1px solid var(--intergalactic-border-primary, #c4c7cf)}.___SRangeCalendar_hw5in_gg_,.___SRangeComparatorHeader_hw5in_gg_{padding:var(--intergalactic-spacing-4x, 16px)}.___SFooter_hw5in_gg_{border-top:1px solid var(--intergalactic-border-primary, #c4c7cf)}.___SFooter_hw5in_gg_,.___SPeriodsList_hw5in_gg_{padding:var(--intergalactic-spacing-4x, 16px)}" /*__inner_css_end__*/, "hw5in_gg_") /*__reshadow_css_end__*/, {
|
|
26
|
+
"__SHeader": "___SHeader_hw5in_gg_",
|
|
27
|
+
"__STitle": "___STitle_hw5in_gg_",
|
|
28
|
+
"__SToday": "___SToday_hw5in_gg_",
|
|
29
|
+
"__SPeriod": "___SPeriod_hw5in_gg_",
|
|
30
|
+
"__SButton": "___SButton_hw5in_gg_",
|
|
31
|
+
"__SInner": "___SInner_hw5in_gg_",
|
|
32
|
+
"__SInputMask": "___SInputMask_hw5in_gg_",
|
|
33
|
+
"__SIndicator": "___SIndicator_hw5in_gg_",
|
|
34
|
+
"__SRangeIndicator": "___SRangeIndicator_hw5in_gg_",
|
|
35
|
+
"_range_value": "_range_value_hw5in_gg_",
|
|
36
|
+
"_range_compare": "_range_compare_hw5in_gg_",
|
|
37
|
+
"_disabled": "__disabled_hw5in_gg_",
|
|
38
|
+
"__SHumanizedDate": "___SHumanizedDate_hw5in_gg_",
|
|
39
|
+
"__SSingleDateInput": "___SSingleDateInput_hw5in_gg_",
|
|
40
|
+
"__SValue": "___SValue_hw5in_gg_",
|
|
41
|
+
"__SDateRange": "___SDateRange_hw5in_gg_",
|
|
42
|
+
"__SMask": "___SMask_hw5in_gg_",
|
|
43
|
+
"_noHumanizedDate": "__noHumanizedDate_hw5in_gg_",
|
|
44
|
+
"__SRangeSep": "___SRangeSep_hw5in_gg_",
|
|
45
|
+
"_fulfilled": "__fulfilled_hw5in_gg_",
|
|
46
|
+
"__SRangeComparatorHeader": "___SRangeComparatorHeader_hw5in_gg_",
|
|
47
|
+
"__SRangeCalendar": "___SRangeCalendar_hw5in_gg_",
|
|
48
|
+
"__SFooter": "___SFooter_hw5in_gg_",
|
|
49
|
+
"__SPeriodsList": "___SPeriodsList_hw5in_gg_",
|
|
50
|
+
"__SPopper": "___SPopper_hw5in_gg_"
|
|
49
51
|
});
|
|
52
|
+
var INTERACTION_TAGS = ['INPUT'];
|
|
50
53
|
var INTERACTION_KEYS = ['ArrowDown', 'Enter', 'Space'];
|
|
51
54
|
var defaultDisplayedPeriod = new Date(new Date().setHours(0, 0, 0, 0));
|
|
52
55
|
var getLatestDate = function getLatestDate() {
|
|
@@ -74,6 +77,7 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
74
77
|
}
|
|
75
78
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
76
79
|
_defineProperty(_assertThisInitialized(_this), "popperRef", /*#__PURE__*/React.createRef());
|
|
80
|
+
_defineProperty(_assertThisInitialized(_this), "unitRefs", {});
|
|
77
81
|
_defineProperty(_assertThisInitialized(_this), "navigateView", function (direction) {
|
|
78
82
|
var displayedPeriod = _this.asProps.displayedPeriod;
|
|
79
83
|
var action = direction >= 1 ? 'add' : 'subtract';
|
|
@@ -85,6 +89,13 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
85
89
|
return _this.navigateView(direction);
|
|
86
90
|
};
|
|
87
91
|
});
|
|
92
|
+
_defineProperty(_assertThisInitialized(_this), "handleApplyClick", function () {
|
|
93
|
+
var _this$asProps = _this.asProps,
|
|
94
|
+
value = _this$asProps.value,
|
|
95
|
+
preselectedValue = _this$asProps.preselectedValue,
|
|
96
|
+
preselectedCompare = _this$asProps.preselectedCompare;
|
|
97
|
+
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);
|
|
98
|
+
});
|
|
88
99
|
_defineProperty(_assertThisInitialized(_this), "handleApply", function (value, compare) {
|
|
89
100
|
_this.handlers.value({
|
|
90
101
|
value: value,
|
|
@@ -92,26 +103,97 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
92
103
|
});
|
|
93
104
|
_this.handlers.visible(false);
|
|
94
105
|
});
|
|
95
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
106
|
+
_defineProperty(_assertThisInitialized(_this), "handleKeydownDown", function (place) {
|
|
107
|
+
return function (e) {
|
|
108
|
+
var _this$asProps2 = _this.asProps,
|
|
109
|
+
displayedPeriod = _this$asProps2.displayedPeriod,
|
|
110
|
+
preselectedValue = _this$asProps2.preselectedValue,
|
|
111
|
+
visible = _this$asProps2.visible,
|
|
112
|
+
focusedRange = _this$asProps2.focusedRange;
|
|
113
|
+
var key = e.code;
|
|
114
|
+
var highlighted = focusedRange === 'compare' ? _this.asProps.compareHighlighted : _this.asProps.highlighted;
|
|
115
|
+
if (place === 'trigger' && INTERACTION_KEYS.includes(key)) {
|
|
116
|
+
e.stopPropagation();
|
|
117
|
+
_this.handlers.visible(!visible);
|
|
118
|
+
setTimeout(function () {
|
|
119
|
+
var popper = _this.popperRef.current;
|
|
120
|
+
if (popper) {
|
|
121
|
+
popper.focus();
|
|
122
|
+
}
|
|
123
|
+
}, 0);
|
|
124
|
+
}
|
|
125
|
+
var day = _this.keyDiff[key];
|
|
126
|
+
var setNextDisplayedPeriod = function setNextDisplayedPeriod(next_highlighted) {
|
|
127
|
+
var _next_highlighted = _slicedToArray(next_highlighted, 2),
|
|
128
|
+
left_period = _next_highlighted[0],
|
|
129
|
+
right_period = _next_highlighted[1];
|
|
130
|
+
var monthDisplayedPeriod = displayedPeriod === null || displayedPeriod === void 0 ? void 0 : displayedPeriod.getMonth();
|
|
131
|
+
var period = right_period || left_period;
|
|
132
|
+
if (period) {
|
|
133
|
+
if (!monthDisplayedPeriod) {
|
|
134
|
+
return period;
|
|
135
|
+
}
|
|
136
|
+
if (period.getMonth() - monthDisplayedPeriod > 1) {
|
|
137
|
+
return DateRangeComparatorAbstract.subtract(period, 1, 'month');
|
|
138
|
+
} else if (period.getMonth() - monthDisplayedPeriod < 0) {
|
|
139
|
+
return period;
|
|
140
|
+
}
|
|
105
141
|
}
|
|
106
|
-
|
|
107
|
-
|
|
142
|
+
return displayedPeriod;
|
|
143
|
+
};
|
|
144
|
+
if (place === 'popper' && e.code === 'Space' && highlighted.length) {
|
|
145
|
+
var highlightedDate = highlighted[1] || highlighted[0];
|
|
146
|
+
if (!_this.isDisabled(highlightedDate)) {
|
|
147
|
+
_this.handleChange(highlightedDate);
|
|
148
|
+
}
|
|
149
|
+
e.preventDefault();
|
|
150
|
+
}
|
|
151
|
+
if (place === 'popper' && e.code === 'Enter' && (e.metaKey || e.ctrlKey)) {
|
|
152
|
+
return _this.handleApplyClick();
|
|
153
|
+
}
|
|
154
|
+
var changedDate = undefined;
|
|
155
|
+
if (day) {
|
|
156
|
+
if (INTERACTION_TAGS.includes(e.target.tagName)) return;
|
|
157
|
+
if (highlighted.length) {
|
|
158
|
+
var next_highlighted;
|
|
159
|
+
if ((preselectedValue === null || preselectedValue === void 0 ? void 0 : preselectedValue.length) === 1) {
|
|
160
|
+
next_highlighted = [preselectedValue[0], dayjs(highlighted[1] || highlighted[0]).add(day, _this.keyStep).toDate()];
|
|
161
|
+
changedDate = next_highlighted[1];
|
|
162
|
+
} else {
|
|
163
|
+
next_highlighted = [dayjs(highlighted[0]).add(day, _this.keyStep).toDate()];
|
|
164
|
+
changedDate = next_highlighted[0];
|
|
165
|
+
}
|
|
166
|
+
if (focusedRange === 'compare') {
|
|
167
|
+
_this.handlers.compareHighlighted(next_highlighted);
|
|
168
|
+
} else {
|
|
169
|
+
_this.handlers.highlighted(next_highlighted);
|
|
170
|
+
}
|
|
171
|
+
_this.handlers.displayedPeriod(setNextDisplayedPeriod(next_highlighted));
|
|
172
|
+
} else {
|
|
173
|
+
var _highlighted = [displayedPeriod ? displayedPeriod : dayjs().toDate()];
|
|
174
|
+
if (focusedRange === 'compare') {
|
|
175
|
+
_this.handlers.compareHighlighted(_highlighted);
|
|
176
|
+
} else {
|
|
177
|
+
_this.handlers.highlighted(_highlighted);
|
|
178
|
+
}
|
|
179
|
+
changedDate = _highlighted[0];
|
|
180
|
+
}
|
|
181
|
+
e.preventDefault();
|
|
182
|
+
if (changedDate) {
|
|
183
|
+
var _this$unitRefs$format;
|
|
184
|
+
var formatter = _this.keyStep === 'month' ? formatMMYY : formatDDMMYY;
|
|
185
|
+
var formattedDate = formatter(changedDate, _this.asProps.locale);
|
|
186
|
+
(_this$unitRefs$format = _this.unitRefs[formattedDate]) === null || _this$unitRefs$format === void 0 ? void 0 : _this$unitRefs$format.focus();
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
};
|
|
108
190
|
});
|
|
109
191
|
_defineProperty(_assertThisInitialized(_this), "handleChange", function (date) {
|
|
110
192
|
var _value, _value2, _value3;
|
|
111
|
-
var _this$
|
|
112
|
-
focusedRange = _this$
|
|
113
|
-
preselectedCompare = _this$
|
|
114
|
-
preselectedValue = _this$
|
|
193
|
+
var _this$asProps3 = _this.asProps,
|
|
194
|
+
focusedRange = _this$asProps3.focusedRange,
|
|
195
|
+
preselectedCompare = _this$asProps3.preselectedCompare,
|
|
196
|
+
preselectedValue = _this$asProps3.preselectedValue;
|
|
115
197
|
var highlighted = [];
|
|
116
198
|
var value = focusedRange === 'compare' ? preselectedCompare : preselectedValue;
|
|
117
199
|
if (Array.isArray(date)) {
|
|
@@ -144,15 +226,15 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
144
226
|
value: function getPeriodProps() {
|
|
145
227
|
var _this$asProps$value,
|
|
146
228
|
_this2 = this;
|
|
147
|
-
var _this$
|
|
148
|
-
_this$
|
|
149
|
-
periods = _this$
|
|
150
|
-
onHighlightedChange = _this$
|
|
151
|
-
onCompareHighlightedChange = _this$
|
|
152
|
-
onDisplayedPeriodChange = _this$
|
|
153
|
-
preselectedValue = _this$
|
|
154
|
-
preselectedCompare = _this$
|
|
155
|
-
focusedRange = _this$
|
|
229
|
+
var _this$asProps4 = this.asProps,
|
|
230
|
+
_this$asProps4$period = _this$asProps4.periods,
|
|
231
|
+
periods = _this$asProps4$period === void 0 ? this.getDefaultPeriods() : _this$asProps4$period,
|
|
232
|
+
onHighlightedChange = _this$asProps4.onHighlightedChange,
|
|
233
|
+
onCompareHighlightedChange = _this$asProps4.onCompareHighlightedChange,
|
|
234
|
+
onDisplayedPeriodChange = _this$asProps4.onDisplayedPeriodChange,
|
|
235
|
+
preselectedValue = _this$asProps4.preselectedValue,
|
|
236
|
+
preselectedCompare = _this$asProps4.preselectedCompare,
|
|
237
|
+
focusedRange = _this$asProps4.focusedRange;
|
|
156
238
|
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;
|
|
157
239
|
if (focusedRange === 'compare') {
|
|
158
240
|
var _this$asProps$value2;
|
|
@@ -238,28 +320,21 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
238
320
|
}, {
|
|
239
321
|
key: "getApplyProps",
|
|
240
322
|
value: function getApplyProps() {
|
|
241
|
-
var
|
|
242
|
-
var _this$asProps3 = this.asProps,
|
|
243
|
-
value = _this$asProps3.value,
|
|
244
|
-
getI18nText = _this$asProps3.getI18nText,
|
|
245
|
-
preselectedValue = _this$asProps3.preselectedValue,
|
|
246
|
-
preselectedCompare = _this$asProps3.preselectedCompare;
|
|
323
|
+
var getI18nText = this.asProps.getI18nText;
|
|
247
324
|
return {
|
|
248
325
|
getI18nText: getI18nText,
|
|
249
|
-
onClick:
|
|
250
|
-
return _this4.handleApply(preselectedValue !== null && preselectedValue !== void 0 ? preselectedValue : value === null || value === void 0 ? void 0 : value.value, preselectedCompare !== null && preselectedCompare !== void 0 ? preselectedCompare : value === null || value === void 0 ? void 0 : value.compare);
|
|
251
|
-
}
|
|
326
|
+
onClick: this.handleApplyClick
|
|
252
327
|
};
|
|
253
328
|
}
|
|
254
329
|
}, {
|
|
255
330
|
key: "getResetProps",
|
|
256
331
|
value: function getResetProps() {
|
|
257
|
-
var
|
|
332
|
+
var _this4 = this;
|
|
258
333
|
var getI18nText = this.asProps.getI18nText;
|
|
259
334
|
return {
|
|
260
335
|
getI18nText: getI18nText,
|
|
261
336
|
onClick: function onClick() {
|
|
262
|
-
return
|
|
337
|
+
return _this4.handleApply(null, null);
|
|
263
338
|
}
|
|
264
339
|
};
|
|
265
340
|
}
|
|
@@ -285,9 +360,9 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
285
360
|
}, {
|
|
286
361
|
key: "getTitleProps",
|
|
287
362
|
value: function getTitleProps(props, index) {
|
|
288
|
-
var _this$
|
|
289
|
-
locale = _this$
|
|
290
|
-
displayedPeriod = _this$
|
|
363
|
+
var _this$asProps5 = this.asProps,
|
|
364
|
+
locale = _this$asProps5.locale,
|
|
365
|
+
displayedPeriod = _this$asProps5.displayedPeriod;
|
|
291
366
|
return {
|
|
292
367
|
children: new Intl.DateTimeFormat(locale, {
|
|
293
368
|
month: 'long',
|
|
@@ -300,14 +375,14 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
300
375
|
value: function getTriggerProps(_ref10) {
|
|
301
376
|
var _this$asProps$value3,
|
|
302
377
|
_this$asProps$value4,
|
|
303
|
-
|
|
378
|
+
_this5 = this;
|
|
304
379
|
var _ref10$placeholder = _ref10.placeholder,
|
|
305
380
|
placeholder = _ref10$placeholder === void 0 ? 'Select date ranges' : _ref10$placeholder,
|
|
306
381
|
_ref10$separator = _ref10.separator,
|
|
307
382
|
separator = _ref10$separator === void 0 ? 'vs.' : _ref10$separator;
|
|
308
|
-
var _this$
|
|
309
|
-
locale = _this$
|
|
310
|
-
visible = _this$
|
|
383
|
+
var _this$asProps6 = this.asProps,
|
|
384
|
+
locale = _this$asProps6.locale,
|
|
385
|
+
visible = _this$asProps6.visible;
|
|
311
386
|
var value = (_this$asProps$value3 = this.asProps.value) === null || _this$asProps$value3 === void 0 ? void 0 : _this$asProps$value3.value;
|
|
312
387
|
var compare = (_this$asProps$value4 = this.asProps.value) === null || _this$asProps$value4 === void 0 ? void 0 : _this$asProps$value4.compare;
|
|
313
388
|
var formattingProps = {
|
|
@@ -327,9 +402,9 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
327
402
|
children: children,
|
|
328
403
|
visible: visible,
|
|
329
404
|
onClick: function onClick() {
|
|
330
|
-
return
|
|
405
|
+
return _this5.handlers.visible(!visible);
|
|
331
406
|
},
|
|
332
|
-
onKeyDown: this.
|
|
407
|
+
onKeyDown: this.handleKeydownDown('trigger')
|
|
333
408
|
};
|
|
334
409
|
}
|
|
335
410
|
}, {
|
|
@@ -340,21 +415,21 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
340
415
|
}, {
|
|
341
416
|
key: "getValueDateRangeProps",
|
|
342
417
|
value: function getValueDateRangeProps() {
|
|
343
|
-
var
|
|
344
|
-
var _this$
|
|
345
|
-
value = _this$
|
|
346
|
-
onDisplayedPeriodChange = _this$
|
|
347
|
-
locale = _this$
|
|
348
|
-
disabled = _this$
|
|
349
|
-
size = _this$
|
|
350
|
-
getI18nText = _this$
|
|
351
|
-
focusedRange = _this$
|
|
352
|
-
preselectedValue = _this$
|
|
418
|
+
var _this6 = this;
|
|
419
|
+
var _this$asProps7 = this.asProps,
|
|
420
|
+
value = _this$asProps7.value,
|
|
421
|
+
onDisplayedPeriodChange = _this$asProps7.onDisplayedPeriodChange,
|
|
422
|
+
locale = _this$asProps7.locale,
|
|
423
|
+
disabled = _this$asProps7.disabled,
|
|
424
|
+
size = _this$asProps7.size,
|
|
425
|
+
getI18nText = _this$asProps7.getI18nText,
|
|
426
|
+
focusedRange = _this$asProps7.focusedRange,
|
|
427
|
+
preselectedValue = _this$asProps7.preselectedValue;
|
|
353
428
|
return {
|
|
354
429
|
focused: focusedRange === 'value' ? true : undefined,
|
|
355
430
|
value: preselectedValue !== null && preselectedValue !== void 0 ? preselectedValue : value === null || value === void 0 ? void 0 : value.value,
|
|
356
431
|
onChange: function onChange(value) {
|
|
357
|
-
return
|
|
432
|
+
return _this6.handlers.preselectedValue(value);
|
|
358
433
|
},
|
|
359
434
|
onDisplayedPeriodChange: onDisplayedPeriodChange,
|
|
360
435
|
locale: locale,
|
|
@@ -363,7 +438,7 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
363
438
|
children: this.getRangeInput(),
|
|
364
439
|
getI18nText: getI18nText,
|
|
365
440
|
onFocus: function onFocus() {
|
|
366
|
-
|
|
441
|
+
_this6.handlers.focusedRange('value');
|
|
367
442
|
return false;
|
|
368
443
|
}
|
|
369
444
|
};
|
|
@@ -372,23 +447,23 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
372
447
|
key: "getCompareDateRangeProps",
|
|
373
448
|
value: function getCompareDateRangeProps() {
|
|
374
449
|
var _value$compare,
|
|
375
|
-
|
|
376
|
-
var _this$
|
|
377
|
-
value = _this$
|
|
378
|
-
onDisplayedPeriodChange = _this$
|
|
379
|
-
locale = _this$
|
|
380
|
-
disabled = _this$
|
|
381
|
-
size = _this$
|
|
382
|
-
getI18nText = _this$
|
|
383
|
-
focusedRange = _this$
|
|
384
|
-
preselectedCompare = _this$
|
|
385
|
-
compareToggle = _this$
|
|
450
|
+
_this7 = this;
|
|
451
|
+
var _this$asProps8 = this.asProps,
|
|
452
|
+
value = _this$asProps8.value,
|
|
453
|
+
onDisplayedPeriodChange = _this$asProps8.onDisplayedPeriodChange,
|
|
454
|
+
locale = _this$asProps8.locale,
|
|
455
|
+
disabled = _this$asProps8.disabled,
|
|
456
|
+
size = _this$asProps8.size,
|
|
457
|
+
getI18nText = _this$asProps8.getI18nText,
|
|
458
|
+
focusedRange = _this$asProps8.focusedRange,
|
|
459
|
+
preselectedCompare = _this$asProps8.preselectedCompare,
|
|
460
|
+
compareToggle = _this$asProps8.compareToggle;
|
|
386
461
|
return {
|
|
387
462
|
focused: focusedRange === 'compare' ? true : undefined,
|
|
388
463
|
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),
|
|
389
464
|
value: preselectedCompare !== null && preselectedCompare !== void 0 ? preselectedCompare : value === null || value === void 0 ? void 0 : value.compare,
|
|
390
465
|
onChange: function onChange(value) {
|
|
391
|
-
return
|
|
466
|
+
return _this7.handlers.preselectedCompare(value);
|
|
392
467
|
},
|
|
393
468
|
onDisplayedPeriodChange: onDisplayedPeriodChange,
|
|
394
469
|
locale: locale,
|
|
@@ -397,7 +472,7 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
397
472
|
children: this.getRangeInput(),
|
|
398
473
|
getI18nText: getI18nText,
|
|
399
474
|
onFocus: function onFocus() {
|
|
400
|
-
|
|
475
|
+
_this7.handlers.focusedRange('compare');
|
|
401
476
|
return false;
|
|
402
477
|
}
|
|
403
478
|
};
|
|
@@ -406,21 +481,21 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
406
481
|
key: "getCompareToggleProps",
|
|
407
482
|
value: function getCompareToggleProps() {
|
|
408
483
|
var _value$compare2,
|
|
409
|
-
|
|
410
|
-
var _this$
|
|
411
|
-
getI18nText = _this$
|
|
412
|
-
value = _this$
|
|
413
|
-
compareToggle = _this$
|
|
484
|
+
_this8 = this;
|
|
485
|
+
var _this$asProps9 = this.asProps,
|
|
486
|
+
getI18nText = _this$asProps9.getI18nText,
|
|
487
|
+
value = _this$asProps9.value,
|
|
488
|
+
compareToggle = _this$asProps9.compareToggle;
|
|
414
489
|
return {
|
|
415
490
|
getI18nText: getI18nText,
|
|
416
491
|
checked: compareToggle !== null && compareToggle !== void 0 ? compareToggle : value === null || value === void 0 ? void 0 : (_value$compare2 = value.compare) === null || _value$compare2 === void 0 ? void 0 : _value$compare2.length,
|
|
417
492
|
onChange: function onChange(checked) {
|
|
418
493
|
if (checked) {
|
|
419
|
-
|
|
420
|
-
|
|
494
|
+
_this8.handlers.compareToggle(true);
|
|
495
|
+
_this8.handlers.focusedRange('compare');
|
|
421
496
|
} else {
|
|
422
|
-
|
|
423
|
-
|
|
497
|
+
_this8.handlers.compareToggle(false);
|
|
498
|
+
_this8.handlers.focusedRange('value');
|
|
424
499
|
}
|
|
425
500
|
}
|
|
426
501
|
};
|
|
@@ -428,18 +503,19 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
428
503
|
}, {
|
|
429
504
|
key: "getCalendarProps",
|
|
430
505
|
value: function getCalendarProps(_props, index) {
|
|
431
|
-
var _this$
|
|
432
|
-
locale = _this$
|
|
433
|
-
displayedPeriod = _this$
|
|
434
|
-
disabled = _this$
|
|
435
|
-
value = _this$
|
|
436
|
-
onCompareHighlightedChange = _this$
|
|
437
|
-
highlighted = _this$
|
|
438
|
-
compareHighlighted = _this$
|
|
439
|
-
onHighlightedChange = _this$
|
|
440
|
-
preselectedCompare = _this$
|
|
441
|
-
preselectedValue = _this$
|
|
442
|
-
focusedRange = _this$
|
|
506
|
+
var _this$asProps10 = this.asProps,
|
|
507
|
+
locale = _this$asProps10.locale,
|
|
508
|
+
displayedPeriod = _this$asProps10.displayedPeriod,
|
|
509
|
+
disabled = _this$asProps10.disabled,
|
|
510
|
+
value = _this$asProps10.value,
|
|
511
|
+
onCompareHighlightedChange = _this$asProps10.onCompareHighlightedChange,
|
|
512
|
+
highlighted = _this$asProps10.highlighted,
|
|
513
|
+
compareHighlighted = _this$asProps10.compareHighlighted,
|
|
514
|
+
onHighlightedChange = _this$asProps10.onHighlightedChange,
|
|
515
|
+
preselectedCompare = _this$asProps10.preselectedCompare,
|
|
516
|
+
preselectedValue = _this$asProps10.preselectedValue,
|
|
517
|
+
focusedRange = _this$asProps10.focusedRange,
|
|
518
|
+
getI18nText = _this$asProps10.getI18nText;
|
|
443
519
|
return {
|
|
444
520
|
locale: locale,
|
|
445
521
|
displayedPeriod: dayjs(displayedPeriod).add(index, this.navigateStep).startOf(this.navigateStep).toDate(),
|
|
@@ -451,7 +527,10 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
451
527
|
onHighlightedChange: onHighlightedChange,
|
|
452
528
|
range: focusedRange,
|
|
453
529
|
value: preselectedValue !== null && preselectedValue !== void 0 ? preselectedValue : value === null || value === void 0 ? void 0 : value.value,
|
|
454
|
-
compare: preselectedCompare !== null && preselectedCompare !== void 0 ? preselectedCompare : value === null || value === void 0 ? void 0 : value.compare
|
|
530
|
+
compare: preselectedCompare !== null && preselectedCompare !== void 0 ? preselectedCompare : value === null || value === void 0 ? void 0 : value.compare,
|
|
531
|
+
unitRefs: this.unitRefs,
|
|
532
|
+
getI18nText: getI18nText,
|
|
533
|
+
actionsDescribing: index === 0 ? 'range-compare' : null
|
|
455
534
|
};
|
|
456
535
|
}
|
|
457
536
|
}, {
|
|
@@ -459,7 +538,8 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
459
538
|
value: function getPopperProps() {
|
|
460
539
|
return {
|
|
461
540
|
p: 0,
|
|
462
|
-
ref: this.popperRef
|
|
541
|
+
ref: this.popperRef,
|
|
542
|
+
onKeyDown: this.handleKeydownDown('popper')
|
|
463
543
|
};
|
|
464
544
|
}
|
|
465
545
|
}, {
|
|
@@ -467,10 +547,10 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
467
547
|
value: function render() {
|
|
468
548
|
var _ref = this.asProps,
|
|
469
549
|
_ref4;
|
|
470
|
-
var _this$
|
|
471
|
-
Children = _this$
|
|
472
|
-
styles = _this$
|
|
473
|
-
providedAriaLabel = _this$
|
|
550
|
+
var _this$asProps11 = this.asProps,
|
|
551
|
+
Children = _this$asProps11.Children,
|
|
552
|
+
styles = _this$asProps11.styles,
|
|
553
|
+
providedAriaLabel = _this$asProps11['aria-label'];
|
|
474
554
|
return /*#__PURE__*/React.createElement(React.Fragment, null, (_ref4 = sstyled(styles), /*#__PURE__*/React.createElement(Dropdown, _assignProps({
|
|
475
555
|
"use:aria-label": providedAriaLabel,
|
|
476
556
|
"__excludeProps": ['onChange', 'value']
|
|
@@ -505,6 +585,9 @@ var DateRangeComparatorAbstract = /*#__PURE__*/function (_Component) {
|
|
|
505
585
|
_defineProperty(DateRangeComparatorAbstract, "displayName", 'DateRangeComparator');
|
|
506
586
|
_defineProperty(DateRangeComparatorAbstract, "style", style);
|
|
507
587
|
_defineProperty(DateRangeComparatorAbstract, "enhance", [i18nEnhance(localizedMessages)]);
|
|
588
|
+
_defineProperty(DateRangeComparatorAbstract, "subtract", function (date, amount, unit) {
|
|
589
|
+
return dayjs(date).subtract(amount, unit).toDate();
|
|
590
|
+
});
|
|
508
591
|
function Apply(props) {
|
|
509
592
|
var _ref2 = arguments[0];
|
|
510
593
|
var getI18nText = props.getI18nText;
|