@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
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as ScrollToTimeOptions, B as useCalendarTheme, C as EventKeyExtractor, D as RecurrenceRule, E as RecurrenceFrequency, F as CalendarThemeProvider, I as PartialCalendarTheme, L as darkTheme, M as WeekStartsOn, N as WeekdayFormat, O as RenderEvent, P as CalendarTheme, R as defaultTheme, S as EventDragStartHandler, T as MonthDateInfo, _ as CalendarMode, a as MonthPager, b as EventAccessibilityLabeler, c as MonthViewProps, d as SlotDefault, f as SlotStyleProps, g as CalendarHandle, h as CalendarEvent, i as MonthListSlot, j as TimeGridMode, k as RenderEventArgs, l as MonthViewSlot, m as BusinessHoursBand, n as MonthList, o as MonthPagerProps, p as BusinessHours, r as MonthListProps, s as MonthView, t as DefaultMonthEvent, u as ResolvedSlot, v as CreateGhostArgs, w as ICalendarEvent, x as EventDragHandler, y as EventAccessibilityLabelContext, z as mergeTheme } from "./DefaultMonthEvent-DzgQFuVp.mjs";
|
|
2
2
|
import { Locale } from "date-fns";
|
|
3
3
|
import { ComponentType, ReactElement, ReactNode, RefAttributes } from "react";
|
|
4
4
|
import { SharedValue, useSharedValue } from "react-native-reanimated";
|
|
@@ -620,10 +620,11 @@ type CalendarProps<T> = SlotStyleProps<CalendarSlot> & {
|
|
|
620
620
|
renderHeaderForMonthView?: (weekDays: Date[]) => React.ReactNode;
|
|
621
621
|
/**
|
|
622
622
|
* Month mode only: replace the default date badge in each day cell. Receives
|
|
623
|
-
* the day
|
|
623
|
+
* the day and its state (`isCurrentMonth`, `isToday`, `isSelected`,
|
|
624
|
+
* `isDisabled`); return your own date label (e.g. a number with a dot or badge).
|
|
624
625
|
* Event chips and the "+N more" label still render below it.
|
|
625
626
|
*/
|
|
626
|
-
renderCustomDateForMonth?: (date: Date) => React.ReactNode;
|
|
627
|
+
renderCustomDateForMonth?: (date: Date, info: MonthDateInfo) => React.ReactNode;
|
|
627
628
|
/** Drawn between rows of the `schedule` (agenda) list. */
|
|
628
629
|
itemSeparatorComponent?: React.ComponentType<unknown> | null;
|
|
629
630
|
};
|
|
@@ -837,4 +838,4 @@ interface ResourceTimelineProps<T = unknown> {
|
|
|
837
838
|
* ```
|
|
838
839
|
*/
|
|
839
840
|
export declare function ResourceTimeline<T = unknown>({ date, orientation, resources: allResources, resourcesPerPage, resourcePage, events, resourceId, startHour, endHour, hourWidth, hourHeight, rowHeight, labelWidth, ampm, renderEvent, onPressEvent, onLongPressEvent, onDragEvent, onPressCell, onLongPressCell, onCreateEvent, renderCreateGhost, businessHours, renderBusinessHours, renderResourceHeader, dragStepMinutes, showNowIndicator, now: nowProp, timeZone, labels: labelsProp }: ResourceTimelineProps<T>): ReactElement;
|
|
840
|
-
export { type AgendaProps, type AgendaSlot, type BusinessHours, type BusinessHoursBand, type CalendarEvent, type CalendarHandle, type CalendarLabels, type CalendarMode, type CalendarProps, type CalendarSlot, type CalendarTheme, CalendarThemeProvider, type CreateGhostArgs, type DateRange, type DateSelectionConstraints, type DaySelectionState, DefaultMonthEvent, type EventAccessibilityLabelContext, type EventAccessibilityLabeler, type EventDragHandler, type EventDragStartHandler, type EventKeyExtractor, type ExpandRecurringEventsOptions, type HourRenderer, type ICalEvent, type ICalendarEvent, type MonthEventSegment, type MonthGrid, type MonthGridDay, type MonthGridWeek, type MonthGridWeekday, MonthList, type MonthListProps, type MonthListSlot, MonthPager, type MonthPagerProps, MonthView, type MonthViewProps, type MonthViewSlot, type MonthWeekEvents, type MultiWeekGrid, type MultiWeekGridDay, type MultiWeekGridInterval, type MultiWeekGridOptions, type MultiWeekGridWeek, type MultiWeekViewProps, type PartialCalendarTheme, type PositionedEvent, type RecurrenceFrequency, type RecurrenceRule, type RenderEvent, type RenderEventArgs, type ResolvedSlot, type Resource, type ResourceEventArgs, type ResourceTimelineProps, type ScrollToTimeOptions, type SlotDefault, type SlotStyleProps, type TimeGridMode, type TimeGridProps, type TimeGridSlot, type ToICalendarOptions, type UseDateRangeOptions, type UseMonthGridOptions, type WeekStartsOn, type WeekdayFormat, type YearViewProps, type YearViewSlot, 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 };
|
|
841
|
+
export { type AgendaProps, type AgendaSlot, type BusinessHours, type BusinessHoursBand, type CalendarEvent, type CalendarHandle, type CalendarLabels, type CalendarMode, type CalendarProps, type CalendarSlot, type CalendarTheme, CalendarThemeProvider, type CreateGhostArgs, type DateRange, type DateSelectionConstraints, type DaySelectionState, DefaultMonthEvent, type EventAccessibilityLabelContext, type EventAccessibilityLabeler, type EventDragHandler, type EventDragStartHandler, type EventKeyExtractor, type ExpandRecurringEventsOptions, type HourRenderer, type ICalEvent, type ICalendarEvent, type MonthDateInfo, type MonthEventSegment, type MonthGrid, type MonthGridDay, type MonthGridWeek, type MonthGridWeekday, MonthList, type MonthListProps, type MonthListSlot, MonthPager, type MonthPagerProps, MonthView, type MonthViewProps, type MonthViewSlot, type MonthWeekEvents, type MultiWeekGrid, type MultiWeekGridDay, type MultiWeekGridInterval, type MultiWeekGridOptions, type MultiWeekGridWeek, type MultiWeekViewProps, type PartialCalendarTheme, type PositionedEvent, type RecurrenceFrequency, type RecurrenceRule, type RenderEvent, type RenderEventArgs, type ResolvedSlot, type Resource, type ResourceEventArgs, type ResourceTimelineProps, type ScrollToTimeOptions, type SlotDefault, type SlotStyleProps, type TimeGridMode, type TimeGridProps, type TimeGridSlot, type ToICalendarOptions, type UseDateRangeOptions, type UseMonthGridOptions, type WeekStartsOn, type WeekdayFormat, type YearViewProps, type YearViewSlot, 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/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as ScrollToTimeOptions, B as useCalendarTheme, C as EventKeyExtractor, D as RecurrenceRule, E as RecurrenceFrequency, F as CalendarThemeProvider, I as PartialCalendarTheme, L as darkTheme, M as WeekStartsOn, N as WeekdayFormat, O as RenderEvent, P as CalendarTheme, R as defaultTheme, S as EventDragStartHandler, T as MonthDateInfo, _ as CalendarMode, a as MonthPager, b as EventAccessibilityLabeler, c as MonthViewProps, d as SlotDefault, f as SlotStyleProps, g as CalendarHandle, h as CalendarEvent, i as MonthListSlot, j as TimeGridMode, k as RenderEventArgs, l as MonthViewSlot, m as BusinessHoursBand, n as MonthList, o as MonthPagerProps, p as BusinessHours, r as MonthListProps, s as MonthView, t as DefaultMonthEvent, u as ResolvedSlot, v as CreateGhostArgs, w as ICalendarEvent, x as EventDragHandler, y as EventAccessibilityLabelContext, z as mergeTheme } from "./DefaultMonthEvent-joYl8Tu2.js";
|
|
2
2
|
import { Locale } from "date-fns";
|
|
3
3
|
import { ComponentType, ReactElement, ReactNode, RefAttributes } from "react";
|
|
4
4
|
import { ScrollViewProps, StyleProp, ViewStyle } from "react-native";
|
|
@@ -620,10 +620,11 @@ type CalendarProps<T> = SlotStyleProps<CalendarSlot> & {
|
|
|
620
620
|
renderHeaderForMonthView?: (weekDays: Date[]) => React.ReactNode;
|
|
621
621
|
/**
|
|
622
622
|
* Month mode only: replace the default date badge in each day cell. Receives
|
|
623
|
-
* the day
|
|
623
|
+
* the day and its state (`isCurrentMonth`, `isToday`, `isSelected`,
|
|
624
|
+
* `isDisabled`); return your own date label (e.g. a number with a dot or badge).
|
|
624
625
|
* Event chips and the "+N more" label still render below it.
|
|
625
626
|
*/
|
|
626
|
-
renderCustomDateForMonth?: (date: Date) => React.ReactNode;
|
|
627
|
+
renderCustomDateForMonth?: (date: Date, info: MonthDateInfo) => React.ReactNode;
|
|
627
628
|
/** Drawn between rows of the `schedule` (agenda) list. */
|
|
628
629
|
itemSeparatorComponent?: React.ComponentType<unknown> | null;
|
|
629
630
|
};
|
|
@@ -837,4 +838,4 @@ interface ResourceTimelineProps<T = unknown> {
|
|
|
837
838
|
* ```
|
|
838
839
|
*/
|
|
839
840
|
export declare function ResourceTimeline<T = unknown>({ date, orientation, resources: allResources, resourcesPerPage, resourcePage, events, resourceId, startHour, endHour, hourWidth, hourHeight, rowHeight, labelWidth, ampm, renderEvent, onPressEvent, onLongPressEvent, onDragEvent, onPressCell, onLongPressCell, onCreateEvent, renderCreateGhost, businessHours, renderBusinessHours, renderResourceHeader, dragStepMinutes, showNowIndicator, now: nowProp, timeZone, labels: labelsProp }: ResourceTimelineProps<T>): ReactElement;
|
|
840
|
-
export { type AgendaProps, type AgendaSlot, type BusinessHours, type BusinessHoursBand, type CalendarEvent, type CalendarHandle, type CalendarLabels, type CalendarMode, type CalendarProps, type CalendarSlot, type CalendarTheme, CalendarThemeProvider, type CreateGhostArgs, type DateRange, type DateSelectionConstraints, type DaySelectionState, DefaultMonthEvent, type EventAccessibilityLabelContext, type EventAccessibilityLabeler, type EventDragHandler, type EventDragStartHandler, type EventKeyExtractor, type ExpandRecurringEventsOptions, type HourRenderer, type ICalEvent, type ICalendarEvent, type MonthEventSegment, type MonthGrid, type MonthGridDay, type MonthGridWeek, type MonthGridWeekday, MonthList, type MonthListProps, type MonthListSlot, MonthPager, type MonthPagerProps, MonthView, type MonthViewProps, type MonthViewSlot, type MonthWeekEvents, type MultiWeekGrid, type MultiWeekGridDay, type MultiWeekGridInterval, type MultiWeekGridOptions, type MultiWeekGridWeek, type MultiWeekViewProps, type PartialCalendarTheme, type PositionedEvent, type RecurrenceFrequency, type RecurrenceRule, type RenderEvent, type RenderEventArgs, type ResolvedSlot, type Resource, type ResourceEventArgs, type ResourceTimelineProps, type ScrollToTimeOptions, type SlotDefault, type SlotStyleProps, type TimeGridMode, type TimeGridProps, type TimeGridSlot, type ToICalendarOptions, type UseDateRangeOptions, type UseMonthGridOptions, type WeekStartsOn, type WeekdayFormat, type YearViewProps, type YearViewSlot, 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 };
|
|
841
|
+
export { type AgendaProps, type AgendaSlot, type BusinessHours, type BusinessHoursBand, type CalendarEvent, type CalendarHandle, type CalendarLabels, type CalendarMode, type CalendarProps, type CalendarSlot, type CalendarTheme, CalendarThemeProvider, type CreateGhostArgs, type DateRange, type DateSelectionConstraints, type DaySelectionState, DefaultMonthEvent, type EventAccessibilityLabelContext, type EventAccessibilityLabeler, type EventDragHandler, type EventDragStartHandler, type EventKeyExtractor, type ExpandRecurringEventsOptions, type HourRenderer, type ICalEvent, type ICalendarEvent, type MonthDateInfo, type MonthEventSegment, type MonthGrid, type MonthGridDay, type MonthGridWeek, type MonthGridWeekday, MonthList, type MonthListProps, type MonthListSlot, MonthPager, type MonthPagerProps, MonthView, type MonthViewProps, type MonthViewSlot, type MonthWeekEvents, type MultiWeekGrid, type MultiWeekGridDay, type MultiWeekGridInterval, type MultiWeekGridOptions, type MultiWeekGridWeek, type MultiWeekViewProps, type PartialCalendarTheme, type PositionedEvent, type RecurrenceFrequency, type RecurrenceRule, type RenderEvent, type RenderEventArgs, type ResolvedSlot, type Resource, type ResourceEventArgs, type ResourceTimelineProps, type ScrollToTimeOptions, type SlotDefault, type SlotStyleProps, type TimeGridMode, type TimeGridProps, type TimeGridSlot, type ToICalendarOptions, type UseDateRangeOptions, type UseMonthGridOptions, type WeekStartsOn, type WeekdayFormat, type YearViewProps, type YearViewSlot, 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/index.js
CHANGED
|
@@ -20,7 +20,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
20
20
|
value: mod,
|
|
21
21
|
enumerable: true
|
|
22
22
|
}) : target, mod));
|
|
23
|
-
const require_MonthList = require("./MonthList-
|
|
23
|
+
const require_MonthList = require("./MonthList-DeO-x5VW.js");
|
|
24
24
|
let date_fns = require("date-fns");
|
|
25
25
|
let react = require("react");
|
|
26
26
|
let react_native_reanimated = require("react-native-reanimated");
|
|
@@ -984,7 +984,7 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
984
984
|
const resizeStartDelta = (0, react_native_reanimated.useSharedValue)(0);
|
|
985
985
|
const dragZ = (0, react_native_reanimated.useSharedValue)(0);
|
|
986
986
|
const moving = (0, react_native_reanimated.useSharedValue)(0);
|
|
987
|
-
const
|
|
987
|
+
const resizeYielded = (0, react_native_reanimated.useSharedValue)(0);
|
|
988
988
|
const edgeDir = (0, react_native_reanimated.useSharedValue)(0);
|
|
989
989
|
const lifted = (0, react_native_reanimated.useSharedValue)(0);
|
|
990
990
|
const grabX = (0, react_native_reanimated.useSharedValue)(0);
|
|
@@ -1038,7 +1038,7 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
1038
1038
|
]);
|
|
1039
1039
|
const boxStyle = (0, react_native_reanimated.useAnimatedStyle)(() => {
|
|
1040
1040
|
const top = (startHours + moveExtra.value.top - minHour) * cellHeight.value + moveOffset.value + resizeStartDelta.value;
|
|
1041
|
-
const floating =
|
|
1041
|
+
const floating = moving.value || moveOffset.value !== 0 || moveOffsetX.value !== 0;
|
|
1042
1042
|
return {
|
|
1043
1043
|
left: floating ? dayLeftPx : left,
|
|
1044
1044
|
width: floating ? dayWidth : width,
|
|
@@ -1322,14 +1322,18 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
1322
1322
|
press?.(event);
|
|
1323
1323
|
}, []);
|
|
1324
1324
|
const resizeGesture = (0, react.useMemo)(() => {
|
|
1325
|
-
const pan = react_native_gesture_handler.Gesture.Pan().enabled(resizable).
|
|
1326
|
-
|
|
1327
|
-
|
|
1325
|
+
const pan = react_native_gesture_handler.Gesture.Pan().enabled(resizable).onStart(() => {
|
|
1326
|
+
if (moving.value) {
|
|
1327
|
+
resizeYielded.value = 1;
|
|
1328
|
+
return;
|
|
1329
|
+
}
|
|
1328
1330
|
dragZ.value = DRAG_EVENT_Z;
|
|
1329
1331
|
(0, react_native_reanimated.runOnJS)(notifyDragStart)();
|
|
1330
1332
|
}).onUpdate((event) => {
|
|
1333
|
+
if (resizeYielded.value) return;
|
|
1331
1334
|
resizeDelta.value = event.translationY;
|
|
1332
1335
|
}).onEnd((event) => {
|
|
1336
|
+
if (resizeYielded.value) return;
|
|
1333
1337
|
const delta = (0, _super_calendar_core.snapDeltaMinutes)(event.translationY, cellHeight.value, snapMinutes);
|
|
1334
1338
|
if (delta === 0) {
|
|
1335
1339
|
resizeDelta.value = 0;
|
|
@@ -1338,8 +1342,8 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
1338
1342
|
resizeDelta.value = delta / MINUTES_PER_HOUR$1 * cellHeight.value;
|
|
1339
1343
|
(0, react_native_reanimated.runOnJS)(commitDrag)(0, delta);
|
|
1340
1344
|
}).onFinalize(() => {
|
|
1341
|
-
dragZ.value = 0;
|
|
1342
|
-
|
|
1345
|
+
if (!resizeYielded.value) dragZ.value = 0;
|
|
1346
|
+
resizeYielded.value = 0;
|
|
1343
1347
|
});
|
|
1344
1348
|
const tap = react_native_gesture_handler.Gesture.Tap().runOnJS(true).onEnd((_event, success) => {
|
|
1345
1349
|
if (success) handlePress();
|
|
@@ -1352,7 +1356,8 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
1352
1356
|
resizable,
|
|
1353
1357
|
snapMinutes,
|
|
1354
1358
|
cellHeight,
|
|
1355
|
-
|
|
1359
|
+
moving,
|
|
1360
|
+
resizeYielded,
|
|
1356
1361
|
resizeDelta,
|
|
1357
1362
|
dragZ,
|
|
1358
1363
|
commitDrag,
|
|
@@ -1362,14 +1367,18 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
1362
1367
|
handleLongPressFromHandle
|
|
1363
1368
|
]);
|
|
1364
1369
|
const resizeStartGesture = (0, react.useMemo)(() => {
|
|
1365
|
-
const pan = react_native_gesture_handler.Gesture.Pan().enabled(resizableFromStart).
|
|
1366
|
-
|
|
1367
|
-
|
|
1370
|
+
const pan = react_native_gesture_handler.Gesture.Pan().enabled(resizableFromStart).onStart(() => {
|
|
1371
|
+
if (moving.value) {
|
|
1372
|
+
resizeYielded.value = 1;
|
|
1373
|
+
return;
|
|
1374
|
+
}
|
|
1368
1375
|
dragZ.value = DRAG_EVENT_Z;
|
|
1369
1376
|
(0, react_native_reanimated.runOnJS)(notifyDragStart)();
|
|
1370
1377
|
}).onUpdate((event) => {
|
|
1378
|
+
if (resizeYielded.value) return;
|
|
1371
1379
|
resizeStartDelta.value = event.translationY;
|
|
1372
1380
|
}).onEnd((event) => {
|
|
1381
|
+
if (resizeYielded.value) return;
|
|
1373
1382
|
const delta = (0, _super_calendar_core.snapDeltaMinutes)(event.translationY, cellHeight.value, snapMinutes);
|
|
1374
1383
|
if (delta === 0) {
|
|
1375
1384
|
resizeStartDelta.value = 0;
|
|
@@ -1378,8 +1387,8 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
1378
1387
|
resizeStartDelta.value = delta / MINUTES_PER_HOUR$1 * cellHeight.value;
|
|
1379
1388
|
(0, react_native_reanimated.runOnJS)(commitDrag)(delta, 0);
|
|
1380
1389
|
}).onFinalize(() => {
|
|
1381
|
-
dragZ.value = 0;
|
|
1382
|
-
|
|
1390
|
+
if (!resizeYielded.value) dragZ.value = 0;
|
|
1391
|
+
resizeYielded.value = 0;
|
|
1383
1392
|
});
|
|
1384
1393
|
const tap = react_native_gesture_handler.Gesture.Tap().runOnJS(true).onEnd((_event, success) => {
|
|
1385
1394
|
if (success) handlePress();
|
|
@@ -1392,7 +1401,8 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
1392
1401
|
resizableFromStart,
|
|
1393
1402
|
snapMinutes,
|
|
1394
1403
|
cellHeight,
|
|
1395
|
-
|
|
1404
|
+
moving,
|
|
1405
|
+
resizeYielded,
|
|
1396
1406
|
resizeStartDelta,
|
|
1397
1407
|
dragZ,
|
|
1398
1408
|
commitDrag,
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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";
|
|
@@ -961,7 +961,7 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
961
961
|
const resizeStartDelta = useSharedValue(0);
|
|
962
962
|
const dragZ = useSharedValue(0);
|
|
963
963
|
const moving = useSharedValue(0);
|
|
964
|
-
const
|
|
964
|
+
const resizeYielded = useSharedValue(0);
|
|
965
965
|
const edgeDir = useSharedValue(0);
|
|
966
966
|
const lifted = useSharedValue(0);
|
|
967
967
|
const grabX = useSharedValue(0);
|
|
@@ -1015,7 +1015,7 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
1015
1015
|
]);
|
|
1016
1016
|
const boxStyle = useAnimatedStyle(() => {
|
|
1017
1017
|
const top = (startHours + moveExtra.value.top - minHour) * cellHeight.value + moveOffset.value + resizeStartDelta.value;
|
|
1018
|
-
const floating =
|
|
1018
|
+
const floating = moving.value || moveOffset.value !== 0 || moveOffsetX.value !== 0;
|
|
1019
1019
|
return {
|
|
1020
1020
|
left: floating ? dayLeftPx : left,
|
|
1021
1021
|
width: floating ? dayWidth : width,
|
|
@@ -1299,14 +1299,18 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
1299
1299
|
press?.(event);
|
|
1300
1300
|
}, []);
|
|
1301
1301
|
const resizeGesture = useMemo(() => {
|
|
1302
|
-
const pan = Gesture.Pan().enabled(resizable).
|
|
1303
|
-
|
|
1304
|
-
|
|
1302
|
+
const pan = Gesture.Pan().enabled(resizable).onStart(() => {
|
|
1303
|
+
if (moving.value) {
|
|
1304
|
+
resizeYielded.value = 1;
|
|
1305
|
+
return;
|
|
1306
|
+
}
|
|
1305
1307
|
dragZ.value = DRAG_EVENT_Z;
|
|
1306
1308
|
runOnJS(notifyDragStart)();
|
|
1307
1309
|
}).onUpdate((event) => {
|
|
1310
|
+
if (resizeYielded.value) return;
|
|
1308
1311
|
resizeDelta.value = event.translationY;
|
|
1309
1312
|
}).onEnd((event) => {
|
|
1313
|
+
if (resizeYielded.value) return;
|
|
1310
1314
|
const delta = snapDeltaMinutes(event.translationY, cellHeight.value, snapMinutes);
|
|
1311
1315
|
if (delta === 0) {
|
|
1312
1316
|
resizeDelta.value = 0;
|
|
@@ -1315,8 +1319,8 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
1315
1319
|
resizeDelta.value = delta / MINUTES_PER_HOUR$1 * cellHeight.value;
|
|
1316
1320
|
runOnJS(commitDrag)(0, delta);
|
|
1317
1321
|
}).onFinalize(() => {
|
|
1318
|
-
dragZ.value = 0;
|
|
1319
|
-
|
|
1322
|
+
if (!resizeYielded.value) dragZ.value = 0;
|
|
1323
|
+
resizeYielded.value = 0;
|
|
1320
1324
|
});
|
|
1321
1325
|
const tap = Gesture.Tap().runOnJS(true).onEnd((_event, success) => {
|
|
1322
1326
|
if (success) handlePress();
|
|
@@ -1329,7 +1333,8 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
1329
1333
|
resizable,
|
|
1330
1334
|
snapMinutes,
|
|
1331
1335
|
cellHeight,
|
|
1332
|
-
|
|
1336
|
+
moving,
|
|
1337
|
+
resizeYielded,
|
|
1333
1338
|
resizeDelta,
|
|
1334
1339
|
dragZ,
|
|
1335
1340
|
commitDrag,
|
|
@@ -1339,14 +1344,18 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
1339
1344
|
handleLongPressFromHandle
|
|
1340
1345
|
]);
|
|
1341
1346
|
const resizeStartGesture = useMemo(() => {
|
|
1342
|
-
const pan = Gesture.Pan().enabled(resizableFromStart).
|
|
1343
|
-
|
|
1344
|
-
|
|
1347
|
+
const pan = Gesture.Pan().enabled(resizableFromStart).onStart(() => {
|
|
1348
|
+
if (moving.value) {
|
|
1349
|
+
resizeYielded.value = 1;
|
|
1350
|
+
return;
|
|
1351
|
+
}
|
|
1345
1352
|
dragZ.value = DRAG_EVENT_Z;
|
|
1346
1353
|
runOnJS(notifyDragStart)();
|
|
1347
1354
|
}).onUpdate((event) => {
|
|
1355
|
+
if (resizeYielded.value) return;
|
|
1348
1356
|
resizeStartDelta.value = event.translationY;
|
|
1349
1357
|
}).onEnd((event) => {
|
|
1358
|
+
if (resizeYielded.value) return;
|
|
1350
1359
|
const delta = snapDeltaMinutes(event.translationY, cellHeight.value, snapMinutes);
|
|
1351
1360
|
if (delta === 0) {
|
|
1352
1361
|
resizeStartDelta.value = 0;
|
|
@@ -1355,8 +1364,8 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
1355
1364
|
resizeStartDelta.value = delta / MINUTES_PER_HOUR$1 * cellHeight.value;
|
|
1356
1365
|
runOnJS(commitDrag)(delta, 0);
|
|
1357
1366
|
}).onFinalize(() => {
|
|
1358
|
-
dragZ.value = 0;
|
|
1359
|
-
|
|
1367
|
+
if (!resizeYielded.value) dragZ.value = 0;
|
|
1368
|
+
resizeYielded.value = 0;
|
|
1360
1369
|
});
|
|
1361
1370
|
const tap = Gesture.Tap().runOnJS(true).onEnd((_event, success) => {
|
|
1362
1371
|
if (success) handlePress();
|
|
@@ -1369,7 +1378,8 @@ function AnimatedEventBoxInner({ positioned, eventIndex, movingEvent, onMovePrev
|
|
|
1369
1378
|
resizableFromStart,
|
|
1370
1379
|
snapMinutes,
|
|
1371
1380
|
cellHeight,
|
|
1372
|
-
|
|
1381
|
+
moving,
|
|
1382
|
+
resizeYielded,
|
|
1373
1383
|
resizeStartDelta,
|
|
1374
1384
|
dragZ,
|
|
1375
1385
|
commitDrag,
|
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, nowInTimeZone } 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;
|
|
@@ -33,6 +33,7 @@ import type {
|
|
|
33
33
|
CalendarMode,
|
|
34
34
|
CreateGhostArgs,
|
|
35
35
|
EventKeyExtractor,
|
|
36
|
+
MonthDateInfo,
|
|
36
37
|
RenderEvent,
|
|
37
38
|
RenderEventArgs,
|
|
38
39
|
WeekStartsOn,
|
|
@@ -49,8 +50,6 @@ import {
|
|
|
49
50
|
expandRecurringEvents,
|
|
50
51
|
type WeekdayFormat,
|
|
51
52
|
getViewDays,
|
|
52
|
-
} from "@super-calendar/core";
|
|
53
|
-
import {
|
|
54
53
|
type CalendarHandle,
|
|
55
54
|
type CalendarLabels,
|
|
56
55
|
resolveCalendarLabels,
|
|
@@ -378,10 +377,11 @@ export type CalendarProps<T> = SlotStyleProps<CalendarSlot> & {
|
|
|
378
377
|
renderHeaderForMonthView?: (weekDays: Date[]) => React.ReactNode;
|
|
379
378
|
/**
|
|
380
379
|
* Month mode only: replace the default date badge in each day cell. Receives
|
|
381
|
-
* the day
|
|
380
|
+
* the day and its state (`isCurrentMonth`, `isToday`, `isSelected`,
|
|
381
|
+
* `isDisabled`); return your own date label (e.g. a number with a dot or badge).
|
|
382
382
|
* Event chips and the "+N more" label still render below it.
|
|
383
383
|
*/
|
|
384
|
-
renderCustomDateForMonth?: (date: Date) => React.ReactNode;
|
|
384
|
+
renderCustomDateForMonth?: (date: Date, info: MonthDateInfo) => React.ReactNode;
|
|
385
385
|
/** Drawn between rows of the `schedule` (agenda) list. */
|
|
386
386
|
itemSeparatorComponent?: React.ComponentType<unknown> | null;
|
|
387
387
|
};
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { memo, useCallback, useLayoutEffect, useRef, type ComponentRef } from "react";
|
|
2
|
+
import {
|
|
3
|
+
type LayoutChangeEvent,
|
|
4
|
+
type LayoutRectangle,
|
|
5
|
+
Platform,
|
|
6
|
+
StyleSheet,
|
|
7
|
+
TouchableOpacity,
|
|
8
|
+
View,
|
|
9
|
+
type StyleProp,
|
|
10
|
+
type ViewStyle,
|
|
11
|
+
} from "react-native";
|
|
12
|
+
import type { ResolvedSlot } from "../utils/slots";
|
|
13
|
+
|
|
14
|
+
export interface MonthCellGeometry {
|
|
15
|
+
minimumHeight: number;
|
|
16
|
+
top: number;
|
|
17
|
+
bottom: number;
|
|
18
|
+
gap: number;
|
|
19
|
+
overlayTop: number;
|
|
20
|
+
weekMargin: number;
|
|
21
|
+
weekMarginTop: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
type ProbeView = ComponentRef<typeof View>;
|
|
25
|
+
type Part = "frame" | "row" | "cell" | "date" | "lane" | "overlay";
|
|
26
|
+
const MARKER_HEIGHT = 1;
|
|
27
|
+
const hiddenProbeProps = {
|
|
28
|
+
pointerEvents: "none",
|
|
29
|
+
accessible: false,
|
|
30
|
+
accessibilityElementsHidden: true,
|
|
31
|
+
importantForAccessibility: "no-hide-descendants",
|
|
32
|
+
...(Platform.OS === "web" ? { "aria-hidden": true, inert: "inert" } : {}),
|
|
33
|
+
} as const;
|
|
34
|
+
|
|
35
|
+
// Zero-height weeks leave only the grid's padding, borders and gaps. The outer
|
|
36
|
+
// box also includes its margins. Neither measurement depends on the drawn rows.
|
|
37
|
+
export const MonthGridSpacingProbe = memo(function MonthGridSpacingProbe({
|
|
38
|
+
grid,
|
|
39
|
+
weeks,
|
|
40
|
+
onInnerHeight,
|
|
41
|
+
onOuterHeight,
|
|
42
|
+
}: {
|
|
43
|
+
grid: ResolvedSlot<ViewStyle>;
|
|
44
|
+
weeks: number;
|
|
45
|
+
onInnerHeight: (height: number) => void;
|
|
46
|
+
onOuterHeight: (height: number) => void;
|
|
47
|
+
}) {
|
|
48
|
+
return (
|
|
49
|
+
<View
|
|
50
|
+
{...hiddenProbeProps}
|
|
51
|
+
style={styles.frame}
|
|
52
|
+
onLayout={(e) => onOuterHeight(e.nativeEvent.layout.height)}
|
|
53
|
+
>
|
|
54
|
+
<View
|
|
55
|
+
{...grid}
|
|
56
|
+
style={[grid.style, styles.gridSpacing]}
|
|
57
|
+
onLayout={(e) => onInnerHeight(e.nativeEvent.layout.height)}
|
|
58
|
+
>
|
|
59
|
+
{Array.from({ length: weeks }, (_, index) => (
|
|
60
|
+
<View key={index} style={styles.emptyWeek} />
|
|
61
|
+
))}
|
|
62
|
+
</View>
|
|
63
|
+
</View>
|
|
64
|
+
);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// The two markers take the place of the date and the first event. Their natural
|
|
68
|
+
// positions include spacing applied by a class, including on the enclosing week.
|
|
69
|
+
// The probe has no fixed height, so measuring it cannot grow the visible rows.
|
|
70
|
+
export const MonthCellProbe = memo(function MonthCellProbe({
|
|
71
|
+
id,
|
|
72
|
+
week,
|
|
73
|
+
day,
|
|
74
|
+
cellStyle,
|
|
75
|
+
dayWidth,
|
|
76
|
+
weekWidth,
|
|
77
|
+
onMeasure,
|
|
78
|
+
}: {
|
|
79
|
+
id: string;
|
|
80
|
+
week: ResolvedSlot<ViewStyle>;
|
|
81
|
+
day: ResolvedSlot<ViewStyle>;
|
|
82
|
+
cellStyle: StyleProp<ViewStyle>;
|
|
83
|
+
dayWidth: number;
|
|
84
|
+
weekWidth: number;
|
|
85
|
+
onMeasure: (id: string, geometry: MonthCellGeometry) => void;
|
|
86
|
+
}) {
|
|
87
|
+
const layouts = useRef<Partial<Record<Part, LayoutRectangle>>>({});
|
|
88
|
+
const nodes = useRef<Partial<Record<Part, ProbeView | null>>>({});
|
|
89
|
+
const report = useCallback(
|
|
90
|
+
(
|
|
91
|
+
height: number,
|
|
92
|
+
row: Pick<LayoutRectangle, "y" | "height">,
|
|
93
|
+
top: number,
|
|
94
|
+
laneTop: number,
|
|
95
|
+
laneHeight: number,
|
|
96
|
+
overlayTop: number,
|
|
97
|
+
) => {
|
|
98
|
+
if (height > 0)
|
|
99
|
+
onMeasure(id, {
|
|
100
|
+
minimumHeight: height,
|
|
101
|
+
top,
|
|
102
|
+
gap: Math.max(0, laneTop - top - MARKER_HEIGHT),
|
|
103
|
+
bottom: height - laneTop - laneHeight,
|
|
104
|
+
overlayTop,
|
|
105
|
+
weekMargin: height - row.height,
|
|
106
|
+
weekMarginTop: row.y,
|
|
107
|
+
});
|
|
108
|
+
},
|
|
109
|
+
[id, onMeasure],
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
// React Native Web's onLayout observes resizing. Changing padding can move both
|
|
113
|
+
// markers without resizing them. Read their layout offsets before ancestor transforms.
|
|
114
|
+
const readWeb = useCallback(() => {
|
|
115
|
+
if (Platform.OS !== "web" || typeof HTMLElement === "undefined") return false;
|
|
116
|
+
const frame = nodes.current.frame;
|
|
117
|
+
if (!(frame instanceof HTMLElement)) return false;
|
|
118
|
+
const layout = (part: Part) => {
|
|
119
|
+
const node = nodes.current[part];
|
|
120
|
+
if (!(node instanceof HTMLElement)) return;
|
|
121
|
+
let y = 0;
|
|
122
|
+
let current: HTMLElement = node;
|
|
123
|
+
while (current !== frame) {
|
|
124
|
+
const parent = current.offsetParent;
|
|
125
|
+
if (!(parent instanceof HTMLElement)) return;
|
|
126
|
+
y += current.offsetTop + parent.clientTop;
|
|
127
|
+
current = parent;
|
|
128
|
+
}
|
|
129
|
+
return { y, height: node.offsetHeight };
|
|
130
|
+
};
|
|
131
|
+
const row = layout("row"),
|
|
132
|
+
date = layout("date"),
|
|
133
|
+
lane = layout("lane"),
|
|
134
|
+
overlay = layout("overlay");
|
|
135
|
+
if (!row || !date || !lane || !overlay) return false;
|
|
136
|
+
report(frame.offsetHeight, row, date.y, lane.y, lane.height, overlay.y);
|
|
137
|
+
return true;
|
|
138
|
+
}, [report]);
|
|
139
|
+
|
|
140
|
+
useLayoutEffect(() => {
|
|
141
|
+
readWeb();
|
|
142
|
+
}, [readWeb, week, day, cellStyle, dayWidth, weekWidth]);
|
|
143
|
+
|
|
144
|
+
function observe(part: Part) {
|
|
145
|
+
return {
|
|
146
|
+
...(Platform.OS === "web" && {
|
|
147
|
+
ref: (node: ProbeView | null) => {
|
|
148
|
+
nodes.current[part] = node;
|
|
149
|
+
},
|
|
150
|
+
}),
|
|
151
|
+
onLayout: (event: LayoutChangeEvent) => {
|
|
152
|
+
if (readWeb()) return;
|
|
153
|
+
layouts.current[part] = event.nativeEvent.layout;
|
|
154
|
+
const { frame, row, cell, date, lane, overlay } = layouts.current;
|
|
155
|
+
if (!frame || !row || !cell || !date || !lane || !overlay) return;
|
|
156
|
+
const cellTop = row.y + cell.y;
|
|
157
|
+
report(
|
|
158
|
+
frame.height,
|
|
159
|
+
row,
|
|
160
|
+
cellTop + date.y,
|
|
161
|
+
cellTop + lane.y,
|
|
162
|
+
lane.height,
|
|
163
|
+
row.y + overlay.y,
|
|
164
|
+
);
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
return (
|
|
169
|
+
<View {...observe("frame")} style={styles.frame} collapsable={false} {...hiddenProbeProps}>
|
|
170
|
+
<View
|
|
171
|
+
{...observe("row")}
|
|
172
|
+
{...week}
|
|
173
|
+
style={[week.style, styles.intrinsic, { width: weekWidth }]}
|
|
174
|
+
collapsable={false}
|
|
175
|
+
>
|
|
176
|
+
<TouchableOpacity
|
|
177
|
+
{...day}
|
|
178
|
+
style={[day.style, cellStyle, styles.measuredDay, { width: dayWidth }]}
|
|
179
|
+
disabled
|
|
180
|
+
onLayout={observe("cell").onLayout}
|
|
181
|
+
>
|
|
182
|
+
<View {...observe("date")} style={styles.marker} collapsable={false} />
|
|
183
|
+
<View {...observe("lane")} style={styles.laneMarker} collapsable={false} />
|
|
184
|
+
</TouchableOpacity>
|
|
185
|
+
<View {...observe("overlay")} style={StyleSheet.absoluteFill} collapsable={false} />
|
|
186
|
+
</View>
|
|
187
|
+
</View>
|
|
188
|
+
);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
const styles = StyleSheet.create({
|
|
192
|
+
frame: { position: "absolute", top: 0, left: 0, right: 0, opacity: 0 },
|
|
193
|
+
gridSpacing: { height: "auto", minHeight: 0, maxHeight: "auto", flex: 0 },
|
|
194
|
+
emptyWeek: { height: 0 },
|
|
195
|
+
intrinsic: { height: "auto", minHeight: 0 },
|
|
196
|
+
// The visible cell supplies the width, including changes from gaps and hidden days.
|
|
197
|
+
measuredDay: { justifyContent: "flex-start", alignSelf: "stretch", flex: 0, flexBasis: "auto" },
|
|
198
|
+
marker: { height: MARKER_HEIGHT },
|
|
199
|
+
// Fill space reserved by the day height so it does not count as bottom padding.
|
|
200
|
+
laneMarker: { height: MARKER_HEIGHT, flexGrow: 1 },
|
|
201
|
+
});
|
|
@@ -44,9 +44,11 @@ import {
|
|
|
44
44
|
type EventAccessibilityLabeler,
|
|
45
45
|
type WeekdayFormat,
|
|
46
46
|
isDateSelectable,
|
|
47
|
+
type CalendarLabels,
|
|
48
|
+
buildMonthWeeks,
|
|
49
|
+
getWeekDays,
|
|
50
|
+
weekdayFormatToken,
|
|
47
51
|
} from "@super-calendar/core";
|
|
48
|
-
import type { CalendarLabels } from "@super-calendar/core";
|
|
49
|
-
import { buildMonthWeeks, getWeekDays, weekdayFormatToken } from "@super-calendar/core";
|
|
50
52
|
import { createSlots, type SlotStyleProps } from "../utils/slots";
|
|
51
53
|
import { DefaultMonthEvent } from "./DefaultMonthEvent";
|
|
52
54
|
import { MonthView, type MonthViewSlot } from "./MonthView";
|
|
@@ -42,6 +42,7 @@ import type {
|
|
|
42
42
|
EventDragHandler,
|
|
43
43
|
EventDragStartHandler,
|
|
44
44
|
EventKeyExtractor,
|
|
45
|
+
MonthDateInfo,
|
|
45
46
|
RenderEvent,
|
|
46
47
|
WeekStartsOn,
|
|
47
48
|
} from "../types";
|
|
@@ -55,8 +56,8 @@ import {
|
|
|
55
56
|
filterHiddenDays,
|
|
56
57
|
getWeekDays,
|
|
57
58
|
weekdayFormatToken,
|
|
59
|
+
type CalendarLabels,
|
|
58
60
|
} from "@super-calendar/core";
|
|
59
|
-
import type { CalendarLabels } from "@super-calendar/core";
|
|
60
61
|
import { createSlots, type SlotStyleProps } from "../utils/slots";
|
|
61
62
|
import { useWebPagerKeys } from "../utils/useWebPagerKeys";
|
|
62
63
|
import { DateRows, type DateRowsSource, type MonthViewSlot } from "./MonthView";
|
|
@@ -143,8 +144,8 @@ export type MonthPagerProps<T> = {
|
|
|
143
144
|
activeDate?: Date;
|
|
144
145
|
/** Replace the weekday-label header above the month grid. Receives the week's days. */
|
|
145
146
|
renderHeaderForMonthView?: (weekDays: Date[]) => React.ReactNode;
|
|
146
|
-
/** Replace the default date badge in each day cell. Receives the day. */
|
|
147
|
-
renderCustomDateForMonth?: (date: Date) => React.ReactNode;
|
|
147
|
+
/** Replace the default date badge in each day cell. Receives the day and its state. */
|
|
148
|
+
renderCustomDateForMonth?: (date: Date, info: MonthDateInfo) => React.ReactNode;
|
|
148
149
|
} & SlotStyleProps<MonthViewSlot>;
|
|
149
150
|
|
|
150
151
|
/**
|