@super-calendar/native 2.17.0 → 2.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,6 +12,15 @@ The React Native renderer for [super-calendar](https://github.com/afonsojramos/s
12
12
  - 🪝 Headless `useMonthGrid` and `useDateRange` for fully custom UIs
13
13
  - 🎨 Themeable, with a `darkTheme` preset
14
14
 
15
+ ## All-day spans
16
+
17
+ In the time grid, an all-day event renders once as a bar across the visible
18
+ dates it covers. Overlapping events stack on separate rows. The end is
19
+ exclusive, and hidden days take no width. `renderEvent` and press callbacks
20
+ receive the original event; `continuesBefore` and `continuesAfter` indicate
21
+ clipping at the visible range edges. The `allDayColumn` slot styles one
22
+ spanning cell. Timed events that cross midnight keep their per-day segments.
23
+
15
24
  ## Install
16
25
 
17
26
  ```sh
@@ -141,6 +150,17 @@ passes the lane's `resource`. The preview geometry stays on the UI thread, and
141
150
  the content is clipped to it and hidden from screen readers.
142
151
  A cancelled gesture clears the preview without calling `onCreateEvent`.
143
152
 
153
+ `MonthView`, `MultiWeekView`, `MonthPager`, and `Calendar` in `month` or
154
+ `multiweek` mode also accept `renderCreateGhost`. These views pass the full
155
+ all-day range, with an exclusive end, and render one copy per covered week row.
156
+ Use date labels rather than times for this content. The preview updates when
157
+ the sweep reaches another day, uses `chipHeight`, `chipGap`, and the
158
+ `createGhost` slot, and overlays a visible event lane without changing the row
159
+ height. Content is clipped, ignores pointer input, and is hidden from screen
160
+ readers. On React Native Web, it also stays out of the tab order. Both the renderer and `onCreateEvent` are required; together they also
161
+ show the event-grid layout in an empty month. Omitting the renderer preserves
162
+ the existing day highlight.
163
+
144
164
  ## Styling with Tailwind
145
165
 
146
166
  Every styleable part is a named slot that accepts a class (resolved by a Tailwind runtime such as [uniwind](https://docs.uniwind.dev) or NativeWind) and/or a style override. A classed slot drops its built-in themed styles, so your classes own the look:
@@ -1,8 +1,8 @@
1
1
  import { Locale } from "date-fns";
2
2
  import { ComponentType, ReactElement, ReactNode } from "react";
3
- import { SharedValue } from "react-native-reanimated";
4
- import { BusinessHours, BusinessHoursBand as BusinessHoursBand$1, CalendarColors, CalendarEvent, CalendarEvent as CalendarEvent$1, CalendarHandle as CalendarHandle$1, CalendarLabels, CalendarMode, CalendarMode as CalendarMode$1, CreateGhostArgs as CreateGhostArgs$1, DateRange, EventAccessibilityLabelContext, EventAccessibilityLabeler, EventAccessibilityLabeler as EventAccessibilityLabeler$1, EventKeyExtractor, ICalendarEvent, RecurrenceFrequency, RecurrenceRule, ScrollToTimeOptions, TimeGridMode, WeekStartsOn as WeekStartsOn$1, WeekdayFormat, WeekdayFormat as WeekdayFormat$1 } from "@super-calendar/core";
5
3
  import { AccessibilityActionEvent, AccessibilityActionInfo, ImageStyle, 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, CalendarHandle as CalendarHandle$1, CalendarLabels, CalendarMode, CalendarMode as CalendarMode$1, CreateGhostArgs, CreateGhostArgs as CreateGhostArgs$1, DateRange, EventAccessibilityLabelContext, EventAccessibilityLabeler, EventAccessibilityLabeler as EventAccessibilityLabeler$1, EventKeyExtractor, ICalendarEvent, RecurrenceFrequency, RecurrenceRule, ScrollToTimeOptions, TimeGridMode, WeekStartsOn as WeekStartsOn$1, WeekdayFormat, WeekdayFormat as WeekdayFormat$1 } from "@super-calendar/core";
6
6
  /**
7
7
  * The full set of colours, text styles and metrics the calendar paints with.
8
8
  * Supply a `Partial<CalendarTheme>` to `<Calendar theme={...} />`; missing keys
@@ -137,8 +137,8 @@ type RenderEventArgs<T = unknown> = {
137
137
  boxHeight?: SharedValue<number>;
138
138
  /**
139
139
  * On the week/day grid, true when this is a clipped segment of a multi-day
140
- * event that started on an earlier day / continues onto a later day. Lets a
141
- * renderer draw "continues" affordances. `undefined` in month mode.
140
+ * timed event. For an all-day bar, these flags refer to the visible date
141
+ * range instead. Lets a renderer draw "continues" affordances.
142
142
  */
143
143
  continuesBefore?: boolean;
144
144
  continuesAfter?: boolean;
@@ -223,7 +223,7 @@ interface ResolvedSlot<Style extends SlotStyle = ViewStyle> {
223
223
  * Native text colour doesn't inherit from the badge). Event chips are styled
224
224
  * by `renderEvent` (or the theme), not a slot.
225
225
  */
226
- type MonthViewSlot = "title" | "weekdays" | "weekday" | "grid" | "week" | "day" | "dayBadge" | "dayBadgeText" | "rangeBand" | "more" | "morePopover";
226
+ type MonthViewSlot = "title" | "weekdays" | "weekday" | "grid" | "week" | "day" | "dayBadge" | "dayBadgeText" | "rangeBand" | "createGhost" | "more" | "morePopover";
227
227
  /** Props for {@link MonthView}, the single-month grid. */
228
228
  type MonthViewProps<T> = SlotStyleProps<MonthViewSlot> & {
229
229
  date: Date;
@@ -248,6 +248,13 @@ type MonthViewProps<T> = SlotStyleProps<MonthViewSlot> & {
248
248
  /** Weekday header label width: `narrow` ("M"), `short` ("Mon", default), or `long` ("Monday"). */
249
249
  weekdayFormat?: WeekdayFormat;
250
250
  locale?: Locale;
251
+ /**
252
+ * The instant whose calendar day is highlighted as today. Defaults to the
253
+ * device clock, and is read in `timeZone` when one is set.
254
+ */
255
+ now?: Date;
256
+ /** Highlight today as it is in this IANA time zone (default: the device's). */
257
+ timeZone?: string;
251
258
  /** Sort each day's events by start time before slicing. Default true. */
252
259
  sortedMonthView?: boolean;
253
260
  /** Template for the overflow label; `{moreCount}` is replaced. Default "{moreCount} More". */
@@ -317,6 +324,14 @@ type MonthViewProps<T> = SlotStyleProps<MonthViewSlot> & {
317
324
  * plain tap fires `onPressDay`/`onPressCell` instead.
318
325
  */
319
326
  onCreateEvent?: (start: Date, end: Date) => void;
327
+ /**
328
+ * Content inside the drag-to-create preview. Receives the full all-day range,
329
+ * with an exclusive end, that `onCreateEvent` would receive on release. A span
330
+ * crossing rows renders the component once per row with the same range.
331
+ * Requires `onCreateEvent`; content is clipped, noninteractive, and hidden
332
+ * from screen readers. Omit to keep the day highlight without preview content.
333
+ */
334
+ renderCreateGhost?: ComponentType<CreateGhostArgs>;
320
335
  /**
321
336
  * Reports the day span of a create sweep **as it happens**, as the ordered
322
337
  * inclusive `[start, end]` days (both at midnight), so a selection highlight can
@@ -380,6 +395,8 @@ type MonthPagerProps<T> = {
380
395
  hiddenDays?: number[];
381
396
  weekdayFormat?: WeekdayFormat;
382
397
  locale?: Locale;
398
+ now?: Date;
399
+ timeZone?: string;
383
400
  sortedMonthView?: boolean;
384
401
  moreLabel?: string;
385
402
  /** Translations for the screen-reader words and gutter text; omitted keys use English. */
@@ -400,6 +417,8 @@ type MonthPagerProps<T> = {
400
417
  onPressMore?: (events: CalendarEvent$1<T>[], date: Date) => void;
401
418
  /** Drag across empty day cells to sweep out an all-day span for a new event. */
402
419
  onCreateEvent?: (start: Date, end: Date) => void;
420
+ /** Content for each row of the live creation preview; requires `onCreateEvent`. */
421
+ renderCreateGhost?: ComponentType<CreateGhostArgs>;
403
422
  /** Drag-to-select: reports the swept `[start, end]` days live. */
404
423
  onSelectDrag?: (start: Date, end: Date) => void;
405
424
  /** Days drawn as selected (a filled badge). */
@@ -1,8 +1,8 @@
1
1
  import { Locale } from "date-fns";
2
2
  import { ComponentType, ReactElement, ReactNode } from "react";
3
- import { AccessibilityActionEvent, AccessibilityActionInfo, ImageStyle, StyleProp, TextStyle, ViewStyle } from "react-native";
4
3
  import { SharedValue } from "react-native-reanimated";
5
- import { BusinessHours, BusinessHoursBand as BusinessHoursBand$1, CalendarColors, CalendarEvent, CalendarEvent as CalendarEvent$1, CalendarHandle as CalendarHandle$1, CalendarLabels, CalendarMode, CalendarMode as CalendarMode$1, CreateGhostArgs as CreateGhostArgs$1, DateRange, EventAccessibilityLabelContext, EventAccessibilityLabeler, EventAccessibilityLabeler as EventAccessibilityLabeler$1, EventKeyExtractor, ICalendarEvent, RecurrenceFrequency, RecurrenceRule, ScrollToTimeOptions, TimeGridMode, WeekStartsOn as WeekStartsOn$1, WeekdayFormat, WeekdayFormat as WeekdayFormat$1 } from "@super-calendar/core";
4
+ import { BusinessHours, BusinessHoursBand as BusinessHoursBand$1, CalendarColors, CalendarEvent, CalendarEvent as CalendarEvent$1, CalendarHandle as CalendarHandle$1, CalendarLabels, CalendarMode, CalendarMode as CalendarMode$1, CreateGhostArgs, CreateGhostArgs as CreateGhostArgs$1, DateRange, EventAccessibilityLabelContext, EventAccessibilityLabeler, EventAccessibilityLabeler as EventAccessibilityLabeler$1, EventKeyExtractor, ICalendarEvent, RecurrenceFrequency, RecurrenceRule, ScrollToTimeOptions, TimeGridMode, WeekStartsOn as WeekStartsOn$1, WeekdayFormat, WeekdayFormat as WeekdayFormat$1 } from "@super-calendar/core";
5
+ import { AccessibilityActionEvent, AccessibilityActionInfo, ImageStyle, StyleProp, TextStyle, ViewStyle } from "react-native";
6
6
  /**
7
7
  * The full set of colours, text styles and metrics the calendar paints with.
8
8
  * Supply a `Partial<CalendarTheme>` to `<Calendar theme={...} />`; missing keys
@@ -137,8 +137,8 @@ type RenderEventArgs<T = unknown> = {
137
137
  boxHeight?: SharedValue<number>;
138
138
  /**
139
139
  * On the week/day grid, true when this is a clipped segment of a multi-day
140
- * event that started on an earlier day / continues onto a later day. Lets a
141
- * renderer draw "continues" affordances. `undefined` in month mode.
140
+ * timed event. For an all-day bar, these flags refer to the visible date
141
+ * range instead. Lets a renderer draw "continues" affordances.
142
142
  */
143
143
  continuesBefore?: boolean;
144
144
  continuesAfter?: boolean;
@@ -223,7 +223,7 @@ interface ResolvedSlot<Style extends SlotStyle = ViewStyle> {
223
223
  * Native text colour doesn't inherit from the badge). Event chips are styled
224
224
  * by `renderEvent` (or the theme), not a slot.
225
225
  */
226
- type MonthViewSlot = "title" | "weekdays" | "weekday" | "grid" | "week" | "day" | "dayBadge" | "dayBadgeText" | "rangeBand" | "more" | "morePopover";
226
+ type MonthViewSlot = "title" | "weekdays" | "weekday" | "grid" | "week" | "day" | "dayBadge" | "dayBadgeText" | "rangeBand" | "createGhost" | "more" | "morePopover";
227
227
  /** Props for {@link MonthView}, the single-month grid. */
228
228
  type MonthViewProps<T> = SlotStyleProps<MonthViewSlot> & {
229
229
  date: Date;
@@ -248,6 +248,13 @@ type MonthViewProps<T> = SlotStyleProps<MonthViewSlot> & {
248
248
  /** Weekday header label width: `narrow` ("M"), `short` ("Mon", default), or `long` ("Monday"). */
249
249
  weekdayFormat?: WeekdayFormat;
250
250
  locale?: Locale;
251
+ /**
252
+ * The instant whose calendar day is highlighted as today. Defaults to the
253
+ * device clock, and is read in `timeZone` when one is set.
254
+ */
255
+ now?: Date;
256
+ /** Highlight today as it is in this IANA time zone (default: the device's). */
257
+ timeZone?: string;
251
258
  /** Sort each day's events by start time before slicing. Default true. */
252
259
  sortedMonthView?: boolean;
253
260
  /** Template for the overflow label; `{moreCount}` is replaced. Default "{moreCount} More". */
@@ -317,6 +324,14 @@ type MonthViewProps<T> = SlotStyleProps<MonthViewSlot> & {
317
324
  * plain tap fires `onPressDay`/`onPressCell` instead.
318
325
  */
319
326
  onCreateEvent?: (start: Date, end: Date) => void;
327
+ /**
328
+ * Content inside the drag-to-create preview. Receives the full all-day range,
329
+ * with an exclusive end, that `onCreateEvent` would receive on release. A span
330
+ * crossing rows renders the component once per row with the same range.
331
+ * Requires `onCreateEvent`; content is clipped, noninteractive, and hidden
332
+ * from screen readers. Omit to keep the day highlight without preview content.
333
+ */
334
+ renderCreateGhost?: ComponentType<CreateGhostArgs>;
320
335
  /**
321
336
  * Reports the day span of a create sweep **as it happens**, as the ordered
322
337
  * inclusive `[start, end]` days (both at midnight), so a selection highlight can
@@ -380,6 +395,8 @@ type MonthPagerProps<T> = {
380
395
  hiddenDays?: number[];
381
396
  weekdayFormat?: WeekdayFormat;
382
397
  locale?: Locale;
398
+ now?: Date;
399
+ timeZone?: string;
383
400
  sortedMonthView?: boolean;
384
401
  moreLabel?: string;
385
402
  /** Translations for the screen-reader words and gutter text; omitted keys use English. */
@@ -400,6 +417,8 @@ type MonthPagerProps<T> = {
400
417
  onPressMore?: (events: CalendarEvent$1<T>[], date: Date) => void;
401
418
  /** Drag across empty day cells to sweep out an all-day span for a new event. */
402
419
  onCreateEvent?: (start: Date, end: Date) => void;
420
+ /** Content for each row of the live creation preview; requires `onCreateEvent`. */
421
+ renderCreateGhost?: ComponentType<CreateGhostArgs>;
403
422
  /** Drag-to-select: reports the swept `[start, end]` days live. */
404
423
  onSelectDrag?: (start: Date, end: Date) => void;
405
424
  /** Days drawn as selected (a filled badge). */
@@ -255,6 +255,10 @@ function holdWebDateDrag(node, pointer, start, move, cancel, release) {
255
255
  }
256
256
  // src/components/MonthView.tsx
257
257
  const isWeb$2 = react_native.Platform.OS === "web";
258
+ const webPreviewProps = isWeb$2 ? {
259
+ "aria-hidden": true,
260
+ inert: "inert"
261
+ } : {};
258
262
  const DAY_CELL_PADDING_TOP = 4;
259
263
  const DATE_BADGE_HEIGHT = 24;
260
264
  const BAND_CENTER_Y = 16;
@@ -305,7 +309,7 @@ function MonthViewInner({ date, showAdjacentMonths = true, showSixWeeks = false,
305
309
  source
306
310
  });
307
311
  }
308
- function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipGap = CELL_ROW_GAP, weekStartsOn, hiddenDays, weekdayFormat = "short", locale, sortedMonthView = true, moreLabel = "{moreCount} More", labels: labelsProp, highlightWeekends = true, disableMonthEventCellPress = false, isRTL = false, showTitle = true, showWeekdays = true, activeDate, selectedDates: selectedDatesProp, selectedRange: selectedRangeProp, fillCellOnSelection = false, minDate: minDateProp, maxDate: maxDateProp, isDateDisabled: isDateDisabledProp, calendarCellStyle, renderEvent, eventAccessibilityLabel, keyExtractor, onPressDay, onLongPressDay, onPressCell, onPressEvent, onLongPressEvent, onPressMore, onCreateEvent, onSelectDrag, onDragEvent, onDragStart, eventStartEditable = true, eventOverlap = true, renderCustomDateForMonth, onDayPointerDown, onDayPointerEnter, classNames, styles: styleOverrides }) {
312
+ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipGap = CELL_ROW_GAP, weekStartsOn, hiddenDays, weekdayFormat = "short", locale, now, timeZone, sortedMonthView = true, moreLabel = "{moreCount} More", labels: labelsProp, highlightWeekends = true, disableMonthEventCellPress = false, isRTL = false, showTitle = true, showWeekdays = true, activeDate, selectedDates: selectedDatesProp, selectedRange: selectedRangeProp, fillCellOnSelection = false, minDate: minDateProp, maxDate: maxDateProp, isDateDisabled: isDateDisabledProp, calendarCellStyle, renderEvent, eventAccessibilityLabel, keyExtractor, onPressDay, onLongPressDay, onPressCell, onPressEvent, onLongPressEvent, onPressMore, onCreateEvent, renderCreateGhost: RenderCreateGhost, onSelectDrag, onDragEvent, onDragStart, eventStartEditable = true, eventOverlap = true, renderCustomDateForMonth, onDayPointerDown, onDayPointerEnter, classNames, styles: styleOverrides }) {
309
313
  const { date } = source;
310
314
  const multiWeek = source.kind === "multiweek";
311
315
  const showAdjacentMonths = source.kind === "month" ? source.showAdjacentMonths : true;
@@ -333,6 +337,7 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
333
337
  const [hoveredKey, setHoveredKey] = (0, react.useState)(null);
334
338
  const [pressedKey, setPressedKey] = (0, react.useState)(null);
335
339
  const [moreOpenFor, setMoreOpenFor] = (0, react.useState)(null);
340
+ const today = (0, _super_calendar_core.nowInTimeZone)(now, timeZone);
336
341
  const multiWeekGrid = (0, react.useMemo)(() => numberOfWeeks === void 0 ? null : (0, _super_calendar_core.buildMultiWeekGrid)(date, {
337
342
  numberOfWeeks,
338
343
  weekStartsOn,
@@ -410,7 +415,8 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
410
415
  if (sortedMonthView) for (const list of map.values()) list.sort(_super_calendar_core.compareDayEvents);
411
416
  return map;
412
417
  }, [events, sortedMonthView]);
413
- const showGrid = multiWeek || events.length > 0;
418
+ const createContentEnabled = onCreateEvent != null && RenderCreateGhost != null;
419
+ const showGrid = multiWeek || events.length > 0 || createContentEnabled;
414
420
  const weekLayouts = (0, react.useMemo)(() => showGrid ? weeks.map((week) => (0, _super_calendar_core.layoutMonthWeek)(week, collectRowEvents(week, eventsByDay))) : [], [
415
421
  showGrid,
416
422
  weeks,
@@ -421,6 +427,7 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
421
427
  const heldTouch = (0, react.useRef)(null);
422
428
  const heldOrigin = (0, react.useRef)(null);
423
429
  const [drag, setDrag] = (0, react.useState)(null);
430
+ const createRange = (0, react.useMemo)(() => createContentEnabled && drag?.kind === "create" ? (0, _super_calendar_core.monthCreateRange)(drag.anchor, drag.hover) : null, [createContentEnabled, drag]);
424
431
  const dragRef = (0, react.useRef)(null);
425
432
  const interactionWindow = (0, react.useRef)(windowKey);
426
433
  interactionWindow.current = windowKey;
@@ -682,7 +689,7 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
682
689
  }, theme.containers.dayCell]
683
690
  }) }, day.toISOString());
684
691
  const dayEvents = eventsByDay.get((0, date_fns.startOfDay)(day).toISOString()) ?? [];
685
- const isToday = (0, _super_calendar_core.getIsToday)(day);
692
+ const isToday = (0, _super_calendar_core.getIsToday)(day, today);
686
693
  const isHighlighted = activeDate ? (0, _super_calendar_core.isSameCalendarDay)(day, activeDate) : isToday;
687
694
  const { isDisabled, isSelected, isInRange, isRangeStart, isRangeEnd } = (0, _super_calendar_core.daySelectionState)(day, {
688
695
  selectedDates,
@@ -939,15 +946,21 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
939
946
  lastVisCol = cols - 1 - [...week].reverse().findIndex((d) => (0, date_fns.isSameMonth)(d, date));
940
947
  }
941
948
  }
949
+ const draftColumns = createRange ? week.flatMap((day, index) => (showAdjacentMonths || (0, date_fns.isSameMonth)(day, date)) && day >= createRange.start && day < createRange.end ? [index] : []) : [];
950
+ const draftStart = draftColumns[0];
951
+ const draftEnd = draftColumns.at(-1);
952
+ const draftLane = Math.min(visibleLanes, Math.max(0, capacity.full - 1));
953
+ const draftTop = badgeArea + draftLane * chipMetrics.chipRowHeight;
954
+ const draftHeight = Math.min(chipMetrics.chipHeight, Math.max(0, gridHeight / weeks.length - draftTop));
942
955
  return /* @__PURE__ */ (0, react.createElement)(react_native.View, {
943
956
  ...slot("week", {
944
957
  base: styles$3.weekRow,
945
958
  themed: theme.containers.weekRow
946
959
  }),
947
960
  key: multiWeekGrid?.weeks[weekIndex].id ?? week[0].toISOString()
948
- }, week.map((day, dayCol) => renderDay(day, dayCol, rowLayout, visibleLanes)), showGrid ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
961
+ }, week.map((day, dayCol) => renderDay(day, dayCol, rowLayout, visibleLanes)), showGrid ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
949
962
  style: [react_native.StyleSheet.absoluteFill, multiWeek ? styles$3.childrenOnlyPointerEvents : { pointerEvents: "box-none" }],
950
- children: rowLayout.segments.filter((seg) => seg.lane < visibleLanes).map((seg) => {
963
+ children: [rowLayout.segments.filter((seg) => seg.lane < visibleLanes).map((seg) => {
951
964
  const startCol = Math.max(seg.startCol, firstVisCol);
952
965
  const endCol = Math.min(seg.endCol, lastVisCol);
953
966
  if (startCol > endCol) return null;
@@ -973,7 +986,36 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
973
986
  onLongPress: disableMonthEventCellPress || !onLongPressEvent ? void 0 : () => onLongPressEvent(seg.event)
974
987
  })
975
988
  }, `bar-${seg.event.start.toISOString()}:${seg.event.title}:${seg.lane}`);
976
- })
989
+ }), RenderCreateGhost && createRange && draftStart !== void 0 && draftEnd !== void 0 && draftHeight > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
990
+ testID: "month-create-ghost",
991
+ ...slot("createGhost", {
992
+ base: {
993
+ position: "absolute",
994
+ left: pct(draftStart / cols * 100),
995
+ right: pct((cols - 1 - draftEnd) / cols * 100),
996
+ top: draftTop,
997
+ height: draftHeight,
998
+ marginHorizontal: CHIP_INSET_H,
999
+ overflow: "hidden",
1000
+ zIndex: 1
1001
+ },
1002
+ themed: {
1003
+ backgroundColor: theme.colors.rangeBackground,
1004
+ borderColor: theme.colors.selectedBackground,
1005
+ borderWidth: 1,
1006
+ borderRadius: 4
1007
+ }
1008
+ }),
1009
+ ...webPreviewProps,
1010
+ pointerEvents: "none",
1011
+ accessible: false,
1012
+ accessibilityElementsHidden: true,
1013
+ importantForAccessibility: "no-hide-descendants",
1014
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RenderCreateGhost, {
1015
+ start: createRange.start,
1016
+ end: createRange.end
1017
+ })
1018
+ }) : null]
977
1019
  }) : null);
978
1020
  })
979
1021
  })
@@ -1107,7 +1149,7 @@ function MonthPagerInner({ showAdjacentMonths = true, showSixWeeks = false, ...r
1107
1149
  spec
1108
1150
  });
1109
1151
  }
1110
- function DateRowsPagerInner({ spec, initialAnchor, date, events, maxVisibleEventCount, chipHeight, chipGap, weekStartsOn, hiddenDays, weekdayFormat = "short", locale, sortedMonthView, moreLabel, labels, highlightWeekends, disableMonthEventCellPress, isRTL, calendarCellStyle, renderEvent, keyExtractor, onPressDay, onLongPressDay, onPressCell, onPressEvent, onLongPressEvent, onPressMore, onCreateEvent, onSelectDrag, selectedDates, selectedRange, fillCellOnSelection, minDate, maxDate, isDateDisabled, onDragEvent, onDragStart, eventStartEditable, eventOverlap, onChangeDate, freeSwipe = false, swipeEnabled = true, showTitle = true, activeDate, renderHeaderForMonthView, renderCustomDateForMonth, classNames, styles: styleOverrides }) {
1152
+ function DateRowsPagerInner({ spec, initialAnchor, date, events, maxVisibleEventCount, chipHeight, chipGap, weekStartsOn, hiddenDays, weekdayFormat = "short", locale, now, timeZone, sortedMonthView, moreLabel, labels, highlightWeekends, disableMonthEventCellPress, isRTL, calendarCellStyle, renderEvent, keyExtractor, onPressDay, onLongPressDay, onPressCell, onPressEvent, onLongPressEvent, onPressMore, onCreateEvent, renderCreateGhost, onSelectDrag, selectedDates, selectedRange, fillCellOnSelection, minDate, maxDate, isDateDisabled, onDragEvent, onDragStart, eventStartEditable, eventOverlap, onChangeDate, freeSwipe = false, swipeEnabled = true, showTitle = true, activeDate, renderHeaderForMonthView, renderCustomDateForMonth, classNames, styles: styleOverrides }) {
1111
1153
  const theme = useCalendarTheme();
1112
1154
  const slot = (0, react.useMemo)(() => createSlots({
1113
1155
  classNames,
@@ -1194,20 +1236,33 @@ function DateRowsPagerInner({ spec, initialAnchor, date, events, maxVisibleEvent
1194
1236
  isRTL,
1195
1237
  hiddenDays
1196
1238
  ]);
1239
+ const nowTime = now?.getTime();
1197
1240
  const monthExtraData = (0, react.useMemo)(() => ({
1198
1241
  events,
1199
1242
  activeDate,
1243
+ nowTime,
1244
+ timeZone,
1200
1245
  fillCellOnSelection,
1201
1246
  dragSelect: onSelectDrag != null,
1202
1247
  chipHeight,
1203
- chipGap
1248
+ chipGap,
1249
+ renderCreateGhost,
1250
+ onCreateEvent,
1251
+ createGhostClassName: classNames?.createGhost,
1252
+ createGhostStyle: styleOverrides?.createGhost
1204
1253
  }), [
1205
1254
  events,
1206
1255
  activeDate,
1256
+ nowTime,
1257
+ timeZone,
1207
1258
  fillCellOnSelection,
1208
1259
  onSelectDrag,
1209
1260
  chipHeight,
1210
- chipGap
1261
+ chipGap,
1262
+ renderCreateGhost,
1263
+ onCreateEvent,
1264
+ classNames?.createGhost,
1265
+ styleOverrides?.createGhost
1211
1266
  ]);
1212
1267
  const selection = (0, react.useMemo)(() => ({
1213
1268
  selectedDates,
@@ -1255,6 +1310,8 @@ function DateRowsPagerInner({ spec, initialAnchor, date, events, maxVisibleEvent
1255
1310
  weekStartsOn,
1256
1311
  hiddenDays,
1257
1312
  locale,
1313
+ now,
1314
+ timeZone,
1258
1315
  sortedMonthView,
1259
1316
  moreLabel,
1260
1317
  labels,
@@ -1272,6 +1329,7 @@ function DateRowsPagerInner({ spec, initialAnchor, date, events, maxVisibleEvent
1272
1329
  onLongPressEvent,
1273
1330
  onPressMore,
1274
1331
  onCreateEvent,
1332
+ renderCreateGhost,
1275
1333
  onSelectDrag,
1276
1334
  fillCellOnSelection,
1277
1335
  onDragEvent,
@@ -1292,6 +1350,8 @@ function DateRowsPagerInner({ spec, initialAnchor, date, events, maxVisibleEvent
1292
1350
  weekStartsOn,
1293
1351
  hiddenDays,
1294
1352
  locale,
1353
+ now,
1354
+ timeZone,
1295
1355
  sortedMonthView,
1296
1356
  moreLabel,
1297
1357
  labels,
@@ -1310,6 +1370,7 @@ function DateRowsPagerInner({ spec, initialAnchor, date, events, maxVisibleEvent
1310
1370
  onLongPressEvent,
1311
1371
  onPressMore,
1312
1372
  onCreateEvent,
1373
+ renderCreateGhost,
1313
1374
  onSelectDrag,
1314
1375
  fillCellOnSelection,
1315
1376
  onDragEvent,
@@ -1,6 +1,6 @@
1
1
  import { addDays, addMonths, addWeeks, differenceInCalendarMonths, differenceInCalendarWeeks, format, isSameMonth, startOfDay, startOfMonth, startOfWeek } from "date-fns";
2
2
  import { createContext, createElement, memo, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
3
- import { CalendarSelectionProvider, buildMonthWeeks, buildMultiWeekGrid, compareDayEvents, darkColors, dayAccessibilityLabel, dayBadgeKind, daySelectionState, defaultCalendarLabels, eventAccessibilityLabel, eventTimeLabel, filterHiddenDays, getIsToday, getWeekDays, groupEventsByDay, isAllDayEvent, isBackgroundEvent, isDateSelectable, isSameCalendarDay, isWeekend, layoutMonthWeek, lightColors, monthCreateRange, monthDropBounds, monthEventCapacity, monthVisibleCount, overlapsOtherEvents, rangeBandKind, resolveCalendarLabels, titleEllipsizeMode, titleNumberOfLines, useCalendarSelection, weekdayFormatToken } from "@super-calendar/core";
3
+ import { CalendarSelectionProvider, buildMonthWeeks, buildMultiWeekGrid, compareDayEvents, darkColors, dayAccessibilityLabel, dayBadgeKind, daySelectionState, defaultCalendarLabels, eventAccessibilityLabel, eventTimeLabel, filterHiddenDays, getIsToday, getWeekDays, groupEventsByDay, isAllDayEvent, isBackgroundEvent, isDateSelectable, isSameCalendarDay, isWeekend, layoutMonthWeek, lightColors, monthCreateRange, monthDropBounds, monthEventCapacity, monthVisibleCount, nowInTimeZone, overlapsOtherEvents, rangeBandKind, resolveCalendarLabels, 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 { Gesture, GestureDetector } from "react-native-gesture-handler";
6
6
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -255,6 +255,10 @@ function holdWebDateDrag(node, pointer, start, move, cancel, release) {
255
255
  }
256
256
  // src/components/MonthView.tsx
257
257
  const isWeb$2 = Platform.OS === "web";
258
+ const webPreviewProps = isWeb$2 ? {
259
+ "aria-hidden": true,
260
+ inert: "inert"
261
+ } : {};
258
262
  const DAY_CELL_PADDING_TOP = 4;
259
263
  const DATE_BADGE_HEIGHT = 24;
260
264
  const BAND_CENTER_Y = 16;
@@ -305,7 +309,7 @@ function MonthViewInner({ date, showAdjacentMonths = true, showSixWeeks = false,
305
309
  source
306
310
  });
307
311
  }
308
- function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipGap = CELL_ROW_GAP, weekStartsOn, hiddenDays, weekdayFormat = "short", locale, sortedMonthView = true, moreLabel = "{moreCount} More", labels: labelsProp, highlightWeekends = true, disableMonthEventCellPress = false, isRTL = false, showTitle = true, showWeekdays = true, activeDate, selectedDates: selectedDatesProp, selectedRange: selectedRangeProp, fillCellOnSelection = false, minDate: minDateProp, maxDate: maxDateProp, isDateDisabled: isDateDisabledProp, calendarCellStyle, renderEvent, eventAccessibilityLabel, keyExtractor, onPressDay, onLongPressDay, onPressCell, onPressEvent, onLongPressEvent, onPressMore, onCreateEvent, onSelectDrag, onDragEvent, onDragStart, eventStartEditable = true, eventOverlap = true, renderCustomDateForMonth, onDayPointerDown, onDayPointerEnter, classNames, styles: styleOverrides }) {
312
+ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipGap = CELL_ROW_GAP, weekStartsOn, hiddenDays, weekdayFormat = "short", locale, now, timeZone, sortedMonthView = true, moreLabel = "{moreCount} More", labels: labelsProp, highlightWeekends = true, disableMonthEventCellPress = false, isRTL = false, showTitle = true, showWeekdays = true, activeDate, selectedDates: selectedDatesProp, selectedRange: selectedRangeProp, fillCellOnSelection = false, minDate: minDateProp, maxDate: maxDateProp, isDateDisabled: isDateDisabledProp, calendarCellStyle, renderEvent, eventAccessibilityLabel, keyExtractor, onPressDay, onLongPressDay, onPressCell, onPressEvent, onLongPressEvent, onPressMore, onCreateEvent, renderCreateGhost: RenderCreateGhost, onSelectDrag, onDragEvent, onDragStart, eventStartEditable = true, eventOverlap = true, renderCustomDateForMonth, onDayPointerDown, onDayPointerEnter, classNames, styles: styleOverrides }) {
309
313
  const { date } = source;
310
314
  const multiWeek = source.kind === "multiweek";
311
315
  const showAdjacentMonths = source.kind === "month" ? source.showAdjacentMonths : true;
@@ -333,6 +337,7 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
333
337
  const [hoveredKey, setHoveredKey] = useState(null);
334
338
  const [pressedKey, setPressedKey] = useState(null);
335
339
  const [moreOpenFor, setMoreOpenFor] = useState(null);
340
+ const today = nowInTimeZone(now, timeZone);
336
341
  const multiWeekGrid = useMemo(() => numberOfWeeks === void 0 ? null : buildMultiWeekGrid(date, {
337
342
  numberOfWeeks,
338
343
  weekStartsOn,
@@ -410,7 +415,8 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
410
415
  if (sortedMonthView) for (const list of map.values()) list.sort(compareDayEvents);
411
416
  return map;
412
417
  }, [events, sortedMonthView]);
413
- const showGrid = multiWeek || events.length > 0;
418
+ const createContentEnabled = onCreateEvent != null && RenderCreateGhost != null;
419
+ const showGrid = multiWeek || events.length > 0 || createContentEnabled;
414
420
  const weekLayouts = useMemo(() => showGrid ? weeks.map((week) => layoutMonthWeek(week, collectRowEvents(week, eventsByDay))) : [], [
415
421
  showGrid,
416
422
  weeks,
@@ -421,6 +427,7 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
421
427
  const heldTouch = useRef(null);
422
428
  const heldOrigin = useRef(null);
423
429
  const [drag, setDrag] = useState(null);
430
+ const createRange = useMemo(() => createContentEnabled && drag?.kind === "create" ? monthCreateRange(drag.anchor, drag.hover) : null, [createContentEnabled, drag]);
424
431
  const dragRef = useRef(null);
425
432
  const interactionWindow = useRef(windowKey);
426
433
  interactionWindow.current = windowKey;
@@ -682,7 +689,7 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
682
689
  }, theme.containers.dayCell]
683
690
  }) }, day.toISOString());
684
691
  const dayEvents = eventsByDay.get(startOfDay(day).toISOString()) ?? [];
685
- const isToday = getIsToday(day);
692
+ const isToday = getIsToday(day, today);
686
693
  const isHighlighted = activeDate ? isSameCalendarDay(day, activeDate) : isToday;
687
694
  const { isDisabled, isSelected, isInRange, isRangeStart, isRangeEnd } = daySelectionState(day, {
688
695
  selectedDates,
@@ -939,15 +946,21 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
939
946
  lastVisCol = cols - 1 - [...week].reverse().findIndex((d) => isSameMonth(d, date));
940
947
  }
941
948
  }
949
+ const draftColumns = createRange ? week.flatMap((day, index) => (showAdjacentMonths || isSameMonth(day, date)) && day >= createRange.start && day < createRange.end ? [index] : []) : [];
950
+ const draftStart = draftColumns[0];
951
+ const draftEnd = draftColumns.at(-1);
952
+ const draftLane = Math.min(visibleLanes, Math.max(0, capacity.full - 1));
953
+ const draftTop = badgeArea + draftLane * chipMetrics.chipRowHeight;
954
+ const draftHeight = Math.min(chipMetrics.chipHeight, Math.max(0, gridHeight / weeks.length - draftTop));
942
955
  return /* @__PURE__ */ createElement(View, {
943
956
  ...slot("week", {
944
957
  base: styles$3.weekRow,
945
958
  themed: theme.containers.weekRow
946
959
  }),
947
960
  key: multiWeekGrid?.weeks[weekIndex].id ?? week[0].toISOString()
948
- }, week.map((day, dayCol) => renderDay(day, dayCol, rowLayout, visibleLanes)), showGrid ? /* @__PURE__ */ jsx(View, {
961
+ }, week.map((day, dayCol) => renderDay(day, dayCol, rowLayout, visibleLanes)), showGrid ? /* @__PURE__ */ jsxs(View, {
949
962
  style: [StyleSheet.absoluteFill, multiWeek ? styles$3.childrenOnlyPointerEvents : { pointerEvents: "box-none" }],
950
- children: rowLayout.segments.filter((seg) => seg.lane < visibleLanes).map((seg) => {
963
+ children: [rowLayout.segments.filter((seg) => seg.lane < visibleLanes).map((seg) => {
951
964
  const startCol = Math.max(seg.startCol, firstVisCol);
952
965
  const endCol = Math.min(seg.endCol, lastVisCol);
953
966
  if (startCol > endCol) return null;
@@ -973,7 +986,36 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
973
986
  onLongPress: disableMonthEventCellPress || !onLongPressEvent ? void 0 : () => onLongPressEvent(seg.event)
974
987
  })
975
988
  }, `bar-${seg.event.start.toISOString()}:${seg.event.title}:${seg.lane}`);
976
- })
989
+ }), RenderCreateGhost && createRange && draftStart !== void 0 && draftEnd !== void 0 && draftHeight > 0 ? /* @__PURE__ */ jsx(View, {
990
+ testID: "month-create-ghost",
991
+ ...slot("createGhost", {
992
+ base: {
993
+ position: "absolute",
994
+ left: pct(draftStart / cols * 100),
995
+ right: pct((cols - 1 - draftEnd) / cols * 100),
996
+ top: draftTop,
997
+ height: draftHeight,
998
+ marginHorizontal: CHIP_INSET_H,
999
+ overflow: "hidden",
1000
+ zIndex: 1
1001
+ },
1002
+ themed: {
1003
+ backgroundColor: theme.colors.rangeBackground,
1004
+ borderColor: theme.colors.selectedBackground,
1005
+ borderWidth: 1,
1006
+ borderRadius: 4
1007
+ }
1008
+ }),
1009
+ ...webPreviewProps,
1010
+ pointerEvents: "none",
1011
+ accessible: false,
1012
+ accessibilityElementsHidden: true,
1013
+ importantForAccessibility: "no-hide-descendants",
1014
+ children: /* @__PURE__ */ jsx(RenderCreateGhost, {
1015
+ start: createRange.start,
1016
+ end: createRange.end
1017
+ })
1018
+ }) : null]
977
1019
  }) : null);
978
1020
  })
979
1021
  })
@@ -1107,7 +1149,7 @@ function MonthPagerInner({ showAdjacentMonths = true, showSixWeeks = false, ...r
1107
1149
  spec
1108
1150
  });
1109
1151
  }
1110
- function DateRowsPagerInner({ spec, initialAnchor, date, events, maxVisibleEventCount, chipHeight, chipGap, weekStartsOn, hiddenDays, weekdayFormat = "short", locale, sortedMonthView, moreLabel, labels, highlightWeekends, disableMonthEventCellPress, isRTL, calendarCellStyle, renderEvent, keyExtractor, onPressDay, onLongPressDay, onPressCell, onPressEvent, onLongPressEvent, onPressMore, onCreateEvent, onSelectDrag, selectedDates, selectedRange, fillCellOnSelection, minDate, maxDate, isDateDisabled, onDragEvent, onDragStart, eventStartEditable, eventOverlap, onChangeDate, freeSwipe = false, swipeEnabled = true, showTitle = true, activeDate, renderHeaderForMonthView, renderCustomDateForMonth, classNames, styles: styleOverrides }) {
1152
+ function DateRowsPagerInner({ spec, initialAnchor, date, events, maxVisibleEventCount, chipHeight, chipGap, weekStartsOn, hiddenDays, weekdayFormat = "short", locale, now, timeZone, sortedMonthView, moreLabel, labels, highlightWeekends, disableMonthEventCellPress, isRTL, calendarCellStyle, renderEvent, keyExtractor, onPressDay, onLongPressDay, onPressCell, onPressEvent, onLongPressEvent, onPressMore, onCreateEvent, renderCreateGhost, onSelectDrag, selectedDates, selectedRange, fillCellOnSelection, minDate, maxDate, isDateDisabled, onDragEvent, onDragStart, eventStartEditable, eventOverlap, onChangeDate, freeSwipe = false, swipeEnabled = true, showTitle = true, activeDate, renderHeaderForMonthView, renderCustomDateForMonth, classNames, styles: styleOverrides }) {
1111
1153
  const theme = useCalendarTheme();
1112
1154
  const slot = useMemo(() => createSlots({
1113
1155
  classNames,
@@ -1194,20 +1236,33 @@ function DateRowsPagerInner({ spec, initialAnchor, date, events, maxVisibleEvent
1194
1236
  isRTL,
1195
1237
  hiddenDays
1196
1238
  ]);
1239
+ const nowTime = now?.getTime();
1197
1240
  const monthExtraData = useMemo(() => ({
1198
1241
  events,
1199
1242
  activeDate,
1243
+ nowTime,
1244
+ timeZone,
1200
1245
  fillCellOnSelection,
1201
1246
  dragSelect: onSelectDrag != null,
1202
1247
  chipHeight,
1203
- chipGap
1248
+ chipGap,
1249
+ renderCreateGhost,
1250
+ onCreateEvent,
1251
+ createGhostClassName: classNames?.createGhost,
1252
+ createGhostStyle: styleOverrides?.createGhost
1204
1253
  }), [
1205
1254
  events,
1206
1255
  activeDate,
1256
+ nowTime,
1257
+ timeZone,
1207
1258
  fillCellOnSelection,
1208
1259
  onSelectDrag,
1209
1260
  chipHeight,
1210
- chipGap
1261
+ chipGap,
1262
+ renderCreateGhost,
1263
+ onCreateEvent,
1264
+ classNames?.createGhost,
1265
+ styleOverrides?.createGhost
1211
1266
  ]);
1212
1267
  const selection = useMemo(() => ({
1213
1268
  selectedDates,
@@ -1255,6 +1310,8 @@ function DateRowsPagerInner({ spec, initialAnchor, date, events, maxVisibleEvent
1255
1310
  weekStartsOn,
1256
1311
  hiddenDays,
1257
1312
  locale,
1313
+ now,
1314
+ timeZone,
1258
1315
  sortedMonthView,
1259
1316
  moreLabel,
1260
1317
  labels,
@@ -1272,6 +1329,7 @@ function DateRowsPagerInner({ spec, initialAnchor, date, events, maxVisibleEvent
1272
1329
  onLongPressEvent,
1273
1330
  onPressMore,
1274
1331
  onCreateEvent,
1332
+ renderCreateGhost,
1275
1333
  onSelectDrag,
1276
1334
  fillCellOnSelection,
1277
1335
  onDragEvent,
@@ -1292,6 +1350,8 @@ function DateRowsPagerInner({ spec, initialAnchor, date, events, maxVisibleEvent
1292
1350
  weekStartsOn,
1293
1351
  hiddenDays,
1294
1352
  locale,
1353
+ now,
1354
+ timeZone,
1295
1355
  sortedMonthView,
1296
1356
  moreLabel,
1297
1357
  labels,
@@ -1310,6 +1370,7 @@ function DateRowsPagerInner({ spec, initialAnchor, date, events, maxVisibleEvent
1310
1370
  onLongPressEvent,
1311
1371
  onPressMore,
1312
1372
  onCreateEvent,
1373
+ renderCreateGhost,
1313
1374
  onSelectDrag,
1314
1375
  fillCellOnSelection,
1315
1376
  onDragEvent,