@commercetools-uikit/calendar-time-utils 15.15.0 → 16.0.0

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.
@@ -1 +1,2 @@
1
1
  export * from "./declarations/src/index";
2
+ //# sourceMappingURL=commercetools-uikit-calendar-time-utils.cjs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commercetools-uikit-calendar-time-utils.cjs.d.ts","sourceRoot":"","sources":["./declarations/src/index.d.ts"],"names":[],"mappings":"AAAA"}
@@ -3,7 +3,6 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
6
- var _toConsumableArray = require('@babel/runtime-corejs3/helpers/toConsumableArray');
7
6
  var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
8
7
  var _sliceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/slice');
9
8
  var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
@@ -14,7 +13,6 @@ var _Object$entries = require('@babel/runtime-corejs3/core-js-stable/object/entr
14
13
  var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
15
14
  var moment = require('moment-timezone');
16
15
  var utils = require('@commercetools-uikit/utils');
17
- var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
18
16
 
19
17
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
20
18
 
@@ -28,10 +26,8 @@ var _Object$entries__default = /*#__PURE__*/_interopDefault(_Object$entries);
28
26
  var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
29
27
  var moment__default = /*#__PURE__*/_interopDefault(moment);
30
28
 
31
- var _en, _de, _es, _fr, _zhCN;
32
-
33
29
  // Reference: https://momentjs.com/docs/#/displaying/format/
34
- var formatToken = {
30
+ const formatToken = {
35
31
  D: 'D',
36
32
  // NUMERIC_SINGLE_DAY
37
33
  DD: 'DD',
@@ -64,22 +60,42 @@ var formatToken = {
64
60
  // We just need to provide the translation for the characters that are different
65
61
  // For instance, in english we don't need to translate date characters as
66
62
  // they are the same as the pattern characters
67
- var DATE_FORMAT_LOCALIZED_MAPPINGS = {
68
- en: (_en = {}, _defineProperty(_en, formatToken.h, 'HH'), _defineProperty(_en, formatToken.A, 'AM/PM'), _en),
69
- de: (_de = {}, _defineProperty(_de, formatToken.DD, 'TT'), _defineProperty(_de, formatToken.YYYY, 'JJJJ'), _defineProperty(_de, formatToken.HH, 'SS'), _de),
70
- es: (_es = {}, _defineProperty(_es, formatToken.H, 'HH'), _defineProperty(_es, formatToken.YYYY, 'AAAA'), _es),
71
- fr: (_fr = {}, _defineProperty(_fr, formatToken.DD, 'JJ'), _defineProperty(_fr, formatToken.YYYY, 'AAAA'), _fr),
72
- 'zh-CN': (_zhCN = {}, _defineProperty(_zhCN, formatToken.HH, '小时'), _defineProperty(_zhCN, formatToken.mm, '分钟'), _defineProperty(_zhCN, formatToken.DD, '日'), _defineProperty(_zhCN, formatToken.MM, '月'), _defineProperty(_zhCN, formatToken.YYYY, '年'), _zhCN)
63
+ const DATE_FORMAT_LOCALIZED_MAPPINGS = {
64
+ en: {
65
+ // MM/DD/YYYY - h:mm A -> MM/DD/YYYY - HH:mm AM/PM
66
+ [formatToken.h]: 'HH',
67
+ [formatToken.A]: 'AM/PM'
68
+ },
69
+ de: {
70
+ // DD.MM.YYYY - HH:mm -> TT.MM.JJJJ - SS:mm
71
+ [formatToken.DD]: 'TT',
72
+ [formatToken.YYYY]: 'JJJJ',
73
+ [formatToken.HH]: 'SS'
74
+ },
75
+ es: {
76
+ // DD/MM/YYYY - H:mm -> DD/MM/AAAA - HH:mm
77
+ [formatToken.H]: 'HH',
78
+ [formatToken.YYYY]: 'AAAA'
79
+ },
80
+ fr: {
81
+ // DD/MM/YYYY - HH:mm -> JJ/MM/AAAA - HH:mm
82
+ [formatToken.DD]: 'JJ',
83
+ [formatToken.YYYY]: 'AAAA'
84
+ },
85
+ 'zh-CN': {
86
+ // YYYY/MM/DD - HH:mm -> 年/月/日 - 小时:分钟
87
+ [formatToken.HH]: '小时',
88
+ [formatToken.mm]: '分钟',
89
+ [formatToken.DD]: '日',
90
+ [formatToken.MM]: '月',
91
+ [formatToken.YYYY]: '年'
92
+ }
73
93
  };
74
94
 
75
- var getDaysInMonth = function getDaysInMonth(day, timeZone) {
76
- return moment__default["default"].tz(day, timeZone).daysInMonth();
77
- };
78
- var changeDateInMonth = function changeDateInMonth(day, timeZone, dayOfMonth) {
79
- return moment__default["default"].tz(day, timeZone).date(dayOfMonth).toISOString();
80
- };
81
- var changeTime = function changeTime(dateString, timeZone, parsedTime) {
82
- var date = moment__default["default"].tz(dateString, timeZone);
95
+ const getDaysInMonth = (day, timeZone) => moment__default["default"].tz(day, timeZone).daysInMonth();
96
+ const changeDateInMonth = (day, timeZone, dayOfMonth) => moment__default["default"].tz(day, timeZone).date(dayOfMonth).toISOString();
97
+ const changeTime = (dateString, timeZone, parsedTime) => {
98
+ const date = moment__default["default"].tz(dateString, timeZone);
83
99
  date.hours(parsedTime.hours);
84
100
  date.minutes(parsedTime.minutes);
85
101
  date.seconds(parsedTime.seconds);
@@ -87,74 +103,50 @@ var changeTime = function changeTime(dateString, timeZone, parsedTime) {
87
103
  date.milliseconds(parsedTime.milliseconds);
88
104
  return date.toISOString();
89
105
  };
90
- var getPreviousDay = function getPreviousDay(day) {
91
- return moment__default["default"](day).subtract(1, 'day').format('YYYY-MM-DD');
92
- };
93
- var formatTime = function formatTime(day, locale, timeZone) {
94
- var date = moment__default["default"].tz(day, timeZone).locale(locale);
106
+ const getPreviousDay = day => moment__default["default"](day).subtract(1, 'day').format('YYYY-MM-DD');
107
+ const formatTime = (day, locale, timeZone) => {
108
+ const date = moment__default["default"].tz(day, timeZone).locale(locale);
95
109
  if (date.milliseconds()) return date.format('HH:mm:ss.SSS');
96
110
  if (date.seconds()) return date.format('LTS'); // 5:13:51 PM
97
111
 
98
112
  return date.format('LT'); // 5:13 PM
99
113
  };
100
- var formatDate = function formatDate(day, locale, timeZone) {
114
+ const formatDate = (day, locale, timeZone) => {
101
115
  var _context;
102
116
 
103
- var date = moment__default["default"](day, moment__default["default"].ISO_8601, locale).tz(timeZone).format('L');
104
- var time = formatTime(day, locale, timeZone);
117
+ const date = moment__default["default"](day, moment__default["default"].ISO_8601, locale).tz(timeZone).format('L');
118
+ const time = formatTime(day, locale, timeZone);
105
119
  return _concatInstanceProperty__default["default"](_context = "".concat(date, " ")).call(_context, time);
106
120
  };
107
- var getDateInMonth = function getDateInMonth(day, timeZone) {
108
- return moment__default["default"].tz(day, timeZone).date();
109
- };
110
- var getToday = function getToday(timeZone) {
111
- return moment__default["default"].tz(timeZone).startOf('day').toISOString();
112
- };
113
- var changeMonth = function changeMonth(day, timeZone, delta) {
114
- return moment__default["default"].tz(day, timeZone).add(delta, 'month').toISOString();
115
- };
116
- var getPaddingDayCount = function getPaddingDayCount(day, locale, timeZone) {
117
- var firstDayOfWeek = moment__default["default"].localeData(locale).firstDayOfWeek();
118
- var firstDayOfMonth = moment__default["default"].tz(day, timeZone).startOf('month').day(); // ensure number is always positive
121
+ const getDateInMonth = (day, timeZone) => moment__default["default"].tz(day, timeZone).date();
122
+ const getToday = timeZone => moment__default["default"].tz(timeZone).startOf('day').toISOString();
123
+ const changeMonth = (day, timeZone, delta) => moment__default["default"].tz(day, timeZone).add(delta, 'month').toISOString();
124
+ const getPaddingDayCount = (day, locale, timeZone) => {
125
+ const firstDayOfWeek = moment__default["default"].localeData(locale).firstDayOfWeek();
126
+ const firstDayOfMonth = moment__default["default"].tz(day, timeZone).startOf('month').day(); // ensure number is always positive
119
127
 
120
128
  return (firstDayOfMonth - firstDayOfWeek + 7) % 7;
121
129
  };
122
- var getWeekdayNames = function getWeekdayNames(locale) {
123
- var _context2;
124
-
125
- var weekDays = moment__default["default"].localeData(locale).weekdaysMin();
126
- var firstDay = moment__default["default"].localeData(locale).firstDayOfWeek();
127
- return _concatInstanceProperty__default["default"](_context2 = []).call(_context2, _toConsumableArray(_sliceInstanceProperty__default["default"](weekDays).call(weekDays, firstDay)), _toConsumableArray(_sliceInstanceProperty__default["default"](weekDays).call(weekDays, 0, firstDay)));
128
- };
129
- var getStartOf = function getStartOf(day, timeZone) {
130
- return moment__default["default"].tz(day, timeZone).startOf('day').toISOString();
131
- };
132
- var getMonthCalendarLabel = function getMonthCalendarLabel(day, locale) {
133
- return moment__default["default"](day, moment__default["default"].ISO_8601, locale).format('MMMM');
134
- };
135
- var getYearCalendarLabel = function getYearCalendarLabel(day, locale) {
136
- return moment__default["default"](day, moment__default["default"].ISO_8601, locale).format('YYYY');
130
+ const getWeekdayNames = locale => {
131
+ const weekDays = moment__default["default"].localeData(locale).weekdaysMin();
132
+ const firstDay = moment__default["default"].localeData(locale).firstDayOfWeek();
133
+ return [..._sliceInstanceProperty__default["default"](weekDays).call(weekDays, firstDay), ..._sliceInstanceProperty__default["default"](weekDays).call(weekDays, 0, firstDay)];
137
134
  };
138
- var isSameDay = function isSameDay(a, b) {
139
- return moment__default["default"](a).isSame(b, 'day');
140
- };
141
- var getCalendarDayLabel = function getCalendarDayLabel(day, timeZone) {
142
- return moment__default["default"].tz(day, timeZone).format('D');
143
- };
144
- var createItemDateTimeToString = function createItemDateTimeToString(locale, timeZone) {
145
- return function (item) {
146
- return item ? formatDate(item, locale, timeZone) : '';
147
- };
148
- };
149
- var createCalendarItems = function createCalendarItems(day, timeString, timeZone) {
150
- var _context3;
135
+ const getStartOf = (day, timeZone) => moment__default["default"].tz(day, timeZone).startOf('day').toISOString();
136
+ const getMonthCalendarLabel = (day, locale) => moment__default["default"](day, moment__default["default"].ISO_8601, locale).format('MMMM');
137
+ const getYearCalendarLabel = (day, locale) => moment__default["default"](day, moment__default["default"].ISO_8601, locale).format('YYYY');
138
+ const isSameDay = (a, b) => moment__default["default"](a).isSame(b, 'day');
139
+ const getCalendarDayLabel = (day, timeZone) => moment__default["default"].tz(day, timeZone).format('D');
140
+ const createItemDateTimeToString = (locale, timeZone) => item => item ? formatDate(item, locale, timeZone) : '';
141
+ const createCalendarItems = (day, timeString, timeZone) => {
142
+ var _context2;
151
143
 
152
- var parsedTime = utils.parseTime(timeString);
153
- return _mapInstanceProperty__default["default"](_context3 = _Array$from__default["default"]({
144
+ const parsedTime = utils.parseTime(timeString);
145
+ return _mapInstanceProperty__default["default"](_context2 = _Array$from__default["default"]({
154
146
  length: getDaysInMonth(day, timeZone)
155
- })).call(_context3, function (_, i) {
156
- var dayOfMonth = i + 1;
157
- var date = changeDateInMonth(day, timeZone, dayOfMonth);
147
+ })).call(_context2, (_, i) => {
148
+ const dayOfMonth = i + 1;
149
+ let date = changeDateInMonth(day, timeZone, dayOfMonth);
158
150
 
159
151
  if (parsedTime) {
160
152
  date = changeTime(date, timeZone, parsedTime);
@@ -163,22 +155,22 @@ var createCalendarItems = function createCalendarItems(day, timeString, timeZone
163
155
  return date;
164
156
  });
165
157
  };
166
- var createSuggestedItems = function createSuggestedItems(inputValue, timeZone) {
158
+ const createSuggestedItems = (inputValue, timeZone) => {
167
159
  if (_startsWithInstanceProperty__default["default"](inputValue).call(inputValue, 't')) return [getToday(timeZone)];
168
160
  return [];
169
161
  };
170
- var parseInputText = function parseInputText(text, locale, timeZone) {
171
- var parts = text.split(' ');
172
- var dateString = parts[0];
162
+ const parseInputText = (text, locale, timeZone) => {
163
+ const parts = text.split(' ');
164
+ const dateString = parts[0];
173
165
 
174
- var timeString = _sliceInstanceProperty__default["default"](parts).call(parts, 1).join(' ');
166
+ const timeString = _sliceInstanceProperty__default["default"](parts).call(parts, 1).join(' ');
175
167
 
176
168
  if (!dateString) return '';
177
- var date = moment__default["default"].tz(dateString, moment__default["default"].localeData(locale).longDateFormat('L'), timeZone);
169
+ const date = moment__default["default"].tz(dateString, moment__default["default"].localeData(locale).longDateFormat('L'), timeZone);
178
170
  if (!date.isValid()) return ''; // enable parsing a date only
179
171
 
180
172
  if (!timeString) return date.startOf('day').toISOString();
181
- var parsedTime = utils.parseTime(timeString);
173
+ const parsedTime = utils.parseTime(timeString);
182
174
 
183
175
  if (parsedTime) {
184
176
  date.hours(parsedTime.hours);
@@ -191,13 +183,13 @@ var parseInputText = function parseInputText(text, locale, timeZone) {
191
183
 
192
184
  return '';
193
185
  };
194
- var localizedDateFormatPatternCache = new _Map__default["default"]();
195
- var getLocalizedDateTimeFormatPattern = function getLocalizedDateTimeFormatPattern(locale) {
196
- var _context4, _context5;
186
+ const localizedDateFormatPatternCache = new _Map__default["default"]();
187
+ const getLocalizedDateTimeFormatPattern = function (locale) {
188
+ var _context3, _context4;
197
189
 
198
- var formatType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'date';
190
+ let formatType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'date';
199
191
 
200
- var key = _concatInstanceProperty__default["default"](_context4 = "".concat(locale, "::")).call(_context4, formatType);
192
+ const key = _concatInstanceProperty__default["default"](_context3 = "".concat(locale, "::")).call(_context3, formatType);
201
193
 
202
194
  if (localizedDateFormatPatternCache.has(key)) {
203
195
  return localizedDateFormatPatternCache.get(key);
@@ -206,8 +198,8 @@ var getLocalizedDateTimeFormatPattern = function getLocalizedDateTimeFormatPatte
206
198
  // https://momentjs.com/docs/#/displaying/ ("Localized formats" section)
207
199
 
208
200
 
209
- var localeData = moment__default["default"]().locale(locale).localeData();
210
- var localizedFormat = '';
201
+ const localeData = moment__default["default"]().locale(locale).localeData();
202
+ let localizedFormat = '';
211
203
 
212
204
  switch (formatType) {
213
205
  case 'date':
@@ -219,7 +211,7 @@ var getLocalizedDateTimeFormatPattern = function getLocalizedDateTimeFormatPatte
219
211
  break;
220
212
 
221
213
  case 'full':
222
- localizedFormat = _concatInstanceProperty__default["default"](_context5 = "".concat(localeData.longDateFormat('L'), " - ")).call(_context5, localeData.longDateFormat('LT'));
214
+ localizedFormat = _concatInstanceProperty__default["default"](_context4 = "".concat(localeData.longDateFormat('L'), " - ")).call(_context4, localeData.longDateFormat('LT'));
223
215
  break;
224
216
 
225
217
  default:
@@ -228,19 +220,19 @@ var getLocalizedDateTimeFormatPattern = function getLocalizedDateTimeFormatPatte
228
220
  // and the generic language code (e.g. 'en').
229
221
 
230
222
 
231
- var _locale$split = locale.split('-'),
232
- _locale$split2 = _slicedToArray(_locale$split, 1),
233
- languageCode = _locale$split2[0];
223
+ const _locale$split = locale.split('-'),
224
+ _locale$split2 = _slicedToArray(_locale$split, 1),
225
+ languageCode = _locale$split2[0];
234
226
 
235
- var localeMappings = _Object$entries__default["default"](DATE_FORMAT_LOCALIZED_MAPPINGS[locale] || DATE_FORMAT_LOCALIZED_MAPPINGS[languageCode] || {}); // In case we don't have a translation for the locale, we fallback to the
227
+ const localeMappings = _Object$entries__default["default"](DATE_FORMAT_LOCALIZED_MAPPINGS[locale] || DATE_FORMAT_LOCALIZED_MAPPINGS[languageCode] || {}); // In case we don't have a translation for the locale, we fallback to the
236
228
  // pattern from the moment locale data.
237
229
 
238
230
 
239
- var pattern = localizedFormat;
231
+ let pattern = localizedFormat;
240
232
 
241
233
  if (localeMappings && localeMappings.length > 0) {
242
- pattern = _reduceInstanceProperty__default["default"](localeMappings).call(localeMappings, function (localizedPattern, _ref) {
243
- var _ref2 = _slicedToArray(_ref, 2),
234
+ pattern = _reduceInstanceProperty__default["default"](localeMappings).call(localeMappings, (localizedPattern, _ref) => {
235
+ let _ref2 = _slicedToArray(_ref, 2),
244
236
  token = _ref2[0],
245
237
  mappedValue = _ref2[1];
246
238
 
@@ -253,7 +245,7 @@ var getLocalizedDateTimeFormatPattern = function getLocalizedDateTimeFormatPatte
253
245
  };
254
246
 
255
247
  // NOTE: This string will be replaced on build time with the package version.
256
- var version = "15.15.0";
248
+ var version = "16.0.0";
257
249
 
258
250
  exports.changeDateInMonth = changeDateInMonth;
259
251
  exports.changeMonth = changeMonth;
@@ -3,7 +3,6 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
6
- var _toConsumableArray = require('@babel/runtime-corejs3/helpers/toConsumableArray');
7
6
  var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
8
7
  var _sliceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/slice');
9
8
  var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
@@ -14,7 +13,6 @@ var _Object$entries = require('@babel/runtime-corejs3/core-js-stable/object/entr
14
13
  var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
15
14
  var moment = require('moment-timezone');
16
15
  var utils = require('@commercetools-uikit/utils');
17
- var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
18
16
 
19
17
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
20
18
 
@@ -28,10 +26,8 @@ var _Object$entries__default = /*#__PURE__*/_interopDefault(_Object$entries);
28
26
  var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
29
27
  var moment__default = /*#__PURE__*/_interopDefault(moment);
30
28
 
31
- var _en, _de, _es, _fr, _zhCN;
32
-
33
29
  // Reference: https://momentjs.com/docs/#/displaying/format/
34
- var formatToken = {
30
+ const formatToken = {
35
31
  D: 'D',
36
32
  // NUMERIC_SINGLE_DAY
37
33
  DD: 'DD',
@@ -64,22 +60,42 @@ var formatToken = {
64
60
  // We just need to provide the translation for the characters that are different
65
61
  // For instance, in english we don't need to translate date characters as
66
62
  // they are the same as the pattern characters
67
- var DATE_FORMAT_LOCALIZED_MAPPINGS = {
68
- en: (_en = {}, _defineProperty(_en, formatToken.h, 'HH'), _defineProperty(_en, formatToken.A, 'AM/PM'), _en),
69
- de: (_de = {}, _defineProperty(_de, formatToken.DD, 'TT'), _defineProperty(_de, formatToken.YYYY, 'JJJJ'), _defineProperty(_de, formatToken.HH, 'SS'), _de),
70
- es: (_es = {}, _defineProperty(_es, formatToken.H, 'HH'), _defineProperty(_es, formatToken.YYYY, 'AAAA'), _es),
71
- fr: (_fr = {}, _defineProperty(_fr, formatToken.DD, 'JJ'), _defineProperty(_fr, formatToken.YYYY, 'AAAA'), _fr),
72
- 'zh-CN': (_zhCN = {}, _defineProperty(_zhCN, formatToken.HH, '小时'), _defineProperty(_zhCN, formatToken.mm, '分钟'), _defineProperty(_zhCN, formatToken.DD, '日'), _defineProperty(_zhCN, formatToken.MM, '月'), _defineProperty(_zhCN, formatToken.YYYY, '年'), _zhCN)
63
+ const DATE_FORMAT_LOCALIZED_MAPPINGS = {
64
+ en: {
65
+ // MM/DD/YYYY - h:mm A -> MM/DD/YYYY - HH:mm AM/PM
66
+ [formatToken.h]: 'HH',
67
+ [formatToken.A]: 'AM/PM'
68
+ },
69
+ de: {
70
+ // DD.MM.YYYY - HH:mm -> TT.MM.JJJJ - SS:mm
71
+ [formatToken.DD]: 'TT',
72
+ [formatToken.YYYY]: 'JJJJ',
73
+ [formatToken.HH]: 'SS'
74
+ },
75
+ es: {
76
+ // DD/MM/YYYY - H:mm -> DD/MM/AAAA - HH:mm
77
+ [formatToken.H]: 'HH',
78
+ [formatToken.YYYY]: 'AAAA'
79
+ },
80
+ fr: {
81
+ // DD/MM/YYYY - HH:mm -> JJ/MM/AAAA - HH:mm
82
+ [formatToken.DD]: 'JJ',
83
+ [formatToken.YYYY]: 'AAAA'
84
+ },
85
+ 'zh-CN': {
86
+ // YYYY/MM/DD - HH:mm -> 年/月/日 - 小时:分钟
87
+ [formatToken.HH]: '小时',
88
+ [formatToken.mm]: '分钟',
89
+ [formatToken.DD]: '日',
90
+ [formatToken.MM]: '月',
91
+ [formatToken.YYYY]: '年'
92
+ }
73
93
  };
74
94
 
75
- var getDaysInMonth = function getDaysInMonth(day, timeZone) {
76
- return moment__default["default"].tz(day, timeZone).daysInMonth();
77
- };
78
- var changeDateInMonth = function changeDateInMonth(day, timeZone, dayOfMonth) {
79
- return moment__default["default"].tz(day, timeZone).date(dayOfMonth).toISOString();
80
- };
81
- var changeTime = function changeTime(dateString, timeZone, parsedTime) {
82
- var date = moment__default["default"].tz(dateString, timeZone);
95
+ const getDaysInMonth = (day, timeZone) => moment__default["default"].tz(day, timeZone).daysInMonth();
96
+ const changeDateInMonth = (day, timeZone, dayOfMonth) => moment__default["default"].tz(day, timeZone).date(dayOfMonth).toISOString();
97
+ const changeTime = (dateString, timeZone, parsedTime) => {
98
+ const date = moment__default["default"].tz(dateString, timeZone);
83
99
  date.hours(parsedTime.hours);
84
100
  date.minutes(parsedTime.minutes);
85
101
  date.seconds(parsedTime.seconds);
@@ -87,74 +103,50 @@ var changeTime = function changeTime(dateString, timeZone, parsedTime) {
87
103
  date.milliseconds(parsedTime.milliseconds);
88
104
  return date.toISOString();
89
105
  };
90
- var getPreviousDay = function getPreviousDay(day) {
91
- return moment__default["default"](day).subtract(1, 'day').format('YYYY-MM-DD');
92
- };
93
- var formatTime = function formatTime(day, locale, timeZone) {
94
- var date = moment__default["default"].tz(day, timeZone).locale(locale);
106
+ const getPreviousDay = day => moment__default["default"](day).subtract(1, 'day').format('YYYY-MM-DD');
107
+ const formatTime = (day, locale, timeZone) => {
108
+ const date = moment__default["default"].tz(day, timeZone).locale(locale);
95
109
  if (date.milliseconds()) return date.format('HH:mm:ss.SSS');
96
110
  if (date.seconds()) return date.format('LTS'); // 5:13:51 PM
97
111
 
98
112
  return date.format('LT'); // 5:13 PM
99
113
  };
100
- var formatDate = function formatDate(day, locale, timeZone) {
114
+ const formatDate = (day, locale, timeZone) => {
101
115
  var _context;
102
116
 
103
- var date = moment__default["default"](day, moment__default["default"].ISO_8601, locale).tz(timeZone).format('L');
104
- var time = formatTime(day, locale, timeZone);
117
+ const date = moment__default["default"](day, moment__default["default"].ISO_8601, locale).tz(timeZone).format('L');
118
+ const time = formatTime(day, locale, timeZone);
105
119
  return _concatInstanceProperty__default["default"](_context = "".concat(date, " ")).call(_context, time);
106
120
  };
107
- var getDateInMonth = function getDateInMonth(day, timeZone) {
108
- return moment__default["default"].tz(day, timeZone).date();
109
- };
110
- var getToday = function getToday(timeZone) {
111
- return moment__default["default"].tz(timeZone).startOf('day').toISOString();
112
- };
113
- var changeMonth = function changeMonth(day, timeZone, delta) {
114
- return moment__default["default"].tz(day, timeZone).add(delta, 'month').toISOString();
115
- };
116
- var getPaddingDayCount = function getPaddingDayCount(day, locale, timeZone) {
117
- var firstDayOfWeek = moment__default["default"].localeData(locale).firstDayOfWeek();
118
- var firstDayOfMonth = moment__default["default"].tz(day, timeZone).startOf('month').day(); // ensure number is always positive
121
+ const getDateInMonth = (day, timeZone) => moment__default["default"].tz(day, timeZone).date();
122
+ const getToday = timeZone => moment__default["default"].tz(timeZone).startOf('day').toISOString();
123
+ const changeMonth = (day, timeZone, delta) => moment__default["default"].tz(day, timeZone).add(delta, 'month').toISOString();
124
+ const getPaddingDayCount = (day, locale, timeZone) => {
125
+ const firstDayOfWeek = moment__default["default"].localeData(locale).firstDayOfWeek();
126
+ const firstDayOfMonth = moment__default["default"].tz(day, timeZone).startOf('month').day(); // ensure number is always positive
119
127
 
120
128
  return (firstDayOfMonth - firstDayOfWeek + 7) % 7;
121
129
  };
122
- var getWeekdayNames = function getWeekdayNames(locale) {
123
- var _context2;
124
-
125
- var weekDays = moment__default["default"].localeData(locale).weekdaysMin();
126
- var firstDay = moment__default["default"].localeData(locale).firstDayOfWeek();
127
- return _concatInstanceProperty__default["default"](_context2 = []).call(_context2, _toConsumableArray(_sliceInstanceProperty__default["default"](weekDays).call(weekDays, firstDay)), _toConsumableArray(_sliceInstanceProperty__default["default"](weekDays).call(weekDays, 0, firstDay)));
128
- };
129
- var getStartOf = function getStartOf(day, timeZone) {
130
- return moment__default["default"].tz(day, timeZone).startOf('day').toISOString();
131
- };
132
- var getMonthCalendarLabel = function getMonthCalendarLabel(day, locale) {
133
- return moment__default["default"](day, moment__default["default"].ISO_8601, locale).format('MMMM');
134
- };
135
- var getYearCalendarLabel = function getYearCalendarLabel(day, locale) {
136
- return moment__default["default"](day, moment__default["default"].ISO_8601, locale).format('YYYY');
130
+ const getWeekdayNames = locale => {
131
+ const weekDays = moment__default["default"].localeData(locale).weekdaysMin();
132
+ const firstDay = moment__default["default"].localeData(locale).firstDayOfWeek();
133
+ return [..._sliceInstanceProperty__default["default"](weekDays).call(weekDays, firstDay), ..._sliceInstanceProperty__default["default"](weekDays).call(weekDays, 0, firstDay)];
137
134
  };
138
- var isSameDay = function isSameDay(a, b) {
139
- return moment__default["default"](a).isSame(b, 'day');
140
- };
141
- var getCalendarDayLabel = function getCalendarDayLabel(day, timeZone) {
142
- return moment__default["default"].tz(day, timeZone).format('D');
143
- };
144
- var createItemDateTimeToString = function createItemDateTimeToString(locale, timeZone) {
145
- return function (item) {
146
- return item ? formatDate(item, locale, timeZone) : '';
147
- };
148
- };
149
- var createCalendarItems = function createCalendarItems(day, timeString, timeZone) {
150
- var _context3;
135
+ const getStartOf = (day, timeZone) => moment__default["default"].tz(day, timeZone).startOf('day').toISOString();
136
+ const getMonthCalendarLabel = (day, locale) => moment__default["default"](day, moment__default["default"].ISO_8601, locale).format('MMMM');
137
+ const getYearCalendarLabel = (day, locale) => moment__default["default"](day, moment__default["default"].ISO_8601, locale).format('YYYY');
138
+ const isSameDay = (a, b) => moment__default["default"](a).isSame(b, 'day');
139
+ const getCalendarDayLabel = (day, timeZone) => moment__default["default"].tz(day, timeZone).format('D');
140
+ const createItemDateTimeToString = (locale, timeZone) => item => item ? formatDate(item, locale, timeZone) : '';
141
+ const createCalendarItems = (day, timeString, timeZone) => {
142
+ var _context2;
151
143
 
152
- var parsedTime = utils.parseTime(timeString);
153
- return _mapInstanceProperty__default["default"](_context3 = _Array$from__default["default"]({
144
+ const parsedTime = utils.parseTime(timeString);
145
+ return _mapInstanceProperty__default["default"](_context2 = _Array$from__default["default"]({
154
146
  length: getDaysInMonth(day, timeZone)
155
- })).call(_context3, function (_, i) {
156
- var dayOfMonth = i + 1;
157
- var date = changeDateInMonth(day, timeZone, dayOfMonth);
147
+ })).call(_context2, (_, i) => {
148
+ const dayOfMonth = i + 1;
149
+ let date = changeDateInMonth(day, timeZone, dayOfMonth);
158
150
 
159
151
  if (parsedTime) {
160
152
  date = changeTime(date, timeZone, parsedTime);
@@ -163,22 +155,22 @@ var createCalendarItems = function createCalendarItems(day, timeString, timeZone
163
155
  return date;
164
156
  });
165
157
  };
166
- var createSuggestedItems = function createSuggestedItems(inputValue, timeZone) {
158
+ const createSuggestedItems = (inputValue, timeZone) => {
167
159
  if (_startsWithInstanceProperty__default["default"](inputValue).call(inputValue, 't')) return [getToday(timeZone)];
168
160
  return [];
169
161
  };
170
- var parseInputText = function parseInputText(text, locale, timeZone) {
171
- var parts = text.split(' ');
172
- var dateString = parts[0];
162
+ const parseInputText = (text, locale, timeZone) => {
163
+ const parts = text.split(' ');
164
+ const dateString = parts[0];
173
165
 
174
- var timeString = _sliceInstanceProperty__default["default"](parts).call(parts, 1).join(' ');
166
+ const timeString = _sliceInstanceProperty__default["default"](parts).call(parts, 1).join(' ');
175
167
 
176
168
  if (!dateString) return '';
177
- var date = moment__default["default"].tz(dateString, moment__default["default"].localeData(locale).longDateFormat('L'), timeZone);
169
+ const date = moment__default["default"].tz(dateString, moment__default["default"].localeData(locale).longDateFormat('L'), timeZone);
178
170
  if (!date.isValid()) return ''; // enable parsing a date only
179
171
 
180
172
  if (!timeString) return date.startOf('day').toISOString();
181
- var parsedTime = utils.parseTime(timeString);
173
+ const parsedTime = utils.parseTime(timeString);
182
174
 
183
175
  if (parsedTime) {
184
176
  date.hours(parsedTime.hours);
@@ -191,13 +183,13 @@ var parseInputText = function parseInputText(text, locale, timeZone) {
191
183
 
192
184
  return '';
193
185
  };
194
- var localizedDateFormatPatternCache = new _Map__default["default"]();
195
- var getLocalizedDateTimeFormatPattern = function getLocalizedDateTimeFormatPattern(locale) {
196
- var _context4, _context5;
186
+ const localizedDateFormatPatternCache = new _Map__default["default"]();
187
+ const getLocalizedDateTimeFormatPattern = function (locale) {
188
+ var _context3, _context4;
197
189
 
198
- var formatType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'date';
190
+ let formatType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'date';
199
191
 
200
- var key = _concatInstanceProperty__default["default"](_context4 = "".concat(locale, "::")).call(_context4, formatType);
192
+ const key = _concatInstanceProperty__default["default"](_context3 = "".concat(locale, "::")).call(_context3, formatType);
201
193
 
202
194
  if (localizedDateFormatPatternCache.has(key)) {
203
195
  return localizedDateFormatPatternCache.get(key);
@@ -206,8 +198,8 @@ var getLocalizedDateTimeFormatPattern = function getLocalizedDateTimeFormatPatte
206
198
  // https://momentjs.com/docs/#/displaying/ ("Localized formats" section)
207
199
 
208
200
 
209
- var localeData = moment__default["default"]().locale(locale).localeData();
210
- var localizedFormat = '';
201
+ const localeData = moment__default["default"]().locale(locale).localeData();
202
+ let localizedFormat = '';
211
203
 
212
204
  switch (formatType) {
213
205
  case 'date':
@@ -219,7 +211,7 @@ var getLocalizedDateTimeFormatPattern = function getLocalizedDateTimeFormatPatte
219
211
  break;
220
212
 
221
213
  case 'full':
222
- localizedFormat = _concatInstanceProperty__default["default"](_context5 = "".concat(localeData.longDateFormat('L'), " - ")).call(_context5, localeData.longDateFormat('LT'));
214
+ localizedFormat = _concatInstanceProperty__default["default"](_context4 = "".concat(localeData.longDateFormat('L'), " - ")).call(_context4, localeData.longDateFormat('LT'));
223
215
  break;
224
216
 
225
217
  default:
@@ -228,19 +220,19 @@ var getLocalizedDateTimeFormatPattern = function getLocalizedDateTimeFormatPatte
228
220
  // and the generic language code (e.g. 'en').
229
221
 
230
222
 
231
- var _locale$split = locale.split('-'),
232
- _locale$split2 = _slicedToArray(_locale$split, 1),
233
- languageCode = _locale$split2[0];
223
+ const _locale$split = locale.split('-'),
224
+ _locale$split2 = _slicedToArray(_locale$split, 1),
225
+ languageCode = _locale$split2[0];
234
226
 
235
- var localeMappings = _Object$entries__default["default"](DATE_FORMAT_LOCALIZED_MAPPINGS[locale] || DATE_FORMAT_LOCALIZED_MAPPINGS[languageCode] || {}); // In case we don't have a translation for the locale, we fallback to the
227
+ const localeMappings = _Object$entries__default["default"](DATE_FORMAT_LOCALIZED_MAPPINGS[locale] || DATE_FORMAT_LOCALIZED_MAPPINGS[languageCode] || {}); // In case we don't have a translation for the locale, we fallback to the
236
228
  // pattern from the moment locale data.
237
229
 
238
230
 
239
- var pattern = localizedFormat;
231
+ let pattern = localizedFormat;
240
232
 
241
233
  if (localeMappings && localeMappings.length > 0) {
242
- pattern = _reduceInstanceProperty__default["default"](localeMappings).call(localeMappings, function (localizedPattern, _ref) {
243
- var _ref2 = _slicedToArray(_ref, 2),
234
+ pattern = _reduceInstanceProperty__default["default"](localeMappings).call(localeMappings, (localizedPattern, _ref) => {
235
+ let _ref2 = _slicedToArray(_ref, 2),
244
236
  token = _ref2[0],
245
237
  mappedValue = _ref2[1];
246
238
 
@@ -253,7 +245,7 @@ var getLocalizedDateTimeFormatPattern = function getLocalizedDateTimeFormatPatte
253
245
  };
254
246
 
255
247
  // NOTE: This string will be replaced on build time with the package version.
256
- var version = "15.15.0";
248
+ var version = "16.0.0";
257
249
 
258
250
  exports.changeDateInMonth = changeDateInMonth;
259
251
  exports.changeMonth = changeMonth;
@@ -1,5 +1,4 @@
1
1
  import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
2
- import _toConsumableArray from '@babel/runtime-corejs3/helpers/esm/toConsumableArray';
3
2
  import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
4
3
  import _sliceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/slice';
5
4
  import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
@@ -10,12 +9,9 @@ import _Object$entries from '@babel/runtime-corejs3/core-js-stable/object/entrie
10
9
  import _reduceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/reduce';
11
10
  import moment from 'moment-timezone';
12
11
  import { parseTime } from '@commercetools-uikit/utils';
13
- import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
14
-
15
- var _en, _de, _es, _fr, _zhCN;
16
12
 
17
13
  // Reference: https://momentjs.com/docs/#/displaying/format/
18
- var formatToken = {
14
+ const formatToken = {
19
15
  D: 'D',
20
16
  // NUMERIC_SINGLE_DAY
21
17
  DD: 'DD',
@@ -48,22 +44,42 @@ var formatToken = {
48
44
  // We just need to provide the translation for the characters that are different
49
45
  // For instance, in english we don't need to translate date characters as
50
46
  // they are the same as the pattern characters
51
- var DATE_FORMAT_LOCALIZED_MAPPINGS = {
52
- en: (_en = {}, _defineProperty(_en, formatToken.h, 'HH'), _defineProperty(_en, formatToken.A, 'AM/PM'), _en),
53
- de: (_de = {}, _defineProperty(_de, formatToken.DD, 'TT'), _defineProperty(_de, formatToken.YYYY, 'JJJJ'), _defineProperty(_de, formatToken.HH, 'SS'), _de),
54
- es: (_es = {}, _defineProperty(_es, formatToken.H, 'HH'), _defineProperty(_es, formatToken.YYYY, 'AAAA'), _es),
55
- fr: (_fr = {}, _defineProperty(_fr, formatToken.DD, 'JJ'), _defineProperty(_fr, formatToken.YYYY, 'AAAA'), _fr),
56
- 'zh-CN': (_zhCN = {}, _defineProperty(_zhCN, formatToken.HH, '小时'), _defineProperty(_zhCN, formatToken.mm, '分钟'), _defineProperty(_zhCN, formatToken.DD, '日'), _defineProperty(_zhCN, formatToken.MM, '月'), _defineProperty(_zhCN, formatToken.YYYY, '年'), _zhCN)
47
+ const DATE_FORMAT_LOCALIZED_MAPPINGS = {
48
+ en: {
49
+ // MM/DD/YYYY - h:mm A -> MM/DD/YYYY - HH:mm AM/PM
50
+ [formatToken.h]: 'HH',
51
+ [formatToken.A]: 'AM/PM'
52
+ },
53
+ de: {
54
+ // DD.MM.YYYY - HH:mm -> TT.MM.JJJJ - SS:mm
55
+ [formatToken.DD]: 'TT',
56
+ [formatToken.YYYY]: 'JJJJ',
57
+ [formatToken.HH]: 'SS'
58
+ },
59
+ es: {
60
+ // DD/MM/YYYY - H:mm -> DD/MM/AAAA - HH:mm
61
+ [formatToken.H]: 'HH',
62
+ [formatToken.YYYY]: 'AAAA'
63
+ },
64
+ fr: {
65
+ // DD/MM/YYYY - HH:mm -> JJ/MM/AAAA - HH:mm
66
+ [formatToken.DD]: 'JJ',
67
+ [formatToken.YYYY]: 'AAAA'
68
+ },
69
+ 'zh-CN': {
70
+ // YYYY/MM/DD - HH:mm -> 年/月/日 - 小时:分钟
71
+ [formatToken.HH]: '小时',
72
+ [formatToken.mm]: '分钟',
73
+ [formatToken.DD]: '日',
74
+ [formatToken.MM]: '月',
75
+ [formatToken.YYYY]: '年'
76
+ }
57
77
  };
58
78
 
59
- var getDaysInMonth = function getDaysInMonth(day, timeZone) {
60
- return moment.tz(day, timeZone).daysInMonth();
61
- };
62
- var changeDateInMonth = function changeDateInMonth(day, timeZone, dayOfMonth) {
63
- return moment.tz(day, timeZone).date(dayOfMonth).toISOString();
64
- };
65
- var changeTime = function changeTime(dateString, timeZone, parsedTime) {
66
- var date = moment.tz(dateString, timeZone);
79
+ const getDaysInMonth = (day, timeZone) => moment.tz(day, timeZone).daysInMonth();
80
+ const changeDateInMonth = (day, timeZone, dayOfMonth) => moment.tz(day, timeZone).date(dayOfMonth).toISOString();
81
+ const changeTime = (dateString, timeZone, parsedTime) => {
82
+ const date = moment.tz(dateString, timeZone);
67
83
  date.hours(parsedTime.hours);
68
84
  date.minutes(parsedTime.minutes);
69
85
  date.seconds(parsedTime.seconds);
@@ -71,74 +87,50 @@ var changeTime = function changeTime(dateString, timeZone, parsedTime) {
71
87
  date.milliseconds(parsedTime.milliseconds);
72
88
  return date.toISOString();
73
89
  };
74
- var getPreviousDay = function getPreviousDay(day) {
75
- return moment(day).subtract(1, 'day').format('YYYY-MM-DD');
76
- };
77
- var formatTime = function formatTime(day, locale, timeZone) {
78
- var date = moment.tz(day, timeZone).locale(locale);
90
+ const getPreviousDay = day => moment(day).subtract(1, 'day').format('YYYY-MM-DD');
91
+ const formatTime = (day, locale, timeZone) => {
92
+ const date = moment.tz(day, timeZone).locale(locale);
79
93
  if (date.milliseconds()) return date.format('HH:mm:ss.SSS');
80
94
  if (date.seconds()) return date.format('LTS'); // 5:13:51 PM
81
95
 
82
96
  return date.format('LT'); // 5:13 PM
83
97
  };
84
- var formatDate = function formatDate(day, locale, timeZone) {
98
+ const formatDate = (day, locale, timeZone) => {
85
99
  var _context;
86
100
 
87
- var date = moment(day, moment.ISO_8601, locale).tz(timeZone).format('L');
88
- var time = formatTime(day, locale, timeZone);
101
+ const date = moment(day, moment.ISO_8601, locale).tz(timeZone).format('L');
102
+ const time = formatTime(day, locale, timeZone);
89
103
  return _concatInstanceProperty(_context = "".concat(date, " ")).call(_context, time);
90
104
  };
91
- var getDateInMonth = function getDateInMonth(day, timeZone) {
92
- return moment.tz(day, timeZone).date();
93
- };
94
- var getToday = function getToday(timeZone) {
95
- return moment.tz(timeZone).startOf('day').toISOString();
96
- };
97
- var changeMonth = function changeMonth(day, timeZone, delta) {
98
- return moment.tz(day, timeZone).add(delta, 'month').toISOString();
99
- };
100
- var getPaddingDayCount = function getPaddingDayCount(day, locale, timeZone) {
101
- var firstDayOfWeek = moment.localeData(locale).firstDayOfWeek();
102
- var firstDayOfMonth = moment.tz(day, timeZone).startOf('month').day(); // ensure number is always positive
105
+ const getDateInMonth = (day, timeZone) => moment.tz(day, timeZone).date();
106
+ const getToday = timeZone => moment.tz(timeZone).startOf('day').toISOString();
107
+ const changeMonth = (day, timeZone, delta) => moment.tz(day, timeZone).add(delta, 'month').toISOString();
108
+ const getPaddingDayCount = (day, locale, timeZone) => {
109
+ const firstDayOfWeek = moment.localeData(locale).firstDayOfWeek();
110
+ const firstDayOfMonth = moment.tz(day, timeZone).startOf('month').day(); // ensure number is always positive
103
111
 
104
112
  return (firstDayOfMonth - firstDayOfWeek + 7) % 7;
105
113
  };
106
- var getWeekdayNames = function getWeekdayNames(locale) {
114
+ const getWeekdayNames = locale => {
115
+ const weekDays = moment.localeData(locale).weekdaysMin();
116
+ const firstDay = moment.localeData(locale).firstDayOfWeek();
117
+ return [..._sliceInstanceProperty(weekDays).call(weekDays, firstDay), ..._sliceInstanceProperty(weekDays).call(weekDays, 0, firstDay)];
118
+ };
119
+ const getStartOf = (day, timeZone) => moment.tz(day, timeZone).startOf('day').toISOString();
120
+ const getMonthCalendarLabel = (day, locale) => moment(day, moment.ISO_8601, locale).format('MMMM');
121
+ const getYearCalendarLabel = (day, locale) => moment(day, moment.ISO_8601, locale).format('YYYY');
122
+ const isSameDay = (a, b) => moment(a).isSame(b, 'day');
123
+ const getCalendarDayLabel = (day, timeZone) => moment.tz(day, timeZone).format('D');
124
+ const createItemDateTimeToString = (locale, timeZone) => item => item ? formatDate(item, locale, timeZone) : '';
125
+ const createCalendarItems = (day, timeString, timeZone) => {
107
126
  var _context2;
108
127
 
109
- var weekDays = moment.localeData(locale).weekdaysMin();
110
- var firstDay = moment.localeData(locale).firstDayOfWeek();
111
- return _concatInstanceProperty(_context2 = []).call(_context2, _toConsumableArray(_sliceInstanceProperty(weekDays).call(weekDays, firstDay)), _toConsumableArray(_sliceInstanceProperty(weekDays).call(weekDays, 0, firstDay)));
112
- };
113
- var getStartOf = function getStartOf(day, timeZone) {
114
- return moment.tz(day, timeZone).startOf('day').toISOString();
115
- };
116
- var getMonthCalendarLabel = function getMonthCalendarLabel(day, locale) {
117
- return moment(day, moment.ISO_8601, locale).format('MMMM');
118
- };
119
- var getYearCalendarLabel = function getYearCalendarLabel(day, locale) {
120
- return moment(day, moment.ISO_8601, locale).format('YYYY');
121
- };
122
- var isSameDay = function isSameDay(a, b) {
123
- return moment(a).isSame(b, 'day');
124
- };
125
- var getCalendarDayLabel = function getCalendarDayLabel(day, timeZone) {
126
- return moment.tz(day, timeZone).format('D');
127
- };
128
- var createItemDateTimeToString = function createItemDateTimeToString(locale, timeZone) {
129
- return function (item) {
130
- return item ? formatDate(item, locale, timeZone) : '';
131
- };
132
- };
133
- var createCalendarItems = function createCalendarItems(day, timeString, timeZone) {
134
- var _context3;
135
-
136
- var parsedTime = parseTime(timeString);
137
- return _mapInstanceProperty(_context3 = _Array$from({
128
+ const parsedTime = parseTime(timeString);
129
+ return _mapInstanceProperty(_context2 = _Array$from({
138
130
  length: getDaysInMonth(day, timeZone)
139
- })).call(_context3, function (_, i) {
140
- var dayOfMonth = i + 1;
141
- var date = changeDateInMonth(day, timeZone, dayOfMonth);
131
+ })).call(_context2, (_, i) => {
132
+ const dayOfMonth = i + 1;
133
+ let date = changeDateInMonth(day, timeZone, dayOfMonth);
142
134
 
143
135
  if (parsedTime) {
144
136
  date = changeTime(date, timeZone, parsedTime);
@@ -147,22 +139,22 @@ var createCalendarItems = function createCalendarItems(day, timeString, timeZone
147
139
  return date;
148
140
  });
149
141
  };
150
- var createSuggestedItems = function createSuggestedItems(inputValue, timeZone) {
142
+ const createSuggestedItems = (inputValue, timeZone) => {
151
143
  if (_startsWithInstanceProperty(inputValue).call(inputValue, 't')) return [getToday(timeZone)];
152
144
  return [];
153
145
  };
154
- var parseInputText = function parseInputText(text, locale, timeZone) {
155
- var parts = text.split(' ');
156
- var dateString = parts[0];
146
+ const parseInputText = (text, locale, timeZone) => {
147
+ const parts = text.split(' ');
148
+ const dateString = parts[0];
157
149
 
158
- var timeString = _sliceInstanceProperty(parts).call(parts, 1).join(' ');
150
+ const timeString = _sliceInstanceProperty(parts).call(parts, 1).join(' ');
159
151
 
160
152
  if (!dateString) return '';
161
- var date = moment.tz(dateString, moment.localeData(locale).longDateFormat('L'), timeZone);
153
+ const date = moment.tz(dateString, moment.localeData(locale).longDateFormat('L'), timeZone);
162
154
  if (!date.isValid()) return ''; // enable parsing a date only
163
155
 
164
156
  if (!timeString) return date.startOf('day').toISOString();
165
- var parsedTime = parseTime(timeString);
157
+ const parsedTime = parseTime(timeString);
166
158
 
167
159
  if (parsedTime) {
168
160
  date.hours(parsedTime.hours);
@@ -175,13 +167,13 @@ var parseInputText = function parseInputText(text, locale, timeZone) {
175
167
 
176
168
  return '';
177
169
  };
178
- var localizedDateFormatPatternCache = new _Map();
179
- var getLocalizedDateTimeFormatPattern = function getLocalizedDateTimeFormatPattern(locale) {
180
- var _context4, _context5;
170
+ const localizedDateFormatPatternCache = new _Map();
171
+ const getLocalizedDateTimeFormatPattern = function (locale) {
172
+ var _context3, _context4;
181
173
 
182
- var formatType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'date';
174
+ let formatType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'date';
183
175
 
184
- var key = _concatInstanceProperty(_context4 = "".concat(locale, "::")).call(_context4, formatType);
176
+ const key = _concatInstanceProperty(_context3 = "".concat(locale, "::")).call(_context3, formatType);
185
177
 
186
178
  if (localizedDateFormatPatternCache.has(key)) {
187
179
  return localizedDateFormatPatternCache.get(key);
@@ -190,8 +182,8 @@ var getLocalizedDateTimeFormatPattern = function getLocalizedDateTimeFormatPatte
190
182
  // https://momentjs.com/docs/#/displaying/ ("Localized formats" section)
191
183
 
192
184
 
193
- var localeData = moment().locale(locale).localeData();
194
- var localizedFormat = '';
185
+ const localeData = moment().locale(locale).localeData();
186
+ let localizedFormat = '';
195
187
 
196
188
  switch (formatType) {
197
189
  case 'date':
@@ -203,7 +195,7 @@ var getLocalizedDateTimeFormatPattern = function getLocalizedDateTimeFormatPatte
203
195
  break;
204
196
 
205
197
  case 'full':
206
- localizedFormat = _concatInstanceProperty(_context5 = "".concat(localeData.longDateFormat('L'), " - ")).call(_context5, localeData.longDateFormat('LT'));
198
+ localizedFormat = _concatInstanceProperty(_context4 = "".concat(localeData.longDateFormat('L'), " - ")).call(_context4, localeData.longDateFormat('LT'));
207
199
  break;
208
200
 
209
201
  default:
@@ -212,19 +204,19 @@ var getLocalizedDateTimeFormatPattern = function getLocalizedDateTimeFormatPatte
212
204
  // and the generic language code (e.g. 'en').
213
205
 
214
206
 
215
- var _locale$split = locale.split('-'),
216
- _locale$split2 = _slicedToArray(_locale$split, 1),
217
- languageCode = _locale$split2[0];
207
+ const _locale$split = locale.split('-'),
208
+ _locale$split2 = _slicedToArray(_locale$split, 1),
209
+ languageCode = _locale$split2[0];
218
210
 
219
- var localeMappings = _Object$entries(DATE_FORMAT_LOCALIZED_MAPPINGS[locale] || DATE_FORMAT_LOCALIZED_MAPPINGS[languageCode] || {}); // In case we don't have a translation for the locale, we fallback to the
211
+ const localeMappings = _Object$entries(DATE_FORMAT_LOCALIZED_MAPPINGS[locale] || DATE_FORMAT_LOCALIZED_MAPPINGS[languageCode] || {}); // In case we don't have a translation for the locale, we fallback to the
220
212
  // pattern from the moment locale data.
221
213
 
222
214
 
223
- var pattern = localizedFormat;
215
+ let pattern = localizedFormat;
224
216
 
225
217
  if (localeMappings && localeMappings.length > 0) {
226
- pattern = _reduceInstanceProperty(localeMappings).call(localeMappings, function (localizedPattern, _ref) {
227
- var _ref2 = _slicedToArray(_ref, 2),
218
+ pattern = _reduceInstanceProperty(localeMappings).call(localeMappings, (localizedPattern, _ref) => {
219
+ let _ref2 = _slicedToArray(_ref, 2),
228
220
  token = _ref2[0],
229
221
  mappedValue = _ref2[1];
230
222
 
@@ -237,6 +229,6 @@ var getLocalizedDateTimeFormatPattern = function getLocalizedDateTimeFormatPatte
237
229
  };
238
230
 
239
231
  // NOTE: This string will be replaced on build time with the package version.
240
- var version = "15.15.0";
232
+ var version = "16.0.0";
241
233
 
242
234
  export { changeDateInMonth, changeMonth, changeTime, createCalendarItems, createItemDateTimeToString, createSuggestedItems, formatDate, formatTime, getCalendarDayLabel, getDateInMonth, getDaysInMonth, getLocalizedDateTimeFormatPattern, getMonthCalendarLabel, getPaddingDayCount, getPreviousDay, getStartOf, getToday, getWeekdayNames, getYearCalendarLabel, isSameDay, parseInputText, version };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@commercetools-uikit/calendar-time-utils",
3
3
  "description": "Utilities to work with time values for a calendar.",
4
- "version": "15.15.0",
4
+ "version": "16.0.0",
5
5
  "bugs": "https://github.com/commercetools/ui-kit/issues",
6
6
  "repository": {
7
7
  "type": "git",
@@ -21,10 +21,10 @@
21
21
  "dependencies": {
22
22
  "@babel/runtime": "^7.20.13",
23
23
  "@babel/runtime-corejs3": "^7.20.13",
24
- "@commercetools-uikit/utils": "15.15.0"
24
+ "@commercetools-uikit/utils": "16.0.0"
25
25
  },
26
26
  "devDependencies": {
27
- "moment-timezone": "0.5.41"
27
+ "moment-timezone": "0.5.43"
28
28
  },
29
29
  "peerDependencies": {
30
30
  "moment-timezone": "0.5.x"