@super-calendar/dom 2.6.0 → 2.8.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/dist/index.d.mts +111 -16
- package/dist/index.d.ts +111 -16
- package/dist/index.js +811 -250
- package/dist/index.mjs +783 -252
- package/package.json +2 -2
- package/src/Agenda.tsx +5 -2
- package/src/Calendar.tsx +42 -0
- package/src/MonthList.tsx +3 -1
- package/src/MonthView.tsx +441 -174
- package/src/ResourceTimeline.tsx +286 -24
- package/src/TimeGrid.tsx +427 -87
- package/src/YearView.tsx +14 -4
- package/src/index.ts +8 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@super-calendar/dom",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"description": "Virtualized month / week / day calendar and date picker for react-dom. No React Native, no react-native-web.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"calendar",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@super-calendar/core": "2.
|
|
51
|
+
"@super-calendar/core": "2.8.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@legendapp/list": ">=3",
|
package/src/Agenda.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import { LegendList } from "@legendapp/list/react";
|
|
|
2
2
|
import { format, isSameDay, type Locale, startOfDay } from "date-fns";
|
|
3
3
|
import { type ComponentType, type CSSProperties, type ReactElement, useMemo } from "react";
|
|
4
4
|
import type { CalendarEvent, EventAccessibilityLabeler } from "@super-calendar/core";
|
|
5
|
-
import { eventTimeLabel, getIsToday, isAllDayEvent } from "@super-calendar/core";
|
|
5
|
+
import { eventTimeLabel, getIsToday, isAllDayEvent, isBackgroundEvent } from "@super-calendar/core";
|
|
6
6
|
import { createSlots, type ResolvedSlot, type SlotStyleProps } from "./slots";
|
|
7
7
|
import { type DomCalendarTheme, mergeDomTheme } from "./theme";
|
|
8
8
|
|
|
@@ -122,7 +122,10 @@ export function Agenda<T = unknown>({
|
|
|
122
122
|
const Renderer = renderEvent;
|
|
123
123
|
|
|
124
124
|
const rows = useMemo<Row<T>[]>(() => {
|
|
125
|
-
const sorted =
|
|
125
|
+
const sorted = events
|
|
126
|
+
// Background events shade the grids; they have no agenda row.
|
|
127
|
+
.filter((event) => !isBackgroundEvent(event))
|
|
128
|
+
.sort((a, b) => a.start.getTime() - b.start.getTime());
|
|
126
129
|
const out: Row<T>[] = [];
|
|
127
130
|
let currentDay: Date | null = null;
|
|
128
131
|
sorted.forEach((event, index) => {
|
package/src/Calendar.tsx
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
import {
|
|
23
23
|
type CalendarMode,
|
|
24
24
|
type BusinessHours,
|
|
25
|
+
type BusinessHoursBand,
|
|
25
26
|
type CalendarEvent,
|
|
26
27
|
type DateRange,
|
|
27
28
|
type DateSelectionConstraints,
|
|
@@ -67,6 +68,14 @@ export interface CalendarProps<T = unknown>
|
|
|
67
68
|
events?: CalendarEvent<T>[];
|
|
68
69
|
/** First day of the week. Sunday = 0 (default) … Saturday = 6. */
|
|
69
70
|
weekStartsOn?: WeekStartsOn;
|
|
71
|
+
/** Weekdays (0=Sunday…6=Saturday) hidden from the grid, e.g. `[0, 6]` for weekends off. */
|
|
72
|
+
hiddenDays?: number[];
|
|
73
|
+
/**
|
|
74
|
+
* Fixed "now" instant for the current-time indicator (doesn't tick), e.g. a
|
|
75
|
+
* server-synced clock. Defaults to the device clock, shifted into `timeZone`
|
|
76
|
+
* when one is set so the line matches the displayed events.
|
|
77
|
+
*/
|
|
78
|
+
now?: Date;
|
|
70
79
|
/** Column count for `mode="custom"`. */
|
|
71
80
|
numberOfDays?: number;
|
|
72
81
|
/** date-fns locale for titles, headers, and time labels. */
|
|
@@ -116,10 +125,25 @@ export interface CalendarProps<T = unknown>
|
|
|
116
125
|
weekNumberPrefix?: string;
|
|
117
126
|
/** Shade the hours outside business hours. */
|
|
118
127
|
businessHours?: BusinessHours;
|
|
128
|
+
/**
|
|
129
|
+
* Render a closed-hours band's content yourself (a label, icon, pattern).
|
|
130
|
+
* The grid keeps positioning the band; when set, the themed tint is dropped
|
|
131
|
+
* and your output fills the band instead. Decorative only: the
|
|
132
|
+
* band stays non-interactive and hidden from assistive tech.
|
|
133
|
+
*/
|
|
134
|
+
renderBusinessHours?: (band: BusinessHoursBand) => ReactNode;
|
|
119
135
|
/** Show the current-time indicator (default true). */
|
|
120
136
|
showNowIndicator?: boolean;
|
|
121
137
|
/** Show the all-day lane (default true). */
|
|
122
138
|
showAllDayEventCell?: boolean;
|
|
139
|
+
/** Tint weekend columns (default true). Set false to treat weekends normally. */
|
|
140
|
+
highlightWeekends?: boolean;
|
|
141
|
+
/** Allow moving events by default (per-event `startEditable` overrides). Default true. */
|
|
142
|
+
eventStartEditable?: boolean;
|
|
143
|
+
/** Allow resizing events by default (per-event `durationEditable` overrides). Default true. */
|
|
144
|
+
eventDurationEditable?: boolean;
|
|
145
|
+
/** Reject drags/resizes that would overlap another event (default true = allowed). */
|
|
146
|
+
eventOverlap?: boolean;
|
|
123
147
|
/** Snap dragged/created events to this many minutes. */
|
|
124
148
|
dragStepMinutes?: number;
|
|
125
149
|
/** Tap empty grid space. */
|
|
@@ -243,6 +267,8 @@ export function Calendar<T = unknown>({
|
|
|
243
267
|
events,
|
|
244
268
|
onChangeDate,
|
|
245
269
|
weekStartsOn = 0,
|
|
270
|
+
hiddenDays,
|
|
271
|
+
now,
|
|
246
272
|
numberOfDays,
|
|
247
273
|
locale,
|
|
248
274
|
timeZone,
|
|
@@ -263,8 +289,13 @@ export function Calendar<T = unknown>({
|
|
|
263
289
|
showWeekNumber,
|
|
264
290
|
weekNumberPrefix,
|
|
265
291
|
businessHours,
|
|
292
|
+
renderBusinessHours,
|
|
266
293
|
showNowIndicator,
|
|
267
294
|
showAllDayEventCell,
|
|
295
|
+
highlightWeekends,
|
|
296
|
+
eventStartEditable,
|
|
297
|
+
eventDurationEditable,
|
|
298
|
+
eventOverlap,
|
|
268
299
|
dragStepMinutes,
|
|
269
300
|
onPressCell,
|
|
270
301
|
onCreateEvent,
|
|
@@ -333,6 +364,7 @@ export function Calendar<T = unknown>({
|
|
|
333
364
|
date={date}
|
|
334
365
|
events={displayEvents}
|
|
335
366
|
weekStartsOn={weekStartsOn}
|
|
367
|
+
hiddenDays={hiddenDays}
|
|
336
368
|
locale={locale}
|
|
337
369
|
theme={theme}
|
|
338
370
|
className={className}
|
|
@@ -368,6 +400,7 @@ export function Calendar<T = unknown>({
|
|
|
368
400
|
date={date}
|
|
369
401
|
events={displayEvents}
|
|
370
402
|
weekStartsOn={weekStartsOn}
|
|
403
|
+
hiddenDays={hiddenDays}
|
|
371
404
|
weekdayFormat={weekdayFormat}
|
|
372
405
|
locale={locale}
|
|
373
406
|
theme={theme}
|
|
@@ -400,6 +433,9 @@ export function Calendar<T = unknown>({
|
|
|
400
433
|
mode={mode}
|
|
401
434
|
events={displayEvents}
|
|
402
435
|
weekStartsOn={weekStartsOn}
|
|
436
|
+
hiddenDays={hiddenDays}
|
|
437
|
+
now={now}
|
|
438
|
+
timeZone={timeZone}
|
|
403
439
|
weekdayFormat={weekdayFormat}
|
|
404
440
|
numberOfDays={numberOfDays}
|
|
405
441
|
locale={locale}
|
|
@@ -419,14 +455,20 @@ export function Calendar<T = unknown>({
|
|
|
419
455
|
showWeekNumber={showWeekNumber}
|
|
420
456
|
weekNumberPrefix={weekNumberPrefix}
|
|
421
457
|
businessHours={businessHours}
|
|
458
|
+
renderBusinessHours={renderBusinessHours}
|
|
422
459
|
showNowIndicator={showNowIndicator}
|
|
423
460
|
showAllDayEventCell={showAllDayEventCell}
|
|
461
|
+
highlightWeekends={highlightWeekends}
|
|
462
|
+
eventStartEditable={eventStartEditable}
|
|
463
|
+
eventDurationEditable={eventDurationEditable}
|
|
464
|
+
eventOverlap={eventOverlap}
|
|
424
465
|
dragStepMinutes={dragStepMinutes}
|
|
425
466
|
onPressEvent={onPressEvent}
|
|
426
467
|
onPressCell={onPressCell}
|
|
427
468
|
onCreateEvent={onCreateEvent}
|
|
428
469
|
onDragStart={onDragStart}
|
|
429
470
|
onDragEvent={onDragEvent}
|
|
471
|
+
onChangeDate={onChangeDate}
|
|
430
472
|
onPressDateHeader={onPressDateHeader}
|
|
431
473
|
renderEvent={renderTimeEvent}
|
|
432
474
|
eventAccessibilityLabel={eventAccessibilityLabel}
|
package/src/MonthList.tsx
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
type DateSelectionConstraints,
|
|
10
10
|
type EventAccessibilityLabeler,
|
|
11
11
|
groupEventsByDay,
|
|
12
|
+
isBackgroundEvent,
|
|
12
13
|
type WeekdayFormat,
|
|
13
14
|
type WeekStartsOn,
|
|
14
15
|
} from "@super-calendar/core";
|
|
@@ -133,7 +134,8 @@ export function MonthList<T = unknown>({
|
|
|
133
134
|
// Build the day→events index once for the whole list rather than per month.
|
|
134
135
|
const eventsByDay = useMemo(() => {
|
|
135
136
|
if (!events) return undefined;
|
|
136
|
-
|
|
137
|
+
// Background events shade the time grid; the month grids ignore them.
|
|
138
|
+
const map = groupEventsByDay(events.filter((event) => !isBackgroundEvent(event)));
|
|
137
139
|
// Each day reads all-day events first, then timed events by start.
|
|
138
140
|
for (const list of map.values()) list.sort(compareDayEvents);
|
|
139
141
|
return map;
|