@chayns-components/date 5.0.0-beta.920 → 5.0.0-beta.921

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.
Files changed (73) hide show
  1. package/lib/cjs/components/calendar/Calendar.js +17 -17
  2. package/lib/cjs/components/calendar/Calendar.js.map +1 -1
  3. package/lib/cjs/components/calendar/month-wrapper/MonthWrapper.js +1 -0
  4. package/lib/cjs/components/calendar/month-wrapper/MonthWrapper.js.map +1 -1
  5. package/lib/cjs/components/calendar/month-wrapper/month/Month.js.map +1 -1
  6. package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.js +19 -21
  7. package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.js.map +1 -1
  8. package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/day/Day.js +3 -3
  9. package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/day/Day.js.map +1 -1
  10. package/lib/cjs/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.js +9 -11
  11. package/lib/cjs/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.js.map +1 -1
  12. package/lib/cjs/components/calendar/month-year-pickers/MonthYearPickers.js +2 -2
  13. package/lib/cjs/components/calendar/month-year-pickers/MonthYearPickers.js.map +1 -1
  14. package/lib/cjs/components/date-info/DateInfo.js.map +1 -1
  15. package/lib/cjs/hooks/useDateInfo.js +27 -72
  16. package/lib/cjs/hooks/useDateInfo.js.map +1 -1
  17. package/lib/cjs/index.js +130 -2
  18. package/lib/cjs/index.js.map +1 -1
  19. package/lib/cjs/types/dateinfo.js +2 -0
  20. package/lib/cjs/types/dateinfo.js.map +1 -0
  21. package/lib/cjs/utils/calendar.js +12 -9
  22. package/lib/cjs/utils/calendar.js.map +1 -1
  23. package/lib/cjs/utils/date.js +114 -0
  24. package/lib/cjs/utils/date.js.map +1 -0
  25. package/lib/cjs/utils/dateInfo.js +99 -344
  26. package/lib/cjs/utils/dateInfo.js.map +1 -1
  27. package/lib/esm/components/calendar/Calendar.js +4 -4
  28. package/lib/esm/components/calendar/Calendar.js.map +1 -1
  29. package/lib/esm/components/calendar/month-wrapper/MonthWrapper.js +1 -0
  30. package/lib/esm/components/calendar/month-wrapper/MonthWrapper.js.map +1 -1
  31. package/lib/esm/components/calendar/month-wrapper/month/Month.js.map +1 -1
  32. package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.js +2 -4
  33. package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.js.map +1 -1
  34. package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/Day.js +1 -1
  35. package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/Day.js.map +1 -1
  36. package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.js +8 -10
  37. package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.js.map +1 -1
  38. package/lib/esm/components/calendar/month-year-pickers/MonthYearPickers.js +1 -1
  39. package/lib/esm/components/calendar/month-year-pickers/MonthYearPickers.js.map +1 -1
  40. package/lib/esm/components/date-info/DateInfo.js.map +1 -1
  41. package/lib/esm/hooks/useDateInfo.js +28 -73
  42. package/lib/esm/hooks/useDateInfo.js.map +1 -1
  43. package/lib/esm/index.js +10 -2
  44. package/lib/esm/index.js.map +1 -1
  45. package/lib/esm/types/dateinfo.js +2 -0
  46. package/lib/esm/types/dateinfo.js.map +1 -0
  47. package/lib/esm/utils/calendar.js +4 -3
  48. package/lib/esm/utils/calendar.js.map +1 -1
  49. package/lib/esm/utils/date.js +89 -0
  50. package/lib/esm/utils/date.js.map +1 -0
  51. package/lib/esm/utils/dateInfo.js +98 -339
  52. package/lib/esm/utils/dateInfo.js.map +1 -1
  53. package/lib/types/components/calendar/Calendar.d.ts +2 -2
  54. package/lib/types/components/calendar/month-wrapper/MonthWrapper.d.ts +2 -2
  55. package/lib/types/components/calendar/month-wrapper/MonthWrapper.styles.d.ts +1 -1
  56. package/lib/types/components/calendar/month-wrapper/month/Month.d.ts +2 -2
  57. package/lib/types/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.d.ts +2 -2
  58. package/lib/types/components/calendar/month-year-pickers/MonthYearPickers.d.ts +2 -2
  59. package/lib/types/components/date-info/DateInfo.d.ts +1 -1
  60. package/lib/types/components/opening-times/opening-inputs/OpeningInputs.styles.d.ts +1 -1
  61. package/lib/types/components/opening-times/opening-inputs/opening-input/OpeningInput.styles.d.ts +1 -1
  62. package/lib/types/hooks/useDateInfo.d.ts +1 -34
  63. package/lib/types/index.d.ts +6 -4
  64. package/lib/types/types/dateinfo.d.ts +34 -0
  65. package/lib/types/utils/calendar.d.ts +2 -2
  66. package/lib/types/utils/date.d.ts +27 -0
  67. package/lib/types/utils/dateInfo.d.ts +10 -51
  68. package/package.json +3 -4
  69. package/lib/cjs/constants/dateInfo.js +0 -639
  70. package/lib/cjs/constants/dateInfo.js.map +0 -1
  71. package/lib/esm/constants/dateInfo.js +0 -633
  72. package/lib/esm/constants/dateInfo.js.map +0 -1
  73. package/lib/types/constants/dateInfo.d.ts +0 -23
@@ -1 +1 @@
1
- {"version":3,"file":"Day.js","names":["_dateFns","require","_react","_interopRequireWildcard","_Category","_interopRequireDefault","_Day","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","Day","date","highlightedDates","categories","isSameMonth","isSelected","onClick","isDisabled","isIntervalStart","isIntervalEnd","customThumbColors","isWithinIntervalSelection","shouldShowHighlightsInMonthOverlay","setHoveringDay","dayRef","useRef","styles","useMemo","_highlightedDates$fin","undefined","find","highlightedDate","dates","some","highlighted","isSameDay","style","categoryElements","flatMap","category","filter","day","map","createElement","key","getTime","Math","random","color","StyledDay","ref","$isSameMonth","$isDisabled","$backgroundColor","backgroundColor","$textColor","textColor","onMouseEnter","onMouseLeave","StyledDayNumber","$customThumbColors","$isSelected","$isIntervalStart","$isIntervalEnd","$isWithinIntervalSelection","getDate","StyledDayCategoryWrapper","displayName","_default","exports"],"sources":["../../../../../../../../src/components/calendar/month-wrapper/month/day-wrapper/day/Day.tsx"],"sourcesContent":["import { isSameDay } from 'date-fns';\nimport React, { FC, useMemo, useRef } from 'react';\nimport {\n Categories, CustomThumbColors,\n HighlightedDates,\n HighlightedDateStyles,\n} from '../../../../../../types/calendar';\nimport Category from './category/Category';\nimport { StyledDay, StyledDayCategoryWrapper, StyledDayNumber } from './Day.styles';\n\nexport type DayProps = {\n date: Date;\n isSameMonth: boolean;\n isSelected: boolean;\n onClick: (date: Date, shouldFireEvent: boolean) => void;\n highlightedDates?: HighlightedDates[];\n categories?: Categories[];\n isDisabled: boolean;\n isIntervalStart: boolean;\n isIntervalEnd: boolean;\n isWithinIntervalSelection: boolean;\n setHoveringDay: (date: Date | null) => void;\n shouldShowHighlightsInMonthOverlay: boolean;\n customThumbColors?: CustomThumbColors;\n};\n\nconst Day: FC<DayProps> = ({\n date,\n highlightedDates,\n categories,\n isSameMonth,\n isSelected,\n onClick,\n isDisabled,\n isIntervalStart,\n isIntervalEnd,customThumbColors,\n isWithinIntervalSelection,\n shouldShowHighlightsInMonthOverlay,\n setHoveringDay,\n}) => {\n const dayRef = useRef<HTMLDivElement>(null);\n\n const styles: HighlightedDateStyles | undefined = useMemo(() => {\n if (!highlightedDates || (!shouldShowHighlightsInMonthOverlay && !isSameMonth)) {\n return undefined;\n }\n\n return highlightedDates.find((highlightedDate) =>\n highlightedDate.dates.some((highlighted) => isSameDay(highlighted, date)),\n )?.style;\n }, [date, highlightedDates, isSameMonth, shouldShowHighlightsInMonthOverlay]);\n\n const categoryElements = useMemo(() => {\n if (!categories || (!shouldShowHighlightsInMonthOverlay && !isSameMonth)) return [];\n\n return categories.flatMap((category) =>\n category.dates\n .filter((day) => isSameDay(day, date))\n .map((day) => (\n <Category key={day.getTime() * Math.random()} color={category.color} />\n )),\n );\n }, [categories, date, isSameMonth, shouldShowHighlightsInMonthOverlay]);\n\n return (\n <StyledDay\n ref={dayRef}\n onClick={() => onClick(date, isSameMonth && !isDisabled)}\n $isSameMonth={isSameMonth}\n $isDisabled={isDisabled}\n $backgroundColor={styles?.backgroundColor}\n $textColor={styles?.textColor}\n onMouseEnter={() => setHoveringDay(date)}\n onMouseLeave={() => setHoveringDay(null)}\n >\n <StyledDayNumber\n $customThumbColors={customThumbColors}\n $isSelected={\n shouldShowHighlightsInMonthOverlay ? isSelected : isSelected && isSameMonth\n }\n $isIntervalStart={\n shouldShowHighlightsInMonthOverlay\n ? isIntervalStart\n : isIntervalStart && isSameMonth\n }\n $isIntervalEnd={\n shouldShowHighlightsInMonthOverlay\n ? isIntervalEnd\n : isIntervalEnd && isSameMonth\n }\n $isWithinIntervalSelection={\n shouldShowHighlightsInMonthOverlay\n ? isWithinIntervalSelection\n : isWithinIntervalSelection && isSameMonth\n }\n >\n {date.getDate()}\n </StyledDayNumber>\n {categoryElements && (\n <StyledDayCategoryWrapper>{categoryElements}</StyledDayCategoryWrapper>\n )}\n </StyledDay>\n );\n};\n\nDay.displayName = 'Day';\n\nexport default Day;\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AAMA,IAAAG,SAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,IAAA,GAAAL,OAAA;AAAoF,SAAAI,uBAAAE,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,SAAAJ,wBAAAI,CAAA,EAAAK,CAAA,SAAAA,CAAA,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C,UAAW;IACxBoC,gBAAgB,EAAE3B,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAE4B,eAAgB;IAC1CC,UAAU,EAAE7B,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAE8B,SAAU;IAC9BC,YAAY,EAAEA,CAAA,KAAMlC,cAAc,CAACZ,IAAI,CAAE;IACzC+C,YAAY,EAAEA,CAAA,KAAMnC,cAAc,CAAC,IAAI;EAAE,gBAEzCtC,MAAA,CAAAO,OAAA,CAAAmD,aAAA,CAACtD,IAAA,CAAAsE,eAAe;IACZC,kBAAkB,EAAExC,iBAAkB;IACtCyC,WAAW,EACPvC,kCAAkC,GAAGP,UAAU,GAAGA,UAAU,IAAID,WACnE;IACDgD,gBAAgB,EACZxC,kCAAkC,GAC5BJ,eAAe,GACfA,eAAe,IAAIJ,WAC5B;IACDiD,cAAc,EACVzC,kCAAkC,GAC5BH,aAAa,GACbA,aAAa,IAAIL,WAC1B;IACDkD,0BAA0B,EACtB1C,kCAAkC,GAC5BD,yBAAyB,GACzBA,yBAAyB,IAAIP;EACtC,GAEAH,IAAI,CAACsD,OAAO,CAAC,CACD,CAAC,EACjB5B,gBAAgB,iBACbpD,MAAA,CAAAO,OAAA,CAAAmD,aAAA,CAACtD,IAAA,CAAA6E,wBAAwB,QAAE7B,gBAA2C,CAEnE,CAAC;AAEpB,CAAC;AAED3B,GAAG,CAACyD,WAAW,GAAG,KAAK;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA7E,OAAA,GAETkB,GAAG","ignoreList":[]}
1
+ {"version":3,"file":"Day.js","names":["_react","_interopRequireWildcard","require","_Category","_interopRequireDefault","_Day","_date","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","Day","date","highlightedDates","categories","isSameMonth","isSelected","onClick","isDisabled","isIntervalStart","isIntervalEnd","customThumbColors","isWithinIntervalSelection","shouldShowHighlightsInMonthOverlay","setHoveringDay","dayRef","useRef","styles","useMemo","_highlightedDates$fin","undefined","find","highlightedDate","dates","some","highlighted","isSameDay","style","categoryElements","flatMap","category","filter","day","map","createElement","key","getTime","Math","random","color","StyledDay","ref","$isSameMonth","$isDisabled","$backgroundColor","backgroundColor","$textColor","textColor","onMouseEnter","onMouseLeave","StyledDayNumber","$customThumbColors","$isSelected","$isIntervalStart","$isIntervalEnd","$isWithinIntervalSelection","getDate","StyledDayCategoryWrapper","displayName","_default","exports"],"sources":["../../../../../../../../src/components/calendar/month-wrapper/month/day-wrapper/day/Day.tsx"],"sourcesContent":["import React, { FC, useMemo, useRef } from 'react';\nimport {\n Categories, CustomThumbColors,\n HighlightedDates,\n HighlightedDateStyles,\n} from '../../../../../../types/calendar';\nimport Category from './category/Category';\nimport { StyledDay, StyledDayCategoryWrapper, StyledDayNumber } from './Day.styles';\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};\n\nconst Day: FC<DayProps> = ({\n date,\n highlightedDates,\n categories,\n isSameMonth,\n isSelected,\n onClick,\n isDisabled,\n isIntervalStart,\n isIntervalEnd,customThumbColors,\n isWithinIntervalSelection,\n shouldShowHighlightsInMonthOverlay,\n setHoveringDay,\n}) => {\n const dayRef = useRef<HTMLDivElement>(null);\n\n const styles: HighlightedDateStyles | undefined = useMemo(() => {\n if (!highlightedDates || (!shouldShowHighlightsInMonthOverlay && !isSameMonth)) {\n return undefined;\n }\n\n return highlightedDates.find((highlightedDate) =>\n highlightedDate.dates.some((highlighted) => isSameDay(highlighted, date)),\n )?.style;\n }, [date, highlightedDates, isSameMonth, shouldShowHighlightsInMonthOverlay]);\n\n const categoryElements = useMemo(() => {\n if (!categories || (!shouldShowHighlightsInMonthOverlay && !isSameMonth)) return [];\n\n return categories.flatMap((category) =>\n category.dates\n .filter((day) => isSameDay(day, date))\n .map((day) => (\n <Category key={day.getTime() * Math.random()} color={category.color} />\n )),\n );\n }, [categories, date, isSameMonth, shouldShowHighlightsInMonthOverlay]);\n\n return (\n <StyledDay\n ref={dayRef}\n onClick={() => onClick(date, isSameMonth && !isDisabled)}\n $isSameMonth={isSameMonth}\n $isDisabled={isDisabled}\n $backgroundColor={styles?.backgroundColor}\n $textColor={styles?.textColor}\n onMouseEnter={() => setHoveringDay(date)}\n onMouseLeave={() => setHoveringDay(null)}\n >\n <StyledDayNumber\n $customThumbColors={customThumbColors}\n $isSelected={\n shouldShowHighlightsInMonthOverlay ? isSelected : isSelected && isSameMonth\n }\n $isIntervalStart={\n shouldShowHighlightsInMonthOverlay\n ? isIntervalStart\n : isIntervalStart && isSameMonth\n }\n $isIntervalEnd={\n shouldShowHighlightsInMonthOverlay\n ? isIntervalEnd\n : isIntervalEnd && isSameMonth\n }\n $isWithinIntervalSelection={\n shouldShowHighlightsInMonthOverlay\n ? isWithinIntervalSelection\n : isWithinIntervalSelection && isSameMonth\n }\n >\n {date.getDate()}\n </StyledDayNumber>\n {categoryElements && (\n <StyledDayCategoryWrapper>{categoryElements}</StyledDayCategoryWrapper>\n )}\n </StyledDay>\n );\n};\n\nDay.displayName = 'Day';\n\nexport default Day;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAMA,IAAAC,SAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,IAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAAuD,SAAAE,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAA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});
6
6
  exports.default = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
- var _dateFns = require("date-fns");
9
8
  var _WeekdayWrapper = require("./WeekdayWrapper.styles");
10
9
  var _Weekday = _interopRequireDefault(require("./weekday/Weekday"));
10
+ var _date = require("../../../../../utils/date");
11
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
12
  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); }
13
13
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
14
  const WeekdayWrapper = ({
15
15
  locale
16
16
  }) => {
17
- const monday = (0, _dateFns.startOfWeek)(new Date(), {
18
- weekStartsOn: 1
19
- });
20
- const sunday = (0, _dateFns.endOfWeek)(new Date(), {
21
- weekStartsOn: 1
22
- });
23
- const weekdays = (0, _dateFns.eachDayOfInterval)({
17
+ const monday = (0, _date.startOfWeek)(new Date());
18
+ const sunday = (0, _date.endOfWeek)(new Date());
19
+ const weekdays = (0, _date.eachDayOfInterval)({
24
20
  start: monday,
25
21
  end: sunday
26
22
  });
27
23
  const weekdayElements = (0, _react.useMemo)(() => {
28
24
  const items = [];
29
25
  weekdays.forEach(day => {
30
- const formattedDay = (0, _dateFns.format)(day, 'EE', {
31
- locale
32
- });
26
+ const options = {
27
+ weekday: 'short'
28
+ };
29
+ const formatter = new Intl.DateTimeFormat(locale, options);
30
+ const formattedDay = formatter.format(day);
33
31
  items.push(/*#__PURE__*/_react.default.createElement(_Weekday.default, {
34
32
  key: `weekday-${formattedDay}`,
35
33
  name: formattedDay
@@ -1 +1 @@
1
- {"version":3,"file":"WeekdayWrapper.js","names":["_react","_interopRequireWildcard","require","_dateFns","_WeekdayWrapper","_Weekday","_interopRequireDefault","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","WeekdayWrapper","locale","monday","startOfWeek","Date","weekStartsOn","sunday","endOfWeek","weekdays","eachDayOfInterval","start","end","weekdayElements","useMemo","items","forEach","day","formattedDay","format","push","createElement","key","name","StyledWeekdayWrapper","displayName","_default","exports"],"sources":["../../../../../../../src/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.tsx"],"sourcesContent":["import React, { FC, type ReactElement, useMemo } from 'react';\nimport { startOfWeek, endOfWeek, eachDayOfInterval, format } from 'date-fns';\nimport { StyledWeekdayWrapper } from './WeekdayWrapper.styles';\nimport Weekday from './weekday/Weekday';\nimport type { Locale } from 'date-fns';\n\nexport type WeekdayWrapperProps = {\n locale?: Locale;\n};\n\nconst WeekdayWrapper: FC<WeekdayWrapperProps> = ({ locale }) => {\n const monday = startOfWeek(new Date(), { weekStartsOn: 1 });\n const sunday = endOfWeek(new Date(), { weekStartsOn: 1 });\n const weekdays = eachDayOfInterval({ start: monday, end: sunday });\n\n const weekdayElements = useMemo(() => {\n const items: ReactElement[] = [];\n\n weekdays.forEach((day) => {\n const formattedDay = format(day, 'EE', { locale });\n\n items.push(<Weekday key={`weekday-${formattedDay}`} name={formattedDay} />);\n });\n\n return items;\n }, [locale, weekdays]);\n\n return <StyledWeekdayWrapper>{weekdayElements}</StyledWeekdayWrapper>;\n};\n\nWeekdayWrapper.displayName = 'WeekdayWrapper';\n\nexport default WeekdayWrapper;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GA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_Weekday","_interopRequireDefault","_date","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","WeekdayWrapper","locale","monday","startOfWeek","Date","sunday","endOfWeek","weekdays","eachDayOfInterval","start","end","weekdayElements","useMemo","items","forEach","day","options","weekday","formatter","Intl","DateTimeFormat","formattedDay","format","push","createElement","key","name","StyledWeekdayWrapper","displayName","_default","exports"],"sources":["../../../../../../../src/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.tsx"],"sourcesContent":["import React, { FC, type ReactElement, useMemo } from 'react';\nimport { StyledWeekdayWrapper } from './WeekdayWrapper.styles';\nimport Weekday from './weekday/Weekday';\nimport {Language} from \"chayns-api\";\nimport {eachDayOfInterval, endOfWeek, startOfWeek} from \"../../../../../utils/date\";\n\nexport type WeekdayWrapperProps = {\n locale?: Language;\n};\n\nconst WeekdayWrapper: FC<WeekdayWrapperProps> = ({ locale }) => {\n const monday = startOfWeek(new Date());\n const sunday = endOfWeek(new Date());\n const weekdays = eachDayOfInterval({ start: monday, end: sunday });\n\n const weekdayElements = useMemo(() => {\n const items: ReactElement[] = [];\n\n weekdays.forEach((day) => {\n const options: Intl.DateTimeFormatOptions = { weekday: 'short' };\n const formatter = new Intl.DateTimeFormat(locale, options);\n const formattedDay = formatter.format(day);\n\n items.push(<Weekday key={`weekday-${formattedDay}`} name={formattedDay} />);\n });\n\n return items;\n }, [locale, weekdays]);\n\n return <StyledWeekdayWrapper>{weekdayElements}</StyledWeekdayWrapper>;\n};\n\nWeekdayWrapper.displayName = 'WeekdayWrapper';\n\nexport default WeekdayWrapper;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,KAAA,GAAAJ,OAAA;AAAoF,SAAAG,uBAA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,MAAM,GAAG,IAAAC,iBAAW,EAAC,IAAIC,IAAI,CAAC,CAAC,CAAC;EACtC,MAAMC,MAAM,GAAG,IAAAC,eAAS,EAAC,IAAIF,IAAI,CAAC,CAAC,CAAC;EACpC,MAAMG,QAAQ,GAAG,IAAAC,uBAAiB,EAAC;IAAEC,KAAK,EAAEP,MAAM;IAAEQ,GAAG,EAAEL;EAAO,CAAC,CAAC;EAElE,MAAMM,eAAe,GAAG,IAAAC,cAAO,EAAC,MAAM;IAClC,MAAMC,KAAqB,GAAG,EAAE;IAEhCN,QAAQ,CAACO,OAAO,CAAEC,GAAG,IAAK;MACtB,MAAMC,OAAmC,GAAG;QAAEC,OAAO,EAAE;MAAQ,CAAC;MAChE,MAAMC,SAAS,GAAG,IAAIC,IAAI,CAACC,cAAc,CAACnB,MAAM,EAAEe,OAAO,CAAC;MAC1D,MAAMK,YAAY,GAAGH,SAAS,CAACI,MAAM,CAACP,GAAG,CAAC;MAE1CF,KAAK,CAACU,IAAI,cAAClD,MAAA,CAAAS,OAAA,CAAA0C,aAAA,CAAC/C,QAAA,CAAAK,OAAO;QAAC2C,GAAG,EAAE,WAAWJ,YAAY,EAAG;QAACK,IAAI,EAAEL;MAAa,CAAE,CAAC,CAAC;IAC/E,CAAC,CAAC;IAEF,OAAOR,KAAK;EAChB,CAAC,EAAE,CAACZ,MAAM,EAAEM,QAAQ,CAAC,CAAC;EAEtB,oBAAOlC,MAAA,CAAAS,OAAA,CAAA0C,aAAA,CAAChD,eAAA,CAAAmD,oBAAoB,QAAEhB,eAAsC,CAAC;AACzE,CAAC;AAEDX,cAAc,CAAC4B,WAAW,GAAG,gBAAgB;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAhD,OAAA,GAE/BkB,cAAc","ignoreList":[]}
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = exports.MonthYearPickerType = void 0;
7
7
  var _core = require("@chayns-components/core");
8
- var _dateFns = require("date-fns");
9
8
  var _react = _interopRequireWildcard(require("react"));
10
9
  var _calendar = require("../../../utils/calendar");
11
10
  var _Month = require("../month-wrapper/month/Month.styles");
11
+ var _date = require("../../../utils/date");
12
12
  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); }
13
13
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
14
  let MonthYearPickerType = exports.MonthYearPickerType = /*#__PURE__*/function (MonthYearPickerType) {
@@ -34,7 +34,7 @@ const MonthYearPickers = ({
34
34
  }),
35
35
  value: tempMonth
36
36
  })), [locale]);
37
- const hasMultipleMonths = (0, _react.useMemo)(() => (0, _dateFns.differenceInCalendarMonths)(maxDate, minDate) > 0, [minDate, maxDate]);
37
+ const hasMultipleMonths = (0, _react.useMemo)(() => (0, _date.differenceInCalendarMonths)(maxDate, minDate) > 0, [minDate, maxDate]);
38
38
  const years = (0, _react.useMemo)(() => (0, _calendar.getYearsBetween)(minDate, maxDate).map(tempYear => ({
39
39
  text: tempYear.toString(),
40
40
  value: tempYear
@@ -1 +1 @@
1
- {"version":3,"file":"MonthYearPickers.js","names":["_core","require","_dateFns","_react","_interopRequireWildcard","_calendar","_Month","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","MonthYearPickerType","exports","MonthYearPickers","month","year","locale","minDate","maxDate","setCurrentDate","displayIndex","showMonthYearPickers","currentYear","useState","Date","getFullYear","months","useMemo","map","tempMonth","text","formatMonth","value","hasMultipleMonths","differenceInCalendarMonths","years","getYearsBetween","tempYear","toString","hasMultipleYears","length","createElement","Fragment","ComboBox","onSelect","selectedItem","tempSelectedDate","isDateInRange","currentDate","lists","list","placeholder","StyledMonthName","_default"],"sources":["../../../../../src/components/calendar/month-year-pickers/MonthYearPickers.tsx"],"sourcesContent":["import { ComboBox } from '@chayns-components/core';\nimport { differenceInCalendarMonths, Locale } from 'date-fns';\nimport React, { FC, useMemo, useState } from 'react';\nimport { EMonth } from '../../../types/calendar';\nimport { formatMonth, getYearsBetween, isDateInRange } from '../../../utils/calendar';\nimport { StyledMonthName } from '../month-wrapper/month/Month.styles';\n\nexport enum MonthYearPickerType {\n Month = 'month',\n Year = 'year',\n}\n\ntype MonthYearPickerProps = {\n month: EMonth;\n year: number;\n locale: Locale;\n minDate: Date;\n maxDate: Date;\n setCurrentDate: (date: Date) => void;\n displayIndex?: number;\n showMonthYearPickers: boolean;\n};\n\nconst MonthYearPickers: FC<MonthYearPickerProps> = ({\n month,\n year,\n locale,\n minDate,\n maxDate,\n setCurrentDate,\n displayIndex = 0,\n showMonthYearPickers,\n}) => {\n const [currentYear] = useState(new Date().getFullYear());\n\n const months = useMemo(\n () =>\n [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12].map((tempMonth) => ({\n text: formatMonth({ month: tempMonth, locale }),\n value: tempMonth,\n })),\n [locale],\n );\n\n const hasMultipleMonths = useMemo(\n () => differenceInCalendarMonths(maxDate, minDate) > 0,\n [minDate, maxDate],\n );\n\n const years = useMemo(\n () =>\n getYearsBetween(minDate, maxDate).map((tempYear) => ({\n text: tempYear.toString(),\n value: tempYear,\n })),\n [minDate, maxDate],\n );\n\n const hasMultipleYears = useMemo(() => years.length > 1, [years]);\n\n return (\n <>\n {showMonthYearPickers && hasMultipleMonths ? (\n <ComboBox\n onSelect={(selectedItem) => {\n const tempSelectedDate = isDateInRange({\n minDate,\n maxDate,\n currentDate: new Date(\n year,\n (selectedItem.value as number) - 1 - displayIndex,\n 1,\n ),\n });\n\n setCurrentDate(tempSelectedDate);\n }}\n lists={[\n {\n list: months,\n },\n ]}\n selectedItem={{\n text: formatMonth({ month, locale }),\n value: month,\n }}\n placeholder=\"\"\n />\n ) : (\n <StyledMonthName>{formatMonth({ locale, month })}</StyledMonthName>\n )}\n {showMonthYearPickers && hasMultipleYears ? (\n <ComboBox\n onSelect={(selectedItem) => {\n const tempSelectedDate = isDateInRange({\n minDate,\n maxDate,\n currentDate: new Date(\n selectedItem.value as number,\n month - 1 - displayIndex,\n 1,\n ),\n });\n\n setCurrentDate(tempSelectedDate);\n }}\n lists={[\n {\n list: years,\n },\n ]}\n selectedItem={{\n text: year.toString(),\n value: year,\n }}\n placeholder=\"\"\n />\n ) : (\n <StyledMonthName>{currentYear !== year ? year : ''}</StyledMonthName>\n )}\n </>\n );\n};\n\nexport default MonthYearPickers;\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,uBAAA,CAAAH,OAAA;AAEA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAAsE,SAAAM,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAJ,wBAAAI,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,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E,CACH;MACIC,IAAI,EAAExB;IACV,CAAC,CACH;IACFmB,YAAY,EAAE;MACVf,IAAI,EAAE,IAAAC,qBAAW,EAAC;QAAEjB,KAAK;QAAEE;MAAO,CAAC,CAAC;MACpCgB,KAAK,EAAElB;IACX,CAAE;IACFqC,WAAW,EAAC;EAAE,CACjB,CAAC,gBAEFhE,MAAA,CAAAU,OAAA,CAAA4C,aAAA,CAACnD,MAAA,CAAA8D,eAAe,QAAE,IAAArB,qBAAW,EAAC;IAAEf,MAAM;IAAEF;EAAM,CAAC,CAAmB,CACrE,EACAO,oBAAoB,IAAIkB,gBAAgB,gBACrCpD,MAAA,CAAAU,OAAA,CAAA4C,aAAA,CAACzD,KAAA,CAAA2D,QAAQ;IACLC,QAAQ,EAAGC,YAAY,IAAK;MACxB,MAAMC,gBAAgB,GAAG,IAAAC,uBAAa,EAAC;QACnC9B,OAAO;QACPC,OAAO;QACP8B,WAAW,EAAE,IAAIxB,IAAI,CACjBqB,YAAY,CAACb,KAAK,EAClBlB,KAAK,GAAG,CAAC,GAAGM,YAAY,EACxB,CACJ;MACJ,CAAC,CAAC;MAEFD,cAAc,CAAC2B,gBAAgB,CAAC;IACpC,CAAE;IACFG,KAAK,EAAE,CACH;MACIC,IAAI,EAAEf;IACV,CAAC,CACH;IACFU,YAAY,EAAE;MACVf,IAAI,EAAEf,IAAI,CAACuB,QAAQ,CAAC,CAAC;MACrBN,KAAK,EAAEjB;IACX,CAAE;IACFoC,WAAW,EAAC;EAAE,CACjB,CAAC,gBAEFhE,MAAA,CAAAU,OAAA,CAAA4C,aAAA,CAACnD,MAAA,CAAA8D,eAAe,QAAE9B,WAAW,KAAKP,IAAI,GAAGA,IAAI,GAAG,EAAoB,CAE1E,CAAC;AAEX,CAAC;AAAC,IAAAsC,QAAA,GAAAzC,OAAA,CAAAf,OAAA,GAEagB,gBAAgB","ignoreList":[]}
1
+ {"version":3,"file":"MonthYearPickers.js","names":["_core","require","_react","_interopRequireWildcard","_calendar","_Month","_date","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","MonthYearPickerType","exports","MonthYearPickers","month","year","locale","minDate","maxDate","setCurrentDate","displayIndex","showMonthYearPickers","currentYear","useState","Date","getFullYear","months","useMemo","map","tempMonth","text","formatMonth","value","hasMultipleMonths","differenceInCalendarMonths","years","getYearsBetween","tempYear","toString","hasMultipleYears","length","createElement","Fragment","ComboBox","onSelect","selectedItem","tempSelectedDate","isDateInRange","currentDate","lists","list","placeholder","StyledMonthName","_default"],"sources":["../../../../../src/components/calendar/month-year-pickers/MonthYearPickers.tsx"],"sourcesContent":["import { ComboBox } from '@chayns-components/core';\nimport React, { FC, useMemo, useState } from 'react';\nimport { EMonth } from '../../../types/calendar';\nimport { formatMonth, getYearsBetween, isDateInRange } from '../../../utils/calendar';\nimport { StyledMonthName } from '../month-wrapper/month/Month.styles';\nimport {Language} from \"chayns-api\";\nimport {differenceInCalendarMonths} from \"../../../utils/date\";\n\nexport enum MonthYearPickerType {\n Month = 'month',\n Year = 'year',\n}\n\ntype MonthYearPickerProps = {\n month: EMonth;\n year: number;\n locale: Language;\n minDate: Date;\n maxDate: Date;\n setCurrentDate: (date: Date) => void;\n displayIndex?: number;\n showMonthYearPickers: boolean;\n};\n\nconst MonthYearPickers: FC<MonthYearPickerProps> = ({\n month,\n year,\n locale,\n minDate,\n maxDate,\n setCurrentDate,\n displayIndex = 0,\n showMonthYearPickers,\n}) => {\n const [currentYear] = useState(new Date().getFullYear());\n\n const months = useMemo(\n () =>\n [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12].map((tempMonth) => ({\n text: formatMonth({ month: tempMonth, locale }),\n value: tempMonth,\n })),\n [locale],\n );\n\n const hasMultipleMonths = useMemo(\n () => differenceInCalendarMonths(maxDate, minDate) > 0,\n [minDate, maxDate],\n );\n\n const years = useMemo(\n () =>\n getYearsBetween(minDate, maxDate).map((tempYear) => ({\n text: tempYear.toString(),\n value: tempYear,\n })),\n [minDate, maxDate],\n );\n\n const hasMultipleYears = useMemo(() => years.length > 1, [years]);\n\n return (\n <>\n {showMonthYearPickers && hasMultipleMonths ? (\n <ComboBox\n onSelect={(selectedItem) => {\n const tempSelectedDate = isDateInRange({\n minDate,\n maxDate,\n currentDate: new Date(\n year,\n (selectedItem.value as number) - 1 - displayIndex,\n 1,\n ),\n });\n\n setCurrentDate(tempSelectedDate);\n }}\n lists={[\n {\n list: months,\n },\n ]}\n selectedItem={{\n text: formatMonth({ month, locale }),\n value: month,\n }}\n placeholder=\"\"\n />\n ) : (\n <StyledMonthName>{formatMonth({ locale, month })}</StyledMonthName>\n )}\n {showMonthYearPickers && hasMultipleYears ? (\n <ComboBox\n onSelect={(selectedItem) => {\n const tempSelectedDate = isDateInRange({\n minDate,\n maxDate,\n currentDate: new Date(\n selectedItem.value as number,\n month - 1 - displayIndex,\n 1,\n ),\n });\n\n setCurrentDate(tempSelectedDate);\n }}\n lists={[\n {\n list: years,\n },\n ]}\n selectedItem={{\n text: year.toString(),\n value: year,\n }}\n placeholder=\"\"\n />\n ) : (\n <StyledMonthName>{currentYear !== year ? year : ''}</StyledMonthName>\n )}\n </>\n );\n};\n\nexport default MonthYearPickers;\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AAEA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAEA,IAAAK,KAAA,GAAAL,OAAA;AAA+D,SAAAM,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAL,wBAAAK,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,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GA,IAAI,GAAG,EAAoB,CAE1E,CAAC;AAEX,CAAC;AAAC,IAAAsC,QAAA,GAAAzC,OAAA,CAAAf,OAAA,GAEagB,gBAAgB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"DateInfo.js","names":["_react","_interopRequireWildcard","require","_useDateInfo","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","DateInfo","date","preText","shouldShowYear","shouldShowTime","shouldShowRelativeDayOfWeek","shouldUseShortText","shouldShowDayOfWeek","shouldShowDateToNowDifference","formattedDate","useDateInfo","useMemo","createElement","displayName","_default","exports"],"sources":["../../../../src/components/date-info/DateInfo.tsx"],"sourcesContent":["import React, { FC, useMemo } from 'react';\nimport { useDateInfo, type UseDateInfoOptions } from '../../hooks/useDateInfo';\n\nexport type DateInfoProps = UseDateInfoOptions;\n\nconst DateInfo: FC<DateInfoProps> = ({\n date,\n preText = '',\n shouldShowYear,\n shouldShowTime,\n shouldShowRelativeDayOfWeek,\n shouldUseShortText,\n shouldShowDayOfWeek,\n shouldShowDateToNowDifference,\n}) => {\n const formattedDate = useDateInfo({\n date,\n preText,\n shouldShowYear,\n shouldShowTime,\n shouldUseShortText,\n shouldShowDayOfWeek,\n shouldShowRelativeDayOfWeek,\n shouldShowDateToNowDifference,\n });\n\n return useMemo(() => <span>{formattedDate}</span>, [formattedDate]);\n};\n\nDateInfo.displayName = 'DateInfo';\n\nexport default DateInfo;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAA+E,SAAAE,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,S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IAAAG,cAAO,EAAC,mBAAMnC,MAAA,CAAAU,OAAA,CAAA0B,aAAA,eAAOH,aAAoB,CAAC,EAAE,CAACA,aAAa,CAAC,CAAC;AACvE,CAAC;AAEDT,QAAQ,CAACa,WAAW,GAAG,UAAU;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA7B,OAAA,GAEnBc,QAAQ","ignoreList":[]}
1
+ {"version":3,"file":"DateInfo.js","names":["_react","_interopRequireWildcard","require","_useDateInfo","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","DateInfo","date","preText","shouldShowYear","shouldShowTime","shouldShowRelativeDayOfWeek","shouldUseShortText","shouldShowDayOfWeek","shouldShowDateToNowDifference","formattedDate","useDateInfo","useMemo","createElement","displayName","_default","exports"],"sources":["../../../../src/components/date-info/DateInfo.tsx"],"sourcesContent":["import React, { FC, useMemo } from 'react';\nimport { useDateInfo } from '../../hooks/useDateInfo';\nimport { UseDateInfoOptions } from '../../types/dateinfo';\n\nexport type DateInfoProps = UseDateInfoOptions;\n\nconst DateInfo: FC<DateInfoProps> = ({\n date,\n preText = '',\n shouldShowYear,\n shouldShowTime,\n shouldShowRelativeDayOfWeek,\n shouldUseShortText,\n shouldShowDayOfWeek,\n shouldShowDateToNowDifference,\n}) => {\n const formattedDate = useDateInfo({\n date,\n preText,\n shouldShowYear,\n shouldShowTime,\n shouldUseShortText,\n shouldShowDayOfWeek,\n shouldShowRelativeDayOfWeek,\n shouldShowDateToNowDifference,\n });\n\n return useMemo(() => <span>{formattedDate}</span>, [formattedDate]);\n};\n\nDateInfo.displayName = 'DateInfo';\n\nexport default DateInfo;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAAsD,SAAAE,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,I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IACJC,OAAO;IACPC,cAAc;IACdC,cAAc;IACdE,kBAAkB;IAClBC,mBAAmB;IACnBF,2BAA2B;IAC3BG;EACJ,CAAC,CAAC;EAEF,OAAO,IAAAG,cAAO,EAAC,mBAAMnC,MAAA,CAAAU,OAAA,CAAA0B,aAAA,eAAOH,aAAoB,CAAC,EAAE,CAACA,aAAa,CAAC,CAAC;AACvE,CAAC;AAEDT,QAAQ,CAACa,WAAW,GAAG,UAAU;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA7B,OAAA,GAEnBc,QAAQ","ignoreList":[]}
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.useDateInfo = void 0;
7
- var _dateFns = require("date-fns");
7
+ var _chaynsApi = require("chayns-api");
8
8
  var _react = require("react");
9
9
  var _dateInfo = require("../utils/dateInfo");
10
10
  const useDateInfo = ({
@@ -17,92 +17,47 @@ const useDateInfo = ({
17
17
  shouldShowYear,
18
18
  preText
19
19
  }) => {
20
- const [formattedDateString, setFormattedDateString] = (0, _react.useState)('');
21
- const [language] = (0, _react.useState)((0, _dateInfo.getLanguage)());
22
- const formattedDate = (0, _react.useMemo)(() => new Date(date), [date]);
23
- const isDateNearToday = (0, _dateFns.isToday)(date) || (0, _dateFns.isYesterday)(date) || (0, _dateFns.isTomorrow)(date);
20
+ const {
21
+ active: language
22
+ } = (0, _chaynsApi.getLanguage)();
23
+ const [formattedDate, setFormattedDate] = (0, _react.useState)(date.toLocaleDateString());
24
+ const [currentDate, setCurrentDate] = (0, _react.useState)(new Date());
24
25
  (0, _react.useEffect)(() => {
25
- // This useEffect is used for normal date formation
26
26
  if (shouldShowDateToNowDifference) {
27
27
  return;
28
28
  }
29
- let newFormattedDateString = (0, _dateInfo.getFormattedDayOfWeek)({
30
- shouldShowDayOfWeek,
31
- shouldShowRelativeDayOfWeek,
32
- shouldUseShortText,
33
- date: formattedDate,
34
- language
35
- });
36
- if (!isDateNearToday || !shouldShowRelativeDayOfWeek || !shouldShowTime) {
37
- let formatString = 'dd. ';
38
- formatString += `${(0, _dateInfo.getMonthFormat)({
39
- shouldUseShortText
40
- })}`;
41
- formatString += `${(0, _dateInfo.getYearFormat)({
42
- date: formattedDate,
43
- shouldShowYear
44
- })}`;
45
- newFormattedDateString += (0, _dateFns.format)(formattedDate, formatString, {
46
- locale: language
47
- });
48
- } else {
49
- newFormattedDateString = newFormattedDateString.replace(', ', '');
50
- }
51
- newFormattedDateString += (0, _dateInfo.getFormattedTime)({
52
- date: formattedDate,
29
+ setFormattedDate((0, _dateInfo.getDateInfo)({
30
+ date,
31
+ shouldShowYear,
53
32
  shouldShowTime,
54
- language
55
- });
56
- setFormattedDateString(newFormattedDateString);
57
- }, [date, formattedDate, language, shouldShowDateToNowDifference, shouldShowDayOfWeek, shouldShowRelativeDayOfWeek, shouldShowYear, shouldShowTime, shouldUseShortText, isDateNearToday]);
58
-
59
- // Calculate remaining time till next minute to update time according to time left
60
- const [currentDate, setCurrentDate] = (0, _react.useState)(new Date());
33
+ shouldUseShortText,
34
+ shouldShowDayOfWeek,
35
+ shouldShowRelativeDayOfWeek
36
+ }));
37
+ }, [date, shouldShowDateToNowDifference, shouldShowDayOfWeek, shouldShowRelativeDayOfWeek, shouldShowTime, shouldShowYear, shouldUseShortText]);
61
38
  (0, _react.useEffect)(() => {
62
- // This useEffect is for calculating the current date for shouldShowDateToNowDifference option
63
- if (!shouldShowDateToNowDifference) {
64
- return () => {};
65
- }
66
- let timeoutTime = formattedDate.getSeconds() - new Date().getSeconds();
67
-
68
- // If the seconds of date are after seconds of current time, the timeoutTime has to be calculated differently
69
- if (timeoutTime < 0) {
70
- timeoutTime = 60 - new Date().getSeconds() + formattedDate.getSeconds();
71
- }
72
-
73
- // initialized with remaining time
74
- let timeDiffInMs = formattedDate.getTime() - currentDate.getTime();
75
-
76
- // set to elapsed time
77
- if ((0, _dateFns.isPast)(formattedDate)) {
78
- timeDiffInMs = currentDate.getTime() - formattedDate.getTime();
79
- }
80
-
81
- // time difference is less than a minute, time should be updated every second
82
- if (timeDiffInMs < 60000) {
83
- timeoutTime = 1;
84
- }
85
-
86
- // Set timeoutTime to at least 1000ms
87
- timeoutTime = Math.max(timeoutTime * 1000, 1000);
88
- const timeout = setTimeout(() => {
89
- setCurrentDate(new Date());
90
- }, timeoutTime);
39
+ if (!shouldShowDateToNowDifference) return () => {};
40
+ const updateCurrentDate = () => setCurrentDate(new Date());
41
+ const now = new Date();
42
+ const timeDiffInMs = Math.abs(date.getTime() - now.getTime());
43
+ const updateInterval = timeDiffInMs < 60000 ? 1000 : 60000 - now.getSeconds() * 1000;
44
+ const intervalId = setInterval(updateCurrentDate, 1000);
45
+ const timeout = setTimeout(updateCurrentDate, updateInterval);
91
46
  return () => {
92
47
  clearTimeout(timeout);
48
+ clearInterval(intervalId);
93
49
  };
94
- }, [currentDate, date, formattedDate, shouldShowDateToNowDifference]);
50
+ }, [date, shouldShowDateToNowDifference]);
95
51
  (0, _react.useEffect)(() => {
96
- // This useEffect is for showing the difference of the date to now
97
52
  if (shouldShowDateToNowDifference) {
98
- setFormattedDateString((0, _dateInfo.getTimeTillNow)({
99
- date: formattedDate,
53
+ setFormattedDate((0, _dateInfo.getTimeTillNow)({
54
+ date,
100
55
  currentDate,
101
56
  language
102
57
  }));
103
58
  }
104
- }, [currentDate, date, formattedDate, language, shouldShowDateToNowDifference]);
105
- return (0, _react.useMemo)(() => `${preText ? `${preText.trim()} ` : ''}${formattedDateString}`, [formattedDateString, preText]);
59
+ }, [date, currentDate, language, shouldShowDateToNowDifference]);
60
+ return (0, _react.useMemo)(() => `${preText ? `${preText.trim()} ` : ''}${formattedDate}`, [formattedDate, preText]);
106
61
  };
107
62
  exports.useDateInfo = useDateInfo;
108
63
  //# sourceMappingURL=useDateInfo.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDateInfo.js","names":["_dateFns","require","_react","_dateInfo","useDateInfo","date","shouldShowDateToNowDifference","shouldShowRelativeDayOfWeek","shouldShowDayOfWeek","shouldShowTime","shouldUseShortText","shouldShowYear","preText","formattedDateString","setFormattedDateString","useState","language","getLanguage","formattedDate","useMemo","Date","isDateNearToday","isToday","isYesterday","isTomorrow","useEffect","newFormattedDateString","getFormattedDayOfWeek","formatString","getMonthFormat","getYearFormat","format","locale","replace","getFormattedTime","currentDate","setCurrentDate","timeoutTime","getSeconds","timeDiffInMs","getTime","isPast","Math","max","timeout","setTimeout","clearTimeout","getTimeTillNow","trim","exports"],"sources":["../../../src/hooks/useDateInfo.ts"],"sourcesContent":["import { format, isPast, isToday, isTomorrow, isYesterday } from 'date-fns';\nimport { useEffect, useMemo, useState } from 'react';\nimport {\n getFormattedDayOfWeek,\n getFormattedTime,\n getLanguage,\n getMonthFormat,\n getTimeTillNow,\n getYearFormat,\n} from '../utils/dateInfo';\n\nexport interface UseDateInfoOptions {\n /**\n * The date, that should be displayed\n */\n date: Date | string;\n /**\n * Additional text for \"shouldShowDateToNowDifference\" prop. Writes a text before the calculated time\n */\n preText?: string;\n /**\n * Adds the current year to the display\n */\n shouldShowYear?: boolean;\n /**\n * Adds the time to the display.\n */\n shouldShowTime?: boolean;\n /**\n * Whether the relative day of week to today should be shown (today, yesterday or tomorrow).\n */\n shouldShowRelativeDayOfWeek?: boolean;\n /**\n * Shortens the day and month text to maximum three digits\n */\n shouldUseShortText?: boolean;\n /**\n * Adds the day of week to the display\n */\n shouldShowDayOfWeek?: boolean;\n /**\n * Shows the difference from the date to now. The component handles updates itself.\n */\n shouldShowDateToNowDifference?: boolean;\n}\n\nexport const useDateInfo = ({\n date,\n shouldShowDateToNowDifference,\n shouldShowRelativeDayOfWeek,\n shouldShowDayOfWeek,\n shouldShowTime,\n shouldUseShortText,\n shouldShowYear,\n preText,\n}: UseDateInfoOptions) => {\n const [formattedDateString, setFormattedDateString] = useState<string>('');\n const [language] = useState(getLanguage());\n\n const formattedDate = useMemo(() => new Date(date), [date]);\n\n const isDateNearToday = isToday(date) || isYesterday(date) || isTomorrow(date);\n\n useEffect(() => {\n // This useEffect is used for normal date formation\n if (shouldShowDateToNowDifference) {\n return;\n }\n\n let newFormattedDateString = getFormattedDayOfWeek({\n shouldShowDayOfWeek,\n shouldShowRelativeDayOfWeek,\n shouldUseShortText,\n date: formattedDate,\n language,\n });\n\n if (!isDateNearToday || !shouldShowRelativeDayOfWeek || !shouldShowTime) {\n let formatString = 'dd. ';\n\n formatString += `${getMonthFormat({ shouldUseShortText })}`;\n\n formatString += `${getYearFormat({\n date: formattedDate,\n shouldShowYear,\n })}`;\n\n newFormattedDateString += format(formattedDate, formatString, { locale: language });\n } else {\n newFormattedDateString = newFormattedDateString.replace(', ', '');\n }\n\n newFormattedDateString += getFormattedTime({\n date: formattedDate,\n shouldShowTime,\n language,\n });\n\n setFormattedDateString(newFormattedDateString);\n }, [\n date,\n formattedDate,\n language,\n shouldShowDateToNowDifference,\n shouldShowDayOfWeek,\n shouldShowRelativeDayOfWeek,\n shouldShowYear,\n shouldShowTime,\n shouldUseShortText,\n isDateNearToday,\n ]);\n\n // Calculate remaining time till next minute to update time according to time left\n const [currentDate, setCurrentDate] = useState(new Date());\n\n useEffect(() => {\n // This useEffect is for calculating the current date for shouldShowDateToNowDifference option\n if (!shouldShowDateToNowDifference) {\n return () => {};\n }\n\n let timeoutTime = formattedDate.getSeconds() - new Date().getSeconds();\n\n // If the seconds of date are after seconds of current time, the timeoutTime has to be calculated differently\n if (timeoutTime < 0) {\n timeoutTime = 60 - new Date().getSeconds() + formattedDate.getSeconds();\n }\n\n // initialized with remaining time\n let timeDiffInMs = formattedDate.getTime() - currentDate.getTime();\n\n // set to elapsed time\n if (isPast(formattedDate)) {\n timeDiffInMs = currentDate.getTime() - formattedDate.getTime();\n }\n\n // time difference is less than a minute, time should be updated every second\n if (timeDiffInMs < 60000) {\n timeoutTime = 1;\n }\n\n // Set timeoutTime to at least 1000ms\n timeoutTime = Math.max(timeoutTime * 1000, 1000);\n\n const timeout = setTimeout(() => {\n setCurrentDate(new Date());\n }, timeoutTime);\n\n return () => {\n clearTimeout(timeout);\n };\n }, [currentDate, date, formattedDate, shouldShowDateToNowDifference]);\n\n useEffect(() => {\n // This useEffect is for showing the difference of the date to now\n if (shouldShowDateToNowDifference) {\n setFormattedDateString(getTimeTillNow({ date: formattedDate, currentDate, language }));\n }\n }, [currentDate, date, formattedDate, language, shouldShowDateToNowDifference]);\n\n return useMemo(\n () => `${preText ? `${preText.trim()} ` : ''}${formattedDateString}`,\n [formattedDateString, preText],\n );\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AA4CO,MAAMG,WAAW,GAAGA,CAAC;EACxBC,IAAI;EACJC,6BAA6B;EAC7BC,2BAA2B;EAC3BC,mBAAmB;EACnBC,cAAc;EACdC,kBAAkB;EAClBC,cAAc;EACdC;AACgB,CAAC,KAAK;EACtB,MAAM,CAACC,mBAAmB,EAAEC,sBAAsB,CAAC,GAAG,IAAAC,eAAQ,EAAS,EAAE,CAAC;EAC1E,MAAM,CAACC,QAAQ,CAAC,GAAG,IAAAD,eAAQ,EAAC,IAAAE,qBAAW,EAAC,CAAC,CAAC;EAE1C,MAAMC,aAAa,GAAG,IAAAC,cAAO,EAAC,MAAM,IAAIC,IAAI,CAACf,IAAI,CAAC,EAAE,CAACA,IAAI,CAAC,CAAC;EAE3D,MAAMgB,eAAe,GAAG,IAAAC,gBAAO,EAACjB,IAAI,CAAC,IAAI,IAAAkB,oBAAW,EAAClB,IAAI,CAAC,IAAI,IAAAmB,mBAAU,EAACnB,IAAI,CAAC;EAE9E,IAAAoB,gBAAS,EAAC,MAAM;IACZ;IACA,IAAInB,6BAA6B,EAAE;MAC/B;IACJ;IAEA,IAAIoB,sBAAsB,GAAG,IAAAC,+BAAqB,EAAC;MAC/CnB,mBAAmB;MACnBD,2BAA2B;MAC3BG,kBAAkB;MAClBL,IAAI,EAAEa,aAAa;MACnBF;IACJ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,mBAAmB,EAAED,OAAO,CACjC,CAAC;AACL,CAAC;AAACqC,OAAA,CAAA7C,WAAA,GAAAA,WAAA","ignoreList":[]}
1
+ {"version":3,"file":"useDateInfo.js","names":["_chaynsApi","require","_react","_dateInfo","useDateInfo","date","shouldShowDateToNowDifference","shouldShowRelativeDayOfWeek","shouldShowDayOfWeek","shouldShowTime","shouldUseShortText","shouldShowYear","preText","active","language","getLanguage","formattedDate","setFormattedDate","useState","toLocaleDateString","currentDate","setCurrentDate","Date","useEffect","getDateInfo","updateCurrentDate","now","timeDiffInMs","Math","abs","getTime","updateInterval","getSeconds","intervalId","setInterval","timeout","setTimeout","clearTimeout","clearInterval","getTimeTillNow","useMemo","trim","exports"],"sources":["../../../src/hooks/useDateInfo.ts"],"sourcesContent":["import { getLanguage } from 'chayns-api';\nimport { useEffect, useMemo, useState } from 'react';\nimport { UseDateInfoOptions } from '../types/dateinfo';\nimport { getDateInfo, getTimeTillNow } from '../utils/dateInfo';\n\nexport const useDateInfo = ({\n date,\n shouldShowDateToNowDifference,\n shouldShowRelativeDayOfWeek,\n shouldShowDayOfWeek,\n shouldShowTime,\n shouldUseShortText,\n shouldShowYear,\n preText,\n}: UseDateInfoOptions) => {\n const { active: language } = getLanguage();\n\n const [formattedDate, setFormattedDate] = useState(date.toLocaleDateString());\n const [currentDate, setCurrentDate] = useState(new Date());\n\n useEffect(() => {\n if (shouldShowDateToNowDifference) {\n return;\n }\n\n setFormattedDate(\n getDateInfo({\n date,\n shouldShowYear,\n shouldShowTime,\n shouldUseShortText,\n shouldShowDayOfWeek,\n shouldShowRelativeDayOfWeek,\n }),\n );\n }, [\n date,\n shouldShowDateToNowDifference,\n shouldShowDayOfWeek,\n shouldShowRelativeDayOfWeek,\n shouldShowTime,\n shouldShowYear,\n shouldUseShortText,\n ]);\n\n useEffect(() => {\n if (!shouldShowDateToNowDifference) return () => {};\n\n const updateCurrentDate = () => setCurrentDate(new Date());\n const now = new Date();\n const timeDiffInMs = Math.abs(date.getTime() - now.getTime());\n\n const updateInterval = timeDiffInMs < 60000 ? 1000 : 60000 - now.getSeconds() * 1000;\n\n const intervalId = setInterval(updateCurrentDate, 1000);\n const timeout = setTimeout(updateCurrentDate, updateInterval);\n\n return () => {\n clearTimeout(timeout);\n clearInterval(intervalId);\n };\n }, [date, shouldShowDateToNowDifference]);\n\n useEffect(() => {\n if (shouldShowDateToNowDifference) {\n setFormattedDate(getTimeTillNow({ date, currentDate, language }));\n }\n }, [date, currentDate, language, shouldShowDateToNowDifference]);\n\n return useMemo(\n () => `${preText ? `${preText.trim()} ` : ''}${formattedDate}`,\n [formattedDate, preText],\n );\n};\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,SAAA,GAAAF,OAAA;AAEO,MAAMG,WAAW,GAAGA,CAAC;EACxBC,IAAI;EACJC,6BAA6B;EAC7BC,2BAA2B;EAC3BC,mBAAmB;EACnBC,cAAc;EACdC,kBAAkB;EAClBC,cAAc;EACdC;AACgB,CAAC,KAAK;EACtB,MAAM;IAAEC,MAAM,EAAEC;EAAS,CAAC,GAAG,IAAAC,sBAAW,EAAC,CAAC;EAE1C,MAAM,CAACC,aAAa,EAAEC,gBAAgB,CAAC,GAAG,IAAAC,eAAQ,EAACb,IAAI,CAACc,kBAAkB,CAAC,CAAC,CAAC;EAC7E,MAAM,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAG,IAAAH,eAAQ,EAAC,IAAII,IAAI,CAAC,CAAC,CAAC;EAE1D,IAAAC,gBAAS,EAAC,MAAM;IACZ,IAAIjB,6BAA6B,EAAE;MAC/B;IACJ;IAEAW,gBAAgB,CACZ,IAAAO,qBAAW,EAAC;MACRnB,IAAI;MACJM,cAAc;MACdF,cAAc;MACdC,kBAAkB;MAClBF,mBAAmB;MACnBD;IACJ,CAAC,CACL,CAAC;EACL,CAAC,EAAE,CACCF,IAAI,EACJC,6BAA6B,EAC7BE,mBAAm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C9D,CAACA,aAAa,EAAEJ,OAAO,CAC3B,CAAC;AACL,CAAC;AAAC8B,OAAA,CAAAtC,WAAA,GAAAA,WAAA","ignoreList":[]}
package/lib/cjs/index.js CHANGED
@@ -33,6 +33,132 @@ Object.defineProperty(exports, "OpeningTimes", {
33
33
  return _OpeningTimes.default;
34
34
  }
35
35
  });
36
+ Object.defineProperty(exports, "addDays", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _date.addDays;
40
+ }
41
+ });
42
+ Object.defineProperty(exports, "addYears", {
43
+ enumerable: true,
44
+ get: function () {
45
+ return _date.addYears;
46
+ }
47
+ });
48
+ Object.defineProperty(exports, "differenceInCalendarMonths", {
49
+ enumerable: true,
50
+ get: function () {
51
+ return _date.differenceInCalendarMonths;
52
+ }
53
+ });
54
+ Object.defineProperty(exports, "eachDayOfInterval", {
55
+ enumerable: true,
56
+ get: function () {
57
+ return _date.eachDayOfInterval;
58
+ }
59
+ });
60
+ Object.defineProperty(exports, "endOfWeek", {
61
+ enumerable: true,
62
+ get: function () {
63
+ return _date.endOfWeek;
64
+ }
65
+ });
66
+ Object.defineProperty(exports, "getDateInfo", {
67
+ enumerable: true,
68
+ get: function () {
69
+ return _dateInfo.getDateInfo;
70
+ }
71
+ });
72
+ Object.defineProperty(exports, "getIsDateNearToday", {
73
+ enumerable: true,
74
+ get: function () {
75
+ return _date.getIsDateNearToday;
76
+ }
77
+ });
78
+ Object.defineProperty(exports, "getTimeTillNow", {
79
+ enumerable: true,
80
+ get: function () {
81
+ return _dateInfo.getTimeTillNow;
82
+ }
83
+ });
84
+ Object.defineProperty(exports, "isAfter", {
85
+ enumerable: true,
86
+ get: function () {
87
+ return _date.isAfter;
88
+ }
89
+ });
90
+ Object.defineProperty(exports, "isBefore", {
91
+ enumerable: true,
92
+ get: function () {
93
+ return _date.isBefore;
94
+ }
95
+ });
96
+ Object.defineProperty(exports, "isCurrentYear", {
97
+ enumerable: true,
98
+ get: function () {
99
+ return _date.isCurrentYear;
100
+ }
101
+ });
102
+ Object.defineProperty(exports, "isMorning", {
103
+ enumerable: true,
104
+ get: function () {
105
+ return _date.isMorning;
106
+ }
107
+ });
108
+ Object.defineProperty(exports, "isSameDay", {
109
+ enumerable: true,
110
+ get: function () {
111
+ return _date.isSameDay;
112
+ }
113
+ });
114
+ Object.defineProperty(exports, "isSameMonth", {
115
+ enumerable: true,
116
+ get: function () {
117
+ return _date.isSameMonth;
118
+ }
119
+ });
120
+ Object.defineProperty(exports, "isToday", {
121
+ enumerable: true,
122
+ get: function () {
123
+ return _date.isToday;
124
+ }
125
+ });
126
+ Object.defineProperty(exports, "isTomorrow", {
127
+ enumerable: true,
128
+ get: function () {
129
+ return _date.isTomorrow;
130
+ }
131
+ });
132
+ Object.defineProperty(exports, "isWithinInterval", {
133
+ enumerable: true,
134
+ get: function () {
135
+ return _date.isWithinInterval;
136
+ }
137
+ });
138
+ Object.defineProperty(exports, "isYesterday", {
139
+ enumerable: true,
140
+ get: function () {
141
+ return _date.isYesterday;
142
+ }
143
+ });
144
+ Object.defineProperty(exports, "startOfMonth", {
145
+ enumerable: true,
146
+ get: function () {
147
+ return _date.startOfMonth;
148
+ }
149
+ });
150
+ Object.defineProperty(exports, "startOfWeek", {
151
+ enumerable: true,
152
+ get: function () {
153
+ return _date.startOfWeek;
154
+ }
155
+ });
156
+ Object.defineProperty(exports, "subYears", {
157
+ enumerable: true,
158
+ get: function () {
159
+ return _date.subYears;
160
+ }
161
+ });
36
162
  Object.defineProperty(exports, "useDateInfo", {
37
163
  enumerable: true,
38
164
  get: function () {
@@ -40,10 +166,12 @@ Object.defineProperty(exports, "useDateInfo", {
40
166
  }
41
167
  });
42
168
  var _Calendar = _interopRequireDefault(require("./components/calendar/Calendar"));
43
- var _DateInfo = _interopRequireDefault(require("./components/date-info/DateInfo"));
169
+ var _calendar = require("./types/calendar");
44
170
  var _OpeningInputs = _interopRequireDefault(require("./components/opening-times/opening-inputs/OpeningInputs"));
45
171
  var _OpeningTimes = _interopRequireDefault(require("./components/opening-times/OpeningTimes"));
172
+ var _DateInfo = _interopRequireDefault(require("./components/date-info/DateInfo"));
46
173
  var _useDateInfo = require("./hooks/useDateInfo");
47
- var _calendar = require("./types/calendar");
174
+ var _dateInfo = require("./utils/dateInfo");
175
+ var _date = require("./utils/date");
48
176
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
49
177
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_Calendar","_interopRequireDefault","require","_DateInfo","_OpeningInputs","_OpeningTimes","_useDateInfo","_calendar","e","__esModule","default"],"sources":["../../src/index.ts"],"sourcesContent":["export { default as Calendar } from './components/calendar/Calendar';\nexport { default as DateInfo } from './components/date-info/DateInfo';\nexport { default as OpeningInputs } from './components/opening-times/opening-inputs/OpeningInputs';\nexport { default as OpeningTimes } from './components/opening-times/OpeningTimes';\nexport { useDateInfo } from './hooks/useDateInfo';\nexport type { Categories, HighlightedDates, HighlightedDateStyles, CustomThumbColors } from './types/calendar';\nexport { CalendarType } from './types/calendar';\nexport type { HintTextPosition, OpeningTime, Time, Weekday } from './types/openingTimes';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,cAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,aAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AAEA,IAAAK,SAAA,GAAAL,OAAA;AAAgD,SAAAD,uBAAAO,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_Calendar","_interopRequireDefault","require","_calendar","_OpeningInputs","_OpeningTimes","_DateInfo","_useDateInfo","_dateInfo","_date","e","__esModule","default"],"sources":["../../src/index.ts"],"sourcesContent":["// Calendar\nexport {default as Calendar} from './components/calendar/Calendar';\nexport type {Categories, HighlightedDates, HighlightedDateStyles, DateInterval, CustomThumbColors} from './types/calendar';\nexport {CalendarType} from './types/calendar';\n\n// OpeningTimes\nexport {default as OpeningInputs} from './components/opening-times/opening-inputs/OpeningInputs';\nexport {default as OpeningTimes} from './components/opening-times/OpeningTimes';\nexport type {HintTextPosition, OpeningTime, Time, Weekday} from './types/openingTimes';\n\n// DateInfo\nexport {default as DateInfo} from './components/date-info/DateInfo';\nexport {useDateInfo} from './hooks/useDateInfo';\nexport {getDateInfo, getTimeTillNow} from './utils/dateInfo'\n\n// Utils\nexport {\n isToday,\n getIsDateNearToday,\n isTomorrow,\n isYesterday,\n isMorning,\n isCurrentYear,\n addYears,\n addDays,\n isSameDay,\n eachDayOfInterval,\n isWithinInterval,\n subYears,\n endOfWeek,\n startOfWeek,\n isSameMonth,\n differenceInCalendarMonths,\n startOfMonth,\n isAfter,\n isBefore\n} from './utils/date'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAD,OAAA;AAGA,IAAAE,cAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,aAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAIA,IAAAI,SAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AAGA,IAAAO,KAAA,GAAAP,OAAA;AAoBqB,SAAAD,uBAAAS,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=dateinfo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dateinfo.js","names":[],"sources":["../../../src/types/dateinfo.ts"],"sourcesContent":["export interface UseDateInfoOptions {\n /**\n * The date, that should be displayed\n */\n date: Date;\n /**\n * Additional text for \"shouldShowDateToNowDifference\" prop. Writes a text before the calculated time\n */\n preText?: string;\n /**\n * Adds the current year to the display\n */\n shouldShowYear?: boolean;\n /**\n * Adds the time to the display.\n */\n shouldShowTime?: boolean;\n /**\n * Whether the relative day of week to today should be shown (today, yesterday or tomorrow).\n */\n shouldShowRelativeDayOfWeek?: boolean;\n /**\n * Shortens the day and month text to maximum three digits\n */\n shouldUseShortText?: boolean;\n /**\n * Adds the day of week to the display\n */\n shouldShowDayOfWeek?: boolean;\n /**\n * Shows the difference from the date to now. The component handles updates itself.\n */\n shouldShowDateToNowDifference?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.isDateInRange = exports.getYearsBetween = exports.getNewDate = exports.getMonthAndYear = exports.formatMonth = exports.findNextDate = void 0;
7
- var _dateFns = require("date-fns");
7
+ var _date = require("./date");
8
8
  const getMonthAndYear = date => {
9
9
  const month = date.getMonth() + 1;
10
10
  const year = date.getFullYear();
@@ -19,13 +19,13 @@ const isDateInRange = ({
19
19
  maxDate,
20
20
  currentDate
21
21
  }) => {
22
- const monthStartOfCurrentDate = (0, _dateFns.startOfMonth)(currentDate);
23
- const monthStartOfMaxDate = (0, _dateFns.startOfMonth)(maxDate);
24
- const monthStartOfMinDate = (0, _dateFns.startOfMonth)(minDate);
22
+ const monthStartOfCurrentDate = (0, _date.startOfMonth)(currentDate);
23
+ const monthStartOfMaxDate = (0, _date.startOfMonth)(maxDate);
24
+ const monthStartOfMinDate = (0, _date.startOfMonth)(minDate);
25
25
  switch (true) {
26
- case (0, _dateFns.isAfter)(monthStartOfCurrentDate, monthStartOfMaxDate):
26
+ case (0, _date.isAfter)(monthStartOfCurrentDate, monthStartOfMaxDate):
27
27
  return monthStartOfMaxDate;
28
- case (0, _dateFns.isBefore)(monthStartOfCurrentDate, monthStartOfMinDate):
28
+ case (0, _date.isBefore)(monthStartOfCurrentDate, monthStartOfMinDate):
29
29
  return monthStartOfMinDate;
30
30
  default:
31
31
  return monthStartOfCurrentDate;
@@ -47,9 +47,12 @@ exports.getNewDate = getNewDate;
47
47
  const formatMonth = ({
48
48
  month,
49
49
  locale
50
- }) => (0, _dateFns.format)(new Date(2022, month - 1, 1), 'MMMM', {
51
- locale
52
- });
50
+ }) => {
51
+ const date = new Date(2022, month - 1, 1);
52
+ return date.toLocaleString(locale, {
53
+ month: 'long'
54
+ });
55
+ };
53
56
  exports.formatMonth = formatMonth;
54
57
  const findNextDate = (date, dateArray) => {
55
58
  const futureDates = dateArray.filter(d => d > date);