@super-calendar/native 2.18.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 +6 -4
- package/dist/{DefaultMonthEvent-B7xVeY7Q.d.ts → DefaultMonthEvent-DzgQFuVp.d.mts} +25 -7
- package/dist/{DefaultMonthEvent-hGk7wSrr.d.mts → DefaultMonthEvent-joYl8Tu2.d.ts} +25 -7
- package/dist/{MonthList-DdQxRhUy.mjs → MonthList-BGl1gTDr.mjs} +545 -100
- package/dist/{MonthList-C_NTufaK.js → MonthList-DeO-x5VW.js} +543 -98
- package/dist/index.d.mts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +25 -15
- package/dist/index.mjs +25 -15
- 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 +1 -2
- package/src/components/Calendar.tsx +4 -4
- package/src/components/MonthCellProbe.tsx +201 -0
- package/src/components/MonthList.tsx +4 -2
- package/src/components/MonthPager.tsx +4 -3
- package/src/components/MonthView.tsx +532 -138
- package/src/components/ResourceTimeline.tsx +11 -2
- package/src/components/TimeGrid.tsx +39 -30
- package/src/components/YearView.tsx +0 -2
- package/src/index.tsx +1 -0
- package/src/types.ts +18 -0
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
type ComponentType,
|
|
3
|
+
type ReactElement,
|
|
4
|
+
type ReactNode,
|
|
5
|
+
useCallback,
|
|
6
|
+
useEffect,
|
|
7
|
+
useLayoutEffect,
|
|
8
|
+
useMemo,
|
|
9
|
+
useRef,
|
|
10
|
+
useState,
|
|
11
|
+
} from "react";
|
|
3
12
|
import {
|
|
4
13
|
type AccessibilityActionEvent,
|
|
5
14
|
type GestureResponderEvent,
|
|
@@ -86,8 +86,6 @@ import {
|
|
|
86
86
|
isSameCalendarDay,
|
|
87
87
|
isWeekend,
|
|
88
88
|
viewDayCount,
|
|
89
|
-
} from "@super-calendar/core";
|
|
90
|
-
import {
|
|
91
89
|
backgroundBandsForDay,
|
|
92
90
|
cellRangeFromDrag,
|
|
93
91
|
clampMoveStartMinutes,
|
|
@@ -98,15 +96,16 @@ import {
|
|
|
98
96
|
resolveDraggedBounds,
|
|
99
97
|
movedClockSpan,
|
|
100
98
|
snapDeltaMinutes,
|
|
99
|
+
formatHour,
|
|
100
|
+
layoutDayEvents,
|
|
101
|
+
type PositionedEvent,
|
|
102
|
+
type CalendarHandle,
|
|
103
|
+
type CalendarLabels,
|
|
104
|
+
type EventAccessibilityLabeler,
|
|
105
|
+
resolveCalendarLabels,
|
|
106
|
+
type WeekdayFormat,
|
|
107
|
+
weekdayFormatToken,
|
|
101
108
|
} from "@super-calendar/core";
|
|
102
|
-
import { formatHour, layoutDayEvents, type PositionedEvent } from "@super-calendar/core";
|
|
103
|
-
import type {
|
|
104
|
-
CalendarHandle,
|
|
105
|
-
CalendarLabels,
|
|
106
|
-
EventAccessibilityLabeler,
|
|
107
|
-
} from "@super-calendar/core";
|
|
108
|
-
import { resolveCalendarLabels } from "@super-calendar/core";
|
|
109
|
-
import { type WeekdayFormat, weekdayFormatToken } from "@super-calendar/core";
|
|
110
109
|
import {
|
|
111
110
|
type ResolvedSlot,
|
|
112
111
|
SlotStylesProvider,
|
|
@@ -486,9 +485,10 @@ function AnimatedEventBoxInner<T>({
|
|
|
486
485
|
// across its day column; the box's own clip is geometric, so it can't disagree
|
|
487
486
|
// with the box during the frames between release and the committed re-render.
|
|
488
487
|
const moving = useSharedValue(0);
|
|
489
|
-
// 1 while a
|
|
490
|
-
// handles, so a hold on one
|
|
491
|
-
|
|
488
|
+
// 1 while a resize pan runs after a long press already picked the event up. The
|
|
489
|
+
// move gesture wraps the handles, so a hold on one starts a move, and the resize
|
|
490
|
+
// stands aside until the finger lifts instead of committing as well.
|
|
491
|
+
const resizeYielded = useSharedValue(0);
|
|
492
492
|
// Edge auto-advance: which side the drag has pushed past the visible columns
|
|
493
493
|
// (-1 left / 0 none / +1 right).
|
|
494
494
|
const edgeDir = useSharedValue(0);
|
|
@@ -606,10 +606,8 @@ function AnimatedEventBoxInner<T>({
|
|
|
606
606
|
// A picked-up event floats across its whole day column, like the multi-day
|
|
607
607
|
// preview and the spill, instead of keeping its slice of an overlap group. It
|
|
608
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.
|
|
610
|
-
|
|
611
|
-
const floating =
|
|
612
|
-
!onHandle.value && (moving.value || moveOffset.value !== 0 || moveOffsetX.value !== 0);
|
|
609
|
+
// flash back to its old slice before the committed layout lands.
|
|
610
|
+
const floating = moving.value || moveOffset.value !== 0 || moveOffsetX.value !== 0;
|
|
613
611
|
return {
|
|
614
612
|
left: floating ? dayLeftPx : left,
|
|
615
613
|
width: floating ? dayWidth : width,
|
|
@@ -1001,21 +999,25 @@ function AnimatedEventBoxInner<T>({
|
|
|
1001
999
|
// A plain tap on a resize handle is a press on the event. The two handles cover
|
|
1002
1000
|
// almost all of a box at the minimum height, so without this a 5- to 30-minute
|
|
1003
1001
|
// event has next to no tappable surface. A drag from a handle still resizes:
|
|
1004
|
-
// the pan wins the race as soon as the finger moves.
|
|
1002
|
+
// the pan wins the race as soon as the finger moves. A long press on a handle
|
|
1003
|
+
// picks the event up for a move instead, as it does anywhere on the box.
|
|
1005
1004
|
const resizeGesture = useMemo(() => {
|
|
1006
1005
|
const pan = Gesture.Pan()
|
|
1007
1006
|
.enabled(resizable)
|
|
1008
|
-
.onBegin(() => {
|
|
1009
|
-
onHandle.value = 1;
|
|
1010
|
-
})
|
|
1011
1007
|
.onStart(() => {
|
|
1008
|
+
if (moving.value) {
|
|
1009
|
+
resizeYielded.value = 1;
|
|
1010
|
+
return;
|
|
1011
|
+
}
|
|
1012
1012
|
dragZ.value = DRAG_EVENT_Z;
|
|
1013
1013
|
runOnJS(notifyDragStart)();
|
|
1014
1014
|
})
|
|
1015
1015
|
.onUpdate((event) => {
|
|
1016
|
+
if (resizeYielded.value) return;
|
|
1016
1017
|
resizeDelta.value = event.translationY;
|
|
1017
1018
|
})
|
|
1018
1019
|
.onEnd((event) => {
|
|
1020
|
+
if (resizeYielded.value) return;
|
|
1019
1021
|
const delta = snapDeltaMinutes(event.translationY, cellHeight.value, snapMinutes);
|
|
1020
1022
|
if (delta === 0) {
|
|
1021
1023
|
resizeDelta.value = 0;
|
|
@@ -1025,8 +1027,9 @@ function AnimatedEventBoxInner<T>({
|
|
|
1025
1027
|
runOnJS(commitDrag)(0, delta);
|
|
1026
1028
|
})
|
|
1027
1029
|
.onFinalize(() => {
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
+
// A yielded resize leaves the moving box raised.
|
|
1031
|
+
if (!resizeYielded.value) dragZ.value = 0;
|
|
1032
|
+
resizeYielded.value = 0;
|
|
1030
1033
|
});
|
|
1031
1034
|
const tap = Gesture.Tap()
|
|
1032
1035
|
.runOnJS(true)
|
|
@@ -1044,7 +1047,8 @@ function AnimatedEventBoxInner<T>({
|
|
|
1044
1047
|
resizable,
|
|
1045
1048
|
snapMinutes,
|
|
1046
1049
|
cellHeight,
|
|
1047
|
-
|
|
1050
|
+
moving,
|
|
1051
|
+
resizeYielded,
|
|
1048
1052
|
resizeDelta,
|
|
1049
1053
|
dragZ,
|
|
1050
1054
|
commitDrag,
|
|
@@ -1059,17 +1063,20 @@ function AnimatedEventBoxInner<T>({
|
|
|
1059
1063
|
const resizeStartGesture = useMemo(() => {
|
|
1060
1064
|
const pan = Gesture.Pan()
|
|
1061
1065
|
.enabled(resizableFromStart)
|
|
1062
|
-
.onBegin(() => {
|
|
1063
|
-
onHandle.value = 1;
|
|
1064
|
-
})
|
|
1065
1066
|
.onStart(() => {
|
|
1067
|
+
if (moving.value) {
|
|
1068
|
+
resizeYielded.value = 1;
|
|
1069
|
+
return;
|
|
1070
|
+
}
|
|
1066
1071
|
dragZ.value = DRAG_EVENT_Z;
|
|
1067
1072
|
runOnJS(notifyDragStart)();
|
|
1068
1073
|
})
|
|
1069
1074
|
.onUpdate((event) => {
|
|
1075
|
+
if (resizeYielded.value) return;
|
|
1070
1076
|
resizeStartDelta.value = event.translationY;
|
|
1071
1077
|
})
|
|
1072
1078
|
.onEnd((event) => {
|
|
1079
|
+
if (resizeYielded.value) return;
|
|
1073
1080
|
const delta = snapDeltaMinutes(event.translationY, cellHeight.value, snapMinutes);
|
|
1074
1081
|
if (delta === 0) {
|
|
1075
1082
|
resizeStartDelta.value = 0;
|
|
@@ -1079,8 +1086,9 @@ function AnimatedEventBoxInner<T>({
|
|
|
1079
1086
|
runOnJS(commitDrag)(delta, 0);
|
|
1080
1087
|
})
|
|
1081
1088
|
.onFinalize(() => {
|
|
1082
|
-
|
|
1083
|
-
|
|
1089
|
+
// A yielded resize leaves the moving box raised.
|
|
1090
|
+
if (!resizeYielded.value) dragZ.value = 0;
|
|
1091
|
+
resizeYielded.value = 0;
|
|
1084
1092
|
});
|
|
1085
1093
|
const tap = Gesture.Tap()
|
|
1086
1094
|
.runOnJS(true)
|
|
@@ -1098,7 +1106,8 @@ function AnimatedEventBoxInner<T>({
|
|
|
1098
1106
|
resizableFromStart,
|
|
1099
1107
|
snapMinutes,
|
|
1100
1108
|
cellHeight,
|
|
1101
|
-
|
|
1109
|
+
moving,
|
|
1110
|
+
resizeYielded,
|
|
1102
1111
|
resizeStartDelta,
|
|
1103
1112
|
dragZ,
|
|
1104
1113
|
commitDrag,
|
package/src/index.tsx
CHANGED
package/src/types.ts
CHANGED
|
@@ -112,3 +112,21 @@ export type RenderEventArgs<T = unknown> = {
|
|
|
112
112
|
* (`flex: 1`); the calendar positions and sizes the wrapping box for you.
|
|
113
113
|
*/
|
|
114
114
|
export type RenderEvent<T = unknown> = ComponentType<RenderEventArgs<T>>;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* The state of a month day cell, passed to `renderCustomDateForMonth` so a custom
|
|
118
|
+
* date badge can style the day the way the built-in badge does.
|
|
119
|
+
*/
|
|
120
|
+
export type MonthDateInfo = {
|
|
121
|
+
/**
|
|
122
|
+
* False for a day from the previous or next month, shown with
|
|
123
|
+
* `showAdjacentMonths`. Always true in `MultiWeekView`.
|
|
124
|
+
*/
|
|
125
|
+
isCurrentMonth: boolean;
|
|
126
|
+
/** The day is today. */
|
|
127
|
+
isToday: boolean;
|
|
128
|
+
/** The day is in `selectedDates` or is an endpoint of `selectedRange`. */
|
|
129
|
+
isSelected: boolean;
|
|
130
|
+
/** The day fails `minDate`, `maxDate` or `isDateDisabled`. */
|
|
131
|
+
isDisabled: boolean;
|
|
132
|
+
};
|