@chayns-components/date 5.0.0-beta.1000

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.
Files changed (173) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +34 -0
  3. package/lib/cjs/components/calendar/Calendar.js +314 -0
  4. package/lib/cjs/components/calendar/Calendar.js.map +1 -0
  5. package/lib/cjs/components/calendar/Calendar.styles.js +34 -0
  6. package/lib/cjs/components/calendar/Calendar.styles.js.map +1 -0
  7. package/lib/cjs/components/calendar/month-wrapper/MonthWrapper.js +158 -0
  8. package/lib/cjs/components/calendar/month-wrapper/MonthWrapper.js.map +1 -0
  9. package/lib/cjs/components/calendar/month-wrapper/MonthWrapper.styles.js +23 -0
  10. package/lib/cjs/components/calendar/month-wrapper/MonthWrapper.styles.js.map +1 -0
  11. package/lib/cjs/components/calendar/month-wrapper/month/Month.js +65 -0
  12. package/lib/cjs/components/calendar/month-wrapper/month/Month.js.map +1 -0
  13. package/lib/cjs/components/calendar/month-wrapper/month/Month.styles.js +26 -0
  14. package/lib/cjs/components/calendar/month-wrapper/month/Month.styles.js.map +1 -0
  15. package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.js +129 -0
  16. package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.js.map +1 -0
  17. package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.styles.js +16 -0
  18. package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.styles.js.map +1 -0
  19. package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/day/Day.js +63 -0
  20. package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/day/Day.js.map +1 -0
  21. package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/day/Day.styles.js +114 -0
  22. package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/day/Day.styles.js.map +1 -0
  23. package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/day/category/Category.js +17 -0
  24. package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/day/category/Category.js.map +1 -0
  25. package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/day/category/Category.styles.js +18 -0
  26. package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/day/category/Category.styles.js.map +1 -0
  27. package/lib/cjs/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.js +42 -0
  28. package/lib/cjs/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.js.map +1 -0
  29. package/lib/cjs/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.styles.js +16 -0
  30. package/lib/cjs/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.styles.js.map +1 -0
  31. package/lib/cjs/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.js +15 -0
  32. package/lib/cjs/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.js.map +1 -0
  33. package/lib/cjs/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.styles.js +17 -0
  34. package/lib/cjs/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.styles.js.map +1 -0
  35. package/lib/cjs/components/calendar/month-year-pickers/MonthYearPickers.js +86 -0
  36. package/lib/cjs/components/calendar/month-year-pickers/MonthYearPickers.js.map +1 -0
  37. package/lib/cjs/components/date-info/DateInfo.js +35 -0
  38. package/lib/cjs/components/date-info/DateInfo.js.map +1 -0
  39. package/lib/cjs/components/opening-times/OpeningTimes.js +246 -0
  40. package/lib/cjs/components/opening-times/OpeningTimes.js.map +1 -0
  41. package/lib/cjs/components/opening-times/OpeningTimes.styles.js +28 -0
  42. package/lib/cjs/components/opening-times/OpeningTimes.styles.js.map +1 -0
  43. package/lib/cjs/components/opening-times/hint-text/HintText.js +19 -0
  44. package/lib/cjs/components/opening-times/hint-text/HintText.js.map +1 -0
  45. package/lib/cjs/components/opening-times/hint-text/HintText.styles.js +24 -0
  46. package/lib/cjs/components/opening-times/hint-text/HintText.styles.js.map +1 -0
  47. package/lib/cjs/components/opening-times/opening-inputs/OpeningInputs.js +153 -0
  48. package/lib/cjs/components/opening-times/opening-inputs/OpeningInputs.js.map +1 -0
  49. package/lib/cjs/components/opening-times/opening-inputs/OpeningInputs.styles.js +24 -0
  50. package/lib/cjs/components/opening-times/opening-inputs/OpeningInputs.styles.js.map +1 -0
  51. package/lib/cjs/components/opening-times/opening-inputs/opening-input/OpeningInput.js +106 -0
  52. package/lib/cjs/components/opening-times/opening-inputs/opening-input/OpeningInput.js.map +1 -0
  53. package/lib/cjs/components/opening-times/opening-inputs/opening-input/OpeningInput.styles.js +41 -0
  54. package/lib/cjs/components/opening-times/opening-inputs/opening-input/OpeningInput.styles.js.map +1 -0
  55. package/lib/cjs/hooks/useDateInfo.js +63 -0
  56. package/lib/cjs/hooks/useDateInfo.js.map +1 -0
  57. package/lib/cjs/index.js +177 -0
  58. package/lib/cjs/index.js.map +1 -0
  59. package/lib/cjs/types/calendar.js +28 -0
  60. package/lib/cjs/types/calendar.js.map +1 -0
  61. package/lib/cjs/types/dateinfo.js +2 -0
  62. package/lib/cjs/types/dateinfo.js.map +1 -0
  63. package/lib/cjs/types/openingTimes.js +18 -0
  64. package/lib/cjs/types/openingTimes.js.map +1 -0
  65. package/lib/cjs/utils/calendar.js +73 -0
  66. package/lib/cjs/utils/calendar.js.map +1 -0
  67. package/lib/cjs/utils/date.js +114 -0
  68. package/lib/cjs/utils/date.js.map +1 -0
  69. package/lib/cjs/utils/dateInfo.js +126 -0
  70. package/lib/cjs/utils/dateInfo.js.map +1 -0
  71. package/lib/esm/components/calendar/Calendar.js +306 -0
  72. package/lib/esm/components/calendar/Calendar.js.map +1 -0
  73. package/lib/esm/components/calendar/Calendar.styles.js +33 -0
  74. package/lib/esm/components/calendar/Calendar.styles.js.map +1 -0
  75. package/lib/esm/components/calendar/month-wrapper/MonthWrapper.js +150 -0
  76. package/lib/esm/components/calendar/month-wrapper/MonthWrapper.js.map +1 -0
  77. package/lib/esm/components/calendar/month-wrapper/MonthWrapper.styles.js +22 -0
  78. package/lib/esm/components/calendar/month-wrapper/MonthWrapper.styles.js.map +1 -0
  79. package/lib/esm/components/calendar/month-wrapper/month/Month.js +61 -0
  80. package/lib/esm/components/calendar/month-wrapper/month/Month.js.map +1 -0
  81. package/lib/esm/components/calendar/month-wrapper/month/Month.styles.js +22 -0
  82. package/lib/esm/components/calendar/month-wrapper/month/Month.styles.js.map +1 -0
  83. package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.js +121 -0
  84. package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.js.map +1 -0
  85. package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.styles.js +9 -0
  86. package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.styles.js.map +1 -0
  87. package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/Day.js +54 -0
  88. package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/Day.js.map +1 -0
  89. package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/Day.styles.js +123 -0
  90. package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/Day.styles.js.map +1 -0
  91. package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/category/Category.js +13 -0
  92. package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/category/Category.js.map +1 -0
  93. package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/category/Category.styles.js +14 -0
  94. package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/category/Category.styles.js.map +1 -0
  95. package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.js +34 -0
  96. package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.js.map +1 -0
  97. package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.styles.js +9 -0
  98. package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.styles.js.map +1 -0
  99. package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.js +11 -0
  100. package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.js.map +1 -0
  101. package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.styles.js +13 -0
  102. package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.styles.js.map +1 -0
  103. package/lib/esm/components/calendar/month-year-pickers/MonthYearPickers.js +79 -0
  104. package/lib/esm/components/calendar/month-year-pickers/MonthYearPickers.js.map +1 -0
  105. package/lib/esm/components/date-info/DateInfo.js +28 -0
  106. package/lib/esm/components/date-info/DateInfo.js.map +1 -0
  107. package/lib/esm/components/opening-times/OpeningTimes.js +240 -0
  108. package/lib/esm/components/opening-times/OpeningTimes.js.map +1 -0
  109. package/lib/esm/components/opening-times/OpeningTimes.styles.js +24 -0
  110. package/lib/esm/components/opening-times/OpeningTimes.styles.js.map +1 -0
  111. package/lib/esm/components/opening-times/hint-text/HintText.js +12 -0
  112. package/lib/esm/components/opening-times/hint-text/HintText.js.map +1 -0
  113. package/lib/esm/components/opening-times/hint-text/HintText.styles.js +23 -0
  114. package/lib/esm/components/opening-times/hint-text/HintText.styles.js.map +1 -0
  115. package/lib/esm/components/opening-times/opening-inputs/OpeningInputs.js +149 -0
  116. package/lib/esm/components/opening-times/opening-inputs/OpeningInputs.js.map +1 -0
  117. package/lib/esm/components/opening-times/opening-inputs/OpeningInputs.styles.js +22 -0
  118. package/lib/esm/components/opening-times/opening-inputs/OpeningInputs.styles.js.map +1 -0
  119. package/lib/esm/components/opening-times/opening-inputs/opening-input/OpeningInput.js +99 -0
  120. package/lib/esm/components/opening-times/opening-inputs/opening-input/OpeningInput.js.map +1 -0
  121. package/lib/esm/components/opening-times/opening-inputs/opening-input/OpeningInput.styles.js +40 -0
  122. package/lib/esm/components/opening-times/opening-inputs/opening-input/OpeningInput.styles.js.map +1 -0
  123. package/lib/esm/hooks/useDateInfo.js +57 -0
  124. package/lib/esm/hooks/useDateInfo.js.map +1 -0
  125. package/lib/esm/index.js +15 -0
  126. package/lib/esm/index.js.map +1 -0
  127. package/lib/esm/types/calendar.js +22 -0
  128. package/lib/esm/types/calendar.js.map +1 -0
  129. package/lib/esm/types/dateinfo.js +2 -0
  130. package/lib/esm/types/dateinfo.js.map +1 -0
  131. package/lib/esm/types/openingTimes.js +12 -0
  132. package/lib/esm/types/openingTimes.js.map +1 -0
  133. package/lib/esm/utils/calendar.js +63 -0
  134. package/lib/esm/utils/calendar.js.map +1 -0
  135. package/lib/esm/utils/date.js +89 -0
  136. package/lib/esm/utils/date.js.map +1 -0
  137. package/lib/esm/utils/dateInfo.js +120 -0
  138. package/lib/esm/utils/dateInfo.js.map +1 -0
  139. package/lib/types/components/calendar/Calendar.d.ts +97 -0
  140. package/lib/types/components/calendar/Calendar.styles.d.ts +8 -0
  141. package/lib/types/components/calendar/month-wrapper/MonthWrapper.d.ts +26 -0
  142. package/lib/types/components/calendar/month-wrapper/MonthWrapper.styles.d.ts +274 -0
  143. package/lib/types/components/calendar/month-wrapper/month/Month.d.ts +26 -0
  144. package/lib/types/components/calendar/month-wrapper/month/Month.styles.d.ts +8 -0
  145. package/lib/types/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.d.ts +20 -0
  146. package/lib/types/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.styles.d.ts +1 -0
  147. package/lib/types/components/calendar/month-wrapper/month/day-wrapper/day/Day.d.ts +19 -0
  148. package/lib/types/components/calendar/month-wrapper/month/day-wrapper/day/Day.styles.d.ts +20 -0
  149. package/lib/types/components/calendar/month-wrapper/month/day-wrapper/day/category/Category.d.ts +6 -0
  150. package/lib/types/components/calendar/month-wrapper/month/day-wrapper/day/category/Category.styles.d.ts +7 -0
  151. package/lib/types/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.d.ts +7 -0
  152. package/lib/types/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.styles.d.ts +1 -0
  153. package/lib/types/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.d.ts +6 -0
  154. package/lib/types/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.styles.d.ts +3 -0
  155. package/lib/types/components/calendar/month-year-pickers/MonthYearPickers.d.ts +19 -0
  156. package/lib/types/components/date-info/DateInfo.d.ts +5 -0
  157. package/lib/types/components/opening-times/OpeningTimes.d.ts +51 -0
  158. package/lib/types/components/opening-times/OpeningTimes.styles.d.ts +11 -0
  159. package/lib/types/components/opening-times/hint-text/HintText.d.ts +6 -0
  160. package/lib/types/components/opening-times/hint-text/HintText.styles.d.ts +3 -0
  161. package/lib/types/components/opening-times/opening-inputs/OpeningInputs.d.ts +46 -0
  162. package/lib/types/components/opening-times/opening-inputs/OpeningInputs.styles.d.ts +272 -0
  163. package/lib/types/components/opening-times/opening-inputs/opening-input/OpeningInput.d.ts +15 -0
  164. package/lib/types/components/opening-times/opening-inputs/opening-input/OpeningInput.styles.d.ts +273 -0
  165. package/lib/types/hooks/useDateInfo.d.ts +2 -0
  166. package/lib/types/index.d.ts +10 -0
  167. package/lib/types/types/calendar.d.ts +55 -0
  168. package/lib/types/types/dateinfo.d.ts +34 -0
  169. package/lib/types/types/openingTimes.d.ts +33 -0
  170. package/lib/types/utils/calendar.d.ts +18 -0
  171. package/lib/types/utils/date.d.ts +27 -0
  172. package/lib/types/utils/dateInfo.d.ts +14 -0
  173. package/package.json +86 -0
@@ -0,0 +1,306 @@
1
+ import { ComboBox, Icon } from '@chayns-components/core';
2
+ import { Language } from 'chayns-api';
3
+ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
4
+ import { CalendarType } from '../../types/calendar';
5
+ import { getNewDate, getYearsBetween, isDateInRange } from '../../utils/calendar';
6
+ import { addYears, differenceInCalendarMonths, isSameDay, isSameMonth, isWithinInterval, subYears } from '../../utils/date';
7
+ import { StyledCalendar, StyledCalendarIconWrapper, StyledCalendarIconWrapperPseudo, StyledPseudoMonthYearPicker } from './Calendar.styles';
8
+ import MonthWrapper from './month-wrapper/MonthWrapper';
9
+ const DEFAULT_MAX_DATE = addYears(new Date(), 1);
10
+ const DEFAULT_MIN_DATE = subYears(new Date(), 1);
11
+ const Calendar = _ref => {
12
+ let {
13
+ locale = Language.German,
14
+ maxDate = DEFAULT_MAX_DATE,
15
+ minDate = DEFAULT_MIN_DATE,
16
+ highlightedDates,
17
+ onChange,
18
+ customThumbColors,
19
+ selectedDate,
20
+ selectedDates,
21
+ selectedDateInterval,
22
+ categories,
23
+ isDisabled,
24
+ type = CalendarType.Single,
25
+ shouldShowHighlightsInMonthOverlay = true,
26
+ disabledDates = [],
27
+ showMonthYearPickers: showMonthYearPickersProp,
28
+ onShownDatesChange = () => {}
29
+ } = _ref;
30
+ const [currentDate, setCurrentDate] = useState();
31
+ const [shouldRenderTwoMonths, setShouldRenderTwoMonths] = useState(true);
32
+ const [internalSelectedDate, setInternalSelectedDate] = useState(() => type === CalendarType.Multiple ? [] : undefined);
33
+ const [direction, setDirection] = useState();
34
+ const [width, setWidth] = useState(0);
35
+ const showMonthYearPickers = useMemo(() => {
36
+ const hasMultipleMonths = differenceInCalendarMonths(maxDate, minDate) > 0;
37
+ const hasMultipleYears = getYearsBetween(minDate, maxDate).length > 1;
38
+ return !!(showMonthYearPickersProp && (hasMultipleMonths || hasMultipleYears));
39
+ }, [minDate, maxDate, showMonthYearPickersProp]);
40
+ const calendarRef = useRef(null);
41
+ useEffect(() => {
42
+ if (currentDate) {
43
+ const start = new Date(currentDate.getFullYear(), currentDate.getMonth(), 1);
44
+ if (shouldRenderTwoMonths) {
45
+ const end = new Date(currentDate.getFullYear(), currentDate.getMonth() + 2, 0);
46
+ onShownDatesChange({
47
+ start,
48
+ end
49
+ });
50
+ } else {
51
+ const end = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 0);
52
+ onShownDatesChange({
53
+ start,
54
+ end
55
+ });
56
+ }
57
+ }
58
+ // eslint-disable-next-line react-hooks/exhaustive-deps
59
+ }, [currentDate, shouldRenderTwoMonths]);
60
+ useEffect(() => {
61
+ const bounds = {
62
+ start: minDate,
63
+ end: maxDate
64
+ };
65
+ if (type === CalendarType.Single) {
66
+ if (selectedDate) {
67
+ const isDisabledDate = disabledDates.some(disabledDate => isSameDay(selectedDate, disabledDate));
68
+ const isDateInBounds = isWithinInterval(selectedDate, bounds);
69
+ if (!isDisabledDate && isDateInBounds) {
70
+ setInternalSelectedDate(selectedDate);
71
+ } else {
72
+ 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:', {
73
+ minDate,
74
+ maxDate
75
+ }]));
76
+ setInternalSelectedDate(() => undefined);
77
+ }
78
+ } else {
79
+ setInternalSelectedDate(() => undefined);
80
+ }
81
+ } else if (type === CalendarType.Multiple) {
82
+ if (selectedDates) {
83
+ const disabledSelectedDates = [];
84
+ const datesOutsideOfBounds = [];
85
+ const filteredDates = selectedDates.filter(date => {
86
+ if (disabledDates.some(disabledDate => isSameDay(date, disabledDate))) {
87
+ disabledSelectedDates.push(date);
88
+ return false;
89
+ }
90
+ if (!isWithinInterval(date, bounds)) {
91
+ datesOutsideOfBounds.push(date);
92
+ return false;
93
+ }
94
+ return true;
95
+ });
96
+ if (disabledSelectedDates.length > 0 || datesOutsideOfBounds.length > 0) {
97
+ 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:', {
98
+ minDate,
99
+ maxDate
100
+ }] : []));
101
+ }
102
+ setInternalSelectedDate(filteredDates);
103
+ } else {
104
+ setInternalSelectedDate([]);
105
+ }
106
+ } else if (type === CalendarType.Interval) {
107
+ if (selectedDateInterval) {
108
+ const intervalIncludesDisabledDate = selectedDateInterval.end && disabledDates.some(disabledDate => isWithinInterval(disabledDate, {
109
+ start: selectedDateInterval.start,
110
+ end: selectedDateInterval.end
111
+ }));
112
+ const intervalIsInBounds = isWithinInterval(selectedDateInterval.start, bounds) && (!selectedDateInterval.end || isWithinInterval(selectedDateInterval.end, bounds));
113
+ if (!intervalIncludesDisabledDate && intervalIsInBounds) {
114
+ setInternalSelectedDate(selectedDateInterval);
115
+ } else {
116
+ 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:', {
117
+ minDate,
118
+ maxDate
119
+ }]));
120
+ setInternalSelectedDate(() => undefined);
121
+ }
122
+ }
123
+ }
124
+ }, [type, selectedDate, selectedDates, selectedDateInterval, disabledDates, minDate, maxDate]);
125
+ useEffect(() => {
126
+ if (calendarRef.current) {
127
+ const resizeObserver = new ResizeObserver(entries => {
128
+ if (entries && entries[0]) {
129
+ const observedWidth = entries[0].contentRect.width;
130
+ setWidth(observedWidth - 30);
131
+ if (observedWidth < 430) {
132
+ setShouldRenderTwoMonths(false);
133
+ } else {
134
+ setShouldRenderTwoMonths(true);
135
+ }
136
+ }
137
+ });
138
+ resizeObserver.observe(calendarRef.current);
139
+ return () => {
140
+ resizeObserver.disconnect();
141
+ };
142
+ }
143
+ return () => {};
144
+ }, []);
145
+ useEffect(() => {
146
+ setCurrentDate(prevDate => isDateInRange({
147
+ minDate,
148
+ maxDate,
149
+ currentDate: prevDate || new Date()
150
+ }));
151
+ }, [maxDate, minDate]);
152
+ const handleLeftArrowClick = useCallback(() => {
153
+ if (direction) return;
154
+ setDirection('left');
155
+ setCurrentDate(prevDate => {
156
+ if (!prevDate) {
157
+ return prevDate;
158
+ }
159
+ const newDate = getNewDate(-1, prevDate);
160
+ return isDateInRange({
161
+ minDate,
162
+ maxDate,
163
+ currentDate: newDate
164
+ });
165
+ });
166
+ }, [maxDate, minDate, direction]);
167
+ const handleRightArrowClick = useCallback(() => {
168
+ if (direction) return;
169
+ setDirection('right');
170
+ setCurrentDate(prevDate => {
171
+ if (!prevDate) {
172
+ return prevDate;
173
+ }
174
+ const newDate = getNewDate(1, prevDate);
175
+ return isDateInRange({
176
+ minDate,
177
+ maxDate,
178
+ currentDate: newDate
179
+ });
180
+ });
181
+ }, [maxDate, minDate, direction]);
182
+ const handleSelect = useCallback(date => {
183
+ setInternalSelectedDate(prevDate => {
184
+ let onChangePayload = null;
185
+ let newInternalSelectedDate;
186
+ if (type === CalendarType.Single) {
187
+ onChangePayload = date;
188
+ newInternalSelectedDate = date;
189
+ } else if (type === CalendarType.Multiple) {
190
+ const prevSelectedDates = prevDate;
191
+ // Selects or unselects date , depending on if it is already selected.
192
+ if (prevSelectedDates.some(d => isSameDay(d, date))) {
193
+ newInternalSelectedDate = prevSelectedDates.filter(d => !isSameDay(d, date));
194
+ } else {
195
+ newInternalSelectedDate = [...prevSelectedDates, date];
196
+ }
197
+ onChangePayload = newInternalSelectedDate;
198
+ } else if (type === CalendarType.Interval) {
199
+ const prevSelectedDateInterval = prevDate;
200
+ const updateInterval = (start, end) => {
201
+ const newInterval = {
202
+ start,
203
+ end
204
+ };
205
+ onChangePayload = newInterval;
206
+ newInternalSelectedDate = newInterval;
207
+ };
208
+
209
+ // Sets first selection as interval start.
210
+ if (!prevSelectedDateInterval) {
211
+ updateInterval(date);
212
+ } else if (prevSelectedDateInterval.start && !prevSelectedDateInterval.end) {
213
+ // Sets second selection as interval start, if it is earlier than the previous interval start.
214
+ // Else sets it as interval end.
215
+ if (date < prevSelectedDateInterval.start) {
216
+ updateInterval(date);
217
+ } else {
218
+ updateInterval(prevSelectedDateInterval.start, date);
219
+ }
220
+ } else {
221
+ // Resets interval if a third date is selected.
222
+ updateInterval(date);
223
+ }
224
+ }
225
+ if (typeof onChange === 'function' && onChangePayload) {
226
+ onChange(onChangePayload);
227
+ }
228
+ return newInternalSelectedDate;
229
+ });
230
+ }, [type, onChange]);
231
+ const handleAnimationFinished = () => {
232
+ setDirection(() => undefined);
233
+ };
234
+ const ShouldShowLeftArrow = useMemo(() => {
235
+ if (!currentDate) {
236
+ return false;
237
+ }
238
+ return !isSameMonth(currentDate, minDate);
239
+ }, [currentDate, minDate]);
240
+ const ShouldShowRightArrow = useMemo(() => {
241
+ if (!currentDate) {
242
+ return false;
243
+ }
244
+ return !isSameMonth(currentDate, maxDate);
245
+ }, [currentDate, maxDate]);
246
+ return /*#__PURE__*/React.createElement(StyledCalendar, {
247
+ ref: calendarRef,
248
+ $isDisabled: isDisabled
249
+ }, ShouldShowLeftArrow ? /*#__PURE__*/React.createElement(StyledCalendarIconWrapper, {
250
+ onClick: handleLeftArrowClick
251
+ }, /*#__PURE__*/React.createElement("div", {
252
+ // TODO Use styled-components instead of inline styles
253
+ style: {
254
+ display: 'flex',
255
+ flexDirection: 'row',
256
+ flexWrap: 'nowrap',
257
+ height: 'fit-content'
258
+ }
259
+ }, showMonthYearPickers && /*#__PURE__*/React.createElement(StyledPseudoMonthYearPicker, null, /*#__PURE__*/React.createElement(ComboBox, {
260
+ lists: [{
261
+ list: []
262
+ }],
263
+ placeholder: ""
264
+ })), /*#__PURE__*/React.createElement(Icon, {
265
+ icons: ['fa fa-angle-left']
266
+ }))) : /*#__PURE__*/React.createElement(StyledCalendarIconWrapperPseudo, null), currentDate && /*#__PURE__*/React.createElement(MonthWrapper, {
267
+ shouldRenderTwo: shouldRenderTwoMonths,
268
+ currentDate: currentDate,
269
+ width: width,
270
+ locale: locale,
271
+ direction: direction,
272
+ customThumbColors: customThumbColors,
273
+ onSelect: handleSelect,
274
+ selectedDate: internalSelectedDate,
275
+ highlightedDates: highlightedDates,
276
+ categories: categories,
277
+ onAnimationFinished: handleAnimationFinished,
278
+ minDate: minDate,
279
+ maxDate: maxDate,
280
+ type: type,
281
+ disabledDates: disabledDates,
282
+ setCurrentDate: setCurrentDate,
283
+ shouldShowHighlightsInMonthOverlay: shouldShowHighlightsInMonthOverlay,
284
+ showMonthYearPickers: showMonthYearPickers
285
+ }), ShouldShowRightArrow ? /*#__PURE__*/React.createElement(StyledCalendarIconWrapper, {
286
+ onClick: handleRightArrowClick
287
+ }, /*#__PURE__*/React.createElement("div", {
288
+ // TODO Use styled-components instead of inline styles
289
+ style: {
290
+ display: 'flex',
291
+ flexDirection: 'row',
292
+ flexWrap: 'nowrap',
293
+ height: 'fit-content'
294
+ }
295
+ }, showMonthYearPickers && /*#__PURE__*/React.createElement(StyledPseudoMonthYearPicker, null, /*#__PURE__*/React.createElement(ComboBox, {
296
+ lists: [{
297
+ list: []
298
+ }],
299
+ placeholder: ""
300
+ })), /*#__PURE__*/React.createElement(Icon, {
301
+ icons: ['fa fa-angle-right']
302
+ }))) : /*#__PURE__*/React.createElement(StyledCalendarIconWrapperPseudo, null));
303
+ };
304
+ Calendar.displayName = 'Calendar';
305
+ export default Calendar;
306
+ //# sourceMappingURL=Calendar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Calendar.js","names":["ComboBox","Icon","Language","React","useCallback","useEffect","useMemo","useRef","useState","CalendarType","getNewDate","getYearsBetween","isDateInRange","addYears","differenceInCalendarMonths","isSameDay","isSameMonth","isWithinInterval","subYears","StyledCalendar","StyledCalendarIconWrapper","StyledCalendarIconWrapperPseudo","StyledPseudoMonthYearPicker","MonthWrapper","DEFAULT_MAX_DATE","Date","DEFAULT_MIN_DATE","Calendar","_ref","locale","German","maxDate","minDate","highlightedDates","onChange","customThumbColors","selectedDate","selectedDates","selectedDateInterval","categories","isDisabled","type","Single","shouldShowHighlightsInMonthOverlay","disabledDates","showMonthYearPickers","showMonthYearPickersProp","onShownDatesChange","currentDate","setCurrentDate","shouldRenderTwoMonths","setShouldRenderTwoMonths","internalSelectedDate","setInternalSelectedDate","Multiple","undefined","direction","setDirection","width","setWidth","hasMultipleMonths","hasMultipleYears","length","calendarRef","start","getFullYear","getMonth","end","bounds","isDisabledDate","some","disabledDate","isDateInBounds","console","warn","disabledSelectedDates","datesOutsideOfBounds","filteredDates","filter","date","push","Interval","intervalIncludesDisabledDate","intervalIsInBounds","current","resizeObserver","ResizeObserver","entries","observedWidth","contentRect","observe","disconnect","prevDate","handleLeftArrowClick","newDate","handleRightArrowClick","handleSelect","onChangePayload","newInternalSelectedDate","prevSelectedDates","d","prevSelectedDateInterval","updateInterval","newInterval","handleAnimationFinished","ShouldShowLeftArrow","ShouldShowRightArrow","createElement","ref","$isDisabled","onClick","style","display","flexDirection","flexWrap","height","lists","list","placeholder","icons","shouldRenderTwo","onSelect","onAnimationFinished","displayName"],"sources":["../../../../src/components/calendar/Calendar.tsx"],"sourcesContent":["import { ComboBox, Icon } from '@chayns-components/core';\nimport { Language } from 'chayns-api';\nimport React, { FC, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport {\n CalendarType,\n Categories,\n CustomThumbColors,\n DateInterval,\n HighlightedDates,\n} from '../../types/calendar';\nimport { getNewDate, getYearsBetween, isDateInRange } from '../../utils/calendar';\nimport {\n addYears,\n differenceInCalendarMonths,\n isSameDay,\n isSameMonth,\n isWithinInterval,\n subYears,\n} from '../../utils/date';\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 * Custom colors for the thumb.\n */\n customThumbColors?: CustomThumbColors;\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?: Language;\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 * Whether the highlighted dates should be displayed for the greyed month overlay days.\n */\n shouldShowHighlightsInMonthOverlay?: boolean;\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 * Function to be executed when the shown dates change. Returns the start of the displayed month and the end of the last displayed month (since depending on the available widths, there are one or two months displayed).\n @param { start: Date, end: Date }\n */\n onShownDatesChange?: (dates: { start: Date; end: Date }) => 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 = Language.German,\n maxDate = DEFAULT_MAX_DATE,\n minDate = DEFAULT_MIN_DATE,\n highlightedDates,\n onChange,\n customThumbColors,\n selectedDate,\n selectedDates,\n selectedDateInterval,\n categories,\n isDisabled,\n type = CalendarType.Single,\n shouldShowHighlightsInMonthOverlay = true,\n disabledDates = [],\n showMonthYearPickers: showMonthYearPickersProp,\n onShownDatesChange = () => {},\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' | undefined>();\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 if (currentDate) {\n const start = new Date(currentDate.getFullYear(), currentDate.getMonth(), 1);\n\n if (shouldRenderTwoMonths) {\n const end = new Date(currentDate.getFullYear(), currentDate.getMonth() + 2, 0);\n onShownDatesChange({\n start,\n end,\n });\n } else {\n const end = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 0);\n onShownDatesChange({\n start,\n end,\n });\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [currentDate, shouldRenderTwoMonths]);\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 setCurrentDate((prevDate) =>\n isDateInRange({ minDate, maxDate, currentDate: prevDate || new Date() }),\n );\n }, [maxDate, minDate]);\n\n const handleLeftArrowClick = useCallback(() => {\n if (direction) return;\n\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, direction]);\n\n const handleRightArrowClick = useCallback(() => {\n if (direction) return;\n\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, direction]);\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;\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 customThumbColors={customThumbColors}\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 shouldShowHighlightsInMonthOverlay={shouldShowHighlightsInMonthOverlay}\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,SAASA,QAAQ,EAAEC,IAAI,QAAQ,yBAAyB;AACxD,SAASC,QAAQ,QAAQ,YAAY;AACrC,OAAOC,KAAK,IAAQC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AACpF,SACIC,YAAY,QAKT,sBAAsB;AAC7B,SAASC,UAAU,EAAEC,eAAe,EAAEC,aAAa,QAAQ,sBAAsB;AACjF,SACIC,QAAQ,EACRC,0BAA0B,EAC1BC,SAAS,EACTC,WAAW,EACXC,gBAAgB,EAChBC,QAAQ,QACL,kBAAkB;AACzB,SACIC,cAAc,EACdC,yBAAyB,EACzBC,+BAA+B,EAC/BC,2BAA2B,QACxB,mBAAmB;AAC1B,OAAOC,YAAY,MAAM,8BAA8B;AAiGvD,MAAMC,gBAAgB,GAAGX,QAAQ,CAAC,IAAIY,IAAI,CAAC,CAAC,EAAE,CAAC,C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AAE,CAE1B,CAAC;AAEzB,CAAC;AAEDM,QAAQ,CAACgG,WAAW,GAAG,UAAU;AAEjC,eAAehG,QAAQ","ignoreList":[]}
@@ -0,0 +1,33 @@
1
+ import styled from 'styled-components';
2
+ export const StyledCalendar = styled.div`
3
+ display: flex;
4
+ width: 100%;
5
+ opacity: ${_ref => {
6
+ let {
7
+ $isDisabled
8
+ } = _ref;
9
+ return $isDisabled ? 0.5 : 1;
10
+ }};
11
+ pointer-events: ${_ref2 => {
12
+ let {
13
+ $isDisabled
14
+ } = _ref2;
15
+ return $isDisabled ? 'none' : undefined;
16
+ }};
17
+ user-select: none;
18
+ `;
19
+ export const StyledCalendarIconWrapper = styled.div`
20
+ cursor: pointer;
21
+ z-index: 2;
22
+ `;
23
+ export const StyledCalendarIconWrapperPseudo = styled.div`
24
+ width: 15px;
25
+ `;
26
+ export const StyledPseudoMonthYearPicker = styled.div`
27
+ height: fit-content;
28
+ width: 0;
29
+ overflow: hidden;
30
+ pointer-events: none;
31
+ user-select: none;
32
+ `;
33
+ //# sourceMappingURL=Calendar.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Calendar.styles.js","names":["styled","StyledCalendar","div","_ref","$isDisabled","_ref2","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,OAAOA,MAAM,MAAM,mBAAmB;AAItC,OAAO,MAAMC,cAAc,GAAGD,MAAM,CAACE,GAAwB;AAC7D;AACA;AACA,eAAeC,IAAA;EAAA,IAAC;IAAEC;EAAY,CAAC,GAAAD,IAAA;EAAA,OAAMC,WAAW,GAAG,GAAG,GAAG,CAAC;AAAA,CAAC;AAC3D,sBAAsBC,KAAA;EAAA,IAAC;IAAED;EAAY,CAAC,GAAAC,KAAA;EAAA,OAAMD,WAAW,GAAG,MAAM,GAAGE,SAAS;AAAA,CAAC;AAC7E;AACA,CAAC;AAED,OAAO,MAAMC,yBAAyB,GAAGP,MAAM,CAACE,GAAG;AACnD;AACA;AACA,CAAC;AAED,OAAO,MAAMM,+BAA+B,GAAGR,MAAM,CAACE,GAAG;AACzD;AACA,CAAC;AAED,OAAO,MAAMO,2BAA2B,GAAGT,MAAM,CAACE,GAAG;AACrD;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
@@ -0,0 +1,150 @@
1
+ import React, { useEffect, useMemo, useState } from 'react';
2
+ import { getMonthAndYear, getNewDate } from '../../../utils/calendar';
3
+ import Month from './month/Month';
4
+ import { StyledMonthWrapper, StyledMotionWrapper } from './MonthWrapper.styles';
5
+ const MonthWrapper = _ref => {
6
+ let {
7
+ locale,
8
+ currentDate,
9
+ highlightedDates,
10
+ selectedDate,
11
+ onSelect,
12
+ categories,
13
+ direction,
14
+ onAnimationFinished,
15
+ shouldRenderTwo,
16
+ width,
17
+ customThumbColors,
18
+ isDisabled,
19
+ minDate,
20
+ maxDate,
21
+ shouldShowHighlightsInMonthOverlay,
22
+ type,
23
+ disabledDates,
24
+ setCurrentDate,
25
+ showMonthYearPickers
26
+ } = _ref;
27
+ const [content, setContent] = useState();
28
+ const [hoveringDay, setHoveringDay] = useState(null);
29
+ const monthHeight = useMemo(() => width / (shouldRenderTwo ? 2 : 1), [width, shouldRenderTwo]);
30
+ useEffect(() => {
31
+ setContent(() => {
32
+ // Initial render of months
33
+ const items = [];
34
+ for (let i = -1; i < 3; i++) {
35
+ const date = getNewDate(i, currentDate);
36
+ const {
37
+ month,
38
+ year
39
+ } = getMonthAndYear(date);
40
+ items.push(/*#__PURE__*/React.createElement(Month, {
41
+ height: monthHeight,
42
+ key: `${month}-${year}`,
43
+ month: month,
44
+ year: year,
45
+ locale: locale,
46
+ onSelect: onSelect,
47
+ highlightedDates: highlightedDates,
48
+ shouldShowHighlightsInMonthOverlay: shouldShowHighlightsInMonthOverlay,
49
+ categories: categories,
50
+ selectedDate: selectedDate,
51
+ minDate: minDate,
52
+ maxDate: maxDate,
53
+ type: type,
54
+ customThumbColors: customThumbColors,
55
+ hoveringDay: hoveringDay,
56
+ setHoveringDay: setHoveringDay,
57
+ disabledDates: disabledDates,
58
+ setCurrentDate: setCurrentDate,
59
+ displayIndex: i,
60
+ showMonthYearPickers: showMonthYearPickers
61
+ }));
62
+ }
63
+ return items;
64
+ });
65
+ // eslint-disable-next-line react-hooks/exhaustive-deps
66
+ }, [monthHeight]);
67
+ useEffect(() => {
68
+ // Doesn't update props until animation is completed
69
+ if (direction) return;
70
+ setContent(prevState => (prevState ?? []).map((element, index) => {
71
+ const date = getNewDate(index - 1, currentDate);
72
+ const {
73
+ month,
74
+ year
75
+ } = getMonthAndYear(date);
76
+ return {
77
+ ...element,
78
+ props: {
79
+ ...element.props,
80
+ categories,
81
+ disabledDates,
82
+ displayIndex: index - 1,
83
+ highlightedDates,
84
+ hoveringDay,
85
+ locale,
86
+ onSelect,
87
+ shouldShowHighlightsInMonthOverlay,
88
+ maxDate,
89
+ minDate,
90
+ month,
91
+ customThumbColors,
92
+ selectedDate,
93
+ setCurrentDate,
94
+ setHoveringDay,
95
+ showMonthYearPickers,
96
+ type,
97
+ year
98
+ }
99
+ };
100
+ }));
101
+ }, [customThumbColors, categories, currentDate, direction, disabledDates, highlightedDates, hoveringDay, locale, onAnimationFinished, onSelect, maxDate, minDate, selectedDate, setCurrentDate, setHoveringDay, showMonthYearPickers, type, shouldShowHighlightsInMonthOverlay]);
102
+ const animate = useMemo(() => {
103
+ if (shouldRenderTwo) {
104
+ switch (true) {
105
+ case direction === 'left':
106
+ return {
107
+ x: '0%'
108
+ };
109
+ case direction === 'right':
110
+ return {
111
+ x: '-100%'
112
+ };
113
+ default:
114
+ return {
115
+ x: '-50%'
116
+ };
117
+ }
118
+ } else {
119
+ switch (true) {
120
+ case direction === 'left':
121
+ return {
122
+ x: '0%'
123
+ };
124
+ case direction === 'right':
125
+ return {
126
+ x: '-200%'
127
+ };
128
+ default:
129
+ return {
130
+ x: '-100%'
131
+ };
132
+ }
133
+ }
134
+ }, [direction, shouldRenderTwo]);
135
+ return /*#__PURE__*/React.createElement(StyledMonthWrapper, {
136
+ $height: monthHeight,
137
+ $width: width
138
+ }, /*#__PURE__*/React.createElement(StyledMotionWrapper, {
139
+ animate: animate,
140
+ $isDisabled: isDisabled,
141
+ transition: {
142
+ type: 'tween',
143
+ duration: !direction ? 0 : 0.2
144
+ },
145
+ onAnimationComplete: onAnimationFinished
146
+ }, content));
147
+ };
148
+ MonthWrapper.displayName = 'MonthWrapper';
149
+ export default MonthWrapper;
150
+ //# sourceMappingURL=MonthWrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MonthWrapper.js","names":["React","useEffect","useMemo","useState","getMonthAndYear","getNewDate","Month","StyledMonthWrapper","StyledMotionWrapper","MonthWrapper","_ref","locale","currentDate","highlightedDates","selectedDate","onSelect","categories","direction","onAnimationFinished","shouldRenderTwo","width","customThumbColors","isDisabled","minDate","maxDate","shouldShowHighlightsInMonthOverlay","type","disabledDates","setCurrentDate","showMonthYearPickers","content","setContent","hoveringDay","setHoveringDay","monthHeight","items","i","date","month","year","push","createElement","height","key","displayIndex","prevState","map","element","index","props","animate","x","$height","$width","$isDisabled","transition","duration","onAnimationComplete","displayName"],"sources":["../../../../../src/components/calendar/month-wrapper/MonthWrapper.tsx"],"sourcesContent":["import type { MotionProps } from 'framer-motion';\nimport React, { FC, useEffect, useMemo, useState, type ReactElement } from 'react';\nimport {\n CalendarType,\n Categories, CustomThumbColors,\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';\nimport {Language} from \"chayns-api\";\n\nexport type MonthWrapperProps = {\n locale: Language;\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 shouldShowHighlightsInMonthOverlay: boolean;\n showMonthYearPickers: boolean;\n customThumbColors?: CustomThumbColors;\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,customThumbColors,\n isDisabled,\n minDate,\n maxDate,\n shouldShowHighlightsInMonthOverlay,\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(() => {\n // Initial render of months\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 shouldShowHighlightsInMonthOverlay={shouldShowHighlightsInMonthOverlay}\n categories={categories}\n selectedDate={selectedDate}\n minDate={minDate}\n maxDate={maxDate}\n type={type}\n customThumbColors={customThumbColors}\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 // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [monthHeight]);\n\n useEffect(() => {\n // Doesn't update props until animation is completed\n if (direction) return;\n\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 disabledDates,\n displayIndex: index - 1,\n highlightedDates,\n hoveringDay,\n locale,\n onSelect,\n shouldShowHighlightsInMonthOverlay,\n maxDate,\n minDate,\n month,\n customThumbColors,\n selectedDate,\n setCurrentDate,\n setHoveringDay,\n showMonthYearPickers,\n type,\n year,\n } as ReactElement,\n };\n }),\n );\n }, [\n customThumbColors,\n categories,\n currentDate,\n direction,\n disabledDates,\n highlightedDates,\n hoveringDay,\n locale,\n onAnimationFinished,\n onSelect,\n maxDate,\n minDate,\n selectedDate,\n setCurrentDate,\n setHoveringDay,\n showMonthYearPickers,\n type,\n shouldShowHighlightsInMonthOverlay,\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 = 'MonthWrapper';\n\nexport default MonthWrapper;\n"],"mappings":"AACA,OAAOA,KAAK,IAAQC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAA2B,OAAO;AAOlF,SAASC,eAAe,EAAEC,UAAU,QAAQ,yBAAyB;AACrE,OAAOC,KAAK,MAAM,eAAe;AACjC,SAASC,kBAAkB,EAAEC,mBAAmB,QAAQ,uBAAuB;AAyB/E,MAAMC,YAAmC,GAAGC,IAAA,IAmBtC;EAAA,IAnBuC;IACzCC,MAAM;IACNC,WAAW;IACXC,gBAAgB;IAChBC,YAAY;IACZC,QAAQ;IACRC,UAAU;IACVC,SAAS;IACTC,mBAAmB;IACnBC,eAAe;IACfC,KAAK;IAACC,iBAAiB;IACvBC,UAAU;IACVC,OAAO;IACPC,OAAO;IACPC,kCAAkC;IAClCC,IAAI;IACJC,aAAa;IACbC,cAAc;IACdC;EACJ,CAAC,GAAAnB,IAAA;EACG,MAAM,CAACoB,OAAO,EAAEC,UAAU,CAAC,GAAG5B,QAAQ,CAAiB,CAAC;EAExD,MAAM,CAAC6B,WAAW,EAAEC,cAAc,CAAC,GAAG9B,QAAQ,CAAc,IAAI,CAAC;EAEjE,MAAM+B,WAAW,GAAGhC,OAAO,CAAC,MAAMkB,KAAK,IAAID,eAAe,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAACC,KAAK,EAAED,eAAe,CAAC,CAAC;EAE9FlB,SAAS,CAAC,MAAM;IACZ8B,UAAU,CAAC,MAAM;MACb;MACA,MAAMI,KAAqB,GAAG,EAAE;MAEhC,KAAK,IAAIC,CAAC,GAAG,CAAC,CAAC,EAAEA,CAAC,GAAG,CAAC,EAAEA,CAAC,EAAE,EAAE;QACzB,MAAMC,IAAI,GAAGhC,UAAU,CAAC+B,CAAC,EAAExB,WAAW,CAAC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AAkB;IAAC6C,OAAO,EAAElB,WAAY;IAACmB,MAAM,EAAEjC;EAAM,gBACpDpB,KAAA,CAAAyC,aAAA,CAACjC,mBAAmB;IAChB0C,OAAO,EAAEA,OAAQ;IACjBI,WAAW,EAAEhC,UAAW;IACxBiC,UAAU,EAAE;MACR7B,IAAI,EAAE,OAAO;MACb8B,QAAQ,EAAE,CAACvC,SAAS,GAAG,CAAC,GAAG;IAC/B,CAAE;IACFwC,mBAAmB,EAAEvC;EAAoB,GAExCY,OACgB,CACL,CAAC;AAE7B,CAAC;AAEDrB,YAAY,CAACiD,WAAW,GAAG,cAAc;AAEzC,eAAejD,YAAY","ignoreList":[]}
@@ -0,0 +1,22 @@
1
+ import { motion } from 'framer-motion';
2
+ import styled from 'styled-components';
3
+ export const StyledMonthWrapper = styled.div`
4
+ width: ${_ref => {
5
+ let {
6
+ $width
7
+ } = _ref;
8
+ return $width;
9
+ }}px;
10
+ overflow-x: clip;
11
+ height: ${_ref2 => {
12
+ let {
13
+ $height
14
+ } = _ref2;
15
+ return $height;
16
+ }}px;
17
+ `;
18
+ export const StyledMotionWrapper = styled(motion.div)`
19
+ display: flex;
20
+ height: 100%;
21
+ `;
22
+ //# sourceMappingURL=MonthWrapper.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MonthWrapper.styles.js","names":["motion","styled","StyledMonthWrapper","div","_ref","$width","_ref2","$height","StyledMotionWrapper"],"sources":["../../../../../src/components/calendar/month-wrapper/MonthWrapper.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport { motion } from 'framer-motion';\nimport styled from 'styled-components';\n\ntype StyledMonthWrapperProps = WithTheme<{ $height: number; $width: number }>;\n\nexport const StyledMonthWrapper = styled.div<StyledMonthWrapperProps>`\n width: ${({ $width }) => $width}px;\n overflow-x: clip;\n height: ${({ $height }) => $height}px;\n`;\n\ntype StyledMotionWrapperProps = { $isDisabled?: boolean };\n\nexport const StyledMotionWrapper = styled(motion.div)<StyledMotionWrapperProps>`\n display: flex;\n height: 100%;\n`;\n"],"mappings":"AACA,SAASA,MAAM,QAAQ,eAAe;AACtC,OAAOC,MAAM,MAAM,mBAAmB;AAItC,OAAO,MAAMC,kBAAkB,GAAGD,MAAM,CAACE,GAA4B;AACrE,aAAaC,IAAA;EAAA,IAAC;IAAEC;EAAO,CAAC,GAAAD,IAAA;EAAA,OAAKC,MAAM;AAAA;AACnC;AACA,cAAcC,KAAA;EAAA,IAAC;IAAEC;EAAQ,CAAC,GAAAD,KAAA;EAAA,OAAKC,OAAO;AAAA;AACtC,CAAC;AAID,OAAO,MAAMC,mBAAmB,GAAGP,MAAM,CAACD,MAAM,CAACG,GAAG,CAA2B;AAC/E;AACA;AACA,CAAC","ignoreList":[]}