@semcore/date-picker 4.35.0 → 4.36.0
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 +14 -0
- package/lib/cjs/DatePicker.js +2 -0
- package/lib/cjs/DatePicker.js.map +1 -1
- package/lib/cjs/DateRangePicker.js +2 -0
- package/lib/cjs/DateRangePicker.js.map +1 -1
- package/lib/cjs/MonthPicker.js +2 -0
- package/lib/cjs/MonthPicker.js.map +1 -1
- package/lib/cjs/MonthRangePicker.js +2 -0
- package/lib/cjs/MonthRangePicker.js.map +1 -1
- package/lib/cjs/components/Calendar.js +21 -21
- package/lib/cjs/components/DateRangeComparatorAbstract.js +31 -26
- package/lib/cjs/components/DateRangeComparatorAbstract.js.map +1 -1
- package/lib/cjs/components/InputTrigger.js +200 -73
- package/lib/cjs/components/InputTrigger.js.map +1 -1
- package/lib/cjs/components/PickerAbstract.js +27 -26
- package/lib/cjs/components/PickerAbstract.js.map +1 -1
- package/lib/cjs/components/RangePickerAbstract.js +27 -26
- package/lib/cjs/components/RangePickerAbstract.js.map +1 -1
- package/lib/cjs/index.d.js.map +1 -1
- package/lib/cjs/style/date-picker.shadow.css +4 -0
- package/lib/cjs/translations/en.json +5 -1
- package/lib/es6/DatePicker.js +2 -0
- package/lib/es6/DatePicker.js.map +1 -1
- package/lib/es6/DateRangePicker.js +2 -0
- package/lib/es6/DateRangePicker.js.map +1 -1
- package/lib/es6/MonthPicker.js +2 -0
- package/lib/es6/MonthPicker.js.map +1 -1
- package/lib/es6/MonthRangePicker.js +2 -0
- package/lib/es6/MonthRangePicker.js.map +1 -1
- package/lib/es6/components/Calendar.js +21 -21
- package/lib/es6/components/DateRangeComparatorAbstract.js +31 -26
- package/lib/es6/components/DateRangeComparatorAbstract.js.map +1 -1
- package/lib/es6/components/InputTrigger.js +200 -73
- package/lib/es6/components/InputTrigger.js.map +1 -1
- package/lib/es6/components/PickerAbstract.js +27 -26
- package/lib/es6/components/PickerAbstract.js.map +1 -1
- package/lib/es6/components/RangePickerAbstract.js +27 -26
- package/lib/es6/components/RangePickerAbstract.js.map +1 -1
- package/lib/es6/index.d.js.map +1 -1
- package/lib/es6/style/date-picker.shadow.css +4 -0
- package/lib/es6/translations/en.json +5 -1
- package/lib/types/index.d.ts +32 -14
- package/package.json +13 -13
|
@@ -21,6 +21,7 @@ var _core = _interopRequireWildcard(require("@semcore/core"));
|
|
|
21
21
|
var _react = _interopRequireDefault(require("react"));
|
|
22
22
|
var _baseTrigger = _interopRequireDefault(require("@semcore/base-trigger"));
|
|
23
23
|
var _inputMask = _interopRequireDefault(require("@semcore/input-mask"));
|
|
24
|
+
var _tooltip = _interopRequireDefault(require("@semcore/tooltip"));
|
|
24
25
|
var _flexBox = require("@semcore/flex-box");
|
|
25
26
|
var _m = _interopRequireDefault(require("@semcore/icon/Calendar/m"));
|
|
26
27
|
var _neighborLocation = _interopRequireDefault(require("@semcore/neighbor-location"));
|
|
@@ -32,34 +33,35 @@ var _excluded = ["children", "id", "role", "aria-haspopup", "aria-expanded", "ar
|
|
|
32
33
|
_excluded3 = ["value", "onChange", "onDisplayedPeriodChange", "locale", "w", "ariaHasPopup"],
|
|
33
34
|
_excluded4 = ["value", "locale", "onDisplayedPeriodChange", "ariaHasPopup"],
|
|
34
35
|
_excluded5 = ["value", "locale", "onDisplayedPeriodChange", "ariaHasPopup"],
|
|
35
|
-
_excluded6 = ["date", "onDateChange", "onDisplayedPeriodChange", "locale", "styles", "parts", "disabledDates", "forwardRef", "placeholders", "labelPrefix", "__excludeProps", "Root"];
|
|
36
|
+
_excluded6 = ["date", "onDateChange", "onDisplayedPeriodChange", "locale", "styles", "parts", "disabledDates", "forwardRef", "placeholders", "labelPrefix", "onMaskPipeBlock", "__excludeProps", "Root"];
|
|
36
37
|
/*__reshadow-styles__:"../style/date-picker.shadow.css"*/
|
|
37
|
-
var style = ( /*__reshadow_css_start__*/_core.sstyled.insert( /*__inner_css_start__*/".
|
|
38
|
-
"__SHeader": "
|
|
39
|
-
"__STitle": "
|
|
40
|
-
"__SToday": "
|
|
41
|
-
"__SPeriod": "
|
|
42
|
-
"__SButton": "
|
|
43
|
-
"__SInner": "
|
|
44
|
-
"__SInputMask": "
|
|
45
|
-
"__SIndicator": "
|
|
46
|
-
"__SRangeIndicator": "
|
|
47
|
-
"_range_value": "
|
|
48
|
-
"_range_compare": "
|
|
49
|
-
"_disabled": "
|
|
50
|
-
"__SHumanizedDate": "
|
|
51
|
-
"__SSingleDateInput": "
|
|
52
|
-
"__SValue": "
|
|
53
|
-
"__SDateRange": "
|
|
54
|
-
"__SMask": "
|
|
55
|
-
"_noHumanizedDate": "
|
|
56
|
-
"__SRangeSep": "
|
|
57
|
-
"_fulfilled": "
|
|
58
|
-
"__SRangeComparatorHeader": "
|
|
59
|
-
"__SRangeCalendar": "
|
|
60
|
-
"__SFooter": "
|
|
61
|
-
"__SPeriodsList": "
|
|
62
|
-
"
|
|
38
|
+
var style = ( /*__reshadow_css_start__*/_core.sstyled.insert( /*__inner_css_start__*/".___SPopper_obi8f_gg_{padding:var(--intergalactic-spacing-4x, 16px);outline:0}.___SPopper_obi8f_gg_::-moz-focus-inner{border:0;padding:0}.___SPopper_obi8f_gg_:active,.___SPopper_obi8f_gg_:focus{outline:0;-webkit-text-decoration:none;text-decoration:none}@media (hover:hover){.___SPopper_obi8f_gg_:hover{outline:0;-webkit-text-decoration:none;text-decoration:none}}.___SPopper_obi8f_gg_:focus{box-shadow:var(--intergalactic-keyboard-focus, 0px 0px 0px 3px rgba(0, 143, 248, 0.5))}.___SHeader_obi8f_gg_,.___STitle_obi8f_gg_{display:flex;align-items:center}.___STitle_obi8f_gg_{font-size:var(--intergalactic-fs-200, 14px);color:var(--intergalactic-text-primary, #191b23);height:32px;width:100%;justify-content:center}.___SToday_obi8f_gg_{display:flex;margin-top:var(--intergalactic-spacing-3x, 12px);justify-content:center}.___SPeriod_obi8f_gg_{display:flex;flex-direction:column;margin-bottom:var(--intergalactic-spacing-2x, 8px)}.___SButton_obi8f_gg_ .___SInner_obi8f_gg_{justify-content:flex-start}.___SInputMask_obi8f_gg_{color:var(--intergalactic-text-primary, #191b23);line-height:normal}.___SIndicator_obi8f_gg_{color:var(--intergalactic-text-secondary, #6c6e79)}.___SRangeIndicator_obi8f_gg_{border-radius:50%;flex-shrink:0}.___SRangeIndicator_obi8f_gg_._range_value_obi8f_gg_{background-color:var(--intergalactic-date-picker-cell-active, #2bb3ff)}.___SRangeIndicator_obi8f_gg_._range_compare_obi8f_gg_{background-color:var(--intergalactic-date-picker-cell-comparison-active, #8649e1)}.___SRangeIndicator_obi8f_gg_.__disabled_obi8f_gg_{opacity:var(--intergalactic-disabled-opacity, 0.3)}.___SHumanizedDate_obi8f_gg_{position:absolute;pointer-events:none}.___SDateRange_obi8f_gg_ .___SMask_obi8f_gg_,.___SDateRange_obi8f_gg_ .___SValue_obi8f_gg_,.___SSingleDateInput_obi8f_gg_ .___SMask_obi8f_gg_,.___SSingleDateInput_obi8f_gg_ .___SValue_obi8f_gg_{opacity:0}.___SSingleDateInput_obi8f_gg_:focus-within .___SHumanizedDate_obi8f_gg_{opacity:0;z-index:var(--intergalactic-z-index-deep, -999)}.___SSingleDateInput_obi8f_gg_:focus-within .___SMask_obi8f_gg_,.___SSingleDateInput_obi8f_gg_:focus-within .___SValue_obi8f_gg_{opacity:1}.___SDateRange_obi8f_gg_:focus-within .___SHumanizedDate_obi8f_gg_{opacity:0;z-index:var(--intergalactic-z-index-deep, -999)}.___SDateRange_obi8f_gg_:focus-within .___SMask_obi8f_gg_,.___SDateRange_obi8f_gg_:focus-within .___SValue_obi8f_gg_{opacity:1}.___SInputMask_obi8f_gg_.__noHumanizedDate_obi8f_gg_ .___SMask_obi8f_gg_,.___SInputMask_obi8f_gg_.__noHumanizedDate_obi8f_gg_ .___SValue_obi8f_gg_{opacity:1}.___SDateRange_obi8f_gg_ .___SInputMask_obi8f_gg_:focus-within .___SMask_obi8f_gg_{background-color:var(--intergalactic-bg-highlight-focus, rgba(0, 143, 248, 0.2))}.___SDateRange_obi8f_gg_:focus-within .___SRangeSep_obi8f_gg_,.___SRangeSep_obi8f_gg_.__fulfilled_obi8f_gg_{color:var(--intergalactic-text-primary, #191b23)}.___SRangeComparatorHeader_obi8f_gg_{border-bottom:1px solid var(--intergalactic-border-primary, #c4c7cf)}.___SRangeCalendar_obi8f_gg_,.___SRangeComparatorHeader_obi8f_gg_{padding:var(--intergalactic-spacing-4x, 16px)}.___SFooter_obi8f_gg_{border-top:1px solid var(--intergalactic-border-primary, #c4c7cf)}.___SFooter_obi8f_gg_,.___SPeriodsList_obi8f_gg_{padding:var(--intergalactic-spacing-4x, 16px)}.___STooltip_obi8f_gg_{padding:var(--intergalactic-spacing-3x, 12px)}" /*__inner_css_end__*/, "obi8f_gg_") /*__reshadow_css_end__*/, {
|
|
39
|
+
"__SHeader": "___SHeader_obi8f_gg_",
|
|
40
|
+
"__STitle": "___STitle_obi8f_gg_",
|
|
41
|
+
"__SToday": "___SToday_obi8f_gg_",
|
|
42
|
+
"__SPeriod": "___SPeriod_obi8f_gg_",
|
|
43
|
+
"__SButton": "___SButton_obi8f_gg_",
|
|
44
|
+
"__SInner": "___SInner_obi8f_gg_",
|
|
45
|
+
"__SInputMask": "___SInputMask_obi8f_gg_",
|
|
46
|
+
"__SIndicator": "___SIndicator_obi8f_gg_",
|
|
47
|
+
"__SRangeIndicator": "___SRangeIndicator_obi8f_gg_",
|
|
48
|
+
"_range_value": "_range_value_obi8f_gg_",
|
|
49
|
+
"_range_compare": "_range_compare_obi8f_gg_",
|
|
50
|
+
"_disabled": "__disabled_obi8f_gg_",
|
|
51
|
+
"__SHumanizedDate": "___SHumanizedDate_obi8f_gg_",
|
|
52
|
+
"__SSingleDateInput": "___SSingleDateInput_obi8f_gg_",
|
|
53
|
+
"__SValue": "___SValue_obi8f_gg_",
|
|
54
|
+
"__SDateRange": "___SDateRange_obi8f_gg_",
|
|
55
|
+
"__SMask": "___SMask_obi8f_gg_",
|
|
56
|
+
"_noHumanizedDate": "__noHumanizedDate_obi8f_gg_",
|
|
57
|
+
"__SRangeSep": "___SRangeSep_obi8f_gg_",
|
|
58
|
+
"_fulfilled": "__fulfilled_obi8f_gg_",
|
|
59
|
+
"__SRangeComparatorHeader": "___SRangeComparatorHeader_obi8f_gg_",
|
|
60
|
+
"__SRangeCalendar": "___SRangeCalendar_obi8f_gg_",
|
|
61
|
+
"__SFooter": "___SFooter_obi8f_gg_",
|
|
62
|
+
"__SPeriodsList": "___SPeriodsList_obi8f_gg_",
|
|
63
|
+
"__STooltip": "___STooltip_obi8f_gg_",
|
|
64
|
+
"__SPopper": "___SPopper_obi8f_gg_"
|
|
63
65
|
});
|
|
64
66
|
var defaultAllowedParts = {
|
|
65
67
|
year: true,
|
|
@@ -134,10 +136,52 @@ var SingleDateInputRoot = /*#__PURE__*/function (_Component2) {
|
|
|
134
136
|
(0, _inherits2["default"])(SingleDateInputRoot, _Component2);
|
|
135
137
|
var _super2 = (0, _createSuper2["default"])(SingleDateInputRoot);
|
|
136
138
|
function SingleDateInputRoot() {
|
|
139
|
+
var _this;
|
|
137
140
|
(0, _classCallCheck2["default"])(this, SingleDateInputRoot);
|
|
138
|
-
|
|
141
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
142
|
+
args[_key] = arguments[_key];
|
|
143
|
+
}
|
|
144
|
+
_this = _super2.call.apply(_super2, [this].concat(args));
|
|
145
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {
|
|
146
|
+
errorText: null,
|
|
147
|
+
showError: false
|
|
148
|
+
});
|
|
149
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleDisabledDateInputAttemptChange", function (value) {
|
|
150
|
+
if (value === _this.asProps.disabledDateInputAttempt) return;
|
|
151
|
+
_this.handlers.disabledDateInputAttempt(value);
|
|
152
|
+
});
|
|
153
|
+
return _this;
|
|
139
154
|
}
|
|
140
155
|
(0, _createClass2["default"])(SingleDateInputRoot, [{
|
|
156
|
+
key: "uncontrolledProps",
|
|
157
|
+
value: function uncontrolledProps() {
|
|
158
|
+
var _this2 = this;
|
|
159
|
+
return {
|
|
160
|
+
disabledDateInputAttempt: [null, function (date) {
|
|
161
|
+
var errorText = _this2.state.errorText;
|
|
162
|
+
var showError = false;
|
|
163
|
+
if (date !== null) {
|
|
164
|
+
errorText = _this2.asProps.disabledErrorText;
|
|
165
|
+
if (errorText === undefined) {
|
|
166
|
+
var key = 'unavailableDate';
|
|
167
|
+
if (_this2.asProps.parts && !_this2.asProps.parts.day) {
|
|
168
|
+
key = 'unavailableMonth';
|
|
169
|
+
}
|
|
170
|
+
errorText = _this2.asProps.getI18nText(key);
|
|
171
|
+
}
|
|
172
|
+
if (typeof errorText === 'function') {
|
|
173
|
+
errorText = errorText(date);
|
|
174
|
+
}
|
|
175
|
+
showError = true;
|
|
176
|
+
}
|
|
177
|
+
_this2.setState({
|
|
178
|
+
errorText: errorText,
|
|
179
|
+
showError: showError
|
|
180
|
+
});
|
|
181
|
+
}]
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
}, {
|
|
141
185
|
key: "getMaskedInputProps",
|
|
142
186
|
value: function getMaskedInputProps() {
|
|
143
187
|
var _this$asProps4 = this.asProps,
|
|
@@ -153,7 +197,8 @@ var SingleDateInputRoot = /*#__PURE__*/function (_Component2) {
|
|
|
153
197
|
onDateChange: onChange,
|
|
154
198
|
onDisplayedPeriodChange: onDisplayedPeriodChange,
|
|
155
199
|
locale: locale,
|
|
156
|
-
'aria-haspopup': 'true'
|
|
200
|
+
'aria-haspopup': 'true',
|
|
201
|
+
onMaskPipeBlock: this.handleDisabledDateInputAttemptChange
|
|
157
202
|
}, otherProps);
|
|
158
203
|
}
|
|
159
204
|
}, {
|
|
@@ -164,9 +209,19 @@ var SingleDateInputRoot = /*#__PURE__*/function (_Component2) {
|
|
|
164
209
|
var _this$asProps5 = this.asProps,
|
|
165
210
|
Children = _this$asProps5.Children,
|
|
166
211
|
forwardRef = _this$asProps5.forwardRef,
|
|
167
|
-
styles = _this$asProps5.styles
|
|
212
|
+
styles = _this$asProps5.styles,
|
|
213
|
+
state = _this$asProps5.state;
|
|
214
|
+
var _this$state = this.state,
|
|
215
|
+
errorText = _this$state.errorText,
|
|
216
|
+
showError = _this$state.showError;
|
|
168
217
|
var SSingleDateInput = _inputMask["default"];
|
|
169
218
|
return _ref9 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SSingleDateInput, _ref9.cn("SSingleDateInput", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
|
|
219
|
+
"tag": _tooltip["default"],
|
|
220
|
+
"placement": 'top-start',
|
|
221
|
+
"title": errorText,
|
|
222
|
+
"theme": 'warning',
|
|
223
|
+
"visible": showError,
|
|
224
|
+
"state": showError ? 'invalid' : state,
|
|
170
225
|
"ref": forwardRef,
|
|
171
226
|
"__excludeProps": ['onChange', 'style', 'aria-expanded']
|
|
172
227
|
}, _ref2))), /*#__PURE__*/_react["default"].createElement(_neighborLocation["default"], _ref9.cn("NeighborLocation", {}), /*#__PURE__*/_react["default"].createElement(Children, _ref9.cn("Children", {}))));
|
|
@@ -179,71 +234,122 @@ var SingleDateInputRoot = /*#__PURE__*/function (_Component2) {
|
|
|
179
234
|
(0, _defineProperty2["default"])(SingleDateInputRoot, "defaultProps", {
|
|
180
235
|
children: function children() {
|
|
181
236
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(SingleDateInput.Indicator, null), /*#__PURE__*/_react["default"].createElement(SingleDateInput.MaskedInput, null));
|
|
182
|
-
}
|
|
237
|
+
},
|
|
238
|
+
defaultDisabledDateInputAttempt: false
|
|
183
239
|
});
|
|
184
240
|
var DateRangeRoot = /*#__PURE__*/function (_Component3) {
|
|
185
241
|
(0, _inherits2["default"])(DateRangeRoot, _Component3);
|
|
186
242
|
var _super3 = (0, _createSuper2["default"])(DateRangeRoot);
|
|
187
243
|
function DateRangeRoot() {
|
|
188
|
-
var
|
|
244
|
+
var _this3;
|
|
189
245
|
(0, _classCallCheck2["default"])(this, DateRangeRoot);
|
|
190
|
-
for (var
|
|
191
|
-
args[
|
|
246
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
247
|
+
args[_key2] = arguments[_key2];
|
|
192
248
|
}
|
|
193
|
-
|
|
194
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
249
|
+
_this3 = _super3.call.apply(_super3, [this].concat(args));
|
|
250
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this3), "state", {
|
|
251
|
+
errorText: null,
|
|
252
|
+
showError: false,
|
|
253
|
+
lastChangedInput: 'from'
|
|
254
|
+
});
|
|
255
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this3), "fromRef", /*#__PURE__*/_react["default"].createRef());
|
|
256
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this3), "toRef", /*#__PURE__*/_react["default"].createRef());
|
|
257
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this3), "handleFromChange", function (value, event) {
|
|
258
|
+
var _this3$asProps$value$, _this3$asProps$value, _this3$asProps$value$2, _this3$asProps$value2;
|
|
259
|
+
var onChange = _this3.asProps.onChange;
|
|
260
|
+
var prevValue = [(_this3$asProps$value$ = (_this3$asProps$value = _this3.asProps.value) === null || _this3$asProps$value === void 0 ? void 0 : _this3$asProps$value[0]) !== null && _this3$asProps$value$ !== void 0 ? _this3$asProps$value$ : null, (_this3$asProps$value$2 = (_this3$asProps$value2 = _this3.asProps.value) === null || _this3$asProps$value2 === void 0 ? void 0 : _this3$asProps$value2[1]) !== null && _this3$asProps$value$2 !== void 0 ? _this3$asProps$value$2 : null];
|
|
200
261
|
onChange([value, prevValue[1]], event);
|
|
201
262
|
if (value) {
|
|
202
|
-
if (!
|
|
203
|
-
|
|
263
|
+
if (!_this3.toRef.current) return;
|
|
264
|
+
_this3.toRef.current.focus();
|
|
204
265
|
setTimeout(function () {
|
|
205
|
-
if (!
|
|
206
|
-
|
|
266
|
+
if (!_this3.toRef.current) return;
|
|
267
|
+
_this3.toRef.current.setSelectionRange(0, 0);
|
|
207
268
|
}, 0);
|
|
208
269
|
}
|
|
209
270
|
});
|
|
210
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(
|
|
211
|
-
var
|
|
212
|
-
var onChange =
|
|
213
|
-
var prevValue = [(
|
|
271
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this3), "handleToChange", function (value, event) {
|
|
272
|
+
var _this3$asProps$value$3, _this3$asProps$value3, _this3$asProps$value$4, _this3$asProps$value4;
|
|
273
|
+
var onChange = _this3.asProps.onChange;
|
|
274
|
+
var prevValue = [(_this3$asProps$value$3 = (_this3$asProps$value3 = _this3.asProps.value) === null || _this3$asProps$value3 === void 0 ? void 0 : _this3$asProps$value3[0]) !== null && _this3$asProps$value$3 !== void 0 ? _this3$asProps$value$3 : null, (_this3$asProps$value$4 = (_this3$asProps$value4 = _this3.asProps.value) === null || _this3$asProps$value4 === void 0 ? void 0 : _this3$asProps$value4[1]) !== null && _this3$asProps$value$4 !== void 0 ? _this3$asProps$value$4 : null];
|
|
214
275
|
onChange([prevValue[0], value], event);
|
|
215
276
|
});
|
|
216
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(
|
|
217
|
-
if (!
|
|
218
|
-
if (!
|
|
219
|
-
|
|
220
|
-
|
|
277
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this3), "handleFromKeydown", function (event) {
|
|
278
|
+
if (!_this3.toRef.current) return;
|
|
279
|
+
if (!_this3.fromRef.current) return;
|
|
280
|
+
_this3.setState({
|
|
281
|
+
lastChangedInput: 'from'
|
|
282
|
+
});
|
|
283
|
+
if (event.key === 'ArrowRight' && _this3.fromRef.current.selectionStart === _this3.fromRef.current.value.length && _this3.fromRef.current.selectionEnd === _this3.fromRef.current.value.length) {
|
|
284
|
+
_this3.toRef.current.focus();
|
|
221
285
|
setTimeout(function () {
|
|
222
|
-
|
|
286
|
+
_this3.toRef.current.setSelectionRange(0, 0);
|
|
223
287
|
}, 0);
|
|
224
288
|
}
|
|
225
289
|
});
|
|
226
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(
|
|
227
|
-
if (!
|
|
228
|
-
if (!
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
290
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this3), "handleToKeydown", function (event) {
|
|
291
|
+
if (!_this3.toRef.current) return;
|
|
292
|
+
if (!_this3.fromRef.current) return;
|
|
293
|
+
_this3.setState({
|
|
294
|
+
lastChangedInput: 'to'
|
|
295
|
+
});
|
|
296
|
+
if (event.key === 'Backspace' && !_this3.toRef.current.value) {
|
|
297
|
+
var value = _this3.fromRef.current.value;
|
|
298
|
+
_this3.fromRef.current.focus();
|
|
232
299
|
setTimeout(function () {
|
|
233
|
-
|
|
300
|
+
_this3.fromRef.current.setSelectionRange(value.length, value.length);
|
|
234
301
|
}, 0);
|
|
235
302
|
}
|
|
236
|
-
if (event.key === 'ArrowLeft' &&
|
|
237
|
-
var _value =
|
|
238
|
-
|
|
303
|
+
if (event.key === 'ArrowLeft' && _this3.toRef.current.selectionStart === 0 && _this3.toRef.current.selectionEnd === 0) {
|
|
304
|
+
var _value = _this3.fromRef.current.value;
|
|
305
|
+
_this3.fromRef.current.focus();
|
|
239
306
|
setTimeout(function () {
|
|
240
|
-
|
|
307
|
+
_this3.fromRef.current.setSelectionRange(_value.length, _value.length);
|
|
241
308
|
}, 0);
|
|
242
309
|
}
|
|
243
310
|
});
|
|
244
|
-
|
|
311
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this3), "handleDisabledDateInputAttemptChange", function (value) {
|
|
312
|
+
if (value === _this3.asProps.disabledDateInputAttempt) return;
|
|
313
|
+
_this3.handlers.disabledDateInputAttempt(value);
|
|
314
|
+
});
|
|
315
|
+
return _this3;
|
|
245
316
|
}
|
|
246
317
|
(0, _createClass2["default"])(DateRangeRoot, [{
|
|
318
|
+
key: "uncontrolledProps",
|
|
319
|
+
value: function uncontrolledProps() {
|
|
320
|
+
var _this4 = this;
|
|
321
|
+
return {
|
|
322
|
+
disabledDateInputAttempt: [null, function (date) {
|
|
323
|
+
var errorText = _this4.state.errorText;
|
|
324
|
+
var showError = false;
|
|
325
|
+
if (date !== null) {
|
|
326
|
+
errorText = _this4.asProps.disabledErrorText;
|
|
327
|
+
if (errorText === undefined) {
|
|
328
|
+
var key = 'unavailableDate';
|
|
329
|
+
if (_this4.asProps.parts && !_this4.asProps.parts.day) {
|
|
330
|
+
key = 'unavailableMonth';
|
|
331
|
+
}
|
|
332
|
+
if (_this4.state.lastChangedInput === 'to') {
|
|
333
|
+
key = 'unavailableEndDate';
|
|
334
|
+
if (_this4.asProps.parts && !_this4.asProps.parts.day) {
|
|
335
|
+
key = 'unavailableEndMonth';
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
errorText = _this4.asProps.getI18nText(key);
|
|
339
|
+
}
|
|
340
|
+
if (typeof errorText === 'function') {
|
|
341
|
+
errorText = errorText(date);
|
|
342
|
+
}
|
|
343
|
+
showError = true;
|
|
344
|
+
}
|
|
345
|
+
_this4.setState({
|
|
346
|
+
errorText: errorText,
|
|
347
|
+
showError: showError
|
|
348
|
+
});
|
|
349
|
+
}]
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
}, {
|
|
247
353
|
key: "getFromMaskedInputProps",
|
|
248
354
|
value: function getFromMaskedInputProps() {
|
|
249
355
|
var _this$asProps6 = this.asProps,
|
|
@@ -260,7 +366,8 @@ var DateRangeRoot = /*#__PURE__*/function (_Component3) {
|
|
|
260
366
|
locale: locale,
|
|
261
367
|
flex: 1,
|
|
262
368
|
onDisplayedPeriodChange: onDisplayedPeriodChange,
|
|
263
|
-
'aria-haspopup': ariaHasPopup
|
|
369
|
+
'aria-haspopup': ariaHasPopup,
|
|
370
|
+
onMaskPipeBlock: this.handleDisabledDateInputAttemptChange
|
|
264
371
|
}, otherProps);
|
|
265
372
|
}
|
|
266
373
|
}, {
|
|
@@ -280,7 +387,8 @@ var DateRangeRoot = /*#__PURE__*/function (_Component3) {
|
|
|
280
387
|
locale: locale,
|
|
281
388
|
flex: 1,
|
|
282
389
|
onDisplayedPeriodChange: onDisplayedPeriodChange,
|
|
283
|
-
'aria-haspopup': ariaHasPopup
|
|
390
|
+
'aria-haspopup': ariaHasPopup,
|
|
391
|
+
onMaskPipeBlock: this.handleDisabledDateInputAttemptChange
|
|
284
392
|
}, otherProps);
|
|
285
393
|
}
|
|
286
394
|
}, {
|
|
@@ -300,8 +408,19 @@ var DateRangeRoot = /*#__PURE__*/function (_Component3) {
|
|
|
300
408
|
var _this$asProps8 = this.asProps,
|
|
301
409
|
Children = _this$asProps8.Children,
|
|
302
410
|
styles = _this$asProps8.styles,
|
|
303
|
-
w = _this$asProps8.w
|
|
411
|
+
w = _this$asProps8.w,
|
|
412
|
+
state = _this$asProps8.state;
|
|
413
|
+
var _this$state2 = this.state,
|
|
414
|
+
errorText = _this$state2.errorText,
|
|
415
|
+
showError = _this$state2.showError,
|
|
416
|
+
lastChangedInput = _this$state2.lastChangedInput;
|
|
304
417
|
return _ref10 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SDateRange, _ref10.cn("SDateRange", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
|
|
418
|
+
"tag": _tooltip["default"],
|
|
419
|
+
"placement": lastChangedInput === 'to' ? 'top-end' : 'top-start',
|
|
420
|
+
"title": errorText,
|
|
421
|
+
"theme": 'warning',
|
|
422
|
+
"visible": showError,
|
|
423
|
+
"state": showError ? 'invalid' : state,
|
|
305
424
|
"__excludeProps": ['onChange', 'value', 'aria-expanded'],
|
|
306
425
|
"w": w
|
|
307
426
|
}, _ref3))), /*#__PURE__*/_react["default"].createElement(Children, _ref10.cn("Children", {})));
|
|
@@ -314,7 +433,8 @@ var DateRangeRoot = /*#__PURE__*/function (_Component3) {
|
|
|
314
433
|
(0, _defineProperty2["default"])(DateRangeRoot, "defaultProps", {
|
|
315
434
|
children: function children() {
|
|
316
435
|
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));
|
|
317
|
-
}
|
|
436
|
+
},
|
|
437
|
+
defaultDisabledDateInputAttempt: false
|
|
318
438
|
});
|
|
319
439
|
var FromMaskedInput = function FromMaskedInput(props) {
|
|
320
440
|
var _ref4 = arguments[0],
|
|
@@ -369,6 +489,7 @@ var MaskedInput = function MaskedInput(_ref16) {
|
|
|
369
489
|
placeholders = _ref16$placeholders === void 0 ? defaultPlaceholders : _ref16$placeholders,
|
|
370
490
|
_ref16$labelPrefix = _ref16.labelPrefix,
|
|
371
491
|
labelPrefix = _ref16$labelPrefix === void 0 ? 'Date' : _ref16$labelPrefix,
|
|
492
|
+
onMaskPipeBlock = _ref16.onMaskPipeBlock,
|
|
372
493
|
__excludeProps = _ref16.__excludeProps,
|
|
373
494
|
_root = _ref16.Root,
|
|
374
495
|
otherProps = (0, _objectWithoutProperties2["default"])(_ref16, _excluded6);
|
|
@@ -473,6 +594,7 @@ var MaskedInput = function MaskedInput(_ref16) {
|
|
|
473
594
|
}
|
|
474
595
|
}
|
|
475
596
|
if (placeholdersOnly) {
|
|
597
|
+
onMaskPipeBlock === null || onMaskPipeBlock === void 0 ? void 0 : onMaskPipeBlock(null);
|
|
476
598
|
return '';
|
|
477
599
|
}
|
|
478
600
|
var getOffsetTo = function getOffsetTo(partName) {
|
|
@@ -542,10 +664,14 @@ var MaskedInput = function MaskedInput(_ref16) {
|
|
|
542
664
|
date.setMonth(allowedParts.month ? parseInt(month, 10) - 1 : 0);
|
|
543
665
|
date.setDate(allowedParts.day ? parseInt(day, 10) : 1);
|
|
544
666
|
if (disabledDates !== null && disabledDates !== void 0 && disabledDates.some((0, _includesDate["default"])((0, _dayjs["default"])(date), 'date'))) {
|
|
667
|
+
onMaskPipeBlock === null || onMaskPipeBlock === void 0 ? void 0 : onMaskPipeBlock(date);
|
|
545
668
|
return false;
|
|
546
669
|
}
|
|
547
670
|
if (allowedParts.day) {
|
|
548
|
-
if (date.getDate() !== parseInt(day, 10))
|
|
671
|
+
if (date.getDate() !== parseInt(day, 10)) {
|
|
672
|
+
onMaskPipeBlock === null || onMaskPipeBlock === void 0 ? void 0 : onMaskPipeBlock(date);
|
|
673
|
+
return false;
|
|
674
|
+
}
|
|
549
675
|
}
|
|
550
676
|
}
|
|
551
677
|
var result = [];
|
|
@@ -563,11 +689,12 @@ var MaskedInput = function MaskedInput(_ref16) {
|
|
|
563
689
|
} finally {
|
|
564
690
|
_iterator4.f();
|
|
565
691
|
}
|
|
692
|
+
onMaskPipeBlock === null || onMaskPipeBlock === void 0 ? void 0 : onMaskPipeBlock(null);
|
|
566
693
|
return {
|
|
567
694
|
value: result.join(sep),
|
|
568
695
|
indexesOfPipedChars: indexesOfPipedChars
|
|
569
696
|
};
|
|
570
|
-
}, [placeholders, sep, order, allowedParts, disabledDates]);
|
|
697
|
+
}, [placeholders, sep, order, allowedParts, disabledDates, onMaskPipeBlock]);
|
|
571
698
|
var handleChange = _react["default"].useCallback(function (value) {
|
|
572
699
|
var parsed = {};
|
|
573
700
|
for (var partName in placeholders) {
|