baseui 10.12.1 → 11.0.2
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 +28 -15
- package/datepicker/calendar.js.flow +31 -14
- package/datepicker/constants.js +12 -2
- package/datepicker/constants.js.flow +10 -0
- package/datepicker/datepicker.js +117 -86
- package/datepicker/datepicker.js.flow +123 -66
- 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-calendar.js +6 -1
- package/datepicker/stateful-calendar.js.flow +8 -1
- package/datepicker/stateful-container.js +23 -2
- package/datepicker/stateful-container.js.flow +17 -3
- package/datepicker/stateful-datepicker.js +6 -1
- package/datepicker/stateful-datepicker.js.flow +7 -1
- package/datepicker/styled-components.js +23 -1
- package/datepicker/styled-components.js.flow +12 -2
- package/datepicker/types.js.flow +46 -43
- 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 +28 -15
- package/es/datepicker/constants.js +8 -0
- package/es/datepicker/datepicker.js +106 -79
- package/es/datepicker/day.js +77 -34
- package/es/datepicker/month.js +3 -1
- package/es/datepicker/stateful-calendar.js +6 -1
- package/es/datepicker/stateful-container.js +22 -2
- package/es/datepicker/stateful-datepicker.js +6 -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/snackbar-context.js +1 -1
- 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 +28 -15
- package/esm/datepicker/constants.js +8 -0
- package/esm/datepicker/datepicker.js +116 -86
- package/esm/datepicker/day.js +84 -34
- package/esm/datepicker/month.js +3 -1
- package/esm/datepicker/stateful-calendar.js +6 -1
- package/esm/datepicker/stateful-container.js +23 -2
- package/esm/datepicker/stateful-datepicker.js +6 -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/snackbar-context.js +1 -1
- 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/snackbar-context.js +1 -1
- package/snackbar/snackbar-context.js.flow +1 -1
- 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/tag/types.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
package/datepicker/day.js.flow
CHANGED
|
@@ -14,6 +14,7 @@ import type { DayPropsT, DayStateT } from './types.js';
|
|
|
14
14
|
import { LocaleContext } from '../locale/index.js';
|
|
15
15
|
import type { LocaleT } from '../locale/types.js';
|
|
16
16
|
import { isFocusVisible } from '../utils/focusVisible.js';
|
|
17
|
+
import { INPUT_ROLE } from './constants.js';
|
|
17
18
|
|
|
18
19
|
export default class Day<T = Date> extends React.Component<DayPropsT<T>, DayStateT> {
|
|
19
20
|
static defaultProps = {
|
|
@@ -72,21 +73,58 @@ export default class Day<T = Date> extends React.Component<DayPropsT<T>, DayStat
|
|
|
72
73
|
: this.props.month;
|
|
73
74
|
};
|
|
74
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Determines how the day value(s) should be updated when a new day is selected.
|
|
78
|
+
* Note: time values are incorporated into new day/date values downstream in `Calendar`.
|
|
79
|
+
* Note: Situations where Start Dates are after End Dates are handled downstream in `Datepicker`.
|
|
80
|
+
* */
|
|
75
81
|
onSelect: (T) => void = (selectedDate) => {
|
|
76
82
|
const { range, value } = this.props;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
+
|
|
84
|
+
let nextDate;
|
|
85
|
+
if (Array.isArray(value) && range && this.props.hasLockedBehavior) {
|
|
86
|
+
const currentDate = this.props.value;
|
|
87
|
+
let nextStartDate = null;
|
|
88
|
+
let nextEndDate = null;
|
|
89
|
+
|
|
90
|
+
if (this.props.selectedInput === INPUT_ROLE.startDate) {
|
|
91
|
+
nextStartDate = selectedDate;
|
|
92
|
+
nextEndDate = Array.isArray(currentDate) && currentDate[1] ? currentDate[1] : null;
|
|
93
|
+
} else if (this.props.selectedInput === INPUT_ROLE.endDate) {
|
|
94
|
+
nextStartDate = Array.isArray(currentDate) && currentDate[0] ? currentDate[0] : null;
|
|
95
|
+
nextEndDate = selectedDate;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
nextDate = [nextStartDate];
|
|
99
|
+
if (nextEndDate) {
|
|
100
|
+
nextDate.push(nextEndDate);
|
|
101
|
+
}
|
|
102
|
+
} else if (Array.isArray(value) && range && !this.props.hasLockedBehavior) {
|
|
103
|
+
const [start, end] = value;
|
|
104
|
+
|
|
105
|
+
// Starting a new range
|
|
106
|
+
if ((!start && !end) || (start && end)) {
|
|
107
|
+
nextDate = [selectedDate, null];
|
|
108
|
+
|
|
109
|
+
// EndDate needs a StartDate, SelectedDate comes before EndDate
|
|
110
|
+
} else if (!start && end && this.dateHelpers.isAfter(end, selectedDate)) {
|
|
111
|
+
nextDate = [selectedDate, end];
|
|
112
|
+
|
|
113
|
+
// EndDate needs a StartDate, but SelectedDate comes after EndDate
|
|
114
|
+
} else if (!start && end && this.dateHelpers.isAfter(selectedDate, end)) {
|
|
115
|
+
nextDate = [end, selectedDate];
|
|
116
|
+
|
|
117
|
+
// StartDate needs an EndDate, SelectedDate comes after StartDate
|
|
118
|
+
} else if (start && !end && this.dateHelpers.isAfter(selectedDate, start)) {
|
|
119
|
+
nextDate = [start, selectedDate];
|
|
83
120
|
} else {
|
|
84
|
-
|
|
121
|
+
nextDate = [selectedDate, start];
|
|
85
122
|
}
|
|
86
123
|
} else {
|
|
87
|
-
|
|
124
|
+
nextDate = selectedDate;
|
|
88
125
|
}
|
|
89
|
-
|
|
126
|
+
|
|
127
|
+
this.props.onSelect({ date: nextDate });
|
|
90
128
|
};
|
|
91
129
|
|
|
92
130
|
onKeyDown = (event: KeyboardEvent) => {
|
|
@@ -205,16 +243,21 @@ export default class Day<T = Date> extends React.Component<DayPropsT<T>, DayStat
|
|
|
205
243
|
isPseudoSelected() {
|
|
206
244
|
const date = this.getDateProp();
|
|
207
245
|
const { value } = this.props;
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
246
|
+
|
|
247
|
+
if (Array.isArray(value)) {
|
|
248
|
+
const [start, end] = value;
|
|
249
|
+
|
|
250
|
+
if (!start && !end) {
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if (start && end) {
|
|
255
|
+
return this.dateHelpers.isDayInRange(
|
|
256
|
+
this.clampToDayStart(date),
|
|
257
|
+
this.clampToDayStart(start),
|
|
258
|
+
this.clampToDayStart(end)
|
|
259
|
+
);
|
|
260
|
+
}
|
|
218
261
|
}
|
|
219
262
|
}
|
|
220
263
|
|
|
@@ -222,46 +265,66 @@ export default class Day<T = Date> extends React.Component<DayPropsT<T>, DayStat
|
|
|
222
265
|
isPseudoHighlighted() {
|
|
223
266
|
const date = this.getDateProp();
|
|
224
267
|
const { value, highlightedDate } = this.props;
|
|
225
|
-
if (Array.isArray(value) && !value[0] && !value[1]) {
|
|
226
|
-
return false;
|
|
227
|
-
}
|
|
228
268
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
269
|
+
if (Array.isArray(value)) {
|
|
270
|
+
const [start, end] = value;
|
|
271
|
+
|
|
272
|
+
if (!start && !end) {
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
if (highlightedDate && start && !end) {
|
|
277
|
+
if (this.dateHelpers.isAfter(highlightedDate, start)) {
|
|
278
|
+
return this.dateHelpers.isDayInRange(
|
|
279
|
+
this.clampToDayStart(date),
|
|
280
|
+
this.clampToDayStart(start),
|
|
281
|
+
this.clampToDayStart(highlightedDate)
|
|
282
|
+
);
|
|
283
|
+
} else {
|
|
284
|
+
return this.dateHelpers.isDayInRange(
|
|
285
|
+
this.clampToDayStart(date),
|
|
286
|
+
this.clampToDayStart(highlightedDate),
|
|
287
|
+
this.clampToDayStart(start)
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
if (highlightedDate && !start && end) {
|
|
293
|
+
if (this.dateHelpers.isAfter(highlightedDate, end)) {
|
|
294
|
+
return this.dateHelpers.isDayInRange(
|
|
295
|
+
this.clampToDayStart(date),
|
|
296
|
+
this.clampToDayStart(end),
|
|
297
|
+
this.clampToDayStart(highlightedDate)
|
|
298
|
+
);
|
|
299
|
+
} else {
|
|
300
|
+
return this.dateHelpers.isDayInRange(
|
|
301
|
+
this.clampToDayStart(date),
|
|
302
|
+
this.clampToDayStart(highlightedDate),
|
|
303
|
+
this.clampToDayStart(end)
|
|
304
|
+
);
|
|
305
|
+
}
|
|
243
306
|
}
|
|
244
307
|
}
|
|
245
308
|
}
|
|
246
309
|
|
|
247
310
|
getSharedProps() {
|
|
248
311
|
const date = this.getDateProp();
|
|
249
|
-
const { value, highlightedDate, range, highlighted } = this.props;
|
|
312
|
+
const { value, highlightedDate, range, highlighted, peekNextMonth } = this.props;
|
|
250
313
|
const $isHighlighted = highlighted;
|
|
251
314
|
const $selected = this.isSelected();
|
|
252
315
|
const $hasRangeHighlighted = !!(
|
|
253
316
|
Array.isArray(value) &&
|
|
254
317
|
range &&
|
|
255
|
-
value.length === 1 &&
|
|
256
318
|
highlightedDate &&
|
|
257
|
-
!this.dateHelpers.isSameDay(value[0], highlightedDate)
|
|
319
|
+
((value[0] && !value[1] && !this.dateHelpers.isSameDay(value[0], highlightedDate)) ||
|
|
320
|
+
(!value[0] && value[1] && !this.dateHelpers.isSameDay(value[1], highlightedDate)))
|
|
258
321
|
);
|
|
259
|
-
const $outsideMonth = !
|
|
322
|
+
const $outsideMonth = !peekNextMonth && this.isOutsideMonth();
|
|
260
323
|
const $outsideMonthWithinRange = !!(
|
|
261
324
|
Array.isArray(value) &&
|
|
262
325
|
range &&
|
|
263
326
|
$outsideMonth &&
|
|
264
|
-
!
|
|
327
|
+
!peekNextMonth &&
|
|
265
328
|
this.isOutsideOfMonthButWithinRange()
|
|
266
329
|
);
|
|
267
330
|
return {
|
|
@@ -270,7 +333,8 @@ export default class Day<T = Date> extends React.Component<DayPropsT<T>, DayStat
|
|
|
270
333
|
$disabled: this.props.disabled,
|
|
271
334
|
$endDate:
|
|
272
335
|
(Array.isArray(value) &&
|
|
273
|
-
|
|
336
|
+
!!(value[0] && value[1]) &&
|
|
337
|
+
range &&
|
|
274
338
|
$selected &&
|
|
275
339
|
this.dateHelpers.isSameDay(date, value[1])) ||
|
|
276
340
|
false,
|
|
@@ -280,9 +344,9 @@ export default class Day<T = Date> extends React.Component<DayPropsT<T>, DayStat
|
|
|
280
344
|
Array.isArray(value) &&
|
|
281
345
|
$hasRangeHighlighted &&
|
|
282
346
|
highlightedDate &&
|
|
283
|
-
value[0] &&
|
|
284
|
-
|
|
285
|
-
$hasRangeSelected: Array.isArray(value) ? value
|
|
347
|
+
((value[0] && this.dateHelpers.isAfter(highlightedDate, value[0])) ||
|
|
348
|
+
(value[1] && this.dateHelpers.isAfter(highlightedDate, value[1]))),
|
|
349
|
+
$hasRangeSelected: Array.isArray(value) ? !!(value[0] && value[1]) : false,
|
|
286
350
|
$highlightedDate: highlightedDate,
|
|
287
351
|
$isHighlighted,
|
|
288
352
|
$isHovered: this.state.isHovered,
|
|
@@ -292,19 +356,19 @@ export default class Day<T = Date> extends React.Component<DayPropsT<T>, DayStat
|
|
|
292
356
|
$month: this.getMonthProp(),
|
|
293
357
|
$outsideMonth,
|
|
294
358
|
$outsideMonthWithinRange,
|
|
295
|
-
$peekNextMonth:
|
|
359
|
+
$peekNextMonth: peekNextMonth,
|
|
296
360
|
$pseudoHighlighted:
|
|
297
|
-
|
|
298
|
-
$pseudoSelected:
|
|
299
|
-
$range:
|
|
361
|
+
range && !$isHighlighted && !$selected ? this.isPseudoHighlighted() : false,
|
|
362
|
+
$pseudoSelected: range && !$selected ? this.isPseudoSelected() : false,
|
|
363
|
+
$range: range,
|
|
300
364
|
$selected,
|
|
301
365
|
$startDate:
|
|
302
|
-
Array.isArray(
|
|
303
|
-
|
|
304
|
-
this.props.range &&
|
|
305
|
-
$selected
|
|
306
|
-
? this.dateHelpers.isSameDay(date, this.props.value[0])
|
|
366
|
+
Array.isArray(value) && value[0] && value[1] && range && $selected
|
|
367
|
+
? this.dateHelpers.isSameDay(date, value[0])
|
|
307
368
|
: false,
|
|
369
|
+
$hasLockedBehavior: this.props.hasLockedBehavior,
|
|
370
|
+
$selectedInput: this.props.selectedInput,
|
|
371
|
+
$value: this.props.value,
|
|
308
372
|
};
|
|
309
373
|
}
|
|
310
374
|
|
|
@@ -28,7 +28,6 @@ export type DatepickerLocaleT = {|
|
|
|
28
28
|
quickSelectPlaceholder: string,
|
|
29
29
|
timeSelectEndLabel: string,
|
|
30
30
|
timeSelectStartLabel: string,
|
|
31
|
-
timePickerAriaLabel?: string,
|
|
32
31
|
timePickerAriaLabel12Hour: string,
|
|
33
32
|
timePickerAriaLabel24Hour: string,
|
|
34
33
|
timezonePickerAriaLabel: string,
|
package/datepicker/month.js
CHANGED
|
@@ -143,7 +143,9 @@ var CalendarMonth = /*#__PURE__*/function (_React$Component) {
|
|
|
143
143
|
onChange: _this.props.onChange,
|
|
144
144
|
overrides: _this.props.overrides,
|
|
145
145
|
peekNextMonth: _this.props.peekNextMonth,
|
|
146
|
-
value: _this.props.value
|
|
146
|
+
value: _this.props.value,
|
|
147
|
+
hasLockedBehavior: _this.props.hasLockedBehavior,
|
|
148
|
+
selectedInput: _this.props.selectedInput
|
|
147
149
|
}));
|
|
148
150
|
i++;
|
|
149
151
|
currentWeekStart = _this.dateHelpers.addWeeks(currentWeekStart, 1); // It will break on the next week if the week is out of the month
|
package/datepicker/month.js.flow
CHANGED
|
@@ -100,6 +100,8 @@ export default class CalendarMonth<T = Date> extends React.Component<MonthPropsT
|
|
|
100
100
|
overrides={this.props.overrides}
|
|
101
101
|
peekNextMonth={this.props.peekNextMonth}
|
|
102
102
|
value={this.props.value}
|
|
103
|
+
hasLockedBehavior={this.props.hasLockedBehavior}
|
|
104
|
+
selectedInput={this.props.selectedInput}
|
|
103
105
|
/>
|
|
104
106
|
);
|
|
105
107
|
i++;
|
|
@@ -19,6 +19,8 @@ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return
|
|
|
19
19
|
|
|
20
20
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
21
|
|
|
22
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
23
|
+
|
|
22
24
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
23
25
|
|
|
24
26
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
@@ -56,7 +58,10 @@ var StatefulComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
56
58
|
key: "render",
|
|
57
59
|
value: function render() {
|
|
58
60
|
return /*#__PURE__*/React.createElement(_statefulContainer.default, this.props, function (extendedProps) {
|
|
59
|
-
return /*#__PURE__*/React.createElement(_calendar.default, extendedProps
|
|
61
|
+
return /*#__PURE__*/React.createElement(_calendar.default, _extends({}, extendedProps, {
|
|
62
|
+
// flowlint-next-line unclear-type:off
|
|
63
|
+
onChange: extendedProps.onChange
|
|
64
|
+
}));
|
|
60
65
|
});
|
|
61
66
|
}
|
|
62
67
|
}]);
|
|
@@ -18,10 +18,17 @@ class StatefulComponent<T = Date> extends React.Component<PropsT<T>> {
|
|
|
18
18
|
stateReducer: (type, nextState) => nextState,
|
|
19
19
|
onSelect: () => {},
|
|
20
20
|
};
|
|
21
|
+
|
|
21
22
|
render() {
|
|
22
23
|
return (
|
|
23
24
|
<StatefulContainer {...this.props}>
|
|
24
|
-
{(extendedProps) =>
|
|
25
|
+
{(extendedProps) => (
|
|
26
|
+
<Calendar
|
|
27
|
+
{...extendedProps}
|
|
28
|
+
// flowlint-next-line unclear-type:off
|
|
29
|
+
onChange={(extendedProps.onChange: any)}
|
|
30
|
+
/>
|
|
31
|
+
)}
|
|
25
32
|
</StatefulContainer>
|
|
26
33
|
);
|
|
27
34
|
}
|
|
@@ -64,8 +64,29 @@ var StatefulContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
64
64
|
value: date
|
|
65
65
|
});
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
var onChange = _this.props.onChange;
|
|
68
|
+
|
|
69
|
+
if (onChange) {
|
|
70
|
+
if (Array.isArray(date)) {
|
|
71
|
+
if (date.every(Boolean)) {
|
|
72
|
+
// flowlint-next-line unclear-type:off
|
|
73
|
+
onChange({
|
|
74
|
+
date: date
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
} else {
|
|
78
|
+
onChange({
|
|
79
|
+
date: date
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
var onRangeChange = _this.props.onRangeChange;
|
|
85
|
+
|
|
86
|
+
if (onRangeChange) {
|
|
87
|
+
onRangeChange({
|
|
88
|
+
date: date
|
|
89
|
+
});
|
|
69
90
|
}
|
|
70
91
|
});
|
|
71
92
|
|
|
@@ -33,11 +33,25 @@ class StatefulContainer<T = Date> extends React.Component<PropsT<T>, ContainerSt
|
|
|
33
33
|
this.state = { value, ...props.initialState };
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
onChange: ({ date: ?T | Array
|
|
36
|
+
onChange: ({ +date: ?T | Array<?T> }) => mixed = (data) => {
|
|
37
37
|
const { date } = data;
|
|
38
38
|
this.internalSetState(STATE_CHANGE_TYPE.change, { value: date });
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
|
|
40
|
+
const onChange = this.props.onChange;
|
|
41
|
+
if (onChange) {
|
|
42
|
+
if (Array.isArray(date)) {
|
|
43
|
+
if (date.every(Boolean)) {
|
|
44
|
+
// flowlint-next-line unclear-type:off
|
|
45
|
+
onChange({ date: ((date: any): Array<T>) });
|
|
46
|
+
}
|
|
47
|
+
} else {
|
|
48
|
+
onChange({ date });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const onRangeChange = this.props.onRangeChange;
|
|
53
|
+
if (onRangeChange) {
|
|
54
|
+
onRangeChange({ date });
|
|
41
55
|
}
|
|
42
56
|
};
|
|
43
57
|
|
|
@@ -19,6 +19,8 @@ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return
|
|
|
19
19
|
|
|
20
20
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
21
|
|
|
22
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
23
|
+
|
|
22
24
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
23
25
|
|
|
24
26
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
@@ -56,7 +58,10 @@ var StatefulComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
56
58
|
key: "render",
|
|
57
59
|
value: function render() {
|
|
58
60
|
return /*#__PURE__*/React.createElement(_statefulContainer.default, this.props, function (extendedProps) {
|
|
59
|
-
return /*#__PURE__*/React.createElement(_datepicker.default, extendedProps
|
|
61
|
+
return /*#__PURE__*/React.createElement(_datepicker.default, _extends({}, extendedProps, {
|
|
62
|
+
// flowlint-next-line unclear-type:off
|
|
63
|
+
onChange: extendedProps.onChange
|
|
64
|
+
}));
|
|
60
65
|
});
|
|
61
66
|
}
|
|
62
67
|
}]);
|
|
@@ -21,7 +21,13 @@ class StatefulComponent<T = Date> extends React.Component<PropsT<T>> {
|
|
|
21
21
|
render() {
|
|
22
22
|
return (
|
|
23
23
|
<StatefulContainer {...this.props}>
|
|
24
|
-
{(extendedProps) =>
|
|
24
|
+
{(extendedProps) => (
|
|
25
|
+
<Datepicker
|
|
26
|
+
{...extendedProps}
|
|
27
|
+
// flowlint-next-line unclear-type:off
|
|
28
|
+
onChange={(extendedProps.onChange: any)}
|
|
29
|
+
/>
|
|
30
|
+
)}
|
|
25
31
|
</StatefulContainer>
|
|
26
32
|
);
|
|
27
33
|
}
|
|
@@ -13,6 +13,18 @@ var _constants = require("./constants.js");
|
|
|
13
13
|
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
|
|
16
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
17
|
+
|
|
18
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
19
|
+
|
|
20
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
21
|
+
|
|
22
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
23
|
+
|
|
24
|
+
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
25
|
+
|
|
26
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
27
|
+
|
|
16
28
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
17
29
|
|
|
18
30
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
@@ -448,6 +460,9 @@ var StyledDay = (0, _index.styled)('div', function (props) {
|
|
|
448
460
|
$outsideMonthWithinRange = props.$outsideMonthWithinRange,
|
|
449
461
|
$hasDateLabel = props.$hasDateLabel,
|
|
450
462
|
$density = props.$density,
|
|
463
|
+
$hasLockedBehavior = props.$hasLockedBehavior,
|
|
464
|
+
$selectedInput = props.$selectedInput,
|
|
465
|
+
$value = props.$value,
|
|
451
466
|
_props$$theme4 = props.$theme,
|
|
452
467
|
colors = _props$$theme4.colors,
|
|
453
468
|
typography = _props$$theme4.typography,
|
|
@@ -469,6 +484,13 @@ var StyledDay = (0, _index.styled)('div', function (props) {
|
|
|
469
484
|
}
|
|
470
485
|
}
|
|
471
486
|
|
|
487
|
+
var _ref9 = Array.isArray($value) ? $value : [$value, null],
|
|
488
|
+
_ref10 = _slicedToArray(_ref9, 2),
|
|
489
|
+
startDate = _ref10[0],
|
|
490
|
+
endDate = _ref10[1];
|
|
491
|
+
|
|
492
|
+
var oppositeInputIsPopulated = $selectedInput === _constants.INPUT_ROLE.startDate ? endDate !== null && typeof endDate !== 'undefined' : startDate !== null && typeof startDate !== 'undefined';
|
|
493
|
+
var shouldHighlightRange = $range && !($hasLockedBehavior && !oppositeInputIsPopulated);
|
|
472
494
|
return _objectSpread(_objectSpread(_objectSpread({}, $density === _constants.DENSITY.high ? typography.ParagraphSmall : typography.ParagraphMedium), {}, {
|
|
473
495
|
boxSizing: 'border-box',
|
|
474
496
|
position: 'relative',
|
|
@@ -530,7 +552,7 @@ var StyledDay = (0, _index.styled)('div', function (props) {
|
|
|
530
552
|
}, getDayStyles(code, props.$theme)[':after'] || {}), $outsideMonthWithinRange ? {
|
|
531
553
|
content: null
|
|
532
554
|
} : {})
|
|
533
|
-
},
|
|
555
|
+
}, shouldHighlightRange ? {
|
|
534
556
|
// :before pseudo element defines a grey background style that extends
|
|
535
557
|
// the selected/highlighted day's circle and spans through a range
|
|
536
558
|
':before': _objectSpread(_objectSpread({
|
|
@@ -8,7 +8,7 @@ LICENSE file in the root directory of this source tree.
|
|
|
8
8
|
import { styled } from '../styles/index.js';
|
|
9
9
|
import getDayStateCode from './utils/day-state.js';
|
|
10
10
|
import type { SharedStylePropsT, CalendarPropsT } from './types.js';
|
|
11
|
-
import { ORIENTATION, DENSITY } from './constants.js';
|
|
11
|
+
import { ORIENTATION, DENSITY, INPUT_ROLE } from './constants.js';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Main component container element
|
|
@@ -408,6 +408,9 @@ export const StyledDay = styled<SharedStylePropsT>('div', (props) => {
|
|
|
408
408
|
$outsideMonthWithinRange,
|
|
409
409
|
$hasDateLabel,
|
|
410
410
|
$density,
|
|
411
|
+
$hasLockedBehavior,
|
|
412
|
+
$selectedInput,
|
|
413
|
+
$value,
|
|
411
414
|
$theme: { colors, typography, sizing },
|
|
412
415
|
} = props;
|
|
413
416
|
const code = getDayStateCode(props);
|
|
@@ -427,6 +430,13 @@ export const StyledDay = styled<SharedStylePropsT>('div', (props) => {
|
|
|
427
430
|
}
|
|
428
431
|
}
|
|
429
432
|
|
|
433
|
+
const [startDate, endDate] = Array.isArray($value) ? $value : [$value, null];
|
|
434
|
+
const oppositeInputIsPopulated =
|
|
435
|
+
$selectedInput === INPUT_ROLE.startDate
|
|
436
|
+
? endDate !== null && typeof endDate !== 'undefined'
|
|
437
|
+
: startDate !== null && typeof startDate !== 'undefined';
|
|
438
|
+
const shouldHighlightRange = $range && !($hasLockedBehavior && !oppositeInputIsPopulated);
|
|
439
|
+
|
|
430
440
|
return ({
|
|
431
441
|
...($density === DENSITY.high ? typography.ParagraphSmall : typography.ParagraphMedium),
|
|
432
442
|
boxSizing: 'border-box',
|
|
@@ -496,7 +506,7 @@ export const StyledDay = styled<SharedStylePropsT>('div', (props) => {
|
|
|
496
506
|
...(getDayStyles(code, props.$theme)[':after'] || {}),
|
|
497
507
|
...($outsideMonthWithinRange ? { content: null } : {}),
|
|
498
508
|
},
|
|
499
|
-
...(
|
|
509
|
+
...(shouldHighlightRange
|
|
500
510
|
? {
|
|
501
511
|
// :before pseudo element defines a grey background style that extends
|
|
502
512
|
// the selected/highlighted day's circle and spans through a range
|