@alfalab/core-components-calendar-range 4.0.1 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -0
- package/dist/Component.js +3 -3
- package/dist/cssm/Component.js +2 -2
- package/dist/cssm/useCalendarMonthes.js +12 -4
- package/dist/esm/Component.js +3 -3
- package/dist/esm/index.css +5 -5
- package/dist/esm/useCalendarMonthes.js +12 -4
- package/dist/index.css +5 -5
- package/dist/modern/Component.js +3 -3
- package/dist/modern/index.css +5 -5
- package/dist/modern/useCalendarMonthes.js +12 -4
- package/dist/useCalendarMonthes.js +12 -4
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,44 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [4.1.0](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-calendar-range@4.0.4...@alfalab/core-components-calendar-range@4.1.0) (2021-12-08)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **calendar:** мобильные стили ([#867](https://github.com/alfa-laboratory/core-components/issues/867)) ([febf545](https://github.com/alfa-laboratory/core-components/commit/febf54551f8179a1ba03fe65ed47aa3b20b01472))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [4.0.4](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-calendar-range@4.0.3...@alfalab/core-components-calendar-range@4.0.4) (2021-12-01)
|
|
18
|
+
|
|
19
|
+
**Note:** Version bump only for package @alfalab/core-components-calendar-range
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## [4.0.3](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-calendar-range@4.0.2...@alfalab/core-components-calendar-range@4.0.3) (2021-11-26)
|
|
26
|
+
|
|
27
|
+
**Note:** Version bump only for package @alfalab/core-components-calendar-range
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## [4.0.2](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-calendar-range@4.0.1...@alfalab/core-components-calendar-range@4.0.2) (2021-11-22)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### Bug Fixes
|
|
37
|
+
|
|
38
|
+
* **calendar-range:** fix default month to ([#868](https://github.com/alfa-laboratory/core-components/issues/868)) ([1f9fb97](https://github.com/alfa-laboratory/core-components/commit/1f9fb9709292d28300c3fc4386ffd858b2efd852))
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
6
44
|
## [4.0.1](https://github.com/alfa-laboratory/core-components/compare/@alfalab/core-components-calendar-range@4.0.0...@alfalab/core-components-calendar-range@4.0.1) (2021-11-16)
|
|
7
45
|
|
|
8
46
|
**Note:** Version bump only for package @alfalab/core-components-calendar-range
|
package/dist/Component.js
CHANGED
|
@@ -43,7 +43,7 @@ var __assign = function () {
|
|
|
43
43
|
return __assign.apply(this, arguments);
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
-
var styles = {"component":"calendar-
|
|
46
|
+
var styles = {"component":"calendar-range__component_1lna6","divider":"calendar-range__divider_1lna6"};
|
|
47
47
|
require('./index.css')
|
|
48
48
|
|
|
49
49
|
var CalendarRange = function (_a) {
|
|
@@ -187,11 +187,11 @@ var CalendarRange = function (_a) {
|
|
|
187
187
|
minDate: minDate,
|
|
188
188
|
});
|
|
189
189
|
return (React__default['default'].createElement("div", { className: cn__default['default'](styles.component, className), "data-test-id": dataTestId },
|
|
190
|
-
React__default['default'].createElement(coreComponentsCalendarInput.CalendarInput, __assign({}, inputFromProps, { calendarPosition: calendarPosition, onInputChange: handleInputFromChange, onCalendarChange: handleFromCalendarChange, value: inputValueFrom.value, minDate: maxMinDates.fromMinDate, maxDate: maxMinDates.fromMaxDate, calendarProps: __assign(__assign({}, inputFromProps.calendarProps), { month: monthFrom, onMonthChange: handleMonthFromChange, selectorView: selectorView,
|
|
190
|
+
React__default['default'].createElement(coreComponentsCalendarInput.CalendarInput, __assign({}, inputFromProps, { useAnchorWidth: false, calendarPosition: calendarPosition, onInputChange: handleInputFromChange, onCalendarChange: handleFromCalendarChange, value: inputValueFrom.value, minDate: maxMinDates.fromMinDate, maxDate: maxMinDates.fromMaxDate, calendarProps: __assign(__assign({}, inputFromProps.calendarProps), { month: monthFrom, onMonthChange: handleMonthFromChange, selectorView: selectorView,
|
|
191
191
|
selectedFrom: selectedFrom, selectedTo: calendarSelectedTo }) })),
|
|
192
192
|
React__default['default'].createElement("span", { className: styles.divider }),
|
|
193
193
|
React__default['default'].createElement("div", { onMouseOver: handleCalendarToMouseOver },
|
|
194
|
-
React__default['default'].createElement(coreComponentsCalendarInput.CalendarInput, __assign({}, inputToProps, { calendarPosition: calendarPosition, popoverPosition: 'bottom-end', onInputChange: handleInputToChange, onCalendarChange: handleToCalendarChange, value: inputValueTo.value, minDate: maxMinDates.toMinDate, maxDate: maxMinDates.toMaxDate, calendarProps: __assign(__assign({}, inputToProps.calendarProps), { month: monthTo, onMonthChange: handleMonthToChange, selectorView: selectorView,
|
|
194
|
+
React__default['default'].createElement(coreComponentsCalendarInput.CalendarInput, __assign({}, inputToProps, { useAnchorWidth: false, calendarPosition: calendarPosition, popoverPosition: 'bottom-end', onInputChange: handleInputToChange, onCalendarChange: handleToCalendarChange, value: inputValueTo.value, minDate: maxMinDates.toMinDate, maxDate: maxMinDates.toMaxDate, calendarProps: __assign(__assign({}, inputToProps.calendarProps), { month: monthTo, onMonthChange: handleMonthToChange, selectorView: selectorView,
|
|
195
195
|
selectedFrom: selectedFrom,
|
|
196
196
|
selectedTo: selectedTo }) })))));
|
|
197
197
|
};
|
package/dist/cssm/Component.js
CHANGED
|
@@ -186,11 +186,11 @@ var CalendarRange = function (_a) {
|
|
|
186
186
|
minDate: minDate,
|
|
187
187
|
});
|
|
188
188
|
return (React__default['default'].createElement("div", { className: cn__default['default'](styles__default['default'].component, className), "data-test-id": dataTestId },
|
|
189
|
-
React__default['default'].createElement(coreComponentsCalendarInput.CalendarInput, __assign({}, inputFromProps, { calendarPosition: calendarPosition, onInputChange: handleInputFromChange, onCalendarChange: handleFromCalendarChange, value: inputValueFrom.value, minDate: maxMinDates.fromMinDate, maxDate: maxMinDates.fromMaxDate, calendarProps: __assign(__assign({}, inputFromProps.calendarProps), { month: monthFrom, onMonthChange: handleMonthFromChange, selectorView: selectorView,
|
|
189
|
+
React__default['default'].createElement(coreComponentsCalendarInput.CalendarInput, __assign({}, inputFromProps, { useAnchorWidth: false, calendarPosition: calendarPosition, onInputChange: handleInputFromChange, onCalendarChange: handleFromCalendarChange, value: inputValueFrom.value, minDate: maxMinDates.fromMinDate, maxDate: maxMinDates.fromMaxDate, calendarProps: __assign(__assign({}, inputFromProps.calendarProps), { month: monthFrom, onMonthChange: handleMonthFromChange, selectorView: selectorView,
|
|
190
190
|
selectedFrom: selectedFrom, selectedTo: calendarSelectedTo }) })),
|
|
191
191
|
React__default['default'].createElement("span", { className: styles__default['default'].divider }),
|
|
192
192
|
React__default['default'].createElement("div", { onMouseOver: handleCalendarToMouseOver },
|
|
193
|
-
React__default['default'].createElement(coreComponentsCalendarInput.CalendarInput, __assign({}, inputToProps, { calendarPosition: calendarPosition, popoverPosition: 'bottom-end', onInputChange: handleInputToChange, onCalendarChange: handleToCalendarChange, value: inputValueTo.value, minDate: maxMinDates.toMinDate, maxDate: maxMinDates.toMaxDate, calendarProps: __assign(__assign({}, inputToProps.calendarProps), { month: monthTo, onMonthChange: handleMonthToChange, selectorView: selectorView,
|
|
193
|
+
React__default['default'].createElement(coreComponentsCalendarInput.CalendarInput, __assign({}, inputToProps, { useAnchorWidth: false, calendarPosition: calendarPosition, popoverPosition: 'bottom-end', onInputChange: handleInputToChange, onCalendarChange: handleToCalendarChange, value: inputValueTo.value, minDate: maxMinDates.toMinDate, maxDate: maxMinDates.toMaxDate, calendarProps: __assign(__assign({}, inputToProps.calendarProps), { month: monthTo, onMonthChange: handleMonthToChange, selectorView: selectorView,
|
|
194
194
|
selectedFrom: selectedFrom,
|
|
195
195
|
selectedTo: selectedTo }) })))));
|
|
196
196
|
};
|
|
@@ -7,10 +7,18 @@ var dateFns = require('date-fns');
|
|
|
7
7
|
|
|
8
8
|
function useCalendarMonthes(_a) {
|
|
9
9
|
var inputValueFrom = _a.inputValueFrom, inputValueTo = _a.inputValueTo, defaultMonth = _a.defaultMonth, isPopover = _a.isPopover;
|
|
10
|
-
var initialMonthFrom =
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
var initialMonthFrom = (function () {
|
|
11
|
+
if (inputValueFrom.value && inputValueFrom.date) {
|
|
12
|
+
return dateFns.startOfMonth(inputValueFrom.date).getTime();
|
|
13
|
+
}
|
|
14
|
+
return defaultMonth;
|
|
15
|
+
})();
|
|
16
|
+
var initialMonthTo = (function () {
|
|
17
|
+
if (inputValueTo.value && inputValueTo.date) {
|
|
18
|
+
return dateFns.startOfMonth(inputValueTo.date).getTime();
|
|
19
|
+
}
|
|
20
|
+
return isPopover ? initialMonthFrom : dateFns.addMonths(initialMonthFrom, 1).getTime();
|
|
21
|
+
})();
|
|
14
22
|
var _b = React.useState(initialMonthFrom), monthFrom = _b[0], setMonthFrom = _b[1];
|
|
15
23
|
var _c = React.useState(initialMonthTo), monthTo = _c[0], setMonthTo = _c[1];
|
|
16
24
|
var handleMonthFromChange = React.useCallback(function (newMonthFrom) {
|
package/dist/esm/Component.js
CHANGED
|
@@ -34,7 +34,7 @@ var __assign = function () {
|
|
|
34
34
|
return __assign.apply(this, arguments);
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
var styles = {"component":"calendar-
|
|
37
|
+
var styles = {"component":"calendar-range__component_1lna6","divider":"calendar-range__divider_1lna6"};
|
|
38
38
|
require('./index.css')
|
|
39
39
|
|
|
40
40
|
var CalendarRange = function (_a) {
|
|
@@ -178,11 +178,11 @@ var CalendarRange = function (_a) {
|
|
|
178
178
|
minDate: minDate,
|
|
179
179
|
});
|
|
180
180
|
return (React.createElement("div", { className: cn(styles.component, className), "data-test-id": dataTestId },
|
|
181
|
-
React.createElement(CalendarInput, __assign({}, inputFromProps, { calendarPosition: calendarPosition, onInputChange: handleInputFromChange, onCalendarChange: handleFromCalendarChange, value: inputValueFrom.value, minDate: maxMinDates.fromMinDate, maxDate: maxMinDates.fromMaxDate, calendarProps: __assign(__assign({}, inputFromProps.calendarProps), { month: monthFrom, onMonthChange: handleMonthFromChange, selectorView: selectorView,
|
|
181
|
+
React.createElement(CalendarInput, __assign({}, inputFromProps, { useAnchorWidth: false, calendarPosition: calendarPosition, onInputChange: handleInputFromChange, onCalendarChange: handleFromCalendarChange, value: inputValueFrom.value, minDate: maxMinDates.fromMinDate, maxDate: maxMinDates.fromMaxDate, calendarProps: __assign(__assign({}, inputFromProps.calendarProps), { month: monthFrom, onMonthChange: handleMonthFromChange, selectorView: selectorView,
|
|
182
182
|
selectedFrom: selectedFrom, selectedTo: calendarSelectedTo }) })),
|
|
183
183
|
React.createElement("span", { className: styles.divider }),
|
|
184
184
|
React.createElement("div", { onMouseOver: handleCalendarToMouseOver },
|
|
185
|
-
React.createElement(CalendarInput, __assign({}, inputToProps, { calendarPosition: calendarPosition, popoverPosition: 'bottom-end', onInputChange: handleInputToChange, onCalendarChange: handleToCalendarChange, value: inputValueTo.value, minDate: maxMinDates.toMinDate, maxDate: maxMinDates.toMaxDate, calendarProps: __assign(__assign({}, inputToProps.calendarProps), { month: monthTo, onMonthChange: handleMonthToChange, selectorView: selectorView,
|
|
185
|
+
React.createElement(CalendarInput, __assign({}, inputToProps, { useAnchorWidth: false, calendarPosition: calendarPosition, popoverPosition: 'bottom-end', onInputChange: handleInputToChange, onCalendarChange: handleToCalendarChange, value: inputValueTo.value, minDate: maxMinDates.toMinDate, maxDate: maxMinDates.toMaxDate, calendarProps: __assign(__assign({}, inputToProps.calendarProps), { month: monthTo, onMonthChange: handleMonthToChange, selectorView: selectorView,
|
|
186
186
|
selectedFrom: selectedFrom,
|
|
187
187
|
selectedTo: selectedTo }) })))));
|
|
188
188
|
};
|
package/dist/esm/index.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: n3311 */
|
|
2
2
|
:root {
|
|
3
3
|
--color-light-graphic-primary: #0b1f35;
|
|
4
4
|
}
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
:root {
|
|
14
14
|
--gap-xs: 8px;
|
|
15
15
|
}
|
|
16
|
-
.calendar-
|
|
16
|
+
.calendar-range__component_1lna6 {
|
|
17
17
|
display: flex
|
|
18
18
|
}
|
|
19
|
-
.calendar-
|
|
19
|
+
.calendar-range__component_1lna6 button[aria-selected='true'] {
|
|
20
20
|
cursor: pointer;
|
|
21
21
|
}
|
|
22
|
-
.calendar-
|
|
22
|
+
.calendar-range__divider_1lna6 {
|
|
23
23
|
height: 48px;
|
|
24
24
|
display: flex;
|
|
25
25
|
align-items: center;
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
width: 16px;
|
|
28
28
|
margin: 0 var(--gap-xs)
|
|
29
29
|
}
|
|
30
|
-
.calendar-
|
|
30
|
+
.calendar-range__divider_1lna6:after {
|
|
31
31
|
content: '';
|
|
32
32
|
display: block;
|
|
33
33
|
width: 100%;
|
|
@@ -3,10 +3,18 @@ import { startOfMonth, addMonths, subMonths } from 'date-fns';
|
|
|
3
3
|
|
|
4
4
|
function useCalendarMonthes(_a) {
|
|
5
5
|
var inputValueFrom = _a.inputValueFrom, inputValueTo = _a.inputValueTo, defaultMonth = _a.defaultMonth, isPopover = _a.isPopover;
|
|
6
|
-
var initialMonthFrom =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
var initialMonthFrom = (function () {
|
|
7
|
+
if (inputValueFrom.value && inputValueFrom.date) {
|
|
8
|
+
return startOfMonth(inputValueFrom.date).getTime();
|
|
9
|
+
}
|
|
10
|
+
return defaultMonth;
|
|
11
|
+
})();
|
|
12
|
+
var initialMonthTo = (function () {
|
|
13
|
+
if (inputValueTo.value && inputValueTo.date) {
|
|
14
|
+
return startOfMonth(inputValueTo.date).getTime();
|
|
15
|
+
}
|
|
16
|
+
return isPopover ? initialMonthFrom : addMonths(initialMonthFrom, 1).getTime();
|
|
17
|
+
})();
|
|
10
18
|
var _b = useState(initialMonthFrom), monthFrom = _b[0], setMonthFrom = _b[1];
|
|
11
19
|
var _c = useState(initialMonthTo), monthTo = _c[0], setMonthTo = _c[1];
|
|
12
20
|
var handleMonthFromChange = useCallback(function (newMonthFrom) {
|
package/dist/index.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: n3311 */
|
|
2
2
|
:root {
|
|
3
3
|
--color-light-graphic-primary: #0b1f35;
|
|
4
4
|
}
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
:root {
|
|
14
14
|
--gap-xs: 8px;
|
|
15
15
|
}
|
|
16
|
-
.calendar-
|
|
16
|
+
.calendar-range__component_1lna6 {
|
|
17
17
|
display: flex
|
|
18
18
|
}
|
|
19
|
-
.calendar-
|
|
19
|
+
.calendar-range__component_1lna6 button[aria-selected='true'] {
|
|
20
20
|
cursor: pointer;
|
|
21
21
|
}
|
|
22
|
-
.calendar-
|
|
22
|
+
.calendar-range__divider_1lna6 {
|
|
23
23
|
height: 48px;
|
|
24
24
|
display: flex;
|
|
25
25
|
align-items: center;
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
width: 16px;
|
|
28
28
|
margin: 0 var(--gap-xs)
|
|
29
29
|
}
|
|
30
|
-
.calendar-
|
|
30
|
+
.calendar-range__divider_1lna6:after {
|
|
31
31
|
content: '';
|
|
32
32
|
display: block;
|
|
33
33
|
width: 100%;
|
package/dist/modern/Component.js
CHANGED
|
@@ -7,7 +7,7 @@ import { initialValueState, getCorrectValueState, isDayButton } from './utils.js
|
|
|
7
7
|
import { useCalendarMonthes } from './useCalendarMonthes.js';
|
|
8
8
|
import { useCalendarMaxMinDates } from './useCalendarMaxMinDates.js';
|
|
9
9
|
|
|
10
|
-
var styles = {"component":"calendar-
|
|
10
|
+
var styles = {"component":"calendar-range__component_1lna6","divider":"calendar-range__divider_1lna6"};
|
|
11
11
|
require('./index.css')
|
|
12
12
|
|
|
13
13
|
/* eslint-disable multiline-comment-style */
|
|
@@ -149,7 +149,7 @@ const CalendarRange = ({ className, defaultMonth = startOfMonth(new Date()).getT
|
|
|
149
149
|
minDate,
|
|
150
150
|
});
|
|
151
151
|
return (React.createElement("div", { className: cn(styles.component, className), "data-test-id": dataTestId },
|
|
152
|
-
React.createElement(CalendarInput, Object.assign({}, inputFromProps, { calendarPosition: calendarPosition, onInputChange: handleInputFromChange, onCalendarChange: handleFromCalendarChange, value: inputValueFrom.value, minDate: maxMinDates.fromMinDate, maxDate: maxMinDates.fromMaxDate, calendarProps: {
|
|
152
|
+
React.createElement(CalendarInput, Object.assign({}, inputFromProps, { useAnchorWidth: false, calendarPosition: calendarPosition, onInputChange: handleInputFromChange, onCalendarChange: handleFromCalendarChange, value: inputValueFrom.value, minDate: maxMinDates.fromMinDate, maxDate: maxMinDates.fromMaxDate, calendarProps: {
|
|
153
153
|
...inputFromProps.calendarProps,
|
|
154
154
|
month: monthFrom,
|
|
155
155
|
onMonthChange: handleMonthFromChange,
|
|
@@ -159,7 +159,7 @@ const CalendarRange = ({ className, defaultMonth = startOfMonth(new Date()).getT
|
|
|
159
159
|
} })),
|
|
160
160
|
React.createElement("span", { className: styles.divider }),
|
|
161
161
|
React.createElement("div", { onMouseOver: handleCalendarToMouseOver },
|
|
162
|
-
React.createElement(CalendarInput, Object.assign({}, inputToProps, { calendarPosition: calendarPosition, popoverPosition: 'bottom-end', onInputChange: handleInputToChange, onCalendarChange: handleToCalendarChange, value: inputValueTo.value, minDate: maxMinDates.toMinDate, maxDate: maxMinDates.toMaxDate, calendarProps: {
|
|
162
|
+
React.createElement(CalendarInput, Object.assign({}, inputToProps, { useAnchorWidth: false, calendarPosition: calendarPosition, popoverPosition: 'bottom-end', onInputChange: handleInputToChange, onCalendarChange: handleToCalendarChange, value: inputValueTo.value, minDate: maxMinDates.toMinDate, maxDate: maxMinDates.toMaxDate, calendarProps: {
|
|
163
163
|
...inputToProps.calendarProps,
|
|
164
164
|
month: monthTo,
|
|
165
165
|
onMonthChange: handleMonthToChange,
|
package/dist/modern/index.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: n3311 */
|
|
2
2
|
:root {
|
|
3
3
|
--color-light-graphic-primary: #0b1f35;
|
|
4
4
|
}
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
:root {
|
|
14
14
|
--gap-xs: 8px;
|
|
15
15
|
}
|
|
16
|
-
.calendar-
|
|
16
|
+
.calendar-range__component_1lna6 {
|
|
17
17
|
display: flex
|
|
18
18
|
}
|
|
19
|
-
.calendar-
|
|
19
|
+
.calendar-range__component_1lna6 button[aria-selected='true'] {
|
|
20
20
|
cursor: pointer;
|
|
21
21
|
}
|
|
22
|
-
.calendar-
|
|
22
|
+
.calendar-range__divider_1lna6 {
|
|
23
23
|
height: 48px;
|
|
24
24
|
display: flex;
|
|
25
25
|
align-items: center;
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
width: 16px;
|
|
28
28
|
margin: 0 var(--gap-xs)
|
|
29
29
|
}
|
|
30
|
-
.calendar-
|
|
30
|
+
.calendar-range__divider_1lna6:after {
|
|
31
31
|
content: '';
|
|
32
32
|
display: block;
|
|
33
33
|
width: 100%;
|
|
@@ -2,10 +2,18 @@ import { useState, useCallback } from 'react';
|
|
|
2
2
|
import { startOfMonth, addMonths, subMonths } from 'date-fns';
|
|
3
3
|
|
|
4
4
|
function useCalendarMonthes({ inputValueFrom, inputValueTo, defaultMonth, isPopover, }) {
|
|
5
|
-
const initialMonthFrom =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
const initialMonthFrom = (() => {
|
|
6
|
+
if (inputValueFrom.value && inputValueFrom.date) {
|
|
7
|
+
return startOfMonth(inputValueFrom.date).getTime();
|
|
8
|
+
}
|
|
9
|
+
return defaultMonth;
|
|
10
|
+
})();
|
|
11
|
+
const initialMonthTo = (() => {
|
|
12
|
+
if (inputValueTo.value && inputValueTo.date) {
|
|
13
|
+
return startOfMonth(inputValueTo.date).getTime();
|
|
14
|
+
}
|
|
15
|
+
return isPopover ? initialMonthFrom : addMonths(initialMonthFrom, 1).getTime();
|
|
16
|
+
})();
|
|
9
17
|
const [monthFrom, setMonthFrom] = useState(initialMonthFrom);
|
|
10
18
|
const [monthTo, setMonthTo] = useState(initialMonthTo);
|
|
11
19
|
const handleMonthFromChange = useCallback((newMonthFrom) => {
|
|
@@ -7,10 +7,18 @@ var dateFns = require('date-fns');
|
|
|
7
7
|
|
|
8
8
|
function useCalendarMonthes(_a) {
|
|
9
9
|
var inputValueFrom = _a.inputValueFrom, inputValueTo = _a.inputValueTo, defaultMonth = _a.defaultMonth, isPopover = _a.isPopover;
|
|
10
|
-
var initialMonthFrom =
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
var initialMonthFrom = (function () {
|
|
11
|
+
if (inputValueFrom.value && inputValueFrom.date) {
|
|
12
|
+
return dateFns.startOfMonth(inputValueFrom.date).getTime();
|
|
13
|
+
}
|
|
14
|
+
return defaultMonth;
|
|
15
|
+
})();
|
|
16
|
+
var initialMonthTo = (function () {
|
|
17
|
+
if (inputValueTo.value && inputValueTo.date) {
|
|
18
|
+
return dateFns.startOfMonth(inputValueTo.date).getTime();
|
|
19
|
+
}
|
|
20
|
+
return isPopover ? initialMonthFrom : dateFns.addMonths(initialMonthFrom, 1).getTime();
|
|
21
|
+
})();
|
|
14
22
|
var _b = React.useState(initialMonthFrom), monthFrom = _b[0], setMonthFrom = _b[1];
|
|
15
23
|
var _c = React.useState(initialMonthTo), monthTo = _c[0], setMonthTo = _c[1];
|
|
16
24
|
var handleMonthFromChange = React.useCallback(function (newMonthFrom) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alfalab/core-components-calendar-range",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Calendar range component",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
"react-dom": "^16.9.0 || ^17.0.1"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@alfalab/core-components-calendar": "^3.
|
|
23
|
-
"@alfalab/core-components-calendar-input": "^5.0
|
|
22
|
+
"@alfalab/core-components-calendar": "^3.2.0",
|
|
23
|
+
"@alfalab/core-components-calendar-input": "^5.1.0",
|
|
24
24
|
"classnames": "^2.2.6",
|
|
25
25
|
"date-fns": "^2.16.1",
|
|
26
26
|
"react-merge-refs": "^1.1.0"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "19a2d088b6c18a127940199cfd6e6fc4e8639ec5"
|
|
29
29
|
}
|