@super-calendar/native 2.17.0 → 2.18.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 +20 -0
- package/dist/{DefaultMonthEvent-C3C30hfV.d.mts → DefaultMonthEvent-B7xVeY7Q.d.ts} +24 -5
- package/dist/{DefaultMonthEvent-Dx3lD7ig.d.ts → DefaultMonthEvent-hGk7wSrr.d.mts} +24 -5
- package/dist/{MonthList-B2TSGYp7.js → MonthList-C_NTufaK.js} +70 -9
- package/dist/{MonthList-N1GVDIE4.mjs → MonthList-DdQxRhUy.mjs} +71 -10
- package/dist/index.d.mts +37 -13
- package/dist/index.d.ts +37 -13
- package/dist/index.js +179 -63
- package/dist/index.mjs +151 -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 -2
- package/src/components/AllDayLane.tsx +64 -37
- package/src/components/Calendar.tsx +100 -26
- package/src/components/MonthPager.tsx +37 -1
- package/src/components/MonthView.tsx +89 -4
- package/src/components/TimeGrid.tsx +60 -11
- package/src/components/YearView.tsx +12 -1
- package/src/index.tsx +10 -2
- package/src/types.ts +2 -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-DdQxRhUy.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 onHandle = 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 = !onHandle.value && (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,
|
|
@@ -1268,7 +1299,9 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
1268
1299
|
press?.(event);
|
|
1269
1300
|
}, []);
|
|
1270
1301
|
const resizeGesture = useMemo(() => {
|
|
1271
|
-
const pan = Gesture.Pan().enabled(resizable).
|
|
1302
|
+
const pan = Gesture.Pan().enabled(resizable).onBegin(() => {
|
|
1303
|
+
onHandle.value = 1;
|
|
1304
|
+
}).onStart(() => {
|
|
1272
1305
|
dragZ.value = DRAG_EVENT_Z;
|
|
1273
1306
|
runOnJS(notifyDragStart)();
|
|
1274
1307
|
}).onUpdate((event) => {
|
|
@@ -1283,6 +1316,7 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
1283
1316
|
runOnJS(commitDrag)(0, delta);
|
|
1284
1317
|
}).onFinalize(() => {
|
|
1285
1318
|
dragZ.value = 0;
|
|
1319
|
+
onHandle.value = 0;
|
|
1286
1320
|
});
|
|
1287
1321
|
const tap = Gesture.Tap().runOnJS(true).onEnd((_event, success) => {
|
|
1288
1322
|
if (success) handlePress();
|
|
@@ -1295,6 +1329,7 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
1295
1329
|
resizable,
|
|
1296
1330
|
snapMinutes,
|
|
1297
1331
|
cellHeight,
|
|
1332
|
+
onHandle,
|
|
1298
1333
|
resizeDelta,
|
|
1299
1334
|
dragZ,
|
|
1300
1335
|
commitDrag,
|
|
@@ -1304,7 +1339,9 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
1304
1339
|
handleLongPressFromHandle
|
|
1305
1340
|
]);
|
|
1306
1341
|
const resizeStartGesture = useMemo(() => {
|
|
1307
|
-
const pan = Gesture.Pan().enabled(resizableFromStart).
|
|
1342
|
+
const pan = Gesture.Pan().enabled(resizableFromStart).onBegin(() => {
|
|
1343
|
+
onHandle.value = 1;
|
|
1344
|
+
}).onStart(() => {
|
|
1308
1345
|
dragZ.value = DRAG_EVENT_Z;
|
|
1309
1346
|
runOnJS(notifyDragStart)();
|
|
1310
1347
|
}).onUpdate((event) => {
|
|
@@ -1319,6 +1356,7 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
1319
1356
|
runOnJS(commitDrag)(delta, 0);
|
|
1320
1357
|
}).onFinalize(() => {
|
|
1321
1358
|
dragZ.value = 0;
|
|
1359
|
+
onHandle.value = 0;
|
|
1322
1360
|
});
|
|
1323
1361
|
const tap = Gesture.Tap().runOnJS(true).onEnd((_event, success) => {
|
|
1324
1362
|
if (success) handlePress();
|
|
@@ -1331,6 +1369,7 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
1331
1369
|
resizableFromStart,
|
|
1332
1370
|
snapMinutes,
|
|
1333
1371
|
cellHeight,
|
|
1372
|
+
onHandle,
|
|
1334
1373
|
resizeStartDelta,
|
|
1335
1374
|
dragZ,
|
|
1336
1375
|
commitDrag,
|
|
@@ -1684,6 +1723,7 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
|
|
|
1684
1723
|
now: nowProp,
|
|
1685
1724
|
timeZone: nowTimeZone
|
|
1686
1725
|
});
|
|
1726
|
+
const today = showNowIndicator && isActive ? now : nowInTimeZone$1(nowProp, nowTimeZone);
|
|
1687
1727
|
const nowDayIndex = days.findIndex((day) => isSameCalendarDay$1(day, now));
|
|
1688
1728
|
const nowHours = (getHours(now) * MINUTES_PER_HOUR$1 + getMinutes(now)) / MINUTES_PER_HOUR$1;
|
|
1689
1729
|
const nowInWindow = nowHours >= minHour && nowHours <= maxHour;
|
|
@@ -2010,6 +2050,7 @@ function TimetablePageInner({ mode, numberOfDays, hiddenDays, now: nowProp, nowT
|
|
|
2010
2050
|
dayWidth,
|
|
2011
2051
|
weekdayFormat,
|
|
2012
2052
|
todayLabel,
|
|
2053
|
+
today,
|
|
2013
2054
|
locale,
|
|
2014
2055
|
activeDate,
|
|
2015
2056
|
onPressDateHeader
|
|
@@ -2780,6 +2821,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2780
2821
|
now,
|
|
2781
2822
|
timeZone
|
|
2782
2823
|
]);
|
|
2824
|
+
const nowTime = now?.getTime();
|
|
2783
2825
|
const listExtraData = useMemo(() => ({
|
|
2784
2826
|
events,
|
|
2785
2827
|
activeIndex,
|
|
@@ -2789,7 +2831,9 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2789
2831
|
onCreateEvent,
|
|
2790
2832
|
dragStepMinutes,
|
|
2791
2833
|
minHour,
|
|
2792
|
-
maxHour
|
|
2834
|
+
maxHour,
|
|
2835
|
+
nowTime,
|
|
2836
|
+
timeZone
|
|
2793
2837
|
}), [
|
|
2794
2838
|
events,
|
|
2795
2839
|
activeIndex,
|
|
@@ -2799,7 +2843,9 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2799
2843
|
onCreateEvent,
|
|
2800
2844
|
dragStepMinutes,
|
|
2801
2845
|
minHour,
|
|
2802
|
-
maxHour
|
|
2846
|
+
maxHour,
|
|
2847
|
+
nowTime,
|
|
2848
|
+
timeZone
|
|
2803
2849
|
]);
|
|
2804
2850
|
return /* @__PURE__ */ jsx(SlotStylesProvider, {
|
|
2805
2851
|
classNames,
|
|
@@ -2943,7 +2989,7 @@ function TimeGridInner({ mode, numberOfDays = 1, weekEndsOn, date, events, cellH
|
|
|
2943
2989
|
* ```
|
|
2944
2990
|
*/
|
|
2945
2991
|
const TimeGrid = memo(forwardRef(TimeGridInner));
|
|
2946
|
-
const DayHeaderRow = ({ days, mode, dayWidth, weekdayFormat, todayLabel, locale, activeDate, onPressDateHeader }) => {
|
|
2992
|
+
const DayHeaderRow = ({ days, mode, dayWidth, weekdayFormat, todayLabel, today, locale, activeDate, onPressDateHeader }) => {
|
|
2947
2993
|
const slot = useSlots();
|
|
2948
2994
|
return /* @__PURE__ */ jsx(View, {
|
|
2949
2995
|
...slot("header", { base: styles$1.headerRow }),
|
|
@@ -2953,16 +2999,17 @@ const DayHeaderRow = ({ days, mode, dayWidth, weekdayFormat, todayLabel, locale,
|
|
|
2953
2999
|
width: dayWidth,
|
|
2954
3000
|
weekdayFormat,
|
|
2955
3001
|
todayLabel,
|
|
3002
|
+
today,
|
|
2956
3003
|
locale,
|
|
2957
3004
|
activeDate,
|
|
2958
3005
|
onPressDateHeader
|
|
2959
3006
|
}, day.toISOString()))
|
|
2960
3007
|
});
|
|
2961
3008
|
};
|
|
2962
|
-
const DayHeader = ({ day, width, weekdayFormat = "short", todayLabel, locale, activeDate, onPressDateHeader }) => {
|
|
3009
|
+
const DayHeader = ({ day, width, weekdayFormat = "short", todayLabel, today, locale, activeDate, onPressDateHeader }) => {
|
|
2963
3010
|
const theme = useCalendarTheme();
|
|
2964
3011
|
const slot = useSlots();
|
|
2965
|
-
const isToday = getIsToday$1(day);
|
|
3012
|
+
const isToday = getIsToday$1(day, today);
|
|
2966
3013
|
const isHighlighted = activeDate ? isSameCalendarDay$1(day, activeDate) : isToday;
|
|
2967
3014
|
const accessibilityLabel = `${format(day, "EEEE d MMMM", { locale })}${isToday ? `, ${todayLabel}` : ""}`;
|
|
2968
3015
|
const headerSlot = slot("columnHeader", {
|
|
@@ -3263,12 +3310,8 @@ function CalendarInner({ events, mode, date, onChangeDate, onChangeDateRange, on
|
|
|
3263
3310
|
const displayEvents = useMemo(() => {
|
|
3264
3311
|
let out = events;
|
|
3265
3312
|
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);
|
|
3313
|
+
const [start, end] = expansionRange(mode, date, weekStartsOn, numberOfDays ?? 1, weekEndsOn, numberOfWeeks);
|
|
3314
|
+
out = timeZone ? expandRecurringEvents$1(out, fromZonedTime$1(start, timeZone), fromZonedTime$1(end, timeZone), { timeZone }) : expandRecurringEvents$1(out, start, end);
|
|
3272
3315
|
}
|
|
3273
3316
|
if (timeZone) out = eventsInTimeZone$1(out, timeZone);
|
|
3274
3317
|
return out;
|
|
@@ -3283,11 +3326,47 @@ function CalendarInner({ events, mode, date, onChangeDate, onChangeDateRange, on
|
|
|
3283
3326
|
numberOfWeeks
|
|
3284
3327
|
]);
|
|
3285
3328
|
const handlePressEvent = useCallback((event) => {
|
|
3286
|
-
if (!event.disabled) onPressEvent(event);
|
|
3287
|
-
}, [onPressEvent]);
|
|
3329
|
+
if (!event.disabled) onPressEvent(timeZone ? zonedEventSource$1(event) : event);
|
|
3330
|
+
}, [onPressEvent, timeZone]);
|
|
3288
3331
|
const handleLongPressEvent = useMemo(() => onLongPressEvent ? (event) => {
|
|
3289
|
-
if (!event.disabled) onLongPressEvent(event);
|
|
3290
|
-
} : void 0, [onLongPressEvent]);
|
|
3332
|
+
if (!event.disabled) onLongPressEvent(timeZone ? zonedEventSource$1(event) : event);
|
|
3333
|
+
} : void 0, [onLongPressEvent, timeZone]);
|
|
3334
|
+
const timeGridMode = mode !== "month" && mode !== "multiweek";
|
|
3335
|
+
const zoned = useMemo(() => {
|
|
3336
|
+
if (!timeZone) return {
|
|
3337
|
+
onDragStart,
|
|
3338
|
+
onDragEvent,
|
|
3339
|
+
onPressMore,
|
|
3340
|
+
onPressTime: onPressCell,
|
|
3341
|
+
onLongPressTime: onLongPressCell,
|
|
3342
|
+
onCreateTimed: onCreateEvent
|
|
3343
|
+
};
|
|
3344
|
+
const instant = (wallClock) => fromZonedTime$1(wallClock, timeZone);
|
|
3345
|
+
return {
|
|
3346
|
+
onDragStart: onDragStart && ((event) => onDragStart(zonedEventSource$1(event))),
|
|
3347
|
+
onDragEvent: onDragEvent && ((event, start, end) => {
|
|
3348
|
+
const bounds = zonedDragBounds$1(event, start, end, { keepDuration: timeGridMode });
|
|
3349
|
+
if (!bounds) return false;
|
|
3350
|
+
return onDragEvent(zonedEventSource$1(event), bounds.start, bounds.end);
|
|
3351
|
+
}),
|
|
3352
|
+
onPressMore: onPressMore && ((dayEvents, day) => onPressMore(dayEvents.map(zonedEventSource$1), day)),
|
|
3353
|
+
onPressTime: onPressCell && ((time) => onPressCell(instant(time))),
|
|
3354
|
+
onLongPressTime: onLongPressCell && ((time) => onLongPressCell(instant(time))),
|
|
3355
|
+
onCreateTimed: onCreateEvent && ((start, end) => {
|
|
3356
|
+
const range = fromZonedRange$1(start, end, timeZone);
|
|
3357
|
+
if (range) onCreateEvent(range.start, range.end);
|
|
3358
|
+
})
|
|
3359
|
+
};
|
|
3360
|
+
}, [
|
|
3361
|
+
timeZone,
|
|
3362
|
+
timeGridMode,
|
|
3363
|
+
onDragStart,
|
|
3364
|
+
onDragEvent,
|
|
3365
|
+
onPressMore,
|
|
3366
|
+
onPressCell,
|
|
3367
|
+
onLongPressCell,
|
|
3368
|
+
onCreateEvent
|
|
3369
|
+
]);
|
|
3291
3370
|
const handleChangeDate = useCallback((next) => {
|
|
3292
3371
|
onChangeDate(next);
|
|
3293
3372
|
onChangeDateRange?.(visibleRange(mode, next, weekStartsOn, numberOfDays ?? 1, weekEndsOn, numberOfWeeks, hiddenDays));
|
|
@@ -3358,6 +3437,8 @@ function CalendarInner({ events, mode, date, onChangeDate, onChangeDateRange, on
|
|
|
3358
3437
|
hiddenDays,
|
|
3359
3438
|
weekdayFormat,
|
|
3360
3439
|
locale,
|
|
3440
|
+
now,
|
|
3441
|
+
timeZone,
|
|
3361
3442
|
labels,
|
|
3362
3443
|
sortedMonthView,
|
|
3363
3444
|
moreLabel,
|
|
@@ -3376,11 +3457,12 @@ function CalendarInner({ events, mode, date, onChangeDate, onChangeDateRange, on
|
|
|
3376
3457
|
onPressCell,
|
|
3377
3458
|
onPressEvent: handlePressEvent,
|
|
3378
3459
|
onLongPressEvent: handleLongPressEvent,
|
|
3379
|
-
onPressMore,
|
|
3460
|
+
onPressMore: zoned.onPressMore,
|
|
3380
3461
|
onCreateEvent,
|
|
3462
|
+
renderCreateGhost,
|
|
3381
3463
|
onSelectDrag,
|
|
3382
|
-
onDragEvent,
|
|
3383
|
-
onDragStart,
|
|
3464
|
+
onDragEvent: zoned.onDragEvent,
|
|
3465
|
+
onDragStart: zoned.onDragStart,
|
|
3384
3466
|
eventStartEditable,
|
|
3385
3467
|
eventOverlap,
|
|
3386
3468
|
selectedDates,
|
|
@@ -3401,6 +3483,8 @@ function CalendarInner({ events, mode, date, onChangeDate, onChangeDateRange, on
|
|
|
3401
3483
|
weekStartsOn,
|
|
3402
3484
|
hiddenDays,
|
|
3403
3485
|
locale,
|
|
3486
|
+
now,
|
|
3487
|
+
timeZone,
|
|
3404
3488
|
labels,
|
|
3405
3489
|
activeDate,
|
|
3406
3490
|
selectedDates,
|
|
@@ -3417,6 +3501,8 @@ function CalendarInner({ events, mode, date, onChangeDate, onChangeDateRange, on
|
|
|
3417
3501
|
}) : mode === "schedule" ? /* @__PURE__ */ jsx(Agenda, {
|
|
3418
3502
|
events: displayEvents,
|
|
3419
3503
|
locale,
|
|
3504
|
+
now,
|
|
3505
|
+
timeZone,
|
|
3420
3506
|
renderEvent: resolvedRenderEvent,
|
|
3421
3507
|
keyExtractor,
|
|
3422
3508
|
onPressEvent: handlePressEvent,
|
|
@@ -3480,14 +3566,14 @@ function CalendarInner({ events, mode, date, onChangeDate, onChangeDateRange, on
|
|
|
3480
3566
|
swipeEnabled,
|
|
3481
3567
|
onPressEvent: handlePressEvent,
|
|
3482
3568
|
onLongPressEvent: handleLongPressEvent,
|
|
3483
|
-
onDragEvent,
|
|
3569
|
+
onDragEvent: zoned.onDragEvent,
|
|
3484
3570
|
showDragHandle,
|
|
3485
|
-
onDragStart,
|
|
3571
|
+
onDragStart: zoned.onDragStart,
|
|
3486
3572
|
dragStepMinutes,
|
|
3487
|
-
onPressCell,
|
|
3573
|
+
onPressCell: zoned.onPressTime,
|
|
3488
3574
|
resetPageOnPressCell,
|
|
3489
|
-
onLongPressCell,
|
|
3490
|
-
onCreateEvent,
|
|
3575
|
+
onLongPressCell: zoned.onLongPressTime,
|
|
3576
|
+
onCreateEvent: zoned.onCreateTimed,
|
|
3491
3577
|
renderCreateGhost,
|
|
3492
3578
|
onPressDateHeader,
|
|
3493
3579
|
onChangeDate: handleChangeDate,
|
|
@@ -4518,4 +4604,4 @@ const styles = StyleSheet.create({
|
|
|
4518
4604
|
right: 0
|
|
4519
4605
|
}
|
|
4520
4606
|
});
|
|
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 };
|
|
4607
|
+
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 { C as EventKeyExtractor, D as RenderEvent, F as PartialCalendarTheme, I as darkTheme, L as defaultTheme, N as CalendarTheme, O as RenderEventArgs, P as CalendarThemeProvider, R as mergeTheme, _ as CalendarMode, a as MonthPager, c as MonthViewProps, h as CalendarEvent, j as WeekStartsOn, n as MonthList, o as MonthPagerProps, r as MonthListProps, s as MonthView, t as DefaultMonthEvent, w as ICalendarEvent, z as useCalendarTheme } from "./DefaultMonthEvent-
|
|
1
|
+
import { C as EventKeyExtractor, D as RenderEvent, F as PartialCalendarTheme, I as darkTheme, L as defaultTheme, N as CalendarTheme, O as RenderEventArgs, P as CalendarThemeProvider, R as mergeTheme, _ as CalendarMode, a as MonthPager, c as MonthViewProps, h as CalendarEvent, j as WeekStartsOn, n as MonthList, o as MonthPagerProps, r as MonthListProps, s as MonthView, t as DefaultMonthEvent, w as ICalendarEvent, z as useCalendarTheme } from "./DefaultMonthEvent-hGk7wSrr.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 { C as EventKeyExtractor, D as RenderEvent, F as PartialCalendarTheme, I as darkTheme, L as defaultTheme, N as CalendarTheme, O as RenderEventArgs, P as CalendarThemeProvider, R as mergeTheme, _ as CalendarMode, a as MonthPager, c as MonthViewProps, h as CalendarEvent, j as WeekStartsOn, n as MonthList, o as MonthPagerProps, r as MonthListProps, s as MonthView, t as DefaultMonthEvent, w as ICalendarEvent, z as useCalendarTheme } from "./DefaultMonthEvent-
|
|
1
|
+
import { C as EventKeyExtractor, D as RenderEvent, F as PartialCalendarTheme, I as darkTheme, L as defaultTheme, N as CalendarTheme, O as RenderEventArgs, P as CalendarThemeProvider, R as mergeTheme, _ as CalendarMode, a as MonthPager, c as MonthViewProps, h as CalendarEvent, j as WeekStartsOn, n as MonthList, o as MonthPagerProps, r as MonthListProps, s as MonthView, t as DefaultMonthEvent, w as ICalendarEvent, z as useCalendarTheme } from "./DefaultMonthEvent-B7xVeY7Q.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-C_NTufaK.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-DdQxRhUy.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.18.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.18.0"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
70
|
"@legendapp/list": ">=3",
|
|
@@ -5,7 +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";
|
|
8
|
+
import { getIsToday, nowInTimeZone } from "@super-calendar/core";
|
|
9
9
|
import { isAllDayEvent, isBackgroundEvent } from "@super-calendar/core";
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -18,6 +18,13 @@ export type AgendaSlot = "dayHeader" | "eventRow" | "empty";
|
|
|
18
18
|
export type AgendaProps<T> = SlotStyleProps<AgendaSlot> & {
|
|
19
19
|
events: CalendarEvent<T>[];
|
|
20
20
|
locale?: Locale;
|
|
21
|
+
/**
|
|
22
|
+
* The instant whose calendar day is highlighted as today. Defaults to the
|
|
23
|
+
* device clock, and is read in `timeZone` when one is set.
|
|
24
|
+
*/
|
|
25
|
+
now?: Date;
|
|
26
|
+
/** Highlight today as it is in this IANA time zone (default: the device's). */
|
|
27
|
+
timeZone?: string;
|
|
21
28
|
renderEvent: RenderEvent<T>;
|
|
22
29
|
keyExtractor: EventKeyExtractor<T>;
|
|
23
30
|
onPressEvent: (event: CalendarEvent<T>) => void;
|
|
@@ -43,6 +50,8 @@ type Row<T> =
|
|
|
43
50
|
export function Agenda<T>({
|
|
44
51
|
events,
|
|
45
52
|
locale,
|
|
53
|
+
now,
|
|
54
|
+
timeZone,
|
|
46
55
|
renderEvent,
|
|
47
56
|
keyExtractor,
|
|
48
57
|
onPressEvent,
|
|
@@ -80,10 +89,14 @@ export function Agenda<T>({
|
|
|
80
89
|
}, [events, keyExtractor]);
|
|
81
90
|
|
|
82
91
|
const keyExtractorRow = useCallback((row: Row<T>) => row.key, []);
|
|
92
|
+
// The day, not the instant, so the rows re-render once a day.
|
|
93
|
+
const todayKey = startOfDay(nowInTimeZone(now, timeZone)).getTime();
|
|
83
94
|
const renderItem = useCallback(
|
|
84
95
|
({ item }: LegendListRenderItemProps<Row<T>>) => {
|
|
85
96
|
if (item.kind === "header") {
|
|
86
|
-
const isHighlighted = activeDate
|
|
97
|
+
const isHighlighted = activeDate
|
|
98
|
+
? isSameDay(item.date, activeDate)
|
|
99
|
+
: getIsToday(item.date, new Date(todayKey));
|
|
87
100
|
return (
|
|
88
101
|
<Text
|
|
89
102
|
{...slot<TextStyle>("dayHeader", {
|
|
@@ -116,6 +129,7 @@ export function Agenda<T>({
|
|
|
116
129
|
theme,
|
|
117
130
|
locale,
|
|
118
131
|
activeDate,
|
|
132
|
+
todayKey,
|
|
119
133
|
onPressDay,
|
|
120
134
|
onPressEvent,
|
|
121
135
|
onLongPressEvent,
|
|
@@ -143,6 +157,9 @@ export function Agenda<T>({
|
|
|
143
157
|
data={rows}
|
|
144
158
|
keyExtractor={keyExtractorRow}
|
|
145
159
|
renderItem={renderItem}
|
|
160
|
+
// LegendList keeps rendered rows until `data` or `extraData` changes, so
|
|
161
|
+
// the day that is today has to invalidate them.
|
|
162
|
+
extraData={todayKey}
|
|
146
163
|
// The public prop is data-agnostic; LegendList types the separator by row.
|
|
147
164
|
ItemSeparatorComponent={
|
|
148
165
|
(itemSeparatorComponent ?? undefined) as ComponentType<{ leadingItem: Row<T> }> | undefined
|