@commercetools-uikit/calendar-time-utils 19.11.0 → 19.12.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.
@@ -4,7 +4,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
6
6
  var _parseInt = require('@babel/runtime-corejs3/core-js-stable/parse-int');
7
- 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');
10
9
  var _Array$from = require('@babel/runtime-corejs3/core-js-stable/array/from');
@@ -18,7 +17,6 @@ var utils = require('@commercetools-uikit/utils');
18
17
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
19
18
 
20
19
  var _parseInt__default = /*#__PURE__*/_interopDefault(_parseInt);
21
- var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
22
20
  var _sliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_sliceInstanceProperty);
23
21
  var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
24
22
  var _Array$from__default = /*#__PURE__*/_interopDefault(_Array$from);
@@ -122,7 +120,7 @@ const formatDefaultTime = (time, locale) => {
122
120
  });
123
121
  return moment__default["default"](today).locale(locale).format('LT'); // 5:13 PM
124
122
  } else {
125
- process.env.NODE_ENV !== "production" ? utils.warning(false, "DataTimeInput: the specified defaultDaySelectionTime '".concat(time, "' is not supported. The format should be hh:mm, e.g. 11:10. Using 00:00 as default time.")) : void 0;
123
+ process.env.NODE_ENV !== "production" ? utils.warning(false, `DataTimeInput: the specified defaultDaySelectionTime '${time}' is not supported. The format should be hh:mm, e.g. 11:10. Using 00:00 as default time.`) : void 0;
126
124
  today.set({
127
125
  hour: 0,
128
126
  minute: 0
@@ -137,10 +135,9 @@ const formatTime = (day, locale, timeZone) => {
137
135
  return date.format('LT'); // 5:13 PM
138
136
  };
139
137
  const formatDate = (day, locale, timeZone) => {
140
- var _context;
141
138
  const date = moment__default["default"](day, moment__default["default"].ISO_8601, locale).tz(timeZone).format('L');
142
139
  const time = formatTime(day, locale, timeZone);
143
- return _concatInstanceProperty__default["default"](_context = "".concat(date, " ")).call(_context, time);
140
+ return `${date} ${time}`;
144
141
  };
145
142
  const getDateInMonth = (day, timeZone) => moment__default["default"].tz(day, timeZone).date();
146
143
  const getToday = timeZone => moment__default["default"].tz(timeZone).startOf('day').toISOString();
@@ -164,11 +161,11 @@ const isSameDay = (a, b) => moment__default["default"](a).isSame(b, 'day');
164
161
  const getCalendarDayLabel = (day, timeZone) => moment__default["default"].tz(day, timeZone).format('D');
165
162
  const createItemDateTimeToString = (locale, timeZone) => item => item ? formatDate(item, locale, timeZone) : '';
166
163
  const createCalendarItems = (day, timeString, timeZone) => {
167
- var _context2;
164
+ var _context;
168
165
  const parsedTime = utils.parseTime(timeString);
169
- return _mapInstanceProperty__default["default"](_context2 = _Array$from__default["default"]({
166
+ return _mapInstanceProperty__default["default"](_context = _Array$from__default["default"]({
170
167
  length: getDaysInMonth(day, timeZone)
171
- })).call(_context2, (_, i) => {
168
+ })).call(_context, (_, i) => {
172
169
  const dayOfMonth = i + 1;
173
170
  let date = changeDateInMonth(day, timeZone, dayOfMonth);
174
171
  if (parsedTime) {
@@ -204,9 +201,8 @@ const parseInputText = (text, locale, timeZone) => {
204
201
  };
205
202
  const localizedDateFormatPatternCache = new _Map__default["default"]();
206
203
  const getLocalizedDateTimeFormatPattern = function (locale) {
207
- var _context3, _context4;
208
204
  let formatType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'date';
209
- const key = _concatInstanceProperty__default["default"](_context3 = "".concat(locale, "::")).call(_context3, formatType);
205
+ const key = `${locale}::${formatType}`;
210
206
  if (localizedDateFormatPatternCache.has(key)) {
211
207
  return localizedDateFormatPatternCache.get(key);
212
208
  }
@@ -224,10 +220,10 @@ const getLocalizedDateTimeFormatPattern = function (locale) {
224
220
  localizedFormat = localeData.longDateFormat('LT');
225
221
  break;
226
222
  case 'full':
227
- localizedFormat = _concatInstanceProperty__default["default"](_context4 = "".concat(localeData.longDateFormat('L'), " - ")).call(_context4, localeData.longDateFormat('LT'));
223
+ localizedFormat = `${localeData.longDateFormat('L')} - ${localeData.longDateFormat('LT')}`;
228
224
  break;
229
225
  default:
230
- throw new Error("CalendarTime.getLocalizedDateTimeFormatPattern: Unknown format type '".concat(formatType, "'"));
226
+ throw new Error(`CalendarTime.getLocalizedDateTimeFormatPattern: Unknown format type '${formatType}'`);
231
227
  }
232
228
 
233
229
  // We try to get the localization both with the whole locale (e.g. 'en-GB')
@@ -4,7 +4,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
6
6
  var _parseInt = require('@babel/runtime-corejs3/core-js-stable/parse-int');
7
- 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');
10
9
  var _Array$from = require('@babel/runtime-corejs3/core-js-stable/array/from');
@@ -18,7 +17,6 @@ var utils = require('@commercetools-uikit/utils');
18
17
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
19
18
 
20
19
  var _parseInt__default = /*#__PURE__*/_interopDefault(_parseInt);
21
- var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
22
20
  var _sliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_sliceInstanceProperty);
23
21
  var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
24
22
  var _Array$from__default = /*#__PURE__*/_interopDefault(_Array$from);
@@ -136,10 +134,9 @@ const formatTime = (day, locale, timeZone) => {
136
134
  return date.format('LT'); // 5:13 PM
137
135
  };
138
136
  const formatDate = (day, locale, timeZone) => {
139
- var _context;
140
137
  const date = moment__default["default"](day, moment__default["default"].ISO_8601, locale).tz(timeZone).format('L');
141
138
  const time = formatTime(day, locale, timeZone);
142
- return _concatInstanceProperty__default["default"](_context = "".concat(date, " ")).call(_context, time);
139
+ return `${date} ${time}`;
143
140
  };
144
141
  const getDateInMonth = (day, timeZone) => moment__default["default"].tz(day, timeZone).date();
145
142
  const getToday = timeZone => moment__default["default"].tz(timeZone).startOf('day').toISOString();
@@ -163,11 +160,11 @@ const isSameDay = (a, b) => moment__default["default"](a).isSame(b, 'day');
163
160
  const getCalendarDayLabel = (day, timeZone) => moment__default["default"].tz(day, timeZone).format('D');
164
161
  const createItemDateTimeToString = (locale, timeZone) => item => item ? formatDate(item, locale, timeZone) : '';
165
162
  const createCalendarItems = (day, timeString, timeZone) => {
166
- var _context2;
163
+ var _context;
167
164
  const parsedTime = utils.parseTime(timeString);
168
- return _mapInstanceProperty__default["default"](_context2 = _Array$from__default["default"]({
165
+ return _mapInstanceProperty__default["default"](_context = _Array$from__default["default"]({
169
166
  length: getDaysInMonth(day, timeZone)
170
- })).call(_context2, (_, i) => {
167
+ })).call(_context, (_, i) => {
171
168
  const dayOfMonth = i + 1;
172
169
  let date = changeDateInMonth(day, timeZone, dayOfMonth);
173
170
  if (parsedTime) {
@@ -203,9 +200,8 @@ const parseInputText = (text, locale, timeZone) => {
203
200
  };
204
201
  const localizedDateFormatPatternCache = new _Map__default["default"]();
205
202
  const getLocalizedDateTimeFormatPattern = function (locale) {
206
- var _context3, _context4;
207
203
  let formatType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'date';
208
- const key = _concatInstanceProperty__default["default"](_context3 = "".concat(locale, "::")).call(_context3, formatType);
204
+ const key = `${locale}::${formatType}`;
209
205
  if (localizedDateFormatPatternCache.has(key)) {
210
206
  return localizedDateFormatPatternCache.get(key);
211
207
  }
@@ -223,10 +219,10 @@ const getLocalizedDateTimeFormatPattern = function (locale) {
223
219
  localizedFormat = localeData.longDateFormat('LT');
224
220
  break;
225
221
  case 'full':
226
- localizedFormat = _concatInstanceProperty__default["default"](_context4 = "".concat(localeData.longDateFormat('L'), " - ")).call(_context4, localeData.longDateFormat('LT'));
222
+ localizedFormat = `${localeData.longDateFormat('L')} - ${localeData.longDateFormat('LT')}`;
227
223
  break;
228
224
  default:
229
- throw new Error("CalendarTime.getLocalizedDateTimeFormatPattern: Unknown format type '".concat(formatType, "'"));
225
+ throw new Error(`CalendarTime.getLocalizedDateTimeFormatPattern: Unknown format type '${formatType}'`);
230
226
  }
231
227
 
232
228
  // We try to get the localization both with the whole locale (e.g. 'en-GB')
@@ -1,6 +1,5 @@
1
1
  import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
2
2
  import _parseInt from '@babel/runtime-corejs3/core-js-stable/parse-int';
3
- 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';
6
5
  import _Array$from from '@babel/runtime-corejs3/core-js-stable/array/from';
@@ -105,7 +104,7 @@ const formatDefaultTime = (time, locale) => {
105
104
  });
106
105
  return moment(today).locale(locale).format('LT'); // 5:13 PM
107
106
  } else {
108
- process.env.NODE_ENV !== "production" ? warning(false, "DataTimeInput: the specified defaultDaySelectionTime '".concat(time, "' is not supported. The format should be hh:mm, e.g. 11:10. Using 00:00 as default time.")) : void 0;
107
+ process.env.NODE_ENV !== "production" ? warning(false, `DataTimeInput: the specified defaultDaySelectionTime '${time}' is not supported. The format should be hh:mm, e.g. 11:10. Using 00:00 as default time.`) : void 0;
109
108
  today.set({
110
109
  hour: 0,
111
110
  minute: 0
@@ -120,10 +119,9 @@ const formatTime = (day, locale, timeZone) => {
120
119
  return date.format('LT'); // 5:13 PM
121
120
  };
122
121
  const formatDate = (day, locale, timeZone) => {
123
- var _context;
124
122
  const date = moment(day, moment.ISO_8601, locale).tz(timeZone).format('L');
125
123
  const time = formatTime(day, locale, timeZone);
126
- return _concatInstanceProperty(_context = "".concat(date, " ")).call(_context, time);
124
+ return `${date} ${time}`;
127
125
  };
128
126
  const getDateInMonth = (day, timeZone) => moment.tz(day, timeZone).date();
129
127
  const getToday = timeZone => moment.tz(timeZone).startOf('day').toISOString();
@@ -147,11 +145,11 @@ const isSameDay = (a, b) => moment(a).isSame(b, 'day');
147
145
  const getCalendarDayLabel = (day, timeZone) => moment.tz(day, timeZone).format('D');
148
146
  const createItemDateTimeToString = (locale, timeZone) => item => item ? formatDate(item, locale, timeZone) : '';
149
147
  const createCalendarItems = (day, timeString, timeZone) => {
150
- var _context2;
148
+ var _context;
151
149
  const parsedTime = parseTime(timeString);
152
- return _mapInstanceProperty(_context2 = _Array$from({
150
+ return _mapInstanceProperty(_context = _Array$from({
153
151
  length: getDaysInMonth(day, timeZone)
154
- })).call(_context2, (_, i) => {
152
+ })).call(_context, (_, i) => {
155
153
  const dayOfMonth = i + 1;
156
154
  let date = changeDateInMonth(day, timeZone, dayOfMonth);
157
155
  if (parsedTime) {
@@ -187,9 +185,8 @@ const parseInputText = (text, locale, timeZone) => {
187
185
  };
188
186
  const localizedDateFormatPatternCache = new _Map();
189
187
  const getLocalizedDateTimeFormatPattern = function (locale) {
190
- var _context3, _context4;
191
188
  let formatType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'date';
192
- const key = _concatInstanceProperty(_context3 = "".concat(locale, "::")).call(_context3, formatType);
189
+ const key = `${locale}::${formatType}`;
193
190
  if (localizedDateFormatPatternCache.has(key)) {
194
191
  return localizedDateFormatPatternCache.get(key);
195
192
  }
@@ -207,10 +204,10 @@ const getLocalizedDateTimeFormatPattern = function (locale) {
207
204
  localizedFormat = localeData.longDateFormat('LT');
208
205
  break;
209
206
  case 'full':
210
- localizedFormat = _concatInstanceProperty(_context4 = "".concat(localeData.longDateFormat('L'), " - ")).call(_context4, localeData.longDateFormat('LT'));
207
+ localizedFormat = `${localeData.longDateFormat('L')} - ${localeData.longDateFormat('LT')}`;
211
208
  break;
212
209
  default:
213
- throw new Error("CalendarTime.getLocalizedDateTimeFormatPattern: Unknown format type '".concat(formatType, "'"));
210
+ throw new Error(`CalendarTime.getLocalizedDateTimeFormatPattern: Unknown format type '${formatType}'`);
214
211
  }
215
212
 
216
213
  // We try to get the localization both with the whole locale (e.g. 'en-GB')
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": "19.11.0",
4
+ "version": "19.12.0",
5
5
  "bugs": "https://github.com/commercetools/ui-kit/issues",
6
6
  "repository": {
7
7
  "type": "git",
@@ -21,7 +21,7 @@
21
21
  "dependencies": {
22
22
  "@babel/runtime": "^7.20.13",
23
23
  "@babel/runtime-corejs3": "^7.20.13",
24
- "@commercetools-uikit/utils": "19.11.0"
24
+ "@commercetools-uikit/utils": "19.12.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "moment-timezone": "0.5.45"