@chayns-components/date 5.0.0-beta.1160 → 5.0.0-beta.1162
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/esm/components/calendar/Calendar.js +18 -19
- package/lib/esm/components/calendar/Calendar.js.map +1 -1
- package/lib/esm/components/calendar/Calendar.styles.js +6 -12
- package/lib/esm/components/calendar/Calendar.styles.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/MonthWrapper.js +21 -22
- package/lib/esm/components/calendar/month-wrapper/MonthWrapper.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/MonthWrapper.styles.js +6 -12
- package/lib/esm/components/calendar/month-wrapper/MonthWrapper.styles.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/month/Month.js +50 -53
- package/lib/esm/components/calendar/month-wrapper/month/Month.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/month/Month.styles.js +3 -6
- 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 +16 -17
- 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/day/Day.js +15 -16
- 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 +36 -53
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/Day.styles.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/category/Category.js +5 -8
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/category/Category.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/category/Category.styles.js +3 -6
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/category/Category.styles.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.js +3 -4
- package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.js +3 -6
- package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.styles.js +3 -6
- package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.styles.js.map +1 -1
- package/lib/esm/components/calendar/month-year-pickers/MonthYearPickers.js +10 -11
- package/lib/esm/components/calendar/month-year-pickers/MonthYearPickers.js.map +1 -1
- package/lib/esm/components/date-info/DateInfo.js +10 -11
- package/lib/esm/components/date-info/DateInfo.js.map +1 -1
- package/lib/esm/components/opening-times/OpeningTimes.js +24 -32
- package/lib/esm/components/opening-times/OpeningTimes.js.map +1 -1
- package/lib/esm/components/opening-times/OpeningTimes.styles.js +3 -6
- package/lib/esm/components/opening-times/OpeningTimes.styles.js.map +1 -1
- package/lib/esm/components/opening-times/hint-text/HintText.js +3 -4
- package/lib/esm/components/opening-times/hint-text/HintText.js.map +1 -1
- package/lib/esm/components/opening-times/hint-text/HintText.styles.js +6 -12
- package/lib/esm/components/opening-times/hint-text/HintText.styles.js.map +1 -1
- package/lib/esm/components/opening-times/opening-inputs/OpeningInputs.js +20 -25
- package/lib/esm/components/opening-times/opening-inputs/OpeningInputs.js.map +1 -1
- package/lib/esm/components/opening-times/opening-inputs/OpeningInputs.styles.js +7 -13
- package/lib/esm/components/opening-times/opening-inputs/OpeningInputs.styles.js.map +1 -1
- package/lib/esm/components/opening-times/opening-inputs/opening-input/OpeningInput.js +11 -12
- package/lib/esm/components/opening-times/opening-inputs/opening-input/OpeningInput.js.map +1 -1
- package/lib/esm/components/opening-times/opening-inputs/opening-input/OpeningInput.styles.js +6 -12
- package/lib/esm/components/opening-times/opening-inputs/opening-input/OpeningInput.styles.js.map +1 -1
- package/lib/esm/hooks/useDateInfo.js +10 -11
- package/lib/esm/hooks/useDateInfo.js.map +1 -1
- package/lib/esm/utils/calendar.js +9 -11
- package/lib/esm/utils/calendar.js.map +1 -1
- package/lib/esm/utils/dateInfo.js +20 -24
- package/lib/esm/utils/dateInfo.js.map +1 -1
- package/package.json +8 -8
|
@@ -8,25 +8,24 @@ import { StyledCalendar, StyledCalendarIconWrapper, StyledCalendarIconWrapperCon
|
|
|
8
8
|
import MonthWrapper from './month-wrapper/MonthWrapper';
|
|
9
9
|
const DEFAULT_MAX_DATE = addYears(new Date(), 1);
|
|
10
10
|
const DEFAULT_MIN_DATE = subYears(new Date(), 1);
|
|
11
|
-
const Calendar =
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
} = _ref;
|
|
11
|
+
const Calendar = ({
|
|
12
|
+
locale = Language.German,
|
|
13
|
+
maxDate = DEFAULT_MAX_DATE,
|
|
14
|
+
minDate = DEFAULT_MIN_DATE,
|
|
15
|
+
highlightedDates,
|
|
16
|
+
onChange,
|
|
17
|
+
customThumbColors,
|
|
18
|
+
selectedDate,
|
|
19
|
+
selectedDates,
|
|
20
|
+
selectedDateInterval,
|
|
21
|
+
categories,
|
|
22
|
+
isDisabled,
|
|
23
|
+
type = CalendarType.Single,
|
|
24
|
+
shouldShowHighlightsInMonthOverlay = true,
|
|
25
|
+
disabledDates = [],
|
|
26
|
+
showMonthYearPickers: showMonthYearPickersProp,
|
|
27
|
+
onShownDatesChange = () => {}
|
|
28
|
+
}) => {
|
|
30
29
|
const [currentDate, setCurrentDate] = useState();
|
|
31
30
|
const [shouldRenderTwoMonths, setShouldRenderTwoMonths] = useState(true);
|
|
32
31
|
const [internalSelectedDate, setInternalSelectedDate] = useState(() => type === CalendarType.Multiple ? [] : undefined);
|
|
@@ -1 +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","StyledCalendarIconWrapperContent","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","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 StyledCalendarIconWrapperContent,\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 <StyledCalendarIconWrapperContent>\n {showMonthYearPickers && (\n <StyledPseudoMonthYearPicker>\n <ComboBox lists={[{ list: [] }]} placeholder=\"\" />\n </StyledPseudoMonthYearPicker>\n )}\n <Icon icons={['fa fa-angle-left']} />\n </StyledCalendarIconWrapperContent>\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 <StyledCalendarIconWrapperContent>\n {showMonthYearPickers && (\n <StyledPseudoMonthYearPicker>\n <ComboBox lists={[{ list: [] }]} placeholder=\"\" />\n </StyledPseudoMonthYearPicker>\n )}\n <Icon icons={['fa fa-angle-right']} />\n </StyledCalendarIconWrapperContent>\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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A,CAAC5G,QAAQ;IAACgH,KAAK,EAAE,CAAC;MAAEC,IAAI,EAAE;IAAG,CAAC,CAAE;IAACC,WAAW,EAAC;EAAE,CAAE,CACxB,CAChC,eACD/G,KAAA,CAAAyG,aAAA,CAAC3G,IAAI;IAACkH,KAAK,EAAE,CAAC,mBAAmB;EAAE,CAAE,CACP,CACX,CAAC,gBAE5BhH,KAAA,CAAAyG,aAAA,CAACtF,+BAA+B,MAAE,CAE1B,CAAC;AAEzB,CAAC;AAEDM,QAAQ,CAAC2F,WAAW,GAAG,UAAU;AAEjC,eAAe3F,QAAQ","ignoreList":[]}
|
|
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","StyledCalendarIconWrapperContent","StyledCalendarIconWrapperPseudo","StyledPseudoMonthYearPicker","MonthWrapper","DEFAULT_MAX_DATE","Date","DEFAULT_MIN_DATE","Calendar","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","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 StyledCalendarIconWrapperContent,\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 <StyledCalendarIconWrapperContent>\n {showMonthYearPickers && (\n <StyledPseudoMonthYearPicker>\n <ComboBox lists={[{ list: [] }]} placeholder=\"\" />\n </StyledPseudoMonthYearPicker>\n )}\n <Icon icons={['fa fa-angle-left']} />\n </StyledCalendarIconWrapperContent>\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 <StyledCalendarIconWrapperContent>\n {showMonthYearPickers && (\n <StyledPseudoMonthYearPicker>\n <ComboBox lists={[{ list: [] }]} placeholder=\"\" />\n </StyledPseudoMonthYearPicker>\n )}\n <Icon icons={['fa fa-angle-right']} />\n </StyledCalendarIconWrapperContent>\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,gCAAgC,EAChCC,+BAA+B,EAC/BC,2BAA2B,QACxB,mBAAmB;AAC1B,OAAOC,YAAY,MAAM,8BAA8B;AAiGvD,MAAMC,gBAAgB,GAAGZ,QAAQ,CAAC,IAAIa,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;AAChD,MAAMC,gBAAgB,GAAGT,QAAQ,CAAC,IAAIQ,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;AAEhD,MAAME,QAA2B,GAAGA,CAAC;EACjCC,MAAM,GAAG3B,QAAQ,CAAC4B,MAAM;EACxBC,OAAO,GAAGN,gBAAgB;EAC1BO,OAAO,GAAGL,gBAAgB;EAC1BM,gBAAgB;EAChBC,QAAQ;EACRC,iBAAiB;EACjBC,YAAY;EACZC,aAAa;EACbC,oBAAoB;EACpBC,UAAU;EACVC,UAAU;EACVC,IAAI,GAAGhC,YAAY,CAACiC,MAAM;EAC1BC,kCAAkC,GAAG,IAAI;EACzCC,aAA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AmC;IACvEE,oBAAoB,EAAEA;EAAqB,CAC9C,CACJ,EACA6D,oBAAoB,gBACjBvG,KAAA,CAAAwG,aAAA,CAACvF,yBAAyB;IAAC0F,OAAO,EAAEf;EAAsB,gBACtD5F,KAAA,CAAAwG,aAAA,CAACtF,gCAAgC,QAC5BwB,oBAAoB,iBACjB1C,KAAA,CAAAwG,aAAA,CAACpF,2BAA2B,qBACxBpB,KAAA,CAAAwG,aAAA,CAAC3G,QAAQ;IAAC+G,KAAK,EAAE,CAAC;MAAEC,IAAI,EAAE;IAAG,CAAC,CAAE;IAACC,WAAW,EAAC;EAAE,CAAE,CACxB,CAChC,eACD9G,KAAA,CAAAwG,aAAA,CAAC1G,IAAI;IAACiH,KAAK,EAAE,CAAC,mBAAmB;EAAE,CAAE,CACP,CACX,CAAC,gBAE5B/G,KAAA,CAAAwG,aAAA,CAACrF,+BAA+B,MAAE,CAE1B,CAAC;AAEzB,CAAC;AAEDM,QAAQ,CAAC0F,WAAW,GAAG,UAAU;AAEjC,eAAe1F,QAAQ","ignoreList":[]}
|
|
@@ -2,18 +2,12 @@ import styled from 'styled-components';
|
|
|
2
2
|
export const StyledCalendar = styled.div`
|
|
3
3
|
display: flex;
|
|
4
4
|
width: 100%;
|
|
5
|
-
opacity: ${
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}};
|
|
11
|
-
pointer-events: ${_ref2 => {
|
|
12
|
-
let {
|
|
13
|
-
$isDisabled
|
|
14
|
-
} = _ref2;
|
|
15
|
-
return $isDisabled ? 'none' : undefined;
|
|
16
|
-
}};
|
|
5
|
+
opacity: ${({
|
|
6
|
+
$isDisabled
|
|
7
|
+
}) => $isDisabled ? 0.5 : 1};
|
|
8
|
+
pointer-events: ${({
|
|
9
|
+
$isDisabled
|
|
10
|
+
}) => $isDisabled ? 'none' : undefined};
|
|
17
11
|
user-select: none;
|
|
18
12
|
`;
|
|
19
13
|
export const StyledCalendarIconWrapper = styled.div`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Calendar.styles.js","names":["styled","StyledCalendar","div","
|
|
1
|
+
{"version":3,"file":"Calendar.styles.js","names":["styled","StyledCalendar","div","$isDisabled","undefined","StyledCalendarIconWrapper","StyledCalendarIconWrapperContent","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 StyledCalendarIconWrapperContent = styled.div`\n display: flex;\n flex-direction: row;\n flex-wrap: nowrap;\n height: fit-content;\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,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;AAED,OAAO,MAAMC,yBAAyB,GAAGL,MAAM,CAACE,GAAG;AACnD;AACA;AACA,CAAC;AAED,OAAO,MAAMI,gCAAgC,GAAGN,MAAM,CAACE,GAAG;AAC1D;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMK,+BAA+B,GAAGP,MAAM,CAACE,GAAG;AACzD;AACA,CAAC;AAED,OAAO,MAAMM,2BAA2B,GAAGR,MAAM,CAACE,GAAG;AACrD;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
|
|
@@ -2,28 +2,27 @@ import React, { useEffect, useMemo, useState } from 'react';
|
|
|
2
2
|
import { getMonthAndYear, getNewDate } from '../../../utils/calendar';
|
|
3
3
|
import Month from './month/Month';
|
|
4
4
|
import { StyledMonthWrapper, StyledMotionWrapper } from './MonthWrapper.styles';
|
|
5
|
-
const MonthWrapper =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
} = _ref;
|
|
5
|
+
const MonthWrapper = ({
|
|
6
|
+
locale,
|
|
7
|
+
currentDate,
|
|
8
|
+
highlightedDates,
|
|
9
|
+
selectedDate,
|
|
10
|
+
onSelect,
|
|
11
|
+
categories,
|
|
12
|
+
direction,
|
|
13
|
+
onAnimationFinished,
|
|
14
|
+
shouldRenderTwo,
|
|
15
|
+
width,
|
|
16
|
+
customThumbColors,
|
|
17
|
+
isDisabled,
|
|
18
|
+
minDate,
|
|
19
|
+
maxDate,
|
|
20
|
+
shouldShowHighlightsInMonthOverlay,
|
|
21
|
+
type,
|
|
22
|
+
disabledDates,
|
|
23
|
+
setCurrentDate,
|
|
24
|
+
showMonthYearPickers
|
|
25
|
+
}) => {
|
|
27
26
|
const [content, setContent] = useState();
|
|
28
27
|
const [hoveringDay, setHoveringDay] = useState(null);
|
|
29
28
|
const monthHeight = useMemo(() => width / (shouldRenderTwo ? 2 : 1), [width, shouldRenderTwo]);
|
|
@@ -1 +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 { Language } from 'chayns-api';\nimport type { MotionProps } from 'motion/react';\nimport React, { FC, useEffect, useMemo, useState, type ReactElement } from 'react';\nimport {\n CalendarType,\n Categories,\n 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';\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,\n 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":"AAEA,OAAOA,KAAK,IAAQC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAA2B,OAAO;AAQlF,SAASC,eAAe,EAAEC,UAAU,QAAQ,yBAAyB;AACrE,OAAOC,KAAK,MAAM,eAAe;AACjC,SAASC,kBAAkB,EAAEC,mBAAmB,QAAQ,uBAAuB;AAwB/E,MAAMC,YAAmC,GAAGC,IAAA,IAoBtC;EAAA,IApBuC;IACzCC,MAAM;IACNC,WAAW;IACXC,gBAAgB;IAChBC,YAAY;IACZC,QAAQ;IACRC,UAAU;IACVC,SAAS;IACTC,mBAAmB;IACnBC,eAAe;IACfC,KAAK;IACLC,iBAAiB;IACjBC,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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C;QACzB;UACI,OAAO;YAAEA,CAAC,EAAE;UAAO,CAAC;MAC5B;IACJ,CAAC,MAAM;MACH,QAAQ,IAAI;QACR,KAAKlC,SAAS,KAAK,MAAM;UACrB,OAAO;YAAEkC,CAAC,EAAE;UAAK,CAAC;QACtB,KAAKlC,SAAS,KAAK,OAAO;UACtB,OAAO;YAAEkC,CAAC,EAAE;UAAQ,CAAC;QACzB;UACI,OAAO;YAAEA,CAAC,EAAE;UAAQ,CAAC;MAC7B;IACJ;EACJ,CAAC,EAAE,CAAClC,SAAS,EAAEE,eAAe,CAAC,CAAC;EAEhC,oBACInB,KAAA,CAAAyC,aAAA,CAAClC,kBAAkB;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":[]}
|
|
1
|
+
{"version":3,"file":"MonthWrapper.js","names":["React","useEffect","useMemo","useState","getMonthAndYear","getNewDate","Month","StyledMonthWrapper","StyledMotionWrapper","MonthWrapper","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 { Language } from 'chayns-api';\nimport type { MotionProps } from 'motion/react';\nimport React, { FC, useEffect, useMemo, useState, type ReactElement } from 'react';\nimport {\n CalendarType,\n Categories,\n 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';\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,\n 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":"AAEA,OAAOA,KAAK,IAAQC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAA2B,OAAO;AAQlF,SAASC,eAAe,EAAEC,UAAU,QAAQ,yBAAyB;AACrE,OAAOC,KAAK,MAAM,eAAe;AACjC,SAASC,kBAAkB,EAAEC,mBAAmB,QAAQ,uBAAuB;AAwB/E,MAAMC,YAAmC,GAAGA,CAAC;EACzCC,MAAM;EACNC,WAAW;EACXC,gBAAgB;EAChBC,YAAY;EACZC,QAAQ;EACRC,UAAU;EACVC,SAAS;EACTC,mBAAmB;EACnBC,eAAe;EACfC,KAAK;EACLC,iBAAiB;EACjBC,UAAU;EACVC,OAAO;EACPC,OAAO;EACPC,kCAAkC;EAClCC,IAAI;EACJC,aAAa;EACbC,cAAc;EACdC;AACJ,CAAC,KAAK;EACF,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAG3B,QAAQ,CAAiB,CAAC;EAExD,MAAM,CAAC4B,WAAW,EAAEC,cAAc,CAAC,GAAG7B,QAAQ,CAAc,IAAI,CAAC;EAEjE,MAAM8B,WAAW,GAAG/B,OAAO,CAAC,MAAMiB,KAAK,IAAID,eAAe,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAACC,KAAK,EAAED,eAAe,CAAC,CAAC;EAE9FjB,SAAS,CAAC,MAAM;IACZ6B,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,GAAG/B,UAAU,CAAC8B,CAAC,EAAExB,WAAW,CAAC;QAEvC,MAA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C,OAAO,EAAElB,WAAY;IAACmB,MAAM,EAAEjC;EAAM,gBACpDnB,KAAA,CAAAwC,aAAA,CAAChC,mBAAmB;IAChByC,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;AAEDpB,YAAY,CAACgD,WAAW,GAAG,cAAc;AAEzC,eAAehD,YAAY","ignoreList":[]}
|
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
import { motion } from 'motion/react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
export const StyledMonthWrapper = styled.div`
|
|
4
|
-
width: ${
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} = _ref;
|
|
8
|
-
return $width;
|
|
9
|
-
}}px;
|
|
4
|
+
width: ${({
|
|
5
|
+
$width
|
|
6
|
+
}) => $width}px;
|
|
10
7
|
overflow-x: clip;
|
|
11
|
-
height: ${
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} = _ref2;
|
|
15
|
-
return $height;
|
|
16
|
-
}}px;
|
|
8
|
+
height: ${({
|
|
9
|
+
$height
|
|
10
|
+
}) => $height}px;
|
|
17
11
|
`;
|
|
18
12
|
export const StyledMotionWrapper = styled(motion.div)`
|
|
19
13
|
display: flex;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MonthWrapper.styles.js","names":["motion","styled","StyledMonthWrapper","div","
|
|
1
|
+
{"version":3,"file":"MonthWrapper.styles.js","names":["motion","styled","StyledMonthWrapper","div","$width","$height","StyledMotionWrapper"],"sources":["../../../../../src/components/calendar/month-wrapper/MonthWrapper.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport { motion } from 'motion/react';\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,cAAc;AACrC,OAAOC,MAAM,MAAM,mBAAmB;AAItC,OAAO,MAAMC,kBAAkB,GAAGD,MAAM,CAACE,GAA4B;AACrE,aAAa,CAAC;EAAEC;AAAO,CAAC,KAAKA,MAAM;AACnC;AACA,cAAc,CAAC;EAAEC;AAAQ,CAAC,KAAKA,OAAO;AACtC,CAAC;AAID,OAAO,MAAMC,mBAAmB,GAAGL,MAAM,CAACD,MAAM,CAACG,GAAG,CAA2B;AAC/E;AACA;AACA,CAAC","ignoreList":[]}
|
|
@@ -3,59 +3,56 @@ import MonthYearPickers from '../../month-year-pickers/MonthYearPickers';
|
|
|
3
3
|
import DayWrapper from './day-wrapper/DayWrapper';
|
|
4
4
|
import { StyledMonth, StyledMonthHead } from './Month.styles';
|
|
5
5
|
import WeekdayWrapper from './weekday-wrapper/WeekdayWrapper';
|
|
6
|
-
const Month =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
disabledDates: disabledDates
|
|
57
|
-
}));
|
|
58
|
-
};
|
|
6
|
+
const Month = ({
|
|
7
|
+
month,
|
|
8
|
+
year,
|
|
9
|
+
locale,
|
|
10
|
+
highlightedDates,
|
|
11
|
+
selectedDate,
|
|
12
|
+
onSelect,
|
|
13
|
+
categories,
|
|
14
|
+
height,
|
|
15
|
+
minDate,
|
|
16
|
+
maxDate,
|
|
17
|
+
customThumbColors,
|
|
18
|
+
shouldShowHighlightsInMonthOverlay,
|
|
19
|
+
type,
|
|
20
|
+
hoveringDay,
|
|
21
|
+
setHoveringDay,
|
|
22
|
+
disabledDates,
|
|
23
|
+
setCurrentDate,
|
|
24
|
+
displayIndex,
|
|
25
|
+
showMonthYearPickers
|
|
26
|
+
}) => /*#__PURE__*/React.createElement(StyledMonth, {
|
|
27
|
+
$height: height
|
|
28
|
+
}, /*#__PURE__*/React.createElement(StyledMonthHead, null, /*#__PURE__*/React.createElement(MonthYearPickers, {
|
|
29
|
+
month: month,
|
|
30
|
+
year: year,
|
|
31
|
+
locale: locale,
|
|
32
|
+
minDate: minDate,
|
|
33
|
+
maxDate: maxDate,
|
|
34
|
+
setCurrentDate: setCurrentDate,
|
|
35
|
+
displayIndex: displayIndex,
|
|
36
|
+
showMonthYearPickers: showMonthYearPickers
|
|
37
|
+
})), /*#__PURE__*/React.createElement(WeekdayWrapper, {
|
|
38
|
+
locale: locale
|
|
39
|
+
}), /*#__PURE__*/React.createElement(DayWrapper, {
|
|
40
|
+
key: `day-wrapper-${month}`,
|
|
41
|
+
categories: categories,
|
|
42
|
+
selectedDate: selectedDate,
|
|
43
|
+
customThumbColors: customThumbColors,
|
|
44
|
+
month: month,
|
|
45
|
+
year: year,
|
|
46
|
+
onSelect: onSelect,
|
|
47
|
+
shouldShowHighlightsInMonthOverlay: shouldShowHighlightsInMonthOverlay,
|
|
48
|
+
highlightedDates: highlightedDates,
|
|
49
|
+
minDate: minDate,
|
|
50
|
+
maxDate: maxDate,
|
|
51
|
+
type: type,
|
|
52
|
+
hoveringDay: hoveringDay,
|
|
53
|
+
setHoveringDay: setHoveringDay,
|
|
54
|
+
disabledDates: disabledDates
|
|
55
|
+
}));
|
|
59
56
|
Month.displayName = 'Month';
|
|
60
57
|
export default Month;
|
|
61
58
|
//# sourceMappingURL=Month.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Month.js","names":["React","MonthYearPickers","DayWrapper","StyledMonth","StyledMonthHead","WeekdayWrapper","Month","
|
|
1
|
+
{"version":3,"file":"Month.js","names":["React","MonthYearPickers","DayWrapper","StyledMonth","StyledMonthHead","WeekdayWrapper","Month","month","year","locale","highlightedDates","selectedDate","onSelect","categories","height","minDate","maxDate","customThumbColors","shouldShowHighlightsInMonthOverlay","type","hoveringDay","setHoveringDay","disabledDates","setCurrentDate","displayIndex","showMonthYearPickers","createElement","$height","key","displayName"],"sources":["../../../../../../src/components/calendar/month-wrapper/month/Month.tsx"],"sourcesContent":["import React, { FC } from 'react';\nimport {\n CalendarType,\n Categories,\n CustomThumbColors,\n DateInterval,\n EMonth,\n HighlightedDates,\n} from '../../../../types/calendar';\nimport MonthYearPickers from '../../month-year-pickers/MonthYearPickers';\nimport DayWrapper from './day-wrapper/DayWrapper';\nimport { StyledMonth, StyledMonthHead } from './Month.styles';\nimport WeekdayWrapper from './weekday-wrapper/WeekdayWrapper';\nimport { Language } from 'chayns-api';\n\nexport type MonthProps = {\n month: EMonth;\n year: number;\n locale: Language;\n highlightedDates?: HighlightedDates[];\n onSelect: (date: Date) => void;\n selectedDate?: Date | Date[] | DateInterval;\n categories?: Categories[];\n height: number;\n minDate: Date;\n maxDate: Date;\n type: CalendarType;\n hoveringDay: Date | null;\n setHoveringDay: (date: Date | null) => void;\n disabledDates: Date[];\n setCurrentDate: (date: Date) => void;\n displayIndex?: number;\n shouldShowHighlightsInMonthOverlay: boolean;\n customThumbColors?: CustomThumbColors;\n showMonthYearPickers: boolean;\n};\n\nconst Month: FC<MonthProps> = ({\n month,\n year,\n locale,\n highlightedDates,\n selectedDate,\n onSelect,\n categories,\n height,\n minDate,\n maxDate,\n customThumbColors,\n shouldShowHighlightsInMonthOverlay,\n type,\n hoveringDay,\n setHoveringDay,\n disabledDates,\n setCurrentDate,\n displayIndex,\n showMonthYearPickers,\n}) => (\n <StyledMonth $height={height}>\n <StyledMonthHead>\n <MonthYearPickers\n month={month}\n year={year}\n locale={locale}\n minDate={minDate}\n maxDate={maxDate}\n setCurrentDate={setCurrentDate}\n displayIndex={displayIndex}\n showMonthYearPickers={showMonthYearPickers}\n />\n </StyledMonthHead>\n <WeekdayWrapper locale={locale} />\n <DayWrapper\n key={`day-wrapper-${month}`}\n categories={categories}\n selectedDate={selectedDate}\n customThumbColors={customThumbColors}\n month={month}\n year={year}\n onSelect={onSelect}\n shouldShowHighlightsInMonthOverlay={shouldShowHighlightsInMonthOverlay}\n highlightedDates={highlightedDates}\n minDate={minDate}\n maxDate={maxDate}\n type={type}\n hoveringDay={hoveringDay}\n setHoveringDay={setHoveringDay}\n disabledDates={disabledDates}\n />\n </StyledMonth>\n);\n\nMonth.displayName = 'Month';\n\nexport default Month;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAc,OAAO;AASjC,OAAOC,gBAAgB,MAAM,2CAA2C;AACxE,OAAOC,UAAU,MAAM,0BAA0B;AACjD,SAASC,WAAW,EAAEC,eAAe,QAAQ,gBAAgB;AAC7D,OAAOC,cAAc,MAAM,kCAAkC;AAyB7D,MAAMC,KAAqB,GAAGA,CAAC;EAC3BC,KAAK;EACLC,IAAI;EACJC,MAAM;EACNC,gBAAgB;EAChBC,YAAY;EACZC,QAAQ;EACRC,UAAU;EACVC,MAAM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2
|
export const StyledMonth = styled.div`
|
|
3
|
-
height: ${
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} = _ref;
|
|
7
|
-
return $height;
|
|
8
|
-
}}px;
|
|
3
|
+
height: ${({
|
|
4
|
+
$height
|
|
5
|
+
}) => $height}px;
|
|
9
6
|
aspect-ratio: 1;
|
|
10
7
|
`;
|
|
11
8
|
export const StyledMonthHead = styled.div`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Month.styles.js","names":["styled","StyledMonth","div","
|
|
1
|
+
{"version":3,"file":"Month.styles.js","names":["styled","StyledMonth","div","$height","StyledMonthHead","StyledMonthName"],"sources":["../../../../../../src/components/calendar/month-wrapper/month/Month.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport styled from 'styled-components';\n\ntype StyledMonthProps = WithTheme<{ $height: number }>;\n\nexport const StyledMonth = styled.div<StyledMonthProps>`\n height: ${({ $height }) => $height}px;\n aspect-ratio: 1;\n`;\n\nexport const StyledMonthHead = styled.div`\n display: flex;\n align-items: center;\n justify-content: center;\n column-gap: 7px;\n`;\n\nexport const StyledMonthName = styled.div`\n font-weight: bold;\n text-align: center;\n user-select: none;\n`;\n"],"mappings":"AACA,OAAOA,MAAM,MAAM,mBAAmB;AAItC,OAAO,MAAMC,WAAW,GAAGD,MAAM,CAACE,GAAqB;AACvD,cAAc,CAAC;EAAEC;AAAQ,CAAC,KAAKA,OAAO;AACtC;AACA,CAAC;AAED,OAAO,MAAMC,eAAe,GAAGJ,MAAM,CAACE,GAAG;AACzC;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMG,eAAe,GAAGL,MAAM,CAACE,GAAG;AACzC;AACA;AACA;AACA,CAAC","ignoreList":[]}
|
|
@@ -4,23 +4,22 @@ import { findNextDate } from '../../../../../utils/calendar';
|
|
|
4
4
|
import Day from './day/Day';
|
|
5
5
|
import { StyledDayWrapper } from './DayWrapper.styles';
|
|
6
6
|
import { addDays, isAfter, isSameDay, isSameMonth, isWithinInterval, startOfMonth, startOfWeek } from '../../../../../utils/date';
|
|
7
|
-
const DayWrapper =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
} = _ref;
|
|
7
|
+
const DayWrapper = ({
|
|
8
|
+
month,
|
|
9
|
+
year,
|
|
10
|
+
highlightedDates,
|
|
11
|
+
onSelect,
|
|
12
|
+
selectedDate,
|
|
13
|
+
categories,
|
|
14
|
+
minDate,
|
|
15
|
+
maxDate,
|
|
16
|
+
customThumbColors,
|
|
17
|
+
type,
|
|
18
|
+
hoveringDay,
|
|
19
|
+
shouldShowHighlightsInMonthOverlay,
|
|
20
|
+
setHoveringDay,
|
|
21
|
+
disabledDates
|
|
22
|
+
}) => {
|
|
24
23
|
const dayOfCurrentMonth = useMemo(() => new Date(year, month - 1, 13), [month, year]);
|
|
25
24
|
const days = useMemo(() => {
|
|
26
25
|
const dateArray = [];
|