@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,35 +1,2 @@
1
- export interface UseDateInfoOptions {
2
- /**
3
- * The date, that should be displayed
4
- */
5
- date: Date | string;
6
- /**
7
- * Additional text for "shouldShowDateToNowDifference" prop. Writes a text before the calculated time
8
- */
9
- preText?: string;
10
- /**
11
- * Adds the current year to the display
12
- */
13
- shouldShowYear?: boolean;
14
- /**
15
- * Adds the time to the display.
16
- */
17
- shouldShowTime?: boolean;
18
- /**
19
- * Whether the relative day of week to today should be shown (today, yesterday or tomorrow).
20
- */
21
- shouldShowRelativeDayOfWeek?: boolean;
22
- /**
23
- * Shortens the day and month text to maximum three digits
24
- */
25
- shouldUseShortText?: boolean;
26
- /**
27
- * Adds the day of week to the display
28
- */
29
- shouldShowDayOfWeek?: boolean;
30
- /**
31
- * Shows the difference from the date to now. The component handles updates itself.
32
- */
33
- shouldShowDateToNowDifference?: boolean;
34
- }
1
+ import { UseDateInfoOptions } from '../types/dateinfo';
35
2
  export declare const useDateInfo: ({ date, shouldShowDateToNowDifference, shouldShowRelativeDayOfWeek, shouldShowDayOfWeek, shouldShowTime, shouldUseShortText, shouldShowYear, preText, }: UseDateInfoOptions) => string;
@@ -1,8 +1,10 @@
1
1
  export { default as Calendar } from './components/calendar/Calendar';
2
- export { default as DateInfo } from './components/date-info/DateInfo';
2
+ export type { Categories, HighlightedDates, HighlightedDateStyles, DateInterval, CustomThumbColors } from './types/calendar';
3
+ export { CalendarType } from './types/calendar';
3
4
  export { default as OpeningInputs } from './components/opening-times/opening-inputs/OpeningInputs';
4
5
  export { default as OpeningTimes } from './components/opening-times/OpeningTimes';
5
- export { useDateInfo } from './hooks/useDateInfo';
6
- export type { Categories, HighlightedDates, HighlightedDateStyles, CustomThumbColors } from './types/calendar';
7
- export { CalendarType } from './types/calendar';
8
6
  export type { HintTextPosition, OpeningTime, Time, Weekday } from './types/openingTimes';
7
+ export { default as DateInfo } from './components/date-info/DateInfo';
8
+ export { useDateInfo } from './hooks/useDateInfo';
9
+ export { getDateInfo, getTimeTillNow } from './utils/dateInfo';
10
+ export { isToday, getIsDateNearToday, isTomorrow, isYesterday, isMorning, isCurrentYear, addYears, addDays, isSameDay, eachDayOfInterval, isWithinInterval, subYears, endOfWeek, startOfWeek, isSameMonth, differenceInCalendarMonths, startOfMonth, isAfter, isBefore } from './utils/date';
@@ -0,0 +1,34 @@
1
+ export interface UseDateInfoOptions {
2
+ /**
3
+ * The date, that should be displayed
4
+ */
5
+ date: Date;
6
+ /**
7
+ * Additional text for "shouldShowDateToNowDifference" prop. Writes a text before the calculated time
8
+ */
9
+ preText?: string;
10
+ /**
11
+ * Adds the current year to the display
12
+ */
13
+ shouldShowYear?: boolean;
14
+ /**
15
+ * Adds the time to the display.
16
+ */
17
+ shouldShowTime?: boolean;
18
+ /**
19
+ * Whether the relative day of week to today should be shown (today, yesterday or tomorrow).
20
+ */
21
+ shouldShowRelativeDayOfWeek?: boolean;
22
+ /**
23
+ * Shortens the day and month text to maximum three digits
24
+ */
25
+ shouldUseShortText?: boolean;
26
+ /**
27
+ * Adds the day of week to the display
28
+ */
29
+ shouldShowDayOfWeek?: boolean;
30
+ /**
31
+ * Shows the difference from the date to now. The component handles updates itself.
32
+ */
33
+ shouldShowDateToNowDifference?: boolean;
34
+ }
@@ -1,9 +1,9 @@
1
- import { type Locale } from 'date-fns';
2
1
  import type { EMonth, IMonth } from '../types/calendar';
2
+ import { Language } from "chayns-api";
3
3
  export declare const getMonthAndYear: (date: Date) => IMonth;
4
4
  interface FormatMonthOptions {
5
5
  month: EMonth;
6
- locale: Locale;
6
+ locale: Language;
7
7
  }
8
8
  interface IsDateInRange {
9
9
  minDate: Date;
@@ -0,0 +1,27 @@
1
+ export declare const isToday: (date: Date) => boolean;
2
+ export declare const isTomorrow: (date: Date) => boolean;
3
+ export declare const isYesterday: (date: Date) => boolean;
4
+ export declare const isCurrentYear: (date: Date) => boolean;
5
+ export declare const getIsDateNearToday: (date: Date) => boolean;
6
+ export declare const isMorning: (date: Date) => boolean;
7
+ export declare const isAfter: (firstDate: Date, secondDate: Date) => boolean;
8
+ export declare const isBefore: (firstDate: Date, secondDate: Date) => boolean;
9
+ export declare const startOfMonth: (date: Date) => Date;
10
+ export declare const addYears: (date: Date, years: number) => Date;
11
+ export declare const differenceInCalendarMonths: (firstDate: Date, secondDate: Date) => number;
12
+ export declare const isSameDay: (firstDate: Date, secondDate: Date) => boolean;
13
+ export declare const isSameMonth: (firstDate: Date, secondDate: Date) => boolean;
14
+ interface Interval {
15
+ start: Date;
16
+ end: Date;
17
+ }
18
+ export declare const isWithinInterval: (date: Date, interval: Interval) => boolean;
19
+ export declare const subYears: (date: Date, years: number) => Date;
20
+ export declare const startOfWeek: (date: Date) => Date;
21
+ export declare const endOfWeek: (date: Date) => Date;
22
+ export declare const eachDayOfInterval: (interval: {
23
+ start: Date;
24
+ end: Date;
25
+ }) => Date[];
26
+ export declare const addDays: (date: Date, days: number) => Date;
27
+ export {};
@@ -1,56 +1,15 @@
1
- import { type Locale } from 'date-fns';
2
- import { type TimeTypeStringsRecord } from '../constants/dateInfo';
3
- export declare const getLanguage: () => Locale;
4
- interface GetTimeStringProps {
5
- language?: string;
6
- isMorning?: boolean;
7
- }
8
- export declare const getTimeString: ({ language, isMorning }: GetTimeStringProps) => "" | "uur" | "heures" | "AM" | "PM" | "Uhr" | "h";
9
- interface GetFormattedYearOptions {
10
- date: Date;
11
- shouldShowYear?: boolean;
12
- }
13
- export declare const getYearFormat: ({ date, shouldShowYear }: GetFormattedYearOptions) => "" | " yyyy";
14
- interface GetFormattedMonthOptions {
15
- shouldUseShortText?: boolean;
16
- }
17
- export declare const getMonthFormat: ({ shouldUseShortText }: GetFormattedMonthOptions) => "LLL." | "LLLL";
18
- interface GetFormattedDayOfWeekOptions {
19
- shouldShowDayOfWeek?: boolean;
20
- shouldShowRelativeDayOfWeek?: boolean;
21
- shouldUseShortText?: boolean;
22
- date: Date;
23
- language?: Locale;
24
- }
25
- export declare const getFormattedDayOfWeek: ({ shouldShowRelativeDayOfWeek, shouldShowDayOfWeek, shouldUseShortText, date, language, }: GetFormattedDayOfWeekOptions) => string;
26
- interface GetFormattedTimeOptions {
27
- shouldShowTime?: boolean;
1
+ import { Language } from 'chayns-api';
2
+ import { UseDateInfoOptions } from '../types/dateinfo';
3
+ export declare const getDateInfo: ({ date, shouldShowYear, shouldShowTime, shouldShowDayOfWeek, shouldShowRelativeDayOfWeek, shouldUseShortText, }: Omit<UseDateInfoOptions, "shouldShowDateToNowDifference" & "preText">) => string;
4
+ interface GetTimeTillNow {
28
5
  date: Date;
29
- language: Locale;
30
- }
31
- export declare const getFormattedTime: ({ shouldShowTime, date, language }: GetFormattedTimeOptions) => string;
32
- export declare const isMorning: (date: Date) => boolean;
33
- export interface Time {
34
- value: number;
35
- type: TimeType;
36
- isPast: boolean;
37
- }
38
- export declare enum TimeType {
39
- Seconds = 0,
40
- Minutes = 1,
41
- Hours = 2,
42
- Days = 3,
43
- Weeks = 4,
44
- Months = 5,
45
- Years = 6
6
+ currentDate: Date;
7
+ language: Language;
46
8
  }
47
- export declare const getTimeTypeStrings: (language: string) => TimeTypeStringsRecord | undefined;
48
- interface GetTimeTillNowOptions {
9
+ export declare const getTimeTillNow: ({ date, currentDate, language, }: GetTimeTillNow) => string;
10
+ interface GetTimeStringProps {
11
+ language?: Language;
49
12
  date: Date;
50
- currentDate: Date;
51
- language: Locale;
52
13
  }
53
- export declare const getTimeTillNow: ({ date, currentDate, language }: GetTimeTillNowOptions) => string;
54
- export declare const getFormattedPastTimeString: (time: Time, language: Locale) => string;
55
- export declare const getFormattedFutureTimeString: (time: Time, language: Locale) => string;
14
+ export declare const getTimeString: ({ language, date }: GetTimeStringProps) => string;
56
15
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chayns-components/date",
3
- "version": "5.0.0-beta.920",
3
+ "version": "5.0.0-beta.921",
4
4
  "description": "A set of beautiful React components for developing your own applications with chayns.",
5
5
  "sideEffects": false,
6
6
  "browserslist": [
@@ -69,8 +69,7 @@
69
69
  "typescript": "^5.7.2"
70
70
  },
71
71
  "dependencies": {
72
- "@chayns-components/core": "^5.0.0-beta.920",
73
- "date-fns": "^3.6.0",
72
+ "@chayns-components/core": "^5.0.0-beta.921",
74
73
  "uuid": "^10.0.0"
75
74
  },
76
75
  "peerDependencies": {
@@ -83,5 +82,5 @@
83
82
  "publishConfig": {
84
83
  "access": "public"
85
84
  },
86
- "gitHead": "7648b9a9d0c113b14ace255f63fbf0de5cb8daab"
85
+ "gitHead": "7b1332c3aa20828cbf959627dc1addd3553a863e"
87
86
  }