baseui 0.0.0-alpha-3a96a5e → 0.0.0-alpha-bcb33da

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 (146) hide show
  1. package/a11y/a11y.js +2 -2
  2. package/a11y/a11y.js.flow +3 -3
  3. package/button/styled-components.js +47 -18
  4. package/button/styled-components.js.flow +25 -5
  5. package/data-table/column-categorical.js +1 -1
  6. package/data-table/column-categorical.js.flow +2 -2
  7. package/data-table/column-datetime.js +1 -1
  8. package/data-table/column-datetime.js.flow +1 -1
  9. package/data-table/column-numerical.js +1 -1
  10. package/data-table/column-numerical.js.flow +3 -3
  11. package/datepicker/calendar.js +6 -12
  12. package/datepicker/calendar.js.flow +12 -23
  13. package/datepicker/datepicker.js +5 -16
  14. package/datepicker/datepicker.js.flow +10 -25
  15. package/datepicker/day.js +30 -58
  16. package/datepicker/day.js.flow +51 -103
  17. package/datepicker/stateful-container.js.flow +1 -2
  18. package/datepicker/types.js.flow +9 -11
  19. package/drawer/drawer.js +3 -1
  20. package/drawer/drawer.js.flow +7 -1
  21. package/es/a11y/a11y.js +2 -2
  22. package/es/button/styled-components.js +32 -2
  23. package/es/data-table/column-categorical.js +2 -2
  24. package/es/data-table/column-datetime.js +1 -1
  25. package/es/data-table/column-numerical.js +2 -2
  26. package/es/datepicker/calendar.js +6 -12
  27. package/es/datepicker/datepicker.js +5 -15
  28. package/es/datepicker/day.js +30 -51
  29. package/es/drawer/drawer.js +3 -1
  30. package/es/form-control/form-control.js +58 -7
  31. package/es/form-control/styled-components.js +27 -6
  32. package/es/index.js +1 -1
  33. package/es/map-marker/badge-enhancer.js +61 -0
  34. package/es/map-marker/constants.js +146 -2
  35. package/es/map-marker/drag-shadow.js +32 -0
  36. package/es/map-marker/fixed-marker.js +54 -48
  37. package/es/map-marker/floating-marker.js +21 -12
  38. package/es/map-marker/index.js +1 -1
  39. package/es/map-marker/label-enhancer.js +39 -0
  40. package/es/map-marker/needle.js +26 -0
  41. package/es/map-marker/pin-head.js +42 -40
  42. package/es/map-marker/styled-components.js +177 -32
  43. package/es/map-marker/types.js +1 -1
  44. package/es/modal/modal.js +3 -1
  45. package/es/popover/popover.js +4 -2
  46. package/es/progress-bar/index.js +1 -1
  47. package/es/progress-bar/progressbar.js +15 -7
  48. package/es/progress-bar/styled-components.js +9 -5
  49. package/es/table/filter.js +3 -1
  50. package/es/themes/dark-theme/color-component-tokens.js +4 -0
  51. package/es/themes/light-theme/color-component-tokens.js +4 -0
  52. package/es/timezonepicker/timezone-picker.js +53 -36
  53. package/es/timezonepicker/tzdata.js +2 -0
  54. package/es/timezonepicker/update-tzdata.js +69 -0
  55. package/esm/a11y/a11y.js +3 -3
  56. package/esm/button/styled-components.js +47 -18
  57. package/esm/data-table/column-categorical.js +2 -2
  58. package/esm/data-table/column-datetime.js +1 -1
  59. package/esm/data-table/column-numerical.js +2 -2
  60. package/esm/datepicker/calendar.js +6 -12
  61. package/esm/datepicker/datepicker.js +5 -16
  62. package/esm/datepicker/day.js +30 -58
  63. package/esm/drawer/drawer.js +3 -1
  64. package/esm/form-control/form-control.js +60 -9
  65. package/esm/form-control/styled-components.js +23 -3
  66. package/esm/index.js +1 -1
  67. package/esm/map-marker/badge-enhancer.js +79 -0
  68. package/esm/map-marker/constants.js +94 -4
  69. package/esm/map-marker/drag-shadow.js +53 -0
  70. package/esm/map-marker/fixed-marker.js +84 -80
  71. package/esm/map-marker/floating-marker.js +22 -13
  72. package/esm/map-marker/index.js +1 -1
  73. package/esm/map-marker/label-enhancer.js +60 -0
  74. package/esm/map-marker/needle.js +43 -0
  75. package/esm/map-marker/pin-head.js +77 -66
  76. package/esm/map-marker/styled-components.js +182 -51
  77. package/esm/map-marker/types.js +1 -1
  78. package/esm/modal/modal.js +3 -1
  79. package/esm/popover/popover.js +4 -2
  80. package/esm/progress-bar/index.js +1 -1
  81. package/esm/progress-bar/progressbar.js +17 -8
  82. package/esm/progress-bar/styled-components.js +9 -4
  83. package/esm/table/filter.js +3 -1
  84. package/esm/themes/dark-theme/color-component-tokens.js +4 -0
  85. package/esm/themes/light-theme/color-component-tokens.js +4 -0
  86. package/esm/timezonepicker/timezone-picker.js +64 -36
  87. package/esm/timezonepicker/tzdata.js +2 -0
  88. package/esm/timezonepicker/update-tzdata.js +160 -0
  89. package/form-control/form-control.js +61 -8
  90. package/form-control/form-control.js.flow +82 -10
  91. package/form-control/index.d.ts +1 -0
  92. package/form-control/styled-components.js +27 -5
  93. package/form-control/styled-components.js.flow +25 -3
  94. package/form-control/types.js.flow +20 -8
  95. package/index.js +6 -0
  96. package/index.js.flow +1 -1
  97. package/map-marker/badge-enhancer.js +90 -0
  98. package/map-marker/badge-enhancer.js.flow +86 -0
  99. package/map-marker/constants.js +103 -5
  100. package/map-marker/constants.js.flow +152 -0
  101. package/map-marker/drag-shadow.js +64 -0
  102. package/map-marker/drag-shadow.js.flow +52 -0
  103. package/map-marker/fixed-marker.js +84 -78
  104. package/map-marker/fixed-marker.js.flow +78 -66
  105. package/map-marker/floating-marker.js +22 -13
  106. package/map-marker/floating-marker.js.flow +30 -17
  107. package/map-marker/index.d.ts +125 -24
  108. package/map-marker/index.js +18 -0
  109. package/map-marker/index.js.flow +3 -0
  110. package/map-marker/label-enhancer.js +71 -0
  111. package/map-marker/label-enhancer.js.flow +63 -0
  112. package/map-marker/needle.js +54 -0
  113. package/map-marker/needle.js.flow +29 -0
  114. package/map-marker/pin-head.js +80 -69
  115. package/map-marker/pin-head.js.flow +122 -84
  116. package/map-marker/styled-components.js +200 -62
  117. package/map-marker/styled-components.js.flow +172 -22
  118. package/map-marker/types.js.flow +69 -20
  119. package/modal/modal.js +3 -1
  120. package/modal/modal.js.flow +2 -0
  121. package/package.json +4 -4
  122. package/popover/popover.js +4 -2
  123. package/popover/popover.js.flow +3 -1
  124. package/progress-bar/index.d.ts +2 -0
  125. package/progress-bar/index.js +6 -0
  126. package/progress-bar/index.js.flow +1 -0
  127. package/progress-bar/progressbar.js +17 -8
  128. package/progress-bar/progressbar.js.flow +19 -7
  129. package/progress-bar/styled-components.js +9 -4
  130. package/progress-bar/styled-components.js.flow +15 -4
  131. package/progress-bar/types.js.flow +12 -2
  132. package/styles/index.js.flow +1 -1
  133. package/table/filter.js +3 -1
  134. package/table/filter.js.flow +5 -1
  135. package/themes/dark-theme/color-component-tokens.js +4 -0
  136. package/themes/dark-theme/color-component-tokens.js.flow +4 -0
  137. package/themes/light-theme/color-component-tokens.js +4 -0
  138. package/themes/light-theme/color-component-tokens.js.flow +4 -0
  139. package/themes/types.js.flow +4 -0
  140. package/timezonepicker/timezone-picker.js +69 -41
  141. package/timezonepicker/timezone-picker.js.flow +52 -46
  142. package/timezonepicker/types.js.flow +1 -1
  143. package/timezonepicker/tzdata.js +10 -0
  144. package/timezonepicker/tzdata.js.flow +347 -0
  145. package/timezonepicker/update-tzdata.js +164 -0
  146. package/timezonepicker/update-tzdata.js.flow +70 -0
package/a11y/a11y.js CHANGED
@@ -140,8 +140,8 @@ function Violation(props) {
140
140
  ref: setPopper,
141
141
  $top: "".concat(offset.top, "px") || '0px',
142
142
  $left: "".concat(offset.left, "px") || '0px'
143
- }, /*#__PURE__*/React.createElement(_index2.Caption1, null, props.target), props.violations.map(function (violation, index) {
144
- return /*#__PURE__*/React.createElement(_index2.Paragraph3, {
143
+ }, /*#__PURE__*/React.createElement(_index2.ParagraphXSmall, null, props.target), props.violations.map(function (violation, index) {
144
+ return /*#__PURE__*/React.createElement(_index2.ParagraphSmall, {
145
145
  key: index
146
146
  }, violation.description);
147
147
  }))));
package/a11y/a11y.js.flow CHANGED
@@ -11,7 +11,7 @@ import * as React from 'react';
11
11
  import axe from 'axe-core';
12
12
 
13
13
  import {Layer, TetherBehavior, TETHER_PLACEMENT} from '../layer/index.js';
14
- import {Paragraph3, Caption1} from '../typography/index.js';
14
+ import {ParagraphSmall, ParagraphXSmall} from '../typography/index.js';
15
15
  import {styled} from '../styles/index.js';
16
16
  import {ThemeContext} from '../styles/theme-provider.js';
17
17
 
@@ -101,9 +101,9 @@ function Violation(props: ViolationPropsT) {
101
101
  $top={`${offset.top}px` || '0px'}
102
102
  $left={`${offset.left}px` || '0px'}
103
103
  >
104
- <Caption1>{props.target}</Caption1>
104
+ <ParagraphXSmall>{props.target}</ParagraphXSmall>
105
105
  {props.violations.map((violation, index) => (
106
- <Paragraph3 key={index}>{violation.description}</Paragraph3>
106
+ <ParagraphSmall key={index}>{violation.description}</ParagraphSmall>
107
107
  ))}
108
108
  </ViolationContainer>
109
109
  </TetherBehavior>
@@ -46,11 +46,14 @@ var BaseButton = (0, _index.styled)('button', function (_ref) {
46
46
  transitionDuration: $theme.animation.timing200,
47
47
  transitionTimingFunction: $theme.animation.linearCurve,
48
48
  cursor: 'pointer',
49
- ':disabled': {
50
- cursor: 'not-allowed',
51
- backgroundColor: $kind === _constants.KIND.minimal || $kind === _constants.KIND.tertiary ? 'transparent' : $theme.colors.buttonDisabledFill,
52
- color: $theme.colors.buttonDisabledText
53
- },
49
+ ':disabled': _objectSpread({
50
+ cursor: 'not-allowed'
51
+ }, getDisabledStyles({
52
+ $theme: $theme,
53
+ $kind: $kind,
54
+ $disabled: $disabled,
55
+ $isSelected: $isSelected
56
+ })),
54
57
  marginLeft: 0,
55
58
  marginTop: 0,
56
59
  marginRight: 0,
@@ -275,10 +278,36 @@ function getFontStyles(_ref10) {
275
278
  }
276
279
  }
277
280
 
278
- function getPaddingStyles(_ref11) {
281
+ function getDisabledStyles(_ref11) {
279
282
  var $theme = _ref11.$theme,
280
- $size = _ref11.$size,
281
- $shape = _ref11.$shape;
283
+ $kind = _ref11.$kind,
284
+ $isSelected = _ref11.$isSelected,
285
+ $disabled = _ref11.$disabled;
286
+
287
+ if ($disabled && $isSelected) {
288
+ if ($kind === _constants.KIND.primary || $kind === _constants.KIND.secondary) {
289
+ return {
290
+ color: $theme.colors.buttonDisabledActiveText,
291
+ backgroundColor: $theme.colors.buttonDisabledActiveFill
292
+ };
293
+ } else if ($kind === _constants.KIND.minimal || $kind === _constants.KIND.tertiary) {
294
+ return {
295
+ backgroundColor: $theme.colors.buttonTertiaryDisabledActiveFill,
296
+ color: $theme.colors.buttonTertiaryDisabledActiveText
297
+ };
298
+ }
299
+ }
300
+
301
+ return {
302
+ backgroundColor: $kind === _constants.KIND.minimal || $kind === _constants.KIND.tertiary ? 'transparent' : $theme.colors.buttonDisabledFill,
303
+ color: $theme.colors.buttonDisabledText
304
+ };
305
+ }
306
+
307
+ function getPaddingStyles(_ref12) {
308
+ var $theme = _ref12.$theme,
309
+ $size = _ref12.$size,
310
+ $shape = _ref12.$shape;
282
311
  var iconShape = $shape === _constants.SHAPE.square || $shape === _constants.SHAPE.circle || $shape === _constants.SHAPE.round;
283
312
 
284
313
  switch ($size) {
@@ -316,12 +345,12 @@ function getPaddingStyles(_ref11) {
316
345
  }
317
346
  }
318
347
 
319
- function getKindStyles(_ref12) {
320
- var $theme = _ref12.$theme,
321
- $isLoading = _ref12.$isLoading,
322
- $isSelected = _ref12.$isSelected,
323
- $kind = _ref12.$kind,
324
- $disabled = _ref12.$disabled;
348
+ function getKindStyles(_ref13) {
349
+ var $theme = _ref13.$theme,
350
+ $isLoading = _ref13.$isLoading,
351
+ $isSelected = _ref13.$isSelected,
352
+ $kind = _ref13.$kind,
353
+ $disabled = _ref13.$disabled;
325
354
 
326
355
  if ($disabled) {
327
356
  return Object.freeze({});
@@ -409,10 +438,10 @@ function getKindStyles(_ref12) {
409
438
  }
410
439
  }
411
440
 
412
- function getShapeStyles(_ref13) {
413
- var $theme = _ref13.$theme,
414
- $shape = _ref13.$shape,
415
- $size = _ref13.$size;
441
+ function getShapeStyles(_ref14) {
442
+ var $theme = _ref14.$theme,
443
+ $shape = _ref14.$shape,
444
+ $size = _ref14.$size;
416
445
 
417
446
  if ($shape === _constants.SHAPE.circle || $shape === _constants.SHAPE.square) {
418
447
  var height, width;
@@ -46,11 +46,7 @@ export const BaseButton = styled<SharedStylePropsT>(
46
46
  cursor: 'pointer',
47
47
  ':disabled': {
48
48
  cursor: 'not-allowed',
49
- backgroundColor:
50
- $kind === KIND.minimal || $kind === KIND.tertiary
51
- ? 'transparent'
52
- : $theme.colors.buttonDisabledFill,
53
- color: $theme.colors.buttonDisabledText,
49
+ ...getDisabledStyles({$theme, $kind, $disabled, $isSelected}),
54
50
  },
55
51
  marginLeft: 0,
56
52
  marginTop: 0,
@@ -229,6 +225,30 @@ function getFontStyles({$theme, $size}) {
229
225
  }
230
226
  }
231
227
 
228
+ function getDisabledStyles({$theme, $kind, $isSelected, $disabled}) {
229
+ if ($disabled && $isSelected) {
230
+ if ($kind === KIND.primary || $kind === KIND.secondary) {
231
+ return {
232
+ color: $theme.colors.buttonDisabledActiveText,
233
+ backgroundColor: $theme.colors.buttonDisabledActiveFill,
234
+ };
235
+ } else if ($kind === KIND.minimal || $kind === KIND.tertiary) {
236
+ return {
237
+ backgroundColor: $theme.colors.buttonTertiaryDisabledActiveFill,
238
+ color: $theme.colors.buttonTertiaryDisabledActiveText,
239
+ };
240
+ }
241
+ }
242
+
243
+ return {
244
+ backgroundColor:
245
+ $kind === KIND.minimal || $kind === KIND.tertiary
246
+ ? 'transparent'
247
+ : $theme.colors.buttonDisabledFill,
248
+ color: $theme.colors.buttonDisabledText,
249
+ };
250
+ }
251
+
232
252
  function getPaddingStyles({$theme, $size, $shape}) {
233
253
  const iconShape =
234
254
  $shape === SHAPE.square ||
@@ -208,7 +208,7 @@ function CategoricalFilter(props) {
208
208
  overflowY: 'auto',
209
209
  marginTop: theme.sizing.scale600
210
210
  })
211
- }, !filteredCategories.length && /*#__PURE__*/React.createElement(_index6.Label3, null, locale.datatable.categoricalFilterEmpty), Boolean(filteredCategories.length) && filteredCategories.map(function (category, i) {
211
+ }, !filteredCategories.length && /*#__PURE__*/React.createElement(_index6.LabelSmall, null, locale.datatable.categoricalFilterEmpty), Boolean(filteredCategories.length) && filteredCategories.map(function (category, i) {
212
212
  return /*#__PURE__*/React.createElement("div", {
213
213
  className: checkboxStyles,
214
214
  key: i
@@ -14,7 +14,7 @@ import {Checkbox, StyledLabel} from '../checkbox/index.js';
14
14
  import Search from '../icon/search.js';
15
15
  import {Input, SIZE as INPUT_SIZE} from '../input/index.js';
16
16
  import {useStyletron, withStyle} from '../styles/index.js';
17
- import {Label3} from '../typography/index.js';
17
+ import {LabelSmall} from '../typography/index.js';
18
18
 
19
19
  import Column from './column.js';
20
20
  import {COLUMNS} from './constants.js';
@@ -184,7 +184,7 @@ export function CategoricalFilter(props: CategoricalFilterProps) {
184
184
  })}
185
185
  >
186
186
  {!filteredCategories.length && (
187
- <Label3>{locale.datatable.categoricalFilterEmpty}</Label3>
187
+ <LabelSmall>{locale.datatable.categoricalFilterEmpty}</LabelSmall>
188
188
  )}
189
189
 
190
190
  {Boolean(filteredCategories.length) &&
@@ -456,7 +456,7 @@ function DatetimeFilter(props) {
456
456
  if (Array.isArray(date)) {
457
457
  if (!date.length) return;
458
458
  var nextDates = date.map(function (d, i) {
459
- return d ? (0, _index13.applyDateToTime)(rangeDates[i], d) : null;
459
+ return (0, _index13.applyDateToTime)(rangeDates[i], d);
460
460
  });
461
461
  setRangeDates(nextDates);
462
462
  }
@@ -410,7 +410,7 @@ function DatetimeFilter(props) {
410
410
  if (Array.isArray(date)) {
411
411
  if (!date.length) return;
412
412
  const nextDates = date.map((d, i) =>
413
- d ? applyDateToTime(rangeDates[i], d) : null,
413
+ applyDateToTime(rangeDates[i], d),
414
414
  );
415
415
  setRangeDates(nextDates);
416
416
  }
@@ -493,7 +493,7 @@ function NumericalFilter(props) {
493
493
  marginLeft: theme.sizing.scale300,
494
494
  marginRight: theme.sizing.scale300
495
495
  })
496
- }, /*#__PURE__*/React.createElement(_index5.Paragraph4, null, format(min, props.options)), ' ', /*#__PURE__*/React.createElement(_index5.Paragraph4, null, format(max, props.options))), /*#__PURE__*/React.createElement("div", {
496
+ }, /*#__PURE__*/React.createElement(_index5.ParagraphXSmall, null, format(min, props.options)), ' ', /*#__PURE__*/React.createElement(_index5.ParagraphXSmall, null, format(max, props.options))), /*#__PURE__*/React.createElement("div", {
497
497
  className: css({
498
498
  display: 'flex',
499
499
  justifyContent: 'space-between'
@@ -12,7 +12,7 @@ import {Button, SIZE} from '../button/index.js';
12
12
  import {ButtonGroup, MODE} from '../button-group/index.js';
13
13
  import {Input, SIZE as INPUT_SIZE} from '../input/index.js';
14
14
  import {useStyletron} from '../styles/index.js';
15
- import {Paragraph4} from '../typography/index.js';
15
+ import {ParagraphXSmall} from '../typography/index.js';
16
16
 
17
17
  import Column from './column.js';
18
18
  import {COLUMNS, NUMERICAL_FORMATS, NUMERICAL_OPERATIONS} from './constants.js';
@@ -388,8 +388,8 @@ function NumericalFilter(props) {
388
388
  marginRight: theme.sizing.scale300,
389
389
  })}
390
390
  >
391
- <Paragraph4>{format(min, props.options)}</Paragraph4>{' '}
392
- <Paragraph4>{format(max, props.options)}</Paragraph4>
391
+ <ParagraphXSmall>{format(min, props.options)}</ParagraphXSmall>{' '}
392
+ <ParagraphXSmall>{format(max, props.options)}</ParagraphXSmall>
393
393
  </div>
394
394
 
395
395
  <div className={css({display: 'flex', justifyContent: 'space-between'})}>
@@ -339,16 +339,10 @@ var Calendar = /*#__PURE__*/function (_React$Component) {
339
339
 
340
340
 
341
341
  if (Array.isArray(data.date)) {
342
- var start = data.date[0] ? _this.dateHelpers.applyDateToTime(newTimeState[0], data.date[0]) : null;
343
- var end = data.date[1] ? _this.dateHelpers.applyDateToTime(newTimeState[1], data.date[1]) : null;
344
- newTimeState[0] = start;
345
-
346
- if (end) {
347
- updatedDate = [start, end];
348
- newTimeState[1] = end;
349
- } else {
350
- updatedDate = [start];
351
- }
342
+ updatedDate = data.date.map(function (date, index) {
343
+ newTimeState[index] = _this.dateHelpers.applyDateToTime(newTimeState[index], date);
344
+ return newTimeState[index];
345
+ });
352
346
  } else if (!Array.isArray(_this.props.value) && data.date) {
353
347
  newTimeState[0] = _this.dateHelpers.applyDateToTime(newTimeState[0], data.date);
354
348
  updatedDate = newTimeState[0];
@@ -380,7 +374,7 @@ var Calendar = /*#__PURE__*/function (_React$Component) {
380
374
 
381
375
  if (Array.isArray(_this.props.value)) {
382
376
  var dates = _this.props.value.map(function (date, i) {
383
- if (date && index === i) {
377
+ if (index === i) {
384
378
  return _this.dateHelpers.applyTimeToDate(date, time);
385
379
  }
386
380
 
@@ -388,7 +382,7 @@ var Calendar = /*#__PURE__*/function (_React$Component) {
388
382
  });
389
383
 
390
384
  onChange({
391
- date: [dates[0], dates[1]]
385
+ date: dates
392
386
  });
393
387
  } else {
394
388
  var date = _this.dateHelpers.applyTimeToDate(_this.props.value, time);
@@ -22,11 +22,7 @@ import {
22
22
  import dateFnsAdapter from './utils/date-fns-adapter.js';
23
23
  import DateHelpers from './utils/date-helpers.js';
24
24
  import {getOverrides, mergeOverrides} from '../helpers/overrides.js';
25
- import type {
26
- CalendarPropsT,
27
- CalendarInternalState,
28
- DateValueT,
29
- } from './types.js';
25
+ import type {CalendarPropsT, CalendarInternalState} from './types.js';
30
26
  import {DENSITY, ORIENTATION} from './constants.js';
31
27
 
32
28
  export default class Calendar<T = Date> extends React.Component<
@@ -144,7 +140,7 @@ export default class Calendar<T = Date> extends React.Component<
144
140
  return monthDelta >= 0 && monthDelta < (this.props.monthsShown || 1);
145
141
  }
146
142
 
147
- getSingleDate(value: DateValueT<T>): ?T {
143
+ getSingleDate(value: ?T | Array<T>): ?T {
148
144
  // need to check this.props.range but flow would complain
149
145
  // at the return value in the else clause
150
146
  if (Array.isArray(value)) {
@@ -350,26 +346,20 @@ export default class Calendar<T = Date> extends React.Component<
350
346
  this.props.onDayMouseLeave && this.props.onDayMouseLeave(data);
351
347
  };
352
348
 
353
- handleDateChange: ({date: DateValueT<T>}) => void = data => {
349
+ handleDateChange: ({date: ?T | Array<T>}) => void = data => {
354
350
  const {onChange = params => {}} = this.props;
355
351
  let updatedDate = data.date;
356
352
  // We'll need to update the date in time values of internal state
357
353
  const newTimeState = [...this.state.time];
358
354
  // Apply the currently selected time values (saved in state) to the updated date
359
355
  if (Array.isArray(data.date)) {
360
- const start = data.date[0]
361
- ? this.dateHelpers.applyDateToTime(newTimeState[0], data.date[0])
362
- : null;
363
- const end = data.date[1]
364
- ? this.dateHelpers.applyDateToTime(newTimeState[1], data.date[1])
365
- : null;
366
- newTimeState[0] = start;
367
- if (end) {
368
- updatedDate = [start, end];
369
- newTimeState[1] = end;
370
- } else {
371
- updatedDate = [start];
372
- }
356
+ updatedDate = data.date.map((date, index) => {
357
+ newTimeState[index] = this.dateHelpers.applyDateToTime(
358
+ newTimeState[index],
359
+ date,
360
+ );
361
+ return newTimeState[index];
362
+ });
373
363
  } else if (!Array.isArray(this.props.value) && data.date) {
374
364
  newTimeState[0] = this.dateHelpers.applyDateToTime(
375
365
  newTimeState[0],
@@ -377,7 +367,6 @@ export default class Calendar<T = Date> extends React.Component<
377
367
  );
378
368
  updatedDate = newTimeState[0];
379
369
  }
380
-
381
370
  // Update the date in time values of internal state
382
371
  this.setState({time: newTimeState});
383
372
  onChange({date: updatedDate});
@@ -396,12 +385,12 @@ export default class Calendar<T = Date> extends React.Component<
396
385
  // with the date value set to the date with updated time
397
386
  if (Array.isArray(this.props.value)) {
398
387
  const dates = this.props.value.map((date, i) => {
399
- if (date && index === i) {
388
+ if (index === i) {
400
389
  return this.dateHelpers.applyTimeToDate(date, time);
401
390
  }
402
391
  return date;
403
392
  });
404
- onChange({date: [dates[0], dates[1]]});
393
+ onChange({date: dates});
405
394
  } else {
406
395
  const date = this.dateHelpers.applyTimeToDate(this.props.value, time);
407
396
  onChange({date});
@@ -98,7 +98,6 @@ var combineSeparatedInputs = function combineSeparatedInputs(newInputValue) {
98
98
  prevEndDate = _prevCombinedInputVal4 === void 0 ? '' : _prevCombinedInputVal4;
99
99
 
100
100
  if (separatedInput === 'startDate' && prevEndDate) {
101
- // TODO(LUKE): use INPUT_DELIMITER below
102
101
  inputValue = "".concat(inputValue, " \u2013 ").concat(prevEndDate);
103
102
  }
104
103
 
@@ -132,11 +131,11 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
132
131
  var nextDate = data.date;
133
132
 
134
133
  if (Array.isArray(nextDate) && _this.props.range) {
135
- if (!nextDate[0] || !nextDate[1]) {
134
+ if (nextDate.length < 2) {
136
135
  isOpen = true;
137
136
  isPseudoFocused = true;
138
137
  calendarFocused = null;
139
- } else if (nextDate[0] && nextDate[1]) {
138
+ } else if (nextDate.length === 2) {
140
139
  var _nextDate = nextDate,
141
140
  _nextDate2 = _slicedToArray(_nextDate, 2),
142
141
  start = _nextDate2[0],
@@ -283,7 +282,6 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
283
282
  }
284
283
 
285
284
  if (range && !separateRangeInputs) {
286
- // TODO(LUKE): use INPUT_DELIMITER below
287
285
  return '9999/99/99 – 9999/99/99';
288
286
  }
289
287
 
@@ -471,11 +469,6 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
471
469
  }
472
470
 
473
471
  _createClass(Datepicker, [{
474
- key: "getNullDatePlaceholder",
475
- value: function getNullDatePlaceholder(formatString) {
476
- return (this.getMask() || formatString).split('–')[0].replace(/[0-9]|[a-z]/g, ' ');
477
- }
478
- }, {
479
472
  key: "formatDate",
480
473
  value: function formatDate(date, formatString) {
481
474
  var _this2 = this;
@@ -492,13 +485,9 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
492
485
  return '';
493
486
  } else if (Array.isArray(date) && !date[0] && !date[1]) {
494
487
  return '';
495
- } else if (Array.isArray(date) && !date[0] && date[1]) {
496
- var endDate = format(date[1]);
497
- var startDate = this.getNullDatePlaceholder(formatString);
498
- return [startDate, endDate].join(INPUT_DELIMITER);
499
488
  } else if (Array.isArray(date)) {
500
489
  return date.map(function (day) {
501
- return day ? format(day) : '';
490
+ return format(day);
502
491
  }).join(INPUT_DELIMITER);
503
492
  } else {
504
493
  return format(date);
@@ -650,11 +639,11 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
650
639
  clipPath: 'inset(100%)'
651
640
  }
652
641
  }, // No date selected
653
- !_this4.props.value || Array.isArray(_this4.props.value) && !_this4.props.value[0] && !_this4.props.value[1] ? '' : // Date selected in a non-range picker
642
+ !_this4.props.value || Array.isArray(_this4.props.value) && !_this4.props.value.length ? '' : // Date selected in a non-range picker
654
643
  !Array.isArray(_this4.props.value) ? (0, _i18nInterpolation.default)(locale.datepicker.selectedDate, {
655
644
  date: _this4.state.inputValue || ''
656
645
  }) : // Start and end dates are selected in a range picker
657
- _this4.props.value[0] && _this4.props.value[1] ? (0, _i18nInterpolation.default)(locale.datepicker.selectedDateRange, {
646
+ _this4.props.value.length > 1 ? (0, _i18nInterpolation.default)(locale.datepicker.selectedDateRange, {
658
647
  startDate: _this4.formatDisplayValue(_this4.props.value[0]),
659
648
  endDate: _this4.formatDisplayValue( // $FlowFixMe
660
649
  _this4.props.value[1])
@@ -19,7 +19,7 @@ import {
19
19
  StyledStartDate,
20
20
  StyledEndDate,
21
21
  } from './styled-components.js';
22
- import type {DatepickerPropsT, DateValueT} from './types.js';
22
+ import type {DatepickerPropsT} from './types.js';
23
23
  import DateHelpers from './utils/date-helpers.js';
24
24
  import dateFnsAdapter from './utils/date-fns-adapter.js';
25
25
  import type {LocaleT} from '../locale/types.js';
@@ -38,7 +38,6 @@ const combineSeparatedInputs = (
38
38
  INPUT_DELIMITER,
39
39
  );
40
40
  if (separatedInput === 'startDate' && prevEndDate) {
41
- // TODO(LUKE): use INPUT_DELIMITER below
42
41
  inputValue = `${inputValue} – ${prevEndDate}`;
43
42
  }
44
43
  if (separatedInput === 'endDate') {
@@ -82,18 +81,18 @@ export default class Datepicker<T = Date> extends React.Component<
82
81
  };
83
82
  }
84
83
 
85
- onChange: ({date: DateValueT<T>}) => void = data => {
84
+ onChange: ({date: ?T | Array<T>}) => void = data => {
86
85
  let isOpen = false;
87
86
  let isPseudoFocused = false;
88
87
  let calendarFocused = false;
89
88
  let nextDate = data.date;
90
89
 
91
90
  if (Array.isArray(nextDate) && this.props.range) {
92
- if (!nextDate[0] || !nextDate[1]) {
91
+ if (nextDate.length < 2) {
93
92
  isOpen = true;
94
93
  isPseudoFocused = true;
95
94
  calendarFocused = null;
96
- } else if (nextDate[0] && nextDate[1]) {
95
+ } else if (nextDate.length === 2) {
97
96
  const [start, end] = nextDate;
98
97
  if (this.dateHelpers.isAfter(start, end)) {
99
98
  nextDate = [start, start];
@@ -144,36 +143,25 @@ export default class Datepicker<T = Date> extends React.Component<
144
143
  this.props.onChange && this.props.onChange({date: nextDate});
145
144
  };
146
145
 
147
- getNullDatePlaceholder(formatString: string) {
148
- return (this.getMask() || formatString)
149
- .split('–')[0]
150
- .replace(/[0-9]|[a-z]/g, ' ');
151
- }
152
-
153
- formatDate(date: DateValueT<T>, formatString: string) {
154
- const format = (date: T) => {
146
+ formatDate(date: ?T | Array<T>, formatString: string) {
147
+ const format = date => {
155
148
  if (formatString === DEFAULT_DATE_FORMAT) {
156
149
  return this.dateHelpers.format(date, 'slashDate', this.props.locale);
157
150
  }
158
151
  return this.dateHelpers.formatDate(date, formatString, this.props.locale);
159
152
  };
160
-
161
153
  if (!date) {
162
154
  return '';
163
155
  } else if (Array.isArray(date) && !date[0] && !date[1]) {
164
156
  return '';
165
- } else if (Array.isArray(date) && !date[0] && date[1]) {
166
- const endDate = format(date[1]);
167
- const startDate = this.getNullDatePlaceholder(formatString);
168
- return [startDate, endDate].join(INPUT_DELIMITER);
169
157
  } else if (Array.isArray(date)) {
170
- return date.map(day => (day ? format(day) : '')).join(INPUT_DELIMITER);
158
+ return date.map(day => format(day)).join(INPUT_DELIMITER);
171
159
  } else {
172
160
  return format(date);
173
161
  }
174
162
  }
175
163
 
176
- formatDisplayValue: (DateValueT<T>) => string = (date: DateValueT<T>) => {
164
+ formatDisplayValue: (?T | Array<T>) => string = (date: ?T | Array<T>) => {
177
165
  const {displayValueAtRangeIndex, formatDisplayValue, range} = this.props;
178
166
  const formatString = this.normalizeDashes(this.props.formatString);
179
167
 
@@ -253,7 +241,6 @@ export default class Datepicker<T = Date> extends React.Component<
253
241
  }
254
242
 
255
243
  if (range && !separateRangeInputs) {
256
- // TODO(LUKE): use INPUT_DELIMITER below
257
244
  return '9999/99/99 – 9999/99/99';
258
245
  }
259
246
 
@@ -613,9 +600,7 @@ export default class Datepicker<T = Date> extends React.Component<
613
600
  >
614
601
  {// No date selected
615
602
  !this.props.value ||
616
- (Array.isArray(this.props.value) &&
617
- !this.props.value[0] &&
618
- !this.props.value[1])
603
+ (Array.isArray(this.props.value) && !this.props.value.length)
619
604
  ? ''
620
605
  : // Date selected in a non-range picker
621
606
  !Array.isArray(this.props.value)
@@ -623,7 +608,7 @@ export default class Datepicker<T = Date> extends React.Component<
623
608
  date: this.state.inputValue || '',
624
609
  })
625
610
  : // Start and end dates are selected in a range picker
626
- this.props.value[0] && this.props.value[1]
611
+ this.props.value.length > 1
627
612
  ? getInterpolatedString(locale.datepicker.selectedDateRange, {
628
613
  startDate: this.formatDisplayValue(this.props.value[0]),
629
614
  endDate: this.formatDisplayValue(