baseui 10.12.0 → 11.0.1

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 (291) hide show
  1. package/README.md +3 -3
  2. package/accordion/accordion.js +60 -13
  3. package/accordion/accordion.js.flow +49 -12
  4. package/accordion/index.d.ts +0 -3
  5. package/accordion/panel.js +7 -6
  6. package/accordion/panel.js.flow +20 -20
  7. package/accordion/stateless-accordion.js +2 -4
  8. package/accordion/stateless-accordion.js.flow +0 -2
  9. package/accordion/types.js.flow +0 -5
  10. package/button/constants.js +1 -2
  11. package/button/constants.js.flow +0 -1
  12. package/button/index.d.ts +0 -1
  13. package/button/styled-components.js +2 -29
  14. package/button/styled-components.js.flow +2 -30
  15. package/checkbox/checkbox.js +6 -30
  16. package/checkbox/checkbox.js.flow +7 -38
  17. package/checkbox/constants.js +2 -1
  18. package/checkbox/constants.js.flow +2 -1
  19. package/checkbox/index.d.ts +4 -6
  20. package/checkbox/index.js +0 -6
  21. package/checkbox/index.js.flow +0 -1
  22. package/checkbox/styled-components.js +52 -149
  23. package/checkbox/styled-components.js.flow +59 -165
  24. package/checkbox/types.js.flow +0 -5
  25. package/data-table/column-categorical.js +1 -1
  26. package/data-table/column-categorical.js.flow +1 -1
  27. package/data-table/column-datetime.js +1 -1
  28. package/data-table/column-datetime.js.flow +3 -1
  29. package/data-table/column.js +6 -2
  30. package/data-table/column.js.flow +9 -7
  31. package/data-table/data-table.js +10 -2
  32. package/data-table/data-table.js.flow +4 -1
  33. package/data-table/header-cell.js +3 -0
  34. package/data-table/header-cell.js.flow +1 -1
  35. package/data-table/index.d.ts +7 -8
  36. package/data-table/stateful-data-table.js +2 -1
  37. package/data-table/stateful-data-table.js.flow +1 -0
  38. package/data-table/types.js.flow +8 -0
  39. package/datepicker/calendar.js +15 -7
  40. package/datepicker/calendar.js.flow +23 -9
  41. package/datepicker/constants.js +12 -2
  42. package/datepicker/constants.js.flow +10 -0
  43. package/datepicker/datepicker.js +61 -30
  44. package/datepicker/datepicker.js.flow +77 -37
  45. package/datepicker/day.js +85 -34
  46. package/datepicker/day.js.flow +118 -54
  47. package/datepicker/locale.js.flow +0 -1
  48. package/datepicker/month.js +3 -1
  49. package/datepicker/month.js.flow +2 -0
  50. package/datepicker/stateful-container.js.flow +2 -1
  51. package/datepicker/styled-components.js +23 -1
  52. package/datepicker/styled-components.js.flow +12 -2
  53. package/datepicker/types.js.flow +35 -10
  54. package/datepicker/utils/date-helpers.js +30 -0
  55. package/datepicker/utils/date-helpers.js.flow +12 -0
  56. package/datepicker/week.js +3 -1
  57. package/datepicker/week.js.flow +2 -0
  58. package/es/accordion/accordion.js +52 -12
  59. package/es/accordion/panel.js +7 -5
  60. package/es/accordion/stateless-accordion.js +2 -4
  61. package/es/button/constants.js +1 -2
  62. package/es/button/styled-components.js +2 -29
  63. package/es/checkbox/checkbox.js +7 -32
  64. package/es/checkbox/constants.js +2 -1
  65. package/es/checkbox/index.js +1 -1
  66. package/es/checkbox/styled-components.js +51 -146
  67. package/es/data-table/column-categorical.js +1 -1
  68. package/es/data-table/column-datetime.js +1 -1
  69. package/es/data-table/column.js +6 -2
  70. package/es/data-table/data-table.js +6 -2
  71. package/es/data-table/header-cell.js +3 -0
  72. package/es/data-table/stateful-data-table.js +2 -1
  73. package/es/datepicker/calendar.js +15 -7
  74. package/es/datepicker/constants.js +8 -0
  75. package/es/datepicker/datepicker.js +56 -29
  76. package/es/datepicker/day.js +77 -34
  77. package/es/datepicker/month.js +3 -1
  78. package/es/datepicker/styled-components.js +8 -2
  79. package/es/datepicker/types.js +1 -1
  80. package/es/datepicker/utils/date-helpers.js +16 -0
  81. package/es/datepicker/week.js +3 -1
  82. package/es/file-uploader/file-uploader.js +4 -4
  83. package/es/form-control/styled-components.js +0 -1
  84. package/es/header-navigation/styled-components.js +3 -3
  85. package/es/helpers/overrides.js +1 -2
  86. package/es/input/styled-components.js +4 -4
  87. package/es/layer/layer.js +4 -4
  88. package/es/list/list-item.js +5 -1
  89. package/es/list/menu-adapter.js +4 -0
  90. package/es/locale/index.js +0 -7
  91. package/es/menu/stateful-container.js +0 -1
  92. package/es/menu/styled-components.js +1 -1
  93. package/es/modal/index.js +1 -1
  94. package/es/modal/modal.js +19 -65
  95. package/es/modal/styled-components.js +12 -48
  96. package/es/phone-input/default-props.js +1 -1
  97. package/es/phone-input/index.js +0 -4
  98. package/es/phone-input/phone-input-lite.js +55 -31
  99. package/es/radio/radio.js +1 -7
  100. package/es/radio/radiogroup.js +3 -28
  101. package/es/radio/styled-components.js +4 -5
  102. package/es/rating/styled-components.js +3 -3
  103. package/es/select/index.js +1 -2
  104. package/es/select/select-component.js +20 -20
  105. package/es/select/styled-components.js +21 -17
  106. package/es/snackbar/styled-components.js +2 -2
  107. package/es/spinner/index.js +3 -9
  108. package/es/spinner/styled-components.js +2 -32
  109. package/es/table/filter.js +3 -3
  110. package/es/tag/styled-components.js +1 -1
  111. package/es/themes/dark-theme/color-component-tokens.js +0 -38
  112. package/es/themes/dark-theme/color-tokens.js +0 -2
  113. package/es/themes/dark-theme/create-dark-theme.js +0 -2
  114. package/es/themes/dark-theme/dark-theme.js +0 -2
  115. package/es/themes/light-theme/color-component-tokens.js +0 -38
  116. package/es/themes/light-theme/color-tokens.js +0 -2
  117. package/es/themes/light-theme/create-light-theme.js +0 -2
  118. package/es/themes/light-theme/light-theme.js +0 -2
  119. package/es/timepicker/timepicker.js +1 -8
  120. package/es/typography/index.js +1 -31
  121. package/esm/accordion/accordion.js +60 -13
  122. package/esm/accordion/panel.js +7 -6
  123. package/esm/accordion/stateless-accordion.js +2 -4
  124. package/esm/button/constants.js +1 -2
  125. package/esm/button/styled-components.js +2 -29
  126. package/esm/checkbox/checkbox.js +7 -30
  127. package/esm/checkbox/constants.js +2 -1
  128. package/esm/checkbox/index.js +1 -1
  129. package/esm/checkbox/styled-components.js +52 -147
  130. package/esm/data-table/column-categorical.js +1 -1
  131. package/esm/data-table/column-datetime.js +1 -1
  132. package/esm/data-table/column.js +6 -2
  133. package/esm/data-table/data-table.js +10 -2
  134. package/esm/data-table/header-cell.js +3 -0
  135. package/esm/data-table/stateful-data-table.js +2 -1
  136. package/esm/datepicker/calendar.js +15 -7
  137. package/esm/datepicker/constants.js +8 -0
  138. package/esm/datepicker/datepicker.js +60 -30
  139. package/esm/datepicker/day.js +84 -34
  140. package/esm/datepicker/month.js +3 -1
  141. package/esm/datepicker/styled-components.js +24 -2
  142. package/esm/datepicker/types.js +1 -1
  143. package/esm/datepicker/utils/date-helpers.js +30 -0
  144. package/esm/datepicker/week.js +3 -1
  145. package/esm/file-uploader/file-uploader.js +4 -4
  146. package/esm/form-control/styled-components.js +0 -1
  147. package/esm/header-navigation/styled-components.js +3 -3
  148. package/esm/helpers/overrides.js +1 -2
  149. package/esm/input/styled-components.js +4 -4
  150. package/esm/layer/layer.js +4 -4
  151. package/esm/list/list-item.js +5 -1
  152. package/esm/list/menu-adapter.js +4 -0
  153. package/esm/locale/index.js +0 -7
  154. package/esm/menu/stateful-container.js +0 -1
  155. package/esm/menu/styled-components.js +1 -1
  156. package/esm/modal/index.js +1 -1
  157. package/esm/modal/modal.js +28 -71
  158. package/esm/modal/styled-components.js +6 -38
  159. package/esm/phone-input/default-props.js +1 -1
  160. package/esm/phone-input/index.js +0 -4
  161. package/esm/phone-input/phone-input-lite.js +60 -37
  162. package/esm/radio/radio.js +1 -7
  163. package/esm/radio/radiogroup.js +3 -28
  164. package/esm/radio/styled-components.js +4 -5
  165. package/esm/rating/styled-components.js +3 -3
  166. package/esm/select/index.js +1 -2
  167. package/esm/select/select-component.js +20 -20
  168. package/esm/select/styled-components.js +21 -14
  169. package/esm/snackbar/styled-components.js +2 -2
  170. package/esm/spinner/index.js +3 -9
  171. package/esm/spinner/styled-components.js +2 -40
  172. package/esm/table/filter.js +3 -3
  173. package/esm/tag/styled-components.js +1 -1
  174. package/esm/themes/dark-theme/color-component-tokens.js +0 -38
  175. package/esm/themes/dark-theme/color-tokens.js +0 -2
  176. package/esm/themes/dark-theme/create-dark-theme.js +1 -2
  177. package/esm/themes/dark-theme/dark-theme.js +1 -2
  178. package/esm/themes/light-theme/color-component-tokens.js +0 -38
  179. package/esm/themes/light-theme/color-tokens.js +0 -2
  180. package/esm/themes/light-theme/create-light-theme.js +1 -2
  181. package/esm/themes/light-theme/light-theme.js +1 -2
  182. package/esm/timepicker/timepicker.js +1 -8
  183. package/esm/typography/index.js +1 -35
  184. package/file-uploader/file-uploader.js +3 -3
  185. package/file-uploader/file-uploader.js.flow +4 -4
  186. package/form-control/index.d.ts +9 -0
  187. package/form-control/styled-components.js +0 -1
  188. package/form-control/styled-components.js.flow +0 -1
  189. package/header-navigation/styled-components.js +3 -3
  190. package/header-navigation/styled-components.js.flow +3 -3
  191. package/helpers/overrides.js +1 -2
  192. package/helpers/overrides.js.flow +1 -1
  193. package/input/index.d.ts +5 -9
  194. package/input/styled-components.js +4 -4
  195. package/input/styled-components.js.flow +4 -4
  196. package/layer/layer.js +4 -4
  197. package/layer/layer.js.flow +4 -3
  198. package/list/list-item.js +5 -1
  199. package/list/list-item.js.flow +4 -0
  200. package/list/menu-adapter.js +4 -0
  201. package/list/menu-adapter.js.flow +4 -0
  202. package/list/types.js.flow +4 -0
  203. package/locale/index.js +0 -7
  204. package/locale/index.js.flow +0 -7
  205. package/locale.ts +0 -1
  206. package/menu/index.d.ts +1 -3
  207. package/menu/stateful-container.js +0 -1
  208. package/menu/stateful-container.js.flow +0 -1
  209. package/menu/styled-components.js +1 -1
  210. package/menu/styled-components.js.flow +1 -1
  211. package/modal/index.d.ts +4 -6
  212. package/modal/index.js +0 -6
  213. package/modal/index.js.flow +0 -1
  214. package/modal/modal.js +27 -70
  215. package/modal/modal.js.flow +17 -83
  216. package/modal/styled-components.js +7 -40
  217. package/modal/styled-components.js.flow +12 -44
  218. package/modal/types.js.flow +1 -10
  219. package/package.json +3 -2
  220. package/phone-input/default-props.js +1 -1
  221. package/phone-input/default-props.js.flow +1 -1
  222. package/phone-input/index.d.ts +0 -1
  223. package/phone-input/index.js +0 -36
  224. package/phone-input/index.js.flow +0 -4
  225. package/phone-input/phone-input-lite.js +63 -38
  226. package/phone-input/phone-input-lite.js.flow +66 -44
  227. package/radio/index.d.ts +4 -9
  228. package/radio/radio.js +1 -7
  229. package/radio/radio.js.flow +1 -8
  230. package/radio/radiogroup.js +3 -28
  231. package/radio/radiogroup.js.flow +2 -26
  232. package/radio/styled-components.js +4 -5
  233. package/radio/styled-components.js.flow +3 -4
  234. package/radio/types.js.flow +4 -15
  235. package/rating/styled-components.js +3 -3
  236. package/rating/styled-components.js.flow +3 -3
  237. package/select/index.d.ts +0 -2
  238. package/select/index.js +0 -6
  239. package/select/index.js.flow +0 -2
  240. package/select/select-component.js +23 -24
  241. package/select/select-component.js.flow +25 -14
  242. package/select/styled-components.js +23 -17
  243. package/select/styled-components.js.flow +17 -12
  244. package/snackbar/styled-components.js +1 -1
  245. package/snackbar/styled-components.js.flow +11 -11
  246. package/spinner/index.d.ts +5 -18
  247. package/spinner/index.js +2 -68
  248. package/spinner/index.js.flow +2 -27
  249. package/spinner/styled-components.js +9 -45
  250. package/spinner/styled-components.js.flow +2 -34
  251. package/spinner/types.js.flow +1 -19
  252. package/styles/types.js.flow +0 -2
  253. package/table/filter.js +3 -3
  254. package/table/filter.js.flow +3 -3
  255. package/tag/styled-components.js +1 -1
  256. package/tag/styled-components.js.flow +1 -1
  257. package/theme.ts +0 -81
  258. package/themes/dark-theme/color-component-tokens.js +0 -38
  259. package/themes/dark-theme/color-component-tokens.js.flow +0 -42
  260. package/themes/dark-theme/color-tokens.js +0 -2
  261. package/themes/dark-theme/color-tokens.js.flow +0 -2
  262. package/themes/dark-theme/create-dark-theme.js +1 -3
  263. package/themes/dark-theme/create-dark-theme.js.flow +0 -2
  264. package/themes/dark-theme/dark-theme.js +1 -3
  265. package/themes/dark-theme/dark-theme.js.flow +0 -2
  266. package/themes/light-theme/color-component-tokens.js +0 -38
  267. package/themes/light-theme/color-component-tokens.js.flow +0 -43
  268. package/themes/light-theme/color-tokens.js +0 -2
  269. package/themes/light-theme/color-tokens.js.flow +0 -2
  270. package/themes/light-theme/create-light-theme.js +1 -3
  271. package/themes/light-theme/create-light-theme.js.flow +0 -2
  272. package/themes/light-theme/light-theme.js +1 -3
  273. package/themes/light-theme/light-theme.js.flow +0 -2
  274. package/themes/types.js.flow +0 -68
  275. package/timepicker/timepicker.js +1 -8
  276. package/timepicker/timepicker.js.flow +4 -10
  277. package/typography/index.d.ts +0 -23
  278. package/typography/index.js +2 -57
  279. package/typography/index.js.flow +0 -31
  280. package/es/spinner/spinner.js +0 -68
  281. package/es/themes/dark-theme/color-deprecated-semantic-tokens.js +0 -35
  282. package/es/themes/light-theme/color-deprecated-semantic-tokens.js +0 -35
  283. package/esm/spinner/spinner.js +0 -125
  284. package/esm/themes/dark-theme/color-deprecated-semantic-tokens.js +0 -38
  285. package/esm/themes/light-theme/color-deprecated-semantic-tokens.js +0 -38
  286. package/spinner/spinner.js +0 -136
  287. package/spinner/spinner.js.flow +0 -75
  288. package/themes/dark-theme/color-deprecated-semantic-tokens.js +0 -50
  289. package/themes/dark-theme/color-deprecated-semantic-tokens.js.flow +0 -42
  290. package/themes/light-theme/color-deprecated-semantic-tokens.js +0 -50
  291. package/themes/light-theme/color-deprecated-semantic-tokens.js.flow +0 -42
@@ -22,7 +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 { CalendarPropsT, CalendarInternalState } from './types.js';
25
+ import type { CalendarPropsT, CalendarInternalState, DateValueT } from './types.js';
26
26
  import { DENSITY, ORIENTATION } from './constants.js';
27
27
 
28
28
  export default class Calendar<T = Date> extends React.Component<
@@ -134,7 +134,7 @@ export default class Calendar<T = Date> extends React.Component<
134
134
  return monthDelta >= 0 && monthDelta < (this.props.monthsShown || 1);
135
135
  }
136
136
 
137
- getSingleDate(value: ?T | Array<T>): ?T {
137
+ getSingleDate(value: DateValueT<T>): ?T {
138
138
  // need to check this.props.range but flow would complain
139
139
  // at the return value in the else clause
140
140
  if (Array.isArray(value)) {
@@ -337,21 +337,33 @@ export default class Calendar<T = Date> extends React.Component<
337
337
  this.props.onDayMouseLeave && this.props.onDayMouseLeave(data);
338
338
  };
339
339
 
340
- handleDateChange: ({ date: ?T | Array<T> }) => void = (data) => {
340
+ /** Responsible for merging time values into date values. Note: the 'Day' component
341
+ * determines how the days themselves change when a new day is selected. */
342
+ handleDateChange: ({ date: DateValueT<T> }) => void = (data) => {
341
343
  const { onChange = (params) => {} } = this.props;
342
344
  let updatedDate = data.date;
343
345
  // We'll need to update the date in time values of internal state
344
346
  const newTimeState = [...this.state.time];
345
347
  // Apply the currently selected time values (saved in state) to the updated date
346
348
  if (Array.isArray(data.date)) {
347
- updatedDate = data.date.map((date, index) => {
348
- newTimeState[index] = this.dateHelpers.applyDateToTime(newTimeState[index], date);
349
- return newTimeState[index];
350
- });
349
+ const start = data.date[0]
350
+ ? this.dateHelpers.applyDateToTime(newTimeState[0], data.date[0])
351
+ : null;
352
+ const end = data.date[1]
353
+ ? this.dateHelpers.applyDateToTime(newTimeState[1], data.date[1])
354
+ : null;
355
+ newTimeState[0] = start;
356
+ if (end) {
357
+ updatedDate = [start, end];
358
+ newTimeState[1] = end;
359
+ } else {
360
+ updatedDate = [start];
361
+ }
351
362
  } else if (!Array.isArray(this.props.value) && data.date) {
352
363
  newTimeState[0] = this.dateHelpers.applyDateToTime(newTimeState[0], data.date);
353
364
  updatedDate = newTimeState[0];
354
365
  }
366
+
355
367
  // Update the date in time values of internal state
356
368
  this.setState({ time: newTimeState });
357
369
  onChange({ date: updatedDate });
@@ -367,12 +379,12 @@ export default class Calendar<T = Date> extends React.Component<
367
379
  // with the date value set to the date with updated time
368
380
  if (Array.isArray(this.props.value)) {
369
381
  const dates = this.props.value.map((date, i) => {
370
- if (index === i) {
382
+ if (date && index === i) {
371
383
  return this.dateHelpers.applyTimeToDate(date, time);
372
384
  }
373
385
  return date;
374
386
  });
375
- onChange({ date: dates });
387
+ onChange({ date: [dates[0], dates[1]] });
376
388
  } else {
377
389
  const date = this.dateHelpers.applyTimeToDate(this.props.value, time);
378
390
  onChange({ date });
@@ -452,6 +464,8 @@ export default class Calendar<T = Date> extends React.Component<
452
464
  value={this.props.value}
453
465
  peekNextMonth={this.props.peekNextMonth}
454
466
  fixedHeight={this.props.fixedHeight}
467
+ hasLockedBehavior={!!this.props.hasLockedBehavior}
468
+ selectedInput={this.props.selectedInput}
455
469
  />
456
470
  </CalendarContainer>
457
471
  );
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.DENSITY = exports.DEFAULT_MONTHS = exports.WEEKDAYS = exports.STATE_CHANGE_TYPE = exports.ORIENTATION = exports.ISO_MONTH_FORMAT = exports.ISO_FORMAT = exports.DISPLAY_FORMAT = void 0;
6
+ exports.RANGED_CALENDAR_BEHAVIOR = exports.INPUT_ROLE = exports.DENSITY = exports.DEFAULT_MONTHS = exports.WEEKDAYS = exports.STATE_CHANGE_TYPE = exports.ORIENTATION = exports.ISO_MONTH_FORMAT = exports.ISO_FORMAT = exports.DISPLAY_FORMAT = void 0;
7
7
 
8
8
  /*
9
9
  Copyright (c) Uber Technologies, Inc.
@@ -40,4 +40,14 @@ var DENSITY = {
40
40
  high: 'high',
41
41
  default: 'default'
42
42
  };
43
- exports.DENSITY = DENSITY;
43
+ exports.DENSITY = DENSITY;
44
+ var INPUT_ROLE = {
45
+ startDate: 'startDate',
46
+ endDate: 'endDate'
47
+ };
48
+ exports.INPUT_ROLE = INPUT_ROLE;
49
+ var RANGED_CALENDAR_BEHAVIOR = {
50
+ default: 'default',
51
+ locked: 'locked'
52
+ };
53
+ exports.RANGED_CALENDAR_BEHAVIOR = RANGED_CALENDAR_BEHAVIOR;
@@ -33,6 +33,16 @@ export const DENSITY = {
33
33
  default: 'default',
34
34
  };
35
35
 
36
+ export const INPUT_ROLE = {
37
+ startDate: 'startDate',
38
+ endDate: 'endDate',
39
+ };
40
+
41
+ export const RANGED_CALENDAR_BEHAVIOR = {
42
+ default: 'default',
43
+ locked: 'locked',
44
+ };
45
+
36
46
  declare var __DEV__: boolean;
37
47
  declare var __NODE__: boolean;
38
48
  declare var __BROWSER__: boolean;
@@ -27,6 +27,8 @@ var _dateHelpers = _interopRequireDefault(require("./utils/date-helpers.js"));
27
27
 
28
28
  var _dateFnsAdapter = _interopRequireDefault(require("./utils/date-fns-adapter.js"));
29
29
 
30
+ var _constants = require("./constants.js");
31
+
30
32
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
33
 
32
34
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
@@ -83,26 +85,26 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
83
85
 
84
86
  var DEFAULT_DATE_FORMAT = 'yyyy/MM/dd';
85
87
  exports.DEFAULT_DATE_FORMAT = DEFAULT_DATE_FORMAT;
86
- var INPUT_DELIMITER = ' ';
88
+ var INPUT_DELIMITER = '–';
87
89
 
88
90
  var combineSeparatedInputs = function combineSeparatedInputs(newInputValue) {
89
91
  var prevCombinedInputValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
90
- var separatedInput = arguments.length > 2 ? arguments[2] : undefined;
92
+ var inputRole = arguments.length > 2 ? arguments[2] : undefined;
91
93
  var inputValue = newInputValue;
92
94
 
93
- var _prevCombinedInputVal = prevCombinedInputValue.split(INPUT_DELIMITER),
95
+ var _prevCombinedInputVal = prevCombinedInputValue.split(" ".concat(INPUT_DELIMITER, " ")),
94
96
  _prevCombinedInputVal2 = _slicedToArray(_prevCombinedInputVal, 2),
95
97
  _prevCombinedInputVal3 = _prevCombinedInputVal2[0],
96
98
  prevStartDate = _prevCombinedInputVal3 === void 0 ? '' : _prevCombinedInputVal3,
97
99
  _prevCombinedInputVal4 = _prevCombinedInputVal2[1],
98
100
  prevEndDate = _prevCombinedInputVal4 === void 0 ? '' : _prevCombinedInputVal4;
99
101
 
100
- if (separatedInput === 'startDate' && prevEndDate) {
101
- inputValue = "".concat(inputValue, " \u2013 ").concat(prevEndDate);
102
+ if (inputRole === _constants.INPUT_ROLE.startDate && prevEndDate) {
103
+ inputValue = "".concat(inputValue, " ").concat(INPUT_DELIMITER, " ").concat(prevEndDate);
102
104
  }
103
105
 
104
- if (separatedInput === 'endDate') {
105
- inputValue = "".concat(prevStartDate, " \u2013 ").concat(inputValue);
106
+ if (inputRole === _constants.INPUT_ROLE.endDate) {
107
+ inputValue = "".concat(prevStartDate, " ").concat(INPUT_DELIMITER, " ").concat(inputValue);
106
108
  }
107
109
 
108
110
  return inputValue;
@@ -118,7 +120,7 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
118
120
 
119
121
  _classCallCheck(this, Datepicker);
120
122
 
121
- _this = _super.call(this, props); //$FlowFixMe
123
+ _this = _super.call(this, props); //$FlowFixMe[incompatible-call]
122
124
 
123
125
  _defineProperty(_assertThisInitialized(_this), "calendar", void 0);
124
126
 
@@ -131,18 +133,27 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
131
133
  var nextDate = data.date;
132
134
 
133
135
  if (Array.isArray(nextDate) && _this.props.range) {
134
- if (nextDate.length < 2) {
136
+ if (!nextDate[0] || !nextDate[1]) {
135
137
  isOpen = true;
136
138
  isPseudoFocused = true;
137
139
  calendarFocused = null;
138
- } else if (nextDate.length === 2) {
140
+ } else if (nextDate[0] && nextDate[1]) {
139
141
  var _nextDate = nextDate,
140
142
  _nextDate2 = _slicedToArray(_nextDate, 2),
141
143
  start = _nextDate2[0],
142
144
  end = _nextDate2[1];
143
145
 
144
146
  if (_this.dateHelpers.isAfter(start, end)) {
145
- nextDate = [start, start];
147
+ if (_this.hasLockedBehavior()) {
148
+ nextDate = _this.props.value;
149
+ isOpen = true;
150
+ } else {
151
+ nextDate = [start, start];
152
+ }
153
+ } else if (_this.dateHelpers.dateRangeIncludesDates( // $FlowFixMe Cannot call `this.dateHelpers.dateRangeIncludesDates` with `nextDate` bound to the first parameter because read-only array type [1] is incompatible with array type [2]
154
+ nextDate, _this.props.excludeDates)) {
155
+ nextDate = _this.props.value;
156
+ isOpen = true;
146
157
  }
147
158
 
148
159
  if (_this.state.lastActiveElm) {
@@ -234,11 +245,12 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
234
245
  return _this.formatDate(date, formatString);
235
246
  });
236
247
 
237
- _defineProperty(_assertThisInitialized(_this), "open", function () {
248
+ _defineProperty(_assertThisInitialized(_this), "open", function (inputRole) {
238
249
  _this.setState({
239
250
  isOpen: true,
240
251
  isPseudoFocused: true,
241
- calendarFocused: false
252
+ calendarFocused: false,
253
+ selectedInput: inputRole
242
254
  }, _this.props.onOpen);
243
255
  });
244
256
 
@@ -247,6 +259,7 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
247
259
 
248
260
  _this.setState({
249
261
  isOpen: false,
262
+ selectedInput: null,
250
263
  isPseudoFocused: isPseudoFocused,
251
264
  calendarFocused: false
252
265
  }, _this.props.onClose);
@@ -282,14 +295,14 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
282
295
  }
283
296
 
284
297
  if (range && !separateRangeInputs) {
285
- return '9999/99/99 9999/99/99';
298
+ return "9999/99/99 ".concat(INPUT_DELIMITER, " 9999/99/99");
286
299
  }
287
300
 
288
301
  return '9999/99/99';
289
302
  });
290
303
 
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;
304
+ _defineProperty(_assertThisInitialized(_this), "handleInputChange", function (event, inputRole) {
305
+ var inputValue = _this.props.range && _this.props.separateRangeInputs ? combineSeparatedInputs(event.currentTarget.value, _this.state.inputValue, inputRole) : event.currentTarget.value;
293
306
 
294
307
  var mask = _this.getMask();
295
308
 
@@ -322,7 +335,7 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
322
335
  };
323
336
 
324
337
  if (_this.props.range && typeof _this.props.displayValueAtRangeIndex !== 'number') {
325
- var _this$normalizeDashes = _this.normalizeDashes(inputValue).split(INPUT_DELIMITER),
338
+ var _this$normalizeDashes = _this.normalizeDashes(inputValue).split(" ".concat(INPUT_DELIMITER, " ")),
326
339
  _this$normalizeDashes2 = _slicedToArray(_this$normalizeDashes, 2),
327
340
  left = _this$normalizeDashes2[0],
328
341
  right = _this$normalizeDashes2[1];
@@ -454,13 +467,18 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
454
467
 
455
468
  _defineProperty(_assertThisInitialized(_this), "normalizeDashes", function (inputValue) {
456
469
  // replacing both hyphens and em-dashes with en-dashes
457
- return inputValue.replace(/-/g, '–').replace(/—/g, '–');
470
+ return inputValue.replace(/-/g, INPUT_DELIMITER).replace(/—/g, INPUT_DELIMITER);
471
+ });
472
+
473
+ _defineProperty(_assertThisInitialized(_this), "hasLockedBehavior", function () {
474
+ return _this.props.rangedCalendarBehavior === _constants.RANGED_CALENDAR_BEHAVIOR.locked && _this.props.range && _this.props.separateRangeInputs;
458
475
  });
459
476
 
460
477
  _this.dateHelpers = new _dateHelpers.default(props.adapter);
461
478
  _this.state = {
462
479
  calendarFocused: false,
463
480
  isOpen: false,
481
+ selectedInput: null,
464
482
  isPseudoFocused: false,
465
483
  lastActiveElm: null,
466
484
  inputValue: _this.formatDisplayValue(props.value) || ''
@@ -469,6 +487,11 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
469
487
  }
470
488
 
471
489
  _createClass(Datepicker, [{
490
+ key: "getNullDatePlaceholder",
491
+ value: function getNullDatePlaceholder(formatString) {
492
+ return (this.getMask() || formatString).split(INPUT_DELIMITER)[0].replace(/[0-9]|[a-z]/g, ' ');
493
+ }
494
+ }, {
472
495
  key: "formatDate",
473
496
  value: function formatDate(date, formatString) {
474
497
  var _this2 = this;
@@ -485,10 +508,14 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
485
508
  return '';
486
509
  } else if (Array.isArray(date) && !date[0] && !date[1]) {
487
510
  return '';
511
+ } else if (Array.isArray(date) && !date[0] && date[1]) {
512
+ var endDate = format(date[1]);
513
+ var startDate = this.getNullDatePlaceholder(formatString);
514
+ return [startDate, endDate].join(" ".concat(INPUT_DELIMITER, " "));
488
515
  } else if (Array.isArray(date)) {
489
516
  return date.map(function (day) {
490
- return format(day);
491
- }).join(INPUT_DELIMITER);
517
+ return day ? format(day) : '';
518
+ }).join(" ".concat(INPUT_DELIMITER, " "));
492
519
  } else {
493
520
  return format(date);
494
521
  }
@@ -504,7 +531,7 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
504
531
  }
505
532
  }, {
506
533
  key: "renderInputComponent",
507
- value: function renderInputComponent(locale, separatedInput) {
534
+ value: function renderInputComponent(locale, inputRole) {
508
535
  var _this3 = this;
509
536
 
510
537
  var _this$props$overrides = this.props.overrides,
@@ -515,19 +542,19 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
515
542
  InputComponent = _getOverrides2[0],
516
543
  inputProps = _getOverrides2[1];
517
544
 
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';
545
+ var placeholder = this.props.placeholder || this.props.placeholder === '' ? this.props.placeholder : this.props.range && !this.props.separateRangeInputs ? "YYYY/MM/DD ".concat(INPUT_DELIMITER, " YYYY/MM/DD") : 'YYYY/MM/DD';
519
546
 
520
- var _split = (this.state.inputValue || '').split(INPUT_DELIMITER),
547
+ var _split = (this.state.inputValue || '').split(" ".concat(INPUT_DELIMITER, " ")),
521
548
  _split2 = _slicedToArray(_split, 2),
522
549
  _split2$ = _split2[0],
523
550
  startDate = _split2$ === void 0 ? '' : _split2$,
524
551
  _split2$2 = _split2[1],
525
552
  endDate = _split2$2 === void 0 ? '' : _split2$2;
526
553
 
527
- var value = separatedInput === 'startDate' ? startDate : separatedInput === 'endDate' ? endDate : this.state.inputValue;
554
+ var value = inputRole === _constants.INPUT_ROLE.startDate ? startDate : inputRole === _constants.INPUT_ROLE.endDate ? endDate : this.state.inputValue;
528
555
 
529
556
  var onChange = function onChange(event) {
530
- return _this3.handleInputChange(event, separatedInput);
557
+ return _this3.handleInputChange(event, inputRole);
531
558
  };
532
559
 
533
560
  return /*#__PURE__*/React.createElement(InputComponent, _extends({
@@ -541,7 +568,9 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
541
568
  disabled: this.props.disabled,
542
569
  size: this.props.size,
543
570
  value: value,
544
- onFocus: this.open,
571
+ onFocus: function onFocus() {
572
+ return _this3.open(inputRole);
573
+ },
545
574
  onBlur: this.handleInputBlur,
546
575
  onKeyDown: this.handleKeyDown,
547
576
  onChange: onChange,
@@ -604,11 +633,13 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
604
633
  trapTabbing: true,
605
634
  value: _this4.props.value
606
635
  }, _this4.props, {
607
- onChange: _this4.onChange
636
+ onChange: _this4.onChange,
637
+ selectedInput: _this4.state.selectedInput,
638
+ hasLockedBehavior: _this4.hasLockedBehavior()
608
639
  }))
609
640
  }, popoverProps), /*#__PURE__*/React.createElement(InputWrapper, _extends({}, inputWrapperProps, {
610
641
  $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", {
642
+ }), _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, _constants.INPUT_ROLE.startDate)), /*#__PURE__*/React.createElement(EndDate, endDateProps, /*#__PURE__*/React.createElement(InputLabel, inputLabelProps, endDateLabel), _this4.renderInputComponent(locale, _constants.INPUT_ROLE.endDate))) : /*#__PURE__*/React.createElement(React.Fragment, null, _this4.renderInputComponent(locale)))), /*#__PURE__*/React.createElement("p", {
612
643
  id: _this4.props['aria-describedby'],
613
644
  style: {
614
645
  position: 'fixed',
@@ -639,11 +670,11 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
639
670
  clipPath: 'inset(100%)'
640
671
  }
641
672
  }, // No date selected
642
- !_this4.props.value || Array.isArray(_this4.props.value) && !_this4.props.value.length ? '' : // Date selected in a non-range picker
673
+ !_this4.props.value || Array.isArray(_this4.props.value) && !_this4.props.value[0] && !_this4.props.value[1] ? '' : // Date selected in a non-range picker
643
674
  !Array.isArray(_this4.props.value) ? (0, _i18nInterpolation.default)(locale.datepicker.selectedDate, {
644
675
  date: _this4.state.inputValue || ''
645
676
  }) : // Start and end dates are selected in a range picker
646
- _this4.props.value.length > 1 ? (0, _i18nInterpolation.default)(locale.datepicker.selectedDateRange, {
677
+ _this4.props.value[0] && _this4.props.value[1] ? (0, _i18nInterpolation.default)(locale.datepicker.selectedDateRange, {
647
678
  startDate: _this4.formatDisplayValue(_this4.props.value[0]),
648
679
  endDate: _this4.formatDisplayValue( // $FlowFixMe
649
680
  _this4.props.value[1])
@@ -19,23 +19,26 @@ import {
19
19
  StyledStartDate,
20
20
  StyledEndDate,
21
21
  } from './styled-components.js';
22
- import type { DatepickerPropsT } from './types.js';
22
+ import type { DatepickerPropsT, DateValueT, InputRoleT } 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';
26
+ import { INPUT_ROLE, RANGED_CALENDAR_BEHAVIOR } from './constants.js';
26
27
 
27
28
  export const DEFAULT_DATE_FORMAT = 'yyyy/MM/dd';
28
29
 
29
- const INPUT_DELIMITER = ' ';
30
+ const INPUT_DELIMITER = '–';
30
31
 
31
- const combineSeparatedInputs = (newInputValue, prevCombinedInputValue = '', separatedInput) => {
32
+ const combineSeparatedInputs = (newInputValue, prevCombinedInputValue = '', inputRole) => {
32
33
  let inputValue = newInputValue;
33
- const [prevStartDate = '', prevEndDate = ''] = prevCombinedInputValue.split(INPUT_DELIMITER);
34
- if (separatedInput === 'startDate' && prevEndDate) {
35
- inputValue = `${inputValue} – ${prevEndDate}`;
34
+ const [prevStartDate = '', prevEndDate = ''] = prevCombinedInputValue.split(
35
+ ` ${INPUT_DELIMITER} `
36
+ );
37
+ if (inputRole === INPUT_ROLE.startDate && prevEndDate) {
38
+ inputValue = `${inputValue} ${INPUT_DELIMITER} ${prevEndDate}`;
36
39
  }
37
- if (separatedInput === 'endDate') {
38
- inputValue = `${prevStartDate} ${inputValue}`;
40
+ if (inputRole === INPUT_ROLE.endDate) {
41
+ inputValue = `${prevStartDate} ${INPUT_DELIMITER} ${inputValue}`;
39
42
  }
40
43
  return inputValue;
41
44
  };
@@ -43,6 +46,7 @@ const combineSeparatedInputs = (newInputValue, prevCombinedInputValue = '', sepa
43
46
  type StateT = {|
44
47
  calendarFocused: boolean,
45
48
  isOpen: boolean,
49
+ selectedInput: ?InputRoleT,
46
50
  isPseudoFocused: boolean,
47
51
  lastActiveElm: ?HTMLElement,
48
52
  inputValue?: string,
@@ -62,32 +66,47 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
62
66
 
63
67
  constructor(props: DatepickerPropsT<T>) {
64
68
  super(props);
65
- //$FlowFixMe
69
+ //$FlowFixMe[incompatible-call]
66
70
  this.dateHelpers = new DateHelpers(props.adapter);
67
71
  this.state = {
68
72
  calendarFocused: false,
69
73
  isOpen: false,
74
+ selectedInput: null,
70
75
  isPseudoFocused: false,
71
76
  lastActiveElm: null,
72
77
  inputValue: this.formatDisplayValue(props.value) || '',
73
78
  };
74
79
  }
75
80
 
76
- onChange: ({ date: ?T | Array<T> }) => void = (data) => {
81
+ onChange: ({ date: DateValueT<T> }) => void = (data) => {
77
82
  let isOpen = false;
78
83
  let isPseudoFocused = false;
79
84
  let calendarFocused = false;
80
85
  let nextDate = data.date;
81
86
 
82
87
  if (Array.isArray(nextDate) && this.props.range) {
83
- if (nextDate.length < 2) {
88
+ if (!nextDate[0] || !nextDate[1]) {
84
89
  isOpen = true;
85
90
  isPseudoFocused = true;
86
91
  calendarFocused = null;
87
- } else if (nextDate.length === 2) {
92
+ } else if (nextDate[0] && nextDate[1]) {
88
93
  const [start, end] = nextDate;
89
94
  if (this.dateHelpers.isAfter(start, end)) {
90
- nextDate = [start, start];
95
+ if (this.hasLockedBehavior()) {
96
+ nextDate = this.props.value;
97
+ isOpen = true;
98
+ } else {
99
+ nextDate = [start, start];
100
+ }
101
+ } else if (
102
+ this.dateHelpers.dateRangeIncludesDates(
103
+ // $FlowFixMe Cannot call `this.dateHelpers.dateRangeIncludesDates` with `nextDate` bound to the first parameter because read-only array type [1] is incompatible with array type [2]
104
+ nextDate,
105
+ this.props.excludeDates
106
+ )
107
+ ) {
108
+ nextDate = this.props.value;
109
+ isOpen = true;
91
110
  }
92
111
 
93
112
  if (this.state.lastActiveElm) {
@@ -134,25 +153,34 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
134
153
  this.props.onChange && this.props.onChange({ date: nextDate });
135
154
  };
136
155
 
137
- formatDate(date: ?T | Array<T>, formatString: string) {
138
- const format = (date) => {
156
+ getNullDatePlaceholder(formatString: string) {
157
+ return (this.getMask() || formatString).split(INPUT_DELIMITER)[0].replace(/[0-9]|[a-z]/g, ' ');
158
+ }
159
+
160
+ formatDate(date: DateValueT<T>, formatString: string) {
161
+ const format = (date: T) => {
139
162
  if (formatString === DEFAULT_DATE_FORMAT) {
140
163
  return this.dateHelpers.format(date, 'slashDate', this.props.locale);
141
164
  }
142
165
  return this.dateHelpers.formatDate(date, formatString, this.props.locale);
143
166
  };
167
+
144
168
  if (!date) {
145
169
  return '';
146
170
  } else if (Array.isArray(date) && !date[0] && !date[1]) {
147
171
  return '';
172
+ } else if (Array.isArray(date) && !date[0] && date[1]) {
173
+ const endDate = format(date[1]);
174
+ const startDate = this.getNullDatePlaceholder(formatString);
175
+ return [startDate, endDate].join(` ${INPUT_DELIMITER} `);
148
176
  } else if (Array.isArray(date)) {
149
- return date.map((day) => format(day)).join(INPUT_DELIMITER);
177
+ return date.map((day) => (day ? format(day) : '')).join(` ${INPUT_DELIMITER} `);
150
178
  } else {
151
179
  return format(date);
152
180
  }
153
181
  }
154
182
 
155
- formatDisplayValue: (?T | Array<T>) => string = (date: ?T | Array<T>) => {
183
+ formatDisplayValue: (DateValueT<T>) => string = (date: DateValueT<T>) => {
156
184
  const { displayValueAtRangeIndex, formatDisplayValue, range } = this.props;
157
185
  const formatString = this.normalizeDashes(this.props.formatString);
158
186
 
@@ -181,12 +209,13 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
181
209
  return this.formatDate(date, formatString);
182
210
  };
183
211
 
184
- open = () => {
212
+ open = (inputRole?: InputRoleT) => {
185
213
  this.setState(
186
214
  {
187
215
  isOpen: true,
188
216
  isPseudoFocused: true,
189
217
  calendarFocused: false,
218
+ selectedInput: inputRole,
190
219
  },
191
220
  this.props.onOpen
192
221
  );
@@ -197,6 +226,7 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
197
226
  this.setState(
198
227
  {
199
228
  isOpen: false,
229
+ selectedInput: null,
200
230
  isPseudoFocused,
201
231
  calendarFocused: false,
202
232
  },
@@ -229,19 +259,16 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
229
259
  }
230
260
 
231
261
  if (range && !separateRangeInputs) {
232
- return '9999/99/99 9999/99/99';
262
+ return `9999/99/99 ${INPUT_DELIMITER} 9999/99/99`;
233
263
  }
234
264
 
235
265
  return '9999/99/99';
236
266
  };
237
267
 
238
- handleInputChange = (
239
- event: SyntheticInputEvent<HTMLInputElement>,
240
- separatedInput?: 'startDate' | 'endDate'
241
- ) => {
268
+ handleInputChange = (event: SyntheticInputEvent<HTMLInputElement>, inputRole?: InputRoleT) => {
242
269
  const inputValue =
243
270
  this.props.range && this.props.separateRangeInputs
244
- ? combineSeparatedInputs(event.currentTarget.value, this.state.inputValue, separatedInput)
271
+ ? combineSeparatedInputs(event.currentTarget.value, this.state.inputValue, inputRole)
245
272
  : event.currentTarget.value;
246
273
 
247
274
  const mask = this.getMask();
@@ -270,7 +297,7 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
270
297
  };
271
298
 
272
299
  if (this.props.range && typeof this.props.displayValueAtRangeIndex !== 'number') {
273
- const [left, right] = this.normalizeDashes(inputValue).split(INPUT_DELIMITER);
300
+ const [left, right] = this.normalizeDashes(inputValue).split(` ${INPUT_DELIMITER} `);
274
301
 
275
302
  let startDate = this.dateHelpers.date(left);
276
303
  let endDate = this.dateHelpers.date(right);
@@ -370,7 +397,15 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
370
397
 
371
398
  normalizeDashes = (inputValue: string) => {
372
399
  // replacing both hyphens and em-dashes with en-dashes
373
- return inputValue.replace(/-/g, '–').replace(/—/g, '–');
400
+ return inputValue.replace(/-/g, INPUT_DELIMITER).replace(/—/g, INPUT_DELIMITER);
401
+ };
402
+
403
+ hasLockedBehavior = () => {
404
+ return (
405
+ this.props.rangedCalendarBehavior === RANGED_CALENDAR_BEHAVIOR.locked &&
406
+ this.props.range &&
407
+ this.props.separateRangeInputs
408
+ );
374
409
  };
375
410
 
376
411
  componentDidUpdate(prevProps: DatepickerPropsT<T>) {
@@ -381,7 +416,7 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
381
416
  }
382
417
  }
383
418
 
384
- renderInputComponent(locale: LocaleT, separatedInput?: 'startDate' | 'endDate') {
419
+ renderInputComponent(locale: LocaleT, inputRole?: InputRoleT) {
385
420
  const { overrides = {} } = this.props;
386
421
 
387
422
  const [InputComponent, inputProps] = getOverrides(overrides.Input, MaskedInput);
@@ -390,19 +425,21 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
390
425
  this.props.placeholder || this.props.placeholder === ''
391
426
  ? this.props.placeholder
392
427
  : this.props.range && !this.props.separateRangeInputs
393
- ? 'YYYY/MM/DD YYYY/MM/DD'
428
+ ? `YYYY/MM/DD ${INPUT_DELIMITER} YYYY/MM/DD`
394
429
  : 'YYYY/MM/DD';
395
430
 
396
- const [startDate = '', endDate = ''] = (this.state.inputValue || '').split(INPUT_DELIMITER);
431
+ const [startDate = '', endDate = ''] = (this.state.inputValue || '').split(
432
+ ` ${INPUT_DELIMITER} `
433
+ );
397
434
 
398
435
  const value =
399
- separatedInput === 'startDate'
436
+ inputRole === INPUT_ROLE.startDate
400
437
  ? startDate
401
- : separatedInput === 'endDate'
438
+ : inputRole === INPUT_ROLE.endDate
402
439
  ? endDate
403
440
  : this.state.inputValue;
404
441
 
405
- const onChange = (event) => this.handleInputChange(event, separatedInput);
442
+ const onChange = (event) => this.handleInputChange(event, inputRole);
406
443
 
407
444
  return (
408
445
  <InputComponent
@@ -419,7 +456,7 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
419
456
  disabled={this.props.disabled}
420
457
  size={this.props.size}
421
458
  value={value}
422
- onFocus={this.open}
459
+ onFocus={() => this.open(inputRole)}
423
460
  onBlur={this.handleInputBlur}
424
461
  onKeyDown={this.handleKeyDown}
425
462
  onChange={onChange}
@@ -463,6 +500,8 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
463
500
  value={this.props.value}
464
501
  {...this.props}
465
502
  onChange={this.onChange}
503
+ selectedInput={this.state.selectedInput}
504
+ hasLockedBehavior={this.hasLockedBehavior()}
466
505
  />
467
506
  }
468
507
  {...popoverProps}
@@ -476,11 +515,11 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
476
515
  <>
477
516
  <StartDate {...startDateProps}>
478
517
  <InputLabel {...inputLabelProps}>{startDateLabel}</InputLabel>
479
- {this.renderInputComponent(locale, 'startDate')}
518
+ {this.renderInputComponent(locale, INPUT_ROLE.startDate)}
480
519
  </StartDate>
481
520
  <EndDate {...endDateProps}>
482
521
  <InputLabel {...inputLabelProps}>{endDateLabel}</InputLabel>
483
- {this.renderInputComponent(locale, 'endDate')}
522
+ {this.renderInputComponent(locale, INPUT_ROLE.endDate)}
484
523
  </EndDate>
485
524
  </>
486
525
  ) : (
@@ -524,7 +563,8 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
524
563
  >
525
564
  {
526
565
  // No date selected
527
- !this.props.value || (Array.isArray(this.props.value) && !this.props.value.length)
566
+ !this.props.value ||
567
+ (Array.isArray(this.props.value) && !this.props.value[0] && !this.props.value[1])
528
568
  ? ''
529
569
  : // Date selected in a non-range picker
530
570
  !Array.isArray(this.props.value)
@@ -532,7 +572,7 @@ export default class Datepicker<T = Date> extends React.Component<DatepickerProp
532
572
  date: this.state.inputValue || '',
533
573
  })
534
574
  : // Start and end dates are selected in a range picker
535
- this.props.value.length > 1
575
+ this.props.value[0] && this.props.value[1]
536
576
  ? getInterpolatedString(locale.datepicker.selectedDateRange, {
537
577
  startDate: this.formatDisplayValue(this.props.value[0]),
538
578
  endDate: this.formatDisplayValue(