@chayns-components/date 5.0.0-beta.998 → 5.0.1
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 -22
- package/lib/cjs/components/calendar/Calendar.js.map +1 -1
- package/lib/cjs/components/calendar/Calendar.styles.js +7 -1
- package/lib/cjs/components/calendar/Calendar.styles.js.map +1 -1
- package/lib/cjs/components/calendar/month-wrapper/MonthWrapper.js +9 -4
- package/lib/cjs/components/calendar/month-wrapper/MonthWrapper.js.map +1 -1
- package/lib/cjs/components/calendar/month-wrapper/MonthWrapper.styles.js +2 -2
- package/lib/cjs/components/calendar/month-wrapper/MonthWrapper.styles.js.map +1 -1
- package/lib/cjs/components/calendar/month-wrapper/month/Month.js +64 -32
- 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 +5 -4
- 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 +7 -4
- 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 +17 -3
- package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/day/Day.styles.js.map +1 -1
- package/lib/cjs/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.js +1 -2
- package/lib/cjs/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.js.map +1 -1
- package/lib/cjs/components/calendar/month-year-pickers/MonthYearPickers.js +4 -3
- package/lib/cjs/components/calendar/month-year-pickers/MonthYearPickers.js.map +1 -1
- package/lib/cjs/components/date-info/DateInfo.js +4 -3
- package/lib/cjs/components/date-info/DateInfo.js.map +1 -1
- package/lib/cjs/components/opening-times/OpeningTimes.js +12 -15
- package/lib/cjs/components/opening-times/OpeningTimes.js.map +1 -1
- package/lib/cjs/components/opening-times/hint-text/HintText.js +1 -2
- package/lib/cjs/components/opening-times/hint-text/HintText.js.map +1 -1
- package/lib/cjs/components/opening-times/opening-inputs/OpeningInputs.js +16 -17
- package/lib/cjs/components/opening-times/opening-inputs/OpeningInputs.js.map +1 -1
- package/lib/cjs/components/opening-times/opening-inputs/OpeningInputs.styles.js +3 -4
- package/lib/cjs/components/opening-times/opening-inputs/OpeningInputs.styles.js.map +1 -1
- package/lib/cjs/components/opening-times/opening-inputs/opening-input/OpeningInput.js +1 -2
- package/lib/cjs/components/opening-times/opening-inputs/opening-input/OpeningInput.js.map +1 -1
- package/lib/cjs/components/opening-times/opening-inputs/opening-input/OpeningInput.styles.js +2 -2
- package/lib/cjs/components/opening-times/opening-inputs/opening-input/OpeningInput.styles.js.map +1 -1
- package/lib/cjs/hooks/useDateInfo.js +3 -1
- package/lib/cjs/hooks/useDateInfo.js.map +1 -1
- package/lib/cjs/index.js +6 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/types/calendar.js.map +1 -1
- package/lib/cjs/types/dateinfo.js +4 -0
- package/lib/cjs/types/dateinfo.js.map +1 -1
- package/lib/cjs/types/openingTimes.js.map +1 -1
- package/lib/cjs/utils/calendar.js.map +1 -1
- package/lib/cjs/utils/date.js.map +1 -1
- package/lib/cjs/utils/dateInfo.js +52 -28
- package/lib/cjs/utils/dateInfo.js.map +1 -1
- package/lib/esm/components/calendar/Calendar.js +26 -39
- package/lib/esm/components/calendar/Calendar.js.map +1 -1
- package/lib/esm/components/calendar/Calendar.styles.js +12 -12
- package/lib/esm/components/calendar/Calendar.styles.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/MonthWrapper.js +28 -23
- package/lib/esm/components/calendar/month-wrapper/MonthWrapper.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/MonthWrapper.styles.js +7 -13
- package/lib/esm/components/calendar/month-wrapper/MonthWrapper.styles.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/month/Month.js +51 -25
- package/lib/esm/components/calendar/month-wrapper/month/Month.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/month/Month.styles.js +3 -6
- package/lib/esm/components/calendar/month-wrapper/month/Month.styles.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.js +20 -19
- 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 +22 -19
- 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 +51 -53
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/Day.styles.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/category/Category.js +5 -8
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/category/Category.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/category/Category.styles.js +3 -6
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/category/Category.styles.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.js +4 -5
- package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.js +3 -6
- package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.styles.js +3 -6
- package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.styles.js.map +1 -1
- package/lib/esm/components/calendar/month-year-pickers/MonthYearPickers.js +13 -12
- package/lib/esm/components/calendar/month-year-pickers/MonthYearPickers.js.map +1 -1
- package/lib/esm/components/date-info/DateInfo.js +12 -11
- package/lib/esm/components/date-info/DateInfo.js.map +1 -1
- package/lib/esm/components/opening-times/OpeningTimes.js +34 -44
- package/lib/esm/components/opening-times/OpeningTimes.js.map +1 -1
- package/lib/esm/components/opening-times/OpeningTimes.styles.js +3 -6
- package/lib/esm/components/opening-times/OpeningTimes.styles.js.map +1 -1
- package/lib/esm/components/opening-times/hint-text/HintText.js +3 -4
- package/lib/esm/components/opening-times/hint-text/HintText.js.map +1 -1
- package/lib/esm/components/opening-times/hint-text/HintText.styles.js +6 -12
- package/lib/esm/components/opening-times/hint-text/HintText.styles.js.map +1 -1
- package/lib/esm/components/opening-times/opening-inputs/OpeningInputs.js +21 -26
- package/lib/esm/components/opening-times/opening-inputs/OpeningInputs.js.map +1 -1
- package/lib/esm/components/opening-times/opening-inputs/OpeningInputs.styles.js +8 -14
- package/lib/esm/components/opening-times/opening-inputs/OpeningInputs.styles.js.map +1 -1
- package/lib/esm/components/opening-times/opening-inputs/opening-input/OpeningInput.js +11 -12
- package/lib/esm/components/opening-times/opening-inputs/opening-input/OpeningInput.js.map +1 -1
- package/lib/esm/components/opening-times/opening-inputs/opening-input/OpeningInput.styles.js +7 -13
- package/lib/esm/components/opening-times/opening-inputs/opening-input/OpeningInput.styles.js.map +1 -1
- package/lib/esm/hooks/useDateInfo.js +13 -12
- package/lib/esm/hooks/useDateInfo.js.map +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/types/calendar.js.map +1 -1
- package/lib/esm/types/dateinfo.js +1 -1
- package/lib/esm/types/dateinfo.js.map +1 -1
- package/lib/esm/types/openingTimes.js.map +1 -1
- package/lib/esm/utils/calendar.js +10 -12
- package/lib/esm/utils/calendar.js.map +1 -1
- package/lib/esm/utils/date.js.map +1 -1
- package/lib/esm/utils/dateInfo.js +65 -45
- package/lib/esm/utils/dateInfo.js.map +1 -1
- package/lib/types/components/calendar/Calendar.d.ts +5 -1
- package/lib/types/components/calendar/Calendar.styles.d.ts +1 -0
- package/lib/types/components/calendar/month-wrapper/MonthWrapper.d.ts +5 -2
- package/lib/types/components/calendar/month-wrapper/MonthWrapper.styles.d.ts +2 -263
- package/lib/types/components/calendar/month-wrapper/month/Month.d.ts +5 -2
- 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 +5 -1
- package/lib/types/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.d.ts +1 -1
- package/lib/types/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.styles.d.ts +1 -1
- package/lib/types/components/calendar/month-year-pickers/MonthYearPickers.d.ts +1 -1
- package/lib/types/components/opening-times/OpeningTimes.d.ts +2 -6
- package/lib/types/components/opening-times/OpeningTimes.styles.d.ts +1 -1
- package/lib/types/components/opening-times/hint-text/HintText.styles.d.ts +1 -1
- package/lib/types/components/opening-times/opening-inputs/OpeningInputs.styles.d.ts +3 -264
- package/lib/types/components/opening-times/opening-inputs/opening-input/OpeningInput.styles.d.ts +2 -263
- package/lib/types/hooks/useDateInfo.d.ts +1 -1
- package/lib/types/index.d.ts +3 -3
- package/lib/types/types/dateinfo.d.ts +14 -5
- package/lib/types/types/openingTimes.d.ts +2 -0
- package/lib/types/utils/calendar.d.ts +1 -1
- package/lib/types/utils/dateInfo.d.ts +6 -1
- package/package.json +18 -17
|
@@ -2,28 +2,30 @@ import React, { useEffect, useMemo, useState } from 'react';
|
|
|
2
2
|
import { getMonthAndYear, getNewDate } from '../../../utils/calendar';
|
|
3
3
|
import Month from './month/Month';
|
|
4
4
|
import { StyledMonthWrapper, StyledMotionWrapper } from './MonthWrapper.styles';
|
|
5
|
-
const MonthWrapper =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
5
|
+
const MonthWrapper = ({
|
|
6
|
+
locale,
|
|
7
|
+
currentDate,
|
|
8
|
+
highlightedDates,
|
|
9
|
+
selectedDate,
|
|
10
|
+
onSelect,
|
|
11
|
+
categories,
|
|
12
|
+
direction,
|
|
13
|
+
onAnimationFinished,
|
|
14
|
+
shouldRenderTwo,
|
|
15
|
+
width,
|
|
16
|
+
customThumbColors,
|
|
17
|
+
isDisabled,
|
|
18
|
+
minDate,
|
|
19
|
+
maxDate,
|
|
20
|
+
shouldShowHighlightsInMonthOverlay,
|
|
21
|
+
type,
|
|
22
|
+
disabledDates,
|
|
23
|
+
setCurrentDate,
|
|
24
|
+
showMonthYearPickers,
|
|
25
|
+
handleLeftArrowClick,
|
|
26
|
+
handleRightArrowClick,
|
|
27
|
+
currentDateBackgroundColor
|
|
28
|
+
}) => {
|
|
27
29
|
const [content, setContent] = useState();
|
|
28
30
|
const [hoveringDay, setHoveringDay] = useState(null);
|
|
29
31
|
const monthHeight = useMemo(() => width / (shouldRenderTwo ? 2 : 1), [width, shouldRenderTwo]);
|
|
@@ -57,7 +59,10 @@ const MonthWrapper = _ref => {
|
|
|
57
59
|
disabledDates: disabledDates,
|
|
58
60
|
setCurrentDate: setCurrentDate,
|
|
59
61
|
displayIndex: i,
|
|
60
|
-
showMonthYearPickers: showMonthYearPickers
|
|
62
|
+
showMonthYearPickers: showMonthYearPickers,
|
|
63
|
+
handleLeftArrowClick: handleLeftArrowClick,
|
|
64
|
+
handleRightArrowClick: handleRightArrowClick,
|
|
65
|
+
currentDateBackgroundColor: currentDateBackgroundColor
|
|
61
66
|
}));
|
|
62
67
|
}
|
|
63
68
|
return items;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MonthWrapper.js","names":["React","useEffect","useMemo","useState","getMonthAndYear","getNewDate","Month","StyledMonthWrapper","StyledMotionWrapper","MonthWrapper","_ref","locale","currentDate","highlightedDates","selectedDate","onSelect","categories","direction","onAnimationFinished","shouldRenderTwo","width","customThumbColors","isDisabled","minDate","maxDate","shouldShowHighlightsInMonthOverlay","type","disabledDates","setCurrentDate","showMonthYearPickers","content","setContent","hoveringDay","setHoveringDay","monthHeight","items","i","date","month","year","push","createElement","height","key","displayIndex","prevState","map","element","index","props","animate","x","$height","$width","$isDisabled","transition","duration","onAnimationComplete","displayName"],"sources":["../../../../../src/components/calendar/month-wrapper/MonthWrapper.tsx"],"sourcesContent":["import type { MotionProps } from 'framer-motion';\nimport React, { FC, useEffect, useMemo, useState, type ReactElement } from 'react';\nimport {\n CalendarType,\n Categories, CustomThumbColors,\n DateInterval,\n HighlightedDates,\n} from '../../../types/calendar';\nimport { getMonthAndYear, getNewDate } from '../../../utils/calendar';\nimport Month from './month/Month';\nimport { StyledMonthWrapper, StyledMotionWrapper } from './MonthWrapper.styles';\nimport {Language} from \"chayns-api\";\n\nexport type MonthWrapperProps = {\n locale: Language;\n highlightedDates?: HighlightedDates[];\n onSelect: (date: Date) => void;\n selectedDate?: Date | Date[] | DateInterval;\n categories?: Categories[];\n currentDate: Date;\n direction?: 'left' | 'right';\n onAnimationFinished: () => void;\n shouldRenderTwo: boolean;\n width: number;\n isDisabled?: boolean;\n maxDate: Date;\n minDate: Date;\n type: CalendarType;\n disabledDates: Date[];\n setCurrentDate: (date: Date) => void;\n shouldShowHighlightsInMonthOverlay: boolean;\n showMonthYearPickers: boolean;\n customThumbColors?: CustomThumbColors;\n};\n\nconst MonthWrapper: FC<MonthWrapperProps> = ({\n locale,\n currentDate,\n highlightedDates,\n selectedDate,\n onSelect,\n categories,\n direction,\n onAnimationFinished,\n shouldRenderTwo,\n width,customThumbColors,\n isDisabled,\n minDate,\n maxDate,\n shouldShowHighlightsInMonthOverlay,\n type,\n disabledDates,\n setCurrentDate,\n showMonthYearPickers,\n}) => {\n const [content, setContent] = useState<ReactElement[]>();\n\n const [hoveringDay, setHoveringDay] = useState<Date | null>(null);\n\n const monthHeight = useMemo(() => width / (shouldRenderTwo ? 2 : 1), [width, shouldRenderTwo]);\n\n useEffect(() => {\n setContent(() => {\n // Initial render of months\n const items: ReactElement[] = [];\n\n for (let i = -1; i < 3; i++) {\n const date = getNewDate(i, currentDate);\n\n const { month, year } = getMonthAndYear(date);\n\n items.push(\n <Month\n height={monthHeight}\n key={`${month}-${year}`}\n month={month}\n year={year}\n locale={locale}\n onSelect={onSelect}\n highlightedDates={highlightedDates}\n shouldShowHighlightsInMonthOverlay={shouldShowHighlightsInMonthOverlay}\n categories={categories}\n selectedDate={selectedDate}\n minDate={minDate}\n maxDate={maxDate}\n type={type}\n customThumbColors={customThumbColors}\n hoveringDay={hoveringDay}\n setHoveringDay={setHoveringDay}\n disabledDates={disabledDates}\n setCurrentDate={setCurrentDate}\n displayIndex={i}\n showMonthYearPickers={showMonthYearPickers}\n />,\n );\n }\n\n return items;\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [monthHeight]);\n\n useEffect(() => {\n // Doesn't update props until animation is completed\n if (direction) return;\n\n setContent((prevState) =>\n (prevState ?? []).map((element, index) => {\n const date = getNewDate(index - 1, currentDate);\n\n const { month, year } = getMonthAndYear(date);\n\n return {\n ...element,\n props: {\n ...element.props,\n categories,\n disabledDates,\n displayIndex: index - 1,\n highlightedDates,\n hoveringDay,\n locale,\n onSelect,\n shouldShowHighlightsInMonthOverlay,\n maxDate,\n minDate,\n month,\n customThumbColors,\n selectedDate,\n setCurrentDate,\n setHoveringDay,\n showMonthYearPickers,\n type,\n year,\n } as ReactElement,\n };\n }),\n );\n }, [\n customThumbColors,\n categories,\n currentDate,\n direction,\n disabledDates,\n highlightedDates,\n hoveringDay,\n locale,\n onAnimationFinished,\n onSelect,\n maxDate,\n minDate,\n selectedDate,\n setCurrentDate,\n setHoveringDay,\n showMonthYearPickers,\n type,\n shouldShowHighlightsInMonthOverlay,\n ]);\n\n const animate: MotionProps['animate'] = useMemo(() => {\n if (shouldRenderTwo) {\n switch (true) {\n case direction === 'left':\n return { x: '0%' };\n case direction === 'right':\n return { x: '-100%' };\n default:\n return { x: '-50%' };\n }\n } else {\n switch (true) {\n case direction === 'left':\n return { x: '0%' };\n case direction === 'right':\n return { x: '-200%' };\n default:\n return { x: '-100%' };\n }\n }\n }, [direction, shouldRenderTwo]);\n\n return (\n <StyledMonthWrapper $height={monthHeight} $width={width}>\n <StyledMotionWrapper\n animate={animate}\n $isDisabled={isDisabled}\n transition={{\n type: 'tween',\n duration: !direction ? 0 : 0.2,\n }}\n onAnimationComplete={onAnimationFinished}\n >\n {content}\n </StyledMotionWrapper>\n </StyledMonthWrapper>\n );\n};\n\nMonthWrapper.displayName = 'MonthWrapper';\n\nexport default MonthWrapper;\n"],"mappings":"AACA,OAAOA,KAAK,IAAQC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAA2B,OAAO;AAOlF,SAASC,eAAe,EAAEC,UAAU,QAAQ,yBAAyB;AACrE,OAAOC,KAAK,MAAM,eAAe;AACjC,SAASC,kBAAkB,EAAEC,mBAAmB,QAAQ,uBAAuB;AAyB/E,MAAMC,YAAmC,GAAGC,IAAA,IAmBtC;EAAA,IAnBuC;IACzCC,MAAM;IACNC,WAAW;IACXC,gBAAgB;IAChBC,YAAY;IACZC,QAAQ;IACRC,UAAU;IACVC,SAAS;IACTC,mBAAmB;IACnBC,eAAe;IACfC,KAAK;IAACC,iBAAiB;IACvBC,UAAU;IACVC,OAAO;IACPC,OAAO;IACPC,kCAAkC;IAClCC,IAAI;IACJC,aAAa;IACbC,cAAc;IACdC;EACJ,CAAC,GAAAnB,IAAA;EACG,MAAM,CAACoB,OAAO,EAAEC,UAAU,CAAC,GAAG5B,QAAQ,CAAiB,CAAC;EAExD,MAAM,CAAC6B,WAAW,EAAEC,cAAc,CAAC,GAAG9B,QAAQ,CAAc,IAAI,CAAC;EAEjE,MAA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C,EAAE;UAAO,CAAC;MAC5B;IACJ,CAAC,MAAM;MACH,QAAQ,IAAI;QACR,KAAKlC,SAAS,KAAK,MAAM;UACrB,OAAO;YAAEkC,CAAC,EAAE;UAAK,CAAC;QACtB,KAAKlC,SAAS,KAAK,OAAO;UACtB,OAAO;YAAEkC,CAAC,EAAE;UAAQ,CAAC;QACzB;UACI,OAAO;YAAEA,CAAC,EAAE;UAAQ,CAAC;MAC7B;IACJ;EACJ,CAAC,EAAE,CAAClC,SAAS,EAAEE,eAAe,CAAC,CAAC;EAEhC,oBACInB,KAAA,CAAAyC,aAAA,CAAClC,kBAAkB;IAAC6C,OAAO,EAAElB,WAAY;IAACmB,MAAM,EAAEjC;EAAM,gBACpDpB,KAAA,CAAAyC,aAAA,CAACjC,mBAAmB;IAChB0C,OAAO,EAAEA,OAAQ;IACjBI,WAAW,EAAEhC,UAAW;IACxBiC,UAAU,EAAE;MACR7B,IAAI,EAAE,OAAO;MACb8B,QAAQ,EAAE,CAACvC,SAAS,GAAG,CAAC,GAAG;IAC/B,CAAE;IACFwC,mBAAmB,EAAEvC;EAAoB,GAExCY,OACgB,CACL,CAAC;AAE7B,CAAC;AAEDrB,YAAY,CAACiD,WAAW,GAAG,cAAc;AAEzC,eAAejD,YAAY","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"MonthWrapper.js","names":["React","useEffect","useMemo","useState","getMonthAndYear","getNewDate","Month","StyledMonthWrapper","StyledMotionWrapper","MonthWrapper","locale","currentDate","highlightedDates","selectedDate","onSelect","categories","direction","onAnimationFinished","shouldRenderTwo","width","customThumbColors","isDisabled","minDate","maxDate","shouldShowHighlightsInMonthOverlay","type","disabledDates","setCurrentDate","showMonthYearPickers","handleLeftArrowClick","handleRightArrowClick","currentDateBackgroundColor","content","setContent","hoveringDay","setHoveringDay","monthHeight","items","i","date","month","year","push","createElement","height","key","displayIndex","prevState","map","element","index","props","animate","x","$height","$width","$isDisabled","transition","duration","onAnimationComplete","displayName"],"sources":["../../../../../src/components/calendar/month-wrapper/MonthWrapper.tsx"],"sourcesContent":["import { Language } from 'chayns-api';\nimport type { MotionProps } from 'motion/react';\nimport React, { FC, useEffect, useMemo, useState, type ReactElement, CSSProperties } from 'react';\nimport {\n CalendarType,\n Categories,\n CustomThumbColors,\n DateInterval,\n HighlightedDates,\n} from '../../../types/calendar';\nimport { getMonthAndYear, getNewDate } from '../../../utils/calendar';\nimport Month from './month/Month';\nimport { StyledMonthWrapper, StyledMotionWrapper } from './MonthWrapper.styles';\n\nexport type MonthWrapperProps = {\n locale: Language;\n highlightedDates?: HighlightedDates[];\n onSelect: (date: Date) => void;\n selectedDate?: Date | Date[] | DateInterval;\n categories?: Categories[];\n currentDate: Date;\n direction?: 'left' | 'right';\n onAnimationFinished: () => void;\n shouldRenderTwo: boolean;\n width: number;\n isDisabled?: boolean;\n maxDate: Date;\n minDate: Date;\n type: CalendarType;\n disabledDates: Date[];\n setCurrentDate: (date: Date) => void;\n shouldShowHighlightsInMonthOverlay: boolean;\n showMonthYearPickers: boolean;\n customThumbColors?: CustomThumbColors;\n handleLeftArrowClick: () => void;\n handleRightArrowClick: () => void;\n currentDateBackgroundColor?: CSSProperties['backgroundColor'];\n};\n\nconst MonthWrapper: FC<MonthWrapperProps> = ({\n locale,\n currentDate,\n highlightedDates,\n selectedDate,\n onSelect,\n categories,\n direction,\n onAnimationFinished,\n shouldRenderTwo,\n width,\n customThumbColors,\n isDisabled,\n minDate,\n maxDate,\n shouldShowHighlightsInMonthOverlay,\n type,\n disabledDates,\n setCurrentDate,\n showMonthYearPickers,\n handleLeftArrowClick,\n handleRightArrowClick,\n currentDateBackgroundColor,\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 handleLeftArrowClick={handleLeftArrowClick}\n handleRightArrowClick={handleRightArrowClick}\n currentDateBackgroundColor={currentDateBackgroundColor}\n />,\n );\n }\n\n return items;\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [monthHeight]);\n\n useEffect(() => {\n // Doesn't update props until animation is completed\n if (direction) return;\n\n setContent((prevState) =>\n (prevState ?? []).map((element, index) => {\n const date = getNewDate(index - 1, currentDate);\n\n const { month, year } = getMonthAndYear(date);\n\n return {\n ...element,\n props: {\n ...element.props,\n categories,\n disabledDates,\n displayIndex: index - 1,\n highlightedDates,\n hoveringDay,\n locale,\n onSelect,\n shouldShowHighlightsInMonthOverlay,\n maxDate,\n minDate,\n month,\n customThumbColors,\n selectedDate,\n setCurrentDate,\n setHoveringDay,\n showMonthYearPickers,\n type,\n year,\n } as ReactElement,\n };\n }),\n );\n }, [\n customThumbColors,\n categories,\n currentDate,\n direction,\n disabledDates,\n highlightedDates,\n hoveringDay,\n locale,\n onAnimationFinished,\n onSelect,\n maxDate,\n minDate,\n selectedDate,\n setCurrentDate,\n setHoveringDay,\n showMonthYearPickers,\n type,\n shouldShowHighlightsInMonthOverlay,\n ]);\n\n const animate: MotionProps['animate'] = useMemo(() => {\n if (shouldRenderTwo) {\n switch (true) {\n case direction === 'left':\n return { x: '0%' };\n case direction === 'right':\n return { x: '-100%' };\n default:\n return { x: '-50%' };\n }\n } else {\n switch (true) {\n case direction === 'left':\n return { x: '0%' };\n case direction === 'right':\n return { x: '-200%' };\n default:\n return { x: '-100%' };\n }\n }\n }, [direction, shouldRenderTwo]);\n\n return (\n <StyledMonthWrapper $height={monthHeight} $width={width}>\n <StyledMotionWrapper\n animate={animate}\n $isDisabled={isDisabled}\n transition={{\n type: 'tween',\n duration: !direction ? 0 : 0.2,\n }}\n onAnimationComplete={onAnimationFinished}\n >\n {content}\n </StyledMotionWrapper>\n </StyledMonthWrapper>\n );\n};\n\nMonthWrapper.displayName = 'MonthWrapper';\n\nexport default MonthWrapper;\n"],"mappings":"AAEA,OAAOA,KAAK,IAAQC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAA0C,OAAO;AAQjG,SAASC,eAAe,EAAEC,UAAU,QAAQ,yBAAyB;AACrE,OAAOC,KAAK,MAAM,eAAe;AACjC,SAASC,kBAAkB,EAAEC,mBAAmB,QAAQ,uBAAuB;AA2B/E,MAAMC,YAAmC,GAAGA,CAAC;EACzCC,MAAM;EACNC,WAAW;EACXC,gBAAgB;EAChBC,YAAY;EACZC,QAAQ;EACRC,UAAU;EACVC,SAAS;EACTC,mBAAmB;EACnBC,eAAe;EACfC,KAAK;EACLC,iBAAiB;EACjBC,UAAU;EACVC,OAAO;EACPC,OAAO;EACPC,kCAAkC;EAClCC,IAAI;EACJC,aAAa;EACbC,cAAc;EACdC,oBAAoB;EACpBC,oBAAoB;EACpBC,qBAAqB;EACrBC;AACJ,CAAC,KAAK;EACF,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAG9B,QAAQ,CAAiB,CAAC;EAExD,MAAM,CAAC+B,WAAW,EAAEC,cAAc,CAAC,GAAGhC,QAAQ,CAAc,IAAI,CAAC;EAEjE,MAAMiC,WAAW,GAAGlC,OAAO,CAAC,MAAMiB,KAAK,IAAID,eAAe,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAACC,KAAK,EAAED,eAAe,C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MAC5B;IACJ,CAAC,MAAM;MACH,QAAQ,IAAI;QACR,KAAKrC,SAAS,KAAK,MAAM;UACrB,OAAO;YAAEqC,CAAC,EAAE;UAAK,CAAC;QACtB,KAAKrC,SAAS,KAAK,OAAO;UACtB,OAAO;YAAEqC,CAAC,EAAE;UAAQ,CAAC;QACzB;UACI,OAAO;YAAEA,CAAC,EAAE;UAAQ,CAAC;MAC7B;IACJ;EACJ,CAAC,EAAE,CAACrC,SAAS,EAAEE,eAAe,CAAC,CAAC;EAEhC,oBACIlB,KAAA,CAAA2C,aAAA,CAACpC,kBAAkB;IAAC+C,OAAO,EAAElB,WAAY;IAACmB,MAAM,EAAEpC;EAAM,gBACpDnB,KAAA,CAAA2C,aAAA,CAACnC,mBAAmB;IAChB4C,OAAO,EAAEA,OAAQ;IACjBI,WAAW,EAAEnC,UAAW;IACxBoC,UAAU,EAAE;MACRhC,IAAI,EAAE,OAAO;MACbiC,QAAQ,EAAE,CAAC1C,SAAS,GAAG,CAAC,GAAG;IAC/B,CAAE;IACF2C,mBAAmB,EAAE1C;EAAoB,GAExCe,OACgB,CACL,CAAC;AAE7B,CAAC;AAEDvB,YAAY,CAACmD,WAAW,GAAG,cAAc;AAEzC,eAAenD,YAAY","ignoreList":[]}
|
|
@@ -1,19 +1,13 @@
|
|
|
1
|
-
import { motion } from '
|
|
1
|
+
import { motion } from 'motion/react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
export const StyledMonthWrapper = styled.div`
|
|
4
|
-
width: ${
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} = _ref;
|
|
8
|
-
return $width;
|
|
9
|
-
}}px;
|
|
4
|
+
width: ${({
|
|
5
|
+
$width
|
|
6
|
+
}) => $width}px;
|
|
10
7
|
overflow-x: clip;
|
|
11
|
-
height: ${
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} = _ref2;
|
|
15
|
-
return $height;
|
|
16
|
-
}}px;
|
|
8
|
+
height: ${({
|
|
9
|
+
$height
|
|
10
|
+
}) => $height}px;
|
|
17
11
|
`;
|
|
18
12
|
export const StyledMotionWrapper = styled(motion.div)`
|
|
19
13
|
display: flex;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MonthWrapper.styles.js","names":["motion","styled","StyledMonthWrapper","div","
|
|
1
|
+
{"version":3,"file":"MonthWrapper.styles.js","names":["motion","styled","StyledMonthWrapper","div","$width","$height","StyledMotionWrapper"],"sources":["../../../../../src/components/calendar/month-wrapper/MonthWrapper.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport { motion } from 'motion/react';\nimport styled from 'styled-components';\n\ntype StyledMonthWrapperProps = WithTheme<{ $height: number; $width: number }>;\n\nexport const StyledMonthWrapper = styled.div<StyledMonthWrapperProps>`\n width: ${({ $width }) => $width}px;\n overflow-x: clip;\n height: ${({ $height }) => $height}px;\n`;\n\ntype StyledMotionWrapperProps = { $isDisabled?: boolean };\n\nexport const StyledMotionWrapper = styled(motion.div)<StyledMotionWrapperProps>`\n display: flex;\n height: 100%;\n`;\n"],"mappings":"AACA,SAASA,MAAM,QAAQ,cAAc;AACrC,OAAOC,MAAM,MAAM,mBAAmB;AAItC,OAAO,MAAMC,kBAAkB,GAAGD,MAAM,CAACE,GAA4B;AACrE,aAAa,CAAC;EAAEC;AAAO,CAAC,KAAKA,MAAM;AACnC;AACA,cAAc,CAAC;EAAEC;AAAQ,CAAC,KAAKA,OAAO;AACtC,CAAC;AAID,OAAO,MAAMC,mBAAmB,GAAGL,MAAM,CAACD,MAAM,CAACG,GAAG,CAA2B;AAC/E;AACA;AACA,CAAC","ignoreList":[]}
|
|
@@ -1,32 +1,57 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import MonthYearPickers from '../../month-year-pickers/MonthYearPickers';
|
|
3
3
|
import DayWrapper from './day-wrapper/DayWrapper';
|
|
4
4
|
import { StyledMonth, StyledMonthHead } from './Month.styles';
|
|
5
5
|
import WeekdayWrapper from './weekday-wrapper/WeekdayWrapper';
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
6
|
+
const minSwipeDistance = 50;
|
|
7
|
+
const Month = ({
|
|
8
|
+
month,
|
|
9
|
+
year,
|
|
10
|
+
locale,
|
|
11
|
+
highlightedDates,
|
|
12
|
+
selectedDate,
|
|
13
|
+
onSelect,
|
|
14
|
+
categories,
|
|
15
|
+
height,
|
|
16
|
+
minDate,
|
|
17
|
+
maxDate,
|
|
18
|
+
customThumbColors,
|
|
19
|
+
shouldShowHighlightsInMonthOverlay,
|
|
20
|
+
type,
|
|
21
|
+
hoveringDay,
|
|
22
|
+
setHoveringDay,
|
|
23
|
+
disabledDates,
|
|
24
|
+
setCurrentDate,
|
|
25
|
+
displayIndex,
|
|
26
|
+
showMonthYearPickers,
|
|
27
|
+
handleLeftArrowClick,
|
|
28
|
+
handleRightArrowClick,
|
|
29
|
+
currentDateBackgroundColor
|
|
30
|
+
}) => {
|
|
31
|
+
const [touchStart, setTouchStart] = useState();
|
|
32
|
+
const [touchEnd, setTouchEnd] = useState();
|
|
33
|
+
const onTouchStart = e => {
|
|
34
|
+
setTouchEnd(undefined);
|
|
35
|
+
setTouchStart(e.targetTouches[0]?.clientX);
|
|
36
|
+
};
|
|
37
|
+
const onTouchMove = e => {
|
|
38
|
+
setTouchEnd(e.targetTouches[0]?.clientX);
|
|
39
|
+
};
|
|
40
|
+
const onTouchEnd = () => {
|
|
41
|
+
if (!touchStart || !touchEnd) return;
|
|
42
|
+
const distance = touchStart - touchEnd;
|
|
43
|
+
if (distance < -minSwipeDistance) {
|
|
44
|
+
handleLeftArrowClick();
|
|
45
|
+
}
|
|
46
|
+
if (distance > minSwipeDistance) {
|
|
47
|
+
handleRightArrowClick();
|
|
48
|
+
}
|
|
49
|
+
};
|
|
28
50
|
return /*#__PURE__*/React.createElement(StyledMonth, {
|
|
29
|
-
$height: height
|
|
51
|
+
$height: height,
|
|
52
|
+
onTouchStart: onTouchStart,
|
|
53
|
+
onTouchMove: onTouchMove,
|
|
54
|
+
onTouchEnd: onTouchEnd
|
|
30
55
|
}, /*#__PURE__*/React.createElement(StyledMonthHead, null, /*#__PURE__*/React.createElement(MonthYearPickers, {
|
|
31
56
|
month: month,
|
|
32
57
|
year: year,
|
|
@@ -53,7 +78,8 @@ const Month = _ref => {
|
|
|
53
78
|
type: type,
|
|
54
79
|
hoveringDay: hoveringDay,
|
|
55
80
|
setHoveringDay: setHoveringDay,
|
|
56
|
-
disabledDates: disabledDates
|
|
81
|
+
disabledDates: disabledDates,
|
|
82
|
+
currentDateBackgroundColor: currentDateBackgroundColor
|
|
57
83
|
}));
|
|
58
84
|
};
|
|
59
85
|
Month.displayName = 'Month';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Month.js","names":["React","MonthYearPickers","DayWrapper","StyledMonth","StyledMonthHead","WeekdayWrapper","
|
|
1
|
+
{"version":3,"file":"Month.js","names":["React","useState","MonthYearPickers","DayWrapper","StyledMonth","StyledMonthHead","WeekdayWrapper","minSwipeDistance","Month","month","year","locale","highlightedDates","selectedDate","onSelect","categories","height","minDate","maxDate","customThumbColors","shouldShowHighlightsInMonthOverlay","type","hoveringDay","setHoveringDay","disabledDates","setCurrentDate","displayIndex","showMonthYearPickers","handleLeftArrowClick","handleRightArrowClick","currentDateBackgroundColor","touchStart","setTouchStart","touchEnd","setTouchEnd","onTouchStart","e","undefined","targetTouches","clientX","onTouchMove","onTouchEnd","distance","createElement","$height","key","displayName"],"sources":["../../../../../../src/components/calendar/month-wrapper/month/Month.tsx"],"sourcesContent":["import React, { CSSProperties, FC, TouchEvent, useState } from 'react';\nimport {\n CalendarType,\n Categories,\n CustomThumbColors,\n DateInterval,\n EMonth,\n HighlightedDates,\n} from '../../../../types/calendar';\nimport MonthYearPickers from '../../month-year-pickers/MonthYearPickers';\nimport DayWrapper from './day-wrapper/DayWrapper';\nimport { StyledMonth, StyledMonthHead } from './Month.styles';\nimport WeekdayWrapper from './weekday-wrapper/WeekdayWrapper';\nimport { Language } from 'chayns-api';\n\nexport type MonthProps = {\n month: EMonth;\n year: number;\n locale: Language;\n highlightedDates?: HighlightedDates[];\n onSelect: (date: Date) => void;\n selectedDate?: Date | Date[] | DateInterval;\n categories?: Categories[];\n height: number;\n minDate: Date;\n maxDate: Date;\n type: CalendarType;\n hoveringDay: Date | null;\n setHoveringDay: (date: Date | null) => void;\n disabledDates: Date[];\n setCurrentDate: (date: Date) => void;\n displayIndex?: number;\n shouldShowHighlightsInMonthOverlay: boolean;\n customThumbColors?: CustomThumbColors;\n showMonthYearPickers: boolean;\n handleLeftArrowClick: () => void;\n handleRightArrowClick: () => void;\n currentDateBackgroundColor?: CSSProperties['backgroundColor'];\n};\n\nconst minSwipeDistance = 50;\n\nconst Month: FC<MonthProps> = ({\n month,\n year,\n locale,\n highlightedDates,\n selectedDate,\n onSelect,\n categories,\n height,\n minDate,\n maxDate,\n customThumbColors,\n shouldShowHighlightsInMonthOverlay,\n type,\n hoveringDay,\n setHoveringDay,\n disabledDates,\n setCurrentDate,\n displayIndex,\n showMonthYearPickers,\n handleLeftArrowClick,\n handleRightArrowClick,\n currentDateBackgroundColor,\n}) => {\n const [touchStart, setTouchStart] = useState<undefined | number>();\n const [touchEnd, setTouchEnd] = useState<undefined | number>();\n\n const onTouchStart = (e: TouchEvent<HTMLDivElement>) => {\n setTouchEnd(undefined);\n setTouchStart(e.targetTouches[0]?.clientX);\n };\n\n const onTouchMove = (e: TouchEvent<HTMLDivElement>) => {\n setTouchEnd(e.targetTouches[0]?.clientX);\n };\n\n const onTouchEnd = () => {\n if (!touchStart || !touchEnd) return;\n const distance = touchStart - touchEnd;\n if (distance < -minSwipeDistance) {\n handleLeftArrowClick();\n }\n if (distance > minSwipeDistance) {\n handleRightArrowClick();\n }\n };\n\n return (\n <StyledMonth\n $height={height}\n onTouchStart={onTouchStart}\n onTouchMove={onTouchMove}\n onTouchEnd={onTouchEnd}\n >\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 currentDateBackgroundColor={currentDateBackgroundColor}\n />\n </StyledMonth>\n );\n};\n\nMonth.displayName = 'Month';\n\nexport default Month;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAmCC,QAAQ,QAAQ,OAAO;AAStE,OAAOC,gBAAgB,MAAM,2CAA2C;AACxE,OAAOC,UAAU,MAAM,0BAA0B;AACjD,SAASC,WAAW,EAAEC,eAAe,QAAQ,gBAAgB;AAC7D,OAAOC,cAAc,MAAM,kCAAkC;AA4B7D,MAAMC,gBAAgB,GAAG,EAAE;AAE3B,MAAMC,KAAqB,GAAGA,CAAC;EAC3BC,KAAK;EACLC,IAAI;EACJC,MAAM;EACNC,gBAAgB;EAChBC,YAAY;EACZC,QAAQ;EACRC,UAAU;EACVC,MAAM;EACNC,OAAO;EACPC,OAAO;EACPC,iBAAiB;EACjBC,kCAAkC;EAClCC,IAAI;EACJC,WAAW;EACXC,cAAc;EACdC,a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,EAAEA,cAAe;IAC/BC,YAAY,EAAEA,YAAa;IAC3BC,oBAAoB,EAAEA;EAAqB,CAC9C,CACY,CAAC,eAClB3B,KAAA,CAAA2C,aAAA,CAACrC,cAAc;IAACK,MAAM,EAAEA;EAAO,CAAE,CAAC,eAClCX,KAAA,CAAA2C,aAAA,CAACxC,UAAU;IACP0C,GAAG,EAAE,eAAepC,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,aAAc;IAC7BM,0BAA0B,EAAEA;EAA2B,CAC1D,CACQ,CAAC;AAEtB,CAAC;AAEDtB,KAAK,CAACsC,WAAW,GAAG,OAAO;AAE3B,eAAetC,KAAK","ignoreList":[]}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
2
|
export const StyledMonth = styled.div`
|
|
3
|
-
height: ${
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} = _ref;
|
|
7
|
-
return $height;
|
|
8
|
-
}}px;
|
|
3
|
+
height: ${({
|
|
4
|
+
$height
|
|
5
|
+
}) => $height}px;
|
|
9
6
|
aspect-ratio: 1;
|
|
10
7
|
`;
|
|
11
8
|
export const StyledMonthHead = styled.div`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Month.styles.js","names":["styled","StyledMonth","div","
|
|
1
|
+
{"version":3,"file":"Month.styles.js","names":["styled","StyledMonth","div","$height","StyledMonthHead","StyledMonthName"],"sources":["../../../../../../src/components/calendar/month-wrapper/month/Month.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport styled from 'styled-components';\n\ntype StyledMonthProps = WithTheme<{ $height: number }>;\n\nexport const StyledMonth = styled.div<StyledMonthProps>`\n height: ${({ $height }) => $height}px;\n aspect-ratio: 1;\n`;\n\nexport const StyledMonthHead = styled.div`\n display: flex;\n align-items: center;\n justify-content: center;\n column-gap: 7px;\n`;\n\nexport const StyledMonthName = styled.div`\n font-weight: bold;\n text-align: center;\n user-select: none;\n`;\n"],"mappings":"AACA,OAAOA,MAAM,MAAM,mBAAmB;AAItC,OAAO,MAAMC,WAAW,GAAGD,MAAM,CAACE,GAAqB;AACvD,cAAc,CAAC;EAAEC;AAAQ,CAAC,KAAKA,OAAO;AACtC;AACA,CAAC;AAED,OAAO,MAAMC,eAAe,GAAGJ,MAAM,CAACE,GAAG;AACzC;AACA;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMG,eAAe,GAAGL,MAAM,CAACE,GAAG;AACzC;AACA;AACA;AACA,CAAC","ignoreList":[]}
|
|
@@ -3,24 +3,24 @@ import { CalendarType } from '../../../../../types/calendar';
|
|
|
3
3
|
import { findNextDate } from '../../../../../utils/calendar';
|
|
4
4
|
import Day from './day/Day';
|
|
5
5
|
import { StyledDayWrapper } from './DayWrapper.styles';
|
|
6
|
-
import { addDays, isAfter, isSameDay, isSameMonth, isWithinInterval, startOfMonth, startOfWeek } from
|
|
7
|
-
const DayWrapper =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
6
|
+
import { addDays, isAfter, isSameDay, isSameMonth, isWithinInterval, startOfMonth, startOfWeek } from '../../../../../utils/date';
|
|
7
|
+
const DayWrapper = ({
|
|
8
|
+
month,
|
|
9
|
+
year,
|
|
10
|
+
highlightedDates,
|
|
11
|
+
onSelect,
|
|
12
|
+
selectedDate,
|
|
13
|
+
categories,
|
|
14
|
+
minDate,
|
|
15
|
+
maxDate,
|
|
16
|
+
customThumbColors,
|
|
17
|
+
type,
|
|
18
|
+
hoveringDay,
|
|
19
|
+
shouldShowHighlightsInMonthOverlay,
|
|
20
|
+
setHoveringDay,
|
|
21
|
+
disabledDates,
|
|
22
|
+
currentDateBackgroundColor
|
|
23
|
+
}) => {
|
|
24
24
|
const dayOfCurrentMonth = useMemo(() => new Date(year, month - 1, 13), [month, year]);
|
|
25
25
|
const days = useMemo(() => {
|
|
26
26
|
const dateArray = [];
|
|
@@ -109,7 +109,8 @@ const DayWrapper = _ref => {
|
|
|
109
109
|
isSameMonth: isSameMonth(day, dayOfCurrentMonth),
|
|
110
110
|
onClick: handleDayClick,
|
|
111
111
|
highlightedDates: highlightedDates,
|
|
112
|
-
setHoveringDay: setHoveringDay
|
|
112
|
+
setHoveringDay: setHoveringDay,
|
|
113
|
+
currentDateBackgroundColor: currentDateBackgroundColor
|
|
113
114
|
}));
|
|
114
115
|
});
|
|
115
116
|
return items;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DayWrapper.js","names":["React","useCallback","useMemo","CalendarType","findNextDate","Day","StyledDayWrapper","addDays","isAfter","isSameDay","isSameMonth","isWithinInterval","startOfMonth","startOfWeek","DayWrapper","_ref","month","year","highlightedDates","onSelect","selectedDate","categories","minDate","maxDate","customThumbColors","type","hoveringDay","shouldShowHighlightsInMonthOverlay","setHoveringDay","disabledDates","dayOfCurrentMonth","Date","days","dateArray","currentDate","startDay","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 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';\nimport {\n addDays,\n isAfter,\n isSameDay,\n isSameMonth,\n isWithinInterval,\n startOfMonth,\n startOfWeek\n} from \"../../../../../utils/date\";\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);\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,OAAOA,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;AACtD,SACIC,OAAO,EACPC,OAAO,EACPC,SAAS,EACTC,WAAW,EACXC,gBAAgB,EAChBC,YAAY,EACZC,WAAW,QACR,2BAA2B;AAmBlC,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,GAAG5B,OAAO,CAAC,MAAM,IAAI6B,IAAI,CAACd,IAAI,EAAED,KAAK,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE,CAACA,KAAK,EAAEC,IAAI,CAAC,CAAC;EAErF,MAAMe,IAAI,GAAG9B,OAAO,CAAC,MAAM;IACvB,MAAM+B,SAAiB,GAAG,EAAE;IAE5B,MAAMC,WAAW,GAAGtB,YAAY,CAACkB,iBAAiB,CAAC;IAEnD,MAAMK,QAAQ,GAAGtB,WAAW,CAACqB,WA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eAAepD,UAAU","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"DayWrapper.js","names":["React","useCallback","useMemo","CalendarType","findNextDate","Day","StyledDayWrapper","addDays","isAfter","isSameDay","isSameMonth","isWithinInterval","startOfMonth","startOfWeek","DayWrapper","month","year","highlightedDates","onSelect","selectedDate","categories","minDate","maxDate","customThumbColors","type","hoveringDay","shouldShowHighlightsInMonthOverlay","setHoveringDay","disabledDates","currentDateBackgroundColor","dayOfCurrentMonth","Date","days","dateArray","currentDate","startDay","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 React, { FC, useCallback, useMemo, type ReactElement, CSSProperties } from 'react';\nimport {\n CalendarType,\n type Categories,\n 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';\nimport {\n addDays,\n isAfter,\n isSameDay,\n isSameMonth,\n isWithinInterval,\n startOfMonth,\n startOfWeek,\n} from '../../../../../utils/date';\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 currentDateBackgroundColor?: CSSProperties['backgroundColor'];\n};\n\nconst DayWrapper: FC<DayWrapperProps> = ({\n month,\n year,\n highlightedDates,\n onSelect,\n selectedDate,\n categories,\n minDate,\n maxDate,\n customThumbColors,\n type,\n hoveringDay,\n shouldShowHighlightsInMonthOverlay,\n setHoveringDay,\n disabledDates,\n currentDateBackgroundColor,\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);\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 currentDateBackgroundColor={currentDateBackgroundColor}\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 customThumbColors,\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,OAAOA,KAAK,IAAQC,WAAW,EAAEC,OAAO,QAA0C,OAAO;AACzF,SACIC,YAAY,QAMT,+BAA+B;AACtC,SAASC,YAAY,QAAQ,+BAA+B;AAC5D,OAAOC,GAAG,MAAM,WAAW;AAC3B,SAASC,gBAAgB,QAAQ,qBAAqB;AACtD,SACIC,OAAO,EACPC,OAAO,EACPC,SAAS,EACTC,WAAW,EACXC,gBAAgB,E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B;QACrDE,UAAU,EAAEA,UAAW;QACvB5B,kCAAkC,EAAEA,kCAAmC;QACvEhB,WAAW,EAAEA,WAAW,CAACsC,GAAG,EAAElB,iBAAiB,CAAE;QACjDmC,OAAO,EAAE1B,cAAe;QACxBtB,gBAAgB,EAAEA,gBAAiB;QACnCU,cAAc,EAAEA,cAAe;QAC/BE,0BAA0B,EAAEA;MAA2B,CAC1D,CACL,CAAC;IACL,CAAC,CAAC;IAEF,OAAOc,KAAK;EAChB,CAAC,EAAE,CACCxB,YAAY,EACZS,aAAa,EACbI,IAAI,EACJX,OAAO,EACPC,OAAO,EACPE,IAAI,EACJC,WAAW,EACXL,UAAU,EACVG,iBAAiB,EACjBG,kCAAkC,EAClCI,iBAAiB,EACjBS,cAAc,EACdtB,gBAAgB,EAChBU,cAAc,CACjB,CAAC;EAEF,oBAAO3B,KAAA,CAAA8D,aAAA,CAACxD,gBAAgB,QAAEoC,WAA8B,CAAC;AAC7D,CAAC;AAED5B,UAAU,CAACoD,WAAW,GAAG,YAAY;AAErC,eAAepD,UAAU","ignoreList":[]}
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import React, { useMemo, useRef } from 'react';
|
|
2
2
|
import Category from './category/Category';
|
|
3
|
-
import { StyledDay, StyledDayCategoryWrapper, StyledDayNumber } from './Day.styles';
|
|
4
|
-
import { isSameDay } from
|
|
5
|
-
const Day =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
3
|
+
import { StyledCurrentDay, StyledDay, StyledDayCategoryWrapper, StyledDayNumber } from './Day.styles';
|
|
4
|
+
import { isSameDay } from '../../../../../../utils/date';
|
|
5
|
+
const Day = ({
|
|
6
|
+
date,
|
|
7
|
+
highlightedDates,
|
|
8
|
+
categories,
|
|
9
|
+
isSameMonth,
|
|
10
|
+
isSelected,
|
|
11
|
+
onClick,
|
|
12
|
+
isDisabled,
|
|
13
|
+
isIntervalStart,
|
|
14
|
+
isIntervalEnd,
|
|
15
|
+
customThumbColors,
|
|
16
|
+
isWithinIntervalSelection,
|
|
17
|
+
shouldShowHighlightsInMonthOverlay,
|
|
18
|
+
setHoveringDay,
|
|
19
|
+
currentDateBackgroundColor
|
|
20
|
+
}) => {
|
|
21
21
|
const dayRef = useRef(null);
|
|
22
|
+
const isCurrentDay = useMemo(() => isSameDay(date, new Date()), [date]);
|
|
22
23
|
const styles = useMemo(() => {
|
|
23
24
|
if (!highlightedDates || !shouldShowHighlightsInMonthOverlay && !isSameMonth) {
|
|
24
25
|
return undefined;
|
|
@@ -41,7 +42,9 @@ const Day = _ref => {
|
|
|
41
42
|
$textColor: styles?.textColor,
|
|
42
43
|
onMouseEnter: () => setHoveringDay(date),
|
|
43
44
|
onMouseLeave: () => setHoveringDay(null)
|
|
44
|
-
}, /*#__PURE__*/React.createElement(
|
|
45
|
+
}, isCurrentDay && currentDateBackgroundColor ? /*#__PURE__*/React.createElement(StyledCurrentDay, {
|
|
46
|
+
$backgroundColor: currentDateBackgroundColor
|
|
47
|
+
}) : null, /*#__PURE__*/React.createElement(StyledDayNumber, {
|
|
45
48
|
$customThumbColors: customThumbColors,
|
|
46
49
|
$isSelected: shouldShowHighlightsInMonthOverlay ? isSelected : isSelected && isSameMonth,
|
|
47
50
|
$isIntervalStart: shouldShowHighlightsInMonthOverlay ? isIntervalStart : isIntervalStart && isSameMonth,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Day.js","names":["React","useMemo","useRef","Category","StyledDay","StyledDayCategoryWrapper","StyledDayNumber","isSameDay","Day","
|
|
1
|
+
{"version":3,"file":"Day.js","names":["React","useMemo","useRef","Category","StyledCurrentDay","StyledDay","StyledDayCategoryWrapper","StyledDayNumber","isSameDay","Day","date","highlightedDates","categories","isSameMonth","isSelected","onClick","isDisabled","isIntervalStart","isIntervalEnd","customThumbColors","isWithinIntervalSelection","shouldShowHighlightsInMonthOverlay","setHoveringDay","currentDateBackgroundColor","dayRef","isCurrentDay","Date","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 React, { CSSProperties, FC, useMemo, useRef } from 'react';\nimport {\n Categories,\n CustomThumbColors,\n HighlightedDates,\n HighlightedDateStyles,\n} from '../../../../../../types/calendar';\nimport Category from './category/Category';\nimport {\n StyledCurrentDay,\n StyledDay,\n StyledDayCategoryWrapper,\n StyledDayNumber,\n} from './Day.styles';\nimport { isSameDay } from '../../../../../../utils/date';\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 currentDateBackgroundColor?: CSSProperties['backgroundColor'];\n};\n\nconst Day: FC<DayProps> = ({\n date,\n highlightedDates,\n categories,\n isSameMonth,\n isSelected,\n onClick,\n isDisabled,\n isIntervalStart,\n isIntervalEnd,\n customThumbColors,\n isWithinIntervalSelection,\n shouldShowHighlightsInMonthOverlay,\n setHoveringDay,\n currentDateBackgroundColor,\n}) => {\n const dayRef = useRef<HTMLDivElement>(null);\n const isCurrentDay = useMemo(() => isSameDay(date, new Date()), [date]);\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 {isCurrentDay && currentDateBackgroundColor ? (\n <StyledCurrentDay $backgroundColor={currentDateBackgroundColor} />\n ) : null}\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,OAAOA,KAAK,IAAuBC,OAAO,EAAEC,MA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