@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,191 +1,185 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import _callSuper from "@babel/runtime/helpers/esm/callSuper";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
2
|
+
import { assignProps, Component, CORE_INSTANCE, sstyled } from "@semcore/core";
|
|
3
|
+
import { Flex, Box } from "@semcore/base-components";
|
|
8
4
|
import Button from "@semcore/button";
|
|
9
5
|
import i18nEnhance from "@semcore/core/lib/utils/enhances/i18nEnhance";
|
|
10
6
|
import Divider from "@semcore/divider";
|
|
11
7
|
import Dropdown from "@semcore/dropdown";
|
|
12
|
-
import { Flex, Box } from "@semcore/flex-box";
|
|
13
8
|
import dayjs from "dayjs";
|
|
14
9
|
import React from "react";
|
|
15
10
|
import { localizedMessages } from "../translations/__intergalactic-dynamic-locales.mjs";
|
|
16
11
|
import { formatMMYY, formatDDMMYY } from "../utils/formatDate.mjs";
|
|
17
12
|
import { includesDate } from "../utils/includesDate.mjs";
|
|
18
13
|
/*!__reshadow-styles__:"../style/date-picker.shadow.css"*/
|
|
19
|
-
|
|
14
|
+
const style = (
|
|
20
15
|
/*__reshadow_css_start__*/
|
|
21
16
|
(sstyled.insert(
|
|
22
17
|
/*__inner_css_start__*/
|
|
23
|
-
".
|
|
18
|
+
".___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}}",
|
|
24
19
|
/*__inner_css_end__*/
|
|
25
|
-
"
|
|
20
|
+
"9ubmf_gg_"
|
|
26
21
|
), /*__reshadow_css_end__*/
|
|
27
22
|
{
|
|
28
|
-
"__SHeader": "
|
|
29
|
-
"__STitle": "
|
|
30
|
-
"__SToday": "
|
|
31
|
-
"__SPeriod": "
|
|
32
|
-
"__SButton": "
|
|
33
|
-
"__SInner": "
|
|
34
|
-
"__SInputMask": "
|
|
35
|
-
"_animationsDisabled": "
|
|
36
|
-
"__SIndicator": "
|
|
37
|
-
"__SRangeIndicator": "
|
|
38
|
-
"_range_value": "
|
|
39
|
-
"_range_compare": "
|
|
40
|
-
"_disabled": "
|
|
41
|
-
"__SHumanizedDate": "
|
|
42
|
-
"__SMask": "
|
|
43
|
-
"__SSingleDateInput": "
|
|
44
|
-
"__SValue": "
|
|
45
|
-
"__SDateRange": "
|
|
46
|
-
"_noHumanizedDate": "
|
|
47
|
-
"__SRangeSep": "
|
|
48
|
-
"_fulfilled": "
|
|
49
|
-
"__SRangeComparatorHeader": "
|
|
50
|
-
"__SRangeCalendar": "
|
|
51
|
-
"__SFooter": "
|
|
52
|
-
"__SPeriodsList": "
|
|
53
|
-
"__STooltip": "
|
|
54
|
-
"__SCompareToggle": "
|
|
55
|
-
"__SPopper": "
|
|
23
|
+
"__SHeader": "___SHeader_9ubmf_gg_",
|
|
24
|
+
"__STitle": "___STitle_9ubmf_gg_",
|
|
25
|
+
"__SToday": "___SToday_9ubmf_gg_",
|
|
26
|
+
"__SPeriod": "___SPeriod_9ubmf_gg_",
|
|
27
|
+
"__SButton": "___SButton_9ubmf_gg_",
|
|
28
|
+
"__SInner": "___SInner_9ubmf_gg_",
|
|
29
|
+
"__SInputMask": "___SInputMask_9ubmf_gg_",
|
|
30
|
+
"_animationsDisabled": "__animationsDisabled_9ubmf_gg_",
|
|
31
|
+
"__SIndicator": "___SIndicator_9ubmf_gg_",
|
|
32
|
+
"__SRangeIndicator": "___SRangeIndicator_9ubmf_gg_",
|
|
33
|
+
"_range_value": "_range_value_9ubmf_gg_",
|
|
34
|
+
"_range_compare": "_range_compare_9ubmf_gg_",
|
|
35
|
+
"_disabled": "__disabled_9ubmf_gg_",
|
|
36
|
+
"__SHumanizedDate": "___SHumanizedDate_9ubmf_gg_",
|
|
37
|
+
"__SMask": "___SMask_9ubmf_gg_",
|
|
38
|
+
"__SSingleDateInput": "___SSingleDateInput_9ubmf_gg_",
|
|
39
|
+
"__SValue": "___SValue_9ubmf_gg_",
|
|
40
|
+
"__SDateRange": "___SDateRange_9ubmf_gg_",
|
|
41
|
+
"_noHumanizedDate": "__noHumanizedDate_9ubmf_gg_",
|
|
42
|
+
"__SRangeSep": "___SRangeSep_9ubmf_gg_",
|
|
43
|
+
"_fulfilled": "__fulfilled_9ubmf_gg_",
|
|
44
|
+
"__SRangeComparatorHeader": "___SRangeComparatorHeader_9ubmf_gg_",
|
|
45
|
+
"__SRangeCalendar": "___SRangeCalendar_9ubmf_gg_",
|
|
46
|
+
"__SFooter": "___SFooter_9ubmf_gg_",
|
|
47
|
+
"__SPeriodsList": "___SPeriodsList_9ubmf_gg_",
|
|
48
|
+
"__STooltip": "___STooltip_9ubmf_gg_",
|
|
49
|
+
"__SCompareToggle": "___SCompareToggle_9ubmf_gg_",
|
|
50
|
+
"__SPopper": "___SPopper_9ubmf_gg_"
|
|
56
51
|
})
|
|
57
52
|
);
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
53
|
+
const INTERACTION_TAGS = ["INPUT"];
|
|
54
|
+
const INTERACTION_KEYS = ["ArrowDown", "Enter", " "];
|
|
55
|
+
const defaultDisplayedPeriod = new Date((/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0));
|
|
61
56
|
function getEndDate(value) {
|
|
62
57
|
if (!Array.isArray(value)) return null;
|
|
63
|
-
|
|
58
|
+
const [startDate, endDate = startDate] = value;
|
|
64
59
|
return endDate;
|
|
65
60
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
_defineProperty(
|
|
75
|
-
_defineProperty(
|
|
76
|
-
_defineProperty(
|
|
77
|
-
_defineProperty(
|
|
78
|
-
_defineProperty(
|
|
79
|
-
_defineProperty(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
var action = direction >= 1 ? "add" : "subtract";
|
|
87
|
-
var date = dayjs(displayedPeriod)[action](1, _this.navigateStep).toDate();
|
|
88
|
-
_this.handlers.displayedPeriod(date);
|
|
61
|
+
class RangePickerAbstract extends Component {
|
|
62
|
+
constructor(...args) {
|
|
63
|
+
super(...args);
|
|
64
|
+
_defineProperty(this, "applyButtonRef", /* @__PURE__ */ React.createRef());
|
|
65
|
+
_defineProperty(this, "resetButtonRef", /* @__PURE__ */ React.createRef());
|
|
66
|
+
_defineProperty(this, "prevButtonRef", /* @__PURE__ */ React.createRef());
|
|
67
|
+
_defineProperty(this, "nextButtonRef", /* @__PURE__ */ React.createRef());
|
|
68
|
+
_defineProperty(this, "popperRef", /* @__PURE__ */ React.createRef());
|
|
69
|
+
_defineProperty(this, "periodRefs", []);
|
|
70
|
+
_defineProperty(this, "unitRefs", {});
|
|
71
|
+
_defineProperty(this, "navigateStep", void 0);
|
|
72
|
+
_defineProperty(this, "keyDiff", void 0);
|
|
73
|
+
_defineProperty(this, "keyStep", void 0);
|
|
74
|
+
_defineProperty(this, "navigateView", (direction) => {
|
|
75
|
+
const {
|
|
76
|
+
displayedPeriod
|
|
77
|
+
} = this.asProps;
|
|
78
|
+
const action = direction >= 1 ? "add" : "subtract";
|
|
79
|
+
const date = dayjs(displayedPeriod)[action](1, this.navigateStep).toDate();
|
|
80
|
+
this.handlers.displayedPeriod(date);
|
|
89
81
|
});
|
|
90
|
-
_defineProperty(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
var setNextDisplayedPeriod = function setNextDisplayedPeriod2(next_highlighted2) {
|
|
112
|
-
var _next_highlighted = _slicedToArray(next_highlighted2, 2), startPeriod = _next_highlighted[0], endPeriod = _next_highlighted[1];
|
|
113
|
-
var highlightedPeriod = endPeriod || startPeriod;
|
|
114
|
-
var displayedPeriodNormalized = displayedPeriod === null || displayedPeriod === void 0 ? void 0 : displayedPeriod.getDate();
|
|
115
|
-
var highlightedPeriodNormalized = highlightedPeriod === null || highlightedPeriod === void 0 ? void 0 : highlightedPeriod.getDate();
|
|
116
|
-
if (_this.navigateStep === "month") {
|
|
117
|
-
displayedPeriodNormalized = displayedPeriod === null || displayedPeriod === void 0 ? void 0 : displayedPeriod.getMonth();
|
|
118
|
-
highlightedPeriodNormalized = highlightedPeriod === null || highlightedPeriod === void 0 ? void 0 : highlightedPeriod.getMonth();
|
|
119
|
-
}
|
|
120
|
-
if (_this.navigateStep === "year") {
|
|
121
|
-
displayedPeriodNormalized = displayedPeriod === null || displayedPeriod === void 0 ? void 0 : displayedPeriod.getYear();
|
|
122
|
-
highlightedPeriodNormalized = highlightedPeriod === null || highlightedPeriod === void 0 ? void 0 : highlightedPeriod.getYear();
|
|
123
|
-
}
|
|
124
|
-
var offset = highlightedPeriodNormalized - displayedPeriodNormalized;
|
|
125
|
-
if (offset < 0 || offset > 1) {
|
|
126
|
-
return highlightedPeriod;
|
|
82
|
+
_defineProperty(this, "bindHandlerNavigateClick", (direction) => () => this.navigateView(direction));
|
|
83
|
+
_defineProperty(this, "handlerKeyDown", (place) => (e) => {
|
|
84
|
+
var _a;
|
|
85
|
+
const {
|
|
86
|
+
displayedPeriod,
|
|
87
|
+
highlighted,
|
|
88
|
+
preselectedValue,
|
|
89
|
+
visible
|
|
90
|
+
} = this.asProps;
|
|
91
|
+
const {
|
|
92
|
+
key,
|
|
93
|
+
target
|
|
94
|
+
} = e;
|
|
95
|
+
if ([" ", "Enter"].includes(key) && [this.prevButtonRef.current, this.nextButtonRef.current].includes(target)) return;
|
|
96
|
+
if (place === "trigger" && INTERACTION_KEYS.includes(key)) {
|
|
97
|
+
e.stopPropagation();
|
|
98
|
+
this.handlers.visible(!visible);
|
|
99
|
+
setTimeout(() => {
|
|
100
|
+
const popper = this.popperRef.current;
|
|
101
|
+
if (popper) {
|
|
102
|
+
popper.focus();
|
|
127
103
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
104
|
+
}, 0);
|
|
105
|
+
}
|
|
106
|
+
const day = this.keyDiff[key];
|
|
107
|
+
const setNextDisplayedPeriod = (next_highlighted) => {
|
|
108
|
+
const [startPeriod, endPeriod] = next_highlighted;
|
|
109
|
+
const highlightedPeriod = endPeriod || startPeriod;
|
|
110
|
+
let displayedPeriodNormalized = displayedPeriod == null ? void 0 : displayedPeriod.getDate();
|
|
111
|
+
let highlightedPeriodNormalized = highlightedPeriod == null ? void 0 : highlightedPeriod.getDate();
|
|
112
|
+
if (this.navigateStep === "month") {
|
|
113
|
+
displayedPeriodNormalized = displayedPeriod == null ? void 0 : displayedPeriod.getMonth();
|
|
114
|
+
highlightedPeriodNormalized = highlightedPeriod == null ? void 0 : highlightedPeriod.getMonth();
|
|
132
115
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
var highlightedDate = highlighted[1] || highlighted[0];
|
|
141
|
-
if (!_this.isDisabled(highlightedDate)) {
|
|
142
|
-
_this.handleChange(highlightedDate);
|
|
143
|
-
}
|
|
144
|
-
e.preventDefault();
|
|
116
|
+
if (this.navigateStep === "year") {
|
|
117
|
+
displayedPeriodNormalized = displayedPeriod == null ? void 0 : displayedPeriod.getYear();
|
|
118
|
+
highlightedPeriodNormalized = highlightedPeriod == null ? void 0 : highlightedPeriod.getYear();
|
|
119
|
+
}
|
|
120
|
+
const offset = highlightedPeriodNormalized - displayedPeriodNormalized;
|
|
121
|
+
if (offset < 0 || offset > 1) {
|
|
122
|
+
return highlightedPeriod;
|
|
145
123
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
124
|
+
return displayedPeriod;
|
|
125
|
+
};
|
|
126
|
+
if (place === "popper" && e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
|
|
127
|
+
return this.handleApplyClick();
|
|
128
|
+
}
|
|
129
|
+
const isPeriodTarget = this.periodRefs.find((el) => el === target);
|
|
130
|
+
const isResetButtonTarget = target === this.resetButtonRef.current;
|
|
131
|
+
const isApplyButtonTarget = target === this.applyButtonRef.current;
|
|
132
|
+
const areTargetedControls = isPeriodTarget || isResetButtonTarget || isApplyButtonTarget;
|
|
133
|
+
if (place === "popper" && e.key === " " && highlighted.length && !areTargetedControls) {
|
|
134
|
+
const highlightedDate = highlighted[1] || highlighted[0];
|
|
135
|
+
if (!this.isDisabled(highlightedDate)) {
|
|
136
|
+
this.handleChange(highlightedDate);
|
|
137
|
+
}
|
|
138
|
+
e.preventDefault();
|
|
139
|
+
}
|
|
140
|
+
let changedDate = void 0;
|
|
141
|
+
if (day) {
|
|
142
|
+
if (INTERACTION_TAGS.includes(e.target.tagName)) return;
|
|
143
|
+
if (highlighted.length) {
|
|
144
|
+
let next_highlighted;
|
|
145
|
+
if (preselectedValue.length === 1) {
|
|
146
|
+
next_highlighted = [preselectedValue[0], dayjs(highlighted[1] || highlighted[0]).add(day, this.keyStep).toDate()];
|
|
147
|
+
changedDate = next_highlighted[1];
|
|
160
148
|
} else {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
changedDate = _highlighted[0];
|
|
164
|
-
}
|
|
165
|
-
e.preventDefault();
|
|
166
|
-
if (changedDate) {
|
|
167
|
-
var _this$unitRefs$format;
|
|
168
|
-
var formatter = _this.keyStep === "month" ? formatMMYY : formatDDMMYY;
|
|
169
|
-
var formattedDate = formatter(changedDate, _this.asProps.locale);
|
|
170
|
-
(_this$unitRefs$format = _this.unitRefs[formattedDate]) === null || _this$unitRefs$format === void 0 || _this$unitRefs$format.focus();
|
|
149
|
+
next_highlighted = [dayjs(highlighted[0]).add(day, this.keyStep).toDate()];
|
|
150
|
+
changedDate = next_highlighted[0];
|
|
171
151
|
}
|
|
152
|
+
this.handlers.highlighted(next_highlighted);
|
|
153
|
+
this.handlers.displayedPeriod(setNextDisplayedPeriod(next_highlighted));
|
|
154
|
+
} else {
|
|
155
|
+
const highlighted2 = [displayedPeriod ? displayedPeriod : dayjs().toDate()];
|
|
156
|
+
this.handlers.highlighted(highlighted2);
|
|
157
|
+
changedDate = highlighted2[0];
|
|
172
158
|
}
|
|
173
|
-
|
|
159
|
+
e.preventDefault();
|
|
160
|
+
if (changedDate) {
|
|
161
|
+
const formatter = this.keyStep === "month" ? formatMMYY : formatDDMMYY;
|
|
162
|
+
const formattedDate = formatter(changedDate, this.asProps.locale);
|
|
163
|
+
(_a = this.unitRefs[formattedDate]) == null ? void 0 : _a.focus();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
174
166
|
});
|
|
175
|
-
_defineProperty(
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
167
|
+
_defineProperty(this, "handleReset", () => {
|
|
168
|
+
this.handleChange([]);
|
|
169
|
+
this.handlers.value([]);
|
|
170
|
+
this.handlers.visible(false);
|
|
179
171
|
});
|
|
180
|
-
_defineProperty(
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
172
|
+
_defineProperty(this, "handleApply", (value) => {
|
|
173
|
+
const [startDate, endDate = startDate] = value;
|
|
174
|
+
this.handleChange([]);
|
|
175
|
+
this.handlers.value([startDate, endDate]);
|
|
176
|
+
this.handlers.visible(false);
|
|
185
177
|
});
|
|
186
|
-
_defineProperty(
|
|
187
|
-
|
|
188
|
-
|
|
178
|
+
_defineProperty(this, "handleChange", (date) => {
|
|
179
|
+
let {
|
|
180
|
+
preselectedValue
|
|
181
|
+
} = this.asProps;
|
|
182
|
+
let highlighted = [];
|
|
189
183
|
if (Array.isArray(date)) {
|
|
190
184
|
preselectedValue = date;
|
|
191
185
|
} else if (!preselectedValue.length) {
|
|
@@ -199,248 +193,268 @@ var RangePickerAbstract = /* @__PURE__ */ (function(_Component) {
|
|
|
199
193
|
} else {
|
|
200
194
|
preselectedValue = [preselectedValue[0], date];
|
|
201
195
|
}
|
|
202
|
-
|
|
203
|
-
|
|
196
|
+
this.handlers.preselectedValue(preselectedValue);
|
|
197
|
+
this.handlers.highlighted(highlighted);
|
|
204
198
|
});
|
|
205
|
-
_defineProperty(
|
|
206
|
-
|
|
207
|
-
|
|
199
|
+
_defineProperty(this, "handleApplyClick", () => {
|
|
200
|
+
const {
|
|
201
|
+
value,
|
|
202
|
+
preselectedValue
|
|
203
|
+
} = this.asProps;
|
|
204
|
+
return this.handleApply(preselectedValue.length ? preselectedValue : value);
|
|
208
205
|
});
|
|
209
|
-
return _this;
|
|
210
206
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
207
|
+
static defaultProps({
|
|
208
|
+
value,
|
|
209
|
+
defaultValue
|
|
210
|
+
}) {
|
|
211
|
+
return {
|
|
212
|
+
i18n: localizedMessages,
|
|
213
|
+
locale: "en",
|
|
214
|
+
defaultDisplayedPeriod: getEndDate(value) || getEndDate(defaultValue) || defaultDisplayedPeriod,
|
|
215
|
+
defaultValue: [],
|
|
216
|
+
defaultHighlighted: [],
|
|
217
|
+
defaultVisible: false,
|
|
218
|
+
defaultPreselectedValue: [],
|
|
219
|
+
disabled: [],
|
|
220
|
+
size: "m"
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
uncontrolledProps() {
|
|
224
|
+
return {
|
|
225
|
+
displayedPeriod: null,
|
|
226
|
+
visible: [null, (visible) => {
|
|
227
|
+
const {
|
|
228
|
+
value,
|
|
229
|
+
displayedPeriod
|
|
230
|
+
} = this.asProps;
|
|
231
|
+
const endDate = getEndDate(value ?? void 0);
|
|
232
|
+
if (!visible) {
|
|
233
|
+
this.handlers.highlighted([]);
|
|
234
|
+
this.handlers.preselectedValue([]);
|
|
235
|
+
}
|
|
236
|
+
if (visible) {
|
|
237
|
+
if (endDate && endDate !== displayedPeriod) {
|
|
238
|
+
this.handlers.displayedPeriod(endDate);
|
|
239
|
+
} else if (!endDate) {
|
|
240
|
+
const {
|
|
241
|
+
displayedPeriod: displayedPeriod2,
|
|
242
|
+
defaultDisplayedPeriod: defaultDisplayedPeriod2
|
|
243
|
+
} = this.props;
|
|
244
|
+
this.handlers.displayedPeriod(displayedPeriod2 || defaultDisplayedPeriod2);
|
|
240
245
|
}
|
|
241
|
-
}]
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
}, {
|
|
245
|
-
key: "isDisabled",
|
|
246
|
-
value: function isDisabled(date) {
|
|
247
|
-
var disabled = this.asProps.disabled;
|
|
248
|
-
return disabled.some(includesDate(dayjs(date), "date"));
|
|
249
|
-
}
|
|
250
|
-
}, {
|
|
251
|
-
key: "getDefaultPeriods",
|
|
252
|
-
value: function getDefaultPeriods() {
|
|
253
|
-
return [];
|
|
254
|
-
}
|
|
255
|
-
}, {
|
|
256
|
-
key: "getButtonTriggerProps",
|
|
257
|
-
value: function getButtonTriggerProps() {
|
|
258
|
-
var _this$asProps3 = this.asProps, value = _this$asProps3.value, size = _this$asProps3.size, visible = _this$asProps3.visible;
|
|
259
|
-
return {
|
|
260
|
-
popoverVisible: visible,
|
|
261
|
-
size,
|
|
262
|
-
empty: !value[0] && !value[1],
|
|
263
|
-
onKeyDown: this.handlerKeyDown("trigger")
|
|
264
|
-
};
|
|
265
|
-
}
|
|
266
|
-
}, {
|
|
267
|
-
key: "getPopperProps",
|
|
268
|
-
value: function getPopperProps() {
|
|
269
|
-
var Picker = this[CORE_INSTANCE];
|
|
270
|
-
var _this$asProps4 = this.asProps, _this$asProps4$period = _this$asProps4.periods, periods = _this$asProps4$period === void 0 ? this.getDefaultPeriods() : _this$asProps4$period, unclearable = _this$asProps4.unclearable;
|
|
271
|
-
var buttons = /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Picker.Apply, null), !unclearable && /* @__PURE__ */ React.createElement(Picker.Reset, {
|
|
272
|
-
ml: 2
|
|
273
|
-
}));
|
|
274
|
-
return {
|
|
275
|
-
tabIndex: 0,
|
|
276
|
-
ref: this.popperRef,
|
|
277
|
-
onKeyDown: this.handlerKeyDown("popper"),
|
|
278
|
-
children: /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Flex, null, /* @__PURE__ */ React.createElement(Flex, null, /* @__PURE__ */ React.createElement(Box, {
|
|
279
|
-
mr: 2
|
|
280
|
-
}, /* @__PURE__ */ React.createElement(Picker.Header, null, /* @__PURE__ */ React.createElement(Picker.Prev, null), /* @__PURE__ */ React.createElement(Picker.Title, null)), /* @__PURE__ */ React.createElement(Picker.Calendar, null)), /* @__PURE__ */ React.createElement(Box, {
|
|
281
|
-
ml: 2
|
|
282
|
-
}, /* @__PURE__ */ React.createElement(Picker.Header, null, /* @__PURE__ */ React.createElement(Picker.Title, {
|
|
283
|
-
"aria-live": void 0
|
|
284
|
-
}), /* @__PURE__ */ React.createElement(Picker.Next, null)), /* @__PURE__ */ React.createElement(Picker.Calendar, null))), periods.length > 0 && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Divider, {
|
|
285
|
-
m: "-16px 16px",
|
|
286
|
-
orientation: "vertical",
|
|
287
|
-
h: "auto"
|
|
288
|
-
}), /* @__PURE__ */ React.createElement(Flex, {
|
|
289
|
-
direction: "column"
|
|
290
|
-
}, /* @__PURE__ */ React.createElement(Picker.Period, null), /* @__PURE__ */ React.createElement(Flex, {
|
|
291
|
-
mt: "auto"
|
|
292
|
-
}, buttons)))), periods.length === 0 && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Divider, {
|
|
293
|
-
m: "16px -16px",
|
|
294
|
-
orientation: "horizontal",
|
|
295
|
-
w: "auto"
|
|
296
|
-
}), /* @__PURE__ */ React.createElement(Flex, null, /* @__PURE__ */ React.createElement(Picker.Period, null), /* @__PURE__ */ React.createElement(Flex, {
|
|
297
|
-
mt: "auto"
|
|
298
|
-
}, buttons))))
|
|
299
|
-
};
|
|
300
|
-
}
|
|
301
|
-
}, {
|
|
302
|
-
key: "getHeaderProps",
|
|
303
|
-
value: function getHeaderProps() {
|
|
304
|
-
var Picker = this[CORE_INSTANCE];
|
|
305
|
-
return {
|
|
306
|
-
children: /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Picker.Prev, null), /* @__PURE__ */ React.createElement(Picker.Title, null), /* @__PURE__ */ React.createElement(Picker.Next, null))
|
|
307
|
-
};
|
|
308
|
-
}
|
|
309
|
-
}, {
|
|
310
|
-
key: "getTitleProps",
|
|
311
|
-
value: function getTitleProps(_props, index) {
|
|
312
|
-
var _this$asProps5 = this.asProps, locale = _this$asProps5.locale, displayedPeriod = _this$asProps5.displayedPeriod;
|
|
313
|
-
return {
|
|
314
|
-
children: new Intl.DateTimeFormat(locale, {
|
|
315
|
-
month: "long",
|
|
316
|
-
year: "numeric"
|
|
317
|
-
}).format(dayjs(displayedPeriod).add(index, this.navigateStep).startOf(this.navigateStep).toDate())
|
|
318
|
-
};
|
|
319
|
-
}
|
|
320
|
-
}, {
|
|
321
|
-
key: "getNextProps",
|
|
322
|
-
value: function getNextProps() {
|
|
323
|
-
var getI18nText = this.asProps.getI18nText;
|
|
324
|
-
var navigateStep = this.navigateStep;
|
|
325
|
-
return {
|
|
326
|
-
"ref": this.nextButtonRef,
|
|
327
|
-
"onClick": this.bindHandlerNavigateClick(1),
|
|
328
|
-
getI18nText,
|
|
329
|
-
"aria-label": navigateStep === "month" ? getI18nText("nextMonth") : getI18nText("nextYear")
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
}, {
|
|
333
|
-
key: "getPrevProps",
|
|
334
|
-
value: function getPrevProps() {
|
|
335
|
-
var getI18nText = this.asProps.getI18nText;
|
|
336
|
-
var navigateStep = this.navigateStep;
|
|
337
|
-
return {
|
|
338
|
-
"ref": this.prevButtonRef,
|
|
339
|
-
"onClick": this.bindHandlerNavigateClick(-1),
|
|
340
|
-
getI18nText,
|
|
341
|
-
"aria-label": navigateStep === "month" ? getI18nText("prevMonth") : getI18nText("prevYear")
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
}, {
|
|
345
|
-
key: "getCalendarProps",
|
|
346
|
-
value: function getCalendarProps(_props, index) {
|
|
347
|
-
var _this$asProps6 = this.asProps, locale = _this$asProps6.locale, displayedPeriod = _this$asProps6.displayedPeriod, disabled = _this$asProps6.disabled, value = _this$asProps6.value, highlighted = _this$asProps6.highlighted, onHighlightedChange = _this$asProps6.onHighlightedChange, onVisibleChange = _this$asProps6.onVisibleChange, preselectedValue = _this$asProps6.preselectedValue, getI18nText = _this$asProps6.getI18nText;
|
|
348
|
-
return {
|
|
349
|
-
locale,
|
|
350
|
-
displayedPeriod: dayjs(displayedPeriod).add(index, this.navigateStep).startOf(this.navigateStep).toDate(),
|
|
351
|
-
disabled,
|
|
352
|
-
highlighted,
|
|
353
|
-
onHighlightedChange,
|
|
354
|
-
onVisibleChange,
|
|
355
|
-
value: preselectedValue.length ? preselectedValue : value,
|
|
356
|
-
onChange: this.handleChange,
|
|
357
|
-
unitRefs: this.unitRefs,
|
|
358
|
-
getI18nText,
|
|
359
|
-
actionsDescribing: index === 0 ? "range" : null,
|
|
360
|
-
tabIndex: index === 0 ? 0 : -1
|
|
361
|
-
};
|
|
362
|
-
}
|
|
363
|
-
}, {
|
|
364
|
-
key: "getPeriodProps",
|
|
365
|
-
value: function getPeriodProps() {
|
|
366
|
-
var _this3 = this;
|
|
367
|
-
var _this$asProps7 = this.asProps, _this$asProps7$period = _this$asProps7.periods, periods = _this$asProps7$period === void 0 ? this.getDefaultPeriods() : _this$asProps7$period, value = _this$asProps7.value, onHighlightedChange = _this$asProps7.onHighlightedChange, onDisplayedPeriodChange = _this$asProps7.onDisplayedPeriodChange, preselectedValue = _this$asProps7.preselectedValue, getI18nText = _this$asProps7.getI18nText;
|
|
368
|
-
return {
|
|
369
|
-
periods,
|
|
370
|
-
"value": preselectedValue.length ? preselectedValue : value,
|
|
371
|
-
"onChange": this.handleApply,
|
|
372
|
-
onHighlightedChange,
|
|
373
|
-
onDisplayedPeriodChange,
|
|
374
|
-
"role": "listbox",
|
|
375
|
-
"aria-label": getI18nText("periods"),
|
|
376
|
-
"periodRef": function periodRef(index) {
|
|
377
|
-
return function(element) {
|
|
378
|
-
if (!element) return;
|
|
379
|
-
_this3.periodRefs[index] = element;
|
|
380
|
-
};
|
|
381
246
|
}
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
}
|
|
247
|
+
}],
|
|
248
|
+
highlighted: null,
|
|
249
|
+
preselectedValue: null,
|
|
250
|
+
value: [null, (value) => {
|
|
251
|
+
if (value[0] !== null || value[1] !== null) {
|
|
252
|
+
this.handlers.displayedPeriod(getEndDate([value[0] ?? void 0, value[1] ?? void 0]));
|
|
253
|
+
}
|
|
254
|
+
}]
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
isDisabled(date) {
|
|
258
|
+
const {
|
|
259
|
+
disabled
|
|
260
|
+
} = this.asProps;
|
|
261
|
+
return disabled.some(includesDate(dayjs(date), "date"));
|
|
262
|
+
}
|
|
263
|
+
getDefaultPeriods() {
|
|
264
|
+
return [];
|
|
265
|
+
}
|
|
266
|
+
getButtonTriggerProps() {
|
|
267
|
+
const {
|
|
268
|
+
value,
|
|
269
|
+
size,
|
|
270
|
+
visible
|
|
271
|
+
} = this.asProps;
|
|
272
|
+
return {
|
|
273
|
+
popoverVisible: visible,
|
|
274
|
+
size,
|
|
275
|
+
empty: !value[0] && !value[1],
|
|
276
|
+
onKeyDown: this.handlerKeyDown("trigger")
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
getPopperProps() {
|
|
280
|
+
const Picker = this[CORE_INSTANCE];
|
|
281
|
+
const {
|
|
282
|
+
periods = this.getDefaultPeriods(),
|
|
283
|
+
unclearable
|
|
284
|
+
} = this.asProps;
|
|
285
|
+
const buttons = /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Picker.Apply, null), !unclearable && /* @__PURE__ */ React.createElement(Picker.Reset, {
|
|
286
|
+
ml: 2
|
|
287
|
+
}));
|
|
288
|
+
return {
|
|
289
|
+
tabIndex: 0,
|
|
290
|
+
ref: this.popperRef,
|
|
291
|
+
onKeyDown: this.handlerKeyDown("popper"),
|
|
292
|
+
children: /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Flex, null, /* @__PURE__ */ React.createElement(Flex, null, /* @__PURE__ */ React.createElement(Box, {
|
|
293
|
+
mr: 2
|
|
294
|
+
}, /* @__PURE__ */ React.createElement(Picker.Header, null, /* @__PURE__ */ React.createElement(Picker.Prev, null), /* @__PURE__ */ React.createElement(Picker.Title, null)), /* @__PURE__ */ React.createElement(Picker.Calendar, null)), /* @__PURE__ */ React.createElement(Box, {
|
|
295
|
+
ml: 2
|
|
296
|
+
}, /* @__PURE__ */ React.createElement(Picker.Header, null, /* @__PURE__ */ React.createElement(Picker.Title, {
|
|
297
|
+
"aria-live": void 0
|
|
298
|
+
}), /* @__PURE__ */ React.createElement(Picker.Next, null)), /* @__PURE__ */ React.createElement(Picker.Calendar, null))), periods.length > 0 && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Divider, {
|
|
299
|
+
m: "-16px 16px",
|
|
300
|
+
orientation: "vertical",
|
|
301
|
+
h: "auto"
|
|
302
|
+
}), /* @__PURE__ */ React.createElement(Flex, {
|
|
303
|
+
direction: "column"
|
|
304
|
+
}, /* @__PURE__ */ React.createElement(Picker.Period, null), /* @__PURE__ */ React.createElement(Flex, {
|
|
305
|
+
mt: "auto"
|
|
306
|
+
}, buttons)))), periods.length === 0 && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Divider, {
|
|
307
|
+
m: "16px -16px",
|
|
308
|
+
orientation: "horizontal",
|
|
309
|
+
w: "auto"
|
|
310
|
+
}), /* @__PURE__ */ React.createElement(Flex, null, /* @__PURE__ */ React.createElement(Picker.Period, null), /* @__PURE__ */ React.createElement(Flex, {
|
|
311
|
+
mt: "auto"
|
|
312
|
+
}, buttons))))
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
getHeaderProps() {
|
|
316
|
+
const Picker = this[CORE_INSTANCE];
|
|
317
|
+
return {
|
|
318
|
+
children: /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Picker.Prev, null), /* @__PURE__ */ React.createElement(Picker.Title, null), /* @__PURE__ */ React.createElement(Picker.Next, null))
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
getTitleProps(_props, index) {
|
|
322
|
+
const {
|
|
323
|
+
locale,
|
|
324
|
+
displayedPeriod
|
|
325
|
+
} = this.asProps;
|
|
326
|
+
return {
|
|
327
|
+
children: new Intl.DateTimeFormat(locale, {
|
|
328
|
+
month: "long",
|
|
329
|
+
year: "numeric"
|
|
330
|
+
}).format(dayjs(displayedPeriod).add(index, this.navigateStep).startOf(this.navigateStep).toDate())
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
getNextProps() {
|
|
334
|
+
const {
|
|
335
|
+
getI18nText
|
|
336
|
+
} = this.asProps;
|
|
337
|
+
const {
|
|
338
|
+
navigateStep
|
|
339
|
+
} = this;
|
|
340
|
+
return {
|
|
341
|
+
"ref": this.nextButtonRef,
|
|
342
|
+
"onClick": this.bindHandlerNavigateClick(1),
|
|
343
|
+
getI18nText,
|
|
344
|
+
"aria-label": navigateStep === "month" ? getI18nText("nextMonth") : getI18nText("nextYear")
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
getPrevProps() {
|
|
348
|
+
const {
|
|
349
|
+
getI18nText
|
|
350
|
+
} = this.asProps;
|
|
351
|
+
const {
|
|
352
|
+
navigateStep
|
|
353
|
+
} = this;
|
|
354
|
+
return {
|
|
355
|
+
"ref": this.prevButtonRef,
|
|
356
|
+
"onClick": this.bindHandlerNavigateClick(-1),
|
|
357
|
+
getI18nText,
|
|
358
|
+
"aria-label": navigateStep === "month" ? getI18nText("prevMonth") : getI18nText("prevYear")
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
getCalendarProps(_props, index) {
|
|
362
|
+
const {
|
|
363
|
+
locale,
|
|
364
|
+
displayedPeriod,
|
|
365
|
+
disabled,
|
|
366
|
+
value,
|
|
367
|
+
highlighted,
|
|
368
|
+
onHighlightedChange,
|
|
369
|
+
onVisibleChange,
|
|
370
|
+
preselectedValue,
|
|
371
|
+
getI18nText
|
|
372
|
+
} = this.asProps;
|
|
373
|
+
return {
|
|
374
|
+
locale,
|
|
375
|
+
displayedPeriod: dayjs(displayedPeriod).add(index, this.navigateStep).startOf(this.navigateStep).toDate(),
|
|
376
|
+
disabled,
|
|
377
|
+
highlighted,
|
|
378
|
+
onHighlightedChange,
|
|
379
|
+
onVisibleChange,
|
|
380
|
+
value: preselectedValue.length ? preselectedValue : value,
|
|
381
|
+
onChange: this.handleChange,
|
|
382
|
+
unitRefs: this.unitRefs,
|
|
383
|
+
getI18nText,
|
|
384
|
+
actionsDescribing: index === 0 ? "range" : null,
|
|
385
|
+
tabIndex: index === 0 ? 0 : -1
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
getPeriodProps() {
|
|
389
|
+
const {
|
|
390
|
+
periods = this.getDefaultPeriods(),
|
|
391
|
+
value,
|
|
392
|
+
onHighlightedChange,
|
|
393
|
+
onDisplayedPeriodChange,
|
|
394
|
+
preselectedValue,
|
|
395
|
+
getI18nText
|
|
396
|
+
} = this.asProps;
|
|
397
|
+
return {
|
|
398
|
+
periods,
|
|
399
|
+
"value": preselectedValue.length ? preselectedValue : value,
|
|
400
|
+
"onChange": this.handleApply,
|
|
401
|
+
onHighlightedChange,
|
|
402
|
+
onDisplayedPeriodChange,
|
|
403
|
+
"role": "listbox",
|
|
404
|
+
"aria-label": getI18nText("periods"),
|
|
405
|
+
"periodRef": (index) => (element) => {
|
|
406
|
+
if (!element) return;
|
|
407
|
+
this.periodRefs[index] = element;
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
getApplyProps() {
|
|
412
|
+
const {
|
|
413
|
+
getI18nText
|
|
414
|
+
} = this.asProps;
|
|
415
|
+
return {
|
|
416
|
+
getI18nText,
|
|
417
|
+
onClick: this.handleApplyClick,
|
|
418
|
+
ref: this.applyButtonRef
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
getResetProps() {
|
|
422
|
+
const {
|
|
423
|
+
getI18nText
|
|
424
|
+
} = this.asProps;
|
|
425
|
+
return {
|
|
426
|
+
getI18nText,
|
|
427
|
+
onClick: this.handleReset,
|
|
428
|
+
ref: this.resetButtonRef
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
render() {
|
|
432
|
+
var _ref = this.asProps, _ref4;
|
|
433
|
+
const {
|
|
434
|
+
Children,
|
|
435
|
+
styles,
|
|
436
|
+
"aria-label": providedAriaLabel
|
|
437
|
+
} = this.asProps;
|
|
438
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, (_ref4 = sstyled(styles), /* @__PURE__ */ React.createElement(Dropdown, assignProps({
|
|
439
|
+
"use:aria-label": providedAriaLabel,
|
|
440
|
+
"__excludeProps": ["onChange", "value"]
|
|
441
|
+
}, _ref), /* @__PURE__ */ React.createElement(Children, _ref4.cn("Children", {})))));
|
|
442
|
+
}
|
|
443
|
+
}
|
|
432
444
|
_defineProperty(RangePickerAbstract, "displayName", "DatePicker");
|
|
433
445
|
_defineProperty(RangePickerAbstract, "style", style);
|
|
434
446
|
_defineProperty(RangePickerAbstract, "enhance", [i18nEnhance(localizedMessages)]);
|
|
435
|
-
_defineProperty(RangePickerAbstract, "add",
|
|
447
|
+
_defineProperty(RangePickerAbstract, "add", (date, amount, unit) => {
|
|
436
448
|
return dayjs(date).add(amount, unit).toDate();
|
|
437
449
|
});
|
|
438
|
-
_defineProperty(RangePickerAbstract, "subtract",
|
|
450
|
+
_defineProperty(RangePickerAbstract, "subtract", (date, amount, unit) => {
|
|
439
451
|
return dayjs(date).subtract(amount, unit).toDate();
|
|
440
452
|
});
|
|
441
453
|
function Apply(props) {
|
|
442
454
|
var _ref2 = arguments[0];
|
|
443
|
-
|
|
455
|
+
const {
|
|
456
|
+
getI18nText
|
|
457
|
+
} = props;
|
|
444
458
|
return /* @__PURE__ */ React.createElement(Button, assignProps({
|
|
445
459
|
"use": "primary",
|
|
446
460
|
"children": getI18nText("apply")
|
|
@@ -448,7 +462,9 @@ function Apply(props) {
|
|
|
448
462
|
}
|
|
449
463
|
function Reset(props) {
|
|
450
464
|
var _ref3 = arguments[0];
|
|
451
|
-
|
|
465
|
+
const {
|
|
466
|
+
getI18nText
|
|
467
|
+
} = props;
|
|
452
468
|
return /* @__PURE__ */ React.createElement(Button, assignProps({
|
|
453
469
|
"use": "tertiary",
|
|
454
470
|
"theme": "muted",
|