@alfalab/core-components-calendar-range 7.0.6 → 7.0.8
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/Component.js +7 -2
- package/components/divider/Component.d.ts +8 -0
- package/components/divider/Component.js +25 -0
- package/components/divider/index.css +75 -0
- package/components/divider/index.d.ts +1 -0
- package/components/divider/index.js +9 -0
- package/cssm/Component.js +7 -1
- package/cssm/components/divider/Component.d.ts +8 -0
- package/cssm/components/divider/Component.js +24 -0
- package/cssm/components/divider/index.d.ts +1 -0
- package/cssm/components/divider/index.js +10 -0
- package/cssm/components/divider/index.module.css +74 -0
- package/cssm/hooks.js +31 -22
- package/cssm/index.js +2 -0
- package/cssm/views/index.module.css +0 -21
- package/cssm/views/popover.js +14 -5
- package/cssm/views/static.js +22 -9
- package/esm/Component.js +2 -1
- package/esm/components/divider/Component.d.ts +8 -0
- package/esm/components/divider/Component.js +18 -0
- package/esm/components/divider/index.css +75 -0
- package/esm/components/divider/index.d.ts +1 -0
- package/esm/components/divider/index.js +3 -0
- package/esm/index.js +2 -1
- package/esm/{index.module-bf0c7948.d.ts → index.module-1aaed941.d.ts} +0 -0
- package/esm/{index.module-bf0c7948.js → index.module-1aaed941.js} +1 -1
- package/esm/views/index.css +6 -27
- package/esm/views/popover.js +3 -2
- package/esm/views/static.js +3 -2
- package/hooks.js +31 -22
- package/index.js +2 -1
- package/{index.module-3391f602.d.ts → index.module-255b4286.d.ts} +0 -0
- package/{index.module-3391f602.js → index.module-255b4286.js} +1 -1
- package/modern/Component.js +2 -1
- package/modern/components/divider/Component.d.ts +8 -0
- package/modern/components/divider/Component.js +16 -0
- package/modern/components/divider/index.css +75 -0
- package/modern/components/divider/index.d.ts +1 -0
- package/modern/components/divider/index.js +3 -0
- package/modern/index.js +2 -1
- package/modern/index.module-491eb220.js +4 -0
- package/modern/views/index.css +6 -27
- package/modern/views/popover.js +3 -2
- package/modern/views/static.js +3 -2
- package/package.json +4 -4
- package/views/index.css +6 -27
- package/views/popover.js +13 -6
- package/views/static.js +21 -10
- package/modern/index.module-5493f8ee.js +0 -4
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/* hash: 1udsd */
|
|
2
|
+
:root {
|
|
3
|
+
--color-light-graphic-primary: #0b1f35;
|
|
4
|
+
}
|
|
5
|
+
:root {
|
|
6
|
+
|
|
7
|
+
/* Hard */
|
|
8
|
+
|
|
9
|
+
/* Up */
|
|
10
|
+
|
|
11
|
+
/* Hard up */
|
|
12
|
+
}
|
|
13
|
+
:root {
|
|
14
|
+
--gap-xs: 8px;
|
|
15
|
+
}
|
|
16
|
+
:root {
|
|
17
|
+
--size-s-height: 48px;
|
|
18
|
+
--size-m-height: 56px;
|
|
19
|
+
--size-l-height: 64px;
|
|
20
|
+
--size-xl-height: 72px;
|
|
21
|
+
}
|
|
22
|
+
:root {
|
|
23
|
+
|
|
24
|
+
/* Кнопки выбора месяцев и годов */
|
|
25
|
+
|
|
26
|
+
/* Шапка */
|
|
27
|
+
|
|
28
|
+
/* День */
|
|
29
|
+
|
|
30
|
+
/* today */
|
|
31
|
+
|
|
32
|
+
/* highlighted */
|
|
33
|
+
|
|
34
|
+
/* holidays */
|
|
35
|
+
|
|
36
|
+
/* range */
|
|
37
|
+
|
|
38
|
+
/* selected */
|
|
39
|
+
|
|
40
|
+
/* disabled */
|
|
41
|
+
|
|
42
|
+
/* marker */
|
|
43
|
+
}
|
|
44
|
+
.calendar-range__component_1tbg6 {
|
|
45
|
+
display: flex;
|
|
46
|
+
align-items: center;
|
|
47
|
+
justify-content: center;
|
|
48
|
+
width: 16px;
|
|
49
|
+
margin: 0 var(--gap-xs)
|
|
50
|
+
}
|
|
51
|
+
.calendar-range__component_1tbg6:after {
|
|
52
|
+
content: '';
|
|
53
|
+
display: block;
|
|
54
|
+
width: 100%;
|
|
55
|
+
height: 1px;
|
|
56
|
+
background-color: var(--color-light-graphic-primary);
|
|
57
|
+
}
|
|
58
|
+
.calendar-range__outer_1tbg6 {
|
|
59
|
+
position: relative;
|
|
60
|
+
|
|
61
|
+
/* FormControl .above height + margin-bottom */
|
|
62
|
+
top: 24px;
|
|
63
|
+
}
|
|
64
|
+
.calendar-range__s_1tbg6 {
|
|
65
|
+
height: var(--size-s-height);
|
|
66
|
+
}
|
|
67
|
+
.calendar-range__m_1tbg6 {
|
|
68
|
+
height: var(--size-m-height);
|
|
69
|
+
}
|
|
70
|
+
.calendar-range__l_1tbg6 {
|
|
71
|
+
height: var(--size-l-height);
|
|
72
|
+
}
|
|
73
|
+
.calendar-range__xl_1tbg6 {
|
|
74
|
+
height: var(--size-xl-height);
|
|
75
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Component";
|
package/esm/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export { CalendarRange } from './Component.js';
|
|
2
|
-
import './index.module-
|
|
2
|
+
import './index.module-1aaed941.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
import './views/popover.js';
|
|
5
5
|
import 'classnames';
|
|
6
6
|
import 'date-fns/startOfMonth';
|
|
7
7
|
import '@alfalab/core-components-calendar-input/esm';
|
|
8
8
|
import '@alfalab/core-components-date-input/esm';
|
|
9
|
+
import './components/divider/Component.js';
|
|
9
10
|
import './hooks.js';
|
|
10
11
|
import 'date-fns/addMonths';
|
|
11
12
|
import 'date-fns/isEqual';
|
|
File without changes
|
|
@@ -37,7 +37,7 @@ function __rest(s, e) {
|
|
|
37
37
|
return t;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
var styles = {"component":"calendar-
|
|
40
|
+
var styles = {"component":"calendar-range__component_1ci3b","static":"calendar-range__static_1ci3b","calendar":"calendar-range__calendar_1ci3b"};
|
|
41
41
|
require('./views/index.css')
|
|
42
42
|
|
|
43
43
|
export { __rest as _, __assign as a, styles as s };
|
package/esm/views/index.css
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
2
|
-
:root {
|
|
3
|
-
--color-light-graphic-primary: #0b1f35;
|
|
4
|
-
}
|
|
1
|
+
/* hash: 1y02j */
|
|
5
2
|
:root {
|
|
6
3
|
|
|
7
4
|
/* Hard */
|
|
@@ -10,9 +7,6 @@
|
|
|
10
7
|
|
|
11
8
|
/* Hard up */
|
|
12
9
|
}
|
|
13
|
-
:root {
|
|
14
|
-
--gap-xs: 8px;
|
|
15
|
-
}
|
|
16
10
|
:root {
|
|
17
11
|
--calendar-inner-width: 280px;
|
|
18
12
|
|
|
@@ -36,33 +30,18 @@
|
|
|
36
30
|
|
|
37
31
|
/* marker */
|
|
38
32
|
}
|
|
39
|
-
.calendar-
|
|
33
|
+
.calendar-range__component_1ci3b {
|
|
40
34
|
display: flex
|
|
41
35
|
}
|
|
42
|
-
.calendar-
|
|
36
|
+
.calendar-range__component_1ci3b button[aria-selected='true'] {
|
|
43
37
|
cursor: pointer;
|
|
44
38
|
}
|
|
45
|
-
.calendar-
|
|
39
|
+
.calendar-range__component_1ci3b *[class*='errorIcon_'] {
|
|
46
40
|
display: none;
|
|
47
41
|
}
|
|
48
|
-
.calendar-
|
|
42
|
+
.calendar-range__component_1ci3b *[class*='calendarIcon_'] {
|
|
49
43
|
margin-right: 0;
|
|
50
44
|
}
|
|
51
|
-
.calendar-
|
|
52
|
-
height: 48px;
|
|
53
|
-
display: flex;
|
|
54
|
-
align-items: center;
|
|
55
|
-
justify-content: center;
|
|
56
|
-
width: 16px;
|
|
57
|
-
margin: 0 var(--gap-xs)
|
|
58
|
-
}
|
|
59
|
-
.calendar-range__divider_17yx8:after {
|
|
60
|
-
content: '';
|
|
61
|
-
display: block;
|
|
62
|
-
width: 100%;
|
|
63
|
-
height: 1px;
|
|
64
|
-
background-color: var(--color-light-graphic-primary);
|
|
65
|
-
}
|
|
66
|
-
.calendar-range__static_17yx8 .calendar-range__calendar_17yx8 {
|
|
45
|
+
.calendar-range__static_1ci3b .calendar-range__calendar_1ci3b {
|
|
67
46
|
width: var(--calendar-inner-width);
|
|
68
47
|
}
|
package/esm/views/popover.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { s as styles, a as __assign } from '../index.module-
|
|
1
|
+
import { s as styles, a as __assign } from '../index.module-1aaed941.js';
|
|
2
2
|
import React, { useState, useCallback, useEffect } from 'react';
|
|
3
3
|
import cn from 'classnames';
|
|
4
4
|
import startOfMonth from 'date-fns/startOfMonth';
|
|
5
5
|
import { isValidInputValue, parseDateString, CalendarInput } from '@alfalab/core-components-calendar-input/esm';
|
|
6
6
|
import { isCompleteDateInput } from '@alfalab/core-components-date-input/esm';
|
|
7
|
+
import { Divider } from '../components/divider/Component.js';
|
|
7
8
|
import { usePopoverViewMonthes } from '../hooks.js';
|
|
8
9
|
import 'date-fns/addMonths';
|
|
9
10
|
import 'date-fns/isEqual';
|
|
@@ -106,7 +107,7 @@ var CalendarRangePopover = function (_a) {
|
|
|
106
107
|
}, [hasValidateError]);
|
|
107
108
|
return (React.createElement("div", { className: cn(styles.component, className), "data-test-id": dataTestId },
|
|
108
109
|
React.createElement(CalendarInput, __assign({}, inputFromProps, { useAnchorWidth: false, calendarPosition: 'popover', popoverPosition: 'bottom-start', error: inputFromInvalid || bothInvalid || inputFromProps.error, onChange: handleFromChange, onInputChange: handleInputFromChange, onBlur: handleInputFromBlur, value: inputFromValue, minDate: minDate, maxDate: maxDate, offDays: offDays, events: events, calendarProps: __assign(__assign({}, inputFromProps.calendarProps), { month: monthFrom, onMonthChange: handleMonthFromChange, selectorView: 'full' }) })),
|
|
109
|
-
React.createElement(
|
|
110
|
+
React.createElement(Divider, { inputFromProps: inputFromProps, inputToProps: inputToProps }),
|
|
110
111
|
React.createElement(CalendarInput, __assign({}, inputToProps, { useAnchorWidth: false, calendarPosition: 'popover', popoverPosition: 'bottom-end', error: inputToInvalid || bothInvalid || inputToProps.error, onChange: handleToChange, onInputChange: handleInputToChange, onBlur: handleInputToBlur, value: inputToValue, minDate: dateFrom || minDate, maxDate: maxDate, offDays: offDays, events: events, calendarProps: __assign(__assign({}, inputToProps.calendarProps), { month: monthTo, onMonthChange: handleMonthToChange, selectorView: 'full' }) }))));
|
|
111
112
|
};
|
|
112
113
|
|
package/esm/views/static.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as __rest, s as styles, a as __assign } from '../index.module-
|
|
1
|
+
import { _ as __rest, s as styles, a as __assign } from '../index.module-1aaed941.js';
|
|
2
2
|
import React, { useState, useCallback, useEffect } from 'react';
|
|
3
3
|
import cn from 'classnames';
|
|
4
4
|
import addMonths from 'date-fns/addMonths';
|
|
@@ -9,6 +9,7 @@ import subMonths from 'date-fns/subMonths';
|
|
|
9
9
|
import { usePeriodWithReset, Calendar } from '@alfalab/core-components-calendar/esm';
|
|
10
10
|
import { isValidInputValue, parseDateString, formatDate } from '@alfalab/core-components-calendar-input/esm';
|
|
11
11
|
import { isCompleteDateInput, DateInput } from '@alfalab/core-components-date-input/esm';
|
|
12
|
+
import { Divider } from '../components/divider/Component.js';
|
|
12
13
|
import { useStaticViewMonthes, useSelectionProps } from '../hooks.js';
|
|
13
14
|
import { isDayButton } from '../utils.js';
|
|
14
15
|
import 'date-fns/isEqual';
|
|
@@ -151,7 +152,7 @@ var CalendarRangeStatic = function (_a) {
|
|
|
151
152
|
? 'input'
|
|
152
153
|
: dateInputFromProps.mobileMode, value: inputFromValue, onChange: handleInputFromChange, onClear: handleClearFrom, onBlur: handleValidInputFrom, error: bothInvalid || inputFromInvalid || dateInputFromProps.error, clear: true, block: true })),
|
|
153
154
|
React.createElement(CalendarFromComponent, __assign({}, calendarFromProps, { className: cn(styles.calendar, calendarFromProps === null || calendarFromProps === void 0 ? void 0 : calendarFromProps.className), month: monthFrom, selectorView: 'month-only', offDays: offDays, events: events, onChange: period.updatePeriod, onMonthChange: handleMonthFromChange, minDate: minDate, maxDate: maxDate && max([maxDate, endOfMonth(subMonths(maxDate, 1))]).getTime() }, rangeProps))),
|
|
154
|
-
React.createElement(
|
|
155
|
+
React.createElement(Divider, { inputFromProps: inputFromProps, inputToProps: inputToProps }),
|
|
155
156
|
React.createElement("div", null,
|
|
156
157
|
React.createElement(DateInput, __assign({}, dateInputToProps, { mobileMode: dateInputToProps.mobileMode === 'popover'
|
|
157
158
|
? 'input'
|
package/hooks.js
CHANGED
|
@@ -8,6 +8,15 @@ var min = require('date-fns/min');
|
|
|
8
8
|
var startOfMonth = require('date-fns/startOfMonth');
|
|
9
9
|
var subMonths = require('date-fns/subMonths');
|
|
10
10
|
|
|
11
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
12
|
+
|
|
13
|
+
var addMonths__default = /*#__PURE__*/_interopDefaultCompat(addMonths);
|
|
14
|
+
var isEqual__default = /*#__PURE__*/_interopDefaultCompat(isEqual);
|
|
15
|
+
var max__default = /*#__PURE__*/_interopDefaultCompat(max);
|
|
16
|
+
var min__default = /*#__PURE__*/_interopDefaultCompat(min);
|
|
17
|
+
var startOfMonth__default = /*#__PURE__*/_interopDefaultCompat(startOfMonth);
|
|
18
|
+
var subMonths__default = /*#__PURE__*/_interopDefaultCompat(subMonths);
|
|
19
|
+
|
|
11
20
|
function usePopoverViewMonthes(_a) {
|
|
12
21
|
var dateFrom = _a.dateFrom, dateTo = _a.dateTo, defaultMonth = _a.defaultMonth, resetKey = _a.resetKey;
|
|
13
22
|
var _b = React.useState(), monthFrom = _b[0], setMonthFrom = _b[1];
|
|
@@ -25,10 +34,10 @@ function usePopoverViewMonthes(_a) {
|
|
|
25
34
|
}
|
|
26
35
|
}, [dateFrom]);
|
|
27
36
|
React.useEffect(function () {
|
|
28
|
-
setMonthFrom(dateFrom ?
|
|
37
|
+
setMonthFrom(dateFrom ? startOfMonth__default.default(dateFrom).getTime() : defaultMonth);
|
|
29
38
|
}, [defaultMonth, dateFrom, resetKey]);
|
|
30
39
|
React.useEffect(function () {
|
|
31
|
-
setMonthTo(dateTo ?
|
|
40
|
+
setMonthTo(dateTo ? startOfMonth__default.default(dateTo).getTime() : monthFrom);
|
|
32
41
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
33
42
|
}, [dateTo, resetKey]);
|
|
34
43
|
return {
|
|
@@ -44,44 +53,44 @@ function useStaticViewMonthes(_a) {
|
|
|
44
53
|
* Если указана начальная дата — левый месяц равен ей, иначе используется дата конца.
|
|
45
54
|
* Если обе даты не указаны, то используется дефолтный месяц
|
|
46
55
|
*/
|
|
47
|
-
var initialMonthFrom = React.useMemo(function () { return
|
|
56
|
+
var initialMonthFrom = React.useMemo(function () { return startOfMonth__default.default(selectedFrom || selectedTo || defaultMonth).getTime(); },
|
|
48
57
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
49
58
|
[]);
|
|
50
59
|
/**
|
|
51
60
|
* Правый месяц должен быть как минимум на 1 месяц больше левого
|
|
52
61
|
*/
|
|
53
62
|
var initialMonthTo = React.useMemo(function () {
|
|
54
|
-
return
|
|
55
|
-
selectedTo ?
|
|
56
|
-
|
|
63
|
+
return max__default.default([
|
|
64
|
+
selectedTo ? startOfMonth__default.default(selectedTo) : 0,
|
|
65
|
+
addMonths__default.default(initialMonthFrom, 1),
|
|
57
66
|
]).getTime();
|
|
58
67
|
},
|
|
59
68
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
60
69
|
[]);
|
|
61
70
|
if (defaultMonthPosition === 'right') {
|
|
62
71
|
initialMonthTo = initialMonthFrom;
|
|
63
|
-
initialMonthFrom =
|
|
72
|
+
initialMonthFrom = subMonths__default.default(initialMonthFrom, 1).getTime();
|
|
64
73
|
}
|
|
65
74
|
var _b = React.useState(initialMonthFrom), monthFrom = _b[0], setMonthFrom = _b[1];
|
|
66
75
|
var _c = React.useState(initialMonthTo), monthTo = _c[0], setMonthTo = _c[1];
|
|
67
76
|
var handleMonthFromChange = React.useCallback(function (newMonthFrom) {
|
|
68
77
|
setMonthFrom(newMonthFrom);
|
|
69
|
-
if (monthTo &&
|
|
70
|
-
var nextMonth =
|
|
78
|
+
if (monthTo && isEqual__default.default(newMonthFrom, monthTo)) {
|
|
79
|
+
var nextMonth = addMonths__default.default(newMonthFrom, 1).getTime();
|
|
71
80
|
setMonthTo(nextMonth);
|
|
72
81
|
}
|
|
73
82
|
}, [monthTo]);
|
|
74
83
|
var handleMonthToChange = React.useCallback(function (newMonthTo) {
|
|
75
84
|
setMonthTo(newMonthTo);
|
|
76
|
-
if (monthFrom &&
|
|
77
|
-
var prevMonth =
|
|
85
|
+
if (monthFrom && isEqual__default.default(newMonthTo, monthFrom)) {
|
|
86
|
+
var prevMonth = subMonths__default.default(newMonthTo, 1).getTime();
|
|
78
87
|
setMonthFrom(prevMonth);
|
|
79
88
|
}
|
|
80
89
|
}, [monthFrom]);
|
|
81
90
|
// eslint-disable-next-line complexity
|
|
82
91
|
React.useEffect(function () {
|
|
83
|
-
var selectedFromMonth = selectedFrom ?
|
|
84
|
-
var selectedToMonth = selectedTo ?
|
|
92
|
+
var selectedFromMonth = selectedFrom ? startOfMonth__default.default(selectedFrom).getTime() : undefined;
|
|
93
|
+
var selectedToMonth = selectedTo ? startOfMonth__default.default(selectedTo).getTime() : undefined;
|
|
85
94
|
// Проверяем, показываются ли выбранные месяцы в левой или правой части компонента
|
|
86
95
|
var fromMonthOnLeft = selectedFromMonth && selectedFromMonth === monthFrom;
|
|
87
96
|
var fromMonthOnRight = selectedFromMonth && selectedFromMonth === monthTo;
|
|
@@ -90,25 +99,25 @@ function useStaticViewMonthes(_a) {
|
|
|
90
99
|
var fromMonthOnScreen = fromMonthOnLeft || fromMonthOnRight;
|
|
91
100
|
var toMonthOnScreen = toMonthOnLeft || toMonthOnRight;
|
|
92
101
|
if (fromMonthOnLeft && toMonthOnLeft) {
|
|
93
|
-
setMonthTo(
|
|
102
|
+
setMonthTo(max__default.default([addMonths__default.default(selectedFromMonth, 1), monthTo]).getTime());
|
|
94
103
|
return;
|
|
95
104
|
}
|
|
96
105
|
if (fromMonthOnRight && toMonthOnRight) {
|
|
97
|
-
setMonthFrom(
|
|
106
|
+
setMonthFrom(min__default.default([subMonths__default.default(selectedToMonth, 1), monthFrom]).getTime());
|
|
98
107
|
return;
|
|
99
108
|
}
|
|
100
109
|
if (selectedFromMonth && selectedToMonth) {
|
|
101
110
|
setMonthFrom(selectedFromMonth);
|
|
102
|
-
setMonthTo(
|
|
111
|
+
setMonthTo(max__default.default([addMonths__default.default(selectedFromMonth, 1), selectedToMonth]).getTime());
|
|
103
112
|
return;
|
|
104
113
|
}
|
|
105
114
|
if (selectedFromMonth && !selectedToMonth && !fromMonthOnScreen) {
|
|
106
115
|
setMonthFrom(selectedFromMonth);
|
|
107
|
-
setMonthTo(
|
|
116
|
+
setMonthTo(max__default.default([addMonths__default.default(selectedFromMonth, 1), monthTo]).getTime());
|
|
108
117
|
}
|
|
109
118
|
if (selectedToMonth && !selectedFromMonth && !toMonthOnScreen) {
|
|
110
119
|
setMonthTo(selectedToMonth);
|
|
111
|
-
setMonthFrom(
|
|
120
|
+
setMonthFrom(min__default.default([subMonths__default.default(selectedToMonth, 1), monthFrom]).getTime());
|
|
112
121
|
}
|
|
113
122
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
114
123
|
}, [selectedFrom, selectedTo]);
|
|
@@ -124,15 +133,15 @@ function useSelectionProps(from, to, highlighted) {
|
|
|
124
133
|
if (from && to) {
|
|
125
134
|
return {
|
|
126
135
|
rangeComplete: true,
|
|
127
|
-
selectedFrom:
|
|
128
|
-
selectedTo:
|
|
136
|
+
selectedFrom: min__default.default([from, to]).getTime(),
|
|
137
|
+
selectedTo: max__default.default([from, to]).getTime(),
|
|
129
138
|
};
|
|
130
139
|
}
|
|
131
140
|
var dates = [from, to, highlighted].filter(function (date) { return date !== undefined; });
|
|
132
141
|
return {
|
|
133
142
|
rangeComplete: false,
|
|
134
|
-
selectedFrom: from || dates.length === 2 ?
|
|
135
|
-
selectedTo: to || dates.length === 2 ?
|
|
143
|
+
selectedFrom: from || dates.length === 2 ? min__default.default(dates).getTime() : undefined,
|
|
144
|
+
selectedTo: to || dates.length === 2 ? max__default.default(dates).getTime() : undefined,
|
|
136
145
|
};
|
|
137
146
|
}, [from, highlighted, to]);
|
|
138
147
|
}
|
package/index.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var Component = require('./Component.js');
|
|
4
|
-
require('./index.module-
|
|
4
|
+
require('./index.module-255b4286.js');
|
|
5
5
|
require('react');
|
|
6
6
|
require('./views/popover.js');
|
|
7
7
|
require('classnames');
|
|
8
8
|
require('date-fns/startOfMonth');
|
|
9
9
|
require('@alfalab/core-components-calendar-input');
|
|
10
10
|
require('@alfalab/core-components-date-input');
|
|
11
|
+
require('./components/divider/Component.js');
|
|
11
12
|
require('./hooks.js');
|
|
12
13
|
require('date-fns/addMonths');
|
|
13
14
|
require('date-fns/isEqual');
|
|
File without changes
|
|
@@ -39,7 +39,7 @@ function __rest(s, e) {
|
|
|
39
39
|
return t;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
var styles = {"component":"calendar-
|
|
42
|
+
var styles = {"component":"calendar-range__component_1ci3b","static":"calendar-range__static_1ci3b","calendar":"calendar-range__calendar_1ci3b"};
|
|
43
43
|
require('./views/index.css')
|
|
44
44
|
|
|
45
45
|
exports.__rest = __rest;
|
package/modern/Component.js
CHANGED
|
@@ -5,13 +5,14 @@ import 'classnames';
|
|
|
5
5
|
import 'date-fns/startOfMonth';
|
|
6
6
|
import '@alfalab/core-components-calendar-input/modern';
|
|
7
7
|
import '@alfalab/core-components-date-input/modern';
|
|
8
|
+
import './components/divider/Component.js';
|
|
8
9
|
import './hooks.js';
|
|
9
10
|
import 'date-fns/addMonths';
|
|
10
11
|
import 'date-fns/isEqual';
|
|
11
12
|
import 'date-fns/max';
|
|
12
13
|
import 'date-fns/min';
|
|
13
14
|
import 'date-fns/subMonths';
|
|
14
|
-
import './index.module-
|
|
15
|
+
import './index.module-491eb220.js';
|
|
15
16
|
import 'date-fns/endOfMonth';
|
|
16
17
|
import '@alfalab/core-components-calendar/modern';
|
|
17
18
|
import './utils.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { CalendarRangeProps } from "../../Component";
|
|
3
|
+
type Props = {
|
|
4
|
+
inputFromProps?: CalendarRangeProps['inputFromProps'];
|
|
5
|
+
inputToProps?: CalendarRangeProps['inputToProps'];
|
|
6
|
+
};
|
|
7
|
+
declare const Divider: FC<Props>;
|
|
8
|
+
export { Divider };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
|
|
4
|
+
const styles = {"component":"calendar-range__component_1tbg6","outer":"calendar-range__outer_1tbg6","s":"calendar-range__s_1tbg6","m":"calendar-range__m_1tbg6","l":"calendar-range__l_1tbg6","xl":"calendar-range__xl_1tbg6"};
|
|
5
|
+
require('./index.css')
|
|
6
|
+
|
|
7
|
+
const Divider = ({ inputFromProps, inputToProps }) => {
|
|
8
|
+
const outer = inputFromProps?.label &&
|
|
9
|
+
inputFromProps?.labelView === 'outer' &&
|
|
10
|
+
inputToProps?.label &&
|
|
11
|
+
inputToProps?.labelView === 'outer';
|
|
12
|
+
const size = inputFromProps?.size || inputToProps?.size || 's';
|
|
13
|
+
return React.createElement("span", { className: cn(styles.component, styles[size], { [styles.outer]: outer }) });
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { Divider };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/* hash: 1udsd */
|
|
2
|
+
:root {
|
|
3
|
+
--color-light-graphic-primary: #0b1f35;
|
|
4
|
+
}
|
|
5
|
+
:root {
|
|
6
|
+
|
|
7
|
+
/* Hard */
|
|
8
|
+
|
|
9
|
+
/* Up */
|
|
10
|
+
|
|
11
|
+
/* Hard up */
|
|
12
|
+
}
|
|
13
|
+
:root {
|
|
14
|
+
--gap-xs: 8px;
|
|
15
|
+
}
|
|
16
|
+
:root {
|
|
17
|
+
--size-s-height: 48px;
|
|
18
|
+
--size-m-height: 56px;
|
|
19
|
+
--size-l-height: 64px;
|
|
20
|
+
--size-xl-height: 72px;
|
|
21
|
+
}
|
|
22
|
+
:root {
|
|
23
|
+
|
|
24
|
+
/* Кнопки выбора месяцев и годов */
|
|
25
|
+
|
|
26
|
+
/* Шапка */
|
|
27
|
+
|
|
28
|
+
/* День */
|
|
29
|
+
|
|
30
|
+
/* today */
|
|
31
|
+
|
|
32
|
+
/* highlighted */
|
|
33
|
+
|
|
34
|
+
/* holidays */
|
|
35
|
+
|
|
36
|
+
/* range */
|
|
37
|
+
|
|
38
|
+
/* selected */
|
|
39
|
+
|
|
40
|
+
/* disabled */
|
|
41
|
+
|
|
42
|
+
/* marker */
|
|
43
|
+
}
|
|
44
|
+
.calendar-range__component_1tbg6 {
|
|
45
|
+
display: flex;
|
|
46
|
+
align-items: center;
|
|
47
|
+
justify-content: center;
|
|
48
|
+
width: 16px;
|
|
49
|
+
margin: 0 var(--gap-xs)
|
|
50
|
+
}
|
|
51
|
+
.calendar-range__component_1tbg6:after {
|
|
52
|
+
content: '';
|
|
53
|
+
display: block;
|
|
54
|
+
width: 100%;
|
|
55
|
+
height: 1px;
|
|
56
|
+
background-color: var(--color-light-graphic-primary);
|
|
57
|
+
}
|
|
58
|
+
.calendar-range__outer_1tbg6 {
|
|
59
|
+
position: relative;
|
|
60
|
+
|
|
61
|
+
/* FormControl .above height + margin-bottom */
|
|
62
|
+
top: 24px;
|
|
63
|
+
}
|
|
64
|
+
.calendar-range__s_1tbg6 {
|
|
65
|
+
height: var(--size-s-height);
|
|
66
|
+
}
|
|
67
|
+
.calendar-range__m_1tbg6 {
|
|
68
|
+
height: var(--size-m-height);
|
|
69
|
+
}
|
|
70
|
+
.calendar-range__l_1tbg6 {
|
|
71
|
+
height: var(--size-l-height);
|
|
72
|
+
}
|
|
73
|
+
.calendar-range__xl_1tbg6 {
|
|
74
|
+
height: var(--size-xl-height);
|
|
75
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Component";
|
package/modern/index.js
CHANGED
|
@@ -5,13 +5,14 @@ import 'classnames';
|
|
|
5
5
|
import 'date-fns/startOfMonth';
|
|
6
6
|
import '@alfalab/core-components-calendar-input/modern';
|
|
7
7
|
import '@alfalab/core-components-date-input/modern';
|
|
8
|
+
import './components/divider/Component.js';
|
|
8
9
|
import './hooks.js';
|
|
9
10
|
import 'date-fns/addMonths';
|
|
10
11
|
import 'date-fns/isEqual';
|
|
11
12
|
import 'date-fns/max';
|
|
12
13
|
import 'date-fns/min';
|
|
13
14
|
import 'date-fns/subMonths';
|
|
14
|
-
import './index.module-
|
|
15
|
+
import './index.module-491eb220.js';
|
|
15
16
|
import './views/static.js';
|
|
16
17
|
import 'date-fns/endOfMonth';
|
|
17
18
|
import '@alfalab/core-components-calendar/modern';
|
package/modern/views/index.css
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
2
|
-
:root {
|
|
3
|
-
--color-light-graphic-primary: #0b1f35;
|
|
4
|
-
}
|
|
1
|
+
/* hash: 1y02j */
|
|
5
2
|
:root {
|
|
6
3
|
|
|
7
4
|
/* Hard */
|
|
@@ -10,9 +7,6 @@
|
|
|
10
7
|
|
|
11
8
|
/* Hard up */
|
|
12
9
|
}
|
|
13
|
-
:root {
|
|
14
|
-
--gap-xs: 8px;
|
|
15
|
-
}
|
|
16
10
|
:root {
|
|
17
11
|
--calendar-inner-width: 280px;
|
|
18
12
|
|
|
@@ -36,33 +30,18 @@
|
|
|
36
30
|
|
|
37
31
|
/* marker */
|
|
38
32
|
}
|
|
39
|
-
.calendar-
|
|
33
|
+
.calendar-range__component_1ci3b {
|
|
40
34
|
display: flex
|
|
41
35
|
}
|
|
42
|
-
.calendar-
|
|
36
|
+
.calendar-range__component_1ci3b button[aria-selected='true'] {
|
|
43
37
|
cursor: pointer;
|
|
44
38
|
}
|
|
45
|
-
.calendar-
|
|
39
|
+
.calendar-range__component_1ci3b *[class*='errorIcon_'] {
|
|
46
40
|
display: none;
|
|
47
41
|
}
|
|
48
|
-
.calendar-
|
|
42
|
+
.calendar-range__component_1ci3b *[class*='calendarIcon_'] {
|
|
49
43
|
margin-right: 0;
|
|
50
44
|
}
|
|
51
|
-
.calendar-
|
|
52
|
-
height: 48px;
|
|
53
|
-
display: flex;
|
|
54
|
-
align-items: center;
|
|
55
|
-
justify-content: center;
|
|
56
|
-
width: 16px;
|
|
57
|
-
margin: 0 var(--gap-xs)
|
|
58
|
-
}
|
|
59
|
-
.calendar-range__divider_17yx8:after {
|
|
60
|
-
content: '';
|
|
61
|
-
display: block;
|
|
62
|
-
width: 100%;
|
|
63
|
-
height: 1px;
|
|
64
|
-
background-color: var(--color-light-graphic-primary);
|
|
65
|
-
}
|
|
66
|
-
.calendar-range__static_17yx8 .calendar-range__calendar_17yx8 {
|
|
45
|
+
.calendar-range__static_1ci3b .calendar-range__calendar_1ci3b {
|
|
67
46
|
width: var(--calendar-inner-width);
|
|
68
47
|
}
|
package/modern/views/popover.js
CHANGED
|
@@ -3,8 +3,9 @@ import cn from 'classnames';
|
|
|
3
3
|
import startOfMonth from 'date-fns/startOfMonth';
|
|
4
4
|
import { isValidInputValue, parseDateString, CalendarInput } from '@alfalab/core-components-calendar-input/modern';
|
|
5
5
|
import { isCompleteDateInput } from '@alfalab/core-components-date-input/modern';
|
|
6
|
+
import { Divider } from '../components/divider/Component.js';
|
|
6
7
|
import { usePopoverViewMonthes } from '../hooks.js';
|
|
7
|
-
import { s as styles } from '../index.module-
|
|
8
|
+
import { s as styles } from '../index.module-491eb220.js';
|
|
8
9
|
import 'date-fns/addMonths';
|
|
9
10
|
import 'date-fns/isEqual';
|
|
10
11
|
import 'date-fns/max';
|
|
@@ -110,7 +111,7 @@ const CalendarRangePopover = ({ className, defaultMonth = startOfMonth(new Date(
|
|
|
110
111
|
onMonthChange: handleMonthFromChange,
|
|
111
112
|
selectorView: 'full',
|
|
112
113
|
} }),
|
|
113
|
-
React.createElement(
|
|
114
|
+
React.createElement(Divider, { inputFromProps: inputFromProps, inputToProps: inputToProps }),
|
|
114
115
|
React.createElement(CalendarInput, { ...inputToProps, useAnchorWidth: false, calendarPosition: 'popover', popoverPosition: 'bottom-end', error: inputToInvalid || bothInvalid || inputToProps.error, onChange: handleToChange, onInputChange: handleInputToChange, onBlur: handleInputToBlur, value: inputToValue, minDate: dateFrom || minDate, maxDate: maxDate, offDays: offDays, events: events, calendarProps: {
|
|
115
116
|
...inputToProps.calendarProps,
|
|
116
117
|
month: monthTo,
|
package/modern/views/static.js
CHANGED
|
@@ -8,9 +8,10 @@ import subMonths from 'date-fns/subMonths';
|
|
|
8
8
|
import { usePeriodWithReset, Calendar } from '@alfalab/core-components-calendar/modern';
|
|
9
9
|
import { isValidInputValue, parseDateString, formatDate } from '@alfalab/core-components-calendar-input/modern';
|
|
10
10
|
import { isCompleteDateInput, DateInput } from '@alfalab/core-components-date-input/modern';
|
|
11
|
+
import { Divider } from '../components/divider/Component.js';
|
|
11
12
|
import { useStaticViewMonthes, useSelectionProps } from '../hooks.js';
|
|
12
13
|
import { isDayButton } from '../utils.js';
|
|
13
|
-
import { s as styles } from '../index.module-
|
|
14
|
+
import { s as styles } from '../index.module-491eb220.js';
|
|
14
15
|
import 'date-fns/isEqual';
|
|
15
16
|
import 'date-fns/min';
|
|
16
17
|
|
|
@@ -151,7 +152,7 @@ const CalendarRangeStatic = ({ className, defaultMonth = startOfMonth(new Date()
|
|
|
151
152
|
? 'input'
|
|
152
153
|
: dateInputFromProps.mobileMode, value: inputFromValue, onChange: handleInputFromChange, onClear: handleClearFrom, onBlur: handleValidInputFrom, error: bothInvalid || inputFromInvalid || dateInputFromProps.error, clear: true, block: true }),
|
|
153
154
|
React.createElement(CalendarFromComponent, { ...calendarFromProps, className: cn(styles.calendar, calendarFromProps?.className), month: monthFrom, selectorView: 'month-only', offDays: offDays, events: events, onChange: period.updatePeriod, onMonthChange: handleMonthFromChange, minDate: minDate, maxDate: maxDate && max([maxDate, endOfMonth(subMonths(maxDate, 1))]).getTime(), ...rangeProps })),
|
|
154
|
-
React.createElement(
|
|
155
|
+
React.createElement(Divider, { inputFromProps: inputFromProps, inputToProps: inputToProps }),
|
|
155
156
|
React.createElement("div", null,
|
|
156
157
|
React.createElement(DateInput, { ...dateInputToProps, mobileMode: dateInputToProps.mobileMode === 'popover'
|
|
157
158
|
? 'input'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alfalab/core-components-calendar-range",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.8",
|
|
4
4
|
"description": "Calendar range component",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@alfalab/core-components-calendar": "^6.1
|
|
22
|
-
"@alfalab/core-components-calendar-input": "^8.1
|
|
23
|
-
"@alfalab/core-components-date-input": "^4.1.
|
|
21
|
+
"@alfalab/core-components-calendar": "^6.2.1",
|
|
22
|
+
"@alfalab/core-components-calendar-input": "^8.2.1",
|
|
23
|
+
"@alfalab/core-components-date-input": "^4.1.2",
|
|
24
24
|
"classnames": "^2.3.1",
|
|
25
25
|
"date-fns": "^2.16.1"
|
|
26
26
|
}
|