@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,650 +1,893 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import { sstyled
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import { Flex
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import { datesIntersects
|
|
22
|
-
import { includesDate
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import
|
|
26
|
-
var
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
|
+
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
5
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
6
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
7
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
8
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
9
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
10
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
11
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
12
|
+
import { sstyled } from "@semcore/utils/lib/core/index";
|
|
13
|
+
import createComponent, { sstyled as sstyled$1, assignProps, Component } from "@semcore/core";
|
|
14
|
+
import React from "react";
|
|
15
|
+
import BaseTrigger from "@semcore/base-trigger";
|
|
16
|
+
import InputMask from "@semcore/input-mask";
|
|
17
|
+
import Tooltip from "@semcore/tooltip";
|
|
18
|
+
import { Flex, Box } from "@semcore/flex-box";
|
|
19
|
+
import Calendar from "@semcore/icon/Calendar/m";
|
|
20
|
+
import NeighborLocation from "@semcore/neighbor-location";
|
|
21
|
+
import { datesIntersects } from "../utils/datesIntersects.mjs";
|
|
22
|
+
import { includesDate } from "../utils/includesDate.mjs";
|
|
23
|
+
import dayjs from "dayjs";
|
|
24
|
+
import useEnhancedEffect from "@semcore/utils/lib/use/useEnhancedEffect";
|
|
25
|
+
import assignProps$1 from "@semcore/utils/lib/assignProps";
|
|
26
|
+
var _excluded = ["children", "id", "role", "aria-haspopup", "aria-label", "style"], _excluded2 = ["children", "id", "role", "aria-haspopup", "aria-label", "style"], _excluded3 = ["value", "onChange", "onDisplayedPeriodChange", "locale", "w", "ariaHasPopup", "showError"], _excluded4 = ["value", "locale", "onDisplayedPeriodChange", "ariaHasPopup", "showError"], _excluded5 = ["value", "locale", "onDisplayedPeriodChange", "ariaHasPopup", "inputId", "showError"], _excluded6 = ["date", "onDateChange", "onDisplayedPeriodChange", "locale", "styles", "parts", "disabledDates", "forwardRef", "placeholders", "labelPrefix", "onMaskPipeBlock", "containerFocused", "animationsDisabled", "getI18nText", "inputId", "inputRole", "__excludeProps", "Root"];
|
|
27
|
+
/*!__reshadow-styles__:"../style/date-picker.shadow.css"*/
|
|
28
|
+
var style = (
|
|
27
29
|
/*__reshadow_css_start__*/
|
|
28
|
-
(
|
|
30
|
+
(sstyled.insert(
|
|
29
31
|
/*__inner_css_start__*/
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
32
|
+
".___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}}",
|
|
33
|
+
/*__inner_css_end__*/
|
|
34
|
+
"svfjr_gg_"
|
|
35
|
+
), /*__reshadow_css_end__*/
|
|
36
|
+
{
|
|
37
|
+
"__SHeader": "___SHeader_svfjr_gg_",
|
|
38
|
+
"__STitle": "___STitle_svfjr_gg_",
|
|
39
|
+
"__SToday": "___SToday_svfjr_gg_",
|
|
40
|
+
"__SPeriod": "___SPeriod_svfjr_gg_",
|
|
41
|
+
"__SButton": "___SButton_svfjr_gg_",
|
|
42
|
+
"__SInner": "___SInner_svfjr_gg_",
|
|
43
|
+
"__SInputMask": "___SInputMask_svfjr_gg_",
|
|
44
|
+
"_animationsDisabled": "__animationsDisabled_svfjr_gg_",
|
|
45
|
+
"__SValue": "___SValue_svfjr_gg_",
|
|
46
|
+
"__SIndicator": "___SIndicator_svfjr_gg_",
|
|
47
|
+
"__SRangeIndicator": "___SRangeIndicator_svfjr_gg_",
|
|
48
|
+
"_range_value": "_range_value_svfjr_gg_",
|
|
49
|
+
"_range_compare": "_range_compare_svfjr_gg_",
|
|
50
|
+
"_disabled": "__disabled_svfjr_gg_",
|
|
51
|
+
"__SHumanizedDate": "___SHumanizedDate_svfjr_gg_",
|
|
52
|
+
"__SMask": "___SMask_svfjr_gg_",
|
|
53
|
+
"__SSingleDateInput": "___SSingleDateInput_svfjr_gg_",
|
|
54
|
+
"__SDateRange": "___SDateRange_svfjr_gg_",
|
|
55
|
+
"_noHumanizedDate": "__noHumanizedDate_svfjr_gg_",
|
|
56
|
+
"__SRangeSep": "___SRangeSep_svfjr_gg_",
|
|
57
|
+
"_fulfilled": "__fulfilled_svfjr_gg_",
|
|
58
|
+
"__SRangeComparatorHeader": "___SRangeComparatorHeader_svfjr_gg_",
|
|
59
|
+
"__SRangeCalendar": "___SRangeCalendar_svfjr_gg_",
|
|
60
|
+
"__SFooter": "___SFooter_svfjr_gg_",
|
|
61
|
+
"__SPeriodsList": "___SPeriodsList_svfjr_gg_",
|
|
62
|
+
"__STooltip": "___STooltip_svfjr_gg_",
|
|
63
|
+
"__SCompareToggle": "___SCompareToggle_svfjr_gg_",
|
|
64
|
+
"__SPopper": "___SPopper_svfjr_gg_"
|
|
61
65
|
})
|
|
62
|
-
)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
);
|
|
67
|
+
var defaultAllowedParts = {
|
|
68
|
+
year: true,
|
|
69
|
+
month: true,
|
|
70
|
+
day: true
|
|
71
|
+
};
|
|
72
|
+
var exampleDate = new Date(2e3, 4, 29);
|
|
73
|
+
var InputTriggerRoot = /* @__PURE__ */ function(_Component) {
|
|
74
|
+
_inherits(InputTriggerRoot2, _Component);
|
|
75
|
+
var _super = _createSuper(InputTriggerRoot2);
|
|
76
|
+
function InputTriggerRoot2() {
|
|
77
|
+
_classCallCheck(this, InputTriggerRoot2);
|
|
78
|
+
return _super.apply(this, arguments);
|
|
71
79
|
}
|
|
72
|
-
|
|
80
|
+
_createClass(InputTriggerRoot2, [{
|
|
73
81
|
key: "getSingleDateInputProps",
|
|
74
|
-
value: function() {
|
|
75
|
-
var
|
|
76
|
-
|
|
77
|
-
var
|
|
78
|
-
|
|
79
|
-
var
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
value: function getSingleDateInputProps() {
|
|
83
|
+
var _this$asProps = this.asProps;
|
|
84
|
+
_this$asProps.children;
|
|
85
|
+
var id = _this$asProps.id;
|
|
86
|
+
_this$asProps.role;
|
|
87
|
+
var ariaHasPopup = _this$asProps["aria-haspopup"];
|
|
88
|
+
_this$asProps["aria-label"];
|
|
89
|
+
_this$asProps.style;
|
|
90
|
+
var otherProps = _objectWithoutProperties(_this$asProps, _excluded);
|
|
91
|
+
return _objectSpread(_objectSpread({}, otherProps), {}, {
|
|
92
|
+
ariaHasPopup,
|
|
93
|
+
inputId: id
|
|
85
94
|
});
|
|
86
95
|
}
|
|
87
96
|
}, {
|
|
88
97
|
key: "getDateRangeProps",
|
|
89
|
-
value: function() {
|
|
90
|
-
var
|
|
91
|
-
|
|
92
|
-
var
|
|
93
|
-
|
|
94
|
-
var
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
value: function getDateRangeProps() {
|
|
99
|
+
var _this$asProps2 = this.asProps;
|
|
100
|
+
_this$asProps2.children;
|
|
101
|
+
var id = _this$asProps2.id;
|
|
102
|
+
_this$asProps2.role;
|
|
103
|
+
var ariaHasPopup = _this$asProps2["aria-haspopup"];
|
|
104
|
+
_this$asProps2["aria-label"];
|
|
105
|
+
_this$asProps2.style;
|
|
106
|
+
var otherProps = _objectWithoutProperties(_this$asProps2, _excluded2);
|
|
107
|
+
return _objectSpread(_objectSpread({}, otherProps), {}, {
|
|
108
|
+
ariaHasPopup,
|
|
109
|
+
inputId: id
|
|
100
110
|
});
|
|
101
111
|
}
|
|
102
112
|
}, {
|
|
103
113
|
key: "render",
|
|
104
|
-
value: function() {
|
|
105
|
-
var
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
value: function render() {
|
|
115
|
+
var _ref = this.asProps, _ref8;
|
|
116
|
+
var SInputTrigger = Box;
|
|
117
|
+
var _this$asProps3 = this.asProps, Children = _this$asProps3.Children, style2 = _this$asProps3.style, getI18nText = _this$asProps3.getI18nText;
|
|
118
|
+
return _ref8 = sstyled$1(style2), /* @__PURE__ */ React.createElement(SInputTrigger, _ref8.cn("SInputTrigger", _objectSpread({}, assignProps({
|
|
119
|
+
"aria-label": getI18nText("input"),
|
|
120
|
+
"__excludeProps": ["onChange", "value", "role", "id"]
|
|
121
|
+
}, _ref))), /* @__PURE__ */ React.createElement(Children, _ref8.cn("Children", {})));
|
|
122
|
+
}
|
|
123
|
+
}]);
|
|
124
|
+
return InputTriggerRoot2;
|
|
125
|
+
}(Component);
|
|
126
|
+
_defineProperty(InputTriggerRoot, "displayName", "InputTrigger");
|
|
127
|
+
_defineProperty(InputTriggerRoot, "style", style);
|
|
128
|
+
_defineProperty(InputTriggerRoot, "defaultProps", {
|
|
116
129
|
duration: 300,
|
|
117
|
-
popoverVisible:
|
|
130
|
+
popoverVisible: true
|
|
118
131
|
});
|
|
119
|
-
var
|
|
120
|
-
|
|
121
|
-
var
|
|
122
|
-
function
|
|
123
|
-
var
|
|
124
|
-
|
|
125
|
-
for (var
|
|
126
|
-
|
|
127
|
-
|
|
132
|
+
var SingleDateInputRoot = /* @__PURE__ */ function(_Component2) {
|
|
133
|
+
_inherits(SingleDateInputRoot2, _Component2);
|
|
134
|
+
var _super2 = _createSuper(SingleDateInputRoot2);
|
|
135
|
+
function SingleDateInputRoot2() {
|
|
136
|
+
var _this;
|
|
137
|
+
_classCallCheck(this, SingleDateInputRoot2);
|
|
138
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
139
|
+
args[_key] = arguments[_key];
|
|
140
|
+
}
|
|
141
|
+
_this = _super2.call.apply(_super2, [this].concat(args));
|
|
142
|
+
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
128
143
|
errorText: null,
|
|
129
|
-
showError:
|
|
130
|
-
focused:
|
|
131
|
-
})
|
|
132
|
-
|
|
133
|
-
|
|
144
|
+
showError: false,
|
|
145
|
+
focused: false
|
|
146
|
+
});
|
|
147
|
+
_defineProperty(_assertThisInitialized(_this), "handleFocus", function() {
|
|
148
|
+
_this.setState({
|
|
149
|
+
focused: true
|
|
134
150
|
});
|
|
135
|
-
})
|
|
136
|
-
|
|
137
|
-
|
|
151
|
+
});
|
|
152
|
+
_defineProperty(_assertThisInitialized(_this), "handleBlur", function() {
|
|
153
|
+
_this.setState({
|
|
154
|
+
focused: false
|
|
138
155
|
});
|
|
139
|
-
})
|
|
140
|
-
|
|
141
|
-
|
|
156
|
+
});
|
|
157
|
+
_defineProperty(_assertThisInitialized(_this), "handleInputMaskPipeBlock", function(value) {
|
|
158
|
+
if (value === _this.asProps.disabledDateInputAttempt) return;
|
|
159
|
+
_this.handlers.disabledDateInputAttempt(value);
|
|
160
|
+
});
|
|
161
|
+
return _this;
|
|
142
162
|
}
|
|
143
|
-
|
|
163
|
+
_createClass(SingleDateInputRoot2, [{
|
|
144
164
|
key: "uncontrolledProps",
|
|
145
|
-
value: function() {
|
|
146
|
-
var
|
|
165
|
+
value: function uncontrolledProps() {
|
|
166
|
+
var _this2 = this;
|
|
147
167
|
return {
|
|
148
|
-
disabledDateInputAttempt: [null, function(
|
|
149
|
-
var
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
168
|
+
disabledDateInputAttempt: [null, function(date) {
|
|
169
|
+
var errorText = _this2.state.errorText;
|
|
170
|
+
var showError = false;
|
|
171
|
+
if (date !== null) {
|
|
172
|
+
errorText = _this2.asProps.disabledErrorText;
|
|
173
|
+
if (errorText === void 0) {
|
|
174
|
+
var key = "unavailableDate";
|
|
175
|
+
if (_this2.asProps.parts && !_this2.asProps.parts.day) {
|
|
176
|
+
key = "unavailableMonth";
|
|
177
|
+
}
|
|
178
|
+
errorText = _this2.asProps.getI18nText(key);
|
|
179
|
+
}
|
|
180
|
+
if (typeof errorText === "function") {
|
|
181
|
+
errorText = errorText(date);
|
|
154
182
|
}
|
|
155
|
-
|
|
183
|
+
showError = _this2.asProps.disabledErrorText !== null;
|
|
156
184
|
}
|
|
157
|
-
|
|
158
|
-
errorText
|
|
159
|
-
showError
|
|
185
|
+
_this2.setState({
|
|
186
|
+
errorText,
|
|
187
|
+
showError
|
|
160
188
|
});
|
|
161
189
|
}]
|
|
162
190
|
};
|
|
163
191
|
}
|
|
164
192
|
}, {
|
|
165
193
|
key: "getMaskedInputProps",
|
|
166
|
-
value: function() {
|
|
167
|
-
var
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
194
|
+
value: function getMaskedInputProps() {
|
|
195
|
+
var _this$asProps4 = this.asProps, value = _this$asProps4.value, onChange = _this$asProps4.onChange, onDisplayedPeriodChange = _this$asProps4.onDisplayedPeriodChange, locale = _this$asProps4.locale;
|
|
196
|
+
_this$asProps4.w;
|
|
197
|
+
_this$asProps4.ariaHasPopup;
|
|
198
|
+
_this$asProps4.showError;
|
|
199
|
+
var otherProps = _objectWithoutProperties(_this$asProps4, _excluded3);
|
|
200
|
+
return _objectSpread({
|
|
201
|
+
date: value,
|
|
202
|
+
onDateChange: onChange,
|
|
203
|
+
onDisplayedPeriodChange,
|
|
204
|
+
locale,
|
|
175
205
|
"aria-haspopup": "true",
|
|
176
206
|
onMaskPipeBlock: this.handleInputMaskPipeBlock
|
|
177
|
-
},
|
|
207
|
+
}, otherProps);
|
|
178
208
|
}
|
|
179
209
|
}, {
|
|
180
210
|
key: "render",
|
|
181
|
-
value: function() {
|
|
182
|
-
var
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
211
|
+
value: function render() {
|
|
212
|
+
var _ref2 = this.asProps, _ref9;
|
|
213
|
+
var _this$asProps5 = this.asProps, Children = _this$asProps5.Children, forwardRef = _this$asProps5.forwardRef, styles = _this$asProps5.styles, state = _this$asProps5.state, showErrorProps = _this$asProps5.showError, popoverVisible = _this$asProps5.popoverVisible;
|
|
214
|
+
var _this$state = this.state, errorText = _this$state.errorText, showErrorState = _this$state.showError, focused = _this$state.focused;
|
|
215
|
+
var showError = showErrorState && showErrorProps;
|
|
216
|
+
var SSingleDateInput = InputMask;
|
|
217
|
+
return _ref9 = sstyled$1(styles), /* @__PURE__ */ React.createElement(SSingleDateInput, _ref9.cn("SSingleDateInput", _objectSpread({}, assignProps({
|
|
218
|
+
"tag": Tooltip,
|
|
219
|
+
"placement": "top-start",
|
|
220
|
+
"title": errorText,
|
|
221
|
+
"theme": "warning",
|
|
222
|
+
"visible": showError && (popoverVisible || focused),
|
|
223
|
+
"state": showError ? "invalid" : state,
|
|
224
|
+
"ref": forwardRef,
|
|
225
|
+
"onFocus": this.handleFocus,
|
|
226
|
+
"onBlur": this.handleBlur,
|
|
227
|
+
"__excludeProps": ["onChange", "style", "aria-expanded"]
|
|
228
|
+
}, _ref2))), /* @__PURE__ */ React.createElement(NeighborLocation, _ref9.cn("NeighborLocation", {}), /* @__PURE__ */ React.createElement(Children, _ref9.cn("Children", {}))));
|
|
229
|
+
}
|
|
230
|
+
}]);
|
|
231
|
+
return SingleDateInputRoot2;
|
|
232
|
+
}(Component);
|
|
233
|
+
_defineProperty(SingleDateInputRoot, "displayName", "SingleDateInput");
|
|
234
|
+
_defineProperty(SingleDateInputRoot, "style", style);
|
|
235
|
+
_defineProperty(SingleDateInputRoot, "defaultProps", {
|
|
236
|
+
children: function children() {
|
|
237
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(SingleDateInput.Indicator, null), /* @__PURE__ */ React.createElement(SingleDateInput.MaskedInput, null));
|
|
203
238
|
},
|
|
204
|
-
defaultDisabledDateInputAttempt:
|
|
205
|
-
showError:
|
|
239
|
+
defaultDisabledDateInputAttempt: false,
|
|
240
|
+
showError: true
|
|
206
241
|
});
|
|
207
|
-
var
|
|
208
|
-
|
|
209
|
-
var
|
|
210
|
-
function
|
|
211
|
-
var
|
|
212
|
-
|
|
213
|
-
for (var
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
242
|
+
var DateRangeRoot = /* @__PURE__ */ function(_Component3) {
|
|
243
|
+
_inherits(DateRangeRoot2, _Component3);
|
|
244
|
+
var _super3 = _createSuper(DateRangeRoot2);
|
|
245
|
+
function DateRangeRoot2() {
|
|
246
|
+
var _this3;
|
|
247
|
+
_classCallCheck(this, DateRangeRoot2);
|
|
248
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
249
|
+
args[_key2] = arguments[_key2];
|
|
250
|
+
}
|
|
251
|
+
_this3 = _super3.call.apply(_super3, [this].concat(args));
|
|
252
|
+
_defineProperty(_assertThisInitialized(_this3), "state", {
|
|
253
|
+
containerFocused: false,
|
|
217
254
|
errorText: null,
|
|
218
|
-
showError:
|
|
255
|
+
showError: false,
|
|
219
256
|
lastChangedInput: "from"
|
|
220
|
-
})
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
257
|
+
});
|
|
258
|
+
_defineProperty(_assertThisInitialized(_this3), "fromRef", /* @__PURE__ */ React.createRef());
|
|
259
|
+
_defineProperty(_assertThisInitialized(_this3), "toRef", /* @__PURE__ */ React.createRef());
|
|
260
|
+
_defineProperty(_assertThisInitialized(_this3), "handleFromChange", function(value, event) {
|
|
261
|
+
var _this3$asProps$value$, _this3$asProps$value, _this3$asProps$value$2, _this3$asProps$value2;
|
|
262
|
+
var onChange = _this3.asProps.onChange;
|
|
263
|
+
var prevValue = [(_this3$asProps$value$ = (_this3$asProps$value = _this3.asProps.value) === null || _this3$asProps$value === void 0 ? void 0 : _this3$asProps$value[0]) !== null && _this3$asProps$value$ !== void 0 ? _this3$asProps$value$ : null, (_this3$asProps$value$2 = (_this3$asProps$value2 = _this3.asProps.value) === null || _this3$asProps$value2 === void 0 ? void 0 : _this3$asProps$value2[1]) !== null && _this3$asProps$value$2 !== void 0 ? _this3$asProps$value$2 : null];
|
|
264
|
+
onChange([value, prevValue[1]], event);
|
|
265
|
+
if (value) {
|
|
266
|
+
if (!_this3.toRef.current) return;
|
|
267
|
+
_this3.toRef.current.focus();
|
|
268
|
+
setTimeout(function() {
|
|
269
|
+
if (!_this3.toRef.current) return;
|
|
270
|
+
_this3.toRef.current.setSelectionRange(0, 0);
|
|
226
271
|
}, 0);
|
|
227
272
|
}
|
|
228
|
-
})
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
273
|
+
});
|
|
274
|
+
_defineProperty(_assertThisInitialized(_this3), "handleToChange", function(value, event) {
|
|
275
|
+
var _this3$asProps$value$3, _this3$asProps$value3, _this3$asProps$value$4, _this3$asProps$value4;
|
|
276
|
+
var onChange = _this3.asProps.onChange;
|
|
277
|
+
var prevValue = [(_this3$asProps$value$3 = (_this3$asProps$value3 = _this3.asProps.value) === null || _this3$asProps$value3 === void 0 ? void 0 : _this3$asProps$value3[0]) !== null && _this3$asProps$value$3 !== void 0 ? _this3$asProps$value$3 : null, (_this3$asProps$value$4 = (_this3$asProps$value4 = _this3.asProps.value) === null || _this3$asProps$value4 === void 0 ? void 0 : _this3$asProps$value4[1]) !== null && _this3$asProps$value$4 !== void 0 ? _this3$asProps$value$4 : null];
|
|
278
|
+
onChange([prevValue[0], value], event);
|
|
279
|
+
});
|
|
280
|
+
_defineProperty(_assertThisInitialized(_this3), "handleFromKeydown", function(event) {
|
|
281
|
+
if (!_this3.toRef.current) return;
|
|
282
|
+
if (!_this3.fromRef.current) return;
|
|
283
|
+
_this3.setState({
|
|
233
284
|
lastChangedInput: "from"
|
|
234
|
-
})
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
lastChangedInput: "to"
|
|
241
|
-
}), r.key === "Backspace" && !e.toRef.current.value) {
|
|
242
|
-
var d = e.fromRef.current.value;
|
|
243
|
-
e.fromRef.current.focus(), setTimeout(function() {
|
|
244
|
-
e.fromRef.current.setSelectionRange(d.length, d.length);
|
|
245
|
-
}, 0);
|
|
246
|
-
}
|
|
247
|
-
if (r.key === "ArrowLeft" && e.toRef.current.selectionStart === 0 && e.toRef.current.selectionEnd === 0) {
|
|
248
|
-
var n = e.fromRef.current.value;
|
|
249
|
-
e.fromRef.current.focus(), setTimeout(function() {
|
|
250
|
-
e.fromRef.current.setSelectionRange(n.length, n.length);
|
|
251
|
-
}, 0);
|
|
252
|
-
}
|
|
285
|
+
});
|
|
286
|
+
if (event.key === "ArrowRight" && _this3.fromRef.current.selectionStart === _this3.fromRef.current.value.length && _this3.fromRef.current.selectionEnd === _this3.fromRef.current.value.length) {
|
|
287
|
+
_this3.toRef.current.focus();
|
|
288
|
+
setTimeout(function() {
|
|
289
|
+
_this3.toRef.current.setSelectionRange(0, 0);
|
|
290
|
+
}, 0);
|
|
253
291
|
}
|
|
254
|
-
})
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
292
|
+
});
|
|
293
|
+
_defineProperty(_assertThisInitialized(_this3), "handleToKeydown", function(event) {
|
|
294
|
+
if (!_this3.toRef.current) return;
|
|
295
|
+
if (!_this3.fromRef.current) return;
|
|
296
|
+
_this3.setState({
|
|
297
|
+
lastChangedInput: "to"
|
|
259
298
|
});
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
299
|
+
if (event.key === "Backspace" && !_this3.toRef.current.value) {
|
|
300
|
+
var value = _this3.fromRef.current.value;
|
|
301
|
+
_this3.fromRef.current.focus();
|
|
302
|
+
setTimeout(function() {
|
|
303
|
+
_this3.fromRef.current.setSelectionRange(value.length, value.length);
|
|
304
|
+
}, 0);
|
|
305
|
+
}
|
|
306
|
+
if (event.key === "ArrowLeft" && _this3.toRef.current.selectionStart === 0 && _this3.toRef.current.selectionEnd === 0) {
|
|
307
|
+
var _value = _this3.fromRef.current.value;
|
|
308
|
+
_this3.fromRef.current.focus();
|
|
309
|
+
setTimeout(function() {
|
|
310
|
+
_this3.fromRef.current.setSelectionRange(_value.length, _value.length);
|
|
311
|
+
}, 0);
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
_defineProperty(_assertThisInitialized(_this3), "handleInputMaskPipeBlock", function(value) {
|
|
315
|
+
if (value === _this3.asProps.disabledDateInputAttempt) return;
|
|
316
|
+
_this3.handlers.disabledDateInputAttempt(value);
|
|
317
|
+
});
|
|
318
|
+
_defineProperty(_assertThisInitialized(_this3), "handleFocus", function() {
|
|
319
|
+
_this3.setState({
|
|
320
|
+
containerFocused: true
|
|
321
|
+
});
|
|
322
|
+
});
|
|
323
|
+
_defineProperty(_assertThisInitialized(_this3), "handleBlur", function() {
|
|
324
|
+
_this3.setState({
|
|
325
|
+
containerFocused: false
|
|
263
326
|
});
|
|
264
|
-
})
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
327
|
+
});
|
|
328
|
+
_defineProperty(_assertThisInitialized(_this3), "updateDisabledDateInputAttempt", function(value) {
|
|
329
|
+
var disabledDates = _this3.asProps.disabledDates;
|
|
330
|
+
var invalid = false;
|
|
331
|
+
if (value) {
|
|
332
|
+
if (value[0] && value[1]) invalid = disabledDates.some(datesIntersects([value[0], value[1]], _this3.asProps.unit));
|
|
333
|
+
else if (value[0]) invalid = disabledDates.some(includesDate(dayjs(value[0]), _this3.asProps.unit));
|
|
334
|
+
else if (value[1]) invalid = disabledDates.some(includesDate(dayjs(value[1]), _this3.asProps.unit));
|
|
335
|
+
}
|
|
336
|
+
if (invalid) {
|
|
337
|
+
var invalidValue = _this3.state.lastChangedInput === "to" ? value[1] : value[0];
|
|
268
338
|
setTimeout(function() {
|
|
269
|
-
|
|
339
|
+
if (value === _this3.asProps.disabledDateInputAttempt) return;
|
|
340
|
+
_this3.handlers.disabledDateInputAttempt(invalidValue);
|
|
270
341
|
}, 0);
|
|
271
342
|
}
|
|
272
|
-
})
|
|
343
|
+
});
|
|
344
|
+
return _this3;
|
|
273
345
|
}
|
|
274
|
-
|
|
346
|
+
_createClass(DateRangeRoot2, [{
|
|
275
347
|
key: "uncontrolledProps",
|
|
276
|
-
value: function() {
|
|
277
|
-
var
|
|
348
|
+
value: function uncontrolledProps() {
|
|
349
|
+
var _this4 = this;
|
|
278
350
|
return {
|
|
279
|
-
disabledDateInputAttempt: [null, function(
|
|
280
|
-
var
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
351
|
+
disabledDateInputAttempt: [null, function(date) {
|
|
352
|
+
var errorText = _this4.state.errorText;
|
|
353
|
+
var showError = false;
|
|
354
|
+
if (date !== null) {
|
|
355
|
+
errorText = _this4.asProps.disabledErrorText;
|
|
356
|
+
if (errorText === void 0) {
|
|
357
|
+
var key = "unavailableDate";
|
|
358
|
+
if (_this4.asProps.parts && !_this4.asProps.parts.day) {
|
|
359
|
+
key = "unavailableMonth";
|
|
360
|
+
}
|
|
361
|
+
if (_this4.state.lastChangedInput === "to") {
|
|
362
|
+
key = "unavailableEndDate";
|
|
363
|
+
if (_this4.asProps.parts && !_this4.asProps.parts.day) {
|
|
364
|
+
key = "unavailableEndMonth";
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
errorText = _this4.asProps.getI18nText(key);
|
|
285
368
|
}
|
|
286
|
-
typeof
|
|
369
|
+
if (typeof errorText === "function") {
|
|
370
|
+
errorText = errorText(date);
|
|
371
|
+
}
|
|
372
|
+
showError = _this4.asProps.disabledErrorText !== null;
|
|
287
373
|
}
|
|
288
|
-
|
|
289
|
-
errorText
|
|
290
|
-
showError
|
|
374
|
+
_this4.setState({
|
|
375
|
+
errorText,
|
|
376
|
+
showError
|
|
291
377
|
});
|
|
292
378
|
}]
|
|
293
379
|
};
|
|
294
380
|
}
|
|
295
381
|
}, {
|
|
296
382
|
key: "getFromMaskedInputProps",
|
|
297
|
-
value: function() {
|
|
298
|
-
var
|
|
299
|
-
|
|
300
|
-
var
|
|
301
|
-
return
|
|
383
|
+
value: function getFromMaskedInputProps() {
|
|
384
|
+
var _this$asProps6 = this.asProps, value = _this$asProps6.value, locale = _this$asProps6.locale, onDisplayedPeriodChange = _this$asProps6.onDisplayedPeriodChange, ariaHasPopup = _this$asProps6.ariaHasPopup;
|
|
385
|
+
_this$asProps6.showError;
|
|
386
|
+
var otherProps = _objectWithoutProperties(_this$asProps6, _excluded4);
|
|
387
|
+
return assignProps$1({
|
|
302
388
|
ref: this.fromRef,
|
|
303
|
-
date:
|
|
389
|
+
date: value === null || value === void 0 ? void 0 : value[0],
|
|
304
390
|
onDateChange: this.handleFromChange,
|
|
305
391
|
onKeyDown: this.handleFromKeydown,
|
|
306
|
-
locale
|
|
392
|
+
locale,
|
|
307
393
|
flex: 1,
|
|
308
|
-
onDisplayedPeriodChange
|
|
309
|
-
"aria-haspopup":
|
|
394
|
+
onDisplayedPeriodChange,
|
|
395
|
+
"aria-haspopup": ariaHasPopup,
|
|
310
396
|
onMaskPipeBlock: this.handleInputMaskPipeBlock,
|
|
311
397
|
containerFocused: this.state.containerFocused
|
|
312
|
-
},
|
|
398
|
+
}, otherProps);
|
|
313
399
|
}
|
|
314
400
|
}, {
|
|
315
401
|
key: "getToMaskedInputProps",
|
|
316
|
-
value: function() {
|
|
317
|
-
var
|
|
318
|
-
|
|
319
|
-
|
|
402
|
+
value: function getToMaskedInputProps() {
|
|
403
|
+
var _this$asProps7 = this.asProps, value = _this$asProps7.value, locale = _this$asProps7.locale, onDisplayedPeriodChange = _this$asProps7.onDisplayedPeriodChange, ariaHasPopup = _this$asProps7.ariaHasPopup;
|
|
404
|
+
_this$asProps7.inputId;
|
|
405
|
+
_this$asProps7.showError;
|
|
406
|
+
var otherProps = _objectWithoutProperties(_this$asProps7, _excluded5);
|
|
407
|
+
var ariaLabel = this.asProps.getI18nText("toDate", {
|
|
320
408
|
date: this.asProps.getI18nText("input")
|
|
321
409
|
});
|
|
322
|
-
return
|
|
410
|
+
return assignProps$1({
|
|
323
411
|
ref: this.toRef,
|
|
324
|
-
date:
|
|
412
|
+
date: value === null || value === void 0 ? void 0 : value[1],
|
|
325
413
|
onDateChange: this.handleToChange,
|
|
326
414
|
onKeyDown: this.handleToKeydown,
|
|
327
|
-
locale
|
|
415
|
+
locale,
|
|
328
416
|
flex: 1,
|
|
329
|
-
onDisplayedPeriodChange
|
|
330
|
-
"aria-label":
|
|
331
|
-
"aria-haspopup":
|
|
417
|
+
onDisplayedPeriodChange,
|
|
418
|
+
"aria-label": ariaLabel,
|
|
419
|
+
"aria-haspopup": ariaHasPopup,
|
|
332
420
|
onMaskPipeBlock: this.handleInputMaskPipeBlock,
|
|
333
421
|
containerFocused: this.state.containerFocused
|
|
334
|
-
},
|
|
422
|
+
}, otherProps);
|
|
335
423
|
}
|
|
336
424
|
}, {
|
|
337
425
|
key: "getRangeSepProps",
|
|
338
|
-
value: function() {
|
|
339
|
-
var
|
|
426
|
+
value: function getRangeSepProps() {
|
|
427
|
+
var value = this.asProps.value;
|
|
340
428
|
return {
|
|
341
|
-
fulfilled: !!(
|
|
429
|
+
fulfilled: !!(value && (value[0] || value[1]))
|
|
342
430
|
};
|
|
343
431
|
}
|
|
344
432
|
}, {
|
|
345
433
|
key: "componentDidUpdate",
|
|
346
|
-
value: function(
|
|
347
|
-
|
|
434
|
+
value: function componentDidUpdate(prevProps) {
|
|
435
|
+
if (prevProps.value !== this.asProps.value) {
|
|
436
|
+
this.updateDisabledDateInputAttempt(this.asProps.value);
|
|
437
|
+
}
|
|
348
438
|
}
|
|
349
439
|
}, {
|
|
350
440
|
key: "componentDidMount",
|
|
351
|
-
value: function() {
|
|
441
|
+
value: function componentDidMount() {
|
|
352
442
|
this.updateDisabledDateInputAttempt(this.asProps.value);
|
|
353
443
|
}
|
|
354
444
|
}, {
|
|
355
445
|
key: "render",
|
|
356
|
-
value: function() {
|
|
357
|
-
var
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
446
|
+
value: function render() {
|
|
447
|
+
var _ref3 = this.asProps, _ref10;
|
|
448
|
+
var SDateRange = InputMask;
|
|
449
|
+
var _this$asProps8 = this.asProps, Children = _this$asProps8.Children, styles = _this$asProps8.styles, w = _this$asProps8.w, state = _this$asProps8.state, showErrorProps = _this$asProps8.showError, popoverVisible = _this$asProps8.popoverVisible;
|
|
450
|
+
var _this$state2 = this.state, errorText = _this$state2.errorText, lastChangedInput = _this$state2.lastChangedInput, showErrorState = _this$state2.showError, containerFocused = _this$state2.containerFocused;
|
|
451
|
+
var showError = showErrorState && showErrorProps;
|
|
452
|
+
return _ref10 = sstyled$1(styles), /* @__PURE__ */ React.createElement(SDateRange, _ref10.cn("SDateRange", _objectSpread({}, assignProps({
|
|
453
|
+
"tag": Tooltip,
|
|
454
|
+
"ignorePortalsStacking": true,
|
|
455
|
+
"placement": lastChangedInput === "to" ? "top-end" : "top-start",
|
|
456
|
+
"title": errorText,
|
|
457
|
+
"theme": "warning",
|
|
458
|
+
"visible": showError && (popoverVisible || containerFocused),
|
|
459
|
+
"state": showError ? "invalid" : state,
|
|
460
|
+
"__excludeProps": ["onChange", "value", "aria-expanded"],
|
|
461
|
+
"w": w,
|
|
462
|
+
"onFocus": this.handleFocus,
|
|
463
|
+
"onBlur": this.handleBlur
|
|
464
|
+
}, _ref3))), /* @__PURE__ */ React.createElement(Children, _ref10.cn("Children", {})));
|
|
465
|
+
}
|
|
466
|
+
}]);
|
|
467
|
+
return DateRangeRoot2;
|
|
468
|
+
}(Component);
|
|
469
|
+
_defineProperty(DateRangeRoot, "displayName", "DateRange");
|
|
470
|
+
_defineProperty(DateRangeRoot, "style", style);
|
|
471
|
+
_defineProperty(DateRangeRoot, "defaultProps", {
|
|
472
|
+
children: function children2() {
|
|
473
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(DateRange.Indicator, null), /* @__PURE__ */ React.createElement(DateRange.FromMaskedInput, null), /* @__PURE__ */ React.createElement(DateRange.RangeSep, null), /* @__PURE__ */ React.createElement(DateRange.ToMaskedInput, null));
|
|
379
474
|
},
|
|
380
|
-
defaultDisabledDateInputAttempt:
|
|
381
|
-
showError:
|
|
475
|
+
defaultDisabledDateInputAttempt: false,
|
|
476
|
+
showError: true
|
|
382
477
|
});
|
|
383
|
-
var
|
|
384
|
-
var
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
},
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
var
|
|
395
|
-
return
|
|
396
|
-
|
|
478
|
+
var FromMaskedInput = function FromMaskedInput2(props) {
|
|
479
|
+
var _ref4 = arguments[0], _ref11;
|
|
480
|
+
var SFromMaskedInput = MaskedInput;
|
|
481
|
+
var getI18nText = props.getI18nText;
|
|
482
|
+
return _ref11 = sstyled$1(props.styles), /* @__PURE__ */ React.createElement(SFromMaskedInput, _ref11.cn("SFromMaskedInput", _objectSpread({}, assignProps({
|
|
483
|
+
"labelPrefix": getI18nText("fromDatePlaceholder")
|
|
484
|
+
}, _ref4))));
|
|
485
|
+
};
|
|
486
|
+
var ToMaskedInput = function ToMaskedInput2(props) {
|
|
487
|
+
var _ref5 = arguments[0], _ref12;
|
|
488
|
+
var SToMaskedInput = MaskedInput;
|
|
489
|
+
var getI18nText = props.getI18nText;
|
|
490
|
+
return _ref12 = sstyled$1(props.styles), /* @__PURE__ */ React.createElement(SToMaskedInput, _ref12.cn("SToMaskedInput", _objectSpread({}, assignProps({
|
|
491
|
+
"labelPrefix": getI18nText("toDatePlaceholder")
|
|
492
|
+
}, _ref5))));
|
|
493
|
+
};
|
|
494
|
+
var Indicator = function Indicator2(props) {
|
|
495
|
+
var _ref6 = arguments[0], _ref13;
|
|
496
|
+
var SIndicator = InputMask.Addon;
|
|
497
|
+
return _ref13 = sstyled$1(props.styles), /* @__PURE__ */ React.createElement(SIndicator, _ref13.cn("SIndicator", _objectSpread({}, assignProps({
|
|
498
|
+
"tag": Calendar,
|
|
397
499
|
"aria-hidden": "true",
|
|
398
|
-
tabIndex: -1
|
|
399
|
-
},
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
500
|
+
"tabIndex": -1
|
|
501
|
+
}, _ref6))));
|
|
502
|
+
};
|
|
503
|
+
var RangeSep = function RangeSep2(props) {
|
|
504
|
+
var _ref7 = arguments[0], _ref14;
|
|
505
|
+
var SRangeSep = InputMask.Addon;
|
|
506
|
+
return _ref14 = sstyled$1(props.styles), /* @__PURE__ */ React.createElement(SRangeSep, _ref14.cn("SRangeSep", _objectSpread({}, assignProps({
|
|
507
|
+
"tag": Flex,
|
|
508
|
+
"alignItems": "center",
|
|
509
|
+
"justifyContent": "center",
|
|
510
|
+
"pl": 0,
|
|
511
|
+
"flex": "0"
|
|
512
|
+
}, _ref7))), "–");
|
|
513
|
+
};
|
|
514
|
+
var MaskedInput = function MaskedInput2(_ref16) {
|
|
515
|
+
var _ref15;
|
|
516
|
+
var outerValue = _ref16.date, onDateChange = _ref16.onDateChange, onDisplayedPeriodChange = _ref16.onDisplayedPeriodChange, locale = _ref16.locale, styles = _ref16.styles, _ref16$parts = _ref16.parts, allowedParts = _ref16$parts === void 0 ? defaultAllowedParts : _ref16$parts, disabledDates = _ref16.disabledDates, forwardRef = _ref16.forwardRef, providedPlaceholders = _ref16.placeholders, _ref16$labelPrefix = _ref16.labelPrefix, labelPrefix = _ref16$labelPrefix === void 0 ? "Date" : _ref16$labelPrefix, onMaskPipeBlock = _ref16.onMaskPipeBlock, containerFocused = _ref16.containerFocused, animationsDisabled = _ref16.animationsDisabled, getI18nText = _ref16.getI18nText, inputId = _ref16.inputId, _ref16$inputRole = _ref16.inputRole, inputRole = _ref16$inputRole === void 0 ? "combobox" : _ref16$inputRole;
|
|
517
|
+
_ref16.__excludeProps;
|
|
518
|
+
_ref16.Root;
|
|
519
|
+
var otherProps = _objectWithoutProperties(_ref16, _excluded6);
|
|
520
|
+
var ref = React.useRef();
|
|
521
|
+
var _React$useState = React.useState(void 0), _React$useState2 = _slicedToArray(_React$useState, 2), width = _React$useState2[0], setWidth = _React$useState2[1];
|
|
522
|
+
var placeholders = React.useMemo(function() {
|
|
523
|
+
if (providedPlaceholders) return providedPlaceholders;
|
|
524
|
+
return {
|
|
525
|
+
year: getI18nText("placeholder-years"),
|
|
526
|
+
month: getI18nText("placeholder-months"),
|
|
527
|
+
day: getI18nText("placeholder-days")
|
|
417
528
|
};
|
|
418
|
-
}, [
|
|
419
|
-
if (
|
|
420
|
-
|
|
421
|
-
placeholders
|
|
422
|
-
})
|
|
423
|
-
|
|
424
|
-
|
|
529
|
+
}, [providedPlaceholders, getI18nText]);
|
|
530
|
+
if (placeholders.year.length !== 1 || placeholders.month.length !== 1 || placeholders.day.length !== 1) {
|
|
531
|
+
console.error({
|
|
532
|
+
placeholders
|
|
533
|
+
});
|
|
534
|
+
throw new Error("InputTrigger placeholder prop should contain fields year, month and day each one with string value of single character length. [see above what was received] (".concat(placeholders, ")"), placeholders);
|
|
535
|
+
}
|
|
536
|
+
var _React$useMemo = React.useMemo(function() {
|
|
537
|
+
var _sep;
|
|
538
|
+
var options = {
|
|
425
539
|
year: "numeric",
|
|
426
540
|
month: "numeric",
|
|
427
541
|
day: "numeric"
|
|
428
|
-
}
|
|
542
|
+
};
|
|
543
|
+
var dateTimeFormat = new Intl.DateTimeFormat(locale, options);
|
|
544
|
+
var sep2 = void 0;
|
|
545
|
+
var order2 = [];
|
|
546
|
+
var parts = dateTimeFormat.formatToParts(exampleDate);
|
|
547
|
+
var _iterator = _createForOfIteratorHelper(parts), _step;
|
|
429
548
|
try {
|
|
430
|
-
for (
|
|
431
|
-
var
|
|
432
|
-
!
|
|
549
|
+
for (_iterator.s(); !(_step = _iterator.n()).done; ) {
|
|
550
|
+
var part = _step.value;
|
|
551
|
+
if (!sep2 && part.type === "literal") {
|
|
552
|
+
sep2 = part.value;
|
|
553
|
+
}
|
|
554
|
+
if (order2.length < 3 && ["day", "month", "year"].includes(part.type) && allowedParts[part.type]) {
|
|
555
|
+
order2.push(part.type);
|
|
556
|
+
}
|
|
433
557
|
}
|
|
434
|
-
} catch (
|
|
435
|
-
|
|
558
|
+
} catch (err) {
|
|
559
|
+
_iterator.e(err);
|
|
436
560
|
} finally {
|
|
437
|
-
|
|
561
|
+
_iterator.f();
|
|
562
|
+
}
|
|
563
|
+
sep2 = (_sep = sep2) !== null && _sep !== void 0 ? _sep : " ";
|
|
564
|
+
return {
|
|
565
|
+
sep: sep2,
|
|
566
|
+
order: order2
|
|
567
|
+
};
|
|
568
|
+
}, [locale, allowedParts]), sep = _React$useMemo.sep, order = _React$useMemo.order;
|
|
569
|
+
var outer = React.useMemo(function() {
|
|
570
|
+
var outerDate = outerValue;
|
|
571
|
+
if (typeof outerValue === "number" || typeof outerValue === "string") {
|
|
572
|
+
outerDate = new Date(outerValue);
|
|
438
573
|
}
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
574
|
+
var validDate = outerDate && outerDate instanceof Date && !Number.isNaN(outerDate.getTime());
|
|
575
|
+
if (!validDate) return null;
|
|
576
|
+
return {
|
|
577
|
+
year: outerDate.getFullYear().toString().padStart(4, "0"),
|
|
578
|
+
month: (outerDate.getMonth() + 1).toString().padStart(2, "0"),
|
|
579
|
+
day: outerDate.getDate().toString().padStart(2, "0")
|
|
442
580
|
};
|
|
443
|
-
}, [
|
|
444
|
-
|
|
445
|
-
(
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
month: (t.getMonth() + 1).toString().padStart(2, "0"),
|
|
450
|
-
day: t.getDate().toString().padStart(2, "0")
|
|
451
|
-
} : null;
|
|
452
|
-
}, [e]), Te = i.useCallback(function(t) {
|
|
453
|
-
if (!t || !t.year && !t.month && !t.day) return null;
|
|
454
|
-
var l = [], c = G(k), S;
|
|
581
|
+
}, [outerValue]);
|
|
582
|
+
var stringifyValue = React.useCallback(function(value2) {
|
|
583
|
+
if (!value2) return null;
|
|
584
|
+
if (!value2.year && !value2.month && !value2.day) return null;
|
|
585
|
+
var result = [];
|
|
586
|
+
var _iterator2 = _createForOfIteratorHelper(order), _step2;
|
|
455
587
|
try {
|
|
456
|
-
for (
|
|
457
|
-
var
|
|
458
|
-
|
|
588
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done; ) {
|
|
589
|
+
var part = _step2.value;
|
|
590
|
+
if (!allowedParts[part]) continue;
|
|
591
|
+
if (part === "year" && value2.year) result.push(value2.year);
|
|
592
|
+
if (part === "month" && value2.month) result.push(value2.month);
|
|
593
|
+
if (part === "day" && value2.day) result.push(value2.day);
|
|
459
594
|
}
|
|
460
|
-
} catch (
|
|
461
|
-
|
|
595
|
+
} catch (err) {
|
|
596
|
+
_iterator2.e(err);
|
|
462
597
|
} finally {
|
|
463
|
-
|
|
464
|
-
}
|
|
465
|
-
return
|
|
466
|
-
}, [
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
598
|
+
_iterator2.f();
|
|
599
|
+
}
|
|
600
|
+
return result.join(sep);
|
|
601
|
+
}, [order, allowedParts]);
|
|
602
|
+
var _React$useState3 = React.useState(outer), _React$useState4 = _slicedToArray(_React$useState3, 2), internalValue = _React$useState4[0], setInternalValue = _React$useState4[1];
|
|
603
|
+
var value = React.useMemo(function() {
|
|
604
|
+
return stringifyValue(internalValue);
|
|
605
|
+
}, [stringifyValue, internalValue]);
|
|
606
|
+
var lastKnownOuterValue = React.useRef(outer);
|
|
607
|
+
React.useEffect(function() {
|
|
608
|
+
var _lastKnownOuterValue$, _lastKnownOuterValue$2, _lastKnownOuterValue$3;
|
|
609
|
+
if (((_lastKnownOuterValue$ = lastKnownOuterValue.current) === null || _lastKnownOuterValue$ === void 0 ? void 0 : _lastKnownOuterValue$.day) !== (outer === null || outer === void 0 ? void 0 : outer.day) || ((_lastKnownOuterValue$2 = lastKnownOuterValue.current) === null || _lastKnownOuterValue$2 === void 0 ? void 0 : _lastKnownOuterValue$2.month) !== (outer === null || outer === void 0 ? void 0 : outer.month) || ((_lastKnownOuterValue$3 = lastKnownOuterValue.current) === null || _lastKnownOuterValue$3 === void 0 ? void 0 : _lastKnownOuterValue$3.year) !== (outer === null || outer === void 0 ? void 0 : outer.year)) {
|
|
610
|
+
setInternalValue(outer);
|
|
611
|
+
}
|
|
612
|
+
lastKnownOuterValue.current = outer;
|
|
613
|
+
}, [outer, setInternalValue]);
|
|
614
|
+
var pipeMask = React.useCallback(function(value2) {
|
|
615
|
+
var placeholdersOnly = true;
|
|
616
|
+
for (var i = 0; i < value2.length; i++) {
|
|
617
|
+
if (value2[i] !== "_" && value2[i] !== sep) {
|
|
618
|
+
placeholdersOnly = false;
|
|
477
619
|
break;
|
|
478
620
|
}
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
621
|
+
}
|
|
622
|
+
if (placeholdersOnly) {
|
|
623
|
+
onMaskPipeBlock === null || onMaskPipeBlock === void 0 ? void 0 : onMaskPipeBlock(null);
|
|
624
|
+
return "";
|
|
625
|
+
}
|
|
626
|
+
var getOffsetTo = function getOffsetTo2(partName2) {
|
|
627
|
+
var partsBefore = order.slice(0, order.indexOf(partName2));
|
|
628
|
+
var offset = 0;
|
|
629
|
+
var _iterator3 = _createForOfIteratorHelper(partsBefore), _step3;
|
|
483
630
|
try {
|
|
484
|
-
for (
|
|
485
|
-
var
|
|
486
|
-
|
|
631
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done; ) {
|
|
632
|
+
var part2 = _step3.value;
|
|
633
|
+
if (part2 === "year" && allowedParts.year) offset += 4;
|
|
634
|
+
if (part2 === "month" && allowedParts.month) offset += 2;
|
|
635
|
+
if (part2 === "day" && allowedParts.day) offset += 2;
|
|
487
636
|
}
|
|
488
|
-
} catch (
|
|
489
|
-
|
|
637
|
+
} catch (err) {
|
|
638
|
+
_iterator3.e(err);
|
|
490
639
|
} finally {
|
|
491
|
-
|
|
640
|
+
_iterator3.f();
|
|
492
641
|
}
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
var
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
642
|
+
offset += partsBefore.length * sep.length;
|
|
643
|
+
return offset;
|
|
644
|
+
};
|
|
645
|
+
var indexesOfPipedChars = [];
|
|
646
|
+
var parsed = {};
|
|
647
|
+
var parts = value2.split(sep);
|
|
648
|
+
for (var partName in placeholders) {
|
|
649
|
+
parsed[partName] = placeholders[partName];
|
|
650
|
+
}
|
|
651
|
+
for (var _i = 0; _i < order.length; _i++) {
|
|
652
|
+
parsed[order[_i]] = parts[_i];
|
|
653
|
+
}
|
|
654
|
+
var year = parsed.year, month = parsed.month, day = parsed.day;
|
|
655
|
+
if (allowedParts.month) {
|
|
656
|
+
if (month[0] !== "_" && parseInt(month[0], 10) > 1) {
|
|
657
|
+
month = "0".concat(month[0]);
|
|
658
|
+
indexesOfPipedChars.push(getOffsetTo("month"));
|
|
659
|
+
}
|
|
660
|
+
if (month === "00") month = "01";
|
|
661
|
+
if (month[0] !== "_" && month[1] !== "_" && parseInt(month, 10) > 12) return false;
|
|
662
|
+
}
|
|
663
|
+
if (allowedParts.day) {
|
|
664
|
+
if (day[0] !== "_" && parseInt(day[0], 10) > 3) {
|
|
665
|
+
day = "0".concat(day[0]);
|
|
666
|
+
indexesOfPipedChars.push(getOffsetTo("day"));
|
|
667
|
+
}
|
|
668
|
+
if (day === "00") day = "01";
|
|
669
|
+
if (day[0] !== "_" && day[1] !== "_" && parseInt(day, 10) > 31) return false;
|
|
670
|
+
}
|
|
671
|
+
year = year.split("").map(function(_char) {
|
|
672
|
+
return _char === "_" ? placeholders.year : _char;
|
|
508
673
|
}).join("");
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
674
|
+
month = month.split("").map(function(_char2) {
|
|
675
|
+
return _char2 === "_" ? placeholders.month : _char2;
|
|
676
|
+
}).join("");
|
|
677
|
+
day = day.split("").map(function(_char3) {
|
|
678
|
+
return _char3 === "_" ? placeholders.day : _char3;
|
|
679
|
+
}).join("");
|
|
680
|
+
var yearFulfilled = !allowedParts.year || year && year.length >= 4 && !year.includes(placeholders.year);
|
|
681
|
+
var monthFulfilled = !allowedParts.month || month && month.length === 2 && !month.includes(placeholders.month);
|
|
682
|
+
var dayFulfilled = !allowedParts.day || day && day.length === 2 && !day.includes(placeholders.day);
|
|
683
|
+
var fulfilled = yearFulfilled && monthFulfilled && dayFulfilled;
|
|
684
|
+
if (fulfilled) {
|
|
685
|
+
var date = new Date(0, 0, 0, 0, 0, 0, 0);
|
|
686
|
+
var yearParsed = allowedParts.year ? parseInt(year, 10) : 0;
|
|
687
|
+
var monthParsed = allowedParts.month ? parseInt(month, 10) - 1 : 0;
|
|
688
|
+
var dayParsed = allowedParts.day ? parseInt(day, 10) : 1;
|
|
689
|
+
date.setFullYear(yearParsed, monthParsed, dayParsed);
|
|
690
|
+
if (disabledDates !== null && disabledDates !== void 0 && disabledDates.some(includesDate(dayjs(date), "date"))) {
|
|
691
|
+
onMaskPipeBlock === null || onMaskPipeBlock === void 0 ? void 0 : onMaskPipeBlock(date);
|
|
692
|
+
return false;
|
|
693
|
+
}
|
|
694
|
+
if (allowedParts.day) {
|
|
695
|
+
if (date.getDate() !== parseInt(day, 10)) {
|
|
696
|
+
onMaskPipeBlock === null || onMaskPipeBlock === void 0 ? void 0 : onMaskPipeBlock(date);
|
|
697
|
+
return false;
|
|
698
|
+
}
|
|
699
|
+
}
|
|
514
700
|
}
|
|
515
|
-
var
|
|
701
|
+
var result = [];
|
|
702
|
+
var _iterator4 = _createForOfIteratorHelper(order), _step4;
|
|
516
703
|
try {
|
|
517
|
-
for (
|
|
518
|
-
var
|
|
519
|
-
|
|
704
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done; ) {
|
|
705
|
+
var part = _step4.value;
|
|
706
|
+
if (part === "year") result.push(year);
|
|
707
|
+
if (part === "month") result.push(month);
|
|
708
|
+
if (part === "day") result.push(day);
|
|
520
709
|
}
|
|
521
|
-
} catch (
|
|
522
|
-
|
|
710
|
+
} catch (err) {
|
|
711
|
+
_iterator4.e(err);
|
|
523
712
|
} finally {
|
|
524
|
-
|
|
713
|
+
_iterator4.f();
|
|
525
714
|
}
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
715
|
+
onMaskPipeBlock === null || onMaskPipeBlock === void 0 ? void 0 : onMaskPipeBlock(null);
|
|
716
|
+
return {
|
|
717
|
+
value: result.join(sep),
|
|
718
|
+
indexesOfPipedChars
|
|
529
719
|
};
|
|
530
|
-
}, [
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
var
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
720
|
+
}, [placeholders, sep, order, allowedParts, disabledDates, onMaskPipeBlock]);
|
|
721
|
+
var handleChange = React.useCallback(function(value2) {
|
|
722
|
+
var parsed = {};
|
|
723
|
+
for (var partName in placeholders) {
|
|
724
|
+
parsed[partName] = placeholders[partName];
|
|
725
|
+
}
|
|
726
|
+
var parts = value2.split(sep);
|
|
727
|
+
for (var i = 0; i < order.length; i++) {
|
|
728
|
+
parsed[order[i]] = parts[i];
|
|
729
|
+
}
|
|
730
|
+
var year = parsed.year, month = parsed.month, day = parsed.day;
|
|
731
|
+
setInternalValue({
|
|
732
|
+
year,
|
|
733
|
+
month,
|
|
734
|
+
day
|
|
541
735
|
});
|
|
542
|
-
var
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
736
|
+
var yearFulfilled = !allowedParts.year || year && year.length >= 4 && !year.includes(placeholders.year);
|
|
737
|
+
var monthFulfilled = !allowedParts.month || month && month.length === 2 && !month.includes(placeholders.month);
|
|
738
|
+
var dayFulfilled = !allowedParts.day || day && day.length === 2 && !day.includes(placeholders.day);
|
|
739
|
+
var fulfilled = yearFulfilled && monthFulfilled && dayFulfilled;
|
|
740
|
+
if (fulfilled) {
|
|
741
|
+
var date = new Date(0, 0, 0, 0, 0, 0, 0);
|
|
742
|
+
var yearParsed = allowedParts.year ? parseInt(year, 10) : 0;
|
|
743
|
+
var monthParsed = allowedParts.month ? parseInt(month, 10) - 1 : 0;
|
|
744
|
+
var dayParsed = allowedParts.day ? parseInt(day, 10) : 1;
|
|
745
|
+
date.setFullYear(yearParsed, monthParsed, dayParsed);
|
|
746
|
+
onDateChange(date);
|
|
747
|
+
lastKnownOuterValue.current = {
|
|
748
|
+
year,
|
|
749
|
+
month,
|
|
750
|
+
day
|
|
549
751
|
};
|
|
550
752
|
return;
|
|
551
753
|
}
|
|
552
|
-
if (
|
|
553
|
-
|
|
554
|
-
|
|
754
|
+
if (lastKnownOuterValue.current !== null) {
|
|
755
|
+
onDateChange(null);
|
|
756
|
+
lastKnownOuterValue.current = null;
|
|
555
757
|
}
|
|
556
|
-
|
|
557
|
-
|
|
758
|
+
if (yearFulfilled && allowedParts.year) {
|
|
759
|
+
var _date = new Date(0, 0, 0, 0, 0, 0, 0);
|
|
760
|
+
_date.setFullYear(parseInt(year, 10));
|
|
761
|
+
if (monthFulfilled && allowedParts.month) {
|
|
762
|
+
_date.setMonth(parseInt(month, 10) - 1);
|
|
763
|
+
}
|
|
764
|
+
onDisplayedPeriodChange(_date);
|
|
765
|
+
}
|
|
766
|
+
}, [onDateChange, setInternalValue, placeholders, onDisplayedPeriodChange, order, allowedParts]);
|
|
767
|
+
var mask = React.useMemo(function() {
|
|
768
|
+
var result = [];
|
|
769
|
+
var _iterator5 = _createForOfIteratorHelper(order), _step5;
|
|
558
770
|
try {
|
|
559
|
-
for (
|
|
560
|
-
var
|
|
561
|
-
|
|
771
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done; ) {
|
|
772
|
+
var part = _step5.value;
|
|
773
|
+
if (part === "year") result.push(placeholders.year + placeholders.year + placeholders.year + placeholders.year);
|
|
774
|
+
if (part === "month") result.push(placeholders.month + placeholders.month);
|
|
775
|
+
if (part === "day") result.push(placeholders.day + placeholders.day);
|
|
562
776
|
}
|
|
563
|
-
} catch (
|
|
564
|
-
|
|
777
|
+
} catch (err) {
|
|
778
|
+
_iterator5.e(err);
|
|
565
779
|
} finally {
|
|
566
|
-
|
|
567
|
-
}
|
|
568
|
-
return
|
|
569
|
-
}, [
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
(
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
780
|
+
_iterator5.f();
|
|
781
|
+
}
|
|
782
|
+
return result.join(sep);
|
|
783
|
+
}, [sep, order, placeholders]);
|
|
784
|
+
var aliases = React.useMemo(function() {
|
|
785
|
+
var _ref17;
|
|
786
|
+
return _ref17 = {}, _defineProperty(_ref17, placeholders.year, /\d/), _defineProperty(_ref17, placeholders.month, /\d/), _defineProperty(_ref17, placeholders.day, /\d/), _ref17;
|
|
787
|
+
}, [placeholders]);
|
|
788
|
+
var maskOnlySymbols = React.useMemo(function() {
|
|
789
|
+
var _ref18;
|
|
790
|
+
return _ref18 = {}, _defineProperty(_ref18, placeholders.year, true), _defineProperty(_ref18, placeholders.month, true), _defineProperty(_ref18, placeholders.day, true), _defineProperty(_ref18, sep, true), _ref18;
|
|
791
|
+
}, [sep, placeholders]);
|
|
792
|
+
var humanizedDate = React.useMemo(function() {
|
|
793
|
+
var outerDate = outerValue;
|
|
794
|
+
if (typeof outerValue === "number" || typeof outerValue === "string") {
|
|
795
|
+
outerDate = new Date(outerValue);
|
|
796
|
+
}
|
|
797
|
+
var validDate = outerDate && outerDate instanceof Date && !Number.isNaN(outerDate.getTime());
|
|
798
|
+
if (!validDate) return null;
|
|
799
|
+
return new Intl.DateTimeFormat(locale, {
|
|
800
|
+
year: allowedParts.year ? "numeric" : void 0,
|
|
801
|
+
month: allowedParts.month ? "short" : void 0,
|
|
802
|
+
day: allowedParts.day ? "numeric" : void 0
|
|
803
|
+
}).format(outerDate);
|
|
804
|
+
}, [outerValue, locale, allowedParts]);
|
|
805
|
+
useEnhancedEffect(function() {
|
|
806
|
+
if (!ref.current) return;
|
|
807
|
+
var stringsToMeasure = humanizedDate ? [humanizedDate, mask] : [mask];
|
|
808
|
+
var widths = [];
|
|
809
|
+
var measureSpan = document.createElement("span");
|
|
810
|
+
var computedStyle = window.getComputedStyle(ref.current);
|
|
811
|
+
var typographyRelatedStyles = ["height", "font-size", "font-family", "font-weight", "font-style", "line-height", "letter-spacing", "text-transform", "word-spacing"];
|
|
812
|
+
for (var _i2 = 0, _typographyRelatedSty = typographyRelatedStyles; _i2 < _typographyRelatedSty.length; _i2++) {
|
|
813
|
+
var _style = _typographyRelatedSty[_i2];
|
|
814
|
+
measureSpan.style[_style] = computedStyle[_style];
|
|
815
|
+
}
|
|
816
|
+
measureSpan.style.position = "absolute";
|
|
817
|
+
measureSpan.style.visibility = "hidden";
|
|
818
|
+
document.body.appendChild(measureSpan);
|
|
819
|
+
for (var _i3 = 0, _stringsToMeasure = stringsToMeasure; _i3 < _stringsToMeasure.length; _i3++) {
|
|
820
|
+
var string = _stringsToMeasure[_i3];
|
|
821
|
+
measureSpan.innerHTML = string;
|
|
822
|
+
widths.push(measureSpan.offsetWidth);
|
|
823
|
+
}
|
|
824
|
+
measureSpan.remove();
|
|
825
|
+
var maxWidth = Math.max.apply(Math, widths);
|
|
826
|
+
setWidth(maxWidth);
|
|
827
|
+
}, [locale, humanizedDate, allowedParts, mask]);
|
|
828
|
+
var SHumanizedDate = "div";
|
|
829
|
+
var handleInputRef = React.useCallback(function(node) {
|
|
830
|
+
ref.current = node;
|
|
831
|
+
if (!node || node.tagName !== "INPUT") return;
|
|
832
|
+
if (typeof forwardRef === "function") forwardRef(node);
|
|
833
|
+
else forwardRef.current = node;
|
|
834
|
+
}, [forwardRef]);
|
|
835
|
+
var _React$useState5 = React.useState(width), _React$useState6 = _slicedToArray(_React$useState5, 2), appliedWidth = _React$useState6[0], setAppliedWidth = _React$useState6[1];
|
|
836
|
+
var _React$useState7 = React.useState(false), _React$useState8 = _slicedToArray(_React$useState7, 2), innerFocused = _React$useState8[0], setInnerFocused = _React$useState8[1];
|
|
837
|
+
var focused = containerFocused !== null && containerFocused !== void 0 ? containerFocused : innerFocused;
|
|
838
|
+
var handleFocus = React.useCallback(function(event) {
|
|
839
|
+
var _otherProps$onFocus;
|
|
840
|
+
(_otherProps$onFocus = otherProps.onFocus) === null || _otherProps$onFocus === void 0 ? void 0 : _otherProps$onFocus.call(otherProps, event);
|
|
841
|
+
setInnerFocused(true);
|
|
609
842
|
}, []);
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
843
|
+
var handleBlur = React.useCallback(function(event) {
|
|
844
|
+
var _otherProps$onBlur;
|
|
845
|
+
(_otherProps$onBlur = otherProps.onBlur) === null || _otherProps$onBlur === void 0 ? void 0 : _otherProps$onBlur.call(otherProps, event);
|
|
846
|
+
setInnerFocused(false);
|
|
847
|
+
}, []);
|
|
848
|
+
useEnhancedEffect(function() {
|
|
849
|
+
if (focused) return;
|
|
850
|
+
setAppliedWidth(width);
|
|
851
|
+
}, [width, focused]);
|
|
852
|
+
return _ref15 = sstyled$1(styles), /* @__PURE__ */ React.createElement(InputMask.Value, _extends({
|
|
853
|
+
"aria-label": labelPrefix,
|
|
854
|
+
title: mask,
|
|
855
|
+
mask,
|
|
856
|
+
aliases,
|
|
857
|
+
maskOnlySymbols,
|
|
858
|
+
placeholder: mask,
|
|
859
|
+
inputW: appliedWidth,
|
|
860
|
+
wMin: appliedWidth,
|
|
861
|
+
id: inputId
|
|
862
|
+
}, otherProps, {
|
|
863
|
+
onFocus: handleFocus,
|
|
864
|
+
onBlur: handleBlur,
|
|
865
|
+
focused,
|
|
866
|
+
ref: handleInputRef,
|
|
867
|
+
pipe: pipeMask,
|
|
868
|
+
value: value !== null && value !== void 0 ? value : "",
|
|
869
|
+
onChange: handleChange,
|
|
870
|
+
noHumanizedDate: !humanizedDate,
|
|
871
|
+
animationsDisabled,
|
|
872
|
+
inputRole,
|
|
633
873
|
inputMode: "numeric"
|
|
634
|
-
}),
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
874
|
+
}), humanizedDate && /* @__PURE__ */ React.createElement(SHumanizedDate, _ref15.cn("SHumanizedDate", {}), humanizedDate));
|
|
875
|
+
};
|
|
876
|
+
var SingleDateInput = createComponent(SingleDateInputRoot, {
|
|
877
|
+
Indicator,
|
|
878
|
+
MaskedInput
|
|
879
|
+
});
|
|
880
|
+
var DateRange = createComponent(DateRangeRoot, {
|
|
881
|
+
Indicator,
|
|
882
|
+
RangeSep,
|
|
883
|
+
FromMaskedInput,
|
|
884
|
+
ToMaskedInput
|
|
885
|
+
});
|
|
886
|
+
var InputTrigger = createComponent(InputTriggerRoot, {
|
|
887
|
+
Addon: BaseTrigger.Addon,
|
|
888
|
+
SingleDateInput,
|
|
889
|
+
DateRange
|
|
647
890
|
});
|
|
648
891
|
export {
|
|
649
|
-
|
|
892
|
+
InputTrigger as default
|
|
650
893
|
};
|