@chayns-components/date 5.0.0-beta.914 → 5.0.0-beta.917
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/components/calendar/Calendar.js +2 -0
- package/lib/cjs/components/calendar/Calendar.js.map +1 -1
- package/lib/cjs/components/calendar/month-wrapper/MonthWrapper.js +4 -1
- package/lib/cjs/components/calendar/month-wrapper/MonthWrapper.js.map +1 -1
- package/lib/cjs/components/calendar/month-wrapper/month/Month.js +2 -0
- package/lib/cjs/components/calendar/month-wrapper/month/Month.js.map +1 -1
- package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.js +3 -1
- package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.js.map +1 -1
- package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/day/Day.js +2 -0
- package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/day/Day.js.map +1 -1
- package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/day/Day.styles.js +5 -3
- package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/day/Day.styles.js.map +1 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/types/calendar.js.map +1 -1
- package/lib/esm/components/calendar/Calendar.js +2 -0
- package/lib/esm/components/calendar/Calendar.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/MonthWrapper.js +4 -1
- package/lib/esm/components/calendar/month-wrapper/MonthWrapper.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/month/Month.js +2 -0
- package/lib/esm/components/calendar/month-wrapper/month/Month.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.js +3 -1
- 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 +2 -0
- 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 +5 -3
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/Day.styles.js.map +1 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/types/calendar.js.map +1 -1
- package/lib/types/components/calendar/Calendar.d.ts +5 -1
- package/lib/types/components/calendar/month-wrapper/MonthWrapper.d.ts +2 -1
- package/lib/types/components/calendar/month-wrapper/month/Month.d.ts +2 -1
- package/lib/types/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.d.ts +2 -1
- package/lib/types/components/calendar/month-wrapper/month/day-wrapper/day/Day.d.ts +2 -1
- package/lib/types/components/calendar/month-wrapper/month/day-wrapper/day/Day.styles.d.ts +2 -0
- package/lib/types/index.d.ts +1 -1
- package/lib/types/types/calendar.d.ts +14 -0
- package/package.json +6 -6
|
@@ -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","shouldShowHighlightsInMonthOverlay","disabledDates","showMonthYearPickers","showMonthYearPickersProp","onShownDatesChange","currentDate","setCurrentDate","shouldRenderTwoMonths","setShouldRenderTwoMonths","internalSelectedDate","setInternalSelectedDate","Multiple","undefined","direction","setDirection","width","setWidth","hasMultipleMonths","hasMultipleYears","length","calendarRef","start","getFullYear","getMonth","end","bounds","isDisabledDate","some","disabledDate","isDateInBounds","console","warn","disabledSelectedDates","datesOutsideOfBounds","filteredDates","filter","date","push","Interval","intervalIncludesDisabledDate","intervalIsInBounds","current","resizeObserver","ResizeObserver","entries","observedWidth","contentRect","observe","disconnect","prevDate","handleLeftArrowClick","newDate","handleRightArrowClick","handleSelect","onChangePayload","newInternalSelectedDate","prevSelectedDates","d","prevSelectedDateInterval","updateInterval","newInterval","handleAnimationFinished","ShouldShowLeftArrow","ShouldShowRightArrow","createElement","ref","$isDisabled","onClick","style","display","flexDirection","flexWrap","height","lists","list","placeholder","icons","shouldRenderTwo","onSelect","onAnimationFinished","displayName"],"sources":["../../../../src/components/calendar/Calendar.tsx"],"sourcesContent":["import { ComboBox, Icon } from '@chayns-components/core';\nimport {\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 * 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 = 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 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'>();\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) =>\n isDateInRange({ minDate, maxDate, currentDate: prevDate || new Date() }),\n );\n }, [maxDate, minDate]);\n\n const handleLeftArrowClick = useCallback(() => {\n if (direction) return;\n\n setDirection('left');\n\n setCurrentDate((prevDate) => {\n if (!prevDate) {\n return prevDate;\n }\n\n const newDate = getNewDate(-1, prevDate);\n\n return isDateInRange({ minDate, maxDate, currentDate: newDate });\n });\n }, [maxDate, minDate, direction]);\n\n const handleRightArrowClick = useCallback(() => {\n if (direction) return;\n\n setDirection('right');\n\n setCurrentDate((prevDate) => {\n if (!prevDate) {\n return prevDate;\n }\n\n const newDate = getNewDate(1, prevDate);\n\n return isDateInRange({ minDate, maxDate, currentDate: newDate });\n });\n }, [maxDate, minDate, direction]);\n\n const handleSelect = useCallback(\n (date: Date) => {\n setInternalSelectedDate((prevDate) => {\n let onChangePayload: Date | Date[] | DateInterval | null = null;\n let newInternalSelectedDate: Date | Date[] | DateInterval | undefined;\n\n if (type === CalendarType.Single) {\n onChangePayload = date;\n newInternalSelectedDate = date;\n } else if (type === CalendarType.Multiple) {\n const prevSelectedDates = prevDate as Date[];\n // Selects or unselects date , depending on if it is already selected.\n if (prevSelectedDates.some((d) => isSameDay(d, date))) {\n newInternalSelectedDate = prevSelectedDates.filter(\n (d) => !isSameDay(d, date),\n );\n } else {\n newInternalSelectedDate = [...prevSelectedDates, date];\n }\n\n onChangePayload = newInternalSelectedDate;\n } else if (type === CalendarType.Interval) {\n const prevSelectedDateInterval = prevDate as DateInterval;\n\n const updateInterval = (start: Date, end?: Date): void => {\n const newInterval = { start, end };\n onChangePayload = newInterval;\n newInternalSelectedDate = newInterval;\n };\n\n // Sets first selection as interval start.\n if (!prevSelectedDateInterval) {\n updateInterval(date);\n } else if (prevSelectedDateInterval.start && !prevSelectedDateInterval.end) {\n // Sets second selection as interval start, if it is earlier than the previous interval start.\n // Else sets it as interval end.\n if (date < prevSelectedDateInterval.start) {\n updateInterval(date);\n } else {\n updateInterval(prevSelectedDateInterval.start, date);\n }\n } else {\n // Resets interval if a third date is selected.\n updateInterval(date);\n }\n }\n\n if (typeof onChange === 'function' && onChangePayload) {\n onChange(onChangePayload);\n }\n\n return newInternalSelectedDate;\n });\n },\n [type, onChange],\n );\n\n const handleAnimationFinished = () => {\n setDirection(undefined);\n };\n\n const ShouldShowLeftArrow = useMemo(() => {\n if (!currentDate) {\n return false;\n }\n\n return !isSameMonth(currentDate, minDate);\n }, [currentDate, minDate]);\n\n const ShouldShowRightArrow = useMemo(() => {\n if (!currentDate) {\n return false;\n }\n\n return !isSameMonth(currentDate, maxDate);\n }, [currentDate, maxDate]);\n\n return (\n <StyledCalendar ref={calendarRef} $isDisabled={isDisabled}>\n {ShouldShowLeftArrow ? (\n <StyledCalendarIconWrapper onClick={handleLeftArrowClick}>\n <div // TODO Use styled-components instead of inline styles\n style={{\n display: 'flex',\n flexDirection: 'row',\n flexWrap: 'nowrap',\n height: 'fit-content',\n }}\n >\n {showMonthYearPickers && (\n <StyledPseudoMonthYearPicker>\n <ComboBox lists={[{ list: [] }]} placeholder=\"\" />\n </StyledPseudoMonthYearPicker>\n )}\n <Icon icons={['fa fa-angle-left']} />\n </div>\n </StyledCalendarIconWrapper>\n ) : (\n <StyledCalendarIconWrapperPseudo />\n )}\n {currentDate && (\n <MonthWrapper\n shouldRenderTwo={shouldRenderTwoMonths}\n currentDate={currentDate}\n width={width}\n locale={locale}\n direction={direction}\n onSelect={handleSelect}\n selectedDate={internalSelectedDate}\n highlightedDates={highlightedDates}\n categories={categories}\n onAnimationFinished={handleAnimationFinished}\n minDate={minDate}\n maxDate={maxDate}\n type={type}\n disabledDates={disabledDates}\n setCurrentDate={setCurrentDate}\n shouldShowHighlightsInMonthOverlay={shouldShowHighlightsInMonthOverlay}\n showMonthYearPickers={showMonthYearPickers}\n />\n )}\n {ShouldShowRightArrow ? (\n <StyledCalendarIconWrapper onClick={handleRightArrowClick}>\n <div // TODO Use styled-components instead of inline styles\n style={{\n display: 'flex',\n flexDirection: 'row',\n flexWrap: 'nowrap',\n height: 'fit-content',\n }}\n >\n {showMonthYearPickers && (\n <StyledPseudoMonthYearPicker>\n <ComboBox lists={[{ list: [] }]} placeholder=\"\" />\n </StyledPseudoMonthYearPicker>\n )}\n <Icon icons={['fa fa-angle-right']} />\n </div>\n </StyledCalendarIconWrapper>\n ) : (\n <StyledCalendarIconWrapperPseudo />\n )}\n </StyledCalendar>\n );\n};\n\nCalendar.displayName = 'Calendar';\n\nexport default Calendar;\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,IAAI,QAAQ,yBAAyB;AACxD,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;AA6FvD,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,IAgB9B;EAAA,IAhB+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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AO,EAAEA,OAAQ;IACjBS,IAAI,EAAEA,IAAK;IACXG,aAAa,EAAEA,aAAc;IAC7BK,cAAc,EAAEA,cAAe;IAC/BN,kCAAkC,EAAEA,kCAAmC;IACvEE,oBAAoB,EAAEA;EAAqB,CAC9C,CACJ,EACA6D,oBAAoB,gBACjB/F,KAAA,CAAAgG,aAAA,CAACrF,yBAAyB;IAACwF,OAAO,EAAEf;EAAsB,gBACtDpF,KAAA,CAAAgG,aAAA;IAAK;IACDI,KAAK,EAAE;MACHC,OAAO,EAAE,MAAM;MACfC,aAAa,EAAE,KAAK;MACpBC,QAAQ,EAAE,QAAQ;MAClBC,MAAM,EAAE;IACZ;EAAE,GAEDtE,oBAAoB,iBACjBlC,KAAA,CAAAgG,aAAA,CAACnF,2BAA2B,qBACxBb,KAAA,CAAAgG,aAAA,CAACzG,QAAQ;IAACkH,KAAK,EAAE,CAAC;MAAEC,IAAI,EAAE;IAAG,CAAC,CAAE;IAACC,WAAW,EAAC;EAAE,CAAE,CACxB,CAChC,eACD3G,KAAA,CAAAgG,aAAA,CAACxG,IAAI;IAACoH,KAAK,EAAE,CAAC,mBAAmB;EAAE,CAAE,CACpC,CACkB,CAAC,gBAE5B5G,KAAA,CAAAgG,aAAA,CAACpF,+BAA+B,MAAE,CAE1B,CAAC;AAEzB,CAAC;AAEDM,QAAQ,CAAC8F,WAAW,GAAG,UAAU;AAEjC,eAAe9F,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","customThumbColors","selectedDate","selectedDates","selectedDateInterval","categories","isDisabled","type","Single","shouldShowHighlightsInMonthOverlay","disabledDates","showMonthYearPickers","showMonthYearPickersProp","onShownDatesChange","currentDate","setCurrentDate","shouldRenderTwoMonths","setShouldRenderTwoMonths","internalSelectedDate","setInternalSelectedDate","Multiple","undefined","direction","setDirection","width","setWidth","hasMultipleMonths","hasMultipleYears","length","calendarRef","start","getFullYear","getMonth","end","bounds","isDisabledDate","some","disabledDate","isDateInBounds","console","warn","disabledSelectedDates","datesOutsideOfBounds","filteredDates","filter","date","push","Interval","intervalIncludesDisabledDate","intervalIsInBounds","current","resizeObserver","ResizeObserver","entries","observedWidth","contentRect","observe","disconnect","prevDate","handleLeftArrowClick","newDate","handleRightArrowClick","handleSelect","onChangePayload","newInternalSelectedDate","prevSelectedDates","d","prevSelectedDateInterval","updateInterval","newInterval","handleAnimationFinished","ShouldShowLeftArrow","ShouldShowRightArrow","createElement","ref","$isDisabled","onClick","style","display","flexDirection","flexWrap","height","lists","list","placeholder","icons","shouldRenderTwo","onSelect","onAnimationFinished","displayName"],"sources":["../../../../src/components/calendar/Calendar.tsx"],"sourcesContent":["import { ComboBox, Icon } from '@chayns-components/core';\nimport {\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 {Categories, CustomThumbColors, 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 * 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?: 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 * 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 = de,\n maxDate = DEFAULT_MAX_DATE,\n minDate = DEFAULT_MIN_DATE,\n highlightedDates,\n onChange,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'>();\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) =>\n isDateInRange({ minDate, maxDate, currentDate: prevDate || new Date() }),\n );\n }, [maxDate, minDate]);\n\n const handleLeftArrowClick = useCallback(() => {\n if (direction) return;\n\n setDirection('left');\n\n setCurrentDate((prevDate) => {\n if (!prevDate) {\n return prevDate;\n }\n\n const newDate = getNewDate(-1, prevDate);\n\n return isDateInRange({ minDate, maxDate, currentDate: newDate });\n });\n }, [maxDate, minDate, direction]);\n\n const handleRightArrowClick = useCallback(() => {\n if (direction) return;\n\n setDirection('right');\n\n setCurrentDate((prevDate) => {\n if (!prevDate) {\n return prevDate;\n }\n\n const newDate = getNewDate(1, prevDate);\n\n return isDateInRange({ minDate, maxDate, currentDate: newDate });\n });\n }, [maxDate, minDate, direction]);\n\n const handleSelect = useCallback(\n (date: Date) => {\n setInternalSelectedDate((prevDate) => {\n let onChangePayload: Date | Date[] | DateInterval | null = null;\n let newInternalSelectedDate: Date | Date[] | DateInterval | undefined;\n\n if (type === CalendarType.Single) {\n onChangePayload = date;\n newInternalSelectedDate = date;\n } else if (type === CalendarType.Multiple) {\n const prevSelectedDates = prevDate as Date[];\n // Selects or unselects date , depending on if it is already selected.\n if (prevSelectedDates.some((d) => isSameDay(d, date))) {\n newInternalSelectedDate = prevSelectedDates.filter(\n (d) => !isSameDay(d, date),\n );\n } else {\n newInternalSelectedDate = [...prevSelectedDates, date];\n }\n\n onChangePayload = newInternalSelectedDate;\n } else if (type === CalendarType.Interval) {\n const prevSelectedDateInterval = prevDate as DateInterval;\n\n const updateInterval = (start: Date, end?: Date): void => {\n const newInterval = { start, end };\n onChangePayload = newInterval;\n newInternalSelectedDate = newInterval;\n };\n\n // Sets first selection as interval start.\n if (!prevSelectedDateInterval) {\n updateInterval(date);\n } else if (prevSelectedDateInterval.start && !prevSelectedDateInterval.end) {\n // Sets second selection as interval start, if it is earlier than the previous interval start.\n // Else sets it as interval end.\n if (date < prevSelectedDateInterval.start) {\n updateInterval(date);\n } else {\n updateInterval(prevSelectedDateInterval.start, date);\n }\n } else {\n // Resets interval if a third date is selected.\n updateInterval(date);\n }\n }\n\n if (typeof onChange === 'function' && onChangePayload) {\n onChange(onChangePayload);\n }\n\n return newInternalSelectedDate;\n });\n },\n [type, onChange],\n );\n\n const handleAnimationFinished = () => {\n setDirection(undefined);\n };\n\n const ShouldShowLeftArrow = useMemo(() => {\n if (!currentDate) {\n return false;\n }\n\n return !isSameMonth(currentDate, minDate);\n }, [currentDate, minDate]);\n\n const ShouldShowRightArrow = useMemo(() => {\n if (!currentDate) {\n return false;\n }\n\n return !isSameMonth(currentDate, maxDate);\n }, [currentDate, maxDate]);\n\n return (\n <StyledCalendar ref={calendarRef} $isDisabled={isDisabled}>\n {ShouldShowLeftArrow ? (\n <StyledCalendarIconWrapper onClick={handleLeftArrowClick}>\n <div // TODO Use styled-components instead of inline styles\n style={{\n display: 'flex',\n flexDirection: 'row',\n flexWrap: 'nowrap',\n height: 'fit-content',\n }}\n >\n {showMonthYearPickers && (\n <StyledPseudoMonthYearPicker>\n <ComboBox lists={[{ list: [] }]} placeholder=\"\" />\n </StyledPseudoMonthYearPicker>\n )}\n <Icon icons={['fa fa-angle-left']} />\n </div>\n </StyledCalendarIconWrapper>\n ) : (\n <StyledCalendarIconWrapperPseudo />\n )}\n {currentDate && (\n <MonthWrapper\n shouldRenderTwo={shouldRenderTwoMonths}\n currentDate={currentDate}\n width={width}\n locale={locale}\n direction={direction}\n customThumbColors={customThumbColors}\n onSelect={handleSelect}\n selectedDate={internalSelectedDate}\n highlightedDates={highlightedDates}\n categories={categories}\n onAnimationFinished={handleAnimationFinished}\n minDate={minDate}\n maxDate={maxDate}\n type={type}\n disabledDates={disabledDates}\n setCurrentDate={setCurrentDate}\n shouldShowHighlightsInMonthOverlay={shouldShowHighlightsInMonthOverlay}\n showMonthYearPickers={showMonthYearPickers}\n />\n )}\n {ShouldShowRightArrow ? (\n <StyledCalendarIconWrapper onClick={handleRightArrowClick}>\n <div // TODO Use styled-components instead of inline styles\n style={{\n display: 'flex',\n flexDirection: 'row',\n flexWrap: 'nowrap',\n height: 'fit-content',\n }}\n >\n {showMonthYearPickers && (\n <StyledPseudoMonthYearPicker>\n <ComboBox lists={[{ list: [] }]} placeholder=\"\" />\n </StyledPseudoMonthYearPicker>\n )}\n <Icon icons={['fa fa-angle-right']} />\n </div>\n </StyledCalendarIconWrapper>\n ) : (\n <StyledCalendarIconWrapperPseudo />\n )}\n </StyledCalendar>\n );\n};\n\nCalendar.displayName = 'Calendar';\n\nexport default Calendar;\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,IAAI,QAAQ,yBAAyB;AACxD,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,mBA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E,CACpC,CACkB,CAAC,gBAE5B7G,KAAA,CAAAiG,aAAA,CAACrF,+BAA+B,MAAE,CAE1B,CAAC;AAEzB,CAAC;AAEDM,QAAQ,CAAC+F,WAAW,GAAG,UAAU;AAEjC,eAAe/F,QAAQ","ignoreList":[]}
|
|
@@ -14,6 +14,7 @@ const MonthWrapper = _ref => {
|
|
|
14
14
|
onAnimationFinished,
|
|
15
15
|
shouldRenderTwo,
|
|
16
16
|
width,
|
|
17
|
+
customThumbColors,
|
|
17
18
|
isDisabled,
|
|
18
19
|
minDate,
|
|
19
20
|
maxDate,
|
|
@@ -50,6 +51,7 @@ const MonthWrapper = _ref => {
|
|
|
50
51
|
minDate: minDate,
|
|
51
52
|
maxDate: maxDate,
|
|
52
53
|
type: type,
|
|
54
|
+
customThumbColors: customThumbColors,
|
|
53
55
|
hoveringDay: hoveringDay,
|
|
54
56
|
setHoveringDay: setHoveringDay,
|
|
55
57
|
disabledDates: disabledDates,
|
|
@@ -85,6 +87,7 @@ const MonthWrapper = _ref => {
|
|
|
85
87
|
maxDate,
|
|
86
88
|
minDate,
|
|
87
89
|
month,
|
|
90
|
+
customThumbColors,
|
|
88
91
|
selectedDate,
|
|
89
92
|
setCurrentDate,
|
|
90
93
|
setHoveringDay,
|
|
@@ -94,7 +97,7 @@ const MonthWrapper = _ref => {
|
|
|
94
97
|
}
|
|
95
98
|
};
|
|
96
99
|
}));
|
|
97
|
-
}, [categories, currentDate, direction, disabledDates, highlightedDates, hoveringDay, locale, onAnimationFinished, onSelect, maxDate, minDate, selectedDate, setCurrentDate, setHoveringDay, showMonthYearPickers, type, shouldShowHighlightsInMonthOverlay]);
|
|
100
|
+
}, [customThumbColors, categories, currentDate, direction, disabledDates, highlightedDates, hoveringDay, locale, onAnimationFinished, onSelect, maxDate, minDate, selectedDate, setCurrentDate, setHoveringDay, showMonthYearPickers, type, shouldShowHighlightsInMonthOverlay]);
|
|
98
101
|
const animate = useMemo(() => {
|
|
99
102
|
if (shouldRenderTwo) {
|
|
100
103
|
switch (true) {
|
|
@@ -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","isDisabled","minDate","maxDate","shouldShowHighlightsInMonthOverlay","type","disabledDates","setCurrentDate","showMonthYearPickers","content","setContent","hoveringDay","setHoveringDay","monthHeight","items","i","date","month","year","push","createElement","height","key","displayIndex","prevState","map","element","index","props","animate","x","$height","$width","$isDisabled","transition","duration","onAnimationComplete","displayName"],"sources":["../../../../../src/components/calendar/month-wrapper/MonthWrapper.tsx"],"sourcesContent":["import type { Locale } from 'date-fns';\nimport type { MotionProps } from 'framer-motion';\nimport React, { FC, useEffect, useMemo, useState, type ReactElement } from 'react';\nimport type {\n CalendarType,\n Categories,\n DateInterval,\n HighlightedDates,\n} from '../../../types/calendar';\nimport { getMonthAndYear, getNewDate } from '../../../utils/calendar';\nimport Month from './month/Month';\nimport { StyledMonthWrapper, StyledMotionWrapper } from './MonthWrapper.styles';\n\nexport type MonthWrapperProps = {\n locale: Locale;\n highlightedDates?: HighlightedDates[];\n onSelect: (date: Date) => void;\n selectedDate?: Date | Date[] | DateInterval;\n categories?: Categories[];\n currentDate: Date;\n direction?: 'left' | 'right';\n onAnimationFinished: () => void;\n shouldRenderTwo: boolean;\n width: number;\n isDisabled?: boolean;\n maxDate: Date;\n minDate: Date;\n type: CalendarType;\n disabledDates: Date[];\n setCurrentDate: (date: Date) => void;\n shouldShowHighlightsInMonthOverlay: boolean;\n showMonthYearPickers: boolean;\n};\n\nconst MonthWrapper: FC<MonthWrapperProps> = ({\n locale,\n currentDate,\n highlightedDates,\n selectedDate,\n onSelect,\n categories,\n direction,\n onAnimationFinished,\n shouldRenderTwo,\n width,\n isDisabled,\n minDate,\n maxDate,\n 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 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 }, [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 selectedDate,\n setCurrentDate,\n setHoveringDay,\n showMonthYearPickers,\n type,\n year,\n } as ReactElement,\n };\n }),\n );\n }, [\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;AAOlF,SAASC,eAAe,EAAEC,UAAU,QAAQ,yBAAyB;AACrE,OAAOC,KAAK,MAAM,eAAe;AACjC,SAASC,kBAAkB,EAAEC,mBAAmB,QAAQ,uBAAuB;AAuB/E,MAAMC,YAAmC,GAAGC,IAAA,IAmBtC;EAAA,IAnBuC;IACzCC,MAAM;IACNC,WAAW;IACXC,gBAAgB;IAChBC,YAAY;IACZC,QAAQ;IACRC,UAAU;IACVC,SAAS;IACTC,mBAAmB;IACnBC,eAAe;IACfC,KAAK;IACLC,UAAU;IACVC,OAAO;IACPC,OAAO;IACPC,kCAAkC;IAClCC,IAAI;IACJC,aAAa;IACbC,cAAc;IACdC;EACJ,CAAC,GAAAlB,IAAA;EACG,MAAM,CAACmB,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,MAAMkB,KAAK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AAEiC,CAAC,EAAE;UAAK,CAAC;QACtB,KAAKjC,SAAS,KAAK,OAAO;UACtB,OAAO;YAAEiC,CAAC,EAAE;UAAQ,CAAC;QACzB;UACI,OAAO;YAAEA,CAAC,EAAE;UAAQ,CAAC;MAC7B;IACJ;EACJ,CAAC,EAAE,CAACjC,SAAS,EAAEE,eAAe,CAAC,CAAC;EAEhC,oBACInB,KAAA,CAAAwC,aAAA,CAACjC,kBAAkB;IAAC4C,OAAO,EAAElB,WAAY;IAACmB,MAAM,EAAEhC;EAAM,gBACpDpB,KAAA,CAAAwC,aAAA,CAAChC,mBAAmB;IAChByC,OAAO,EAAEA,OAAQ;IACjBI,WAAW,EAAEhC,UAAW;IACxBiC,UAAU,EAAE;MACR7B,IAAI,EAAE,OAAO;MACb8B,QAAQ,EAAE,CAACtC,SAAS,GAAG,CAAC,GAAG;IAC/B,CAAE;IACFuC,mBAAmB,EAAEtC;EAAoB,GAExCW,OACgB,CACL,CAAC;AAE7B,CAAC;AAEDpB,YAAY,CAACgD,WAAW,GAAG,cAAc;AAEzC,eAAehD,YAAY","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"MonthWrapper.js","names":["React","useEffect","useMemo","useState","getMonthAndYear","getNewDate","Month","StyledMonthWrapper","StyledMotionWrapper","MonthWrapper","_ref","locale","currentDate","highlightedDates","selectedDate","onSelect","categories","direction","onAnimationFinished","shouldRenderTwo","width","customThumbColors","isDisabled","minDate","maxDate","shouldShowHighlightsInMonthOverlay","type","disabledDates","setCurrentDate","showMonthYearPickers","content","setContent","hoveringDay","setHoveringDay","monthHeight","items","i","date","month","year","push","createElement","height","key","displayIndex","prevState","map","element","index","props","animate","x","$height","$width","$isDisabled","transition","duration","onAnimationComplete","displayName"],"sources":["../../../../../src/components/calendar/month-wrapper/MonthWrapper.tsx"],"sourcesContent":["import type { Locale } from 'date-fns';\nimport type { MotionProps } from 'framer-motion';\nimport React, { FC, useEffect, useMemo, useState, type ReactElement } from 'react';\nimport {\n CalendarType,\n Categories, CustomThumbColors,\n DateInterval,\n HighlightedDates,\n} from '../../../types/calendar';\nimport { getMonthAndYear, getNewDate } from '../../../utils/calendar';\nimport Month from './month/Month';\nimport { StyledMonthWrapper, StyledMotionWrapper } from './MonthWrapper.styles';\n\nexport type MonthWrapperProps = {\n locale: Locale;\n highlightedDates?: HighlightedDates[];\n onSelect: (date: Date) => void;\n selectedDate?: Date | Date[] | DateInterval;\n categories?: Categories[];\n currentDate: Date;\n direction?: 'left' | 'right';\n onAnimationFinished: () => void;\n shouldRenderTwo: boolean;\n width: number;\n isDisabled?: boolean;\n maxDate: Date;\n minDate: Date;\n type: CalendarType;\n disabledDates: Date[];\n setCurrentDate: (date: Date) => void;\n shouldShowHighlightsInMonthOverlay: boolean;\n showMonthYearPickers: boolean;\n customThumbColors?: CustomThumbColors;\n};\n\nconst MonthWrapper: FC<MonthWrapperProps> = ({\n locale,\n currentDate,\n highlightedDates,\n selectedDate,\n onSelect,\n categories,\n direction,\n onAnimationFinished,\n shouldRenderTwo,\n width,customThumbColors,\n isDisabled,\n minDate,\n maxDate,\n shouldShowHighlightsInMonthOverlay,\n type,\n disabledDates,\n setCurrentDate,\n showMonthYearPickers,\n}) => {\n const [content, setContent] = useState<ReactElement[]>();\n\n const [hoveringDay, setHoveringDay] = useState<Date | null>(null);\n\n const monthHeight = useMemo(() => width / (shouldRenderTwo ? 2 : 1), [width, shouldRenderTwo]);\n\n useEffect(() => {\n setContent(() => {\n // Initial render of months\n const items: ReactElement[] = [];\n\n for (let i = -1; i < 3; i++) {\n const date = getNewDate(i, currentDate);\n\n const { month, year } = getMonthAndYear(date);\n\n items.push(\n <Month\n height={monthHeight}\n key={`${month}-${year}`}\n month={month}\n year={year}\n locale={locale}\n onSelect={onSelect}\n highlightedDates={highlightedDates}\n shouldShowHighlightsInMonthOverlay={shouldShowHighlightsInMonthOverlay}\n categories={categories}\n selectedDate={selectedDate}\n minDate={minDate}\n maxDate={maxDate}\n type={type}\n customThumbColors={customThumbColors}\n hoveringDay={hoveringDay}\n setHoveringDay={setHoveringDay}\n disabledDates={disabledDates}\n setCurrentDate={setCurrentDate}\n displayIndex={i}\n showMonthYearPickers={showMonthYearPickers}\n />,\n );\n }\n\n return items;\n });\n }, [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;\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hC,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":[]}
|
|
@@ -15,6 +15,7 @@ const Month = _ref => {
|
|
|
15
15
|
height,
|
|
16
16
|
minDate,
|
|
17
17
|
maxDate,
|
|
18
|
+
customThumbColors,
|
|
18
19
|
shouldShowHighlightsInMonthOverlay,
|
|
19
20
|
type,
|
|
20
21
|
hoveringDay,
|
|
@@ -41,6 +42,7 @@ const Month = _ref => {
|
|
|
41
42
|
key: `day-wrapper-${month}`,
|
|
42
43
|
categories: categories,
|
|
43
44
|
selectedDate: selectedDate,
|
|
45
|
+
customThumbColors: customThumbColors,
|
|
44
46
|
month: month,
|
|
45
47
|
year: year,
|
|
46
48
|
onSelect: onSelect,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Month.js","names":["React","MonthYearPickers","DayWrapper","StyledMonth","StyledMonthHead","WeekdayWrapper","Month","_ref","month","year","locale","highlightedDates","selectedDate","onSelect","categories","height","minDate","maxDate","shouldShowHighlightsInMonthOverlay","type","hoveringDay","setHoveringDay","disabledDates","setCurrentDate","displayIndex","showMonthYearPickers","createElement","$height","key","displayName"],"sources":["../../../../../../src/components/calendar/month-wrapper/month/Month.tsx"],"sourcesContent":["import type { Locale } from 'date-fns';\nimport React, { FC } from 'react';\nimport
|
|
1
|
+
{"version":3,"file":"Month.js","names":["React","MonthYearPickers","DayWrapper","StyledMonth","StyledMonthHead","WeekdayWrapper","Month","_ref","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 type { Locale } from 'date-fns';\nimport React, { FC } from 'react';\nimport {\n CalendarType,\n Categories, 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';\n\nexport type MonthProps = {\n month: EMonth;\n year: number;\n locale: Locale;\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,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":"AACA,OAAOA,KAAK,MAAc,OAAO;AAQjC,OAAOC,gBAAgB,MAAM,2CAA2C;AACxE,OAAOC,UAAU,MAAM,0BAA0B;AACjD,SAASC,WAAW,EAAEC,eAAe,QAAQ,gBAAgB;AAC7D,OAAOC,cAAc,MAAM,kCAAkC;AAwB7D,MAAMC,KAAqB,GAAGC,IAAA;EAAA,IAAC;IAC3BC,KAAK;IACLC,IAAI;IACJC,MAAM;IACNC,gBAAgB;IAChBC,YAAY;IACZC,QAAQ;IACRC,UAAU;IACVC,MAAM;IACNC,OAAO;IACPC,OAAO;IAACC,iBAAiB;IACzBC,kCAAkC;IAClCC,IAAI;IACJC,WAAW;IACXC,cAAc;IACdC,aAAa;IACbC,cAAc;IACdC,YAAY;IACZC;EACJ,CAAC,GAAAnB,IAAA;EAAA,oBACGP,KAAA,CAAA2B,aAAA,CAACxB,WAAW;IAACyB,OAAO,EAAEb;EAAO,gBACzBf,KAAA,CAAA2B,aAAA,CAACvB,eAAe,qBACZJ,KAAA,CAAA2B,aAAA,CAAC1B,gBAAgB;IACbO,KAAK,EAAEA,KAAM;IACbC,IAAI,EAAEA,IAAK;IACXC,MAAM,EAAEA,MAAO;IACfM,OAAO,EAAEA,OAAQ;IACjBC,OAAO,EAAEA,OAAQ;IACjBO,cAAc,EAAEA,cAAe;IAC/BC,YAAY,EAAEA,YAAa;IAC3BC,oBAAoB,EAAEA;EAAqB,CAC9C,CACY,CAAC,eAClB1B,KAAA,CAAA2B,aAAA,CAACtB,cAAc;IAACK,MAAM,EAAEA;EAAO,CAAE,CAAC,eAClCV,KAAA,CAAA2B,aAAA,CAACzB,UAAU;IACP2B,GAAG,EAAE,eAAerB,KAAK,EAAG;IAC5BM,UAAU,EAAEA,UAAW;IACvBF,YAAY,EAAEA,YAAa;IAC3BM,iBAAiB,EAAEA,iBAAkB;IACrCV,KAAK,EAAEA,KAAM;IACbC,IAAI,EAAEA,IAAK;IACXI,QAAQ,EAAEA,QAAS;IACnBM,kCAAkC,EAAEA,kCAAmC;IACvER,gBAAgB,EAAEA,gBAAiB;IACnCK,OAAO,EAAEA,OAAQ;IACjBC,OAAO,EAAEA,OAAQ;IACjBG,IAAI,EAAEA,IAAK;IACXC,WAAW,EAAEA,WAAY;IACzBC,cAAc,EAAEA,cAAe;IAC/BC,aAAa,EAAEA;EAAc,CAChC,CACQ,CAAC;AAAA,CACjB;AAEDjB,KAAK,CAACwB,WAAW,GAAG,OAAO;AAE3B,eAAexB,KAAK","ignoreList":[]}
|
|
@@ -14,6 +14,7 @@ const DayWrapper = _ref => {
|
|
|
14
14
|
categories,
|
|
15
15
|
minDate,
|
|
16
16
|
maxDate,
|
|
17
|
+
customThumbColors,
|
|
17
18
|
type,
|
|
18
19
|
hoveringDay,
|
|
19
20
|
shouldShowHighlightsInMonthOverlay,
|
|
@@ -101,6 +102,7 @@ const DayWrapper = _ref => {
|
|
|
101
102
|
categories: categories,
|
|
102
103
|
date: day,
|
|
103
104
|
isSelected: isSelected,
|
|
105
|
+
customThumbColors: customThumbColors,
|
|
104
106
|
isIntervalStart: isIntervalStart,
|
|
105
107
|
isIntervalEnd: isIntervalEnd,
|
|
106
108
|
isWithinIntervalSelection: isWithinIntervalSelection,
|
|
@@ -113,7 +115,7 @@ const DayWrapper = _ref => {
|
|
|
113
115
|
}));
|
|
114
116
|
});
|
|
115
117
|
return items;
|
|
116
|
-
}, [selectedDate, disabledDates, days, minDate, maxDate, type, hoveringDay, categories, shouldShowHighlightsInMonthOverlay, dayOfCurrentMonth, handleDayClick, highlightedDates, setHoveringDay]);
|
|
118
|
+
}, [selectedDate, disabledDates, days, minDate, maxDate, type, hoveringDay, categories, customThumbColors, shouldShowHighlightsInMonthOverlay, dayOfCurrentMonth, handleDayClick, highlightedDates, setHoveringDay]);
|
|
117
119
|
return /*#__PURE__*/React.createElement(StyledDayWrapper, null, dayElements);
|
|
118
120
|
};
|
|
119
121
|
DayWrapper.displayName = 'DayWrapper';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DayWrapper.js","names":["addDays","isAfter","isSameDay","isSameMonth","isWithinInterval","startOfMonth","startOfWeek","React","useCallback","useMemo","CalendarType","findNextDate","Day","StyledDayWrapper","DayWrapper","_ref","month","year","highlightedDates","onSelect","selectedDate","categories","minDate","maxDate","type","hoveringDay","shouldShowHighlightsInMonthOverlay","setHoveringDay","disabledDates","dayOfCurrentMonth","Date","days","dateArray","currentDate","startDay","weekStartsOn","i","newDate","push","handleDayClick","date","shouldFireEvent","dayElements","items","start","end","firstDisabledDateAfterStart","forEach","day","isSelected","isIntervalStart","isIntervalEnd","isWithinIntervalSelection","showHoverEffect","isDisabled","some","disabledDate","Single","Multiple","Array","isArray","Interval","createElement","key","toDateString","onClick","displayName"],"sources":["../../../../../../../src/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.tsx"],"sourcesContent":["import {\n addDays,\n isAfter,\n isSameDay,\n isSameMonth,\n isWithinInterval,\n startOfMonth,\n startOfWeek,\n} from 'date-fns';\nimport React, { FC, useCallback, useMemo, type ReactElement } from 'react';\nimport {\n CalendarType,\n type Categories,\n type DateInterval,\n type EMonth,\n type HighlightedDates,\n} from '../../../../../types/calendar';\nimport { findNextDate } from '../../../../../utils/calendar';\nimport Day from './day/Day';\nimport { StyledDayWrapper } from './DayWrapper.styles';\n\nexport type DayWrapperProps = {\n month: EMonth;\n year: number;\n highlightedDates?: HighlightedDates[];\n onSelect: (date: Date) => void;\n selectedDate?: Date | Date[] | DateInterval;\n categories?: Categories[];\n minDate: Date;\n maxDate: Date;\n type: CalendarType;\n hoveringDay: Date | null;\n setHoveringDay: (date: Date | null) => void;\n disabledDates: Date[];\n shouldShowHighlightsInMonthOverlay: boolean;\n};\n\nconst DayWrapper: FC<DayWrapperProps> = ({\n month,\n year,\n highlightedDates,\n onSelect,\n selectedDate,\n categories,\n minDate,\n maxDate,\n type,\n hoveringDay,\n shouldShowHighlightsInMonthOverlay,\n setHoveringDay,\n disabledDates,\n}) => {\n const dayOfCurrentMonth = useMemo(() => new Date(year, month - 1, 13), [month, year]);\n\n const days = useMemo(() => {\n const dateArray: Date[] = [];\n\n const currentDate = startOfMonth(dayOfCurrentMonth);\n\n const startDay = startOfWeek(currentDate, { weekStartsOn: 1 });\n\n for (let i = 0; i < 42; i++) {\n const newDate = addDays(startDay, i);\n dateArray.push(newDate);\n }\n\n return dateArray;\n }, [dayOfCurrentMonth]);\n\n const handleDayClick = useCallback(\n (date: Date, shouldFireEvent: boolean) => {\n if (shouldFireEvent) {\n onSelect(date);\n }\n },\n [onSelect],\n );\n\n const dayElements = useMemo(() => {\n const items: ReactElement[] = [];\n\n const { start, end } = (selectedDate || {}) as DateInterval;\n const firstDisabledDateAfterStart = findNextDate(start, disabledDates);\n\n days.forEach((day) => {\n let isSelected = false;\n let isIntervalStart = false;\n let isIntervalEnd = false;\n let isWithinIntervalSelection = false;\n const showHoverEffect = false;\n\n let isDisabled =\n // Disables dates, that are not between minDate and maxDate.\n !isWithinInterval(day, { start: minDate, end: maxDate }) ||\n // Disables\n disabledDates.some((disabledDate) => isSameDay(disabledDate, day));\n\n if (type === CalendarType.Single && selectedDate instanceof Date) {\n isSelected = isSameDay(selectedDate, day);\n } else if (type === CalendarType.Multiple && Array.isArray(selectedDate)) {\n isSelected = selectedDate.some((date) => isSameDay(date, day));\n } else if (type === CalendarType.Interval && start) {\n isIntervalStart = isSameDay(start, day);\n if (end) {\n isIntervalEnd = isSameDay(end, day);\n\n isWithinIntervalSelection = isWithinInterval(day, {\n start,\n end,\n });\n } else if (\n firstDisabledDateAfterStart &&\n !isDisabled &&\n isAfter(day, firstDisabledDateAfterStart)\n ) {\n // Ensures, that the interval end can't be set in a way, that the interval includes disabled dates.\n isDisabled = true;\n }\n }\n\n if (\n type === CalendarType.Interval &&\n hoveringDay &&\n !isIntervalStart &&\n !isIntervalEnd &&\n !isWithinIntervalSelection\n ) {\n if (!start) {\n isIntervalStart = isSameDay(day, hoveringDay);\n } else if (start && !end) {\n if (start > day) {\n isIntervalStart = isSameDay(day, hoveringDay);\n } else {\n isWithinIntervalSelection = isWithinInterval(day, {\n start,\n end: hoveringDay,\n });\n isIntervalEnd = isSameDay(hoveringDay, day);\n }\n } else if (start && end && isSameDay(hoveringDay, day)) {\n isIntervalStart = !isWithinInterval(day, { start, end });\n }\n }\n\n items.push(\n <Day\n key={`single-day-${day.toDateString()}`}\n categories={categories}\n date={day}\n isSelected={isSelected}\n isIntervalStart={isIntervalStart}\n isIntervalEnd={isIntervalEnd}\n isWithinIntervalSelection={isWithinIntervalSelection}\n isDisabled={isDisabled}\n shouldShowHighlightsInMonthOverlay={shouldShowHighlightsInMonthOverlay}\n isSameMonth={isSameMonth(day, dayOfCurrentMonth)}\n onClick={handleDayClick}\n highlightedDates={highlightedDates}\n setHoveringDay={setHoveringDay}\n />,\n );\n });\n\n return items;\n }, [\n selectedDate,\n disabledDates,\n days,\n minDate,\n maxDate,\n type,\n hoveringDay,\n categories,\n shouldShowHighlightsInMonthOverlay,\n dayOfCurrentMonth,\n handleDayClick,\n highlightedDates,\n setHoveringDay,\n ]);\n\n return <StyledDayWrapper>{dayElements}</StyledDayWrapper>;\n};\n\nDayWrapper.displayName = 'DayWrapper';\n\nexport default DayWrapper;\n"],"mappings":"AAAA,SACIA,OAAO,EACPC,OAAO,EACPC,SAAS,EACTC,WAAW,EACXC,gBAAgB,EAChBC,YAAY,EACZC,WAAW,QACR,UAAU;AACjB,OAAOC,KAAK,IAAQC,WAAW,EAAEC,OAAO,QAA2B,OAAO;AAC1E,SACIC,YAAY,QAKT,+BAA+B;AACtC,SAASC,YAAY,QAAQ,+BAA+B;AAC5D,OAAOC,GAAG,MAAM,WAAW;AAC3B,SAASC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rDE,UAAU,EAAEA,UAAW;QACvB5B,kCAAkC,EAAEA,kCAAmC;QACvEvB,WAAW,EAAEA,WAAW,CAAC6C,GAAG,EAAEnB,iBAAiB,CAAE;QACjDoC,OAAO,EAAE1B,cAAe;QACxBrB,gBAAgB,EAAEA,gBAAiB;QACnCS,cAAc,EAAEA;MAAe,CAClC,CACL,CAAC;IACL,CAAC,CAAC;IAEF,OAAOgB,KAAK;EAChB,CAAC,EAAE,CACCvB,YAAY,EACZQ,aAAa,EACbG,IAAI,EACJT,OAAO,EACPC,OAAO,EACPC,IAAI,EACJC,WAAW,EACXJ,UAAU,EACVK,kCAAkC,EAClCG,iBAAiB,EACjBU,cAAc,EACdrB,gBAAgB,EAChBS,cAAc,CACjB,CAAC;EAEF,oBAAOpB,KAAA,CAAAuD,aAAA,CAACjD,gBAAgB,QAAE6B,WAA8B,CAAC;AAC7D,CAAC;AAED5B,UAAU,CAACoD,WAAW,GAAG,YAAY;AAErC,eAAepD,UAAU","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"DayWrapper.js","names":["addDays","isAfter","isSameDay","isSameMonth","isWithinInterval","startOfMonth","startOfWeek","React","useCallback","useMemo","CalendarType","findNextDate","Day","StyledDayWrapper","DayWrapper","_ref","month","year","highlightedDates","onSelect","selectedDate","categories","minDate","maxDate","customThumbColors","type","hoveringDay","shouldShowHighlightsInMonthOverlay","setHoveringDay","disabledDates","dayOfCurrentMonth","Date","days","dateArray","currentDate","startDay","weekStartsOn","i","newDate","push","handleDayClick","date","shouldFireEvent","dayElements","items","start","end","firstDisabledDateAfterStart","forEach","day","isSelected","isIntervalStart","isIntervalEnd","isWithinIntervalSelection","showHoverEffect","isDisabled","some","disabledDate","Single","Multiple","Array","isArray","Interval","createElement","key","toDateString","onClick","displayName"],"sources":["../../../../../../../src/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.tsx"],"sourcesContent":["import {\n addDays,\n isAfter,\n isSameDay,\n isSameMonth,\n isWithinInterval,\n startOfMonth,\n startOfWeek,\n} from 'date-fns';\nimport React, { FC, useCallback, useMemo, type ReactElement } from 'react';\nimport {\n CalendarType,\n type Categories, CustomThumbColors,\n type DateInterval,\n type EMonth,\n type HighlightedDates,\n} from '../../../../../types/calendar';\nimport { findNextDate } from '../../../../../utils/calendar';\nimport Day from './day/Day';\nimport { StyledDayWrapper } from './DayWrapper.styles';\n\nexport type DayWrapperProps = {\n month: EMonth;\n year: number;\n highlightedDates?: HighlightedDates[];\n onSelect: (date: Date) => void;\n selectedDate?: Date | Date[] | DateInterval;\n categories?: Categories[];\n minDate: Date;\n maxDate: Date;\n type: CalendarType;\n hoveringDay: Date | null;\n setHoveringDay: (date: Date | null) => void;\n disabledDates: Date[];\n customThumbColors?: CustomThumbColors;\n shouldShowHighlightsInMonthOverlay: boolean;\n};\n\nconst DayWrapper: FC<DayWrapperProps> = ({\n month,\n year,\n highlightedDates,\n onSelect,\n selectedDate,\n categories,\n minDate,\n maxDate,customThumbColors,\n type,\n hoveringDay,\n shouldShowHighlightsInMonthOverlay,\n setHoveringDay,\n disabledDates,\n}) => {\n const dayOfCurrentMonth = useMemo(() => new Date(year, month - 1, 13), [month, year]);\n\n const days = useMemo(() => {\n const dateArray: Date[] = [];\n\n const currentDate = startOfMonth(dayOfCurrentMonth);\n\n const startDay = startOfWeek(currentDate, { weekStartsOn: 1 });\n\n for (let i = 0; i < 42; i++) {\n const newDate = addDays(startDay, i);\n dateArray.push(newDate);\n }\n\n return dateArray;\n }, [dayOfCurrentMonth]);\n\n const handleDayClick = useCallback(\n (date: Date, shouldFireEvent: boolean) => {\n if (shouldFireEvent) {\n onSelect(date);\n }\n },\n [onSelect],\n );\n\n const dayElements = useMemo(() => {\n const items: ReactElement[] = [];\n\n const { start, end } = (selectedDate || {}) as DateInterval;\n const firstDisabledDateAfterStart = findNextDate(start, disabledDates);\n\n days.forEach((day) => {\n let isSelected = false;\n let isIntervalStart = false;\n let isIntervalEnd = false;\n let isWithinIntervalSelection = false;\n const showHoverEffect = false;\n\n let isDisabled =\n // Disables dates, that are not between minDate and maxDate.\n !isWithinInterval(day, { start: minDate, end: maxDate }) ||\n // Disables\n disabledDates.some((disabledDate) => isSameDay(disabledDate, day));\n\n if (type === CalendarType.Single && selectedDate instanceof Date) {\n isSelected = isSameDay(selectedDate, day);\n } else if (type === CalendarType.Multiple && Array.isArray(selectedDate)) {\n isSelected = selectedDate.some((date) => isSameDay(date, day));\n } else if (type === CalendarType.Interval && start) {\n isIntervalStart = isSameDay(start, day);\n if (end) {\n isIntervalEnd = isSameDay(end, day);\n\n isWithinIntervalSelection = isWithinInterval(day, {\n start,\n end,\n });\n } else if (\n firstDisabledDateAfterStart &&\n !isDisabled &&\n isAfter(day, firstDisabledDateAfterStart)\n ) {\n // Ensures, that the interval end can't be set in a way, that the interval includes disabled dates.\n isDisabled = true;\n }\n }\n\n if (\n type === CalendarType.Interval &&\n hoveringDay &&\n !isIntervalStart &&\n !isIntervalEnd &&\n !isWithinIntervalSelection\n ) {\n if (!start) {\n isIntervalStart = isSameDay(day, hoveringDay);\n } else if (start && !end) {\n if (start > day) {\n isIntervalStart = isSameDay(day, hoveringDay);\n } else {\n isWithinIntervalSelection = isWithinInterval(day, {\n start,\n end: hoveringDay,\n });\n isIntervalEnd = isSameDay(hoveringDay, day);\n }\n } else if (start && end && isSameDay(hoveringDay, day)) {\n isIntervalStart = !isWithinInterval(day, { start, end });\n }\n }\n\n items.push(\n <Day\n key={`single-day-${day.toDateString()}`}\n categories={categories}\n date={day}\n isSelected={isSelected}\n customThumbColors={customThumbColors}\n isIntervalStart={isIntervalStart}\n isIntervalEnd={isIntervalEnd}\n isWithinIntervalSelection={isWithinIntervalSelection}\n isDisabled={isDisabled}\n shouldShowHighlightsInMonthOverlay={shouldShowHighlightsInMonthOverlay}\n isSameMonth={isSameMonth(day, dayOfCurrentMonth)}\n onClick={handleDayClick}\n highlightedDates={highlightedDates}\n setHoveringDay={setHoveringDay}\n />,\n );\n });\n\n return items;\n }, [selectedDate, disabledDates, days, minDate, maxDate, type, hoveringDay, categories, customThumbColors, shouldShowHighlightsInMonthOverlay, dayOfCurrentMonth, handleDayClick, highlightedDates, setHoveringDay]);\n\n return <StyledDayWrapper>{dayElements}</StyledDayWrapper>;\n};\n\nDayWrapper.displayName = 'DayWrapper';\n\nexport default DayWrapper;\n"],"mappings":"AAAA,SACIA,OAAO,EACPC,OAAO,EACPC,SAAS,EACTC,WAAW,EACXC,gBAAgB,EAChBC,YAAY,EACZC,WAAW,QACR,UAAU;AACjB,OAAOC,KAAK,IAAQC,WAAW,EAAEC,OAAO,QAA2B,OAAO;AAC1E,SACIC,YAAY,QAKT,+BAA+B;AACtC,SAASC,YAAY,QAAQ,+BAA+B;AAC5D,OAAOC,GAAG,MAAM,WAAW;AAC3B,SAASC,gBAAgB,QAAQ,qBAAqB;AAmBtD,MAAMC,UAA+B,GAAGC,IAAA,IAclC;EAAA,IAdmC;IACrCC,KAAK;IACLC,IAAI;IACJC,gBAAgB;IAChBC,QAAQ;IACRC,YAAY;IACZC,UAAU;IACVC,OAAO;IACPC,OAAO;IAACC,iBAAiB;IACzBC,IAAI;IACJC,WAAW;IACXC,kCAAkC;IAClCC,cAAc;IACdC;EACJ,CAAC,GAAAd,IAAA;EACG,MAAMe,iBAAiB,GAAGrB,OAAO,CAAC,MAAM,IAAIsB,IAAI,CAACd,IAAI,EAAED,KAAK,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE,CAACA,KAAK,EAAEC,IAAI,CAAC,CAAC;EAErF,MAAMe,IAAI,GAAGvB,OAAO,CAAC,MAAM;IACvB,MAAMwB,SAAiB,GAAG,EAAE;IAE5B,MAAMC,WAAW,GAAG7B,YAAY,CAACyB,iBAAiB,CAAC;IAEnD,MAAMK,QAAQ,GAAG7B,WAAW,CAAC4B,WAAW,EAAE;MAAEE,YAAY,EAAE;IAAE,CAAC,CAAC;IAE9D,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAG,EAAE,EAAEA,CAAC,EA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|
|
14
14
|
isIntervalStart,
|
|
15
15
|
isIntervalEnd,
|
|
16
|
+
customThumbColors,
|
|
16
17
|
isWithinIntervalSelection,
|
|
17
18
|
shouldShowHighlightsInMonthOverlay,
|
|
18
19
|
setHoveringDay
|
|
@@ -41,6 +42,7 @@ const Day = _ref => {
|
|
|
41
42
|
onMouseEnter: () => setHoveringDay(date),
|
|
42
43
|
onMouseLeave: () => setHoveringDay(null)
|
|
43
44
|
}, /*#__PURE__*/React.createElement(StyledDayNumber, {
|
|
45
|
+
$customThumbColors: customThumbColors,
|
|
44
46
|
$isSelected: shouldShowHighlightsInMonthOverlay ? isSelected : isSelected && isSameMonth,
|
|
45
47
|
$isIntervalStart: shouldShowHighlightsInMonthOverlay ? isIntervalStart : isIntervalStart && isSameMonth,
|
|
46
48
|
$isIntervalEnd: shouldShowHighlightsInMonthOverlay ? isIntervalEnd : isIntervalEnd && isSameMonth,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Day.js","names":["isSameDay","React","useMemo","useRef","Category","StyledDay","StyledDayCategoryWrapper","StyledDayNumber","Day","_ref","date","highlightedDates","categories","isSameMonth","isSelected","onClick","isDisabled","isIntervalStart","isIntervalEnd","isWithinIntervalSelection","shouldShowHighlightsInMonthOverlay","setHoveringDay","dayRef","styles","undefined","find","highlightedDate","dates","some","highlighted","style","categoryElements","flatMap","category","filter","day","map","createElement","key","getTime","Math","random","color","ref","$isSameMonth","$isDisabled","$backgroundColor","backgroundColor","$textColor","textColor","onMouseEnter","onMouseLeave","$isSelected","$isIntervalStart","$isIntervalEnd","$isWithinIntervalSelection","getDate","displayName"],"sources":["../../../../../../../../src/components/calendar/month-wrapper/month/day-wrapper/day/Day.tsx"],"sourcesContent":["import { isSameDay } from 'date-fns';\nimport React, { FC, useMemo, useRef } from 'react';\nimport
|
|
1
|
+
{"version":3,"file":"Day.js","names":["isSameDay","React","useMemo","useRef","Category","StyledDay","StyledDayCategoryWrapper","StyledDayNumber","Day","_ref","date","highlightedDates","categories","isSameMonth","isSelected","onClick","isDisabled","isIntervalStart","isIntervalEnd","customThumbColors","isWithinIntervalSelection","shouldShowHighlightsInMonthOverlay","setHoveringDay","dayRef","styles","undefined","find","highlightedDate","dates","some","highlighted","style","categoryElements","flatMap","category","filter","day","map","createElement","key","getTime","Math","random","color","ref","$isSameMonth","$isDisabled","$backgroundColor","backgroundColor","$textColor","textColor","onMouseEnter","onMouseLeave","$customThumbColors","$isSelected","$isIntervalStart","$isIntervalEnd","$isWithinIntervalSelection","getDate","displayName"],"sources":["../../../../../../../../src/components/calendar/month-wrapper/month/day-wrapper/day/Day.tsx"],"sourcesContent":["import { isSameDay } from 'date-fns';\nimport React, { FC, useMemo, useRef } from 'react';\nimport {\n Categories, CustomThumbColors,\n HighlightedDates,\n HighlightedDateStyles,\n} from '../../../../../../types/calendar';\nimport Category from './category/Category';\nimport { StyledDay, StyledDayCategoryWrapper, StyledDayNumber } from './Day.styles';\n\nexport type DayProps = {\n date: Date;\n isSameMonth: boolean;\n isSelected: boolean;\n onClick: (date: Date, shouldFireEvent: boolean) => void;\n highlightedDates?: HighlightedDates[];\n categories?: Categories[];\n isDisabled: boolean;\n isIntervalStart: boolean;\n isIntervalEnd: boolean;\n isWithinIntervalSelection: boolean;\n setHoveringDay: (date: Date | null) => void;\n shouldShowHighlightsInMonthOverlay: boolean;\n customThumbColors?: CustomThumbColors;\n};\n\nconst Day: FC<DayProps> = ({\n date,\n highlightedDates,\n categories,\n isSameMonth,\n isSelected,\n onClick,\n isDisabled,\n isIntervalStart,\n isIntervalEnd,customThumbColors,\n isWithinIntervalSelection,\n shouldShowHighlightsInMonthOverlay,\n setHoveringDay,\n}) => {\n const dayRef = useRef<HTMLDivElement>(null);\n\n const styles: HighlightedDateStyles | undefined = useMemo(() => {\n if (!highlightedDates || (!shouldShowHighlightsInMonthOverlay && !isSameMonth)) {\n return undefined;\n }\n\n return highlightedDates.find((highlightedDate) =>\n highlightedDate.dates.some((highlighted) => isSameDay(highlighted, date)),\n )?.style;\n }, [date, highlightedDates, isSameMonth, shouldShowHighlightsInMonthOverlay]);\n\n const categoryElements = useMemo(() => {\n if (!categories || (!shouldShowHighlightsInMonthOverlay && !isSameMonth)) return [];\n\n return categories.flatMap((category) =>\n category.dates\n .filter((day) => isSameDay(day, date))\n .map((day) => (\n <Category key={day.getTime() * Math.random()} color={category.color} />\n )),\n );\n }, [categories, date, isSameMonth, shouldShowHighlightsInMonthOverlay]);\n\n return (\n <StyledDay\n ref={dayRef}\n onClick={() => onClick(date, isSameMonth && !isDisabled)}\n $isSameMonth={isSameMonth}\n $isDisabled={isDisabled}\n $backgroundColor={styles?.backgroundColor}\n $textColor={styles?.textColor}\n onMouseEnter={() => setHoveringDay(date)}\n onMouseLeave={() => setHoveringDay(null)}\n >\n <StyledDayNumber\n $customThumbColors={customThumbColors}\n $isSelected={\n shouldShowHighlightsInMonthOverlay ? isSelected : isSelected && isSameMonth\n }\n $isIntervalStart={\n shouldShowHighlightsInMonthOverlay\n ? isIntervalStart\n : isIntervalStart && isSameMonth\n }\n $isIntervalEnd={\n shouldShowHighlightsInMonthOverlay\n ? isIntervalEnd\n : isIntervalEnd && isSameMonth\n }\n $isWithinIntervalSelection={\n shouldShowHighlightsInMonthOverlay\n ? isWithinIntervalSelection\n : isWithinIntervalSelection && isSameMonth\n }\n >\n {date.getDate()}\n </StyledDayNumber>\n {categoryElements && (\n <StyledDayCategoryWrapper>{categoryElements}</StyledDayCategoryWrapper>\n )}\n </StyledDay>\n );\n};\n\nDay.displayName = 'Day';\n\nexport default Day;\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,UAAU;AACpC,OAAOC,KAAK,IAAQC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAMlD,OAAOC,QAAQ,MAAM,qBAAqB;AAC1C,SAASC,SAAS,EAAEC,wBAAwB,EAAEC,eAAe,QAAQ,cAAc;AAkBnF,MAAMC,GAAiB,GAAGC,IAAA,IAapB;EAAA,IAbqB;IACvBC,IAA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C;EAEvE,oBACIpB,KAAA,CAAAqC,aAAA,CAACjC,SAAS;IACNuC,GAAG,EAAErB,MAAO;IACZR,OAAO,EAAEA,CAAA,KAAMA,OAAO,CAACL,IAAI,EAAEG,WAAW,IAAI,CAACG,UAAU,CAAE;IACzD6B,YAAY,EAAEhC,WAAY;IAC1BiC,WAAW,EAAE9B,UAAW;IACxB+B,gBAAgB,EAAEvB,MAAM,EAAEwB,eAAgB;IAC1CC,UAAU,EAAEzB,MAAM,EAAE0B,SAAU;IAC9BC,YAAY,EAAEA,CAAA,KAAM7B,cAAc,CAACZ,IAAI,CAAE;IACzC0C,YAAY,EAAEA,CAAA,KAAM9B,cAAc,CAAC,IAAI;EAAE,gBAEzCrB,KAAA,CAAAqC,aAAA,CAAC/B,eAAe;IACZ8C,kBAAkB,EAAElC,iBAAkB;IACtCmC,WAAW,EACPjC,kCAAkC,GAAGP,UAAU,GAAGA,UAAU,IAAID,WACnE;IACD0C,gBAAgB,EACZlC,kCAAkC,GAC5BJ,eAAe,GACfA,eAAe,IAAIJ,WAC5B;IACD2C,cAAc,EACVnC,kCAAkC,GAC5BH,aAAa,GACbA,aAAa,IAAIL,WAC1B;IACD4C,0BAA0B,EACtBpC,kCAAkC,GAC5BD,yBAAyB,GACzBA,yBAAyB,IAAIP;EACtC,GAEAH,IAAI,CAACgD,OAAO,CAAC,CACD,CAAC,EACjB1B,gBAAgB,iBACb/B,KAAA,CAAAqC,aAAA,CAAChC,wBAAwB,QAAE0B,gBAA2C,CAEnE,CAAC;AAEpB,CAAC;AAEDxB,GAAG,CAACmD,WAAW,GAAG,KAAK;AAEvB,eAAenD,GAAG","ignoreList":[]}
|
|
@@ -66,11 +66,12 @@ export const StyledDayNumber = styled.div`
|
|
|
66
66
|
$isIntervalEnd,
|
|
67
67
|
$isIntervalStart,
|
|
68
68
|
$isWithinIntervalSelection,
|
|
69
|
+
$customThumbColors,
|
|
69
70
|
theme
|
|
70
71
|
} = _ref6;
|
|
71
72
|
return !!($isSelected || $isIntervalStart || $isIntervalEnd || $isWithinIntervalSelection) && css`
|
|
72
|
-
background-color: ${theme['404']};
|
|
73
|
-
color: ${theme['409']};
|
|
73
|
+
background-color: ${$customThumbColors?.mainBackgroundColor ?? theme['404']};
|
|
74
|
+
color: ${$customThumbColors?.mainTextColor ?? theme['409']};
|
|
74
75
|
`;
|
|
75
76
|
}}
|
|
76
77
|
|
|
@@ -79,6 +80,7 @@ export const StyledDayNumber = styled.div`
|
|
|
79
80
|
$isIntervalStart,
|
|
80
81
|
$isIntervalEnd,
|
|
81
82
|
$isWithinIntervalSelection,
|
|
83
|
+
$customThumbColors,
|
|
82
84
|
theme
|
|
83
85
|
} = _ref7;
|
|
84
86
|
if ($isIntervalStart && $isIntervalEnd) {
|
|
@@ -103,7 +105,7 @@ export const StyledDayNumber = styled.div`
|
|
|
103
105
|
return css`
|
|
104
106
|
border-radius: 0;
|
|
105
107
|
width: 100%;
|
|
106
|
-
background-color: ${theme['403']};
|
|
108
|
+
background-color: ${$customThumbColors?.secondaryBackgroundColor ?? theme['403']};
|
|
107
109
|
`;
|
|
108
110
|
}
|
|
109
111
|
return '';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Day.styles.js","names":["styled","css","StyledDay","div","_ref","$isSameMonth","$isDisabled","_ref2","theme","text","_ref3","_ref4","_ref5","$backgroundColor","$textColor","StyledDayNumber","_ref6","$isSelected","$isIntervalEnd","$isIntervalStart","$isWithinIntervalSelection","_ref7","StyledDayCategoryWrapper"],"sources":["../../../../../../../../src/components/calendar/month-wrapper/month/day-wrapper/day/Day.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport type { CSSProperties } from 'react';\nimport styled, { css } from 'styled-components';\n\ntype StyledDayProps = WithTheme<{\n $isSameMonth: boolean;\n $backgroundColor?: CSSProperties['backgroundColor'];\n $textColor?: CSSProperties['color'];\n $isDisabled: boolean;\n}>;\n\nexport const StyledDay = styled.div<StyledDayProps>`\n position: relative;\n cursor: ${({ $isSameMonth, $isDisabled }) =>\n $isSameMonth && !$isDisabled ? 'pointer' : 'default'};\n color: ${({ theme }: StyledDayProps) => theme.text};\n opacity: ${({ $isSameMonth, $isDisabled }) => {\n if ($isSameMonth && !$isDisabled) {\n return '1';\n }\n if ($isDisabled) {\n return '0.2';\n }\n return '0.5';\n }};\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n aspect-ratio: 1;\n pointer-events: ${({ $isSameMonth, $isDisabled }) =>\n $isSameMonth && !$isDisabled ? 'auto' : 'none'};\n\n ${({ $backgroundColor, $textColor }) =>\n $backgroundColor &&\n $textColor &&\n css`\n color: ${$textColor};\n background-color: ${$backgroundColor};\n `}\n`;\n\ntype StyledDayNumberProps = WithTheme<{\n $isSelected: boolean;\n $isIntervalEnd: boolean;\n $isIntervalStart: boolean;\n $isWithinIntervalSelection: boolean;\n}>;\n\nexport const StyledDayNumber = styled.div<StyledDayNumberProps>`\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 80%;\n height: 80%;\n font-size: 90%;\n\n ${({ $isSelected, $isIntervalEnd, $isIntervalStart, $isWithinIntervalSelection, theme }) =>\n !!($isSelected || $isIntervalStart || $isIntervalEnd || $isWithinIntervalSelection) &&\n css`\n background-color: ${theme['404']};\n color: ${theme['409']};\n `}\n\n ${({ $isIntervalStart, $isIntervalEnd, $isWithinIntervalSelection, theme }) => {\n if ($isIntervalStart && $isIntervalEnd) {\n return css`\n border-radius: 5px;\n width: 100%;\n `;\n }\n if ($isIntervalStart) {\n return css`\n border-radius: 5px 0 0 5px;\n width: 100%;\n `;\n }\n if ($isIntervalEnd) {\n return css`\n border-radius: 0 5px 5px 0;\n width: 100%;\n `;\n }\n if ($isWithinIntervalSelection) {\n return css`\n border-radius: 0;\n width: 100%;\n background-color: ${theme['403']};\n `;\n }\n\n return '';\n }}\n`;\n\nexport const StyledDayCategoryWrapper = styled.div`\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 6%;\n width: 100%;\n position: absolute;\n bottom: 2px;\n`;\n"],"mappings":"AAEA,OAAOA,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;
|
|
1
|
+
{"version":3,"file":"Day.styles.js","names":["styled","css","StyledDay","div","_ref","$isSameMonth","$isDisabled","_ref2","theme","text","_ref3","_ref4","_ref5","$backgroundColor","$textColor","StyledDayNumber","_ref6","$isSelected","$isIntervalEnd","$isIntervalStart","$isWithinIntervalSelection","$customThumbColors","mainBackgroundColor","mainTextColor","_ref7","secondaryBackgroundColor","StyledDayCategoryWrapper"],"sources":["../../../../../../../../src/components/calendar/month-wrapper/month/day-wrapper/day/Day.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport type { CSSProperties } from 'react';\nimport styled, { css } from 'styled-components';\nimport {CustomThumbColors} from \"../../../../../../types/calendar\";\n\ntype StyledDayProps = WithTheme<{\n $isSameMonth: boolean;\n $backgroundColor?: CSSProperties['backgroundColor'];\n $textColor?: CSSProperties['color'];\n $isDisabled: boolean;\n}>;\n\nexport const StyledDay = styled.div<StyledDayProps>`\n position: relative;\n cursor: ${({ $isSameMonth, $isDisabled }) =>\n $isSameMonth && !$isDisabled ? 'pointer' : 'default'};\n color: ${({ theme }: StyledDayProps) => theme.text};\n opacity: ${({ $isSameMonth, $isDisabled }) => {\n if ($isSameMonth && !$isDisabled) {\n return '1';\n }\n if ($isDisabled) {\n return '0.2';\n }\n return '0.5';\n }};\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n aspect-ratio: 1;\n pointer-events: ${({ $isSameMonth, $isDisabled }) =>\n $isSameMonth && !$isDisabled ? 'auto' : 'none'};\n\n ${({ $backgroundColor, $textColor }) =>\n $backgroundColor &&\n $textColor &&\n css`\n color: ${$textColor};\n background-color: ${$backgroundColor};\n `}\n`;\n\ntype StyledDayNumberProps = WithTheme<{\n $isSelected: boolean;\n $isIntervalEnd: boolean;\n $isIntervalStart: boolean;\n $isWithinIntervalSelection: boolean;\n $customThumbColors?: CustomThumbColors;\n}>;\n\nexport const StyledDayNumber = styled.div<StyledDayNumberProps>`\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 80%;\n height: 80%;\n font-size: 90%;\n\n ${({ $isSelected, $isIntervalEnd, $isIntervalStart, $isWithinIntervalSelection, $customThumbColors, theme }) =>\n !!($isSelected || $isIntervalStart || $isIntervalEnd || $isWithinIntervalSelection) &&\n css`\n background-color: ${$customThumbColors?.mainBackgroundColor ?? theme['404']};\n color: ${$customThumbColors?.mainTextColor ?? theme['409']};\n `}\n\n ${({ $isIntervalStart, $isIntervalEnd, $isWithinIntervalSelection, $customThumbColors, theme }) => {\n if ($isIntervalStart && $isIntervalEnd) {\n return css`\n border-radius: 5px;\n width: 100%;\n `;\n }\n if ($isIntervalStart) {\n return css`\n border-radius: 5px 0 0 5px;\n width: 100%;\n `;\n }\n if ($isIntervalEnd) {\n return css`\n border-radius: 0 5px 5px 0;\n width: 100%;\n `;\n }\n if ($isWithinIntervalSelection) {\n return css`\n border-radius: 0;\n width: 100%;\n background-color: ${$customThumbColors?.secondaryBackgroundColor ?? theme['403']};\n `;\n }\n\n return '';\n }}\n`;\n\nexport const StyledDayCategoryWrapper = styled.div`\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 6%;\n width: 100%;\n position: absolute;\n bottom: 2px;\n`;\n"],"mappings":"AAEA,OAAOA,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAU/C,OAAO,MAAMC,SAAS,GAAGF,MAAM,CAACG,GAAmB;AACnD;AACA,cAAcC,IAAA;EAAA,IAAC;IAAEC,YAAY;IAAEC;EAAY,CAAC,GAAAF,IAAA;EAAA,OACpCC,YAAY,IAAI,CAACC,WAAW,GAAG,SAAS,GAAG,SAAS;AAAA;AAC5D,aAAaC,KAAA;EAAA,IAAC;IAAEC;EAAsB,CAAC,GAAAD,KAAA;EAAA,OAAKC,KAAK,CAACC,IAAI;AAAA;AACtD,eAAeC,KAAA,IAAmC;EAAA,IA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pC,OAAOjB,GAAG;AACtB;AACA;AACA,aAAa;EACL;EACA,IAAIkB,gBAAgB,EAAE;IAClB,OAAOlB,GAAG;AACtB;AACA;AACA,aAAa;EACL;EACA,IAAIiB,cAAc,EAAE;IAChB,OAAOjB,GAAG;AACtB;AACA;AACA,aAAa;EACL;EACA,IAAImB,0BAA0B,EAAE;IAC5B,OAAOnB,GAAG;AACtB;AACA;AACA,oCAAoCoB,kBAAkB,EAAEI,wBAAwB,IAAIjB,KAAK,CAAC,KAAK,CAAC;AAChG,aAAa;EACL;EAEA,OAAO,EAAE;AACb,CAAC;AACL,CAAC;AAED,OAAO,MAAMkB,wBAAwB,GAAG1B,MAAM,CAACG,GAAG;AAClD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["default","Calendar","DateInfo","OpeningInputs","OpeningTimes","useDateInfo","CalendarType"],"sources":["../../src/index.ts"],"sourcesContent":["export { default as Calendar } from './components/calendar/Calendar';\nexport { default as DateInfo } from './components/date-info/DateInfo';\nexport { default as OpeningInputs } from './components/opening-times/opening-inputs/OpeningInputs';\nexport { default as OpeningTimes } from './components/opening-times/OpeningTimes';\nexport { useDateInfo } from './hooks/useDateInfo';\nexport type { Categories, HighlightedDates, HighlightedDateStyles } from './types/calendar';\nexport { CalendarType } from './types/calendar';\nexport type { HintTextPosition, OpeningTime, Time, Weekday } from './types/openingTimes';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,QAAQ,QAAQ,gCAAgC;AACpE,SAASD,OAAO,IAAIE,QAAQ,QAAQ,iCAAiC;AACrE,SAASF,OAAO,IAAIG,aAAa,QAAQ,yDAAyD;AAClG,SAASH,OAAO,IAAII,YAAY,QAAQ,yCAAyC;AACjF,SAASC,WAAW,QAAQ,qBAAqB;AAEjD,SAASC,YAAY,QAAQ,kBAAkB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["default","Calendar","DateInfo","OpeningInputs","OpeningTimes","useDateInfo","CalendarType"],"sources":["../../src/index.ts"],"sourcesContent":["export { default as Calendar } from './components/calendar/Calendar';\nexport { default as DateInfo } from './components/date-info/DateInfo';\nexport { default as OpeningInputs } from './components/opening-times/opening-inputs/OpeningInputs';\nexport { default as OpeningTimes } from './components/opening-times/OpeningTimes';\nexport { useDateInfo } from './hooks/useDateInfo';\nexport type { Categories, HighlightedDates, HighlightedDateStyles, CustomThumbColors } from './types/calendar';\nexport { CalendarType } from './types/calendar';\nexport type { HintTextPosition, OpeningTime, Time, Weekday } from './types/openingTimes';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,QAAQ,QAAQ,gCAAgC;AACpE,SAASD,OAAO,IAAIE,QAAQ,QAAQ,iCAAiC;AACrE,SAASF,OAAO,IAAIG,aAAa,QAAQ,yDAAyD;AAClG,SAASH,OAAO,IAAII,YAAY,QAAQ,yCAAyC;AACjF,SAASC,WAAW,QAAQ,qBAAqB;AAEjD,SAASC,YAAY,QAAQ,kBAAkB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar.js","names":["EMonth","CalendarType"],"sources":["../../../src/types/calendar.ts"],"sourcesContent":["import type { CSSProperties } from 'react';\n\nexport interface HighlightedDates {\n dates: Date[];\n style: HighlightedDateStyles;\n}\n\nexport interface HighlightedDateStyles {\n backgroundColor: CSSProperties['backgroundColor'];\n textColor: CSSProperties['color'];\n}\n\nexport interface Categories {\n id: string;\n dates: Date[];\n color: CSSProperties['color'];\n}\n\nexport interface IMonth {\n month: EMonth;\n year: number;\n}\n\nexport enum EMonth {\n January = 1,\n February,\n March,\n April,\n May,\n June,\n July,\n August,\n September,\n October,\n November,\n December,\n}\n\nexport enum CalendarType {\n Single = 'single',\n Multiple = 'multiple',\n Interval = 'interval',\n}\n\nexport type DateInterval = {\n start: Date;\n end?: Date;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"calendar.js","names":["EMonth","CalendarType"],"sources":["../../../src/types/calendar.ts"],"sourcesContent":["import type { CSSProperties } from 'react';\n\nexport interface HighlightedDates {\n dates: Date[];\n style: HighlightedDateStyles;\n}\n\nexport interface HighlightedDateStyles {\n backgroundColor: CSSProperties['backgroundColor'];\n textColor: CSSProperties['color'];\n}\n\nexport interface Categories {\n id: string;\n dates: Date[];\n color: CSSProperties['color'];\n}\n\nexport interface IMonth {\n month: EMonth;\n year: number;\n}\n\nexport interface CustomThumbColors {\n /**\n * The background color of the main thumbs (single, multi, interval)\n */\n mainBackgroundColor?: CSSProperties['color'];\n /**\n * The text color of the main thumbs (single, multi, interval)\n */\n mainTextColor?: CSSProperties['color'];\n /**\n * The background color of the middle part of the interval thumb\n */\n secondaryBackgroundColor?: CSSProperties['color'];\n\n}\n\nexport enum EMonth {\n January = 1,\n February,\n March,\n April,\n May,\n June,\n July,\n August,\n September,\n October,\n November,\n December,\n}\n\nexport enum CalendarType {\n Single = 'single',\n Multiple = 'multiple',\n Interval = 'interval',\n}\n\nexport type DateInterval = {\n start: Date;\n end?: Date;\n};\n"],"mappings":"AAuCA,WAAYA,MAAM,0BAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAAA,OAANA,MAAM;AAAA;AAelB,WAAYC,YAAY,0BAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAA,OAAZA,YAAY;AAAA","ignoreList":[]}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { type Locale } from 'date-fns';
|
|
2
2
|
import { FC } from 'react';
|
|
3
|
-
import
|
|
3
|
+
import { Categories, CustomThumbColors, DateInterval, HighlightedDates } from '../../types/calendar';
|
|
4
4
|
import { CalendarType } from '../../types/calendar';
|
|
5
5
|
interface BaseProps {
|
|
6
6
|
/**
|
|
7
7
|
* An array to group dates into a category.
|
|
8
8
|
*/
|
|
9
9
|
categories?: Categories[];
|
|
10
|
+
/**
|
|
11
|
+
* Custom colors for the thumb.
|
|
12
|
+
*/
|
|
13
|
+
customThumbColors?: CustomThumbColors;
|
|
10
14
|
/**
|
|
11
15
|
* An array with dates and corresponding styles to highlight.
|
|
12
16
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Locale } from 'date-fns';
|
|
2
2
|
import { FC } from 'react';
|
|
3
|
-
import
|
|
3
|
+
import { CalendarType, Categories, CustomThumbColors, DateInterval, HighlightedDates } from '../../../types/calendar';
|
|
4
4
|
export type MonthWrapperProps = {
|
|
5
5
|
locale: Locale;
|
|
6
6
|
highlightedDates?: HighlightedDates[];
|
|
@@ -20,6 +20,7 @@ export type MonthWrapperProps = {
|
|
|
20
20
|
setCurrentDate: (date: Date) => void;
|
|
21
21
|
shouldShowHighlightsInMonthOverlay: boolean;
|
|
22
22
|
showMonthYearPickers: boolean;
|
|
23
|
+
customThumbColors?: CustomThumbColors;
|
|
23
24
|
};
|
|
24
25
|
declare const MonthWrapper: FC<MonthWrapperProps>;
|
|
25
26
|
export default MonthWrapper;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Locale } from 'date-fns';
|
|
2
2
|
import { FC } from 'react';
|
|
3
|
-
import
|
|
3
|
+
import { CalendarType, Categories, CustomThumbColors, DateInterval, EMonth, HighlightedDates } from '../../../../types/calendar';
|
|
4
4
|
export type MonthProps = {
|
|
5
5
|
month: EMonth;
|
|
6
6
|
year: number;
|
|
@@ -19,6 +19,7 @@ export type MonthProps = {
|
|
|
19
19
|
setCurrentDate: (date: Date) => void;
|
|
20
20
|
displayIndex?: number;
|
|
21
21
|
shouldShowHighlightsInMonthOverlay: boolean;
|
|
22
|
+
customThumbColors?: CustomThumbColors;
|
|
22
23
|
showMonthYearPickers: boolean;
|
|
23
24
|
};
|
|
24
25
|
declare const Month: FC<MonthProps>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import { CalendarType, type Categories, type DateInterval, type EMonth, type HighlightedDates } from '../../../../../types/calendar';
|
|
2
|
+
import { CalendarType, type Categories, CustomThumbColors, type DateInterval, type EMonth, type HighlightedDates } from '../../../../../types/calendar';
|
|
3
3
|
export type DayWrapperProps = {
|
|
4
4
|
month: EMonth;
|
|
5
5
|
year: number;
|
|
@@ -13,6 +13,7 @@ export type DayWrapperProps = {
|
|
|
13
13
|
hoveringDay: Date | null;
|
|
14
14
|
setHoveringDay: (date: Date | null) => void;
|
|
15
15
|
disabledDates: Date[];
|
|
16
|
+
customThumbColors?: CustomThumbColors;
|
|
16
17
|
shouldShowHighlightsInMonthOverlay: boolean;
|
|
17
18
|
};
|
|
18
19
|
declare const DayWrapper: FC<DayWrapperProps>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { Categories, CustomThumbColors, HighlightedDates } from '../../../../../../types/calendar';
|
|
3
3
|
export type DayProps = {
|
|
4
4
|
date: Date;
|
|
5
5
|
isSameMonth: boolean;
|
|
@@ -13,6 +13,7 @@ export type DayProps = {
|
|
|
13
13
|
isWithinIntervalSelection: boolean;
|
|
14
14
|
setHoveringDay: (date: Date | null) => void;
|
|
15
15
|
shouldShowHighlightsInMonthOverlay: boolean;
|
|
16
|
+
customThumbColors?: CustomThumbColors;
|
|
16
17
|
};
|
|
17
18
|
declare const Day: FC<DayProps>;
|
|
18
19
|
export default Day;
|