@chayns-components/date 5.0.0-beta.718 → 5.0.0-beta.719

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.
@@ -4,12 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _react = _interopRequireWildcard(require("react"));
7
+ var _core = require("@chayns-components/core");
8
8
  var _dateFns = require("date-fns");
9
9
  var _locale = require("date-fns/locale");
10
- var _Calendar = require("./Calendar.styles");
10
+ var _react = _interopRequireWildcard(require("react"));
11
11
  var _calendar = require("../../utils/calendar");
12
- var _core = require("@chayns-components/core");
12
+ var _Calendar = require("./Calendar.styles");
13
13
  var _MonthWrapper = _interopRequireDefault(require("./month-wrapper/MonthWrapper"));
14
14
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
15
  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); }
@@ -22,7 +22,8 @@ const Calendar = ({
22
22
  highlightedDates,
23
23
  onSelect,
24
24
  selectedDate,
25
- categories
25
+ categories,
26
+ isDisabled
26
27
  }) => {
27
28
  const [currentDate, setCurrentDate] = (0, _react.useState)();
28
29
  const [shouldRenderTwoMonths, setShouldRenderTwoMonths] = (0, _react.useState)(true);
@@ -113,7 +114,8 @@ const Calendar = ({
113
114
  return !(0, _dateFns.isSameMonth)(currentDate, endDate);
114
115
  }, [currentDate, endDate]);
115
116
  return /*#__PURE__*/_react.default.createElement(_Calendar.StyledCalendar, {
116
- ref: calendarRef
117
+ ref: calendarRef,
118
+ $isDisabled: isDisabled
117
119
  }, ShouldShowLeftArrow ? /*#__PURE__*/_react.default.createElement(_Calendar.StyledCalendarIconWrapper, {
118
120
  onClick: handleLeftArrowClick
119
121
  }, /*#__PURE__*/_react.default.createElement(_core.Icon, {
@@ -1 +1 @@
1
- {"version":3,"file":"Calendar.js","names":["_react","_interopRequireWildcard","require","_dateFns","_locale","_Calendar","_calendar","_core","_MonthWrapper","_interopRequireDefault","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","END_DATE","Date","setFullYear","getFullYear","Calendar","locale","de","endDate","startDate","highlightedDates","onSelect","selectedDate","categories","currentDate","setCurrentDate","useState","shouldRenderTwoMonths","setShouldRenderTwoMonths","internalSelectedDate","setInternalSelectedDate","direction","setDirection","width","setWidth","calendarRef","useRef","useEffect","current","resizeObserver","ResizeObserver","entries","observedWidth","contentRect","observe","disconnect","date","isDateInRange","handleLeftArrowClick","useCallback","prevDate","newDate","getNewDate","handleRightArrowClick","handleSelect","handleAnimationFinished","undefined","ShouldShowLeftArrow","useMemo","isSameMonth","ShouldShowRightArrow","createElement","StyledCalendar","ref","StyledCalendarIconWrapper","onClick","Icon","icons","StyledCalendarIconWrapperPseudo","shouldRenderTwo","onAnimationFinished","displayName","_default","exports"],"sources":["../../../../src/components/calendar/Calendar.tsx"],"sourcesContent":["import React, { FC, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { isSameMonth, type Locale } from 'date-fns';\nimport { de } from 'date-fns/locale';\nimport {\n StyledCalendar,\n StyledCalendarIconWrapper,\n StyledCalendarIconWrapperPseudo,\n} from './Calendar.styles';\nimport { getNewDate, isDateInRange } from '../../utils/calendar';\nimport type { Categories, HighlightedDates } from '../../types/calendar';\nimport { Icon } from '@chayns-components/core';\nimport MonthWrapper from './month-wrapper/MonthWrapper';\n\nconst END_DATE = new Date(new Date().setFullYear(new Date().getFullYear() + 100));\n\nexport type CalendarProps = {\n /**\n * An array to group dates into a category.\n */\n categories?: Categories[];\n /**\n * The last Month that can be displayed.\n */\n endDate?: Date;\n /**\n * An array with dates and corresponding styles to highlight.\n */\n highlightedDates?: HighlightedDates[];\n /**\n * The locale language to format the dates.\n */\n locale?: Locale;\n /**\n * Function to be executed when a date is selected.\n * @param date\n */\n onSelect?: (date: Date) => void;\n /**\n * A date that should be preselected.\n */\n selectedDate?: Date;\n /**\n * The first Month that can be displayed.\n */\n startDate: Date;\n};\n\nconst Calendar: FC<CalendarProps> = ({\n locale = de,\n endDate = END_DATE,\n startDate,\n highlightedDates,\n onSelect,\n selectedDate,\n categories,\n}) => {\n const [currentDate, setCurrentDate] = useState<Date>();\n const [shouldRenderTwoMonths, setShouldRenderTwoMonths] = useState(true);\n const [internalSelectedDate, setInternalSelectedDate] = useState<Date>();\n const [direction, setDirection] = useState<'left' | 'right'>();\n const [width, setWidth] = useState(0);\n\n const calendarRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (selectedDate) {\n setInternalSelectedDate(selectedDate);\n }\n }, [selectedDate]);\n\n useEffect(() => {\n if (calendarRef.current) {\n const resizeObserver = new ResizeObserver((entries) => {\n if (entries && entries[0]) {\n const observedWidth = entries[0].contentRect.width;\n\n setWidth(observedWidth - 30);\n\n if (observedWidth < 430) {\n setShouldRenderTwoMonths(false);\n } else {\n setShouldRenderTwoMonths(true);\n }\n }\n });\n\n resizeObserver.observe(calendarRef.current);\n\n return () => {\n resizeObserver.disconnect();\n };\n }\n\n return () => {};\n }, []);\n\n useEffect(() => {\n const date = new Date();\n\n setCurrentDate(isDateInRange({ startDate, endDate, currentDate: date }));\n }, [endDate, startDate]);\n\n const handleLeftArrowClick = useCallback(() => {\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({ startDate, endDate, currentDate: newDate });\n });\n }, [endDate, startDate]);\n\n const handleRightArrowClick = useCallback(() => {\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({ startDate, endDate, currentDate: newDate });\n });\n }, [endDate, startDate]);\n\n const handleSelect = useCallback(\n (date: Date) => {\n setInternalSelectedDate(date);\n\n if (typeof onSelect === 'function') {\n onSelect(date);\n }\n },\n [onSelect],\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, startDate);\n }, [currentDate, startDate]);\n\n const ShouldShowRightArrow = useMemo(() => {\n if (!currentDate) {\n return false;\n }\n\n return !isSameMonth(currentDate, endDate);\n }, [currentDate, endDate]);\n\n return (\n <StyledCalendar ref={calendarRef}>\n {ShouldShowLeftArrow ? (\n <StyledCalendarIconWrapper onClick={handleLeftArrowClick}>\n <Icon icons={['fa fa-angle-left']} />\n </StyledCalendarIconWrapper>\n ) : (\n <StyledCalendarIconWrapperPseudo />\n )}\n {currentDate && (\n <MonthWrapper\n shouldRenderTwo={shouldRenderTwoMonths}\n currentDate={currentDate}\n width={width}\n locale={locale}\n direction={direction}\n onSelect={handleSelect}\n selectedDate={internalSelectedDate}\n highlightedDates={highlightedDates}\n categories={categories}\n onAnimationFinished={handleAnimationFinished}\n />\n )}\n {ShouldShowRightArrow ? (\n <StyledCalendarIconWrapper onClick={handleRightArrowClick}>\n <Icon icons={['fa fa-angle-right']} />\n </StyledCalendarIconWrapper>\n ) : (\n <StyledCalendarIconWrapperPseudo />\n )}\n </StyledCalendar>\n );\n};\n\nCalendar.displayName = 'Calendar';\n\nexport default Calendar;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AAKA,IAAAI,SAAA,GAAAJ,OAAA;AAEA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAC,sBAAA,CAAAP,OAAA;AAAwD,SAAAO,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,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CAAAY,OAAA,CAAAoE,aAAA,CAAC3E,SAAA,CAAAkF,+BAA+B,MAAE,CACrC,EACA5C,WAAW,iBACR3C,MAAA,CAAAY,OAAA,CAAAoE,aAAA,CAACxE,aAAA,CAAAI,OAAY;IACT4E,eAAe,EAAE1C,qBAAsB;IACvCH,WAAW,EAAEA,WAAY;IACzBS,KAAK,EAAEA,KAAM;IACbjB,MAAM,EAAEA,MAAO;IACfe,SAAS,EAAEA,SAAU;IACrBV,QAAQ,EAAEiC,YAAa;IACvBhC,YAAY,EAAEO,oBAAqB;IACnCT,gBAAgB,EAAEA,gBAAiB;IACnCG,UAAU,EAAEA,UAAW;IACvB+C,mBAAmB,EAAEf;EAAwB,CAChD,CACJ,EACAK,oBAAoB,gBACjB/E,MAAA,CAAAY,OAAA,CAAAoE,aAAA,CAAC3E,SAAA,CAAA8E,yBAAyB;IAACC,OAAO,EAAEZ;EAAsB,gBACtDxE,MAAA,CAAAY,OAAA,CAAAoE,aAAA,CAACzE,KAAA,CAAA8E,IAAI;IAACC,KAAK,EAAE,CAAC,mBAAmB;EAAE,CAAE,CACd,CAAC,gBAE5BtF,MAAA,CAAAY,OAAA,CAAAoE,aAAA,CAAC3E,SAAA,CAAAkF,+BAA+B,MAAE,CAE1B,CAAC;AAEzB,CAAC;AAEDrD,QAAQ,CAACwD,WAAW,GAAG,UAAU;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAhF,OAAA,GAEnBsB,QAAQ","ignoreList":[]}
1
+ {"version":3,"file":"Calendar.js","names":["_core","require","_dateFns","_locale","_react","_interopRequireWildcard","_calendar","_Calendar","_MonthWrapper","_interopRequireDefault","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","END_DATE","Date","setFullYear","getFullYear","Calendar","locale","de","endDate","startDate","highlightedDates","onSelect","selectedDate","categories","isDisabled","currentDate","setCurrentDate","useState","shouldRenderTwoMonths","setShouldRenderTwoMonths","internalSelectedDate","setInternalSelectedDate","direction","setDirection","width","setWidth","calendarRef","useRef","useEffect","current","resizeObserver","ResizeObserver","entries","observedWidth","contentRect","observe","disconnect","date","isDateInRange","handleLeftArrowClick","useCallback","prevDate","newDate","getNewDate","handleRightArrowClick","handleSelect","handleAnimationFinished","undefined","ShouldShowLeftArrow","useMemo","isSameMonth","ShouldShowRightArrow","createElement","StyledCalendar","ref","$isDisabled","StyledCalendarIconWrapper","onClick","Icon","icons","StyledCalendarIconWrapperPseudo","shouldRenderTwo","onAnimationFinished","displayName","_default","exports"],"sources":["../../../../src/components/calendar/Calendar.tsx"],"sourcesContent":["import { Icon } from '@chayns-components/core';\nimport { isSameMonth, type Locale } from 'date-fns';\nimport { de } from 'date-fns/locale';\nimport React, { FC, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport type { Categories, HighlightedDates } from '../../types/calendar';\nimport { getNewDate, isDateInRange } from '../../utils/calendar';\nimport {\n StyledCalendar,\n StyledCalendarIconWrapper,\n StyledCalendarIconWrapperPseudo,\n} from './Calendar.styles';\nimport MonthWrapper from './month-wrapper/MonthWrapper';\n\nconst END_DATE = new Date(new Date().setFullYear(new Date().getFullYear() + 100));\n\nexport type CalendarProps = {\n /**\n * An array to group dates into a category.\n */\n categories?: Categories[];\n /**\n * The last Month that can be displayed.\n */\n endDate?: Date;\n /**\n * An array with dates and corresponding styles to highlight.\n */\n highlightedDates?: HighlightedDates[];\n /**\n * The locale language to format the dates.\n */\n locale?: Locale;\n /**\n * Function to be executed when a date is selected.\n * @param date\n */\n onSelect?: (date: Date) => void;\n /**\n * A date that should be preselected.\n */\n selectedDate?: Date;\n /**\n * The first Month that can be displayed.\n */\n startDate: Date;\n /**\n * To disable the Calendar\n */\n isDisabled?: boolean;\n};\n\nconst Calendar: FC<CalendarProps> = ({\n locale = de,\n endDate = END_DATE,\n startDate,\n highlightedDates,\n onSelect,\n selectedDate,\n categories,\n isDisabled,\n}) => {\n const [currentDate, setCurrentDate] = useState<Date>();\n const [shouldRenderTwoMonths, setShouldRenderTwoMonths] = useState(true);\n const [internalSelectedDate, setInternalSelectedDate] = useState<Date>();\n const [direction, setDirection] = useState<'left' | 'right'>();\n const [width, setWidth] = useState(0);\n\n const calendarRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (selectedDate) {\n setInternalSelectedDate(selectedDate);\n }\n }, [selectedDate]);\n\n useEffect(() => {\n if (calendarRef.current) {\n const resizeObserver = new ResizeObserver((entries) => {\n if (entries && entries[0]) {\n const observedWidth = entries[0].contentRect.width;\n\n setWidth(observedWidth - 30);\n\n if (observedWidth < 430) {\n setShouldRenderTwoMonths(false);\n } else {\n setShouldRenderTwoMonths(true);\n }\n }\n });\n\n resizeObserver.observe(calendarRef.current);\n\n return () => {\n resizeObserver.disconnect();\n };\n }\n\n return () => {};\n }, []);\n\n useEffect(() => {\n const date = new Date();\n\n setCurrentDate(isDateInRange({ startDate, endDate, currentDate: date }));\n }, [endDate, startDate]);\n\n const handleLeftArrowClick = useCallback(() => {\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({ startDate, endDate, currentDate: newDate });\n });\n }, [endDate, startDate]);\n\n const handleRightArrowClick = useCallback(() => {\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({ startDate, endDate, currentDate: newDate });\n });\n }, [endDate, startDate]);\n\n const handleSelect = useCallback(\n (date: Date) => {\n setInternalSelectedDate(date);\n\n if (typeof onSelect === 'function') {\n onSelect(date);\n }\n },\n [onSelect],\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, startDate);\n }, [currentDate, startDate]);\n\n const ShouldShowRightArrow = useMemo(() => {\n if (!currentDate) {\n return false;\n }\n\n return !isSameMonth(currentDate, endDate);\n }, [currentDate, endDate]);\n\n return (\n <StyledCalendar ref={calendarRef} $isDisabled={isDisabled}>\n {ShouldShowLeftArrow ? (\n <StyledCalendarIconWrapper onClick={handleLeftArrowClick}>\n <Icon icons={['fa fa-angle-left']} />\n </StyledCalendarIconWrapper>\n ) : (\n <StyledCalendarIconWrapperPseudo />\n )}\n {currentDate && (\n <MonthWrapper\n shouldRenderTwo={shouldRenderTwoMonths}\n currentDate={currentDate}\n width={width}\n locale={locale}\n direction={direction}\n onSelect={handleSelect}\n selectedDate={internalSelectedDate}\n highlightedDates={highlightedDates}\n categories={categories}\n onAnimationFinished={handleAnimationFinished}\n />\n )}\n {ShouldShowRightArrow ? (\n <StyledCalendarIconWrapper onClick={handleRightArrowClick}>\n <Icon icons={['fa fa-angle-right']} />\n </StyledCalendarIconWrapper>\n ) : (\n <StyledCalendarIconWrapperPseudo />\n )}\n </StyledCalendar>\n );\n};\n\nCalendar.displayName = 'Calendar';\n\nexport default Calendar;\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAC,uBAAA,CAAAJ,OAAA;AAEA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AAKA,IAAAO,aAAA,GAAAC,sBAAA,CAAAR,OAAA;AAAwD,SAAAQ,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,SAAAL,wB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C,qBAAsB;IACvCH,WAAW,EAAEA,WAAY;IACzBS,KAAK,EAAEA,KAAM;IACblB,MAAM,EAAEA,MAAO;IACfgB,SAAS,EAAEA,SAAU;IACrBX,QAAQ,EAAEkC,YAAa;IACvBjC,YAAY,EAAEQ,oBAAqB;IACnCV,gBAAgB,EAAEA,gBAAiB;IACnCG,UAAU,EAAEA,UAAW;IACvBiD,mBAAmB,EAAEhB;EAAwB,CAChD,CACJ,EACAK,oBAAoB,gBACjB5E,MAAA,CAAAQ,OAAA,CAAAqE,aAAA,CAAC1E,SAAA,CAAA8E,yBAAyB;IAACC,OAAO,EAAEb;EAAsB,gBACtDrE,MAAA,CAAAQ,OAAA,CAAAqE,aAAA,CAACjF,KAAA,CAAAuF,IAAI;IAACC,KAAK,EAAE,CAAC,mBAAmB;EAAE,CAAE,CACd,CAAC,gBAE5BpF,MAAA,CAAAQ,OAAA,CAAAqE,aAAA,CAAC1E,SAAA,CAAAkF,+BAA+B,MAAE,CAE1B,CAAC;AAEzB,CAAC;AAEDvD,QAAQ,CAAC0D,WAAW,GAAG,UAAU;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAlF,OAAA,GAEnBsB,QAAQ","ignoreList":[]}
@@ -9,6 +9,12 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
9
9
  const StyledCalendar = exports.StyledCalendar = _styledComponents.default.div`
10
10
  display: flex;
11
11
  width: 100%;
12
+ opacity: ${({
13
+ $isDisabled
14
+ }) => $isDisabled ? 0.5 : 1};
15
+ pointer-events: ${({
16
+ $isDisabled
17
+ }) => $isDisabled ? 'none' : undefined};
12
18
  `;
13
19
  const StyledCalendarIconWrapper = exports.StyledCalendarIconWrapper = _styledComponents.default.div`
14
20
  cursor: pointer;
@@ -1 +1 @@
1
- {"version":3,"file":"Calendar.styles.js","names":["_styledComponents","_interopRequireDefault","require","e","__esModule","default","StyledCalendar","exports","styled","div","StyledCalendarIconWrapper","StyledCalendarIconWrapperPseudo"],"sources":["../../../../src/components/calendar/Calendar.styles.ts"],"sourcesContent":["import styled from 'styled-components';\n\nexport const StyledCalendar = styled.div`\n display: flex;\n width: 100%;\n`;\n\nexport const StyledCalendarIconWrapper = styled.div`\n cursor: pointer;\n z-index: 2;\n`;\n\nexport const StyledCalendarIconWrapperPseudo = styled.div`\n width: 15px;\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAuC,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEhC,MAAMG,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAGE,yBAAM,CAACC,GAAG;AACxC;AACA;AACA,CAAC;AAEM,MAAMC,yBAAyB,GAAAH,OAAA,CAAAG,yBAAA,GAAGF,yBAAM,CAACC,GAAG;AACnD;AACA;AACA,CAAC;AAEM,MAAME,+BAA+B,GAAAJ,OAAA,CAAAI,+BAAA,GAAGH,yBAAM,CAACC,GAAG;AACzD;AACA,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"Calendar.styles.js","names":["_styledComponents","_interopRequireDefault","require","e","__esModule","default","StyledCalendar","exports","styled","div","$isDisabled","undefined","StyledCalendarIconWrapper","StyledCalendarIconWrapperPseudo"],"sources":["../../../../src/components/calendar/Calendar.styles.ts"],"sourcesContent":["import styled from 'styled-components';\n\ntype StyledCalendarProps = { $isDisabled?: boolean };\n\nexport const StyledCalendar = styled.div<StyledCalendarProps>`\n display: flex;\n width: 100%;\n opacity: ${({ $isDisabled }) => ($isDisabled ? 0.5 : 1)};\n pointer-events: ${({ $isDisabled }) => ($isDisabled ? 'none' : undefined)};\n`;\n\nexport const StyledCalendarIconWrapper = styled.div`\n cursor: pointer;\n z-index: 2;\n`;\n\nexport const StyledCalendarIconWrapperPseudo = styled.div`\n width: 15px;\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAuC,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAIhC,MAAMG,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAGE,yBAAM,CAACC,GAAwB;AAC7D;AACA;AACA,eAAe,CAAC;EAAEC;AAAY,CAAC,KAAMA,WAAW,GAAG,GAAG,GAAG,CAAE;AAC3D,sBAAsB,CAAC;EAAEA;AAAY,CAAC,KAAMA,WAAW,GAAG,MAAM,GAAGC,SAAU;AAC7E,CAAC;AAEM,MAAMC,yBAAyB,GAAAL,OAAA,CAAAK,yBAAA,GAAGJ,yBAAM,CAACC,GAAG;AACnD;AACA;AACA,CAAC;AAEM,MAAMI,+BAA+B,GAAAN,OAAA,CAAAM,+BAAA,GAAGL,yBAAM,CAACC,GAAG;AACzD;AACA,CAAC","ignoreList":[]}
@@ -21,7 +21,8 @@ const MonthWrapper = ({
21
21
  direction,
22
22
  onAnimationFinished,
23
23
  shouldRenderTwo,
24
- width
24
+ width,
25
+ isDisabled
25
26
  }) => {
26
27
  const [content, setContent] = (0, _react.useState)();
27
28
  const [prevSelectedDate, setPrevSelectedDate] = (0, _react.useState)();
@@ -149,6 +150,7 @@ const MonthWrapper = ({
149
150
  $width: width
150
151
  }, /*#__PURE__*/_react.default.createElement(_MonthWrapper.StyledMotionWrapper, {
151
152
  animate: animate,
153
+ $isDisabled: isDisabled,
152
154
  transition: {
153
155
  type: 'tween',
154
156
  duration: !direction ? 0 : 0.2
@@ -1 +1 @@
1
- {"version":3,"file":"MonthWrapper.js","names":["_react","_interopRequireWildcard","require","_calendar","_Month","_interopRequireDefault","_MonthWrapper","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","MonthWrapper","locale","currentDate","highlightedDates","selectedDate","onSelect","categories","direction","onAnimationFinished","shouldRenderTwo","width","content","setContent","useState","prevSelectedDate","setPrevSelectedDate","monthHeight","useMemo","useEffect","undefined","prevState","items","date","getNewDate","month","year","getMonthAndYear","push","createElement","height","key","unshift","pop","shift","map","element","props","animate","x","StyledMonthWrapper","$height","$width","StyledMotionWrapper","transition","type","duration","onAnimationComplete","displayName","_default","exports"],"sources":["../../../../../src/components/calendar/month-wrapper/MonthWrapper.tsx"],"sourcesContent":["import type { Locale } from 'date-fns';\nimport type { MotionProps } from 'framer-motion';\nimport React, { FC, useEffect, useMemo, useState, type ReactElement } from 'react';\nimport type { Categories, HighlightedDates } from '../../../types/calendar';\nimport { getMonthAndYear, getNewDate } from '../../../utils/calendar';\nimport Month from './month/Month';\nimport { StyledMonthWrapper, StyledMotionWrapper } from './MonthWrapper.styles';\n\nexport type MonthWrapperProps = {\n locale: Locale;\n highlightedDates?: HighlightedDates[];\n onSelect: (date: Date) => void;\n selectedDate?: Date;\n categories?: Categories[];\n currentDate: Date;\n direction?: 'left' | 'right';\n onAnimationFinished: () => void;\n shouldRenderTwo: boolean;\n width: number;\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}) => {\n const [content, setContent] = useState<ReactElement[]>();\n const [prevSelectedDate, setPrevSelectedDate] = useState<Date>();\n\n const monthHeight = useMemo(() => width / (shouldRenderTwo ? 2 : 1), [width, shouldRenderTwo]);\n\n useEffect(() => {\n setContent(undefined);\n }, [monthHeight]);\n\n useEffect(() => {\n if (prevSelectedDate !== selectedDate) {\n setPrevSelectedDate(selectedDate);\n }\n }, [prevSelectedDate, selectedDate]);\n\n useEffect(() => {\n setContent((prevState) => {\n // Initial render of months\n if (!prevState) {\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 categories={categories}\n selectedDate={selectedDate}\n />,\n );\n }\n\n return items;\n }\n\n if (direction === 'left') {\n const date = getNewDate(-1, currentDate);\n\n const { month, year } = getMonthAndYear(date);\n\n prevState.unshift(\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 categories={categories}\n selectedDate={selectedDate}\n />,\n );\n prevState.pop();\n }\n\n if (direction === 'right') {\n const date = getNewDate(2, currentDate);\n\n const { month, year } = getMonthAndYear(date);\n\n prevState.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 categories={categories}\n selectedDate={selectedDate}\n />,\n );\n prevState.shift();\n }\n\n return prevState;\n });\n }, [\n categories,\n currentDate,\n direction,\n highlightedDates,\n locale,\n monthHeight,\n onSelect,\n prevSelectedDate,\n selectedDate,\n ]);\n\n useEffect(() => {\n if (selectedDate) {\n setContent((prevState) =>\n (prevState ?? []).map((element) => ({\n ...element,\n props: { ...element.props, selectedDate } as ReactElement,\n })),\n );\n }\n }, [selectedDate]);\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 transition={{\n type: 'tween',\n duration: !direction ? 0 : 0.2,\n }}\n onAnimationComplete={onAnimationFinished}\n >\n {content}\n </StyledMotionWrapper>\n </StyledMonthWrapper>\n );\n};\n\nM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AC;QACzB;UACI,OAAO;YAAEA,CAAC,EAAE;UAAO,CAAC;MAC5B;IACJ,CAAC,MAAM;MACH,QAAQ,IAAI;QACR,KAAK/B,SAAS,KAAK,MAAM;UACrB,OAAO;YAAE+B,CAAC,EAAE;UAAK,CAAC;QACtB,KAAK/B,SAAS,KAAK,OAAO;UACtB,OAAO;YAAE+B,CAAC,EAAE;UAAQ,CAAC;QACzB;UACI,OAAO;YAAEA,CAAC,EAAE;UAAQ,CAAC;MAC7B;IACJ;EACJ,CAAC,EAAE,CAAC/B,SAAS,EAAEE,eAAe,CAAC,CAAC;EAEhC,oBACIpC,MAAA,CAAAS,OAAA,CAAA8C,aAAA,CAACjD,aAAA,CAAA4D,kBAAkB;IAACC,OAAO,EAAExB,WAAY;IAACyB,MAAM,EAAE/B;EAAM,gBACpDrC,MAAA,CAAAS,OAAA,CAAA8C,aAAA,CAACjD,aAAA,CAAA+D,mBAAmB;IAChBL,OAAO,EAAEA,OAAQ;IACjBM,UAAU,EAAE;MACRC,IAAI,EAAE,OAAO;MACbC,QAAQ,EAAE,CAACtC,SAAS,GAAG,CAAC,GAAG;IAC/B,CAAE;IACFuC,mBAAmB,EAAEtC;EAAoB,GAExCG,OACgB,CACL,CAAC;AAE7B,CAAC;AAEDX,YAAY,CAAC+C,WAAW,GAAG,cAAc;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAnE,OAAA,GAE3BkB,YAAY","ignoreList":[]}
1
+ {"version":3,"file":"MonthWrapper.js","names":["_react","_interopRequireWildcard","require","_calendar","_Month","_interopRequireDefault","_MonthWrapper","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","MonthWrapper","locale","currentDate","highlightedDates","selectedDate","onSelect","categories","direction","onAnimationFinished","shouldRenderTwo","width","isDisabled","content","setContent","useState","prevSelectedDate","setPrevSelectedDate","monthHeight","useMemo","useEffect","undefined","prevState","items","date","getNewDate","month","year","getMonthAndYear","push","createElement","height","key","unshift","pop","shift","map","element","props","animate","x","StyledMonthWrapper","$height","$width","StyledMotionWrapper","$isDisabled","transition","type","duration","onAnimationComplete","displayName","_default","exports"],"sources":["../../../../../src/components/calendar/month-wrapper/MonthWrapper.tsx"],"sourcesContent":["import type { Locale } from 'date-fns';\nimport type { MotionProps } from 'framer-motion';\nimport React, { FC, useEffect, useMemo, useState, type ReactElement } from 'react';\nimport type { Categories, HighlightedDates } from '../../../types/calendar';\nimport { getMonthAndYear, getNewDate } from '../../../utils/calendar';\nimport Month from './month/Month';\nimport { StyledMonthWrapper, StyledMotionWrapper } from './MonthWrapper.styles';\n\nexport type MonthWrapperProps = {\n locale: Locale;\n highlightedDates?: HighlightedDates[];\n onSelect: (date: Date) => void;\n selectedDate?: Date;\n categories?: Categories[];\n currentDate: Date;\n direction?: 'left' | 'right';\n onAnimationFinished: () => void;\n shouldRenderTwo: boolean;\n width: number;\n isDisabled?: boolean;\n};\n\nconst MonthWrapper: FC<MonthWrapperProps> = ({\n locale,\n currentDate,\n highlightedDates,\n selectedDate,\n onSelect,\n categories,\n direction,\n onAnimationFinished,\n shouldRenderTwo,\n width,\n isDisabled,\n}) => {\n const [content, setContent] = useState<ReactElement[]>();\n const [prevSelectedDate, setPrevSelectedDate] = useState<Date>();\n\n const monthHeight = useMemo(() => width / (shouldRenderTwo ? 2 : 1), [width, shouldRenderTwo]);\n\n useEffect(() => {\n setContent(undefined);\n }, [monthHeight]);\n\n useEffect(() => {\n if (prevSelectedDate !== selectedDate) {\n setPrevSelectedDate(selectedDate);\n }\n }, [prevSelectedDate, selectedDate]);\n\n useEffect(() => {\n setContent((prevState) => {\n // Initial render of months\n if (!prevState) {\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 categories={categories}\n selectedDate={selectedDate}\n />,\n );\n }\n\n return items;\n }\n\n if (direction === 'left') {\n const date = getNewDate(-1, currentDate);\n\n const { month, year } = getMonthAndYear(date);\n\n prevState.unshift(\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 categories={categories}\n selectedDate={selectedDate}\n />,\n );\n prevState.pop();\n }\n\n if (direction === 'right') {\n const date = getNewDate(2, currentDate);\n\n const { month, year } = getMonthAndYear(date);\n\n prevState.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 categories={categories}\n selectedDate={selectedDate}\n />,\n );\n prevState.shift();\n }\n\n return prevState;\n });\n }, [\n categories,\n currentDate,\n direction,\n highlightedDates,\n locale,\n monthHeight,\n onSelect,\n prevSelectedDate,\n selectedDate,\n ]);\n\n useEffect(() => {\n if (selectedDate) {\n setContent((prevState) =>\n (prevState ?? []).map((element) => ({\n ...element,\n props: { ...element.props, selectedDate } as ReactElement,\n })),\n );\n }\n }, [selectedDate]);\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 = 'MonthWrap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CAAC;QACzB;UACI,OAAO;YAAEA,CAAC,EAAE;UAAO,CAAC;MAC5B;IACJ,CAAC,MAAM;MACH,QAAQ,IAAI;QACR,KAAKhC,SAAS,KAAK,MAAM;UACrB,OAAO;YAAEgC,CAAC,EAAE;UAAK,CAAC;QACtB,KAAKhC,SAAS,KAAK,OAAO;UACtB,OAAO;YAAEgC,CAAC,EAAE;UAAQ,CAAC;QACzB;UACI,OAAO;YAAEA,CAAC,EAAE;UAAQ,CAAC;MAC7B;IACJ;EACJ,CAAC,EAAE,CAAChC,SAAS,EAAEE,eAAe,CAAC,CAAC;EAEhC,oBACIpC,MAAA,CAAAS,OAAA,CAAA+C,aAAA,CAAClD,aAAA,CAAA6D,kBAAkB;IAACC,OAAO,EAAExB,WAAY;IAACyB,MAAM,EAAEhC;EAAM,gBACpDrC,MAAA,CAAAS,OAAA,CAAA+C,aAAA,CAAClD,aAAA,CAAAgE,mBAAmB;IAChBL,OAAO,EAAEA,OAAQ;IACjBM,WAAW,EAAEjC,UAAW;IACxBkC,UAAU,EAAE;MACRC,IAAI,EAAE,OAAO;MACbC,QAAQ,EAAE,CAACxC,SAAS,GAAG,CAAC,GAAG;IAC/B,CAAE;IACFyC,mBAAmB,EAAExC;EAAoB,GAExCI,OACgB,CACL,CAAC;AAE7B,CAAC;AAEDZ,YAAY,CAACiD,WAAW,GAAG,cAAc;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAArE,OAAA,GAE3BkB,YAAY","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"MonthWrapper.styles.js","names":["_framerMotion","require","_styledComponents","_interopRequireDefault","e","__esModule","default","StyledMonthWrapper","exports","styled","div","$width","$height","StyledMotionWrapper","motion"],"sources":["../../../../../src/components/calendar/month-wrapper/MonthWrapper.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport { motion } from 'framer-motion';\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\nexport const StyledMotionWrapper = styled(motion.div)`\n display: flex;\n height: 100%;\n`;\n"],"mappings":";;;;;;AACA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAuC,SAAAE,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAIhC,MAAMG,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAGE,yBAAM,CAACC,GAA4B;AACrE,aAAa,CAAC;EAAEC;AAAO,CAAC,KAAKA,MAAM;AACnC;AACA,cAAc,CAAC;EAAEC;AAAQ,CAAC,KAAKA,OAAO;AACtC,CAAC;AAEM,MAAMC,mBAAmB,GAAAL,OAAA,CAAAK,mBAAA,GAAG,IAAAJ,yBAAM,EAACK,oBAAM,CAACJ,GAAG,CAAC;AACrD;AACA;AACA,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"MonthWrapper.styles.js","names":["_framerMotion","require","_styledComponents","_interopRequireDefault","e","__esModule","default","StyledMonthWrapper","exports","styled","div","$width","$height","StyledMotionWrapper","motion"],"sources":["../../../../../src/components/calendar/month-wrapper/MonthWrapper.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport { motion } from 'framer-motion';\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,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAuC,SAAAE,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAIhC,MAAMG,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAGE,yBAAM,CAACC,GAA4B;AACrE,aAAa,CAAC;EAAEC;AAAO,CAAC,KAAKA,MAAM;AACnC;AACA,cAAc,CAAC;EAAEC;AAAQ,CAAC,KAAKA,OAAO;AACtC,CAAC;AAIM,MAAMC,mBAAmB,GAAAL,OAAA,CAAAK,mBAAA,GAAG,IAAAJ,yBAAM,EAACK,oBAAM,CAACJ,GAAG,CAA2B;AAC/E;AACA;AACA,CAAC","ignoreList":[]}
@@ -1,9 +1,9 @@
1
- import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
1
+ import { Icon } from '@chayns-components/core';
2
2
  import { isSameMonth } from 'date-fns';
3
3
  import { de } from 'date-fns/locale';
4
- import { StyledCalendar, StyledCalendarIconWrapper, StyledCalendarIconWrapperPseudo } from './Calendar.styles';
4
+ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
5
5
  import { getNewDate, isDateInRange } from '../../utils/calendar';
6
- import { Icon } from '@chayns-components/core';
6
+ import { StyledCalendar, StyledCalendarIconWrapper, StyledCalendarIconWrapperPseudo } from './Calendar.styles';
7
7
  import MonthWrapper from './month-wrapper/MonthWrapper';
8
8
  const END_DATE = new Date(new Date().setFullYear(new Date().getFullYear() + 100));
9
9
  const Calendar = _ref => {
@@ -14,7 +14,8 @@ const Calendar = _ref => {
14
14
  highlightedDates,
15
15
  onSelect,
16
16
  selectedDate,
17
- categories
17
+ categories,
18
+ isDisabled
18
19
  } = _ref;
19
20
  const [currentDate, setCurrentDate] = useState();
20
21
  const [shouldRenderTwoMonths, setShouldRenderTwoMonths] = useState(true);
@@ -105,7 +106,8 @@ const Calendar = _ref => {
105
106
  return !isSameMonth(currentDate, endDate);
106
107
  }, [currentDate, endDate]);
107
108
  return /*#__PURE__*/React.createElement(StyledCalendar, {
108
- ref: calendarRef
109
+ ref: calendarRef,
110
+ $isDisabled: isDisabled
109
111
  }, ShouldShowLeftArrow ? /*#__PURE__*/React.createElement(StyledCalendarIconWrapper, {
110
112
  onClick: handleLeftArrowClick
111
113
  }, /*#__PURE__*/React.createElement(Icon, {
@@ -1 +1 @@
1
- {"version":3,"file":"Calendar.js","names":["React","useCallback","useEffect","useMemo","useRef","useState","isSameMonth","de","StyledCalendar","StyledCalendarIconWrapper","StyledCalendarIconWrapperPseudo","getNewDate","isDateInRange","Icon","MonthWrapper","END_DATE","Date","setFullYear","getFullYear","Calendar","_ref","locale","endDate","startDate","highlightedDates","onSelect","selectedDate","categories","currentDate","setCurrentDate","shouldRenderTwoMonths","setShouldRenderTwoMonths","internalSelectedDate","setInternalSelectedDate","direction","setDirection","width","setWidth","calendarRef","current","resizeObserver","ResizeObserver","entries","observedWidth","contentRect","observe","disconnect","date","handleLeftArrowClick","prevDate","newDate","handleRightArrowClick","handleSelect","handleAnimationFinished","undefined","ShouldShowLeftArrow","ShouldShowRightArrow","createElement","ref","onClick","icons","shouldRenderTwo","onAnimationFinished","displayName"],"sources":["../../../../src/components/calendar/Calendar.tsx"],"sourcesContent":["import React, { FC, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { isSameMonth, type Locale } from 'date-fns';\nimport { de } from 'date-fns/locale';\nimport {\n StyledCalendar,\n StyledCalendarIconWrapper,\n StyledCalendarIconWrapperPseudo,\n} from './Calendar.styles';\nimport { getNewDate, isDateInRange } from '../../utils/calendar';\nimport type { Categories, HighlightedDates } from '../../types/calendar';\nimport { Icon } from '@chayns-components/core';\nimport MonthWrapper from './month-wrapper/MonthWrapper';\n\nconst END_DATE = new Date(new Date().setFullYear(new Date().getFullYear() + 100));\n\nexport type CalendarProps = {\n /**\n * An array to group dates into a category.\n */\n categories?: Categories[];\n /**\n * The last Month that can be displayed.\n */\n endDate?: Date;\n /**\n * An array with dates and corresponding styles to highlight.\n */\n highlightedDates?: HighlightedDates[];\n /**\n * The locale language to format the dates.\n */\n locale?: Locale;\n /**\n * Function to be executed when a date is selected.\n * @param date\n */\n onSelect?: (date: Date) => void;\n /**\n * A date that should be preselected.\n */\n selectedDate?: Date;\n /**\n * The first Month that can be displayed.\n */\n startDate: Date;\n};\n\nconst Calendar: FC<CalendarProps> = ({\n locale = de,\n endDate = END_DATE,\n startDate,\n highlightedDates,\n onSelect,\n selectedDate,\n categories,\n}) => {\n const [currentDate, setCurrentDate] = useState<Date>();\n const [shouldRenderTwoMonths, setShouldRenderTwoMonths] = useState(true);\n const [internalSelectedDate, setInternalSelectedDate] = useState<Date>();\n const [direction, setDirection] = useState<'left' | 'right'>();\n const [width, setWidth] = useState(0);\n\n const calendarRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (selectedDate) {\n setInternalSelectedDate(selectedDate);\n }\n }, [selectedDate]);\n\n useEffect(() => {\n if (calendarRef.current) {\n const resizeObserver = new ResizeObserver((entries) => {\n if (entries && entries[0]) {\n const observedWidth = entries[0].contentRect.width;\n\n setWidth(observedWidth - 30);\n\n if (observedWidth < 430) {\n setShouldRenderTwoMonths(false);\n } else {\n setShouldRenderTwoMonths(true);\n }\n }\n });\n\n resizeObserver.observe(calendarRef.current);\n\n return () => {\n resizeObserver.disconnect();\n };\n }\n\n return () => {};\n }, []);\n\n useEffect(() => {\n const date = new Date();\n\n setCurrentDate(isDateInRange({ startDate, endDate, currentDate: date }));\n }, [endDate, startDate]);\n\n const handleLeftArrowClick = useCallback(() => {\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({ startDate, endDate, currentDate: newDate });\n });\n }, [endDate, startDate]);\n\n const handleRightArrowClick = useCallback(() => {\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({ startDate, endDate, currentDate: newDate });\n });\n }, [endDate, startDate]);\n\n const handleSelect = useCallback(\n (date: Date) => {\n setInternalSelectedDate(date);\n\n if (typeof onSelect === 'function') {\n onSelect(date);\n }\n },\n [onSelect],\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, startDate);\n }, [currentDate, startDate]);\n\n const ShouldShowRightArrow = useMemo(() => {\n if (!currentDate) {\n return false;\n }\n\n return !isSameMonth(currentDate, endDate);\n }, [currentDate, endDate]);\n\n return (\n <StyledCalendar ref={calendarRef}>\n {ShouldShowLeftArrow ? (\n <StyledCalendarIconWrapper onClick={handleLeftArrowClick}>\n <Icon icons={['fa fa-angle-left']} />\n </StyledCalendarIconWrapper>\n ) : (\n <StyledCalendarIconWrapperPseudo />\n )}\n {currentDate && (\n <MonthWrapper\n shouldRenderTwo={shouldRenderTwoMonths}\n currentDate={currentDate}\n width={width}\n locale={locale}\n direction={direction}\n onSelect={handleSelect}\n selectedDate={internalSelectedDate}\n highlightedDates={highlightedDates}\n categories={categories}\n onAnimationFinished={handleAnimationFinished}\n />\n )}\n {ShouldShowRightArrow ? (\n <StyledCalendarIconWrapper onClick={handleRightArrowClick}>\n <Icon icons={['fa fa-angle-right']} />\n </StyledCalendarIconWrapper>\n ) : (\n <StyledCalendarIconWrapperPseudo />\n )}\n </StyledCalendar>\n );\n};\n\nCalendar.displayName = 'Calendar';\n\nexport default Calendar;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAQC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AACpF,SAASC,WAAW,QAAqB,UAAU;AACnD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SACIC,cAAc,EACdC,yBAAyB,EACzBC,+B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DhD,KAAA,CAAAyD,aAAA,CAAC5C,IAAI;IAAC+C,KAAK,EAAE,CAAC,kBAAkB;EAAE,CAAE,CACb,CAAC,gBAE5B5D,KAAA,CAAAyD,aAAA,CAAC/C,+BAA+B,MAAE,CACrC,EACAkB,WAAW,iBACR5B,KAAA,CAAAyD,aAAA,CAAC3C,YAAY;IACT+C,eAAe,EAAE/B,qBAAsB;IACvCF,WAAW,EAAEA,WAAY;IACzBQ,KAAK,EAAEA,KAAM;IACbf,MAAM,EAAEA,MAAO;IACfa,SAAS,EAAEA,SAAU;IACrBT,QAAQ,EAAE2B,YAAa;IACvB1B,YAAY,EAAEM,oBAAqB;IACnCR,gBAAgB,EAAEA,gBAAiB;IACnCG,UAAU,EAAEA,UAAW;IACvBmC,mBAAmB,EAAET;EAAwB,CAChD,CACJ,EACAG,oBAAoB,gBACjBxD,KAAA,CAAAyD,aAAA,CAAChD,yBAAyB;IAACkD,OAAO,EAAER;EAAsB,gBACtDnD,KAAA,CAAAyD,aAAA,CAAC5C,IAAI;IAAC+C,KAAK,EAAE,CAAC,mBAAmB;EAAE,CAAE,CACd,CAAC,gBAE5B5D,KAAA,CAAAyD,aAAA,CAAC/C,+BAA+B,MAAE,CAE1B,CAAC;AAEzB,CAAC;AAEDS,QAAQ,CAAC4C,WAAW,GAAG,UAAU;AAEjC,eAAe5C,QAAQ","ignoreList":[]}
1
+ {"version":3,"file":"Calendar.js","names":["Icon","isSameMonth","de","React","useCallback","useEffect","useMemo","useRef","useState","getNewDate","isDateInRange","StyledCalendar","StyledCalendarIconWrapper","StyledCalendarIconWrapperPseudo","MonthWrapper","END_DATE","Date","setFullYear","getFullYear","Calendar","_ref","locale","endDate","startDate","highlightedDates","onSelect","selectedDate","categories","isDisabled","currentDate","setCurrentDate","shouldRenderTwoMonths","setShouldRenderTwoMonths","internalSelectedDate","setInternalSelectedDate","direction","setDirection","width","setWidth","calendarRef","current","resizeObserver","ResizeObserver","entries","observedWidth","contentRect","observe","disconnect","date","handleLeftArrowClick","prevDate","newDate","handleRightArrowClick","handleSelect","handleAnimationFinished","undefined","ShouldShowLeftArrow","ShouldShowRightArrow","createElement","ref","$isDisabled","onClick","icons","shouldRenderTwo","onAnimationFinished","displayName"],"sources":["../../../../src/components/calendar/Calendar.tsx"],"sourcesContent":["import { Icon } from '@chayns-components/core';\nimport { isSameMonth, type Locale } from 'date-fns';\nimport { de } from 'date-fns/locale';\nimport React, { FC, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport type { Categories, HighlightedDates } from '../../types/calendar';\nimport { getNewDate, isDateInRange } from '../../utils/calendar';\nimport {\n StyledCalendar,\n StyledCalendarIconWrapper,\n StyledCalendarIconWrapperPseudo,\n} from './Calendar.styles';\nimport MonthWrapper from './month-wrapper/MonthWrapper';\n\nconst END_DATE = new Date(new Date().setFullYear(new Date().getFullYear() + 100));\n\nexport type CalendarProps = {\n /**\n * An array to group dates into a category.\n */\n categories?: Categories[];\n /**\n * The last Month that can be displayed.\n */\n endDate?: Date;\n /**\n * An array with dates and corresponding styles to highlight.\n */\n highlightedDates?: HighlightedDates[];\n /**\n * The locale language to format the dates.\n */\n locale?: Locale;\n /**\n * Function to be executed when a date is selected.\n * @param date\n */\n onSelect?: (date: Date) => void;\n /**\n * A date that should be preselected.\n */\n selectedDate?: Date;\n /**\n * The first Month that can be displayed.\n */\n startDate: Date;\n /**\n * To disable the Calendar\n */\n isDisabled?: boolean;\n};\n\nconst Calendar: FC<CalendarProps> = ({\n locale = de,\n endDate = END_DATE,\n startDate,\n highlightedDates,\n onSelect,\n selectedDate,\n categories,\n isDisabled,\n}) => {\n const [currentDate, setCurrentDate] = useState<Date>();\n const [shouldRenderTwoMonths, setShouldRenderTwoMonths] = useState(true);\n const [internalSelectedDate, setInternalSelectedDate] = useState<Date>();\n const [direction, setDirection] = useState<'left' | 'right'>();\n const [width, setWidth] = useState(0);\n\n const calendarRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (selectedDate) {\n setInternalSelectedDate(selectedDate);\n }\n }, [selectedDate]);\n\n useEffect(() => {\n if (calendarRef.current) {\n const resizeObserver = new ResizeObserver((entries) => {\n if (entries && entries[0]) {\n const observedWidth = entries[0].contentRect.width;\n\n setWidth(observedWidth - 30);\n\n if (observedWidth < 430) {\n setShouldRenderTwoMonths(false);\n } else {\n setShouldRenderTwoMonths(true);\n }\n }\n });\n\n resizeObserver.observe(calendarRef.current);\n\n return () => {\n resizeObserver.disconnect();\n };\n }\n\n return () => {};\n }, []);\n\n useEffect(() => {\n const date = new Date();\n\n setCurrentDate(isDateInRange({ startDate, endDate, currentDate: date }));\n }, [endDate, startDate]);\n\n const handleLeftArrowClick = useCallback(() => {\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({ startDate, endDate, currentDate: newDate });\n });\n }, [endDate, startDate]);\n\n const handleRightArrowClick = useCallback(() => {\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({ startDate, endDate, currentDate: newDate });\n });\n }, [endDate, startDate]);\n\n const handleSelect = useCallback(\n (date: Date) => {\n setInternalSelectedDate(date);\n\n if (typeof onSelect === 'function') {\n onSelect(date);\n }\n },\n [onSelect],\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, startDate);\n }, [currentDate, startDate]);\n\n const ShouldShowRightArrow = useMemo(() => {\n if (!currentDate) {\n return false;\n }\n\n return !isSameMonth(currentDate, endDate);\n }, [currentDate, endDate]);\n\n return (\n <StyledCalendar ref={calendarRef} $isDisabled={isDisabled}>\n {ShouldShowLeftArrow ? (\n <StyledCalendarIconWrapper onClick={handleLeftArrowClick}>\n <Icon icons={['fa fa-angle-left']} />\n </StyledCalendarIconWrapper>\n ) : (\n <StyledCalendarIconWrapperPseudo />\n )}\n {currentDate && (\n <MonthWrapper\n shouldRenderTwo={shouldRenderTwoMonths}\n currentDate={currentDate}\n width={width}\n locale={locale}\n direction={direction}\n onSelect={handleSelect}\n selectedDate={internalSelectedDate}\n highlightedDates={highlightedDates}\n categories={categories}\n onAnimationFinished={handleAnimationFinished}\n />\n )}\n {ShouldShowRightArrow ? (\n <StyledCalendarIconWrapper onClick={handleRightArrowClick}>\n <Icon icons={['fa fa-angle-right']} />\n </StyledCalendarIconWrapper>\n ) : (\n <StyledCalendarIconWrapperPseudo />\n )}\n </StyledCalendar>\n );\n};\n\nCalendar.displayName = 'Calendar';\n\nexport default Calendar;\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,yBAAyB;AAC9C,SAASC,WAAW,QAAqB,UAAU;AACnD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,OAAOC,KAAK,IAAQC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAEpF,SAASC,UAAU,EAAEC,aAAa,QAAQ,sBAAsB;AAChE,SACIC,cAAc,EACdC,yBAAyB,EACzBC,+BAA+B,QAC5B,mBAAmB;AAC1B,OAAOC,YAAY,MAAM,8BAA8B;AAEvD,MAAMC,QAAQ,GAAG,IAAIC,IAAI,CAAC,IAAIA,IAAI,CAAC,CAAC,CAACC,WAAW,CAAC,IAAID,IAAI,CAAC,CAAC,CAACE,WAAW,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;AAsCjF,MAAMC,QAA2B,GAAGC,IAAA,IAS9B;EAAA,IAT+B;IACjCC,MAAM,GAAGnB,EAAE;IACXoB,OAAO,GAAGP,QAAQ;IAClBQ,SAAS;IACTC,gBAAgB;IAChBC,QAAQ;IACRC,YAAY;IACZC,UAAU;IACVC;EACJ,CAAC,GAAAR,IAAA;EACG,MAAM,CAACS,WAAW,EAAEC,cAAc,CAAC,GAAGtB,QAAQ,CAAO,CAAC;EACt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A,CAAAuD,aAAA,CAAC9C,yBAAyB;IAACiD,OAAO,EAAET;EAAsB,gBACtDjD,KAAA,CAAAuD,aAAA,CAAC1D,IAAI;IAAC8D,KAAK,EAAE,CAAC,mBAAmB;EAAE,CAAE,CACd,CAAC,gBAE5B3D,KAAA,CAAAuD,aAAA,CAAC7C,+BAA+B,MAAE,CAE1B,CAAC;AAEzB,CAAC;AAEDM,QAAQ,CAAC8C,WAAW,GAAG,UAAU;AAEjC,eAAe9C,QAAQ","ignoreList":[]}
@@ -2,6 +2,18 @@ import styled from 'styled-components';
2
2
  export const StyledCalendar = styled.div`
3
3
  display: flex;
4
4
  width: 100%;
5
+ opacity: ${_ref => {
6
+ let {
7
+ $isDisabled
8
+ } = _ref;
9
+ return $isDisabled ? 0.5 : 1;
10
+ }};
11
+ pointer-events: ${_ref2 => {
12
+ let {
13
+ $isDisabled
14
+ } = _ref2;
15
+ return $isDisabled ? 'none' : undefined;
16
+ }};
5
17
  `;
6
18
  export const StyledCalendarIconWrapper = styled.div`
7
19
  cursor: pointer;
@@ -1 +1 @@
1
- {"version":3,"file":"Calendar.styles.js","names":["styled","StyledCalendar","div","StyledCalendarIconWrapper","StyledCalendarIconWrapperPseudo"],"sources":["../../../../src/components/calendar/Calendar.styles.ts"],"sourcesContent":["import styled from 'styled-components';\n\nexport const StyledCalendar = styled.div`\n display: flex;\n width: 100%;\n`;\n\nexport const StyledCalendarIconWrapper = styled.div`\n cursor: pointer;\n z-index: 2;\n`;\n\nexport const StyledCalendarIconWrapperPseudo = styled.div`\n width: 15px;\n`;\n"],"mappings":"AAAA,OAAOA,MAAM,MAAM,mBAAmB;AAEtC,OAAO,MAAMC,cAAc,GAAGD,MAAM,CAACE,GAAG;AACxC;AACA;AACA,CAAC;AAED,OAAO,MAAMC,yBAAyB,GAAGH,MAAM,CAACE,GAAG;AACnD;AACA;AACA,CAAC;AAED,OAAO,MAAME,+BAA+B,GAAGJ,MAAM,CAACE,GAAG;AACzD;AACA,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"Calendar.styles.js","names":["styled","StyledCalendar","div","_ref","$isDisabled","_ref2","undefined","StyledCalendarIconWrapper","StyledCalendarIconWrapperPseudo"],"sources":["../../../../src/components/calendar/Calendar.styles.ts"],"sourcesContent":["import styled from 'styled-components';\n\ntype StyledCalendarProps = { $isDisabled?: boolean };\n\nexport const StyledCalendar = styled.div<StyledCalendarProps>`\n display: flex;\n width: 100%;\n opacity: ${({ $isDisabled }) => ($isDisabled ? 0.5 : 1)};\n pointer-events: ${({ $isDisabled }) => ($isDisabled ? 'none' : undefined)};\n`;\n\nexport const StyledCalendarIconWrapper = styled.div`\n cursor: pointer;\n z-index: 2;\n`;\n\nexport const StyledCalendarIconWrapperPseudo = styled.div`\n width: 15px;\n`;\n"],"mappings":"AAAA,OAAOA,MAAM,MAAM,mBAAmB;AAItC,OAAO,MAAMC,cAAc,GAAGD,MAAM,CAACE,GAAwB;AAC7D;AACA;AACA,eAAeC,IAAA;EAAA,IAAC;IAAEC;EAAY,CAAC,GAAAD,IAAA;EAAA,OAAMC,WAAW,GAAG,GAAG,GAAG,CAAC;AAAA,CAAC;AAC3D,sBAAsBC,KAAA;EAAA,IAAC;IAAED;EAAY,CAAC,GAAAC,KAAA;EAAA,OAAMD,WAAW,GAAG,MAAM,GAAGE,SAAS;AAAA,CAAC;AAC7E,CAAC;AAED,OAAO,MAAMC,yBAAyB,GAAGP,MAAM,CAACE,GAAG;AACnD;AACA;AACA,CAAC;AAED,OAAO,MAAMM,+BAA+B,GAAGR,MAAM,CAACE,GAAG;AACzD;AACA,CAAC","ignoreList":[]}
@@ -13,7 +13,8 @@ const MonthWrapper = _ref => {
13
13
  direction,
14
14
  onAnimationFinished,
15
15
  shouldRenderTwo,
16
- width
16
+ width,
17
+ isDisabled
17
18
  } = _ref;
18
19
  const [content, setContent] = useState();
19
20
  const [prevSelectedDate, setPrevSelectedDate] = useState();
@@ -141,6 +142,7 @@ const MonthWrapper = _ref => {
141
142
  $width: width
142
143
  }, /*#__PURE__*/React.createElement(StyledMotionWrapper, {
143
144
  animate: animate,
145
+ $isDisabled: isDisabled,
144
146
  transition: {
145
147
  type: 'tween',
146
148
  duration: !direction ? 0 : 0.2
@@ -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","content","setContent","prevSelectedDate","setPrevSelectedDate","monthHeight","undefined","prevState","items","i","date","month","year","push","createElement","height","key","unshift","pop","shift","map","element","props","animate","x","$height","$width","transition","type","duration","onAnimationComplete","displayName"],"sources":["../../../../../src/components/calendar/month-wrapper/MonthWrapper.tsx"],"sourcesContent":["import type { Locale } from 'date-fns';\nimport type { MotionProps } from 'framer-motion';\nimport React, { FC, useEffect, useMemo, useState, type ReactElement } from 'react';\nimport type { Categories, HighlightedDates } from '../../../types/calendar';\nimport { getMonthAndYear, getNewDate } from '../../../utils/calendar';\nimport Month from './month/Month';\nimport { StyledMonthWrapper, StyledMotionWrapper } from './MonthWrapper.styles';\n\nexport type MonthWrapperProps = {\n locale: Locale;\n highlightedDates?: HighlightedDates[];\n onSelect: (date: Date) => void;\n selectedDate?: Date;\n categories?: Categories[];\n currentDate: Date;\n direction?: 'left' | 'right';\n onAnimationFinished: () => void;\n shouldRenderTwo: boolean;\n width: number;\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}) => {\n const [content, setContent] = useState<ReactElement[]>();\n const [prevSelectedDate, setPrevSelectedDate] = useState<Date>();\n\n const monthHeight = useMemo(() => width / (shouldRenderTwo ? 2 : 1), [width, shouldRenderTwo]);\n\n useEffect(() => {\n setContent(undefined);\n }, [monthHeight]);\n\n useEffect(() => {\n if (prevSelectedDate !== selectedDate) {\n setPrevSelectedDate(selectedDate);\n }\n }, [prevSelectedDate, selectedDate]);\n\n useEffect(() => {\n setContent((prevState) => {\n // Initial render of months\n if (!prevState) {\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 categories={categories}\n selectedDate={selectedDate}\n />,\n );\n }\n\n return items;\n }\n\n if (direction === 'left') {\n const date = getNewDate(-1, currentDate);\n\n const { month, year } = getMonthAndYear(date);\n\n prevState.unshift(\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 categories={categories}\n selectedDate={selectedDate}\n />,\n );\n prevState.pop();\n }\n\n if (direction === 'right') {\n const date = getNewDate(2, currentDate);\n\n const { month, year } = getMonthAndYear(date);\n\n prevState.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 categories={categories}\n selectedDate={selectedDate}\n />,\n );\n prevState.shift();\n }\n\n return prevState;\n });\n }, [\n categories,\n currentDate,\n direction,\n highlightedDates,\n locale,\n monthHeight,\n onSelect,\n prevSelectedDate,\n selectedDate,\n ]);\n\n useEffect(() => {\n if (selectedDate) {\n setContent((prevState) =>\n (prevState ?? []).map((element) => ({\n ...element,\n props: { ...element.props, selectedDate } as ReactElement,\n })),\n );\n }\n }, [selectedDate]);\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 transition={{\n type: 'tween',\n duration: !direction ? 0 : 0.2,\n }}\n onAnimationComplete={onAnimationFinished}\n >\n {content}\n </StyledMotionWrapper>\n </StyledMonthWrapper>\n );\n};\n\nMonthWrapper.displayName = 'MonthWrapper';\n\nexport default MonthWrapper;\n"],"mappings":"AAEA,OAAOA,KAAK,IAAQC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAA2B,OAAO;AAElF,SAASC,eAAe,EAAEC,UAAU,QAAQ,yBAAyB;AACrE,OAAOC,KAAK,MAAM,eAAe;AACjC,SAASC,kBAAkB,EAAEC,mBAAmB,QAAQ,uBAAuB;AAe/E,MAAMC,YAAmC,GAAGC,IAAA,IAWtC;EAAA,IAXuC;IACzCC,MAAM;IACNC,WAAW;IACXC,gBAAgB;IAChBC,YAAY;IACZC,QAAQ;IACRC,UAAU;IACVC,SAAS;IACTC,mBAAmB;IACnBC,eAAe;IACfC;EACJ,CAAC,GAAAV,IAAA;EACG,MAAM,CAACW,OAAO,EAAEC,UAAU,CAAC,GAAGnB,QAAQ,CAAiB,CAAC;EACxD,MAAM,CAACoB,gBAAgB,EAAEC,mBAAmB,CAAC,GAAGrB,QAAQ,CAAO,CAAC;EAEhE,MAAMsB,WAAW,GAAGvB,OAAO,CAAC,MAAMkB,KAAK,IAAID,eAAe,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAACC,KAAK,EAAED,eAAe,CAAC,CAAC;EAE9FlB,SAAS,CAAC,MAAM;IACZqB,UAAU,CAACI,SAAS,CAAC;EACzB,CAAC,EAAE,CAACD,WAAW,CAAC,CAAC;EAEjBxB,SAAS,CAAC,MAAM;IACZ,IAAIsB,gBAAgB,KAAKT,YAAY,EAAE;MACnCU,mBAAmB,CAACV,YAAY,CAAC;IACrC;EACJ,CAAC,EA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AA+B,GAAGzC,OAAO,CAAC,MAAM;IAClD,IAAIiB,eAAe,EAAE;MACjB,QAAQ,IAAI;QACR,KAAKF,SAAS,KAAK,MAAM;UACrB,OAAO;YAAE2B,CAAC,EAAE;UAAK,CAAC;QACtB,KAAK3B,SAAS,KAAK,OAAO;UACtB,OAAO;YAAE2B,CAAC,EAAE;UAAQ,CAAC;QACzB;UACI,OAAO;YAAEA,CAAC,EAAE;UAAO,CAAC;MAC5B;IACJ,CAAC,MAAM;MACH,QAAQ,IAAI;QACR,KAAK3B,SAAS,KAAK,MAAM;UACrB,OAAO;YAAE2B,CAAC,EAAE;UAAK,CAAC;QACtB,KAAK3B,SAAS,KAAK,OAAO;UACtB,OAAO;YAAE2B,CAAC,EAAE;UAAQ,CAAC;QACzB;UACI,OAAO;YAAEA,CAAC,EAAE;UAAQ,CAAC;MAC7B;IACJ;EACJ,CAAC,EAAE,CAAC3B,SAAS,EAAEE,eAAe,CAAC,CAAC;EAEhC,oBACInB,KAAA,CAAAkC,aAAA,CAAC3B,kBAAkB;IAACsC,OAAO,EAAEpB,WAAY;IAACqB,MAAM,EAAE1B;EAAM,gBACpDpB,KAAA,CAAAkC,aAAA,CAAC1B,mBAAmB;IAChBmC,OAAO,EAAEA,OAAQ;IACjBI,UAAU,EAAE;MACRC,IAAI,EAAE,OAAO;MACbC,QAAQ,EAAE,CAAChC,SAAS,GAAG,CAAC,GAAG;IAC/B,CAAE;IACFiC,mBAAmB,EAAEhC;EAAoB,GAExCG,OACgB,CACL,CAAC;AAE7B,CAAC;AAEDZ,YAAY,CAAC0C,WAAW,GAAG,cAAc;AAEzC,eAAe1C,YAAY","ignoreList":[]}
1
+ {"version":3,"file":"MonthWrapper.js","names":["React","useEffect","useMemo","useState","getMonthAndYear","getNewDate","Month","StyledMonthWrapper","StyledMotionWrapper","MonthWrapper","_ref","locale","currentDate","highlightedDates","selectedDate","onSelect","categories","direction","onAnimationFinished","shouldRenderTwo","width","isDisabled","content","setContent","prevSelectedDate","setPrevSelectedDate","monthHeight","undefined","prevState","items","i","date","month","year","push","createElement","height","key","unshift","pop","shift","map","element","props","animate","x","$height","$width","$isDisabled","transition","type","duration","onAnimationComplete","displayName"],"sources":["../../../../../src/components/calendar/month-wrapper/MonthWrapper.tsx"],"sourcesContent":["import type { Locale } from 'date-fns';\nimport type { MotionProps } from 'framer-motion';\nimport React, { FC, useEffect, useMemo, useState, type ReactElement } from 'react';\nimport type { Categories, HighlightedDates } from '../../../types/calendar';\nimport { getMonthAndYear, getNewDate } from '../../../utils/calendar';\nimport Month from './month/Month';\nimport { StyledMonthWrapper, StyledMotionWrapper } from './MonthWrapper.styles';\n\nexport type MonthWrapperProps = {\n locale: Locale;\n highlightedDates?: HighlightedDates[];\n onSelect: (date: Date) => void;\n selectedDate?: Date;\n categories?: Categories[];\n currentDate: Date;\n direction?: 'left' | 'right';\n onAnimationFinished: () => void;\n shouldRenderTwo: boolean;\n width: number;\n isDisabled?: boolean;\n};\n\nconst MonthWrapper: FC<MonthWrapperProps> = ({\n locale,\n currentDate,\n highlightedDates,\n selectedDate,\n onSelect,\n categories,\n direction,\n onAnimationFinished,\n shouldRenderTwo,\n width,\n isDisabled,\n}) => {\n const [content, setContent] = useState<ReactElement[]>();\n const [prevSelectedDate, setPrevSelectedDate] = useState<Date>();\n\n const monthHeight = useMemo(() => width / (shouldRenderTwo ? 2 : 1), [width, shouldRenderTwo]);\n\n useEffect(() => {\n setContent(undefined);\n }, [monthHeight]);\n\n useEffect(() => {\n if (prevSelectedDate !== selectedDate) {\n setPrevSelectedDate(selectedDate);\n }\n }, [prevSelectedDate, selectedDate]);\n\n useEffect(() => {\n setContent((prevState) => {\n // Initial render of months\n if (!prevState) {\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 categories={categories}\n selectedDate={selectedDate}\n />,\n );\n }\n\n return items;\n }\n\n if (direction === 'left') {\n const date = getNewDate(-1, currentDate);\n\n const { month, year } = getMonthAndYear(date);\n\n prevState.unshift(\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 categories={categories}\n selectedDate={selectedDate}\n />,\n );\n prevState.pop();\n }\n\n if (direction === 'right') {\n const date = getNewDate(2, currentDate);\n\n const { month, year } = getMonthAndYear(date);\n\n prevState.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 categories={categories}\n selectedDate={selectedDate}\n />,\n );\n prevState.shift();\n }\n\n return prevState;\n });\n }, [\n categories,\n currentDate,\n direction,\n highlightedDates,\n locale,\n monthHeight,\n onSelect,\n prevSelectedDate,\n selectedDate,\n ]);\n\n useEffect(() => {\n if (selectedDate) {\n setContent((prevState) =>\n (prevState ?? []).map((element) => ({\n ...element,\n props: { ...element.props, selectedDate } as ReactElement,\n })),\n );\n }\n }, [selectedDate]);\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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C;MAC5B;IACJ,CAAC,MAAM;MACH,QAAQ,IAAI;QACR,KAAK5B,SAAS,KAAK,MAAM;UACrB,OAAO;YAAE4B,CAAC,EAAE;UAAK,CAAC;QACtB,KAAK5B,SAAS,KAAK,OAAO;UACtB,OAAO;YAAE4B,CAAC,EAAE;UAAQ,CAAC;QACzB;UACI,OAAO;YAAEA,CAAC,EAAE;UAAQ,CAAC;MAC7B;IACJ;EACJ,CAAC,EAAE,CAAC5B,SAAS,EAAEE,eAAe,CAAC,CAAC;EAEhC,oBACInB,KAAA,CAAAmC,aAAA,CAAC5B,kBAAkB;IAACuC,OAAO,EAAEpB,WAAY;IAACqB,MAAM,EAAE3B;EAAM,gBACpDpB,KAAA,CAAAmC,aAAA,CAAC3B,mBAAmB;IAChBoC,OAAO,EAAEA,OAAQ;IACjBI,WAAW,EAAE3B,UAAW;IACxB4B,UAAU,EAAE;MACRC,IAAI,EAAE,OAAO;MACbC,QAAQ,EAAE,CAAClC,SAAS,GAAG,CAAC,GAAG;IAC/B,CAAE;IACFmC,mBAAmB,EAAElC;EAAoB,GAExCI,OACgB,CACL,CAAC;AAE7B,CAAC;AAEDb,YAAY,CAAC4C,WAAW,GAAG,cAAc;AAEzC,eAAe5C,YAAY","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"MonthWrapper.styles.js","names":["motion","styled","StyledMonthWrapper","div","_ref","$width","_ref2","$height","StyledMotionWrapper"],"sources":["../../../../../src/components/calendar/month-wrapper/MonthWrapper.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport { motion } from 'framer-motion';\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\nexport const StyledMotionWrapper = styled(motion.div)`\n display: flex;\n height: 100%;\n`;\n"],"mappings":"AACA,SAASA,MAAM,QAAQ,eAAe;AACtC,OAAOC,MAAM,MAAM,mBAAmB;AAItC,OAAO,MAAMC,kBAAkB,GAAGD,MAAM,CAACE,GAA4B;AACrE,aAAaC,IAAA;EAAA,IAAC;IAAEC;EAAO,CAAC,GAAAD,IAAA;EAAA,OAAKC,MAAM;AAAA;AACnC;AACA,cAAcC,KAAA;EAAA,IAAC;IAAEC;EAAQ,CAAC,GAAAD,KAAA;EAAA,OAAKC,OAAO;AAAA;AACtC,CAAC;AAED,OAAO,MAAMC,mBAAmB,GAAGP,MAAM,CAACD,MAAM,CAACG,GAAG,CAAC;AACrD;AACA;AACA,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"MonthWrapper.styles.js","names":["motion","styled","StyledMonthWrapper","div","_ref","$width","_ref2","$height","StyledMotionWrapper"],"sources":["../../../../../src/components/calendar/month-wrapper/MonthWrapper.styles.ts"],"sourcesContent":["import type { WithTheme } from '@chayns-components/core';\nimport { motion } from 'framer-motion';\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,eAAe;AACtC,OAAOC,MAAM,MAAM,mBAAmB;AAItC,OAAO,MAAMC,kBAAkB,GAAGD,MAAM,CAACE,GAA4B;AACrE,aAAaC,IAAA;EAAA,IAAC;IAAEC;EAAO,CAAC,GAAAD,IAAA;EAAA,OAAKC,MAAM;AAAA;AACnC;AACA,cAAcC,KAAA;EAAA,IAAC;IAAEC;EAAQ,CAAC,GAAAD,KAAA;EAAA,OAAKC,OAAO;AAAA;AACtC,CAAC;AAID,OAAO,MAAMC,mBAAmB,GAAGP,MAAM,CAACD,MAAM,CAACG,GAAG,CAA2B;AAC/E;AACA;AACA,CAAC","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import { FC } from 'react';
2
1
  import { type Locale } from 'date-fns';
2
+ import { FC } from 'react';
3
3
  import type { Categories, HighlightedDates } from '../../types/calendar';
4
4
  export type CalendarProps = {
5
5
  /**
@@ -31,6 +31,10 @@ export type CalendarProps = {
31
31
  * The first Month that can be displayed.
32
32
  */
33
33
  startDate: Date;
34
+ /**
35
+ * To disable the Calendar
36
+ */
37
+ isDisabled?: boolean;
34
38
  };
35
39
  declare const Calendar: FC<CalendarProps>;
36
40
  export default Calendar;
@@ -1,3 +1,7 @@
1
- export declare const StyledCalendar: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
1
+ type StyledCalendarProps = {
2
+ $isDisabled?: boolean;
3
+ };
4
+ export declare const StyledCalendar: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledCalendarProps>> & string;
2
5
  export declare const StyledCalendarIconWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
3
6
  export declare const StyledCalendarIconWrapperPseudo: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
7
+ export {};
@@ -12,6 +12,7 @@ export type MonthWrapperProps = {
12
12
  onAnimationFinished: () => void;
13
13
  shouldRenderTwo: boolean;
14
14
  width: number;
15
+ isDisabled?: boolean;
15
16
  };
16
17
  declare const MonthWrapper: FC<MonthWrapperProps>;
17
18
  export default MonthWrapper;
@@ -4,7 +4,10 @@ type StyledMonthWrapperProps = WithTheme<{
4
4
  $width: number;
5
5
  }>;
6
6
  export declare const StyledMonthWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledMonthWrapperProps>> & string;
7
- export declare const StyledMotionWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<{
7
+ type StyledMotionWrapperProps = {
8
+ $isDisabled?: boolean;
9
+ };
10
+ export declare const StyledMotionWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<Omit<{
8
11
  color?: string | undefined;
9
12
  defaultChecked?: boolean | undefined;
10
13
  defaultValue?: string | number | readonly string[] | undefined;
@@ -266,5 +269,5 @@ export declare const StyledMotionWrapper: import("styled-components/dist/types")
266
269
  onTransitionEndCapture?: import("react").TransitionEventHandler<HTMLDivElement> | undefined;
267
270
  } & import("framer-motion").MotionProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & {
268
271
  ref?: ((instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLDivElement> | null | undefined;
269
- }, never>> & string & Omit<import("framer-motion").ForwardRefComponent<HTMLDivElement, import("framer-motion").HTMLMotionProps<"div">>, keyof import("react").Component<any, {}, any>>;
272
+ }, StyledMotionWrapperProps>> & string & Omit<import("framer-motion").ForwardRefComponent<HTMLDivElement, import("framer-motion").HTMLMotionProps<"div">>, keyof import("react").Component<any, {}, any>>;
270
273
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chayns-components/date",
3
- "version": "5.0.0-beta.718",
3
+ "version": "5.0.0-beta.719",
4
4
  "description": "A set of beautiful React components for developing your own applications with chayns.",
5
5
  "sideEffects": false,
6
6
  "browserslist": [
@@ -67,7 +67,7 @@
67
67
  "typescript": "^5.5.4"
68
68
  },
69
69
  "dependencies": {
70
- "@chayns-components/core": "^5.0.0-beta.718",
70
+ "@chayns-components/core": "^5.0.0-beta.719",
71
71
  "date-fns": "^2.30.0",
72
72
  "uuid": "^9.0.1"
73
73
  },
@@ -81,5 +81,5 @@
81
81
  "publishConfig": {
82
82
  "access": "public"
83
83
  },
84
- "gitHead": "e3f617666e06d2c43017901bcb6dac55162d2a43"
84
+ "gitHead": "d40c2613880a6867019a5a42d560312df5496ae2"
85
85
  }