@super-calendar/native 2.3.2 → 2.4.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 +21 -0
- package/dist/{DefaultMonthEvent-BW6qy50X.d.ts → DefaultMonthEvent-BSvuJUFk.d.ts} +174 -173
- package/dist/{DefaultMonthEvent-BbCMc60z.d.mts → DefaultMonthEvent-zDj9dHEv.d.mts} +174 -173
- package/dist/{MonthList-CFXm7BK_.js → MonthList-Aczb2RSY.js} +219 -108
- package/dist/{MonthList-BidXJMfm.mjs → MonthList-zPLklHAY.mjs} +203 -110
- package/dist/index.d.mts +221 -263
- package/dist/index.d.ts +221 -263
- package/dist/index.js +549 -209
- package/dist/index.mjs +542 -214
- 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 +52 -11
- package/src/components/AllDayLane.tsx +22 -8
- package/src/components/Calendar.tsx +84 -5
- package/src/components/DefaultEvent.tsx +4 -0
- package/src/components/MonthList.tsx +52 -10
- package/src/components/MonthPager.tsx +45 -6
- package/src/components/MonthView.tsx +133 -74
- package/src/components/ResourceTimeline.tsx +276 -35
- package/src/components/TimeGrid.tsx +282 -162
- package/src/index.tsx +12 -4
- package/src/types.ts +16 -1
- package/src/utils/slots.ts +83 -0
|
@@ -104,6 +104,40 @@ 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
106
|
//#endregion
|
|
107
|
+
//#region src/utils/slots.ts
|
|
108
|
+
/**
|
|
109
|
+
* Build a slot resolver for one render. `slot(name, defaults)` returns the
|
|
110
|
+
* props to spread on that element: the resolved `style` array and, when the
|
|
111
|
+
* consumer supplied one, a `className` for the Tailwind runtime to pick up.
|
|
112
|
+
*/
|
|
113
|
+
function createSlots({ classNames, styles }) {
|
|
114
|
+
return (name, defaults) => {
|
|
115
|
+
const slotClass = classNames?.[name];
|
|
116
|
+
return {
|
|
117
|
+
style: [
|
|
118
|
+
defaults?.base,
|
|
119
|
+
slotClass ? void 0 : defaults?.themed,
|
|
120
|
+
styles?.[name]
|
|
121
|
+
],
|
|
122
|
+
...slotClass ? { className: slotClass } : null
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
const SlotStylesContext = (0, react.createContext)({});
|
|
127
|
+
/** Provide a component's `classNames`/`styles` maps to its internal slots. */
|
|
128
|
+
function SlotStylesProvider({ classNames, styles, children }) {
|
|
129
|
+
const value = (0, react.useMemo)(() => ({
|
|
130
|
+
classNames,
|
|
131
|
+
styles
|
|
132
|
+
}), [classNames, styles]);
|
|
133
|
+
return (0, react.createElement)(SlotStylesContext.Provider, { value }, children);
|
|
134
|
+
}
|
|
135
|
+
/** Resolve slots against the nearest {@link SlotStylesProvider}'s maps. */
|
|
136
|
+
function useSlots() {
|
|
137
|
+
const maps = (0, react.useContext)(SlotStylesContext);
|
|
138
|
+
return (0, react.useMemo)(() => createSlots(maps), [maps]);
|
|
139
|
+
}
|
|
140
|
+
//#endregion
|
|
107
141
|
//#region src/utils/useWebPagerKeys.ts
|
|
108
142
|
const getDocument = () => globalThis.document;
|
|
109
143
|
const isTextEntry = (element) => {
|
|
@@ -168,8 +202,12 @@ const CELL_ROW_GAP = 2;
|
|
|
168
202
|
const CHIP_PADDING_V = 2;
|
|
169
203
|
const FALLBACK_VISIBLE_COUNT = 3;
|
|
170
204
|
const numericStyle = (value, fallback) => typeof value === "number" ? value : fallback;
|
|
171
|
-
function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, weekdayFormat = "short", locale, sortedMonthView = true, moreLabel = "{moreCount} More", showAdjacentMonths = true, disableMonthEventCellPress = false, isRTL = false, showSixWeeks = false, showTitle = true, showWeekdays = true, activeDate, selectedDates: selectedDatesProp, selectedRange: selectedRangeProp, fillCellOnSelection = false, minDate: minDateProp, maxDate: maxDateProp, isDateDisabled: isDateDisabledProp, calendarCellStyle, renderEvent, eventAccessibilityLabel, keyExtractor, onPressDay, onLongPressDay, onPressEvent, onLongPressEvent, onPressMore, renderCustomDateForMonth, onDayPointerDown, onDayPointerEnter }) {
|
|
205
|
+
function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, weekdayFormat = "short", locale, sortedMonthView = true, moreLabel = "{moreCount} More", showAdjacentMonths = true, disableMonthEventCellPress = false, isRTL = false, showSixWeeks = false, showTitle = true, showWeekdays = true, activeDate, selectedDates: selectedDatesProp, selectedRange: selectedRangeProp, fillCellOnSelection = false, minDate: minDateProp, maxDate: maxDateProp, isDateDisabled: isDateDisabledProp, calendarCellStyle, renderEvent, eventAccessibilityLabel, keyExtractor, onPressDay, onLongPressDay, onPressEvent, onLongPressEvent, onPressMore, renderCustomDateForMonth, onDayPointerDown, onDayPointerEnter, classNames, styles: styleOverrides }) {
|
|
172
206
|
const theme = useCalendarTheme();
|
|
207
|
+
const slot = createSlots({
|
|
208
|
+
classNames,
|
|
209
|
+
styles: styleOverrides
|
|
210
|
+
});
|
|
173
211
|
const selection = (0, _super_calendar_core.useCalendarSelection)();
|
|
174
212
|
const selectedDates = selectedDatesProp ?? selection.selectedDates;
|
|
175
213
|
const selectedRange = selectedRangeProp ?? selection.selectedRange;
|
|
@@ -226,15 +264,14 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, week
|
|
|
226
264
|
const showGrid = events.length > 0;
|
|
227
265
|
const renderDay = (day) => {
|
|
228
266
|
const isCurrentMonth = (0, date_fns.isSameMonth)(day, date);
|
|
229
|
-
if (!isCurrentMonth && !showAdjacentMonths) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
230
|
-
styles$3.dayCell,
|
|
231
|
-
showGrid && {
|
|
267
|
+
if (!isCurrentMonth && !showAdjacentMonths) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, { ...slot("day", {
|
|
268
|
+
base: styles$3.dayCell,
|
|
269
|
+
themed: [showGrid && {
|
|
232
270
|
borderTopWidth: react_native.StyleSheet.hairlineWidth,
|
|
233
271
|
borderRightWidth: react_native.StyleSheet.hairlineWidth,
|
|
234
272
|
borderColor: theme.colors.gridLine
|
|
235
|
-
},
|
|
236
|
-
|
|
237
|
-
] }, day.toISOString());
|
|
273
|
+
}, theme.containers.dayCell]
|
|
274
|
+
}) }, day.toISOString());
|
|
238
275
|
const dayEvents = eventsByDay.get((0, date_fns.startOfDay)(day).toISOString()) ?? [];
|
|
239
276
|
const isToday = (0, _super_calendar_core.getIsToday)(day);
|
|
240
277
|
const isHighlighted = activeDate ? (0, _super_calendar_core.isSameCalendarDay)(day, activeDate) : isToday;
|
|
@@ -261,19 +298,21 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, week
|
|
|
261
298
|
const handleLongPressDay = isDisabled || !onLongPressDay ? void 0 : () => onLongPressDay(day);
|
|
262
299
|
const eventCount = dayEvents.length;
|
|
263
300
|
const accessibilityLabel = `${(0, date_fns.format)(day, "EEEE, d LLLL yyyy", { locale })}${isToday ? ", today" : ""}${isSelected ? ", selected" : ""}${isDisabled ? ", unavailable" : ""}, ${eventCount} ${eventCount === 1 ? "event" : "events"}`;
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
showGrid && styles$3.dayCellEvents,
|
|
301
|
+
const daySlot = slot("day", {
|
|
302
|
+
base: [styles$3.dayCell, showGrid && styles$3.dayCellEvents],
|
|
303
|
+
themed: [
|
|
268
304
|
showGrid && {
|
|
269
305
|
borderTopWidth: react_native.StyleSheet.hairlineWidth,
|
|
270
306
|
borderRightWidth: react_native.StyleSheet.hairlineWidth,
|
|
271
307
|
borderColor: theme.colors.gridLine
|
|
272
308
|
},
|
|
273
309
|
(0, _super_calendar_core.isWeekend)(day) && { backgroundColor: theme.colors.weekendBackground },
|
|
274
|
-
calendarCellStyle?.(day),
|
|
275
310
|
theme.containers.dayCell
|
|
276
|
-
]
|
|
311
|
+
]
|
|
312
|
+
});
|
|
313
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.TouchableOpacity, {
|
|
314
|
+
...daySlot,
|
|
315
|
+
style: [daySlot.style, calendarCellStyle?.(day)],
|
|
277
316
|
activeOpacity: showGrid ? .2 : 1,
|
|
278
317
|
...showGrid ? null : {
|
|
279
318
|
onPressIn: () => setPressedKey(dayKey),
|
|
@@ -298,48 +337,54 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, week
|
|
|
298
337
|
children: [
|
|
299
338
|
hasBand ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
300
339
|
testID: "month-range-band",
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
340
|
+
...slot("rangeBand", {
|
|
341
|
+
base: [
|
|
342
|
+
styles$3.rangeBand,
|
|
343
|
+
{ pointerEvents: "none" },
|
|
344
|
+
fillCellOnSelection ? {
|
|
345
|
+
top: 0,
|
|
346
|
+
bottom: 0
|
|
347
|
+
} : {
|
|
348
|
+
top: BAND_CENTER_Y - theme.rangeBandHeight / 2,
|
|
349
|
+
height: theme.rangeBandHeight
|
|
350
|
+
},
|
|
351
|
+
!fillCellOnSelection && isRangeStart && {
|
|
352
|
+
left: "50%",
|
|
353
|
+
marginLeft: -24 / 2,
|
|
354
|
+
borderTopLeftRadius: theme.rangeBandHeight / 2,
|
|
355
|
+
borderBottomLeftRadius: theme.rangeBandHeight / 2
|
|
356
|
+
},
|
|
357
|
+
!fillCellOnSelection && isRangeEnd && {
|
|
358
|
+
right: "50%",
|
|
359
|
+
marginRight: -24 / 2,
|
|
360
|
+
borderTopRightRadius: theme.rangeBandHeight / 2,
|
|
361
|
+
borderBottomRightRadius: theme.rangeBandHeight / 2
|
|
362
|
+
}
|
|
363
|
+
],
|
|
364
|
+
themed: { backgroundColor: theme.colors.rangeBackground }
|
|
365
|
+
})
|
|
325
366
|
}) : null,
|
|
326
367
|
renderCustomDateForMonth ? renderCustomDateForMonth(day) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
368
|
+
...slot("dayBadge", {
|
|
369
|
+
base: [
|
|
370
|
+
styles$3.dateBadge,
|
|
371
|
+
showGrid && styles$3.dateBadgeEvents,
|
|
372
|
+
!showGrid && pressedKey === dayKey && { opacity: .2 }
|
|
373
|
+
],
|
|
374
|
+
themed: [
|
|
375
|
+
isFilledBadge && {
|
|
376
|
+
backgroundColor: isHighlighted ? theme.colors.todayBackground : theme.colors.selectedBackground,
|
|
377
|
+
borderRadius: theme.todayBadgeRadius
|
|
378
|
+
},
|
|
379
|
+
isHovered && !isFilledBadge && {
|
|
380
|
+
backgroundColor: theme.colors.hoverBackground,
|
|
381
|
+
borderRadius: theme.todayBadgeRadius
|
|
382
|
+
},
|
|
383
|
+
theme.containers.dayBadge
|
|
384
|
+
]
|
|
385
|
+
}),
|
|
341
386
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
|
|
342
|
-
|
|
387
|
+
...slot("dayBadgeText", { themed: [theme.text.dateCell, { color: dateColor }] }),
|
|
343
388
|
allowFontScaling: false,
|
|
344
389
|
children: (0, date_fns.format)(day, "d")
|
|
345
390
|
})
|
|
@@ -355,11 +400,10 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, week
|
|
|
355
400
|
})
|
|
356
401
|
}, keyExtractor(event, index))),
|
|
357
402
|
hiddenCount > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
],
|
|
403
|
+
...slot("more", {
|
|
404
|
+
base: styles$3.moreLabel,
|
|
405
|
+
themed: [theme.text.more, { color: theme.colors.textMuted }]
|
|
406
|
+
}),
|
|
363
407
|
onPress: onPressMore ? () => onPressMore(dayEvents, day) : void 0,
|
|
364
408
|
accessibilityRole: "button",
|
|
365
409
|
accessibilityLabel: `Show ${hiddenCount} more events`,
|
|
@@ -377,33 +421,37 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, week
|
|
|
377
421
|
style: styles$3.root,
|
|
378
422
|
children: [
|
|
379
423
|
showTitle ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
|
|
380
|
-
|
|
381
|
-
styles$3.title,
|
|
382
|
-
theme.text.monthTitle,
|
|
383
|
-
|
|
384
|
-
],
|
|
424
|
+
...slot("title", {
|
|
425
|
+
base: styles$3.title,
|
|
426
|
+
themed: [theme.text.monthTitle, { color: theme.colors.text }]
|
|
427
|
+
}),
|
|
385
428
|
allowFontScaling: false,
|
|
386
429
|
children: (0, date_fns.format)(date, "MMMM yyyy", locale ? { locale } : void 0)
|
|
387
430
|
}) : null,
|
|
388
431
|
showWeekdays ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
389
|
-
|
|
432
|
+
...slot("weekdays", {
|
|
433
|
+
base: styles$3.weekdayHeader,
|
|
434
|
+
themed: theme.containers.weekdayHeader
|
|
435
|
+
}),
|
|
390
436
|
children: weekdayLabels.map((day) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
],
|
|
437
|
+
...slot("weekday", {
|
|
438
|
+
base: styles$3.weekdayLabel,
|
|
439
|
+
themed: [theme.text.weekday, { color: theme.colors.textMuted }]
|
|
440
|
+
}),
|
|
396
441
|
allowFontScaling: false,
|
|
397
442
|
children: (0, date_fns.format)(day, (0, _super_calendar_core.weekdayFormatToken)(weekdayFormat), { locale })
|
|
398
443
|
}, day.toISOString()))
|
|
399
444
|
}) : null,
|
|
400
445
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
401
|
-
|
|
446
|
+
...slot("grid", { base: styles$3.container }),
|
|
402
447
|
onLayout: handleLayout,
|
|
403
|
-
children: weeks.map((week) => /* @__PURE__ */ (0,
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
448
|
+
children: weeks.map((week) => /* @__PURE__ */ (0, react.createElement)(react_native.View, {
|
|
449
|
+
...slot("week", {
|
|
450
|
+
base: styles$3.weekRow,
|
|
451
|
+
themed: theme.containers.weekRow
|
|
452
|
+
}),
|
|
453
|
+
key: week[0].toISOString()
|
|
454
|
+
}, week.map((day) => renderDay(day))))
|
|
407
455
|
})
|
|
408
456
|
]
|
|
409
457
|
});
|
|
@@ -479,8 +527,12 @@ const styles$3 = react_native.StyleSheet.create({
|
|
|
479
527
|
const isWeb$1 = react_native.Platform.OS === "web";
|
|
480
528
|
const PAGE_WINDOW$1 = 60;
|
|
481
529
|
const PAGE_VIEWABILITY = { itemVisiblePercentThreshold: 90 };
|
|
482
|
-
function MonthPagerInner({ date, events, maxVisibleEventCount, weekStartsOn, weekdayFormat = "short", locale, sortedMonthView, moreLabel, showAdjacentMonths, disableMonthEventCellPress, isRTL, calendarCellStyle, renderEvent, keyExtractor, onPressDay, onLongPressDay, onPressEvent, onLongPressEvent, onPressMore, onChangeDate, freeSwipe = false, swipeEnabled = true, showSixWeeks = false, activeDate, renderHeaderForMonthView, renderCustomDateForMonth }) {
|
|
530
|
+
function MonthPagerInner({ date, events, maxVisibleEventCount, weekStartsOn, weekdayFormat = "short", locale, sortedMonthView, moreLabel, showAdjacentMonths, disableMonthEventCellPress, isRTL, calendarCellStyle, renderEvent, keyExtractor, onPressDay, onLongPressDay, onPressEvent, onLongPressEvent, onPressMore, onChangeDate, freeSwipe = false, swipeEnabled = true, showSixWeeks = false, activeDate, renderHeaderForMonthView, renderCustomDateForMonth, classNames, styles: styleOverrides }) {
|
|
483
531
|
const theme = useCalendarTheme();
|
|
532
|
+
const slot = (0, react.useMemo)(() => createSlots({
|
|
533
|
+
classNames,
|
|
534
|
+
styles: styleOverrides
|
|
535
|
+
}), [classNames, styleOverrides]);
|
|
484
536
|
const { width, height } = (0, react_native.useWindowDimensions)();
|
|
485
537
|
const listRef = (0, react.useRef)(null);
|
|
486
538
|
const containerRef = (0, react.useRef)(null);
|
|
@@ -548,6 +600,10 @@ function MonthPagerInner({ date, events, maxVisibleEventCount, weekStartsOn, wee
|
|
|
548
600
|
weekStartsOn,
|
|
549
601
|
isRTL
|
|
550
602
|
]);
|
|
603
|
+
const listExtraData = (0, react.useMemo)(() => ({
|
|
604
|
+
events,
|
|
605
|
+
activeDate
|
|
606
|
+
}), [events, activeDate]);
|
|
551
607
|
const snapToIndices = (0, react.useMemo)(() => monthDates.map((_, index) => index), [monthDates]);
|
|
552
608
|
const keyExtractorList = (0, react.useCallback)((item) => item.toISOString(), []);
|
|
553
609
|
const getFixedItemSize = (0, react.useCallback)(() => containerWidth, [containerWidth]);
|
|
@@ -579,7 +635,9 @@ function MonthPagerInner({ date, events, maxVisibleEventCount, weekStartsOn, wee
|
|
|
579
635
|
onPressEvent,
|
|
580
636
|
onLongPressEvent,
|
|
581
637
|
onPressMore,
|
|
582
|
-
renderCustomDateForMonth
|
|
638
|
+
renderCustomDateForMonth,
|
|
639
|
+
classNames,
|
|
640
|
+
styles: styleOverrides
|
|
583
641
|
})
|
|
584
642
|
}), [
|
|
585
643
|
containerWidth,
|
|
@@ -603,25 +661,27 @@ function MonthPagerInner({ date, events, maxVisibleEventCount, weekStartsOn, wee
|
|
|
603
661
|
onPressEvent,
|
|
604
662
|
onLongPressEvent,
|
|
605
663
|
onPressMore,
|
|
606
|
-
renderCustomDateForMonth
|
|
664
|
+
renderCustomDateForMonth,
|
|
665
|
+
classNames,
|
|
666
|
+
styleOverrides
|
|
607
667
|
]);
|
|
608
668
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
|
|
609
669
|
ref: containerRef,
|
|
610
670
|
style: [styles$2.container, theme.containers.monthContainer],
|
|
611
671
|
children: [
|
|
612
672
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
|
|
613
|
-
|
|
614
|
-
styles$2.monthTitle,
|
|
615
|
-
theme.text.monthTitle,
|
|
616
|
-
|
|
617
|
-
],
|
|
673
|
+
...slot("title", {
|
|
674
|
+
base: styles$2.monthTitle,
|
|
675
|
+
themed: [theme.text.monthTitle, { color: theme.colors.text }]
|
|
676
|
+
}),
|
|
618
677
|
allowFontScaling: false,
|
|
619
678
|
children: (0, date_fns.format)(date, "MMMM yyyy", locale ? { locale } : void 0)
|
|
620
679
|
}),
|
|
621
680
|
renderHeaderForMonthView ? renderHeaderForMonthView(weekDays) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MonthWeekdayHeader, {
|
|
622
681
|
weekDays,
|
|
623
682
|
weekdayFormat,
|
|
624
|
-
locale
|
|
683
|
+
locale,
|
|
684
|
+
slot
|
|
625
685
|
}),
|
|
626
686
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
627
687
|
style: styles$2.pager,
|
|
@@ -633,6 +693,7 @@ function MonthPagerInner({ date, events, maxVisibleEventCount, weekStartsOn, wee
|
|
|
633
693
|
ref: listRef,
|
|
634
694
|
style: isWeb$1 ? [styles$2.pagerList, styles$2.webNoScroll] : styles$2.pagerList,
|
|
635
695
|
data: monthDates,
|
|
696
|
+
extraData: listExtraData,
|
|
636
697
|
horizontal: true,
|
|
637
698
|
recycleItems: false,
|
|
638
699
|
keyExtractor: keyExtractorList,
|
|
@@ -671,16 +732,18 @@ function MonthPagerInner({ date, events, maxVisibleEventCount, weekStartsOn, wee
|
|
|
671
732
|
* ```
|
|
672
733
|
*/
|
|
673
734
|
const MonthPager = (0, react.memo)(MonthPagerInner);
|
|
674
|
-
const MonthWeekdayHeader = ({ weekDays, weekdayFormat = "short", locale }) => {
|
|
735
|
+
const MonthWeekdayHeader = ({ weekDays, weekdayFormat = "short", locale, slot }) => {
|
|
675
736
|
const theme = useCalendarTheme();
|
|
676
737
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
677
|
-
|
|
738
|
+
...slot("weekdays", {
|
|
739
|
+
base: styles$2.weekdayHeader,
|
|
740
|
+
themed: theme.containers.weekdayHeader
|
|
741
|
+
}),
|
|
678
742
|
children: weekDays.map((day) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
],
|
|
743
|
+
...slot("weekday", {
|
|
744
|
+
base: styles$2.weekdayLabel,
|
|
745
|
+
themed: [theme.text.weekday, { color: theme.colors.textMuted }]
|
|
746
|
+
}),
|
|
684
747
|
allowFontScaling: false,
|
|
685
748
|
children: (0, date_fns.format)(day, (0, _super_calendar_core.weekdayFormatToken)(weekdayFormat), { locale })
|
|
686
749
|
}, day.toISOString()))
|
|
@@ -796,11 +859,24 @@ const AUTOSCROLL_INTERVAL_MS = 16;
|
|
|
796
859
|
const NO_EVENTS = [];
|
|
797
860
|
const noop = () => {};
|
|
798
861
|
const defaultKeyExtractor = (event) => `${event.start.toISOString()}|${event.end.toISOString()}|${event.title ?? ""}`;
|
|
799
|
-
function MonthListInner({ date, events = NO_EVENTS, weekStartsOn, weekdayFormat = "short", weekRowHeight: weekRowHeightProp, monthHeaderHeight = DEFAULT_MONTH_HEADER_HEIGHT, maxVisibleEventCount, locale, sortedMonthView, moreLabel, showAdjacentMonths = false, disableMonthEventCellPress, isRTL, activeDate, selectedDates, selectedRange, fillCellOnSelection, minDate, maxDate, isDateDisabled, calendarCellStyle, renderEvent = DefaultMonthEvent, eventAccessibilityLabel, keyExtractor = defaultKeyExtractor, onPressDay, onLongPressDay, onPressEvent = noop, onLongPressEvent, onPressMore, onSelectDrag, onChangeVisibleMonth, renderMonthHeader }) {
|
|
862
|
+
function MonthListInner({ date, events = NO_EVENTS, weekStartsOn, weekdayFormat = "short", weekRowHeight: weekRowHeightProp, monthHeaderHeight = DEFAULT_MONTH_HEADER_HEIGHT, maxVisibleEventCount, locale, sortedMonthView, moreLabel, showAdjacentMonths = false, disableMonthEventCellPress, isRTL, activeDate, selectedDates, selectedRange, fillCellOnSelection, minDate, maxDate, isDateDisabled, calendarCellStyle, renderEvent = DefaultMonthEvent, eventAccessibilityLabel, keyExtractor = defaultKeyExtractor, onPressDay, onLongPressDay, onPressEvent = noop, onLongPressEvent, onPressMore, onSelectDrag, onChangeVisibleMonth, renderMonthHeader, classNames, styles: styleOverrides }) {
|
|
800
863
|
const theme = useCalendarTheme();
|
|
864
|
+
const slot = (0, react.useMemo)(() => createSlots({
|
|
865
|
+
classNames,
|
|
866
|
+
styles: styleOverrides
|
|
867
|
+
}), [classNames, styleOverrides]);
|
|
801
868
|
const listRef = (0, react.useRef)(null);
|
|
802
869
|
const weekRowHeight = weekRowHeightProp ?? (events.length > 0 ? DEFAULT_EVENT_WEEK_ROW_HEIGHT : DEFAULT_WEEK_ROW_HEIGHT);
|
|
803
870
|
const [firstViewableIndex, setFirstViewableIndex] = (0, react.useState)(0);
|
|
871
|
+
const listExtraData = (0, react.useMemo)(() => ({
|
|
872
|
+
events,
|
|
873
|
+
activeDate,
|
|
874
|
+
firstViewableIndex
|
|
875
|
+
}), [
|
|
876
|
+
events,
|
|
877
|
+
activeDate,
|
|
878
|
+
firstViewableIndex
|
|
879
|
+
]);
|
|
804
880
|
const [anchorDate] = (0, react.useState)(date);
|
|
805
881
|
const anchor = (0, react.useMemo)(() => (0, date_fns.startOfMonth)(anchorDate), [anchorDate]);
|
|
806
882
|
const monthDates = (0, react.useMemo)(() => Array.from({ length: 121 }, (_, i) => (0, date_fns.addMonths)(anchor, i - PAGE_WINDOW)), [anchor]);
|
|
@@ -905,16 +981,17 @@ function MonthListInner({ date, events = NO_EVENTS, weekStartsOn, weekdayFormat
|
|
|
905
981
|
if (autoScrollRef.current?.dir === dir) return;
|
|
906
982
|
stopAutoScroll();
|
|
907
983
|
const max = Math.max(0, offsets[offsets.length - 1] - viewportRef.current.height);
|
|
984
|
+
const id = setInterval(() => {
|
|
985
|
+
const next = Math.min(max, Math.max(0, scrollYRef.current + dir * AUTOSCROLL_STEP_PX));
|
|
986
|
+
scrollYRef.current = next;
|
|
987
|
+
listRef.current?.scrollToOffset({
|
|
988
|
+
offset: next,
|
|
989
|
+
animated: false
|
|
990
|
+
});
|
|
991
|
+
extendTo(dayAtContent(lastPanRef.current.x, next + lastPanRef.current.y));
|
|
992
|
+
}, AUTOSCROLL_INTERVAL_MS);
|
|
908
993
|
autoScrollRef.current = {
|
|
909
|
-
id
|
|
910
|
-
const next = Math.min(max, Math.max(0, scrollYRef.current + dir * AUTOSCROLL_STEP_PX));
|
|
911
|
-
scrollYRef.current = next;
|
|
912
|
-
listRef.current?.scrollToOffset({
|
|
913
|
-
offset: next,
|
|
914
|
-
animated: false
|
|
915
|
-
});
|
|
916
|
-
extendTo(dayAtContent(lastPanRef.current.x, next + lastPanRef.current.y));
|
|
917
|
-
}, AUTOSCROLL_INTERVAL_MS),
|
|
994
|
+
id,
|
|
918
995
|
dir
|
|
919
996
|
};
|
|
920
997
|
}, [
|
|
@@ -994,7 +1071,10 @@ function MonthListInner({ date, events = NO_EVENTS, weekStartsOn, weekdayFormat
|
|
|
994
1071
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
995
1072
|
style: [styles.monthHeader, { height: monthHeaderHeight }],
|
|
996
1073
|
children: renderMonthHeader ? renderMonthHeader(item) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
|
|
997
|
-
|
|
1074
|
+
...slot("title", {
|
|
1075
|
+
base: styles.monthTitle,
|
|
1076
|
+
themed: [styles.monthTitleText, { color: theme.colors.text }]
|
|
1077
|
+
}),
|
|
998
1078
|
children: (0, date_fns.format)(item, "LLLL yyyy", { locale })
|
|
999
1079
|
})
|
|
1000
1080
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
@@ -1024,7 +1104,9 @@ function MonthListInner({ date, events = NO_EVENTS, weekStartsOn, weekdayFormat
|
|
|
1024
1104
|
onLongPressEvent,
|
|
1025
1105
|
onPressMore,
|
|
1026
1106
|
onDayPointerDown: isWeb && dragEnabled ? onDayPointerDown : void 0,
|
|
1027
|
-
onDayPointerEnter: isWeb && dragEnabled ? onDayPointerEnter : void 0
|
|
1107
|
+
onDayPointerEnter: isWeb && dragEnabled ? onDayPointerEnter : void 0,
|
|
1108
|
+
classNames,
|
|
1109
|
+
styles: styleOverrides
|
|
1028
1110
|
})
|
|
1029
1111
|
})]
|
|
1030
1112
|
}), [
|
|
@@ -1055,14 +1137,17 @@ function MonthListInner({ date, events = NO_EVENTS, weekStartsOn, weekdayFormat
|
|
|
1055
1137
|
onLongPressEvent,
|
|
1056
1138
|
onPressMore,
|
|
1057
1139
|
onDayPointerDown,
|
|
1058
|
-
onDayPointerEnter
|
|
1140
|
+
onDayPointerEnter,
|
|
1141
|
+
slot,
|
|
1142
|
+
classNames,
|
|
1143
|
+
styleOverrides
|
|
1059
1144
|
]);
|
|
1060
1145
|
const list = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_legendapp_list_react_native.LegendList, {
|
|
1061
1146
|
ref: listRef,
|
|
1062
1147
|
style: styles.list,
|
|
1063
1148
|
data: monthDates,
|
|
1064
1149
|
recycleItems: false,
|
|
1065
|
-
extraData:
|
|
1150
|
+
extraData: listExtraData,
|
|
1066
1151
|
keyExtractor: keyExtractorList,
|
|
1067
1152
|
getFixedItemSize,
|
|
1068
1153
|
initialScrollIndex: initialIndex,
|
|
@@ -1084,9 +1169,15 @@ function MonthListInner({ date, events = NO_EVENTS, weekStartsOn, weekdayFormat
|
|
|
1084
1169
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
|
|
1085
1170
|
style: styles.container,
|
|
1086
1171
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
1087
|
-
|
|
1172
|
+
...slot("weekdays", {
|
|
1173
|
+
base: styles.weekdayHeader,
|
|
1174
|
+
themed: { borderBottomColor: theme.colors.gridLine }
|
|
1175
|
+
}),
|
|
1088
1176
|
children: weekDays.map((day) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
|
|
1089
|
-
|
|
1177
|
+
...slot("weekday", {
|
|
1178
|
+
base: styles.weekdayLabel,
|
|
1179
|
+
themed: [styles.weekdayLabelText, { color: theme.colors.textMuted }]
|
|
1180
|
+
}),
|
|
1090
1181
|
allowFontScaling: false,
|
|
1091
1182
|
children: (0, date_fns.format)(day, (0, _super_calendar_core.weekdayFormatToken)(weekdayFormat), { locale })
|
|
1092
1183
|
}, day.toISOString()))
|
|
@@ -1133,8 +1224,8 @@ const styles = react_native.StyleSheet.create({
|
|
|
1133
1224
|
container: { flex: 1 },
|
|
1134
1225
|
list: { flex: 1 },
|
|
1135
1226
|
monthHeader: { justifyContent: "center" },
|
|
1136
|
-
monthTitle: {
|
|
1137
|
-
|
|
1227
|
+
monthTitle: { paddingHorizontal: 8 },
|
|
1228
|
+
monthTitleText: {
|
|
1138
1229
|
fontSize: 17,
|
|
1139
1230
|
fontWeight: "700"
|
|
1140
1231
|
},
|
|
@@ -1146,7 +1237,9 @@ const styles = react_native.StyleSheet.create({
|
|
|
1146
1237
|
},
|
|
1147
1238
|
weekdayLabel: {
|
|
1148
1239
|
flex: 1,
|
|
1149
|
-
textAlign: "center"
|
|
1240
|
+
textAlign: "center"
|
|
1241
|
+
},
|
|
1242
|
+
weekdayLabelText: {
|
|
1150
1243
|
fontSize: 12,
|
|
1151
1244
|
fontWeight: "600"
|
|
1152
1245
|
}
|
|
@@ -1182,6 +1275,18 @@ Object.defineProperty(exports, "MonthView", {
|
|
|
1182
1275
|
return MonthView;
|
|
1183
1276
|
}
|
|
1184
1277
|
});
|
|
1278
|
+
Object.defineProperty(exports, "SlotStylesProvider", {
|
|
1279
|
+
enumerable: true,
|
|
1280
|
+
get: function() {
|
|
1281
|
+
return SlotStylesProvider;
|
|
1282
|
+
}
|
|
1283
|
+
});
|
|
1284
|
+
Object.defineProperty(exports, "createSlots", {
|
|
1285
|
+
enumerable: true,
|
|
1286
|
+
get: function() {
|
|
1287
|
+
return createSlots;
|
|
1288
|
+
}
|
|
1289
|
+
});
|
|
1185
1290
|
Object.defineProperty(exports, "darkTheme", {
|
|
1186
1291
|
enumerable: true,
|
|
1187
1292
|
get: function() {
|
|
@@ -1206,6 +1311,12 @@ Object.defineProperty(exports, "useCalendarTheme", {
|
|
|
1206
1311
|
return useCalendarTheme;
|
|
1207
1312
|
}
|
|
1208
1313
|
});
|
|
1314
|
+
Object.defineProperty(exports, "useSlots", {
|
|
1315
|
+
enumerable: true,
|
|
1316
|
+
get: function() {
|
|
1317
|
+
return useSlots;
|
|
1318
|
+
}
|
|
1319
|
+
});
|
|
1209
1320
|
Object.defineProperty(exports, "useWebPagerKeys", {
|
|
1210
1321
|
enumerable: true,
|
|
1211
1322
|
get: function() {
|