@semcore/date-picker 3.0.9 → 3.0.12

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 (67) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +2 -2
  3. package/lib/cjs/DatePicker.js.map +1 -1
  4. package/lib/cjs/DateRangePicker.js.map +1 -1
  5. package/lib/cjs/MonthPicker.js.map +1 -1
  6. package/lib/cjs/MonthRangePicker.js.map +1 -1
  7. package/lib/cjs/components/ButtonTrigger.js.map +1 -1
  8. package/lib/cjs/components/Calendar.js +17 -17
  9. package/lib/cjs/components/Calendar.js.map +1 -1
  10. package/lib/cjs/components/PickerAbstract.js +7 -7
  11. package/lib/cjs/components/PickerAbstract.js.map +1 -1
  12. package/lib/cjs/components/RangePickerAbstract.js +7 -7
  13. package/lib/cjs/components/RangePickerAbstract.js.map +1 -1
  14. package/lib/cjs/components/index.js +3 -3
  15. package/lib/cjs/components/index.js.map +1 -1
  16. package/lib/cjs/index.js.map +1 -1
  17. package/lib/cjs/utils/cronTabScheduler.js.map +1 -1
  18. package/lib/cjs/utils/formatDate.js.map +1 -1
  19. package/lib/cjs/utils/includesDate.js.map +1 -1
  20. package/lib/cjs/utils/shortDateRangeFormat.js.map +1 -1
  21. package/lib/es6/DatePicker.js.map +1 -1
  22. package/lib/es6/DateRangePicker.js.map +1 -1
  23. package/lib/es6/MonthPicker.js.map +1 -1
  24. package/lib/es6/MonthRangePicker.js.map +1 -1
  25. package/lib/es6/components/ButtonTrigger.js.map +1 -1
  26. package/lib/es6/components/Calendar.js +17 -17
  27. package/lib/es6/components/Calendar.js.map +1 -1
  28. package/lib/es6/components/PickerAbstract.js +7 -7
  29. package/lib/es6/components/PickerAbstract.js.map +1 -1
  30. package/lib/es6/components/RangePickerAbstract.js +7 -7
  31. package/lib/es6/components/RangePickerAbstract.js.map +1 -1
  32. package/lib/es6/components/index.js +3 -3
  33. package/lib/es6/components/index.js.map +1 -1
  34. package/lib/es6/index.js.map +1 -1
  35. package/lib/es6/utils/cronTabScheduler.js.map +1 -1
  36. package/lib/es6/utils/formatDate.js.map +1 -1
  37. package/lib/es6/utils/includesDate.js.map +1 -1
  38. package/lib/es6/utils/shortDateRangeFormat.js.map +1 -1
  39. package/package.json +1 -1
  40. package/src/DatePicker.jsx +0 -113
  41. package/src/DateRangePicker.jsx +0 -91
  42. package/src/MonthPicker.jsx +0 -71
  43. package/src/MonthRangePicker.jsx +0 -108
  44. package/src/components/ButtonTrigger.jsx +0 -23
  45. package/src/components/Calendar.jsx +0 -284
  46. package/src/components/PickerAbstract.jsx +0 -199
  47. package/src/components/RangePickerAbstract.jsx +0 -340
  48. package/src/components/index.jsx +0 -121
  49. package/src/index.d.ts +0 -355
  50. package/src/index.js +0 -8
  51. package/src/style/calendar.shadow.css +0 -190
  52. package/src/style/date-picker.shadow.css +0 -49
  53. package/src/translations/de.json +0 -13
  54. package/src/translations/en.json +0 -13
  55. package/src/translations/es.json +0 -13
  56. package/src/translations/fr.json +0 -13
  57. package/src/translations/it.json +0 -13
  58. package/src/translations/ja.json +0 -13
  59. package/src/translations/ko.json +0 -13
  60. package/src/translations/pt.json +0 -13
  61. package/src/translations/ru.json +0 -13
  62. package/src/translations/vi.json +0 -13
  63. package/src/translations/zh.json +0 -13
  64. package/src/utils/cronTabScheduler.js +0 -99
  65. package/src/utils/formatDate.js +0 -8
  66. package/src/utils/includesDate.js +0 -13
  67. package/src/utils/shortDateRangeFormat.js +0 -70
@@ -1,13 +0,0 @@
1
- {
2
- "apply": "Aplicar",
3
- "reset": "Redefinir",
4
- "today": "Hoje",
5
- "last2Days": "Últimos 2 dias",
6
- "lastWeek": "Última semana",
7
- "last2Weeks": "Últimas 2 semanas",
8
- "lastMonth": "Último mês",
9
- "last2Months": "Últimos 2 meses",
10
- "last3Months": "Últimos 3 meses",
11
- "last6Months": "Últimos 6 meses",
12
- "last12Months": "Últimos 12 meses"
13
- }
@@ -1,13 +0,0 @@
1
- {
2
- "apply": "Применить",
3
- "reset": "Сброс",
4
- "today": "Сегодня",
5
- "last2Days": "Последние 2 дня",
6
- "lastWeek": "Прошлая неделя",
7
- "last2Weeks": "Последние 2 недели",
8
- "lastMonth": "Прошлый месяц",
9
- "last2Months": "Последние 2 месяцев",
10
- "last3Months": "Последние 3 месяцев",
11
- "last6Months": "Последние 6 месяцев",
12
- "last12Months": "Последние 12 месяцев"
13
- }
@@ -1,13 +0,0 @@
1
- {
2
- "apply": "Áp dụng",
3
- "reset": "Đặt lại",
4
- "today": "Hôm nay",
5
- "last2Days": "2 ngày trước",
6
- "lastWeek": "Tuần trước",
7
- "last2Weeks": "2 tuần trước",
8
- "lastMonth": "Tháng trước",
9
- "last2Months": "2 tháng qua",
10
- "last3Months": "3 tháng qua",
11
- "last6Months": "6 tháng qua",
12
- "last12Months": "12 tháng qua"
13
- }
@@ -1,13 +0,0 @@
1
- {
2
- "apply": "应用",
3
- "reset": "重置",
4
- "today": "今天",
5
- "last2Days": "过去 2 天",
6
- "lastWeek": "上周",
7
- "last2Weeks": "上两周",
8
- "lastMonth": "上个月",
9
- "last2Months": "过去 2 个月",
10
- "last3Months": "过去 3 个月",
11
- "last6Months": "过去 6 个月",
12
- "last12Months": "过去 12 个月"
13
- }
@@ -1,99 +0,0 @@
1
- function cronUnitToArray(unit) {
2
- if (unit.includes('-')) {
3
- const [start, end] = unit.split('-');
4
- return Array.from(
5
- { length: parseInt(end, 10) - parseInt(start, 10) + 1 },
6
- (_, idx) => parseInt(start, 10) + idx,
7
- );
8
- }
9
- return unit.split(/[,\/]/);
10
- }
11
-
12
- export function isValidSchedule(pattern) {
13
- if (typeof pattern !== 'string') return false;
14
-
15
- function isValidUnit(unit, min, max) {
16
- const unitValues = cronUnitToArray(unit);
17
- const CRON_REG = /^\d+$|^\*$|^\*\/\d+$/;
18
- return unitValues.every((item) => {
19
- const intItem = parseInt(item, 10);
20
- return !(intItem < min || intItem > max || !CRON_REG.test(item));
21
- });
22
- }
23
-
24
- function isValidMonth(month) {
25
- return isValidUnit(month, 1, 12);
26
- }
27
-
28
- function isValidWeekDay(weekDay) {
29
- return isValidUnit(weekDay, 1, 7);
30
- }
31
-
32
- function isValidMonthDay(monthDay) {
33
- return isValidUnit(monthDay, 1, 31);
34
- }
35
-
36
- function validate(pattern, validateFn, msg) {
37
- if (validateFn(pattern)) return true;
38
- // eslint-disable-next-line no-console
39
- console.warn(`DatePicker disabledSchedule: ${msg} format is invalid`);
40
- return false;
41
- }
42
-
43
- const patternArr = pattern.split(' ');
44
-
45
- if (patternArr.length < 3) return false;
46
-
47
- return patternArr.every((pattern, idx) => {
48
- switch (idx) {
49
- case 0:
50
- return validate(pattern, isValidMonthDay, 'day of month');
51
- case 1:
52
- return validate(pattern, isValidMonth, 'month');
53
- case 2:
54
- return validate(pattern, isValidWeekDay, 'day of week');
55
- default:
56
- return false;
57
- }
58
- });
59
- }
60
-
61
- export function isInPeriod(pattern, date) {
62
- const patternArr = pattern.split(' ');
63
-
64
- function isInPeriod(date, period, dateMethod) {
65
- if (period === '*') return true;
66
- return date[dateMethod]() === parseInt(period, 10);
67
- }
68
-
69
- function monthInPeriod(date, period) {
70
- return isInPeriod(date, period, 'getMonth');
71
- }
72
-
73
- function monthDayInPeriod(date, period) {
74
- return isInPeriod(date, period, 'getDate');
75
- }
76
-
77
- function weekDayInPeriod(date, period) {
78
- if (period == 7) period = 0;
79
- return isInPeriod(date, period, 'getDay');
80
- }
81
-
82
- function test(units, date, testFn) {
83
- return units.some((unit) => testFn(date, unit));
84
- }
85
-
86
- return patternArr.every((unit, idx) => {
87
- const unitValues = cronUnitToArray(unit);
88
- switch (idx) {
89
- case 0:
90
- return test(unitValues, date, monthDayInPeriod);
91
- case 1:
92
- return test(unitValues, date, monthInPeriod);
93
- case 2:
94
- return test(unitValues, date, weekDayInPeriod);
95
- default:
96
- return false;
97
- }
98
- });
99
- }
@@ -1,8 +0,0 @@
1
- import dayjs from 'dayjs';
2
-
3
- export const getLocaleDate = (date, locale) =>
4
- new Intl.DateTimeFormat(locale, {
5
- day: 'numeric',
6
- month: 'short',
7
- year: 'numeric',
8
- }).format(dayjs(date).toDate());
@@ -1,13 +0,0 @@
1
- import { isInPeriod, isValidSchedule } from './cronTabScheduler';
2
-
3
- export default (date, unit) => (disabled_day) => {
4
- if (Array.isArray(disabled_day)) {
5
- const MAX_DATE_TIMESTAMP = 8640000000000000;
6
- const [start, end] = disabled_day;
7
- return date.isBetween(start || -MAX_DATE_TIMESTAMP, end || MAX_DATE_TIMESTAMP, unit, '[]');
8
- }
9
- if (isValidSchedule(disabled_day)) {
10
- return isInPeriod(disabled_day, date.toDate());
11
- }
12
- return date.isSame(disabled_day, 'date');
13
- };
@@ -1,70 +0,0 @@
1
- import dayjs from 'dayjs';
2
-
3
- function getDayJSLocale(locale) {
4
- if (locale.includes('en') || locale.includes('ja')) {
5
- return 'en';
6
- }
7
- return 'ru';
8
- }
9
-
10
- export default function shortDateRangeFormat(dates, { locale = 'en-US', ...options }) {
11
- const { format } = new Intl.DateTimeFormat(locale, options);
12
- const normalizeDates = dates.map((date) => dayjs(date).toDate());
13
- const monthsYears = dates.map((date) => [
14
- dayjs(date).date(),
15
- dayjs(date).month(),
16
- dayjs(date).year(),
17
- ]);
18
-
19
- if (monthsYears.length > 1) {
20
- const isSimilarDay = monthsYears[0][0] === monthsYears[1][0];
21
- const isSimilarMonth = monthsYears[0][1] === monthsYears[1][1];
22
- const isSimilarYear = monthsYears[0][2] === monthsYears[1][2];
23
-
24
- if (isSimilarMonth && isSimilarYear && !options.day) {
25
- return format(normalizeDates[0]);
26
- }
27
- if (isSimilarMonth && isSimilarYear) {
28
- if (getDayJSLocale(locale) === 'en') {
29
- if (isSimilarDay) {
30
- return `${new Intl.DateTimeFormat(locale, { month: options.month }).format(
31
- normalizeDates[0],
32
- )} ${normalizeDates[0].getDate()}, ${normalizeDates[0].getFullYear()}`;
33
- }
34
- return `${new Intl.DateTimeFormat(locale, { month: options.month }).format(
35
- normalizeDates[0],
36
- )} ${normalizeDates[0].getDate()} - ${normalizeDates[1].getDate()}, ${normalizeDates[0].getFullYear()}`;
37
- }
38
- if (isSimilarDay) {
39
- return `${normalizeDates[0].getDate()} ${new Intl.DateTimeFormat(locale, {
40
- month: options.month,
41
- }).format(normalizeDates[0])} ${normalizeDates[0].getFullYear()}`;
42
- }
43
- return `${normalizeDates[0].getDate()} - ${normalizeDates[1].getDate()} ${new Intl.DateTimeFormat(
44
- locale,
45
- { month: options.month },
46
- ).format(normalizeDates[0])} ${normalizeDates[0].getFullYear()}`;
47
- }
48
-
49
- if (isSimilarYear) {
50
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
51
- const { year, ...newOptions } = options;
52
- if (getDayJSLocale(locale) === 'en') {
53
- return `${new Intl.DateTimeFormat(locale, newOptions).format(
54
- normalizeDates[0],
55
- )} - ${new Intl.DateTimeFormat(locale, newOptions).format(
56
- normalizeDates[1],
57
- )}, ${normalizeDates[0].getFullYear()}`;
58
- }
59
- return `${new Intl.DateTimeFormat(locale, newOptions).format(
60
- normalizeDates[0],
61
- )} - ${new Intl.DateTimeFormat(locale, newOptions).format(
62
- normalizeDates[1],
63
- )} ${normalizeDates[0].getFullYear()}`;
64
- }
65
-
66
- return `${format(normalizeDates[0])} - ${format(normalizeDates[1])}`;
67
- }
68
-
69
- return format(normalizeDates[0]);
70
- }