@super-calendar/dom 2.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Afonso Jorge Ramos
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,463 @@
1
+ import { Locale } from "date-fns";
2
+ import { CSSProperties, ComponentType, ReactNode } from "react";
3
+ import { BusinessHours, BusinessHours as BusinessHours$1, CalendarColors, CalendarEvent, CalendarEvent as CalendarEvent$1, CalendarMode, CalendarMode as CalendarMode$1, DateRange, DateRange as DateRange$1, DateSelectionConstraints, DateSelectionConstraints as DateSelectionConstraints$1, DaySelectionState, ICalendarEvent, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, PositionedEvent, TimeGridMode, TimeGridMode as TimeGridMode$1, UseDateRangeOptions, UseMonthGridOptions, WeekStartsOn, WeekStartsOn as WeekStartsOn$1, buildMonthGrid, daySelectionState, getViewDays, isAllDayEvent, isDateSelectable, isRangeEndpoint, isWithinDateRange, layoutDayEvents, nextDateRange, useDateRange, useMonthGrid } from "@super-calendar/core";
4
+
5
+ //#region src/theme.d.ts
6
+ type DomCalendarTheme = CalendarColors & {
7
+ /** Row height of a day cell, in px. */cellHeight: number; /** Diameter of the day badge, in px. */
8
+ dayBadgeSize: number;
9
+ /**
10
+ * Height of the selection band strip, in px (the default pill look). The pill's
11
+ * corner radius is half this. Ignored when `fillCellOnSelection` is set, where
12
+ * the band fills the whole cell instead.
13
+ */
14
+ rangeBandHeight: number; /** Font stack for the calendar. */
15
+ fontFamily: string;
16
+ };
17
+ declare const defaultDomTheme: DomCalendarTheme;
18
+ declare const darkDomTheme: DomCalendarTheme;
19
+ /** Merge a partial override onto a base theme (defaults to {@link defaultDomTheme}). */
20
+ declare function mergeDomTheme(overrides?: Partial<DomCalendarTheme>, base?: DomCalendarTheme): DomCalendarTheme;
21
+ //#endregion
22
+ //#region src/Agenda.d.ts
23
+ /** Props passed to a custom agenda (schedule) event renderer. */
24
+ interface DomAgendaEventArgs<T = unknown> {
25
+ event: CalendarEvent$1<T>;
26
+ /** Always "schedule"; lets a renderer shared with other views branch on it. */
27
+ mode: "schedule";
28
+ isAllDay: boolean;
29
+ /** Render the time range in 12-hour AM/PM. */
30
+ ampm?: boolean;
31
+ onPress: () => void;
32
+ }
33
+ type DomAgendaEvent<T = unknown> = ComponentType<DomAgendaEventArgs<T>>;
34
+ interface AgendaProps<T = unknown> {
35
+ /** Events to list. The consumer controls which (and therefore the date range). */
36
+ events: CalendarEvent$1<T>[];
37
+ locale?: Locale;
38
+ /** Render times in 12-hour AM/PM (default false, 24h). */
39
+ ampm?: boolean;
40
+ /** Highlight this date's header instead of the real "today". */
41
+ activeDate?: Date;
42
+ theme?: Partial<DomCalendarTheme>;
43
+ /** Height of the scroll viewport, in px (default 480). */
44
+ height?: number | string;
45
+ /** Replace the built-in event row. */
46
+ renderEvent?: DomAgendaEvent<T>;
47
+ onPressEvent?: (event: CalendarEvent$1<T>) => void;
48
+ /** Tap a day's header. */
49
+ onPressDay?: (date: Date) => void;
50
+ className?: string;
51
+ style?: CSSProperties;
52
+ }
53
+ /**
54
+ * A vertical, day-grouped list of events: the schedule view, with plain DOM
55
+ * elements. Events are sorted by start and grouped under a date header per day;
56
+ * the consumer controls which events (and therefore which dates) are shown. The
57
+ * react-dom counterpart of the React Native `Agenda`.
58
+ */
59
+ declare function Agenda<T = unknown>({
60
+ events,
61
+ locale,
62
+ ampm,
63
+ activeDate,
64
+ theme: themeOverrides,
65
+ height,
66
+ renderEvent,
67
+ onPressEvent,
68
+ onPressDay,
69
+ className,
70
+ style
71
+ }: AgendaProps<T>): import("react").JSX.Element;
72
+ //#endregion
73
+ //#region src/MonthView.d.ts
74
+ /** Props passed to a custom month event chip renderer. */
75
+ interface DomMonthEventArgs<T = unknown> {
76
+ event: CalendarEvent$1<T>;
77
+ onPress: () => void;
78
+ }
79
+ type DomMonthEvent<T = unknown> = ComponentType<DomMonthEventArgs<T>>;
80
+ interface MonthViewProps<T = unknown> extends DateSelectionConstraints$1 {
81
+ /** Any day within the month to render. */
82
+ date: Date;
83
+ /** First day of the week. Sunday = 0 (default) … Saturday = 6. */
84
+ weekStartsOn?: WeekStartsOn$1;
85
+ /**
86
+ * Events to render as chips in each day cell. Passing this (even `[]`) switches
87
+ * the grid to the calendar layout (date in the corner, chips below); omit it for
88
+ * the compact date-picker look.
89
+ */
90
+ events?: CalendarEvent$1<T>[];
91
+ /** Custom chip renderer; falls back to the built-in titled chip. */
92
+ renderEvent?: DomMonthEvent<T>;
93
+ /** Max chips shown per day before a "+N more" row (default 3). */
94
+ maxVisibleEventCount?: number;
95
+ /** Template for the overflow row; `{moreCount}` is replaced (default "{moreCount} More"). */
96
+ moreLabel?: string;
97
+ /** Tap an event chip. */
98
+ onPressEvent?: (event: CalendarEvent$1<T>) => void;
99
+ /** Tap the "+N more" overflow row. */
100
+ onPressMore?: (events: CalendarEvent$1<T>[], date: Date) => void;
101
+ /** Selected span; days between the endpoints get the range band. */
102
+ selectedRange?: DateRange$1;
103
+ /** Discrete selected days (single / multiple). */
104
+ selectedDates?: Date[];
105
+ /** Render days from the neighbouring months in the leading/trailing cells (default true). */
106
+ showAdjacentMonths?: boolean;
107
+ /**
108
+ * Fill the whole cell with the range background instead of the default
109
+ * centered rounded "pill" strip. Default false.
110
+ */
111
+ fillCellOnSelection?: boolean;
112
+ /** Render the "Month yyyy" title above the grid (default true). */
113
+ showTitle?: boolean;
114
+ /** Render the weekday header row (default true). */
115
+ showWeekdays?: boolean;
116
+ /** date-fns locale for the title and weekday labels. */
117
+ locale?: Locale;
118
+ /** Theme overrides; falls back to the default light theme. */
119
+ theme?: Partial<DomCalendarTheme>;
120
+ /** Fired when a selectable day is clicked. */
121
+ onPressDay?: (date: Date) => void;
122
+ /**
123
+ * When events are shown, also make the day cells keyboard-navigable: a single
124
+ * roving tab stop, arrow keys move the focus, Enter opens the day (`onPressDay`).
125
+ * Default false, so keyboard focus moves through events only. The date picker
126
+ * (rendered without `events`) is always navigable regardless of this flag.
127
+ */
128
+ keyboardDayNavigation?: boolean;
129
+ className?: string;
130
+ style?: CSSProperties;
131
+ }
132
+ interface MonthViewInternalProps<T = unknown> extends MonthViewProps<T> {
133
+ eventsByDay?: ReadonlyMap<string, CalendarEvent$1<T>[]>;
134
+ }
135
+ /** A single static month grid, rendered with plain DOM elements. */
136
+ declare function MonthView<T = unknown>({
137
+ date,
138
+ weekStartsOn,
139
+ events,
140
+ eventsByDay: eventsByDayProp,
141
+ renderEvent,
142
+ maxVisibleEventCount,
143
+ moreLabel,
144
+ onPressEvent,
145
+ onPressMore,
146
+ selectedRange,
147
+ selectedDates,
148
+ showAdjacentMonths,
149
+ fillCellOnSelection,
150
+ showTitle,
151
+ showWeekdays,
152
+ locale,
153
+ theme: themeOverrides,
154
+ minDate,
155
+ maxDate,
156
+ isDateDisabled,
157
+ onPressDay,
158
+ keyboardDayNavigation,
159
+ className,
160
+ style
161
+ }: MonthViewInternalProps<T>): import("react").JSX.Element;
162
+ //#endregion
163
+ //#region src/TimeGrid.d.ts
164
+ /** Props passed to a custom time-grid event renderer. */
165
+ interface DomRenderEventArgs<T = unknown> {
166
+ event: CalendarEvent$1<T>;
167
+ mode: CalendarMode$1;
168
+ isAllDay: boolean;
169
+ boxHeight?: number;
170
+ continuesBefore?: boolean;
171
+ continuesAfter?: boolean;
172
+ /** Show the time range in 12-hour AM/PM. */
173
+ ampm?: boolean;
174
+ onPress: () => void;
175
+ }
176
+ type DomRenderEvent<T = unknown> = ComponentType<DomRenderEventArgs<T>>;
177
+ interface TimeGridProps<T = unknown> {
178
+ date: Date;
179
+ events?: CalendarEvent$1<T>[];
180
+ /** "day" (default), "3days", "week", or "custom" (with `numberOfDays`). */
181
+ mode?: TimeGridMode$1;
182
+ numberOfDays?: number;
183
+ weekStartsOn?: WeekStartsOn$1;
184
+ /** Initial pixels per hour (default 48). */
185
+ hourHeight?: number;
186
+ /** Initial scroll position, in minutes from midnight (default 8:00). */
187
+ scrollOffsetMinutes?: number;
188
+ /** Pinch / Ctrl-⌘-scroll to zoom the grid (default true). */
189
+ zoomable?: boolean;
190
+ minHourHeight?: number;
191
+ maxHourHeight?: number;
192
+ /** Snap dragged events to this many minutes (default 15). */
193
+ dragStepMinutes?: number;
194
+ /** Render event time ranges in 12-hour AM/PM (default false, 24h). */
195
+ ampm?: boolean;
196
+ /** Sub-divisions per hour for the grid lines, e.g. 2 for half-hour (default 1). */
197
+ timeslots?: number;
198
+ /** Shade the hours outside business hours; `null` shades the whole day. */
199
+ businessHours?: BusinessHours$1;
200
+ /** Show the current-time indicator on today's column (default true). */
201
+ showNowIndicator?: boolean;
202
+ /** Show the all-day lane above the grid (default true). */
203
+ showAllDayEventCell?: boolean;
204
+ locale?: Locale;
205
+ theme?: Partial<DomCalendarTheme>;
206
+ height?: number | string;
207
+ renderEvent?: DomRenderEvent<T>;
208
+ /** Replace the hour-axis label. Receives the hour (0–23) and the `ampm` flag. */
209
+ hourComponent?: (hour: number, ampm: boolean) => ReactNode;
210
+ onPressEvent?: (event: CalendarEvent$1<T>) => void;
211
+ onPressDateHeader?: (day: Date) => void;
212
+ /** Tap empty grid space; called with the date and time at the press. */
213
+ onPressCell?: (date: Date) => void;
214
+ /** Drag empty grid space to create; called with the swept start/end. */
215
+ onCreateEvent?: (start: Date, end: Date) => void;
216
+ /** Fires when an event drag begins (e.g. to trigger haptics). */
217
+ onDragStart?: (event: CalendarEvent$1<T>) => void;
218
+ /**
219
+ * Enables drag-to-move and resize; called with the proposed new start/end.
220
+ * Return `false` to reject the drop (the event snaps back).
221
+ */
222
+ onDragEvent?: (event: CalendarEvent$1<T>, start: Date, end: Date) => void | boolean;
223
+ className?: string;
224
+ style?: CSSProperties;
225
+ }
226
+ /**
227
+ * A day / week / N-day time grid rendered with plain DOM elements. Events are
228
+ * positioned with the library's pure `layoutDayEvents`, so overlap columns and
229
+ * multi-day clipping match the React Native renderer. Supports Ctrl/⌘-scroll and
230
+ * two-finger pinch to zoom, and pointer drag to move / resize events.
231
+ */
232
+ declare function TimeGrid<T = unknown>({
233
+ date,
234
+ events,
235
+ mode,
236
+ numberOfDays,
237
+ weekStartsOn,
238
+ hourHeight: initialHourHeight,
239
+ scrollOffsetMinutes,
240
+ zoomable,
241
+ minHourHeight,
242
+ maxHourHeight,
243
+ dragStepMinutes,
244
+ ampm,
245
+ timeslots,
246
+ businessHours,
247
+ showNowIndicator,
248
+ showAllDayEventCell,
249
+ locale,
250
+ theme: themeOverrides,
251
+ height,
252
+ renderEvent,
253
+ hourComponent,
254
+ onPressEvent,
255
+ onPressDateHeader,
256
+ onPressCell,
257
+ onCreateEvent,
258
+ onDragStart,
259
+ onDragEvent,
260
+ className,
261
+ style
262
+ }: TimeGridProps<T>): import("react").JSX.Element;
263
+ //#endregion
264
+ //#region src/Calendar.d.ts
265
+ interface CalendarProps<T = unknown> extends DateSelectionConstraints$1 {
266
+ /**
267
+ * The view to render (default "week"). `month` renders a month grid, `schedule`
268
+ * a day-grouped agenda list, and the others a time grid.
269
+ */
270
+ mode?: "month" | "schedule" | TimeGridMode$1;
271
+ /** Controlled anchor date. Change it (e.g. from your own header) to navigate. */
272
+ date: Date;
273
+ /** Your events. */
274
+ events?: CalendarEvent$1<T>[];
275
+ /** First day of the week. Sunday = 0 (default) … Saturday = 6. */
276
+ weekStartsOn?: WeekStartsOn$1;
277
+ /** Column count for `mode="custom"`. */
278
+ numberOfDays?: number;
279
+ locale?: Locale;
280
+ theme?: Partial<DomCalendarTheme>;
281
+ /** Height of the scroll viewport, in px. */
282
+ height?: number | string;
283
+ className?: string;
284
+ style?: CSSProperties;
285
+ /** Tap an event (both layouts). */
286
+ onPressEvent?: (event: CalendarEvent$1<T>) => void;
287
+ /** 12-hour AM/PM time labels (default false). */
288
+ ampm?: boolean;
289
+ /** Initial pixels per hour. */
290
+ hourHeight?: number;
291
+ /** Initial scroll position, in minutes from midnight. */
292
+ scrollOffsetMinutes?: number;
293
+ /** Sub-divisions per hour for the grid lines. */
294
+ timeslots?: number;
295
+ /** Shade the hours outside business hours. */
296
+ businessHours?: BusinessHours$1;
297
+ /** Show the current-time indicator (default true). */
298
+ showNowIndicator?: boolean;
299
+ /** Show the all-day lane (default true). */
300
+ showAllDayEventCell?: boolean;
301
+ /** Snap dragged/created events to this many minutes. */
302
+ dragStepMinutes?: number;
303
+ /** Tap empty grid space. */
304
+ onPressCell?: (date: Date) => void;
305
+ /** Drag empty grid space to create. */
306
+ onCreateEvent?: (start: Date, end: Date) => void;
307
+ /** Fires when an event drag begins. */
308
+ onDragStart?: (event: CalendarEvent$1<T>) => void;
309
+ /** Enables drag-to-move/resize; return `false` to reject the drop. */
310
+ onDragEvent?: (event: CalendarEvent$1<T>, start: Date, end: Date) => void | boolean;
311
+ /** Tap a day's column header. */
312
+ onPressDateHeader?: (day: Date) => void;
313
+ /** Custom time-grid event renderer. */
314
+ renderTimeEvent?: DomRenderEvent<T>;
315
+ /** Replace the hour-axis label. Receives the hour (0–23) and the `ampm` flag. */
316
+ hourComponent?: (hour: number, ampm: boolean) => ReactNode;
317
+ /** Max chips per day before a "+N more" row. */
318
+ maxVisibleEventCount?: number;
319
+ /** Overflow row template; `{moreCount}` is replaced. */
320
+ moreLabel?: string;
321
+ /** Render neighbouring months' days in the leading/trailing cells (default true). */
322
+ showAdjacentMonths?: boolean;
323
+ /** Fill the cell with the range background instead of the pill band. */
324
+ fillCellOnSelection?: boolean;
325
+ /** Selected span. */
326
+ selectedRange?: DateRange$1;
327
+ /** Discrete selected days. */
328
+ selectedDates?: Date[];
329
+ /**
330
+ * In month mode, make day cells keyboard-navigable (one roving tab stop, arrow
331
+ * keys, Enter to open the day). Default false: keyboard focus moves through
332
+ * events only. Has no effect on the time-grid modes.
333
+ */
334
+ keyboardDayNavigation?: boolean;
335
+ /** Tap a day cell. */
336
+ onPressDay?: (date: Date) => void;
337
+ /** Tap the "+N more" overflow row. */
338
+ onPressMore?: (events: CalendarEvent$1<T>[], date: Date) => void;
339
+ /** Custom month chip renderer. */
340
+ renderMonthEvent?: DomMonthEvent<T>;
341
+ /** Custom agenda row renderer (`mode="schedule"`). */
342
+ renderScheduleEvent?: DomAgendaEvent<T>;
343
+ }
344
+ /**
345
+ * Batteries-included entry point for the react-dom renderer: it picks the right
346
+ * view for `mode`. `month` renders a single {@link MonthView}; `schedule` renders
347
+ * an {@link Agenda}; the time-grid modes render a {@link TimeGrid}. For a
348
+ * scrolling month picker, use {@link MonthList} directly.
349
+ */
350
+ declare function Calendar<T = unknown>({
351
+ mode,
352
+ date,
353
+ events,
354
+ weekStartsOn,
355
+ numberOfDays,
356
+ locale,
357
+ theme,
358
+ height,
359
+ className,
360
+ style,
361
+ onPressEvent,
362
+ ampm,
363
+ hourHeight,
364
+ scrollOffsetMinutes,
365
+ timeslots,
366
+ businessHours,
367
+ showNowIndicator,
368
+ showAllDayEventCell,
369
+ dragStepMinutes,
370
+ onPressCell,
371
+ onCreateEvent,
372
+ onDragStart,
373
+ onDragEvent,
374
+ onPressDateHeader,
375
+ renderTimeEvent,
376
+ hourComponent,
377
+ maxVisibleEventCount,
378
+ moreLabel,
379
+ showAdjacentMonths,
380
+ fillCellOnSelection,
381
+ selectedRange,
382
+ selectedDates,
383
+ minDate,
384
+ maxDate,
385
+ isDateDisabled,
386
+ keyboardDayNavigation,
387
+ onPressDay,
388
+ onPressMore,
389
+ renderMonthEvent,
390
+ renderScheduleEvent
391
+ }: CalendarProps<T>): import("react").JSX.Element;
392
+ //#endregion
393
+ //#region src/MonthList.d.ts
394
+ interface MonthListProps<T = unknown> extends DateSelectionConstraints$1 {
395
+ /** Anchor month; the list spans `pastMonths` before to `futureMonths` after. */
396
+ date: Date;
397
+ /** Months to render before the anchor (default 1). */
398
+ pastMonths?: number;
399
+ /** Months to render after the anchor (default 12). */
400
+ futureMonths?: number;
401
+ weekStartsOn?: WeekStartsOn$1;
402
+ /** Events to render as chips in each day cell (calendar layout when provided). */
403
+ events?: CalendarEvent$1<T>[];
404
+ /** Custom chip renderer; falls back to the built-in titled chip. */
405
+ renderEvent?: DomMonthEvent<T>;
406
+ /** Max chips shown per day before a "+N more" row (default 3). */
407
+ maxVisibleEventCount?: number;
408
+ /** Template for the overflow row; `{moreCount}` is replaced. */
409
+ moreLabel?: string;
410
+ /** Tap an event chip. */
411
+ onPressEvent?: (event: CalendarEvent$1<T>) => void;
412
+ /** Tap the "+N more" overflow row. */
413
+ onPressMore?: (events: CalendarEvent$1<T>[], date: Date) => void;
414
+ selectedRange?: DateRange$1;
415
+ selectedDates?: Date[];
416
+ /** Fill the whole cell on selection instead of the default rounded pill band. */
417
+ fillCellOnSelection?: boolean;
418
+ locale?: Locale;
419
+ theme?: Partial<DomCalendarTheme>;
420
+ /** Height of the scroll viewport, in px (default 480). */
421
+ height?: number | string;
422
+ /**
423
+ * When events are shown, make each month's day cells keyboard-navigable (roving
424
+ * tab stop, arrow keys, Enter to open the day). Default false. The picker
425
+ * layout (no `events`) is always navigable regardless.
426
+ */
427
+ keyboardDayNavigation?: boolean;
428
+ onPressDay?: (date: Date) => void;
429
+ className?: string;
430
+ style?: CSSProperties;
431
+ }
432
+ /**
433
+ * A vertically scrolling, virtualized list of months: the date picker. Built on
434
+ * Legend List's DOM renderer and the library's headless grid logic. Selection is
435
+ * controlled, pass `selectedRange` (or `selectedDates`) and handle `onPressDay`.
436
+ */
437
+ declare function MonthList<T = unknown>({
438
+ date,
439
+ pastMonths,
440
+ futureMonths,
441
+ weekStartsOn,
442
+ events,
443
+ renderEvent,
444
+ maxVisibleEventCount,
445
+ moreLabel,
446
+ onPressEvent,
447
+ onPressMore,
448
+ selectedRange,
449
+ selectedDates,
450
+ fillCellOnSelection,
451
+ locale,
452
+ theme: themeOverrides,
453
+ height,
454
+ minDate,
455
+ maxDate,
456
+ isDateDisabled,
457
+ keyboardDayNavigation,
458
+ onPressDay,
459
+ className,
460
+ style
461
+ }: MonthListProps<T>): import("react").JSX.Element;
462
+ //#endregion
463
+ export { Agenda, type AgendaProps, type BusinessHours, Calendar, type CalendarEvent, type CalendarMode, type CalendarProps, type DateRange, type DateSelectionConstraints, type DaySelectionState, type DomAgendaEvent, type DomAgendaEventArgs, type DomCalendarTheme, type DomMonthEvent, type DomMonthEventArgs, type DomRenderEvent, type DomRenderEventArgs, type ICalendarEvent, type MonthGrid, type MonthGridDay, type MonthGridWeek, type MonthGridWeekday, MonthList, type MonthListProps, MonthView, type MonthViewProps, type PositionedEvent, TimeGrid, type TimeGridMode, type TimeGridProps, type UseDateRangeOptions, type UseMonthGridOptions, type WeekStartsOn, buildMonthGrid, darkDomTheme, daySelectionState, defaultDomTheme, getViewDays, isAllDayEvent, isDateSelectable, isRangeEndpoint, isWithinDateRange, layoutDayEvents, mergeDomTheme, nextDateRange, useDateRange, useMonthGrid };