@zohodesk/components 1.6.15 → 1.6.16

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 CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  Dot UI is a customizable React component library built to deliver a clean, accessible, and developer-friendly UI experience. It offers a growing set of reusable components designed to align with modern design systems and streamline application development across projects.
4
4
 
5
+ # 1.6.16
6
+
7
+ - **DateWidget**
8
+ - Fixed i18n key handling issue to ensure localized labels/messages are resolved consistently.
9
+
5
10
 
6
11
  # 1.6.15
7
12
 
@@ -54,6 +54,7 @@ class DateWidgetComponent extends React.Component {
54
54
  this.handleDateIconClick = this.handleDateIconClick.bind(this);
55
55
  this.handleSelectionRangeDetails = this.handleSelectionRangeDetails.bind(this);
56
56
  this.handleBlurSelectionRange = this.handleBlurSelectionRange.bind(this);
57
+ this.getI18nMonthLabels = this.getI18nMonthLabels.bind(this);
57
58
  this.state = {
58
59
  selected: '',
59
60
  displayText: '',
@@ -264,6 +265,16 @@ class DateWidgetComponent extends React.Component {
264
265
  !isOpenOnly && togglePopup(e, `${defaultPosition}Right`);
265
266
  }
266
267
 
268
+ getI18nMonthLabels() {
269
+ const {
270
+ i18nKeys
271
+ } = this.props;
272
+ return {
273
+ i18nShortMonths: i18nKeys.monthNamesShort || i18nShortMonths,
274
+ i18nMonths: i18nKeys.monthNames || i18nMonths
275
+ };
276
+ }
277
+
267
278
  handleSelectionRangeDetails(props) {
268
279
  const {
269
280
  timeZone,
@@ -280,7 +291,11 @@ class DateWidgetComponent extends React.Component {
280
291
  minute,
281
292
  noon
282
293
  } = this.state;
283
- const selected = value === INVALID_DATE ? '' : value; //New UI Changes
294
+ const selected = value === INVALID_DATE ? '' : value;
295
+ const {
296
+ i18nShortMonths: localizedShortMonths,
297
+ i18nMonths: localizedMonths
298
+ } = this.getI18nMonthLabels(); //New UI Changes
284
299
 
285
300
  const dateFormatDetails = getDateFormatDetails(dateFormat, {
286
301
  isHideCurrentYear: false,
@@ -289,8 +304,8 @@ class DateWidgetComponent extends React.Component {
289
304
  isDateTime
290
305
  });
291
306
  const dateFormatSelection = getDateFormatSelection(dateFormatDetails, isDateTime, {
292
- i18nShortMonths,
293
- i18nMonths,
307
+ i18nShortMonths: localizedShortMonths,
308
+ i18nMonths: localizedMonths,
294
309
  selectedValue: selected,
295
310
  day,
296
311
  month,
@@ -320,6 +335,10 @@ class DateWidgetComponent extends React.Component {
320
335
  is24Hour,
321
336
  isHideCurrentYear
322
337
  } = props;
338
+ const {
339
+ i18nShortMonths: localizedShortMonths,
340
+ i18nMonths: localizedMonths
341
+ } = this.getI18nMonthLabels();
323
342
  const dateFormatDetails = getDateFormatDetails(dateFormat, {
324
343
  isHideCurrentYear,
325
344
  value,
@@ -340,7 +359,10 @@ class DateWidgetComponent extends React.Component {
340
359
  format = `${newDateFormat} ${is24Hour ? 'HH:mm' : 'hh:mm A'}`;
341
360
  }
342
361
 
343
- displayText = formatDate(convertedValue, format);
362
+ displayText = formatDate(convertedValue, format, {
363
+ i18nShortMonths: localizedShortMonths,
364
+ i18nMonths: localizedMonths
365
+ });
344
366
  }
345
367
 
346
368
  return {
@@ -828,6 +850,10 @@ class DateWidgetComponent extends React.Component {
828
850
  } = this.props;
829
851
 
830
852
  if (isDateEdited || isFocused || isPopupReady || isPopupOpen) {
853
+ const {
854
+ i18nShortMonths: localizedShortMonths,
855
+ i18nMonths: localizedMonths
856
+ } = this.getI18nMonthLabels();
831
857
  const {
832
858
  day: selectedDay = '',
833
859
  month: selectedMonth = '',
@@ -853,8 +879,8 @@ class DateWidgetComponent extends React.Component {
853
879
  minute: selectedMinute,
854
880
  noon: selectedNoon
855
881
  }, dateFormatDetails, isDateTime, {
856
- i18nShortMonths,
857
- i18nMonths,
882
+ i18nShortMonths: localizedShortMonths,
883
+ i18nMonths: localizedMonths,
858
884
  is24Hour
859
885
  });
860
886
  return dateTimeString;
@@ -14,7 +14,10 @@ export function getTimeOffset() {
14
14
  const matchingOffset = Object.keys(offsetMap).find(offset => GMT.getTimezoneOffset() === Number(offset));
15
15
  return matchingOffset ? offsetMap[matchingOffset].toString().split(' ') : ['', ''];
16
16
  }
17
- export function formatDate(dateMill, mask) {
17
+ export function formatDate(dateMill, mask, {
18
+ i18nShortMonths,
19
+ i18nMonths
20
+ } = {}) {
18
21
  let date = new Date(dateMill);
19
22
  let O = getTimeOffset()[0];
20
23
  let Z = getTimeOffset()[1];
@@ -26,6 +29,10 @@ export function formatDate(dateMill, mask) {
26
29
  let M = date.getMinutes();
27
30
  let s = date.getSeconds();
28
31
  let L = date.getMilliseconds();
32
+ const defaultShortMonths = dateFormat.monthNames.slice(0, 12);
33
+ const defaultMonths = dateFormat.monthNames.slice(12);
34
+ const resolvedShortMonths = Array.isArray(i18nShortMonths) ? i18nShortMonths : defaultShortMonths;
35
+ const resolvedMonths = Array.isArray(i18nMonths) ? i18nMonths : defaultMonths;
29
36
  let flags = {
30
37
  d: d,
31
38
  O: O,
@@ -38,8 +45,8 @@ export function formatDate(dateMill, mask) {
38
45
  DDDD: dateFormat.dayNames[D + 7],
39
46
  M: m + 1,
40
47
  MM: pad(m + 1, 2),
41
- MMM: dateFormat.monthNames[m],
42
- MMMM: dateFormat.monthNames[m + 12],
48
+ MMM: resolvedShortMonths[m],
49
+ MMMM: resolvedMonths[m],
43
50
  yy: String(y).slice(2),
44
51
  YY: String(y).slice(2),
45
52
  yyyy: y,
@@ -102,6 +102,7 @@ var DateWidgetComponent = /*#__PURE__*/function (_React$Component) {
102
102
  _this.handleDateIconClick = _this.handleDateIconClick.bind(_assertThisInitialized(_this));
103
103
  _this.handleSelectionRangeDetails = _this.handleSelectionRangeDetails.bind(_assertThisInitialized(_this));
104
104
  _this.handleBlurSelectionRange = _this.handleBlurSelectionRange.bind(_assertThisInitialized(_this));
105
+ _this.getI18nMonthLabels = _this.getI18nMonthLabels.bind(_assertThisInitialized(_this));
105
106
  _this.state = {
106
107
  selected: '',
107
108
  displayText: '',
@@ -313,6 +314,15 @@ var DateWidgetComponent = /*#__PURE__*/function (_React$Component) {
313
314
 
314
315
  !isOpenOnly && togglePopup(e, "".concat(defaultPosition, "Right"));
315
316
  }
317
+ }, {
318
+ key: "getI18nMonthLabels",
319
+ value: function getI18nMonthLabels() {
320
+ var i18nKeys = this.props.i18nKeys;
321
+ return {
322
+ i18nShortMonths: i18nKeys.monthNamesShort || _constants.i18nShortMonths,
323
+ i18nMonths: i18nKeys.monthNames || _constants.i18nMonths
324
+ };
325
+ }
316
326
  }, {
317
327
  key: "handleSelectionRangeDetails",
318
328
  value: function handleSelectionRangeDetails(props) {
@@ -328,7 +338,12 @@ var DateWidgetComponent = /*#__PURE__*/function (_React$Component) {
328
338
  hour = _this$state2.hour,
329
339
  minute = _this$state2.minute,
330
340
  noon = _this$state2.noon;
331
- var selected = value === _constants.INVALID_DATE ? '' : value; //New UI Changes
341
+ var selected = value === _constants.INVALID_DATE ? '' : value;
342
+
343
+ var _this$getI18nMonthLab = this.getI18nMonthLabels(),
344
+ localizedShortMonths = _this$getI18nMonthLab.i18nShortMonths,
345
+ localizedMonths = _this$getI18nMonthLab.i18nMonths; //New UI Changes
346
+
332
347
 
333
348
  var dateFormatDetails = (0, _dateFormat.getDateFormatDetails)(dateFormat, {
334
349
  isHideCurrentYear: false,
@@ -337,8 +352,8 @@ var DateWidgetComponent = /*#__PURE__*/function (_React$Component) {
337
352
  isDateTime: isDateTime
338
353
  });
339
354
  var dateFormatSelection = (0, _dateFormat.getDateFormatSelection)(dateFormatDetails, isDateTime, {
340
- i18nShortMonths: _constants.i18nShortMonths,
341
- i18nMonths: _constants.i18nMonths,
355
+ i18nShortMonths: localizedShortMonths,
356
+ i18nMonths: localizedMonths,
342
357
  selectedValue: selected,
343
358
  day: day,
344
359
  month: month,
@@ -365,6 +380,11 @@ var DateWidgetComponent = /*#__PURE__*/function (_React$Component) {
365
380
  value = props.value,
366
381
  is24Hour = props.is24Hour,
367
382
  isHideCurrentYear = props.isHideCurrentYear;
383
+
384
+ var _this$getI18nMonthLab2 = this.getI18nMonthLabels(),
385
+ localizedShortMonths = _this$getI18nMonthLab2.i18nShortMonths,
386
+ localizedMonths = _this$getI18nMonthLab2.i18nMonths;
387
+
368
388
  var dateFormatDetails = (0, _dateFormat.getDateFormatDetails)(dateFormat, {
369
389
  isHideCurrentYear: isHideCurrentYear,
370
390
  value: value,
@@ -383,7 +403,10 @@ var DateWidgetComponent = /*#__PURE__*/function (_React$Component) {
383
403
  format = "".concat(newDateFormat, " ").concat(is24Hour ? 'HH:mm' : 'hh:mm A');
384
404
  }
385
405
 
386
- displayText = (0, _common.formatDate)(convertedValue, format);
406
+ displayText = (0, _common.formatDate)(convertedValue, format, {
407
+ i18nShortMonths: localizedShortMonths,
408
+ i18nMonths: localizedMonths
409
+ });
387
410
  }
388
411
 
389
412
  return {
@@ -849,6 +872,10 @@ var DateWidgetComponent = /*#__PURE__*/function (_React$Component) {
849
872
  isPopupOpen = _this$props9.isPopupOpen;
850
873
 
851
874
  if (isDateEdited || isFocused || isPopupReady || isPopupOpen) {
875
+ var _this$getI18nMonthLab3 = this.getI18nMonthLabels(),
876
+ localizedShortMonths = _this$getI18nMonthLab3.i18nShortMonths,
877
+ localizedMonths = _this$getI18nMonthLab3.i18nMonths;
878
+
852
879
  var _getDateDetails2 = (0, _dateFormat.getDateDetails)(selected, {
853
880
  day: day,
854
881
  month: month,
@@ -880,8 +907,8 @@ var DateWidgetComponent = /*#__PURE__*/function (_React$Component) {
880
907
  minute: selectedMinute,
881
908
  noon: selectedNoon
882
909
  }, dateFormatDetails, isDateTime, {
883
- i18nShortMonths: _constants.i18nShortMonths,
884
- i18nMonths: _constants.i18nMonths,
910
+ i18nShortMonths: localizedShortMonths,
911
+ i18nMonths: localizedMonths,
885
912
  is24Hour: is24Hour
886
913
  });
887
914
  return dateTimeString;
@@ -46,6 +46,10 @@ function getTimeOffset() {
46
46
  }
47
47
 
48
48
  function formatDate(dateMill, mask) {
49
+ var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
50
+ i18nShortMonths = _ref.i18nShortMonths,
51
+ i18nMonths = _ref.i18nMonths;
52
+
49
53
  var date = new Date(dateMill);
50
54
  var O = getTimeOffset()[0];
51
55
  var Z = getTimeOffset()[1];
@@ -57,6 +61,10 @@ function formatDate(dateMill, mask) {
57
61
  var M = date.getMinutes();
58
62
  var s = date.getSeconds();
59
63
  var L = date.getMilliseconds();
64
+ var defaultShortMonths = dateFormat.monthNames.slice(0, 12);
65
+ var defaultMonths = dateFormat.monthNames.slice(12);
66
+ var resolvedShortMonths = Array.isArray(i18nShortMonths) ? i18nShortMonths : defaultShortMonths;
67
+ var resolvedMonths = Array.isArray(i18nMonths) ? i18nMonths : defaultMonths;
60
68
  var flags = {
61
69
  d: d,
62
70
  O: O,
@@ -69,8 +77,8 @@ function formatDate(dateMill, mask) {
69
77
  DDDD: dateFormat.dayNames[D + 7],
70
78
  M: m + 1,
71
79
  MM: pad(m + 1, 2),
72
- MMM: dateFormat.monthNames[m],
73
- MMMM: dateFormat.monthNames[m + 12],
80
+ MMM: resolvedShortMonths[m],
81
+ MMMM: resolvedMonths[m],
74
82
  yy: String(y).slice(2),
75
83
  YY: String(y).slice(2),
76
84
  yyyy: y,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/components",
3
- "version": "1.6.15",
3
+ "version": "1.6.16",
4
4
  "main": "es/index.js",
5
5
  "module": "es/index.js",
6
6
  "private": false,