@super-calendar/dom 2.18.0 → 2.19.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.js +42 -11
- package/dist/index.mjs +43 -12
- package/package.json +2 -2
- package/src/Agenda.tsx +2 -1
- package/src/Calendar.tsx +2 -1
- package/src/MonthList.tsx +1 -1
- package/src/MonthView.tsx +77 -29
- package/src/ResourceTimeline.tsx +11 -7
- package/src/YearView.tsx +9 -4
package/dist/index.js
CHANGED
|
@@ -645,6 +645,7 @@ function InertDiv(props) {
|
|
|
645
645
|
});
|
|
646
646
|
}
|
|
647
647
|
// src/MonthView.tsx
|
|
648
|
+
const pressedEvent = (event) => event.target instanceof Element && event.target.closest("[data-slot=\"chipButton\"]") !== null;
|
|
648
649
|
const EMPTY_LAYOUT = {
|
|
649
650
|
segments: [],
|
|
650
651
|
laneCount: 0
|
|
@@ -1051,6 +1052,33 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1051
1052
|
createStart,
|
|
1052
1053
|
createEnd
|
|
1053
1054
|
]);
|
|
1055
|
+
const visibleLanesFor = (0, react.useCallback)((laneCount) => laneCount > maxVisibleEventCount ? Math.max(maxVisibleEventCount - 1, 1) : laneCount, [maxVisibleEventCount]);
|
|
1056
|
+
const draftEvent = (0, react.useMemo)(() => createRange ? {
|
|
1057
|
+
title: "",
|
|
1058
|
+
start: createRange.start,
|
|
1059
|
+
end: createRange.end,
|
|
1060
|
+
allDay: true
|
|
1061
|
+
} : null, [createRange]);
|
|
1062
|
+
const rowLayouts = (0, react.useMemo)(() => {
|
|
1063
|
+
if (!draftEvent) return weekLayouts;
|
|
1064
|
+
const days = (0, _super_calendar_core.withDraftEventDays)(eventsByDay, draftEvent);
|
|
1065
|
+
return weeks.map((week, index) => {
|
|
1066
|
+
const base = weekLayouts[index] ?? EMPTY_LAYOUT;
|
|
1067
|
+
if (!week.days.some((d) => d.date >= draftEvent.start && d.date < draftEvent.end)) return base;
|
|
1068
|
+
const placed = (0, _super_calendar_core.layoutMonthWeek)(week.days.map((d) => d.date), collectRowEvents(week, days));
|
|
1069
|
+
return (0, _super_calendar_core.keepMonthDraftVisible)(placed, base, draftEvent, {
|
|
1070
|
+
visibleLanes: visibleLanesFor,
|
|
1071
|
+
extraLaneFits: (visibleLanes) => visibleLanes < maxVisibleEventCount
|
|
1072
|
+
});
|
|
1073
|
+
});
|
|
1074
|
+
}, [
|
|
1075
|
+
draftEvent,
|
|
1076
|
+
weekLayouts,
|
|
1077
|
+
eventsByDay,
|
|
1078
|
+
weeks,
|
|
1079
|
+
visibleLanesFor,
|
|
1080
|
+
maxVisibleEventCount
|
|
1081
|
+
]);
|
|
1054
1082
|
const movedRef = (0, react.useRef)(false);
|
|
1055
1083
|
const suppressClickRef = (0, react.useRef)(false);
|
|
1056
1084
|
const consumeSuppressedClick = (detail) => {
|
|
@@ -1132,6 +1160,7 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1132
1160
|
const pressRow = (event, day, moving) => {
|
|
1133
1161
|
if (event.button !== 0 || event.isPrimary === false || heldTouch.current) return;
|
|
1134
1162
|
beginPress();
|
|
1163
|
+
if (!moving && pressedEvent(event.nativeEvent)) return;
|
|
1135
1164
|
pressOrigin.current = {
|
|
1136
1165
|
x: event.clientX,
|
|
1137
1166
|
y: event.clientY,
|
|
@@ -1361,9 +1390,10 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1361
1390
|
overflowY: "auto"
|
|
1362
1391
|
} } : void 0),
|
|
1363
1392
|
children: weeks.map((week, weekIndex) => {
|
|
1364
|
-
const rowLayout =
|
|
1365
|
-
const visibleLanes = rowLayout.laneCount
|
|
1393
|
+
const rowLayout = rowLayouts[weekIndex] ?? EMPTY_LAYOUT;
|
|
1394
|
+
const visibleLanes = visibleLanesFor(rowLayout.laneCount);
|
|
1366
1395
|
const cols = week.days.length;
|
|
1396
|
+
const extraLane = visibleLanes < maxVisibleEventCount ? (0, _super_calendar_core.monthExtraLaneColumns)(rowLayout, visibleLanes, cols) : week.days.map(() => false);
|
|
1367
1397
|
let firstVisCol = 0;
|
|
1368
1398
|
let lastVisCol = cols - 1;
|
|
1369
1399
|
if (eventsMode && !showAdjacentMonths) {
|
|
@@ -1374,7 +1404,7 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1374
1404
|
lastVisCol = cols - 1 - lastFromEnd;
|
|
1375
1405
|
}
|
|
1376
1406
|
}
|
|
1377
|
-
const barSegs = rowLayout.
|
|
1407
|
+
const barSegs = (0, _super_calendar_core.monthVisibleBars)(rowLayout, visibleLanes, extraLane).filter((s) => s.event !== draftEvent).map((s) => {
|
|
1378
1408
|
const startCol = Math.max(s.startCol, firstVisCol);
|
|
1379
1409
|
const endCol = Math.min(s.endCol, lastVisCol);
|
|
1380
1410
|
return {
|
|
@@ -1385,10 +1415,10 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1385
1415
|
continuesAfter: s.continuesAfter || endCol < s.endCol
|
|
1386
1416
|
};
|
|
1387
1417
|
}).filter((b) => b.startCol <= b.endCol);
|
|
1388
|
-
const
|
|
1389
|
-
const draftStart =
|
|
1390
|
-
const draftEnd =
|
|
1391
|
-
const draftTop = 28 + chipGap +
|
|
1418
|
+
const draftSegment = rowLayout.segments.find((s) => s.event === draftEvent);
|
|
1419
|
+
const draftStart = draftSegment ? Math.max(draftSegment.startCol, firstVisCol) : -1;
|
|
1420
|
+
const draftEnd = draftSegment ? Math.min(draftSegment.endCol, lastVisCol) : -1;
|
|
1421
|
+
const draftTop = 28 + chipGap + (draftSegment?.lane ?? 0) * (chipHeight + chipGap);
|
|
1392
1422
|
const draftHeight = Math.min(chipHeight, Math.max(0, eventRowHeight - draftTop));
|
|
1393
1423
|
const barChipButton = slot("chipButton", chipButtonDefault);
|
|
1394
1424
|
const barChip = slot("chip", chipDefault(theme, chipHeight));
|
|
@@ -1399,6 +1429,7 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1399
1429
|
gridTemplateColumns: `repeat(${week.days.length}, minmax(0, 1fr))`
|
|
1400
1430
|
} }),
|
|
1401
1431
|
children: week.days.map((day, dayCol) => {
|
|
1432
|
+
const dayLanes = visibleLanes + (extraLane[dayCol] ? 1 : 0);
|
|
1402
1433
|
const hidden = !showAdjacentMonths && isOutsidePeriod(day);
|
|
1403
1434
|
const cellHeight = eventsMode ? eventRowHeight : theme.cellHeight;
|
|
1404
1435
|
if (hidden) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -1428,7 +1459,7 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1428
1459
|
});
|
|
1429
1460
|
if (eventsMode) {
|
|
1430
1461
|
const dayEvents = eventsByDay.get((0, date_fns.startOfDay)(day.date).toISOString()) ?? [];
|
|
1431
|
-
const hiddenEvents = rowLayout.segments.filter((s) => s.startCol <= dayCol && s.endCol >= dayCol && s.lane >=
|
|
1462
|
+
const hiddenEvents = rowLayout.segments.filter((s) => s.startCol <= dayCol && s.endCol >= dayCol && s.lane >= dayLanes && s.event !== draftEvent).map((s) => s.event);
|
|
1432
1463
|
const dayLabel = (0, date_fns.format)(day.date, "d MMMM", locale ? { locale } : void 0);
|
|
1433
1464
|
const dayCellProps = slot("day", eventCellDefault(day, theme, cellHeight, highlightWeekends, inCreate || isDropTarget, chipGap));
|
|
1434
1465
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -1535,9 +1566,9 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1535
1566
|
},
|
|
1536
1567
|
children: b.seg.event.title
|
|
1537
1568
|
})
|
|
1538
|
-
}, `bar-${b.seg.event.start.toISOString()}:${b.seg.event.title}:${b.seg.lane}`);
|
|
1569
|
+
}, `bar-${b.seg.event.start.toISOString()}:${b.seg.event.title}:${b.seg.lane}:${b.startCol}`);
|
|
1539
1570
|
}),
|
|
1540
|
-
RenderCreateGhost && createRange && draftStart === dayCol && draftEnd
|
|
1571
|
+
RenderCreateGhost && createRange && draftStart === dayCol && draftEnd >= draftStart && draftHeight > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InertDiv, {
|
|
1541
1572
|
...slot("createGhost", {
|
|
1542
1573
|
base: {
|
|
1543
1574
|
position: "absolute",
|
|
@@ -1572,7 +1603,7 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1572
1603
|
gap: chipGap
|
|
1573
1604
|
} }),
|
|
1574
1605
|
children: [
|
|
1575
|
-
Array.from({ length:
|
|
1606
|
+
Array.from({ length: dayLanes }, (_, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1576
1607
|
"aria-hidden": true,
|
|
1577
1608
|
style: { height: chipHeight }
|
|
1578
1609
|
}, `lane-${i}`)),
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LegendList } from "@legendapp/list/react";
|
|
2
2
|
import { addDays, addMonths, addWeeks, addYears, differenceInCalendarDays, endOfDay, endOfMonth, endOfWeek, endOfYear, format, getISOWeek, isSameDay, isSameMonth, startOfDay, startOfMonth, startOfWeek, startOfYear } from "date-fns";
|
|
3
3
|
import { createElement, forwardRef, useCallback, useEffect, useId, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
4
|
-
import { backgroundBandsForDay, backgroundBandsForDay as backgroundBandsForDay$1, bandRounding, buildMonthGrid, buildMonthGrid as buildMonthGrid$1, buildMonthWeeks, buildMultiWeekGrid, buildMultiWeekGrid as buildMultiWeekGrid$1, cellRangeFromDrag, clampMoveStartMinutes, closedHourBands, compareDayEvents, darkColors, dayAccessibilityLabel, dayBadgeKind, daySelectionState, daySelectionState as daySelectionState$1, defaultCalendarLabels, eventAccessibilityLabel, eventChipLayout, eventTimeLabel, eventsInTimeZone, expandRecurringEvents, expandRecurringEvents as expandRecurringEvents$1, filterHiddenDays, formatHour, fromZonedRange, fromZonedTime, 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, movedClockSpan, nextDateRange, nextDateRange as nextDateRange$1, nowInTimeZone, overlapsOtherEvents, pageStepDays, parseICalendar, rangeBandKind, resolveCalendarLabels, resolveDraggedBounds, shiftMinutes, titleNumberOfLines, toICalendar, useDateRange, useEventSource, useMonthGrid, useNow, useNow as useNow$1, weekdayFormatToken, weekdayFormatToken as weekdayFormatToken$1, zonedDragBounds, zonedEventSource } from "@super-calendar/core";
|
|
4
|
+
import { backgroundBandsForDay, backgroundBandsForDay as backgroundBandsForDay$1, bandRounding, buildMonthGrid, buildMonthGrid as buildMonthGrid$1, buildMonthWeeks, buildMultiWeekGrid, buildMultiWeekGrid as buildMultiWeekGrid$1, cellRangeFromDrag, clampMoveStartMinutes, closedHourBands, compareDayEvents, darkColors, dayAccessibilityLabel, dayBadgeKind, daySelectionState, daySelectionState as daySelectionState$1, defaultCalendarLabels, eventAccessibilityLabel, eventChipLayout, eventTimeLabel, eventsInTimeZone, expandRecurringEvents, expandRecurringEvents as expandRecurringEvents$1, filterHiddenDays, formatHour, fromZonedRange, fromZonedTime, getIsToday, getViewDays, getViewDays as getViewDays$1, getWeekDays, getYearMonths, groupEventsByDay, isAllDayEvent, isAllDayEvent as isAllDayEvent$1, isBackgroundEvent, isBackgroundEvent as isBackgroundEvent$1, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, keepMonthDraftVisible, layoutDayEvents, layoutDayEvents as layoutDayEvents$1, layoutMonthWeek, layoutMonthWeek as layoutMonthWeek$1, lightColors, monthCreateRange, monthDropBounds, monthExtraLaneColumns, monthVisibleBars, movedClockSpan, nextDateRange, nextDateRange as nextDateRange$1, nowInTimeZone, overlapsOtherEvents, pageStepDays, parseICalendar, rangeBandKind, resolveCalendarLabels, resolveDraggedBounds, shiftMinutes, titleNumberOfLines, toICalendar, useDateRange, useEventSource, useMonthGrid, useNow, useNow as useNow$1, weekdayFormatToken, weekdayFormatToken as weekdayFormatToken$1, withDraftEventDays, zonedDragBounds, zonedEventSource } from "@super-calendar/core";
|
|
5
5
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
// src/slots.ts
|
|
7
7
|
/** Join truthy class names (a dependency-free clsx-lite). */
|
|
@@ -644,6 +644,7 @@ function InertDiv(props) {
|
|
|
644
644
|
});
|
|
645
645
|
}
|
|
646
646
|
// src/MonthView.tsx
|
|
647
|
+
const pressedEvent = (event) => event.target instanceof Element && event.target.closest("[data-slot=\"chipButton\"]") !== null;
|
|
647
648
|
const EMPTY_LAYOUT = {
|
|
648
649
|
segments: [],
|
|
649
650
|
laneCount: 0
|
|
@@ -1050,6 +1051,33 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1050
1051
|
createStart,
|
|
1051
1052
|
createEnd
|
|
1052
1053
|
]);
|
|
1054
|
+
const visibleLanesFor = useCallback((laneCount) => laneCount > maxVisibleEventCount ? Math.max(maxVisibleEventCount - 1, 1) : laneCount, [maxVisibleEventCount]);
|
|
1055
|
+
const draftEvent = useMemo(() => createRange ? {
|
|
1056
|
+
title: "",
|
|
1057
|
+
start: createRange.start,
|
|
1058
|
+
end: createRange.end,
|
|
1059
|
+
allDay: true
|
|
1060
|
+
} : null, [createRange]);
|
|
1061
|
+
const rowLayouts = useMemo(() => {
|
|
1062
|
+
if (!draftEvent) return weekLayouts;
|
|
1063
|
+
const days = withDraftEventDays(eventsByDay, draftEvent);
|
|
1064
|
+
return weeks.map((week, index) => {
|
|
1065
|
+
const base = weekLayouts[index] ?? EMPTY_LAYOUT;
|
|
1066
|
+
if (!week.days.some((d) => d.date >= draftEvent.start && d.date < draftEvent.end)) return base;
|
|
1067
|
+
const placed = layoutMonthWeek$1(week.days.map((d) => d.date), collectRowEvents(week, days));
|
|
1068
|
+
return keepMonthDraftVisible(placed, base, draftEvent, {
|
|
1069
|
+
visibleLanes: visibleLanesFor,
|
|
1070
|
+
extraLaneFits: (visibleLanes) => visibleLanes < maxVisibleEventCount
|
|
1071
|
+
});
|
|
1072
|
+
});
|
|
1073
|
+
}, [
|
|
1074
|
+
draftEvent,
|
|
1075
|
+
weekLayouts,
|
|
1076
|
+
eventsByDay,
|
|
1077
|
+
weeks,
|
|
1078
|
+
visibleLanesFor,
|
|
1079
|
+
maxVisibleEventCount
|
|
1080
|
+
]);
|
|
1053
1081
|
const movedRef = useRef(false);
|
|
1054
1082
|
const suppressClickRef = useRef(false);
|
|
1055
1083
|
const consumeSuppressedClick = (detail) => {
|
|
@@ -1131,6 +1159,7 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1131
1159
|
const pressRow = (event, day, moving) => {
|
|
1132
1160
|
if (event.button !== 0 || event.isPrimary === false || heldTouch.current) return;
|
|
1133
1161
|
beginPress();
|
|
1162
|
+
if (!moving && pressedEvent(event.nativeEvent)) return;
|
|
1134
1163
|
pressOrigin.current = {
|
|
1135
1164
|
x: event.clientX,
|
|
1136
1165
|
y: event.clientY,
|
|
@@ -1360,9 +1389,10 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1360
1389
|
overflowY: "auto"
|
|
1361
1390
|
} } : void 0),
|
|
1362
1391
|
children: weeks.map((week, weekIndex) => {
|
|
1363
|
-
const rowLayout =
|
|
1364
|
-
const visibleLanes = rowLayout.laneCount
|
|
1392
|
+
const rowLayout = rowLayouts[weekIndex] ?? EMPTY_LAYOUT;
|
|
1393
|
+
const visibleLanes = visibleLanesFor(rowLayout.laneCount);
|
|
1365
1394
|
const cols = week.days.length;
|
|
1395
|
+
const extraLane = visibleLanes < maxVisibleEventCount ? monthExtraLaneColumns(rowLayout, visibleLanes, cols) : week.days.map(() => false);
|
|
1366
1396
|
let firstVisCol = 0;
|
|
1367
1397
|
let lastVisCol = cols - 1;
|
|
1368
1398
|
if (eventsMode && !showAdjacentMonths) {
|
|
@@ -1373,7 +1403,7 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1373
1403
|
lastVisCol = cols - 1 - lastFromEnd;
|
|
1374
1404
|
}
|
|
1375
1405
|
}
|
|
1376
|
-
const barSegs = rowLayout.
|
|
1406
|
+
const barSegs = monthVisibleBars(rowLayout, visibleLanes, extraLane).filter((s) => s.event !== draftEvent).map((s) => {
|
|
1377
1407
|
const startCol = Math.max(s.startCol, firstVisCol);
|
|
1378
1408
|
const endCol = Math.min(s.endCol, lastVisCol);
|
|
1379
1409
|
return {
|
|
@@ -1384,10 +1414,10 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1384
1414
|
continuesAfter: s.continuesAfter || endCol < s.endCol
|
|
1385
1415
|
};
|
|
1386
1416
|
}).filter((b) => b.startCol <= b.endCol);
|
|
1387
|
-
const
|
|
1388
|
-
const draftStart =
|
|
1389
|
-
const draftEnd =
|
|
1390
|
-
const draftTop = 28 + chipGap +
|
|
1417
|
+
const draftSegment = rowLayout.segments.find((s) => s.event === draftEvent);
|
|
1418
|
+
const draftStart = draftSegment ? Math.max(draftSegment.startCol, firstVisCol) : -1;
|
|
1419
|
+
const draftEnd = draftSegment ? Math.min(draftSegment.endCol, lastVisCol) : -1;
|
|
1420
|
+
const draftTop = 28 + chipGap + (draftSegment?.lane ?? 0) * (chipHeight + chipGap);
|
|
1391
1421
|
const draftHeight = Math.min(chipHeight, Math.max(0, eventRowHeight - draftTop));
|
|
1392
1422
|
const barChipButton = slot("chipButton", chipButtonDefault);
|
|
1393
1423
|
const barChip = slot("chip", chipDefault(theme, chipHeight));
|
|
@@ -1398,6 +1428,7 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1398
1428
|
gridTemplateColumns: `repeat(${week.days.length}, minmax(0, 1fr))`
|
|
1399
1429
|
} }),
|
|
1400
1430
|
children: week.days.map((day, dayCol) => {
|
|
1431
|
+
const dayLanes = visibleLanes + (extraLane[dayCol] ? 1 : 0);
|
|
1401
1432
|
const hidden = !showAdjacentMonths && isOutsidePeriod(day);
|
|
1402
1433
|
const cellHeight = eventsMode ? eventRowHeight : theme.cellHeight;
|
|
1403
1434
|
if (hidden) return /* @__PURE__ */ jsx("div", {
|
|
@@ -1427,7 +1458,7 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1427
1458
|
});
|
|
1428
1459
|
if (eventsMode) {
|
|
1429
1460
|
const dayEvents = eventsByDay.get(startOfDay(day.date).toISOString()) ?? [];
|
|
1430
|
-
const hiddenEvents = rowLayout.segments.filter((s) => s.startCol <= dayCol && s.endCol >= dayCol && s.lane >=
|
|
1461
|
+
const hiddenEvents = rowLayout.segments.filter((s) => s.startCol <= dayCol && s.endCol >= dayCol && s.lane >= dayLanes && s.event !== draftEvent).map((s) => s.event);
|
|
1431
1462
|
const dayLabel = format(day.date, "d MMMM", locale ? { locale } : void 0);
|
|
1432
1463
|
const dayCellProps = slot("day", eventCellDefault(day, theme, cellHeight, highlightWeekends, inCreate || isDropTarget, chipGap));
|
|
1433
1464
|
return /* @__PURE__ */ jsxs("div", {
|
|
@@ -1534,9 +1565,9 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1534
1565
|
},
|
|
1535
1566
|
children: b.seg.event.title
|
|
1536
1567
|
})
|
|
1537
|
-
}, `bar-${b.seg.event.start.toISOString()}:${b.seg.event.title}:${b.seg.lane}`);
|
|
1568
|
+
}, `bar-${b.seg.event.start.toISOString()}:${b.seg.event.title}:${b.seg.lane}:${b.startCol}`);
|
|
1538
1569
|
}),
|
|
1539
|
-
RenderCreateGhost && createRange && draftStart === dayCol && draftEnd
|
|
1570
|
+
RenderCreateGhost && createRange && draftStart === dayCol && draftEnd >= draftStart && draftHeight > 0 ? /* @__PURE__ */ jsx(InertDiv, {
|
|
1540
1571
|
...slot("createGhost", {
|
|
1541
1572
|
base: {
|
|
1542
1573
|
position: "absolute",
|
|
@@ -1571,7 +1602,7 @@ function DateRows({ source, weekStartsOn = 0, hiddenDays, weekdayFormat = "short
|
|
|
1571
1602
|
gap: chipGap
|
|
1572
1603
|
} }),
|
|
1573
1604
|
children: [
|
|
1574
|
-
Array.from({ length:
|
|
1605
|
+
Array.from({ length: dayLanes }, (_, i) => /* @__PURE__ */ jsx("div", {
|
|
1575
1606
|
"aria-hidden": true,
|
|
1576
1607
|
style: { height: chipHeight }
|
|
1577
1608
|
}, `lane-${i}`)),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@super-calendar/dom",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.19.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.19.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@legendapp/list": ">=3",
|
package/src/Agenda.tsx
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
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
|
-
import type { CalendarEvent, EventAccessibilityLabeler } from "@super-calendar/core";
|
|
5
4
|
import {
|
|
5
|
+
type CalendarEvent,
|
|
6
|
+
type EventAccessibilityLabeler,
|
|
6
7
|
eventTimeLabel,
|
|
7
8
|
getIsToday,
|
|
8
9
|
isAllDayEvent,
|
package/src/Calendar.tsx
CHANGED
|
@@ -45,8 +45,9 @@ import {
|
|
|
45
45
|
getViewDays,
|
|
46
46
|
type WeekdayFormat,
|
|
47
47
|
type WeekStartsOn,
|
|
48
|
+
type CalendarHandle,
|
|
49
|
+
type CalendarLabels,
|
|
48
50
|
} from "@super-calendar/core";
|
|
49
|
-
import type { CalendarHandle, CalendarLabels } from "@super-calendar/core";
|
|
50
51
|
import { Agenda, type AgendaSlot, type DomAgendaEvent } from "./Agenda";
|
|
51
52
|
import { YearView, type YearViewSlot } from "./YearView";
|
|
52
53
|
import { type DomMonthEvent, MonthView, type MonthViewSlot } from "./MonthView";
|
package/src/MonthList.tsx
CHANGED
|
@@ -12,8 +12,8 @@ import {
|
|
|
12
12
|
isBackgroundEvent,
|
|
13
13
|
type WeekdayFormat,
|
|
14
14
|
type WeekStartsOn,
|
|
15
|
+
type CalendarLabels,
|
|
15
16
|
} from "@super-calendar/core";
|
|
16
|
-
import type { CalendarLabels } from "@super-calendar/core";
|
|
17
17
|
import { type DomMonthEvent, MonthView, type MonthViewSlot } from "./MonthView";
|
|
18
18
|
import { createSlots, type SlotStyleProps } from "./slots";
|
|
19
19
|
import { type DomCalendarTheme, mergeDomTheme } from "./theme";
|
package/src/MonthView.tsx
CHANGED
|
@@ -34,17 +34,19 @@ import {
|
|
|
34
34
|
groupEventsByDay,
|
|
35
35
|
isBackgroundEvent,
|
|
36
36
|
isAllDayEvent,
|
|
37
|
+
keepMonthDraftVisible,
|
|
37
38
|
layoutMonthWeek,
|
|
38
39
|
monthCreateRange,
|
|
39
40
|
monthDropBounds,
|
|
41
|
+
monthExtraLaneColumns,
|
|
40
42
|
type MonthGridWeekday,
|
|
43
|
+
monthVisibleBars,
|
|
44
|
+
withDraftEventDays,
|
|
41
45
|
type MultiWeekGridDay,
|
|
42
46
|
overlapsOtherEvents,
|
|
43
47
|
rangeBandKind,
|
|
44
48
|
type WeekdayFormat,
|
|
45
49
|
type WeekStartsOn,
|
|
46
|
-
} from "@super-calendar/core";
|
|
47
|
-
import {
|
|
48
50
|
type CalendarLabels,
|
|
49
51
|
dayAccessibilityLabel,
|
|
50
52
|
resolveCalendarLabels,
|
|
@@ -75,6 +77,9 @@ export type MonthViewSlot =
|
|
|
75
77
|
| "morePopover";
|
|
76
78
|
|
|
77
79
|
// Stable empty layout for rows with no events (avoids a fresh object per render).
|
|
80
|
+
// Whether a pointer press began on an event chip inside a day cell.
|
|
81
|
+
const pressedEvent = (event: Event) =>
|
|
82
|
+
event.target instanceof Element && event.target.closest('[data-slot="chipButton"]') !== null;
|
|
78
83
|
const EMPTY_LAYOUT = { segments: [], laneCount: 0 } as const;
|
|
79
84
|
|
|
80
85
|
// Chip metrics for the events layout (when `events` is provided).
|
|
@@ -883,6 +888,45 @@ export function DateRows<T = unknown>({
|
|
|
883
888
|
: null,
|
|
884
889
|
[createContentEnabled, createStart, createEnd],
|
|
885
890
|
);
|
|
891
|
+
// Lanes a week row shows: all of them, or one fewer than the cap plus "+more".
|
|
892
|
+
const visibleLanesFor = useCallback(
|
|
893
|
+
(laneCount: number) =>
|
|
894
|
+
laneCount > maxVisibleEventCount ? Math.max(maxVisibleEventCount - 1, 1) : laneCount,
|
|
895
|
+
[maxVisibleEventCount],
|
|
896
|
+
);
|
|
897
|
+
// While a create sweep draws its content, lay the rows it covers out with the
|
|
898
|
+
// draft as an all-day event, so it takes the lane the created event will land on
|
|
899
|
+
// and the other bars move aside the same way.
|
|
900
|
+
const draftEvent = useMemo(
|
|
901
|
+
() =>
|
|
902
|
+
createRange
|
|
903
|
+
? ({
|
|
904
|
+
title: "",
|
|
905
|
+
start: createRange.start,
|
|
906
|
+
end: createRange.end,
|
|
907
|
+
allDay: true,
|
|
908
|
+
} as CalendarEvent<T>)
|
|
909
|
+
: null,
|
|
910
|
+
[createRange],
|
|
911
|
+
);
|
|
912
|
+
const rowLayouts = useMemo(() => {
|
|
913
|
+
if (!draftEvent) return weekLayouts;
|
|
914
|
+
const days = withDraftEventDays(eventsByDay, draftEvent);
|
|
915
|
+
return weeks.map((week, index) => {
|
|
916
|
+
const base = weekLayouts[index] ?? EMPTY_LAYOUT;
|
|
917
|
+
if (!week.days.some((d) => d.date >= draftEvent.start && d.date < draftEvent.end)) {
|
|
918
|
+
return base;
|
|
919
|
+
}
|
|
920
|
+
const placed = layoutMonthWeek(
|
|
921
|
+
week.days.map((d) => d.date),
|
|
922
|
+
collectRowEvents(week, days),
|
|
923
|
+
);
|
|
924
|
+
return keepMonthDraftVisible(placed, base, draftEvent, {
|
|
925
|
+
visibleLanes: visibleLanesFor,
|
|
926
|
+
extraLaneFits: (visibleLanes) => visibleLanes < maxVisibleEventCount,
|
|
927
|
+
});
|
|
928
|
+
});
|
|
929
|
+
}, [draftEvent, weekLayouts, eventsByDay, weeks, visibleLanesFor, maxVisibleEventCount]);
|
|
886
930
|
const movedRef = useRef(false);
|
|
887
931
|
// Set when a drag commits, so the click the browser fires next is swallowed (it
|
|
888
932
|
// must not also open the day, or the event the drag landed on). A drag that ends
|
|
@@ -955,6 +999,10 @@ export function DateRows<T = unknown>({
|
|
|
955
999
|
) => {
|
|
956
1000
|
if (event.button !== 0 || event.isPrimary === false || heldTouch.current) return;
|
|
957
1001
|
beginPress();
|
|
1002
|
+
// A press on an event that can't move starts a fresh interaction but no
|
|
1003
|
+
// sweep: a sweep starts from a day, and its preview would move the row
|
|
1004
|
+
// under the click.
|
|
1005
|
+
if (!moving && pressedEvent(event.nativeEvent)) return;
|
|
958
1006
|
pressOrigin.current = {
|
|
959
1007
|
x: event.clientX,
|
|
960
1008
|
y: event.clientY,
|
|
@@ -1222,16 +1270,19 @@ export function DateRows<T = unknown>({
|
|
|
1222
1270
|
// inside its start-column cell (valid grid content that reads with that day)
|
|
1223
1271
|
// and overflows right across the days it spans. The cells reserve the lane
|
|
1224
1272
|
// rows so "+more" sits below the bars.
|
|
1225
|
-
const rowLayout =
|
|
1273
|
+
const rowLayout = rowLayouts[weekIndex] ?? EMPTY_LAYOUT;
|
|
1226
1274
|
// When lanes overflow, keep the last row for "+more" but always show at
|
|
1227
1275
|
// least one bar, so a day never collapses to only the overflow row.
|
|
1228
|
-
const
|
|
1229
|
-
const
|
|
1230
|
-
|
|
1231
|
-
|
|
1276
|
+
const visibleLanes = visibleLanesFor(rowLayout.laneCount);
|
|
1277
|
+
const cols = week.days.length;
|
|
1278
|
+
// A day whose only hidden event sits on the "+more" row's lane draws that
|
|
1279
|
+
// event there instead of "+1 more".
|
|
1280
|
+
const extraLane =
|
|
1281
|
+
visibleLanes < maxVisibleEventCount
|
|
1282
|
+
? monthExtraLaneColumns(rowLayout, visibleLanes, cols)
|
|
1283
|
+
: week.days.map(() => false);
|
|
1232
1284
|
// With adjacent months hidden, clamp bars to the current-month columns so
|
|
1233
1285
|
// none draw over the blank leading/trailing cells.
|
|
1234
|
-
const cols = week.days.length;
|
|
1235
1286
|
let firstVisCol = 0;
|
|
1236
1287
|
let lastVisCol = cols - 1;
|
|
1237
1288
|
if (eventsMode && !showAdjacentMonths) {
|
|
@@ -1242,8 +1293,8 @@ export function DateRows<T = unknown>({
|
|
|
1242
1293
|
lastVisCol = cols - 1 - lastFromEnd;
|
|
1243
1294
|
}
|
|
1244
1295
|
}
|
|
1245
|
-
const barSegs = rowLayout
|
|
1246
|
-
.filter((s) => s.
|
|
1296
|
+
const barSegs = monthVisibleBars(rowLayout, visibleLanes, extraLane)
|
|
1297
|
+
.filter((s) => s.event !== draftEvent)
|
|
1247
1298
|
.map((s) => {
|
|
1248
1299
|
const startCol = Math.max(s.startCol, firstVisCol);
|
|
1249
1300
|
const endCol = Math.min(s.endCol, lastVisCol);
|
|
@@ -1256,22 +1307,12 @@ export function DateRows<T = unknown>({
|
|
|
1256
1307
|
};
|
|
1257
1308
|
})
|
|
1258
1309
|
.filter((b) => b.startCol <= b.endCol);
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
day.date >= createRange.end
|
|
1264
|
-
? []
|
|
1265
|
-
: [index],
|
|
1266
|
-
)
|
|
1267
|
-
: [];
|
|
1268
|
-
const draftStart = draftColumns[0];
|
|
1269
|
-
const draftEnd = draftColumns.at(-1);
|
|
1310
|
+
// The draft's own lane and columns, clamped like the bars.
|
|
1311
|
+
const draftSegment = rowLayout.segments.find((s) => s.event === draftEvent);
|
|
1312
|
+
const draftStart = draftSegment ? Math.max(draftSegment.startCol, firstVisCol) : -1;
|
|
1313
|
+
const draftEnd = draftSegment ? Math.min(draftSegment.endCol, lastVisCol) : -1;
|
|
1270
1314
|
const draftTop =
|
|
1271
|
-
CELL_PAD +
|
|
1272
|
-
DATE_ROW +
|
|
1273
|
-
chipGap +
|
|
1274
|
-
Math.min(visibleLanes, Math.max(0, maxVisibleEventCount - 1)) * (chipHeight + chipGap);
|
|
1315
|
+
CELL_PAD + DATE_ROW + chipGap + (draftSegment?.lane ?? 0) * (chipHeight + chipGap);
|
|
1275
1316
|
const draftHeight = Math.min(chipHeight, Math.max(0, eventRowHeight - draftTop));
|
|
1276
1317
|
const barChipButton = slot("chipButton", chipButtonDefault);
|
|
1277
1318
|
const barChip = slot("chip", chipDefault(theme, chipHeight));
|
|
@@ -1287,6 +1328,9 @@ export function DateRows<T = unknown>({
|
|
|
1287
1328
|
})}
|
|
1288
1329
|
>
|
|
1289
1330
|
{week.days.map((day, dayCol) => {
|
|
1331
|
+
// Lanes this day shows: the row's, plus the "+more" row's when it holds
|
|
1332
|
+
// the day's only hidden event.
|
|
1333
|
+
const dayLanes = visibleLanes + (extraLane[dayCol] ? 1 : 0);
|
|
1290
1334
|
const hidden = !showAdjacentMonths && isOutsidePeriod(day);
|
|
1291
1335
|
const cellHeight = eventsMode ? eventRowHeight : theme.cellHeight;
|
|
1292
1336
|
if (hidden) {
|
|
@@ -1329,7 +1373,11 @@ export function DateRows<T = unknown>({
|
|
|
1329
1373
|
// whole day.
|
|
1330
1374
|
const hiddenEvents = rowLayout.segments
|
|
1331
1375
|
.filter(
|
|
1332
|
-
(s) =>
|
|
1376
|
+
(s) =>
|
|
1377
|
+
s.startCol <= dayCol &&
|
|
1378
|
+
s.endCol >= dayCol &&
|
|
1379
|
+
s.lane >= dayLanes &&
|
|
1380
|
+
s.event !== draftEvent,
|
|
1333
1381
|
)
|
|
1334
1382
|
.map((s) => s.event);
|
|
1335
1383
|
const dayLabel = format(day.date, "d MMMM", locale ? { locale } : undefined);
|
|
@@ -1436,7 +1484,7 @@ export function DateRows<T = unknown>({
|
|
|
1436
1484
|
dragArmed && drag?.kind === "move" && drag.event === b.seg.event;
|
|
1437
1485
|
return (
|
|
1438
1486
|
<button
|
|
1439
|
-
key={`bar-${b.seg.event.start.toISOString()}:${b.seg.event.title}:${b.seg.lane}`}
|
|
1487
|
+
key={`bar-${b.seg.event.start.toISOString()}:${b.seg.event.title}:${b.seg.lane}:${b.startCol}`}
|
|
1440
1488
|
type="button"
|
|
1441
1489
|
onPointerDown={
|
|
1442
1490
|
canMove(b.seg.event)
|
|
@@ -1511,7 +1559,7 @@ export function DateRows<T = unknown>({
|
|
|
1511
1559
|
{RenderCreateGhost &&
|
|
1512
1560
|
createRange &&
|
|
1513
1561
|
draftStart === dayCol &&
|
|
1514
|
-
draftEnd
|
|
1562
|
+
draftEnd >= draftStart &&
|
|
1515
1563
|
draftHeight > 0 ? (
|
|
1516
1564
|
<InertDiv
|
|
1517
1565
|
{...slot("createGhost", {
|
|
@@ -1547,7 +1595,7 @@ export function DateRows<T = unknown>({
|
|
|
1547
1595
|
>
|
|
1548
1596
|
{/* Reserve one row per visible lane so the absolute bars have
|
|
1549
1597
|
space and "+more" sits below them. */}
|
|
1550
|
-
{Array.from({ length:
|
|
1598
|
+
{Array.from({ length: dayLanes }, (_, i) => (
|
|
1551
1599
|
<div key={`lane-${i}`} aria-hidden style={{ height: chipHeight }} />
|
|
1552
1600
|
))}
|
|
1553
1601
|
{hiddenEvents.length > 0 ? (
|
package/src/ResourceTimeline.tsx
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
ComponentType,
|
|
3
|
-
CSSProperties,
|
|
4
|
-
PointerEvent as ReactPointerEvent,
|
|
5
|
-
ReactElement,
|
|
6
|
-
ReactNode,
|
|
1
|
+
import {
|
|
2
|
+
type ComponentType,
|
|
3
|
+
type CSSProperties,
|
|
4
|
+
type PointerEvent as ReactPointerEvent,
|
|
5
|
+
type ReactElement,
|
|
6
|
+
type ReactNode,
|
|
7
|
+
useCallback,
|
|
8
|
+
useEffect,
|
|
9
|
+
useMemo,
|
|
10
|
+
useRef,
|
|
11
|
+
useState,
|
|
7
12
|
} from "react";
|
|
8
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
9
13
|
import {
|
|
10
14
|
backgroundBandsForDay,
|
|
11
15
|
type BusinessHoursBand,
|
package/src/YearView.tsx
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { format, startOfDay, type Locale } from "date-fns";
|
|
2
|
-
import
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
type CSSProperties,
|
|
4
|
+
type PointerEvent as ReactPointerEvent,
|
|
5
|
+
type ReactElement,
|
|
6
|
+
useEffect,
|
|
7
|
+
useMemo,
|
|
8
|
+
useRef,
|
|
9
|
+
useState,
|
|
10
|
+
} from "react";
|
|
4
11
|
import {
|
|
5
12
|
bandRounding,
|
|
6
13
|
buildMonthWeeks,
|
|
@@ -21,8 +28,6 @@ import {
|
|
|
21
28
|
rangeBandKind,
|
|
22
29
|
type WeekStartsOn,
|
|
23
30
|
weekdayFormatToken,
|
|
24
|
-
} from "@super-calendar/core";
|
|
25
|
-
import {
|
|
26
31
|
type CalendarLabels,
|
|
27
32
|
dayAccessibilityLabel,
|
|
28
33
|
resolveCalendarLabels,
|