baseui 11.0.1 → 11.1.0

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 (266) hide show
  1. package/a11y/index.d.ts +1 -1
  2. package/accordion/index.d.ts +25 -28
  3. package/app-nav-bar/app-nav-bar.js +33 -40
  4. package/app-nav-bar/app-nav-bar.js.flow +46 -62
  5. package/app-nav-bar/index.d.ts +9 -8
  6. package/app-nav-bar/styled-components.js +49 -29
  7. package/app-nav-bar/styled-components.js.flow +25 -8
  8. package/app-nav-bar/types.js.flow +2 -0
  9. package/aspect-ratio-box/index.d.ts +2 -4
  10. package/avatar/index.d.ts +6 -12
  11. package/badge/badge.js +109 -0
  12. package/badge/badge.js.flow +91 -0
  13. package/badge/constants.js +54 -0
  14. package/badge/constants.js.flow +52 -0
  15. package/badge/hint-dot.js +96 -0
  16. package/badge/hint-dot.js.flow +68 -0
  17. package/badge/index.d.ts +97 -0
  18. package/badge/index.js +80 -0
  19. package/badge/index.js.flow +20 -0
  20. package/badge/notification-circle.js +103 -0
  21. package/badge/notification-circle.js.flow +81 -0
  22. package/badge/package.json +4 -0
  23. package/badge/styled-components.js +242 -0
  24. package/badge/styled-components.js.flow +325 -0
  25. package/badge/types.js +11 -0
  26. package/badge/types.js.flow +59 -0
  27. package/badge/utils.js +33 -0
  28. package/badge/utils.js.flow +23 -0
  29. package/banner/banner.js +283 -0
  30. package/banner/banner.js.flow +253 -0
  31. package/banner/constants.js +35 -0
  32. package/banner/constants.js.flow +33 -0
  33. package/banner/index.d.ts +75 -0
  34. package/banner/index.js +44 -0
  35. package/banner/index.js.flow +16 -0
  36. package/banner/package.json +4 -0
  37. package/banner/styled-components.js +131 -0
  38. package/banner/styled-components.js.flow +119 -0
  39. package/banner/types.js +11 -0
  40. package/banner/types.js.flow +66 -0
  41. package/block/index.d.ts +4 -4
  42. package/breadcrumbs/breadcrumbs.js +5 -1
  43. package/breadcrumbs/breadcrumbs.js.flow +2 -2
  44. package/breadcrumbs/index.d.ts +5 -5
  45. package/button/button.js +2 -1
  46. package/button/button.js.flow +1 -0
  47. package/button/index.d.ts +19 -29
  48. package/button-group/index.d.ts +18 -24
  49. package/card/index.d.ts +16 -14
  50. package/checkbox/index.d.ts +17 -21
  51. package/combobox/index.d.ts +7 -11
  52. package/data-table/index.d.ts +7 -10
  53. package/datepicker/calendar.js +16 -11
  54. package/datepicker/calendar.js.flow +12 -9
  55. package/datepicker/datepicker.js +58 -58
  56. package/datepicker/datepicker.js.flow +51 -34
  57. package/datepicker/index.d.ts +42 -63
  58. package/datepicker/stateful-calendar.js +6 -1
  59. package/datepicker/stateful-calendar.js.flow +8 -1
  60. package/datepicker/stateful-container.js +23 -2
  61. package/datepicker/stateful-container.js.flow +17 -4
  62. package/datepicker/stateful-datepicker.js +6 -1
  63. package/datepicker/stateful-datepicker.js.flow +7 -1
  64. package/datepicker/types.js.flow +21 -43
  65. package/datepicker/utils/date-helpers.js +1 -1
  66. package/datepicker/utils/date-helpers.js.flow +1 -1
  67. package/dnd-list/index.d.ts +22 -35
  68. package/drawer/index.d.ts +22 -27
  69. package/es/app-nav-bar/app-nav-bar.js +9 -19
  70. package/es/app-nav-bar/styled-components.js +32 -13
  71. package/es/badge/badge.js +70 -0
  72. package/es/badge/constants.js +42 -0
  73. package/es/badge/hint-dot.js +55 -0
  74. package/es/badge/index.js +11 -0
  75. package/es/badge/notification-circle.js +65 -0
  76. package/es/badge/styled-components.js +296 -0
  77. package/es/badge/types.js +8 -0
  78. package/es/badge/utils.js +17 -0
  79. package/es/banner/banner.js +213 -0
  80. package/es/banner/constants.js +24 -0
  81. package/es/banner/index.js +9 -0
  82. package/es/banner/styled-components.js +122 -0
  83. package/es/banner/types.js +8 -0
  84. package/es/breadcrumbs/breadcrumbs.js +5 -1
  85. package/es/button/button.js +1 -0
  86. package/es/datepicker/calendar.js +15 -10
  87. package/es/datepicker/datepicker.js +52 -52
  88. package/es/datepicker/stateful-calendar.js +6 -1
  89. package/es/datepicker/stateful-container.js +22 -2
  90. package/es/datepicker/stateful-datepicker.js +6 -1
  91. package/es/datepicker/utils/date-helpers.js +1 -1
  92. package/es/helper/helper-steps.js +3 -1
  93. package/es/input/base-input.js +18 -11
  94. package/es/input/input.js +15 -10
  95. package/es/input/masked-input.js +5 -2
  96. package/es/input/utils.js +4 -2
  97. package/es/locale/tr_TR.js +115 -0
  98. package/es/notification/notification.js +16 -1
  99. package/es/payment-card/custom-cards.config.js +22 -0
  100. package/es/payment-card/icons/uatp.js +52 -0
  101. package/es/payment-card/payment-card.js +8 -3
  102. package/es/popover/popover.js +2 -1
  103. package/es/popover/stateful-container.js +2 -0
  104. package/es/popover/styled-components.js +2 -1
  105. package/es/progress-steps/numbered-step.js +2 -2
  106. package/es/select/select-component.js +48 -23
  107. package/es/select/utils/default-filter-options.js +1 -1
  108. package/es/snackbar/snackbar-context.js +1 -1
  109. package/es/table-semantic/styled-components.js +14 -0
  110. package/es/table-semantic/table-builder.js +12 -5
  111. package/es/textarea/textarea.js +15 -9
  112. package/es/themes/dark-theme/color-component-tokens.js +8 -0
  113. package/es/themes/light-theme/color-component-tokens.js +8 -0
  114. package/es/tree-view/tree-label.js +9 -1
  115. package/esm/app-nav-bar/app-nav-bar.js +32 -38
  116. package/esm/app-nav-bar/styled-components.js +46 -28
  117. package/esm/badge/badge.js +97 -0
  118. package/esm/badge/constants.js +42 -0
  119. package/esm/badge/hint-dot.js +83 -0
  120. package/esm/badge/index.js +11 -0
  121. package/esm/badge/notification-circle.js +91 -0
  122. package/esm/badge/styled-components.js +235 -0
  123. package/esm/badge/types.js +8 -0
  124. package/esm/badge/utils.js +17 -0
  125. package/esm/banner/banner.js +271 -0
  126. package/esm/banner/constants.js +24 -0
  127. package/esm/banner/index.js +9 -0
  128. package/esm/banner/styled-components.js +113 -0
  129. package/esm/banner/types.js +8 -0
  130. package/esm/breadcrumbs/breadcrumbs.js +5 -1
  131. package/esm/button/button.js +2 -1
  132. package/esm/datepicker/calendar.js +16 -11
  133. package/esm/datepicker/datepicker.js +58 -58
  134. package/esm/datepicker/stateful-calendar.js +6 -1
  135. package/esm/datepicker/stateful-container.js +23 -2
  136. package/esm/datepicker/stateful-datepicker.js +6 -1
  137. package/esm/datepicker/utils/date-helpers.js +1 -1
  138. package/esm/helper/helper-steps.js +3 -1
  139. package/esm/input/base-input.js +18 -11
  140. package/esm/input/input.js +15 -10
  141. package/esm/input/masked-input.js +6 -3
  142. package/esm/input/utils.js +4 -2
  143. package/esm/locale/tr_TR.js +115 -0
  144. package/esm/notification/notification.js +17 -1
  145. package/esm/payment-card/custom-cards.config.js +22 -0
  146. package/esm/payment-card/icons/uatp.js +53 -0
  147. package/esm/payment-card/payment-card.js +9 -7
  148. package/esm/popover/popover.js +2 -1
  149. package/esm/popover/stateful-container.js +2 -0
  150. package/esm/popover/styled-components.js +3 -2
  151. package/esm/progress-steps/numbered-step.js +2 -2
  152. package/esm/select/select-component.js +85 -59
  153. package/esm/select/utils/default-filter-options.js +1 -1
  154. package/esm/snackbar/snackbar-context.js +1 -1
  155. package/esm/table-semantic/styled-components.js +31 -18
  156. package/esm/table-semantic/table-builder.js +34 -23
  157. package/esm/textarea/textarea.js +15 -9
  158. package/esm/themes/dark-theme/color-component-tokens.js +8 -0
  159. package/esm/themes/light-theme/color-component-tokens.js +8 -0
  160. package/esm/tree-view/tree-label.js +10 -2
  161. package/file-uploader/index.d.ts +11 -11
  162. package/flex-grid/index.d.ts +3 -3
  163. package/form-control/index.d.ts +7 -19
  164. package/header-navigation/index.d.ts +8 -9
  165. package/heading/index.d.ts +3 -4
  166. package/helper/helper-steps.js +19 -13
  167. package/helper/helper-steps.js.flow +3 -1
  168. package/helper/index.d.ts +7 -7
  169. package/helpers/base-provider.d.ts +16 -0
  170. package/helpers/overrides.d.ts +23 -0
  171. package/icon/index.d.ts +32 -32
  172. package/index.d.ts +34 -114
  173. package/input/base-input.js +18 -11
  174. package/input/base-input.js.flow +18 -6
  175. package/input/index.d.ts +29 -32
  176. package/input/input.js +15 -10
  177. package/input/input.js.flow +10 -5
  178. package/input/masked-input.js +6 -3
  179. package/input/masked-input.js.flow +3 -0
  180. package/input/types.js.flow +4 -0
  181. package/input/utils.js +4 -2
  182. package/input/utils.js.flow +2 -1
  183. package/layer/index.d.ts +6 -11
  184. package/layout-grid/index.d.ts +25 -7
  185. package/link/index.d.ts +2 -2
  186. package/list/index.d.ts +26 -31
  187. package/{locale.ts → locale/index.d.ts} +8 -0
  188. package/locale/tr_TR.js +123 -0
  189. package/locale/tr_TR.js.flow +124 -0
  190. package/map-marker/index.d.ts +41 -47
  191. package/menu/index.d.ts +27 -37
  192. package/modal/index.d.ts +28 -38
  193. package/notification/index.d.ts +2 -3
  194. package/notification/notification.js +18 -1
  195. package/notification/notification.js.flow +15 -1
  196. package/overrides.ts +2 -22
  197. package/package.json +26 -17
  198. package/pagination/index.d.ts +22 -26
  199. package/payment-card/custom-cards.config.js +30 -0
  200. package/payment-card/custom-cards.config.js.flow +29 -0
  201. package/payment-card/icons/uatp.js +67 -0
  202. package/payment-card/icons/uatp.js.flow +62 -0
  203. package/payment-card/index.d.ts +8 -8
  204. package/payment-card/payment-card.js +12 -7
  205. package/payment-card/payment-card.js.flow +12 -0
  206. package/phone-input/index.d.ts +261 -269
  207. package/pin-code/index.d.ts +11 -18
  208. package/popover/index.d.ts +39 -55
  209. package/popover/popover.js +2 -1
  210. package/popover/popover.js.flow +2 -1
  211. package/popover/stateful-container.js +2 -0
  212. package/popover/stateful-container.js.flow +2 -0
  213. package/popover/styled-components.js +3 -2
  214. package/popover/styled-components.js.flow +2 -1
  215. package/popover/types.js.flow +1 -0
  216. package/progress-bar/index.d.ts +11 -12
  217. package/progress-steps/index.d.ts +16 -16
  218. package/progress-steps/numbered-step.js.flow +2 -2
  219. package/radio/index.d.ts +12 -15
  220. package/rating/index.d.ts +9 -12
  221. package/select/index.d.ts +34 -36
  222. package/select/select-component.js +82 -56
  223. package/select/select-component.js.flow +46 -34
  224. package/select/types.js.flow +1 -0
  225. package/select/utils/default-filter-options.js +1 -1
  226. package/select/utils/default-filter-options.js.flow +1 -1
  227. package/side-navigation/index.d.ts +11 -13
  228. package/skeleton/index.d.ts +1 -1
  229. package/slider/index.d.ts +17 -26
  230. package/snackbar/index.d.ts +8 -8
  231. package/snackbar/snackbar-context.js +1 -1
  232. package/snackbar/snackbar-context.js.flow +1 -1
  233. package/spinner/index.d.ts +4 -3
  234. package/styles/index.d.ts +82 -2
  235. package/table/index.d.ts +16 -16
  236. package/table-grid/index.d.ts +6 -8
  237. package/table-semantic/index.d.ts +26 -32
  238. package/table-semantic/styled-components.js +33 -19
  239. package/table-semantic/styled-components.js.flow +12 -0
  240. package/table-semantic/table-builder.js +38 -22
  241. package/table-semantic/table-builder.js.flow +32 -17
  242. package/table-semantic/types.js.flow +1 -0
  243. package/tabs/index.d.ts +20 -23
  244. package/tabs-motion/index.d.ts +23 -23
  245. package/tag/index.d.ts +14 -18
  246. package/tag/types.js.flow +1 -1
  247. package/textarea/index.d.ts +11 -14
  248. package/textarea/textarea.js +15 -9
  249. package/textarea/textarea.js.flow +11 -5
  250. package/textarea/types.js.flow +1 -0
  251. package/theme.ts +36 -777
  252. package/themes/dark-theme/color-component-tokens.js +8 -0
  253. package/themes/dark-theme/color-component-tokens.js.flow +9 -0
  254. package/themes/index.d.ts +765 -0
  255. package/themes/light-theme/color-component-tokens.js +8 -0
  256. package/themes/light-theme/color-component-tokens.js.flow +9 -0
  257. package/themes/types.js.flow +9 -0
  258. package/timepicker/index.d.ts +5 -8
  259. package/timezonepicker/index.d.ts +5 -8
  260. package/toast/index.d.ts +26 -40
  261. package/tokens/index.d.ts +1 -1
  262. package/tooltip/index.d.ts +7 -9
  263. package/tree-view/index.d.ts +15 -19
  264. package/tree-view/tree-label.js +10 -2
  265. package/tree-view/tree-label.js.flow +4 -4
  266. package/typography/index.d.ts +37 -37
@@ -0,0 +1,8 @@
1
+ /*
2
+ Copyright (c) Uber Technologies, Inc.
3
+
4
+ This source code is licensed under the MIT license found in the
5
+ LICENSE file in the root directory of this source tree.
6
+ */
7
+ import * as React from 'react';
8
+ import { ACTION_POSITION, ARTWORK_TYPE, HIERARCHY, KIND } from './constants.js';
@@ -76,7 +76,11 @@ export function Breadcrumbs(props) {
76
76
  }, baseListItemProps), child, (showTrailingSeparator || index !== childrenArray.length - 1) && /*#__PURE__*/React.createElement(Separator, _extends({}, baseSeparatorProps, {
77
77
  key: "separator-".concat(index)
78
78
  }), /*#__PURE__*/React.createElement(ThemeContext.Consumer, null, function (theme) {
79
- return theme.direction === 'rtl' ? /*#__PURE__*/React.createElement(Left, baseIconProps) : /*#__PURE__*/React.createElement(Right, baseIconProps);
79
+ return theme.direction === 'rtl' ? /*#__PURE__*/React.createElement(Left, _extends({
80
+ size: 16
81
+ }, baseIconProps)) : /*#__PURE__*/React.createElement(Right, _extends({
82
+ size: 16
83
+ }, baseIconProps));
80
84
  }))));
81
85
  });
82
86
  return /*#__PURE__*/React.createElement(LocaleContext.Consumer, null, function (locale) {
@@ -131,7 +131,8 @@ var Button = /*#__PURE__*/function (_React$Component) {
131
131
  endEnhancer = _this$props2.endEnhancer,
132
132
  children = _this$props2.children,
133
133
  forwardedRef = _this$props2.forwardedRef,
134
- restProps = _objectWithoutProperties(_this$props2, ["overrides", "size", "kind", "shape", "isLoading", "isSelected", "startEnhancer", "endEnhancer", "children", "forwardedRef"]); // Get overrides
134
+ colors = _this$props2.colors,
135
+ restProps = _objectWithoutProperties(_this$props2, ["overrides", "size", "kind", "shape", "isLoading", "isSelected", "startEnhancer", "endEnhancer", "children", "forwardedRef", "colors"]); // Get overrides
135
136
 
136
137
 
137
138
  var _getOverrides = getOverrides( // adding both (1) BaseButton and (2) Root
@@ -315,12 +315,12 @@ var Calendar = /*#__PURE__*/function (_React$Component) {
315
315
  _defineProperty(_assertThisInitialized(_this), "handleDateChange", function (data) {
316
316
  var _this$props$onChange = _this.props.onChange,
317
317
  onChange = _this$props$onChange === void 0 ? function (params) {} : _this$props$onChange;
318
- var updatedDate = data.date; // We'll need to update the date in time values of internal state
319
-
320
- var newTimeState = _toConsumableArray(_this.state.time); // Apply the currently selected time values (saved in state) to the updated date
321
-
318
+ var updatedDate = data.date; // Apply the currently selected time values (saved in state) to the updated date
322
319
 
323
320
  if (Array.isArray(data.date)) {
321
+ // We'll need to update the date in time values of internal state
322
+ var newTimeState = _toConsumableArray(_this.state.time);
323
+
324
324
  var start = data.date[0] ? _this.dateHelpers.applyDateToTime(newTimeState[0], data.date[0]) : null;
325
325
  var end = data.date[1] ? _this.dateHelpers.applyDateToTime(newTimeState[1], data.date[1]) : null;
326
326
  newTimeState[0] = start;
@@ -330,16 +330,21 @@ var Calendar = /*#__PURE__*/function (_React$Component) {
330
330
  newTimeState[1] = end;
331
331
  } else {
332
332
  updatedDate = [start];
333
- }
333
+ } // Update the date in time values of internal state
334
+
335
+
336
+ _this.setState({
337
+ time: newTimeState
338
+ });
334
339
  } else if (!Array.isArray(_this.props.value) && data.date) {
335
- newTimeState[0] = _this.dateHelpers.applyDateToTime(newTimeState[0], data.date);
336
- updatedDate = newTimeState[0];
337
- } // Update the date in time values of internal state
340
+ var _newTimeState = _this.dateHelpers.applyDateToTime(_this.state.time[0], data.date);
338
341
 
342
+ updatedDate = _newTimeState; // Update the date in time values of internal state
339
343
 
340
- _this.setState({
341
- time: newTimeState
342
- });
344
+ _this.setState({
345
+ time: [_newTimeState]
346
+ });
347
+ }
343
348
 
344
349
  onChange({
345
350
  date: updatedDate
@@ -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); } }
@@ -107,7 +107,39 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
107
107
 
108
108
  _defineProperty(_assertThisInitialized(_this), "dateHelpers", void 0);
109
109
 
110
- _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) {
111
143
  var isOpen = false;
112
144
  var isPseudoFocused = false;
113
145
  var calendarFocused = false;
@@ -184,9 +216,7 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
184
216
  inputValue: _this.formatDisplayValue(nextDate)
185
217
  }));
186
218
 
187
- _this.props.onChange && _this.props.onChange({
188
- date: nextDate
189
- });
219
+ _this.handleChange(nextDate);
190
220
  });
191
221
 
192
222
  _defineProperty(_assertThisInitialized(_this), "formatDisplayValue", function (date) {
@@ -290,16 +320,10 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
290
320
  var formatString = _this.normalizeDashes(_this.props.formatString);
291
321
 
292
322
  if (typeof mask === 'string' && inputValue === mask.replace(/9/g, ' ') || inputValue.length === 0) {
293
- if (_this.props.onChange) {
294
- if (_this.props.range) {
295
- _this.props.onChange({
296
- date: []
297
- });
298
- } else {
299
- _this.props.onChange({
300
- date: null
301
- });
302
- }
323
+ if (_this.props.range) {
324
+ _this.handleChange([]);
325
+ } else {
326
+ _this.handleChange(null);
303
327
  }
304
328
  }
305
329
 
@@ -330,19 +354,13 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
330
354
  endDate = parseDateString(right);
331
355
  }
332
356
 
333
- var onChange = _this.props.onChange;
334
-
335
- if (onChange) {
336
- 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
337
358
 
338
359
 
339
- 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);
340
361
 
341
- if (datesValid && rangeValid) {
342
- onChange({
343
- date: [startDate, endDate]
344
- });
345
- }
362
+ if (datesValid && rangeValid) {
363
+ _this.handleChange([startDate, endDate]);
346
364
  }
347
365
  } else {
348
366
  var dateString = _this.normalizeDashes(inputValue);
@@ -360,11 +378,10 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
360
378
 
361
379
  var _this$props3 = _this.props,
362
380
  displayValueAtRangeIndex = _this$props3.displayValueAtRangeIndex,
363
- _onChange = _this$props3.onChange,
364
381
  range = _this$props3.range,
365
382
  value = _this$props3.value;
366
383
 
367
- if (date && _this.dateHelpers.isValid(date) && _onChange) {
384
+ if (date && _this.dateHelpers.isValid(date)) {
368
385
  if (range && Array.isArray(value) && typeof displayValueAtRangeIndex === 'number') {
369
386
  var _value = _slicedToArray(value, 2),
370
387
  _left = _value[0],
@@ -374,22 +391,16 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
374
391
  _left = date;
375
392
 
376
393
  if (!_right) {
377
- _onChange({
378
- date: [_left]
379
- });
394
+ _this.handleChange([_left]);
380
395
  } else {
381
396
  if (_this.dateHelpers.isAfter(_right, _left) || _this.dateHelpers.isEqual(_left, _right)) {
382
- _onChange({
383
- date: [_left, _right]
384
- });
397
+ _this.handleChange([_left, _right]);
385
398
  } else {
386
399
  // Is resetting back to previous value appropriate? Invalid range is not
387
400
  // communicated to the user, but if it was not reset the text value would
388
401
  // show one value and date value another. This seems a bit better but clearly
389
402
  // has a downside.
390
- _onChange({
391
- date: _toConsumableArray(value)
392
- });
403
+ _this.handleChange(_toConsumableArray(value));
393
404
  }
394
405
  }
395
406
  } else if (displayValueAtRangeIndex === 1) {
@@ -397,26 +408,18 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
397
408
 
398
409
  if (!_left) {
399
410
  // If start value is not defined, set start/end to the same day.
400
- _onChange({
401
- date: [_right, _right]
402
- });
411
+ _this.handleChange([_right, _right]);
403
412
  } else {
404
413
  if (_this.dateHelpers.isAfter(_right, _left) || _this.dateHelpers.isEqual(_left, _right)) {
405
- _onChange({
406
- date: [_left, _right]
407
- });
414
+ _this.handleChange([_left, _right]);
408
415
  } else {
409
416
  // See comment above about resetting dates on invalid range
410
- _onChange({
411
- date: _toConsumableArray(value)
412
- });
417
+ _this.handleChange(_toConsumableArray(value));
413
418
  }
414
419
  }
415
420
  }
416
421
  } else {
417
- _onChange({
418
- date: date
419
- });
422
+ _this.handleChange(date);
420
423
  }
421
424
  }
422
425
  }
@@ -533,11 +536,6 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
533
536
  endDate = _split2$2 === void 0 ? '' : _split2$2;
534
537
 
535
538
  var value = inputRole === INPUT_ROLE.startDate ? startDate : inputRole === INPUT_ROLE.endDate ? endDate : this.state.inputValue;
536
-
537
- var onChange = function onChange(event) {
538
- return _this3.handleInputChange(event, inputRole);
539
- };
540
-
541
539
  return /*#__PURE__*/React.createElement(InputComponent, _extends({
542
540
  "aria-disabled": this.props.disabled,
543
541
  "aria-label": this.props['aria-label'] || (this.props.range ? locale.datepicker.ariaLabelRange : locale.datepicker.ariaLabel),
@@ -554,7 +552,9 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
554
552
  },
555
553
  onBlur: this.handleInputBlur,
556
554
  onKeyDown: this.handleKeyDown,
557
- onChange: onChange,
555
+ onChange: function onChange(event) {
556
+ return _this3.handleInputChange(event, inputRole);
557
+ },
558
558
  placeholder: placeholder,
559
559
  mask: this.getMask(),
560
560
  required: this.props.required,
@@ -614,7 +614,7 @@ var Datepicker = /*#__PURE__*/function (_React$Component) {
614
614
  trapTabbing: true,
615
615
  value: _this4.props.value
616
616
  }, _this4.props, {
617
- onChange: _this4.onChange,
617
+ onChange: _this4.onCalendarSelect,
618
618
  selectedInput: _this4.state.selectedInput,
619
619
  hasLockedBehavior: _this4.hasLockedBehavior()
620
620
  }))
@@ -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
  }]);
@@ -58,8 +58,29 @@ var StatefulContainer = /*#__PURE__*/function (_React$Component) {
58
58
  value: date
59
59
  });
60
60
 
61
- if (typeof _this.props.onChange === 'function') {
62
- _this.props.onChange(data);
61
+ var onChange = _this.props.onChange;
62
+
63
+ if (onChange) {
64
+ if (Array.isArray(date)) {
65
+ if (date.every(Boolean)) {
66
+ // flowlint-next-line unclear-type:off
67
+ onChange({
68
+ date: date
69
+ });
70
+ }
71
+ } else {
72
+ onChange({
73
+ date: date
74
+ });
75
+ }
76
+ }
77
+
78
+ var onRangeChange = _this.props.onRangeChange;
79
+
80
+ if (onRangeChange) {
81
+ onRangeChange({
82
+ date: date
83
+ });
63
84
  }
64
85
  });
65
86
 
@@ -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(Datepicker, extendedProps);
52
+ return /*#__PURE__*/React.createElement(Datepicker, _extends({}, extendedProps, {
53
+ // flowlint-next-line unclear-type:off
54
+ onChange: extendedProps.onChange
55
+ }));
51
56
  });
52
57
  }
53
58
  }]);
@@ -86,7 +86,7 @@ var DateHelpers = function DateHelpers(_adapter) {
86
86
  var UtilsClass = adapter.constructor;
87
87
  var className = adapter.constructor.name; // This ensures that if the adapter class isn't
88
88
  // supported it just falls back the default formats
89
- // NOTE: in e2e tests puppeteer seems to add
89
+ // NOTE: in e2e tests playwright seems to add
90
90
  // a JSHandle wrapping class to all objects
91
91
  // so className always resolves to JSHandle:e
92
92
  // and if falls back to the default
@@ -17,7 +17,9 @@ This source code is licensed under the MIT license found in the
17
17
  LICENSE file in the root directory of this source tree.
18
18
  */
19
19
  import * as React from 'react';
20
- import { ArrowLeft, ArrowRight, Check } from '../icon/index.js';
20
+ import ArrowLeft from '../icon/arrow-left.js';
21
+ import ArrowRight from '../icon/arrow-right.js';
22
+ import Check from '../icon/check.js';
21
23
  import { Button, KIND, SHAPE } from '../button/index.js';
22
24
  import { useStyletron } from '../styles/index.js';
23
25
  export function HelperSteps(_ref) {
@@ -85,7 +85,7 @@ var BaseInput = /*#__PURE__*/function (_React$Component) {
85
85
  });
86
86
 
87
87
  _defineProperty(_assertThisInitialized(_this), "onInputKeyDown", function (e) {
88
- if (_this.props.clearOnEscape && e.key === 'Escape' && _this.inputRef.current) {
88
+ if (_this.props.clearOnEscape && e.key === 'Escape' && _this.inputRef.current && !_this.props.readOnly) {
89
89
  _this.clearValue(); // prevent event from closing modal or doing something unexpected
90
90
 
91
91
 
@@ -100,19 +100,23 @@ var BaseInput = /*#__PURE__*/function (_React$Component) {
100
100
  });
101
101
 
102
102
  _defineProperty(_assertThisInitialized(_this), "onFocus", function (e) {
103
- _this.setState({
104
- isFocused: true
105
- });
103
+ if (!_this.props.readOnly) {
104
+ _this.setState({
105
+ isFocused: true
106
+ });
106
107
 
107
- _this.props.onFocus(e);
108
+ _this.props.onFocus(e);
109
+ }
108
110
  });
109
111
 
110
112
  _defineProperty(_assertThisInitialized(_this), "onBlur", function (e) {
111
- _this.setState({
112
- isFocused: false
113
- });
113
+ if (!_this.props.readOnly) {
114
+ _this.setState({
115
+ isFocused: false
116
+ });
114
117
 
115
- _this.props.onBlur(e);
118
+ _this.props.onBlur(e);
119
+ }
116
120
  });
117
121
 
118
122
  _defineProperty(_assertThisInitialized(_this), "handleFocusForMaskToggle", function (event) {
@@ -267,10 +271,11 @@ var BaseInput = /*#__PURE__*/function (_React$Component) {
267
271
  clearable = _this$props2.clearable,
268
272
  value = _this$props2.value,
269
273
  disabled = _this$props2.disabled,
274
+ readOnly = _this$props2.readOnly,
270
275
  _this$props2$override = _this$props2.overrides,
271
276
  overrides = _this$props2$override === void 0 ? {} : _this$props2$override;
272
277
 
273
- if (disabled || !clearable || value == null || typeof value === 'string' && value.length === 0) {
278
+ if (disabled || readOnly || !clearable || value == null || typeof value === 'string' && value.length === 0) {
274
279
  return null;
275
280
  }
276
281
 
@@ -360,6 +365,7 @@ var BaseInput = /*#__PURE__*/function (_React$Component) {
360
365
  "aria-required": this.props.required,
361
366
  autoComplete: autoComplete,
362
367
  disabled: this.props.disabled,
368
+ readOnly: this.props.readOnly,
363
369
  id: this.props.id,
364
370
  inputMode: this.props.inputMode,
365
371
  maxLength: this.props.maxLength,
@@ -419,7 +425,8 @@ _defineProperty(BaseInput, "defaultProps", {
419
425
  required: false,
420
426
  role: null,
421
427
  size: SIZE.default,
422
- type: 'text'
428
+ type: 'text',
429
+ readOnly: false
423
430
  });
424
431
 
425
432
  export default BaseInput;
@@ -70,23 +70,27 @@ var Input = /*#__PURE__*/function (_React$Component) {
70
70
  _this = _super.call.apply(_super, [this].concat(args));
71
71
 
72
72
  _defineProperty(_assertThisInitialized(_this), "state", {
73
- isFocused: _this.props.autoFocus || false
73
+ isFocused: _this.props.autoFocus && !_this.props.readOnly || false
74
74
  });
75
75
 
76
76
  _defineProperty(_assertThisInitialized(_this), "onFocus", function (e) {
77
- _this.setState({
78
- isFocused: true
79
- });
77
+ if (!_this.props.readOnly) {
78
+ _this.setState({
79
+ isFocused: true
80
+ });
80
81
 
81
- _this.props.onFocus(e);
82
+ _this.props.onFocus(e);
83
+ }
82
84
  });
83
85
 
84
86
  _defineProperty(_assertThisInitialized(_this), "onBlur", function (e) {
85
- _this.setState({
86
- isFocused: false
87
- });
87
+ if (!_this.props.readOnly) {
88
+ _this.setState({
89
+ isFocused: false
90
+ });
88
91
 
89
- _this.props.onBlur(e);
92
+ _this.props.onBlur(e);
93
+ }
90
94
  });
91
95
 
92
96
  return _this;
@@ -163,7 +167,8 @@ _defineProperty(Input, "defaultProps", {
163
167
  startEnhancer: null,
164
168
  endEnhancer: null,
165
169
  clearable: false,
166
- type: 'text'
170
+ type: 'text',
171
+ readOnly: false
167
172
  });
168
173
 
169
174
  function getAdjoinedProp(startEnhancer, endEnhancer) {
@@ -32,14 +32,16 @@ var MaskOverride = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
32
32
  onBlur = _ref.onBlur,
33
33
  value = _ref.value,
34
34
  disabled = _ref.disabled,
35
- restProps = _objectWithoutProperties(_ref, ["startEnhancer", "endEnhancer", "error", "positive", "onChange", "onFocus", "onBlur", "value", "disabled"]);
35
+ readOnly = _ref.readOnly,
36
+ restProps = _objectWithoutProperties(_ref, ["startEnhancer", "endEnhancer", "error", "positive", "onChange", "onFocus", "onBlur", "value", "disabled", "readOnly"]);
36
37
 
37
38
  return /*#__PURE__*/React.createElement(InputMask, _extends({
38
39
  onChange: onChange,
39
40
  onFocus: onFocus,
40
41
  onBlur: onBlur,
41
42
  value: value,
42
- disabled: disabled
43
+ disabled: disabled,
44
+ readOnly: readOnly
43
45
  }, restProps), function (props) {
44
46
  return /*#__PURE__*/React.createElement(StyledInput, _extends({
45
47
  ref: ref,
@@ -47,7 +49,8 @@ var MaskOverride = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
47
49
  onFocus: onFocus,
48
50
  onBlur: onBlur,
49
51
  value: value,
50
- disabled: disabled
52
+ disabled: disabled,
53
+ readOnly: readOnly
51
54
  }, props));
52
55
  });
53
56
  });
@@ -10,7 +10,8 @@ export function getSharedProps(props, state) {
10
10
  positive = props.positive,
11
11
  adjoined = props.adjoined,
12
12
  size = props.size,
13
- required = props.required;
13
+ required = props.required,
14
+ readOnly = props.readOnly;
14
15
  var isFocused = state.isFocused;
15
16
  return {
16
17
  $isFocused: isFocused,
@@ -19,6 +20,7 @@ export function getSharedProps(props, state) {
19
20
  $positive: positive,
20
21
  $adjoined: adjoined,
21
22
  $size: size,
22
- $required: required
23
+ $required: required,
24
+ $isReadOnly: readOnly
23
25
  };
24
26
  }