@alfalab/core-components-calendar-range 5.0.0 → 5.1.0
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 +16 -0
- package/dist/Component.js +1 -1
- package/dist/cssm/hooks.d.ts +6 -1
- package/dist/cssm/hooks.js +18 -0
- package/dist/cssm/views/static.js +14 -19
- package/dist/esm/Component.js +1 -1
- package/dist/esm/hooks.d.ts +6 -1
- package/dist/esm/hooks.js +18 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/{index.module-1e16472a.d.ts → index.module-bbf7d46d.d.ts} +0 -0
- package/dist/esm/{index.module-1e16472a.js → index.module-bbf7d46d.js} +1 -1
- package/dist/esm/views/index.css +8 -8
- package/dist/esm/views/popover.js +1 -1
- package/dist/esm/views/static.js +17 -22
- package/dist/hooks.d.ts +6 -1
- package/dist/hooks.js +18 -0
- package/dist/index.js +1 -1
- package/dist/{index.module-bcae62ec.d.ts → index.module-a9bc9731.d.ts} +0 -0
- package/dist/{index.module-bcae62ec.js → index.module-a9bc9731.js} +1 -1
- package/dist/modern/Component.js +1 -1
- package/dist/modern/hooks.d.ts +6 -1
- package/dist/modern/hooks.js +18 -1
- package/dist/modern/index.js +1 -1
- package/dist/modern/index.module-4c141936.js +4 -0
- package/dist/modern/views/index.css +8 -8
- package/dist/modern/views/popover.js +1 -1
- package/dist/modern/views/static.js +17 -21
- package/dist/utils.js +3 -1
- package/dist/views/index.css +8 -8
- package/dist/views/popover.js +1 -1
- package/dist/views/static.js +15 -20
- package/package.json +2 -2
- package/dist/modern/index.module-7d74ac8d.js +0 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [5.1.0](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-calendar-range@5.0.0...@alfalab/core-components-calendar-range@5.1.0) (2022-02-21)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **calendar-range:** correct highlights ([#1002](https://github.com/alfa-laboratory/core-components/issues/1002)) ([5c12da2](https://github.com/alfa-laboratory/core-components/commit/5c12da2eb72b146b0a5f58447312f96f4b424c48))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* Исправить импорты в сторях. ([#998](https://github.com/alfa-laboratory/core-components/issues/998)) ([e6a654a](https://github.com/alfa-laboratory/core-components/commit/e6a654a0599451c7d149484cb61d8067eed083b7))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
# [5.0.0](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-calendar-range@4.3.0...@alfalab/core-components-calendar-range@5.0.0) (2022-02-17)
|
|
7
23
|
|
|
8
24
|
|
package/dist/Component.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var index_module = require('./index.module-
|
|
5
|
+
var index_module = require('./index.module-a9bc9731.js');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
require('classnames');
|
|
8
8
|
require('date-fns/startOfMonth');
|
package/dist/cssm/hooks.d.ts
CHANGED
|
@@ -19,4 +19,9 @@ declare function useStaticViewMonthes({ selectedFrom, selectedTo, defaultMonth,
|
|
|
19
19
|
handleMonthFromChange: (newMonthFrom: number) => void;
|
|
20
20
|
handleMonthToChange: (newMonthTo: number) => void;
|
|
21
21
|
};
|
|
22
|
-
|
|
22
|
+
declare function useSelectionProps(from?: number, to?: number, highlighted?: number): {
|
|
23
|
+
rangeComplete: boolean;
|
|
24
|
+
selectedFrom: number | undefined;
|
|
25
|
+
selectedTo: number | undefined;
|
|
26
|
+
};
|
|
27
|
+
export { usePopoverViewMonthes, useStaticViewMonthes, useSelectionProps };
|
package/dist/cssm/hooks.js
CHANGED
|
@@ -126,6 +126,24 @@ function useStaticViewMonthes(_a) {
|
|
|
126
126
|
handleMonthToChange: handleMonthToChange,
|
|
127
127
|
};
|
|
128
128
|
}
|
|
129
|
+
function useSelectionProps(from, to, highlighted) {
|
|
130
|
+
return React.useMemo(function () {
|
|
131
|
+
if (from && to) {
|
|
132
|
+
return {
|
|
133
|
+
rangeComplete: true,
|
|
134
|
+
selectedFrom: min__default['default']([from, to]).getTime(),
|
|
135
|
+
selectedTo: max__default['default']([from, to]).getTime(),
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
var dates = [from, to, highlighted].filter(function (date) { return date !== undefined; });
|
|
139
|
+
return {
|
|
140
|
+
rangeComplete: false,
|
|
141
|
+
selectedFrom: from || dates.length === 2 ? min__default['default'](dates).getTime() : undefined,
|
|
142
|
+
selectedTo: to || dates.length === 2 ? max__default['default'](dates).getTime() : undefined,
|
|
143
|
+
};
|
|
144
|
+
}, [from, highlighted, to]);
|
|
145
|
+
}
|
|
129
146
|
|
|
130
147
|
exports.usePopoverViewMonthes = usePopoverViewMonthes;
|
|
148
|
+
exports.useSelectionProps = useSelectionProps;
|
|
131
149
|
exports.useStaticViewMonthes = useStaticViewMonthes;
|
|
@@ -32,7 +32,6 @@ var endOfMonth__default = /*#__PURE__*/_interopDefaultLegacy(endOfMonth);
|
|
|
32
32
|
|
|
33
33
|
var CalendarRangeStatic = function (_a) {
|
|
34
34
|
var className = _a.className, _b = _a.defaultMonth, defaultMonth = _b === void 0 ? startOfMonth__default['default'](new Date()).getTime() : _b, minDate = _a.minDate, maxDate = _a.maxDate, _c = _a.valueFrom, valueFrom = _c === void 0 ? '' : _c, _d = _a.valueTo, valueTo = _d === void 0 ? '' : _d, _e = _a.onDateFromChange, onDateFromChange = _e === void 0 ? function () { return null; } : _e, _f = _a.onDateToChange, onDateToChange = _f === void 0 ? function () { return null; } : _f, _g = _a.onChange, onChange = _g === void 0 ? function () { return null; } : _g, _h = _a.inputFromProps, inputFromProps = _h === void 0 ? {} : _h, _j = _a.inputToProps, inputToProps = _j === void 0 ? {} : _j, offDays = _a.offDays, events = _a.events, dataTestId = _a.dataTestId;
|
|
35
|
-
var calendarToRef = React.useRef(null);
|
|
36
35
|
var _k = React.useState(valueFrom), inputFromValue = _k[0], setInputFromValue = _k[1];
|
|
37
36
|
var _l = React.useState(valueTo), inputToValue = _l[0], setInputToValue = _l[1];
|
|
38
37
|
var dateFrom = coreComponentsCalendarInput.isValidInputValue(inputFromValue, minDate, maxDate, offDays)
|
|
@@ -47,7 +46,7 @@ var CalendarRangeStatic = function (_a) {
|
|
|
47
46
|
var bothInvalid = coreComponentsDateInput.isCompleteDateInput(inputFromValue) &&
|
|
48
47
|
coreComponentsDateInput.isCompleteDateInput(inputToValue) &&
|
|
49
48
|
coreComponentsCalendarInput.parseDateString(inputFromValue).getTime() > coreComponentsCalendarInput.parseDateString(inputToValue).getTime();
|
|
50
|
-
var _m = React.useState(
|
|
49
|
+
var _m = React.useState(undefined), highlightedDate = _m[0], setHighlightedDate = _m[1];
|
|
51
50
|
var period = coreComponentsCalendar.usePeriodWithReset({
|
|
52
51
|
initialSelectedFrom: dateFrom ? coreComponentsCalendarInput.parseDateString(inputFromValue).getTime() : undefined,
|
|
53
52
|
initialSelectedTo: dateTo ? coreComponentsCalendarInput.parseDateString(inputToValue).getTime() : undefined,
|
|
@@ -73,22 +72,17 @@ var CalendarRangeStatic = function (_a) {
|
|
|
73
72
|
var handleInputToChange = React.useCallback(function (_, payload) {
|
|
74
73
|
setInputToValue(payload.value);
|
|
75
74
|
}, []);
|
|
76
|
-
var
|
|
77
|
-
var _a;
|
|
75
|
+
var handleMouseOver = React.useCallback(function (event) {
|
|
78
76
|
var target = event.target;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
return highlighted;
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
setNextMonthHighlighted(false);
|
|
77
|
+
var mouseOverDayButton = utils.isDayButton(target) || utils.isDayButton(target.parentElement);
|
|
78
|
+
var date;
|
|
79
|
+
if (mouseOverDayButton) {
|
|
80
|
+
var button = target.tagName === 'BUTTON' ? target : target.parentElement;
|
|
81
|
+
if (button.dataset.date) {
|
|
82
|
+
date = +button.dataset.date;
|
|
83
|
+
}
|
|
91
84
|
}
|
|
85
|
+
setHighlightedDate(date);
|
|
92
86
|
}, []);
|
|
93
87
|
var handleClearFrom = React.useCallback(function () {
|
|
94
88
|
setInputFromValue('');
|
|
@@ -152,24 +146,25 @@ var CalendarRangeStatic = function (_a) {
|
|
|
152
146
|
}
|
|
153
147
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
154
148
|
}, [inputToValue]);
|
|
149
|
+
var rangeProps = hooks.useSelectionProps(period.selectedFrom, period.selectedTo, highlightedDate);
|
|
155
150
|
var calendarFromProps = inputFromProps.calendarProps, dateInputFromProps = tslib_es6.__rest(inputFromProps, ["calendarProps"]);
|
|
156
151
|
var calendarToProps = inputToProps.calendarProps, dateInputToProps = tslib_es6.__rest(inputToProps, ["calendarProps"]);
|
|
157
152
|
var CalendarFromComponent = dateInputFromProps.Calendar || coreComponentsCalendar.Calendar;
|
|
158
153
|
var CalendarToComponent = dateInputToProps.Calendar || coreComponentsCalendar.Calendar;
|
|
159
154
|
return (
|
|
160
155
|
// eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
|
|
161
|
-
React__default['default'].createElement("div", { className: cn__default['default'](styles__default['default'].component, styles__default['default'].static, className), onMouseOver:
|
|
156
|
+
React__default['default'].createElement("div", { className: cn__default['default'](styles__default['default'].component, styles__default['default'].static, className), onMouseOver: handleMouseOver, "data-test-id": dataTestId },
|
|
162
157
|
React__default['default'].createElement("div", null,
|
|
163
158
|
React__default['default'].createElement(coreComponentsDateInput.DateInput, tslib_es6.__assign({}, dateInputFromProps, { mobileMode: dateInputFromProps.mobileMode === 'popover'
|
|
164
159
|
? 'input'
|
|
165
160
|
: dateInputFromProps.mobileMode, value: inputFromValue, onChange: handleInputFromChange, onClear: handleClearFrom, onBlur: handleValidInputFrom, error: bothInvalid || inputFromInvalid || dateInputFromProps.error, clear: true, block: true })),
|
|
166
|
-
React__default['default'].createElement(CalendarFromComponent, tslib_es6.__assign({}, calendarFromProps, { className: cn__default['default'](styles__default['default'].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__default['default']([maxDate, endOfMonth__default['default'](subMonths__default['default'](maxDate, 1))]).getTime()
|
|
161
|
+
React__default['default'].createElement(CalendarFromComponent, tslib_es6.__assign({}, calendarFromProps, { className: cn__default['default'](styles__default['default'].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__default['default']([maxDate, endOfMonth__default['default'](subMonths__default['default'](maxDate, 1))]).getTime() }, rangeProps))),
|
|
167
162
|
React__default['default'].createElement("span", { className: styles__default['default'].divider }),
|
|
168
163
|
React__default['default'].createElement("div", null,
|
|
169
164
|
React__default['default'].createElement(coreComponentsDateInput.DateInput, tslib_es6.__assign({}, dateInputToProps, { mobileMode: dateInputToProps.mobileMode === 'popover'
|
|
170
165
|
? 'input'
|
|
171
166
|
: dateInputToProps.mobileMode, value: inputToValue, onChange: handleInputToChange, onClear: handleClearTo, onBlur: handleValidInputTo, error: bothInvalid || inputToInvalid, clear: true, block: true })),
|
|
172
|
-
React__default['default'].createElement(CalendarToComponent, tslib_es6.__assign({}, calendarToProps, { className: cn__default['default'](styles__default['default'].calendar, calendarToProps === null || calendarToProps === void 0 ? void 0 : calendarToProps.className),
|
|
167
|
+
React__default['default'].createElement(CalendarToComponent, tslib_es6.__assign({}, calendarToProps, { className: cn__default['default'](styles__default['default'].calendar, calendarToProps === null || calendarToProps === void 0 ? void 0 : calendarToProps.className), month: monthTo, selectorView: 'month-only', offDays: offDays, events: events, onChange: period.updatePeriod, onMonthChange: handleMonthToChange, minDate: minDate && startOfMonth__default['default'](addMonths__default['default'](minDate, 1)).getTime(), maxDate: maxDate }, rangeProps)))));
|
|
173
168
|
};
|
|
174
169
|
|
|
175
170
|
exports.CalendarRangeStatic = CalendarRangeStatic;
|
package/dist/esm/Component.js
CHANGED
package/dist/esm/hooks.d.ts
CHANGED
|
@@ -19,4 +19,9 @@ declare function useStaticViewMonthes({ selectedFrom, selectedTo, defaultMonth,
|
|
|
19
19
|
handleMonthFromChange: (newMonthFrom: number) => void;
|
|
20
20
|
handleMonthToChange: (newMonthTo: number) => void;
|
|
21
21
|
};
|
|
22
|
-
|
|
22
|
+
declare function useSelectionProps(from?: number, to?: number, highlighted?: number): {
|
|
23
|
+
rangeComplete: boolean;
|
|
24
|
+
selectedFrom: number | undefined;
|
|
25
|
+
selectedTo: number | undefined;
|
|
26
|
+
};
|
|
27
|
+
export { usePopoverViewMonthes, useStaticViewMonthes, useSelectionProps };
|
package/dist/esm/hooks.js
CHANGED
|
@@ -113,5 +113,22 @@ function useStaticViewMonthes(_a) {
|
|
|
113
113
|
handleMonthToChange: handleMonthToChange,
|
|
114
114
|
};
|
|
115
115
|
}
|
|
116
|
+
function useSelectionProps(from, to, highlighted) {
|
|
117
|
+
return useMemo(function () {
|
|
118
|
+
if (from && to) {
|
|
119
|
+
return {
|
|
120
|
+
rangeComplete: true,
|
|
121
|
+
selectedFrom: min([from, to]).getTime(),
|
|
122
|
+
selectedTo: max([from, to]).getTime(),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
var dates = [from, to, highlighted].filter(function (date) { return date !== undefined; });
|
|
126
|
+
return {
|
|
127
|
+
rangeComplete: false,
|
|
128
|
+
selectedFrom: from || dates.length === 2 ? min(dates).getTime() : undefined,
|
|
129
|
+
selectedTo: to || dates.length === 2 ? max(dates).getTime() : undefined,
|
|
130
|
+
};
|
|
131
|
+
}, [from, highlighted, to]);
|
|
132
|
+
}
|
|
116
133
|
|
|
117
|
-
export { usePopoverViewMonthes, useStaticViewMonthes };
|
|
134
|
+
export { usePopoverViewMonthes, useSelectionProps, useStaticViewMonthes };
|
package/dist/esm/index.js
CHANGED
|
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_eksd6","divider":"calendar-range__divider_eksd6","static":"calendar-range__static_eksd6","calendar":"calendar-range__calendar_eksd6"};
|
|
41
41
|
require('./views/index.css')
|
|
42
42
|
|
|
43
43
|
export { __rest as _, __assign as a, styles as s };
|
package/dist/esm/views/index.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: 13dnh */
|
|
2
2
|
:root {
|
|
3
3
|
--color-light-graphic-primary: #0b1f35;
|
|
4
4
|
}
|
|
@@ -34,19 +34,19 @@
|
|
|
34
34
|
|
|
35
35
|
/* marker */
|
|
36
36
|
}
|
|
37
|
-
.calendar-
|
|
37
|
+
.calendar-range__component_eksd6 {
|
|
38
38
|
display: flex
|
|
39
39
|
}
|
|
40
|
-
.calendar-
|
|
40
|
+
.calendar-range__component_eksd6 button[aria-selected='true'] {
|
|
41
41
|
cursor: pointer;
|
|
42
42
|
}
|
|
43
|
-
.calendar-
|
|
43
|
+
.calendar-range__component_eksd6 *[class*='errorIcon_'] {
|
|
44
44
|
display: none;
|
|
45
45
|
}
|
|
46
|
-
.calendar-
|
|
46
|
+
.calendar-range__component_eksd6 *[class*='calendarIcon_'] {
|
|
47
47
|
margin-right: 0;
|
|
48
48
|
}
|
|
49
|
-
.calendar-
|
|
49
|
+
.calendar-range__divider_eksd6 {
|
|
50
50
|
height: 48px;
|
|
51
51
|
display: flex;
|
|
52
52
|
align-items: center;
|
|
@@ -54,13 +54,13 @@
|
|
|
54
54
|
width: 16px;
|
|
55
55
|
margin: 0 var(--gap-xs)
|
|
56
56
|
}
|
|
57
|
-
.calendar-
|
|
57
|
+
.calendar-range__divider_eksd6:after {
|
|
58
58
|
content: '';
|
|
59
59
|
display: block;
|
|
60
60
|
width: 100%;
|
|
61
61
|
height: 1px;
|
|
62
62
|
background-color: var(--color-light-graphic-primary);
|
|
63
63
|
}
|
|
64
|
-
.calendar-
|
|
64
|
+
.calendar-range__static_eksd6 .calendar-range__calendar_eksd6 {
|
|
65
65
|
width: var(--calendar-inner-width);
|
|
66
66
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as styles, a as __assign } from '../index.module-
|
|
1
|
+
import { s as styles, a as __assign } from '../index.module-bbf7d46d.js';
|
|
2
2
|
import React, { useState, useCallback, useEffect } from 'react';
|
|
3
3
|
import cn from 'classnames';
|
|
4
4
|
import startOfMonth from 'date-fns/startOfMonth';
|
package/dist/esm/views/static.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as __rest, s as styles, a as __assign } from '../index.module-
|
|
2
|
-
import React, {
|
|
1
|
+
import { _ as __rest, s as styles, a as __assign } from '../index.module-bbf7d46d.js';
|
|
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, formatDate } from '@alfalab/core-components-calendar-input/dist/esm';
|
|
@@ -9,14 +9,13 @@ import subMonths from 'date-fns/subMonths';
|
|
|
9
9
|
import max from 'date-fns/max';
|
|
10
10
|
import 'date-fns/min';
|
|
11
11
|
import 'date-fns/isEqual';
|
|
12
|
-
import { useStaticViewMonthes } from '../hooks.js';
|
|
12
|
+
import { useStaticViewMonthes, useSelectionProps } from '../hooks.js';
|
|
13
13
|
import endOfMonth from 'date-fns/endOfMonth';
|
|
14
14
|
import { usePeriodWithReset, Calendar } from '@alfalab/core-components-calendar/dist/esm';
|
|
15
15
|
import { isDayButton } from '../utils.js';
|
|
16
16
|
|
|
17
17
|
var CalendarRangeStatic = function (_a) {
|
|
18
18
|
var className = _a.className, _b = _a.defaultMonth, defaultMonth = _b === void 0 ? startOfMonth(new Date()).getTime() : _b, minDate = _a.minDate, maxDate = _a.maxDate, _c = _a.valueFrom, valueFrom = _c === void 0 ? '' : _c, _d = _a.valueTo, valueTo = _d === void 0 ? '' : _d, _e = _a.onDateFromChange, onDateFromChange = _e === void 0 ? function () { return null; } : _e, _f = _a.onDateToChange, onDateToChange = _f === void 0 ? function () { return null; } : _f, _g = _a.onChange, onChange = _g === void 0 ? function () { return null; } : _g, _h = _a.inputFromProps, inputFromProps = _h === void 0 ? {} : _h, _j = _a.inputToProps, inputToProps = _j === void 0 ? {} : _j, offDays = _a.offDays, events = _a.events, dataTestId = _a.dataTestId;
|
|
19
|
-
var calendarToRef = useRef(null);
|
|
20
19
|
var _k = useState(valueFrom), inputFromValue = _k[0], setInputFromValue = _k[1];
|
|
21
20
|
var _l = useState(valueTo), inputToValue = _l[0], setInputToValue = _l[1];
|
|
22
21
|
var dateFrom = isValidInputValue(inputFromValue, minDate, maxDate, offDays)
|
|
@@ -31,7 +30,7 @@ var CalendarRangeStatic = function (_a) {
|
|
|
31
30
|
var bothInvalid = isCompleteDateInput(inputFromValue) &&
|
|
32
31
|
isCompleteDateInput(inputToValue) &&
|
|
33
32
|
parseDateString(inputFromValue).getTime() > parseDateString(inputToValue).getTime();
|
|
34
|
-
var _m = useState(
|
|
33
|
+
var _m = useState(undefined), highlightedDate = _m[0], setHighlightedDate = _m[1];
|
|
35
34
|
var period = usePeriodWithReset({
|
|
36
35
|
initialSelectedFrom: dateFrom ? parseDateString(inputFromValue).getTime() : undefined,
|
|
37
36
|
initialSelectedTo: dateTo ? parseDateString(inputToValue).getTime() : undefined,
|
|
@@ -57,22 +56,17 @@ var CalendarRangeStatic = function (_a) {
|
|
|
57
56
|
var handleInputToChange = useCallback(function (_, payload) {
|
|
58
57
|
setInputToValue(payload.value);
|
|
59
58
|
}, []);
|
|
60
|
-
var
|
|
61
|
-
var _a;
|
|
59
|
+
var handleMouseOver = useCallback(function (event) {
|
|
62
60
|
var target = event.target;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
return highlighted;
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
setNextMonthHighlighted(false);
|
|
61
|
+
var mouseOverDayButton = isDayButton(target) || isDayButton(target.parentElement);
|
|
62
|
+
var date;
|
|
63
|
+
if (mouseOverDayButton) {
|
|
64
|
+
var button = target.tagName === 'BUTTON' ? target : target.parentElement;
|
|
65
|
+
if (button.dataset.date) {
|
|
66
|
+
date = +button.dataset.date;
|
|
67
|
+
}
|
|
75
68
|
}
|
|
69
|
+
setHighlightedDate(date);
|
|
76
70
|
}, []);
|
|
77
71
|
var handleClearFrom = useCallback(function () {
|
|
78
72
|
setInputFromValue('');
|
|
@@ -136,24 +130,25 @@ var CalendarRangeStatic = function (_a) {
|
|
|
136
130
|
}
|
|
137
131
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
138
132
|
}, [inputToValue]);
|
|
133
|
+
var rangeProps = useSelectionProps(period.selectedFrom, period.selectedTo, highlightedDate);
|
|
139
134
|
var calendarFromProps = inputFromProps.calendarProps, dateInputFromProps = __rest(inputFromProps, ["calendarProps"]);
|
|
140
135
|
var calendarToProps = inputToProps.calendarProps, dateInputToProps = __rest(inputToProps, ["calendarProps"]);
|
|
141
136
|
var CalendarFromComponent = dateInputFromProps.Calendar || Calendar;
|
|
142
137
|
var CalendarToComponent = dateInputToProps.Calendar || Calendar;
|
|
143
138
|
return (
|
|
144
139
|
// eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
|
|
145
|
-
React.createElement("div", { className: cn(styles.component, styles.static, className), onMouseOver:
|
|
140
|
+
React.createElement("div", { className: cn(styles.component, styles.static, className), onMouseOver: handleMouseOver, "data-test-id": dataTestId },
|
|
146
141
|
React.createElement("div", null,
|
|
147
142
|
React.createElement(DateInput, __assign({}, dateInputFromProps, { mobileMode: dateInputFromProps.mobileMode === 'popover'
|
|
148
143
|
? 'input'
|
|
149
144
|
: dateInputFromProps.mobileMode, value: inputFromValue, onChange: handleInputFromChange, onClear: handleClearFrom, onBlur: handleValidInputFrom, error: bothInvalid || inputFromInvalid || dateInputFromProps.error, clear: true, block: true })),
|
|
150
|
-
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()
|
|
145
|
+
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))),
|
|
151
146
|
React.createElement("span", { className: styles.divider }),
|
|
152
147
|
React.createElement("div", null,
|
|
153
148
|
React.createElement(DateInput, __assign({}, dateInputToProps, { mobileMode: dateInputToProps.mobileMode === 'popover'
|
|
154
149
|
? 'input'
|
|
155
150
|
: dateInputToProps.mobileMode, value: inputToValue, onChange: handleInputToChange, onClear: handleClearTo, onBlur: handleValidInputTo, error: bothInvalid || inputToInvalid, clear: true, block: true })),
|
|
156
|
-
React.createElement(CalendarToComponent, __assign({}, calendarToProps, { className: cn(styles.calendar, calendarToProps === null || calendarToProps === void 0 ? void 0 : calendarToProps.className),
|
|
151
|
+
React.createElement(CalendarToComponent, __assign({}, calendarToProps, { className: cn(styles.calendar, calendarToProps === null || calendarToProps === void 0 ? void 0 : calendarToProps.className), month: monthTo, selectorView: 'month-only', offDays: offDays, events: events, onChange: period.updatePeriod, onMonthChange: handleMonthToChange, minDate: minDate && startOfMonth(addMonths(minDate, 1)).getTime(), maxDate: maxDate }, rangeProps)))));
|
|
157
152
|
};
|
|
158
153
|
|
|
159
154
|
export { CalendarRangeStatic };
|
package/dist/hooks.d.ts
CHANGED
|
@@ -19,4 +19,9 @@ declare function useStaticViewMonthes({ selectedFrom, selectedTo, defaultMonth,
|
|
|
19
19
|
handleMonthFromChange: (newMonthFrom: number) => void;
|
|
20
20
|
handleMonthToChange: (newMonthTo: number) => void;
|
|
21
21
|
};
|
|
22
|
-
|
|
22
|
+
declare function useSelectionProps(from?: number, to?: number, highlighted?: number): {
|
|
23
|
+
rangeComplete: boolean;
|
|
24
|
+
selectedFrom: number | undefined;
|
|
25
|
+
selectedTo: number | undefined;
|
|
26
|
+
};
|
|
27
|
+
export { usePopoverViewMonthes, useStaticViewMonthes, useSelectionProps };
|
package/dist/hooks.js
CHANGED
|
@@ -126,6 +126,24 @@ function useStaticViewMonthes(_a) {
|
|
|
126
126
|
handleMonthToChange: handleMonthToChange,
|
|
127
127
|
};
|
|
128
128
|
}
|
|
129
|
+
function useSelectionProps(from, to, highlighted) {
|
|
130
|
+
return React.useMemo(function () {
|
|
131
|
+
if (from && to) {
|
|
132
|
+
return {
|
|
133
|
+
rangeComplete: true,
|
|
134
|
+
selectedFrom: min__default['default']([from, to]).getTime(),
|
|
135
|
+
selectedTo: max__default['default']([from, to]).getTime(),
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
var dates = [from, to, highlighted].filter(function (date) { return date !== undefined; });
|
|
139
|
+
return {
|
|
140
|
+
rangeComplete: false,
|
|
141
|
+
selectedFrom: from || dates.length === 2 ? min__default['default'](dates).getTime() : undefined,
|
|
142
|
+
selectedTo: to || dates.length === 2 ? max__default['default'](dates).getTime() : undefined,
|
|
143
|
+
};
|
|
144
|
+
}, [from, highlighted, to]);
|
|
145
|
+
}
|
|
129
146
|
|
|
130
147
|
exports.usePopoverViewMonthes = usePopoverViewMonthes;
|
|
148
|
+
exports.useSelectionProps = useSelectionProps;
|
|
131
149
|
exports.useStaticViewMonthes = useStaticViewMonthes;
|
package/dist/index.js
CHANGED
|
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_eksd6","divider":"calendar-range__divider_eksd6","static":"calendar-range__static_eksd6","calendar":"calendar-range__calendar_eksd6"};
|
|
43
43
|
require('./views/index.css')
|
|
44
44
|
|
|
45
45
|
exports.__rest = __rest;
|
package/dist/modern/Component.js
CHANGED
|
@@ -9,7 +9,7 @@ import 'date-fns/max';
|
|
|
9
9
|
import 'date-fns/min';
|
|
10
10
|
import 'date-fns/isEqual';
|
|
11
11
|
import './hooks.js';
|
|
12
|
-
import './index.module-
|
|
12
|
+
import './index.module-4c141936.js';
|
|
13
13
|
import { CalendarRangePopover } from './views/popover.js';
|
|
14
14
|
import 'date-fns/endOfMonth';
|
|
15
15
|
import '@alfalab/core-components-calendar/dist/modern';
|
package/dist/modern/hooks.d.ts
CHANGED
|
@@ -19,4 +19,9 @@ declare function useStaticViewMonthes({ selectedFrom, selectedTo, defaultMonth,
|
|
|
19
19
|
handleMonthFromChange: (newMonthFrom: number) => void;
|
|
20
20
|
handleMonthToChange: (newMonthTo: number) => void;
|
|
21
21
|
};
|
|
22
|
-
|
|
22
|
+
declare function useSelectionProps(from?: number, to?: number, highlighted?: number): {
|
|
23
|
+
rangeComplete: boolean;
|
|
24
|
+
selectedFrom: number | undefined;
|
|
25
|
+
selectedTo: number | undefined;
|
|
26
|
+
};
|
|
27
|
+
export { usePopoverViewMonthes, useStaticViewMonthes, useSelectionProps };
|
package/dist/modern/hooks.js
CHANGED
|
@@ -109,5 +109,22 @@ function useStaticViewMonthes({ selectedFrom, selectedTo, defaultMonth, }) {
|
|
|
109
109
|
handleMonthToChange,
|
|
110
110
|
};
|
|
111
111
|
}
|
|
112
|
+
function useSelectionProps(from, to, highlighted) {
|
|
113
|
+
return useMemo(() => {
|
|
114
|
+
if (from && to) {
|
|
115
|
+
return {
|
|
116
|
+
rangeComplete: true,
|
|
117
|
+
selectedFrom: min([from, to]).getTime(),
|
|
118
|
+
selectedTo: max([from, to]).getTime(),
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
const dates = [from, to, highlighted].filter(date => date !== undefined);
|
|
122
|
+
return {
|
|
123
|
+
rangeComplete: false,
|
|
124
|
+
selectedFrom: from || dates.length === 2 ? min(dates).getTime() : undefined,
|
|
125
|
+
selectedTo: to || dates.length === 2 ? max(dates).getTime() : undefined,
|
|
126
|
+
};
|
|
127
|
+
}, [from, highlighted, to]);
|
|
128
|
+
}
|
|
112
129
|
|
|
113
|
-
export { usePopoverViewMonthes, useStaticViewMonthes };
|
|
130
|
+
export { usePopoverViewMonthes, useSelectionProps, useStaticViewMonthes };
|
package/dist/modern/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import 'date-fns/max';
|
|
|
9
9
|
import 'date-fns/min';
|
|
10
10
|
import 'date-fns/isEqual';
|
|
11
11
|
import './hooks.js';
|
|
12
|
-
import './index.module-
|
|
12
|
+
import './index.module-4c141936.js';
|
|
13
13
|
import './views/popover.js';
|
|
14
14
|
import 'date-fns/endOfMonth';
|
|
15
15
|
import '@alfalab/core-components-calendar/dist/modern';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: 13dnh */
|
|
2
2
|
:root {
|
|
3
3
|
--color-light-graphic-primary: #0b1f35;
|
|
4
4
|
}
|
|
@@ -34,19 +34,19 @@
|
|
|
34
34
|
|
|
35
35
|
/* marker */
|
|
36
36
|
}
|
|
37
|
-
.calendar-
|
|
37
|
+
.calendar-range__component_eksd6 {
|
|
38
38
|
display: flex
|
|
39
39
|
}
|
|
40
|
-
.calendar-
|
|
40
|
+
.calendar-range__component_eksd6 button[aria-selected='true'] {
|
|
41
41
|
cursor: pointer;
|
|
42
42
|
}
|
|
43
|
-
.calendar-
|
|
43
|
+
.calendar-range__component_eksd6 *[class*='errorIcon_'] {
|
|
44
44
|
display: none;
|
|
45
45
|
}
|
|
46
|
-
.calendar-
|
|
46
|
+
.calendar-range__component_eksd6 *[class*='calendarIcon_'] {
|
|
47
47
|
margin-right: 0;
|
|
48
48
|
}
|
|
49
|
-
.calendar-
|
|
49
|
+
.calendar-range__divider_eksd6 {
|
|
50
50
|
height: 48px;
|
|
51
51
|
display: flex;
|
|
52
52
|
align-items: center;
|
|
@@ -54,13 +54,13 @@
|
|
|
54
54
|
width: 16px;
|
|
55
55
|
margin: 0 var(--gap-xs)
|
|
56
56
|
}
|
|
57
|
-
.calendar-
|
|
57
|
+
.calendar-range__divider_eksd6:after {
|
|
58
58
|
content: '';
|
|
59
59
|
display: block;
|
|
60
60
|
width: 100%;
|
|
61
61
|
height: 1px;
|
|
62
62
|
background-color: var(--color-light-graphic-primary);
|
|
63
63
|
}
|
|
64
|
-
.calendar-
|
|
64
|
+
.calendar-range__static_eksd6 .calendar-range__calendar_eksd6 {
|
|
65
65
|
width: var(--calendar-inner-width);
|
|
66
66
|
}
|
|
@@ -9,7 +9,7 @@ import 'date-fns/max';
|
|
|
9
9
|
import 'date-fns/min';
|
|
10
10
|
import 'date-fns/isEqual';
|
|
11
11
|
import { usePopoverViewMonthes } from '../hooks.js';
|
|
12
|
-
import { s as styles } from '../index.module-
|
|
12
|
+
import { s as styles } from '../index.module-4c141936.js';
|
|
13
13
|
|
|
14
14
|
const CalendarRangePopover = ({ className, defaultMonth = startOfMonth(new Date()).getTime(), minDate, maxDate, valueFrom = '', valueTo = '', onDateFromChange = () => null, onDateToChange = () => null, onChange = () => null, inputFromProps = {}, inputToProps = {}, offDays, events, dataTestId, }) => {
|
|
15
15
|
const [inputFromValue, setInputFromValue] = useState(valueFrom);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useState, useCallback, useEffect } from 'react';
|
|
2
2
|
import cn from 'classnames';
|
|
3
3
|
import startOfMonth from 'date-fns/startOfMonth';
|
|
4
4
|
import { isValidInputValue, parseDateString, formatDate } from '@alfalab/core-components-calendar-input/dist/modern';
|
|
@@ -8,15 +8,14 @@ import subMonths from 'date-fns/subMonths';
|
|
|
8
8
|
import max from 'date-fns/max';
|
|
9
9
|
import 'date-fns/min';
|
|
10
10
|
import 'date-fns/isEqual';
|
|
11
|
-
import { useStaticViewMonthes } from '../hooks.js';
|
|
12
|
-
import { s as styles } from '../index.module-
|
|
11
|
+
import { useStaticViewMonthes, useSelectionProps } from '../hooks.js';
|
|
12
|
+
import { s as styles } from '../index.module-4c141936.js';
|
|
13
13
|
import endOfMonth from 'date-fns/endOfMonth';
|
|
14
14
|
import { usePeriodWithReset, Calendar } from '@alfalab/core-components-calendar/dist/modern';
|
|
15
15
|
import { isDayButton } from '../utils.js';
|
|
16
16
|
|
|
17
17
|
/* eslint-disable complexity */
|
|
18
18
|
const CalendarRangeStatic = ({ className, defaultMonth = startOfMonth(new Date()).getTime(), minDate, maxDate, valueFrom = '', valueTo = '', onDateFromChange = () => null, onDateToChange = () => null, onChange = () => null, inputFromProps = {}, inputToProps = {}, offDays, events, dataTestId, }) => {
|
|
19
|
-
const calendarToRef = useRef(null);
|
|
20
19
|
const [inputFromValue, setInputFromValue] = useState(valueFrom);
|
|
21
20
|
const [inputToValue, setInputToValue] = useState(valueTo);
|
|
22
21
|
let dateFrom = isValidInputValue(inputFromValue, minDate, maxDate, offDays)
|
|
@@ -31,7 +30,7 @@ const CalendarRangeStatic = ({ className, defaultMonth = startOfMonth(new Date()
|
|
|
31
30
|
const bothInvalid = isCompleteDateInput(inputFromValue) &&
|
|
32
31
|
isCompleteDateInput(inputToValue) &&
|
|
33
32
|
parseDateString(inputFromValue).getTime() > parseDateString(inputToValue).getTime();
|
|
34
|
-
const [
|
|
33
|
+
const [highlightedDate, setHighlightedDate] = useState(undefined);
|
|
35
34
|
const period = usePeriodWithReset({
|
|
36
35
|
initialSelectedFrom: dateFrom ? parseDateString(inputFromValue).getTime() : undefined,
|
|
37
36
|
initialSelectedTo: dateTo ? parseDateString(inputToValue).getTime() : undefined,
|
|
@@ -57,21 +56,17 @@ const CalendarRangeStatic = ({ className, defaultMonth = startOfMonth(new Date()
|
|
|
57
56
|
const handleInputToChange = useCallback((_, payload) => {
|
|
58
57
|
setInputToValue(payload.value);
|
|
59
58
|
}, []);
|
|
60
|
-
const
|
|
59
|
+
const handleMouseOver = useCallback((event) => {
|
|
61
60
|
const target = event.target;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return highlighted;
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
setNextMonthHighlighted(false);
|
|
61
|
+
const mouseOverDayButton = isDayButton(target) || isDayButton(target.parentElement);
|
|
62
|
+
let date;
|
|
63
|
+
if (mouseOverDayButton) {
|
|
64
|
+
const button = target.tagName === 'BUTTON' ? target : target.parentElement;
|
|
65
|
+
if (button.dataset.date) {
|
|
66
|
+
date = +button.dataset.date;
|
|
67
|
+
}
|
|
74
68
|
}
|
|
69
|
+
setHighlightedDate(date);
|
|
75
70
|
}, []);
|
|
76
71
|
const handleClearFrom = useCallback(() => {
|
|
77
72
|
setInputFromValue('');
|
|
@@ -135,24 +130,25 @@ const CalendarRangeStatic = ({ className, defaultMonth = startOfMonth(new Date()
|
|
|
135
130
|
}
|
|
136
131
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
137
132
|
}, [inputToValue]);
|
|
133
|
+
const rangeProps = useSelectionProps(period.selectedFrom, period.selectedTo, highlightedDate);
|
|
138
134
|
const { calendarProps: calendarFromProps, ...dateInputFromProps } = inputFromProps;
|
|
139
135
|
const { calendarProps: calendarToProps, ...dateInputToProps } = inputToProps;
|
|
140
136
|
const CalendarFromComponent = dateInputFromProps.Calendar || Calendar;
|
|
141
137
|
const CalendarToComponent = dateInputToProps.Calendar || Calendar;
|
|
142
138
|
return (
|
|
143
139
|
// eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
|
|
144
|
-
React.createElement("div", { className: cn(styles.component, styles.static, className), onMouseOver:
|
|
140
|
+
React.createElement("div", { className: cn(styles.component, styles.static, className), onMouseOver: handleMouseOver, "data-test-id": dataTestId },
|
|
145
141
|
React.createElement("div", null,
|
|
146
142
|
React.createElement(DateInput, Object.assign({}, dateInputFromProps, { mobileMode: dateInputFromProps.mobileMode === 'popover'
|
|
147
143
|
? 'input'
|
|
148
144
|
: dateInputFromProps.mobileMode, value: inputFromValue, onChange: handleInputFromChange, onClear: handleClearFrom, onBlur: handleValidInputFrom, error: bothInvalid || inputFromInvalid || dateInputFromProps.error, clear: true, block: true })),
|
|
149
|
-
React.createElement(CalendarFromComponent, Object.assign({}, 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()
|
|
145
|
+
React.createElement(CalendarFromComponent, Object.assign({}, 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))),
|
|
150
146
|
React.createElement("span", { className: styles.divider }),
|
|
151
147
|
React.createElement("div", null,
|
|
152
148
|
React.createElement(DateInput, Object.assign({}, dateInputToProps, { mobileMode: dateInputToProps.mobileMode === 'popover'
|
|
153
149
|
? 'input'
|
|
154
150
|
: dateInputToProps.mobileMode, value: inputToValue, onChange: handleInputToChange, onClear: handleClearTo, onBlur: handleValidInputTo, error: bothInvalid || inputToInvalid, clear: true, block: true })),
|
|
155
|
-
React.createElement(CalendarToComponent, Object.assign({}, calendarToProps, { className: cn(styles.calendar, calendarToProps?.className),
|
|
151
|
+
React.createElement(CalendarToComponent, Object.assign({}, calendarToProps, { className: cn(styles.calendar, calendarToProps?.className), month: monthTo, selectorView: 'month-only', offDays: offDays, events: events, onChange: period.updatePeriod, onMonthChange: handleMonthToChange, minDate: minDate && startOfMonth(addMonths(minDate, 1)).getTime(), maxDate: maxDate }, rangeProps)))));
|
|
156
152
|
};
|
|
157
153
|
|
|
158
154
|
export { CalendarRangeStatic };
|
package/dist/utils.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var isDayButton = function (node) {
|
|
5
|
+
var isDayButton = function (node) {
|
|
6
|
+
return node && node.tagName === 'BUTTON' && node.dataset.date;
|
|
7
|
+
};
|
|
6
8
|
|
|
7
9
|
exports.isDayButton = isDayButton;
|
package/dist/views/index.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: 13dnh */
|
|
2
2
|
:root {
|
|
3
3
|
--color-light-graphic-primary: #0b1f35;
|
|
4
4
|
}
|
|
@@ -34,19 +34,19 @@
|
|
|
34
34
|
|
|
35
35
|
/* marker */
|
|
36
36
|
}
|
|
37
|
-
.calendar-
|
|
37
|
+
.calendar-range__component_eksd6 {
|
|
38
38
|
display: flex
|
|
39
39
|
}
|
|
40
|
-
.calendar-
|
|
40
|
+
.calendar-range__component_eksd6 button[aria-selected='true'] {
|
|
41
41
|
cursor: pointer;
|
|
42
42
|
}
|
|
43
|
-
.calendar-
|
|
43
|
+
.calendar-range__component_eksd6 *[class*='errorIcon_'] {
|
|
44
44
|
display: none;
|
|
45
45
|
}
|
|
46
|
-
.calendar-
|
|
46
|
+
.calendar-range__component_eksd6 *[class*='calendarIcon_'] {
|
|
47
47
|
margin-right: 0;
|
|
48
48
|
}
|
|
49
|
-
.calendar-
|
|
49
|
+
.calendar-range__divider_eksd6 {
|
|
50
50
|
height: 48px;
|
|
51
51
|
display: flex;
|
|
52
52
|
align-items: center;
|
|
@@ -54,13 +54,13 @@
|
|
|
54
54
|
width: 16px;
|
|
55
55
|
margin: 0 var(--gap-xs)
|
|
56
56
|
}
|
|
57
|
-
.calendar-
|
|
57
|
+
.calendar-range__divider_eksd6:after {
|
|
58
58
|
content: '';
|
|
59
59
|
display: block;
|
|
60
60
|
width: 100%;
|
|
61
61
|
height: 1px;
|
|
62
62
|
background-color: var(--color-light-graphic-primary);
|
|
63
63
|
}
|
|
64
|
-
.calendar-
|
|
64
|
+
.calendar-range__static_eksd6 .calendar-range__calendar_eksd6 {
|
|
65
65
|
width: var(--calendar-inner-width);
|
|
66
66
|
}
|
package/dist/views/popover.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var index_module = require('../index.module-
|
|
5
|
+
var index_module = require('../index.module-a9bc9731.js');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var cn = require('classnames');
|
|
8
8
|
var startOfMonth = require('date-fns/startOfMonth');
|
package/dist/views/static.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var index_module = require('../index.module-
|
|
5
|
+
var index_module = require('../index.module-a9bc9731.js');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var cn = require('classnames');
|
|
8
8
|
var startOfMonth = require('date-fns/startOfMonth');
|
|
@@ -30,7 +30,6 @@ var endOfMonth__default = /*#__PURE__*/_interopDefaultLegacy(endOfMonth);
|
|
|
30
30
|
|
|
31
31
|
var CalendarRangeStatic = function (_a) {
|
|
32
32
|
var className = _a.className, _b = _a.defaultMonth, defaultMonth = _b === void 0 ? startOfMonth__default['default'](new Date()).getTime() : _b, minDate = _a.minDate, maxDate = _a.maxDate, _c = _a.valueFrom, valueFrom = _c === void 0 ? '' : _c, _d = _a.valueTo, valueTo = _d === void 0 ? '' : _d, _e = _a.onDateFromChange, onDateFromChange = _e === void 0 ? function () { return null; } : _e, _f = _a.onDateToChange, onDateToChange = _f === void 0 ? function () { return null; } : _f, _g = _a.onChange, onChange = _g === void 0 ? function () { return null; } : _g, _h = _a.inputFromProps, inputFromProps = _h === void 0 ? {} : _h, _j = _a.inputToProps, inputToProps = _j === void 0 ? {} : _j, offDays = _a.offDays, events = _a.events, dataTestId = _a.dataTestId;
|
|
33
|
-
var calendarToRef = React.useRef(null);
|
|
34
33
|
var _k = React.useState(valueFrom), inputFromValue = _k[0], setInputFromValue = _k[1];
|
|
35
34
|
var _l = React.useState(valueTo), inputToValue = _l[0], setInputToValue = _l[1];
|
|
36
35
|
var dateFrom = coreComponentsCalendarInput.isValidInputValue(inputFromValue, minDate, maxDate, offDays)
|
|
@@ -45,7 +44,7 @@ var CalendarRangeStatic = function (_a) {
|
|
|
45
44
|
var bothInvalid = coreComponentsDateInput.isCompleteDateInput(inputFromValue) &&
|
|
46
45
|
coreComponentsDateInput.isCompleteDateInput(inputToValue) &&
|
|
47
46
|
coreComponentsCalendarInput.parseDateString(inputFromValue).getTime() > coreComponentsCalendarInput.parseDateString(inputToValue).getTime();
|
|
48
|
-
var _m = React.useState(
|
|
47
|
+
var _m = React.useState(undefined), highlightedDate = _m[0], setHighlightedDate = _m[1];
|
|
49
48
|
var period = coreComponentsCalendar.usePeriodWithReset({
|
|
50
49
|
initialSelectedFrom: dateFrom ? coreComponentsCalendarInput.parseDateString(inputFromValue).getTime() : undefined,
|
|
51
50
|
initialSelectedTo: dateTo ? coreComponentsCalendarInput.parseDateString(inputToValue).getTime() : undefined,
|
|
@@ -71,22 +70,17 @@ var CalendarRangeStatic = function (_a) {
|
|
|
71
70
|
var handleInputToChange = React.useCallback(function (_, payload) {
|
|
72
71
|
setInputToValue(payload.value);
|
|
73
72
|
}, []);
|
|
74
|
-
var
|
|
75
|
-
var _a;
|
|
73
|
+
var handleMouseOver = React.useCallback(function (event) {
|
|
76
74
|
var target = event.target;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
return highlighted;
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
setNextMonthHighlighted(false);
|
|
75
|
+
var mouseOverDayButton = utils.isDayButton(target) || utils.isDayButton(target.parentElement);
|
|
76
|
+
var date;
|
|
77
|
+
if (mouseOverDayButton) {
|
|
78
|
+
var button = target.tagName === 'BUTTON' ? target : target.parentElement;
|
|
79
|
+
if (button.dataset.date) {
|
|
80
|
+
date = +button.dataset.date;
|
|
81
|
+
}
|
|
89
82
|
}
|
|
83
|
+
setHighlightedDate(date);
|
|
90
84
|
}, []);
|
|
91
85
|
var handleClearFrom = React.useCallback(function () {
|
|
92
86
|
setInputFromValue('');
|
|
@@ -150,24 +144,25 @@ var CalendarRangeStatic = function (_a) {
|
|
|
150
144
|
}
|
|
151
145
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
152
146
|
}, [inputToValue]);
|
|
147
|
+
var rangeProps = hooks.useSelectionProps(period.selectedFrom, period.selectedTo, highlightedDate);
|
|
153
148
|
var calendarFromProps = inputFromProps.calendarProps, dateInputFromProps = index_module.__rest(inputFromProps, ["calendarProps"]);
|
|
154
149
|
var calendarToProps = inputToProps.calendarProps, dateInputToProps = index_module.__rest(inputToProps, ["calendarProps"]);
|
|
155
150
|
var CalendarFromComponent = dateInputFromProps.Calendar || coreComponentsCalendar.Calendar;
|
|
156
151
|
var CalendarToComponent = dateInputToProps.Calendar || coreComponentsCalendar.Calendar;
|
|
157
152
|
return (
|
|
158
153
|
// eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
|
|
159
|
-
React__default['default'].createElement("div", { className: cn__default['default'](index_module.styles.component, index_module.styles.static, className), onMouseOver:
|
|
154
|
+
React__default['default'].createElement("div", { className: cn__default['default'](index_module.styles.component, index_module.styles.static, className), onMouseOver: handleMouseOver, "data-test-id": dataTestId },
|
|
160
155
|
React__default['default'].createElement("div", null,
|
|
161
156
|
React__default['default'].createElement(coreComponentsDateInput.DateInput, index_module.__assign({}, dateInputFromProps, { mobileMode: dateInputFromProps.mobileMode === 'popover'
|
|
162
157
|
? 'input'
|
|
163
158
|
: dateInputFromProps.mobileMode, value: inputFromValue, onChange: handleInputFromChange, onClear: handleClearFrom, onBlur: handleValidInputFrom, error: bothInvalid || inputFromInvalid || dateInputFromProps.error, clear: true, block: true })),
|
|
164
|
-
React__default['default'].createElement(CalendarFromComponent, index_module.__assign({}, calendarFromProps, { className: cn__default['default'](index_module.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__default['default']([maxDate, endOfMonth__default['default'](subMonths__default['default'](maxDate, 1))]).getTime()
|
|
159
|
+
React__default['default'].createElement(CalendarFromComponent, index_module.__assign({}, calendarFromProps, { className: cn__default['default'](index_module.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__default['default']([maxDate, endOfMonth__default['default'](subMonths__default['default'](maxDate, 1))]).getTime() }, rangeProps))),
|
|
165
160
|
React__default['default'].createElement("span", { className: index_module.styles.divider }),
|
|
166
161
|
React__default['default'].createElement("div", null,
|
|
167
162
|
React__default['default'].createElement(coreComponentsDateInput.DateInput, index_module.__assign({}, dateInputToProps, { mobileMode: dateInputToProps.mobileMode === 'popover'
|
|
168
163
|
? 'input'
|
|
169
164
|
: dateInputToProps.mobileMode, value: inputToValue, onChange: handleInputToChange, onClear: handleClearTo, onBlur: handleValidInputTo, error: bothInvalid || inputToInvalid, clear: true, block: true })),
|
|
170
|
-
React__default['default'].createElement(CalendarToComponent, index_module.__assign({}, calendarToProps, { className: cn__default['default'](index_module.styles.calendar, calendarToProps === null || calendarToProps === void 0 ? void 0 : calendarToProps.className),
|
|
165
|
+
React__default['default'].createElement(CalendarToComponent, index_module.__assign({}, calendarToProps, { className: cn__default['default'](index_module.styles.calendar, calendarToProps === null || calendarToProps === void 0 ? void 0 : calendarToProps.className), month: monthTo, selectorView: 'month-only', offDays: offDays, events: events, onChange: period.updatePeriod, onMonthChange: handleMonthToChange, minDate: minDate && startOfMonth__default['default'](addMonths__default['default'](minDate, 1)).getTime(), maxDate: maxDate }, rangeProps)))));
|
|
171
166
|
};
|
|
172
167
|
|
|
173
168
|
exports.CalendarRangeStatic = CalendarRangeStatic;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alfalab/core-components-calendar-range",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"description": "Calendar range component",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,5 +25,5 @@
|
|
|
25
25
|
"classnames": "^2.2.6",
|
|
26
26
|
"date-fns": "^2.16.1"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "306fbf59136bff772c75ec3f5c0c87fb5a803b15"
|
|
29
29
|
}
|