@super-calendar/core 2.17.0 → 2.18.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 +13 -10
- package/dist/index.mjs +9 -11
- package/dist/{recurrence-CvIJfSMl.mjs → recurrence-15B6fu6K.mjs} +306 -101
- package/dist/{recurrence-D_oJ7A9D.js → recurrence-M-rJQgqd.js} +334 -99
- package/dist/{timezone-vbd68uRS.d.mts → timezone-BY2vQwRx.d.mts} +109 -13
- package/dist/{timezone-vbd68uRS.d.ts → timezone-BY2vQwRx.d.ts} +109 -13
- package/dist/vanilla.d.mts +2 -2
- package/dist/vanilla.d.ts +2 -2
- package/dist/vanilla.js +6 -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 +7 -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
|
@@ -83,6 +83,13 @@ interface RecurrenceRule {
|
|
|
83
83
|
* the event's time of day. Omit to repeat on the start date's own weekday.
|
|
84
84
|
*/
|
|
85
85
|
weekdays?: WeekStartsOn[];
|
|
86
|
+
/**
|
|
87
|
+
* For `weekly` rules with `weekdays`: the day a week starts on (0 = Sunday …
|
|
88
|
+
* 6 = Saturday). It decides which of the `weekdays` share a week, so it only
|
|
89
|
+
* changes the result when `interval` is greater than 1. Default 1 (Monday),
|
|
90
|
+
* as in RFC 5545. Maps to iCal `WKST`.
|
|
91
|
+
*/
|
|
92
|
+
weekStartsOn?: WeekStartsOn;
|
|
86
93
|
/**
|
|
87
94
|
* For `monthly`/`yearly`: repeat on the Nth weekday of the period instead of the
|
|
88
95
|
* start date's day-of-month — e.g. `{ week: 3, weekday: 1 }` is the 3rd Monday.
|
|
@@ -365,8 +372,12 @@ declare const buildMonthWeeks: (month: Date, weekStartsOn: WeekStartsOn, { showS
|
|
|
365
372
|
declare const filterHiddenDays: (days: Date[], hiddenDays?: number[]) => Date[];
|
|
366
373
|
/** True when `date` is a Saturday or Sunday. */
|
|
367
374
|
declare const isWeekend: (date: Date) => boolean;
|
|
368
|
-
/**
|
|
369
|
-
|
|
375
|
+
/**
|
|
376
|
+
* True when `date` falls on the current calendar day. Pass `today` to compare
|
|
377
|
+
* against that day instead of the device clock, e.g. the result of
|
|
378
|
+
* `nowInTimeZone` for a calendar displayed in another time zone.
|
|
379
|
+
*/
|
|
380
|
+
declare const getIsToday: (date: Date, today?: Date) => boolean;
|
|
370
381
|
/** True when `a` and `b` are the same calendar day (ignoring the time of day). */
|
|
371
382
|
declare const isSameCalendarDay: (a: Date, b: Date) => boolean;
|
|
372
383
|
/** Minutes elapsed since midnight (0–1439). */
|
|
@@ -375,8 +386,10 @@ declare const minutesIntoDay: (date: Date) => number;
|
|
|
375
386
|
declare const getYearMonths: (date: Date) => Date[];
|
|
376
387
|
/**
|
|
377
388
|
* True when two time ranges overlap. Edges touching (one ends exactly when the
|
|
378
|
-
* next begins) do not count as an overlap.
|
|
379
|
-
*
|
|
389
|
+
* next begins) do not count as an overlap. A zero-length range occupies its own
|
|
390
|
+
* instant: it overlaps a range that contains that instant or starts at it, and
|
|
391
|
+
* another zero-length range at the same instant. Compares absolute instants, so
|
|
392
|
+
* events at the same wall-clock time on different days do not overlap.
|
|
380
393
|
*/
|
|
381
394
|
declare function eventsOverlap(aStart: Date, aEnd: Date, bStart: Date, bEnd: Date): boolean;
|
|
382
395
|
/**
|
|
@@ -444,8 +457,8 @@ declare function resolveDraggedBounds(start: Date, end: Date, deltaStartMinutes:
|
|
|
444
457
|
} | null;
|
|
445
458
|
/**
|
|
446
459
|
* The all-day range swept out between two day cells of the month grid, ordered
|
|
447
|
-
* whichever way the sweep ran: `start` is
|
|
448
|
-
*
|
|
460
|
+
* whichever way the sweep ran: `start` is the first local day's start and `end` is
|
|
461
|
+
* the next day's start after the last, so a one-day sweep yields a usable event. Shared
|
|
449
462
|
* by both renderers so a month drag-to-create means the same thing on each.
|
|
450
463
|
*/
|
|
451
464
|
declare function monthCreateRange(anchor: Date, hover: Date): {
|
|
@@ -963,6 +976,11 @@ interface UseMonthGridOptions extends DateSelectionConstraints {
|
|
|
963
976
|
selectedRange?: DateRange;
|
|
964
977
|
/** A date-fns locale for the weekday labels. */
|
|
965
978
|
locale?: Locale;
|
|
979
|
+
/**
|
|
980
|
+
* The calendar day flagged `isToday`. Defaults to the device's current day;
|
|
981
|
+
* pass `nowInTimeZone(now, timeZone)` for a grid shown in another time zone.
|
|
982
|
+
*/
|
|
983
|
+
today?: Date;
|
|
966
984
|
}
|
|
967
985
|
/**
|
|
968
986
|
* Pure month-grid builder: the weeks and weekday headers for `month`, each day
|
|
@@ -1021,13 +1039,30 @@ interface MultiWeekGrid {
|
|
|
1021
1039
|
* safe integer, or the last week falls outside the range `Date` can represent.
|
|
1022
1040
|
*/
|
|
1023
1041
|
declare function buildMultiWeekGrid(date: Date, options?: MultiWeekGridOptions): MultiWeekGrid;
|
|
1042
|
+
/** Options for {@link expandRecurringEvents}. */
|
|
1043
|
+
interface ExpandRecurringEventsOptions {
|
|
1044
|
+
/**
|
|
1045
|
+
* The IANA time zone whose wall clock the rules repeat on (e.g.
|
|
1046
|
+
* `"America/New_York"`). A timed event keeps its clock time in that zone across
|
|
1047
|
+
* the zone's DST changes, and its weekday, month-day and exception rules read
|
|
1048
|
+
* that zone's calendar. An exception that reads the event's own time of day
|
|
1049
|
+
* there (or equals one of the `rdates`) drops the occurrence at that instant;
|
|
1050
|
+
* any other exception at midnight, on the device or in the zone, drops its
|
|
1051
|
+
* whole day. Omit it to repeat on the device's clock. All-day events
|
|
1052
|
+
* name calendar days, so they always repeat on the device's calendar.
|
|
1053
|
+
*/
|
|
1054
|
+
timeZone?: string;
|
|
1055
|
+
}
|
|
1024
1056
|
/**
|
|
1025
1057
|
* Materialise recurring events into concrete occurrences overlapping
|
|
1026
1058
|
* `[rangeStart, rangeEnd]`. Non-recurring events pass through untouched, so the
|
|
1027
1059
|
* result is ready to hand to `<Calendar events={...} />`. Each occurrence keeps
|
|
1028
1060
|
* the original event's duration and fields (minus `recurrence`).
|
|
1061
|
+
*
|
|
1062
|
+
* Pass `timeZone` to repeat timed events on that zone's wall clock instead of
|
|
1063
|
+
* the device's. `rangeStart` and `rangeEnd` are real instants either way.
|
|
1029
1064
|
*/
|
|
1030
|
-
declare function expandRecurringEvents<T>(events: CalendarEvent<T>[], rangeStart: Date, rangeEnd: Date): CalendarEvent<T>[];
|
|
1065
|
+
declare function expandRecurringEvents<T>(events: CalendarEvent<T>[], rangeStart: Date, rangeEnd: Date, { timeZone }?: ExpandRecurringEventsOptions): CalendarEvent<T>[];
|
|
1031
1066
|
/**
|
|
1032
1067
|
* Reinterpret an instant as its wall-clock time in `timeZone`, returned as a
|
|
1033
1068
|
* device-local `Date` whose fields (hours, minutes, …) read back as that zone's
|
|
@@ -1039,18 +1074,79 @@ declare function expandRecurringEvents<T>(events: CalendarEvent<T>[], rangeStart
|
|
|
1039
1074
|
* original UTC instant, so don't round-trip it back to a real time.
|
|
1040
1075
|
*/
|
|
1041
1076
|
declare function toZonedTime(date: Date, timeZone: string): Date;
|
|
1077
|
+
/**
|
|
1078
|
+
* The current instant, or the fixed `now` when given, as the wall clock of
|
|
1079
|
+
* `timeZone` (see {@link toZonedTime}). Without a `timeZone` it is the instant
|
|
1080
|
+
* itself, read on the device clock. Compare calendar days against it to find
|
|
1081
|
+
* "today" for a calendar displayed in another time zone.
|
|
1082
|
+
*/
|
|
1083
|
+
declare function nowInTimeZone(now?: Date, timeZone?: string): Date;
|
|
1042
1084
|
/**
|
|
1043
1085
|
* The inverse of {@link toZonedTime}: given a wall-clock time in `timeZone`,
|
|
1044
1086
|
* return the absolute UTC instant. Pass the wall clock as a `Date` whose **UTC**
|
|
1045
1087
|
* fields hold the components (e.g. `new Date(Date.UTC(y, m, d, h, min))`). Used to
|
|
1046
|
-
* resolve iCal `TZID` times; DST-correct via a two-pass offset
|
|
1047
|
-
*
|
|
1088
|
+
* resolve iCal `TZID` times; DST-correct via a two-pass offset. A time in the
|
|
1089
|
+
* hour a spring-forward change skips names no instant; it resolves the same
|
|
1090
|
+
* distance after the skipped hour (02:30 becomes 03:30), as a device clock does.
|
|
1048
1091
|
*/
|
|
1049
1092
|
declare function zonedTimeToUtc(wallClock: Date, timeZone: string): Date;
|
|
1050
1093
|
/**
|
|
1051
|
-
*
|
|
1052
|
-
*
|
|
1053
|
-
*
|
|
1094
|
+
* The inverse of {@link toZonedTime}: the real instant for a date whose
|
|
1095
|
+
* device-local fields hold a wall-clock time in `timeZone`, such as a date a
|
|
1096
|
+
* calendar displaying that zone reports. DST-correct via {@link zonedTimeToUtc}.
|
|
1097
|
+
*/
|
|
1098
|
+
declare function fromZonedTime(date: Date, timeZone: string): Date;
|
|
1099
|
+
/**
|
|
1100
|
+
* Shift every timed event's `start`/`end` through {@link toZonedTime} so the
|
|
1101
|
+
* calendar displays them in `timeZone`. Other fields are preserved. All-day
|
|
1102
|
+
* events (see `isAllDayEvent`) name calendar days, not instants, so they are
|
|
1103
|
+
* returned as they are and stay on their days. Memoize the result (e.g. with
|
|
1104
|
+
* `useMemo`) since it allocates new dates.
|
|
1054
1105
|
*/
|
|
1055
1106
|
declare function eventsInTimeZone<T>(events: CalendarEvent<T>[], timeZone: string): CalendarEvent<T>[];
|
|
1056
|
-
|
|
1107
|
+
/**
|
|
1108
|
+
* The event a display copy made by {@link eventsInTimeZone} stands for, with its
|
|
1109
|
+
* real `start` and `end`. Any other event is returned as it is. Use it in the
|
|
1110
|
+
* callbacks of a view that displays zoned events, to get back the event you
|
|
1111
|
+
* passed in.
|
|
1112
|
+
*/
|
|
1113
|
+
declare function zonedEventSource<T>(event: CalendarEvent<T>): CalendarEvent<T>;
|
|
1114
|
+
/** Options for {@link zonedDragBounds}. */
|
|
1115
|
+
interface ZonedDragBoundsOptions {
|
|
1116
|
+
/**
|
|
1117
|
+
* Keep the event's real elapsed duration when the drag moved both edges, as a
|
|
1118
|
+
* time-grid move does: the start is read off the zone's wall clock and the end
|
|
1119
|
+
* follows it, so a move across a DST change in the zone doesn't stretch or
|
|
1120
|
+
* shrink the event. Leave it off for a month-grid drop, which keeps the clock
|
|
1121
|
+
* time of both edges.
|
|
1122
|
+
*/
|
|
1123
|
+
keepDuration?: boolean;
|
|
1124
|
+
}
|
|
1125
|
+
/**
|
|
1126
|
+
* Convert the bounds a view reports for a dragged event back to real instants.
|
|
1127
|
+
* `event` is the displayed event the view passed to `onDragEvent`, and `start`
|
|
1128
|
+
* / `end` the bounds it reported. For a display copy made by
|
|
1129
|
+
* {@link eventsInTimeZone}, each bound is read as a wall-clock time in that
|
|
1130
|
+
* zone, following the zone's own DST changes; an edge the drag left alone keeps
|
|
1131
|
+
* the source event's exact instant. Bounds of any other event (an all-day
|
|
1132
|
+
* event, or one that was never shifted) are returned unchanged.
|
|
1133
|
+
*
|
|
1134
|
+
* Returns `null` when the reported span doesn't survive the conversion: an edge
|
|
1135
|
+
* dropped into the hour a spring-forward change skips moves to after it, which
|
|
1136
|
+
* can leave the event ending at or before its start. Reject such a drop.
|
|
1137
|
+
*/
|
|
1138
|
+
declare function zonedDragBounds<T>(event: CalendarEvent<T>, start: Date, end: Date, { keepDuration }?: ZonedDragBoundsOptions): {
|
|
1139
|
+
start: Date;
|
|
1140
|
+
end: Date;
|
|
1141
|
+
} | null;
|
|
1142
|
+
/**
|
|
1143
|
+
* Convert a wall-clock range a view reports in `timeZone` (a created event, for
|
|
1144
|
+
* example) to real instants. Returns `null` when the span doesn't survive the
|
|
1145
|
+
* conversion: a time in the hour a spring-forward change skips moves to after
|
|
1146
|
+
* it, which can leave the range ending at or before its start.
|
|
1147
|
+
*/
|
|
1148
|
+
declare function fromZonedRange(start: Date, end: Date, timeZone: string): {
|
|
1149
|
+
start: Date;
|
|
1150
|
+
end: Date;
|
|
1151
|
+
} | null;
|
|
1152
|
+
export { eventAccessibilityLabel as $, BusinessHoursBand as $t, backgroundBandsForDay as A, isWeekend as At, wallClockHours as B, isDateSelectable as Bt, MonthWeekEvents as C, buildMonthWeeks as Ct, layoutMonthWeek as D, getWeekDays as Dt, buildMonthGrid as E, getViewDays as Et, eventDayKeys as F, DateRange as Ft, ToICalendarOptions as G, RangeBandKind as Gt, EventSourceOptions as H, isWithinDateRange as Ht, groupEventsByDay as I, DateSelectionConstraints as It, EventAccessibilityLabelContext as J, rangeBandKind as Jt, parseICalendar as K, bandRounding as Kt, isAllDayEvent as L, DaySelectionState as Lt, closedHourBands as M, viewDayCount as Mt, compareDayEvents as N, weekDaysCount as Nt, weekdayFormatToken as O, getYearMonths as Ot, drawnEnd as P, CalendarSelection as Pt, MonthEventCapacity as Q, BusinessHours as Qt, isBackgroundEvent as R, UseDateRangeOptions as Rt, MonthGridWeekday as S, snapDeltaMinutes as St, WeekdayFormat as T, getIsToday as Tt, loadEventSource as U, nextDateRange as Ut, EventSource as V, isRangeEndpoint as Vt, ICalEvent as W, DayBadgeKind as Wt, EventChipLayout as X, darkColors as Xt, EventAccessibilityLabeler as Y, CalendarColors as Yt, MIN_BOX_HEIGHT_FOR_TIME as Z, lightColors as Zt, buildMultiWeekGrid as _, movedClockSpan as _t, nowInTimeZone as a, EventKeyExtractor as an, monthVisibleCount as at, MonthGridDay as b, resolveDraggedBounds as bt, zonedEventSource as c, RecurrenceRule as cn, CalendarLabels as ct, expandRecurringEvents as d, WeekStartsOn as dn, resolveCalendarLabels as dt, BusinessHoursValue as en, eventChipLayout as et, MultiWeekGrid as f, cellRangeFromDrag as ft, MultiWeekGridWeek as g, monthDropBounds as gt, MultiWeekGridOptions as h, monthCreateRange as ht, fromZonedTime as i, CreateGhostArgs as in, monthEventCapacity as it, clockHoursBetween as j, minutesIntoDay as jt, PositionedEvent as k, isSameCalendarDay as kt, zonedTimeToUtc as l, ScrollToTimeOptions as ln, dayAccessibilityLabel as lt, MultiWeekGridInterval as m, eventsOverlap as mt, eventsInTimeZone as n, CalendarHandle as nn, formatHour as nt, toZonedTime as o, ICalendarEvent as on, titleEllipsizeMode as ot, MultiWeekGridDay as p, clampMoveStartMinutes as pt, toICalendar as q, dayBadgeKind as qt, fromZonedRange as r, CalendarMode as rn, isTimeVisibleAtHeight as rt, zonedDragBounds as s, RecurrenceFrequency as sn, titleNumberOfLines as st, ZonedDragBoundsOptions as t, CalendarEvent as tn, eventTimeLabel as tt, ExpandRecurringEventsOptions as u, TimeGridMode as un, defaultCalendarLabels as ut, MonthEventSegment as v, overlapsOtherEvents as vt, UseMonthGridOptions as w, filterHiddenDays as wt, MonthGridWeek as x, shiftMinutes as xt, MonthGrid as y, pageStepDays as yt, layoutDayEvents as z, daySelectionState as zt };
|
|
@@ -83,6 +83,13 @@ interface RecurrenceRule {
|
|
|
83
83
|
* the event's time of day. Omit to repeat on the start date's own weekday.
|
|
84
84
|
*/
|
|
85
85
|
weekdays?: WeekStartsOn[];
|
|
86
|
+
/**
|
|
87
|
+
* For `weekly` rules with `weekdays`: the day a week starts on (0 = Sunday …
|
|
88
|
+
* 6 = Saturday). It decides which of the `weekdays` share a week, so it only
|
|
89
|
+
* changes the result when `interval` is greater than 1. Default 1 (Monday),
|
|
90
|
+
* as in RFC 5545. Maps to iCal `WKST`.
|
|
91
|
+
*/
|
|
92
|
+
weekStartsOn?: WeekStartsOn;
|
|
86
93
|
/**
|
|
87
94
|
* For `monthly`/`yearly`: repeat on the Nth weekday of the period instead of the
|
|
88
95
|
* start date's day-of-month — e.g. `{ week: 3, weekday: 1 }` is the 3rd Monday.
|
|
@@ -365,8 +372,12 @@ declare const buildMonthWeeks: (month: Date, weekStartsOn: WeekStartsOn, { showS
|
|
|
365
372
|
declare const filterHiddenDays: (days: Date[], hiddenDays?: number[]) => Date[];
|
|
366
373
|
/** True when `date` is a Saturday or Sunday. */
|
|
367
374
|
declare const isWeekend: (date: Date) => boolean;
|
|
368
|
-
/**
|
|
369
|
-
|
|
375
|
+
/**
|
|
376
|
+
* True when `date` falls on the current calendar day. Pass `today` to compare
|
|
377
|
+
* against that day instead of the device clock, e.g. the result of
|
|
378
|
+
* `nowInTimeZone` for a calendar displayed in another time zone.
|
|
379
|
+
*/
|
|
380
|
+
declare const getIsToday: (date: Date, today?: Date) => boolean;
|
|
370
381
|
/** True when `a` and `b` are the same calendar day (ignoring the time of day). */
|
|
371
382
|
declare const isSameCalendarDay: (a: Date, b: Date) => boolean;
|
|
372
383
|
/** Minutes elapsed since midnight (0–1439). */
|
|
@@ -375,8 +386,10 @@ declare const minutesIntoDay: (date: Date) => number;
|
|
|
375
386
|
declare const getYearMonths: (date: Date) => Date[];
|
|
376
387
|
/**
|
|
377
388
|
* True when two time ranges overlap. Edges touching (one ends exactly when the
|
|
378
|
-
* next begins) do not count as an overlap.
|
|
379
|
-
*
|
|
389
|
+
* next begins) do not count as an overlap. A zero-length range occupies its own
|
|
390
|
+
* instant: it overlaps a range that contains that instant or starts at it, and
|
|
391
|
+
* another zero-length range at the same instant. Compares absolute instants, so
|
|
392
|
+
* events at the same wall-clock time on different days do not overlap.
|
|
380
393
|
*/
|
|
381
394
|
declare function eventsOverlap(aStart: Date, aEnd: Date, bStart: Date, bEnd: Date): boolean;
|
|
382
395
|
/**
|
|
@@ -444,8 +457,8 @@ declare function resolveDraggedBounds(start: Date, end: Date, deltaStartMinutes:
|
|
|
444
457
|
} | null;
|
|
445
458
|
/**
|
|
446
459
|
* The all-day range swept out between two day cells of the month grid, ordered
|
|
447
|
-
* whichever way the sweep ran: `start` is
|
|
448
|
-
*
|
|
460
|
+
* whichever way the sweep ran: `start` is the first local day's start and `end` is
|
|
461
|
+
* the next day's start after the last, so a one-day sweep yields a usable event. Shared
|
|
449
462
|
* by both renderers so a month drag-to-create means the same thing on each.
|
|
450
463
|
*/
|
|
451
464
|
declare function monthCreateRange(anchor: Date, hover: Date): {
|
|
@@ -963,6 +976,11 @@ interface UseMonthGridOptions extends DateSelectionConstraints {
|
|
|
963
976
|
selectedRange?: DateRange;
|
|
964
977
|
/** A date-fns locale for the weekday labels. */
|
|
965
978
|
locale?: Locale;
|
|
979
|
+
/**
|
|
980
|
+
* The calendar day flagged `isToday`. Defaults to the device's current day;
|
|
981
|
+
* pass `nowInTimeZone(now, timeZone)` for a grid shown in another time zone.
|
|
982
|
+
*/
|
|
983
|
+
today?: Date;
|
|
966
984
|
}
|
|
967
985
|
/**
|
|
968
986
|
* Pure month-grid builder: the weeks and weekday headers for `month`, each day
|
|
@@ -1021,13 +1039,30 @@ interface MultiWeekGrid {
|
|
|
1021
1039
|
* safe integer, or the last week falls outside the range `Date` can represent.
|
|
1022
1040
|
*/
|
|
1023
1041
|
declare function buildMultiWeekGrid(date: Date, options?: MultiWeekGridOptions): MultiWeekGrid;
|
|
1042
|
+
/** Options for {@link expandRecurringEvents}. */
|
|
1043
|
+
interface ExpandRecurringEventsOptions {
|
|
1044
|
+
/**
|
|
1045
|
+
* The IANA time zone whose wall clock the rules repeat on (e.g.
|
|
1046
|
+
* `"America/New_York"`). A timed event keeps its clock time in that zone across
|
|
1047
|
+
* the zone's DST changes, and its weekday, month-day and exception rules read
|
|
1048
|
+
* that zone's calendar. An exception that reads the event's own time of day
|
|
1049
|
+
* there (or equals one of the `rdates`) drops the occurrence at that instant;
|
|
1050
|
+
* any other exception at midnight, on the device or in the zone, drops its
|
|
1051
|
+
* whole day. Omit it to repeat on the device's clock. All-day events
|
|
1052
|
+
* name calendar days, so they always repeat on the device's calendar.
|
|
1053
|
+
*/
|
|
1054
|
+
timeZone?: string;
|
|
1055
|
+
}
|
|
1024
1056
|
/**
|
|
1025
1057
|
* Materialise recurring events into concrete occurrences overlapping
|
|
1026
1058
|
* `[rangeStart, rangeEnd]`. Non-recurring events pass through untouched, so the
|
|
1027
1059
|
* result is ready to hand to `<Calendar events={...} />`. Each occurrence keeps
|
|
1028
1060
|
* the original event's duration and fields (minus `recurrence`).
|
|
1061
|
+
*
|
|
1062
|
+
* Pass `timeZone` to repeat timed events on that zone's wall clock instead of
|
|
1063
|
+
* the device's. `rangeStart` and `rangeEnd` are real instants either way.
|
|
1029
1064
|
*/
|
|
1030
|
-
declare function expandRecurringEvents<T>(events: CalendarEvent<T>[], rangeStart: Date, rangeEnd: Date): CalendarEvent<T>[];
|
|
1065
|
+
declare function expandRecurringEvents<T>(events: CalendarEvent<T>[], rangeStart: Date, rangeEnd: Date, { timeZone }?: ExpandRecurringEventsOptions): CalendarEvent<T>[];
|
|
1031
1066
|
/**
|
|
1032
1067
|
* Reinterpret an instant as its wall-clock time in `timeZone`, returned as a
|
|
1033
1068
|
* device-local `Date` whose fields (hours, minutes, …) read back as that zone's
|
|
@@ -1039,18 +1074,79 @@ declare function expandRecurringEvents<T>(events: CalendarEvent<T>[], rangeStart
|
|
|
1039
1074
|
* original UTC instant, so don't round-trip it back to a real time.
|
|
1040
1075
|
*/
|
|
1041
1076
|
declare function toZonedTime(date: Date, timeZone: string): Date;
|
|
1077
|
+
/**
|
|
1078
|
+
* The current instant, or the fixed `now` when given, as the wall clock of
|
|
1079
|
+
* `timeZone` (see {@link toZonedTime}). Without a `timeZone` it is the instant
|
|
1080
|
+
* itself, read on the device clock. Compare calendar days against it to find
|
|
1081
|
+
* "today" for a calendar displayed in another time zone.
|
|
1082
|
+
*/
|
|
1083
|
+
declare function nowInTimeZone(now?: Date, timeZone?: string): Date;
|
|
1042
1084
|
/**
|
|
1043
1085
|
* The inverse of {@link toZonedTime}: given a wall-clock time in `timeZone`,
|
|
1044
1086
|
* return the absolute UTC instant. Pass the wall clock as a `Date` whose **UTC**
|
|
1045
1087
|
* fields hold the components (e.g. `new Date(Date.UTC(y, m, d, h, min))`). Used to
|
|
1046
|
-
* resolve iCal `TZID` times; DST-correct via a two-pass offset
|
|
1047
|
-
*
|
|
1088
|
+
* resolve iCal `TZID` times; DST-correct via a two-pass offset. A time in the
|
|
1089
|
+
* hour a spring-forward change skips names no instant; it resolves the same
|
|
1090
|
+
* distance after the skipped hour (02:30 becomes 03:30), as a device clock does.
|
|
1048
1091
|
*/
|
|
1049
1092
|
declare function zonedTimeToUtc(wallClock: Date, timeZone: string): Date;
|
|
1050
1093
|
/**
|
|
1051
|
-
*
|
|
1052
|
-
*
|
|
1053
|
-
*
|
|
1094
|
+
* The inverse of {@link toZonedTime}: the real instant for a date whose
|
|
1095
|
+
* device-local fields hold a wall-clock time in `timeZone`, such as a date a
|
|
1096
|
+
* calendar displaying that zone reports. DST-correct via {@link zonedTimeToUtc}.
|
|
1097
|
+
*/
|
|
1098
|
+
declare function fromZonedTime(date: Date, timeZone: string): Date;
|
|
1099
|
+
/**
|
|
1100
|
+
* Shift every timed event's `start`/`end` through {@link toZonedTime} so the
|
|
1101
|
+
* calendar displays them in `timeZone`. Other fields are preserved. All-day
|
|
1102
|
+
* events (see `isAllDayEvent`) name calendar days, not instants, so they are
|
|
1103
|
+
* returned as they are and stay on their days. Memoize the result (e.g. with
|
|
1104
|
+
* `useMemo`) since it allocates new dates.
|
|
1054
1105
|
*/
|
|
1055
1106
|
declare function eventsInTimeZone<T>(events: CalendarEvent<T>[], timeZone: string): CalendarEvent<T>[];
|
|
1056
|
-
|
|
1107
|
+
/**
|
|
1108
|
+
* The event a display copy made by {@link eventsInTimeZone} stands for, with its
|
|
1109
|
+
* real `start` and `end`. Any other event is returned as it is. Use it in the
|
|
1110
|
+
* callbacks of a view that displays zoned events, to get back the event you
|
|
1111
|
+
* passed in.
|
|
1112
|
+
*/
|
|
1113
|
+
declare function zonedEventSource<T>(event: CalendarEvent<T>): CalendarEvent<T>;
|
|
1114
|
+
/** Options for {@link zonedDragBounds}. */
|
|
1115
|
+
interface ZonedDragBoundsOptions {
|
|
1116
|
+
/**
|
|
1117
|
+
* Keep the event's real elapsed duration when the drag moved both edges, as a
|
|
1118
|
+
* time-grid move does: the start is read off the zone's wall clock and the end
|
|
1119
|
+
* follows it, so a move across a DST change in the zone doesn't stretch or
|
|
1120
|
+
* shrink the event. Leave it off for a month-grid drop, which keeps the clock
|
|
1121
|
+
* time of both edges.
|
|
1122
|
+
*/
|
|
1123
|
+
keepDuration?: boolean;
|
|
1124
|
+
}
|
|
1125
|
+
/**
|
|
1126
|
+
* Convert the bounds a view reports for a dragged event back to real instants.
|
|
1127
|
+
* `event` is the displayed event the view passed to `onDragEvent`, and `start`
|
|
1128
|
+
* / `end` the bounds it reported. For a display copy made by
|
|
1129
|
+
* {@link eventsInTimeZone}, each bound is read as a wall-clock time in that
|
|
1130
|
+
* zone, following the zone's own DST changes; an edge the drag left alone keeps
|
|
1131
|
+
* the source event's exact instant. Bounds of any other event (an all-day
|
|
1132
|
+
* event, or one that was never shifted) are returned unchanged.
|
|
1133
|
+
*
|
|
1134
|
+
* Returns `null` when the reported span doesn't survive the conversion: an edge
|
|
1135
|
+
* dropped into the hour a spring-forward change skips moves to after it, which
|
|
1136
|
+
* can leave the event ending at or before its start. Reject such a drop.
|
|
1137
|
+
*/
|
|
1138
|
+
declare function zonedDragBounds<T>(event: CalendarEvent<T>, start: Date, end: Date, { keepDuration }?: ZonedDragBoundsOptions): {
|
|
1139
|
+
start: Date;
|
|
1140
|
+
end: Date;
|
|
1141
|
+
} | null;
|
|
1142
|
+
/**
|
|
1143
|
+
* Convert a wall-clock range a view reports in `timeZone` (a created event, for
|
|
1144
|
+
* example) to real instants. Returns `null` when the span doesn't survive the
|
|
1145
|
+
* conversion: a time in the hour a spring-forward change skips moves to after
|
|
1146
|
+
* it, which can leave the range ending at or before its start.
|
|
1147
|
+
*/
|
|
1148
|
+
declare function fromZonedRange(start: Date, end: Date, timeZone: string): {
|
|
1149
|
+
start: Date;
|
|
1150
|
+
end: Date;
|
|
1151
|
+
} | null;
|
|
1152
|
+
export { eventAccessibilityLabel as $, BusinessHoursBand as $t, backgroundBandsForDay as A, isWeekend as At, wallClockHours as B, isDateSelectable as Bt, MonthWeekEvents as C, buildMonthWeeks as Ct, layoutMonthWeek as D, getWeekDays as Dt, buildMonthGrid as E, getViewDays as Et, eventDayKeys as F, DateRange as Ft, ToICalendarOptions as G, RangeBandKind as Gt, EventSourceOptions as H, isWithinDateRange as Ht, groupEventsByDay as I, DateSelectionConstraints as It, EventAccessibilityLabelContext as J, rangeBandKind as Jt, parseICalendar as K, bandRounding as Kt, isAllDayEvent as L, DaySelectionState as Lt, closedHourBands as M, viewDayCount as Mt, compareDayEvents as N, weekDaysCount as Nt, weekdayFormatToken as O, getYearMonths as Ot, drawnEnd as P, CalendarSelection as Pt, MonthEventCapacity as Q, BusinessHours as Qt, isBackgroundEvent as R, UseDateRangeOptions as Rt, MonthGridWeekday as S, snapDeltaMinutes as St, WeekdayFormat as T, getIsToday as Tt, loadEventSource as U, nextDateRange as Ut, EventSource as V, isRangeEndpoint as Vt, ICalEvent as W, DayBadgeKind as Wt, EventChipLayout as X, darkColors as Xt, EventAccessibilityLabeler as Y, CalendarColors as Yt, MIN_BOX_HEIGHT_FOR_TIME as Z, lightColors as Zt, buildMultiWeekGrid as _, movedClockSpan as _t, nowInTimeZone as a, EventKeyExtractor as an, monthVisibleCount as at, MonthGridDay as b, resolveDraggedBounds as bt, zonedEventSource as c, RecurrenceRule as cn, CalendarLabels as ct, expandRecurringEvents as d, WeekStartsOn as dn, resolveCalendarLabels as dt, BusinessHoursValue as en, eventChipLayout as et, MultiWeekGrid as f, cellRangeFromDrag as ft, MultiWeekGridWeek as g, monthDropBounds as gt, MultiWeekGridOptions as h, monthCreateRange as ht, fromZonedTime as i, CreateGhostArgs as in, monthEventCapacity as it, clockHoursBetween as j, minutesIntoDay as jt, PositionedEvent as k, isSameCalendarDay as kt, zonedTimeToUtc as l, ScrollToTimeOptions as ln, dayAccessibilityLabel as lt, MultiWeekGridInterval as m, eventsOverlap as mt, eventsInTimeZone as n, CalendarHandle as nn, formatHour as nt, toZonedTime as o, ICalendarEvent as on, titleEllipsizeMode as ot, MultiWeekGridDay as p, clampMoveStartMinutes as pt, toICalendar as q, dayBadgeKind as qt, fromZonedRange as r, CalendarMode as rn, isTimeVisibleAtHeight as rt, zonedDragBounds as s, RecurrenceFrequency as sn, titleNumberOfLines as st, ZonedDragBoundsOptions as t, CalendarEvent as tn, eventTimeLabel as tt, ExpandRecurringEventsOptions as u, TimeGridMode as un, defaultCalendarLabels as ut, MonthEventSegment as v, overlapsOtherEvents as vt, UseMonthGridOptions as w, filterHiddenDays as wt, MonthGridWeek as x, shiftMinutes as xt, MonthGrid as y, pageStepDays as yt, layoutDayEvents as z, daySelectionState 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, 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 };
|
|
1
|
+
import { $ as eventAccessibilityLabel, $t as BusinessHoursBand, A as backgroundBandsForDay, At as isWeekend, B as wallClockHours, Bt as isDateSelectable, C as MonthWeekEvents, Ct as buildMonthWeeks, D as layoutMonthWeek, Dt as getWeekDays, E as buildMonthGrid, Et as getViewDays, F as eventDayKeys, Ft as DateRange, G as ToICalendarOptions, Gt as RangeBandKind, H as EventSourceOptions, Ht as isWithinDateRange, I as groupEventsByDay, It as DateSelectionConstraints, J as EventAccessibilityLabelContext, Jt as rangeBandKind, K as parseICalendar, Kt as bandRounding, L as isAllDayEvent, Lt as DaySelectionState, M as closedHourBands, Mt as viewDayCount, N as compareDayEvents, Nt as weekDaysCount, O as weekdayFormatToken, Ot as getYearMonths, P as drawnEnd, Pt as CalendarSelection, Q as MonthEventCapacity, Qt as BusinessHours, R as isBackgroundEvent, Rt as UseDateRangeOptions, S as MonthGridWeekday, St as snapDeltaMinutes, T as WeekdayFormat, Tt as getIsToday, U as loadEventSource, Ut as nextDateRange, V as EventSource, Vt as isRangeEndpoint, W as ICalEvent, Wt as DayBadgeKind, X as EventChipLayout, Xt as darkColors, Y as EventAccessibilityLabeler, Yt as CalendarColors, Z as MIN_BOX_HEIGHT_FOR_TIME, Zt as lightColors, _ as buildMultiWeekGrid, _t as movedClockSpan, a as nowInTimeZone, an as EventKeyExtractor, at as monthVisibleCount, b as MonthGridDay, bt as resolveDraggedBounds, c as zonedEventSource, cn as RecurrenceRule, ct as CalendarLabels, d as expandRecurringEvents, dn as WeekStartsOn, dt as resolveCalendarLabels, en as BusinessHoursValue, et as eventChipLayout, f as MultiWeekGrid, ft as cellRangeFromDrag, g as MultiWeekGridWeek, gt as monthDropBounds, h as MultiWeekGridOptions, ht as monthCreateRange, i as fromZonedTime, in as CreateGhostArgs, it as monthEventCapacity, j as clockHoursBetween, jt as minutesIntoDay, k as PositionedEvent, kt as isSameCalendarDay, l as zonedTimeToUtc, ln as ScrollToTimeOptions, lt as dayAccessibilityLabel, m as MultiWeekGridInterval, mt as eventsOverlap, n as eventsInTimeZone, nn as CalendarHandle, nt as formatHour, o as toZonedTime, on as ICalendarEvent, ot as titleEllipsizeMode, p as MultiWeekGridDay, pt as clampMoveStartMinutes, q as toICalendar, qt as dayBadgeKind, r as fromZonedRange, rn as CalendarMode, rt as isTimeVisibleAtHeight, s as zonedDragBounds, sn as RecurrenceFrequency, st as titleNumberOfLines, t as ZonedDragBoundsOptions, tn as CalendarEvent, tt as eventTimeLabel, u as ExpandRecurringEventsOptions, un as TimeGridMode, ut as defaultCalendarLabels, v as MonthEventSegment, vt as overlapsOtherEvents, w as UseMonthGridOptions, wt as filterHiddenDays, x as MonthGridWeek, xt as shiftMinutes, y as MonthGrid, yt as pageStepDays, z as layoutDayEvents, zt as daySelectionState } from "./timezone-BY2vQwRx.mjs";
|
|
2
|
+
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, 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, layoutDayEvents, layoutMonthWeek, lightColors, loadEventSource, minutesIntoDay, monthCreateRange, monthDropBounds, monthEventCapacity, monthVisibleCount, movedClockSpan, nextDateRange, nowInTimeZone, overlapsOtherEvents, pageStepDays, parseICalendar, rangeBandKind, resolveCalendarLabels, resolveDraggedBounds, shiftMinutes, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, viewDayCount, wallClockHours, weekDaysCount, weekdayFormatToken, zonedDragBounds, zonedEventSource, 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, 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 };
|
|
1
|
+
import { $ as eventAccessibilityLabel, $t as BusinessHoursBand, A as backgroundBandsForDay, At as isWeekend, B as wallClockHours, Bt as isDateSelectable, C as MonthWeekEvents, Ct as buildMonthWeeks, D as layoutMonthWeek, Dt as getWeekDays, E as buildMonthGrid, Et as getViewDays, F as eventDayKeys, Ft as DateRange, G as ToICalendarOptions, Gt as RangeBandKind, H as EventSourceOptions, Ht as isWithinDateRange, I as groupEventsByDay, It as DateSelectionConstraints, J as EventAccessibilityLabelContext, Jt as rangeBandKind, K as parseICalendar, Kt as bandRounding, L as isAllDayEvent, Lt as DaySelectionState, M as closedHourBands, Mt as viewDayCount, N as compareDayEvents, Nt as weekDaysCount, O as weekdayFormatToken, Ot as getYearMonths, P as drawnEnd, Pt as CalendarSelection, Q as MonthEventCapacity, Qt as BusinessHours, R as isBackgroundEvent, Rt as UseDateRangeOptions, S as MonthGridWeekday, St as snapDeltaMinutes, T as WeekdayFormat, Tt as getIsToday, U as loadEventSource, Ut as nextDateRange, V as EventSource, Vt as isRangeEndpoint, W as ICalEvent, Wt as DayBadgeKind, X as EventChipLayout, Xt as darkColors, Y as EventAccessibilityLabeler, Yt as CalendarColors, Z as MIN_BOX_HEIGHT_FOR_TIME, Zt as lightColors, _ as buildMultiWeekGrid, _t as movedClockSpan, a as nowInTimeZone, an as EventKeyExtractor, at as monthVisibleCount, b as MonthGridDay, bt as resolveDraggedBounds, c as zonedEventSource, cn as RecurrenceRule, ct as CalendarLabels, d as expandRecurringEvents, dn as WeekStartsOn, dt as resolveCalendarLabels, en as BusinessHoursValue, et as eventChipLayout, f as MultiWeekGrid, ft as cellRangeFromDrag, g as MultiWeekGridWeek, gt as monthDropBounds, h as MultiWeekGridOptions, ht as monthCreateRange, i as fromZonedTime, in as CreateGhostArgs, it as monthEventCapacity, j as clockHoursBetween, jt as minutesIntoDay, k as PositionedEvent, kt as isSameCalendarDay, l as zonedTimeToUtc, ln as ScrollToTimeOptions, lt as dayAccessibilityLabel, m as MultiWeekGridInterval, mt as eventsOverlap, n as eventsInTimeZone, nn as CalendarHandle, nt as formatHour, o as toZonedTime, on as ICalendarEvent, ot as titleEllipsizeMode, p as MultiWeekGridDay, pt as clampMoveStartMinutes, q as toICalendar, qt as dayBadgeKind, r as fromZonedRange, rn as CalendarMode, rt as isTimeVisibleAtHeight, s as zonedDragBounds, sn as RecurrenceFrequency, st as titleNumberOfLines, t as ZonedDragBoundsOptions, tn as CalendarEvent, tt as eventTimeLabel, u as ExpandRecurringEventsOptions, un as TimeGridMode, ut as defaultCalendarLabels, v as MonthEventSegment, vt as overlapsOtherEvents, w as UseMonthGridOptions, wt as filterHiddenDays, x as MonthGridWeek, xt as shiftMinutes, y as MonthGrid, yt as pageStepDays, z as layoutDayEvents, zt as daySelectionState } from "./timezone-BY2vQwRx.js";
|
|
2
|
+
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, 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, layoutDayEvents, layoutMonthWeek, lightColors, loadEventSource, minutesIntoDay, monthCreateRange, monthDropBounds, monthEventCapacity, monthVisibleCount, movedClockSpan, nextDateRange, nowInTimeZone, overlapsOtherEvents, pageStepDays, parseICalendar, rangeBandKind, resolveCalendarLabels, resolveDraggedBounds, shiftMinutes, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, viewDayCount, wallClockHours, weekDaysCount, weekdayFormatToken, zonedDragBounds, zonedEventSource, zonedTimeToUtc };
|
package/dist/vanilla.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-M-rJQgqd.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;
|
|
@@ -26,6 +26,8 @@ exports.eventsOverlap = require_recurrence.eventsOverlap;
|
|
|
26
26
|
exports.expandRecurringEvents = require_recurrence.expandRecurringEvents;
|
|
27
27
|
exports.filterHiddenDays = require_recurrence.filterHiddenDays;
|
|
28
28
|
exports.formatHour = require_recurrence.formatHour;
|
|
29
|
+
exports.fromZonedRange = require_recurrence.fromZonedRange;
|
|
30
|
+
exports.fromZonedTime = require_recurrence.fromZonedTime;
|
|
29
31
|
exports.getIsToday = require_recurrence.getIsToday;
|
|
30
32
|
exports.getViewDays = require_recurrence.getViewDays;
|
|
31
33
|
exports.getWeekDays = require_recurrence.getWeekDays;
|
|
@@ -50,6 +52,7 @@ exports.monthEventCapacity = require_recurrence.monthEventCapacity;
|
|
|
50
52
|
exports.monthVisibleCount = require_recurrence.monthVisibleCount;
|
|
51
53
|
exports.movedClockSpan = require_recurrence.movedClockSpan;
|
|
52
54
|
exports.nextDateRange = require_recurrence.nextDateRange;
|
|
55
|
+
exports.nowInTimeZone = require_recurrence.nowInTimeZone;
|
|
53
56
|
exports.overlapsOtherEvents = require_recurrence.overlapsOtherEvents;
|
|
54
57
|
exports.pageStepDays = require_recurrence.pageStepDays;
|
|
55
58
|
exports.parseICalendar = require_recurrence.parseICalendar;
|
|
@@ -66,4 +69,6 @@ exports.viewDayCount = require_recurrence.viewDayCount;
|
|
|
66
69
|
exports.wallClockHours = require_recurrence.wallClockHours;
|
|
67
70
|
exports.weekDaysCount = require_recurrence.weekDaysCount;
|
|
68
71
|
exports.weekdayFormatToken = require_recurrence.weekdayFormatToken;
|
|
72
|
+
exports.zonedDragBounds = require_recurrence.zonedDragBounds;
|
|
73
|
+
exports.zonedEventSource = require_recurrence.zonedEventSource;
|
|
69
74
|
exports.zonedTimeToUtc = require_recurrence.zonedTimeToUtc;
|
package/dist/vanilla.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { _ as MIN_BOX_HEIGHT_FOR_TIME, V as backgroundBandsForDay, mt as bandRounding, r as buildMonthGrid, rt as buildMonthWeeks, n as buildMultiWeekGrid, A as cellRangeFromDrag, j as clampMoveStartMinutes, H as clockHoursBetween, U as closedHourBands, W as compareDayEvents, _t as darkColors, D as dayAccessibilityLabel, ht as dayBadgeKind, Q as daySelectionState, O as defaultCalendarLabels, G as drawnEnd, v as eventAccessibilityLabel, y as eventChipLayout, K as eventDayKeys, b as eventTimeLabel, l as eventsInTimeZone, M as eventsOverlap, t as expandRecurringEvents, it as filterHiddenDays, x as formatHour, u as fromZonedRange, d as fromZonedTime, at as getIsToday, ot as getViewDays, st as getWeekDays, ct as getYearMonths, q as groupEventsByDay, J as isAllDayEvent, Y as isBackgroundEvent, $ as isDateSelectable, et as isRangeEndpoint, lt as isSameCalendarDay, S as isTimeVisibleAtHeight, ut as isWeekend, tt as isWithinDateRange, X as layoutDayEvents, i as layoutMonthWeek, vt as lightColors, o as loadEventSource, dt as minutesIntoDay, N as monthCreateRange, P as monthDropBounds, C as monthEventCapacity, w as monthVisibleCount, F as movedClockSpan, nt as nextDateRange, f as nowInTimeZone, I as overlapsOtherEvents, L as pageStepDays, s as parseICalendar, gt as rangeBandKind, k as resolveCalendarLabels, R as resolveDraggedBounds, z as shiftMinutes, B as snapDeltaMinutes, T as titleEllipsizeMode, E as titleNumberOfLines, c as toICalendar, p as toZonedTime, ft as viewDayCount, Z as wallClockHours, pt as weekDaysCount, a as weekdayFormatToken, m as zonedDragBounds, h as zonedEventSource, g as zonedTimeToUtc } from "./recurrence-15B6fu6K.mjs";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@super-calendar/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.18.0",
|
|
4
4
|
"description": "Render-agnostic core for super-calendar: date math, selection model, event layout, the month-grid builder, headless hooks, and neutral theme tokens. No renderer.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"calendar",
|
package/src/types.ts
CHANGED
|
@@ -94,6 +94,13 @@ export interface RecurrenceRule {
|
|
|
94
94
|
* the event's time of day. Omit to repeat on the start date's own weekday.
|
|
95
95
|
*/
|
|
96
96
|
weekdays?: WeekStartsOn[];
|
|
97
|
+
/**
|
|
98
|
+
* For `weekly` rules with `weekdays`: the day a week starts on (0 = Sunday …
|
|
99
|
+
* 6 = Saturday). It decides which of the `weekdays` share a week, so it only
|
|
100
|
+
* changes the result when `interval` is greater than 1. Default 1 (Monday),
|
|
101
|
+
* as in RFC 5545. Maps to iCal `WKST`.
|
|
102
|
+
*/
|
|
103
|
+
weekStartsOn?: WeekStartsOn;
|
|
97
104
|
/**
|
|
98
105
|
* For `monthly`/`yearly`: repeat on the Nth weekday of the period instead of the
|
|
99
106
|
* start date's day-of-month — e.g. `{ week: 3, weekday: 1 }` is the 3rd Monday.
|
package/src/utils/dates.ts
CHANGED
|
@@ -146,8 +146,13 @@ export const isWeekend = (date: Date): boolean => {
|
|
|
146
146
|
return day === 0 || day === 6;
|
|
147
147
|
};
|
|
148
148
|
|
|
149
|
-
/**
|
|
150
|
-
|
|
149
|
+
/**
|
|
150
|
+
* True when `date` falls on the current calendar day. Pass `today` to compare
|
|
151
|
+
* against that day instead of the device clock, e.g. the result of
|
|
152
|
+
* `nowInTimeZone` for a calendar displayed in another time zone.
|
|
153
|
+
*/
|
|
154
|
+
export const getIsToday = (date: Date, today?: Date): boolean =>
|
|
155
|
+
today ? isSameDay(date, today) : isToday(date);
|
|
151
156
|
|
|
152
157
|
/** True when `a` and `b` are the same calendar day (ignoring the time of day). */
|
|
153
158
|
export const isSameCalendarDay = (a: Date, b: Date): boolean => isSameDay(a, b);
|
package/src/utils/drag.ts
CHANGED
|
@@ -6,11 +6,19 @@ import { MIN_DURATION_HOURS } from "./minDuration";
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* True when two time ranges overlap. Edges touching (one ends exactly when the
|
|
9
|
-
* next begins) do not count as an overlap.
|
|
10
|
-
*
|
|
9
|
+
* next begins) do not count as an overlap. A zero-length range occupies its own
|
|
10
|
+
* instant: it overlaps a range that contains that instant or starts at it, and
|
|
11
|
+
* another zero-length range at the same instant. Compares absolute instants, so
|
|
12
|
+
* events at the same wall-clock time on different days do not overlap.
|
|
11
13
|
*/
|
|
12
14
|
export function eventsOverlap(aStart: Date, aEnd: Date, bStart: Date, bEnd: Date): boolean {
|
|
13
|
-
|
|
15
|
+
const a0 = aStart.getTime();
|
|
16
|
+
const a1 = aEnd.getTime();
|
|
17
|
+
const b0 = bStart.getTime();
|
|
18
|
+
const b1 = bEnd.getTime();
|
|
19
|
+
if (a0 === a1) return b0 === b1 ? a0 === b0 : b0 <= a0 && a0 < b1;
|
|
20
|
+
if (b0 === b1) return a0 <= b0 && b0 < a1;
|
|
21
|
+
return a0 < b1 && b0 < a1;
|
|
14
22
|
}
|
|
15
23
|
|
|
16
24
|
/**
|
|
@@ -181,8 +189,8 @@ export function resolveDraggedBounds(
|
|
|
181
189
|
|
|
182
190
|
/**
|
|
183
191
|
* The all-day range swept out between two day cells of the month grid, ordered
|
|
184
|
-
* whichever way the sweep ran: `start` is
|
|
185
|
-
*
|
|
192
|
+
* whichever way the sweep ran: `start` is the first local day's start and `end` is
|
|
193
|
+
* the next day's start after the last, so a one-day sweep yields a usable event. Shared
|
|
186
194
|
* by both renderers so a month drag-to-create means the same thing on each.
|
|
187
195
|
*/
|
|
188
196
|
export function monthCreateRange(anchor: Date, hover: Date): { start: Date; end: Date } {
|
|
@@ -190,7 +198,7 @@ export function monthCreateRange(anchor: Date, hover: Date): { start: Date; end:
|
|
|
190
198
|
const b = startOfDay(hover);
|
|
191
199
|
const first = a.getTime() <= b.getTime() ? a : b;
|
|
192
200
|
const last = a.getTime() <= b.getTime() ? b : a;
|
|
193
|
-
return { start: first, end: addDays(last, 1) };
|
|
201
|
+
return { start: first, end: startOfDay(addDays(last, 1)) };
|
|
194
202
|
}
|
|
195
203
|
|
|
196
204
|
/**
|
package/src/utils/eventSource.ts
CHANGED
|
@@ -90,6 +90,8 @@ function recurrenceFromJSON(value: unknown, field: string): RecurrenceRule {
|
|
|
90
90
|
rule.weekdays = arrayFromJSON(input.weekdays, `${field}.weekdays`).map((day) =>
|
|
91
91
|
weekdayFromJSON(day, `${field}.weekdays`),
|
|
92
92
|
);
|
|
93
|
+
if (input.weekStartsOn !== undefined)
|
|
94
|
+
rule.weekStartsOn = weekdayFromJSON(input.weekStartsOn, `${field}.weekStartsOn`);
|
|
93
95
|
if (input.months !== undefined)
|
|
94
96
|
rule.months = arrayFromJSON(input.months, `${field}.months`).map((month) =>
|
|
95
97
|
integerFromJSON(month, `${field}.months`, 1, 12),
|
package/src/utils/ical.ts
CHANGED
|
@@ -188,6 +188,8 @@ function parseRRule(value: string): RecurrenceRule | undefined {
|
|
|
188
188
|
}
|
|
189
189
|
if (plain.length) rule.weekdays = plain;
|
|
190
190
|
}
|
|
191
|
+
const wkst = BYDAY.indexOf(parts.get("WKST")?.trim().toUpperCase() as (typeof BYDAY)[number]);
|
|
192
|
+
if (wkst >= 0) rule.weekStartsOn = wkst as WeekStartsOn;
|
|
191
193
|
const bymonthday = parts.get("BYMONTHDAY");
|
|
192
194
|
if (bymonthday) {
|
|
193
195
|
const days = bymonthday
|
|
@@ -217,6 +219,9 @@ function formatRRule(rule: RecurrenceRule): string {
|
|
|
217
219
|
} else if (rule.weekdays?.length) {
|
|
218
220
|
parts.push(`BYDAY=${rule.weekdays.map((d) => BYDAY[d]).join(",")}`);
|
|
219
221
|
}
|
|
222
|
+
if (rule.weekStartsOn != null && BYDAY[rule.weekStartsOn]) {
|
|
223
|
+
parts.push(`WKST=${BYDAY[rule.weekStartsOn]}`);
|
|
224
|
+
}
|
|
220
225
|
if (rule.monthDays?.length) parts.push(`BYMONTHDAY=${rule.monthDays.join(",")}`);
|
|
221
226
|
if (rule.months?.length) parts.push(`BYMONTH=${rule.months.join(",")}`);
|
|
222
227
|
return parts.join(";");
|