@semcore/date-picker 4.57.0 → 4.57.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/lib/cjs/components/Calendar.js +24 -22
- package/lib/cjs/components/Calendar.js.map +1 -1
- package/lib/cjs/components/DateRangeComparatorAbstract.js +32 -30
- package/lib/cjs/components/DateRangeComparatorAbstract.js.map +1 -1
- package/lib/cjs/components/InputTrigger.js +32 -30
- package/lib/cjs/components/InputTrigger.js.map +1 -1
- package/lib/cjs/components/PickerAbstract.js +32 -30
- package/lib/cjs/components/PickerAbstract.js.map +1 -1
- package/lib/cjs/components/RangePickerAbstract.js +32 -30
- package/lib/cjs/components/RangePickerAbstract.js.map +1 -1
- package/lib/es6/components/Calendar.js +24 -22
- package/lib/es6/components/Calendar.js.map +1 -1
- package/lib/es6/components/DateRangeComparatorAbstract.js +32 -30
- package/lib/es6/components/DateRangeComparatorAbstract.js.map +1 -1
- package/lib/es6/components/InputTrigger.js +32 -30
- package/lib/es6/components/InputTrigger.js.map +1 -1
- package/lib/es6/components/PickerAbstract.js +32 -30
- package/lib/es6/components/PickerAbstract.js.map +1 -1
- package/lib/es6/components/RangePickerAbstract.js +32 -30
- package/lib/es6/components/RangePickerAbstract.js.map +1 -1
- package/lib/esm/DatePicker.mjs +114 -103
- package/lib/esm/DateRangeComparator.mjs +166 -149
- package/lib/esm/DateRangePicker.mjs +85 -77
- package/lib/esm/MonthDateRangeComparator.mjs +187 -169
- package/lib/esm/MonthPicker.mjs +78 -71
- package/lib/esm/MonthRangePicker.mjs +94 -85
- package/lib/esm/components/ButtonTrigger.mjs +16 -15
- package/lib/esm/components/Calendar.mjs +409 -287
- package/lib/esm/components/DateRangeComparatorAbstract.mjs +458 -330
- package/lib/esm/components/InputTrigger.mjs +762 -519
- package/lib/esm/components/PickerAbstract.mjs +196 -149
- package/lib/esm/components/RangePickerAbstract.mjs +310 -221
- package/lib/esm/components/index.mjs +127 -109
- package/lib/esm/index.mjs +13 -13
- package/lib/esm/style/calendar.shadow.css +259 -0
- package/lib/esm/style/date-picker.shadow.css +179 -0
- package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +32 -32
- package/lib/esm/translations/de.json.mjs +83 -56
- package/lib/esm/translations/en.json.mjs +95 -64
- package/lib/esm/translations/es.json.mjs +83 -56
- package/lib/esm/translations/fr.json.mjs +83 -56
- package/lib/esm/translations/it.json.mjs +83 -56
- package/lib/esm/translations/ja.json.mjs +83 -56
- package/lib/esm/translations/ko.json.mjs +83 -56
- package/lib/esm/translations/nl.json.mjs +83 -56
- package/lib/esm/translations/pl.json.mjs +83 -56
- package/lib/esm/translations/pt.json.mjs +83 -56
- package/lib/esm/translations/ru.json.mjs +35 -24
- package/lib/esm/translations/sv.json.mjs +83 -56
- package/lib/esm/translations/tr.json.mjs +83 -56
- package/lib/esm/translations/vi.json.mjs +83 -56
- package/lib/esm/translations/zh.json.mjs +83 -56
- package/lib/esm/utils/cronTabScheduler.mjs +58 -52
- package/lib/esm/utils/datesIntersects.mjs +15 -11
- package/lib/esm/utils/formatDate.mjs +25 -18
- package/lib/esm/utils/includesDate.mjs +13 -9
- package/lib/esm/utils/shortDateRangeFormat.mjs +53 -31
- package/package.json +15 -15
|
@@ -1,84 +1,90 @@
|
|
|
1
|
-
import
|
|
2
|
-
function
|
|
3
|
-
if (
|
|
4
|
-
var
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
function cronUnitToArray(unit) {
|
|
3
|
+
if (unit.includes("-")) {
|
|
4
|
+
var _unit$split = unit.split("-"), _unit$split2 = _slicedToArray(_unit$split, 2), start = _unit$split2[0], end = _unit$split2[1];
|
|
5
5
|
return Array.from({
|
|
6
|
-
length: parseInt(
|
|
7
|
-
}, function(
|
|
8
|
-
return parseInt(
|
|
6
|
+
length: parseInt(end, 10) - parseInt(start, 10) + 1
|
|
7
|
+
}, function(_, idx) {
|
|
8
|
+
return parseInt(start, 10) + idx;
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
|
-
return
|
|
11
|
+
return unit.split(/[,\/]/);
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
if (typeof
|
|
15
|
-
function
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
function isValidSchedule(pattern) {
|
|
14
|
+
if (typeof pattern !== "string") return false;
|
|
15
|
+
function isValidUnit(unit, min, max) {
|
|
16
|
+
var unitValues = cronUnitToArray(unit);
|
|
17
|
+
var CRON_REG = /^\d+$|^\*$|^\*\/\d+$/;
|
|
18
|
+
return unitValues.every(function(item) {
|
|
19
|
+
var intItem = parseInt(item, 10);
|
|
20
|
+
return !(intItem < min || intItem > max || !CRON_REG.test(item));
|
|
20
21
|
});
|
|
21
22
|
}
|
|
22
|
-
function
|
|
23
|
-
return
|
|
23
|
+
function isValidMonth(month) {
|
|
24
|
+
return isValidUnit(month, 1, 12);
|
|
24
25
|
}
|
|
25
|
-
function
|
|
26
|
-
return
|
|
26
|
+
function isValidWeekDay(weekDay) {
|
|
27
|
+
return isValidUnit(weekDay, 1, 7);
|
|
27
28
|
}
|
|
28
|
-
function
|
|
29
|
-
return
|
|
29
|
+
function isValidMonthDay(monthDay) {
|
|
30
|
+
return isValidUnit(monthDay, 1, 31);
|
|
30
31
|
}
|
|
31
|
-
function
|
|
32
|
-
|
|
32
|
+
function validate(pattern2, validateFn, msg) {
|
|
33
|
+
if (validateFn(pattern2)) return true;
|
|
34
|
+
console.warn("DatePicker disabledSchedule: ".concat(msg, " format is invalid"));
|
|
35
|
+
return false;
|
|
33
36
|
}
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
var patternArr = pattern.split(" ");
|
|
38
|
+
if (patternArr.length < 3) return false;
|
|
39
|
+
return patternArr.every(function(pattern2, idx) {
|
|
40
|
+
switch (idx) {
|
|
37
41
|
case 0:
|
|
38
|
-
return
|
|
42
|
+
return validate(pattern2, isValidMonthDay, "day of month");
|
|
39
43
|
case 1:
|
|
40
|
-
return
|
|
44
|
+
return validate(pattern2, isValidMonth, "month");
|
|
41
45
|
case 2:
|
|
42
|
-
return
|
|
46
|
+
return validate(pattern2, isValidWeekDay, "day of week");
|
|
43
47
|
default:
|
|
44
|
-
return
|
|
48
|
+
return false;
|
|
45
49
|
}
|
|
46
50
|
});
|
|
47
51
|
}
|
|
48
|
-
function
|
|
49
|
-
var
|
|
50
|
-
function
|
|
51
|
-
|
|
52
|
+
function isInPeriod(pattern, date) {
|
|
53
|
+
var patternArr = pattern.split(" ");
|
|
54
|
+
function isInPeriod2(date2, period, dateMethod) {
|
|
55
|
+
if (period === "*") return true;
|
|
56
|
+
return date2[dateMethod]() === parseInt(period, 10);
|
|
52
57
|
}
|
|
53
|
-
function
|
|
54
|
-
return
|
|
58
|
+
function monthInPeriod(date2, period) {
|
|
59
|
+
return isInPeriod2(date2, period, "getMonth");
|
|
55
60
|
}
|
|
56
|
-
function
|
|
57
|
-
return
|
|
61
|
+
function monthDayInPeriod(date2, period) {
|
|
62
|
+
return isInPeriod2(date2, period, "getDate");
|
|
58
63
|
}
|
|
59
|
-
function
|
|
60
|
-
|
|
64
|
+
function weekDayInPeriod(date2, period) {
|
|
65
|
+
if (period === 7) period = 0;
|
|
66
|
+
return isInPeriod2(date2, period, "getDay");
|
|
61
67
|
}
|
|
62
|
-
function
|
|
63
|
-
return
|
|
64
|
-
return
|
|
68
|
+
function test(units, date2, testFn) {
|
|
69
|
+
return units.some(function(unit) {
|
|
70
|
+
return testFn(date2, unit);
|
|
65
71
|
});
|
|
66
72
|
}
|
|
67
|
-
return
|
|
68
|
-
var
|
|
69
|
-
switch (
|
|
73
|
+
return patternArr.every(function(unit, idx) {
|
|
74
|
+
var unitValues = cronUnitToArray(unit);
|
|
75
|
+
switch (idx) {
|
|
70
76
|
case 0:
|
|
71
|
-
return
|
|
77
|
+
return test(unitValues, date, monthDayInPeriod);
|
|
72
78
|
case 1:
|
|
73
|
-
return
|
|
79
|
+
return test(unitValues, date, monthInPeriod);
|
|
74
80
|
case 2:
|
|
75
|
-
return
|
|
81
|
+
return test(unitValues, date, weekDayInPeriod);
|
|
76
82
|
default:
|
|
77
|
-
return
|
|
83
|
+
return false;
|
|
78
84
|
}
|
|
79
85
|
});
|
|
80
86
|
}
|
|
81
87
|
export {
|
|
82
|
-
|
|
83
|
-
|
|
88
|
+
isInPeriod,
|
|
89
|
+
isValidSchedule
|
|
84
90
|
};
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { isValidSchedule
|
|
3
|
-
import
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import { isValidSchedule, isInPeriod } from "./cronTabScheduler.mjs";
|
|
3
|
+
import dayjs from "dayjs";
|
|
4
|
+
var MAX_DATE_TIMESTAMP = 864e13;
|
|
5
|
+
var datesIntersects = function datesIntersects2(_ref, unit) {
|
|
6
|
+
var _ref2 = _slicedToArray(_ref, 2), dateFrom = _ref2[0], dateTo = _ref2[1];
|
|
7
|
+
return function(disabled_day) {
|
|
8
|
+
if (Array.isArray(disabled_day)) {
|
|
9
|
+
var _disabled_day = _slicedToArray(disabled_day, 2), start = _disabled_day[0], end = _disabled_day[1];
|
|
10
|
+
return dateFrom && dayjs(dateFrom).isBetween(start || -MAX_DATE_TIMESTAMP, end || MAX_DATE_TIMESTAMP, unit, "[]") || dateTo && dayjs(dateTo).isBetween(start || -MAX_DATE_TIMESTAMP, end || MAX_DATE_TIMESTAMP, unit, "[]") || dateFrom && dateTo && dayjs(start).isBetween(dayjs(dateFrom), dayjs(dateTo), unit, "[]") || dateFrom && dateTo && dayjs(end).isBetween(dayjs(dateFrom), dayjs(dateTo), unit, "[]");
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
+
if (isValidSchedule(disabled_day)) {
|
|
13
|
+
return isInPeriod(disabled_day, dateFrom) || isInPeriod(disabled_day, dateTo);
|
|
14
|
+
}
|
|
15
|
+
return dateFrom && dateTo && dayjs(disabled_day).isBetween(dayjs(dateFrom), dayjs(dateTo), unit, "[]");
|
|
12
16
|
};
|
|
13
17
|
};
|
|
14
18
|
export {
|
|
15
|
-
|
|
19
|
+
datesIntersects
|
|
16
20
|
};
|
|
@@ -1,21 +1,28 @@
|
|
|
1
|
-
import
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
var DDMMYYFormattersCache = {};
|
|
3
|
+
var formatDDMMYY = function formatDDMMYY2(date, locale) {
|
|
4
|
+
if (DDMMYYFormattersCache[locale] === void 0) {
|
|
5
|
+
DDMMYYFormattersCache[locale] = new Intl.DateTimeFormat(locale, {
|
|
6
|
+
day: "numeric",
|
|
7
|
+
month: "short",
|
|
8
|
+
year: "numeric"
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
var formatter = DDMMYYFormattersCache[locale];
|
|
12
|
+
return formatter.format(dayjs(date).toDate());
|
|
13
|
+
};
|
|
14
|
+
var MMYYYYFormattersCache = {};
|
|
15
|
+
var formatMMYY = function formatMMYY2(date, locale) {
|
|
16
|
+
if (MMYYYYFormattersCache[locale] === void 0) {
|
|
17
|
+
MMYYYYFormattersCache[locale] = new Intl.DateTimeFormat(locale, {
|
|
18
|
+
month: "long",
|
|
19
|
+
year: "numeric"
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
var formatter = MMYYYYFormattersCache[locale];
|
|
23
|
+
return formatter.format(dayjs(date).toDate());
|
|
17
24
|
};
|
|
18
25
|
export {
|
|
19
|
-
|
|
20
|
-
|
|
26
|
+
formatDDMMYY,
|
|
27
|
+
formatMMYY
|
|
21
28
|
};
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { isValidSchedule
|
|
3
|
-
var
|
|
4
|
-
return function(
|
|
5
|
-
if (Array.isArray(
|
|
6
|
-
var
|
|
7
|
-
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import { isValidSchedule, isInPeriod } from "./cronTabScheduler.mjs";
|
|
3
|
+
var includesDate = function includesDate2(date, unit) {
|
|
4
|
+
return function(disabled_day) {
|
|
5
|
+
if (Array.isArray(disabled_day)) {
|
|
6
|
+
var MAX_DATE_TIMESTAMP = 864e13;
|
|
7
|
+
var _disabled_day = _slicedToArray(disabled_day, 2), start = _disabled_day[0], end = _disabled_day[1];
|
|
8
|
+
return date.isBetween(start || -MAX_DATE_TIMESTAMP, end || MAX_DATE_TIMESTAMP, unit, "[]");
|
|
8
9
|
}
|
|
9
|
-
|
|
10
|
+
if (isValidSchedule(disabled_day)) {
|
|
11
|
+
return isInPeriod(disabled_day, date.toDate());
|
|
12
|
+
}
|
|
13
|
+
return date.isSame(disabled_day, "date");
|
|
10
14
|
};
|
|
11
15
|
};
|
|
12
16
|
export {
|
|
13
|
-
|
|
17
|
+
includesDate
|
|
14
18
|
};
|
|
@@ -1,38 +1,60 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
var
|
|
4
|
-
function
|
|
5
|
-
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
|
+
import dayjs from "dayjs";
|
|
3
|
+
var _excluded = ["locale"], _excluded2 = ["year"];
|
|
4
|
+
function getDayJSLocale(locale) {
|
|
5
|
+
if (locale.includes("en") || locale.includes("ja")) {
|
|
6
|
+
return "en";
|
|
7
|
+
}
|
|
8
|
+
return "ru";
|
|
6
9
|
}
|
|
7
|
-
function
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return
|
|
10
|
+
function shortDateRangeFormat(dates, _ref) {
|
|
11
|
+
var _ref$locale = _ref.locale, locale = _ref$locale === void 0 ? "en-US" : _ref$locale, options = _objectWithoutProperties(_ref, _excluded);
|
|
12
|
+
var _Intl$DateTimeFormat = new Intl.DateTimeFormat(locale, options), format = _Intl$DateTimeFormat.format;
|
|
13
|
+
var normalizeDates = dates.map(function(date) {
|
|
14
|
+
return dayjs(date).toDate();
|
|
15
|
+
});
|
|
16
|
+
var monthsYears = dates.map(function(date) {
|
|
17
|
+
return [dayjs(date).date(), dayjs(date).month(), dayjs(date).year()];
|
|
12
18
|
});
|
|
13
|
-
if (
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (
|
|
18
|
-
return
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
19
|
+
if (monthsYears.length > 1) {
|
|
20
|
+
var isSimilarDay = monthsYears[0][0] === monthsYears[1][0];
|
|
21
|
+
var isSimilarMonth = monthsYears[0][1] === monthsYears[1][1];
|
|
22
|
+
var isSimilarYear = monthsYears[0][2] === monthsYears[1][2];
|
|
23
|
+
if (isSimilarMonth && isSimilarYear && !options.day) {
|
|
24
|
+
return format(normalizeDates[0]);
|
|
25
|
+
}
|
|
26
|
+
if (isSimilarMonth && isSimilarYear) {
|
|
27
|
+
if (getDayJSLocale(locale) === "en") {
|
|
28
|
+
if (isSimilarDay) {
|
|
29
|
+
return "".concat(new Intl.DateTimeFormat(locale, {
|
|
30
|
+
month: options.month
|
|
31
|
+
}).format(normalizeDates[0]), " ").concat(normalizeDates[0].getDate(), ", ").concat(normalizeDates[0].getFullYear());
|
|
32
|
+
}
|
|
33
|
+
return "".concat(new Intl.DateTimeFormat(locale, {
|
|
34
|
+
month: options.month
|
|
35
|
+
}).format(normalizeDates[0]), " ").concat(normalizeDates[0].getDate(), "-").concat(normalizeDates[1].getDate(), ", ").concat(normalizeDates[0].getFullYear());
|
|
36
|
+
}
|
|
37
|
+
if (isSimilarDay) {
|
|
38
|
+
return "".concat(normalizeDates[0].getDate(), " ").concat(new Intl.DateTimeFormat(locale, {
|
|
39
|
+
month: options.month
|
|
40
|
+
}).format(normalizeDates[0]), " ").concat(normalizeDates[0].getFullYear());
|
|
41
|
+
}
|
|
42
|
+
return "".concat(normalizeDates[0].getDate(), "-").concat(normalizeDates[1].getDate(), " ").concat(new Intl.DateTimeFormat(locale, {
|
|
43
|
+
month: options.month
|
|
44
|
+
}).format(normalizeDates[0]), " ").concat(normalizeDates[0].getFullYear());
|
|
45
|
+
}
|
|
46
|
+
if (isSimilarYear) {
|
|
47
|
+
options.year;
|
|
48
|
+
var newOptions = _objectWithoutProperties(options, _excluded2);
|
|
49
|
+
if (getDayJSLocale(locale) === "en") {
|
|
50
|
+
return "".concat(new Intl.DateTimeFormat(locale, newOptions).format(normalizeDates[0]), "-").concat(new Intl.DateTimeFormat(locale, newOptions).format(normalizeDates[1]), ", ").concat(normalizeDates[0].getFullYear());
|
|
51
|
+
}
|
|
52
|
+
return "".concat(new Intl.DateTimeFormat(locale, newOptions).format(normalizeDates[0]), "-").concat(new Intl.DateTimeFormat(locale, newOptions).format(normalizeDates[1]), " ").concat(normalizeDates[0].getFullYear());
|
|
31
53
|
}
|
|
32
|
-
return "".concat(
|
|
54
|
+
return "".concat(format(normalizeDates[0]), "-").concat(format(normalizeDates[1]));
|
|
33
55
|
}
|
|
34
|
-
return
|
|
56
|
+
return format(normalizeDates[0]);
|
|
35
57
|
}
|
|
36
58
|
export {
|
|
37
|
-
|
|
59
|
+
shortDateRangeFormat as default
|
|
38
60
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semcore/date-picker",
|
|
3
3
|
"description": "Semrush DatePicker Component",
|
|
4
|
-
"version": "4.57.
|
|
4
|
+
"version": "4.57.1",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es6/index.js",
|
|
7
7
|
"typings": "lib/types/index.d.ts",
|
|
@@ -14,20 +14,20 @@
|
|
|
14
14
|
"types": "./lib/types/index.d.ts"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@semcore/utils": "4.48.
|
|
18
|
-
"@semcore/base-trigger": "4.53.
|
|
19
|
-
"@semcore/button": "5.43.
|
|
20
|
-
"@semcore/divider": "4.40.
|
|
21
|
-
"@semcore/dropdown": "4.43.
|
|
22
|
-
"@semcore/flex-box": "5.41.
|
|
23
|
-
"@semcore/icon": "4.
|
|
24
|
-
"@semcore/input": "4.42.
|
|
25
|
-
"@semcore/input-mask": "5.43.
|
|
26
|
-
"@semcore/neighbor-location": "4.40.
|
|
27
|
-
"@semcore/typography": "5.53.
|
|
28
|
-
"@semcore/checkbox": "7.44.
|
|
29
|
-
"@semcore/popper": "5.46.
|
|
30
|
-
"@semcore/tooltip": "6.49.
|
|
17
|
+
"@semcore/utils": "4.48.4",
|
|
18
|
+
"@semcore/base-trigger": "4.53.1",
|
|
19
|
+
"@semcore/button": "5.43.2",
|
|
20
|
+
"@semcore/divider": "4.40.3",
|
|
21
|
+
"@semcore/dropdown": "4.43.3",
|
|
22
|
+
"@semcore/flex-box": "5.41.3",
|
|
23
|
+
"@semcore/icon": "4.62.0",
|
|
24
|
+
"@semcore/input": "4.42.3",
|
|
25
|
+
"@semcore/input-mask": "5.43.3",
|
|
26
|
+
"@semcore/neighbor-location": "4.40.3",
|
|
27
|
+
"@semcore/typography": "5.53.1",
|
|
28
|
+
"@semcore/checkbox": "7.44.3",
|
|
29
|
+
"@semcore/popper": "5.46.3",
|
|
30
|
+
"@semcore/tooltip": "6.49.3",
|
|
31
31
|
"dayjs": "1.8.36"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|