@commercetools-uikit/date-time-input 15.15.0 → 16.0.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/dist/commercetools-uikit-date-time-input.cjs.d.ts +1 -0
- package/dist/commercetools-uikit-date-time-input.cjs.d.ts.map +1 -0
- package/dist/commercetools-uikit-date-time-input.cjs.dev.js +130 -158
- package/dist/commercetools-uikit-date-time-input.cjs.prod.js +130 -158
- package/dist/commercetools-uikit-date-time-input.esm.js +130 -158
- package/package.json +16 -16
|
@@ -51,22 +51,18 @@ var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstancePro
|
|
|
51
51
|
var Downshift__default = /*#__PURE__*/_interopDefault(Downshift);
|
|
52
52
|
var Constraints__default = /*#__PURE__*/_interopDefault(Constraints);
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
placeholder: props.placeholder,
|
|
67
|
-
css: getInputStyles()
|
|
68
|
-
});
|
|
69
|
-
};
|
|
54
|
+
const getInputStyles = () => /*#__PURE__*/react.css("width:100%;text-align:center;border:0;border-top:1px solid ", designSystem.designTokens.colorNeutral90, ";padding:10px 0;outline:0;font-size:", designSystem.designTokens.fontSizeDefault, ";margin-top:", designSystem.designTokens.spacing20, ";color:", designSystem.designTokens.colorSolid, ";:disabled{background-color:", designSystem.designTokens.colorSurface, ";}" + ("" ), "" );
|
|
55
|
+
|
|
56
|
+
const DateCalendarTimeInput = props => jsxRuntime.jsx("input", {
|
|
57
|
+
disabled: props.isDisabled,
|
|
58
|
+
ref: props.timeInputRef,
|
|
59
|
+
type: "text",
|
|
60
|
+
value: props.value,
|
|
61
|
+
onChange: props.onChange,
|
|
62
|
+
onKeyDown: props.onKeyDown,
|
|
63
|
+
placeholder: props.placeholder,
|
|
64
|
+
css: getInputStyles()
|
|
65
|
+
});
|
|
70
66
|
|
|
71
67
|
DateCalendarTimeInput.propTypes = {};
|
|
72
68
|
DateCalendarTimeInput.displayName = 'DateCalendarTimeInput';
|
|
@@ -74,37 +70,33 @@ var TimeInput = DateCalendarTimeInput;
|
|
|
74
70
|
|
|
75
71
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
76
72
|
|
|
77
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var
|
|
73
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
78
74
|
|
|
79
75
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
80
76
|
|
|
81
77
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct__default["default"]) return false; if (_Reflect$construct__default["default"].sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
82
|
-
|
|
78
|
+
const activationTypes = [Downshift__default["default"].stateChangeTypes.keyDownEnter, Downshift__default["default"].stateChangeTypes.clickItem];
|
|
83
79
|
|
|
84
|
-
|
|
80
|
+
const preventDownshiftDefault = event => {
|
|
85
81
|
event.nativeEvent.preventDownshiftDefault = true;
|
|
86
82
|
}; // This keeps the menu open when the user focuses the time input (thereby
|
|
87
83
|
// blurring the regular input/toggle button)
|
|
88
84
|
|
|
89
85
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
event.persist();
|
|
86
|
+
const createBlurHandler = timeInputRef => event => {
|
|
87
|
+
event.persist();
|
|
93
88
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
};
|
|
89
|
+
if (event.relatedTarget === timeInputRef.current) {
|
|
90
|
+
preventDownshiftDefault(event);
|
|
91
|
+
}
|
|
98
92
|
};
|
|
99
93
|
|
|
100
|
-
|
|
94
|
+
let DateTimeInput = /*#__PURE__*/function (_Component) {
|
|
101
95
|
_inherits(DateTimeInput, _Component);
|
|
102
96
|
|
|
103
97
|
var _super = _createSuper(DateTimeInput);
|
|
104
98
|
|
|
105
99
|
function DateTimeInput() {
|
|
106
|
-
var _context;
|
|
107
|
-
|
|
108
100
|
var _this;
|
|
109
101
|
|
|
110
102
|
_classCallCheck(this, DateTimeInput);
|
|
@@ -113,7 +105,7 @@ var DateTimeInput = /*#__PURE__*/function (_Component) {
|
|
|
113
105
|
args[_key] = arguments[_key];
|
|
114
106
|
}
|
|
115
107
|
|
|
116
|
-
_this = _super.call
|
|
108
|
+
_this = _super.call(this, ...args);
|
|
117
109
|
_this.inputRef = /*#__PURE__*/react$1.createRef();
|
|
118
110
|
_this.timeInputRef = /*#__PURE__*/react$1.createRef();
|
|
119
111
|
_this.state = {
|
|
@@ -124,10 +116,10 @@ var DateTimeInput = /*#__PURE__*/function (_Component) {
|
|
|
124
116
|
};
|
|
125
117
|
|
|
126
118
|
_this.jumpMonths = function (amount) {
|
|
127
|
-
|
|
119
|
+
let dayToHighlight = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
128
120
|
|
|
129
|
-
_this.setState(
|
|
130
|
-
|
|
121
|
+
_this.setState(prevState => {
|
|
122
|
+
const nextDate = calendarTimeUtils.changeMonth(prevState.calendarDate, _this.props.timeZone, amount);
|
|
131
123
|
return {
|
|
132
124
|
calendarDate: nextDate,
|
|
133
125
|
highlightedIndex: dayToHighlight
|
|
@@ -135,22 +127,20 @@ var DateTimeInput = /*#__PURE__*/function (_Component) {
|
|
|
135
127
|
});
|
|
136
128
|
};
|
|
137
129
|
|
|
138
|
-
_this.showToday =
|
|
139
|
-
|
|
130
|
+
_this.showToday = () => {
|
|
131
|
+
const today = calendarTimeUtils.getToday(_this.props.timeZone);
|
|
140
132
|
|
|
141
|
-
_this.setState(
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
};
|
|
146
|
-
}, function () {
|
|
133
|
+
_this.setState(prevState => ({
|
|
134
|
+
calendarDate: today,
|
|
135
|
+
highlightedIndex: (prevState.suggestedItems || []).length + calendarTimeUtils.getDateInMonth(today, _this.props.timeZone) - 1
|
|
136
|
+
}), () => {
|
|
147
137
|
var _this$inputRef$curren;
|
|
148
138
|
|
|
149
139
|
return (_this$inputRef$curren = _this.inputRef.current) === null || _this$inputRef$curren === void 0 ? void 0 : _this$inputRef$curren.focus();
|
|
150
140
|
});
|
|
151
141
|
};
|
|
152
142
|
|
|
153
|
-
_this.handleBlur =
|
|
143
|
+
_this.handleBlur = () => {
|
|
154
144
|
if (_this.props.onBlur) _this.props.onBlur({
|
|
155
145
|
target: {
|
|
156
146
|
id: _this.props.id,
|
|
@@ -159,8 +149,8 @@ var DateTimeInput = /*#__PURE__*/function (_Component) {
|
|
|
159
149
|
});
|
|
160
150
|
};
|
|
161
151
|
|
|
162
|
-
_this.handleTimeChange =
|
|
163
|
-
|
|
152
|
+
_this.handleTimeChange = event => {
|
|
153
|
+
const parsedTime = utils.parseTime(event.target.value);
|
|
164
154
|
|
|
165
155
|
_this.setState({
|
|
166
156
|
timeString: event.target.value
|
|
@@ -168,7 +158,7 @@ var DateTimeInput = /*#__PURE__*/function (_Component) {
|
|
|
168
158
|
|
|
169
159
|
|
|
170
160
|
if (_this.props.value === '') return;
|
|
171
|
-
|
|
161
|
+
let date = calendarTimeUtils.getStartOf(_this.props.value, _this.props.timeZone);
|
|
172
162
|
|
|
173
163
|
if (parsedTime) {
|
|
174
164
|
date = calendarTimeUtils.changeTime(date, _this.props.timeZone, parsedTime);
|
|
@@ -177,7 +167,7 @@ var DateTimeInput = /*#__PURE__*/function (_Component) {
|
|
|
177
167
|
_this.emit(date);
|
|
178
168
|
};
|
|
179
169
|
|
|
180
|
-
_this.emit =
|
|
170
|
+
_this.emit = value => {
|
|
181
171
|
var _this$props$onChange, _this$props;
|
|
182
172
|
|
|
183
173
|
return (_this$props$onChange = (_this$props = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, {
|
|
@@ -197,8 +187,7 @@ var DateTimeInput = /*#__PURE__*/function (_Component) {
|
|
|
197
187
|
_createClass(DateTimeInput, [{
|
|
198
188
|
key: "render",
|
|
199
189
|
value: function render() {
|
|
200
|
-
var
|
|
201
|
-
_this2 = this;
|
|
190
|
+
var _context;
|
|
202
191
|
|
|
203
192
|
if (!this.props.isReadOnly) ;
|
|
204
193
|
|
|
@@ -215,7 +204,7 @@ var DateTimeInput = /*#__PURE__*/function (_Component) {
|
|
|
215
204
|
selectedItem: this.props.value === '' ? null : this.props.value,
|
|
216
205
|
highlightedIndex: this.state.highlightedIndex,
|
|
217
206
|
onChange: this.emit,
|
|
218
|
-
stateReducer:
|
|
207
|
+
stateReducer: (_, changes) => {
|
|
219
208
|
if (_includesInstanceProperty__default["default"](activationTypes).call(activationTypes, changes.type)) {
|
|
220
209
|
return _objectSpread(_objectSpread({}, changes), {}, {
|
|
221
210
|
isOpen: true
|
|
@@ -224,20 +213,20 @@ var DateTimeInput = /*#__PURE__*/function (_Component) {
|
|
|
224
213
|
|
|
225
214
|
return changes;
|
|
226
215
|
},
|
|
227
|
-
onStateChange:
|
|
228
|
-
|
|
216
|
+
onStateChange: changes => {
|
|
217
|
+
this.setState(prevState => {
|
|
229
218
|
if (_includesInstanceProperty__default["default"](activationTypes).call(activationTypes, changes.type)) {
|
|
230
219
|
return {
|
|
231
220
|
startDate: changes.isOpen ? prevState.startDate : null,
|
|
232
221
|
inputValue: changes.inputValue || prevState.inputValue,
|
|
233
|
-
timeString: changes.selectedItem ? calendarTimeUtils.formatTime(changes.selectedItem,
|
|
222
|
+
timeString: changes.selectedItem ? calendarTimeUtils.formatTime(changes.selectedItem, this.props.intl.locale, this.props.timeZone) : prevState.timeString
|
|
234
223
|
};
|
|
235
224
|
}
|
|
236
225
|
|
|
237
226
|
if (changes.hasOwnProperty('inputValue')) {
|
|
238
|
-
|
|
227
|
+
const suggestedItems = calendarTimeUtils.createSuggestedItems(changes.inputValue, this.props.timeZone);
|
|
239
228
|
return {
|
|
240
|
-
suggestedItems
|
|
229
|
+
suggestedItems,
|
|
241
230
|
highlightedIndex: suggestedItems.length > 0 ? 0 : null
|
|
242
231
|
};
|
|
243
232
|
}
|
|
@@ -247,10 +236,10 @@ var DateTimeInput = /*#__PURE__*/function (_Component) {
|
|
|
247
236
|
inputValue: changes.inputValue || prevState.inputValue,
|
|
248
237
|
startDate: changes.isOpen ? prevState.startDate : null,
|
|
249
238
|
// set time input value to time from value when menu is opened
|
|
250
|
-
timeString: changes.isOpen &&
|
|
239
|
+
timeString: changes.isOpen && this.props.value !== '' ? calendarTimeUtils.formatTime(this.props.value, this.props.intl.locale, this.props.timeZone) : '',
|
|
251
240
|
// ensure calendar always opens on selected item, or on
|
|
252
241
|
// current month when there is no selected item
|
|
253
|
-
calendarDate:
|
|
242
|
+
calendarDate: this.props.value === '' ? calendarTimeUtils.getToday(this.props.timeZone) : this.props.value
|
|
254
243
|
};
|
|
255
244
|
}
|
|
256
245
|
|
|
@@ -261,19 +250,19 @@ var DateTimeInput = /*#__PURE__*/function (_Component) {
|
|
|
261
250
|
}
|
|
262
251
|
|
|
263
252
|
return null;
|
|
264
|
-
},
|
|
253
|
+
}, () => {
|
|
265
254
|
if (_includesInstanceProperty__default["default"](activationTypes).call(activationTypes, changes.type)) {
|
|
266
|
-
var
|
|
255
|
+
var _this$timeInputRef$cu, _this$timeInputRef$cu2;
|
|
267
256
|
|
|
268
|
-
(
|
|
269
|
-
(
|
|
257
|
+
(_this$timeInputRef$cu = this.timeInputRef.current) === null || _this$timeInputRef$cu === void 0 ? void 0 : _this$timeInputRef$cu.focus();
|
|
258
|
+
(_this$timeInputRef$cu2 = this.timeInputRef.current) === null || _this$timeInputRef$cu2 === void 0 ? void 0 : _this$timeInputRef$cu2.setSelectionRange(0, this.state.timeString.length);
|
|
270
259
|
}
|
|
271
260
|
});
|
|
272
261
|
},
|
|
273
|
-
children:
|
|
274
|
-
var
|
|
262
|
+
children: _ref => {
|
|
263
|
+
var _context2;
|
|
275
264
|
|
|
276
|
-
|
|
265
|
+
let getInputProps = _ref.getInputProps,
|
|
277
266
|
getMenuProps = _ref.getMenuProps,
|
|
278
267
|
getItemProps = _ref.getItemProps,
|
|
279
268
|
getToggleButtonProps = _ref.getToggleButtonProps,
|
|
@@ -285,36 +274,36 @@ var DateTimeInput = /*#__PURE__*/function (_Component) {
|
|
|
285
274
|
selectedItem = _ref.selectedItem,
|
|
286
275
|
inputValue = _ref.inputValue,
|
|
287
276
|
isOpen = _ref.isOpen;
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
277
|
+
const suggestedItems = this.state.suggestedItems;
|
|
278
|
+
const calendarItems = calendarTimeUtils.createCalendarItems(this.state.calendarDate, this.state.timeString, this.props.timeZone);
|
|
279
|
+
const paddingDayCount = calendarTimeUtils.getPaddingDayCount(this.state.calendarDate, this.props.intl.locale, this.props.timeZone);
|
|
291
280
|
|
|
292
|
-
|
|
281
|
+
const paddingDays = _fillInstanceProperty__default["default"](_context2 = Array(paddingDayCount)).call(_context2, undefined);
|
|
293
282
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
283
|
+
const weekdays = calendarTimeUtils.getWeekdayNames(this.props.intl.locale);
|
|
284
|
+
const today = calendarTimeUtils.getToday(this.props.timeZone);
|
|
285
|
+
const isTimeInputVisible = Boolean(this.props.value) && this.props.value !== '';
|
|
297
286
|
return jsxRuntime.jsxs("div", {
|
|
298
|
-
onFocus:
|
|
299
|
-
onBlur:
|
|
287
|
+
onFocus: this.props.onFocus,
|
|
288
|
+
onBlur: this.handleBlur,
|
|
300
289
|
children: [jsxRuntime.jsx(calendarUtils.CalendarBody, {
|
|
301
|
-
inputRef:
|
|
290
|
+
inputRef: this.inputRef,
|
|
302
291
|
inputProps: getInputProps(_objectSpread({
|
|
303
292
|
/* ARIA */
|
|
304
|
-
'aria-invalid':
|
|
305
|
-
'aria-errormessage':
|
|
293
|
+
'aria-invalid': this.props['aria-invalid'],
|
|
294
|
+
'aria-errormessage': this.props['aria-errormessage'],
|
|
306
295
|
// Unset the aria-labelledby as it interfers with the link
|
|
307
296
|
// between the <label for> and the <input id>.
|
|
308
297
|
'aria-labelledby': undefined,
|
|
309
|
-
name:
|
|
310
|
-
placeholder: typeof
|
|
311
|
-
onMouseEnter:
|
|
298
|
+
name: this.props.name,
|
|
299
|
+
placeholder: typeof this.props.placeholder === 'string' ? this.props.placeholder : calendarTimeUtils.getLocalizedDateTimeFormatPattern(this.props.intl.locale, 'full'),
|
|
300
|
+
onMouseEnter: () => {
|
|
312
301
|
// we remove the highlight so that the user can use the
|
|
313
302
|
// arrow keys to move the cursor when hovering
|
|
314
303
|
if (isOpen) setHighlightedIndex(-1);
|
|
315
304
|
},
|
|
316
|
-
onKeyDown:
|
|
317
|
-
if (
|
|
305
|
+
onKeyDown: event => {
|
|
306
|
+
if (this.props.isReadOnly) {
|
|
318
307
|
preventDownshiftDefault(event);
|
|
319
308
|
return;
|
|
320
309
|
} // parse input when user presses enter on regular input,
|
|
@@ -323,10 +312,8 @@ var DateTimeInput = /*#__PURE__*/function (_Component) {
|
|
|
323
312
|
|
|
324
313
|
if (event.key === 'Enter' && highlightedIndex === null) {
|
|
325
314
|
preventDownshiftDefault(event);
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
_this2.emit(parsedDate);
|
|
329
|
-
|
|
315
|
+
const parsedDate = calendarTimeUtils.parseInputText(inputValue, this.props.intl.locale, this.props.timeZone);
|
|
316
|
+
this.emit(parsedDate);
|
|
330
317
|
closeMenu();
|
|
331
318
|
} // ArrowDown
|
|
332
319
|
|
|
@@ -337,128 +324,113 @@ var DateTimeInput = /*#__PURE__*/function (_Component) {
|
|
|
337
324
|
// then bypass normal arrow navigation
|
|
338
325
|
preventDownshiftDefault(event); // then jump to start of next month
|
|
339
326
|
|
|
340
|
-
|
|
327
|
+
this.jumpMonths(1, 0);
|
|
341
328
|
}
|
|
342
329
|
} // ArrowUp
|
|
343
330
|
|
|
344
331
|
|
|
345
332
|
if (event.key === 'ArrowUp') {
|
|
346
|
-
|
|
333
|
+
const previousDay = calendarTimeUtils.getPreviousDay(calendarItems[Number(highlightedIndex)]);
|
|
347
334
|
|
|
348
335
|
if (Number(highlightedIndex) <= 0) {
|
|
349
336
|
// if it's the start of the month
|
|
350
337
|
// then bypass normal arrow navigation
|
|
351
338
|
preventDownshiftDefault(event);
|
|
352
|
-
|
|
339
|
+
const numberOfDaysOfPrevMonth = calendarTimeUtils.getDaysInMonth(previousDay, this.props.timeZone); // then jump to the last day of the previous month
|
|
353
340
|
|
|
354
|
-
|
|
341
|
+
this.jumpMonths(-1, numberOfDaysOfPrevMonth - 1);
|
|
355
342
|
}
|
|
356
343
|
}
|
|
357
344
|
},
|
|
358
|
-
onClick:
|
|
359
|
-
onBlur: createBlurHandler(
|
|
360
|
-
onChange:
|
|
345
|
+
onClick: this.props.isReadOnly ? undefined : openMenu,
|
|
346
|
+
onBlur: createBlurHandler(this.timeInputRef),
|
|
347
|
+
onChange: event => {
|
|
361
348
|
var _event$target$value;
|
|
362
349
|
|
|
363
350
|
// keep timeInput and regular input in sync when user
|
|
364
351
|
// types into regular input
|
|
365
352
|
if (!isOpen) return;
|
|
366
|
-
|
|
353
|
+
const time = (_event$target$value = event.target.value) === null || _event$target$value === void 0 ? void 0 : _event$target$value.split(' ')[1];
|
|
367
354
|
if (!time) return;
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
_this2.setState(function () {
|
|
355
|
+
const parsedTime = utils.parseTime(time);
|
|
356
|
+
this.setState(() => {
|
|
371
357
|
if (!parsedTime) return {
|
|
372
358
|
timeString: ''
|
|
373
359
|
};
|
|
374
|
-
|
|
360
|
+
let date = calendarTimeUtils.getToday(this.props.timeZone);
|
|
375
361
|
|
|
376
362
|
if (parsedTime) {
|
|
377
|
-
date = calendarTimeUtils.changeTime(date,
|
|
363
|
+
date = calendarTimeUtils.changeTime(date, this.props.timeZone, parsedTime);
|
|
378
364
|
}
|
|
379
365
|
|
|
380
366
|
return {
|
|
381
|
-
timeString: calendarTimeUtils.formatTime(date,
|
|
367
|
+
timeString: calendarTimeUtils.formatTime(date, this.props.intl.locale, this.props.timeZone)
|
|
382
368
|
};
|
|
383
369
|
});
|
|
384
370
|
}
|
|
385
|
-
}, utils.filterDataAttributes(
|
|
371
|
+
}, utils.filterDataAttributes(this.props))),
|
|
386
372
|
hasSelection: Boolean(selectedItem),
|
|
387
373
|
onClear: clearSelection,
|
|
388
374
|
isOpen: isOpen,
|
|
389
|
-
isDisabled:
|
|
390
|
-
isReadOnly:
|
|
375
|
+
isDisabled: this.props.isDisabled,
|
|
376
|
+
isReadOnly: this.props.isReadOnly,
|
|
391
377
|
toggleButtonProps: getToggleButtonProps({
|
|
392
|
-
onBlur: createBlurHandler(
|
|
378
|
+
onBlur: createBlurHandler(this.timeInputRef)
|
|
393
379
|
}),
|
|
394
|
-
hasError:
|
|
395
|
-
hasWarning:
|
|
396
|
-
}), isOpen && !
|
|
380
|
+
hasError: this.props.hasError,
|
|
381
|
+
hasWarning: this.props.hasWarning
|
|
382
|
+
}), isOpen && !this.props.isDisabled && jsxRuntime.jsxs(calendarUtils.CalendarMenu, _objectSpread(_objectSpread({}, getMenuProps()), {}, {
|
|
397
383
|
hasFooter: true,
|
|
398
|
-
hasError:
|
|
399
|
-
hasWarning:
|
|
384
|
+
hasError: this.props.hasError,
|
|
385
|
+
hasWarning: this.props.hasWarning,
|
|
400
386
|
children: [jsxRuntime.jsx(calendarUtils.CalendarHeader, {
|
|
401
|
-
monthLabel: calendarTimeUtils.getMonthCalendarLabel(
|
|
402
|
-
yearLabel: calendarTimeUtils.getYearCalendarLabel(
|
|
403
|
-
onPrevMonthClick:
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
return _this2.jumpMonths(1);
|
|
409
|
-
},
|
|
410
|
-
onPrevYearClick: function onPrevYearClick() {
|
|
411
|
-
return _this2.jumpMonths(-12);
|
|
412
|
-
},
|
|
413
|
-
onNextYearClick: function onNextYearClick() {
|
|
414
|
-
return _this2.jumpMonths(12);
|
|
415
|
-
}
|
|
387
|
+
monthLabel: calendarTimeUtils.getMonthCalendarLabel(this.state.calendarDate, this.props.intl.locale),
|
|
388
|
+
yearLabel: calendarTimeUtils.getYearCalendarLabel(this.state.calendarDate, this.props.intl.locale),
|
|
389
|
+
onPrevMonthClick: () => this.jumpMonths(-1),
|
|
390
|
+
onTodayClick: this.showToday,
|
|
391
|
+
onNextMonthClick: () => this.jumpMonths(1),
|
|
392
|
+
onPrevYearClick: () => this.jumpMonths(-12),
|
|
393
|
+
onNextYearClick: () => this.jumpMonths(12)
|
|
416
394
|
}), jsxRuntime.jsxs(calendarUtils.CalendarContent, {
|
|
417
|
-
children: [_mapInstanceProperty__default["default"](weekdays).call(weekdays,
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
}), _mapInstanceProperty__default["default"](
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
})), {}, {
|
|
436
|
-
isHighlighted: suggestedItems.length + index === highlightedIndex,
|
|
437
|
-
isSelected: calendarTimeUtils.isSameDay(item, _this2.props.value),
|
|
438
|
-
children: calendarTimeUtils.getCalendarDayLabel(item, _this2.props.timeZone)
|
|
439
|
-
}), item);
|
|
440
|
-
})]
|
|
395
|
+
children: [_mapInstanceProperty__default["default"](weekdays).call(weekdays, weekday => jsxRuntime.jsx(calendarUtils.CalendarDay, {
|
|
396
|
+
type: "heading",
|
|
397
|
+
children: weekday
|
|
398
|
+
}, weekday)), _mapInstanceProperty__default["default"](paddingDays).call(paddingDays, (_, index) => jsxRuntime.jsx(calendarUtils.CalendarDay, {
|
|
399
|
+
type: "spacing"
|
|
400
|
+
}, index)), _mapInstanceProperty__default["default"](calendarItems).call(calendarItems, (item, index) => jsxRuntime.jsx(calendarUtils.CalendarDay, _objectSpread(_objectSpread({
|
|
401
|
+
isToday: calendarTimeUtils.isSameDay(today, item)
|
|
402
|
+
}, getItemProps({
|
|
403
|
+
disabled: this.props.isDisabled,
|
|
404
|
+
item,
|
|
405
|
+
onMouseOut: () => {
|
|
406
|
+
setHighlightedIndex(-1);
|
|
407
|
+
}
|
|
408
|
+
})), {}, {
|
|
409
|
+
isHighlighted: suggestedItems.length + index === highlightedIndex,
|
|
410
|
+
isSelected: calendarTimeUtils.isSameDay(item, this.props.value),
|
|
411
|
+
children: calendarTimeUtils.getCalendarDayLabel(item, this.props.timeZone)
|
|
412
|
+
}), item))]
|
|
441
413
|
}), jsxRuntime.jsx(TimeInput, {
|
|
442
414
|
isDisabled: !isTimeInputVisible,
|
|
443
|
-
timeInputRef:
|
|
444
|
-
placeholder: calendarTimeUtils.getLocalizedDateTimeFormatPattern(
|
|
445
|
-
value:
|
|
446
|
-
onChange:
|
|
447
|
-
onKeyDown:
|
|
415
|
+
timeInputRef: this.timeInputRef,
|
|
416
|
+
placeholder: calendarTimeUtils.getLocalizedDateTimeFormatPattern(this.props.intl.locale, 'time'),
|
|
417
|
+
value: this.state.timeString,
|
|
418
|
+
onChange: this.handleTimeChange,
|
|
419
|
+
onKeyDown: event => {
|
|
448
420
|
if (event.key === 'ArrowUp') {
|
|
449
|
-
var
|
|
421
|
+
var _this$inputRef$curren2;
|
|
450
422
|
|
|
451
423
|
setHighlightedIndex(-1);
|
|
452
|
-
(
|
|
424
|
+
(_this$inputRef$curren2 = this.inputRef.current) === null || _this$inputRef$curren2 === void 0 ? void 0 : _this$inputRef$curren2.focus();
|
|
453
425
|
return;
|
|
454
426
|
}
|
|
455
427
|
|
|
456
428
|
if (event.key === 'Enter') {
|
|
457
|
-
var
|
|
429
|
+
var _this$inputRef$curren3, _this$inputRef$curren4;
|
|
458
430
|
|
|
459
431
|
setHighlightedIndex(-1);
|
|
460
|
-
(
|
|
461
|
-
(
|
|
432
|
+
(_this$inputRef$curren3 = this.inputRef.current) === null || _this$inputRef$curren3 === void 0 ? void 0 : _this$inputRef$curren3.focus();
|
|
433
|
+
(_this$inputRef$curren4 = this.inputRef.current) === null || _this$inputRef$curren4 === void 0 ? void 0 : _this$inputRef$curren4.setSelectionRange(0, 100);
|
|
462
434
|
closeMenu();
|
|
463
435
|
}
|
|
464
436
|
}
|
|
@@ -466,7 +438,7 @@ var DateTimeInput = /*#__PURE__*/function (_Component) {
|
|
|
466
438
|
}))]
|
|
467
439
|
});
|
|
468
440
|
}
|
|
469
|
-
}, _concatInstanceProperty__default["default"](
|
|
441
|
+
}, _concatInstanceProperty__default["default"](_context = "".concat(this.props.timeZone, ":")).call(_context, this.props.intl.locale))
|
|
470
442
|
});
|
|
471
443
|
}
|
|
472
444
|
}]);
|
|
@@ -479,7 +451,7 @@ DateTimeInput.propTypes = {};
|
|
|
479
451
|
var dateTimeInput = reactIntl.injectIntl(DateTimeInput);
|
|
480
452
|
|
|
481
453
|
// NOTE: This string will be replaced on build time with the package version.
|
|
482
|
-
var version = "
|
|
454
|
+
var version = "16.0.0";
|
|
483
455
|
|
|
484
456
|
exports["default"] = dateTimeInput;
|
|
485
457
|
exports.version = version;
|