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
@@ -6,21 +6,19 @@ LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
8
  // @flow
9
- import { styled, expandBorderStyles } from '../styles/index.js';
10
- import { STYLE_TYPE } from './constants.js';
9
+ import { styled } from '../styles/index.js';
11
10
 
12
11
  import type { SharedStylePropsT } from './types.js';
13
12
 
14
13
  function getBorderColor(props) {
15
- const { $disabled, $checked, $isError, $error, $isIndeterminate, $theme, $isFocusVisible } =
16
- props;
14
+ const { $disabled, $checked, $error, $isIndeterminate, $theme, $isFocusVisible } = props;
17
15
  const { colors } = $theme;
18
16
  if ($disabled) {
19
17
  return colors.tickFillDisabled;
20
18
  } else if ($checked || $isIndeterminate) {
21
19
  return 'transparent';
22
- } else if ($error || $isError) {
23
- return colors.borderError;
20
+ } else if ($error) {
21
+ return colors.borderNegative;
24
22
  } else if ($isFocusVisible) {
25
23
  return colors.borderSelected;
26
24
  } else {
@@ -62,29 +60,15 @@ function getLabelPadding(props) {
62
60
  }
63
61
 
64
62
  function getBackgroundColor(props) {
65
- const {
66
- $disabled,
67
- $checked,
68
- $isIndeterminate,
69
- $isError,
70
- $error,
71
- $isHovered,
72
- $isActive,
73
- $theme,
74
- $checkmarkType,
75
- } = props;
76
- const isToggle = $checkmarkType === STYLE_TYPE.toggle;
63
+ const { $disabled, $checked, $isIndeterminate, $error, $isHovered, $isActive, $theme } = props;
77
64
  const { colors } = $theme;
78
65
  if ($disabled) {
79
- if (isToggle) {
80
- return colors.toggleFillDisabled;
81
- }
82
66
  if ($checked || $isIndeterminate) {
83
67
  return colors.tickFillDisabled;
84
68
  } else {
85
69
  return colors.tickFill;
86
70
  }
87
- } else if (($error || $isError) && ($isIndeterminate || $checked)) {
71
+ } else if ($error && ($isIndeterminate || $checked)) {
88
72
  if ($isActive) {
89
73
  return colors.tickFillErrorSelectedHoverActive;
90
74
  } else if ($isHovered) {
@@ -92,7 +76,7 @@ function getBackgroundColor(props) {
92
76
  } else {
93
77
  return colors.tickFillErrorSelected;
94
78
  }
95
- } else if ($error || $isError) {
79
+ } else if ($error) {
96
80
  if ($isActive) {
97
81
  return colors.tickFillErrorHoverActive;
98
82
  } else if ($isHovered) {
@@ -110,11 +94,11 @@ function getBackgroundColor(props) {
110
94
  }
111
95
  } else {
112
96
  if ($isActive) {
113
- return isToggle ? colors.sliderTrackFillActive : colors.tickFillActive;
97
+ return colors.tickFillActive;
114
98
  } else if ($isHovered) {
115
- return isToggle ? colors.sliderTrackFillHover : colors.tickFillHover;
99
+ return colors.tickFillHover;
116
100
  } else {
117
- return isToggle ? colors.toggleTrackFill : colors.tickFill;
101
+ return colors.tickFill;
118
102
  }
119
103
  }
120
104
  }
@@ -137,13 +121,12 @@ export const Root = styled<SharedStylePropsT>('label', (props) => {
137
121
  });
138
122
 
139
123
  export const Checkmark = styled<SharedStylePropsT>('span', (props) => {
140
- const { $checked, $disabled, $isError, $error, $isIndeterminate, $theme, $isFocusVisible } =
141
- props;
124
+ const { $checked, $disabled, $error, $isIndeterminate, $theme, $isFocusVisible } = props;
142
125
  const { sizing, animation } = $theme;
143
126
 
144
127
  const tickColor = $disabled
145
128
  ? $theme.colors.tickMarkFillDisabled
146
- : $isError || $error
129
+ : $error
147
130
  ? $theme.colors.tickMarkFillError
148
131
  : $theme.colors.tickMarkFill;
149
132
 
@@ -208,10 +191,9 @@ export const Checkmark = styled<SharedStylePropsT>('span', (props) => {
208
191
  });
209
192
 
210
193
  export const Label = styled<SharedStylePropsT>('div', (props) => {
211
- const { $theme, $checkmarkType } = props;
194
+ const { $theme } = props;
212
195
  const { typography } = $theme;
213
196
  return ({
214
- flex: $checkmarkType === STYLE_TYPE.toggle ? 'auto' : null,
215
197
  verticalAlign: 'middle',
216
198
  ...getLabelPadding(props),
217
199
  color: getLabelColor(props),
@@ -232,146 +214,58 @@ export const Input = styled('input', {
232
214
  });
233
215
 
234
216
  export const Toggle = styled<SharedStylePropsT>('div', (props) => {
235
- if (props.$checkmarkType === STYLE_TYPE.toggle) {
236
- const borderRadius = props.$theme.borders.useRoundedCorners
237
- ? props.$theme.borders.radius200
238
- : null;
239
- return ({
240
- ...expandBorderStyles(props.$theme.borders.border300),
241
- alignItems: 'center',
242
- backgroundColor: props.$theme.colors.mono100,
243
- borderTopLeftRadius: borderRadius,
244
- borderTopRightRadius: borderRadius,
245
- borderBottomRightRadius: borderRadius,
246
- borderBottomLeftRadius: borderRadius,
247
- boxShadow: props.$isFocusVisible
248
- ? `0 0 0 3px ${props.$theme.colors.accent}`
249
- : props.$theme.lighting.shadow400,
250
- outline: 'none',
251
- display: 'flex',
252
- justifyContent: 'center',
253
- height: props.$theme.sizing.scale800,
254
- width: props.$theme.sizing.scale800,
255
- }: {});
256
- }
257
-
258
- if (props.$checkmarkType === STYLE_TYPE.toggle_round) {
259
- let backgroundColor = props.$theme.colors.toggleFill;
260
- if (props.$disabled) {
261
- backgroundColor = props.$theme.colors.toggleFillDisabled;
262
- } else if (props.$checked && (props.$error || props.$isError)) {
263
- backgroundColor = props.$theme.colors.borderError;
264
- } else if (props.$checked) {
265
- backgroundColor = props.$theme.colors.toggleFillChecked;
266
- }
267
- return {
268
- backgroundColor,
269
- borderTopLeftRadius: '50%',
270
- borderTopRightRadius: '50%',
271
- borderBottomRightRadius: '50%',
272
- borderBottomLeftRadius: '50%',
273
- boxShadow: props.$isFocusVisible
274
- ? `0 0 0 3px ${props.$theme.colors.accent}`
275
- : props.$isHovered && !props.$disabled
276
- ? props.$theme.lighting.shadow500
277
- : props.$theme.lighting.shadow400,
278
- outline: 'none',
279
- height: props.$theme.sizing.scale700,
280
- width: props.$theme.sizing.scale700,
281
- transform: props.$checked
282
- ? `translateX(${props.$theme.direction === 'rtl' ? '-100%' : '100%'})`
283
- : null,
284
- transition: `transform ${props.$theme.animation.timing200}`,
285
- };
286
- }
287
-
288
- return {};
289
- });
290
-
291
- export const ToggleInner = styled<SharedStylePropsT>('div', (props) => {
292
- if (props.$checkmarkType === STYLE_TYPE.toggle) {
293
- // eslint-disable-next-line no-inner-declarations
294
- const backgroundColor = () => {
295
- if (props.$disabled) {
296
- return props.$theme.colors.sliderHandleInnerFillDisabled;
297
- }
298
-
299
- if (props.$isActive && props.$checked) {
300
- return props.$theme.colors.sliderHandleInnerFillSelectedActive;
301
- }
302
-
303
- if (props.$isHovered && props.$checked) {
304
- return props.$theme.colors.sliderHandleInnerFillSelectedHover;
305
- }
306
-
307
- return props.$theme.colors.toggleTrackFill;
308
- };
309
- return {
310
- height: props.$theme.sizing.scale300,
311
- width: props.$theme.sizing.scale0,
312
- borderTopLeftRadius: props.$theme.borders.radius100,
313
- borderTopRightRadius: props.$theme.borders.radius100,
314
- borderBottomRightRadius: props.$theme.borders.radius100,
315
- borderBottomLeftRadius: props.$theme.borders.radius100,
316
- backgroundColor: backgroundColor(),
317
- };
217
+ let backgroundColor = props.$theme.colors.toggleFill;
218
+ if (props.$disabled) {
219
+ backgroundColor = props.$theme.colors.toggleFillDisabled;
220
+ } else if (props.$checked && props.$error) {
221
+ backgroundColor = props.$theme.colors.tickFillErrorSelected;
222
+ } else if (props.$checked) {
223
+ backgroundColor = props.$theme.colors.toggleFillChecked;
318
224
  }
319
225
 
320
- if (props.$checkmarkType === STYLE_TYPE.toggle_round) {
321
- return {};
322
- }
323
-
324
- return {};
226
+ return {
227
+ backgroundColor,
228
+ borderTopLeftRadius: '50%',
229
+ borderTopRightRadius: '50%',
230
+ borderBottomRightRadius: '50%',
231
+ borderBottomLeftRadius: '50%',
232
+ boxShadow: props.$isFocusVisible
233
+ ? `0 0 0 3px ${props.$theme.colors.accent}`
234
+ : props.$isHovered && !props.$disabled
235
+ ? props.$theme.lighting.shadow500
236
+ : props.$theme.lighting.shadow400,
237
+ outline: 'none',
238
+ height: props.$theme.sizing.scale700,
239
+ width: props.$theme.sizing.scale700,
240
+ transform: props.$checked
241
+ ? `translateX(${props.$theme.direction === 'rtl' ? '-100%' : '100%'})`
242
+ : null,
243
+ transition: `transform ${props.$theme.animation.timing200}`,
244
+ };
325
245
  });
326
246
 
327
247
  export const ToggleTrack = styled<SharedStylePropsT>('div', (props) => {
328
- if (props.$checkmarkType === STYLE_TYPE.toggle) {
329
- const borderRadius = props.$theme.borders.useRoundedCorners
330
- ? props.$theme.borders.radius200
331
- : null;
332
- return ({
333
- alignItems: 'center',
334
- backgroundColor: getBackgroundColor(props),
335
- borderTopLeftRadius: borderRadius,
336
- borderTopRightRadius: borderRadius,
337
- borderBottomRightRadius: borderRadius,
338
- borderBottomLeftRadius: borderRadius,
339
- display: 'flex',
340
- height: props.$theme.sizing.scale600,
341
- justifyContent: props.$checked ? 'flex-end' : 'flex-start',
342
- marginTop: props.$theme.sizing.scale100,
343
- marginBottom: props.$theme.sizing.scale100,
344
- marginLeft: props.$theme.sizing.scale100,
345
- marginRight: props.$theme.sizing.scale100,
346
- width: props.$theme.sizing.scale1000,
347
- }: {});
348
- }
349
-
350
- if (props.$checkmarkType === STYLE_TYPE.toggle_round) {
351
- let backgroundColor = props.$theme.colors.toggleTrackFill;
352
- if (props.$disabled) {
353
- backgroundColor = props.$theme.colors.toggleTrackFillDisabled;
354
- } else if ((props.$error || props.$isError) && props.$checked) {
355
- backgroundColor = props.$theme.colors.tickFillError;
356
- }
357
- return {
358
- alignItems: 'center',
359
- backgroundColor,
360
- borderTopLeftRadius: '7px',
361
- borderTopRightRadius: '7px',
362
- borderBottomRightRadius: '7px',
363
- borderBottomLeftRadius: '7px',
364
- display: 'flex',
365
- height: props.$theme.sizing.scale550,
366
- marginTop: props.$theme.sizing.scale200,
367
- marginBottom: props.$theme.sizing.scale100,
368
- marginLeft: props.$theme.sizing.scale200,
369
- marginRight: props.$theme.sizing.scale100,
370
- width: props.$theme.sizing.scale1000,
371
- };
248
+ let backgroundColor = props.$theme.colors.toggleTrackFill;
249
+ if (props.$disabled) {
250
+ backgroundColor = props.$theme.colors.toggleTrackFillDisabled;
251
+ } else if (props.$error && props.$checked) {
252
+ backgroundColor = props.$theme.colors.tickFillError;
372
253
  }
373
-
374
- return {};
254
+ return {
255
+ alignItems: 'center',
256
+ backgroundColor,
257
+ borderTopLeftRadius: '7px',
258
+ borderTopRightRadius: '7px',
259
+ borderBottomRightRadius: '7px',
260
+ borderBottomLeftRadius: '7px',
261
+ display: 'flex',
262
+ height: props.$theme.sizing.scale550,
263
+ marginTop: props.$theme.sizing.scale200,
264
+ marginBottom: props.$theme.sizing.scale100,
265
+ marginLeft: props.$theme.sizing.scale200,
266
+ marginRight: props.$theme.sizing.scale100,
267
+ width: props.$theme.sizing.scale1000,
268
+ };
375
269
  });
376
270
 
377
271
  declare var __DEV__: boolean;
@@ -27,7 +27,6 @@ export type DefaultPropsT = {
27
27
  children?: React$Node,
28
28
  checked: boolean,
29
29
  disabled: boolean,
30
- isError: boolean,
31
30
  error: boolean,
32
31
  autoFocus: boolean,
33
32
  isIndeterminate: boolean,
@@ -63,8 +62,6 @@ export type PropsT = {
63
62
  required?: boolean,
64
63
  /** Renders checkbox in errored state. */
65
64
  error?: boolean,
66
- /** You should use error instead. */
67
- isError?: boolean,
68
65
  /** Used to get a ref to the input element. Useful for programmatically focusing the input */
69
66
  inputRef: ReactRefT<HTMLInputElement>,
70
67
  /** Focus the checkbox on initial render. */
@@ -195,14 +192,12 @@ export type SharedStylePropsT = {
195
192
  $isFocusVisible: boolean,
196
193
  $isHovered: boolean,
197
194
  $isActive: boolean,
198
- $isError: boolean,
199
195
  $error: boolean,
200
196
  $checked: boolean,
201
197
  $isIndeterminate: boolean,
202
198
  $required: boolean,
203
199
  $disabled: boolean,
204
200
  $value: string,
205
- $checkmarkType: StyleTypeT,
206
201
  $labelPlacement: LabelPlacementT,
207
202
  };
208
203
 
@@ -79,7 +79,7 @@ function FilterQuickControls(props) {
79
79
  var locale = React.useContext(_index7.LocaleContext);
80
80
  return /*#__PURE__*/React.createElement(_index2.ButtonGroup, {
81
81
  size: _index.SIZE.mini,
82
- kind: _index.KIND.minimal
82
+ kind: _index.KIND.tertiary
83
83
  }, /*#__PURE__*/React.createElement(_index.Button, {
84
84
  type: "button",
85
85
  onClick: props.onSelectAll
@@ -54,7 +54,7 @@ function FilterQuickControls(props: { onSelectAll: () => void, onClearSelection:
54
54
  const locale = React.useContext(LocaleContext);
55
55
 
56
56
  return (
57
- <ButtonGroup size={SIZE.mini} kind={KIND.minimal}>
57
+ <ButtonGroup size={SIZE.mini} kind={KIND.tertiary}>
58
58
  <Button type="button" onClick={props.onSelectAll}>
59
59
  {locale.datatable.categoricalFilterSelectAll}
60
60
  </Button>
@@ -456,7 +456,7 @@ function DatetimeFilter(props) {
456
456
  if (Array.isArray(date)) {
457
457
  if (!date.length) return;
458
458
  var nextDates = date.map(function (d, i) {
459
- return (0, _index13.applyDateToTime)(rangeDates[i], d);
459
+ return d ? (0, _index13.applyDateToTime)(rangeDates[i], d) : null;
460
460
  });
461
461
  setRangeDates(nextDates);
462
462
  }
@@ -382,7 +382,9 @@ function DatetimeFilter(props) {
382
382
  onChange={({ date }) => {
383
383
  if (Array.isArray(date)) {
384
384
  if (!date.length) return;
385
- const nextDates = date.map((d, i) => applyDateToTime(rangeDates[i], d));
385
+ const nextDates = date.map((d, i) =>
386
+ d ? applyDateToTime(rangeDates[i], d) : null
387
+ );
386
388
  setRangeDates(nextDates);
387
389
  }
388
390
  }}
@@ -84,7 +84,11 @@ function Column(options) {
84
84
  display: 'flex',
85
85
  height: '100%'
86
86
  })
87
- }, Boolean(props.onSelect) && /*#__PURE__*/React.createElement(_index.Checkbox, {
87
+ }, Boolean(props.onSelect) && /*#__PURE__*/React.createElement("span", {
88
+ className: css({
89
+ paddingRight: theme.sizing.scale300
90
+ })
91
+ }, /*#__PURE__*/React.createElement(_index.Checkbox, {
88
92
  onChange: props.onSelect,
89
93
  checked: props.isSelected,
90
94
  overrides: {
@@ -95,7 +99,7 @@ function Column(options) {
95
99
  }
96
100
  }
97
101
  }
98
- }), /*#__PURE__*/React.createElement(ProvidedCell, props)));
102
+ })), /*#__PURE__*/React.createElement(ProvidedCell, props)));
99
103
  }),
100
104
  renderFilter: options.renderFilter || function () {
101
105
  return null;
@@ -62,13 +62,15 @@ function Column<ValueT, FilterParamsT>(
62
62
  })}
63
63
  >
64
64
  {Boolean(props.onSelect) && (
65
- <Checkbox
66
- onChange={props.onSelect}
67
- checked={props.isSelected}
68
- overrides={{
69
- Checkmark: { style: { marginTop: null, marginBottom: null } },
70
- }}
71
- />
65
+ <span className={css({ paddingRight: theme.sizing.scale300 })}>
66
+ <Checkbox
67
+ onChange={props.onSelect}
68
+ checked={props.isSelected}
69
+ overrides={{
70
+ Checkmark: { style: { marginTop: null, marginBottom: null } },
71
+ }}
72
+ />
73
+ </span>
72
74
  )}
73
75
  <ProvidedCell {...props} />
74
76
  </div>
@@ -485,7 +485,7 @@ var InnerTableElement = /*#__PURE__*/React.forwardRef(function (props, ref) {
485
485
  });
486
486
  },
487
487
  size: _index.SIZE.compact,
488
- kind: _index.KIND.minimal,
488
+ kind: _index.KIND.tertiary,
489
489
  shape: _index.SHAPE.round,
490
490
  overrides: {
491
491
  BaseButton: {
@@ -587,7 +587,7 @@ const InnerTableElement = React.forwardRef<
587
587
  })
588
588
  }
589
589
  size={BUTTON_SIZES.compact}
590
- kind={BUTTON_KINDS.minimal}
590
+ kind={BUTTON_KINDS.tertiary}
591
591
  shape={BUTTON_SHAPES.round}
592
592
  overrides={{
593
593
  BaseButton: {
@@ -111,6 +111,9 @@ var HeaderCell = /*#__PURE__*/React.forwardRef(function (props, ref) {
111
111
  onFocus: handleFocus,
112
112
  onBlur: handleBlur
113
113
  }, props.isSelectable && /*#__PURE__*/React.createElement("span", {
114
+ className: css({
115
+ paddingRight: theme.sizing.scale300
116
+ }),
114
117
  ref: checkboxRef
115
118
  }, /*#__PURE__*/React.createElement(_index.Checkbox, {
116
119
  onChange: function onChange(e) {
@@ -97,7 +97,7 @@ const HeaderCell = React.forwardRef<HeaderCellPropsT, HTMLDivElement>((props, re
97
97
  onBlur={handleBlur}
98
98
  >
99
99
  {props.isSelectable && (
100
- <span ref={checkboxRef}>
100
+ <span className={css({ paddingRight: theme.sizing.scale300 })} ref={checkboxRef}>
101
101
  <Checkbox
102
102
  onChange={(e) => {
103
103
  if (props.isSelectedAll || props.isSelectedIndeterminate) {
@@ -339,10 +339,16 @@ var Calendar = /*#__PURE__*/function (_React$Component) {
339
339
 
340
340
 
341
341
  if (Array.isArray(data.date)) {
342
- updatedDate = data.date.map(function (date, index) {
343
- newTimeState[index] = _this.dateHelpers.applyDateToTime(newTimeState[index], date);
344
- return newTimeState[index];
345
- });
342
+ var start = data.date[0] ? _this.dateHelpers.applyDateToTime(newTimeState[0], data.date[0]) : null;
343
+ var end = data.date[1] ? _this.dateHelpers.applyDateToTime(newTimeState[1], data.date[1]) : null;
344
+ newTimeState[0] = start;
345
+
346
+ if (end) {
347
+ updatedDate = [start, end];
348
+ newTimeState[1] = end;
349
+ } else {
350
+ updatedDate = [start];
351
+ }
346
352
  } else if (!Array.isArray(_this.props.value) && data.date) {
347
353
  newTimeState[0] = _this.dateHelpers.applyDateToTime(newTimeState[0], data.date);
348
354
  updatedDate = newTimeState[0];
@@ -374,7 +380,7 @@ var Calendar = /*#__PURE__*/function (_React$Component) {
374
380
 
375
381
  if (Array.isArray(_this.props.value)) {
376
382
  var dates = _this.props.value.map(function (date, i) {
377
- if (index === i) {
383
+ if (date && index === i) {
378
384
  return _this.dateHelpers.applyTimeToDate(date, time);
379
385
  }
380
386
 
@@ -382,7 +388,7 @@ var Calendar = /*#__PURE__*/function (_React$Component) {
382
388
  });
383
389
 
384
390
  onChange({
385
- date: dates
391
+ date: [dates[0], dates[1]]
386
392
  });
387
393
  } else {
388
394
  var date = _this.dateHelpers.applyTimeToDate(_this.props.value, time);
@@ -452,7 +458,9 @@ var Calendar = /*#__PURE__*/function (_React$Component) {
452
458
  overrides: overrides,
453
459
  value: _this.props.value,
454
460
  peekNextMonth: _this.props.peekNextMonth,
455
- fixedHeight: _this.props.fixedHeight
461
+ fixedHeight: _this.props.fixedHeight,
462
+ hasLockedBehavior: !!_this.props.hasLockedBehavior,
463
+ selectedInput: _this.props.selectedInput
456
464
  })));
457
465
  monthList.push( /*#__PURE__*/React.createElement("div", {
458
466
  key: "month-component-".concat(i)
@@ -22,7 +22,7 @@ import {
22
22
  import dateFnsAdapter from './utils/date-fns-adapter.js';
23
23
  import DateHelpers from './utils/date-helpers.js';
24
24
  import { getOverrides, mergeOverrides } from '../helpers/overrides.js';
25
- import type { CalendarPropsT, CalendarInternalState } from './types.js';
25
+ import type { CalendarPropsT, CalendarInternalState, DateValueT } from './types.js';
26
26
  import { DENSITY, ORIENTATION } from './constants.js';
27
27
 
28
28
  export default class Calendar<T = Date> extends React.Component<
@@ -134,7 +134,7 @@ export default class Calendar<T = Date> extends React.Component<
134
134
  return monthDelta >= 0 && monthDelta < (this.props.monthsShown || 1);
135
135
  }
136
136
 
137
- getSingleDate(value: ?T | Array<T>): ?T {
137
+ getSingleDate(value: DateValueT<T>): ?T {
138
138
  // need to check this.props.range but flow would complain
139
139
  // at the return value in the else clause
140
140
  if (Array.isArray(value)) {
@@ -337,21 +337,33 @@ export default class Calendar<T = Date> extends React.Component<
337
337
  this.props.onDayMouseLeave && this.props.onDayMouseLeave(data);
338
338
  };
339
339
 
340
- handleDateChange: ({ date: ?T | Array<T> }) => void = (data) => {
340
+ /** Responsible for merging time values into date values. Note: the 'Day' component
341
+ * determines how the days themselves change when a new day is selected. */
342
+ handleDateChange: ({ date: DateValueT<T> }) => void = (data) => {
341
343
  const { onChange = (params) => {} } = this.props;
342
344
  let updatedDate = data.date;
343
345
  // We'll need to update the date in time values of internal state
344
346
  const newTimeState = [...this.state.time];
345
347
  // Apply the currently selected time values (saved in state) to the updated date
346
348
  if (Array.isArray(data.date)) {
347
- updatedDate = data.date.map((date, index) => {
348
- newTimeState[index] = this.dateHelpers.applyDateToTime(newTimeState[index], date);
349
- return newTimeState[index];
350
- });
349
+ const start = data.date[0]
350
+ ? this.dateHelpers.applyDateToTime(newTimeState[0], data.date[0])
351
+ : null;
352
+ const end = data.date[1]
353
+ ? this.dateHelpers.applyDateToTime(newTimeState[1], data.date[1])
354
+ : null;
355
+ newTimeState[0] = start;
356
+ if (end) {
357
+ updatedDate = [start, end];
358
+ newTimeState[1] = end;
359
+ } else {
360
+ updatedDate = [start];
361
+ }
351
362
  } else if (!Array.isArray(this.props.value) && data.date) {
352
363
  newTimeState[0] = this.dateHelpers.applyDateToTime(newTimeState[0], data.date);
353
364
  updatedDate = newTimeState[0];
354
365
  }
366
+
355
367
  // Update the date in time values of internal state
356
368
  this.setState({ time: newTimeState });
357
369
  onChange({ date: updatedDate });
@@ -367,12 +379,12 @@ export default class Calendar<T = Date> extends React.Component<
367
379
  // with the date value set to the date with updated time
368
380
  if (Array.isArray(this.props.value)) {
369
381
  const dates = this.props.value.map((date, i) => {
370
- if (index === i) {
382
+ if (date && index === i) {
371
383
  return this.dateHelpers.applyTimeToDate(date, time);
372
384
  }
373
385
  return date;
374
386
  });
375
- onChange({ date: dates });
387
+ onChange({ date: [dates[0], dates[1]] });
376
388
  } else {
377
389
  const date = this.dateHelpers.applyTimeToDate(this.props.value, time);
378
390
  onChange({ date });
@@ -452,6 +464,8 @@ export default class Calendar<T = Date> extends React.Component<
452
464
  value={this.props.value}
453
465
  peekNextMonth={this.props.peekNextMonth}
454
466
  fixedHeight={this.props.fixedHeight}
467
+ hasLockedBehavior={!!this.props.hasLockedBehavior}
468
+ selectedInput={this.props.selectedInput}
455
469
  />
456
470
  </CalendarContainer>
457
471
  );
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.DENSITY = exports.DEFAULT_MONTHS = exports.WEEKDAYS = exports.STATE_CHANGE_TYPE = exports.ORIENTATION = exports.ISO_MONTH_FORMAT = exports.ISO_FORMAT = exports.DISPLAY_FORMAT = void 0;
6
+ exports.RANGED_CALENDAR_BEHAVIOR = exports.INPUT_ROLE = exports.DENSITY = exports.DEFAULT_MONTHS = exports.WEEKDAYS = exports.STATE_CHANGE_TYPE = exports.ORIENTATION = exports.ISO_MONTH_FORMAT = exports.ISO_FORMAT = exports.DISPLAY_FORMAT = void 0;
7
7
 
8
8
  /*
9
9
  Copyright (c) Uber Technologies, Inc.
@@ -40,4 +40,14 @@ var DENSITY = {
40
40
  high: 'high',
41
41
  default: 'default'
42
42
  };
43
- exports.DENSITY = DENSITY;
43
+ exports.DENSITY = DENSITY;
44
+ var INPUT_ROLE = {
45
+ startDate: 'startDate',
46
+ endDate: 'endDate'
47
+ };
48
+ exports.INPUT_ROLE = INPUT_ROLE;
49
+ var RANGED_CALENDAR_BEHAVIOR = {
50
+ default: 'default',
51
+ locked: 'locked'
52
+ };
53
+ exports.RANGED_CALENDAR_BEHAVIOR = RANGED_CALENDAR_BEHAVIOR;
@@ -33,6 +33,16 @@ export const DENSITY = {
33
33
  default: 'default',
34
34
  };
35
35
 
36
+ export const INPUT_ROLE = {
37
+ startDate: 'startDate',
38
+ endDate: 'endDate',
39
+ };
40
+
41
+ export const RANGED_CALENDAR_BEHAVIOR = {
42
+ default: 'default',
43
+ locked: 'locked',
44
+ };
45
+
36
46
  declare var __DEV__: boolean;
37
47
  declare var __NODE__: boolean;
38
48
  declare var __BROWSER__: boolean;