baseui 10.12.1 → 11.0.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 (307) 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 +28 -15
  40. package/datepicker/calendar.js.flow +31 -14
  41. package/datepicker/constants.js +12 -2
  42. package/datepicker/constants.js.flow +10 -0
  43. package/datepicker/datepicker.js +117 -86
  44. package/datepicker/datepicker.js.flow +123 -66
  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-calendar.js +6 -1
  51. package/datepicker/stateful-calendar.js.flow +8 -1
  52. package/datepicker/stateful-container.js +23 -2
  53. package/datepicker/stateful-container.js.flow +17 -3
  54. package/datepicker/stateful-datepicker.js +6 -1
  55. package/datepicker/stateful-datepicker.js.flow +7 -1
  56. package/datepicker/styled-components.js +23 -1
  57. package/datepicker/styled-components.js.flow +12 -2
  58. package/datepicker/types.js.flow +46 -43
  59. package/datepicker/utils/date-helpers.js +30 -0
  60. package/datepicker/utils/date-helpers.js.flow +12 -0
  61. package/datepicker/week.js +3 -1
  62. package/datepicker/week.js.flow +2 -0
  63. package/es/accordion/accordion.js +52 -12
  64. package/es/accordion/panel.js +7 -5
  65. package/es/accordion/stateless-accordion.js +2 -4
  66. package/es/button/constants.js +1 -2
  67. package/es/button/styled-components.js +2 -29
  68. package/es/checkbox/checkbox.js +7 -32
  69. package/es/checkbox/constants.js +2 -1
  70. package/es/checkbox/index.js +1 -1
  71. package/es/checkbox/styled-components.js +51 -146
  72. package/es/data-table/column-categorical.js +1 -1
  73. package/es/data-table/column-datetime.js +1 -1
  74. package/es/data-table/column.js +6 -2
  75. package/es/data-table/data-table.js +6 -2
  76. package/es/data-table/header-cell.js +3 -0
  77. package/es/data-table/stateful-data-table.js +2 -1
  78. package/es/datepicker/calendar.js +28 -15
  79. package/es/datepicker/constants.js +8 -0
  80. package/es/datepicker/datepicker.js +106 -79
  81. package/es/datepicker/day.js +77 -34
  82. package/es/datepicker/month.js +3 -1
  83. package/es/datepicker/stateful-calendar.js +6 -1
  84. package/es/datepicker/stateful-container.js +22 -2
  85. package/es/datepicker/stateful-datepicker.js +6 -1
  86. package/es/datepicker/styled-components.js +8 -2
  87. package/es/datepicker/types.js +1 -1
  88. package/es/datepicker/utils/date-helpers.js +16 -0
  89. package/es/datepicker/week.js +3 -1
  90. package/es/file-uploader/file-uploader.js +4 -4
  91. package/es/form-control/styled-components.js +0 -1
  92. package/es/header-navigation/styled-components.js +3 -3
  93. package/es/helpers/overrides.js +1 -2
  94. package/es/input/styled-components.js +4 -4
  95. package/es/layer/layer.js +4 -4
  96. package/es/list/list-item.js +5 -1
  97. package/es/list/menu-adapter.js +4 -0
  98. package/es/locale/index.js +0 -7
  99. package/es/menu/stateful-container.js +0 -1
  100. package/es/menu/styled-components.js +1 -1
  101. package/es/modal/index.js +1 -1
  102. package/es/modal/modal.js +19 -65
  103. package/es/modal/styled-components.js +12 -48
  104. package/es/phone-input/default-props.js +1 -1
  105. package/es/phone-input/index.js +0 -4
  106. package/es/phone-input/phone-input-lite.js +55 -31
  107. package/es/radio/radio.js +1 -7
  108. package/es/radio/radiogroup.js +3 -28
  109. package/es/radio/styled-components.js +4 -5
  110. package/es/rating/styled-components.js +3 -3
  111. package/es/select/index.js +1 -2
  112. package/es/select/select-component.js +20 -20
  113. package/es/select/styled-components.js +21 -17
  114. package/es/snackbar/snackbar-context.js +1 -1
  115. package/es/snackbar/styled-components.js +2 -2
  116. package/es/spinner/index.js +3 -9
  117. package/es/spinner/styled-components.js +2 -32
  118. package/es/table/filter.js +3 -3
  119. package/es/tag/styled-components.js +1 -1
  120. package/es/themes/dark-theme/color-component-tokens.js +0 -38
  121. package/es/themes/dark-theme/color-tokens.js +0 -2
  122. package/es/themes/dark-theme/create-dark-theme.js +0 -2
  123. package/es/themes/dark-theme/dark-theme.js +0 -2
  124. package/es/themes/light-theme/color-component-tokens.js +0 -38
  125. package/es/themes/light-theme/color-tokens.js +0 -2
  126. package/es/themes/light-theme/create-light-theme.js +0 -2
  127. package/es/themes/light-theme/light-theme.js +0 -2
  128. package/es/timepicker/timepicker.js +1 -8
  129. package/es/typography/index.js +1 -31
  130. package/esm/accordion/accordion.js +60 -13
  131. package/esm/accordion/panel.js +7 -6
  132. package/esm/accordion/stateless-accordion.js +2 -4
  133. package/esm/button/constants.js +1 -2
  134. package/esm/button/styled-components.js +2 -29
  135. package/esm/checkbox/checkbox.js +7 -30
  136. package/esm/checkbox/constants.js +2 -1
  137. package/esm/checkbox/index.js +1 -1
  138. package/esm/checkbox/styled-components.js +52 -147
  139. package/esm/data-table/column-categorical.js +1 -1
  140. package/esm/data-table/column-datetime.js +1 -1
  141. package/esm/data-table/column.js +6 -2
  142. package/esm/data-table/data-table.js +10 -2
  143. package/esm/data-table/header-cell.js +3 -0
  144. package/esm/data-table/stateful-data-table.js +2 -1
  145. package/esm/datepicker/calendar.js +28 -15
  146. package/esm/datepicker/constants.js +8 -0
  147. package/esm/datepicker/datepicker.js +116 -86
  148. package/esm/datepicker/day.js +84 -34
  149. package/esm/datepicker/month.js +3 -1
  150. package/esm/datepicker/stateful-calendar.js +6 -1
  151. package/esm/datepicker/stateful-container.js +23 -2
  152. package/esm/datepicker/stateful-datepicker.js +6 -1
  153. package/esm/datepicker/styled-components.js +24 -2
  154. package/esm/datepicker/types.js +1 -1
  155. package/esm/datepicker/utils/date-helpers.js +30 -0
  156. package/esm/datepicker/week.js +3 -1
  157. package/esm/file-uploader/file-uploader.js +4 -4
  158. package/esm/form-control/styled-components.js +0 -1
  159. package/esm/header-navigation/styled-components.js +3 -3
  160. package/esm/helpers/overrides.js +1 -2
  161. package/esm/input/styled-components.js +4 -4
  162. package/esm/layer/layer.js +4 -4
  163. package/esm/list/list-item.js +5 -1
  164. package/esm/list/menu-adapter.js +4 -0
  165. package/esm/locale/index.js +0 -7
  166. package/esm/menu/stateful-container.js +0 -1
  167. package/esm/menu/styled-components.js +1 -1
  168. package/esm/modal/index.js +1 -1
  169. package/esm/modal/modal.js +28 -71
  170. package/esm/modal/styled-components.js +6 -38
  171. package/esm/phone-input/default-props.js +1 -1
  172. package/esm/phone-input/index.js +0 -4
  173. package/esm/phone-input/phone-input-lite.js +60 -37
  174. package/esm/radio/radio.js +1 -7
  175. package/esm/radio/radiogroup.js +3 -28
  176. package/esm/radio/styled-components.js +4 -5
  177. package/esm/rating/styled-components.js +3 -3
  178. package/esm/select/index.js +1 -2
  179. package/esm/select/select-component.js +20 -20
  180. package/esm/select/styled-components.js +21 -14
  181. package/esm/snackbar/snackbar-context.js +1 -1
  182. package/esm/snackbar/styled-components.js +2 -2
  183. package/esm/spinner/index.js +3 -9
  184. package/esm/spinner/styled-components.js +2 -40
  185. package/esm/table/filter.js +3 -3
  186. package/esm/tag/styled-components.js +1 -1
  187. package/esm/themes/dark-theme/color-component-tokens.js +0 -38
  188. package/esm/themes/dark-theme/color-tokens.js +0 -2
  189. package/esm/themes/dark-theme/create-dark-theme.js +1 -2
  190. package/esm/themes/dark-theme/dark-theme.js +1 -2
  191. package/esm/themes/light-theme/color-component-tokens.js +0 -38
  192. package/esm/themes/light-theme/color-tokens.js +0 -2
  193. package/esm/themes/light-theme/create-light-theme.js +1 -2
  194. package/esm/themes/light-theme/light-theme.js +1 -2
  195. package/esm/timepicker/timepicker.js +1 -8
  196. package/esm/typography/index.js +1 -35
  197. package/file-uploader/file-uploader.js +3 -3
  198. package/file-uploader/file-uploader.js.flow +4 -4
  199. package/form-control/index.d.ts +9 -0
  200. package/form-control/styled-components.js +0 -1
  201. package/form-control/styled-components.js.flow +0 -1
  202. package/header-navigation/styled-components.js +3 -3
  203. package/header-navigation/styled-components.js.flow +3 -3
  204. package/helpers/overrides.js +1 -2
  205. package/helpers/overrides.js.flow +1 -1
  206. package/input/index.d.ts +5 -9
  207. package/input/styled-components.js +4 -4
  208. package/input/styled-components.js.flow +4 -4
  209. package/layer/layer.js +4 -4
  210. package/layer/layer.js.flow +4 -3
  211. package/list/list-item.js +5 -1
  212. package/list/list-item.js.flow +4 -0
  213. package/list/menu-adapter.js +4 -0
  214. package/list/menu-adapter.js.flow +4 -0
  215. package/list/types.js.flow +4 -0
  216. package/locale/index.js +0 -7
  217. package/locale/index.js.flow +0 -7
  218. package/locale.ts +0 -1
  219. package/menu/index.d.ts +1 -3
  220. package/menu/stateful-container.js +0 -1
  221. package/menu/stateful-container.js.flow +0 -1
  222. package/menu/styled-components.js +1 -1
  223. package/menu/styled-components.js.flow +1 -1
  224. package/modal/index.d.ts +4 -6
  225. package/modal/index.js +0 -6
  226. package/modal/index.js.flow +0 -1
  227. package/modal/modal.js +27 -70
  228. package/modal/modal.js.flow +17 -83
  229. package/modal/styled-components.js +7 -40
  230. package/modal/styled-components.js.flow +12 -44
  231. package/modal/types.js.flow +1 -10
  232. package/package.json +3 -2
  233. package/phone-input/default-props.js +1 -1
  234. package/phone-input/default-props.js.flow +1 -1
  235. package/phone-input/index.d.ts +0 -1
  236. package/phone-input/index.js +0 -36
  237. package/phone-input/index.js.flow +0 -4
  238. package/phone-input/phone-input-lite.js +63 -38
  239. package/phone-input/phone-input-lite.js.flow +66 -44
  240. package/radio/index.d.ts +4 -9
  241. package/radio/radio.js +1 -7
  242. package/radio/radio.js.flow +1 -8
  243. package/radio/radiogroup.js +3 -28
  244. package/radio/radiogroup.js.flow +2 -26
  245. package/radio/styled-components.js +4 -5
  246. package/radio/styled-components.js.flow +3 -4
  247. package/radio/types.js.flow +4 -15
  248. package/rating/styled-components.js +3 -3
  249. package/rating/styled-components.js.flow +3 -3
  250. package/select/index.d.ts +0 -2
  251. package/select/index.js +0 -6
  252. package/select/index.js.flow +0 -2
  253. package/select/select-component.js +23 -24
  254. package/select/select-component.js.flow +25 -14
  255. package/select/styled-components.js +23 -17
  256. package/select/styled-components.js.flow +17 -12
  257. package/snackbar/snackbar-context.js +1 -1
  258. package/snackbar/snackbar-context.js.flow +1 -1
  259. package/snackbar/styled-components.js +1 -1
  260. package/snackbar/styled-components.js.flow +11 -11
  261. package/spinner/index.d.ts +5 -18
  262. package/spinner/index.js +2 -68
  263. package/spinner/index.js.flow +2 -27
  264. package/spinner/styled-components.js +9 -45
  265. package/spinner/styled-components.js.flow +2 -34
  266. package/spinner/types.js.flow +1 -19
  267. package/styles/types.js.flow +0 -2
  268. package/table/filter.js +3 -3
  269. package/table/filter.js.flow +3 -3
  270. package/tag/styled-components.js +1 -1
  271. package/tag/styled-components.js.flow +1 -1
  272. package/tag/types.js.flow +1 -1
  273. package/theme.ts +0 -81
  274. package/themes/dark-theme/color-component-tokens.js +0 -38
  275. package/themes/dark-theme/color-component-tokens.js.flow +0 -42
  276. package/themes/dark-theme/color-tokens.js +0 -2
  277. package/themes/dark-theme/color-tokens.js.flow +0 -2
  278. package/themes/dark-theme/create-dark-theme.js +1 -3
  279. package/themes/dark-theme/create-dark-theme.js.flow +0 -2
  280. package/themes/dark-theme/dark-theme.js +1 -3
  281. package/themes/dark-theme/dark-theme.js.flow +0 -2
  282. package/themes/light-theme/color-component-tokens.js +0 -38
  283. package/themes/light-theme/color-component-tokens.js.flow +0 -43
  284. package/themes/light-theme/color-tokens.js +0 -2
  285. package/themes/light-theme/color-tokens.js.flow +0 -2
  286. package/themes/light-theme/create-light-theme.js +1 -3
  287. package/themes/light-theme/create-light-theme.js.flow +0 -2
  288. package/themes/light-theme/light-theme.js +1 -3
  289. package/themes/light-theme/light-theme.js.flow +0 -2
  290. package/themes/types.js.flow +0 -68
  291. package/timepicker/timepicker.js +1 -8
  292. package/timepicker/timepicker.js.flow +4 -10
  293. package/typography/index.d.ts +0 -23
  294. package/typography/index.js +2 -57
  295. package/typography/index.js.flow +0 -31
  296. package/es/spinner/spinner.js +0 -68
  297. package/es/themes/dark-theme/color-deprecated-semantic-tokens.js +0 -35
  298. package/es/themes/light-theme/color-deprecated-semantic-tokens.js +0 -35
  299. package/esm/spinner/spinner.js +0 -125
  300. package/esm/themes/dark-theme/color-deprecated-semantic-tokens.js +0 -38
  301. package/esm/themes/light-theme/color-deprecated-semantic-tokens.js +0 -38
  302. package/spinner/spinner.js +0 -136
  303. package/spinner/spinner.js.flow +0 -75
  304. package/themes/dark-theme/color-deprecated-semantic-tokens.js +0 -50
  305. package/themes/dark-theme/color-deprecated-semantic-tokens.js.flow +0 -42
  306. package/themes/light-theme/color-deprecated-semantic-tokens.js +0 -50
  307. package/themes/light-theme/color-deprecated-semantic-tokens.js.flow +0 -42
@@ -2,6 +2,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
2
2
 
3
3
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
4
 
5
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
6
+
7
+ 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; }
8
+
5
9
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
6
10
 
7
11
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -10,10 +14,6 @@ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.it
10
14
 
11
15
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
12
16
 
13
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
14
-
15
- 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; }
16
-
17
17
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
18
18
 
19
19
  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); } }
@@ -64,27 +64,28 @@ import { LocaleContext } from '../locale/index.js';
64
64
  import { StyledInputWrapper, StyledInputLabel, StyledStartDate, StyledEndDate } from './styled-components.js';
65
65
  import DateHelpers from './utils/date-helpers.js';
66
66
  import dateFnsAdapter from './utils/date-fns-adapter.js';
67
+ import { INPUT_ROLE, RANGED_CALENDAR_BEHAVIOR } from './constants.js';
67
68
  export var DEFAULT_DATE_FORMAT = 'yyyy/MM/dd';
68
- var INPUT_DELIMITER = ' ';
69
+ var INPUT_DELIMITER = '–';
69
70
 
70
71
  var combineSeparatedInputs = function combineSeparatedInputs(newInputValue) {
71
72
  var prevCombinedInputValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
72
- var separatedInput = arguments.length > 2 ? arguments[2] : undefined;
73
+ var inputRole = arguments.length > 2 ? arguments[2] : undefined;
73
74
  var inputValue = newInputValue;
74
75
 
75
- var _prevCombinedInputVal = prevCombinedInputValue.split(INPUT_DELIMITER),
76
+ var _prevCombinedInputVal = prevCombinedInputValue.split(" ".concat(INPUT_DELIMITER, " ")),
76
77
  _prevCombinedInputVal2 = _slicedToArray(_prevCombinedInputVal, 2),
77
78
  _prevCombinedInputVal3 = _prevCombinedInputVal2[0],
78
79
  prevStartDate = _prevCombinedInputVal3 === void 0 ? '' : _prevCombinedInputVal3,
79
80
  _prevCombinedInputVal4 = _prevCombinedInputVal2[1],
80
81
  prevEndDate = _prevCombinedInputVal4 === void 0 ? '' : _prevCombinedInputVal4;
81
82
 
82
- if (separatedInput === 'startDate' && prevEndDate) {
83
- inputValue = "".concat(inputValue, " \u2013 ").concat(prevEndDate);
83
+ if (inputRole === INPUT_ROLE.startDate && prevEndDate) {
84
+ inputValue = "".concat(inputValue, " ").concat(INPUT_DELIMITER, " ").concat(prevEndDate);
84
85
  }
85
86
 
86
- if (separatedInput === 'endDate') {
87
- inputValue = "".concat(prevStartDate, " \u2013 ").concat(inputValue);
87
+ if (inputRole === INPUT_ROLE.endDate) {
88
+ inputValue = "".concat(prevStartDate, " ").concat(INPUT_DELIMITER, " ").concat(inputValue);
88
89
  }
89
90
 
90
91
  return inputValue;
@@ -100,31 +101,72 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
100
101
 
101
102
  _classCallCheck(this, Datepicker);
102
103
 
103
- _this = _super.call(this, props); //$FlowFixMe
104
+ _this = _super.call(this, props); //$FlowFixMe[incompatible-call]
104
105
 
105
106
  _defineProperty(_assertThisInitialized(_this), "calendar", void 0);
106
107
 
107
108
  _defineProperty(_assertThisInitialized(_this), "dateHelpers", void 0);
108
109
 
109
- _defineProperty(_assertThisInitialized(_this), "onChange", function (data) {
110
+ _defineProperty(_assertThisInitialized(_this), "handleChange", function (date) {
111
+ var onChange = _this.props.onChange;
112
+ var onRangeChange = _this.props.onRangeChange;
113
+
114
+ if (Array.isArray(date)) {
115
+ if (onChange && date.every(Boolean)) {
116
+ // flowlint-next-line unclear-type:off
117
+ onChange({
118
+ date: date
119
+ });
120
+ }
121
+
122
+ if (onRangeChange) {
123
+ onRangeChange({
124
+ date: _toConsumableArray(date)
125
+ });
126
+ }
127
+ } else {
128
+ if (onChange) {
129
+ onChange({
130
+ date: date
131
+ });
132
+ }
133
+
134
+ if (onRangeChange) {
135
+ onRangeChange({
136
+ date: date
137
+ });
138
+ }
139
+ }
140
+ });
141
+
142
+ _defineProperty(_assertThisInitialized(_this), "onCalendarSelect", function (data) {
110
143
  var isOpen = false;
111
144
  var isPseudoFocused = false;
112
145
  var calendarFocused = false;
113
146
  var nextDate = data.date;
114
147
 
115
148
  if (Array.isArray(nextDate) && _this.props.range) {
116
- if (nextDate.length < 2) {
149
+ if (!nextDate[0] || !nextDate[1]) {
117
150
  isOpen = true;
118
151
  isPseudoFocused = true;
119
152
  calendarFocused = null;
120
- } else if (nextDate.length === 2) {
153
+ } else if (nextDate[0] && nextDate[1]) {
121
154
  var _nextDate = nextDate,
122
155
  _nextDate2 = _slicedToArray(_nextDate, 2),
123
156
  start = _nextDate2[0],
124
157
  end = _nextDate2[1];
125
158
 
126
159
  if (_this.dateHelpers.isAfter(start, end)) {
127
- nextDate = [start, start];
160
+ if (_this.hasLockedBehavior()) {
161
+ nextDate = _this.props.value;
162
+ isOpen = true;
163
+ } else {
164
+ nextDate = [start, start];
165
+ }
166
+ } 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]
167
+ nextDate, _this.props.excludeDates)) {
168
+ nextDate = _this.props.value;
169
+ isOpen = true;
128
170
  }
129
171
 
130
172
  if (_this.state.lastActiveElm) {
@@ -174,9 +216,7 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
174
216
  inputValue: _this.formatDisplayValue(nextDate)
175
217
  }));
176
218
 
177
- _this.props.onChange && _this.props.onChange({
178
- date: nextDate
179
- });
219
+ _this.handleChange(nextDate);
180
220
  });
181
221
 
182
222
  _defineProperty(_assertThisInitialized(_this), "formatDisplayValue", function (date) {
@@ -216,11 +256,12 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
216
256
  return _this.formatDate(date, formatString);
217
257
  });
218
258
 
219
- _defineProperty(_assertThisInitialized(_this), "open", function () {
259
+ _defineProperty(_assertThisInitialized(_this), "open", function (inputRole) {
220
260
  _this.setState({
221
261
  isOpen: true,
222
262
  isPseudoFocused: true,
223
- calendarFocused: false
263
+ calendarFocused: false,
264
+ selectedInput: inputRole
224
265
  }, _this.props.onOpen);
225
266
  });
226
267
 
@@ -229,6 +270,7 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
229
270
 
230
271
  _this.setState({
231
272
  isOpen: false,
273
+ selectedInput: null,
232
274
  isPseudoFocused: isPseudoFocused,
233
275
  calendarFocused: false
234
276
  }, _this.props.onClose);
@@ -264,30 +306,24 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
264
306
  }
265
307
 
266
308
  if (range && !separateRangeInputs) {
267
- return '9999/99/99 9999/99/99';
309
+ return "9999/99/99 ".concat(INPUT_DELIMITER, " 9999/99/99");
268
310
  }
269
311
 
270
312
  return '9999/99/99';
271
313
  });
272
314
 
273
- _defineProperty(_assertThisInitialized(_this), "handleInputChange", function (event, separatedInput) {
274
- var inputValue = _this.props.range && _this.props.separateRangeInputs ? combineSeparatedInputs(event.currentTarget.value, _this.state.inputValue, separatedInput) : event.currentTarget.value;
315
+ _defineProperty(_assertThisInitialized(_this), "handleInputChange", function (event, inputRole) {
316
+ var inputValue = _this.props.range && _this.props.separateRangeInputs ? combineSeparatedInputs(event.currentTarget.value, _this.state.inputValue, inputRole) : event.currentTarget.value;
275
317
 
276
318
  var mask = _this.getMask();
277
319
 
278
320
  var formatString = _this.normalizeDashes(_this.props.formatString);
279
321
 
280
322
  if (typeof mask === 'string' && inputValue === mask.replace(/9/g, ' ') || inputValue.length === 0) {
281
- if (_this.props.onChange) {
282
- if (_this.props.range) {
283
- _this.props.onChange({
284
- date: []
285
- });
286
- } else {
287
- _this.props.onChange({
288
- date: null
289
- });
290
- }
323
+ if (_this.props.range) {
324
+ _this.handleChange([]);
325
+ } else {
326
+ _this.handleChange(null);
291
327
  }
292
328
  }
293
329
 
@@ -304,7 +340,7 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
304
340
  };
305
341
 
306
342
  if (_this.props.range && typeof _this.props.displayValueAtRangeIndex !== 'number') {
307
- var _this$normalizeDashes = _this.normalizeDashes(inputValue).split(INPUT_DELIMITER),
343
+ var _this$normalizeDashes = _this.normalizeDashes(inputValue).split(" ".concat(INPUT_DELIMITER, " ")),
308
344
  _this$normalizeDashes2 = _slicedToArray(_this$normalizeDashes, 2),
309
345
  left = _this$normalizeDashes2[0],
310
346
  right = _this$normalizeDashes2[1];
@@ -318,19 +354,13 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
318
354
  endDate = parseDateString(right);
319
355
  }
320
356
 
321
- var onChange = _this.props.onChange;
322
-
323
- if (onChange) {
324
- var datesValid = _this.dateHelpers.isValid(startDate) && _this.dateHelpers.isValid(endDate); // added equal case so that times within the same day can be expressed
357
+ var datesValid = _this.dateHelpers.isValid(startDate) && _this.dateHelpers.isValid(endDate); // added equal case so that times within the same day can be expressed
325
358
 
326
359
 
327
- var rangeValid = _this.dateHelpers.isAfter(endDate, startDate) || _this.dateHelpers.isEqual(startDate, endDate);
360
+ var rangeValid = _this.dateHelpers.isAfter(endDate, startDate) || _this.dateHelpers.isEqual(startDate, endDate);
328
361
 
329
- if (datesValid && rangeValid) {
330
- onChange({
331
- date: [startDate, endDate]
332
- });
333
- }
362
+ if (datesValid && rangeValid) {
363
+ _this.handleChange([startDate, endDate]);
334
364
  }
335
365
  } else {
336
366
  var dateString = _this.normalizeDashes(inputValue);
@@ -348,11 +378,10 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
348
378
 
349
379
  var _this$props3 = _this.props,
350
380
  displayValueAtRangeIndex = _this$props3.displayValueAtRangeIndex,
351
- _onChange = _this$props3.onChange,
352
381
  range = _this$props3.range,
353
382
  value = _this$props3.value;
354
383
 
355
- if (date && _this.dateHelpers.isValid(date) && _onChange) {
384
+ if (date && _this.dateHelpers.isValid(date)) {
356
385
  if (range && Array.isArray(value) && typeof displayValueAtRangeIndex === 'number') {
357
386
  var _value = _slicedToArray(value, 2),
358
387
  _left = _value[0],
@@ -362,22 +391,16 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
362
391
  _left = date;
363
392
 
364
393
  if (!_right) {
365
- _onChange({
366
- date: [_left]
367
- });
394
+ _this.handleChange([_left]);
368
395
  } else {
369
396
  if (_this.dateHelpers.isAfter(_right, _left) || _this.dateHelpers.isEqual(_left, _right)) {
370
- _onChange({
371
- date: [_left, _right]
372
- });
397
+ _this.handleChange([_left, _right]);
373
398
  } else {
374
399
  // Is resetting back to previous value appropriate? Invalid range is not
375
400
  // communicated to the user, but if it was not reset the text value would
376
401
  // show one value and date value another. This seems a bit better but clearly
377
402
  // has a downside.
378
- _onChange({
379
- date: _toConsumableArray(value)
380
- });
403
+ _this.handleChange(_toConsumableArray(value));
381
404
  }
382
405
  }
383
406
  } else if (displayValueAtRangeIndex === 1) {
@@ -385,26 +408,18 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
385
408
 
386
409
  if (!_left) {
387
410
  // If start value is not defined, set start/end to the same day.
388
- _onChange({
389
- date: [_right, _right]
390
- });
411
+ _this.handleChange([_right, _right]);
391
412
  } else {
392
413
  if (_this.dateHelpers.isAfter(_right, _left) || _this.dateHelpers.isEqual(_left, _right)) {
393
- _onChange({
394
- date: [_left, _right]
395
- });
414
+ _this.handleChange([_left, _right]);
396
415
  } else {
397
416
  // See comment above about resetting dates on invalid range
398
- _onChange({
399
- date: _toConsumableArray(value)
400
- });
417
+ _this.handleChange(_toConsumableArray(value));
401
418
  }
402
419
  }
403
420
  }
404
421
  } else {
405
- _onChange({
406
- date: date
407
- });
422
+ _this.handleChange(date);
408
423
  }
409
424
  }
410
425
  }
@@ -436,13 +451,18 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
436
451
 
437
452
  _defineProperty(_assertThisInitialized(_this), "normalizeDashes", function (inputValue) {
438
453
  // replacing both hyphens and em-dashes with en-dashes
439
- return inputValue.replace(/-/g, '–').replace(/—/g, '–');
454
+ return inputValue.replace(/-/g, INPUT_DELIMITER).replace(/—/g, INPUT_DELIMITER);
455
+ });
456
+
457
+ _defineProperty(_assertThisInitialized(_this), "hasLockedBehavior", function () {
458
+ return _this.props.rangedCalendarBehavior === RANGED_CALENDAR_BEHAVIOR.locked && _this.props.range && _this.props.separateRangeInputs;
440
459
  });
441
460
 
442
461
  _this.dateHelpers = new DateHelpers(props.adapter);
443
462
  _this.state = {
444
463
  calendarFocused: false,
445
464
  isOpen: false,
465
+ selectedInput: null,
446
466
  isPseudoFocused: false,
447
467
  lastActiveElm: null,
448
468
  inputValue: _this.formatDisplayValue(props.value) || ''
@@ -451,6 +471,11 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
451
471
  }
452
472
 
453
473
  _createClass(Datepicker, [{
474
+ key: "getNullDatePlaceholder",
475
+ value: function getNullDatePlaceholder(formatString) {
476
+ return (this.getMask() || formatString).split(INPUT_DELIMITER)[0].replace(/[0-9]|[a-z]/g, ' ');
477
+ }
478
+ }, {
454
479
  key: "formatDate",
455
480
  value: function formatDate(date, formatString) {
456
481
  var _this2 = this;
@@ -467,10 +492,14 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
467
492
  return '';
468
493
  } else if (Array.isArray(date) && !date[0] && !date[1]) {
469
494
  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(" ".concat(INPUT_DELIMITER, " "));
470
499
  } else if (Array.isArray(date)) {
471
500
  return date.map(function (day) {
472
- return format(day);
473
- }).join(INPUT_DELIMITER);
501
+ return day ? format(day) : '';
502
+ }).join(" ".concat(INPUT_DELIMITER, " "));
474
503
  } else {
475
504
  return format(date);
476
505
  }
@@ -486,7 +515,7 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
486
515
  }
487
516
  }, {
488
517
  key: "renderInputComponent",
489
- value: function renderInputComponent(locale, separatedInput) {
518
+ value: function renderInputComponent(locale, inputRole) {
490
519
  var _this3 = this;
491
520
 
492
521
  var _this$props$overrides = this.props.overrides,
@@ -497,21 +526,16 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
497
526
  InputComponent = _getOverrides2[0],
498
527
  inputProps = _getOverrides2[1];
499
528
 
500
- 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';
529
+ 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';
501
530
 
502
- var _split = (this.state.inputValue || '').split(INPUT_DELIMITER),
531
+ var _split = (this.state.inputValue || '').split(" ".concat(INPUT_DELIMITER, " ")),
503
532
  _split2 = _slicedToArray(_split, 2),
504
533
  _split2$ = _split2[0],
505
534
  startDate = _split2$ === void 0 ? '' : _split2$,
506
535
  _split2$2 = _split2[1],
507
536
  endDate = _split2$2 === void 0 ? '' : _split2$2;
508
537
 
509
- var value = separatedInput === 'startDate' ? startDate : separatedInput === 'endDate' ? endDate : this.state.inputValue;
510
-
511
- var onChange = function onChange(event) {
512
- return _this3.handleInputChange(event, separatedInput);
513
- };
514
-
538
+ var value = inputRole === INPUT_ROLE.startDate ? startDate : inputRole === INPUT_ROLE.endDate ? endDate : this.state.inputValue;
515
539
  return /*#__PURE__*/React.createElement(InputComponent, _extends({
516
540
  "aria-disabled": this.props.disabled,
517
541
  "aria-label": this.props['aria-label'] || (this.props.range ? locale.datepicker.ariaLabelRange : locale.datepicker.ariaLabel),
@@ -523,10 +547,14 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
523
547
  disabled: this.props.disabled,
524
548
  size: this.props.size,
525
549
  value: value,
526
- onFocus: this.open,
550
+ onFocus: function onFocus() {
551
+ return _this3.open(inputRole);
552
+ },
527
553
  onBlur: this.handleInputBlur,
528
554
  onKeyDown: this.handleKeyDown,
529
- onChange: onChange,
555
+ onChange: function onChange(event) {
556
+ return _this3.handleInputChange(event, inputRole);
557
+ },
530
558
  placeholder: placeholder,
531
559
  mask: this.getMask(),
532
560
  required: this.props.required,
@@ -586,11 +614,13 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
586
614
  trapTabbing: true,
587
615
  value: _this4.props.value
588
616
  }, _this4.props, {
589
- onChange: _this4.onChange
617
+ onChange: _this4.onCalendarSelect,
618
+ selectedInput: _this4.state.selectedInput,
619
+ hasLockedBehavior: _this4.hasLockedBehavior()
590
620
  }))
591
621
  }, popoverProps), /*#__PURE__*/React.createElement(InputWrapper, _extends({}, inputWrapperProps, {
592
622
  $separateRangeInputs: _this4.props.range && _this4.props.separateRangeInputs
593
- }), _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", {
623
+ }), _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, INPUT_ROLE.startDate)), /*#__PURE__*/React.createElement(EndDate, endDateProps, /*#__PURE__*/React.createElement(InputLabel, inputLabelProps, endDateLabel), _this4.renderInputComponent(locale, INPUT_ROLE.endDate))) : /*#__PURE__*/React.createElement(React.Fragment, null, _this4.renderInputComponent(locale)))), /*#__PURE__*/React.createElement("p", {
594
624
  id: _this4.props['aria-describedby'],
595
625
  style: {
596
626
  position: 'fixed',
@@ -621,11 +651,11 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
621
651
  clipPath: 'inset(100%)'
622
652
  }
623
653
  }, // No date selected
624
- !_this4.props.value || Array.isArray(_this4.props.value) && !_this4.props.value.length ? '' : // Date selected in a non-range picker
654
+ !_this4.props.value || Array.isArray(_this4.props.value) && !_this4.props.value[0] && !_this4.props.value[1] ? '' : // Date selected in a non-range picker
625
655
  !Array.isArray(_this4.props.value) ? getInterpolatedString(locale.datepicker.selectedDate, {
626
656
  date: _this4.state.inputValue || ''
627
657
  }) : // Start and end dates are selected in a range picker
628
- _this4.props.value.length > 1 ? getInterpolatedString(locale.datepicker.selectedDateRange, {
658
+ _this4.props.value[0] && _this4.props.value[1] ? getInterpolatedString(locale.datepicker.selectedDateRange, {
629
659
  startDate: _this4.formatDisplayValue(_this4.props.value[0]),
630
660
  endDate: _this4.formatDisplayValue( // $FlowFixMe
631
661
  _this4.props.value[1])
@@ -49,6 +49,7 @@ import DateHelpers from './utils/date-helpers.js';
49
49
  import { getOverrides } from '../helpers/overrides.js';
50
50
  import { LocaleContext } from '../locale/index.js';
51
51
  import { isFocusVisible } from '../utils/focusVisible.js';
52
+ import { INPUT_ROLE } from './constants.js';
52
53
 
53
54
  var Day = /*#__PURE__*/function (_React$Component) {
54
55
  _inherits(Day, _React$Component);
@@ -83,22 +84,49 @@ var Day = /*#__PURE__*/function (_React$Component) {
83
84
  var _this$props = _this.props,
84
85
  range = _this$props.range,
85
86
  value = _this$props.value;
86
- var date;
87
+ var nextDate;
88
+
89
+ if (Array.isArray(value) && range && _this.props.hasLockedBehavior) {
90
+ var currentDate = _this.props.value;
91
+ var nextStartDate = null;
92
+ var nextEndDate = null;
93
+
94
+ if (_this.props.selectedInput === INPUT_ROLE.startDate) {
95
+ nextStartDate = selectedDate;
96
+ nextEndDate = Array.isArray(currentDate) && currentDate[1] ? currentDate[1] : null;
97
+ } else if (_this.props.selectedInput === INPUT_ROLE.endDate) {
98
+ nextStartDate = Array.isArray(currentDate) && currentDate[0] ? currentDate[0] : null;
99
+ nextEndDate = selectedDate;
100
+ }
101
+
102
+ nextDate = [nextStartDate];
87
103
 
88
- if (Array.isArray(value) && range) {
89
- if (!value.length || value.length > 1) {
90
- date = [selectedDate];
91
- } else if (_this.dateHelpers.isAfter(selectedDate, value[0])) {
92
- date = [value[0], selectedDate];
104
+ if (nextEndDate) {
105
+ nextDate.push(nextEndDate);
106
+ }
107
+ } else if (Array.isArray(value) && range && !_this.props.hasLockedBehavior) {
108
+ var _value = _slicedToArray(value, 2),
109
+ start = _value[0],
110
+ end = _value[1]; // Starting a new range
111
+
112
+
113
+ if (!start && !end || start && end) {
114
+ nextDate = [selectedDate, null]; // EndDate needs a StartDate, SelectedDate comes before EndDate
115
+ } else if (!start && end && _this.dateHelpers.isAfter(end, selectedDate)) {
116
+ nextDate = [selectedDate, end]; // EndDate needs a StartDate, but SelectedDate comes after EndDate
117
+ } else if (!start && end && _this.dateHelpers.isAfter(selectedDate, end)) {
118
+ nextDate = [end, selectedDate]; // StartDate needs an EndDate, SelectedDate comes after StartDate
119
+ } else if (start && !end && _this.dateHelpers.isAfter(selectedDate, start)) {
120
+ nextDate = [start, selectedDate];
93
121
  } else {
94
- date = [selectedDate, value[0]];
122
+ nextDate = [selectedDate, start];
95
123
  }
96
124
  } else {
97
- date = selectedDate;
125
+ nextDate = selectedDate;
98
126
  }
99
127
 
100
128
  _this.props.onSelect({
101
- date: date
129
+ date: nextDate
102
130
  });
103
131
  });
104
132
 
@@ -285,13 +313,18 @@ var Day = /*#__PURE__*/function (_React$Component) {
285
313
  var date = this.getDateProp();
286
314
  var value = this.props.value;
287
315
 
288
- if (Array.isArray(value) && !value[0] && !value[1]) {
289
- return false;
290
- } // fix flow by passing a specific arg type and remove 'Array.isArray(value)'
316
+ if (Array.isArray(value)) {
317
+ var _value2 = _slicedToArray(value, 2),
318
+ start = _value2[0],
319
+ end = _value2[1];
291
320
 
321
+ if (!start && !end) {
322
+ return false;
323
+ }
292
324
 
293
- if (Array.isArray(value) && value.length > 1) {
294
- return this.dateHelpers.isDayInRange(this.clampToDayStart(date), this.clampToDayStart(value[0]), this.clampToDayStart(value[1]));
325
+ if (start && end) {
326
+ return this.dateHelpers.isDayInRange(this.clampToDayStart(date), this.clampToDayStart(start), this.clampToDayStart(end));
327
+ }
295
328
  }
296
329
  } // calculated for range case only
297
330
 
@@ -303,16 +336,29 @@ var Day = /*#__PURE__*/function (_React$Component) {
303
336
  value = _this$props4.value,
304
337
  highlightedDate = _this$props4.highlightedDate;
305
338
 
306
- if (Array.isArray(value) && !value[0] && !value[1]) {
307
- return false;
308
- } // fix flow by passing a specific arg type and remove 'Array.isArray(value)'
339
+ if (Array.isArray(value)) {
340
+ var _value3 = _slicedToArray(value, 2),
341
+ start = _value3[0],
342
+ end = _value3[1];
343
+
344
+ if (!start && !end) {
345
+ return false;
346
+ }
309
347
 
348
+ if (highlightedDate && start && !end) {
349
+ if (this.dateHelpers.isAfter(highlightedDate, start)) {
350
+ return this.dateHelpers.isDayInRange(this.clampToDayStart(date), this.clampToDayStart(start), this.clampToDayStart(highlightedDate));
351
+ } else {
352
+ return this.dateHelpers.isDayInRange(this.clampToDayStart(date), this.clampToDayStart(highlightedDate), this.clampToDayStart(start));
353
+ }
354
+ }
310
355
 
311
- if (Array.isArray(value) && highlightedDate && value[0] && !value[1]) {
312
- if (this.dateHelpers.isAfter(highlightedDate, value[0])) {
313
- return this.dateHelpers.isDayInRange(this.clampToDayStart(date), this.clampToDayStart(value[0]), this.clampToDayStart(highlightedDate));
314
- } else {
315
- return this.dateHelpers.isDayInRange(this.clampToDayStart(date), this.clampToDayStart(highlightedDate), this.clampToDayStart(value[0]));
356
+ if (highlightedDate && !start && end) {
357
+ if (this.dateHelpers.isAfter(highlightedDate, end)) {
358
+ return this.dateHelpers.isDayInRange(this.clampToDayStart(date), this.clampToDayStart(end), this.clampToDayStart(highlightedDate));
359
+ } else {
360
+ return this.dateHelpers.isDayInRange(this.clampToDayStart(date), this.clampToDayStart(highlightedDate), this.clampToDayStart(end));
361
+ }
316
362
  }
317
363
  }
318
364
  }
@@ -324,21 +370,22 @@ var Day = /*#__PURE__*/function (_React$Component) {
324
370
  value = _this$props5.value,
325
371
  highlightedDate = _this$props5.highlightedDate,
326
372
  range = _this$props5.range,
327
- highlighted = _this$props5.highlighted;
373
+ highlighted = _this$props5.highlighted,
374
+ peekNextMonth = _this$props5.peekNextMonth;
328
375
  var $isHighlighted = highlighted;
329
376
  var $selected = this.isSelected();
330
- var $hasRangeHighlighted = !!(Array.isArray(value) && range && value.length === 1 && highlightedDate && !this.dateHelpers.isSameDay(value[0], highlightedDate));
331
- var $outsideMonth = !this.props.peekNextMonth && this.isOutsideMonth();
332
- var $outsideMonthWithinRange = !!(Array.isArray(value) && range && $outsideMonth && !this.props.peekNextMonth && this.isOutsideOfMonthButWithinRange());
377
+ var $hasRangeHighlighted = !!(Array.isArray(value) && range && highlightedDate && (value[0] && !value[1] && !this.dateHelpers.isSameDay(value[0], highlightedDate) || !value[0] && value[1] && !this.dateHelpers.isSameDay(value[1], highlightedDate)));
378
+ var $outsideMonth = !peekNextMonth && this.isOutsideMonth();
379
+ var $outsideMonthWithinRange = !!(Array.isArray(value) && range && $outsideMonth && !peekNextMonth && this.isOutsideOfMonthButWithinRange());
333
380
  return {
334
381
  $date: date,
335
382
  $density: this.props.density,
336
383
  $disabled: this.props.disabled,
337
- $endDate: Array.isArray(value) && this.props.range && $selected && this.dateHelpers.isSameDay(date, value[1]) || false,
384
+ $endDate: Array.isArray(value) && !!(value[0] && value[1]) && range && $selected && this.dateHelpers.isSameDay(date, value[1]) || false,
338
385
  $hasDateLabel: !!this.props.dateLabel,
339
386
  $hasRangeHighlighted: $hasRangeHighlighted,
340
- $hasRangeOnRight: Array.isArray(value) && $hasRangeHighlighted && highlightedDate && value[0] && this.dateHelpers.isAfter(highlightedDate, value[0]),
341
- $hasRangeSelected: Array.isArray(value) ? value.length === 2 : false,
387
+ $hasRangeOnRight: Array.isArray(value) && $hasRangeHighlighted && highlightedDate && (value[0] && this.dateHelpers.isAfter(highlightedDate, value[0]) || value[1] && this.dateHelpers.isAfter(highlightedDate, value[1])),
388
+ $hasRangeSelected: Array.isArray(value) ? !!(value[0] && value[1]) : false,
342
389
  $highlightedDate: highlightedDate,
343
390
  $isHighlighted: $isHighlighted,
344
391
  $isHovered: this.state.isHovered,
@@ -348,12 +395,15 @@ var Day = /*#__PURE__*/function (_React$Component) {
348
395
  $month: this.getMonthProp(),
349
396
  $outsideMonth: $outsideMonth,
350
397
  $outsideMonthWithinRange: $outsideMonthWithinRange,
351
- $peekNextMonth: this.props.peekNextMonth,
352
- $pseudoHighlighted: this.props.range && !$isHighlighted && !$selected ? this.isPseudoHighlighted() : false,
353
- $pseudoSelected: this.props.range && !$selected ? this.isPseudoSelected() : false,
354
- $range: this.props.range,
398
+ $peekNextMonth: peekNextMonth,
399
+ $pseudoHighlighted: range && !$isHighlighted && !$selected ? this.isPseudoHighlighted() : false,
400
+ $pseudoSelected: range && !$selected ? this.isPseudoSelected() : false,
401
+ $range: range,
355
402
  $selected: $selected,
356
- $startDate: Array.isArray(this.props.value) && this.props.value.length > 1 && this.props.range && $selected ? this.dateHelpers.isSameDay(date, this.props.value[0]) : false
403
+ $startDate: Array.isArray(value) && value[0] && value[1] && range && $selected ? this.dateHelpers.isSameDay(date, value[0]) : false,
404
+ $hasLockedBehavior: this.props.hasLockedBehavior,
405
+ $selectedInput: this.props.selectedInput,
406
+ $value: this.props.value
357
407
  };
358
408
  }
359
409
  }, {
@@ -129,7 +129,9 @@ var CalendarMonth = /*#__PURE__*/function (_React$Component) {
129
129
  onChange: _this.props.onChange,
130
130
  overrides: _this.props.overrides,
131
131
  peekNextMonth: _this.props.peekNextMonth,
132
- value: _this.props.value
132
+ value: _this.props.value,
133
+ hasLockedBehavior: _this.props.hasLockedBehavior,
134
+ selectedInput: _this.props.selectedInput
133
135
  }));
134
136
  i++;
135
137
  currentWeekStart = _this.dateHelpers.addWeeks(currentWeekStart, 1); // It will break on the next week if the week is out of the month
@@ -1,5 +1,7 @@
1
1
  function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
2
2
 
3
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
+
3
5
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4
6
 
5
7
  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); } }
@@ -47,7 +49,10 @@ var StatefulComponent = /*#__PURE__*/function (_React$Component) {
47
49
  key: "render",
48
50
  value: function render() {
49
51
  return /*#__PURE__*/React.createElement(StatefulContainer, this.props, function (extendedProps) {
50
- return /*#__PURE__*/React.createElement(Calendar, extendedProps);
52
+ return /*#__PURE__*/React.createElement(Calendar, _extends({}, extendedProps, {
53
+ // flowlint-next-line unclear-type:off
54
+ onChange: extendedProps.onChange
55
+ }));
51
56
  });
52
57
  }
53
58
  }]);