@super-calendar/native 2.6.0 → 2.7.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/dist/{DefaultMonthEvent-BSvuJUFk.d.ts → DefaultMonthEvent-DCPDsnvq.d.ts} +10 -6
- package/dist/{DefaultMonthEvent-zDj9dHEv.d.mts → DefaultMonthEvent-DMOC5aNL.d.mts} +10 -6
- package/dist/{MonthList-Gu6p64fE.js → MonthList-CJs1vq5T.js} +80 -11
- package/dist/{MonthList-CMzYn9T0.mjs → MonthList-Dn37Ezj0.mjs} +82 -13
- package/dist/index.d.mts +80 -17
- package/dist/index.d.ts +80 -17
- package/dist/index.js +627 -125
- package/dist/index.mjs +606 -128
- 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 +5 -2
- package/src/components/AllDayLane.tsx +3 -2
- package/src/components/Calendar.tsx +29 -0
- package/src/components/DefaultEvent.tsx +3 -1
- package/src/components/MonthPager.tsx +12 -3
- package/src/components/MonthView.tsx +95 -8
- package/src/components/ResourceTimeline.tsx +270 -29
- package/src/components/TimeGrid.tsx +656 -97
- package/src/components/YearView.tsx +14 -4
- package/src/index.tsx +10 -1
- package/src/types.ts +1 -0
package/dist/picker.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as PartialCalendarTheme, C as RenderEvent, E as WeekStartsOn, M as defaultTheme, N as mergeTheme, O as CalendarTheme, P as useCalendarTheme, a as MonthPager, b as ICalendarEvent, c as MonthViewProps, g as CalendarMode, h as CalendarEvent, j as darkTheme, k as CalendarThemeProvider, n as MonthList, o as MonthPagerProps, r as MonthListProps, s as MonthView, t as DefaultMonthEvent, w as RenderEventArgs, y as EventKeyExtractor } from "./DefaultMonthEvent-DMOC5aNL.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 { A as
|
|
1
|
+
import { A as PartialCalendarTheme, C as RenderEvent, E as WeekStartsOn, M as defaultTheme, N as mergeTheme, O as CalendarTheme, P as useCalendarTheme, a as MonthPager, b as ICalendarEvent, c as MonthViewProps, g as CalendarMode, h as CalendarEvent, j as darkTheme, k as CalendarThemeProvider, n as MonthList, o as MonthPagerProps, r as MonthListProps, s as MonthView, t as DefaultMonthEvent, w as RenderEventArgs, y as EventKeyExtractor } from "./DefaultMonthEvent-DCPDsnvq.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-CJs1vq5T.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-Dn37Ezj0.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.7.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.7.0"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
70
|
"@legendapp/list": ">=3",
|
|
@@ -6,7 +6,7 @@ import { useCalendarTheme } from "../theme";
|
|
|
6
6
|
import type { CalendarEvent, EventKeyExtractor, RenderEvent } from "../types";
|
|
7
7
|
import { createSlots, type SlotStyleProps } from "../utils/slots";
|
|
8
8
|
import { getIsToday } from "@super-calendar/core";
|
|
9
|
-
import { isAllDayEvent } from "@super-calendar/core";
|
|
9
|
+
import { isAllDayEvent, isBackgroundEvent } from "@super-calendar/core";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* The styleable parts of {@link Agenda}. Mirrors the dom renderer's slot names;
|
|
@@ -60,7 +60,10 @@ export function Agenda<T>({
|
|
|
60
60
|
const RenderEventComponent = renderEvent;
|
|
61
61
|
|
|
62
62
|
const rows = useMemo<Row<T>[]>(() => {
|
|
63
|
-
const sorted =
|
|
63
|
+
const sorted = events
|
|
64
|
+
// Background events shade the grids; they have no agenda row.
|
|
65
|
+
.filter((event) => !isBackgroundEvent(event))
|
|
66
|
+
.sort((a, b) => a.start.getTime() - b.start.getTime());
|
|
64
67
|
const out: Row<T>[] = [];
|
|
65
68
|
let currentDay: Date | null = null;
|
|
66
69
|
sorted.forEach((event, index) => {
|
|
@@ -3,7 +3,7 @@ import { StyleSheet, Text, 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";
|
|
6
|
-
import { isAllDayEvent } from "@super-calendar/core";
|
|
6
|
+
import { isAllDayEvent, isBackgroundEvent } from "@super-calendar/core";
|
|
7
7
|
|
|
8
8
|
// The lane's slots are a subset of the TimeGrid slot union; typed locally so
|
|
9
9
|
// this file doesn't import the full TimeGrid type.
|
|
@@ -42,7 +42,8 @@ export function AllDayLane<T>({
|
|
|
42
42
|
const slot = useSlots<AllDayLaneSlot>();
|
|
43
43
|
const RenderEventComponent = renderEvent;
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
// Background events shade the timed columns instead of taking a lane chip.
|
|
46
|
+
const allDay = events.filter((event) => isAllDayEvent(event) && !isBackgroundEvent(event));
|
|
46
47
|
const perDay = days.map((day) => {
|
|
47
48
|
const start = startOfDay(day);
|
|
48
49
|
const next = addDays(start, 1);
|
|
@@ -18,6 +18,7 @@ import { useSharedValue } from "react-native-reanimated";
|
|
|
18
18
|
import { CalendarThemeProvider, mergeTheme, type PartialCalendarTheme } from "../theme";
|
|
19
19
|
import type {
|
|
20
20
|
BusinessHours,
|
|
21
|
+
BusinessHoursBand,
|
|
21
22
|
CalendarEvent,
|
|
22
23
|
CalendarMode,
|
|
23
24
|
EventKeyExtractor,
|
|
@@ -128,6 +129,14 @@ export type CalendarProps<T> = SlotStyleProps<CalendarSlot> & {
|
|
|
128
129
|
disableMonthEventCellPress?: boolean;
|
|
129
130
|
/** First day of the week. Sunday = 0 (default) … Saturday = 6. */
|
|
130
131
|
weekStartsOn?: WeekStartsOn;
|
|
132
|
+
/** Weekdays (0=Sunday…6=Saturday) hidden from the grid, e.g. `[0, 6]` for weekends off. */
|
|
133
|
+
hiddenDays?: number[];
|
|
134
|
+
/**
|
|
135
|
+
* Fixed "now" instant for the current-time indicator (doesn't tick), e.g. a
|
|
136
|
+
* server-synced clock. Defaults to the device clock, shifted into `timeZone`
|
|
137
|
+
* when one is set so the line matches the displayed events.
|
|
138
|
+
*/
|
|
139
|
+
now?: Date;
|
|
131
140
|
/** Weekday header label width: `narrow` ("M"), `short` ("Mon", default), or `long` ("Monday"). */
|
|
132
141
|
weekdayFormat?: WeekdayFormat;
|
|
133
142
|
/** Number of day columns when `mode="custom"`. Ignored by other modes. Default 1. */
|
|
@@ -156,6 +165,13 @@ export type CalendarProps<T> = SlotStyleProps<CalendarSlot> & {
|
|
|
156
165
|
* whole day (closed). Omit for no shading.
|
|
157
166
|
*/
|
|
158
167
|
businessHours?: BusinessHours;
|
|
168
|
+
/**
|
|
169
|
+
* Week/day grid only: render a closed-hours band's content yourself (a
|
|
170
|
+
* label, icon, pattern). The grid keeps positioning the band; when set, the
|
|
171
|
+
* themed tint is dropped and your output fills the band instead. Decorative only: the
|
|
172
|
+
* band stays non-interactive and hidden from assistive tech.
|
|
173
|
+
*/
|
|
174
|
+
renderBusinessHours?: (band: BusinessHoursBand) => React.ReactNode;
|
|
159
175
|
/** Stable key per event. Defaults to start-time + index. */
|
|
160
176
|
keyExtractor?: EventKeyExtractor<T>;
|
|
161
177
|
/** Partial theme merged over the defaults. */
|
|
@@ -177,6 +193,8 @@ export type CalendarProps<T> = SlotStyleProps<CalendarSlot> & {
|
|
|
177
193
|
* whole-day spans) are not shown on the time grid.
|
|
178
194
|
*/
|
|
179
195
|
showAllDayEventCell?: boolean;
|
|
196
|
+
/** Tint weekend columns (default true). Set false to treat weekends normally. */
|
|
197
|
+
highlightWeekends?: boolean;
|
|
180
198
|
/** Show the ISO week number in the week/day header gutter. Default false. */
|
|
181
199
|
showWeekNumber?: boolean;
|
|
182
200
|
/** Prefix for the week-number label (e.g. "W"). Default "W". */
|
|
@@ -363,6 +381,8 @@ export function Calendar<T>({
|
|
|
363
381
|
showAdjacentMonths,
|
|
364
382
|
disableMonthEventCellPress,
|
|
365
383
|
weekStartsOn = 0,
|
|
384
|
+
hiddenDays,
|
|
385
|
+
now,
|
|
366
386
|
weekdayFormat,
|
|
367
387
|
numberOfDays,
|
|
368
388
|
weekEndsOn,
|
|
@@ -371,6 +391,7 @@ export function Calendar<T>({
|
|
|
371
391
|
eventCellStyle,
|
|
372
392
|
calendarCellStyle,
|
|
373
393
|
businessHours,
|
|
394
|
+
renderBusinessHours,
|
|
374
395
|
keyExtractor = defaultKeyExtractor as EventKeyExtractor<T>,
|
|
375
396
|
theme,
|
|
376
397
|
cellHeight: cellHeightProp,
|
|
@@ -381,6 +402,7 @@ export function Calendar<T>({
|
|
|
381
402
|
hideHours,
|
|
382
403
|
timeslots,
|
|
383
404
|
showAllDayEventCell,
|
|
405
|
+
highlightWeekends,
|
|
384
406
|
showWeekNumber,
|
|
385
407
|
weekNumberPrefix,
|
|
386
408
|
hourComponent,
|
|
@@ -516,6 +538,7 @@ export function Calendar<T>({
|
|
|
516
538
|
events={displayEvents}
|
|
517
539
|
maxVisibleEventCount={maxVisibleEventCount}
|
|
518
540
|
weekStartsOn={weekStartsOn}
|
|
541
|
+
hiddenDays={hiddenDays}
|
|
519
542
|
weekdayFormat={weekdayFormat}
|
|
520
543
|
locale={locale}
|
|
521
544
|
sortedMonthView={sortedMonthView}
|
|
@@ -546,6 +569,7 @@ export function Calendar<T>({
|
|
|
546
569
|
date={date}
|
|
547
570
|
events={displayEvents}
|
|
548
571
|
weekStartsOn={weekStartsOn}
|
|
572
|
+
hiddenDays={hiddenDays}
|
|
549
573
|
locale={locale}
|
|
550
574
|
activeDate={activeDate}
|
|
551
575
|
onPressDay={onPressDay}
|
|
@@ -578,6 +602,9 @@ export function Calendar<T>({
|
|
|
578
602
|
hourHeight={hourHeight}
|
|
579
603
|
weekStartsOn={weekStartsOn}
|
|
580
604
|
weekdayFormat={weekdayFormat}
|
|
605
|
+
hiddenDays={hiddenDays}
|
|
606
|
+
now={now}
|
|
607
|
+
timeZone={timeZone}
|
|
581
608
|
renderEvent={resolvedRenderEvent}
|
|
582
609
|
keyExtractor={keyExtractor}
|
|
583
610
|
scrollOffsetMinutes={scrollOffsetMinutes}
|
|
@@ -585,8 +612,10 @@ export function Calendar<T>({
|
|
|
585
612
|
hideHours={hideHours}
|
|
586
613
|
timeslots={timeslots}
|
|
587
614
|
showAllDayEventCell={showAllDayEventCell}
|
|
615
|
+
highlightWeekends={highlightWeekends}
|
|
588
616
|
calendarCellStyle={calendarCellStyle}
|
|
589
617
|
businessHours={businessHours}
|
|
618
|
+
renderBusinessHours={renderBusinessHours}
|
|
590
619
|
showWeekNumber={showWeekNumber}
|
|
591
620
|
weekNumberPrefix={weekNumberPrefix}
|
|
592
621
|
hourComponent={hourComponent}
|
|
@@ -132,7 +132,9 @@ export function DefaultEvent<T>({
|
|
|
132
132
|
]}
|
|
133
133
|
onPress={onPress}
|
|
134
134
|
onLongPress={onLongPress}
|
|
135
|
-
|
|
135
|
+
// Keep the box fully opaque while pressed: a move drag is a held long-press,
|
|
136
|
+
// and a dimmed event under the finger for the whole drag reads as broken.
|
|
137
|
+
activeOpacity={1}
|
|
136
138
|
accessibilityRole="button"
|
|
137
139
|
accessibilityLabel={accessibilityLabel}
|
|
138
140
|
accessibilityState={{ disabled: event.disabled ?? false }}
|
|
@@ -17,7 +17,12 @@ import {
|
|
|
17
17
|
} from "react-native";
|
|
18
18
|
import { useCalendarTheme } from "../theme";
|
|
19
19
|
import type { CalendarEvent, EventKeyExtractor, RenderEvent, WeekStartsOn } from "../types";
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
type WeekdayFormat,
|
|
22
|
+
filterHiddenDays,
|
|
23
|
+
getWeekDays,
|
|
24
|
+
weekdayFormatToken,
|
|
25
|
+
} from "@super-calendar/core";
|
|
21
26
|
import { createSlots, type SlotStyleProps } from "../utils/slots";
|
|
22
27
|
import { useWebPagerKeys } from "../utils/useWebPagerKeys";
|
|
23
28
|
import { MonthView, type MonthViewSlot } from "./MonthView";
|
|
@@ -41,6 +46,8 @@ export type MonthPagerProps<T> = {
|
|
|
41
46
|
events: CalendarEvent<T>[];
|
|
42
47
|
maxVisibleEventCount?: number;
|
|
43
48
|
weekStartsOn: WeekStartsOn;
|
|
49
|
+
/** Weekdays (0=Sunday…6=Saturday) hidden from the grid, e.g. `[0, 6]` for weekends off. */
|
|
50
|
+
hiddenDays?: number[];
|
|
44
51
|
weekdayFormat?: WeekdayFormat;
|
|
45
52
|
locale?: Locale;
|
|
46
53
|
sortedMonthView?: boolean;
|
|
@@ -72,6 +79,7 @@ function MonthPagerInner<T>({
|
|
|
72
79
|
events,
|
|
73
80
|
maxVisibleEventCount,
|
|
74
81
|
weekStartsOn,
|
|
82
|
+
hiddenDays,
|
|
75
83
|
weekdayFormat = "short",
|
|
76
84
|
locale,
|
|
77
85
|
sortedMonthView,
|
|
@@ -210,9 +218,9 @@ function MonthPagerInner<T>({
|
|
|
210
218
|
// only on `weekStartsOn`, so any week works; reuse the anchor. Reversed in RTL
|
|
211
219
|
// to line up with the mirrored day cells.
|
|
212
220
|
const weekDays = useMemo(() => {
|
|
213
|
-
const days = getWeekDays(anchor, weekStartsOn);
|
|
221
|
+
const days = filterHiddenDays(getWeekDays(anchor, weekStartsOn), hiddenDays);
|
|
214
222
|
return isRTL ? days.reverse() : days;
|
|
215
|
-
}, [anchor, weekStartsOn, isRTL]);
|
|
223
|
+
}, [anchor, weekStartsOn, isRTL, hiddenDays]);
|
|
216
224
|
|
|
217
225
|
// Pages are keyed by month Dates that never change, so LegendList keeps the
|
|
218
226
|
// pages it has already rendered and only re-renders them when `data` or
|
|
@@ -237,6 +245,7 @@ function MonthPagerInner<T>({
|
|
|
237
245
|
showWeekdays={false}
|
|
238
246
|
maxVisibleEventCount={maxVisibleEventCount}
|
|
239
247
|
weekStartsOn={weekStartsOn}
|
|
248
|
+
hiddenDays={hiddenDays}
|
|
240
249
|
locale={locale}
|
|
241
250
|
sortedMonthView={sortedMonthView}
|
|
242
251
|
moreLabel={moreLabel}
|
|
@@ -2,7 +2,10 @@ import { format, type Locale, isSameMonth, startOfDay } from "date-fns";
|
|
|
2
2
|
import { memo, type ReactElement, useMemo, useState } from "react";
|
|
3
3
|
import {
|
|
4
4
|
type LayoutChangeEvent,
|
|
5
|
+
Modal,
|
|
5
6
|
Platform,
|
|
7
|
+
Pressable,
|
|
8
|
+
ScrollView,
|
|
6
9
|
StyleSheet,
|
|
7
10
|
type StyleProp,
|
|
8
11
|
Text,
|
|
@@ -30,12 +33,18 @@ import { dayBadgeKind, rangeBandKind } from "@super-calendar/core";
|
|
|
30
33
|
import {
|
|
31
34
|
buildMonthWeeks,
|
|
32
35
|
getIsToday,
|
|
36
|
+
filterHiddenDays,
|
|
33
37
|
getWeekDays,
|
|
34
38
|
isSameCalendarDay,
|
|
35
39
|
isWeekend,
|
|
36
40
|
} from "@super-calendar/core";
|
|
37
41
|
import { monthEventCapacity, monthVisibleCount } from "@super-calendar/core";
|
|
38
|
-
import {
|
|
42
|
+
import {
|
|
43
|
+
compareDayEvents,
|
|
44
|
+
groupEventsByDay,
|
|
45
|
+
isAllDayEvent,
|
|
46
|
+
isBackgroundEvent,
|
|
47
|
+
} from "@super-calendar/core";
|
|
39
48
|
|
|
40
49
|
// Day-cell metrics, mirrored from the styles below, used to estimate how many
|
|
41
50
|
// event chips fit when auto-fitting `maxVisibleEventCount`.
|
|
@@ -67,7 +76,8 @@ export type MonthViewSlot =
|
|
|
67
76
|
| "dayBadge"
|
|
68
77
|
| "dayBadgeText"
|
|
69
78
|
| "rangeBand"
|
|
70
|
-
| "more"
|
|
79
|
+
| "more"
|
|
80
|
+
| "morePopover";
|
|
71
81
|
|
|
72
82
|
/** Props for {@link MonthView}, the single-month grid. */
|
|
73
83
|
export type MonthViewProps<T> = SlotStyleProps<MonthViewSlot> & {
|
|
@@ -81,6 +91,8 @@ export type MonthViewProps<T> = SlotStyleProps<MonthViewSlot> & {
|
|
|
81
91
|
*/
|
|
82
92
|
maxVisibleEventCount?: number;
|
|
83
93
|
weekStartsOn: WeekStartsOn;
|
|
94
|
+
/** Weekdays (0=Sunday…6=Saturday) hidden from the grid, e.g. `[0, 6]` for weekends off. */
|
|
95
|
+
hiddenDays?: number[];
|
|
84
96
|
/** Weekday header label width: `narrow` ("M"), `short` ("Mon", default), or `long` ("Monday"). */
|
|
85
97
|
weekdayFormat?: WeekdayFormat;
|
|
86
98
|
locale?: Locale;
|
|
@@ -148,6 +160,7 @@ function MonthViewInner<T>({
|
|
|
148
160
|
events,
|
|
149
161
|
maxVisibleEventCount,
|
|
150
162
|
weekStartsOn,
|
|
163
|
+
hiddenDays,
|
|
151
164
|
weekdayFormat = "short",
|
|
152
165
|
locale,
|
|
153
166
|
sortedMonthView = true,
|
|
@@ -203,18 +216,24 @@ function MonthViewInner<T>({
|
|
|
203
216
|
// Picker: which day is being pressed, so the tap dims only its badge (the circle),
|
|
204
217
|
// not the whole cell background. Stays null in the events calendar.
|
|
205
218
|
const [pressedKey, setPressedKey] = useState<string | null>(null);
|
|
219
|
+
// Built-in "+N more" popover: opens when the consumer doesn't handle
|
|
220
|
+
// `onPressMore` themselves; lists the day's events in a modal card.
|
|
221
|
+
const [moreOpenFor, setMoreOpenFor] = useState<{
|
|
222
|
+
day: Date;
|
|
223
|
+
events: CalendarEvent<T>[];
|
|
224
|
+
} | null>(null);
|
|
206
225
|
|
|
207
226
|
const weeks = useMemo(
|
|
208
|
-
() => buildMonthWeeks(date, weekStartsOn, { showSixWeeks, isRTL }),
|
|
209
|
-
[date, weekStartsOn, isRTL, showSixWeeks],
|
|
227
|
+
() => buildMonthWeeks(date, weekStartsOn, { showSixWeeks, isRTL, hiddenDays }),
|
|
228
|
+
[date, weekStartsOn, isRTL, showSixWeeks, hiddenDays],
|
|
210
229
|
);
|
|
211
230
|
|
|
212
231
|
// Weekday labels for the header row (any week works; reuse this month). Reversed
|
|
213
232
|
// in RTL so they line up with the mirrored day columns.
|
|
214
233
|
const weekdayLabels = useMemo(() => {
|
|
215
|
-
const days = getWeekDays(date, weekStartsOn);
|
|
234
|
+
const days = filterHiddenDays(getWeekDays(date, weekStartsOn), hiddenDays);
|
|
216
235
|
return isRTL ? days.reverse() : days;
|
|
217
|
-
}, [date, weekStartsOn, isRTL]);
|
|
236
|
+
}, [date, weekStartsOn, isRTL, hiddenDays]);
|
|
218
237
|
|
|
219
238
|
// How many chips fit per cell: a fixed cap when `maxVisibleEventCount` is set,
|
|
220
239
|
// else derived from the measured cell height and the (default) chip metrics.
|
|
@@ -240,7 +259,8 @@ function MonthViewInner<T>({
|
|
|
240
259
|
// inside every one of the (up to) 42 day cells on each render. Multi-day events
|
|
241
260
|
// are indexed under every day they span.
|
|
242
261
|
const eventsByDay = useMemo(() => {
|
|
243
|
-
|
|
262
|
+
// Background events shade the time grid; the month grid ignores them.
|
|
263
|
+
const map = groupEventsByDay(events.filter((event) => !isBackgroundEvent(event)));
|
|
244
264
|
if (sortedMonthView) {
|
|
245
265
|
// All-day events head the day, then timed events by start (shared with dom).
|
|
246
266
|
for (const list of map.values()) list.sort(compareDayEvents);
|
|
@@ -480,7 +500,11 @@ function MonthViewInner<T>({
|
|
|
480
500
|
base: styles.moreLabel,
|
|
481
501
|
themed: [theme.text.more, { color: theme.colors.textMuted }],
|
|
482
502
|
})}
|
|
483
|
-
onPress={
|
|
503
|
+
onPress={
|
|
504
|
+
onPressMore
|
|
505
|
+
? () => onPressMore(dayEvents, day)
|
|
506
|
+
: () => setMoreOpenFor({ day, events: dayEvents })
|
|
507
|
+
}
|
|
484
508
|
accessibilityRole="button"
|
|
485
509
|
accessibilityLabel={`Show ${hiddenCount} more events`}
|
|
486
510
|
allowFontScaling={false}
|
|
@@ -531,6 +555,50 @@ function MonthViewInner<T>({
|
|
|
531
555
|
))}
|
|
532
556
|
</View>
|
|
533
557
|
) : null}
|
|
558
|
+
{moreOpenFor ? (
|
|
559
|
+
<Modal transparent animationType="fade" visible onRequestClose={() => setMoreOpenFor(null)}>
|
|
560
|
+
<Pressable
|
|
561
|
+
style={styles.moreBackdrop}
|
|
562
|
+
accessibilityLabel="Close"
|
|
563
|
+
onPress={() => setMoreOpenFor(null)}
|
|
564
|
+
>
|
|
565
|
+
<Pressable
|
|
566
|
+
// Swallow taps on the card so only the backdrop dismisses.
|
|
567
|
+
onPress={() => {}}
|
|
568
|
+
{...slot("morePopover", {
|
|
569
|
+
base: styles.moreCard,
|
|
570
|
+
themed: {
|
|
571
|
+
backgroundColor: theme.colors.surface,
|
|
572
|
+
borderColor: theme.colors.gridLine,
|
|
573
|
+
},
|
|
574
|
+
})}
|
|
575
|
+
>
|
|
576
|
+
<Text
|
|
577
|
+
accessibilityRole="header"
|
|
578
|
+
style={[styles.moreCardTitle, { color: theme.colors.text }]}
|
|
579
|
+
allowFontScaling={false}
|
|
580
|
+
>
|
|
581
|
+
{format(moreOpenFor.day, "EEEE, d LLLL yyyy", { locale })}
|
|
582
|
+
</Text>
|
|
583
|
+
<ScrollView>
|
|
584
|
+
{moreOpenFor.events.map((event, index) => (
|
|
585
|
+
<View key={keyExtractor(event, index)} style={styles.moreCardRow}>
|
|
586
|
+
<RenderEventComponent
|
|
587
|
+
event={event}
|
|
588
|
+
mode="month"
|
|
589
|
+
isAllDay={isAllDayEvent(event)}
|
|
590
|
+
onPress={() => {
|
|
591
|
+
setMoreOpenFor(null);
|
|
592
|
+
onPressEvent(event);
|
|
593
|
+
}}
|
|
594
|
+
/>
|
|
595
|
+
</View>
|
|
596
|
+
))}
|
|
597
|
+
</ScrollView>
|
|
598
|
+
</Pressable>
|
|
599
|
+
</Pressable>
|
|
600
|
+
</Modal>
|
|
601
|
+
) : null}
|
|
534
602
|
<View {...slot("grid", { base: styles.container })} onLayout={handleLayout}>
|
|
535
603
|
{weeks.map((week) => (
|
|
536
604
|
<View
|
|
@@ -620,4 +688,23 @@ const styles = StyleSheet.create({
|
|
|
620
688
|
marginTop: 2,
|
|
621
689
|
marginHorizontal: 4,
|
|
622
690
|
},
|
|
691
|
+
// The built-in "+N more" popover card.
|
|
692
|
+
moreBackdrop: {
|
|
693
|
+
flex: 1,
|
|
694
|
+
backgroundColor: "rgba(0, 0, 0, 0.3)",
|
|
695
|
+
alignItems: "center",
|
|
696
|
+
justifyContent: "center",
|
|
697
|
+
padding: 24,
|
|
698
|
+
},
|
|
699
|
+
moreCard: {
|
|
700
|
+
width: "100%",
|
|
701
|
+
maxWidth: 360,
|
|
702
|
+
maxHeight: "60%",
|
|
703
|
+
borderRadius: 12,
|
|
704
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
705
|
+
padding: 12,
|
|
706
|
+
gap: 6,
|
|
707
|
+
},
|
|
708
|
+
moreCardTitle: { fontSize: 14, fontWeight: "600", marginBottom: 4 },
|
|
709
|
+
moreCardRow: { marginBottom: 4 },
|
|
623
710
|
});
|