@super-calendar/core 2.16.0 → 2.17.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/README.md +25 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -1
- package/dist/index.mjs +2 -2
- package/dist/{recurrence-CvUX9ncg.mjs → recurrence-CvIJfSMl.mjs} +84 -7
- package/dist/{recurrence-BvmTFytR.js → recurrence-D_oJ7A9D.js} +89 -6
- package/dist/{timezone-d6EaWlvP.d.mts → timezone-vbd68uRS.d.mts} +69 -9
- package/dist/{timezone-d6EaWlvP.d.ts → timezone-vbd68uRS.d.ts} +69 -9
- package/dist/vanilla.d.mts +2 -2
- package/dist/vanilla.d.ts +2 -2
- package/dist/vanilla.js +2 -1
- package/dist/vanilla.mjs +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/types.ts +16 -4
- package/src/utils/dates.ts +10 -1
- package/src/utils/eventDisplay.ts +5 -5
- package/src/utils/multiWeekGrid.ts +139 -0
- package/src/vanilla.ts +1 -0
package/README.md
CHANGED
|
@@ -85,6 +85,31 @@ move and resize dialog. `eventChangeRejected` supplies the web dialog's rejectio
|
|
|
85
85
|
message (default "This change is not allowed."). `resolveCalendarLabels` fills omitted labels with English
|
|
86
86
|
defaults from `defaultCalendarLabels`.
|
|
87
87
|
|
|
88
|
+
## Multi-week grids
|
|
89
|
+
|
|
90
|
+
`buildMultiWeekGrid` is available from both core entries. It builds consecutive
|
|
91
|
+
full weeks without month padding or hourly slots.
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
import { buildMultiWeekGrid } from "@super-calendar/core/vanilla";
|
|
95
|
+
|
|
96
|
+
const grid = buildMultiWeekGrid(new Date(2026, 11, 28), {
|
|
97
|
+
numberOfWeeks: 3,
|
|
98
|
+
weekStartsOn: 1,
|
|
99
|
+
hiddenDays: [0, 6],
|
|
100
|
+
});
|
|
101
|
+
console.log(grid.weeks, grid.period, grid.visibleRange);
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
`numberOfWeeks` defaults to `2` and must be a positive safe integer. Invalid
|
|
105
|
+
dates, invalid counts, and spans outside JavaScript's date range throw
|
|
106
|
+
`RangeError` before allocating rows. The builder materializes O(7 × N) days.
|
|
107
|
+
`period` covers full weeks; `visibleRange` gives the chronological visible
|
|
108
|
+
endpoints after hidden weekdays. Both use `{ start, endExclusive }`. RTL reverses
|
|
109
|
+
row display only. `MultiWeekGridDay` has the month builder's day state without
|
|
110
|
+
`isCurrentMonth`; `MultiWeekGridWeek.id` uses the unfiltered week start.
|
|
111
|
+
`getViewDays` and `viewDayCount` reject `multiweek`, so use this builder for it.
|
|
112
|
+
|
|
88
113
|
## Recurrence limits
|
|
89
114
|
|
|
90
115
|
Recurring-event expansion stops at JavaScript's date limits and omits occurrences
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as titleEllipsizeMode, $t as ICalendarEvent, A as isAllDayEvent, At as DaySelectionState, B as toICalendar, Bt as dayBadgeKind, C as backgroundBandsForDay, Ct as isWeekend, D as drawnEnd, Dt as CalendarSelection, E as compareDayEvents, Et as weekDaysCount, F as EventSourceOptions, Ft as isWithinDateRange, G as MonthEventCapacity, Gt as BusinessHours, H as EventAccessibilityLabeler, Ht as CalendarColors, I as loadEventSource, It as nextDateRange, J as eventTimeLabel, Jt as CalendarEvent, K as eventAccessibilityLabel, Kt as BusinessHoursBand, L as ICalEvent, Lt as DayBadgeKind, M as layoutDayEvents, Mt as daySelectionState, N as wallClockHours, Nt as isDateSelectable, O as eventDayKeys, Ot as DateRange, P as EventSource, Pt as isRangeEndpoint, Q as monthVisibleCount, Qt as EventKeyExtractor, R as ToICalendarOptions, Rt as RangeBandKind, S as PositionedEvent, St as isSameCalendarDay, T as closedHourBands, Tt as viewDayCount, U as EventChipLayout, Ut as darkColors, V as EventAccessibilityLabelContext, Vt as rangeBandKind, W as MIN_BOX_HEIGHT_FOR_TIME, Wt as lightColors, X as isTimeVisibleAtHeight, Xt as CalendarMode, Y as formatHour, Yt as CalendarHandle, Z as monthEventCapacity, Zt as CreateGhostArgs, _ as UseMonthGridOptions, _t as filterHiddenDays, a as MultiWeekGrid, at as cellRangeFromDrag, b as layoutMonthWeek, bt as getWeekDays, c as MultiWeekGridOptions, ct as monthCreateRange, d as MonthEventSegment, dt as overlapsOtherEvents, en as RecurrenceFrequency, et as titleNumberOfLines, f as MonthGrid, ft as pageStepDays, g as MonthWeekEvents, gt as buildMonthWeeks, h as MonthGridWeekday, ht as snapDeltaMinutes, i as expandRecurringEvents, in as WeekStartsOn, it as resolveCalendarLabels, j as isBackgroundEvent, jt as UseDateRangeOptions, k as groupEventsByDay, kt as DateSelectionConstraints, l as MultiWeekGridWeek, lt as monthDropBounds, m as MonthGridWeek, mt as shiftMinutes, n as toZonedTime, nn as ScrollToTimeOptions, nt as dayAccessibilityLabel, o as MultiWeekGridDay, ot as clampMoveStartMinutes, p as MonthGridDay, pt as resolveDraggedBounds, q as eventChipLayout, qt as BusinessHoursValue, r as zonedTimeToUtc, rn as TimeGridMode, rt as defaultCalendarLabels, s as MultiWeekGridInterval, st as eventsOverlap, t as eventsInTimeZone, tn as RecurrenceRule, tt as CalendarLabels, u as buildMultiWeekGrid, ut as movedClockSpan, v as WeekdayFormat, vt as getIsToday, w as clockHoursBetween, wt as minutesIntoDay, x as weekdayFormatToken, xt as getYearMonths, y as buildMonthGrid, yt as getViewDays, z as parseICalendar, zt as bandRounding } from "./timezone-vbd68uRS.mjs";
|
|
2
2
|
import { Dispatch, SetStateAction } from "react";
|
|
3
3
|
/** Options for {@link useNow}. */
|
|
4
4
|
export interface UseNowOptions {
|
|
@@ -91,4 +91,4 @@ export declare function useDateRange(options?: UseDateRangeOptions): UseDateRang
|
|
|
91
91
|
* ```
|
|
92
92
|
*/
|
|
93
93
|
export declare function useMonthGrid(month: Date, options?: UseMonthGridOptions): MonthGrid;
|
|
94
|
-
export { BusinessHours, BusinessHoursBand, BusinessHoursValue, CalendarColors, CalendarEvent, CalendarHandle, CalendarLabels, CalendarMode, CalendarSelection, CreateGhostArgs, DateRange, DateSelectionConstraints, DayBadgeKind, DaySelectionState, EventAccessibilityLabelContext, EventAccessibilityLabeler, EventChipLayout, EventKeyExtractor, EventSource, EventSourceOptions, ICalEvent, ICalendarEvent, MIN_BOX_HEIGHT_FOR_TIME, MonthEventCapacity, MonthEventSegment, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, MonthWeekEvents, PositionedEvent, RangeBandKind, RecurrenceFrequency, RecurrenceRule, ScrollToTimeOptions, TimeGridMode, ToICalendarOptions, UseDateRangeOptions, UseMonthGridOptions, WeekStartsOn, WeekdayFormat, backgroundBandsForDay, bandRounding, buildMonthGrid, buildMonthWeeks, cellRangeFromDrag, clampMoveStartMinutes, clockHoursBetween, closedHourBands, compareDayEvents, darkColors, dayAccessibilityLabel, dayBadgeKind, daySelectionState, defaultCalendarLabels, drawnEnd, eventAccessibilityLabel, eventChipLayout, eventDayKeys, eventTimeLabel, eventsInTimeZone, eventsOverlap, expandRecurringEvents, filterHiddenDays, formatHour, getIsToday, getViewDays, getWeekDays, getYearMonths, groupEventsByDay, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isTimeVisibleAtHeight, isWeekend, isWithinDateRange, layoutDayEvents, layoutMonthWeek, lightColors, loadEventSource, minutesIntoDay, monthCreateRange, monthDropBounds, monthEventCapacity, monthVisibleCount, movedClockSpan, nextDateRange, overlapsOtherEvents, pageStepDays, parseICalendar, rangeBandKind, resolveCalendarLabels, resolveDraggedBounds, shiftMinutes, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, viewDayCount, wallClockHours, weekDaysCount, weekdayFormatToken, zonedTimeToUtc };
|
|
94
|
+
export { BusinessHours, BusinessHoursBand, BusinessHoursValue, CalendarColors, CalendarEvent, CalendarHandle, CalendarLabels, CalendarMode, CalendarSelection, CreateGhostArgs, DateRange, DateSelectionConstraints, DayBadgeKind, DaySelectionState, EventAccessibilityLabelContext, EventAccessibilityLabeler, EventChipLayout, EventKeyExtractor, EventSource, EventSourceOptions, ICalEvent, ICalendarEvent, MIN_BOX_HEIGHT_FOR_TIME, MonthEventCapacity, MonthEventSegment, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, MonthWeekEvents, MultiWeekGrid, MultiWeekGridDay, MultiWeekGridInterval, MultiWeekGridOptions, MultiWeekGridWeek, PositionedEvent, RangeBandKind, RecurrenceFrequency, RecurrenceRule, ScrollToTimeOptions, TimeGridMode, ToICalendarOptions, UseDateRangeOptions, UseMonthGridOptions, WeekStartsOn, WeekdayFormat, backgroundBandsForDay, bandRounding, buildMonthGrid, buildMonthWeeks, buildMultiWeekGrid, cellRangeFromDrag, clampMoveStartMinutes, clockHoursBetween, closedHourBands, compareDayEvents, darkColors, dayAccessibilityLabel, dayBadgeKind, daySelectionState, defaultCalendarLabels, drawnEnd, eventAccessibilityLabel, eventChipLayout, eventDayKeys, eventTimeLabel, eventsInTimeZone, eventsOverlap, expandRecurringEvents, filterHiddenDays, formatHour, getIsToday, getViewDays, getWeekDays, getYearMonths, groupEventsByDay, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isTimeVisibleAtHeight, isWeekend, isWithinDateRange, layoutDayEvents, layoutMonthWeek, lightColors, loadEventSource, minutesIntoDay, monthCreateRange, monthDropBounds, monthEventCapacity, monthVisibleCount, movedClockSpan, nextDateRange, overlapsOtherEvents, pageStepDays, parseICalendar, rangeBandKind, resolveCalendarLabels, resolveDraggedBounds, shiftMinutes, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, viewDayCount, wallClockHours, weekDaysCount, weekdayFormatToken, zonedTimeToUtc };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as titleEllipsizeMode, $t as ICalendarEvent, A as isAllDayEvent, At as DaySelectionState, B as toICalendar, Bt as dayBadgeKind, C as backgroundBandsForDay, Ct as isWeekend, D as drawnEnd, Dt as CalendarSelection, E as compareDayEvents, Et as weekDaysCount, F as EventSourceOptions, Ft as isWithinDateRange, G as MonthEventCapacity, Gt as BusinessHours, H as EventAccessibilityLabeler, Ht as CalendarColors, I as loadEventSource, It as nextDateRange, J as eventTimeLabel, Jt as CalendarEvent, K as eventAccessibilityLabel, Kt as BusinessHoursBand, L as ICalEvent, Lt as DayBadgeKind, M as layoutDayEvents, Mt as daySelectionState, N as wallClockHours, Nt as isDateSelectable, O as eventDayKeys, Ot as DateRange, P as EventSource, Pt as isRangeEndpoint, Q as monthVisibleCount, Qt as EventKeyExtractor, R as ToICalendarOptions, Rt as RangeBandKind, S as PositionedEvent, St as isSameCalendarDay, T as closedHourBands, Tt as viewDayCount, U as EventChipLayout, Ut as darkColors, V as EventAccessibilityLabelContext, Vt as rangeBandKind, W as MIN_BOX_HEIGHT_FOR_TIME, Wt as lightColors, X as isTimeVisibleAtHeight, Xt as CalendarMode, Y as formatHour, Yt as CalendarHandle, Z as monthEventCapacity, Zt as CreateGhostArgs, _ as UseMonthGridOptions, _t as filterHiddenDays, a as MultiWeekGrid, at as cellRangeFromDrag, b as layoutMonthWeek, bt as getWeekDays, c as MultiWeekGridOptions, ct as monthCreateRange, d as MonthEventSegment, dt as overlapsOtherEvents, en as RecurrenceFrequency, et as titleNumberOfLines, f as MonthGrid, ft as pageStepDays, g as MonthWeekEvents, gt as buildMonthWeeks, h as MonthGridWeekday, ht as snapDeltaMinutes, i as expandRecurringEvents, in as WeekStartsOn, it as resolveCalendarLabels, j as isBackgroundEvent, jt as UseDateRangeOptions, k as groupEventsByDay, kt as DateSelectionConstraints, l as MultiWeekGridWeek, lt as monthDropBounds, m as MonthGridWeek, mt as shiftMinutes, n as toZonedTime, nn as ScrollToTimeOptions, nt as dayAccessibilityLabel, o as MultiWeekGridDay, ot as clampMoveStartMinutes, p as MonthGridDay, pt as resolveDraggedBounds, q as eventChipLayout, qt as BusinessHoursValue, r as zonedTimeToUtc, rn as TimeGridMode, rt as defaultCalendarLabels, s as MultiWeekGridInterval, st as eventsOverlap, t as eventsInTimeZone, tn as RecurrenceRule, tt as CalendarLabels, u as buildMultiWeekGrid, ut as movedClockSpan, v as WeekdayFormat, vt as getIsToday, w as clockHoursBetween, wt as minutesIntoDay, x as weekdayFormatToken, xt as getYearMonths, y as buildMonthGrid, yt as getViewDays, z as parseICalendar, zt as bandRounding } from "./timezone-vbd68uRS.js";
|
|
2
2
|
import { Dispatch, SetStateAction } from "react";
|
|
3
3
|
/** Options for {@link useNow}. */
|
|
4
4
|
export interface UseNowOptions {
|
|
@@ -91,4 +91,4 @@ export declare function useDateRange(options?: UseDateRangeOptions): UseDateRang
|
|
|
91
91
|
* ```
|
|
92
92
|
*/
|
|
93
93
|
export declare function useMonthGrid(month: Date, options?: UseMonthGridOptions): MonthGrid;
|
|
94
|
-
export { BusinessHours, BusinessHoursBand, BusinessHoursValue, CalendarColors, CalendarEvent, CalendarHandle, CalendarLabels, CalendarMode, CalendarSelection, CreateGhostArgs, DateRange, DateSelectionConstraints, DayBadgeKind, DaySelectionState, EventAccessibilityLabelContext, EventAccessibilityLabeler, EventChipLayout, EventKeyExtractor, EventSource, EventSourceOptions, ICalEvent, ICalendarEvent, MIN_BOX_HEIGHT_FOR_TIME, MonthEventCapacity, MonthEventSegment, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, MonthWeekEvents, PositionedEvent, RangeBandKind, RecurrenceFrequency, RecurrenceRule, ScrollToTimeOptions, TimeGridMode, ToICalendarOptions, UseDateRangeOptions, UseMonthGridOptions, WeekStartsOn, WeekdayFormat, backgroundBandsForDay, bandRounding, buildMonthGrid, buildMonthWeeks, cellRangeFromDrag, clampMoveStartMinutes, clockHoursBetween, closedHourBands, compareDayEvents, darkColors, dayAccessibilityLabel, dayBadgeKind, daySelectionState, defaultCalendarLabels, drawnEnd, eventAccessibilityLabel, eventChipLayout, eventDayKeys, eventTimeLabel, eventsInTimeZone, eventsOverlap, expandRecurringEvents, filterHiddenDays, formatHour, getIsToday, getViewDays, getWeekDays, getYearMonths, groupEventsByDay, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isTimeVisibleAtHeight, isWeekend, isWithinDateRange, layoutDayEvents, layoutMonthWeek, lightColors, loadEventSource, minutesIntoDay, monthCreateRange, monthDropBounds, monthEventCapacity, monthVisibleCount, movedClockSpan, nextDateRange, overlapsOtherEvents, pageStepDays, parseICalendar, rangeBandKind, resolveCalendarLabels, resolveDraggedBounds, shiftMinutes, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, viewDayCount, wallClockHours, weekDaysCount, weekdayFormatToken, zonedTimeToUtc };
|
|
94
|
+
export { BusinessHours, BusinessHoursBand, BusinessHoursValue, CalendarColors, CalendarEvent, CalendarHandle, CalendarLabels, CalendarMode, CalendarSelection, CreateGhostArgs, DateRange, DateSelectionConstraints, DayBadgeKind, DaySelectionState, EventAccessibilityLabelContext, EventAccessibilityLabeler, EventChipLayout, EventKeyExtractor, EventSource, EventSourceOptions, ICalEvent, ICalendarEvent, MIN_BOX_HEIGHT_FOR_TIME, MonthEventCapacity, MonthEventSegment, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, MonthWeekEvents, MultiWeekGrid, MultiWeekGridDay, MultiWeekGridInterval, MultiWeekGridOptions, MultiWeekGridWeek, PositionedEvent, RangeBandKind, RecurrenceFrequency, RecurrenceRule, ScrollToTimeOptions, TimeGridMode, ToICalendarOptions, UseDateRangeOptions, UseMonthGridOptions, WeekStartsOn, WeekdayFormat, backgroundBandsForDay, bandRounding, buildMonthGrid, buildMonthWeeks, buildMultiWeekGrid, cellRangeFromDrag, clampMoveStartMinutes, clockHoursBetween, closedHourBands, compareDayEvents, darkColors, dayAccessibilityLabel, dayBadgeKind, daySelectionState, defaultCalendarLabels, drawnEnd, eventAccessibilityLabel, eventChipLayout, eventDayKeys, eventTimeLabel, eventsInTimeZone, eventsOverlap, expandRecurringEvents, filterHiddenDays, formatHour, getIsToday, getViewDays, getWeekDays, getYearMonths, groupEventsByDay, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isTimeVisibleAtHeight, isWeekend, isWithinDateRange, layoutDayEvents, layoutMonthWeek, lightColors, loadEventSource, minutesIntoDay, monthCreateRange, monthDropBounds, monthEventCapacity, monthVisibleCount, movedClockSpan, nextDateRange, overlapsOtherEvents, pageStepDays, parseICalendar, rangeBandKind, resolveCalendarLabels, resolveDraggedBounds, shiftMinutes, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, viewDayCount, wallClockHours, weekDaysCount, weekdayFormatToken, zonedTimeToUtc };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_recurrence = require("./recurrence-
|
|
2
|
+
const require_recurrence = require("./recurrence-D_oJ7A9D.js");
|
|
3
3
|
let date_fns = require("date-fns");
|
|
4
4
|
let react = require("react");
|
|
5
5
|
// src/utils/useNow.ts
|
|
@@ -193,6 +193,7 @@ exports.backgroundBandsForDay = require_recurrence.backgroundBandsForDay;
|
|
|
193
193
|
exports.bandRounding = require_recurrence.bandRounding;
|
|
194
194
|
exports.buildMonthGrid = require_recurrence.buildMonthGrid;
|
|
195
195
|
exports.buildMonthWeeks = require_recurrence.buildMonthWeeks;
|
|
196
|
+
exports.buildMultiWeekGrid = require_recurrence.buildMultiWeekGrid;
|
|
196
197
|
exports.cellRangeFromDrag = require_recurrence.cellRangeFromDrag;
|
|
197
198
|
exports.clampMoveStartMinutes = require_recurrence.clampMoveStartMinutes;
|
|
198
199
|
exports.clockHoursBetween = require_recurrence.clockHoursBetween;
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as filterHiddenDays, A as movedClockSpan, B as drawnEnd, C as defaultCalendarLabels, D as eventsOverlap, E as clampMoveStartMinutes, F as snapDeltaMinutes, G as layoutDayEvents, H as groupEventsByDay, I as backgroundBandsForDay, J as isDateSelectable, K as wallClockHours, L as clockHoursBetween, M as pageStepDays, N as resolveDraggedBounds, O as monthCreateRange, P as shiftMinutes, Q as buildMonthWeeks, R as closedHourBands, S as dayAccessibilityLabel, T as cellRangeFromDrag, U as isAllDayEvent, V as eventDayKeys, W as isBackgroundEvent, X as isWithinDateRange, Y as isRangeEndpoint, Z as nextDateRange, _ as isTimeVisibleAtHeight, a as weekdayFormatToken, at as isWeekend, b as titleEllipsizeMode, c as toICalendar, ct as weekDaysCount, d as zonedTimeToUtc, dt as rangeBandKind, et as getIsToday, f as MIN_BOX_HEIGHT_FOR_TIME, ft as darkColors, g as formatHour, h as eventTimeLabel, i as layoutMonthWeek, it as isSameCalendarDay, j as overlapsOtherEvents, k as monthDropBounds, l as eventsInTimeZone, lt as bandRounding, m as eventChipLayout, n as buildMultiWeekGrid, nt as getWeekDays, o as loadEventSource, ot as minutesIntoDay, p as eventAccessibilityLabel, pt as lightColors, q as daySelectionState, r as buildMonthGrid, rt as getYearMonths, s as parseICalendar, st as viewDayCount, t as expandRecurringEvents, tt as getViewDays, u as toZonedTime, ut as dayBadgeKind, v as monthEventCapacity, w as resolveCalendarLabels, x as titleNumberOfLines, y as monthVisibleCount, z as compareDayEvents } from "./recurrence-CvIJfSMl.mjs";
|
|
2
2
|
import { startOfDay } from "date-fns";
|
|
3
3
|
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
4
4
|
// src/utils/useNow.ts
|
|
@@ -186,4 +186,4 @@ function useMonthGrid(month, options = {}) {
|
|
|
186
186
|
locale
|
|
187
187
|
]);
|
|
188
188
|
}
|
|
189
|
-
export { CalendarSelectionProvider, MIN_BOX_HEIGHT_FOR_TIME, backgroundBandsForDay, bandRounding, buildMonthGrid, buildMonthWeeks, cellRangeFromDrag, clampMoveStartMinutes, clockHoursBetween, closedHourBands, compareDayEvents, darkColors, dayAccessibilityLabel, dayBadgeKind, daySelectionState, defaultCalendarLabels, drawnEnd, eventAccessibilityLabel, eventChipLayout, eventDayKeys, eventTimeLabel, eventsInTimeZone, eventsOverlap, expandRecurringEvents, filterHiddenDays, formatHour, getIsToday, getViewDays, getWeekDays, getYearMonths, groupEventsByDay, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isTimeVisibleAtHeight, isWeekend, isWithinDateRange, layoutDayEvents, layoutMonthWeek, lightColors, loadEventSource, minutesIntoDay, monthCreateRange, monthDropBounds, monthEventCapacity, monthVisibleCount, movedClockSpan, nextDateRange, overlapsOtherEvents, pageStepDays, parseICalendar, rangeBandKind, resolveCalendarLabels, resolveDraggedBounds, shiftMinutes, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, useCalendarSelection, useDateRange, useEventSource, useMonthGrid, useNow, viewDayCount, wallClockHours, weekDaysCount, weekdayFormatToken, zonedTimeToUtc };
|
|
189
|
+
export { CalendarSelectionProvider, MIN_BOX_HEIGHT_FOR_TIME, backgroundBandsForDay, bandRounding, buildMonthGrid, buildMonthWeeks, buildMultiWeekGrid, cellRangeFromDrag, clampMoveStartMinutes, clockHoursBetween, closedHourBands, compareDayEvents, darkColors, dayAccessibilityLabel, dayBadgeKind, daySelectionState, defaultCalendarLabels, drawnEnd, eventAccessibilityLabel, eventChipLayout, eventDayKeys, eventTimeLabel, eventsInTimeZone, eventsOverlap, expandRecurringEvents, filterHiddenDays, formatHour, getIsToday, getViewDays, getWeekDays, getYearMonths, groupEventsByDay, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isTimeVisibleAtHeight, isWeekend, isWithinDateRange, layoutDayEvents, layoutMonthWeek, lightColors, loadEventSource, minutesIntoDay, monthCreateRange, monthDropBounds, monthEventCapacity, monthVisibleCount, movedClockSpan, nextDateRange, overlapsOtherEvents, pageStepDays, parseICalendar, rangeBandKind, resolveCalendarLabels, resolveDraggedBounds, shiftMinutes, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, useCalendarSelection, useDateRange, useEventSource, useMonthGrid, useNow, viewDayCount, wallClockHours, weekDaysCount, weekdayFormatToken, zonedTimeToUtc };
|
|
@@ -71,12 +71,17 @@ const getWeekDays = (date, weekStartsOn) => {
|
|
|
71
71
|
const start = startOfWeek(date, { weekStartsOn });
|
|
72
72
|
return Array.from({ length: 7 }, (_, index) => addDays(start, index));
|
|
73
73
|
};
|
|
74
|
-
/**
|
|
74
|
+
/**
|
|
75
|
+
* How many day columns a time-grid mode shows. `custom` uses `numberOfDays`.
|
|
76
|
+
* Throws a `RangeError` for `multiweek`, which has week rows instead of day
|
|
77
|
+
* columns; use `buildMultiWeekGrid` for it.
|
|
78
|
+
*/
|
|
75
79
|
const viewDayCount = (mode, numberOfDays = 1) => {
|
|
76
80
|
switch (mode) {
|
|
77
81
|
case "week": return 7;
|
|
78
82
|
case "3days": return 3;
|
|
79
83
|
case "custom": return Math.max(1, Math.floor(numberOfDays));
|
|
84
|
+
case "multiweek": throw new RangeError("The multiweek mode has week rows, not day columns. Use buildMultiWeekGrid for its days.");
|
|
80
85
|
default: return 1;
|
|
81
86
|
}
|
|
82
87
|
};
|
|
@@ -103,6 +108,7 @@ const weekDaysCount = (weekStartsOn, weekEndsOn) => {
|
|
|
103
108
|
* (honouring `weekStartsOn`). `custom` with a `weekEndsOn` spans the partial week
|
|
104
109
|
* from `weekStartsOn` to `weekEndsOn` (anchored to `date`'s week, paging by week);
|
|
105
110
|
* otherwise every mode shows `viewDayCount` consecutive days starting at `date`.
|
|
111
|
+
* Throws a `RangeError` for `multiweek` (see `viewDayCount`).
|
|
106
112
|
*/
|
|
107
113
|
const getViewDays = (mode, date, weekStartsOn, numberOfDays = 1, isRTL = false, weekEndsOn, hiddenDays) => {
|
|
108
114
|
const hidden = hiddenDays && hiddenDays.length > 0 && hiddenDays.length < 7 ? hiddenDays : [];
|
|
@@ -700,21 +706,21 @@ function eventAccessibilityLabel(args) {
|
|
|
700
706
|
return [args.title, time].filter(Boolean).join(", ");
|
|
701
707
|
}
|
|
702
708
|
/**
|
|
703
|
-
* Month cells and the all-day lane show a single clipped line;
|
|
704
|
-
* (`undefined`) wrap to fill the box.
|
|
709
|
+
* Month and multi-week cells and the all-day lane show a single clipped line;
|
|
710
|
+
* timed-grid titles (`undefined`) wrap to fill the box.
|
|
705
711
|
*/
|
|
706
712
|
function titleNumberOfLines(mode, isAllDay) {
|
|
707
|
-
return mode === "month" || isAllDay ? 1 : void 0;
|
|
713
|
+
return mode === "month" || mode === "multiweek" || isAllDay ? 1 : void 0;
|
|
708
714
|
}
|
|
709
715
|
/**
|
|
710
716
|
* The secondary line under the title in the built-in renderer, or `null` when
|
|
711
717
|
* none should show. Timed events get their `start - end` range. An all-day event
|
|
712
718
|
* gets the literal "All day" in the schedule (which has no all-day lane to
|
|
713
719
|
* signal it positionally) and nothing on the day/week grid (the lane already
|
|
714
|
-
* does). Month cells and `showTime={false}` always return `null`.
|
|
720
|
+
* does). Month and multi-week cells and `showTime={false}` always return `null`.
|
|
715
721
|
*/
|
|
716
722
|
function eventTimeLabel(args) {
|
|
717
|
-
if (!args.showTime || args.mode === "month") return null;
|
|
723
|
+
if (!args.showTime || args.mode === "month" || args.mode === "multiweek") return null;
|
|
718
724
|
if (args.isAllDay) return args.mode === "schedule" ? args.allDayLabel ?? "All day" : null;
|
|
719
725
|
const timeFormat = args.ampm ? "h:mm a" : "HH:mm";
|
|
720
726
|
return `${format(args.start, timeFormat)} - ${format(args.end, timeFormat)}`;
|
|
@@ -1368,6 +1374,77 @@ function buildMonthGrid(month, options = {}) {
|
|
|
1368
1374
|
}))
|
|
1369
1375
|
};
|
|
1370
1376
|
}
|
|
1377
|
+
// src/utils/multiWeekGrid.ts
|
|
1378
|
+
/**
|
|
1379
|
+
* Pure multi-week builder: `numberOfWeeks` consecutive full calendar weeks,
|
|
1380
|
+
* starting with the week that contains `date` (aligned back to `weekStartsOn`).
|
|
1381
|
+
* Each day carries the same selection, disabled, today, and weekend state as
|
|
1382
|
+
* {@link buildMonthGrid}. Hidden weekdays shrink the rows without changing the
|
|
1383
|
+
* period; `isRTL` reverses each row's display order.
|
|
1384
|
+
*
|
|
1385
|
+
* The result is fully materialized, so its size grows with `numberOfWeeks`.
|
|
1386
|
+
*
|
|
1387
|
+
* @throws RangeError when `date` is invalid, `numberOfWeeks` is not a positive
|
|
1388
|
+
* safe integer, or the last week falls outside the range `Date` can represent.
|
|
1389
|
+
*/
|
|
1390
|
+
function buildMultiWeekGrid(date, options = {}) {
|
|
1391
|
+
const { numberOfWeeks = 2, weekStartsOn = 0, weekdayFormat = "short", isRTL = false, hiddenDays, selectedDates, selectedRange, minDate, maxDate, isDateDisabled, locale } = options;
|
|
1392
|
+
if (!(date instanceof Date) || Number.isNaN(date.getTime())) throw new RangeError("buildMultiWeekGrid: date must be a valid Date.");
|
|
1393
|
+
if (!Number.isSafeInteger(numberOfWeeks) || numberOfWeeks < 1) throw new RangeError(`buildMultiWeekGrid: numberOfWeeks must be a positive whole number, received ${String(numberOfWeeks)}.`);
|
|
1394
|
+
const start = startOfWeek(date, { weekStartsOn });
|
|
1395
|
+
const endExclusive = addDays(start, numberOfWeeks * 7);
|
|
1396
|
+
if (Number.isNaN(endExclusive.getTime())) throw new RangeError(`buildMultiWeekGrid: ${numberOfWeeks} weeks from ${format(start, "yyyy-MM-dd")} cannot be represented as a Date.`);
|
|
1397
|
+
const constraints = {
|
|
1398
|
+
minDate,
|
|
1399
|
+
maxDate,
|
|
1400
|
+
isDateDisabled
|
|
1401
|
+
};
|
|
1402
|
+
const selection = {
|
|
1403
|
+
selectedDates,
|
|
1404
|
+
selectedRange
|
|
1405
|
+
};
|
|
1406
|
+
let first = null;
|
|
1407
|
+
let last = null;
|
|
1408
|
+
const weeks = [];
|
|
1409
|
+
for (let row = 0; row < numberOfWeeks; row++) {
|
|
1410
|
+
const weekStart = addDays(start, row * 7);
|
|
1411
|
+
const all = Array.from({ length: 7 }, (_, index) => addDays(weekStart, index));
|
|
1412
|
+
const visible = filterHiddenDays(all, hiddenDays);
|
|
1413
|
+
if (visible.length > 0) {
|
|
1414
|
+
if (first === null) first = visible[0];
|
|
1415
|
+
last = visible[visible.length - 1];
|
|
1416
|
+
}
|
|
1417
|
+
const ordered = isRTL ? [...visible].reverse() : visible;
|
|
1418
|
+
weeks.push({
|
|
1419
|
+
id: format(weekStart, "yyyy-MM-dd"),
|
|
1420
|
+
days: ordered.map((day) => ({
|
|
1421
|
+
date: day,
|
|
1422
|
+
id: format(day, "yyyy-MM-dd"),
|
|
1423
|
+
label: format(day, "d"),
|
|
1424
|
+
isToday: getIsToday(day),
|
|
1425
|
+
isWeekend: isWeekend(day),
|
|
1426
|
+
...daySelectionState(day, selection, constraints)
|
|
1427
|
+
}))
|
|
1428
|
+
});
|
|
1429
|
+
}
|
|
1430
|
+
const token = weekdayFormatToken(weekdayFormat);
|
|
1431
|
+
const weekdays = weeks[0].days.map((day) => ({
|
|
1432
|
+
date: day.date,
|
|
1433
|
+
label: format(day.date, token, { locale })
|
|
1434
|
+
}));
|
|
1435
|
+
return {
|
|
1436
|
+
period: {
|
|
1437
|
+
start,
|
|
1438
|
+
endExclusive
|
|
1439
|
+
},
|
|
1440
|
+
visibleRange: {
|
|
1441
|
+
start: first ?? start,
|
|
1442
|
+
endExclusive: last ? addDays(last, 1) : endExclusive
|
|
1443
|
+
},
|
|
1444
|
+
weeks,
|
|
1445
|
+
weekdays
|
|
1446
|
+
};
|
|
1447
|
+
}
|
|
1371
1448
|
// src/utils/recurrence.ts
|
|
1372
1449
|
const STEP = {
|
|
1373
1450
|
daily: addDays,
|
|
@@ -1545,4 +1622,4 @@ function expandRecurringEvents(events, rangeStart, rangeEnd) {
|
|
|
1545
1622
|
}
|
|
1546
1623
|
return out;
|
|
1547
1624
|
}
|
|
1548
|
-
export {
|
|
1625
|
+
export { filterHiddenDays as $, movedClockSpan as A, drawnEnd as B, defaultCalendarLabels as C, eventsOverlap as D, clampMoveStartMinutes as E, snapDeltaMinutes as F, layoutDayEvents as G, groupEventsByDay as H, backgroundBandsForDay as I, isDateSelectable as J, wallClockHours as K, clockHoursBetween as L, pageStepDays as M, resolveDraggedBounds as N, monthCreateRange as O, shiftMinutes as P, buildMonthWeeks as Q, closedHourBands as R, dayAccessibilityLabel as S, cellRangeFromDrag as T, isAllDayEvent as U, eventDayKeys as V, isBackgroundEvent as W, isWithinDateRange as X, isRangeEndpoint as Y, nextDateRange as Z, isTimeVisibleAtHeight as _, weekdayFormatToken as a, isWeekend as at, titleEllipsizeMode as b, toICalendar as c, weekDaysCount as ct, zonedTimeToUtc as d, rangeBandKind as dt, getIsToday as et, MIN_BOX_HEIGHT_FOR_TIME as f, darkColors as ft, formatHour as g, eventTimeLabel as h, layoutMonthWeek as i, isSameCalendarDay as it, overlapsOtherEvents as j, monthDropBounds as k, eventsInTimeZone as l, bandRounding as lt, eventChipLayout as m, buildMultiWeekGrid as n, getWeekDays as nt, loadEventSource as o, minutesIntoDay as ot, eventAccessibilityLabel as p, lightColors as pt, daySelectionState as q, buildMonthGrid as r, getYearMonths as rt, parseICalendar as s, viewDayCount as st, expandRecurringEvents as t, getViewDays as tt, toZonedTime as u, dayBadgeKind as ut, monthEventCapacity as v, resolveCalendarLabels as w, titleNumberOfLines as x, monthVisibleCount as y, compareDayEvents as z };
|
|
@@ -71,12 +71,17 @@ const getWeekDays = (date, weekStartsOn) => {
|
|
|
71
71
|
const start = (0, date_fns.startOfWeek)(date, { weekStartsOn });
|
|
72
72
|
return Array.from({ length: 7 }, (_, index) => (0, date_fns.addDays)(start, index));
|
|
73
73
|
};
|
|
74
|
-
/**
|
|
74
|
+
/**
|
|
75
|
+
* How many day columns a time-grid mode shows. `custom` uses `numberOfDays`.
|
|
76
|
+
* Throws a `RangeError` for `multiweek`, which has week rows instead of day
|
|
77
|
+
* columns; use `buildMultiWeekGrid` for it.
|
|
78
|
+
*/
|
|
75
79
|
const viewDayCount = (mode, numberOfDays = 1) => {
|
|
76
80
|
switch (mode) {
|
|
77
81
|
case "week": return 7;
|
|
78
82
|
case "3days": return 3;
|
|
79
83
|
case "custom": return Math.max(1, Math.floor(numberOfDays));
|
|
84
|
+
case "multiweek": throw new RangeError("The multiweek mode has week rows, not day columns. Use buildMultiWeekGrid for its days.");
|
|
80
85
|
default: return 1;
|
|
81
86
|
}
|
|
82
87
|
};
|
|
@@ -103,6 +108,7 @@ const weekDaysCount = (weekStartsOn, weekEndsOn) => {
|
|
|
103
108
|
* (honouring `weekStartsOn`). `custom` with a `weekEndsOn` spans the partial week
|
|
104
109
|
* from `weekStartsOn` to `weekEndsOn` (anchored to `date`'s week, paging by week);
|
|
105
110
|
* otherwise every mode shows `viewDayCount` consecutive days starting at `date`.
|
|
111
|
+
* Throws a `RangeError` for `multiweek` (see `viewDayCount`).
|
|
106
112
|
*/
|
|
107
113
|
const getViewDays = (mode, date, weekStartsOn, numberOfDays = 1, isRTL = false, weekEndsOn, hiddenDays) => {
|
|
108
114
|
const hidden = hiddenDays && hiddenDays.length > 0 && hiddenDays.length < 7 ? hiddenDays : [];
|
|
@@ -700,21 +706,21 @@ function eventAccessibilityLabel(args) {
|
|
|
700
706
|
return [args.title, time].filter(Boolean).join(", ");
|
|
701
707
|
}
|
|
702
708
|
/**
|
|
703
|
-
* Month cells and the all-day lane show a single clipped line;
|
|
704
|
-
* (`undefined`) wrap to fill the box.
|
|
709
|
+
* Month and multi-week cells and the all-day lane show a single clipped line;
|
|
710
|
+
* timed-grid titles (`undefined`) wrap to fill the box.
|
|
705
711
|
*/
|
|
706
712
|
function titleNumberOfLines(mode, isAllDay) {
|
|
707
|
-
return mode === "month" || isAllDay ? 1 : void 0;
|
|
713
|
+
return mode === "month" || mode === "multiweek" || isAllDay ? 1 : void 0;
|
|
708
714
|
}
|
|
709
715
|
/**
|
|
710
716
|
* The secondary line under the title in the built-in renderer, or `null` when
|
|
711
717
|
* none should show. Timed events get their `start - end` range. An all-day event
|
|
712
718
|
* gets the literal "All day" in the schedule (which has no all-day lane to
|
|
713
719
|
* signal it positionally) and nothing on the day/week grid (the lane already
|
|
714
|
-
* does). Month cells and `showTime={false}` always return `null`.
|
|
720
|
+
* does). Month and multi-week cells and `showTime={false}` always return `null`.
|
|
715
721
|
*/
|
|
716
722
|
function eventTimeLabel(args) {
|
|
717
|
-
if (!args.showTime || args.mode === "month") return null;
|
|
723
|
+
if (!args.showTime || args.mode === "month" || args.mode === "multiweek") return null;
|
|
718
724
|
if (args.isAllDay) return args.mode === "schedule" ? args.allDayLabel ?? "All day" : null;
|
|
719
725
|
const timeFormat = args.ampm ? "h:mm a" : "HH:mm";
|
|
720
726
|
return `${(0, date_fns.format)(args.start, timeFormat)} - ${(0, date_fns.format)(args.end, timeFormat)}`;
|
|
@@ -1368,6 +1374,77 @@ function buildMonthGrid(month, options = {}) {
|
|
|
1368
1374
|
}))
|
|
1369
1375
|
};
|
|
1370
1376
|
}
|
|
1377
|
+
// src/utils/multiWeekGrid.ts
|
|
1378
|
+
/**
|
|
1379
|
+
* Pure multi-week builder: `numberOfWeeks` consecutive full calendar weeks,
|
|
1380
|
+
* starting with the week that contains `date` (aligned back to `weekStartsOn`).
|
|
1381
|
+
* Each day carries the same selection, disabled, today, and weekend state as
|
|
1382
|
+
* {@link buildMonthGrid}. Hidden weekdays shrink the rows without changing the
|
|
1383
|
+
* period; `isRTL` reverses each row's display order.
|
|
1384
|
+
*
|
|
1385
|
+
* The result is fully materialized, so its size grows with `numberOfWeeks`.
|
|
1386
|
+
*
|
|
1387
|
+
* @throws RangeError when `date` is invalid, `numberOfWeeks` is not a positive
|
|
1388
|
+
* safe integer, or the last week falls outside the range `Date` can represent.
|
|
1389
|
+
*/
|
|
1390
|
+
function buildMultiWeekGrid(date, options = {}) {
|
|
1391
|
+
const { numberOfWeeks = 2, weekStartsOn = 0, weekdayFormat = "short", isRTL = false, hiddenDays, selectedDates, selectedRange, minDate, maxDate, isDateDisabled, locale } = options;
|
|
1392
|
+
if (!(date instanceof Date) || Number.isNaN(date.getTime())) throw new RangeError("buildMultiWeekGrid: date must be a valid Date.");
|
|
1393
|
+
if (!Number.isSafeInteger(numberOfWeeks) || numberOfWeeks < 1) throw new RangeError(`buildMultiWeekGrid: numberOfWeeks must be a positive whole number, received ${String(numberOfWeeks)}.`);
|
|
1394
|
+
const start = (0, date_fns.startOfWeek)(date, { weekStartsOn });
|
|
1395
|
+
const endExclusive = (0, date_fns.addDays)(start, numberOfWeeks * 7);
|
|
1396
|
+
if (Number.isNaN(endExclusive.getTime())) throw new RangeError(`buildMultiWeekGrid: ${numberOfWeeks} weeks from ${(0, date_fns.format)(start, "yyyy-MM-dd")} cannot be represented as a Date.`);
|
|
1397
|
+
const constraints = {
|
|
1398
|
+
minDate,
|
|
1399
|
+
maxDate,
|
|
1400
|
+
isDateDisabled
|
|
1401
|
+
};
|
|
1402
|
+
const selection = {
|
|
1403
|
+
selectedDates,
|
|
1404
|
+
selectedRange
|
|
1405
|
+
};
|
|
1406
|
+
let first = null;
|
|
1407
|
+
let last = null;
|
|
1408
|
+
const weeks = [];
|
|
1409
|
+
for (let row = 0; row < numberOfWeeks; row++) {
|
|
1410
|
+
const weekStart = (0, date_fns.addDays)(start, row * 7);
|
|
1411
|
+
const all = Array.from({ length: 7 }, (_, index) => (0, date_fns.addDays)(weekStart, index));
|
|
1412
|
+
const visible = filterHiddenDays(all, hiddenDays);
|
|
1413
|
+
if (visible.length > 0) {
|
|
1414
|
+
if (first === null) first = visible[0];
|
|
1415
|
+
last = visible[visible.length - 1];
|
|
1416
|
+
}
|
|
1417
|
+
const ordered = isRTL ? [...visible].reverse() : visible;
|
|
1418
|
+
weeks.push({
|
|
1419
|
+
id: (0, date_fns.format)(weekStart, "yyyy-MM-dd"),
|
|
1420
|
+
days: ordered.map((day) => ({
|
|
1421
|
+
date: day,
|
|
1422
|
+
id: (0, date_fns.format)(day, "yyyy-MM-dd"),
|
|
1423
|
+
label: (0, date_fns.format)(day, "d"),
|
|
1424
|
+
isToday: getIsToday(day),
|
|
1425
|
+
isWeekend: isWeekend(day),
|
|
1426
|
+
...daySelectionState(day, selection, constraints)
|
|
1427
|
+
}))
|
|
1428
|
+
});
|
|
1429
|
+
}
|
|
1430
|
+
const token = weekdayFormatToken(weekdayFormat);
|
|
1431
|
+
const weekdays = weeks[0].days.map((day) => ({
|
|
1432
|
+
date: day.date,
|
|
1433
|
+
label: (0, date_fns.format)(day.date, token, { locale })
|
|
1434
|
+
}));
|
|
1435
|
+
return {
|
|
1436
|
+
period: {
|
|
1437
|
+
start,
|
|
1438
|
+
endExclusive
|
|
1439
|
+
},
|
|
1440
|
+
visibleRange: {
|
|
1441
|
+
start: first ?? start,
|
|
1442
|
+
endExclusive: last ? (0, date_fns.addDays)(last, 1) : endExclusive
|
|
1443
|
+
},
|
|
1444
|
+
weeks,
|
|
1445
|
+
weekdays
|
|
1446
|
+
};
|
|
1447
|
+
}
|
|
1371
1448
|
// src/utils/recurrence.ts
|
|
1372
1449
|
const STEP = {
|
|
1373
1450
|
daily: date_fns.addDays,
|
|
@@ -1575,6 +1652,12 @@ Object.defineProperty(exports, "buildMonthWeeks", {
|
|
|
1575
1652
|
return buildMonthWeeks;
|
|
1576
1653
|
}
|
|
1577
1654
|
});
|
|
1655
|
+
Object.defineProperty(exports, "buildMultiWeekGrid", {
|
|
1656
|
+
enumerable: true,
|
|
1657
|
+
get: function() {
|
|
1658
|
+
return buildMultiWeekGrid;
|
|
1659
|
+
}
|
|
1660
|
+
});
|
|
1578
1661
|
Object.defineProperty(exports, "cellRangeFromDrag", {
|
|
1579
1662
|
enumerable: true,
|
|
1580
1663
|
get: function() {
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { Locale } from "date-fns";
|
|
2
|
-
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
/**
|
|
3
|
+
* The view the calendar renders: a day-column grid (`day`, `3days`, `week`,
|
|
4
|
+
* `custom`), the `month` grid, consecutive week rows (`multiweek`), the
|
|
5
|
+
* `schedule` list, or the `year` overview.
|
|
6
|
+
*/
|
|
7
|
+
type CalendarMode = "day" | "3days" | "week" | "custom" | "month" | "multiweek" | "schedule" | "year";
|
|
8
|
+
/** The time-grid modes (day-column views, excluding the month, multi-week, schedule, and year views). */
|
|
9
|
+
type TimeGridMode = Exclude<CalendarMode, "month" | "multiweek" | "schedule" | "year">;
|
|
6
10
|
/**
|
|
7
11
|
* The minimal shape every calendar event must have. Layout (positioning,
|
|
8
12
|
* overlap resolution, paging) only ever reads `start`/`end`; `title` is used by
|
|
@@ -323,7 +327,11 @@ interface UseDateRangeOptions extends DateSelectionConstraints {
|
|
|
323
327
|
}
|
|
324
328
|
/** The seven dates of the week containing `date`, starting on `weekStartsOn`. */
|
|
325
329
|
declare const getWeekDays: (date: Date, weekStartsOn: WeekStartsOn) => Date[];
|
|
326
|
-
/**
|
|
330
|
+
/**
|
|
331
|
+
* How many day columns a time-grid mode shows. `custom` uses `numberOfDays`.
|
|
332
|
+
* Throws a `RangeError` for `multiweek`, which has week rows instead of day
|
|
333
|
+
* columns; use `buildMultiWeekGrid` for it.
|
|
334
|
+
*/
|
|
327
335
|
declare const viewDayCount: (mode: CalendarMode, numberOfDays?: number) => number;
|
|
328
336
|
/**
|
|
329
337
|
* Days in the inclusive span from `weekStartsOn` to `weekEndsOn` (1–7),
|
|
@@ -336,6 +344,7 @@ declare const weekDaysCount: (weekStartsOn: WeekStartsOn, weekEndsOn: WeekStarts
|
|
|
336
344
|
* (honouring `weekStartsOn`). `custom` with a `weekEndsOn` spans the partial week
|
|
337
345
|
* from `weekStartsOn` to `weekEndsOn` (anchored to `date`'s week, paging by week);
|
|
338
346
|
* otherwise every mode shows `viewDayCount` consecutive days starting at `date`.
|
|
347
|
+
* Throws a `RangeError` for `multiweek` (see `viewDayCount`).
|
|
339
348
|
*/
|
|
340
349
|
declare const getViewDays: (mode: CalendarMode, date: Date, weekStartsOn: WeekStartsOn, numberOfDays?: number, isRTL?: boolean, weekEndsOn?: WeekStartsOn, hiddenDays?: number[]) => Date[];
|
|
341
350
|
/**
|
|
@@ -586,8 +595,8 @@ interface EventAccessibilityLabelContext {
|
|
|
586
595
|
*/
|
|
587
596
|
type EventAccessibilityLabeler<T = unknown> = (event: CalendarEvent<T>, context: EventAccessibilityLabelContext) => string;
|
|
588
597
|
/**
|
|
589
|
-
* Month cells and the all-day lane show a single clipped line;
|
|
590
|
-
* (`undefined`) wrap to fill the box.
|
|
598
|
+
* Month and multi-week cells and the all-day lane show a single clipped line;
|
|
599
|
+
* timed-grid titles (`undefined`) wrap to fill the box.
|
|
591
600
|
*/
|
|
592
601
|
declare function titleNumberOfLines(mode: CalendarMode, isAllDay: boolean): number | undefined;
|
|
593
602
|
/**
|
|
@@ -595,7 +604,7 @@ declare function titleNumberOfLines(mode: CalendarMode, isAllDay: boolean): numb
|
|
|
595
604
|
* none should show. Timed events get their `start - end` range. An all-day event
|
|
596
605
|
* gets the literal "All day" in the schedule (which has no all-day lane to
|
|
597
606
|
* signal it positionally) and nothing on the day/week grid (the lane already
|
|
598
|
-
* does). Month cells and `showTime={false}` always return `null`.
|
|
607
|
+
* does). Month and multi-week cells and `showTime={false}` always return `null`.
|
|
599
608
|
*/
|
|
600
609
|
declare function eventTimeLabel(args: {
|
|
601
610
|
mode: CalendarMode;
|
|
@@ -961,6 +970,57 @@ interface UseMonthGridOptions extends DateSelectionConstraints {
|
|
|
961
970
|
* data outside React; inside a component prefer {@link useMonthGrid}.
|
|
962
971
|
*/
|
|
963
972
|
declare function buildMonthGrid(month: Date, options?: UseMonthGridOptions): MonthGrid;
|
|
973
|
+
/** Options for {@link buildMultiWeekGrid}. */
|
|
974
|
+
interface MultiWeekGridOptions extends Omit<UseMonthGridOptions, "showSixWeeks"> {
|
|
975
|
+
/**
|
|
976
|
+
* How many consecutive full weeks to show. A positive whole number; default 2.
|
|
977
|
+
* Other values throw a `RangeError`.
|
|
978
|
+
*/
|
|
979
|
+
numberOfWeeks?: number;
|
|
980
|
+
}
|
|
981
|
+
/**
|
|
982
|
+
* A day in a multi-week grid. Every day of the grid belongs to the requested
|
|
983
|
+
* period, so it carries no month-membership flag.
|
|
984
|
+
*/
|
|
985
|
+
type MultiWeekGridDay = Omit<MonthGridDay, "isCurrentMonth">;
|
|
986
|
+
/** One week row of a {@link MultiWeekGrid}. */
|
|
987
|
+
interface MultiWeekGridWeek {
|
|
988
|
+
/** The week's first calendar day as `yyyy-MM-dd`, before hidden days are removed. */
|
|
989
|
+
id: string;
|
|
990
|
+
/** The row's days in display order, without hidden weekdays. */
|
|
991
|
+
days: MultiWeekGridDay[];
|
|
992
|
+
}
|
|
993
|
+
/** A half-open local calendar interval, `[start, endExclusive)`. */
|
|
994
|
+
interface MultiWeekGridInterval {
|
|
995
|
+
/** Midnight of the first day. */
|
|
996
|
+
start: Date;
|
|
997
|
+
/** Midnight after the last day. */
|
|
998
|
+
endExclusive: Date;
|
|
999
|
+
}
|
|
1000
|
+
/** The rows, weekday headers, and date bounds of a multi-week grid. */
|
|
1001
|
+
interface MultiWeekGrid {
|
|
1002
|
+
/** Every calendar day of the requested weeks, independent of hidden weekdays and RTL. */
|
|
1003
|
+
period: MultiWeekGridInterval;
|
|
1004
|
+
/** From the earliest to the latest displayed day; hidden days inside it stay hidden. */
|
|
1005
|
+
visibleRange: MultiWeekGridInterval;
|
|
1006
|
+
/** The week rows, oldest first. */
|
|
1007
|
+
weeks: MultiWeekGridWeek[];
|
|
1008
|
+
/** The weekday header cells, in display order. */
|
|
1009
|
+
weekdays: MonthGridWeekday[];
|
|
1010
|
+
}
|
|
1011
|
+
/**
|
|
1012
|
+
* Pure multi-week builder: `numberOfWeeks` consecutive full calendar weeks,
|
|
1013
|
+
* starting with the week that contains `date` (aligned back to `weekStartsOn`).
|
|
1014
|
+
* Each day carries the same selection, disabled, today, and weekend state as
|
|
1015
|
+
* {@link buildMonthGrid}. Hidden weekdays shrink the rows without changing the
|
|
1016
|
+
* period; `isRTL` reverses each row's display order.
|
|
1017
|
+
*
|
|
1018
|
+
* The result is fully materialized, so its size grows with `numberOfWeeks`.
|
|
1019
|
+
*
|
|
1020
|
+
* @throws RangeError when `date` is invalid, `numberOfWeeks` is not a positive
|
|
1021
|
+
* safe integer, or the last week falls outside the range `Date` can represent.
|
|
1022
|
+
*/
|
|
1023
|
+
declare function buildMultiWeekGrid(date: Date, options?: MultiWeekGridOptions): MultiWeekGrid;
|
|
964
1024
|
/**
|
|
965
1025
|
* Materialise recurring events into concrete occurrences overlapping
|
|
966
1026
|
* `[rangeStart, rangeEnd]`. Non-recurring events pass through untouched, so the
|
|
@@ -993,4 +1053,4 @@ declare function zonedTimeToUtc(wallClock: Date, timeZone: string): Date;
|
|
|
993
1053
|
* (e.g. with `useMemo`) since it allocates new dates.
|
|
994
1054
|
*/
|
|
995
1055
|
declare function eventsInTimeZone<T>(events: CalendarEvent<T>[], timeZone: string): CalendarEvent<T>[];
|
|
996
|
-
export {
|
|
1056
|
+
export { titleEllipsizeMode as $, ICalendarEvent as $t, isAllDayEvent as A, DaySelectionState as At, toICalendar as B, dayBadgeKind as Bt, backgroundBandsForDay as C, isWeekend as Ct, drawnEnd as D, CalendarSelection as Dt, compareDayEvents as E, weekDaysCount as Et, EventSourceOptions as F, isWithinDateRange as Ft, MonthEventCapacity as G, BusinessHours as Gt, EventAccessibilityLabeler as H, CalendarColors as Ht, loadEventSource as I, nextDateRange as It, eventTimeLabel as J, CalendarEvent as Jt, eventAccessibilityLabel as K, BusinessHoursBand as Kt, ICalEvent as L, DayBadgeKind as Lt, layoutDayEvents as M, daySelectionState as Mt, wallClockHours as N, isDateSelectable as Nt, eventDayKeys as O, DateRange as Ot, EventSource as P, isRangeEndpoint as Pt, monthVisibleCount as Q, EventKeyExtractor as Qt, ToICalendarOptions as R, RangeBandKind as Rt, PositionedEvent as S, isSameCalendarDay as St, closedHourBands as T, viewDayCount as Tt, EventChipLayout as U, darkColors as Ut, EventAccessibilityLabelContext as V, rangeBandKind as Vt, MIN_BOX_HEIGHT_FOR_TIME as W, lightColors as Wt, isTimeVisibleAtHeight as X, CalendarMode as Xt, formatHour as Y, CalendarHandle as Yt, monthEventCapacity as Z, CreateGhostArgs as Zt, UseMonthGridOptions as _, filterHiddenDays as _t, MultiWeekGrid as a, cellRangeFromDrag as at, layoutMonthWeek as b, getWeekDays as bt, MultiWeekGridOptions as c, monthCreateRange as ct, MonthEventSegment as d, overlapsOtherEvents as dt, RecurrenceFrequency as en, titleNumberOfLines as et, MonthGrid as f, pageStepDays as ft, MonthWeekEvents as g, buildMonthWeeks as gt, MonthGridWeekday as h, snapDeltaMinutes as ht, expandRecurringEvents as i, WeekStartsOn as in, resolveCalendarLabels as it, isBackgroundEvent as j, UseDateRangeOptions as jt, groupEventsByDay as k, DateSelectionConstraints as kt, MultiWeekGridWeek as l, monthDropBounds as lt, MonthGridWeek as m, shiftMinutes as mt, toZonedTime as n, ScrollToTimeOptions as nn, dayAccessibilityLabel as nt, MultiWeekGridDay as o, clampMoveStartMinutes as ot, MonthGridDay as p, resolveDraggedBounds as pt, eventChipLayout as q, BusinessHoursValue as qt, zonedTimeToUtc as r, TimeGridMode as rn, defaultCalendarLabels as rt, MultiWeekGridInterval as s, eventsOverlap as st, eventsInTimeZone as t, RecurrenceRule as tn, CalendarLabels as tt, buildMultiWeekGrid as u, movedClockSpan as ut, WeekdayFormat as v, getIsToday as vt, clockHoursBetween as w, minutesIntoDay as wt, weekdayFormatToken as x, getYearMonths as xt, buildMonthGrid as y, getViewDays as yt, parseICalendar as z, bandRounding as zt };
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { Locale } from "date-fns";
|
|
2
|
-
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
/**
|
|
3
|
+
* The view the calendar renders: a day-column grid (`day`, `3days`, `week`,
|
|
4
|
+
* `custom`), the `month` grid, consecutive week rows (`multiweek`), the
|
|
5
|
+
* `schedule` list, or the `year` overview.
|
|
6
|
+
*/
|
|
7
|
+
type CalendarMode = "day" | "3days" | "week" | "custom" | "month" | "multiweek" | "schedule" | "year";
|
|
8
|
+
/** The time-grid modes (day-column views, excluding the month, multi-week, schedule, and year views). */
|
|
9
|
+
type TimeGridMode = Exclude<CalendarMode, "month" | "multiweek" | "schedule" | "year">;
|
|
6
10
|
/**
|
|
7
11
|
* The minimal shape every calendar event must have. Layout (positioning,
|
|
8
12
|
* overlap resolution, paging) only ever reads `start`/`end`; `title` is used by
|
|
@@ -323,7 +327,11 @@ interface UseDateRangeOptions extends DateSelectionConstraints {
|
|
|
323
327
|
}
|
|
324
328
|
/** The seven dates of the week containing `date`, starting on `weekStartsOn`. */
|
|
325
329
|
declare const getWeekDays: (date: Date, weekStartsOn: WeekStartsOn) => Date[];
|
|
326
|
-
/**
|
|
330
|
+
/**
|
|
331
|
+
* How many day columns a time-grid mode shows. `custom` uses `numberOfDays`.
|
|
332
|
+
* Throws a `RangeError` for `multiweek`, which has week rows instead of day
|
|
333
|
+
* columns; use `buildMultiWeekGrid` for it.
|
|
334
|
+
*/
|
|
327
335
|
declare const viewDayCount: (mode: CalendarMode, numberOfDays?: number) => number;
|
|
328
336
|
/**
|
|
329
337
|
* Days in the inclusive span from `weekStartsOn` to `weekEndsOn` (1–7),
|
|
@@ -336,6 +344,7 @@ declare const weekDaysCount: (weekStartsOn: WeekStartsOn, weekEndsOn: WeekStarts
|
|
|
336
344
|
* (honouring `weekStartsOn`). `custom` with a `weekEndsOn` spans the partial week
|
|
337
345
|
* from `weekStartsOn` to `weekEndsOn` (anchored to `date`'s week, paging by week);
|
|
338
346
|
* otherwise every mode shows `viewDayCount` consecutive days starting at `date`.
|
|
347
|
+
* Throws a `RangeError` for `multiweek` (see `viewDayCount`).
|
|
339
348
|
*/
|
|
340
349
|
declare const getViewDays: (mode: CalendarMode, date: Date, weekStartsOn: WeekStartsOn, numberOfDays?: number, isRTL?: boolean, weekEndsOn?: WeekStartsOn, hiddenDays?: number[]) => Date[];
|
|
341
350
|
/**
|
|
@@ -586,8 +595,8 @@ interface EventAccessibilityLabelContext {
|
|
|
586
595
|
*/
|
|
587
596
|
type EventAccessibilityLabeler<T = unknown> = (event: CalendarEvent<T>, context: EventAccessibilityLabelContext) => string;
|
|
588
597
|
/**
|
|
589
|
-
* Month cells and the all-day lane show a single clipped line;
|
|
590
|
-
* (`undefined`) wrap to fill the box.
|
|
598
|
+
* Month and multi-week cells and the all-day lane show a single clipped line;
|
|
599
|
+
* timed-grid titles (`undefined`) wrap to fill the box.
|
|
591
600
|
*/
|
|
592
601
|
declare function titleNumberOfLines(mode: CalendarMode, isAllDay: boolean): number | undefined;
|
|
593
602
|
/**
|
|
@@ -595,7 +604,7 @@ declare function titleNumberOfLines(mode: CalendarMode, isAllDay: boolean): numb
|
|
|
595
604
|
* none should show. Timed events get their `start - end` range. An all-day event
|
|
596
605
|
* gets the literal "All day" in the schedule (which has no all-day lane to
|
|
597
606
|
* signal it positionally) and nothing on the day/week grid (the lane already
|
|
598
|
-
* does). Month cells and `showTime={false}` always return `null`.
|
|
607
|
+
* does). Month and multi-week cells and `showTime={false}` always return `null`.
|
|
599
608
|
*/
|
|
600
609
|
declare function eventTimeLabel(args: {
|
|
601
610
|
mode: CalendarMode;
|
|
@@ -961,6 +970,57 @@ interface UseMonthGridOptions extends DateSelectionConstraints {
|
|
|
961
970
|
* data outside React; inside a component prefer {@link useMonthGrid}.
|
|
962
971
|
*/
|
|
963
972
|
declare function buildMonthGrid(month: Date, options?: UseMonthGridOptions): MonthGrid;
|
|
973
|
+
/** Options for {@link buildMultiWeekGrid}. */
|
|
974
|
+
interface MultiWeekGridOptions extends Omit<UseMonthGridOptions, "showSixWeeks"> {
|
|
975
|
+
/**
|
|
976
|
+
* How many consecutive full weeks to show. A positive whole number; default 2.
|
|
977
|
+
* Other values throw a `RangeError`.
|
|
978
|
+
*/
|
|
979
|
+
numberOfWeeks?: number;
|
|
980
|
+
}
|
|
981
|
+
/**
|
|
982
|
+
* A day in a multi-week grid. Every day of the grid belongs to the requested
|
|
983
|
+
* period, so it carries no month-membership flag.
|
|
984
|
+
*/
|
|
985
|
+
type MultiWeekGridDay = Omit<MonthGridDay, "isCurrentMonth">;
|
|
986
|
+
/** One week row of a {@link MultiWeekGrid}. */
|
|
987
|
+
interface MultiWeekGridWeek {
|
|
988
|
+
/** The week's first calendar day as `yyyy-MM-dd`, before hidden days are removed. */
|
|
989
|
+
id: string;
|
|
990
|
+
/** The row's days in display order, without hidden weekdays. */
|
|
991
|
+
days: MultiWeekGridDay[];
|
|
992
|
+
}
|
|
993
|
+
/** A half-open local calendar interval, `[start, endExclusive)`. */
|
|
994
|
+
interface MultiWeekGridInterval {
|
|
995
|
+
/** Midnight of the first day. */
|
|
996
|
+
start: Date;
|
|
997
|
+
/** Midnight after the last day. */
|
|
998
|
+
endExclusive: Date;
|
|
999
|
+
}
|
|
1000
|
+
/** The rows, weekday headers, and date bounds of a multi-week grid. */
|
|
1001
|
+
interface MultiWeekGrid {
|
|
1002
|
+
/** Every calendar day of the requested weeks, independent of hidden weekdays and RTL. */
|
|
1003
|
+
period: MultiWeekGridInterval;
|
|
1004
|
+
/** From the earliest to the latest displayed day; hidden days inside it stay hidden. */
|
|
1005
|
+
visibleRange: MultiWeekGridInterval;
|
|
1006
|
+
/** The week rows, oldest first. */
|
|
1007
|
+
weeks: MultiWeekGridWeek[];
|
|
1008
|
+
/** The weekday header cells, in display order. */
|
|
1009
|
+
weekdays: MonthGridWeekday[];
|
|
1010
|
+
}
|
|
1011
|
+
/**
|
|
1012
|
+
* Pure multi-week builder: `numberOfWeeks` consecutive full calendar weeks,
|
|
1013
|
+
* starting with the week that contains `date` (aligned back to `weekStartsOn`).
|
|
1014
|
+
* Each day carries the same selection, disabled, today, and weekend state as
|
|
1015
|
+
* {@link buildMonthGrid}. Hidden weekdays shrink the rows without changing the
|
|
1016
|
+
* period; `isRTL` reverses each row's display order.
|
|
1017
|
+
*
|
|
1018
|
+
* The result is fully materialized, so its size grows with `numberOfWeeks`.
|
|
1019
|
+
*
|
|
1020
|
+
* @throws RangeError when `date` is invalid, `numberOfWeeks` is not a positive
|
|
1021
|
+
* safe integer, or the last week falls outside the range `Date` can represent.
|
|
1022
|
+
*/
|
|
1023
|
+
declare function buildMultiWeekGrid(date: Date, options?: MultiWeekGridOptions): MultiWeekGrid;
|
|
964
1024
|
/**
|
|
965
1025
|
* Materialise recurring events into concrete occurrences overlapping
|
|
966
1026
|
* `[rangeStart, rangeEnd]`. Non-recurring events pass through untouched, so the
|
|
@@ -993,4 +1053,4 @@ declare function zonedTimeToUtc(wallClock: Date, timeZone: string): Date;
|
|
|
993
1053
|
* (e.g. with `useMemo`) since it allocates new dates.
|
|
994
1054
|
*/
|
|
995
1055
|
declare function eventsInTimeZone<T>(events: CalendarEvent<T>[], timeZone: string): CalendarEvent<T>[];
|
|
996
|
-
export {
|
|
1056
|
+
export { titleEllipsizeMode as $, ICalendarEvent as $t, isAllDayEvent as A, DaySelectionState as At, toICalendar as B, dayBadgeKind as Bt, backgroundBandsForDay as C, isWeekend as Ct, drawnEnd as D, CalendarSelection as Dt, compareDayEvents as E, weekDaysCount as Et, EventSourceOptions as F, isWithinDateRange as Ft, MonthEventCapacity as G, BusinessHours as Gt, EventAccessibilityLabeler as H, CalendarColors as Ht, loadEventSource as I, nextDateRange as It, eventTimeLabel as J, CalendarEvent as Jt, eventAccessibilityLabel as K, BusinessHoursBand as Kt, ICalEvent as L, DayBadgeKind as Lt, layoutDayEvents as M, daySelectionState as Mt, wallClockHours as N, isDateSelectable as Nt, eventDayKeys as O, DateRange as Ot, EventSource as P, isRangeEndpoint as Pt, monthVisibleCount as Q, EventKeyExtractor as Qt, ToICalendarOptions as R, RangeBandKind as Rt, PositionedEvent as S, isSameCalendarDay as St, closedHourBands as T, viewDayCount as Tt, EventChipLayout as U, darkColors as Ut, EventAccessibilityLabelContext as V, rangeBandKind as Vt, MIN_BOX_HEIGHT_FOR_TIME as W, lightColors as Wt, isTimeVisibleAtHeight as X, CalendarMode as Xt, formatHour as Y, CalendarHandle as Yt, monthEventCapacity as Z, CreateGhostArgs as Zt, UseMonthGridOptions as _, filterHiddenDays as _t, MultiWeekGrid as a, cellRangeFromDrag as at, layoutMonthWeek as b, getWeekDays as bt, MultiWeekGridOptions as c, monthCreateRange as ct, MonthEventSegment as d, overlapsOtherEvents as dt, RecurrenceFrequency as en, titleNumberOfLines as et, MonthGrid as f, pageStepDays as ft, MonthWeekEvents as g, buildMonthWeeks as gt, MonthGridWeekday as h, snapDeltaMinutes as ht, expandRecurringEvents as i, WeekStartsOn as in, resolveCalendarLabels as it, isBackgroundEvent as j, UseDateRangeOptions as jt, groupEventsByDay as k, DateSelectionConstraints as kt, MultiWeekGridWeek as l, monthDropBounds as lt, MonthGridWeek as m, shiftMinutes as mt, toZonedTime as n, ScrollToTimeOptions as nn, dayAccessibilityLabel as nt, MultiWeekGridDay as o, clampMoveStartMinutes as ot, MonthGridDay as p, resolveDraggedBounds as pt, eventChipLayout as q, BusinessHoursValue as qt, zonedTimeToUtc as r, TimeGridMode as rn, defaultCalendarLabels as rt, MultiWeekGridInterval as s, eventsOverlap as st, eventsInTimeZone as t, RecurrenceRule as tn, CalendarLabels as tt, buildMultiWeekGrid as u, movedClockSpan as ut, WeekdayFormat as v, getIsToday as vt, clockHoursBetween as w, minutesIntoDay as wt, weekdayFormatToken as x, getYearMonths as xt, buildMonthGrid as y, getViewDays as yt, parseICalendar as z, bandRounding as zt };
|
package/dist/vanilla.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
export { BusinessHours, BusinessHoursBand, BusinessHoursValue, CalendarColors, CalendarEvent, CalendarHandle, CalendarLabels, CalendarMode, CalendarSelection, CreateGhostArgs, DateRange, DateSelectionConstraints, DayBadgeKind, DaySelectionState, EventAccessibilityLabelContext, EventAccessibilityLabeler, EventChipLayout, EventKeyExtractor, EventSource, EventSourceOptions, ICalEvent, ICalendarEvent, MIN_BOX_HEIGHT_FOR_TIME, MonthEventCapacity, MonthEventSegment, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, MonthWeekEvents, PositionedEvent, RangeBandKind, RecurrenceFrequency, RecurrenceRule, ScrollToTimeOptions, TimeGridMode, ToICalendarOptions, UseDateRangeOptions, UseMonthGridOptions, WeekStartsOn, WeekdayFormat, backgroundBandsForDay, bandRounding, buildMonthGrid, buildMonthWeeks, cellRangeFromDrag, clampMoveStartMinutes, clockHoursBetween, closedHourBands, compareDayEvents, darkColors, dayAccessibilityLabel, dayBadgeKind, daySelectionState, defaultCalendarLabels, drawnEnd, eventAccessibilityLabel, eventChipLayout, eventDayKeys, eventTimeLabel, eventsInTimeZone, eventsOverlap, expandRecurringEvents, filterHiddenDays, formatHour, getIsToday, getViewDays, getWeekDays, getYearMonths, groupEventsByDay, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isTimeVisibleAtHeight, isWeekend, isWithinDateRange, layoutDayEvents, layoutMonthWeek, lightColors, loadEventSource, minutesIntoDay, monthCreateRange, monthDropBounds, monthEventCapacity, monthVisibleCount, movedClockSpan, nextDateRange, overlapsOtherEvents, pageStepDays, parseICalendar, rangeBandKind, resolveCalendarLabels, resolveDraggedBounds, shiftMinutes, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, viewDayCount, wallClockHours, weekDaysCount, weekdayFormatToken, zonedTimeToUtc };
|
|
1
|
+
import { $ as titleEllipsizeMode, $t as ICalendarEvent, A as isAllDayEvent, At as DaySelectionState, B as toICalendar, Bt as dayBadgeKind, C as backgroundBandsForDay, Ct as isWeekend, D as drawnEnd, Dt as CalendarSelection, E as compareDayEvents, Et as weekDaysCount, F as EventSourceOptions, Ft as isWithinDateRange, G as MonthEventCapacity, Gt as BusinessHours, H as EventAccessibilityLabeler, Ht as CalendarColors, I as loadEventSource, It as nextDateRange, J as eventTimeLabel, Jt as CalendarEvent, K as eventAccessibilityLabel, Kt as BusinessHoursBand, L as ICalEvent, Lt as DayBadgeKind, M as layoutDayEvents, Mt as daySelectionState, N as wallClockHours, Nt as isDateSelectable, O as eventDayKeys, Ot as DateRange, P as EventSource, Pt as isRangeEndpoint, Q as monthVisibleCount, Qt as EventKeyExtractor, R as ToICalendarOptions, Rt as RangeBandKind, S as PositionedEvent, St as isSameCalendarDay, T as closedHourBands, Tt as viewDayCount, U as EventChipLayout, Ut as darkColors, V as EventAccessibilityLabelContext, Vt as rangeBandKind, W as MIN_BOX_HEIGHT_FOR_TIME, Wt as lightColors, X as isTimeVisibleAtHeight, Xt as CalendarMode, Y as formatHour, Yt as CalendarHandle, Z as monthEventCapacity, Zt as CreateGhostArgs, _ as UseMonthGridOptions, _t as filterHiddenDays, a as MultiWeekGrid, at as cellRangeFromDrag, b as layoutMonthWeek, bt as getWeekDays, c as MultiWeekGridOptions, ct as monthCreateRange, d as MonthEventSegment, dt as overlapsOtherEvents, en as RecurrenceFrequency, et as titleNumberOfLines, f as MonthGrid, ft as pageStepDays, g as MonthWeekEvents, gt as buildMonthWeeks, h as MonthGridWeekday, ht as snapDeltaMinutes, i as expandRecurringEvents, in as WeekStartsOn, it as resolveCalendarLabels, j as isBackgroundEvent, jt as UseDateRangeOptions, k as groupEventsByDay, kt as DateSelectionConstraints, l as MultiWeekGridWeek, lt as monthDropBounds, m as MonthGridWeek, mt as shiftMinutes, n as toZonedTime, nn as ScrollToTimeOptions, nt as dayAccessibilityLabel, o as MultiWeekGridDay, ot as clampMoveStartMinutes, p as MonthGridDay, pt as resolveDraggedBounds, q as eventChipLayout, qt as BusinessHoursValue, r as zonedTimeToUtc, rn as TimeGridMode, rt as defaultCalendarLabels, s as MultiWeekGridInterval, st as eventsOverlap, t as eventsInTimeZone, tn as RecurrenceRule, tt as CalendarLabels, u as buildMultiWeekGrid, ut as movedClockSpan, v as WeekdayFormat, vt as getIsToday, w as clockHoursBetween, wt as minutesIntoDay, x as weekdayFormatToken, xt as getYearMonths, y as buildMonthGrid, yt as getViewDays, z as parseICalendar, zt as bandRounding } from "./timezone-vbd68uRS.mjs";
|
|
2
|
+
export { BusinessHours, BusinessHoursBand, BusinessHoursValue, CalendarColors, CalendarEvent, CalendarHandle, CalendarLabels, CalendarMode, CalendarSelection, CreateGhostArgs, DateRange, DateSelectionConstraints, DayBadgeKind, DaySelectionState, EventAccessibilityLabelContext, EventAccessibilityLabeler, EventChipLayout, EventKeyExtractor, EventSource, EventSourceOptions, ICalEvent, ICalendarEvent, MIN_BOX_HEIGHT_FOR_TIME, MonthEventCapacity, MonthEventSegment, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, MonthWeekEvents, MultiWeekGrid, MultiWeekGridDay, MultiWeekGridInterval, MultiWeekGridOptions, MultiWeekGridWeek, PositionedEvent, RangeBandKind, RecurrenceFrequency, RecurrenceRule, ScrollToTimeOptions, TimeGridMode, ToICalendarOptions, UseDateRangeOptions, UseMonthGridOptions, WeekStartsOn, WeekdayFormat, backgroundBandsForDay, bandRounding, buildMonthGrid, buildMonthWeeks, buildMultiWeekGrid, cellRangeFromDrag, clampMoveStartMinutes, clockHoursBetween, closedHourBands, compareDayEvents, darkColors, dayAccessibilityLabel, dayBadgeKind, daySelectionState, defaultCalendarLabels, drawnEnd, eventAccessibilityLabel, eventChipLayout, eventDayKeys, eventTimeLabel, eventsInTimeZone, eventsOverlap, expandRecurringEvents, filterHiddenDays, formatHour, getIsToday, getViewDays, getWeekDays, getYearMonths, groupEventsByDay, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isTimeVisibleAtHeight, isWeekend, isWithinDateRange, layoutDayEvents, layoutMonthWeek, lightColors, loadEventSource, minutesIntoDay, monthCreateRange, monthDropBounds, monthEventCapacity, monthVisibleCount, movedClockSpan, nextDateRange, overlapsOtherEvents, pageStepDays, parseICalendar, rangeBandKind, resolveCalendarLabels, resolveDraggedBounds, shiftMinutes, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, viewDayCount, wallClockHours, weekDaysCount, weekdayFormatToken, zonedTimeToUtc };
|
package/dist/vanilla.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
export { BusinessHours, BusinessHoursBand, BusinessHoursValue, CalendarColors, CalendarEvent, CalendarHandle, CalendarLabels, CalendarMode, CalendarSelection, CreateGhostArgs, DateRange, DateSelectionConstraints, DayBadgeKind, DaySelectionState, EventAccessibilityLabelContext, EventAccessibilityLabeler, EventChipLayout, EventKeyExtractor, EventSource, EventSourceOptions, ICalEvent, ICalendarEvent, MIN_BOX_HEIGHT_FOR_TIME, MonthEventCapacity, MonthEventSegment, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, MonthWeekEvents, PositionedEvent, RangeBandKind, RecurrenceFrequency, RecurrenceRule, ScrollToTimeOptions, TimeGridMode, ToICalendarOptions, UseDateRangeOptions, UseMonthGridOptions, WeekStartsOn, WeekdayFormat, backgroundBandsForDay, bandRounding, buildMonthGrid, buildMonthWeeks, cellRangeFromDrag, clampMoveStartMinutes, clockHoursBetween, closedHourBands, compareDayEvents, darkColors, dayAccessibilityLabel, dayBadgeKind, daySelectionState, defaultCalendarLabels, drawnEnd, eventAccessibilityLabel, eventChipLayout, eventDayKeys, eventTimeLabel, eventsInTimeZone, eventsOverlap, expandRecurringEvents, filterHiddenDays, formatHour, getIsToday, getViewDays, getWeekDays, getYearMonths, groupEventsByDay, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isTimeVisibleAtHeight, isWeekend, isWithinDateRange, layoutDayEvents, layoutMonthWeek, lightColors, loadEventSource, minutesIntoDay, monthCreateRange, monthDropBounds, monthEventCapacity, monthVisibleCount, movedClockSpan, nextDateRange, overlapsOtherEvents, pageStepDays, parseICalendar, rangeBandKind, resolveCalendarLabels, resolveDraggedBounds, shiftMinutes, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, viewDayCount, wallClockHours, weekDaysCount, weekdayFormatToken, zonedTimeToUtc };
|
|
1
|
+
import { $ as titleEllipsizeMode, $t as ICalendarEvent, A as isAllDayEvent, At as DaySelectionState, B as toICalendar, Bt as dayBadgeKind, C as backgroundBandsForDay, Ct as isWeekend, D as drawnEnd, Dt as CalendarSelection, E as compareDayEvents, Et as weekDaysCount, F as EventSourceOptions, Ft as isWithinDateRange, G as MonthEventCapacity, Gt as BusinessHours, H as EventAccessibilityLabeler, Ht as CalendarColors, I as loadEventSource, It as nextDateRange, J as eventTimeLabel, Jt as CalendarEvent, K as eventAccessibilityLabel, Kt as BusinessHoursBand, L as ICalEvent, Lt as DayBadgeKind, M as layoutDayEvents, Mt as daySelectionState, N as wallClockHours, Nt as isDateSelectable, O as eventDayKeys, Ot as DateRange, P as EventSource, Pt as isRangeEndpoint, Q as monthVisibleCount, Qt as EventKeyExtractor, R as ToICalendarOptions, Rt as RangeBandKind, S as PositionedEvent, St as isSameCalendarDay, T as closedHourBands, Tt as viewDayCount, U as EventChipLayout, Ut as darkColors, V as EventAccessibilityLabelContext, Vt as rangeBandKind, W as MIN_BOX_HEIGHT_FOR_TIME, Wt as lightColors, X as isTimeVisibleAtHeight, Xt as CalendarMode, Y as formatHour, Yt as CalendarHandle, Z as monthEventCapacity, Zt as CreateGhostArgs, _ as UseMonthGridOptions, _t as filterHiddenDays, a as MultiWeekGrid, at as cellRangeFromDrag, b as layoutMonthWeek, bt as getWeekDays, c as MultiWeekGridOptions, ct as monthCreateRange, d as MonthEventSegment, dt as overlapsOtherEvents, en as RecurrenceFrequency, et as titleNumberOfLines, f as MonthGrid, ft as pageStepDays, g as MonthWeekEvents, gt as buildMonthWeeks, h as MonthGridWeekday, ht as snapDeltaMinutes, i as expandRecurringEvents, in as WeekStartsOn, it as resolveCalendarLabels, j as isBackgroundEvent, jt as UseDateRangeOptions, k as groupEventsByDay, kt as DateSelectionConstraints, l as MultiWeekGridWeek, lt as monthDropBounds, m as MonthGridWeek, mt as shiftMinutes, n as toZonedTime, nn as ScrollToTimeOptions, nt as dayAccessibilityLabel, o as MultiWeekGridDay, ot as clampMoveStartMinutes, p as MonthGridDay, pt as resolveDraggedBounds, q as eventChipLayout, qt as BusinessHoursValue, r as zonedTimeToUtc, rn as TimeGridMode, rt as defaultCalendarLabels, s as MultiWeekGridInterval, st as eventsOverlap, t as eventsInTimeZone, tn as RecurrenceRule, tt as CalendarLabels, u as buildMultiWeekGrid, ut as movedClockSpan, v as WeekdayFormat, vt as getIsToday, w as clockHoursBetween, wt as minutesIntoDay, x as weekdayFormatToken, xt as getYearMonths, y as buildMonthGrid, yt as getViewDays, z as parseICalendar, zt as bandRounding } from "./timezone-vbd68uRS.js";
|
|
2
|
+
export { BusinessHours, BusinessHoursBand, BusinessHoursValue, CalendarColors, CalendarEvent, CalendarHandle, CalendarLabels, CalendarMode, CalendarSelection, CreateGhostArgs, DateRange, DateSelectionConstraints, DayBadgeKind, DaySelectionState, EventAccessibilityLabelContext, EventAccessibilityLabeler, EventChipLayout, EventKeyExtractor, EventSource, EventSourceOptions, ICalEvent, ICalendarEvent, MIN_BOX_HEIGHT_FOR_TIME, MonthEventCapacity, MonthEventSegment, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, MonthWeekEvents, MultiWeekGrid, MultiWeekGridDay, MultiWeekGridInterval, MultiWeekGridOptions, MultiWeekGridWeek, PositionedEvent, RangeBandKind, RecurrenceFrequency, RecurrenceRule, ScrollToTimeOptions, TimeGridMode, ToICalendarOptions, UseDateRangeOptions, UseMonthGridOptions, WeekStartsOn, WeekdayFormat, backgroundBandsForDay, bandRounding, buildMonthGrid, buildMonthWeeks, buildMultiWeekGrid, cellRangeFromDrag, clampMoveStartMinutes, clockHoursBetween, closedHourBands, compareDayEvents, darkColors, dayAccessibilityLabel, dayBadgeKind, daySelectionState, defaultCalendarLabels, drawnEnd, eventAccessibilityLabel, eventChipLayout, eventDayKeys, eventTimeLabel, eventsInTimeZone, eventsOverlap, expandRecurringEvents, filterHiddenDays, formatHour, getIsToday, getViewDays, getWeekDays, getYearMonths, groupEventsByDay, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isTimeVisibleAtHeight, isWeekend, isWithinDateRange, layoutDayEvents, layoutMonthWeek, lightColors, loadEventSource, minutesIntoDay, monthCreateRange, monthDropBounds, monthEventCapacity, monthVisibleCount, movedClockSpan, nextDateRange, overlapsOtherEvents, pageStepDays, parseICalendar, rangeBandKind, resolveCalendarLabels, resolveDraggedBounds, shiftMinutes, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, viewDayCount, wallClockHours, weekDaysCount, weekdayFormatToken, zonedTimeToUtc };
|
package/dist/vanilla.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_recurrence = require("./recurrence-
|
|
2
|
+
const require_recurrence = require("./recurrence-D_oJ7A9D.js");
|
|
3
3
|
exports.MIN_BOX_HEIGHT_FOR_TIME = require_recurrence.MIN_BOX_HEIGHT_FOR_TIME;
|
|
4
4
|
exports.backgroundBandsForDay = require_recurrence.backgroundBandsForDay;
|
|
5
5
|
exports.bandRounding = require_recurrence.bandRounding;
|
|
6
6
|
exports.buildMonthGrid = require_recurrence.buildMonthGrid;
|
|
7
7
|
exports.buildMonthWeeks = require_recurrence.buildMonthWeeks;
|
|
8
|
+
exports.buildMultiWeekGrid = require_recurrence.buildMultiWeekGrid;
|
|
8
9
|
exports.cellRangeFromDrag = require_recurrence.cellRangeFromDrag;
|
|
9
10
|
exports.clampMoveStartMinutes = require_recurrence.clampMoveStartMinutes;
|
|
10
11
|
exports.clockHoursBetween = require_recurrence.clockHoursBetween;
|
package/dist/vanilla.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { f as MIN_BOX_HEIGHT_FOR_TIME, I as backgroundBandsForDay, lt as bandRounding, r as buildMonthGrid, Q as buildMonthWeeks, n as buildMultiWeekGrid, T as cellRangeFromDrag, E as clampMoveStartMinutes, L as clockHoursBetween, R as closedHourBands, z as compareDayEvents, ft as darkColors, S as dayAccessibilityLabel, ut as dayBadgeKind, q as daySelectionState, C as defaultCalendarLabels, B as drawnEnd, p as eventAccessibilityLabel, m as eventChipLayout, V as eventDayKeys, h as eventTimeLabel, l as eventsInTimeZone, D as eventsOverlap, t as expandRecurringEvents, $ as filterHiddenDays, g as formatHour, et as getIsToday, tt as getViewDays, nt as getWeekDays, rt as getYearMonths, H as groupEventsByDay, U as isAllDayEvent, W as isBackgroundEvent, J as isDateSelectable, Y as isRangeEndpoint, it as isSameCalendarDay, _ as isTimeVisibleAtHeight, at as isWeekend, X as isWithinDateRange, G as layoutDayEvents, i as layoutMonthWeek, pt as lightColors, o as loadEventSource, ot as minutesIntoDay, O as monthCreateRange, k as monthDropBounds, v as monthEventCapacity, y as monthVisibleCount, A as movedClockSpan, Z as nextDateRange, j as overlapsOtherEvents, M as pageStepDays, s as parseICalendar, dt as rangeBandKind, w as resolveCalendarLabels, N as resolveDraggedBounds, P as shiftMinutes, F as snapDeltaMinutes, b as titleEllipsizeMode, x as titleNumberOfLines, c as toICalendar, u as toZonedTime, st as viewDayCount, K as wallClockHours, ct as weekDaysCount, a as weekdayFormatToken, d as zonedTimeToUtc } from "./recurrence-CvIJfSMl.mjs";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@super-calendar/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.17.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/index.ts
CHANGED
|
@@ -29,6 +29,7 @@ export * from "./utils/useNow";
|
|
|
29
29
|
export * from "./utils/useEventSource";
|
|
30
30
|
export * from "./utils/layout";
|
|
31
31
|
export * from "./utils/monthGrid";
|
|
32
|
+
export * from "./utils/multiWeekGrid";
|
|
32
33
|
export * from "./utils/recurrence";
|
|
33
34
|
export * from "./utils/timezone";
|
|
34
35
|
export * from "./utils/useDateRange";
|
package/src/types.ts
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The view the calendar renders: a day-column grid (`day`, `3days`, `week`,
|
|
3
|
+
* `custom`), the `month` grid, consecutive week rows (`multiweek`), the
|
|
4
|
+
* `schedule` list, or the `year` overview.
|
|
5
|
+
*/
|
|
6
|
+
export type CalendarMode =
|
|
7
|
+
| "day"
|
|
8
|
+
| "3days"
|
|
9
|
+
| "week"
|
|
10
|
+
| "custom"
|
|
11
|
+
| "month"
|
|
12
|
+
| "multiweek"
|
|
13
|
+
| "schedule"
|
|
14
|
+
| "year";
|
|
3
15
|
|
|
4
|
-
/** The time-grid modes (day-column views, excluding month and
|
|
5
|
-
export type TimeGridMode = Exclude<CalendarMode, "month" | "schedule" | "year">;
|
|
16
|
+
/** The time-grid modes (day-column views, excluding the month, multi-week, schedule, and year views). */
|
|
17
|
+
export type TimeGridMode = Exclude<CalendarMode, "month" | "multiweek" | "schedule" | "year">;
|
|
6
18
|
|
|
7
19
|
/**
|
|
8
20
|
* The minimal shape every calendar event must have. Layout (positioning,
|
package/src/utils/dates.ts
CHANGED
|
@@ -19,7 +19,11 @@ export const getWeekDays = (date: Date, weekStartsOn: WeekStartsOn): Date[] => {
|
|
|
19
19
|
return Array.from({ length: 7 }, (_, index) => addDays(start, index));
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* How many day columns a time-grid mode shows. `custom` uses `numberOfDays`.
|
|
24
|
+
* Throws a `RangeError` for `multiweek`, which has week rows instead of day
|
|
25
|
+
* columns; use `buildMultiWeekGrid` for it.
|
|
26
|
+
*/
|
|
23
27
|
export const viewDayCount = (mode: CalendarMode, numberOfDays = 1): number => {
|
|
24
28
|
switch (mode) {
|
|
25
29
|
case "week":
|
|
@@ -28,6 +32,10 @@ export const viewDayCount = (mode: CalendarMode, numberOfDays = 1): number => {
|
|
|
28
32
|
return 3;
|
|
29
33
|
case "custom":
|
|
30
34
|
return Math.max(1, Math.floor(numberOfDays));
|
|
35
|
+
case "multiweek":
|
|
36
|
+
throw new RangeError(
|
|
37
|
+
"The multiweek mode has week rows, not day columns. Use buildMultiWeekGrid for its days.",
|
|
38
|
+
);
|
|
31
39
|
default:
|
|
32
40
|
return 1; // 'day'
|
|
33
41
|
}
|
|
@@ -57,6 +65,7 @@ export const weekDaysCount = (weekStartsOn: WeekStartsOn, weekEndsOn: WeekStarts
|
|
|
57
65
|
* (honouring `weekStartsOn`). `custom` with a `weekEndsOn` spans the partial week
|
|
58
66
|
* from `weekStartsOn` to `weekEndsOn` (anchored to `date`'s week, paging by week);
|
|
59
67
|
* otherwise every mode shows `viewDayCount` consecutive days starting at `date`.
|
|
68
|
+
* Throws a `RangeError` for `multiweek` (see `viewDayCount`).
|
|
60
69
|
*/
|
|
61
70
|
export const getViewDays = (
|
|
62
71
|
mode: CalendarMode,
|
|
@@ -62,11 +62,11 @@ export type EventAccessibilityLabeler<T = unknown> = (
|
|
|
62
62
|
) => string;
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
|
-
* Month cells and the all-day lane show a single clipped line;
|
|
66
|
-
* (`undefined`) wrap to fill the box.
|
|
65
|
+
* Month and multi-week cells and the all-day lane show a single clipped line;
|
|
66
|
+
* timed-grid titles (`undefined`) wrap to fill the box.
|
|
67
67
|
*/
|
|
68
68
|
export function titleNumberOfLines(mode: CalendarMode, isAllDay: boolean): number | undefined {
|
|
69
|
-
return mode === "month" || isAllDay ? 1 : undefined;
|
|
69
|
+
return mode === "month" || mode === "multiweek" || isAllDay ? 1 : undefined;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
/**
|
|
@@ -74,7 +74,7 @@ export function titleNumberOfLines(mode: CalendarMode, isAllDay: boolean): numbe
|
|
|
74
74
|
* none should show. Timed events get their `start - end` range. An all-day event
|
|
75
75
|
* gets the literal "All day" in the schedule (which has no all-day lane to
|
|
76
76
|
* signal it positionally) and nothing on the day/week grid (the lane already
|
|
77
|
-
* does). Month cells and `showTime={false}` always return `null`.
|
|
77
|
+
* does). Month and multi-week cells and `showTime={false}` always return `null`.
|
|
78
78
|
*/
|
|
79
79
|
export function eventTimeLabel(args: {
|
|
80
80
|
mode: CalendarMode;
|
|
@@ -86,7 +86,7 @@ export function eventTimeLabel(args: {
|
|
|
86
86
|
/** Text for an all-day event in the schedule. Default "All day". */
|
|
87
87
|
allDayLabel?: string;
|
|
88
88
|
}): string | null {
|
|
89
|
-
if (!args.showTime || args.mode === "month") return null;
|
|
89
|
+
if (!args.showTime || args.mode === "month" || args.mode === "multiweek") return null;
|
|
90
90
|
if (args.isAllDay) return args.mode === "schedule" ? (args.allDayLabel ?? "All day") : null;
|
|
91
91
|
const timeFormat = args.ampm ? "h:mm a" : "HH:mm";
|
|
92
92
|
return `${format(args.start, timeFormat)} - ${format(args.end, timeFormat)}`;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { addDays, format, startOfWeek } from "date-fns";
|
|
2
|
+
import { daySelectionState } from "./dateRange";
|
|
3
|
+
import { filterHiddenDays, getIsToday, isWeekend } from "./dates";
|
|
4
|
+
import {
|
|
5
|
+
type MonthGridDay,
|
|
6
|
+
type MonthGridWeekday,
|
|
7
|
+
type UseMonthGridOptions,
|
|
8
|
+
weekdayFormatToken,
|
|
9
|
+
} from "./monthGrid";
|
|
10
|
+
|
|
11
|
+
/** Options for {@link buildMultiWeekGrid}. */
|
|
12
|
+
export interface MultiWeekGridOptions extends Omit<UseMonthGridOptions, "showSixWeeks"> {
|
|
13
|
+
/**
|
|
14
|
+
* How many consecutive full weeks to show. A positive whole number; default 2.
|
|
15
|
+
* Other values throw a `RangeError`.
|
|
16
|
+
*/
|
|
17
|
+
numberOfWeeks?: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A day in a multi-week grid. Every day of the grid belongs to the requested
|
|
22
|
+
* period, so it carries no month-membership flag.
|
|
23
|
+
*/
|
|
24
|
+
export type MultiWeekGridDay = Omit<MonthGridDay, "isCurrentMonth">;
|
|
25
|
+
|
|
26
|
+
/** One week row of a {@link MultiWeekGrid}. */
|
|
27
|
+
export interface MultiWeekGridWeek {
|
|
28
|
+
/** The week's first calendar day as `yyyy-MM-dd`, before hidden days are removed. */
|
|
29
|
+
id: string;
|
|
30
|
+
/** The row's days in display order, without hidden weekdays. */
|
|
31
|
+
days: MultiWeekGridDay[];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** A half-open local calendar interval, `[start, endExclusive)`. */
|
|
35
|
+
export interface MultiWeekGridInterval {
|
|
36
|
+
/** Midnight of the first day. */
|
|
37
|
+
start: Date;
|
|
38
|
+
/** Midnight after the last day. */
|
|
39
|
+
endExclusive: Date;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** The rows, weekday headers, and date bounds of a multi-week grid. */
|
|
43
|
+
export interface MultiWeekGrid {
|
|
44
|
+
/** Every calendar day of the requested weeks, independent of hidden weekdays and RTL. */
|
|
45
|
+
period: MultiWeekGridInterval;
|
|
46
|
+
/** From the earliest to the latest displayed day; hidden days inside it stay hidden. */
|
|
47
|
+
visibleRange: MultiWeekGridInterval;
|
|
48
|
+
/** The week rows, oldest first. */
|
|
49
|
+
weeks: MultiWeekGridWeek[];
|
|
50
|
+
/** The weekday header cells, in display order. */
|
|
51
|
+
weekdays: MonthGridWeekday[];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Pure multi-week builder: `numberOfWeeks` consecutive full calendar weeks,
|
|
56
|
+
* starting with the week that contains `date` (aligned back to `weekStartsOn`).
|
|
57
|
+
* Each day carries the same selection, disabled, today, and weekend state as
|
|
58
|
+
* {@link buildMonthGrid}. Hidden weekdays shrink the rows without changing the
|
|
59
|
+
* period; `isRTL` reverses each row's display order.
|
|
60
|
+
*
|
|
61
|
+
* The result is fully materialized, so its size grows with `numberOfWeeks`.
|
|
62
|
+
*
|
|
63
|
+
* @throws RangeError when `date` is invalid, `numberOfWeeks` is not a positive
|
|
64
|
+
* safe integer, or the last week falls outside the range `Date` can represent.
|
|
65
|
+
*/
|
|
66
|
+
export function buildMultiWeekGrid(date: Date, options: MultiWeekGridOptions = {}): MultiWeekGrid {
|
|
67
|
+
const {
|
|
68
|
+
numberOfWeeks = 2,
|
|
69
|
+
weekStartsOn = 0,
|
|
70
|
+
weekdayFormat = "short",
|
|
71
|
+
isRTL = false,
|
|
72
|
+
hiddenDays,
|
|
73
|
+
selectedDates,
|
|
74
|
+
selectedRange,
|
|
75
|
+
minDate,
|
|
76
|
+
maxDate,
|
|
77
|
+
isDateDisabled,
|
|
78
|
+
locale,
|
|
79
|
+
} = options;
|
|
80
|
+
|
|
81
|
+
if (!(date instanceof Date) || Number.isNaN(date.getTime())) {
|
|
82
|
+
throw new RangeError("buildMultiWeekGrid: date must be a valid Date.");
|
|
83
|
+
}
|
|
84
|
+
if (!Number.isSafeInteger(numberOfWeeks) || numberOfWeeks < 1) {
|
|
85
|
+
throw new RangeError(
|
|
86
|
+
`buildMultiWeekGrid: numberOfWeeks must be a positive whole number, received ${String(numberOfWeeks)}.`,
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
const start = startOfWeek(date, { weekStartsOn });
|
|
90
|
+
const endExclusive = addDays(start, numberOfWeeks * 7);
|
|
91
|
+
if (Number.isNaN(endExclusive.getTime())) {
|
|
92
|
+
throw new RangeError(
|
|
93
|
+
`buildMultiWeekGrid: ${numberOfWeeks} weeks from ${format(start, "yyyy-MM-dd")} cannot be represented as a Date.`,
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const constraints = { minDate, maxDate, isDateDisabled };
|
|
98
|
+
const selection = { selectedDates, selectedRange };
|
|
99
|
+
let first: Date | null = null;
|
|
100
|
+
let last: Date | null = null;
|
|
101
|
+
const weeks: MultiWeekGridWeek[] = [];
|
|
102
|
+
for (let row = 0; row < numberOfWeeks; row++) {
|
|
103
|
+
const weekStart = addDays(start, row * 7);
|
|
104
|
+
const all = Array.from({ length: 7 }, (_, index) => addDays(weekStart, index));
|
|
105
|
+
const visible = filterHiddenDays(all, hiddenDays);
|
|
106
|
+
if (visible.length > 0) {
|
|
107
|
+
if (first === null) first = visible[0];
|
|
108
|
+
last = visible[visible.length - 1];
|
|
109
|
+
}
|
|
110
|
+
const ordered = isRTL ? [...visible].reverse() : visible;
|
|
111
|
+
weeks.push({
|
|
112
|
+
id: format(weekStart, "yyyy-MM-dd"),
|
|
113
|
+
days: ordered.map((day): MultiWeekGridDay => ({
|
|
114
|
+
date: day,
|
|
115
|
+
id: format(day, "yyyy-MM-dd"),
|
|
116
|
+
label: format(day, "d"),
|
|
117
|
+
isToday: getIsToday(day),
|
|
118
|
+
isWeekend: isWeekend(day),
|
|
119
|
+
...daySelectionState(day, selection, constraints),
|
|
120
|
+
})),
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const token = weekdayFormatToken(weekdayFormat);
|
|
125
|
+
const weekdays: MonthGridWeekday[] = weeks[0].days.map((day) => ({
|
|
126
|
+
date: day.date,
|
|
127
|
+
label: format(day.date, token, { locale }),
|
|
128
|
+
}));
|
|
129
|
+
|
|
130
|
+
return {
|
|
131
|
+
period: { start, endExclusive },
|
|
132
|
+
visibleRange: {
|
|
133
|
+
start: first ?? start,
|
|
134
|
+
endExclusive: last ? addDays(last, 1) : endExclusive,
|
|
135
|
+
},
|
|
136
|
+
weeks,
|
|
137
|
+
weekdays,
|
|
138
|
+
};
|
|
139
|
+
}
|
package/src/vanilla.ts
CHANGED
|
@@ -10,6 +10,7 @@ export * from "./utils/ical";
|
|
|
10
10
|
export * from "./utils/labels";
|
|
11
11
|
export * from "./utils/layout";
|
|
12
12
|
export * from "./utils/monthGrid";
|
|
13
|
+
export * from "./utils/multiWeekGrid";
|
|
13
14
|
export * from "./utils/recurrence";
|
|
14
15
|
export * from "./utils/timezone";
|
|
15
16
|
export * from "./utils/eventSource";
|