@commercetools-uikit/calendar-time-utils 20.2.3 → 20.3.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,6 +4,7 @@ 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');
|
|
7
8
|
var _sliceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/slice');
|
|
8
9
|
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
9
10
|
var _Array$from = require('@babel/runtime-corejs3/core-js-stable/array/from');
|
|
@@ -17,6 +18,7 @@ var utils = require('@commercetools-uikit/utils');
|
|
|
17
18
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
18
19
|
|
|
19
20
|
var _parseInt__default = /*#__PURE__*/_interopDefault(_parseInt);
|
|
21
|
+
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
20
22
|
var _sliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_sliceInstanceProperty);
|
|
21
23
|
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
22
24
|
var _Array$from__default = /*#__PURE__*/_interopDefault(_Array$from);
|
|
@@ -112,7 +114,7 @@ const formatDefaultTime = (time, locale) => {
|
|
|
112
114
|
});
|
|
113
115
|
return moment__default["default"](today).locale(locale).format('LT'); // 5:13 PM
|
|
114
116
|
} else {
|
|
115
|
-
process.env.NODE_ENV !== "production" ? utils.warning(false,
|
|
117
|
+
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;
|
|
116
118
|
today.set({
|
|
117
119
|
hour: 0,
|
|
118
120
|
minute: 0
|
|
@@ -127,9 +129,10 @@ const formatTime = (day, locale, timeZone) => {
|
|
|
127
129
|
return date.format('LT'); // 5:13 PM
|
|
128
130
|
};
|
|
129
131
|
const formatDate = (day, locale, timeZone) => {
|
|
132
|
+
var _context;
|
|
130
133
|
const date = moment__default["default"](day, moment__default["default"].ISO_8601, locale).tz(timeZone).format('L');
|
|
131
134
|
const time = formatTime(day, locale, timeZone);
|
|
132
|
-
return
|
|
135
|
+
return _concatInstanceProperty__default["default"](_context = "".concat(date, " ")).call(_context, time);
|
|
133
136
|
};
|
|
134
137
|
const getDateInMonth = (day, timeZone) => moment__default["default"].tz(day, timeZone).date();
|
|
135
138
|
const getToday = timeZone => moment__default["default"].tz(timeZone).startOf('day').toISOString();
|
|
@@ -153,11 +156,11 @@ const isSameDay = (a, b) => moment__default["default"](a).isSame(b, 'day');
|
|
|
153
156
|
const getCalendarDayLabel = (day, timeZone) => moment__default["default"].tz(day, timeZone).format('D');
|
|
154
157
|
const createItemDateTimeToString = (locale, timeZone) => item => item ? formatDate(item, locale, timeZone) : '';
|
|
155
158
|
const createCalendarItems = (day, timeString, timeZone) => {
|
|
156
|
-
var
|
|
159
|
+
var _context2;
|
|
157
160
|
const parsedTime = utils.parseTime(timeString);
|
|
158
|
-
return _mapInstanceProperty__default["default"](
|
|
161
|
+
return _mapInstanceProperty__default["default"](_context2 = _Array$from__default["default"]({
|
|
159
162
|
length: getDaysInMonth(day, timeZone)
|
|
160
|
-
})).call(
|
|
163
|
+
})).call(_context2, (_, i) => {
|
|
161
164
|
const dayOfMonth = i + 1;
|
|
162
165
|
let date = changeDateInMonth(day, timeZone, dayOfMonth);
|
|
163
166
|
if (parsedTime) {
|
|
@@ -193,8 +196,9 @@ const parseInputText = (text, locale, timeZone) => {
|
|
|
193
196
|
};
|
|
194
197
|
const localizedDateFormatPatternCache = new _Map__default["default"]();
|
|
195
198
|
const getLocalizedDateTimeFormatPattern = function (locale) {
|
|
199
|
+
var _context3, _context4;
|
|
196
200
|
let formatType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'date';
|
|
197
|
-
const key =
|
|
201
|
+
const key = _concatInstanceProperty__default["default"](_context3 = "".concat(locale, "::")).call(_context3, formatType);
|
|
198
202
|
if (localizedDateFormatPatternCache.has(key)) {
|
|
199
203
|
return localizedDateFormatPatternCache.get(key);
|
|
200
204
|
}
|
|
@@ -212,10 +216,10 @@ const getLocalizedDateTimeFormatPattern = function (locale) {
|
|
|
212
216
|
localizedFormat = localeData.longDateFormat('LT');
|
|
213
217
|
break;
|
|
214
218
|
case 'full':
|
|
215
|
-
localizedFormat =
|
|
219
|
+
localizedFormat = _concatInstanceProperty__default["default"](_context4 = "".concat(localeData.longDateFormat('L'), " - ")).call(_context4, localeData.longDateFormat('LT'));
|
|
216
220
|
break;
|
|
217
221
|
default:
|
|
218
|
-
throw new Error(
|
|
222
|
+
throw new Error("CalendarTime.getLocalizedDateTimeFormatPattern: Unknown format type '".concat(formatType, "'"));
|
|
219
223
|
}
|
|
220
224
|
|
|
221
225
|
// We try to get the localization both with the whole locale (e.g. 'en-GB')
|
|
@@ -241,7 +245,7 @@ const getLocalizedDateTimeFormatPattern = function (locale) {
|
|
|
241
245
|
};
|
|
242
246
|
|
|
243
247
|
// NOTE: This string will be replaced on build time with the package version.
|
|
244
|
-
var version = "20.
|
|
248
|
+
var version = "20.3.0";
|
|
245
249
|
|
|
246
250
|
exports.changeDateInMonth = changeDateInMonth;
|
|
247
251
|
exports.changeMonth = changeMonth;
|
|
@@ -4,6 +4,7 @@ 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');
|
|
7
8
|
var _sliceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/slice');
|
|
8
9
|
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
9
10
|
var _Array$from = require('@babel/runtime-corejs3/core-js-stable/array/from');
|
|
@@ -17,6 +18,7 @@ var utils = require('@commercetools-uikit/utils');
|
|
|
17
18
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
18
19
|
|
|
19
20
|
var _parseInt__default = /*#__PURE__*/_interopDefault(_parseInt);
|
|
21
|
+
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
20
22
|
var _sliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_sliceInstanceProperty);
|
|
21
23
|
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
22
24
|
var _Array$from__default = /*#__PURE__*/_interopDefault(_Array$from);
|
|
@@ -126,9 +128,10 @@ const formatTime = (day, locale, timeZone) => {
|
|
|
126
128
|
return date.format('LT'); // 5:13 PM
|
|
127
129
|
};
|
|
128
130
|
const formatDate = (day, locale, timeZone) => {
|
|
131
|
+
var _context;
|
|
129
132
|
const date = moment__default["default"](day, moment__default["default"].ISO_8601, locale).tz(timeZone).format('L');
|
|
130
133
|
const time = formatTime(day, locale, timeZone);
|
|
131
|
-
return
|
|
134
|
+
return _concatInstanceProperty__default["default"](_context = "".concat(date, " ")).call(_context, time);
|
|
132
135
|
};
|
|
133
136
|
const getDateInMonth = (day, timeZone) => moment__default["default"].tz(day, timeZone).date();
|
|
134
137
|
const getToday = timeZone => moment__default["default"].tz(timeZone).startOf('day').toISOString();
|
|
@@ -152,11 +155,11 @@ const isSameDay = (a, b) => moment__default["default"](a).isSame(b, 'day');
|
|
|
152
155
|
const getCalendarDayLabel = (day, timeZone) => moment__default["default"].tz(day, timeZone).format('D');
|
|
153
156
|
const createItemDateTimeToString = (locale, timeZone) => item => item ? formatDate(item, locale, timeZone) : '';
|
|
154
157
|
const createCalendarItems = (day, timeString, timeZone) => {
|
|
155
|
-
var
|
|
158
|
+
var _context2;
|
|
156
159
|
const parsedTime = utils.parseTime(timeString);
|
|
157
|
-
return _mapInstanceProperty__default["default"](
|
|
160
|
+
return _mapInstanceProperty__default["default"](_context2 = _Array$from__default["default"]({
|
|
158
161
|
length: getDaysInMonth(day, timeZone)
|
|
159
|
-
})).call(
|
|
162
|
+
})).call(_context2, (_, i) => {
|
|
160
163
|
const dayOfMonth = i + 1;
|
|
161
164
|
let date = changeDateInMonth(day, timeZone, dayOfMonth);
|
|
162
165
|
if (parsedTime) {
|
|
@@ -192,8 +195,9 @@ const parseInputText = (text, locale, timeZone) => {
|
|
|
192
195
|
};
|
|
193
196
|
const localizedDateFormatPatternCache = new _Map__default["default"]();
|
|
194
197
|
const getLocalizedDateTimeFormatPattern = function (locale) {
|
|
198
|
+
var _context3, _context4;
|
|
195
199
|
let formatType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'date';
|
|
196
|
-
const key =
|
|
200
|
+
const key = _concatInstanceProperty__default["default"](_context3 = "".concat(locale, "::")).call(_context3, formatType);
|
|
197
201
|
if (localizedDateFormatPatternCache.has(key)) {
|
|
198
202
|
return localizedDateFormatPatternCache.get(key);
|
|
199
203
|
}
|
|
@@ -211,10 +215,10 @@ const getLocalizedDateTimeFormatPattern = function (locale) {
|
|
|
211
215
|
localizedFormat = localeData.longDateFormat('LT');
|
|
212
216
|
break;
|
|
213
217
|
case 'full':
|
|
214
|
-
localizedFormat =
|
|
218
|
+
localizedFormat = _concatInstanceProperty__default["default"](_context4 = "".concat(localeData.longDateFormat('L'), " - ")).call(_context4, localeData.longDateFormat('LT'));
|
|
215
219
|
break;
|
|
216
220
|
default:
|
|
217
|
-
throw new Error(
|
|
221
|
+
throw new Error("CalendarTime.getLocalizedDateTimeFormatPattern: Unknown format type '".concat(formatType, "'"));
|
|
218
222
|
}
|
|
219
223
|
|
|
220
224
|
// We try to get the localization both with the whole locale (e.g. 'en-GB')
|
|
@@ -240,7 +244,7 @@ const getLocalizedDateTimeFormatPattern = function (locale) {
|
|
|
240
244
|
};
|
|
241
245
|
|
|
242
246
|
// NOTE: This string will be replaced on build time with the package version.
|
|
243
|
-
var version = "20.
|
|
247
|
+
var version = "20.3.0";
|
|
244
248
|
|
|
245
249
|
exports.changeDateInMonth = changeDateInMonth;
|
|
246
250
|
exports.changeMonth = changeMonth;
|
|
@@ -1,5 +1,6 @@
|
|
|
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';
|
|
3
4
|
import _sliceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/slice';
|
|
4
5
|
import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
|
|
5
6
|
import _Array$from from '@babel/runtime-corejs3/core-js-stable/array/from';
|
|
@@ -96,7 +97,7 @@ const formatDefaultTime = (time, locale) => {
|
|
|
96
97
|
});
|
|
97
98
|
return moment(today).locale(locale).format('LT'); // 5:13 PM
|
|
98
99
|
} else {
|
|
99
|
-
process.env.NODE_ENV !== "production" ? warning(false,
|
|
100
|
+
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;
|
|
100
101
|
today.set({
|
|
101
102
|
hour: 0,
|
|
102
103
|
minute: 0
|
|
@@ -111,9 +112,10 @@ const formatTime = (day, locale, timeZone) => {
|
|
|
111
112
|
return date.format('LT'); // 5:13 PM
|
|
112
113
|
};
|
|
113
114
|
const formatDate = (day, locale, timeZone) => {
|
|
115
|
+
var _context;
|
|
114
116
|
const date = moment(day, moment.ISO_8601, locale).tz(timeZone).format('L');
|
|
115
117
|
const time = formatTime(day, locale, timeZone);
|
|
116
|
-
return
|
|
118
|
+
return _concatInstanceProperty(_context = "".concat(date, " ")).call(_context, time);
|
|
117
119
|
};
|
|
118
120
|
const getDateInMonth = (day, timeZone) => moment.tz(day, timeZone).date();
|
|
119
121
|
const getToday = timeZone => moment.tz(timeZone).startOf('day').toISOString();
|
|
@@ -137,11 +139,11 @@ const isSameDay = (a, b) => moment(a).isSame(b, 'day');
|
|
|
137
139
|
const getCalendarDayLabel = (day, timeZone) => moment.tz(day, timeZone).format('D');
|
|
138
140
|
const createItemDateTimeToString = (locale, timeZone) => item => item ? formatDate(item, locale, timeZone) : '';
|
|
139
141
|
const createCalendarItems = (day, timeString, timeZone) => {
|
|
140
|
-
var
|
|
142
|
+
var _context2;
|
|
141
143
|
const parsedTime = parseTime(timeString);
|
|
142
|
-
return _mapInstanceProperty(
|
|
144
|
+
return _mapInstanceProperty(_context2 = _Array$from({
|
|
143
145
|
length: getDaysInMonth(day, timeZone)
|
|
144
|
-
})).call(
|
|
146
|
+
})).call(_context2, (_, i) => {
|
|
145
147
|
const dayOfMonth = i + 1;
|
|
146
148
|
let date = changeDateInMonth(day, timeZone, dayOfMonth);
|
|
147
149
|
if (parsedTime) {
|
|
@@ -177,8 +179,9 @@ const parseInputText = (text, locale, timeZone) => {
|
|
|
177
179
|
};
|
|
178
180
|
const localizedDateFormatPatternCache = new _Map();
|
|
179
181
|
const getLocalizedDateTimeFormatPattern = function (locale) {
|
|
182
|
+
var _context3, _context4;
|
|
180
183
|
let formatType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'date';
|
|
181
|
-
const key =
|
|
184
|
+
const key = _concatInstanceProperty(_context3 = "".concat(locale, "::")).call(_context3, formatType);
|
|
182
185
|
if (localizedDateFormatPatternCache.has(key)) {
|
|
183
186
|
return localizedDateFormatPatternCache.get(key);
|
|
184
187
|
}
|
|
@@ -196,10 +199,10 @@ const getLocalizedDateTimeFormatPattern = function (locale) {
|
|
|
196
199
|
localizedFormat = localeData.longDateFormat('LT');
|
|
197
200
|
break;
|
|
198
201
|
case 'full':
|
|
199
|
-
localizedFormat =
|
|
202
|
+
localizedFormat = _concatInstanceProperty(_context4 = "".concat(localeData.longDateFormat('L'), " - ")).call(_context4, localeData.longDateFormat('LT'));
|
|
200
203
|
break;
|
|
201
204
|
default:
|
|
202
|
-
throw new Error(
|
|
205
|
+
throw new Error("CalendarTime.getLocalizedDateTimeFormatPattern: Unknown format type '".concat(formatType, "'"));
|
|
203
206
|
}
|
|
204
207
|
|
|
205
208
|
// We try to get the localization both with the whole locale (e.g. 'en-GB')
|
|
@@ -225,6 +228,6 @@ const getLocalizedDateTimeFormatPattern = function (locale) {
|
|
|
225
228
|
};
|
|
226
229
|
|
|
227
230
|
// NOTE: This string will be replaced on build time with the package version.
|
|
228
|
-
var version = "20.
|
|
231
|
+
var version = "20.3.0";
|
|
229
232
|
|
|
230
233
|
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.3.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": "20.
|
|
24
|
+
"@commercetools-uikit/utils": "20.3.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"moment-timezone": "0.6.0"
|