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
|
@@ -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,28 +39,69 @@ 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
|
|
|
45
46
|
_defineProperty(this, "dateHelpers", void 0);
|
|
46
47
|
|
|
47
|
-
_defineProperty(this, "
|
|
48
|
+
_defineProperty(this, "handleChange", date => {
|
|
49
|
+
const onChange = this.props.onChange;
|
|
50
|
+
const onRangeChange = this.props.onRangeChange;
|
|
51
|
+
|
|
52
|
+
if (Array.isArray(date)) {
|
|
53
|
+
if (onChange && date.every(Boolean)) {
|
|
54
|
+
// flowlint-next-line unclear-type:off
|
|
55
|
+
onChange({
|
|
56
|
+
date: date
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (onRangeChange) {
|
|
61
|
+
onRangeChange({
|
|
62
|
+
date: [...date]
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
} else {
|
|
66
|
+
if (onChange) {
|
|
67
|
+
onChange({
|
|
68
|
+
date
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (onRangeChange) {
|
|
73
|
+
onRangeChange({
|
|
74
|
+
date
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
_defineProperty(this, "onCalendarSelect", data => {
|
|
48
81
|
let isOpen = false;
|
|
49
82
|
let isPseudoFocused = false;
|
|
50
83
|
let calendarFocused = false;
|
|
51
84
|
let nextDate = data.date;
|
|
52
85
|
|
|
53
86
|
if (Array.isArray(nextDate) && this.props.range) {
|
|
54
|
-
if (nextDate
|
|
87
|
+
if (!nextDate[0] || !nextDate[1]) {
|
|
55
88
|
isOpen = true;
|
|
56
89
|
isPseudoFocused = true;
|
|
57
90
|
calendarFocused = null;
|
|
58
|
-
} else if (nextDate
|
|
91
|
+
} else if (nextDate[0] && nextDate[1]) {
|
|
59
92
|
const [start, end] = nextDate;
|
|
60
93
|
|
|
61
94
|
if (this.dateHelpers.isAfter(start, end)) {
|
|
62
|
-
|
|
95
|
+
if (this.hasLockedBehavior()) {
|
|
96
|
+
nextDate = this.props.value;
|
|
97
|
+
isOpen = true;
|
|
98
|
+
} else {
|
|
99
|
+
nextDate = [start, start];
|
|
100
|
+
}
|
|
101
|
+
} 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]
|
|
102
|
+
nextDate, this.props.excludeDates)) {
|
|
103
|
+
nextDate = this.props.value;
|
|
104
|
+
isOpen = true;
|
|
63
105
|
}
|
|
64
106
|
|
|
65
107
|
if (this.state.lastActiveElm) {
|
|
@@ -104,9 +146,7 @@ export default class Datepicker extends React.Component {
|
|
|
104
146
|
}),
|
|
105
147
|
inputValue: this.formatDisplayValue(nextDate)
|
|
106
148
|
});
|
|
107
|
-
this.
|
|
108
|
-
date: nextDate
|
|
109
|
-
});
|
|
149
|
+
this.handleChange(nextDate);
|
|
110
150
|
});
|
|
111
151
|
|
|
112
152
|
_defineProperty(this, "formatDisplayValue", date => {
|
|
@@ -146,11 +186,12 @@ export default class Datepicker extends React.Component {
|
|
|
146
186
|
return this.formatDate(date, formatString);
|
|
147
187
|
});
|
|
148
188
|
|
|
149
|
-
_defineProperty(this, "open",
|
|
189
|
+
_defineProperty(this, "open", inputRole => {
|
|
150
190
|
this.setState({
|
|
151
191
|
isOpen: true,
|
|
152
192
|
isPseudoFocused: true,
|
|
153
|
-
calendarFocused: false
|
|
193
|
+
calendarFocused: false,
|
|
194
|
+
selectedInput: inputRole
|
|
154
195
|
}, this.props.onOpen);
|
|
155
196
|
});
|
|
156
197
|
|
|
@@ -158,6 +199,7 @@ export default class Datepicker extends React.Component {
|
|
|
158
199
|
const isPseudoFocused = false;
|
|
159
200
|
this.setState({
|
|
160
201
|
isOpen: false,
|
|
202
|
+
selectedInput: null,
|
|
161
203
|
isPseudoFocused,
|
|
162
204
|
calendarFocused: false
|
|
163
205
|
}, this.props.onClose);
|
|
@@ -194,28 +236,22 @@ export default class Datepicker extends React.Component {
|
|
|
194
236
|
}
|
|
195
237
|
|
|
196
238
|
if (range && !separateRangeInputs) {
|
|
197
|
-
return
|
|
239
|
+
return `9999/99/99 ${INPUT_DELIMITER} 9999/99/99`;
|
|
198
240
|
}
|
|
199
241
|
|
|
200
242
|
return '9999/99/99';
|
|
201
243
|
});
|
|
202
244
|
|
|
203
|
-
_defineProperty(this, "handleInputChange", (event,
|
|
204
|
-
const inputValue = this.props.range && this.props.separateRangeInputs ? combineSeparatedInputs(event.currentTarget.value, this.state.inputValue,
|
|
245
|
+
_defineProperty(this, "handleInputChange", (event, inputRole) => {
|
|
246
|
+
const inputValue = this.props.range && this.props.separateRangeInputs ? combineSeparatedInputs(event.currentTarget.value, this.state.inputValue, inputRole) : event.currentTarget.value;
|
|
205
247
|
const mask = this.getMask();
|
|
206
248
|
const formatString = this.normalizeDashes(this.props.formatString);
|
|
207
249
|
|
|
208
250
|
if (typeof mask === 'string' && inputValue === mask.replace(/9/g, ' ') || inputValue.length === 0) {
|
|
209
|
-
if (this.props.
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
});
|
|
214
|
-
} else {
|
|
215
|
-
this.props.onChange({
|
|
216
|
-
date: null
|
|
217
|
-
});
|
|
218
|
-
}
|
|
251
|
+
if (this.props.range) {
|
|
252
|
+
this.handleChange([]);
|
|
253
|
+
} else {
|
|
254
|
+
this.handleChange(null);
|
|
219
255
|
}
|
|
220
256
|
}
|
|
221
257
|
|
|
@@ -232,7 +268,7 @@ export default class Datepicker extends React.Component {
|
|
|
232
268
|
};
|
|
233
269
|
|
|
234
270
|
if (this.props.range && typeof this.props.displayValueAtRangeIndex !== 'number') {
|
|
235
|
-
const [left, right] = this.normalizeDashes(inputValue).split(INPUT_DELIMITER);
|
|
271
|
+
const [left, right] = this.normalizeDashes(inputValue).split(` ${INPUT_DELIMITER} `);
|
|
236
272
|
let startDate = this.dateHelpers.date(left);
|
|
237
273
|
let endDate = this.dateHelpers.date(right);
|
|
238
274
|
|
|
@@ -241,18 +277,12 @@ export default class Datepicker extends React.Component {
|
|
|
241
277
|
endDate = parseDateString(right);
|
|
242
278
|
}
|
|
243
279
|
|
|
244
|
-
const
|
|
280
|
+
const datesValid = this.dateHelpers.isValid(startDate) && this.dateHelpers.isValid(endDate); // added equal case so that times within the same day can be expressed
|
|
245
281
|
|
|
246
|
-
|
|
247
|
-
const datesValid = this.dateHelpers.isValid(startDate) && this.dateHelpers.isValid(endDate); // added equal case so that times within the same day can be expressed
|
|
248
|
-
|
|
249
|
-
const rangeValid = this.dateHelpers.isAfter(endDate, startDate) || this.dateHelpers.isEqual(startDate, endDate);
|
|
282
|
+
const rangeValid = this.dateHelpers.isAfter(endDate, startDate) || this.dateHelpers.isEqual(startDate, endDate);
|
|
250
283
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
date: [startDate, endDate]
|
|
254
|
-
});
|
|
255
|
-
}
|
|
284
|
+
if (datesValid && rangeValid) {
|
|
285
|
+
this.handleChange([startDate, endDate]);
|
|
256
286
|
}
|
|
257
287
|
} else {
|
|
258
288
|
const dateString = this.normalizeDashes(inputValue);
|
|
@@ -268,12 +298,11 @@ export default class Datepicker extends React.Component {
|
|
|
268
298
|
|
|
269
299
|
const {
|
|
270
300
|
displayValueAtRangeIndex,
|
|
271
|
-
onChange,
|
|
272
301
|
range,
|
|
273
302
|
value
|
|
274
303
|
} = this.props;
|
|
275
304
|
|
|
276
|
-
if (date && this.dateHelpers.isValid(date)
|
|
305
|
+
if (date && this.dateHelpers.isValid(date)) {
|
|
277
306
|
if (range && Array.isArray(value) && typeof displayValueAtRangeIndex === 'number') {
|
|
278
307
|
let [left, right] = value;
|
|
279
308
|
|
|
@@ -281,22 +310,16 @@ export default class Datepicker extends React.Component {
|
|
|
281
310
|
left = date;
|
|
282
311
|
|
|
283
312
|
if (!right) {
|
|
284
|
-
|
|
285
|
-
date: [left]
|
|
286
|
-
});
|
|
313
|
+
this.handleChange([left]);
|
|
287
314
|
} else {
|
|
288
315
|
if (this.dateHelpers.isAfter(right, left) || this.dateHelpers.isEqual(left, right)) {
|
|
289
|
-
|
|
290
|
-
date: [left, right]
|
|
291
|
-
});
|
|
316
|
+
this.handleChange([left, right]);
|
|
292
317
|
} else {
|
|
293
318
|
// Is resetting back to previous value appropriate? Invalid range is not
|
|
294
319
|
// communicated to the user, but if it was not reset the text value would
|
|
295
320
|
// show one value and date value another. This seems a bit better but clearly
|
|
296
321
|
// has a downside.
|
|
297
|
-
|
|
298
|
-
date: [...value]
|
|
299
|
-
});
|
|
322
|
+
this.handleChange([...value]);
|
|
300
323
|
}
|
|
301
324
|
}
|
|
302
325
|
} else if (displayValueAtRangeIndex === 1) {
|
|
@@ -304,26 +327,18 @@ export default class Datepicker extends React.Component {
|
|
|
304
327
|
|
|
305
328
|
if (!left) {
|
|
306
329
|
// If start value is not defined, set start/end to the same day.
|
|
307
|
-
|
|
308
|
-
date: [right, right]
|
|
309
|
-
});
|
|
330
|
+
this.handleChange([right, right]);
|
|
310
331
|
} else {
|
|
311
332
|
if (this.dateHelpers.isAfter(right, left) || this.dateHelpers.isEqual(left, right)) {
|
|
312
|
-
|
|
313
|
-
date: [left, right]
|
|
314
|
-
});
|
|
333
|
+
this.handleChange([left, right]);
|
|
315
334
|
} else {
|
|
316
335
|
// See comment above about resetting dates on invalid range
|
|
317
|
-
|
|
318
|
-
date: [...value]
|
|
319
|
-
});
|
|
336
|
+
this.handleChange([...value]);
|
|
320
337
|
}
|
|
321
338
|
}
|
|
322
339
|
}
|
|
323
340
|
} else {
|
|
324
|
-
|
|
325
|
-
date
|
|
326
|
-
});
|
|
341
|
+
this.handleChange(date);
|
|
327
342
|
}
|
|
328
343
|
}
|
|
329
344
|
}
|
|
@@ -353,19 +368,28 @@ export default class Datepicker extends React.Component {
|
|
|
353
368
|
|
|
354
369
|
_defineProperty(this, "normalizeDashes", inputValue => {
|
|
355
370
|
// replacing both hyphens and em-dashes with en-dashes
|
|
356
|
-
return inputValue.replace(/-/g,
|
|
371
|
+
return inputValue.replace(/-/g, INPUT_DELIMITER).replace(/—/g, INPUT_DELIMITER);
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
_defineProperty(this, "hasLockedBehavior", () => {
|
|
375
|
+
return this.props.rangedCalendarBehavior === RANGED_CALENDAR_BEHAVIOR.locked && this.props.range && this.props.separateRangeInputs;
|
|
357
376
|
});
|
|
358
377
|
|
|
359
378
|
this.dateHelpers = new DateHelpers(props.adapter);
|
|
360
379
|
this.state = {
|
|
361
380
|
calendarFocused: false,
|
|
362
381
|
isOpen: false,
|
|
382
|
+
selectedInput: null,
|
|
363
383
|
isPseudoFocused: false,
|
|
364
384
|
lastActiveElm: null,
|
|
365
385
|
inputValue: this.formatDisplayValue(props.value) || ''
|
|
366
386
|
};
|
|
367
387
|
}
|
|
368
388
|
|
|
389
|
+
getNullDatePlaceholder(formatString) {
|
|
390
|
+
return (this.getMask() || formatString).split(INPUT_DELIMITER)[0].replace(/[0-9]|[a-z]/g, ' ');
|
|
391
|
+
}
|
|
392
|
+
|
|
369
393
|
formatDate(date, formatString) {
|
|
370
394
|
const format = date => {
|
|
371
395
|
if (formatString === DEFAULT_DATE_FORMAT) {
|
|
@@ -379,8 +403,12 @@ export default class Datepicker extends React.Component {
|
|
|
379
403
|
return '';
|
|
380
404
|
} else if (Array.isArray(date) && !date[0] && !date[1]) {
|
|
381
405
|
return '';
|
|
406
|
+
} else if (Array.isArray(date) && !date[0] && date[1]) {
|
|
407
|
+
const endDate = format(date[1]);
|
|
408
|
+
const startDate = this.getNullDatePlaceholder(formatString);
|
|
409
|
+
return [startDate, endDate].join(` ${INPUT_DELIMITER} `);
|
|
382
410
|
} else if (Array.isArray(date)) {
|
|
383
|
-
return date.map(day => format(day)).join(INPUT_DELIMITER);
|
|
411
|
+
return date.map(day => day ? format(day) : '').join(` ${INPUT_DELIMITER} `);
|
|
384
412
|
} else {
|
|
385
413
|
return format(date);
|
|
386
414
|
}
|
|
@@ -394,17 +422,14 @@ export default class Datepicker extends React.Component {
|
|
|
394
422
|
}
|
|
395
423
|
}
|
|
396
424
|
|
|
397
|
-
renderInputComponent(locale,
|
|
425
|
+
renderInputComponent(locale, inputRole) {
|
|
398
426
|
const {
|
|
399
427
|
overrides = {}
|
|
400
428
|
} = this.props;
|
|
401
429
|
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 =
|
|
405
|
-
|
|
406
|
-
const onChange = event => this.handleInputChange(event, separatedInput);
|
|
407
|
-
|
|
430
|
+
const placeholder = this.props.placeholder || this.props.placeholder === '' ? this.props.placeholder : this.props.range && !this.props.separateRangeInputs ? `YYYY/MM/DD ${INPUT_DELIMITER} YYYY/MM/DD` : 'YYYY/MM/DD';
|
|
431
|
+
const [startDate = '', endDate = ''] = (this.state.inputValue || '').split(` ${INPUT_DELIMITER} `);
|
|
432
|
+
const value = inputRole === INPUT_ROLE.startDate ? startDate : inputRole === INPUT_ROLE.endDate ? endDate : this.state.inputValue;
|
|
408
433
|
return /*#__PURE__*/React.createElement(InputComponent, _extends({
|
|
409
434
|
"aria-disabled": this.props.disabled,
|
|
410
435
|
"aria-label": this.props['aria-label'] || (this.props.range ? locale.datepicker.ariaLabelRange : locale.datepicker.ariaLabel),
|
|
@@ -416,10 +441,10 @@ 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
|
-
onChange:
|
|
447
|
+
onChange: event => this.handleInputChange(event, inputRole),
|
|
423
448
|
placeholder: placeholder,
|
|
424
449
|
mask: this.getMask(),
|
|
425
450
|
required: this.props.required,
|
|
@@ -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.
|
|
480
|
+
onChange: this.onCalendarSelect,
|
|
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])
|
package/es/datepicker/day.js
CHANGED
|
@@ -15,6 +15,7 @@ import DateHelpers from './utils/date-helpers.js';
|
|
|
15
15
|
import { getOverrides } from '../helpers/overrides.js';
|
|
16
16
|
import { LocaleContext } from '../locale/index.js';
|
|
17
17
|
import { isFocusVisible } from '../utils/focusVisible.js';
|
|
18
|
+
import { INPUT_ROLE } from './constants.js';
|
|
18
19
|
export default class Day extends React.Component {
|
|
19
20
|
constructor(props) {
|
|
20
21
|
super(props);
|
|
@@ -41,22 +42,46 @@ export default class Day extends React.Component {
|
|
|
41
42
|
range,
|
|
42
43
|
value
|
|
43
44
|
} = this.props;
|
|
44
|
-
let
|
|
45
|
+
let nextDate;
|
|
46
|
+
|
|
47
|
+
if (Array.isArray(value) && range && this.props.hasLockedBehavior) {
|
|
48
|
+
const currentDate = this.props.value;
|
|
49
|
+
let nextStartDate = null;
|
|
50
|
+
let nextEndDate = null;
|
|
51
|
+
|
|
52
|
+
if (this.props.selectedInput === INPUT_ROLE.startDate) {
|
|
53
|
+
nextStartDate = selectedDate;
|
|
54
|
+
nextEndDate = Array.isArray(currentDate) && currentDate[1] ? currentDate[1] : null;
|
|
55
|
+
} else if (this.props.selectedInput === INPUT_ROLE.endDate) {
|
|
56
|
+
nextStartDate = Array.isArray(currentDate) && currentDate[0] ? currentDate[0] : null;
|
|
57
|
+
nextEndDate = selectedDate;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
nextDate = [nextStartDate];
|
|
45
61
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
62
|
+
if (nextEndDate) {
|
|
63
|
+
nextDate.push(nextEndDate);
|
|
64
|
+
}
|
|
65
|
+
} else if (Array.isArray(value) && range && !this.props.hasLockedBehavior) {
|
|
66
|
+
const [start, end] = value; // Starting a new range
|
|
67
|
+
|
|
68
|
+
if (!start && !end || start && end) {
|
|
69
|
+
nextDate = [selectedDate, null]; // EndDate needs a StartDate, SelectedDate comes before EndDate
|
|
70
|
+
} else if (!start && end && this.dateHelpers.isAfter(end, selectedDate)) {
|
|
71
|
+
nextDate = [selectedDate, end]; // EndDate needs a StartDate, but SelectedDate comes after EndDate
|
|
72
|
+
} else if (!start && end && this.dateHelpers.isAfter(selectedDate, end)) {
|
|
73
|
+
nextDate = [end, selectedDate]; // StartDate needs an EndDate, SelectedDate comes after StartDate
|
|
74
|
+
} else if (start && !end && this.dateHelpers.isAfter(selectedDate, start)) {
|
|
75
|
+
nextDate = [start, selectedDate];
|
|
51
76
|
} else {
|
|
52
|
-
|
|
77
|
+
nextDate = [selectedDate, start];
|
|
53
78
|
}
|
|
54
79
|
} else {
|
|
55
|
-
|
|
80
|
+
nextDate = selectedDate;
|
|
56
81
|
}
|
|
57
82
|
|
|
58
83
|
this.props.onSelect({
|
|
59
|
-
date
|
|
84
|
+
date: nextDate
|
|
60
85
|
});
|
|
61
86
|
});
|
|
62
87
|
|
|
@@ -233,13 +258,16 @@ export default class Day extends React.Component {
|
|
|
233
258
|
value
|
|
234
259
|
} = this.props;
|
|
235
260
|
|
|
236
|
-
if (Array.isArray(value)
|
|
237
|
-
|
|
238
|
-
} // fix flow by passing a specific arg type and remove 'Array.isArray(value)'
|
|
261
|
+
if (Array.isArray(value)) {
|
|
262
|
+
const [start, end] = value;
|
|
239
263
|
|
|
264
|
+
if (!start && !end) {
|
|
265
|
+
return false;
|
|
266
|
+
}
|
|
240
267
|
|
|
241
|
-
|
|
242
|
-
|
|
268
|
+
if (start && end) {
|
|
269
|
+
return this.dateHelpers.isDayInRange(this.clampToDayStart(date), this.clampToDayStart(start), this.clampToDayStart(end));
|
|
270
|
+
}
|
|
243
271
|
}
|
|
244
272
|
} // calculated for range case only
|
|
245
273
|
|
|
@@ -251,16 +279,27 @@ export default class Day extends React.Component {
|
|
|
251
279
|
highlightedDate
|
|
252
280
|
} = this.props;
|
|
253
281
|
|
|
254
|
-
if (Array.isArray(value)
|
|
255
|
-
|
|
256
|
-
} // fix flow by passing a specific arg type and remove 'Array.isArray(value)'
|
|
282
|
+
if (Array.isArray(value)) {
|
|
283
|
+
const [start, end] = value;
|
|
257
284
|
|
|
285
|
+
if (!start && !end) {
|
|
286
|
+
return false;
|
|
287
|
+
}
|
|
258
288
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
289
|
+
if (highlightedDate && start && !end) {
|
|
290
|
+
if (this.dateHelpers.isAfter(highlightedDate, start)) {
|
|
291
|
+
return this.dateHelpers.isDayInRange(this.clampToDayStart(date), this.clampToDayStart(start), this.clampToDayStart(highlightedDate));
|
|
292
|
+
} else {
|
|
293
|
+
return this.dateHelpers.isDayInRange(this.clampToDayStart(date), this.clampToDayStart(highlightedDate), this.clampToDayStart(start));
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
if (highlightedDate && !start && end) {
|
|
298
|
+
if (this.dateHelpers.isAfter(highlightedDate, end)) {
|
|
299
|
+
return this.dateHelpers.isDayInRange(this.clampToDayStart(date), this.clampToDayStart(end), this.clampToDayStart(highlightedDate));
|
|
300
|
+
} else {
|
|
301
|
+
return this.dateHelpers.isDayInRange(this.clampToDayStart(date), this.clampToDayStart(highlightedDate), this.clampToDayStart(end));
|
|
302
|
+
}
|
|
264
303
|
}
|
|
265
304
|
}
|
|
266
305
|
}
|
|
@@ -271,22 +310,23 @@ export default class Day extends React.Component {
|
|
|
271
310
|
value,
|
|
272
311
|
highlightedDate,
|
|
273
312
|
range,
|
|
274
|
-
highlighted
|
|
313
|
+
highlighted,
|
|
314
|
+
peekNextMonth
|
|
275
315
|
} = this.props;
|
|
276
316
|
const $isHighlighted = highlighted;
|
|
277
317
|
const $selected = this.isSelected();
|
|
278
|
-
const $hasRangeHighlighted = !!(Array.isArray(value) && range && value
|
|
279
|
-
const $outsideMonth = !
|
|
280
|
-
const $outsideMonthWithinRange = !!(Array.isArray(value) && range && $outsideMonth && !
|
|
318
|
+
const $hasRangeHighlighted = !!(Array.isArray(value) && range && highlightedDate && (value[0] && !value[1] && !this.dateHelpers.isSameDay(value[0], highlightedDate) || !value[0] && value[1] && !this.dateHelpers.isSameDay(value[1], highlightedDate)));
|
|
319
|
+
const $outsideMonth = !peekNextMonth && this.isOutsideMonth();
|
|
320
|
+
const $outsideMonthWithinRange = !!(Array.isArray(value) && range && $outsideMonth && !peekNextMonth && this.isOutsideOfMonthButWithinRange());
|
|
281
321
|
return {
|
|
282
322
|
$date: date,
|
|
283
323
|
$density: this.props.density,
|
|
284
324
|
$disabled: this.props.disabled,
|
|
285
|
-
$endDate: Array.isArray(value) &&
|
|
325
|
+
$endDate: Array.isArray(value) && !!(value[0] && value[1]) && range && $selected && this.dateHelpers.isSameDay(date, value[1]) || false,
|
|
286
326
|
$hasDateLabel: !!this.props.dateLabel,
|
|
287
327
|
$hasRangeHighlighted,
|
|
288
|
-
$hasRangeOnRight: Array.isArray(value) && $hasRangeHighlighted && highlightedDate && value[0] && this.dateHelpers.isAfter(highlightedDate, value[0]),
|
|
289
|
-
$hasRangeSelected: Array.isArray(value) ? value
|
|
328
|
+
$hasRangeOnRight: Array.isArray(value) && $hasRangeHighlighted && highlightedDate && (value[0] && this.dateHelpers.isAfter(highlightedDate, value[0]) || value[1] && this.dateHelpers.isAfter(highlightedDate, value[1])),
|
|
329
|
+
$hasRangeSelected: Array.isArray(value) ? !!(value[0] && value[1]) : false,
|
|
290
330
|
$highlightedDate: highlightedDate,
|
|
291
331
|
$isHighlighted,
|
|
292
332
|
$isHovered: this.state.isHovered,
|
|
@@ -296,12 +336,15 @@ export default class Day extends React.Component {
|
|
|
296
336
|
$month: this.getMonthProp(),
|
|
297
337
|
$outsideMonth,
|
|
298
338
|
$outsideMonthWithinRange,
|
|
299
|
-
$peekNextMonth:
|
|
300
|
-
$pseudoHighlighted:
|
|
301
|
-
$pseudoSelected:
|
|
302
|
-
$range:
|
|
339
|
+
$peekNextMonth: peekNextMonth,
|
|
340
|
+
$pseudoHighlighted: range && !$isHighlighted && !$selected ? this.isPseudoHighlighted() : false,
|
|
341
|
+
$pseudoSelected: range && !$selected ? this.isPseudoSelected() : false,
|
|
342
|
+
$range: range,
|
|
303
343
|
$selected,
|
|
304
|
-
$startDate: Array.isArray(
|
|
344
|
+
$startDate: Array.isArray(value) && value[0] && value[1] && range && $selected ? this.dateHelpers.isSameDay(date, value[0]) : false,
|
|
345
|
+
$hasLockedBehavior: this.props.hasLockedBehavior,
|
|
346
|
+
$selectedInput: this.props.selectedInput,
|
|
347
|
+
$value: this.props.value
|
|
305
348
|
};
|
|
306
349
|
}
|
|
307
350
|
|
package/es/datepicker/month.js
CHANGED
|
@@ -82,7 +82,9 @@ export default class CalendarMonth extends React.Component {
|
|
|
82
82
|
onChange: this.props.onChange,
|
|
83
83
|
overrides: this.props.overrides,
|
|
84
84
|
peekNextMonth: this.props.peekNextMonth,
|
|
85
|
-
value: this.props.value
|
|
85
|
+
value: this.props.value,
|
|
86
|
+
hasLockedBehavior: this.props.hasLockedBehavior,
|
|
87
|
+
selectedInput: this.props.selectedInput
|
|
86
88
|
}));
|
|
87
89
|
i++;
|
|
88
90
|
currentWeekStart = this.dateHelpers.addWeeks(currentWeekStart, 1); // It will break on the next week if the week is out of the month
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
1
3
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
4
|
|
|
3
5
|
/*
|
|
@@ -12,7 +14,10 @@ import Calendar from './calendar.js';
|
|
|
12
14
|
|
|
13
15
|
class StatefulComponent extends React.Component {
|
|
14
16
|
render() {
|
|
15
|
-
return /*#__PURE__*/React.createElement(StatefulContainer, this.props, extendedProps => /*#__PURE__*/React.createElement(Calendar, extendedProps
|
|
17
|
+
return /*#__PURE__*/React.createElement(StatefulContainer, this.props, extendedProps => /*#__PURE__*/React.createElement(Calendar, _extends({}, extendedProps, {
|
|
18
|
+
// flowlint-next-line unclear-type:off
|
|
19
|
+
onChange: extendedProps.onChange
|
|
20
|
+
})));
|
|
16
21
|
}
|
|
17
22
|
|
|
18
23
|
}
|
|
@@ -20,9 +20,29 @@ class StatefulContainer extends React.Component {
|
|
|
20
20
|
this.internalSetState(STATE_CHANGE_TYPE.change, {
|
|
21
21
|
value: date
|
|
22
22
|
});
|
|
23
|
+
const onChange = this.props.onChange;
|
|
23
24
|
|
|
24
|
-
if (
|
|
25
|
-
|
|
25
|
+
if (onChange) {
|
|
26
|
+
if (Array.isArray(date)) {
|
|
27
|
+
if (date.every(Boolean)) {
|
|
28
|
+
// flowlint-next-line unclear-type:off
|
|
29
|
+
onChange({
|
|
30
|
+
date: date
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
} else {
|
|
34
|
+
onChange({
|
|
35
|
+
date
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const onRangeChange = this.props.onRangeChange;
|
|
41
|
+
|
|
42
|
+
if (onRangeChange) {
|
|
43
|
+
onRangeChange({
|
|
44
|
+
date
|
|
45
|
+
});
|
|
26
46
|
}
|
|
27
47
|
});
|
|
28
48
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
1
3
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
4
|
|
|
3
5
|
/*
|
|
@@ -12,7 +14,10 @@ import Datepicker from './datepicker.js';
|
|
|
12
14
|
|
|
13
15
|
class StatefulComponent extends React.Component {
|
|
14
16
|
render() {
|
|
15
|
-
return /*#__PURE__*/React.createElement(StatefulContainer, this.props, extendedProps => /*#__PURE__*/React.createElement(Datepicker, extendedProps
|
|
17
|
+
return /*#__PURE__*/React.createElement(StatefulContainer, this.props, extendedProps => /*#__PURE__*/React.createElement(Datepicker, _extends({}, extendedProps, {
|
|
18
|
+
// flowlint-next-line unclear-type:off
|
|
19
|
+
onChange: extendedProps.onChange
|
|
20
|
+
})));
|
|
16
21
|
}
|
|
17
22
|
|
|
18
23
|
}
|