@super-calendar/core 2.17.0 → 2.19.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 +8 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +17 -10
- package/dist/index.mjs +9 -11
- package/dist/{recurrence-CvIJfSMl.mjs → recurrence-BqpCShcV.mjs} +402 -101
- package/dist/{recurrence-D_oJ7A9D.js → recurrence-CTjr6nxJ.js} +454 -99
- package/dist/{timezone-vbd68uRS.d.mts → timezone-DhGhYIeB.d.mts} +150 -13
- package/dist/{timezone-vbd68uRS.d.ts → timezone-DhGhYIeB.d.ts} +150 -13
- package/dist/vanilla.d.mts +2 -2
- package/dist/vanilla.d.ts +2 -2
- package/dist/vanilla.js +10 -1
- package/dist/vanilla.mjs +1 -1
- package/package.json +1 -1
- package/src/types.ts +7 -0
- package/src/utils/dates.ts +7 -2
- package/src/utils/drag.ts +14 -6
- package/src/utils/eventSource.ts +2 -0
- package/src/utils/ical.ts +5 -0
- package/src/utils/layout.ts +19 -5
- package/src/utils/monthGrid.ts +135 -1
- package/src/utils/multiWeekGrid.ts +2 -1
- package/src/utils/recurrence.ts +203 -77
- package/src/utils/timezone.ts +151 -48
- package/src/utils/useMonthGrid.ts +5 -0
- package/src/utils/useNow.ts +4 -9
- package/src/utils/zoneFields.ts +71 -0
package/README.md
CHANGED
|
@@ -75,6 +75,14 @@ Use `resolveDraggedBounds` to commit a move or resize. Equal start and end delta
|
|
|
75
75
|
move the event while preserving elapsed duration, including across daylight
|
|
76
76
|
saving changes. For a resize, pass zero for the edge you want to keep fixed.
|
|
77
77
|
|
|
78
|
+
`eventDayKeys` and `groupEventsByDay` index every occupied local calendar day by
|
|
79
|
+
its start-of-day ISO value. Midnight clock changes do not shift later day keys.
|
|
80
|
+
An event ending at the start of a day excludes that day.
|
|
81
|
+
|
|
82
|
+
`monthCreateRange(anchor, hover)` returns the ordered all-day creation range.
|
|
83
|
+
Its exclusive end is the start of the day after the last selected date,
|
|
84
|
+
including when a clock change skips midnight.
|
|
85
|
+
|
|
78
86
|
`CalendarEvent<T>` includes an optional `dragHandleColor: string` for the native
|
|
79
87
|
renderer's time-grid and resource-timeline resize grips. When omitted, those
|
|
80
88
|
grips use `theme.colors.eventText`. Core preserves the field without interpreting it.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as EventAccessibilityLabelContext, $t as rangeBandKind, A as monthExtraLaneColumns, At as getIsToday, B as eventDayKeys, Bt as DateRange, C as MonthRowLanes, Ct as overlapsOtherEvents, D as buildMonthGrid, Dt as snapDeltaMinutes, E as WeekdayFormat, Et as shiftMinutes, F as backgroundBandsForDay, Ft as isWeekend, G as wallClockHours, Gt as isDateSelectable, H as isAllDayEvent, Ht as DaySelectionState, I as clockHoursBetween, It as minutesIntoDay, J as loadEventSource, Jt as nextDateRange, K as EventSource, Kt as isRangeEndpoint, L as closedHourBands, Lt as viewDayCount, M as weekdayFormatToken, Mt as getWeekDays, N as withDraftEventDays, Nt as getYearMonths, O as keepMonthDraftVisible, Ot as buildMonthWeeks, P as PositionedEvent, Pt as isSameCalendarDay, Q as toICalendar, Qt as dayBadgeKind, R as compareDayEvents, Rt as weekDaysCount, S as MonthGridWeekday, St as movedClockSpan, T as UseMonthGridOptions, Tt as resolveDraggedBounds, U as isBackgroundEvent, Ut as UseDateRangeOptions, V as groupEventsByDay, Vt as DateSelectionConstraints, W as layoutDayEvents, Wt as daySelectionState, X as ToICalendarOptions, Xt as RangeBandKind, Y as ICalEvent, Yt as DayBadgeKind, Z as parseICalendar, Zt as bandRounding, _ as buildMultiWeekGrid, _t as cellRangeFromDrag, a as nowInTimeZone, an as BusinessHoursValue, at as eventChipLayout, b as MonthGridDay, bt as monthCreateRange, c as zonedEventSource, cn as CalendarMode, ct as isTimeVisibleAtHeight, d as expandRecurringEvents, dn as ICalendarEvent, dt as titleEllipsizeMode, en as CalendarColors, et as EventAccessibilityLabeler, f as MultiWeekGrid, fn as RecurrenceFrequency, ft as titleNumberOfLines, g as MultiWeekGridWeek, gn as WeekStartsOn, gt as resolveCalendarLabels, h as MultiWeekGridOptions, hn as TimeGridMode, ht as defaultCalendarLabels, i as fromZonedTime, in as BusinessHoursBand, it as eventAccessibilityLabel, j as monthVisibleBars, jt as getViewDays, k as layoutMonthWeek, kt as filterHiddenDays, l as zonedTimeToUtc, ln as CreateGhostArgs, lt as monthEventCapacity, m as MultiWeekGridInterval, mn as ScrollToTimeOptions, mt as dayAccessibilityLabel, n as eventsInTimeZone, nn as lightColors, nt as MIN_BOX_HEIGHT_FOR_TIME, o as toZonedTime, on as CalendarEvent, ot as eventTimeLabel, p as MultiWeekGridDay, pn as RecurrenceRule, pt as CalendarLabels, q as EventSourceOptions, qt as isWithinDateRange, r as fromZonedRange, rn as BusinessHours, rt as MonthEventCapacity, s as zonedDragBounds, sn as CalendarHandle, st as formatHour, t as ZonedDragBoundsOptions, tn as darkColors, tt as EventChipLayout, u as ExpandRecurringEventsOptions, un as EventKeyExtractor, ut as monthVisibleCount, v as MonthEventSegment, vt as clampMoveStartMinutes, w as MonthWeekEvents, wt as pageStepDays, x as MonthGridWeek, xt as monthDropBounds, y as MonthGrid, yt as eventsOverlap, z as drawnEnd, zt as CalendarSelection } from "./timezone-DhGhYIeB.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, 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 };
|
|
94
|
+
export { BusinessHours, BusinessHoursBand, BusinessHoursValue, CalendarColors, CalendarEvent, CalendarHandle, CalendarLabels, CalendarMode, CalendarSelection, CreateGhostArgs, DateRange, DateSelectionConstraints, DayBadgeKind, DaySelectionState, EventAccessibilityLabelContext, EventAccessibilityLabeler, EventChipLayout, EventKeyExtractor, EventSource, EventSourceOptions, ExpandRecurringEventsOptions, ICalEvent, ICalendarEvent, MIN_BOX_HEIGHT_FOR_TIME, MonthEventCapacity, MonthEventSegment, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, MonthRowLanes, MonthWeekEvents, MultiWeekGrid, MultiWeekGridDay, MultiWeekGridInterval, MultiWeekGridOptions, MultiWeekGridWeek, PositionedEvent, RangeBandKind, RecurrenceFrequency, RecurrenceRule, ScrollToTimeOptions, TimeGridMode, ToICalendarOptions, UseDateRangeOptions, UseMonthGridOptions, WeekStartsOn, WeekdayFormat, ZonedDragBoundsOptions, 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, fromZonedRange, fromZonedTime, getIsToday, getViewDays, getWeekDays, getYearMonths, groupEventsByDay, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isTimeVisibleAtHeight, isWeekend, isWithinDateRange, keepMonthDraftVisible, layoutDayEvents, layoutMonthWeek, lightColors, loadEventSource, minutesIntoDay, monthCreateRange, monthDropBounds, monthEventCapacity, monthExtraLaneColumns, monthVisibleBars, monthVisibleCount, movedClockSpan, nextDateRange, nowInTimeZone, overlapsOtherEvents, pageStepDays, parseICalendar, rangeBandKind, resolveCalendarLabels, resolveDraggedBounds, shiftMinutes, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, viewDayCount, wallClockHours, weekDaysCount, weekdayFormatToken, withDraftEventDays, zonedDragBounds, zonedEventSource, zonedTimeToUtc };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as EventAccessibilityLabelContext, $t as rangeBandKind, A as monthExtraLaneColumns, At as getIsToday, B as eventDayKeys, Bt as DateRange, C as MonthRowLanes, Ct as overlapsOtherEvents, D as buildMonthGrid, Dt as snapDeltaMinutes, E as WeekdayFormat, Et as shiftMinutes, F as backgroundBandsForDay, Ft as isWeekend, G as wallClockHours, Gt as isDateSelectable, H as isAllDayEvent, Ht as DaySelectionState, I as clockHoursBetween, It as minutesIntoDay, J as loadEventSource, Jt as nextDateRange, K as EventSource, Kt as isRangeEndpoint, L as closedHourBands, Lt as viewDayCount, M as weekdayFormatToken, Mt as getWeekDays, N as withDraftEventDays, Nt as getYearMonths, O as keepMonthDraftVisible, Ot as buildMonthWeeks, P as PositionedEvent, Pt as isSameCalendarDay, Q as toICalendar, Qt as dayBadgeKind, R as compareDayEvents, Rt as weekDaysCount, S as MonthGridWeekday, St as movedClockSpan, T as UseMonthGridOptions, Tt as resolveDraggedBounds, U as isBackgroundEvent, Ut as UseDateRangeOptions, V as groupEventsByDay, Vt as DateSelectionConstraints, W as layoutDayEvents, Wt as daySelectionState, X as ToICalendarOptions, Xt as RangeBandKind, Y as ICalEvent, Yt as DayBadgeKind, Z as parseICalendar, Zt as bandRounding, _ as buildMultiWeekGrid, _t as cellRangeFromDrag, a as nowInTimeZone, an as BusinessHoursValue, at as eventChipLayout, b as MonthGridDay, bt as monthCreateRange, c as zonedEventSource, cn as CalendarMode, ct as isTimeVisibleAtHeight, d as expandRecurringEvents, dn as ICalendarEvent, dt as titleEllipsizeMode, en as CalendarColors, et as EventAccessibilityLabeler, f as MultiWeekGrid, fn as RecurrenceFrequency, ft as titleNumberOfLines, g as MultiWeekGridWeek, gn as WeekStartsOn, gt as resolveCalendarLabels, h as MultiWeekGridOptions, hn as TimeGridMode, ht as defaultCalendarLabels, i as fromZonedTime, in as BusinessHoursBand, it as eventAccessibilityLabel, j as monthVisibleBars, jt as getViewDays, k as layoutMonthWeek, kt as filterHiddenDays, l as zonedTimeToUtc, ln as CreateGhostArgs, lt as monthEventCapacity, m as MultiWeekGridInterval, mn as ScrollToTimeOptions, mt as dayAccessibilityLabel, n as eventsInTimeZone, nn as lightColors, nt as MIN_BOX_HEIGHT_FOR_TIME, o as toZonedTime, on as CalendarEvent, ot as eventTimeLabel, p as MultiWeekGridDay, pn as RecurrenceRule, pt as CalendarLabels, q as EventSourceOptions, qt as isWithinDateRange, r as fromZonedRange, rn as BusinessHours, rt as MonthEventCapacity, s as zonedDragBounds, sn as CalendarHandle, st as formatHour, t as ZonedDragBoundsOptions, tn as darkColors, tt as EventChipLayout, u as ExpandRecurringEventsOptions, un as EventKeyExtractor, ut as monthVisibleCount, v as MonthEventSegment, vt as clampMoveStartMinutes, w as MonthWeekEvents, wt as pageStepDays, x as MonthGridWeek, xt as monthDropBounds, y as MonthGrid, yt as eventsOverlap, z as drawnEnd, zt as CalendarSelection } from "./timezone-DhGhYIeB.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, 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 };
|
|
94
|
+
export { BusinessHours, BusinessHoursBand, BusinessHoursValue, CalendarColors, CalendarEvent, CalendarHandle, CalendarLabels, CalendarMode, CalendarSelection, CreateGhostArgs, DateRange, DateSelectionConstraints, DayBadgeKind, DaySelectionState, EventAccessibilityLabelContext, EventAccessibilityLabeler, EventChipLayout, EventKeyExtractor, EventSource, EventSourceOptions, ExpandRecurringEventsOptions, ICalEvent, ICalendarEvent, MIN_BOX_HEIGHT_FOR_TIME, MonthEventCapacity, MonthEventSegment, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, MonthRowLanes, MonthWeekEvents, MultiWeekGrid, MultiWeekGridDay, MultiWeekGridInterval, MultiWeekGridOptions, MultiWeekGridWeek, PositionedEvent, RangeBandKind, RecurrenceFrequency, RecurrenceRule, ScrollToTimeOptions, TimeGridMode, ToICalendarOptions, UseDateRangeOptions, UseMonthGridOptions, WeekStartsOn, WeekdayFormat, ZonedDragBoundsOptions, 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, fromZonedRange, fromZonedTime, getIsToday, getViewDays, getWeekDays, getYearMonths, groupEventsByDay, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isTimeVisibleAtHeight, isWeekend, isWithinDateRange, keepMonthDraftVisible, layoutDayEvents, layoutMonthWeek, lightColors, loadEventSource, minutesIntoDay, monthCreateRange, monthDropBounds, monthEventCapacity, monthExtraLaneColumns, monthVisibleBars, monthVisibleCount, movedClockSpan, nextDateRange, nowInTimeZone, overlapsOtherEvents, pageStepDays, parseICalendar, rangeBandKind, resolveCalendarLabels, resolveDraggedBounds, shiftMinutes, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, viewDayCount, wallClockHours, weekDaysCount, weekdayFormatToken, withDraftEventDays, zonedDragBounds, zonedEventSource, zonedTimeToUtc };
|
package/dist/index.js
CHANGED
|
@@ -1,26 +1,22 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_recurrence = require("./recurrence-
|
|
2
|
+
const require_recurrence = require("./recurrence-CTjr6nxJ.js");
|
|
3
3
|
let date_fns = require("date-fns");
|
|
4
4
|
let react = require("react");
|
|
5
5
|
// src/utils/useNow.ts
|
|
6
6
|
const MINUTE_MS = 6e4;
|
|
7
|
-
const resolveNow = (now, timeZone) => {
|
|
8
|
-
const instant = now ?? /* @__PURE__ */ new Date();
|
|
9
|
-
return timeZone ? require_recurrence.toZonedTime(instant, timeZone) : instant;
|
|
10
|
-
};
|
|
11
7
|
/**
|
|
12
8
|
* The current wall-clock time, re-read every `tickMs` while `enabled`, shifted
|
|
13
9
|
* into `timeZone` when given, or pinned to a fixed `now` override. Drives the
|
|
14
10
|
* now indicator on both renderers so it can't disagree with zone-shifted events.
|
|
15
11
|
*/
|
|
16
12
|
function useNow(enabled, { now, timeZone, tickMs = MINUTE_MS } = {}) {
|
|
17
|
-
const [value, setValue] = (0, react.useState)(() =>
|
|
13
|
+
const [value, setValue] = (0, react.useState)(() => require_recurrence.nowInTimeZone(now, timeZone));
|
|
18
14
|
const nowMs = now?.getTime();
|
|
19
15
|
(0, react.useEffect)(() => {
|
|
20
16
|
if (!enabled) return;
|
|
21
|
-
setValue(
|
|
17
|
+
setValue(require_recurrence.nowInTimeZone(nowMs != null ? new Date(nowMs) : void 0, timeZone));
|
|
22
18
|
if (nowMs != null) return;
|
|
23
|
-
const id = setInterval(() => setValue(
|
|
19
|
+
const id = setInterval(() => setValue(require_recurrence.nowInTimeZone(void 0, timeZone)), tickMs);
|
|
24
20
|
return () => clearInterval(id);
|
|
25
21
|
}, [
|
|
26
22
|
enabled,
|
|
@@ -173,7 +169,8 @@ function useDateRange(options = {}) {
|
|
|
173
169
|
* ```
|
|
174
170
|
*/
|
|
175
171
|
function useMonthGrid(month, options = {}) {
|
|
176
|
-
const { weekStartsOn, showSixWeeks, isRTL, selectedDates, selectedRange, minDate, maxDate, isDateDisabled, locale } = options;
|
|
172
|
+
const { weekStartsOn, showSixWeeks, isRTL, selectedDates, selectedRange, minDate, maxDate, isDateDisabled, locale, today } = options;
|
|
173
|
+
const todayKey = today ? (0, date_fns.startOfDay)(today).getTime() : void 0;
|
|
177
174
|
return (0, react.useMemo)(() => require_recurrence.buildMonthGrid(month, options), [
|
|
178
175
|
month,
|
|
179
176
|
weekStartsOn,
|
|
@@ -184,7 +181,8 @@ function useMonthGrid(month, options = {}) {
|
|
|
184
181
|
minDate,
|
|
185
182
|
maxDate,
|
|
186
183
|
isDateDisabled,
|
|
187
|
-
locale
|
|
184
|
+
locale,
|
|
185
|
+
todayKey
|
|
188
186
|
]);
|
|
189
187
|
}
|
|
190
188
|
exports.CalendarSelectionProvider = CalendarSelectionProvider;
|
|
@@ -214,6 +212,8 @@ exports.eventsOverlap = require_recurrence.eventsOverlap;
|
|
|
214
212
|
exports.expandRecurringEvents = require_recurrence.expandRecurringEvents;
|
|
215
213
|
exports.filterHiddenDays = require_recurrence.filterHiddenDays;
|
|
216
214
|
exports.formatHour = require_recurrence.formatHour;
|
|
215
|
+
exports.fromZonedRange = require_recurrence.fromZonedRange;
|
|
216
|
+
exports.fromZonedTime = require_recurrence.fromZonedTime;
|
|
217
217
|
exports.getIsToday = require_recurrence.getIsToday;
|
|
218
218
|
exports.getViewDays = require_recurrence.getViewDays;
|
|
219
219
|
exports.getWeekDays = require_recurrence.getWeekDays;
|
|
@@ -227,6 +227,7 @@ exports.isSameCalendarDay = require_recurrence.isSameCalendarDay;
|
|
|
227
227
|
exports.isTimeVisibleAtHeight = require_recurrence.isTimeVisibleAtHeight;
|
|
228
228
|
exports.isWeekend = require_recurrence.isWeekend;
|
|
229
229
|
exports.isWithinDateRange = require_recurrence.isWithinDateRange;
|
|
230
|
+
exports.keepMonthDraftVisible = require_recurrence.keepMonthDraftVisible;
|
|
230
231
|
exports.layoutDayEvents = require_recurrence.layoutDayEvents;
|
|
231
232
|
exports.layoutMonthWeek = require_recurrence.layoutMonthWeek;
|
|
232
233
|
exports.lightColors = require_recurrence.lightColors;
|
|
@@ -235,9 +236,12 @@ exports.minutesIntoDay = require_recurrence.minutesIntoDay;
|
|
|
235
236
|
exports.monthCreateRange = require_recurrence.monthCreateRange;
|
|
236
237
|
exports.monthDropBounds = require_recurrence.monthDropBounds;
|
|
237
238
|
exports.monthEventCapacity = require_recurrence.monthEventCapacity;
|
|
239
|
+
exports.monthExtraLaneColumns = require_recurrence.monthExtraLaneColumns;
|
|
240
|
+
exports.monthVisibleBars = require_recurrence.monthVisibleBars;
|
|
238
241
|
exports.monthVisibleCount = require_recurrence.monthVisibleCount;
|
|
239
242
|
exports.movedClockSpan = require_recurrence.movedClockSpan;
|
|
240
243
|
exports.nextDateRange = require_recurrence.nextDateRange;
|
|
244
|
+
exports.nowInTimeZone = require_recurrence.nowInTimeZone;
|
|
241
245
|
exports.overlapsOtherEvents = require_recurrence.overlapsOtherEvents;
|
|
242
246
|
exports.pageStepDays = require_recurrence.pageStepDays;
|
|
243
247
|
exports.parseICalendar = require_recurrence.parseICalendar;
|
|
@@ -259,4 +263,7 @@ exports.viewDayCount = require_recurrence.viewDayCount;
|
|
|
259
263
|
exports.wallClockHours = require_recurrence.wallClockHours;
|
|
260
264
|
exports.weekDaysCount = require_recurrence.weekDaysCount;
|
|
261
265
|
exports.weekdayFormatToken = require_recurrence.weekdayFormatToken;
|
|
266
|
+
exports.withDraftEventDays = require_recurrence.withDraftEventDays;
|
|
267
|
+
exports.zonedDragBounds = require_recurrence.zonedDragBounds;
|
|
268
|
+
exports.zonedEventSource = require_recurrence.zonedEventSource;
|
|
262
269
|
exports.zonedTimeToUtc = require_recurrence.zonedTimeToUtc;
|
package/dist/index.mjs
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as isBackgroundEvent, A as titleNumberOfLines, B as overlapsOtherEvents, C as eventChipLayout, D as monthEventCapacity, E as isTimeVisibleAtHeight, F as clampMoveStartMinutes, G as backgroundBandsForDay, H as resolveDraggedBounds, I as eventsOverlap, J as compareDayEvents, K as clockHoursBetween, L as monthCreateRange, M as defaultCalendarLabels, N as resolveCalendarLabels, O as monthVisibleCount, P as cellRangeFromDrag, Q as isAllDayEvent, R as monthDropBounds, S as eventAccessibilityLabel, St as lightColors, T as formatHour, U as shiftMinutes, V as pageStepDays, W as snapDeltaMinutes, X as eventDayKeys, Y as drawnEnd, Z as groupEventsByDay, _ as toZonedTime, _t as weekDaysCount, a as layoutMonthWeek, at as isWithinDateRange, b as zonedTimeToUtc, bt as rangeBandKind, c as weekdayFormatToken, ct as filterHiddenDays, d as parseICalendar, dt as getWeekDays, et as layoutDayEvents, f as toICalendar, ft as getYearMonths, g as nowInTimeZone, gt as viewDayCount, h as fromZonedTime, ht as minutesIntoDay, i as keepMonthDraftVisible, it as isRangeEndpoint, j as dayAccessibilityLabel, k as titleEllipsizeMode, l as withDraftEventDays, lt as getIsToday, m as fromZonedRange, mt as isWeekend, n as buildMultiWeekGrid, nt as daySelectionState, o as monthExtraLaneColumns, ot as nextDateRange, p as eventsInTimeZone, pt as isSameCalendarDay, q as closedHourBands, r as buildMonthGrid, rt as isDateSelectable, s as monthVisibleBars, st as buildMonthWeeks, t as expandRecurringEvents, tt as wallClockHours, u as loadEventSource, ut as getViewDays, v as zonedDragBounds, vt as bandRounding, w as eventTimeLabel, x as MIN_BOX_HEIGHT_FOR_TIME, xt as darkColors, y as zonedEventSource, yt as dayBadgeKind, z as movedClockSpan } from "./recurrence-BqpCShcV.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
|
|
5
5
|
const MINUTE_MS = 6e4;
|
|
6
|
-
const resolveNow = (now, timeZone) => {
|
|
7
|
-
const instant = now ?? /* @__PURE__ */ new Date();
|
|
8
|
-
return timeZone ? toZonedTime(instant, timeZone) : instant;
|
|
9
|
-
};
|
|
10
6
|
/**
|
|
11
7
|
* The current wall-clock time, re-read every `tickMs` while `enabled`, shifted
|
|
12
8
|
* into `timeZone` when given, or pinned to a fixed `now` override. Drives the
|
|
13
9
|
* now indicator on both renderers so it can't disagree with zone-shifted events.
|
|
14
10
|
*/
|
|
15
11
|
function useNow(enabled, { now, timeZone, tickMs = MINUTE_MS } = {}) {
|
|
16
|
-
const [value, setValue] = useState(() =>
|
|
12
|
+
const [value, setValue] = useState(() => nowInTimeZone(now, timeZone));
|
|
17
13
|
const nowMs = now?.getTime();
|
|
18
14
|
useEffect(() => {
|
|
19
15
|
if (!enabled) return;
|
|
20
|
-
setValue(
|
|
16
|
+
setValue(nowInTimeZone(nowMs != null ? new Date(nowMs) : void 0, timeZone));
|
|
21
17
|
if (nowMs != null) return;
|
|
22
|
-
const id = setInterval(() => setValue(
|
|
18
|
+
const id = setInterval(() => setValue(nowInTimeZone(void 0, timeZone)), tickMs);
|
|
23
19
|
return () => clearInterval(id);
|
|
24
20
|
}, [
|
|
25
21
|
enabled,
|
|
@@ -172,7 +168,8 @@ function useDateRange(options = {}) {
|
|
|
172
168
|
* ```
|
|
173
169
|
*/
|
|
174
170
|
function useMonthGrid(month, options = {}) {
|
|
175
|
-
const { weekStartsOn, showSixWeeks, isRTL, selectedDates, selectedRange, minDate, maxDate, isDateDisabled, locale } = options;
|
|
171
|
+
const { weekStartsOn, showSixWeeks, isRTL, selectedDates, selectedRange, minDate, maxDate, isDateDisabled, locale, today } = options;
|
|
172
|
+
const todayKey = today ? startOfDay(today).getTime() : void 0;
|
|
176
173
|
return useMemo(() => buildMonthGrid(month, options), [
|
|
177
174
|
month,
|
|
178
175
|
weekStartsOn,
|
|
@@ -183,7 +180,8 @@ function useMonthGrid(month, options = {}) {
|
|
|
183
180
|
minDate,
|
|
184
181
|
maxDate,
|
|
185
182
|
isDateDisabled,
|
|
186
|
-
locale
|
|
183
|
+
locale,
|
|
184
|
+
todayKey
|
|
187
185
|
]);
|
|
188
186
|
}
|
|
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 };
|
|
187
|
+
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, fromZonedRange, fromZonedTime, getIsToday, getViewDays, getWeekDays, getYearMonths, groupEventsByDay, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isTimeVisibleAtHeight, isWeekend, isWithinDateRange, keepMonthDraftVisible, layoutDayEvents, layoutMonthWeek, lightColors, loadEventSource, minutesIntoDay, monthCreateRange, monthDropBounds, monthEventCapacity, monthExtraLaneColumns, monthVisibleBars, monthVisibleCount, movedClockSpan, nextDateRange, nowInTimeZone, overlapsOtherEvents, pageStepDays, parseICalendar, rangeBandKind, resolveCalendarLabels, resolveDraggedBounds, shiftMinutes, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, useCalendarSelection, useDateRange, useEventSource, useMonthGrid, useNow, viewDayCount, wallClockHours, weekDaysCount, weekdayFormatToken, withDraftEventDays, zonedDragBounds, zonedEventSource, zonedTimeToUtc };
|