@super-calendar/native 2.17.0 → 2.19.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.
@@ -1,6 +1,6 @@
1
1
  import { addDays, addMonths, addWeeks, differenceInCalendarMonths, differenceInCalendarWeeks, format, isSameMonth, startOfDay, startOfMonth, startOfWeek } from "date-fns";
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";
2
+ import { createContext, createElement, memo, useCallback, useContext, useEffect, useLayoutEffect, 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, keepMonthDraftVisible, layoutMonthWeek, lightColors, monthCreateRange, monthDropBounds, monthEventCapacity, monthExtraLaneColumns, monthVisibleBars, monthVisibleCount, nowInTimeZone, overlapsOtherEvents, rangeBandKind, resolveCalendarLabels, titleEllipsizeMode, titleNumberOfLines, useCalendarSelection, weekdayFormatToken, withDraftEventDays } 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";
@@ -176,6 +176,167 @@ function useWebPagerKeys(enabled, onPage) {
176
176
  return () => doc.removeEventListener("keydown", handler);
177
177
  }, [enabled, onPage]);
178
178
  }
179
+ // src/components/MonthCellProbe.tsx
180
+ const MARKER_HEIGHT = 1;
181
+ const hiddenProbeProps = {
182
+ pointerEvents: "none",
183
+ accessible: false,
184
+ accessibilityElementsHidden: true,
185
+ importantForAccessibility: "no-hide-descendants",
186
+ ...Platform.OS === "web" ? {
187
+ "aria-hidden": true,
188
+ inert: "inert"
189
+ } : {}
190
+ };
191
+ const MonthGridSpacingProbe = memo(function MonthGridSpacingProbe({ grid, weeks, onInnerHeight, onOuterHeight }) {
192
+ return /* @__PURE__ */ jsx(View, {
193
+ ...hiddenProbeProps,
194
+ style: styles$4.frame,
195
+ onLayout: (e) => onOuterHeight(e.nativeEvent.layout.height),
196
+ children: /* @__PURE__ */ jsx(View, {
197
+ ...grid,
198
+ style: [grid.style, styles$4.gridSpacing],
199
+ onLayout: (e) => onInnerHeight(e.nativeEvent.layout.height),
200
+ children: Array.from({ length: weeks }, (_, index) => /* @__PURE__ */ jsx(View, { style: styles$4.emptyWeek }, index))
201
+ })
202
+ });
203
+ });
204
+ const MonthCellProbe = memo(function MonthCellProbe({ id, week, day, cellStyle, dayWidth, weekWidth, onMeasure }) {
205
+ const layouts = useRef({});
206
+ const nodes = useRef({});
207
+ const report = useCallback((height, row, top, laneTop, laneHeight, overlayTop) => {
208
+ if (height > 0) onMeasure(id, {
209
+ minimumHeight: height,
210
+ top,
211
+ gap: Math.max(0, laneTop - top - MARKER_HEIGHT),
212
+ bottom: height - laneTop - laneHeight,
213
+ overlayTop,
214
+ weekMargin: height - row.height,
215
+ weekMarginTop: row.y
216
+ });
217
+ }, [id, onMeasure]);
218
+ const readWeb = useCallback(() => {
219
+ if (Platform.OS !== "web" || typeof HTMLElement === "undefined") return false;
220
+ const frame = nodes.current.frame;
221
+ if (!(frame instanceof HTMLElement)) return false;
222
+ const layout = (part) => {
223
+ const node = nodes.current[part];
224
+ if (!(node instanceof HTMLElement)) return;
225
+ let y = 0;
226
+ let current = node;
227
+ while (current !== frame) {
228
+ const parent = current.offsetParent;
229
+ if (!(parent instanceof HTMLElement)) return;
230
+ y += current.offsetTop + parent.clientTop;
231
+ current = parent;
232
+ }
233
+ return {
234
+ y,
235
+ height: node.offsetHeight
236
+ };
237
+ };
238
+ const row = layout("row"), date = layout("date"), lane = layout("lane"), overlay = layout("overlay");
239
+ if (!row || !date || !lane || !overlay) return false;
240
+ report(frame.offsetHeight, row, date.y, lane.y, lane.height, overlay.y);
241
+ return true;
242
+ }, [report]);
243
+ useLayoutEffect(() => {
244
+ readWeb();
245
+ }, [
246
+ readWeb,
247
+ week,
248
+ day,
249
+ cellStyle,
250
+ dayWidth,
251
+ weekWidth
252
+ ]);
253
+ function observe(part) {
254
+ return {
255
+ ...Platform.OS === "web" && { ref: (node) => {
256
+ nodes.current[part] = node;
257
+ } },
258
+ onLayout: (event) => {
259
+ if (readWeb()) return;
260
+ layouts.current[part] = event.nativeEvent.layout;
261
+ const { frame, row, cell, date, lane, overlay } = layouts.current;
262
+ if (!frame || !row || !cell || !date || !lane || !overlay) return;
263
+ const cellTop = row.y + cell.y;
264
+ report(frame.height, row, cellTop + date.y, cellTop + lane.y, lane.height, row.y + overlay.y);
265
+ }
266
+ };
267
+ }
268
+ return /* @__PURE__ */ jsx(View, {
269
+ ...observe("frame"),
270
+ style: styles$4.frame,
271
+ collapsable: false,
272
+ ...hiddenProbeProps,
273
+ children: /* @__PURE__ */ jsxs(View, {
274
+ ...observe("row"),
275
+ ...week,
276
+ style: [
277
+ week.style,
278
+ styles$4.intrinsic,
279
+ { width: weekWidth }
280
+ ],
281
+ collapsable: false,
282
+ children: [/* @__PURE__ */ jsxs(TouchableOpacity, {
283
+ ...day,
284
+ style: [
285
+ day.style,
286
+ cellStyle,
287
+ styles$4.measuredDay,
288
+ { width: dayWidth }
289
+ ],
290
+ disabled: true,
291
+ onLayout: observe("cell").onLayout,
292
+ children: [/* @__PURE__ */ jsx(View, {
293
+ ...observe("date"),
294
+ style: styles$4.marker,
295
+ collapsable: false
296
+ }), /* @__PURE__ */ jsx(View, {
297
+ ...observe("lane"),
298
+ style: styles$4.laneMarker,
299
+ collapsable: false
300
+ })]
301
+ }), /* @__PURE__ */ jsx(View, {
302
+ ...observe("overlay"),
303
+ style: StyleSheet.absoluteFill,
304
+ collapsable: false
305
+ })]
306
+ })
307
+ });
308
+ });
309
+ const styles$4 = StyleSheet.create({
310
+ frame: {
311
+ position: "absolute",
312
+ top: 0,
313
+ left: 0,
314
+ right: 0,
315
+ opacity: 0
316
+ },
317
+ gridSpacing: {
318
+ height: "auto",
319
+ minHeight: 0,
320
+ maxHeight: "auto",
321
+ flex: 0
322
+ },
323
+ emptyWeek: { height: 0 },
324
+ intrinsic: {
325
+ height: "auto",
326
+ minHeight: 0
327
+ },
328
+ measuredDay: {
329
+ justifyContent: "flex-start",
330
+ alignSelf: "stretch",
331
+ flex: 0,
332
+ flexBasis: "auto"
333
+ },
334
+ marker: { height: MARKER_HEIGHT },
335
+ laneMarker: {
336
+ height: MARKER_HEIGHT,
337
+ flexGrow: 1
338
+ }
339
+ });
179
340
  // src/utils/withEventAccessibilityLabel.tsx
180
341
  /**
181
342
  * Wrap an event renderer so it injects a consumer's `eventAccessibilityLabel`
@@ -255,10 +416,15 @@ function holdWebDateDrag(node, pointer, start, move, cancel, release) {
255
416
  }
256
417
  // src/components/MonthView.tsx
257
418
  const isWeb$2 = Platform.OS === "web";
419
+ const webPreviewProps = isWeb$2 ? {
420
+ "aria-hidden": true,
421
+ inert: "inert"
422
+ } : {};
258
423
  const DAY_CELL_PADDING_TOP = 4;
259
424
  const DATE_BADGE_HEIGHT = 24;
260
425
  const BAND_CENTER_Y = 16;
261
426
  const CELL_ROW_GAP = 2;
427
+ const MORE_LABEL_MARGIN_TOP = 2;
262
428
  const EMPTY_LAYOUT = {
263
429
  segments: [],
264
430
  laneCount: 0
@@ -305,18 +471,21 @@ function MonthViewInner({ date, showAdjacentMonths = true, showSixWeeks = false,
305
471
  source
306
472
  });
307
473
  }
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 }) {
474
+ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipGap: chipGapProp, 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
475
  const { date } = source;
310
476
  const multiWeek = source.kind === "multiweek";
477
+ const chipGap = chipGapProp ?? CELL_ROW_GAP;
478
+ const defaultCellSpacing = !multiWeek || !classNames?.day;
479
+ const createContentEnabled = onCreateEvent != null && RenderCreateGhost != null;
480
+ const showGrid = multiWeek || events.length > 0 || createContentEnabled;
311
481
  const showAdjacentMonths = source.kind === "month" ? source.showAdjacentMonths : true;
312
482
  const showSixWeeks = source.kind === "month" ? source.showSixWeeks : false;
313
483
  const numberOfWeeks = source.kind === "multiweek" ? source.numberOfWeeks : void 0;
314
484
  const theme = useCalendarTheme();
315
- const badgeArea = 28 + chipGap;
316
- const slot = createSlots({
485
+ const slot = useMemo(() => createSlots({
317
486
  classNames,
318
487
  styles: styleOverrides
319
- });
488
+ }), [classNames, styleOverrides]);
320
489
  const labels = useMemo(() => resolveCalendarLabels(labelsProp), [labelsProp]);
321
490
  const selection = useCalendarSelection();
322
491
  const selectedDates = selectedDatesProp ?? selection.selectedDates;
@@ -330,9 +499,15 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
330
499
  height: 0
331
500
  });
332
501
  const gridHeight = gridSize.height;
502
+ const weekTops = useRef([]);
503
+ const [drawnWeek, setDrawnWeek] = useState({
504
+ width: 0,
505
+ height: 0
506
+ });
333
507
  const [hoveredKey, setHoveredKey] = useState(null);
334
508
  const [pressedKey, setPressedKey] = useState(null);
335
509
  const [moreOpenFor, setMoreOpenFor] = useState(null);
510
+ const today = nowInTimeZone(now, timeZone);
336
511
  const multiWeekGrid = useMemo(() => numberOfWeeks === void 0 ? null : buildMultiWeekGrid(date, {
337
512
  numberOfWeeks,
338
513
  weekStartsOn,
@@ -368,20 +543,163 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
368
543
  isRTL,
369
544
  hiddenDays
370
545
  ]);
371
- const chipMetrics = useMemo(() => {
546
+ const laneChipHeight = useMemo(() => {
372
547
  const fontSize = numericStyle(theme.text.eventTitle.fontSize, 12);
373
548
  const lineHeight = numericStyle(theme.text.eventTitle.lineHeight, Math.ceil(fontSize * 1.3));
374
- const height = chipHeight ?? lineHeight + 4;
549
+ return chipHeight ?? lineHeight + 4;
550
+ }, [theme, chipHeight]);
551
+ const moreSlot = slot("more", {
552
+ base: [styles$3.moreLabel, chipHeight != null && { height: chipHeight }],
553
+ themed: [theme.text.more, { color: theme.colors.textMuted }]
554
+ });
555
+ const [measuredMoreArea, setMeasuredMoreArea] = useState(0);
556
+ const moreLabelArea = measuredMoreArea || (() => {
557
+ const style = StyleSheet.flatten(moreSlot.style) ?? {};
558
+ const edge = (value) => typeof value === "number" ? value : 0;
559
+ const margin = edge(style.marginTop ?? style.marginVertical ?? style.margin) + edge(style.marginBottom ?? style.marginVertical ?? style.margin);
560
+ const padding = edge(style.paddingTop ?? style.paddingVertical ?? style.padding) + edge(style.paddingBottom ?? style.paddingVertical ?? style.padding);
561
+ const line = numericStyle(style.lineHeight, Math.ceil(numericStyle(style.fontSize, 11) * 1.3));
562
+ return margin + (typeof style.height === "number" ? style.height : line + padding);
563
+ })();
564
+ const [daySizes, setDaySizes] = useState({});
565
+ const shownDayKeys = useMemo(() => new Set(weeks.flat().map((day) => day.toISOString())), [weeks]);
566
+ const recordDaySize = (dayKey, dimension, size) => setDaySizes((previous) => {
567
+ if (previous[dayKey]?.[dimension] === size) return previous;
568
+ const next = { [dayKey]: {
569
+ ...previous[dayKey],
570
+ [dimension]: size
571
+ } };
572
+ for (const key in previous) if (key !== dayKey && shownDayKeys.has(key)) next[key] = previous[key];
573
+ return next;
574
+ });
575
+ const dateHeight = useMemo(() => {
576
+ if (!multiWeek) return DATE_BADGE_HEIGHT;
577
+ let tallest = DATE_BADGE_HEIGHT;
578
+ for (const key of shownDayKeys) tallest = Math.max(tallest, daySizes[key]?.dateHeight ?? 0);
579
+ return tallest;
580
+ }, [
581
+ multiWeek,
582
+ daySizes,
583
+ shownDayKeys
584
+ ]);
585
+ const dayCellBase = useMemo(() => [
586
+ styles$3.dayCell,
587
+ defaultCellSpacing && styles$3.dayCellPadding,
588
+ (defaultCellSpacing || chipGapProp != null) && { gap: chipGap },
589
+ showGrid && styles$3.dayCellEvents
590
+ ], [
591
+ defaultCellSpacing,
592
+ chipGapProp,
593
+ chipGap,
594
+ showGrid
595
+ ]);
596
+ const dayCellLines = useMemo(() => showGrid && {
597
+ borderTopWidth: StyleSheet.hairlineWidth,
598
+ borderRightWidth: StyleSheet.hairlineWidth,
599
+ borderColor: theme.colors.gridLine
600
+ }, [showGrid, theme.colors.gridLine]);
601
+ const probeDay = useMemo(() => slot("day", {
602
+ base: dayCellBase,
603
+ themed: [dayCellLines, theme.containers.dayCell]
604
+ }), [
605
+ slot,
606
+ dayCellBase,
607
+ dayCellLines,
608
+ theme.containers.dayCell
609
+ ]);
610
+ const probeWeek = useMemo(() => slot("week", {
611
+ base: styles$3.weekRowFixed,
612
+ themed: theme.containers.weekRow
613
+ }), [slot, theme.containers.weekRow]);
614
+ const cellStyles = useMemo(() => {
615
+ const probes = /* @__PURE__ */ new Map();
616
+ const byDay = /* @__PURE__ */ new Map();
617
+ if (multiWeek) {
618
+ const ids = /* @__PURE__ */ new Map();
619
+ for (const week of weeks) for (const day of week) {
620
+ const dayKey = day.toISOString();
621
+ const style = calendarCellStyle?.(day) ?? void 0;
622
+ const styleId = ids.get(style) ?? (style ? dayKey : "default");
623
+ ids.set(style, styleId);
624
+ const width = daySizes[dayKey]?.width ?? 0;
625
+ const id = `${styleId}:${width}`;
626
+ probes.set(id, {
627
+ style,
628
+ width
629
+ });
630
+ byDay.set(dayKey, id);
631
+ }
632
+ }
375
633
  return {
376
- chipHeight: height,
377
- chipRowHeight: height + chipGap
634
+ probes,
635
+ byDay
378
636
  };
379
637
  }, [
380
- theme,
381
- chipHeight,
382
- chipGap
638
+ multiWeek,
639
+ weeks,
640
+ calendarCellStyle,
641
+ daySizes
642
+ ]);
643
+ const [measuredCells, setMeasuredCells] = useState({});
644
+ const recordCell = useCallback((id, measured) => {
645
+ setMeasuredCells((previous) => {
646
+ const old = previous[id];
647
+ if (old && old.minimumHeight === measured.minimumHeight && old.top === measured.top && old.bottom === measured.bottom && old.gap === measured.gap && old.overlayTop === measured.overlayTop && old.weekMargin === measured.weekMargin && old.weekMarginTop === measured.weekMarginTop) return previous;
648
+ const next = { [id]: measured };
649
+ for (const key of cellStyles.probes.keys()) if (key !== id && previous[key]) next[key] = previous[key];
650
+ return next;
651
+ });
652
+ }, [cellStyles]);
653
+ const estimatedCell = useMemo(() => ({
654
+ minimumHeight: 0,
655
+ top: defaultCellSpacing ? DAY_CELL_PADDING_TOP + (multiWeek ? StyleSheet.hairlineWidth : 0) : 0,
656
+ bottom: 0,
657
+ gap: defaultCellSpacing ? chipGap : chipGapProp ?? 0,
658
+ overlayTop: 0,
659
+ weekMargin: 0,
660
+ weekMarginTop: 0
661
+ }), [
662
+ multiWeek,
663
+ defaultCellSpacing,
664
+ chipGap,
665
+ chipGapProp
666
+ ]);
667
+ const cellGeometry = useMemo(() => {
668
+ let common;
669
+ for (const id of cellStyles.probes.keys()) {
670
+ const cell = measuredCells[id] ?? estimatedCell;
671
+ if (!common) common = { ...cell };
672
+ else {
673
+ common.minimumHeight = Math.max(common.minimumHeight, cell.minimumHeight);
674
+ common.top = Math.max(common.top, cell.top);
675
+ common.bottom = Math.max(common.bottom, cell.bottom);
676
+ common.gap = Math.max(common.gap, cell.gap);
677
+ }
678
+ }
679
+ return common ?? estimatedCell;
680
+ }, [
681
+ cellStyles,
682
+ measuredCells,
683
+ estimatedCell
684
+ ]);
685
+ const dateArea = cellGeometry.top + dateHeight;
686
+ const cellLaneHeight = laneChipHeight + cellGeometry.gap;
687
+ const laneTop = dateArea + cellGeometry.gap;
688
+ const barTop = laneTop - cellGeometry.overlayTop;
689
+ const contentHeight = dateArea + cellGeometry.gap + cellGeometry.bottom + (maxVisibleEventCount != null ? Math.max(1, maxVisibleEventCount) * cellLaneHeight + moreLabelArea : Math.max(FALLBACK_VISIBLE_COUNT * cellLaneHeight, cellLaneHeight + moreLabelArea));
690
+ const minimumRowHeight = Math.max(contentHeight, cellGeometry.minimumHeight);
691
+ const [viewportHeight, setViewportHeight] = useState(0);
692
+ const gridProbe = useMemo(() => multiWeek && (classNames?.grid || styleOverrides?.grid) ? slot("grid") : null, [
693
+ multiWeek,
694
+ classNames?.grid,
695
+ styleOverrides?.grid,
696
+ slot
383
697
  ]);
384
- const minimumRowHeight = badgeArea + Math.max(1, maxVisibleEventCount ?? FALLBACK_VISIBLE_COUNT) * chipMetrics.chipRowHeight;
698
+ const [gridInnerSpacing, setGridInnerSpacing] = useState(0);
699
+ const [gridOuterSpacing, setGridOuterSpacing] = useState(0);
700
+ const heightForWeeks = viewportHeight - (gridProbe ? gridOuterSpacing : 0);
701
+ const multiWeekRowHeight = multiWeek && viewportHeight > 0 ? Math.max(minimumRowHeight, heightForWeeks / weeks.length) - cellGeometry.weekMargin : void 0;
702
+ const rowHeight = multiWeek && drawnWeek.height > 0 ? drawnWeek.height + cellGeometry.weekMargin : gridHeight / weeks.length;
385
703
  const capacity = useMemo(() => {
386
704
  if (maxVisibleEventCount != null) return {
387
705
  full: maxVisibleEventCount,
@@ -391,26 +709,30 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
391
709
  full: FALLBACK_VISIBLE_COUNT,
392
710
  withMore: FALLBACK_VISIBLE_COUNT
393
711
  };
394
- const rowHeight = gridHeight / weeks.length;
395
- const moreFontSize = numericStyle(theme.text.more.fontSize, 11);
396
- const moreRowHeight = (chipHeight ?? Math.ceil(moreFontSize * 1.3)) + chipGap;
397
- const available = rowHeight - DAY_CELL_PADDING_TOP - DATE_BADGE_HEIGHT;
398
- return monthEventCapacity(available, chipMetrics.chipRowHeight, moreRowHeight);
712
+ const available = rowHeight - dateArea - cellGeometry.bottom;
713
+ return monthEventCapacity(available, cellLaneHeight, moreLabelArea + cellGeometry.gap);
399
714
  }, [
400
715
  maxVisibleEventCount,
401
716
  gridHeight,
402
717
  weeks.length,
403
- theme,
404
- chipMetrics,
405
- chipHeight,
406
- chipGap
718
+ rowHeight,
719
+ dateArea,
720
+ cellGeometry,
721
+ cellLaneHeight,
722
+ moreLabelArea
407
723
  ]);
724
+ const rowLanes = useCallback((rowLayout, columns) => {
725
+ const visibleLanes = monthVisibleCount(rowLayout.laneCount, capacity);
726
+ return {
727
+ visibleLanes,
728
+ extraLane: capacity.full > visibleLanes ? monthExtraLaneColumns(rowLayout, visibleLanes, columns) : Array.from({ length: columns }, () => false)
729
+ };
730
+ }, [capacity]);
408
731
  const eventsByDay = useMemo(() => {
409
732
  const map = groupEventsByDay(events.filter((event) => !isBackgroundEvent(event)));
410
733
  if (sortedMonthView) for (const list of map.values()) list.sort(compareDayEvents);
411
734
  return map;
412
735
  }, [events, sortedMonthView]);
413
- const showGrid = multiWeek || events.length > 0;
414
736
  const weekLayouts = useMemo(() => showGrid ? weeks.map((week) => layoutMonthWeek(week, collectRowEvents(week, eventsByDay))) : [], [
415
737
  showGrid,
416
738
  weeks,
@@ -421,6 +743,32 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
421
743
  const heldTouch = useRef(null);
422
744
  const heldOrigin = useRef(null);
423
745
  const [drag, setDrag] = useState(null);
746
+ const createRange = useMemo(() => createContentEnabled && drag?.kind === "create" ? monthCreateRange(drag.anchor, drag.hover) : null, [createContentEnabled, drag]);
747
+ const draftEvent = useMemo(() => createRange ? {
748
+ title: "",
749
+ start: createRange.start,
750
+ end: createRange.end,
751
+ allDay: true
752
+ } : null, [createRange]);
753
+ const rowLayouts = useMemo(() => {
754
+ if (!draftEvent) return weekLayouts;
755
+ const days = withDraftEventDays(eventsByDay, draftEvent, sortedMonthView);
756
+ return weeks.map((week, index) => {
757
+ const base = weekLayouts[index] ?? EMPTY_LAYOUT;
758
+ if (!week.some((day) => day >= draftEvent.start && day < draftEvent.end)) return base;
759
+ return keepMonthDraftVisible(layoutMonthWeek(week, collectRowEvents(week, days)), base, draftEvent, {
760
+ visibleLanes: (laneCount) => monthVisibleCount(laneCount, capacity),
761
+ extraLaneFits: (visibleLanes) => capacity.full > visibleLanes
762
+ });
763
+ });
764
+ }, [
765
+ draftEvent,
766
+ weekLayouts,
767
+ eventsByDay,
768
+ sortedMonthView,
769
+ weeks,
770
+ capacity
771
+ ]);
424
772
  const dragRef = useRef(null);
425
773
  const interactionWindow = useRef(windowKey);
426
774
  interactionWindow.current = windowKey;
@@ -470,8 +818,19 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
470
818
  const hitTest = useCallback((x, y) => {
471
819
  const { width, height } = gridSize;
472
820
  if (width <= 0 || height <= 0 || weeks.length === 0) return null;
473
- const rowHeight = height / weeks.length;
474
- const row = Math.min(weeks.length - 1, Math.max(0, Math.floor(y / rowHeight)));
821
+ let row = Math.min(weeks.length - 1, Math.max(0, Math.floor(y / rowHeight)));
822
+ let rowTop = row * rowHeight;
823
+ if (multiWeek) {
824
+ const grid = isWeb$2 && typeof Element !== "undefined" && gridRef.current instanceof Element ? gridRef.current : null;
825
+ const gridTop = grid?.getBoundingClientRect().top ?? 0;
826
+ const topOf = (index) => {
827
+ const node = grid?.children[index];
828
+ const borderTop = node ? node.getBoundingClientRect().top - gridTop : weekTops.current[index];
829
+ return borderTop == null ? index * rowHeight : borderTop - cellGeometry.weekMarginTop;
830
+ };
831
+ row = weekAtOffset(y, weeks.length, topOf);
832
+ rowTop = topOf(row);
833
+ }
475
834
  const cols = weeks[row].length;
476
835
  const col = Math.min(cols - 1, Math.max(0, Math.floor(x / (width / cols))));
477
836
  const day = weeks[row][col];
@@ -483,19 +842,25 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
483
842
  isDateDisabled
484
843
  })) return null;
485
844
  const rowLayout = weekLayouts[row] ?? EMPTY_LAYOUT;
486
- const lane = Math.floor((y - row * rowHeight - badgeArea) / chipMetrics.chipRowHeight);
487
- const visibleLanes = monthVisibleCount(rowLayout.laneCount, capacity);
845
+ const laneOffset = y - rowTop - laneTop;
846
+ const lane = Math.floor(laneOffset / cellLaneHeight);
847
+ const insideBar = !multiWeek || laneOffset - lane * cellLaneHeight < laneChipHeight;
848
+ const { visibleLanes, extraLane } = rowLanes(rowLayout, cols);
488
849
  return {
489
850
  day,
490
- event: (lane >= 0 && lane < visibleLanes ? rowLayout.segments.find((s) => s.lane === lane && s.startCol <= col && s.endCol >= col) : void 0)?.event ?? null
851
+ event: (insideBar && lane >= 0 && lane < visibleLanes + (extraLane[col] ? 1 : 0) ? rowLayout.segments.find((s) => s.lane === lane && s.startCol <= col && s.endCol >= col) : void 0)?.event ?? null
491
852
  };
492
853
  }, [
493
854
  gridSize,
494
855
  weeks,
495
856
  weekLayouts,
496
- capacity,
497
- chipMetrics,
498
- badgeArea,
857
+ rowLanes,
858
+ multiWeek,
859
+ rowHeight,
860
+ cellGeometry.weekMarginTop,
861
+ laneChipHeight,
862
+ laneTop,
863
+ cellLaneHeight,
499
864
  showAdjacentMonths,
500
865
  date,
501
866
  minDate,
@@ -671,10 +1036,14 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
671
1036
  heldOrigin.current = null;
672
1037
  });
673
1038
  };
674
- const renderDay = (day, dayCol, rowLayout, visibleLanes) => {
1039
+ const renderDay = (day, dayCol, rowLayout, dayLanes) => {
675
1040
  const isCurrentMonth = multiWeek || isSameMonth(day, date);
676
1041
  if (!isCurrentMonth && !showAdjacentMonths) return /* @__PURE__ */ jsx(View, { ...slot("day", {
677
- base: [styles$3.dayCell, { gap: chipGap }],
1042
+ base: [
1043
+ styles$3.dayCell,
1044
+ styles$3.dayCellPadding,
1045
+ { gap: chipGap }
1046
+ ],
678
1047
  themed: [showGrid && {
679
1048
  borderTopWidth: StyleSheet.hairlineWidth,
680
1049
  borderRightWidth: StyleSheet.hairlineWidth,
@@ -682,7 +1051,7 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
682
1051
  }, theme.containers.dayCell]
683
1052
  }) }, day.toISOString());
684
1053
  const dayEvents = eventsByDay.get(startOfDay(day).toISOString()) ?? [];
685
- const isToday = getIsToday(day);
1054
+ const isToday = getIsToday(day, today);
686
1055
  const isHighlighted = activeDate ? isSameCalendarDay(day, activeDate) : isToday;
687
1056
  const { isDisabled, isSelected, isInRange, isRangeStart, isRangeEnd } = daySelectionState(day, {
688
1057
  selectedDates,
@@ -692,7 +1061,7 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
692
1061
  maxDate,
693
1062
  isDateDisabled
694
1063
  });
695
- const hiddenCount = rowLayout.segments.filter((s) => s.startCol <= dayCol && s.endCol >= dayCol && s.lane >= visibleLanes).map((s) => s.event).length;
1064
+ const hiddenCount = rowLayout.segments.filter((s) => s.startCol <= dayCol && s.endCol >= dayCol && s.lane >= dayLanes && s.event !== draftEvent).map((s) => s.event).length;
696
1065
  const isFilledBadge = dayBadgeKind({ isSelected }, isHighlighted) !== "none";
697
1066
  const hasBand = rangeBandKind({
698
1067
  isInRange,
@@ -700,6 +1069,10 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
700
1069
  isRangeEnd
701
1070
  }, fillCellOnSelection) !== "none";
702
1071
  const dayKey = day.toISOString();
1072
+ const probeId = cellStyles.byDay.get(dayKey) ?? "default";
1073
+ const cellStyle = multiWeek ? cellStyles.probes.get(probeId)?.style : calendarCellStyle?.(day);
1074
+ const cell = measuredCells[probeId] ?? estimatedCell;
1075
+ const dateMargin = laneTop - cell.top - (daySizes[dayKey]?.dateHeight ?? DATE_BADGE_HEIGHT) - cell.gap;
703
1076
  const isDragPreview = isInCreateSpan(drag, day) || drag?.kind === "move" && isSameCalendarDay(day, drag.to) && !isSameCalendarDay(day, drag.from);
704
1077
  const isHovered = isWeb$2 && !isDisabled && !showGrid && hoveredKey === dayKey;
705
1078
  const dateColor = isDisabled ? theme.colors.textDisabled : isFilledBadge ? isHighlighted ? theme.colors.todayText : theme.colors.selectedText : isCurrentMonth ? theme.colors.text : theme.colors.textDisabled;
@@ -718,18 +1091,40 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
718
1091
  eventCount,
719
1092
  labels
720
1093
  });
1094
+ const dateElement = renderCustomDateForMonth ? renderCustomDateForMonth(day, {
1095
+ isCurrentMonth,
1096
+ isToday,
1097
+ isSelected,
1098
+ isDisabled
1099
+ }) : /* @__PURE__ */ jsx(View, {
1100
+ ...slot("dayBadge", {
1101
+ base: [
1102
+ styles$3.dateBadge,
1103
+ showGrid && styles$3.dateBadgeEvents,
1104
+ !showGrid && pressedKey === dayKey && { opacity: .2 }
1105
+ ],
1106
+ themed: [
1107
+ isFilledBadge && {
1108
+ backgroundColor: isHighlighted ? theme.colors.todayBackground : theme.colors.selectedBackground,
1109
+ borderRadius: theme.todayBadgeRadius
1110
+ },
1111
+ isHovered && !isFilledBadge && {
1112
+ backgroundColor: theme.colors.hoverBackground,
1113
+ borderRadius: theme.todayBadgeRadius
1114
+ },
1115
+ theme.containers.dayBadge
1116
+ ]
1117
+ }),
1118
+ children: /* @__PURE__ */ jsx(Text, {
1119
+ ...slot("dayBadgeText", { themed: [theme.text.dateCell, { color: dateColor }] }),
1120
+ allowFontScaling: false,
1121
+ children: format(day, "d")
1122
+ })
1123
+ });
721
1124
  const daySlot = slot("day", {
722
- base: [
723
- styles$3.dayCell,
724
- { gap: chipGap },
725
- showGrid && styles$3.dayCellEvents
726
- ],
1125
+ base: dayCellBase,
727
1126
  themed: [
728
- showGrid && {
729
- borderTopWidth: StyleSheet.hairlineWidth,
730
- borderRightWidth: StyleSheet.hairlineWidth,
731
- borderColor: theme.colors.gridLine
732
- },
1127
+ dayCellLines,
733
1128
  highlightWeekends && isWeekend(day) && { backgroundColor: theme.colors.weekendBackground },
734
1129
  isDragPreview && { backgroundColor: theme.colors.rangeBackground },
735
1130
  theme.containers.dayCell
@@ -737,7 +1132,12 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
737
1132
  });
738
1133
  return /* @__PURE__ */ jsxs(TouchableOpacity, {
739
1134
  ...daySlot,
740
- style: [daySlot.style, calendarCellStyle?.(day)],
1135
+ style: [
1136
+ daySlot.style,
1137
+ cellStyle,
1138
+ multiWeek && styles$3.dayCellStacked
1139
+ ],
1140
+ onLayout: multiWeek ? (event) => recordDaySize(dayKey, "width", event.nativeEvent.layout.width) : void 0,
741
1141
  activeOpacity: showGrid ? .2 : 1,
742
1142
  ...showGrid ? null : {
743
1143
  onPressIn: () => setPressedKey(dayKey),
@@ -789,40 +1189,17 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
789
1189
  themed: { backgroundColor: theme.colors.rangeBackground }
790
1190
  })
791
1191
  }) : null,
792
- renderCustomDateForMonth ? renderCustomDateForMonth(day) : /* @__PURE__ */ jsx(View, {
793
- ...slot("dayBadge", {
794
- base: [
795
- styles$3.dateBadge,
796
- showGrid && styles$3.dateBadgeEvents,
797
- !showGrid && pressedKey === dayKey && { opacity: .2 }
798
- ],
799
- themed: [
800
- isFilledBadge && {
801
- backgroundColor: isHighlighted ? theme.colors.todayBackground : theme.colors.selectedBackground,
802
- borderRadius: theme.todayBadgeRadius
803
- },
804
- isHovered && !isFilledBadge && {
805
- backgroundColor: theme.colors.hoverBackground,
806
- borderRadius: theme.todayBadgeRadius
807
- },
808
- theme.containers.dayBadge
809
- ]
810
- }),
811
- children: /* @__PURE__ */ jsx(Text, {
812
- ...slot("dayBadgeText", { themed: [theme.text.dateCell, { color: dateColor }] }),
813
- allowFontScaling: false,
814
- children: format(day, "d")
815
- })
816
- }),
817
- Array.from({ length: visibleLanes }, (_, i) => /* @__PURE__ */ jsx(View, { style: {
818
- height: chipMetrics.chipHeight,
1192
+ multiWeek ? /* @__PURE__ */ jsx(View, {
1193
+ style: [renderCustomDateForMonth ? void 0 : styles$3.dateWrapperStretch, hiddenCount > 0 && { marginBottom: Math.max(0, dateMargin) + dayLanes * cellLaneHeight }],
1194
+ onLayout: (event) => recordDaySize(dayKey, "dateHeight", event.nativeEvent.layout.height),
1195
+ children: dateElement
1196
+ }) : dateElement,
1197
+ !multiWeek && Array.from({ length: dayLanes }, (_, i) => /* @__PURE__ */ jsx(View, { style: {
1198
+ height: laneChipHeight,
819
1199
  pointerEvents: "none"
820
1200
  } }, `lane-${i}`)),
821
1201
  hiddenCount > 0 ? /* @__PURE__ */ jsx(Text, {
822
- ...slot("more", {
823
- base: [styles$3.moreLabel, chipHeight != null && { height: chipHeight }],
824
- themed: [theme.text.more, { color: theme.colors.textMuted }]
825
- }),
1202
+ ...moreSlot,
826
1203
  onPress: onPressMore ? () => onPressMore(dayEvents, day) : () => setMoreOpenFor({
827
1204
  day,
828
1205
  events: dayEvents
@@ -830,6 +1207,7 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
830
1207
  accessibilityRole: "button",
831
1208
  accessibilityLabel: `${labels.moreEvents(hiddenCount)}, ${format(day, "d MMMM", { locale })}`,
832
1209
  allowFontScaling: false,
1210
+ numberOfLines: 1,
833
1211
  children: moreLabel.replace("{moreCount}", String(hiddenCount))
834
1212
  }) : null
835
1213
  ]
@@ -847,6 +1225,40 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
847
1225
  children: /* @__PURE__ */ jsxs(View, {
848
1226
  style: styles$3.root,
849
1227
  children: [
1228
+ showGrid ? /* @__PURE__ */ jsx(View, {
1229
+ testID: "month-more-probe",
1230
+ style: styles$3.moreProbe,
1231
+ ...webPreviewProps,
1232
+ pointerEvents: "none",
1233
+ accessible: false,
1234
+ accessibilityElementsHidden: true,
1235
+ importantForAccessibility: "no-hide-descendants",
1236
+ onLayout: (event) => {
1237
+ const { height } = event.nativeEvent.layout;
1238
+ setMeasuredMoreArea((previous) => previous === height ? previous : height);
1239
+ },
1240
+ children: /* @__PURE__ */ jsx(Text, {
1241
+ ...moreSlot,
1242
+ allowFontScaling: false,
1243
+ numberOfLines: 1,
1244
+ children: moreLabel.replace("{moreCount}", "99")
1245
+ })
1246
+ }) : null,
1247
+ gridProbe && /* @__PURE__ */ jsx(MonthGridSpacingProbe, {
1248
+ grid: gridProbe,
1249
+ weeks: weeks.length,
1250
+ onInnerHeight: setGridInnerSpacing,
1251
+ onOuterHeight: setGridOuterSpacing
1252
+ }),
1253
+ Array.from(cellStyles.probes, ([id, cell]) => cell.width > 0 && drawnWeek.width > 0 && /* @__PURE__ */ jsx(MonthCellProbe, {
1254
+ id,
1255
+ week: probeWeek,
1256
+ day: probeDay,
1257
+ cellStyle: cell.style,
1258
+ dayWidth: cell.width,
1259
+ weekWidth: drawnWeek.width,
1260
+ onMeasure: recordCell
1261
+ }, id)),
850
1262
  showTitle ? /* @__PURE__ */ jsx(Text, {
851
1263
  ...slot("title", {
852
1264
  base: styles$3.title,
@@ -909,13 +1321,14 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
909
1321
  }) : null,
910
1322
  /* @__PURE__ */ jsx(DateRowsViewport, {
911
1323
  scrollable: multiWeek,
1324
+ onHeight: setViewportHeight,
912
1325
  children: /* @__PURE__ */ jsx(MonthGridSurface, {
913
1326
  gesture: dragGesture,
914
1327
  children: /* @__PURE__ */ jsx(View, {
915
1328
  ref: gridRef,
916
1329
  testID: multiWeek ? "multiweek-grid" : "month-grid",
917
1330
  accessibilityLabel: multiWeek ? title : void 0,
918
- ...slot("grid", { base: [styles$3.container, multiWeek ? { minHeight: minimumRowHeight * weeks.length } : void 0] }),
1331
+ ...slot("grid", { base: [!multiWeekRowHeight && styles$3.container, multiWeek && { minHeight: minimumRowHeight * weeks.length + (gridProbe ? gridInnerSpacing : 0) }] }),
919
1332
  onLayout: handleLayout,
920
1333
  ...isWeb$2 && dragEnabled ? {
921
1334
  onPointerDown: pressWebGrid,
@@ -927,9 +1340,9 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
927
1340
  }
928
1341
  } : null,
929
1342
  children: weeks.map((week, weekIndex) => {
930
- const rowLayout = weekLayouts[weekIndex] ?? EMPTY_LAYOUT;
931
- const visibleLanes = monthVisibleCount(rowLayout.laneCount, capacity);
1343
+ const rowLayout = rowLayouts[weekIndex] ?? EMPTY_LAYOUT;
932
1344
  const cols = week.length;
1345
+ const { visibleLanes, extraLane } = rowLanes(rowLayout, cols);
933
1346
  let firstVisCol = 0;
934
1347
  let lastVisCol = cols - 1;
935
1348
  if (showGrid && !showAdjacentMonths) {
@@ -939,15 +1352,33 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
939
1352
  lastVisCol = cols - 1 - [...week].reverse().findIndex((d) => isSameMonth(d, date));
940
1353
  }
941
1354
  }
1355
+ const draftSegment = rowLayout.segments.find((s) => s.event === draftEvent);
1356
+ const draftStart = draftSegment ? Math.max(draftSegment.startCol, firstVisCol) : -1;
1357
+ const draftEnd = draftSegment ? Math.min(draftSegment.endCol, lastVisCol) : -1;
1358
+ const draftTop = barTop + (draftSegment?.lane ?? 0) * cellLaneHeight;
1359
+ const draftHeight = Math.min(laneChipHeight, Math.max(0, rowHeight - draftTop));
942
1360
  return /* @__PURE__ */ createElement(View, {
943
1361
  ...slot("week", {
944
- base: styles$3.weekRow,
1362
+ base: multiWeekRowHeight ? [styles$3.weekRowFixed, {
1363
+ height: multiWeekRowHeight,
1364
+ minHeight: minimumRowHeight - cellGeometry.weekMargin,
1365
+ flexGrow: 1,
1366
+ flexShrink: 1
1367
+ }] : styles$3.weekRow,
945
1368
  themed: theme.containers.weekRow
946
1369
  }),
947
- key: multiWeekGrid?.weeks[weekIndex].id ?? week[0].toISOString()
948
- }, week.map((day, dayCol) => renderDay(day, dayCol, rowLayout, visibleLanes)), showGrid ? /* @__PURE__ */ jsx(View, {
1370
+ key: multiWeekGrid?.weeks[weekIndex].id ?? week[0].toISOString(),
1371
+ onLayout: multiWeek ? (event) => {
1372
+ const { y, height, width } = event.nativeEvent.layout;
1373
+ weekTops.current[weekIndex] = y;
1374
+ if (weekIndex === 0) setDrawnWeek((previous) => previous.width === width && previous.height === height ? previous : {
1375
+ width,
1376
+ height
1377
+ });
1378
+ } : void 0
1379
+ }, week.map((day, dayCol) => renderDay(day, dayCol, rowLayout, visibleLanes + (extraLane[dayCol] ? 1 : 0))), showGrid ? /* @__PURE__ */ jsxs(View, {
949
1380
  style: [StyleSheet.absoluteFill, multiWeek ? styles$3.childrenOnlyPointerEvents : { pointerEvents: "box-none" }],
950
- children: rowLayout.segments.filter((seg) => seg.lane < visibleLanes).map((seg) => {
1381
+ children: [monthVisibleBars(rowLayout, visibleLanes, extraLane).filter((seg) => seg.event !== draftEvent).map((seg) => {
951
1382
  const startCol = Math.max(seg.startCol, firstVisCol);
952
1383
  const endCol = Math.min(seg.endCol, lastVisCol);
953
1384
  if (startCol > endCol) return null;
@@ -957,8 +1388,8 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
957
1388
  position: "absolute",
958
1389
  left: pct(startCol / cols * 100),
959
1390
  width: pct((endCol - startCol + 1) / cols * 100),
960
- top: badgeArea + seg.lane * chipMetrics.chipRowHeight,
961
- height: chipMetrics.chipHeight,
1391
+ top: barTop + seg.lane * cellLaneHeight,
1392
+ height: laneChipHeight,
962
1393
  paddingHorizontal: CHIP_INSET_H,
963
1394
  opacity: isDragged ? DRAGGED_BAR_OPACITY : 1
964
1395
  }, multiWeek ? drag ? styles$3.noPointerEvents : styles$3.childrenOnlyPointerEvents : { pointerEvents: drag ? "none" : "box-none" }],
@@ -972,8 +1403,37 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
972
1403
  },
973
1404
  onLongPress: disableMonthEventCellPress || !onLongPressEvent ? void 0 : () => onLongPressEvent(seg.event)
974
1405
  })
975
- }, `bar-${seg.event.start.toISOString()}:${seg.event.title}:${seg.lane}`);
976
- })
1406
+ }, `bar-${seg.event.start.toISOString()}:${seg.event.title}:${seg.lane}:${seg.startCol}`);
1407
+ }), RenderCreateGhost && createRange && draftStart >= 0 && draftEnd >= draftStart && draftHeight > 0 ? /* @__PURE__ */ jsx(View, {
1408
+ testID: "month-create-ghost",
1409
+ ...slot("createGhost", {
1410
+ base: {
1411
+ position: "absolute",
1412
+ left: pct(draftStart / cols * 100),
1413
+ right: pct((cols - 1 - draftEnd) / cols * 100),
1414
+ top: draftTop,
1415
+ height: draftHeight,
1416
+ marginHorizontal: CHIP_INSET_H,
1417
+ overflow: "hidden",
1418
+ zIndex: 1
1419
+ },
1420
+ themed: {
1421
+ backgroundColor: theme.colors.rangeBackground,
1422
+ borderColor: theme.colors.selectedBackground,
1423
+ borderWidth: 1,
1424
+ borderRadius: 4
1425
+ }
1426
+ }),
1427
+ ...webPreviewProps,
1428
+ pointerEvents: "none",
1429
+ accessible: false,
1430
+ accessibilityElementsHidden: true,
1431
+ importantForAccessibility: "no-hide-descendants",
1432
+ children: /* @__PURE__ */ jsx(RenderCreateGhost, {
1433
+ start: createRange.start,
1434
+ end: createRange.end
1435
+ })
1436
+ }) : null]
977
1437
  }) : null);
978
1438
  })
979
1439
  })
@@ -983,10 +1443,22 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
983
1443
  })
984
1444
  });
985
1445
  }
986
- function DateRowsViewport({ scrollable, children }) {
1446
+ function weekAtOffset(y, count, topOf) {
1447
+ let first = 0;
1448
+ let end = count;
1449
+ while (first + 1 < end) {
1450
+ const middle = Math.floor((first + end) / 2);
1451
+ if (topOf(middle) <= y) first = middle;
1452
+ else end = middle;
1453
+ }
1454
+ return first;
1455
+ }
1456
+ function DateRowsViewport({ scrollable, onHeight, children }) {
987
1457
  return scrollable ? /* @__PURE__ */ jsx(ScrollView, {
988
- style: styles$3.container,
1458
+ testID: "multiweek-viewport",
1459
+ style: styles$3.multiWeekViewport,
989
1460
  contentContainerStyle: { flexGrow: 1 },
1461
+ onLayout: (event) => onHeight(event.nativeEvent.layout.height),
990
1462
  children
991
1463
  }) : children;
992
1464
  }
@@ -1020,6 +1492,17 @@ const MonthView = memo(MonthViewInner);
1020
1492
  */
1021
1493
  const DateRows = memo(DateRowsInner);
1022
1494
  const styles$3 = StyleSheet.create({
1495
+ moreProbe: {
1496
+ position: "absolute",
1497
+ left: 0,
1498
+ top: 0,
1499
+ opacity: 0
1500
+ },
1501
+ dateWrapperStretch: { alignSelf: "stretch" },
1502
+ dayCellStacked: {
1503
+ justifyContent: "flex-start",
1504
+ alignSelf: "stretch"
1505
+ },
1023
1506
  root: { flex: 1 },
1024
1507
  title: {
1025
1508
  paddingTop: 10,
@@ -1035,19 +1518,23 @@ const styles$3 = StyleSheet.create({
1035
1518
  textAlign: "center"
1036
1519
  },
1037
1520
  container: { flex: 1 },
1521
+ multiWeekViewport: {
1522
+ flex: 1,
1523
+ ...isWeb$2 && { scrollbarGutter: "stable" }
1524
+ },
1038
1525
  childrenOnlyPointerEvents: { pointerEvents: "box-none" },
1039
1526
  noPointerEvents: { pointerEvents: "none" },
1040
1527
  weekRow: {
1041
1528
  flex: 1,
1042
1529
  flexDirection: "row"
1043
1530
  },
1531
+ weekRowFixed: { flexDirection: "row" },
1044
1532
  dayCell: {
1045
1533
  flex: 1,
1046
1534
  alignItems: "center",
1047
- paddingTop: 4,
1048
- gap: 2,
1049
1535
  overflow: "hidden"
1050
1536
  },
1537
+ dayCellPadding: { paddingTop: DAY_CELL_PADDING_TOP },
1051
1538
  dayCellEvents: { alignItems: "stretch" },
1052
1539
  dateBadge: {
1053
1540
  justifyContent: "center",
@@ -1066,7 +1553,7 @@ const styles$3 = StyleSheet.create({
1066
1553
  },
1067
1554
  monthEvent: { marginHorizontal: 4 },
1068
1555
  moreLabel: {
1069
- marginTop: 2,
1556
+ marginTop: MORE_LABEL_MARGIN_TOP,
1070
1557
  marginHorizontal: 4
1071
1558
  },
1072
1559
  moreBackdrop: {
@@ -1107,7 +1594,7 @@ function MonthPagerInner({ showAdjacentMonths = true, showSixWeeks = false, ...r
1107
1594
  spec
1108
1595
  });
1109
1596
  }
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 }) {
1597
+ 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
1598
  const theme = useCalendarTheme();
1112
1599
  const slot = useMemo(() => createSlots({
1113
1600
  classNames,
@@ -1194,20 +1681,33 @@ function DateRowsPagerInner({ spec, initialAnchor, date, events, maxVisibleEvent
1194
1681
  isRTL,
1195
1682
  hiddenDays
1196
1683
  ]);
1684
+ const nowTime = now?.getTime();
1197
1685
  const monthExtraData = useMemo(() => ({
1198
1686
  events,
1199
1687
  activeDate,
1688
+ nowTime,
1689
+ timeZone,
1200
1690
  fillCellOnSelection,
1201
1691
  dragSelect: onSelectDrag != null,
1202
1692
  chipHeight,
1203
- chipGap
1693
+ chipGap,
1694
+ renderCreateGhost,
1695
+ onCreateEvent,
1696
+ createGhostClassName: classNames?.createGhost,
1697
+ createGhostStyle: styleOverrides?.createGhost
1204
1698
  }), [
1205
1699
  events,
1206
1700
  activeDate,
1701
+ nowTime,
1702
+ timeZone,
1207
1703
  fillCellOnSelection,
1208
1704
  onSelectDrag,
1209
1705
  chipHeight,
1210
- chipGap
1706
+ chipGap,
1707
+ renderCreateGhost,
1708
+ onCreateEvent,
1709
+ classNames?.createGhost,
1710
+ styleOverrides?.createGhost
1211
1711
  ]);
1212
1712
  const selection = useMemo(() => ({
1213
1713
  selectedDates,
@@ -1255,6 +1755,8 @@ function DateRowsPagerInner({ spec, initialAnchor, date, events, maxVisibleEvent
1255
1755
  weekStartsOn,
1256
1756
  hiddenDays,
1257
1757
  locale,
1758
+ now,
1759
+ timeZone,
1258
1760
  sortedMonthView,
1259
1761
  moreLabel,
1260
1762
  labels,
@@ -1272,6 +1774,7 @@ function DateRowsPagerInner({ spec, initialAnchor, date, events, maxVisibleEvent
1272
1774
  onLongPressEvent,
1273
1775
  onPressMore,
1274
1776
  onCreateEvent,
1777
+ renderCreateGhost,
1275
1778
  onSelectDrag,
1276
1779
  fillCellOnSelection,
1277
1780
  onDragEvent,
@@ -1292,6 +1795,8 @@ function DateRowsPagerInner({ spec, initialAnchor, date, events, maxVisibleEvent
1292
1795
  weekStartsOn,
1293
1796
  hiddenDays,
1294
1797
  locale,
1798
+ now,
1799
+ timeZone,
1295
1800
  sortedMonthView,
1296
1801
  moreLabel,
1297
1802
  labels,
@@ -1310,6 +1815,7 @@ function DateRowsPagerInner({ spec, initialAnchor, date, events, maxVisibleEvent
1310
1815
  onLongPressEvent,
1311
1816
  onPressMore,
1312
1817
  onCreateEvent,
1818
+ renderCreateGhost,
1313
1819
  onSelectDrag,
1314
1820
  fillCellOnSelection,
1315
1821
  onDragEvent,