@super-calendar/native 2.11.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.
@@ -89,7 +89,8 @@ import {
89
89
  snapDeltaMinutes,
90
90
  } from "@super-calendar/core";
91
91
  import { formatHour, layoutDayEvents, type PositionedEvent } from "@super-calendar/core";
92
- import type { EventAccessibilityLabeler } from "@super-calendar/core";
92
+ import type { CalendarLabels, EventAccessibilityLabeler } from "@super-calendar/core";
93
+ import { resolveCalendarLabels } from "@super-calendar/core";
93
94
  import { type WeekdayFormat, weekdayFormatToken } from "@super-calendar/core";
94
95
  import {
95
96
  type ResolvedSlot,
@@ -100,6 +101,7 @@ import {
100
101
  import { useWebGridZoom } from "../utils/useWebGridZoom";
101
102
  import { useWebPagerKeys } from "../utils/useWebPagerKeys";
102
103
  import { withEventAccessibilityLabel } from "../utils/withEventAccessibilityLabel";
104
+ import { CalendarLabelsContext, useCalendarLabels } from "../utils/labels";
103
105
  import { AllDayLane } from "./AllDayLane";
104
106
  import { type MultiDayMove, MultiDayMovePreview } from "./MultiDayMovePreview";
105
107
 
@@ -414,6 +416,7 @@ function AnimatedEventBoxInner<T>({
414
416
  }: AnimatedEventBoxProps<T>) {
415
417
  const RenderEventComponent = renderEvent;
416
418
  const theme = useCalendarTheme();
419
+ const labels = useCalendarLabels();
417
420
  const slot = useSlots<TimeGridSlot>();
418
421
  // Pager geometry, so a cross-week edge drag can find the edges and page the
419
422
  // view live under the finger (see EdgePaging). The two edge
@@ -1020,31 +1023,23 @@ function AnimatedEventBoxInner<T>({
1020
1023
  // Dragging is gesture-only, so expose the same move/resize commit path as
1021
1024
  // discrete screen-reader actions (VoiceOver/TalkBack invoke them from the
1022
1025
  // actions menu). Steps are one `snapMinutes` unit, matching a drag snap.
1023
- const unit = (n: number) => `${n} minute${n === 1 ? "" : "s"}`;
1024
- // Label the whole-page move by what a page means in this mode.
1025
- const pageUnit =
1026
- mode === "week"
1027
- ? "week"
1028
- : daysPerPage === 1
1029
- ? "day"
1030
- : `${daysPerPage} day${daysPerPage === 1 ? "" : "s"}`;
1031
1026
  const dragActions = [
1032
1027
  ...(canMove
1033
1028
  ? [
1034
- { name: "move-later", label: `Move ${unit(snapMinutes)} later` },
1035
- { name: "move-earlier", label: `Move ${unit(snapMinutes)} earlier` },
1029
+ { name: "move-later", label: labels.moveLater(snapMinutes) },
1030
+ { name: "move-earlier", label: labels.moveEarlier(snapMinutes) },
1036
1031
  ]
1037
1032
  : []),
1038
1033
  ...(resizable
1039
1034
  ? [
1040
- { name: "extend", label: `Extend by ${unit(snapMinutes)}` },
1041
- { name: "shrink", label: `Shorten by ${unit(snapMinutes)}` },
1035
+ { name: "extend", label: labels.extend(snapMinutes) },
1036
+ { name: "shrink", label: labels.shorten(snapMinutes) },
1042
1037
  ]
1043
1038
  : []),
1044
1039
  ...(canMove
1045
1040
  ? [
1046
- { name: "move-next-page", label: `Move to next ${pageUnit}` },
1047
- { name: "move-previous-page", label: `Move to previous ${pageUnit}` },
1041
+ { name: "move-next-page", label: labels.moveToNextPage(daysPerPage, mode) },
1042
+ { name: "move-previous-page", label: labels.moveToPreviousPage(daysPerPage, mode) },
1048
1043
  ]
1049
1044
  : []),
1050
1045
  ];
@@ -1228,6 +1223,8 @@ type HourGutterProps = {
1228
1223
  /** Draw the "all-day" text in the lane cell. Default off, so an empty lane reads
1229
1224
  * as neutral space rather than a labelled-but-empty row. */
1230
1225
  showAllDayLabel: boolean;
1226
+ /** The text drawn when `showAllDayLabel` is on. */
1227
+ allDayLabel: string;
1231
1228
  /** Height of the day-header corner above the "all-day" cell (0 when the header
1232
1229
  * isn't paged, i.e. a custom `renderHeader` draws its own fixed header). */
1233
1230
  headerHeight: number;
@@ -1251,6 +1248,7 @@ const HourGutterInner = ({
1251
1248
  scrollY,
1252
1249
  showLane,
1253
1250
  showAllDayLabel,
1251
+ allDayLabel,
1254
1252
  headerHeight,
1255
1253
  weekNumber,
1256
1254
  ampm,
@@ -1315,7 +1313,7 @@ const HourGutterInner = ({
1315
1313
  })}
1316
1314
  allowFontScaling={false}
1317
1315
  >
1318
- all-day
1316
+ {allDayLabel}
1319
1317
  </Text>
1320
1318
  ) : null}
1321
1319
  </Animated.View>
@@ -1558,6 +1556,7 @@ type TimetablePageProps<T> = {
1558
1556
  * `renderHeader` owns a fixed header above the pager. */
1559
1557
  pagedHeader: boolean;
1560
1558
  weekdayFormat?: WeekdayFormat;
1559
+ todayLabel: string;
1561
1560
  locale?: Locale;
1562
1561
  activeDate?: Date;
1563
1562
  onPressDateHeader?: (date: Date) => void;
@@ -1615,6 +1614,7 @@ function TimetablePageInner<T>({
1615
1614
  height,
1616
1615
  pagedHeader,
1617
1616
  weekdayFormat,
1617
+ todayLabel,
1618
1618
  locale,
1619
1619
  activeDate,
1620
1620
  onPressDateHeader,
@@ -1923,6 +1923,7 @@ function TimetablePageInner<T>({
1923
1923
  mode={mode}
1924
1924
  dayWidth={dayWidth}
1925
1925
  weekdayFormat={weekdayFormat}
1926
+ todayLabel={todayLabel}
1926
1927
  locale={locale}
1927
1928
  activeDate={activeDate}
1928
1929
  onPressDateHeader={onPressDateHeader}
@@ -2223,6 +2224,8 @@ export type TimeGridProps<T> = SlotStyleProps<TimeGridSlot> & {
2223
2224
  weekStartsOn: WeekStartsOn;
2224
2225
  /** Column-header weekday label width: `narrow` ("M"), `short` ("Mon", default), or `long` ("Monday"). */
2225
2226
  weekdayFormat?: WeekdayFormat;
2227
+ /** Translations for the screen-reader words and gutter text; omitted keys use English. */
2228
+ labels?: Partial<CalendarLabels>;
2226
2229
  renderEvent: RenderEvent<T>;
2227
2230
  /**
2228
2231
  * Override the screen-reader label for each event. Receives the event and a
@@ -2345,6 +2348,7 @@ function TimeGridInner<T>({
2345
2348
  hourHeight = DEFAULT_HOUR_HEIGHT,
2346
2349
  weekStartsOn,
2347
2350
  weekdayFormat = "short",
2351
+ labels: labelsProp,
2348
2352
  renderEvent,
2349
2353
  eventAccessibilityLabel,
2350
2354
  keyExtractor,
@@ -2406,6 +2410,8 @@ function TimeGridInner<T>({
2406
2410
  const clampedMaxHour = Math.max(clampedMinHour + 1, Math.min(maxHour, HOURS_PER_DAY));
2407
2411
  // Collapse the hour gutter to zero when hours are hidden.
2408
2412
  const hourColumnWidth = hideHours ? 0 : hourColumnWidthProp;
2413
+ const labels = useMemo(() => resolveCalendarLabels(labelsProp), [labelsProp]);
2414
+ const todayLabel = labels.today;
2409
2415
  // The built-in day header pages with the columns (rendered inside each page). A
2410
2416
  // custom `renderHeader` keeps a single fixed header above the pager instead, so
2411
2417
  // the pages carry no header and nothing offsets by its height.
@@ -3034,6 +3040,7 @@ function TimeGridInner<T>({
3034
3040
  height={pagerHeight}
3035
3041
  pagedHeader={pagedHeader}
3036
3042
  weekdayFormat={weekdayFormat}
3043
+ todayLabel={todayLabel}
3037
3044
  locale={locale}
3038
3045
  activeDate={activeDate}
3039
3046
  onPressDateHeader={onPressDateHeader}
@@ -3044,6 +3051,7 @@ function TimeGridInner<T>({
3044
3051
  pagerHeight,
3045
3052
  pagedHeader,
3046
3053
  weekdayFormat,
3054
+ todayLabel,
3047
3055
  locale,
3048
3056
  activeDate,
3049
3057
  onPressDateHeader,
@@ -3104,144 +3112,149 @@ function TimeGridInner<T>({
3104
3112
 
3105
3113
  return (
3106
3114
  <SlotStylesProvider classNames={classNames} styles={styleOverrides}>
3107
- <EdgePagingContext.Provider value={edgePaging}>
3108
- <View
3109
- ref={containerRef}
3110
- style={styles.container}
3111
- onLayout={(event) => setContainerWidth(event.nativeEvent.layout.width)}
3112
- >
3113
- {renderHeader ? renderHeader(headerDays) : null}
3114
-
3115
- {headerComponent}
3116
-
3115
+ <CalendarLabelsContext.Provider value={labels}>
3116
+ <EdgePagingContext.Provider value={edgePaging}>
3117
3117
  <View
3118
- ref={viewportRef}
3119
- style={styles.viewport}
3120
- onLayout={() => {
3121
- seedWebScroll();
3122
- // Window-space top of the scroll viewport, for the drag worklets'
3123
- // ghost placement (layout gives parent-relative coords, not window).
3124
- viewportRef.current?.measureInWindow((_x, y) => {
3125
- // eslint-disable-next-line react-hooks/immutability -- Reanimated shared value: assigning .value is the intended mutation API
3126
- viewportTop.value = y;
3127
- });
3128
- }}
3118
+ ref={containerRef}
3119
+ style={styles.container}
3120
+ onLayout={(event) => setContainerWidth(event.nativeEvent.layout.width)}
3129
3121
  >
3130
- <GestureDetector gesture={zoomGesture}>
3131
- <Animated.ScrollView
3132
- ref={scrollRef}
3133
- showsVerticalScrollIndicator={showVerticalScrollIndicator}
3134
- scrollEnabled={verticalScrollEnabled}
3135
- onScroll={scrollHandler}
3136
- scrollEventThrottle={16}
3137
- refreshControl={verticalScrollEnabled ? refreshControl : undefined}
3138
- contentOffset={{ x: 0, y: seedDefaultY }}
3139
- >
3140
- <Animated.View testID="time-grid-hours" style={[styles.gridRow, gridHeightStyle]}>
3141
- {hourColumnWidth > 0 ? (
3142
- <HourGutter
3143
- width={hourColumnWidth}
3144
- minHour={clampedMinHour}
3145
- maxHour={clampedMaxHour}
3146
- cellHeight={cellHeight}
3147
- laneHeight={laneHeight}
3148
- scrollY={scrollY}
3149
- showLane={showAllDayEventCell}
3150
- showAllDayLabel={showAllDayLabel}
3151
- headerHeight={headerOffset}
3152
- weekNumber={weekNumber}
3153
- ampm={ampm}
3154
- hourComponent={hourComponent}
3155
- />
3156
- ) : null}
3157
- <View
3158
- ref={pagerRef}
3159
- testID="time-grid-pager"
3160
- style={[styles.pager, { left: hourColumnWidth, height: pagerHeight }]}
3161
- onLayout={(event) => {
3162
- // Window-space frame of the pager for the drag worklets' edge
3163
- // detection and ghost placement. Only a width change matters
3164
- // (the grid's or the hour column's); the zoom changes the
3165
- // height every frame, so those layouts are skipped.
3166
- const laidOutWidth = event.nativeEvent.layout.width;
3167
- if (laidOutWidth === pagerLayoutWidthRef.current) return;
3168
- pagerLayoutWidthRef.current = laidOutWidth;
3169
- setPagerLayoutWidth(laidOutWidth);
3170
- pagerRef.current?.measureInWindow((x, _y, measuredWidth) => {
3171
- // eslint-disable-next-line react-hooks/immutability -- Reanimated shared value: assigning .value is the intended mutation API
3172
- pagerLeft.value = x;
3173
- // eslint-disable-next-line react-hooks/immutability -- Reanimated shared value: assigning .value is the intended mutation API
3174
- pagerWidth.value = measuredWidth;
3175
- });
3176
- }}
3177
- >
3178
- {pagerReady ? (
3179
- <AnimatedLegendList
3180
- // Mounts once the pager has measured, so the fixed item size is
3181
- // right from the list's first layout; the key remounts it on a
3182
- // later width change (a rotation, a re-measured container).
3183
- key={`grid-${columnsWidth}`}
3184
- ref={listRef}
3185
- style={isWeb ? [styles.pagerList, styles.webNoScroll] : styles.pagerList}
3186
- data={pageDates}
3187
- extraData={listExtraData}
3188
- horizontal
3189
- recycleItems={false}
3190
- keyExtractor={keyExtractorList}
3191
- getFixedItemSize={getFixedItemSize}
3192
- // Mount the next pages either side while idle, not mid-swipe.
3193
- drawDistance={columnsWidth * 2}
3194
- // The live horizontal offset, kept on the UI thread, drives the
3195
- // all-day band's height.
3196
- sharedValues={pagerSharedValues}
3197
- // On web LegendList ignores these RN scroll props (it leaks them to the
3198
- // DOM as unknown attributes), so omit them there and disable horizontal
3199
- // scroll via `webNoScroll`; paging is driven by the arrow keys instead.
3200
- // Native: paging makes each swipe hard-stop at the adjacent page, while
3201
- // `freeSwipe` lets momentum carry across pages and snap to a boundary.
3202
- {...(isWeb
3203
- ? null
3204
- : {
3205
- scrollEnabled: swipeEnabled,
3206
- pagingEnabled: !freeSwipe,
3207
- snapToIndices: freeSwipe ? snapToIndices : undefined,
3208
- // Paging: snap to the adjacent page quickly instead of the
3209
- // slow platform glide, and stop at that page rather than
3210
- // drifting, so rapid one-week swipes land crisply instead of
3211
- // queuing a long chain of drawn-out snaps. `freeSwipe` keeps
3212
- // its momentum, so it can still fling across several pages.
3213
- decelerationRate: freeSwipe ? ("normal" as const) : ("fast" as const),
3214
- disableIntervalMomentum: !freeSwipe,
3215
- scrollEventThrottle: 16,
3216
- onMomentumScrollEnd: handlePagerSettled,
3217
- })}
3218
- initialScrollIndex={activeIndex}
3219
- showsHorizontalScrollIndicator={false}
3220
- viewabilityConfig={PAGE_VIEWABILITY}
3221
- onViewableItemsChanged={handleViewableItemsChanged}
3222
- renderItem={renderItem}
3223
- />
3224
- ) : null}
3225
- {liftedEvent ? (
3226
- <DragGhost
3227
- x={ghostX}
3228
- y={ghostY}
3229
- w={ghostW}
3230
- h={ghostH}
3231
- visible={ghostVisible}
3232
- event={liftedEvent}
3233
- mode={mode}
3234
- renderEvent={labeledRenderEvent}
3235
- eventGap={eventGap}
3122
+ {renderHeader ? renderHeader(headerDays) : null}
3123
+
3124
+ {headerComponent}
3125
+
3126
+ <View
3127
+ ref={viewportRef}
3128
+ style={styles.viewport}
3129
+ onLayout={() => {
3130
+ seedWebScroll();
3131
+ // Window-space top of the scroll viewport, for the drag worklets'
3132
+ // ghost placement (layout gives parent-relative coords, not window).
3133
+ viewportRef.current?.measureInWindow((_x, y) => {
3134
+ // eslint-disable-next-line react-hooks/immutability -- Reanimated shared value: assigning .value is the intended mutation API
3135
+ viewportTop.value = y;
3136
+ });
3137
+ }}
3138
+ >
3139
+ <GestureDetector gesture={zoomGesture}>
3140
+ <Animated.ScrollView
3141
+ ref={scrollRef}
3142
+ showsVerticalScrollIndicator={showVerticalScrollIndicator}
3143
+ scrollEnabled={verticalScrollEnabled}
3144
+ onScroll={scrollHandler}
3145
+ scrollEventThrottle={16}
3146
+ refreshControl={verticalScrollEnabled ? refreshControl : undefined}
3147
+ contentOffset={{ x: 0, y: seedDefaultY }}
3148
+ >
3149
+ <Animated.View testID="time-grid-hours" style={[styles.gridRow, gridHeightStyle]}>
3150
+ {hourColumnWidth > 0 ? (
3151
+ <HourGutter
3152
+ width={hourColumnWidth}
3153
+ minHour={clampedMinHour}
3154
+ maxHour={clampedMaxHour}
3155
+ cellHeight={cellHeight}
3156
+ laneHeight={laneHeight}
3157
+ scrollY={scrollY}
3158
+ showLane={showAllDayEventCell}
3159
+ showAllDayLabel={showAllDayLabel}
3160
+ allDayLabel={labels.allDay}
3161
+ headerHeight={headerOffset}
3162
+ weekNumber={weekNumber}
3163
+ ampm={ampm}
3164
+ hourComponent={hourComponent}
3236
3165
  />
3237
3166
  ) : null}
3238
- </View>
3239
- </Animated.View>
3240
- </Animated.ScrollView>
3241
- </GestureDetector>
3167
+ <View
3168
+ ref={pagerRef}
3169
+ testID="time-grid-pager"
3170
+ style={[styles.pager, { left: hourColumnWidth, height: pagerHeight }]}
3171
+ onLayout={(event) => {
3172
+ // Window-space frame of the pager for the drag worklets' edge
3173
+ // detection and ghost placement. Only a width change matters
3174
+ // (the grid's or the hour column's); the zoom changes the
3175
+ // height every frame, so those layouts are skipped.
3176
+ const laidOutWidth = event.nativeEvent.layout.width;
3177
+ if (laidOutWidth === pagerLayoutWidthRef.current) return;
3178
+ pagerLayoutWidthRef.current = laidOutWidth;
3179
+ setPagerLayoutWidth(laidOutWidth);
3180
+ pagerRef.current?.measureInWindow((x, _y, measuredWidth) => {
3181
+ // eslint-disable-next-line react-hooks/immutability -- Reanimated shared value: assigning .value is the intended mutation API
3182
+ pagerLeft.value = x;
3183
+ // eslint-disable-next-line react-hooks/immutability -- Reanimated shared value: assigning .value is the intended mutation API
3184
+ pagerWidth.value = measuredWidth;
3185
+ });
3186
+ }}
3187
+ >
3188
+ {pagerReady ? (
3189
+ <AnimatedLegendList
3190
+ // Mounts once the pager has measured, so the fixed item size is
3191
+ // right from the list's first layout; the key remounts it on a
3192
+ // later width change (a rotation, a re-measured container).
3193
+ key={`grid-${columnsWidth}`}
3194
+ ref={listRef}
3195
+ style={isWeb ? [styles.pagerList, styles.webNoScroll] : styles.pagerList}
3196
+ data={pageDates}
3197
+ extraData={listExtraData}
3198
+ horizontal
3199
+ recycleItems={false}
3200
+ keyExtractor={keyExtractorList}
3201
+ getFixedItemSize={getFixedItemSize}
3202
+ // Mount the next pages either side while idle, not mid-swipe.
3203
+ drawDistance={columnsWidth * 2}
3204
+ // The live horizontal offset, kept on the UI thread, drives the
3205
+ // all-day band's height.
3206
+ sharedValues={pagerSharedValues}
3207
+ // On web LegendList ignores these RN scroll props (it leaks them to the
3208
+ // DOM as unknown attributes), so omit them there and disable horizontal
3209
+ // scroll via `webNoScroll`; paging is driven by the arrow keys instead.
3210
+ // Native: paging makes each swipe hard-stop at the adjacent page, while
3211
+ // `freeSwipe` lets momentum carry across pages and snap to a boundary.
3212
+ {...(isWeb
3213
+ ? null
3214
+ : {
3215
+ scrollEnabled: swipeEnabled,
3216
+ pagingEnabled: !freeSwipe,
3217
+ snapToIndices: freeSwipe ? snapToIndices : undefined,
3218
+ // Paging: snap to the adjacent page quickly instead of the
3219
+ // slow platform glide, and stop at that page rather than
3220
+ // drifting, so rapid one-week swipes land crisply instead of
3221
+ // queuing a long chain of drawn-out snaps. `freeSwipe` keeps
3222
+ // its momentum, so it can still fling across several pages.
3223
+ decelerationRate: freeSwipe
3224
+ ? ("normal" as const)
3225
+ : ("fast" as const),
3226
+ disableIntervalMomentum: !freeSwipe,
3227
+ scrollEventThrottle: 16,
3228
+ onMomentumScrollEnd: handlePagerSettled,
3229
+ })}
3230
+ initialScrollIndex={activeIndex}
3231
+ showsHorizontalScrollIndicator={false}
3232
+ viewabilityConfig={PAGE_VIEWABILITY}
3233
+ onViewableItemsChanged={handleViewableItemsChanged}
3234
+ renderItem={renderItem}
3235
+ />
3236
+ ) : null}
3237
+ {liftedEvent ? (
3238
+ <DragGhost
3239
+ x={ghostX}
3240
+ y={ghostY}
3241
+ w={ghostW}
3242
+ h={ghostH}
3243
+ visible={ghostVisible}
3244
+ event={liftedEvent}
3245
+ mode={mode}
3246
+ renderEvent={labeledRenderEvent}
3247
+ eventGap={eventGap}
3248
+ />
3249
+ ) : null}
3250
+ </View>
3251
+ </Animated.View>
3252
+ </Animated.ScrollView>
3253
+ </GestureDetector>
3254
+ </View>
3242
3255
  </View>
3243
- </View>
3244
- </EdgePagingContext.Provider>
3256
+ </EdgePagingContext.Provider>
3257
+ </CalendarLabelsContext.Provider>
3245
3258
  </SlotStylesProvider>
3246
3259
  );
3247
3260
  }
@@ -3272,6 +3285,7 @@ type DayHeaderRowProps = {
3272
3285
  mode: CalendarMode;
3273
3286
  dayWidth: number;
3274
3287
  weekdayFormat?: WeekdayFormat;
3288
+ todayLabel: string;
3275
3289
  locale?: Locale;
3276
3290
  activeDate?: Date;
3277
3291
  onPressDateHeader?: (date: Date) => void;
@@ -3284,6 +3298,7 @@ const DayHeaderRow = ({
3284
3298
  mode,
3285
3299
  dayWidth,
3286
3300
  weekdayFormat,
3301
+ todayLabel,
3287
3302
  locale,
3288
3303
  activeDate,
3289
3304
  onPressDateHeader,
@@ -3298,6 +3313,7 @@ const DayHeaderRow = ({
3298
3313
  mode={mode}
3299
3314
  width={dayWidth}
3300
3315
  weekdayFormat={weekdayFormat}
3316
+ todayLabel={todayLabel}
3301
3317
  locale={locale}
3302
3318
  activeDate={activeDate}
3303
3319
  onPressDateHeader={onPressDateHeader}
@@ -3312,6 +3328,7 @@ type DayHeaderProps = {
3312
3328
  mode: CalendarMode;
3313
3329
  width: number;
3314
3330
  weekdayFormat?: WeekdayFormat;
3331
+ todayLabel: string;
3315
3332
  locale?: Locale;
3316
3333
  activeDate?: Date;
3317
3334
  onPressDateHeader?: (date: Date) => void;
@@ -3321,6 +3338,7 @@ const DayHeader = ({
3321
3338
  day,
3322
3339
  width,
3323
3340
  weekdayFormat = "short",
3341
+ todayLabel,
3324
3342
  locale,
3325
3343
  activeDate,
3326
3344
  onPressDateHeader,
@@ -3334,7 +3352,7 @@ const DayHeader = ({
3334
3352
  // One accessible name for the whole header (the weekday + number below are
3335
3353
  // decorative). `accessible` groups the children so a screen reader announces
3336
3354
  // this once, not label-by-label.
3337
- const accessibilityLabel = `${format(day, "EEEE d MMMM", { locale })}${isToday ? ", today" : ""}`;
3355
+ const accessibilityLabel = `${format(day, "EEEE d MMMM", { locale })}${isToday ? `, ${todayLabel}` : ""}`;
3338
3356
  const headerSlot = slot("columnHeader", {
3339
3357
  base: [styles.dayHeader, { width }],
3340
3358
  themed: theme.containers.columnHeader,
@@ -33,6 +33,11 @@ import {
33
33
  rangeBandKind,
34
34
  weekdayFormatToken,
35
35
  } from "@super-calendar/core";
36
+ import {
37
+ type CalendarLabels,
38
+ dayAccessibilityLabel,
39
+ resolveCalendarLabels,
40
+ } from "@super-calendar/core";
36
41
 
37
42
  const isWeb = Platform.OS === "web";
38
43
  // Hold before a year-grid drag takes over, so a tap still opens the day.
@@ -67,6 +72,8 @@ export type YearViewProps<T = unknown> = SlotStyleProps<YearViewSlot> & {
67
72
  /** Weekdays (0=Sunday…6=Saturday) hidden from the grid, e.g. `[0, 6]` for weekends off. */
68
73
  hiddenDays?: number[];
69
74
  locale?: Locale;
75
+ /** Translations for the screen-reader words; omitted keys use English. */
76
+ labels?: Partial<CalendarLabels>;
70
77
  /** Highlight this date instead of the real "today". */
71
78
  activeDate?: Date;
72
79
  /** A selected span: endpoints get a filled badge, the days between get the range band. */
@@ -118,6 +125,7 @@ function YearViewInner<T>({
118
125
  weekStartsOn,
119
126
  hiddenDays,
120
127
  locale,
128
+ labels: labelsProp,
121
129
  activeDate,
122
130
  selectedRange,
123
131
  selectedDates,
@@ -134,6 +142,7 @@ function YearViewInner<T>({
134
142
  styles: styleOverrides,
135
143
  }: YearViewProps<T>): ReactElement {
136
144
  const theme = useCalendarTheme();
145
+ const labels = useMemo(() => resolveCalendarLabels(labelsProp), [labelsProp]);
137
146
  const slot = createSlots<YearViewSlot>({ classNames, styles: styleOverrides });
138
147
 
139
148
  const [columns, setColumns] = useState(FALLBACK_COLUMNS);
@@ -340,11 +349,14 @@ function YearViewInner<T>({
340
349
  sweep != null &&
341
350
  dayTime >= Math.min(sweep.anchor, sweep.hover) &&
342
351
  dayTime <= Math.max(sweep.anchor, sweep.hover);
343
- const label = `${format(day, "EEEE, d LLLL yyyy", { locale })}${
344
- isToday ? ", today" : ""
345
- }${state.isSelected ? ", selected" : ""}${
346
- state.isDisabled ? ", unavailable" : ""
347
- }${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
+ });
348
360
  // Today wins over a selection, matching the month grid.
349
361
  const badge = dayBadgeKind(state, isHighlighted);
350
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
+ }