baseui 10.12.1 → 11.0.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 (271) 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 +1 -1
  32. package/data-table/data-table.js.flow +1 -1
  33. package/data-table/header-cell.js +3 -0
  34. package/data-table/header-cell.js.flow +1 -1
  35. package/datepicker/calendar.js +15 -7
  36. package/datepicker/calendar.js.flow +23 -9
  37. package/datepicker/constants.js +12 -2
  38. package/datepicker/constants.js.flow +10 -0
  39. package/datepicker/datepicker.js +61 -30
  40. package/datepicker/datepicker.js.flow +77 -37
  41. package/datepicker/day.js +85 -34
  42. package/datepicker/day.js.flow +118 -54
  43. package/datepicker/locale.js.flow +0 -1
  44. package/datepicker/month.js +3 -1
  45. package/datepicker/month.js.flow +2 -0
  46. package/datepicker/stateful-container.js.flow +2 -1
  47. package/datepicker/styled-components.js +23 -1
  48. package/datepicker/styled-components.js.flow +12 -2
  49. package/datepicker/types.js.flow +35 -10
  50. package/datepicker/utils/date-helpers.js +30 -0
  51. package/datepicker/utils/date-helpers.js.flow +12 -0
  52. package/datepicker/week.js +3 -1
  53. package/datepicker/week.js.flow +2 -0
  54. package/es/accordion/accordion.js +52 -12
  55. package/es/accordion/panel.js +7 -5
  56. package/es/accordion/stateless-accordion.js +2 -4
  57. package/es/button/constants.js +1 -2
  58. package/es/button/styled-components.js +2 -29
  59. package/es/checkbox/checkbox.js +7 -32
  60. package/es/checkbox/constants.js +2 -1
  61. package/es/checkbox/index.js +1 -1
  62. package/es/checkbox/styled-components.js +51 -146
  63. package/es/data-table/column-categorical.js +1 -1
  64. package/es/data-table/column-datetime.js +1 -1
  65. package/es/data-table/column.js +6 -2
  66. package/es/data-table/data-table.js +1 -1
  67. package/es/data-table/header-cell.js +3 -0
  68. package/es/datepicker/calendar.js +15 -7
  69. package/es/datepicker/constants.js +8 -0
  70. package/es/datepicker/datepicker.js +56 -29
  71. package/es/datepicker/day.js +77 -34
  72. package/es/datepicker/month.js +3 -1
  73. package/es/datepicker/styled-components.js +8 -2
  74. package/es/datepicker/types.js +1 -1
  75. package/es/datepicker/utils/date-helpers.js +16 -0
  76. package/es/datepicker/week.js +3 -1
  77. package/es/file-uploader/file-uploader.js +4 -4
  78. package/es/header-navigation/styled-components.js +3 -3
  79. package/es/helpers/overrides.js +1 -2
  80. package/es/input/styled-components.js +4 -4
  81. package/es/layer/layer.js +4 -4
  82. package/es/locale/index.js +0 -7
  83. package/es/menu/stateful-container.js +0 -1
  84. package/es/menu/styled-components.js +1 -1
  85. package/es/modal/index.js +1 -1
  86. package/es/modal/modal.js +19 -65
  87. package/es/modal/styled-components.js +12 -48
  88. package/es/phone-input/default-props.js +1 -1
  89. package/es/phone-input/index.js +0 -4
  90. package/es/phone-input/phone-input-lite.js +55 -31
  91. package/es/radio/radio.js +1 -7
  92. package/es/radio/radiogroup.js +3 -28
  93. package/es/radio/styled-components.js +4 -5
  94. package/es/rating/styled-components.js +3 -3
  95. package/es/select/index.js +1 -2
  96. package/es/select/select-component.js +4 -8
  97. package/es/select/styled-components.js +4 -4
  98. package/es/snackbar/styled-components.js +2 -2
  99. package/es/spinner/index.js +3 -9
  100. package/es/spinner/styled-components.js +2 -32
  101. package/es/table/filter.js +3 -3
  102. package/es/tag/styled-components.js +1 -1
  103. package/es/themes/dark-theme/color-component-tokens.js +0 -38
  104. package/es/themes/dark-theme/color-tokens.js +0 -2
  105. package/es/themes/dark-theme/create-dark-theme.js +0 -2
  106. package/es/themes/dark-theme/dark-theme.js +0 -2
  107. package/es/themes/light-theme/color-component-tokens.js +0 -38
  108. package/es/themes/light-theme/color-tokens.js +0 -2
  109. package/es/themes/light-theme/create-light-theme.js +0 -2
  110. package/es/themes/light-theme/light-theme.js +0 -2
  111. package/es/timepicker/timepicker.js +1 -8
  112. package/es/typography/index.js +1 -31
  113. package/esm/accordion/accordion.js +60 -13
  114. package/esm/accordion/panel.js +7 -6
  115. package/esm/accordion/stateless-accordion.js +2 -4
  116. package/esm/button/constants.js +1 -2
  117. package/esm/button/styled-components.js +2 -29
  118. package/esm/checkbox/checkbox.js +7 -30
  119. package/esm/checkbox/constants.js +2 -1
  120. package/esm/checkbox/index.js +1 -1
  121. package/esm/checkbox/styled-components.js +52 -147
  122. package/esm/data-table/column-categorical.js +1 -1
  123. package/esm/data-table/column-datetime.js +1 -1
  124. package/esm/data-table/column.js +6 -2
  125. package/esm/data-table/data-table.js +1 -1
  126. package/esm/data-table/header-cell.js +3 -0
  127. package/esm/datepicker/calendar.js +15 -7
  128. package/esm/datepicker/constants.js +8 -0
  129. package/esm/datepicker/datepicker.js +60 -30
  130. package/esm/datepicker/day.js +84 -34
  131. package/esm/datepicker/month.js +3 -1
  132. package/esm/datepicker/styled-components.js +24 -2
  133. package/esm/datepicker/types.js +1 -1
  134. package/esm/datepicker/utils/date-helpers.js +30 -0
  135. package/esm/datepicker/week.js +3 -1
  136. package/esm/file-uploader/file-uploader.js +4 -4
  137. package/esm/header-navigation/styled-components.js +3 -3
  138. package/esm/helpers/overrides.js +1 -2
  139. package/esm/input/styled-components.js +4 -4
  140. package/esm/layer/layer.js +4 -4
  141. package/esm/locale/index.js +0 -7
  142. package/esm/menu/stateful-container.js +0 -1
  143. package/esm/menu/styled-components.js +1 -1
  144. package/esm/modal/index.js +1 -1
  145. package/esm/modal/modal.js +28 -71
  146. package/esm/modal/styled-components.js +6 -38
  147. package/esm/phone-input/default-props.js +1 -1
  148. package/esm/phone-input/index.js +0 -4
  149. package/esm/phone-input/phone-input-lite.js +60 -37
  150. package/esm/radio/radio.js +1 -7
  151. package/esm/radio/radiogroup.js +3 -28
  152. package/esm/radio/styled-components.js +4 -5
  153. package/esm/rating/styled-components.js +3 -3
  154. package/esm/select/index.js +1 -2
  155. package/esm/select/select-component.js +4 -8
  156. package/esm/select/styled-components.js +4 -4
  157. package/esm/snackbar/styled-components.js +2 -2
  158. package/esm/spinner/index.js +3 -9
  159. package/esm/spinner/styled-components.js +2 -40
  160. package/esm/table/filter.js +3 -3
  161. package/esm/tag/styled-components.js +1 -1
  162. package/esm/themes/dark-theme/color-component-tokens.js +0 -38
  163. package/esm/themes/dark-theme/color-tokens.js +0 -2
  164. package/esm/themes/dark-theme/create-dark-theme.js +1 -2
  165. package/esm/themes/dark-theme/dark-theme.js +1 -2
  166. package/esm/themes/light-theme/color-component-tokens.js +0 -38
  167. package/esm/themes/light-theme/color-tokens.js +0 -2
  168. package/esm/themes/light-theme/create-light-theme.js +1 -2
  169. package/esm/themes/light-theme/light-theme.js +1 -2
  170. package/esm/timepicker/timepicker.js +1 -8
  171. package/esm/typography/index.js +1 -35
  172. package/file-uploader/file-uploader.js +3 -3
  173. package/file-uploader/file-uploader.js.flow +4 -4
  174. package/header-navigation/styled-components.js +3 -3
  175. package/header-navigation/styled-components.js.flow +3 -3
  176. package/helpers/overrides.js +1 -2
  177. package/helpers/overrides.js.flow +1 -1
  178. package/input/index.d.ts +5 -9
  179. package/input/styled-components.js +4 -4
  180. package/input/styled-components.js.flow +4 -4
  181. package/layer/layer.js +4 -4
  182. package/layer/layer.js.flow +4 -3
  183. package/locale/index.js +0 -7
  184. package/locale/index.js.flow +0 -7
  185. package/locale.ts +0 -1
  186. package/menu/index.d.ts +1 -3
  187. package/menu/stateful-container.js +0 -1
  188. package/menu/stateful-container.js.flow +0 -1
  189. package/menu/styled-components.js +1 -1
  190. package/menu/styled-components.js.flow +1 -1
  191. package/modal/index.d.ts +4 -6
  192. package/modal/index.js +0 -6
  193. package/modal/index.js.flow +0 -1
  194. package/modal/modal.js +27 -70
  195. package/modal/modal.js.flow +17 -83
  196. package/modal/styled-components.js +7 -40
  197. package/modal/styled-components.js.flow +12 -44
  198. package/modal/types.js.flow +1 -10
  199. package/package.json +2 -2
  200. package/phone-input/default-props.js +1 -1
  201. package/phone-input/default-props.js.flow +1 -1
  202. package/phone-input/index.d.ts +0 -1
  203. package/phone-input/index.js +0 -36
  204. package/phone-input/index.js.flow +0 -4
  205. package/phone-input/phone-input-lite.js +63 -38
  206. package/phone-input/phone-input-lite.js.flow +66 -44
  207. package/radio/index.d.ts +4 -9
  208. package/radio/radio.js +1 -7
  209. package/radio/radio.js.flow +1 -8
  210. package/radio/radiogroup.js +3 -28
  211. package/radio/radiogroup.js.flow +2 -26
  212. package/radio/styled-components.js +4 -5
  213. package/radio/styled-components.js.flow +3 -4
  214. package/radio/types.js.flow +4 -15
  215. package/rating/styled-components.js +3 -3
  216. package/rating/styled-components.js.flow +3 -3
  217. package/select/index.d.ts +0 -2
  218. package/select/index.js +0 -6
  219. package/select/index.js.flow +0 -2
  220. package/select/select-component.js +4 -8
  221. package/select/select-component.js.flow +2 -3
  222. package/select/styled-components.js +4 -4
  223. package/select/styled-components.js.flow +4 -4
  224. package/snackbar/styled-components.js +1 -1
  225. package/snackbar/styled-components.js.flow +11 -11
  226. package/spinner/index.d.ts +5 -18
  227. package/spinner/index.js +2 -68
  228. package/spinner/index.js.flow +2 -27
  229. package/spinner/styled-components.js +9 -45
  230. package/spinner/styled-components.js.flow +2 -34
  231. package/spinner/types.js.flow +1 -19
  232. package/styles/types.js.flow +0 -2
  233. package/table/filter.js +3 -3
  234. package/table/filter.js.flow +3 -3
  235. package/tag/styled-components.js +1 -1
  236. package/tag/styled-components.js.flow +1 -1
  237. package/theme.ts +0 -81
  238. package/themes/dark-theme/color-component-tokens.js +0 -38
  239. package/themes/dark-theme/color-component-tokens.js.flow +0 -42
  240. package/themes/dark-theme/color-tokens.js +0 -2
  241. package/themes/dark-theme/color-tokens.js.flow +0 -2
  242. package/themes/dark-theme/create-dark-theme.js +1 -3
  243. package/themes/dark-theme/create-dark-theme.js.flow +0 -2
  244. package/themes/dark-theme/dark-theme.js +1 -3
  245. package/themes/dark-theme/dark-theme.js.flow +0 -2
  246. package/themes/light-theme/color-component-tokens.js +0 -38
  247. package/themes/light-theme/color-component-tokens.js.flow +0 -43
  248. package/themes/light-theme/color-tokens.js +0 -2
  249. package/themes/light-theme/color-tokens.js.flow +0 -2
  250. package/themes/light-theme/create-light-theme.js +1 -3
  251. package/themes/light-theme/create-light-theme.js.flow +0 -2
  252. package/themes/light-theme/light-theme.js +1 -3
  253. package/themes/light-theme/light-theme.js.flow +0 -2
  254. package/themes/types.js.flow +0 -68
  255. package/timepicker/timepicker.js +1 -8
  256. package/timepicker/timepicker.js.flow +4 -10
  257. package/typography/index.d.ts +0 -23
  258. package/typography/index.js +2 -57
  259. package/typography/index.js.flow +0 -31
  260. package/es/spinner/spinner.js +0 -68
  261. package/es/themes/dark-theme/color-deprecated-semantic-tokens.js +0 -35
  262. package/es/themes/light-theme/color-deprecated-semantic-tokens.js +0 -35
  263. package/esm/spinner/spinner.js +0 -125
  264. package/esm/themes/dark-theme/color-deprecated-semantic-tokens.js +0 -38
  265. package/esm/themes/light-theme/color-deprecated-semantic-tokens.js +0 -38
  266. package/spinner/spinner.js +0 -136
  267. package/spinner/spinner.js.flow +0 -75
  268. package/themes/dark-theme/color-deprecated-semantic-tokens.js +0 -50
  269. package/themes/dark-theme/color-deprecated-semantic-tokens.js.flow +0 -42
  270. package/themes/light-theme/color-deprecated-semantic-tokens.js +0 -50
  271. package/themes/light-theme/color-deprecated-semantic-tokens.js.flow +0 -42
@@ -4,14 +4,12 @@ Copyright (c) Uber Technologies, Inc.
4
4
  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
- import { styled, expandBorderStyles } from '../styles/index.js';
8
- import { STYLE_TYPE } from './constants.js';
7
+ import { styled } from '../styles/index.js';
9
8
 
10
9
  function getBorderColor(props) {
11
10
  const {
12
11
  $disabled,
13
12
  $checked,
14
- $isError,
15
13
  $error,
16
14
  $isIndeterminate,
17
15
  $theme,
@@ -25,8 +23,8 @@ function getBorderColor(props) {
25
23
  return colors.tickFillDisabled;
26
24
  } else if ($checked || $isIndeterminate) {
27
25
  return 'transparent';
28
- } else if ($error || $isError) {
29
- return colors.borderError;
26
+ } else if ($error) {
27
+ return colors.borderNegative;
30
28
  } else if ($isFocusVisible) {
31
29
  return colors.borderSelected;
32
30
  } else {
@@ -82,29 +80,22 @@ function getBackgroundColor(props) {
82
80
  $disabled,
83
81
  $checked,
84
82
  $isIndeterminate,
85
- $isError,
86
83
  $error,
87
84
  $isHovered,
88
85
  $isActive,
89
- $theme,
90
- $checkmarkType
86
+ $theme
91
87
  } = props;
92
- const isToggle = $checkmarkType === STYLE_TYPE.toggle;
93
88
  const {
94
89
  colors
95
90
  } = $theme;
96
91
 
97
92
  if ($disabled) {
98
- if (isToggle) {
99
- return colors.toggleFillDisabled;
100
- }
101
-
102
93
  if ($checked || $isIndeterminate) {
103
94
  return colors.tickFillDisabled;
104
95
  } else {
105
96
  return colors.tickFill;
106
97
  }
107
- } else if (($error || $isError) && ($isIndeterminate || $checked)) {
98
+ } else if ($error && ($isIndeterminate || $checked)) {
108
99
  if ($isActive) {
109
100
  return colors.tickFillErrorSelectedHoverActive;
110
101
  } else if ($isHovered) {
@@ -112,7 +103,7 @@ function getBackgroundColor(props) {
112
103
  } else {
113
104
  return colors.tickFillErrorSelected;
114
105
  }
115
- } else if ($error || $isError) {
106
+ } else if ($error) {
116
107
  if ($isActive) {
117
108
  return colors.tickFillErrorHoverActive;
118
109
  } else if ($isHovered) {
@@ -130,11 +121,11 @@ function getBackgroundColor(props) {
130
121
  }
131
122
  } else {
132
123
  if ($isActive) {
133
- return isToggle ? colors.sliderTrackFillActive : colors.tickFillActive;
124
+ return colors.tickFillActive;
134
125
  } else if ($isHovered) {
135
- return isToggle ? colors.sliderTrackFillHover : colors.tickFillHover;
126
+ return colors.tickFillHover;
136
127
  } else {
137
- return isToggle ? colors.toggleTrackFill : colors.tickFill;
128
+ return colors.tickFill;
138
129
  }
139
130
  }
140
131
  }
@@ -168,7 +159,6 @@ export const Checkmark = styled('span', props => {
168
159
  const {
169
160
  $checked,
170
161
  $disabled,
171
- $isError,
172
162
  $error,
173
163
  $isIndeterminate,
174
164
  $theme,
@@ -178,7 +168,7 @@ export const Checkmark = styled('span', props => {
178
168
  sizing,
179
169
  animation
180
170
  } = $theme;
181
- const tickColor = $disabled ? $theme.colors.tickMarkFillDisabled : $isError || $error ? $theme.colors.tickMarkFillError : $theme.colors.tickMarkFill;
171
+ const tickColor = $disabled ? $theme.colors.tickMarkFillDisabled : $error ? $theme.colors.tickMarkFillError : $theme.colors.tickMarkFill;
182
172
  const indeterminate = encodeURIComponent(`
183
173
  <svg width="14" height="4" viewBox="0 0 14 4" fill="none" xmlns="http://www.w3.org/2000/svg">
184
174
  <path d="M14 0.5H0V3.5H14V0.5Z" fill="${tickColor}"/>
@@ -234,14 +224,12 @@ export const Checkmark = styled('span', props => {
234
224
  Checkmark.displayName = "Checkmark";
235
225
  export const Label = styled('div', props => {
236
226
  const {
237
- $theme,
238
- $checkmarkType
227
+ $theme
239
228
  } = props;
240
229
  const {
241
230
  typography
242
231
  } = $theme;
243
232
  return {
244
- flex: $checkmarkType === STYLE_TYPE.toggle ? 'auto' : null,
245
233
  verticalAlign: 'middle',
246
234
  ...getLabelPadding(props),
247
235
  color: getLabelColor(props),
@@ -262,137 +250,54 @@ export const Input = styled('input', {
262
250
  });
263
251
  Input.displayName = "Input";
264
252
  export const Toggle = styled('div', props => {
265
- if (props.$checkmarkType === STYLE_TYPE.toggle) {
266
- const borderRadius = props.$theme.borders.useRoundedCorners ? props.$theme.borders.radius200 : null;
267
- return { ...expandBorderStyles(props.$theme.borders.border300),
268
- alignItems: 'center',
269
- backgroundColor: props.$theme.colors.mono100,
270
- borderTopLeftRadius: borderRadius,
271
- borderTopRightRadius: borderRadius,
272
- borderBottomRightRadius: borderRadius,
273
- borderBottomLeftRadius: borderRadius,
274
- boxShadow: props.$isFocusVisible ? `0 0 0 3px ${props.$theme.colors.accent}` : props.$theme.lighting.shadow400,
275
- outline: 'none',
276
- display: 'flex',
277
- justifyContent: 'center',
278
- height: props.$theme.sizing.scale800,
279
- width: props.$theme.sizing.scale800
280
- };
281
- }
253
+ let backgroundColor = props.$theme.colors.toggleFill;
282
254
 
283
- if (props.$checkmarkType === STYLE_TYPE.toggle_round) {
284
- let backgroundColor = props.$theme.colors.toggleFill;
285
-
286
- if (props.$disabled) {
287
- backgroundColor = props.$theme.colors.toggleFillDisabled;
288
- } else if (props.$checked && (props.$error || props.$isError)) {
289
- backgroundColor = props.$theme.colors.borderError;
290
- } else if (props.$checked) {
291
- backgroundColor = props.$theme.colors.toggleFillChecked;
292
- }
293
-
294
- return {
295
- backgroundColor,
296
- borderTopLeftRadius: '50%',
297
- borderTopRightRadius: '50%',
298
- borderBottomRightRadius: '50%',
299
- borderBottomLeftRadius: '50%',
300
- boxShadow: props.$isFocusVisible ? `0 0 0 3px ${props.$theme.colors.accent}` : props.$isHovered && !props.$disabled ? props.$theme.lighting.shadow500 : props.$theme.lighting.shadow400,
301
- outline: 'none',
302
- height: props.$theme.sizing.scale700,
303
- width: props.$theme.sizing.scale700,
304
- transform: props.$checked ? `translateX(${props.$theme.direction === 'rtl' ? '-100%' : '100%'})` : null,
305
- transition: `transform ${props.$theme.animation.timing200}`
306
- };
255
+ if (props.$disabled) {
256
+ backgroundColor = props.$theme.colors.toggleFillDisabled;
257
+ } else if (props.$checked && props.$error) {
258
+ backgroundColor = props.$theme.colors.tickFillErrorSelected;
259
+ } else if (props.$checked) {
260
+ backgroundColor = props.$theme.colors.toggleFillChecked;
307
261
  }
308
262
 
309
- return {};
263
+ return {
264
+ backgroundColor,
265
+ borderTopLeftRadius: '50%',
266
+ borderTopRightRadius: '50%',
267
+ borderBottomRightRadius: '50%',
268
+ borderBottomLeftRadius: '50%',
269
+ boxShadow: props.$isFocusVisible ? `0 0 0 3px ${props.$theme.colors.accent}` : props.$isHovered && !props.$disabled ? props.$theme.lighting.shadow500 : props.$theme.lighting.shadow400,
270
+ outline: 'none',
271
+ height: props.$theme.sizing.scale700,
272
+ width: props.$theme.sizing.scale700,
273
+ transform: props.$checked ? `translateX(${props.$theme.direction === 'rtl' ? '-100%' : '100%'})` : null,
274
+ transition: `transform ${props.$theme.animation.timing200}`
275
+ };
310
276
  });
311
277
  Toggle.displayName = "Toggle";
312
- export const ToggleInner = styled('div', props => {
313
- if (props.$checkmarkType === STYLE_TYPE.toggle) {
314
- // eslint-disable-next-line no-inner-declarations
315
- const backgroundColor = () => {
316
- if (props.$disabled) {
317
- return props.$theme.colors.sliderHandleInnerFillDisabled;
318
- }
319
-
320
- if (props.$isActive && props.$checked) {
321
- return props.$theme.colors.sliderHandleInnerFillSelectedActive;
322
- }
323
-
324
- if (props.$isHovered && props.$checked) {
325
- return props.$theme.colors.sliderHandleInnerFillSelectedHover;
326
- }
327
-
328
- return props.$theme.colors.toggleTrackFill;
329
- };
330
-
331
- return {
332
- height: props.$theme.sizing.scale300,
333
- width: props.$theme.sizing.scale0,
334
- borderTopLeftRadius: props.$theme.borders.radius100,
335
- borderTopRightRadius: props.$theme.borders.radius100,
336
- borderBottomRightRadius: props.$theme.borders.radius100,
337
- borderBottomLeftRadius: props.$theme.borders.radius100,
338
- backgroundColor: backgroundColor()
339
- };
340
- }
341
-
342
- if (props.$checkmarkType === STYLE_TYPE.toggle_round) {
343
- return {};
344
- }
345
-
346
- return {};
347
- });
348
- ToggleInner.displayName = "ToggleInner";
349
278
  export const ToggleTrack = styled('div', props => {
350
- if (props.$checkmarkType === STYLE_TYPE.toggle) {
351
- const borderRadius = props.$theme.borders.useRoundedCorners ? props.$theme.borders.radius200 : null;
352
- return {
353
- alignItems: 'center',
354
- backgroundColor: getBackgroundColor(props),
355
- borderTopLeftRadius: borderRadius,
356
- borderTopRightRadius: borderRadius,
357
- borderBottomRightRadius: borderRadius,
358
- borderBottomLeftRadius: borderRadius,
359
- display: 'flex',
360
- height: props.$theme.sizing.scale600,
361
- justifyContent: props.$checked ? 'flex-end' : 'flex-start',
362
- marginTop: props.$theme.sizing.scale100,
363
- marginBottom: props.$theme.sizing.scale100,
364
- marginLeft: props.$theme.sizing.scale100,
365
- marginRight: props.$theme.sizing.scale100,
366
- width: props.$theme.sizing.scale1000
367
- };
368
- }
369
-
370
- if (props.$checkmarkType === STYLE_TYPE.toggle_round) {
371
- let backgroundColor = props.$theme.colors.toggleTrackFill;
372
-
373
- if (props.$disabled) {
374
- backgroundColor = props.$theme.colors.toggleTrackFillDisabled;
375
- } else if ((props.$error || props.$isError) && props.$checked) {
376
- backgroundColor = props.$theme.colors.tickFillError;
377
- }
279
+ let backgroundColor = props.$theme.colors.toggleTrackFill;
378
280
 
379
- return {
380
- alignItems: 'center',
381
- backgroundColor,
382
- borderTopLeftRadius: '7px',
383
- borderTopRightRadius: '7px',
384
- borderBottomRightRadius: '7px',
385
- borderBottomLeftRadius: '7px',
386
- display: 'flex',
387
- height: props.$theme.sizing.scale550,
388
- marginTop: props.$theme.sizing.scale200,
389
- marginBottom: props.$theme.sizing.scale100,
390
- marginLeft: props.$theme.sizing.scale200,
391
- marginRight: props.$theme.sizing.scale100,
392
- width: props.$theme.sizing.scale1000
393
- };
281
+ if (props.$disabled) {
282
+ backgroundColor = props.$theme.colors.toggleTrackFillDisabled;
283
+ } else if (props.$error && props.$checked) {
284
+ backgroundColor = props.$theme.colors.tickFillError;
394
285
  }
395
286
 
396
- return {};
287
+ return {
288
+ alignItems: 'center',
289
+ backgroundColor,
290
+ borderTopLeftRadius: '7px',
291
+ borderTopRightRadius: '7px',
292
+ borderBottomRightRadius: '7px',
293
+ borderBottomLeftRadius: '7px',
294
+ display: 'flex',
295
+ height: props.$theme.sizing.scale550,
296
+ marginTop: props.$theme.sizing.scale200,
297
+ marginBottom: props.$theme.sizing.scale100,
298
+ marginLeft: props.$theme.sizing.scale200,
299
+ marginRight: props.$theme.sizing.scale100,
300
+ width: props.$theme.sizing.scale1000
301
+ };
397
302
  });
398
303
  ToggleTrack.displayName = "ToggleTrack";
@@ -37,7 +37,7 @@ function FilterQuickControls(props) {
37
37
  const locale = React.useContext(LocaleContext);
38
38
  return /*#__PURE__*/React.createElement(ButtonGroup, {
39
39
  size: SIZE.mini,
40
- kind: KIND.minimal
40
+ kind: KIND.tertiary
41
41
  }, /*#__PURE__*/React.createElement(Button, {
42
42
  type: "button",
43
43
  onClick: props.onSelectAll
@@ -322,7 +322,7 @@ function DatetimeFilter(props) {
322
322
  }) => {
323
323
  if (Array.isArray(date)) {
324
324
  if (!date.length) return;
325
- const nextDates = date.map((d, i) => applyDateToTime(rangeDates[i], d));
325
+ const nextDates = date.map((d, i) => d ? applyDateToTime(rangeDates[i], d) : null);
326
326
  setRangeDates(nextDates);
327
327
  }
328
328
  },
@@ -49,7 +49,11 @@ function Column(options) {
49
49
  display: 'flex',
50
50
  height: '100%'
51
51
  })
52
- }, Boolean(props.onSelect) && /*#__PURE__*/React.createElement(Checkbox, {
52
+ }, Boolean(props.onSelect) && /*#__PURE__*/React.createElement("span", {
53
+ className: css({
54
+ paddingRight: theme.sizing.scale300
55
+ })
56
+ }, /*#__PURE__*/React.createElement(Checkbox, {
53
57
  onChange: props.onSelect,
54
58
  checked: props.isSelected,
55
59
  overrides: {
@@ -60,7 +64,7 @@ function Column(options) {
60
64
  }
61
65
  }
62
66
  }
63
- }), /*#__PURE__*/React.createElement(ProvidedCell, props)));
67
+ })), /*#__PURE__*/React.createElement(ProvidedCell, props)));
64
68
  }),
65
69
  renderFilter: options.renderFilter || (() => null),
66
70
  sortable: Boolean(options.sortable) && Boolean(options.sortFn),
@@ -396,7 +396,7 @@ const InnerTableElement = /*#__PURE__*/React.forwardRef((props, ref) => {
396
396
  row: ctx.rows[ctx.rowHighlightIndex - 1]
397
397
  }),
398
398
  size: BUTTON_SIZES.compact,
399
- kind: BUTTON_KINDS.minimal,
399
+ kind: BUTTON_KINDS.tertiary,
400
400
  shape: BUTTON_SHAPES.round,
401
401
  overrides: {
402
402
  BaseButton: {
@@ -69,6 +69,9 @@ const HeaderCell = /*#__PURE__*/React.forwardRef((props, ref) => {
69
69
  onFocus: handleFocus,
70
70
  onBlur: handleBlur
71
71
  }, props.isSelectable && /*#__PURE__*/React.createElement("span", {
72
+ className: css({
73
+ paddingRight: theme.sizing.scale300
74
+ }),
72
75
  ref: checkboxRef
73
76
  }, /*#__PURE__*/React.createElement(Checkbox, {
74
77
  onChange: e => {
@@ -257,10 +257,16 @@ export default class Calendar extends React.Component {
257
257
  const newTimeState = [...this.state.time]; // Apply the currently selected time values (saved in state) to the updated date
258
258
 
259
259
  if (Array.isArray(data.date)) {
260
- updatedDate = data.date.map((date, index) => {
261
- newTimeState[index] = this.dateHelpers.applyDateToTime(newTimeState[index], date);
262
- return newTimeState[index];
263
- });
260
+ const start = data.date[0] ? this.dateHelpers.applyDateToTime(newTimeState[0], data.date[0]) : null;
261
+ const end = data.date[1] ? this.dateHelpers.applyDateToTime(newTimeState[1], data.date[1]) : null;
262
+ newTimeState[0] = start;
263
+
264
+ if (end) {
265
+ updatedDate = [start, end];
266
+ newTimeState[1] = end;
267
+ } else {
268
+ updatedDate = [start];
269
+ }
264
270
  } else if (!Array.isArray(this.props.value) && data.date) {
265
271
  newTimeState[0] = this.dateHelpers.applyDateToTime(newTimeState[0], data.date);
266
272
  updatedDate = newTimeState[0];
@@ -289,14 +295,14 @@ export default class Calendar extends React.Component {
289
295
 
290
296
  if (Array.isArray(this.props.value)) {
291
297
  const dates = this.props.value.map((date, i) => {
292
- if (index === i) {
298
+ if (date && index === i) {
293
299
  return this.dateHelpers.applyTimeToDate(date, time);
294
300
  }
295
301
 
296
302
  return date;
297
303
  });
298
304
  onChange({
299
- date: dates
305
+ date: [dates[0], dates[1]]
300
306
  });
301
307
  } else {
302
308
  const date = this.dateHelpers.applyTimeToDate(this.props.value, time);
@@ -355,7 +361,9 @@ export default class Calendar extends React.Component {
355
361
  overrides: overrides,
356
362
  value: this.props.value,
357
363
  peekNextMonth: this.props.peekNextMonth,
358
- fixedHeight: this.props.fixedHeight
364
+ fixedHeight: this.props.fixedHeight,
365
+ hasLockedBehavior: !!this.props.hasLockedBehavior,
366
+ selectedInput: this.props.selectedInput
359
367
  })));
360
368
  monthList.push( /*#__PURE__*/React.createElement("div", {
361
369
  key: `month-component-${i}`
@@ -25,4 +25,12 @@ export const DEFAULT_MONTHS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
25
25
  export const DENSITY = {
26
26
  high: 'high',
27
27
  default: 'default'
28
+ };
29
+ export const INPUT_ROLE = {
30
+ startDate: 'startDate',
31
+ endDate: 'endDate'
32
+ };
33
+ export const RANGED_CALENDAR_BEHAVIOR = {
34
+ default: 'default',
35
+ locked: 'locked'
28
36
  };
@@ -18,19 +18,20 @@ import { LocaleContext } from '../locale/index.js';
18
18
  import { StyledInputWrapper, StyledInputLabel, StyledStartDate, StyledEndDate } from './styled-components.js';
19
19
  import DateHelpers from './utils/date-helpers.js';
20
20
  import dateFnsAdapter from './utils/date-fns-adapter.js';
21
+ import { INPUT_ROLE, RANGED_CALENDAR_BEHAVIOR } from './constants.js';
21
22
  export const DEFAULT_DATE_FORMAT = 'yyyy/MM/dd';
22
- const INPUT_DELIMITER = ' ';
23
+ const INPUT_DELIMITER = '–';
23
24
 
24
- const combineSeparatedInputs = (newInputValue, prevCombinedInputValue = '', separatedInput) => {
25
+ const combineSeparatedInputs = (newInputValue, prevCombinedInputValue = '', inputRole) => {
25
26
  let inputValue = newInputValue;
26
- const [prevStartDate = '', prevEndDate = ''] = prevCombinedInputValue.split(INPUT_DELIMITER);
27
+ const [prevStartDate = '', prevEndDate = ''] = prevCombinedInputValue.split(` ${INPUT_DELIMITER} `);
27
28
 
28
- if (separatedInput === 'startDate' && prevEndDate) {
29
- inputValue = `${inputValue} ${prevEndDate}`;
29
+ if (inputRole === INPUT_ROLE.startDate && prevEndDate) {
30
+ inputValue = `${inputValue} ${INPUT_DELIMITER} ${prevEndDate}`;
30
31
  }
31
32
 
32
- if (separatedInput === 'endDate') {
33
- inputValue = `${prevStartDate} ${inputValue}`;
33
+ if (inputRole === INPUT_ROLE.endDate) {
34
+ inputValue = `${prevStartDate} ${INPUT_DELIMITER} ${inputValue}`;
34
35
  }
35
36
 
36
37
  return inputValue;
@@ -38,7 +39,7 @@ const combineSeparatedInputs = (newInputValue, prevCombinedInputValue = '', sepa
38
39
 
39
40
  export default class Datepicker extends React.Component {
40
41
  constructor(props) {
41
- super(props); //$FlowFixMe
42
+ super(props); //$FlowFixMe[incompatible-call]
42
43
 
43
44
  _defineProperty(this, "calendar", void 0);
44
45
 
@@ -51,15 +52,24 @@ export default class Datepicker extends React.Component {
51
52
  let nextDate = data.date;
52
53
 
53
54
  if (Array.isArray(nextDate) && this.props.range) {
54
- if (nextDate.length < 2) {
55
+ if (!nextDate[0] || !nextDate[1]) {
55
56
  isOpen = true;
56
57
  isPseudoFocused = true;
57
58
  calendarFocused = null;
58
- } else if (nextDate.length === 2) {
59
+ } else if (nextDate[0] && nextDate[1]) {
59
60
  const [start, end] = nextDate;
60
61
 
61
62
  if (this.dateHelpers.isAfter(start, end)) {
62
- nextDate = [start, start];
63
+ if (this.hasLockedBehavior()) {
64
+ nextDate = this.props.value;
65
+ isOpen = true;
66
+ } else {
67
+ nextDate = [start, start];
68
+ }
69
+ } 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]
70
+ nextDate, this.props.excludeDates)) {
71
+ nextDate = this.props.value;
72
+ isOpen = true;
63
73
  }
64
74
 
65
75
  if (this.state.lastActiveElm) {
@@ -146,11 +156,12 @@ export default class Datepicker extends React.Component {
146
156
  return this.formatDate(date, formatString);
147
157
  });
148
158
 
149
- _defineProperty(this, "open", () => {
159
+ _defineProperty(this, "open", inputRole => {
150
160
  this.setState({
151
161
  isOpen: true,
152
162
  isPseudoFocused: true,
153
- calendarFocused: false
163
+ calendarFocused: false,
164
+ selectedInput: inputRole
154
165
  }, this.props.onOpen);
155
166
  });
156
167
 
@@ -158,6 +169,7 @@ export default class Datepicker extends React.Component {
158
169
  const isPseudoFocused = false;
159
170
  this.setState({
160
171
  isOpen: false,
172
+ selectedInput: null,
161
173
  isPseudoFocused,
162
174
  calendarFocused: false
163
175
  }, this.props.onClose);
@@ -194,14 +206,14 @@ export default class Datepicker extends React.Component {
194
206
  }
195
207
 
196
208
  if (range && !separateRangeInputs) {
197
- return '9999/99/99 9999/99/99';
209
+ return `9999/99/99 ${INPUT_DELIMITER} 9999/99/99`;
198
210
  }
199
211
 
200
212
  return '9999/99/99';
201
213
  });
202
214
 
203
- _defineProperty(this, "handleInputChange", (event, separatedInput) => {
204
- const inputValue = this.props.range && this.props.separateRangeInputs ? combineSeparatedInputs(event.currentTarget.value, this.state.inputValue, separatedInput) : event.currentTarget.value;
215
+ _defineProperty(this, "handleInputChange", (event, inputRole) => {
216
+ const inputValue = this.props.range && this.props.separateRangeInputs ? combineSeparatedInputs(event.currentTarget.value, this.state.inputValue, inputRole) : event.currentTarget.value;
205
217
  const mask = this.getMask();
206
218
  const formatString = this.normalizeDashes(this.props.formatString);
207
219
 
@@ -232,7 +244,7 @@ export default class Datepicker extends React.Component {
232
244
  };
233
245
 
234
246
  if (this.props.range && typeof this.props.displayValueAtRangeIndex !== 'number') {
235
- const [left, right] = this.normalizeDashes(inputValue).split(INPUT_DELIMITER);
247
+ const [left, right] = this.normalizeDashes(inputValue).split(` ${INPUT_DELIMITER} `);
236
248
  let startDate = this.dateHelpers.date(left);
237
249
  let endDate = this.dateHelpers.date(right);
238
250
 
@@ -353,19 +365,28 @@ export default class Datepicker extends React.Component {
353
365
 
354
366
  _defineProperty(this, "normalizeDashes", inputValue => {
355
367
  // replacing both hyphens and em-dashes with en-dashes
356
- return inputValue.replace(/-/g, '–').replace(/—/g, '–');
368
+ return inputValue.replace(/-/g, INPUT_DELIMITER).replace(/—/g, INPUT_DELIMITER);
369
+ });
370
+
371
+ _defineProperty(this, "hasLockedBehavior", () => {
372
+ return this.props.rangedCalendarBehavior === RANGED_CALENDAR_BEHAVIOR.locked && this.props.range && this.props.separateRangeInputs;
357
373
  });
358
374
 
359
375
  this.dateHelpers = new DateHelpers(props.adapter);
360
376
  this.state = {
361
377
  calendarFocused: false,
362
378
  isOpen: false,
379
+ selectedInput: null,
363
380
  isPseudoFocused: false,
364
381
  lastActiveElm: null,
365
382
  inputValue: this.formatDisplayValue(props.value) || ''
366
383
  };
367
384
  }
368
385
 
386
+ getNullDatePlaceholder(formatString) {
387
+ return (this.getMask() || formatString).split(INPUT_DELIMITER)[0].replace(/[0-9]|[a-z]/g, ' ');
388
+ }
389
+
369
390
  formatDate(date, formatString) {
370
391
  const format = date => {
371
392
  if (formatString === DEFAULT_DATE_FORMAT) {
@@ -379,8 +400,12 @@ export default class Datepicker extends React.Component {
379
400
  return '';
380
401
  } else if (Array.isArray(date) && !date[0] && !date[1]) {
381
402
  return '';
403
+ } else if (Array.isArray(date) && !date[0] && date[1]) {
404
+ const endDate = format(date[1]);
405
+ const startDate = this.getNullDatePlaceholder(formatString);
406
+ return [startDate, endDate].join(` ${INPUT_DELIMITER} `);
382
407
  } else if (Array.isArray(date)) {
383
- return date.map(day => format(day)).join(INPUT_DELIMITER);
408
+ return date.map(day => day ? format(day) : '').join(` ${INPUT_DELIMITER} `);
384
409
  } else {
385
410
  return format(date);
386
411
  }
@@ -394,16 +419,16 @@ export default class Datepicker extends React.Component {
394
419
  }
395
420
  }
396
421
 
397
- renderInputComponent(locale, separatedInput) {
422
+ renderInputComponent(locale, inputRole) {
398
423
  const {
399
424
  overrides = {}
400
425
  } = this.props;
401
426
  const [InputComponent, inputProps] = getOverrides(overrides.Input, MaskedInput);
402
- const 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';
403
- const [startDate = '', endDate = ''] = (this.state.inputValue || '').split(INPUT_DELIMITER);
404
- const value = separatedInput === 'startDate' ? startDate : separatedInput === 'endDate' ? endDate : this.state.inputValue;
427
+ 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
+ const [startDate = '', endDate = ''] = (this.state.inputValue || '').split(` ${INPUT_DELIMITER} `);
429
+ const value = inputRole === INPUT_ROLE.startDate ? startDate : inputRole === INPUT_ROLE.endDate ? endDate : this.state.inputValue;
405
430
 
406
- const onChange = event => this.handleInputChange(event, separatedInput);
431
+ const onChange = event => this.handleInputChange(event, inputRole);
407
432
 
408
433
  return /*#__PURE__*/React.createElement(InputComponent, _extends({
409
434
  "aria-disabled": this.props.disabled,
@@ -416,7 +441,7 @@ export default class Datepicker extends React.Component {
416
441
  disabled: this.props.disabled,
417
442
  size: this.props.size,
418
443
  value: value,
419
- onFocus: this.open,
444
+ onFocus: () => this.open(inputRole),
420
445
  onBlur: this.handleInputBlur,
421
446
  onKeyDown: this.handleKeyDown,
422
447
  onChange: onChange,
@@ -452,11 +477,13 @@ export default class Datepicker extends React.Component {
452
477
  trapTabbing: true,
453
478
  value: this.props.value
454
479
  }, this.props, {
455
- onChange: this.onChange
480
+ onChange: this.onChange,
481
+ selectedInput: this.state.selectedInput,
482
+ hasLockedBehavior: this.hasLockedBehavior()
456
483
  }))
457
484
  }, popoverProps), /*#__PURE__*/React.createElement(InputWrapper, _extends({}, inputWrapperProps, {
458
485
  $separateRangeInputs: this.props.range && this.props.separateRangeInputs
459
- }), this.props.range && this.props.separateRangeInputs ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(StartDate, startDateProps, /*#__PURE__*/React.createElement(InputLabel, inputLabelProps, startDateLabel), this.renderInputComponent(locale, 'startDate')), /*#__PURE__*/React.createElement(EndDate, endDateProps, /*#__PURE__*/React.createElement(InputLabel, inputLabelProps, endDateLabel), this.renderInputComponent(locale, 'endDate'))) : /*#__PURE__*/React.createElement(React.Fragment, null, this.renderInputComponent(locale)))), /*#__PURE__*/React.createElement("p", {
486
+ }), this.props.range && this.props.separateRangeInputs ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(StartDate, startDateProps, /*#__PURE__*/React.createElement(InputLabel, inputLabelProps, startDateLabel), this.renderInputComponent(locale, INPUT_ROLE.startDate)), /*#__PURE__*/React.createElement(EndDate, endDateProps, /*#__PURE__*/React.createElement(InputLabel, inputLabelProps, endDateLabel), this.renderInputComponent(locale, INPUT_ROLE.endDate))) : /*#__PURE__*/React.createElement(React.Fragment, null, this.renderInputComponent(locale)))), /*#__PURE__*/React.createElement("p", {
460
487
  id: this.props['aria-describedby'],
461
488
  style: {
462
489
  position: 'fixed',
@@ -487,11 +514,11 @@ export default class Datepicker extends React.Component {
487
514
  clipPath: 'inset(100%)'
488
515
  }
489
516
  }, // No date selected
490
- !this.props.value || Array.isArray(this.props.value) && !this.props.value.length ? '' : // Date selected in a non-range picker
517
+ !this.props.value || Array.isArray(this.props.value) && !this.props.value[0] && !this.props.value[1] ? '' : // Date selected in a non-range picker
491
518
  !Array.isArray(this.props.value) ? getInterpolatedString(locale.datepicker.selectedDate, {
492
519
  date: this.state.inputValue || ''
493
520
  }) : // Start and end dates are selected in a range picker
494
- this.props.value.length > 1 ? getInterpolatedString(locale.datepicker.selectedDateRange, {
521
+ this.props.value[0] && this.props.value[1] ? getInterpolatedString(locale.datepicker.selectedDateRange, {
495
522
  startDate: this.formatDisplayValue(this.props.value[0]),
496
523
  endDate: this.formatDisplayValue( // $FlowFixMe
497
524
  this.props.value[1])