@super-calendar/native 2.6.0 → 2.8.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-Cm9DsHBK.d.mts} +17 -10
- package/dist/{DefaultMonthEvent-zDj9dHEv.d.mts → DefaultMonthEvent-DAxZjk_D.d.ts} +17 -10
- package/dist/{MonthList-Gu6p64fE.js → MonthList-BWTCCmko.js} +168 -35
- package/dist/{MonthList-CMzYn9T0.mjs → MonthList-Chx0jP5n.mjs} +170 -37
- package/dist/index.d.mts +101 -17
- package/dist/index.d.ts +101 -17
- package/dist/index.js +734 -159
- package/dist/index.mjs +707 -162
- 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 +41 -0
- package/src/components/DefaultEvent.tsx +3 -1
- package/src/components/MonthPager.tsx +12 -3
- package/src/components/MonthView.tsx +239 -43
- package/src/components/ResourceTimeline.tsx +302 -44
- package/src/components/TimeGrid.tsx +807 -122
- package/src/components/YearView.tsx +14 -4
- package/src/index.tsx +13 -1
- package/src/types.ts +1 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Locale } from "date-fns";
|
|
2
|
-
import { ComponentType, ReactElement } from "react";
|
|
3
|
-
import { AccessibilityActionEvent, AccessibilityActionInfo, StyleProp, TextStyle, ViewStyle } from "react-native";
|
|
2
|
+
import { ComponentType, ReactElement, ReactNode } from "react";
|
|
4
3
|
import { SharedValue } from "react-native-reanimated";
|
|
5
|
-
import { BusinessHours, CalendarColors, CalendarEvent, CalendarEvent as CalendarEvent$1, CalendarMode, CalendarMode as CalendarMode$1, DateRange, EventAccessibilityLabelContext, EventAccessibilityLabeler, EventAccessibilityLabeler as EventAccessibilityLabeler$1, EventKeyExtractor, ICalendarEvent, RecurrenceFrequency, RecurrenceRule, TimeGridMode, WeekStartsOn, WeekdayFormat, WeekdayFormat as WeekdayFormat$1 } from "@super-calendar/core";
|
|
4
|
+
import { BusinessHours, BusinessHoursBand as BusinessHoursBand$1, CalendarColors, CalendarEvent, CalendarEvent as CalendarEvent$1, CalendarMode, CalendarMode as CalendarMode$1, DateRange, EventAccessibilityLabelContext, EventAccessibilityLabeler, EventAccessibilityLabeler as EventAccessibilityLabeler$1, EventKeyExtractor, ICalendarEvent, RecurrenceFrequency, RecurrenceRule, TimeGridMode, WeekStartsOn, WeekdayFormat, WeekdayFormat as WeekdayFormat$1 } from "@super-calendar/core";
|
|
5
|
+
import { AccessibilityActionEvent, AccessibilityActionInfo, StyleProp, TextStyle, ViewStyle } from "react-native";
|
|
6
6
|
//#region src/theme.d.ts
|
|
7
7
|
/**
|
|
8
8
|
* The full set of colours, text styles and metrics the calendar paints with.
|
|
@@ -208,19 +208,24 @@ interface ResolvedSlot {
|
|
|
208
208
|
* Native text colour doesn't inherit from the badge). Event chips are styled
|
|
209
209
|
* by `renderEvent` (or the theme), not a slot.
|
|
210
210
|
*/
|
|
211
|
-
type MonthViewSlot = "title" | "weekdays" | "weekday" | "grid" | "week" | "day" | "dayBadge" | "dayBadgeText" | "rangeBand" | "more";
|
|
211
|
+
type MonthViewSlot = "title" | "weekdays" | "weekday" | "grid" | "week" | "day" | "dayBadge" | "dayBadgeText" | "rangeBand" | "more" | "morePopover";
|
|
212
212
|
/** Props for {@link MonthView}, the single-month grid. */
|
|
213
213
|
type MonthViewProps<T> = SlotStyleProps<MonthViewSlot> & {
|
|
214
214
|
date: Date;
|
|
215
215
|
events: CalendarEvent$1<T>[];
|
|
216
216
|
/**
|
|
217
|
-
* Max event
|
|
218
|
-
*
|
|
219
|
-
*
|
|
217
|
+
* Max event lanes (stacked rows) shown per week before the rest of a day's
|
|
218
|
+
* events collapse into a "+N more" label. Because multi-day events draw as one
|
|
219
|
+
* bar spanning a lane across the week, this caps lanes per row, not chips per
|
|
220
|
+
* day, so a long bar can push a lightly-booked day's own events into "+N more".
|
|
221
|
+
* Omit to auto-fit as many lanes as the cell height allows (the default); set a
|
|
222
|
+
* number for a fixed cap. Auto-fit assumes the built-in chip size — pass an
|
|
220
223
|
* explicit value when using a custom `renderEvent`.
|
|
221
224
|
*/
|
|
222
225
|
maxVisibleEventCount?: number;
|
|
223
226
|
weekStartsOn: WeekStartsOn;
|
|
227
|
+
/** Weekdays (0=Sunday…6=Saturday) hidden from the grid, e.g. `[0, 6]` for weekends off. */
|
|
228
|
+
hiddenDays?: number[];
|
|
224
229
|
/** Weekday header label width: `narrow` ("M"), `short` ("Mon", default), or `long` ("Monday"). */
|
|
225
230
|
weekdayFormat?: WeekdayFormat;
|
|
226
231
|
locale?: Locale;
|
|
@@ -282,7 +287,7 @@ type MonthViewProps<T> = SlotStyleProps<MonthViewSlot> & {
|
|
|
282
287
|
*/
|
|
283
288
|
renderCustomDateForMonth?: (date: Date) => React.ReactNode;
|
|
284
289
|
};
|
|
285
|
-
declare function MonthViewInner<T>({ date, events, maxVisibleEventCount, weekStartsOn, weekdayFormat, locale, sortedMonthView, moreLabel, showAdjacentMonths, disableMonthEventCellPress, isRTL, showSixWeeks, showTitle, showWeekdays, activeDate, selectedDates: selectedDatesProp, selectedRange: selectedRangeProp, fillCellOnSelection, minDate: minDateProp, maxDate: maxDateProp, isDateDisabled: isDateDisabledProp, calendarCellStyle, renderEvent, eventAccessibilityLabel, keyExtractor, onPressDay, onLongPressDay, onPressEvent, onLongPressEvent, onPressMore, renderCustomDateForMonth, onDayPointerDown, onDayPointerEnter, classNames, styles: styleOverrides }: MonthViewProps<T>): ReactElement;
|
|
290
|
+
declare function MonthViewInner<T>({ date, events, maxVisibleEventCount, weekStartsOn, hiddenDays, weekdayFormat, locale, sortedMonthView, moreLabel, showAdjacentMonths, disableMonthEventCellPress, isRTL, showSixWeeks, showTitle, showWeekdays, activeDate, selectedDates: selectedDatesProp, selectedRange: selectedRangeProp, fillCellOnSelection, minDate: minDateProp, maxDate: maxDateProp, isDateDisabled: isDateDisabledProp, calendarCellStyle, renderEvent, eventAccessibilityLabel, keyExtractor, onPressDay, onLongPressDay, onPressEvent, onLongPressEvent, onPressMore, renderCustomDateForMonth, onDayPointerDown, onDayPointerEnter, classNames, styles: styleOverrides }: MonthViewProps<T>): ReactElement;
|
|
286
291
|
/**
|
|
287
292
|
* A single month rendered as a 7-column grid of day cells, each showing its
|
|
288
293
|
* event chips with a "+N more" overflow. Render it on its own for a static
|
|
@@ -308,6 +313,8 @@ type MonthPagerProps<T> = {
|
|
|
308
313
|
events: CalendarEvent$1<T>[];
|
|
309
314
|
maxVisibleEventCount?: number;
|
|
310
315
|
weekStartsOn: WeekStartsOn;
|
|
316
|
+
/** Weekdays (0=Sunday…6=Saturday) hidden from the grid, e.g. `[0, 6]` for weekends off. */
|
|
317
|
+
hiddenDays?: number[];
|
|
311
318
|
weekdayFormat?: WeekdayFormat;
|
|
312
319
|
locale?: Locale;
|
|
313
320
|
sortedMonthView?: boolean;
|
|
@@ -333,7 +340,7 @@ type MonthPagerProps<T> = {
|
|
|
333
340
|
/** Replace the default date badge in each day cell. Receives the day. */
|
|
334
341
|
renderCustomDateForMonth?: (date: Date) => React.ReactNode;
|
|
335
342
|
} & SlotStyleProps<MonthViewSlot>;
|
|
336
|
-
declare function MonthPagerInner<T>({ date, events, maxVisibleEventCount, weekStartsOn, weekdayFormat, locale, sortedMonthView, moreLabel, showAdjacentMonths, disableMonthEventCellPress, isRTL, calendarCellStyle, renderEvent, keyExtractor, onPressDay, onLongPressDay, onPressEvent, onLongPressEvent, onPressMore, onChangeDate, freeSwipe, swipeEnabled, showSixWeeks, activeDate, renderHeaderForMonthView, renderCustomDateForMonth, classNames, styles: styleOverrides }: MonthPagerProps<T>): ReactElement;
|
|
343
|
+
declare function MonthPagerInner<T>({ date, events, maxVisibleEventCount, weekStartsOn, hiddenDays, weekdayFormat, locale, sortedMonthView, moreLabel, showAdjacentMonths, disableMonthEventCellPress, isRTL, calendarCellStyle, renderEvent, keyExtractor, onPressDay, onLongPressDay, onPressEvent, onLongPressEvent, onPressMore, onChangeDate, freeSwipe, swipeEnabled, showSixWeeks, activeDate, renderHeaderForMonthView, renderCustomDateForMonth, classNames, styles: styleOverrides }: MonthPagerProps<T>): ReactElement;
|
|
337
344
|
/**
|
|
338
345
|
* A horizontally swipeable month carousel. Swipe left/right to page between
|
|
339
346
|
* months; the committed month is reported through `onChangeDate`. It is the
|
|
@@ -451,4 +458,4 @@ declare const MonthList: typeof MonthListInner;
|
|
|
451
458
|
*/
|
|
452
459
|
declare function DefaultMonthEvent<T>({ event, mode, isAllDay, ampm, showTime, ellipsizeTitle, allDayLabel, accessibilityLabel: accessibilityLabelProp, cellStyle, onPress, onLongPress }: RenderEventArgs<T>): ReactElement;
|
|
453
460
|
//#endregion
|
|
454
|
-
export {
|
|
461
|
+
export { PartialCalendarTheme as A, RenderEvent as C, WeekdayFormat$1 as D, WeekStartsOn as E, defaultTheme as M, mergeTheme as N, CalendarTheme as O, useCalendarTheme as P, RecurrenceRule as S, TimeGridMode as T, EventAccessibilityLabelContext as _, MonthPager as a, ICalendarEvent as b, MonthViewProps as c, SlotDefault as d, SlotStyleProps as f, CalendarMode$1 as g, CalendarEvent$1 as h, MonthListSlot as i, darkTheme as j, CalendarThemeProvider as k, MonthViewSlot as l, BusinessHoursBand$1 as m, MonthList as n, MonthPagerProps as o, BusinessHours as p, MonthListProps as r, MonthView as s, DefaultMonthEvent as t, ResolvedSlot as u, EventAccessibilityLabeler$1 as v, RenderEventArgs as w, RecurrenceFrequency as x, EventKeyExtractor as y };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Locale } from "date-fns";
|
|
2
|
-
import { ComponentType, ReactElement } from "react";
|
|
3
|
-
import { SharedValue } from "react-native-reanimated";
|
|
4
|
-
import { BusinessHours, CalendarColors, CalendarEvent, CalendarEvent as CalendarEvent$1, CalendarMode, CalendarMode as CalendarMode$1, DateRange, EventAccessibilityLabelContext, EventAccessibilityLabeler, EventAccessibilityLabeler as EventAccessibilityLabeler$1, EventKeyExtractor, ICalendarEvent, RecurrenceFrequency, RecurrenceRule, TimeGridMode, WeekStartsOn, WeekdayFormat, WeekdayFormat as WeekdayFormat$1 } from "@super-calendar/core";
|
|
2
|
+
import { ComponentType, ReactElement, ReactNode } from "react";
|
|
5
3
|
import { AccessibilityActionEvent, AccessibilityActionInfo, StyleProp, TextStyle, ViewStyle } from "react-native";
|
|
4
|
+
import { SharedValue } from "react-native-reanimated";
|
|
5
|
+
import { BusinessHours, BusinessHoursBand as BusinessHoursBand$1, CalendarColors, CalendarEvent, CalendarEvent as CalendarEvent$1, CalendarMode, CalendarMode as CalendarMode$1, DateRange, EventAccessibilityLabelContext, EventAccessibilityLabeler, EventAccessibilityLabeler as EventAccessibilityLabeler$1, EventKeyExtractor, ICalendarEvent, RecurrenceFrequency, RecurrenceRule, TimeGridMode, WeekStartsOn, WeekdayFormat, WeekdayFormat as WeekdayFormat$1 } from "@super-calendar/core";
|
|
6
6
|
//#region src/theme.d.ts
|
|
7
7
|
/**
|
|
8
8
|
* The full set of colours, text styles and metrics the calendar paints with.
|
|
@@ -208,19 +208,24 @@ interface ResolvedSlot {
|
|
|
208
208
|
* Native text colour doesn't inherit from the badge). Event chips are styled
|
|
209
209
|
* by `renderEvent` (or the theme), not a slot.
|
|
210
210
|
*/
|
|
211
|
-
type MonthViewSlot = "title" | "weekdays" | "weekday" | "grid" | "week" | "day" | "dayBadge" | "dayBadgeText" | "rangeBand" | "more";
|
|
211
|
+
type MonthViewSlot = "title" | "weekdays" | "weekday" | "grid" | "week" | "day" | "dayBadge" | "dayBadgeText" | "rangeBand" | "more" | "morePopover";
|
|
212
212
|
/** Props for {@link MonthView}, the single-month grid. */
|
|
213
213
|
type MonthViewProps<T> = SlotStyleProps<MonthViewSlot> & {
|
|
214
214
|
date: Date;
|
|
215
215
|
events: CalendarEvent$1<T>[];
|
|
216
216
|
/**
|
|
217
|
-
* Max event
|
|
218
|
-
*
|
|
219
|
-
*
|
|
217
|
+
* Max event lanes (stacked rows) shown per week before the rest of a day's
|
|
218
|
+
* events collapse into a "+N more" label. Because multi-day events draw as one
|
|
219
|
+
* bar spanning a lane across the week, this caps lanes per row, not chips per
|
|
220
|
+
* day, so a long bar can push a lightly-booked day's own events into "+N more".
|
|
221
|
+
* Omit to auto-fit as many lanes as the cell height allows (the default); set a
|
|
222
|
+
* number for a fixed cap. Auto-fit assumes the built-in chip size — pass an
|
|
220
223
|
* explicit value when using a custom `renderEvent`.
|
|
221
224
|
*/
|
|
222
225
|
maxVisibleEventCount?: number;
|
|
223
226
|
weekStartsOn: WeekStartsOn;
|
|
227
|
+
/** Weekdays (0=Sunday…6=Saturday) hidden from the grid, e.g. `[0, 6]` for weekends off. */
|
|
228
|
+
hiddenDays?: number[];
|
|
224
229
|
/** Weekday header label width: `narrow` ("M"), `short` ("Mon", default), or `long` ("Monday"). */
|
|
225
230
|
weekdayFormat?: WeekdayFormat;
|
|
226
231
|
locale?: Locale;
|
|
@@ -282,7 +287,7 @@ type MonthViewProps<T> = SlotStyleProps<MonthViewSlot> & {
|
|
|
282
287
|
*/
|
|
283
288
|
renderCustomDateForMonth?: (date: Date) => React.ReactNode;
|
|
284
289
|
};
|
|
285
|
-
declare function MonthViewInner<T>({ date, events, maxVisibleEventCount, weekStartsOn, weekdayFormat, locale, sortedMonthView, moreLabel, showAdjacentMonths, disableMonthEventCellPress, isRTL, showSixWeeks, showTitle, showWeekdays, activeDate, selectedDates: selectedDatesProp, selectedRange: selectedRangeProp, fillCellOnSelection, minDate: minDateProp, maxDate: maxDateProp, isDateDisabled: isDateDisabledProp, calendarCellStyle, renderEvent, eventAccessibilityLabel, keyExtractor, onPressDay, onLongPressDay, onPressEvent, onLongPressEvent, onPressMore, renderCustomDateForMonth, onDayPointerDown, onDayPointerEnter, classNames, styles: styleOverrides }: MonthViewProps<T>): ReactElement;
|
|
290
|
+
declare function MonthViewInner<T>({ date, events, maxVisibleEventCount, weekStartsOn, hiddenDays, weekdayFormat, locale, sortedMonthView, moreLabel, showAdjacentMonths, disableMonthEventCellPress, isRTL, showSixWeeks, showTitle, showWeekdays, activeDate, selectedDates: selectedDatesProp, selectedRange: selectedRangeProp, fillCellOnSelection, minDate: minDateProp, maxDate: maxDateProp, isDateDisabled: isDateDisabledProp, calendarCellStyle, renderEvent, eventAccessibilityLabel, keyExtractor, onPressDay, onLongPressDay, onPressEvent, onLongPressEvent, onPressMore, renderCustomDateForMonth, onDayPointerDown, onDayPointerEnter, classNames, styles: styleOverrides }: MonthViewProps<T>): ReactElement;
|
|
286
291
|
/**
|
|
287
292
|
* A single month rendered as a 7-column grid of day cells, each showing its
|
|
288
293
|
* event chips with a "+N more" overflow. Render it on its own for a static
|
|
@@ -308,6 +313,8 @@ type MonthPagerProps<T> = {
|
|
|
308
313
|
events: CalendarEvent$1<T>[];
|
|
309
314
|
maxVisibleEventCount?: number;
|
|
310
315
|
weekStartsOn: WeekStartsOn;
|
|
316
|
+
/** Weekdays (0=Sunday…6=Saturday) hidden from the grid, e.g. `[0, 6]` for weekends off. */
|
|
317
|
+
hiddenDays?: number[];
|
|
311
318
|
weekdayFormat?: WeekdayFormat;
|
|
312
319
|
locale?: Locale;
|
|
313
320
|
sortedMonthView?: boolean;
|
|
@@ -333,7 +340,7 @@ type MonthPagerProps<T> = {
|
|
|
333
340
|
/** Replace the default date badge in each day cell. Receives the day. */
|
|
334
341
|
renderCustomDateForMonth?: (date: Date) => React.ReactNode;
|
|
335
342
|
} & SlotStyleProps<MonthViewSlot>;
|
|
336
|
-
declare function MonthPagerInner<T>({ date, events, maxVisibleEventCount, weekStartsOn, weekdayFormat, locale, sortedMonthView, moreLabel, showAdjacentMonths, disableMonthEventCellPress, isRTL, calendarCellStyle, renderEvent, keyExtractor, onPressDay, onLongPressDay, onPressEvent, onLongPressEvent, onPressMore, onChangeDate, freeSwipe, swipeEnabled, showSixWeeks, activeDate, renderHeaderForMonthView, renderCustomDateForMonth, classNames, styles: styleOverrides }: MonthPagerProps<T>): ReactElement;
|
|
343
|
+
declare function MonthPagerInner<T>({ date, events, maxVisibleEventCount, weekStartsOn, hiddenDays, weekdayFormat, locale, sortedMonthView, moreLabel, showAdjacentMonths, disableMonthEventCellPress, isRTL, calendarCellStyle, renderEvent, keyExtractor, onPressDay, onLongPressDay, onPressEvent, onLongPressEvent, onPressMore, onChangeDate, freeSwipe, swipeEnabled, showSixWeeks, activeDate, renderHeaderForMonthView, renderCustomDateForMonth, classNames, styles: styleOverrides }: MonthPagerProps<T>): ReactElement;
|
|
337
344
|
/**
|
|
338
345
|
* A horizontally swipeable month carousel. Swipe left/right to page between
|
|
339
346
|
* months; the committed month is reported through `onChangeDate`. It is the
|
|
@@ -451,4 +458,4 @@ declare const MonthList: typeof MonthListInner;
|
|
|
451
458
|
*/
|
|
452
459
|
declare function DefaultMonthEvent<T>({ event, mode, isAllDay, ampm, showTime, ellipsizeTitle, allDayLabel, accessibilityLabel: accessibilityLabelProp, cellStyle, onPress, onLongPress }: RenderEventArgs<T>): ReactElement;
|
|
453
460
|
//#endregion
|
|
454
|
-
export {
|
|
461
|
+
export { PartialCalendarTheme as A, RenderEvent as C, WeekdayFormat$1 as D, WeekStartsOn as E, defaultTheme as M, mergeTheme as N, CalendarTheme as O, useCalendarTheme as P, RecurrenceRule as S, TimeGridMode as T, EventAccessibilityLabelContext as _, MonthPager as a, ICalendarEvent as b, MonthViewProps as c, SlotDefault as d, SlotStyleProps as f, CalendarMode$1 as g, CalendarEvent$1 as h, MonthListSlot as i, darkTheme as j, CalendarThemeProvider as k, MonthViewSlot as l, BusinessHoursBand$1 as m, MonthList as n, MonthPagerProps as o, BusinessHours as p, MonthListProps as r, MonthView as s, DefaultMonthEvent as t, ResolvedSlot as u, EventAccessibilityLabeler$1 as v, RenderEventArgs as w, RecurrenceFrequency as x, EventKeyExtractor as y };
|
|
@@ -200,9 +200,29 @@ const DATE_BADGE_HEIGHT = 24;
|
|
|
200
200
|
const BAND_CENTER_Y = 16;
|
|
201
201
|
const CELL_ROW_GAP = 2;
|
|
202
202
|
const CHIP_PADDING_V = 2;
|
|
203
|
+
const BADGE_AREA = 30;
|
|
204
|
+
const EMPTY_LAYOUT = {
|
|
205
|
+
segments: [],
|
|
206
|
+
laneCount: 0
|
|
207
|
+
};
|
|
208
|
+
const CHIP_INSET_H = 4;
|
|
203
209
|
const FALLBACK_VISIBLE_COUNT = 3;
|
|
204
210
|
const numericStyle = (value, fallback) => typeof value === "number" ? value : fallback;
|
|
205
|
-
function
|
|
211
|
+
function collectRowEvents(week, eventsByDay) {
|
|
212
|
+
const seen = /* @__PURE__ */ new Set();
|
|
213
|
+
const out = [];
|
|
214
|
+
for (const day of week) {
|
|
215
|
+
const list = eventsByDay.get((0, date_fns.startOfDay)(day).toISOString());
|
|
216
|
+
if (!list) continue;
|
|
217
|
+
for (const event of list) if (!seen.has(event)) {
|
|
218
|
+
seen.add(event);
|
|
219
|
+
out.push(event);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return out;
|
|
223
|
+
}
|
|
224
|
+
const pct = (n) => `${n}%`;
|
|
225
|
+
function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, hiddenDays, weekdayFormat = "short", locale, sortedMonthView = true, moreLabel = "{moreCount} More", showAdjacentMonths = true, disableMonthEventCellPress = false, isRTL = false, showSixWeeks = false, showTitle = true, showWeekdays = true, activeDate, selectedDates: selectedDatesProp, selectedRange: selectedRangeProp, fillCellOnSelection = false, minDate: minDateProp, maxDate: maxDateProp, isDateDisabled: isDateDisabledProp, calendarCellStyle, renderEvent, eventAccessibilityLabel, keyExtractor, onPressDay, onLongPressDay, onPressEvent, onLongPressEvent, onPressMore, renderCustomDateForMonth, onDayPointerDown, onDayPointerEnter, classNames, styles: styleOverrides }) {
|
|
206
226
|
const theme = useCalendarTheme();
|
|
207
227
|
const slot = createSlots({
|
|
208
228
|
classNames,
|
|
@@ -218,23 +238,35 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, week
|
|
|
218
238
|
const [gridHeight, setGridHeight] = (0, react.useState)(0);
|
|
219
239
|
const [hoveredKey, setHoveredKey] = (0, react.useState)(null);
|
|
220
240
|
const [pressedKey, setPressedKey] = (0, react.useState)(null);
|
|
241
|
+
const [moreOpenFor, setMoreOpenFor] = (0, react.useState)(null);
|
|
221
242
|
const weeks = (0, react.useMemo)(() => (0, _super_calendar_core.buildMonthWeeks)(date, weekStartsOn, {
|
|
222
243
|
showSixWeeks,
|
|
223
|
-
isRTL
|
|
244
|
+
isRTL,
|
|
245
|
+
hiddenDays
|
|
224
246
|
}), [
|
|
225
247
|
date,
|
|
226
248
|
weekStartsOn,
|
|
227
249
|
isRTL,
|
|
228
|
-
showSixWeeks
|
|
250
|
+
showSixWeeks,
|
|
251
|
+
hiddenDays
|
|
229
252
|
]);
|
|
230
253
|
const weekdayLabels = (0, react.useMemo)(() => {
|
|
231
|
-
const days = (0, _super_calendar_core.getWeekDays)(date, weekStartsOn);
|
|
254
|
+
const days = (0, _super_calendar_core.filterHiddenDays)((0, _super_calendar_core.getWeekDays)(date, weekStartsOn), hiddenDays);
|
|
232
255
|
return isRTL ? days.reverse() : days;
|
|
233
256
|
}, [
|
|
234
257
|
date,
|
|
235
258
|
weekStartsOn,
|
|
236
|
-
isRTL
|
|
259
|
+
isRTL,
|
|
260
|
+
hiddenDays
|
|
237
261
|
]);
|
|
262
|
+
const chipMetrics = (0, react.useMemo)(() => {
|
|
263
|
+
const fontSize = numericStyle(theme.text.eventTitle.fontSize, 12);
|
|
264
|
+
const chipHeight = numericStyle(theme.text.eventTitle.lineHeight, Math.ceil(fontSize * 1.3)) + CHIP_PADDING_V * 2;
|
|
265
|
+
return {
|
|
266
|
+
chipHeight,
|
|
267
|
+
chipRowHeight: chipHeight + CELL_ROW_GAP
|
|
268
|
+
};
|
|
269
|
+
}, [theme]);
|
|
238
270
|
const capacity = (0, react.useMemo)(() => {
|
|
239
271
|
if (maxVisibleEventCount != null) return {
|
|
240
272
|
full: maxVisibleEventCount,
|
|
@@ -245,24 +277,28 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, week
|
|
|
245
277
|
withMore: FALLBACK_VISIBLE_COUNT
|
|
246
278
|
};
|
|
247
279
|
const rowHeight = gridHeight / weeks.length;
|
|
248
|
-
const fontSize = numericStyle(theme.text.eventTitle.fontSize, 12);
|
|
249
|
-
const chipRowHeight = numericStyle(theme.text.eventTitle.lineHeight, Math.ceil(fontSize * 1.3)) + CHIP_PADDING_V * 2 + CELL_ROW_GAP;
|
|
250
280
|
const moreFontSize = numericStyle(theme.text.more.fontSize, 11);
|
|
251
281
|
const moreRowHeight = Math.ceil(moreFontSize * 1.3) + CELL_ROW_GAP;
|
|
252
|
-
return (0, _super_calendar_core.monthEventCapacity)(rowHeight - DAY_CELL_PADDING_TOP - DATE_BADGE_HEIGHT, chipRowHeight, moreRowHeight);
|
|
282
|
+
return (0, _super_calendar_core.monthEventCapacity)(rowHeight - DAY_CELL_PADDING_TOP - DATE_BADGE_HEIGHT, chipMetrics.chipRowHeight, moreRowHeight);
|
|
253
283
|
}, [
|
|
254
284
|
maxVisibleEventCount,
|
|
255
285
|
gridHeight,
|
|
256
286
|
weeks.length,
|
|
257
|
-
theme
|
|
287
|
+
theme,
|
|
288
|
+
chipMetrics
|
|
258
289
|
]);
|
|
259
290
|
const eventsByDay = (0, react.useMemo)(() => {
|
|
260
|
-
const map = (0, _super_calendar_core.groupEventsByDay)(events);
|
|
291
|
+
const map = (0, _super_calendar_core.groupEventsByDay)(events.filter((event) => !(0, _super_calendar_core.isBackgroundEvent)(event)));
|
|
261
292
|
if (sortedMonthView) for (const list of map.values()) list.sort(_super_calendar_core.compareDayEvents);
|
|
262
293
|
return map;
|
|
263
294
|
}, [events, sortedMonthView]);
|
|
264
295
|
const showGrid = events.length > 0;
|
|
265
|
-
const
|
|
296
|
+
const weekLayouts = (0, react.useMemo)(() => showGrid ? weeks.map((week) => (0, _super_calendar_core.layoutMonthWeek)(week, collectRowEvents(week, eventsByDay))) : [], [
|
|
297
|
+
showGrid,
|
|
298
|
+
weeks,
|
|
299
|
+
eventsByDay
|
|
300
|
+
]);
|
|
301
|
+
const renderDay = (day, dayCol, rowLayout, visibleLanes) => {
|
|
266
302
|
const isCurrentMonth = (0, date_fns.isSameMonth)(day, date);
|
|
267
303
|
if (!isCurrentMonth && !showAdjacentMonths) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, { ...slot("day", {
|
|
268
304
|
base: styles$3.dayCell,
|
|
@@ -283,8 +319,7 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, week
|
|
|
283
319
|
maxDate,
|
|
284
320
|
isDateDisabled
|
|
285
321
|
});
|
|
286
|
-
const
|
|
287
|
-
const hiddenCount = dayEvents.length - visibleCount;
|
|
322
|
+
const hiddenCount = rowLayout.segments.filter((s) => s.startCol <= dayCol && s.endCol >= dayCol && s.lane >= visibleLanes).map((s) => s.event).length;
|
|
288
323
|
const isFilledBadge = (0, _super_calendar_core.dayBadgeKind)({ isSelected }, isHighlighted) !== "none";
|
|
289
324
|
const hasBand = (0, _super_calendar_core.rangeBandKind)({
|
|
290
325
|
isInRange,
|
|
@@ -389,22 +424,19 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, week
|
|
|
389
424
|
children: (0, date_fns.format)(day, "d")
|
|
390
425
|
})
|
|
391
426
|
}),
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
mode: "month",
|
|
397
|
-
isAllDay: (0, _super_calendar_core.isAllDayEvent)(event),
|
|
398
|
-
onPress: disableMonthEventCellPress ? () => {} : () => onPressEvent(event),
|
|
399
|
-
onLongPress: disableMonthEventCellPress || !onLongPressEvent ? void 0 : () => onLongPressEvent(event)
|
|
400
|
-
})
|
|
401
|
-
}, keyExtractor(event, index))),
|
|
427
|
+
Array.from({ length: visibleLanes }, (_, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, { style: {
|
|
428
|
+
height: chipMetrics.chipHeight,
|
|
429
|
+
pointerEvents: "none"
|
|
430
|
+
} }, `lane-${i}`)),
|
|
402
431
|
hiddenCount > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
|
|
403
432
|
...slot("more", {
|
|
404
433
|
base: styles$3.moreLabel,
|
|
405
434
|
themed: [theme.text.more, { color: theme.colors.textMuted }]
|
|
406
435
|
}),
|
|
407
|
-
onPress: onPressMore ? () => onPressMore(dayEvents, day) :
|
|
436
|
+
onPress: onPressMore ? () => onPressMore(dayEvents, day) : () => setMoreOpenFor({
|
|
437
|
+
day,
|
|
438
|
+
events: dayEvents
|
|
439
|
+
}),
|
|
408
440
|
accessibilityRole: "button",
|
|
409
441
|
accessibilityLabel: `Show ${hiddenCount} more events`,
|
|
410
442
|
allowFontScaling: false,
|
|
@@ -442,16 +474,93 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, week
|
|
|
442
474
|
children: (0, date_fns.format)(day, (0, _super_calendar_core.weekdayFormatToken)(weekdayFormat), { locale })
|
|
443
475
|
}, day.toISOString()))
|
|
444
476
|
}) : null,
|
|
477
|
+
moreOpenFor ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Modal, {
|
|
478
|
+
transparent: true,
|
|
479
|
+
animationType: "fade",
|
|
480
|
+
visible: true,
|
|
481
|
+
onRequestClose: () => setMoreOpenFor(null),
|
|
482
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Pressable, {
|
|
483
|
+
style: styles$3.moreBackdrop,
|
|
484
|
+
accessibilityLabel: "Close",
|
|
485
|
+
onPress: () => setMoreOpenFor(null),
|
|
486
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.Pressable, {
|
|
487
|
+
onPress: () => {},
|
|
488
|
+
...slot("morePopover", {
|
|
489
|
+
base: styles$3.moreCard,
|
|
490
|
+
themed: {
|
|
491
|
+
backgroundColor: theme.colors.surface,
|
|
492
|
+
borderColor: theme.colors.gridLine
|
|
493
|
+
}
|
|
494
|
+
}),
|
|
495
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
|
|
496
|
+
accessibilityRole: "header",
|
|
497
|
+
style: [styles$3.moreCardTitle, { color: theme.colors.text }],
|
|
498
|
+
allowFontScaling: false,
|
|
499
|
+
children: (0, date_fns.format)(moreOpenFor.day, "EEEE, d LLLL yyyy", { locale })
|
|
500
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.ScrollView, { children: moreOpenFor.events.map((event, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
501
|
+
style: styles$3.moreCardRow,
|
|
502
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RenderEventComponent, {
|
|
503
|
+
event,
|
|
504
|
+
mode: "month",
|
|
505
|
+
isAllDay: (0, _super_calendar_core.isAllDayEvent)(event),
|
|
506
|
+
onPress: () => {
|
|
507
|
+
setMoreOpenFor(null);
|
|
508
|
+
onPressEvent(event);
|
|
509
|
+
}
|
|
510
|
+
})
|
|
511
|
+
}, keyExtractor(event, index))) })]
|
|
512
|
+
})
|
|
513
|
+
})
|
|
514
|
+
}) : null,
|
|
445
515
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
446
516
|
...slot("grid", { base: styles$3.container }),
|
|
447
517
|
onLayout: handleLayout,
|
|
448
|
-
children: weeks.map((week) =>
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
518
|
+
children: weeks.map((week, weekIndex) => {
|
|
519
|
+
const rowLayout = weekLayouts[weekIndex] ?? EMPTY_LAYOUT;
|
|
520
|
+
const visibleLanes = (0, _super_calendar_core.monthVisibleCount)(rowLayout.laneCount, capacity);
|
|
521
|
+
const cols = week.length;
|
|
522
|
+
let firstVisCol = 0;
|
|
523
|
+
let lastVisCol = cols - 1;
|
|
524
|
+
if (showGrid && !showAdjacentMonths) {
|
|
525
|
+
const first = week.findIndex((d) => (0, date_fns.isSameMonth)(d, date));
|
|
526
|
+
if (first !== -1) {
|
|
527
|
+
firstVisCol = first;
|
|
528
|
+
lastVisCol = cols - 1 - [...week].reverse().findIndex((d) => (0, date_fns.isSameMonth)(d, date));
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
return /* @__PURE__ */ (0, react.createElement)(react_native.View, {
|
|
532
|
+
...slot("week", {
|
|
533
|
+
base: styles$3.weekRow,
|
|
534
|
+
themed: theme.containers.weekRow
|
|
535
|
+
}),
|
|
536
|
+
key: week[0].toISOString()
|
|
537
|
+
}, week.map((day, dayCol) => renderDay(day, dayCol, rowLayout, visibleLanes)), showGrid ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
538
|
+
style: [react_native.StyleSheet.absoluteFill, { pointerEvents: "box-none" }],
|
|
539
|
+
children: rowLayout.segments.filter((seg) => seg.lane < visibleLanes).map((seg) => {
|
|
540
|
+
const startCol = Math.max(seg.startCol, firstVisCol);
|
|
541
|
+
const endCol = Math.min(seg.endCol, lastVisCol);
|
|
542
|
+
if (startCol > endCol) return null;
|
|
543
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
544
|
+
style: {
|
|
545
|
+
position: "absolute",
|
|
546
|
+
left: pct(startCol / cols * 100),
|
|
547
|
+
width: pct((endCol - startCol + 1) / cols * 100),
|
|
548
|
+
top: BADGE_AREA + seg.lane * chipMetrics.chipRowHeight,
|
|
549
|
+
height: chipMetrics.chipHeight,
|
|
550
|
+
paddingHorizontal: CHIP_INSET_H,
|
|
551
|
+
pointerEvents: "box-none"
|
|
552
|
+
},
|
|
553
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RenderEventComponent, {
|
|
554
|
+
event: seg.event,
|
|
555
|
+
mode: "month",
|
|
556
|
+
isAllDay: (0, _super_calendar_core.isAllDayEvent)(seg.event),
|
|
557
|
+
onPress: disableMonthEventCellPress ? () => {} : () => onPressEvent(seg.event),
|
|
558
|
+
onLongPress: disableMonthEventCellPress || !onLongPressEvent ? void 0 : () => onLongPressEvent(seg.event)
|
|
559
|
+
})
|
|
560
|
+
}, `bar-${seg.event.start.toISOString()}:${seg.event.title}:${seg.lane}`);
|
|
561
|
+
})
|
|
562
|
+
}) : null);
|
|
563
|
+
})
|
|
455
564
|
})
|
|
456
565
|
]
|
|
457
566
|
});
|
|
@@ -520,14 +629,36 @@ const styles$3 = react_native.StyleSheet.create({
|
|
|
520
629
|
moreLabel: {
|
|
521
630
|
marginTop: 2,
|
|
522
631
|
marginHorizontal: 4
|
|
523
|
-
}
|
|
632
|
+
},
|
|
633
|
+
moreBackdrop: {
|
|
634
|
+
flex: 1,
|
|
635
|
+
backgroundColor: "rgba(0, 0, 0, 0.3)",
|
|
636
|
+
alignItems: "center",
|
|
637
|
+
justifyContent: "center",
|
|
638
|
+
padding: 24
|
|
639
|
+
},
|
|
640
|
+
moreCard: {
|
|
641
|
+
width: "100%",
|
|
642
|
+
maxWidth: 360,
|
|
643
|
+
maxHeight: "60%",
|
|
644
|
+
borderRadius: 12,
|
|
645
|
+
borderWidth: react_native.StyleSheet.hairlineWidth,
|
|
646
|
+
padding: 12,
|
|
647
|
+
gap: 6
|
|
648
|
+
},
|
|
649
|
+
moreCardTitle: {
|
|
650
|
+
fontSize: 14,
|
|
651
|
+
fontWeight: "600",
|
|
652
|
+
marginBottom: 4
|
|
653
|
+
},
|
|
654
|
+
moreCardRow: { marginBottom: 4 }
|
|
524
655
|
});
|
|
525
656
|
//#endregion
|
|
526
657
|
//#region src/components/MonthPager.tsx
|
|
527
658
|
const isWeb$1 = react_native.Platform.OS === "web";
|
|
528
659
|
const PAGE_WINDOW$1 = 60;
|
|
529
660
|
const PAGE_VIEWABILITY = { itemVisiblePercentThreshold: 90 };
|
|
530
|
-
function MonthPagerInner({ date, events, maxVisibleEventCount, weekStartsOn, weekdayFormat = "short", locale, sortedMonthView, moreLabel, showAdjacentMonths, disableMonthEventCellPress, isRTL, calendarCellStyle, renderEvent, keyExtractor, onPressDay, onLongPressDay, onPressEvent, onLongPressEvent, onPressMore, onChangeDate, freeSwipe = false, swipeEnabled = true, showSixWeeks = false, activeDate, renderHeaderForMonthView, renderCustomDateForMonth, classNames, styles: styleOverrides }) {
|
|
661
|
+
function MonthPagerInner({ date, events, maxVisibleEventCount, weekStartsOn, hiddenDays, weekdayFormat = "short", locale, sortedMonthView, moreLabel, showAdjacentMonths, disableMonthEventCellPress, isRTL, calendarCellStyle, renderEvent, keyExtractor, onPressDay, onLongPressDay, onPressEvent, onLongPressEvent, onPressMore, onChangeDate, freeSwipe = false, swipeEnabled = true, showSixWeeks = false, activeDate, renderHeaderForMonthView, renderCustomDateForMonth, classNames, styles: styleOverrides }) {
|
|
531
662
|
const theme = useCalendarTheme();
|
|
532
663
|
const slot = (0, react.useMemo)(() => createSlots({
|
|
533
664
|
classNames,
|
|
@@ -593,12 +724,13 @@ function MonthPagerInner({ date, events, maxVisibleEventCount, weekStartsOn, wee
|
|
|
593
724
|
onChangeDate
|
|
594
725
|
]));
|
|
595
726
|
const weekDays = (0, react.useMemo)(() => {
|
|
596
|
-
const days = (0, _super_calendar_core.getWeekDays)(anchor, weekStartsOn);
|
|
727
|
+
const days = (0, _super_calendar_core.filterHiddenDays)((0, _super_calendar_core.getWeekDays)(anchor, weekStartsOn), hiddenDays);
|
|
597
728
|
return isRTL ? days.reverse() : days;
|
|
598
729
|
}, [
|
|
599
730
|
anchor,
|
|
600
731
|
weekStartsOn,
|
|
601
|
-
isRTL
|
|
732
|
+
isRTL,
|
|
733
|
+
hiddenDays
|
|
602
734
|
]);
|
|
603
735
|
const listExtraData = (0, react.useMemo)(() => ({
|
|
604
736
|
events,
|
|
@@ -619,6 +751,7 @@ function MonthPagerInner({ date, events, maxVisibleEventCount, weekStartsOn, wee
|
|
|
619
751
|
showWeekdays: false,
|
|
620
752
|
maxVisibleEventCount,
|
|
621
753
|
weekStartsOn,
|
|
754
|
+
hiddenDays,
|
|
622
755
|
locale,
|
|
623
756
|
sortedMonthView,
|
|
624
757
|
moreLabel,
|