@commercetools-uikit/date-time-input 20.5.0 → 20.6.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/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <!-- THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -->
2
- <!-- This file is created by the `yarn generate-readme` script. -->
2
+ <!-- This file is created by the `pnpm generate-readme` script. -->
3
3
 
4
4
  # DateTimeInput
5
5
 
@@ -12,7 +12,7 @@ It formats the selected date depending on the current locale.
12
12
  ## Installation
13
13
 
14
14
  ```
15
- yarn add @commercetools-uikit/date-time-input
15
+ pnpm add @commercetools-uikit/date-time-input
16
16
  ```
17
17
 
18
18
  ```
@@ -22,7 +22,7 @@ npm --save install @commercetools-uikit/date-time-input
22
22
  Additionally install the peer dependencies (if not present)
23
23
 
24
24
  ```
25
- yarn add moment react react-intl
25
+ pnpm add moment react react-intl
26
26
  ```
27
27
 
28
28
  ```
@@ -66,7 +66,8 @@ export default Example;
66
66
  | `isReadOnly` | `boolean` | | | Disables the date picker menu and sets the input field as read-only |
67
67
  | `hasError` | `boolean` | | | Indicates the input field has an error |
68
68
  | `hasWarning` | `boolean` | | | Indicates the input field has a warning |
69
- | `defaultDaySelectionTime` | `string` | | | The time that will be used by default when a user selects a calendar day.&#xA;It must follow the “HH:mm” pattern (eg: 04:30, 13:25, 23:59) |
69
+ | `defaultDaySelectionTime` | `string` | | | The time that will be used by default when a user selects a calendar day.&#xA;It must follow the "HH:mm" pattern (eg: 04:30, 13:25, 23:59) |
70
+ | `appearance` | `union`<br/>Possible values:<br/>`'default' , 'filter'` | | | Indicates the appearance of the input.&#xA;Filter appearance removes borders and box shadows, and calendar is always open. |
70
71
 
71
72
  ## Signatures
72
73
 
@@ -17,7 +17,6 @@ var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
17
17
  var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
18
18
  var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
19
19
  var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
20
- var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
21
20
  var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
22
21
  var _fillInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/fill');
23
22
  var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
@@ -43,7 +42,6 @@ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachIns
43
42
  var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
44
43
  var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
45
44
  var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
46
- var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
47
45
  var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
48
46
  var _fillInstanceProperty__default = /*#__PURE__*/_interopDefault(_fillInstanceProperty);
49
47
  var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
@@ -66,7 +64,7 @@ DateCalendarTimeInput.displayName = 'DateCalendarTimeInput';
66
64
  var TimeInput = DateCalendarTimeInput;
67
65
 
68
66
  function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
69
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(t))).call(_context4, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
67
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
70
68
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? _Reflect$construct__default["default"](o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
71
69
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
72
70
  const activationTypes = [Downshift__default["default"].stateChangeTypes.keyDownEnter, Downshift__default["default"].stateChangeTypes.clickItem];
@@ -117,10 +115,7 @@ let DateTimeInput = /*#__PURE__*/function (_Component) {
117
115
  _this.setState(prevState => ({
118
116
  calendarDate: today,
119
117
  highlightedIndex: (prevState.suggestedItems || []).length + calendarTimeUtils.getDateInMonth(today, _this.props.timeZone) - 1
120
- }), () => {
121
- var _this$inputRef$curren;
122
- return (_this$inputRef$curren = _this.inputRef.current) === null || _this$inputRef$curren === void 0 ? void 0 : _this$inputRef$curren.focus();
123
- });
118
+ }), () => _this.inputRef.current?.focus());
124
119
  };
125
120
  _this.handleBlur = () => {
126
121
  if (_this.props.onBlur) _this.props.onBlur({
@@ -144,25 +139,21 @@ let DateTimeInput = /*#__PURE__*/function (_Component) {
144
139
  }
145
140
  _this.emit(date);
146
141
  };
147
- _this.emit = value => {
148
- var _this$props$onChange, _this$props;
149
- return (_this$props$onChange = (_this$props = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, {
150
- target: {
151
- id: _this.props.id,
152
- name: _this.props.name,
153
- // when cleared the value is null, but we always want it to be an
154
- // empty string when there is no value.
155
- value: value || ''
156
- }
157
- });
158
- };
142
+ _this.emit = value => _this.props.onChange?.({
143
+ target: {
144
+ id: _this.props.id,
145
+ name: _this.props.name,
146
+ // when cleared the value is null, but we always want it to be an
147
+ // empty string when there is no value.
148
+ value: value || ''
149
+ }
150
+ });
159
151
  return _this;
160
152
  }
161
153
  _inherits(DateTimeInput, _Component);
162
154
  return _createClass(DateTimeInput, [{
163
155
  key: "render",
164
156
  value: function render() {
165
- var _context;
166
157
  if (!this.props.isReadOnly) {
167
158
  process.env.NODE_ENV !== "production" ? utils.warning(typeof this.props.onChange === 'function', 'DateTimeInput: `onChange` is required when input is not read only.') : void 0;
168
159
  }
@@ -225,14 +216,13 @@ let DateTimeInput = /*#__PURE__*/function (_Component) {
225
216
  return null;
226
217
  }, () => {
227
218
  if (_includesInstanceProperty__default["default"](activationTypes).call(activationTypes, changes.type)) {
228
- var _this$timeInputRef$cu, _this$timeInputRef$cu2;
229
- (_this$timeInputRef$cu = this.timeInputRef.current) === null || _this$timeInputRef$cu === void 0 || _this$timeInputRef$cu.focus();
230
- (_this$timeInputRef$cu2 = this.timeInputRef.current) === null || _this$timeInputRef$cu2 === void 0 || _this$timeInputRef$cu2.setSelectionRange(0, this.state.timeString.length);
219
+ this.timeInputRef.current?.focus();
220
+ this.timeInputRef.current?.setSelectionRange(0, this.state.timeString.length);
231
221
  }
232
222
  });
233
223
  },
234
224
  children: _ref => {
235
- var _context2;
225
+ var _context;
236
226
  let getInputProps = _ref.getInputProps,
237
227
  getMenuProps = _ref.getMenuProps,
238
228
  getItemProps = _ref.getItemProps,
@@ -248,7 +238,7 @@ let DateTimeInput = /*#__PURE__*/function (_Component) {
248
238
  const suggestedItems = this.state.suggestedItems;
249
239
  const calendarItems = calendarTimeUtils.createCalendarItems(this.state.calendarDate, this.state.timeString, this.props.timeZone);
250
240
  const paddingDayCount = calendarTimeUtils.getPaddingDayCount(this.state.calendarDate, this.props.intl.locale, this.props.timeZone);
251
- const paddingDays = _fillInstanceProperty__default["default"](_context2 = Array(paddingDayCount)).call(_context2, undefined);
241
+ const paddingDays = _fillInstanceProperty__default["default"](_context = Array(paddingDayCount)).call(_context, undefined);
252
242
  const weekdays = calendarTimeUtils.getWeekdayNames(this.props.intl.locale);
253
243
  const today = calendarTimeUtils.getToday(this.props.timeZone);
254
244
  const isTimeInputVisible = Boolean(this.props.value) && this.props.value !== '';
@@ -316,19 +306,17 @@ let DateTimeInput = /*#__PURE__*/function (_Component) {
316
306
  // validate the input on blur, and emit the value if it's valid
317
307
  onBlur: event => {
318
308
  createBlurHandler(this.timeInputRef, () => {
319
- var _this$inputRef$curren2;
320
- const inputValue = ((_this$inputRef$curren2 = this.inputRef.current) === null || _this$inputRef$curren2 === void 0 ? void 0 : _this$inputRef$curren2.value) || '';
309
+ const inputValue = this.inputRef.current?.value || '';
321
310
  const parsedDate = calendarTimeUtils.parseInputText(inputValue, this.props.intl.locale, this.props.timeZone);
322
311
  if (inputValue.length > 0 && !parsedDate) return;
323
312
  this.emit(parsedDate);
324
313
  })(event);
325
314
  },
326
315
  onChange: event => {
327
- var _event$target$value;
328
316
  // keep timeInput and regular input in sync when user
329
317
  // types into regular input
330
318
  if (!isOpen) return;
331
- const time = (_event$target$value = event.target.value) === null || _event$target$value === void 0 ? void 0 : _event$target$value.split(' ')[1];
319
+ const time = event.target.value?.split(' ')[1];
332
320
  if (!time) return;
333
321
  const parsedTime = utils.parseTime(time);
334
322
  this.setState(() => {
@@ -396,16 +384,14 @@ let DateTimeInput = /*#__PURE__*/function (_Component) {
396
384
  onChange: this.handleTimeChange,
397
385
  onKeyDown: event => {
398
386
  if (event.key === 'ArrowUp') {
399
- var _this$inputRef$curren3;
400
387
  setHighlightedIndex(-1);
401
- (_this$inputRef$curren3 = this.inputRef.current) === null || _this$inputRef$curren3 === void 0 || _this$inputRef$curren3.focus();
388
+ this.inputRef.current?.focus();
402
389
  return;
403
390
  }
404
391
  if (event.key === 'Enter') {
405
- var _this$inputRef$curren4, _this$inputRef$curren5;
406
392
  setHighlightedIndex(-1);
407
- (_this$inputRef$curren4 = this.inputRef.current) === null || _this$inputRef$curren4 === void 0 || _this$inputRef$curren4.focus();
408
- (_this$inputRef$curren5 = this.inputRef.current) === null || _this$inputRef$curren5 === void 0 || _this$inputRef$curren5.setSelectionRange(0, 100);
393
+ this.inputRef.current?.focus();
394
+ this.inputRef.current?.setSelectionRange(0, 100);
409
395
  closeMenu();
410
396
  }
411
397
  }
@@ -413,7 +399,7 @@ let DateTimeInput = /*#__PURE__*/function (_Component) {
413
399
  }))]
414
400
  });
415
401
  }
416
- }, _concatInstanceProperty__default["default"](_context = "".concat(this.props.timeZone, ":")).call(_context, this.props.intl.locale))
402
+ }, `${this.props.timeZone}:${this.props.intl.locale}`)
417
403
  });
418
404
  }
419
405
  }]);
@@ -422,7 +408,7 @@ DateTimeInput.displayName = 'DateTimeInput';
422
408
  var dateTimeInput = reactIntl.injectIntl(DateTimeInput);
423
409
 
424
410
  // NOTE: This string will be replaced on build time with the package version.
425
- var version = "20.5.0";
411
+ var version = "20.6.0";
426
412
 
427
413
  exports["default"] = dateTimeInput;
428
414
  exports.version = version;
@@ -17,7 +17,6 @@ var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
17
17
  var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
18
18
  var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
19
19
  var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
20
- var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
21
20
  var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
22
21
  var _fillInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/fill');
23
22
  var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
@@ -43,7 +42,6 @@ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachIns
43
42
  var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
44
43
  var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
45
44
  var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
46
- var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
47
45
  var _includesInstanceProperty__default = /*#__PURE__*/_interopDefault(_includesInstanceProperty);
48
46
  var _fillInstanceProperty__default = /*#__PURE__*/_interopDefault(_fillInstanceProperty);
49
47
  var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
@@ -66,7 +64,7 @@ DateCalendarTimeInput.displayName = 'DateCalendarTimeInput';
66
64
  var TimeInput = DateCalendarTimeInput;
67
65
 
68
66
  function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
69
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(t))).call(_context4, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
67
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
70
68
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? _Reflect$construct__default["default"](o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
71
69
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
72
70
  const activationTypes = [Downshift__default["default"].stateChangeTypes.keyDownEnter, Downshift__default["default"].stateChangeTypes.clickItem];
@@ -117,10 +115,7 @@ let DateTimeInput = /*#__PURE__*/function (_Component) {
117
115
  _this.setState(prevState => ({
118
116
  calendarDate: today,
119
117
  highlightedIndex: (prevState.suggestedItems || []).length + calendarTimeUtils.getDateInMonth(today, _this.props.timeZone) - 1
120
- }), () => {
121
- var _this$inputRef$curren;
122
- return (_this$inputRef$curren = _this.inputRef.current) === null || _this$inputRef$curren === void 0 ? void 0 : _this$inputRef$curren.focus();
123
- });
118
+ }), () => _this.inputRef.current?.focus());
124
119
  };
125
120
  _this.handleBlur = () => {
126
121
  if (_this.props.onBlur) _this.props.onBlur({
@@ -144,25 +139,21 @@ let DateTimeInput = /*#__PURE__*/function (_Component) {
144
139
  }
145
140
  _this.emit(date);
146
141
  };
147
- _this.emit = value => {
148
- var _this$props$onChange, _this$props;
149
- return (_this$props$onChange = (_this$props = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, {
150
- target: {
151
- id: _this.props.id,
152
- name: _this.props.name,
153
- // when cleared the value is null, but we always want it to be an
154
- // empty string when there is no value.
155
- value: value || ''
156
- }
157
- });
158
- };
142
+ _this.emit = value => _this.props.onChange?.({
143
+ target: {
144
+ id: _this.props.id,
145
+ name: _this.props.name,
146
+ // when cleared the value is null, but we always want it to be an
147
+ // empty string when there is no value.
148
+ value: value || ''
149
+ }
150
+ });
159
151
  return _this;
160
152
  }
161
153
  _inherits(DateTimeInput, _Component);
162
154
  return _createClass(DateTimeInput, [{
163
155
  key: "render",
164
156
  value: function render() {
165
- var _context;
166
157
  if (!this.props.isReadOnly) ;
167
158
  const appearance = this.props.appearance || 'default';
168
159
  return jsxRuntime.jsx(Constraints__default["default"].Horizontal, {
@@ -223,14 +214,13 @@ let DateTimeInput = /*#__PURE__*/function (_Component) {
223
214
  return null;
224
215
  }, () => {
225
216
  if (_includesInstanceProperty__default["default"](activationTypes).call(activationTypes, changes.type)) {
226
- var _this$timeInputRef$cu, _this$timeInputRef$cu2;
227
- (_this$timeInputRef$cu = this.timeInputRef.current) === null || _this$timeInputRef$cu === void 0 || _this$timeInputRef$cu.focus();
228
- (_this$timeInputRef$cu2 = this.timeInputRef.current) === null || _this$timeInputRef$cu2 === void 0 || _this$timeInputRef$cu2.setSelectionRange(0, this.state.timeString.length);
217
+ this.timeInputRef.current?.focus();
218
+ this.timeInputRef.current?.setSelectionRange(0, this.state.timeString.length);
229
219
  }
230
220
  });
231
221
  },
232
222
  children: _ref => {
233
- var _context2;
223
+ var _context;
234
224
  let getInputProps = _ref.getInputProps,
235
225
  getMenuProps = _ref.getMenuProps,
236
226
  getItemProps = _ref.getItemProps,
@@ -246,7 +236,7 @@ let DateTimeInput = /*#__PURE__*/function (_Component) {
246
236
  const suggestedItems = this.state.suggestedItems;
247
237
  const calendarItems = calendarTimeUtils.createCalendarItems(this.state.calendarDate, this.state.timeString, this.props.timeZone);
248
238
  const paddingDayCount = calendarTimeUtils.getPaddingDayCount(this.state.calendarDate, this.props.intl.locale, this.props.timeZone);
249
- const paddingDays = _fillInstanceProperty__default["default"](_context2 = Array(paddingDayCount)).call(_context2, undefined);
239
+ const paddingDays = _fillInstanceProperty__default["default"](_context = Array(paddingDayCount)).call(_context, undefined);
250
240
  const weekdays = calendarTimeUtils.getWeekdayNames(this.props.intl.locale);
251
241
  const today = calendarTimeUtils.getToday(this.props.timeZone);
252
242
  const isTimeInputVisible = Boolean(this.props.value) && this.props.value !== '';
@@ -314,19 +304,17 @@ let DateTimeInput = /*#__PURE__*/function (_Component) {
314
304
  // validate the input on blur, and emit the value if it's valid
315
305
  onBlur: event => {
316
306
  createBlurHandler(this.timeInputRef, () => {
317
- var _this$inputRef$curren2;
318
- const inputValue = ((_this$inputRef$curren2 = this.inputRef.current) === null || _this$inputRef$curren2 === void 0 ? void 0 : _this$inputRef$curren2.value) || '';
307
+ const inputValue = this.inputRef.current?.value || '';
319
308
  const parsedDate = calendarTimeUtils.parseInputText(inputValue, this.props.intl.locale, this.props.timeZone);
320
309
  if (inputValue.length > 0 && !parsedDate) return;
321
310
  this.emit(parsedDate);
322
311
  })(event);
323
312
  },
324
313
  onChange: event => {
325
- var _event$target$value;
326
314
  // keep timeInput and regular input in sync when user
327
315
  // types into regular input
328
316
  if (!isOpen) return;
329
- const time = (_event$target$value = event.target.value) === null || _event$target$value === void 0 ? void 0 : _event$target$value.split(' ')[1];
317
+ const time = event.target.value?.split(' ')[1];
330
318
  if (!time) return;
331
319
  const parsedTime = utils.parseTime(time);
332
320
  this.setState(() => {
@@ -394,16 +382,14 @@ let DateTimeInput = /*#__PURE__*/function (_Component) {
394
382
  onChange: this.handleTimeChange,
395
383
  onKeyDown: event => {
396
384
  if (event.key === 'ArrowUp') {
397
- var _this$inputRef$curren3;
398
385
  setHighlightedIndex(-1);
399
- (_this$inputRef$curren3 = this.inputRef.current) === null || _this$inputRef$curren3 === void 0 || _this$inputRef$curren3.focus();
386
+ this.inputRef.current?.focus();
400
387
  return;
401
388
  }
402
389
  if (event.key === 'Enter') {
403
- var _this$inputRef$curren4, _this$inputRef$curren5;
404
390
  setHighlightedIndex(-1);
405
- (_this$inputRef$curren4 = this.inputRef.current) === null || _this$inputRef$curren4 === void 0 || _this$inputRef$curren4.focus();
406
- (_this$inputRef$curren5 = this.inputRef.current) === null || _this$inputRef$curren5 === void 0 || _this$inputRef$curren5.setSelectionRange(0, 100);
391
+ this.inputRef.current?.focus();
392
+ this.inputRef.current?.setSelectionRange(0, 100);
407
393
  closeMenu();
408
394
  }
409
395
  }
@@ -411,7 +397,7 @@ let DateTimeInput = /*#__PURE__*/function (_Component) {
411
397
  }))]
412
398
  });
413
399
  }
414
- }, _concatInstanceProperty__default["default"](_context = "".concat(this.props.timeZone, ":")).call(_context, this.props.intl.locale))
400
+ }, `${this.props.timeZone}:${this.props.intl.locale}`)
415
401
  });
416
402
  }
417
403
  }]);
@@ -420,7 +406,7 @@ DateTimeInput.displayName = 'DateTimeInput';
420
406
  var dateTimeInput = reactIntl.injectIntl(DateTimeInput);
421
407
 
422
408
  // NOTE: This string will be replaced on build time with the package version.
423
- var version = "20.5.0";
409
+ var version = "20.6.0";
424
410
 
425
411
  exports["default"] = dateTimeInput;
426
412
  exports.version = version;
@@ -13,7 +13,6 @@ import _createClass from '@babel/runtime-corejs3/helpers/esm/createClass';
13
13
  import _possibleConstructorReturn from '@babel/runtime-corejs3/helpers/esm/possibleConstructorReturn';
14
14
  import _getPrototypeOf from '@babel/runtime-corejs3/helpers/esm/getPrototypeOf';
15
15
  import _inherits from '@babel/runtime-corejs3/helpers/esm/inherits';
16
- import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
17
16
  import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
18
17
  import _fillInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/fill';
19
18
  import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
@@ -44,7 +43,7 @@ DateCalendarTimeInput.displayName = 'DateCalendarTimeInput';
44
43
  var TimeInput = DateCalendarTimeInput;
45
44
 
46
45
  function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
47
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context3 = ownKeys(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context4 = ownKeys(Object(t))).call(_context4, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
46
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context3 = ownKeys(Object(t))).call(_context3, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
48
47
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? _Reflect$construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
49
48
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
50
49
  const activationTypes = [Downshift.stateChangeTypes.keyDownEnter, Downshift.stateChangeTypes.clickItem];
@@ -95,10 +94,7 @@ let DateTimeInput = /*#__PURE__*/function (_Component) {
95
94
  _this.setState(prevState => ({
96
95
  calendarDate: today,
97
96
  highlightedIndex: (prevState.suggestedItems || []).length + getDateInMonth(today, _this.props.timeZone) - 1
98
- }), () => {
99
- var _this$inputRef$curren;
100
- return (_this$inputRef$curren = _this.inputRef.current) === null || _this$inputRef$curren === void 0 ? void 0 : _this$inputRef$curren.focus();
101
- });
97
+ }), () => _this.inputRef.current?.focus());
102
98
  };
103
99
  _this.handleBlur = () => {
104
100
  if (_this.props.onBlur) _this.props.onBlur({
@@ -122,25 +118,21 @@ let DateTimeInput = /*#__PURE__*/function (_Component) {
122
118
  }
123
119
  _this.emit(date);
124
120
  };
125
- _this.emit = value => {
126
- var _this$props$onChange, _this$props;
127
- return (_this$props$onChange = (_this$props = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, {
128
- target: {
129
- id: _this.props.id,
130
- name: _this.props.name,
131
- // when cleared the value is null, but we always want it to be an
132
- // empty string when there is no value.
133
- value: value || ''
134
- }
135
- });
136
- };
121
+ _this.emit = value => _this.props.onChange?.({
122
+ target: {
123
+ id: _this.props.id,
124
+ name: _this.props.name,
125
+ // when cleared the value is null, but we always want it to be an
126
+ // empty string when there is no value.
127
+ value: value || ''
128
+ }
129
+ });
137
130
  return _this;
138
131
  }
139
132
  _inherits(DateTimeInput, _Component);
140
133
  return _createClass(DateTimeInput, [{
141
134
  key: "render",
142
135
  value: function render() {
143
- var _context;
144
136
  if (!this.props.isReadOnly) {
145
137
  process.env.NODE_ENV !== "production" ? warning(typeof this.props.onChange === 'function', 'DateTimeInput: `onChange` is required when input is not read only.') : void 0;
146
138
  }
@@ -203,14 +195,13 @@ let DateTimeInput = /*#__PURE__*/function (_Component) {
203
195
  return null;
204
196
  }, () => {
205
197
  if (_includesInstanceProperty(activationTypes).call(activationTypes, changes.type)) {
206
- var _this$timeInputRef$cu, _this$timeInputRef$cu2;
207
- (_this$timeInputRef$cu = this.timeInputRef.current) === null || _this$timeInputRef$cu === void 0 || _this$timeInputRef$cu.focus();
208
- (_this$timeInputRef$cu2 = this.timeInputRef.current) === null || _this$timeInputRef$cu2 === void 0 || _this$timeInputRef$cu2.setSelectionRange(0, this.state.timeString.length);
198
+ this.timeInputRef.current?.focus();
199
+ this.timeInputRef.current?.setSelectionRange(0, this.state.timeString.length);
209
200
  }
210
201
  });
211
202
  },
212
203
  children: _ref => {
213
- var _context2;
204
+ var _context;
214
205
  let getInputProps = _ref.getInputProps,
215
206
  getMenuProps = _ref.getMenuProps,
216
207
  getItemProps = _ref.getItemProps,
@@ -226,7 +217,7 @@ let DateTimeInput = /*#__PURE__*/function (_Component) {
226
217
  const suggestedItems = this.state.suggestedItems;
227
218
  const calendarItems = createCalendarItems(this.state.calendarDate, this.state.timeString, this.props.timeZone);
228
219
  const paddingDayCount = getPaddingDayCount(this.state.calendarDate, this.props.intl.locale, this.props.timeZone);
229
- const paddingDays = _fillInstanceProperty(_context2 = Array(paddingDayCount)).call(_context2, undefined);
220
+ const paddingDays = _fillInstanceProperty(_context = Array(paddingDayCount)).call(_context, undefined);
230
221
  const weekdays = getWeekdayNames(this.props.intl.locale);
231
222
  const today = getToday(this.props.timeZone);
232
223
  const isTimeInputVisible = Boolean(this.props.value) && this.props.value !== '';
@@ -294,19 +285,17 @@ let DateTimeInput = /*#__PURE__*/function (_Component) {
294
285
  // validate the input on blur, and emit the value if it's valid
295
286
  onBlur: event => {
296
287
  createBlurHandler(this.timeInputRef, () => {
297
- var _this$inputRef$curren2;
298
- const inputValue = ((_this$inputRef$curren2 = this.inputRef.current) === null || _this$inputRef$curren2 === void 0 ? void 0 : _this$inputRef$curren2.value) || '';
288
+ const inputValue = this.inputRef.current?.value || '';
299
289
  const parsedDate = parseInputText(inputValue, this.props.intl.locale, this.props.timeZone);
300
290
  if (inputValue.length > 0 && !parsedDate) return;
301
291
  this.emit(parsedDate);
302
292
  })(event);
303
293
  },
304
294
  onChange: event => {
305
- var _event$target$value;
306
295
  // keep timeInput and regular input in sync when user
307
296
  // types into regular input
308
297
  if (!isOpen) return;
309
- const time = (_event$target$value = event.target.value) === null || _event$target$value === void 0 ? void 0 : _event$target$value.split(' ')[1];
298
+ const time = event.target.value?.split(' ')[1];
310
299
  if (!time) return;
311
300
  const parsedTime = parseTime(time);
312
301
  this.setState(() => {
@@ -374,16 +363,14 @@ let DateTimeInput = /*#__PURE__*/function (_Component) {
374
363
  onChange: this.handleTimeChange,
375
364
  onKeyDown: event => {
376
365
  if (event.key === 'ArrowUp') {
377
- var _this$inputRef$curren3;
378
366
  setHighlightedIndex(-1);
379
- (_this$inputRef$curren3 = this.inputRef.current) === null || _this$inputRef$curren3 === void 0 || _this$inputRef$curren3.focus();
367
+ this.inputRef.current?.focus();
380
368
  return;
381
369
  }
382
370
  if (event.key === 'Enter') {
383
- var _this$inputRef$curren4, _this$inputRef$curren5;
384
371
  setHighlightedIndex(-1);
385
- (_this$inputRef$curren4 = this.inputRef.current) === null || _this$inputRef$curren4 === void 0 || _this$inputRef$curren4.focus();
386
- (_this$inputRef$curren5 = this.inputRef.current) === null || _this$inputRef$curren5 === void 0 || _this$inputRef$curren5.setSelectionRange(0, 100);
372
+ this.inputRef.current?.focus();
373
+ this.inputRef.current?.setSelectionRange(0, 100);
387
374
  closeMenu();
388
375
  }
389
376
  }
@@ -391,7 +378,7 @@ let DateTimeInput = /*#__PURE__*/function (_Component) {
391
378
  }))]
392
379
  });
393
380
  }
394
- }, _concatInstanceProperty(_context = "".concat(this.props.timeZone, ":")).call(_context, this.props.intl.locale))
381
+ }, `${this.props.timeZone}:${this.props.intl.locale}`)
395
382
  });
396
383
  }
397
384
  }]);
@@ -400,6 +387,6 @@ DateTimeInput.displayName = 'DateTimeInput';
400
387
  var dateTimeInput = injectIntl(DateTimeInput);
401
388
 
402
389
  // NOTE: This string will be replaced on build time with the package version.
403
- var version = "20.5.0";
390
+ var version = "20.6.0";
404
391
 
405
392
  export { dateTimeInput as default, version };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@commercetools-uikit/date-time-input",
3
3
  "description": "The `DateTimeInput` component allows the user to select a date. This component also supports multiple date selection.",
4
- "version": "20.5.0",
4
+ "version": "20.6.0",
5
5
  "bugs": "https://github.com/commercetools/ui-kit/issues",
6
6
  "repository": {
7
7
  "type": "git",
@@ -9,7 +9,13 @@
9
9
  "directory": "packages/components/inputs/date-time-input"
10
10
  },
11
11
  "homepage": "https://uikit.commercetools.com",
12
- "keywords": ["javascript", "typescript", "design-system", "react", "uikit"],
12
+ "keywords": [
13
+ "javascript",
14
+ "typescript",
15
+ "design-system",
16
+ "react",
17
+ "uikit"
18
+ ],
13
19
  "license": "MIT",
14
20
  "publishConfig": {
15
21
  "access": "public"
@@ -17,31 +23,34 @@
17
23
  "sideEffects": false,
18
24
  "main": "dist/commercetools-uikit-date-time-input.cjs.js",
19
25
  "module": "dist/commercetools-uikit-date-time-input.esm.js",
20
- "files": ["dist"],
26
+ "files": [
27
+ "dist"
28
+ ],
21
29
  "dependencies": {
22
30
  "@babel/runtime": "^7.20.13",
23
31
  "@babel/runtime-corejs3": "^7.20.13",
24
- "@commercetools-uikit/accessible-button": "20.5.0",
25
- "@commercetools-uikit/calendar-time-utils": "20.5.0",
26
- "@commercetools-uikit/calendar-utils": "20.5.0",
27
- "@commercetools-uikit/constraints": "20.5.0",
28
- "@commercetools-uikit/design-system": "20.5.0",
29
- "@commercetools-uikit/hooks": "20.5.0",
30
- "@commercetools-uikit/icons": "20.5.0",
31
- "@commercetools-uikit/secondary-icon-button": "20.5.0",
32
- "@commercetools-uikit/select-utils": "20.5.0",
33
- "@commercetools-uikit/spacings-inline": "20.5.0",
34
- "@commercetools-uikit/text": "20.5.0",
35
- "@commercetools-uikit/tooltip": "20.5.0",
36
- "@commercetools-uikit/utils": "20.5.0",
37
32
  "@emotion/react": "^11.10.5",
38
33
  "@emotion/styled": "^11.10.5",
39
34
  "downshift": "9.0.10",
40
35
  "react-is": "19.2.0",
41
- "warning": "4.0.3"
36
+ "warning": "4.0.3",
37
+ "@commercetools-uikit/accessible-button": "^20.6.0",
38
+ "@commercetools-uikit/calendar-time-utils": "^20.6.0",
39
+ "@commercetools-uikit/calendar-utils": "^20.6.0",
40
+ "@commercetools-uikit/constraints": "^20.6.0",
41
+ "@commercetools-uikit/design-system": "^20.6.0",
42
+ "@commercetools-uikit/hooks": "^20.6.0",
43
+ "@commercetools-uikit/icons": "^20.6.0",
44
+ "@commercetools-uikit/secondary-icon-button": "^20.6.0",
45
+ "@commercetools-uikit/select-utils": "^20.6.0",
46
+ "@commercetools-uikit/spacings-inline": "^20.6.0",
47
+ "@commercetools-uikit/text": "^20.6.0",
48
+ "@commercetools-uikit/tooltip": "^20.6.0",
49
+ "@commercetools-uikit/utils": "^20.6.0"
42
50
  },
43
51
  "devDependencies": {
44
52
  "moment": "2.30.1",
53
+ "prop-types": "^15.8.1",
45
54
  "react": "19.2.0",
46
55
  "react-intl": "^7.1.4"
47
56
  },
@@ -50,4 +59,4 @@
50
59
  "react": "19.x",
51
60
  "react-intl": "7.x"
52
61
  }
53
- }
62
+ }