@semcore/date-picker 3.6.31 → 3.6.33
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 +16 -53
- package/lib/cjs/DatePicker.js.map +1 -1
- package/lib/cjs/DateRangePicker.js +9 -35
- package/lib/cjs/DateRangePicker.js.map +1 -1
- package/lib/cjs/MonthPicker.js +11 -36
- package/lib/cjs/MonthPicker.js.map +1 -1
- package/lib/cjs/MonthRangePicker.js +11 -38
- package/lib/cjs/MonthRangePicker.js.map +1 -1
- package/lib/cjs/components/ButtonTrigger.js +1 -12
- package/lib/cjs/components/ButtonTrigger.js.map +1 -1
- package/lib/cjs/components/Calendar.js +42 -125
- package/lib/cjs/components/Calendar.js.map +1 -1
- package/lib/cjs/components/InputTrigger.js +125 -270
- package/lib/cjs/components/InputTrigger.js.map +1 -1
- package/lib/cjs/components/PickerAbstract.js +35 -81
- package/lib/cjs/components/PickerAbstract.js.map +1 -1
- package/lib/cjs/components/RangePickerAbstract.js +52 -121
- package/lib/cjs/components/RangePickerAbstract.js.map +1 -1
- package/lib/cjs/components/index.js +18 -75
- package/lib/cjs/components/index.js.map +1 -1
- package/lib/cjs/index.js +0 -7
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js +0 -14
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js.map +1 -1
- package/lib/cjs/utils/cronTabScheduler.js +5 -31
- package/lib/cjs/utils/cronTabScheduler.js.map +1 -1
- package/lib/cjs/utils/formatDate.js +0 -4
- package/lib/cjs/utils/formatDate.js.map +1 -1
- package/lib/cjs/utils/includesDate.js +2 -11
- package/lib/cjs/utils/includesDate.js.map +1 -1
- package/lib/cjs/utils/shortDateRangeFormat.js +5 -25
- package/lib/cjs/utils/shortDateRangeFormat.js.map +1 -1
- package/lib/es6/DatePicker.js +16 -39
- package/lib/es6/DatePicker.js.map +1 -1
- package/lib/es6/DateRangePicker.js +9 -24
- package/lib/es6/DateRangePicker.js.map +1 -1
- package/lib/es6/MonthPicker.js +11 -26
- package/lib/es6/MonthPicker.js.map +1 -1
- package/lib/es6/MonthRangePicker.js +11 -26
- package/lib/es6/MonthRangePicker.js.map +1 -1
- package/lib/es6/components/ButtonTrigger.js +1 -3
- package/lib/es6/components/ButtonTrigger.js.map +1 -1
- package/lib/es6/components/Calendar.js +42 -119
- package/lib/es6/components/Calendar.js.map +1 -1
- package/lib/es6/components/InputTrigger.js +125 -256
- package/lib/es6/components/InputTrigger.js.map +1 -1
- package/lib/es6/components/PickerAbstract.js +35 -82
- package/lib/es6/components/PickerAbstract.js.map +1 -1
- package/lib/es6/components/RangePickerAbstract.js +52 -118
- package/lib/es6/components/RangePickerAbstract.js.map +1 -1
- package/lib/es6/components/index.js +19 -45
- package/lib/es6/components/index.js.map +1 -1
- package/lib/es6/index.js.map +1 -1
- package/lib/es6/translations/__intergalactic-dynamic-locales.js.map +1 -1
- package/lib/es6/utils/cronTabScheduler.js +5 -28
- package/lib/es6/utils/cronTabScheduler.js.map +1 -1
- package/lib/es6/utils/formatDate.js.map +1 -1
- package/lib/es6/utils/includesDate.js +2 -6
- package/lib/es6/utils/includesDate.js.map +1 -1
- package/lib/es6/utils/shortDateRangeFormat.js +5 -21
- package/lib/es6/utils/shortDateRangeFormat.js.map +1 -1
- package/package.json +1 -1
|
@@ -18,11 +18,11 @@ import { assignProps as _assignProps3 } from "@semcore/core";
|
|
|
18
18
|
import { assignProps as _assignProps2 } from "@semcore/core";
|
|
19
19
|
import { assignProps as _assignProps } from "@semcore/core";
|
|
20
20
|
var _excluded = ["children", "id", "role", "aria-haspopup", "aria-label", "style"],
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
_excluded2 = ["children", "id", "role", "aria-haspopup", "aria-label", "style"],
|
|
22
|
+
_excluded3 = ["value", "onChange", "onDisplayedPeriodChange", "locale", "w"],
|
|
23
|
+
_excluded4 = ["value", "locale", "onDisplayedPeriodChange"],
|
|
24
|
+
_excluded5 = ["value", "locale", "onDisplayedPeriodChange"],
|
|
25
|
+
_excluded6 = ["date", "onDateChange", "onDisplayedPeriodChange", "locale", "styles", "parts", "disabledDates", "forwardRef", "placeholders", "labelPrefix", "__excludeProps", "Root"];
|
|
26
26
|
import React from 'react';
|
|
27
27
|
import BaseTrigger from '@semcore/base-trigger';
|
|
28
28
|
import InputMask from '@semcore/input-mask';
|
|
@@ -32,33 +32,24 @@ import createComponent, { Root, sstyled, Component } from '@semcore/core';
|
|
|
32
32
|
import NeighborLocation from '@semcore/neighbor-location';
|
|
33
33
|
import includesDate from '../utils/includesDate';
|
|
34
34
|
import dayjs from 'dayjs';
|
|
35
|
-
|
|
36
35
|
/*__reshadow-styles__:"../style/date-picker.shadow.css"*/
|
|
37
|
-
var style = (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
,
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"__SSingleDateInput": "___SSingleDateInput_jazw5_gg_",
|
|
55
|
-
"__SValue": "___SValue_jazw5_gg_",
|
|
56
|
-
"__SDateRange": "___SDateRange_jazw5_gg_",
|
|
57
|
-
"__SMask": "___SMask_jazw5_gg_",
|
|
58
|
-
"_focus-within": "__focus-within_jazw5_gg_",
|
|
59
|
-
"_noHumanizedDate": "__noHumanizedDate_jazw5_gg_",
|
|
60
|
-
"__SRangeSep": "___SRangeSep_jazw5_gg_",
|
|
61
|
-
"_fulfilled": "__fulfilled_jazw5_gg_"
|
|
36
|
+
var style = ( /*__reshadow_css_start__*/_sstyled.insert( /*__inner_css_start__*/".___SPopper_m4rau_gg_{padding:var(--intergalactic-spacing-4x, 16px);outline:0}.___SPopper_m4rau_gg_::-moz-focus-inner{border:0;padding:0}.___SPopper_m4rau_gg_:active,.___SPopper_m4rau_gg_:focus{outline:0;text-decoration:none}@media (hover:hover){.___SPopper_m4rau_gg_:hover{outline:0;text-decoration:none}}.___SPopper_m4rau_gg_:focus{box-shadow:var(--intergalactic-keyboard-focus, 0px 0px 0px 3px rgba(0, 143, 248, 0.3))}.___SHeader_m4rau_gg_,.___STitle_m4rau_gg_{display:flex;align-items:center}.___STitle_m4rau_gg_{font-size:var(--intergalactic-fs-200, 14px);color:var(--intergalactic-text-primary, #191b23);height:32px;width:100%;justify-content:center}.___SToday_m4rau_gg_{display:flex;margin-top:var(--intergalactic-spacing-3x, 12px);justify-content:center}.___SPeriod_m4rau_gg_{display:flex;flex-direction:column;margin-bottom:var(--intergalactic-spacing-2x, 8px)}.___SInputMask_m4rau_gg_{color:var(--intergalactic-text-primary, #191b23)}.___SIndicator_m4rau_gg_{color:var(--intergalactic-text-secondary, #6c6e79)}.___SHumanizedDate_m4rau_gg_{position:absolute;pointer-events:none}.___SDateRange_m4rau_gg_ .___SMask_m4rau_gg_,.___SDateRange_m4rau_gg_ .___SValue_m4rau_gg_,.___SSingleDateInput_m4rau_gg_ .___SMask_m4rau_gg_,.___SSingleDateInput_m4rau_gg_ .___SValue_m4rau_gg_{opacity:0}.___SSingleDateInput_m4rau_gg_.__focus-within_m4rau_gg_ .___SHumanizedDate_m4rau_gg_{opacity:0;z-index:var(--intergalactic-z-index-deep, -999)}.___SSingleDateInput_m4rau_gg_:focus-within .___SHumanizedDate_m4rau_gg_{opacity:0;z-index:var(--intergalactic-z-index-deep, -999)}.___SSingleDateInput_m4rau_gg_.__focus-within_m4rau_gg_ .___SMask_m4rau_gg_,.___SSingleDateInput_m4rau_gg_.__focus-within_m4rau_gg_ .___SValue_m4rau_gg_{opacity:1}.___SSingleDateInput_m4rau_gg_:focus-within .___SMask_m4rau_gg_,.___SSingleDateInput_m4rau_gg_:focus-within .___SValue_m4rau_gg_{opacity:1}.___SDateRange_m4rau_gg_.__focus-within_m4rau_gg_ .___SHumanizedDate_m4rau_gg_{opacity:0;z-index:var(--intergalactic-z-index-deep, -999)}.___SDateRange_m4rau_gg_:focus-within .___SHumanizedDate_m4rau_gg_{opacity:0;z-index:var(--intergalactic-z-index-deep, -999)}.___SDateRange_m4rau_gg_.__focus-within_m4rau_gg_ .___SMask_m4rau_gg_,.___SDateRange_m4rau_gg_.__focus-within_m4rau_gg_ .___SValue_m4rau_gg_{opacity:1}.___SDateRange_m4rau_gg_:focus-within .___SMask_m4rau_gg_,.___SDateRange_m4rau_gg_:focus-within .___SValue_m4rau_gg_{opacity:1}.___SInputMask_m4rau_gg_.__noHumanizedDate_m4rau_gg_ .___SMask_m4rau_gg_,.___SInputMask_m4rau_gg_.__noHumanizedDate_m4rau_gg_ .___SValue_m4rau_gg_{opacity:1}.___SDateRange_m4rau_gg_ .___SInputMask_m4rau_gg_.__focus-within_m4rau_gg_ .___SMask_m4rau_gg_{background-color:var(--intergalactic-bg-highlight-focus, rgba(0, 143, 248, 0.2))}.___SDateRange_m4rau_gg_ .___SInputMask_m4rau_gg_:focus-within .___SMask_m4rau_gg_{background-color:var(--intergalactic-bg-highlight-focus, rgba(0, 143, 248, 0.2))}.___SDateRange_m4rau_gg_.__focus-within_m4rau_gg_ .___SRangeSep_m4rau_gg_,.___SRangeSep_m4rau_gg_.__fulfilled_m4rau_gg_{color:var(--intergalactic-text-primary, #191b23)}.___SDateRange_m4rau_gg_:focus-within .___SRangeSep_m4rau_gg_,.___SRangeSep_m4rau_gg_.__fulfilled_m4rau_gg_{color:var(--intergalactic-text-primary, #191b23)}" /*__inner_css_end__*/, "m4rau_gg_") /*__reshadow_css_end__*/, {
|
|
37
|
+
"__SPopper": "___SPopper_m4rau_gg_",
|
|
38
|
+
"__SHeader": "___SHeader_m4rau_gg_",
|
|
39
|
+
"__STitle": "___STitle_m4rau_gg_",
|
|
40
|
+
"__SToday": "___SToday_m4rau_gg_",
|
|
41
|
+
"__SPeriod": "___SPeriod_m4rau_gg_",
|
|
42
|
+
"__SInputMask": "___SInputMask_m4rau_gg_",
|
|
43
|
+
"__SIndicator": "___SIndicator_m4rau_gg_",
|
|
44
|
+
"__SHumanizedDate": "___SHumanizedDate_m4rau_gg_",
|
|
45
|
+
"__SSingleDateInput": "___SSingleDateInput_m4rau_gg_",
|
|
46
|
+
"__SValue": "___SValue_m4rau_gg_",
|
|
47
|
+
"__SDateRange": "___SDateRange_m4rau_gg_",
|
|
48
|
+
"__SMask": "___SMask_m4rau_gg_",
|
|
49
|
+
"_focus-within": "__focus-within_m4rau_gg_",
|
|
50
|
+
"_noHumanizedDate": "__noHumanizedDate_m4rau_gg_",
|
|
51
|
+
"__SRangeSep": "___SRangeSep_m4rau_gg_",
|
|
52
|
+
"_fulfilled": "__fulfilled_m4rau_gg_"
|
|
62
53
|
});
|
|
63
54
|
import assignProps from '@semcore/utils/lib/assignProps';
|
|
64
55
|
var defaultAllowedParts = {
|
|
@@ -71,97 +62,79 @@ var defaultPlaceholders = {
|
|
|
71
62
|
month: 'M',
|
|
72
63
|
day: 'D'
|
|
73
64
|
};
|
|
74
|
-
|
|
75
65
|
var InputTriggerRoot = /*#__PURE__*/function (_Component) {
|
|
76
66
|
_inherits(InputTriggerRoot, _Component);
|
|
77
|
-
|
|
78
67
|
var _super = _createSuper(InputTriggerRoot);
|
|
79
|
-
|
|
80
68
|
function InputTriggerRoot() {
|
|
81
69
|
_classCallCheck(this, InputTriggerRoot);
|
|
82
|
-
|
|
83
70
|
return _super.apply(this, arguments);
|
|
84
71
|
}
|
|
85
|
-
|
|
86
72
|
_createClass(InputTriggerRoot, [{
|
|
87
73
|
key: "getSingleDateInputProps",
|
|
88
74
|
value: function getSingleDateInputProps() {
|
|
89
75
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
90
76
|
var _this$asProps = this.asProps,
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
77
|
+
children = _this$asProps.children,
|
|
78
|
+
id = _this$asProps.id,
|
|
79
|
+
role = _this$asProps.role,
|
|
80
|
+
ariaHasPopup = _this$asProps['aria-haspopup'],
|
|
81
|
+
ariaLabel = _this$asProps['aria-label'],
|
|
82
|
+
style = _this$asProps.style,
|
|
83
|
+
otherProps = _objectWithoutProperties(_this$asProps, _excluded);
|
|
99
84
|
return otherProps;
|
|
100
85
|
}
|
|
101
86
|
}, {
|
|
102
87
|
key: "getDateRangeProps",
|
|
103
88
|
value: function getDateRangeProps() {
|
|
104
89
|
var _this$asProps2 = this.asProps,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
90
|
+
children = _this$asProps2.children,
|
|
91
|
+
id = _this$asProps2.id,
|
|
92
|
+
role = _this$asProps2.role,
|
|
93
|
+
ariaHasPopup = _this$asProps2['aria-haspopup'],
|
|
94
|
+
ariaLabel = _this$asProps2['aria-label'],
|
|
95
|
+
style = _this$asProps2.style,
|
|
96
|
+
otherProps = _objectWithoutProperties(_this$asProps2, _excluded2);
|
|
112
97
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
113
|
-
|
|
114
|
-
|
|
115
98
|
return otherProps;
|
|
116
99
|
}
|
|
117
100
|
}, {
|
|
118
101
|
key: "render",
|
|
119
102
|
value: function render() {
|
|
120
103
|
var _ref = this.asProps,
|
|
121
|
-
|
|
122
|
-
|
|
104
|
+
_ref8;
|
|
123
105
|
var SInputTrigger = Box;
|
|
124
106
|
var _this$asProps3 = this.asProps,
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
107
|
+
Children = _this$asProps3.Children,
|
|
108
|
+
style = _this$asProps3.style,
|
|
109
|
+
getI18nText = _this$asProps3.getI18nText;
|
|
128
110
|
return _ref8 = sstyled(style), /*#__PURE__*/React.createElement(SInputTrigger, _ref8.cn("SInputTrigger", _objectSpread({}, _assignProps({
|
|
129
111
|
"aria-label": getI18nText('input'),
|
|
130
112
|
"__excludeProps": ['onChange', 'value', 'role']
|
|
131
113
|
}, _ref))), /*#__PURE__*/React.createElement(Children, _ref8.cn("Children", {})));
|
|
132
114
|
}
|
|
133
115
|
}]);
|
|
134
|
-
|
|
135
116
|
return InputTriggerRoot;
|
|
136
117
|
}(Component);
|
|
137
|
-
|
|
138
118
|
_defineProperty(InputTriggerRoot, "displayName", 'InputTrigger');
|
|
139
|
-
|
|
140
119
|
_defineProperty(InputTriggerRoot, "style", style);
|
|
141
|
-
|
|
142
120
|
var SingleDateInputRoot = /*#__PURE__*/function (_Component2) {
|
|
143
121
|
_inherits(SingleDateInputRoot, _Component2);
|
|
144
|
-
|
|
145
122
|
var _super2 = _createSuper(SingleDateInputRoot);
|
|
146
|
-
|
|
147
123
|
function SingleDateInputRoot() {
|
|
148
124
|
_classCallCheck(this, SingleDateInputRoot);
|
|
149
|
-
|
|
150
125
|
return _super2.apply(this, arguments);
|
|
151
126
|
}
|
|
152
|
-
|
|
153
127
|
_createClass(SingleDateInputRoot, [{
|
|
154
128
|
key: "getMaskedInputProps",
|
|
155
129
|
value: function getMaskedInputProps() {
|
|
156
130
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
157
131
|
var _this$asProps4 = this.asProps,
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
132
|
+
value = _this$asProps4.value,
|
|
133
|
+
onChange = _this$asProps4.onChange,
|
|
134
|
+
onDisplayedPeriodChange = _this$asProps4.onDisplayedPeriodChange,
|
|
135
|
+
locale = _this$asProps4.locale,
|
|
136
|
+
w = _this$asProps4.w,
|
|
137
|
+
otherProps = _objectWithoutProperties(_this$asProps4, _excluded3);
|
|
165
138
|
return _objectSpread({
|
|
166
139
|
date: value,
|
|
167
140
|
onDateChange: onChange,
|
|
@@ -173,12 +146,11 @@ var SingleDateInputRoot = /*#__PURE__*/function (_Component2) {
|
|
|
173
146
|
key: "render",
|
|
174
147
|
value: function render() {
|
|
175
148
|
var _ref2 = this.asProps,
|
|
176
|
-
|
|
177
|
-
|
|
149
|
+
_ref9;
|
|
178
150
|
var _this$asProps5 = this.asProps,
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
151
|
+
Children = _this$asProps5.Children,
|
|
152
|
+
forwardRef = _this$asProps5.forwardRef,
|
|
153
|
+
styles = _this$asProps5.styles;
|
|
182
154
|
var SSingleDateInput = InputMask;
|
|
183
155
|
return _ref9 = sstyled(styles), /*#__PURE__*/React.createElement(SSingleDateInput, _ref9.cn("SSingleDateInput", _objectSpread({}, _assignProps2({
|
|
184
156
|
"ref": forwardRef,
|
|
@@ -186,118 +158,85 @@ var SingleDateInputRoot = /*#__PURE__*/function (_Component2) {
|
|
|
186
158
|
}, _ref2))), /*#__PURE__*/React.createElement(NeighborLocation, _ref9.cn("NeighborLocation", {}), /*#__PURE__*/React.createElement(Children, _ref9.cn("Children", {}))));
|
|
187
159
|
}
|
|
188
160
|
}]);
|
|
189
|
-
|
|
190
161
|
return SingleDateInputRoot;
|
|
191
162
|
}(Component);
|
|
192
|
-
|
|
193
163
|
_defineProperty(SingleDateInputRoot, "displayName", 'SingleDateInput');
|
|
194
|
-
|
|
195
164
|
_defineProperty(SingleDateInputRoot, "style", style);
|
|
196
|
-
|
|
197
165
|
_defineProperty(SingleDateInputRoot, "defaultProps", {
|
|
198
166
|
children: function children() {
|
|
199
167
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SingleDateInput.Indicator, null), /*#__PURE__*/React.createElement(SingleDateInput.MaskedInput, null));
|
|
200
168
|
}
|
|
201
169
|
});
|
|
202
|
-
|
|
203
170
|
var DateRangeRoot = /*#__PURE__*/function (_Component3) {
|
|
204
171
|
_inherits(DateRangeRoot, _Component3);
|
|
205
|
-
|
|
206
172
|
var _super3 = _createSuper(DateRangeRoot);
|
|
207
|
-
|
|
208
173
|
function DateRangeRoot() {
|
|
209
174
|
var _this;
|
|
210
|
-
|
|
211
175
|
_classCallCheck(this, DateRangeRoot);
|
|
212
|
-
|
|
213
176
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
214
177
|
args[_key] = arguments[_key];
|
|
215
178
|
}
|
|
216
|
-
|
|
217
179
|
_this = _super3.call.apply(_super3, [this].concat(args));
|
|
218
|
-
|
|
219
180
|
_defineProperty(_assertThisInitialized(_this), "fromRef", /*#__PURE__*/React.createRef());
|
|
220
|
-
|
|
221
181
|
_defineProperty(_assertThisInitialized(_this), "toRef", /*#__PURE__*/React.createRef());
|
|
222
|
-
|
|
223
182
|
_defineProperty(_assertThisInitialized(_this), "handleFromChange", function (value, event) {
|
|
224
183
|
var _this$asProps$value$, _this$asProps$value, _this$asProps$value$2, _this$asProps$value2;
|
|
225
|
-
|
|
226
184
|
var onChange = _this.asProps.onChange;
|
|
227
185
|
var prevValue = [(_this$asProps$value$ = (_this$asProps$value = _this.asProps.value) === null || _this$asProps$value === void 0 ? void 0 : _this$asProps$value[0]) !== null && _this$asProps$value$ !== void 0 ? _this$asProps$value$ : null, (_this$asProps$value$2 = (_this$asProps$value2 = _this.asProps.value) === null || _this$asProps$value2 === void 0 ? void 0 : _this$asProps$value2[1]) !== null && _this$asProps$value$2 !== void 0 ? _this$asProps$value$2 : null];
|
|
228
186
|
onChange([value, prevValue[1]], event);
|
|
229
|
-
|
|
230
187
|
if (value) {
|
|
231
188
|
if (!_this.toRef.current) return;
|
|
232
|
-
|
|
233
189
|
_this.toRef.current.focus();
|
|
234
|
-
|
|
235
190
|
setTimeout(function () {
|
|
236
191
|
if (!_this.toRef.current) return;
|
|
237
|
-
|
|
238
192
|
_this.toRef.current.setSelectionRange(0, 0);
|
|
239
193
|
}, 0);
|
|
240
194
|
}
|
|
241
195
|
});
|
|
242
|
-
|
|
243
196
|
_defineProperty(_assertThisInitialized(_this), "handleToChange", function (value, event) {
|
|
244
197
|
var _this$asProps$value$3, _this$asProps$value3, _this$asProps$value$4, _this$asProps$value4;
|
|
245
|
-
|
|
246
198
|
var onChange = _this.asProps.onChange;
|
|
247
199
|
var prevValue = [(_this$asProps$value$3 = (_this$asProps$value3 = _this.asProps.value) === null || _this$asProps$value3 === void 0 ? void 0 : _this$asProps$value3[0]) !== null && _this$asProps$value$3 !== void 0 ? _this$asProps$value$3 : null, (_this$asProps$value$4 = (_this$asProps$value4 = _this.asProps.value) === null || _this$asProps$value4 === void 0 ? void 0 : _this$asProps$value4[1]) !== null && _this$asProps$value$4 !== void 0 ? _this$asProps$value$4 : null];
|
|
248
200
|
onChange([prevValue[0], value], event);
|
|
249
201
|
});
|
|
250
|
-
|
|
251
202
|
_defineProperty(_assertThisInitialized(_this), "handleFromKeydown", function (event) {
|
|
252
203
|
if (!_this.toRef.current) return;
|
|
253
204
|
if (!_this.fromRef.current) return;
|
|
254
|
-
|
|
255
205
|
if (event.code === 'ArrowRight' && _this.fromRef.current.selectionStart === _this.fromRef.current.value.length && _this.fromRef.current.selectionEnd === _this.fromRef.current.value.length) {
|
|
256
206
|
_this.toRef.current.focus();
|
|
257
|
-
|
|
258
207
|
setTimeout(function () {
|
|
259
208
|
_this.toRef.current.setSelectionRange(0, 0);
|
|
260
209
|
}, 0);
|
|
261
210
|
}
|
|
262
211
|
});
|
|
263
|
-
|
|
264
212
|
_defineProperty(_assertThisInitialized(_this), "handleToKeydown", function (event) {
|
|
265
213
|
if (!_this.toRef.current) return;
|
|
266
214
|
if (!_this.fromRef.current) return;
|
|
267
|
-
|
|
268
215
|
if (event.code === 'Backspace' && !_this.toRef.current.value) {
|
|
269
216
|
var value = _this.fromRef.current.value;
|
|
270
|
-
|
|
271
217
|
_this.fromRef.current.focus();
|
|
272
|
-
|
|
273
218
|
setTimeout(function () {
|
|
274
219
|
_this.fromRef.current.setSelectionRange(value.length, value.length);
|
|
275
220
|
}, 0);
|
|
276
221
|
}
|
|
277
|
-
|
|
278
222
|
if (event.code === 'ArrowLeft' && _this.toRef.current.selectionStart === 0 && _this.toRef.current.selectionEnd === 0) {
|
|
279
223
|
var _value = _this.fromRef.current.value;
|
|
280
|
-
|
|
281
224
|
_this.fromRef.current.focus();
|
|
282
|
-
|
|
283
225
|
setTimeout(function () {
|
|
284
226
|
_this.fromRef.current.setSelectionRange(_value.length, _value.length);
|
|
285
227
|
}, 0);
|
|
286
228
|
}
|
|
287
229
|
});
|
|
288
|
-
|
|
289
230
|
return _this;
|
|
290
231
|
}
|
|
291
|
-
|
|
292
232
|
_createClass(DateRangeRoot, [{
|
|
293
233
|
key: "getFromMaskedInputProps",
|
|
294
234
|
value: function getFromMaskedInputProps() {
|
|
295
235
|
var _this$asProps6 = this.asProps,
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
236
|
+
value = _this$asProps6.value,
|
|
237
|
+
locale = _this$asProps6.locale,
|
|
238
|
+
onDisplayedPeriodChange = _this$asProps6.onDisplayedPeriodChange,
|
|
239
|
+
otherProps = _objectWithoutProperties(_this$asProps6, _excluded4);
|
|
301
240
|
return assignProps({
|
|
302
241
|
ref: this.fromRef,
|
|
303
242
|
date: value === null || value === void 0 ? void 0 : value[0],
|
|
@@ -312,11 +251,10 @@ var DateRangeRoot = /*#__PURE__*/function (_Component3) {
|
|
|
312
251
|
key: "getToMaskedInputProps",
|
|
313
252
|
value: function getToMaskedInputProps() {
|
|
314
253
|
var _this$asProps7 = this.asProps,
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
254
|
+
value = _this$asProps7.value,
|
|
255
|
+
locale = _this$asProps7.locale,
|
|
256
|
+
onDisplayedPeriodChange = _this$asProps7.onDisplayedPeriodChange,
|
|
257
|
+
otherProps = _objectWithoutProperties(_this$asProps7, _excluded5);
|
|
320
258
|
return assignProps({
|
|
321
259
|
ref: this.toRef,
|
|
322
260
|
date: value === null || value === void 0 ? void 0 : value[1],
|
|
@@ -339,57 +277,46 @@ var DateRangeRoot = /*#__PURE__*/function (_Component3) {
|
|
|
339
277
|
key: "render",
|
|
340
278
|
value: function render() {
|
|
341
279
|
var _ref3 = this.asProps,
|
|
342
|
-
|
|
343
|
-
|
|
280
|
+
_ref10;
|
|
344
281
|
var SDateRange = InputMask;
|
|
345
282
|
var _this$asProps8 = this.asProps,
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
283
|
+
Children = _this$asProps8.Children,
|
|
284
|
+
styles = _this$asProps8.styles,
|
|
285
|
+
w = _this$asProps8.w;
|
|
349
286
|
return _ref10 = sstyled(styles), /*#__PURE__*/React.createElement(SDateRange, _ref10.cn("SDateRange", _objectSpread({}, _assignProps3({
|
|
350
287
|
"__excludeProps": ['onChange', 'value'],
|
|
351
288
|
"w": w
|
|
352
289
|
}, _ref3))), /*#__PURE__*/React.createElement(Children, _ref10.cn("Children", {})));
|
|
353
290
|
}
|
|
354
291
|
}]);
|
|
355
|
-
|
|
356
292
|
return DateRangeRoot;
|
|
357
293
|
}(Component);
|
|
358
|
-
|
|
359
294
|
_defineProperty(DateRangeRoot, "displayName", 'DateRange');
|
|
360
|
-
|
|
361
295
|
_defineProperty(DateRangeRoot, "style", style);
|
|
362
|
-
|
|
363
296
|
_defineProperty(DateRangeRoot, "defaultProps", {
|
|
364
297
|
children: function children() {
|
|
365
298
|
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));
|
|
366
299
|
}
|
|
367
300
|
});
|
|
368
|
-
|
|
369
301
|
var FromMaskedInput = function FromMaskedInput(props) {
|
|
370
302
|
var _ref4 = arguments[0],
|
|
371
|
-
|
|
372
|
-
|
|
303
|
+
_ref11;
|
|
373
304
|
var SFromMaskedInput = MaskedInput;
|
|
374
305
|
return _ref11 = sstyled(props.styles), /*#__PURE__*/React.createElement(SFromMaskedInput, _ref11.cn("SFromMaskedInput", _objectSpread({}, _assignProps4({
|
|
375
306
|
"labelPrefix": "from date"
|
|
376
307
|
}, _ref4))));
|
|
377
308
|
};
|
|
378
|
-
|
|
379
309
|
var ToMaskedInput = function ToMaskedInput(props) {
|
|
380
310
|
var _ref5 = arguments[0],
|
|
381
|
-
|
|
382
|
-
|
|
311
|
+
_ref12;
|
|
383
312
|
var SToMaskedInput = MaskedInput;
|
|
384
313
|
return _ref12 = sstyled(props.styles), /*#__PURE__*/React.createElement(SToMaskedInput, _ref12.cn("SToMaskedInput", _objectSpread({}, _assignProps5({
|
|
385
314
|
"labelPrefix": "to date"
|
|
386
315
|
}, _ref5))));
|
|
387
316
|
};
|
|
388
|
-
|
|
389
317
|
var Indicator = function Indicator(props) {
|
|
390
318
|
var _ref6 = arguments[0],
|
|
391
|
-
|
|
392
|
-
|
|
319
|
+
_ref13;
|
|
393
320
|
var SIndicator = InputMask.Addon;
|
|
394
321
|
return _ref13 = sstyled(props.styles), /*#__PURE__*/React.createElement(SIndicator, _ref13.cn("SIndicator", _objectSpread({}, _assignProps6({
|
|
395
322
|
"tag": Calendar,
|
|
@@ -397,11 +324,9 @@ var Indicator = function Indicator(props) {
|
|
|
397
324
|
"tabIndex": -1
|
|
398
325
|
}, _ref6))));
|
|
399
326
|
};
|
|
400
|
-
|
|
401
327
|
var RangeSep = function RangeSep(props) {
|
|
402
328
|
var _ref7 = arguments[0],
|
|
403
|
-
|
|
404
|
-
|
|
329
|
+
_ref14;
|
|
405
330
|
var SRangeSep = InputMask.Addon;
|
|
406
331
|
return _ref14 = sstyled(props.styles), /*#__PURE__*/React.createElement(SRangeSep, _ref14.cn("SRangeSep", _objectSpread({}, _assignProps7({
|
|
407
332
|
"tag": Flex,
|
|
@@ -411,27 +336,24 @@ var RangeSep = function RangeSep(props) {
|
|
|
411
336
|
"flex": "0"
|
|
412
337
|
}, _ref7))), "-");
|
|
413
338
|
};
|
|
414
|
-
|
|
415
339
|
var MaskedInput = function MaskedInput(_ref16) {
|
|
416
340
|
var _ref15;
|
|
417
|
-
|
|
418
341
|
var outerValue = _ref16.date,
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
342
|
+
onDateChange = _ref16.onDateChange,
|
|
343
|
+
onDisplayedPeriodChange = _ref16.onDisplayedPeriodChange,
|
|
344
|
+
locale = _ref16.locale,
|
|
345
|
+
styles = _ref16.styles,
|
|
346
|
+
_ref16$parts = _ref16.parts,
|
|
347
|
+
allowedParts = _ref16$parts === void 0 ? defaultAllowedParts : _ref16$parts,
|
|
348
|
+
disabledDates = _ref16.disabledDates,
|
|
349
|
+
forwardRef = _ref16.forwardRef,
|
|
350
|
+
_ref16$placeholders = _ref16.placeholders,
|
|
351
|
+
placeholders = _ref16$placeholders === void 0 ? defaultPlaceholders : _ref16$placeholders,
|
|
352
|
+
_ref16$labelPrefix = _ref16.labelPrefix,
|
|
353
|
+
labelPrefix = _ref16$labelPrefix === void 0 ? 'Date' : _ref16$labelPrefix,
|
|
354
|
+
__excludeProps = _ref16.__excludeProps,
|
|
355
|
+
_root = _ref16.Root,
|
|
356
|
+
otherProps = _objectWithoutProperties(_ref16, _excluded6);
|
|
435
357
|
if (placeholders.year.length !== 1 || placeholders.month.length !== 1 || placeholders.day.length !== 1) {
|
|
436
358
|
// eslint-disable-next-line no-console
|
|
437
359
|
console.error({
|
|
@@ -439,51 +361,43 @@ var MaskedInput = function MaskedInput(_ref16) {
|
|
|
439
361
|
});
|
|
440
362
|
throw new Error("InputTrigger placeholder prop should contain fields year, month and day each one with string value of single character length. [see above what was received] (".concat(placeholders, ")"), placeholders);
|
|
441
363
|
}
|
|
442
|
-
|
|
443
364
|
var _React$useMemo = React.useMemo(function () {
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
var _iterator = _createForOfIteratorHelper(parts),
|
|
365
|
+
var _sep;
|
|
366
|
+
var exampleDate = new Date(2000, 4, 29);
|
|
367
|
+
var options = {
|
|
368
|
+
year: 'numeric',
|
|
369
|
+
month: '2-digit',
|
|
370
|
+
day: '2-digit'
|
|
371
|
+
};
|
|
372
|
+
var dateTimeFormat = new Intl.DateTimeFormat(locale, options);
|
|
373
|
+
var sep = undefined;
|
|
374
|
+
var order = [];
|
|
375
|
+
var parts = dateTimeFormat.formatToParts(exampleDate);
|
|
376
|
+
var _iterator = _createForOfIteratorHelper(parts),
|
|
458
377
|
_step;
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
if (order.length < 3 && ['day', 'month', 'year'].includes(part.type) && allowedParts[part.type]) {
|
|
469
|
-
order.push(part.type);
|
|
378
|
+
try {
|
|
379
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
380
|
+
var part = _step.value;
|
|
381
|
+
if (!sep && part.type === 'literal') {
|
|
382
|
+
sep = part.value;
|
|
383
|
+
}
|
|
384
|
+
if (order.length < 3 && ['day', 'month', 'year'].includes(part.type) && allowedParts[part.type]) {
|
|
385
|
+
order.push(part.type);
|
|
386
|
+
}
|
|
470
387
|
}
|
|
388
|
+
} catch (err) {
|
|
389
|
+
_iterator.e(err);
|
|
390
|
+
} finally {
|
|
391
|
+
_iterator.f();
|
|
471
392
|
}
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
sep =
|
|
479
|
-
|
|
480
|
-
sep: sep,
|
|
481
|
-
order: order
|
|
482
|
-
};
|
|
483
|
-
}, [locale, allowedParts]),
|
|
484
|
-
sep = _React$useMemo.sep,
|
|
485
|
-
order = _React$useMemo.order;
|
|
486
|
-
|
|
393
|
+
sep = (_sep = sep) !== null && _sep !== void 0 ? _sep : ' ';
|
|
394
|
+
return {
|
|
395
|
+
sep: sep,
|
|
396
|
+
order: order
|
|
397
|
+
};
|
|
398
|
+
}, [locale, allowedParts]),
|
|
399
|
+
sep = _React$useMemo.sep,
|
|
400
|
+
order = _React$useMemo.order;
|
|
487
401
|
var outer = React.useMemo(function () {
|
|
488
402
|
var validDate = outerValue && outerValue instanceof Date && !Number.isNaN(outerValue.getTime());
|
|
489
403
|
if (!validDate) return null;
|
|
@@ -497,10 +411,8 @@ var MaskedInput = function MaskedInput(_ref16) {
|
|
|
497
411
|
if (!value) return null;
|
|
498
412
|
if (!value.year && !value.month && !value.day) return null;
|
|
499
413
|
var result = [];
|
|
500
|
-
|
|
501
414
|
var _iterator2 = _createForOfIteratorHelper(order),
|
|
502
|
-
|
|
503
|
-
|
|
415
|
+
_step2;
|
|
504
416
|
try {
|
|
505
417
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
506
418
|
var part = _step2.value;
|
|
@@ -514,49 +426,39 @@ var MaskedInput = function MaskedInput(_ref16) {
|
|
|
514
426
|
} finally {
|
|
515
427
|
_iterator2.f();
|
|
516
428
|
}
|
|
517
|
-
|
|
518
429
|
return result.join(sep);
|
|
519
430
|
}, [order, allowedParts]);
|
|
520
|
-
|
|
521
431
|
var _React$useState = React.useState(outer),
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
432
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
433
|
+
internalValue = _React$useState2[0],
|
|
434
|
+
setInternalValue = _React$useState2[1];
|
|
526
435
|
var value = React.useMemo(function () {
|
|
527
436
|
return stringifyValue(internalValue);
|
|
528
437
|
}, [stringifyValue, internalValue]);
|
|
529
438
|
var lastKnownOuterValue = React.useRef(outer);
|
|
530
439
|
React.useEffect(function () {
|
|
531
440
|
var _lastKnownOuterValue$, _lastKnownOuterValue$2, _lastKnownOuterValue$3;
|
|
532
|
-
|
|
533
441
|
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)) {
|
|
534
442
|
setInternalValue(outer);
|
|
535
443
|
}
|
|
536
|
-
|
|
537
444
|
lastKnownOuterValue.current = outer;
|
|
538
445
|
}, [outer, setInternalValue]);
|
|
539
446
|
var pipeMask = React.useCallback(function (value) {
|
|
540
447
|
var placeholdersOnly = true;
|
|
541
|
-
|
|
542
448
|
for (var i = 0; i < value.length; i++) {
|
|
543
449
|
if (value[i] !== '_' && value[i] !== sep) {
|
|
544
450
|
placeholdersOnly = false;
|
|
545
451
|
break;
|
|
546
452
|
}
|
|
547
453
|
}
|
|
548
|
-
|
|
549
454
|
if (placeholdersOnly) {
|
|
550
455
|
return '';
|
|
551
456
|
}
|
|
552
|
-
|
|
553
457
|
var getOffsetTo = function getOffsetTo(partName) {
|
|
554
458
|
var partsBefore = order.slice(0, order.indexOf(partName));
|
|
555
459
|
var offset = 0;
|
|
556
|
-
|
|
557
460
|
var _iterator3 = _createForOfIteratorHelper(partsBefore),
|
|
558
|
-
|
|
559
|
-
|
|
461
|
+
_step3;
|
|
560
462
|
try {
|
|
561
463
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
562
464
|
var part = _step3.value;
|
|
@@ -569,47 +471,37 @@ var MaskedInput = function MaskedInput(_ref16) {
|
|
|
569
471
|
} finally {
|
|
570
472
|
_iterator3.f();
|
|
571
473
|
}
|
|
572
|
-
|
|
573
474
|
offset += partsBefore.length * sep.length;
|
|
574
475
|
return offset;
|
|
575
476
|
};
|
|
576
|
-
|
|
577
477
|
var indexesOfPipedChars = [];
|
|
578
478
|
var parsed = {};
|
|
579
479
|
var parts = value.split(sep);
|
|
580
|
-
|
|
581
480
|
for (var partName in placeholders) {
|
|
582
481
|
parsed[partName] = placeholders[partName];
|
|
583
482
|
}
|
|
584
|
-
|
|
585
483
|
for (var _i = 0; _i < order.length; _i++) {
|
|
586
484
|
parsed[order[_i]] = parts[_i];
|
|
587
485
|
}
|
|
588
|
-
|
|
589
486
|
var year = parsed.year,
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
487
|
+
month = parsed.month,
|
|
488
|
+
day = parsed.day;
|
|
593
489
|
if (allowedParts.month) {
|
|
594
490
|
if (month[0] !== '_' && parseInt(month[0], 10) > 1) {
|
|
595
491
|
month = "0".concat(month[0]);
|
|
596
492
|
indexesOfPipedChars.push(getOffsetTo('month'));
|
|
597
493
|
}
|
|
598
|
-
|
|
599
494
|
if (month === '00') month = '01';
|
|
600
495
|
if (month[0] !== '_' && month[1] !== '_' && parseInt(month, 10) > 12) return false;
|
|
601
496
|
}
|
|
602
|
-
|
|
603
497
|
if (allowedParts.day) {
|
|
604
498
|
if (day[0] !== '_' && parseInt(day[0], 10) > 3) {
|
|
605
499
|
day = "0".concat(day[0]);
|
|
606
500
|
indexesOfPipedChars.push(getOffsetTo('day'));
|
|
607
501
|
}
|
|
608
|
-
|
|
609
502
|
if (day === '00') day = '01';
|
|
610
503
|
if (day[0] !== '_' && day[1] !== '_' && parseInt(day, 10) > 31) return false;
|
|
611
504
|
}
|
|
612
|
-
|
|
613
505
|
year = year.split('').map(function (_char) {
|
|
614
506
|
return _char === '_' ? placeholders.year : _char;
|
|
615
507
|
}).join('');
|
|
@@ -623,27 +515,21 @@ var MaskedInput = function MaskedInput(_ref16) {
|
|
|
623
515
|
var monthFulfilled = !allowedParts.month || month && month.length === 2 && !month.includes(placeholders.month);
|
|
624
516
|
var dayFulfilled = !allowedParts.day || day && day.length === 2 && !day.includes(placeholders.day);
|
|
625
517
|
var fulfilled = yearFulfilled && monthFulfilled && dayFulfilled;
|
|
626
|
-
|
|
627
518
|
if (fulfilled) {
|
|
628
519
|
var date = new Date();
|
|
629
520
|
date.setFullYear(allowedParts.year ? parseInt(year, 10) : 0);
|
|
630
521
|
date.setMonth(allowedParts.month ? parseInt(month, 10) - 1 : 0);
|
|
631
522
|
date.setDate(allowedParts.day ? parseInt(day, 10) : 1);
|
|
632
|
-
|
|
633
523
|
if (disabledDates && disabledDates.some(includesDate(dayjs(date), 'date'))) {
|
|
634
524
|
return false;
|
|
635
525
|
}
|
|
636
|
-
|
|
637
526
|
if (allowedParts.day) {
|
|
638
527
|
if (date.getDate() !== parseInt(day, 10)) return false;
|
|
639
528
|
}
|
|
640
529
|
}
|
|
641
|
-
|
|
642
530
|
var result = [];
|
|
643
|
-
|
|
644
531
|
var _iterator4 = _createForOfIteratorHelper(order),
|
|
645
|
-
|
|
646
|
-
|
|
532
|
+
_step4;
|
|
647
533
|
try {
|
|
648
534
|
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
649
535
|
var part = _step4.value;
|
|
@@ -656,7 +542,6 @@ var MaskedInput = function MaskedInput(_ref16) {
|
|
|
656
542
|
} finally {
|
|
657
543
|
_iterator4.f();
|
|
658
544
|
}
|
|
659
|
-
|
|
660
545
|
return {
|
|
661
546
|
value: result.join(sep),
|
|
662
547
|
indexesOfPipedChars: indexesOfPipedChars
|
|
@@ -664,20 +549,16 @@ var MaskedInput = function MaskedInput(_ref16) {
|
|
|
664
549
|
}, [placeholders, sep, order, allowedParts, disabledDates]);
|
|
665
550
|
var handleChange = React.useCallback(function (value) {
|
|
666
551
|
var parsed = {};
|
|
667
|
-
|
|
668
552
|
for (var partName in placeholders) {
|
|
669
553
|
parsed[partName] = placeholders[partName];
|
|
670
554
|
}
|
|
671
|
-
|
|
672
555
|
var parts = value.split(sep);
|
|
673
|
-
|
|
674
556
|
for (var i = 0; i < order.length; i++) {
|
|
675
557
|
parsed[order[i]] = parts[i];
|
|
676
558
|
}
|
|
677
|
-
|
|
678
559
|
var year = parsed.year,
|
|
679
|
-
|
|
680
|
-
|
|
560
|
+
month = parsed.month,
|
|
561
|
+
day = parsed.day;
|
|
681
562
|
setInternalValue({
|
|
682
563
|
year: year,
|
|
683
564
|
month: month,
|
|
@@ -687,7 +568,6 @@ var MaskedInput = function MaskedInput(_ref16) {
|
|
|
687
568
|
var monthFulfilled = !allowedParts.month || month && month.length === 2 && !month.includes(placeholders.month);
|
|
688
569
|
var dayFulfilled = !allowedParts.day || day && day.length === 2 && !day.includes(placeholders.day);
|
|
689
570
|
var fulfilled = yearFulfilled && monthFulfilled && dayFulfilled;
|
|
690
|
-
|
|
691
571
|
if (fulfilled) {
|
|
692
572
|
var date = new Date();
|
|
693
573
|
date.setFullYear(allowedParts.year ? parseInt(year, 10) : 0);
|
|
@@ -701,30 +581,23 @@ var MaskedInput = function MaskedInput(_ref16) {
|
|
|
701
581
|
};
|
|
702
582
|
return;
|
|
703
583
|
}
|
|
704
|
-
|
|
705
584
|
if (lastKnownOuterValue.current !== null) {
|
|
706
585
|
onDateChange(null);
|
|
707
586
|
lastKnownOuterValue.current = null;
|
|
708
587
|
}
|
|
709
|
-
|
|
710
588
|
if (yearFulfilled && allowedParts.year) {
|
|
711
589
|
var _date = new Date();
|
|
712
|
-
|
|
713
590
|
_date.setFullYear(parseInt(year, 10));
|
|
714
|
-
|
|
715
591
|
if (monthFulfilled && allowedParts.month) {
|
|
716
592
|
_date.setMonth(parseInt(month, 10) - 1);
|
|
717
593
|
}
|
|
718
|
-
|
|
719
594
|
onDisplayedPeriodChange(_date);
|
|
720
595
|
}
|
|
721
596
|
}, [onDateChange, setInternalValue, placeholders, onDisplayedPeriodChange, order, allowedParts]);
|
|
722
597
|
var mask = React.useMemo(function () {
|
|
723
598
|
var result = [];
|
|
724
|
-
|
|
725
599
|
var _iterator5 = _createForOfIteratorHelper(order),
|
|
726
|
-
|
|
727
|
-
|
|
600
|
+
_step5;
|
|
728
601
|
try {
|
|
729
602
|
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
730
603
|
var part = _step5.value;
|
|
@@ -737,17 +610,14 @@ var MaskedInput = function MaskedInput(_ref16) {
|
|
|
737
610
|
} finally {
|
|
738
611
|
_iterator5.f();
|
|
739
612
|
}
|
|
740
|
-
|
|
741
613
|
return result.join(sep);
|
|
742
614
|
}, [sep, order, placeholders]);
|
|
743
615
|
var aliases = React.useMemo(function () {
|
|
744
616
|
var _ref17;
|
|
745
|
-
|
|
746
617
|
return _ref17 = {}, _defineProperty(_ref17, placeholders.year, /\d/), _defineProperty(_ref17, placeholders.month, /\d/), _defineProperty(_ref17, placeholders.day, /\d/), _ref17;
|
|
747
618
|
}, [placeholders]);
|
|
748
619
|
var maskOnlySymbols = React.useMemo(function () {
|
|
749
620
|
var _ref18;
|
|
750
|
-
|
|
751
621
|
return _ref18 = {}, _defineProperty(_ref18, placeholders.year, true), _defineProperty(_ref18, placeholders.month, true), _defineProperty(_ref18, placeholders.day, true), _defineProperty(_ref18, sep, true), _ref18;
|
|
752
622
|
}, [sep, placeholders]);
|
|
753
623
|
var humanizedDate = React.useMemo(function () {
|
|
@@ -778,7 +648,6 @@ var MaskedInput = function MaskedInput(_ref16) {
|
|
|
778
648
|
noHumanizedDate: !humanizedDate
|
|
779
649
|
}), humanizedDate && /*#__PURE__*/React.createElement(SHumanizedDate, _ref15.cn("SHumanizedDate", {}), humanizedDate));
|
|
780
650
|
};
|
|
781
|
-
|
|
782
651
|
var SingleDateInput = createComponent(SingleDateInputRoot, {
|
|
783
652
|
Indicator: Indicator,
|
|
784
653
|
MaskedInput: MaskedInput
|