@chayns-components/date 5.0.0-beta.836 → 5.0.0-beta.838

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.
@@ -148,11 +148,10 @@ const Calendar = ({
148
148
  return () => {};
149
149
  }, []);
150
150
  (0, _react.useEffect)(() => {
151
- const date = new Date();
152
- setCurrentDate((0, _calendar2.isDateInRange)({
151
+ setCurrentDate(prevDate => (0, _calendar2.isDateInRange)({
153
152
  minDate,
154
153
  maxDate,
155
- currentDate: date
154
+ currentDate: prevDate || new Date()
156
155
  }));
157
156
  }, [maxDate, minDate]);
158
157
  const handleLeftArrowClick = (0, _react.useCallback)(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"Calendar.js","names":["_core","require","_dateFns","_locale","_react","_interopRequireWildcard","_calendar","_calendar2","_Calendar","_MonthWrapper","_interopRequireDefault","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","DEFAULT_MAX_DATE","addYears","Date","DEFAULT_MIN_DATE","subYears","Calendar","locale","de","maxDate","minDate","highlightedDates","onChange","selectedDate","selectedDates","selectedDateInterval","categories","isDisabled","type","CalendarType","Single","disabledDates","showMonthYearPickers","showMonthYearPickersProp","onShownDatesChange","currentDate","setCurrentDate","useState","shouldRenderTwoMonths","setShouldRenderTwoMonths","internalSelectedDate","setInternalSelectedDate","Multiple","undefined","direction","setDirection","width","setWidth","useMemo","hasMultipleMonths","differenceInCalendarMonths","hasMultipleYears","getYearsBetween","length","calendarRef","useRef","useEffect","start","getFullYear","getMonth","end","bounds","isDisabledDate","some","disabledDate","isSameDay","isDateInBounds","isWithinInterval","console","warn","disabledSelectedDates","datesOutsideOfBounds","filteredDates","filter","date","push","Interval","intervalIncludesDisabledDate","intervalIsInBounds","current","resizeObserver","ResizeObserver","entries","observedWidth","contentRect","observe","disconnect","isDateInRange","handleLeftArrowClick","useCallback","prevDate","newDate","getNewDate","handleRightArrowClick","handleSelect","onChangePayload","newInternalSelectedDate","prevSelectedDates","d","prevSelectedDateInterval","updateInterval","newInterval","handleAnimationFinished","ShouldShowLeftArrow","isSameMonth","ShouldShowRightArrow","createElement","StyledCalendar","ref","$isDisabled","StyledCalendarIconWrapper","onClick","style","display","flexDirection","flexWrap","height","StyledPseudoMonthYearPicker","ComboBox","lists","list","placeholder","Icon","icons","StyledCalendarIconWrapperPseudo","shouldRenderTwo","onSelect","onAnimationFinished","displayName","_default","exports"],"sources":["../../../../src/components/calendar/Calendar.tsx"],"sourcesContent":["import { ComboBox, Icon } from '@chayns-components/core';\nimport {\n addYears,\n differenceInCalendarMonths,\n isSameDay,\n isSameMonth,\n isWithinInterval,\n subYears,\n type Locale,\n} from 'date-fns';\nimport { de } from 'date-fns/locale';\nimport React, { FC, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport type { Categories, DateInterval, HighlightedDates } from '../../types/calendar';\nimport { CalendarType } from '../../types/calendar';\nimport { getNewDate, getYearsBetween, isDateInRange } from '../../utils/calendar';\nimport {\n StyledCalendar,\n StyledCalendarIconWrapper,\n StyledCalendarIconWrapperPseudo,\n StyledPseudoMonthYearPicker,\n} from './Calendar.styles';\nimport MonthWrapper from './month-wrapper/MonthWrapper';\n\ninterface BaseProps {\n /**\n * An array to group dates into a category.\n */\n categories?: Categories[];\n /**\n * An array with dates and corresponding styles to highlight.\n */\n highlightedDates?: HighlightedDates[];\n /**\n * To disable the Calendar\n */\n isDisabled?: boolean;\n /**\n * The locale language to format the dates.\n */\n locale?: Locale;\n /**\n * The maximum date that can be selected.\n */\n maxDate?: Date;\n /**\n * The minimum date that can be selected.\n */\n minDate?: Date;\n /**\n * An array of dates that should be disabled.\n */\n disabledDates?: Date[];\n /**\n * Shows the month and year pickers, if there are multiple months/years to select from.\n */\n showMonthYearPickers?: boolean;\n /**\n * Function to be executed when the selected date, dates or date interval change.\n * @param date\n */\n onChange?: (date: Date | Date[] | DateInterval) => void;\n /**\n * 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 = de,\n maxDate = DEFAULT_MAX_DATE,\n minDate = DEFAULT_MIN_DATE,\n highlightedDates,\n onChange,\n selectedDate,\n selectedDates,\n selectedDateInterval,\n categories,\n isDisabled,\n type = CalendarType.Single,\n disabledDates = [],\n showMonthYearPickers: showMonthYearPickersProp,\n 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'>();\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 }, [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 const date = new Date();\n\n setCurrentDate(isDateInRange({ minDate, maxDate, currentDate: date }));\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 = undefined;\n\n if (type === CalendarType.Single) {\n onChangePayload = date;\n newInternalSelectedDate = date;\n } else if (type === CalendarType.Multiple) {\n const prevSelectedDates = prevDate as Date[];\n // Selects or unselects date , depending on if it is already selected.\n if (prevSelectedDates.some((d) => isSameDay(d, date))) {\n newInternalSelectedDate = prevSelectedDates.filter(\n (d) => !isSameDay(d, date),\n );\n } else {\n newInternalSelectedDate = [...prevSelectedDates, date];\n }\n\n onChangePayload = newInternalSelectedDate;\n } else if (type === CalendarType.Interval) {\n const prevSelectedDateInterval = prevDate as DateInterval;\n\n const updateInterval = (start: Date, end?: Date): void => {\n const newInterval = { start, end };\n onChangePayload = newInterval;\n newInternalSelectedDate = newInterval;\n };\n\n // Sets first selection as interval start.\n if (!prevSelectedDateInterval) {\n updateInterval(date);\n } else if (prevSelectedDateInterval.start && !prevSelectedDateInterval.end) {\n // Sets second selection as interval start, if it is earlier than the previous interval start.\n // Else sets it as interval end.\n if (date < prevSelectedDateInterval.start) {\n updateInterval(date);\n } else {\n updateInterval(prevSelectedDateInterval.start, date);\n }\n } else {\n // Resets interval if a third date is selected.\n updateInterval(date);\n }\n }\n\n if (typeof onChange === 'function' && onChangePayload) {\n onChange(onChangePayload);\n }\n\n return newInternalSelectedDate;\n });\n },\n [type, onChange],\n );\n\n const handleAnimationFinished = () => {\n setDirection(undefined);\n };\n\n const ShouldShowLeftArrow = useMemo(() => {\n if (!currentDate) {\n return false;\n }\n\n return !isSameMonth(currentDate, minDate);\n }, [currentDate, minDate]);\n\n const ShouldShowRightArrow = useMemo(() => {\n if (!currentDate) {\n return false;\n }\n\n return !isSameMonth(currentDate, maxDate);\n }, [currentDate, maxDate]);\n\n return (\n <StyledCalendar ref={calendarRef} $isDisabled={isDisabled}>\n {ShouldShowLeftArrow ? (\n <StyledCalendarIconWrapper onClick={handleLeftArrowClick}>\n <div // TODO Use styled-components instead of inline styles\n style={{\n display: 'flex',\n flexDirection: 'row',\n flexWrap: 'nowrap',\n height: 'fit-content',\n }}\n >\n {showMonthYearPickers && (\n <StyledPseudoMonthYearPicker>\n <ComboBox lists={[{ list: [] }]} placeholder=\"\" />\n </StyledPseudoMonthYearPicker>\n )}\n <Icon icons={['fa fa-angle-left']} />\n </div>\n </StyledCalendarIconWrapper>\n ) : (\n <StyledCalendarIconWrapperPseudo />\n )}\n {currentDate && (\n <MonthWrapper\n shouldRenderTwo={shouldRenderTwoMonths}\n currentDate={currentDate}\n width={width}\n locale={locale}\n direction={direction}\n onSelect={handleSelect}\n selectedDate={internalSelectedDate}\n highlightedDates={highlightedDates}\n categories={categories}\n onAnimationFinished={handleAnimationFinished}\n minDate={minDate}\n maxDate={maxDate}\n type={type}\n disabledDates={disabledDates}\n setCurrentDate={setCurrentDate}\n showMonthYearPickers={showMonthYearPickers}\n />\n )}\n {ShouldShowRightArrow ? (\n <StyledCalendarIconWrapper onClick={handleRightArrowClick}>\n <div // TODO Use styled-components instead of inline styles\n style={{\n display: 'flex',\n flexDirection: 'row',\n flexWrap: 'nowrap',\n height: 'fit-content',\n }}\n >\n {showMonthYearPickers && (\n <StyledPseudoMonthYearPicker>\n <ComboBox lists={[{ list: [] }]} placeholder=\"\" />\n </StyledPseudoMonthYearPicker>\n )}\n <Icon icons={['fa fa-angle-right']} />\n </div>\n </StyledCalendarIconWrapper>\n ) : (\n <StyledCalendarIconWrapperPseudo />\n )}\n </StyledCalendar>\n );\n};\n\nCalendar.displayName = 'Calendar';\n\nexport default Calendar;\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AASA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAC,uBAAA,CAAAJ,OAAA;AAEA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AAMA,IAAAQ,aAAA,GAAAC,sBAAA,CAAAT,OAAA;AAAwD,SAAAS,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAAH,CAAA,6BAAAI,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAD,wBAAA,YAAAA,CAAAH,CAAA,WAAAA,CAAA,GAAAM,CAAA,GAAAD,CAAA,KAAAL,CAAA;AAAA,SAAAN,wBAAAM,CAAA,EAAAK,CAAA,SAAAA,CAAA,IAAAL,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAE,OAAA,EAAAF,CAAA,QAAAM,CAAA,GAAAH,wBAAA,CAAAE,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAC,GAAA,CAAAP,CAAA,UAAAM,CAAA,CAAAE,GAAA,CAAAR,CAAA,OAAAS,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAf,CAAA,oBAAA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AQ;IACjBS,IAAI,EAAEA,IAAK;IACXG,aAAa,EAAEA,aAAc;IAC7BK,cAAc,EAAEA,cAAe;IAC/BJ,oBAAoB,EAAEA;EAAqB,CAC9C,CACJ,EACAyE,oBAAoB,gBACjBzH,MAAA,CAAAS,OAAA,CAAAiH,aAAA,CAACtH,SAAA,CAAA0H,yBAAyB;IAACC,OAAO,EAAElB;EAAsB,gBACtD7G,MAAA,CAAAS,OAAA,CAAAiH,aAAA;IAAK;IACDM,KAAK,EAAE;MACHC,OAAO,EAAE,MAAM;MACfC,aAAa,EAAE,KAAK;MACpBC,QAAQ,EAAE,QAAQ;MAClBC,MAAM,EAAE;IACZ;EAAE,GAEDpF,oBAAoB,iBACjBhD,MAAA,CAAAS,OAAA,CAAAiH,aAAA,CAACtH,SAAA,CAAAiI,2BAA2B,qBACxBrI,MAAA,CAAAS,OAAA,CAAAiH,aAAA,CAAC9H,KAAA,CAAA0I,QAAQ;IAACC,KAAK,EAAE,CAAC;MAAEC,IAAI,EAAE;IAAG,CAAC,CAAE;IAACC,WAAW,EAAC;EAAE,CAAE,CACxB,CAChC,eACDzI,MAAA,CAAAS,OAAA,CAAAiH,aAAA,CAAC9H,KAAA,CAAA8I,IAAI;IAACC,KAAK,EAAE,CAAC,mBAAmB;EAAE,CAAE,CACpC,CACkB,CAAC,gBAE5B3I,MAAA,CAAAS,OAAA,CAAAiH,aAAA,CAACtH,SAAA,CAAAwI,+BAA+B,MAAE,CAE1B,CAAC;AAEzB,CAAC;AAED5G,QAAQ,CAACgH,WAAW,GAAG,UAAU;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAzI,OAAA,GAEnBuB,QAAQ","ignoreList":[]}
1
+ {"version":3,"file":"Calendar.js","names":["_core","require","_dateFns","_locale","_react","_interopRequireWildcard","_calendar","_calendar2","_Calendar","_MonthWrapper","_interopRequireDefault","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","DEFAULT_MAX_DATE","addYears","Date","DEFAULT_MIN_DATE","subYears","Calendar","locale","de","maxDate","minDate","highlightedDates","onChange","selectedDate","selectedDates","selectedDateInterval","categories","isDisabled","type","CalendarType","Single","disabledDates","showMonthYearPickers","showMonthYearPickersProp","onShownDatesChange","currentDate","setCurrentDate","useState","shouldRenderTwoMonths","setShouldRenderTwoMonths","internalSelectedDate","setInternalSelectedDate","Multiple","undefined","direction","setDirection","width","setWidth","useMemo","hasMultipleMonths","differenceInCalendarMonths","hasMultipleYears","getYearsBetween","length","calendarRef","useRef","useEffect","start","getFullYear","getMonth","end","bounds","isDisabledDate","some","disabledDate","isSameDay","isDateInBounds","isWithinInterval","console","warn","disabledSelectedDates","datesOutsideOfBounds","filteredDates","filter","date","push","Interval","intervalIncludesDisabledDate","intervalIsInBounds","current","resizeObserver","ResizeObserver","entries","observedWidth","contentRect","observe","disconnect","prevDate","isDateInRange","handleLeftArrowClick","useCallback","newDate","getNewDate","handleRightArrowClick","handleSelect","onChangePayload","newInternalSelectedDate","prevSelectedDates","d","prevSelectedDateInterval","updateInterval","newInterval","handleAnimationFinished","ShouldShowLeftArrow","isSameMonth","ShouldShowRightArrow","createElement","StyledCalendar","ref","$isDisabled","StyledCalendarIconWrapper","onClick","style","display","flexDirection","flexWrap","height","StyledPseudoMonthYearPicker","ComboBox","lists","list","placeholder","Icon","icons","StyledCalendarIconWrapperPseudo","shouldRenderTwo","onSelect","onAnimationFinished","displayName","_default","exports"],"sources":["../../../../src/components/calendar/Calendar.tsx"],"sourcesContent":["import { ComboBox, Icon } from '@chayns-components/core';\nimport {\n addYears,\n differenceInCalendarMonths,\n isSameDay,\n isSameMonth,\n isWithinInterval,\n subYears,\n type Locale,\n} from 'date-fns';\nimport { de } from 'date-fns/locale';\nimport React, { FC, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport type { Categories, DateInterval, HighlightedDates } from '../../types/calendar';\nimport { CalendarType } from '../../types/calendar';\nimport { getNewDate, getYearsBetween, isDateInRange } from '../../utils/calendar';\nimport {\n StyledCalendar,\n StyledCalendarIconWrapper,\n StyledCalendarIconWrapperPseudo,\n StyledPseudoMonthYearPicker,\n} from './Calendar.styles';\nimport MonthWrapper from './month-wrapper/MonthWrapper';\n\ninterface BaseProps {\n /**\n * An array to group dates into a category.\n */\n categories?: Categories[];\n /**\n * An array with dates and corresponding styles to highlight.\n */\n highlightedDates?: HighlightedDates[];\n /**\n * To disable the Calendar\n */\n isDisabled?: boolean;\n /**\n * The locale language to format the dates.\n */\n locale?: Locale;\n /**\n * The maximum date that can be selected.\n */\n maxDate?: Date;\n /**\n * The minimum date that can be selected.\n */\n minDate?: Date;\n /**\n * An array of dates that should be disabled.\n */\n disabledDates?: Date[];\n /**\n * Shows the month and year pickers, if there are multiple months/years to select from.\n */\n showMonthYearPickers?: boolean;\n /**\n * Function to be executed when the selected date, dates or date interval change.\n * @param date\n */\n onChange?: (date: Date | Date[] | DateInterval) => void;\n /**\n * 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 = de,\n maxDate = DEFAULT_MAX_DATE,\n minDate = DEFAULT_MIN_DATE,\n highlightedDates,\n onChange,\n selectedDate,\n selectedDates,\n selectedDateInterval,\n categories,\n isDisabled,\n type = CalendarType.Single,\n disabledDates = [],\n showMonthYearPickers: showMonthYearPickersProp,\n 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'>();\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 }, [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) => isDateInRange({ minDate, maxDate, currentDate: prevDate || new Date() }));\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 = undefined;\n\n if (type === CalendarType.Single) {\n onChangePayload = date;\n newInternalSelectedDate = date;\n } else if (type === CalendarType.Multiple) {\n const prevSelectedDates = prevDate as Date[];\n // Selects or unselects date , depending on if it is already selected.\n if (prevSelectedDates.some((d) => isSameDay(d, date))) {\n newInternalSelectedDate = prevSelectedDates.filter(\n (d) => !isSameDay(d, date),\n );\n } else {\n newInternalSelectedDate = [...prevSelectedDates, date];\n }\n\n onChangePayload = newInternalSelectedDate;\n } else if (type === CalendarType.Interval) {\n const prevSelectedDateInterval = prevDate as DateInterval;\n\n const updateInterval = (start: Date, end?: Date): void => {\n const newInterval = { start, end };\n onChangePayload = newInterval;\n newInternalSelectedDate = newInterval;\n };\n\n // Sets first selection as interval start.\n if (!prevSelectedDateInterval) {\n updateInterval(date);\n } else if (prevSelectedDateInterval.start && !prevSelectedDateInterval.end) {\n // Sets second selection as interval start, if it is earlier than the previous interval start.\n // Else sets it as interval end.\n if (date < prevSelectedDateInterval.start) {\n updateInterval(date);\n } else {\n updateInterval(prevSelectedDateInterval.start, date);\n }\n } else {\n // Resets interval if a third date is selected.\n updateInterval(date);\n }\n }\n\n if (typeof onChange === 'function' && onChangePayload) {\n onChange(onChangePayload);\n }\n\n return newInternalSelectedDate;\n });\n },\n [type, onChange],\n );\n\n const handleAnimationFinished = () => {\n setDirection(undefined);\n };\n\n const ShouldShowLeftArrow = useMemo(() => {\n if (!currentDate) {\n return false;\n }\n\n return !isSameMonth(currentDate, minDate);\n }, [currentDate, minDate]);\n\n const ShouldShowRightArrow = useMemo(() => {\n if (!currentDate) {\n return false;\n }\n\n return !isSameMonth(currentDate, maxDate);\n }, [currentDate, maxDate]);\n\n return (\n <StyledCalendar ref={calendarRef} $isDisabled={isDisabled}>\n {ShouldShowLeftArrow ? (\n <StyledCalendarIconWrapper onClick={handleLeftArrowClick}>\n <div // TODO Use styled-components instead of inline styles\n style={{\n display: 'flex',\n flexDirection: 'row',\n flexWrap: 'nowrap',\n height: 'fit-content',\n }}\n >\n {showMonthYearPickers && (\n <StyledPseudoMonthYearPicker>\n <ComboBox lists={[{ list: [] }]} placeholder=\"\" />\n </StyledPseudoMonthYearPicker>\n )}\n <Icon icons={['fa fa-angle-left']} />\n </div>\n </StyledCalendarIconWrapper>\n ) : (\n <StyledCalendarIconWrapperPseudo />\n )}\n {currentDate && (\n <MonthWrapper\n shouldRenderTwo={shouldRenderTwoMonths}\n currentDate={currentDate}\n width={width}\n locale={locale}\n direction={direction}\n onSelect={handleSelect}\n selectedDate={internalSelectedDate}\n highlightedDates={highlightedDates}\n categories={categories}\n onAnimationFinished={handleAnimationFinished}\n minDate={minDate}\n maxDate={maxDate}\n type={type}\n disabledDates={disabledDates}\n setCurrentDate={setCurrentDate}\n showMonthYearPickers={showMonthYearPickers}\n />\n )}\n {ShouldShowRightArrow ? (\n <StyledCalendarIconWrapper onClick={handleRightArrowClick}>\n <div // TODO Use styled-components instead of inline styles\n style={{\n display: 'flex',\n flexDirection: 'row',\n flexWrap: 'nowrap',\n height: 'fit-content',\n }}\n >\n {showMonthYearPickers && (\n <StyledPseudoMonthYearPicker>\n <ComboBox lists={[{ list: [] }]} placeholder=\"\" />\n </StyledPseudoMonthYearPicker>\n )}\n <Icon icons={['fa fa-angle-right']} />\n </div>\n </StyledCalendarIconWrapper>\n ) : (\n <StyledCalendarIconWrapperPseudo />\n )}\n </StyledCalendar>\n );\n};\n\nCalendar.displayName = 'Calendar';\n\nexport default Calendar;\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AASA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAC,uBAAA,CAAAJ,OAAA;AAEA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AAMA,IAAAQ,aAAA,GAAAC,sBAAA,CAAAT,OAAA;AAAwD,SAAAS,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG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G,CAAC,CAAE;IAACC,WAAW,EAAC;EAAE,CAAE,CACxB,CAChC,eACDzI,MAAA,CAAAS,OAAA,CAAAiH,aAAA,CAAC9H,KAAA,CAAA8I,IAAI;IAACC,KAAK,EAAE,CAAC,mBAAmB;EAAE,CAAE,CACpC,CACkB,CAAC,gBAE5B3I,MAAA,CAAAS,OAAA,CAAAiH,aAAA,CAACtH,SAAA,CAAAwI,+BAA+B,MAAE,CAE1B,CAAC;AAEzB,CAAC;AAED5G,QAAQ,CAACgH,WAAW,GAAG,UAAU;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAzI,OAAA,GAEnBuB,QAAQ","ignoreList":[]}
@@ -140,11 +140,10 @@ const Calendar = _ref => {
140
140
  return () => {};
141
141
  }, []);
142
142
  useEffect(() => {
143
- const date = new Date();
144
- setCurrentDate(isDateInRange({
143
+ setCurrentDate(prevDate => isDateInRange({
145
144
  minDate,
146
145
  maxDate,
147
- currentDate: date
146
+ currentDate: prevDate || new Date()
148
147
  }));
149
148
  }, [maxDate, minDate]);
150
149
  const handleLeftArrowClick = useCallback(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"Calendar.js","names":["ComboBox","Icon","addYears","differenceInCalendarMonths","isSameDay","isSameMonth","isWithinInterval","subYears","de","React","useCallback","useEffect","useMemo","useRef","useState","CalendarType","getNewDate","getYearsBetween","isDateInRange","StyledCalendar","StyledCalendarIconWrapper","StyledCalendarIconWrapperPseudo","StyledPseudoMonthYearPicker","MonthWrapper","DEFAULT_MAX_DATE","Date","DEFAULT_MIN_DATE","Calendar","_ref","locale","maxDate","minDate","highlightedDates","onChange","selectedDate","selectedDates","selectedDateInterval","categories","isDisabled","type","Single","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","handleLeftArrowClick","prevDate","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 {\n addYears,\n differenceInCalendarMonths,\n isSameDay,\n isSameMonth,\n isWithinInterval,\n subYears,\n type Locale,\n} from 'date-fns';\nimport { de } from 'date-fns/locale';\nimport React, { FC, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport type { Categories, DateInterval, HighlightedDates } from '../../types/calendar';\nimport { CalendarType } from '../../types/calendar';\nimport { getNewDate, getYearsBetween, isDateInRange } from '../../utils/calendar';\nimport {\n StyledCalendar,\n StyledCalendarIconWrapper,\n StyledCalendarIconWrapperPseudo,\n StyledPseudoMonthYearPicker,\n} from './Calendar.styles';\nimport MonthWrapper from './month-wrapper/MonthWrapper';\n\ninterface BaseProps {\n /**\n * An array to group dates into a category.\n */\n categories?: Categories[];\n /**\n * An array with dates and corresponding styles to highlight.\n */\n highlightedDates?: HighlightedDates[];\n /**\n * To disable the Calendar\n */\n isDisabled?: boolean;\n /**\n * The locale language to format the dates.\n */\n locale?: Locale;\n /**\n * The maximum date that can be selected.\n */\n maxDate?: Date;\n /**\n * The minimum date that can be selected.\n */\n minDate?: Date;\n /**\n * An array of dates that should be disabled.\n */\n disabledDates?: Date[];\n /**\n * Shows the month and year pickers, if there are multiple months/years to select from.\n */\n showMonthYearPickers?: boolean;\n /**\n * Function to be executed when the selected date, dates or date interval change.\n * @param date\n */\n onChange?: (date: Date | Date[] | DateInterval) => void;\n /**\n * 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 = de,\n maxDate = DEFAULT_MAX_DATE,\n minDate = DEFAULT_MIN_DATE,\n highlightedDates,\n onChange,\n selectedDate,\n selectedDates,\n selectedDateInterval,\n categories,\n isDisabled,\n type = CalendarType.Single,\n disabledDates = [],\n showMonthYearPickers: showMonthYearPickersProp,\n 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'>();\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 }, [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 const date = new Date();\n\n setCurrentDate(isDateInRange({ minDate, maxDate, currentDate: date }));\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 = undefined;\n\n if (type === CalendarType.Single) {\n onChangePayload = date;\n newInternalSelectedDate = date;\n } else if (type === CalendarType.Multiple) {\n const prevSelectedDates = prevDate as Date[];\n // Selects or unselects date , depending on if it is already selected.\n if (prevSelectedDates.some((d) => isSameDay(d, date))) {\n newInternalSelectedDate = prevSelectedDates.filter(\n (d) => !isSameDay(d, date),\n );\n } else {\n newInternalSelectedDate = [...prevSelectedDates, date];\n }\n\n onChangePayload = newInternalSelectedDate;\n } else if (type === CalendarType.Interval) {\n const prevSelectedDateInterval = prevDate as DateInterval;\n\n const updateInterval = (start: Date, end?: Date): void => {\n const newInterval = { start, end };\n onChangePayload = newInterval;\n newInternalSelectedDate = newInterval;\n };\n\n // Sets first selection as interval start.\n if (!prevSelectedDateInterval) {\n updateInterval(date);\n } else if (prevSelectedDateInterval.start && !prevSelectedDateInterval.end) {\n // Sets second selection as interval start, if it is earlier than the previous interval start.\n // Else sets it as interval end.\n if (date < prevSelectedDateInterval.start) {\n updateInterval(date);\n } else {\n updateInterval(prevSelectedDateInterval.start, date);\n }\n } else {\n // Resets interval if a third date is selected.\n updateInterval(date);\n }\n }\n\n if (typeof onChange === 'function' && onChangePayload) {\n onChange(onChangePayload);\n }\n\n return newInternalSelectedDate;\n });\n },\n [type, onChange],\n );\n\n const handleAnimationFinished = () => {\n setDirection(undefined);\n };\n\n const ShouldShowLeftArrow = useMemo(() => {\n if (!currentDate) {\n return false;\n }\n\n return !isSameMonth(currentDate, minDate);\n }, [currentDate, minDate]);\n\n const ShouldShowRightArrow = useMemo(() => {\n if (!currentDate) {\n return false;\n }\n\n return !isSameMonth(currentDate, maxDate);\n }, [currentDate, maxDate]);\n\n return (\n <StyledCalendar ref={calendarRef} $isDisabled={isDisabled}>\n {ShouldShowLeftArrow ? (\n <StyledCalendarIconWrapper onClick={handleLeftArrowClick}>\n <div // TODO Use styled-components instead of inline styles\n style={{\n display: 'flex',\n flexDirection: 'row',\n flexWrap: 'nowrap',\n height: 'fit-content',\n }}\n >\n {showMonthYearPickers && (\n <StyledPseudoMonthYearPicker>\n <ComboBox lists={[{ list: [] }]} placeholder=\"\" />\n </StyledPseudoMonthYearPicker>\n )}\n <Icon icons={['fa fa-angle-left']} />\n </div>\n </StyledCalendarIconWrapper>\n ) : (\n <StyledCalendarIconWrapperPseudo />\n )}\n {currentDate && (\n <MonthWrapper\n shouldRenderTwo={shouldRenderTwoMonths}\n currentDate={currentDate}\n width={width}\n locale={locale}\n direction={direction}\n onSelect={handleSelect}\n selectedDate={internalSelectedDate}\n highlightedDates={highlightedDates}\n categories={categories}\n onAnimationFinished={handleAnimationFinished}\n minDate={minDate}\n maxDate={maxDate}\n type={type}\n disabledDates={disabledDates}\n setCurrentDate={setCurrentDate}\n showMonthYearPickers={showMonthYearPickers}\n />\n )}\n {ShouldShowRightArrow ? (\n <StyledCalendarIconWrapper onClick={handleRightArrowClick}>\n <div // TODO Use styled-components instead of inline styles\n style={{\n display: 'flex',\n flexDirection: 'row',\n flexWrap: 'nowrap',\n height: 'fit-content',\n }}\n >\n {showMonthYearPickers && (\n <StyledPseudoMonthYearPicker>\n <ComboBox lists={[{ list: [] }]} placeholder=\"\" />\n </StyledPseudoMonthYearPicker>\n )}\n <Icon icons={['fa fa-angle-right']} />\n </div>\n </StyledCalendarIconWrapper>\n ) : (\n <StyledCalendarIconWrapperPseudo />\n )}\n </StyledCalendar>\n );\n};\n\nCalendar.displayName = 'Calendar';\n\nexport default Calendar;\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,IAAI,QAAQ,yBAAyB;AACxD,SACIC,QAAQ,EACRC,0BAA0B,EAC1BC,SAAS,EACTC,WAAW,EACXC,gBAAgB,EAChBC,QAAQ,QAEL,UAAU;AACjB,SAASC,EAAE,QAAQ,iBAAiB;AACpC,OAAOC,KAAK,IAAQC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAEpF,SAASC,YAAY,QAAQ,sBAAsB;AACnD,SAASC,UAAU,EAAEC,eAAe,EAAEC,aAAa,QAAQ,sBAAsB;AACjF,SACIC,cAAc,EACdC,yBAAyB,EACzBC,+BAA+B,EAC/BC,2BAA2B,QACxB,mBAAmB;AAC1B,OAAOC,YAAY,MAAM,8BAA8B;AAyFvD,MAAMC,gBAAgB,GAAGtB,QAAQ,CAAC,IAAIuB,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;AAChD,MAAMC,gBAAgB,GAAGnB,QAAQ,CAAC,IAAIkB,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;AAEhD,MAAME,QAA2B,GAAGC,IAAA,IAe9B;EAAA,IAf+B;IACjCC,MAAM,GAAGrB,EAAE;IACXsB,OAAO,GAAGN,gBAAgB;IAC1BO,OAAO,GAAGL,gBAAgB;IAC1BM,gBAAgB;IAChBC,QAAQ;IACRC,YAAY;IACZC,aAAa;IACbC,oBAAoB;IACpBC,UAAU;IACVC,UAAU;IACVC,IAAI,GAAGxB,YAAY,CAAC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XE,aAAa,EAAEA,aAAc;IAC7BK,cAAc,EAAEA,cAAe;IAC/BJ,oBAAoB,EAAEA;EAAqB,CAC9C,CACJ,EACA6D,oBAAoB,gBACjB9F,KAAA,CAAA+F,aAAA,CAACpF,yBAAyB;IAACuF,OAAO,EAAEf;EAAsB,gBACtDnF,KAAA,CAAA+F,aAAA;IAAK;IACDI,KAAK,EAAE;MACHC,OAAO,EAAE,MAAM;MACfC,aAAa,EAAE,KAAK;MACpBC,QAAQ,EAAE,QAAQ;MAClBC,MAAM,EAAE;IACZ;EAAE,GAEDtE,oBAAoB,iBACjBjC,KAAA,CAAA+F,aAAA,CAAClF,2BAA2B,qBACxBb,KAAA,CAAA+F,aAAA,CAACxG,QAAQ;IAACiH,KAAK,EAAE,CAAC;MAAEC,IAAI,EAAE;IAAG,CAAC,CAAE;IAACC,WAAW,EAAC;EAAE,CAAE,CACxB,CAChC,eACD1G,KAAA,CAAA+F,aAAA,CAACvG,IAAI;IAACmH,KAAK,EAAE,CAAC,mBAAmB;EAAE,CAAE,CACpC,CACkB,CAAC,gBAE5B3G,KAAA,CAAA+F,aAAA,CAACnF,+BAA+B,MAAE,CAE1B,CAAC;AAEzB,CAAC;AAEDM,QAAQ,CAAC6F,WAAW,GAAG,UAAU;AAEjC,eAAe7F,QAAQ","ignoreList":[]}
1
+ {"version":3,"file":"Calendar.js","names":["ComboBox","Icon","addYears","differenceInCalendarMonths","isSameDay","isSameMonth","isWithinInterval","subYears","de","React","useCallback","useEffect","useMemo","useRef","useState","CalendarType","getNewDate","getYearsBetween","isDateInRange","StyledCalendar","StyledCalendarIconWrapper","StyledCalendarIconWrapperPseudo","StyledPseudoMonthYearPicker","MonthWrapper","DEFAULT_MAX_DATE","Date","DEFAULT_MIN_DATE","Calendar","_ref","locale","maxDate","minDate","highlightedDates","onChange","selectedDate","selectedDates","selectedDateInterval","categories","isDisabled","type","Single","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 {\n addYears,\n differenceInCalendarMonths,\n isSameDay,\n isSameMonth,\n isWithinInterval,\n subYears,\n type Locale,\n} from 'date-fns';\nimport { de } from 'date-fns/locale';\nimport React, { FC, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport type { Categories, DateInterval, HighlightedDates } from '../../types/calendar';\nimport { CalendarType } from '../../types/calendar';\nimport { getNewDate, getYearsBetween, isDateInRange } from '../../utils/calendar';\nimport {\n StyledCalendar,\n StyledCalendarIconWrapper,\n StyledCalendarIconWrapperPseudo,\n StyledPseudoMonthYearPicker,\n} from './Calendar.styles';\nimport MonthWrapper from './month-wrapper/MonthWrapper';\n\ninterface BaseProps {\n /**\n * An array to group dates into a category.\n */\n categories?: Categories[];\n /**\n * An array with dates and corresponding styles to highlight.\n */\n highlightedDates?: HighlightedDates[];\n /**\n * To disable the Calendar\n */\n isDisabled?: boolean;\n /**\n * The locale language to format the dates.\n */\n locale?: Locale;\n /**\n * The maximum date that can be selected.\n */\n maxDate?: Date;\n /**\n * The minimum date that can be selected.\n */\n minDate?: Date;\n /**\n * An array of dates that should be disabled.\n */\n disabledDates?: Date[];\n /**\n * Shows the month and year pickers, if there are multiple months/years to select from.\n */\n showMonthYearPickers?: boolean;\n /**\n * Function to be executed when the selected date, dates or date interval change.\n * @param date\n */\n onChange?: (date: Date | Date[] | DateInterval) => void;\n /**\n * 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 = de,\n maxDate = DEFAULT_MAX_DATE,\n minDate = DEFAULT_MIN_DATE,\n highlightedDates,\n onChange,\n selectedDate,\n selectedDates,\n selectedDateInterval,\n categories,\n isDisabled,\n type = CalendarType.Single,\n disabledDates = [],\n showMonthYearPickers: showMonthYearPickersProp,\n 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'>();\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 }, [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) => isDateInRange({ minDate, maxDate, currentDate: prevDate || new Date() }));\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 = undefined;\n\n if (type === CalendarType.Single) {\n onChangePayload = date;\n newInternalSelectedDate = date;\n } else if (type === CalendarType.Multiple) {\n const prevSelectedDates = prevDate as Date[];\n // Selects or unselects date , depending on if it is already selected.\n if (prevSelectedDates.some((d) => isSameDay(d, date))) {\n newInternalSelectedDate = prevSelectedDates.filter(\n (d) => !isSameDay(d, date),\n );\n } else {\n newInternalSelectedDate = [...prevSelectedDates, date];\n }\n\n onChangePayload = newInternalSelectedDate;\n } else if (type === CalendarType.Interval) {\n const prevSelectedDateInterval = prevDate as DateInterval;\n\n const updateInterval = (start: Date, end?: Date): void => {\n const newInterval = { start, end };\n onChangePayload = newInterval;\n newInternalSelectedDate = newInterval;\n };\n\n // Sets first selection as interval start.\n if (!prevSelectedDateInterval) {\n updateInterval(date);\n } else if (prevSelectedDateInterval.start && !prevSelectedDateInterval.end) {\n // Sets second selection as interval start, if it is earlier than the previous interval start.\n // Else sets it as interval end.\n if (date < prevSelectedDateInterval.start) {\n updateInterval(date);\n } else {\n updateInterval(prevSelectedDateInterval.start, date);\n }\n } else {\n // Resets interval if a third date is selected.\n updateInterval(date);\n }\n }\n\n if (typeof onChange === 'function' && onChangePayload) {\n onChange(onChangePayload);\n }\n\n return newInternalSelectedDate;\n });\n },\n [type, onChange],\n );\n\n const handleAnimationFinished = () => {\n setDirection(undefined);\n };\n\n const ShouldShowLeftArrow = useMemo(() => {\n if (!currentDate) {\n return false;\n }\n\n return !isSameMonth(currentDate, minDate);\n }, [currentDate, minDate]);\n\n const ShouldShowRightArrow = useMemo(() => {\n if (!currentDate) {\n return false;\n }\n\n return !isSameMonth(currentDate, maxDate);\n }, [currentDate, maxDate]);\n\n return (\n <StyledCalendar ref={calendarRef} $isDisabled={isDisabled}>\n {ShouldShowLeftArrow ? (\n <StyledCalendarIconWrapper onClick={handleLeftArrowClick}>\n <div // TODO Use styled-components instead of inline styles\n style={{\n display: 'flex',\n flexDirection: 'row',\n flexWrap: 'nowrap',\n height: 'fit-content',\n }}\n >\n {showMonthYearPickers && (\n <StyledPseudoMonthYearPicker>\n <ComboBox lists={[{ list: [] }]} placeholder=\"\" />\n </StyledPseudoMonthYearPicker>\n )}\n <Icon icons={['fa fa-angle-left']} />\n </div>\n </StyledCalendarIconWrapper>\n ) : (\n <StyledCalendarIconWrapperPseudo />\n )}\n {currentDate && (\n <MonthWrapper\n shouldRenderTwo={shouldRenderTwoMonths}\n currentDate={currentDate}\n width={width}\n locale={locale}\n direction={direction}\n onSelect={handleSelect}\n selectedDate={internalSelectedDate}\n highlightedDates={highlightedDates}\n categories={categories}\n onAnimationFinished={handleAnimationFinished}\n minDate={minDate}\n maxDate={maxDate}\n type={type}\n disabledDates={disabledDates}\n setCurrentDate={setCurrentDate}\n showMonthYearPickers={showMonthYearPickers}\n />\n )}\n {ShouldShowRightArrow ? (\n <StyledCalendarIconWrapper onClick={handleRightArrowClick}>\n <div // TODO Use styled-components instead of inline styles\n style={{\n display: 'flex',\n flexDirection: 'row',\n flexWrap: 'nowrap',\n height: 'fit-content',\n }}\n >\n {showMonthYearPickers && (\n <StyledPseudoMonthYearPicker>\n <ComboBox lists={[{ list: [] }]} placeholder=\"\" />\n </StyledPseudoMonthYearPicker>\n )}\n <Icon icons={['fa fa-angle-right']} />\n </div>\n </StyledCalendarIconWrapper>\n ) : (\n <StyledCalendarIconWrapperPseudo />\n )}\n </StyledCalendar>\n );\n};\n\nCalendar.displayName = 'Calendar';\n\nexport default Calendar;\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,IAAI,QAAQ,yBAAyB;AACxD,SACIC,QAAQ,EACRC,0BAA0B,EAC1BC,SAAS,EACTC,WAAW,EACXC,gBAAgB,EAChBC,QAAQ,QAEL,UAAU;AACjB,SAASC,EAAE,QAAQ,iBAAiB;AACpC,OAAOC,KAAK,IAAQC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAEpF,SAASC,YAAY,QAAQ,sBAAsB;AACnD,SAASC,UAAU,EAAEC,eAAe,EAAEC,aAAa,QAAQ,sBAAsB;AACjF,SACIC,cAAc,EACdC,yBAAyB,EACzBC,+BAA+B,EAC/BC,2BAA2B,QACxB,mBAAmB;AAC1B,OAAOC,YAAY,MAAM,8BAA8B;AAyFvD,MAAMC,gBAAgB,GAAGtB,QAAQ,CAAC,IAAIuB,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;AAChD,MAAMC,gBAAgB,GAAGnB,QAAQ,CAAC,IAAIkB,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;AAEhD,MAAME,QAA2B,GAAGC,IAAA,IAe9B;EAAA,IAf+B;IACjCC,MAAM,GAAGrB,EAAE;IACXsB,OAAO,GAAGN,gBAAgB;IAC1BO,OAAO,GAAGL,gBA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AW;IACvBkF,mBAAmB,EAAElB,uBAAwB;IAC7CtE,OAAO,EAAEA,OAAQ;IACjBD,OAAO,EAAEA,OAAQ;IACjBS,IAAI,EAAEA,IAAK;IACXE,aAAa,EAAEA,aAAc;IAC7BK,cAAc,EAAEA,cAAe;IAC/BJ,oBAAoB,EAAEA;EAAqB,CAC9C,CACJ,EACA6D,oBAAoB,gBACjB9F,KAAA,CAAA+F,aAAA,CAACpF,yBAAyB;IAACuF,OAAO,EAAEf;EAAsB,gBACtDnF,KAAA,CAAA+F,aAAA;IAAK;IACDI,KAAK,EAAE;MACHC,OAAO,EAAE,MAAM;MACfC,aAAa,EAAE,KAAK;MACpBC,QAAQ,EAAE,QAAQ;MAClBC,MAAM,EAAE;IACZ;EAAE,GAEDtE,oBAAoB,iBACjBjC,KAAA,CAAA+F,aAAA,CAAClF,2BAA2B,qBACxBb,KAAA,CAAA+F,aAAA,CAACxG,QAAQ;IAACiH,KAAK,EAAE,CAAC;MAAEC,IAAI,EAAE;IAAG,CAAC,CAAE;IAACC,WAAW,EAAC;EAAE,CAAE,CACxB,CAChC,eACD1G,KAAA,CAAA+F,aAAA,CAACvG,IAAI;IAACmH,KAAK,EAAE,CAAC,mBAAmB;EAAE,CAAE,CACpC,CACkB,CAAC,gBAE5B3G,KAAA,CAAA+F,aAAA,CAACnF,+BAA+B,MAAE,CAE1B,CAAC;AAEzB,CAAC;AAEDM,QAAQ,CAAC6F,WAAW,GAAG,UAAU;AAEjC,eAAe7F,QAAQ","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chayns-components/date",
3
- "version": "5.0.0-beta.836",
3
+ "version": "5.0.0-beta.838",
4
4
  "description": "A set of beautiful React components for developing your own applications with chayns.",
5
5
  "sideEffects": false,
6
6
  "browserslist": [
@@ -69,7 +69,7 @@
69
69
  "typescript": "^5.6.2"
70
70
  },
71
71
  "dependencies": {
72
- "@chayns-components/core": "^5.0.0-beta.835",
72
+ "@chayns-components/core": "^5.0.0-beta.837",
73
73
  "date-fns": "^3.6.0",
74
74
  "uuid": "^10.0.0"
75
75
  },
@@ -83,5 +83,5 @@
83
83
  "publishConfig": {
84
84
  "access": "public"
85
85
  },
86
- "gitHead": "fb583966654269315123795c20217b7bf9f11961"
86
+ "gitHead": "964fb7be28251b7f224ccdf0da50aa894ecc1e80"
87
87
  }