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