@chayns-components/date 5.0.0-beta.811 → 5.0.0-beta.813
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/lib/cjs/components/calendar/Calendar.js +146 -67
- package/lib/cjs/components/calendar/Calendar.js.map +1 -1
- package/lib/cjs/components/calendar/Calendar.styles.js +8 -1
- package/lib/cjs/components/calendar/Calendar.styles.js.map +1 -1
- package/lib/cjs/components/calendar/month-wrapper/MonthWrapper.js +38 -11
- package/lib/cjs/components/calendar/month-wrapper/MonthWrapper.js.map +1 -1
- package/lib/cjs/components/calendar/month-wrapper/month/Month.js +34 -30
- package/lib/cjs/components/calendar/month-wrapper/month/Month.js.map +1 -1
- package/lib/cjs/components/calendar/month-wrapper/month/Month.styles.js +2 -1
- package/lib/cjs/components/calendar/month-wrapper/month/Month.styles.js.map +1 -1
- package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.js +50 -47
- package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.js.map +1 -1
- package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.styles.js +0 -1
- package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.styles.js.map +1 -1
- package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/day/Day.js +8 -10
- package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/day/Day.js.map +1 -1
- package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/day/Day.styles.js +38 -41
- package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/day/Day.styles.js.map +1 -1
- package/lib/cjs/components/calendar/month-year-pickers/MonthYearPickers.js +86 -0
- package/lib/cjs/components/calendar/month-year-pickers/MonthYearPickers.js.map +1 -0
- package/lib/cjs/types/calendar.js.map +1 -1
- package/lib/cjs/utils/calendar.js +18 -2
- package/lib/cjs/utils/calendar.js.map +1 -1
- package/lib/esm/components/calendar/Calendar.js +150 -71
- package/lib/esm/components/calendar/Calendar.js.map +1 -1
- package/lib/esm/components/calendar/Calendar.styles.js +7 -0
- package/lib/esm/components/calendar/Calendar.styles.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/MonthWrapper.js +38 -11
- package/lib/esm/components/calendar/month-wrapper/MonthWrapper.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/month/Month.js +17 -9
- package/lib/esm/components/calendar/month-wrapper/month/Month.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/month/Month.styles.js +2 -1
- package/lib/esm/components/calendar/month-wrapper/month/Month.styles.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.js +51 -48
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.styles.js +0 -1
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.styles.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/Day.js +8 -10
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/Day.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/Day.styles.js +41 -39
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/Day.styles.js.map +1 -1
- package/lib/esm/components/calendar/month-year-pickers/MonthYearPickers.js +79 -0
- package/lib/esm/components/calendar/month-year-pickers/MonthYearPickers.js.map +1 -0
- package/lib/esm/types/calendar.js.map +1 -1
- package/lib/esm/utils/calendar.js +15 -1
- package/lib/esm/utils/calendar.js.map +1 -1
- package/lib/types/components/calendar/Calendar.d.ts +41 -6
- package/lib/types/components/calendar/Calendar.styles.d.ts +1 -0
- package/lib/types/components/calendar/month-wrapper/MonthWrapper.d.ts +2 -0
- package/lib/types/components/calendar/month-wrapper/MonthWrapper.styles.d.ts +1 -1
- package/lib/types/components/calendar/month-wrapper/month/Month.d.ts +4 -1
- package/lib/types/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.d.ts +1 -1
- package/lib/types/components/calendar/month-wrapper/month/day-wrapper/day/Day.d.ts +0 -1
- package/lib/types/components/calendar/month-wrapper/month/day-wrapper/day/Day.styles.d.ts +3 -0
- package/lib/types/components/calendar/month-year-pickers/MonthYearPickers.d.ts +19 -0
- package/lib/types/components/opening-times/opening-inputs/OpeningInputs.styles.d.ts +1 -1
- package/lib/types/components/opening-times/opening-inputs/opening-input/OpeningInput.styles.d.ts +1 -1
- package/lib/types/types/calendar.d.ts +2 -2
- package/lib/types/utils/calendar.d.ts +2 -0
- package/package.json +3 -3
|
@@ -24,44 +24,90 @@ const Calendar = ({
|
|
|
24
24
|
highlightedDates,
|
|
25
25
|
onChange,
|
|
26
26
|
selectedDate,
|
|
27
|
+
selectedDates,
|
|
28
|
+
selectedDateInterval,
|
|
27
29
|
categories,
|
|
28
30
|
isDisabled,
|
|
29
|
-
|
|
30
|
-
disabledDates = []
|
|
31
|
+
type = _calendar.CalendarType.Single,
|
|
32
|
+
disabledDates = [],
|
|
33
|
+
showMonthYearPickers: showMonthYearPickersProp
|
|
31
34
|
}) => {
|
|
32
|
-
const type = _calendar.CalendarType.Single;
|
|
33
35
|
const [currentDate, setCurrentDate] = (0, _react.useState)();
|
|
34
36
|
const [shouldRenderTwoMonths, setShouldRenderTwoMonths] = (0, _react.useState)(true);
|
|
35
|
-
const [internalSelectedDate, setInternalSelectedDate] = (0, _react.useState)();
|
|
37
|
+
const [internalSelectedDate, setInternalSelectedDate] = (0, _react.useState)(type === _calendar.CalendarType.Multiple ? [] : undefined);
|
|
36
38
|
const [direction, setDirection] = (0, _react.useState)();
|
|
37
39
|
const [width, setWidth] = (0, _react.useState)(0);
|
|
40
|
+
const showMonthYearPickers = (0, _react.useMemo)(() => {
|
|
41
|
+
const hasMultipleMonths = (0, _dateFns.differenceInCalendarMonths)(maxDate, minDate) > 0;
|
|
42
|
+
const hasMultipleYears = (0, _calendar2.getYearsBetween)(minDate, maxDate).length > 1;
|
|
43
|
+
return !!(showMonthYearPickersProp && (hasMultipleMonths || hasMultipleYears));
|
|
44
|
+
}, [minDate, maxDate, showMonthYearPickersProp]);
|
|
38
45
|
const calendarRef = (0, _react.useRef)(null);
|
|
39
46
|
(0, _react.useEffect)(() => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
47
|
+
const bounds = {
|
|
48
|
+
start: minDate,
|
|
49
|
+
end: maxDate
|
|
50
|
+
};
|
|
51
|
+
if (type === _calendar.CalendarType.Single) {
|
|
52
|
+
if (selectedDate) {
|
|
53
|
+
const isDisabledDate = disabledDates.some(disabledDate => (0, _dateFns.isSameDay)(selectedDate, disabledDate));
|
|
54
|
+
const isDateInBounds = (0, _dateFns.isWithinInterval)(selectedDate, bounds);
|
|
55
|
+
if (!isDisabledDate && isDateInBounds) {
|
|
56
|
+
setInternalSelectedDate(selectedDate);
|
|
57
|
+
} else {
|
|
58
|
+
console.warn('[@chayns-components/date] Warning: Failed to set selectedDate, because it is disabled or out of bounds.', '\nselectedDate:', selectedDate, ...(isDisabledDate ? ['\nselectedDate is disabled'] : []), ...(isDateInBounds ? [] : ['\nselectedDate is outside of bounds:', {
|
|
59
|
+
minDate,
|
|
60
|
+
maxDate
|
|
61
|
+
}]));
|
|
62
|
+
setInternalSelectedDate(undefined);
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
setInternalSelectedDate(undefined);
|
|
66
|
+
}
|
|
67
|
+
} else if (type === _calendar.CalendarType.Multiple) {
|
|
68
|
+
if (selectedDates) {
|
|
69
|
+
const disabledSelectedDates = [];
|
|
70
|
+
const datesOutsideOfBounds = [];
|
|
71
|
+
const filteredDates = selectedDates.filter(date => {
|
|
72
|
+
if (disabledDates.some(disabledDate => (0, _dateFns.isSameDay)(date, disabledDate))) {
|
|
73
|
+
disabledSelectedDates.push(date);
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
if (!(0, _dateFns.isWithinInterval)(date, bounds)) {
|
|
77
|
+
datesOutsideOfBounds.push(date);
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
return true;
|
|
81
|
+
});
|
|
82
|
+
if (disabledSelectedDates.length > 0 || datesOutsideOfBounds.length > 0) {
|
|
83
|
+
console.warn('[@chayns-components/date] Warning: Failed to set all selectedDates, because some are disabled or out of bounds.', ...(disabledSelectedDates.length > 0 ? ['\nselectedDates that are disabled:', disabledSelectedDates] : []), ...(datesOutsideOfBounds.length > 0 ? ['\nselectedDates that are outside of bounds:', datesOutsideOfBounds, 'bounds:', {
|
|
84
|
+
minDate,
|
|
85
|
+
maxDate
|
|
86
|
+
}] : []));
|
|
87
|
+
}
|
|
88
|
+
setInternalSelectedDate(filteredDates);
|
|
89
|
+
} else {
|
|
90
|
+
setInternalSelectedDate([]);
|
|
91
|
+
}
|
|
92
|
+
} else if (type === _calendar.CalendarType.Interval) {
|
|
93
|
+
if (selectedDateInterval) {
|
|
94
|
+
const intervalIncludesDisabledDate = selectedDateInterval.end && disabledDates.some(disabledDate => (0, _dateFns.isWithinInterval)(disabledDate, {
|
|
95
|
+
start: selectedDateInterval.start,
|
|
96
|
+
end: selectedDateInterval.end
|
|
97
|
+
}));
|
|
98
|
+
const intervalIsInBounds = (0, _dateFns.isWithinInterval)(selectedDateInterval.start, bounds) && (!selectedDateInterval.end || (0, _dateFns.isWithinInterval)(selectedDateInterval.end, bounds));
|
|
99
|
+
if (!intervalIncludesDisabledDate && intervalIsInBounds) {
|
|
100
|
+
setInternalSelectedDate(selectedDateInterval);
|
|
101
|
+
} else {
|
|
102
|
+
console.warn('[@chayns-components/date] Warning: Failed to set selectedDateInterval, because it includes disabled dates or dates that are out of bounds.', '\nselectedDateInterval:', selectedDateInterval, ...(intervalIncludesDisabledDate ? ['\ndisabled dates:', disabledDates] : []), ...(intervalIsInBounds ? [] : ['\nbounds:', {
|
|
103
|
+
minDate,
|
|
104
|
+
maxDate
|
|
105
|
+
}]));
|
|
106
|
+
setInternalSelectedDate(undefined);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
44
109
|
}
|
|
45
|
-
|
|
46
|
-
// if (
|
|
47
|
-
// selectedDate &&
|
|
48
|
-
// ((type === CalendarType.Single && selectedDate instanceof Date) ||
|
|
49
|
-
// (type === CalendarType.Multiple && Array.isArray(selectedDate)))
|
|
50
|
-
// ) {
|
|
51
|
-
// setInternalSelectedDate(selectedDate);
|
|
52
|
-
// } else if (type === CalendarType.Interval && (selectedDate as DateInterval)?.start) {
|
|
53
|
-
// setInternalSelectedDate({
|
|
54
|
-
// start: (selectedDate as DateInterval).start,
|
|
55
|
-
// end: (selectedDate as DateInterval).end,
|
|
56
|
-
// });
|
|
57
|
-
// } else if (type === CalendarType.Multiple) {
|
|
58
|
-
// setInternalSelectedDate([]);
|
|
59
|
-
// } else if (type === CalendarType.Interval) {
|
|
60
|
-
// setInternalSelectedDate({});
|
|
61
|
-
// } else {
|
|
62
|
-
// setInternalSelectedDate(undefined);
|
|
63
|
-
// }
|
|
64
|
-
}, [type, selectedDate, disabledDates]);
|
|
110
|
+
}, [type, selectedDate, selectedDates, selectedDateInterval, disabledDates, minDate, maxDate]);
|
|
65
111
|
(0, _react.useEffect)(() => {
|
|
66
112
|
if (calendarRef.current) {
|
|
67
113
|
const resizeObserver = new ResizeObserver(entries => {
|
|
@@ -120,43 +166,48 @@ const Calendar = ({
|
|
|
120
166
|
}, [maxDate, minDate]);
|
|
121
167
|
const handleSelect = (0, _react.useCallback)(date => {
|
|
122
168
|
setInternalSelectedDate(prevDate => {
|
|
123
|
-
let onChangePayload
|
|
124
|
-
let newInternalSelectedDate
|
|
169
|
+
let onChangePayload = null;
|
|
170
|
+
let newInternalSelectedDate = undefined;
|
|
171
|
+
if (type === _calendar.CalendarType.Single) {
|
|
172
|
+
onChangePayload = date;
|
|
173
|
+
newInternalSelectedDate = date;
|
|
174
|
+
} else if (type === _calendar.CalendarType.Multiple) {
|
|
175
|
+
const prevSelectedDates = prevDate;
|
|
176
|
+
// Selects or unselects date , depending on if it is already selected.
|
|
177
|
+
if (prevSelectedDates.some(d => (0, _dateFns.isSameDay)(d, date))) {
|
|
178
|
+
newInternalSelectedDate = prevSelectedDates.filter(d => !(0, _dateFns.isSameDay)(d, date));
|
|
179
|
+
} else {
|
|
180
|
+
newInternalSelectedDate = [...prevSelectedDates, date];
|
|
181
|
+
}
|
|
182
|
+
onChangePayload = newInternalSelectedDate;
|
|
183
|
+
} else if (type === _calendar.CalendarType.Interval) {
|
|
184
|
+
const prevSelectedDateInterval = prevDate;
|
|
185
|
+
const updateInterval = (start, end) => {
|
|
186
|
+
const newInterval = {
|
|
187
|
+
start,
|
|
188
|
+
end
|
|
189
|
+
};
|
|
190
|
+
onChangePayload = newInterval;
|
|
191
|
+
newInternalSelectedDate = newInterval;
|
|
192
|
+
};
|
|
125
193
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
} else {
|
|
135
|
-
newInternalSelectedDate = [...prevDate, date];
|
|
136
|
-
}
|
|
137
|
-
onChangePayload = newInternalSelectedDate;
|
|
138
|
-
} else if (type === CalendarType.Interval) {
|
|
139
|
-
if ((prevDate as DateInterval).start && !(prevDate as DateInterval).end) {
|
|
140
|
-
if (date < (prevDate as DateInterval).start) {
|
|
141
|
-
onChangePayload = { start: date, end: undefined };
|
|
142
|
-
newInternalSelectedDate = { start: date, end: undefined };
|
|
143
|
-
} else {
|
|
144
|
-
onChangePayload = {
|
|
145
|
-
start: (prevDate as DateInterval).start,
|
|
146
|
-
end: date,
|
|
147
|
-
};
|
|
148
|
-
newInternalSelectedDate = {
|
|
149
|
-
start: (prevDate as DateInterval).start,
|
|
150
|
-
end: date,
|
|
151
|
-
};
|
|
152
|
-
}
|
|
194
|
+
// Sets first selection as interval start.
|
|
195
|
+
if (!prevSelectedDateInterval) {
|
|
196
|
+
updateInterval(date);
|
|
197
|
+
} else if (prevSelectedDateInterval.start && !prevSelectedDateInterval.end) {
|
|
198
|
+
// Sets second selection as interval start, if it is earlier than the previous interval start.
|
|
199
|
+
// Else sets it as interval end.
|
|
200
|
+
if (date < prevSelectedDateInterval.start) {
|
|
201
|
+
updateInterval(date);
|
|
153
202
|
} else {
|
|
154
|
-
|
|
155
|
-
newInternalSelectedDate = { start: date, end: undefined };
|
|
203
|
+
updateInterval(prevSelectedDateInterval.start, date);
|
|
156
204
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
205
|
+
} else {
|
|
206
|
+
// Resets interval if a third date is selected.
|
|
207
|
+
updateInterval(date);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (typeof onChange === 'function' && onChangePayload) {
|
|
160
211
|
onChange(onChangePayload);
|
|
161
212
|
}
|
|
162
213
|
return newInternalSelectedDate;
|
|
@@ -182,9 +233,22 @@ const Calendar = ({
|
|
|
182
233
|
$isDisabled: isDisabled
|
|
183
234
|
}, ShouldShowLeftArrow ? /*#__PURE__*/_react.default.createElement(_Calendar.StyledCalendarIconWrapper, {
|
|
184
235
|
onClick: handleLeftArrowClick
|
|
185
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
236
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
237
|
+
// TODO Use styled-components instead of inline styles
|
|
238
|
+
style: {
|
|
239
|
+
display: 'flex',
|
|
240
|
+
flexDirection: 'row',
|
|
241
|
+
flexWrap: 'nowrap',
|
|
242
|
+
height: 'fit-content'
|
|
243
|
+
}
|
|
244
|
+
}, showMonthYearPickers && /*#__PURE__*/_react.default.createElement(_Calendar.StyledPseudoMonthYearPicker, null, /*#__PURE__*/_react.default.createElement(_core.ComboBox, {
|
|
245
|
+
lists: [{
|
|
246
|
+
list: []
|
|
247
|
+
}],
|
|
248
|
+
placeholder: ""
|
|
249
|
+
})), /*#__PURE__*/_react.default.createElement(_core.Icon, {
|
|
186
250
|
icons: ['fa fa-angle-left']
|
|
187
|
-
})) : /*#__PURE__*/_react.default.createElement(_Calendar.StyledCalendarIconWrapperPseudo, null), currentDate && /*#__PURE__*/_react.default.createElement(_MonthWrapper.default, {
|
|
251
|
+
}))) : /*#__PURE__*/_react.default.createElement(_Calendar.StyledCalendarIconWrapperPseudo, null), currentDate && /*#__PURE__*/_react.default.createElement(_MonthWrapper.default, {
|
|
188
252
|
shouldRenderTwo: shouldRenderTwoMonths,
|
|
189
253
|
currentDate: currentDate,
|
|
190
254
|
width: width,
|
|
@@ -198,12 +262,27 @@ const Calendar = ({
|
|
|
198
262
|
minDate: minDate,
|
|
199
263
|
maxDate: maxDate,
|
|
200
264
|
type: type,
|
|
201
|
-
disabledDates: disabledDates
|
|
265
|
+
disabledDates: disabledDates,
|
|
266
|
+
setCurrentDate: setCurrentDate,
|
|
267
|
+
showMonthYearPickers: showMonthYearPickers
|
|
202
268
|
}), ShouldShowRightArrow ? /*#__PURE__*/_react.default.createElement(_Calendar.StyledCalendarIconWrapper, {
|
|
203
269
|
onClick: handleRightArrowClick
|
|
204
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
270
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
271
|
+
// TODO Use styled-components instead of inline styles
|
|
272
|
+
style: {
|
|
273
|
+
display: 'flex',
|
|
274
|
+
flexDirection: 'row',
|
|
275
|
+
flexWrap: 'nowrap',
|
|
276
|
+
height: 'fit-content'
|
|
277
|
+
}
|
|
278
|
+
}, showMonthYearPickers && /*#__PURE__*/_react.default.createElement(_Calendar.StyledPseudoMonthYearPicker, null, /*#__PURE__*/_react.default.createElement(_core.ComboBox, {
|
|
279
|
+
lists: [{
|
|
280
|
+
list: []
|
|
281
|
+
}],
|
|
282
|
+
placeholder: ""
|
|
283
|
+
})), /*#__PURE__*/_react.default.createElement(_core.Icon, {
|
|
205
284
|
icons: ['fa fa-angle-right']
|
|
206
|
-
})) : /*#__PURE__*/_react.default.createElement(_Calendar.StyledCalendarIconWrapperPseudo, null));
|
|
285
|
+
}))) : /*#__PURE__*/_react.default.createElement(_Calendar.StyledCalendarIconWrapperPseudo, null));
|
|
207
286
|
};
|
|
208
287
|
Calendar.displayName = 'Calendar';
|
|
209
288
|
var _default = exports.default = Calendar;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Calendar.js","names":["_core","require","_dateFns","_locale","_react","_interopRequireWildcard","_calendar","_calendar2","_Calendar","_MonthWrapper","_interopRequireDefault","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","DEFAULT_MAX_DATE","addYears","Date","DEFAULT_MIN_DATE","subYears","Calendar","locale","de","maxDate","minDate","highlightedDates","onChange","selectedDate","categories","isDisabled","disabledDates","type","CalendarType","Single","currentDate","setCurrentDate","useState","shouldRenderTwoMonths","setShouldRenderTwoMonths","internalSelectedDate","setInternalSelectedDate","direction","setDirection","width","setWidth","calendarRef","useRef","useEffect","some","disabledDate","isSameDay","undefined","current","resizeObserver","ResizeObserver","entries","observedWidth","contentRect","observe","disconnect","date","isDateInRange","handleLeftArrowClick","useCallback","prevDate","newDate","getNewDate","handleRightArrowClick","handleSelect","onChangePayload","newInternalSelectedDate","handleAnimationFinished","ShouldShowLeftArrow","useMemo","isSameMonth","ShouldShowRightArrow","createElement","StyledCalendar","ref","$isDisabled","StyledCalendarIconWrapper","onClick","Icon","icons","StyledCalendarIconWrapperPseudo","shouldRenderTwo","onSelect","onAnimationFinished","displayName","_default","exports"],"sources":["../../../../src/components/calendar/Calendar.tsx"],"sourcesContent":["import { Icon } from '@chayns-components/core';\nimport { addYears, isSameDay, isSameMonth, subYears, type Locale } from 'date-fns';\nimport { de } from 'date-fns/locale';\nimport React, { FC, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport type { Categories, DateInterval, HighlightedDates } from '../../types/calendar';\nimport { CalendarType } from '../../types/calendar';\nimport { getNewDate, isDateInRange } from '../../utils/calendar';\nimport {\n StyledCalendar,\n StyledCalendarIconWrapper,\n StyledCalendarIconWrapperPseudo,\n} from './Calendar.styles';\nimport MonthWrapper from './month-wrapper/MonthWrapper';\n\ninterface BaseProps {\n /**\n * An array to group dates into a category.\n */\n categories?: Categories[];\n /**\n * An array with dates and corresponding styles to highlight.\n */\n highlightedDates?: HighlightedDates[];\n /**\n * To disable the Calendar\n */\n isDisabled?: boolean;\n /**\n * The locale language to format the dates.\n */\n locale?: Locale;\n /**\n * The maximum date that can be selected.\n */\n maxDate?: Date;\n /**\n * The minimum date that can be selected.\n */\n minDate?: Date;\n /**\n * An array of dates that should be disabled.\n */\n disabledDates?: Date[];\n}\n\ninterface SingleSelectionProps extends BaseProps {\n /* type?: CalendarType.Single; */\n /**\n * Function to be executed when the selected date changes.\n * @param date\n */\n onChange?: (date: Date) => void;\n /**\n * A date that should be preselected.\n */\n selectedDate?: Date;\n}\n\ninterface MultipleSelectionProps extends BaseProps {\n type?: CalendarType.Multiple;\n /**\n * Function to be executed when the selected dates change.\n * @param date\n */\n onChange?: (date: Date[]) => void;\n /**\n * An array of dates that should be preselected.\n */\n selectedDate?: Date[];\n}\n\ninterface IntervalSelectionProps extends BaseProps {\n type?: CalendarType.Interval;\n /**\n * Function to be executed when the selected interval changes.\n * @param date\n */\n onChange?: (date: DateInterval) => void;\n /**\n * An interval that should be preselected.\n */\n selectedDate?: DateInterval;\n}\n\nexport type CalendarProps =\n SingleSelectionProps /* | MultipleSelectionProps | IntervalSelectionProps */;\n\nconst DEFAULT_MAX_DATE = addYears(new Date(), 1);\nconst DEFAULT_MIN_DATE = subYears(new Date(), 1);\n\nconst Calendar: FC<CalendarProps> = ({\n locale = de,\n maxDate = DEFAULT_MAX_DATE,\n minDate = DEFAULT_MIN_DATE,\n highlightedDates,\n onChange,\n selectedDate,\n categories,\n isDisabled,\n // type = CalendarType.Single,\n disabledDates = [],\n}) => {\n const type = CalendarType.Single;\n\n const [currentDate, setCurrentDate] = useState<Date>();\n const [shouldRenderTwoMonths, setShouldRenderTwoMonths] = useState(true);\n const [internalSelectedDate, setInternalSelectedDate] = useState<\n Date | Date[] | DateInterval\n >();\n const [direction, setDirection] = useState<'left' | 'right'>();\n const [width, setWidth] = useState(0);\n\n const calendarRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (\n selectedDate &&\n type === CalendarType.Single &&\n !disabledDates.some((disabledDate) => isSameDay(selectedDate, disabledDate))\n ) {\n setInternalSelectedDate(selectedDate);\n } else {\n setInternalSelectedDate(undefined);\n }\n\n // if (\n // selectedDate &&\n // ((type === CalendarType.Single && selectedDate instanceof Date) ||\n // (type === CalendarType.Multiple && Array.isArray(selectedDate)))\n // ) {\n // setInternalSelectedDate(selectedDate);\n // } else if (type === CalendarType.Interval && (selectedDate as DateInterval)?.start) {\n // setInternalSelectedDate({\n // start: (selectedDate as DateInterval).start,\n // end: (selectedDate as DateInterval).end,\n // });\n // } else if (type === CalendarType.Multiple) {\n // setInternalSelectedDate([]);\n // } else if (type === CalendarType.Interval) {\n // setInternalSelectedDate({});\n // } else {\n // setInternalSelectedDate(undefined);\n // }\n }, [type, selectedDate, disabledDates]);\n\n useEffect(() => {\n if (calendarRef.current) {\n const resizeObserver = new ResizeObserver((entries) => {\n if (entries && entries[0]) {\n const observedWidth = entries[0].contentRect.width;\n\n setWidth(observedWidth - 30);\n\n if (observedWidth < 430) {\n setShouldRenderTwoMonths(false);\n } else {\n setShouldRenderTwoMonths(true);\n }\n }\n });\n\n resizeObserver.observe(calendarRef.current);\n\n return () => {\n resizeObserver.disconnect();\n };\n }\n\n return () => {};\n }, []);\n\n useEffect(() => {\n const date = new Date();\n\n setCurrentDate(isDateInRange({ minDate, maxDate, currentDate: date }));\n }, [maxDate, minDate]);\n\n const handleLeftArrowClick = useCallback(() => {\n setDirection('left');\n\n setCurrentDate((prevDate) => {\n if (!prevDate) {\n return prevDate;\n }\n\n const newDate = getNewDate(-1, prevDate);\n\n return isDateInRange({ minDate, maxDate, currentDate: newDate });\n });\n }, [maxDate, minDate]);\n\n const handleRightArrowClick = useCallback(() => {\n setDirection('right');\n\n setCurrentDate((prevDate) => {\n if (!prevDate) {\n return prevDate;\n }\n\n const newDate = getNewDate(1, prevDate);\n\n return isDateInRange({ minDate, maxDate, currentDate: newDate });\n });\n }, [maxDate, minDate]);\n\n const handleSelect = useCallback(\n (date: Date) => {\n setInternalSelectedDate((prevDate) => {\n let onChangePayload: Date /* | Date[] | DateInterval */;\n let newInternalSelectedDate: Date /* | Date[] | DateInterval */;\n\n /* if (type === CalendarType.Single) { */\n onChangePayload = date;\n newInternalSelectedDate = date;\n /* } else if (type === CalendarType.Multiple) {\n if ((prevDate as Date[]).some((d) => isSameDay(d, date))) {\n newInternalSelectedDate = (prevDate as Date[]).filter(\n (d) => !isSameDay(d, date),\n );\n } else {\n newInternalSelectedDate = [...prevDate, date];\n }\n\n onChangePayload = newInternalSelectedDate;\n } else if (type === CalendarType.Interval) {\n if ((prevDate as DateInterval).start && !(prevDate as DateInterval).end) {\n if (date < (prevDate as DateInterval).start) {\n onChangePayload = { start: date, end: undefined };\n newInternalSelectedDate = { start: date, end: undefined };\n } else {\n onChangePayload = {\n start: (prevDate as DateInterval).start,\n end: date,\n };\n newInternalSelectedDate = {\n start: (prevDate as DateInterval).start,\n end: date,\n };\n }\n } else {\n onChangePayload = { start: date, end: undefined };\n newInternalSelectedDate = { start: date, end: undefined };\n }\n } */\n\n if (typeof onChange === 'function') {\n onChange(onChangePayload);\n }\n\n return newInternalSelectedDate;\n });\n },\n [type, onChange],\n );\n\n const handleAnimationFinished = () => {\n setDirection(undefined);\n };\n\n const ShouldShowLeftArrow = useMemo(() => {\n if (!currentDate) {\n return false;\n }\n\n return !isSameMonth(currentDate, minDate);\n }, [currentDate, minDate]);\n\n const ShouldShowRightArrow = useMemo(() => {\n if (!currentDate) {\n return false;\n }\n\n return !isSameMonth(currentDate, maxDate);\n }, [currentDate, maxDate]);\n\n return (\n <StyledCalendar ref={calendarRef} $isDisabled={isDisabled}>\n {ShouldShowLeftArrow ? (\n <StyledCalendarIconWrapper onClick={handleLeftArrowClick}>\n <Icon icons={['fa fa-angle-left']} />\n </StyledCalendarIconWrapper>\n ) : (\n <StyledCalendarIconWrapperPseudo />\n )}\n {currentDate && (\n <MonthWrapper\n shouldRenderTwo={shouldRenderTwoMonths}\n currentDate={currentDate}\n width={width}\n locale={locale}\n direction={direction}\n onSelect={handleSelect}\n selectedDate={internalSelectedDate}\n highlightedDates={highlightedDates}\n categories={categories}\n onAnimationFinished={handleAnimationFinished}\n minDate={minDate}\n maxDate={maxDate}\n type={type}\n disabledDates={disabledDates}\n />\n )}\n {ShouldShowRightArrow ? (\n <StyledCalendarIconWrapper onClick={handleRightArrowClick}>\n <Icon icons={['fa fa-angle-right']} />\n </StyledCalendarIconWrapper>\n ) : (\n <StyledCalendarIconWrapperPseudo />\n )}\n </StyledCalendar>\n );\n};\n\nCalendar.displayName = 'Calendar';\n\nexport default Calendar;\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAC,uBAAA,CAAAJ,OAAA;AAEA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AAKA,IAAAQ,aAAA,GAAAC,sBAAA,CAAAT,OAAA;AAAwD,SAAAS,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAAH,CAAA,6BAAAI,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAD,wBAAA,YAAAA,CAAAH,CAAA,WAAAA,CAAA,GAAAM,CAAA,GAAAD,CAAA,KAAAL,CAAA;AAAA,SAAAN,wBAAAM,CAAA,EAAAK,CAAA,SAAAA,CAAA,IAAAL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,CAAA+E,aAAA,CAAC5F,KAAA,CAAAkG,IAAI;IAACC,KAAK,EAAE,CAAC,mBAAmB;EAAE,CAAE,CACd,CAAC,gBAE5B/F,MAAA,CAAAS,OAAA,CAAA+E,aAAA,CAACpF,SAAA,CAAA4F,+BAA+B,MAAE,CAE1B,CAAC;AAEzB,CAAC;AAEDhE,QAAQ,CAACoE,WAAW,GAAG,UAAU;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA7F,OAAA,GAEnBuB,QAAQ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Calendar.js","names":["_core","require","_dateFns","_locale","_react","_interopRequireWildcard","_calendar","_calendar2","_Calendar","_MonthWrapper","_interopRequireDefault","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","DEFAULT_MAX_DATE","addYears","Date","DEFAULT_MIN_DATE","subYears","Calendar","locale","de","maxDate","minDate","highlightedDates","onChange","selectedDate","selectedDates","selectedDateInterval","categories","isDisabled","type","CalendarType","Single","disabledDates","showMonthYearPickers","showMonthYearPickersProp","currentDate","setCurrentDate","useState","shouldRenderTwoMonths","setShouldRenderTwoMonths","internalSelectedDate","setInternalSelectedDate","Multiple","undefined","direction","setDirection","width","setWidth","useMemo","hasMultipleMonths","differenceInCalendarMonths","hasMultipleYears","getYearsBetween","length","calendarRef","useRef","useEffect","bounds","start","end","isDisabledDate","some","disabledDate","isSameDay","isDateInBounds","isWithinInterval","console","warn","disabledSelectedDates","datesOutsideOfBounds","filteredDates","filter","date","push","Interval","intervalIncludesDisabledDate","intervalIsInBounds","current","resizeObserver","ResizeObserver","entries","observedWidth","contentRect","observe","disconnect","isDateInRange","handleLeftArrowClick","useCallback","prevDate","newDate","getNewDate","handleRightArrowClick","handleSelect","onChangePayload","newInternalSelectedDate","prevSelectedDates","d","prevSelectedDateInterval","updateInterval","newInterval","handleAnimationFinished","ShouldShowLeftArrow","isSameMonth","ShouldShowRightArrow","createElement","StyledCalendar","ref","$isDisabled","StyledCalendarIconWrapper","onClick","style","display","flexDirection","flexWrap","height","StyledPseudoMonthYearPicker","ComboBox","lists","list","placeholder","Icon","icons","StyledCalendarIconWrapperPseudo","shouldRenderTwo","onSelect","onAnimationFinished","displayName","_default","exports"],"sources":["../../../../src/components/calendar/Calendar.tsx"],"sourcesContent":["import { ComboBox, Icon } from '@chayns-components/core';\nimport {\n addYears,\n differenceInCalendarMonths,\n isSameDay,\n isSameMonth,\n isWithinInterval,\n subYears,\n type Locale,\n} from 'date-fns';\nimport { de } from 'date-fns/locale';\nimport React, { FC, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport type { Categories, DateInterval, HighlightedDates } from '../../types/calendar';\nimport { CalendarType } from '../../types/calendar';\nimport { getNewDate, getYearsBetween, isDateInRange } from '../../utils/calendar';\nimport {\n StyledCalendar,\n StyledCalendarIconWrapper,\n StyledCalendarIconWrapperPseudo,\n StyledPseudoMonthYearPicker,\n} from './Calendar.styles';\nimport MonthWrapper from './month-wrapper/MonthWrapper';\n\ninterface BaseProps {\n /**\n * An array to group dates into a category.\n */\n categories?: Categories[];\n /**\n * An array with dates and corresponding styles to highlight.\n */\n highlightedDates?: HighlightedDates[];\n /**\n * To disable the Calendar\n */\n isDisabled?: boolean;\n /**\n * The locale language to format the dates.\n */\n locale?: Locale;\n /**\n * The maximum date that can be selected.\n */\n maxDate?: Date;\n /**\n * The minimum date that can be selected.\n */\n minDate?: Date;\n /**\n * An array of dates that should be disabled.\n */\n disabledDates?: Date[];\n /**\n * Shows the month and year pickers, if there are multiple months/years to select from.\n */\n showMonthYearPickers?: boolean;\n /**\n * Function to be executed when the selected date, dates or date interval change.\n * @param date\n */\n onChange?: (date: Date | Date[] | DateInterval) => void;\n}\n\ninterface SingleSelectionProps {\n /**\n * The type of the calendar selection.\n */\n type?: CalendarType.Single;\n /**\n * A date that should be preselected.\n */\n selectedDate?: Date;\n selectedDates: never;\n selectedDateInterval: never;\n}\n\ninterface MultipleSelectionProps {\n /**\n * The type of the calendar selection.\n */\n type: CalendarType.Multiple;\n /**\n * An array of dates that should be preselected.\n */\n selectedDates?: Date[];\n selectedDate: never;\n selectedDateInterval: never;\n}\n\ninterface IntervalSelectionProps {\n /**\n * The type of the calendar selection.\n */\n type: CalendarType.Interval;\n /**\n * An interval that should be preselected.\n */\n selectedDateInterval?: DateInterval;\n selectedDates: never;\n selectedDate: never;\n}\n\nexport type CalendarProps = BaseProps &\n (SingleSelectionProps | MultipleSelectionProps | IntervalSelectionProps);\n\nconst DEFAULT_MAX_DATE = addYears(new Date(), 1);\nconst DEFAULT_MIN_DATE = subYears(new Date(), 1);\n\nconst Calendar: FC<CalendarProps> = ({\n locale = de,\n maxDate = DEFAULT_MAX_DATE,\n minDate = DEFAULT_MIN_DATE,\n highlightedDates,\n onChange,\n selectedDate,\n selectedDates,\n selectedDateInterval,\n categories,\n isDisabled,\n type = CalendarType.Single,\n disabledDates = [],\n showMonthYearPickers: showMonthYearPickersProp,\n}) => {\n const [currentDate, setCurrentDate] = useState<Date>();\n const [shouldRenderTwoMonths, setShouldRenderTwoMonths] = useState(true);\n const [internalSelectedDate, setInternalSelectedDate] = useState<\n Date | Date[] | DateInterval | undefined\n >(type === CalendarType.Multiple ? [] : undefined);\n const [direction, setDirection] = useState<'left' | 'right'>();\n const [width, setWidth] = useState(0);\n\n const showMonthYearPickers = useMemo(() => {\n const hasMultipleMonths = differenceInCalendarMonths(maxDate, minDate) > 0;\n const hasMultipleYears = getYearsBetween(minDate, maxDate).length > 1;\n\n return !!(showMonthYearPickersProp && (hasMultipleMonths || hasMultipleYears));\n }, [minDate, maxDate, showMonthYearPickersProp]);\n\n const calendarRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const bounds = {\n start: minDate,\n end: maxDate,\n };\n if (type === CalendarType.Single) {\n if (selectedDate) {\n const isDisabledDate = disabledDates.some((disabledDate) =>\n isSameDay(selectedDate, disabledDate),\n );\n const isDateInBounds = isWithinInterval(selectedDate, bounds);\n\n if (!isDisabledDate && isDateInBounds) {\n setInternalSelectedDate(selectedDate);\n } else {\n console.warn(\n '[@chayns-components/date] Warning: Failed to set selectedDate, because it is disabled or out of bounds.',\n '\\nselectedDate:',\n selectedDate,\n ...(isDisabledDate ? ['\\nselectedDate is disabled'] : []),\n ...(isDateInBounds\n ? []\n : ['\\nselectedDate is outside of bounds:', { minDate, maxDate }]),\n );\n setInternalSelectedDate(undefined);\n }\n } else {\n setInternalSelectedDate(undefined);\n }\n } else if (type === CalendarType.Multiple) {\n if (selectedDates) {\n const disabledSelectedDates: Date[] = [];\n const datesOutsideOfBounds: Date[] = [];\n\n const filteredDates = selectedDates.filter((date) => {\n if (disabledDates.some((disabledDate) => isSameDay(date, disabledDate))) {\n disabledSelectedDates.push(date);\n return false;\n }\n\n if (!isWithinInterval(date, bounds)) {\n datesOutsideOfBounds.push(date);\n return false;\n }\n\n return true;\n });\n\n if (disabledSelectedDates.length > 0 || datesOutsideOfBounds.length > 0) {\n console.warn(\n '[@chayns-components/date] Warning: Failed to set all selectedDates, because some are disabled or out of bounds.',\n ...(disabledSelectedDates.length > 0\n ? ['\\nselectedDates that are disabled:', disabledSelectedDates]\n : []),\n ...(datesOutsideOfBounds.length > 0\n ? [\n '\\nselectedDates that are outside of bounds:',\n datesOutsideOfBounds,\n 'bounds:',\n { minDate, maxDate },\n ]\n : []),\n );\n }\n\n setInternalSelectedDate(filteredDates);\n } else {\n setInternalSelectedDate([]);\n }\n } else if (type === CalendarType.Interval) {\n if (selectedDateInterval) {\n const intervalIncludesDisabledDate =\n selectedDateInterval.end &&\n disabledDates.some((disabledDate) =>\n isWithinInterval(disabledDate, {\n start: selectedDateInterval.start,\n end: selectedDateInterval.end as Date,\n }),\n );\n\n const intervalIsInBounds =\n isWithinInterval(selectedDateInterval.start, bounds) &&\n (!selectedDateInterval.end ||\n isWithinInterval(selectedDateInterval.end, bounds));\n\n if (!intervalIncludesDisabledDate && intervalIsInBounds) {\n setInternalSelectedDate(selectedDateInterval);\n } else {\n console.warn(\n '[@chayns-components/date] Warning: Failed to set selectedDateInterval, because it includes disabled dates or dates that are out of bounds.',\n '\\nselectedDateInterval:',\n selectedDateInterval,\n ...(intervalIncludesDisabledDate\n ? ['\\ndisabled dates:', disabledDates]\n : []),\n ...(intervalIsInBounds ? [] : ['\\nbounds:', { minDate, maxDate }]),\n );\n setInternalSelectedDate(undefined);\n }\n }\n }\n }, [type, selectedDate, selectedDates, selectedDateInterval, disabledDates, minDate, maxDate]);\n\n useEffect(() => {\n if (calendarRef.current) {\n const resizeObserver = new ResizeObserver((entries) => {\n if (entries && entries[0]) {\n const observedWidth = entries[0].contentRect.width;\n\n setWidth(observedWidth - 30);\n\n if (observedWidth < 430) {\n setShouldRenderTwoMonths(false);\n } else {\n setShouldRenderTwoMonths(true);\n }\n }\n });\n\n resizeObserver.observe(calendarRef.current);\n\n return () => {\n resizeObserver.disconnect();\n };\n }\n\n return () => {};\n }, []);\n\n useEffect(() => {\n const date = new Date();\n\n setCurrentDate(isDateInRange({ minDate, maxDate, currentDate: date }));\n }, [maxDate, minDate]);\n\n const handleLeftArrowClick = useCallback(() => {\n setDirection('left');\n\n setCurrentDate((prevDate) => {\n if (!prevDate) {\n return prevDate;\n }\n\n const newDate = getNewDate(-1, prevDate);\n\n return isDateInRange({ minDate, maxDate, currentDate: newDate });\n });\n }, [maxDate, minDate]);\n\n const handleRightArrowClick = useCallback(() => {\n setDirection('right');\n\n setCurrentDate((prevDate) => {\n if (!prevDate) {\n return prevDate;\n }\n\n const newDate = getNewDate(1, prevDate);\n\n return isDateInRange({ minDate, maxDate, currentDate: newDate });\n });\n }, [maxDate, minDate]);\n\n const handleSelect = useCallback(\n (date: Date) => {\n setInternalSelectedDate((prevDate) => {\n let onChangePayload: Date | Date[] | DateInterval | null = null;\n let newInternalSelectedDate: Date | Date[] | DateInterval | undefined = undefined;\n\n if (type === CalendarType.Single) {\n onChangePayload = date;\n newInternalSelectedDate = date;\n } else if (type === CalendarType.Multiple) {\n const prevSelectedDates = prevDate as Date[];\n // Selects or unselects date , depending on if it is already selected.\n if (prevSelectedDates.some((d) => isSameDay(d, date))) {\n newInternalSelectedDate = prevSelectedDates.filter(\n (d) => !isSameDay(d, date),\n );\n } else {\n newInternalSelectedDate = [...prevSelectedDates, date];\n }\n\n onChangePayload = newInternalSelectedDate;\n } else if (type === CalendarType.Interval) {\n const prevSelectedDateInterval = prevDate as DateInterval;\n\n const updateInterval = (start: Date, end?: Date): void => {\n const newInterval = { start, end };\n onChangePayload = newInterval;\n newInternalSelectedDate = newInterval;\n };\n\n // Sets first selection as interval start.\n if (!prevSelectedDateInterval) {\n updateInterval(date);\n } else if (prevSelectedDateInterval.start && !prevSelectedDateInterval.end) {\n // Sets second selection as interval start, if it is earlier than the previous interval start.\n // Else sets it as interval end.\n if (date < prevSelectedDateInterval.start) {\n updateInterval(date);\n } else {\n updateInterval(prevSelectedDateInterval.start, date);\n }\n } else {\n // Resets interval if a third date is selected.\n updateInterval(date);\n }\n }\n\n if (typeof onChange === 'function' && onChangePayload) {\n onChange(onChangePayload);\n }\n\n return newInternalSelectedDate;\n });\n },\n [type, onChange],\n );\n\n const handleAnimationFinished = () => {\n setDirection(undefined);\n };\n\n const ShouldShowLeftArrow = useMemo(() => {\n if (!currentDate) {\n return false;\n }\n\n return !isSameMonth(currentDate, minDate);\n }, [currentDate, minDate]);\n\n const ShouldShowRightArrow = useMemo(() => {\n if (!currentDate) {\n return false;\n }\n\n return !isSameMonth(currentDate, maxDate);\n }, [currentDate, maxDate]);\n\n return (\n <StyledCalendar ref={calendarRef} $isDisabled={isDisabled}>\n {ShouldShowLeftArrow ? (\n <StyledCalendarIconWrapper onClick={handleLeftArrowClick}>\n <div // TODO Use styled-components instead of inline styles\n style={{\n display: 'flex',\n flexDirection: 'row',\n flexWrap: 'nowrap',\n height: 'fit-content',\n }}\n >\n {showMonthYearPickers && (\n <StyledPseudoMonthYearPicker>\n <ComboBox lists={[{ list: [] }]} placeholder=\"\" />\n </StyledPseudoMonthYearPicker>\n )}\n <Icon icons={['fa fa-angle-left']} />\n </div>\n </StyledCalendarIconWrapper>\n ) : (\n <StyledCalendarIconWrapperPseudo />\n )}\n {currentDate && (\n <MonthWrapper\n shouldRenderTwo={shouldRenderTwoMonths}\n currentDate={currentDate}\n width={width}\n locale={locale}\n direction={direction}\n onSelect={handleSelect}\n selectedDate={internalSelectedDate}\n highlightedDates={highlightedDates}\n categories={categories}\n onAnimationFinished={handleAnimationFinished}\n minDate={minDate}\n maxDate={maxDate}\n type={type}\n disabledDates={disabledDates}\n setCurrentDate={setCurrentDate}\n showMonthYearPickers={showMonthYearPickers}\n />\n )}\n {ShouldShowRightArrow ? (\n <StyledCalendarIconWrapper onClick={handleRightArrowClick}>\n <div // TODO Use styled-components instead of inline styles\n style={{\n display: 'flex',\n flexDirection: 'row',\n flexWrap: 'nowrap',\n height: 'fit-content',\n }}\n >\n {showMonthYearPickers && (\n <StyledPseudoMonthYearPicker>\n <ComboBox lists={[{ list: [] }]} placeholder=\"\" />\n </StyledPseudoMonthYearPicker>\n )}\n <Icon icons={['fa fa-angle-right']} />\n </div>\n </StyledCalendarIconWrapper>\n ) : (\n <StyledCalendarIconWrapperPseudo />\n )}\n </StyledCalendar>\n );\n};\n\nCalendar.displayName = 'Calendar';\n\nexport default Calendar;\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AASA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAC,uBAAA,CAAAJ,OAAA;AAEA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AAMA,IAAAQ,aAAA,GAAAC,sBAAA,CAAAT,OAAA;AAAwD,SAAAS,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OA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BACtD1G,MAAA,CAAAS,OAAA,CAAA8G,aAAA;IAAK;IACDM,KAAK,EAAE;MACHC,OAAO,EAAE,MAAM;MACfC,aAAa,EAAE,KAAK;MACpBC,QAAQ,EAAE,QAAQ;MAClBC,MAAM,EAAE;IACZ;EAAE,GAEDjF,oBAAoB,iBACjBhD,MAAA,CAAAS,OAAA,CAAA8G,aAAA,CAACnH,SAAA,CAAA8H,2BAA2B,qBACxBlI,MAAA,CAAAS,OAAA,CAAA8G,aAAA,CAAC3H,KAAA,CAAAuI,QAAQ;IAACC,KAAK,EAAE,CAAC;MAAEC,IAAI,EAAE;IAAG,CAAC,CAAE;IAACC,WAAW,EAAC;EAAE,CAAE,CACxB,CAChC,eACDtI,MAAA,CAAAS,OAAA,CAAA8G,aAAA,CAAC3H,KAAA,CAAA2I,IAAI;IAACC,KAAK,EAAE,CAAC,mBAAmB;EAAE,CAAE,CACpC,CACkB,CAAC,gBAE5BxI,MAAA,CAAAS,OAAA,CAAA8G,aAAA,CAACnH,SAAA,CAAAqI,+BAA+B,MAAE,CAE1B,CAAC;AAEzB,CAAC;AAEDzG,QAAQ,CAAC6G,WAAW,GAAG,UAAU;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAtI,OAAA,GAEnBuB,QAAQ","ignoreList":[]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.StyledCalendarIconWrapperPseudo = exports.StyledCalendarIconWrapper = exports.StyledCalendar = void 0;
|
|
6
|
+
exports.StyledPseudoMonthYearPicker = exports.StyledCalendarIconWrapperPseudo = exports.StyledCalendarIconWrapper = exports.StyledCalendar = void 0;
|
|
7
7
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
8
8
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
9
|
const StyledCalendar = exports.StyledCalendar = _styledComponents.default.div`
|
|
@@ -24,4 +24,11 @@ const StyledCalendarIconWrapper = exports.StyledCalendarIconWrapper = _styledCom
|
|
|
24
24
|
const StyledCalendarIconWrapperPseudo = exports.StyledCalendarIconWrapperPseudo = _styledComponents.default.div`
|
|
25
25
|
width: 15px;
|
|
26
26
|
`;
|
|
27
|
+
const StyledPseudoMonthYearPicker = exports.StyledPseudoMonthYearPicker = _styledComponents.default.div`
|
|
28
|
+
height: fit-content;
|
|
29
|
+
width: 0;
|
|
30
|
+
overflow: hidden;
|
|
31
|
+
pointer-events: none;
|
|
32
|
+
user-select: none;
|
|
33
|
+
`;
|
|
27
34
|
//# sourceMappingURL=Calendar.styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Calendar.styles.js","names":["_styledComponents","_interopRequireDefault","require","e","__esModule","default","StyledCalendar","exports","styled","div","$isDisabled","undefined","StyledCalendarIconWrapper","StyledCalendarIconWrapperPseudo"],"sources":["../../../../src/components/calendar/Calendar.styles.ts"],"sourcesContent":["import styled from 'styled-components';\n\ntype StyledCalendarProps = { $isDisabled?: boolean };\n\nexport const StyledCalendar = styled.div<StyledCalendarProps>`\n display: flex;\n width: 100%;\n opacity: ${({ $isDisabled }) => ($isDisabled ? 0.5 : 1)};\n pointer-events: ${({ $isDisabled }) => ($isDisabled ? 'none' : undefined)};\n user-select: none;\n`;\n\nexport const StyledCalendarIconWrapper = styled.div`\n cursor: pointer;\n z-index: 2;\n`;\n\nexport const StyledCalendarIconWrapperPseudo = styled.div`\n width: 15px;\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAuC,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAIhC,MAAMG,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAGE,yBAAM,CAACC,GAAwB;AAC7D;AACA;AACA,eAAe,CAAC;EAAEC;AAAY,CAAC,KAAMA,WAAW,GAAG,GAAG,GAAG,CAAE;AAC3D,sBAAsB,CAAC;EAAEA;AAAY,CAAC,KAAMA,WAAW,GAAG,MAAM,GAAGC,SAAU;AAC7E;AACA,CAAC;AAEM,MAAMC,yBAAyB,GAAAL,OAAA,CAAAK,yBAAA,GAAGJ,yBAAM,CAACC,GAAG;AACnD;AACA;AACA,CAAC;AAEM,MAAMI,+BAA+B,GAAAN,OAAA,CAAAM,+BAAA,GAAGL,yBAAM,CAACC,GAAG;AACzD;AACA,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Calendar.styles.js","names":["_styledComponents","_interopRequireDefault","require","e","__esModule","default","StyledCalendar","exports","styled","div","$isDisabled","undefined","StyledCalendarIconWrapper","StyledCalendarIconWrapperPseudo","StyledPseudoMonthYearPicker"],"sources":["../../../../src/components/calendar/Calendar.styles.ts"],"sourcesContent":["import styled from 'styled-components';\n\ntype StyledCalendarProps = { $isDisabled?: boolean };\n\nexport const StyledCalendar = styled.div<StyledCalendarProps>`\n display: flex;\n width: 100%;\n opacity: ${({ $isDisabled }) => ($isDisabled ? 0.5 : 1)};\n pointer-events: ${({ $isDisabled }) => ($isDisabled ? 'none' : undefined)};\n user-select: none;\n`;\n\nexport const StyledCalendarIconWrapper = styled.div`\n cursor: pointer;\n z-index: 2;\n`;\n\nexport const StyledCalendarIconWrapperPseudo = styled.div`\n width: 15px;\n`;\n\nexport const StyledPseudoMonthYearPicker = styled.div`\n height: fit-content;\n width: 0;\n overflow: hidden;\n pointer-events: none;\n user-select: none;\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAuC,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAIhC,MAAMG,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAGE,yBAAM,CAACC,GAAwB;AAC7D;AACA;AACA,eAAe,CAAC;EAAEC;AAAY,CAAC,KAAMA,WAAW,GAAG,GAAG,GAAG,CAAE;AAC3D,sBAAsB,CAAC;EAAEA;AAAY,CAAC,KAAMA,WAAW,GAAG,MAAM,GAAGC,SAAU;AAC7E;AACA,CAAC;AAEM,MAAMC,yBAAyB,GAAAL,OAAA,CAAAK,yBAAA,GAAGJ,yBAAM,CAACC,GAAG;AACnD;AACA;AACA,CAAC;AAEM,MAAMI,+BAA+B,GAAAN,OAAA,CAAAM,+BAAA,GAAGL,yBAAM,CAACC,GAAG;AACzD;AACA,CAAC;AAEM,MAAMK,2BAA2B,GAAAP,OAAA,CAAAO,2BAAA,GAAGN,yBAAM,CAACC,GAAG;AACrD;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
|
|
@@ -26,7 +26,9 @@ const MonthWrapper = ({
|
|
|
26
26
|
minDate,
|
|
27
27
|
maxDate,
|
|
28
28
|
type,
|
|
29
|
-
disabledDates
|
|
29
|
+
disabledDates,
|
|
30
|
+
setCurrentDate,
|
|
31
|
+
showMonthYearPickers
|
|
30
32
|
}) => {
|
|
31
33
|
const [content, setContent] = (0, _react.useState)();
|
|
32
34
|
const [hoveringDay, setHoveringDay] = (0, _react.useState)(null);
|
|
@@ -60,7 +62,10 @@ const MonthWrapper = ({
|
|
|
60
62
|
type: type,
|
|
61
63
|
hoveringDay: hoveringDay,
|
|
62
64
|
setHoveringDay: setHoveringDay,
|
|
63
|
-
disabledDates: disabledDates
|
|
65
|
+
disabledDates: disabledDates,
|
|
66
|
+
setCurrentDate: setCurrentDate,
|
|
67
|
+
displayIndex: i,
|
|
68
|
+
showMonthYearPickers: showMonthYearPickers
|
|
64
69
|
}));
|
|
65
70
|
}
|
|
66
71
|
return items;
|
|
@@ -86,7 +91,9 @@ const MonthWrapper = ({
|
|
|
86
91
|
type: type,
|
|
87
92
|
hoveringDay: hoveringDay,
|
|
88
93
|
setHoveringDay: setHoveringDay,
|
|
89
|
-
disabledDates: disabledDates
|
|
94
|
+
disabledDates: disabledDates,
|
|
95
|
+
setCurrentDate: setCurrentDate,
|
|
96
|
+
showMonthYearPickers: showMonthYearPickers
|
|
90
97
|
}));
|
|
91
98
|
prevState.pop();
|
|
92
99
|
}
|
|
@@ -111,25 +118,45 @@ const MonthWrapper = ({
|
|
|
111
118
|
type: type,
|
|
112
119
|
hoveringDay: hoveringDay,
|
|
113
120
|
setHoveringDay: setHoveringDay,
|
|
114
|
-
disabledDates: disabledDates
|
|
121
|
+
disabledDates: disabledDates,
|
|
122
|
+
setCurrentDate: setCurrentDate,
|
|
123
|
+
showMonthYearPickers: showMonthYearPickers
|
|
115
124
|
}));
|
|
116
125
|
prevState.shift();
|
|
117
126
|
}
|
|
118
127
|
return prevState;
|
|
119
128
|
});
|
|
120
|
-
}, [categories, currentDate, direction, highlightedDates, locale, monthHeight, onSelect, selectedDate, minDate, maxDate, type, hoveringDay, disabledDates]);
|
|
129
|
+
}, [categories, currentDate, direction, highlightedDates, locale, monthHeight, onSelect, selectedDate, minDate, maxDate, type, hoveringDay, disabledDates, setCurrentDate, showMonthYearPickers]);
|
|
121
130
|
(0, _react.useEffect)(() => {
|
|
122
|
-
if (
|
|
123
|
-
|
|
131
|
+
if (direction) return;
|
|
132
|
+
setContent(prevState => (prevState ?? []).map((element, index) => {
|
|
133
|
+
const date = (0, _calendar.getNewDate)(index - 1, currentDate);
|
|
134
|
+
const {
|
|
135
|
+
month,
|
|
136
|
+
year
|
|
137
|
+
} = (0, _calendar.getMonthAndYear)(date);
|
|
138
|
+
return {
|
|
124
139
|
...element,
|
|
125
140
|
props: {
|
|
126
141
|
...element.props,
|
|
142
|
+
categories,
|
|
143
|
+
highlightedDates,
|
|
144
|
+
locale,
|
|
145
|
+
onSelect,
|
|
127
146
|
selectedDate,
|
|
128
|
-
|
|
147
|
+
minDate,
|
|
148
|
+
maxDate,
|
|
149
|
+
type,
|
|
150
|
+
hoveringDay,
|
|
151
|
+
disabledDates,
|
|
152
|
+
month,
|
|
153
|
+
year,
|
|
154
|
+
displayIndex: index - 1,
|
|
155
|
+
showMonthYearPickers
|
|
129
156
|
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}, [selectedDate,
|
|
157
|
+
};
|
|
158
|
+
}));
|
|
159
|
+
}, [categories, disabledDates, highlightedDates, hoveringDay, locale, maxDate, minDate, onSelect, selectedDate, type, currentDate, direction, showMonthYearPickers]);
|
|
133
160
|
const animate = (0, _react.useMemo)(() => {
|
|
134
161
|
if (shouldRenderTwo) {
|
|
135
162
|
switch (true) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MonthWrapper.js","names":["_react","_interopRequireWildcard","require","_calendar","_Month","_interopRequireDefault","_MonthWrapper","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","MonthWrapper","locale","currentDate","highlightedDates","selectedDate","onSelect","categories","direction","onAnimationFinished","shouldRenderTwo","width","isDisabled","minDate","maxDate","type","disabledDates","content","setContent","useState","hoveringDay","setHoveringDay","monthHeight","useMemo","useEffect","undefined","prevState","items","date","getNewDate","month","year","getMonthAndYear","push","createElement","height","key","unshift","pop","shift","map","element","props","animate","x","StyledMonthWrapper","$height","$width","StyledMotionWrapper","$isDisabled","transition","duration","onAnimationComplete","displayName","_default","exports"],"sources":["../../../../../src/components/calendar/month-wrapper/MonthWrapper.tsx"],"sourcesContent":["import type { Locale } from 'date-fns';\nimport type { MotionProps } from 'framer-motion';\nimport React, { FC, useEffect, useMemo, useState, type ReactElement } from 'react';\nimport type {\n CalendarType,\n Categories,\n DateInterval,\n HighlightedDates,\n} from '../../../types/calendar';\nimport { getMonthAndYear, getNewDate } from '../../../utils/calendar';\nimport Month from './month/Month';\nimport { StyledMonthWrapper, StyledMotionWrapper } from './MonthWrapper.styles';\n\nexport type MonthWrapperProps = {\n locale: Locale;\n highlightedDates?: HighlightedDates[];\n onSelect: (date: Date) => void;\n selectedDate?: Date | Date[] | DateInterval;\n categories?: Categories[];\n currentDate: Date;\n direction?: 'left' | 'right';\n onAnimationFinished: () => void;\n shouldRenderTwo: boolean;\n width: number;\n isDisabled?: boolean;\n maxDate: Date;\n minDate: Date;\n type: CalendarType;\n disabledDates: Date[];\n};\n\nconst MonthWrapper: FC<MonthWrapperProps> = ({\n locale,\n currentDate,\n highlightedDates,\n selectedDate,\n onSelect,\n categories,\n direction,\n onAnimationFinished,\n shouldRenderTwo,\n width,\n isDisabled,\n minDate,\n maxDate,\n type,\n disabledDates,\n}) => {\n const [content, setContent] = useState<ReactElement[]>();\n\n const [hoveringDay, setHoveringDay] = useState<Date | null>(null);\n\n const monthHeight = useMemo(() => width / (shouldRenderTwo ? 2 : 1), [width, shouldRenderTwo]);\n\n useEffect(() => {\n setContent(undefined);\n }, [monthHeight]);\n\n useEffect(() => {\n setContent((prevState) => {\n // Initial render of months\n if (!prevState) {\n const items: ReactElement[] = [];\n\n for (let i = -1; i < 3; i++) {\n const date = getNewDate(i, currentDate);\n\n const { month, year } = getMonthAndYear(date);\n\n items.push(\n <Month\n height={monthHeight}\n key={`${month}-${year}`}\n month={month}\n year={year}\n locale={locale}\n onSelect={onSelect}\n highlightedDates={highlightedDates}\n categories={categories}\n selectedDate={selectedDate}\n minDate={minDate}\n maxDate={maxDate}\n type={type}\n hoveringDay={hoveringDay}\n setHoveringDay={setHoveringDay}\n disabledDates={disabledDates}\n />,\n );\n }\n\n return items;\n }\n\n if (direction === 'left') {\n const date = getNewDate(-1, currentDate);\n\n const { month, year } = getMonthAndYear(date);\n\n prevState.unshift(\n <Month\n height={monthHeight}\n key={`${month}-${year}`}\n month={month}\n year={year}\n locale={locale}\n onSelect={onSelect}\n highlightedDates={highlightedDates}\n categories={categories}\n selectedDate={selectedDate}\n minDate={minDate}\n maxDate={maxDate}\n type={type}\n hoveringDay={hoveringDay}\n setHoveringDay={setHoveringDay}\n disabledDates={disabledDates}\n />,\n );\n prevState.pop();\n }\n\n if (direction === 'right') {\n const date = getNewDate(2, currentDate);\n\n const { month, year } = getMonthAndYear(date);\n\n prevState.push(\n <Month\n height={monthHeight}\n key={`${month}-${year}`}\n month={month}\n year={year}\n locale={locale}\n onSelect={onSelect}\n highlightedDates={highlightedDates}\n categories={categories}\n selectedDate={selectedDate}\n minDate={minDate}\n maxDate={maxDate}\n type={type}\n hoveringDay={hoveringDay}\n setHoveringDay={setHoveringDay}\n disabledDates={disabledDates}\n />,\n );\n prevState.shift();\n }\n\n return prevState;\n });\n }, [\n categories,\n currentDate,\n direction,\n highlightedDates,\n locale,\n monthHeight,\n onSelect,\n selectedDate,\n minDate,\n maxDate,\n type,\n hoveringDay,\n disabledDates,\n ]);\n\n useEffect(() => {\n if (selectedDate || hoveringDay) {\n setContent((prevState) =>\n (prevState ?? []).map((element) => ({\n ...element,\n props: { ...element.props, selectedDate, hoveringDay } as ReactElement,\n })),\n );\n }\n }, [selectedDate, hoveringDay]);\n\n const animate: MotionProps['animate'] = useMemo(() => {\n if (shouldRenderTwo) {\n switch (true) {\n case direction === 'left':\n return { x: '0%' };\n case direction === 'right':\n return { x: '-100%' };\n default:\n return { x: '-50%' };\n }\n } else {\n switch (true) {\n case direction === 'left':\n return { x: '0%' };\n case direction === 'right':\n return { x: '-200%' };\n default:\n return { x: '-100%' };\n }\n }\n }, [direction, shouldRenderTwo]);\n\n return (\n <StyledMonthWrapper $height={monthHeight} $width={width}>\n <StyledMotionWrapper\n animate={animate}\n $isDisabled={isDisabled}\n transition={{\n type: 'tween',\n duration: !direction ? 0 : 0.2,\n }}\n onAnimationComplete={onAnimationFinished}\n >\n {content}\n </StyledMotionWrapper>\n </StyledMonthWrapper>\n );\n};\n\nMonthWrapper.displayName = 'MonthWrapper';\n\nexport default MonthWrapper;\n"],"mappings":";;;;;;AAEA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAOA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA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,"file":"MonthWrapper.js","names":["_react","_interopRequireWildcard","require","_calendar","_Month","_interopRequireDefault","_MonthWrapper","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","MonthWrapper","locale","currentDate","highlightedDates","selectedDate","onSelect","categories","direction","onAnimationFinished","shouldRenderTwo","width","isDisabled","minDate","maxDate","type","disabledDates","setCurrentDate","showMonthYearPickers","content","setContent","useState","hoveringDay","setHoveringDay","monthHeight","useMemo","useEffect","undefined","prevState","items","date","getNewDate","month","year","getMonthAndYear","push","createElement","height","key","displayIndex","unshift","pop","shift","map","element","index","props","animate","x","StyledMonthWrapper","$height","$width","StyledMotionWrapper","$isDisabled","transition","duration","onAnimationComplete","displayName","_default","exports"],"sources":["../../../../../src/components/calendar/month-wrapper/MonthWrapper.tsx"],"sourcesContent":["import type { Locale } from 'date-fns';\nimport type { MotionProps } from 'framer-motion';\nimport React, { FC, useEffect, useMemo, useState, type ReactElement } from 'react';\nimport type {\n CalendarType,\n Categories,\n DateInterval,\n HighlightedDates,\n} from '../../../types/calendar';\nimport { getMonthAndYear, getNewDate } from '../../../utils/calendar';\nimport Month from './month/Month';\nimport { StyledMonthWrapper, StyledMotionWrapper } from './MonthWrapper.styles';\n\nexport type MonthWrapperProps = {\n locale: Locale;\n highlightedDates?: HighlightedDates[];\n onSelect: (date: Date) => void;\n selectedDate?: Date | Date[] | DateInterval;\n categories?: Categories[];\n currentDate: Date;\n direction?: 'left' | 'right';\n onAnimationFinished: () => void;\n shouldRenderTwo: boolean;\n width: number;\n isDisabled?: boolean;\n maxDate: Date;\n minDate: Date;\n type: CalendarType;\n disabledDates: Date[];\n setCurrentDate: (date: Date) => void;\n showMonthYearPickers: boolean;\n};\n\nconst MonthWrapper: FC<MonthWrapperProps> = ({\n locale,\n currentDate,\n highlightedDates,\n selectedDate,\n onSelect,\n categories,\n direction,\n onAnimationFinished,\n shouldRenderTwo,\n width,\n isDisabled,\n minDate,\n maxDate,\n type,\n disabledDates,\n setCurrentDate,\n showMonthYearPickers,\n}) => {\n const [content, setContent] = useState<ReactElement[]>();\n\n const [hoveringDay, setHoveringDay] = useState<Date | null>(null);\n\n const monthHeight = useMemo(() => width / (shouldRenderTwo ? 2 : 1), [width, shouldRenderTwo]);\n\n useEffect(() => {\n setContent(undefined);\n }, [monthHeight]);\n\n useEffect(() => {\n setContent((prevState) => {\n // Initial render of months\n if (!prevState) {\n const items: ReactElement[] = [];\n\n for (let i = -1; i < 3; i++) {\n const date = getNewDate(i, currentDate);\n\n const { month, year } = getMonthAndYear(date);\n\n items.push(\n <Month\n height={monthHeight}\n key={`${month}-${year}`}\n month={month}\n year={year}\n locale={locale}\n onSelect={onSelect}\n highlightedDates={highlightedDates}\n categories={categories}\n selectedDate={selectedDate}\n minDate={minDate}\n maxDate={maxDate}\n type={type}\n hoveringDay={hoveringDay}\n setHoveringDay={setHoveringDay}\n disabledDates={disabledDates}\n setCurrentDate={setCurrentDate}\n displayIndex={i}\n showMonthYearPickers={showMonthYearPickers}\n />,\n );\n }\n\n return items;\n }\n\n if (direction === 'left') {\n const date = getNewDate(-1, currentDate);\n\n const { month, year } = getMonthAndYear(date);\n\n prevState.unshift(\n <Month\n height={monthHeight}\n key={`${month}-${year}`}\n month={month}\n year={year}\n locale={locale}\n onSelect={onSelect}\n highlightedDates={highlightedDates}\n categories={categories}\n selectedDate={selectedDate}\n minDate={minDate}\n maxDate={maxDate}\n type={type}\n hoveringDay={hoveringDay}\n setHoveringDay={setHoveringDay}\n disabledDates={disabledDates}\n setCurrentDate={setCurrentDate}\n showMonthYearPickers={showMonthYearPickers}\n />,\n );\n prevState.pop();\n }\n\n if (direction === 'right') {\n const date = getNewDate(2, currentDate);\n\n const { month, year } = getMonthAndYear(date);\n\n prevState.push(\n <Month\n height={monthHeight}\n key={`${month}-${year}`}\n month={month}\n year={year}\n locale={locale}\n onSelect={onSelect}\n highlightedDates={highlightedDates}\n categories={categories}\n selectedDate={selectedDate}\n minDate={minDate}\n maxDate={maxDate}\n type={type}\n hoveringDay={hoveringDay}\n setHoveringDay={setHoveringDay}\n disabledDates={disabledDates}\n setCurrentDate={setCurrentDate}\n showMonthYearPickers={showMonthYearPickers}\n />,\n );\n prevState.shift();\n }\n\n return prevState;\n });\n }, [\n categories,\n currentDate,\n direction,\n highlightedDates,\n locale,\n monthHeight,\n onSelect,\n selectedDate,\n minDate,\n maxDate,\n type,\n hoveringDay,\n disabledDates,\n setCurrentDate,\n showMonthYearPickers,\n ]);\n\n useEffect(() => {\n if (direction) return;\n setContent((prevState) =>\n (prevState ?? []).map((element, index) => {\n const date = getNewDate(index - 1, currentDate);\n\n const { month, year } = getMonthAndYear(date);\n\n return {\n ...element,\n props: {\n ...element.props,\n categories,\n highlightedDates,\n locale,\n onSelect,\n selectedDate,\n minDate,\n maxDate,\n type,\n hoveringDay,\n disabledDates,\n month,\n year,\n displayIndex: index - 1,\n showMonthYearPickers,\n } as ReactElement,\n };\n }),\n );\n }, [\n categories,\n disabledDates,\n highlightedDates,\n hoveringDay,\n locale,\n maxDate,\n minDate,\n onSelect,\n selectedDate,\n type,\n currentDate,\n direction,\n showMonthYearPickers,\n ]);\n\n const animate: MotionProps['animate'] = useMemo(() => {\n if (shouldRenderTwo) {\n switch (true) {\n case direction === 'left':\n return { x: '0%' };\n case direction === 'right':\n return { x: '-100%' };\n default:\n return { x: '-50%' };\n }\n } else {\n switch (true) {\n case direction === 'left':\n return { x: '0%' };\n case direction === 'right':\n return { x: '-200%' };\n default:\n return { x: '-100%' };\n }\n }\n }, [direction, shouldRenderTwo]);\n\n return (\n <StyledMonthWrapper $height={monthHeight} $width={width}>\n <StyledMotionWrapper\n animate={animate}\n $isDisabled={isDisabled}\n transition={{\n type: 'tween',\n duration: !direction ? 0 : 0.2,\n }}\n onAnimationComplete={onAnimationFinished}\n >\n {content}\n </StyledMotionWrapper>\n </StyledMonthWrapper>\n );\n};\n\nMonthWrapper.displayName =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