@super-calendar/native 2.10.0 → 2.11.1

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.
@@ -9,6 +9,7 @@ import {
9
9
  Text,
10
10
  type TextStyle,
11
11
  View,
12
+ type ScrollViewProps,
12
13
  } from "react-native";
13
14
  import { Gesture, GestureDetector, type PanGesture } from "react-native-gesture-handler";
14
15
  import { useCalendarTheme } from "../theme";
@@ -32,6 +33,11 @@ import {
32
33
  rangeBandKind,
33
34
  weekdayFormatToken,
34
35
  } from "@super-calendar/core";
36
+ import {
37
+ type CalendarLabels,
38
+ dayAccessibilityLabel,
39
+ resolveCalendarLabels,
40
+ } from "@super-calendar/core";
35
41
 
36
42
  const isWeb = Platform.OS === "web";
37
43
  // Hold before a year-grid drag takes over, so a tap still opens the day.
@@ -66,6 +72,8 @@ export type YearViewProps<T = unknown> = SlotStyleProps<YearViewSlot> & {
66
72
  /** Weekdays (0=Sunday…6=Saturday) hidden from the grid, e.g. `[0, 6]` for weekends off. */
67
73
  hiddenDays?: number[];
68
74
  locale?: Locale;
75
+ /** Translations for the screen-reader words; omitted keys use English. */
76
+ labels?: Partial<CalendarLabels>;
69
77
  /** Highlight this date instead of the real "today". */
70
78
  activeDate?: Date;
71
79
  /** A selected span: endpoints get a filled badge, the days between get the range band. */
@@ -103,6 +111,8 @@ export type YearViewProps<T = unknown> = SlotStyleProps<YearViewSlot> & {
103
111
  * the last, exclusive). A plain tap still fires `onPressDay`, not this.
104
112
  */
105
113
  onCreateEvent?: (start: Date, end: Date) => void;
114
+ /** Pull-to-refresh control, mounted on the year's scroll view. */
115
+ refreshControl?: ScrollViewProps["refreshControl"];
106
116
  };
107
117
 
108
118
  // Seed before the first layout pass so the grid renders immediately (and in
@@ -115,6 +125,7 @@ function YearViewInner<T>({
115
125
  weekStartsOn,
116
126
  hiddenDays,
117
127
  locale,
128
+ labels: labelsProp,
118
129
  activeDate,
119
130
  selectedRange,
120
131
  selectedDates,
@@ -126,10 +137,12 @@ function YearViewInner<T>({
126
137
  onPressMonth,
127
138
  onSelectDrag,
128
139
  onCreateEvent,
140
+ refreshControl,
129
141
  classNames,
130
142
  styles: styleOverrides,
131
143
  }: YearViewProps<T>): ReactElement {
132
144
  const theme = useCalendarTheme();
145
+ const labels = useMemo(() => resolveCalendarLabels(labelsProp), [labelsProp]);
133
146
  const slot = createSlots<YearViewSlot>({ classNames, styles: styleOverrides });
134
147
 
135
148
  const [columns, setColumns] = useState(FALLBACK_COLUMNS);
@@ -244,6 +257,7 @@ function YearViewInner<T>({
244
257
  // under the finger. On the web a press arms it immediately, so freezing
245
258
  // there would cost every touch scroll; the browser arbitrates instead.
246
259
  scrollEnabled={isWeb || sweep == null}
260
+ refreshControl={refreshControl}
247
261
  >
248
262
  <View {...slot("grid", { base: styles.grid })}>
249
263
  {months.map((month, monthIndex) => {
@@ -335,11 +349,14 @@ function YearViewInner<T>({
335
349
  sweep != null &&
336
350
  dayTime >= Math.min(sweep.anchor, sweep.hover) &&
337
351
  dayTime <= Math.max(sweep.anchor, sweep.hover);
338
- const label = `${format(day, "EEEE, d LLLL yyyy", { locale })}${
339
- isToday ? ", today" : ""
340
- }${state.isSelected ? ", selected" : ""}${
341
- state.isDisabled ? ", unavailable" : ""
342
- }${hasEvents ? ", has events" : ""}`;
352
+ const label = dayAccessibilityLabel({
353
+ dateLabel: format(day, "EEEE, d LLLL yyyy", { locale }),
354
+ isToday,
355
+ isSelected: state.isSelected,
356
+ isDisabled: state.isDisabled,
357
+ hasEvents,
358
+ labels,
359
+ });
343
360
  // Today wins over a selection, matching the month grid.
344
361
  const badge = dayBadgeKind(state, isHighlighted);
345
362
  const daySlot = slot("day", { base: styles.day });
package/src/index.tsx CHANGED
@@ -98,6 +98,7 @@ export {
98
98
  weekdayFormatToken,
99
99
  } from "@super-calendar/core";
100
100
  export { expandRecurringEvents } from "@super-calendar/core";
101
+ export { type CalendarLabels, defaultCalendarLabels } from "@super-calendar/core";
101
102
  export {
102
103
  type ICalEvent,
103
104
  parseICalendar,
@@ -0,0 +1,13 @@
1
+ import { type CalendarLabels, defaultCalendarLabels } from "@super-calendar/core";
2
+ import { type Context, createContext, useContext } from "react";
3
+
4
+ /**
5
+ * The resolved `labels` of the nearest view, so the built-in event renderers
6
+ * can localize their screen-reader text without a prop on `RenderEventArgs`.
7
+ */
8
+ export const CalendarLabelsContext: Context<CalendarLabels> =
9
+ createContext<CalendarLabels>(defaultCalendarLabels);
10
+
11
+ export function useCalendarLabels(): CalendarLabels {
12
+ return useContext(CalendarLabelsContext);
13
+ }