@chayns-components/date 5.0.0-beta.949 → 5.0.0-beta.951
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 +9 -8
- package/lib/cjs/components/calendar/Calendar.js.map +1 -1
- package/lib/esm/components/calendar/Calendar.js +9 -8
- package/lib/esm/components/calendar/Calendar.js.map +1 -1
- package/lib/types/components/calendar/Calendar.d.ts +8 -9
- package/package.json +2 -2
|
@@ -5,13 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _core = require("@chayns-components/core");
|
|
8
|
+
var _chaynsApi = require("chayns-api");
|
|
8
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
10
|
var _calendar = require("../../types/calendar");
|
|
10
11
|
var _calendar2 = require("../../utils/calendar");
|
|
12
|
+
var _date = require("../../utils/date");
|
|
11
13
|
var _Calendar = require("./Calendar.styles");
|
|
12
14
|
var _MonthWrapper = _interopRequireDefault(require("./month-wrapper/MonthWrapper"));
|
|
13
|
-
var _chaynsApi = require("chayns-api");
|
|
14
|
-
var _date = require("../../utils/date");
|
|
15
15
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
16
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
17
17
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -37,7 +37,7 @@ const Calendar = ({
|
|
|
37
37
|
}) => {
|
|
38
38
|
const [currentDate, setCurrentDate] = (0, _react.useState)();
|
|
39
39
|
const [shouldRenderTwoMonths, setShouldRenderTwoMonths] = (0, _react.useState)(true);
|
|
40
|
-
const [internalSelectedDate, setInternalSelectedDate] = (0, _react.useState)(type === _calendar.CalendarType.Multiple ? [] : undefined);
|
|
40
|
+
const [internalSelectedDate, setInternalSelectedDate] = (0, _react.useState)(() => type === _calendar.CalendarType.Multiple ? [] : undefined);
|
|
41
41
|
const [direction, setDirection] = (0, _react.useState)();
|
|
42
42
|
const [width, setWidth] = (0, _react.useState)(0);
|
|
43
43
|
const showMonthYearPickers = (0, _react.useMemo)(() => {
|
|
@@ -63,7 +63,8 @@ const Calendar = ({
|
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
67
|
+
}, [currentDate, shouldRenderTwoMonths]);
|
|
67
68
|
(0, _react.useEffect)(() => {
|
|
68
69
|
const bounds = {
|
|
69
70
|
start: minDate,
|
|
@@ -80,10 +81,10 @@ const Calendar = ({
|
|
|
80
81
|
minDate,
|
|
81
82
|
maxDate
|
|
82
83
|
}]));
|
|
83
|
-
setInternalSelectedDate(undefined);
|
|
84
|
+
setInternalSelectedDate(() => undefined);
|
|
84
85
|
}
|
|
85
86
|
} else {
|
|
86
|
-
setInternalSelectedDate(undefined);
|
|
87
|
+
setInternalSelectedDate(() => undefined);
|
|
87
88
|
}
|
|
88
89
|
} else if (type === _calendar.CalendarType.Multiple) {
|
|
89
90
|
if (selectedDates) {
|
|
@@ -124,7 +125,7 @@ const Calendar = ({
|
|
|
124
125
|
minDate,
|
|
125
126
|
maxDate
|
|
126
127
|
}]));
|
|
127
|
-
setInternalSelectedDate(undefined);
|
|
128
|
+
setInternalSelectedDate(() => undefined);
|
|
128
129
|
}
|
|
129
130
|
}
|
|
130
131
|
}
|
|
@@ -236,7 +237,7 @@ const Calendar = ({
|
|
|
236
237
|
});
|
|
237
238
|
}, [type, onChange]);
|
|
238
239
|
const handleAnimationFinished = () => {
|
|
239
|
-
setDirection(undefined);
|
|
240
|
+
setDirection(() => undefined);
|
|
240
241
|
};
|
|
241
242
|
const ShouldShowLeftArrow = (0, _react.useMemo)(() => {
|
|
242
243
|
if (!currentDate) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Calendar.js","names":["_core","require","_react","_interopRequireWildcard","_calendar","_calendar2","_Calendar","_MonthWrapper","_interopRequireDefault","_chaynsApi","_date","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","DEFAULT_MAX_DATE","addYears","Date","DEFAULT_MIN_DATE","subYears","Calendar","locale","Language","German","maxDate","minDate","highlightedDates","onChange","customThumbColors","selectedDate","selectedDates","selectedDateInterval","categories","isDisabled","type","CalendarType","Single","shouldShowHighlightsInMonthOverlay","disabledDates","showMonthYearPickers","showMonthYearPickersProp","onShownDatesChange","currentDate","setCurrentDate","useState","shouldRenderTwoMonths","setShouldRenderTwoMonths","internalSelectedDate","setInternalSelectedDate","Multiple","undefined","direction","setDirection","width","setWidth","useMemo","hasMultipleMonths","differenceInCalendarMonths","hasMultipleYears","getYearsBetween","length","calendarRef","useRef","useEffect","start","getFullYear","getMonth","end","bounds","isDisabledDate","some","disabledDate","isSameDay","isDateInBounds","isWithinInterval","console","warn","disabledSelectedDates","datesOutsideOfBounds","filteredDates","filter","date","push","Interval","intervalIncludesDisabledDate","intervalIsInBounds","current","resizeObserver","ResizeObserver","entries","observedWidth","contentRect","observe","disconnect","prevDate","isDateInRange","handleLeftArrowClick","useCallback","newDate","getNewDate","handleRightArrowClick","handleSelect","onChangePayload","newInternalSelectedDate","prevSelectedDates","d","prevSelectedDateInterval","updateInterval","newInterval","handleAnimationFinished","ShouldShowLeftArrow","isSameMonth","ShouldShowRightArrow","createElement","StyledCalendar","ref","$isDisabled","StyledCalendarIconWrapper","onClick","style","display","flexDirection","flexWrap","height","StyledPseudoMonthYearPicker","ComboBox","lists","list","placeholder","Icon","icons","StyledCalendarIconWrapperPseudo","shouldRenderTwo","onSelect","onAnimationFinished","displayName","_default","exports"],"sources":["../../../../src/components/calendar/Calendar.tsx"],"sourcesContent":["import { ComboBox, Icon } from '@chayns-components/core';\nimport 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';\nimport {Language} from \"chayns-api\";\nimport {\n addYears,\n differenceInCalendarMonths,\n isSameDay,\n isSameMonth,\n isWithinInterval,\n subYears\n} from \"../../utils/date\";\n\ninterface BaseProps {\n /**\n * An array to group dates into a category.\n */\n categories?: Categories[];\n /**\n * Custom colors for the thumb.\n */\n customThumbColors?: CustomThumbColors;\n /**\n * An array with dates and corresponding styles to highlight.\n */\n highlightedDates?: HighlightedDates[];\n /**\n * To disable the Calendar\n */\n isDisabled?: boolean;\n /**\n * The locale language to format the dates.\n */\n locale?: Language;\n /**\n * The maximum date that can be selected.\n */\n maxDate?: Date;\n /**\n * The minimum date that can be selected.\n */\n minDate?: Date;\n /**\n * An array of dates that should be disabled.\n */\n disabledDates?: Date[];\n /**\n * Whether the highlighted dates should be displayed for the greyed month overlay days.\n */\n shouldShowHighlightsInMonthOverlay?: boolean;\n /**\n * Shows the month and year pickers, if there are multiple months/years to select from.\n */\n showMonthYearPickers?: boolean;\n /**\n * Function to be executed when the selected date, dates or date interval change.\n * @param date\n */\n onChange?: (date: Date | Date[] | DateInterval) => void;\n /**\n * Function to be executed when the shown dates change. Returns the start of the displayed month and the end of the last displayed month (since depending on the available widths, there are one or two months displayed).\n @param { start: Date, end: Date }\n */\n onShownDatesChange?: (dates: { start: Date; end: Date }) => void;\n}\n\ninterface SingleSelectionProps {\n /**\n * The type of the calendar selection.\n */\n type?: CalendarType.Single;\n /**\n * A date that should be preselected.\n */\n selectedDate?: Date;\n selectedDates: never;\n selectedDateInterval: never;\n}\n\ninterface MultipleSelectionProps {\n /**\n * The type of the calendar selection.\n */\n type: CalendarType.Multiple;\n /**\n * An array of dates that should be preselected.\n */\n selectedDates?: Date[];\n selectedDate: never;\n selectedDateInterval: never;\n}\n\ninterface IntervalSelectionProps {\n /**\n * The type of the calendar selection.\n */\n type: CalendarType.Interval;\n /**\n * An interval that should be preselected.\n */\n selectedDateInterval?: DateInterval;\n selectedDates: never;\n selectedDate: never;\n}\n\nexport type CalendarProps = BaseProps &\n (SingleSelectionProps | MultipleSelectionProps | IntervalSelectionProps);\n\nconst DEFAULT_MAX_DATE = addYears(new Date(), 1);\nconst DEFAULT_MIN_DATE = subYears(new Date(), 1);\n\nconst Calendar: FC<CalendarProps> = ({\n locale = Language.German,\n maxDate = DEFAULT_MAX_DATE,\n minDate = DEFAULT_MIN_DATE,\n highlightedDates,\n onChange,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, onShownDatesChange, 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,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AAEA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AAMA,IAAAM,aAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,UAAA,GAAAR,OAAA;AACA,IAAAS,KAAA,GAAAT,OAAA;AAO0B,SAAAO,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAAH,CAAA,6BAAAI,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAD,wBAAA,YAAAA,CAAAH,CAAA,WAAAA,CAAA,GAAAM,CAAA,GAAAD,CAAA,KAAAL,CAAA;AAAA,SAAAR,wBAAAQ,CAAA,EAAAK,CAAA,SAAAA,CAAA,IAAAL,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAE,OAAA,EAAAF,CAAA,QAAAM,CAAA,GAAAH,wBAAA,CAAAE,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAC,GAAA,CAAAP,CAAA,UAAAM,CAAA,CA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AG,UAAU;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA5I,OAAA,GAEnBuB,QAAQ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Calendar.js","names":["_core","require","_chaynsApi","_react","_interopRequireWildcard","_calendar","_calendar2","_date","_Calendar","_MonthWrapper","_interopRequireDefault","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","DEFAULT_MAX_DATE","addYears","Date","DEFAULT_MIN_DATE","subYears","Calendar","locale","Language","German","maxDate","minDate","highlightedDates","onChange","customThumbColors","selectedDate","selectedDates","selectedDateInterval","categories","isDisabled","type","CalendarType","Single","shouldShowHighlightsInMonthOverlay","disabledDates","showMonthYearPickers","showMonthYearPickersProp","onShownDatesChange","currentDate","setCurrentDate","useState","shouldRenderTwoMonths","setShouldRenderTwoMonths","internalSelectedDate","setInternalSelectedDate","Multiple","undefined","direction","setDirection","width","setWidth","useMemo","hasMultipleMonths","differenceInCalendarMonths","hasMultipleYears","getYearsBetween","length","calendarRef","useRef","useEffect","start","getFullYear","getMonth","end","bounds","isDisabledDate","some","disabledDate","isSameDay","isDateInBounds","isWithinInterval","console","warn","disabledSelectedDates","datesOutsideOfBounds","filteredDates","filter","date","push","Interval","intervalIncludesDisabledDate","intervalIsInBounds","current","resizeObserver","ResizeObserver","entries","observedWidth","contentRect","observe","disconnect","prevDate","isDateInRange","handleLeftArrowClick","useCallback","newDate","getNewDate","handleRightArrowClick","handleSelect","onChangePayload","newInternalSelectedDate","prevSelectedDates","d","prevSelectedDateInterval","updateInterval","newInterval","handleAnimationFinished","ShouldShowLeftArrow","isSameMonth","ShouldShowRightArrow","createElement","StyledCalendar","ref","$isDisabled","StyledCalendarIconWrapper","onClick","style","display","flexDirection","flexWrap","height","StyledPseudoMonthYearPicker","ComboBox","lists","list","placeholder","Icon","icons","StyledCalendarIconWrapperPseudo","shouldRenderTwo","onSelect","onAnimationFinished","displayName","_default","exports"],"sources":["../../../../src/components/calendar/Calendar.tsx"],"sourcesContent":["import { ComboBox, Icon } from '@chayns-components/core';\nimport { Language } from 'chayns-api';\nimport React, { FC, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport {\n CalendarType,\n Categories,\n CustomThumbColors,\n DateInterval,\n HighlightedDates,\n} from '../../types/calendar';\nimport { getNewDate, getYearsBetween, isDateInRange } from '../../utils/calendar';\nimport {\n addYears,\n differenceInCalendarMonths,\n isSameDay,\n isSameMonth,\n isWithinInterval,\n subYears,\n} from '../../utils/date';\nimport {\n StyledCalendar,\n StyledCalendarIconWrapper,\n StyledCalendarIconWrapperPseudo,\n StyledPseudoMonthYearPicker,\n} from './Calendar.styles';\nimport MonthWrapper from './month-wrapper/MonthWrapper';\n\ninterface BaseProps {\n /**\n * An array to group dates into a category.\n */\n categories?: Categories[];\n /**\n * Custom colors for the thumb.\n */\n customThumbColors?: CustomThumbColors;\n /**\n * An array with dates and corresponding styles to highlight.\n */\n highlightedDates?: HighlightedDates[];\n /**\n * To disable the Calendar\n */\n isDisabled?: boolean;\n /**\n * The locale language to format the dates.\n */\n locale?: Language;\n /**\n * The maximum date that can be selected.\n */\n maxDate?: Date;\n /**\n * The minimum date that can be selected.\n */\n minDate?: Date;\n /**\n * An array of dates that should be disabled.\n */\n disabledDates?: Date[];\n /**\n * Whether the highlighted dates should be displayed for the greyed month overlay days.\n */\n shouldShowHighlightsInMonthOverlay?: boolean;\n /**\n * Shows the month and year pickers, if there are multiple months/years to select from.\n */\n showMonthYearPickers?: boolean;\n /**\n * Function to be executed when the selected date, dates or date interval change.\n * @param date\n */\n onChange?: (date: Date | Date[] | DateInterval) => void;\n /**\n * Function to be executed when the shown dates change. Returns the start of the displayed month and the end of the last displayed month (since depending on the available widths, there are one or two months displayed).\n @param { start: Date, end: Date }\n */\n onShownDatesChange?: (dates: { start: Date; end: Date }) => void;\n}\n\ninterface SingleSelectionProps {\n /**\n * The type of the calendar selection.\n */\n type?: CalendarType.Single;\n /**\n * A date that should be preselected.\n */\n selectedDate?: Date;\n selectedDates?: never;\n selectedDateInterval?: never;\n}\n\ninterface MultipleSelectionProps {\n /**\n * The type of the calendar selection.\n */\n type: CalendarType.Multiple;\n /**\n * An array of dates that should be preselected.\n */\n selectedDates?: Date[];\n selectedDate?: never;\n selectedDateInterval?: never;\n}\n\ninterface IntervalSelectionProps {\n /**\n * The type of the calendar selection.\n */\n type: CalendarType.Interval;\n /**\n * An interval that should be preselected.\n */\n selectedDateInterval?: DateInterval;\n selectedDates?: never;\n selectedDate?: never;\n}\n\nexport type CalendarProps = BaseProps &\n (SingleSelectionProps | MultipleSelectionProps | IntervalSelectionProps);\n\nconst DEFAULT_MAX_DATE = addYears(new Date(), 1);\nconst DEFAULT_MIN_DATE = subYears(new Date(), 1);\n\nconst Calendar: FC<CalendarProps> = ({\n locale = Language.German,\n maxDate = DEFAULT_MAX_DATE,\n minDate = DEFAULT_MIN_DATE,\n highlightedDates,\n onChange,\n customThumbColors,\n selectedDate,\n selectedDates,\n selectedDateInterval,\n categories,\n isDisabled,\n type = CalendarType.Single,\n shouldShowHighlightsInMonthOverlay = true,\n disabledDates = [],\n showMonthYearPickers: showMonthYearPickersProp,\n onShownDatesChange = () => {},\n}) => {\n const [currentDate, setCurrentDate] = useState<Date>();\n const [shouldRenderTwoMonths, setShouldRenderTwoMonths] = useState(true);\n const [internalSelectedDate, setInternalSelectedDate] = useState<\n Date | Date[] | DateInterval | undefined\n >(() => (type === CalendarType.Multiple ? [] : undefined));\n const [direction, setDirection] = useState<'left' | 'right' | undefined>();\n const [width, setWidth] = useState(0);\n\n const showMonthYearPickers = useMemo(() => {\n const hasMultipleMonths = differenceInCalendarMonths(maxDate, minDate) > 0;\n const hasMultipleYears = getYearsBetween(minDate, maxDate).length > 1;\n\n return !!(showMonthYearPickersProp && (hasMultipleMonths || hasMultipleYears));\n }, [minDate, maxDate, showMonthYearPickersProp]);\n\n const calendarRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (currentDate) {\n const start = new Date(currentDate.getFullYear(), currentDate.getMonth(), 1);\n\n if (shouldRenderTwoMonths) {\n const end = new Date(currentDate.getFullYear(), currentDate.getMonth() + 2, 0);\n onShownDatesChange({\n start,\n end,\n });\n } else {\n const end = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 0);\n onShownDatesChange({\n start,\n end,\n });\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [currentDate, shouldRenderTwoMonths]);\n\n useEffect(() => {\n const bounds = {\n start: minDate,\n end: maxDate,\n };\n if (type === CalendarType.Single) {\n if (selectedDate) {\n const isDisabledDate = disabledDates.some((disabledDate) =>\n isSameDay(selectedDate, disabledDate),\n );\n const isDateInBounds = isWithinInterval(selectedDate, bounds);\n\n if (!isDisabledDate && isDateInBounds) {\n setInternalSelectedDate(selectedDate);\n } else {\n console.warn(\n '[@chayns-components/date] Warning: Failed to set selectedDate, because it is disabled or out of bounds.',\n '\\nselectedDate:',\n selectedDate,\n ...(isDisabledDate ? ['\\nselectedDate is disabled'] : []),\n ...(isDateInBounds\n ? []\n : ['\\nselectedDate is outside of bounds:', { minDate, maxDate }]),\n );\n setInternalSelectedDate(() => undefined);\n }\n } else {\n setInternalSelectedDate(() => undefined);\n }\n } else if (type === CalendarType.Multiple) {\n if (selectedDates) {\n const disabledSelectedDates: Date[] = [];\n const datesOutsideOfBounds: Date[] = [];\n\n const filteredDates = selectedDates.filter((date) => {\n if (disabledDates.some((disabledDate) => isSameDay(date, disabledDate))) {\n disabledSelectedDates.push(date);\n return false;\n }\n\n if (!isWithinInterval(date, bounds)) {\n datesOutsideOfBounds.push(date);\n return false;\n }\n\n return true;\n });\n\n if (disabledSelectedDates.length > 0 || datesOutsideOfBounds.length > 0) {\n console.warn(\n '[@chayns-components/date] Warning: Failed to set all selectedDates, because some are disabled or out of bounds.',\n ...(disabledSelectedDates.length > 0\n ? ['\\nselectedDates that are disabled:', disabledSelectedDates]\n : []),\n ...(datesOutsideOfBounds.length > 0\n ? [\n '\\nselectedDates that are outside of bounds:',\n datesOutsideOfBounds,\n 'bounds:',\n { minDate, maxDate },\n ]\n : []),\n );\n }\n\n setInternalSelectedDate(filteredDates);\n } else {\n setInternalSelectedDate([]);\n }\n } else if (type === CalendarType.Interval) {\n if (selectedDateInterval) {\n const intervalIncludesDisabledDate =\n selectedDateInterval.end &&\n disabledDates.some((disabledDate) =>\n isWithinInterval(disabledDate, {\n start: selectedDateInterval.start,\n end: selectedDateInterval.end as Date,\n }),\n );\n\n const intervalIsInBounds =\n isWithinInterval(selectedDateInterval.start, bounds) &&\n (!selectedDateInterval.end ||\n isWithinInterval(selectedDateInterval.end, bounds));\n\n if (!intervalIncludesDisabledDate && intervalIsInBounds) {\n setInternalSelectedDate(selectedDateInterval);\n } else {\n console.warn(\n '[@chayns-components/date] Warning: Failed to set selectedDateInterval, because it includes disabled dates or dates that are out of bounds.',\n '\\nselectedDateInterval:',\n selectedDateInterval,\n ...(intervalIncludesDisabledDate\n ? ['\\ndisabled dates:', disabledDates]\n : []),\n ...(intervalIsInBounds ? [] : ['\\nbounds:', { minDate, maxDate }]),\n );\n setInternalSelectedDate(() => undefined);\n }\n }\n }\n }, [type, selectedDate, selectedDates, selectedDateInterval, disabledDates, minDate, maxDate]);\n\n useEffect(() => {\n if (calendarRef.current) {\n const resizeObserver = new ResizeObserver((entries) => {\n if (entries && entries[0]) {\n const observedWidth = entries[0].contentRect.width;\n\n setWidth(observedWidth - 30);\n\n if (observedWidth < 430) {\n setShouldRenderTwoMonths(false);\n } else {\n setShouldRenderTwoMonths(true);\n }\n }\n });\n\n resizeObserver.observe(calendarRef.current);\n\n return () => {\n resizeObserver.disconnect();\n };\n }\n\n return () => {};\n }, []);\n\n useEffect(() => {\n setCurrentDate((prevDate) =>\n isDateInRange({ minDate, maxDate, currentDate: prevDate || new Date() }),\n );\n }, [maxDate, minDate]);\n\n const handleLeftArrowClick = useCallback(() => {\n if (direction) return;\n\n setDirection('left');\n\n setCurrentDate((prevDate) => {\n if (!prevDate) {\n return prevDate;\n }\n\n const newDate = getNewDate(-1, prevDate);\n\n return isDateInRange({ minDate, maxDate, currentDate: newDate });\n });\n }, [maxDate, minDate, direction]);\n\n const handleRightArrowClick = useCallback(() => {\n if (direction) return;\n\n setDirection('right');\n\n setCurrentDate((prevDate) => {\n if (!prevDate) {\n return prevDate;\n }\n\n const newDate = getNewDate(1, prevDate);\n\n return isDateInRange({ minDate, maxDate, currentDate: newDate });\n });\n }, [maxDate, minDate, direction]);\n\n const handleSelect = useCallback(\n (date: Date) => {\n setInternalSelectedDate((prevDate) => {\n let onChangePayload: Date | Date[] | DateInterval | null = null;\n let newInternalSelectedDate: Date | Date[] | DateInterval | undefined;\n\n if (type === CalendarType.Single) {\n onChangePayload = date;\n newInternalSelectedDate = date;\n } else if (type === CalendarType.Multiple) {\n const prevSelectedDates = prevDate as Date[];\n // Selects or unselects date , depending on if it is already selected.\n if (prevSelectedDates.some((d) => isSameDay(d, date))) {\n newInternalSelectedDate = prevSelectedDates.filter(\n (d) => !isSameDay(d, date),\n );\n } else {\n newInternalSelectedDate = [...prevSelectedDates, date];\n }\n\n onChangePayload = newInternalSelectedDate;\n } else if (type === CalendarType.Interval) {\n const prevSelectedDateInterval = prevDate as DateInterval;\n\n const updateInterval = (start: Date, end?: Date): void => {\n const newInterval = { start, end };\n onChangePayload = newInterval;\n newInternalSelectedDate = newInterval;\n };\n\n // Sets first selection as interval start.\n if (!prevSelectedDateInterval) {\n updateInterval(date);\n } else if (prevSelectedDateInterval.start && !prevSelectedDateInterval.end) {\n // Sets second selection as interval start, if it is earlier than the previous interval start.\n // Else sets it as interval end.\n if (date < prevSelectedDateInterval.start) {\n updateInterval(date);\n } else {\n updateInterval(prevSelectedDateInterval.start, date);\n }\n } else {\n // Resets interval if a third date is selected.\n updateInterval(date);\n }\n }\n\n if (typeof onChange === 'function' && onChangePayload) {\n onChange(onChangePayload);\n }\n\n return newInternalSelectedDate;\n });\n },\n [type, onChange],\n );\n\n const handleAnimationFinished = () => {\n setDirection(() => undefined);\n };\n\n const ShouldShowLeftArrow = useMemo(() => {\n if (!currentDate) {\n return false;\n }\n\n return !isSameMonth(currentDate, minDate);\n }, [currentDate, minDate]);\n\n const ShouldShowRightArrow = useMemo(() => {\n if (!currentDate) {\n return false;\n }\n\n return !isSameMonth(currentDate, maxDate);\n }, [currentDate, maxDate]);\n\n return (\n <StyledCalendar ref={calendarRef} $isDisabled={isDisabled}>\n {ShouldShowLeftArrow ? (\n <StyledCalendarIconWrapper onClick={handleLeftArrowClick}>\n <div // TODO Use styled-components instead of inline styles\n style={{\n display: 'flex',\n flexDirection: 'row',\n flexWrap: 'nowrap',\n height: 'fit-content',\n }}\n >\n {showMonthYearPickers && (\n <StyledPseudoMonthYearPicker>\n <ComboBox lists={[{ list: [] }]} placeholder=\"\" />\n </StyledPseudoMonthYearPicker>\n )}\n <Icon icons={['fa fa-angle-left']} />\n </div>\n </StyledCalendarIconWrapper>\n ) : (\n <StyledCalendarIconWrapperPseudo />\n )}\n {currentDate && (\n <MonthWrapper\n shouldRenderTwo={shouldRenderTwoMonths}\n currentDate={currentDate}\n width={width}\n locale={locale}\n direction={direction}\n customThumbColors={customThumbColors}\n onSelect={handleSelect}\n selectedDate={internalSelectedDate}\n highlightedDates={highlightedDates}\n categories={categories}\n onAnimationFinished={handleAnimationFinished}\n minDate={minDate}\n maxDate={maxDate}\n type={type}\n disabledDates={disabledDates}\n setCurrentDate={setCurrentDate}\n shouldShowHighlightsInMonthOverlay={shouldShowHighlightsInMonthOverlay}\n showMonthYearPickers={showMonthYearPickers}\n />\n )}\n {ShouldShowRightArrow ? (\n <StyledCalendarIconWrapper onClick={handleRightArrowClick}>\n <div // TODO Use styled-components instead of inline styles\n style={{\n display: 'flex',\n flexDirection: 'row',\n flexWrap: 'nowrap',\n height: 'fit-content',\n }}\n >\n {showMonthYearPickers && (\n <StyledPseudoMonthYearPicker>\n <ComboBox lists={[{ list: [] }]} placeholder=\"\" />\n </StyledPseudoMonthYearPicker>\n )}\n <Icon icons={['fa fa-angle-right']} />\n </div>\n </StyledCalendarIconWrapper>\n ) : (\n <StyledCalendarIconWrapperPseudo />\n )}\n </StyledCalendar>\n );\n};\n\nCalendar.displayName = 'Calendar';\n\nexport default Calendar;\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,uBAAA,CAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAOA,IAAAK,UAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AAQA,IAAAO,SAAA,GAAAP,OAAA;AAMA,IAAAQ,aAAA,GAAAC,sBAAA,CAAAT,OAAA;AAAwD,SAAAS,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAAH,CAAA,6BAAAI,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAD,wBAAA,YAAAA,CAAAH,CAAA,WAAAA,CAAA,GAAAM,CAAA,GAAAD,CAAA,KAAAL,CAAA;AAAA,SAAAP,wBAAAO,CAAA,EAAAK,CAAA,SAAAA,CAAA,IAAAL,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAE,OAAA,EAAAF,CAAA,QAAAM,CAAA,GAAAH,wBAAA,CAAAE,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAC,GAAA,CAAAP,CAAA,UAAAM,CAAA,CAAAE,GAAA,CAAAR,CAAA,OAAAS,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAf,CAAA,oBAAAe,CAAA,OAAAC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|
|
2
|
+
import { Language } from 'chayns-api';
|
|
2
3
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
4
|
import { CalendarType } from '../../types/calendar';
|
|
4
5
|
import { getNewDate, getYearsBetween, isDateInRange } from '../../utils/calendar';
|
|
6
|
+
import { addYears, differenceInCalendarMonths, isSameDay, isSameMonth, isWithinInterval, subYears } from '../../utils/date';
|
|
5
7
|
import { StyledCalendar, StyledCalendarIconWrapper, StyledCalendarIconWrapperPseudo, StyledPseudoMonthYearPicker } from './Calendar.styles';
|
|
6
8
|
import MonthWrapper from './month-wrapper/MonthWrapper';
|
|
7
|
-
import { Language } from "chayns-api";
|
|
8
|
-
import { addYears, differenceInCalendarMonths, isSameDay, isSameMonth, isWithinInterval, subYears } from "../../utils/date";
|
|
9
9
|
const DEFAULT_MAX_DATE = addYears(new Date(), 1);
|
|
10
10
|
const DEFAULT_MIN_DATE = subYears(new Date(), 1);
|
|
11
11
|
const Calendar = _ref => {
|
|
@@ -29,7 +29,7 @@ const Calendar = _ref => {
|
|
|
29
29
|
} = _ref;
|
|
30
30
|
const [currentDate, setCurrentDate] = useState();
|
|
31
31
|
const [shouldRenderTwoMonths, setShouldRenderTwoMonths] = useState(true);
|
|
32
|
-
const [internalSelectedDate, setInternalSelectedDate] = useState(type === CalendarType.Multiple ? [] : undefined);
|
|
32
|
+
const [internalSelectedDate, setInternalSelectedDate] = useState(() => type === CalendarType.Multiple ? [] : undefined);
|
|
33
33
|
const [direction, setDirection] = useState();
|
|
34
34
|
const [width, setWidth] = useState(0);
|
|
35
35
|
const showMonthYearPickers = useMemo(() => {
|
|
@@ -55,7 +55,8 @@ const Calendar = _ref => {
|
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
59
|
+
}, [currentDate, shouldRenderTwoMonths]);
|
|
59
60
|
useEffect(() => {
|
|
60
61
|
const bounds = {
|
|
61
62
|
start: minDate,
|
|
@@ -72,10 +73,10 @@ const Calendar = _ref => {
|
|
|
72
73
|
minDate,
|
|
73
74
|
maxDate
|
|
74
75
|
}]));
|
|
75
|
-
setInternalSelectedDate(undefined);
|
|
76
|
+
setInternalSelectedDate(() => undefined);
|
|
76
77
|
}
|
|
77
78
|
} else {
|
|
78
|
-
setInternalSelectedDate(undefined);
|
|
79
|
+
setInternalSelectedDate(() => undefined);
|
|
79
80
|
}
|
|
80
81
|
} else if (type === CalendarType.Multiple) {
|
|
81
82
|
if (selectedDates) {
|
|
@@ -116,7 +117,7 @@ const Calendar = _ref => {
|
|
|
116
117
|
minDate,
|
|
117
118
|
maxDate
|
|
118
119
|
}]));
|
|
119
|
-
setInternalSelectedDate(undefined);
|
|
120
|
+
setInternalSelectedDate(() => undefined);
|
|
120
121
|
}
|
|
121
122
|
}
|
|
122
123
|
}
|
|
@@ -228,7 +229,7 @@ const Calendar = _ref => {
|
|
|
228
229
|
});
|
|
229
230
|
}, [type, onChange]);
|
|
230
231
|
const handleAnimationFinished = () => {
|
|
231
|
-
setDirection(undefined);
|
|
232
|
+
setDirection(() => undefined);
|
|
232
233
|
};
|
|
233
234
|
const ShouldShowLeftArrow = useMemo(() => {
|
|
234
235
|
if (!currentDate) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Calendar.js","names":["ComboBox","Icon","React","useCallback","useEffect","useMemo","useRef","useState","CalendarType","getNewDate","getYearsBetween","isDateInRange","StyledCalendar","StyledCalendarIconWrapper","StyledCalendarIconWrapperPseudo","StyledPseudoMonthYearPicker","MonthWrapper","Language","addYears","differenceInCalendarMonths","isSameDay","isSameMonth","isWithinInterval","subYears","DEFAULT_MAX_DATE","Date","DEFAULT_MIN_DATE","Calendar","_ref","locale","German","maxDate","minDate","highlightedDates","onChange","customThumbColors","selectedDate","selectedDates","selectedDateInterval","categories","isDisabled","type","Single","shouldShowHighlightsInMonthOverlay","disabledDates","showMonthYearPickers","showMonthYearPickersProp","onShownDatesChange","currentDate","setCurrentDate","shouldRenderTwoMonths","setShouldRenderTwoMonths","internalSelectedDate","setInternalSelectedDate","Multiple","undefined","direction","setDirection","width","setWidth","hasMultipleMonths","hasMultipleYears","length","calendarRef","start","getFullYear","getMonth","end","bounds","isDisabledDate","some","disabledDate","isDateInBounds","console","warn","disabledSelectedDates","datesOutsideOfBounds","filteredDates","filter","date","push","Interval","intervalIncludesDisabledDate","intervalIsInBounds","current","resizeObserver","ResizeObserver","entries","observedWidth","contentRect","observe","disconnect","prevDate","handleLeftArrowClick","newDate","handleRightArrowClick","handleSelect","onChangePayload","newInternalSelectedDate","prevSelectedDates","d","prevSelectedDateInterval","updateInterval","newInterval","handleAnimationFinished","ShouldShowLeftArrow","ShouldShowRightArrow","createElement","ref","$isDisabled","onClick","style","display","flexDirection","flexWrap","height","lists","list","placeholder","icons","shouldRenderTwo","onSelect","onAnimationFinished","displayName"],"sources":["../../../../src/components/calendar/Calendar.tsx"],"sourcesContent":["import { ComboBox, Icon } from '@chayns-components/core';\nimport 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';\nimport {Language} from \"chayns-api\";\nimport {\n addYears,\n differenceInCalendarMonths,\n isSameDay,\n isSameMonth,\n isWithinInterval,\n subYears\n} from \"../../utils/date\";\n\ninterface BaseProps {\n /**\n * An array to group dates into a category.\n */\n categories?: Categories[];\n /**\n * Custom colors for the thumb.\n */\n customThumbColors?: CustomThumbColors;\n /**\n * An array with dates and corresponding styles to highlight.\n */\n highlightedDates?: HighlightedDates[];\n /**\n * To disable the Calendar\n */\n isDisabled?: boolean;\n /**\n * The locale language to format the dates.\n */\n locale?: Language;\n /**\n * The maximum date that can be selected.\n */\n maxDate?: Date;\n /**\n * The minimum date that can be selected.\n */\n minDate?: Date;\n /**\n * An array of dates that should be disabled.\n */\n disabledDates?: Date[];\n /**\n * Whether the highlighted dates should be displayed for the greyed month overlay days.\n */\n shouldShowHighlightsInMonthOverlay?: boolean;\n /**\n * Shows the month and year pickers, if there are multiple months/years to select from.\n */\n showMonthYearPickers?: boolean;\n /**\n * Function to be executed when the selected date, dates or date interval change.\n * @param date\n */\n onChange?: (date: Date | Date[] | DateInterval) => void;\n /**\n * Function to be executed when the shown dates change. Returns the start of the displayed month and the end of the last displayed month (since depending on the available widths, there are one or two months displayed).\n @param { start: Date, end: Date }\n */\n onShownDatesChange?: (dates: { start: Date; end: Date }) => void;\n}\n\ninterface SingleSelectionProps {\n /**\n * The type of the calendar selection.\n */\n type?: CalendarType.Single;\n /**\n * A date that should be preselected.\n */\n selectedDate?: Date;\n selectedDates: never;\n selectedDateInterval: never;\n}\n\ninterface MultipleSelectionProps {\n /**\n * The type of the calendar selection.\n */\n type: CalendarType.Multiple;\n /**\n * An array of dates that should be preselected.\n */\n selectedDates?: Date[];\n selectedDate: never;\n selectedDateInterval: never;\n}\n\ninterface IntervalSelectionProps {\n /**\n * The type of the calendar selection.\n */\n type: CalendarType.Interval;\n /**\n * An interval that should be preselected.\n */\n selectedDateInterval?: DateInterval;\n selectedDates: never;\n selectedDate: never;\n}\n\nexport type CalendarProps = BaseProps &\n (SingleSelectionProps | MultipleSelectionProps | IntervalSelectionProps);\n\nconst DEFAULT_MAX_DATE = addYears(new Date(), 1);\nconst DEFAULT_MIN_DATE = subYears(new Date(), 1);\n\nconst Calendar: FC<CalendarProps> = ({\n locale = Language.German,\n maxDate = DEFAULT_MAX_DATE,\n minDate = DEFAULT_MIN_DATE,\n highlightedDates,\n onChange,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, onShownDatesChange, 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,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;AACvD,SAAQC,QAAQ,QAAO,YAAY;AACnC,SACIC,QAAQ,EACRC,0BAA0B,EAC1BC,SAAS,EACTC,WAAW,EACXC,gBAAgB,EAChBC,QAAQ,QACL,kBAAkB;AAiGzB,MAAMC,gBAAgB,GAAGN,QAAQ,C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aAAA,CAAC7F,+BAA+B,MAAE,CAE1B,CAAC;AAEzB,CAAC;AAEDa,QAAQ,CAACgG,WAAW,GAAG,UAAU;AAEjC,eAAehG,QAAQ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Calendar.js","names":["ComboBox","Icon","Language","React","useCallback","useEffect","useMemo","useRef","useState","CalendarType","getNewDate","getYearsBetween","isDateInRange","addYears","differenceInCalendarMonths","isSameDay","isSameMonth","isWithinInterval","subYears","StyledCalendar","StyledCalendarIconWrapper","StyledCalendarIconWrapperPseudo","StyledPseudoMonthYearPicker","MonthWrapper","DEFAULT_MAX_DATE","Date","DEFAULT_MIN_DATE","Calendar","_ref","locale","German","maxDate","minDate","highlightedDates","onChange","customThumbColors","selectedDate","selectedDates","selectedDateInterval","categories","isDisabled","type","Single","shouldShowHighlightsInMonthOverlay","disabledDates","showMonthYearPickers","showMonthYearPickersProp","onShownDatesChange","currentDate","setCurrentDate","shouldRenderTwoMonths","setShouldRenderTwoMonths","internalSelectedDate","setInternalSelectedDate","Multiple","undefined","direction","setDirection","width","setWidth","hasMultipleMonths","hasMultipleYears","length","calendarRef","start","getFullYear","getMonth","end","bounds","isDisabledDate","some","disabledDate","isDateInBounds","console","warn","disabledSelectedDates","datesOutsideOfBounds","filteredDates","filter","date","push","Interval","intervalIncludesDisabledDate","intervalIsInBounds","current","resizeObserver","ResizeObserver","entries","observedWidth","contentRect","observe","disconnect","prevDate","handleLeftArrowClick","newDate","handleRightArrowClick","handleSelect","onChangePayload","newInternalSelectedDate","prevSelectedDates","d","prevSelectedDateInterval","updateInterval","newInterval","handleAnimationFinished","ShouldShowLeftArrow","ShouldShowRightArrow","createElement","ref","$isDisabled","onClick","style","display","flexDirection","flexWrap","height","lists","list","placeholder","icons","shouldRenderTwo","onSelect","onAnimationFinished","displayName"],"sources":["../../../../src/components/calendar/Calendar.tsx"],"sourcesContent":["import { ComboBox, Icon } from '@chayns-components/core';\nimport { Language } from 'chayns-api';\nimport React, { FC, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport {\n CalendarType,\n Categories,\n CustomThumbColors,\n DateInterval,\n HighlightedDates,\n} from '../../types/calendar';\nimport { getNewDate, getYearsBetween, isDateInRange } from '../../utils/calendar';\nimport {\n addYears,\n differenceInCalendarMonths,\n isSameDay,\n isSameMonth,\n isWithinInterval,\n subYears,\n} from '../../utils/date';\nimport {\n StyledCalendar,\n StyledCalendarIconWrapper,\n StyledCalendarIconWrapperPseudo,\n StyledPseudoMonthYearPicker,\n} from './Calendar.styles';\nimport MonthWrapper from './month-wrapper/MonthWrapper';\n\ninterface BaseProps {\n /**\n * An array to group dates into a category.\n */\n categories?: Categories[];\n /**\n * Custom colors for the thumb.\n */\n customThumbColors?: CustomThumbColors;\n /**\n * An array with dates and corresponding styles to highlight.\n */\n highlightedDates?: HighlightedDates[];\n /**\n * To disable the Calendar\n */\n isDisabled?: boolean;\n /**\n * The locale language to format the dates.\n */\n locale?: Language;\n /**\n * The maximum date that can be selected.\n */\n maxDate?: Date;\n /**\n * The minimum date that can be selected.\n */\n minDate?: Date;\n /**\n * An array of dates that should be disabled.\n */\n disabledDates?: Date[];\n /**\n * Whether the highlighted dates should be displayed for the greyed month overlay days.\n */\n shouldShowHighlightsInMonthOverlay?: boolean;\n /**\n * Shows the month and year pickers, if there are multiple months/years to select from.\n */\n showMonthYearPickers?: boolean;\n /**\n * Function to be executed when the selected date, dates or date interval change.\n * @param date\n */\n onChange?: (date: Date | Date[] | DateInterval) => void;\n /**\n * Function to be executed when the shown dates change. Returns the start of the displayed month and the end of the last displayed month (since depending on the available widths, there are one or two months displayed).\n @param { start: Date, end: Date }\n */\n onShownDatesChange?: (dates: { start: Date; end: Date }) => void;\n}\n\ninterface SingleSelectionProps {\n /**\n * The type of the calendar selection.\n */\n type?: CalendarType.Single;\n /**\n * A date that should be preselected.\n */\n selectedDate?: Date;\n selectedDates?: never;\n selectedDateInterval?: never;\n}\n\ninterface MultipleSelectionProps {\n /**\n * The type of the calendar selection.\n */\n type: CalendarType.Multiple;\n /**\n * An array of dates that should be preselected.\n */\n selectedDates?: Date[];\n selectedDate?: never;\n selectedDateInterval?: never;\n}\n\ninterface IntervalSelectionProps {\n /**\n * The type of the calendar selection.\n */\n type: CalendarType.Interval;\n /**\n * An interval that should be preselected.\n */\n selectedDateInterval?: DateInterval;\n selectedDates?: never;\n selectedDate?: never;\n}\n\nexport type CalendarProps = BaseProps &\n (SingleSelectionProps | MultipleSelectionProps | IntervalSelectionProps);\n\nconst DEFAULT_MAX_DATE = addYears(new Date(), 1);\nconst DEFAULT_MIN_DATE = subYears(new Date(), 1);\n\nconst Calendar: FC<CalendarProps> = ({\n locale = Language.German,\n maxDate = DEFAULT_MAX_DATE,\n minDate = DEFAULT_MIN_DATE,\n highlightedDates,\n onChange,\n customThumbColors,\n selectedDate,\n selectedDates,\n selectedDateInterval,\n categories,\n isDisabled,\n type = CalendarType.Single,\n shouldShowHighlightsInMonthOverlay = true,\n disabledDates = [],\n showMonthYearPickers: showMonthYearPickersProp,\n onShownDatesChange = () => {},\n}) => {\n const [currentDate, setCurrentDate] = useState<Date>();\n const [shouldRenderTwoMonths, setShouldRenderTwoMonths] = useState(true);\n const [internalSelectedDate, setInternalSelectedDate] = useState<\n Date | Date[] | DateInterval | undefined\n >(() => (type === CalendarType.Multiple ? [] : undefined));\n const [direction, setDirection] = useState<'left' | 'right' | undefined>();\n const [width, setWidth] = useState(0);\n\n const showMonthYearPickers = useMemo(() => {\n const hasMultipleMonths = differenceInCalendarMonths(maxDate, minDate) > 0;\n const hasMultipleYears = getYearsBetween(minDate, maxDate).length > 1;\n\n return !!(showMonthYearPickersProp && (hasMultipleMonths || hasMultipleYears));\n }, [minDate, maxDate, showMonthYearPickersProp]);\n\n const calendarRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (currentDate) {\n const start = new Date(currentDate.getFullYear(), currentDate.getMonth(), 1);\n\n if (shouldRenderTwoMonths) {\n const end = new Date(currentDate.getFullYear(), currentDate.getMonth() + 2, 0);\n onShownDatesChange({\n start,\n end,\n });\n } else {\n const end = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 0);\n onShownDatesChange({\n start,\n end,\n });\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [currentDate, shouldRenderTwoMonths]);\n\n useEffect(() => {\n const bounds = {\n start: minDate,\n end: maxDate,\n };\n if (type === CalendarType.Single) {\n if (selectedDate) {\n const isDisabledDate = disabledDates.some((disabledDate) =>\n isSameDay(selectedDate, disabledDate),\n );\n const isDateInBounds = isWithinInterval(selectedDate, bounds);\n\n if (!isDisabledDate && isDateInBounds) {\n setInternalSelectedDate(selectedDate);\n } else {\n console.warn(\n '[@chayns-components/date] Warning: Failed to set selectedDate, because it is disabled or out of bounds.',\n '\\nselectedDate:',\n selectedDate,\n ...(isDisabledDate ? ['\\nselectedDate is disabled'] : []),\n ...(isDateInBounds\n ? []\n : ['\\nselectedDate is outside of bounds:', { minDate, maxDate }]),\n );\n setInternalSelectedDate(() => undefined);\n }\n } else {\n setInternalSelectedDate(() => undefined);\n }\n } else if (type === CalendarType.Multiple) {\n if (selectedDates) {\n const disabledSelectedDates: Date[] = [];\n const datesOutsideOfBounds: Date[] = [];\n\n const filteredDates = selectedDates.filter((date) => {\n if (disabledDates.some((disabledDate) => isSameDay(date, disabledDate))) {\n disabledSelectedDates.push(date);\n return false;\n }\n\n if (!isWithinInterval(date, bounds)) {\n datesOutsideOfBounds.push(date);\n return false;\n }\n\n return true;\n });\n\n if (disabledSelectedDates.length > 0 || datesOutsideOfBounds.length > 0) {\n console.warn(\n '[@chayns-components/date] Warning: Failed to set all selectedDates, because some are disabled or out of bounds.',\n ...(disabledSelectedDates.length > 0\n ? ['\\nselectedDates that are disabled:', disabledSelectedDates]\n : []),\n ...(datesOutsideOfBounds.length > 0\n ? [\n '\\nselectedDates that are outside of bounds:',\n datesOutsideOfBounds,\n 'bounds:',\n { minDate, maxDate },\n ]\n : []),\n );\n }\n\n setInternalSelectedDate(filteredDates);\n } else {\n setInternalSelectedDate([]);\n }\n } else if (type === CalendarType.Interval) {\n if (selectedDateInterval) {\n const intervalIncludesDisabledDate =\n selectedDateInterval.end &&\n disabledDates.some((disabledDate) =>\n isWithinInterval(disabledDate, {\n start: selectedDateInterval.start,\n end: selectedDateInterval.end as Date,\n }),\n );\n\n const intervalIsInBounds =\n isWithinInterval(selectedDateInterval.start, bounds) &&\n (!selectedDateInterval.end ||\n isWithinInterval(selectedDateInterval.end, bounds));\n\n if (!intervalIncludesDisabledDate && intervalIsInBounds) {\n setInternalSelectedDate(selectedDateInterval);\n } else {\n console.warn(\n '[@chayns-components/date] Warning: Failed to set selectedDateInterval, because it includes disabled dates or dates that are out of bounds.',\n '\\nselectedDateInterval:',\n selectedDateInterval,\n ...(intervalIncludesDisabledDate\n ? ['\\ndisabled dates:', disabledDates]\n : []),\n ...(intervalIsInBounds ? [] : ['\\nbounds:', { minDate, maxDate }]),\n );\n setInternalSelectedDate(() => undefined);\n }\n }\n }\n }, [type, selectedDate, selectedDates, selectedDateInterval, disabledDates, minDate, maxDate]);\n\n useEffect(() => {\n if (calendarRef.current) {\n const resizeObserver = new ResizeObserver((entries) => {\n if (entries && entries[0]) {\n const observedWidth = entries[0].contentRect.width;\n\n setWidth(observedWidth - 30);\n\n if (observedWidth < 430) {\n setShouldRenderTwoMonths(false);\n } else {\n setShouldRenderTwoMonths(true);\n }\n }\n });\n\n resizeObserver.observe(calendarRef.current);\n\n return () => {\n resizeObserver.disconnect();\n };\n }\n\n return () => {};\n }, []);\n\n useEffect(() => {\n setCurrentDate((prevDate) =>\n isDateInRange({ minDate, maxDate, currentDate: prevDate || new Date() }),\n );\n }, [maxDate, minDate]);\n\n const handleLeftArrowClick = useCallback(() => {\n if (direction) return;\n\n setDirection('left');\n\n setCurrentDate((prevDate) => {\n if (!prevDate) {\n return prevDate;\n }\n\n const newDate = getNewDate(-1, prevDate);\n\n return isDateInRange({ minDate, maxDate, currentDate: newDate });\n });\n }, [maxDate, minDate, direction]);\n\n const handleRightArrowClick = useCallback(() => {\n if (direction) return;\n\n setDirection('right');\n\n setCurrentDate((prevDate) => {\n if (!prevDate) {\n return prevDate;\n }\n\n const newDate = getNewDate(1, prevDate);\n\n return isDateInRange({ minDate, maxDate, currentDate: newDate });\n });\n }, [maxDate, minDate, direction]);\n\n const handleSelect = useCallback(\n (date: Date) => {\n setInternalSelectedDate((prevDate) => {\n let onChangePayload: Date | Date[] | DateInterval | null = null;\n let newInternalSelectedDate: Date | Date[] | DateInterval | undefined;\n\n if (type === CalendarType.Single) {\n onChangePayload = date;\n newInternalSelectedDate = date;\n } else if (type === CalendarType.Multiple) {\n const prevSelectedDates = prevDate as Date[];\n // Selects or unselects date , depending on if it is already selected.\n if (prevSelectedDates.some((d) => isSameDay(d, date))) {\n newInternalSelectedDate = prevSelectedDates.filter(\n (d) => !isSameDay(d, date),\n );\n } else {\n newInternalSelectedDate = [...prevSelectedDates, date];\n }\n\n onChangePayload = newInternalSelectedDate;\n } else if (type === CalendarType.Interval) {\n const prevSelectedDateInterval = prevDate as DateInterval;\n\n const updateInterval = (start: Date, end?: Date): void => {\n const newInterval = { start, end };\n onChangePayload = newInterval;\n newInternalSelectedDate = newInterval;\n };\n\n // Sets first selection as interval start.\n if (!prevSelectedDateInterval) {\n updateInterval(date);\n } else if (prevSelectedDateInterval.start && !prevSelectedDateInterval.end) {\n // Sets second selection as interval start, if it is earlier than the previous interval start.\n // Else sets it as interval end.\n if (date < prevSelectedDateInterval.start) {\n updateInterval(date);\n } else {\n updateInterval(prevSelectedDateInterval.start, date);\n }\n } else {\n // Resets interval if a third date is selected.\n updateInterval(date);\n }\n }\n\n if (typeof onChange === 'function' && onChangePayload) {\n onChange(onChangePayload);\n }\n\n return newInternalSelectedDate;\n });\n },\n [type, onChange],\n );\n\n const handleAnimationFinished = () => {\n setDirection(() => undefined);\n };\n\n const ShouldShowLeftArrow = useMemo(() => {\n if (!currentDate) {\n return false;\n }\n\n return !isSameMonth(currentDate, minDate);\n }, [currentDate, minDate]);\n\n const ShouldShowRightArrow = useMemo(() => {\n if (!currentDate) {\n return false;\n }\n\n return !isSameMonth(currentDate, maxDate);\n }, [currentDate, maxDate]);\n\n return (\n <StyledCalendar ref={calendarRef} $isDisabled={isDisabled}>\n {ShouldShowLeftArrow ? (\n <StyledCalendarIconWrapper onClick={handleLeftArrowClick}>\n <div // TODO Use styled-components instead of inline styles\n style={{\n display: 'flex',\n flexDirection: 'row',\n flexWrap: 'nowrap',\n height: 'fit-content',\n }}\n >\n {showMonthYearPickers && (\n <StyledPseudoMonthYearPicker>\n <ComboBox lists={[{ list: [] }]} placeholder=\"\" />\n </StyledPseudoMonthYearPicker>\n )}\n <Icon icons={['fa fa-angle-left']} />\n </div>\n </StyledCalendarIconWrapper>\n ) : (\n <StyledCalendarIconWrapperPseudo />\n )}\n {currentDate && (\n <MonthWrapper\n shouldRenderTwo={shouldRenderTwoMonths}\n currentDate={currentDate}\n width={width}\n locale={locale}\n direction={direction}\n customThumbColors={customThumbColors}\n onSelect={handleSelect}\n selectedDate={internalSelectedDate}\n highlightedDates={highlightedDates}\n categories={categories}\n onAnimationFinished={handleAnimationFinished}\n minDate={minDate}\n maxDate={maxDate}\n type={type}\n disabledDates={disabledDates}\n setCurrentDate={setCurrentDate}\n shouldShowHighlightsInMonthOverlay={shouldShowHighlightsInMonthOverlay}\n showMonthYearPickers={showMonthYearPickers}\n />\n )}\n {ShouldShowRightArrow ? (\n <StyledCalendarIconWrapper onClick={handleRightArrowClick}>\n <div // TODO Use styled-components instead of inline styles\n style={{\n display: 'flex',\n flexDirection: 'row',\n flexWrap: 'nowrap',\n height: 'fit-content',\n }}\n >\n {showMonthYearPickers && (\n <StyledPseudoMonthYearPicker>\n <ComboBox lists={[{ list: [] }]} placeholder=\"\" />\n </StyledPseudoMonthYearPicker>\n )}\n <Icon icons={['fa fa-angle-right']} />\n </div>\n </StyledCalendarIconWrapper>\n ) : (\n <StyledCalendarIconWrapperPseudo />\n )}\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AEA;EAAqB,CAC9C,CACJ,EACA6D,oBAAoB,gBACjBvG,KAAA,CAAAwG,aAAA,CAACvF,yBAAyB;IAAC0F,OAAO,EAAEf;EAAsB,gBACtD5F,KAAA,CAAAwG,aAAA;IAAK;IACDI,KAAK,EAAE;MACHC,OAAO,EAAE,MAAM;MACfC,aAAa,EAAE,KAAK;MACpBC,QAAQ,EAAE,QAAQ;MAClBC,MAAM,EAAE;IACZ;EAAE,GAEDtE,oBAAoB,iBACjB1C,KAAA,CAAAwG,aAAA,CAACrF,2BAA2B,qBACxBnB,KAAA,CAAAwG,aAAA,CAAC3G,QAAQ;IAACoH,KAAK,EAAE,CAAC;MAAEC,IAAI,EAAE;IAAG,CAAC,CAAE;IAACC,WAAW,EAAC;EAAE,CAAE,CACxB,CAChC,eACDnH,KAAA,CAAAwG,aAAA,CAAC1G,IAAI;IAACsH,KAAK,EAAE,CAAC,mBAAmB;EAAE,CAAE,CACpC,CACkB,CAAC,gBAE5BpH,KAAA,CAAAwG,aAAA,CAACtF,+BAA+B,MAAE,CAE1B,CAAC;AAEzB,CAAC;AAEDM,QAAQ,CAACgG,WAAW,GAAG,UAAU;AAEjC,eAAehG,QAAQ","ignoreList":[]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import { Language } from 'chayns-api';
|
|
1
2
|
import { FC } from 'react';
|
|
2
|
-
import { Categories, CustomThumbColors, DateInterval, HighlightedDates } from '../../types/calendar';
|
|
3
|
-
import { CalendarType } from '../../types/calendar';
|
|
4
|
-
import { Language } from "chayns-api";
|
|
3
|
+
import { CalendarType, Categories, CustomThumbColors, DateInterval, HighlightedDates } from '../../types/calendar';
|
|
5
4
|
interface BaseProps {
|
|
6
5
|
/**
|
|
7
6
|
* An array to group dates into a category.
|
|
@@ -66,8 +65,8 @@ interface SingleSelectionProps {
|
|
|
66
65
|
* A date that should be preselected.
|
|
67
66
|
*/
|
|
68
67
|
selectedDate?: Date;
|
|
69
|
-
selectedDates
|
|
70
|
-
selectedDateInterval
|
|
68
|
+
selectedDates?: never;
|
|
69
|
+
selectedDateInterval?: never;
|
|
71
70
|
}
|
|
72
71
|
interface MultipleSelectionProps {
|
|
73
72
|
/**
|
|
@@ -78,8 +77,8 @@ interface MultipleSelectionProps {
|
|
|
78
77
|
* An array of dates that should be preselected.
|
|
79
78
|
*/
|
|
80
79
|
selectedDates?: Date[];
|
|
81
|
-
selectedDate
|
|
82
|
-
selectedDateInterval
|
|
80
|
+
selectedDate?: never;
|
|
81
|
+
selectedDateInterval?: never;
|
|
83
82
|
}
|
|
84
83
|
interface IntervalSelectionProps {
|
|
85
84
|
/**
|
|
@@ -90,8 +89,8 @@ interface IntervalSelectionProps {
|
|
|
90
89
|
* An interval that should be preselected.
|
|
91
90
|
*/
|
|
92
91
|
selectedDateInterval?: DateInterval;
|
|
93
|
-
selectedDates
|
|
94
|
-
selectedDate
|
|
92
|
+
selectedDates?: never;
|
|
93
|
+
selectedDate?: never;
|
|
95
94
|
}
|
|
96
95
|
export type CalendarProps = BaseProps & (SingleSelectionProps | MultipleSelectionProps | IntervalSelectionProps);
|
|
97
96
|
declare const Calendar: FC<CalendarProps>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chayns-components/date",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.951",
|
|
4
4
|
"description": "A set of beautiful React components for developing your own applications with chayns.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"browserslist": [
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"publishConfig": {
|
|
83
83
|
"access": "public"
|
|
84
84
|
},
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "33a2d78714a28fbe5ed781ff827ee3a108d69a97"
|
|
86
86
|
}
|