@super-calendar/dom 2.8.2 → 2.9.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 +81 -10
- package/dist/index.d.ts +81 -10
- package/dist/index.js +345 -83
- package/dist/index.mjs +347 -85
- package/package.json +2 -2
- package/src/Calendar.tsx +42 -3
- package/src/MonthView.tsx +200 -50
- package/src/TimeGrid.tsx +174 -52
- package/src/YearView.tsx +218 -19
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LegendList } from "@legendapp/list/react";
|
|
2
|
-
import { addDays, addMinutes, addMonths, addYears, endOfDay, endOfMonth, endOfWeek, endOfYear, format, getISOWeek, isSameDay, isSameMonth, startOfDay, startOfMonth, startOfWeek, startOfYear } from "date-fns";
|
|
2
|
+
import { addDays, addMinutes, addMonths, addYears, differenceInCalendarDays, endOfDay, endOfMonth, endOfWeek, endOfYear, format, getISOWeek, isSameDay, isSameMonth, startOfDay, startOfMonth, startOfWeek, startOfYear } from "date-fns";
|
|
3
3
|
import { useEffect, useId, useMemo, useRef, useState } from "react";
|
|
4
|
-
import { backgroundBandsForDay, backgroundBandsForDay as backgroundBandsForDay$1, bandRounding, buildMonthGrid, buildMonthGrid as buildMonthGrid$1, buildMonthWeeks, cellRangeFromDrag, closedHourBands, compareDayEvents, darkColors, dayBadgeKind, daySelectionState, eventAccessibilityLabel, eventChipLayout, eventTimeLabel, eventsInTimeZone, expandRecurringEvents, expandRecurringEvents as expandRecurringEvents$1, filterHiddenDays, formatHour, getIsToday, getViewDays, getViewDays as getViewDays$1, getWeekDays, getYearMonths, groupEventsByDay, isAllDayEvent, isAllDayEvent as isAllDayEvent$1, isBackgroundEvent, isBackgroundEvent as isBackgroundEvent$1, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, layoutDayEvents, layoutDayEvents as layoutDayEvents$1, layoutMonthWeek, layoutMonthWeek as layoutMonthWeek$1, lightColors, nextDateRange, nextDateRange as nextDateRange$1, overlapsOtherEvents, pageStepDays, parseICalendar, rangeBandKind, titleNumberOfLines, toICalendar, useDateRange, useEventSource, useMonthGrid, useNow, useNow as useNow$1, weekdayFormatToken, weekdayFormatToken as weekdayFormatToken$1 } from "@super-calendar/core";
|
|
4
|
+
import { backgroundBandsForDay, backgroundBandsForDay as backgroundBandsForDay$1, bandRounding, buildMonthGrid, buildMonthGrid as buildMonthGrid$1, buildMonthWeeks, cellRangeFromDrag, clampMoveStartMinutes, closedHourBands, compareDayEvents, darkColors, dayBadgeKind, daySelectionState, daySelectionState as daySelectionState$1, eventAccessibilityLabel, eventChipLayout, eventTimeLabel, eventsInTimeZone, expandRecurringEvents, expandRecurringEvents as expandRecurringEvents$1, filterHiddenDays, formatHour, getIsToday, getViewDays, getViewDays as getViewDays$1, getWeekDays, getYearMonths, groupEventsByDay, isAllDayEvent, isAllDayEvent as isAllDayEvent$1, isBackgroundEvent, isBackgroundEvent as isBackgroundEvent$1, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, layoutDayEvents, layoutDayEvents as layoutDayEvents$1, layoutMonthWeek, layoutMonthWeek as layoutMonthWeek$1, lightColors, monthCreateRange, monthDropBounds, nextDateRange, nextDateRange as nextDateRange$1, overlapsOtherEvents, pageStepDays, parseICalendar, rangeBandKind, titleNumberOfLines, toICalendar, useDateRange, useEventSource, useMonthGrid, useNow, useNow as useNow$1, weekdayFormatToken, weekdayFormatToken as weekdayFormatToken$1 } from "@super-calendar/core";
|
|
5
5
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
//#region src/slots.ts
|
|
7
7
|
/** Join truthy class names (a dependency-free clsx-lite). */
|
|
@@ -240,12 +240,56 @@ function Agenda({ events, locale, ampm = false, activeDate, theme: themeOverride
|
|
|
240
240
|
* highlighted and a dot under days that hold events. It's the view `Calendar`
|
|
241
241
|
* renders for `mode="year"`.
|
|
242
242
|
*/
|
|
243
|
-
function YearView({ date, events, weekStartsOn = 0, hiddenDays, locale, activeDate, minMonthWidth = 150, onPressDay, onPressMonth, theme: themeOverrides, className, style, classNames, styles }) {
|
|
243
|
+
function YearView({ date, events, weekStartsOn = 0, hiddenDays, locale, activeDate, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, minMonthWidth = 150, onPressDay, onPressMonth, onSelectDrag, onCreateEvent, theme: themeOverrides, className, style, classNames, styles }) {
|
|
244
244
|
const theme = useMemo(() => mergeDomTheme(themeOverrides), [themeOverrides]);
|
|
245
245
|
const slot = createSlots({
|
|
246
246
|
classNames,
|
|
247
247
|
styles
|
|
248
248
|
});
|
|
249
|
+
const sweepEnabled = onSelectDrag != null || onCreateEvent != null;
|
|
250
|
+
const [creating, setCreating] = useState(null);
|
|
251
|
+
const creatingRef = useRef(creating);
|
|
252
|
+
creatingRef.current = creating;
|
|
253
|
+
const movedRef = useRef(false);
|
|
254
|
+
const suppressClickRef = useRef(false);
|
|
255
|
+
const beginPress = () => {
|
|
256
|
+
suppressClickRef.current = false;
|
|
257
|
+
movedRef.current = false;
|
|
258
|
+
};
|
|
259
|
+
const beginCreate = (day) => {
|
|
260
|
+
const t = startOfDay(day).getTime();
|
|
261
|
+
setCreating({
|
|
262
|
+
anchor: t,
|
|
263
|
+
hover: t
|
|
264
|
+
});
|
|
265
|
+
};
|
|
266
|
+
const extendCreate = (day) => {
|
|
267
|
+
const current = creatingRef.current;
|
|
268
|
+
if (!current) return;
|
|
269
|
+
const t = startOfDay(day).getTime();
|
|
270
|
+
if (t === current.hover) return;
|
|
271
|
+
movedRef.current = true;
|
|
272
|
+
setCreating((c) => c ? {
|
|
273
|
+
...c,
|
|
274
|
+
hover: t
|
|
275
|
+
} : c);
|
|
276
|
+
const [lo, hi] = current.anchor <= t ? [current.anchor, t] : [t, current.anchor];
|
|
277
|
+
onSelectDrag?.(new Date(lo), new Date(hi));
|
|
278
|
+
};
|
|
279
|
+
const isCreating = creating !== null;
|
|
280
|
+
useEffect(() => {
|
|
281
|
+
if (!isCreating) return;
|
|
282
|
+
const finish = () => {
|
|
283
|
+
const c = creatingRef.current;
|
|
284
|
+
setCreating(null);
|
|
285
|
+
if (!c || !movedRef.current) return;
|
|
286
|
+
suppressClickRef.current = true;
|
|
287
|
+
const range = monthCreateRange(new Date(c.anchor), new Date(c.hover));
|
|
288
|
+
onCreateEvent?.(range.start, range.end);
|
|
289
|
+
};
|
|
290
|
+
window.addEventListener("pointerup", finish);
|
|
291
|
+
return () => window.removeEventListener("pointerup", finish);
|
|
292
|
+
}, [isCreating, onCreateEvent]);
|
|
249
293
|
const months = useMemo(() => getYearMonths(date), [date]);
|
|
250
294
|
const weekdayLabels = useMemo(() => filterHiddenDays(getWeekDays(date, weekStartsOn), hiddenDays).map((d) => format(d, weekdayFormatToken$1("narrow"), { locale })), [
|
|
251
295
|
date,
|
|
@@ -342,9 +386,21 @@ function YearView({ date, events, weekStartsOn = 0, hiddenDays, locale, activeDa
|
|
|
342
386
|
"aria-hidden": true,
|
|
343
387
|
style: { aspectRatio: "1" }
|
|
344
388
|
}, day.toISOString());
|
|
345
|
-
const
|
|
389
|
+
const isToday = getIsToday(day);
|
|
390
|
+
const isHighlighted = activeDate ? isSameCalendarDay(day, activeDate) : isToday;
|
|
346
391
|
const hasEvents = eventDays.has(startOfDay(day).toISOString());
|
|
347
|
-
const
|
|
392
|
+
const state = daySelectionState$1(day, {
|
|
393
|
+
selectedDates,
|
|
394
|
+
selectedRange
|
|
395
|
+
}, {
|
|
396
|
+
minDate,
|
|
397
|
+
maxDate,
|
|
398
|
+
isDateDisabled
|
|
399
|
+
});
|
|
400
|
+
const dayTime = startOfDay(day).getTime();
|
|
401
|
+
const inCreate = creating != null && dayTime >= Math.min(creating.anchor, creating.hover) && dayTime <= Math.max(creating.anchor, creating.hover);
|
|
402
|
+
const label = `${format(day, "EEEE, d LLLL yyyy", { locale })}${isToday ? ", today" : ""}${state.isSelected ? ", selected" : ""}${state.isDisabled ? ", unavailable" : ""}${hasEvents ? ", has events" : ""}`;
|
|
403
|
+
const badge = dayBadgeKind(state, isHighlighted);
|
|
348
404
|
const daySlot = slot("day", {
|
|
349
405
|
base: {
|
|
350
406
|
position: "relative",
|
|
@@ -356,21 +412,40 @@ function YearView({ date, events, weekStartsOn = 0, hiddenDays, locale, activeDa
|
|
|
356
412
|
border: "none",
|
|
357
413
|
background: "transparent",
|
|
358
414
|
font: "inherit",
|
|
359
|
-
cursor: onPressDay ? "pointer" : "default",
|
|
360
|
-
boxSizing: "border-box"
|
|
415
|
+
cursor: state.isDisabled ? "default" : onPressDay || sweepEnabled ? "pointer" : "default",
|
|
416
|
+
boxSizing: "border-box",
|
|
417
|
+
...sweepEnabled ? { touchAction: "pan-y" } : null
|
|
361
418
|
},
|
|
362
419
|
themed: {
|
|
363
420
|
fontSize: 11,
|
|
364
|
-
|
|
365
|
-
...isHighlighted ? {
|
|
366
|
-
background: theme.todayBackground,
|
|
367
|
-
color: theme.todayText
|
|
368
|
-
} : { color: theme.text }
|
|
421
|
+
color: state.isDisabled ? theme.textDisabled : theme.text
|
|
369
422
|
}
|
|
370
423
|
});
|
|
371
424
|
const states = dataState({
|
|
372
|
-
"data-today":
|
|
373
|
-
"data-events": hasEvents
|
|
425
|
+
"data-today": isToday,
|
|
426
|
+
"data-events": hasEvents,
|
|
427
|
+
"data-selected": state.isSelected,
|
|
428
|
+
"data-range": state.isInRange,
|
|
429
|
+
"data-disabled": state.isDisabled,
|
|
430
|
+
"data-creating": inCreate
|
|
431
|
+
});
|
|
432
|
+
const bandKind = rangeBandKind(state, true);
|
|
433
|
+
const rounding = bandRounding(rangeBandKind(state, false));
|
|
434
|
+
const band = bandKind === "none" ? null : /* @__PURE__ */ jsx("span", {
|
|
435
|
+
"data-band": true,
|
|
436
|
+
"aria-hidden": true,
|
|
437
|
+
...slot("rangeBand", {
|
|
438
|
+
base: {
|
|
439
|
+
position: "absolute",
|
|
440
|
+
inset: 0,
|
|
441
|
+
zIndex: 0,
|
|
442
|
+
borderTopLeftRadius: rounding.start ? "50%" : 0,
|
|
443
|
+
borderBottomLeftRadius: rounding.start ? "50%" : 0,
|
|
444
|
+
borderTopRightRadius: rounding.end ? "50%" : 0,
|
|
445
|
+
borderBottomRightRadius: rounding.end ? "50%" : 0
|
|
446
|
+
},
|
|
447
|
+
themed: { background: theme.rangeBackground }
|
|
448
|
+
})
|
|
374
449
|
});
|
|
375
450
|
const dot = hasEvents ? /* @__PURE__ */ jsx("span", {
|
|
376
451
|
"aria-hidden": true,
|
|
@@ -380,27 +455,77 @@ function YearView({ date, events, weekStartsOn = 0, hiddenDays, locale, activeDa
|
|
|
380
455
|
bottom: 1,
|
|
381
456
|
left: "50%",
|
|
382
457
|
marginLeft: -1.5,
|
|
458
|
+
zIndex: 2,
|
|
383
459
|
width: 3,
|
|
384
460
|
height: 3,
|
|
385
461
|
borderRadius: 2
|
|
386
462
|
},
|
|
387
|
-
themed: { background:
|
|
463
|
+
themed: { background: badge === "none" ? theme.todayBackground : theme.todayText }
|
|
388
464
|
})
|
|
389
465
|
}) : null;
|
|
390
|
-
|
|
466
|
+
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
467
|
+
band,
|
|
468
|
+
/* @__PURE__ */ jsx("span", {
|
|
469
|
+
...slot("dayBadge", {
|
|
470
|
+
base: {
|
|
471
|
+
position: "relative",
|
|
472
|
+
zIndex: 1,
|
|
473
|
+
width: "100%",
|
|
474
|
+
height: "100%",
|
|
475
|
+
borderRadius: "50%",
|
|
476
|
+
display: "flex",
|
|
477
|
+
alignItems: "center",
|
|
478
|
+
justifyContent: "center"
|
|
479
|
+
},
|
|
480
|
+
themed: badge === "today" ? {
|
|
481
|
+
background: theme.todayBackground,
|
|
482
|
+
color: theme.todayText
|
|
483
|
+
} : badge === "selected" ? {
|
|
484
|
+
background: theme.selectedBackground,
|
|
485
|
+
color: theme.selectedText
|
|
486
|
+
} : {}
|
|
487
|
+
}),
|
|
488
|
+
children: day.getDate()
|
|
489
|
+
}),
|
|
490
|
+
dot
|
|
491
|
+
] });
|
|
492
|
+
const sweepHandlers = sweepEnabled ? {
|
|
493
|
+
onPointerDown: (e) => {
|
|
494
|
+
beginPress();
|
|
495
|
+
if (e.button === 0 && !state.isDisabled) beginCreate(day);
|
|
496
|
+
},
|
|
497
|
+
onPointerEnter: state.isDisabled ? void 0 : () => extendCreate(day)
|
|
498
|
+
} : null;
|
|
499
|
+
return onPressDay ? /* @__PURE__ */ jsx("button", {
|
|
391
500
|
type: "button",
|
|
392
501
|
role: "gridcell",
|
|
393
|
-
|
|
502
|
+
disabled: state.isDisabled,
|
|
394
503
|
"aria-label": label,
|
|
504
|
+
onClick: () => {
|
|
505
|
+
if (suppressClickRef.current) {
|
|
506
|
+
suppressClickRef.current = false;
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
509
|
+
onPressDay(day);
|
|
510
|
+
},
|
|
511
|
+
...sweepHandlers,
|
|
395
512
|
...states,
|
|
396
513
|
...daySlot,
|
|
397
|
-
children:
|
|
398
|
-
}, day.toISOString()) : /* @__PURE__ */
|
|
514
|
+
children: content
|
|
515
|
+
}, day.toISOString()) : sweepEnabled ? /* @__PURE__ */ jsx("div", {
|
|
399
516
|
role: "gridcell",
|
|
517
|
+
"aria-disabled": state.isDisabled || void 0,
|
|
400
518
|
"aria-label": label,
|
|
519
|
+
...sweepHandlers,
|
|
401
520
|
...states,
|
|
402
521
|
...daySlot,
|
|
403
|
-
children:
|
|
522
|
+
children: content
|
|
523
|
+
}, day.toISOString()) : /* @__PURE__ */ jsx("div", {
|
|
524
|
+
role: "gridcell",
|
|
525
|
+
"aria-label": label,
|
|
526
|
+
...states,
|
|
527
|
+
...daySlot,
|
|
528
|
+
children: content
|
|
404
529
|
}, day.toISOString());
|
|
405
530
|
})
|
|
406
531
|
}, week[0].toISOString()))
|
|
@@ -421,6 +546,7 @@ const DATE_ROW = 24;
|
|
|
421
546
|
const CHIP_HEIGHT = 18;
|
|
422
547
|
const CHIP_GAP = 2;
|
|
423
548
|
const CELL_PAD = 4;
|
|
549
|
+
const DRAGGED_CHIP_OPACITY = .4;
|
|
424
550
|
function dayCellDefault(day, theme, highlightWeekends) {
|
|
425
551
|
return {
|
|
426
552
|
base: {
|
|
@@ -447,21 +573,27 @@ function dayCellDefault(day, theme, highlightWeekends) {
|
|
|
447
573
|
* rounded strip (the default) or fill the whole cell (`fillCell`). Returns null
|
|
448
574
|
* for days with no band. Endpoints get the leading/trailing pill rounding. Its
|
|
449
575
|
* geometry is structural; only the fill colour is themed.
|
|
576
|
+
*
|
|
577
|
+
* In events mode the strip tracks the compact date badge instead of the picker's
|
|
578
|
+
* tall cell, so it reads as a band across the dates rather than a block over the
|
|
579
|
+
* event chips (and matches the native renderer's month grid).
|
|
450
580
|
*/
|
|
451
|
-
function rangeBandDefault(day, theme, fillCell) {
|
|
581
|
+
function rangeBandDefault(day, theme, fillCell, eventsMode) {
|
|
452
582
|
const kind = rangeBandKind(day, fillCell);
|
|
453
583
|
if (kind === "none") return null;
|
|
454
584
|
const fill = kind === "fill";
|
|
455
|
-
const
|
|
456
|
-
const
|
|
585
|
+
const badgeSize = eventsMode ? DATE_ROW - 2 : theme.dayBadgeSize;
|
|
586
|
+
const bandHeight = eventsMode ? badgeSize : theme.rangeBandHeight;
|
|
587
|
+
const inset = fill ? 0 : eventsMode ? CELL_PAD : Math.max(0, (theme.cellHeight - bandHeight) / 2);
|
|
588
|
+
const radius = fill ? 0 : bandHeight / 2;
|
|
457
589
|
const rounding = bandRounding(kind);
|
|
458
|
-
const cap = `calc(50% - ${
|
|
590
|
+
const cap = eventsMode ? 0 : `calc(50% - ${badgeSize / 2}px)`;
|
|
459
591
|
const base = {
|
|
460
592
|
position: "absolute",
|
|
461
593
|
left: rounding.start ? cap : 0,
|
|
462
594
|
right: rounding.end ? cap : 0,
|
|
463
595
|
top: inset,
|
|
464
|
-
bottom: inset,
|
|
596
|
+
...fill || !eventsMode ? { bottom: inset } : { height: bandHeight },
|
|
465
597
|
zIndex: 0
|
|
466
598
|
};
|
|
467
599
|
if (rounding.start) {
|
|
@@ -498,7 +630,7 @@ function badgeDefault(day, theme, hovered) {
|
|
|
498
630
|
}
|
|
499
631
|
};
|
|
500
632
|
}
|
|
501
|
-
function eventCellDefault(day, theme, height, highlightWeekends) {
|
|
633
|
+
function eventCellDefault(day, theme, height, highlightWeekends, isDragTarget) {
|
|
502
634
|
return {
|
|
503
635
|
base: {
|
|
504
636
|
position: "relative",
|
|
@@ -516,7 +648,7 @@ function eventCellDefault(day, theme, height, highlightWeekends) {
|
|
|
516
648
|
},
|
|
517
649
|
themed: {
|
|
518
650
|
borderTop: `1px solid ${theme.gridLine}`,
|
|
519
|
-
background: highlightWeekends && day.isWeekend && !day.isInRange ? theme.weekendBackground : "transparent",
|
|
651
|
+
background: isDragTarget ? theme.rangeBackground : highlightWeekends && day.isWeekend && !day.isInRange ? theme.weekendBackground : "transparent",
|
|
520
652
|
color: day.isDisabled ? theme.textDisabled : theme.text
|
|
521
653
|
}
|
|
522
654
|
};
|
|
@@ -616,7 +748,7 @@ function collectRowEvents(week, eventsByDay) {
|
|
|
616
748
|
* <MonthView date={new Date()} events={events} onPressDay={(d) => setDate(d)} />
|
|
617
749
|
* ```
|
|
618
750
|
*/
|
|
619
|
-
function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short", events, eventsByDay: eventsByDayProp, renderEvent, eventAccessibilityLabel, maxVisibleEventCount = 3, moreLabel = "{moreCount} More", onPressEvent, onPressMore, selectedRange, selectedDates, showAdjacentMonths = true, highlightWeekends = true, fillCellOnSelection = false, showTitle = true, showWeekdays = true, locale, theme: themeOverrides, minDate, maxDate, isDateDisabled, onPressDay, onCreateEvent, keyboardDayNavigation = false, className, style, classNames, styles }) {
|
|
751
|
+
function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short", events, eventsByDay: eventsByDayProp, renderEvent, eventAccessibilityLabel, maxVisibleEventCount = 3, moreLabel = "{moreCount} More", onPressEvent, onPressMore, selectedRange, selectedDates, showAdjacentMonths = true, highlightWeekends = true, fillCellOnSelection = false, showTitle = true, showWeekdays = true, locale, theme: themeOverrides, minDate, maxDate, isDateDisabled, onPressDay, onPressCell, onCreateEvent, onSelectDrag, onDragEvent, onDragStart, eventStartEditable = true, eventOverlap = true, keyboardDayNavigation = false, className, style, classNames, styles }) {
|
|
620
752
|
const theme = useMemo(() => mergeDomTheme(themeOverrides), [themeOverrides]);
|
|
621
753
|
const slot = createSlots({
|
|
622
754
|
classNames,
|
|
@@ -706,46 +838,87 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
706
838
|
const [hoveredKey, setHoveredKey] = useState(null);
|
|
707
839
|
const gridRef = useRef(null);
|
|
708
840
|
const focusKey = format(focusedDate, "yyyy-MM-dd");
|
|
709
|
-
const [
|
|
710
|
-
const
|
|
711
|
-
|
|
841
|
+
const [drag, setDrag] = useState(null);
|
|
842
|
+
const dragRef = useRef(drag);
|
|
843
|
+
dragRef.current = drag;
|
|
712
844
|
const movedRef = useRef(false);
|
|
713
845
|
const suppressClickRef = useRef(false);
|
|
846
|
+
const consumeSuppressedClick = () => {
|
|
847
|
+
if (!suppressClickRef.current) return false;
|
|
848
|
+
suppressClickRef.current = false;
|
|
849
|
+
return true;
|
|
850
|
+
};
|
|
851
|
+
const canMove = (event) => onDragEvent != null && !event.disabled && event.draggable !== false && (event.startEditable ?? eventStartEditable);
|
|
852
|
+
const beginPress = () => {
|
|
853
|
+
suppressClickRef.current = false;
|
|
854
|
+
movedRef.current = false;
|
|
855
|
+
};
|
|
714
856
|
const beginCreate = (day) => {
|
|
715
|
-
if (!onCreateEvent) return;
|
|
857
|
+
if (!onCreateEvent && !onSelectDrag) return;
|
|
716
858
|
const t = startOfDay(day).getTime();
|
|
717
|
-
|
|
718
|
-
|
|
859
|
+
setDrag({
|
|
860
|
+
kind: "create",
|
|
719
861
|
anchor: t,
|
|
720
862
|
hover: t
|
|
721
863
|
});
|
|
722
864
|
};
|
|
723
|
-
const
|
|
724
|
-
if (!
|
|
865
|
+
const beginMove = (event, day) => {
|
|
866
|
+
if (!canMove(event)) return;
|
|
725
867
|
const t = startOfDay(day).getTime();
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
868
|
+
setDrag({
|
|
869
|
+
kind: "move",
|
|
870
|
+
event,
|
|
871
|
+
from: t,
|
|
872
|
+
to: t
|
|
873
|
+
});
|
|
874
|
+
onDragStart?.(event);
|
|
875
|
+
};
|
|
876
|
+
const extendDrag = (day) => {
|
|
877
|
+
const current = dragRef.current;
|
|
878
|
+
if (!current) return;
|
|
879
|
+
const t = startOfDay(day).getTime();
|
|
880
|
+
if (t === (current.kind === "create" ? current.hover : current.to)) return;
|
|
881
|
+
movedRef.current = true;
|
|
882
|
+
setDrag(current.kind === "create" ? {
|
|
883
|
+
...current,
|
|
884
|
+
hover: t
|
|
885
|
+
} : {
|
|
886
|
+
...current,
|
|
887
|
+
to: t
|
|
888
|
+
});
|
|
889
|
+
if (current.kind === "create") {
|
|
890
|
+
const [lo, hi] = current.anchor <= t ? [current.anchor, t] : [t, current.anchor];
|
|
891
|
+
onSelectDrag?.(new Date(lo), new Date(hi));
|
|
732
892
|
}
|
|
733
893
|
};
|
|
734
|
-
const
|
|
894
|
+
const isDragging = drag !== null;
|
|
895
|
+
const dragWired = onCreateEvent != null || onSelectDrag != null || onDragEvent != null;
|
|
735
896
|
useEffect(() => {
|
|
736
|
-
if (!
|
|
897
|
+
if (!isDragging) return;
|
|
737
898
|
const finish = () => {
|
|
738
|
-
const
|
|
739
|
-
|
|
740
|
-
if (!
|
|
899
|
+
const current = dragRef.current;
|
|
900
|
+
setDrag(null);
|
|
901
|
+
if (!current || !movedRef.current) return;
|
|
741
902
|
suppressClickRef.current = true;
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
903
|
+
if (current.kind === "create") {
|
|
904
|
+
const range = monthCreateRange(new Date(current.anchor), new Date(current.hover));
|
|
905
|
+
onCreateEvent?.(range.start, range.end);
|
|
906
|
+
return;
|
|
907
|
+
}
|
|
908
|
+
const next = monthDropBounds(current.event, new Date(current.from), new Date(current.to));
|
|
909
|
+
if (!next) return;
|
|
910
|
+
if (eventOverlap === false && overlapsOtherEvents(events ?? [], current.event, next.start, next.end)) return;
|
|
911
|
+
onDragEvent?.(current.event, next.start, next.end);
|
|
745
912
|
};
|
|
746
913
|
window.addEventListener("pointerup", finish);
|
|
747
914
|
return () => window.removeEventListener("pointerup", finish);
|
|
748
|
-
}, [
|
|
915
|
+
}, [
|
|
916
|
+
isDragging,
|
|
917
|
+
onCreateEvent,
|
|
918
|
+
onDragEvent,
|
|
919
|
+
eventOverlap,
|
|
920
|
+
events
|
|
921
|
+
]);
|
|
749
922
|
const onKeyDown = (e) => {
|
|
750
923
|
let next = null;
|
|
751
924
|
if (e.key === "ArrowLeft") next = addDays(focusedDate, -1);
|
|
@@ -845,10 +1018,11 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
845
1018
|
"aria-hidden": true,
|
|
846
1019
|
style: { height: cellHeight }
|
|
847
1020
|
}, day.id);
|
|
848
|
-
const band = rangeBandDefault(day, theme, fillCellOnSelection);
|
|
1021
|
+
const band = rangeBandDefault(day, theme, fillCellOnSelection, eventsMode);
|
|
849
1022
|
const label = format(day.date, "EEEE, d MMMM yyyy", locale ? { locale } : void 0);
|
|
850
1023
|
const dayTime = startOfDay(day.date).getTime();
|
|
851
|
-
const inCreate =
|
|
1024
|
+
const inCreate = drag?.kind === "create" && dayTime >= Math.min(drag.anchor, drag.hover) && dayTime <= Math.max(drag.anchor, drag.hover);
|
|
1025
|
+
const isDropTarget = drag?.kind === "move" && dayTime === drag.to && drag.to !== drag.from;
|
|
852
1026
|
const dayData = dataState({
|
|
853
1027
|
"data-today": day.isToday,
|
|
854
1028
|
"data-selected": day.isSelected,
|
|
@@ -856,13 +1030,14 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
856
1030
|
"data-weekend": day.isWeekend,
|
|
857
1031
|
"data-outside": !day.isCurrentMonth,
|
|
858
1032
|
"data-disabled": day.isDisabled,
|
|
859
|
-
"data-creating": inCreate
|
|
1033
|
+
"data-creating": inCreate,
|
|
1034
|
+
"data-drop": isDropTarget
|
|
860
1035
|
});
|
|
861
1036
|
if (eventsMode) {
|
|
862
1037
|
const dayEvents = eventsByDay.get(startOfDay(day.date).toISOString()) ?? [];
|
|
863
1038
|
const hiddenEvents = rowLayout.segments.filter((s) => s.startCol <= dayCol && s.endCol >= dayCol && s.lane >= visibleLanes).map((s) => s.event);
|
|
864
1039
|
const dayLabel = format(day.date, "d MMMM", locale ? { locale } : void 0);
|
|
865
|
-
const dayCellProps = slot("day", eventCellDefault(day, theme, cellHeight, highlightWeekends));
|
|
1040
|
+
const dayCellProps = slot("day", eventCellDefault(day, theme, cellHeight, highlightWeekends, inCreate || isDropTarget));
|
|
866
1041
|
return /* @__PURE__ */ jsxs("div", {
|
|
867
1042
|
role: "gridcell",
|
|
868
1043
|
"data-day": day.id,
|
|
@@ -871,26 +1046,28 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
871
1046
|
"aria-disabled": day.isDisabled || void 0,
|
|
872
1047
|
"aria-label": label,
|
|
873
1048
|
...dayCellProps,
|
|
874
|
-
style:
|
|
1049
|
+
style: dragWired ? {
|
|
875
1050
|
...dayCellProps.style,
|
|
876
|
-
touchAction: "none"
|
|
1051
|
+
touchAction: "none",
|
|
1052
|
+
userSelect: "none"
|
|
877
1053
|
} : dayCellProps.style,
|
|
878
|
-
onPointerDown:
|
|
879
|
-
if (e.button
|
|
1054
|
+
onPointerDown: dragWired && !day.isDisabled ? (e) => {
|
|
1055
|
+
if (e.button !== 0) return;
|
|
1056
|
+
beginPress();
|
|
1057
|
+
beginCreate(day.date);
|
|
880
1058
|
} : void 0,
|
|
881
|
-
onPointerEnter:
|
|
1059
|
+
onPointerEnter: dragWired && !day.isDisabled ? () => extendDrag(day.date) : void 0,
|
|
882
1060
|
onClick: day.isDisabled ? void 0 : () => {
|
|
883
|
-
if (
|
|
884
|
-
suppressClickRef.current = false;
|
|
885
|
-
return;
|
|
886
|
-
}
|
|
1061
|
+
if (consumeSuppressedClick()) return;
|
|
887
1062
|
onPressDay?.(day.date);
|
|
1063
|
+
onPressCell?.(startOfDay(day.date));
|
|
888
1064
|
},
|
|
889
1065
|
onKeyDown: keyboardDayNavigation && !day.isDisabled ? (e) => {
|
|
890
1066
|
if (e.target !== e.currentTarget) return;
|
|
891
1067
|
if (e.key === "Enter" || e.key === " ") {
|
|
892
1068
|
e.preventDefault();
|
|
893
1069
|
onPressDay?.(day.date);
|
|
1070
|
+
onPressCell?.(startOfDay(day.date));
|
|
894
1071
|
}
|
|
895
1072
|
} : void 0,
|
|
896
1073
|
children: [
|
|
@@ -906,10 +1083,18 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
906
1083
|
}),
|
|
907
1084
|
barSegs.filter((b) => b.startCol === dayCol).map((b) => {
|
|
908
1085
|
const span = b.endCol - b.startCol + 1;
|
|
1086
|
+
const isDragged = drag?.kind === "move" && drag.event === b.seg.event;
|
|
909
1087
|
return /* @__PURE__ */ jsx("button", {
|
|
910
1088
|
type: "button",
|
|
1089
|
+
onPointerDown: canMove(b.seg.event) ? (e) => {
|
|
1090
|
+
if (e.button !== 0) return;
|
|
1091
|
+
e.stopPropagation();
|
|
1092
|
+
beginPress();
|
|
1093
|
+
beginMove(b.seg.event, day.date);
|
|
1094
|
+
} : void 0,
|
|
911
1095
|
onClick: (e) => {
|
|
912
1096
|
e.stopPropagation();
|
|
1097
|
+
if (consumeSuppressedClick()) return;
|
|
913
1098
|
onPressEvent?.(b.seg.event);
|
|
914
1099
|
},
|
|
915
1100
|
...barChipButton,
|
|
@@ -926,7 +1111,10 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
926
1111
|
width: `calc(${span * 100}% - 4px)`,
|
|
927
1112
|
top: 30 + b.seg.lane * 20,
|
|
928
1113
|
height: CHIP_HEIGHT,
|
|
929
|
-
pointerEvents:
|
|
1114
|
+
pointerEvents: isDragging ? "none" : "auto",
|
|
1115
|
+
opacity: isDragged ? DRAGGED_CHIP_OPACITY : void 0,
|
|
1116
|
+
cursor: canMove(b.seg.event) ? "grab" : void 0,
|
|
1117
|
+
touchAction: dragWired ? "none" : void 0,
|
|
930
1118
|
zIndex: 2
|
|
931
1119
|
},
|
|
932
1120
|
children: Chip ? /* @__PURE__ */ jsx(Chip, {
|
|
@@ -1063,7 +1251,10 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
1063
1251
|
"aria-label": label,
|
|
1064
1252
|
"aria-pressed": day.isSelected || day.isInRange,
|
|
1065
1253
|
...slot("day", dayCellDefault(day, theme, highlightWeekends)),
|
|
1066
|
-
onClick: day.isDisabled ? void 0 : () =>
|
|
1254
|
+
onClick: day.isDisabled ? void 0 : () => {
|
|
1255
|
+
onPressDay?.(day.date);
|
|
1256
|
+
onPressCell?.(startOfDay(day.date));
|
|
1257
|
+
},
|
|
1067
1258
|
onMouseEnter: day.isDisabled ? void 0 : () => setHoveredKey(day.id),
|
|
1068
1259
|
onMouseLeave: () => setHoveredKey((k) => k === day.id ? null : k),
|
|
1069
1260
|
children: [band ? /* @__PURE__ */ jsx("span", {
|
|
@@ -1086,6 +1277,7 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
1086
1277
|
//#endregion
|
|
1087
1278
|
//#region src/TimeGrid.tsx
|
|
1088
1279
|
const GUTTER_WIDTH$1 = 56;
|
|
1280
|
+
const HOURS_PER_DAY = 24;
|
|
1089
1281
|
const clamp$1 = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
|
|
1090
1282
|
const EDGE_ZONE = 32;
|
|
1091
1283
|
const EDGE_DWELL_MS = 600;
|
|
@@ -1191,7 +1383,8 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1191
1383
|
});
|
|
1192
1384
|
const scrollRef = useRef(null);
|
|
1193
1385
|
const dfns = locale ? { locale } : void 0;
|
|
1194
|
-
const
|
|
1386
|
+
const snapMinutes = Math.max(1, dragStepMinutes);
|
|
1387
|
+
const snapHours = snapMinutes / 60;
|
|
1195
1388
|
const windowStart = Math.max(0, Math.min(minHour, 23));
|
|
1196
1389
|
const windowEnd = Math.max(windowStart + 1, Math.min(maxHour, 24));
|
|
1197
1390
|
const windowHours = windowEnd - windowStart;
|
|
@@ -1354,15 +1547,22 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1354
1547
|
const dHours = (e.clientY - dragOrigin.current.pointerY) / hourHeightRef.current;
|
|
1355
1548
|
const snap = (v) => Math.round(v / snapHours) * snapHours;
|
|
1356
1549
|
if (d.kind === "move") {
|
|
1357
|
-
const
|
|
1550
|
+
const raw = snap(dragOrigin.current.startHours + dHours);
|
|
1551
|
+
const startHours = d.continuesBefore ? raw : clampMoveStartMinutes(raw * 60, windowStart, windowEnd, snapMinutes) / 60;
|
|
1358
1552
|
const o = dragOrigin.current;
|
|
1359
1553
|
const rawDayDelta = o.dayWidth > 0 ? Math.round((e.clientX - o.pointerX) / o.dayWidth) : 0;
|
|
1360
|
-
const
|
|
1554
|
+
const targetDay = clamp$1(o.dayIndex + rawDayDelta, 0, daysRef.current.length - 1);
|
|
1555
|
+
const dayDelta = targetDay - o.dayIndex;
|
|
1556
|
+
const spillHours = Math.min(Math.max(startHours + d.durationHours - HOURS_PER_DAY, 0), windowHours);
|
|
1557
|
+
const nextDay = daysRef.current[targetDay + 1];
|
|
1558
|
+
const spillDayIndex = spillHours > 0 && nextDay && differenceInCalendarDays(nextDay, daysRef.current[targetDay]) === 1 && !d.continuesAfter ? targetDay + 1 : -1;
|
|
1361
1559
|
applyDrag({
|
|
1362
1560
|
...d,
|
|
1363
1561
|
startHours,
|
|
1364
1562
|
dayDelta,
|
|
1365
1563
|
dayOffsetPx: dayDelta * o.dayWidth,
|
|
1564
|
+
spillHours,
|
|
1565
|
+
spillDayIndex,
|
|
1366
1566
|
moved: true
|
|
1367
1567
|
});
|
|
1368
1568
|
const g = ghostRef.current;
|
|
@@ -1411,25 +1611,31 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1411
1611
|
held?.onPress();
|
|
1412
1612
|
return;
|
|
1413
1613
|
}
|
|
1414
|
-
const
|
|
1614
|
+
const origin = dragOrigin.current;
|
|
1615
|
+
const originIndex = origin?.dayIndex ?? 0;
|
|
1415
1616
|
let base = null;
|
|
1416
1617
|
if (d.kind === "move") if (pagedRef.current) {
|
|
1417
1618
|
const day = dayAt(e.clientX, e.clientY);
|
|
1418
1619
|
base = day ? startOfDay(day) : null;
|
|
1419
1620
|
} else base = startOfDay(daysRef.current[originIndex + d.dayDelta] ?? daysRef.current[originIndex]);
|
|
1420
1621
|
else base = startOfDay(daysRef.current[originIndex] ?? daysRef.current[0]);
|
|
1421
|
-
if (base && held) {
|
|
1422
|
-
const
|
|
1423
|
-
const
|
|
1424
|
-
|
|
1622
|
+
if (base && held && origin) {
|
|
1623
|
+
const segmentStart = addMinutes(base, Math.round(d.startHours * 60));
|
|
1624
|
+
const segmentEnd = addMinutes(base, Math.round((d.startHours + d.durationHours) * 60));
|
|
1625
|
+
const startShift = d.kind === "resize" ? 0 : segmentStart.getTime() - origin.segmentStart.getTime();
|
|
1626
|
+
const endShift = d.kind === "resize-start" ? 0 : segmentEnd.getTime() - origin.segmentEnd.getTime();
|
|
1627
|
+
const start = new Date(held.event.start.getTime() + startShift);
|
|
1628
|
+
const end = new Date(held.event.end.getTime() + endShift);
|
|
1629
|
+
if (end > start) onDragEventRef.current?.(held.event, start, end);
|
|
1425
1630
|
}
|
|
1426
1631
|
finishDrag();
|
|
1427
1632
|
};
|
|
1428
1633
|
const cancelDrag = () => {
|
|
1429
1634
|
finishDrag();
|
|
1430
1635
|
};
|
|
1431
|
-
const beginDrag = (e,
|
|
1636
|
+
const beginDrag = (e, pe, key, kind, dayIndex, onPress) => {
|
|
1432
1637
|
if (!onDragEvent) return;
|
|
1638
|
+
const { event, startHours, durationHours, continuesBefore, continuesAfter } = pe;
|
|
1433
1639
|
e.stopPropagation();
|
|
1434
1640
|
try {
|
|
1435
1641
|
e.target.setPointerCapture?.(e.pointerId);
|
|
@@ -1438,13 +1644,16 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1438
1644
|
const column = kind === "move" ? boxEl.parentElement : null;
|
|
1439
1645
|
const dayWidth = column ? column.getBoundingClientRect().width : 0;
|
|
1440
1646
|
const boxRect = kind === "move" ? boxEl.getBoundingClientRect() : null;
|
|
1647
|
+
const originBase = startOfDay(days[dayIndex] ?? days[0]);
|
|
1441
1648
|
dragOrigin.current = {
|
|
1442
1649
|
pointerX: e.clientX,
|
|
1443
1650
|
pointerY: e.clientY,
|
|
1444
1651
|
startHours,
|
|
1445
1652
|
durationHours,
|
|
1446
1653
|
dayIndex,
|
|
1447
|
-
dayWidth
|
|
1654
|
+
dayWidth,
|
|
1655
|
+
segmentStart: addMinutes(originBase, Math.round(startHours * 60)),
|
|
1656
|
+
segmentEnd: addMinutes(originBase, Math.round((startHours + durationHours) * 60))
|
|
1448
1657
|
};
|
|
1449
1658
|
draggedRef.current = {
|
|
1450
1659
|
event,
|
|
@@ -1467,8 +1676,12 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1467
1676
|
kind,
|
|
1468
1677
|
startHours,
|
|
1469
1678
|
durationHours,
|
|
1679
|
+
continuesBefore,
|
|
1680
|
+
continuesAfter,
|
|
1470
1681
|
dayDelta: 0,
|
|
1471
1682
|
dayOffsetPx: 0,
|
|
1683
|
+
spillHours: 0,
|
|
1684
|
+
spillDayIndex: -1,
|
|
1472
1685
|
moved: false
|
|
1473
1686
|
});
|
|
1474
1687
|
onDragStart?.(event);
|
|
@@ -1528,10 +1741,10 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1528
1741
|
const moved = Math.abs(endPx - o.startPx) > 4;
|
|
1529
1742
|
const h = hourHeightRef.current;
|
|
1530
1743
|
if (moved && onCreateEvent) {
|
|
1531
|
-
const range = cellRangeFromDrag(day, o.startPx, endPx, h, windowStart,
|
|
1744
|
+
const range = cellRangeFromDrag(day, o.startPx, endPx, h, windowStart, snapMinutes);
|
|
1532
1745
|
if (range) onCreateEvent(range.start, range.end);
|
|
1533
1746
|
} else if (onPressCell) {
|
|
1534
|
-
const at = cellRangeFromDrag(day, o.startPx, o.startPx, h, windowStart,
|
|
1747
|
+
const at = cellRangeFromDrag(day, o.startPx, o.startPx, h, windowStart, snapMinutes);
|
|
1535
1748
|
if (at) onPressCell(at.start);
|
|
1536
1749
|
}
|
|
1537
1750
|
createOrigin.current = null;
|
|
@@ -1542,6 +1755,21 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1542
1755
|
setCreateBox(null);
|
|
1543
1756
|
};
|
|
1544
1757
|
const positionedByDay = useMemo(() => days.map((day) => layoutDayEvents$1(events, day)), [days, events]);
|
|
1758
|
+
const spillPreviewFor = (dayIndex) => {
|
|
1759
|
+
if (paged || !drag || drag.kind !== "move" || drag.spillDayIndex !== dayIndex) return null;
|
|
1760
|
+
const dragged = draggedRef.current?.event;
|
|
1761
|
+
if (!dragged) return null;
|
|
1762
|
+
return {
|
|
1763
|
+
event: dragged,
|
|
1764
|
+
mode,
|
|
1765
|
+
isAllDay: false,
|
|
1766
|
+
boxHeight: Math.max(drag.spillHours * hourHeight, 14),
|
|
1767
|
+
continuesBefore: true,
|
|
1768
|
+
continuesAfter: false,
|
|
1769
|
+
ampm,
|
|
1770
|
+
onPress: () => {}
|
|
1771
|
+
};
|
|
1772
|
+
};
|
|
1545
1773
|
const navByDay = useMemo(() => positionedByDay.map((list, day) => list.map((pe, idx) => ({
|
|
1546
1774
|
key: `${day}:${idx}`,
|
|
1547
1775
|
start: pe.startHours,
|
|
@@ -1849,6 +2077,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1849
2077
|
const nowTop = (nowHours - windowStart) * hourHeight;
|
|
1850
2078
|
const bands = bandsByDay[dayIndex];
|
|
1851
2079
|
const ghost = createBox?.dayIndex === dayIndex ? createBox : null;
|
|
2080
|
+
const spill = spillPreviewFor(dayIndex);
|
|
1852
2081
|
return /* @__PURE__ */ jsxs("div", {
|
|
1853
2082
|
"data-date": day.toISOString(),
|
|
1854
2083
|
onPointerDown: cellEnabled ? (e) => beginCreate(e, dayIndex) : void 0,
|
|
@@ -1925,7 +2154,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1925
2154
|
const durationHours = active ? active.durationHours : pe.durationHours;
|
|
1926
2155
|
if (!active && (pe.startHours >= windowEnd || pe.startHours + pe.durationHours <= windowStart)) return null;
|
|
1927
2156
|
const top = (startHours - windowStart) * hourHeight;
|
|
1928
|
-
const boxHeight = Math.max(durationHours * hourHeight, 14);
|
|
2157
|
+
const boxHeight = Math.max(Math.min(durationHours, HOURS_PER_DAY - startHours) * hourHeight, 14);
|
|
1929
2158
|
const widthPct = 100 / pe.columns;
|
|
1930
2159
|
const onPress = () => onPressEvent?.(pe.event);
|
|
1931
2160
|
const args = {
|
|
@@ -1964,7 +2193,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1964
2193
|
}
|
|
1965
2194
|
if (keyboardEventNavigation) onEventKeyDown(key, e);
|
|
1966
2195
|
},
|
|
1967
|
-
onPointerDown: canMove ? (e) => beginDrag(e, pe
|
|
2196
|
+
onPointerDown: canMove ? (e) => beginDrag(e, pe, key, "move", dayIndex, onPress) : void 0,
|
|
1968
2197
|
onClick: canMove ? void 0 : onPress,
|
|
1969
2198
|
...dataState({ "data-dragging": !!active }),
|
|
1970
2199
|
...slot("event", { base: {
|
|
@@ -1988,7 +2217,7 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
1988
2217
|
canResize && !pe.continuesBefore ? /* @__PURE__ */ jsx("div", {
|
|
1989
2218
|
onPointerDown: (e) => {
|
|
1990
2219
|
e.stopPropagation();
|
|
1991
|
-
beginDrag(e, pe
|
|
2220
|
+
beginDrag(e, pe, key, "resize-start", dayIndex);
|
|
1992
2221
|
},
|
|
1993
2222
|
style: {
|
|
1994
2223
|
position: "absolute",
|
|
@@ -2000,10 +2229,10 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
2000
2229
|
touchAction: "none"
|
|
2001
2230
|
}
|
|
2002
2231
|
}) : null,
|
|
2003
|
-
canResize ? /* @__PURE__ */ jsx("div", {
|
|
2232
|
+
canResize && !pe.continuesAfter ? /* @__PURE__ */ jsx("div", {
|
|
2004
2233
|
onPointerDown: (e) => {
|
|
2005
2234
|
e.stopPropagation();
|
|
2006
|
-
beginDrag(e, pe
|
|
2235
|
+
beginDrag(e, pe, key, "resize", dayIndex);
|
|
2007
2236
|
},
|
|
2008
2237
|
style: {
|
|
2009
2238
|
position: "absolute",
|
|
@@ -2018,6 +2247,25 @@ function TimeGrid({ date, events = [], mode = "day", numberOfDays = 1, weekStart
|
|
|
2018
2247
|
]
|
|
2019
2248
|
}, idx);
|
|
2020
2249
|
}),
|
|
2250
|
+
spill ? /* @__PURE__ */ jsx("div", {
|
|
2251
|
+
"aria-hidden": true,
|
|
2252
|
+
...dataState({ "data-dragging": true }),
|
|
2253
|
+
...slot("event", { base: {
|
|
2254
|
+
position: "absolute",
|
|
2255
|
+
top: -windowStart * hourHeight,
|
|
2256
|
+
left: 1,
|
|
2257
|
+
right: 1,
|
|
2258
|
+
height: spill.boxHeight,
|
|
2259
|
+
pointerEvents: "none",
|
|
2260
|
+
zIndex: 3,
|
|
2261
|
+
opacity: .85
|
|
2262
|
+
} }),
|
|
2263
|
+
children: Renderer ? /* @__PURE__ */ jsx(Renderer, { ...spill }) : /* @__PURE__ */ jsx(DefaultDomEvent, {
|
|
2264
|
+
...spill,
|
|
2265
|
+
theme,
|
|
2266
|
+
boxProps: slot("eventBox")
|
|
2267
|
+
})
|
|
2268
|
+
}) : null,
|
|
2021
2269
|
showNow ? /* @__PURE__ */ jsxs("div", {
|
|
2022
2270
|
...slot("nowIndicator", { base: {
|
|
2023
2271
|
position: "absolute",
|
|
@@ -2128,7 +2376,7 @@ function pageStep(mode, date, direction, weekStartsOn, numberOfDays) {
|
|
|
2128
2376
|
* <Calendar mode="week" date={new Date()} events={events} />
|
|
2129
2377
|
* ```
|
|
2130
2378
|
*/
|
|
2131
|
-
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, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onPressMonth, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }) {
|
|
2379
|
+
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 }) {
|
|
2132
2380
|
const displayEvents = useMemo(() => {
|
|
2133
2381
|
let out = events ?? EMPTY_EVENTS;
|
|
2134
2382
|
if (out.some((e) => e.recurrence)) {
|
|
@@ -2171,8 +2419,15 @@ function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0,
|
|
|
2171
2419
|
} : style,
|
|
2172
2420
|
classNames,
|
|
2173
2421
|
styles,
|
|
2422
|
+
selectedRange,
|
|
2423
|
+
selectedDates,
|
|
2424
|
+
minDate,
|
|
2425
|
+
maxDate,
|
|
2426
|
+
isDateDisabled,
|
|
2174
2427
|
onPressDay,
|
|
2175
|
-
onPressMonth
|
|
2428
|
+
onPressMonth,
|
|
2429
|
+
onSelectDrag,
|
|
2430
|
+
onCreateEvent
|
|
2176
2431
|
});
|
|
2177
2432
|
else if (mode === "schedule") view = /* @__PURE__ */ jsx(Agenda, {
|
|
2178
2433
|
events: displayEvents,
|
|
@@ -2206,6 +2461,7 @@ function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0,
|
|
|
2206
2461
|
maxVisibleEventCount,
|
|
2207
2462
|
moreLabel,
|
|
2208
2463
|
showAdjacentMonths,
|
|
2464
|
+
showTitle,
|
|
2209
2465
|
fillCellOnSelection,
|
|
2210
2466
|
selectedRange,
|
|
2211
2467
|
selectedDates,
|
|
@@ -2214,7 +2470,13 @@ function Calendar({ mode = "week", date, events, onChangeDate, weekStartsOn = 0,
|
|
|
2214
2470
|
isDateDisabled,
|
|
2215
2471
|
keyboardDayNavigation,
|
|
2216
2472
|
onPressDay,
|
|
2473
|
+
onPressCell,
|
|
2217
2474
|
onCreateEvent,
|
|
2475
|
+
onSelectDrag,
|
|
2476
|
+
onDragEvent,
|
|
2477
|
+
onDragStart,
|
|
2478
|
+
eventStartEditable,
|
|
2479
|
+
eventOverlap,
|
|
2218
2480
|
onPressEvent,
|
|
2219
2481
|
onPressMore,
|
|
2220
2482
|
renderEvent: renderMonthEvent,
|