@super-calendar/native 2.5.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-Aczb2RSY.js → MonthList-CJs1vq5T.js} +81 -12
- package/dist/{MonthList-zPLklHAY.mjs → MonthList-Dn37Ezj0.mjs} +83 -14
- package/dist/index.d.mts +130 -18
- package/dist/index.d.ts +130 -18
- package/dist/index.js +799 -121
- package/dist/index.mjs +778 -125
- 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 +61 -2
- 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 +286 -0
- package/src/index.tsx +11 -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);
|
|
@@ -5,10 +5,12 @@ import {
|
|
|
5
5
|
endOfDay,
|
|
6
6
|
endOfMonth,
|
|
7
7
|
endOfWeek,
|
|
8
|
+
endOfYear,
|
|
8
9
|
type Locale,
|
|
9
10
|
startOfDay,
|
|
10
11
|
startOfMonth,
|
|
11
12
|
startOfWeek,
|
|
13
|
+
startOfYear,
|
|
12
14
|
} from "date-fns";
|
|
13
15
|
import { type ReactElement, useCallback, useMemo } from "react";
|
|
14
16
|
import type { StyleProp, ViewStyle } from "react-native";
|
|
@@ -16,6 +18,7 @@ import { useSharedValue } from "react-native-reanimated";
|
|
|
16
18
|
import { CalendarThemeProvider, mergeTheme, type PartialCalendarTheme } from "../theme";
|
|
17
19
|
import type {
|
|
18
20
|
BusinessHours,
|
|
21
|
+
BusinessHoursBand,
|
|
19
22
|
CalendarEvent,
|
|
20
23
|
CalendarMode,
|
|
21
24
|
EventKeyExtractor,
|
|
@@ -31,6 +34,7 @@ import {
|
|
|
31
34
|
getViewDays,
|
|
32
35
|
} from "@super-calendar/core";
|
|
33
36
|
import { type SlotStyleProps } from "../utils/slots";
|
|
37
|
+
import { YearView, type YearViewSlot } from "./YearView";
|
|
34
38
|
import { Agenda, type AgendaSlot } from "./Agenda";
|
|
35
39
|
import { DefaultEvent } from "./DefaultEvent";
|
|
36
40
|
import { MonthPager } from "./MonthPager";
|
|
@@ -49,7 +53,7 @@ import {
|
|
|
49
53
|
* month pager, the grid slots reach the time grid, and the agenda slots reach
|
|
50
54
|
* the schedule view; slots for views that aren't rendered are ignored.
|
|
51
55
|
*/
|
|
52
|
-
export type CalendarSlot = MonthViewSlot | TimeGridSlot | AgendaSlot;
|
|
56
|
+
export type CalendarSlot = MonthViewSlot | TimeGridSlot | AgendaSlot | YearViewSlot;
|
|
53
57
|
|
|
54
58
|
/** Props for the {@link Calendar} component. */
|
|
55
59
|
export type CalendarProps<T> = SlotStyleProps<CalendarSlot> & {
|
|
@@ -85,8 +89,10 @@ export type CalendarProps<T> = SlotStyleProps<CalendarSlot> & {
|
|
|
85
89
|
* drag-to-move and drag-to-resize working while hiding the visible indicator.
|
|
86
90
|
*/
|
|
87
91
|
showDragHandle?: boolean;
|
|
88
|
-
/** Tap a day cell (month
|
|
92
|
+
/** Tap a day cell (month and year modes) — e.g. drill into the day view. */
|
|
89
93
|
onPressDay?: (date: Date) => void;
|
|
94
|
+
/** Tap a month's title in the year view — e.g. jump to that month. */
|
|
95
|
+
onPressMonth?: (month: Date) => void;
|
|
90
96
|
/** Long-press a day cell (month mode). */
|
|
91
97
|
onLongPressDay?: (date: Date) => void;
|
|
92
98
|
/** Tap the "+N more" overflow label in a month cell. */
|
|
@@ -123,6 +129,14 @@ export type CalendarProps<T> = SlotStyleProps<CalendarSlot> & {
|
|
|
123
129
|
disableMonthEventCellPress?: boolean;
|
|
124
130
|
/** First day of the week. Sunday = 0 (default) … Saturday = 6. */
|
|
125
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;
|
|
126
140
|
/** Weekday header label width: `narrow` ("M"), `short` ("Mon", default), or `long` ("Monday"). */
|
|
127
141
|
weekdayFormat?: WeekdayFormat;
|
|
128
142
|
/** Number of day columns when `mode="custom"`. Ignored by other modes. Default 1. */
|
|
@@ -151,6 +165,13 @@ export type CalendarProps<T> = SlotStyleProps<CalendarSlot> & {
|
|
|
151
165
|
* whole day (closed). Omit for no shading.
|
|
152
166
|
*/
|
|
153
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;
|
|
154
175
|
/** Stable key per event. Defaults to start-time + index. */
|
|
155
176
|
keyExtractor?: EventKeyExtractor<T>;
|
|
156
177
|
/** Partial theme merged over the defaults. */
|
|
@@ -172,6 +193,8 @@ export type CalendarProps<T> = SlotStyleProps<CalendarSlot> & {
|
|
|
172
193
|
* whole-day spans) are not shown on the time grid.
|
|
173
194
|
*/
|
|
174
195
|
showAllDayEventCell?: boolean;
|
|
196
|
+
/** Tint weekend columns (default true). Set false to treat weekends normally. */
|
|
197
|
+
highlightWeekends?: boolean;
|
|
175
198
|
/** Show the ISO week number in the week/day header gutter. Default false. */
|
|
176
199
|
showWeekNumber?: boolean;
|
|
177
200
|
/** Prefix for the week-number label (e.g. "W"). Default "W". */
|
|
@@ -261,6 +284,12 @@ function visibleRange(
|
|
|
261
284
|
endOfWeek(endOfMonth(date), { weekStartsOn }),
|
|
262
285
|
];
|
|
263
286
|
}
|
|
287
|
+
if (mode === "year") {
|
|
288
|
+
return [
|
|
289
|
+
startOfWeek(startOfYear(date), { weekStartsOn }),
|
|
290
|
+
endOfWeek(endOfYear(date), { weekStartsOn }),
|
|
291
|
+
];
|
|
292
|
+
}
|
|
264
293
|
const days = getViewDays(mode, date, weekStartsOn, numberOfDays, false, weekEndsOn);
|
|
265
294
|
return [startOfDay(days[0]), endOfDay(days[days.length - 1])];
|
|
266
295
|
}
|
|
@@ -283,6 +312,12 @@ function expansionRange(
|
|
|
283
312
|
addWeeks(endOfWeek(endOfMonth(addMonths(date, 1)), { weekStartsOn }), 1),
|
|
284
313
|
];
|
|
285
314
|
}
|
|
315
|
+
if (mode === "year") {
|
|
316
|
+
return [
|
|
317
|
+
startOfWeek(startOfYear(date), { weekStartsOn }),
|
|
318
|
+
endOfWeek(endOfYear(date), { weekStartsOn }),
|
|
319
|
+
];
|
|
320
|
+
}
|
|
286
321
|
if (mode === "schedule") {
|
|
287
322
|
// The agenda lists forward from the anchor date; three months is a sensible
|
|
288
323
|
// default look-ahead. Pre-expand for a different window.
|
|
@@ -332,6 +367,7 @@ export function Calendar<T>({
|
|
|
332
367
|
dragStepMinutes,
|
|
333
368
|
showDragHandle,
|
|
334
369
|
onPressDay,
|
|
370
|
+
onPressMonth,
|
|
335
371
|
onLongPressDay,
|
|
336
372
|
onPressMore,
|
|
337
373
|
onPressCell,
|
|
@@ -345,6 +381,8 @@ export function Calendar<T>({
|
|
|
345
381
|
showAdjacentMonths,
|
|
346
382
|
disableMonthEventCellPress,
|
|
347
383
|
weekStartsOn = 0,
|
|
384
|
+
hiddenDays,
|
|
385
|
+
now,
|
|
348
386
|
weekdayFormat,
|
|
349
387
|
numberOfDays,
|
|
350
388
|
weekEndsOn,
|
|
@@ -353,6 +391,7 @@ export function Calendar<T>({
|
|
|
353
391
|
eventCellStyle,
|
|
354
392
|
calendarCellStyle,
|
|
355
393
|
businessHours,
|
|
394
|
+
renderBusinessHours,
|
|
356
395
|
keyExtractor = defaultKeyExtractor as EventKeyExtractor<T>,
|
|
357
396
|
theme,
|
|
358
397
|
cellHeight: cellHeightProp,
|
|
@@ -363,6 +402,7 @@ export function Calendar<T>({
|
|
|
363
402
|
hideHours,
|
|
364
403
|
timeslots,
|
|
365
404
|
showAllDayEventCell,
|
|
405
|
+
highlightWeekends,
|
|
366
406
|
showWeekNumber,
|
|
367
407
|
weekNumberPrefix,
|
|
368
408
|
hourComponent,
|
|
@@ -498,6 +538,7 @@ export function Calendar<T>({
|
|
|
498
538
|
events={displayEvents}
|
|
499
539
|
maxVisibleEventCount={maxVisibleEventCount}
|
|
500
540
|
weekStartsOn={weekStartsOn}
|
|
541
|
+
hiddenDays={hiddenDays}
|
|
501
542
|
weekdayFormat={weekdayFormat}
|
|
502
543
|
locale={locale}
|
|
503
544
|
sortedMonthView={sortedMonthView}
|
|
@@ -523,6 +564,19 @@ export function Calendar<T>({
|
|
|
523
564
|
classNames={classNames}
|
|
524
565
|
styles={styleOverrides}
|
|
525
566
|
/>
|
|
567
|
+
) : mode === "year" ? (
|
|
568
|
+
<YearView
|
|
569
|
+
date={date}
|
|
570
|
+
events={displayEvents}
|
|
571
|
+
weekStartsOn={weekStartsOn}
|
|
572
|
+
hiddenDays={hiddenDays}
|
|
573
|
+
locale={locale}
|
|
574
|
+
activeDate={activeDate}
|
|
575
|
+
onPressDay={onPressDay}
|
|
576
|
+
onPressMonth={onPressMonth}
|
|
577
|
+
classNames={classNames}
|
|
578
|
+
styles={styleOverrides}
|
|
579
|
+
/>
|
|
526
580
|
) : mode === "schedule" ? (
|
|
527
581
|
<Agenda
|
|
528
582
|
events={displayEvents}
|
|
@@ -548,6 +602,9 @@ export function Calendar<T>({
|
|
|
548
602
|
hourHeight={hourHeight}
|
|
549
603
|
weekStartsOn={weekStartsOn}
|
|
550
604
|
weekdayFormat={weekdayFormat}
|
|
605
|
+
hiddenDays={hiddenDays}
|
|
606
|
+
now={now}
|
|
607
|
+
timeZone={timeZone}
|
|
551
608
|
renderEvent={resolvedRenderEvent}
|
|
552
609
|
keyExtractor={keyExtractor}
|
|
553
610
|
scrollOffsetMinutes={scrollOffsetMinutes}
|
|
@@ -555,8 +612,10 @@ export function Calendar<T>({
|
|
|
555
612
|
hideHours={hideHours}
|
|
556
613
|
timeslots={timeslots}
|
|
557
614
|
showAllDayEventCell={showAllDayEventCell}
|
|
615
|
+
highlightWeekends={highlightWeekends}
|
|
558
616
|
calendarCellStyle={calendarCellStyle}
|
|
559
617
|
businessHours={businessHours}
|
|
618
|
+
renderBusinessHours={renderBusinessHours}
|
|
560
619
|
showWeekNumber={showWeekNumber}
|
|
561
620
|
weekNumberPrefix={weekNumberPrefix}
|
|
562
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
|
});
|