@super-calendar/dom 2.13.0 → 2.14.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/README.md +26 -0
- package/dist/index.d.mts +22 -2
- package/dist/index.d.ts +22 -2
- package/dist/index.js +185 -42
- package/dist/index.mjs +185 -42
- package/package.json +2 -2
- package/src/Calendar.tsx +16 -0
- package/src/MonthList.tsx +11 -4
- package/src/MonthView.tsx +26 -16
- package/src/TimeGrid.tsx +188 -18
- package/src/touch.ts +61 -0
package/dist/index.mjs
CHANGED
|
@@ -637,7 +637,7 @@ function badgeDefault(day, theme, hovered) {
|
|
|
637
637
|
}
|
|
638
638
|
};
|
|
639
639
|
}
|
|
640
|
-
function eventCellDefault(day, theme, height, highlightWeekends, isDragTarget) {
|
|
640
|
+
function eventCellDefault(day, theme, height, highlightWeekends, isDragTarget, chipGap) {
|
|
641
641
|
return {
|
|
642
642
|
base: {
|
|
643
643
|
position: "relative",
|
|
@@ -647,7 +647,7 @@ function eventCellDefault(day, theme, height, highlightWeekends, isDragTarget) {
|
|
|
647
647
|
cursor: day.isDisabled ? "default" : "pointer",
|
|
648
648
|
display: "flex",
|
|
649
649
|
flexDirection: "column",
|
|
650
|
-
gap:
|
|
650
|
+
gap: chipGap,
|
|
651
651
|
padding: CELL_PAD,
|
|
652
652
|
boxSizing: "border-box",
|
|
653
653
|
textAlign: "left",
|
|
@@ -693,12 +693,12 @@ const chipButtonDefault = { base: {
|
|
|
693
693
|
textAlign: "left",
|
|
694
694
|
fontFamily: "inherit"
|
|
695
695
|
} };
|
|
696
|
-
function chipDefault(theme) {
|
|
696
|
+
function chipDefault(theme, chipHeight) {
|
|
697
697
|
return {
|
|
698
698
|
base: {
|
|
699
699
|
display: "block",
|
|
700
|
-
height:
|
|
701
|
-
lineHeight: `${
|
|
700
|
+
height: chipHeight,
|
|
701
|
+
lineHeight: `${chipHeight}px`,
|
|
702
702
|
whiteSpace: "nowrap",
|
|
703
703
|
overflow: "hidden",
|
|
704
704
|
textOverflow: "ellipsis"
|
|
@@ -713,7 +713,7 @@ function chipDefault(theme) {
|
|
|
713
713
|
}
|
|
714
714
|
};
|
|
715
715
|
}
|
|
716
|
-
function moreButtonDefault(theme) {
|
|
716
|
+
function moreButtonDefault(theme, chipHeight) {
|
|
717
717
|
return {
|
|
718
718
|
base: {
|
|
719
719
|
position: "relative",
|
|
@@ -722,8 +722,8 @@ function moreButtonDefault(theme) {
|
|
|
722
722
|
background: "transparent",
|
|
723
723
|
cursor: "pointer",
|
|
724
724
|
textAlign: "left",
|
|
725
|
-
height:
|
|
726
|
-
lineHeight: `${
|
|
725
|
+
height: chipHeight,
|
|
726
|
+
lineHeight: `${chipHeight}px`,
|
|
727
727
|
fontFamily: "inherit"
|
|
728
728
|
},
|
|
729
729
|
themed: {
|
|
@@ -755,7 +755,7 @@ function collectRowEvents(week, eventsByDay) {
|
|
|
755
755
|
* <MonthView date={new Date()} events={events} onPressDay={(d) => setDate(d)} />
|
|
756
756
|
* ```
|
|
757
757
|
*/
|
|
758
|
-
function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short", events, eventsByDay: eventsByDayProp, renderEvent, eventAccessibilityLabel, maxVisibleEventCount = 3, moreLabel = "{moreCount} More", labels: labelsProp, 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 }) {
|
|
758
|
+
function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short", events, eventsByDay: eventsByDayProp, renderEvent, eventAccessibilityLabel, maxVisibleEventCount = 3, chipHeight = CHIP_HEIGHT, chipGap = CHIP_GAP, moreLabel = "{moreCount} More", labels: labelsProp, 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 }) {
|
|
759
759
|
const theme = useMemo(() => mergeDomTheme(themeOverrides), [themeOverrides]);
|
|
760
760
|
const labels = useMemo(() => resolveCalendarLabels(labelsProp), [labelsProp]);
|
|
761
761
|
const slot = createSlots({
|
|
@@ -800,7 +800,7 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
800
800
|
document.removeEventListener("keydown", onKey);
|
|
801
801
|
};
|
|
802
802
|
}, [moreOpenFor]);
|
|
803
|
-
const eventRowHeight = 32 + maxVisibleEventCount *
|
|
803
|
+
const eventRowHeight = 32 + maxVisibleEventCount * (chipHeight + chipGap);
|
|
804
804
|
const { weeks, weekdays } = useMemo(() => buildMonthGrid$1(date, {
|
|
805
805
|
weekStartsOn,
|
|
806
806
|
hiddenDays,
|
|
@@ -1012,7 +1012,7 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
1012
1012
|
};
|
|
1013
1013
|
}).filter((b) => b.startCol <= b.endCol);
|
|
1014
1014
|
const barChipButton = slot("chipButton", chipButtonDefault);
|
|
1015
|
-
const barChip = slot("chip", chipDefault(theme));
|
|
1015
|
+
const barChip = slot("chip", chipDefault(theme, chipHeight));
|
|
1016
1016
|
return /* @__PURE__ */ jsx("div", {
|
|
1017
1017
|
role: "row",
|
|
1018
1018
|
...slot("week", { base: {
|
|
@@ -1051,7 +1051,7 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
1051
1051
|
const dayEvents = eventsByDay.get(startOfDay(day.date).toISOString()) ?? [];
|
|
1052
1052
|
const hiddenEvents = rowLayout.segments.filter((s) => s.startCol <= dayCol && s.endCol >= dayCol && s.lane >= visibleLanes).map((s) => s.event);
|
|
1053
1053
|
const dayLabel = format(day.date, "d MMMM", locale ? { locale } : void 0);
|
|
1054
|
-
const dayCellProps = slot("day", eventCellDefault(day, theme, cellHeight, highlightWeekends, inCreate || isDropTarget));
|
|
1054
|
+
const dayCellProps = slot("day", eventCellDefault(day, theme, cellHeight, highlightWeekends, inCreate || isDropTarget, chipGap));
|
|
1055
1055
|
return /* @__PURE__ */ jsxs("div", {
|
|
1056
1056
|
role: "gridcell",
|
|
1057
1057
|
"data-day": day.id,
|
|
@@ -1129,8 +1129,8 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
1129
1129
|
position: "absolute",
|
|
1130
1130
|
left: 2,
|
|
1131
1131
|
width: `calc(${span * 100}% - 4px)`,
|
|
1132
|
-
top:
|
|
1133
|
-
height:
|
|
1132
|
+
top: 28 + chipGap + b.seg.lane * (chipHeight + chipGap),
|
|
1133
|
+
height: chipHeight,
|
|
1134
1134
|
pointerEvents: isDragging ? "none" : "auto",
|
|
1135
1135
|
opacity: isDragged ? DRAGGED_CHIP_OPACITY : void 0,
|
|
1136
1136
|
cursor: canMove(b.seg.event) ? "grab" : void 0,
|
|
@@ -1161,12 +1161,12 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
1161
1161
|
...slot("events", { base: {
|
|
1162
1162
|
display: "flex",
|
|
1163
1163
|
flexDirection: "column",
|
|
1164
|
-
gap:
|
|
1164
|
+
gap: chipGap
|
|
1165
1165
|
} }),
|
|
1166
1166
|
children: [
|
|
1167
1167
|
Array.from({ length: visibleLanes }, (_, i) => /* @__PURE__ */ jsx("div", {
|
|
1168
1168
|
"aria-hidden": true,
|
|
1169
|
-
style: { height:
|
|
1169
|
+
style: { height: chipHeight }
|
|
1170
1170
|
}, `lane-${i}`)),
|
|
1171
1171
|
hiddenEvents.length > 0 ? /* @__PURE__ */ jsx("button", {
|
|
1172
1172
|
type: "button",
|
|
@@ -1179,7 +1179,7 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
1179
1179
|
setMoreOpenFor((open) => open === day.id ? null : day.id);
|
|
1180
1180
|
}
|
|
1181
1181
|
},
|
|
1182
|
-
...slot("more", moreButtonDefault(theme)),
|
|
1182
|
+
...slot("more", moreButtonDefault(theme, chipHeight)),
|
|
1183
1183
|
"aria-label": `${labels.moreEvents(hiddenEvents.length)}, ${dayLabel}`,
|
|
1184
1184
|
"aria-expanded": onPressMore ? void 0 : moreOpenFor === day.id,
|
|
1185
1185
|
children: moreLabel.replace("{moreCount}", String(hiddenEvents.length))
|
|
@@ -1251,7 +1251,7 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
1251
1251
|
event,
|
|
1252
1252
|
onPress: () => onPressEvent?.(event)
|
|
1253
1253
|
}) : /* @__PURE__ */ jsx("span", {
|
|
1254
|
-
...slot("chip", chipDefault(theme)),
|
|
1254
|
+
...slot("chip", chipDefault(theme, chipHeight)),
|
|
1255
1255
|
children: event.title
|
|
1256
1256
|
})
|
|
1257
1257
|
}, i))]
|
|
@@ -1295,6 +1295,45 @@ function MonthView({ date, weekStartsOn = 0, hiddenDays, weekdayFormat = "short"
|
|
|
1295
1295
|
});
|
|
1296
1296
|
}
|
|
1297
1297
|
//#endregion
|
|
1298
|
+
//#region src/touch.ts
|
|
1299
|
+
function waitForHold(grab, delay, threshold, onHold, onTap, onCancel) {
|
|
1300
|
+
const detach = () => {
|
|
1301
|
+
clearTimeout(timer);
|
|
1302
|
+
document.removeEventListener("pointermove", move);
|
|
1303
|
+
document.removeEventListener("pointerup", up);
|
|
1304
|
+
document.removeEventListener("pointercancel", cancelPointer);
|
|
1305
|
+
document.removeEventListener("pointerdown", anotherPointer);
|
|
1306
|
+
};
|
|
1307
|
+
const cancel = () => {
|
|
1308
|
+
detach();
|
|
1309
|
+
onCancel();
|
|
1310
|
+
};
|
|
1311
|
+
const move = (event) => {
|
|
1312
|
+
if (event.pointerId === grab.pointerId && Math.hypot(event.clientX - grab.clientX, event.clientY - grab.clientY) > threshold) cancel();
|
|
1313
|
+
};
|
|
1314
|
+
const up = (event) => {
|
|
1315
|
+
if (event.pointerId === grab.pointerId) {
|
|
1316
|
+
detach();
|
|
1317
|
+
onTap();
|
|
1318
|
+
}
|
|
1319
|
+
};
|
|
1320
|
+
const cancelPointer = (event) => {
|
|
1321
|
+
if (event.pointerId === grab.pointerId) cancel();
|
|
1322
|
+
};
|
|
1323
|
+
const anotherPointer = (event) => {
|
|
1324
|
+
if (event.pointerId !== grab.pointerId) cancel();
|
|
1325
|
+
};
|
|
1326
|
+
const timer = setTimeout(() => {
|
|
1327
|
+
detach();
|
|
1328
|
+
onHold();
|
|
1329
|
+
}, delay);
|
|
1330
|
+
document.addEventListener("pointermove", move);
|
|
1331
|
+
document.addEventListener("pointerup", up);
|
|
1332
|
+
document.addEventListener("pointercancel", cancelPointer);
|
|
1333
|
+
document.addEventListener("pointerdown", anotherPointer);
|
|
1334
|
+
return cancel;
|
|
1335
|
+
}
|
|
1336
|
+
//#endregion
|
|
1298
1337
|
//#region src/TimeGrid.tsx
|
|
1299
1338
|
const GUTTER_WIDTH$1 = 56;
|
|
1300
1339
|
const HOURS_PER_DAY = 24;
|
|
@@ -1304,6 +1343,7 @@ const clamp$1 = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
|
|
|
1304
1343
|
const EDGE_ZONE = 32;
|
|
1305
1344
|
const EDGE_DWELL_MS = 600;
|
|
1306
1345
|
const EDGE_REPEAT_MS = 600;
|
|
1346
|
+
const CELL_TOUCH_SLOP_PX = 8;
|
|
1307
1347
|
const VISUALLY_HIDDEN = {
|
|
1308
1348
|
position: "absolute",
|
|
1309
1349
|
width: 1,
|
|
@@ -1398,7 +1438,7 @@ function DefaultDomEvent({ event, mode, isAllDay, boxHeight, ampm = false, theme
|
|
|
1398
1438
|
* ```
|
|
1399
1439
|
*/
|
|
1400
1440
|
const TimeGrid = forwardRef(TimeGridInner);
|
|
1401
|
-
function TimeGridInner({ 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, renderBackgroundEvent, showNowIndicator = true, highlightWeekends = true, eventStartEditable = true, eventDurationEditable = true, eventOverlap = true, now: nowProp, timeZone, showAllDayEventCell = true, showAllDayLabel = false, labels: labelsProp, locale, theme: themeOverrides, height = 600, renderEvent, eventAccessibilityLabel: eventAccessibilityLabel$1, hourComponent, onPressEvent, onPressDateHeader, onPressCell, onCreateEvent, onDragStart, onDragEvent, onChangeDate, className, style, classNames, styles }, ref) {
|
|
1441
|
+
function TimeGridInner({ 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, touchDragDelay = 300, touchDragThreshold = 8, ampm = false, timeslots = 1, minHour = 0, maxHour = 24, hideHours = false, showWeekNumber = false, weekNumberPrefix = "W", hiddenDays, keyboardEventNavigation = false, businessHours, renderBusinessHours, renderBackgroundEvent, showNowIndicator = true, highlightWeekends = true, eventStartEditable = true, eventDurationEditable = true, eventOverlap = true, now: nowProp, timeZone, showAllDayEventCell = true, showAllDayLabel = false, labels: labelsProp, locale, theme: themeOverrides, height = 600, renderEvent, eventAccessibilityLabel: eventAccessibilityLabel$1, hourComponent, onPressEvent, onPressDateHeader, onPressCell, onCreateEvent, onDragStart, onDragEvent, onChangeDate, className, style, classNames, styles }, ref) {
|
|
1402
1442
|
const theme = useMemo(() => mergeDomTheme(themeOverrides), [themeOverrides]);
|
|
1403
1443
|
const labels = useMemo(() => resolveCalendarLabels(labelsProp), [labelsProp]);
|
|
1404
1444
|
const slot = createSlots({
|
|
@@ -1432,6 +1472,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
1432
1472
|
};
|
|
1433
1473
|
const [createBox, setCreateBox] = useState(null);
|
|
1434
1474
|
const createOrigin = useRef(null);
|
|
1475
|
+
const cellTouchRef = useRef(null);
|
|
1435
1476
|
const cellEnabled = !!onPressCell || !!onCreateEvent;
|
|
1436
1477
|
const days = useMemo(() => getViewDays$1(mode, date, weekStartsOn, numberOfDays, false, void 0, hiddenDays), [
|
|
1437
1478
|
mode,
|
|
@@ -1452,6 +1493,10 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
1452
1493
|
const [paged, setPaged] = useState(false);
|
|
1453
1494
|
const draggedRef = useRef(null);
|
|
1454
1495
|
const ghostRef = useRef(null);
|
|
1496
|
+
const touchDragRef = useRef(false);
|
|
1497
|
+
const activeGrabRef = useRef(null);
|
|
1498
|
+
const cancelHoldRef = useRef(null);
|
|
1499
|
+
const tappedRef = useRef(null);
|
|
1455
1500
|
const docHandlersRef = useRef(null);
|
|
1456
1501
|
const daysRef = useRef(days);
|
|
1457
1502
|
daysRef.current = days;
|
|
@@ -1505,6 +1550,22 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
1505
1550
|
minHourHeight,
|
|
1506
1551
|
maxHourHeight
|
|
1507
1552
|
]);
|
|
1553
|
+
useEffect(() => {
|
|
1554
|
+
const el = scrollRef.current;
|
|
1555
|
+
if (!el) return;
|
|
1556
|
+
const onTouchMove = (e) => {
|
|
1557
|
+
if (touchDragRef.current && e.cancelable) e.preventDefault();
|
|
1558
|
+
};
|
|
1559
|
+
const onContextMenu = (e) => {
|
|
1560
|
+
if (touchDragRef.current || cancelHoldRef.current) e.preventDefault();
|
|
1561
|
+
};
|
|
1562
|
+
el.addEventListener("touchmove", onTouchMove, { passive: false });
|
|
1563
|
+
el.addEventListener("contextmenu", onContextMenu);
|
|
1564
|
+
return () => {
|
|
1565
|
+
el.removeEventListener("touchmove", onTouchMove);
|
|
1566
|
+
el.removeEventListener("contextmenu", onContextMenu);
|
|
1567
|
+
};
|
|
1568
|
+
}, []);
|
|
1508
1569
|
const pinch = useRef(/* @__PURE__ */ new Map());
|
|
1509
1570
|
const pinchBase = useRef(null);
|
|
1510
1571
|
const onBodyPointerDown = (e) => {
|
|
@@ -1568,6 +1629,8 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
1568
1629
|
edgeSide.current = 0;
|
|
1569
1630
|
pagedRef.current = false;
|
|
1570
1631
|
setPaged(false);
|
|
1632
|
+
touchDragRef.current = false;
|
|
1633
|
+
activeGrabRef.current = null;
|
|
1571
1634
|
draggedRef.current = null;
|
|
1572
1635
|
dragOrigin.current = null;
|
|
1573
1636
|
applyDrag(null);
|
|
@@ -1575,6 +1638,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
1575
1638
|
const moveDrag = (e) => {
|
|
1576
1639
|
const d = dragRef.current;
|
|
1577
1640
|
if (!d || !dragOrigin.current) return;
|
|
1641
|
+
if (touchDragRef.current && !d.moved && Math.hypot(e.clientX - dragOrigin.current.pointerX, e.clientY - dragOrigin.current.pointerY) <= touchDragThreshold) return;
|
|
1578
1642
|
ptr.current = {
|
|
1579
1643
|
x: e.clientX,
|
|
1580
1644
|
y: e.clientY
|
|
@@ -1603,7 +1667,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
1603
1667
|
const g = ghostRef.current;
|
|
1604
1668
|
const held = draggedRef.current;
|
|
1605
1669
|
if (g && held) g.style.transform = `translate(${e.clientX - held.grabX}px, ${e.clientY - held.grabY}px)`;
|
|
1606
|
-
if (edgeAdvanceEnabled) {
|
|
1670
|
+
if (edgeAdvanceEnabled && o.pointerType === "mouse") {
|
|
1607
1671
|
const rect = columnsRef.current?.getBoundingClientRect();
|
|
1608
1672
|
if (rect && rect.right > rect.left) {
|
|
1609
1673
|
const left = rect.left + gutterWidth;
|
|
@@ -1638,12 +1702,15 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
1638
1702
|
const d = dragRef.current;
|
|
1639
1703
|
if (!d) return;
|
|
1640
1704
|
try {
|
|
1641
|
-
|
|
1705
|
+
activeGrabRef.current?.box.releasePointerCapture?.(e.pointerId);
|
|
1642
1706
|
} catch {}
|
|
1643
1707
|
const held = draggedRef.current;
|
|
1644
1708
|
if (!d.moved) {
|
|
1709
|
+
const wasTouch = touchDragRef.current;
|
|
1710
|
+
const tapBox = activeGrabRef.current?.box ?? null;
|
|
1645
1711
|
finishDrag();
|
|
1646
|
-
|
|
1712
|
+
if (wasTouch) tappedRef.current = tapBox;
|
|
1713
|
+
else held?.onPress();
|
|
1647
1714
|
return;
|
|
1648
1715
|
}
|
|
1649
1716
|
const origin = dragOrigin.current;
|
|
@@ -1670,13 +1737,13 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
1670
1737
|
finishDrag();
|
|
1671
1738
|
};
|
|
1672
1739
|
const beginDrag = (e, pe, key, kind, dayIndex, onPress) => {
|
|
1673
|
-
if (!onDragEvent) return;
|
|
1674
1740
|
const { event, startHours, durationHours, continuesBefore, continuesAfter } = pe;
|
|
1675
|
-
e.stopPropagation();
|
|
1676
1741
|
try {
|
|
1677
|
-
e.
|
|
1742
|
+
e.box.setPointerCapture?.(e.pointerId);
|
|
1678
1743
|
} catch {}
|
|
1679
|
-
|
|
1744
|
+
touchDragRef.current = e.pointerType !== "mouse";
|
|
1745
|
+
activeGrabRef.current = e;
|
|
1746
|
+
const boxEl = e.box;
|
|
1680
1747
|
const column = kind === "move" ? boxEl.parentElement : null;
|
|
1681
1748
|
const dayWidth = column ? column.getBoundingClientRect().width : 0;
|
|
1682
1749
|
const boxRect = kind === "move" ? boxEl.getBoundingClientRect() : null;
|
|
@@ -1684,6 +1751,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
1684
1751
|
dragOrigin.current = {
|
|
1685
1752
|
pointerX: e.clientX,
|
|
1686
1753
|
pointerY: e.clientY,
|
|
1754
|
+
pointerType: e.pointerType,
|
|
1687
1755
|
startHours,
|
|
1688
1756
|
durationHours,
|
|
1689
1757
|
dayIndex,
|
|
@@ -1723,21 +1791,68 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
1723
1791
|
onDragStart?.(event);
|
|
1724
1792
|
detachDocListeners();
|
|
1725
1793
|
const handlers = {
|
|
1726
|
-
move:
|
|
1727
|
-
|
|
1728
|
-
|
|
1794
|
+
move: (event) => {
|
|
1795
|
+
if (event.pointerId === e.pointerId) moveDrag(event);
|
|
1796
|
+
},
|
|
1797
|
+
up: (event) => {
|
|
1798
|
+
if (event.pointerId === e.pointerId) endDrag(event);
|
|
1799
|
+
},
|
|
1800
|
+
cancel: (event) => {
|
|
1801
|
+
if (event.pointerId === e.pointerId) cancelDrag();
|
|
1802
|
+
}
|
|
1729
1803
|
};
|
|
1730
1804
|
docHandlersRef.current = handlers;
|
|
1731
1805
|
document.addEventListener("pointermove", handlers.move);
|
|
1732
1806
|
document.addEventListener("pointerup", handlers.up);
|
|
1733
1807
|
document.addEventListener("pointercancel", handlers.cancel);
|
|
1734
1808
|
};
|
|
1809
|
+
const pressEvent = (e, pe, key, kind, dayIndex, onPress) => {
|
|
1810
|
+
if (!onDragEvent || e.button > 0) return;
|
|
1811
|
+
e.stopPropagation();
|
|
1812
|
+
const hadPendingHold = cancelHoldRef.current !== null;
|
|
1813
|
+
cancelHoldRef.current?.();
|
|
1814
|
+
tappedRef.current = null;
|
|
1815
|
+
if (hadPendingHold || activeGrabRef.current || e.pointerType !== "mouse" && !e.isPrimary) return;
|
|
1816
|
+
const grab = {
|
|
1817
|
+
box: e.currentTarget,
|
|
1818
|
+
pointerId: e.pointerId,
|
|
1819
|
+
pointerType: e.pointerType,
|
|
1820
|
+
clientX: e.clientX,
|
|
1821
|
+
clientY: e.clientY
|
|
1822
|
+
};
|
|
1823
|
+
if (e.pointerType === "mouse") {
|
|
1824
|
+
beginDrag(grab, pe, key, kind, dayIndex, onPress);
|
|
1825
|
+
return;
|
|
1826
|
+
}
|
|
1827
|
+
cancelHoldRef.current = waitForHold(grab, touchDragDelay, touchDragThreshold, () => {
|
|
1828
|
+
cancelHoldRef.current = null;
|
|
1829
|
+
beginDrag(grab, pe, key, kind, dayIndex, onPress);
|
|
1830
|
+
}, () => {
|
|
1831
|
+
cancelHoldRef.current = null;
|
|
1832
|
+
tappedRef.current = grab.box;
|
|
1833
|
+
}, () => {
|
|
1834
|
+
cancelHoldRef.current = null;
|
|
1835
|
+
});
|
|
1836
|
+
};
|
|
1735
1837
|
useEffect(() => () => {
|
|
1838
|
+
cancelHoldRef.current?.();
|
|
1736
1839
|
detachDocListeners();
|
|
1737
1840
|
clearEdgeTimer();
|
|
1738
1841
|
}, []);
|
|
1842
|
+
useEffect(() => {
|
|
1843
|
+
cancelHoldRef.current?.();
|
|
1844
|
+
}, [
|
|
1845
|
+
date,
|
|
1846
|
+
events,
|
|
1847
|
+
onDragEvent
|
|
1848
|
+
]);
|
|
1739
1849
|
const pxFromTop = (el, clientY) => clientY - el.getBoundingClientRect().top;
|
|
1740
1850
|
const beginCreate = (e, dayIndex) => {
|
|
1851
|
+
cellTouchRef.current = e.pointerType === "touch" && e.target === e.currentTarget ? {
|
|
1852
|
+
pointerId: e.pointerId,
|
|
1853
|
+
x: e.clientX,
|
|
1854
|
+
y: e.clientY
|
|
1855
|
+
} : null;
|
|
1741
1856
|
if (!cellEnabled || e.pointerType === "touch") return;
|
|
1742
1857
|
if (e.target !== e.currentTarget || e.button > 0) return;
|
|
1743
1858
|
const el = e.currentTarget;
|
|
@@ -1757,6 +1872,8 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
1757
1872
|
});
|
|
1758
1873
|
};
|
|
1759
1874
|
const moveCreate = (e) => {
|
|
1875
|
+
const touch = cellTouchRef.current;
|
|
1876
|
+
if (touch && e.pointerId === touch.pointerId && Math.hypot(e.clientX - touch.x, e.clientY - touch.y) > CELL_TOUCH_SLOP_PX) cellTouchRef.current = null;
|
|
1760
1877
|
const o = createOrigin.current;
|
|
1761
1878
|
if (!o) return;
|
|
1762
1879
|
const cur = pxFromTop(o.el, e.clientY);
|
|
@@ -1786,7 +1903,17 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
1786
1903
|
createOrigin.current = null;
|
|
1787
1904
|
setCreateBox(null);
|
|
1788
1905
|
};
|
|
1906
|
+
const tapCell = (e, dayIndex) => {
|
|
1907
|
+
const touch = cellTouchRef.current;
|
|
1908
|
+
cellTouchRef.current = null;
|
|
1909
|
+
const day = days[dayIndex];
|
|
1910
|
+
if (!touch || !onPressCell || !day || e.target !== e.currentTarget) return;
|
|
1911
|
+
const px = pxFromTop(e.currentTarget, e.clientY);
|
|
1912
|
+
const at = cellRangeFromDrag(day, px, px, hourHeightRef.current, windowStart, snapMinutes);
|
|
1913
|
+
if (at) onPressCell(at.start);
|
|
1914
|
+
};
|
|
1789
1915
|
const cancelCreate = () => {
|
|
1916
|
+
cellTouchRef.current = null;
|
|
1790
1917
|
createOrigin.current = null;
|
|
1791
1918
|
setCreateBox(null);
|
|
1792
1919
|
};
|
|
@@ -2146,6 +2273,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2146
2273
|
onPointerMove: cellEnabled ? moveCreate : void 0,
|
|
2147
2274
|
onPointerUp: cellEnabled ? endCreate : void 0,
|
|
2148
2275
|
onPointerCancel: cellEnabled ? cancelCreate : void 0,
|
|
2276
|
+
onClick: cellEnabled ? (e) => tapCell(e, dayIndex) : void 0,
|
|
2149
2277
|
...dataState({
|
|
2150
2278
|
"data-today": getIsToday(day),
|
|
2151
2279
|
"data-weekend": isWeekend(day)
|
|
@@ -2281,8 +2409,13 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2281
2409
|
}
|
|
2282
2410
|
if (keyboardEventNavigation) onEventKeyDown(key, e);
|
|
2283
2411
|
},
|
|
2284
|
-
onPointerDown: canMove ? (e) =>
|
|
2285
|
-
onClick: canMove ?
|
|
2412
|
+
onPointerDown: canMove ? (e) => pressEvent(e, pe, key, "move", dayIndex, onPress) : void 0,
|
|
2413
|
+
onClick: canMove ? (e) => {
|
|
2414
|
+
if (e.detail === 0 || tappedRef.current && e.currentTarget.contains(tappedRef.current)) {
|
|
2415
|
+
tappedRef.current = null;
|
|
2416
|
+
onPress();
|
|
2417
|
+
}
|
|
2418
|
+
} : onPress,
|
|
2286
2419
|
...dataState({ "data-dragging": !!active && !hiddenForMove }),
|
|
2287
2420
|
...slot("event", { base: {
|
|
2288
2421
|
position: "absolute",
|
|
@@ -2291,7 +2424,9 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2291
2424
|
left: `calc(${pe.column * widthPct}% + ${eventGap}px)`,
|
|
2292
2425
|
width: `calc(${widthPct}% - ${eventGap * 2}px)`,
|
|
2293
2426
|
cursor: canMove ? "grab" : "pointer",
|
|
2294
|
-
touchAction: canMove ? "
|
|
2427
|
+
touchAction: canMove ? "pan-y" : "auto",
|
|
2428
|
+
userSelect: canMove ? "none" : void 0,
|
|
2429
|
+
WebkitTouchCallout: canMove ? "none" : void 0,
|
|
2295
2430
|
zIndex: active ? 3 : 1,
|
|
2296
2431
|
opacity: active ? .85 : 1,
|
|
2297
2432
|
visibility: hiddenForMove ? "hidden" : void 0,
|
|
@@ -2305,8 +2440,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2305
2440
|
}),
|
|
2306
2441
|
canResize && !pe.continuesBefore ? /* @__PURE__ */ jsx("div", {
|
|
2307
2442
|
onPointerDown: (e) => {
|
|
2308
|
-
e
|
|
2309
|
-
beginDrag(e, pe, key, "resize-start", dayIndex, canMove ? onPress : void 0);
|
|
2443
|
+
pressEvent(e, pe, key, "resize-start", dayIndex, canMove ? onPress : void 0);
|
|
2310
2444
|
},
|
|
2311
2445
|
style: {
|
|
2312
2446
|
position: "absolute",
|
|
@@ -2315,13 +2449,12 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2315
2449
|
top: 0,
|
|
2316
2450
|
height: 8,
|
|
2317
2451
|
cursor: "ns-resize",
|
|
2318
|
-
touchAction: "
|
|
2452
|
+
touchAction: "pan-y"
|
|
2319
2453
|
}
|
|
2320
2454
|
}) : null,
|
|
2321
2455
|
canResize && !pe.continuesAfter ? /* @__PURE__ */ jsx("div", {
|
|
2322
2456
|
onPointerDown: (e) => {
|
|
2323
|
-
e
|
|
2324
|
-
beginDrag(e, pe, key, "resize", dayIndex, canMove ? onPress : void 0);
|
|
2457
|
+
pressEvent(e, pe, key, "resize", dayIndex, canMove ? onPress : void 0);
|
|
2325
2458
|
},
|
|
2326
2459
|
style: {
|
|
2327
2460
|
position: "absolute",
|
|
@@ -2330,7 +2463,7 @@ function TimeGridInner({ date, events = [], mode = "day", numberOfDays = 1, week
|
|
|
2330
2463
|
bottom: 0,
|
|
2331
2464
|
height: 8,
|
|
2332
2465
|
cursor: "ns-resize",
|
|
2333
|
-
touchAction: "
|
|
2466
|
+
touchAction: "pan-y"
|
|
2334
2467
|
}
|
|
2335
2468
|
}) : null
|
|
2336
2469
|
]
|
|
@@ -2497,7 +2630,7 @@ function pageStep(mode, date, direction, weekStartsOn, numberOfDays) {
|
|
|
2497
2630
|
* ```
|
|
2498
2631
|
*/
|
|
2499
2632
|
const Calendar = forwardRef(CalendarInner);
|
|
2500
|
-
function CalendarInner({ 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, renderBackgroundEvent, showNowIndicator, showAllDayEventCell, showAllDayLabel, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, dragStepMinutes, onPressCell, onCreateEvent, onDragStart, onDragEvent, onPressDateHeader, renderTimeEvent, hourComponent, keyboardEventNavigation, maxVisibleEventCount, moreLabel, labels, showAdjacentMonths, showTitle, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onSelectDrag, onPressMonth, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }, ref) {
|
|
2633
|
+
function CalendarInner({ 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, renderBackgroundEvent, showNowIndicator, showAllDayEventCell, showAllDayLabel, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, dragStepMinutes, touchDragDelay, touchDragThreshold, onPressCell, onCreateEvent, onDragStart, onDragEvent, onPressDateHeader, renderTimeEvent, hourComponent, keyboardEventNavigation, maxVisibleEventCount, chipHeight, chipGap, moreLabel, labels, showAdjacentMonths, showTitle, weekdayFormat, fillCellOnSelection, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, onSelectDrag, onPressMonth, onPressMore, renderMonthEvent, renderScheduleEvent, classNames, styles }, ref) {
|
|
2501
2634
|
const timeGridRef = useRef(null);
|
|
2502
2635
|
useImperativeHandle(ref, () => ({ scrollToTime: (minutes, options) => timeGridRef.current?.scrollToTime(minutes, options) }), []);
|
|
2503
2636
|
const displayEvents = useMemo(() => {
|
|
@@ -2584,6 +2717,8 @@ function CalendarInner({ mode = "week", date, events, onChangeDate, weekStartsOn
|
|
|
2584
2717
|
classNames,
|
|
2585
2718
|
styles,
|
|
2586
2719
|
maxVisibleEventCount,
|
|
2720
|
+
chipHeight,
|
|
2721
|
+
chipGap,
|
|
2587
2722
|
moreLabel,
|
|
2588
2723
|
showAdjacentMonths,
|
|
2589
2724
|
showTitle,
|
|
@@ -2648,6 +2783,8 @@ function CalendarInner({ mode = "week", date, events, onChangeDate, weekStartsOn
|
|
|
2648
2783
|
eventDurationEditable,
|
|
2649
2784
|
eventOverlap,
|
|
2650
2785
|
dragStepMinutes,
|
|
2786
|
+
touchDragDelay,
|
|
2787
|
+
touchDragThreshold,
|
|
2651
2788
|
onPressEvent,
|
|
2652
2789
|
onPressCell,
|
|
2653
2790
|
onCreateEvent,
|
|
@@ -2673,7 +2810,7 @@ function CalendarInner({ mode = "week", date, events, onChangeDate, weekStartsOn
|
|
|
2673
2810
|
* Legend List's DOM renderer and the library's headless grid logic. Selection is
|
|
2674
2811
|
* controlled, pass `selectedRange` (or `selectedDates`) and handle `onPressDay`.
|
|
2675
2812
|
*/
|
|
2676
|
-
function MonthList({ date, pastMonths = 1, futureMonths = 12, weekdayFormat = "short", highlightWeekends = true, weekStartsOn = 0, events, renderEvent, eventAccessibilityLabel, maxVisibleEventCount, moreLabel, labels, onPressEvent, onPressMore, selectedRange, selectedDates, fillCellOnSelection = false, locale, theme: themeOverrides, height = 480, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, className, style, classNames, styles }) {
|
|
2813
|
+
function MonthList({ date, pastMonths = 1, futureMonths = 12, weekdayFormat = "short", highlightWeekends = true, weekStartsOn = 0, events, renderEvent, eventAccessibilityLabel, maxVisibleEventCount, chipHeight, chipGap, moreLabel, labels, onPressEvent, onPressMore, selectedRange, selectedDates, fillCellOnSelection = false, locale, theme: themeOverrides, height = 480, minDate, maxDate, isDateDisabled, keyboardDayNavigation, onPressDay, className, style, classNames, styles }) {
|
|
2677
2814
|
const theme = useMemo(() => mergeDomTheme(themeOverrides), [themeOverrides]);
|
|
2678
2815
|
const slot = createSlots({
|
|
2679
2816
|
classNames,
|
|
@@ -2707,11 +2844,15 @@ function MonthList({ date, pastMonths = 1, futureMonths = 12, weekdayFormat = "s
|
|
|
2707
2844
|
const extraData = useMemo(() => [
|
|
2708
2845
|
selectedRange,
|
|
2709
2846
|
selectedDates,
|
|
2710
|
-
events
|
|
2847
|
+
events,
|
|
2848
|
+
chipHeight,
|
|
2849
|
+
chipGap
|
|
2711
2850
|
], [
|
|
2712
2851
|
selectedRange,
|
|
2713
2852
|
selectedDates,
|
|
2714
|
-
events
|
|
2853
|
+
events,
|
|
2854
|
+
chipHeight,
|
|
2855
|
+
chipGap
|
|
2715
2856
|
]);
|
|
2716
2857
|
return /* @__PURE__ */ jsxs("div", {
|
|
2717
2858
|
className,
|
|
@@ -2760,6 +2901,8 @@ function MonthList({ date, pastMonths = 1, futureMonths = 12, weekdayFormat = "s
|
|
|
2760
2901
|
renderEvent,
|
|
2761
2902
|
eventAccessibilityLabel,
|
|
2762
2903
|
maxVisibleEventCount,
|
|
2904
|
+
chipHeight,
|
|
2905
|
+
chipGap,
|
|
2763
2906
|
moreLabel,
|
|
2764
2907
|
labels,
|
|
2765
2908
|
onPressEvent,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@super-calendar/dom",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.14.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.14.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@legendapp/list": ">=3",
|
package/src/Calendar.tsx
CHANGED
|
@@ -176,6 +176,10 @@ export interface CalendarProps<T = unknown>
|
|
|
176
176
|
eventOverlap?: boolean;
|
|
177
177
|
/** Snap dragged/created events to this many minutes. */
|
|
178
178
|
dragStepMinutes?: number;
|
|
179
|
+
/** DOM touch/pen hold duration in ms (default 300). */
|
|
180
|
+
touchDragDelay?: number;
|
|
181
|
+
/** DOM touch/pen movement tolerance in px (default 8). */
|
|
182
|
+
touchDragThreshold?: number;
|
|
179
183
|
/**
|
|
180
184
|
* Tap empty space: the date+time pressed on the week/day grid, or the tapped
|
|
181
185
|
* day at midnight in `month` mode (where it fires alongside `onPressDay`).
|
|
@@ -210,6 +214,10 @@ export interface CalendarProps<T = unknown>
|
|
|
210
214
|
// --- Month mode ---
|
|
211
215
|
/** Max chips per day before a "+N more" row. */
|
|
212
216
|
maxVisibleEventCount?: number;
|
|
217
|
+
/** Month chip height in pixels; omit to keep the renderer default. */
|
|
218
|
+
chipHeight?: number;
|
|
219
|
+
/** Gap between month chip rows in pixels (default 2). */
|
|
220
|
+
chipGap?: number;
|
|
213
221
|
/** Overflow row template; `{moreCount}` is replaced. */
|
|
214
222
|
moreLabel?: string;
|
|
215
223
|
/** Translations for the screen-reader words and gutter text; omitted keys use English. */
|
|
@@ -361,6 +369,8 @@ function CalendarInner<T = unknown>(
|
|
|
361
369
|
eventDurationEditable,
|
|
362
370
|
eventOverlap,
|
|
363
371
|
dragStepMinutes,
|
|
372
|
+
touchDragDelay,
|
|
373
|
+
touchDragThreshold,
|
|
364
374
|
onPressCell,
|
|
365
375
|
onCreateEvent,
|
|
366
376
|
onDragStart,
|
|
@@ -371,6 +381,8 @@ function CalendarInner<T = unknown>(
|
|
|
371
381
|
keyboardEventNavigation,
|
|
372
382
|
// month
|
|
373
383
|
maxVisibleEventCount,
|
|
384
|
+
chipHeight,
|
|
385
|
+
chipGap,
|
|
374
386
|
moreLabel,
|
|
375
387
|
labels,
|
|
376
388
|
showAdjacentMonths,
|
|
@@ -496,6 +508,8 @@ function CalendarInner<T = unknown>(
|
|
|
496
508
|
classNames={classNames}
|
|
497
509
|
styles={styles}
|
|
498
510
|
maxVisibleEventCount={maxVisibleEventCount}
|
|
511
|
+
chipHeight={chipHeight}
|
|
512
|
+
chipGap={chipGap}
|
|
499
513
|
moreLabel={moreLabel}
|
|
500
514
|
showAdjacentMonths={showAdjacentMonths}
|
|
501
515
|
showTitle={showTitle}
|
|
@@ -563,6 +577,8 @@ function CalendarInner<T = unknown>(
|
|
|
563
577
|
eventDurationEditable={eventDurationEditable}
|
|
564
578
|
eventOverlap={eventOverlap}
|
|
565
579
|
dragStepMinutes={dragStepMinutes}
|
|
580
|
+
touchDragDelay={touchDragDelay}
|
|
581
|
+
touchDragThreshold={touchDragThreshold}
|
|
566
582
|
onPressEvent={onPressEvent}
|
|
567
583
|
onPressCell={onPressCell}
|
|
568
584
|
onCreateEvent={onCreateEvent}
|
package/src/MonthList.tsx
CHANGED
|
@@ -52,6 +52,10 @@ export interface MonthListProps<T = unknown>
|
|
|
52
52
|
eventAccessibilityLabel?: EventAccessibilityLabeler<T>;
|
|
53
53
|
/** Max chips shown per day before a "+N more" row (default 3). */
|
|
54
54
|
maxVisibleEventCount?: number;
|
|
55
|
+
/** Month chip height in pixels; omit to keep the renderer default. */
|
|
56
|
+
chipHeight?: number;
|
|
57
|
+
/** Gap between month chip rows in pixels (default 2). */
|
|
58
|
+
chipGap?: number;
|
|
55
59
|
/** Template for the overflow row; `{moreCount}` is replaced. */
|
|
56
60
|
moreLabel?: string;
|
|
57
61
|
/** Translations for the screen-reader words and gutter text; omitted keys use English. */
|
|
@@ -102,6 +106,8 @@ export function MonthList<T = unknown>({
|
|
|
102
106
|
renderEvent,
|
|
103
107
|
eventAccessibilityLabel,
|
|
104
108
|
maxVisibleEventCount,
|
|
109
|
+
chipHeight,
|
|
110
|
+
chipGap,
|
|
105
111
|
moreLabel,
|
|
106
112
|
labels,
|
|
107
113
|
onPressEvent,
|
|
@@ -148,11 +154,10 @@ export function MonthList<T = unknown>({
|
|
|
148
154
|
return map;
|
|
149
155
|
}, [events]);
|
|
150
156
|
|
|
151
|
-
//
|
|
152
|
-
// actually change, not on every parent render.
|
|
157
|
+
// Cached rows refresh when selection, events, or chip dimensions change.
|
|
153
158
|
const extraData = useMemo(
|
|
154
|
-
() => [selectedRange, selectedDates, events] as const,
|
|
155
|
-
[selectedRange, selectedDates, events],
|
|
159
|
+
() => [selectedRange, selectedDates, events, chipHeight, chipGap] as const,
|
|
160
|
+
[selectedRange, selectedDates, events, chipHeight, chipGap],
|
|
156
161
|
);
|
|
157
162
|
|
|
158
163
|
return (
|
|
@@ -202,6 +207,8 @@ export function MonthList<T = unknown>({
|
|
|
202
207
|
renderEvent={renderEvent}
|
|
203
208
|
eventAccessibilityLabel={eventAccessibilityLabel}
|
|
204
209
|
maxVisibleEventCount={maxVisibleEventCount}
|
|
210
|
+
chipHeight={chipHeight}
|
|
211
|
+
chipGap={chipGap}
|
|
205
212
|
moreLabel={moreLabel}
|
|
206
213
|
labels={labels}
|
|
207
214
|
onPressEvent={onPressEvent}
|