@super-calendar/native 2.13.0 → 2.14.1
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 +6 -0
- package/dist/{DefaultMonthEvent-H1IQMTqK.d.ts → DefaultMonthEvent-BDD7GgL8.d.mts} +16 -4
- package/dist/{DefaultMonthEvent-eip3mlq_.d.mts → DefaultMonthEvent-ggwYo7Fy.d.ts} +16 -4
- package/dist/{MonthList-sGAZxQZ_.js → MonthList-D4_LBnbU.js} +47 -19
- package/dist/{MonthList-B-UE37ZG.mjs → MonthList-DWCH3GT5.mjs} +47 -19
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +80 -16
- package/dist/index.mjs +81 -17
- 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/Calendar.tsx +8 -0
- package/src/components/MonthList.tsx +23 -4
- package/src/components/MonthPager.tsx +30 -4
- package/src/components/MonthView.tsx +29 -14
- package/src/components/MultiDayMovePreview.tsx +5 -5
- package/src/components/ResourceTimeline.tsx +44 -14
- package/src/components/TimeGrid.tsx +66 -10
- package/src/components/YearView.tsx +2 -2
package/dist/index.js
CHANGED
|
@@ -21,7 +21,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
enumerable: true
|
|
22
22
|
}) : target, mod));
|
|
23
23
|
//#endregion
|
|
24
|
-
const require_MonthList = require("./MonthList-
|
|
24
|
+
const require_MonthList = require("./MonthList-D4_LBnbU.js");
|
|
25
25
|
let date_fns = require("date-fns");
|
|
26
26
|
let react = require("react");
|
|
27
27
|
let react_native_reanimated = require("react-native-reanimated");
|
|
@@ -778,9 +778,11 @@ function PreviewDay({ move, cellHeight, dayWidth, minHour, mode, renderEvent: Re
|
|
|
778
778
|
const start = (0, _super_calendar_core.shiftMinutes)(new Date(startTimestamp), dayOffsets[target] + minuteDelta).getTime();
|
|
779
779
|
const end = start + duration;
|
|
780
780
|
const visible = !lifted.value && start < dayEnd && end > dayStart;
|
|
781
|
+
const segStart = new Date(Math.max(start, dayStart));
|
|
782
|
+
const segEnd = new Date(Math.min(end, dayEnd));
|
|
781
783
|
return {
|
|
782
|
-
top: (
|
|
783
|
-
hours: visible ? Math.max((
|
|
784
|
+
top: (0, _super_calendar_core.wallClockHours)(segStart, new Date(dayStart), new Date(dayEnd)),
|
|
785
|
+
hours: visible ? Math.max((0, _super_calendar_core.clockHoursBetween)(segStart, segEnd), .25) : 0,
|
|
784
786
|
continuesBefore: start < dayStart,
|
|
785
787
|
continuesAfter: end > dayEnd
|
|
786
788
|
};
|
|
@@ -843,6 +845,10 @@ const isWeb$1 = react_native.Platform.OS === "web";
|
|
|
843
845
|
const MINUTES_PER_HOUR$1 = 60;
|
|
844
846
|
const HOURS_PER_DAY = 24;
|
|
845
847
|
const MINUTES_PER_DAY = 1440;
|
|
848
|
+
const NO_MOVE_EXTRA$1 = {
|
|
849
|
+
top: 0,
|
|
850
|
+
hours: 0
|
|
851
|
+
};
|
|
846
852
|
const PAGE_WINDOW = 180;
|
|
847
853
|
const PAGE_VIEWABILITY = { itemVisiblePercentThreshold: 90 };
|
|
848
854
|
const PAGER_IDLE_MS = 150;
|
|
@@ -980,9 +986,34 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
980
986
|
minutes: startHours * MINUTES_PER_HOUR$1,
|
|
981
987
|
ownsStart
|
|
982
988
|
}), [startHours, ownsStart]);
|
|
983
|
-
const
|
|
989
|
+
const eventStartMs = positioned.event.start.getTime();
|
|
990
|
+
const eventEndMs = positioned.event.end.getTime();
|
|
991
|
+
const moveExtra = (0, react_native_reanimated.useDerivedValue)(() => {
|
|
992
|
+
if (multiDay || lifted.value || cellHeight.value <= 0) return NO_MOVE_EXTRA$1;
|
|
993
|
+
if (moveOffset.value === 0 && moveOffsetX.value === 0) return NO_MOVE_EXTRA$1;
|
|
994
|
+
const columnDelta = dayWidth > 0 ? Math.round(moveOffsetX.value / dayWidth) : 0;
|
|
995
|
+
const target = Math.min(Math.max(dayIndex + columnDelta, 0), dayCount - 1);
|
|
996
|
+
const minutes = Math.round(moveOffset.value / cellHeight.value * MINUTES_PER_HOUR$1) + (dayOrdinals[target] - dayOrdinals[dayIndex]) * MINUTES_PER_DAY;
|
|
997
|
+
const from = new Date(eventStartMs);
|
|
998
|
+
const to = new Date(eventEndMs);
|
|
999
|
+
const moved = (0, _super_calendar_core.movedClockSpan)(from, to, minutes);
|
|
1000
|
+
return {
|
|
1001
|
+
top: moved.startHours - minutes / MINUTES_PER_HOUR$1,
|
|
1002
|
+
hours: moved.hours - durationHours
|
|
1003
|
+
};
|
|
1004
|
+
}, [
|
|
1005
|
+
multiDay,
|
|
1006
|
+
dayWidth,
|
|
1007
|
+
dayIndex,
|
|
1008
|
+
dayCount,
|
|
1009
|
+
dayOrdinals,
|
|
1010
|
+
eventStartMs,
|
|
1011
|
+
eventEndMs,
|
|
1012
|
+
durationHours
|
|
1013
|
+
]);
|
|
1014
|
+
const boxHeight = (0, react_native_reanimated.useDerivedValue)(() => Math.max((durationHours + moveExtra.value.hours) * cellHeight.value + resizeDelta.value - resizeStartDelta.value, minEventHeight), [durationHours, minEventHeight]);
|
|
984
1015
|
const visibleBoxHeight = (0, react_native_reanimated.useDerivedValue)(() => {
|
|
985
|
-
const top = (startHours - minHour) * cellHeight.value + moveOffset.value + resizeStartDelta.value;
|
|
1016
|
+
const top = (startHours + moveExtra.value.top - minHour) * cellHeight.value + moveOffset.value + resizeStartDelta.value;
|
|
986
1017
|
const dayEnd = (HOURS_PER_DAY - minHour) * cellHeight.value;
|
|
987
1018
|
return Math.max(Math.min(boxHeight.value, dayEnd - top), minEventHeight);
|
|
988
1019
|
}, [
|
|
@@ -992,7 +1023,7 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
992
1023
|
]);
|
|
993
1024
|
const boxStyle = (0, react_native_reanimated.useAnimatedStyle)(() => {
|
|
994
1025
|
return {
|
|
995
|
-
top: (startHours - minHour) * cellHeight.value + moveOffset.value + resizeStartDelta.value,
|
|
1026
|
+
top: (startHours + moveExtra.value.top - minHour) * cellHeight.value + moveOffset.value + resizeStartDelta.value,
|
|
996
1027
|
height: visibleBoxHeight.value,
|
|
997
1028
|
transform: [{ translateX: moveOffsetX.value }],
|
|
998
1029
|
zIndex: dragZ.value,
|
|
@@ -1005,7 +1036,8 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
1005
1036
|
]);
|
|
1006
1037
|
const spillHeight = (0, react_native_reanimated.useDerivedValue)(() => {
|
|
1007
1038
|
if (multiDay || !moving.value || lifted.value || cellHeight.value <= 0) return 0;
|
|
1008
|
-
const
|
|
1039
|
+
const extra = moveExtra.value;
|
|
1040
|
+
const overflowHours = startHours + extra.top + moveOffset.value / cellHeight.value + durationHours + extra.hours - HOURS_PER_DAY;
|
|
1009
1041
|
if (overflowHours <= 0) return 0;
|
|
1010
1042
|
const columnDelta = dayWidth > 0 ? Math.round(moveOffsetX.value / dayWidth) : 0;
|
|
1011
1043
|
const target = Math.min(Math.max(dayIndex + columnDelta, 0), dayCount - 1);
|
|
@@ -2118,7 +2150,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2118
2150
|
animated: false
|
|
2119
2151
|
});
|
|
2120
2152
|
const dom = node.getScrollableNode();
|
|
2121
|
-
if (dom && dom.scrollHeight > dom.clientHeight) webSeededRef.current = true;
|
|
2153
|
+
if (dom != null && typeof dom === "object" && "scrollHeight" in dom && typeof dom.scrollHeight === "number" && "clientHeight" in dom && typeof dom.clientHeight === "number" && dom.scrollHeight > dom.clientHeight) webSeededRef.current = true;
|
|
2122
2154
|
}, [scrollRef, seedDefaultY]);
|
|
2123
2155
|
const laneHeights = (0, react_native_reanimated.useSharedValue)({});
|
|
2124
2156
|
const laneHeightsRef = (0, react.useRef)({});
|
|
@@ -3067,7 +3099,7 @@ function expansionRange(mode, date, weekStartsOn, numberOfDays, weekEndsOn) {
|
|
|
3067
3099
|
* ```
|
|
3068
3100
|
*/
|
|
3069
3101
|
const Calendar = (0, react.forwardRef)(CalendarInner);
|
|
3070
|
-
function CalendarInner({ events, mode, date, onChangeDate, onChangeDateRange, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, dragStepMinutes, showDragHandle, onPressDay, onPressMonth, onLongPressDay, onPressMore, onPressCell, resetPageOnPressCell, onLongPressCell, onCreateEvent, onSelectDrag, selectedDates, selectedRange, fillCellOnSelection, minDate, maxDate, isDateDisabled, onPressDateHeader, maxVisibleEventCount, sortedMonthView, moreLabel, labels, showAdjacentMonths, disableMonthEventCellPress, weekStartsOn = 0, hiddenDays, now, weekdayFormat, numberOfDays, weekEndsOn, renderEvent = DefaultEvent, eventAccessibilityLabel, eventCellStyle, calendarCellStyle, businessHours, renderBusinessHours, renderBackgroundEvent, keyExtractor = defaultKeyExtractor, theme, cellHeight: cellHeightProp, hourHeight = 48, minHourHeight, maxHourHeight, minEventHeight, eventGap, hourColumnWidth, hideHours, timeslots, showAllDayEventCell, showAllDayLabel, refreshControl, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, showWeekNumber, weekNumberPrefix, hourComponent, showSixWeeks, showTitle, swipeEnabled, showVerticalScrollIndicator, verticalScrollEnabled, headerComponent, minHour, maxHour, ampm, showTime, ellipsizeTitle, allDayLabel, scrollOffsetMinutes, showNowIndicator, locale, timeZone, activeDate, isRTL, freeSwipe, renderTimeGridHeader, renderHeaderForMonthView, renderCustomDateForMonth, itemSeparatorComponent, classNames, styles: styleOverrides }, ref) {
|
|
3102
|
+
function CalendarInner({ events, mode, date, onChangeDate, onChangeDateRange, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, dragStepMinutes, showDragHandle, onPressDay, onPressMonth, onLongPressDay, onPressMore, onPressCell, resetPageOnPressCell, onLongPressCell, onCreateEvent, onSelectDrag, selectedDates, selectedRange, fillCellOnSelection, minDate, maxDate, isDateDisabled, onPressDateHeader, maxVisibleEventCount, chipHeight, chipGap, sortedMonthView, moreLabel, labels, showAdjacentMonths, disableMonthEventCellPress, weekStartsOn = 0, hiddenDays, now, weekdayFormat, numberOfDays, weekEndsOn, renderEvent = DefaultEvent, eventAccessibilityLabel, eventCellStyle, calendarCellStyle, businessHours, renderBusinessHours, renderBackgroundEvent, keyExtractor = defaultKeyExtractor, theme, cellHeight: cellHeightProp, hourHeight = 48, minHourHeight, maxHourHeight, minEventHeight, eventGap, hourColumnWidth, hideHours, timeslots, showAllDayEventCell, showAllDayLabel, refreshControl, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, showWeekNumber, weekNumberPrefix, hourComponent, showSixWeeks, showTitle, swipeEnabled, showVerticalScrollIndicator, verticalScrollEnabled, headerComponent, minHour, maxHour, ampm, showTime, ellipsizeTitle, allDayLabel, scrollOffsetMinutes, showNowIndicator, locale, timeZone, activeDate, isRTL, freeSwipe, renderTimeGridHeader, renderHeaderForMonthView, renderCustomDateForMonth, itemSeparatorComponent, classNames, styles: styleOverrides }, ref) {
|
|
3071
3103
|
const mergedTheme = (0, react.useMemo)(() => require_MonthList.mergeTheme(theme), [theme]);
|
|
3072
3104
|
const internalCellHeight = (0, react_native_reanimated.useSharedValue)(hourHeight);
|
|
3073
3105
|
const cellHeight = cellHeightProp ?? internalCellHeight;
|
|
@@ -3148,6 +3180,8 @@ function CalendarInner({ events, mode, date, onChangeDate, onChangeDateRange, on
|
|
|
3148
3180
|
date,
|
|
3149
3181
|
events: displayEvents,
|
|
3150
3182
|
maxVisibleEventCount,
|
|
3183
|
+
chipHeight,
|
|
3184
|
+
chipGap,
|
|
3151
3185
|
weekStartsOn,
|
|
3152
3186
|
hiddenDays,
|
|
3153
3187
|
weekdayFormat,
|
|
@@ -3298,6 +3332,10 @@ function CalendarInner({ events, mode, date, onChangeDate, onChangeDateRange, on
|
|
|
3298
3332
|
const MOVE_ACTIVATE_MS = 250;
|
|
3299
3333
|
const DRAG_ACTIVATE_PX = 8;
|
|
3300
3334
|
const MINUTES_PER_HOUR = 60;
|
|
3335
|
+
const NO_MOVE_EXTRA = {
|
|
3336
|
+
top: 0,
|
|
3337
|
+
hours: 0
|
|
3338
|
+
};
|
|
3301
3339
|
const isWeb = react_native.Platform.OS === "web";
|
|
3302
3340
|
const clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
|
|
3303
3341
|
const GUTTER_WIDTH = 56;
|
|
@@ -3430,16 +3468,42 @@ function ResourceBar({ pe, vertical, hourSize, left, top, width, height, rendere
|
|
|
3430
3468
|
case "move-previous-lane": commit(0, 0, -1);
|
|
3431
3469
|
}
|
|
3432
3470
|
} : void 0;
|
|
3433
|
-
const
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3471
|
+
const eventStartMs = pe.event.start.getTime();
|
|
3472
|
+
const eventEndMs = pe.event.end.getTime();
|
|
3473
|
+
const clipped = pe.continuesBefore || pe.continuesAfter;
|
|
3474
|
+
const barHours = pe.durationHours;
|
|
3475
|
+
const moveExtra = (0, react_native_reanimated.useDerivedValue)(() => {
|
|
3476
|
+
if (clipped || moveX.value === 0 || hourSize <= 0) return NO_MOVE_EXTRA;
|
|
3477
|
+
const minutes = Math.round(moveX.value / hourSize * MINUTES_PER_HOUR);
|
|
3478
|
+
const from = new Date(eventStartMs);
|
|
3479
|
+
const to = new Date(eventEndMs);
|
|
3480
|
+
const moved = (0, _super_calendar_core.movedClockSpan)(from, to, minutes);
|
|
3481
|
+
return {
|
|
3482
|
+
top: moved.startHours - minutes / MINUTES_PER_HOUR,
|
|
3483
|
+
hours: moved.hours - barHours
|
|
3484
|
+
};
|
|
3485
|
+
}, [
|
|
3486
|
+
clipped,
|
|
3487
|
+
hourSize,
|
|
3488
|
+
eventStartMs,
|
|
3489
|
+
eventEndMs,
|
|
3490
|
+
barHours
|
|
3491
|
+
]);
|
|
3492
|
+
const barStyle = (0, react_native_reanimated.useAnimatedStyle)(() => {
|
|
3493
|
+
const shift = moveX.value + moveExtra.value.top * hourSize;
|
|
3494
|
+
const grow = resizeW.value + moveExtra.value.hours * hourSize;
|
|
3495
|
+
return vertical ? {
|
|
3496
|
+
transform: [{ translateY: shift }, { translateX: moveCross.value }],
|
|
3497
|
+
height: Math.max(height + grow, 2)
|
|
3498
|
+
} : {
|
|
3499
|
+
transform: [{ translateX: shift }, { translateY: moveCross.value }],
|
|
3500
|
+
width: Math.max(width + grow, 2)
|
|
3501
|
+
};
|
|
3439
3502
|
}, [
|
|
3440
3503
|
vertical,
|
|
3441
3504
|
width,
|
|
3442
|
-
height
|
|
3505
|
+
height,
|
|
3506
|
+
hourSize
|
|
3443
3507
|
]);
|
|
3444
3508
|
const laneId = resources[laneIndex]?.id ?? "";
|
|
3445
3509
|
const moveGesture = (0, react.useMemo)(() => react_native_gesture_handler.Gesture.Pan().enabled(draggable).activateAfterLongPress(MOVE_ACTIVATE_MS).onStart(() => {
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as withEventAccessibilityLabel, c as createSlots, d as useCalendarLabels, f as CalendarThemeProvider, g as useCalendarTheme, h as mergeTheme, i as MonthView, l as useSlots, m as defaultTheme, n as DefaultMonthEvent, o as useWebPagerKeys, p as darkTheme, r as MonthPager, s as SlotStylesProvider, t as MonthList, u as CalendarLabelsContext } from "./MonthList-
|
|
1
|
+
import { a as withEventAccessibilityLabel, c as createSlots, d as useCalendarLabels, f as CalendarThemeProvider, g as useCalendarTheme, h as mergeTheme, i as MonthView, l as useSlots, m as defaultTheme, n as DefaultMonthEvent, o as useWebPagerKeys, p as darkTheme, r as MonthPager, s as SlotStylesProvider, t as MonthList, u as CalendarLabelsContext } from "./MonthList-DWCH3GT5.mjs";
|
|
2
2
|
import { addDays, addMonths, addWeeks, differenceInCalendarDays, endOfDay, endOfMonth, endOfWeek, endOfYear, format, getHours, getISOWeek, getMinutes, isSameDay, startOfDay, startOfMonth, startOfWeek, startOfYear } from "date-fns";
|
|
3
3
|
import { createContext, forwardRef, memo, useCallback, useContext, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
4
4
|
import Animated, { runOnJS, useAnimatedReaction, useAnimatedRef, useAnimatedScrollHandler, useAnimatedStyle, useDerivedValue, useReducedMotion, useSharedValue } from "react-native-reanimated";
|
|
5
|
-
import { backgroundBandsForDay, backgroundBandsForDay as backgroundBandsForDay$1, bandRounding, buildMonthGrid, buildMonthWeeks, buildMonthWeeks as buildMonthWeeks$1, cellRangeFromDrag, clampMoveStartMinutes, closedHourBands, dayAccessibilityLabel, dayBadgeKind, daySelectionState, daySelectionState as daySelectionState$1, defaultCalendarLabels, eventAccessibilityLabel, eventChipLayout, eventTimeLabel, eventsInTimeZone, eventsInTimeZone as eventsInTimeZone$1, expandRecurringEvents, expandRecurringEvents as expandRecurringEvents$1, filterHiddenDays, formatHour, getIsToday, getIsToday as getIsToday$1, getViewDays, getViewDays as getViewDays$1, getWeekDays, getWeekDays as getWeekDays$1, getYearMonths, groupEventsByDay, isAllDayEvent, isAllDayEvent as isAllDayEvent$1, isBackgroundEvent, isBackgroundEvent as isBackgroundEvent$1, isDateSelectable, isDateSelectable as isDateSelectable$1, isRangeEndpoint, isSameCalendarDay, isSameCalendarDay as isSameCalendarDay$1, isWeekend, isWeekend as isWeekend$1, isWithinDateRange, layoutDayEvents, layoutDayEvents as layoutDayEvents$1, layoutMonthWeek, minutesIntoDay, monthCreateRange, nextDateRange, overlapsOtherEvents, pageStepDays, parseICalendar, rangeBandKind, resolveCalendarLabels, resolveDraggedBounds, shiftMinutes, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, useDateRange, useEventSource, useMonthGrid, useNow, useNow as useNow$1, viewDayCount, weekdayFormatToken, weekdayFormatToken as weekdayFormatToken$1 } from "@super-calendar/core";
|
|
5
|
+
import { backgroundBandsForDay, backgroundBandsForDay as backgroundBandsForDay$1, bandRounding, buildMonthGrid, buildMonthWeeks, buildMonthWeeks as buildMonthWeeks$1, cellRangeFromDrag, clampMoveStartMinutes, clockHoursBetween, closedHourBands, dayAccessibilityLabel, dayBadgeKind, daySelectionState, daySelectionState as daySelectionState$1, defaultCalendarLabels, eventAccessibilityLabel, eventChipLayout, eventTimeLabel, eventsInTimeZone, eventsInTimeZone as eventsInTimeZone$1, expandRecurringEvents, expandRecurringEvents as expandRecurringEvents$1, filterHiddenDays, formatHour, getIsToday, getIsToday as getIsToday$1, getViewDays, getViewDays as getViewDays$1, getWeekDays, getWeekDays as getWeekDays$1, getYearMonths, groupEventsByDay, isAllDayEvent, isAllDayEvent as isAllDayEvent$1, isBackgroundEvent, isBackgroundEvent as isBackgroundEvent$1, isDateSelectable, isDateSelectable as isDateSelectable$1, isRangeEndpoint, isSameCalendarDay, isSameCalendarDay as isSameCalendarDay$1, isWeekend, isWeekend as isWeekend$1, isWithinDateRange, layoutDayEvents, layoutDayEvents as layoutDayEvents$1, layoutMonthWeek, minutesIntoDay, monthCreateRange, movedClockSpan, nextDateRange, overlapsOtherEvents, pageStepDays, parseICalendar, rangeBandKind, resolveCalendarLabels, resolveDraggedBounds, shiftMinutes, snapDeltaMinutes, titleEllipsizeMode, titleNumberOfLines, toICalendar, toZonedTime, useDateRange, useEventSource, useMonthGrid, useNow, useNow as useNow$1, viewDayCount, wallClockHours, weekdayFormatToken, weekdayFormatToken as weekdayFormatToken$1 } from "@super-calendar/core";
|
|
6
6
|
import { PixelRatio, Platform, Pressable, ScrollView, StyleSheet, Text, TouchableOpacity, View, useWindowDimensions } from "react-native";
|
|
7
7
|
import { Gesture, GestureDetector } from "react-native-gesture-handler";
|
|
8
8
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -754,9 +754,11 @@ function PreviewDay({ move, cellHeight, dayWidth, minHour, mode, renderEvent: Re
|
|
|
754
754
|
const start = shiftMinutes(new Date(startTimestamp), dayOffsets[target] + minuteDelta).getTime();
|
|
755
755
|
const end = start + duration;
|
|
756
756
|
const visible = !lifted.value && start < dayEnd && end > dayStart;
|
|
757
|
+
const segStart = new Date(Math.max(start, dayStart));
|
|
758
|
+
const segEnd = new Date(Math.min(end, dayEnd));
|
|
757
759
|
return {
|
|
758
|
-
top: (
|
|
759
|
-
hours: visible ? Math.max((
|
|
760
|
+
top: wallClockHours(segStart, new Date(dayStart), new Date(dayEnd)),
|
|
761
|
+
hours: visible ? Math.max(clockHoursBetween(segStart, segEnd), .25) : 0,
|
|
760
762
|
continuesBefore: start < dayStart,
|
|
761
763
|
continuesAfter: end > dayEnd
|
|
762
764
|
};
|
|
@@ -819,6 +821,10 @@ const isWeb$1 = Platform.OS === "web";
|
|
|
819
821
|
const MINUTES_PER_HOUR$1 = 60;
|
|
820
822
|
const HOURS_PER_DAY = 24;
|
|
821
823
|
const MINUTES_PER_DAY = 1440;
|
|
824
|
+
const NO_MOVE_EXTRA$1 = {
|
|
825
|
+
top: 0,
|
|
826
|
+
hours: 0
|
|
827
|
+
};
|
|
822
828
|
const PAGE_WINDOW = 180;
|
|
823
829
|
const PAGE_VIEWABILITY = { itemVisiblePercentThreshold: 90 };
|
|
824
830
|
const PAGER_IDLE_MS = 150;
|
|
@@ -956,9 +962,34 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
956
962
|
minutes: startHours * MINUTES_PER_HOUR$1,
|
|
957
963
|
ownsStart
|
|
958
964
|
}), [startHours, ownsStart]);
|
|
959
|
-
const
|
|
965
|
+
const eventStartMs = positioned.event.start.getTime();
|
|
966
|
+
const eventEndMs = positioned.event.end.getTime();
|
|
967
|
+
const moveExtra = useDerivedValue(() => {
|
|
968
|
+
if (multiDay || lifted.value || cellHeight.value <= 0) return NO_MOVE_EXTRA$1;
|
|
969
|
+
if (moveOffset.value === 0 && moveOffsetX.value === 0) return NO_MOVE_EXTRA$1;
|
|
970
|
+
const columnDelta = dayWidth > 0 ? Math.round(moveOffsetX.value / dayWidth) : 0;
|
|
971
|
+
const target = Math.min(Math.max(dayIndex + columnDelta, 0), dayCount - 1);
|
|
972
|
+
const minutes = Math.round(moveOffset.value / cellHeight.value * MINUTES_PER_HOUR$1) + (dayOrdinals[target] - dayOrdinals[dayIndex]) * MINUTES_PER_DAY;
|
|
973
|
+
const from = new Date(eventStartMs);
|
|
974
|
+
const to = new Date(eventEndMs);
|
|
975
|
+
const moved = movedClockSpan(from, to, minutes);
|
|
976
|
+
return {
|
|
977
|
+
top: moved.startHours - minutes / MINUTES_PER_HOUR$1,
|
|
978
|
+
hours: moved.hours - durationHours
|
|
979
|
+
};
|
|
980
|
+
}, [
|
|
981
|
+
multiDay,
|
|
982
|
+
dayWidth,
|
|
983
|
+
dayIndex,
|
|
984
|
+
dayCount,
|
|
985
|
+
dayOrdinals,
|
|
986
|
+
eventStartMs,
|
|
987
|
+
eventEndMs,
|
|
988
|
+
durationHours
|
|
989
|
+
]);
|
|
990
|
+
const boxHeight = useDerivedValue(() => Math.max((durationHours + moveExtra.value.hours) * cellHeight.value + resizeDelta.value - resizeStartDelta.value, minEventHeight), [durationHours, minEventHeight]);
|
|
960
991
|
const visibleBoxHeight = useDerivedValue(() => {
|
|
961
|
-
const top = (startHours - minHour) * cellHeight.value + moveOffset.value + resizeStartDelta.value;
|
|
992
|
+
const top = (startHours + moveExtra.value.top - minHour) * cellHeight.value + moveOffset.value + resizeStartDelta.value;
|
|
962
993
|
const dayEnd = (HOURS_PER_DAY - minHour) * cellHeight.value;
|
|
963
994
|
return Math.max(Math.min(boxHeight.value, dayEnd - top), minEventHeight);
|
|
964
995
|
}, [
|
|
@@ -968,7 +999,7 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
968
999
|
]);
|
|
969
1000
|
const boxStyle = useAnimatedStyle(() => {
|
|
970
1001
|
return {
|
|
971
|
-
top: (startHours - minHour) * cellHeight.value + moveOffset.value + resizeStartDelta.value,
|
|
1002
|
+
top: (startHours + moveExtra.value.top - minHour) * cellHeight.value + moveOffset.value + resizeStartDelta.value,
|
|
972
1003
|
height: visibleBoxHeight.value,
|
|
973
1004
|
transform: [{ translateX: moveOffsetX.value }],
|
|
974
1005
|
zIndex: dragZ.value,
|
|
@@ -981,7 +1012,8 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
981
1012
|
]);
|
|
982
1013
|
const spillHeight = useDerivedValue(() => {
|
|
983
1014
|
if (multiDay || !moving.value || lifted.value || cellHeight.value <= 0) return 0;
|
|
984
|
-
const
|
|
1015
|
+
const extra = moveExtra.value;
|
|
1016
|
+
const overflowHours = startHours + extra.top + moveOffset.value / cellHeight.value + durationHours + extra.hours - HOURS_PER_DAY;
|
|
985
1017
|
if (overflowHours <= 0) return 0;
|
|
986
1018
|
const columnDelta = dayWidth > 0 ? Math.round(moveOffsetX.value / dayWidth) : 0;
|
|
987
1019
|
const target = Math.min(Math.max(dayIndex + columnDelta, 0), dayCount - 1);
|
|
@@ -2094,7 +2126,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2094
2126
|
animated: false
|
|
2095
2127
|
});
|
|
2096
2128
|
const dom = node.getScrollableNode();
|
|
2097
|
-
if (dom && dom.scrollHeight > dom.clientHeight) webSeededRef.current = true;
|
|
2129
|
+
if (dom != null && typeof dom === "object" && "scrollHeight" in dom && typeof dom.scrollHeight === "number" && "clientHeight" in dom && typeof dom.clientHeight === "number" && dom.scrollHeight > dom.clientHeight) webSeededRef.current = true;
|
|
2098
2130
|
}, [scrollRef, seedDefaultY]);
|
|
2099
2131
|
const laneHeights = useSharedValue({});
|
|
2100
2132
|
const laneHeightsRef = useRef({});
|
|
@@ -3043,7 +3075,7 @@ function expansionRange(mode, date, weekStartsOn, numberOfDays, weekEndsOn) {
|
|
|
3043
3075
|
* ```
|
|
3044
3076
|
*/
|
|
3045
3077
|
const Calendar = forwardRef(CalendarInner);
|
|
3046
|
-
function CalendarInner({ events, mode, date, onChangeDate, onChangeDateRange, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, dragStepMinutes, showDragHandle, onPressDay, onPressMonth, onLongPressDay, onPressMore, onPressCell, resetPageOnPressCell, onLongPressCell, onCreateEvent, onSelectDrag, selectedDates, selectedRange, fillCellOnSelection, minDate, maxDate, isDateDisabled, onPressDateHeader, maxVisibleEventCount, sortedMonthView, moreLabel, labels, showAdjacentMonths, disableMonthEventCellPress, weekStartsOn = 0, hiddenDays, now, weekdayFormat, numberOfDays, weekEndsOn, renderEvent = DefaultEvent, eventAccessibilityLabel, eventCellStyle, calendarCellStyle, businessHours, renderBusinessHours, renderBackgroundEvent, keyExtractor = defaultKeyExtractor, theme, cellHeight: cellHeightProp, hourHeight = 48, minHourHeight, maxHourHeight, minEventHeight, eventGap, hourColumnWidth, hideHours, timeslots, showAllDayEventCell, showAllDayLabel, refreshControl, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, showWeekNumber, weekNumberPrefix, hourComponent, showSixWeeks, showTitle, swipeEnabled, showVerticalScrollIndicator, verticalScrollEnabled, headerComponent, minHour, maxHour, ampm, showTime, ellipsizeTitle, allDayLabel, scrollOffsetMinutes, showNowIndicator, locale, timeZone, activeDate, isRTL, freeSwipe, renderTimeGridHeader, renderHeaderForMonthView, renderCustomDateForMonth, itemSeparatorComponent, classNames, styles: styleOverrides }, ref) {
|
|
3078
|
+
function CalendarInner({ events, mode, date, onChangeDate, onChangeDateRange, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, dragStepMinutes, showDragHandle, onPressDay, onPressMonth, onLongPressDay, onPressMore, onPressCell, resetPageOnPressCell, onLongPressCell, onCreateEvent, onSelectDrag, selectedDates, selectedRange, fillCellOnSelection, minDate, maxDate, isDateDisabled, onPressDateHeader, maxVisibleEventCount, chipHeight, chipGap, sortedMonthView, moreLabel, labels, showAdjacentMonths, disableMonthEventCellPress, weekStartsOn = 0, hiddenDays, now, weekdayFormat, numberOfDays, weekEndsOn, renderEvent = DefaultEvent, eventAccessibilityLabel, eventCellStyle, calendarCellStyle, businessHours, renderBusinessHours, renderBackgroundEvent, keyExtractor = defaultKeyExtractor, theme, cellHeight: cellHeightProp, hourHeight = 48, minHourHeight, maxHourHeight, minEventHeight, eventGap, hourColumnWidth, hideHours, timeslots, showAllDayEventCell, showAllDayLabel, refreshControl, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, showWeekNumber, weekNumberPrefix, hourComponent, showSixWeeks, showTitle, swipeEnabled, showVerticalScrollIndicator, verticalScrollEnabled, headerComponent, minHour, maxHour, ampm, showTime, ellipsizeTitle, allDayLabel, scrollOffsetMinutes, showNowIndicator, locale, timeZone, activeDate, isRTL, freeSwipe, renderTimeGridHeader, renderHeaderForMonthView, renderCustomDateForMonth, itemSeparatorComponent, classNames, styles: styleOverrides }, ref) {
|
|
3047
3079
|
const mergedTheme = useMemo(() => mergeTheme(theme), [theme]);
|
|
3048
3080
|
const internalCellHeight = useSharedValue(hourHeight);
|
|
3049
3081
|
const cellHeight = cellHeightProp ?? internalCellHeight;
|
|
@@ -3124,6 +3156,8 @@ function CalendarInner({ events, mode, date, onChangeDate, onChangeDateRange, on
|
|
|
3124
3156
|
date,
|
|
3125
3157
|
events: displayEvents,
|
|
3126
3158
|
maxVisibleEventCount,
|
|
3159
|
+
chipHeight,
|
|
3160
|
+
chipGap,
|
|
3127
3161
|
weekStartsOn,
|
|
3128
3162
|
hiddenDays,
|
|
3129
3163
|
weekdayFormat,
|
|
@@ -3274,6 +3308,10 @@ function CalendarInner({ events, mode, date, onChangeDate, onChangeDateRange, on
|
|
|
3274
3308
|
const MOVE_ACTIVATE_MS = 250;
|
|
3275
3309
|
const DRAG_ACTIVATE_PX = 8;
|
|
3276
3310
|
const MINUTES_PER_HOUR = 60;
|
|
3311
|
+
const NO_MOVE_EXTRA = {
|
|
3312
|
+
top: 0,
|
|
3313
|
+
hours: 0
|
|
3314
|
+
};
|
|
3277
3315
|
const isWeb = Platform.OS === "web";
|
|
3278
3316
|
const clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
|
|
3279
3317
|
const GUTTER_WIDTH = 56;
|
|
@@ -3406,16 +3444,42 @@ function ResourceBar({ pe, vertical, hourSize, left, top, width, height, rendere
|
|
|
3406
3444
|
case "move-previous-lane": commit(0, 0, -1);
|
|
3407
3445
|
}
|
|
3408
3446
|
} : void 0;
|
|
3409
|
-
const
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3447
|
+
const eventStartMs = pe.event.start.getTime();
|
|
3448
|
+
const eventEndMs = pe.event.end.getTime();
|
|
3449
|
+
const clipped = pe.continuesBefore || pe.continuesAfter;
|
|
3450
|
+
const barHours = pe.durationHours;
|
|
3451
|
+
const moveExtra = useDerivedValue(() => {
|
|
3452
|
+
if (clipped || moveX.value === 0 || hourSize <= 0) return NO_MOVE_EXTRA;
|
|
3453
|
+
const minutes = Math.round(moveX.value / hourSize * MINUTES_PER_HOUR);
|
|
3454
|
+
const from = new Date(eventStartMs);
|
|
3455
|
+
const to = new Date(eventEndMs);
|
|
3456
|
+
const moved = movedClockSpan(from, to, minutes);
|
|
3457
|
+
return {
|
|
3458
|
+
top: moved.startHours - minutes / MINUTES_PER_HOUR,
|
|
3459
|
+
hours: moved.hours - barHours
|
|
3460
|
+
};
|
|
3461
|
+
}, [
|
|
3462
|
+
clipped,
|
|
3463
|
+
hourSize,
|
|
3464
|
+
eventStartMs,
|
|
3465
|
+
eventEndMs,
|
|
3466
|
+
barHours
|
|
3467
|
+
]);
|
|
3468
|
+
const barStyle = useAnimatedStyle(() => {
|
|
3469
|
+
const shift = moveX.value + moveExtra.value.top * hourSize;
|
|
3470
|
+
const grow = resizeW.value + moveExtra.value.hours * hourSize;
|
|
3471
|
+
return vertical ? {
|
|
3472
|
+
transform: [{ translateY: shift }, { translateX: moveCross.value }],
|
|
3473
|
+
height: Math.max(height + grow, 2)
|
|
3474
|
+
} : {
|
|
3475
|
+
transform: [{ translateX: shift }, { translateY: moveCross.value }],
|
|
3476
|
+
width: Math.max(width + grow, 2)
|
|
3477
|
+
};
|
|
3415
3478
|
}, [
|
|
3416
3479
|
vertical,
|
|
3417
3480
|
width,
|
|
3418
|
-
height
|
|
3481
|
+
height,
|
|
3482
|
+
hourSize
|
|
3419
3483
|
]);
|
|
3420
3484
|
const laneId = resources[laneIndex]?.id ?? "";
|
|
3421
3485
|
const moveGesture = useMemo(() => Gesture.Pan().enabled(draggable).activateAfterLongPress(MOVE_ACTIVATE_MS).onStart(() => {
|
package/dist/picker.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as WeekStartsOn, C as ICalendarEvent, D as RenderEventArgs, E as RenderEvent, F as darkTheme, I as defaultTheme, L as mergeTheme, M as CalendarTheme, N as CalendarThemeProvider, P as PartialCalendarTheme, R as useCalendarTheme, S as EventKeyExtractor, _ as CalendarMode, a as MonthPager, c as MonthViewProps, h as CalendarEvent, n as MonthList, o as MonthPagerProps, r as MonthListProps, s as MonthView, t as DefaultMonthEvent } from "./DefaultMonthEvent-
|
|
1
|
+
import { A as WeekStartsOn, C as ICalendarEvent, D as RenderEventArgs, E as RenderEvent, F as darkTheme, I as defaultTheme, L as mergeTheme, M as CalendarTheme, N as CalendarThemeProvider, P as PartialCalendarTheme, R as useCalendarTheme, S as EventKeyExtractor, _ as CalendarMode, a as MonthPager, c as MonthViewProps, h as CalendarEvent, n as MonthList, o as MonthPagerProps, r as MonthListProps, s as MonthView, t as DefaultMonthEvent } from "./DefaultMonthEvent-BDD7GgL8.mjs";
|
|
2
2
|
import { DateRange, DateSelectionConstraints, DaySelectionState, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, UseDateRangeOptions, UseMonthGridOptions, buildMonthGrid, buildMonthWeeks, daySelectionState, getIsToday, getWeekDays, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, minutesIntoDay, nextDateRange, useDateRange, useMonthGrid } from "@super-calendar/core";
|
|
3
3
|
export { type CalendarEvent, type CalendarMode, type CalendarTheme, CalendarThemeProvider, type DateRange, type DateSelectionConstraints, type DaySelectionState, DefaultMonthEvent, type EventKeyExtractor, type ICalendarEvent, type MonthGrid, type MonthGridDay, type MonthGridWeek, type MonthGridWeekday, MonthList, type MonthListProps, MonthPager, type MonthPagerProps, MonthView, type MonthViewProps, type PartialCalendarTheme, type RenderEvent, type RenderEventArgs, type UseDateRangeOptions, type UseMonthGridOptions, type WeekStartsOn, buildMonthGrid, buildMonthWeeks, darkTheme, daySelectionState, defaultTheme, getIsToday, getWeekDays, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, mergeTheme, minutesIntoDay, nextDateRange, useCalendarTheme, useDateRange, useMonthGrid };
|
package/dist/picker.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as WeekStartsOn, C as ICalendarEvent, D as RenderEventArgs, E as RenderEvent, F as darkTheme, I as defaultTheme, L as mergeTheme, M as CalendarTheme, N as CalendarThemeProvider, P as PartialCalendarTheme, R as useCalendarTheme, S as EventKeyExtractor, _ as CalendarMode, a as MonthPager, c as MonthViewProps, h as CalendarEvent, n as MonthList, o as MonthPagerProps, r as MonthListProps, s as MonthView, t as DefaultMonthEvent } from "./DefaultMonthEvent-
|
|
1
|
+
import { A as WeekStartsOn, C as ICalendarEvent, D as RenderEventArgs, E as RenderEvent, F as darkTheme, I as defaultTheme, L as mergeTheme, M as CalendarTheme, N as CalendarThemeProvider, P as PartialCalendarTheme, R as useCalendarTheme, S as EventKeyExtractor, _ as CalendarMode, a as MonthPager, c as MonthViewProps, h as CalendarEvent, n as MonthList, o as MonthPagerProps, r as MonthListProps, s as MonthView, t as DefaultMonthEvent } from "./DefaultMonthEvent-ggwYo7Fy.js";
|
|
2
2
|
import { DateRange, DateSelectionConstraints, DaySelectionState, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, UseDateRangeOptions, UseMonthGridOptions, buildMonthGrid, buildMonthWeeks, daySelectionState, getIsToday, getWeekDays, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, minutesIntoDay, nextDateRange, useDateRange, useMonthGrid } from "@super-calendar/core";
|
|
3
3
|
export { type CalendarEvent, type CalendarMode, type CalendarTheme, CalendarThemeProvider, type DateRange, type DateSelectionConstraints, type DaySelectionState, DefaultMonthEvent, type EventKeyExtractor, type ICalendarEvent, type MonthGrid, type MonthGridDay, type MonthGridWeek, type MonthGridWeekday, MonthList, type MonthListProps, MonthPager, type MonthPagerProps, MonthView, type MonthViewProps, type PartialCalendarTheme, type RenderEvent, type RenderEventArgs, type UseDateRangeOptions, type UseMonthGridOptions, type WeekStartsOn, buildMonthGrid, buildMonthWeeks, darkTheme, daySelectionState, defaultTheme, getIsToday, getWeekDays, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, mergeTheme, minutesIntoDay, nextDateRange, useCalendarTheme, useDateRange, useMonthGrid };
|
package/dist/picker.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_MonthList = require("./MonthList-
|
|
2
|
+
const require_MonthList = require("./MonthList-D4_LBnbU.js");
|
|
3
3
|
let _super_calendar_core = require("@super-calendar/core");
|
|
4
4
|
exports.CalendarThemeProvider = require_MonthList.CalendarThemeProvider;
|
|
5
5
|
exports.DefaultMonthEvent = require_MonthList.DefaultMonthEvent;
|
package/dist/picker.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { f as CalendarThemeProvider, g as useCalendarTheme, h as mergeTheme, i as MonthView, m as defaultTheme, n as DefaultMonthEvent, p as darkTheme, r as MonthPager, t as MonthList } from "./MonthList-
|
|
1
|
+
import { f as CalendarThemeProvider, g as useCalendarTheme, h as mergeTheme, i as MonthView, m as defaultTheme, n as DefaultMonthEvent, p as darkTheme, r as MonthPager, t as MonthList } from "./MonthList-DWCH3GT5.mjs";
|
|
2
2
|
import { buildMonthGrid, buildMonthWeeks, daySelectionState, getIsToday, getWeekDays, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, minutesIntoDay, nextDateRange, useDateRange, useMonthGrid } from "@super-calendar/core";
|
|
3
3
|
export { CalendarThemeProvider, DefaultMonthEvent, MonthList, MonthPager, MonthView, buildMonthGrid, buildMonthWeeks, darkTheme, daySelectionState, defaultTheme, getIsToday, getWeekDays, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, mergeTheme, minutesIntoDay, nextDateRange, useCalendarTheme, useDateRange, useMonthGrid };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@super-calendar/native",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.14.1",
|
|
4
4
|
"description": "Gesture-driven, virtualized month / week / day calendar and date picker for React Native (and web via react-native-web).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agenda",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"access": "public"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@super-calendar/core": "2.
|
|
67
|
+
"@super-calendar/core": "2.14.1"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
70
|
"@legendapp/list": ">=3",
|
|
@@ -169,6 +169,10 @@ export type CalendarProps<T> = SlotStyleProps<CalendarSlot> & {
|
|
|
169
169
|
* fixed cap. Pass an explicit value when using a custom `renderEvent`.
|
|
170
170
|
*/
|
|
171
171
|
maxVisibleEventCount?: number;
|
|
172
|
+
/** Month chip height in pixels; omit to keep the renderer default. */
|
|
173
|
+
chipHeight?: number;
|
|
174
|
+
/** Gap between month chip rows in pixels (default 2). */
|
|
175
|
+
chipGap?: number;
|
|
172
176
|
/** Sort each month day's events by start. Default true. */
|
|
173
177
|
sortedMonthView?: boolean;
|
|
174
178
|
/** Month overflow label template; `{moreCount}` is replaced. Default "{moreCount} More". */
|
|
@@ -489,6 +493,8 @@ function CalendarInner<T>(
|
|
|
489
493
|
isDateDisabled,
|
|
490
494
|
onPressDateHeader,
|
|
491
495
|
maxVisibleEventCount,
|
|
496
|
+
chipHeight,
|
|
497
|
+
chipGap,
|
|
492
498
|
sortedMonthView,
|
|
493
499
|
moreLabel,
|
|
494
500
|
labels,
|
|
@@ -673,6 +679,8 @@ function CalendarInner<T>(
|
|
|
673
679
|
date={date}
|
|
674
680
|
events={displayEvents}
|
|
675
681
|
maxVisibleEventCount={maxVisibleEventCount}
|
|
682
|
+
chipHeight={chipHeight}
|
|
683
|
+
chipGap={chipGap}
|
|
676
684
|
weekStartsOn={weekStartsOn}
|
|
677
685
|
hiddenDays={hiddenDays}
|
|
678
686
|
weekdayFormat={weekdayFormat}
|
|
@@ -12,7 +12,16 @@ import {
|
|
|
12
12
|
type Locale,
|
|
13
13
|
startOfMonth,
|
|
14
14
|
} from "date-fns";
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
type ComponentRef,
|
|
17
|
+
memo,
|
|
18
|
+
type ReactElement,
|
|
19
|
+
useCallback,
|
|
20
|
+
useEffect,
|
|
21
|
+
useMemo,
|
|
22
|
+
useRef,
|
|
23
|
+
useState,
|
|
24
|
+
} from "react";
|
|
16
25
|
import {
|
|
17
26
|
type LayoutChangeEvent,
|
|
18
27
|
type NativeScrollEvent,
|
|
@@ -98,6 +107,10 @@ export type MonthListProps<T> = {
|
|
|
98
107
|
*/
|
|
99
108
|
monthHeaderHeight?: number;
|
|
100
109
|
maxVisibleEventCount?: number;
|
|
110
|
+
/** Month chip height in pixels; omit to keep the renderer default. */
|
|
111
|
+
chipHeight?: number;
|
|
112
|
+
/** Gap between month chip rows in pixels (default 2). */
|
|
113
|
+
chipGap?: number;
|
|
101
114
|
locale?: Locale;
|
|
102
115
|
sortedMonthView?: boolean;
|
|
103
116
|
moreLabel?: string;
|
|
@@ -153,6 +166,8 @@ function MonthListInner<T>({
|
|
|
153
166
|
weekRowHeight: weekRowHeightProp,
|
|
154
167
|
monthHeaderHeight = DEFAULT_MONTH_HEADER_HEIGHT,
|
|
155
168
|
maxVisibleEventCount,
|
|
169
|
+
chipHeight,
|
|
170
|
+
chipGap,
|
|
156
171
|
locale,
|
|
157
172
|
sortedMonthView,
|
|
158
173
|
moreLabel,
|
|
@@ -209,8 +224,8 @@ function MonthListInner<T>({
|
|
|
209
224
|
// `firstViewableIndex` (the web `inert` cutoff must stay current). Selection
|
|
210
225
|
// needs no entry: it reaches MonthView through context.
|
|
211
226
|
const listExtraData = useMemo(
|
|
212
|
-
() => ({ events, activeDate, firstViewableIndex }),
|
|
213
|
-
[events, activeDate, firstViewableIndex],
|
|
227
|
+
() => ({ events, activeDate, firstViewableIndex, chipHeight, chipGap }),
|
|
228
|
+
[events, activeDate, firstViewableIndex, chipHeight, chipGap],
|
|
214
229
|
);
|
|
215
230
|
|
|
216
231
|
// A fixed window of months anchored once, aligned to the month start.
|
|
@@ -466,6 +481,8 @@ function MonthListInner<T>({
|
|
|
466
481
|
showTitle={false}
|
|
467
482
|
showWeekdays={false}
|
|
468
483
|
maxVisibleEventCount={maxVisibleEventCount}
|
|
484
|
+
chipHeight={chipHeight}
|
|
485
|
+
chipGap={chipGap}
|
|
469
486
|
weekStartsOn={weekStartsOn}
|
|
470
487
|
locale={locale}
|
|
471
488
|
sortedMonthView={sortedMonthView}
|
|
@@ -503,6 +520,8 @@ function MonthListInner<T>({
|
|
|
503
520
|
locale,
|
|
504
521
|
events,
|
|
505
522
|
maxVisibleEventCount,
|
|
523
|
+
chipHeight,
|
|
524
|
+
chipGap,
|
|
506
525
|
weekStartsOn,
|
|
507
526
|
sortedMonthView,
|
|
508
527
|
moreLabel,
|
|
@@ -603,7 +622,7 @@ function MonthBlock({
|
|
|
603
622
|
inert: boolean;
|
|
604
623
|
children: React.ReactNode;
|
|
605
624
|
}) {
|
|
606
|
-
const ref = useRef<View
|
|
625
|
+
const ref = useRef<ComponentRef<typeof View>>(null);
|
|
607
626
|
useEffect(() => {
|
|
608
627
|
if (!isWeb) return;
|
|
609
628
|
const node = ref.current as unknown as { inert?: boolean } | null;
|
|
@@ -5,7 +5,16 @@ import {
|
|
|
5
5
|
type OnViewableItemsChangedInfo,
|
|
6
6
|
} from "@legendapp/list/react-native";
|
|
7
7
|
import { addMonths, differenceInCalendarMonths, format, type Locale, startOfMonth } from "date-fns";
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
type ComponentRef,
|
|
10
|
+
memo,
|
|
11
|
+
type ReactElement,
|
|
12
|
+
useCallback,
|
|
13
|
+
useEffect,
|
|
14
|
+
useMemo,
|
|
15
|
+
useRef,
|
|
16
|
+
useState,
|
|
17
|
+
} from "react";
|
|
9
18
|
import {
|
|
10
19
|
Platform,
|
|
11
20
|
StyleSheet,
|
|
@@ -57,6 +66,10 @@ export type MonthPagerProps<T> = {
|
|
|
57
66
|
date: Date;
|
|
58
67
|
events: CalendarEvent<T>[];
|
|
59
68
|
maxVisibleEventCount?: number;
|
|
69
|
+
/** Month chip height in pixels; omit to keep the theme default. */
|
|
70
|
+
chipHeight?: number;
|
|
71
|
+
/** Gap between month chip rows in pixels (default 2). */
|
|
72
|
+
chipGap?: number;
|
|
60
73
|
weekStartsOn: WeekStartsOn;
|
|
61
74
|
/** Weekdays (0=Sunday…6=Saturday) hidden from the grid, e.g. `[0, 6]` for weekends off. */
|
|
62
75
|
hiddenDays?: number[];
|
|
@@ -121,6 +134,8 @@ function MonthPagerInner<T>({
|
|
|
121
134
|
date,
|
|
122
135
|
events,
|
|
123
136
|
maxVisibleEventCount,
|
|
137
|
+
chipHeight,
|
|
138
|
+
chipGap,
|
|
124
139
|
weekStartsOn,
|
|
125
140
|
hiddenDays,
|
|
126
141
|
weekdayFormat = "short",
|
|
@@ -172,7 +187,7 @@ function MonthPagerInner<T>({
|
|
|
172
187
|
);
|
|
173
188
|
const { width, height } = useWindowDimensions();
|
|
174
189
|
const listRef = useRef<LegendListRef>(null);
|
|
175
|
-
const containerRef = useRef<View
|
|
190
|
+
const containerRef = useRef<ComponentRef<typeof View>>(null);
|
|
176
191
|
|
|
177
192
|
// Web: LegendList's horizontal scroll container is `overflow-x: auto`, so a
|
|
178
193
|
// trackpad swipe or horizontal wheel would page between months. Paging should be
|
|
@@ -291,8 +306,15 @@ function MonthPagerInner<T>({
|
|
|
291
306
|
// grids as renderItem props, not through the selection context below: toggling
|
|
292
307
|
// a "pick dates" mode on must reach the pages already rendered.
|
|
293
308
|
const listExtraData = useMemo(
|
|
294
|
-
() => ({
|
|
295
|
-
|
|
309
|
+
() => ({
|
|
310
|
+
events,
|
|
311
|
+
activeDate,
|
|
312
|
+
fillCellOnSelection,
|
|
313
|
+
dragSelect: onSelectDrag != null,
|
|
314
|
+
chipHeight,
|
|
315
|
+
chipGap,
|
|
316
|
+
}),
|
|
317
|
+
[events, activeDate, fillCellOnSelection, onSelectDrag, chipHeight, chipGap],
|
|
296
318
|
);
|
|
297
319
|
|
|
298
320
|
// Selection reaches the grids through context, not `renderItem`, so a change
|
|
@@ -317,6 +339,8 @@ function MonthPagerInner<T>({
|
|
|
317
339
|
showTitle={false}
|
|
318
340
|
showWeekdays={false}
|
|
319
341
|
maxVisibleEventCount={maxVisibleEventCount}
|
|
342
|
+
chipHeight={chipHeight}
|
|
343
|
+
chipGap={chipGap}
|
|
320
344
|
weekStartsOn={weekStartsOn}
|
|
321
345
|
hiddenDays={hiddenDays}
|
|
322
346
|
locale={locale}
|
|
@@ -356,6 +380,8 @@ function MonthPagerInner<T>({
|
|
|
356
380
|
pageHeight,
|
|
357
381
|
events,
|
|
358
382
|
maxVisibleEventCount,
|
|
383
|
+
chipHeight,
|
|
384
|
+
chipGap,
|
|
359
385
|
weekStartsOn,
|
|
360
386
|
hiddenDays,
|
|
361
387
|
locale,
|