@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
|
@@ -81,6 +81,7 @@ import type {
|
|
|
81
81
|
} from "../types";
|
|
82
82
|
import {
|
|
83
83
|
getIsToday,
|
|
84
|
+
nowInTimeZone,
|
|
84
85
|
getViewDays,
|
|
85
86
|
isSameCalendarDay,
|
|
86
87
|
isWeekend,
|
|
@@ -481,10 +482,13 @@ function AnimatedEventBoxInner<T>({
|
|
|
481
482
|
// Raised to DRAG_EVENT_Z while a gesture is active so the dragged event floats
|
|
482
483
|
// above all the others, then back to 0 when it settles.
|
|
483
484
|
const dragZ = useSharedValue(0);
|
|
484
|
-
// 1 while a move gesture is running.
|
|
485
|
-
// clip is geometric, so it can't disagree
|
|
486
|
-
// release and the committed re-render.
|
|
485
|
+
// 1 while a move gesture is running. Gates the spill preview and floats the box
|
|
486
|
+
// across its day column; the box's own clip is geometric, so it can't disagree
|
|
487
|
+
// with the box during the frames between release and the committed re-render.
|
|
487
488
|
const moving = useSharedValue(0);
|
|
489
|
+
// 1 while a finger is down on a resize handle. The move gesture wraps the
|
|
490
|
+
// handles, so a hold on one picks the event up too until the resize takes over.
|
|
491
|
+
const onHandle = useSharedValue(0);
|
|
488
492
|
// Edge auto-advance: which side the drag has pushed past the visible columns
|
|
489
493
|
// (-1 left / 0 none / +1 right).
|
|
490
494
|
const edgeDir = useSharedValue(0);
|
|
@@ -520,6 +524,9 @@ function AnimatedEventBoxInner<T>({
|
|
|
520
524
|
}),
|
|
521
525
|
[startHours, ownsStart],
|
|
522
526
|
);
|
|
527
|
+
// How far into its day column the box sits, mirrored the same way: an overlap
|
|
528
|
+
// group reflows when the consumer updates `events` mid-drag.
|
|
529
|
+
const columnInsetSV = useDerivedValue(() => left - dayLeftPx, [left, dayLeftPx]);
|
|
523
530
|
|
|
524
531
|
// Where a move in progress lands beyond its plain row offset, in hours: a start
|
|
525
532
|
// in the hour a spring-forward change skips moves on past it (`top`), and the
|
|
@@ -596,14 +603,23 @@ function AnimatedEventBoxInner<T>({
|
|
|
596
603
|
// drag commits.
|
|
597
604
|
// Hidden while lifted: the floating ghost stands in for the box until the
|
|
598
605
|
// drop commits (and, for a multi-day move, while the preview draws it).
|
|
606
|
+
// A picked-up event floats across its whole day column, like the multi-day
|
|
607
|
+
// preview and the spill, instead of keeping its slice of an overlap group. It
|
|
608
|
+
// keeps floating while a dropped move holds its offset, so the box doesn't
|
|
609
|
+
// flash back to its old slice before the committed layout lands. A resize keeps
|
|
610
|
+
// the slice, even when a hold on its handle picked the event up first.
|
|
611
|
+
const floating =
|
|
612
|
+
!onHandle.value && (moving.value || moveOffset.value !== 0 || moveOffsetX.value !== 0);
|
|
599
613
|
return {
|
|
614
|
+
left: floating ? dayLeftPx : left,
|
|
615
|
+
width: floating ? dayWidth : width,
|
|
600
616
|
top,
|
|
601
617
|
height: visibleBoxHeight.value,
|
|
602
618
|
transform: [{ translateX: moveOffsetX.value }],
|
|
603
619
|
zIndex: dragZ.value,
|
|
604
620
|
opacity: hiddenForMove || lifted.value ? 0 : 1,
|
|
605
621
|
};
|
|
606
|
-
}, [startHours, minHour, hiddenForMove]);
|
|
622
|
+
}, [startHours, minHour, hiddenForMove, left, width, dayLeftPx, dayWidth]);
|
|
607
623
|
|
|
608
624
|
// Pixel height of the part of a move that runs past midnight, or 0 when nothing
|
|
609
625
|
// spills. Measured against the end of the day, not `maxHour`: a narrowed window
|
|
@@ -781,7 +797,7 @@ function AnimatedEventBoxInner<T>({
|
|
|
781
797
|
// the same gesture keeps tracking after the page changes.
|
|
782
798
|
if (!lifted.value) {
|
|
783
799
|
lifted.value = 1;
|
|
784
|
-
edgePaging.ghostW.value =
|
|
800
|
+
edgePaging.ghostW.value = dayWidth;
|
|
785
801
|
edgePaging.ghostH.value = boxHeight.value;
|
|
786
802
|
edgePaging.ghostX.value = liveAbsX.value - grabX.value - edgePaging.pagerLeft.value;
|
|
787
803
|
edgePaging.ghostY.value = liveAbsY.value - grabY.value - edgePaging.pagerTop.value;
|
|
@@ -797,7 +813,7 @@ function AnimatedEventBoxInner<T>({
|
|
|
797
813
|
disarmEdge,
|
|
798
814
|
edgePaging,
|
|
799
815
|
lifted,
|
|
800
|
-
|
|
816
|
+
dayWidth,
|
|
801
817
|
boxHeight,
|
|
802
818
|
liveAbsX,
|
|
803
819
|
liveAbsY,
|
|
@@ -816,8 +832,9 @@ function AnimatedEventBoxInner<T>({
|
|
|
816
832
|
edgeDir.value = 0;
|
|
817
833
|
lifted.value = 0;
|
|
818
834
|
// Where in the box the finger grabbed, and the live finger position, so
|
|
819
|
-
// the ghost can be seeded and tracked in window space (see armEdge).
|
|
820
|
-
|
|
835
|
+
// the ghost can be seeded and tracked in window space (see armEdge). The
|
|
836
|
+
// grab is measured from the day column, where the floating box now starts.
|
|
837
|
+
grabX.value = event.x + columnInsetSV.value;
|
|
821
838
|
grabY.value = event.y;
|
|
822
839
|
liveAbsX.value = event.absoluteX;
|
|
823
840
|
liveAbsY.value = event.absoluteY;
|
|
@@ -931,6 +948,7 @@ function AnimatedEventBoxInner<T>({
|
|
|
931
948
|
}, [
|
|
932
949
|
canMove,
|
|
933
950
|
snapMinutes,
|
|
951
|
+
columnInsetSV,
|
|
934
952
|
cellHeight,
|
|
935
953
|
moveOffset,
|
|
936
954
|
moveOffsetX,
|
|
@@ -987,6 +1005,9 @@ function AnimatedEventBoxInner<T>({
|
|
|
987
1005
|
const resizeGesture = useMemo(() => {
|
|
988
1006
|
const pan = Gesture.Pan()
|
|
989
1007
|
.enabled(resizable)
|
|
1008
|
+
.onBegin(() => {
|
|
1009
|
+
onHandle.value = 1;
|
|
1010
|
+
})
|
|
990
1011
|
.onStart(() => {
|
|
991
1012
|
dragZ.value = DRAG_EVENT_Z;
|
|
992
1013
|
runOnJS(notifyDragStart)();
|
|
@@ -1005,6 +1026,7 @@ function AnimatedEventBoxInner<T>({
|
|
|
1005
1026
|
})
|
|
1006
1027
|
.onFinalize(() => {
|
|
1007
1028
|
dragZ.value = 0;
|
|
1029
|
+
onHandle.value = 0;
|
|
1008
1030
|
});
|
|
1009
1031
|
const tap = Gesture.Tap()
|
|
1010
1032
|
.runOnJS(true)
|
|
@@ -1022,6 +1044,7 @@ function AnimatedEventBoxInner<T>({
|
|
|
1022
1044
|
resizable,
|
|
1023
1045
|
snapMinutes,
|
|
1024
1046
|
cellHeight,
|
|
1047
|
+
onHandle,
|
|
1025
1048
|
resizeDelta,
|
|
1026
1049
|
dragZ,
|
|
1027
1050
|
commitDrag,
|
|
@@ -1036,6 +1059,9 @@ function AnimatedEventBoxInner<T>({
|
|
|
1036
1059
|
const resizeStartGesture = useMemo(() => {
|
|
1037
1060
|
const pan = Gesture.Pan()
|
|
1038
1061
|
.enabled(resizableFromStart)
|
|
1062
|
+
.onBegin(() => {
|
|
1063
|
+
onHandle.value = 1;
|
|
1064
|
+
})
|
|
1039
1065
|
.onStart(() => {
|
|
1040
1066
|
dragZ.value = DRAG_EVENT_Z;
|
|
1041
1067
|
runOnJS(notifyDragStart)();
|
|
@@ -1054,6 +1080,7 @@ function AnimatedEventBoxInner<T>({
|
|
|
1054
1080
|
})
|
|
1055
1081
|
.onFinalize(() => {
|
|
1056
1082
|
dragZ.value = 0;
|
|
1083
|
+
onHandle.value = 0;
|
|
1057
1084
|
});
|
|
1058
1085
|
const tap = Gesture.Tap()
|
|
1059
1086
|
.runOnJS(true)
|
|
@@ -1071,6 +1098,7 @@ function AnimatedEventBoxInner<T>({
|
|
|
1071
1098
|
resizableFromStart,
|
|
1072
1099
|
snapMinutes,
|
|
1073
1100
|
cellHeight,
|
|
1101
|
+
onHandle,
|
|
1074
1102
|
resizeStartDelta,
|
|
1075
1103
|
dragZ,
|
|
1076
1104
|
commitDrag,
|
|
@@ -1770,6 +1798,9 @@ function TimetablePageInner<T>({
|
|
|
1770
1798
|
const hoursRange = useMemo(() => hourRange(minHour, maxHour), [minHour, maxHour]);
|
|
1771
1799
|
|
|
1772
1800
|
const now = useNow(showNowIndicator && isActive, { now: nowProp, timeZone: nowTimeZone });
|
|
1801
|
+
// The day the header marks as today: the indicator's clock while it runs, so
|
|
1802
|
+
// the two can't disagree.
|
|
1803
|
+
const today = showNowIndicator && isActive ? now : nowInTimeZone(nowProp, nowTimeZone);
|
|
1773
1804
|
// "Today" follows the (possibly zone-shifted or overridden) now, so the line
|
|
1774
1805
|
// lands in the column the events are displayed in.
|
|
1775
1806
|
const nowDayIndex = days.findIndex((day) => isSameCalendarDay(day, now));
|
|
@@ -2178,6 +2209,7 @@ function TimetablePageInner<T>({
|
|
|
2178
2209
|
dayWidth={dayWidth}
|
|
2179
2210
|
weekdayFormat={weekdayFormat}
|
|
2180
2211
|
todayLabel={todayLabel}
|
|
2212
|
+
today={today}
|
|
2181
2213
|
locale={locale}
|
|
2182
2214
|
activeDate={activeDate}
|
|
2183
2215
|
onPressDateHeader={onPressDateHeader}
|
|
@@ -2480,9 +2512,15 @@ export type TimeGridProps<T> = SlotStyleProps<TimeGridSlot> & {
|
|
|
2480
2512
|
weekEndsOn?: WeekStartsOn;
|
|
2481
2513
|
/** Weekdays (0=Sunday…6=Saturday) hidden from the grid, e.g. `[0, 6]` for weekends off. */
|
|
2482
2514
|
hiddenDays?: number[];
|
|
2483
|
-
/**
|
|
2515
|
+
/**
|
|
2516
|
+
* Fixed "now" instant for the indicator (doesn't tick) and for the day
|
|
2517
|
+
* highlighted as today. Defaults to the device clock.
|
|
2518
|
+
*/
|
|
2484
2519
|
now?: Date;
|
|
2485
|
-
/**
|
|
2520
|
+
/**
|
|
2521
|
+
* Shift the now indicator and the day highlighted as today into this IANA zone
|
|
2522
|
+
* (pair with `eventsInTimeZone`).
|
|
2523
|
+
*/
|
|
2486
2524
|
timeZone?: string;
|
|
2487
2525
|
date: Date;
|
|
2488
2526
|
events: CalendarEvent<T>[];
|
|
@@ -3503,6 +3541,8 @@ function TimeGridInner<T>(
|
|
|
3503
3541
|
// `columnsWidth` resizes the mounted pages when the grid is re-measured.
|
|
3504
3542
|
// `showDragHandle` refreshes grips without requiring an event-data change, and
|
|
3505
3543
|
// `renderCreateGhost` swaps the preview content of mounted pages.
|
|
3544
|
+
// `now` and `timeZone` move the today highlight and the now line.
|
|
3545
|
+
const nowTime = now?.getTime();
|
|
3506
3546
|
const listExtraData = useMemo(
|
|
3507
3547
|
() => ({
|
|
3508
3548
|
events,
|
|
@@ -3514,6 +3554,8 @@ function TimeGridInner<T>(
|
|
|
3514
3554
|
dragStepMinutes,
|
|
3515
3555
|
minHour,
|
|
3516
3556
|
maxHour,
|
|
3557
|
+
nowTime,
|
|
3558
|
+
timeZone,
|
|
3517
3559
|
}),
|
|
3518
3560
|
[
|
|
3519
3561
|
events,
|
|
@@ -3525,6 +3567,8 @@ function TimeGridInner<T>(
|
|
|
3525
3567
|
dragStepMinutes,
|
|
3526
3568
|
minHour,
|
|
3527
3569
|
maxHour,
|
|
3570
|
+
nowTime,
|
|
3571
|
+
timeZone,
|
|
3528
3572
|
],
|
|
3529
3573
|
);
|
|
3530
3574
|
|
|
@@ -3713,6 +3757,7 @@ type DayHeaderRowProps = {
|
|
|
3713
3757
|
dayWidth: number;
|
|
3714
3758
|
weekdayFormat?: WeekdayFormat;
|
|
3715
3759
|
todayLabel: string;
|
|
3760
|
+
today: Date;
|
|
3716
3761
|
locale?: Locale;
|
|
3717
3762
|
activeDate?: Date;
|
|
3718
3763
|
onPressDateHeader?: (date: Date) => void;
|
|
@@ -3726,6 +3771,7 @@ const DayHeaderRow = ({
|
|
|
3726
3771
|
dayWidth,
|
|
3727
3772
|
weekdayFormat,
|
|
3728
3773
|
todayLabel,
|
|
3774
|
+
today,
|
|
3729
3775
|
locale,
|
|
3730
3776
|
activeDate,
|
|
3731
3777
|
onPressDateHeader,
|
|
@@ -3741,6 +3787,7 @@ const DayHeaderRow = ({
|
|
|
3741
3787
|
width={dayWidth}
|
|
3742
3788
|
weekdayFormat={weekdayFormat}
|
|
3743
3789
|
todayLabel={todayLabel}
|
|
3790
|
+
today={today}
|
|
3744
3791
|
locale={locale}
|
|
3745
3792
|
activeDate={activeDate}
|
|
3746
3793
|
onPressDateHeader={onPressDateHeader}
|
|
@@ -3756,6 +3803,7 @@ type DayHeaderProps = {
|
|
|
3756
3803
|
width: number;
|
|
3757
3804
|
weekdayFormat?: WeekdayFormat;
|
|
3758
3805
|
todayLabel: string;
|
|
3806
|
+
today: Date;
|
|
3759
3807
|
locale?: Locale;
|
|
3760
3808
|
activeDate?: Date;
|
|
3761
3809
|
onPressDateHeader?: (date: Date) => void;
|
|
@@ -3766,13 +3814,14 @@ const DayHeader = ({
|
|
|
3766
3814
|
width,
|
|
3767
3815
|
weekdayFormat = "short",
|
|
3768
3816
|
todayLabel,
|
|
3817
|
+
today,
|
|
3769
3818
|
locale,
|
|
3770
3819
|
activeDate,
|
|
3771
3820
|
onPressDateHeader,
|
|
3772
3821
|
}: DayHeaderProps) => {
|
|
3773
3822
|
const theme = useCalendarTheme();
|
|
3774
3823
|
const slot = useSlots<TimeGridSlot>();
|
|
3775
|
-
const isToday = getIsToday(day);
|
|
3824
|
+
const isToday = getIsToday(day, today);
|
|
3776
3825
|
// Highlight the chosen `activeDate` when supplied, else the real today.
|
|
3777
3826
|
const isHighlighted = activeDate ? isSameCalendarDay(day, activeDate) : isToday;
|
|
3778
3827
|
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
monthCreateRange,
|
|
24
24
|
daySelectionState,
|
|
25
25
|
getIsToday,
|
|
26
|
+
nowInTimeZone,
|
|
26
27
|
filterHiddenDays,
|
|
27
28
|
getWeekDays,
|
|
28
29
|
getYearMonths,
|
|
@@ -72,6 +73,13 @@ export type YearViewProps<T = unknown> = SlotStyleProps<YearViewSlot> & {
|
|
|
72
73
|
/** Weekdays (0=Sunday…6=Saturday) hidden from the grid, e.g. `[0, 6]` for weekends off. */
|
|
73
74
|
hiddenDays?: number[];
|
|
74
75
|
locale?: Locale;
|
|
76
|
+
/**
|
|
77
|
+
* The instant whose calendar day is highlighted as today. Defaults to the
|
|
78
|
+
* device clock, and is read in `timeZone` when one is set.
|
|
79
|
+
*/
|
|
80
|
+
now?: Date;
|
|
81
|
+
/** Highlight today as it is in this IANA time zone (default: the device's). */
|
|
82
|
+
timeZone?: string;
|
|
75
83
|
/** Translations for the screen-reader words; omitted keys use English. */
|
|
76
84
|
labels?: Partial<CalendarLabels>;
|
|
77
85
|
/** Highlight this date instead of the real "today". */
|
|
@@ -125,6 +133,8 @@ function YearViewInner<T>({
|
|
|
125
133
|
weekStartsOn,
|
|
126
134
|
hiddenDays,
|
|
127
135
|
locale,
|
|
136
|
+
now,
|
|
137
|
+
timeZone,
|
|
128
138
|
labels: labelsProp,
|
|
129
139
|
activeDate,
|
|
130
140
|
selectedRange,
|
|
@@ -152,6 +162,7 @@ function YearViewInner<T>({
|
|
|
152
162
|
setColumns(Math.max(2, Math.min(4, Math.floor(width / minMonthWidth))));
|
|
153
163
|
};
|
|
154
164
|
|
|
165
|
+
const today = nowInTimeZone(now, timeZone);
|
|
155
166
|
const months = useMemo(() => getYearMonths(date), [date]);
|
|
156
167
|
// Each mini month's week rows, built once per year rather than per render, so
|
|
157
168
|
// the drag hit-test (and the pan it is built into) keeps a stable identity.
|
|
@@ -332,7 +343,7 @@ function YearViewInner<T>({
|
|
|
332
343
|
if (day.getMonth() !== month.getMonth()) {
|
|
333
344
|
return <View key={day.toISOString()} style={styles.day} />;
|
|
334
345
|
}
|
|
335
|
-
const isToday = getIsToday(day);
|
|
346
|
+
const isToday = getIsToday(day, today);
|
|
336
347
|
const isHighlighted = activeDate
|
|
337
348
|
? isSameCalendarDay(day, activeDate)
|
|
338
349
|
: isToday;
|
package/src/index.tsx
CHANGED
|
@@ -107,7 +107,7 @@ export {
|
|
|
107
107
|
useMonthGrid,
|
|
108
108
|
weekdayFormatToken,
|
|
109
109
|
} from "@super-calendar/core";
|
|
110
|
-
export { expandRecurringEvents } from "@super-calendar/core";
|
|
110
|
+
export { expandRecurringEvents, type ExpandRecurringEventsOptions } from "@super-calendar/core";
|
|
111
111
|
export { type CalendarLabels, defaultCalendarLabels } from "@super-calendar/core";
|
|
112
112
|
export {
|
|
113
113
|
type ICalEvent,
|
|
@@ -115,7 +115,15 @@ export {
|
|
|
115
115
|
toICalendar,
|
|
116
116
|
type ToICalendarOptions,
|
|
117
117
|
} from "@super-calendar/core";
|
|
118
|
-
export {
|
|
118
|
+
export {
|
|
119
|
+
eventsInTimeZone,
|
|
120
|
+
fromZonedRange,
|
|
121
|
+
fromZonedTime,
|
|
122
|
+
nowInTimeZone,
|
|
123
|
+
toZonedTime,
|
|
124
|
+
zonedDragBounds,
|
|
125
|
+
zonedEventSource,
|
|
126
|
+
} from "@super-calendar/core";
|
|
119
127
|
export {
|
|
120
128
|
buildMonthWeeks,
|
|
121
129
|
getViewDays,
|
package/src/types.ts
CHANGED
|
@@ -67,8 +67,8 @@ export type RenderEventArgs<T = unknown> = {
|
|
|
67
67
|
boxHeight?: SharedValue<number>;
|
|
68
68
|
/**
|
|
69
69
|
* On the week/day grid, true when this is a clipped segment of a multi-day
|
|
70
|
-
* event
|
|
71
|
-
* renderer draw "continues" affordances.
|
|
70
|
+
* timed event. For an all-day bar, these flags refer to the visible date
|
|
71
|
+
* range instead. Lets a renderer draw "continues" affordances.
|
|
72
72
|
*/
|
|
73
73
|
continuesBefore?: boolean;
|
|
74
74
|
continuesAfter?: boolean;
|