@super-calendar/native 2.18.0 → 2.20.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 +24 -4
- package/dist/{DefaultMonthEvent-B7xVeY7Q.d.ts → DefaultMonthEvent-DzgQFuVp.d.mts} +25 -7
- package/dist/{DefaultMonthEvent-hGk7wSrr.d.mts → DefaultMonthEvent-joYl8Tu2.d.ts} +25 -7
- package/dist/{MonthList-DdQxRhUy.mjs → MonthList-BGl1gTDr.mjs} +545 -100
- package/dist/{MonthList-C_NTufaK.js → MonthList-DeO-x5VW.js} +543 -98
- package/dist/index.d.mts +51 -4
- package/dist/index.d.ts +51 -4
- package/dist/index.js +107 -39
- package/dist/index.mjs +107 -39
- package/dist/picker.d.mts +1 -1
- package/dist/picker.d.ts +1 -1
- package/dist/picker.js +1 -1
- package/dist/picker.mjs +1 -1
- package/package.json +2 -2
- package/src/components/Agenda.tsx +1 -2
- package/src/components/Calendar.tsx +21 -4
- package/src/components/MonthCellProbe.tsx +201 -0
- package/src/components/MonthList.tsx +4 -2
- package/src/components/MonthPager.tsx +4 -3
- package/src/components/MonthView.tsx +532 -138
- package/src/components/ResourceTimeline.tsx +11 -2
- package/src/components/TimeGrid.tsx +176 -62
- package/src/components/YearView.tsx +0 -2
- package/src/index.tsx +2 -0
- package/src/types.ts +18 -0
|
@@ -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, nowInTimeZone, 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`
|
|
@@ -263,6 +424,7 @@ const DAY_CELL_PADDING_TOP = 4;
|
|
|
263
424
|
const DATE_BADGE_HEIGHT = 24;
|
|
264
425
|
const BAND_CENTER_Y = 16;
|
|
265
426
|
const CELL_ROW_GAP = 2;
|
|
427
|
+
const MORE_LABEL_MARGIN_TOP = 2;
|
|
266
428
|
const EMPTY_LAYOUT = {
|
|
267
429
|
segments: [],
|
|
268
430
|
laneCount: 0
|
|
@@ -309,18 +471,21 @@ function MonthViewInner({ date, showAdjacentMonths = true, showSixWeeks = false,
|
|
|
309
471
|
source
|
|
310
472
|
});
|
|
311
473
|
}
|
|
312
|
-
function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipGap
|
|
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 }) {
|
|
313
475
|
const { date } = source;
|
|
314
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;
|
|
315
481
|
const showAdjacentMonths = source.kind === "month" ? source.showAdjacentMonths : true;
|
|
316
482
|
const showSixWeeks = source.kind === "month" ? source.showSixWeeks : false;
|
|
317
483
|
const numberOfWeeks = source.kind === "multiweek" ? source.numberOfWeeks : void 0;
|
|
318
484
|
const theme = useCalendarTheme();
|
|
319
|
-
const
|
|
320
|
-
const slot = createSlots({
|
|
485
|
+
const slot = useMemo(() => createSlots({
|
|
321
486
|
classNames,
|
|
322
487
|
styles: styleOverrides
|
|
323
|
-
});
|
|
488
|
+
}), [classNames, styleOverrides]);
|
|
324
489
|
const labels = useMemo(() => resolveCalendarLabels(labelsProp), [labelsProp]);
|
|
325
490
|
const selection = useCalendarSelection();
|
|
326
491
|
const selectedDates = selectedDatesProp ?? selection.selectedDates;
|
|
@@ -334,6 +499,11 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
|
|
|
334
499
|
height: 0
|
|
335
500
|
});
|
|
336
501
|
const gridHeight = gridSize.height;
|
|
502
|
+
const weekTops = useRef([]);
|
|
503
|
+
const [drawnWeek, setDrawnWeek] = useState({
|
|
504
|
+
width: 0,
|
|
505
|
+
height: 0
|
|
506
|
+
});
|
|
337
507
|
const [hoveredKey, setHoveredKey] = useState(null);
|
|
338
508
|
const [pressedKey, setPressedKey] = useState(null);
|
|
339
509
|
const [moreOpenFor, setMoreOpenFor] = useState(null);
|
|
@@ -373,20 +543,163 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
|
|
|
373
543
|
isRTL,
|
|
374
544
|
hiddenDays
|
|
375
545
|
]);
|
|
376
|
-
const
|
|
546
|
+
const laneChipHeight = useMemo(() => {
|
|
377
547
|
const fontSize = numericStyle(theme.text.eventTitle.fontSize, 12);
|
|
378
548
|
const lineHeight = numericStyle(theme.text.eventTitle.lineHeight, Math.ceil(fontSize * 1.3));
|
|
379
|
-
|
|
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
|
+
}
|
|
380
633
|
return {
|
|
381
|
-
|
|
382
|
-
|
|
634
|
+
probes,
|
|
635
|
+
byDay
|
|
383
636
|
};
|
|
384
637
|
}, [
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
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
|
|
388
697
|
]);
|
|
389
|
-
const
|
|
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;
|
|
390
703
|
const capacity = useMemo(() => {
|
|
391
704
|
if (maxVisibleEventCount != null) return {
|
|
392
705
|
full: maxVisibleEventCount,
|
|
@@ -396,27 +709,30 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
|
|
|
396
709
|
full: FALLBACK_VISIBLE_COUNT,
|
|
397
710
|
withMore: FALLBACK_VISIBLE_COUNT
|
|
398
711
|
};
|
|
399
|
-
const
|
|
400
|
-
|
|
401
|
-
const moreRowHeight = (chipHeight ?? Math.ceil(moreFontSize * 1.3)) + chipGap;
|
|
402
|
-
const available = rowHeight - DAY_CELL_PADDING_TOP - DATE_BADGE_HEIGHT;
|
|
403
|
-
return monthEventCapacity(available, chipMetrics.chipRowHeight, moreRowHeight);
|
|
712
|
+
const available = rowHeight - dateArea - cellGeometry.bottom;
|
|
713
|
+
return monthEventCapacity(available, cellLaneHeight, moreLabelArea + cellGeometry.gap);
|
|
404
714
|
}, [
|
|
405
715
|
maxVisibleEventCount,
|
|
406
716
|
gridHeight,
|
|
407
717
|
weeks.length,
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
718
|
+
rowHeight,
|
|
719
|
+
dateArea,
|
|
720
|
+
cellGeometry,
|
|
721
|
+
cellLaneHeight,
|
|
722
|
+
moreLabelArea
|
|
412
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]);
|
|
413
731
|
const eventsByDay = useMemo(() => {
|
|
414
732
|
const map = groupEventsByDay(events.filter((event) => !isBackgroundEvent(event)));
|
|
415
733
|
if (sortedMonthView) for (const list of map.values()) list.sort(compareDayEvents);
|
|
416
734
|
return map;
|
|
417
735
|
}, [events, sortedMonthView]);
|
|
418
|
-
const createContentEnabled = onCreateEvent != null && RenderCreateGhost != null;
|
|
419
|
-
const showGrid = multiWeek || events.length > 0 || createContentEnabled;
|
|
420
736
|
const weekLayouts = useMemo(() => showGrid ? weeks.map((week) => layoutMonthWeek(week, collectRowEvents(week, eventsByDay))) : [], [
|
|
421
737
|
showGrid,
|
|
422
738
|
weeks,
|
|
@@ -428,6 +744,31 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
|
|
|
428
744
|
const heldOrigin = useRef(null);
|
|
429
745
|
const [drag, setDrag] = useState(null);
|
|
430
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
|
+
]);
|
|
431
772
|
const dragRef = useRef(null);
|
|
432
773
|
const interactionWindow = useRef(windowKey);
|
|
433
774
|
interactionWindow.current = windowKey;
|
|
@@ -477,8 +818,19 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
|
|
|
477
818
|
const hitTest = useCallback((x, y) => {
|
|
478
819
|
const { width, height } = gridSize;
|
|
479
820
|
if (width <= 0 || height <= 0 || weeks.length === 0) return null;
|
|
480
|
-
|
|
481
|
-
|
|
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
|
+
}
|
|
482
834
|
const cols = weeks[row].length;
|
|
483
835
|
const col = Math.min(cols - 1, Math.max(0, Math.floor(x / (width / cols))));
|
|
484
836
|
const day = weeks[row][col];
|
|
@@ -490,19 +842,25 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
|
|
|
490
842
|
isDateDisabled
|
|
491
843
|
})) return null;
|
|
492
844
|
const rowLayout = weekLayouts[row] ?? EMPTY_LAYOUT;
|
|
493
|
-
const
|
|
494
|
-
const
|
|
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);
|
|
495
849
|
return {
|
|
496
850
|
day,
|
|
497
|
-
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
|
|
498
852
|
};
|
|
499
853
|
}, [
|
|
500
854
|
gridSize,
|
|
501
855
|
weeks,
|
|
502
856
|
weekLayouts,
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
857
|
+
rowLanes,
|
|
858
|
+
multiWeek,
|
|
859
|
+
rowHeight,
|
|
860
|
+
cellGeometry.weekMarginTop,
|
|
861
|
+
laneChipHeight,
|
|
862
|
+
laneTop,
|
|
863
|
+
cellLaneHeight,
|
|
506
864
|
showAdjacentMonths,
|
|
507
865
|
date,
|
|
508
866
|
minDate,
|
|
@@ -678,10 +1036,14 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
|
|
|
678
1036
|
heldOrigin.current = null;
|
|
679
1037
|
});
|
|
680
1038
|
};
|
|
681
|
-
const renderDay = (day, dayCol, rowLayout,
|
|
1039
|
+
const renderDay = (day, dayCol, rowLayout, dayLanes) => {
|
|
682
1040
|
const isCurrentMonth = multiWeek || isSameMonth(day, date);
|
|
683
1041
|
if (!isCurrentMonth && !showAdjacentMonths) return /* @__PURE__ */ jsx(View, { ...slot("day", {
|
|
684
|
-
base: [
|
|
1042
|
+
base: [
|
|
1043
|
+
styles$3.dayCell,
|
|
1044
|
+
styles$3.dayCellPadding,
|
|
1045
|
+
{ gap: chipGap }
|
|
1046
|
+
],
|
|
685
1047
|
themed: [showGrid && {
|
|
686
1048
|
borderTopWidth: StyleSheet.hairlineWidth,
|
|
687
1049
|
borderRightWidth: StyleSheet.hairlineWidth,
|
|
@@ -699,7 +1061,7 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
|
|
|
699
1061
|
maxDate,
|
|
700
1062
|
isDateDisabled
|
|
701
1063
|
});
|
|
702
|
-
const hiddenCount = rowLayout.segments.filter((s) => s.startCol <= dayCol && s.endCol >= dayCol && s.lane >=
|
|
1064
|
+
const hiddenCount = rowLayout.segments.filter((s) => s.startCol <= dayCol && s.endCol >= dayCol && s.lane >= dayLanes && s.event !== draftEvent).map((s) => s.event).length;
|
|
703
1065
|
const isFilledBadge = dayBadgeKind({ isSelected }, isHighlighted) !== "none";
|
|
704
1066
|
const hasBand = rangeBandKind({
|
|
705
1067
|
isInRange,
|
|
@@ -707,6 +1069,10 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
|
|
|
707
1069
|
isRangeEnd
|
|
708
1070
|
}, fillCellOnSelection) !== "none";
|
|
709
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;
|
|
710
1076
|
const isDragPreview = isInCreateSpan(drag, day) || drag?.kind === "move" && isSameCalendarDay(day, drag.to) && !isSameCalendarDay(day, drag.from);
|
|
711
1077
|
const isHovered = isWeb$2 && !isDisabled && !showGrid && hoveredKey === dayKey;
|
|
712
1078
|
const dateColor = isDisabled ? theme.colors.textDisabled : isFilledBadge ? isHighlighted ? theme.colors.todayText : theme.colors.selectedText : isCurrentMonth ? theme.colors.text : theme.colors.textDisabled;
|
|
@@ -725,18 +1091,40 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
|
|
|
725
1091
|
eventCount,
|
|
726
1092
|
labels
|
|
727
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
|
+
});
|
|
728
1124
|
const daySlot = slot("day", {
|
|
729
|
-
base:
|
|
730
|
-
styles$3.dayCell,
|
|
731
|
-
{ gap: chipGap },
|
|
732
|
-
showGrid && styles$3.dayCellEvents
|
|
733
|
-
],
|
|
1125
|
+
base: dayCellBase,
|
|
734
1126
|
themed: [
|
|
735
|
-
|
|
736
|
-
borderTopWidth: StyleSheet.hairlineWidth,
|
|
737
|
-
borderRightWidth: StyleSheet.hairlineWidth,
|
|
738
|
-
borderColor: theme.colors.gridLine
|
|
739
|
-
},
|
|
1127
|
+
dayCellLines,
|
|
740
1128
|
highlightWeekends && isWeekend(day) && { backgroundColor: theme.colors.weekendBackground },
|
|
741
1129
|
isDragPreview && { backgroundColor: theme.colors.rangeBackground },
|
|
742
1130
|
theme.containers.dayCell
|
|
@@ -744,7 +1132,12 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
|
|
|
744
1132
|
});
|
|
745
1133
|
return /* @__PURE__ */ jsxs(TouchableOpacity, {
|
|
746
1134
|
...daySlot,
|
|
747
|
-
style: [
|
|
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,
|
|
748
1141
|
activeOpacity: showGrid ? .2 : 1,
|
|
749
1142
|
...showGrid ? null : {
|
|
750
1143
|
onPressIn: () => setPressedKey(dayKey),
|
|
@@ -796,40 +1189,17 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
|
|
|
796
1189
|
themed: { backgroundColor: theme.colors.rangeBackground }
|
|
797
1190
|
})
|
|
798
1191
|
}) : null,
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
themed: [
|
|
807
|
-
isFilledBadge && {
|
|
808
|
-
backgroundColor: isHighlighted ? theme.colors.todayBackground : theme.colors.selectedBackground,
|
|
809
|
-
borderRadius: theme.todayBadgeRadius
|
|
810
|
-
},
|
|
811
|
-
isHovered && !isFilledBadge && {
|
|
812
|
-
backgroundColor: theme.colors.hoverBackground,
|
|
813
|
-
borderRadius: theme.todayBadgeRadius
|
|
814
|
-
},
|
|
815
|
-
theme.containers.dayBadge
|
|
816
|
-
]
|
|
817
|
-
}),
|
|
818
|
-
children: /* @__PURE__ */ jsx(Text, {
|
|
819
|
-
...slot("dayBadgeText", { themed: [theme.text.dateCell, { color: dateColor }] }),
|
|
820
|
-
allowFontScaling: false,
|
|
821
|
-
children: format(day, "d")
|
|
822
|
-
})
|
|
823
|
-
}),
|
|
824
|
-
Array.from({ length: visibleLanes }, (_, i) => /* @__PURE__ */ jsx(View, { style: {
|
|
825
|
-
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,
|
|
826
1199
|
pointerEvents: "none"
|
|
827
1200
|
} }, `lane-${i}`)),
|
|
828
1201
|
hiddenCount > 0 ? /* @__PURE__ */ jsx(Text, {
|
|
829
|
-
...
|
|
830
|
-
base: [styles$3.moreLabel, chipHeight != null && { height: chipHeight }],
|
|
831
|
-
themed: [theme.text.more, { color: theme.colors.textMuted }]
|
|
832
|
-
}),
|
|
1202
|
+
...moreSlot,
|
|
833
1203
|
onPress: onPressMore ? () => onPressMore(dayEvents, day) : () => setMoreOpenFor({
|
|
834
1204
|
day,
|
|
835
1205
|
events: dayEvents
|
|
@@ -837,6 +1207,7 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
|
|
|
837
1207
|
accessibilityRole: "button",
|
|
838
1208
|
accessibilityLabel: `${labels.moreEvents(hiddenCount)}, ${format(day, "d MMMM", { locale })}`,
|
|
839
1209
|
allowFontScaling: false,
|
|
1210
|
+
numberOfLines: 1,
|
|
840
1211
|
children: moreLabel.replace("{moreCount}", String(hiddenCount))
|
|
841
1212
|
}) : null
|
|
842
1213
|
]
|
|
@@ -854,6 +1225,40 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
|
|
|
854
1225
|
children: /* @__PURE__ */ jsxs(View, {
|
|
855
1226
|
style: styles$3.root,
|
|
856
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)),
|
|
857
1262
|
showTitle ? /* @__PURE__ */ jsx(Text, {
|
|
858
1263
|
...slot("title", {
|
|
859
1264
|
base: styles$3.title,
|
|
@@ -916,13 +1321,14 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
|
|
|
916
1321
|
}) : null,
|
|
917
1322
|
/* @__PURE__ */ jsx(DateRowsViewport, {
|
|
918
1323
|
scrollable: multiWeek,
|
|
1324
|
+
onHeight: setViewportHeight,
|
|
919
1325
|
children: /* @__PURE__ */ jsx(MonthGridSurface, {
|
|
920
1326
|
gesture: dragGesture,
|
|
921
1327
|
children: /* @__PURE__ */ jsx(View, {
|
|
922
1328
|
ref: gridRef,
|
|
923
1329
|
testID: multiWeek ? "multiweek-grid" : "month-grid",
|
|
924
1330
|
accessibilityLabel: multiWeek ? title : void 0,
|
|
925
|
-
...slot("grid", { base: [styles$3.container, multiWeek
|
|
1331
|
+
...slot("grid", { base: [!multiWeekRowHeight && styles$3.container, multiWeek && { minHeight: minimumRowHeight * weeks.length + (gridProbe ? gridInnerSpacing : 0) }] }),
|
|
926
1332
|
onLayout: handleLayout,
|
|
927
1333
|
...isWeb$2 && dragEnabled ? {
|
|
928
1334
|
onPointerDown: pressWebGrid,
|
|
@@ -934,9 +1340,9 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
|
|
|
934
1340
|
}
|
|
935
1341
|
} : null,
|
|
936
1342
|
children: weeks.map((week, weekIndex) => {
|
|
937
|
-
const rowLayout =
|
|
938
|
-
const visibleLanes = monthVisibleCount(rowLayout.laneCount, capacity);
|
|
1343
|
+
const rowLayout = rowLayouts[weekIndex] ?? EMPTY_LAYOUT;
|
|
939
1344
|
const cols = week.length;
|
|
1345
|
+
const { visibleLanes, extraLane } = rowLanes(rowLayout, cols);
|
|
940
1346
|
let firstVisCol = 0;
|
|
941
1347
|
let lastVisCol = cols - 1;
|
|
942
1348
|
if (showGrid && !showAdjacentMonths) {
|
|
@@ -946,21 +1352,33 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
|
|
|
946
1352
|
lastVisCol = cols - 1 - [...week].reverse().findIndex((d) => isSameMonth(d, date));
|
|
947
1353
|
}
|
|
948
1354
|
}
|
|
949
|
-
const
|
|
950
|
-
const draftStart =
|
|
951
|
-
const draftEnd =
|
|
952
|
-
const
|
|
953
|
-
const
|
|
954
|
-
const draftHeight = Math.min(chipMetrics.chipHeight, Math.max(0, gridHeight / weeks.length - draftTop));
|
|
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));
|
|
955
1360
|
return /* @__PURE__ */ createElement(View, {
|
|
956
1361
|
...slot("week", {
|
|
957
|
-
base: styles$3.
|
|
1362
|
+
base: multiWeekRowHeight ? [styles$3.weekRowFixed, {
|
|
1363
|
+
height: multiWeekRowHeight,
|
|
1364
|
+
minHeight: minimumRowHeight - cellGeometry.weekMargin,
|
|
1365
|
+
flexGrow: 1,
|
|
1366
|
+
flexShrink: 1
|
|
1367
|
+
}] : styles$3.weekRow,
|
|
958
1368
|
themed: theme.containers.weekRow
|
|
959
1369
|
}),
|
|
960
|
-
key: multiWeekGrid?.weeks[weekIndex].id ?? week[0].toISOString()
|
|
961
|
-
|
|
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, {
|
|
962
1380
|
style: [StyleSheet.absoluteFill, multiWeek ? styles$3.childrenOnlyPointerEvents : { pointerEvents: "box-none" }],
|
|
963
|
-
children: [rowLayout.
|
|
1381
|
+
children: [monthVisibleBars(rowLayout, visibleLanes, extraLane).filter((seg) => seg.event !== draftEvent).map((seg) => {
|
|
964
1382
|
const startCol = Math.max(seg.startCol, firstVisCol);
|
|
965
1383
|
const endCol = Math.min(seg.endCol, lastVisCol);
|
|
966
1384
|
if (startCol > endCol) return null;
|
|
@@ -970,8 +1388,8 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
|
|
|
970
1388
|
position: "absolute",
|
|
971
1389
|
left: pct(startCol / cols * 100),
|
|
972
1390
|
width: pct((endCol - startCol + 1) / cols * 100),
|
|
973
|
-
top:
|
|
974
|
-
height:
|
|
1391
|
+
top: barTop + seg.lane * cellLaneHeight,
|
|
1392
|
+
height: laneChipHeight,
|
|
975
1393
|
paddingHorizontal: CHIP_INSET_H,
|
|
976
1394
|
opacity: isDragged ? DRAGGED_BAR_OPACITY : 1
|
|
977
1395
|
}, multiWeek ? drag ? styles$3.noPointerEvents : styles$3.childrenOnlyPointerEvents : { pointerEvents: drag ? "none" : "box-none" }],
|
|
@@ -985,8 +1403,8 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
|
|
|
985
1403
|
},
|
|
986
1404
|
onLongPress: disableMonthEventCellPress || !onLongPressEvent ? void 0 : () => onLongPressEvent(seg.event)
|
|
987
1405
|
})
|
|
988
|
-
}, `bar-${seg.event.start.toISOString()}:${seg.event.title}:${seg.lane}`);
|
|
989
|
-
}), RenderCreateGhost && createRange && draftStart
|
|
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, {
|
|
990
1408
|
testID: "month-create-ghost",
|
|
991
1409
|
...slot("createGhost", {
|
|
992
1410
|
base: {
|
|
@@ -1025,10 +1443,22 @@ function DateRowsInner({ source, events, maxVisibleEventCount, chipHeight, chipG
|
|
|
1025
1443
|
})
|
|
1026
1444
|
});
|
|
1027
1445
|
}
|
|
1028
|
-
function
|
|
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 }) {
|
|
1029
1457
|
return scrollable ? /* @__PURE__ */ jsx(ScrollView, {
|
|
1030
|
-
|
|
1458
|
+
testID: "multiweek-viewport",
|
|
1459
|
+
style: styles$3.multiWeekViewport,
|
|
1031
1460
|
contentContainerStyle: { flexGrow: 1 },
|
|
1461
|
+
onLayout: (event) => onHeight(event.nativeEvent.layout.height),
|
|
1032
1462
|
children
|
|
1033
1463
|
}) : children;
|
|
1034
1464
|
}
|
|
@@ -1062,6 +1492,17 @@ const MonthView = memo(MonthViewInner);
|
|
|
1062
1492
|
*/
|
|
1063
1493
|
const DateRows = memo(DateRowsInner);
|
|
1064
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
|
+
},
|
|
1065
1506
|
root: { flex: 1 },
|
|
1066
1507
|
title: {
|
|
1067
1508
|
paddingTop: 10,
|
|
@@ -1077,19 +1518,23 @@ const styles$3 = StyleSheet.create({
|
|
|
1077
1518
|
textAlign: "center"
|
|
1078
1519
|
},
|
|
1079
1520
|
container: { flex: 1 },
|
|
1521
|
+
multiWeekViewport: {
|
|
1522
|
+
flex: 1,
|
|
1523
|
+
...isWeb$2 && { scrollbarGutter: "stable" }
|
|
1524
|
+
},
|
|
1080
1525
|
childrenOnlyPointerEvents: { pointerEvents: "box-none" },
|
|
1081
1526
|
noPointerEvents: { pointerEvents: "none" },
|
|
1082
1527
|
weekRow: {
|
|
1083
1528
|
flex: 1,
|
|
1084
1529
|
flexDirection: "row"
|
|
1085
1530
|
},
|
|
1531
|
+
weekRowFixed: { flexDirection: "row" },
|
|
1086
1532
|
dayCell: {
|
|
1087
1533
|
flex: 1,
|
|
1088
1534
|
alignItems: "center",
|
|
1089
|
-
paddingTop: 4,
|
|
1090
|
-
gap: 2,
|
|
1091
1535
|
overflow: "hidden"
|
|
1092
1536
|
},
|
|
1537
|
+
dayCellPadding: { paddingTop: DAY_CELL_PADDING_TOP },
|
|
1093
1538
|
dayCellEvents: { alignItems: "stretch" },
|
|
1094
1539
|
dateBadge: {
|
|
1095
1540
|
justifyContent: "center",
|
|
@@ -1108,7 +1553,7 @@ const styles$3 = StyleSheet.create({
|
|
|
1108
1553
|
},
|
|
1109
1554
|
monthEvent: { marginHorizontal: 4 },
|
|
1110
1555
|
moreLabel: {
|
|
1111
|
-
marginTop:
|
|
1556
|
+
marginTop: MORE_LABEL_MARGIN_TOP,
|
|
1112
1557
|
marginHorizontal: 4
|
|
1113
1558
|
},
|
|
1114
1559
|
moreBackdrop: {
|