@super-calendar/native 2.1.4 → 2.2.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.
@@ -18,6 +18,10 @@ const defaultTheme = {
18
18
  fontSize: 13,
19
19
  fontWeight: "700"
20
20
  },
21
+ monthTitle: {
22
+ fontSize: 17,
23
+ fontWeight: "700"
24
+ },
21
25
  dateCell: {
22
26
  fontSize: 13,
23
27
  fontWeight: "700"
@@ -33,6 +37,23 @@ const defaultTheme = {
33
37
  lineHeight: 16
34
38
  }
35
39
  },
40
+ containers: {
41
+ monthContainer: {},
42
+ weekdayHeader: {},
43
+ weekRow: {},
44
+ dayCell: {},
45
+ dayBadge: {},
46
+ monthEvent: {},
47
+ columnHeader: {},
48
+ timeGridEvent: {},
49
+ nowIndicator: {},
50
+ resourceRow: {},
51
+ resourceLabel: {},
52
+ agendaList: {},
53
+ agendaRow: {},
54
+ allDayLane: {},
55
+ allDayColumn: {}
56
+ },
36
57
  todayBadgeRadius: 999,
37
58
  rangeBandHeight: 22
38
59
  };
@@ -44,6 +65,7 @@ const defaultTheme = {
44
65
  const darkTheme = {
45
66
  colors: _super_calendar_core.darkColors,
46
67
  text: defaultTheme.text,
68
+ containers: defaultTheme.containers,
47
69
  todayBadgeRadius: defaultTheme.todayBadgeRadius,
48
70
  rangeBandHeight: defaultTheme.rangeBandHeight
49
71
  };
@@ -59,6 +81,10 @@ function mergeTheme(theme) {
59
81
  ...defaultTheme.text,
60
82
  ...theme.text
61
83
  },
84
+ containers: {
85
+ ...defaultTheme.containers,
86
+ ...theme.containers
87
+ },
62
88
  todayBadgeRadius: theme.todayBadgeRadius ?? defaultTheme.todayBadgeRadius,
63
89
  rangeBandHeight: theme.rangeBandHeight ?? defaultTheme.rangeBandHeight
64
90
  };
@@ -105,6 +131,29 @@ function useWebPagerKeys(enabled, onPage) {
105
131
  }, [enabled, onPage]);
106
132
  }
107
133
  //#endregion
134
+ //#region src/utils/withEventAccessibilityLabel.tsx
135
+ /**
136
+ * Wrap an event renderer so it injects a consumer's `eventAccessibilityLabel`
137
+ * override into `RenderEventArgs.accessibilityLabel`. The built-in renderers use
138
+ * that string in place of their default label, and custom renderers can read it
139
+ * too. Returns the renderer unchanged when no override is set, so the common path
140
+ * pays nothing.
141
+ */
142
+ function withEventAccessibilityLabel(renderEvent, labeler, ampm) {
143
+ if (!labeler) return renderEvent;
144
+ const Base = renderEvent;
145
+ return function LabeledEvent(props) {
146
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Base, {
147
+ ...props,
148
+ accessibilityLabel: labeler(props.event, {
149
+ mode: props.mode,
150
+ isAllDay: props.isAllDay ?? false,
151
+ ampm
152
+ })
153
+ });
154
+ };
155
+ }
156
+ //#endregion
108
157
  //#region src/components/MonthView.tsx
109
158
  const isWeb$2 = react_native.Platform.OS === "web";
110
159
  const DAY_CELL_PADDING_TOP = 4;
@@ -114,7 +163,7 @@ const CELL_ROW_GAP = 2;
114
163
  const CHIP_PADDING_V = 2;
115
164
  const FALLBACK_VISIBLE_COUNT = 3;
116
165
  const numericStyle = (value, fallback) => typeof value === "number" ? value : fallback;
117
- function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, 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, keyExtractor, onPressDay, onLongPressDay, onPressEvent, onLongPressEvent, onPressMore, renderCustomDateForMonth, onDayPointerDown, onDayPointerEnter }) {
166
+ 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 }) {
118
167
  const theme = useCalendarTheme();
119
168
  const selection = (0, _super_calendar_core.useCalendarSelection)();
120
169
  const selectedDates = selectedDatesProp ?? selection.selectedDates;
@@ -122,7 +171,7 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, loca
122
171
  const minDate = minDateProp ?? selection.minDate;
123
172
  const maxDate = maxDateProp ?? selection.maxDate;
124
173
  const isDateDisabled = isDateDisabledProp ?? selection.isDateDisabled;
125
- const RenderEventComponent = renderEvent;
174
+ const RenderEventComponent = (0, react.useMemo)(() => withEventAccessibilityLabel(renderEvent, eventAccessibilityLabel, false), [renderEvent, eventAccessibilityLabel]);
126
175
  const [gridHeight, setGridHeight] = (0, react.useState)(0);
127
176
  const [hoveredKey, setHoveredKey] = (0, react.useState)(null);
128
177
  const [pressedKey, setPressedKey] = (0, react.useState)(null);
@@ -172,11 +221,15 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, loca
172
221
  const showGrid = events.length > 0;
173
222
  const renderDay = (day) => {
174
223
  const isCurrentMonth = (0, date_fns.isSameMonth)(day, date);
175
- if (!isCurrentMonth && !showAdjacentMonths) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, { style: [styles$3.dayCell, showGrid && {
176
- borderTopWidth: react_native.StyleSheet.hairlineWidth,
177
- borderRightWidth: react_native.StyleSheet.hairlineWidth,
178
- borderColor: theme.colors.gridLine
179
- }] }, day.toISOString());
224
+ if (!isCurrentMonth && !showAdjacentMonths) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, { style: [
225
+ styles$3.dayCell,
226
+ showGrid && {
227
+ borderTopWidth: react_native.StyleSheet.hairlineWidth,
228
+ borderRightWidth: react_native.StyleSheet.hairlineWidth,
229
+ borderColor: theme.colors.gridLine
230
+ },
231
+ theme.containers.dayCell
232
+ ] }, day.toISOString());
180
233
  const dayEvents = eventsByDay.get((0, date_fns.startOfDay)(day).toISOString()) ?? [];
181
234
  const isToday = (0, _super_calendar_core.getIsToday)(day);
182
235
  const isHighlighted = activeDate ? (0, _super_calendar_core.isSameCalendarDay)(day, activeDate) : isToday;
@@ -213,7 +266,8 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, loca
213
266
  borderColor: theme.colors.gridLine
214
267
  },
215
268
  (0, _super_calendar_core.isWeekend)(day) && { backgroundColor: theme.colors.weekendBackground },
216
- calendarCellStyle?.(day)
269
+ calendarCellStyle?.(day),
270
+ theme.containers.dayCell
217
271
  ],
218
272
  activeOpacity: showGrid ? .2 : 1,
219
273
  ...showGrid ? null : {
@@ -276,7 +330,8 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, loca
276
330
  backgroundColor: theme.colors.hoverBackground,
277
331
  borderRadius: theme.todayBadgeRadius
278
332
  },
279
- !showGrid && pressedKey === dayKey && { opacity: .2 }
333
+ !showGrid && pressedKey === dayKey && { opacity: .2 },
334
+ theme.containers.dayBadge
280
335
  ],
281
336
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
282
337
  style: [theme.text.dateCell, { color: dateColor }],
@@ -285,7 +340,7 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, loca
285
340
  })
286
341
  }),
287
342
  dayEvents.slice(0, visibleCount).map((event, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
288
- style: styles$3.monthEvent,
343
+ style: [styles$3.monthEvent, theme.containers.monthEvent],
289
344
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RenderEventComponent, {
290
345
  event,
291
346
  mode: "month",
@@ -317,12 +372,16 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, loca
317
372
  style: styles$3.root,
318
373
  children: [
319
374
  showTitle ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
320
- style: [styles$3.title, { color: theme.colors.text }],
375
+ style: [
376
+ styles$3.title,
377
+ theme.text.monthTitle,
378
+ { color: theme.colors.text }
379
+ ],
321
380
  allowFontScaling: false,
322
381
  children: (0, date_fns.format)(date, "MMMM yyyy", locale ? { locale } : void 0)
323
382
  }) : null,
324
383
  showWeekdays ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
325
- style: styles$3.weekdayHeader,
384
+ style: [styles$3.weekdayHeader, theme.containers.weekdayHeader],
326
385
  children: weekdayLabels.map((day) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
327
386
  style: [
328
387
  theme.text.weekday,
@@ -330,14 +389,14 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, loca
330
389
  { color: theme.colors.textMuted }
331
390
  ],
332
391
  allowFontScaling: false,
333
- children: (0, date_fns.format)(day, "EEE", { locale })
392
+ children: (0, date_fns.format)(day, (0, _super_calendar_core.weekdayFormatToken)(weekdayFormat), { locale })
334
393
  }, day.toISOString()))
335
394
  }) : null,
336
395
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
337
396
  style: styles$3.container,
338
397
  onLayout: handleLayout,
339
398
  children: weeks.map((week) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
340
- style: styles$3.weekRow,
399
+ style: [styles$3.weekRow, theme.containers.weekRow],
341
400
  children: week.map((day) => renderDay(day))
342
401
  }, week[0].toISOString()))
343
402
  })
@@ -351,7 +410,7 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, loca
351
410
  *
352
411
  * @example
353
412
  * ```tsx
354
- * import { MonthView, type CalendarEvent } from "react-native-super-calendar";
413
+ * import { MonthView, type CalendarEvent } from "@super-calendar/native";
355
414
  *
356
415
  * <MonthView
357
416
  * date={new Date()}
@@ -364,8 +423,6 @@ const MonthView = (0, react.memo)(MonthViewInner);
364
423
  const styles$3 = react_native.StyleSheet.create({
365
424
  root: { flex: 1 },
366
425
  title: {
367
- fontSize: 17,
368
- fontWeight: "700",
369
426
  paddingTop: 10,
370
427
  paddingHorizontal: 14,
371
428
  paddingBottom: 6
@@ -417,7 +474,7 @@ const styles$3 = react_native.StyleSheet.create({
417
474
  const isWeb$1 = react_native.Platform.OS === "web";
418
475
  const PAGE_WINDOW$1 = 60;
419
476
  const PAGE_VIEWABILITY = { itemVisiblePercentThreshold: 90 };
420
- function MonthPagerInner({ date, events, maxVisibleEventCount, weekStartsOn, locale, sortedMonthView, moreLabel, showAdjacentMonths, disableMonthEventCellPress, isRTL, calendarCellStyle, renderEvent, keyExtractor, onPressDay, onLongPressDay, onPressEvent, onLongPressEvent, onPressMore, onChangeDate, freeSwipe = false, swipeEnabled = true, showSixWeeks = false, activeDate, renderHeaderForMonthView, renderCustomDateForMonth }) {
477
+ 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 }) {
421
478
  const theme = useCalendarTheme();
422
479
  const { width, height } = (0, react_native.useWindowDimensions)();
423
480
  const listRef = (0, react.useRef)(null);
@@ -545,15 +602,20 @@ function MonthPagerInner({ date, events, maxVisibleEventCount, weekStartsOn, loc
545
602
  ]);
546
603
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
547
604
  ref: containerRef,
548
- style: styles$2.container,
605
+ style: [styles$2.container, theme.containers.monthContainer],
549
606
  children: [
550
607
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
551
- style: [styles$2.monthTitle, { color: theme.colors.text }],
608
+ style: [
609
+ styles$2.monthTitle,
610
+ theme.text.monthTitle,
611
+ { color: theme.colors.text }
612
+ ],
552
613
  allowFontScaling: false,
553
614
  children: (0, date_fns.format)(date, "MMMM yyyy", locale ? { locale } : void 0)
554
615
  }),
555
616
  renderHeaderForMonthView ? renderHeaderForMonthView(weekDays) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MonthWeekdayHeader, {
556
617
  weekDays,
618
+ weekdayFormat,
557
619
  locale
558
620
  }),
559
621
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
@@ -592,7 +654,7 @@ function MonthPagerInner({ date, events, maxVisibleEventCount, weekStartsOn, loc
592
654
  *
593
655
  * @example
594
656
  * ```tsx
595
- * import { MonthPager } from "react-native-super-calendar";
657
+ * import { MonthPager } from "@super-calendar/native";
596
658
  *
597
659
  * <MonthPager
598
660
  * date={date}
@@ -604,10 +666,10 @@ function MonthPagerInner({ date, events, maxVisibleEventCount, weekStartsOn, loc
604
666
  * ```
605
667
  */
606
668
  const MonthPager = (0, react.memo)(MonthPagerInner);
607
- const MonthWeekdayHeader = ({ weekDays, locale }) => {
669
+ const MonthWeekdayHeader = ({ weekDays, weekdayFormat = "short", locale }) => {
608
670
  const theme = useCalendarTheme();
609
671
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
610
- style: styles$2.weekdayHeader,
672
+ style: [styles$2.weekdayHeader, theme.containers.weekdayHeader],
611
673
  children: weekDays.map((day) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
612
674
  style: [
613
675
  theme.text.weekday,
@@ -615,7 +677,7 @@ const MonthWeekdayHeader = ({ weekDays, locale }) => {
615
677
  { color: theme.colors.textMuted }
616
678
  ],
617
679
  allowFontScaling: false,
618
- children: (0, date_fns.format)(day, "EEE", { locale })
680
+ children: (0, date_fns.format)(day, (0, _super_calendar_core.weekdayFormatToken)(weekdayFormat), { locale })
619
681
  }, day.toISOString()))
620
682
  });
621
683
  };
@@ -625,8 +687,6 @@ const styles$2 = react_native.StyleSheet.create({
625
687
  pagerList: { flex: 1 },
626
688
  webNoScroll: { overflow: "hidden" },
627
689
  monthTitle: {
628
- fontSize: 17,
629
- fontWeight: "700",
630
690
  paddingTop: 10,
631
691
  paddingHorizontal: 14,
632
692
  paddingBottom: 6
@@ -649,7 +709,7 @@ const styles$2 = react_native.StyleSheet.create({
649
709
  * default renderer for `MonthList`, so the `/picker` entry point stays free of
650
710
  * Reanimated.
651
711
  */
652
- function DefaultMonthEvent({ event, mode, isAllDay, ampm = false, showTime = true, ellipsizeTitle = false, allDayLabel, cellStyle, onPress, onLongPress }) {
712
+ function DefaultMonthEvent({ event, mode, isAllDay, ampm = false, showTime = true, ellipsizeTitle = false, allDayLabel, accessibilityLabel: accessibilityLabelProp, cellStyle, onPress, onLongPress }) {
653
713
  const theme = useCalendarTheme();
654
714
  const isAllDayEvent = isAllDay ?? false;
655
715
  const timeLabel = (0, _super_calendar_core.eventTimeLabel)({
@@ -662,7 +722,7 @@ function DefaultMonthEvent({ event, mode, isAllDay, ampm = false, showTime = tru
662
722
  allDayLabel
663
723
  });
664
724
  const ellipsizeMode = (0, _super_calendar_core.titleEllipsizeMode)(ellipsizeTitle);
665
- const accessibilityLabel = (0, _super_calendar_core.eventAccessibilityLabel)({
725
+ const accessibilityLabel = accessibilityLabelProp ?? (0, _super_calendar_core.eventAccessibilityLabel)({
666
726
  title: event.title,
667
727
  isAllDay: isAllDayEvent,
668
728
  start: event.start,
@@ -731,7 +791,7 @@ const AUTOSCROLL_INTERVAL_MS = 16;
731
791
  const NO_EVENTS = [];
732
792
  const noop = () => {};
733
793
  const defaultKeyExtractor = (event) => `${event.start.toISOString()}|${event.end.toISOString()}|${event.title ?? ""}`;
734
- function MonthListInner({ date, events = NO_EVENTS, weekStartsOn, 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, keyExtractor = defaultKeyExtractor, onPressDay, onLongPressDay, onPressEvent = noop, onLongPressEvent, onPressMore, onSelectDrag, onChangeVisibleMonth, renderMonthHeader }) {
794
+ 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 }) {
735
795
  const theme = useCalendarTheme();
736
796
  const listRef = (0, react.useRef)(null);
737
797
  const weekRowHeight = weekRowHeightProp ?? (events.length > 0 ? DEFAULT_EVENT_WEEK_ROW_HEIGHT : DEFAULT_WEEK_ROW_HEIGHT);
@@ -951,6 +1011,7 @@ function MonthListInner({ date, events = NO_EVENTS, weekStartsOn, weekRowHeight:
951
1011
  fillCellOnSelection,
952
1012
  calendarCellStyle,
953
1013
  renderEvent,
1014
+ eventAccessibilityLabel,
954
1015
  keyExtractor,
955
1016
  onPressDay: dragEnabled ? handlePressDay : onPressDay,
956
1017
  onLongPressDay,
@@ -1022,7 +1083,7 @@ function MonthListInner({ date, events = NO_EVENTS, weekStartsOn, weekRowHeight:
1022
1083
  children: weekDays.map((day) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Text, {
1023
1084
  style: [styles.weekdayLabel, { color: theme.colors.textMuted }],
1024
1085
  allowFontScaling: false,
1025
- children: (0, date_fns.format)(day, "EEE", { locale })
1086
+ children: (0, date_fns.format)(day, (0, _super_calendar_core.weekdayFormatToken)(weekdayFormat), { locale })
1026
1087
  }, day.toISOString()))
1027
1088
  }), dragGesture && !isWeb ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native_gesture_handler.GestureDetector, {
1028
1089
  gesture: dragGesture,
@@ -1052,7 +1113,7 @@ function MonthBlock({ height, inert, children }) {
1052
1113
  *
1053
1114
  * @example
1054
1115
  * ```tsx
1055
- * import { MonthList } from "react-native-super-calendar/picker";
1116
+ * import { MonthList } from "@super-calendar/native/picker";
1056
1117
  *
1057
1118
  * <MonthList
1058
1119
  * date={new Date()}
@@ -1146,3 +1207,9 @@ Object.defineProperty(exports, "useWebPagerKeys", {
1146
1207
  return useWebPagerKeys;
1147
1208
  }
1148
1209
  });
1210
+ Object.defineProperty(exports, "withEventAccessibilityLabel", {
1211
+ enumerable: true,
1212
+ get: function() {
1213
+ return withEventAccessibilityLabel;
1214
+ }
1215
+ });
@@ -1,6 +1,6 @@
1
1
  import { addMonths, differenceInCalendarMonths, format, isSameMonth, startOfDay, startOfMonth } from "date-fns";
2
2
  import { createContext, memo, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
3
- import { CalendarSelectionProvider, buildMonthWeeks, compareDayEvents, darkColors, dayBadgeKind, daySelectionState, eventAccessibilityLabel, eventTimeLabel, getIsToday, getWeekDays, groupEventsByDay, isAllDayEvent, isDateSelectable, isSameCalendarDay, isWeekend, lightColors, monthEventCapacity, monthVisibleCount, rangeBandKind, titleEllipsizeMode, titleNumberOfLines, useCalendarSelection } from "@super-calendar/core";
3
+ import { CalendarSelectionProvider, buildMonthWeeks, compareDayEvents, darkColors, dayBadgeKind, daySelectionState, eventAccessibilityLabel, eventTimeLabel, getIsToday, getWeekDays, groupEventsByDay, isAllDayEvent, isDateSelectable, isSameCalendarDay, isWeekend, lightColors, monthEventCapacity, monthVisibleCount, rangeBandKind, titleEllipsizeMode, titleNumberOfLines, useCalendarSelection, weekdayFormatToken } from "@super-calendar/core";
4
4
  import { LegendList } from "@legendapp/list/react-native";
5
5
  import { Platform, StyleSheet, Text, TouchableOpacity, View, useWindowDimensions } from "react-native";
6
6
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -18,6 +18,10 @@ const defaultTheme = {
18
18
  fontSize: 13,
19
19
  fontWeight: "700"
20
20
  },
21
+ monthTitle: {
22
+ fontSize: 17,
23
+ fontWeight: "700"
24
+ },
21
25
  dateCell: {
22
26
  fontSize: 13,
23
27
  fontWeight: "700"
@@ -33,6 +37,23 @@ const defaultTheme = {
33
37
  lineHeight: 16
34
38
  }
35
39
  },
40
+ containers: {
41
+ monthContainer: {},
42
+ weekdayHeader: {},
43
+ weekRow: {},
44
+ dayCell: {},
45
+ dayBadge: {},
46
+ monthEvent: {},
47
+ columnHeader: {},
48
+ timeGridEvent: {},
49
+ nowIndicator: {},
50
+ resourceRow: {},
51
+ resourceLabel: {},
52
+ agendaList: {},
53
+ agendaRow: {},
54
+ allDayLane: {},
55
+ allDayColumn: {}
56
+ },
36
57
  todayBadgeRadius: 999,
37
58
  rangeBandHeight: 22
38
59
  };
@@ -44,6 +65,7 @@ const defaultTheme = {
44
65
  const darkTheme = {
45
66
  colors: darkColors,
46
67
  text: defaultTheme.text,
68
+ containers: defaultTheme.containers,
47
69
  todayBadgeRadius: defaultTheme.todayBadgeRadius,
48
70
  rangeBandHeight: defaultTheme.rangeBandHeight
49
71
  };
@@ -59,6 +81,10 @@ function mergeTheme(theme) {
59
81
  ...defaultTheme.text,
60
82
  ...theme.text
61
83
  },
84
+ containers: {
85
+ ...defaultTheme.containers,
86
+ ...theme.containers
87
+ },
62
88
  todayBadgeRadius: theme.todayBadgeRadius ?? defaultTheme.todayBadgeRadius,
63
89
  rangeBandHeight: theme.rangeBandHeight ?? defaultTheme.rangeBandHeight
64
90
  };
@@ -105,6 +131,29 @@ function useWebPagerKeys(enabled, onPage) {
105
131
  }, [enabled, onPage]);
106
132
  }
107
133
  //#endregion
134
+ //#region src/utils/withEventAccessibilityLabel.tsx
135
+ /**
136
+ * Wrap an event renderer so it injects a consumer's `eventAccessibilityLabel`
137
+ * override into `RenderEventArgs.accessibilityLabel`. The built-in renderers use
138
+ * that string in place of their default label, and custom renderers can read it
139
+ * too. Returns the renderer unchanged when no override is set, so the common path
140
+ * pays nothing.
141
+ */
142
+ function withEventAccessibilityLabel(renderEvent, labeler, ampm) {
143
+ if (!labeler) return renderEvent;
144
+ const Base = renderEvent;
145
+ return function LabeledEvent(props) {
146
+ return /* @__PURE__ */ jsx(Base, {
147
+ ...props,
148
+ accessibilityLabel: labeler(props.event, {
149
+ mode: props.mode,
150
+ isAllDay: props.isAllDay ?? false,
151
+ ampm
152
+ })
153
+ });
154
+ };
155
+ }
156
+ //#endregion
108
157
  //#region src/components/MonthView.tsx
109
158
  const isWeb$2 = Platform.OS === "web";
110
159
  const DAY_CELL_PADDING_TOP = 4;
@@ -114,7 +163,7 @@ const CELL_ROW_GAP = 2;
114
163
  const CHIP_PADDING_V = 2;
115
164
  const FALLBACK_VISIBLE_COUNT = 3;
116
165
  const numericStyle = (value, fallback) => typeof value === "number" ? value : fallback;
117
- function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, 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, keyExtractor, onPressDay, onLongPressDay, onPressEvent, onLongPressEvent, onPressMore, renderCustomDateForMonth, onDayPointerDown, onDayPointerEnter }) {
166
+ 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 }) {
118
167
  const theme = useCalendarTheme();
119
168
  const selection = useCalendarSelection();
120
169
  const selectedDates = selectedDatesProp ?? selection.selectedDates;
@@ -122,7 +171,7 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, loca
122
171
  const minDate = minDateProp ?? selection.minDate;
123
172
  const maxDate = maxDateProp ?? selection.maxDate;
124
173
  const isDateDisabled = isDateDisabledProp ?? selection.isDateDisabled;
125
- const RenderEventComponent = renderEvent;
174
+ const RenderEventComponent = useMemo(() => withEventAccessibilityLabel(renderEvent, eventAccessibilityLabel, false), [renderEvent, eventAccessibilityLabel]);
126
175
  const [gridHeight, setGridHeight] = useState(0);
127
176
  const [hoveredKey, setHoveredKey] = useState(null);
128
177
  const [pressedKey, setPressedKey] = useState(null);
@@ -172,11 +221,15 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, loca
172
221
  const showGrid = events.length > 0;
173
222
  const renderDay = (day) => {
174
223
  const isCurrentMonth = isSameMonth(day, date);
175
- if (!isCurrentMonth && !showAdjacentMonths) return /* @__PURE__ */ jsx(View, { style: [styles$3.dayCell, showGrid && {
176
- borderTopWidth: StyleSheet.hairlineWidth,
177
- borderRightWidth: StyleSheet.hairlineWidth,
178
- borderColor: theme.colors.gridLine
179
- }] }, day.toISOString());
224
+ if (!isCurrentMonth && !showAdjacentMonths) return /* @__PURE__ */ jsx(View, { style: [
225
+ styles$3.dayCell,
226
+ showGrid && {
227
+ borderTopWidth: StyleSheet.hairlineWidth,
228
+ borderRightWidth: StyleSheet.hairlineWidth,
229
+ borderColor: theme.colors.gridLine
230
+ },
231
+ theme.containers.dayCell
232
+ ] }, day.toISOString());
180
233
  const dayEvents = eventsByDay.get(startOfDay(day).toISOString()) ?? [];
181
234
  const isToday = getIsToday(day);
182
235
  const isHighlighted = activeDate ? isSameCalendarDay(day, activeDate) : isToday;
@@ -213,7 +266,8 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, loca
213
266
  borderColor: theme.colors.gridLine
214
267
  },
215
268
  isWeekend(day) && { backgroundColor: theme.colors.weekendBackground },
216
- calendarCellStyle?.(day)
269
+ calendarCellStyle?.(day),
270
+ theme.containers.dayCell
217
271
  ],
218
272
  activeOpacity: showGrid ? .2 : 1,
219
273
  ...showGrid ? null : {
@@ -276,7 +330,8 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, loca
276
330
  backgroundColor: theme.colors.hoverBackground,
277
331
  borderRadius: theme.todayBadgeRadius
278
332
  },
279
- !showGrid && pressedKey === dayKey && { opacity: .2 }
333
+ !showGrid && pressedKey === dayKey && { opacity: .2 },
334
+ theme.containers.dayBadge
280
335
  ],
281
336
  children: /* @__PURE__ */ jsx(Text, {
282
337
  style: [theme.text.dateCell, { color: dateColor }],
@@ -285,7 +340,7 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, loca
285
340
  })
286
341
  }),
287
342
  dayEvents.slice(0, visibleCount).map((event, index) => /* @__PURE__ */ jsx(View, {
288
- style: styles$3.monthEvent,
343
+ style: [styles$3.monthEvent, theme.containers.monthEvent],
289
344
  children: /* @__PURE__ */ jsx(RenderEventComponent, {
290
345
  event,
291
346
  mode: "month",
@@ -317,12 +372,16 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, loca
317
372
  style: styles$3.root,
318
373
  children: [
319
374
  showTitle ? /* @__PURE__ */ jsx(Text, {
320
- style: [styles$3.title, { color: theme.colors.text }],
375
+ style: [
376
+ styles$3.title,
377
+ theme.text.monthTitle,
378
+ { color: theme.colors.text }
379
+ ],
321
380
  allowFontScaling: false,
322
381
  children: format(date, "MMMM yyyy", locale ? { locale } : void 0)
323
382
  }) : null,
324
383
  showWeekdays ? /* @__PURE__ */ jsx(View, {
325
- style: styles$3.weekdayHeader,
384
+ style: [styles$3.weekdayHeader, theme.containers.weekdayHeader],
326
385
  children: weekdayLabels.map((day) => /* @__PURE__ */ jsx(Text, {
327
386
  style: [
328
387
  theme.text.weekday,
@@ -330,14 +389,14 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, loca
330
389
  { color: theme.colors.textMuted }
331
390
  ],
332
391
  allowFontScaling: false,
333
- children: format(day, "EEE", { locale })
392
+ children: format(day, weekdayFormatToken(weekdayFormat), { locale })
334
393
  }, day.toISOString()))
335
394
  }) : null,
336
395
  /* @__PURE__ */ jsx(View, {
337
396
  style: styles$3.container,
338
397
  onLayout: handleLayout,
339
398
  children: weeks.map((week) => /* @__PURE__ */ jsx(View, {
340
- style: styles$3.weekRow,
399
+ style: [styles$3.weekRow, theme.containers.weekRow],
341
400
  children: week.map((day) => renderDay(day))
342
401
  }, week[0].toISOString()))
343
402
  })
@@ -351,7 +410,7 @@ function MonthViewInner({ date, events, maxVisibleEventCount, weekStartsOn, loca
351
410
  *
352
411
  * @example
353
412
  * ```tsx
354
- * import { MonthView, type CalendarEvent } from "react-native-super-calendar";
413
+ * import { MonthView, type CalendarEvent } from "@super-calendar/native";
355
414
  *
356
415
  * <MonthView
357
416
  * date={new Date()}
@@ -364,8 +423,6 @@ const MonthView = memo(MonthViewInner);
364
423
  const styles$3 = StyleSheet.create({
365
424
  root: { flex: 1 },
366
425
  title: {
367
- fontSize: 17,
368
- fontWeight: "700",
369
426
  paddingTop: 10,
370
427
  paddingHorizontal: 14,
371
428
  paddingBottom: 6
@@ -417,7 +474,7 @@ const styles$3 = StyleSheet.create({
417
474
  const isWeb$1 = Platform.OS === "web";
418
475
  const PAGE_WINDOW$1 = 60;
419
476
  const PAGE_VIEWABILITY = { itemVisiblePercentThreshold: 90 };
420
- function MonthPagerInner({ date, events, maxVisibleEventCount, weekStartsOn, locale, sortedMonthView, moreLabel, showAdjacentMonths, disableMonthEventCellPress, isRTL, calendarCellStyle, renderEvent, keyExtractor, onPressDay, onLongPressDay, onPressEvent, onLongPressEvent, onPressMore, onChangeDate, freeSwipe = false, swipeEnabled = true, showSixWeeks = false, activeDate, renderHeaderForMonthView, renderCustomDateForMonth }) {
477
+ 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 }) {
421
478
  const theme = useCalendarTheme();
422
479
  const { width, height } = useWindowDimensions();
423
480
  const listRef = useRef(null);
@@ -545,15 +602,20 @@ function MonthPagerInner({ date, events, maxVisibleEventCount, weekStartsOn, loc
545
602
  ]);
546
603
  return /* @__PURE__ */ jsxs(View, {
547
604
  ref: containerRef,
548
- style: styles$2.container,
605
+ style: [styles$2.container, theme.containers.monthContainer],
549
606
  children: [
550
607
  /* @__PURE__ */ jsx(Text, {
551
- style: [styles$2.monthTitle, { color: theme.colors.text }],
608
+ style: [
609
+ styles$2.monthTitle,
610
+ theme.text.monthTitle,
611
+ { color: theme.colors.text }
612
+ ],
552
613
  allowFontScaling: false,
553
614
  children: format(date, "MMMM yyyy", locale ? { locale } : void 0)
554
615
  }),
555
616
  renderHeaderForMonthView ? renderHeaderForMonthView(weekDays) : /* @__PURE__ */ jsx(MonthWeekdayHeader, {
556
617
  weekDays,
618
+ weekdayFormat,
557
619
  locale
558
620
  }),
559
621
  /* @__PURE__ */ jsx(View, {
@@ -592,7 +654,7 @@ function MonthPagerInner({ date, events, maxVisibleEventCount, weekStartsOn, loc
592
654
  *
593
655
  * @example
594
656
  * ```tsx
595
- * import { MonthPager } from "react-native-super-calendar";
657
+ * import { MonthPager } from "@super-calendar/native";
596
658
  *
597
659
  * <MonthPager
598
660
  * date={date}
@@ -604,10 +666,10 @@ function MonthPagerInner({ date, events, maxVisibleEventCount, weekStartsOn, loc
604
666
  * ```
605
667
  */
606
668
  const MonthPager = memo(MonthPagerInner);
607
- const MonthWeekdayHeader = ({ weekDays, locale }) => {
669
+ const MonthWeekdayHeader = ({ weekDays, weekdayFormat = "short", locale }) => {
608
670
  const theme = useCalendarTheme();
609
671
  return /* @__PURE__ */ jsx(View, {
610
- style: styles$2.weekdayHeader,
672
+ style: [styles$2.weekdayHeader, theme.containers.weekdayHeader],
611
673
  children: weekDays.map((day) => /* @__PURE__ */ jsx(Text, {
612
674
  style: [
613
675
  theme.text.weekday,
@@ -615,7 +677,7 @@ const MonthWeekdayHeader = ({ weekDays, locale }) => {
615
677
  { color: theme.colors.textMuted }
616
678
  ],
617
679
  allowFontScaling: false,
618
- children: format(day, "EEE", { locale })
680
+ children: format(day, weekdayFormatToken(weekdayFormat), { locale })
619
681
  }, day.toISOString()))
620
682
  });
621
683
  };
@@ -625,8 +687,6 @@ const styles$2 = StyleSheet.create({
625
687
  pagerList: { flex: 1 },
626
688
  webNoScroll: { overflow: "hidden" },
627
689
  monthTitle: {
628
- fontSize: 17,
629
- fontWeight: "700",
630
690
  paddingTop: 10,
631
691
  paddingHorizontal: 14,
632
692
  paddingBottom: 6
@@ -649,7 +709,7 @@ const styles$2 = StyleSheet.create({
649
709
  * default renderer for `MonthList`, so the `/picker` entry point stays free of
650
710
  * Reanimated.
651
711
  */
652
- function DefaultMonthEvent({ event, mode, isAllDay, ampm = false, showTime = true, ellipsizeTitle = false, allDayLabel, cellStyle, onPress, onLongPress }) {
712
+ function DefaultMonthEvent({ event, mode, isAllDay, ampm = false, showTime = true, ellipsizeTitle = false, allDayLabel, accessibilityLabel: accessibilityLabelProp, cellStyle, onPress, onLongPress }) {
653
713
  const theme = useCalendarTheme();
654
714
  const isAllDayEvent = isAllDay ?? false;
655
715
  const timeLabel = eventTimeLabel({
@@ -662,7 +722,7 @@ function DefaultMonthEvent({ event, mode, isAllDay, ampm = false, showTime = tru
662
722
  allDayLabel
663
723
  });
664
724
  const ellipsizeMode = titleEllipsizeMode(ellipsizeTitle);
665
- const accessibilityLabel = eventAccessibilityLabel({
725
+ const accessibilityLabel = accessibilityLabelProp ?? eventAccessibilityLabel({
666
726
  title: event.title,
667
727
  isAllDay: isAllDayEvent,
668
728
  start: event.start,
@@ -731,7 +791,7 @@ const AUTOSCROLL_INTERVAL_MS = 16;
731
791
  const NO_EVENTS = [];
732
792
  const noop = () => {};
733
793
  const defaultKeyExtractor = (event) => `${event.start.toISOString()}|${event.end.toISOString()}|${event.title ?? ""}`;
734
- function MonthListInner({ date, events = NO_EVENTS, weekStartsOn, 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, keyExtractor = defaultKeyExtractor, onPressDay, onLongPressDay, onPressEvent = noop, onLongPressEvent, onPressMore, onSelectDrag, onChangeVisibleMonth, renderMonthHeader }) {
794
+ 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 }) {
735
795
  const theme = useCalendarTheme();
736
796
  const listRef = useRef(null);
737
797
  const weekRowHeight = weekRowHeightProp ?? (events.length > 0 ? DEFAULT_EVENT_WEEK_ROW_HEIGHT : DEFAULT_WEEK_ROW_HEIGHT);
@@ -951,6 +1011,7 @@ function MonthListInner({ date, events = NO_EVENTS, weekStartsOn, weekRowHeight:
951
1011
  fillCellOnSelection,
952
1012
  calendarCellStyle,
953
1013
  renderEvent,
1014
+ eventAccessibilityLabel,
954
1015
  keyExtractor,
955
1016
  onPressDay: dragEnabled ? handlePressDay : onPressDay,
956
1017
  onLongPressDay,
@@ -1022,7 +1083,7 @@ function MonthListInner({ date, events = NO_EVENTS, weekStartsOn, weekRowHeight:
1022
1083
  children: weekDays.map((day) => /* @__PURE__ */ jsx(Text, {
1023
1084
  style: [styles.weekdayLabel, { color: theme.colors.textMuted }],
1024
1085
  allowFontScaling: false,
1025
- children: format(day, "EEE", { locale })
1086
+ children: format(day, weekdayFormatToken(weekdayFormat), { locale })
1026
1087
  }, day.toISOString()))
1027
1088
  }), dragGesture && !isWeb ? /* @__PURE__ */ jsx(GestureDetector, {
1028
1089
  gesture: dragGesture,
@@ -1052,7 +1113,7 @@ function MonthBlock({ height, inert, children }) {
1052
1113
  *
1053
1114
  * @example
1054
1115
  * ```tsx
1055
- * import { MonthList } from "react-native-super-calendar/picker";
1116
+ * import { MonthList } from "@super-calendar/native/picker";
1056
1117
  *
1057
1118
  * <MonthList
1058
1119
  * date={new Date()}
@@ -1086,4 +1147,4 @@ const styles = StyleSheet.create({
1086
1147
  }
1087
1148
  });
1088
1149
  //#endregion
1089
- export { useWebPagerKeys as a, defaultTheme as c, MonthView as i, mergeTheme as l, DefaultMonthEvent as n, CalendarThemeProvider as o, MonthPager as r, darkTheme as s, MonthList as t, useCalendarTheme as u };
1150
+ export { withEventAccessibilityLabel as a, darkTheme as c, useCalendarTheme as d, MonthView as i, defaultTheme as l, DefaultMonthEvent as n, useWebPagerKeys as o, MonthPager as r, CalendarThemeProvider as s, MonthList as t, mergeTheme as u };