@super-calendar/native 2.8.1 → 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/README.md +1 -0
- package/dist/{DefaultMonthEvent-CjwX3Nt1.d.ts → DefaultMonthEvent--9Jg6w-x.d.ts} +98 -10
- package/dist/{DefaultMonthEvent-VgJarTO_.d.mts → DefaultMonthEvent-BlnKHaq2.d.mts} +98 -10
- package/dist/{MonthList-DjAz4xoi.mjs → MonthList-CjKhzOJX.mjs} +356 -102
- package/dist/{MonthList-C-vBotP0.js → MonthList-DNT1LJkk.js} +355 -101
- package/dist/index.d.mts +85 -37
- package/dist/index.d.ts +85 -37
- package/dist/index.js +377 -60
- package/dist/index.mjs +378 -61
- package/dist/picker.d.mts +1 -1
- package/dist/picker.d.ts +1 -1
- package/dist/picker.js +1 -1
- package/dist/picker.mjs +1 -1
- package/package.json +2 -2
- package/src/components/Agenda.tsx +3 -3
- package/src/components/AllDayLane.tsx +2 -2
- package/src/components/Calendar.tsx +79 -16
- package/src/components/MonthList.tsx +3 -2
- package/src/components/MonthPager.tsx +152 -63
- package/src/components/MonthView.tsx +422 -80
- package/src/components/TimeGrid.tsx +247 -35
- package/src/components/YearView.tsx +371 -83
- package/src/types.ts +19 -0
- package/src/utils/slots.ts +33 -9
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { addMonths, differenceInCalendarMonths, format, isSameMonth, startOfDay, startOfMonth } from "date-fns";
|
|
2
2
|
import { createContext, createElement, memo, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
-
import { CalendarSelectionProvider, buildMonthWeeks, compareDayEvents, darkColors, dayBadgeKind, daySelectionState, eventAccessibilityLabel, eventTimeLabel, filterHiddenDays, getIsToday, getWeekDays, groupEventsByDay, isAllDayEvent, isBackgroundEvent, isDateSelectable, isSameCalendarDay, isWeekend, layoutMonthWeek, lightColors, monthEventCapacity, monthVisibleCount, rangeBandKind, titleEllipsizeMode, titleNumberOfLines, useCalendarSelection, weekdayFormatToken } from "@super-calendar/core";
|
|
3
|
+
import { CalendarSelectionProvider, buildMonthWeeks, compareDayEvents, darkColors, dayBadgeKind, daySelectionState, eventAccessibilityLabel, eventTimeLabel, filterHiddenDays, getIsToday, getWeekDays, groupEventsByDay, isAllDayEvent, isBackgroundEvent, isDateSelectable, isSameCalendarDay, isWeekend, layoutMonthWeek, lightColors, monthCreateRange, monthDropBounds, monthEventCapacity, monthVisibleCount, overlapsOtherEvents, rangeBandKind, titleEllipsizeMode, titleNumberOfLines, useCalendarSelection, weekdayFormatToken } from "@super-calendar/core";
|
|
4
4
|
import { Modal, Platform, Pressable, ScrollView, StyleSheet, Text, TouchableOpacity, View, useWindowDimensions } from "react-native";
|
|
5
|
+
import { Gesture, GestureDetector } from "react-native-gesture-handler";
|
|
5
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
7
|
import { LegendList } from "@legendapp/list/react-native";
|
|
7
|
-
import { Gesture, GestureDetector } from "react-native-gesture-handler";
|
|
8
8
|
//#region src/theme.ts
|
|
9
9
|
/** The default light theme. Every key the calendar reads falls back to this. */
|
|
10
10
|
const defaultTheme = {
|
|
@@ -207,6 +207,8 @@ const EMPTY_LAYOUT = {
|
|
|
207
207
|
};
|
|
208
208
|
const CHIP_INSET_H = 4;
|
|
209
209
|
const FALLBACK_VISIBLE_COUNT = 3;
|
|
210
|
+
const DRAG_LONG_PRESS_MS = 400;
|
|
211
|
+
const DRAGGED_BAR_OPACITY = .4;
|
|
210
212
|
const numericStyle = (value, fallback) => typeof value === "number" ? value : fallback;
|
|
211
213
|
function collectRowEvents(week, eventsByDay) {
|
|
212
214
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -222,7 +224,14 @@ function collectRowEvents(week, eventsByDay) {
|
|
|
222
224
|
return out;
|
|
223
225
|
}
|
|
224
226
|
const pct = (n) => `${n}%`;
|
|
225
|
-
function
|
|
227
|
+
function isInCreateSpan(drag, day) {
|
|
228
|
+
if (drag?.kind !== "create") return false;
|
|
229
|
+
const time = startOfDay(day).getTime();
|
|
230
|
+
const a = startOfDay(drag.anchor).getTime();
|
|
231
|
+
const b = startOfDay(drag.hover).getTime();
|
|
232
|
+
return time >= Math.min(a, b) && time <= Math.max(a, b);
|
|
233
|
+
}
|
|
234
|
+
function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, hiddenDays, weekdayFormat = "short", locale, sortedMonthView = true, moreLabel = "{moreCount} More", showAdjacentMonths = true, highlightWeekends = true, disableMonthEventCellPress = false, isRTL = false, showSixWeeks = false, showTitle = true, showWeekdays = true, activeDate, selectedDates: selectedDatesProp, selectedRange: selectedRangeProp, fillCellOnSelection = false, minDate: minDateProp, maxDate: maxDateProp, isDateDisabled: isDateDisabledProp, calendarCellStyle, renderEvent, eventAccessibilityLabel, keyExtractor, onPressDay, onLongPressDay, onPressCell, onPressEvent, onLongPressEvent, onPressMore, onCreateEvent, onSelectDrag, onDragEvent, onDragStart, eventStartEditable = true, eventOverlap = true, renderCustomDateForMonth, onDayPointerDown, onDayPointerEnter, classNames, styles: styleOverrides }) {
|
|
226
235
|
const theme = useCalendarTheme();
|
|
227
236
|
const slot = createSlots({
|
|
228
237
|
classNames,
|
|
@@ -235,7 +244,11 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, hidd
|
|
|
235
244
|
const maxDate = maxDateProp ?? selection.maxDate;
|
|
236
245
|
const isDateDisabled = isDateDisabledProp ?? selection.isDateDisabled;
|
|
237
246
|
const RenderEventComponent = useMemo(() => withEventAccessibilityLabel(renderEvent, eventAccessibilityLabel, false), [renderEvent, eventAccessibilityLabel]);
|
|
238
|
-
const [
|
|
247
|
+
const [gridSize, setGridSize] = useState({
|
|
248
|
+
width: 0,
|
|
249
|
+
height: 0
|
|
250
|
+
});
|
|
251
|
+
const gridHeight = gridSize.height;
|
|
239
252
|
const [hoveredKey, setHoveredKey] = useState(null);
|
|
240
253
|
const [pressedKey, setPressedKey] = useState(null);
|
|
241
254
|
const [moreOpenFor, setMoreOpenFor] = useState(null);
|
|
@@ -298,6 +311,169 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, hidd
|
|
|
298
311
|
weeks,
|
|
299
312
|
eventsByDay
|
|
300
313
|
]);
|
|
314
|
+
const dragEnabled = onCreateEvent != null || onSelectDrag != null || onDragEvent != null;
|
|
315
|
+
const gridRef = useRef(null);
|
|
316
|
+
const [drag, setDrag] = useState(null);
|
|
317
|
+
const dragRef = useRef(null);
|
|
318
|
+
const movedRef = useRef(false);
|
|
319
|
+
const suppressPressRef = useRef(false);
|
|
320
|
+
const applyDrag = useCallback((next) => {
|
|
321
|
+
dragRef.current = next;
|
|
322
|
+
setDrag(next);
|
|
323
|
+
}, []);
|
|
324
|
+
const consumeSuppressedPress = useCallback(() => {
|
|
325
|
+
if (!suppressPressRef.current) return false;
|
|
326
|
+
suppressPressRef.current = false;
|
|
327
|
+
return true;
|
|
328
|
+
}, []);
|
|
329
|
+
const canMoveEvent = useCallback((event) => !event.disabled && event.draggable !== false && (event.startEditable ?? eventStartEditable), [eventStartEditable]);
|
|
330
|
+
const hitTest = useCallback((x, y) => {
|
|
331
|
+
const { width, height } = gridSize;
|
|
332
|
+
if (width <= 0 || height <= 0 || weeks.length === 0) return null;
|
|
333
|
+
const rowHeight = height / weeks.length;
|
|
334
|
+
const row = Math.min(weeks.length - 1, Math.max(0, Math.floor(y / rowHeight)));
|
|
335
|
+
const cols = weeks[row].length;
|
|
336
|
+
const col = Math.min(cols - 1, Math.max(0, Math.floor(x / (width / cols))));
|
|
337
|
+
const day = weeks[row][col];
|
|
338
|
+
if (!day) return null;
|
|
339
|
+
if (!showAdjacentMonths && !isSameMonth(day, date)) return null;
|
|
340
|
+
if (!isDateSelectable(day, {
|
|
341
|
+
minDate,
|
|
342
|
+
maxDate,
|
|
343
|
+
isDateDisabled
|
|
344
|
+
})) return null;
|
|
345
|
+
const rowLayout = weekLayouts[row] ?? EMPTY_LAYOUT;
|
|
346
|
+
const lane = Math.floor((y - row * rowHeight - BADGE_AREA) / chipMetrics.chipRowHeight);
|
|
347
|
+
const visibleLanes = monthVisibleCount(rowLayout.laneCount, capacity);
|
|
348
|
+
return {
|
|
349
|
+
day,
|
|
350
|
+
event: (lane >= 0 && lane < visibleLanes ? rowLayout.segments.find((s) => s.lane === lane && s.startCol <= col && s.endCol >= col) : void 0)?.event ?? null
|
|
351
|
+
};
|
|
352
|
+
}, [
|
|
353
|
+
gridSize,
|
|
354
|
+
weeks,
|
|
355
|
+
weekLayouts,
|
|
356
|
+
capacity,
|
|
357
|
+
chipMetrics,
|
|
358
|
+
showAdjacentMonths,
|
|
359
|
+
date,
|
|
360
|
+
minDate,
|
|
361
|
+
maxDate,
|
|
362
|
+
isDateDisabled
|
|
363
|
+
]);
|
|
364
|
+
const beginDrag = useCallback((x, y) => {
|
|
365
|
+
suppressPressRef.current = false;
|
|
366
|
+
movedRef.current = false;
|
|
367
|
+
const hit = hitTest(x, y);
|
|
368
|
+
if (!hit) return;
|
|
369
|
+
if (hit.event) {
|
|
370
|
+
if (!onDragEvent || !canMoveEvent(hit.event)) return;
|
|
371
|
+
applyDrag({
|
|
372
|
+
kind: "move",
|
|
373
|
+
event: hit.event,
|
|
374
|
+
from: hit.day,
|
|
375
|
+
to: hit.day
|
|
376
|
+
});
|
|
377
|
+
onDragStart?.(hit.event);
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
if (onCreateEvent || onSelectDrag) applyDrag({
|
|
381
|
+
kind: "create",
|
|
382
|
+
anchor: hit.day,
|
|
383
|
+
hover: hit.day
|
|
384
|
+
});
|
|
385
|
+
}, [
|
|
386
|
+
hitTest,
|
|
387
|
+
onDragEvent,
|
|
388
|
+
onCreateEvent,
|
|
389
|
+
onSelectDrag,
|
|
390
|
+
onDragStart,
|
|
391
|
+
canMoveEvent,
|
|
392
|
+
applyDrag
|
|
393
|
+
]);
|
|
394
|
+
const extendDrag = useCallback((x, y) => {
|
|
395
|
+
const current = dragRef.current;
|
|
396
|
+
if (!current) return;
|
|
397
|
+
const hit = hitTest(x, y);
|
|
398
|
+
if (!hit) return;
|
|
399
|
+
const previous = current.kind === "create" ? current.hover : current.to;
|
|
400
|
+
if (startOfDay(hit.day).getTime() === startOfDay(previous).getTime()) return;
|
|
401
|
+
movedRef.current = true;
|
|
402
|
+
applyDrag(current.kind === "create" ? {
|
|
403
|
+
...current,
|
|
404
|
+
hover: hit.day
|
|
405
|
+
} : {
|
|
406
|
+
...current,
|
|
407
|
+
to: hit.day
|
|
408
|
+
});
|
|
409
|
+
if (current.kind === "create") {
|
|
410
|
+
const a = startOfDay(current.anchor);
|
|
411
|
+
const b = startOfDay(hit.day);
|
|
412
|
+
const [lo, hi] = a.getTime() <= b.getTime() ? [a, b] : [b, a];
|
|
413
|
+
onSelectDrag?.(lo, hi);
|
|
414
|
+
}
|
|
415
|
+
}, [
|
|
416
|
+
hitTest,
|
|
417
|
+
applyDrag,
|
|
418
|
+
onSelectDrag
|
|
419
|
+
]);
|
|
420
|
+
const endDrag = useCallback(() => {
|
|
421
|
+
const current = dragRef.current;
|
|
422
|
+
applyDrag(null);
|
|
423
|
+
if (!current) return;
|
|
424
|
+
if (isWeb$2) suppressPressRef.current = movedRef.current;
|
|
425
|
+
if (current.kind === "create") {
|
|
426
|
+
if (isWeb$2 && !movedRef.current) return;
|
|
427
|
+
const range = monthCreateRange(current.anchor, current.hover);
|
|
428
|
+
onCreateEvent?.(range.start, range.end);
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
const next = monthDropBounds(current.event, current.from, current.to);
|
|
432
|
+
if (!next) return;
|
|
433
|
+
if (eventOverlap === false && overlapsOtherEvents(events, current.event, next.start, next.end)) return;
|
|
434
|
+
onDragEvent?.(current.event, next.start, next.end);
|
|
435
|
+
}, [
|
|
436
|
+
applyDrag,
|
|
437
|
+
onCreateEvent,
|
|
438
|
+
onDragEvent,
|
|
439
|
+
eventOverlap,
|
|
440
|
+
events
|
|
441
|
+
]);
|
|
442
|
+
const dragGesture = useMemo(() => {
|
|
443
|
+
if (!dragEnabled || isWeb$2) return void 0;
|
|
444
|
+
return Gesture.Pan().activateAfterLongPress(DRAG_LONG_PRESS_MS).runOnJS(true).onStart((event) => beginDrag(event.x, event.y)).onUpdate((event) => extendDrag(event.x, event.y)).onEnd((_event, success) => {
|
|
445
|
+
if (success) endDrag();
|
|
446
|
+
}).onFinalize(() => {
|
|
447
|
+
if (dragRef.current) applyDrag(null);
|
|
448
|
+
});
|
|
449
|
+
}, [
|
|
450
|
+
dragEnabled,
|
|
451
|
+
beginDrag,
|
|
452
|
+
extendDrag,
|
|
453
|
+
endDrag,
|
|
454
|
+
applyDrag
|
|
455
|
+
]);
|
|
456
|
+
const gridPoint = useCallback((clientX, clientY) => {
|
|
457
|
+
const rect = gridRef.current?.getBoundingClientRect?.();
|
|
458
|
+
return rect ? {
|
|
459
|
+
x: clientX - rect.left,
|
|
460
|
+
y: clientY - rect.top
|
|
461
|
+
} : null;
|
|
462
|
+
}, []);
|
|
463
|
+
useEffect(() => {
|
|
464
|
+
if (!isWeb$2 || !dragEnabled) return;
|
|
465
|
+
const up = () => {
|
|
466
|
+
if (dragRef.current) endDrag();
|
|
467
|
+
};
|
|
468
|
+
const target = globalThis;
|
|
469
|
+
target.addEventListener?.("pointerup", up);
|
|
470
|
+
const node = gridRef.current;
|
|
471
|
+
if (node?.style) {
|
|
472
|
+
node.style.touchAction = "none";
|
|
473
|
+
node.style.userSelect = "none";
|
|
474
|
+
}
|
|
475
|
+
return () => target.removeEventListener?.("pointerup", up);
|
|
476
|
+
}, [dragEnabled, endDrag]);
|
|
301
477
|
const renderDay = (day, dayCol, rowLayout, visibleLanes) => {
|
|
302
478
|
const isCurrentMonth = isSameMonth(day, date);
|
|
303
479
|
if (!isCurrentMonth && !showAdjacentMonths) return /* @__PURE__ */ jsx(View, { ...slot("day", {
|
|
@@ -327,9 +503,14 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, hidd
|
|
|
327
503
|
isRangeEnd
|
|
328
504
|
}, fillCellOnSelection) !== "none";
|
|
329
505
|
const dayKey = day.toISOString();
|
|
506
|
+
const isDragPreview = isInCreateSpan(drag, day) || drag?.kind === "move" && isSameCalendarDay(day, drag.to) && !isSameCalendarDay(day, drag.from);
|
|
330
507
|
const isHovered = isWeb$2 && !isDisabled && !showGrid && hoveredKey === dayKey;
|
|
331
508
|
const dateColor = isDisabled ? theme.colors.textDisabled : isFilledBadge ? isHighlighted ? theme.colors.todayText : theme.colors.selectedText : isCurrentMonth ? theme.colors.text : theme.colors.textDisabled;
|
|
332
|
-
const handlePressDay = isDisabled || !onPressDay ? void 0 : () =>
|
|
509
|
+
const handlePressDay = isDisabled || !onPressDay && !onPressCell ? void 0 : () => {
|
|
510
|
+
if (consumeSuppressedPress()) return;
|
|
511
|
+
onPressDay?.(day);
|
|
512
|
+
onPressCell?.(startOfDay(day));
|
|
513
|
+
};
|
|
333
514
|
const handleLongPressDay = isDisabled || !onLongPressDay ? void 0 : () => onLongPressDay(day);
|
|
334
515
|
const eventCount = dayEvents.length;
|
|
335
516
|
const accessibilityLabel = `${format(day, "EEEE, d LLLL yyyy", { locale })}${isToday ? ", today" : ""}${isSelected ? ", selected" : ""}${isDisabled ? ", unavailable" : ""}, ${eventCount} ${eventCount === 1 ? "event" : "events"}`;
|
|
@@ -342,6 +523,7 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, hidd
|
|
|
342
523
|
borderColor: theme.colors.gridLine
|
|
343
524
|
},
|
|
344
525
|
highlightWeekends && isWeekend(day) && { backgroundColor: theme.colors.weekendBackground },
|
|
526
|
+
isDragPreview && { backgroundColor: theme.colors.rangeBackground },
|
|
345
527
|
theme.containers.dayCell
|
|
346
528
|
]
|
|
347
529
|
});
|
|
@@ -355,7 +537,7 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, hidd
|
|
|
355
537
|
},
|
|
356
538
|
onPress: handlePressDay,
|
|
357
539
|
onLongPress: handleLongPressDay,
|
|
358
|
-
disabled: isDisabled || !onPressDay && !onLongPressDay,
|
|
540
|
+
disabled: isDisabled || !onPressDay && !onLongPressDay && !onPressCell,
|
|
359
541
|
...isWeb$2 && !isDisabled ? {
|
|
360
542
|
onPointerEnter: () => {
|
|
361
543
|
if (!showGrid) setHoveredKey(dayKey);
|
|
@@ -446,8 +628,11 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, hidd
|
|
|
446
628
|
}, day.toISOString());
|
|
447
629
|
};
|
|
448
630
|
const handleLayout = (event) => {
|
|
449
|
-
const
|
|
450
|
-
|
|
631
|
+
const { width, height } = event.nativeEvent.layout;
|
|
632
|
+
setGridSize((prev) => prev.width === width && prev.height === height ? prev : {
|
|
633
|
+
width,
|
|
634
|
+
height
|
|
635
|
+
});
|
|
451
636
|
};
|
|
452
637
|
return /* @__PURE__ */ jsxs(View, {
|
|
453
638
|
style: styles$3.root,
|
|
@@ -512,59 +697,87 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, hidd
|
|
|
512
697
|
})
|
|
513
698
|
})
|
|
514
699
|
}) : null,
|
|
515
|
-
/* @__PURE__ */ jsx(
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
700
|
+
/* @__PURE__ */ jsx(MonthGridSurface, {
|
|
701
|
+
gesture: dragGesture,
|
|
702
|
+
children: /* @__PURE__ */ jsx(View, {
|
|
703
|
+
ref: gridRef,
|
|
704
|
+
testID: "month-grid",
|
|
705
|
+
...slot("grid", { base: styles$3.container }),
|
|
706
|
+
onLayout: handleLayout,
|
|
707
|
+
...isWeb$2 && dragEnabled ? {
|
|
708
|
+
onPointerDown: (event) => {
|
|
709
|
+
const point = gridPoint(event.nativeEvent.clientX, event.nativeEvent.clientY);
|
|
710
|
+
if (point) beginDrag(point.x, point.y);
|
|
711
|
+
},
|
|
712
|
+
onPointerMove: (event) => {
|
|
713
|
+
if (!dragRef.current) return;
|
|
714
|
+
const point = gridPoint(event.nativeEvent.clientX, event.nativeEvent.clientY);
|
|
715
|
+
if (point) extendDrag(point.x, point.y);
|
|
529
716
|
}
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
717
|
+
} : null,
|
|
718
|
+
children: weeks.map((week, weekIndex) => {
|
|
719
|
+
const rowLayout = weekLayouts[weekIndex] ?? EMPTY_LAYOUT;
|
|
720
|
+
const visibleLanes = monthVisibleCount(rowLayout.laneCount, capacity);
|
|
721
|
+
const cols = week.length;
|
|
722
|
+
let firstVisCol = 0;
|
|
723
|
+
let lastVisCol = cols - 1;
|
|
724
|
+
if (showGrid && !showAdjacentMonths) {
|
|
725
|
+
const first = week.findIndex((d) => isSameMonth(d, date));
|
|
726
|
+
if (first !== -1) {
|
|
727
|
+
firstVisCol = first;
|
|
728
|
+
lastVisCol = cols - 1 - [...week].reverse().findIndex((d) => isSameMonth(d, date));
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
return /* @__PURE__ */ createElement(View, {
|
|
732
|
+
...slot("week", {
|
|
733
|
+
base: styles$3.weekRow,
|
|
734
|
+
themed: theme.containers.weekRow
|
|
735
|
+
}),
|
|
736
|
+
key: week[0].toISOString()
|
|
737
|
+
}, week.map((day, dayCol) => renderDay(day, dayCol, rowLayout, visibleLanes)), showGrid ? /* @__PURE__ */ jsx(View, {
|
|
738
|
+
style: [StyleSheet.absoluteFill, { pointerEvents: "box-none" }],
|
|
739
|
+
children: rowLayout.segments.filter((seg) => seg.lane < visibleLanes).map((seg) => {
|
|
740
|
+
const startCol = Math.max(seg.startCol, firstVisCol);
|
|
741
|
+
const endCol = Math.min(seg.endCol, lastVisCol);
|
|
742
|
+
if (startCol > endCol) return null;
|
|
743
|
+
const isDragged = drag?.kind === "move" && drag.event === seg.event;
|
|
744
|
+
return /* @__PURE__ */ jsx(View, {
|
|
745
|
+
style: {
|
|
746
|
+
position: "absolute",
|
|
747
|
+
left: pct(startCol / cols * 100),
|
|
748
|
+
width: pct((endCol - startCol + 1) / cols * 100),
|
|
749
|
+
top: BADGE_AREA + seg.lane * chipMetrics.chipRowHeight,
|
|
750
|
+
height: chipMetrics.chipHeight,
|
|
751
|
+
paddingHorizontal: CHIP_INSET_H,
|
|
752
|
+
pointerEvents: drag ? "none" : "box-none",
|
|
753
|
+
opacity: isDragged ? DRAGGED_BAR_OPACITY : 1
|
|
754
|
+
},
|
|
755
|
+
children: /* @__PURE__ */ jsx(RenderEventComponent, {
|
|
756
|
+
event: seg.event,
|
|
757
|
+
mode: "month",
|
|
758
|
+
isAllDay: isAllDayEvent(seg.event),
|
|
759
|
+
onPress: disableMonthEventCellPress ? () => {} : () => {
|
|
760
|
+
if (consumeSuppressedPress()) return;
|
|
761
|
+
onPressEvent(seg.event);
|
|
762
|
+
},
|
|
763
|
+
onLongPress: disableMonthEventCellPress || !onLongPressEvent ? void 0 : () => onLongPressEvent(seg.event)
|
|
764
|
+
})
|
|
765
|
+
}, `bar-${seg.event.start.toISOString()}:${seg.event.title}:${seg.lane}`);
|
|
766
|
+
})
|
|
767
|
+
}) : null);
|
|
768
|
+
})
|
|
563
769
|
})
|
|
564
770
|
})
|
|
565
771
|
]
|
|
566
772
|
});
|
|
567
773
|
}
|
|
774
|
+
function MonthGridSurface({ gesture, children }) {
|
|
775
|
+
if (!gesture) return children;
|
|
776
|
+
return /* @__PURE__ */ jsx(GestureDetector, {
|
|
777
|
+
gesture,
|
|
778
|
+
children
|
|
779
|
+
});
|
|
780
|
+
}
|
|
568
781
|
/**
|
|
569
782
|
* A single month rendered as a 7-column grid of day cells, each showing its
|
|
570
783
|
* event chips with a "+N more" overflow. Render it on its own for a static
|
|
@@ -658,7 +871,7 @@ const styles$3 = StyleSheet.create({
|
|
|
658
871
|
const isWeb$1 = Platform.OS === "web";
|
|
659
872
|
const PAGE_WINDOW$1 = 60;
|
|
660
873
|
const PAGE_VIEWABILITY = { itemVisiblePercentThreshold: 90 };
|
|
661
|
-
function MonthPagerInner({ date, events, maxVisibleEventCount, weekStartsOn, hiddenDays, weekdayFormat = "short", locale, sortedMonthView, moreLabel, showAdjacentMonths, highlightWeekends, disableMonthEventCellPress, isRTL, calendarCellStyle, renderEvent, keyExtractor, onPressDay, onLongPressDay, onPressEvent, onLongPressEvent, onPressMore, onChangeDate, freeSwipe = false, swipeEnabled = true, showSixWeeks = false, activeDate, renderHeaderForMonthView, renderCustomDateForMonth, classNames, styles: styleOverrides }) {
|
|
874
|
+
function MonthPagerInner({ date, events, maxVisibleEventCount, weekStartsOn, hiddenDays, weekdayFormat = "short", locale, sortedMonthView, moreLabel, showAdjacentMonths, highlightWeekends, disableMonthEventCellPress, isRTL, calendarCellStyle, renderEvent, keyExtractor, onPressDay, onLongPressDay, onPressCell, onPressEvent, onLongPressEvent, onPressMore, onCreateEvent, onSelectDrag, selectedDates, selectedRange, fillCellOnSelection, minDate, maxDate, isDateDisabled, onDragEvent, onDragStart, eventStartEditable, eventOverlap, onChangeDate, freeSwipe = false, swipeEnabled = true, showSixWeeks = false, showTitle = true, activeDate, renderHeaderForMonthView, renderCustomDateForMonth, classNames, styles: styleOverrides }) {
|
|
662
875
|
const theme = useCalendarTheme();
|
|
663
876
|
const slot = useMemo(() => createSlots({
|
|
664
877
|
classNames,
|
|
@@ -734,8 +947,28 @@ function MonthPagerInner({ date, events, maxVisibleEventCount, weekStartsOn, hid
|
|
|
734
947
|
]);
|
|
735
948
|
const listExtraData = useMemo(() => ({
|
|
736
949
|
events,
|
|
737
|
-
activeDate
|
|
738
|
-
|
|
950
|
+
activeDate,
|
|
951
|
+
fillCellOnSelection,
|
|
952
|
+
dragSelect: onSelectDrag != null
|
|
953
|
+
}), [
|
|
954
|
+
events,
|
|
955
|
+
activeDate,
|
|
956
|
+
fillCellOnSelection,
|
|
957
|
+
onSelectDrag
|
|
958
|
+
]);
|
|
959
|
+
const selection = useMemo(() => ({
|
|
960
|
+
selectedDates,
|
|
961
|
+
selectedRange,
|
|
962
|
+
minDate,
|
|
963
|
+
maxDate,
|
|
964
|
+
isDateDisabled
|
|
965
|
+
}), [
|
|
966
|
+
selectedDates,
|
|
967
|
+
selectedRange,
|
|
968
|
+
minDate,
|
|
969
|
+
maxDate,
|
|
970
|
+
isDateDisabled
|
|
971
|
+
]);
|
|
739
972
|
const snapToIndices = useMemo(() => monthDates.map((_, index) => index), [monthDates]);
|
|
740
973
|
const keyExtractorList = useCallback((item) => item.toISOString(), []);
|
|
741
974
|
const getFixedItemSize = useCallback(() => containerWidth, [containerWidth]);
|
|
@@ -766,9 +999,17 @@ function MonthPagerInner({ date, events, maxVisibleEventCount, weekStartsOn, hid
|
|
|
766
999
|
keyExtractor,
|
|
767
1000
|
onPressDay,
|
|
768
1001
|
onLongPressDay,
|
|
1002
|
+
onPressCell,
|
|
769
1003
|
onPressEvent,
|
|
770
1004
|
onLongPressEvent,
|
|
771
1005
|
onPressMore,
|
|
1006
|
+
onCreateEvent,
|
|
1007
|
+
onSelectDrag,
|
|
1008
|
+
fillCellOnSelection,
|
|
1009
|
+
onDragEvent,
|
|
1010
|
+
onDragStart,
|
|
1011
|
+
eventStartEditable,
|
|
1012
|
+
eventOverlap,
|
|
772
1013
|
renderCustomDateForMonth,
|
|
773
1014
|
classNames,
|
|
774
1015
|
styles: styleOverrides
|
|
@@ -779,10 +1020,12 @@ function MonthPagerInner({ date, events, maxVisibleEventCount, weekStartsOn, hid
|
|
|
779
1020
|
events,
|
|
780
1021
|
maxVisibleEventCount,
|
|
781
1022
|
weekStartsOn,
|
|
1023
|
+
hiddenDays,
|
|
782
1024
|
locale,
|
|
783
1025
|
sortedMonthView,
|
|
784
1026
|
moreLabel,
|
|
785
1027
|
showAdjacentMonths,
|
|
1028
|
+
highlightWeekends,
|
|
786
1029
|
disableMonthEventCellPress,
|
|
787
1030
|
isRTL,
|
|
788
1031
|
showSixWeeks,
|
|
@@ -792,59 +1035,70 @@ function MonthPagerInner({ date, events, maxVisibleEventCount, weekStartsOn, hid
|
|
|
792
1035
|
keyExtractor,
|
|
793
1036
|
onPressDay,
|
|
794
1037
|
onLongPressDay,
|
|
1038
|
+
onPressCell,
|
|
795
1039
|
onPressEvent,
|
|
796
1040
|
onLongPressEvent,
|
|
797
1041
|
onPressMore,
|
|
1042
|
+
onCreateEvent,
|
|
1043
|
+
onSelectDrag,
|
|
1044
|
+
fillCellOnSelection,
|
|
1045
|
+
onDragEvent,
|
|
1046
|
+
onDragStart,
|
|
1047
|
+
eventStartEditable,
|
|
1048
|
+
eventOverlap,
|
|
798
1049
|
renderCustomDateForMonth,
|
|
799
1050
|
classNames,
|
|
800
1051
|
styleOverrides
|
|
801
1052
|
]);
|
|
802
|
-
return /* @__PURE__ */
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
1053
|
+
return /* @__PURE__ */ jsx(CalendarSelectionProvider, {
|
|
1054
|
+
value: selection,
|
|
1055
|
+
children: /* @__PURE__ */ jsxs(View, {
|
|
1056
|
+
ref: containerRef,
|
|
1057
|
+
style: [styles$2.container, theme.containers.monthContainer],
|
|
1058
|
+
children: [
|
|
1059
|
+
showTitle ? /* @__PURE__ */ jsx(Text, {
|
|
1060
|
+
...slot("title", {
|
|
1061
|
+
base: styles$2.monthTitle,
|
|
1062
|
+
themed: [theme.text.monthTitle, { color: theme.colors.text }]
|
|
1063
|
+
}),
|
|
1064
|
+
allowFontScaling: false,
|
|
1065
|
+
children: format(date, "MMMM yyyy", locale ? { locale } : void 0)
|
|
1066
|
+
}) : null,
|
|
1067
|
+
renderHeaderForMonthView ? renderHeaderForMonthView(weekDays) : /* @__PURE__ */ jsx(MonthWeekdayHeader, {
|
|
1068
|
+
weekDays,
|
|
1069
|
+
weekdayFormat,
|
|
1070
|
+
locale,
|
|
1071
|
+
slot
|
|
810
1072
|
}),
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
weekdayFormat,
|
|
817
|
-
locale,
|
|
818
|
-
slot
|
|
819
|
-
}),
|
|
820
|
-
/* @__PURE__ */ jsx(View, {
|
|
821
|
-
style: styles$2.pager,
|
|
822
|
-
onLayout: (event) => {
|
|
823
|
-
setPageHeight(event.nativeEvent.layout.height);
|
|
824
|
-
setContainerWidth(event.nativeEvent.layout.width);
|
|
825
|
-
},
|
|
826
|
-
children: /* @__PURE__ */ jsx(LegendList, {
|
|
827
|
-
ref: listRef,
|
|
828
|
-
style: isWeb$1 ? [styles$2.pagerList, styles$2.webNoScroll] : styles$2.pagerList,
|
|
829
|
-
data: monthDates,
|
|
830
|
-
extraData: listExtraData,
|
|
831
|
-
horizontal: true,
|
|
832
|
-
recycleItems: false,
|
|
833
|
-
keyExtractor: keyExtractorList,
|
|
834
|
-
getFixedItemSize,
|
|
835
|
-
...isWeb$1 ? null : {
|
|
836
|
-
scrollEnabled: swipeEnabled,
|
|
837
|
-
pagingEnabled: !freeSwipe,
|
|
838
|
-
snapToIndices: freeSwipe ? snapToIndices : void 0
|
|
1073
|
+
/* @__PURE__ */ jsx(View, {
|
|
1074
|
+
style: styles$2.pager,
|
|
1075
|
+
onLayout: (event) => {
|
|
1076
|
+
setPageHeight(event.nativeEvent.layout.height);
|
|
1077
|
+
setContainerWidth(event.nativeEvent.layout.width);
|
|
839
1078
|
},
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
1079
|
+
children: /* @__PURE__ */ jsx(LegendList, {
|
|
1080
|
+
ref: listRef,
|
|
1081
|
+
style: isWeb$1 ? [styles$2.pagerList, styles$2.webNoScroll] : styles$2.pagerList,
|
|
1082
|
+
data: monthDates,
|
|
1083
|
+
extraData: listExtraData,
|
|
1084
|
+
horizontal: true,
|
|
1085
|
+
recycleItems: false,
|
|
1086
|
+
keyExtractor: keyExtractorList,
|
|
1087
|
+
getFixedItemSize,
|
|
1088
|
+
...isWeb$1 ? null : {
|
|
1089
|
+
scrollEnabled: swipeEnabled,
|
|
1090
|
+
pagingEnabled: !freeSwipe,
|
|
1091
|
+
snapToIndices: freeSwipe ? snapToIndices : void 0
|
|
1092
|
+
},
|
|
1093
|
+
initialScrollIndex: activeIndex,
|
|
1094
|
+
showsHorizontalScrollIndicator: false,
|
|
1095
|
+
viewabilityConfig: PAGE_VIEWABILITY,
|
|
1096
|
+
onViewableItemsChanged: handleViewableItemsChanged,
|
|
1097
|
+
renderItem
|
|
1098
|
+
}, pageHeight)
|
|
1099
|
+
})
|
|
1100
|
+
]
|
|
1101
|
+
})
|
|
848
1102
|
});
|
|
849
1103
|
}
|
|
850
1104
|
/**
|