@semcore/date-picker 16.2.4 → 17.0.0-prerelease.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/lib/cjs/DatePicker.js +116 -139
- package/lib/cjs/DatePicker.js.map +1 -1
- package/lib/cjs/DateRangeComparator.js +144 -149
- package/lib/cjs/DateRangeComparator.js.map +1 -1
- package/lib/cjs/DateRangePicker.js +86 -101
- package/lib/cjs/DateRangePicker.js.map +1 -1
- package/lib/cjs/MonthDateRangeComparator.js +173 -180
- package/lib/cjs/MonthDateRangeComparator.js.map +1 -1
- package/lib/cjs/MonthPicker.js +70 -87
- package/lib/cjs/MonthPicker.js.map +1 -1
- package/lib/cjs/MonthRangePicker.js +96 -111
- package/lib/cjs/MonthRangePicker.js.map +1 -1
- package/lib/cjs/components/ButtonTrigger.js +12 -11
- package/lib/cjs/components/ButtonTrigger.js.map +1 -1
- package/lib/cjs/components/Calendar.js +409 -466
- package/lib/cjs/components/Calendar.js.map +1 -1
- package/lib/cjs/components/DateRangeComparatorAbstract.js +574 -626
- package/lib/cjs/components/DateRangeComparatorAbstract.js.map +1 -1
- package/lib/cjs/components/InputTrigger.js +585 -677
- package/lib/cjs/components/InputTrigger.js.map +1 -1
- package/lib/cjs/components/PickerAbstract.js +254 -273
- package/lib/cjs/components/PickerAbstract.js.map +1 -1
- package/lib/cjs/components/RangePickerAbstract.js +407 -439
- package/lib/cjs/components/RangePickerAbstract.js.map +1 -1
- package/lib/cjs/components/index.js +92 -102
- package/lib/cjs/components/index.js.map +1 -1
- package/lib/cjs/index.d.js.map +1 -1
- package/lib/cjs/index.js +15 -15
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js +17 -17
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js.map +1 -1
- package/lib/cjs/utils/cronTabScheduler.js +13 -22
- package/lib/cjs/utils/cronTabScheduler.js.map +1 -1
- package/lib/cjs/utils/datesIntersects.js +12 -19
- package/lib/cjs/utils/datesIntersects.js.map +1 -1
- package/lib/cjs/utils/formatDate.js +11 -9
- package/lib/cjs/utils/formatDate.js.map +1 -1
- package/lib/cjs/utils/includesDate.js +11 -16
- package/lib/cjs/utils/includesDate.js.map +1 -1
- package/lib/cjs/utils/isBetweenPlugin.js +6 -6
- package/lib/cjs/utils/isBetweenPlugin.js.map +1 -1
- package/lib/cjs/utils/shortDateRangeFormat.js +29 -33
- package/lib/cjs/utils/shortDateRangeFormat.js.map +1 -1
- package/lib/es6/DatePicker.js +117 -141
- package/lib/es6/DatePicker.js.map +1 -1
- package/lib/es6/DateRangeComparator.js +130 -135
- package/lib/es6/DateRangeComparator.js.map +1 -1
- package/lib/es6/DateRangePicker.js +87 -102
- package/lib/es6/DateRangePicker.js.map +1 -1
- package/lib/es6/MonthDateRangeComparator.js +159 -166
- package/lib/es6/MonthDateRangeComparator.js.map +1 -1
- package/lib/es6/MonthPicker.js +72 -89
- package/lib/es6/MonthPicker.js.map +1 -1
- package/lib/es6/MonthRangePicker.js +97 -112
- package/lib/es6/MonthRangePicker.js.map +1 -1
- package/lib/es6/components/ButtonTrigger.js +4 -3
- package/lib/es6/components/ButtonTrigger.js.map +1 -1
- package/lib/es6/components/Calendar.js +400 -457
- package/lib/es6/components/Calendar.js.map +1 -1
- package/lib/es6/components/DateRangeComparatorAbstract.js +552 -604
- package/lib/es6/components/DateRangeComparatorAbstract.js.map +1 -1
- package/lib/es6/components/InputTrigger.js +568 -660
- package/lib/es6/components/InputTrigger.js.map +1 -1
- package/lib/es6/components/PickerAbstract.js +246 -265
- package/lib/es6/components/PickerAbstract.js.map +1 -1
- package/lib/es6/components/RangePickerAbstract.js +397 -429
- package/lib/es6/components/RangePickerAbstract.js.map +1 -1
- package/lib/es6/components/index.js +74 -85
- package/lib/es6/components/index.js.map +1 -1
- package/lib/es6/index.d.js.map +1 -1
- package/lib/es6/translations/__intergalactic-dynamic-locales.js +16 -16
- package/lib/es6/translations/__intergalactic-dynamic-locales.js.map +1 -1
- package/lib/es6/utils/cronTabScheduler.js +13 -21
- package/lib/es6/utils/cronTabScheduler.js.map +1 -1
- package/lib/es6/utils/datesIntersects.js +10 -18
- package/lib/es6/utils/datesIntersects.js.map +1 -1
- package/lib/es6/utils/formatDate.js +6 -6
- package/lib/es6/utils/formatDate.js.map +1 -1
- package/lib/es6/utils/includesDate.js +10 -15
- package/lib/es6/utils/includesDate.js.map +1 -1
- package/lib/es6/utils/isBetweenPlugin.js +4 -4
- package/lib/es6/utils/isBetweenPlugin.js.map +1 -1
- package/lib/es6/utils/shortDateRangeFormat.js +27 -31
- package/lib/es6/utils/shortDateRangeFormat.js.map +1 -1
- package/lib/esm/DatePicker.mjs +109 -114
- package/lib/esm/DateRangeComparator.mjs +112 -105
- package/lib/esm/DateRangePicker.mjs +76 -80
- package/lib/esm/MonthDateRangeComparator.mjs +141 -134
- package/lib/esm/MonthPicker.mjs +65 -70
- package/lib/esm/MonthRangePicker.mjs +86 -88
- package/lib/esm/components/ButtonTrigger.mjs +4 -3
- package/lib/esm/components/Calendar.mjs +397 -423
- package/lib/esm/components/DateRangeComparatorAbstract.mjs +559 -516
- package/lib/esm/components/InputTrigger.mjs +550 -557
- package/lib/esm/components/PickerAbstract.mjs +249 -244
- package/lib/esm/components/RangePickerAbstract.mjs +400 -384
- package/lib/esm/components/index.mjs +73 -69
- package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +1 -1
- package/lib/esm/utils/cronTabScheduler.mjs +13 -18
- package/lib/esm/utils/datesIntersects.mjs +10 -14
- package/lib/esm/utils/formatDate.mjs +6 -6
- package/lib/esm/utils/includesDate.mjs +10 -13
- package/lib/esm/utils/isBetweenPlugin.mjs +4 -4
- package/lib/esm/utils/shortDateRangeFormat.mjs +27 -27
- package/lib/types/index.d.ts +2 -44
- package/package.json +16 -17
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _createForOfIteratorHelper from "@babel/runtime/helpers/createForOfIteratorHelper";
|
|
3
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
|
-
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
5
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
6
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
7
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
8
|
-
import _callSuper from "@babel/runtime/helpers/callSuper";
|
|
9
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
10
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
11
3
|
import { sstyled as _sstyled } from "@semcore/core";
|
|
12
4
|
import { assignProps as _assignProps7 } from "@semcore/core";
|
|
@@ -16,224 +8,205 @@ import { assignProps as _assignProps4 } from "@semcore/core";
|
|
|
16
8
|
import { assignProps as _assignProps3 } from "@semcore/core";
|
|
17
9
|
import { assignProps as _assignProps2 } from "@semcore/core";
|
|
18
10
|
import { assignProps as _assignProps } from "@semcore/core";
|
|
19
|
-
|
|
20
|
-
_excluded2 = ["children", "id", "role", "aria-haspopup", "aria-label", "style"],
|
|
21
|
-
_excluded3 = ["value", "onChange", "onDisplayedPeriodChange", "locale", "w", "ariaHasPopup", "showError"],
|
|
22
|
-
_excluded4 = ["value", "locale", "onDisplayedPeriodChange", "ariaHasPopup", "showError"],
|
|
23
|
-
_excluded5 = ["value", "locale", "onDisplayedPeriodChange", "ariaHasPopup", "inputId", "showError"],
|
|
24
|
-
_excluded6 = ["date", "onDateChange", "onDisplayedPeriodChange", "locale", "styles", "parts", "disabledDates", "forwardRef", "placeholders", "labelPrefix", "onMaskPipeBlock", "containerFocused", "animationsDisabled", "getI18nText", "inputId", "inputRole", "__excludeProps", "Root"];
|
|
11
|
+
import { NeighborLocation, Flex, Box } from '@semcore/base-components';
|
|
25
12
|
import BaseTrigger from '@semcore/base-trigger';
|
|
26
13
|
import { createComponent, Root, sstyled, Component } from '@semcore/core';
|
|
27
14
|
import assignProps from '@semcore/core/lib/utils/assignProps';
|
|
28
15
|
import useEnhancedEffect from '@semcore/core/lib/utils/use/useEnhancedEffect';
|
|
29
|
-
import { Flex, Box } from '@semcore/flex-box';
|
|
30
16
|
import Calendar from '@semcore/icon/Calendar/m';
|
|
31
17
|
import InputMask from '@semcore/input-mask';
|
|
32
|
-
import NeighborLocation from '@semcore/neighbor-location';
|
|
33
18
|
import Tooltip from '@semcore/tooltip';
|
|
34
19
|
import dayjs from 'dayjs';
|
|
35
20
|
import React from 'react';
|
|
36
21
|
/*!__reshadow-styles__:"../style/date-picker.shadow.css"*/
|
|
37
|
-
|
|
22
|
+
const style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/".___SPopper_9ubmf_gg_{padding:var(--intergalactic-spacing-4x, 16px);outline:0}.___SPopper_9ubmf_gg_::-moz-focus-inner{border:0;padding:0}.___SPopper_9ubmf_gg_:active,.___SPopper_9ubmf_gg_:focus{-webkit-text-decoration:none;text-decoration:none}@media (hover:hover){.___SPopper_9ubmf_gg_:hover{-webkit-text-decoration:none;text-decoration:none}}.___SHeader_9ubmf_gg_,.___STitle_9ubmf_gg_{display:flex;align-items:center}.___STitle_9ubmf_gg_{font-size:var(--intergalactic-fs-200, 14px);color:var(--intergalactic-text-primary, #191b23);height:32px;width:100%;justify-content:center}.___SToday_9ubmf_gg_{display:flex;margin-top:var(--intergalactic-spacing-3x, 12px);justify-content:center}.___SPeriod_9ubmf_gg_{display:flex;flex-direction:column;margin-bottom:var(--intergalactic-spacing-2x, 8px)}.___SButton_9ubmf_gg_ .___SInner_9ubmf_gg_{justify-content:flex-start}.___SInputMask_9ubmf_gg_{color:var(--intergalactic-text-primary, #191b23);line-height:normal;padding-right:var(--intergalactic-spacing-2x, 8px);transition:width calc(var(--intergalactic-duration-medium, 300)*1ms) ease,min-width calc(var(--intergalactic-duration-medium, 300)*1ms) ease}.___SInputMask_9ubmf_gg_.__animationsDisabled_9ubmf_gg_{transition:none}.___SInputMask_9ubmf_gg_ .___SValue_9ubmf_gg_{letter-spacing:0}.___SInputMask_9ubmf_gg_ .___SValue_9ubmf_gg_:focus{outline:0}.___SIndicator_9ubmf_gg_{color:var(--intergalactic-text-secondary, #6c6e79)}.___SRangeIndicator_9ubmf_gg_{border-radius:50%;flex-shrink:0}.___SRangeIndicator_9ubmf_gg_._range_value_9ubmf_gg_{background-color:var(--intergalactic-date-picker-cell-active, #2bb3ff)}.___SRangeIndicator_9ubmf_gg_._range_compare_9ubmf_gg_{background-color:var(--intergalactic-date-picker-cell-comparison-active, #8649e1)}.___SRangeIndicator_9ubmf_gg_.__disabled_9ubmf_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3)}.___SHumanizedDate_9ubmf_gg_{position:absolute;pointer-events:none;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;width:100%}.___SMask_9ubmf_gg_{letter-spacing:0;white-space:nowrap;overflow:hidden}.___SDateRange_9ubmf_gg_ .___SMask_9ubmf_gg_,.___SDateRange_9ubmf_gg_ .___SValue_9ubmf_gg_,.___SSingleDateInput_9ubmf_gg_ .___SMask_9ubmf_gg_,.___SSingleDateInput_9ubmf_gg_ .___SValue_9ubmf_gg_{opacity:0}.___SSingleDateInput_9ubmf_gg_:focus-within .___SHumanizedDate_9ubmf_gg_{opacity:0;z-index:var(--intergalactic-z-index-deep, -999)}.___SSingleDateInput_9ubmf_gg_:focus-within .___SMask_9ubmf_gg_,.___SSingleDateInput_9ubmf_gg_:focus-within .___SValue_9ubmf_gg_{opacity:1}.___SDateRange_9ubmf_gg_:focus-within .___SHumanizedDate_9ubmf_gg_{opacity:0;z-index:var(--intergalactic-z-index-deep, -999)}.___SDateRange_9ubmf_gg_:focus-within .___SMask_9ubmf_gg_,.___SDateRange_9ubmf_gg_:focus-within .___SValue_9ubmf_gg_{opacity:1}.___SInputMask_9ubmf_gg_.__noHumanizedDate_9ubmf_gg_ .___SMask_9ubmf_gg_,.___SInputMask_9ubmf_gg_.__noHumanizedDate_9ubmf_gg_ .___SValue_9ubmf_gg_{opacity:1}.___SDateRange_9ubmf_gg_ .___SInputMask_9ubmf_gg_:focus-within .___SMask_9ubmf_gg_{background-color:var(--intergalactic-bg-highlight-focus, rgba(0, 143, 248, 0.2))}.___SDateRange_9ubmf_gg_:focus-within .___SRangeSep_9ubmf_gg_,.___SRangeSep_9ubmf_gg_.__fulfilled_9ubmf_gg_{color:var(--intergalactic-text-primary, #191b23)}.___SRangeComparatorHeader_9ubmf_gg_{border-bottom:1px solid var(--intergalactic-border-primary, #c4c7cf)}.___SRangeCalendar_9ubmf_gg_,.___SRangeComparatorHeader_9ubmf_gg_{padding:var(--intergalactic-spacing-4x, 16px)}.___SFooter_9ubmf_gg_{border-top:1px solid var(--intergalactic-border-primary, #c4c7cf)}.___SFooter_9ubmf_gg_,.___SPeriodsList_9ubmf_gg_{padding:var(--intergalactic-spacing-4x, 16px)}.___STooltip_9ubmf_gg_{padding:var(--intergalactic-spacing-3x, 12px)}.___SCompareToggle_9ubmf_gg_{white-space:nowrap}@media (prefers-reduced-motion){.___SInputMask_9ubmf_gg_{transition:none}}", /*__inner_css_end__*/"9ubmf_gg_"),
|
|
38
23
|
/*__reshadow_css_end__*/
|
|
39
24
|
{
|
|
40
|
-
"__SHeader": "
|
|
41
|
-
"__STitle": "
|
|
42
|
-
"__SToday": "
|
|
43
|
-
"__SPeriod": "
|
|
44
|
-
"__SButton": "
|
|
45
|
-
"__SInner": "
|
|
46
|
-
"__SInputMask": "
|
|
47
|
-
"_animationsDisabled": "
|
|
48
|
-
"__SIndicator": "
|
|
49
|
-
"__SRangeIndicator": "
|
|
50
|
-
"_range_value": "
|
|
51
|
-
"_range_compare": "
|
|
52
|
-
"_disabled": "
|
|
53
|
-
"__SHumanizedDate": "
|
|
54
|
-
"__SMask": "
|
|
55
|
-
"__SSingleDateInput": "
|
|
56
|
-
"__SValue": "
|
|
57
|
-
"__SDateRange": "
|
|
58
|
-
"_noHumanizedDate": "
|
|
59
|
-
"__SRangeSep": "
|
|
60
|
-
"_fulfilled": "
|
|
61
|
-
"__SRangeComparatorHeader": "
|
|
62
|
-
"__SRangeCalendar": "
|
|
63
|
-
"__SFooter": "
|
|
64
|
-
"__SPeriodsList": "
|
|
65
|
-
"__STooltip": "
|
|
66
|
-
"__SCompareToggle": "
|
|
67
|
-
"__SPopper": "
|
|
25
|
+
"__SHeader": "___SHeader_9ubmf_gg_",
|
|
26
|
+
"__STitle": "___STitle_9ubmf_gg_",
|
|
27
|
+
"__SToday": "___SToday_9ubmf_gg_",
|
|
28
|
+
"__SPeriod": "___SPeriod_9ubmf_gg_",
|
|
29
|
+
"__SButton": "___SButton_9ubmf_gg_",
|
|
30
|
+
"__SInner": "___SInner_9ubmf_gg_",
|
|
31
|
+
"__SInputMask": "___SInputMask_9ubmf_gg_",
|
|
32
|
+
"_animationsDisabled": "__animationsDisabled_9ubmf_gg_",
|
|
33
|
+
"__SIndicator": "___SIndicator_9ubmf_gg_",
|
|
34
|
+
"__SRangeIndicator": "___SRangeIndicator_9ubmf_gg_",
|
|
35
|
+
"_range_value": "_range_value_9ubmf_gg_",
|
|
36
|
+
"_range_compare": "_range_compare_9ubmf_gg_",
|
|
37
|
+
"_disabled": "__disabled_9ubmf_gg_",
|
|
38
|
+
"__SHumanizedDate": "___SHumanizedDate_9ubmf_gg_",
|
|
39
|
+
"__SMask": "___SMask_9ubmf_gg_",
|
|
40
|
+
"__SSingleDateInput": "___SSingleDateInput_9ubmf_gg_",
|
|
41
|
+
"__SValue": "___SValue_9ubmf_gg_",
|
|
42
|
+
"__SDateRange": "___SDateRange_9ubmf_gg_",
|
|
43
|
+
"_noHumanizedDate": "__noHumanizedDate_9ubmf_gg_",
|
|
44
|
+
"__SRangeSep": "___SRangeSep_9ubmf_gg_",
|
|
45
|
+
"_fulfilled": "__fulfilled_9ubmf_gg_",
|
|
46
|
+
"__SRangeComparatorHeader": "___SRangeComparatorHeader_9ubmf_gg_",
|
|
47
|
+
"__SRangeCalendar": "___SRangeCalendar_9ubmf_gg_",
|
|
48
|
+
"__SFooter": "___SFooter_9ubmf_gg_",
|
|
49
|
+
"__SPeriodsList": "___SPeriodsList_9ubmf_gg_",
|
|
50
|
+
"__STooltip": "___STooltip_9ubmf_gg_",
|
|
51
|
+
"__SCompareToggle": "___SCompareToggle_9ubmf_gg_",
|
|
52
|
+
"__SPopper": "___SPopper_9ubmf_gg_"
|
|
68
53
|
});
|
|
69
54
|
import { datesIntersects } from '../utils/datesIntersects';
|
|
70
55
|
import { includesDate } from '../utils/includesDate';
|
|
71
|
-
|
|
56
|
+
const defaultAllowedParts = {
|
|
72
57
|
year: true,
|
|
73
58
|
month: true,
|
|
74
59
|
day: true
|
|
75
60
|
};
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
61
|
+
const exampleDate = new Date(2000, 4, 29);
|
|
62
|
+
class InputTriggerRoot extends Component {
|
|
63
|
+
getSingleDateInputProps() {
|
|
64
|
+
const {
|
|
65
|
+
children: _children,
|
|
66
|
+
id,
|
|
67
|
+
role: _role,
|
|
68
|
+
'aria-haspopup': ariaHasPopup,
|
|
69
|
+
// 'aria-expanded': ariaExpanded,
|
|
70
|
+
'aria-label': _ariaLabel,
|
|
71
|
+
style: _style,
|
|
72
|
+
...otherProps
|
|
73
|
+
} = this.asProps;
|
|
74
|
+
return {
|
|
75
|
+
...otherProps,
|
|
76
|
+
ariaHasPopup,
|
|
77
|
+
inputId: id
|
|
78
|
+
};
|
|
81
79
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
return _objectSpread(_objectSpread({}, otherProps), {}, {
|
|
111
|
-
ariaHasPopup: ariaHasPopup,
|
|
112
|
-
inputId: id
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
}, {
|
|
116
|
-
key: "render",
|
|
117
|
-
value: function render() {
|
|
118
|
-
var _ref = this.asProps,
|
|
119
|
-
_ref8;
|
|
120
|
-
var SInputTrigger = Box;
|
|
121
|
-
var _this$asProps3 = this.asProps,
|
|
122
|
-
Children = _this$asProps3.Children,
|
|
123
|
-
style = _this$asProps3.style,
|
|
124
|
-
getI18nText = _this$asProps3.getI18nText;
|
|
125
|
-
return _ref8 = sstyled(style), /*#__PURE__*/React.createElement(SInputTrigger, _ref8.cn("SInputTrigger", _objectSpread({}, _assignProps({
|
|
80
|
+
getDateRangeProps() {
|
|
81
|
+
const {
|
|
82
|
+
children: _children,
|
|
83
|
+
id,
|
|
84
|
+
role: _rolw,
|
|
85
|
+
'aria-haspopup': ariaHasPopup,
|
|
86
|
+
'aria-label': _ariaLabel,
|
|
87
|
+
// 'aria-expanded': ariaExpanded,
|
|
88
|
+
style: _style,
|
|
89
|
+
...otherProps
|
|
90
|
+
} = this.asProps;
|
|
91
|
+
return {
|
|
92
|
+
...otherProps,
|
|
93
|
+
ariaHasPopup,
|
|
94
|
+
inputId: id
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
render() {
|
|
98
|
+
var _ref = this.asProps,
|
|
99
|
+
_ref8;
|
|
100
|
+
const SInputTrigger = Box;
|
|
101
|
+
const {
|
|
102
|
+
Children,
|
|
103
|
+
style,
|
|
104
|
+
getI18nText
|
|
105
|
+
} = this.asProps;
|
|
106
|
+
return _ref8 = sstyled(style), /*#__PURE__*/React.createElement(SInputTrigger, _ref8.cn("SInputTrigger", {
|
|
107
|
+
..._assignProps({
|
|
126
108
|
"aria-label": getI18nText('input'),
|
|
127
109
|
"__excludeProps": ['onChange', 'value', 'role', 'id']
|
|
128
|
-
}, _ref)
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
110
|
+
}, _ref)
|
|
111
|
+
}), /*#__PURE__*/React.createElement(Children, _ref8.cn("Children", {})));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
132
114
|
_defineProperty(InputTriggerRoot, "displayName", 'InputTrigger');
|
|
133
115
|
_defineProperty(InputTriggerRoot, "style", style);
|
|
134
116
|
_defineProperty(InputTriggerRoot, "defaultProps", {
|
|
135
117
|
duration: 300,
|
|
136
118
|
popoverVisible: true
|
|
137
119
|
});
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
143
|
-
args[_key] = arguments[_key];
|
|
144
|
-
}
|
|
145
|
-
_this = _callSuper(this, SingleDateInputRoot, [].concat(args));
|
|
146
|
-
_defineProperty(_this, "state", {
|
|
120
|
+
class SingleDateInputRoot extends Component {
|
|
121
|
+
constructor(...args) {
|
|
122
|
+
super(...args);
|
|
123
|
+
_defineProperty(this, "state", {
|
|
147
124
|
errorText: null,
|
|
148
125
|
showError: false,
|
|
149
126
|
focused: false
|
|
150
127
|
});
|
|
151
|
-
_defineProperty(
|
|
152
|
-
|
|
128
|
+
_defineProperty(this, "handleFocus", () => {
|
|
129
|
+
this.setState({
|
|
153
130
|
focused: true
|
|
154
131
|
});
|
|
155
132
|
});
|
|
156
|
-
_defineProperty(
|
|
157
|
-
|
|
133
|
+
_defineProperty(this, "handleBlur", () => {
|
|
134
|
+
this.setState({
|
|
158
135
|
focused: false
|
|
159
136
|
});
|
|
160
137
|
});
|
|
161
|
-
_defineProperty(
|
|
162
|
-
if (value ===
|
|
163
|
-
|
|
138
|
+
_defineProperty(this, "handleInputMaskPipeBlock", value => {
|
|
139
|
+
if (value === this.asProps.disabledDateInputAttempt) return;
|
|
140
|
+
this.handlers.disabledDateInputAttempt(value);
|
|
164
141
|
});
|
|
165
|
-
return _this;
|
|
166
142
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
if (errorText === undefined) {
|
|
179
|
-
var key = 'unavailableDate';
|
|
180
|
-
if (_this2.asProps.parts && !_this2.asProps.parts.day) {
|
|
181
|
-
key = 'unavailableMonth';
|
|
182
|
-
}
|
|
183
|
-
errorText = _this2.asProps.getI18nText(key);
|
|
184
|
-
}
|
|
185
|
-
if (typeof errorText === 'function') {
|
|
186
|
-
errorText = errorText(date);
|
|
143
|
+
uncontrolledProps() {
|
|
144
|
+
return {
|
|
145
|
+
disabledDateInputAttempt: [null, date => {
|
|
146
|
+
let errorText = this.state.errorText;
|
|
147
|
+
let showError = false;
|
|
148
|
+
if (date !== null) {
|
|
149
|
+
errorText = this.asProps.disabledErrorText;
|
|
150
|
+
if (errorText === undefined) {
|
|
151
|
+
let key = 'unavailableDate';
|
|
152
|
+
if (this.asProps.parts && !this.asProps.parts.day) {
|
|
153
|
+
key = 'unavailableMonth';
|
|
187
154
|
}
|
|
188
|
-
|
|
155
|
+
errorText = this.asProps.getI18nText(key);
|
|
189
156
|
}
|
|
190
|
-
|
|
191
|
-
errorText
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
157
|
+
if (typeof errorText === 'function') {
|
|
158
|
+
errorText = errorText(date);
|
|
159
|
+
}
|
|
160
|
+
showError = this.asProps.disabledErrorText !== null;
|
|
161
|
+
}
|
|
162
|
+
this.setState({
|
|
163
|
+
errorText,
|
|
164
|
+
showError
|
|
165
|
+
});
|
|
166
|
+
}]
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
getMaskedInputProps() {
|
|
170
|
+
const {
|
|
171
|
+
value,
|
|
172
|
+
onChange,
|
|
173
|
+
onDisplayedPeriodChange,
|
|
174
|
+
locale,
|
|
175
|
+
w: _w,
|
|
176
|
+
ariaHasPopup: _ariaHasPopup,
|
|
177
|
+
showError: _showError,
|
|
178
|
+
...otherProps
|
|
179
|
+
} = this.asProps;
|
|
180
|
+
return {
|
|
181
|
+
'date': value,
|
|
182
|
+
'onDateChange': onChange,
|
|
183
|
+
onDisplayedPeriodChange,
|
|
184
|
+
locale,
|
|
185
|
+
'aria-haspopup': 'true',
|
|
186
|
+
'onMaskPipeBlock': this.handleInputMaskPipeBlock,
|
|
187
|
+
...otherProps
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
render() {
|
|
191
|
+
var _ref2 = this.asProps,
|
|
192
|
+
_ref9;
|
|
193
|
+
const {
|
|
194
|
+
Children,
|
|
195
|
+
forwardRef,
|
|
196
|
+
styles,
|
|
197
|
+
state,
|
|
198
|
+
showError: showErrorProps,
|
|
199
|
+
popoverVisible
|
|
200
|
+
} = this.asProps;
|
|
201
|
+
const {
|
|
202
|
+
errorText,
|
|
203
|
+
showError: showErrorState,
|
|
204
|
+
focused
|
|
205
|
+
} = this.state;
|
|
206
|
+
const showError = showErrorState && showErrorProps;
|
|
207
|
+
const SSingleDateInput = InputMask;
|
|
208
|
+
return _ref9 = sstyled(styles), /*#__PURE__*/React.createElement(SSingleDateInput, _ref9.cn("SSingleDateInput", {
|
|
209
|
+
..._assignProps2({
|
|
237
210
|
"tag": Tooltip,
|
|
238
211
|
"placement": 'top-start',
|
|
239
212
|
"title": errorText,
|
|
@@ -244,246 +217,233 @@ var SingleDateInputRoot = /*#__PURE__*/function (_Component2) {
|
|
|
244
217
|
"onFocus": this.handleFocus,
|
|
245
218
|
"onBlur": this.handleBlur,
|
|
246
219
|
"__excludeProps": ['onChange', 'style', 'aria-expanded']
|
|
247
|
-
}, _ref2)
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}
|
|
220
|
+
}, _ref2)
|
|
221
|
+
}), /*#__PURE__*/React.createElement(NeighborLocation, _ref9.cn("NeighborLocation", {}), /*#__PURE__*/React.createElement(Children, _ref9.cn("Children", {}))));
|
|
222
|
+
}
|
|
223
|
+
}
|
|
251
224
|
_defineProperty(SingleDateInputRoot, "displayName", 'SingleDateInput');
|
|
252
225
|
_defineProperty(SingleDateInputRoot, "style", style);
|
|
253
226
|
_defineProperty(SingleDateInputRoot, "defaultProps", {
|
|
254
|
-
children:
|
|
255
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SingleDateInput.Indicator, null), /*#__PURE__*/React.createElement(SingleDateInput.MaskedInput, null));
|
|
256
|
-
},
|
|
227
|
+
children: () => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SingleDateInput.Indicator, null), /*#__PURE__*/React.createElement(SingleDateInput.MaskedInput, null)),
|
|
257
228
|
defaultDisabledDateInputAttempt: false,
|
|
258
229
|
showError: true
|
|
259
230
|
});
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
265
|
-
args[_key2] = arguments[_key2];
|
|
266
|
-
}
|
|
267
|
-
_this3 = _callSuper(this, DateRangeRoot, [].concat(args));
|
|
268
|
-
_defineProperty(_this3, "state", {
|
|
231
|
+
class DateRangeRoot extends Component {
|
|
232
|
+
constructor(...args) {
|
|
233
|
+
super(...args);
|
|
234
|
+
_defineProperty(this, "state", {
|
|
269
235
|
containerFocused: false,
|
|
270
236
|
errorText: null,
|
|
271
237
|
showError: false,
|
|
272
238
|
lastChangedInput: 'from'
|
|
273
239
|
});
|
|
274
|
-
_defineProperty(
|
|
275
|
-
_defineProperty(
|
|
276
|
-
_defineProperty(
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
240
|
+
_defineProperty(this, "fromRef", /*#__PURE__*/React.createRef());
|
|
241
|
+
_defineProperty(this, "toRef", /*#__PURE__*/React.createRef());
|
|
242
|
+
_defineProperty(this, "handleFromChange", (value, event) => {
|
|
243
|
+
const {
|
|
244
|
+
onChange
|
|
245
|
+
} = this.asProps;
|
|
246
|
+
const prevValue = [this.asProps.value?.[0] ?? null, this.asProps.value?.[1] ?? null];
|
|
280
247
|
onChange([value, prevValue[1]], event);
|
|
281
248
|
if (value) {
|
|
282
|
-
if (!
|
|
283
|
-
|
|
284
|
-
setTimeout(
|
|
285
|
-
if (!
|
|
286
|
-
|
|
249
|
+
if (!this.toRef.current) return;
|
|
250
|
+
this.toRef.current.focus();
|
|
251
|
+
setTimeout(() => {
|
|
252
|
+
if (!this.toRef.current) return;
|
|
253
|
+
this.toRef.current.setSelectionRange(0, 0);
|
|
287
254
|
}, 0);
|
|
288
255
|
}
|
|
289
256
|
});
|
|
290
|
-
_defineProperty(
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
257
|
+
_defineProperty(this, "handleToChange", (value, event) => {
|
|
258
|
+
const {
|
|
259
|
+
onChange
|
|
260
|
+
} = this.asProps;
|
|
261
|
+
const prevValue = [this.asProps.value?.[0] ?? null, this.asProps.value?.[1] ?? null];
|
|
294
262
|
onChange([prevValue[0], value], event);
|
|
295
263
|
});
|
|
296
|
-
_defineProperty(
|
|
297
|
-
if (!
|
|
298
|
-
if (!
|
|
299
|
-
|
|
264
|
+
_defineProperty(this, "handleFromKeydown", event => {
|
|
265
|
+
if (!this.toRef.current) return;
|
|
266
|
+
if (!this.fromRef.current) return;
|
|
267
|
+
this.setState({
|
|
300
268
|
lastChangedInput: 'from'
|
|
301
269
|
});
|
|
302
|
-
if (event.key === 'ArrowRight' &&
|
|
303
|
-
|
|
304
|
-
setTimeout(
|
|
305
|
-
|
|
270
|
+
if (event.key === 'ArrowRight' && this.fromRef.current.selectionStart === this.fromRef.current.value.length && this.fromRef.current.selectionEnd === this.fromRef.current.value.length) {
|
|
271
|
+
this.toRef.current.focus();
|
|
272
|
+
setTimeout(() => {
|
|
273
|
+
this.toRef.current.setSelectionRange(0, 0);
|
|
306
274
|
}, 0);
|
|
307
275
|
}
|
|
308
276
|
});
|
|
309
|
-
_defineProperty(
|
|
310
|
-
if (!
|
|
311
|
-
if (!
|
|
312
|
-
|
|
277
|
+
_defineProperty(this, "handleToKeydown", event => {
|
|
278
|
+
if (!this.toRef.current) return;
|
|
279
|
+
if (!this.fromRef.current) return;
|
|
280
|
+
this.setState({
|
|
313
281
|
lastChangedInput: 'to'
|
|
314
282
|
});
|
|
315
|
-
if (event.key === 'Backspace' && !
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
setTimeout(
|
|
319
|
-
|
|
283
|
+
if (event.key === 'Backspace' && !this.toRef.current.value) {
|
|
284
|
+
const value = this.fromRef.current.value;
|
|
285
|
+
this.fromRef.current.focus();
|
|
286
|
+
setTimeout(() => {
|
|
287
|
+
this.fromRef.current.setSelectionRange(value.length, value.length);
|
|
320
288
|
}, 0);
|
|
321
289
|
}
|
|
322
|
-
if (event.key === 'ArrowLeft' &&
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
setTimeout(
|
|
326
|
-
|
|
290
|
+
if (event.key === 'ArrowLeft' && this.toRef.current.selectionStart === 0 && this.toRef.current.selectionEnd === 0) {
|
|
291
|
+
const value = this.fromRef.current.value;
|
|
292
|
+
this.fromRef.current.focus();
|
|
293
|
+
setTimeout(() => {
|
|
294
|
+
this.fromRef.current.setSelectionRange(value.length, value.length);
|
|
327
295
|
}, 0);
|
|
328
296
|
}
|
|
329
297
|
});
|
|
330
|
-
_defineProperty(
|
|
331
|
-
if (value ===
|
|
332
|
-
|
|
298
|
+
_defineProperty(this, "handleInputMaskPipeBlock", value => {
|
|
299
|
+
if (value === this.asProps.disabledDateInputAttempt) return;
|
|
300
|
+
this.handlers.disabledDateInputAttempt(value);
|
|
333
301
|
});
|
|
334
|
-
_defineProperty(
|
|
335
|
-
|
|
302
|
+
_defineProperty(this, "handleFocus", () => {
|
|
303
|
+
this.setState({
|
|
336
304
|
containerFocused: true
|
|
337
305
|
});
|
|
338
306
|
});
|
|
339
|
-
_defineProperty(
|
|
340
|
-
|
|
307
|
+
_defineProperty(this, "handleBlur", () => {
|
|
308
|
+
this.setState({
|
|
341
309
|
containerFocused: false
|
|
342
310
|
});
|
|
343
311
|
});
|
|
344
|
-
_defineProperty(
|
|
345
|
-
|
|
346
|
-
|
|
312
|
+
_defineProperty(this, "updateDisabledDateInputAttempt", value => {
|
|
313
|
+
const {
|
|
314
|
+
disabledDates
|
|
315
|
+
} = this.asProps;
|
|
316
|
+
let invalid = false;
|
|
347
317
|
if (value) {
|
|
348
|
-
if (value[0] && value[1]) invalid = disabledDates.some(datesIntersects([value[0], value[1]],
|
|
318
|
+
if (value[0] && value[1]) invalid = disabledDates.some(datesIntersects([value[0], value[1]], this.asProps.unit));else if (value[0]) invalid = disabledDates.some(includesDate(dayjs(value[0]), this.asProps.unit));else if (value[1]) invalid = disabledDates.some(includesDate(dayjs(value[1]), this.asProps.unit));
|
|
349
319
|
}
|
|
350
320
|
if (invalid) {
|
|
351
|
-
|
|
352
|
-
setTimeout(
|
|
353
|
-
if (value ===
|
|
354
|
-
|
|
321
|
+
const invalidValue = this.state.lastChangedInput === 'to' ? value[1] : value[0];
|
|
322
|
+
setTimeout(() => {
|
|
323
|
+
if (value === this.asProps.disabledDateInputAttempt) return;
|
|
324
|
+
this.handlers.disabledDateInputAttempt(invalidValue);
|
|
355
325
|
}, 0);
|
|
356
326
|
}
|
|
357
327
|
});
|
|
358
|
-
return _this3;
|
|
359
328
|
}
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
if (errorText === undefined) {
|
|
372
|
-
var key = 'unavailableDate';
|
|
373
|
-
if (_this4.asProps.parts && !_this4.asProps.parts.day) {
|
|
374
|
-
key = 'unavailableMonth';
|
|
375
|
-
}
|
|
376
|
-
if (_this4.state.lastChangedInput === 'to') {
|
|
377
|
-
key = 'unavailableEndDate';
|
|
378
|
-
if (_this4.asProps.parts && !_this4.asProps.parts.day) {
|
|
379
|
-
key = 'unavailableEndMonth';
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
errorText = _this4.asProps.getI18nText(key);
|
|
329
|
+
uncontrolledProps() {
|
|
330
|
+
return {
|
|
331
|
+
disabledDateInputAttempt: [null, date => {
|
|
332
|
+
let errorText = this.state.errorText;
|
|
333
|
+
let showError = false;
|
|
334
|
+
if (date !== null) {
|
|
335
|
+
errorText = this.asProps.disabledErrorText;
|
|
336
|
+
if (errorText === undefined) {
|
|
337
|
+
let key = 'unavailableDate';
|
|
338
|
+
if (this.asProps.parts && !this.asProps.parts.day) {
|
|
339
|
+
key = 'unavailableMonth';
|
|
383
340
|
}
|
|
384
|
-
if (
|
|
385
|
-
|
|
341
|
+
if (this.state.lastChangedInput === 'to') {
|
|
342
|
+
key = 'unavailableEndDate';
|
|
343
|
+
if (this.asProps.parts && !this.asProps.parts.day) {
|
|
344
|
+
key = 'unavailableEndMonth';
|
|
345
|
+
}
|
|
386
346
|
}
|
|
387
|
-
|
|
347
|
+
errorText = this.asProps.getI18nText(key);
|
|
388
348
|
}
|
|
389
|
-
|
|
390
|
-
errorText
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
}, {
|
|
463
|
-
key: "componentDidMount",
|
|
464
|
-
value: function componentDidMount() {
|
|
349
|
+
if (typeof errorText === 'function') {
|
|
350
|
+
errorText = errorText(date);
|
|
351
|
+
}
|
|
352
|
+
showError = this.asProps.disabledErrorText !== null;
|
|
353
|
+
}
|
|
354
|
+
this.setState({
|
|
355
|
+
errorText,
|
|
356
|
+
showError
|
|
357
|
+
});
|
|
358
|
+
}]
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
getFromMaskedInputProps() {
|
|
362
|
+
const {
|
|
363
|
+
value,
|
|
364
|
+
locale,
|
|
365
|
+
onDisplayedPeriodChange,
|
|
366
|
+
ariaHasPopup,
|
|
367
|
+
showError: _showError,
|
|
368
|
+
...otherProps
|
|
369
|
+
} = this.asProps;
|
|
370
|
+
return assignProps({
|
|
371
|
+
'ref': this.fromRef,
|
|
372
|
+
'date': value?.[0],
|
|
373
|
+
'onDateChange': this.handleFromChange,
|
|
374
|
+
'onKeyDown': this.handleFromKeydown,
|
|
375
|
+
locale,
|
|
376
|
+
'flex': 1,
|
|
377
|
+
onDisplayedPeriodChange,
|
|
378
|
+
'aria-haspopup': ariaHasPopup,
|
|
379
|
+
'onMaskPipeBlock': this.handleInputMaskPipeBlock,
|
|
380
|
+
'containerFocused': this.state.containerFocused
|
|
381
|
+
}, otherProps);
|
|
382
|
+
}
|
|
383
|
+
getToMaskedInputProps() {
|
|
384
|
+
const {
|
|
385
|
+
value,
|
|
386
|
+
locale,
|
|
387
|
+
onDisplayedPeriodChange,
|
|
388
|
+
ariaHasPopup,
|
|
389
|
+
inputId: _inputId,
|
|
390
|
+
showError: _showError,
|
|
391
|
+
...otherProps
|
|
392
|
+
} = this.asProps;
|
|
393
|
+
const ariaLabel = this.asProps.getI18nText('toDate', {
|
|
394
|
+
date: this.asProps.getI18nText('input')
|
|
395
|
+
});
|
|
396
|
+
return assignProps({
|
|
397
|
+
'ref': this.toRef,
|
|
398
|
+
'date': value?.[1],
|
|
399
|
+
'onDateChange': this.handleToChange,
|
|
400
|
+
'onKeyDown': this.handleToKeydown,
|
|
401
|
+
locale,
|
|
402
|
+
'flex': 1,
|
|
403
|
+
onDisplayedPeriodChange,
|
|
404
|
+
'aria-label': ariaLabel,
|
|
405
|
+
'aria-haspopup': ariaHasPopup,
|
|
406
|
+
'onMaskPipeBlock': this.handleInputMaskPipeBlock,
|
|
407
|
+
'containerFocused': this.state.containerFocused
|
|
408
|
+
}, otherProps);
|
|
409
|
+
}
|
|
410
|
+
getRangeSepProps() {
|
|
411
|
+
const {
|
|
412
|
+
value
|
|
413
|
+
} = this.asProps;
|
|
414
|
+
return {
|
|
415
|
+
fulfilled: !!(value && (value[0] || value[1]))
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
componentDidUpdate(prevProps) {
|
|
419
|
+
if (prevProps.value !== this.asProps.value) {
|
|
465
420
|
this.updateDisabledDateInputAttempt(this.asProps.value);
|
|
466
421
|
}
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
value
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
422
|
+
}
|
|
423
|
+
componentDidMount() {
|
|
424
|
+
this.updateDisabledDateInputAttempt(this.asProps.value);
|
|
425
|
+
}
|
|
426
|
+
render() {
|
|
427
|
+
var _ref3 = this.asProps,
|
|
428
|
+
_ref0;
|
|
429
|
+
const SDateRange = InputMask;
|
|
430
|
+
const {
|
|
431
|
+
Children,
|
|
432
|
+
styles,
|
|
433
|
+
w,
|
|
434
|
+
state,
|
|
435
|
+
showError: showErrorProps,
|
|
436
|
+
popoverVisible
|
|
437
|
+
} = this.asProps;
|
|
438
|
+
const {
|
|
439
|
+
errorText,
|
|
440
|
+
lastChangedInput,
|
|
441
|
+
showError: showErrorState,
|
|
442
|
+
containerFocused
|
|
443
|
+
} = this.state;
|
|
444
|
+
const showError = showErrorState && showErrorProps;
|
|
445
|
+
return _ref0 = sstyled(styles), /*#__PURE__*/React.createElement(SDateRange, _ref0.cn("SDateRange", {
|
|
446
|
+
..._assignProps3({
|
|
487
447
|
"tag": Tooltip,
|
|
488
448
|
"ignorePortalsStacking": true,
|
|
489
449
|
"placement": lastChangedInput === 'to' ? 'top-end' : 'top-start',
|
|
@@ -495,89 +455,94 @@ var DateRangeRoot = /*#__PURE__*/function (_Component3) {
|
|
|
495
455
|
"w": w,
|
|
496
456
|
"onFocus": this.handleFocus,
|
|
497
457
|
"onBlur": this.handleBlur
|
|
498
|
-
}, _ref3)
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
}
|
|
458
|
+
}, _ref3)
|
|
459
|
+
}), /*#__PURE__*/React.createElement(Children, _ref0.cn("Children", {})));
|
|
460
|
+
}
|
|
461
|
+
}
|
|
502
462
|
_defineProperty(DateRangeRoot, "displayName", 'DateRange');
|
|
503
463
|
_defineProperty(DateRangeRoot, "style", style);
|
|
504
464
|
_defineProperty(DateRangeRoot, "defaultProps", {
|
|
505
|
-
children:
|
|
506
|
-
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));
|
|
507
|
-
},
|
|
465
|
+
children: () => /*#__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)),
|
|
508
466
|
defaultDisabledDateInputAttempt: false,
|
|
509
467
|
showError: true
|
|
510
468
|
});
|
|
511
469
|
function FromMaskedInput(props) {
|
|
512
470
|
var _ref4 = arguments[0],
|
|
513
471
|
_ref1;
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
472
|
+
const SFromMaskedInput = MaskedInput;
|
|
473
|
+
const {
|
|
474
|
+
getI18nText
|
|
475
|
+
} = props;
|
|
476
|
+
return _ref1 = sstyled(props.styles), /*#__PURE__*/React.createElement(SFromMaskedInput, _ref1.cn("SFromMaskedInput", {
|
|
477
|
+
..._assignProps4({
|
|
478
|
+
"labelPrefix": getI18nText('fromDatePlaceholder')
|
|
479
|
+
}, _ref4)
|
|
480
|
+
}));
|
|
519
481
|
}
|
|
520
482
|
function ToMaskedInput(props) {
|
|
521
483
|
var _ref5 = arguments[0],
|
|
522
484
|
_ref10;
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
485
|
+
const SToMaskedInput = MaskedInput;
|
|
486
|
+
const {
|
|
487
|
+
getI18nText
|
|
488
|
+
} = props;
|
|
489
|
+
return _ref10 = sstyled(props.styles), /*#__PURE__*/React.createElement(SToMaskedInput, _ref10.cn("SToMaskedInput", {
|
|
490
|
+
..._assignProps5({
|
|
491
|
+
"labelPrefix": getI18nText('toDatePlaceholder')
|
|
492
|
+
}, _ref5)
|
|
493
|
+
}));
|
|
528
494
|
}
|
|
529
495
|
function Indicator(props) {
|
|
530
496
|
var _ref6 = arguments[0],
|
|
531
497
|
_ref11;
|
|
532
|
-
|
|
533
|
-
return _ref11 = sstyled(props.styles), /*#__PURE__*/React.createElement(SIndicator, _ref11.cn("SIndicator",
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
498
|
+
const SIndicator = InputMask.Addon;
|
|
499
|
+
return _ref11 = sstyled(props.styles), /*#__PURE__*/React.createElement(SIndicator, _ref11.cn("SIndicator", {
|
|
500
|
+
..._assignProps6({
|
|
501
|
+
"tag": Calendar,
|
|
502
|
+
"aria-hidden": 'true',
|
|
503
|
+
"tabIndex": -1
|
|
504
|
+
}, _ref6)
|
|
505
|
+
}));
|
|
538
506
|
}
|
|
539
507
|
function RangeSep(props) {
|
|
540
508
|
var _ref7 = arguments[0],
|
|
541
509
|
_ref12;
|
|
542
|
-
|
|
543
|
-
return _ref12 = sstyled(props.styles), /*#__PURE__*/React.createElement(SRangeSep, _ref12.cn("SRangeSep",
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
510
|
+
const SRangeSep = InputMask.Addon;
|
|
511
|
+
return _ref12 = sstyled(props.styles), /*#__PURE__*/React.createElement(SRangeSep, _ref12.cn("SRangeSep", {
|
|
512
|
+
..._assignProps7({
|
|
513
|
+
"tag": Flex,
|
|
514
|
+
"alignItems": 'center',
|
|
515
|
+
"justifyContent": 'center',
|
|
516
|
+
"pl": 0,
|
|
517
|
+
"flex": '0'
|
|
518
|
+
}, _ref7)
|
|
519
|
+
}), "\u2013");
|
|
550
520
|
}
|
|
551
|
-
function MaskedInput(
|
|
521
|
+
function MaskedInput({
|
|
522
|
+
date: outerValue,
|
|
523
|
+
onDateChange,
|
|
524
|
+
onDisplayedPeriodChange,
|
|
525
|
+
locale,
|
|
526
|
+
styles,
|
|
527
|
+
parts: allowedParts = defaultAllowedParts,
|
|
528
|
+
disabledDates,
|
|
529
|
+
forwardRef,
|
|
530
|
+
placeholders: providedPlaceholders,
|
|
531
|
+
labelPrefix = 'Date',
|
|
532
|
+
onMaskPipeBlock,
|
|
533
|
+
containerFocused,
|
|
534
|
+
animationsDisabled,
|
|
535
|
+
getI18nText,
|
|
536
|
+
inputId,
|
|
537
|
+
inputRole = 'combobox',
|
|
538
|
+
__excludeProps,
|
|
539
|
+
Root: _root,
|
|
540
|
+
...otherProps
|
|
541
|
+
}) {
|
|
552
542
|
var _ref13;
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
locale = _ref14.locale,
|
|
557
|
-
styles = _ref14.styles,
|
|
558
|
-
_ref14$parts = _ref14.parts,
|
|
559
|
-
allowedParts = _ref14$parts === void 0 ? defaultAllowedParts : _ref14$parts,
|
|
560
|
-
disabledDates = _ref14.disabledDates,
|
|
561
|
-
forwardRef = _ref14.forwardRef,
|
|
562
|
-
providedPlaceholders = _ref14.placeholders,
|
|
563
|
-
_ref14$labelPrefix = _ref14.labelPrefix,
|
|
564
|
-
labelPrefix = _ref14$labelPrefix === void 0 ? 'Date' : _ref14$labelPrefix,
|
|
565
|
-
onMaskPipeBlock = _ref14.onMaskPipeBlock,
|
|
566
|
-
containerFocused = _ref14.containerFocused,
|
|
567
|
-
animationsDisabled = _ref14.animationsDisabled,
|
|
568
|
-
getI18nText = _ref14.getI18nText,
|
|
569
|
-
inputId = _ref14.inputId,
|
|
570
|
-
_ref14$inputRole = _ref14.inputRole,
|
|
571
|
-
inputRole = _ref14$inputRole === void 0 ? 'combobox' : _ref14$inputRole,
|
|
572
|
-
__excludeProps = _ref14.__excludeProps,
|
|
573
|
-
_root = _ref14.Root,
|
|
574
|
-
otherProps = _objectWithoutProperties(_ref14, _excluded6);
|
|
575
|
-
var ref = React.useRef();
|
|
576
|
-
var _React$useState = React.useState(undefined),
|
|
577
|
-
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
578
|
-
width = _React$useState2[0],
|
|
579
|
-
setWidth = _React$useState2[1];
|
|
580
|
-
var placeholders = React.useMemo(function () {
|
|
543
|
+
const ref = React.useRef();
|
|
544
|
+
const [width, setWidth] = React.useState(undefined);
|
|
545
|
+
const placeholders = React.useMemo(() => {
|
|
581
546
|
if (providedPlaceholders) return providedPlaceholders;
|
|
582
547
|
return {
|
|
583
548
|
year: getI18nText('placeholder-years'),
|
|
@@ -588,51 +553,43 @@ function MaskedInput(_ref14) {
|
|
|
588
553
|
if (placeholders.year.length !== 1 || placeholders.month.length !== 1 || placeholders.day.length !== 1) {
|
|
589
554
|
// eslint-disable-next-line no-console
|
|
590
555
|
console.error({
|
|
591
|
-
placeholders
|
|
556
|
+
placeholders
|
|
592
557
|
});
|
|
593
|
-
throw new Error(
|
|
558
|
+
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] (${placeholders})`, placeholders);
|
|
594
559
|
}
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
sep = part.value;
|
|
612
|
-
}
|
|
613
|
-
if (order.length < 3 && ['day', 'month', 'year'].includes(part.type) && allowedParts[part.type]) {
|
|
614
|
-
order.push(part.type);
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
} catch (err) {
|
|
618
|
-
_iterator.e(err);
|
|
619
|
-
} finally {
|
|
620
|
-
_iterator.f();
|
|
560
|
+
const {
|
|
561
|
+
sep,
|
|
562
|
+
order
|
|
563
|
+
} = React.useMemo(() => {
|
|
564
|
+
const options = {
|
|
565
|
+
year: 'numeric',
|
|
566
|
+
month: 'numeric',
|
|
567
|
+
day: 'numeric'
|
|
568
|
+
};
|
|
569
|
+
const dateTimeFormat = new Intl.DateTimeFormat(locale, options);
|
|
570
|
+
let sep = undefined;
|
|
571
|
+
const order = [];
|
|
572
|
+
const parts = dateTimeFormat.formatToParts(exampleDate);
|
|
573
|
+
for (const part of parts) {
|
|
574
|
+
if (!sep && part.type === 'literal') {
|
|
575
|
+
sep = part.value;
|
|
621
576
|
}
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
577
|
+
if (order.length < 3 && ['day', 'month', 'year'].includes(part.type) && allowedParts[part.type]) {
|
|
578
|
+
order.push(part.type);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
sep = sep ?? ' ';
|
|
582
|
+
return {
|
|
583
|
+
sep,
|
|
584
|
+
order
|
|
585
|
+
};
|
|
586
|
+
}, [locale, allowedParts]);
|
|
587
|
+
const outer = React.useMemo(() => {
|
|
588
|
+
let outerDate = outerValue;
|
|
632
589
|
if (typeof outerValue === 'number' || typeof outerValue === 'string') {
|
|
633
590
|
outerDate = new Date(outerValue);
|
|
634
591
|
}
|
|
635
|
-
|
|
592
|
+
const validDate = outerDate && outerDate instanceof Date && !Number.isNaN(outerDate.getTime());
|
|
636
593
|
if (!validDate) return null;
|
|
637
594
|
return {
|
|
638
595
|
year: outerDate.getFullYear().toString().padStart(4, '0'),
|
|
@@ -640,89 +597,67 @@ function MaskedInput(_ref14) {
|
|
|
640
597
|
day: outerDate.getDate().toString().padStart(2, '0')
|
|
641
598
|
};
|
|
642
599
|
}, [outerValue]);
|
|
643
|
-
|
|
600
|
+
const stringifyValue = React.useCallback(value => {
|
|
644
601
|
if (!value) return null;
|
|
645
602
|
if (!value.year && !value.month && !value.day) return null;
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
if (!allowedParts[part]) continue;
|
|
653
|
-
if (part === 'year' && value.year) result.push(value.year);
|
|
654
|
-
if (part === 'month' && value.month) result.push(value.month);
|
|
655
|
-
if (part === 'day' && value.day) result.push(value.day);
|
|
656
|
-
}
|
|
657
|
-
} catch (err) {
|
|
658
|
-
_iterator2.e(err);
|
|
659
|
-
} finally {
|
|
660
|
-
_iterator2.f();
|
|
603
|
+
const result = [];
|
|
604
|
+
for (const part of order) {
|
|
605
|
+
if (!allowedParts[part]) continue;
|
|
606
|
+
if (part === 'year' && value.year) result.push(value.year);
|
|
607
|
+
if (part === 'month' && value.month) result.push(value.month);
|
|
608
|
+
if (part === 'day' && value.day) result.push(value.day);
|
|
661
609
|
}
|
|
662
610
|
return result.join(sep);
|
|
663
611
|
}, [order, allowedParts]);
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
return stringifyValue(internalValue);
|
|
670
|
-
}, [stringifyValue, internalValue]);
|
|
671
|
-
var lastKnownOuterValue = React.useRef(outer);
|
|
672
|
-
React.useEffect(function () {
|
|
673
|
-
var _lastKnownOuterValue$, _lastKnownOuterValue$2, _lastKnownOuterValue$3;
|
|
674
|
-
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)) {
|
|
612
|
+
const [internalValue, setInternalValue] = React.useState(outer);
|
|
613
|
+
const value = React.useMemo(() => stringifyValue(internalValue), [stringifyValue, internalValue]);
|
|
614
|
+
const lastKnownOuterValue = React.useRef(outer);
|
|
615
|
+
React.useEffect(() => {
|
|
616
|
+
if (lastKnownOuterValue.current?.day !== outer?.day || lastKnownOuterValue.current?.month !== outer?.month || lastKnownOuterValue.current?.year !== outer?.year) {
|
|
675
617
|
setInternalValue(outer);
|
|
676
618
|
}
|
|
677
619
|
lastKnownOuterValue.current = outer;
|
|
678
620
|
}, [outer, setInternalValue]);
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
for (
|
|
621
|
+
const pipeMask = React.useCallback(value => {
|
|
622
|
+
let placeholdersOnly = true;
|
|
623
|
+
for (let i = 0; i < value.length; i++) {
|
|
682
624
|
if (value[i] !== '_' && value[i] !== sep) {
|
|
683
625
|
placeholdersOnly = false;
|
|
684
626
|
break;
|
|
685
627
|
}
|
|
686
628
|
}
|
|
687
629
|
if (placeholdersOnly) {
|
|
688
|
-
onMaskPipeBlock
|
|
630
|
+
onMaskPipeBlock?.(null);
|
|
689
631
|
return '';
|
|
690
632
|
}
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
var part = _step3.value;
|
|
699
|
-
if (part === 'year' && allowedParts.year) offset += 4;
|
|
700
|
-
if (part === 'month' && allowedParts.month) offset += 2;
|
|
701
|
-
if (part === 'day' && allowedParts.day) offset += 2;
|
|
702
|
-
}
|
|
703
|
-
} catch (err) {
|
|
704
|
-
_iterator3.e(err);
|
|
705
|
-
} finally {
|
|
706
|
-
_iterator3.f();
|
|
633
|
+
const getOffsetTo = partName => {
|
|
634
|
+
const partsBefore = order.slice(0, order.indexOf(partName));
|
|
635
|
+
let offset = 0;
|
|
636
|
+
for (const part of partsBefore) {
|
|
637
|
+
if (part === 'year' && allowedParts.year) offset += 4;
|
|
638
|
+
if (part === 'month' && allowedParts.month) offset += 2;
|
|
639
|
+
if (part === 'day' && allowedParts.day) offset += 2;
|
|
707
640
|
}
|
|
708
641
|
offset += partsBefore.length * sep.length;
|
|
709
642
|
return offset;
|
|
710
643
|
};
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
for (
|
|
644
|
+
const indexesOfPipedChars = [];
|
|
645
|
+
const parsed = {};
|
|
646
|
+
const parts = value.split(sep);
|
|
647
|
+
for (const partName in placeholders) {
|
|
715
648
|
parsed[partName] = placeholders[partName];
|
|
716
649
|
}
|
|
717
|
-
for (
|
|
718
|
-
parsed[order[
|
|
650
|
+
for (let i = 0; i < order.length; i++) {
|
|
651
|
+
parsed[order[i]] = parts[i];
|
|
719
652
|
}
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
653
|
+
let {
|
|
654
|
+
year,
|
|
655
|
+
month,
|
|
656
|
+
day
|
|
657
|
+
} = parsed;
|
|
723
658
|
if (allowedParts.month) {
|
|
724
659
|
if (month[0] !== '_' && Number.parseInt(month[0], 10) > 1) {
|
|
725
|
-
month =
|
|
660
|
+
month = `0${month[0]}`;
|
|
726
661
|
indexesOfPipedChars.push(getOffsetTo('month'));
|
|
727
662
|
}
|
|
728
663
|
if (month === '00') month = '01';
|
|
@@ -730,95 +665,82 @@ function MaskedInput(_ref14) {
|
|
|
730
665
|
}
|
|
731
666
|
if (allowedParts.day) {
|
|
732
667
|
if (day[0] !== '_' && Number.parseInt(day[0], 10) > 3) {
|
|
733
|
-
day =
|
|
668
|
+
day = `0${day[0]}`;
|
|
734
669
|
indexesOfPipedChars.push(getOffsetTo('day'));
|
|
735
670
|
}
|
|
736
671
|
if (day === '00') day = '01';
|
|
737
672
|
if (day[0] !== '_' && day[1] !== '_' && Number.parseInt(day, 10) > 31) return false;
|
|
738
673
|
}
|
|
739
|
-
year = year.split('').map(
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
return _char3 === '_' ? placeholders.day : _char3;
|
|
747
|
-
}).join('');
|
|
748
|
-
var yearFulfilled = !allowedParts.year || year && year.length >= 4 && !year.includes(placeholders.year);
|
|
749
|
-
var monthFulfilled = !allowedParts.month || month && month.length === 2 && !month.includes(placeholders.month);
|
|
750
|
-
var dayFulfilled = !allowedParts.day || day && day.length === 2 && !day.includes(placeholders.day);
|
|
751
|
-
var fulfilled = yearFulfilled && monthFulfilled && dayFulfilled;
|
|
674
|
+
year = year.split('').map(char => char === '_' ? placeholders.year : char).join('');
|
|
675
|
+
month = month.split('').map(char => char === '_' ? placeholders.month : char).join('');
|
|
676
|
+
day = day.split('').map(char => char === '_' ? placeholders.day : char).join('');
|
|
677
|
+
const yearFulfilled = !allowedParts.year || year && year.length >= 4 && !year.includes(placeholders.year);
|
|
678
|
+
const monthFulfilled = !allowedParts.month || month && month.length === 2 && !month.includes(placeholders.month);
|
|
679
|
+
const dayFulfilled = !allowedParts.day || day && day.length === 2 && !day.includes(placeholders.day);
|
|
680
|
+
const fulfilled = yearFulfilled && monthFulfilled && dayFulfilled;
|
|
752
681
|
if (fulfilled) {
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
682
|
+
const date = new Date(0, 0, 0, 0, 0, 0, 0);
|
|
683
|
+
const yearParsed = allowedParts.year ? Number.parseInt(year, 10) : 0;
|
|
684
|
+
const monthParsed = allowedParts.month ? Number.parseInt(month, 10) - 1 : 0;
|
|
685
|
+
const dayParsed = allowedParts.day ? Number.parseInt(day, 10) : 1;
|
|
757
686
|
date.setFullYear(yearParsed, monthParsed, dayParsed);
|
|
758
|
-
if (disabledDates
|
|
759
|
-
onMaskPipeBlock
|
|
687
|
+
if (disabledDates?.some(includesDate(dayjs(date), 'date'))) {
|
|
688
|
+
onMaskPipeBlock?.(date);
|
|
760
689
|
return false;
|
|
761
690
|
}
|
|
762
691
|
if (allowedParts.day) {
|
|
763
692
|
if (date.getDate() !== Number.parseInt(day, 10)) {
|
|
764
|
-
onMaskPipeBlock
|
|
693
|
+
onMaskPipeBlock?.(date);
|
|
765
694
|
return false;
|
|
766
695
|
}
|
|
767
696
|
}
|
|
768
697
|
}
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
var part = _step4.value;
|
|
775
|
-
if (part === 'year') result.push(year);
|
|
776
|
-
if (part === 'month') result.push(month);
|
|
777
|
-
if (part === 'day') result.push(day);
|
|
778
|
-
}
|
|
779
|
-
} catch (err) {
|
|
780
|
-
_iterator4.e(err);
|
|
781
|
-
} finally {
|
|
782
|
-
_iterator4.f();
|
|
698
|
+
const result = [];
|
|
699
|
+
for (const part of order) {
|
|
700
|
+
if (part === 'year') result.push(year);
|
|
701
|
+
if (part === 'month') result.push(month);
|
|
702
|
+
if (part === 'day') result.push(day);
|
|
783
703
|
}
|
|
784
|
-
onMaskPipeBlock
|
|
704
|
+
onMaskPipeBlock?.(null);
|
|
785
705
|
return {
|
|
786
706
|
value: result.join(sep),
|
|
787
|
-
indexesOfPipedChars
|
|
707
|
+
indexesOfPipedChars
|
|
788
708
|
};
|
|
789
709
|
}, [placeholders, sep, order, allowedParts, disabledDates, onMaskPipeBlock]);
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
for (
|
|
710
|
+
const handleChange = React.useCallback(value => {
|
|
711
|
+
const parsed = {};
|
|
712
|
+
for (const partName in placeholders) {
|
|
793
713
|
parsed[partName] = placeholders[partName];
|
|
794
714
|
}
|
|
795
|
-
|
|
796
|
-
for (
|
|
715
|
+
const parts = value.split(sep);
|
|
716
|
+
for (let i = 0; i < order.length; i++) {
|
|
797
717
|
parsed[order[i]] = parts[i];
|
|
798
718
|
}
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
719
|
+
const {
|
|
720
|
+
year,
|
|
721
|
+
month,
|
|
722
|
+
day
|
|
723
|
+
} = parsed;
|
|
802
724
|
setInternalValue({
|
|
803
|
-
year
|
|
804
|
-
month
|
|
805
|
-
day
|
|
725
|
+
year,
|
|
726
|
+
month,
|
|
727
|
+
day
|
|
806
728
|
});
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
729
|
+
const yearFulfilled = !allowedParts.year || year && year.length >= 4 && !year.includes(placeholders.year);
|
|
730
|
+
const monthFulfilled = !allowedParts.month || month && month.length === 2 && !month.includes(placeholders.month);
|
|
731
|
+
const dayFulfilled = !allowedParts.day || day && day.length === 2 && !day.includes(placeholders.day);
|
|
732
|
+
const fulfilled = yearFulfilled && monthFulfilled && dayFulfilled;
|
|
811
733
|
if (fulfilled) {
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
734
|
+
const date = new Date(0, 0, 0, 0, 0, 0, 0);
|
|
735
|
+
const yearParsed = allowedParts.year ? Number.parseInt(year, 10) : 0;
|
|
736
|
+
const monthParsed = allowedParts.month ? Number.parseInt(month, 10) - 1 : 0;
|
|
737
|
+
const dayParsed = allowedParts.day ? Number.parseInt(day, 10) : 1;
|
|
816
738
|
date.setFullYear(yearParsed, monthParsed, dayParsed);
|
|
817
739
|
onDateChange(date);
|
|
818
740
|
lastKnownOuterValue.current = {
|
|
819
|
-
year
|
|
820
|
-
month
|
|
821
|
-
day
|
|
741
|
+
year,
|
|
742
|
+
month,
|
|
743
|
+
day
|
|
822
744
|
};
|
|
823
745
|
return;
|
|
824
746
|
}
|
|
@@ -827,44 +749,40 @@ function MaskedInput(_ref14) {
|
|
|
827
749
|
lastKnownOuterValue.current = null;
|
|
828
750
|
}
|
|
829
751
|
if (yearFulfilled && allowedParts.year) {
|
|
830
|
-
|
|
831
|
-
|
|
752
|
+
const date = new Date(0, 0, 0, 0, 0, 0, 0);
|
|
753
|
+
date.setFullYear(Number.parseInt(year, 10));
|
|
832
754
|
if (monthFulfilled && allowedParts.month) {
|
|
833
|
-
|
|
755
|
+
date.setMonth(Number.parseInt(month, 10) - 1);
|
|
834
756
|
}
|
|
835
|
-
onDisplayedPeriodChange(
|
|
757
|
+
onDisplayedPeriodChange(date);
|
|
836
758
|
}
|
|
837
759
|
}, [onDateChange, setInternalValue, placeholders, onDisplayedPeriodChange, order, allowedParts]);
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
var part = _step5.value;
|
|
845
|
-
if (part === 'year') result.push(placeholders.year + placeholders.year + placeholders.year + placeholders.year);
|
|
846
|
-
if (part === 'month') result.push(placeholders.month + placeholders.month);
|
|
847
|
-
if (part === 'day') result.push(placeholders.day + placeholders.day);
|
|
848
|
-
}
|
|
849
|
-
} catch (err) {
|
|
850
|
-
_iterator5.e(err);
|
|
851
|
-
} finally {
|
|
852
|
-
_iterator5.f();
|
|
760
|
+
const mask = React.useMemo(() => {
|
|
761
|
+
const result = [];
|
|
762
|
+
for (const part of order) {
|
|
763
|
+
if (part === 'year') result.push(placeholders.year + placeholders.year + placeholders.year + placeholders.year);
|
|
764
|
+
if (part === 'month') result.push(placeholders.month + placeholders.month);
|
|
765
|
+
if (part === 'day') result.push(placeholders.day + placeholders.day);
|
|
853
766
|
}
|
|
854
767
|
return result.join(sep);
|
|
855
768
|
}, [sep, order, placeholders]);
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
769
|
+
const aliases = React.useMemo(() => ({
|
|
770
|
+
[placeholders.year]: /\d/,
|
|
771
|
+
[placeholders.month]: /\d/,
|
|
772
|
+
[placeholders.day]: /\d/
|
|
773
|
+
}), [placeholders]);
|
|
774
|
+
const maskOnlySymbols = React.useMemo(() => ({
|
|
775
|
+
[placeholders.year]: true,
|
|
776
|
+
[placeholders.month]: true,
|
|
777
|
+
[placeholders.day]: true,
|
|
778
|
+
[sep]: true
|
|
779
|
+
}), [sep, placeholders]);
|
|
780
|
+
const humanizedDate = React.useMemo(() => {
|
|
781
|
+
let outerDate = outerValue;
|
|
864
782
|
if (typeof outerValue === 'number' || typeof outerValue === 'string') {
|
|
865
783
|
outerDate = new Date(outerValue);
|
|
866
784
|
}
|
|
867
|
-
|
|
785
|
+
const validDate = outerDate && outerDate instanceof Date && !Number.isNaN(outerDate.getTime());
|
|
868
786
|
if (!validDate) return null;
|
|
869
787
|
return new Intl.DateTimeFormat(locale, {
|
|
870
788
|
year: allowedParts.year ? 'numeric' : undefined,
|
|
@@ -872,55 +790,45 @@ function MaskedInput(_ref14) {
|
|
|
872
790
|
day: allowedParts.day ? 'numeric' : undefined
|
|
873
791
|
}).format(outerDate);
|
|
874
792
|
}, [outerValue, locale, allowedParts]);
|
|
875
|
-
useEnhancedEffect(
|
|
793
|
+
useEnhancedEffect(() => {
|
|
876
794
|
if (!ref.current) return;
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
for (
|
|
883
|
-
|
|
884
|
-
measureSpan.style[_style2] = computedStyle[_style2];
|
|
795
|
+
const stringsToMeasure = humanizedDate ? [humanizedDate, mask] : [mask];
|
|
796
|
+
const widths = [];
|
|
797
|
+
const measureSpan = document.createElement('span');
|
|
798
|
+
const computedStyle = window.getComputedStyle(ref.current);
|
|
799
|
+
const typographyRelatedStyles = ['height', 'font-size', 'font-family', 'font-weight', 'font-style', 'line-height', 'letter-spacing', 'text-transform', 'word-spacing'];
|
|
800
|
+
for (const style of typographyRelatedStyles) {
|
|
801
|
+
measureSpan.style[style] = computedStyle[style];
|
|
885
802
|
}
|
|
886
803
|
measureSpan.style.position = 'absolute';
|
|
887
804
|
measureSpan.style.visibility = 'hidden';
|
|
888
805
|
document.body.appendChild(measureSpan);
|
|
889
|
-
for (
|
|
890
|
-
var string = _stringsToMeasure[_i3];
|
|
806
|
+
for (const string of stringsToMeasure) {
|
|
891
807
|
measureSpan.innerHTML = string;
|
|
892
808
|
widths.push(measureSpan.offsetWidth);
|
|
893
809
|
}
|
|
894
810
|
measureSpan.remove();
|
|
895
|
-
|
|
811
|
+
const maxWidth = Math.max(...widths);
|
|
896
812
|
setWidth(maxWidth);
|
|
897
813
|
}, [locale, humanizedDate, allowedParts, mask]);
|
|
898
|
-
|
|
899
|
-
|
|
814
|
+
const SHumanizedDate = 'div';
|
|
815
|
+
const handleInputRef = React.useCallback(node => {
|
|
900
816
|
ref.current = node;
|
|
901
817
|
if (!node || node.tagName !== 'INPUT') return;
|
|
902
818
|
if (typeof forwardRef === 'function') forwardRef(node);else forwardRef.current = node;
|
|
903
819
|
}, [forwardRef]);
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
910
|
-
innerFocused = _React$useState8[0],
|
|
911
|
-
setInnerFocused = _React$useState8[1];
|
|
912
|
-
var focused = containerFocused !== null && containerFocused !== void 0 ? containerFocused : innerFocused;
|
|
913
|
-
var handleFocus = React.useCallback(function (event) {
|
|
914
|
-
var _otherProps$onFocus;
|
|
915
|
-
(_otherProps$onFocus = otherProps.onFocus) === null || _otherProps$onFocus === void 0 || _otherProps$onFocus.call(otherProps, event);
|
|
820
|
+
const [appliedWidth, setAppliedWidth] = React.useState(width);
|
|
821
|
+
const [innerFocused, setInnerFocused] = React.useState(false);
|
|
822
|
+
const focused = containerFocused ?? innerFocused;
|
|
823
|
+
const handleFocus = React.useCallback(event => {
|
|
824
|
+
otherProps.onFocus?.(event);
|
|
916
825
|
setInnerFocused(true);
|
|
917
826
|
}, []);
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
(_otherProps$onBlur = otherProps.onBlur) === null || _otherProps$onBlur === void 0 || _otherProps$onBlur.call(otherProps, event);
|
|
827
|
+
const handleBlur = React.useCallback(event => {
|
|
828
|
+
otherProps.onBlur?.(event);
|
|
921
829
|
setInnerFocused(false);
|
|
922
830
|
}, []);
|
|
923
|
-
useEnhancedEffect(
|
|
831
|
+
useEnhancedEffect(() => {
|
|
924
832
|
if (focused) return;
|
|
925
833
|
setAppliedWidth(width);
|
|
926
834
|
}, [width, focused]);
|
|
@@ -940,7 +848,7 @@ function MaskedInput(_ref14) {
|
|
|
940
848
|
focused: focused,
|
|
941
849
|
ref: handleInputRef,
|
|
942
850
|
pipe: pipeMask,
|
|
943
|
-
value: value
|
|
851
|
+
value: value ?? '',
|
|
944
852
|
onChange: handleChange,
|
|
945
853
|
noHumanizedDate: !humanizedDate,
|
|
946
854
|
animationsDisabled: animationsDisabled,
|
|
@@ -948,20 +856,20 @@ function MaskedInput(_ref14) {
|
|
|
948
856
|
inputMode: "numeric"
|
|
949
857
|
}), humanizedDate && /*#__PURE__*/React.createElement(SHumanizedDate, _ref13.cn("SHumanizedDate", {}), humanizedDate));
|
|
950
858
|
}
|
|
951
|
-
|
|
952
|
-
Indicator
|
|
953
|
-
MaskedInput
|
|
859
|
+
const SingleDateInput = createComponent(SingleDateInputRoot, {
|
|
860
|
+
Indicator,
|
|
861
|
+
MaskedInput
|
|
954
862
|
});
|
|
955
|
-
|
|
956
|
-
Indicator
|
|
957
|
-
RangeSep
|
|
958
|
-
FromMaskedInput
|
|
959
|
-
ToMaskedInput
|
|
863
|
+
const DateRange = createComponent(DateRangeRoot, {
|
|
864
|
+
Indicator,
|
|
865
|
+
RangeSep,
|
|
866
|
+
FromMaskedInput,
|
|
867
|
+
ToMaskedInput
|
|
960
868
|
});
|
|
961
|
-
|
|
869
|
+
const InputTrigger = createComponent(InputTriggerRoot, {
|
|
962
870
|
Addon: BaseTrigger.Addon,
|
|
963
|
-
SingleDateInput
|
|
964
|
-
DateRange
|
|
871
|
+
SingleDateInput,
|
|
872
|
+
DateRange
|
|
965
873
|
});
|
|
966
874
|
export default InputTrigger;
|
|
967
875
|
//# sourceMappingURL=InputTrigger.js.map
|