@super-calendar/native 2.7.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-DCPDsnvq.d.ts → DefaultMonthEvent-Cm9DsHBK.d.mts} +7 -4
- package/dist/{DefaultMonthEvent-DMOC5aNL.d.mts → DefaultMonthEvent-DAxZjk_D.d.ts} +7 -4
- package/dist/{MonthList-CJs1vq5T.js → MonthList-BWTCCmko.js} +88 -24
- package/dist/{MonthList-Dn37Ezj0.mjs → MonthList-Chx0jP5n.mjs} +89 -25
- package/dist/index.d.mts +27 -6
- package/dist/index.d.ts +27 -6
- package/dist/index.js +120 -47
- package/dist/index.mjs +116 -49
- 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/Calendar.tsx +12 -0
- package/src/components/MonthView.tsx +144 -35
- package/src/components/ResourceTimeline.tsx +32 -15
- package/src/components/TimeGrid.tsx +155 -29
- package/src/index.tsx +3 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Locale } from "date-fns";
|
|
2
2
|
import { ComponentType, ReactElement, ReactNode } from "react";
|
|
3
|
-
import { AccessibilityActionEvent, AccessibilityActionInfo, StyleProp, TextStyle, ViewStyle } from "react-native";
|
|
4
3
|
import { SharedValue } from "react-native-reanimated";
|
|
5
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.
|
|
@@ -214,9 +214,12 @@ 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;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Locale } from "date-fns";
|
|
2
2
|
import { ComponentType, ReactElement, ReactNode } from "react";
|
|
3
|
+
import { AccessibilityActionEvent, AccessibilityActionInfo, StyleProp, TextStyle, ViewStyle } from "react-native";
|
|
3
4
|
import { SharedValue } from "react-native-reanimated";
|
|
4
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";
|
|
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.
|
|
@@ -214,9 +214,12 @@ 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;
|
|
@@ -200,8 +200,28 @@ 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;
|
|
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}%`;
|
|
205
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({
|
|
@@ -239,6 +259,14 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, hidd
|
|
|
239
259
|
isRTL,
|
|
240
260
|
hiddenDays
|
|
241
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]);
|
|
242
270
|
const capacity = (0, react.useMemo)(() => {
|
|
243
271
|
if (maxVisibleEventCount != null) return {
|
|
244
272
|
full: maxVisibleEventCount,
|
|
@@ -249,16 +277,15 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, hidd
|
|
|
249
277
|
withMore: FALLBACK_VISIBLE_COUNT
|
|
250
278
|
};
|
|
251
279
|
const rowHeight = gridHeight / weeks.length;
|
|
252
|
-
const fontSize = numericStyle(theme.text.eventTitle.fontSize, 12);
|
|
253
|
-
const chipRowHeight = numericStyle(theme.text.eventTitle.lineHeight, Math.ceil(fontSize * 1.3)) + CHIP_PADDING_V * 2 + CELL_ROW_GAP;
|
|
254
280
|
const moreFontSize = numericStyle(theme.text.more.fontSize, 11);
|
|
255
281
|
const moreRowHeight = Math.ceil(moreFontSize * 1.3) + CELL_ROW_GAP;
|
|
256
|
-
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);
|
|
257
283
|
}, [
|
|
258
284
|
maxVisibleEventCount,
|
|
259
285
|
gridHeight,
|
|
260
286
|
weeks.length,
|
|
261
|
-
theme
|
|
287
|
+
theme,
|
|
288
|
+
chipMetrics
|
|
262
289
|
]);
|
|
263
290
|
const eventsByDay = (0, react.useMemo)(() => {
|
|
264
291
|
const map = (0, _super_calendar_core.groupEventsByDay)(events.filter((event) => !(0, _super_calendar_core.isBackgroundEvent)(event)));
|
|
@@ -266,7 +293,12 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, hidd
|
|
|
266
293
|
return map;
|
|
267
294
|
}, [events, sortedMonthView]);
|
|
268
295
|
const showGrid = events.length > 0;
|
|
269
|
-
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) => {
|
|
270
302
|
const isCurrentMonth = (0, date_fns.isSameMonth)(day, date);
|
|
271
303
|
if (!isCurrentMonth && !showAdjacentMonths) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, { ...slot("day", {
|
|
272
304
|
base: styles$3.dayCell,
|
|
@@ -287,8 +319,7 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, hidd
|
|
|
287
319
|
maxDate,
|
|
288
320
|
isDateDisabled
|
|
289
321
|
});
|
|
290
|
-
const
|
|
291
|
-
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;
|
|
292
323
|
const isFilledBadge = (0, _super_calendar_core.dayBadgeKind)({ isSelected }, isHighlighted) !== "none";
|
|
293
324
|
const hasBand = (0, _super_calendar_core.rangeBandKind)({
|
|
294
325
|
isInRange,
|
|
@@ -393,16 +424,10 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, hidd
|
|
|
393
424
|
children: (0, date_fns.format)(day, "d")
|
|
394
425
|
})
|
|
395
426
|
}),
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
mode: "month",
|
|
401
|
-
isAllDay: (0, _super_calendar_core.isAllDayEvent)(event),
|
|
402
|
-
onPress: disableMonthEventCellPress ? () => {} : () => onPressEvent(event),
|
|
403
|
-
onLongPress: disableMonthEventCellPress || !onLongPressEvent ? void 0 : () => onLongPressEvent(event)
|
|
404
|
-
})
|
|
405
|
-
}, 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}`)),
|
|
406
431
|
hiddenCount > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
|
|
407
432
|
...slot("more", {
|
|
408
433
|
base: styles$3.moreLabel,
|
|
@@ -490,13 +515,52 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, hidd
|
|
|
490
515
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
491
516
|
...slot("grid", { base: styles$3.container }),
|
|
492
517
|
onLayout: handleLayout,
|
|
493
|
-
children: weeks.map((week) =>
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
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
|
+
})
|
|
500
564
|
})
|
|
501
565
|
]
|
|
502
566
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { addMonths, differenceInCalendarMonths, format, isSameMonth, startOfDay, startOfMonth } from "date-fns";
|
|
2
2
|
import { createContext, createElement, memo, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
-
import { CalendarSelectionProvider, buildMonthWeeks, compareDayEvents, darkColors, dayBadgeKind, daySelectionState, eventAccessibilityLabel, eventTimeLabel, filterHiddenDays, getIsToday, getWeekDays, groupEventsByDay, isAllDayEvent, isBackgroundEvent, isDateSelectable, isSameCalendarDay, isWeekend, lightColors, monthEventCapacity, monthVisibleCount, rangeBandKind, titleEllipsizeMode, titleNumberOfLines, useCalendarSelection, weekdayFormatToken } from "@super-calendar/core";
|
|
3
|
+
import { CalendarSelectionProvider, buildMonthWeeks, compareDayEvents, darkColors, dayBadgeKind, daySelectionState, eventAccessibilityLabel, eventTimeLabel, filterHiddenDays, getIsToday, getWeekDays, groupEventsByDay, isAllDayEvent, isBackgroundEvent, isDateSelectable, isSameCalendarDay, isWeekend, layoutMonthWeek, lightColors, monthEventCapacity, monthVisibleCount, rangeBandKind, titleEllipsizeMode, titleNumberOfLines, useCalendarSelection, weekdayFormatToken } from "@super-calendar/core";
|
|
4
4
|
import { Modal, Platform, Pressable, ScrollView, StyleSheet, Text, TouchableOpacity, View, useWindowDimensions } from "react-native";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import { LegendList } from "@legendapp/list/react-native";
|
|
@@ -200,8 +200,28 @@ 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;
|
|
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(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}%`;
|
|
205
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({
|
|
@@ -239,6 +259,14 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, hidd
|
|
|
239
259
|
isRTL,
|
|
240
260
|
hiddenDays
|
|
241
261
|
]);
|
|
262
|
+
const chipMetrics = 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]);
|
|
242
270
|
const capacity = useMemo(() => {
|
|
243
271
|
if (maxVisibleEventCount != null) return {
|
|
244
272
|
full: maxVisibleEventCount,
|
|
@@ -249,16 +277,15 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, hidd
|
|
|
249
277
|
withMore: FALLBACK_VISIBLE_COUNT
|
|
250
278
|
};
|
|
251
279
|
const rowHeight = gridHeight / weeks.length;
|
|
252
|
-
const fontSize = numericStyle(theme.text.eventTitle.fontSize, 12);
|
|
253
|
-
const chipRowHeight = numericStyle(theme.text.eventTitle.lineHeight, Math.ceil(fontSize * 1.3)) + CHIP_PADDING_V * 2 + CELL_ROW_GAP;
|
|
254
280
|
const moreFontSize = numericStyle(theme.text.more.fontSize, 11);
|
|
255
281
|
const moreRowHeight = Math.ceil(moreFontSize * 1.3) + CELL_ROW_GAP;
|
|
256
|
-
return monthEventCapacity(rowHeight - DAY_CELL_PADDING_TOP - DATE_BADGE_HEIGHT, chipRowHeight, moreRowHeight);
|
|
282
|
+
return monthEventCapacity(rowHeight - DAY_CELL_PADDING_TOP - DATE_BADGE_HEIGHT, chipMetrics.chipRowHeight, moreRowHeight);
|
|
257
283
|
}, [
|
|
258
284
|
maxVisibleEventCount,
|
|
259
285
|
gridHeight,
|
|
260
286
|
weeks.length,
|
|
261
|
-
theme
|
|
287
|
+
theme,
|
|
288
|
+
chipMetrics
|
|
262
289
|
]);
|
|
263
290
|
const eventsByDay = useMemo(() => {
|
|
264
291
|
const map = groupEventsByDay(events.filter((event) => !isBackgroundEvent(event)));
|
|
@@ -266,7 +293,12 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, hidd
|
|
|
266
293
|
return map;
|
|
267
294
|
}, [events, sortedMonthView]);
|
|
268
295
|
const showGrid = events.length > 0;
|
|
269
|
-
const
|
|
296
|
+
const weekLayouts = useMemo(() => showGrid ? weeks.map((week) => layoutMonthWeek(week, collectRowEvents(week, eventsByDay))) : [], [
|
|
297
|
+
showGrid,
|
|
298
|
+
weeks,
|
|
299
|
+
eventsByDay
|
|
300
|
+
]);
|
|
301
|
+
const renderDay = (day, dayCol, rowLayout, visibleLanes) => {
|
|
270
302
|
const isCurrentMonth = isSameMonth(day, date);
|
|
271
303
|
if (!isCurrentMonth && !showAdjacentMonths) return /* @__PURE__ */ jsx(View, { ...slot("day", {
|
|
272
304
|
base: styles$3.dayCell,
|
|
@@ -287,8 +319,7 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, hidd
|
|
|
287
319
|
maxDate,
|
|
288
320
|
isDateDisabled
|
|
289
321
|
});
|
|
290
|
-
const
|
|
291
|
-
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;
|
|
292
323
|
const isFilledBadge = dayBadgeKind({ isSelected }, isHighlighted) !== "none";
|
|
293
324
|
const hasBand = rangeBandKind({
|
|
294
325
|
isInRange,
|
|
@@ -393,16 +424,10 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, hidd
|
|
|
393
424
|
children: format(day, "d")
|
|
394
425
|
})
|
|
395
426
|
}),
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
mode: "month",
|
|
401
|
-
isAllDay: isAllDayEvent(event),
|
|
402
|
-
onPress: disableMonthEventCellPress ? () => {} : () => onPressEvent(event),
|
|
403
|
-
onLongPress: disableMonthEventCellPress || !onLongPressEvent ? void 0 : () => onLongPressEvent(event)
|
|
404
|
-
})
|
|
405
|
-
}, keyExtractor(event, index))),
|
|
427
|
+
Array.from({ length: visibleLanes }, (_, i) => /* @__PURE__ */ jsx(View, { style: {
|
|
428
|
+
height: chipMetrics.chipHeight,
|
|
429
|
+
pointerEvents: "none"
|
|
430
|
+
} }, `lane-${i}`)),
|
|
406
431
|
hiddenCount > 0 ? /* @__PURE__ */ jsx(Text, {
|
|
407
432
|
...slot("more", {
|
|
408
433
|
base: styles$3.moreLabel,
|
|
@@ -490,13 +515,52 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, hidd
|
|
|
490
515
|
/* @__PURE__ */ jsx(View, {
|
|
491
516
|
...slot("grid", { base: styles$3.container }),
|
|
492
517
|
onLayout: handleLayout,
|
|
493
|
-
children: weeks.map((week) =>
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
518
|
+
children: weeks.map((week, weekIndex) => {
|
|
519
|
+
const rowLayout = weekLayouts[weekIndex] ?? EMPTY_LAYOUT;
|
|
520
|
+
const visibleLanes = 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) => isSameMonth(d, date));
|
|
526
|
+
if (first !== -1) {
|
|
527
|
+
firstVisCol = first;
|
|
528
|
+
lastVisCol = cols - 1 - [...week].reverse().findIndex((d) => isSameMonth(d, date));
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
return /* @__PURE__ */ createElement(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__ */ jsx(View, {
|
|
538
|
+
style: [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__ */ jsx(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__ */ jsx(RenderEventComponent, {
|
|
554
|
+
event: seg.event,
|
|
555
|
+
mode: "month",
|
|
556
|
+
isAllDay: 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
|
+
})
|
|
500
564
|
})
|
|
501
565
|
]
|
|
502
566
|
});
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { A as PartialCalendarTheme, C as RenderEvent, D as WeekdayFormat, E as WeekStartsOn, M as defaultTheme, N as mergeTheme, O as CalendarTheme, P as useCalendarTheme, S as RecurrenceRule, T as TimeGridMode, _ as EventAccessibilityLabelContext, a as MonthPager, b as ICalendarEvent, c as MonthViewProps, d as SlotDefault, f as SlotStyleProps, g as CalendarMode, h as CalendarEvent, i as MonthListSlot, j as darkTheme, k as CalendarThemeProvider, l as MonthViewSlot, m as BusinessHoursBand, n as MonthList, o as MonthPagerProps, p as BusinessHours, r as MonthListProps, s as MonthView, t as DefaultMonthEvent, u as ResolvedSlot, v as EventAccessibilityLabeler, w as RenderEventArgs, x as RecurrenceFrequency, y as EventKeyExtractor } from "./DefaultMonthEvent-
|
|
1
|
+
import { A as PartialCalendarTheme, C as RenderEvent, D as WeekdayFormat, E as WeekStartsOn, M as defaultTheme, N as mergeTheme, O as CalendarTheme, P as useCalendarTheme, S as RecurrenceRule, T as TimeGridMode, _ as EventAccessibilityLabelContext, a as MonthPager, b as ICalendarEvent, c as MonthViewProps, d as SlotDefault, f as SlotStyleProps, g as CalendarMode, h as CalendarEvent, i as MonthListSlot, j as darkTheme, k as CalendarThemeProvider, l as MonthViewSlot, m as BusinessHoursBand, n as MonthList, o as MonthPagerProps, p as BusinessHours, r as MonthListProps, s as MonthView, t as DefaultMonthEvent, u as ResolvedSlot, v as EventAccessibilityLabeler, w as RenderEventArgs, x as RecurrenceFrequency, y as EventKeyExtractor } from "./DefaultMonthEvent-Cm9DsHBK.mjs";
|
|
2
2
|
import { Locale } from "date-fns";
|
|
3
3
|
import { ComponentType, ReactElement, ReactNode } from "react";
|
|
4
4
|
import { SharedValue, useSharedValue } from "react-native-reanimated";
|
|
5
|
-
import { BusinessHoursBand as BusinessHoursBand$1, BusinessHoursValue, CalendarEvent as CalendarEvent$1, DateRange, DateSelectionConstraints, DaySelectionState, EventAccessibilityLabeler as EventAccessibilityLabeler$1, ICalEvent, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, PositionedEvent, ToICalendarOptions, UseDateRangeOptions, UseMonthGridOptions, WeekdayFormat as WeekdayFormat$1, backgroundBandsForDay, buildMonthGrid, buildMonthWeeks, daySelectionState, eventsInTimeZone, expandRecurringEvents, getIsToday, getViewDays, getWeekDays, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, layoutDayEvents, minutesIntoDay, nextDateRange, parseICalendar, toICalendar, toZonedTime, useDateRange, useEventSource, useMonthGrid, useNow, weekdayFormatToken } from "@super-calendar/core";
|
|
5
|
+
import { BusinessHoursBand as BusinessHoursBand$1, BusinessHoursValue, CalendarEvent as CalendarEvent$1, DateRange, DateSelectionConstraints, DaySelectionState, EventAccessibilityLabeler as EventAccessibilityLabeler$1, ICalEvent, MonthEventSegment, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, MonthWeekEvents, PositionedEvent, ToICalendarOptions, UseDateRangeOptions, UseMonthGridOptions, WeekdayFormat as WeekdayFormat$1, backgroundBandsForDay, buildMonthGrid, buildMonthWeeks, daySelectionState, eventsInTimeZone, expandRecurringEvents, getIsToday, getViewDays, getWeekDays, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, layoutDayEvents, layoutMonthWeek, minutesIntoDay, nextDateRange, parseICalendar, toICalendar, toZonedTime, useDateRange, useEventSource, useMonthGrid, useNow, weekdayFormatToken } from "@super-calendar/core";
|
|
6
6
|
import { StyleProp, ViewStyle } from "react-native";
|
|
7
7
|
//#region src/components/YearView.d.ts
|
|
8
8
|
/**
|
|
@@ -201,6 +201,13 @@ type TimeGridProps<T> = SlotStyleProps<TimeGridSlot> & {
|
|
|
201
201
|
* drag-to-move and drag-to-resize working while hiding the visible indicator.
|
|
202
202
|
*/
|
|
203
203
|
showDragHandle?: boolean;
|
|
204
|
+
/** Allow moving events by default (per-event `startEditable` overrides). Default true. */
|
|
205
|
+
eventStartEditable?: boolean;
|
|
206
|
+
/** Allow resizing events by default (per-event `durationEditable` overrides). Default true. */
|
|
207
|
+
eventDurationEditable?: boolean;
|
|
208
|
+
/** Allow a dragged/resized event to overlap another (default true). Set false to
|
|
209
|
+
* reject a drop that would collide, snapping the event back. */
|
|
210
|
+
eventOverlap?: boolean;
|
|
204
211
|
onPressEvent: (event: CalendarEvent<T>) => void;
|
|
205
212
|
onLongPressEvent?: (event: CalendarEvent<T>) => void;
|
|
206
213
|
/**
|
|
@@ -219,7 +226,7 @@ type TimeGridProps<T> = SlotStyleProps<TimeGridSlot> & {
|
|
|
219
226
|
/** Optional header above the grid (e.g. weekday labels). Rendered full-width. */
|
|
220
227
|
renderHeader?: (days: Date[]) => React.ReactNode;
|
|
221
228
|
};
|
|
222
|
-
declare function TimeGridInner<T>({ mode, numberOfDays, weekEndsOn, date, events, cellHeight, hourHeight, weekStartsOn, weekdayFormat, renderEvent, eventAccessibilityLabel, keyExtractor, scrollOffsetMinutes, hourColumnWidth: hourColumnWidthProp, hideHours, timeslots, showAllDayEventCell, highlightWeekends, calendarCellStyle, businessHours, renderBusinessHours, showWeekNumber, headerComponent, minHour, maxHour, ampm, isRTL, minHourHeight, maxHourHeight, showNowIndicator, locale, freeSwipe, swipeEnabled, showVerticalScrollIndicator, verticalScrollEnabled, weekNumberPrefix, hiddenDays, now, timeZone, hourComponent, activeDate, resetPageOnPressCell, dragStepMinutes, showDragHandle, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, onPressCell, onLongPressCell, onCreateEvent, onPressDateHeader, onChangeDate, renderHeader, classNames, styles: styleOverrides }: TimeGridProps<T>): ReactElement;
|
|
229
|
+
declare function TimeGridInner<T>({ mode, numberOfDays, weekEndsOn, date, events, cellHeight, hourHeight, weekStartsOn, weekdayFormat, renderEvent, eventAccessibilityLabel, keyExtractor, scrollOffsetMinutes, hourColumnWidth: hourColumnWidthProp, hideHours, timeslots, showAllDayEventCell, highlightWeekends, calendarCellStyle, businessHours, renderBusinessHours, showWeekNumber, headerComponent, minHour, maxHour, ampm, isRTL, minHourHeight, maxHourHeight, showNowIndicator, locale, freeSwipe, swipeEnabled, showVerticalScrollIndicator, verticalScrollEnabled, weekNumberPrefix, hiddenDays, now, timeZone, hourComponent, activeDate, resetPageOnPressCell, dragStepMinutes, showDragHandle, eventStartEditable, eventDurationEditable, eventOverlap, onPressEvent, onLongPressEvent, onDragEvent: onDragEventProp, onDragStart, onPressCell, onLongPressCell, onCreateEvent, onPressDateHeader, onChangeDate, renderHeader, classNames, styles: styleOverrides }: TimeGridProps<T>): ReactElement;
|
|
223
230
|
/**
|
|
224
231
|
* The timetable view used in day, 3days, week, and custom modes: an
|
|
225
232
|
* hour-by-hour grid with positioned event boxes, an all-day lane, pinch-to-zoom
|
|
@@ -388,6 +395,12 @@ type CalendarProps<T> = SlotStyleProps<CalendarSlot> & {
|
|
|
388
395
|
showAllDayEventCell?: boolean;
|
|
389
396
|
/** Tint weekend columns (default true). Set false to treat weekends normally. */
|
|
390
397
|
highlightWeekends?: boolean;
|
|
398
|
+
/** Allow moving events by default (per-event `startEditable` overrides). Default true. */
|
|
399
|
+
eventStartEditable?: boolean;
|
|
400
|
+
/** Allow resizing events by default (per-event `durationEditable` overrides). Default true. */
|
|
401
|
+
eventDurationEditable?: boolean;
|
|
402
|
+
/** Reject drags/resizes that would overlap another event (default true = allowed). */
|
|
403
|
+
eventOverlap?: boolean;
|
|
391
404
|
/** Show the ISO week number in the week/day header gutter. Default false. */
|
|
392
405
|
showWeekNumber?: boolean;
|
|
393
406
|
/** Prefix for the week-number label (e.g. "W"). Default "W". */
|
|
@@ -481,7 +494,7 @@ type CalendarProps<T> = SlotStyleProps<CalendarSlot> & {
|
|
|
481
494
|
* }
|
|
482
495
|
* ```
|
|
483
496
|
*/
|
|
484
|
-
declare function Calendar<T>({ events, mode, date, onChangeDate, onChangeDateRange, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, dragStepMinutes, showDragHandle, onPressDay, onPressMonth, onLongPressDay, onPressMore, onPressCell, resetPageOnPressCell, onLongPressCell, onCreateEvent, onPressDateHeader, maxVisibleEventCount, sortedMonthView, moreLabel, showAdjacentMonths, disableMonthEventCellPress, weekStartsOn, hiddenDays, now, weekdayFormat, numberOfDays, weekEndsOn, renderEvent, eventAccessibilityLabel, eventCellStyle, calendarCellStyle, businessHours, renderBusinessHours, keyExtractor, theme, cellHeight: cellHeightProp, hourHeight, minHourHeight, maxHourHeight, hourColumnWidth, hideHours, timeslots, showAllDayEventCell, highlightWeekends, showWeekNumber, weekNumberPrefix, hourComponent, showSixWeeks, swipeEnabled, showVerticalScrollIndicator, verticalScrollEnabled, headerComponent, minHour, maxHour, ampm, showTime, ellipsizeTitle, allDayLabel, scrollOffsetMinutes, showNowIndicator, locale, timeZone, activeDate, isRTL, freeSwipe, renderTimeGridHeader, renderHeaderForMonthView, renderCustomDateForMonth, itemSeparatorComponent, classNames, styles: styleOverrides }: CalendarProps<T>): ReactElement;
|
|
497
|
+
declare function Calendar<T>({ events, mode, date, onChangeDate, onChangeDateRange, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, dragStepMinutes, showDragHandle, onPressDay, onPressMonth, onLongPressDay, onPressMore, onPressCell, resetPageOnPressCell, onLongPressCell, onCreateEvent, onPressDateHeader, maxVisibleEventCount, sortedMonthView, moreLabel, showAdjacentMonths, disableMonthEventCellPress, weekStartsOn, hiddenDays, now, weekdayFormat, numberOfDays, weekEndsOn, renderEvent, eventAccessibilityLabel, eventCellStyle, calendarCellStyle, businessHours, renderBusinessHours, keyExtractor, theme, cellHeight: cellHeightProp, hourHeight, minHourHeight, maxHourHeight, hourColumnWidth, hideHours, timeslots, showAllDayEventCell, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, showWeekNumber, weekNumberPrefix, hourComponent, showSixWeeks, swipeEnabled, showVerticalScrollIndicator, verticalScrollEnabled, headerComponent, minHour, maxHour, ampm, showTime, ellipsizeTitle, allDayLabel, scrollOffsetMinutes, showNowIndicator, locale, timeZone, activeDate, isRTL, freeSwipe, renderTimeGridHeader, renderHeaderForMonthView, renderCustomDateForMonth, itemSeparatorComponent, classNames, styles: styleOverrides }: CalendarProps<T>): ReactElement;
|
|
485
498
|
//#endregion
|
|
486
499
|
//#region src/components/DefaultEvent.d.ts
|
|
487
500
|
/**
|
|
@@ -603,6 +616,14 @@ interface ResourceTimelineProps<T = unknown> {
|
|
|
603
616
|
renderBusinessHours?: (band: BusinessHoursBand$1 & {
|
|
604
617
|
resource: Resource;
|
|
605
618
|
}) => ReactNode;
|
|
619
|
+
/**
|
|
620
|
+
* Render each resource's header cell yourself (an avatar, a subtitle, a status
|
|
621
|
+
* dot). Receives the resource and its index; return the cell's content. The board
|
|
622
|
+
* keeps the header cell's sizing so columns stay aligned, so this replaces only
|
|
623
|
+
* the label content. Falls back to the resource title (or id). Applies to both
|
|
624
|
+
* orientations: the top header cells when vertical, the row labels when horizontal.
|
|
625
|
+
*/
|
|
626
|
+
renderResourceHeader?: (resource: Resource, index: number) => ReactNode;
|
|
606
627
|
/** Snap dragged events to this many minutes (default 15). */
|
|
607
628
|
dragStepMinutes?: number;
|
|
608
629
|
/** Show the current-time line when `date` is today (default true). */
|
|
@@ -630,6 +651,6 @@ interface ResourceTimelineProps<T = unknown> {
|
|
|
630
651
|
* />
|
|
631
652
|
* ```
|
|
632
653
|
*/
|
|
633
|
-
declare function ResourceTimeline<T = unknown>({ date, orientation, resources: allResources, resourcesPerPage, resourcePage, events, resourceId, startHour, endHour, hourWidth, hourHeight, rowHeight, labelWidth, ampm, renderEvent, onPressEvent, onLongPressEvent, onDragEvent, onPressCell, onLongPressCell, onCreateEvent, businessHours, renderBusinessHours, dragStepMinutes, showNowIndicator, now: nowProp, timeZone }: ResourceTimelineProps<T>): ReactElement;
|
|
654
|
+
declare function ResourceTimeline<T = unknown>({ date, orientation, resources: allResources, resourcesPerPage, resourcePage, events, resourceId, startHour, endHour, hourWidth, hourHeight, rowHeight, labelWidth, ampm, renderEvent, onPressEvent, onLongPressEvent, onDragEvent, onPressCell, onLongPressCell, onCreateEvent, businessHours, renderBusinessHours, renderResourceHeader, dragStepMinutes, showNowIndicator, now: nowProp, timeZone }: ResourceTimelineProps<T>): ReactElement;
|
|
634
655
|
//#endregion
|
|
635
|
-
export { Agenda, type AgendaProps, type AgendaSlot, type BusinessHours, type BusinessHoursBand, Calendar, type CalendarEvent, type CalendarMode, type CalendarProps, type CalendarSlot, type CalendarTheme, CalendarThemeProvider, DEFAULT_HOUR_HEIGHT, type DateRange, type DateSelectionConstraints, type DaySelectionState, DefaultEvent, DefaultMonthEvent, type EventAccessibilityLabelContext, type EventAccessibilityLabeler, type EventDragHandler, type EventDragStartHandler, type EventKeyExtractor, type HourRenderer, type ICalEvent, type ICalendarEvent, type MonthGrid, type MonthGridDay, type MonthGridWeek, type MonthGridWeekday, MonthList, type MonthListProps, type MonthListSlot, MonthPager, type MonthPagerProps, MonthView, type MonthViewProps, type MonthViewSlot, type PartialCalendarTheme, type PositionedEvent, type RecurrenceFrequency, type RecurrenceRule, type RenderEvent, type RenderEventArgs, type ResolvedSlot, type Resource, type ResourceEventArgs, ResourceTimeline, type ResourceTimelineProps, type SlotDefault, type SlotStyleProps, TimeGrid, type TimeGridMode, type TimeGridProps, type TimeGridSlot, type ToICalendarOptions, type UseDateRangeOptions, type UseMonthGridOptions, type WeekStartsOn, type WeekdayFormat, YearView, type YearViewProps, type YearViewSlot, backgroundBandsForDay, buildMonthGrid, buildMonthWeeks, darkTheme, daySelectionState, defaultTheme, eventsInTimeZone, expandRecurringEvents, getIsToday, getViewDays, getWeekDays, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, layoutDayEvents, mergeTheme, minutesIntoDay, nextDateRange, parseICalendar, toICalendar, toZonedTime, useCalendarTheme, useDateRange, useEventSource, useMonthGrid, useNow, weekdayFormatToken };
|
|
656
|
+
export { Agenda, type AgendaProps, type AgendaSlot, type BusinessHours, type BusinessHoursBand, Calendar, type CalendarEvent, type CalendarMode, type CalendarProps, type CalendarSlot, type CalendarTheme, CalendarThemeProvider, DEFAULT_HOUR_HEIGHT, type DateRange, type DateSelectionConstraints, type DaySelectionState, DefaultEvent, DefaultMonthEvent, type EventAccessibilityLabelContext, type EventAccessibilityLabeler, type EventDragHandler, type EventDragStartHandler, type EventKeyExtractor, type HourRenderer, type ICalEvent, type ICalendarEvent, type MonthEventSegment, type MonthGrid, type MonthGridDay, type MonthGridWeek, type MonthGridWeekday, MonthList, type MonthListProps, type MonthListSlot, MonthPager, type MonthPagerProps, MonthView, type MonthViewProps, type MonthViewSlot, type MonthWeekEvents, type PartialCalendarTheme, type PositionedEvent, type RecurrenceFrequency, type RecurrenceRule, type RenderEvent, type RenderEventArgs, type ResolvedSlot, type Resource, type ResourceEventArgs, ResourceTimeline, type ResourceTimelineProps, type SlotDefault, type SlotStyleProps, TimeGrid, type TimeGridMode, type TimeGridProps, type TimeGridSlot, type ToICalendarOptions, type UseDateRangeOptions, type UseMonthGridOptions, type WeekStartsOn, type WeekdayFormat, YearView, type YearViewProps, type YearViewSlot, backgroundBandsForDay, buildMonthGrid, buildMonthWeeks, darkTheme, daySelectionState, defaultTheme, eventsInTimeZone, expandRecurringEvents, getIsToday, getViewDays, getWeekDays, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, layoutDayEvents, layoutMonthWeek, mergeTheme, minutesIntoDay, nextDateRange, parseICalendar, toICalendar, toZonedTime, useCalendarTheme, useDateRange, useEventSource, useMonthGrid, useNow, weekdayFormatToken };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { A as PartialCalendarTheme, C as RenderEvent, D as WeekdayFormat, E as WeekStartsOn, M as defaultTheme, N as mergeTheme, O as CalendarTheme, P as useCalendarTheme, S as RecurrenceRule, T as TimeGridMode, _ as EventAccessibilityLabelContext, a as MonthPager, b as ICalendarEvent, c as MonthViewProps, d as SlotDefault, f as SlotStyleProps, g as CalendarMode, h as CalendarEvent, i as MonthListSlot, j as darkTheme, k as CalendarThemeProvider, l as MonthViewSlot, m as BusinessHoursBand, n as MonthList, o as MonthPagerProps, p as BusinessHours, r as MonthListProps, s as MonthView, t as DefaultMonthEvent, u as ResolvedSlot, v as EventAccessibilityLabeler, w as RenderEventArgs, x as RecurrenceFrequency, y as EventKeyExtractor } from "./DefaultMonthEvent-
|
|
1
|
+
import { A as PartialCalendarTheme, C as RenderEvent, D as WeekdayFormat, E as WeekStartsOn, M as defaultTheme, N as mergeTheme, O as CalendarTheme, P as useCalendarTheme, S as RecurrenceRule, T as TimeGridMode, _ as EventAccessibilityLabelContext, a as MonthPager, b as ICalendarEvent, c as MonthViewProps, d as SlotDefault, f as SlotStyleProps, g as CalendarMode, h as CalendarEvent, i as MonthListSlot, j as darkTheme, k as CalendarThemeProvider, l as MonthViewSlot, m as BusinessHoursBand, n as MonthList, o as MonthPagerProps, p as BusinessHours, r as MonthListProps, s as MonthView, t as DefaultMonthEvent, u as ResolvedSlot, v as EventAccessibilityLabeler, w as RenderEventArgs, x as RecurrenceFrequency, y as EventKeyExtractor } from "./DefaultMonthEvent-DAxZjk_D.js";
|
|
2
2
|
import { Locale } from "date-fns";
|
|
3
3
|
import { ComponentType, ReactElement, ReactNode } from "react";
|
|
4
4
|
import { StyleProp, ViewStyle } from "react-native";
|
|
5
5
|
import { SharedValue, useSharedValue } from "react-native-reanimated";
|
|
6
|
-
import { BusinessHoursBand as BusinessHoursBand$1, BusinessHoursValue, CalendarEvent as CalendarEvent$1, DateRange, DateSelectionConstraints, DaySelectionState, EventAccessibilityLabeler as EventAccessibilityLabeler$1, ICalEvent, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, PositionedEvent, ToICalendarOptions, UseDateRangeOptions, UseMonthGridOptions, WeekdayFormat as WeekdayFormat$1, backgroundBandsForDay, buildMonthGrid, buildMonthWeeks, daySelectionState, eventsInTimeZone, expandRecurringEvents, getIsToday, getViewDays, getWeekDays, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, layoutDayEvents, minutesIntoDay, nextDateRange, parseICalendar, toICalendar, toZonedTime, useDateRange, useEventSource, useMonthGrid, useNow, weekdayFormatToken } from "@super-calendar/core";
|
|
6
|
+
import { BusinessHoursBand as BusinessHoursBand$1, BusinessHoursValue, CalendarEvent as CalendarEvent$1, DateRange, DateSelectionConstraints, DaySelectionState, EventAccessibilityLabeler as EventAccessibilityLabeler$1, ICalEvent, MonthEventSegment, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, MonthWeekEvents, PositionedEvent, ToICalendarOptions, UseDateRangeOptions, UseMonthGridOptions, WeekdayFormat as WeekdayFormat$1, backgroundBandsForDay, buildMonthGrid, buildMonthWeeks, daySelectionState, eventsInTimeZone, expandRecurringEvents, getIsToday, getViewDays, getWeekDays, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, layoutDayEvents, layoutMonthWeek, minutesIntoDay, nextDateRange, parseICalendar, toICalendar, toZonedTime, useDateRange, useEventSource, useMonthGrid, useNow, weekdayFormatToken } from "@super-calendar/core";
|
|
7
7
|
//#region src/components/YearView.d.ts
|
|
8
8
|
/**
|
|
9
9
|
* The styleable parts of {@link YearView}. `dayText` and `eventDot` are the
|
|
@@ -201,6 +201,13 @@ type TimeGridProps<T> = SlotStyleProps<TimeGridSlot> & {
|
|
|
201
201
|
* drag-to-move and drag-to-resize working while hiding the visible indicator.
|
|
202
202
|
*/
|
|
203
203
|
showDragHandle?: boolean;
|
|
204
|
+
/** Allow moving events by default (per-event `startEditable` overrides). Default true. */
|
|
205
|
+
eventStartEditable?: boolean;
|
|
206
|
+
/** Allow resizing events by default (per-event `durationEditable` overrides). Default true. */
|
|
207
|
+
eventDurationEditable?: boolean;
|
|
208
|
+
/** Allow a dragged/resized event to overlap another (default true). Set false to
|
|
209
|
+
* reject a drop that would collide, snapping the event back. */
|
|
210
|
+
eventOverlap?: boolean;
|
|
204
211
|
onPressEvent: (event: CalendarEvent<T>) => void;
|
|
205
212
|
onLongPressEvent?: (event: CalendarEvent<T>) => void;
|
|
206
213
|
/**
|
|
@@ -219,7 +226,7 @@ type TimeGridProps<T> = SlotStyleProps<TimeGridSlot> & {
|
|
|
219
226
|
/** Optional header above the grid (e.g. weekday labels). Rendered full-width. */
|
|
220
227
|
renderHeader?: (days: Date[]) => React.ReactNode;
|
|
221
228
|
};
|
|
222
|
-
declare function TimeGridInner<T>({ mode, numberOfDays, weekEndsOn, date, events, cellHeight, hourHeight, weekStartsOn, weekdayFormat, renderEvent, eventAccessibilityLabel, keyExtractor, scrollOffsetMinutes, hourColumnWidth: hourColumnWidthProp, hideHours, timeslots, showAllDayEventCell, highlightWeekends, calendarCellStyle, businessHours, renderBusinessHours, showWeekNumber, headerComponent, minHour, maxHour, ampm, isRTL, minHourHeight, maxHourHeight, showNowIndicator, locale, freeSwipe, swipeEnabled, showVerticalScrollIndicator, verticalScrollEnabled, weekNumberPrefix, hiddenDays, now, timeZone, hourComponent, activeDate, resetPageOnPressCell, dragStepMinutes, showDragHandle, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, onPressCell, onLongPressCell, onCreateEvent, onPressDateHeader, onChangeDate, renderHeader, classNames, styles: styleOverrides }: TimeGridProps<T>): ReactElement;
|
|
229
|
+
declare function TimeGridInner<T>({ mode, numberOfDays, weekEndsOn, date, events, cellHeight, hourHeight, weekStartsOn, weekdayFormat, renderEvent, eventAccessibilityLabel, keyExtractor, scrollOffsetMinutes, hourColumnWidth: hourColumnWidthProp, hideHours, timeslots, showAllDayEventCell, highlightWeekends, calendarCellStyle, businessHours, renderBusinessHours, showWeekNumber, headerComponent, minHour, maxHour, ampm, isRTL, minHourHeight, maxHourHeight, showNowIndicator, locale, freeSwipe, swipeEnabled, showVerticalScrollIndicator, verticalScrollEnabled, weekNumberPrefix, hiddenDays, now, timeZone, hourComponent, activeDate, resetPageOnPressCell, dragStepMinutes, showDragHandle, eventStartEditable, eventDurationEditable, eventOverlap, onPressEvent, onLongPressEvent, onDragEvent: onDragEventProp, onDragStart, onPressCell, onLongPressCell, onCreateEvent, onPressDateHeader, onChangeDate, renderHeader, classNames, styles: styleOverrides }: TimeGridProps<T>): ReactElement;
|
|
223
230
|
/**
|
|
224
231
|
* The timetable view used in day, 3days, week, and custom modes: an
|
|
225
232
|
* hour-by-hour grid with positioned event boxes, an all-day lane, pinch-to-zoom
|
|
@@ -388,6 +395,12 @@ type CalendarProps<T> = SlotStyleProps<CalendarSlot> & {
|
|
|
388
395
|
showAllDayEventCell?: boolean;
|
|
389
396
|
/** Tint weekend columns (default true). Set false to treat weekends normally. */
|
|
390
397
|
highlightWeekends?: boolean;
|
|
398
|
+
/** Allow moving events by default (per-event `startEditable` overrides). Default true. */
|
|
399
|
+
eventStartEditable?: boolean;
|
|
400
|
+
/** Allow resizing events by default (per-event `durationEditable` overrides). Default true. */
|
|
401
|
+
eventDurationEditable?: boolean;
|
|
402
|
+
/** Reject drags/resizes that would overlap another event (default true = allowed). */
|
|
403
|
+
eventOverlap?: boolean;
|
|
391
404
|
/** Show the ISO week number in the week/day header gutter. Default false. */
|
|
392
405
|
showWeekNumber?: boolean;
|
|
393
406
|
/** Prefix for the week-number label (e.g. "W"). Default "W". */
|
|
@@ -481,7 +494,7 @@ type CalendarProps<T> = SlotStyleProps<CalendarSlot> & {
|
|
|
481
494
|
* }
|
|
482
495
|
* ```
|
|
483
496
|
*/
|
|
484
|
-
declare function Calendar<T>({ events, mode, date, onChangeDate, onChangeDateRange, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, dragStepMinutes, showDragHandle, onPressDay, onPressMonth, onLongPressDay, onPressMore, onPressCell, resetPageOnPressCell, onLongPressCell, onCreateEvent, onPressDateHeader, maxVisibleEventCount, sortedMonthView, moreLabel, showAdjacentMonths, disableMonthEventCellPress, weekStartsOn, hiddenDays, now, weekdayFormat, numberOfDays, weekEndsOn, renderEvent, eventAccessibilityLabel, eventCellStyle, calendarCellStyle, businessHours, renderBusinessHours, keyExtractor, theme, cellHeight: cellHeightProp, hourHeight, minHourHeight, maxHourHeight, hourColumnWidth, hideHours, timeslots, showAllDayEventCell, highlightWeekends, showWeekNumber, weekNumberPrefix, hourComponent, showSixWeeks, swipeEnabled, showVerticalScrollIndicator, verticalScrollEnabled, headerComponent, minHour, maxHour, ampm, showTime, ellipsizeTitle, allDayLabel, scrollOffsetMinutes, showNowIndicator, locale, timeZone, activeDate, isRTL, freeSwipe, renderTimeGridHeader, renderHeaderForMonthView, renderCustomDateForMonth, itemSeparatorComponent, classNames, styles: styleOverrides }: CalendarProps<T>): ReactElement;
|
|
497
|
+
declare function Calendar<T>({ events, mode, date, onChangeDate, onChangeDateRange, onPressEvent, onLongPressEvent, onDragEvent, onDragStart, dragStepMinutes, showDragHandle, onPressDay, onPressMonth, onLongPressDay, onPressMore, onPressCell, resetPageOnPressCell, onLongPressCell, onCreateEvent, onPressDateHeader, maxVisibleEventCount, sortedMonthView, moreLabel, showAdjacentMonths, disableMonthEventCellPress, weekStartsOn, hiddenDays, now, weekdayFormat, numberOfDays, weekEndsOn, renderEvent, eventAccessibilityLabel, eventCellStyle, calendarCellStyle, businessHours, renderBusinessHours, keyExtractor, theme, cellHeight: cellHeightProp, hourHeight, minHourHeight, maxHourHeight, hourColumnWidth, hideHours, timeslots, showAllDayEventCell, highlightWeekends, eventStartEditable, eventDurationEditable, eventOverlap, showWeekNumber, weekNumberPrefix, hourComponent, showSixWeeks, swipeEnabled, showVerticalScrollIndicator, verticalScrollEnabled, headerComponent, minHour, maxHour, ampm, showTime, ellipsizeTitle, allDayLabel, scrollOffsetMinutes, showNowIndicator, locale, timeZone, activeDate, isRTL, freeSwipe, renderTimeGridHeader, renderHeaderForMonthView, renderCustomDateForMonth, itemSeparatorComponent, classNames, styles: styleOverrides }: CalendarProps<T>): ReactElement;
|
|
485
498
|
//#endregion
|
|
486
499
|
//#region src/components/DefaultEvent.d.ts
|
|
487
500
|
/**
|
|
@@ -603,6 +616,14 @@ interface ResourceTimelineProps<T = unknown> {
|
|
|
603
616
|
renderBusinessHours?: (band: BusinessHoursBand$1 & {
|
|
604
617
|
resource: Resource;
|
|
605
618
|
}) => ReactNode;
|
|
619
|
+
/**
|
|
620
|
+
* Render each resource's header cell yourself (an avatar, a subtitle, a status
|
|
621
|
+
* dot). Receives the resource and its index; return the cell's content. The board
|
|
622
|
+
* keeps the header cell's sizing so columns stay aligned, so this replaces only
|
|
623
|
+
* the label content. Falls back to the resource title (or id). Applies to both
|
|
624
|
+
* orientations: the top header cells when vertical, the row labels when horizontal.
|
|
625
|
+
*/
|
|
626
|
+
renderResourceHeader?: (resource: Resource, index: number) => ReactNode;
|
|
606
627
|
/** Snap dragged events to this many minutes (default 15). */
|
|
607
628
|
dragStepMinutes?: number;
|
|
608
629
|
/** Show the current-time line when `date` is today (default true). */
|
|
@@ -630,6 +651,6 @@ interface ResourceTimelineProps<T = unknown> {
|
|
|
630
651
|
* />
|
|
631
652
|
* ```
|
|
632
653
|
*/
|
|
633
|
-
declare function ResourceTimeline<T = unknown>({ date, orientation, resources: allResources, resourcesPerPage, resourcePage, events, resourceId, startHour, endHour, hourWidth, hourHeight, rowHeight, labelWidth, ampm, renderEvent, onPressEvent, onLongPressEvent, onDragEvent, onPressCell, onLongPressCell, onCreateEvent, businessHours, renderBusinessHours, dragStepMinutes, showNowIndicator, now: nowProp, timeZone }: ResourceTimelineProps<T>): ReactElement;
|
|
654
|
+
declare function ResourceTimeline<T = unknown>({ date, orientation, resources: allResources, resourcesPerPage, resourcePage, events, resourceId, startHour, endHour, hourWidth, hourHeight, rowHeight, labelWidth, ampm, renderEvent, onPressEvent, onLongPressEvent, onDragEvent, onPressCell, onLongPressCell, onCreateEvent, businessHours, renderBusinessHours, renderResourceHeader, dragStepMinutes, showNowIndicator, now: nowProp, timeZone }: ResourceTimelineProps<T>): ReactElement;
|
|
634
655
|
//#endregion
|
|
635
|
-
export { Agenda, type AgendaProps, type AgendaSlot, type BusinessHours, type BusinessHoursBand, Calendar, type CalendarEvent, type CalendarMode, type CalendarProps, type CalendarSlot, type CalendarTheme, CalendarThemeProvider, DEFAULT_HOUR_HEIGHT, type DateRange, type DateSelectionConstraints, type DaySelectionState, DefaultEvent, DefaultMonthEvent, type EventAccessibilityLabelContext, type EventAccessibilityLabeler, type EventDragHandler, type EventDragStartHandler, type EventKeyExtractor, type HourRenderer, type ICalEvent, type ICalendarEvent, type MonthGrid, type MonthGridDay, type MonthGridWeek, type MonthGridWeekday, MonthList, type MonthListProps, type MonthListSlot, MonthPager, type MonthPagerProps, MonthView, type MonthViewProps, type MonthViewSlot, type PartialCalendarTheme, type PositionedEvent, type RecurrenceFrequency, type RecurrenceRule, type RenderEvent, type RenderEventArgs, type ResolvedSlot, type Resource, type ResourceEventArgs, ResourceTimeline, type ResourceTimelineProps, type SlotDefault, type SlotStyleProps, TimeGrid, type TimeGridMode, type TimeGridProps, type TimeGridSlot, type ToICalendarOptions, type UseDateRangeOptions, type UseMonthGridOptions, type WeekStartsOn, type WeekdayFormat, YearView, type YearViewProps, type YearViewSlot, backgroundBandsForDay, buildMonthGrid, buildMonthWeeks, darkTheme, daySelectionState, defaultTheme, eventsInTimeZone, expandRecurringEvents, getIsToday, getViewDays, getWeekDays, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, layoutDayEvents, mergeTheme, minutesIntoDay, nextDateRange, parseICalendar, toICalendar, toZonedTime, useCalendarTheme, useDateRange, useEventSource, useMonthGrid, useNow, weekdayFormatToken };
|
|
656
|
+
export { Agenda, type AgendaProps, type AgendaSlot, type BusinessHours, type BusinessHoursBand, Calendar, type CalendarEvent, type CalendarMode, type CalendarProps, type CalendarSlot, type CalendarTheme, CalendarThemeProvider, DEFAULT_HOUR_HEIGHT, type DateRange, type DateSelectionConstraints, type DaySelectionState, DefaultEvent, DefaultMonthEvent, type EventAccessibilityLabelContext, type EventAccessibilityLabeler, type EventDragHandler, type EventDragStartHandler, type EventKeyExtractor, type HourRenderer, type ICalEvent, type ICalendarEvent, type MonthEventSegment, type MonthGrid, type MonthGridDay, type MonthGridWeek, type MonthGridWeekday, MonthList, type MonthListProps, type MonthListSlot, MonthPager, type MonthPagerProps, MonthView, type MonthViewProps, type MonthViewSlot, type MonthWeekEvents, type PartialCalendarTheme, type PositionedEvent, type RecurrenceFrequency, type RecurrenceRule, type RenderEvent, type RenderEventArgs, type ResolvedSlot, type Resource, type ResourceEventArgs, ResourceTimeline, type ResourceTimelineProps, type SlotDefault, type SlotStyleProps, TimeGrid, type TimeGridMode, type TimeGridProps, type TimeGridSlot, type ToICalendarOptions, type UseDateRangeOptions, type UseMonthGridOptions, type WeekStartsOn, type WeekdayFormat, YearView, type YearViewProps, type YearViewSlot, backgroundBandsForDay, buildMonthGrid, buildMonthWeeks, darkTheme, daySelectionState, defaultTheme, eventsInTimeZone, expandRecurringEvents, getIsToday, getViewDays, getWeekDays, isAllDayEvent, isBackgroundEvent, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, layoutDayEvents, layoutMonthWeek, mergeTheme, minutesIntoDay, nextDateRange, parseICalendar, toICalendar, toZonedTime, useCalendarTheme, useDateRange, useEventSource, useMonthGrid, useNow, weekdayFormatToken };
|