@semcore/date-picker 2.6.0 → 2.7.2
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 +1 -1
- package/lib/cjs/DatePicker.js +8 -4
- package/lib/cjs/DatePicker.js.map +1 -1
- package/lib/cjs/DateRangePicker.js +2 -2
- package/lib/cjs/DateRangePicker.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 +6 -2
- package/lib/cjs/components/ButtonTrigger.js.map +1 -1
- package/lib/cjs/components/Calendar.js +29 -22
- package/lib/cjs/components/Calendar.js.map +1 -1
- package/lib/cjs/components/PickerAbstract.js +6 -6
- package/lib/cjs/components/PickerAbstract.js.map +1 -1
- package/lib/cjs/components/RangePickerAbstract.js +6 -6
- package/lib/cjs/components/RangePickerAbstract.js.map +1 -1
- package/lib/cjs/components/index.js +12 -9
- package/lib/cjs/components/index.js.map +1 -1
- package/lib/cjs/index.js +5 -1
- package/lib/cjs/utils/cronTabScheduler.js +1 -1
- package/lib/cjs/utils/cronTabScheduler.js.map +1 -1
- package/lib/cjs/utils/includesDate.js.map +1 -1
- package/lib/cjs/utils/shortDateRangeFormat.js +5 -2
- package/lib/cjs/utils/shortDateRangeFormat.js.map +1 -1
- package/lib/es6/DatePicker.js +2 -2
- package/lib/es6/DatePicker.js.map +1 -1
- package/lib/es6/DateRangePicker.js +2 -2
- package/lib/es6/DateRangePicker.js.map +1 -1
- package/lib/es6/MonthPicker.js +2 -2
- package/lib/es6/MonthPicker.js.map +1 -1
- package/lib/es6/MonthRangePicker.js +2 -2
- package/lib/es6/MonthRangePicker.js.map +1 -1
- package/lib/es6/components/Calendar.js +20 -19
- package/lib/es6/components/Calendar.js.map +1 -1
- package/lib/es6/components/PickerAbstract.js +6 -6
- package/lib/es6/components/PickerAbstract.js.map +1 -1
- package/lib/es6/components/RangePickerAbstract.js +6 -6
- package/lib/es6/components/RangePickerAbstract.js.map +1 -1
- package/lib/es6/components/index.js +6 -5
- package/lib/es6/components/index.js.map +1 -1
- package/lib/es6/utils/cronTabScheduler.js.map +1 -1
- package/lib/es6/utils/includesDate.js.map +1 -1
- package/lib/es6/utils/shortDateRangeFormat.js +4 -2
- package/lib/es6/utils/shortDateRangeFormat.js.map +1 -1
- package/package.json +3 -3
- package/src/DatePicker.js +1 -3
- package/src/DateRangePicker.js +5 -30
- package/src/MonthPicker.js +1 -3
- package/src/MonthRangePicker.js +9 -32
- package/src/components/Calendar.js +1 -3
- package/src/components/PickerAbstract.js +3 -9
- package/src/components/RangePickerAbstract.js +5 -18
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/shortDateRangeFormat.js"],"names":["dayjs","getDayJSLocale","locale","includes","shortDateRangeFormat","dates","options","Intl","DateTimeFormat","format","normalizeDates","map","date","toDate","monthsYears","month","year","length","isSimilarDay","isSimilarMonth","isSimilarYear","day","getDate","getFullYear","newOptions"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/shortDateRangeFormat.js"],"names":["dayjs","getDayJSLocale","locale","includes","shortDateRangeFormat","dates","options","Intl","DateTimeFormat","format","normalizeDates","map","date","toDate","monthsYears","month","year","length","isSimilarDay","isSimilarMonth","isSimilarYear","day","getDate","getFullYear","newOptions"],"mappings":";;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;;AAEA,SAASC,cAAT,CAAwBC,MAAxB,EAAgC;AAC9B,MAAIA,MAAM,CAACC,QAAP,CAAgB,IAAhB,KAAyBD,MAAM,CAACC,QAAP,CAAgB,IAAhB,CAA7B,EAAoD;AAClD,WAAO,IAAP;AACD;;AACD,SAAO,IAAP;AACD;;AAED,eAAe,SAASC,oBAAT,CAA8BC,KAA9B,QAAuE;AAAA,yBAAhCH,MAAgC;AAAA,MAAhCA,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AAkBa,WAAlB,EAH/B;AAID;;AAED,QAAIH,aAAJ,EAAmB;AACjB,UAAQJ,IAAR,GAAgCV,OAAhC,CAAQU,IAAR;AAAA,UAAiBQ,UAAjB,4BAAgClB,OAAhC;;AACA,UAAIL,cAAc,CAACC,MAAD,CAAd,KAA2B,IAA/B,EAAqC;AACnC,yBAAU,IAAIK,IAAI,CAACC,cAAT,CAAwBN,MAAxB,EAAgCsB,UAAhC,EAA4Cf,MAA5C,CACRC,cAAc,CAAC,CAAD,CADN,CAAV,gBAEO,IAAIH,IAAI,CAACC,cAAT,CAAwBN,MAAxB,EAAgCsB,UAAhC,EAA4Cf,MAA5C,CACLC,cAAc,CAAC,CAAD,CADT,CAFP,eAIMA,cAAc,CAAC,CAAD,CAAd,CAAkBa,WAAlB,EAJN;AAKD;;AACD,uBAAU,IAAIhB,IAAI,CAACC,cAAT,CAAwBN,MAAxB,EAAgCsB,UAAhC,EAA4Cf,MAA5C,CACRC,cAAc,CAAC,CAAD,CADN,CAAV,gBAEO,IAAIH,IAAI,CAACC,cAAT,CAAwBN,MAAxB,EAAgCsB,UAAhC,EAA4Cf,MAA5C,CACLC,cAAc,CAAC,CAAD,CADT,CAFP,cAIKA,cAAc,CAAC,CAAD,CAAd,CAAkBa,WAAlB,EAJL;AAKD;;AAED,qBAAUd,MAAM,CAACC,cAAc,CAAC,CAAD,CAAf,CAAhB,gBAAyCD,MAAM,CAACC,cAAc,CAAC,CAAD,CAAf,CAA/C;AACD;;AAED,SAAOD,MAAM,CAACC,cAAc,CAAC,CAAD,CAAf,CAAb;AACD","sourcesContent":["import dayjs from 'dayjs';\n\nfunction getDayJSLocale(locale) {\n if (locale.includes('en') || locale.includes('ja')) {\n return 'en';\n }\n return 'ru';\n}\n\nexport default function shortDateRangeFormat(dates, { locale = 'en-US', ...options }) {\n const { format } = new Intl.DateTimeFormat(locale, options);\n const normalizeDates = dates.map((date) => dayjs(date).toDate());\n const monthsYears = dates.map((date) => [\n dayjs(date).date(),\n dayjs(date).month(),\n dayjs(date).year(),\n ]);\n\n if (monthsYears.length > 1) {\n const isSimilarDay = monthsYears[0][0] === monthsYears[1][0];\n const isSimilarMonth = monthsYears[0][1] === monthsYears[1][1];\n const isSimilarYear = monthsYears[0][2] === monthsYears[1][2];\n\n if (isSimilarMonth && isSimilarYear && !options.day) {\n return format(normalizeDates[0]);\n }\n if (isSimilarMonth && isSimilarYear) {\n if (getDayJSLocale(locale) === 'en') {\n if (isSimilarDay) {\n return `${new Intl.DateTimeFormat(locale, { month: options.month }).format(\n normalizeDates[0],\n )} ${normalizeDates[0].getDate()}, ${normalizeDates[0].getFullYear()}`;\n }\n return `${new Intl.DateTimeFormat(locale, { month: options.month }).format(\n normalizeDates[0],\n )} ${normalizeDates[0].getDate()} - ${normalizeDates[1].getDate()}, ${normalizeDates[0].getFullYear()}`;\n }\n if (isSimilarDay) {\n return `${normalizeDates[0].getDate()} ${new Intl.DateTimeFormat(locale, {\n month: options.month,\n }).format(normalizeDates[0])} ${normalizeDates[0].getFullYear()}`;\n }\n return `${normalizeDates[0].getDate()} - ${normalizeDates[1].getDate()} ${new Intl.DateTimeFormat(\n locale,\n { month: options.month },\n ).format(normalizeDates[0])} ${normalizeDates[0].getFullYear()}`;\n }\n\n if (isSimilarYear) {\n const { year, ...newOptions } = options;\n if (getDayJSLocale(locale) === 'en') {\n return `${new Intl.DateTimeFormat(locale, newOptions).format(\n normalizeDates[0],\n )} - ${new Intl.DateTimeFormat(locale, newOptions).format(\n normalizeDates[1],\n )}, ${normalizeDates[0].getFullYear()}`;\n }\n return `${new Intl.DateTimeFormat(locale, newOptions).format(\n normalizeDates[0],\n )} - ${new Intl.DateTimeFormat(locale, newOptions).format(\n normalizeDates[1],\n )} ${normalizeDates[0].getFullYear()}`;\n }\n\n return `${format(normalizeDates[0])} - ${format(normalizeDates[1])}`;\n }\n\n return format(normalizeDates[0]);\n}\n"],"file":"shortDateRangeFormat.js"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semcore/date-picker",
|
|
3
3
|
"description": "SEMRush DatePicker Component",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.7.2",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es6/index.js",
|
|
7
7
|
"typings": "lib/types/index.d.ts",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"@semcore/utils": "^3.27",
|
|
17
17
|
"@semcore/base-trigger": "^2",
|
|
18
18
|
"@semcore/flex-box": "^4",
|
|
19
|
-
"@semcore/button": "^3",
|
|
19
|
+
"@semcore/button": "^3.3.2",
|
|
20
20
|
"@semcore/divider": "^2",
|
|
21
21
|
"@semcore/icon": "^2.16",
|
|
22
22
|
"@semcore/dropdown": "^2",
|
|
@@ -28,6 +28,6 @@
|
|
|
28
28
|
"react": "16.8 - 17"
|
|
29
29
|
},
|
|
30
30
|
"jest": {
|
|
31
|
-
"preset": "jest-preset-ui"
|
|
31
|
+
"preset": "@semcore/jest-preset-ui"
|
|
32
32
|
}
|
|
33
33
|
}
|
package/src/DatePicker.js
CHANGED
|
@@ -64,9 +64,7 @@ export class DatePickerRoot extends PickerAbstract {
|
|
|
64
64
|
return {
|
|
65
65
|
...super.getTitleProps(),
|
|
66
66
|
children: new Intl.DateTimeFormat(locale, { month: 'long', year: 'numeric' }).format(
|
|
67
|
-
dayjs(displayedPeriod)
|
|
68
|
-
.startOf('month')
|
|
69
|
-
.toDate(),
|
|
67
|
+
dayjs(displayedPeriod).startOf('month').toDate(),
|
|
70
68
|
),
|
|
71
69
|
};
|
|
72
70
|
}
|
package/src/DateRangePicker.js
CHANGED
|
@@ -35,48 +35,23 @@ class DateRangePickerRoot extends RangePickerAbstract {
|
|
|
35
35
|
return [
|
|
36
36
|
{
|
|
37
37
|
children: getI18nText('last2Days'),
|
|
38
|
-
value: [
|
|
39
|
-
dayjs(today)
|
|
40
|
-
.subtract(1, 'day')
|
|
41
|
-
.toDate(),
|
|
42
|
-
today,
|
|
43
|
-
],
|
|
38
|
+
value: [dayjs(today).subtract(1, 'day').toDate(), today],
|
|
44
39
|
},
|
|
45
40
|
{
|
|
46
41
|
children: getI18nText('lastWeek'),
|
|
47
|
-
value: [
|
|
48
|
-
dayjs(today)
|
|
49
|
-
.subtract(6, 'day')
|
|
50
|
-
.toDate(),
|
|
51
|
-
today,
|
|
52
|
-
],
|
|
42
|
+
value: [dayjs(today).subtract(6, 'day').toDate(), today],
|
|
53
43
|
},
|
|
54
44
|
{
|
|
55
45
|
children: getI18nText('last2Weeks'),
|
|
56
|
-
value: [
|
|
57
|
-
dayjs(today)
|
|
58
|
-
.subtract(13, 'day')
|
|
59
|
-
.toDate(),
|
|
60
|
-
today,
|
|
61
|
-
],
|
|
46
|
+
value: [dayjs(today).subtract(13, 'day').toDate(), today],
|
|
62
47
|
},
|
|
63
48
|
{
|
|
64
49
|
children: getI18nText('lastMonth'),
|
|
65
|
-
value: [
|
|
66
|
-
dayjs(today)
|
|
67
|
-
.subtract(1, 'month')
|
|
68
|
-
.toDate(),
|
|
69
|
-
today,
|
|
70
|
-
],
|
|
50
|
+
value: [dayjs(today).subtract(1, 'month').toDate(), today],
|
|
71
51
|
},
|
|
72
52
|
{
|
|
73
53
|
children: getI18nText('last2Months'),
|
|
74
|
-
value: [
|
|
75
|
-
dayjs(today)
|
|
76
|
-
.subtract(2, 'month')
|
|
77
|
-
.toDate(),
|
|
78
|
-
today,
|
|
79
|
-
],
|
|
54
|
+
value: [dayjs(today).subtract(2, 'month').toDate(), today],
|
|
80
55
|
},
|
|
81
56
|
];
|
|
82
57
|
}
|
package/src/MonthPicker.js
CHANGED
|
@@ -46,9 +46,7 @@ class MonthPickerRoot extends PickerAbstract {
|
|
|
46
46
|
return {
|
|
47
47
|
...super.getTitleProps(),
|
|
48
48
|
children: new Intl.DateTimeFormat(locale, { year: 'numeric' }).format(
|
|
49
|
-
dayjs(displayedPeriod)
|
|
50
|
-
.startOf('year')
|
|
51
|
-
.toDate(),
|
|
49
|
+
dayjs(displayedPeriod).startOf('year').toDate(),
|
|
52
50
|
),
|
|
53
51
|
};
|
|
54
52
|
}
|
package/src/MonthRangePicker.js
CHANGED
|
@@ -36,49 +36,29 @@ class MonthRangePickerRoot extends RangePickerAbstract {
|
|
|
36
36
|
{
|
|
37
37
|
children: getI18nText('lastMonth'),
|
|
38
38
|
value: [
|
|
39
|
-
dayjs(today)
|
|
40
|
-
|
|
41
|
-
.startOf('month')
|
|
42
|
-
.toDate(),
|
|
43
|
-
dayjs(today)
|
|
44
|
-
.startOf('month')
|
|
45
|
-
.toDate(),
|
|
39
|
+
dayjs(today).subtract(1, 'month').startOf('month').toDate(),
|
|
40
|
+
dayjs(today).startOf('month').toDate(),
|
|
46
41
|
],
|
|
47
42
|
},
|
|
48
43
|
{
|
|
49
44
|
children: getI18nText('last3Months'),
|
|
50
45
|
value: [
|
|
51
|
-
dayjs(today)
|
|
52
|
-
|
|
53
|
-
.startOf('month')
|
|
54
|
-
.toDate(),
|
|
55
|
-
dayjs(today)
|
|
56
|
-
.startOf('month')
|
|
57
|
-
.toDate(),
|
|
46
|
+
dayjs(today).subtract(2, 'month').startOf('month').toDate(),
|
|
47
|
+
dayjs(today).startOf('month').toDate(),
|
|
58
48
|
],
|
|
59
49
|
},
|
|
60
50
|
{
|
|
61
51
|
children: getI18nText('last6Months'),
|
|
62
52
|
value: [
|
|
63
|
-
dayjs(today)
|
|
64
|
-
|
|
65
|
-
.startOf('month')
|
|
66
|
-
.toDate(),
|
|
67
|
-
dayjs(today)
|
|
68
|
-
.startOf('month')
|
|
69
|
-
.toDate(),
|
|
53
|
+
dayjs(today).subtract(5, 'month').startOf('month').toDate(),
|
|
54
|
+
dayjs(today).startOf('month').toDate(),
|
|
70
55
|
],
|
|
71
56
|
},
|
|
72
57
|
{
|
|
73
58
|
children: getI18nText('last12Months'),
|
|
74
59
|
value: [
|
|
75
|
-
dayjs(today)
|
|
76
|
-
|
|
77
|
-
.startOf('month')
|
|
78
|
-
.toDate(),
|
|
79
|
-
dayjs(today)
|
|
80
|
-
.startOf('month')
|
|
81
|
-
.toDate(),
|
|
60
|
+
dayjs(today).subtract(11, 'month').startOf('month').toDate(),
|
|
61
|
+
dayjs(today).startOf('month').toDate(),
|
|
82
62
|
],
|
|
83
63
|
},
|
|
84
64
|
];
|
|
@@ -102,10 +82,7 @@ class MonthRangePickerRoot extends RangePickerAbstract {
|
|
|
102
82
|
return {
|
|
103
83
|
...super.getTitleProps(props, index),
|
|
104
84
|
children: new Intl.DateTimeFormat(locale, { year: 'numeric' }).format(
|
|
105
|
-
dayjs(displayedPeriod)
|
|
106
|
-
.add(index, this.navigateStep)
|
|
107
|
-
.startOf(this.navigateStep)
|
|
108
|
-
.toDate(),
|
|
85
|
+
dayjs(displayedPeriod).add(index, this.navigateStep).startOf(this.navigateStep).toDate(),
|
|
109
86
|
),
|
|
110
87
|
};
|
|
111
88
|
}
|
|
@@ -37,9 +37,7 @@ class CalendarWeekDaysRoot extends Component {
|
|
|
37
37
|
getDaysByWeek() {
|
|
38
38
|
const { locale } = this.asProps;
|
|
39
39
|
|
|
40
|
-
let date = dayjs()
|
|
41
|
-
.locale(locale, getDayJSLocaleParams(locale))
|
|
42
|
-
.startOf('week');
|
|
40
|
+
let date = dayjs().locale(locale, getDayJSLocaleParams(locale)).startOf('week');
|
|
43
41
|
return range(7, () => {
|
|
44
42
|
const weekday = new Intl.DateTimeFormat(locale, { weekday: 'short' }).format(date.valueOf());
|
|
45
43
|
date = date.add(1, 'day');
|
|
@@ -42,15 +42,11 @@ class PickerAbstract extends Component {
|
|
|
42
42
|
static enhance = [i18nEnhance()];
|
|
43
43
|
|
|
44
44
|
static add = (date, amount, unit) => {
|
|
45
|
-
return dayjs(date)
|
|
46
|
-
.add(amount, unit)
|
|
47
|
-
.toDate();
|
|
45
|
+
return dayjs(date).add(amount, unit).toDate();
|
|
48
46
|
};
|
|
49
47
|
|
|
50
48
|
static subtract = (date, amount, unit) => {
|
|
51
|
-
return dayjs(date)
|
|
52
|
-
.subtract(amount, unit)
|
|
53
|
-
.toDate();
|
|
49
|
+
return dayjs(date).subtract(amount, unit).toDate();
|
|
54
50
|
};
|
|
55
51
|
|
|
56
52
|
navigateStep;
|
|
@@ -84,9 +80,7 @@ class PickerAbstract extends Component {
|
|
|
84
80
|
navigateView = (direction) => {
|
|
85
81
|
const { displayedPeriod } = this.asProps;
|
|
86
82
|
const action = direction >= 1 ? 'add' : 'subtract';
|
|
87
|
-
const date = dayjs(displayedPeriod)
|
|
88
|
-
[action](1, this.navigateStep)
|
|
89
|
-
.toDate();
|
|
83
|
+
const date = dayjs(displayedPeriod)[action](1, this.navigateStep).toDate();
|
|
90
84
|
this.handlers.displayedPeriod(date);
|
|
91
85
|
};
|
|
92
86
|
|
|
@@ -51,15 +51,11 @@ class RangePickerAbstract extends Component {
|
|
|
51
51
|
static enhance = [i18nEnhance()];
|
|
52
52
|
|
|
53
53
|
static add = (date, amount, unit) => {
|
|
54
|
-
return dayjs(date)
|
|
55
|
-
.add(amount, unit)
|
|
56
|
-
.toDate();
|
|
54
|
+
return dayjs(date).add(amount, unit).toDate();
|
|
57
55
|
};
|
|
58
56
|
|
|
59
57
|
static subtract = (date, amount, unit) => {
|
|
60
|
-
return dayjs(date)
|
|
61
|
-
.subtract(amount, unit)
|
|
62
|
-
.toDate();
|
|
58
|
+
return dayjs(date).subtract(amount, unit).toDate();
|
|
63
59
|
};
|
|
64
60
|
|
|
65
61
|
navigateStep;
|
|
@@ -100,9 +96,7 @@ class RangePickerAbstract extends Component {
|
|
|
100
96
|
navigateView = (direction) => {
|
|
101
97
|
const { displayedPeriod } = this.asProps;
|
|
102
98
|
const action = direction >= 1 ? 'add' : 'subtract';
|
|
103
|
-
const date = dayjs(displayedPeriod)
|
|
104
|
-
[action](1, this.navigateStep)
|
|
105
|
-
.toDate();
|
|
99
|
+
const date = dayjs(displayedPeriod)[action](1, this.navigateStep).toDate();
|
|
106
100
|
this.handlers.displayedPeriod(date);
|
|
107
101
|
};
|
|
108
102
|
|
|
@@ -145,11 +139,7 @@ class RangePickerAbstract extends Component {
|
|
|
145
139
|
.toDate(),
|
|
146
140
|
];
|
|
147
141
|
} else {
|
|
148
|
-
next_highlighted = [
|
|
149
|
-
dayjs(highlighted[0])
|
|
150
|
-
.add(day, this.keyStep)
|
|
151
|
-
.toDate(),
|
|
152
|
-
];
|
|
142
|
+
next_highlighted = [dayjs(highlighted[0]).add(day, this.keyStep).toDate()];
|
|
153
143
|
}
|
|
154
144
|
this.handlers.highlighted(next_highlighted);
|
|
155
145
|
this.handlers.displayedPeriod(setNextDisplayedPeriod(next_highlighted));
|
|
@@ -284,10 +274,7 @@ class RangePickerAbstract extends Component {
|
|
|
284
274
|
const { locale, displayedPeriod } = this.asProps;
|
|
285
275
|
return {
|
|
286
276
|
children: new Intl.DateTimeFormat(locale, { month: 'long', year: 'numeric' }).format(
|
|
287
|
-
dayjs(displayedPeriod)
|
|
288
|
-
.add(index, this.navigateStep)
|
|
289
|
-
.startOf(this.navigateStep)
|
|
290
|
-
.toDate(),
|
|
277
|
+
dayjs(displayedPeriod).add(index, this.navigateStep).startOf(this.navigateStep).toDate(),
|
|
291
278
|
),
|
|
292
279
|
};
|
|
293
280
|
}
|