@commercetools-uikit/date-range-input 12.2.2 → 12.2.6

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.
@@ -10,7 +10,6 @@ var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/in
10
10
  var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
11
11
  var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
12
12
  var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
13
- var _extends = require('@babel/runtime-corejs3/helpers/extends');
14
13
  var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
15
14
  var _toConsumableArray = require('@babel/runtime-corejs3/helpers/toConsumableArray');
16
15
  var _classCallCheck = require('@babel/runtime-corejs3/helpers/classCallCheck');
@@ -24,14 +23,14 @@ var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/insta
24
23
  var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
25
24
  var _sortInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/sort');
26
25
  var _fillInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/fill');
27
- var React = require('react');
26
+ var react = require('react');
28
27
  var PropTypes = require('prop-types');
29
28
  var Downshift = require('downshift');
30
29
  var reactIntl = require('react-intl');
31
30
  var Constraints = require('@commercetools-uikit/constraints');
32
31
  var utils = require('@commercetools-uikit/utils');
33
32
  var calendarUtils = require('@commercetools-uikit/calendar-utils');
34
- var react = require('@emotion/react');
33
+ var jsxRuntime = require('@emotion/react/jsx-runtime');
35
34
 
36
35
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
37
36
 
@@ -49,7 +48,6 @@ var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceP
49
48
  var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
50
49
  var _sortInstanceProperty__default = /*#__PURE__*/_interopDefault(_sortInstanceProperty);
51
50
  var _fillInstanceProperty__default = /*#__PURE__*/_interopDefault(_fillInstanceProperty);
52
- var React__default = /*#__PURE__*/_interopDefault(React);
53
51
  var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
54
52
  var Downshift__default = /*#__PURE__*/_interopDefault(Downshift);
55
53
  var Constraints__default = /*#__PURE__*/_interopDefault(Constraints);
@@ -62,13 +60,13 @@ var messages = reactIntl.defineMessages({
62
60
  }
63
61
  });
64
62
 
65
- function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default['default'](object); if (_Object$getOwnPropertySymbols__default['default']) { var symbols = _Object$getOwnPropertySymbols__default['default'](object); if (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; }
63
+ function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); if (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; }
66
64
 
67
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context6; _forEachInstanceProperty__default['default'](_context6 = ownKeys(Object(source), true)).call(_context6, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors__default['default']) { _Object$defineProperties__default['default'](target, _Object$getOwnPropertyDescriptors__default['default'](source)); } else { var _context7; _forEachInstanceProperty__default['default'](_context7 = ownKeys(Object(source))).call(_context7, function (key) { _Object$defineProperty__default['default'](target, key, _Object$getOwnPropertyDescriptor__default['default'](source, key)); }); } } return target; }
65
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context6; _forEachInstanceProperty__default["default"](_context6 = ownKeys(Object(source), true)).call(_context6, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors__default["default"]) { _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)); } else { var _context7; _forEachInstanceProperty__default["default"](_context7 = ownKeys(Object(source))).call(_context7, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } } return target; }
68
66
 
69
- 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); }; }
67
+ 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); }; }
70
68
 
71
- 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; } }
69
+ 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; } }
72
70
 
73
71
  var preventDownshiftDefault = function preventDownshiftDefault(event) {
74
72
  // eslint-disable-next-line no-param-reassign
@@ -78,8 +76,8 @@ var preventDownshiftDefault = function preventDownshiftDefault(event) {
78
76
  var parseRangeText = function parseRangeText(text, locale) {
79
77
  var _context, _context2;
80
78
 
81
- var parts = _filterInstanceProperty__default['default'](_context = _mapInstanceProperty__default['default'](_context2 = text.split(' - ')).call(_context2, function (part) {
82
- var parsedDate = calendarUtils.parseInputToDate(_trimInstanceProperty__default['default'](part).call(part), locale);
79
+ var parts = _filterInstanceProperty__default["default"](_context = _mapInstanceProperty__default["default"](_context2 = text.split(' - ')).call(_context2, function (part) {
80
+ var parsedDate = calendarUtils.parseInputToDate(_trimInstanceProperty__default["default"](part).call(part), locale);
83
81
  return parsedDate === '' ? null : parsedDate;
84
82
  })).call(_context, Boolean);
85
83
 
@@ -133,8 +131,8 @@ var getRange = function getRange(_ref) {
133
131
  };
134
132
  };
135
133
 
136
- var DateRangeCalendar = /*#__PURE__*/function (_React$Component) {
137
- _inherits(DateRangeCalendar, _React$Component);
134
+ var DateRangeCalendar = /*#__PURE__*/function (_Component) {
135
+ _inherits(DateRangeCalendar, _Component);
138
136
 
139
137
  var _super = _createSuper(DateRangeCalendar);
140
138
 
@@ -149,8 +147,8 @@ var DateRangeCalendar = /*#__PURE__*/function (_React$Component) {
149
147
  args[_key] = arguments[_key];
150
148
  }
151
149
 
152
- _this = _super.call.apply(_super, _concatInstanceProperty__default['default'](_context3 = [this]).call(_context3, args));
153
- _this.inputRef = /*#__PURE__*/React__default['default'].createRef();
150
+ _this = _super.call.apply(_super, _concatInstanceProperty__default["default"](_context3 = [this]).call(_context3, args));
151
+ _this.inputRef = /*#__PURE__*/react.createRef();
154
152
  _this.state = {
155
153
  calendarDate: _this.props.value.length === 2 ? _this.props.value[0] : calendarUtils.getToday(),
156
154
  suggestedItems: [],
@@ -201,7 +199,7 @@ var DateRangeCalendar = /*#__PURE__*/function (_React$Component) {
201
199
  target: {
202
200
  id: _this.props.id,
203
201
  name: _this.props.name,
204
- value: _sortInstanceProperty__default['default'](unsortedRange).call(unsortedRange)
202
+ value: _sortInstanceProperty__default["default"](unsortedRange).call(unsortedRange)
205
203
  }
206
204
  });
207
205
  };
@@ -214,279 +212,283 @@ var DateRangeCalendar = /*#__PURE__*/function (_React$Component) {
214
212
  value: function render() {
215
213
  var _this2 = this;
216
214
 
217
- return react.jsx(Constraints__default['default'].Horizontal, {
218
- max: this.props.horizontalConstraint
219
- }, react.jsx(Downshift__default['default'], {
220
- key: this.props.intl.locale,
221
- inputId: this.props.id,
222
- itemToString: calendarUtils.createItemRangeToString(this.props.intl.locale),
223
- inputValue: this.state.inputValue,
224
- selectedItem: null,
225
- highlightedIndex: this.state.highlightedIndex,
226
- onInputValueChange: function onInputValueChange(inputValue, changes) {
227
- // only attempt to parse input when the user typed into the input
228
- // field
229
- if (changes.type !== Downshift__default['default'].stateChangeTypes.changeInput) return;
230
-
231
- _this2.setState(function () {
232
- var parsedRange = parseRangeText(inputValue, _this2.props.intl.locale);
233
- if (parsedRange.length === 0) return {
234
- suggestedItems: [],
235
- highlightedIndex: null,
236
- inputValue: inputValue,
237
- startDate: null
238
- };
239
-
240
- if (parsedRange.length === 1) {
241
- var calendarDate = parsedRange[0];
242
- return {
215
+ return jsxRuntime.jsx(Constraints__default["default"].Horizontal, {
216
+ max: this.props.horizontalConstraint,
217
+ children: jsxRuntime.jsx(Downshift__default["default"], {
218
+ inputId: this.props.id,
219
+ itemToString: calendarUtils.createItemRangeToString(this.props.intl.locale),
220
+ inputValue: this.state.inputValue,
221
+ selectedItem: null,
222
+ highlightedIndex: this.state.highlightedIndex,
223
+ onInputValueChange: function onInputValueChange(inputValue, changes) {
224
+ // only attempt to parse input when the user typed into the input
225
+ // field
226
+ if (changes.type !== Downshift__default["default"].stateChangeTypes.changeInput) return;
227
+
228
+ _this2.setState(function () {
229
+ var parsedRange = parseRangeText(inputValue, _this2.props.intl.locale);
230
+ if (parsedRange.length === 0) return {
243
231
  suggestedItems: [],
244
- highlightedIndex: calendarUtils.getDateInMonth(calendarDate) - 1,
245
- inputValue: inputValue,
246
- startDate: parsedRange[0],
247
- calendarDate: calendarDate
248
- };
249
- }
250
-
251
- if (parsedRange.length === 2) {
252
- var _calendarDate = parsedRange[1];
253
- return {
254
- suggestedItems: [],
255
- highlightedIndex: calendarUtils.getDateInMonth(_calendarDate) - 1,
256
- inputValue: inputValue,
257
- startDate: parsedRange[0],
258
- calendarDate: _calendarDate
259
- };
260
- }
261
-
262
- return null;
263
- });
264
- },
265
- onStateChange: function onStateChange(changes) {
266
- /* eslint-disable no-prototype-builtins */
267
- _this2.setState(function (prevState) {
268
- // ensure input value matches prop value when menu is closed
269
- if (changes.type === Downshift__default['default'].stateChangeTypes.mouseUp || changes.type === Downshift__default['default'].stateChangeTypes.blurInput) {
270
- return {
271
232
  highlightedIndex: null,
272
- isOpen: false,
273
- inputValue: calendarUtils.formatRange(_this2.props.value, _this2.props.intl.locale)
274
- };
275
- }
276
-
277
- if (changes.hasOwnProperty('selectedItem')) {
278
- var hasStartedRangeSelection = Boolean(!prevState.startDate && changes.selectedItem);
279
- var hasFinishedRangeSelection = Boolean(prevState.startDate && changes.selectedItem);
280
- return {
281
- highlightedIndex: prevState.highlightedIndex,
282
- startDate: prevState.startDate ? null : changes.selectedItem,
283
- calendarDate: changes.selectedItem,
284
- isOpen: !hasFinishedRangeSelection,
285
- inputValue: function () {
286
- if (hasFinishedRangeSelection) {
287
- return calendarUtils.formatRange([prevState.startDate, changes.selectedItem], _this2.props.intl.locale);
288
- }
289
-
290
- if (hasStartedRangeSelection) {
291
- return calendarUtils.formatRange([changes.selectedItem], _this2.props.intl.locale);
292
- }
293
-
294
- return '';
295
- }()
296
- };
297
- }
298
-
299
- if (changes.hasOwnProperty('isOpen')) {
300
- return {
301
- isOpen: changes.isOpen,
302
- highlightedIndex: changes.highlightedIndex || null,
303
- inputValue: changes.inputValue || prevState.inputValue,
304
- // Reset range selection progress when menu opens/closes
305
- startDate: null,
306
- // Ensure calendar opens on selected date.
307
- // Open on the current day as a fallback.
308
- calendarDate: _this2.props.value.length === 2 ? _this2.props.value[0] : calendarUtils.getToday()
233
+ inputValue: inputValue,
234
+ startDate: null
309
235
  };
310
- }
311
236
 
312
- if (changes.hasOwnProperty('highlightedIndex')) {
313
- return {
314
- highlightedIndex: changes.highlightedIndex
315
- };
316
- }
317
-
318
- return null;
319
- });
320
- /* eslint-enable no-prototype-builtins */
321
-
322
- },
323
- onChange: function onChange(selectedItem) {
324
- if (_this2.state.startDate && selectedItem) {
325
- _this2.emit([_this2.state.startDate, selectedItem]);
326
- } else {
327
- _this2.emit([]);
328
- }
329
- },
330
- isOpen: this.state.isOpen
331
- }, function (_ref2) {
332
- var _context4, _context5;
333
-
334
- var getInputProps = _ref2.getInputProps,
335
- getMenuProps = _ref2.getMenuProps,
336
- getItemProps = _ref2.getItemProps,
337
- getToggleButtonProps = _ref2.getToggleButtonProps,
338
- clearSelection = _ref2.clearSelection,
339
- highlightedIndex = _ref2.highlightedIndex,
340
- openMenu = _ref2.openMenu,
341
- setHighlightedIndex = _ref2.setHighlightedIndex,
342
- isOpen = _ref2.isOpen,
343
- inputValue = _ref2.inputValue;
344
- var calendarItems = calendarUtils.createCalendarItems(_this2.state.calendarDate, _this2.props.intl);
345
-
346
- var allItems = _concatInstanceProperty__default['default'](_context4 = []).call(_context4, _toConsumableArray(_this2.state.suggestedItems), _toConsumableArray(calendarItems));
347
-
348
- var paddingDayCount = calendarUtils.getPaddingDayCount(_this2.state.calendarDate, _this2.props.intl.locale);
349
-
350
- var paddingDays = _fillInstanceProperty__default['default'](_context5 = Array(paddingDayCount)).call(_context5);
351
-
352
- var weekdays = calendarUtils.getWeekdayNames(_this2.props.intl.locale);
353
- var today = calendarUtils.getToday();
354
- return react.jsx("div", {
355
- onFocus: _this2.props.onFocus,
356
- onBlur: _this2.handleBlur
357
- }, react.jsx(calendarUtils.CalendarBody, {
358
- inputRef: _this2.inputRef,
359
- inputProps: getInputProps(_objectSpread({
360
- // Unset the aria-labelledby as it interfers with the link
361
- // between the <label for> and the <input id>.
362
- 'aria-labelledby': undefined,
363
- name: _this2.props.name,
364
- placeholder: typeof _this2.props.placeholder === 'string' ? _this2.props.placeholder : _this2.props.intl.formatMessage(messages.placeholder),
365
- onMouseEnter: function onMouseEnter() {
366
- // we remove the highlight so that the user can use the
367
- // arrow keys to move the cursor when hovering
368
- if (isOpen) setHighlightedIndex(null);
369
- },
370
- onKeyDown: function onKeyDown(event) {
371
- if (_this2.props.isReadOnly) {
372
- preventDownshiftDefault(event);
373
- return;
237
+ if (parsedRange.length === 1) {
238
+ var calendarDate = parsedRange[0];
239
+ return {
240
+ suggestedItems: [],
241
+ highlightedIndex: calendarUtils.getDateInMonth(calendarDate) - 1,
242
+ inputValue: inputValue,
243
+ startDate: parsedRange[0],
244
+ calendarDate: calendarDate
245
+ };
374
246
  }
375
247
 
376
- if (event.key === 'Enter' && _trimInstanceProperty__default['default'](inputValue).call(inputValue) === '' && // do not clear value when user presses Enter to
377
- // select the end date (so only clear when there is no
378
- // startDate)
379
- !_this2.state.startDate && _this2.props.isClearable) {
380
- clearSelection();
381
-
382
- _this2.emit([]);
383
- } // ArrowDown
384
-
385
-
386
- if (event.keyCode === 40) {
387
- if (highlightedIndex + 1 >= calendarItems.length) {
388
- // if it's the end of the month
389
- // then bypass normal arrow navigation
390
- preventDownshiftDefault(event); // then jump to start of next month
391
-
392
- _this2.jumpMonth(1, 0);
393
- }
394
- } // ArrowUp
248
+ if (parsedRange.length === 2) {
249
+ var _calendarDate = parsedRange[1];
250
+ return {
251
+ suggestedItems: [],
252
+ highlightedIndex: calendarUtils.getDateInMonth(_calendarDate) - 1,
253
+ inputValue: inputValue,
254
+ startDate: parsedRange[0],
255
+ calendarDate: _calendarDate
256
+ };
257
+ }
395
258
 
259
+ return null;
260
+ });
261
+ },
262
+ onStateChange: function onStateChange(changes) {
263
+ /* eslint-disable no-prototype-builtins */
264
+ _this2.setState(function (prevState) {
265
+ // ensure input value matches prop value when menu is closed
266
+ if (changes.type === Downshift__default["default"].stateChangeTypes.mouseUp || changes.type === Downshift__default["default"].stateChangeTypes.blurInput) {
267
+ return {
268
+ highlightedIndex: null,
269
+ isOpen: false,
270
+ inputValue: calendarUtils.formatRange(_this2.props.value, _this2.props.intl.locale)
271
+ };
272
+ }
396
273
 
397
- if (event.keyCode === 38) {
398
- var previousDay = calendarUtils.getPreviousDay(calendarItems[highlightedIndex]);
274
+ if (changes.hasOwnProperty('selectedItem')) {
275
+ var hasStartedRangeSelection = Boolean(!prevState.startDate && changes.selectedItem);
276
+ var hasFinishedRangeSelection = Boolean(prevState.startDate && changes.selectedItem);
277
+ return {
278
+ highlightedIndex: prevState.highlightedIndex,
279
+ startDate: prevState.startDate ? null : changes.selectedItem,
280
+ calendarDate: changes.selectedItem,
281
+ isOpen: !hasFinishedRangeSelection,
282
+ inputValue: function () {
283
+ if (hasFinishedRangeSelection) {
284
+ return calendarUtils.formatRange([prevState.startDate, changes.selectedItem], _this2.props.intl.locale);
285
+ }
286
+
287
+ if (hasStartedRangeSelection) {
288
+ return calendarUtils.formatRange([changes.selectedItem], _this2.props.intl.locale);
289
+ }
290
+
291
+ return '';
292
+ }()
293
+ };
294
+ }
399
295
 
400
- if (highlightedIndex <= 0) {
401
- // if it's the start of the month
402
- // then bypass normal arrow navigation
403
- preventDownshiftDefault(event);
404
- var numberOfDaysOfPrevMonth = calendarUtils.getDaysInMonth(previousDay); // then jump to the last day of the previous month
296
+ if (changes.hasOwnProperty('isOpen')) {
297
+ return {
298
+ isOpen: changes.isOpen,
299
+ highlightedIndex: changes.highlightedIndex || null,
300
+ inputValue: changes.inputValue || prevState.inputValue,
301
+ // Reset range selection progress when menu opens/closes
302
+ startDate: null,
303
+ // Ensure calendar opens on selected date.
304
+ // Open on the current day as a fallback.
305
+ calendarDate: _this2.props.value.length === 2 ? _this2.props.value[0] : calendarUtils.getToday()
306
+ };
307
+ }
405
308
 
406
- _this2.jumpMonth(-1, numberOfDaysOfPrevMonth - 1);
407
- }
309
+ if (changes.hasOwnProperty('highlightedIndex')) {
310
+ return {
311
+ highlightedIndex: changes.highlightedIndex
312
+ };
408
313
  }
409
- },
410
- // we only do this for readOnly because the input
411
- // doesn't ignore these events, unlike when its disabled
412
- onClick: _this2.props.isReadOnly ? undefined : openMenu
413
- }, utils.filterDataAttributes(_this2.props))),
414
- hasSelection: _this2.props.value.length === 2,
415
- isClearable: _this2.props.isClearable,
416
- onClear: function onClear() {
417
- _this2.setState({
418
- startDate: null
419
- });
420
314
 
421
- _this2.emit([]);
315
+ return null;
316
+ });
317
+ /* eslint-enable no-prototype-builtins */
422
318
 
423
- clearSelection();
424
- },
425
- isOpen: isOpen,
426
- isDisabled: _this2.props.isDisabled,
427
- isReadOnly: _this2.props.isReadOnly,
428
- toggleButtonProps: getToggleButtonProps(),
429
- hasError: _this2.props.hasError,
430
- hasWarning: _this2.props.hasWarning
431
- }), isOpen && !_this2.props.isDisabled && react.jsx(calendarUtils.CalendarMenu, _extends({}, getMenuProps(), {
432
- hasError: _this2.props.hasError,
433
- hasWarning: _this2.props.hasWarning
434
- }), react.jsx(calendarUtils.CalendarHeader, {
435
- monthLabel: calendarUtils.getMonthCalendarLabel(_this2.state.calendarDate, _this2.props.intl.locale),
436
- yearLabel: calendarUtils.getYearCalendarLabel(_this2.state.calendarDate, _this2.props.intl.locale),
437
- onPrevMonthClick: function onPrevMonthClick() {
438
- return _this2.jumpMonth(-1);
439
- },
440
- onTodayClick: _this2.showToday,
441
- onNextMonthClick: function onNextMonthClick() {
442
- return _this2.jumpMonth(1);
443
319
  },
444
- onPrevYearClick: function onPrevYearClick() {
445
- return _this2.jumpMonth(-12);
320
+ onChange: function onChange(selectedItem) {
321
+ if (_this2.state.startDate && selectedItem) {
322
+ _this2.emit([_this2.state.startDate, selectedItem]);
323
+ } else {
324
+ _this2.emit([]);
325
+ }
446
326
  },
447
- onNextYearClick: function onNextYearClick() {
448
- return _this2.jumpMonth(12);
327
+ isOpen: this.state.isOpen,
328
+ children: function children(_ref2) {
329
+ var _context4, _context5;
330
+
331
+ var getInputProps = _ref2.getInputProps,
332
+ getMenuProps = _ref2.getMenuProps,
333
+ getItemProps = _ref2.getItemProps,
334
+ getToggleButtonProps = _ref2.getToggleButtonProps,
335
+ clearSelection = _ref2.clearSelection,
336
+ highlightedIndex = _ref2.highlightedIndex,
337
+ openMenu = _ref2.openMenu,
338
+ setHighlightedIndex = _ref2.setHighlightedIndex,
339
+ isOpen = _ref2.isOpen,
340
+ inputValue = _ref2.inputValue;
341
+ var calendarItems = calendarUtils.createCalendarItems(_this2.state.calendarDate, _this2.props.intl);
342
+
343
+ var allItems = _concatInstanceProperty__default["default"](_context4 = []).call(_context4, _toConsumableArray(_this2.state.suggestedItems), _toConsumableArray(calendarItems));
344
+
345
+ var paddingDayCount = calendarUtils.getPaddingDayCount(_this2.state.calendarDate, _this2.props.intl.locale);
346
+
347
+ var paddingDays = _fillInstanceProperty__default["default"](_context5 = Array(paddingDayCount)).call(_context5);
348
+
349
+ var weekdays = calendarUtils.getWeekdayNames(_this2.props.intl.locale);
350
+ var today = calendarUtils.getToday();
351
+ return jsxRuntime.jsxs("div", {
352
+ onFocus: _this2.props.onFocus,
353
+ onBlur: _this2.handleBlur,
354
+ children: [jsxRuntime.jsx(calendarUtils.CalendarBody, {
355
+ inputRef: _this2.inputRef,
356
+ inputProps: getInputProps(_objectSpread({
357
+ // Unset the aria-labelledby as it interfers with the link
358
+ // between the <label for> and the <input id>.
359
+ 'aria-labelledby': undefined,
360
+ name: _this2.props.name,
361
+ placeholder: typeof _this2.props.placeholder === 'string' ? _this2.props.placeholder : _this2.props.intl.formatMessage(messages.placeholder),
362
+ onMouseEnter: function onMouseEnter() {
363
+ // we remove the highlight so that the user can use the
364
+ // arrow keys to move the cursor when hovering
365
+ if (isOpen) setHighlightedIndex(null);
366
+ },
367
+ onKeyDown: function onKeyDown(event) {
368
+ if (_this2.props.isReadOnly) {
369
+ preventDownshiftDefault(event);
370
+ return;
371
+ }
372
+
373
+ if (event.key === 'Enter' && _trimInstanceProperty__default["default"](inputValue).call(inputValue) === '' && // do not clear value when user presses Enter to
374
+ // select the end date (so only clear when there is no
375
+ // startDate)
376
+ !_this2.state.startDate && _this2.props.isClearable) {
377
+ clearSelection();
378
+
379
+ _this2.emit([]);
380
+ } // ArrowDown
381
+
382
+
383
+ if (event.keyCode === 40) {
384
+ if (highlightedIndex + 1 >= calendarItems.length) {
385
+ // if it's the end of the month
386
+ // then bypass normal arrow navigation
387
+ preventDownshiftDefault(event); // then jump to start of next month
388
+
389
+ _this2.jumpMonth(1, 0);
390
+ }
391
+ } // ArrowUp
392
+
393
+
394
+ if (event.keyCode === 38) {
395
+ var previousDay = calendarUtils.getPreviousDay(calendarItems[highlightedIndex]);
396
+
397
+ if (highlightedIndex <= 0) {
398
+ // if it's the start of the month
399
+ // then bypass normal arrow navigation
400
+ preventDownshiftDefault(event);
401
+ var numberOfDaysOfPrevMonth = calendarUtils.getDaysInMonth(previousDay); // then jump to the last day of the previous month
402
+
403
+ _this2.jumpMonth(-1, numberOfDaysOfPrevMonth - 1);
404
+ }
405
+ }
406
+ },
407
+ // we only do this for readOnly because the input
408
+ // doesn't ignore these events, unlike when its disabled
409
+ onClick: _this2.props.isReadOnly ? undefined : openMenu
410
+ }, utils.filterDataAttributes(_this2.props))),
411
+ hasSelection: _this2.props.value.length === 2,
412
+ isClearable: _this2.props.isClearable,
413
+ onClear: function onClear() {
414
+ _this2.setState({
415
+ startDate: null
416
+ });
417
+
418
+ _this2.emit([]);
419
+
420
+ clearSelection();
421
+ },
422
+ isOpen: isOpen,
423
+ isDisabled: _this2.props.isDisabled,
424
+ isReadOnly: _this2.props.isReadOnly,
425
+ toggleButtonProps: getToggleButtonProps(),
426
+ hasError: _this2.props.hasError,
427
+ hasWarning: _this2.props.hasWarning
428
+ }), isOpen && !_this2.props.isDisabled && jsxRuntime.jsxs(calendarUtils.CalendarMenu, _objectSpread(_objectSpread({}, getMenuProps()), {}, {
429
+ hasError: _this2.props.hasError,
430
+ hasWarning: _this2.props.hasWarning,
431
+ children: [jsxRuntime.jsx(calendarUtils.CalendarHeader, {
432
+ monthLabel: calendarUtils.getMonthCalendarLabel(_this2.state.calendarDate, _this2.props.intl.locale),
433
+ yearLabel: calendarUtils.getYearCalendarLabel(_this2.state.calendarDate, _this2.props.intl.locale),
434
+ onPrevMonthClick: function onPrevMonthClick() {
435
+ return _this2.jumpMonth(-1);
436
+ },
437
+ onTodayClick: _this2.showToday,
438
+ onNextMonthClick: function onNextMonthClick() {
439
+ return _this2.jumpMonth(1);
440
+ },
441
+ onPrevYearClick: function onPrevYearClick() {
442
+ return _this2.jumpMonth(-12);
443
+ },
444
+ onNextYearClick: function onNextYearClick() {
445
+ return _this2.jumpMonth(12);
446
+ }
447
+ }), jsxRuntime.jsxs(calendarUtils.CalendarContent, {
448
+ children: [_mapInstanceProperty__default["default"](weekdays).call(weekdays, function (weekday) {
449
+ return jsxRuntime.jsx(calendarUtils.CalendarDay, {
450
+ type: "heading",
451
+ children: weekday
452
+ }, weekday);
453
+ }), _mapInstanceProperty__default["default"](paddingDays).call(paddingDays, function (day, index) {
454
+ return jsxRuntime.jsx(calendarUtils.CalendarDay, {
455
+ type: "spacing"
456
+ }, index);
457
+ }), _mapInstanceProperty__default["default"](calendarItems).call(calendarItems, function (item, index) {
458
+ var isHighlighted = _this2.state.suggestedItems.length + index === highlightedIndex;
459
+
460
+ var _getRange = getRange({
461
+ item: item,
462
+ value: _this2.props.value,
463
+ startDate: _this2.state.startDate,
464
+ highlightedItem: allItems[_this2.state.highlightedIndex]
465
+ }),
466
+ isRangeStart = _getRange.isRangeStart,
467
+ isRangeBetween = _getRange.isRangeBetween,
468
+ isRangeEnd = _getRange.isRangeEnd;
469
+
470
+ return jsxRuntime.jsx(calendarUtils.CalendarDay, _objectSpread(_objectSpread({
471
+ isToday: calendarUtils.isSameDay(today, item)
472
+ }, getItemProps({
473
+ disabled: _this2.props.isDisabled,
474
+ item: item,
475
+ onMouseOut: function onMouseOut() {
476
+ setHighlightedIndex(null);
477
+ }
478
+ })), {}, {
479
+ isHighlighted: isHighlighted,
480
+ isRangeStart: isRangeStart,
481
+ isRangeBetween: isRangeBetween,
482
+ isRangeEnd: isRangeEnd,
483
+ children: calendarUtils.getCalendarDayLabel(item)
484
+ }), item);
485
+ })]
486
+ })]
487
+ }))]
488
+ });
449
489
  }
450
- }), react.jsx(calendarUtils.CalendarContent, null, _mapInstanceProperty__default['default'](weekdays).call(weekdays, function (weekday) {
451
- return react.jsx(calendarUtils.CalendarDay, {
452
- key: weekday,
453
- type: "heading"
454
- }, weekday);
455
- }), _mapInstanceProperty__default['default'](paddingDays).call(paddingDays, function (day, index) {
456
- return react.jsx(calendarUtils.CalendarDay, {
457
- key: index,
458
- type: "spacing"
459
- });
460
- }), _mapInstanceProperty__default['default'](calendarItems).call(calendarItems, function (item, index) {
461
- var isHighlighted = _this2.state.suggestedItems.length + index === highlightedIndex;
462
-
463
- var _getRange = getRange({
464
- item: item,
465
- value: _this2.props.value,
466
- startDate: _this2.state.startDate,
467
- highlightedItem: allItems[_this2.state.highlightedIndex]
468
- }),
469
- isRangeStart = _getRange.isRangeStart,
470
- isRangeBetween = _getRange.isRangeBetween,
471
- isRangeEnd = _getRange.isRangeEnd;
472
-
473
- return react.jsx(calendarUtils.CalendarDay, _extends({
474
- key: item,
475
- isToday: calendarUtils.isSameDay(today, item)
476
- }, getItemProps({
477
- disabled: _this2.props.isDisabled,
478
- item: item,
479
- onMouseOut: function onMouseOut() {
480
- setHighlightedIndex(null);
481
- }
482
- }), {
483
- isHighlighted: isHighlighted,
484
- isRangeStart: isRangeStart,
485
- isRangeBetween: isRangeBetween,
486
- isRangeEnd: isRangeEnd
487
- }), calendarUtils.getCalendarDayLabel(item));
488
- }))));
489
- }));
490
+ }, this.props.intl.locale)
491
+ });
490
492
  }
491
493
  }], [{
492
494
  key: "getDerivedStateFromProps",
@@ -507,7 +509,7 @@ var DateRangeCalendar = /*#__PURE__*/function (_React$Component) {
507
509
  }]);
508
510
 
509
511
  return DateRangeCalendar;
510
- }(React__default['default'].Component);
512
+ }(react.Component);
511
513
 
512
514
  DateRangeCalendar.displayName = 'DateRangeCalendar';
513
515
  DateRangeCalendar.defaultProps = {
@@ -519,82 +521,82 @@ DateRangeCalendar.isEmpty = function (range) {
519
521
  };
520
522
 
521
523
  DateRangeCalendar.propTypes = process.env.NODE_ENV !== "production" ? {
522
- intl: PropTypes__default['default'].shape({
523
- locale: PropTypes__default['default'].string.isRequired,
524
- formatMessage: PropTypes__default['default'].func.isRequired
524
+ intl: PropTypes__default["default"].shape({
525
+ locale: PropTypes__default["default"].string.isRequired,
526
+ formatMessage: PropTypes__default["default"].func.isRequired
525
527
  }).isRequired,
526
528
 
527
529
  /**
528
530
  * Horizontal size limit of the input field.
529
531
  */
530
- horizontalConstraint: PropTypes__default['default'].oneOf([6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
532
+ horizontalConstraint: PropTypes__default["default"].oneOf([6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
531
533
 
532
534
  /**
533
535
  * The selected date range, must either be an empty array or an array of two strings holding dates formatted as "YYYY-MM-DD".
534
536
  */
535
- value: PropTypes__default['default'].arrayOf(PropTypes__default['default'].string).isRequired,
537
+ value: PropTypes__default["default"].arrayOf(PropTypes__default["default"].string).isRequired,
536
538
 
537
539
  /**
538
540
  * Called when the date range changes. Called with an event containing either an empty array (no value) or an array holding two string in this format: "YYYY-MM-DD".
539
541
  * <br />
540
542
  * Signature: `(event) => void`
541
543
  */
542
- onChange: PropTypes__default['default'].func.isRequired,
544
+ onChange: PropTypes__default["default"].func.isRequired,
543
545
 
544
546
  /**
545
547
  * Allows the range to be cleared
546
548
  */
547
- isClearable: PropTypes__default['default'].bool,
549
+ isClearable: PropTypes__default["default"].bool,
548
550
 
549
551
  /**
550
552
  * Called when the date input gains focus.
551
553
  */
552
- onFocus: PropTypes__default['default'].func,
554
+ onFocus: PropTypes__default["default"].func,
553
555
 
554
556
  /**
555
557
  * Called when the date input loses focus.
556
558
  */
557
- onBlur: PropTypes__default['default'].func,
559
+ onBlur: PropTypes__default["default"].func,
558
560
 
559
561
  /**
560
562
  * Used as the HTML `id` attribute.
561
563
  */
562
- id: PropTypes__default['default'].string,
564
+ id: PropTypes__default["default"].string,
563
565
 
564
566
  /**
565
567
  * Used as the HTML `name` attribute.
566
568
  */
567
- name: PropTypes__default['default'].string,
569
+ name: PropTypes__default["default"].string,
568
570
 
569
571
  /**
570
572
  * Placeholder value to show in the input field
571
573
  */
572
- placeholder: PropTypes__default['default'].string,
574
+ placeholder: PropTypes__default["default"].string,
573
575
 
574
576
  /**
575
577
  * Disables the date picker
576
578
  */
577
- isDisabled: PropTypes__default['default'].bool,
579
+ isDisabled: PropTypes__default["default"].bool,
578
580
 
579
581
  /**
580
582
  * Disables the date picker menu and makes input field read-only
581
583
  */
582
- isReadOnly: PropTypes__default['default'].bool,
584
+ isReadOnly: PropTypes__default["default"].bool,
583
585
 
584
586
  /**
585
587
  * Indicates the input field has an error
586
588
  */
587
- hasError: PropTypes__default['default'].bool,
589
+ hasError: PropTypes__default["default"].bool,
588
590
 
589
591
  /**
590
592
  * Indicates the input field has warning
591
593
  */
592
- hasWarning: PropTypes__default['default'].bool
594
+ hasWarning: PropTypes__default["default"].bool
593
595
  } : {};
594
596
  var dateRangeInput = reactIntl.injectIntl(DateRangeCalendar);
595
597
 
596
- // NOTE: This string will be replaced in the `prepare` script by the `scripts/version.js` file.
597
- var version = '12.2.2';
598
+ // NOTE: This string will be replaced on build time with the package version.
599
+ var version = "12.2.6";
598
600
 
599
- exports['default'] = dateRangeInput;
601
+ exports["default"] = dateRangeInput;
600
602
  exports.version = version;