@super-calendar/native 2.8.1 → 2.8.2

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.
@@ -1,6 +1,6 @@
1
1
  import { Locale } from "date-fns";
2
2
  import { ComponentType, ReactElement, ReactNode } from "react";
3
- import { AccessibilityActionEvent, AccessibilityActionInfo, StyleProp, TextStyle, ViewStyle } from "react-native";
3
+ import { AccessibilityActionEvent, AccessibilityActionInfo, ImageStyle, StyleProp, TextStyle, ViewStyle } from "react-native";
4
4
  import { SharedValue } from "react-native-reanimated";
5
5
  import { BusinessHours, BusinessHoursBand as BusinessHoursBand$1, CalendarColors, CalendarEvent, CalendarEvent as CalendarEvent$1, CalendarMode, CalendarMode as CalendarMode$1, DateRange, EventAccessibilityLabelContext, EventAccessibilityLabeler, EventAccessibilityLabeler as EventAccessibilityLabeler$1, EventKeyExtractor, ICalendarEvent, RecurrenceFrequency, RecurrenceRule, TimeGridMode, WeekStartsOn, WeekdayFormat, WeekdayFormat as WeekdayFormat$1 } from "@super-calendar/core";
6
6
  //#region src/theme.d.ts
@@ -173,6 +173,15 @@ type RenderEventArgs<T = unknown> = {
173
173
  type RenderEvent<T = unknown> = ComponentType<RenderEventArgs<T>>;
174
174
  //#endregion
175
175
  //#region src/utils/slots.d.ts
176
+ /**
177
+ * The style shapes a slot can resolve to. A slot carries the style type of the
178
+ * element it is spread on, because React Native's style types stop being
179
+ * mutually assignable as soon as a consumer's types diverge them: Expo's
180
+ * react-native-web types widen `cursor` on `TextStyle` and `userSelect` on
181
+ * `ViewStyle`, so a `View` slot typed as `TextStyle` fails to compile in any
182
+ * Expo app.
183
+ */
184
+ type SlotStyle = ViewStyle | TextStyle | ImageStyle;
176
185
  /**
177
186
  * Per-slot styling overrides. Give a slot a Tailwind class (uniwind/NativeWind)
178
187
  * and/or a style override; missing slots keep the built-in look.
@@ -186,18 +195,18 @@ interface SlotStyleProps<Slot extends string> {
186
195
  */
187
196
  classNames?: Partial<Record<Slot, string>>;
188
197
  /** Style overrides per slot, merged last (win over defaults and classes). */
189
- styles?: Partial<Record<Slot, StyleProp<TextStyle>>>;
198
+ styles?: Partial<Record<Slot, StyleProp<SlotStyle>>>;
190
199
  }
191
200
  /** A slot's built-in styling, split so classes can replace the look but not the layout. */
192
- interface SlotDefault {
201
+ interface SlotDefault<Style extends SlotStyle = ViewStyle> {
193
202
  /** Structural styles kept even when a class is supplied. */
194
- base?: StyleProp<TextStyle>;
203
+ base?: StyleProp<Style>;
195
204
  /** Themed styles (colour, type, spacing) dropped when a class is supplied. */
196
- themed?: StyleProp<TextStyle>;
205
+ themed?: StyleProp<Style>;
197
206
  }
198
207
  /** The props a resolved slot spreads onto an element. */
199
- interface ResolvedSlot {
200
- style: StyleProp<TextStyle>;
208
+ interface ResolvedSlot<Style extends SlotStyle = ViewStyle> {
209
+ style: StyleProp<Style>;
201
210
  className?: string;
202
211
  }
203
212
  //#endregion
@@ -2,7 +2,7 @@ import { Locale } from "date-fns";
2
2
  import { ComponentType, ReactElement, ReactNode } from "react";
3
3
  import { SharedValue } from "react-native-reanimated";
4
4
  import { BusinessHours, BusinessHoursBand as BusinessHoursBand$1, CalendarColors, CalendarEvent, CalendarEvent as CalendarEvent$1, CalendarMode, CalendarMode as CalendarMode$1, DateRange, EventAccessibilityLabelContext, EventAccessibilityLabeler, EventAccessibilityLabeler as EventAccessibilityLabeler$1, EventKeyExtractor, ICalendarEvent, RecurrenceFrequency, RecurrenceRule, TimeGridMode, WeekStartsOn, WeekdayFormat, WeekdayFormat as WeekdayFormat$1 } from "@super-calendar/core";
5
- import { AccessibilityActionEvent, AccessibilityActionInfo, StyleProp, TextStyle, ViewStyle } from "react-native";
5
+ import { AccessibilityActionEvent, AccessibilityActionInfo, ImageStyle, StyleProp, TextStyle, ViewStyle } from "react-native";
6
6
  //#region src/theme.d.ts
7
7
  /**
8
8
  * The full set of colours, text styles and metrics the calendar paints with.
@@ -173,6 +173,15 @@ type RenderEventArgs<T = unknown> = {
173
173
  type RenderEvent<T = unknown> = ComponentType<RenderEventArgs<T>>;
174
174
  //#endregion
175
175
  //#region src/utils/slots.d.ts
176
+ /**
177
+ * The style shapes a slot can resolve to. A slot carries the style type of the
178
+ * element it is spread on, because React Native's style types stop being
179
+ * mutually assignable as soon as a consumer's types diverge them: Expo's
180
+ * react-native-web types widen `cursor` on `TextStyle` and `userSelect` on
181
+ * `ViewStyle`, so a `View` slot typed as `TextStyle` fails to compile in any
182
+ * Expo app.
183
+ */
184
+ type SlotStyle = ViewStyle | TextStyle | ImageStyle;
176
185
  /**
177
186
  * Per-slot styling overrides. Give a slot a Tailwind class (uniwind/NativeWind)
178
187
  * and/or a style override; missing slots keep the built-in look.
@@ -186,18 +195,18 @@ interface SlotStyleProps<Slot extends string> {
186
195
  */
187
196
  classNames?: Partial<Record<Slot, string>>;
188
197
  /** Style overrides per slot, merged last (win over defaults and classes). */
189
- styles?: Partial<Record<Slot, StyleProp<TextStyle>>>;
198
+ styles?: Partial<Record<Slot, StyleProp<SlotStyle>>>;
190
199
  }
191
200
  /** A slot's built-in styling, split so classes can replace the look but not the layout. */
192
- interface SlotDefault {
201
+ interface SlotDefault<Style extends SlotStyle = ViewStyle> {
193
202
  /** Structural styles kept even when a class is supplied. */
194
- base?: StyleProp<TextStyle>;
203
+ base?: StyleProp<Style>;
195
204
  /** Themed styles (colour, type, spacing) dropped when a class is supplied. */
196
- themed?: StyleProp<TextStyle>;
205
+ themed?: StyleProp<Style>;
197
206
  }
198
207
  /** The props a resolved slot spreads onto an element. */
199
- interface ResolvedSlot {
200
- style: StyleProp<TextStyle>;
208
+ interface ResolvedSlot<Style extends SlotStyle = ViewStyle> {
209
+ style: StyleProp<Style>;
201
210
  className?: string;
202
211
  }
203
212
  //#endregion
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as PartialCalendarTheme, C as RenderEvent, D as WeekdayFormat, E as WeekStartsOn, M as defaultTheme, N as mergeTheme, O as CalendarTheme, P as useCalendarTheme, S as RecurrenceRule, T as TimeGridMode, _ as EventAccessibilityLabelContext, a as MonthPager, b as ICalendarEvent, c as MonthViewProps, d as SlotDefault, f as SlotStyleProps, g as CalendarMode, h as CalendarEvent, i as MonthListSlot, j as darkTheme, k as CalendarThemeProvider, l as MonthViewSlot, m as BusinessHoursBand, n as MonthList, o as MonthPagerProps, p as BusinessHours, r as MonthListProps, s as MonthView, t as DefaultMonthEvent, u as ResolvedSlot, v as EventAccessibilityLabeler, w as RenderEventArgs, x as RecurrenceFrequency, y as EventKeyExtractor } from "./DefaultMonthEvent-VgJarTO_.mjs";
1
+ import { A as PartialCalendarTheme, C as RenderEvent, D as WeekdayFormat, E as WeekStartsOn, M as defaultTheme, N as mergeTheme, O as CalendarTheme, P as useCalendarTheme, S as RecurrenceRule, T as TimeGridMode, _ as EventAccessibilityLabelContext, a as MonthPager, b as ICalendarEvent, c as MonthViewProps, d as SlotDefault, f as SlotStyleProps, g as CalendarMode, h as CalendarEvent, i as MonthListSlot, j as darkTheme, k as CalendarThemeProvider, l as MonthViewSlot, m as BusinessHoursBand, n as MonthList, o as MonthPagerProps, p as BusinessHours, r as MonthListProps, s as MonthView, t as DefaultMonthEvent, u as ResolvedSlot, v as EventAccessibilityLabeler, w as RenderEventArgs, x as RecurrenceFrequency, y as EventKeyExtractor } from "./DefaultMonthEvent-Cewbec1K.mjs";
2
2
  import { Locale } from "date-fns";
3
3
  import { ComponentType, ReactElement, ReactNode } from "react";
4
4
  import { SharedValue, useSharedValue } from "react-native-reanimated";
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as PartialCalendarTheme, C as RenderEvent, D as WeekdayFormat, E as WeekStartsOn, M as defaultTheme, N as mergeTheme, O as CalendarTheme, P as useCalendarTheme, S as RecurrenceRule, T as TimeGridMode, _ as EventAccessibilityLabelContext, a as MonthPager, b as ICalendarEvent, c as MonthViewProps, d as SlotDefault, f as SlotStyleProps, g as CalendarMode, h as CalendarEvent, i as MonthListSlot, j as darkTheme, k as CalendarThemeProvider, l as MonthViewSlot, m as BusinessHoursBand, n as MonthList, o as MonthPagerProps, p as BusinessHours, r as MonthListProps, s as MonthView, t as DefaultMonthEvent, u as ResolvedSlot, v as EventAccessibilityLabeler, w as RenderEventArgs, x as RecurrenceFrequency, y as EventKeyExtractor } from "./DefaultMonthEvent-CjwX3Nt1.js";
1
+ import { A as PartialCalendarTheme, C as RenderEvent, D as WeekdayFormat, E as WeekStartsOn, M as defaultTheme, N as mergeTheme, O as CalendarTheme, P as useCalendarTheme, S as RecurrenceRule, T as TimeGridMode, _ as EventAccessibilityLabelContext, a as MonthPager, b as ICalendarEvent, c as MonthViewProps, d as SlotDefault, f as SlotStyleProps, g as CalendarMode, h as CalendarEvent, i as MonthListSlot, j as darkTheme, k as CalendarThemeProvider, l as MonthViewSlot, m as BusinessHoursBand, n as MonthList, o as MonthPagerProps, p as BusinessHours, r as MonthListProps, s as MonthView, t as DefaultMonthEvent, u as ResolvedSlot, v as EventAccessibilityLabeler, w as RenderEventArgs, x as RecurrenceFrequency, y as EventKeyExtractor } from "./DefaultMonthEvent-C_T4thzu.js";
2
2
  import { Locale } from "date-fns";
3
3
  import { ComponentType, ReactElement, ReactNode } from "react";
4
4
  import { StyleProp, ViewStyle } from "react-native";
package/dist/picker.d.mts CHANGED
@@ -1,3 +1,3 @@
1
- import { A as PartialCalendarTheme, C as RenderEvent, E as WeekStartsOn, M as defaultTheme, N as mergeTheme, O as CalendarTheme, P as useCalendarTheme, a as MonthPager, b as ICalendarEvent, c as MonthViewProps, g as CalendarMode, h as CalendarEvent, j as darkTheme, k as CalendarThemeProvider, n as MonthList, o as MonthPagerProps, r as MonthListProps, s as MonthView, t as DefaultMonthEvent, w as RenderEventArgs, y as EventKeyExtractor } from "./DefaultMonthEvent-VgJarTO_.mjs";
1
+ import { A as PartialCalendarTheme, C as RenderEvent, E as WeekStartsOn, M as defaultTheme, N as mergeTheme, O as CalendarTheme, P as useCalendarTheme, a as MonthPager, b as ICalendarEvent, c as MonthViewProps, g as CalendarMode, h as CalendarEvent, j as darkTheme, k as CalendarThemeProvider, n as MonthList, o as MonthPagerProps, r as MonthListProps, s as MonthView, t as DefaultMonthEvent, w as RenderEventArgs, y as EventKeyExtractor } from "./DefaultMonthEvent-Cewbec1K.mjs";
2
2
  import { DateRange, DateSelectionConstraints, DaySelectionState, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, UseDateRangeOptions, UseMonthGridOptions, buildMonthGrid, buildMonthWeeks, daySelectionState, getIsToday, getWeekDays, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, minutesIntoDay, nextDateRange, useDateRange, useMonthGrid } from "@super-calendar/core";
3
3
  export { type CalendarEvent, type CalendarMode, type CalendarTheme, CalendarThemeProvider, type DateRange, type DateSelectionConstraints, type DaySelectionState, DefaultMonthEvent, type EventKeyExtractor, type ICalendarEvent, type MonthGrid, type MonthGridDay, type MonthGridWeek, type MonthGridWeekday, MonthList, type MonthListProps, MonthPager, type MonthPagerProps, MonthView, type MonthViewProps, type PartialCalendarTheme, type RenderEvent, type RenderEventArgs, type UseDateRangeOptions, type UseMonthGridOptions, type WeekStartsOn, buildMonthGrid, buildMonthWeeks, darkTheme, daySelectionState, defaultTheme, getIsToday, getWeekDays, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, mergeTheme, minutesIntoDay, nextDateRange, useCalendarTheme, useDateRange, useMonthGrid };
package/dist/picker.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { A as PartialCalendarTheme, C as RenderEvent, E as WeekStartsOn, M as defaultTheme, N as mergeTheme, O as CalendarTheme, P as useCalendarTheme, a as MonthPager, b as ICalendarEvent, c as MonthViewProps, g as CalendarMode, h as CalendarEvent, j as darkTheme, k as CalendarThemeProvider, n as MonthList, o as MonthPagerProps, r as MonthListProps, s as MonthView, t as DefaultMonthEvent, w as RenderEventArgs, y as EventKeyExtractor } from "./DefaultMonthEvent-CjwX3Nt1.js";
1
+ import { A as PartialCalendarTheme, C as RenderEvent, E as WeekStartsOn, M as defaultTheme, N as mergeTheme, O as CalendarTheme, P as useCalendarTheme, a as MonthPager, b as ICalendarEvent, c as MonthViewProps, g as CalendarMode, h as CalendarEvent, j as darkTheme, k as CalendarThemeProvider, n as MonthList, o as MonthPagerProps, r as MonthListProps, s as MonthView, t as DefaultMonthEvent, w as RenderEventArgs, y as EventKeyExtractor } from "./DefaultMonthEvent-C_T4thzu.js";
2
2
  import { DateRange, DateSelectionConstraints, DaySelectionState, MonthGrid, MonthGridDay, MonthGridWeek, MonthGridWeekday, UseDateRangeOptions, UseMonthGridOptions, buildMonthGrid, buildMonthWeeks, daySelectionState, getIsToday, getWeekDays, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, minutesIntoDay, nextDateRange, useDateRange, useMonthGrid } from "@super-calendar/core";
3
3
  export { type CalendarEvent, type CalendarMode, type CalendarTheme, CalendarThemeProvider, type DateRange, type DateSelectionConstraints, type DaySelectionState, DefaultMonthEvent, type EventKeyExtractor, type ICalendarEvent, type MonthGrid, type MonthGridDay, type MonthGridWeek, type MonthGridWeekday, MonthList, type MonthListProps, MonthPager, type MonthPagerProps, MonthView, type MonthViewProps, type PartialCalendarTheme, type RenderEvent, type RenderEventArgs, type UseDateRangeOptions, type UseMonthGridOptions, type WeekStartsOn, buildMonthGrid, buildMonthWeeks, darkTheme, daySelectionState, defaultTheme, getIsToday, getWeekDays, isDateSelectable, isRangeEndpoint, isSameCalendarDay, isWeekend, isWithinDateRange, mergeTheme, minutesIntoDay, nextDateRange, useCalendarTheme, useDateRange, useMonthGrid };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@super-calendar/native",
3
- "version": "2.8.1",
3
+ "version": "2.8.2",
4
4
  "description": "Gesture-driven, virtualized month / week / day calendar and date picker for React Native (and web via react-native-web).",
5
5
  "keywords": [
6
6
  "agenda",
@@ -64,7 +64,7 @@
64
64
  "access": "public"
65
65
  },
66
66
  "dependencies": {
67
- "@super-calendar/core": "2.8.1"
67
+ "@super-calendar/core": "2.8.2"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "@legendapp/list": ">=3",
@@ -1,7 +1,7 @@
1
1
  import { LegendList, type LegendListRenderItemProps } from "@legendapp/list/react-native";
2
2
  import { format, isSameDay, type Locale, startOfDay } from "date-fns";
3
3
  import { type ComponentType, type ReactElement, useCallback, useMemo } from "react";
4
- import { StyleSheet, Text, View } from "react-native";
4
+ import { StyleSheet, Text, type TextStyle, View } from "react-native";
5
5
  import { useCalendarTheme } from "../theme";
6
6
  import type { CalendarEvent, EventKeyExtractor, RenderEvent } from "../types";
7
7
  import { createSlots, type SlotStyleProps } from "../utils/slots";
@@ -83,7 +83,7 @@ export function Agenda<T>({
83
83
  const isHighlighted = activeDate ? isSameDay(item.date, activeDate) : getIsToday(item.date);
84
84
  return (
85
85
  <Text
86
- {...slot("dayHeader", {
86
+ {...slot<TextStyle>("dayHeader", {
87
87
  base: styles.header,
88
88
  themed: [
89
89
  styles.headerText,
@@ -124,7 +124,7 @@ export function Agenda<T>({
124
124
  if (rows.length === 0) {
125
125
  return (
126
126
  <Text
127
- {...slot("empty", {
127
+ {...slot<TextStyle>("empty", {
128
128
  base: styles.empty,
129
129
  themed: [styles.emptyText, { color: theme.colors.textMuted }],
130
130
  })}
@@ -1,5 +1,5 @@
1
1
  import { addDays, startOfDay } from "date-fns";
2
- import { StyleSheet, Text, View } from "react-native";
2
+ import { StyleSheet, Text, type TextStyle, View } from "react-native";
3
3
  import { useCalendarTheme } from "../theme";
4
4
  import type { CalendarEvent, CalendarMode, EventKeyExtractor, RenderEvent } from "../types";
5
5
  import { useSlots } from "../utils/slots";
@@ -64,7 +64,7 @@ export function AllDayLane<T>({
64
64
  and right-aligned against the timed columns. Centered vertically so it
65
65
  lines up with the chips whether the lane holds one event or several. */}
66
66
  <Text
67
- {...slot("allDayLabel", {
67
+ {...slot<TextStyle>("allDayLabel", {
68
68
  base: styles.label,
69
69
  themed: { color: theme.colors.textMuted },
70
70
  })}
@@ -21,6 +21,7 @@ import {
21
21
  StyleSheet,
22
22
  type StyleProp,
23
23
  Text,
24
+ type TextStyle,
24
25
  View,
25
26
  type ViewStyle,
26
27
  } from "react-native";
@@ -440,7 +441,7 @@ function MonthListInner<T>({
440
441
  renderMonthHeader(item)
441
442
  ) : (
442
443
  <Text
443
- {...slot("title", {
444
+ {...slot<TextStyle>("title", {
444
445
  base: styles.monthTitle,
445
446
  themed: [styles.monthTitleText, { color: theme.colors.text }],
446
447
  })}
@@ -560,7 +561,7 @@ function MonthListInner<T>({
560
561
  {weekDays.map((day) => (
561
562
  <Text
562
563
  key={day.toISOString()}
563
- {...slot("weekday", {
564
+ {...slot<TextStyle>("weekday", {
564
565
  base: styles.weekdayLabel,
565
566
  themed: [styles.weekdayLabelText, { color: theme.colors.textMuted }],
566
567
  })}
@@ -11,6 +11,7 @@ import {
11
11
  StyleSheet,
12
12
  type StyleProp,
13
13
  Text,
14
+ type TextStyle,
14
15
  useWindowDimensions,
15
16
  View,
16
17
  type ViewStyle,
@@ -304,7 +305,7 @@ function MonthPagerInner<T>({
304
305
  {/* The active month's title, above the (shared) weekday header — mirrors the
305
306
  dom MonthView's title. The grids below omit their own title/weekdays. */}
306
307
  <Text
307
- {...slot("title", {
308
+ {...slot<TextStyle>("title", {
308
309
  base: styles.monthTitle,
309
310
  themed: [theme.text.monthTitle, { color: theme.colors.text }],
310
311
  })}
@@ -411,7 +412,7 @@ const MonthWeekdayHeader = ({
411
412
  {weekDays.map((day) => (
412
413
  <Text
413
414
  key={day.toISOString()}
414
- {...slot("weekday", {
415
+ {...slot<TextStyle>("weekday", {
415
416
  base: styles.weekdayLabel,
416
417
  themed: [theme.text.weekday, { color: theme.colors.textMuted }],
417
418
  })}
@@ -10,6 +10,7 @@ import {
10
10
  StyleSheet,
11
11
  type StyleProp,
12
12
  Text,
13
+ type TextStyle,
13
14
  TouchableOpacity,
14
15
  View,
15
16
  type ViewStyle,
@@ -531,7 +532,9 @@ function MonthViewInner<T>({
531
532
  })}
532
533
  >
533
534
  <Text
534
- {...slot("dayBadgeText", { themed: [theme.text.dateCell, { color: dateColor }] })}
535
+ {...slot<TextStyle>("dayBadgeText", {
536
+ themed: [theme.text.dateCell, { color: dateColor }],
537
+ })}
535
538
  allowFontScaling={false}
536
539
  >
537
540
  {format(day, "d")}
@@ -549,7 +552,7 @@ function MonthViewInner<T>({
549
552
  ))}
550
553
  {hiddenCount > 0 ? (
551
554
  <Text
552
- {...slot("more", {
555
+ {...slot<TextStyle>("more", {
553
556
  base: styles.moreLabel,
554
557
  themed: [theme.text.more, { color: theme.colors.textMuted }],
555
558
  })}
@@ -578,7 +581,7 @@ function MonthViewInner<T>({
578
581
  <View style={styles.root}>
579
582
  {showTitle ? (
580
583
  <Text
581
- {...slot("title", {
584
+ {...slot<TextStyle>("title", {
582
585
  base: styles.title,
583
586
  themed: [theme.text.monthTitle, { color: theme.colors.text }],
584
587
  })}
@@ -597,7 +600,7 @@ function MonthViewInner<T>({
597
600
  {weekdayLabels.map((day) => (
598
601
  <Text
599
602
  key={day.toISOString()}
600
- {...slot("weekday", {
603
+ {...slot<TextStyle>("weekday", {
601
604
  base: styles.weekdayLabel,
602
605
  themed: [theme.text.weekday, { color: theme.colors.textMuted }],
603
606
  })}
@@ -34,6 +34,7 @@ import {
34
34
  StyleSheet,
35
35
  type StyleProp,
36
36
  Text,
37
+ type TextStyle,
37
38
  useWindowDimensions,
38
39
  View,
39
40
  type ViewStyle,
@@ -842,7 +843,7 @@ const HourRow = ({
842
843
  <View style={{ width: hourColumnWidth }}>{hourComponent(hour, ampm)}</View>
843
844
  ) : (
844
845
  <Text
845
- {...slot("hourLabel", {
846
+ {...slot<TextStyle>("hourLabel", {
846
847
  base: [styles.hourLabel, { width: hourColumnWidth }],
847
848
  themed: [theme.text.hourLabel, { color: theme.colors.textMuted }],
848
849
  })}
@@ -2557,7 +2558,7 @@ const DefaultHeader = ({
2557
2558
  <View style={[styles.weekNumberGutter, { width: hourColumnWidth }]}>
2558
2559
  {showWeekNumber && hourColumnWidth > 0 && days[0] ? (
2559
2560
  <Text
2560
- {...slot("weekNumber", {
2561
+ {...slot<TextStyle>("weekNumber", {
2561
2562
  themed: [theme.text.hourLabel, { color: theme.colors.textMuted }],
2562
2563
  })}
2563
2564
  allowFontScaling={false}
@@ -2623,7 +2624,7 @@ const DayHeader = ({
2623
2624
  const content = (
2624
2625
  <>
2625
2626
  <Text
2626
- {...slot("columnHeaderWeekday", {
2627
+ {...slot<TextStyle>("columnHeaderWeekday", {
2627
2628
  themed: [{ color: theme.colors.textMuted }, theme.text.columnHeaderWeekday],
2628
2629
  })}
2629
2630
  allowFontScaling={false}
@@ -2641,7 +2642,7 @@ const DayHeader = ({
2641
2642
  })}
2642
2643
  >
2643
2644
  <Text
2644
- {...slot("columnHeaderDateText", {
2645
+ {...slot<TextStyle>("columnHeaderDateText", {
2645
2646
  themed: [
2646
2647
  theme.text.dayNumber,
2647
2648
  // The state colour stays last so a themed dayNumber can't break the
@@ -6,6 +6,7 @@ import {
6
6
  ScrollView,
7
7
  StyleSheet,
8
8
  Text,
9
+ type TextStyle,
9
10
  View,
10
11
  } from "react-native";
11
12
  import { useCalendarTheme } from "../theme";
@@ -117,7 +118,7 @@ function YearViewInner<T>({
117
118
  const monthLabel = format(month, "MMMM yyyy", { locale });
118
119
  const titleText = (
119
120
  <Text
120
- {...slot("monthTitle", {
121
+ {...slot<TextStyle>("monthTitle", {
121
122
  base: styles.monthTitle,
122
123
  themed: [styles.monthTitleText, { color: theme.colors.todayBackground }],
123
124
  })}
@@ -155,7 +156,7 @@ function YearViewInner<T>({
155
156
  {weekdayLabels.map((label, i) => (
156
157
  <Text
157
158
  key={i}
158
- {...slot("weekday", {
159
+ {...slot<TextStyle>("weekday", {
159
160
  base: styles.weekday,
160
161
  themed: [styles.weekdayText, { color: theme.colors.textMuted }],
161
162
  })}
@@ -192,7 +193,7 @@ function YearViewInner<T>({
192
193
  const content = (
193
194
  <>
194
195
  <Text
195
- {...slot("dayText", {
196
+ {...slot<TextStyle>("dayText", {
196
197
  themed: [
197
198
  styles.dayText,
198
199
  {
@@ -15,7 +15,17 @@
15
15
  // prop React Native silently ignores, so the props are safe to pass everywhere.
16
16
 
17
17
  import { createContext, createElement, type ReactNode, useContext, useMemo } from "react";
18
- import type { StyleProp, TextStyle } from "react-native";
18
+ import type { ImageStyle, StyleProp, TextStyle, ViewStyle } from "react-native";
19
+
20
+ /**
21
+ * The style shapes a slot can resolve to. A slot carries the style type of the
22
+ * element it is spread on, because React Native's style types stop being
23
+ * mutually assignable as soon as a consumer's types diverge them: Expo's
24
+ * react-native-web types widen `cursor` on `TextStyle` and `userSelect` on
25
+ * `ViewStyle`, so a `View` slot typed as `TextStyle` fails to compile in any
26
+ * Expo app.
27
+ */
28
+ export type SlotStyle = ViewStyle | TextStyle | ImageStyle;
19
29
 
20
30
  /**
21
31
  * Per-slot styling overrides. Give a slot a Tailwind class (uniwind/NativeWind)
@@ -30,20 +40,20 @@ export interface SlotStyleProps<Slot extends string> {
30
40
  */
31
41
  classNames?: Partial<Record<Slot, string>>;
32
42
  /** Style overrides per slot, merged last (win over defaults and classes). */
33
- styles?: Partial<Record<Slot, StyleProp<TextStyle>>>;
43
+ styles?: Partial<Record<Slot, StyleProp<SlotStyle>>>;
34
44
  }
35
45
 
36
46
  /** A slot's built-in styling, split so classes can replace the look but not the layout. */
37
- export interface SlotDefault {
47
+ export interface SlotDefault<Style extends SlotStyle = ViewStyle> {
38
48
  /** Structural styles kept even when a class is supplied. */
39
- base?: StyleProp<TextStyle>;
49
+ base?: StyleProp<Style>;
40
50
  /** Themed styles (colour, type, spacing) dropped when a class is supplied. */
41
- themed?: StyleProp<TextStyle>;
51
+ themed?: StyleProp<Style>;
42
52
  }
43
53
 
44
54
  /** The props a resolved slot spreads onto an element. */
45
- export interface ResolvedSlot {
46
- style: StyleProp<TextStyle>;
55
+ export interface ResolvedSlot<Style extends SlotStyle = ViewStyle> {
56
+ style: StyleProp<Style>;
47
57
  className?: string;
48
58
  }
49
59
 
@@ -53,10 +63,24 @@ export interface ResolvedSlot {
53
63
  * consumer supplied one, a `className` for the Tailwind runtime to pick up.
54
64
  */
55
65
  export function createSlots<Slot extends string>({ classNames, styles }: SlotStyleProps<Slot>) {
56
- return (name: Slot, defaults?: SlotDefault): ResolvedSlot => {
66
+ // `NoInfer` keeps the element type a decision, not a guess: without it the
67
+ // literal type of a `StyleSheet.create` entry wins the inference and every
68
+ // themed style passed alongside it is then measured against that one entry.
69
+ // Slots default to a `View`; `slot<TextStyle>(...)` marks the text ones.
70
+ return <Style extends SlotStyle = ViewStyle>(
71
+ name: Slot,
72
+ defaults?: SlotDefault<NoInfer<Style>>,
73
+ ): ResolvedSlot<Style> => {
57
74
  const slotClass = classNames?.[name];
58
75
  return {
59
- style: [defaults?.base, slotClass ? undefined : defaults?.themed, styles?.[name]],
76
+ style: [
77
+ defaults?.base,
78
+ slotClass ? undefined : defaults?.themed,
79
+ // A consumer's override is declared for any element's style, so it is
80
+ // narrowed to this slot's element here. React Native flattens the array
81
+ // and drops properties the element does not support either way.
82
+ styles?.[name] as StyleProp<Style>,
83
+ ],
60
84
  ...(slotClass ? { className: slotClass } : null),
61
85
  };
62
86
  };