@super-calendar/dom 2.9.1 → 2.10.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 +24 -2
- package/dist/index.d.ts +24 -2
- package/dist/index.js +18 -14
- package/dist/index.mjs +18 -14
- package/package.json +2 -2
- package/src/Calendar.tsx +15 -0
- package/src/TimeGrid.tsx +31 -12
package/dist/index.d.mts
CHANGED
|
@@ -371,6 +371,17 @@ interface TimeGridProps<T = unknown> extends SlotStyleProps<TimeGridSlot> {
|
|
|
371
371
|
minHourHeight?: number;
|
|
372
372
|
/** Upper bound for pixels per hour when zooming. */
|
|
373
373
|
maxHourHeight?: number;
|
|
374
|
+
/**
|
|
375
|
+
* Minimum pixel height of a timed event box, so short events stay legible and
|
|
376
|
+
* clickable. Also the floor of the `boxHeight` handed to `renderEvent`. Default
|
|
377
|
+
* 14; pass 0 to size every box strictly by its duration.
|
|
378
|
+
*/
|
|
379
|
+
minEventHeight?: number;
|
|
380
|
+
/**
|
|
381
|
+
* Inset in pixels between a timed event box and its column edges (each side).
|
|
382
|
+
* Default 1; pass 0 to let events fill their column.
|
|
383
|
+
*/
|
|
384
|
+
eventGap?: number;
|
|
374
385
|
/** Snap dragged events to this many minutes (default 15). */
|
|
375
386
|
dragStepMinutes?: number;
|
|
376
387
|
/** Render event time ranges in 12-hour AM/PM (default false, 24h). */
|
|
@@ -479,7 +490,7 @@ interface TimeGridProps<T = unknown> extends SlotStyleProps<TimeGridSlot> {
|
|
|
479
490
|
* <TimeGrid mode="week" date={new Date()} events={events} />
|
|
480
491
|
* ```
|
|
481
492
|
*/
|
|
482
|
-
declare function TimeGrid<T = unknown>({ date, events, mode, numberOfDays, weekStartsOn, weekdayFormat, hourHeight: initialHourHeight, scrollOffsetMinutes, zoomable, minHourHeight, maxHourHeight, dragStepMinutes, ampm, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, hiddenDays, keyboardEventNavigation, businessHours, renderBusinessHours, showNowIndicator, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, now: nowProp, timeZone, showAllDayEventCell, locale, theme: themeOverrides, height, renderEvent, eventAccessibilityLabel, hourComponent, onPressEvent, onPressDateHeader, onPressCell, onCreateEvent, onDragStart, onDragEvent, onChangeDate, className, style, classNames, styles }: TimeGridProps<T>): ReactElement;
|
|
493
|
+
declare function TimeGrid<T = unknown>({ date, events, mode, numberOfDays, weekStartsOn, weekdayFormat, hourHeight: initialHourHeight, scrollOffsetMinutes, zoomable, minHourHeight, maxHourHeight, minEventHeight, eventGap, dragStepMinutes, ampm, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, hiddenDays, keyboardEventNavigation, businessHours, renderBusinessHours, showNowIndicator, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, now: nowProp, timeZone, showAllDayEventCell, locale, theme: themeOverrides, height, renderEvent, eventAccessibilityLabel, hourComponent, onPressEvent, onPressDateHeader, onPressCell, onCreateEvent, onDragStart, onDragEvent, onChangeDate, className, style, classNames, styles }: TimeGridProps<T>): ReactElement;
|
|
483
494
|
//#endregion
|
|
484
495
|
//#region src/Calendar.d.ts
|
|
485
496
|
/**
|
|
@@ -552,6 +563,17 @@ interface CalendarProps<T = unknown> extends DateSelectionConstraints$1, SlotSty
|
|
|
552
563
|
ampm?: boolean;
|
|
553
564
|
/** Initial pixels per hour. */
|
|
554
565
|
hourHeight?: number;
|
|
566
|
+
/**
|
|
567
|
+
* Minimum pixel height of a timed event box, so short events stay legible and
|
|
568
|
+
* clickable. Also the floor of the `boxHeight` handed to `renderTimeEvent`.
|
|
569
|
+
* Default 14; pass 0 to size every box strictly by its duration.
|
|
570
|
+
*/
|
|
571
|
+
minEventHeight?: number;
|
|
572
|
+
/**
|
|
573
|
+
* Inset in pixels between a timed event box and its column edges (each side).
|
|
574
|
+
* Default 1; pass 0 to let events fill their column.
|
|
575
|
+
*/
|
|
576
|
+
eventGap?: number;
|
|
555
577
|
/** Initial scroll position, in minutes from midnight. */
|
|
556
578
|
scrollOffsetMinutes?: number;
|
|
557
579
|
/** Sub-divisions per hour for the grid lines. */
|
|
@@ -673,7 +695,7 @@ interface CalendarProps<T = unknown> extends DateSelectionConstraints$1, SlotSty
|
|
|
673
695
|
* <Calendar mode="week" date={new Date()} events={events} />
|
|
674
696
|
* ```
|
|
675
697
|
*/
|
|
676
|
-
declare function Calendar<T = unknown>({ mode, date, events, onChangeDate, weekStartsOn, hiddenDays, now, numberOfDays, locale, timeZone, theme, height, className, style, onPressEvent, eventAccessibilityLabel, ampm, hourHeight, scrollOffsetMinutes, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, businessHours, renderBusinessHours, showNowIndicator, showAllDayEventCell, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, dragStepMinutes, onPressCell, onCreateEvent, onDragStart, onDragEvent, onPressDateHeader, renderTimeEvent, hourComponent, keyboardEventNavigation, maxVisibleEventCount, moreLabel, showAdjacentMonths, showTitle, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onSelectDrag, onPressMonth, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }: CalendarProps<T>): ReactElement;
|
|
698
|
+
declare function Calendar<T = unknown>({ mode, date, events, onChangeDate, weekStartsOn, hiddenDays, now, numberOfDays, locale, timeZone, theme, height, className, style, onPressEvent, eventAccessibilityLabel, ampm, hourHeight, minEventHeight, eventGap, scrollOffsetMinutes, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, businessHours, renderBusinessHours, showNowIndicator, showAllDayEventCell, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, dragStepMinutes, onPressCell, onCreateEvent, onDragStart, onDragEvent, onPressDateHeader, renderTimeEvent, hourComponent, keyboardEventNavigation, maxVisibleEventCount, moreLabel, showAdjacentMonths, showTitle, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onSelectDrag, onPressMonth, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }: CalendarProps<T>): ReactElement;
|
|
677
699
|
//#endregion
|
|
678
700
|
//#region src/MonthList.d.ts
|
|
679
701
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -371,6 +371,17 @@ interface TimeGridProps<T = unknown> extends SlotStyleProps<TimeGridSlot> {
|
|
|
371
371
|
minHourHeight?: number;
|
|
372
372
|
/** Upper bound for pixels per hour when zooming. */
|
|
373
373
|
maxHourHeight?: number;
|
|
374
|
+
/**
|
|
375
|
+
* Minimum pixel height of a timed event box, so short events stay legible and
|
|
376
|
+
* clickable. Also the floor of the `boxHeight` handed to `renderEvent`. Default
|
|
377
|
+
* 14; pass 0 to size every box strictly by its duration.
|
|
378
|
+
*/
|
|
379
|
+
minEventHeight?: number;
|
|
380
|
+
/**
|
|
381
|
+
* Inset in pixels between a timed event box and its column edges (each side).
|
|
382
|
+
* Default 1; pass 0 to let events fill their column.
|
|
383
|
+
*/
|
|
384
|
+
eventGap?: number;
|
|
374
385
|
/** Snap dragged events to this many minutes (default 15). */
|
|
375
386
|
dragStepMinutes?: number;
|
|
376
387
|
/** Render event time ranges in 12-hour AM/PM (default false, 24h). */
|
|
@@ -479,7 +490,7 @@ interface TimeGridProps<T = unknown> extends SlotStyleProps<TimeGridSlot> {
|
|
|
479
490
|
* <TimeGrid mode="week" date={new Date()} events={events} />
|
|
480
491
|
* ```
|
|
481
492
|
*/
|
|
482
|
-
declare function TimeGrid<T = unknown>({ date, events, mode, numberOfDays, weekStartsOn, weekdayFormat, hourHeight: initialHourHeight, scrollOffsetMinutes, zoomable, minHourHeight, maxHourHeight, dragStepMinutes, ampm, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, hiddenDays, keyboardEventNavigation, businessHours, renderBusinessHours, showNowIndicator, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, now: nowProp, timeZone, showAllDayEventCell, locale, theme: themeOverrides, height, renderEvent, eventAccessibilityLabel, hourComponent, onPressEvent, onPressDateHeader, onPressCell, onCreateEvent, onDragStart, onDragEvent, onChangeDate, className, style, classNames, styles }: TimeGridProps<T>): ReactElement;
|
|
493
|
+
declare function TimeGrid<T = unknown>({ date, events, mode, numberOfDays, weekStartsOn, weekdayFormat, hourHeight: initialHourHeight, scrollOffsetMinutes, zoomable, minHourHeight, maxHourHeight, minEventHeight, eventGap, dragStepMinutes, ampm, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, hiddenDays, keyboardEventNavigation, businessHours, renderBusinessHours, showNowIndicator, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, now: nowProp, timeZone, showAllDayEventCell, locale, theme: themeOverrides, height, renderEvent, eventAccessibilityLabel, hourComponent, onPressEvent, onPressDateHeader, onPressCell, onCreateEvent, onDragStart, onDragEvent, onChangeDate, className, style, classNames, styles }: TimeGridProps<T>): ReactElement;
|
|
483
494
|
//#endregion
|
|
484
495
|
//#region src/Calendar.d.ts
|
|
485
496
|
/**
|
|
@@ -552,6 +563,17 @@ interface CalendarProps<T = unknown> extends DateSelectionConstraints$1, SlotSty
|
|
|
552
563
|
ampm?: boolean;
|
|
553
564
|
/** Initial pixels per hour. */
|
|
554
565
|
hourHeight?: number;
|
|
566
|
+
/**
|
|
567
|
+
* Minimum pixel height of a timed event box, so short events stay legible and
|
|
568
|
+
* clickable. Also the floor of the `boxHeight` handed to `renderTimeEvent`.
|
|
569
|
+
* Default 14; pass 0 to size every box strictly by its duration.
|
|
570
|
+
*/
|
|
571
|
+
minEventHeight?: number;
|
|
572
|
+
/**
|
|
573
|
+
* Inset in pixels between a timed event box and its column edges (each side).
|
|
574
|
+
* Default 1; pass 0 to let events fill their column.
|
|
575
|
+
*/
|
|
576
|
+
eventGap?: number;
|
|
555
577
|
/** Initial scroll position, in minutes from midnight. */
|
|
556
578
|
scrollOffsetMinutes?: number;
|
|
557
579
|
/** Sub-divisions per hour for the grid lines. */
|
|
@@ -673,7 +695,7 @@ interface CalendarProps<T = unknown> extends DateSelectionConstraints$1, SlotSty
|
|
|
673
695
|
* <Calendar mode="week" date={new Date()} events={events} />
|
|
674
696
|
* ```
|
|
675
697
|
*/
|
|
676
|
-
declare function Calendar<T = unknown>({ mode, date, events, onChangeDate, weekStartsOn, hiddenDays, now, numberOfDays, locale, timeZone, theme, height, className, style, onPressEvent, eventAccessibilityLabel, ampm, hourHeight, scrollOffsetMinutes, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, businessHours, renderBusinessHours, showNowIndicator, showAllDayEventCell, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, dragStepMinutes, onPressCell, onCreateEvent, onDragStart, onDragEvent, onPressDateHeader, renderTimeEvent, hourComponent, keyboardEventNavigation, maxVisibleEventCount, moreLabel, showAdjacentMonths, showTitle, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onSelectDrag, onPressMonth, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }: CalendarProps<T>): ReactElement;
|
|
698
|
+
declare function Calendar<T = unknown>({ mode, date, events, onChangeDate, weekStartsOn, hiddenDays, now, numberOfDays, locale, timeZone, theme, height, className, style, onPressEvent, eventAccessibilityLabel, ampm, hourHeight, minEventHeight, eventGap, scrollOffsetMinutes, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, businessHours, renderBusinessHours, showNowIndicator, showAllDayEventCell, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, dragStepMinutes, onPressCell, onCreateEvent, onDragStart, onDragEvent, onPressDateHeader, renderTimeEvent, hourComponent, keyboardEventNavigation, maxVisibleEventCount, moreLabel, showAdjacentMonths, showTitle, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onSelectDrag, onPressMonth, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }: CalendarProps<T>): ReactElement;
|
|
677
699
|
//#endregion
|
|
678
700
|
//#region src/MonthList.d.ts
|
|
679
701
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1279,6 +1279,8 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
1279
1279
|
//#region src/TimeGrid.tsx
|
|
1280
1280
|
const GUTTER_WIDTH$1 = 56;
|
|
1281
1281
|
const HOURS_PER_DAY = 24;
|
|
1282
|
+
const DEFAULT_MIN_EVENT_HEIGHT = 14;
|
|
1283
|
+
const DEFAULT_EVENT_GAP = 1;
|
|
1282
1284
|
const clamp$1 = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
|
|
1283
1285
|
const EDGE_ZONE = 32;
|
|
1284
1286
|
const EDGE_DWELL_MS = 600;
|
|
@@ -1376,7 +1378,7 @@ function DefaultDomEvent({ event, mode, isAllDay, boxHeight, ampm = false, theme
|
|
|
1376
1378
|
* <TimeGrid mode="week" date={new Date()} events={events} />
|
|
1377
1379
|
* ```
|
|
1378
1380
|
*/
|
|
1379
|
-
function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStartsOn = 0, weekdayFormat = "short", hourHeight: initialHourHeight = 48, scrollOffsetMinutes = 480, zoomable = true, minHourHeight = 24, maxHourHeight = 160, dragStepMinutes = 15, ampm = false, timeslots = 1, minHour = 0, maxHour = 24, hideHours = false, showWeekNumber = false, weekNumberPrefix = "W", hiddenDays, keyboardEventNavigation = false, businessHours, renderBusinessHours, showNowIndicator = true, highlightWeekends = true, eventStartEditable = true, eventDurationEditable = true, eventOverlap = true, now: nowProp, timeZone, showAllDayEventCell = true, locale, theme: themeOverrides, height = 600, renderEvent, eventAccessibilityLabel, hourComponent, onPressEvent, onPressDateHeader, onPressCell, onCreateEvent, onDragStart, onDragEvent, onChangeDate, className, style, classNames, styles }) {
|
|
1381
|
+
function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStartsOn = 0, weekdayFormat = "short", hourHeight: initialHourHeight = 48, scrollOffsetMinutes = 480, zoomable = true, minHourHeight = 24, maxHourHeight = 160, minEventHeight = DEFAULT_MIN_EVENT_HEIGHT, eventGap = DEFAULT_EVENT_GAP, dragStepMinutes = 15, ampm = false, timeslots = 1, minHour = 0, maxHour = 24, hideHours = false, showWeekNumber = false, weekNumberPrefix = "W", hiddenDays, keyboardEventNavigation = false, businessHours, renderBusinessHours, showNowIndicator = true, highlightWeekends = true, eventStartEditable = true, eventDurationEditable = true, eventOverlap = true, now: nowProp, timeZone, showAllDayEventCell = true, locale, theme: themeOverrides, height = 600, renderEvent, eventAccessibilityLabel, hourComponent, onPressEvent, onPressDateHeader, onPressCell, onCreateEvent, onDragStart, onDragEvent, onChangeDate, className, style, classNames, styles }) {
|
|
1380
1382
|
const theme = (0, react.useMemo)(() => mergeDomTheme(themeOverrides), [themeOverrides]);
|
|
1381
1383
|
const slot = createSlots({
|
|
1382
1384
|
classNames,
|
|
@@ -1777,7 +1779,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1777
1779
|
event: dragged,
|
|
1778
1780
|
mode,
|
|
1779
1781
|
isAllDay: false,
|
|
1780
|
-
boxHeight: Math.max(drag.spillHours * hourHeight,
|
|
1782
|
+
boxHeight: Math.max(drag.spillHours * hourHeight, minEventHeight),
|
|
1781
1783
|
continuesBefore: true,
|
|
1782
1784
|
continuesAfter: false,
|
|
1783
1785
|
ampm,
|
|
@@ -2170,7 +2172,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
2170
2172
|
const durationHours = active ? active.durationHours : pe.durationHours;
|
|
2171
2173
|
if (!active && (pe.startHours >= windowEnd || pe.startHours + pe.durationHours <= windowStart)) return null;
|
|
2172
2174
|
const top = (startHours - windowStart) * hourHeight;
|
|
2173
|
-
const boxHeight = Math.max(Math.min(durationHours, HOURS_PER_DAY - startHours) * hourHeight,
|
|
2175
|
+
const boxHeight = Math.max(Math.min(durationHours, HOURS_PER_DAY - startHours) * hourHeight, minEventHeight);
|
|
2174
2176
|
const widthPct = 100 / pe.columns;
|
|
2175
2177
|
const onPress = () => onPressEvent?.(pe.event);
|
|
2176
2178
|
const args = {
|
|
@@ -2216,8 +2218,8 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
2216
2218
|
position: "absolute",
|
|
2217
2219
|
top,
|
|
2218
2220
|
height: boxHeight,
|
|
2219
|
-
left: `calc(${pe.column * widthPct}% +
|
|
2220
|
-
width: `calc(${widthPct}% -
|
|
2221
|
+
left: `calc(${pe.column * widthPct}% + ${eventGap}px)`,
|
|
2222
|
+
width: `calc(${widthPct}% - ${eventGap * 2}px)`,
|
|
2221
2223
|
cursor: canMove ? "grab" : "pointer",
|
|
2222
2224
|
touchAction: canMove ? "none" : "auto",
|
|
2223
2225
|
zIndex: active ? 3 : 1,
|
|
@@ -2270,9 +2272,9 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
2270
2272
|
...slot("event", { base: {
|
|
2271
2273
|
position: "absolute",
|
|
2272
2274
|
top: (moveSegment.startHours - windowStart) * hourHeight,
|
|
2273
|
-
left:
|
|
2274
|
-
right:
|
|
2275
|
-
height: Math.max(moveSegment.durationHours * hourHeight,
|
|
2275
|
+
left: eventGap,
|
|
2276
|
+
right: eventGap,
|
|
2277
|
+
height: Math.max(moveSegment.durationHours * hourHeight, minEventHeight),
|
|
2276
2278
|
pointerEvents: "none",
|
|
2277
2279
|
zIndex: 3,
|
|
2278
2280
|
opacity: .85
|
|
@@ -2282,7 +2284,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
2282
2284
|
event: moveSegment.event,
|
|
2283
2285
|
mode,
|
|
2284
2286
|
isAllDay: false,
|
|
2285
|
-
boxHeight: Math.max(moveSegment.durationHours * hourHeight,
|
|
2287
|
+
boxHeight: Math.max(moveSegment.durationHours * hourHeight, minEventHeight),
|
|
2286
2288
|
continuesBefore: moveSegment.continuesBefore,
|
|
2287
2289
|
continuesAfter: moveSegment.continuesAfter,
|
|
2288
2290
|
ampm,
|
|
@@ -2301,8 +2303,8 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
2301
2303
|
...slot("event", { base: {
|
|
2302
2304
|
position: "absolute",
|
|
2303
2305
|
top: -windowStart * hourHeight,
|
|
2304
|
-
left:
|
|
2305
|
-
right:
|
|
2306
|
+
left: eventGap,
|
|
2307
|
+
right: eventGap,
|
|
2306
2308
|
height: spill.boxHeight,
|
|
2307
2309
|
pointerEvents: "none",
|
|
2308
2310
|
zIndex: 3,
|
|
@@ -2342,8 +2344,8 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
2342
2344
|
...slot("createGhost", {
|
|
2343
2345
|
base: {
|
|
2344
2346
|
position: "absolute",
|
|
2345
|
-
left:
|
|
2346
|
-
right:
|
|
2347
|
+
left: eventGap,
|
|
2348
|
+
right: eventGap,
|
|
2347
2349
|
top: ghost.topPx,
|
|
2348
2350
|
height: Math.max(ghost.heightPx, 2),
|
|
2349
2351
|
opacity: .7,
|
|
@@ -2424,7 +2426,7 @@ function pageStep(mode, date, direction, weekStartsOn, numberOfDays) {
|
|
|
2424
2426
|
* <Calendar mode="week" date={new Date()} events={events} />
|
|
2425
2427
|
* ```
|
|
2426
2428
|
*/
|
|
2427
|
-
function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0, hiddenDays, now, numberOfDays, locale, timeZone, theme, height, className, style, onPressEvent, eventAccessibilityLabel, ampm, hourHeight, scrollOffsetMinutes, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, businessHours, renderBusinessHours, showNowIndicator, showAllDayEventCell, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, dragStepMinutes, onPressCell, onCreateEvent, onDragStart, onDragEvent, onPressDateHeader, renderTimeEvent, hourComponent, keyboardEventNavigation, maxVisibleEventCount, moreLabel, showAdjacentMonths, showTitle, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onSelectDrag, onPressMonth, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }) {
|
|
2429
|
+
function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0, hiddenDays, now, numberOfDays, locale, timeZone, theme, height, className, style, onPressEvent, eventAccessibilityLabel, ampm, hourHeight, minEventHeight, eventGap, scrollOffsetMinutes, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, businessHours, renderBusinessHours, showNowIndicator, showAllDayEventCell, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, dragStepMinutes, onPressCell, onCreateEvent, onDragStart, onDragEvent, onPressDateHeader, renderTimeEvent, hourComponent, keyboardEventNavigation, maxVisibleEventCount, moreLabel, showAdjacentMonths, showTitle, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onSelectDrag, onPressMonth, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }) {
|
|
2428
2430
|
const displayEvents = (0, react.useMemo)(() => {
|
|
2429
2431
|
let out = events ?? EMPTY_EVENTS;
|
|
2430
2432
|
if (out.some((e) => e.recurrence)) {
|
|
@@ -2549,6 +2551,8 @@ function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0,
|
|
|
2549
2551
|
styles,
|
|
2550
2552
|
ampm,
|
|
2551
2553
|
hourHeight,
|
|
2554
|
+
minEventHeight,
|
|
2555
|
+
eventGap,
|
|
2552
2556
|
scrollOffsetMinutes,
|
|
2553
2557
|
timeslots,
|
|
2554
2558
|
minHour,
|
package/dist/index.mjs
CHANGED
|
@@ -1278,6 +1278,8 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
1278
1278
|
//#region src/TimeGrid.tsx
|
|
1279
1279
|
const GUTTER_WIDTH$1 = 56;
|
|
1280
1280
|
const HOURS_PER_DAY = 24;
|
|
1281
|
+
const DEFAULT_MIN_EVENT_HEIGHT = 14;
|
|
1282
|
+
const DEFAULT_EVENT_GAP = 1;
|
|
1281
1283
|
const clamp$1 = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
|
|
1282
1284
|
const EDGE_ZONE = 32;
|
|
1283
1285
|
const EDGE_DWELL_MS = 600;
|
|
@@ -1375,7 +1377,7 @@ function DefaultDomEvent({ event, mode, isAllDay, boxHeight, ampm = false, theme
|
|
|
1375
1377
|
* <TimeGrid mode="week" date={new Date()} events={events} />
|
|
1376
1378
|
* ```
|
|
1377
1379
|
*/
|
|
1378
|
-
function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStartsOn = 0, weekdayFormat = "short", hourHeight: initialHourHeight = 48, scrollOffsetMinutes = 480, zoomable = true, minHourHeight = 24, maxHourHeight = 160, dragStepMinutes = 15, ampm = false, timeslots = 1, minHour = 0, maxHour = 24, hideHours = false, showWeekNumber = false, weekNumberPrefix = "W", hiddenDays, keyboardEventNavigation = false, businessHours, renderBusinessHours, showNowIndicator = true, highlightWeekends = true, eventStartEditable = true, eventDurationEditable = true, eventOverlap = true, now: nowProp, timeZone, showAllDayEventCell = true, locale, theme: themeOverrides, height = 600, renderEvent, eventAccessibilityLabel: eventAccessibilityLabel$1, hourComponent, onPressEvent, onPressDateHeader, onPressCell, onCreateEvent, onDragStart, onDragEvent, onChangeDate, className, style, classNames, styles }) {
|
|
1380
|
+
function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStartsOn = 0, weekdayFormat = "short", hourHeight: initialHourHeight = 48, scrollOffsetMinutes = 480, zoomable = true, minHourHeight = 24, maxHourHeight = 160, minEventHeight = DEFAULT_MIN_EVENT_HEIGHT, eventGap = DEFAULT_EVENT_GAP, dragStepMinutes = 15, ampm = false, timeslots = 1, minHour = 0, maxHour = 24, hideHours = false, showWeekNumber = false, weekNumberPrefix = "W", hiddenDays, keyboardEventNavigation = false, businessHours, renderBusinessHours, showNowIndicator = true, highlightWeekends = true, eventStartEditable = true, eventDurationEditable = true, eventOverlap = true, now: nowProp, timeZone, showAllDayEventCell = true, locale, theme: themeOverrides, height = 600, renderEvent, eventAccessibilityLabel: eventAccessibilityLabel$1, hourComponent, onPressEvent, onPressDateHeader, onPressCell, onCreateEvent, onDragStart, onDragEvent, onChangeDate, className, style, classNames, styles }) {
|
|
1379
1381
|
const theme = useMemo(() => mergeDomTheme(themeOverrides), [themeOverrides]);
|
|
1380
1382
|
const slot = createSlots({
|
|
1381
1383
|
classNames,
|
|
@@ -1776,7 +1778,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1776
1778
|
event: dragged,
|
|
1777
1779
|
mode,
|
|
1778
1780
|
isAllDay: false,
|
|
1779
|
-
boxHeight: Math.max(drag.spillHours * hourHeight,
|
|
1781
|
+
boxHeight: Math.max(drag.spillHours * hourHeight, minEventHeight),
|
|
1780
1782
|
continuesBefore: true,
|
|
1781
1783
|
continuesAfter: false,
|
|
1782
1784
|
ampm,
|
|
@@ -2169,7 +2171,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
2169
2171
|
const durationHours = active ? active.durationHours : pe.durationHours;
|
|
2170
2172
|
if (!active && (pe.startHours >= windowEnd || pe.startHours + pe.durationHours <= windowStart)) return null;
|
|
2171
2173
|
const top = (startHours - windowStart) * hourHeight;
|
|
2172
|
-
const boxHeight = Math.max(Math.min(durationHours, HOURS_PER_DAY - startHours) * hourHeight,
|
|
2174
|
+
const boxHeight = Math.max(Math.min(durationHours, HOURS_PER_DAY - startHours) * hourHeight, minEventHeight);
|
|
2173
2175
|
const widthPct = 100 / pe.columns;
|
|
2174
2176
|
const onPress = () => onPressEvent?.(pe.event);
|
|
2175
2177
|
const args = {
|
|
@@ -2215,8 +2217,8 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
2215
2217
|
position: "absolute",
|
|
2216
2218
|
top,
|
|
2217
2219
|
height: boxHeight,
|
|
2218
|
-
left: `calc(${pe.column * widthPct}% +
|
|
2219
|
-
width: `calc(${widthPct}% -
|
|
2220
|
+
left: `calc(${pe.column * widthPct}% + ${eventGap}px)`,
|
|
2221
|
+
width: `calc(${widthPct}% - ${eventGap * 2}px)`,
|
|
2220
2222
|
cursor: canMove ? "grab" : "pointer",
|
|
2221
2223
|
touchAction: canMove ? "none" : "auto",
|
|
2222
2224
|
zIndex: active ? 3 : 1,
|
|
@@ -2269,9 +2271,9 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
2269
2271
|
...slot("event", { base: {
|
|
2270
2272
|
position: "absolute",
|
|
2271
2273
|
top: (moveSegment.startHours - windowStart) * hourHeight,
|
|
2272
|
-
left:
|
|
2273
|
-
right:
|
|
2274
|
-
height: Math.max(moveSegment.durationHours * hourHeight,
|
|
2274
|
+
left: eventGap,
|
|
2275
|
+
right: eventGap,
|
|
2276
|
+
height: Math.max(moveSegment.durationHours * hourHeight, minEventHeight),
|
|
2275
2277
|
pointerEvents: "none",
|
|
2276
2278
|
zIndex: 3,
|
|
2277
2279
|
opacity: .85
|
|
@@ -2281,7 +2283,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
2281
2283
|
event: moveSegment.event,
|
|
2282
2284
|
mode,
|
|
2283
2285
|
isAllDay: false,
|
|
2284
|
-
boxHeight: Math.max(moveSegment.durationHours * hourHeight,
|
|
2286
|
+
boxHeight: Math.max(moveSegment.durationHours * hourHeight, minEventHeight),
|
|
2285
2287
|
continuesBefore: moveSegment.continuesBefore,
|
|
2286
2288
|
continuesAfter: moveSegment.continuesAfter,
|
|
2287
2289
|
ampm,
|
|
@@ -2300,8 +2302,8 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
2300
2302
|
...slot("event", { base: {
|
|
2301
2303
|
position: "absolute",
|
|
2302
2304
|
top: -windowStart * hourHeight,
|
|
2303
|
-
left:
|
|
2304
|
-
right:
|
|
2305
|
+
left: eventGap,
|
|
2306
|
+
right: eventGap,
|
|
2305
2307
|
height: spill.boxHeight,
|
|
2306
2308
|
pointerEvents: "none",
|
|
2307
2309
|
zIndex: 3,
|
|
@@ -2341,8 +2343,8 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
2341
2343
|
...slot("createGhost", {
|
|
2342
2344
|
base: {
|
|
2343
2345
|
position: "absolute",
|
|
2344
|
-
left:
|
|
2345
|
-
right:
|
|
2346
|
+
left: eventGap,
|
|
2347
|
+
right: eventGap,
|
|
2346
2348
|
top: ghost.topPx,
|
|
2347
2349
|
height: Math.max(ghost.heightPx, 2),
|
|
2348
2350
|
opacity: .7,
|
|
@@ -2423,7 +2425,7 @@ function pageStep(mode, date, direction, weekStartsOn, numberOfDays) {
|
|
|
2423
2425
|
* <Calendar mode="week" date={new Date()} events={events} />
|
|
2424
2426
|
* ```
|
|
2425
2427
|
*/
|
|
2426
|
-
function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0, hiddenDays, now, numberOfDays, locale, timeZone, theme, height, className, style, onPressEvent, eventAccessibilityLabel, ampm, hourHeight, scrollOffsetMinutes, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, businessHours, renderBusinessHours, showNowIndicator, showAllDayEventCell, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, dragStepMinutes, onPressCell, onCreateEvent, onDragStart, onDragEvent, onPressDateHeader, renderTimeEvent, hourComponent, keyboardEventNavigation, maxVisibleEventCount, moreLabel, showAdjacentMonths, showTitle, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onSelectDrag, onPressMonth, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }) {
|
|
2428
|
+
function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0, hiddenDays, now, numberOfDays, locale, timeZone, theme, height, className, style, onPressEvent, eventAccessibilityLabel, ampm, hourHeight, minEventHeight, eventGap, scrollOffsetMinutes, timeslots, minHour, maxHour, hideHours, showWeekNumber, weekNumberPrefix, businessHours, renderBusinessHours, showNowIndicator, showAllDayEventCell, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, dragStepMinutes, onPressCell, onCreateEvent, onDragStart, onDragEvent, onPressDateHeader, renderTimeEvent, hourComponent, keyboardEventNavigation, maxVisibleEventCount, moreLabel, showAdjacentMonths, showTitle, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onSelectDrag, onPressMonth, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }) {
|
|
2427
2429
|
const displayEvents = useMemo(() => {
|
|
2428
2430
|
let out = events ?? EMPTY_EVENTS;
|
|
2429
2431
|
if (out.some((e) => e.recurrence)) {
|
|
@@ -2548,6 +2550,8 @@ function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0,
|
|
|
2548
2550
|
styles,
|
|
2549
2551
|
ampm,
|
|
2550
2552
|
hourHeight,
|
|
2553
|
+
minEventHeight,
|
|
2554
|
+
eventGap,
|
|
2551
2555
|
scrollOffsetMinutes,
|
|
2552
2556
|
timeslots,
|
|
2553
2557
|
minHour,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@super-calendar/dom",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.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.10.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@legendapp/list": ">=3",
|
package/src/Calendar.tsx
CHANGED
|
@@ -115,6 +115,17 @@ export interface CalendarProps<T = unknown>
|
|
|
115
115
|
ampm?: boolean;
|
|
116
116
|
/** Initial pixels per hour. */
|
|
117
117
|
hourHeight?: number;
|
|
118
|
+
/**
|
|
119
|
+
* Minimum pixel height of a timed event box, so short events stay legible and
|
|
120
|
+
* clickable. Also the floor of the `boxHeight` handed to `renderTimeEvent`.
|
|
121
|
+
* Default 14; pass 0 to size every box strictly by its duration.
|
|
122
|
+
*/
|
|
123
|
+
minEventHeight?: number;
|
|
124
|
+
/**
|
|
125
|
+
* Inset in pixels between a timed event box and its column edges (each side).
|
|
126
|
+
* Default 1; pass 0 to let events fill their column.
|
|
127
|
+
*/
|
|
128
|
+
eventGap?: number;
|
|
118
129
|
/** Initial scroll position, in minutes from midnight. */
|
|
119
130
|
scrollOffsetMinutes?: number;
|
|
120
131
|
/** Sub-divisions per hour for the grid lines. */
|
|
@@ -310,6 +321,8 @@ export function Calendar<T = unknown>({
|
|
|
310
321
|
// time grid
|
|
311
322
|
ampm,
|
|
312
323
|
hourHeight,
|
|
324
|
+
minEventHeight,
|
|
325
|
+
eventGap,
|
|
313
326
|
scrollOffsetMinutes,
|
|
314
327
|
timeslots,
|
|
315
328
|
minHour,
|
|
@@ -493,6 +506,8 @@ export function Calendar<T = unknown>({
|
|
|
493
506
|
styles={styles}
|
|
494
507
|
ampm={ampm}
|
|
495
508
|
hourHeight={hourHeight}
|
|
509
|
+
minEventHeight={minEventHeight}
|
|
510
|
+
eventGap={eventGap}
|
|
496
511
|
scrollOffsetMinutes={scrollOffsetMinutes}
|
|
497
512
|
timeslots={timeslots}
|
|
498
513
|
minHour={minHour}
|
package/src/TimeGrid.tsx
CHANGED
|
@@ -80,6 +80,12 @@ export type TimeGridSlot =
|
|
|
80
80
|
|
|
81
81
|
const GUTTER_WIDTH = 56;
|
|
82
82
|
const HOURS_PER_DAY = 24;
|
|
83
|
+
// Floor for a timed event box's height, so a very short event still shows a
|
|
84
|
+
// sliver of its chip. Overridable per grid via `minEventHeight`.
|
|
85
|
+
const DEFAULT_MIN_EVENT_HEIGHT = 14;
|
|
86
|
+
// Horizontal inset of each event box from its column edges. Overridable per grid
|
|
87
|
+
// via `eventGap`.
|
|
88
|
+
const DEFAULT_EVENT_GAP = 1;
|
|
83
89
|
const clamp = (v: number, lo: number, hi: number) => Math.min(hi, Math.max(lo, v));
|
|
84
90
|
|
|
85
91
|
// Edge auto-advance: how close to the day-columns edge (px) counts as "at the
|
|
@@ -151,6 +157,17 @@ export interface TimeGridProps<T = unknown> extends SlotStyleProps<TimeGridSlot>
|
|
|
151
157
|
minHourHeight?: number;
|
|
152
158
|
/** Upper bound for pixels per hour when zooming. */
|
|
153
159
|
maxHourHeight?: number;
|
|
160
|
+
/**
|
|
161
|
+
* Minimum pixel height of a timed event box, so short events stay legible and
|
|
162
|
+
* clickable. Also the floor of the `boxHeight` handed to `renderEvent`. Default
|
|
163
|
+
* 14; pass 0 to size every box strictly by its duration.
|
|
164
|
+
*/
|
|
165
|
+
minEventHeight?: number;
|
|
166
|
+
/**
|
|
167
|
+
* Inset in pixels between a timed event box and its column edges (each side).
|
|
168
|
+
* Default 1; pass 0 to let events fill their column.
|
|
169
|
+
*/
|
|
170
|
+
eventGap?: number;
|
|
154
171
|
/** Snap dragged events to this many minutes (default 15). */
|
|
155
172
|
dragStepMinutes?: number;
|
|
156
173
|
/** Render event time ranges in 12-hour AM/PM (default false, 24h). */
|
|
@@ -392,6 +409,8 @@ export function TimeGrid<T = unknown>({
|
|
|
392
409
|
zoomable = true,
|
|
393
410
|
minHourHeight = 24,
|
|
394
411
|
maxHourHeight = 160,
|
|
412
|
+
minEventHeight = DEFAULT_MIN_EVENT_HEIGHT,
|
|
413
|
+
eventGap = DEFAULT_EVENT_GAP,
|
|
395
414
|
dragStepMinutes = 15,
|
|
396
415
|
ampm = false,
|
|
397
416
|
timeslots = 1,
|
|
@@ -998,7 +1017,7 @@ export function TimeGrid<T = unknown>({
|
|
|
998
1017
|
event: dragged,
|
|
999
1018
|
mode,
|
|
1000
1019
|
isAllDay: false,
|
|
1001
|
-
boxHeight: Math.max(drag.spillHours * hourHeight,
|
|
1020
|
+
boxHeight: Math.max(drag.spillHours * hourHeight, minEventHeight),
|
|
1002
1021
|
continuesBefore: true,
|
|
1003
1022
|
continuesAfter: false,
|
|
1004
1023
|
ampm,
|
|
@@ -1484,7 +1503,7 @@ export function TimeGrid<T = unknown>({
|
|
|
1484
1503
|
// them to the day, so the height doesn't jump on commit.
|
|
1485
1504
|
const boxHeight = Math.max(
|
|
1486
1505
|
Math.min(durationHours, HOURS_PER_DAY - startHours) * hourHeight,
|
|
1487
|
-
|
|
1506
|
+
minEventHeight,
|
|
1488
1507
|
);
|
|
1489
1508
|
const widthPct = 100 / pe.columns;
|
|
1490
1509
|
const onPress = () => onPressEvent?.(pe.event);
|
|
@@ -1552,8 +1571,8 @@ export function TimeGrid<T = unknown>({
|
|
|
1552
1571
|
// is the renderer's concern: the built-in one clamps, and a
|
|
1553
1572
|
// custom renderer should adapt to the `boxHeight` it's given.
|
|
1554
1573
|
height: boxHeight,
|
|
1555
|
-
left: `calc(${pe.column * widthPct}% +
|
|
1556
|
-
width: `calc(${widthPct}% -
|
|
1574
|
+
left: `calc(${pe.column * widthPct}% + ${eventGap}px)`,
|
|
1575
|
+
width: `calc(${widthPct}% - ${eventGap * 2}px)`,
|
|
1557
1576
|
cursor: canMove ? "grab" : "pointer",
|
|
1558
1577
|
touchAction: canMove ? "none" : "auto",
|
|
1559
1578
|
zIndex: active ? 3 : 1,
|
|
@@ -1622,9 +1641,9 @@ export function TimeGrid<T = unknown>({
|
|
|
1622
1641
|
base: {
|
|
1623
1642
|
position: "absolute",
|
|
1624
1643
|
top: (moveSegment.startHours - windowStart) * hourHeight,
|
|
1625
|
-
left:
|
|
1626
|
-
right:
|
|
1627
|
-
height: Math.max(moveSegment.durationHours * hourHeight,
|
|
1644
|
+
left: eventGap,
|
|
1645
|
+
right: eventGap,
|
|
1646
|
+
height: Math.max(moveSegment.durationHours * hourHeight, minEventHeight),
|
|
1628
1647
|
pointerEvents: "none",
|
|
1629
1648
|
zIndex: 3,
|
|
1630
1649
|
opacity: 0.85,
|
|
@@ -1636,7 +1655,7 @@ export function TimeGrid<T = unknown>({
|
|
|
1636
1655
|
event: moveSegment.event,
|
|
1637
1656
|
mode,
|
|
1638
1657
|
isAllDay: false,
|
|
1639
|
-
boxHeight: Math.max(moveSegment.durationHours * hourHeight,
|
|
1658
|
+
boxHeight: Math.max(moveSegment.durationHours * hourHeight, minEventHeight),
|
|
1640
1659
|
continuesBefore: moveSegment.continuesBefore,
|
|
1641
1660
|
continuesAfter: moveSegment.continuesAfter,
|
|
1642
1661
|
ampm,
|
|
@@ -1662,8 +1681,8 @@ export function TimeGrid<T = unknown>({
|
|
|
1662
1681
|
// the preview is scrolled out of view, exactly like the
|
|
1663
1682
|
// continuation the drop will commit.
|
|
1664
1683
|
top: -windowStart * hourHeight,
|
|
1665
|
-
left:
|
|
1666
|
-
right:
|
|
1684
|
+
left: eventGap,
|
|
1685
|
+
right: eventGap,
|
|
1667
1686
|
height: spill.boxHeight,
|
|
1668
1687
|
pointerEvents: "none",
|
|
1669
1688
|
zIndex: 3,
|
|
@@ -1712,8 +1731,8 @@ export function TimeGrid<T = unknown>({
|
|
|
1712
1731
|
{...slot("createGhost", {
|
|
1713
1732
|
base: {
|
|
1714
1733
|
position: "absolute",
|
|
1715
|
-
left:
|
|
1716
|
-
right:
|
|
1734
|
+
left: eventGap,
|
|
1735
|
+
right: eventGap,
|
|
1717
1736
|
top: ghost.topPx,
|
|
1718
1737
|
height: Math.max(ghost.heightPx, 2),
|
|
1719
1738
|
opacity: 0.7,
|