@alfalab/core-components-calendar-range 7.0.32 → 7.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/Component.d.ts +4 -0
- package/Component.js +1 -1
- package/components/divider/Component.js +1 -1
- package/components/divider/index.css +8 -8
- package/cssm/Component.d.ts +4 -0
- package/cssm/views/popover.js +15 -9
- package/cssm/views/static.js +17 -11
- package/esm/Component.d.ts +4 -0
- package/esm/Component.js +1 -1
- package/esm/components/divider/Component.js +1 -1
- package/esm/components/divider/index.css +8 -8
- package/esm/index.js +1 -1
- package/esm/index.module-69c70a25.js +4 -0
- package/esm/views/index.css +6 -6
- package/esm/views/popover.js +16 -10
- package/esm/views/static.js +18 -12
- package/index.js +1 -1
- package/index.module-9935cceb.js +6 -0
- package/modern/Component.d.ts +4 -0
- package/modern/Component.js +1 -1
- package/modern/components/divider/Component.js +1 -1
- package/modern/components/divider/index.css +8 -8
- package/modern/index.js +1 -1
- package/modern/index.module-9c5da023.js +4 -0
- package/modern/views/index.css +6 -6
- package/modern/views/popover.js +9 -3
- package/modern/views/static.js +11 -5
- package/package.json +1 -1
- package/utils.js +3 -1
- package/views/index.css +6 -6
- package/views/popover.js +16 -10
- package/views/static.js +18 -12
- package/esm/index.module-e2d51802.js +0 -4
- package/index.module-c07e0822.js +0 -6
- package/modern/index.module-d44c552d.js +0 -4
package/Component.d.ts
CHANGED
|
@@ -81,6 +81,10 @@ type CalendarRangeProps = {
|
|
|
81
81
|
* Отображать начальный месяц слева или справа (влияет только на начальный рендер)
|
|
82
82
|
*/
|
|
83
83
|
defaultMonthPosition?: 'left' | 'right';
|
|
84
|
+
/**
|
|
85
|
+
* Возвращать невалидную дату для кастомной валидации
|
|
86
|
+
*/
|
|
87
|
+
returnInvalidDates?: boolean;
|
|
84
88
|
};
|
|
85
89
|
declare const CalendarRange: FC<CalendarRangeProps>;
|
|
86
90
|
export { CalendarRangeProps, CalendarRange };
|
package/Component.js
CHANGED
|
@@ -18,7 +18,7 @@ require('date-fns/isEqual');
|
|
|
18
18
|
require('date-fns/max');
|
|
19
19
|
require('date-fns/min');
|
|
20
20
|
require('date-fns/subMonths');
|
|
21
|
-
require('./index.module-
|
|
21
|
+
require('./index.module-9935cceb.js');
|
|
22
22
|
require('date-fns/endOfMonth');
|
|
23
23
|
require('date-fns/isSameMonth');
|
|
24
24
|
require('@alfalab/core-components-calendar');
|
|
@@ -10,7 +10,7 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
10
10
|
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
11
11
|
var cn__default = /*#__PURE__*/_interopDefaultCompat(cn);
|
|
12
12
|
|
|
13
|
-
var styles = {"component":"calendar-
|
|
13
|
+
var styles = {"component":"calendar-range__component_iquxi","outer":"calendar-range__outer_iquxi","s":"calendar-range__s_iquxi","m":"calendar-range__m_iquxi","l":"calendar-range__l_iquxi","xl":"calendar-range__xl_iquxi"};
|
|
14
14
|
require('./index.css')
|
|
15
15
|
|
|
16
16
|
var Divider = function (_a) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: 1i8ir */
|
|
2
2
|
:root {
|
|
3
3
|
} /* deprecated */ :root {
|
|
4
4
|
--color-light-graphic-primary: #0e0e0e; /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
@@ -41,29 +41,29 @@
|
|
|
41
41
|
/* disabled */
|
|
42
42
|
|
|
43
43
|
/* marker */
|
|
44
|
-
} .calendar-
|
|
44
|
+
} .calendar-range__component_iquxi {
|
|
45
45
|
display: flex;
|
|
46
46
|
align-items: center;
|
|
47
47
|
justify-content: center;
|
|
48
48
|
width: 16px;
|
|
49
49
|
margin: 0 var(--gap-xs)
|
|
50
|
-
} .calendar-
|
|
50
|
+
} .calendar-range__component_iquxi:after {
|
|
51
51
|
content: '';
|
|
52
52
|
display: block;
|
|
53
53
|
width: 100%;
|
|
54
54
|
height: 1px;
|
|
55
55
|
background-color: var(--color-light-graphic-primary);
|
|
56
|
-
} .calendar-
|
|
56
|
+
} .calendar-range__outer_iquxi {
|
|
57
57
|
position: relative;
|
|
58
58
|
|
|
59
59
|
/* FormControl .above height + margin-bottom */
|
|
60
60
|
top: 24px;
|
|
61
|
-
} .calendar-
|
|
61
|
+
} .calendar-range__s_iquxi {
|
|
62
62
|
height: var(--size-s-height);
|
|
63
|
-
} .calendar-
|
|
63
|
+
} .calendar-range__m_iquxi {
|
|
64
64
|
height: var(--size-m-height);
|
|
65
|
-
} .calendar-
|
|
65
|
+
} .calendar-range__l_iquxi {
|
|
66
66
|
height: var(--size-l-height);
|
|
67
|
-
} .calendar-
|
|
67
|
+
} .calendar-range__xl_iquxi {
|
|
68
68
|
height: var(--size-xl-height);
|
|
69
69
|
}
|
package/cssm/Component.d.ts
CHANGED
|
@@ -81,6 +81,10 @@ type CalendarRangeProps = {
|
|
|
81
81
|
* Отображать начальный месяц слева или справа (влияет только на начальный рендер)
|
|
82
82
|
*/
|
|
83
83
|
defaultMonthPosition?: 'left' | 'right';
|
|
84
|
+
/**
|
|
85
|
+
* Возвращать невалидную дату для кастомной валидации
|
|
86
|
+
*/
|
|
87
|
+
returnInvalidDates?: boolean;
|
|
84
88
|
};
|
|
85
89
|
declare const CalendarRange: FC<CalendarRangeProps>;
|
|
86
90
|
export { CalendarRangeProps, CalendarRange };
|
package/cssm/views/popover.js
CHANGED
|
@@ -27,33 +27,33 @@ var startOfMonth__default = /*#__PURE__*/_interopDefaultCompat(startOfMonth);
|
|
|
27
27
|
var styles__default = /*#__PURE__*/_interopDefaultCompat(styles);
|
|
28
28
|
|
|
29
29
|
var CalendarRangePopover = function (_a) {
|
|
30
|
-
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, onError = _a.onError, _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;
|
|
31
|
-
var
|
|
32
|
-
var
|
|
30
|
+
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, onError = _a.onError, _h = _a.inputFromProps, inputFromProps = _h === void 0 ? {} : _h, _j = _a.inputToProps, inputToProps = _j === void 0 ? {} : _j, offDays = _a.offDays, events = _a.events, _k = _a.returnInvalidDates, returnInvalidDates = _k === void 0 ? false : _k, dataTestId = _a.dataTestId;
|
|
31
|
+
var _l = React.useState(valueFrom), inputFromValue = _l[0], setInputFromValue = _l[1];
|
|
32
|
+
var _m = React.useState(valueTo), inputToValue = _m[0], setInputToValue = _m[1];
|
|
33
33
|
/**
|
|
34
34
|
* Ключ для сброса календарей
|
|
35
35
|
* Пользователь открыл календарь, изменил месяц, но ничего не выбрал
|
|
36
36
|
* — при следующем открытии в календаре будет установлен начальный месяц
|
|
37
37
|
*/
|
|
38
|
-
var
|
|
38
|
+
var _o = React.useState(0), resetKey = _o[0], setResetKey = _o[1];
|
|
39
39
|
var dateFrom = coreComponentsCalendarInput.isValidInputValue(inputFromValue, minDate, maxDate, offDays)
|
|
40
40
|
? coreComponentsCalendarInput.parseDateString(inputFromValue).getTime()
|
|
41
41
|
: null;
|
|
42
42
|
var dateTo = coreComponentsCalendarInput.isValidInputValue(inputToValue, dateFrom || minDate, maxDate, offDays)
|
|
43
43
|
? coreComponentsCalendarInput.parseDateString(inputToValue).getTime()
|
|
44
44
|
: null;
|
|
45
|
-
var
|
|
46
|
-
var
|
|
45
|
+
var _p = React.useState(coreComponentsDateInput.isCompleteDateInput(inputFromValue) && dateFrom === null), inputFromInvalid = _p[0], setInputFromInvalid = _p[1];
|
|
46
|
+
var _q = React.useState(coreComponentsDateInput.isCompleteDateInput(inputToValue) && dateTo === null), inputToInvalid = _q[0], setInputToInvalid = _q[1];
|
|
47
47
|
var bothInvalid = coreComponentsDateInput.isCompleteDateInput(inputFromValue) &&
|
|
48
48
|
coreComponentsDateInput.isCompleteDateInput(inputToValue) &&
|
|
49
49
|
coreComponentsCalendarInput.parseDateString(inputFromValue).getTime() > coreComponentsCalendarInput.parseDateString(inputToValue).getTime();
|
|
50
50
|
var hasValidateError = inputFromInvalid || inputToInvalid || bothInvalid;
|
|
51
|
-
var
|
|
51
|
+
var _r = hooks.usePopoverViewMonthes({
|
|
52
52
|
dateFrom: dateFrom,
|
|
53
53
|
dateTo: dateTo,
|
|
54
54
|
defaultMonth: defaultMonth,
|
|
55
55
|
resetKey: resetKey,
|
|
56
|
-
}), monthFrom =
|
|
56
|
+
}), monthFrom = _r.monthFrom, monthTo = _r.monthTo, handleMonthFromChange = _r.handleMonthFromChange, handleMonthToChange = _r.handleMonthToChange;
|
|
57
57
|
var handleValidInputFrom = React.useCallback(function () {
|
|
58
58
|
setInputFromInvalid(inputFromValue !== '' && !coreComponentsCalendarInput.isValidInputValue(inputFromValue, minDate, maxDate, offDays));
|
|
59
59
|
}, [inputFromValue, maxDate, minDate, offDays]);
|
|
@@ -106,11 +106,17 @@ var CalendarRangePopover = function (_a) {
|
|
|
106
106
|
}, [inputFromValue]);
|
|
107
107
|
hooks$1.useDidUpdateEffect(function () {
|
|
108
108
|
onDateToChange({ value: inputToValue, date: dateTo });
|
|
109
|
+
// eslint-disable-next-line no-nested-ternary
|
|
110
|
+
var inputDateTo = returnInvalidDates
|
|
111
|
+
? coreComponentsDateInput.isCompleteDateInput(inputToValue)
|
|
112
|
+
? coreComponentsCalendarInput.parseDateString(inputToValue).getTime()
|
|
113
|
+
: null
|
|
114
|
+
: dateTo;
|
|
109
115
|
onChange({
|
|
110
116
|
valueFrom: inputFromValue,
|
|
111
117
|
valueTo: inputToValue,
|
|
112
118
|
dateFrom: dateFrom,
|
|
113
|
-
dateTo:
|
|
119
|
+
dateTo: inputDateTo,
|
|
114
120
|
});
|
|
115
121
|
if (!inputToValue || coreComponentsDateInput.isCompleteDateInput(inputToValue)) {
|
|
116
122
|
handleValidInputTo();
|
package/cssm/views/static.js
CHANGED
|
@@ -35,39 +35,39 @@ var subMonths__default = /*#__PURE__*/_interopDefaultCompat(subMonths);
|
|
|
35
35
|
var styles__default = /*#__PURE__*/_interopDefaultCompat(styles);
|
|
36
36
|
|
|
37
37
|
var CalendarRangeStatic = function (_a) {
|
|
38
|
-
var className = _a.className, _b = _a.defaultMonth, defaultMonth = _b === void 0 ? startOfMonth__default.default(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, dataTestId = _a.dataTestId;
|
|
39
|
-
var
|
|
40
|
-
var
|
|
38
|
+
var className = _a.className, _b = _a.defaultMonth, defaultMonth = _b === void 0 ? startOfMonth__default.default(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;
|
|
39
|
+
var _m = React.useState(valueFrom), inputFromValue = _m[0], setInputFromValue = _m[1];
|
|
40
|
+
var _o = React.useState(valueTo), inputToValue = _o[0], setInputToValue = _o[1];
|
|
41
41
|
var dateFrom = coreComponentsCalendarInput.isValidInputValue(inputFromValue, minDate, maxDate, offDays)
|
|
42
42
|
? coreComponentsCalendarInput.parseDateString(inputFromValue).getTime()
|
|
43
43
|
: null;
|
|
44
44
|
var dateTo = coreComponentsCalendarInput.isValidInputValue(inputToValue, dateFrom || minDate, maxDate, offDays)
|
|
45
45
|
? coreComponentsCalendarInput.parseDateString(inputToValue).getTime()
|
|
46
46
|
: null;
|
|
47
|
-
if (coreComponentsDateInput.isCompleteDateInput(inputToValue) && !dateTo) {
|
|
47
|
+
if (coreComponentsDateInput.isCompleteDateInput(inputToValue) && !dateTo && !returnInvalidDates) {
|
|
48
48
|
dateFrom = null;
|
|
49
49
|
}
|
|
50
50
|
var bothInvalid = coreComponentsDateInput.isCompleteDateInput(inputFromValue) &&
|
|
51
51
|
coreComponentsDateInput.isCompleteDateInput(inputToValue) &&
|
|
52
52
|
coreComponentsCalendarInput.parseDateString(inputFromValue).getTime() > coreComponentsCalendarInput.parseDateString(inputToValue).getTime();
|
|
53
|
-
var
|
|
53
|
+
var _p = React.useState(undefined), highlightedDate = _p[0], setHighlightedDate = _p[1];
|
|
54
54
|
var period = coreComponentsCalendar.usePeriodWithReset({
|
|
55
55
|
initialSelectedFrom: dateFrom ? coreComponentsCalendarInput.parseDateString(inputFromValue).getTime() : undefined,
|
|
56
56
|
initialSelectedTo: dateTo ? coreComponentsCalendarInput.parseDateString(inputToValue).getTime() : undefined,
|
|
57
57
|
});
|
|
58
58
|
var validateInputFromValue = React.useCallback(function (value) { return coreComponentsCalendarInput.isValidInputValue(value, minDate, dateFrom || maxDate, offDays); }, [dateFrom, maxDate, minDate, offDays]);
|
|
59
59
|
var validateInputToValue = React.useCallback(function (value) { return coreComponentsCalendarInput.isValidInputValue(value, dateFrom || minDate, maxDate, offDays); }, [dateFrom, minDate, maxDate, offDays]);
|
|
60
|
-
var
|
|
61
|
-
var
|
|
60
|
+
var _q = React.useState(coreComponentsDateInput.isCompleteDateInput(inputFromValue) && dateFrom === null), inputFromInvalid = _q[0], setInputFromInvalid = _q[1];
|
|
61
|
+
var _r = React.useState(coreComponentsDateInput.isCompleteDateInput(inputToValue) && dateTo === null), inputToInvalid = _r[0], setInputToInvalid = _r[1];
|
|
62
62
|
var hasValidateError = bothInvalid || inputFromInvalid || inputToInvalid;
|
|
63
63
|
var calendarFromProps = inputFromProps.calendarProps, onInputChangeFrom = inputFromProps.onInputChange, dateInputFromProps = tslib.__rest(inputFromProps, ["calendarProps", "onInputChange"]);
|
|
64
64
|
var calendarToProps = inputToProps.calendarProps, onInputChangeTo = inputToProps.onInputChange, dateInputToProps = tslib.__rest(inputToProps, ["calendarProps", "onInputChange"]);
|
|
65
|
-
var
|
|
65
|
+
var _s = hooks.useStaticViewMonthes({
|
|
66
66
|
selectedFrom: period.selectedFrom,
|
|
67
67
|
selectedTo: period.selectedTo,
|
|
68
68
|
defaultMonth: defaultMonth,
|
|
69
69
|
defaultMonthPosition: defaultMonthPosition,
|
|
70
|
-
}), monthFrom =
|
|
70
|
+
}), monthFrom = _s.monthFrom, monthTo = _s.monthTo, handleMonthFromChange = _s.handleMonthFromChange, handleMonthToChange = _s.handleMonthToChange;
|
|
71
71
|
var handleValidInputFrom = React.useCallback(function () {
|
|
72
72
|
setInputFromInvalid(inputFromValue !== '' && !validateInputFromValue(inputFromValue));
|
|
73
73
|
}, [inputFromValue, validateInputFromValue]);
|
|
@@ -143,15 +143,21 @@ var CalendarRangeStatic = function (_a) {
|
|
|
143
143
|
period.setStart(dateFrom);
|
|
144
144
|
}
|
|
145
145
|
if (inputToValue !== valueTo) {
|
|
146
|
+
// eslint-disable-next-line no-nested-ternary
|
|
147
|
+
var inputDateTo = returnInvalidDates
|
|
148
|
+
? coreComponentsDateInput.isCompleteDateInput(inputToValue)
|
|
149
|
+
? coreComponentsCalendarInput.parseDateString(inputToValue).getTime()
|
|
150
|
+
: null
|
|
151
|
+
: dateTo;
|
|
146
152
|
onDateToChange({
|
|
147
153
|
value: inputToValue,
|
|
148
|
-
date:
|
|
154
|
+
date: inputDateTo,
|
|
149
155
|
});
|
|
150
156
|
onChange({
|
|
151
157
|
valueFrom: inputFromValue,
|
|
152
158
|
valueTo: inputToValue,
|
|
153
159
|
dateFrom: dateFrom,
|
|
154
|
-
dateTo:
|
|
160
|
+
dateTo: inputDateTo,
|
|
155
161
|
});
|
|
156
162
|
}
|
|
157
163
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
package/esm/Component.d.ts
CHANGED
|
@@ -81,6 +81,10 @@ type CalendarRangeProps = {
|
|
|
81
81
|
* Отображать начальный месяц слева или справа (влияет только на начальный рендер)
|
|
82
82
|
*/
|
|
83
83
|
defaultMonthPosition?: 'left' | 'right';
|
|
84
|
+
/**
|
|
85
|
+
* Возвращать невалидную дату для кастомной валидации
|
|
86
|
+
*/
|
|
87
|
+
returnInvalidDates?: boolean;
|
|
84
88
|
};
|
|
85
89
|
declare const CalendarRange: FC<CalendarRangeProps>;
|
|
86
90
|
export { CalendarRangeProps, CalendarRange };
|
package/esm/Component.js
CHANGED
|
@@ -14,7 +14,7 @@ import 'date-fns/isEqual';
|
|
|
14
14
|
import 'date-fns/max';
|
|
15
15
|
import 'date-fns/min';
|
|
16
16
|
import 'date-fns/subMonths';
|
|
17
|
-
import './index.module-
|
|
17
|
+
import './index.module-69c70a25.js';
|
|
18
18
|
import 'date-fns/endOfMonth';
|
|
19
19
|
import 'date-fns/isSameMonth';
|
|
20
20
|
import '@alfalab/core-components-calendar/esm';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import cn from 'classnames';
|
|
3
3
|
|
|
4
|
-
var styles = {"component":"calendar-
|
|
4
|
+
var styles = {"component":"calendar-range__component_iquxi","outer":"calendar-range__outer_iquxi","s":"calendar-range__s_iquxi","m":"calendar-range__m_iquxi","l":"calendar-range__l_iquxi","xl":"calendar-range__xl_iquxi"};
|
|
5
5
|
require('./index.css')
|
|
6
6
|
|
|
7
7
|
var Divider = function (_a) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: 1i8ir */
|
|
2
2
|
:root {
|
|
3
3
|
} /* deprecated */ :root {
|
|
4
4
|
--color-light-graphic-primary: #0e0e0e; /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
@@ -41,29 +41,29 @@
|
|
|
41
41
|
/* disabled */
|
|
42
42
|
|
|
43
43
|
/* marker */
|
|
44
|
-
} .calendar-
|
|
44
|
+
} .calendar-range__component_iquxi {
|
|
45
45
|
display: flex;
|
|
46
46
|
align-items: center;
|
|
47
47
|
justify-content: center;
|
|
48
48
|
width: 16px;
|
|
49
49
|
margin: 0 var(--gap-xs)
|
|
50
|
-
} .calendar-
|
|
50
|
+
} .calendar-range__component_iquxi:after {
|
|
51
51
|
content: '';
|
|
52
52
|
display: block;
|
|
53
53
|
width: 100%;
|
|
54
54
|
height: 1px;
|
|
55
55
|
background-color: var(--color-light-graphic-primary);
|
|
56
|
-
} .calendar-
|
|
56
|
+
} .calendar-range__outer_iquxi {
|
|
57
57
|
position: relative;
|
|
58
58
|
|
|
59
59
|
/* FormControl .above height + margin-bottom */
|
|
60
60
|
top: 24px;
|
|
61
|
-
} .calendar-
|
|
61
|
+
} .calendar-range__s_iquxi {
|
|
62
62
|
height: var(--size-s-height);
|
|
63
|
-
} .calendar-
|
|
63
|
+
} .calendar-range__m_iquxi {
|
|
64
64
|
height: var(--size-m-height);
|
|
65
|
-
} .calendar-
|
|
65
|
+
} .calendar-range__l_iquxi {
|
|
66
66
|
height: var(--size-l-height);
|
|
67
|
-
} .calendar-
|
|
67
|
+
} .calendar-range__xl_iquxi {
|
|
68
68
|
height: var(--size-xl-height);
|
|
69
69
|
}
|
package/esm/index.js
CHANGED
|
@@ -14,7 +14,7 @@ import 'date-fns/isEqual';
|
|
|
14
14
|
import 'date-fns/max';
|
|
15
15
|
import 'date-fns/min';
|
|
16
16
|
import 'date-fns/subMonths';
|
|
17
|
-
import './index.module-
|
|
17
|
+
import './index.module-69c70a25.js';
|
|
18
18
|
import './views/static.js';
|
|
19
19
|
import 'date-fns/endOfMonth';
|
|
20
20
|
import 'date-fns/isSameMonth';
|
package/esm/views/index.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: 11nyt */
|
|
2
2
|
:root {
|
|
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 */
|
|
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 */
|
|
@@ -36,14 +36,14 @@
|
|
|
36
36
|
/* disabled */
|
|
37
37
|
|
|
38
38
|
/* marker */
|
|
39
|
-
} .calendar-
|
|
39
|
+
} .calendar-range__component_ef2px {
|
|
40
40
|
display: flex
|
|
41
|
-
} .calendar-
|
|
41
|
+
} .calendar-range__component_ef2px button[aria-selected='true'] {
|
|
42
42
|
cursor: pointer;
|
|
43
|
-
} .calendar-
|
|
43
|
+
} .calendar-range__component_ef2px *[class*='errorIcon_'] {
|
|
44
44
|
display: none;
|
|
45
|
-
} .calendar-
|
|
45
|
+
} .calendar-range__component_ef2px *[class*='calendarIcon_'] {
|
|
46
46
|
margin-right: 0;
|
|
47
|
-
} .calendar-
|
|
47
|
+
} .calendar-range__static_ef2px .calendar-range__calendar_ef2px {
|
|
48
48
|
width: var(--calendar-inner-width);
|
|
49
49
|
}
|
package/esm/views/popover.js
CHANGED
|
@@ -7,7 +7,7 @@ import { isCompleteDateInput } from '@alfalab/core-components-date-input/esm';
|
|
|
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-69c70a25.js';
|
|
11
11
|
import 'date-fns/addMonths';
|
|
12
12
|
import 'date-fns/isEqual';
|
|
13
13
|
import 'date-fns/max';
|
|
@@ -15,33 +15,33 @@ import 'date-fns/min';
|
|
|
15
15
|
import 'date-fns/subMonths';
|
|
16
16
|
|
|
17
17
|
var CalendarRangePopover = function (_a) {
|
|
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, onError = _a.onError, _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
|
|
20
|
-
var
|
|
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, onError = _a.onError, _h = _a.inputFromProps, inputFromProps = _h === void 0 ? {} : _h, _j = _a.inputToProps, inputToProps = _j === void 0 ? {} : _j, offDays = _a.offDays, events = _a.events, _k = _a.returnInvalidDates, returnInvalidDates = _k === void 0 ? false : _k, dataTestId = _a.dataTestId;
|
|
19
|
+
var _l = useState(valueFrom), inputFromValue = _l[0], setInputFromValue = _l[1];
|
|
20
|
+
var _m = useState(valueTo), inputToValue = _m[0], setInputToValue = _m[1];
|
|
21
21
|
/**
|
|
22
22
|
* Ключ для сброса календарей
|
|
23
23
|
* Пользователь открыл календарь, изменил месяц, но ничего не выбрал
|
|
24
24
|
* — при следующем открытии в календаре будет установлен начальный месяц
|
|
25
25
|
*/
|
|
26
|
-
var
|
|
26
|
+
var _o = useState(0), resetKey = _o[0], setResetKey = _o[1];
|
|
27
27
|
var dateFrom = isValidInputValue(inputFromValue, minDate, maxDate, offDays)
|
|
28
28
|
? parseDateString(inputFromValue).getTime()
|
|
29
29
|
: null;
|
|
30
30
|
var dateTo = isValidInputValue(inputToValue, dateFrom || minDate, maxDate, offDays)
|
|
31
31
|
? parseDateString(inputToValue).getTime()
|
|
32
32
|
: null;
|
|
33
|
-
var
|
|
34
|
-
var
|
|
33
|
+
var _p = useState(isCompleteDateInput(inputFromValue) && dateFrom === null), inputFromInvalid = _p[0], setInputFromInvalid = _p[1];
|
|
34
|
+
var _q = useState(isCompleteDateInput(inputToValue) && dateTo === null), inputToInvalid = _q[0], setInputToInvalid = _q[1];
|
|
35
35
|
var bothInvalid = isCompleteDateInput(inputFromValue) &&
|
|
36
36
|
isCompleteDateInput(inputToValue) &&
|
|
37
37
|
parseDateString(inputFromValue).getTime() > parseDateString(inputToValue).getTime();
|
|
38
38
|
var hasValidateError = inputFromInvalid || inputToInvalid || bothInvalid;
|
|
39
|
-
var
|
|
39
|
+
var _r = usePopoverViewMonthes({
|
|
40
40
|
dateFrom: dateFrom,
|
|
41
41
|
dateTo: dateTo,
|
|
42
42
|
defaultMonth: defaultMonth,
|
|
43
43
|
resetKey: resetKey,
|
|
44
|
-
}), monthFrom =
|
|
44
|
+
}), monthFrom = _r.monthFrom, monthTo = _r.monthTo, handleMonthFromChange = _r.handleMonthFromChange, handleMonthToChange = _r.handleMonthToChange;
|
|
45
45
|
var handleValidInputFrom = useCallback(function () {
|
|
46
46
|
setInputFromInvalid(inputFromValue !== '' && !isValidInputValue(inputFromValue, minDate, maxDate, offDays));
|
|
47
47
|
}, [inputFromValue, maxDate, minDate, offDays]);
|
|
@@ -94,11 +94,17 @@ var CalendarRangePopover = function (_a) {
|
|
|
94
94
|
}, [inputFromValue]);
|
|
95
95
|
useDidUpdateEffect(function () {
|
|
96
96
|
onDateToChange({ value: inputToValue, date: dateTo });
|
|
97
|
+
// eslint-disable-next-line no-nested-ternary
|
|
98
|
+
var inputDateTo = returnInvalidDates
|
|
99
|
+
? isCompleteDateInput(inputToValue)
|
|
100
|
+
? parseDateString(inputToValue).getTime()
|
|
101
|
+
: null
|
|
102
|
+
: dateTo;
|
|
97
103
|
onChange({
|
|
98
104
|
valueFrom: inputFromValue,
|
|
99
105
|
valueTo: inputToValue,
|
|
100
106
|
dateFrom: dateFrom,
|
|
101
|
-
dateTo:
|
|
107
|
+
dateTo: inputDateTo,
|
|
102
108
|
});
|
|
103
109
|
if (!inputToValue || isCompleteDateInput(inputToValue)) {
|
|
104
110
|
handleValidInputTo();
|
package/esm/views/static.js
CHANGED
|
@@ -13,44 +13,44 @@ import { isCompleteDateInput, DateInput } from '@alfalab/core-components-date-in
|
|
|
13
13
|
import { Divider } from '../components/divider/Component.js';
|
|
14
14
|
import { useStaticViewMonthes, useSelectionProps } from '../hooks.js';
|
|
15
15
|
import { isDayButton } from '../utils.js';
|
|
16
|
-
import { s as styles } from '../index.module-
|
|
16
|
+
import { s as styles } from '../index.module-69c70a25.js';
|
|
17
17
|
import 'date-fns/isEqual';
|
|
18
18
|
import 'date-fns/min';
|
|
19
19
|
|
|
20
20
|
var CalendarRangeStatic = function (_a) {
|
|
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, dataTestId = _a.dataTestId;
|
|
22
|
-
var
|
|
23
|
-
var
|
|
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;
|
|
22
|
+
var _m = useState(valueFrom), inputFromValue = _m[0], setInputFromValue = _m[1];
|
|
23
|
+
var _o = useState(valueTo), inputToValue = _o[0], setInputToValue = _o[1];
|
|
24
24
|
var dateFrom = isValidInputValue(inputFromValue, minDate, maxDate, offDays)
|
|
25
25
|
? parseDateString(inputFromValue).getTime()
|
|
26
26
|
: null;
|
|
27
27
|
var dateTo = isValidInputValue(inputToValue, dateFrom || minDate, maxDate, offDays)
|
|
28
28
|
? parseDateString(inputToValue).getTime()
|
|
29
29
|
: null;
|
|
30
|
-
if (isCompleteDateInput(inputToValue) && !dateTo) {
|
|
30
|
+
if (isCompleteDateInput(inputToValue) && !dateTo && !returnInvalidDates) {
|
|
31
31
|
dateFrom = null;
|
|
32
32
|
}
|
|
33
33
|
var bothInvalid = isCompleteDateInput(inputFromValue) &&
|
|
34
34
|
isCompleteDateInput(inputToValue) &&
|
|
35
35
|
parseDateString(inputFromValue).getTime() > parseDateString(inputToValue).getTime();
|
|
36
|
-
var
|
|
36
|
+
var _p = useState(undefined), highlightedDate = _p[0], setHighlightedDate = _p[1];
|
|
37
37
|
var period = usePeriodWithReset({
|
|
38
38
|
initialSelectedFrom: dateFrom ? parseDateString(inputFromValue).getTime() : undefined,
|
|
39
39
|
initialSelectedTo: dateTo ? parseDateString(inputToValue).getTime() : undefined,
|
|
40
40
|
});
|
|
41
41
|
var validateInputFromValue = useCallback(function (value) { return isValidInputValue(value, minDate, dateFrom || maxDate, offDays); }, [dateFrom, maxDate, minDate, offDays]);
|
|
42
42
|
var validateInputToValue = useCallback(function (value) { return isValidInputValue(value, dateFrom || minDate, maxDate, offDays); }, [dateFrom, minDate, maxDate, offDays]);
|
|
43
|
-
var
|
|
44
|
-
var
|
|
43
|
+
var _q = useState(isCompleteDateInput(inputFromValue) && dateFrom === null), inputFromInvalid = _q[0], setInputFromInvalid = _q[1];
|
|
44
|
+
var _r = useState(isCompleteDateInput(inputToValue) && dateTo === null), inputToInvalid = _r[0], setInputToInvalid = _r[1];
|
|
45
45
|
var hasValidateError = bothInvalid || inputFromInvalid || inputToInvalid;
|
|
46
46
|
var calendarFromProps = inputFromProps.calendarProps, onInputChangeFrom = inputFromProps.onInputChange, dateInputFromProps = __rest(inputFromProps, ["calendarProps", "onInputChange"]);
|
|
47
47
|
var calendarToProps = inputToProps.calendarProps, onInputChangeTo = inputToProps.onInputChange, dateInputToProps = __rest(inputToProps, ["calendarProps", "onInputChange"]);
|
|
48
|
-
var
|
|
48
|
+
var _s = useStaticViewMonthes({
|
|
49
49
|
selectedFrom: period.selectedFrom,
|
|
50
50
|
selectedTo: period.selectedTo,
|
|
51
51
|
defaultMonth: defaultMonth,
|
|
52
52
|
defaultMonthPosition: defaultMonthPosition,
|
|
53
|
-
}), monthFrom =
|
|
53
|
+
}), monthFrom = _s.monthFrom, monthTo = _s.monthTo, handleMonthFromChange = _s.handleMonthFromChange, handleMonthToChange = _s.handleMonthToChange;
|
|
54
54
|
var handleValidInputFrom = useCallback(function () {
|
|
55
55
|
setInputFromInvalid(inputFromValue !== '' && !validateInputFromValue(inputFromValue));
|
|
56
56
|
}, [inputFromValue, validateInputFromValue]);
|
|
@@ -126,15 +126,21 @@ var CalendarRangeStatic = function (_a) {
|
|
|
126
126
|
period.setStart(dateFrom);
|
|
127
127
|
}
|
|
128
128
|
if (inputToValue !== valueTo) {
|
|
129
|
+
// eslint-disable-next-line no-nested-ternary
|
|
130
|
+
var inputDateTo = returnInvalidDates
|
|
131
|
+
? isCompleteDateInput(inputToValue)
|
|
132
|
+
? parseDateString(inputToValue).getTime()
|
|
133
|
+
: null
|
|
134
|
+
: dateTo;
|
|
129
135
|
onDateToChange({
|
|
130
136
|
value: inputToValue,
|
|
131
|
-
date:
|
|
137
|
+
date: inputDateTo,
|
|
132
138
|
});
|
|
133
139
|
onChange({
|
|
134
140
|
valueFrom: inputFromValue,
|
|
135
141
|
valueTo: inputToValue,
|
|
136
142
|
dateFrom: dateFrom,
|
|
137
|
-
dateTo:
|
|
143
|
+
dateTo: inputDateTo,
|
|
138
144
|
});
|
|
139
145
|
}
|
|
140
146
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
package/index.js
CHANGED
|
@@ -18,7 +18,7 @@ require('date-fns/isEqual');
|
|
|
18
18
|
require('date-fns/max');
|
|
19
19
|
require('date-fns/min');
|
|
20
20
|
require('date-fns/subMonths');
|
|
21
|
-
require('./index.module-
|
|
21
|
+
require('./index.module-9935cceb.js');
|
|
22
22
|
require('./views/static.js');
|
|
23
23
|
require('date-fns/endOfMonth');
|
|
24
24
|
require('date-fns/isSameMonth');
|
package/modern/Component.d.ts
CHANGED
|
@@ -81,6 +81,10 @@ type CalendarRangeProps = {
|
|
|
81
81
|
* Отображать начальный месяц слева или справа (влияет только на начальный рендер)
|
|
82
82
|
*/
|
|
83
83
|
defaultMonthPosition?: 'left' | 'right';
|
|
84
|
+
/**
|
|
85
|
+
* Возвращать невалидную дату для кастомной валидации
|
|
86
|
+
*/
|
|
87
|
+
returnInvalidDates?: boolean;
|
|
84
88
|
};
|
|
85
89
|
declare const CalendarRange: FC<CalendarRangeProps>;
|
|
86
90
|
export { CalendarRangeProps, CalendarRange };
|
package/modern/Component.js
CHANGED
|
@@ -13,7 +13,7 @@ import 'date-fns/isEqual';
|
|
|
13
13
|
import 'date-fns/max';
|
|
14
14
|
import 'date-fns/min';
|
|
15
15
|
import 'date-fns/subMonths';
|
|
16
|
-
import './index.module-
|
|
16
|
+
import './index.module-9c5da023.js';
|
|
17
17
|
import 'date-fns/endOfMonth';
|
|
18
18
|
import 'date-fns/isSameMonth';
|
|
19
19
|
import '@alfalab/core-components-calendar/modern';
|
|
@@ -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_iquxi","outer":"calendar-range__outer_iquxi","s":"calendar-range__s_iquxi","m":"calendar-range__m_iquxi","l":"calendar-range__l_iquxi","xl":"calendar-range__xl_iquxi"};
|
|
5
5
|
require('./index.css')
|
|
6
6
|
|
|
7
7
|
const Divider = ({ inputFromProps, inputToProps }) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: 1i8ir */
|
|
2
2
|
:root {
|
|
3
3
|
} /* deprecated */ :root {
|
|
4
4
|
--color-light-graphic-primary: #0e0e0e; /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
@@ -41,29 +41,29 @@
|
|
|
41
41
|
/* disabled */
|
|
42
42
|
|
|
43
43
|
/* marker */
|
|
44
|
-
} .calendar-
|
|
44
|
+
} .calendar-range__component_iquxi {
|
|
45
45
|
display: flex;
|
|
46
46
|
align-items: center;
|
|
47
47
|
justify-content: center;
|
|
48
48
|
width: 16px;
|
|
49
49
|
margin: 0 var(--gap-xs)
|
|
50
|
-
} .calendar-
|
|
50
|
+
} .calendar-range__component_iquxi:after {
|
|
51
51
|
content: '';
|
|
52
52
|
display: block;
|
|
53
53
|
width: 100%;
|
|
54
54
|
height: 1px;
|
|
55
55
|
background-color: var(--color-light-graphic-primary);
|
|
56
|
-
} .calendar-
|
|
56
|
+
} .calendar-range__outer_iquxi {
|
|
57
57
|
position: relative;
|
|
58
58
|
|
|
59
59
|
/* FormControl .above height + margin-bottom */
|
|
60
60
|
top: 24px;
|
|
61
|
-
} .calendar-
|
|
61
|
+
} .calendar-range__s_iquxi {
|
|
62
62
|
height: var(--size-s-height);
|
|
63
|
-
} .calendar-
|
|
63
|
+
} .calendar-range__m_iquxi {
|
|
64
64
|
height: var(--size-m-height);
|
|
65
|
-
} .calendar-
|
|
65
|
+
} .calendar-range__l_iquxi {
|
|
66
66
|
height: var(--size-l-height);
|
|
67
|
-
} .calendar-
|
|
67
|
+
} .calendar-range__xl_iquxi {
|
|
68
68
|
height: var(--size-xl-height);
|
|
69
69
|
}
|
package/modern/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import 'date-fns/isEqual';
|
|
|
13
13
|
import 'date-fns/max';
|
|
14
14
|
import 'date-fns/min';
|
|
15
15
|
import 'date-fns/subMonths';
|
|
16
|
-
import './index.module-
|
|
16
|
+
import './index.module-9c5da023.js';
|
|
17
17
|
import './views/static.js';
|
|
18
18
|
import 'date-fns/endOfMonth';
|
|
19
19
|
import 'date-fns/isSameMonth';
|
package/modern/views/index.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: 11nyt */
|
|
2
2
|
:root {
|
|
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 */
|
|
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 */
|
|
@@ -36,14 +36,14 @@
|
|
|
36
36
|
/* disabled */
|
|
37
37
|
|
|
38
38
|
/* marker */
|
|
39
|
-
} .calendar-
|
|
39
|
+
} .calendar-range__component_ef2px {
|
|
40
40
|
display: flex
|
|
41
|
-
} .calendar-
|
|
41
|
+
} .calendar-range__component_ef2px button[aria-selected='true'] {
|
|
42
42
|
cursor: pointer;
|
|
43
|
-
} .calendar-
|
|
43
|
+
} .calendar-range__component_ef2px *[class*='errorIcon_'] {
|
|
44
44
|
display: none;
|
|
45
|
-
} .calendar-
|
|
45
|
+
} .calendar-range__component_ef2px *[class*='calendarIcon_'] {
|
|
46
46
|
margin-right: 0;
|
|
47
|
-
} .calendar-
|
|
47
|
+
} .calendar-range__static_ef2px .calendar-range__calendar_ef2px {
|
|
48
48
|
width: var(--calendar-inner-width);
|
|
49
49
|
}
|
package/modern/views/popover.js
CHANGED
|
@@ -6,14 +6,14 @@ import { isCompleteDateInput } from '@alfalab/core-components-date-input/modern'
|
|
|
6
6
|
import { useDidUpdateEffect } from '@alfalab/hooks';
|
|
7
7
|
import { Divider } from '../components/divider/Component.js';
|
|
8
8
|
import { usePopoverViewMonthes } from '../hooks.js';
|
|
9
|
-
import { s as styles } from '../index.module-
|
|
9
|
+
import { s as styles } from '../index.module-9c5da023.js';
|
|
10
10
|
import 'date-fns/addMonths';
|
|
11
11
|
import 'date-fns/isEqual';
|
|
12
12
|
import 'date-fns/max';
|
|
13
13
|
import 'date-fns/min';
|
|
14
14
|
import 'date-fns/subMonths';
|
|
15
15
|
|
|
16
|
-
const CalendarRangePopover = ({ className, defaultMonth = startOfMonth(new Date()).getTime(), minDate, maxDate, valueFrom = '', valueTo = '', onDateFromChange = () => null, onDateToChange = () => null, onChange = () => null, onError, inputFromProps = {}, inputToProps = {}, offDays, events, dataTestId, }) => {
|
|
16
|
+
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, }) => {
|
|
17
17
|
const [inputFromValue, setInputFromValue] = useState(valueFrom);
|
|
18
18
|
const [inputToValue, setInputToValue] = useState(valueTo);
|
|
19
19
|
/**
|
|
@@ -90,11 +90,17 @@ const CalendarRangePopover = ({ className, defaultMonth = startOfMonth(new Date(
|
|
|
90
90
|
}, [inputFromValue]);
|
|
91
91
|
useDidUpdateEffect(() => {
|
|
92
92
|
onDateToChange({ value: inputToValue, date: dateTo });
|
|
93
|
+
// eslint-disable-next-line no-nested-ternary
|
|
94
|
+
const inputDateTo = returnInvalidDates
|
|
95
|
+
? isCompleteDateInput(inputToValue)
|
|
96
|
+
? parseDateString(inputToValue).getTime()
|
|
97
|
+
: null
|
|
98
|
+
: dateTo;
|
|
93
99
|
onChange({
|
|
94
100
|
valueFrom: inputFromValue,
|
|
95
101
|
valueTo: inputToValue,
|
|
96
102
|
dateFrom,
|
|
97
|
-
dateTo,
|
|
103
|
+
dateTo: inputDateTo,
|
|
98
104
|
});
|
|
99
105
|
if (!inputToValue || isCompleteDateInput(inputToValue)) {
|
|
100
106
|
handleValidInputTo();
|
package/modern/views/static.js
CHANGED
|
@@ -12,12 +12,12 @@ import { isCompleteDateInput, DateInput } from '@alfalab/core-components-date-in
|
|
|
12
12
|
import { Divider } from '../components/divider/Component.js';
|
|
13
13
|
import { useStaticViewMonthes, useSelectionProps } from '../hooks.js';
|
|
14
14
|
import { isDayButton } from '../utils.js';
|
|
15
|
-
import { s as styles } from '../index.module-
|
|
15
|
+
import { s as styles } from '../index.module-9c5da023.js';
|
|
16
16
|
import 'date-fns/isEqual';
|
|
17
17
|
import 'date-fns/min';
|
|
18
18
|
|
|
19
19
|
/* eslint-disable complexity */
|
|
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, 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, }) => {
|
|
21
21
|
const [inputFromValue, setInputFromValue] = useState(valueFrom);
|
|
22
22
|
const [inputToValue, setInputToValue] = useState(valueTo);
|
|
23
23
|
let dateFrom = isValidInputValue(inputFromValue, minDate, maxDate, offDays)
|
|
@@ -26,7 +26,7 @@ const CalendarRangeStatic = ({ className, defaultMonth = startOfMonth(new Date()
|
|
|
26
26
|
const dateTo = isValidInputValue(inputToValue, dateFrom || minDate, maxDate, offDays)
|
|
27
27
|
? parseDateString(inputToValue).getTime()
|
|
28
28
|
: null;
|
|
29
|
-
if (isCompleteDateInput(inputToValue) && !dateTo) {
|
|
29
|
+
if (isCompleteDateInput(inputToValue) && !dateTo && !returnInvalidDates) {
|
|
30
30
|
dateFrom = null;
|
|
31
31
|
}
|
|
32
32
|
const bothInvalid = isCompleteDateInput(inputFromValue) &&
|
|
@@ -125,15 +125,21 @@ const CalendarRangeStatic = ({ className, defaultMonth = startOfMonth(new Date()
|
|
|
125
125
|
period.setStart(dateFrom);
|
|
126
126
|
}
|
|
127
127
|
if (inputToValue !== valueTo) {
|
|
128
|
+
// eslint-disable-next-line no-nested-ternary
|
|
129
|
+
const inputDateTo = returnInvalidDates
|
|
130
|
+
? isCompleteDateInput(inputToValue)
|
|
131
|
+
? parseDateString(inputToValue).getTime()
|
|
132
|
+
: null
|
|
133
|
+
: dateTo;
|
|
128
134
|
onDateToChange({
|
|
129
135
|
value: inputToValue,
|
|
130
|
-
date:
|
|
136
|
+
date: inputDateTo,
|
|
131
137
|
});
|
|
132
138
|
onChange({
|
|
133
139
|
valueFrom: inputFromValue,
|
|
134
140
|
valueTo: inputToValue,
|
|
135
141
|
dateFrom,
|
|
136
|
-
dateTo,
|
|
142
|
+
dateTo: inputDateTo,
|
|
137
143
|
});
|
|
138
144
|
}
|
|
139
145
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
package/package.json
CHANGED
package/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/views/index.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: 11nyt */
|
|
2
2
|
:root {
|
|
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 */
|
|
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 */
|
|
@@ -36,14 +36,14 @@
|
|
|
36
36
|
/* disabled */
|
|
37
37
|
|
|
38
38
|
/* marker */
|
|
39
|
-
} .calendar-
|
|
39
|
+
} .calendar-range__component_ef2px {
|
|
40
40
|
display: flex
|
|
41
|
-
} .calendar-
|
|
41
|
+
} .calendar-range__component_ef2px button[aria-selected='true'] {
|
|
42
42
|
cursor: pointer;
|
|
43
|
-
} .calendar-
|
|
43
|
+
} .calendar-range__component_ef2px *[class*='errorIcon_'] {
|
|
44
44
|
display: none;
|
|
45
|
-
} .calendar-
|
|
45
|
+
} .calendar-range__component_ef2px *[class*='calendarIcon_'] {
|
|
46
46
|
margin-right: 0;
|
|
47
|
-
} .calendar-
|
|
47
|
+
} .calendar-range__static_ef2px .calendar-range__calendar_ef2px {
|
|
48
48
|
width: var(--calendar-inner-width);
|
|
49
49
|
}
|
package/views/popover.js
CHANGED
|
@@ -11,7 +11,7 @@ var coreComponentsDateInput = require('@alfalab/core-components-date-input');
|
|
|
11
11
|
var hooks$1 = require('@alfalab/hooks');
|
|
12
12
|
var components_divider_Component = require('../components/divider/Component.js');
|
|
13
13
|
var hooks = require('../hooks.js');
|
|
14
|
-
var index_module = require('../index.module-
|
|
14
|
+
var index_module = require('../index.module-9935cceb.js');
|
|
15
15
|
require('date-fns/addMonths');
|
|
16
16
|
require('date-fns/isEqual');
|
|
17
17
|
require('date-fns/max');
|
|
@@ -25,33 +25,33 @@ var cn__default = /*#__PURE__*/_interopDefaultCompat(cn);
|
|
|
25
25
|
var startOfMonth__default = /*#__PURE__*/_interopDefaultCompat(startOfMonth);
|
|
26
26
|
|
|
27
27
|
var CalendarRangePopover = function (_a) {
|
|
28
|
-
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, onError = _a.onError, _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;
|
|
29
|
-
var
|
|
30
|
-
var
|
|
28
|
+
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, onError = _a.onError, _h = _a.inputFromProps, inputFromProps = _h === void 0 ? {} : _h, _j = _a.inputToProps, inputToProps = _j === void 0 ? {} : _j, offDays = _a.offDays, events = _a.events, _k = _a.returnInvalidDates, returnInvalidDates = _k === void 0 ? false : _k, dataTestId = _a.dataTestId;
|
|
29
|
+
var _l = React.useState(valueFrom), inputFromValue = _l[0], setInputFromValue = _l[1];
|
|
30
|
+
var _m = React.useState(valueTo), inputToValue = _m[0], setInputToValue = _m[1];
|
|
31
31
|
/**
|
|
32
32
|
* Ключ для сброса календарей
|
|
33
33
|
* Пользователь открыл календарь, изменил месяц, но ничего не выбрал
|
|
34
34
|
* — при следующем открытии в календаре будет установлен начальный месяц
|
|
35
35
|
*/
|
|
36
|
-
var
|
|
36
|
+
var _o = React.useState(0), resetKey = _o[0], setResetKey = _o[1];
|
|
37
37
|
var dateFrom = coreComponentsCalendarInput.isValidInputValue(inputFromValue, minDate, maxDate, offDays)
|
|
38
38
|
? coreComponentsCalendarInput.parseDateString(inputFromValue).getTime()
|
|
39
39
|
: null;
|
|
40
40
|
var dateTo = coreComponentsCalendarInput.isValidInputValue(inputToValue, dateFrom || minDate, maxDate, offDays)
|
|
41
41
|
? coreComponentsCalendarInput.parseDateString(inputToValue).getTime()
|
|
42
42
|
: null;
|
|
43
|
-
var
|
|
44
|
-
var
|
|
43
|
+
var _p = React.useState(coreComponentsDateInput.isCompleteDateInput(inputFromValue) && dateFrom === null), inputFromInvalid = _p[0], setInputFromInvalid = _p[1];
|
|
44
|
+
var _q = React.useState(coreComponentsDateInput.isCompleteDateInput(inputToValue) && dateTo === null), inputToInvalid = _q[0], setInputToInvalid = _q[1];
|
|
45
45
|
var bothInvalid = coreComponentsDateInput.isCompleteDateInput(inputFromValue) &&
|
|
46
46
|
coreComponentsDateInput.isCompleteDateInput(inputToValue) &&
|
|
47
47
|
coreComponentsCalendarInput.parseDateString(inputFromValue).getTime() > coreComponentsCalendarInput.parseDateString(inputToValue).getTime();
|
|
48
48
|
var hasValidateError = inputFromInvalid || inputToInvalid || bothInvalid;
|
|
49
|
-
var
|
|
49
|
+
var _r = hooks.usePopoverViewMonthes({
|
|
50
50
|
dateFrom: dateFrom,
|
|
51
51
|
dateTo: dateTo,
|
|
52
52
|
defaultMonth: defaultMonth,
|
|
53
53
|
resetKey: resetKey,
|
|
54
|
-
}), monthFrom =
|
|
54
|
+
}), monthFrom = _r.monthFrom, monthTo = _r.monthTo, handleMonthFromChange = _r.handleMonthFromChange, handleMonthToChange = _r.handleMonthToChange;
|
|
55
55
|
var handleValidInputFrom = React.useCallback(function () {
|
|
56
56
|
setInputFromInvalid(inputFromValue !== '' && !coreComponentsCalendarInput.isValidInputValue(inputFromValue, minDate, maxDate, offDays));
|
|
57
57
|
}, [inputFromValue, maxDate, minDate, offDays]);
|
|
@@ -104,11 +104,17 @@ var CalendarRangePopover = function (_a) {
|
|
|
104
104
|
}, [inputFromValue]);
|
|
105
105
|
hooks$1.useDidUpdateEffect(function () {
|
|
106
106
|
onDateToChange({ value: inputToValue, date: dateTo });
|
|
107
|
+
// eslint-disable-next-line no-nested-ternary
|
|
108
|
+
var inputDateTo = returnInvalidDates
|
|
109
|
+
? coreComponentsDateInput.isCompleteDateInput(inputToValue)
|
|
110
|
+
? coreComponentsCalendarInput.parseDateString(inputToValue).getTime()
|
|
111
|
+
: null
|
|
112
|
+
: dateTo;
|
|
107
113
|
onChange({
|
|
108
114
|
valueFrom: inputFromValue,
|
|
109
115
|
valueTo: inputToValue,
|
|
110
116
|
dateFrom: dateFrom,
|
|
111
|
-
dateTo:
|
|
117
|
+
dateTo: inputDateTo,
|
|
112
118
|
});
|
|
113
119
|
if (!inputToValue || coreComponentsDateInput.isCompleteDateInput(inputToValue)) {
|
|
114
120
|
handleValidInputTo();
|
package/views/static.js
CHANGED
|
@@ -17,7 +17,7 @@ var coreComponentsDateInput = require('@alfalab/core-components-date-input');
|
|
|
17
17
|
var components_divider_Component = require('../components/divider/Component.js');
|
|
18
18
|
var hooks = require('../hooks.js');
|
|
19
19
|
var utils = require('../utils.js');
|
|
20
|
-
var index_module = require('../index.module-
|
|
20
|
+
var index_module = require('../index.module-9935cceb.js');
|
|
21
21
|
require('date-fns/isEqual');
|
|
22
22
|
require('date-fns/min');
|
|
23
23
|
|
|
@@ -33,39 +33,39 @@ var startOfMonth__default = /*#__PURE__*/_interopDefaultCompat(startOfMonth);
|
|
|
33
33
|
var subMonths__default = /*#__PURE__*/_interopDefaultCompat(subMonths);
|
|
34
34
|
|
|
35
35
|
var CalendarRangeStatic = function (_a) {
|
|
36
|
-
var className = _a.className, _b = _a.defaultMonth, defaultMonth = _b === void 0 ? startOfMonth__default.default(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, dataTestId = _a.dataTestId;
|
|
37
|
-
var
|
|
38
|
-
var
|
|
36
|
+
var className = _a.className, _b = _a.defaultMonth, defaultMonth = _b === void 0 ? startOfMonth__default.default(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;
|
|
37
|
+
var _m = React.useState(valueFrom), inputFromValue = _m[0], setInputFromValue = _m[1];
|
|
38
|
+
var _o = React.useState(valueTo), inputToValue = _o[0], setInputToValue = _o[1];
|
|
39
39
|
var dateFrom = coreComponentsCalendarInput.isValidInputValue(inputFromValue, minDate, maxDate, offDays)
|
|
40
40
|
? coreComponentsCalendarInput.parseDateString(inputFromValue).getTime()
|
|
41
41
|
: null;
|
|
42
42
|
var dateTo = coreComponentsCalendarInput.isValidInputValue(inputToValue, dateFrom || minDate, maxDate, offDays)
|
|
43
43
|
? coreComponentsCalendarInput.parseDateString(inputToValue).getTime()
|
|
44
44
|
: null;
|
|
45
|
-
if (coreComponentsDateInput.isCompleteDateInput(inputToValue) && !dateTo) {
|
|
45
|
+
if (coreComponentsDateInput.isCompleteDateInput(inputToValue) && !dateTo && !returnInvalidDates) {
|
|
46
46
|
dateFrom = null;
|
|
47
47
|
}
|
|
48
48
|
var bothInvalid = coreComponentsDateInput.isCompleteDateInput(inputFromValue) &&
|
|
49
49
|
coreComponentsDateInput.isCompleteDateInput(inputToValue) &&
|
|
50
50
|
coreComponentsCalendarInput.parseDateString(inputFromValue).getTime() > coreComponentsCalendarInput.parseDateString(inputToValue).getTime();
|
|
51
|
-
var
|
|
51
|
+
var _p = React.useState(undefined), highlightedDate = _p[0], setHighlightedDate = _p[1];
|
|
52
52
|
var period = coreComponentsCalendar.usePeriodWithReset({
|
|
53
53
|
initialSelectedFrom: dateFrom ? coreComponentsCalendarInput.parseDateString(inputFromValue).getTime() : undefined,
|
|
54
54
|
initialSelectedTo: dateTo ? coreComponentsCalendarInput.parseDateString(inputToValue).getTime() : undefined,
|
|
55
55
|
});
|
|
56
56
|
var validateInputFromValue = React.useCallback(function (value) { return coreComponentsCalendarInput.isValidInputValue(value, minDate, dateFrom || maxDate, offDays); }, [dateFrom, maxDate, minDate, offDays]);
|
|
57
57
|
var validateInputToValue = React.useCallback(function (value) { return coreComponentsCalendarInput.isValidInputValue(value, dateFrom || minDate, maxDate, offDays); }, [dateFrom, minDate, maxDate, offDays]);
|
|
58
|
-
var
|
|
59
|
-
var
|
|
58
|
+
var _q = React.useState(coreComponentsDateInput.isCompleteDateInput(inputFromValue) && dateFrom === null), inputFromInvalid = _q[0], setInputFromInvalid = _q[1];
|
|
59
|
+
var _r = React.useState(coreComponentsDateInput.isCompleteDateInput(inputToValue) && dateTo === null), inputToInvalid = _r[0], setInputToInvalid = _r[1];
|
|
60
60
|
var hasValidateError = bothInvalid || inputFromInvalid || inputToInvalid;
|
|
61
61
|
var calendarFromProps = inputFromProps.calendarProps, onInputChangeFrom = inputFromProps.onInputChange, dateInputFromProps = tslib.__rest(inputFromProps, ["calendarProps", "onInputChange"]);
|
|
62
62
|
var calendarToProps = inputToProps.calendarProps, onInputChangeTo = inputToProps.onInputChange, dateInputToProps = tslib.__rest(inputToProps, ["calendarProps", "onInputChange"]);
|
|
63
|
-
var
|
|
63
|
+
var _s = hooks.useStaticViewMonthes({
|
|
64
64
|
selectedFrom: period.selectedFrom,
|
|
65
65
|
selectedTo: period.selectedTo,
|
|
66
66
|
defaultMonth: defaultMonth,
|
|
67
67
|
defaultMonthPosition: defaultMonthPosition,
|
|
68
|
-
}), monthFrom =
|
|
68
|
+
}), monthFrom = _s.monthFrom, monthTo = _s.monthTo, handleMonthFromChange = _s.handleMonthFromChange, handleMonthToChange = _s.handleMonthToChange;
|
|
69
69
|
var handleValidInputFrom = React.useCallback(function () {
|
|
70
70
|
setInputFromInvalid(inputFromValue !== '' && !validateInputFromValue(inputFromValue));
|
|
71
71
|
}, [inputFromValue, validateInputFromValue]);
|
|
@@ -141,15 +141,21 @@ var CalendarRangeStatic = function (_a) {
|
|
|
141
141
|
period.setStart(dateFrom);
|
|
142
142
|
}
|
|
143
143
|
if (inputToValue !== valueTo) {
|
|
144
|
+
// eslint-disable-next-line no-nested-ternary
|
|
145
|
+
var inputDateTo = returnInvalidDates
|
|
146
|
+
? coreComponentsDateInput.isCompleteDateInput(inputToValue)
|
|
147
|
+
? coreComponentsCalendarInput.parseDateString(inputToValue).getTime()
|
|
148
|
+
: null
|
|
149
|
+
: dateTo;
|
|
144
150
|
onDateToChange({
|
|
145
151
|
value: inputToValue,
|
|
146
|
-
date:
|
|
152
|
+
date: inputDateTo,
|
|
147
153
|
});
|
|
148
154
|
onChange({
|
|
149
155
|
valueFrom: inputFromValue,
|
|
150
156
|
valueTo: inputToValue,
|
|
151
157
|
dateFrom: dateFrom,
|
|
152
|
-
dateTo:
|
|
158
|
+
dateTo: inputDateTo,
|
|
153
159
|
});
|
|
154
160
|
}
|
|
155
161
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
package/index.module-c07e0822.js
DELETED