@super-calendar/native 2.15.0 → 2.17.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 +63 -0
- package/dist/{DefaultMonthEvent-BDD7GgL8.d.mts → DefaultMonthEvent-C3C30hfV.d.mts} +7 -21
- package/dist/{DefaultMonthEvent-ggwYo7Fy.d.ts → DefaultMonthEvent-Dx3lD7ig.d.ts} +7 -21
- package/dist/{MonthList-D4_LBnbU.js → MonthList-B2TSGYp7.js} +409 -109
- package/dist/{MonthList-DWCH3GT5.mjs → MonthList-N1GVDIE4.mjs} +400 -112
- package/dist/index.d.mts +50 -16
- package/dist/index.d.ts +50 -16
- package/dist/index.js +375 -46
- package/dist/index.mjs +370 -47
- package/dist/picker.d.mts +1 -1
- package/dist/picker.d.ts +1 -1
- package/dist/picker.js +1 -1
- package/dist/picker.mjs +1 -1
- package/package.json +2 -2
- package/src/components/Calendar.tsx +83 -9
- package/src/components/MonthPager.tsx +175 -20
- package/src/components/MonthView.tsx +332 -116
- package/src/components/MultiWeekView.tsx +34 -0
- package/src/components/ResourceTimeline.tsx +153 -4
- package/src/components/TimeGrid.tsx +241 -7
- package/src/index.tsx +8 -0
- package/src/types.ts +1 -0
- package/src/utils/holdWebDateDrag.ts +63 -0
|
@@ -5,7 +5,7 @@ let react_native = require("react-native");
|
|
|
5
5
|
let react_native_gesture_handler = require("react-native-gesture-handler");
|
|
6
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
7
|
let _legendapp_list_react_native = require("@legendapp/list/react-native");
|
|
8
|
-
|
|
8
|
+
// src/theme.ts
|
|
9
9
|
/** The default light theme. Every key the calendar reads falls back to this. */
|
|
10
10
|
const defaultTheme = {
|
|
11
11
|
colors: _super_calendar_core.lightColors,
|
|
@@ -103,8 +103,7 @@ const CalendarThemeContext = (0, react.createContext)(defaultTheme);
|
|
|
103
103
|
const CalendarThemeProvider = CalendarThemeContext.Provider;
|
|
104
104
|
/** Read the active {@link CalendarTheme} from context. Useful inside custom renderers. */
|
|
105
105
|
const useCalendarTheme = () => (0, react.useContext)(CalendarThemeContext);
|
|
106
|
-
|
|
107
|
-
//#region src/utils/labels.ts
|
|
106
|
+
// src/utils/labels.ts
|
|
108
107
|
/**
|
|
109
108
|
* The resolved `labels` of the nearest view, so the built-in event renderers
|
|
110
109
|
* can localize their screen-reader text without a prop on `RenderEventArgs`.
|
|
@@ -113,8 +112,7 @@ const CalendarLabelsContext = (0, react.createContext)(_super_calendar_core.defa
|
|
|
113
112
|
function useCalendarLabels() {
|
|
114
113
|
return (0, react.useContext)(CalendarLabelsContext);
|
|
115
114
|
}
|
|
116
|
-
|
|
117
|
-
//#region src/utils/slots.ts
|
|
115
|
+
// src/utils/slots.ts
|
|
118
116
|
/**
|
|
119
117
|
* Build a slot resolver for one render. `slot(name, defaults)` returns the
|
|
120
118
|
* props to spread on that element: the resolved `style` array and, when the
|
|
@@ -147,8 +145,7 @@ function useSlots() {
|
|
|
147
145
|
const maps = (0, react.useContext)(SlotStylesContext);
|
|
148
146
|
return (0, react.useMemo)(() => createSlots(maps), [maps]);
|
|
149
147
|
}
|
|
150
|
-
|
|
151
|
-
//#region src/utils/useWebPagerKeys.ts
|
|
148
|
+
// src/utils/useWebPagerKeys.ts
|
|
152
149
|
const getDocument = () => globalThis.document;
|
|
153
150
|
const isTextEntry = (element) => {
|
|
154
151
|
const tag = element?.tagName;
|
|
@@ -179,8 +176,7 @@ function useWebPagerKeys(enabled, onPage) {
|
|
|
179
176
|
return () => doc.removeEventListener("keydown", handler);
|
|
180
177
|
}, [enabled, onPage]);
|
|
181
178
|
}
|
|
182
|
-
|
|
183
|
-
//#region src/utils/withEventAccessibilityLabel.tsx
|
|
179
|
+
// src/utils/withEventAccessibilityLabel.tsx
|
|
184
180
|
/**
|
|
185
181
|
* Wrap an event renderer so it injects a consumer's `eventAccessibilityLabel`
|
|
186
182
|
* override into `RenderEventArgs.accessibilityLabel`. The built-in renderers use
|
|
@@ -202,8 +198,62 @@ function withEventAccessibilityLabel(renderEvent, labeler, ampm) {
|
|
|
202
198
|
});
|
|
203
199
|
};
|
|
204
200
|
}
|
|
205
|
-
|
|
206
|
-
|
|
201
|
+
// src/utils/holdWebDateDrag.ts
|
|
202
|
+
/** Keep quick swipes scrollable, then let a held pointer own the date-row drag. */
|
|
203
|
+
function holdWebDateDrag(node, pointer, start, move, cancel, release) {
|
|
204
|
+
const doc = node.ownerDocument;
|
|
205
|
+
let active = false;
|
|
206
|
+
let finished = false;
|
|
207
|
+
const detach = () => {
|
|
208
|
+
clearTimeout(timer);
|
|
209
|
+
doc.removeEventListener("pointermove", onMove);
|
|
210
|
+
doc.removeEventListener("pointerup", onUp);
|
|
211
|
+
doc.removeEventListener("pointercancel", onCancel);
|
|
212
|
+
doc.removeEventListener("pointerdown", onAnotherPointer);
|
|
213
|
+
doc.removeEventListener("touchmove", onTouchMove);
|
|
214
|
+
doc.removeEventListener("contextmenu", onContextMenu);
|
|
215
|
+
};
|
|
216
|
+
const stop = () => {
|
|
217
|
+
if (finished) return;
|
|
218
|
+
finished = true;
|
|
219
|
+
detach();
|
|
220
|
+
cancel();
|
|
221
|
+
release();
|
|
222
|
+
};
|
|
223
|
+
const onMove = (event) => {
|
|
224
|
+
if (event.pointerId !== pointer.pointerId) return;
|
|
225
|
+
if (active) move(event.clientX, event.clientY);
|
|
226
|
+
else if (Math.hypot(event.clientX - pointer.clientX, event.clientY - pointer.clientY) > 8) stop();
|
|
227
|
+
};
|
|
228
|
+
const onUp = (event) => {
|
|
229
|
+
if (event.pointerId !== pointer.pointerId) return;
|
|
230
|
+
finished = true;
|
|
231
|
+
detach();
|
|
232
|
+
release();
|
|
233
|
+
};
|
|
234
|
+
const onCancel = (event) => {
|
|
235
|
+
if (event.pointerId === pointer.pointerId) stop();
|
|
236
|
+
};
|
|
237
|
+
const onAnotherPointer = (event) => {
|
|
238
|
+
if (event.pointerId !== pointer.pointerId) stop();
|
|
239
|
+
};
|
|
240
|
+
const onTouchMove = (event) => {
|
|
241
|
+
if (active && event.cancelable) event.preventDefault();
|
|
242
|
+
};
|
|
243
|
+
const onContextMenu = (event) => event.preventDefault();
|
|
244
|
+
const timer = setTimeout(() => {
|
|
245
|
+
active = true;
|
|
246
|
+
start();
|
|
247
|
+
}, 400);
|
|
248
|
+
doc.addEventListener("pointermove", onMove);
|
|
249
|
+
doc.addEventListener("pointerup", onUp);
|
|
250
|
+
doc.addEventListener("pointercancel", onCancel);
|
|
251
|
+
doc.addEventListener("pointerdown", onAnotherPointer);
|
|
252
|
+
doc.addEventListener("touchmove", onTouchMove, { passive: false });
|
|
253
|
+
doc.addEventListener("contextmenu", onContextMenu);
|
|
254
|
+
return stop;
|
|
255
|
+
}
|
|
256
|
+
// src/components/MonthView.tsx
|
|
207
257
|
const isWeb$2 = react_native.Platform.OS === "web";
|
|
208
258
|
const DAY_CELL_PADDING_TOP = 4;
|
|
209
259
|
const DATE_BADGE_HEIGHT = 24;
|
|
@@ -239,7 +289,28 @@ function isInCreateSpan(drag, day) {
|
|
|
239
289
|
const b = (0, date_fns.startOfDay)(drag.hover).getTime();
|
|
240
290
|
return time >= Math.min(a, b) && time <= Math.max(a, b);
|
|
241
291
|
}
|
|
242
|
-
function MonthViewInner({ date,
|
|
292
|
+
function MonthViewInner({ date, showAdjacentMonths = true, showSixWeeks = false, ...rest }) {
|
|
293
|
+
const source = (0, react.useMemo)(() => ({
|
|
294
|
+
kind: "month",
|
|
295
|
+
date,
|
|
296
|
+
showAdjacentMonths,
|
|
297
|
+
showSixWeeks
|
|
298
|
+
}), [
|
|
299
|
+
date,
|
|
300
|
+
showAdjacentMonths,
|
|
301
|
+
showSixWeeks
|
|
302
|
+
]);
|
|
303
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DateRows, {
|
|
304
|
+
...rest,
|
|
305
|
+
source
|
|
306
|
+
});
|
|
307
|
+
}
|
|
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 }) {
|
|
309
|
+
const { date } = source;
|
|
310
|
+
const multiWeek = source.kind === "multiweek";
|
|
311
|
+
const showAdjacentMonths = source.kind === "month" ? source.showAdjacentMonths : true;
|
|
312
|
+
const showSixWeeks = source.kind === "month" ? source.showSixWeeks : false;
|
|
313
|
+
const numberOfWeeks = source.kind === "multiweek" ? source.numberOfWeeks : void 0;
|
|
243
314
|
const theme = useCalendarTheme();
|
|
244
315
|
const badgeArea = 28 + chipGap;
|
|
245
316
|
const slot = createSlots({
|
|
@@ -262,17 +333,32 @@ function MonthViewInner({ date, events, maxVisibleEventCount, chipHeight, chipGa
|
|
|
262
333
|
const [hoveredKey, setHoveredKey] = (0, react.useState)(null);
|
|
263
334
|
const [pressedKey, setPressedKey] = (0, react.useState)(null);
|
|
264
335
|
const [moreOpenFor, setMoreOpenFor] = (0, react.useState)(null);
|
|
265
|
-
const
|
|
336
|
+
const multiWeekGrid = (0, react.useMemo)(() => numberOfWeeks === void 0 ? null : (0, _super_calendar_core.buildMultiWeekGrid)(date, {
|
|
337
|
+
numberOfWeeks,
|
|
338
|
+
weekStartsOn,
|
|
339
|
+
isRTL,
|
|
340
|
+
hiddenDays
|
|
341
|
+
}), [
|
|
342
|
+
date,
|
|
343
|
+
numberOfWeeks,
|
|
344
|
+
weekStartsOn,
|
|
345
|
+
isRTL,
|
|
346
|
+
hiddenDays
|
|
347
|
+
]);
|
|
348
|
+
const weeks = (0, react.useMemo)(() => multiWeekGrid ? multiWeekGrid.weeks.map((week) => week.days.map((day) => day.date)) : (0, _super_calendar_core.buildMonthWeeks)(date, weekStartsOn, {
|
|
266
349
|
showSixWeeks,
|
|
267
350
|
isRTL,
|
|
268
351
|
hiddenDays
|
|
269
352
|
}), [
|
|
353
|
+
multiWeekGrid,
|
|
270
354
|
date,
|
|
271
355
|
weekStartsOn,
|
|
272
356
|
isRTL,
|
|
273
357
|
showSixWeeks,
|
|
274
358
|
hiddenDays
|
|
275
359
|
]);
|
|
360
|
+
const title = multiWeekGrid ? `${(0, date_fns.format)(multiWeekGrid.visibleRange.start, "PP", { locale })} – ${(0, date_fns.format)((0, date_fns.addDays)(multiWeekGrid.visibleRange.endExclusive, -1), "PP", { locale })}` : (0, date_fns.format)(date, "MMMM yyyy", { locale });
|
|
361
|
+
const windowKey = multiWeekGrid ? `${multiWeekGrid.period.start.getTime()}:${numberOfWeeks}:${hiddenDays?.join(",")}:${isRTL}` : null;
|
|
276
362
|
const weekdayLabels = (0, react.useMemo)(() => {
|
|
277
363
|
const days = (0, _super_calendar_core.filterHiddenDays)((0, _super_calendar_core.getWeekDays)(date, weekStartsOn), hiddenDays);
|
|
278
364
|
return isRTL ? days.reverse() : days;
|
|
@@ -295,6 +381,7 @@ function MonthViewInner({ date, events, maxVisibleEventCount, chipHeight, chipGa
|
|
|
295
381
|
chipHeight,
|
|
296
382
|
chipGap
|
|
297
383
|
]);
|
|
384
|
+
const minimumRowHeight = badgeArea + Math.max(1, maxVisibleEventCount ?? FALLBACK_VISIBLE_COUNT) * chipMetrics.chipRowHeight;
|
|
298
385
|
const capacity = (0, react.useMemo)(() => {
|
|
299
386
|
if (maxVisibleEventCount != null) return {
|
|
300
387
|
full: maxVisibleEventCount,
|
|
@@ -323,7 +410,7 @@ function MonthViewInner({ date, events, maxVisibleEventCount, chipHeight, chipGa
|
|
|
323
410
|
if (sortedMonthView) for (const list of map.values()) list.sort(_super_calendar_core.compareDayEvents);
|
|
324
411
|
return map;
|
|
325
412
|
}, [events, sortedMonthView]);
|
|
326
|
-
const showGrid = events.length > 0;
|
|
413
|
+
const showGrid = multiWeek || events.length > 0;
|
|
327
414
|
const weekLayouts = (0, react.useMemo)(() => showGrid ? weeks.map((week) => (0, _super_calendar_core.layoutMonthWeek)(week, collectRowEvents(week, eventsByDay))) : [], [
|
|
328
415
|
showGrid,
|
|
329
416
|
weeks,
|
|
@@ -331,20 +418,55 @@ function MonthViewInner({ date, events, maxVisibleEventCount, chipHeight, chipGa
|
|
|
331
418
|
]);
|
|
332
419
|
const dragEnabled = onCreateEvent != null || onSelectDrag != null || onDragEvent != null;
|
|
333
420
|
const gridRef = (0, react.useRef)(null);
|
|
421
|
+
const heldTouch = (0, react.useRef)(null);
|
|
422
|
+
const heldOrigin = (0, react.useRef)(null);
|
|
334
423
|
const [drag, setDrag] = (0, react.useState)(null);
|
|
335
424
|
const dragRef = (0, react.useRef)(null);
|
|
425
|
+
const interactionWindow = (0, react.useRef)(windowKey);
|
|
426
|
+
interactionWindow.current = windowKey;
|
|
427
|
+
const mounted = (0, react.useRef)(true);
|
|
428
|
+
(0, react.useEffect)(() => {
|
|
429
|
+
mounted.current = true;
|
|
430
|
+
return () => {
|
|
431
|
+
mounted.current = false;
|
|
432
|
+
dragRef.current = null;
|
|
433
|
+
};
|
|
434
|
+
}, []);
|
|
336
435
|
const movedRef = (0, react.useRef)(false);
|
|
337
436
|
const suppressPressRef = (0, react.useRef)(false);
|
|
338
437
|
const applyDrag = (0, react.useCallback)((next) => {
|
|
339
438
|
dragRef.current = next;
|
|
340
439
|
setDrag(next);
|
|
341
440
|
}, []);
|
|
441
|
+
(0, react.useEffect)(() => {
|
|
442
|
+
if (windowKey === null) return;
|
|
443
|
+
applyDrag(null);
|
|
444
|
+
setMoreOpenFor(null);
|
|
445
|
+
return () => {
|
|
446
|
+
dragRef.current = null;
|
|
447
|
+
};
|
|
448
|
+
}, [windowKey, applyDrag]);
|
|
449
|
+
(0, react.useEffect)(() => () => {
|
|
450
|
+
heldTouch.current?.();
|
|
451
|
+
}, [windowKey]);
|
|
342
452
|
const consumeSuppressedPress = (0, react.useCallback)(() => {
|
|
343
453
|
if (!suppressPressRef.current) return false;
|
|
344
454
|
suppressPressRef.current = false;
|
|
345
455
|
return true;
|
|
346
456
|
}, []);
|
|
347
457
|
const canMoveEvent = (0, react.useCallback)((event) => !event.disabled && event.draggable !== false && (event.startEditable ?? eventStartEditable), [eventStartEditable]);
|
|
458
|
+
(0, react.useEffect)(() => {
|
|
459
|
+
const origin = heldOrigin.current;
|
|
460
|
+
if (!origin) return;
|
|
461
|
+
const current = dragRef.current;
|
|
462
|
+
const destination = current ? current.kind === "create" ? current.hover : current.to : origin.day;
|
|
463
|
+
const constraints = {
|
|
464
|
+
minDate,
|
|
465
|
+
maxDate,
|
|
466
|
+
isDateDisabled
|
|
467
|
+
};
|
|
468
|
+
if (!(0, _super_calendar_core.isDateSelectable)(origin.day, constraints) || !(0, _super_calendar_core.isDateSelectable)(destination, constraints) || (origin.event ? !onDragEvent || !events.includes(origin.event) || !canMoveEvent(origin.event) : !onCreateEvent && !onSelectDrag)) heldTouch.current?.();
|
|
469
|
+
});
|
|
348
470
|
const hitTest = (0, react.useCallback)((x, y) => {
|
|
349
471
|
const { width, height } = gridSize;
|
|
350
472
|
if (width <= 0 || height <= 0 || weeks.length === 0) return null;
|
|
@@ -380,10 +502,16 @@ function MonthViewInner({ date, events, maxVisibleEventCount, chipHeight, chipGa
|
|
|
380
502
|
maxDate,
|
|
381
503
|
isDateDisabled
|
|
382
504
|
]);
|
|
383
|
-
const beginDrag = (0, react.useCallback)((x, y) => {
|
|
505
|
+
const beginDrag = (0, react.useCallback)((x, y, origin) => {
|
|
506
|
+
if (!mounted.current || multiWeek && interactionWindow.current !== windowKey) return;
|
|
507
|
+
if (origin && (!(0, _super_calendar_core.isDateSelectable)(origin.day, {
|
|
508
|
+
minDate,
|
|
509
|
+
maxDate,
|
|
510
|
+
isDateDisabled
|
|
511
|
+
}) || origin.event && !events.includes(origin.event))) return;
|
|
384
512
|
suppressPressRef.current = false;
|
|
385
513
|
movedRef.current = false;
|
|
386
|
-
const hit = hitTest(x, y);
|
|
514
|
+
const hit = origin ?? hitTest(x, y);
|
|
387
515
|
if (!hit) return;
|
|
388
516
|
if (hit.event) {
|
|
389
517
|
if (!onDragEvent || !canMoveEvent(hit.event)) return;
|
|
@@ -408,7 +536,13 @@ function MonthViewInner({ date, events, maxVisibleEventCount, chipHeight, chipGa
|
|
|
408
536
|
onSelectDrag,
|
|
409
537
|
onDragStart,
|
|
410
538
|
canMoveEvent,
|
|
411
|
-
applyDrag
|
|
539
|
+
applyDrag,
|
|
540
|
+
multiWeek,
|
|
541
|
+
windowKey,
|
|
542
|
+
minDate,
|
|
543
|
+
maxDate,
|
|
544
|
+
isDateDisabled,
|
|
545
|
+
events
|
|
412
546
|
]);
|
|
413
547
|
const extendDrag = (0, react.useCallback)((x, y) => {
|
|
414
548
|
const current = dragRef.current;
|
|
@@ -488,13 +622,57 @@ function MonthViewInner({ date, events, maxVisibleEventCount, chipHeight, chipGa
|
|
|
488
622
|
target.addEventListener?.("pointerup", up);
|
|
489
623
|
const node = gridRef.current;
|
|
490
624
|
if (node?.style) {
|
|
491
|
-
node.style.touchAction = "none";
|
|
625
|
+
node.style.touchAction = multiWeek ? "pan-y" : "none";
|
|
492
626
|
node.style.userSelect = "none";
|
|
493
627
|
}
|
|
494
628
|
return () => target.removeEventListener?.("pointerup", up);
|
|
495
|
-
}, [
|
|
629
|
+
}, [
|
|
630
|
+
dragEnabled,
|
|
631
|
+
endDrag,
|
|
632
|
+
multiWeek
|
|
633
|
+
]);
|
|
634
|
+
const webDragHandlers = (0, react.useRef)({
|
|
635
|
+
beginDrag,
|
|
636
|
+
extendDrag
|
|
637
|
+
});
|
|
638
|
+
webDragHandlers.current = {
|
|
639
|
+
beginDrag,
|
|
640
|
+
extendDrag
|
|
641
|
+
};
|
|
642
|
+
const pressWebGrid = (event) => {
|
|
643
|
+
const pointer = event.nativeEvent;
|
|
644
|
+
if (multiWeek && (pointer.button !== 0 || pointer.isPrimary === false || heldTouch.current)) return;
|
|
645
|
+
if (multiWeek) suppressPressRef.current = false;
|
|
646
|
+
const start = () => {
|
|
647
|
+
const point = gridPoint(pointer.clientX, pointer.clientY);
|
|
648
|
+
if (point) webDragHandlers.current.beginDrag(point.x, point.y);
|
|
649
|
+
};
|
|
650
|
+
if (!multiWeek || !pointer.pointerType || pointer.pointerType === "mouse") {
|
|
651
|
+
start();
|
|
652
|
+
return;
|
|
653
|
+
}
|
|
654
|
+
const node = gridRef.current;
|
|
655
|
+
if (!node) return;
|
|
656
|
+
const point = gridPoint(pointer.clientX, pointer.clientY);
|
|
657
|
+
if (!point) return;
|
|
658
|
+
const origin = hitTest(point.x, point.y);
|
|
659
|
+
if (!origin) return;
|
|
660
|
+
heldOrigin.current = origin;
|
|
661
|
+
heldTouch.current = holdWebDateDrag(node, pointer, () => {
|
|
662
|
+
if (interactionWindow.current === windowKey) webDragHandlers.current.beginDrag(point.x, point.y, origin);
|
|
663
|
+
}, (x, y) => {
|
|
664
|
+
const point = gridPoint(x, y);
|
|
665
|
+
if (point) webDragHandlers.current.extendDrag(point.x, point.y);
|
|
666
|
+
}, () => {
|
|
667
|
+
applyDrag(null);
|
|
668
|
+
movedRef.current = false;
|
|
669
|
+
}, () => {
|
|
670
|
+
heldTouch.current = null;
|
|
671
|
+
heldOrigin.current = null;
|
|
672
|
+
});
|
|
673
|
+
};
|
|
496
674
|
const renderDay = (day, dayCol, rowLayout, visibleLanes) => {
|
|
497
|
-
const isCurrentMonth = (0, date_fns.isSameMonth)(day, date);
|
|
675
|
+
const isCurrentMonth = multiWeek || (0, date_fns.isSameMonth)(day, date);
|
|
498
676
|
if (!isCurrentMonth && !showAdjacentMonths) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, { ...slot("day", {
|
|
499
677
|
base: [styles$3.dayCell, { gap: chipGap }],
|
|
500
678
|
themed: [showGrid && {
|
|
@@ -675,7 +853,7 @@ function MonthViewInner({ date, events, maxVisibleEventCount, chipHeight, chipGa
|
|
|
675
853
|
themed: [theme.text.monthTitle, { color: theme.colors.text }]
|
|
676
854
|
}),
|
|
677
855
|
allowFontScaling: false,
|
|
678
|
-
children:
|
|
856
|
+
children: title
|
|
679
857
|
}) : null,
|
|
680
858
|
showWeekdays ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
681
859
|
...slot("weekdays", {
|
|
@@ -718,7 +896,7 @@ function MonthViewInner({ date, events, maxVisibleEventCount, chipHeight, chipGa
|
|
|
718
896
|
style: styles$3.moreCardRow,
|
|
719
897
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RenderEventComponent, {
|
|
720
898
|
event,
|
|
721
|
-
mode: "month",
|
|
899
|
+
mode: multiWeek ? "multiweek" : "month",
|
|
722
900
|
isAllDay: (0, _super_calendar_core.isAllDayEvent)(event),
|
|
723
901
|
onPress: () => {
|
|
724
902
|
setMoreOpenFor(null);
|
|
@@ -729,74 +907,75 @@ function MonthViewInner({ date, events, maxVisibleEventCount, chipHeight, chipGa
|
|
|
729
907
|
})
|
|
730
908
|
})
|
|
731
909
|
}) : null,
|
|
732
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
733
|
-
|
|
734
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
} : null,
|
|
750
|
-
children: weeks.map((week, weekIndex) => {
|
|
751
|
-
const rowLayout = weekLayouts[weekIndex] ?? EMPTY_LAYOUT;
|
|
752
|
-
const visibleLanes = (0, _super_calendar_core.monthVisibleCount)(rowLayout.laneCount, capacity);
|
|
753
|
-
const cols = week.length;
|
|
754
|
-
let firstVisCol = 0;
|
|
755
|
-
let lastVisCol = cols - 1;
|
|
756
|
-
if (showGrid && !showAdjacentMonths) {
|
|
757
|
-
const first = week.findIndex((d) => (0, date_fns.isSameMonth)(d, date));
|
|
758
|
-
if (first !== -1) {
|
|
759
|
-
firstVisCol = first;
|
|
760
|
-
lastVisCol = cols - 1 - [...week].reverse().findIndex((d) => (0, date_fns.isSameMonth)(d, date));
|
|
910
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(DateRowsViewport, {
|
|
911
|
+
scrollable: multiWeek,
|
|
912
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MonthGridSurface, {
|
|
913
|
+
gesture: dragGesture,
|
|
914
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
915
|
+
ref: gridRef,
|
|
916
|
+
testID: multiWeek ? "multiweek-grid" : "month-grid",
|
|
917
|
+
accessibilityLabel: multiWeek ? title : void 0,
|
|
918
|
+
...slot("grid", { base: [styles$3.container, multiWeek ? { minHeight: minimumRowHeight * weeks.length } : void 0] }),
|
|
919
|
+
onLayout: handleLayout,
|
|
920
|
+
...isWeb$2 && dragEnabled ? {
|
|
921
|
+
onPointerDown: pressWebGrid,
|
|
922
|
+
onPointerMove: (event) => {
|
|
923
|
+
if (heldTouch.current) return;
|
|
924
|
+
if (!dragRef.current) return;
|
|
925
|
+
const point = gridPoint(event.nativeEvent.clientX, event.nativeEvent.clientY);
|
|
926
|
+
if (point) extendDrag(point.x, point.y);
|
|
761
927
|
}
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
928
|
+
} : null,
|
|
929
|
+
children: weeks.map((week, weekIndex) => {
|
|
930
|
+
const rowLayout = weekLayouts[weekIndex] ?? EMPTY_LAYOUT;
|
|
931
|
+
const visibleLanes = (0, _super_calendar_core.monthVisibleCount)(rowLayout.laneCount, capacity);
|
|
932
|
+
const cols = week.length;
|
|
933
|
+
let firstVisCol = 0;
|
|
934
|
+
let lastVisCol = cols - 1;
|
|
935
|
+
if (showGrid && !showAdjacentMonths) {
|
|
936
|
+
const first = week.findIndex((d) => (0, date_fns.isSameMonth)(d, date));
|
|
937
|
+
if (first !== -1) {
|
|
938
|
+
firstVisCol = first;
|
|
939
|
+
lastVisCol = cols - 1 - [...week].reverse().findIndex((d) => (0, date_fns.isSameMonth)(d, date));
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
return /* @__PURE__ */ (0, react.createElement)(react_native.View, {
|
|
943
|
+
...slot("week", {
|
|
944
|
+
base: styles$3.weekRow,
|
|
945
|
+
themed: theme.containers.weekRow
|
|
946
|
+
}),
|
|
947
|
+
key: multiWeekGrid?.weeks[weekIndex].id ?? week[0].toISOString()
|
|
948
|
+
}, week.map((day, dayCol) => renderDay(day, dayCol, rowLayout, visibleLanes)), showGrid ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
949
|
+
style: [react_native.StyleSheet.absoluteFill, multiWeek ? styles$3.childrenOnlyPointerEvents : { pointerEvents: "box-none" }],
|
|
950
|
+
children: rowLayout.segments.filter((seg) => seg.lane < visibleLanes).map((seg) => {
|
|
951
|
+
const startCol = Math.max(seg.startCol, firstVisCol);
|
|
952
|
+
const endCol = Math.min(seg.endCol, lastVisCol);
|
|
953
|
+
if (startCol > endCol) return null;
|
|
954
|
+
const isDragged = drag?.kind === "move" && drag.event === seg.event;
|
|
955
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
956
|
+
style: [{
|
|
957
|
+
position: "absolute",
|
|
958
|
+
left: pct(startCol / cols * 100),
|
|
959
|
+
width: pct((endCol - startCol + 1) / cols * 100),
|
|
960
|
+
top: badgeArea + seg.lane * chipMetrics.chipRowHeight,
|
|
961
|
+
height: chipMetrics.chipHeight,
|
|
962
|
+
paddingHorizontal: CHIP_INSET_H,
|
|
963
|
+
opacity: isDragged ? DRAGGED_BAR_OPACITY : 1
|
|
964
|
+
}, multiWeek ? drag ? styles$3.noPointerEvents : styles$3.childrenOnlyPointerEvents : { pointerEvents: drag ? "none" : "box-none" }],
|
|
965
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RenderEventComponent, {
|
|
966
|
+
event: seg.event,
|
|
967
|
+
mode: multiWeek ? "multiweek" : "month",
|
|
968
|
+
isAllDay: (0, _super_calendar_core.isAllDayEvent)(seg.event),
|
|
969
|
+
onPress: disableMonthEventCellPress ? () => {} : () => {
|
|
970
|
+
if (consumeSuppressedPress()) return;
|
|
971
|
+
onPressEvent(seg.event);
|
|
972
|
+
},
|
|
973
|
+
onLongPress: disableMonthEventCellPress || !onLongPressEvent ? void 0 : () => onLongPressEvent(seg.event)
|
|
974
|
+
})
|
|
975
|
+
}, `bar-${seg.event.start.toISOString()}:${seg.event.title}:${seg.lane}`);
|
|
976
|
+
})
|
|
977
|
+
}) : null);
|
|
978
|
+
})
|
|
800
979
|
})
|
|
801
980
|
})
|
|
802
981
|
})
|
|
@@ -804,6 +983,13 @@ function MonthViewInner({ date, events, maxVisibleEventCount, chipHeight, chipGa
|
|
|
804
983
|
})
|
|
805
984
|
});
|
|
806
985
|
}
|
|
986
|
+
function DateRowsViewport({ scrollable, children }) {
|
|
987
|
+
return scrollable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.ScrollView, {
|
|
988
|
+
style: styles$3.container,
|
|
989
|
+
contentContainerStyle: { flexGrow: 1 },
|
|
990
|
+
children
|
|
991
|
+
}) : children;
|
|
992
|
+
}
|
|
807
993
|
function MonthGridSurface({ gesture, children }) {
|
|
808
994
|
if (!gesture) return children;
|
|
809
995
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native_gesture_handler.GestureDetector, {
|
|
@@ -828,6 +1014,11 @@ function MonthGridSurface({ gesture, children }) {
|
|
|
828
1014
|
* ```
|
|
829
1015
|
*/
|
|
830
1016
|
const MonthView = (0, react.memo)(MonthViewInner);
|
|
1017
|
+
/**
|
|
1018
|
+
* The day-row grid behind the public row views: week rows of day cells with
|
|
1019
|
+
* spanning event bars, overflow, selection, and drag handling.
|
|
1020
|
+
*/
|
|
1021
|
+
const DateRows = (0, react.memo)(DateRowsInner);
|
|
831
1022
|
const styles$3 = react_native.StyleSheet.create({
|
|
832
1023
|
root: { flex: 1 },
|
|
833
1024
|
title: {
|
|
@@ -844,6 +1035,8 @@ const styles$3 = react_native.StyleSheet.create({
|
|
|
844
1035
|
textAlign: "center"
|
|
845
1036
|
},
|
|
846
1037
|
container: { flex: 1 },
|
|
1038
|
+
childrenOnlyPointerEvents: { pointerEvents: "box-none" },
|
|
1039
|
+
noPointerEvents: { pointerEvents: "none" },
|
|
847
1040
|
weekRow: {
|
|
848
1041
|
flex: 1,
|
|
849
1042
|
flexDirection: "row"
|
|
@@ -899,12 +1092,22 @@ const styles$3 = react_native.StyleSheet.create({
|
|
|
899
1092
|
},
|
|
900
1093
|
moreCardRow: { marginBottom: 4 }
|
|
901
1094
|
});
|
|
902
|
-
|
|
903
|
-
//#region src/components/MonthPager.tsx
|
|
1095
|
+
// src/components/MonthPager.tsx
|
|
904
1096
|
const isWeb$1 = react_native.Platform.OS === "web";
|
|
905
1097
|
const PAGE_WINDOW$1 = 60;
|
|
906
1098
|
const PAGE_VIEWABILITY = { itemVisiblePercentThreshold: 90 };
|
|
907
|
-
function MonthPagerInner({
|
|
1099
|
+
function MonthPagerInner({ showAdjacentMonths = true, showSixWeeks = false, ...rest }) {
|
|
1100
|
+
const spec = (0, react.useMemo)(() => ({
|
|
1101
|
+
kind: "month",
|
|
1102
|
+
showAdjacentMonths,
|
|
1103
|
+
showSixWeeks
|
|
1104
|
+
}), [showAdjacentMonths, showSixWeeks]);
|
|
1105
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DateRowsPager, {
|
|
1106
|
+
...rest,
|
|
1107
|
+
spec
|
|
1108
|
+
});
|
|
1109
|
+
}
|
|
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 }) {
|
|
908
1111
|
const theme = useCalendarTheme();
|
|
909
1112
|
const slot = (0, react.useMemo)(() => createSlots({
|
|
910
1113
|
classNames,
|
|
@@ -931,10 +1134,23 @@ function MonthPagerInner({ date, events, maxVisibleEventCount, chipHeight, chipG
|
|
|
931
1134
|
}, []);
|
|
932
1135
|
const [pageHeight, setPageHeight] = (0, react.useState)(height);
|
|
933
1136
|
const [containerWidth, setContainerWidth] = (0, react.useState)(width);
|
|
934
|
-
const [anchorDate] = (0, react.useState)(date);
|
|
935
|
-
const
|
|
936
|
-
const
|
|
937
|
-
|
|
1137
|
+
const [anchorDate] = (0, react.useState)(initialAnchor ?? date);
|
|
1138
|
+
const numberOfWeeks = spec.kind === "multiweek" ? spec.numberOfWeeks : void 0;
|
|
1139
|
+
const anchor = (0, react.useMemo)(() => numberOfWeeks === void 0 ? (0, date_fns.startOfMonth)(anchorDate) : (0, date_fns.startOfWeek)(anchorDate, { weekStartsOn }), [
|
|
1140
|
+
anchorDate,
|
|
1141
|
+
numberOfWeeks,
|
|
1142
|
+
weekStartsOn
|
|
1143
|
+
]);
|
|
1144
|
+
const monthDates = (0, react.useMemo)(() => {
|
|
1145
|
+
const dates = Array.from({ length: 121 }, (_, i) => numberOfWeeks === void 0 ? (0, date_fns.addMonths)(anchor, i - PAGE_WINDOW$1) : (0, date_fns.addWeeks)(anchor, (i - PAGE_WINDOW$1) * numberOfWeeks));
|
|
1146
|
+
return numberOfWeeks === void 0 ? dates : dates.filter((page) => Number.isFinite(page.getTime()) && Number.isFinite((0, date_fns.addWeeks)(page, numberOfWeeks).getTime()));
|
|
1147
|
+
}, [anchor, numberOfWeeks]);
|
|
1148
|
+
const activeIndex = (0, react.useCallback)((target) => numberOfWeeks === void 0 ? (0, date_fns.differenceInCalendarMonths)((0, date_fns.startOfMonth)(target), anchor) + PAGE_WINDOW$1 : (0, date_fns.differenceInCalendarWeeks)(target, monthDates[0], { weekStartsOn }) / numberOfWeeks, [
|
|
1149
|
+
anchor,
|
|
1150
|
+
monthDates,
|
|
1151
|
+
numberOfWeeks,
|
|
1152
|
+
weekStartsOn
|
|
1153
|
+
])(date);
|
|
938
1154
|
const viewedIndexRef = (0, react.useRef)(activeIndex);
|
|
939
1155
|
const pendingScrollIndexRef = (0, react.useRef)(null);
|
|
940
1156
|
const handleViewableItemsChanged = (0, react.useCallback)((info) => {
|
|
@@ -978,7 +1194,7 @@ function MonthPagerInner({ date, events, maxVisibleEventCount, chipHeight, chipG
|
|
|
978
1194
|
isRTL,
|
|
979
1195
|
hiddenDays
|
|
980
1196
|
]);
|
|
981
|
-
const
|
|
1197
|
+
const monthExtraData = (0, react.useMemo)(() => ({
|
|
982
1198
|
events,
|
|
983
1199
|
activeDate,
|
|
984
1200
|
fillCellOnSelection,
|
|
@@ -1006,6 +1222,20 @@ function MonthPagerInner({ date, events, maxVisibleEventCount, chipHeight, chipG
|
|
|
1006
1222
|
maxDate,
|
|
1007
1223
|
isDateDisabled
|
|
1008
1224
|
]);
|
|
1225
|
+
const sourceFor = (0, react.useMemo)(() => {
|
|
1226
|
+
const cache = /* @__PURE__ */ new WeakMap();
|
|
1227
|
+
return (item) => {
|
|
1228
|
+
let source = cache.get(item);
|
|
1229
|
+
if (!source) {
|
|
1230
|
+
source = {
|
|
1231
|
+
...spec,
|
|
1232
|
+
date: item
|
|
1233
|
+
};
|
|
1234
|
+
cache.set(item, source);
|
|
1235
|
+
}
|
|
1236
|
+
return source;
|
|
1237
|
+
};
|
|
1238
|
+
}, [spec]);
|
|
1009
1239
|
const snapToIndices = (0, react.useMemo)(() => monthDates.map((_, index) => index), [monthDates]);
|
|
1010
1240
|
const keyExtractorList = (0, react.useCallback)((item) => item.toISOString(), []);
|
|
1011
1241
|
const getFixedItemSize = (0, react.useCallback)(() => containerWidth, [containerWidth]);
|
|
@@ -1014,8 +1244,8 @@ function MonthPagerInner({ date, events, maxVisibleEventCount, chipHeight, chipG
|
|
|
1014
1244
|
width: containerWidth,
|
|
1015
1245
|
height: pageHeight
|
|
1016
1246
|
},
|
|
1017
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1018
|
-
|
|
1247
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DateRows, {
|
|
1248
|
+
source: sourceFor(item),
|
|
1019
1249
|
events,
|
|
1020
1250
|
showTitle: false,
|
|
1021
1251
|
showWeekdays: false,
|
|
@@ -1028,11 +1258,9 @@ function MonthPagerInner({ date, events, maxVisibleEventCount, chipHeight, chipG
|
|
|
1028
1258
|
sortedMonthView,
|
|
1029
1259
|
moreLabel,
|
|
1030
1260
|
labels,
|
|
1031
|
-
showAdjacentMonths,
|
|
1032
1261
|
highlightWeekends,
|
|
1033
1262
|
disableMonthEventCellPress,
|
|
1034
1263
|
isRTL,
|
|
1035
|
-
showSixWeeks,
|
|
1036
1264
|
activeDate,
|
|
1037
1265
|
calendarCellStyle,
|
|
1038
1266
|
renderEvent,
|
|
@@ -1067,11 +1295,10 @@ function MonthPagerInner({ date, events, maxVisibleEventCount, chipHeight, chipG
|
|
|
1067
1295
|
sortedMonthView,
|
|
1068
1296
|
moreLabel,
|
|
1069
1297
|
labels,
|
|
1070
|
-
|
|
1298
|
+
sourceFor,
|
|
1071
1299
|
highlightWeekends,
|
|
1072
1300
|
disableMonthEventCellPress,
|
|
1073
1301
|
isRTL,
|
|
1074
|
-
showSixWeeks,
|
|
1075
1302
|
activeDate,
|
|
1076
1303
|
calendarCellStyle,
|
|
1077
1304
|
renderEvent,
|
|
@@ -1093,6 +1320,22 @@ function MonthPagerInner({ date, events, maxVisibleEventCount, chipHeight, chipG
|
|
|
1093
1320
|
classNames,
|
|
1094
1321
|
styleOverrides
|
|
1095
1322
|
]);
|
|
1323
|
+
const listExtraData = (0, react.useMemo)(() => numberOfWeeks === void 0 ? monthExtraData : { renderItem }, [
|
|
1324
|
+
numberOfWeeks,
|
|
1325
|
+
monthExtraData,
|
|
1326
|
+
renderItem
|
|
1327
|
+
]);
|
|
1328
|
+
const visible = (0, react.useMemo)(() => numberOfWeeks === void 0 ? null : (0, _super_calendar_core.buildMultiWeekGrid)(date, {
|
|
1329
|
+
numberOfWeeks,
|
|
1330
|
+
weekStartsOn,
|
|
1331
|
+
hiddenDays
|
|
1332
|
+
}).visibleRange, [
|
|
1333
|
+
date,
|
|
1334
|
+
numberOfWeeks,
|
|
1335
|
+
weekStartsOn,
|
|
1336
|
+
hiddenDays
|
|
1337
|
+
]);
|
|
1338
|
+
const title = visible ? `${(0, date_fns.format)(visible.start, "PP", { locale })} – ${(0, date_fns.format)((0, date_fns.addDays)(visible.endExclusive, -1), "PP", { locale })}` : (0, date_fns.format)(date, "MMMM yyyy", { locale });
|
|
1096
1339
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_super_calendar_core.CalendarSelectionProvider, {
|
|
1097
1340
|
value: selection,
|
|
1098
1341
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
|
|
@@ -1105,7 +1348,7 @@ function MonthPagerInner({ date, events, maxVisibleEventCount, chipHeight, chipG
|
|
|
1105
1348
|
themed: [theme.text.monthTitle, { color: theme.colors.text }]
|
|
1106
1349
|
}),
|
|
1107
1350
|
allowFontScaling: false,
|
|
1108
|
-
children:
|
|
1351
|
+
children: title
|
|
1109
1352
|
}) : null,
|
|
1110
1353
|
renderHeaderForMonthView ? renderHeaderForMonthView(weekDays) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MonthWeekdayHeader, {
|
|
1111
1354
|
weekDays,
|
|
@@ -1163,6 +1406,54 @@ function MonthPagerInner({ date, events, maxVisibleEventCount, chipHeight, chipG
|
|
|
1163
1406
|
* ```
|
|
1164
1407
|
*/
|
|
1165
1408
|
const MonthPager = (0, react.memo)(MonthPagerInner);
|
|
1409
|
+
/** The swipeable pager behind `MonthPager` and `Calendar`'s row modes. */
|
|
1410
|
+
function DateRowsPagerRoot(props) {
|
|
1411
|
+
const count = props.spec.kind === "multiweek" ? props.spec.numberOfWeeks : void 0;
|
|
1412
|
+
const target = (0, react.useMemo)(() => count === void 0 ? props.date : (0, _super_calendar_core.buildMultiWeekGrid)(props.date, {
|
|
1413
|
+
numberOfWeeks: count,
|
|
1414
|
+
weekStartsOn: props.weekStartsOn
|
|
1415
|
+
}).period.start, [
|
|
1416
|
+
props.date,
|
|
1417
|
+
count,
|
|
1418
|
+
props.weekStartsOn
|
|
1419
|
+
]);
|
|
1420
|
+
const [series, setSeries] = (0, react.useState)(() => ({
|
|
1421
|
+
anchor: target,
|
|
1422
|
+
count,
|
|
1423
|
+
weekStartsOn: props.weekStartsOn
|
|
1424
|
+
}));
|
|
1425
|
+
let current = series;
|
|
1426
|
+
if (count !== void 0) {
|
|
1427
|
+
const offset = (0, date_fns.differenceInCalendarWeeks)(target, series.anchor, { weekStartsOn: props.weekStartsOn }) / count;
|
|
1428
|
+
if (series.count !== count || series.weekStartsOn !== props.weekStartsOn || !Number.isInteger(offset) || Math.abs(offset) > PAGE_WINDOW$1) {
|
|
1429
|
+
current = {
|
|
1430
|
+
anchor: target,
|
|
1431
|
+
count,
|
|
1432
|
+
weekStartsOn: props.weekStartsOn
|
|
1433
|
+
};
|
|
1434
|
+
setSeries(current);
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
const key = count === void 0 ? "month" : `${current.anchor.getTime()}:${count}:${props.weekStartsOn}`;
|
|
1438
|
+
const generation = (0, react.useRef)(key);
|
|
1439
|
+
generation.current = key;
|
|
1440
|
+
(0, react.useEffect)(() => {
|
|
1441
|
+
generation.current = key;
|
|
1442
|
+
return () => {
|
|
1443
|
+
generation.current = "unmounted";
|
|
1444
|
+
};
|
|
1445
|
+
}, [key]);
|
|
1446
|
+
const onChangeDate = (0, react.useCallback)((date) => {
|
|
1447
|
+
if (generation.current === key) props.onChangeDate(date);
|
|
1448
|
+
}, [key, props.onChangeDate]);
|
|
1449
|
+
return /* @__PURE__ */ (0, react.createElement)(DateRowsPagerInner, {
|
|
1450
|
+
...props,
|
|
1451
|
+
key,
|
|
1452
|
+
initialAnchor: count === void 0 ? void 0 : current.anchor,
|
|
1453
|
+
onChangeDate
|
|
1454
|
+
});
|
|
1455
|
+
}
|
|
1456
|
+
const DateRowsPager = (0, react.memo)(DateRowsPagerRoot);
|
|
1166
1457
|
const MonthWeekdayHeader = ({ weekDays, weekdayFormat = "short", locale, slot }) => {
|
|
1167
1458
|
const theme = useCalendarTheme();
|
|
1168
1459
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
@@ -1199,8 +1490,7 @@ const styles$2 = react_native.StyleSheet.create({
|
|
|
1199
1490
|
textAlign: "center"
|
|
1200
1491
|
}
|
|
1201
1492
|
});
|
|
1202
|
-
|
|
1203
|
-
//#region src/components/DefaultMonthEvent.tsx
|
|
1493
|
+
// src/components/DefaultMonthEvent.tsx
|
|
1204
1494
|
/**
|
|
1205
1495
|
* A lightweight event chip for the month grid and the date picker: the same
|
|
1206
1496
|
* titled box as {@link DefaultEvent} but with no Reanimated dependency (it drops
|
|
@@ -1277,8 +1567,7 @@ const styles$1 = react_native.StyleSheet.create({
|
|
|
1277
1567
|
time: { fontSize: 11 },
|
|
1278
1568
|
disabled: { opacity: .5 }
|
|
1279
1569
|
});
|
|
1280
|
-
|
|
1281
|
-
//#region src/components/MonthList.tsx
|
|
1570
|
+
// src/components/MonthList.tsx
|
|
1282
1571
|
const isWeb = react_native.Platform.OS === "web";
|
|
1283
1572
|
const PAGE_WINDOW = 60;
|
|
1284
1573
|
const VIEWABILITY = { itemVisiblePercentThreshold: 60 };
|
|
@@ -1688,7 +1977,6 @@ const styles = react_native.StyleSheet.create({
|
|
|
1688
1977
|
fontWeight: "600"
|
|
1689
1978
|
}
|
|
1690
1979
|
});
|
|
1691
|
-
//#endregion
|
|
1692
1980
|
Object.defineProperty(exports, "CalendarLabelsContext", {
|
|
1693
1981
|
enumerable: true,
|
|
1694
1982
|
get: function() {
|
|
@@ -1701,6 +1989,18 @@ Object.defineProperty(exports, "CalendarThemeProvider", {
|
|
|
1701
1989
|
return CalendarThemeProvider;
|
|
1702
1990
|
}
|
|
1703
1991
|
});
|
|
1992
|
+
Object.defineProperty(exports, "DateRows", {
|
|
1993
|
+
enumerable: true,
|
|
1994
|
+
get: function() {
|
|
1995
|
+
return DateRows;
|
|
1996
|
+
}
|
|
1997
|
+
});
|
|
1998
|
+
Object.defineProperty(exports, "DateRowsPager", {
|
|
1999
|
+
enumerable: true,
|
|
2000
|
+
get: function() {
|
|
2001
|
+
return DateRowsPager;
|
|
2002
|
+
}
|
|
2003
|
+
});
|
|
1704
2004
|
Object.defineProperty(exports, "DefaultMonthEvent", {
|
|
1705
2005
|
enumerable: true,
|
|
1706
2006
|
get: function() {
|