@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
- const adjustedChange = withTime && !(change instanceof Date) && change?.date ? applyTimeInput(change.date, change.time) : change;
101
- onChange(adjustedChange);
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
- const { parseDateInput } = this.props;
127
+ let normalizedDate;
120
128
  if (date instanceof Date) {
121
- return date;
129
+ normalizedDate = date;
130
+ }
131
+ else if (typeof date === 'number') {
132
+ normalizedDate = new Date(date);
122
133
  }
123
- if (typeof date === 'number') {
124
- return new Date(date);
134
+ else {
135
+ const { parseDateInput } = this.props;
136
+ normalizedDate = parseDateInput(date);
125
137
  }
126
- return parseDateInput(date);
138
+ return normalizedDate && isValid(normalizedDate) ? normalizedDate : null;
127
139
  });
128
140
  formatTime() {
129
141
  const { displayTimeFormat, locale } = this.props;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetbrains/ring-ui",
3
- "version": "7.0.114",
3
+ "version": "7.0.115",
4
4
  "description": "JetBrains UI library",
5
5
  "author": {
6
6
  "name": "JetBrains"