@super-calendar/core 2.5.0 → 2.6.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.
package/dist/index.d.mts CHANGED
@@ -2,9 +2,9 @@ import { Locale } from "date-fns";
2
2
  import { Dispatch, SetStateAction } from "react";
3
3
  //#region src/types.d.ts
4
4
  /** The view the calendar renders: a day-column grid (`day`, `3days`, `week`, `custom`), the `month` grid, or the `schedule` list. */
5
- type CalendarMode = "day" | "3days" | "week" | "custom" | "month" | "schedule";
5
+ type CalendarMode = "day" | "3days" | "week" | "custom" | "month" | "schedule" | "year";
6
6
  /** The time-grid modes (day-column views, excluding month and schedule). */
7
- type TimeGridMode = Exclude<CalendarMode, "month" | "schedule">;
7
+ type TimeGridMode = Exclude<CalendarMode, "month" | "schedule" | "year">;
8
8
  /**
9
9
  * The minimal shape every calendar event must have. Layout (positioning,
10
10
  * overlap resolution, paging) only ever reads `start`/`end`; `title` is used by
@@ -311,6 +311,8 @@ declare const getIsToday: (date: Date) => boolean;
311
311
  declare const isSameCalendarDay: (a: Date, b: Date) => boolean;
312
312
  /** Minutes elapsed since midnight (0–1439). */
313
313
  declare const minutesIntoDay: (date: Date) => number;
314
+ /** The twelve month anchors (first-of-month) of `date`'s year, January first. */
315
+ declare const getYearMonths: (date: Date) => Date[];
314
316
  //#endregion
315
317
  //#region src/utils/drag.d.ts
316
318
  /**
@@ -709,4 +711,4 @@ declare function zonedTimeToUtc(wallClock: Date, timeZone: string): Date;
709
711
  */
710
712
  declare function eventsInTimeZone<T>(events: CalendarEvent<T>[], timeZone: string): CalendarEvent<T>[];
711
713
  //#endregion
712
- export { BusinessHours, CalendarColors, CalendarEvent, CalendarMode, CalendarSelection, CalendarSelectionProvider, DateRange, DateSelectionConstraints, DayBadgeKind, DaySelectionState, EventAccessibilityLabelContext, EventAccessibilityLabeler, EventChipLayout, EventKeyExtractor, ICalEvent, ICalendarEvent, MIN_BOX_HEIGHT_FOR_TIME, MonthEventCapacity, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, PositionedEvent, RangeBandKind, RecurrenceFrequency, RecurrenceRule, TimeGridMode, ToICalendarOptions, UseDateRangeOptions, UseDateRangeResult, UseMonthGridOptions, WeekStartsOn, WeekdayFormat, bandRounding, buildMonthGrid, buildMonthWeeks, cellRangeFromDrag, closedHourBands, compareDayEvents, darkColors, dayBadgeKind, daySelectionState, eventAccessibilityLabel, eventChipLayout, eventDayKeys, eventTimeLabel, eventsInTimeZone, expandRecurringEvents, formatHour, getIsToday, getViewDays, getWeekDays, groupEventsByDay, isAllDayEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isTimeVisibleAtHeight, isWeekend, isWithinDateRange, layoutDayEvents, lightColors, minutesIntoDay, monthEventCapacity, monthVisibleCount, nextDateRange, parseICalendar, rangeBandKind, resolveDraggedBounds, shiftMinutes, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, useCalendarSelection, useDateRange, useMonthGrid, viewDayCount, weekDaysCount, weekdayFormatToken, zonedTimeToUtc };
714
+ export { BusinessHours, CalendarColors, CalendarEvent, CalendarMode, CalendarSelection, CalendarSelectionProvider, DateRange, DateSelectionConstraints, DayBadgeKind, DaySelectionState, EventAccessibilityLabelContext, EventAccessibilityLabeler, EventChipLayout, EventKeyExtractor, ICalEvent, ICalendarEvent, MIN_BOX_HEIGHT_FOR_TIME, MonthEventCapacity, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, PositionedEvent, RangeBandKind, RecurrenceFrequency, RecurrenceRule, TimeGridMode, ToICalendarOptions, UseDateRangeOptions, UseDateRangeResult, UseMonthGridOptions, WeekStartsOn, WeekdayFormat, bandRounding, buildMonthGrid, buildMonthWeeks, cellRangeFromDrag, closedHourBands, compareDayEvents, darkColors, dayBadgeKind, daySelectionState, eventAccessibilityLabel, eventChipLayout, eventDayKeys, eventTimeLabel, eventsInTimeZone, expandRecurringEvents, formatHour, getIsToday, getViewDays, getWeekDays, getYearMonths, groupEventsByDay, isAllDayEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isTimeVisibleAtHeight, isWeekend, isWithinDateRange, layoutDayEvents, lightColors, minutesIntoDay, monthEventCapacity, monthVisibleCount, nextDateRange, parseICalendar, rangeBandKind, resolveDraggedBounds, shiftMinutes, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, useCalendarSelection, useDateRange, useMonthGrid, viewDayCount, weekDaysCount, weekdayFormatToken, zonedTimeToUtc };
package/dist/index.d.ts CHANGED
@@ -2,9 +2,9 @@ import { Dispatch, SetStateAction } from "react";
2
2
  import { Locale } from "date-fns";
3
3
  //#region src/types.d.ts
4
4
  /** The view the calendar renders: a day-column grid (`day`, `3days`, `week`, `custom`), the `month` grid, or the `schedule` list. */
5
- type CalendarMode = "day" | "3days" | "week" | "custom" | "month" | "schedule";
5
+ type CalendarMode = "day" | "3days" | "week" | "custom" | "month" | "schedule" | "year";
6
6
  /** The time-grid modes (day-column views, excluding month and schedule). */
7
- type TimeGridMode = Exclude<CalendarMode, "month" | "schedule">;
7
+ type TimeGridMode = Exclude<CalendarMode, "month" | "schedule" | "year">;
8
8
  /**
9
9
  * The minimal shape every calendar event must have. Layout (positioning,
10
10
  * overlap resolution, paging) only ever reads `start`/`end`; `title` is used by
@@ -311,6 +311,8 @@ declare const getIsToday: (date: Date) => boolean;
311
311
  declare const isSameCalendarDay: (a: Date, b: Date) => boolean;
312
312
  /** Minutes elapsed since midnight (0–1439). */
313
313
  declare const minutesIntoDay: (date: Date) => number;
314
+ /** The twelve month anchors (first-of-month) of `date`'s year, January first. */
315
+ declare const getYearMonths: (date: Date) => Date[];
314
316
  //#endregion
315
317
  //#region src/utils/drag.d.ts
316
318
  /**
@@ -709,4 +711,4 @@ declare function zonedTimeToUtc(wallClock: Date, timeZone: string): Date;
709
711
  */
710
712
  declare function eventsInTimeZone<T>(events: CalendarEvent<T>[], timeZone: string): CalendarEvent<T>[];
711
713
  //#endregion
712
- export { BusinessHours, CalendarColors, CalendarEvent, CalendarMode, CalendarSelection, CalendarSelectionProvider, DateRange, DateSelectionConstraints, DayBadgeKind, DaySelectionState, EventAccessibilityLabelContext, EventAccessibilityLabeler, EventChipLayout, EventKeyExtractor, ICalEvent, ICalendarEvent, MIN_BOX_HEIGHT_FOR_TIME, MonthEventCapacity, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, PositionedEvent, RangeBandKind, RecurrenceFrequency, RecurrenceRule, TimeGridMode, ToICalendarOptions, UseDateRangeOptions, UseDateRangeResult, UseMonthGridOptions, WeekStartsOn, WeekdayFormat, bandRounding, buildMonthGrid, buildMonthWeeks, cellRangeFromDrag, closedHourBands, compareDayEvents, darkColors, dayBadgeKind, daySelectionState, eventAccessibilityLabel, eventChipLayout, eventDayKeys, eventTimeLabel, eventsInTimeZone, expandRecurringEvents, formatHour, getIsToday, getViewDays, getWeekDays, groupEventsByDay, isAllDayEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isTimeVisibleAtHeight, isWeekend, isWithinDateRange, layoutDayEvents, lightColors, minutesIntoDay, monthEventCapacity, monthVisibleCount, nextDateRange, parseICalendar, rangeBandKind, resolveDraggedBounds, shiftMinutes, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, useCalendarSelection, useDateRange, useMonthGrid, viewDayCount, weekDaysCount, weekdayFormatToken, zonedTimeToUtc };
714
+ export { BusinessHours, CalendarColors, CalendarEvent, CalendarMode, CalendarSelection, CalendarSelectionProvider, DateRange, DateSelectionConstraints, DayBadgeKind, DaySelectionState, EventAccessibilityLabelContext, EventAccessibilityLabeler, EventChipLayout, EventKeyExtractor, ICalEvent, ICalendarEvent, MIN_BOX_HEIGHT_FOR_TIME, MonthEventCapacity, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, PositionedEvent, RangeBandKind, RecurrenceFrequency, RecurrenceRule, TimeGridMode, ToICalendarOptions, UseDateRangeOptions, UseDateRangeResult, UseMonthGridOptions, WeekStartsOn, WeekdayFormat, bandRounding, buildMonthGrid, buildMonthWeeks, cellRangeFromDrag, closedHourBands, compareDayEvents, darkColors, dayBadgeKind, daySelectionState, eventAccessibilityLabel, eventChipLayout, eventDayKeys, eventTimeLabel, eventsInTimeZone, expandRecurringEvents, formatHour, getIsToday, getViewDays, getWeekDays, getYearMonths, groupEventsByDay, isAllDayEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isTimeVisibleAtHeight, isWeekend, isWithinDateRange, layoutDayEvents, lightColors, minutesIntoDay, monthEventCapacity, monthVisibleCount, nextDateRange, parseICalendar, rangeBandKind, resolveDraggedBounds, shiftMinutes, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, useCalendarSelection, useDateRange, useMonthGrid, viewDayCount, weekDaysCount, weekdayFormatToken, zonedTimeToUtc };
package/dist/index.js CHANGED
@@ -145,6 +145,8 @@ const getIsToday = (date) => (0, date_fns.isToday)(date);
145
145
  const isSameCalendarDay = (a, b) => (0, date_fns.isSameDay)(a, b);
146
146
  /** Minutes elapsed since midnight (0–1439). */
147
147
  const minutesIntoDay = (date) => (0, date_fns.getHours)(date) * 60 + (0, date_fns.getMinutes)(date);
148
+ /** The twelve month anchors (first-of-month) of `date`'s year, January first. */
149
+ const getYearMonths = (date) => Array.from({ length: 12 }, (_, i) => new Date(date.getFullYear(), i, 1));
148
150
  //#endregion
149
151
  //#region src/utils/dateRange.ts
150
152
  /** Whether `date` passes the min/max/disabled constraints (compared by calendar day). */
@@ -1215,6 +1217,7 @@ exports.formatHour = formatHour;
1215
1217
  exports.getIsToday = getIsToday;
1216
1218
  exports.getViewDays = getViewDays;
1217
1219
  exports.getWeekDays = getWeekDays;
1220
+ exports.getYearMonths = getYearMonths;
1218
1221
  exports.groupEventsByDay = groupEventsByDay;
1219
1222
  exports.isAllDayEvent = isAllDayEvent;
1220
1223
  exports.isDateSelectable = isDateSelectable;
package/dist/index.mjs CHANGED
@@ -144,6 +144,8 @@ const getIsToday = (date) => isToday(date);
144
144
  const isSameCalendarDay = (a, b) => isSameDay(a, b);
145
145
  /** Minutes elapsed since midnight (0–1439). */
146
146
  const minutesIntoDay = (date) => getHours(date) * 60 + getMinutes(date);
147
+ /** The twelve month anchors (first-of-month) of `date`'s year, January first. */
148
+ const getYearMonths = (date) => Array.from({ length: 12 }, (_, i) => new Date(date.getFullYear(), i, 1));
147
149
  //#endregion
148
150
  //#region src/utils/dateRange.ts
149
151
  /** Whether `date` passes the min/max/disabled constraints (compared by calendar day). */
@@ -1193,4 +1195,4 @@ function expandRecurringEvents(events, rangeStart, rangeEnd) {
1193
1195
  return out;
1194
1196
  }
1195
1197
  //#endregion
1196
- export { CalendarSelectionProvider, MIN_BOX_HEIGHT_FOR_TIME, bandRounding, buildMonthGrid, buildMonthWeeks, cellRangeFromDrag, closedHourBands, compareDayEvents, darkColors, dayBadgeKind, daySelectionState, eventAccessibilityLabel, eventChipLayout, eventDayKeys, eventTimeLabel, eventsInTimeZone, expandRecurringEvents, formatHour, getIsToday, getViewDays, getWeekDays, groupEventsByDay, isAllDayEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isTimeVisibleAtHeight, isWeekend, isWithinDateRange, layoutDayEvents, lightColors, minutesIntoDay, monthEventCapacity, monthVisibleCount, nextDateRange, parseICalendar, rangeBandKind, resolveDraggedBounds, shiftMinutes, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, useCalendarSelection, useDateRange, useMonthGrid, viewDayCount, weekDaysCount, weekdayFormatToken, zonedTimeToUtc };
1198
+ export { CalendarSelectionProvider, MIN_BOX_HEIGHT_FOR_TIME, bandRounding, buildMonthGrid, buildMonthWeeks, cellRangeFromDrag, closedHourBands, compareDayEvents, darkColors, dayBadgeKind, daySelectionState, eventAccessibilityLabel, eventChipLayout, eventDayKeys, eventTimeLabel, eventsInTimeZone, expandRecurringEvents, formatHour, getIsToday, getViewDays, getWeekDays, getYearMonths, groupEventsByDay, isAllDayEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isTimeVisibleAtHeight, isWeekend, isWithinDateRange, layoutDayEvents, lightColors, minutesIntoDay, monthEventCapacity, monthVisibleCount, nextDateRange, parseICalendar, rangeBandKind, resolveDraggedBounds, shiftMinutes, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, useCalendarSelection, useDateRange, useMonthGrid, viewDayCount, weekDaysCount, weekdayFormatToken, zonedTimeToUtc };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@super-calendar/core",
3
- "version": "2.5.0",
3
+ "version": "2.6.0",
4
4
  "description": "Render-agnostic core for super-calendar: date math, selection model, event layout, the month-grid builder, headless hooks, and neutral theme tokens. No renderer.",
5
5
  "keywords": [
6
6
  "calendar",
package/src/types.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  /** The view the calendar renders: a day-column grid (`day`, `3days`, `week`, `custom`), the `month` grid, or the `schedule` list. */
2
- export type CalendarMode = "day" | "3days" | "week" | "custom" | "month" | "schedule";
2
+ export type CalendarMode = "day" | "3days" | "week" | "custom" | "month" | "schedule" | "year";
3
3
 
4
4
  /** The time-grid modes (day-column views, excluding month and schedule). */
5
- export type TimeGridMode = Exclude<CalendarMode, "month" | "schedule">;
5
+ export type TimeGridMode = Exclude<CalendarMode, "month" | "schedule" | "year">;
6
6
 
7
7
  /**
8
8
  * The minimal shape every calendar event must have. Layout (positioning,
@@ -119,3 +119,7 @@ export const isSameCalendarDay = (a: Date, b: Date): boolean => isSameDay(a, b);
119
119
 
120
120
  /** Minutes elapsed since midnight (0–1439). */
121
121
  export const minutesIntoDay = (date: Date): number => getHours(date) * 60 + getMinutes(date);
122
+
123
+ /** The twelve month anchors (first-of-month) of `date`'s year, January first. */
124
+ export const getYearMonths = (date: Date): Date[] =>
125
+ Array.from({ length: 12 }, (_, i) => new Date(date.getFullYear(), i, 1));