baseui 10.12.0 → 11.0.1
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.
- package/README.md +3 -3
- package/accordion/accordion.js +60 -13
- package/accordion/accordion.js.flow +49 -12
- package/accordion/index.d.ts +0 -3
- package/accordion/panel.js +7 -6
- package/accordion/panel.js.flow +20 -20
- package/accordion/stateless-accordion.js +2 -4
- package/accordion/stateless-accordion.js.flow +0 -2
- package/accordion/types.js.flow +0 -5
- package/button/constants.js +1 -2
- package/button/constants.js.flow +0 -1
- package/button/index.d.ts +0 -1
- package/button/styled-components.js +2 -29
- package/button/styled-components.js.flow +2 -30
- package/checkbox/checkbox.js +6 -30
- package/checkbox/checkbox.js.flow +7 -38
- package/checkbox/constants.js +2 -1
- package/checkbox/constants.js.flow +2 -1
- package/checkbox/index.d.ts +4 -6
- package/checkbox/index.js +0 -6
- package/checkbox/index.js.flow +0 -1
- package/checkbox/styled-components.js +52 -149
- package/checkbox/styled-components.js.flow +59 -165
- package/checkbox/types.js.flow +0 -5
- package/data-table/column-categorical.js +1 -1
- package/data-table/column-categorical.js.flow +1 -1
- package/data-table/column-datetime.js +1 -1
- package/data-table/column-datetime.js.flow +3 -1
- package/data-table/column.js +6 -2
- package/data-table/column.js.flow +9 -7
- package/data-table/data-table.js +10 -2
- package/data-table/data-table.js.flow +4 -1
- package/data-table/header-cell.js +3 -0
- package/data-table/header-cell.js.flow +1 -1
- package/data-table/index.d.ts +7 -8
- package/data-table/stateful-data-table.js +2 -1
- package/data-table/stateful-data-table.js.flow +1 -0
- package/data-table/types.js.flow +8 -0
- package/datepicker/calendar.js +15 -7
- package/datepicker/calendar.js.flow +23 -9
- package/datepicker/constants.js +12 -2
- package/datepicker/constants.js.flow +10 -0
- package/datepicker/datepicker.js +61 -30
- package/datepicker/datepicker.js.flow +77 -37
- package/datepicker/day.js +85 -34
- package/datepicker/day.js.flow +118 -54
- package/datepicker/locale.js.flow +0 -1
- package/datepicker/month.js +3 -1
- package/datepicker/month.js.flow +2 -0
- package/datepicker/stateful-container.js.flow +2 -1
- package/datepicker/styled-components.js +23 -1
- package/datepicker/styled-components.js.flow +12 -2
- package/datepicker/types.js.flow +35 -10
- package/datepicker/utils/date-helpers.js +30 -0
- package/datepicker/utils/date-helpers.js.flow +12 -0
- package/datepicker/week.js +3 -1
- package/datepicker/week.js.flow +2 -0
- package/es/accordion/accordion.js +52 -12
- package/es/accordion/panel.js +7 -5
- package/es/accordion/stateless-accordion.js +2 -4
- package/es/button/constants.js +1 -2
- package/es/button/styled-components.js +2 -29
- package/es/checkbox/checkbox.js +7 -32
- package/es/checkbox/constants.js +2 -1
- package/es/checkbox/index.js +1 -1
- package/es/checkbox/styled-components.js +51 -146
- package/es/data-table/column-categorical.js +1 -1
- package/es/data-table/column-datetime.js +1 -1
- package/es/data-table/column.js +6 -2
- package/es/data-table/data-table.js +6 -2
- package/es/data-table/header-cell.js +3 -0
- package/es/data-table/stateful-data-table.js +2 -1
- package/es/datepicker/calendar.js +15 -7
- package/es/datepicker/constants.js +8 -0
- package/es/datepicker/datepicker.js +56 -29
- package/es/datepicker/day.js +77 -34
- package/es/datepicker/month.js +3 -1
- package/es/datepicker/styled-components.js +8 -2
- package/es/datepicker/types.js +1 -1
- package/es/datepicker/utils/date-helpers.js +16 -0
- package/es/datepicker/week.js +3 -1
- package/es/file-uploader/file-uploader.js +4 -4
- package/es/form-control/styled-components.js +0 -1
- package/es/header-navigation/styled-components.js +3 -3
- package/es/helpers/overrides.js +1 -2
- package/es/input/styled-components.js +4 -4
- package/es/layer/layer.js +4 -4
- package/es/list/list-item.js +5 -1
- package/es/list/menu-adapter.js +4 -0
- package/es/locale/index.js +0 -7
- package/es/menu/stateful-container.js +0 -1
- package/es/menu/styled-components.js +1 -1
- package/es/modal/index.js +1 -1
- package/es/modal/modal.js +19 -65
- package/es/modal/styled-components.js +12 -48
- package/es/phone-input/default-props.js +1 -1
- package/es/phone-input/index.js +0 -4
- package/es/phone-input/phone-input-lite.js +55 -31
- package/es/radio/radio.js +1 -7
- package/es/radio/radiogroup.js +3 -28
- package/es/radio/styled-components.js +4 -5
- package/es/rating/styled-components.js +3 -3
- package/es/select/index.js +1 -2
- package/es/select/select-component.js +20 -20
- package/es/select/styled-components.js +21 -17
- package/es/snackbar/styled-components.js +2 -2
- package/es/spinner/index.js +3 -9
- package/es/spinner/styled-components.js +2 -32
- package/es/table/filter.js +3 -3
- package/es/tag/styled-components.js +1 -1
- package/es/themes/dark-theme/color-component-tokens.js +0 -38
- package/es/themes/dark-theme/color-tokens.js +0 -2
- package/es/themes/dark-theme/create-dark-theme.js +0 -2
- package/es/themes/dark-theme/dark-theme.js +0 -2
- package/es/themes/light-theme/color-component-tokens.js +0 -38
- package/es/themes/light-theme/color-tokens.js +0 -2
- package/es/themes/light-theme/create-light-theme.js +0 -2
- package/es/themes/light-theme/light-theme.js +0 -2
- package/es/timepicker/timepicker.js +1 -8
- package/es/typography/index.js +1 -31
- package/esm/accordion/accordion.js +60 -13
- package/esm/accordion/panel.js +7 -6
- package/esm/accordion/stateless-accordion.js +2 -4
- package/esm/button/constants.js +1 -2
- package/esm/button/styled-components.js +2 -29
- package/esm/checkbox/checkbox.js +7 -30
- package/esm/checkbox/constants.js +2 -1
- package/esm/checkbox/index.js +1 -1
- package/esm/checkbox/styled-components.js +52 -147
- package/esm/data-table/column-categorical.js +1 -1
- package/esm/data-table/column-datetime.js +1 -1
- package/esm/data-table/column.js +6 -2
- package/esm/data-table/data-table.js +10 -2
- package/esm/data-table/header-cell.js +3 -0
- package/esm/data-table/stateful-data-table.js +2 -1
- package/esm/datepicker/calendar.js +15 -7
- package/esm/datepicker/constants.js +8 -0
- package/esm/datepicker/datepicker.js +60 -30
- package/esm/datepicker/day.js +84 -34
- package/esm/datepicker/month.js +3 -1
- package/esm/datepicker/styled-components.js +24 -2
- package/esm/datepicker/types.js +1 -1
- package/esm/datepicker/utils/date-helpers.js +30 -0
- package/esm/datepicker/week.js +3 -1
- package/esm/file-uploader/file-uploader.js +4 -4
- package/esm/form-control/styled-components.js +0 -1
- package/esm/header-navigation/styled-components.js +3 -3
- package/esm/helpers/overrides.js +1 -2
- package/esm/input/styled-components.js +4 -4
- package/esm/layer/layer.js +4 -4
- package/esm/list/list-item.js +5 -1
- package/esm/list/menu-adapter.js +4 -0
- package/esm/locale/index.js +0 -7
- package/esm/menu/stateful-container.js +0 -1
- package/esm/menu/styled-components.js +1 -1
- package/esm/modal/index.js +1 -1
- package/esm/modal/modal.js +28 -71
- package/esm/modal/styled-components.js +6 -38
- package/esm/phone-input/default-props.js +1 -1
- package/esm/phone-input/index.js +0 -4
- package/esm/phone-input/phone-input-lite.js +60 -37
- package/esm/radio/radio.js +1 -7
- package/esm/radio/radiogroup.js +3 -28
- package/esm/radio/styled-components.js +4 -5
- package/esm/rating/styled-components.js +3 -3
- package/esm/select/index.js +1 -2
- package/esm/select/select-component.js +20 -20
- package/esm/select/styled-components.js +21 -14
- package/esm/snackbar/styled-components.js +2 -2
- package/esm/spinner/index.js +3 -9
- package/esm/spinner/styled-components.js +2 -40
- package/esm/table/filter.js +3 -3
- package/esm/tag/styled-components.js +1 -1
- package/esm/themes/dark-theme/color-component-tokens.js +0 -38
- package/esm/themes/dark-theme/color-tokens.js +0 -2
- package/esm/themes/dark-theme/create-dark-theme.js +1 -2
- package/esm/themes/dark-theme/dark-theme.js +1 -2
- package/esm/themes/light-theme/color-component-tokens.js +0 -38
- package/esm/themes/light-theme/color-tokens.js +0 -2
- package/esm/themes/light-theme/create-light-theme.js +1 -2
- package/esm/themes/light-theme/light-theme.js +1 -2
- package/esm/timepicker/timepicker.js +1 -8
- package/esm/typography/index.js +1 -35
- package/file-uploader/file-uploader.js +3 -3
- package/file-uploader/file-uploader.js.flow +4 -4
- package/form-control/index.d.ts +9 -0
- package/form-control/styled-components.js +0 -1
- package/form-control/styled-components.js.flow +0 -1
- package/header-navigation/styled-components.js +3 -3
- package/header-navigation/styled-components.js.flow +3 -3
- package/helpers/overrides.js +1 -2
- package/helpers/overrides.js.flow +1 -1
- package/input/index.d.ts +5 -9
- package/input/styled-components.js +4 -4
- package/input/styled-components.js.flow +4 -4
- package/layer/layer.js +4 -4
- package/layer/layer.js.flow +4 -3
- package/list/list-item.js +5 -1
- package/list/list-item.js.flow +4 -0
- package/list/menu-adapter.js +4 -0
- package/list/menu-adapter.js.flow +4 -0
- package/list/types.js.flow +4 -0
- package/locale/index.js +0 -7
- package/locale/index.js.flow +0 -7
- package/locale.ts +0 -1
- package/menu/index.d.ts +1 -3
- package/menu/stateful-container.js +0 -1
- package/menu/stateful-container.js.flow +0 -1
- package/menu/styled-components.js +1 -1
- package/menu/styled-components.js.flow +1 -1
- package/modal/index.d.ts +4 -6
- package/modal/index.js +0 -6
- package/modal/index.js.flow +0 -1
- package/modal/modal.js +27 -70
- package/modal/modal.js.flow +17 -83
- package/modal/styled-components.js +7 -40
- package/modal/styled-components.js.flow +12 -44
- package/modal/types.js.flow +1 -10
- package/package.json +3 -2
- package/phone-input/default-props.js +1 -1
- package/phone-input/default-props.js.flow +1 -1
- package/phone-input/index.d.ts +0 -1
- package/phone-input/index.js +0 -36
- package/phone-input/index.js.flow +0 -4
- package/phone-input/phone-input-lite.js +63 -38
- package/phone-input/phone-input-lite.js.flow +66 -44
- package/radio/index.d.ts +4 -9
- package/radio/radio.js +1 -7
- package/radio/radio.js.flow +1 -8
- package/radio/radiogroup.js +3 -28
- package/radio/radiogroup.js.flow +2 -26
- package/radio/styled-components.js +4 -5
- package/radio/styled-components.js.flow +3 -4
- package/radio/types.js.flow +4 -15
- package/rating/styled-components.js +3 -3
- package/rating/styled-components.js.flow +3 -3
- package/select/index.d.ts +0 -2
- package/select/index.js +0 -6
- package/select/index.js.flow +0 -2
- package/select/select-component.js +23 -24
- package/select/select-component.js.flow +25 -14
- package/select/styled-components.js +23 -17
- package/select/styled-components.js.flow +17 -12
- package/snackbar/styled-components.js +1 -1
- package/snackbar/styled-components.js.flow +11 -11
- package/spinner/index.d.ts +5 -18
- package/spinner/index.js +2 -68
- package/spinner/index.js.flow +2 -27
- package/spinner/styled-components.js +9 -45
- package/spinner/styled-components.js.flow +2 -34
- package/spinner/types.js.flow +1 -19
- package/styles/types.js.flow +0 -2
- package/table/filter.js +3 -3
- package/table/filter.js.flow +3 -3
- package/tag/styled-components.js +1 -1
- package/tag/styled-components.js.flow +1 -1
- package/theme.ts +0 -81
- package/themes/dark-theme/color-component-tokens.js +0 -38
- package/themes/dark-theme/color-component-tokens.js.flow +0 -42
- package/themes/dark-theme/color-tokens.js +0 -2
- package/themes/dark-theme/color-tokens.js.flow +0 -2
- package/themes/dark-theme/create-dark-theme.js +1 -3
- package/themes/dark-theme/create-dark-theme.js.flow +0 -2
- package/themes/dark-theme/dark-theme.js +1 -3
- package/themes/dark-theme/dark-theme.js.flow +0 -2
- package/themes/light-theme/color-component-tokens.js +0 -38
- package/themes/light-theme/color-component-tokens.js.flow +0 -43
- package/themes/light-theme/color-tokens.js +0 -2
- package/themes/light-theme/color-tokens.js.flow +0 -2
- package/themes/light-theme/create-light-theme.js +1 -3
- package/themes/light-theme/create-light-theme.js.flow +0 -2
- package/themes/light-theme/light-theme.js +1 -3
- package/themes/light-theme/light-theme.js.flow +0 -2
- package/themes/types.js.flow +0 -68
- package/timepicker/timepicker.js +1 -8
- package/timepicker/timepicker.js.flow +4 -10
- package/typography/index.d.ts +0 -23
- package/typography/index.js +2 -57
- package/typography/index.js.flow +0 -31
- package/es/spinner/spinner.js +0 -68
- package/es/themes/dark-theme/color-deprecated-semantic-tokens.js +0 -35
- package/es/themes/light-theme/color-deprecated-semantic-tokens.js +0 -35
- package/esm/spinner/spinner.js +0 -125
- package/esm/themes/dark-theme/color-deprecated-semantic-tokens.js +0 -38
- package/esm/themes/light-theme/color-deprecated-semantic-tokens.js +0 -38
- package/spinner/spinner.js +0 -136
- package/spinner/spinner.js.flow +0 -75
- package/themes/dark-theme/color-deprecated-semantic-tokens.js +0 -50
- package/themes/dark-theme/color-deprecated-semantic-tokens.js.flow +0 -42
- package/themes/light-theme/color-deprecated-semantic-tokens.js +0 -50
- 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
|
|
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
|
|
29
|
-
return colors.
|
|
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 (
|
|
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
|
|
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
|
|
124
|
+
return colors.tickFillActive;
|
|
134
125
|
} else if ($isHovered) {
|
|
135
|
-
return
|
|
126
|
+
return colors.tickFillHover;
|
|
136
127
|
} else {
|
|
137
|
-
return
|
|
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 : $
|
|
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
|
-
|
|
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.$
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
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
|
-
|
|
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
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
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.
|
|
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
|
},
|
package/es/data-table/column.js
CHANGED
|
@@ -49,7 +49,11 @@ function Column(options) {
|
|
|
49
49
|
display: 'flex',
|
|
50
50
|
height: '100%'
|
|
51
51
|
})
|
|
52
|
-
}, Boolean(props.onSelect) && /*#__PURE__*/React.createElement(
|
|
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.
|
|
399
|
+
kind: BUTTON_KINDS.tertiary,
|
|
400
400
|
shape: BUTTON_SHAPES.round,
|
|
401
401
|
overrides: {
|
|
402
402
|
BaseButton: {
|
|
@@ -459,7 +459,8 @@ export function DataTable({
|
|
|
459
459
|
selectedRowIds,
|
|
460
460
|
sortIndex,
|
|
461
461
|
sortDirection,
|
|
462
|
-
textQuery = ''
|
|
462
|
+
textQuery = '',
|
|
463
|
+
controlRef
|
|
463
464
|
}) {
|
|
464
465
|
const [, theme] = useStyletron();
|
|
465
466
|
const locale = React.useContext(LocaleContext);
|
|
@@ -596,6 +597,9 @@ export function DataTable({
|
|
|
596
597
|
|
|
597
598
|
return result;
|
|
598
599
|
}, [sortedIndices, filteredIndices, onIncludedRowsChange, allRows]);
|
|
600
|
+
React.useImperativeHandle(controlRef, () => ({
|
|
601
|
+
getRows: () => rows
|
|
602
|
+
}), [rows]);
|
|
599
603
|
const [browserScrollbarWidth, setBrowserScrollbarWidth] = React.useState(0);
|
|
600
604
|
const normalizedWidths = React.useMemo(() => {
|
|
601
605
|
const resizedWidths = measuredWidths.map((w, i) => Math.floor(w) + Math.floor(resizeDeltas[i]));
|
|
@@ -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
|
-
|
|
261
|
-
|
|
262
|
-
|
|
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 = '',
|
|
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 (
|
|
29
|
-
inputValue = `${inputValue}
|
|
29
|
+
if (inputRole === INPUT_ROLE.startDate && prevEndDate) {
|
|
30
|
+
inputValue = `${inputValue} ${INPUT_DELIMITER} ${prevEndDate}`;
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
if (
|
|
33
|
-
inputValue = `${prevStartDate}
|
|
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
|
|
55
|
+
if (!nextDate[0] || !nextDate[1]) {
|
|
55
56
|
isOpen = true;
|
|
56
57
|
isPseudoFocused = true;
|
|
57
58
|
calendarFocused = null;
|
|
58
|
-
} else if (nextDate
|
|
59
|
+
} else if (nextDate[0] && nextDate[1]) {
|
|
59
60
|
const [start, end] = nextDate;
|
|
60
61
|
|
|
61
62
|
if (this.dateHelpers.isAfter(start, end)) {
|
|
62
|
-
|
|
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
|
|
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,
|
|
204
|
-
const inputValue = this.props.range && this.props.separateRangeInputs ? combineSeparatedInputs(event.currentTarget.value, this.state.inputValue,
|
|
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,
|
|
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,
|
|
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 ?
|
|
403
|
-
const [startDate = '', endDate = ''] = (this.state.inputValue || '').split(INPUT_DELIMITER);
|
|
404
|
-
const value =
|
|
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,
|
|
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,
|
|
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.
|
|
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
|
|
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])
|