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,9 @@
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
+ export { Banner } from './banner.js';
8
+ export * from './constants.js';
9
+ export * from './styled-components.js';
@@ -0,0 +1,122 @@
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 { styled } from '../styles/index.js';
8
+ import { ACTION_POSITION } from './constants.js';
9
+ export const StyledRoot = styled('div', ({
10
+ $theme,
11
+ $backgroundColor,
12
+ $color,
13
+ $nested
14
+ }) => {
15
+ const radius = $nested ? $theme.borders.radius300 : $theme.borders.radius400;
16
+ return {
17
+ backgroundColor: $backgroundColor,
18
+ borderStartStartRadius: radius,
19
+ borderStartEndRadius: radius,
20
+ borderEndStartRadius: radius,
21
+ borderEndEndRadius: radius,
22
+ color: $color,
23
+ display: 'grid',
24
+ gridColumnGap: $theme.sizing.scale600,
25
+ gridTemplateColumns: 'min-content auto min-content',
26
+ gridTemplateRows: 'auto min-content',
27
+ margin: $theme.sizing.scale600
28
+ };
29
+ });
30
+ StyledRoot.displayName = "StyledRoot";
31
+ export const StyledLeadingContent = styled('div', ({
32
+ $theme,
33
+ $includesArtwork
34
+ }) => {
35
+ return {
36
+ alignItems: 'center',
37
+ display: 'flex',
38
+ paddingInlineStart: $includesArtwork ? $theme.sizing.scale600 : null
39
+ };
40
+ });
41
+ StyledLeadingContent.displayName = "StyledLeadingContent";
42
+ export const StyledMessageContent = styled('div', ({
43
+ $theme,
44
+ $actionPosition
45
+ }) => {
46
+ return {
47
+ display: 'flex',
48
+ flexDirection: 'column',
49
+ justifyContent: 'center',
50
+ paddingBlockStart: $theme.sizing.scale600,
51
+ paddingBlockEnd: $actionPosition === ACTION_POSITION.trailing ? $theme.sizing.scale600 : null
52
+ };
53
+ });
54
+ StyledMessageContent.displayName = "StyledMessageContent";
55
+ export const StyledTrailingContent = styled('div', ({
56
+ $theme
57
+ }) => {
58
+ return {
59
+ display: 'flex',
60
+ gridRowEnd: 'span 2',
61
+ marginInlineStart: 'auto'
62
+ };
63
+ });
64
+ StyledTrailingContent.displayName = "StyledTrailingContent";
65
+ export const StyledBelowContent = styled('div', ({
66
+ $theme,
67
+ $actionPosition
68
+ }) => {
69
+ return {
70
+ gridColumnStart: 2,
71
+ paddingBlockStart: $actionPosition === ACTION_POSITION.below ? $theme.sizing.scale300 : null,
72
+ paddingBlockEnd: $actionPosition === ACTION_POSITION.below ? $theme.sizing.scale600 : null
73
+ };
74
+ });
75
+ StyledBelowContent.displayName = "StyledBelowContent";
76
+ export const StyledTitle = styled('div', ({
77
+ $theme
78
+ }) => {
79
+ return $theme.typography.LabelMedium;
80
+ });
81
+ StyledTitle.displayName = "StyledTitle";
82
+ export const StyledMessage = styled('div', ({
83
+ $theme
84
+ }) => {
85
+ return $theme.typography.ParagraphMedium;
86
+ });
87
+ StyledMessage.displayName = "StyledMessage";
88
+ export const StyledTrailingButtonContainer = styled('div', ({
89
+ $theme
90
+ }) => {
91
+ return {
92
+ display: 'flex',
93
+ alignItems: 'center',
94
+ paddingInlineEnd: $theme.sizing.scale600
95
+ };
96
+ });
97
+ StyledTrailingButtonContainer.displayName = "StyledTrailingButtonContainer";
98
+ export const StyledTrailingIconButton = styled('button', ({
99
+ $theme,
100
+ $nested
101
+ }) => {
102
+ const radius = $nested ? $theme.borders.radius300 : $theme.borders.radius400;
103
+ return {
104
+ alignItems: 'center',
105
+ background: 'none',
106
+ border: 'none',
107
+ borderStartEndRadius: radius,
108
+ borderEndEndRadius: radius,
109
+ color: 'inherit',
110
+ cursor: 'pointer',
111
+ display: 'flex',
112
+ paddingInlineStart: $theme.sizing.scale600,
113
+ paddingInlineEnd: $theme.sizing.scale600,
114
+ ':hover': {
115
+ boxShadow: 'inset 999px 999px 0px rgba(0, 0, 0, 0.04)'
116
+ },
117
+ ':active': {
118
+ boxShadow: 'inset 999px 999px 0px rgba(0, 0, 0, 0.08)'
119
+ }
120
+ };
121
+ });
122
+ StyledTrailingIconButton.displayName = "StyledTrailingIconButton";
@@ -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';
@@ -39,7 +39,11 @@ export function Breadcrumbs(props) {
39
39
  $itemIndex: index
40
40
  }, baseListItemProps), child, (showTrailingSeparator || index !== childrenArray.length - 1) && /*#__PURE__*/React.createElement(Separator, _extends({}, baseSeparatorProps, {
41
41
  key: `separator-${index}`
42
- }), /*#__PURE__*/React.createElement(ThemeContext.Consumer, null, theme => theme.direction === 'rtl' ? /*#__PURE__*/React.createElement(Left, baseIconProps) : /*#__PURE__*/React.createElement(Right, baseIconProps)))));
42
+ }), /*#__PURE__*/React.createElement(ThemeContext.Consumer, null, theme => theme.direction === 'rtl' ? /*#__PURE__*/React.createElement(Left, _extends({
43
+ size: 16
44
+ }, baseIconProps)) : /*#__PURE__*/React.createElement(Right, _extends({
45
+ size: 16
46
+ }, baseIconProps))))));
43
47
  });
44
48
  return /*#__PURE__*/React.createElement(LocaleContext.Consumer, null, locale => /*#__PURE__*/React.createElement(Root, _extends({
45
49
  "aria-label": props['aria-label'] || props.ariaLabel || locale.breadcrumbs.ariaLabel,
@@ -68,6 +68,7 @@ class Button extends React.Component {
68
68
  endEnhancer,
69
69
  children,
70
70
  forwardedRef,
71
+ colors,
71
72
  ...restProps
72
73
  } = this.props; // Get overrides
73
74
 
@@ -252,11 +252,11 @@ export default class Calendar extends React.Component {
252
252
  const {
253
253
  onChange = params => {}
254
254
  } = this.props;
255
- let updatedDate = data.date; // We'll need to update the date in time values of internal state
256
-
257
- const newTimeState = [...this.state.time]; // Apply the currently selected time values (saved in state) to the updated date
255
+ let updatedDate = data.date; // Apply the currently selected time values (saved in state) to the updated date
258
256
 
259
257
  if (Array.isArray(data.date)) {
258
+ // We'll need to update the date in time values of internal state
259
+ const newTimeState = [...this.state.time];
260
260
  const start = data.date[0] ? this.dateHelpers.applyDateToTime(newTimeState[0], data.date[0]) : null;
261
261
  const end = data.date[1] ? this.dateHelpers.applyDateToTime(newTimeState[1], data.date[1]) : null;
262
262
  newTimeState[0] = start;
@@ -266,16 +266,21 @@ export default class Calendar extends React.Component {
266
266
  newTimeState[1] = end;
267
267
  } else {
268
268
  updatedDate = [start];
269
- }
269
+ } // Update the date in time values of internal state
270
+
271
+
272
+ this.setState({
273
+ time: newTimeState
274
+ });
270
275
  } else if (!Array.isArray(this.props.value) && data.date) {
271
- newTimeState[0] = this.dateHelpers.applyDateToTime(newTimeState[0], data.date);
272
- updatedDate = newTimeState[0];
273
- } // Update the date in time values of internal state
276
+ const newTimeState = this.dateHelpers.applyDateToTime(this.state.time[0], data.date);
277
+ updatedDate = newTimeState; // Update the date in time values of internal state
274
278
 
279
+ this.setState({
280
+ time: [newTimeState]
281
+ });
282
+ }
275
283
 
276
- this.setState({
277
- time: newTimeState
278
- });
279
284
  onChange({
280
285
  date: updatedDate
281
286
  });
@@ -45,7 +45,39 @@ export default class Datepicker extends React.Component {
45
45
 
46
46
  _defineProperty(this, "dateHelpers", void 0);
47
47
 
48
- _defineProperty(this, "onChange", data => {
48
+ _defineProperty(this, "handleChange", date => {
49
+ const onChange = this.props.onChange;
50
+ const onRangeChange = this.props.onRangeChange;
51
+
52
+ if (Array.isArray(date)) {
53
+ if (onChange && date.every(Boolean)) {
54
+ // flowlint-next-line unclear-type:off
55
+ onChange({
56
+ date: date
57
+ });
58
+ }
59
+
60
+ if (onRangeChange) {
61
+ onRangeChange({
62
+ date: [...date]
63
+ });
64
+ }
65
+ } else {
66
+ if (onChange) {
67
+ onChange({
68
+ date
69
+ });
70
+ }
71
+
72
+ if (onRangeChange) {
73
+ onRangeChange({
74
+ date
75
+ });
76
+ }
77
+ }
78
+ });
79
+
80
+ _defineProperty(this, "onCalendarSelect", data => {
49
81
  let isOpen = false;
50
82
  let isPseudoFocused = false;
51
83
  let calendarFocused = false;
@@ -114,9 +146,7 @@ export default class Datepicker extends React.Component {
114
146
  }),
115
147
  inputValue: this.formatDisplayValue(nextDate)
116
148
  });
117
- this.props.onChange && this.props.onChange({
118
- date: nextDate
119
- });
149
+ this.handleChange(nextDate);
120
150
  });
121
151
 
122
152
  _defineProperty(this, "formatDisplayValue", date => {
@@ -218,16 +248,10 @@ export default class Datepicker extends React.Component {
218
248
  const formatString = this.normalizeDashes(this.props.formatString);
219
249
 
220
250
  if (typeof mask === 'string' && inputValue === mask.replace(/9/g, ' ') || inputValue.length === 0) {
221
- if (this.props.onChange) {
222
- if (this.props.range) {
223
- this.props.onChange({
224
- date: []
225
- });
226
- } else {
227
- this.props.onChange({
228
- date: null
229
- });
230
- }
251
+ if (this.props.range) {
252
+ this.handleChange([]);
253
+ } else {
254
+ this.handleChange(null);
231
255
  }
232
256
  }
233
257
 
@@ -253,18 +277,12 @@ export default class Datepicker extends React.Component {
253
277
  endDate = parseDateString(right);
254
278
  }
255
279
 
256
- const onChange = this.props.onChange;
280
+ const datesValid = this.dateHelpers.isValid(startDate) && this.dateHelpers.isValid(endDate); // added equal case so that times within the same day can be expressed
257
281
 
258
- if (onChange) {
259
- const datesValid = this.dateHelpers.isValid(startDate) && this.dateHelpers.isValid(endDate); // added equal case so that times within the same day can be expressed
260
-
261
- const rangeValid = this.dateHelpers.isAfter(endDate, startDate) || this.dateHelpers.isEqual(startDate, endDate);
282
+ const rangeValid = this.dateHelpers.isAfter(endDate, startDate) || this.dateHelpers.isEqual(startDate, endDate);
262
283
 
263
- if (datesValid && rangeValid) {
264
- onChange({
265
- date: [startDate, endDate]
266
- });
267
- }
284
+ if (datesValid && rangeValid) {
285
+ this.handleChange([startDate, endDate]);
268
286
  }
269
287
  } else {
270
288
  const dateString = this.normalizeDashes(inputValue);
@@ -280,12 +298,11 @@ export default class Datepicker extends React.Component {
280
298
 
281
299
  const {
282
300
  displayValueAtRangeIndex,
283
- onChange,
284
301
  range,
285
302
  value
286
303
  } = this.props;
287
304
 
288
- if (date && this.dateHelpers.isValid(date) && onChange) {
305
+ if (date && this.dateHelpers.isValid(date)) {
289
306
  if (range && Array.isArray(value) && typeof displayValueAtRangeIndex === 'number') {
290
307
  let [left, right] = value;
291
308
 
@@ -293,22 +310,16 @@ export default class Datepicker extends React.Component {
293
310
  left = date;
294
311
 
295
312
  if (!right) {
296
- onChange({
297
- date: [left]
298
- });
313
+ this.handleChange([left]);
299
314
  } else {
300
315
  if (this.dateHelpers.isAfter(right, left) || this.dateHelpers.isEqual(left, right)) {
301
- onChange({
302
- date: [left, right]
303
- });
316
+ this.handleChange([left, right]);
304
317
  } else {
305
318
  // Is resetting back to previous value appropriate? Invalid range is not
306
319
  // communicated to the user, but if it was not reset the text value would
307
320
  // show one value and date value another. This seems a bit better but clearly
308
321
  // has a downside.
309
- onChange({
310
- date: [...value]
311
- });
322
+ this.handleChange([...value]);
312
323
  }
313
324
  }
314
325
  } else if (displayValueAtRangeIndex === 1) {
@@ -316,26 +327,18 @@ export default class Datepicker extends React.Component {
316
327
 
317
328
  if (!left) {
318
329
  // If start value is not defined, set start/end to the same day.
319
- onChange({
320
- date: [right, right]
321
- });
330
+ this.handleChange([right, right]);
322
331
  } else {
323
332
  if (this.dateHelpers.isAfter(right, left) || this.dateHelpers.isEqual(left, right)) {
324
- onChange({
325
- date: [left, right]
326
- });
333
+ this.handleChange([left, right]);
327
334
  } else {
328
335
  // See comment above about resetting dates on invalid range
329
- onChange({
330
- date: [...value]
331
- });
336
+ this.handleChange([...value]);
332
337
  }
333
338
  }
334
339
  }
335
340
  } else {
336
- onChange({
337
- date
338
- });
341
+ this.handleChange(date);
339
342
  }
340
343
  }
341
344
  }
@@ -427,9 +430,6 @@ export default class Datepicker extends React.Component {
427
430
  const placeholder = this.props.placeholder || this.props.placeholder === '' ? this.props.placeholder : this.props.range && !this.props.separateRangeInputs ? `YYYY/MM/DD ${INPUT_DELIMITER} YYYY/MM/DD` : 'YYYY/MM/DD';
428
431
  const [startDate = '', endDate = ''] = (this.state.inputValue || '').split(` ${INPUT_DELIMITER} `);
429
432
  const value = inputRole === INPUT_ROLE.startDate ? startDate : inputRole === INPUT_ROLE.endDate ? endDate : this.state.inputValue;
430
-
431
- const onChange = event => this.handleInputChange(event, inputRole);
432
-
433
433
  return /*#__PURE__*/React.createElement(InputComponent, _extends({
434
434
  "aria-disabled": this.props.disabled,
435
435
  "aria-label": this.props['aria-label'] || (this.props.range ? locale.datepicker.ariaLabelRange : locale.datepicker.ariaLabel),
@@ -444,7 +444,7 @@ export default class Datepicker extends React.Component {
444
444
  onFocus: () => this.open(inputRole),
445
445
  onBlur: this.handleInputBlur,
446
446
  onKeyDown: this.handleKeyDown,
447
- onChange: onChange,
447
+ onChange: event => this.handleInputChange(event, inputRole),
448
448
  placeholder: placeholder,
449
449
  mask: this.getMask(),
450
450
  required: this.props.required,
@@ -477,7 +477,7 @@ export default class Datepicker extends React.Component {
477
477
  trapTabbing: true,
478
478
  value: this.props.value
479
479
  }, this.props, {
480
- onChange: this.onChange,
480
+ onChange: this.onCalendarSelect,
481
481
  selectedInput: this.state.selectedInput,
482
482
  hasLockedBehavior: this.hasLockedBehavior()
483
483
  }))
@@ -1,3 +1,5 @@
1
+ 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); }
2
+
1
3
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
4
 
3
5
  /*
@@ -12,7 +14,10 @@ import Calendar from './calendar.js';
12
14
 
13
15
  class StatefulComponent extends React.Component {
14
16
  render() {
15
- return /*#__PURE__*/React.createElement(StatefulContainer, this.props, extendedProps => /*#__PURE__*/React.createElement(Calendar, extendedProps));
17
+ return /*#__PURE__*/React.createElement(StatefulContainer, this.props, extendedProps => /*#__PURE__*/React.createElement(Calendar, _extends({}, extendedProps, {
18
+ // flowlint-next-line unclear-type:off
19
+ onChange: extendedProps.onChange
20
+ })));
16
21
  }
17
22
 
18
23
  }
@@ -20,9 +20,29 @@ class StatefulContainer extends React.Component {
20
20
  this.internalSetState(STATE_CHANGE_TYPE.change, {
21
21
  value: date
22
22
  });
23
+ const onChange = this.props.onChange;
23
24
 
24
- if (typeof this.props.onChange === 'function') {
25
- this.props.onChange(data);
25
+ if (onChange) {
26
+ if (Array.isArray(date)) {
27
+ if (date.every(Boolean)) {
28
+ // flowlint-next-line unclear-type:off
29
+ onChange({
30
+ date: date
31
+ });
32
+ }
33
+ } else {
34
+ onChange({
35
+ date
36
+ });
37
+ }
38
+ }
39
+
40
+ const onRangeChange = this.props.onRangeChange;
41
+
42
+ if (onRangeChange) {
43
+ onRangeChange({
44
+ date
45
+ });
26
46
  }
27
47
  });
28
48
 
@@ -1,3 +1,5 @@
1
+ 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); }
2
+
1
3
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
4
 
3
5
  /*
@@ -12,7 +14,10 @@ import Datepicker from './datepicker.js';
12
14
 
13
15
  class StatefulComponent extends React.Component {
14
16
  render() {
15
- return /*#__PURE__*/React.createElement(StatefulContainer, this.props, extendedProps => /*#__PURE__*/React.createElement(Datepicker, extendedProps));
17
+ return /*#__PURE__*/React.createElement(StatefulContainer, this.props, extendedProps => /*#__PURE__*/React.createElement(Datepicker, _extends({}, extendedProps, {
18
+ // flowlint-next-line unclear-type:off
19
+ onChange: extendedProps.onChange
20
+ })));
16
21
  }
17
22
 
18
23
  }
@@ -63,7 +63,7 @@ class DateHelpers {
63
63
  const UtilsClass = adapter.constructor;
64
64
  const className = adapter.constructor.name; // This ensures that if the adapter class isn't
65
65
  // supported it just falls back the default formats
66
- // NOTE: in e2e tests puppeteer seems to add
66
+ // NOTE: in e2e tests playwright seems to add
67
67
  // a JSHandle wrapping class to all objects
68
68
  // so className always resolves to JSHandle:e
69
69
  // and if falls back to the default
@@ -5,7 +5,9 @@ This source code is licensed under the MIT license found in the
5
5
  LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import * as React from 'react';
8
- import { ArrowLeft, ArrowRight, Check } from '../icon/index.js';
8
+ import ArrowLeft from '../icon/arrow-left.js';
9
+ import ArrowRight from '../icon/arrow-right.js';
10
+ import Check from '../icon/check.js';
9
11
  import { Button, KIND, SHAPE } from '../button/index.js';
10
12
  import { useStyletron } from '../styles/index.js';
11
13
  export function HelperSteps({
@@ -37,7 +37,7 @@ class BaseInput extends React.Component {
37
37
  });
38
38
 
39
39
  _defineProperty(this, "onInputKeyDown", e => {
40
- if (this.props.clearOnEscape && e.key === 'Escape' && this.inputRef.current) {
40
+ if (this.props.clearOnEscape && e.key === 'Escape' && this.inputRef.current && !this.props.readOnly) {
41
41
  this.clearValue(); // prevent event from closing modal or doing something unexpected
42
42
 
43
43
  e.stopPropagation();
@@ -51,17 +51,21 @@ class BaseInput extends React.Component {
51
51
  });
52
52
 
53
53
  _defineProperty(this, "onFocus", e => {
54
- this.setState({
55
- isFocused: true
56
- });
57
- this.props.onFocus(e);
54
+ if (!this.props.readOnly) {
55
+ this.setState({
56
+ isFocused: true
57
+ });
58
+ this.props.onFocus(e);
59
+ }
58
60
  });
59
61
 
60
62
  _defineProperty(this, "onBlur", e => {
61
- this.setState({
62
- isFocused: false
63
- });
64
- this.props.onBlur(e);
63
+ if (!this.props.readOnly) {
64
+ this.setState({
65
+ isFocused: false
66
+ });
67
+ this.props.onBlur(e);
68
+ }
65
69
  });
66
70
 
67
71
  _defineProperty(this, "handleFocusForMaskToggle", event => {
@@ -192,10 +196,11 @@ class BaseInput extends React.Component {
192
196
  clearable,
193
197
  value,
194
198
  disabled,
199
+ readOnly,
195
200
  overrides = {}
196
201
  } = this.props;
197
202
 
198
- if (disabled || !clearable || value == null || typeof value === 'string' && value.length === 0) {
203
+ if (disabled || readOnly || !clearable || value == null || typeof value === 'string' && value.length === 0) {
199
204
  return null;
200
205
  }
201
206
 
@@ -265,6 +270,7 @@ class BaseInput extends React.Component {
265
270
  "aria-required": this.props.required,
266
271
  autoComplete: autoComplete,
267
272
  disabled: this.props.disabled,
273
+ readOnly: this.props.readOnly,
268
274
  id: this.props.id,
269
275
  inputMode: this.props.inputMode,
270
276
  maxLength: this.props.maxLength,
@@ -322,7 +328,8 @@ _defineProperty(BaseInput, "defaultProps", {
322
328
  required: false,
323
329
  role: null,
324
330
  size: SIZE.default,
325
- type: 'text'
331
+ type: 'text',
332
+ readOnly: false
326
333
  });
327
334
 
328
335
  export default BaseInput;
package/es/input/input.js CHANGED
@@ -20,21 +20,25 @@ class Input extends React.Component {
20
20
  super(...args);
21
21
 
22
22
  _defineProperty(this, "state", {
23
- isFocused: this.props.autoFocus || false
23
+ isFocused: this.props.autoFocus && !this.props.readOnly || false
24
24
  });
25
25
 
26
26
  _defineProperty(this, "onFocus", e => {
27
- this.setState({
28
- isFocused: true
29
- });
30
- this.props.onFocus(e);
27
+ if (!this.props.readOnly) {
28
+ this.setState({
29
+ isFocused: true
30
+ });
31
+ this.props.onFocus(e);
32
+ }
31
33
  });
32
34
 
33
35
  _defineProperty(this, "onBlur", e => {
34
- this.setState({
35
- isFocused: false
36
- });
37
- this.props.onBlur(e);
36
+ if (!this.props.readOnly) {
37
+ this.setState({
38
+ isFocused: false
39
+ });
40
+ this.props.onBlur(e);
41
+ }
38
42
  });
39
43
  }
40
44
 
@@ -94,7 +98,8 @@ _defineProperty(Input, "defaultProps", {
94
98
  startEnhancer: null,
95
99
  endEnhancer: null,
96
100
  clearable: false,
97
- type: 'text'
101
+ type: 'text',
102
+ readOnly: false
98
103
  });
99
104
 
100
105
  function getAdjoinedProp(startEnhancer, endEnhancer) {
@@ -23,6 +23,7 @@ const MaskOverride = /*#__PURE__*/React.forwardRef(({
23
23
  onBlur,
24
24
  value,
25
25
  disabled,
26
+ readOnly,
26
27
  ...restProps
27
28
  }, ref) => {
28
29
  return /*#__PURE__*/React.createElement(InputMask, _extends({
@@ -30,14 +31,16 @@ const MaskOverride = /*#__PURE__*/React.forwardRef(({
30
31
  onFocus: onFocus,
31
32
  onBlur: onBlur,
32
33
  value: value,
33
- disabled: disabled
34
+ disabled: disabled,
35
+ readOnly: readOnly
34
36
  }, restProps), props => /*#__PURE__*/React.createElement(StyledInput, _extends({
35
37
  ref: ref,
36
38
  onChange: onChange,
37
39
  onFocus: onFocus,
38
40
  onBlur: onBlur,
39
41
  value: value,
40
- disabled: disabled
42
+ disabled: disabled,
43
+ readOnly: readOnly
41
44
  }, props)));
42
45
  });
43
46
  MaskOverride.displayName = 'MaskOverride';
package/es/input/utils.js CHANGED
@@ -11,7 +11,8 @@ export function getSharedProps(props, state) {
11
11
  positive,
12
12
  adjoined,
13
13
  size,
14
- required
14
+ required,
15
+ readOnly
15
16
  } = props;
16
17
  const {
17
18
  isFocused
@@ -23,6 +24,7 @@ export function getSharedProps(props, state) {
23
24
  $positive: positive,
24
25
  $adjoined: adjoined,
25
26
  $size: size,
26
- $required: required
27
+ $required: required,
28
+ $isReadOnly: readOnly
27
29
  };
28
30
  }