@semcore/date-picker 3.4.5 → 3.4.7
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 +8 -2
- package/lib/cjs/DatePicker.js +32 -9
- package/lib/cjs/DatePicker.js.map +1 -1
- package/lib/cjs/DateRangePicker.js +23 -0
- package/lib/cjs/DateRangePicker.js.map +1 -1
- package/lib/cjs/MonthPicker.js +33 -3
- package/lib/cjs/MonthPicker.js.map +1 -1
- package/lib/cjs/MonthRangePicker.js +33 -3
- package/lib/cjs/MonthRangePicker.js.map +1 -1
- package/lib/cjs/components/Calendar.js +20 -18
- package/lib/cjs/components/Calendar.js.map +1 -1
- package/lib/cjs/components/InputTrigger.js +820 -0
- package/lib/cjs/components/InputTrigger.js.map +1 -0
- package/lib/cjs/components/PickerAbstract.js +36 -15
- package/lib/cjs/components/PickerAbstract.js.map +1 -1
- package/lib/cjs/components/RangePickerAbstract.js +34 -13
- package/lib/cjs/components/RangePickerAbstract.js.map +1 -1
- package/lib/cjs/components/index.js +52 -32
- package/lib/cjs/components/index.js.map +1 -1
- package/lib/cjs/index.d.js.map +1 -1
- package/lib/cjs/style/date-picker.shadow.css +48 -0
- package/lib/es6/DatePicker.js +33 -10
- package/lib/es6/DatePicker.js.map +1 -1
- package/lib/es6/DateRangePicker.js +24 -1
- package/lib/es6/DateRangePicker.js.map +1 -1
- package/lib/es6/MonthPicker.js +33 -4
- package/lib/es6/MonthPicker.js.map +1 -1
- package/lib/es6/MonthRangePicker.js +33 -4
- package/lib/es6/MonthRangePicker.js.map +1 -1
- package/lib/es6/components/Calendar.js +20 -18
- package/lib/es6/components/Calendar.js.map +1 -1
- package/lib/es6/components/InputTrigger.js +803 -0
- package/lib/es6/components/InputTrigger.js.map +1 -0
- package/lib/es6/components/PickerAbstract.js +36 -15
- package/lib/es6/components/PickerAbstract.js.map +1 -1
- package/lib/es6/components/RangePickerAbstract.js +34 -13
- package/lib/es6/components/RangePickerAbstract.js.map +1 -1
- package/lib/es6/components/index.js +48 -30
- package/lib/es6/components/index.js.map +1 -1
- package/lib/es6/index.d.js.map +1 -1
- package/lib/es6/style/date-picker.shadow.css +48 -0
- package/lib/types/index.d.ts +64 -2
- package/package.json +10 -5
|
@@ -0,0 +1,820 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports["default"] = void 0;
|
|
11
|
+
|
|
12
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
+
|
|
14
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
|
+
|
|
16
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
17
|
+
|
|
18
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
19
|
+
|
|
20
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
21
|
+
|
|
22
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
23
|
+
|
|
24
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
25
|
+
|
|
26
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
27
|
+
|
|
28
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
29
|
+
|
|
30
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
31
|
+
|
|
32
|
+
var _core = _interopRequireWildcard(require("@semcore/core"));
|
|
33
|
+
|
|
34
|
+
var _react = _interopRequireDefault(require("react"));
|
|
35
|
+
|
|
36
|
+
var _baseTrigger = _interopRequireDefault(require("@semcore/base-trigger"));
|
|
37
|
+
|
|
38
|
+
var _inputMask = _interopRequireDefault(require("@semcore/input-mask"));
|
|
39
|
+
|
|
40
|
+
var _flexBox = require("@semcore/flex-box");
|
|
41
|
+
|
|
42
|
+
var _m = _interopRequireDefault(require("@semcore/icon/Calendar/m"));
|
|
43
|
+
|
|
44
|
+
var _neighborLocation = _interopRequireDefault(require("@semcore/neighbor-location"));
|
|
45
|
+
|
|
46
|
+
var _includesDate = _interopRequireDefault(require("../utils/includesDate"));
|
|
47
|
+
|
|
48
|
+
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
49
|
+
|
|
50
|
+
var _assignProps8 = _interopRequireDefault(require("@semcore/utils/lib/assignProps"));
|
|
51
|
+
|
|
52
|
+
var _excluded = ["children", "id", "role", "aria-haspopup", "aria-label", "style"],
|
|
53
|
+
_excluded2 = ["children", "id", "role", "aria-haspopup", "aria-label", "style"],
|
|
54
|
+
_excluded3 = ["value", "onChange", "onDisplayedPeriodChange", "locale", "w"],
|
|
55
|
+
_excluded4 = ["value", "locale", "onDisplayedPeriodChange"],
|
|
56
|
+
_excluded5 = ["value", "locale", "onDisplayedPeriodChange"],
|
|
57
|
+
_excluded6 = ["date", "onDateChange", "onDisplayedPeriodChange", "locale", "styles", "parts", "disabledDates", "forwardRef", "placeholders", "labelPrefix", "__excludeProps", "Root"];
|
|
58
|
+
|
|
59
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
60
|
+
|
|
61
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
62
|
+
|
|
63
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
64
|
+
|
|
65
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
66
|
+
|
|
67
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
68
|
+
|
|
69
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
70
|
+
|
|
71
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
72
|
+
|
|
73
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
74
|
+
|
|
75
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
76
|
+
|
|
77
|
+
/*__reshadow-styles__:"../style/date-picker.shadow.css"*/
|
|
78
|
+
var style = (
|
|
79
|
+
/*__reshadow_css_start__*/
|
|
80
|
+
_core.sstyled.insert(
|
|
81
|
+
/*__inner_css_start__*/
|
|
82
|
+
".___SPopper_1rxcc_gg_{padding:16px;outline:0}.___SPopper_1rxcc_gg_::-moz-focus-inner{border:none;padding:0}.___SPopper_1rxcc_gg_:active,.___SPopper_1rxcc_gg_:focus,.___SPopper_1rxcc_gg_:hover{outline:0;text-decoration:none}.___SPopper_1rxcc_gg_:focus{box-shadow:0 0 0 3px rgba(0, 143, 248, 0.2)}.___SHeader_1rxcc_gg_{display:flex;align-items:center}.___STitle_1rxcc_gg_{font-size:14px;color:#191b23;height:32px;width:100%;display:flex;justify-content:center;align-items:center}.___SToday_1rxcc_gg_{display:flex;margin-top:12px;justify-content:center}.___SPeriod_1rxcc_gg_{display:flex;flex-direction:column;margin-bottom:8px}.___SDateRange_1rxcc_gg_:active .___SOutline_1rxcc_gg_,.___SDateRange_1rxcc_gg_:hover .___SOutline_1rxcc_gg_,.___SDateRange_1rxcc_gg_.__active_1rxcc_gg_ .___SOutline_1rxcc_gg_,.___SDateRange_1rxcc_gg_.__focus-within_1rxcc_gg_ .___SOutline_1rxcc_gg_,.___SSingleDateInput_1rxcc_gg_:active .___SOutline_1rxcc_gg_,.___SSingleDateInput_1rxcc_gg_:hover .___SOutline_1rxcc_gg_,.___SSingleDateInput_1rxcc_gg_.__active_1rxcc_gg_ .___SOutline_1rxcc_gg_,.___SSingleDateInput_1rxcc_gg_.__focus-within_1rxcc_gg_ .___SOutline_1rxcc_gg_{background-color:rgba(138,142,155,.3)}.___SDateRange_1rxcc_gg_:active .___SOutline_1rxcc_gg_,.___SDateRange_1rxcc_gg_:focus-within .___SOutline_1rxcc_gg_,.___SDateRange_1rxcc_gg_:hover .___SOutline_1rxcc_gg_,.___SDateRange_1rxcc_gg_.__active_1rxcc_gg_ .___SOutline_1rxcc_gg_,.___SSingleDateInput_1rxcc_gg_:active .___SOutline_1rxcc_gg_,.___SSingleDateInput_1rxcc_gg_:focus-within .___SOutline_1rxcc_gg_,.___SSingleDateInput_1rxcc_gg_:hover .___SOutline_1rxcc_gg_,.___SSingleDateInput_1rxcc_gg_.__active_1rxcc_gg_ .___SOutline_1rxcc_gg_{background-color:rgba(138,142,155,.3)}.___SIndicator_1rxcc_gg_{color:#6c6e79}.___SHumanizedDate_1rxcc_gg_{position:absolute;pointer-events:none}.___SDateRange_1rxcc_gg_ .___SMask_1rxcc_gg_,.___SDateRange_1rxcc_gg_ .___SValue_1rxcc_gg_,.___SSingleDateInput_1rxcc_gg_ .___SMask_1rxcc_gg_,.___SSingleDateInput_1rxcc_gg_ .___SValue_1rxcc_gg_{opacity:0}.___SSingleDateInput_1rxcc_gg_.__focus-within_1rxcc_gg_ .___SHumanizedDate_1rxcc_gg_{opacity:0;z-index:-1000}.___SSingleDateInput_1rxcc_gg_:focus-within .___SHumanizedDate_1rxcc_gg_{opacity:0;z-index:-1000}.___SSingleDateInput_1rxcc_gg_.__focus-within_1rxcc_gg_ .___SMask_1rxcc_gg_,.___SSingleDateInput_1rxcc_gg_.__focus-within_1rxcc_gg_ .___SValue_1rxcc_gg_{opacity:1}.___SSingleDateInput_1rxcc_gg_:focus-within .___SMask_1rxcc_gg_,.___SSingleDateInput_1rxcc_gg_:focus-within .___SValue_1rxcc_gg_{opacity:1}.___SDateRange_1rxcc_gg_ .___SValue_1rxcc_gg_{opacity:0}.___SDateRange_1rxcc_gg_.__focus-within_1rxcc_gg_ .___SHumanizedDate_1rxcc_gg_{opacity:0;z-index:-1000}.___SDateRange_1rxcc_gg_:focus-within .___SHumanizedDate_1rxcc_gg_{opacity:0;z-index:-1000}.___SDateRange_1rxcc_gg_.__focus-within_1rxcc_gg_ .___SMask_1rxcc_gg_,.___SDateRange_1rxcc_gg_.__focus-within_1rxcc_gg_ .___SValue_1rxcc_gg_{opacity:1}.___SDateRange_1rxcc_gg_:focus-within .___SMask_1rxcc_gg_,.___SDateRange_1rxcc_gg_:focus-within .___SValue_1rxcc_gg_{opacity:1}.___SInputMask_1rxcc_gg_.__noHumanizedDate_1rxcc_gg_ .___SMask_1rxcc_gg_,.___SInputMask_1rxcc_gg_.__noHumanizedDate_1rxcc_gg_ .___SValue_1rxcc_gg_{opacity:1}"
|
|
83
|
+
/*__inner_css_end__*/
|
|
84
|
+
, "1rxcc_gg_")
|
|
85
|
+
/*__reshadow_css_end__*/
|
|
86
|
+
, {
|
|
87
|
+
"__SPopper": "___SPopper_1rxcc_gg_",
|
|
88
|
+
"__SHeader": "___SHeader_1rxcc_gg_",
|
|
89
|
+
"__STitle": "___STitle_1rxcc_gg_",
|
|
90
|
+
"__SToday": "___SToday_1rxcc_gg_",
|
|
91
|
+
"__SPeriod": "___SPeriod_1rxcc_gg_",
|
|
92
|
+
"__SDateRange": "___SDateRange_1rxcc_gg_",
|
|
93
|
+
"__SOutline": "___SOutline_1rxcc_gg_",
|
|
94
|
+
"_active": "__active_1rxcc_gg_",
|
|
95
|
+
"_focus-within": "__focus-within_1rxcc_gg_",
|
|
96
|
+
"__SSingleDateInput": "___SSingleDateInput_1rxcc_gg_",
|
|
97
|
+
"__SIndicator": "___SIndicator_1rxcc_gg_",
|
|
98
|
+
"__SHumanizedDate": "___SHumanizedDate_1rxcc_gg_",
|
|
99
|
+
"__SMask": "___SMask_1rxcc_gg_",
|
|
100
|
+
"__SValue": "___SValue_1rxcc_gg_",
|
|
101
|
+
"__SInputMask": "___SInputMask_1rxcc_gg_",
|
|
102
|
+
"_noHumanizedDate": "__noHumanizedDate_1rxcc_gg_"
|
|
103
|
+
});
|
|
104
|
+
var defaultAllowedParts = {
|
|
105
|
+
year: true,
|
|
106
|
+
month: true,
|
|
107
|
+
day: true
|
|
108
|
+
};
|
|
109
|
+
var defaultPlaceholders = {
|
|
110
|
+
year: 'Y',
|
|
111
|
+
month: 'M',
|
|
112
|
+
day: 'D'
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
var InputTriggerRoot = /*#__PURE__*/function (_Component) {
|
|
116
|
+
(0, _inherits2["default"])(InputTriggerRoot, _Component);
|
|
117
|
+
|
|
118
|
+
var _super = _createSuper(InputTriggerRoot);
|
|
119
|
+
|
|
120
|
+
function InputTriggerRoot() {
|
|
121
|
+
(0, _classCallCheck2["default"])(this, InputTriggerRoot);
|
|
122
|
+
return _super.apply(this, arguments);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
(0, _createClass2["default"])(InputTriggerRoot, [{
|
|
126
|
+
key: "getSingleDateInputProps",
|
|
127
|
+
value: function getSingleDateInputProps() {
|
|
128
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
129
|
+
var _this$asProps = this.asProps,
|
|
130
|
+
children = _this$asProps.children,
|
|
131
|
+
id = _this$asProps.id,
|
|
132
|
+
role = _this$asProps.role,
|
|
133
|
+
ariaHasPopup = _this$asProps['aria-haspopup'],
|
|
134
|
+
ariaLabel = _this$asProps['aria-label'],
|
|
135
|
+
style = _this$asProps.style,
|
|
136
|
+
otherProps = (0, _objectWithoutProperties2["default"])(_this$asProps, _excluded);
|
|
137
|
+
return otherProps;
|
|
138
|
+
}
|
|
139
|
+
}, {
|
|
140
|
+
key: "getDateRangeProps",
|
|
141
|
+
value: function getDateRangeProps() {
|
|
142
|
+
var _this$asProps2 = this.asProps,
|
|
143
|
+
children = _this$asProps2.children,
|
|
144
|
+
id = _this$asProps2.id,
|
|
145
|
+
role = _this$asProps2.role,
|
|
146
|
+
ariaHasPopup = _this$asProps2['aria-haspopup'],
|
|
147
|
+
ariaLabel = _this$asProps2['aria-label'],
|
|
148
|
+
style = _this$asProps2.style,
|
|
149
|
+
otherProps = (0, _objectWithoutProperties2["default"])(_this$asProps2, _excluded2);
|
|
150
|
+
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
151
|
+
|
|
152
|
+
return otherProps;
|
|
153
|
+
}
|
|
154
|
+
}, {
|
|
155
|
+
key: "render",
|
|
156
|
+
value: function render() {
|
|
157
|
+
var _ref = this.asProps,
|
|
158
|
+
_ref8;
|
|
159
|
+
|
|
160
|
+
var SInputTrigger = _flexBox.Box;
|
|
161
|
+
var _this$asProps3 = this.asProps,
|
|
162
|
+
Children = _this$asProps3.Children,
|
|
163
|
+
style = _this$asProps3.style;
|
|
164
|
+
return _ref8 = (0, _core.sstyled)(style), /*#__PURE__*/_react["default"].createElement(SInputTrigger, _ref8.cn("SInputTrigger", _objectSpread({}, (0, _core.assignProps)({
|
|
165
|
+
"aria-label": "Date field",
|
|
166
|
+
"__excludeProps": ['onChange', 'value', 'role']
|
|
167
|
+
}, _ref))), /*#__PURE__*/_react["default"].createElement(Children, _ref8.cn("Children", {})));
|
|
168
|
+
}
|
|
169
|
+
}]);
|
|
170
|
+
return InputTriggerRoot;
|
|
171
|
+
}(_core.Component);
|
|
172
|
+
|
|
173
|
+
(0, _defineProperty2["default"])(InputTriggerRoot, "displayName", 'InputTrigger');
|
|
174
|
+
(0, _defineProperty2["default"])(InputTriggerRoot, "style", style);
|
|
175
|
+
|
|
176
|
+
var SingleDateInputRoot = /*#__PURE__*/function (_Component2) {
|
|
177
|
+
(0, _inherits2["default"])(SingleDateInputRoot, _Component2);
|
|
178
|
+
|
|
179
|
+
var _super2 = _createSuper(SingleDateInputRoot);
|
|
180
|
+
|
|
181
|
+
function SingleDateInputRoot() {
|
|
182
|
+
(0, _classCallCheck2["default"])(this, SingleDateInputRoot);
|
|
183
|
+
return _super2.apply(this, arguments);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
(0, _createClass2["default"])(SingleDateInputRoot, [{
|
|
187
|
+
key: "getMaskedInputProps",
|
|
188
|
+
value: function getMaskedInputProps() {
|
|
189
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
190
|
+
var _this$asProps4 = this.asProps,
|
|
191
|
+
value = _this$asProps4.value,
|
|
192
|
+
onChange = _this$asProps4.onChange,
|
|
193
|
+
onDisplayedPeriodChange = _this$asProps4.onDisplayedPeriodChange,
|
|
194
|
+
locale = _this$asProps4.locale,
|
|
195
|
+
w = _this$asProps4.w,
|
|
196
|
+
otherProps = (0, _objectWithoutProperties2["default"])(_this$asProps4, _excluded3);
|
|
197
|
+
return _objectSpread({
|
|
198
|
+
date: value,
|
|
199
|
+
onDateChange: onChange,
|
|
200
|
+
onDisplayedPeriodChange: onDisplayedPeriodChange,
|
|
201
|
+
locale: locale
|
|
202
|
+
}, otherProps);
|
|
203
|
+
}
|
|
204
|
+
}, {
|
|
205
|
+
key: "render",
|
|
206
|
+
value: function render() {
|
|
207
|
+
var _ref2 = this.asProps,
|
|
208
|
+
_ref9;
|
|
209
|
+
|
|
210
|
+
var _this$asProps5 = this.asProps,
|
|
211
|
+
Children = _this$asProps5.Children,
|
|
212
|
+
forwardRef = _this$asProps5.forwardRef,
|
|
213
|
+
styles = _this$asProps5.styles;
|
|
214
|
+
var SSingleDateInput = _inputMask["default"];
|
|
215
|
+
return _ref9 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SSingleDateInput, _ref9.cn("SSingleDateInput", _objectSpread({}, (0, _core.assignProps)({
|
|
216
|
+
"ref": forwardRef,
|
|
217
|
+
"__excludeProps": ['onChange', 'style']
|
|
218
|
+
}, _ref2))), /*#__PURE__*/_react["default"].createElement(_neighborLocation["default"], _ref9.cn("NeighborLocation", {}), /*#__PURE__*/_react["default"].createElement(Children, _ref9.cn("Children", {}))));
|
|
219
|
+
}
|
|
220
|
+
}]);
|
|
221
|
+
return SingleDateInputRoot;
|
|
222
|
+
}(_core.Component);
|
|
223
|
+
|
|
224
|
+
(0, _defineProperty2["default"])(SingleDateInputRoot, "displayName", 'SingleDateInput');
|
|
225
|
+
(0, _defineProperty2["default"])(SingleDateInputRoot, "style", style);
|
|
226
|
+
(0, _defineProperty2["default"])(SingleDateInputRoot, "defaultProps", {
|
|
227
|
+
children: function children() {
|
|
228
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(SingleDateInput.Indicator, null), /*#__PURE__*/_react["default"].createElement(SingleDateInput.MaskedInput, null));
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
var DateRangeRoot = /*#__PURE__*/function (_Component3) {
|
|
233
|
+
(0, _inherits2["default"])(DateRangeRoot, _Component3);
|
|
234
|
+
|
|
235
|
+
var _super3 = _createSuper(DateRangeRoot);
|
|
236
|
+
|
|
237
|
+
function DateRangeRoot() {
|
|
238
|
+
var _this;
|
|
239
|
+
|
|
240
|
+
(0, _classCallCheck2["default"])(this, DateRangeRoot);
|
|
241
|
+
|
|
242
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
243
|
+
args[_key] = arguments[_key];
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
_this = _super3.call.apply(_super3, [this].concat(args));
|
|
247
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "fromRef", /*#__PURE__*/_react["default"].createRef());
|
|
248
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "toRef", /*#__PURE__*/_react["default"].createRef());
|
|
249
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleFromChange", function (value, event) {
|
|
250
|
+
var _this$asProps$value$, _this$asProps$value, _this$asProps$value$2, _this$asProps$value2;
|
|
251
|
+
|
|
252
|
+
var onChange = _this.asProps.onChange;
|
|
253
|
+
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];
|
|
254
|
+
onChange([value, prevValue[1]], event);
|
|
255
|
+
|
|
256
|
+
if (value) {
|
|
257
|
+
if (!_this.toRef.current) return;
|
|
258
|
+
|
|
259
|
+
_this.toRef.current.focus();
|
|
260
|
+
|
|
261
|
+
setTimeout(function () {
|
|
262
|
+
if (!_this.toRef.current) return;
|
|
263
|
+
|
|
264
|
+
_this.toRef.current.setSelectionRange(0, 0);
|
|
265
|
+
}, 0);
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleToChange", function (value, event) {
|
|
269
|
+
var _this$asProps$value$3, _this$asProps$value3, _this$asProps$value$4, _this$asProps$value4;
|
|
270
|
+
|
|
271
|
+
var onChange = _this.asProps.onChange;
|
|
272
|
+
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];
|
|
273
|
+
onChange([prevValue[0], value], event);
|
|
274
|
+
});
|
|
275
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleFromKeydown", function (event) {
|
|
276
|
+
if (!_this.toRef.current) return;
|
|
277
|
+
if (!_this.fromRef.current) return;
|
|
278
|
+
|
|
279
|
+
if (event.code === 'ArrowRight' && _this.fromRef.current.selectionStart === _this.fromRef.current.value.length && _this.fromRef.current.selectionEnd === _this.fromRef.current.value.length) {
|
|
280
|
+
_this.toRef.current.focus();
|
|
281
|
+
|
|
282
|
+
setTimeout(function () {
|
|
283
|
+
_this.toRef.current.setSelectionRange(0, 0);
|
|
284
|
+
}, 0);
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleToKeydown", function (event) {
|
|
288
|
+
if (!_this.toRef.current) return;
|
|
289
|
+
if (!_this.fromRef.current) return;
|
|
290
|
+
|
|
291
|
+
if (event.code === 'Backspace' && !_this.toRef.current.value) {
|
|
292
|
+
var value = _this.fromRef.current.value;
|
|
293
|
+
|
|
294
|
+
_this.fromRef.current.focus();
|
|
295
|
+
|
|
296
|
+
setTimeout(function () {
|
|
297
|
+
_this.fromRef.current.setSelectionRange(value.length, value.length);
|
|
298
|
+
}, 0);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
if (event.code === 'ArrowLeft' && _this.toRef.current.selectionStart === 0 && _this.toRef.current.selectionEnd === 0) {
|
|
302
|
+
var _value = _this.fromRef.current.value;
|
|
303
|
+
|
|
304
|
+
_this.fromRef.current.focus();
|
|
305
|
+
|
|
306
|
+
setTimeout(function () {
|
|
307
|
+
_this.fromRef.current.setSelectionRange(_value.length, _value.length);
|
|
308
|
+
}, 0);
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
return _this;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
(0, _createClass2["default"])(DateRangeRoot, [{
|
|
315
|
+
key: "getFromMaskedInputProps",
|
|
316
|
+
value: function getFromMaskedInputProps() {
|
|
317
|
+
var _this$asProps6 = this.asProps,
|
|
318
|
+
value = _this$asProps6.value,
|
|
319
|
+
locale = _this$asProps6.locale,
|
|
320
|
+
onDisplayedPeriodChange = _this$asProps6.onDisplayedPeriodChange,
|
|
321
|
+
otherProps = (0, _objectWithoutProperties2["default"])(_this$asProps6, _excluded4);
|
|
322
|
+
return (0, _assignProps8["default"])({
|
|
323
|
+
ref: this.fromRef,
|
|
324
|
+
date: value === null || value === void 0 ? void 0 : value[0],
|
|
325
|
+
onDateChange: this.handleFromChange,
|
|
326
|
+
onKeyDown: this.handleFromKeydown,
|
|
327
|
+
locale: locale,
|
|
328
|
+
flex: 1,
|
|
329
|
+
onDisplayedPeriodChange: onDisplayedPeriodChange
|
|
330
|
+
}, otherProps);
|
|
331
|
+
}
|
|
332
|
+
}, {
|
|
333
|
+
key: "getToMaskedInputProps",
|
|
334
|
+
value: function getToMaskedInputProps() {
|
|
335
|
+
var _this$asProps7 = this.asProps,
|
|
336
|
+
value = _this$asProps7.value,
|
|
337
|
+
locale = _this$asProps7.locale,
|
|
338
|
+
onDisplayedPeriodChange = _this$asProps7.onDisplayedPeriodChange,
|
|
339
|
+
otherProps = (0, _objectWithoutProperties2["default"])(_this$asProps7, _excluded5);
|
|
340
|
+
return (0, _assignProps8["default"])({
|
|
341
|
+
ref: this.toRef,
|
|
342
|
+
date: value === null || value === void 0 ? void 0 : value[1],
|
|
343
|
+
onDateChange: this.handleToChange,
|
|
344
|
+
onKeyDown: this.handleToKeydown,
|
|
345
|
+
locale: locale,
|
|
346
|
+
flex: 1,
|
|
347
|
+
onDisplayedPeriodChange: onDisplayedPeriodChange
|
|
348
|
+
}, otherProps);
|
|
349
|
+
}
|
|
350
|
+
}, {
|
|
351
|
+
key: "render",
|
|
352
|
+
value: function render() {
|
|
353
|
+
var _ref3 = this.asProps,
|
|
354
|
+
_ref10;
|
|
355
|
+
|
|
356
|
+
var SDateRange = _inputMask["default"];
|
|
357
|
+
var _this$asProps8 = this.asProps,
|
|
358
|
+
Children = _this$asProps8.Children,
|
|
359
|
+
styles = _this$asProps8.styles,
|
|
360
|
+
w = _this$asProps8.w;
|
|
361
|
+
return _ref10 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SDateRange, _ref10.cn("SDateRange", _objectSpread({}, (0, _core.assignProps)({
|
|
362
|
+
"__excludeProps": ['onChange', 'value'],
|
|
363
|
+
"w": w
|
|
364
|
+
}, _ref3))), /*#__PURE__*/_react["default"].createElement(Children, _ref10.cn("Children", {})));
|
|
365
|
+
}
|
|
366
|
+
}]);
|
|
367
|
+
return DateRangeRoot;
|
|
368
|
+
}(_core.Component);
|
|
369
|
+
|
|
370
|
+
(0, _defineProperty2["default"])(DateRangeRoot, "displayName", 'DateRange');
|
|
371
|
+
(0, _defineProperty2["default"])(DateRangeRoot, "style", style);
|
|
372
|
+
(0, _defineProperty2["default"])(DateRangeRoot, "defaultProps", {
|
|
373
|
+
children: function children() {
|
|
374
|
+
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));
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
var FromMaskedInput = function FromMaskedInput(props) {
|
|
379
|
+
var _ref4 = arguments[0],
|
|
380
|
+
_ref11;
|
|
381
|
+
|
|
382
|
+
var SFromMaskedInput = MaskedInput;
|
|
383
|
+
return _ref11 = (0, _core.sstyled)(props.styles), /*#__PURE__*/_react["default"].createElement(SFromMaskedInput, _ref11.cn("SFromMaskedInput", _objectSpread({}, (0, _core.assignProps)({
|
|
384
|
+
"labelPrefix": "from date"
|
|
385
|
+
}, _ref4))));
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
var ToMaskedInput = function ToMaskedInput(props) {
|
|
389
|
+
var _ref5 = arguments[0],
|
|
390
|
+
_ref12;
|
|
391
|
+
|
|
392
|
+
var SToMaskedInput = MaskedInput;
|
|
393
|
+
return _ref12 = (0, _core.sstyled)(props.styles), /*#__PURE__*/_react["default"].createElement(SToMaskedInput, _ref12.cn("SToMaskedInput", _objectSpread({}, (0, _core.assignProps)({
|
|
394
|
+
"labelPrefix": "to date"
|
|
395
|
+
}, _ref5))));
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
var Indicator = function Indicator(props) {
|
|
399
|
+
var _ref6 = arguments[0],
|
|
400
|
+
_ref13;
|
|
401
|
+
|
|
402
|
+
var SIndicator = _inputMask["default"].Addon;
|
|
403
|
+
return _ref13 = (0, _core.sstyled)(props.styles), /*#__PURE__*/_react["default"].createElement(SIndicator, _ref13.cn("SIndicator", _objectSpread({}, (0, _core.assignProps)({
|
|
404
|
+
"tag": _m["default"],
|
|
405
|
+
"aria-hidden": "true",
|
|
406
|
+
"tabIndex": -1
|
|
407
|
+
}, _ref6))));
|
|
408
|
+
};
|
|
409
|
+
|
|
410
|
+
var RangeSep = function RangeSep(props) {
|
|
411
|
+
var _ref7 = arguments[0],
|
|
412
|
+
_ref14;
|
|
413
|
+
|
|
414
|
+
var SRangeSep = _inputMask["default"].Addon;
|
|
415
|
+
return _ref14 = (0, _core.sstyled)(props.styles), /*#__PURE__*/_react["default"].createElement(SRangeSep, _ref14.cn("SRangeSep", _objectSpread({}, (0, _core.assignProps)({
|
|
416
|
+
"tag": _flexBox.Flex,
|
|
417
|
+
"alignItems": "center",
|
|
418
|
+
"justifyContent": "center",
|
|
419
|
+
"pl": 0,
|
|
420
|
+
"flex": "0"
|
|
421
|
+
}, _ref7))), "-");
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
var MaskedInput = function MaskedInput(_ref16) {
|
|
425
|
+
var _ref15;
|
|
426
|
+
|
|
427
|
+
var outerValue = _ref16.date,
|
|
428
|
+
onDateChange = _ref16.onDateChange,
|
|
429
|
+
onDisplayedPeriodChange = _ref16.onDisplayedPeriodChange,
|
|
430
|
+
locale = _ref16.locale,
|
|
431
|
+
styles = _ref16.styles,
|
|
432
|
+
_ref16$parts = _ref16.parts,
|
|
433
|
+
allowedParts = _ref16$parts === void 0 ? defaultAllowedParts : _ref16$parts,
|
|
434
|
+
disabledDates = _ref16.disabledDates,
|
|
435
|
+
forwardRef = _ref16.forwardRef,
|
|
436
|
+
_ref16$placeholders = _ref16.placeholders,
|
|
437
|
+
placeholders = _ref16$placeholders === void 0 ? defaultPlaceholders : _ref16$placeholders,
|
|
438
|
+
_ref16$labelPrefix = _ref16.labelPrefix,
|
|
439
|
+
labelPrefix = _ref16$labelPrefix === void 0 ? 'Date' : _ref16$labelPrefix,
|
|
440
|
+
__excludeProps = _ref16.__excludeProps,
|
|
441
|
+
_root = _ref16.Root,
|
|
442
|
+
otherProps = (0, _objectWithoutProperties2["default"])(_ref16, _excluded6);
|
|
443
|
+
|
|
444
|
+
if (placeholders.year.length !== 1 || placeholders.month.length !== 1 || placeholders.day.length !== 1) {
|
|
445
|
+
// eslint-disable-next-line no-console
|
|
446
|
+
console.error({
|
|
447
|
+
placeholders: placeholders
|
|
448
|
+
});
|
|
449
|
+
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);
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
var _React$useMemo = _react["default"].useMemo(function () {
|
|
453
|
+
var _sep;
|
|
454
|
+
|
|
455
|
+
var exampleDate = new Date(2000, 4, 29);
|
|
456
|
+
var options = {
|
|
457
|
+
year: 'numeric',
|
|
458
|
+
month: '2-digit',
|
|
459
|
+
day: '2-digit'
|
|
460
|
+
};
|
|
461
|
+
var dateTimeFormat = new Intl.DateTimeFormat(locale, options);
|
|
462
|
+
var sep = undefined;
|
|
463
|
+
var order = [];
|
|
464
|
+
var parts = dateTimeFormat.formatToParts(exampleDate);
|
|
465
|
+
|
|
466
|
+
var _iterator = _createForOfIteratorHelper(parts),
|
|
467
|
+
_step;
|
|
468
|
+
|
|
469
|
+
try {
|
|
470
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
471
|
+
var part = _step.value;
|
|
472
|
+
|
|
473
|
+
if (!sep && part.type === 'literal') {
|
|
474
|
+
sep = part.value;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
if (order.length < 3 && ['day', 'month', 'year'].includes(part.type) && allowedParts[part.type]) {
|
|
478
|
+
order.push(part.type);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
} catch (err) {
|
|
482
|
+
_iterator.e(err);
|
|
483
|
+
} finally {
|
|
484
|
+
_iterator.f();
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
sep = (_sep = sep) !== null && _sep !== void 0 ? _sep : ' ';
|
|
488
|
+
return {
|
|
489
|
+
sep: sep,
|
|
490
|
+
order: order
|
|
491
|
+
};
|
|
492
|
+
}, [locale, allowedParts]),
|
|
493
|
+
sep = _React$useMemo.sep,
|
|
494
|
+
order = _React$useMemo.order;
|
|
495
|
+
|
|
496
|
+
var outer = _react["default"].useMemo(function () {
|
|
497
|
+
var validDate = outerValue && outerValue instanceof Date && !Number.isNaN(outerValue.getTime());
|
|
498
|
+
if (!validDate) return null;
|
|
499
|
+
return {
|
|
500
|
+
year: outerValue.getFullYear().toString().padStart(4, '0'),
|
|
501
|
+
month: (outerValue.getMonth() + 1).toString().padStart(2, '0'),
|
|
502
|
+
day: outerValue.getDate().toString().padStart(2, '0')
|
|
503
|
+
};
|
|
504
|
+
}, [outerValue]);
|
|
505
|
+
|
|
506
|
+
var stringifyValue = _react["default"].useCallback(function (value) {
|
|
507
|
+
if (!value) return null;
|
|
508
|
+
if (!value.year && !value.month && !value.day) return null;
|
|
509
|
+
var result = [];
|
|
510
|
+
|
|
511
|
+
var _iterator2 = _createForOfIteratorHelper(order),
|
|
512
|
+
_step2;
|
|
513
|
+
|
|
514
|
+
try {
|
|
515
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
516
|
+
var part = _step2.value;
|
|
517
|
+
if (!allowedParts[part]) continue;
|
|
518
|
+
if (part === 'year' && value.year) result.push(value.year);
|
|
519
|
+
if (part === 'month' && value.month) result.push(value.month);
|
|
520
|
+
if (part === 'day' && value.day) result.push(value.day);
|
|
521
|
+
}
|
|
522
|
+
} catch (err) {
|
|
523
|
+
_iterator2.e(err);
|
|
524
|
+
} finally {
|
|
525
|
+
_iterator2.f();
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
return result.join(sep);
|
|
529
|
+
}, [order, allowedParts]);
|
|
530
|
+
|
|
531
|
+
var _React$useState = _react["default"].useState(outer),
|
|
532
|
+
_React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
|
|
533
|
+
internalValue = _React$useState2[0],
|
|
534
|
+
setInternalValue = _React$useState2[1];
|
|
535
|
+
|
|
536
|
+
var value = _react["default"].useMemo(function () {
|
|
537
|
+
return stringifyValue(internalValue);
|
|
538
|
+
}, [stringifyValue, internalValue]);
|
|
539
|
+
|
|
540
|
+
var lastKnownOuterValue = _react["default"].useRef(outer);
|
|
541
|
+
|
|
542
|
+
_react["default"].useEffect(function () {
|
|
543
|
+
var _lastKnownOuterValue$, _lastKnownOuterValue$2, _lastKnownOuterValue$3;
|
|
544
|
+
|
|
545
|
+
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)) {
|
|
546
|
+
setInternalValue(outer);
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
lastKnownOuterValue.current = outer;
|
|
550
|
+
}, [outer, setInternalValue]);
|
|
551
|
+
|
|
552
|
+
var pipeMask = _react["default"].useCallback(function (value) {
|
|
553
|
+
var placeholdersOnly = true;
|
|
554
|
+
|
|
555
|
+
for (var i = 0; i < value.length; i++) {
|
|
556
|
+
if (value[i] !== '_' && value[i] !== sep) {
|
|
557
|
+
placeholdersOnly = false;
|
|
558
|
+
break;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
if (placeholdersOnly) {
|
|
563
|
+
return '';
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
var getOffsetTo = function getOffsetTo(partName) {
|
|
567
|
+
var partsBefore = order.slice(0, order.indexOf(partName));
|
|
568
|
+
var offset = 0;
|
|
569
|
+
|
|
570
|
+
var _iterator3 = _createForOfIteratorHelper(partsBefore),
|
|
571
|
+
_step3;
|
|
572
|
+
|
|
573
|
+
try {
|
|
574
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
575
|
+
var part = _step3.value;
|
|
576
|
+
if (part === 'year' && allowedParts.year) offset += 4;
|
|
577
|
+
if (part === 'month' && allowedParts.month) offset += 2;
|
|
578
|
+
if (part === 'day' && allowedParts.day) offset += 2;
|
|
579
|
+
}
|
|
580
|
+
} catch (err) {
|
|
581
|
+
_iterator3.e(err);
|
|
582
|
+
} finally {
|
|
583
|
+
_iterator3.f();
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
offset += partsBefore.length * sep.length;
|
|
587
|
+
return offset;
|
|
588
|
+
};
|
|
589
|
+
|
|
590
|
+
var indexesOfPipedChars = [];
|
|
591
|
+
var parsed = {};
|
|
592
|
+
var parts = value.split(sep);
|
|
593
|
+
|
|
594
|
+
for (var partName in placeholders) {
|
|
595
|
+
parsed[partName] = placeholders[partName];
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
for (var _i = 0; _i < order.length; _i++) {
|
|
599
|
+
parsed[order[_i]] = parts[_i];
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
var year = parsed.year,
|
|
603
|
+
month = parsed.month,
|
|
604
|
+
day = parsed.day;
|
|
605
|
+
|
|
606
|
+
if (allowedParts.month) {
|
|
607
|
+
if (month[0] !== '_' && parseInt(month[0], 10) > 1) {
|
|
608
|
+
month = "0".concat(month[0]);
|
|
609
|
+
indexesOfPipedChars.push(getOffsetTo('month'));
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
if (month === '00') month = '01';
|
|
613
|
+
if (month[0] !== '_' && month[1] !== '_' && parseInt(month, 10) > 12) return false;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
if (allowedParts.day) {
|
|
617
|
+
if (day[0] !== '_' && parseInt(day[0], 10) > 3) {
|
|
618
|
+
day = "0".concat(day[0]);
|
|
619
|
+
indexesOfPipedChars.push(getOffsetTo('day'));
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
if (day === '00') day = '01';
|
|
623
|
+
if (day[0] !== '_' && day[1] !== '_' && parseInt(day, 10) > 31) return false;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
year = year.split('').map(function (_char) {
|
|
627
|
+
return _char === '_' ? placeholders.year : _char;
|
|
628
|
+
}).join('');
|
|
629
|
+
month = month.split('').map(function (_char2) {
|
|
630
|
+
return _char2 === '_' ? placeholders.month : _char2;
|
|
631
|
+
}).join('');
|
|
632
|
+
day = day.split('').map(function (_char3) {
|
|
633
|
+
return _char3 === '_' ? placeholders.day : _char3;
|
|
634
|
+
}).join('');
|
|
635
|
+
var yearFulfilled = !allowedParts.year || year && year.length >= 4 && !year.includes(placeholders.year);
|
|
636
|
+
var monthFulfilled = !allowedParts.month || month && month.length === 2 && !month.includes(placeholders.month);
|
|
637
|
+
var dayFulfilled = !allowedParts.day || day && day.length === 2 && !day.includes(placeholders.day);
|
|
638
|
+
var fulfilled = yearFulfilled && monthFulfilled && dayFulfilled;
|
|
639
|
+
|
|
640
|
+
if (fulfilled) {
|
|
641
|
+
var date = new Date();
|
|
642
|
+
date.setFullYear(allowedParts.year ? parseInt(year, 10) : 0);
|
|
643
|
+
date.setMonth(allowedParts.month ? parseInt(month, 10) - 1 : 0);
|
|
644
|
+
date.setDate(allowedParts.day ? parseInt(day, 10) : 1);
|
|
645
|
+
|
|
646
|
+
if (disabledDates && disabledDates.some((0, _includesDate["default"])((0, _dayjs["default"])(date), 'date'))) {
|
|
647
|
+
return false;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
if (allowedParts.day) {
|
|
651
|
+
if (date.getDate() !== parseInt(day, 10)) return false;
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
var result = [];
|
|
656
|
+
|
|
657
|
+
var _iterator4 = _createForOfIteratorHelper(order),
|
|
658
|
+
_step4;
|
|
659
|
+
|
|
660
|
+
try {
|
|
661
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
662
|
+
var part = _step4.value;
|
|
663
|
+
if (part === 'year') result.push(year);
|
|
664
|
+
if (part === 'month') result.push(month);
|
|
665
|
+
if (part === 'day') result.push(day);
|
|
666
|
+
}
|
|
667
|
+
} catch (err) {
|
|
668
|
+
_iterator4.e(err);
|
|
669
|
+
} finally {
|
|
670
|
+
_iterator4.f();
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
return {
|
|
674
|
+
value: result.join(sep),
|
|
675
|
+
indexesOfPipedChars: indexesOfPipedChars
|
|
676
|
+
};
|
|
677
|
+
}, [placeholders, sep, order, allowedParts, disabledDates]);
|
|
678
|
+
|
|
679
|
+
var handleChange = _react["default"].useCallback(function (value) {
|
|
680
|
+
var parsed = {};
|
|
681
|
+
|
|
682
|
+
for (var partName in placeholders) {
|
|
683
|
+
parsed[partName] = placeholders[partName];
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
var parts = value.split(sep);
|
|
687
|
+
|
|
688
|
+
for (var i = 0; i < order.length; i++) {
|
|
689
|
+
parsed[order[i]] = parts[i];
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
var year = parsed.year,
|
|
693
|
+
month = parsed.month,
|
|
694
|
+
day = parsed.day;
|
|
695
|
+
setInternalValue({
|
|
696
|
+
year: year,
|
|
697
|
+
month: month,
|
|
698
|
+
day: day
|
|
699
|
+
});
|
|
700
|
+
var yearFulfilled = !allowedParts.year || year && year.length >= 4 && !year.includes(placeholders.year);
|
|
701
|
+
var monthFulfilled = !allowedParts.month || month && month.length === 2 && !month.includes(placeholders.month);
|
|
702
|
+
var dayFulfilled = !allowedParts.day || day && day.length === 2 && !day.includes(placeholders.day);
|
|
703
|
+
var fulfilled = yearFulfilled && monthFulfilled && dayFulfilled;
|
|
704
|
+
|
|
705
|
+
if (fulfilled) {
|
|
706
|
+
var date = new Date();
|
|
707
|
+
date.setFullYear(allowedParts.year ? parseInt(year, 10) : 0);
|
|
708
|
+
date.setMonth(allowedParts.month ? parseInt(month, 10) - 1 : 0);
|
|
709
|
+
date.setDate(allowedParts.day ? parseInt(day, 10) : 1);
|
|
710
|
+
onDateChange(date);
|
|
711
|
+
lastKnownOuterValue.current = {
|
|
712
|
+
year: year,
|
|
713
|
+
month: month,
|
|
714
|
+
day: day
|
|
715
|
+
};
|
|
716
|
+
return;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
if (lastKnownOuterValue.current !== null) {
|
|
720
|
+
onDateChange(null);
|
|
721
|
+
lastKnownOuterValue.current = null;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
if (yearFulfilled && allowedParts.year) {
|
|
725
|
+
var _date = new Date();
|
|
726
|
+
|
|
727
|
+
_date.setFullYear(parseInt(year, 10));
|
|
728
|
+
|
|
729
|
+
if (monthFulfilled && allowedParts.month) {
|
|
730
|
+
_date.setMonth(parseInt(month, 10) - 1);
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
onDisplayedPeriodChange(_date);
|
|
734
|
+
}
|
|
735
|
+
}, [onDateChange, setInternalValue, placeholders, onDisplayedPeriodChange, order, allowedParts]);
|
|
736
|
+
|
|
737
|
+
var mask = _react["default"].useMemo(function () {
|
|
738
|
+
var result = [];
|
|
739
|
+
|
|
740
|
+
var _iterator5 = _createForOfIteratorHelper(order),
|
|
741
|
+
_step5;
|
|
742
|
+
|
|
743
|
+
try {
|
|
744
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
745
|
+
var part = _step5.value;
|
|
746
|
+
if (part === 'year') result.push(placeholders.year + placeholders.year + placeholders.year + placeholders.year);
|
|
747
|
+
if (part === 'month') result.push(placeholders.month + placeholders.month);
|
|
748
|
+
if (part === 'day') result.push(placeholders.day + placeholders.day);
|
|
749
|
+
}
|
|
750
|
+
} catch (err) {
|
|
751
|
+
_iterator5.e(err);
|
|
752
|
+
} finally {
|
|
753
|
+
_iterator5.f();
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
return result.join(sep);
|
|
757
|
+
}, [sep, order, placeholders]);
|
|
758
|
+
|
|
759
|
+
var aliases = _react["default"].useMemo(function () {
|
|
760
|
+
var _ref17;
|
|
761
|
+
|
|
762
|
+
return _ref17 = {}, (0, _defineProperty2["default"])(_ref17, placeholders.year, /\d/), (0, _defineProperty2["default"])(_ref17, placeholders.month, /\d/), (0, _defineProperty2["default"])(_ref17, placeholders.day, /\d/), _ref17;
|
|
763
|
+
}, [placeholders]);
|
|
764
|
+
|
|
765
|
+
var maskOnlySymbols = _react["default"].useMemo(function () {
|
|
766
|
+
var _ref18;
|
|
767
|
+
|
|
768
|
+
return _ref18 = {}, (0, _defineProperty2["default"])(_ref18, placeholders.year, true), (0, _defineProperty2["default"])(_ref18, placeholders.month, true), (0, _defineProperty2["default"])(_ref18, placeholders.day, true), (0, _defineProperty2["default"])(_ref18, sep, true), _ref18;
|
|
769
|
+
}, [sep, placeholders]);
|
|
770
|
+
|
|
771
|
+
var humanizedDate = _react["default"].useMemo(function () {
|
|
772
|
+
var validDate = outerValue && outerValue instanceof Date && !Number.isNaN(outerValue.getTime());
|
|
773
|
+
if (!validDate) return null;
|
|
774
|
+
return new Intl.DateTimeFormat(locale, {
|
|
775
|
+
year: allowedParts.year ? 'numeric' : undefined,
|
|
776
|
+
month: allowedParts.month ? 'short' : undefined,
|
|
777
|
+
day: allowedParts.day ? '2-digit' : undefined
|
|
778
|
+
}).format(outerValue);
|
|
779
|
+
}, [outerValue, locale, allowedParts]);
|
|
780
|
+
|
|
781
|
+
var SHumanizedDate = 'div';
|
|
782
|
+
|
|
783
|
+
var handleInputRef = _react["default"].useCallback(function (node) {
|
|
784
|
+
if (!node || node.tagName !== 'INPUT') return;
|
|
785
|
+
if (typeof forwardRef === 'function') forwardRef(node);else forwardRef.current = node;
|
|
786
|
+
}, [forwardRef]);
|
|
787
|
+
|
|
788
|
+
return _ref15 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(_inputMask["default"].Value, (0, _extends2["default"])({
|
|
789
|
+
title: "".concat(labelPrefix, " ").concat(mask),
|
|
790
|
+
mask: mask,
|
|
791
|
+
aliases: aliases,
|
|
792
|
+
maskOnlySymbols: maskOnlySymbols,
|
|
793
|
+
placeholder: mask
|
|
794
|
+
}, otherProps, {
|
|
795
|
+
ref: handleInputRef,
|
|
796
|
+
pipe: pipeMask,
|
|
797
|
+
value: value,
|
|
798
|
+
onChange: handleChange,
|
|
799
|
+
noHumanizedDate: !humanizedDate
|
|
800
|
+
}), humanizedDate && /*#__PURE__*/_react["default"].createElement(SHumanizedDate, _ref15.cn("SHumanizedDate", {}), humanizedDate));
|
|
801
|
+
};
|
|
802
|
+
|
|
803
|
+
var SingleDateInput = (0, _core["default"])(SingleDateInputRoot, {
|
|
804
|
+
Indicator: Indicator,
|
|
805
|
+
MaskedInput: MaskedInput
|
|
806
|
+
});
|
|
807
|
+
var DateRange = (0, _core["default"])(DateRangeRoot, {
|
|
808
|
+
Indicator: Indicator,
|
|
809
|
+
RangeSep: RangeSep,
|
|
810
|
+
FromMaskedInput: FromMaskedInput,
|
|
811
|
+
ToMaskedInput: ToMaskedInput
|
|
812
|
+
});
|
|
813
|
+
var InputTrigger = (0, _core["default"])(InputTriggerRoot, {
|
|
814
|
+
Addon: _baseTrigger["default"].Addon,
|
|
815
|
+
SingleDateInput: SingleDateInput,
|
|
816
|
+
DateRange: DateRange
|
|
817
|
+
});
|
|
818
|
+
var _default = InputTrigger;
|
|
819
|
+
exports["default"] = _default;
|
|
820
|
+
//# sourceMappingURL=InputTrigger.js.map
|