@alfalab/core-components-calendar-range 7.1.6 → 7.2.1
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-5684a67d.d.ts +18 -0
- package/Component-63dec22f.d.ts +24 -0
- package/Component-e2b6c730.d.ts +23 -0
- package/Component.desktop-2e2b2125.d.ts +6 -0
- package/Component.desktop-e2b6c730.d.ts +134 -0
- package/Component.js +4 -2
- package/Component.responsive-2e2b2125.d.ts +68 -0
- package/components/divider/Component.js +1 -1
- package/components/divider/index.css +8 -8
- package/cssm/Component-5684a67d.d.ts +18 -0
- package/cssm/Component-63dec22f.d.ts +24 -0
- package/cssm/Component-e2b6c730.d.ts +23 -0
- package/cssm/Component.desktop-2e2b2125.d.ts +6 -0
- package/cssm/Component.desktop-e2b6c730.d.ts +134 -0
- package/cssm/Component.js +3 -1
- package/cssm/Component.responsive-2e2b2125.d.ts +68 -0
- package/cssm/desktop-63dec22f.d.ts +2 -0
- package/cssm/index-9211a437.d.ts +2 -0
- package/cssm/index-ebda875c.d.ts +2 -0
- package/cssm/index-f034f741.d.ts +2 -0
- package/cssm/index.js +3 -1
- package/cssm/shared-848397c5.d.ts +35 -0
- package/cssm/shared-c111a9fd.d.ts +13 -0
- package/cssm/typings-5684a67d.d.ts +23 -0
- package/cssm/typings-9211a437.d.ts +95 -0
- package/cssm/useCalendar-71d94e2b.d.ts +97 -0
- package/cssm/utils-e0a54580.d.ts +8 -0
- package/cssm/utils-e2b6c730.d.ts +88 -0
- package/cssm/views/popover.js +9 -8
- package/cssm/views/static.js +18 -17
- package/desktop-63dec22f.d.ts +2 -0
- package/esm/Component-5684a67d.d.ts +18 -0
- package/esm/Component-63dec22f.d.ts +24 -0
- package/esm/Component-e2b6c730.d.ts +23 -0
- package/esm/Component.desktop-2e2b2125.d.ts +6 -0
- package/esm/Component.desktop-e2b6c730.d.ts +134 -0
- package/esm/Component.js +4 -2
- package/esm/Component.responsive-2e2b2125.d.ts +68 -0
- package/esm/components/divider/Component.js +1 -1
- package/esm/components/divider/index.css +8 -8
- package/esm/desktop-63dec22f.d.ts +2 -0
- package/esm/index-9211a437.d.ts +2 -0
- package/esm/index-ebda875c.d.ts +2 -0
- package/esm/index-f034f741.d.ts +2 -0
- package/esm/index.js +4 -2
- package/esm/index.module-46b1abbe.js +4 -0
- package/esm/shared-848397c5.d.ts +35 -0
- package/esm/shared-c111a9fd.d.ts +13 -0
- package/esm/typings-5684a67d.d.ts +23 -0
- package/esm/typings-9211a437.d.ts +95 -0
- package/esm/useCalendar-71d94e2b.d.ts +97 -0
- package/esm/utils-e0a54580.d.ts +8 -0
- package/esm/utils-e2b6c730.d.ts +88 -0
- package/esm/views/index.css +7 -7
- package/esm/views/popover.js +3 -2
- package/esm/views/static.js +6 -5
- package/index-9211a437.d.ts +2 -0
- package/index-ebda875c.d.ts +2 -0
- package/index-f034f741.d.ts +2 -0
- package/index.js +4 -2
- package/index.module-2681dffc.js +6 -0
- package/modern/Component-5684a67d.d.ts +18 -0
- package/modern/Component-63dec22f.d.ts +24 -0
- package/modern/Component-e2b6c730.d.ts +23 -0
- package/modern/Component.desktop-2e2b2125.d.ts +6 -0
- package/modern/Component.desktop-e2b6c730.d.ts +134 -0
- package/modern/Component.js +4 -2
- package/modern/Component.responsive-2e2b2125.d.ts +68 -0
- package/modern/components/divider/Component.js +1 -1
- package/modern/components/divider/index.css +8 -8
- package/modern/desktop-63dec22f.d.ts +2 -0
- package/modern/index-9211a437.d.ts +2 -0
- package/modern/index-ebda875c.d.ts +2 -0
- package/modern/index-f034f741.d.ts +2 -0
- package/modern/index.js +4 -2
- package/modern/index.module-95129248.js +4 -0
- package/modern/shared-848397c5.d.ts +35 -0
- package/modern/shared-c111a9fd.d.ts +13 -0
- package/modern/typings-5684a67d.d.ts +23 -0
- package/modern/typings-9211a437.d.ts +95 -0
- package/modern/useCalendar-71d94e2b.d.ts +97 -0
- package/modern/utils-e0a54580.d.ts +8 -0
- package/modern/utils-e2b6c730.d.ts +88 -0
- package/modern/views/index.css +7 -7
- package/modern/views/popover.js +3 -2
- package/modern/views/static.js +6 -5
- package/package.json +4 -4
- package/shared-848397c5.d.ts +35 -0
- package/shared-c111a9fd.d.ts +13 -0
- package/src/Component.tsx +113 -0
- package/src/components/divider/Component.tsx +23 -0
- package/src/components/divider/index.module.css +41 -0
- package/src/components/divider/index.ts +1 -0
- package/src/hooks.ts +201 -0
- package/src/index.ts +1 -0
- package/src/utils.ts +2 -0
- package/src/views/index.module.css +28 -0
- package/src/views/popover.tsx +223 -0
- package/src/views/static.tsx +338 -0
- package/typings-5684a67d.d.ts +23 -0
- package/typings-9211a437.d.ts +95 -0
- package/useCalendar-71d94e2b.d.ts +97 -0
- package/utils-e0a54580.d.ts +8 -0
- package/utils-e2b6c730.d.ts +88 -0
- package/views/index.css +7 -7
- package/views/popover.js +10 -9
- package/views/static.js +19 -18
- package/esm/index.module-8ff2af7b.js +0 -4
- package/index.module-bda4cfcc.js +0 -6
- package/modern/index.module-0176534f.js +0 -4
package/views/popover.js
CHANGED
|
@@ -7,11 +7,12 @@ var React = require('react');
|
|
|
7
7
|
var cn = require('classnames');
|
|
8
8
|
var startOfMonth = require('date-fns/startOfMonth');
|
|
9
9
|
var coreComponentsCalendarInput = require('@alfalab/core-components-calendar-input');
|
|
10
|
+
var shared = require('@alfalab/core-components-calendar-input/shared');
|
|
10
11
|
var coreComponentsDateInput = require('@alfalab/core-components-date-input');
|
|
11
12
|
var hooks$1 = require('@alfalab/hooks');
|
|
12
13
|
var components_divider_Component = require('../components/divider/Component.js');
|
|
13
14
|
var hooks = require('../hooks.js');
|
|
14
|
-
var index_module = require('../index.module-
|
|
15
|
+
var index_module = require('../index.module-2681dffc.js');
|
|
15
16
|
require('date-fns/addMonths');
|
|
16
17
|
require('date-fns/isEqual');
|
|
17
18
|
require('date-fns/max');
|
|
@@ -34,17 +35,17 @@ var CalendarRangePopover = function (_a) {
|
|
|
34
35
|
* — при следующем открытии в календаре будет установлен начальный месяц
|
|
35
36
|
*/
|
|
36
37
|
var _o = React.useState(0), resetKey = _o[0], setResetKey = _o[1];
|
|
37
|
-
var dateFrom =
|
|
38
|
-
?
|
|
38
|
+
var dateFrom = shared.isValidInputValue(inputFromValue, minDate, maxDate, offDays)
|
|
39
|
+
? shared.parseDateString(inputFromValue).getTime()
|
|
39
40
|
: null;
|
|
40
|
-
var dateTo =
|
|
41
|
-
?
|
|
41
|
+
var dateTo = shared.isValidInputValue(inputToValue, dateFrom || minDate, maxDate, offDays)
|
|
42
|
+
? shared.parseDateString(inputToValue).getTime()
|
|
42
43
|
: null;
|
|
43
44
|
var _p = React.useState(coreComponentsDateInput.isCompleteDateInput(inputFromValue) && dateFrom === null), inputFromInvalid = _p[0], setInputFromInvalid = _p[1];
|
|
44
45
|
var _q = React.useState(coreComponentsDateInput.isCompleteDateInput(inputToValue) && dateTo === null), inputToInvalid = _q[0], setInputToInvalid = _q[1];
|
|
45
46
|
var bothInvalid = coreComponentsDateInput.isCompleteDateInput(inputFromValue) &&
|
|
46
47
|
coreComponentsDateInput.isCompleteDateInput(inputToValue) &&
|
|
47
|
-
|
|
48
|
+
shared.parseDateString(inputFromValue).getTime() > shared.parseDateString(inputToValue).getTime();
|
|
48
49
|
var hasValidateError = inputFromInvalid || inputToInvalid || bothInvalid;
|
|
49
50
|
var _r = hooks.usePopoverViewMonthes({
|
|
50
51
|
dateFrom: dateFrom,
|
|
@@ -53,11 +54,11 @@ var CalendarRangePopover = function (_a) {
|
|
|
53
54
|
resetKey: resetKey,
|
|
54
55
|
}), monthFrom = _r.monthFrom, monthTo = _r.monthTo, handleMonthFromChange = _r.handleMonthFromChange, handleMonthToChange = _r.handleMonthToChange;
|
|
55
56
|
var handleValidInputFrom = React.useCallback(function () {
|
|
56
|
-
setInputFromInvalid(inputFromValue !== '' && !
|
|
57
|
+
setInputFromInvalid(inputFromValue !== '' && !shared.isValidInputValue(inputFromValue, minDate, maxDate, offDays));
|
|
57
58
|
}, [inputFromValue, maxDate, minDate, offDays]);
|
|
58
59
|
var handleValidInputTo = React.useCallback(function () {
|
|
59
60
|
setInputToInvalid(inputToValue !== '' &&
|
|
60
|
-
!
|
|
61
|
+
!shared.isValidInputValue(inputToValue, dateFrom || minDate, maxDate, offDays));
|
|
61
62
|
}, [dateFrom, inputToValue, maxDate, minDate, offDays]);
|
|
62
63
|
var handleInputFromChange = function (event, payload) {
|
|
63
64
|
var _a;
|
|
@@ -107,7 +108,7 @@ var CalendarRangePopover = function (_a) {
|
|
|
107
108
|
// eslint-disable-next-line no-nested-ternary
|
|
108
109
|
var inputDateTo = returnInvalidDates
|
|
109
110
|
? coreComponentsDateInput.isCompleteDateInput(inputToValue)
|
|
110
|
-
?
|
|
111
|
+
? shared.parseDateString(inputToValue).getTime()
|
|
111
112
|
: null
|
|
112
113
|
: dateTo;
|
|
113
114
|
onChange({
|
package/views/static.js
CHANGED
|
@@ -11,13 +11,14 @@ var isSameMonth = require('date-fns/isSameMonth');
|
|
|
11
11
|
var max = require('date-fns/max');
|
|
12
12
|
var startOfMonth = require('date-fns/startOfMonth');
|
|
13
13
|
var subMonths = require('date-fns/subMonths');
|
|
14
|
-
var
|
|
15
|
-
var
|
|
14
|
+
var desktop = require('@alfalab/core-components-calendar/desktop');
|
|
15
|
+
var shared$1 = require('@alfalab/core-components-calendar/shared');
|
|
16
|
+
var shared = require('@alfalab/core-components-calendar-input/shared');
|
|
16
17
|
var coreComponentsDateInput = require('@alfalab/core-components-date-input');
|
|
17
18
|
var components_divider_Component = require('../components/divider/Component.js');
|
|
18
19
|
var hooks = require('../hooks.js');
|
|
19
20
|
var utils = require('../utils.js');
|
|
20
|
-
var index_module = require('../index.module-
|
|
21
|
+
var index_module = require('../index.module-2681dffc.js');
|
|
21
22
|
require('date-fns/isEqual');
|
|
22
23
|
require('date-fns/min');
|
|
23
24
|
|
|
@@ -36,25 +37,25 @@ var CalendarRangeStatic = function (_a) {
|
|
|
36
37
|
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
38
|
var _m = React.useState(valueFrom), inputFromValue = _m[0], setInputFromValue = _m[1];
|
|
38
39
|
var _o = React.useState(valueTo), inputToValue = _o[0], setInputToValue = _o[1];
|
|
39
|
-
var dateFrom =
|
|
40
|
-
?
|
|
40
|
+
var dateFrom = shared.isValidInputValue(inputFromValue, minDate, maxDate, offDays)
|
|
41
|
+
? shared.parseDateString(inputFromValue).getTime()
|
|
41
42
|
: null;
|
|
42
|
-
var dateTo =
|
|
43
|
-
?
|
|
43
|
+
var dateTo = shared.isValidInputValue(inputToValue, dateFrom || minDate, maxDate, offDays)
|
|
44
|
+
? shared.parseDateString(inputToValue).getTime()
|
|
44
45
|
: null;
|
|
45
46
|
if (coreComponentsDateInput.isCompleteDateInput(inputToValue) && !dateTo && !returnInvalidDates) {
|
|
46
47
|
dateFrom = null;
|
|
47
48
|
}
|
|
48
49
|
var bothInvalid = coreComponentsDateInput.isCompleteDateInput(inputFromValue) &&
|
|
49
50
|
coreComponentsDateInput.isCompleteDateInput(inputToValue) &&
|
|
50
|
-
|
|
51
|
+
shared.parseDateString(inputFromValue).getTime() > shared.parseDateString(inputToValue).getTime();
|
|
51
52
|
var _p = React.useState(undefined), highlightedDate = _p[0], setHighlightedDate = _p[1];
|
|
52
|
-
var period =
|
|
53
|
-
initialSelectedFrom: dateFrom ?
|
|
54
|
-
initialSelectedTo: dateTo ?
|
|
53
|
+
var period = shared$1.usePeriodWithReset({
|
|
54
|
+
initialSelectedFrom: dateFrom ? shared.parseDateString(inputFromValue).getTime() : undefined,
|
|
55
|
+
initialSelectedTo: dateTo ? shared.parseDateString(inputToValue).getTime() : undefined,
|
|
55
56
|
});
|
|
56
|
-
var validateInputFromValue = React.useCallback(function (value) { return
|
|
57
|
-
var validateInputToValue = React.useCallback(function (value) { return
|
|
57
|
+
var validateInputFromValue = React.useCallback(function (value) { return shared.isValidInputValue(value, minDate, dateFrom || maxDate, offDays); }, [dateFrom, maxDate, minDate, offDays]);
|
|
58
|
+
var validateInputToValue = React.useCallback(function (value) { return shared.isValidInputValue(value, dateFrom || minDate, maxDate, offDays); }, [dateFrom, minDate, maxDate, offDays]);
|
|
58
59
|
var _q = React.useState(coreComponentsDateInput.isCompleteDateInput(inputFromValue) && dateFrom === null), inputFromInvalid = _q[0], setInputFromInvalid = _q[1];
|
|
59
60
|
var _r = React.useState(coreComponentsDateInput.isCompleteDateInput(inputToValue) && dateTo === null), inputToInvalid = _r[0], setInputToInvalid = _r[1];
|
|
60
61
|
var hasValidateError = bothInvalid || inputFromInvalid || inputToInvalid;
|
|
@@ -99,10 +100,10 @@ var CalendarRangeStatic = function (_a) {
|
|
|
99
100
|
setInputToValue('');
|
|
100
101
|
}, []);
|
|
101
102
|
React.useEffect(function () {
|
|
102
|
-
setInputFromValue(period.selectedFrom ?
|
|
103
|
+
setInputFromValue(period.selectedFrom ? shared.formatDate(period.selectedFrom) : '');
|
|
103
104
|
}, [period.selectedFrom]);
|
|
104
105
|
React.useEffect(function () {
|
|
105
|
-
setInputToValue(period.selectedTo ?
|
|
106
|
+
setInputToValue(period.selectedTo ? shared.formatDate(period.selectedTo) : '');
|
|
106
107
|
}, [period.selectedTo]);
|
|
107
108
|
React.useEffect(function () {
|
|
108
109
|
setInputFromValue(valueFrom);
|
|
@@ -144,7 +145,7 @@ var CalendarRangeStatic = function (_a) {
|
|
|
144
145
|
// eslint-disable-next-line no-nested-ternary
|
|
145
146
|
var inputDateTo = returnInvalidDates
|
|
146
147
|
? coreComponentsDateInput.isCompleteDateInput(inputToValue)
|
|
147
|
-
?
|
|
148
|
+
? shared.parseDateString(inputToValue).getTime()
|
|
148
149
|
: null
|
|
149
150
|
: dateTo;
|
|
150
151
|
onDateToChange({
|
|
@@ -167,8 +168,8 @@ var CalendarRangeStatic = function (_a) {
|
|
|
167
168
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
168
169
|
}, [hasValidateError]);
|
|
169
170
|
var rangeProps = hooks.useSelectionProps(period.selectedFrom, period.selectedTo, highlightedDate);
|
|
170
|
-
var CalendarFromComponent = dateInputFromProps.Calendar ||
|
|
171
|
-
var CalendarToComponent = dateInputToProps.Calendar ||
|
|
171
|
+
var CalendarFromComponent = dateInputFromProps.Calendar || desktop.CalendarDesktop;
|
|
172
|
+
var CalendarToComponent = dateInputToProps.Calendar || desktop.CalendarDesktop;
|
|
172
173
|
var minMaxInSameMonth = minDate && maxDate && isSameMonth__default.default(minDate, maxDate);
|
|
173
174
|
return (
|
|
174
175
|
// eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
|
package/index.module-bda4cfcc.js
DELETED