@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.
Files changed (59) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/lib/cjs/components/Calendar.js +24 -22
  3. package/lib/cjs/components/Calendar.js.map +1 -1
  4. package/lib/cjs/components/DateRangeComparatorAbstract.js +32 -30
  5. package/lib/cjs/components/DateRangeComparatorAbstract.js.map +1 -1
  6. package/lib/cjs/components/InputTrigger.js +32 -30
  7. package/lib/cjs/components/InputTrigger.js.map +1 -1
  8. package/lib/cjs/components/PickerAbstract.js +32 -30
  9. package/lib/cjs/components/PickerAbstract.js.map +1 -1
  10. package/lib/cjs/components/RangePickerAbstract.js +32 -30
  11. package/lib/cjs/components/RangePickerAbstract.js.map +1 -1
  12. package/lib/es6/components/Calendar.js +24 -22
  13. package/lib/es6/components/Calendar.js.map +1 -1
  14. package/lib/es6/components/DateRangeComparatorAbstract.js +32 -30
  15. package/lib/es6/components/DateRangeComparatorAbstract.js.map +1 -1
  16. package/lib/es6/components/InputTrigger.js +32 -30
  17. package/lib/es6/components/InputTrigger.js.map +1 -1
  18. package/lib/es6/components/PickerAbstract.js +32 -30
  19. package/lib/es6/components/PickerAbstract.js.map +1 -1
  20. package/lib/es6/components/RangePickerAbstract.js +32 -30
  21. package/lib/es6/components/RangePickerAbstract.js.map +1 -1
  22. package/lib/esm/DatePicker.mjs +114 -103
  23. package/lib/esm/DateRangeComparator.mjs +166 -149
  24. package/lib/esm/DateRangePicker.mjs +85 -77
  25. package/lib/esm/MonthDateRangeComparator.mjs +187 -169
  26. package/lib/esm/MonthPicker.mjs +78 -71
  27. package/lib/esm/MonthRangePicker.mjs +94 -85
  28. package/lib/esm/components/ButtonTrigger.mjs +16 -15
  29. package/lib/esm/components/Calendar.mjs +409 -287
  30. package/lib/esm/components/DateRangeComparatorAbstract.mjs +458 -330
  31. package/lib/esm/components/InputTrigger.mjs +762 -519
  32. package/lib/esm/components/PickerAbstract.mjs +196 -149
  33. package/lib/esm/components/RangePickerAbstract.mjs +310 -221
  34. package/lib/esm/components/index.mjs +127 -109
  35. package/lib/esm/index.mjs +13 -13
  36. package/lib/esm/style/calendar.shadow.css +259 -0
  37. package/lib/esm/style/date-picker.shadow.css +179 -0
  38. package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +32 -32
  39. package/lib/esm/translations/de.json.mjs +83 -56
  40. package/lib/esm/translations/en.json.mjs +95 -64
  41. package/lib/esm/translations/es.json.mjs +83 -56
  42. package/lib/esm/translations/fr.json.mjs +83 -56
  43. package/lib/esm/translations/it.json.mjs +83 -56
  44. package/lib/esm/translations/ja.json.mjs +83 -56
  45. package/lib/esm/translations/ko.json.mjs +83 -56
  46. package/lib/esm/translations/nl.json.mjs +83 -56
  47. package/lib/esm/translations/pl.json.mjs +83 -56
  48. package/lib/esm/translations/pt.json.mjs +83 -56
  49. package/lib/esm/translations/ru.json.mjs +35 -24
  50. package/lib/esm/translations/sv.json.mjs +83 -56
  51. package/lib/esm/translations/tr.json.mjs +83 -56
  52. package/lib/esm/translations/vi.json.mjs +83 -56
  53. package/lib/esm/translations/zh.json.mjs +83 -56
  54. package/lib/esm/utils/cronTabScheduler.mjs +58 -52
  55. package/lib/esm/utils/datesIntersects.mjs +15 -11
  56. package/lib/esm/utils/formatDate.mjs +25 -18
  57. package/lib/esm/utils/includesDate.mjs +13 -9
  58. package/lib/esm/utils/shortDateRangeFormat.mjs +53 -31
  59. package/package.json +15 -15
@@ -1,84 +1,90 @@
1
- import v from "@babel/runtime/helpers/esm/slicedToArray";
2
- function h(i) {
3
- if (i.includes("-")) {
4
- var t = i.split("-"), o = v(t, 2), a = o[0], c = o[1];
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(c, 10) - parseInt(a, 10) + 1
7
- }, function(s, f) {
8
- return parseInt(a, 10) + f;
6
+ length: parseInt(end, 10) - parseInt(start, 10) + 1
7
+ }, function(_, idx) {
8
+ return parseInt(start, 10) + idx;
9
9
  });
10
10
  }
11
- return i.split(/[,\/]/);
11
+ return unit.split(/[,\/]/);
12
12
  }
13
- function m(i) {
14
- if (typeof i != "string") return !1;
15
- function t(n, e, r) {
16
- var u = h(n), l = /^\d+$|^\*$|^\*\/\d+$/;
17
- return u.every(function(d) {
18
- var y = parseInt(d, 10);
19
- return !(y < e || y > r || !l.test(d));
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 o(n) {
23
- return t(n, 1, 12);
23
+ function isValidMonth(month) {
24
+ return isValidUnit(month, 1, 12);
24
25
  }
25
- function a(n) {
26
- return t(n, 1, 7);
26
+ function isValidWeekDay(weekDay) {
27
+ return isValidUnit(weekDay, 1, 7);
27
28
  }
28
- function c(n) {
29
- return t(n, 1, 31);
29
+ function isValidMonthDay(monthDay) {
30
+ return isValidUnit(monthDay, 1, 31);
30
31
  }
31
- function s(n, e, r) {
32
- return e(n) ? !0 : (console.warn("DatePicker disabledSchedule: ".concat(r, " format is invalid")), !1);
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 f = i.split(" ");
35
- return f.length < 3 ? !1 : f.every(function(n, e) {
36
- switch (e) {
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 s(n, c, "day of month");
42
+ return validate(pattern2, isValidMonthDay, "day of month");
39
43
  case 1:
40
- return s(n, o, "month");
44
+ return validate(pattern2, isValidMonth, "month");
41
45
  case 2:
42
- return s(n, a, "day of week");
46
+ return validate(pattern2, isValidWeekDay, "day of week");
43
47
  default:
44
- return !1;
48
+ return false;
45
49
  }
46
50
  });
47
51
  }
48
- function p(i, t) {
49
- var o = i.split(" ");
50
- function a(e, r, u) {
51
- return r === "*" ? !0 : e[u]() === parseInt(r, 10);
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 c(e, r) {
54
- return a(e, r, "getMonth");
58
+ function monthInPeriod(date2, period) {
59
+ return isInPeriod2(date2, period, "getMonth");
55
60
  }
56
- function s(e, r) {
57
- return a(e, r, "getDate");
61
+ function monthDayInPeriod(date2, period) {
62
+ return isInPeriod2(date2, period, "getDate");
58
63
  }
59
- function f(e, r) {
60
- return r === 7 && (r = 0), a(e, r, "getDay");
64
+ function weekDayInPeriod(date2, period) {
65
+ if (period === 7) period = 0;
66
+ return isInPeriod2(date2, period, "getDay");
61
67
  }
62
- function n(e, r, u) {
63
- return e.some(function(l) {
64
- return u(r, l);
68
+ function test(units, date2, testFn) {
69
+ return units.some(function(unit) {
70
+ return testFn(date2, unit);
65
71
  });
66
72
  }
67
- return o.every(function(e, r) {
68
- var u = h(e);
69
- switch (r) {
73
+ return patternArr.every(function(unit, idx) {
74
+ var unitValues = cronUnitToArray(unit);
75
+ switch (idx) {
70
76
  case 0:
71
- return n(u, t, s);
77
+ return test(unitValues, date, monthDayInPeriod);
72
78
  case 1:
73
- return n(u, t, c);
79
+ return test(unitValues, date, monthInPeriod);
74
80
  case 2:
75
- return n(u, t, f);
81
+ return test(unitValues, date, weekDayInPeriod);
76
82
  default:
77
- return !1;
83
+ return false;
78
84
  }
79
85
  });
80
86
  }
81
87
  export {
82
- p as isInPeriod,
83
- m as isValidSchedule
88
+ isInPeriod,
89
+ isValidSchedule
84
90
  };
@@ -1,16 +1,20 @@
1
- import A from "@babel/runtime/helpers/esm/slicedToArray";
2
- import { isValidSchedule as T, isInPeriod as w } from "./cronTabScheduler.mjs";
3
- import r from "dayjs";
4
- var f = 864e13, M = function(B, n) {
5
- var m = A(B, 2), e = m[0], t = m[1];
6
- return function(o) {
7
- if (Array.isArray(o)) {
8
- var c = A(o, 2), i = c[0], s = c[1];
9
- return e && r(e).isBetween(i || -f, s || f, n, "[]") || t && r(t).isBetween(i || -f, s || f, n, "[]") || e && t && r(i).isBetween(r(e), r(t), n, "[]") || e && t && r(s).isBetween(r(e), r(t), n, "[]");
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
- return T(o) ? w(o, e) || w(o, t) : e && t && r(o).isBetween(r(e), r(t), n, "[]");
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
- M as datesIntersects
19
+ datesIntersects
16
20
  };
@@ -1,21 +1,28 @@
1
- import n from "dayjs";
2
- var m = {}, Y = function(t, r) {
3
- m[r] === void 0 && (m[r] = new Intl.DateTimeFormat(r, {
4
- day: "numeric",
5
- month: "short",
6
- year: "numeric"
7
- }));
8
- var a = m[r];
9
- return a.format(n(t).toDate());
10
- }, e = {}, i = function(t, r) {
11
- e[r] === void 0 && (e[r] = new Intl.DateTimeFormat(r, {
12
- month: "long",
13
- year: "numeric"
14
- }));
15
- var a = e[r];
16
- return a.format(n(t).toDate());
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
- Y as formatDDMMYY,
20
- i as formatMMYY
26
+ formatDDMMYY,
27
+ formatMMYY
21
28
  };
@@ -1,14 +1,18 @@
1
- import c from "@babel/runtime/helpers/esm/slicedToArray";
2
- import { isValidSchedule as f, isInPeriod as m } from "./cronTabScheduler.mjs";
3
- var D = function(t, i) {
4
- return function(r) {
5
- if (Array.isArray(r)) {
6
- var e = 864e13, n = c(r, 2), o = n[0], u = n[1];
7
- return t.isBetween(o || -e, u || e, i, "[]");
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
- return f(r) ? m(r, t.toDate()) : t.isSame(r, "date");
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
- D as includesDate
17
+ includesDate
14
18
  };
@@ -1,38 +1,60 @@
1
- import g from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
- import l from "dayjs";
3
- var I = ["locale"], T = ["year"];
4
- function h(o) {
5
- return o.includes("en") || o.includes("ja") ? "en" : "ru";
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 y(o, f) {
8
- var D = f.locale, e = D === void 0 ? "en-US" : D, a = g(f, I), v = new Intl.DateTimeFormat(e, a), c = v.format, t = o.map(function(r) {
9
- return l(r).toDate();
10
- }), n = o.map(function(r) {
11
- return [l(r).date(), l(r).month(), l(r).year()];
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 (n.length > 1) {
14
- var i = n[0][0] === n[1][0], F = n[0][1] === n[1][1], u = n[0][2] === n[1][2];
15
- if (F && u && !a.day)
16
- return c(t[0]);
17
- if (F && u)
18
- return h(e) === "en" ? i ? "".concat(new Intl.DateTimeFormat(e, {
19
- month: a.month
20
- }).format(t[0]), " ").concat(t[0].getDate(), ", ").concat(t[0].getFullYear()) : "".concat(new Intl.DateTimeFormat(e, {
21
- month: a.month
22
- }).format(t[0]), " ").concat(t[0].getDate(), "-").concat(t[1].getDate(), ", ").concat(t[0].getFullYear()) : i ? "".concat(t[0].getDate(), " ").concat(new Intl.DateTimeFormat(e, {
23
- month: a.month
24
- }).format(t[0]), " ").concat(t[0].getFullYear()) : "".concat(t[0].getDate(), "-").concat(t[1].getDate(), " ").concat(new Intl.DateTimeFormat(e, {
25
- month: a.month
26
- }).format(t[0]), " ").concat(t[0].getFullYear());
27
- if (u) {
28
- a.year;
29
- var m = g(a, T);
30
- return h(e) === "en" ? "".concat(new Intl.DateTimeFormat(e, m).format(t[0]), "-").concat(new Intl.DateTimeFormat(e, m).format(t[1]), ", ").concat(t[0].getFullYear()) : "".concat(new Intl.DateTimeFormat(e, m).format(t[0]), "-").concat(new Intl.DateTimeFormat(e, m).format(t[1]), " ").concat(t[0].getFullYear());
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(c(t[0]), "-").concat(c(t[1]));
54
+ return "".concat(format(normalizeDates[0]), "-").concat(format(normalizeDates[1]));
33
55
  }
34
- return c(t[0]);
56
+ return format(normalizeDates[0]);
35
57
  }
36
58
  export {
37
- y as default
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.0",
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.2",
18
- "@semcore/base-trigger": "4.53.0",
19
- "@semcore/button": "5.43.1",
20
- "@semcore/divider": "4.40.2",
21
- "@semcore/dropdown": "4.43.2",
22
- "@semcore/flex-box": "5.41.2",
23
- "@semcore/icon": "4.61.0",
24
- "@semcore/input": "4.42.2",
25
- "@semcore/input-mask": "5.43.2",
26
- "@semcore/neighbor-location": "4.40.2",
27
- "@semcore/typography": "5.53.0",
28
- "@semcore/checkbox": "7.44.2",
29
- "@semcore/popper": "5.46.2",
30
- "@semcore/tooltip": "6.49.2",
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": {