@semcore/date-picker 4.56.0 → 16.0.0-prerelease.10
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 +3 -3
- package/lib/cjs/DatePicker.js +3 -4
- package/lib/cjs/DatePicker.js.map +1 -1
- package/lib/cjs/DateRangeComparator.js +2 -2
- package/lib/cjs/DateRangeComparator.js.map +1 -1
- package/lib/cjs/DateRangePicker.js +2 -2
- package/lib/cjs/DateRangePicker.js.map +1 -1
- package/lib/cjs/MonthDateRangeComparator.js +2 -2
- package/lib/cjs/MonthDateRangeComparator.js.map +1 -1
- package/lib/cjs/MonthPicker.js +2 -2
- package/lib/cjs/MonthPicker.js.map +1 -1
- package/lib/cjs/MonthRangePicker.js +2 -2
- package/lib/cjs/MonthRangePicker.js.map +1 -1
- package/lib/cjs/components/ButtonTrigger.js +3 -4
- package/lib/cjs/components/ButtonTrigger.js.map +1 -1
- package/lib/cjs/components/Calendar.js +27 -29
- package/lib/cjs/components/Calendar.js.map +1 -1
- package/lib/cjs/components/DateRangeComparatorAbstract.js +30 -31
- package/lib/cjs/components/DateRangeComparatorAbstract.js.map +1 -1
- package/lib/cjs/components/InputTrigger.js +35 -37
- package/lib/cjs/components/InputTrigger.js.map +1 -1
- package/lib/cjs/components/PickerAbstract.js +30 -31
- package/lib/cjs/components/PickerAbstract.js.map +1 -1
- package/lib/cjs/components/RangePickerAbstract.js +30 -31
- package/lib/cjs/components/RangePickerAbstract.js.map +1 -1
- package/lib/cjs/components/index.js +1 -1
- package/lib/cjs/components/index.js.map +1 -1
- package/lib/cjs/index.d.js.map +1 -1
- package/lib/cjs/style/calendar.shadow.css +5 -1
- package/lib/es6/DatePicker.js +2 -2
- package/lib/es6/DatePicker.js.map +1 -1
- package/lib/es6/DateRangeComparator.js +1 -1
- package/lib/es6/DateRangeComparator.js.map +1 -1
- package/lib/es6/DateRangePicker.js +1 -1
- package/lib/es6/DateRangePicker.js.map +1 -1
- package/lib/es6/MonthDateRangeComparator.js +1 -1
- package/lib/es6/MonthDateRangeComparator.js.map +1 -1
- package/lib/es6/MonthPicker.js +1 -1
- package/lib/es6/MonthPicker.js.map +1 -1
- package/lib/es6/MonthRangePicker.js +1 -1
- package/lib/es6/MonthRangePicker.js.map +1 -1
- package/lib/es6/components/ButtonTrigger.js +2 -2
- package/lib/es6/components/ButtonTrigger.js.map +1 -1
- package/lib/es6/components/Calendar.js +25 -25
- package/lib/es6/components/Calendar.js.map +1 -1
- package/lib/es6/components/DateRangeComparatorAbstract.js +31 -31
- package/lib/es6/components/DateRangeComparatorAbstract.js.map +1 -1
- package/lib/es6/components/InputTrigger.js +33 -33
- package/lib/es6/components/InputTrigger.js.map +1 -1
- package/lib/es6/components/PickerAbstract.js +31 -31
- package/lib/es6/components/PickerAbstract.js.map +1 -1
- package/lib/es6/components/RangePickerAbstract.js +31 -31
- package/lib/es6/components/RangePickerAbstract.js.map +1 -1
- package/lib/es6/components/index.js +1 -1
- package/lib/es6/components/index.js.map +1 -1
- package/lib/es6/index.d.js.map +1 -1
- package/lib/es6/style/calendar.shadow.css +5 -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 +404 -286
- package/lib/esm/components/DateRangeComparatorAbstract.mjs +453 -329
- package/lib/esm/components/InputTrigger.mjs +757 -518
- package/lib/esm/components/PickerAbstract.mjs +191 -148
- package/lib/esm/components/RangePickerAbstract.mjs +305 -220
- package/lib/esm/components/index.mjs +127 -109
- package/lib/esm/index.mjs +13 -13
- 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/lib/types/index.d.ts +1 -1
- package/package.json +15 -18
|
@@ -1,62 +1,89 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
1
|
+
const apply = "应用";
|
|
2
|
+
const reset = "重置";
|
|
3
|
+
const today = "今天";
|
|
4
|
+
const last2Days = "过去 2 天";
|
|
5
|
+
const lastWeek = "上周";
|
|
6
|
+
const last2Weeks = "上两周";
|
|
7
|
+
const lastMonth = "上个月";
|
|
8
|
+
const last2Months = "过去 2 个月";
|
|
9
|
+
const last3Months = "过去 3 个月";
|
|
10
|
+
const last6Months = "过去 6 个月";
|
|
11
|
+
const last12Months = "过去 12 个月";
|
|
12
|
+
const prev = "上一个时段";
|
|
13
|
+
const next = "下一时段";
|
|
14
|
+
const input = "日期字段";
|
|
15
|
+
const compare = "比较";
|
|
16
|
+
const fromDate = "从 {date}";
|
|
17
|
+
const toDate = "至 {date}";
|
|
18
|
+
const periods = "预设";
|
|
19
|
+
const dateRange = "日期范围";
|
|
20
|
+
const dateRange1 = "第一个日期范围";
|
|
21
|
+
const dateRange2 = "第二个日期范围";
|
|
22
|
+
const selectingStarted = "已开始选择";
|
|
23
|
+
const selectingFinished = "已选定";
|
|
24
|
+
const unavailableDate = "请选择可用日期。";
|
|
25
|
+
const unavailableMonth = "请选择可用月份。";
|
|
26
|
+
const unavailableEndDate = "请选择一个可用的截止日期。";
|
|
27
|
+
const unavailableEndMonth = "请选择可用到期月份。";
|
|
28
|
+
const zh = {
|
|
29
|
+
apply,
|
|
30
|
+
reset,
|
|
31
|
+
today,
|
|
32
|
+
last2Days,
|
|
33
|
+
lastWeek,
|
|
34
|
+
last2Weeks,
|
|
35
|
+
lastMonth,
|
|
36
|
+
last2Months,
|
|
37
|
+
last3Months,
|
|
38
|
+
last6Months,
|
|
39
|
+
last12Months,
|
|
40
|
+
prev,
|
|
41
|
+
next,
|
|
42
|
+
input,
|
|
43
|
+
compare,
|
|
44
|
+
fromDate,
|
|
45
|
+
toDate,
|
|
46
|
+
periods,
|
|
47
|
+
dateRange,
|
|
48
|
+
dateRange1,
|
|
49
|
+
dateRange2,
|
|
50
|
+
selectingStarted,
|
|
51
|
+
selectingFinished,
|
|
52
|
+
unavailableDate,
|
|
53
|
+
unavailableMonth,
|
|
54
|
+
unavailableEndDate,
|
|
55
|
+
unavailableEndMonth,
|
|
29
56
|
"placeholder-days": "日",
|
|
30
57
|
"placeholder-months": "月",
|
|
31
58
|
"placeholder-years": "年"
|
|
32
59
|
};
|
|
33
60
|
export {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
apply,
|
|
62
|
+
compare,
|
|
63
|
+
dateRange,
|
|
64
|
+
dateRange1,
|
|
65
|
+
dateRange2,
|
|
66
|
+
zh as default,
|
|
67
|
+
fromDate,
|
|
68
|
+
input,
|
|
69
|
+
last12Months,
|
|
70
|
+
last2Days,
|
|
71
|
+
last2Months,
|
|
72
|
+
last2Weeks,
|
|
73
|
+
last3Months,
|
|
74
|
+
last6Months,
|
|
75
|
+
lastMonth,
|
|
76
|
+
lastWeek,
|
|
77
|
+
next,
|
|
78
|
+
periods,
|
|
79
|
+
prev,
|
|
80
|
+
reset,
|
|
81
|
+
selectingFinished,
|
|
82
|
+
selectingStarted,
|
|
83
|
+
toDate,
|
|
84
|
+
today,
|
|
85
|
+
unavailableDate,
|
|
86
|
+
unavailableEndDate,
|
|
87
|
+
unavailableEndMonth,
|
|
88
|
+
unavailableMonth
|
|
62
89
|
};
|
|
@@ -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/lib/types/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { UnknownProperties, Intergalactic, PropGetterFn } from '@semcore/core';
|
|
|
5
5
|
import Button, { ButtonProps } from '@semcore/button';
|
|
6
6
|
import Divider from '@semcore/divider';
|
|
7
7
|
import { DropdownProps, DropdownTriggerProps } from '@semcore/dropdown';
|
|
8
|
-
import { WithI18nEnhanceProps } from '@semcore/
|
|
8
|
+
import { WithI18nEnhanceProps } from '@semcore/core/lib/utils/enhances/i18nEnhance';
|
|
9
9
|
import BaseTrigger, { BaseTriggerProps } from '@semcore/base-trigger';
|
|
10
10
|
import Input, { InputProps, InputValueProps } from '@semcore/input';
|
|
11
11
|
import { InputMaskValueProps } from '@semcore/input-mask';
|
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
|
+
"version": "16.0.0-prerelease.10",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es6/index.js",
|
|
7
7
|
"typings": "lib/types/index.d.ts",
|
|
@@ -14,26 +14,23 @@
|
|
|
14
14
|
"types": "./lib/types/index.d.ts"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@semcore/
|
|
18
|
-
"@semcore/
|
|
19
|
-
"@semcore/
|
|
20
|
-
"@semcore/
|
|
21
|
-
"@semcore/dropdown": "
|
|
22
|
-
"@semcore/
|
|
23
|
-
"@semcore/
|
|
24
|
-
"@semcore/input": "
|
|
25
|
-
"@semcore/
|
|
26
|
-
"@semcore/
|
|
27
|
-
"@semcore/
|
|
28
|
-
"@semcore/
|
|
29
|
-
"@semcore/
|
|
30
|
-
"@semcore/tooltip": "6.49.1",
|
|
17
|
+
"@semcore/base-trigger": "16.0.0-prerelease.10",
|
|
18
|
+
"@semcore/button": "16.0.0-prerelease.10",
|
|
19
|
+
"@semcore/divider": "16.0.0-prerelease.10",
|
|
20
|
+
"@semcore/popper": "16.0.0-prerelease.10",
|
|
21
|
+
"@semcore/dropdown": "16.0.0-prerelease.10",
|
|
22
|
+
"@semcore/icon": "16.0.0-prerelease.10",
|
|
23
|
+
"@semcore/input": "16.0.0-prerelease.10",
|
|
24
|
+
"@semcore/input-mask": "16.0.0-prerelease.10",
|
|
25
|
+
"@semcore/typography": "16.0.0-prerelease.10",
|
|
26
|
+
"@semcore/checkbox": "16.0.0-prerelease.10",
|
|
27
|
+
"@semcore/tooltip": "16.0.0-prerelease.10",
|
|
28
|
+
"@semcore/flex-box": "16.0.0-prerelease.10",
|
|
29
|
+
"@semcore/neighbor-location": "16.0.0-prerelease.10",
|
|
31
30
|
"dayjs": "1.8.36"
|
|
32
31
|
},
|
|
33
32
|
"peerDependencies": {
|
|
34
|
-
"@semcore/
|
|
35
|
-
"react": "16.8 - 18",
|
|
36
|
-
"react-dom": "16.8 - 18"
|
|
33
|
+
"@semcore/base-components": "^16.0.0-prerelease.10"
|
|
37
34
|
},
|
|
38
35
|
"repository": {
|
|
39
36
|
"type": "git",
|