@super-calendar/core 2.7.0 → 2.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +67 -1
- package/dist/index.d.ts +67 -1
- package/dist/index.js +86 -0
- package/dist/index.mjs +84 -1
- package/package.json +1 -1
- package/src/types.ts +12 -0
- package/src/utils/drag.ts +24 -1
- package/src/utils/monthGrid.ts +111 -2
package/dist/index.d.mts
CHANGED
|
@@ -36,6 +36,18 @@ interface ICalendarEvent {
|
|
|
36
36
|
* instead so the event drags and snaps back.
|
|
37
37
|
*/
|
|
38
38
|
draggable?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Whether this event can be moved (dragged to a new time/day). Defaults to the
|
|
41
|
+
* grid's `eventStartEditable` (itself `true`). Set `false` to allow only resize.
|
|
42
|
+
* A `draggable: false` event ignores this (it can neither move nor resize).
|
|
43
|
+
*/
|
|
44
|
+
startEditable?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Whether this event can be resized (its start or end edge dragged). Defaults to
|
|
47
|
+
* the grid's `eventDurationEditable` (itself `true`). Set `false` to allow only
|
|
48
|
+
* move. A `draggable: false` event ignores this (it can neither move nor resize).
|
|
49
|
+
*/
|
|
50
|
+
durationEditable?: boolean;
|
|
39
51
|
/**
|
|
40
52
|
* How the event renders. `"auto"` (default) is a normal event box/chip;
|
|
41
53
|
* `"background"` paints the event's time range as a non-interactive shaded
|
|
@@ -364,6 +376,18 @@ declare const minutesIntoDay: (date: Date) => number;
|
|
|
364
376
|
declare const getYearMonths: (date: Date) => Date[];
|
|
365
377
|
//#endregion
|
|
366
378
|
//#region src/utils/drag.d.ts
|
|
379
|
+
/**
|
|
380
|
+
* True when two time ranges overlap. Edges touching (one ends exactly when the
|
|
381
|
+
* next begins) do not count as an overlap. Compares absolute instants, so events
|
|
382
|
+
* at the same wall-clock time on different days do not overlap.
|
|
383
|
+
*/
|
|
384
|
+
declare function eventsOverlap(aStart: Date, aEnd: Date, bStart: Date, bEnd: Date): boolean;
|
|
385
|
+
/**
|
|
386
|
+
* True when the range `[start, end)` would overlap any event in `events` other
|
|
387
|
+
* than `moved` (compared by reference). Used by the `eventOverlap` guard to reject
|
|
388
|
+
* a drag/resize that would land an event on top of another.
|
|
389
|
+
*/
|
|
390
|
+
declare function overlapsOtherEvents<T>(events: readonly CalendarEvent<T>[], moved: CalendarEvent<T>, start: Date, end: Date): boolean;
|
|
367
391
|
/**
|
|
368
392
|
* How many calendar days one time-grid page spans, used to advance the view by a
|
|
369
393
|
* whole page (e.g. when dragging an event past the edge into the next week).
|
|
@@ -720,6 +744,48 @@ declare function backgroundBandsForDay<T>(events: CalendarEvent<T>[], day: Date)
|
|
|
720
744
|
}[];
|
|
721
745
|
//#endregion
|
|
722
746
|
//#region src/utils/monthGrid.d.ts
|
|
747
|
+
/**
|
|
748
|
+
* One event's placement within a single week row of the month grid: the column
|
|
749
|
+
* span it covers and the lane (stacked row) it sits in, plus whether it continues
|
|
750
|
+
* past this row's edges (so the renderer can draw a "continues" affordance and
|
|
751
|
+
* square off the clipped end). Columns index into the row's `days` array, so with
|
|
752
|
+
* `hiddenDays` a bar spans the visible columns it touches.
|
|
753
|
+
*/
|
|
754
|
+
interface MonthEventSegment<T = unknown> {
|
|
755
|
+
event: CalendarEvent<T>;
|
|
756
|
+
/** First covered column in the row (0-based, inclusive). */
|
|
757
|
+
startCol: number;
|
|
758
|
+
/** Last covered column in the row (inclusive). */
|
|
759
|
+
endCol: number;
|
|
760
|
+
/** Stacking row within the day cells; 0 is the topmost. */
|
|
761
|
+
lane: number;
|
|
762
|
+
/** The event started before this row's first day. */
|
|
763
|
+
continuesBefore: boolean;
|
|
764
|
+
/** The event ends after this row's last day. */
|
|
765
|
+
continuesAfter: boolean;
|
|
766
|
+
}
|
|
767
|
+
/** The laid-out event segments for one week row, with the number of lanes used. */
|
|
768
|
+
interface MonthWeekEvents<T = unknown> {
|
|
769
|
+
segments: MonthEventSegment<T>[];
|
|
770
|
+
/** Highest lane index used + 1 (0 when the row has no events). */
|
|
771
|
+
laneCount: number;
|
|
772
|
+
}
|
|
773
|
+
/**
|
|
774
|
+
* Lay out one week row's events as continuous horizontal bars: each event becomes
|
|
775
|
+
* a single segment spanning the columns it covers (not a chip repeated per day),
|
|
776
|
+
* stacked into lanes so overlapping events sit on separate rows. Multi-day events
|
|
777
|
+
* that cross the row edges are marked `continuesBefore`/`continuesAfter`. Shared by
|
|
778
|
+
* both renderers so the month grid draws identical spanning bars.
|
|
779
|
+
*
|
|
780
|
+
* Column indices map into the given `days` array in whatever display order it uses,
|
|
781
|
+
* so this is order-independent: a right-to-left (reversed) week lays out correctly,
|
|
782
|
+
* and `continuesBefore`/`continuesAfter` track the array's first/last column edge
|
|
783
|
+
* (not chronology), so the clipped end is squared on the right visual side.
|
|
784
|
+
*
|
|
785
|
+
* Lanes are packed greedily after sorting by start column then longest span first,
|
|
786
|
+
* matching how calendars keep long events on the upper lanes.
|
|
787
|
+
*/
|
|
788
|
+
declare function layoutMonthWeek<T>(days: Date[], events: readonly CalendarEvent<T>[]): MonthWeekEvents<T>;
|
|
723
789
|
/** A single day in the grid, with all the state a custom cell needs to render. */
|
|
724
790
|
interface MonthGridDay {
|
|
725
791
|
/** The day this cell represents. */
|
|
@@ -850,4 +916,4 @@ declare function zonedTimeToUtc(wallClock: Date, timeZone: string): Date;
|
|
|
850
916
|
*/
|
|
851
917
|
declare function eventsInTimeZone<T>(events: CalendarEvent<T>[], timeZone: string): CalendarEvent<T>[];
|
|
852
918
|
//#endregion
|
|
853
|
-
export { BusinessHours, BusinessHoursBand, BusinessHoursValue, CalendarColors, CalendarEvent, CalendarMode, CalendarSelection, CalendarSelectionProvider, DateRange, DateSelectionConstraints, DayBadgeKind, DaySelectionState, EventAccessibilityLabelContext, EventAccessibilityLabeler, EventChipLayout, EventKeyExtractor, EventSourceOptions, EventSourceState, ICalEvent, ICalendarEvent, MIN_BOX_HEIGHT_FOR_TIME, MonthEventCapacity, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, PositionedEvent, RangeBandKind, RecurrenceFrequency, RecurrenceRule, TimeGridMode, ToICalendarOptions, UseDateRangeOptions, UseDateRangeResult, UseMonthGridOptions, UseNowOptions, WeekStartsOn, WeekdayFormat, backgroundBandsForDay, bandRounding, buildMonthGrid, buildMonthWeeks, cellRangeFromDrag, closedHourBands, compareDayEvents, darkColors, dayBadgeKind, daySelectionState, eventAccessibilityLabel, eventChipLayout, eventDayKeys, eventTimeLabel, eventsInTimeZone, expandRecurringEvents, filterHiddenDays, formatHour, getIsToday, getViewDays, getWeekDays, getYearMonths, groupEventsByDay, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isTimeVisibleAtHeight, isWeekend, isWithinDateRange, layoutDayEvents, lightColors, minutesIntoDay, monthEventCapacity, monthVisibleCount, nextDateRange, pageStepDays, parseICalendar, rangeBandKind, resolveDraggedBounds, shiftMinutes, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, useCalendarSelection, useDateRange, useEventSource, useMonthGrid, useNow, viewDayCount, weekDaysCount, weekdayFormatToken, zonedTimeToUtc };
|
|
919
|
+
export { BusinessHours, BusinessHoursBand, BusinessHoursValue, CalendarColors, CalendarEvent, CalendarMode, CalendarSelection, CalendarSelectionProvider, DateRange, DateSelectionConstraints, DayBadgeKind, DaySelectionState, EventAccessibilityLabelContext, EventAccessibilityLabeler, EventChipLayout, EventKeyExtractor, EventSourceOptions, EventSourceState, ICalEvent, ICalendarEvent, MIN_BOX_HEIGHT_FOR_TIME, MonthEventCapacity, MonthEventSegment, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, MonthWeekEvents, PositionedEvent, RangeBandKind, RecurrenceFrequency, RecurrenceRule, TimeGridMode, ToICalendarOptions, UseDateRangeOptions, UseDateRangeResult, UseMonthGridOptions, UseNowOptions, WeekStartsOn, WeekdayFormat, backgroundBandsForDay, bandRounding, buildMonthGrid, buildMonthWeeks, cellRangeFromDrag, closedHourBands, compareDayEvents, darkColors, dayBadgeKind, daySelectionState, 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, minutesIntoDay, monthEventCapacity, monthVisibleCount, nextDateRange, overlapsOtherEvents, pageStepDays, parseICalendar, rangeBandKind, resolveDraggedBounds, shiftMinutes, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, useCalendarSelection, useDateRange, useEventSource, useMonthGrid, useNow, viewDayCount, weekDaysCount, weekdayFormatToken, zonedTimeToUtc };
|
package/dist/index.d.ts
CHANGED
|
@@ -36,6 +36,18 @@ interface ICalendarEvent {
|
|
|
36
36
|
* instead so the event drags and snaps back.
|
|
37
37
|
*/
|
|
38
38
|
draggable?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Whether this event can be moved (dragged to a new time/day). Defaults to the
|
|
41
|
+
* grid's `eventStartEditable` (itself `true`). Set `false` to allow only resize.
|
|
42
|
+
* A `draggable: false` event ignores this (it can neither move nor resize).
|
|
43
|
+
*/
|
|
44
|
+
startEditable?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Whether this event can be resized (its start or end edge dragged). Defaults to
|
|
47
|
+
* the grid's `eventDurationEditable` (itself `true`). Set `false` to allow only
|
|
48
|
+
* move. A `draggable: false` event ignores this (it can neither move nor resize).
|
|
49
|
+
*/
|
|
50
|
+
durationEditable?: boolean;
|
|
39
51
|
/**
|
|
40
52
|
* How the event renders. `"auto"` (default) is a normal event box/chip;
|
|
41
53
|
* `"background"` paints the event's time range as a non-interactive shaded
|
|
@@ -364,6 +376,18 @@ declare const minutesIntoDay: (date: Date) => number;
|
|
|
364
376
|
declare const getYearMonths: (date: Date) => Date[];
|
|
365
377
|
//#endregion
|
|
366
378
|
//#region src/utils/drag.d.ts
|
|
379
|
+
/**
|
|
380
|
+
* True when two time ranges overlap. Edges touching (one ends exactly when the
|
|
381
|
+
* next begins) do not count as an overlap. Compares absolute instants, so events
|
|
382
|
+
* at the same wall-clock time on different days do not overlap.
|
|
383
|
+
*/
|
|
384
|
+
declare function eventsOverlap(aStart: Date, aEnd: Date, bStart: Date, bEnd: Date): boolean;
|
|
385
|
+
/**
|
|
386
|
+
* True when the range `[start, end)` would overlap any event in `events` other
|
|
387
|
+
* than `moved` (compared by reference). Used by the `eventOverlap` guard to reject
|
|
388
|
+
* a drag/resize that would land an event on top of another.
|
|
389
|
+
*/
|
|
390
|
+
declare function overlapsOtherEvents<T>(events: readonly CalendarEvent<T>[], moved: CalendarEvent<T>, start: Date, end: Date): boolean;
|
|
367
391
|
/**
|
|
368
392
|
* How many calendar days one time-grid page spans, used to advance the view by a
|
|
369
393
|
* whole page (e.g. when dragging an event past the edge into the next week).
|
|
@@ -720,6 +744,48 @@ declare function backgroundBandsForDay<T>(events: CalendarEvent<T>[], day: Date)
|
|
|
720
744
|
}[];
|
|
721
745
|
//#endregion
|
|
722
746
|
//#region src/utils/monthGrid.d.ts
|
|
747
|
+
/**
|
|
748
|
+
* One event's placement within a single week row of the month grid: the column
|
|
749
|
+
* span it covers and the lane (stacked row) it sits in, plus whether it continues
|
|
750
|
+
* past this row's edges (so the renderer can draw a "continues" affordance and
|
|
751
|
+
* square off the clipped end). Columns index into the row's `days` array, so with
|
|
752
|
+
* `hiddenDays` a bar spans the visible columns it touches.
|
|
753
|
+
*/
|
|
754
|
+
interface MonthEventSegment<T = unknown> {
|
|
755
|
+
event: CalendarEvent<T>;
|
|
756
|
+
/** First covered column in the row (0-based, inclusive). */
|
|
757
|
+
startCol: number;
|
|
758
|
+
/** Last covered column in the row (inclusive). */
|
|
759
|
+
endCol: number;
|
|
760
|
+
/** Stacking row within the day cells; 0 is the topmost. */
|
|
761
|
+
lane: number;
|
|
762
|
+
/** The event started before this row's first day. */
|
|
763
|
+
continuesBefore: boolean;
|
|
764
|
+
/** The event ends after this row's last day. */
|
|
765
|
+
continuesAfter: boolean;
|
|
766
|
+
}
|
|
767
|
+
/** The laid-out event segments for one week row, with the number of lanes used. */
|
|
768
|
+
interface MonthWeekEvents<T = unknown> {
|
|
769
|
+
segments: MonthEventSegment<T>[];
|
|
770
|
+
/** Highest lane index used + 1 (0 when the row has no events). */
|
|
771
|
+
laneCount: number;
|
|
772
|
+
}
|
|
773
|
+
/**
|
|
774
|
+
* Lay out one week row's events as continuous horizontal bars: each event becomes
|
|
775
|
+
* a single segment spanning the columns it covers (not a chip repeated per day),
|
|
776
|
+
* stacked into lanes so overlapping events sit on separate rows. Multi-day events
|
|
777
|
+
* that cross the row edges are marked `continuesBefore`/`continuesAfter`. Shared by
|
|
778
|
+
* both renderers so the month grid draws identical spanning bars.
|
|
779
|
+
*
|
|
780
|
+
* Column indices map into the given `days` array in whatever display order it uses,
|
|
781
|
+
* so this is order-independent: a right-to-left (reversed) week lays out correctly,
|
|
782
|
+
* and `continuesBefore`/`continuesAfter` track the array's first/last column edge
|
|
783
|
+
* (not chronology), so the clipped end is squared on the right visual side.
|
|
784
|
+
*
|
|
785
|
+
* Lanes are packed greedily after sorting by start column then longest span first,
|
|
786
|
+
* matching how calendars keep long events on the upper lanes.
|
|
787
|
+
*/
|
|
788
|
+
declare function layoutMonthWeek<T>(days: Date[], events: readonly CalendarEvent<T>[]): MonthWeekEvents<T>;
|
|
723
789
|
/** A single day in the grid, with all the state a custom cell needs to render. */
|
|
724
790
|
interface MonthGridDay {
|
|
725
791
|
/** The day this cell represents. */
|
|
@@ -850,4 +916,4 @@ declare function zonedTimeToUtc(wallClock: Date, timeZone: string): Date;
|
|
|
850
916
|
*/
|
|
851
917
|
declare function eventsInTimeZone<T>(events: CalendarEvent<T>[], timeZone: string): CalendarEvent<T>[];
|
|
852
918
|
//#endregion
|
|
853
|
-
export { BusinessHours, BusinessHoursBand, BusinessHoursValue, CalendarColors, CalendarEvent, CalendarMode, CalendarSelection, CalendarSelectionProvider, DateRange, DateSelectionConstraints, DayBadgeKind, DaySelectionState, EventAccessibilityLabelContext, EventAccessibilityLabeler, EventChipLayout, EventKeyExtractor, EventSourceOptions, EventSourceState, ICalEvent, ICalendarEvent, MIN_BOX_HEIGHT_FOR_TIME, MonthEventCapacity, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, PositionedEvent, RangeBandKind, RecurrenceFrequency, RecurrenceRule, TimeGridMode, ToICalendarOptions, UseDateRangeOptions, UseDateRangeResult, UseMonthGridOptions, UseNowOptions, WeekStartsOn, WeekdayFormat, backgroundBandsForDay, bandRounding, buildMonthGrid, buildMonthWeeks, cellRangeFromDrag, closedHourBands, compareDayEvents, darkColors, dayBadgeKind, daySelectionState, eventAccessibilityLabel, eventChipLayout, eventDayKeys, eventTimeLabel, eventsInTimeZone, expandRecurringEvents, filterHiddenDays, formatHour, getIsToday, getViewDays, getWeekDays, getYearMonths, groupEventsByDay, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isTimeVisibleAtHeight, isWeekend, isWithinDateRange, layoutDayEvents, lightColors, minutesIntoDay, monthEventCapacity, monthVisibleCount, nextDateRange, pageStepDays, parseICalendar, rangeBandKind, resolveDraggedBounds, shiftMinutes, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, useCalendarSelection, useDateRange, useEventSource, useMonthGrid, useNow, viewDayCount, weekDaysCount, weekdayFormatToken, zonedTimeToUtc };
|
|
919
|
+
export { BusinessHours, BusinessHoursBand, BusinessHoursValue, CalendarColors, CalendarEvent, CalendarMode, CalendarSelection, CalendarSelectionProvider, DateRange, DateSelectionConstraints, DayBadgeKind, DaySelectionState, EventAccessibilityLabelContext, EventAccessibilityLabeler, EventChipLayout, EventKeyExtractor, EventSourceOptions, EventSourceState, ICalEvent, ICalendarEvent, MIN_BOX_HEIGHT_FOR_TIME, MonthEventCapacity, MonthEventSegment, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, MonthWeekEvents, PositionedEvent, RangeBandKind, RecurrenceFrequency, RecurrenceRule, TimeGridMode, ToICalendarOptions, UseDateRangeOptions, UseDateRangeResult, UseMonthGridOptions, UseNowOptions, WeekStartsOn, WeekdayFormat, backgroundBandsForDay, bandRounding, buildMonthGrid, buildMonthWeeks, cellRangeFromDrag, closedHourBands, compareDayEvents, darkColors, dayBadgeKind, daySelectionState, 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, minutesIntoDay, monthEventCapacity, monthVisibleCount, nextDateRange, overlapsOtherEvents, pageStepDays, parseICalendar, rangeBandKind, resolveDraggedBounds, shiftMinutes, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, useCalendarSelection, useDateRange, useEventSource, useMonthGrid, useNow, viewDayCount, weekDaysCount, weekdayFormatToken, zonedTimeToUtc };
|
package/dist/index.js
CHANGED
|
@@ -278,6 +278,22 @@ function useDateRange(options = {}) {
|
|
|
278
278
|
//#endregion
|
|
279
279
|
//#region src/utils/drag.ts
|
|
280
280
|
/**
|
|
281
|
+
* True when two time ranges overlap. Edges touching (one ends exactly when the
|
|
282
|
+
* next begins) do not count as an overlap. Compares absolute instants, so events
|
|
283
|
+
* at the same wall-clock time on different days do not overlap.
|
|
284
|
+
*/
|
|
285
|
+
function eventsOverlap(aStart, aEnd, bStart, bEnd) {
|
|
286
|
+
return aStart.getTime() < bEnd.getTime() && bStart.getTime() < aEnd.getTime();
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* True when the range `[start, end)` would overlap any event in `events` other
|
|
290
|
+
* than `moved` (compared by reference). Used by the `eventOverlap` guard to reject
|
|
291
|
+
* a drag/resize that would land an event on top of another.
|
|
292
|
+
*/
|
|
293
|
+
function overlapsOtherEvents(events, moved, start, end) {
|
|
294
|
+
return events.some((e) => e !== moved && eventsOverlap(e.start, e.end, start, end));
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
281
297
|
* How many calendar days one time-grid page spans, used to advance the view by a
|
|
282
298
|
* whole page (e.g. when dragging an event past the edge into the next week).
|
|
283
299
|
* Deliberately ignores `hiddenDays` so a week always steps 7, matching the
|
|
@@ -1131,6 +1147,73 @@ function backgroundBandsForDay(events, day) {
|
|
|
1131
1147
|
}
|
|
1132
1148
|
//#endregion
|
|
1133
1149
|
//#region src/utils/monthGrid.ts
|
|
1150
|
+
/** The last calendar day an event visibly covers (a midnight end ends the day before). */
|
|
1151
|
+
function lastCoveredDay(event) {
|
|
1152
|
+
const endMs = event.end.getTime();
|
|
1153
|
+
return (0, date_fns.startOfDay)(new Date(Math.max(event.start.getTime(), endMs - 1))).getTime();
|
|
1154
|
+
}
|
|
1155
|
+
/**
|
|
1156
|
+
* Lay out one week row's events as continuous horizontal bars: each event becomes
|
|
1157
|
+
* a single segment spanning the columns it covers (not a chip repeated per day),
|
|
1158
|
+
* stacked into lanes so overlapping events sit on separate rows. Multi-day events
|
|
1159
|
+
* that cross the row edges are marked `continuesBefore`/`continuesAfter`. Shared by
|
|
1160
|
+
* both renderers so the month grid draws identical spanning bars.
|
|
1161
|
+
*
|
|
1162
|
+
* Column indices map into the given `days` array in whatever display order it uses,
|
|
1163
|
+
* so this is order-independent: a right-to-left (reversed) week lays out correctly,
|
|
1164
|
+
* and `continuesBefore`/`continuesAfter` track the array's first/last column edge
|
|
1165
|
+
* (not chronology), so the clipped end is squared on the right visual side.
|
|
1166
|
+
*
|
|
1167
|
+
* Lanes are packed greedily after sorting by start column then longest span first,
|
|
1168
|
+
* matching how calendars keep long events on the upper lanes.
|
|
1169
|
+
*/
|
|
1170
|
+
function layoutMonthWeek(days, events) {
|
|
1171
|
+
if (days.length === 0) return {
|
|
1172
|
+
segments: [],
|
|
1173
|
+
laneCount: 0
|
|
1174
|
+
};
|
|
1175
|
+
const dayStarts = days.map((d) => (0, date_fns.startOfDay)(d).getTime());
|
|
1176
|
+
const rowStart = Math.min(...dayStarts);
|
|
1177
|
+
const rowEnd = Math.max(...dayStarts);
|
|
1178
|
+
const ascending = dayStarts[0] <= dayStarts[dayStarts.length - 1];
|
|
1179
|
+
const placed = [];
|
|
1180
|
+
for (const event of events) {
|
|
1181
|
+
const evStart = (0, date_fns.startOfDay)(event.start).getTime();
|
|
1182
|
+
const evLast = lastCoveredDay(event);
|
|
1183
|
+
if (evLast < rowStart || evStart > rowEnd) continue;
|
|
1184
|
+
let startCol = -1;
|
|
1185
|
+
let endCol = -1;
|
|
1186
|
+
for (let i = 0; i < dayStarts.length; i++) if (dayStarts[i] >= evStart && dayStarts[i] <= evLast) {
|
|
1187
|
+
if (startCol === -1) startCol = i;
|
|
1188
|
+
endCol = i;
|
|
1189
|
+
}
|
|
1190
|
+
if (startCol === -1) continue;
|
|
1191
|
+
const startsBefore = evStart < rowStart;
|
|
1192
|
+
const endsAfter = evLast > rowEnd;
|
|
1193
|
+
placed.push({
|
|
1194
|
+
event,
|
|
1195
|
+
startCol,
|
|
1196
|
+
endCol,
|
|
1197
|
+
lane: 0,
|
|
1198
|
+
continuesBefore: ascending ? startsBefore : endsAfter,
|
|
1199
|
+
continuesAfter: ascending ? endsAfter : startsBefore
|
|
1200
|
+
});
|
|
1201
|
+
}
|
|
1202
|
+
placed.sort((a, b) => a.startCol - b.startCol || b.endCol - b.startCol - (a.endCol - a.startCol));
|
|
1203
|
+
const laneEnds = [];
|
|
1204
|
+
for (const seg of placed) {
|
|
1205
|
+
let lane = laneEnds.findIndex((end) => end < seg.startCol);
|
|
1206
|
+
if (lane === -1) {
|
|
1207
|
+
lane = laneEnds.length;
|
|
1208
|
+
laneEnds.push(seg.endCol);
|
|
1209
|
+
} else laneEnds[lane] = seg.endCol;
|
|
1210
|
+
seg.lane = lane;
|
|
1211
|
+
}
|
|
1212
|
+
return {
|
|
1213
|
+
segments: placed,
|
|
1214
|
+
laneCount: laneEnds.length
|
|
1215
|
+
};
|
|
1216
|
+
}
|
|
1134
1217
|
/** date-fns tokens for each {@link WeekdayFormat}. */
|
|
1135
1218
|
const WEEKDAY_TOKENS = {
|
|
1136
1219
|
narrow: "EEEEE",
|
|
@@ -1410,6 +1493,7 @@ exports.eventChipLayout = eventChipLayout;
|
|
|
1410
1493
|
exports.eventDayKeys = eventDayKeys;
|
|
1411
1494
|
exports.eventTimeLabel = eventTimeLabel;
|
|
1412
1495
|
exports.eventsInTimeZone = eventsInTimeZone;
|
|
1496
|
+
exports.eventsOverlap = eventsOverlap;
|
|
1413
1497
|
exports.expandRecurringEvents = expandRecurringEvents;
|
|
1414
1498
|
exports.filterHiddenDays = filterHiddenDays;
|
|
1415
1499
|
exports.formatHour = formatHour;
|
|
@@ -1427,11 +1511,13 @@ exports.isTimeVisibleAtHeight = isTimeVisibleAtHeight;
|
|
|
1427
1511
|
exports.isWeekend = isWeekend;
|
|
1428
1512
|
exports.isWithinDateRange = isWithinDateRange;
|
|
1429
1513
|
exports.layoutDayEvents = layoutDayEvents;
|
|
1514
|
+
exports.layoutMonthWeek = layoutMonthWeek;
|
|
1430
1515
|
exports.lightColors = lightColors;
|
|
1431
1516
|
exports.minutesIntoDay = minutesIntoDay;
|
|
1432
1517
|
exports.monthEventCapacity = monthEventCapacity;
|
|
1433
1518
|
exports.monthVisibleCount = monthVisibleCount;
|
|
1434
1519
|
exports.nextDateRange = nextDateRange;
|
|
1520
|
+
exports.overlapsOtherEvents = overlapsOtherEvents;
|
|
1435
1521
|
exports.pageStepDays = pageStepDays;
|
|
1436
1522
|
exports.parseICalendar = parseICalendar;
|
|
1437
1523
|
exports.rangeBandKind = rangeBandKind;
|
package/dist/index.mjs
CHANGED
|
@@ -277,6 +277,22 @@ function useDateRange(options = {}) {
|
|
|
277
277
|
//#endregion
|
|
278
278
|
//#region src/utils/drag.ts
|
|
279
279
|
/**
|
|
280
|
+
* True when two time ranges overlap. Edges touching (one ends exactly when the
|
|
281
|
+
* next begins) do not count as an overlap. Compares absolute instants, so events
|
|
282
|
+
* at the same wall-clock time on different days do not overlap.
|
|
283
|
+
*/
|
|
284
|
+
function eventsOverlap(aStart, aEnd, bStart, bEnd) {
|
|
285
|
+
return aStart.getTime() < bEnd.getTime() && bStart.getTime() < aEnd.getTime();
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* True when the range `[start, end)` would overlap any event in `events` other
|
|
289
|
+
* than `moved` (compared by reference). Used by the `eventOverlap` guard to reject
|
|
290
|
+
* a drag/resize that would land an event on top of another.
|
|
291
|
+
*/
|
|
292
|
+
function overlapsOtherEvents(events, moved, start, end) {
|
|
293
|
+
return events.some((e) => e !== moved && eventsOverlap(e.start, e.end, start, end));
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
280
296
|
* How many calendar days one time-grid page spans, used to advance the view by a
|
|
281
297
|
* whole page (e.g. when dragging an event past the edge into the next week).
|
|
282
298
|
* Deliberately ignores `hiddenDays` so a week always steps 7, matching the
|
|
@@ -1130,6 +1146,73 @@ function backgroundBandsForDay(events, day) {
|
|
|
1130
1146
|
}
|
|
1131
1147
|
//#endregion
|
|
1132
1148
|
//#region src/utils/monthGrid.ts
|
|
1149
|
+
/** The last calendar day an event visibly covers (a midnight end ends the day before). */
|
|
1150
|
+
function lastCoveredDay(event) {
|
|
1151
|
+
const endMs = event.end.getTime();
|
|
1152
|
+
return startOfDay(new Date(Math.max(event.start.getTime(), endMs - 1))).getTime();
|
|
1153
|
+
}
|
|
1154
|
+
/**
|
|
1155
|
+
* Lay out one week row's events as continuous horizontal bars: each event becomes
|
|
1156
|
+
* a single segment spanning the columns it covers (not a chip repeated per day),
|
|
1157
|
+
* stacked into lanes so overlapping events sit on separate rows. Multi-day events
|
|
1158
|
+
* that cross the row edges are marked `continuesBefore`/`continuesAfter`. Shared by
|
|
1159
|
+
* both renderers so the month grid draws identical spanning bars.
|
|
1160
|
+
*
|
|
1161
|
+
* Column indices map into the given `days` array in whatever display order it uses,
|
|
1162
|
+
* so this is order-independent: a right-to-left (reversed) week lays out correctly,
|
|
1163
|
+
* and `continuesBefore`/`continuesAfter` track the array's first/last column edge
|
|
1164
|
+
* (not chronology), so the clipped end is squared on the right visual side.
|
|
1165
|
+
*
|
|
1166
|
+
* Lanes are packed greedily after sorting by start column then longest span first,
|
|
1167
|
+
* matching how calendars keep long events on the upper lanes.
|
|
1168
|
+
*/
|
|
1169
|
+
function layoutMonthWeek(days, events) {
|
|
1170
|
+
if (days.length === 0) return {
|
|
1171
|
+
segments: [],
|
|
1172
|
+
laneCount: 0
|
|
1173
|
+
};
|
|
1174
|
+
const dayStarts = days.map((d) => startOfDay(d).getTime());
|
|
1175
|
+
const rowStart = Math.min(...dayStarts);
|
|
1176
|
+
const rowEnd = Math.max(...dayStarts);
|
|
1177
|
+
const ascending = dayStarts[0] <= dayStarts[dayStarts.length - 1];
|
|
1178
|
+
const placed = [];
|
|
1179
|
+
for (const event of events) {
|
|
1180
|
+
const evStart = startOfDay(event.start).getTime();
|
|
1181
|
+
const evLast = lastCoveredDay(event);
|
|
1182
|
+
if (evLast < rowStart || evStart > rowEnd) continue;
|
|
1183
|
+
let startCol = -1;
|
|
1184
|
+
let endCol = -1;
|
|
1185
|
+
for (let i = 0; i < dayStarts.length; i++) if (dayStarts[i] >= evStart && dayStarts[i] <= evLast) {
|
|
1186
|
+
if (startCol === -1) startCol = i;
|
|
1187
|
+
endCol = i;
|
|
1188
|
+
}
|
|
1189
|
+
if (startCol === -1) continue;
|
|
1190
|
+
const startsBefore = evStart < rowStart;
|
|
1191
|
+
const endsAfter = evLast > rowEnd;
|
|
1192
|
+
placed.push({
|
|
1193
|
+
event,
|
|
1194
|
+
startCol,
|
|
1195
|
+
endCol,
|
|
1196
|
+
lane: 0,
|
|
1197
|
+
continuesBefore: ascending ? startsBefore : endsAfter,
|
|
1198
|
+
continuesAfter: ascending ? endsAfter : startsBefore
|
|
1199
|
+
});
|
|
1200
|
+
}
|
|
1201
|
+
placed.sort((a, b) => a.startCol - b.startCol || b.endCol - b.startCol - (a.endCol - a.startCol));
|
|
1202
|
+
const laneEnds = [];
|
|
1203
|
+
for (const seg of placed) {
|
|
1204
|
+
let lane = laneEnds.findIndex((end) => end < seg.startCol);
|
|
1205
|
+
if (lane === -1) {
|
|
1206
|
+
lane = laneEnds.length;
|
|
1207
|
+
laneEnds.push(seg.endCol);
|
|
1208
|
+
} else laneEnds[lane] = seg.endCol;
|
|
1209
|
+
seg.lane = lane;
|
|
1210
|
+
}
|
|
1211
|
+
return {
|
|
1212
|
+
segments: placed,
|
|
1213
|
+
laneCount: laneEnds.length
|
|
1214
|
+
};
|
|
1215
|
+
}
|
|
1133
1216
|
/** date-fns tokens for each {@link WeekdayFormat}. */
|
|
1134
1217
|
const WEEKDAY_TOKENS = {
|
|
1135
1218
|
narrow: "EEEEE",
|
|
@@ -1392,4 +1475,4 @@ function expandRecurringEvents(events, rangeStart, rangeEnd) {
|
|
|
1392
1475
|
return out;
|
|
1393
1476
|
}
|
|
1394
1477
|
//#endregion
|
|
1395
|
-
export { CalendarSelectionProvider, MIN_BOX_HEIGHT_FOR_TIME, backgroundBandsForDay, bandRounding, buildMonthGrid, buildMonthWeeks, cellRangeFromDrag, closedHourBands, compareDayEvents, darkColors, dayBadgeKind, daySelectionState, eventAccessibilityLabel, eventChipLayout, eventDayKeys, eventTimeLabel, eventsInTimeZone, expandRecurringEvents, filterHiddenDays, formatHour, getIsToday, getViewDays, getWeekDays, getYearMonths, groupEventsByDay, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isTimeVisibleAtHeight, isWeekend, isWithinDateRange, layoutDayEvents, lightColors, minutesIntoDay, monthEventCapacity, monthVisibleCount, nextDateRange, pageStepDays, parseICalendar, rangeBandKind, resolveDraggedBounds, shiftMinutes, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, useCalendarSelection, useDateRange, useEventSource, useMonthGrid, useNow, viewDayCount, weekDaysCount, weekdayFormatToken, zonedTimeToUtc };
|
|
1478
|
+
export { CalendarSelectionProvider, MIN_BOX_HEIGHT_FOR_TIME, backgroundBandsForDay, bandRounding, buildMonthGrid, buildMonthWeeks, cellRangeFromDrag, closedHourBands, compareDayEvents, darkColors, dayBadgeKind, daySelectionState, 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, minutesIntoDay, monthEventCapacity, monthVisibleCount, nextDateRange, overlapsOtherEvents, pageStepDays, parseICalendar, rangeBandKind, resolveDraggedBounds, shiftMinutes, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, useCalendarSelection, useDateRange, useEventSource, useMonthGrid, useNow, viewDayCount, weekDaysCount, weekdayFormatToken, zonedTimeToUtc };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@super-calendar/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.1",
|
|
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
|
@@ -35,6 +35,18 @@ export interface ICalendarEvent {
|
|
|
35
35
|
* instead so the event drags and snaps back.
|
|
36
36
|
*/
|
|
37
37
|
draggable?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Whether this event can be moved (dragged to a new time/day). Defaults to the
|
|
40
|
+
* grid's `eventStartEditable` (itself `true`). Set `false` to allow only resize.
|
|
41
|
+
* A `draggable: false` event ignores this (it can neither move nor resize).
|
|
42
|
+
*/
|
|
43
|
+
startEditable?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Whether this event can be resized (its start or end edge dragged). Defaults to
|
|
46
|
+
* the grid's `eventDurationEditable` (itself `true`). Set `false` to allow only
|
|
47
|
+
* move. A `draggable: false` event ignores this (it can neither move nor resize).
|
|
48
|
+
*/
|
|
49
|
+
durationEditable?: boolean;
|
|
38
50
|
/**
|
|
39
51
|
* How the event renders. `"auto"` (default) is a normal event box/chip;
|
|
40
52
|
* `"background"` paints the event's time range as a non-interactive shaded
|
package/src/utils/drag.ts
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
|
-
import type { CalendarMode, WeekStartsOn } from "../types";
|
|
1
|
+
import type { CalendarEvent, CalendarMode, WeekStartsOn } from "../types";
|
|
2
2
|
import { getViewDays } from "./dates";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* True when two time ranges overlap. Edges touching (one ends exactly when the
|
|
6
|
+
* next begins) do not count as an overlap. Compares absolute instants, so events
|
|
7
|
+
* at the same wall-clock time on different days do not overlap.
|
|
8
|
+
*/
|
|
9
|
+
export function eventsOverlap(aStart: Date, aEnd: Date, bStart: Date, bEnd: Date): boolean {
|
|
10
|
+
return aStart.getTime() < bEnd.getTime() && bStart.getTime() < aEnd.getTime();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* True when the range `[start, end)` would overlap any event in `events` other
|
|
15
|
+
* than `moved` (compared by reference). Used by the `eventOverlap` guard to reject
|
|
16
|
+
* a drag/resize that would land an event on top of another.
|
|
17
|
+
*/
|
|
18
|
+
export function overlapsOtherEvents<T>(
|
|
19
|
+
events: readonly CalendarEvent<T>[],
|
|
20
|
+
moved: CalendarEvent<T>,
|
|
21
|
+
start: Date,
|
|
22
|
+
end: Date,
|
|
23
|
+
): boolean {
|
|
24
|
+
return events.some((e) => e !== moved && eventsOverlap(e.start, e.end, start, end));
|
|
25
|
+
}
|
|
26
|
+
|
|
4
27
|
/**
|
|
5
28
|
* How many calendar days one time-grid page spans, used to advance the view by a
|
|
6
29
|
* whole page (e.g. when dragging an event past the edge into the next week).
|
package/src/utils/monthGrid.ts
CHANGED
|
@@ -1,9 +1,118 @@
|
|
|
1
|
-
import { format, type Locale, isSameMonth } from "date-fns";
|
|
1
|
+
import { format, type Locale, isSameMonth, startOfDay } from "date-fns";
|
|
2
2
|
import { useMemo } from "react";
|
|
3
|
-
import type { WeekStartsOn } from "../types";
|
|
3
|
+
import type { CalendarEvent, WeekStartsOn } from "../types";
|
|
4
4
|
import { type DateRange, type DateSelectionConstraints, daySelectionState } from "./dateRange";
|
|
5
5
|
import { buildMonthWeeks, getIsToday, isWeekend } from "./dates";
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* One event's placement within a single week row of the month grid: the column
|
|
9
|
+
* span it covers and the lane (stacked row) it sits in, plus whether it continues
|
|
10
|
+
* past this row's edges (so the renderer can draw a "continues" affordance and
|
|
11
|
+
* square off the clipped end). Columns index into the row's `days` array, so with
|
|
12
|
+
* `hiddenDays` a bar spans the visible columns it touches.
|
|
13
|
+
*/
|
|
14
|
+
export interface MonthEventSegment<T = unknown> {
|
|
15
|
+
event: CalendarEvent<T>;
|
|
16
|
+
/** First covered column in the row (0-based, inclusive). */
|
|
17
|
+
startCol: number;
|
|
18
|
+
/** Last covered column in the row (inclusive). */
|
|
19
|
+
endCol: number;
|
|
20
|
+
/** Stacking row within the day cells; 0 is the topmost. */
|
|
21
|
+
lane: number;
|
|
22
|
+
/** The event started before this row's first day. */
|
|
23
|
+
continuesBefore: boolean;
|
|
24
|
+
/** The event ends after this row's last day. */
|
|
25
|
+
continuesAfter: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** The laid-out event segments for one week row, with the number of lanes used. */
|
|
29
|
+
export interface MonthWeekEvents<T = unknown> {
|
|
30
|
+
segments: MonthEventSegment<T>[];
|
|
31
|
+
/** Highest lane index used + 1 (0 when the row has no events). */
|
|
32
|
+
laneCount: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The last calendar day an event visibly covers (a midnight end ends the day before). */
|
|
36
|
+
function lastCoveredDay(event: CalendarEvent<unknown>): number {
|
|
37
|
+
const endMs = event.end.getTime();
|
|
38
|
+
// Clamp to the start so a zero/negative-length event still covers its start day.
|
|
39
|
+
return startOfDay(new Date(Math.max(event.start.getTime(), endMs - 1))).getTime();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Lay out one week row's events as continuous horizontal bars: each event becomes
|
|
44
|
+
* a single segment spanning the columns it covers (not a chip repeated per day),
|
|
45
|
+
* stacked into lanes so overlapping events sit on separate rows. Multi-day events
|
|
46
|
+
* that cross the row edges are marked `continuesBefore`/`continuesAfter`. Shared by
|
|
47
|
+
* both renderers so the month grid draws identical spanning bars.
|
|
48
|
+
*
|
|
49
|
+
* Column indices map into the given `days` array in whatever display order it uses,
|
|
50
|
+
* so this is order-independent: a right-to-left (reversed) week lays out correctly,
|
|
51
|
+
* and `continuesBefore`/`continuesAfter` track the array's first/last column edge
|
|
52
|
+
* (not chronology), so the clipped end is squared on the right visual side.
|
|
53
|
+
*
|
|
54
|
+
* Lanes are packed greedily after sorting by start column then longest span first,
|
|
55
|
+
* matching how calendars keep long events on the upper lanes.
|
|
56
|
+
*/
|
|
57
|
+
export function layoutMonthWeek<T>(
|
|
58
|
+
days: Date[],
|
|
59
|
+
events: readonly CalendarEvent<T>[],
|
|
60
|
+
): MonthWeekEvents<T> {
|
|
61
|
+
if (days.length === 0) return { segments: [], laneCount: 0 };
|
|
62
|
+
const dayStarts = days.map((d) => startOfDay(d).getTime());
|
|
63
|
+
// Chronological bounds, independent of the array's direction (RTL reverses it).
|
|
64
|
+
const rowStart = Math.min(...dayStarts);
|
|
65
|
+
const rowEnd = Math.max(...dayStarts);
|
|
66
|
+
const ascending = dayStarts[0] <= dayStarts[dayStarts.length - 1];
|
|
67
|
+
|
|
68
|
+
const placed: MonthEventSegment<T>[] = [];
|
|
69
|
+
for (const event of events) {
|
|
70
|
+
const evStart = startOfDay(event.start).getTime();
|
|
71
|
+
const evLast = lastCoveredDay(event);
|
|
72
|
+
// Skip events entirely outside this row.
|
|
73
|
+
if (evLast < rowStart || evStart > rowEnd) continue;
|
|
74
|
+
// Columns this event covers, found by membership so it works in any day order.
|
|
75
|
+
let startCol = -1;
|
|
76
|
+
let endCol = -1;
|
|
77
|
+
for (let i = 0; i < dayStarts.length; i++) {
|
|
78
|
+
if (dayStarts[i] >= evStart && dayStarts[i] <= evLast) {
|
|
79
|
+
if (startCol === -1) startCol = i;
|
|
80
|
+
endCol = i;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// No column in this row covers the event (e.g. it only falls on a hidden
|
|
84
|
+
// interior day), so it draws no bar here.
|
|
85
|
+
if (startCol === -1) continue;
|
|
86
|
+
const startsBefore = evStart < rowStart;
|
|
87
|
+
const endsAfter = evLast > rowEnd;
|
|
88
|
+
placed.push({
|
|
89
|
+
event,
|
|
90
|
+
startCol,
|
|
91
|
+
endCol,
|
|
92
|
+
lane: 0,
|
|
93
|
+
// Map the chronological overflow to the array's first/last column edge.
|
|
94
|
+
continuesBefore: ascending ? startsBefore : endsAfter,
|
|
95
|
+
continuesAfter: ascending ? endsAfter : startsBefore,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Longest, earliest segments claim the upper lanes first.
|
|
100
|
+
placed.sort((a, b) => a.startCol - b.startCol || b.endCol - b.startCol - (a.endCol - a.startCol));
|
|
101
|
+
const laneEnds: number[] = [];
|
|
102
|
+
for (const seg of placed) {
|
|
103
|
+
let lane = laneEnds.findIndex((end) => end < seg.startCol);
|
|
104
|
+
if (lane === -1) {
|
|
105
|
+
lane = laneEnds.length;
|
|
106
|
+
laneEnds.push(seg.endCol);
|
|
107
|
+
} else {
|
|
108
|
+
laneEnds[lane] = seg.endCol;
|
|
109
|
+
}
|
|
110
|
+
seg.lane = lane;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return { segments: placed, laneCount: laneEnds.length };
|
|
114
|
+
}
|
|
115
|
+
|
|
7
116
|
/** A single day in the grid, with all the state a custom cell needs to render. */
|
|
8
117
|
export interface MonthGridDay {
|
|
9
118
|
/** The day this cell represents. */
|