@alfalab/core-components-calendar-range 7.7.7 → 7.8.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/@alfalab/core-components-shared/node_modules/@alfalab/hooks/package.json +42 -0
- package/@alfalab/core-components-shared/package.json +25 -0
- package/@alfalab/data/package.json +27 -0
- package/@alfalab/utils/package.json +33 -0
- package/Component.d.ts +4 -0
- package/components/divider/Component.js +1 -1
- package/components/divider/index.css +8 -8
- package/cssm/Component.d.ts +4 -0
- package/cssm/shared/index.d.ts +1 -0
- package/cssm/shared/index.js +9 -0
- package/cssm/utils.d.ts +6 -1
- package/cssm/utils.js +10 -0
- package/cssm/views/index.module.css +5 -1
- package/cssm/views/static.js +11 -7
- package/esm/Component.d.ts +4 -0
- package/esm/components/divider/Component.js +1 -1
- package/esm/components/divider/index.css +8 -8
- package/esm/index.module-310fc5cc.js +4 -0
- package/esm/shared/index.d.ts +1 -0
- package/esm/shared/index.js +1 -0
- package/esm/utils.d.ts +6 -1
- package/esm/utils.js +10 -1
- package/esm/views/index.css +12 -8
- package/esm/views/popover.js +1 -1
- package/esm/views/static.js +12 -8
- package/index.module-ed2ad236.js +6 -0
- package/modern/Component.d.ts +4 -0
- package/modern/components/divider/Component.js +1 -1
- package/modern/components/divider/index.css +8 -8
- package/modern/index.module-33e98a48.js +4 -0
- package/modern/shared/index.d.ts +1 -0
- package/modern/shared/index.js +1 -0
- package/modern/utils.d.ts +6 -1
- package/modern/utils.js +10 -1
- package/modern/views/index.css +12 -8
- package/modern/views/popover.js +1 -1
- package/modern/views/static.js +12 -8
- package/moderncssm/Component.d.ts +4 -0
- package/moderncssm/shared/index.d.ts +1 -0
- package/moderncssm/shared/index.js +1 -0
- package/moderncssm/utils.d.ts +6 -1
- package/moderncssm/utils.js +10 -1
- package/moderncssm/views/index.module.css +5 -0
- package/moderncssm/views/static.js +11 -7
- package/package.json +7 -6
- package/shared/index.d.ts +1 -0
- package/shared/index.js +9 -0
- package/src/Component.tsx +5 -0
- package/src/shared/index.ts +1 -0
- package/src/utils.ts +10 -0
- package/src/views/index.module.css +6 -0
- package/src/views/static.tsx +44 -34
- package/utils.d.ts +6 -1
- package/utils.js +10 -0
- package/views/index.css +12 -8
- package/views/popover.js +1 -1
- package/views/static.js +12 -8
- package/esm/index.module-b43c1a3b.js +0 -4
- package/index.module-f3dff99a.js +0 -6
- package/modern/index.module-fdd1725d.js +0 -4
package/esm/views/static.js
CHANGED
|
@@ -11,13 +11,14 @@ import { CalendarDesktop } from '@alfalab/core-components-calendar/esm/desktop';
|
|
|
11
11
|
import { usePeriodWithReset } from '@alfalab/core-components-calendar/esm/shared';
|
|
12
12
|
import { isValidInputValue, parseDateString, formatDate } from '@alfalab/core-components-calendar-input/esm/shared';
|
|
13
13
|
import { isCompleteDateInput, DateInput } from '@alfalab/core-components-date-input/esm';
|
|
14
|
+
import { getDataTestId } from '@alfalab/core-components-shared/esm';
|
|
14
15
|
import { Divider } from '../components/divider/Component.js';
|
|
15
16
|
import { useStaticViewMonthes, useSelectionProps } from '../hooks.js';
|
|
16
17
|
import { isDayButton } from '../utils.js';
|
|
17
|
-
import { s as styles } from '../index.module-
|
|
18
|
+
import { s as styles } from '../index.module-310fc5cc.js';
|
|
18
19
|
|
|
19
20
|
var CalendarRangeStatic = function (_a) {
|
|
20
|
-
var className = _a.className, _b = _a.defaultMonth, defaultMonth = _b === void 0 ? startOfMonth(new Date()).getTime() : _b, _c = _a.defaultMonthPosition, defaultMonthPosition = _c === void 0 ? 'left' : _c, minDate = _a.minDate, maxDate = _a.maxDate, _d = _a.valueFrom, valueFrom = _d === void 0 ? '' : _d, _e = _a.valueTo, valueTo = _e === void 0 ? '' : _e, _f = _a.onDateFromChange, onDateFromChange = _f === void 0 ? function () { return null; } : _f, _g = _a.onDateToChange, onDateToChange = _g === void 0 ? function () { return null; } : _g, _h = _a.onChange, onChange = _h === void 0 ? function () { return null; } : _h, onError = _a.onError, _j = _a.inputFromProps, inputFromProps = _j === void 0 ? {} : _j, _k = _a.inputToProps, inputToProps = _k === void 0 ? {} : _k, offDays = _a.offDays, events = _a.events, _l = _a.returnInvalidDates, returnInvalidDates = _l === void 0 ? false : _l, dataTestId = _a.dataTestId;
|
|
21
|
+
var className = _a.className, _b = _a.defaultMonth, defaultMonth = _b === void 0 ? startOfMonth(new Date()).getTime() : _b, _c = _a.defaultMonthPosition, defaultMonthPosition = _c === void 0 ? 'left' : _c, minDate = _a.minDate, maxDate = _a.maxDate, _d = _a.valueFrom, valueFrom = _d === void 0 ? '' : _d, _e = _a.valueTo, valueTo = _e === void 0 ? '' : _e, _f = _a.onDateFromChange, onDateFromChange = _f === void 0 ? function () { return null; } : _f, _g = _a.onDateToChange, onDateToChange = _g === void 0 ? function () { return null; } : _g, _h = _a.onChange, onChange = _h === void 0 ? function () { return null; } : _h, onError = _a.onError, _j = _a.inputFromProps, inputFromProps = _j === void 0 ? {} : _j, _k = _a.inputToProps, inputToProps = _k === void 0 ? {} : _k, offDays = _a.offDays, events = _a.events, _l = _a.returnInvalidDates, returnInvalidDates = _l === void 0 ? false : _l, dataTestId = _a.dataTestId, calendarContainerClassName = _a.calendarContainerClassName;
|
|
21
22
|
var _m = useState(valueFrom), inputFromValue = _m[0], setInputFromValue = _m[1];
|
|
22
23
|
var _o = useState(valueTo), inputToValue = _o[0], setInputToValue = _o[1];
|
|
23
24
|
var dateFrom = isValidInputValue(inputFromValue, minDate, maxDate, offDays)
|
|
@@ -161,17 +162,20 @@ var CalendarRangeStatic = function (_a) {
|
|
|
161
162
|
React.createElement(DateInput, __assign({}, dateInputFromProps, { mobileMode: dateInputFromProps.mobileMode === 'popover'
|
|
162
163
|
? 'input'
|
|
163
164
|
: dateInputFromProps.mobileMode, value: inputFromValue, onChange: handleInputFromChange, onClear: handleClearFrom, onBlur: handleValidInputFrom, error: bothInvalid || inputFromInvalid || dateInputFromProps.error, clear: true, block: true })),
|
|
164
|
-
React.createElement(
|
|
165
|
-
|
|
166
|
-
|
|
165
|
+
React.createElement("div", { className: cn(styles.calendarContainer, calendarContainerClassName), "data-test-id": getDataTestId(dataTestId, 'container-from') },
|
|
166
|
+
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: minMaxInSameMonth
|
|
167
|
+
? maxDate
|
|
168
|
+
: maxDate &&
|
|
169
|
+
max([maxDate, endOfMonth(subMonths(maxDate, 1))]).getTime() }, rangeProps)))),
|
|
167
170
|
React.createElement(Divider, { inputFromProps: inputFromProps, inputToProps: inputToProps }),
|
|
168
171
|
React.createElement("div", null,
|
|
169
172
|
React.createElement(DateInput, __assign({}, dateInputToProps, { mobileMode: dateInputToProps.mobileMode === 'popover'
|
|
170
173
|
? 'input'
|
|
171
174
|
: dateInputToProps.mobileMode, value: inputToValue, onChange: handleInputToChange, onClear: handleClearTo, onBlur: handleValidInputTo, error: bothInvalid || inputToInvalid || dateInputToProps.error, clear: true, block: true })),
|
|
172
|
-
React.createElement(
|
|
173
|
-
|
|
174
|
-
|
|
175
|
+
React.createElement("div", { "data-test-id": getDataTestId(dataTestId, 'container-to') },
|
|
176
|
+
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: minMaxInSameMonth
|
|
177
|
+
? minDate
|
|
178
|
+
: minDate && startOfMonth(addMonths(minDate, 1)).getTime(), maxDate: maxDate }, rangeProps))))));
|
|
175
179
|
};
|
|
176
180
|
|
|
177
181
|
export { CalendarRangeStatic };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var styles = {"component":"calendar-range__component_1rriu","static":"calendar-range__static_1rriu","calendar":"calendar-range__calendar_1rriu","calendarContainer":"calendar-range__calendarContainer_1rriu"};
|
|
4
|
+
require('./views/index.css')
|
|
5
|
+
|
|
6
|
+
exports.styles = styles;
|
package/modern/Component.d.ts
CHANGED
|
@@ -85,6 +85,10 @@ type CalendarRangeProps = {
|
|
|
85
85
|
* Возвращать невалидную дату для кастомной валидации
|
|
86
86
|
*/
|
|
87
87
|
returnInvalidDates?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Дополнительный класс для контейнера календаря
|
|
90
|
+
*/
|
|
91
|
+
calendarContainerClassName?: string;
|
|
88
92
|
};
|
|
89
93
|
declare const CalendarRange: FC<CalendarRangeProps>;
|
|
90
94
|
export { CalendarRangeProps, CalendarRange };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import cn from 'classnames';
|
|
3
3
|
|
|
4
|
-
const styles = {"component":"calendar-
|
|
4
|
+
const styles = {"component":"calendar-range__component_1j1lv","outer":"calendar-range__outer_1j1lv","s":"calendar-range__s_1j1lv","m":"calendar-range__m_1j1lv","l":"calendar-range__l_1j1lv","xl":"calendar-range__xl_1j1lv"};
|
|
5
5
|
require('./index.css')
|
|
6
6
|
|
|
7
7
|
const Divider = ({ inputFromProps, inputToProps }) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: 12mvb */
|
|
2
2
|
:root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
3
3
|
} /* deprecated */ :root {
|
|
4
4
|
--color-light-neutral-translucent-1300: rgba(3, 3, 6, 0.88); /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
@@ -49,29 +49,29 @@
|
|
|
49
49
|
/* disabled */
|
|
50
50
|
|
|
51
51
|
/* marker */
|
|
52
|
-
} .calendar-
|
|
52
|
+
} .calendar-range__component_1j1lv {
|
|
53
53
|
display: flex;
|
|
54
54
|
align-items: center;
|
|
55
55
|
justify-content: center;
|
|
56
56
|
width: 16px;
|
|
57
57
|
margin: var(--gap-0) var(--gap-8)
|
|
58
|
-
} .calendar-
|
|
58
|
+
} .calendar-range__component_1j1lv:after {
|
|
59
59
|
content: '';
|
|
60
60
|
display: block;
|
|
61
61
|
width: 100%;
|
|
62
62
|
height: 1px;
|
|
63
63
|
background-color: var(--color-light-neutral-translucent-1300);
|
|
64
|
-
} .calendar-
|
|
64
|
+
} .calendar-range__outer_1j1lv {
|
|
65
65
|
position: relative;
|
|
66
66
|
|
|
67
67
|
/* FormControl .above height + margin-bottom */
|
|
68
68
|
top: var(--gap-24);
|
|
69
|
-
} .calendar-
|
|
69
|
+
} .calendar-range__s_1j1lv {
|
|
70
70
|
height: var(--size-s-height);
|
|
71
|
-
} .calendar-
|
|
71
|
+
} .calendar-range__m_1j1lv {
|
|
72
72
|
height: var(--size-m-height);
|
|
73
|
-
} .calendar-
|
|
73
|
+
} .calendar-range__l_1j1lv {
|
|
74
74
|
height: var(--size-l-height);
|
|
75
|
-
} .calendar-
|
|
75
|
+
} .calendar-range__xl_1j1lv {
|
|
76
76
|
height: var(--size-xl-height);
|
|
77
77
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getCalendarRangeTestIds } from "../utils";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getCalendarRangeTestIds } from '../utils.js';
|
package/modern/utils.d.ts
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
declare const isDayButton: (node: HTMLElement | null) => string | false | null | undefined;
|
|
2
|
-
|
|
2
|
+
declare function getCalendarRangeTestIds(dataTestId: string): {
|
|
3
|
+
component: string;
|
|
4
|
+
calendarContainerFrom: string;
|
|
5
|
+
calendarContainerTo: string;
|
|
6
|
+
};
|
|
7
|
+
export { isDayButton, getCalendarRangeTestIds };
|
package/modern/utils.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
import { getDataTestId } from '@alfalab/core-components-shared/modern';
|
|
2
|
+
|
|
1
3
|
const isDayButton = (node) => node && node.tagName === 'BUTTON' && node.dataset.date;
|
|
4
|
+
function getCalendarRangeTestIds(dataTestId) {
|
|
5
|
+
return {
|
|
6
|
+
component: dataTestId,
|
|
7
|
+
calendarContainerFrom: getDataTestId(dataTestId, 'container-from'),
|
|
8
|
+
calendarContainerTo: getDataTestId(dataTestId, 'container-to'),
|
|
9
|
+
};
|
|
10
|
+
}
|
|
2
11
|
|
|
3
|
-
export { isDayButton };
|
|
12
|
+
export { getCalendarRangeTestIds, isDayButton };
|
package/modern/views/index.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: y4y2j */
|
|
2
2
|
:root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
3
3
|
} /* deprecated */ :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
4
4
|
} :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
@@ -45,16 +45,20 @@
|
|
|
45
45
|
/* disabled */
|
|
46
46
|
|
|
47
47
|
/* marker */
|
|
48
|
-
} .calendar-
|
|
48
|
+
} .calendar-range__component_1rriu {
|
|
49
49
|
display: flex
|
|
50
|
-
} .calendar-
|
|
50
|
+
} .calendar-range__component_1rriu button[aria-selected='true'] {
|
|
51
51
|
cursor: pointer;
|
|
52
|
-
} .calendar-
|
|
52
|
+
} .calendar-range__component_1rriu *[class*='errorIcon_'] {
|
|
53
53
|
display: none;
|
|
54
|
-
} .calendar-
|
|
54
|
+
} .calendar-range__component_1rriu *[class*='calendarIcon_'] {
|
|
55
55
|
margin-right: var(--gap-0);
|
|
56
|
-
} .calendar-
|
|
56
|
+
} .calendar-range__static_1rriu .calendar-range__calendar_1rriu {
|
|
57
57
|
width: var(--calendar-inner-width)
|
|
58
|
-
} .calendar-
|
|
58
|
+
} .calendar-range__static_1rriu .calendar-range__calendar_1rriu > div:first-child {
|
|
59
59
|
padding: var(--gap-16) var(--gap-0) var(--gap-12);
|
|
60
|
-
}
|
|
60
|
+
} .calendar-range__calendarContainer_1rriu {
|
|
61
|
+
width: var(--calendar-inner-width);
|
|
62
|
+
display: flex;
|
|
63
|
+
justify-content: center;
|
|
64
|
+
}
|
package/modern/views/popover.js
CHANGED
|
@@ -7,7 +7,7 @@ import { isCompleteDateInput } from '@alfalab/core-components-date-input/modern'
|
|
|
7
7
|
import { useDidUpdateEffect } from '@alfalab/hooks';
|
|
8
8
|
import { Divider } from '../components/divider/Component.js';
|
|
9
9
|
import { usePopoverViewMonthes } from '../hooks.js';
|
|
10
|
-
import { s as styles } from '../index.module-
|
|
10
|
+
import { s as styles } from '../index.module-33e98a48.js';
|
|
11
11
|
|
|
12
12
|
const CalendarRangePopover = ({ className, defaultMonth = startOfMonth(new Date()).getTime(), minDate, maxDate, valueFrom = '', valueTo = '', onDateFromChange = () => null, onDateToChange = () => null, onChange = () => null, onError, inputFromProps = {}, inputToProps = {}, offDays, events, returnInvalidDates = false, dataTestId, }) => {
|
|
13
13
|
const [inputFromValue, setInputFromValue] = useState(valueFrom);
|
package/modern/views/static.js
CHANGED
|
@@ -10,13 +10,14 @@ import { CalendarDesktop } from '@alfalab/core-components-calendar/modern/deskto
|
|
|
10
10
|
import { usePeriodWithReset } from '@alfalab/core-components-calendar/modern/shared';
|
|
11
11
|
import { isValidInputValue, parseDateString, formatDate } from '@alfalab/core-components-calendar-input/modern/shared';
|
|
12
12
|
import { isCompleteDateInput, DateInput } from '@alfalab/core-components-date-input/modern';
|
|
13
|
+
import { getDataTestId } from '@alfalab/core-components-shared/modern';
|
|
13
14
|
import { Divider } from '../components/divider/Component.js';
|
|
14
15
|
import { useStaticViewMonthes, useSelectionProps } from '../hooks.js';
|
|
15
16
|
import { isDayButton } from '../utils.js';
|
|
16
|
-
import { s as styles } from '../index.module-
|
|
17
|
+
import { s as styles } from '../index.module-33e98a48.js';
|
|
17
18
|
|
|
18
19
|
/* eslint-disable complexity */
|
|
19
|
-
const CalendarRangeStatic = ({ className, defaultMonth = startOfMonth(new Date()).getTime(), defaultMonthPosition = 'left', minDate, maxDate, valueFrom = '', valueTo = '', onDateFromChange = () => null, onDateToChange = () => null, onChange = () => null, onError, inputFromProps = {}, inputToProps = {}, offDays, events, returnInvalidDates = false, dataTestId, }) => {
|
|
20
|
+
const CalendarRangeStatic = ({ className, defaultMonth = startOfMonth(new Date()).getTime(), defaultMonthPosition = 'left', minDate, maxDate, valueFrom = '', valueTo = '', onDateFromChange = () => null, onDateToChange = () => null, onChange = () => null, onError, inputFromProps = {}, inputToProps = {}, offDays, events, returnInvalidDates = false, dataTestId, calendarContainerClassName, }) => {
|
|
20
21
|
const [inputFromValue, setInputFromValue] = useState(valueFrom);
|
|
21
22
|
const [inputToValue, setInputToValue] = useState(valueTo);
|
|
22
23
|
let dateFrom = isValidInputValue(inputFromValue, minDate, maxDate, offDays)
|
|
@@ -160,17 +161,20 @@ const CalendarRangeStatic = ({ className, defaultMonth = startOfMonth(new Date()
|
|
|
160
161
|
React.createElement(DateInput, { ...dateInputFromProps, mobileMode: dateInputFromProps.mobileMode === 'popover'
|
|
161
162
|
? 'input'
|
|
162
163
|
: dateInputFromProps.mobileMode, value: inputFromValue, onChange: handleInputFromChange, onClear: handleClearFrom, onBlur: handleValidInputFrom, error: bothInvalid || inputFromInvalid || dateInputFromProps.error, clear: true, block: true }),
|
|
163
|
-
React.createElement(
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
React.createElement("div", { className: cn(styles.calendarContainer, calendarContainerClassName), "data-test-id": getDataTestId(dataTestId, 'container-from') },
|
|
165
|
+
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: minMaxInSameMonth
|
|
166
|
+
? maxDate
|
|
167
|
+
: maxDate &&
|
|
168
|
+
max([maxDate, endOfMonth(subMonths(maxDate, 1))]).getTime(), ...rangeProps }))),
|
|
166
169
|
React.createElement(Divider, { inputFromProps: inputFromProps, inputToProps: inputToProps }),
|
|
167
170
|
React.createElement("div", null,
|
|
168
171
|
React.createElement(DateInput, { ...dateInputToProps, mobileMode: dateInputToProps.mobileMode === 'popover'
|
|
169
172
|
? 'input'
|
|
170
173
|
: dateInputToProps.mobileMode, value: inputToValue, onChange: handleInputToChange, onClear: handleClearTo, onBlur: handleValidInputTo, error: bothInvalid || inputToInvalid || dateInputToProps.error, clear: true, block: true }),
|
|
171
|
-
React.createElement(
|
|
172
|
-
|
|
173
|
-
|
|
174
|
+
React.createElement("div", { "data-test-id": getDataTestId(dataTestId, 'container-to') },
|
|
175
|
+
React.createElement(CalendarToComponent, { ...calendarToProps, className: cn(styles.calendar, calendarToProps?.className), month: monthTo, selectorView: 'month-only', offDays: offDays, events: events, onChange: period.updatePeriod, onMonthChange: handleMonthToChange, minDate: minMaxInSameMonth
|
|
176
|
+
? minDate
|
|
177
|
+
: minDate && startOfMonth(addMonths(minDate, 1)).getTime(), maxDate: maxDate, ...rangeProps })))));
|
|
174
178
|
};
|
|
175
179
|
|
|
176
180
|
export { CalendarRangeStatic };
|
|
@@ -85,6 +85,10 @@ type CalendarRangeProps = {
|
|
|
85
85
|
* Возвращать невалидную дату для кастомной валидации
|
|
86
86
|
*/
|
|
87
87
|
returnInvalidDates?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Дополнительный класс для контейнера календаря
|
|
90
|
+
*/
|
|
91
|
+
calendarContainerClassName?: string;
|
|
88
92
|
};
|
|
89
93
|
declare const CalendarRange: FC<CalendarRangeProps>;
|
|
90
94
|
export { CalendarRangeProps, CalendarRange };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getCalendarRangeTestIds } from "../utils";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getCalendarRangeTestIds } from '../utils.js';
|
package/moderncssm/utils.d.ts
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
declare const isDayButton: (node: HTMLElement | null) => string | false | null | undefined;
|
|
2
|
-
|
|
2
|
+
declare function getCalendarRangeTestIds(dataTestId: string): {
|
|
3
|
+
component: string;
|
|
4
|
+
calendarContainerFrom: string;
|
|
5
|
+
calendarContainerTo: string;
|
|
6
|
+
};
|
|
7
|
+
export { isDayButton, getCalendarRangeTestIds };
|
package/moderncssm/utils.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
import { getDataTestId } from '@alfalab/core-components-shared/moderncssm';
|
|
2
|
+
|
|
1
3
|
const isDayButton = (node) => node && node.tagName === 'BUTTON' && node.dataset.date;
|
|
4
|
+
function getCalendarRangeTestIds(dataTestId) {
|
|
5
|
+
return {
|
|
6
|
+
component: dataTestId,
|
|
7
|
+
calendarContainerFrom: getDataTestId(dataTestId, 'container-from'),
|
|
8
|
+
calendarContainerTo: getDataTestId(dataTestId, 'container-to'),
|
|
9
|
+
};
|
|
10
|
+
}
|
|
2
11
|
|
|
3
|
-
export { isDayButton };
|
|
12
|
+
export { getCalendarRangeTestIds, isDayButton };
|
|
@@ -10,13 +10,14 @@ import { CalendarDesktop } from '@alfalab/core-components-calendar/moderncssm/de
|
|
|
10
10
|
import { usePeriodWithReset } from '@alfalab/core-components-calendar/moderncssm/shared';
|
|
11
11
|
import { isValidInputValue, parseDateString, formatDate } from '@alfalab/core-components-calendar-input/moderncssm/shared';
|
|
12
12
|
import { isCompleteDateInput, DateInput } from '@alfalab/core-components-date-input/moderncssm';
|
|
13
|
+
import { getDataTestId } from '@alfalab/core-components-shared/moderncssm';
|
|
13
14
|
import { Divider } from '../components/divider/Component.js';
|
|
14
15
|
import { useStaticViewMonthes, useSelectionProps } from '../hooks.js';
|
|
15
16
|
import { isDayButton } from '../utils.js';
|
|
16
17
|
import styles from './index.module.css';
|
|
17
18
|
|
|
18
19
|
/* eslint-disable complexity */
|
|
19
|
-
const CalendarRangeStatic = ({ className, defaultMonth = startOfMonth(new Date()).getTime(), defaultMonthPosition = 'left', minDate, maxDate, valueFrom = '', valueTo = '', onDateFromChange = () => null, onDateToChange = () => null, onChange = () => null, onError, inputFromProps = {}, inputToProps = {}, offDays, events, returnInvalidDates = false, dataTestId, }) => {
|
|
20
|
+
const CalendarRangeStatic = ({ className, defaultMonth = startOfMonth(new Date()).getTime(), defaultMonthPosition = 'left', minDate, maxDate, valueFrom = '', valueTo = '', onDateFromChange = () => null, onDateToChange = () => null, onChange = () => null, onError, inputFromProps = {}, inputToProps = {}, offDays, events, returnInvalidDates = false, dataTestId, calendarContainerClassName, }) => {
|
|
20
21
|
const [inputFromValue, setInputFromValue] = useState(valueFrom);
|
|
21
22
|
const [inputToValue, setInputToValue] = useState(valueTo);
|
|
22
23
|
let dateFrom = isValidInputValue(inputFromValue, minDate, maxDate, offDays)
|
|
@@ -160,17 +161,20 @@ const CalendarRangeStatic = ({ className, defaultMonth = startOfMonth(new Date()
|
|
|
160
161
|
React.createElement(DateInput, { ...dateInputFromProps, mobileMode: dateInputFromProps.mobileMode === 'popover'
|
|
161
162
|
? 'input'
|
|
162
163
|
: dateInputFromProps.mobileMode, value: inputFromValue, onChange: handleInputFromChange, onClear: handleClearFrom, onBlur: handleValidInputFrom, error: bothInvalid || inputFromInvalid || dateInputFromProps.error, clear: true, block: true }),
|
|
163
|
-
React.createElement(
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
React.createElement("div", { className: cn(styles.calendarContainer, calendarContainerClassName), "data-test-id": getDataTestId(dataTestId, 'container-from') },
|
|
165
|
+
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: minMaxInSameMonth
|
|
166
|
+
? maxDate
|
|
167
|
+
: maxDate &&
|
|
168
|
+
max([maxDate, endOfMonth(subMonths(maxDate, 1))]).getTime(), ...rangeProps }))),
|
|
166
169
|
React.createElement(Divider, { inputFromProps: inputFromProps, inputToProps: inputToProps }),
|
|
167
170
|
React.createElement("div", null,
|
|
168
171
|
React.createElement(DateInput, { ...dateInputToProps, mobileMode: dateInputToProps.mobileMode === 'popover'
|
|
169
172
|
? 'input'
|
|
170
173
|
: dateInputToProps.mobileMode, value: inputToValue, onChange: handleInputToChange, onClear: handleClearTo, onBlur: handleValidInputTo, error: bothInvalid || inputToInvalid || dateInputToProps.error, clear: true, block: true }),
|
|
171
|
-
React.createElement(
|
|
172
|
-
|
|
173
|
-
|
|
174
|
+
React.createElement("div", { "data-test-id": getDataTestId(dataTestId, 'container-to') },
|
|
175
|
+
React.createElement(CalendarToComponent, { ...calendarToProps, className: cn(styles.calendar, calendarToProps?.className), month: monthTo, selectorView: 'month-only', offDays: offDays, events: events, onChange: period.updatePeriod, onMonthChange: handleMonthToChange, minDate: minMaxInSameMonth
|
|
176
|
+
? minDate
|
|
177
|
+
: minDate && startOfMonth(addMonths(minDate, 1)).getTime(), maxDate: maxDate, ...rangeProps })))));
|
|
174
178
|
};
|
|
175
179
|
|
|
176
180
|
export { CalendarRangeStatic };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alfalab/core-components-calendar-range",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.8.0",
|
|
4
4
|
"description": "Calendar range component",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,11 +16,12 @@
|
|
|
16
16
|
"react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@alfalab/core-components-calendar": "^7.17.
|
|
20
|
-
"@alfalab/core-components-calendar-input": "^10.4.
|
|
21
|
-
"@alfalab/core-components-date-input": "^4.4.
|
|
22
|
-
"@alfalab/
|
|
23
|
-
"
|
|
19
|
+
"@alfalab/core-components-calendar": "^7.17.2",
|
|
20
|
+
"@alfalab/core-components-calendar-input": "^10.4.12",
|
|
21
|
+
"@alfalab/core-components-date-input": "^4.4.11",
|
|
22
|
+
"@alfalab/core-components-shared": "^0.14.1",
|
|
23
|
+
"@alfalab/hooks": "^1.13.1",
|
|
24
|
+
"classnames": "^2.5.1",
|
|
24
25
|
"date-fns": "^2.16.1",
|
|
25
26
|
"tslib": "^2.4.0"
|
|
26
27
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getCalendarRangeTestIds } from "../utils";
|
package/shared/index.js
ADDED
package/src/Component.tsx
CHANGED
|
@@ -101,6 +101,11 @@ export type CalendarRangeProps = {
|
|
|
101
101
|
* Возвращать невалидную дату для кастомной валидации
|
|
102
102
|
*/
|
|
103
103
|
returnInvalidDates?: boolean;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Дополнительный класс для контейнера календаря
|
|
107
|
+
*/
|
|
108
|
+
calendarContainerClassName?: string;
|
|
104
109
|
};
|
|
105
110
|
|
|
106
111
|
export const CalendarRange: FC<CalendarRangeProps> = ({
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getCalendarRangeTestIds } from '../utils';
|
package/src/utils.ts
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
|
+
import { getDataTestId } from '@alfalab/core-components-shared';
|
|
2
|
+
|
|
1
3
|
export const isDayButton = (node: HTMLElement | null) =>
|
|
2
4
|
node && node.tagName === 'BUTTON' && node.dataset.date;
|
|
5
|
+
|
|
6
|
+
export function getCalendarRangeTestIds(dataTestId: string) {
|
|
7
|
+
return {
|
|
8
|
+
component: dataTestId,
|
|
9
|
+
calendarContainerFrom: getDataTestId(dataTestId, 'container-from'),
|
|
10
|
+
calendarContainerTo: getDataTestId(dataTestId, 'container-to'),
|
|
11
|
+
};
|
|
12
|
+
}
|