@semcore/date-picker 4.57.0 → 4.57.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/lib/cjs/components/Calendar.js +24 -22
- package/lib/cjs/components/Calendar.js.map +1 -1
- package/lib/cjs/components/DateRangeComparatorAbstract.js +32 -30
- package/lib/cjs/components/DateRangeComparatorAbstract.js.map +1 -1
- package/lib/cjs/components/InputTrigger.js +32 -30
- package/lib/cjs/components/InputTrigger.js.map +1 -1
- package/lib/cjs/components/PickerAbstract.js +32 -30
- package/lib/cjs/components/PickerAbstract.js.map +1 -1
- package/lib/cjs/components/RangePickerAbstract.js +32 -30
- package/lib/cjs/components/RangePickerAbstract.js.map +1 -1
- package/lib/es6/components/Calendar.js +24 -22
- package/lib/es6/components/Calendar.js.map +1 -1
- package/lib/es6/components/DateRangeComparatorAbstract.js +32 -30
- package/lib/es6/components/DateRangeComparatorAbstract.js.map +1 -1
- package/lib/es6/components/InputTrigger.js +32 -30
- package/lib/es6/components/InputTrigger.js.map +1 -1
- package/lib/es6/components/PickerAbstract.js +32 -30
- package/lib/es6/components/PickerAbstract.js.map +1 -1
- package/lib/es6/components/RangePickerAbstract.js +32 -30
- package/lib/es6/components/RangePickerAbstract.js.map +1 -1
- package/lib/esm/DatePicker.mjs +114 -103
- package/lib/esm/DateRangeComparator.mjs +166 -149
- package/lib/esm/DateRangePicker.mjs +85 -77
- package/lib/esm/MonthDateRangeComparator.mjs +187 -169
- package/lib/esm/MonthPicker.mjs +78 -71
- package/lib/esm/MonthRangePicker.mjs +94 -85
- package/lib/esm/components/ButtonTrigger.mjs +16 -15
- package/lib/esm/components/Calendar.mjs +409 -287
- package/lib/esm/components/DateRangeComparatorAbstract.mjs +458 -330
- package/lib/esm/components/InputTrigger.mjs +762 -519
- package/lib/esm/components/PickerAbstract.mjs +196 -149
- package/lib/esm/components/RangePickerAbstract.mjs +310 -221
- package/lib/esm/components/index.mjs +127 -109
- package/lib/esm/index.mjs +13 -13
- package/lib/esm/style/calendar.shadow.css +259 -0
- package/lib/esm/style/date-picker.shadow.css +179 -0
- package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +32 -32
- package/lib/esm/translations/de.json.mjs +83 -56
- package/lib/esm/translations/en.json.mjs +95 -64
- package/lib/esm/translations/es.json.mjs +83 -56
- package/lib/esm/translations/fr.json.mjs +83 -56
- package/lib/esm/translations/it.json.mjs +83 -56
- package/lib/esm/translations/ja.json.mjs +83 -56
- package/lib/esm/translations/ko.json.mjs +83 -56
- package/lib/esm/translations/nl.json.mjs +83 -56
- package/lib/esm/translations/pl.json.mjs +83 -56
- package/lib/esm/translations/pt.json.mjs +83 -56
- package/lib/esm/translations/ru.json.mjs +35 -24
- package/lib/esm/translations/sv.json.mjs +83 -56
- package/lib/esm/translations/tr.json.mjs +83 -56
- package/lib/esm/translations/vi.json.mjs +83 -56
- package/lib/esm/translations/zh.json.mjs +83 -56
- package/lib/esm/utils/cronTabScheduler.mjs +58 -52
- package/lib/esm/utils/datesIntersects.mjs +15 -11
- package/lib/esm/utils/formatDate.mjs +25 -18
- package/lib/esm/utils/includesDate.mjs +13 -9
- package/lib/esm/utils/shortDateRangeFormat.mjs +53 -31
- package/package.json +15 -15
|
@@ -1,352 +1,441 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { sstyled
|
|
9
|
-
import { CORE_INSTANCE
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import { Flex
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import { localizedMessages
|
|
18
|
-
import { includesDate
|
|
19
|
-
import { formatMMYY
|
|
20
|
-
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
6
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
7
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
8
|
+
import { sstyled } from "@semcore/utils/lib/core/index";
|
|
9
|
+
import { CORE_INSTANCE, sstyled as sstyled$1, assignProps, Component } from "@semcore/core";
|
|
10
|
+
import React from "react";
|
|
11
|
+
import dayjs from "dayjs";
|
|
12
|
+
import Button from "@semcore/button";
|
|
13
|
+
import { Flex, Box } from "@semcore/flex-box";
|
|
14
|
+
import Divider from "@semcore/divider";
|
|
15
|
+
import Dropdown from "@semcore/dropdown";
|
|
16
|
+
import i18nEnhance from "@semcore/utils/lib/enhances/i18nEnhance";
|
|
17
|
+
import { localizedMessages } from "../translations/__intergalactic-dynamic-locales.mjs";
|
|
18
|
+
import { includesDate } from "../utils/includesDate.mjs";
|
|
19
|
+
import { formatMMYY, formatDDMMYY } from "../utils/formatDate.mjs";
|
|
20
|
+
/*!__reshadow-styles__:"../style/date-picker.shadow.css"*/
|
|
21
|
+
var style = (
|
|
21
22
|
/*__reshadow_css_start__*/
|
|
22
|
-
(
|
|
23
|
+
(sstyled.insert(
|
|
23
24
|
/*__inner_css_start__*/
|
|
24
|
-
".
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
25
|
+
".___SPopper_svfjr_gg_{padding:var(--intergalactic-spacing-4x, 16px);outline:0}.___SPopper_svfjr_gg_::-moz-focus-inner{border:0;padding:0}.___SPopper_svfjr_gg_:active,.___SPopper_svfjr_gg_:focus{outline:0;-webkit-text-decoration:none;text-decoration:none}@media (hover:hover){.___SPopper_svfjr_gg_:hover{outline:0;-webkit-text-decoration:none;text-decoration:none}}.___SPopper_svfjr_gg_:focus{box-shadow:var(--intergalactic-keyboard-focus, 0px 0px 0px 3px rgba(0, 143, 248, 0.5))}.___SHeader_svfjr_gg_,.___STitle_svfjr_gg_{display:flex;align-items:center}.___STitle_svfjr_gg_{font-size:var(--intergalactic-fs-200, 14px);color:var(--intergalactic-text-primary, #191b23);height:32px;width:100%;justify-content:center}.___SToday_svfjr_gg_{display:flex;margin-top:var(--intergalactic-spacing-3x, 12px);justify-content:center}.___SPeriod_svfjr_gg_{display:flex;flex-direction:column;margin-bottom:var(--intergalactic-spacing-2x, 8px)}.___SButton_svfjr_gg_ .___SInner_svfjr_gg_{justify-content:flex-start}.___SInputMask_svfjr_gg_{color:var(--intergalactic-text-primary, #191b23);line-height:normal;padding-right:var(--intergalactic-spacing-2x, 8px);transition:width calc(var(--intergalactic-duration-medium, 300)*1ms) ease,min-width calc(var(--intergalactic-duration-medium, 300)*1ms) ease}.___SInputMask_svfjr_gg_.__animationsDisabled_svfjr_gg_{transition:none}.___SInputMask_svfjr_gg_ .___SValue_svfjr_gg_{letter-spacing:0}.___SIndicator_svfjr_gg_{color:var(--intergalactic-text-secondary, #6c6e79)}.___SRangeIndicator_svfjr_gg_{border-radius:50%;flex-shrink:0}.___SRangeIndicator_svfjr_gg_._range_value_svfjr_gg_{background-color:var(--intergalactic-date-picker-cell-active, #2bb3ff)}.___SRangeIndicator_svfjr_gg_._range_compare_svfjr_gg_{background-color:var(--intergalactic-date-picker-cell-comparison-active, #8649e1)}.___SRangeIndicator_svfjr_gg_.__disabled_svfjr_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3)}.___SHumanizedDate_svfjr_gg_{position:absolute;pointer-events:none;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;width:100%}.___SMask_svfjr_gg_{letter-spacing:0;white-space:nowrap;overflow:hidden}.___SDateRange_svfjr_gg_ .___SMask_svfjr_gg_,.___SDateRange_svfjr_gg_ .___SValue_svfjr_gg_,.___SSingleDateInput_svfjr_gg_ .___SMask_svfjr_gg_,.___SSingleDateInput_svfjr_gg_ .___SValue_svfjr_gg_{opacity:0}.___SSingleDateInput_svfjr_gg_:focus-within .___SHumanizedDate_svfjr_gg_{opacity:0;z-index:var(--intergalactic-z-index-deep, -999)}.___SSingleDateInput_svfjr_gg_:focus-within .___SMask_svfjr_gg_,.___SSingleDateInput_svfjr_gg_:focus-within .___SValue_svfjr_gg_{opacity:1}.___SDateRange_svfjr_gg_:focus-within .___SHumanizedDate_svfjr_gg_{opacity:0;z-index:var(--intergalactic-z-index-deep, -999)}.___SDateRange_svfjr_gg_:focus-within .___SMask_svfjr_gg_,.___SDateRange_svfjr_gg_:focus-within .___SValue_svfjr_gg_{opacity:1}.___SInputMask_svfjr_gg_.__noHumanizedDate_svfjr_gg_ .___SMask_svfjr_gg_,.___SInputMask_svfjr_gg_.__noHumanizedDate_svfjr_gg_ .___SValue_svfjr_gg_{opacity:1}.___SDateRange_svfjr_gg_ .___SInputMask_svfjr_gg_:focus-within .___SMask_svfjr_gg_{background-color:var(--intergalactic-bg-highlight-focus, rgba(0, 143, 248, 0.2))}.___SDateRange_svfjr_gg_:focus-within .___SRangeSep_svfjr_gg_,.___SRangeSep_svfjr_gg_.__fulfilled_svfjr_gg_{color:var(--intergalactic-text-primary, #191b23)}.___SRangeComparatorHeader_svfjr_gg_{border-bottom:1px solid var(--intergalactic-border-primary, #c4c7cf)}.___SRangeCalendar_svfjr_gg_,.___SRangeComparatorHeader_svfjr_gg_{padding:var(--intergalactic-spacing-4x, 16px)}.___SFooter_svfjr_gg_{border-top:1px solid var(--intergalactic-border-primary, #c4c7cf)}.___SFooter_svfjr_gg_,.___SPeriodsList_svfjr_gg_{padding:var(--intergalactic-spacing-4x, 16px)}.___STooltip_svfjr_gg_{padding:var(--intergalactic-spacing-3x, 12px)}.___SCompareToggle_svfjr_gg_{white-space:nowrap}@media (prefers-reduced-motion){.___SInputMask_svfjr_gg_{transition:none}}",
|
|
26
|
+
/*__inner_css_end__*/
|
|
27
|
+
"svfjr_gg_"
|
|
28
|
+
), /*__reshadow_css_end__*/
|
|
29
|
+
{
|
|
30
|
+
"__SHeader": "___SHeader_svfjr_gg_",
|
|
31
|
+
"__STitle": "___STitle_svfjr_gg_",
|
|
32
|
+
"__SToday": "___SToday_svfjr_gg_",
|
|
33
|
+
"__SPeriod": "___SPeriod_svfjr_gg_",
|
|
34
|
+
"__SButton": "___SButton_svfjr_gg_",
|
|
35
|
+
"__SInner": "___SInner_svfjr_gg_",
|
|
36
|
+
"__SInputMask": "___SInputMask_svfjr_gg_",
|
|
37
|
+
"_animationsDisabled": "__animationsDisabled_svfjr_gg_",
|
|
38
|
+
"__SValue": "___SValue_svfjr_gg_",
|
|
39
|
+
"__SIndicator": "___SIndicator_svfjr_gg_",
|
|
40
|
+
"__SRangeIndicator": "___SRangeIndicator_svfjr_gg_",
|
|
41
|
+
"_range_value": "_range_value_svfjr_gg_",
|
|
42
|
+
"_range_compare": "_range_compare_svfjr_gg_",
|
|
43
|
+
"_disabled": "__disabled_svfjr_gg_",
|
|
44
|
+
"__SHumanizedDate": "___SHumanizedDate_svfjr_gg_",
|
|
45
|
+
"__SMask": "___SMask_svfjr_gg_",
|
|
46
|
+
"__SSingleDateInput": "___SSingleDateInput_svfjr_gg_",
|
|
47
|
+
"__SDateRange": "___SDateRange_svfjr_gg_",
|
|
48
|
+
"_noHumanizedDate": "__noHumanizedDate_svfjr_gg_",
|
|
49
|
+
"__SRangeSep": "___SRangeSep_svfjr_gg_",
|
|
50
|
+
"_fulfilled": "__fulfilled_svfjr_gg_",
|
|
51
|
+
"__SRangeComparatorHeader": "___SRangeComparatorHeader_svfjr_gg_",
|
|
52
|
+
"__SRangeCalendar": "___SRangeCalendar_svfjr_gg_",
|
|
53
|
+
"__SFooter": "___SFooter_svfjr_gg_",
|
|
54
|
+
"__SPeriodsList": "___SPeriodsList_svfjr_gg_",
|
|
55
|
+
"__STooltip": "___STooltip_svfjr_gg_",
|
|
56
|
+
"__SCompareToggle": "___SCompareToggle_svfjr_gg_",
|
|
57
|
+
"__SPopper": "___SPopper_svfjr_gg_"
|
|
55
58
|
})
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
);
|
|
60
|
+
var INTERACTION_TAGS = ["INPUT"];
|
|
61
|
+
var INTERACTION_KEYS = ["ArrowDown", "Enter", " "];
|
|
62
|
+
var defaultDisplayedPeriod = new Date((/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0));
|
|
63
|
+
function getEndDate(value) {
|
|
64
|
+
if (!Array.isArray(value)) return null;
|
|
65
|
+
var _value = _slicedToArray(value, 2), startDate = _value[0], _value$ = _value[1], endDate = _value$ === void 0 ? startDate : _value$;
|
|
66
|
+
return endDate;
|
|
61
67
|
}
|
|
62
|
-
var
|
|
63
|
-
|
|
64
|
-
var
|
|
65
|
-
function
|
|
66
|
-
var
|
|
67
|
-
|
|
68
|
-
for (var
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
68
|
+
var RangePickerAbstract = /* @__PURE__ */ function(_Component) {
|
|
69
|
+
_inherits(RangePickerAbstract2, _Component);
|
|
70
|
+
var _super = _createSuper(RangePickerAbstract2);
|
|
71
|
+
function RangePickerAbstract2() {
|
|
72
|
+
var _this;
|
|
73
|
+
_classCallCheck(this, RangePickerAbstract2);
|
|
74
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
75
|
+
args[_key] = arguments[_key];
|
|
76
|
+
}
|
|
77
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
78
|
+
_defineProperty(_assertThisInitialized(_this), "popperRef", /* @__PURE__ */ React.createRef());
|
|
79
|
+
_defineProperty(_assertThisInitialized(_this), "unitRefs", {});
|
|
80
|
+
_defineProperty(_assertThisInitialized(_this), "navigateStep", void 0);
|
|
81
|
+
_defineProperty(_assertThisInitialized(_this), "keyDiff", void 0);
|
|
82
|
+
_defineProperty(_assertThisInitialized(_this), "keyStep", void 0);
|
|
83
|
+
_defineProperty(_assertThisInitialized(_this), "navigateView", function(direction) {
|
|
84
|
+
var displayedPeriod = _this.asProps.displayedPeriod;
|
|
85
|
+
var action = direction >= 1 ? "add" : "subtract";
|
|
86
|
+
var date = dayjs(displayedPeriod)[action](1, _this.navigateStep).toDate();
|
|
87
|
+
_this.handlers.displayedPeriod(date);
|
|
88
|
+
});
|
|
89
|
+
_defineProperty(_assertThisInitialized(_this), "bindHandlerNavigateClick", function(direction) {
|
|
74
90
|
return function() {
|
|
75
|
-
return
|
|
91
|
+
return _this.navigateView(direction);
|
|
76
92
|
};
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
93
|
+
});
|
|
94
|
+
_defineProperty(_assertThisInitialized(_this), "handlerKeyDown", function(place) {
|
|
95
|
+
return function(e) {
|
|
96
|
+
var _this$asProps = _this.asProps, displayedPeriod = _this$asProps.displayedPeriod, highlighted = _this$asProps.highlighted, preselectedValue = _this$asProps.preselectedValue, visible = _this$asProps.visible;
|
|
97
|
+
var key = e.key;
|
|
98
|
+
if (place === "trigger" && INTERACTION_KEYS.includes(key)) {
|
|
99
|
+
e.stopPropagation();
|
|
100
|
+
_this.handlers.visible(!visible);
|
|
101
|
+
setTimeout(function() {
|
|
102
|
+
var popper = _this.popperRef.current;
|
|
103
|
+
if (popper) {
|
|
104
|
+
popper.focus();
|
|
105
|
+
}
|
|
106
|
+
}, 0);
|
|
107
|
+
}
|
|
108
|
+
var day = _this.keyDiff[key];
|
|
109
|
+
var setNextDisplayedPeriod = function setNextDisplayedPeriod2(next_highlighted2) {
|
|
110
|
+
var _next_highlighted = _slicedToArray(next_highlighted2, 2), startPeriod = _next_highlighted[0], endPeriod = _next_highlighted[1];
|
|
111
|
+
var highlightedPeriod = endPeriod || startPeriod;
|
|
112
|
+
var displayedPeriodNormalized = displayedPeriod === null || displayedPeriod === void 0 ? void 0 : displayedPeriod.getDate();
|
|
113
|
+
var highlightedPeriodNormalized = highlightedPeriod === null || highlightedPeriod === void 0 ? void 0 : highlightedPeriod.getDate();
|
|
114
|
+
if (_this.navigateStep === "month") {
|
|
115
|
+
displayedPeriodNormalized = displayedPeriod === null || displayedPeriod === void 0 ? void 0 : displayedPeriod.getMonth();
|
|
116
|
+
highlightedPeriodNormalized = highlightedPeriod === null || highlightedPeriod === void 0 ? void 0 : highlightedPeriod.getMonth();
|
|
117
|
+
}
|
|
118
|
+
if (_this.navigateStep === "year") {
|
|
119
|
+
displayedPeriodNormalized = displayedPeriod === null || displayedPeriod === void 0 ? void 0 : displayedPeriod.getYear();
|
|
120
|
+
highlightedPeriodNormalized = highlightedPeriod === null || highlightedPeriod === void 0 ? void 0 : highlightedPeriod.getYear();
|
|
121
|
+
}
|
|
122
|
+
var offset = highlightedPeriodNormalized - displayedPeriodNormalized;
|
|
123
|
+
if (offset < 0 || offset > 1) {
|
|
124
|
+
return highlightedPeriod;
|
|
125
|
+
}
|
|
126
|
+
return displayedPeriod;
|
|
89
127
|
};
|
|
90
|
-
if (
|
|
91
|
-
return
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
128
|
+
if (place === "popper" && e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
|
|
129
|
+
return _this.handleApplyClick();
|
|
130
|
+
}
|
|
131
|
+
if (place === "popper" && e.key === " " && highlighted.length) {
|
|
132
|
+
var highlightedDate = highlighted[1] || highlighted[0];
|
|
133
|
+
if (!_this.isDisabled(highlightedDate)) {
|
|
134
|
+
_this.handleChange(highlightedDate);
|
|
135
|
+
}
|
|
136
|
+
e.preventDefault();
|
|
95
137
|
}
|
|
96
|
-
var
|
|
97
|
-
if (
|
|
98
|
-
if (
|
|
99
|
-
if (
|
|
100
|
-
var
|
|
101
|
-
|
|
138
|
+
var changedDate = void 0;
|
|
139
|
+
if (day) {
|
|
140
|
+
if (INTERACTION_TAGS.includes(e.target.tagName)) return;
|
|
141
|
+
if (highlighted.length) {
|
|
142
|
+
var next_highlighted;
|
|
143
|
+
if (preselectedValue.length === 1) {
|
|
144
|
+
next_highlighted = [preselectedValue[0], dayjs(highlighted[1] || highlighted[0]).add(day, _this.keyStep).toDate()];
|
|
145
|
+
changedDate = next_highlighted[1];
|
|
146
|
+
} else {
|
|
147
|
+
next_highlighted = [dayjs(highlighted[0]).add(day, _this.keyStep).toDate()];
|
|
148
|
+
changedDate = next_highlighted[0];
|
|
149
|
+
}
|
|
150
|
+
_this.handlers.highlighted(next_highlighted);
|
|
151
|
+
_this.handlers.displayedPeriod(setNextDisplayedPeriod(next_highlighted));
|
|
102
152
|
} else {
|
|
103
|
-
var
|
|
104
|
-
|
|
153
|
+
var _highlighted = [displayedPeriod ? displayedPeriod : dayjs().toDate()];
|
|
154
|
+
_this.handlers.highlighted(_highlighted);
|
|
155
|
+
changedDate = _highlighted[0];
|
|
105
156
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
157
|
+
e.preventDefault();
|
|
158
|
+
if (changedDate) {
|
|
159
|
+
var _this$unitRefs$format;
|
|
160
|
+
var formatter = _this.keyStep === "month" ? formatMMYY : formatDDMMYY;
|
|
161
|
+
var formattedDate = formatter(changedDate, _this.asProps.locale);
|
|
162
|
+
(_this$unitRefs$format = _this.unitRefs[formattedDate]) === null || _this$unitRefs$format === void 0 ? void 0 : _this$unitRefs$format.focus();
|
|
109
163
|
}
|
|
110
164
|
}
|
|
111
165
|
};
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
})
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
166
|
+
});
|
|
167
|
+
_defineProperty(_assertThisInitialized(_this), "handleApply", function(value) {
|
|
168
|
+
var _value2 = _slicedToArray(value, 2), startDate = _value2[0], _value2$ = _value2[1], endDate = _value2$ === void 0 ? startDate : _value2$;
|
|
169
|
+
_this.handleChange([]);
|
|
170
|
+
_this.handlers.value([startDate, endDate]);
|
|
171
|
+
_this.handlers.visible(false);
|
|
172
|
+
});
|
|
173
|
+
_defineProperty(_assertThisInitialized(_this), "handleChange", function(date) {
|
|
174
|
+
var preselectedValue = _this.asProps.preselectedValue;
|
|
175
|
+
var highlighted = [];
|
|
176
|
+
if (Array.isArray(date)) {
|
|
177
|
+
preselectedValue = date;
|
|
178
|
+
} else if (!preselectedValue.length) {
|
|
179
|
+
preselectedValue = [date];
|
|
180
|
+
highlighted = [date];
|
|
181
|
+
} else if (preselectedValue.length >= 2) {
|
|
182
|
+
preselectedValue = [date];
|
|
183
|
+
highlighted = [date];
|
|
184
|
+
} else if (preselectedValue[0] > date) {
|
|
185
|
+
preselectedValue = [date, preselectedValue[0]];
|
|
186
|
+
} else {
|
|
187
|
+
preselectedValue = [preselectedValue[0], date];
|
|
188
|
+
}
|
|
189
|
+
_this.handlers.preselectedValue(preselectedValue);
|
|
190
|
+
_this.handlers.highlighted(highlighted);
|
|
191
|
+
});
|
|
192
|
+
_defineProperty(_assertThisInitialized(_this), "handleApplyClick", function() {
|
|
193
|
+
var _this$asProps2 = _this.asProps, value = _this$asProps2.value, preselectedValue = _this$asProps2.preselectedValue;
|
|
194
|
+
return _this.handleApply(preselectedValue.length ? preselectedValue : value);
|
|
195
|
+
});
|
|
196
|
+
return _this;
|
|
122
197
|
}
|
|
123
|
-
|
|
198
|
+
_createClass(RangePickerAbstract2, [{
|
|
124
199
|
key: "uncontrolledProps",
|
|
125
|
-
value: function() {
|
|
126
|
-
var
|
|
200
|
+
value: function uncontrolledProps() {
|
|
201
|
+
var _this2 = this;
|
|
127
202
|
return {
|
|
128
203
|
displayedPeriod: null,
|
|
129
|
-
visible: [null, function(
|
|
130
|
-
var
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
204
|
+
visible: [null, function(visible) {
|
|
205
|
+
var _this2$asProps = _this2.asProps, value = _this2$asProps.value, displayedPeriod = _this2$asProps.displayedPeriod;
|
|
206
|
+
var endDate = getEndDate(value !== null && value !== void 0 ? value : void 0);
|
|
207
|
+
if (!visible) {
|
|
208
|
+
_this2.handlers.highlighted([]);
|
|
209
|
+
_this2.handlers.preselectedValue([]);
|
|
210
|
+
}
|
|
211
|
+
if (visible) {
|
|
212
|
+
if (endDate && endDate !== displayedPeriod) {
|
|
213
|
+
_this2.handlers.displayedPeriod(endDate);
|
|
214
|
+
} else if (!endDate) {
|
|
215
|
+
var _this2$props = _this2.props, _displayedPeriod = _this2$props.displayedPeriod, _defaultDisplayedPeriod = _this2$props.defaultDisplayedPeriod;
|
|
216
|
+
_this2.handlers.displayedPeriod(_displayedPeriod || _defaultDisplayedPeriod);
|
|
137
217
|
}
|
|
138
218
|
}
|
|
139
219
|
}],
|
|
140
220
|
highlighted: null,
|
|
141
221
|
preselectedValue: null,
|
|
142
|
-
value: [null, function(
|
|
143
|
-
if (
|
|
144
|
-
var
|
|
145
|
-
|
|
222
|
+
value: [null, function(value) {
|
|
223
|
+
if (value[0] !== null || value[1] !== null) {
|
|
224
|
+
var _value$2, _value$3;
|
|
225
|
+
_this2.handlers.displayedPeriod(getEndDate([(_value$2 = value[0]) !== null && _value$2 !== void 0 ? _value$2 : void 0, (_value$3 = value[1]) !== null && _value$3 !== void 0 ? _value$3 : void 0]));
|
|
146
226
|
}
|
|
147
227
|
}]
|
|
148
228
|
};
|
|
149
229
|
}
|
|
150
230
|
}, {
|
|
151
231
|
key: "isDisabled",
|
|
152
|
-
value: function(
|
|
153
|
-
var
|
|
154
|
-
return
|
|
232
|
+
value: function isDisabled(date) {
|
|
233
|
+
var disabled = this.asProps.disabled;
|
|
234
|
+
return disabled.some(includesDate(dayjs(date), "date"));
|
|
155
235
|
}
|
|
156
236
|
}, {
|
|
157
237
|
key: "getDefaultPeriods",
|
|
158
|
-
value: function() {
|
|
238
|
+
value: function getDefaultPeriods() {
|
|
159
239
|
return [];
|
|
160
240
|
}
|
|
161
241
|
}, {
|
|
162
242
|
key: "getButtonTriggerProps",
|
|
163
|
-
value: function() {
|
|
164
|
-
var
|
|
243
|
+
value: function getButtonTriggerProps() {
|
|
244
|
+
var _this$asProps3 = this.asProps, value = _this$asProps3.value, size = _this$asProps3.size, visible = _this$asProps3.visible;
|
|
165
245
|
return {
|
|
166
|
-
popoverVisible:
|
|
167
|
-
size
|
|
168
|
-
empty: !
|
|
246
|
+
popoverVisible: visible,
|
|
247
|
+
size,
|
|
248
|
+
empty: !value[0] && !value[1],
|
|
169
249
|
onKeyDown: this.handlerKeyDown("trigger")
|
|
170
250
|
};
|
|
171
251
|
}
|
|
172
252
|
}, {
|
|
173
253
|
key: "getPopperProps",
|
|
174
|
-
value: function() {
|
|
175
|
-
var
|
|
254
|
+
value: function getPopperProps() {
|
|
255
|
+
var Picker = this[CORE_INSTANCE];
|
|
256
|
+
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;
|
|
257
|
+
var buttons = /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Picker.Apply, null), !unclearable && /* @__PURE__ */ React.createElement(Picker.Reset, {
|
|
176
258
|
ml: 2
|
|
177
259
|
}));
|
|
178
260
|
return {
|
|
179
261
|
tabIndex: 0,
|
|
180
262
|
ref: this.popperRef,
|
|
181
263
|
onKeyDown: this.handlerKeyDown("popper"),
|
|
182
|
-
children: /* @__PURE__ */
|
|
264
|
+
children: /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Flex, null, /* @__PURE__ */ React.createElement(Flex, null, /* @__PURE__ */ React.createElement(Box, {
|
|
183
265
|
mr: 2
|
|
184
|
-
}, /* @__PURE__ */
|
|
266
|
+
}, /* @__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, {
|
|
185
267
|
ml: 2
|
|
186
|
-
}, /* @__PURE__ */
|
|
268
|
+
}, /* @__PURE__ */ React.createElement(Picker.Header, null, /* @__PURE__ */ React.createElement(Picker.Title, {
|
|
187
269
|
"aria-live": void 0
|
|
188
|
-
}), /* @__PURE__ */
|
|
270
|
+
}), /* @__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, {
|
|
189
271
|
m: "-16px 16px",
|
|
190
272
|
orientation: "vertical",
|
|
191
273
|
h: "auto"
|
|
192
|
-
}), /* @__PURE__ */
|
|
274
|
+
}), /* @__PURE__ */ React.createElement(Flex, {
|
|
193
275
|
direction: "column"
|
|
194
|
-
}, /* @__PURE__ */
|
|
276
|
+
}, /* @__PURE__ */ React.createElement(Picker.Period, null), /* @__PURE__ */ React.createElement(Flex, {
|
|
195
277
|
mt: "auto"
|
|
196
|
-
},
|
|
278
|
+
}, buttons)))), periods.length === 0 && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Divider, {
|
|
197
279
|
m: "16px -16px",
|
|
198
280
|
orientation: "horizontal",
|
|
199
281
|
w: "auto"
|
|
200
|
-
}), /* @__PURE__ */
|
|
282
|
+
}), /* @__PURE__ */ React.createElement(Flex, null, /* @__PURE__ */ React.createElement(Picker.Period, null), /* @__PURE__ */ React.createElement(Flex, {
|
|
201
283
|
mt: "auto"
|
|
202
|
-
},
|
|
284
|
+
}, buttons))))
|
|
203
285
|
};
|
|
204
286
|
}
|
|
205
287
|
}, {
|
|
206
288
|
key: "getHeaderProps",
|
|
207
|
-
value: function() {
|
|
208
|
-
var
|
|
289
|
+
value: function getHeaderProps() {
|
|
290
|
+
var Picker = this[CORE_INSTANCE];
|
|
209
291
|
return {
|
|
210
|
-
children: /* @__PURE__ */
|
|
292
|
+
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))
|
|
211
293
|
};
|
|
212
294
|
}
|
|
213
295
|
}, {
|
|
214
296
|
key: "getTitleProps",
|
|
215
|
-
value: function(
|
|
216
|
-
var
|
|
297
|
+
value: function getTitleProps(props, index) {
|
|
298
|
+
var _this$asProps5 = this.asProps, locale = _this$asProps5.locale, displayedPeriod = _this$asProps5.displayedPeriod;
|
|
217
299
|
return {
|
|
218
|
-
children: new Intl.DateTimeFormat(
|
|
300
|
+
children: new Intl.DateTimeFormat(locale, {
|
|
219
301
|
month: "long",
|
|
220
302
|
year: "numeric"
|
|
221
|
-
}).format(
|
|
303
|
+
}).format(dayjs(displayedPeriod).add(index, this.navigateStep).startOf(this.navigateStep).toDate())
|
|
222
304
|
};
|
|
223
305
|
}
|
|
224
306
|
}, {
|
|
225
307
|
key: "getNextProps",
|
|
226
|
-
value: function() {
|
|
227
|
-
var
|
|
308
|
+
value: function getNextProps() {
|
|
309
|
+
var getI18nText = this.asProps.getI18nText;
|
|
310
|
+
var navigateStep = this.navigateStep;
|
|
228
311
|
return {
|
|
229
312
|
onClick: this.bindHandlerNavigateClick(1),
|
|
230
|
-
getI18nText
|
|
231
|
-
"aria-label":
|
|
313
|
+
getI18nText,
|
|
314
|
+
"aria-label": navigateStep === "month" ? getI18nText("nextMonth") : getI18nText("nextYear")
|
|
232
315
|
};
|
|
233
316
|
}
|
|
234
317
|
}, {
|
|
235
318
|
key: "getPrevProps",
|
|
236
|
-
value: function() {
|
|
237
|
-
var
|
|
319
|
+
value: function getPrevProps() {
|
|
320
|
+
var getI18nText = this.asProps.getI18nText;
|
|
321
|
+
var navigateStep = this.navigateStep;
|
|
238
322
|
return {
|
|
239
323
|
onClick: this.bindHandlerNavigateClick(-1),
|
|
240
|
-
getI18nText
|
|
241
|
-
"aria-label":
|
|
324
|
+
getI18nText,
|
|
325
|
+
"aria-label": navigateStep === "month" ? getI18nText("prevMonth") : getI18nText("prevYear")
|
|
242
326
|
};
|
|
243
327
|
}
|
|
244
328
|
}, {
|
|
245
329
|
key: "getCalendarProps",
|
|
246
|
-
value: function(
|
|
247
|
-
var
|
|
330
|
+
value: function getCalendarProps(_props, index) {
|
|
331
|
+
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;
|
|
248
332
|
return {
|
|
249
|
-
locale
|
|
250
|
-
displayedPeriod:
|
|
251
|
-
disabled
|
|
252
|
-
highlighted
|
|
253
|
-
onHighlightedChange
|
|
254
|
-
onVisibleChange
|
|
255
|
-
value:
|
|
333
|
+
locale,
|
|
334
|
+
displayedPeriod: dayjs(displayedPeriod).add(index, this.navigateStep).startOf(this.navigateStep).toDate(),
|
|
335
|
+
disabled,
|
|
336
|
+
highlighted,
|
|
337
|
+
onHighlightedChange,
|
|
338
|
+
onVisibleChange,
|
|
339
|
+
value: preselectedValue.length ? preselectedValue : value,
|
|
256
340
|
onChange: this.handleChange,
|
|
257
341
|
unitRefs: this.unitRefs,
|
|
258
|
-
getI18nText
|
|
259
|
-
actionsDescribing:
|
|
260
|
-
tabIndex:
|
|
342
|
+
getI18nText,
|
|
343
|
+
actionsDescribing: index === 0 ? "range" : null,
|
|
344
|
+
tabIndex: index === 0 ? 0 : -1
|
|
261
345
|
};
|
|
262
346
|
}
|
|
263
347
|
}, {
|
|
264
348
|
key: "getPeriodProps",
|
|
265
|
-
value: function() {
|
|
266
|
-
var
|
|
349
|
+
value: function getPeriodProps() {
|
|
350
|
+
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;
|
|
267
351
|
return {
|
|
268
|
-
periods
|
|
269
|
-
value:
|
|
352
|
+
periods,
|
|
353
|
+
value: preselectedValue.length ? preselectedValue : value,
|
|
270
354
|
onChange: this.handleApply,
|
|
271
|
-
onHighlightedChange
|
|
272
|
-
onDisplayedPeriodChange
|
|
355
|
+
onHighlightedChange,
|
|
356
|
+
onDisplayedPeriodChange,
|
|
273
357
|
role: "listbox",
|
|
274
|
-
"aria-label":
|
|
358
|
+
"aria-label": getI18nText("periods")
|
|
275
359
|
};
|
|
276
360
|
}
|
|
277
361
|
}, {
|
|
278
362
|
key: "getApplyProps",
|
|
279
|
-
value: function() {
|
|
280
|
-
var
|
|
363
|
+
value: function getApplyProps() {
|
|
364
|
+
var getI18nText = this.asProps.getI18nText;
|
|
281
365
|
return {
|
|
282
|
-
getI18nText
|
|
366
|
+
getI18nText,
|
|
283
367
|
onClick: this.handleApplyClick
|
|
284
368
|
};
|
|
285
369
|
}
|
|
286
370
|
}, {
|
|
287
371
|
key: "getResetProps",
|
|
288
|
-
value: function() {
|
|
289
|
-
var
|
|
372
|
+
value: function getResetProps() {
|
|
373
|
+
var _this3 = this;
|
|
374
|
+
var getI18nText = this.asProps.getI18nText;
|
|
290
375
|
return {
|
|
291
|
-
getI18nText
|
|
292
|
-
onClick: function() {
|
|
293
|
-
return
|
|
376
|
+
getI18nText,
|
|
377
|
+
onClick: function onClick() {
|
|
378
|
+
return _this3.handleApply([]);
|
|
294
379
|
}
|
|
295
380
|
};
|
|
296
381
|
}
|
|
297
382
|
}, {
|
|
298
383
|
key: "render",
|
|
299
|
-
value: function() {
|
|
300
|
-
var
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
384
|
+
value: function render() {
|
|
385
|
+
var _ref = this.asProps, _ref4;
|
|
386
|
+
var _this$asProps8 = this.asProps, Children = _this$asProps8.Children, styles = _this$asProps8.styles, providedAriaLabel = _this$asProps8["aria-label"];
|
|
387
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, (_ref4 = sstyled$1(styles), /* @__PURE__ */ React.createElement(Dropdown, assignProps({
|
|
388
|
+
"use:aria-label": providedAriaLabel,
|
|
389
|
+
"__excludeProps": ["onChange", "value"]
|
|
390
|
+
}, _ref), /* @__PURE__ */ React.createElement(Children, _ref4.cn("Children", {})))));
|
|
305
391
|
}
|
|
306
392
|
}], [{
|
|
307
393
|
key: "defaultProps",
|
|
308
|
-
value: function(
|
|
309
|
-
var
|
|
394
|
+
value: function defaultProps(_ref5) {
|
|
395
|
+
var value = _ref5.value, defaultValue = _ref5.defaultValue;
|
|
310
396
|
return {
|
|
311
|
-
i18n:
|
|
397
|
+
i18n: localizedMessages,
|
|
312
398
|
locale: "en",
|
|
313
|
-
defaultDisplayedPeriod:
|
|
399
|
+
defaultDisplayedPeriod: getEndDate(value) || getEndDate(defaultValue) || defaultDisplayedPeriod,
|
|
314
400
|
defaultValue: [],
|
|
315
401
|
defaultHighlighted: [],
|
|
316
|
-
defaultVisible:
|
|
402
|
+
defaultVisible: false,
|
|
317
403
|
defaultPreselectedValue: [],
|
|
318
404
|
disabled: [],
|
|
319
405
|
size: "m"
|
|
320
406
|
};
|
|
321
407
|
}
|
|
322
|
-
}])
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
408
|
+
}]);
|
|
409
|
+
return RangePickerAbstract2;
|
|
410
|
+
}(Component);
|
|
411
|
+
_defineProperty(RangePickerAbstract, "displayName", "DatePicker");
|
|
412
|
+
_defineProperty(RangePickerAbstract, "style", style);
|
|
413
|
+
_defineProperty(RangePickerAbstract, "enhance", [i18nEnhance(localizedMessages)]);
|
|
414
|
+
_defineProperty(RangePickerAbstract, "add", function(date, amount, unit) {
|
|
415
|
+
return dayjs(date).add(amount, unit).toDate();
|
|
329
416
|
});
|
|
330
|
-
|
|
331
|
-
return
|
|
417
|
+
_defineProperty(RangePickerAbstract, "subtract", function(date, amount, unit) {
|
|
418
|
+
return dayjs(date).subtract(amount, unit).toDate();
|
|
332
419
|
});
|
|
333
|
-
function
|
|
334
|
-
var
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
420
|
+
function Apply(props) {
|
|
421
|
+
var _ref2 = arguments[0];
|
|
422
|
+
var getI18nText = props.getI18nText;
|
|
423
|
+
return /* @__PURE__ */ React.createElement(Button, assignProps({
|
|
424
|
+
"use": "primary",
|
|
425
|
+
"children": getI18nText("apply")
|
|
426
|
+
}, _ref2));
|
|
339
427
|
}
|
|
340
|
-
function
|
|
341
|
-
var
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
428
|
+
function Reset(props) {
|
|
429
|
+
var _ref3 = arguments[0];
|
|
430
|
+
var getI18nText = props.getI18nText;
|
|
431
|
+
return /* @__PURE__ */ React.createElement(Button, assignProps({
|
|
432
|
+
"use": "tertiary",
|
|
433
|
+
"theme": "muted",
|
|
434
|
+
"children": getI18nText("reset")
|
|
435
|
+
}, _ref3));
|
|
347
436
|
}
|
|
348
437
|
export {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
438
|
+
Apply,
|
|
439
|
+
Reset,
|
|
440
|
+
RangePickerAbstract as default
|
|
352
441
|
};
|