@chayns-components/date 5.0.0-beta.998 → 5.0.0

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 (130) hide show
  1. package/lib/cjs/components/calendar/Calendar.js +9 -22
  2. package/lib/cjs/components/calendar/Calendar.js.map +1 -1
  3. package/lib/cjs/components/calendar/Calendar.styles.js +7 -1
  4. package/lib/cjs/components/calendar/Calendar.styles.js.map +1 -1
  5. package/lib/cjs/components/calendar/month-wrapper/MonthWrapper.js +9 -4
  6. package/lib/cjs/components/calendar/month-wrapper/MonthWrapper.js.map +1 -1
  7. package/lib/cjs/components/calendar/month-wrapper/MonthWrapper.styles.js +2 -2
  8. package/lib/cjs/components/calendar/month-wrapper/MonthWrapper.styles.js.map +1 -1
  9. package/lib/cjs/components/calendar/month-wrapper/month/Month.js +64 -32
  10. package/lib/cjs/components/calendar/month-wrapper/month/Month.js.map +1 -1
  11. package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.js +5 -4
  12. package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.js.map +1 -1
  13. package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/day/Day.js +7 -4
  14. package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/day/Day.js.map +1 -1
  15. package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/day/Day.styles.js +17 -3
  16. package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/day/Day.styles.js.map +1 -1
  17. package/lib/cjs/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.js +1 -2
  18. package/lib/cjs/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.js.map +1 -1
  19. package/lib/cjs/components/calendar/month-year-pickers/MonthYearPickers.js +4 -3
  20. package/lib/cjs/components/calendar/month-year-pickers/MonthYearPickers.js.map +1 -1
  21. package/lib/cjs/components/date-info/DateInfo.js +4 -3
  22. package/lib/cjs/components/date-info/DateInfo.js.map +1 -1
  23. package/lib/cjs/components/opening-times/OpeningTimes.js +12 -15
  24. package/lib/cjs/components/opening-times/OpeningTimes.js.map +1 -1
  25. package/lib/cjs/components/opening-times/hint-text/HintText.js +1 -2
  26. package/lib/cjs/components/opening-times/hint-text/HintText.js.map +1 -1
  27. package/lib/cjs/components/opening-times/opening-inputs/OpeningInputs.js +16 -17
  28. package/lib/cjs/components/opening-times/opening-inputs/OpeningInputs.js.map +1 -1
  29. package/lib/cjs/components/opening-times/opening-inputs/OpeningInputs.styles.js +3 -4
  30. package/lib/cjs/components/opening-times/opening-inputs/OpeningInputs.styles.js.map +1 -1
  31. package/lib/cjs/components/opening-times/opening-inputs/opening-input/OpeningInput.js +1 -2
  32. package/lib/cjs/components/opening-times/opening-inputs/opening-input/OpeningInput.js.map +1 -1
  33. package/lib/cjs/components/opening-times/opening-inputs/opening-input/OpeningInput.styles.js +2 -2
  34. package/lib/cjs/components/opening-times/opening-inputs/opening-input/OpeningInput.styles.js.map +1 -1
  35. package/lib/cjs/hooks/useDateInfo.js +3 -1
  36. package/lib/cjs/hooks/useDateInfo.js.map +1 -1
  37. package/lib/cjs/index.js +6 -0
  38. package/lib/cjs/index.js.map +1 -1
  39. package/lib/cjs/types/calendar.js.map +1 -1
  40. package/lib/cjs/types/dateinfo.js +4 -0
  41. package/lib/cjs/types/dateinfo.js.map +1 -1
  42. package/lib/cjs/types/openingTimes.js.map +1 -1
  43. package/lib/cjs/utils/calendar.js.map +1 -1
  44. package/lib/cjs/utils/date.js.map +1 -1
  45. package/lib/cjs/utils/dateInfo.js +52 -28
  46. package/lib/cjs/utils/dateInfo.js.map +1 -1
  47. package/lib/esm/components/calendar/Calendar.js +26 -39
  48. package/lib/esm/components/calendar/Calendar.js.map +1 -1
  49. package/lib/esm/components/calendar/Calendar.styles.js +12 -12
  50. package/lib/esm/components/calendar/Calendar.styles.js.map +1 -1
  51. package/lib/esm/components/calendar/month-wrapper/MonthWrapper.js +28 -23
  52. package/lib/esm/components/calendar/month-wrapper/MonthWrapper.js.map +1 -1
  53. package/lib/esm/components/calendar/month-wrapper/MonthWrapper.styles.js +7 -13
  54. package/lib/esm/components/calendar/month-wrapper/MonthWrapper.styles.js.map +1 -1
  55. package/lib/esm/components/calendar/month-wrapper/month/Month.js +51 -25
  56. package/lib/esm/components/calendar/month-wrapper/month/Month.js.map +1 -1
  57. package/lib/esm/components/calendar/month-wrapper/month/Month.styles.js +3 -6
  58. package/lib/esm/components/calendar/month-wrapper/month/Month.styles.js.map +1 -1
  59. package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.js +20 -19
  60. package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.js.map +1 -1
  61. package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/Day.js +22 -19
  62. package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/Day.js.map +1 -1
  63. package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/Day.styles.js +51 -53
  64. package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/Day.styles.js.map +1 -1
  65. package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/category/Category.js +5 -8
  66. package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/category/Category.js.map +1 -1
  67. package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/category/Category.styles.js +3 -6
  68. package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/category/Category.styles.js.map +1 -1
  69. package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.js +4 -5
  70. package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.js.map +1 -1
  71. package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.js +3 -6
  72. package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.js.map +1 -1
  73. package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.styles.js +3 -6
  74. package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.styles.js.map +1 -1
  75. package/lib/esm/components/calendar/month-year-pickers/MonthYearPickers.js +13 -12
  76. package/lib/esm/components/calendar/month-year-pickers/MonthYearPickers.js.map +1 -1
  77. package/lib/esm/components/date-info/DateInfo.js +12 -11
  78. package/lib/esm/components/date-info/DateInfo.js.map +1 -1
  79. package/lib/esm/components/opening-times/OpeningTimes.js +34 -44
  80. package/lib/esm/components/opening-times/OpeningTimes.js.map +1 -1
  81. package/lib/esm/components/opening-times/OpeningTimes.styles.js +3 -6
  82. package/lib/esm/components/opening-times/OpeningTimes.styles.js.map +1 -1
  83. package/lib/esm/components/opening-times/hint-text/HintText.js +3 -4
  84. package/lib/esm/components/opening-times/hint-text/HintText.js.map +1 -1
  85. package/lib/esm/components/opening-times/hint-text/HintText.styles.js +6 -12
  86. package/lib/esm/components/opening-times/hint-text/HintText.styles.js.map +1 -1
  87. package/lib/esm/components/opening-times/opening-inputs/OpeningInputs.js +21 -26
  88. package/lib/esm/components/opening-times/opening-inputs/OpeningInputs.js.map +1 -1
  89. package/lib/esm/components/opening-times/opening-inputs/OpeningInputs.styles.js +8 -14
  90. package/lib/esm/components/opening-times/opening-inputs/OpeningInputs.styles.js.map +1 -1
  91. package/lib/esm/components/opening-times/opening-inputs/opening-input/OpeningInput.js +11 -12
  92. package/lib/esm/components/opening-times/opening-inputs/opening-input/OpeningInput.js.map +1 -1
  93. package/lib/esm/components/opening-times/opening-inputs/opening-input/OpeningInput.styles.js +7 -13
  94. package/lib/esm/components/opening-times/opening-inputs/opening-input/OpeningInput.styles.js.map +1 -1
  95. package/lib/esm/hooks/useDateInfo.js +13 -12
  96. package/lib/esm/hooks/useDateInfo.js.map +1 -1
  97. package/lib/esm/index.js +1 -1
  98. package/lib/esm/index.js.map +1 -1
  99. package/lib/esm/types/calendar.js.map +1 -1
  100. package/lib/esm/types/dateinfo.js +1 -1
  101. package/lib/esm/types/dateinfo.js.map +1 -1
  102. package/lib/esm/types/openingTimes.js.map +1 -1
  103. package/lib/esm/utils/calendar.js +10 -12
  104. package/lib/esm/utils/calendar.js.map +1 -1
  105. package/lib/esm/utils/date.js.map +1 -1
  106. package/lib/esm/utils/dateInfo.js +65 -45
  107. package/lib/esm/utils/dateInfo.js.map +1 -1
  108. package/lib/types/components/calendar/Calendar.d.ts +5 -1
  109. package/lib/types/components/calendar/Calendar.styles.d.ts +1 -0
  110. package/lib/types/components/calendar/month-wrapper/MonthWrapper.d.ts +5 -2
  111. package/lib/types/components/calendar/month-wrapper/MonthWrapper.styles.d.ts +2 -263
  112. package/lib/types/components/calendar/month-wrapper/month/Month.d.ts +5 -2
  113. package/lib/types/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.d.ts +2 -1
  114. package/lib/types/components/calendar/month-wrapper/month/day-wrapper/day/Day.d.ts +2 -1
  115. package/lib/types/components/calendar/month-wrapper/month/day-wrapper/day/Day.styles.d.ts +5 -1
  116. package/lib/types/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.d.ts +1 -1
  117. package/lib/types/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.styles.d.ts +1 -1
  118. package/lib/types/components/calendar/month-year-pickers/MonthYearPickers.d.ts +1 -1
  119. package/lib/types/components/opening-times/OpeningTimes.d.ts +2 -6
  120. package/lib/types/components/opening-times/OpeningTimes.styles.d.ts +1 -1
  121. package/lib/types/components/opening-times/hint-text/HintText.styles.d.ts +1 -1
  122. package/lib/types/components/opening-times/opening-inputs/OpeningInputs.styles.d.ts +3 -264
  123. package/lib/types/components/opening-times/opening-inputs/opening-input/OpeningInput.styles.d.ts +2 -263
  124. package/lib/types/hooks/useDateInfo.d.ts +1 -1
  125. package/lib/types/index.d.ts +3 -3
  126. package/lib/types/types/dateinfo.d.ts +14 -5
  127. package/lib/types/types/openingTimes.d.ts +2 -0
  128. package/lib/types/utils/calendar.d.ts +1 -1
  129. package/lib/types/utils/dateInfo.d.ts +6 -1
  130. package/package.json +18 -17
@@ -1 +1 @@
1
- {"version":3,"file":"calendar.js","names":["EMonth","CalendarType"],"sources":["../../../src/types/calendar.ts"],"sourcesContent":["import type { CSSProperties } from 'react';\n\nexport interface HighlightedDates {\n dates: Date[];\n style: HighlightedDateStyles;\n}\n\nexport interface HighlightedDateStyles {\n backgroundColor: CSSProperties['backgroundColor'];\n textColor: CSSProperties['color'];\n}\n\nexport interface Categories {\n id: string;\n dates: Date[];\n color: CSSProperties['color'];\n}\n\nexport interface IMonth {\n month: EMonth;\n year: number;\n}\n\nexport interface CustomThumbColors {\n /**\n * The background color of the main thumbs (single, multi, interval)\n */\n mainBackgroundColor?: CSSProperties['color'];\n /**\n * The text color of the main thumbs (single, multi, interval)\n */\n mainTextColor?: CSSProperties['color'];\n /**\n * The background color of the middle part of the interval thumb\n */\n secondaryBackgroundColor?: CSSProperties['color'];\n\n}\n\nexport enum EMonth {\n January = 1,\n February,\n March,\n April,\n May,\n June,\n July,\n August,\n September,\n October,\n November,\n December,\n}\n\nexport enum CalendarType {\n Single = 'single',\n Multiple = 'multiple',\n Interval = 'interval',\n}\n\nexport type DateInterval = {\n start: Date;\n end?: Date;\n};\n"],"mappings":"AAuCA,WAAYA,MAAM,0BAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAAA,OAANA,MAAM;AAAA;AAelB,WAAYC,YAAY,0BAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAA,OAAZA,YAAY;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"calendar.js","names":["EMonth","CalendarType"],"sources":["../../../src/types/calendar.ts"],"sourcesContent":["import type { CSSProperties } from 'react';\n\nexport interface HighlightedDates {\n dates: Date[];\n style: HighlightedDateStyles;\n}\n\nexport interface HighlightedDateStyles {\n backgroundColor: CSSProperties['backgroundColor'];\n textColor: CSSProperties['color'];\n}\n\nexport interface Categories {\n id: string;\n dates: Date[];\n color: CSSProperties['color'];\n}\n\nexport interface IMonth {\n month: EMonth;\n year: number;\n}\n\nexport interface CustomThumbColors {\n /**\n * The background color of the main thumbs (single, multi, interval)\n */\n mainBackgroundColor?: CSSProperties['color'];\n /**\n * The text color of the main thumbs (single, multi, interval)\n */\n mainTextColor?: CSSProperties['color'];\n /**\n * The background color of the middle part of the interval thumb\n */\n secondaryBackgroundColor?: CSSProperties['color'];\n}\n\nexport enum EMonth {\n January = 1,\n February,\n March,\n April,\n May,\n June,\n July,\n August,\n September,\n October,\n November,\n December,\n}\n\nexport enum CalendarType {\n Single = 'single',\n Multiple = 'multiple',\n Interval = 'interval',\n}\n\nexport type DateInterval = {\n start: Date;\n end?: Date;\n};\n"],"mappings":"AAsCA,WAAYA,MAAM,0BAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAAA,OAANA,MAAM;AAAA;AAelB,WAAYC,YAAY,0BAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAA,OAAZA,YAAY;AAAA","ignoreList":[]}
@@ -1,2 +1,2 @@
1
-
1
+ export {};
2
2
  //# sourceMappingURL=dateinfo.js.map
@@ -1 +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":[]}
1
+ {"version":3,"file":"dateinfo.js","names":[],"sources":["../../../src/types/dateinfo.ts"],"sourcesContent":["import type { Language } from 'chayns-api';\n\nexport interface UseDateInfoOptions {\n /**\n * The date that should be displayed\n */\n date: Date;\n /**\n * The language that should be used for the date. Defaults to the active language given by chayns api.\n */\n language?: Language;\n /**\n * Additional text for the \"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 the week to today should be shown (today, yesterday or tomorrow).\n */\n shouldShowRelativeDayOfWeek?: boolean;\n /**\n * Shortens the day and month text to the maximum three digits\n */\n shouldUseShortText?: boolean;\n /**\n * Adds the day of the 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 * Whether only the time should be displayed.\n */\n shouldShowOnlyTime?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"openingTimes.js","names":["OpeningTimesButtonType","HintTextPosition"],"sources":["../../../src/types/openingTimes.ts"],"sourcesContent":["export interface Weekday {\n name: string;\n id: number;\n}\n\nexport interface Time {\n id: string;\n start: string;\n end: string;\n}\n\nexport interface OpeningTime {\n weekdayId: Weekday['id'];\n id: string;\n isDisabled?: boolean;\n times: Time[];\n}\n\nexport interface OnTimeAdd {\n dayId: OpeningTime['id'];\n time: Time;\n}\n\nexport interface OnChange {\n enabledDays?: OpeningTime['id'][];\n dayId?: OpeningTime['id'];\n time?: Time;\n}\n\nexport enum OpeningTimesButtonType {\n NONE,\n ADD,\n REMOVE,\n}\n\nexport enum HintTextPosition {\n Top,\n Bottom,\n}\n"],"mappings":"AA6BA,WAAYA,sBAAsB,0BAAtBA,sBAAsB;EAAtBA,sBAAsB,CAAtBA,sBAAsB;EAAtBA,sBAAsB,CAAtBA,sBAAsB;EAAtBA,sBAAsB,CAAtBA,sBAAsB;EAAA,OAAtBA,sBAAsB;AAAA;AAMlC,WAAYC,gBAAgB,0BAAhBA,gBAAgB;EAAhBA,gBAAgB,CAAhBA,gBAAgB;EAAhBA,gBAAgB,CAAhBA,gBAAgB;EAAA,OAAhBA,gBAAgB;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"openingTimes.js","names":["OpeningTimesButtonType","HintTextPosition"],"sources":["../../../src/types/openingTimes.ts"],"sourcesContent":["export interface Weekday {\n name: string;\n id: number;\n}\n\nexport interface Time {\n id: string;\n start: string;\n end: string;\n}\n\nexport interface OpeningTime {\n weekdayId: Weekday['id'];\n id: string;\n isDisabled?: boolean;\n times: Time[];\n}\n\nexport interface OnTimeAdd {\n dayId: OpeningTime['id'];\n time: Time;\n isValid: boolean;\n}\n\nexport interface OnChange {\n enabledDays?: OpeningTime['id'][];\n dayId?: OpeningTime['id'];\n time?: Time;\n isValid?: boolean;\n}\n\nexport enum OpeningTimesButtonType {\n NONE,\n ADD,\n REMOVE,\n}\n\nexport enum HintTextPosition {\n Top,\n Bottom,\n}\n"],"mappings":"AA+BA,WAAYA,sBAAsB,0BAAtBA,sBAAsB;EAAtBA,sBAAsB,CAAtBA,sBAAsB;EAAtBA,sBAAsB,CAAtBA,sBAAsB;EAAtBA,sBAAsB,CAAtBA,sBAAsB;EAAA,OAAtBA,sBAAsB;AAAA;AAMlC,WAAYC,gBAAgB,0BAAhBA,gBAAgB;EAAhBA,gBAAgB,CAAhBA,gBAAgB;EAAhBA,gBAAgB,CAAhBA,gBAAgB;EAAA,OAAhBA,gBAAgB;AAAA","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { isAfter, isBefore, startOfMonth } from "./date";
1
+ import { isAfter, isBefore, startOfMonth } from './date';
2
2
  export const getMonthAndYear = date => {
3
3
  const month = date.getMonth() + 1;
4
4
  const year = date.getFullYear();
@@ -7,12 +7,11 @@ export const getMonthAndYear = date => {
7
7
  year
8
8
  };
9
9
  };
10
- export const isDateInRange = _ref => {
11
- let {
12
- minDate,
13
- maxDate,
14
- currentDate
15
- } = _ref;
10
+ export const isDateInRange = ({
11
+ minDate,
12
+ maxDate,
13
+ currentDate
14
+ }) => {
16
15
  const monthStartOfCurrentDate = startOfMonth(currentDate);
17
16
  const monthStartOfMaxDate = startOfMonth(maxDate);
18
17
  const monthStartOfMinDate = startOfMonth(minDate);
@@ -36,11 +35,10 @@ export const getNewDate = (index, currentDate) => {
36
35
  }
37
36
  return newDate;
38
37
  };
39
- export const formatMonth = _ref2 => {
40
- let {
41
- month,
42
- locale
43
- } = _ref2;
38
+ export const formatMonth = ({
39
+ month,
40
+ locale
41
+ }) => {
44
42
  const date = new Date(2022, month - 1, 1);
45
43
  return date.toLocaleString(locale, {
46
44
  month: 'long'
@@ -1 +1 @@
1
- {"version":3,"file":"calendar.js","names":["isAfter","isBefore","startOfMonth","getMonthAndYear","date","month","getMonth","year","getFullYear","isDateInRange","_ref","minDate","maxDate","currentDate","monthStartOfCurrentDate","monthStartOfMaxDate","monthStartOfMinDate","getNewDate","index","newDate","Date","setMonth","setFullYear","formatMonth","_ref2","locale","toLocaleString","findNextDate","dateArray","futureDates","filter","d","sort","a","b","getTime","getYearsBetween","startDate","endDate","startYear","endYear","years","push"],"sources":["../../../src/utils/calendar.ts"],"sourcesContent":["import type { EMonth, IMonth } from '../types/calendar';\nimport {isAfter, isBefore, startOfMonth} from \"./date\";\nimport {Language} from \"chayns-api\";\n\nexport const getMonthAndYear = (date: Date): IMonth => {\n const month = date.getMonth() + 1;\n\n const year = date.getFullYear();\n\n return {\n month,\n year,\n };\n};\n\ninterface FormatMonthOptions {\n month: EMonth;\n locale: Language;\n}\n\ninterface IsDateInRange {\n minDate: Date;\n maxDate: Date;\n currentDate: Date;\n}\n\nexport const isDateInRange = ({ minDate, maxDate, currentDate }: IsDateInRange): Date => {\n const monthStartOfCurrentDate = startOfMonth(currentDate);\n const monthStartOfMaxDate = startOfMonth(maxDate);\n const monthStartOfMinDate = startOfMonth(minDate);\n\n switch (true) {\n case isAfter(monthStartOfCurrentDate, monthStartOfMaxDate):\n return monthStartOfMaxDate;\n case isBefore(monthStartOfCurrentDate, monthStartOfMinDate):\n return monthStartOfMinDate;\n default:\n return monthStartOfCurrentDate;\n }\n};\n\nexport const getNewDate = (index: number, currentDate: Date) => {\n const newDate = new Date(currentDate);\n newDate.setMonth(currentDate.getMonth() + index);\n\n if (currentDate.getMonth() === 11 && newDate.getMonth() === 0) {\n newDate.setFullYear(currentDate.getFullYear() + 1);\n }\n\n if (currentDate.getMonth() === 0 && newDate.getMonth() === 11) {\n newDate.setFullYear(currentDate.getFullYear() - 1);\n }\n\n return newDate;\n};\n\nexport const formatMonth = ({ month, locale }: FormatMonthOptions) => {\n const date = new Date(2022, month - 1, 1);\n return date.toLocaleString(locale, { month: 'long' });\n}\n\nexport const findNextDate = (date: Date, dateArray: Date[]): Date | undefined => {\n const futureDates = dateArray.filter((d) => d > date);\n\n futureDates.sort((a, b) => a.getTime() - b.getTime());\n\n return futureDates[0];\n};\n\nexport const getYearsBetween = (startDate: Date, endDate: Date): number[] => {\n const startYear = startDate.getFullYear();\n const endYear = endDate.getFullYear();\n const years: number[] = [];\n\n for (let year = startYear; year <= endYear; year++) {\n years.push(year);\n }\n\n return years;\n};\n"],"mappings":"AACA,SAAQA,OAAO,EAAEC,QAAQ,EAAEC,YAAY,QAAO,QAAQ;AAGtD,OAAO,MAAMC,eAAe,GAAIC,IAAU,IAAa;EACnD,MAAMC,KAAK,GAAGD,IAAI,CAACE,QAAQ,CAAC,CAAC,GAAG,CAAC;EAEjC,MAAMC,IAAI,GAAGH,IAAI,CAACI,WAAW,CAAC,CAAC;EAE/B,OAAO;IACHH,KAAK;IACLE;EACJ,CAAC;AACL,CAAC;AAaD,OAAO,MAAME,aAAa,GAAGC,IAAA,IAA4D;EAAA,IAA3D;IAAEC,OAAO;IAAEC,OAAO;IAAEC;EAA2B,CAAC,GAAAH,IAAA;EAC1E,MAAMI,uBAAuB,GAAGZ,YAAY,CAACW,WAAW,CAAC;EACzD,MAAME,mBAAmB,GAAGb,YAAY,CAACU,OAAO,CAAC;EACjD,MAAMI,mBAAmB,GAAGd,YAAY,CAACS,OAAO,CAAC;EAEjD,QAAQ,IAAI;IACR,KAAKX,OAAO,CAACc,uBAAuB,EAAEC,mBAAmB,CAAC;MACtD,OAAOA,mBAAmB;IAC9B,KAAKd,QAAQ,CAACa,uBAAuB,EAAEE,mBAAmB,CAAC;MACvD,OAAOA,mBAAmB;IAC9B;MACI,OAAOF,uBAAuB;EACtC;AACJ,CAAC;AAED,OAAO,MAAMG,UAAU,GAAGA,CAACC,KAAa,EAAEL,WAAiB,KAAK;EAC5D,MAAMM,OAAO,GAAG,IAAIC,IAAI,CAACP,WAAW,CAAC;EACrCM,OAAO,CAACE,QAAQ,CAACR,WAAW,CAACP,QAAQ,CAAC,CAAC,GAAGY,KAAK,CAAC;EAEhD,IAAIL,WAAW,CAACP,QAAQ,CAAC,CAAC,KAAK,EAAE,IAAIa,OAAO,CAACb,QAAQ,CAAC,CAAC,KAAK,CAAC,EAAE;IAC3Da,OAAO,CAACG,WAAW,CAACT,WAAW,CAACL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,EAAE;IAChDkC,KAAK,CAACC,IAAI,CAACnC,IAAI,CAAC;EACpB;EAEA,OAAOkC,KAAK;AAChB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"calendar.js","names":["isAfter","isBefore","startOfMonth","getMonthAndYear","date","month","getMonth","year","getFullYear","isDateInRange","minDate","maxDate","currentDate","monthStartOfCurrentDate","monthStartOfMaxDate","monthStartOfMinDate","getNewDate","index","newDate","Date","setMonth","setFullYear","formatMonth","locale","toLocaleString","findNextDate","dateArray","futureDates","filter","d","sort","a","b","getTime","getYearsBetween","startDate","endDate","startYear","endYear","years","push"],"sources":["../../../src/utils/calendar.ts"],"sourcesContent":["import type { EMonth, IMonth } from '../types/calendar';\nimport { isAfter, isBefore, startOfMonth } from './date';\nimport { Language } from 'chayns-api';\n\nexport const getMonthAndYear = (date: Date): IMonth => {\n const month = date.getMonth() + 1;\n\n const year = date.getFullYear();\n\n return {\n month,\n year,\n };\n};\n\ninterface FormatMonthOptions {\n month: EMonth;\n locale: Language;\n}\n\ninterface IsDateInRange {\n minDate: Date;\n maxDate: Date;\n currentDate: Date;\n}\n\nexport const isDateInRange = ({ minDate, maxDate, currentDate }: IsDateInRange): Date => {\n const monthStartOfCurrentDate = startOfMonth(currentDate);\n const monthStartOfMaxDate = startOfMonth(maxDate);\n const monthStartOfMinDate = startOfMonth(minDate);\n\n switch (true) {\n case isAfter(monthStartOfCurrentDate, monthStartOfMaxDate):\n return monthStartOfMaxDate;\n case isBefore(monthStartOfCurrentDate, monthStartOfMinDate):\n return monthStartOfMinDate;\n default:\n return monthStartOfCurrentDate;\n }\n};\n\nexport const getNewDate = (index: number, currentDate: Date) => {\n const newDate = new Date(currentDate);\n newDate.setMonth(currentDate.getMonth() + index);\n\n if (currentDate.getMonth() === 11 && newDate.getMonth() === 0) {\n newDate.setFullYear(currentDate.getFullYear() + 1);\n }\n\n if (currentDate.getMonth() === 0 && newDate.getMonth() === 11) {\n newDate.setFullYear(currentDate.getFullYear() - 1);\n }\n\n return newDate;\n};\n\nexport const formatMonth = ({ month, locale }: FormatMonthOptions) => {\n const date = new Date(2022, month - 1, 1);\n return date.toLocaleString(locale, { month: 'long' });\n};\n\nexport const findNextDate = (date: Date, dateArray: Date[]): Date | undefined => {\n const futureDates = dateArray.filter((d) => d > date);\n\n futureDates.sort((a, b) => a.getTime() - b.getTime());\n\n return futureDates[0];\n};\n\nexport const getYearsBetween = (startDate: Date, endDate: Date): number[] => {\n const startYear = startDate.getFullYear();\n const endYear = endDate.getFullYear();\n const years: number[] = [];\n\n for (let year = startYear; year <= endYear; year++) {\n years.push(year);\n }\n\n return years;\n};\n"],"mappings":"AACA,SAASA,OAAO,EAAEC,QAAQ,EAAEC,YAAY,QAAQ,QAAQ;AAGxD,OAAO,MAAMC,eAAe,GAAIC,IAAU,IAAa;EACnD,MAAMC,KAAK,GAAGD,IAAI,CAACE,QAAQ,CAAC,CAAC,GAAG,CAAC;EAEjC,MAAMC,IAAI,GAAGH,IAAI,CAACI,WAAW,CAAC,CAAC;EAE/B,OAAO;IACHH,KAAK;IACLE;EACJ,CAAC;AACL,CAAC;AAaD,OAAO,MAAME,aAAa,GAAGA,CAAC;EAAEC,OAAO;EAAEC,OAAO;EAAEC;AAA2B,CAAC,KAAW;EACrF,MAAMC,uBAAuB,GAAGX,YAAY,CAACU,WAAW,CAAC;EACzD,MAAME,mBAAmB,GAAGZ,YAAY,CAACS,OAAO,CAAC;EACjD,MAAMI,mBAAmB,GAAGb,YAAY,CAACQ,OAAO,CAAC;EAEjD,QAAQ,IAAI;IACR,KAAKV,OAAO,CAACa,uBAAuB,EAAEC,mBAAmB,CAAC;MACtD,OAAOA,mBAAmB;IAC9B,KAAKb,QAAQ,CAACY,uBAAuB,EAAEE,mBAAmB,CAAC;MACvD,OAAOA,mBAAmB;IAC9B;MACI,OAAOF,uBAAuB;EACtC;AACJ,CAAC;AAED,OAAO,MAAMG,UAAU,GAAGA,CAACC,KAAa,EAAEL,WAAiB,KAAK;EAC5D,MAAMM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EC,OAAa,KAAe;EACzE,MAAMC,SAAS,GAAGF,SAAS,CAAC3B,WAAW,CAAC,CAAC;EACzC,MAAM8B,OAAO,GAAGF,OAAO,CAAC5B,WAAW,CAAC,CAAC;EACrC,MAAM+B,KAAe,GAAG,EAAE;EAE1B,KAAK,IAAIhC,IAAI,GAAG8B,SAAS,EAAE9B,IAAI,IAAI+B,OAAO,EAAE/B,IAAI,EAAE,EAAE;IAChDgC,KAAK,CAACC,IAAI,CAACjC,IAAI,CAAC;EACpB;EAEA,OAAOgC,KAAK;AAChB,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"date.js","names":["isToday","date","today","Date","toDateString","isTomorrow","tomorrow","setDate","getDate","isYesterday","yesterday","isCurrentYear","currentYear","getFullYear","yearOfGivenDate","getIsDateNearToday","setHours","targetDate","diffInDays","getTime","isMorning","hours","getHours","isAfter","firstDate","secondDate","isBefore","startOfMonth","getMonth","addYears","years","differenceInCalendarMonths","isSameDay","isSameMonth","isWithinInterval","interval","start","end","subYears","startOfWeek","day","getDay","diff","endOfWeek","eachDayOfInterval","days","currentDate","push","addDays","result"],"sources":["../../../src/utils/date.ts"],"sourcesContent":["export const isToday = (date: Date): boolean => {\n const today = new Date();\n return today.toDateString() === date.toDateString();\n};\n\nexport const isTomorrow = (date: Date): boolean => {\n const tomorrow = new Date();\n tomorrow.setDate(tomorrow.getDate() + 1);\n return tomorrow.toDateString() === date.toDateString();\n};\n\nexport const isYesterday = (date: Date): boolean => {\n const yesterday = new Date();\n yesterday.setDate(yesterday.getDate() - 1);\n return yesterday.toDateString() === date.toDateString();\n};\n\nexport const isCurrentYear = (date: Date): boolean => {\n const currentYear = new Date().getFullYear();\n const yearOfGivenDate = date.getFullYear();\n return currentYear === yearOfGivenDate;\n};\n\nexport const getIsDateNearToday = (date: Date) => {\n const today = new Date();\n today.setHours(0, 0, 0, 0);\n\n const targetDate = new Date(date);\n targetDate.setHours(0, 0, 0, 0);\n\n const diffInDays = (targetDate.getTime() - today.getTime()) / (1000 * 60 * 60 * 24);\n\n return diffInDays === 0 || diffInDays === -1 || diffInDays === 1;\n};\n\nexport const isMorning = (date: Date) => {\n const hours = date.getHours();\n\n return hours >= 0 && hours < 12;\n};\n\nexport const isAfter = (firstDate: Date, secondDate: Date): boolean => {\n return firstDate.getTime() > secondDate.getTime();\n}\n\nexport const isBefore = (firstDate: Date, secondDate: Date): boolean => {\n return firstDate.getTime() < secondDate.getTime();\n}\n\nexport const startOfMonth = (date: Date): Date => {\n return new Date(date.getFullYear(), date.getMonth(), 1);\n}\n\nexport const addYears = (date: Date, years: number): Date => {\n return new Date(date.getFullYear() + years, date.getMonth(), date.getDate());\n};\n\nexport const differenceInCalendarMonths = (firstDate: Date, secondDate: Date): number => {\n return (firstDate.getFullYear() - secondDate.getFullYear()) * 12 + (firstDate.getMonth() - secondDate.getMonth());\n};\n\nexport const isSameDay = (firstDate: Date, secondDate: Date): boolean => {\n return (\n firstDate.getFullYear() === secondDate.getFullYear() &&\n firstDate.getMonth() === secondDate.getMonth() &&\n firstDate.getDate() === secondDate.getDate()\n );\n};\n\nexport const isSameMonth = (firstDate: Date, secondDate: Date): boolean => {\n return (\n firstDate.getFullYear() === secondDate.getFullYear() &&\n firstDate.getMonth() === secondDate.getMonth()\n );\n};\n\ninterface Interval {\n start: Date;\n end: Date;\n}\n\nexport const isWithinInterval = (date: Date, interval: Interval): boolean => {\n return date.getTime() >= interval.start.getTime() && date.getTime() <= interval.end.getTime();\n};\n\nexport const subYears = (date: Date, years: number): Date => {\n return new Date(date.getFullYear() - years, date.getMonth(), date.getDate());\n};\n\nexport const startOfWeek = (date: Date): Date => {\n const day = date.getDay();\n const diff = day === 0 ? -6 : 1 - day;\n const start = new Date(date);\n start.setDate(date.getDate() + diff);\n start.setHours(0, 0, 0, 0);\n return start;\n};\n\nexport const endOfWeek = (date: Date): Date => {\n const day = date.getDay();\n const diff = day === 0 ? 0 : 7 - day;\n const end = new Date(date);\n end.setDate(date.getDate() + diff);\n end.setHours(23, 59, 59, 999);\n return end;\n};\n\nexport const eachDayOfInterval = (interval: { start: Date, end: Date }): Date[] => {\n const days: Date[] = [];\n const currentDate = new Date(interval.start);\n\n while (currentDate <= interval.end) {\n days.push(new Date(currentDate));\n currentDate.setDate(currentDate.getDate() + 1);\n }\n\n return days;\n};\n\nexport const addDays = (date: Date, days: number): Date => {\n const result = new Date(date);\n result.setDate(date.getDate() + days);\n return result;\n};\n"],"mappings":"AAAA,OAAO,MAAMA,OAAO,GAAIC,IAAU,IAAc;EAC5C,MAAMC,KAAK,GAAG,IAAIC,IAAI,CAAC,CAAC;EACxB,OAAOD,KAAK,CAACE,YAAY,CAAC,CAAC,KAAKH,IAAI,CAACG,YAAY,CAAC,CAAC;AACvD,CAAC;AAED,OAAO,MAAMC,UAAU,GAAIJ,IAAU,IAAc;EAC/C,MAAMK,QAAQ,GAAG,IAAIH,IAAI,CAAC,CAAC;EAC3BG,QAAQ,CAACC,OAAO,CAACD,QAAQ,CAACE,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC;EACxC,OAAOF,QAAQ,CAACF,YAAY,CAAC,CAAC,KAAKH,IAAI,CAACG,YAAY,CAAC,CAAC;AAC1D,CAAC;AAED,OAAO,MAAMK,WAAW,GAAIR,IAAU,IAAc;EAChD,MAAMS,SAAS,GAAG,IAAIP,IAAI,CAAC,CAAC;EAC5BO,SAAS,CAACH,OAAO,CAACG,SAAS,CAACF,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC;EAC1C,OAAOE,SAAS,CAACN,YAAY,CAAC,CAAC,KAAKH,IAAI,CAACG,YAAY,CAAC,CAAC;AAC3D,CAAC;AAED,OAAO,MAAMO,aAAa,GAAIV,IAAU,IAAc;EAClD,MAAMW,WAAW,GAAG,IAAIT,IAAI,CAAC,CAAC,CAACU,WAAW,CAAC,CAAC;EAC5C,MAAMC,eAAe,GAAGb,IAAI,CAACY,WAAW,CAAC,CAAC;EAC1C,OAAOD,WAAW,KAAKE,eAAe;AAC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AOqB,GAAG;AACd,CAAC;AAED,OAAO,MAAMO,iBAAiB,GAAIT,QAAoC,IAAa;EAC/E,MAAMU,IAAY,GAAG,EAAE;EACvB,MAAMC,WAAW,GAAG,IAAI3C,IAAI,CAACgC,QAAQ,CAACC,KAAK,CAAC;EAE5C,OAAOU,WAAW,IAAIX,QAAQ,CAACE,GAAG,EAAE;IAChCQ,IAAI,CAACE,IAAI,CAAC,IAAI5C,IAAI,CAAC2C,WAAW,CAAC,CAAC;IAChCA,WAAW,CAACvC,OAAO,CAACuC,WAAW,CAACtC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC;EAClD;EAEA,OAAOqC,IAAI;AACf,CAAC;AAED,OAAO,MAAMG,OAAO,GAAGA,CAAC/C,IAAU,EAAE4C,IAAY,KAAW;EACvD,MAAMI,MAAM,GAAG,IAAI9C,IAAI,CAACF,IAAI,CAAC;EAC7BgD,MAAM,CAAC1C,OAAO,CAACN,IAAI,CAACO,OAAO,CAAC,CAAC,GAAGqC,IAAI,CAAC;EACrC,OAAOI,MAAM;AACjB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"date.js","names":["isToday","date","today","Date","toDateString","isTomorrow","tomorrow","setDate","getDate","isYesterday","yesterday","isCurrentYear","currentYear","getFullYear","yearOfGivenDate","getIsDateNearToday","setHours","targetDate","diffInDays","getTime","isMorning","hours","getHours","isAfter","firstDate","secondDate","isBefore","startOfMonth","getMonth","addYears","years","differenceInCalendarMonths","isSameDay","isSameMonth","isWithinInterval","interval","start","end","subYears","startOfWeek","day","getDay","diff","endOfWeek","eachDayOfInterval","days","currentDate","push","addDays","result"],"sources":["../../../src/utils/date.ts"],"sourcesContent":["export const isToday = (date: Date): boolean => {\n const today = new Date();\n return today.toDateString() === date.toDateString();\n};\n\nexport const isTomorrow = (date: Date): boolean => {\n const tomorrow = new Date();\n tomorrow.setDate(tomorrow.getDate() + 1);\n return tomorrow.toDateString() === date.toDateString();\n};\n\nexport const isYesterday = (date: Date): boolean => {\n const yesterday = new Date();\n yesterday.setDate(yesterday.getDate() - 1);\n return yesterday.toDateString() === date.toDateString();\n};\n\nexport const isCurrentYear = (date: Date): boolean => {\n const currentYear = new Date().getFullYear();\n const yearOfGivenDate = date.getFullYear();\n return currentYear === yearOfGivenDate;\n};\n\nexport const getIsDateNearToday = (date: Date) => {\n const today = new Date();\n today.setHours(0, 0, 0, 0);\n\n const targetDate = new Date(date);\n targetDate.setHours(0, 0, 0, 0);\n\n const diffInDays = (targetDate.getTime() - today.getTime()) / (1000 * 60 * 60 * 24);\n\n return diffInDays === 0 || diffInDays === -1 || diffInDays === 1;\n};\n\nexport const isMorning = (date: Date) => {\n const hours = date.getHours();\n\n return hours >= 0 && hours < 12;\n};\n\nexport const isAfter = (firstDate: Date, secondDate: Date): boolean => {\n return firstDate.getTime() > secondDate.getTime();\n};\n\nexport const isBefore = (firstDate: Date, secondDate: Date): boolean => {\n return firstDate.getTime() < secondDate.getTime();\n};\n\nexport const startOfMonth = (date: Date): Date => {\n return new Date(date.getFullYear(), date.getMonth(), 1);\n};\n\nexport const addYears = (date: Date, years: number): Date => {\n return new Date(date.getFullYear() + years, date.getMonth(), date.getDate());\n};\n\nexport const differenceInCalendarMonths = (firstDate: Date, secondDate: Date): number => {\n return (\n (firstDate.getFullYear() - secondDate.getFullYear()) * 12 +\n (firstDate.getMonth() - secondDate.getMonth())\n );\n};\n\nexport const isSameDay = (firstDate: Date, secondDate: Date): boolean => {\n return (\n firstDate.getFullYear() === secondDate.getFullYear() &&\n firstDate.getMonth() === secondDate.getMonth() &&\n firstDate.getDate() === secondDate.getDate()\n );\n};\n\nexport const isSameMonth = (firstDate: Date, secondDate: Date): boolean => {\n return (\n firstDate.getFullYear() === secondDate.getFullYear() &&\n firstDate.getMonth() === secondDate.getMonth()\n );\n};\n\ninterface Interval {\n start: Date;\n end: Date;\n}\n\nexport const isWithinInterval = (date: Date, interval: Interval): boolean => {\n return date.getTime() >= interval.start.getTime() && date.getTime() <= interval.end.getTime();\n};\n\nexport const subYears = (date: Date, years: number): Date => {\n return new Date(date.getFullYear() - years, date.getMonth(), date.getDate());\n};\n\nexport const startOfWeek = (date: Date): Date => {\n const day = date.getDay();\n const diff = day === 0 ? -6 : 1 - day;\n const start = new Date(date);\n start.setDate(date.getDate() + diff);\n start.setHours(0, 0, 0, 0);\n return start;\n};\n\nexport const endOfWeek = (date: Date): Date => {\n const day = date.getDay();\n const diff = day === 0 ? 0 : 7 - day;\n const end = new Date(date);\n end.setDate(date.getDate() + diff);\n end.setHours(23, 59, 59, 999);\n return end;\n};\n\nexport const eachDayOfInterval = (interval: { start: Date; end: Date }): Date[] => {\n const days: Date[] = [];\n const currentDate = new Date(interval.start);\n\n while (currentDate <= interval.end) {\n days.push(new Date(currentDate));\n currentDate.setDate(currentDate.getDate() + 1);\n }\n\n return days;\n};\n\nexport const addDays = (date: Date, days: number): Date => {\n const result = new Date(date);\n result.setDate(date.getDate() + days);\n return result;\n};\n"],"mappings":"AAAA,OAAO,MAAMA,OAAO,GAAIC,IAAU,IAAc;EAC5C,MAAMC,KAAK,GAAG,IAAIC,IAAI,CAAC,CAAC;EACxB,OAAOD,KAAK,CAACE,YAAY,CAAC,CAAC,KAAKH,IAAI,CAACG,YAAY,CAAC,CAAC;AACvD,CAAC;AAED,OAAO,MAAMC,UAAU,GAAIJ,IAAU,IAAc;EAC/C,MAAMK,QAAQ,GAAG,IAAIH,IAAI,CAAC,CAAC;EAC3BG,QAAQ,CAACC,OAAO,CAACD,QAAQ,CAACE,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC;EACxC,OAAOF,QAAQ,CAACF,YAAY,CAAC,CAAC,KAAKH,IAAI,CAACG,YAAY,CAAC,CAAC;AAC1D,CAAC;AAED,OAAO,MAAMK,WAAW,GAAIR,IAAU,IAAc;EAChD,MAAMS,SAAS,GAAG,IAAIP,IAAI,CAAC,CAAC;EAC5BO,SAAS,CAACH,OAAO,CAACG,SAAS,CAACF,OAAO,CAAC,CAAC,GAAG,CAAC,CAA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AAMC,IAAI,GAAGF,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,GAAGA,GAAG;EACpC,MAAMH,GAAG,GAAG,IAAIlC,IAAI,CAACF,IAAI,CAAC;EAC1BoC,GAAG,CAAC9B,OAAO,CAACN,IAAI,CAACO,OAAO,CAAC,CAAC,GAAGkC,IAAI,CAAC;EAClCL,GAAG,CAACrB,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC;EAC7B,OAAOqB,GAAG;AACd,CAAC;AAED,OAAO,MAAMO,iBAAiB,GAAIT,QAAoC,IAAa;EAC/E,MAAMU,IAAY,GAAG,EAAE;EACvB,MAAMC,WAAW,GAAG,IAAI3C,IAAI,CAACgC,QAAQ,CAACC,KAAK,CAAC;EAE5C,OAAOU,WAAW,IAAIX,QAAQ,CAACE,GAAG,EAAE;IAChCQ,IAAI,CAACE,IAAI,CAAC,IAAI5C,IAAI,CAAC2C,WAAW,CAAC,CAAC;IAChCA,WAAW,CAACvC,OAAO,CAACuC,WAAW,CAACtC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC;EAClD;EAEA,OAAOqC,IAAI;AACf,CAAC;AAED,OAAO,MAAMG,OAAO,GAAGA,CAAC/C,IAAU,EAAE4C,IAAY,KAAW;EACvD,MAAMI,MAAM,GAAG,IAAI9C,IAAI,CAACF,IAAI,CAAC;EAC7BgD,MAAM,CAAC1C,OAAO,CAACN,IAAI,CAACO,OAAO,CAAC,CAAC,GAAGqC,IAAI,CAAC;EACrC,OAAOI,MAAM;AACjB,CAAC","ignoreList":[]}
@@ -1,20 +1,39 @@
1
1
  import { getLanguage, Language } from 'chayns-api';
2
2
  import { isCurrentYear, isToday, isTomorrow, isYesterday } from './date';
3
- export const getDateInfo = _ref => {
4
- let {
5
- date,
6
- shouldShowYear,
7
- shouldShowTime,
8
- shouldShowDayOfWeek,
9
- shouldShowRelativeDayOfWeek,
10
- shouldUseShortText
11
- } = _ref;
3
+ export const getDateInfo = ({
4
+ date,
5
+ language,
6
+ shouldShowYear,
7
+ shouldShowTime,
8
+ shouldShowOnlyTime,
9
+ shouldShowDayOfWeek,
10
+ shouldShowRelativeDayOfWeek,
11
+ shouldUseShortText
12
+ }) => {
12
13
  const {
13
- active: language
14
+ active: activeLanguage
14
15
  } = getLanguage();
16
+ const timeParts = {};
17
+ if (shouldShowTime || shouldShowOnlyTime) {
18
+ timeParts.hour = '2-digit';
19
+ timeParts.minute = '2-digit';
20
+ }
21
+ let formattedTime = '';
22
+ if (Object.keys(timeParts).length > 0) {
23
+ formattedTime = `${shouldShowOnlyTime ? '' : ', '}${date.toLocaleTimeString(language ?? activeLanguage, {
24
+ ...timeParts
25
+ })}`;
26
+ }
27
+ const hourWord = getTimeString({
28
+ language: language ?? activeLanguage
29
+ });
30
+ formattedTime += shouldShowTime || shouldShowOnlyTime ? ` ${hourWord}` : '';
31
+ if (shouldShowOnlyTime) {
32
+ return formattedTime;
33
+ }
15
34
  let dayPart = '';
16
35
  if (shouldShowRelativeDayOfWeek) {
17
- const rtf = new Intl.RelativeTimeFormat(language, {
36
+ const rtf = new Intl.RelativeTimeFormat(language ?? activeLanguage, {
18
37
  numeric: 'auto'
19
38
  });
20
39
  if (isToday(date)) {
@@ -28,7 +47,7 @@ export const getDateInfo = _ref => {
28
47
  }
29
48
  }
30
49
  if (!dayPart && shouldShowDayOfWeek) {
31
- dayPart = date.toLocaleDateString(language, {
50
+ dayPart = date.toLocaleDateString(language ?? activeLanguage, {
32
51
  weekday: shouldUseShortText ? 'short' : 'long'
33
52
  });
34
53
  }
@@ -39,31 +58,15 @@ export const getDateInfo = _ref => {
39
58
  if (shouldShowYear && !isCurrentYear(date)) {
40
59
  dateParts.year = 'numeric';
41
60
  }
42
- const timeParts = {};
43
- if (shouldShowTime) {
44
- timeParts.hour = '2-digit';
45
- timeParts.minute = '2-digit';
46
- }
47
- let formattedTime = '';
48
- if (Object.keys(timeParts).length > 0) {
49
- formattedTime = `, ${date.toLocaleTimeString(language, {
50
- ...timeParts
51
- })}`;
52
- }
53
- const hourWord = getTimeString({
54
- language
55
- });
56
- formattedTime += shouldShowTime ? ` ${hourWord}` : '';
57
- const formattedDate = `${date.toLocaleDateString(language, dateParts)}${formattedTime}`;
61
+ const formattedDate = `${date.toLocaleDateString(language ?? activeLanguage, dateParts)}${formattedTime}`;
58
62
  return `${dayPart}${dayPart ? ', ' : ''}${formattedDate}`;
59
63
  };
60
64
  const capitalizeFirstLetter = text => text.charAt(0).toUpperCase() + text.slice(1);
61
- export const getTimeTillNow = _ref2 => {
62
- let {
63
- date,
64
- currentDate,
65
- language = Language.English
66
- } = _ref2;
65
+ export const getTimeTillNow = ({
66
+ date,
67
+ currentDate,
68
+ language = Language.English
69
+ }) => {
67
70
  const diffInSeconds = Math.floor((currentDate.getTime() - date.getTime()) / 1000);
68
71
  const isPast = diffInSeconds > 0;
69
72
  const units = [{
@@ -99,20 +102,37 @@ export const getTimeTillNow = _ref2 => {
99
102
  });
100
103
  return formatter.format(isPast ? -count : count, label);
101
104
  };
102
- export const getTimeString = _ref3 => {
103
- let {
105
+ export const getFormattedTime = ({
106
+ date,
107
+ shouldShowSeconds = false
108
+ }) => {
109
+ const {
110
+ active: language
111
+ } = getLanguage();
112
+ const timeOptions = {
113
+ hour: '2-digit',
114
+ minute: '2-digit',
115
+ second: shouldShowSeconds ? '2-digit' : undefined
116
+ };
117
+ const formattedTime = date.toLocaleTimeString(language, timeOptions).replace(/^0/, '');
118
+ const hourWord = getTimeString({
104
119
  language
105
- } = _ref3;
120
+ });
121
+ return `${formattedTime} ${hourWord}`.trim();
122
+ };
123
+ export const getTimeString = ({
124
+ language
125
+ }) => {
106
126
  const map = {
107
- nl: 'uur',
108
- fr: 'heures',
127
+ nl: '',
128
+ fr: '',
109
129
  de: 'Uhr',
110
- es: 'horas',
111
- it: 'ore',
112
- pt: 'horas',
113
- pl: 'godzina',
114
- tr: 'saat',
115
- uk: 'година',
130
+ es: '',
131
+ it: '',
132
+ pt: '',
133
+ pl: '',
134
+ tr: '',
135
+ uk: '',
116
136
  en: ''
117
137
  };
118
138
  return map[language ?? ''] ?? '';
@@ -1 +1 @@
1
- {"version":3,"file":"dateInfo.js","names":["getLanguage","Language","isCurrentYear","isToday","isTomorrow","isYesterday","getDateInfo","_ref","date","shouldShowYear","shouldShowTime","shouldShowDayOfWeek","shouldShowRelativeDayOfWeek","shouldUseShortText","active","language","dayPart","rtf","Intl","RelativeTimeFormat","numeric","capitalizeFirstLetter","format","toLocaleDateString","weekday","dateParts","day","month","year","timeParts","hour","minute","formattedTime","Object","keys","length","toLocaleTimeString","hourWord","getTimeString","formattedDate","text","charAt","toUpperCase","slice","getTimeTillNow","_ref2","currentDate","English","diffInSeconds","Math","floor","getTime","isPast","units","label","seconds","absDiff","abs","find","u","count","formatter","_ref3","map","nl","fr","de","es","it","pt","pl","tr","uk","en"],"sources":["../../../src/utils/dateInfo.ts"],"sourcesContent":["import { getLanguage, Language } from 'chayns-api';\nimport { UseDateInfoOptions } from '../types/dateinfo';\nimport { isCurrentYear, isToday, isTomorrow, isYesterday } from './date';\n\nexport const getDateInfo = ({\n date,\n shouldShowYear,\n shouldShowTime,\n shouldShowDayOfWeek,\n shouldShowRelativeDayOfWeek,\n shouldUseShortText,\n}: Omit<UseDateInfoOptions, 'shouldShowDateToNowDifference' & 'preText'>) => {\n const { active: language } = getLanguage();\n\n let dayPart = '';\n\n if (shouldShowRelativeDayOfWeek) {\n const rtf = new Intl.RelativeTimeFormat(language, { numeric: 'auto' });\n\n if (isToday(date)) {\n dayPart = capitalizeFirstLetter(rtf.format(0, 'day'));\n }\n\n if (isTomorrow(date)) {\n dayPart = capitalizeFirstLetter(rtf.format(1, 'day'));\n }\n\n if (isYesterday(date)) {\n dayPart = capitalizeFirstLetter(rtf.format(-1, 'day'));\n }\n }\n\n if (!dayPart && shouldShowDayOfWeek) {\n dayPart = date.toLocaleDateString(language, {\n weekday: shouldUseShortText ? 'short' : 'long',\n });\n }\n\n const dateParts: Intl.DateTimeFormatOptions = {\n day: '2-digit',\n month: shouldUseShortText ? 'short' : 'long',\n };\n\n if (shouldShowYear && !isCurrentYear(date)) {\n dateParts.year = 'numeric';\n }\n\n const timeParts: Intl.DateTimeFormatOptions = {};\n\n if (shouldShowTime) {\n timeParts.hour = '2-digit';\n timeParts.minute = '2-digit';\n }\n\n let formattedTime = '';\n if (Object.keys(timeParts).length > 0) {\n formattedTime = `, ${date.toLocaleTimeString(language, { ...timeParts })}`;\n }\n\n const hourWord = getTimeString({ language });\n\n formattedTime += shouldShowTime ? ` ${hourWord}` : '';\n\n const formattedDate = `${date.toLocaleDateString(language, dateParts)}${formattedTime}`;\n\n return `${dayPart}${dayPart ? ', ' : ''}${formattedDate}`;\n};\n\nconst capitalizeFirstLetter = (text: string): string =>\n text.charAt(0).toUpperCase() + text.slice(1);\n\ntype RelativeTimeUnit = 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second';\n\ninterface GetTimeTillNow {\n date: Date;\n currentDate: Date;\n language: Language;\n}\n\nexport const getTimeTillNow = ({\n date,\n currentDate,\n language = Language.English,\n}: GetTimeTillNow): string => {\n const diffInSeconds = Math.floor((currentDate.getTime() - date.getTime()) / 1000);\n const isPast = diffInSeconds > 0;\n\n const units: { label: RelativeTimeUnit; seconds: number }[] = [\n { label: 'year', seconds: 31536000 },\n { label: 'month', seconds: 2592000 },\n { label: 'day', seconds: 86400 },\n { label: 'hour', seconds: 3600 },\n { label: 'minute', seconds: 60 },\n { label: 'second', seconds: 1 },\n ];\n\n const absDiff = Math.abs(diffInSeconds);\n const { label, seconds } = units.find((u) => absDiff >= u.seconds) || {\n label: 'second',\n seconds: 1,\n };\n const count = Math.floor(absDiff / seconds);\n\n const formatter = new Intl.RelativeTimeFormat(language, { numeric: 'auto' });\n\n return formatter.format(isPast ? -count : count, label);\n};\n\ninterface GetTimeStringProps {\n language?: Language;\n}\n\nexport const getTimeString = ({ language }: GetTimeStringProps) => {\n const map: { [key: string]: string } = {\n nl: 'uur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wB,KAAA,IAAsC;EAAA,IAArC;IAAE/C;EAA6B,CAAC,GAAA+C,KAAA;EAC1D,MAAMC,GAA8B,GAAG;IACnCC,EAAE,EAAE,KAAK;IACTC,EAAE,EAAE,QAAQ;IACZC,EAAE,EAAE,KAAK;IACTC,EAAE,EAAE,OAAO;IACXC,EAAE,EAAE,KAAK;IACTC,EAAE,EAAE,OAAO;IACXC,EAAE,EAAE,SAAS;IACbC,EAAE,EAAE,MAAM;IACVC,EAAE,EAAE,QAAQ;IACZC,EAAE,EAAE;EACR,CAAC;EAED,OAAOV,GAAG,CAAChD,QAAQ,IAAI,EAAE,CAAC,IAAI,EAAE;AACpC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"dateInfo.js","names":["getLanguage","Language","isCurrentYear","isToday","isTomorrow","isYesterday","getDateInfo","date","language","shouldShowYear","shouldShowTime","shouldShowOnlyTime","shouldShowDayOfWeek","shouldShowRelativeDayOfWeek","shouldUseShortText","active","activeLanguage","timeParts","hour","minute","formattedTime","Object","keys","length","toLocaleTimeString","hourWord","getTimeString","dayPart","rtf","Intl","RelativeTimeFormat","numeric","capitalizeFirstLetter","format","toLocaleDateString","weekday","dateParts","day","month","year","formattedDate","text","charAt","toUpperCase","slice","getTimeTillNow","currentDate","English","diffInSeconds","Math","floor","getTime","isPast","units","label","seconds","absDiff","abs","find","u","count","formatter","getFormattedTime","shouldShowSeconds","timeOptions","second","undefined","replace","trim","map","nl","fr","de","es","it","pt","pl","tr","uk","en"],"sources":["../../../src/utils/dateInfo.ts"],"sourcesContent":["import { getLanguage, Language } from 'chayns-api';\nimport { UseDateInfoOptions } from '../types/dateinfo';\nimport { isCurrentYear, isToday, isTomorrow, isYesterday } from './date';\n\nexport const getDateInfo = ({\n date,\n language,\n shouldShowYear,\n shouldShowTime,\n shouldShowOnlyTime,\n shouldShowDayOfWeek,\n shouldShowRelativeDayOfWeek,\n shouldUseShortText,\n}: Omit<UseDateInfoOptions, 'shouldShowDateToNowDifference' & 'preText'>) => {\n const { active: activeLanguage } = getLanguage();\n\n const timeParts: Intl.DateTimeFormatOptions = {};\n\n if (shouldShowTime || shouldShowOnlyTime) {\n timeParts.hour = '2-digit';\n timeParts.minute = '2-digit';\n }\n\n let formattedTime = '';\n if (Object.keys(timeParts).length > 0) {\n formattedTime = `${shouldShowOnlyTime ? '' : ', '}${date.toLocaleTimeString(language ?? activeLanguage, { ...timeParts })}`;\n }\n\n const hourWord = getTimeString({ language: language ?? activeLanguage });\n\n formattedTime += shouldShowTime || shouldShowOnlyTime ? ` ${hourWord}` : '';\n\n if (shouldShowOnlyTime) {\n return formattedTime;\n }\n\n let dayPart = '';\n\n if (shouldShowRelativeDayOfWeek) {\n const rtf = new Intl.RelativeTimeFormat(language ?? activeLanguage, { numeric: 'auto' });\n\n if (isToday(date)) {\n dayPart = capitalizeFirstLetter(rtf.format(0, 'day'));\n }\n\n if (isTomorrow(date)) {\n dayPart = capitalizeFirstLetter(rtf.format(1, 'day'));\n }\n\n if (isYesterday(date)) {\n dayPart = capitalizeFirstLetter(rtf.format(-1, 'day'));\n }\n }\n\n if (!dayPart && shouldShowDayOfWeek) {\n dayPart = date.toLocaleDateString(language ?? activeLanguage, {\n weekday: shouldUseShortText ? 'short' : 'long',\n });\n }\n\n const dateParts: Intl.DateTimeFormatOptions = {\n day: '2-digit',\n month: shouldUseShortText ? 'short' : 'long',\n };\n\n if (shouldShowYear && !isCurrentYear(date)) {\n dateParts.year = 'numeric';\n }\n\n const formattedDate = `${date.toLocaleDateString(language ?? activeLanguage, dateParts)}${formattedTime}`;\n\n return `${dayPart}${dayPart ? ', ' : ''}${formattedDate}`;\n};\n\nconst capitalizeFirstLetter = (text: string): string =>\n text.charAt(0).toUpperCase() + text.slice(1);\n\ntype RelativeTimeUnit = 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second';\n\ninterface GetTimeTillNow {\n date: Date;\n currentDate: Date;\n language: Language;\n}\n\nexport const getTimeTillNow = ({\n date,\n currentDate,\n language = Language.English,\n}: GetTimeTillNow): string => {\n const diffInSeconds = Math.floor((currentDate.getTime() - date.getTime()) / 1000);\n const isPast = diffInSeconds > 0;\n\n const units: { label: RelativeTimeUnit; seconds: number }[] = [\n { label: 'year', seconds: 31536000 },\n { label: 'month', seconds: 2592000 },\n { label: 'day', seconds: 86400 },\n { label: 'hour', seconds: 3600 },\n { label: 'minute', seconds: 60 },\n { label: 'second', seconds: 1 },\n ];\n\n const absDiff = Math.abs(diffInSeconds);\n const { label, seconds } = units.find((u) => absDiff >= u.seconds) || {\n label: 'second',\n seconds: 1,\n };\n const count = Math.floor(absDiff / seconds);\n\n const formatter = new Intl.RelativeTimeFormat(language, { numeric: 'auto' });\n\n return formatter.format(isPast ? -count : count, label);\n};\n\ninterface GetFormattedTimeOptions {\n date: Date;\n shouldShowSeconds?: boolean;\n}\n\nexport const getFormattedTime = ({\n date,\n shouldShowSeconds = false,\n}: GetFormattedTimeOptions): string => {\n const { active: language } = getLanguage();\n\n const timeOptions: Intl.DateTimeFormatOptions = {\n hour: '2-digit',\n minute: '2-digit',\n second: shouldShowSeconds ? '2-digit' : undefined,\n };\n\n const formattedTime = date.toLocaleTimeString(language, timeOptions).replace(/^0/, '');\n\n const hourWord = getTimeString({ language });\n\n return `${formattedTime} ${hourWord}`.trim();\n};\n\ninterface GetTimeStringProps {\n language?: Language;\n}\n\nexport const getTimeString = ({ language }: GetTimeStringProps) => {\n const map: { [key: string]: string } = {\n nl: '',\n fr: '',\n de: 'Uhr',\n es: '',\n it: '',\n pt: '',\n pl: '',\n tr: '',\n uk: '',\n en: '',\n };\n\n return map[language ?? ''] ?? '';\n};\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,QAAQ,QAAQ,YAAY;AAElD,SAASC,aAAa,EAAEC,OAAO,EAAEC,UAAU,EAAEC,WAAW,QAAQ,QAAQ;AAExE,OAAO,MAAMC,WAAW,GAAGA,CAAC;EACxBC,IAAI;EACJC,QAAQ;EACRC,cAAc;EACdC,cAAc;EACdC,kBAAkB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9C,IAAI,EAAE,SAAS;IACfC,MAAM,EAAE,SAAS;IACjB8C,MAAM,EAAEF,iBAAiB,GAAG,SAAS,GAAGG;EAC5C,CAAC;EAED,MAAM9C,aAAa,GAAGb,IAAI,CAACiB,kBAAkB,CAAChB,QAAQ,EAAEwD,WAAW,CAAC,CAACG,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;EAEtF,MAAM1C,QAAQ,GAAGC,aAAa,CAAC;IAAElB;EAAS,CAAC,CAAC;EAE5C,OAAO,GAAGY,aAAa,IAAIK,QAAQ,EAAE,CAAC2C,IAAI,CAAC,CAAC;AAChD,CAAC;AAMD,OAAO,MAAM1C,aAAa,GAAGA,CAAC;EAAElB;AAA6B,CAAC,KAAK;EAC/D,MAAM6D,GAA8B,GAAG;IACnCC,EAAE,EAAE,EAAE;IACNC,EAAE,EAAE,EAAE;IACNC,EAAE,EAAE,KAAK;IACTC,EAAE,EAAE,EAAE;IACNC,EAAE,EAAE,EAAE;IACNC,EAAE,EAAE,EAAE;IACNC,EAAE,EAAE,EAAE;IACNC,EAAE,EAAE,EAAE;IACNC,EAAE,EAAE,EAAE;IACNC,EAAE,EAAE;EACR,CAAC;EAED,OAAOV,GAAG,CAAC7D,QAAQ,IAAI,EAAE,CAAC,IAAI,EAAE;AACpC,CAAC","ignoreList":[]}
@@ -1,5 +1,5 @@
1
1
  import { Language } from 'chayns-api';
2
- import { FC } from 'react';
2
+ import { CSSProperties, FC } from 'react';
3
3
  import { CalendarType, Categories, CustomThumbColors, DateInterval, HighlightedDates } from '../../types/calendar';
4
4
  interface BaseProps {
5
5
  /**
@@ -55,6 +55,10 @@ interface BaseProps {
55
55
  start: Date;
56
56
  end: Date;
57
57
  }) => void;
58
+ /**
59
+ When set, the current date will be highlighted in the corresponding style.
60
+ */
61
+ currentDateBackgroundColor?: CSSProperties['backgroundColor'];
58
62
  }
59
63
  interface SingleSelectionProps {
60
64
  /**
@@ -3,6 +3,7 @@ type StyledCalendarProps = {
3
3
  };
4
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;
5
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;
6
+ export declare const StyledCalendarIconWrapperContent: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
6
7
  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
8
  export declare const StyledPseudoMonthYearPicker: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
8
9
  export {};
@@ -1,6 +1,6 @@
1
- import { FC } from 'react';
1
+ import { Language } from 'chayns-api';
2
+ import { FC, CSSProperties } from 'react';
2
3
  import { CalendarType, Categories, CustomThumbColors, DateInterval, HighlightedDates } from '../../../types/calendar';
3
- import { Language } from "chayns-api";
4
4
  export type MonthWrapperProps = {
5
5
  locale: Language;
6
6
  highlightedDates?: HighlightedDates[];
@@ -21,6 +21,9 @@ export type MonthWrapperProps = {
21
21
  shouldShowHighlightsInMonthOverlay: boolean;
22
22
  showMonthYearPickers: boolean;
23
23
  customThumbColors?: CustomThumbColors;
24
+ handleLeftArrowClick: () => void;
25
+ handleRightArrowClick: () => void;
26
+ currentDateBackgroundColor?: CSSProperties['backgroundColor'];
24
27
  };
25
28
  declare const MonthWrapper: FC<MonthWrapperProps>;
26
29
  export default MonthWrapper;