@jetbrains/ring-ui 7.0.114 → 7.0.115
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.
|
@@ -97,8 +97,16 @@ export default class DatePicker extends PureComponent {
|
|
|
97
97
|
static contextType = I18nContext;
|
|
98
98
|
handleChange = (change) => {
|
|
99
99
|
const { onChange, withTime, applyTimeInput } = this.props;
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
if (withTime && !(change instanceof Date) && change && 'date' in change && 'time' in change) {
|
|
101
|
+
const { date, time } = change;
|
|
102
|
+
if (date) {
|
|
103
|
+
const dateWithTime = applyTimeInput(date, time);
|
|
104
|
+
onChange(dateWithTime);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
onChange(change);
|
|
109
|
+
}
|
|
102
110
|
};
|
|
103
111
|
clear = () => {
|
|
104
112
|
let change = null;
|
|
@@ -116,14 +124,18 @@ export default class DatePicker extends PureComponent {
|
|
|
116
124
|
this.popup?._onCloseAttempt();
|
|
117
125
|
};
|
|
118
126
|
parse = memoize((date) => {
|
|
119
|
-
|
|
127
|
+
let normalizedDate;
|
|
120
128
|
if (date instanceof Date) {
|
|
121
|
-
|
|
129
|
+
normalizedDate = date;
|
|
130
|
+
}
|
|
131
|
+
else if (typeof date === 'number') {
|
|
132
|
+
normalizedDate = new Date(date);
|
|
122
133
|
}
|
|
123
|
-
|
|
124
|
-
|
|
134
|
+
else {
|
|
135
|
+
const { parseDateInput } = this.props;
|
|
136
|
+
normalizedDate = parseDateInput(date);
|
|
125
137
|
}
|
|
126
|
-
return
|
|
138
|
+
return normalizedDate && isValid(normalizedDate) ? normalizedDate : null;
|
|
127
139
|
});
|
|
128
140
|
formatTime() {
|
|
129
141
|
const { displayTimeFormat, locale } = this.props;
|