@commercetools-uikit/calendar-time-utils 20.5.0 → 20.6.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');
|
|
@@ -19,7 +18,6 @@ var utils = require('@commercetools-uikit/utils');
|
|
|
19
18
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
20
19
|
|
|
21
20
|
var _parseInt__default = /*#__PURE__*/_interopDefault(_parseInt);
|
|
22
|
-
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
23
21
|
var _sliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_sliceInstanceProperty);
|
|
24
22
|
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
25
23
|
var _Array$from__default = /*#__PURE__*/_interopDefault(_Array$from);
|
|
@@ -116,7 +114,7 @@ const formatDefaultTime = (time, locale) => {
|
|
|
116
114
|
});
|
|
117
115
|
return moment__default["default"](today).locale(locale).format('LT'); // 5:13 PM
|
|
118
116
|
} else {
|
|
119
|
-
process.env.NODE_ENV !== "production" ? utils.warning(false,
|
|
117
|
+
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;
|
|
120
118
|
today.set({
|
|
121
119
|
hour: 0,
|
|
122
120
|
minute: 0
|
|
@@ -131,10 +129,9 @@ const formatTime = (day, locale, timeZone) => {
|
|
|
131
129
|
return date.format('LT'); // 5:13 PM
|
|
132
130
|
};
|
|
133
131
|
const formatDate = (day, locale, timeZone) => {
|
|
134
|
-
var _context;
|
|
135
132
|
const date = moment__default["default"](day, moment__default["default"].ISO_8601, locale).tz(timeZone).format('L');
|
|
136
133
|
const time = formatTime(day, locale, timeZone);
|
|
137
|
-
return
|
|
134
|
+
return `${date} ${time}`;
|
|
138
135
|
};
|
|
139
136
|
const getDateInMonth = (day, timeZone) => moment__default["default"].tz(day, timeZone).date();
|
|
140
137
|
const getToday = timeZone => moment__default["default"].tz(timeZone).startOf('day').toISOString();
|
|
@@ -158,11 +155,11 @@ const isSameDay = (a, b) => moment__default["default"](a).isSame(b, 'day');
|
|
|
158
155
|
const getCalendarDayLabel = (day, timeZone) => moment__default["default"].tz(day, timeZone).format('D');
|
|
159
156
|
const createItemDateTimeToString = (locale, timeZone) => item => item ? formatDate(item, locale, timeZone) : '';
|
|
160
157
|
const createCalendarItems = (day, timeString, timeZone) => {
|
|
161
|
-
var
|
|
158
|
+
var _context;
|
|
162
159
|
const parsedTime = utils.parseTime(timeString);
|
|
163
|
-
return _mapInstanceProperty__default["default"](
|
|
160
|
+
return _mapInstanceProperty__default["default"](_context = _Array$from__default["default"]({
|
|
164
161
|
length: getDaysInMonth(day, timeZone)
|
|
165
|
-
})).call(
|
|
162
|
+
})).call(_context, (_, i) => {
|
|
166
163
|
const dayOfMonth = i + 1;
|
|
167
164
|
let date = changeDateInMonth(day, timeZone, dayOfMonth);
|
|
168
165
|
if (parsedTime) {
|
|
@@ -250,9 +247,8 @@ const getIntlTimePattern = locale => {
|
|
|
250
247
|
};
|
|
251
248
|
const localizedDateFormatPatternCache = new _Map__default["default"]();
|
|
252
249
|
const getLocalizedDateTimeFormatPattern = function (locale) {
|
|
253
|
-
var _context3, _context4;
|
|
254
250
|
let formatType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'date';
|
|
255
|
-
const key =
|
|
251
|
+
const key = `${locale}::${formatType}`;
|
|
256
252
|
if (localizedDateFormatPatternCache.has(key)) {
|
|
257
253
|
return localizedDateFormatPatternCache.get(key);
|
|
258
254
|
}
|
|
@@ -265,10 +261,10 @@ const getLocalizedDateTimeFormatPattern = function (locale) {
|
|
|
265
261
|
localizedFormat = getIntlTimePattern(locale);
|
|
266
262
|
break;
|
|
267
263
|
case 'full':
|
|
268
|
-
localizedFormat =
|
|
264
|
+
localizedFormat = `${getIntlDatePattern(locale)} - ${getIntlTimePattern(locale)}`;
|
|
269
265
|
break;
|
|
270
266
|
default:
|
|
271
|
-
throw new Error(
|
|
267
|
+
throw new Error(`CalendarTime.getLocalizedDateTimeFormatPattern: Unknown format type '${formatType}'`);
|
|
272
268
|
}
|
|
273
269
|
|
|
274
270
|
// We try to get the localization both with the whole locale (e.g. 'en-GB')
|
|
@@ -294,7 +290,7 @@ const getLocalizedDateTimeFormatPattern = function (locale) {
|
|
|
294
290
|
};
|
|
295
291
|
|
|
296
292
|
// NOTE: This string will be replaced on build time with the package version.
|
|
297
|
-
var version = "20.
|
|
293
|
+
var version = "20.6.0";
|
|
298
294
|
|
|
299
295
|
exports.changeDateInMonth = changeDateInMonth;
|
|
300
296
|
exports.changeMonth = changeMonth;
|
|
@@ -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');
|
|
@@ -19,7 +18,6 @@ var utils = require('@commercetools-uikit/utils');
|
|
|
19
18
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
20
19
|
|
|
21
20
|
var _parseInt__default = /*#__PURE__*/_interopDefault(_parseInt);
|
|
22
|
-
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
23
21
|
var _sliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_sliceInstanceProperty);
|
|
24
22
|
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
25
23
|
var _Array$from__default = /*#__PURE__*/_interopDefault(_Array$from);
|
|
@@ -130,10 +128,9 @@ const formatTime = (day, locale, timeZone) => {
|
|
|
130
128
|
return date.format('LT'); // 5:13 PM
|
|
131
129
|
};
|
|
132
130
|
const formatDate = (day, locale, timeZone) => {
|
|
133
|
-
var _context;
|
|
134
131
|
const date = moment__default["default"](day, moment__default["default"].ISO_8601, locale).tz(timeZone).format('L');
|
|
135
132
|
const time = formatTime(day, locale, timeZone);
|
|
136
|
-
return
|
|
133
|
+
return `${date} ${time}`;
|
|
137
134
|
};
|
|
138
135
|
const getDateInMonth = (day, timeZone) => moment__default["default"].tz(day, timeZone).date();
|
|
139
136
|
const getToday = timeZone => moment__default["default"].tz(timeZone).startOf('day').toISOString();
|
|
@@ -157,11 +154,11 @@ const isSameDay = (a, b) => moment__default["default"](a).isSame(b, 'day');
|
|
|
157
154
|
const getCalendarDayLabel = (day, timeZone) => moment__default["default"].tz(day, timeZone).format('D');
|
|
158
155
|
const createItemDateTimeToString = (locale, timeZone) => item => item ? formatDate(item, locale, timeZone) : '';
|
|
159
156
|
const createCalendarItems = (day, timeString, timeZone) => {
|
|
160
|
-
var
|
|
157
|
+
var _context;
|
|
161
158
|
const parsedTime = utils.parseTime(timeString);
|
|
162
|
-
return _mapInstanceProperty__default["default"](
|
|
159
|
+
return _mapInstanceProperty__default["default"](_context = _Array$from__default["default"]({
|
|
163
160
|
length: getDaysInMonth(day, timeZone)
|
|
164
|
-
})).call(
|
|
161
|
+
})).call(_context, (_, i) => {
|
|
165
162
|
const dayOfMonth = i + 1;
|
|
166
163
|
let date = changeDateInMonth(day, timeZone, dayOfMonth);
|
|
167
164
|
if (parsedTime) {
|
|
@@ -249,9 +246,8 @@ const getIntlTimePattern = locale => {
|
|
|
249
246
|
};
|
|
250
247
|
const localizedDateFormatPatternCache = new _Map__default["default"]();
|
|
251
248
|
const getLocalizedDateTimeFormatPattern = function (locale) {
|
|
252
|
-
var _context3, _context4;
|
|
253
249
|
let formatType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'date';
|
|
254
|
-
const key =
|
|
250
|
+
const key = `${locale}::${formatType}`;
|
|
255
251
|
if (localizedDateFormatPatternCache.has(key)) {
|
|
256
252
|
return localizedDateFormatPatternCache.get(key);
|
|
257
253
|
}
|
|
@@ -264,10 +260,10 @@ const getLocalizedDateTimeFormatPattern = function (locale) {
|
|
|
264
260
|
localizedFormat = getIntlTimePattern(locale);
|
|
265
261
|
break;
|
|
266
262
|
case 'full':
|
|
267
|
-
localizedFormat =
|
|
263
|
+
localizedFormat = `${getIntlDatePattern(locale)} - ${getIntlTimePattern(locale)}`;
|
|
268
264
|
break;
|
|
269
265
|
default:
|
|
270
|
-
throw new Error(
|
|
266
|
+
throw new Error(`CalendarTime.getLocalizedDateTimeFormatPattern: Unknown format type '${formatType}'`);
|
|
271
267
|
}
|
|
272
268
|
|
|
273
269
|
// We try to get the localization both with the whole locale (e.g. 'en-GB')
|
|
@@ -293,7 +289,7 @@ const getLocalizedDateTimeFormatPattern = function (locale) {
|
|
|
293
289
|
};
|
|
294
290
|
|
|
295
291
|
// NOTE: This string will be replaced on build time with the package version.
|
|
296
|
-
var version = "20.
|
|
292
|
+
var version = "20.6.0";
|
|
297
293
|
|
|
298
294
|
exports.changeDateInMonth = changeDateInMonth;
|
|
299
295
|
exports.changeMonth = changeMonth;
|
|
@@ -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';
|
|
@@ -98,7 +97,7 @@ const formatDefaultTime = (time, locale) => {
|
|
|
98
97
|
});
|
|
99
98
|
return moment(today).locale(locale).format('LT'); // 5:13 PM
|
|
100
99
|
} else {
|
|
101
|
-
process.env.NODE_ENV !== "production" ? warning(false,
|
|
100
|
+
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;
|
|
102
101
|
today.set({
|
|
103
102
|
hour: 0,
|
|
104
103
|
minute: 0
|
|
@@ -113,10 +112,9 @@ const formatTime = (day, locale, timeZone) => {
|
|
|
113
112
|
return date.format('LT'); // 5:13 PM
|
|
114
113
|
};
|
|
115
114
|
const formatDate = (day, locale, timeZone) => {
|
|
116
|
-
var _context;
|
|
117
115
|
const date = moment(day, moment.ISO_8601, locale).tz(timeZone).format('L');
|
|
118
116
|
const time = formatTime(day, locale, timeZone);
|
|
119
|
-
return
|
|
117
|
+
return `${date} ${time}`;
|
|
120
118
|
};
|
|
121
119
|
const getDateInMonth = (day, timeZone) => moment.tz(day, timeZone).date();
|
|
122
120
|
const getToday = timeZone => moment.tz(timeZone).startOf('day').toISOString();
|
|
@@ -140,11 +138,11 @@ const isSameDay = (a, b) => moment(a).isSame(b, 'day');
|
|
|
140
138
|
const getCalendarDayLabel = (day, timeZone) => moment.tz(day, timeZone).format('D');
|
|
141
139
|
const createItemDateTimeToString = (locale, timeZone) => item => item ? formatDate(item, locale, timeZone) : '';
|
|
142
140
|
const createCalendarItems = (day, timeString, timeZone) => {
|
|
143
|
-
var
|
|
141
|
+
var _context;
|
|
144
142
|
const parsedTime = parseTime(timeString);
|
|
145
|
-
return _mapInstanceProperty(
|
|
143
|
+
return _mapInstanceProperty(_context = _Array$from({
|
|
146
144
|
length: getDaysInMonth(day, timeZone)
|
|
147
|
-
})).call(
|
|
145
|
+
})).call(_context, (_, i) => {
|
|
148
146
|
const dayOfMonth = i + 1;
|
|
149
147
|
let date = changeDateInMonth(day, timeZone, dayOfMonth);
|
|
150
148
|
if (parsedTime) {
|
|
@@ -232,9 +230,8 @@ const getIntlTimePattern = locale => {
|
|
|
232
230
|
};
|
|
233
231
|
const localizedDateFormatPatternCache = new _Map();
|
|
234
232
|
const getLocalizedDateTimeFormatPattern = function (locale) {
|
|
235
|
-
var _context3, _context4;
|
|
236
233
|
let formatType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'date';
|
|
237
|
-
const key =
|
|
234
|
+
const key = `${locale}::${formatType}`;
|
|
238
235
|
if (localizedDateFormatPatternCache.has(key)) {
|
|
239
236
|
return localizedDateFormatPatternCache.get(key);
|
|
240
237
|
}
|
|
@@ -247,10 +244,10 @@ const getLocalizedDateTimeFormatPattern = function (locale) {
|
|
|
247
244
|
localizedFormat = getIntlTimePattern(locale);
|
|
248
245
|
break;
|
|
249
246
|
case 'full':
|
|
250
|
-
localizedFormat =
|
|
247
|
+
localizedFormat = `${getIntlDatePattern(locale)} - ${getIntlTimePattern(locale)}`;
|
|
251
248
|
break;
|
|
252
249
|
default:
|
|
253
|
-
throw new Error(
|
|
250
|
+
throw new Error(`CalendarTime.getLocalizedDateTimeFormatPattern: Unknown format type '${formatType}'`);
|
|
254
251
|
}
|
|
255
252
|
|
|
256
253
|
// We try to get the localization both with the whole locale (e.g. 'en-GB')
|
|
@@ -276,6 +273,6 @@ const getLocalizedDateTimeFormatPattern = function (locale) {
|
|
|
276
273
|
};
|
|
277
274
|
|
|
278
275
|
// NOTE: This string will be replaced on build time with the package version.
|
|
279
|
-
var version = "20.
|
|
276
|
+
var version = "20.6.0";
|
|
280
277
|
|
|
281
278
|
export { changeDateInMonth, changeMonth, changeTime, createCalendarItems, createItemDateTimeToString, createSuggestedItems, formatDate, formatDefaultTime, 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": "20.
|
|
4
|
+
"version": "20.6.0",
|
|
5
5
|
"bugs": "https://github.com/commercetools/ui-kit/issues",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -9,7 +9,13 @@
|
|
|
9
9
|
"directory": "packages/calendar-time-utils"
|
|
10
10
|
},
|
|
11
11
|
"homepage": "https://uikit.commercetools.com",
|
|
12
|
-
"keywords": [
|
|
12
|
+
"keywords": [
|
|
13
|
+
"javascript",
|
|
14
|
+
"typescript",
|
|
15
|
+
"design-system",
|
|
16
|
+
"react",
|
|
17
|
+
"uikit"
|
|
18
|
+
],
|
|
13
19
|
"license": "MIT",
|
|
14
20
|
"publishConfig": {
|
|
15
21
|
"access": "public"
|
|
@@ -17,11 +23,13 @@
|
|
|
17
23
|
"sideEffects": false,
|
|
18
24
|
"main": "dist/commercetools-uikit-calendar-time-utils.cjs.js",
|
|
19
25
|
"module": "dist/commercetools-uikit-calendar-time-utils.esm.js",
|
|
20
|
-
"files": [
|
|
26
|
+
"files": [
|
|
27
|
+
"dist"
|
|
28
|
+
],
|
|
21
29
|
"dependencies": {
|
|
22
30
|
"@babel/runtime": "^7.20.13",
|
|
23
31
|
"@babel/runtime-corejs3": "^7.20.13",
|
|
24
|
-
"@commercetools-uikit/utils": "20.
|
|
32
|
+
"@commercetools-uikit/utils": "^20.6.0"
|
|
25
33
|
},
|
|
26
34
|
"devDependencies": {
|
|
27
35
|
"moment-timezone": "0.6.0"
|
|
@@ -29,4 +37,4 @@
|
|
|
29
37
|
"peerDependencies": {
|
|
30
38
|
"moment-timezone": "0.6.x"
|
|
31
39
|
}
|
|
32
|
-
}
|
|
40
|
+
}
|