@super-calendar/native 2.17.0 → 2.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -1
- package/dist/{DefaultMonthEvent-C3C30hfV.d.mts → DefaultMonthEvent-DzgQFuVp.d.mts} +47 -10
- package/dist/{DefaultMonthEvent-Dx3lD7ig.d.ts → DefaultMonthEvent-joYl8Tu2.d.ts} +47 -10
- package/dist/{MonthList-N1GVDIE4.mjs → MonthList-BGl1gTDr.mjs} +603 -97
- package/dist/{MonthList-B2TSGYp7.js → MonthList-DeO-x5VW.js} +601 -95
- package/dist/index.d.mts +40 -15
- package/dist/index.d.ts +40 -15
- package/dist/index.js +189 -63
- package/dist/index.mjs +161 -65
- 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 +19 -3
- package/src/components/AllDayLane.tsx +64 -37
- package/src/components/Calendar.tsx +104 -30
- package/src/components/MonthCellProbe.tsx +201 -0
- package/src/components/MonthList.tsx +4 -2
- package/src/components/MonthPager.tsx +41 -4
- package/src/components/MonthView.tsx +597 -118
- package/src/components/ResourceTimeline.tsx +11 -2
- package/src/components/TimeGrid.tsx +82 -24
- package/src/components/YearView.tsx +12 -3
- package/src/index.tsx +11 -2
- package/src/types.ts +20 -2
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { _ as mergeTheme, a as DateRows, c as useWebPagerKeys, d as useSlots, f as CalendarLabelsContext, g as defaultTheme, h as darkTheme, i as MonthPager, l as SlotStylesProvider, m as CalendarThemeProvider, n as DefaultMonthEvent, o as MonthView, p as useCalendarLabels, r as DateRowsPager, s as withEventAccessibilityLabel, t as MonthList, u as createSlots, v as useCalendarTheme } from "./MonthList-
|
|
1
|
+
import { _ as mergeTheme, a as DateRows, c as useWebPagerKeys, d as useSlots, f as CalendarLabelsContext, g as defaultTheme, h as darkTheme, i as MonthPager, l as SlotStylesProvider, m as CalendarThemeProvider, n as DefaultMonthEvent, o as MonthView, p as useCalendarLabels, r as DateRowsPager, s as withEventAccessibilityLabel, t as MonthList, u as createSlots, v as useCalendarTheme } from "./MonthList-BGl1gTDr.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, useLayoutEffect, 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, buildMultiWeekGrid, buildMultiWeekGrid as buildMultiWeekGrid$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";
|
|
5
|
+
import { backgroundBandsForDay, backgroundBandsForDay as backgroundBandsForDay$1, bandRounding, buildMonthGrid, buildMonthWeeks, buildMonthWeeks as buildMonthWeeks$1, buildMultiWeekGrid, buildMultiWeekGrid as buildMultiWeekGrid$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, fromZonedRange, fromZonedRange as fromZonedRange$1, fromZonedTime, fromZonedTime as fromZonedTime$1, 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, layoutMonthWeek as layoutMonthWeek$1, minutesIntoDay, monthCreateRange, movedClockSpan, nextDateRange, nowInTimeZone, nowInTimeZone as nowInTimeZone$1, 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, zonedDragBounds, zonedDragBounds as zonedDragBounds$1, zonedEventSource, zonedEventSource as zonedEventSource$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";
|
|
@@ -12,7 +12,7 @@ import { AnimatedLegendList } from "@legendapp/list/reanimated";
|
|
|
12
12
|
const isWeb$2 = Platform.OS === "web";
|
|
13
13
|
const DRAG_HOLD_MS = 400;
|
|
14
14
|
const FALLBACK_COLUMNS = 3;
|
|
15
|
-
function YearViewInner({ date, events, weekStartsOn, hiddenDays, locale, labels: labelsProp, activeDate, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, minMonthWidth = 150, onPressDay, onPressMonth, onSelectDrag, onCreateEvent, refreshControl, classNames, styles: styleOverrides }) {
|
|
15
|
+
function YearViewInner({ date, events, weekStartsOn, hiddenDays, locale, now, timeZone, labels: labelsProp, activeDate, selectedRange, selectedDates, minDate, maxDate, isDateDisabled, minMonthWidth = 150, onPressDay, onPressMonth, onSelectDrag, onCreateEvent, refreshControl, classNames, styles: styleOverrides }) {
|
|
16
16
|
const theme = useCalendarTheme();
|
|
17
17
|
const labels = useMemo(() => resolveCalendarLabels(labelsProp), [labelsProp]);
|
|
18
18
|
const slot = createSlots({
|
|
@@ -25,6 +25,7 @@ function YearViewInner({ date, events, weekStartsOn, hiddenDays, locale, labels:
|
|
|
25
25
|
if (width <= 0) return;
|
|
26
26
|
setColumns(Math.max(2, Math.min(4, Math.floor(width / minMonthWidth))));
|
|
27
27
|
};
|
|
28
|
+
const today = nowInTimeZone$1(now, timeZone);
|
|
28
29
|
const months = useMemo(() => getYearMonths(date), [date]);
|
|
29
30
|
const monthWeeks = useMemo(() => months.map((month) => buildMonthWeeks$1(month, weekStartsOn, { hiddenDays })), [
|
|
30
31
|
months,
|
|
@@ -155,7 +156,7 @@ function YearViewInner({ date, events, weekStartsOn, hiddenDays, locale, labels:
|
|
|
155
156
|
...slot("week", { base: styles$5.week }),
|
|
156
157
|
children: week.map((day) => {
|
|
157
158
|
if (day.getMonth() !== month.getMonth()) return /* @__PURE__ */ jsx(View, { style: styles$5.day }, day.toISOString());
|
|
158
|
-
const isToday = getIsToday$1(day);
|
|
159
|
+
const isToday = getIsToday$1(day, today);
|
|
159
160
|
const isHighlighted = activeDate ? isSameCalendarDay$1(day, activeDate) : isToday;
|
|
160
161
|
const hasEvents = eventDays.has(startOfDay(day).toISOString());
|
|
161
162
|
const state = daySelectionState$1(day, {
|
|
@@ -378,7 +379,7 @@ const styles$5 = StyleSheet.create({
|
|
|
378
379
|
* start, grouped under a date header per day. The consumer controls which
|
|
379
380
|
* events (and therefore which date range) are shown.
|
|
380
381
|
*/
|
|
381
|
-
function Agenda({ events, locale, renderEvent, keyExtractor, onPressEvent, onLongPressEvent, onPressDay, activeDate, itemSeparatorComponent, refreshControl, classNames, styles: styleOverrides }) {
|
|
382
|
+
function Agenda({ events, locale, now, timeZone, renderEvent, keyExtractor, onPressEvent, onLongPressEvent, onPressDay, activeDate, itemSeparatorComponent, refreshControl, classNames, styles: styleOverrides }) {
|
|
382
383
|
const theme = useCalendarTheme();
|
|
383
384
|
const slot = useMemo(() => createSlots({
|
|
384
385
|
classNames,
|
|
@@ -408,9 +409,10 @@ function Agenda({ events, locale, renderEvent, keyExtractor, onPressEvent, onLon
|
|
|
408
409
|
return out;
|
|
409
410
|
}, [events, keyExtractor]);
|
|
410
411
|
const keyExtractorRow = useCallback((row) => row.key, []);
|
|
412
|
+
const todayKey = startOfDay(nowInTimeZone$1(now, timeZone)).getTime();
|
|
411
413
|
const renderItem = useCallback(({ item }) => {
|
|
412
414
|
if (item.kind === "header") {
|
|
413
|
-
const isHighlighted = activeDate ? isSameDay(item.date, activeDate) : getIsToday$1(item.date);
|
|
415
|
+
const isHighlighted = activeDate ? isSameDay(item.date, activeDate) : getIsToday$1(item.date, new Date(todayKey));
|
|
414
416
|
return /* @__PURE__ */ jsx(Text, {
|
|
415
417
|
...slot("dayHeader", {
|
|
416
418
|
base: styles$4.header,
|
|
@@ -438,6 +440,7 @@ function Agenda({ events, locale, renderEvent, keyExtractor, onPressEvent, onLon
|
|
|
438
440
|
theme,
|
|
439
441
|
locale,
|
|
440
442
|
activeDate,
|
|
443
|
+
todayKey,
|
|
441
444
|
onPressDay,
|
|
442
445
|
onPressEvent,
|
|
443
446
|
onLongPressEvent,
|
|
@@ -456,6 +459,7 @@ function Agenda({ events, locale, renderEvent, keyExtractor, onPressEvent, onLon
|
|
|
456
459
|
data: rows,
|
|
457
460
|
keyExtractor: keyExtractorRow,
|
|
458
461
|
renderItem,
|
|
462
|
+
extraData: todayKey,
|
|
459
463
|
ItemSeparatorComponent: itemSeparatorComponent ?? void 0,
|
|
460
464
|
recycleItems: false,
|
|
461
465
|
refreshControl
|
|
@@ -676,7 +680,7 @@ function useWebGridZoom(enabled, target, cellHeight, committedCellHeight, minHei
|
|
|
676
680
|
/**
|
|
677
681
|
* The all-day lane of one page, pinned above the scrolling hours. All-day
|
|
678
682
|
* events are excluded from the timed columns (see `layoutDayEvents`) and shown
|
|
679
|
-
* here, stacked
|
|
683
|
+
* here as continuous spans, stacked only when their dates overlap. Always rendered so every page reports a
|
|
680
684
|
* height, zero when the week has none, which the band above the grid follows
|
|
681
685
|
* live as you swipe; the "all-day" label lives in the hour column.
|
|
682
686
|
*/
|
|
@@ -684,43 +688,59 @@ function AllDayLane({ days, events, mode, dayWidth, renderEvent, keyExtractor, o
|
|
|
684
688
|
const theme = useCalendarTheme();
|
|
685
689
|
const slot = useSlots();
|
|
686
690
|
const RenderEventComponent = renderEvent;
|
|
687
|
-
const
|
|
688
|
-
|
|
689
|
-
const
|
|
690
|
-
const
|
|
691
|
-
|
|
692
|
-
|
|
691
|
+
const spans = useMemo(() => {
|
|
692
|
+
const allDay = events.filter((event) => isAllDayEvent$1(event) && !isBackgroundEvent$1(event) && days.some((day) => event.start < addDays(startOfDay(day), 1) && event.end > startOfDay(day)));
|
|
693
|
+
const { segments, laneCount } = layoutMonthWeek$1(days, allDay);
|
|
694
|
+
const lanes = Array.from({ length: laneCount }, () => []);
|
|
695
|
+
for (const segment of segments) lanes[segment.lane].push(segment);
|
|
696
|
+
return lanes.flat();
|
|
697
|
+
}, [days, events]);
|
|
693
698
|
return /* @__PURE__ */ jsx(View, {
|
|
694
699
|
...slot("allDayLane", {
|
|
695
|
-
base: styles$2.lane,
|
|
700
|
+
base: [styles$2.lane, spans.length > 0 && { paddingVertical: 2 }],
|
|
696
701
|
themed: theme.containers.allDayLane
|
|
697
702
|
}),
|
|
698
703
|
onLayout,
|
|
699
|
-
children:
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
704
|
+
children: spans.map((segment, index) => {
|
|
705
|
+
const { event, startCol, endCol, lane, continuesBefore, continuesAfter } = segment;
|
|
706
|
+
const previous = spans[index - 1];
|
|
707
|
+
const previousEnd = previous?.lane === lane ? previous.endCol : -1;
|
|
708
|
+
const lastInLane = spans[index + 1]?.lane !== lane;
|
|
709
|
+
const remaining = lastInLane ? days.length - endCol - 1 : 0;
|
|
710
|
+
const wrapSlack = lastInLane ? Math.min(.5, dayWidth / 4) : 0;
|
|
711
|
+
return /* @__PURE__ */ jsx(View, {
|
|
712
|
+
...slot("allDayColumn", {
|
|
713
|
+
base: [styles$2.column, {
|
|
714
|
+
width: dayWidth * (endCol - startCol + 1),
|
|
715
|
+
marginLeft: dayWidth * (startCol - previousEnd - 1),
|
|
716
|
+
marginRight: dayWidth * remaining - wrapSlack
|
|
717
|
+
}],
|
|
718
|
+
themed: theme.containers.allDayColumn
|
|
719
|
+
}),
|
|
720
|
+
children: /* @__PURE__ */ jsx(View, {
|
|
721
|
+
...slot("allDayEvent", { base: styles$2.chip }),
|
|
722
|
+
children: /* @__PURE__ */ jsx(RenderEventComponent, {
|
|
723
|
+
event,
|
|
724
|
+
mode,
|
|
725
|
+
isAllDay: true,
|
|
726
|
+
continuesBefore,
|
|
727
|
+
continuesAfter,
|
|
728
|
+
onPress: () => onPressEvent(event),
|
|
729
|
+
onLongPress: onLongPressEvent ? () => onLongPressEvent(event) : void 0
|
|
730
|
+
})
|
|
712
731
|
})
|
|
713
|
-
}, keyExtractor(event, index))
|
|
714
|
-
}
|
|
732
|
+
}, keyExtractor(event, index));
|
|
733
|
+
})
|
|
715
734
|
});
|
|
716
735
|
}
|
|
717
736
|
const styles$2 = StyleSheet.create({
|
|
718
|
-
lane: {
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
737
|
+
lane: {
|
|
738
|
+
flexDirection: "row",
|
|
739
|
+
flexWrap: "wrap",
|
|
740
|
+
alignItems: "flex-start",
|
|
741
|
+
rowGap: 2
|
|
723
742
|
},
|
|
743
|
+
column: { paddingHorizontal: 1 },
|
|
724
744
|
chip: { minHeight: 18 }
|
|
725
745
|
});
|
|
726
746
|
// src/components/MultiDayMovePreview.tsx
|
|
@@ -941,6 +961,7 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
941
961
|
const resizeStartDelta = useSharedValue(0);
|
|
942
962
|
const dragZ = useSharedValue(0);
|
|
943
963
|
const moving = useSharedValue(0);
|
|
964
|
+
const resizeYielded = useSharedValue(0);
|
|
944
965
|
const edgeDir = useSharedValue(0);
|
|
945
966
|
const lifted = useSharedValue(0);
|
|
946
967
|
const grabX = useSharedValue(0);
|
|
@@ -956,6 +977,7 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
956
977
|
minutes: startHours * MINUTES_PER_HOUR$1,
|
|
957
978
|
ownsStart
|
|
958
979
|
}), [startHours, ownsStart]);
|
|
980
|
+
const columnInsetSV = useDerivedValue(() => left - dayLeftPx, [left, dayLeftPx]);
|
|
959
981
|
const eventStartMs = positioned.event.start.getTime();
|
|
960
982
|
const eventEndMs = positioned.event.end.getTime();
|
|
961
983
|
const moveExtra = useDerivedValue(() => {
|
|
@@ -992,8 +1014,12 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
992
1014
|
minEventHeight
|
|
993
1015
|
]);
|
|
994
1016
|
const boxStyle = useAnimatedStyle(() => {
|
|
1017
|
+
const top = (startHours + moveExtra.value.top - minHour) * cellHeight.value + moveOffset.value + resizeStartDelta.value;
|
|
1018
|
+
const floating = moving.value || moveOffset.value !== 0 || moveOffsetX.value !== 0;
|
|
995
1019
|
return {
|
|
996
|
-
|
|
1020
|
+
left: floating ? dayLeftPx : left,
|
|
1021
|
+
width: floating ? dayWidth : width,
|
|
1022
|
+
top,
|
|
997
1023
|
height: visibleBoxHeight.value,
|
|
998
1024
|
transform: [{ translateX: moveOffsetX.value }],
|
|
999
1025
|
zIndex: dragZ.value,
|
|
@@ -1002,7 +1028,11 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
1002
1028
|
}, [
|
|
1003
1029
|
startHours,
|
|
1004
1030
|
minHour,
|
|
1005
|
-
hiddenForMove
|
|
1031
|
+
hiddenForMove,
|
|
1032
|
+
left,
|
|
1033
|
+
width,
|
|
1034
|
+
dayLeftPx,
|
|
1035
|
+
dayWidth
|
|
1006
1036
|
]);
|
|
1007
1037
|
const spillHeight = useDerivedValue(() => {
|
|
1008
1038
|
if (multiDay || !moving.value || lifted.value || cellHeight.value <= 0) return 0;
|
|
@@ -1128,7 +1158,7 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
1128
1158
|
if (!edgePaging) return;
|
|
1129
1159
|
if (!lifted.value) {
|
|
1130
1160
|
lifted.value = 1;
|
|
1131
|
-
edgePaging.ghostW.value =
|
|
1161
|
+
edgePaging.ghostW.value = dayWidth;
|
|
1132
1162
|
edgePaging.ghostH.value = boxHeight.value;
|
|
1133
1163
|
edgePaging.ghostX.value = liveAbsX.value - grabX.value - edgePaging.pagerLeft.value;
|
|
1134
1164
|
edgePaging.ghostY.value = liveAbsY.value - grabY.value - edgePaging.pagerTop.value;
|
|
@@ -1143,7 +1173,7 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
1143
1173
|
disarmEdge,
|
|
1144
1174
|
edgePaging,
|
|
1145
1175
|
lifted,
|
|
1146
|
-
|
|
1176
|
+
dayWidth,
|
|
1147
1177
|
boxHeight,
|
|
1148
1178
|
liveAbsX,
|
|
1149
1179
|
liveAbsY,
|
|
@@ -1157,7 +1187,7 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
1157
1187
|
moving.value = 1;
|
|
1158
1188
|
edgeDir.value = 0;
|
|
1159
1189
|
lifted.value = 0;
|
|
1160
|
-
grabX.value = event.x;
|
|
1190
|
+
grabX.value = event.x + columnInsetSV.value;
|
|
1161
1191
|
grabY.value = event.y;
|
|
1162
1192
|
liveAbsX.value = event.absoluteX;
|
|
1163
1193
|
liveAbsY.value = event.absoluteY;
|
|
@@ -1224,6 +1254,7 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
1224
1254
|
}, [
|
|
1225
1255
|
canMove,
|
|
1226
1256
|
snapMinutes,
|
|
1257
|
+
columnInsetSV,
|
|
1227
1258
|
cellHeight,
|
|
1228
1259
|
moveOffset,
|
|
1229
1260
|
moveOffsetX,
|
|
@@ -1269,11 +1300,17 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
1269
1300
|
}, []);
|
|
1270
1301
|
const resizeGesture = useMemo(() => {
|
|
1271
1302
|
const pan = Gesture.Pan().enabled(resizable).onStart(() => {
|
|
1303
|
+
if (moving.value) {
|
|
1304
|
+
resizeYielded.value = 1;
|
|
1305
|
+
return;
|
|
1306
|
+
}
|
|
1272
1307
|
dragZ.value = DRAG_EVENT_Z;
|
|
1273
1308
|
runOnJS(notifyDragStart)();
|
|
1274
1309
|
}).onUpdate((event) => {
|
|
1310
|
+
if (resizeYielded.value) return;
|
|
1275
1311
|
resizeDelta.value = event.translationY;
|
|
1276
1312
|
}).onEnd((event) => {
|
|
1313
|
+
if (resizeYielded.value) return;
|
|
1277
1314
|
const delta = snapDeltaMinutes(event.translationY, cellHeight.value, snapMinutes);
|
|
1278
1315
|
if (delta === 0) {
|
|
1279
1316
|
resizeDelta.value = 0;
|
|
@@ -1282,7 +1319,8 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
1282
1319
|
resizeDelta.value = delta / MINUTES_PER_HOUR$1 * cellHeight.value;
|
|
1283
1320
|
runOnJS(commitDrag)(0, delta);
|
|
1284
1321
|
}).onFinalize(() => {
|
|
1285
|
-
dragZ.value = 0;
|
|
1322
|
+
if (!resizeYielded.value) dragZ.value = 0;
|
|
1323
|
+
resizeYielded.value = 0;
|
|
1286
1324
|
});
|
|
1287
1325
|
const tap = Gesture.Tap().runOnJS(true).onEnd((_event, success) => {
|
|
1288
1326
|
if (success) handlePress();
|
|
@@ -1295,6 +1333,8 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
1295
1333
|
resizable,
|
|
1296
1334
|
snapMinutes,
|
|
1297
1335
|
cellHeight,
|
|
1336
|
+
moving,
|
|
1337
|
+
resizeYielded,
|
|
1298
1338
|
resizeDelta,
|
|
1299
1339
|
dragZ,
|
|
1300
1340
|
commitDrag,
|
|
@@ -1305,11 +1345,17 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
1305
1345
|
]);
|
|
1306
1346
|
const resizeStartGesture = useMemo(() => {
|
|
1307
1347
|
const pan = Gesture.Pan().enabled(resizableFromStart).onStart(() => {
|
|
1348
|
+
if (moving.value) {
|
|
1349
|
+
resizeYielded.value = 1;
|
|
1350
|
+
return;
|
|
1351
|
+
}
|
|
1308
1352
|
dragZ.value = DRAG_EVENT_Z;
|
|
1309
1353
|
runOnJS(notifyDragStart)();
|
|
1310
1354
|
}).onUpdate((event) => {
|
|
1355
|
+
if (resizeYielded.value) return;
|
|
1311
1356
|
resizeStartDelta.value = event.translationY;
|
|
1312
1357
|
}).onEnd((event) => {
|
|
1358
|
+
if (resizeYielded.value) return;
|
|
1313
1359
|
const delta = snapDeltaMinutes(event.translationY, cellHeight.value, snapMinutes);
|
|
1314
1360
|
if (delta === 0) {
|
|
1315
1361
|
resizeStartDelta.value = 0;
|
|
@@ -1318,7 +1364,8 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
1318
1364
|
resizeStartDelta.value = delta / MINUTES_PER_HOUR$1 * cellHeight.value;
|
|
1319
1365
|
runOnJS(commitDrag)(delta, 0);
|
|
1320
1366
|
}).onFinalize(() => {
|
|
1321
|
-
dragZ.value = 0;
|
|
1367
|
+
if (!resizeYielded.value) dragZ.value = 0;
|
|
1368
|
+
resizeYielded.value = 0;
|
|
1322
1369
|
});
|
|
1323
1370
|
const tap = Gesture.Tap().runOnJS(true).onEnd((_event, success) => {
|
|
1324
1371
|
if (success) handlePress();
|
|
@@ -1331,6 +1378,8 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
1331
1378
|
resizableFromStart,
|
|
1332
1379
|
snapMinutes,
|
|
1333
1380
|
cellHeight,
|
|
1381
|
+
moving,
|
|
1382
|
+
resizeYielded,
|
|
1334
1383
|
resizeStartDelta,
|
|
1335
1384
|
dragZ,
|
|
1336
1385
|
commitDrag,
|
|
@@ -1684,6 +1733,7 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
|
|
|
1684
1733
|
now: nowProp,
|
|
1685
1734
|
timeZone: nowTimeZone
|
|
1686
1735
|
});
|
|
1736
|
+
const today = showNowIndicator && isActive ? now : nowInTimeZone$1(nowProp, nowTimeZone);
|
|
1687
1737
|
const nowDayIndex = days.findIndex((day) => isSameCalendarDay$1(day, now));
|
|
1688
1738
|
const nowHours = (getHours(now) * MINUTES_PER_HOUR$1 + getMinutes(now)) / MINUTES_PER_HOUR$1;
|
|
1689
1739
|
const nowInWindow = nowHours >= minHour && nowHours <= maxHour;
|
|
@@ -2010,6 +2060,7 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
|
|
|
2010
2060
|
dayWidth,
|
|
2011
2061
|
weekdayFormat,
|
|
2012
2062
|
todayLabel,
|
|
2063
|
+
today,
|
|
2013
2064
|
locale,
|
|
2014
2065
|
activeDate,
|
|
2015
2066
|
onPressDateHeader
|
|
@@ -2780,6 +2831,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2780
2831
|
now,
|
|
2781
2832
|
timeZone
|
|
2782
2833
|
]);
|
|
2834
|
+
const nowTime = now?.getTime();
|
|
2783
2835
|
const listExtraData = useMemo(() => ({
|
|
2784
2836
|
events,
|
|
2785
2837
|
activeIndex,
|
|
@@ -2789,7 +2841,9 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2789
2841
|
onCreateEvent,
|
|
2790
2842
|
dragStepMinutes,
|
|
2791
2843
|
minHour,
|
|
2792
|
-
maxHour
|
|
2844
|
+
maxHour,
|
|
2845
|
+
nowTime,
|
|
2846
|
+
timeZone
|
|
2793
2847
|
}), [
|
|
2794
2848
|
events,
|
|
2795
2849
|
activeIndex,
|
|
@@ -2799,7 +2853,9 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2799
2853
|
onCreateEvent,
|
|
2800
2854
|
dragStepMinutes,
|
|
2801
2855
|
minHour,
|
|
2802
|
-
maxHour
|
|
2856
|
+
maxHour,
|
|
2857
|
+
nowTime,
|
|
2858
|
+
timeZone
|
|
2803
2859
|
]);
|
|
2804
2860
|
return /* @__PURE__ */ jsx(SlotStylesProvider, {
|
|
2805
2861
|
classNames,
|
|
@@ -2943,7 +2999,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2943
2999
|
* ```
|
|
2944
3000
|
*/
|
|
2945
3001
|
const TimeGrid = memo(forwardRef(TimeGridInner));
|
|
2946
|
-
const DayHeaderRow = ({ days, mode, dayWidth, weekdayFormat, todayLabel, locale, activeDate, onPressDateHeader }) => {
|
|
3002
|
+
const DayHeaderRow = ({ days, mode, dayWidth, weekdayFormat, todayLabel, today, locale, activeDate, onPressDateHeader }) => {
|
|
2947
3003
|
const slot = useSlots();
|
|
2948
3004
|
return /* @__PURE__ */ jsx(View, {
|
|
2949
3005
|
...slot("header", { base: styles$1.headerRow }),
|
|
@@ -2953,16 +3009,17 @@ const DayHeaderRow = ({ days, mode, dayWidth, weekdayFormat, todayLabel, locale,
|
|
|
2953
3009
|
width: dayWidth,
|
|
2954
3010
|
weekdayFormat,
|
|
2955
3011
|
todayLabel,
|
|
3012
|
+
today,
|
|
2956
3013
|
locale,
|
|
2957
3014
|
activeDate,
|
|
2958
3015
|
onPressDateHeader
|
|
2959
3016
|
}, day.toISOString()))
|
|
2960
3017
|
});
|
|
2961
3018
|
};
|
|
2962
|
-
const DayHeader = ({ day, width, weekdayFormat = "short", todayLabel, locale, activeDate, onPressDateHeader }) => {
|
|
3019
|
+
const DayHeader = ({ day, width, weekdayFormat = "short", todayLabel, today, locale, activeDate, onPressDateHeader }) => {
|
|
2963
3020
|
const theme = useCalendarTheme();
|
|
2964
3021
|
const slot = useSlots();
|
|
2965
|
-
const isToday = getIsToday$1(day);
|
|
3022
|
+
const isToday = getIsToday$1(day, today);
|
|
2966
3023
|
const isHighlighted = activeDate ? isSameCalendarDay$1(day, activeDate) : isToday;
|
|
2967
3024
|
const accessibilityLabel = `${format(day, "EEEE d MMMM", { locale })}${isToday ? `, ${todayLabel}` : ""}`;
|
|
2968
3025
|
const headerSlot = slot("columnHeader", {
|
|
@@ -3263,12 +3320,8 @@ function CalendarInner({ events, mode, date, onChangeDate, onChangeDateRange, on
|
|
|
3263
3320
|
const displayEvents = useMemo(() => {
|
|
3264
3321
|
let out = events;
|
|
3265
3322
|
if (out.some((e) => e.recurrence)) {
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
start = addDays(start, -1);
|
|
3269
|
-
end = addDays(end, 1);
|
|
3270
|
-
}
|
|
3271
|
-
out = expandRecurringEvents$1(out, start, end);
|
|
3323
|
+
const [start, end] = expansionRange(mode, date, weekStartsOn, numberOfDays ?? 1, weekEndsOn, numberOfWeeks);
|
|
3324
|
+
out = timeZone ? expandRecurringEvents$1(out, fromZonedTime$1(start, timeZone), fromZonedTime$1(end, timeZone), { timeZone }) : expandRecurringEvents$1(out, start, end);
|
|
3272
3325
|
}
|
|
3273
3326
|
if (timeZone) out = eventsInTimeZone$1(out, timeZone);
|
|
3274
3327
|
return out;
|
|
@@ -3283,11 +3336,47 @@ function CalendarInner({ events, mode, date, onChangeDate, onChangeDateRange, on
|
|
|
3283
3336
|
numberOfWeeks
|
|
3284
3337
|
]);
|
|
3285
3338
|
const handlePressEvent = useCallback((event) => {
|
|
3286
|
-
if (!event.disabled) onPressEvent(event);
|
|
3287
|
-
}, [onPressEvent]);
|
|
3339
|
+
if (!event.disabled) onPressEvent(timeZone ? zonedEventSource$1(event) : event);
|
|
3340
|
+
}, [onPressEvent, timeZone]);
|
|
3288
3341
|
const handleLongPressEvent = useMemo(() => onLongPressEvent ? (event) => {
|
|
3289
|
-
if (!event.disabled) onLongPressEvent(event);
|
|
3290
|
-
} : void 0, [onLongPressEvent]);
|
|
3342
|
+
if (!event.disabled) onLongPressEvent(timeZone ? zonedEventSource$1(event) : event);
|
|
3343
|
+
} : void 0, [onLongPressEvent, timeZone]);
|
|
3344
|
+
const timeGridMode = mode !== "month" && mode !== "multiweek";
|
|
3345
|
+
const zoned = useMemo(() => {
|
|
3346
|
+
if (!timeZone) return {
|
|
3347
|
+
onDragStart,
|
|
3348
|
+
onDragEvent,
|
|
3349
|
+
onPressMore,
|
|
3350
|
+
onPressTime: onPressCell,
|
|
3351
|
+
onLongPressTime: onLongPressCell,
|
|
3352
|
+
onCreateTimed: onCreateEvent
|
|
3353
|
+
};
|
|
3354
|
+
const instant = (wallClock) => fromZonedTime$1(wallClock, timeZone);
|
|
3355
|
+
return {
|
|
3356
|
+
onDragStart: onDragStart && ((event) => onDragStart(zonedEventSource$1(event))),
|
|
3357
|
+
onDragEvent: onDragEvent && ((event, start, end) => {
|
|
3358
|
+
const bounds = zonedDragBounds$1(event, start, end, { keepDuration: timeGridMode });
|
|
3359
|
+
if (!bounds) return false;
|
|
3360
|
+
return onDragEvent(zonedEventSource$1(event), bounds.start, bounds.end);
|
|
3361
|
+
}),
|
|
3362
|
+
onPressMore: onPressMore && ((dayEvents, day) => onPressMore(dayEvents.map(zonedEventSource$1), day)),
|
|
3363
|
+
onPressTime: onPressCell && ((time) => onPressCell(instant(time))),
|
|
3364
|
+
onLongPressTime: onLongPressCell && ((time) => onLongPressCell(instant(time))),
|
|
3365
|
+
onCreateTimed: onCreateEvent && ((start, end) => {
|
|
3366
|
+
const range = fromZonedRange$1(start, end, timeZone);
|
|
3367
|
+
if (range) onCreateEvent(range.start, range.end);
|
|
3368
|
+
})
|
|
3369
|
+
};
|
|
3370
|
+
}, [
|
|
3371
|
+
timeZone,
|
|
3372
|
+
timeGridMode,
|
|
3373
|
+
onDragStart,
|
|
3374
|
+
onDragEvent,
|
|
3375
|
+
onPressMore,
|
|
3376
|
+
onPressCell,
|
|
3377
|
+
onLongPressCell,
|
|
3378
|
+
onCreateEvent
|
|
3379
|
+
]);
|
|
3291
3380
|
const handleChangeDate = useCallback((next) => {
|
|
3292
3381
|
onChangeDate(next);
|
|
3293
3382
|
onChangeDateRange?.(visibleRange(mode, next, weekStartsOn, numberOfDays ?? 1, weekEndsOn, numberOfWeeks, hiddenDays));
|
|
@@ -3358,6 +3447,8 @@ function CalendarInner({ events, mode, date, onChangeDate, onChangeDateRange, on
|
|
|
3358
3447
|
hiddenDays,
|
|
3359
3448
|
weekdayFormat,
|
|
3360
3449
|
locale,
|
|
3450
|
+
now,
|
|
3451
|
+
timeZone,
|
|
3361
3452
|
labels,
|
|
3362
3453
|
sortedMonthView,
|
|
3363
3454
|
moreLabel,
|
|
@@ -3376,11 +3467,12 @@ function CalendarInner({ events, mode, date, onChangeDate, onChangeDateRange, on
|
|
|
3376
3467
|
onPressCell,
|
|
3377
3468
|
onPressEvent: handlePressEvent,
|
|
3378
3469
|
onLongPressEvent: handleLongPressEvent,
|
|
3379
|
-
onPressMore,
|
|
3470
|
+
onPressMore: zoned.onPressMore,
|
|
3380
3471
|
onCreateEvent,
|
|
3472
|
+
renderCreateGhost,
|
|
3381
3473
|
onSelectDrag,
|
|
3382
|
-
onDragEvent,
|
|
3383
|
-
onDragStart,
|
|
3474
|
+
onDragEvent: zoned.onDragEvent,
|
|
3475
|
+
onDragStart: zoned.onDragStart,
|
|
3384
3476
|
eventStartEditable,
|
|
3385
3477
|
eventOverlap,
|
|
3386
3478
|
selectedDates,
|
|
@@ -3401,6 +3493,8 @@ function CalendarInner({ events, mode, date, onChangeDate, onChangeDateRange, on
|
|
|
3401
3493
|
weekStartsOn,
|
|
3402
3494
|
hiddenDays,
|
|
3403
3495
|
locale,
|
|
3496
|
+
now,
|
|
3497
|
+
timeZone,
|
|
3404
3498
|
labels,
|
|
3405
3499
|
activeDate,
|
|
3406
3500
|
selectedDates,
|
|
@@ -3417,6 +3511,8 @@ function CalendarInner({ events, mode, date, onChangeDate, onChangeDateRange, on
|
|
|
3417
3511
|
}) : mode === "schedule" ? /* @__PURE__ */ jsx(Agenda, {
|
|
3418
3512
|
events: displayEvents,
|
|
3419
3513
|
locale,
|
|
3514
|
+
now,
|
|
3515
|
+
timeZone,
|
|
3420
3516
|
renderEvent: resolvedRenderEvent,
|
|
3421
3517
|
keyExtractor,
|
|
3422
3518
|
onPressEvent: handlePressEvent,
|
|
@@ -3480,14 +3576,14 @@ function CalendarInner({ events, mode, date, onChangeDate, onChangeDateRange, on
|
|
|
3480
3576
|
swipeEnabled,
|
|
3481
3577
|
onPressEvent: handlePressEvent,
|
|
3482
3578
|
onLongPressEvent: handleLongPressEvent,
|
|
3483
|
-
onDragEvent,
|
|
3579
|
+
onDragEvent: zoned.onDragEvent,
|
|
3484
3580
|
showDragHandle,
|
|
3485
|
-
onDragStart,
|
|
3581
|
+
onDragStart: zoned.onDragStart,
|
|
3486
3582
|
dragStepMinutes,
|
|
3487
|
-
onPressCell,
|
|
3583
|
+
onPressCell: zoned.onPressTime,
|
|
3488
3584
|
resetPageOnPressCell,
|
|
3489
|
-
onLongPressCell,
|
|
3490
|
-
onCreateEvent,
|
|
3585
|
+
onLongPressCell: zoned.onLongPressTime,
|
|
3586
|
+
onCreateEvent: zoned.onCreateTimed,
|
|
3491
3587
|
renderCreateGhost,
|
|
3492
3588
|
onPressDateHeader,
|
|
3493
3589
|
onChangeDate: handleChangeDate,
|
|
@@ -4518,4 +4614,4 @@ const styles = StyleSheet.create({
|
|
|
4518
4614
|
right: 0
|
|
4519
4615
|
}
|
|
4520
4616
|
});
|
|
4521
|
-
export { Agenda, Calendar, CalendarThemeProvider, DEFAULT_HOUR_HEIGHT, DefaultEvent, DefaultMonthEvent, MonthList, MonthPager, MonthView, MultiWeekView, ResourceTimeline, TimeGrid, YearView, backgroundBandsForDay, buildMonthGrid, buildMonthWeeks, buildMultiWeekGrid, darkTheme, daySelectionState, defaultCalendarLabels, defaultTheme, eventsInTimeZone, expandRecurringEvents, getIsToday, getViewDays, getWeekDays, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, layoutDayEvents, layoutMonthWeek, mergeTheme, minutesIntoDay, nextDateRange, parseICalendar, toICalendar, toZonedTime, useCalendarTheme, useDateRange, useEventSource, useMonthGrid, useNow, weekdayFormatToken };
|
|
4617
|
+
export { Agenda, Calendar, CalendarThemeProvider, DEFAULT_HOUR_HEIGHT, DefaultEvent, DefaultMonthEvent, MonthList, MonthPager, MonthView, MultiWeekView, ResourceTimeline, TimeGrid, YearView, backgroundBandsForDay, buildMonthGrid, buildMonthWeeks, buildMultiWeekGrid, darkTheme, daySelectionState, defaultCalendarLabels, defaultTheme, eventsInTimeZone, expandRecurringEvents, fromZonedRange, fromZonedTime, getIsToday, getViewDays, getWeekDays, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, layoutDayEvents, layoutMonthWeek, mergeTheme, minutesIntoDay, nextDateRange, nowInTimeZone, parseICalendar, toICalendar, toZonedTime, useCalendarTheme, useDateRange, useEventSource, useMonthGrid, useNow, weekdayFormatToken, zonedDragBounds, zonedEventSource };
|
package/dist/picker.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { B as useCalendarTheme, C as EventKeyExtractor, F as CalendarThemeProvider, I as PartialCalendarTheme, L as darkTheme, M as WeekStartsOn, O as RenderEvent, P as CalendarTheme, R as defaultTheme, _ as CalendarMode, a as MonthPager, c as MonthViewProps, h as CalendarEvent, k as RenderEventArgs, n as MonthList, o as MonthPagerProps, r as MonthListProps, s as MonthView, t as DefaultMonthEvent, w as ICalendarEvent, z as mergeTheme } from "./DefaultMonthEvent-DzgQFuVp.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 {
|
|
1
|
+
import { B as useCalendarTheme, C as EventKeyExtractor, F as CalendarThemeProvider, I as PartialCalendarTheme, L as darkTheme, M as WeekStartsOn, O as RenderEvent, P as CalendarTheme, R as defaultTheme, _ as CalendarMode, a as MonthPager, c as MonthViewProps, h as CalendarEvent, k as RenderEventArgs, n as MonthList, o as MonthPagerProps, r as MonthListProps, s as MonthView, t as DefaultMonthEvent, w as ICalendarEvent, z as mergeTheme } from "./DefaultMonthEvent-joYl8Tu2.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-DeO-x5VW.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 { _ as mergeTheme, g as defaultTheme, h as darkTheme, i as MonthPager, m as CalendarThemeProvider, n as DefaultMonthEvent, o as MonthView, t as MonthList, v as useCalendarTheme } from "./MonthList-
|
|
1
|
+
import { _ as mergeTheme, g as defaultTheme, h as darkTheme, i as MonthPager, m as CalendarThemeProvider, n as DefaultMonthEvent, o as MonthView, t as MonthList, v as useCalendarTheme } from "./MonthList-BGl1gTDr.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.19.0",
|
|
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.19.0"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
70
|
"@legendapp/list": ">=3",
|
|
@@ -5,8 +5,7 @@ import { StyleSheet, Text, type TextStyle, View, type ScrollViewProps } from "re
|
|
|
5
5
|
import { useCalendarTheme } from "../theme";
|
|
6
6
|
import type { CalendarEvent, EventKeyExtractor, RenderEvent } from "../types";
|
|
7
7
|
import { createSlots, type SlotStyleProps } from "../utils/slots";
|
|
8
|
-
import { getIsToday } from "@super-calendar/core";
|
|
9
|
-
import { isAllDayEvent, isBackgroundEvent } from "@super-calendar/core";
|
|
8
|
+
import { getIsToday, nowInTimeZone, isAllDayEvent, isBackgroundEvent } from "@super-calendar/core";
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* The styleable parts of {@link Agenda}. Mirrors the dom renderer's slot names;
|
|
@@ -18,6 +17,13 @@ export type AgendaSlot = "dayHeader" | "eventRow" | "empty";
|
|
|
18
17
|
export type AgendaProps<T> = SlotStyleProps<AgendaSlot> & {
|
|
19
18
|
events: CalendarEvent<T>[];
|
|
20
19
|
locale?: Locale;
|
|
20
|
+
/**
|
|
21
|
+
* The instant whose calendar day is highlighted as today. Defaults to the
|
|
22
|
+
* device clock, and is read in `timeZone` when one is set.
|
|
23
|
+
*/
|
|
24
|
+
now?: Date;
|
|
25
|
+
/** Highlight today as it is in this IANA time zone (default: the device's). */
|
|
26
|
+
timeZone?: string;
|
|
21
27
|
renderEvent: RenderEvent<T>;
|
|
22
28
|
keyExtractor: EventKeyExtractor<T>;
|
|
23
29
|
onPressEvent: (event: CalendarEvent<T>) => void;
|
|
@@ -43,6 +49,8 @@ type Row<T> =
|
|
|
43
49
|
export function Agenda<T>({
|
|
44
50
|
events,
|
|
45
51
|
locale,
|
|
52
|
+
now,
|
|
53
|
+
timeZone,
|
|
46
54
|
renderEvent,
|
|
47
55
|
keyExtractor,
|
|
48
56
|
onPressEvent,
|
|
@@ -80,10 +88,14 @@ export function Agenda<T>({
|
|
|
80
88
|
}, [events, keyExtractor]);
|
|
81
89
|
|
|
82
90
|
const keyExtractorRow = useCallback((row: Row<T>) => row.key, []);
|
|
91
|
+
// The day, not the instant, so the rows re-render once a day.
|
|
92
|
+
const todayKey = startOfDay(nowInTimeZone(now, timeZone)).getTime();
|
|
83
93
|
const renderItem = useCallback(
|
|
84
94
|
({ item }: LegendListRenderItemProps<Row<T>>) => {
|
|
85
95
|
if (item.kind === "header") {
|
|
86
|
-
const isHighlighted = activeDate
|
|
96
|
+
const isHighlighted = activeDate
|
|
97
|
+
? isSameDay(item.date, activeDate)
|
|
98
|
+
: getIsToday(item.date, new Date(todayKey));
|
|
87
99
|
return (
|
|
88
100
|
<Text
|
|
89
101
|
{...slot<TextStyle>("dayHeader", {
|
|
@@ -116,6 +128,7 @@ export function Agenda<T>({
|
|
|
116
128
|
theme,
|
|
117
129
|
locale,
|
|
118
130
|
activeDate,
|
|
131
|
+
todayKey,
|
|
119
132
|
onPressDay,
|
|
120
133
|
onPressEvent,
|
|
121
134
|
onLongPressEvent,
|
|
@@ -143,6 +156,9 @@ export function Agenda<T>({
|
|
|
143
156
|
data={rows}
|
|
144
157
|
keyExtractor={keyExtractorRow}
|
|
145
158
|
renderItem={renderItem}
|
|
159
|
+
// LegendList keeps rendered rows until `data` or `extraData` changes, so
|
|
160
|
+
// the day that is today has to invalidate them.
|
|
161
|
+
extraData={todayKey}
|
|
146
162
|
// The public prop is data-agnostic; LegendList types the separator by row.
|
|
147
163
|
ItemSeparatorComponent={
|
|
148
164
|
(itemSeparatorComponent ?? undefined) as ComponentType<{ leadingItem: Row<T> }> | undefined
|