@super-calendar/native 2.8.1 → 2.9.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 +1 -0
- package/dist/{DefaultMonthEvent-CjwX3Nt1.d.ts → DefaultMonthEvent--9Jg6w-x.d.ts} +98 -10
- package/dist/{DefaultMonthEvent-VgJarTO_.d.mts → DefaultMonthEvent-BlnKHaq2.d.mts} +98 -10
- package/dist/{MonthList-DjAz4xoi.mjs → MonthList-CjKhzOJX.mjs} +356 -102
- package/dist/{MonthList-C-vBotP0.js → MonthList-DNT1LJkk.js} +355 -101
- package/dist/index.d.mts +85 -37
- package/dist/index.d.ts +85 -37
- package/dist/index.js +377 -60
- package/dist/index.mjs +378 -61
- 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 +3 -3
- package/src/components/AllDayLane.tsx +2 -2
- package/src/components/Calendar.tsx +79 -16
- package/src/components/MonthList.tsx +3 -2
- package/src/components/MonthPager.tsx +152 -63
- package/src/components/MonthView.tsx +422 -80
- package/src/components/TimeGrid.tsx +247 -35
- package/src/components/YearView.tsx +371 -83
- package/src/types.ts +19 -0
- package/src/utils/slots.ts +33 -9
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-DNT1LJkk.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 { d as darkTheme, f as defaultTheme, i as MonthView, m as useCalendarTheme, n as DefaultMonthEvent, p as mergeTheme, r as MonthPager, t as MonthList, u as CalendarThemeProvider } from "./MonthList-
|
|
1
|
+
import { d as darkTheme, f as defaultTheme, i as MonthView, m as useCalendarTheme, n as DefaultMonthEvent, p as mergeTheme, r as MonthPager, t as MonthList, u as CalendarThemeProvider } from "./MonthList-CjKhzOJX.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.9.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.9.0"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
70
|
"@legendapp/list": ">=3",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LegendList, type LegendListRenderItemProps } from "@legendapp/list/react-native";
|
|
2
2
|
import { format, isSameDay, type Locale, startOfDay } from "date-fns";
|
|
3
3
|
import { type ComponentType, type ReactElement, useCallback, useMemo } from "react";
|
|
4
|
-
import { StyleSheet, Text, View } from "react-native";
|
|
4
|
+
import { StyleSheet, Text, type TextStyle, View } from "react-native";
|
|
5
5
|
import { useCalendarTheme } from "../theme";
|
|
6
6
|
import type { CalendarEvent, EventKeyExtractor, RenderEvent } from "../types";
|
|
7
7
|
import { createSlots, type SlotStyleProps } from "../utils/slots";
|
|
@@ -83,7 +83,7 @@ export function Agenda<T>({
|
|
|
83
83
|
const isHighlighted = activeDate ? isSameDay(item.date, activeDate) : getIsToday(item.date);
|
|
84
84
|
return (
|
|
85
85
|
<Text
|
|
86
|
-
{...slot("dayHeader", {
|
|
86
|
+
{...slot<TextStyle>("dayHeader", {
|
|
87
87
|
base: styles.header,
|
|
88
88
|
themed: [
|
|
89
89
|
styles.headerText,
|
|
@@ -124,7 +124,7 @@ export function Agenda<T>({
|
|
|
124
124
|
if (rows.length === 0) {
|
|
125
125
|
return (
|
|
126
126
|
<Text
|
|
127
|
-
{...slot("empty", {
|
|
127
|
+
{...slot<TextStyle>("empty", {
|
|
128
128
|
base: styles.empty,
|
|
129
129
|
themed: [styles.emptyText, { color: theme.colors.textMuted }],
|
|
130
130
|
})}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { addDays, startOfDay } from "date-fns";
|
|
2
|
-
import { StyleSheet, Text, View } from "react-native";
|
|
2
|
+
import { StyleSheet, Text, type TextStyle, View } from "react-native";
|
|
3
3
|
import { useCalendarTheme } from "../theme";
|
|
4
4
|
import type { CalendarEvent, CalendarMode, EventKeyExtractor, RenderEvent } from "../types";
|
|
5
5
|
import { useSlots } from "../utils/slots";
|
|
@@ -64,7 +64,7 @@ export function AllDayLane<T>({
|
|
|
64
64
|
and right-aligned against the timed columns. Centered vertically so it
|
|
65
65
|
lines up with the chips whether the lane holds one event or several. */}
|
|
66
66
|
<Text
|
|
67
|
-
{...slot("allDayLabel", {
|
|
67
|
+
{...slot<TextStyle>("allDayLabel", {
|
|
68
68
|
base: styles.label,
|
|
69
69
|
themed: { color: theme.colors.textMuted },
|
|
70
70
|
})}
|
|
@@ -27,6 +27,7 @@ import type {
|
|
|
27
27
|
WeekStartsOn,
|
|
28
28
|
} from "../types";
|
|
29
29
|
import {
|
|
30
|
+
type DateRange,
|
|
30
31
|
type EventAccessibilityLabeler,
|
|
31
32
|
eventsInTimeZone,
|
|
32
33
|
expandRecurringEvents,
|
|
@@ -67,19 +68,20 @@ export type CalendarProps<T> = SlotStyleProps<CalendarSlot> & {
|
|
|
67
68
|
/** Long-press an event (month/week/day). */
|
|
68
69
|
onLongPressEvent?: (event: CalendarEvent<T>) => void;
|
|
69
70
|
/**
|
|
70
|
-
* Enable drag-to-move and drag-to-resize
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
71
|
+
* Enable drag-to-move and drag-to-resize. Called with the dragged event and its
|
|
72
|
+
* new start/end; update your own event state in response. On the week/day grid,
|
|
73
|
+
* long-press an event to move it (drag horizontally to change the day too) or
|
|
74
|
+
* drag its bottom grip to resize, snapped to `dragStepMinutes`. In `month` mode,
|
|
75
|
+
* long-press an event bar and drop it on another day: both ends shift by the
|
|
76
|
+
* days dragged, so the time of day and duration are kept. Return `false` to
|
|
77
|
+
* reject the drop (e.g. an overlap) and snap the event back.
|
|
75
78
|
*/
|
|
76
79
|
onDragEvent?: EventDragHandler<T>;
|
|
77
80
|
/**
|
|
78
|
-
* Fired when a
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
* `onDragEvent` is also set.
|
|
81
|
+
* Fired when a drag gesture begins, before any change is committed: on grab for
|
|
82
|
+
* a move (after the long-press), and when a week/day resize drag starts. Use it
|
|
83
|
+
* to trigger haptic feedback, e.g. `Haptics.impactAsync()` from `expo-haptics`.
|
|
84
|
+
* Native-only and inert unless `onDragEvent` is also set.
|
|
83
85
|
*/
|
|
84
86
|
onDragStart?: EventDragStartHandler<T>;
|
|
85
87
|
/** Minutes a drag-to-move/resize snaps to. Default 15. */
|
|
@@ -97,20 +99,47 @@ export type CalendarProps<T> = SlotStyleProps<CalendarSlot> & {
|
|
|
97
99
|
onLongPressDay?: (date: Date) => void;
|
|
98
100
|
/** Tap the "+N more" overflow label in a month cell. */
|
|
99
101
|
onPressMore?: (events: CalendarEvent<T>[], date: Date) => void;
|
|
100
|
-
/**
|
|
102
|
+
/**
|
|
103
|
+
* Tap empty space; receives the date+time pressed on the week/day grid, or the
|
|
104
|
+
* tapped day at midnight in `month` mode (where it fires alongside `onPressDay`).
|
|
105
|
+
*/
|
|
101
106
|
onPressCell?: (date: Date) => void;
|
|
102
107
|
/** After an empty-cell press, snap the pager back to the active page. Default false. */
|
|
103
108
|
resetPageOnPressCell?: boolean;
|
|
104
109
|
/** Long-press empty space on the week/day grid; receives the date+time. */
|
|
105
110
|
onLongPressCell?: (date: Date) => void;
|
|
106
111
|
/**
|
|
107
|
-
* Enable drag-to-create
|
|
108
|
-
*
|
|
109
|
-
* `
|
|
110
|
-
*
|
|
111
|
-
* `
|
|
112
|
+
* Enable drag-to-create: long-press empty space and drag to sweep out a new
|
|
113
|
+
* event, then release. On the week/day grid that is a time range snapped to
|
|
114
|
+
* `dragStepMinutes` (a stationary press yields a one-step range); in `month`
|
|
115
|
+
* mode it is an **all-day** span across the days swept — `start` at midnight of
|
|
116
|
+
* the first day, `end` at midnight after the last. Create your own event in
|
|
117
|
+
* response. Supersedes `onLongPressCell` (and, in month mode, `onLongPressDay`)
|
|
118
|
+
* on empty space when set.
|
|
112
119
|
*/
|
|
113
120
|
onCreateEvent?: (start: Date, end: Date) => void;
|
|
121
|
+
/**
|
|
122
|
+
* Month and year modes: reports a create sweep's day span as it happens, as the
|
|
123
|
+
* ordered inclusive `[start, end]` days, so a selection highlight can follow the
|
|
124
|
+
* drag. Pair it with `useDateRange`'s `selectRange` to drive `selectedRange`.
|
|
125
|
+
* Enables the sweep on its own, so it works without `onCreateEvent`.
|
|
126
|
+
*/
|
|
127
|
+
onSelectDrag?: (start: Date, end: Date) => void;
|
|
128
|
+
/** Days drawn as selected (a filled badge) in month and year modes. */
|
|
129
|
+
selectedDates?: Date[];
|
|
130
|
+
/** A selected span: endpoints get a filled badge, the span gets the range band. */
|
|
131
|
+
selectedRange?: DateRange;
|
|
132
|
+
/**
|
|
133
|
+
* Fill the whole month cell with the range band instead of the default centered
|
|
134
|
+
* rounded "pill" strip. Default false.
|
|
135
|
+
*/
|
|
136
|
+
fillCellOnSelection?: boolean;
|
|
137
|
+
/** Earliest selectable day (inclusive); earlier days render disabled. */
|
|
138
|
+
minDate?: Date;
|
|
139
|
+
/** Latest selectable day (inclusive); later days render disabled. */
|
|
140
|
+
maxDate?: Date;
|
|
141
|
+
/** Return true to render a specific day disabled (dimmed, taps ignored). */
|
|
142
|
+
isDateDisabled?: (date: Date) => boolean;
|
|
114
143
|
/** Tap a day's column header on the week/day grid (default header only). */
|
|
115
144
|
onPressDateHeader?: (date: Date) => void;
|
|
116
145
|
/**
|
|
@@ -209,6 +238,11 @@ export type CalendarProps<T> = SlotStyleProps<CalendarSlot> & {
|
|
|
209
238
|
hourComponent?: HourRenderer;
|
|
210
239
|
/** Always render six week rows in month view, for a fixed-height grid. Default false. */
|
|
211
240
|
showSixWeeks?: boolean;
|
|
241
|
+
/**
|
|
242
|
+
* Render the built-in "MMMM yyyy" title above the month grid. Default true. Set
|
|
243
|
+
* false when your own header already shows the month and year. Month mode only.
|
|
244
|
+
*/
|
|
245
|
+
showTitle?: boolean;
|
|
212
246
|
/** Allow swiping between pages (all modes). Default true. */
|
|
213
247
|
swipeEnabled?: boolean;
|
|
214
248
|
/** Show the vertical scroll indicator on the week/day grid. Default true. */
|
|
@@ -380,6 +414,13 @@ export function Calendar<T>({
|
|
|
380
414
|
resetPageOnPressCell,
|
|
381
415
|
onLongPressCell,
|
|
382
416
|
onCreateEvent,
|
|
417
|
+
onSelectDrag,
|
|
418
|
+
selectedDates,
|
|
419
|
+
selectedRange,
|
|
420
|
+
fillCellOnSelection,
|
|
421
|
+
minDate,
|
|
422
|
+
maxDate,
|
|
423
|
+
isDateDisabled,
|
|
383
424
|
onPressDateHeader,
|
|
384
425
|
maxVisibleEventCount,
|
|
385
426
|
sortedMonthView,
|
|
@@ -416,6 +457,7 @@ export function Calendar<T>({
|
|
|
416
457
|
weekNumberPrefix,
|
|
417
458
|
hourComponent,
|
|
418
459
|
showSixWeeks,
|
|
460
|
+
showTitle,
|
|
419
461
|
swipeEnabled,
|
|
420
462
|
showVerticalScrollIndicator,
|
|
421
463
|
verticalScrollEnabled,
|
|
@@ -557,6 +599,7 @@ export function Calendar<T>({
|
|
|
557
599
|
disableMonthEventCellPress={disableMonthEventCellPress}
|
|
558
600
|
isRTL={isRTL}
|
|
559
601
|
showSixWeeks={showSixWeeks}
|
|
602
|
+
showTitle={showTitle}
|
|
560
603
|
activeDate={activeDate}
|
|
561
604
|
renderHeaderForMonthView={renderHeaderForMonthView}
|
|
562
605
|
renderCustomDateForMonth={renderCustomDateForMonth}
|
|
@@ -565,9 +608,22 @@ export function Calendar<T>({
|
|
|
565
608
|
keyExtractor={keyExtractor}
|
|
566
609
|
onPressDay={onPressDay}
|
|
567
610
|
onLongPressDay={onLongPressDay}
|
|
611
|
+
onPressCell={onPressCell}
|
|
568
612
|
onPressEvent={handlePressEvent}
|
|
569
613
|
onLongPressEvent={handleLongPressEvent}
|
|
570
614
|
onPressMore={onPressMore}
|
|
615
|
+
onCreateEvent={onCreateEvent}
|
|
616
|
+
onSelectDrag={onSelectDrag}
|
|
617
|
+
onDragEvent={onDragEvent}
|
|
618
|
+
onDragStart={onDragStart}
|
|
619
|
+
eventStartEditable={eventStartEditable}
|
|
620
|
+
eventOverlap={eventOverlap}
|
|
621
|
+
selectedDates={selectedDates}
|
|
622
|
+
selectedRange={selectedRange}
|
|
623
|
+
fillCellOnSelection={fillCellOnSelection}
|
|
624
|
+
minDate={minDate}
|
|
625
|
+
maxDate={maxDate}
|
|
626
|
+
isDateDisabled={isDateDisabled}
|
|
571
627
|
onChangeDate={handleChangeDate}
|
|
572
628
|
freeSwipe={freeSwipe}
|
|
573
629
|
swipeEnabled={swipeEnabled}
|
|
@@ -582,8 +638,15 @@ export function Calendar<T>({
|
|
|
582
638
|
hiddenDays={hiddenDays}
|
|
583
639
|
locale={locale}
|
|
584
640
|
activeDate={activeDate}
|
|
641
|
+
selectedDates={selectedDates}
|
|
642
|
+
selectedRange={selectedRange}
|
|
643
|
+
minDate={minDate}
|
|
644
|
+
maxDate={maxDate}
|
|
645
|
+
isDateDisabled={isDateDisabled}
|
|
585
646
|
onPressDay={onPressDay}
|
|
586
647
|
onPressMonth={onPressMonth}
|
|
648
|
+
onSelectDrag={onSelectDrag}
|
|
649
|
+
onCreateEvent={onCreateEvent}
|
|
587
650
|
classNames={classNames}
|
|
588
651
|
styles={styleOverrides}
|
|
589
652
|
/>
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
StyleSheet,
|
|
22
22
|
type StyleProp,
|
|
23
23
|
Text,
|
|
24
|
+
type TextStyle,
|
|
24
25
|
View,
|
|
25
26
|
type ViewStyle,
|
|
26
27
|
} from "react-native";
|
|
@@ -440,7 +441,7 @@ function MonthListInner<T>({
|
|
|
440
441
|
renderMonthHeader(item)
|
|
441
442
|
) : (
|
|
442
443
|
<Text
|
|
443
|
-
{...slot("title", {
|
|
444
|
+
{...slot<TextStyle>("title", {
|
|
444
445
|
base: styles.monthTitle,
|
|
445
446
|
themed: [styles.monthTitleText, { color: theme.colors.text }],
|
|
446
447
|
})}
|
|
@@ -560,7 +561,7 @@ function MonthListInner<T>({
|
|
|
560
561
|
{weekDays.map((day) => (
|
|
561
562
|
<Text
|
|
562
563
|
key={day.toISOString()}
|
|
563
|
-
{...slot("weekday", {
|
|
564
|
+
{...slot<TextStyle>("weekday", {
|
|
564
565
|
base: styles.weekdayLabel,
|
|
565
566
|
themed: [styles.weekdayLabelText, { color: theme.colors.textMuted }],
|
|
566
567
|
})}
|
|
@@ -11,13 +11,24 @@ import {
|
|
|
11
11
|
StyleSheet,
|
|
12
12
|
type StyleProp,
|
|
13
13
|
Text,
|
|
14
|
+
type TextStyle,
|
|
14
15
|
useWindowDimensions,
|
|
15
16
|
View,
|
|
16
17
|
type ViewStyle,
|
|
17
18
|
} from "react-native";
|
|
18
19
|
import { useCalendarTheme } from "../theme";
|
|
19
|
-
import type {
|
|
20
|
+
import type {
|
|
21
|
+
CalendarEvent,
|
|
22
|
+
EventDragHandler,
|
|
23
|
+
EventDragStartHandler,
|
|
24
|
+
EventKeyExtractor,
|
|
25
|
+
RenderEvent,
|
|
26
|
+
WeekStartsOn,
|
|
27
|
+
} from "../types";
|
|
20
28
|
import {
|
|
29
|
+
type CalendarSelection,
|
|
30
|
+
CalendarSelectionProvider,
|
|
31
|
+
type DateRange,
|
|
21
32
|
type WeekdayFormat,
|
|
22
33
|
filterHiddenDays,
|
|
23
34
|
getWeekDays,
|
|
@@ -61,13 +72,41 @@ export type MonthPagerProps<T> = {
|
|
|
61
72
|
keyExtractor: EventKeyExtractor<T>;
|
|
62
73
|
onPressDay?: (date: Date) => void;
|
|
63
74
|
onLongPressDay?: (date: Date) => void;
|
|
75
|
+
/** Tap an empty day cell; receives the day at midnight. */
|
|
76
|
+
onPressCell?: (date: Date) => void;
|
|
64
77
|
onPressEvent: (event: CalendarEvent<T>) => void;
|
|
65
78
|
onLongPressEvent?: (event: CalendarEvent<T>) => void;
|
|
66
79
|
onPressMore?: (events: CalendarEvent<T>[], date: Date) => void;
|
|
80
|
+
/** Drag across empty day cells to sweep out an all-day span for a new event. */
|
|
81
|
+
onCreateEvent?: (start: Date, end: Date) => void;
|
|
82
|
+
/** Drag-to-select: reports the swept `[start, end]` days live. */
|
|
83
|
+
onSelectDrag?: (start: Date, end: Date) => void;
|
|
84
|
+
/** Days drawn as selected (a filled badge). */
|
|
85
|
+
selectedDates?: Date[];
|
|
86
|
+
/** A selected span: endpoints get a filled badge, the span gets the range band. */
|
|
87
|
+
selectedRange?: DateRange;
|
|
88
|
+
/** Fill the whole cell on selection instead of the default rounded pill band. */
|
|
89
|
+
fillCellOnSelection?: boolean;
|
|
90
|
+
/** Earliest selectable day (inclusive); earlier days render disabled. */
|
|
91
|
+
minDate?: Date;
|
|
92
|
+
/** Latest selectable day (inclusive); later days render disabled. */
|
|
93
|
+
maxDate?: Date;
|
|
94
|
+
/** Return true to render a specific day disabled (dimmed, taps ignored). */
|
|
95
|
+
isDateDisabled?: (date: Date) => boolean;
|
|
96
|
+
/** Drag an event bar onto another day to reschedule it. */
|
|
97
|
+
onDragEvent?: EventDragHandler<T>;
|
|
98
|
+
/** Fired when a month drag picks an event up, before anything is committed. */
|
|
99
|
+
onDragStart?: EventDragStartHandler<T>;
|
|
100
|
+
/** Allow moving events by default (per-event `startEditable` overrides). Default true. */
|
|
101
|
+
eventStartEditable?: boolean;
|
|
102
|
+
/** Reject a drop that would overlap another event (default true = allowed). */
|
|
103
|
+
eventOverlap?: boolean;
|
|
67
104
|
onChangeDate: (date: Date) => void;
|
|
68
105
|
freeSwipe?: boolean;
|
|
69
106
|
swipeEnabled?: boolean;
|
|
70
107
|
showSixWeeks?: boolean;
|
|
108
|
+
/** Render the "MMMM yyyy" title above the weekday header. Default true. */
|
|
109
|
+
showTitle?: boolean;
|
|
71
110
|
activeDate?: Date;
|
|
72
111
|
/** Replace the weekday-label header above the month grid. Receives the week's days. */
|
|
73
112
|
renderHeaderForMonthView?: (weekDays: Date[]) => React.ReactNode;
|
|
@@ -94,13 +133,27 @@ function MonthPagerInner<T>({
|
|
|
94
133
|
keyExtractor,
|
|
95
134
|
onPressDay,
|
|
96
135
|
onLongPressDay,
|
|
136
|
+
onPressCell,
|
|
97
137
|
onPressEvent,
|
|
98
138
|
onLongPressEvent,
|
|
99
139
|
onPressMore,
|
|
140
|
+
onCreateEvent,
|
|
141
|
+
onSelectDrag,
|
|
142
|
+
selectedDates,
|
|
143
|
+
selectedRange,
|
|
144
|
+
fillCellOnSelection,
|
|
145
|
+
minDate,
|
|
146
|
+
maxDate,
|
|
147
|
+
isDateDisabled,
|
|
148
|
+
onDragEvent,
|
|
149
|
+
onDragStart,
|
|
150
|
+
eventStartEditable,
|
|
151
|
+
eventOverlap,
|
|
100
152
|
onChangeDate,
|
|
101
153
|
freeSwipe = false,
|
|
102
154
|
swipeEnabled = true,
|
|
103
155
|
showSixWeeks = false,
|
|
156
|
+
showTitle = true,
|
|
104
157
|
activeDate,
|
|
105
158
|
renderHeaderForMonthView,
|
|
106
159
|
renderCustomDateForMonth,
|
|
@@ -230,7 +283,21 @@ function MonthPagerInner<T>({
|
|
|
230
283
|
// `events` (events that arrive after mount, e.g. from an async fetch, must
|
|
231
284
|
// repaint the mounted page) and `activeDate` (the selected-day highlight must
|
|
232
285
|
// move). Mirrors listExtraData in TimeGrid.
|
|
233
|
-
|
|
286
|
+
// `fillCellOnSelection` and `onSelectDrag` ride along because they reach the
|
|
287
|
+
// grids as renderItem props, not through the selection context below: toggling
|
|
288
|
+
// a "pick dates" mode on must reach the pages already rendered.
|
|
289
|
+
const listExtraData = useMemo(
|
|
290
|
+
() => ({ events, activeDate, fillCellOnSelection, dragSelect: onSelectDrag != null }),
|
|
291
|
+
[events, activeDate, fillCellOnSelection, onSelectDrag],
|
|
292
|
+
);
|
|
293
|
+
|
|
294
|
+
// Selection reaches the grids through context, not `renderItem`, so a change
|
|
295
|
+
// repaints the pages LegendList has already cached (which `extraData` alone
|
|
296
|
+
// would not, since the pages are keyed by month and never recycled).
|
|
297
|
+
const selection = useMemo<CalendarSelection>(
|
|
298
|
+
() => ({ selectedDates, selectedRange, minDate, maxDate, isDateDisabled }),
|
|
299
|
+
[selectedDates, selectedRange, minDate, maxDate, isDateDisabled],
|
|
300
|
+
);
|
|
234
301
|
|
|
235
302
|
const snapToIndices = useMemo(() => monthDates.map((_, index) => index), [monthDates]);
|
|
236
303
|
const keyExtractorList = useCallback((item: Date) => item.toISOString(), []);
|
|
@@ -262,9 +329,17 @@ function MonthPagerInner<T>({
|
|
|
262
329
|
keyExtractor={keyExtractor}
|
|
263
330
|
onPressDay={onPressDay}
|
|
264
331
|
onLongPressDay={onLongPressDay}
|
|
332
|
+
onPressCell={onPressCell}
|
|
265
333
|
onPressEvent={onPressEvent}
|
|
266
334
|
onLongPressEvent={onLongPressEvent}
|
|
267
335
|
onPressMore={onPressMore}
|
|
336
|
+
onCreateEvent={onCreateEvent}
|
|
337
|
+
onSelectDrag={onSelectDrag}
|
|
338
|
+
fillCellOnSelection={fillCellOnSelection}
|
|
339
|
+
onDragEvent={onDragEvent}
|
|
340
|
+
onDragStart={onDragStart}
|
|
341
|
+
eventStartEditable={eventStartEditable}
|
|
342
|
+
eventOverlap={eventOverlap}
|
|
268
343
|
renderCustomDateForMonth={renderCustomDateForMonth}
|
|
269
344
|
classNames={classNames}
|
|
270
345
|
styles={styleOverrides}
|
|
@@ -277,10 +352,12 @@ function MonthPagerInner<T>({
|
|
|
277
352
|
events,
|
|
278
353
|
maxVisibleEventCount,
|
|
279
354
|
weekStartsOn,
|
|
355
|
+
hiddenDays,
|
|
280
356
|
locale,
|
|
281
357
|
sortedMonthView,
|
|
282
358
|
moreLabel,
|
|
283
359
|
showAdjacentMonths,
|
|
360
|
+
highlightWeekends,
|
|
284
361
|
disableMonthEventCellPress,
|
|
285
362
|
isRTL,
|
|
286
363
|
showSixWeeks,
|
|
@@ -290,9 +367,17 @@ function MonthPagerInner<T>({
|
|
|
290
367
|
keyExtractor,
|
|
291
368
|
onPressDay,
|
|
292
369
|
onLongPressDay,
|
|
370
|
+
onPressCell,
|
|
293
371
|
onPressEvent,
|
|
294
372
|
onLongPressEvent,
|
|
295
373
|
onPressMore,
|
|
374
|
+
onCreateEvent,
|
|
375
|
+
onSelectDrag,
|
|
376
|
+
fillCellOnSelection,
|
|
377
|
+
onDragEvent,
|
|
378
|
+
onDragStart,
|
|
379
|
+
eventStartEditable,
|
|
380
|
+
eventOverlap,
|
|
296
381
|
renderCustomDateForMonth,
|
|
297
382
|
classNames,
|
|
298
383
|
styleOverrides,
|
|
@@ -300,68 +385,72 @@ function MonthPagerInner<T>({
|
|
|
300
385
|
);
|
|
301
386
|
|
|
302
387
|
return (
|
|
303
|
-
<
|
|
304
|
-
{
|
|
388
|
+
<CalendarSelectionProvider value={selection}>
|
|
389
|
+
<View ref={containerRef} style={[styles.container, theme.containers.monthContainer]}>
|
|
390
|
+
{/* The active month's title, above the (shared) weekday header — mirrors the
|
|
305
391
|
dom MonthView's title. The grids below omit their own title/weekdays. */}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
392
|
+
{showTitle ? (
|
|
393
|
+
<Text
|
|
394
|
+
{...slot<TextStyle>("title", {
|
|
395
|
+
base: styles.monthTitle,
|
|
396
|
+
themed: [theme.text.monthTitle, { color: theme.colors.text }],
|
|
397
|
+
})}
|
|
398
|
+
allowFontScaling={false}
|
|
399
|
+
>
|
|
400
|
+
{format(date, "MMMM yyyy", locale ? { locale } : undefined)}
|
|
401
|
+
</Text>
|
|
402
|
+
) : null}
|
|
403
|
+
{renderHeaderForMonthView ? (
|
|
404
|
+
renderHeaderForMonthView(weekDays)
|
|
405
|
+
) : (
|
|
406
|
+
<MonthWeekdayHeader
|
|
407
|
+
weekDays={weekDays}
|
|
408
|
+
weekdayFormat={weekdayFormat}
|
|
409
|
+
locale={locale}
|
|
410
|
+
slot={slot}
|
|
411
|
+
/>
|
|
412
|
+
)}
|
|
413
|
+
<View
|
|
414
|
+
style={styles.pager}
|
|
415
|
+
onLayout={(event) => {
|
|
416
|
+
setPageHeight(event.nativeEvent.layout.height);
|
|
417
|
+
setContainerWidth(event.nativeEvent.layout.width);
|
|
418
|
+
}}
|
|
419
|
+
>
|
|
420
|
+
<LegendList
|
|
421
|
+
// Remount when the measured page height changes so the list adopts the
|
|
422
|
+
// corrected item height. Without this the list can keep the oversized
|
|
423
|
+
// initial (window-height) seed and clip the last week row.
|
|
424
|
+
key={pageHeight}
|
|
425
|
+
ref={listRef}
|
|
426
|
+
style={isWeb ? [styles.pagerList, styles.webNoScroll] : styles.pagerList}
|
|
427
|
+
data={monthDates}
|
|
428
|
+
extraData={listExtraData}
|
|
429
|
+
horizontal
|
|
430
|
+
recycleItems={false}
|
|
431
|
+
keyExtractor={keyExtractorList}
|
|
432
|
+
getFixedItemSize={getFixedItemSize}
|
|
433
|
+
// On web LegendList ignores these RN scroll props (it leaks them to the
|
|
434
|
+
// DOM as unknown attributes), so omit them there and disable horizontal
|
|
435
|
+
// scroll via `webNoScroll`; paging is driven by the arrow keys instead.
|
|
436
|
+
// Native: paging makes each swipe hard-stop at the adjacent month, while
|
|
437
|
+
// `freeSwipe` lets momentum carry across months and snap to a boundary.
|
|
438
|
+
{...(isWeb
|
|
439
|
+
? null
|
|
440
|
+
: {
|
|
441
|
+
scrollEnabled: swipeEnabled,
|
|
442
|
+
pagingEnabled: !freeSwipe,
|
|
443
|
+
snapToIndices: freeSwipe ? snapToIndices : undefined,
|
|
444
|
+
})}
|
|
445
|
+
initialScrollIndex={activeIndex}
|
|
446
|
+
showsHorizontalScrollIndicator={false}
|
|
447
|
+
viewabilityConfig={PAGE_VIEWABILITY}
|
|
448
|
+
onViewableItemsChanged={handleViewableItemsChanged}
|
|
449
|
+
renderItem={renderItem}
|
|
450
|
+
/>
|
|
451
|
+
</View>
|
|
363
452
|
</View>
|
|
364
|
-
</
|
|
453
|
+
</CalendarSelectionProvider>
|
|
365
454
|
);
|
|
366
455
|
}
|
|
367
456
|
|
|
@@ -411,7 +500,7 @@ const MonthWeekdayHeader = ({
|
|
|
411
500
|
{weekDays.map((day) => (
|
|
412
501
|
<Text
|
|
413
502
|
key={day.toISOString()}
|
|
414
|
-
{...slot("weekday", {
|
|
503
|
+
{...slot<TextStyle>("weekday", {
|
|
415
504
|
base: styles.weekdayLabel,
|
|
416
505
|
themed: [theme.text.weekday, { color: theme.colors.textMuted }],
|
|
417
506
|
})}
|