@jetbrains/ring-ui 4.2.17 → 4.2.19

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.
@@ -351,4 +351,3 @@ rangeWithCustomPlaceholders.storyName = 'range with customized placeholders';
351
351
  rangeWithCustomPlaceholders.parameters = {
352
352
  hermione: {skip: true}
353
353
  };
354
-
@@ -206,15 +206,15 @@ export default class DatePicker extends PureComponent {
206
206
 
207
207
  let text;
208
208
  if (!range && !withTime) {
209
- text = date ? displayFormat(date, locale) : datePlaceholder || translations.setDate;
209
+ text = date ? displayFormat(date, locale) : (datePlaceholder ?? translations.setDate);
210
210
  } else if (!range && withTime) {
211
211
  if (!date && !time) {
212
- text = dateTimePlaceholder || translations.setDateTime;
212
+ text = dateTimePlaceholder ?? translations.setDateTime;
213
213
  } else {
214
214
  text = `${date && displayFormat(date, locale) || '—'}, ${time || '—'}`;
215
215
  }
216
216
  } else if (!from && !to) {
217
- text = rangePlaceholder || translations.setPeriod;
217
+ text = rangePlaceholder ?? translations.setPeriod;
218
218
  } else if (!to) {
219
219
  text = `${displayFormat(from, locale)} —`;
220
220
  } else if (!from) {
@@ -3,8 +3,6 @@ import PropTypes from 'prop-types';
3
3
  import addMonths from 'date-fns/addMonths';
4
4
  import getDay from 'date-fns/getDay';
5
5
  import getDaysInMonth from 'date-fns/getDaysInMonth';
6
- import set from 'date-fns/set';
7
- import startOfHour from 'date-fns/startOfHour';
8
6
  import startOfMonth from 'date-fns/startOfMonth';
9
7
  import subMonths from 'date-fns/subMonths';
10
8
  import endOfMonth from 'date-fns/endOfMonth';
@@ -46,8 +44,9 @@ const scrollSchedule = scheduleRAF();
46
44
  let dy = 0;
47
45
  export default function Months(props) {
48
46
  const {scrollDate} = props;
49
- // prevent switching from april to march because of daylight saving time
50
- const monthStart = startOfHour(set(scrollDate, {date: 1, hours: 1}));
47
+ const monthDate = scrollDate instanceof Date ? scrollDate : new Date(scrollDate);
48
+ // Creating midnight of the first day of the month in UTC to prevent the impact of user timezone
49
+ const monthStart = new Date(Date.UTC(monthDate.getFullYear(), monthDate.getMonth(), 1));
51
50
 
52
51
  let month = subMonths(monthStart, MONTHSBACK);
53
52
  const months = [month];
@@ -1013,6 +1013,7 @@ export const multipleWithLimit = args => <Select {...args}/>;
1013
1013
  multipleWithLimit.storyName = 'multiple with limit';
1014
1014
  multipleWithLimit.parameters = {hermione: {skip: true}};
1015
1015
 
1016
+
1016
1017
  export const selectInPopup = args => (
1017
1018
  <Dropdown
1018
1019
  anchor="Open dropdown"
@@ -311,8 +311,8 @@ export default class Select extends Component {
311
311
 
312
312
  selected: null, // current selection (item / array of items)
313
313
 
314
- label: '', // BUTTON or INPUT label (nothing selected)
315
- selectedLabel: '', // BUTTON or INPUT label (something selected)
314
+ label: null, // BUTTON or INPUT label (nothing selected)
315
+ selectedLabel: null, // BUTTON or INPUT label (something selected)
316
316
  inputPlaceholder: '', // Placeholder for input modes
317
317
  hint: null, // hint text to display under the list
318
318
 
@@ -981,7 +981,7 @@ export default class Select extends Component {
981
981
  }
982
982
 
983
983
  _getLabel() {
984
- return this.props.label || this.props.selectedLabel || 'Select an option';
984
+ return this.props.label ?? this.props.selectedLabel ?? 'Select an option';
985
985
  }
986
986
 
987
987
  _getSelectedString() {
@@ -47,7 +47,6 @@ import './months.js';
47
47
  import 'date-fns/addMonths';
48
48
  import 'date-fns/getDay';
49
49
  import 'date-fns/getDaysInMonth';
50
- import 'date-fns/startOfHour';
51
50
  import 'date-fns/startOfMonth';
52
51
  import 'date-fns/subMonths';
53
52
  import 'date-fns/endOfMonth';
@@ -192,15 +191,15 @@ class DatePicker extends PureComponent {
192
191
  let text;
193
192
 
194
193
  if (!range && !withTime) {
195
- text = date ? displayFormat(date, locale) : datePlaceholder || translations.setDate;
194
+ text = date ? displayFormat(date, locale) : datePlaceholder !== null && datePlaceholder !== void 0 ? datePlaceholder : translations.setDate;
196
195
  } else if (!range && withTime) {
197
196
  if (!date && !time) {
198
- text = dateTimePlaceholder || translations.setDateTime;
197
+ text = dateTimePlaceholder !== null && dateTimePlaceholder !== void 0 ? dateTimePlaceholder : translations.setDateTime;
199
198
  } else {
200
199
  text = "".concat(date && displayFormat(date, locale) || '—', ", ").concat(time || '—');
201
200
  }
202
201
  } else if (!from && !to) {
203
- text = rangePlaceholder || translations.setPeriod;
202
+ text = rangePlaceholder !== null && rangePlaceholder !== void 0 ? rangePlaceholder : translations.setPeriod;
204
203
  } else if (!to) {
205
204
  text = "".concat(displayFormat(from, locale), " \u2014");
206
205
  } else if (!from) {
@@ -35,8 +35,6 @@ import 'date-fns/add';
35
35
  import 'date-fns/addMonths';
36
36
  import 'date-fns/getDay';
37
37
  import 'date-fns/getDaysInMonth';
38
- import 'date-fns/set';
39
- import 'date-fns/startOfHour';
40
38
  import 'date-fns/startOfMonth';
41
39
  import 'date-fns/subMonths';
42
40
  import 'date-fns/endOfMonth';
@@ -51,6 +49,7 @@ import 'date-fns/getDate';
51
49
  import 'date-fns/isToday';
52
50
  import './month-names.js';
53
51
  import 'date-fns/isThisMonth';
52
+ import 'date-fns/set';
54
53
  import 'date-fns/startOfYear';
55
54
  import './month-slider.js';
56
55
  import 'date-fns/addYears';
@@ -4,8 +4,6 @@ import PropTypes from 'prop-types';
4
4
  import addMonths from 'date-fns/addMonths';
5
5
  import getDay from 'date-fns/getDay';
6
6
  import getDaysInMonth from 'date-fns/getDaysInMonth';
7
- import set from 'date-fns/set';
8
- import startOfHour from 'date-fns/startOfHour';
9
7
  import startOfMonth from 'date-fns/startOfMonth';
10
8
  import subMonths from 'date-fns/subMonths';
11
9
  import endOfMonth from 'date-fns/endOfMonth';
@@ -28,6 +26,7 @@ import 'date-fns/isSameDay';
28
26
  import 'date-fns/isToday';
29
27
  import 'date-fns/startOfDay';
30
28
  import 'date-fns/isThisMonth';
29
+ import 'date-fns/set';
31
30
  import 'date-fns/startOfYear';
32
31
  import './month-slider.js';
33
32
  import 'date-fns/addYears';
@@ -65,12 +64,10 @@ let dy = 0;
65
64
  function Months(props) {
66
65
  const {
67
66
  scrollDate
68
- } = props; // prevent switching from april to march because of daylight saving time
67
+ } = props;
68
+ const monthDate = scrollDate instanceof Date ? scrollDate : new Date(scrollDate); // Creating midnight of the first day of the month in UTC to prevent the impact of user timezone
69
69
 
70
- const monthStart = startOfHour(set(scrollDate, {
71
- date: 1,
72
- hours: 1
73
- }));
70
+ const monthStart = new Date(Date.UTC(monthDate.getFullYear(), monthDate.getMonth(), 1));
74
71
  let month = subMonths(monthStart, MONTHSBACK);
75
72
  const months = [month];
76
73
 
@@ -980,7 +980,9 @@ class Select extends Component {
980
980
  }
981
981
 
982
982
  _getLabel() {
983
- return this.props.label || this.props.selectedLabel || 'Select an option';
983
+ var _ref2, _this$props$label;
984
+
985
+ return (_ref2 = (_this$props$label = this.props.label) !== null && _this$props$label !== void 0 ? _this$props$label : this.props.selectedLabel) !== null && _ref2 !== void 0 ? _ref2 : 'Select an option';
984
986
  }
985
987
 
986
988
  _getSelectedString() {
@@ -1312,9 +1314,9 @@ _defineProperty(Select, "defaultProps", {
1312
1314
  directions: [Popup.PopupProps.Directions.BOTTOM_RIGHT, Popup.PopupProps.Directions.BOTTOM_LEFT, Popup.PopupProps.Directions.TOP_LEFT, Popup.PopupProps.Directions.TOP_RIGHT],
1313
1315
  selected: null,
1314
1316
  // current selection (item / array of items)
1315
- label: '',
1317
+ label: null,
1316
1318
  // BUTTON or INPUT label (nothing selected)
1317
- selectedLabel: '',
1319
+ selectedLabel: null,
1318
1320
  // BUTTON or INPUT label (something selected)
1319
1321
  inputPlaceholder: '',
1320
1322
  // Placeholder for input modes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetbrains/ring-ui",
3
- "version": "4.2.17",
3
+ "version": "4.2.19",
4
4
  "description": "JetBrains UI library",
5
5
  "author": "JetBrains",
6
6
  "license": "Apache-2.0",
@@ -221,5 +221,5 @@
221
221
  "node": ">=7.4",
222
222
  "npm": ">=6.0.0"
223
223
  },
224
- "gitHead": "d04a1803eca6e63e2d96a7e109bcfec1dbca7085"
224
+ "gitHead": "3e4b569bf8d13582ab9502779338b81eb737cd3e"
225
225
  }