baseui 10.5.0 → 10.7.2

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.
Files changed (165) hide show
  1. package/app-nav-bar/user-menu.js +1 -0
  2. package/app-nav-bar/user-menu.js.flow +1 -0
  3. package/button/styled-components.js +1 -1
  4. package/button/styled-components.js.flow +4 -1
  5. package/card/styled-components.js +0 -1
  6. package/card/styled-components.js.flow +0 -1
  7. package/combobox/combobox.js +5 -1
  8. package/combobox/combobox.js.flow +4 -0
  9. package/combobox/index.d.ts +6 -3
  10. package/data-table/column-datetime.js +2 -0
  11. package/data-table/column-datetime.js.flow +2 -0
  12. package/datepicker/calendar-header.js +255 -109
  13. package/datepicker/calendar-header.js.flow +282 -145
  14. package/datepicker/calendar.js +6 -1
  15. package/datepicker/calendar.js.flow +5 -1
  16. package/datepicker/constants.js +9 -2
  17. package/datepicker/constants.js.flow +7 -0
  18. package/datepicker/datepicker.js +135 -73
  19. package/datepicker/datepicker.js.flow +161 -62
  20. package/datepicker/day.js +2 -0
  21. package/datepicker/day.js.flow +2 -0
  22. package/datepicker/index.d.ts +8 -0
  23. package/datepicker/month.js +4 -0
  24. package/datepicker/month.js.flow +3 -0
  25. package/datepicker/styled-components.js +116 -56
  26. package/datepicker/styled-components.js.flow +101 -36
  27. package/datepicker/types.js.flow +18 -1
  28. package/datepicker/utils/calendar-header-helpers.js +51 -0
  29. package/datepicker/utils/calendar-header-helpers.js.flow +53 -0
  30. package/datepicker/utils/date-helpers.js +1 -1
  31. package/datepicker/utils/date-helpers.js.flow +1 -1
  32. package/datepicker/week.js +1 -0
  33. package/datepicker/week.js.flow +1 -0
  34. package/dnd-list/index.js.flow +2 -1
  35. package/dnd-list/list.js +1 -2
  36. package/dnd-list/list.js.flow +1 -1
  37. package/dnd-list/styled-components.js +1 -1
  38. package/dnd-list/styled-components.js.flow +1 -0
  39. package/drawer/drawer.js +2 -1
  40. package/drawer/drawer.js.flow +1 -1
  41. package/es/app-nav-bar/user-menu.js +1 -0
  42. package/es/button/styled-components.js +1 -1
  43. package/es/card/styled-components.js +0 -1
  44. package/es/combobox/combobox.js +5 -1
  45. package/es/data-table/column-datetime.js +2 -0
  46. package/es/datepicker/calendar-header.js +204 -93
  47. package/es/datepicker/calendar.js +7 -2
  48. package/es/datepicker/constants.js +6 -1
  49. package/es/datepicker/datepicker.js +70 -42
  50. package/es/datepicker/day.js +2 -0
  51. package/es/datepicker/month.js +3 -0
  52. package/es/datepicker/styled-components.js +98 -37
  53. package/es/datepicker/types.js +1 -1
  54. package/es/datepicker/utils/calendar-header-helpers.js +34 -0
  55. package/es/datepicker/utils/date-helpers.js +1 -1
  56. package/es/datepicker/week.js +1 -0
  57. package/es/dnd-list/index.js +2 -1
  58. package/es/dnd-list/list.js +1 -2
  59. package/es/dnd-list/styled-components.js +1 -0
  60. package/es/drawer/drawer.js +2 -1
  61. package/es/helper/helper.js +1 -0
  62. package/es/layer/layer.js +8 -0
  63. package/es/menu/maybe-child-menu.js +1 -0
  64. package/es/popover/popover.js +6 -5
  65. package/es/popover/stateful-container.js +8 -2
  66. package/es/rating/emoticon-rating.js +3 -1
  67. package/es/rating/star-rating.js +3 -1
  68. package/es/select/select-component.js +5 -5
  69. package/es/select/styled-components.js +34 -4
  70. package/es/snackbar/snackbar-context.js +16 -4
  71. package/es/table-semantic/styled-components.js +6 -4
  72. package/es/table-semantic/table-builder.js +3 -0
  73. package/es/themes/dark-theme/color-component-tokens.js +1 -1
  74. package/es/themes/light-theme/color-component-tokens.js +9 -9
  75. package/es/themes/shared/lighting.js +5 -1
  76. package/es/timepicker/timepicker.js +16 -11
  77. package/es/tooltip/styled-components.js +8 -0
  78. package/es/tooltip/tooltip.js +1 -0
  79. package/esm/app-nav-bar/user-menu.js +1 -0
  80. package/esm/button/styled-components.js +1 -1
  81. package/esm/card/styled-components.js +0 -1
  82. package/esm/combobox/combobox.js +5 -1
  83. package/esm/data-table/column-datetime.js +2 -0
  84. package/esm/datepicker/calendar-header.js +255 -110
  85. package/esm/datepicker/calendar.js +7 -2
  86. package/esm/datepicker/constants.js +6 -1
  87. package/esm/datepicker/datepicker.js +136 -74
  88. package/esm/datepicker/day.js +2 -0
  89. package/esm/datepicker/month.js +3 -0
  90. package/esm/datepicker/styled-components.js +112 -55
  91. package/esm/datepicker/types.js +1 -1
  92. package/esm/datepicker/utils/calendar-header-helpers.js +45 -0
  93. package/esm/datepicker/utils/date-helpers.js +1 -1
  94. package/esm/datepicker/week.js +1 -0
  95. package/esm/dnd-list/index.js +2 -1
  96. package/esm/dnd-list/list.js +1 -2
  97. package/esm/dnd-list/styled-components.js +1 -1
  98. package/esm/drawer/drawer.js +2 -1
  99. package/esm/helper/helper.js +1 -0
  100. package/esm/layer/layer.js +8 -0
  101. package/esm/menu/maybe-child-menu.js +1 -0
  102. package/esm/popover/popover.js +6 -5
  103. package/esm/popover/stateful-container.js +8 -2
  104. package/esm/rating/emoticon-rating.js +2 -2
  105. package/esm/rating/star-rating.js +2 -2
  106. package/esm/select/select-component.js +5 -5
  107. package/esm/select/styled-components.js +28 -4
  108. package/esm/snackbar/snackbar-context.js +16 -4
  109. package/esm/table-semantic/styled-components.js +6 -4
  110. package/esm/table-semantic/table-builder.js +3 -0
  111. package/esm/themes/dark-theme/color-component-tokens.js +1 -1
  112. package/esm/themes/light-theme/color-component-tokens.js +9 -9
  113. package/esm/themes/shared/lighting.js +5 -1
  114. package/esm/timepicker/timepicker.js +17 -11
  115. package/esm/tooltip/styled-components.js +8 -0
  116. package/esm/tooltip/tooltip.js +1 -0
  117. package/helper/helper.js +1 -0
  118. package/helper/helper.js.flow +1 -0
  119. package/layer/layer.js +8 -0
  120. package/layer/layer.js.flow +9 -0
  121. package/link/index.d.ts +1 -0
  122. package/map-marker/index.d.ts +6 -5
  123. package/menu/index.d.ts +7 -0
  124. package/menu/maybe-child-menu.js +1 -0
  125. package/menu/maybe-child-menu.js.flow +1 -0
  126. package/menu/types.js.flow +12 -0
  127. package/modal/index.d.ts +1 -1
  128. package/modal/types.js.flow +4 -1
  129. package/package.json +4 -3
  130. package/popover/index.d.ts +2 -1
  131. package/popover/popover.js +6 -5
  132. package/popover/popover.js.flow +11 -4
  133. package/popover/stateful-container.js +8 -2
  134. package/popover/stateful-container.js.flow +5 -0
  135. package/popover/types.js.flow +6 -1
  136. package/rating/emoticon-rating.js +2 -2
  137. package/rating/emoticon-rating.js.flow +4 -1
  138. package/rating/star-rating.js +2 -2
  139. package/rating/star-rating.js.flow +4 -1
  140. package/select/select-component.js +5 -5
  141. package/select/select-component.js.flow +5 -5
  142. package/select/styled-components.js +28 -4
  143. package/select/styled-components.js.flow +30 -2
  144. package/snackbar/index.d.ts +21 -16
  145. package/snackbar/snackbar-context.js +15 -4
  146. package/snackbar/snackbar-context.js.flow +15 -3
  147. package/table-semantic/styled-components.js +6 -4
  148. package/table-semantic/styled-components.js.flow +6 -4
  149. package/table-semantic/table-builder.js +3 -0
  150. package/table-semantic/table-builder.js.flow +3 -0
  151. package/themes/dark-theme/color-component-tokens.js +1 -1
  152. package/themes/dark-theme/color-component-tokens.js.flow +1 -1
  153. package/themes/light-theme/color-component-tokens.js +9 -9
  154. package/themes/light-theme/color-component-tokens.js.flow +9 -9
  155. package/themes/shared/lighting.js +5 -1
  156. package/themes/shared/lighting.js.flow +4 -0
  157. package/themes/types.js.flow +4 -0
  158. package/timepicker/index.d.ts +1 -0
  159. package/timepicker/timepicker.js +17 -11
  160. package/timepicker/timepicker.js.flow +31 -12
  161. package/timepicker/types.js.flow +10 -0
  162. package/tooltip/styled-components.js +8 -0
  163. package/tooltip/styled-components.js.flow +8 -0
  164. package/tooltip/tooltip.js +1 -0
  165. package/tooltip/tooltip.js.flow +6 -1
@@ -47,18 +47,6 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
47
47
 
48
48
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
49
49
 
50
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
51
-
52
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
53
-
54
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
55
-
56
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
57
-
58
- function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
59
-
60
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
61
-
62
50
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
63
51
 
64
52
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
@@ -81,8 +69,44 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
81
69
 
82
70
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
83
71
 
72
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
73
+
74
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
75
+
76
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
77
+
78
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
79
+
80
+ function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
81
+
82
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
83
+
84
84
  var DEFAULT_DATE_FORMAT = 'yyyy/MM/dd';
85
85
  exports.DEFAULT_DATE_FORMAT = DEFAULT_DATE_FORMAT;
86
+ var INPUT_DELIMITER = ' – ';
87
+
88
+ var combineSeparatedInputs = function combineSeparatedInputs(newInputValue) {
89
+ var prevCombinedInputValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
90
+ var separatedInput = arguments.length > 2 ? arguments[2] : undefined;
91
+ var inputValue = newInputValue;
92
+
93
+ var _prevCombinedInputVal = prevCombinedInputValue.split(INPUT_DELIMITER),
94
+ _prevCombinedInputVal2 = _slicedToArray(_prevCombinedInputVal, 2),
95
+ _prevCombinedInputVal3 = _prevCombinedInputVal2[0],
96
+ prevStartDate = _prevCombinedInputVal3 === void 0 ? '' : _prevCombinedInputVal3,
97
+ _prevCombinedInputVal4 = _prevCombinedInputVal2[1],
98
+ prevEndDate = _prevCombinedInputVal4 === void 0 ? '' : _prevCombinedInputVal4;
99
+
100
+ if (separatedInput === 'startDate' && prevEndDate) {
101
+ inputValue = "".concat(inputValue, " \u2013 ").concat(prevEndDate);
102
+ }
103
+
104
+ if (separatedInput === 'endDate') {
105
+ inputValue = "".concat(prevStartDate, " \u2013 ").concat(inputValue);
106
+ }
107
+
108
+ return inputValue;
109
+ };
86
110
 
87
111
  var Datepicker = /*#__PURE__*/function (_React$Component) {
88
112
  _inherits(Datepicker, _React$Component);
@@ -215,7 +239,7 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
215
239
  isOpen: true,
216
240
  isPseudoFocused: true,
217
241
  calendarFocused: false
218
- });
242
+ }, _this.props.onOpen);
219
243
  });
220
244
 
221
245
  _defineProperty(_assertThisInitialized(_this), "close", function () {
@@ -246,9 +270,10 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
246
270
  var _this$props2 = _this.props,
247
271
  formatString = _this$props2.formatString,
248
272
  mask = _this$props2.mask,
249
- range = _this$props2.range;
273
+ range = _this$props2.range,
274
+ separateRangeInputs = _this$props2.separateRangeInputs;
250
275
 
251
- if (mask === null) {
276
+ if (mask === null || mask === undefined && formatString !== DEFAULT_DATE_FORMAT) {
252
277
  return null;
253
278
  }
254
279
 
@@ -256,28 +281,20 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
256
281
  return _this.normalizeDashes(mask);
257
282
  }
258
283
 
259
- var normalizedFormatString = _this.normalizeDashes(formatString);
260
-
261
- if (formatString) {
262
- if (range) {
263
- return "".concat(normalizedFormatString, " \u2013 ").concat(normalizedFormatString).replace(/[a-z]/gi, '9');
264
- } else {
265
- return normalizedFormatString.replace(/[a-z]/gi, '9');
266
- }
267
- }
268
-
269
- if (range) {
284
+ if (range && !separateRangeInputs) {
270
285
  return '9999/99/99 – 9999/99/99';
271
286
  }
272
287
 
273
288
  return '9999/99/99';
274
289
  });
275
290
 
276
- _defineProperty(_assertThisInitialized(_this), "handleInputChange", function (event) {
277
- var inputValue = event.currentTarget.value;
291
+ _defineProperty(_assertThisInitialized(_this), "handleInputChange", function (event, separatedInput) {
292
+ var inputValue = _this.props.range && _this.props.separateRangeInputs ? combineSeparatedInputs(event.currentTarget.value, _this.state.inputValue, separatedInput) : event.currentTarget.value;
278
293
 
279
294
  var mask = _this.getMask();
280
295
 
296
+ var formatString = _this.normalizeDashes(_this.props.formatString);
297
+
281
298
  if (typeof mask === 'string' && inputValue === mask.replace(/9/g, ' ') || inputValue.length === 0) {
282
299
  if (_this.props.onChange) {
283
300
  if (_this.props.range) {
@@ -296,8 +313,6 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
296
313
  inputValue: inputValue
297
314
  });
298
315
 
299
- var formatString = _this.normalizeDashes(_this.props.formatString);
300
-
301
316
  var parseDateString = function parseDateString(dateString) {
302
317
  if (formatString === DEFAULT_DATE_FORMAT) {
303
318
  return _this.dateHelpers.parse(dateString, 'slashDate', _this.props.locale);
@@ -307,7 +322,7 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
307
322
  };
308
323
 
309
324
  if (_this.props.range && typeof _this.props.displayValueAtRangeIndex !== 'number') {
310
- var _this$normalizeDashes = _this.normalizeDashes(inputValue).split(' – '),
325
+ var _this$normalizeDashes = _this.normalizeDashes(inputValue).split(INPUT_DELIMITER),
311
326
  _this$normalizeDashes2 = _slicedToArray(_this$normalizeDashes, 2),
312
327
  left = _this$normalizeDashes2[0],
313
328
  right = _this$normalizeDashes2[1];
@@ -473,7 +488,7 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
473
488
  } else if (Array.isArray(date)) {
474
489
  return date.map(function (day) {
475
490
  return format(day);
476
- }).join(' – ');
491
+ }).join(INPUT_DELIMITER);
477
492
  } else {
478
493
  return format(date);
479
494
  }
@@ -488,8 +503,8 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
488
503
  }
489
504
  }
490
505
  }, {
491
- key: "render",
492
- value: function render() {
506
+ key: "renderInputComponent",
507
+ value: function renderInputComponent(locale, separatedInput) {
493
508
  var _this3 = this;
494
509
 
495
510
  var _this$props$overrides = this.props.overrides,
@@ -500,6 +515,55 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
500
515
  InputComponent = _getOverrides2[0],
501
516
  inputProps = _getOverrides2[1];
502
517
 
518
+ var placeholder = this.props.placeholder || this.props.placeholder === '' ? this.props.placeholder : this.props.range && !this.props.separateRangeInputs ? 'YYYY/MM/DD – YYYY/MM/DD' : 'YYYY/MM/DD';
519
+
520
+ var _split = (this.state.inputValue || '').split(INPUT_DELIMITER),
521
+ _split2 = _slicedToArray(_split, 2),
522
+ _split2$ = _split2[0],
523
+ startDate = _split2$ === void 0 ? '' : _split2$,
524
+ _split2$2 = _split2[1],
525
+ endDate = _split2$2 === void 0 ? '' : _split2$2;
526
+
527
+ var value = separatedInput === 'startDate' ? startDate : separatedInput === 'endDate' ? endDate : this.state.inputValue;
528
+
529
+ var onChange = function onChange(event) {
530
+ return _this3.handleInputChange(event, separatedInput);
531
+ };
532
+
533
+ return /*#__PURE__*/React.createElement(InputComponent, _extends({
534
+ "aria-disabled": this.props.disabled,
535
+ "aria-label": this.props['aria-label'] || (this.props.range ? locale.datepicker.ariaLabelRange : locale.datepicker.ariaLabel),
536
+ error: this.props.error,
537
+ positive: this.props.positive,
538
+ "aria-describedby": this.props['aria-describedby'],
539
+ "aria-labelledby": this.props['aria-labelledby'],
540
+ "aria-required": this.props.required || null,
541
+ disabled: this.props.disabled,
542
+ size: this.props.size,
543
+ value: value,
544
+ onFocus: this.open,
545
+ onBlur: this.handleInputBlur,
546
+ onKeyDown: this.handleKeyDown,
547
+ onChange: onChange,
548
+ placeholder: placeholder,
549
+ mask: this.getMask(),
550
+ required: this.props.required,
551
+ clearable: this.props.clearable
552
+ }, inputProps));
553
+ }
554
+ }, {
555
+ key: "render",
556
+ value: function render() {
557
+ var _this4 = this;
558
+
559
+ var _this$props4 = this.props,
560
+ _this$props4$override = _this$props4.overrides,
561
+ overrides = _this$props4$override === void 0 ? {} : _this$props4$override,
562
+ _this$props4$startDat = _this$props4.startDateLabel,
563
+ startDateLabel = _this$props4$startDat === void 0 ? 'Start Date' : _this$props4$startDat,
564
+ _this$props4$endDateL = _this$props4.endDateLabel,
565
+ endDateLabel = _this$props4$endDateL === void 0 ? 'End Date' : _this$props4$endDateL;
566
+
503
567
  var _getOverrides3 = (0, _overrides.getOverrides)(overrides.Popover, _index2.Popover),
504
568
  _getOverrides4 = _slicedToArray(_getOverrides3, 2),
505
569
  PopoverComponent = _getOverrides4[0],
@@ -510,44 +574,42 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
510
574
  InputWrapper = _getOverrides6[0],
511
575
  inputWrapperProps = _getOverrides6[1];
512
576
 
513
- var placeholder = this.props.placeholder || this.props.placeholder === '' ? this.props.placeholder : this.props.range ? 'YYYY/MM/DD – YYYY/MM/DD' : 'YYYY/MM/DD';
577
+ var _getOverrides7 = (0, _overrides.getOverrides)(overrides.StartDate, _styledComponents.StyledStartDate),
578
+ _getOverrides8 = _slicedToArray(_getOverrides7, 2),
579
+ StartDate = _getOverrides8[0],
580
+ startDateProps = _getOverrides8[1];
581
+
582
+ var _getOverrides9 = (0, _overrides.getOverrides)(overrides.EndDate, _styledComponents.StyledEndDate),
583
+ _getOverrides10 = _slicedToArray(_getOverrides9, 2),
584
+ EndDate = _getOverrides10[0],
585
+ endDateProps = _getOverrides10[1];
586
+
587
+ var _getOverrides11 = (0, _overrides.getOverrides)(overrides.InputLabel, _styledComponents.StyledInputLabel),
588
+ _getOverrides12 = _slicedToArray(_getOverrides11, 2),
589
+ InputLabel = _getOverrides12[0],
590
+ inputLabelProps = _getOverrides12[1];
591
+
514
592
  return /*#__PURE__*/React.createElement(_index3.LocaleContext.Consumer, null, function (locale) {
515
593
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(PopoverComponent, _extends({
516
594
  focusLock: false,
517
- mountNode: _this3.props.mountNode,
595
+ autoFocus: false,
596
+ mountNode: _this4.props.mountNode,
518
597
  placement: _index2.PLACEMENT.bottom,
519
- isOpen: _this3.state.isOpen,
520
- onClickOutside: _this3.close,
521
- onEsc: _this3.handleEsc,
598
+ isOpen: _this4.state.isOpen,
599
+ onClickOutside: _this4.close,
600
+ onEsc: _this4.handleEsc,
522
601
  content: /*#__PURE__*/React.createElement(_calendar.default, _extends({
523
- adapter: _this3.props.adapter,
524
- autoFocusCalendar: _this3.state.calendarFocused,
602
+ adapter: _this4.props.adapter,
603
+ autoFocusCalendar: _this4.state.calendarFocused,
525
604
  trapTabbing: true,
526
- value: _this3.props.value
527
- }, _this3.props, {
528
- onChange: _this3.onChange
605
+ value: _this4.props.value
606
+ }, _this4.props, {
607
+ onChange: _this4.onChange
529
608
  }))
530
- }, popoverProps), /*#__PURE__*/React.createElement(InputWrapper, inputWrapperProps, /*#__PURE__*/React.createElement(InputComponent, _extends({
531
- "aria-disabled": _this3.props.disabled,
532
- "aria-label": _this3.props['aria-label'] || (_this3.props.range ? locale.datepicker.ariaLabelRange : locale.datepicker.ariaLabel),
533
- error: _this3.props.error,
534
- positive: _this3.props.positive,
535
- "aria-describedby": _this3.props['aria-describedby'],
536
- "aria-labelledby": _this3.props['aria-labelledby'],
537
- "aria-required": _this3.props.required || null,
538
- disabled: _this3.props.disabled,
539
- size: _this3.props.size,
540
- value: _this3.state.inputValue,
541
- onFocus: _this3.open,
542
- onBlur: _this3.handleInputBlur,
543
- onKeyDown: _this3.handleKeyDown,
544
- onChange: _this3.handleInputChange,
545
- placeholder: placeholder,
546
- mask: _this3.getMask(),
547
- required: _this3.props.required,
548
- clearable: _this3.props.clearable
549
- }, inputProps)))), /*#__PURE__*/React.createElement("p", {
550
- id: _this3.props['aria-describedby'],
609
+ }, popoverProps), /*#__PURE__*/React.createElement(InputWrapper, _extends({}, inputWrapperProps, {
610
+ $separateRangeInputs: _this4.props.range && _this4.props.separateRangeInputs
611
+ }), _this4.props.range && _this4.props.separateRangeInputs ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(StartDate, startDateProps, /*#__PURE__*/React.createElement(InputLabel, inputLabelProps, startDateLabel), _this4.renderInputComponent(locale, 'startDate')), /*#__PURE__*/React.createElement(EndDate, endDateProps, /*#__PURE__*/React.createElement(InputLabel, inputLabelProps, endDateLabel), _this4.renderInputComponent(locale, 'endDate'))) : /*#__PURE__*/React.createElement(React.Fragment, null, _this4.renderInputComponent(locale)))), /*#__PURE__*/React.createElement("p", {
612
+ id: _this4.props['aria-describedby'],
551
613
  style: {
552
614
  position: 'fixed',
553
615
  width: '0px',
@@ -577,17 +639,17 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
577
639
  clipPath: 'inset(100%)'
578
640
  }
579
641
  }, // No date selected
580
- !_this3.props.value || Array.isArray(_this3.props.value) && !_this3.props.value.length ? '' : // Date selected in a non-range picker
581
- !Array.isArray(_this3.props.value) ? (0, _i18nInterpolation.default)(locale.datepicker.selectedDate, {
582
- date: _this3.state.inputValue || ''
642
+ !_this4.props.value || Array.isArray(_this4.props.value) && !_this4.props.value.length ? '' : // Date selected in a non-range picker
643
+ !Array.isArray(_this4.props.value) ? (0, _i18nInterpolation.default)(locale.datepicker.selectedDate, {
644
+ date: _this4.state.inputValue || ''
583
645
  }) : // Start and end dates are selected in a range picker
584
- _this3.props.value.length > 1 ? (0, _i18nInterpolation.default)(locale.datepicker.selectedDateRange, {
585
- startDate: _this3.formatDisplayValue(_this3.props.value[0]),
586
- endDate: _this3.formatDisplayValue( // $FlowFixMe
587
- _this3.props.value[1])
646
+ _this4.props.value.length > 1 ? (0, _i18nInterpolation.default)(locale.datepicker.selectedDateRange, {
647
+ startDate: _this4.formatDisplayValue(_this4.props.value[0]),
648
+ endDate: _this4.formatDisplayValue( // $FlowFixMe
649
+ _this4.props.value[1])
588
650
  }) : // A single date selected in a range picker
589
651
  "".concat((0, _i18nInterpolation.default)(locale.datepicker.selectedDate, {
590
- date: _this3.formatDisplayValue(_this3.props.value[0])
652
+ date: _this4.formatDisplayValue(_this4.props.value[0])
591
653
  }), " ").concat(locale.datepicker.selectSecondDatePrompt)));
592
654
  });
593
655
  }
@@ -13,10 +13,38 @@ import Calendar from './calendar.js';
13
13
  import {getOverrides} from '../helpers/overrides.js';
14
14
  import getInterpolatedString from '../helpers/i18n-interpolation.js';
15
15
  import {LocaleContext} from '../locale/index.js';
16
- import {StyledInputWrapper} from './styled-components.js';
16
+ import {
17
+ StyledInputWrapper,
18
+ StyledInputLabel,
19
+ StyledStartDate,
20
+ StyledEndDate,
21
+ } from './styled-components.js';
17
22
  import type {DatepickerPropsT} from './types.js';
18
23
  import DateHelpers from './utils/date-helpers.js';
19
24
  import dateFnsAdapter from './utils/date-fns-adapter.js';
25
+ import type {LocaleT} from '../locale/types.js';
26
+
27
+ export const DEFAULT_DATE_FORMAT = 'yyyy/MM/dd';
28
+
29
+ const INPUT_DELIMITER = ' – ';
30
+
31
+ const combineSeparatedInputs = (
32
+ newInputValue,
33
+ prevCombinedInputValue = '',
34
+ separatedInput,
35
+ ) => {
36
+ let inputValue = newInputValue;
37
+ const [prevStartDate = '', prevEndDate = ''] = prevCombinedInputValue.split(
38
+ INPUT_DELIMITER,
39
+ );
40
+ if (separatedInput === 'startDate' && prevEndDate) {
41
+ inputValue = `${inputValue} – ${prevEndDate}`;
42
+ }
43
+ if (separatedInput === 'endDate') {
44
+ inputValue = `${prevStartDate} – ${inputValue}`;
45
+ }
46
+ return inputValue;
47
+ };
20
48
 
21
49
  type StateT = {|
22
50
  calendarFocused: boolean,
@@ -25,7 +53,6 @@ type StateT = {|
25
53
  lastActiveElm: ?HTMLElement,
26
54
  inputValue?: string,
27
55
  |};
28
- export const DEFAULT_DATE_FORMAT = 'yyyy/MM/dd';
29
56
 
30
57
  export default class Datepicker<T = Date> extends React.Component<
31
58
  DatepickerPropsT<T>,
@@ -128,7 +155,7 @@ export default class Datepicker<T = Date> extends React.Component<
128
155
  } else if (Array.isArray(date) && !date[0] && !date[1]) {
129
156
  return '';
130
157
  } else if (Array.isArray(date)) {
131
- return date.map(day => format(day)).join(' – ');
158
+ return date.map(day => format(day)).join(INPUT_DELIMITER);
132
159
  } else {
133
160
  return format(date);
134
161
  }
@@ -164,11 +191,14 @@ export default class Datepicker<T = Date> extends React.Component<
164
191
  };
165
192
 
166
193
  open = () => {
167
- this.setState({
168
- isOpen: true,
169
- isPseudoFocused: true,
170
- calendarFocused: false,
171
- });
194
+ this.setState(
195
+ {
196
+ isOpen: true,
197
+ isPseudoFocused: true,
198
+ calendarFocused: false,
199
+ },
200
+ this.props.onOpen,
201
+ );
172
202
  };
173
203
 
174
204
  close = () => {
@@ -197,9 +227,12 @@ export default class Datepicker<T = Date> extends React.Component<
197
227
  };
198
228
 
199
229
  getMask = () => {
200
- const {formatString, mask, range} = this.props;
230
+ const {formatString, mask, range, separateRangeInputs} = this.props;
201
231
 
202
- if (mask === null) {
232
+ if (
233
+ mask === null ||
234
+ (mask === undefined && formatString !== DEFAULT_DATE_FORMAT)
235
+ ) {
203
236
  return null;
204
237
  }
205
238
 
@@ -207,28 +240,28 @@ export default class Datepicker<T = Date> extends React.Component<
207
240
  return this.normalizeDashes(mask);
208
241
  }
209
242
 
210
- const normalizedFormatString = this.normalizeDashes(formatString);
211
- if (formatString) {
212
- if (range) {
213
- return `${normalizedFormatString} – ${normalizedFormatString}`.replace(
214
- /[a-z]/gi,
215
- '9',
216
- );
217
- } else {
218
- return normalizedFormatString.replace(/[a-z]/gi, '9');
219
- }
220
- }
221
-
222
- if (range) {
243
+ if (range && !separateRangeInputs) {
223
244
  return '9999/99/99 – 9999/99/99';
224
245
  }
225
246
 
226
247
  return '9999/99/99';
227
248
  };
228
249
 
229
- handleInputChange = (event: SyntheticInputEvent<HTMLInputElement>) => {
230
- const inputValue = event.currentTarget.value;
250
+ handleInputChange = (
251
+ event: SyntheticInputEvent<HTMLInputElement>,
252
+ separatedInput?: 'startDate' | 'endDate',
253
+ ) => {
254
+ const inputValue =
255
+ this.props.range && this.props.separateRangeInputs
256
+ ? combineSeparatedInputs(
257
+ event.currentTarget.value,
258
+ this.state.inputValue,
259
+ separatedInput,
260
+ )
261
+ : event.currentTarget.value;
262
+
231
263
  const mask = this.getMask();
264
+ const formatString = this.normalizeDashes(this.props.formatString);
232
265
 
233
266
  if (
234
267
  (typeof mask === 'string' && inputValue === mask.replace(/9/g, ' ')) ||
@@ -245,7 +278,6 @@ export default class Datepicker<T = Date> extends React.Component<
245
278
 
246
279
  this.setState({inputValue});
247
280
 
248
- const formatString = this.normalizeDashes(this.props.formatString);
249
281
  const parseDateString = dateString => {
250
282
  if (formatString === DEFAULT_DATE_FORMAT) {
251
283
  return this.dateHelpers.parse(
@@ -265,7 +297,9 @@ export default class Datepicker<T = Date> extends React.Component<
265
297
  this.props.range &&
266
298
  typeof this.props.displayValueAtRangeIndex !== 'number'
267
299
  ) {
268
- const [left, right] = this.normalizeDashes(inputValue).split(' – ');
300
+ const [left, right] = this.normalizeDashes(inputValue).split(
301
+ INPUT_DELIMITER,
302
+ );
269
303
 
270
304
  let startDate = this.dateHelpers.date(left);
271
305
  let endDate = this.dateHelpers.date(right);
@@ -391,12 +425,73 @@ export default class Datepicker<T = Date> extends React.Component<
391
425
  }
392
426
  }
393
427
 
394
- render() {
428
+ renderInputComponent(
429
+ locale: LocaleT,
430
+ separatedInput?: 'startDate' | 'endDate',
431
+ ) {
395
432
  const {overrides = {}} = this.props;
433
+
396
434
  const [InputComponent, inputProps] = getOverrides(
397
435
  overrides.Input,
398
436
  MaskedInput,
399
437
  );
438
+
439
+ const placeholder =
440
+ this.props.placeholder || this.props.placeholder === ''
441
+ ? this.props.placeholder
442
+ : this.props.range && !this.props.separateRangeInputs
443
+ ? 'YYYY/MM/DD – YYYY/MM/DD'
444
+ : 'YYYY/MM/DD';
445
+
446
+ const [startDate = '', endDate = ''] = (this.state.inputValue || '').split(
447
+ INPUT_DELIMITER,
448
+ );
449
+
450
+ const value =
451
+ separatedInput === 'startDate'
452
+ ? startDate
453
+ : separatedInput === 'endDate'
454
+ ? endDate
455
+ : this.state.inputValue;
456
+
457
+ const onChange = event => this.handleInputChange(event, separatedInput);
458
+
459
+ return (
460
+ <InputComponent
461
+ aria-disabled={this.props.disabled}
462
+ aria-label={
463
+ this.props['aria-label'] ||
464
+ (this.props.range
465
+ ? locale.datepicker.ariaLabelRange
466
+ : locale.datepicker.ariaLabel)
467
+ }
468
+ error={this.props.error}
469
+ positive={this.props.positive}
470
+ aria-describedby={this.props['aria-describedby']}
471
+ aria-labelledby={this.props['aria-labelledby']}
472
+ aria-required={this.props.required || null}
473
+ disabled={this.props.disabled}
474
+ size={this.props.size}
475
+ value={value}
476
+ onFocus={this.open}
477
+ onBlur={this.handleInputBlur}
478
+ onKeyDown={this.handleKeyDown}
479
+ onChange={onChange}
480
+ placeholder={placeholder}
481
+ mask={this.getMask()}
482
+ required={this.props.required}
483
+ clearable={this.props.clearable}
484
+ {...inputProps}
485
+ />
486
+ );
487
+ }
488
+
489
+ render() {
490
+ const {
491
+ overrides = {},
492
+ startDateLabel = 'Start Date',
493
+ endDateLabel = 'End Date',
494
+ } = this.props;
400
495
  const [PopoverComponent, popoverProps] = getOverrides(
401
496
  overrides.Popover,
402
497
  Popover,
@@ -405,13 +500,18 @@ export default class Datepicker<T = Date> extends React.Component<
405
500
  overrides.InputWrapper,
406
501
  StyledInputWrapper,
407
502
  );
408
-
409
- const placeholder =
410
- this.props.placeholder || this.props.placeholder === ''
411
- ? this.props.placeholder
412
- : this.props.range
413
- ? 'YYYY/MM/DD – YYYY/MM/DD'
414
- : 'YYYY/MM/DD';
503
+ const [StartDate, startDateProps] = getOverrides(
504
+ overrides.StartDate,
505
+ StyledStartDate,
506
+ );
507
+ const [EndDate, endDateProps] = getOverrides(
508
+ overrides.EndDate,
509
+ StyledEndDate,
510
+ );
511
+ const [InputLabel, inputLabelProps] = getOverrides(
512
+ overrides.InputLabel,
513
+ StyledInputLabel,
514
+ );
415
515
 
416
516
  return (
417
517
  <LocaleContext.Consumer>
@@ -419,6 +519,7 @@ export default class Datepicker<T = Date> extends React.Component<
419
519
  <React.Fragment>
420
520
  <PopoverComponent
421
521
  focusLock={false}
522
+ autoFocus={false}
422
523
  mountNode={this.props.mountNode}
423
524
  placement={PLACEMENT.bottom}
424
525
  isOpen={this.state.isOpen}
@@ -436,33 +537,31 @@ export default class Datepicker<T = Date> extends React.Component<
436
537
  }
437
538
  {...popoverProps}
438
539
  >
439
- <InputWrapper {...inputWrapperProps}>
440
- <InputComponent
441
- aria-disabled={this.props.disabled}
442
- aria-label={
443
- this.props['aria-label'] ||
444
- (this.props.range
445
- ? locale.datepicker.ariaLabelRange
446
- : locale.datepicker.ariaLabel)
447
- }
448
- error={this.props.error}
449
- positive={this.props.positive}
450
- aria-describedby={this.props['aria-describedby']}
451
- aria-labelledby={this.props['aria-labelledby']}
452
- aria-required={this.props.required || null}
453
- disabled={this.props.disabled}
454
- size={this.props.size}
455
- value={this.state.inputValue}
456
- onFocus={this.open}
457
- onBlur={this.handleInputBlur}
458
- onKeyDown={this.handleKeyDown}
459
- onChange={this.handleInputChange}
460
- placeholder={placeholder}
461
- mask={this.getMask()}
462
- required={this.props.required}
463
- clearable={this.props.clearable}
464
- {...inputProps}
465
- />
540
+ {}
541
+ <InputWrapper
542
+ {...inputWrapperProps}
543
+ $separateRangeInputs={
544
+ this.props.range && this.props.separateRangeInputs
545
+ }
546
+ >
547
+ {this.props.range && this.props.separateRangeInputs ? (
548
+ <>
549
+ <StartDate {...startDateProps}>
550
+ <InputLabel {...inputLabelProps}>
551
+ {startDateLabel}
552
+ </InputLabel>
553
+ {this.renderInputComponent(locale, 'startDate')}
554
+ </StartDate>
555
+ <EndDate {...endDateProps}>
556
+ <InputLabel {...inputLabelProps}>
557
+ {endDateLabel}
558
+ </InputLabel>
559
+ {this.renderInputComponent(locale, 'endDate')}
560
+ </EndDate>
561
+ </>
562
+ ) : (
563
+ <>{this.renderInputComponent(locale)}</>
564
+ )}
466
565
  </InputWrapper>
467
566
  </PopoverComponent>
468
567
  <p
package/datepicker/day.js CHANGED
@@ -345,6 +345,7 @@ var Day = /*#__PURE__*/function (_React$Component) {
345
345
  var $outsideMonthWithinRange = !!(Array.isArray(value) && range && $outsideMonth && !this.props.peekNextMonth && this.isOutsideOfMonthButWithinRange());
346
346
  return {
347
347
  $date: date,
348
+ $density: this.props.density,
348
349
  $disabled: this.props.disabled,
349
350
  $endDate: Array.isArray(value) && this.props.range && $selected && this.dateHelpers.isSameDay(date, value[1]) || false,
350
351
  $hasDateLabel: !!this.props.dateLabel,
@@ -357,6 +358,7 @@ var Day = /*#__PURE__*/function (_React$Component) {
357
358
  $isFocusVisible: this.state.isFocusVisible,
358
359
  $startOfMonth: this.dateHelpers.isStartOfMonth(date),
359
360
  $endOfMonth: this.dateHelpers.isEndOfMonth(date),
361
+ $month: this.getMonthProp(),
360
362
  $outsideMonth: $outsideMonth,
361
363
  $outsideMonthWithinRange: $outsideMonthWithinRange,
362
364
  $peekNextMonth: this.props.peekNextMonth,
@@ -291,6 +291,7 @@ export default class Day<T = Date> extends React.Component<
291
291
  );
292
292
  return {
293
293
  $date: date,
294
+ $density: this.props.density,
294
295
  $disabled: this.props.disabled,
295
296
  $endDate:
296
297
  (Array.isArray(value) &&
@@ -313,6 +314,7 @@ export default class Day<T = Date> extends React.Component<
313
314
  $isFocusVisible: this.state.isFocusVisible,
314
315
  $startOfMonth: this.dateHelpers.isStartOfMonth(date),
315
316
  $endOfMonth: this.dateHelpers.isEndOfMonth(date),
317
+ $month: this.getMonthProp(),
316
318
  $outsideMonth,
317
319
  $outsideMonthWithinRange,
318
320
  $peekNextMonth: this.props.peekNextMonth,