@@ -8,6 +8,14 @@ import type { CalendarDayMetadata } from "@/hooks/useCalendar";
8
8
import { useOptimizedDayMetadata } from "@/hooks/useOptimizedDayMetadata" ;
9
9
import { useTheme } from "@/hooks/useTheme" ;
10
10
11
+ // react-native-web/overrides.ts
12
+ declare module "react-native" {
13
+ interface PressableStateCallbackType {
14
+ hovered ?: boolean ;
15
+ focused ?: boolean ;
16
+ }
17
+ }
18
+
11
19
const styles = StyleSheet . create ( {
12
20
baseContainer : {
13
21
padding : 6 ,
@@ -33,6 +41,8 @@ type CalendarItemDayTheme = Record<
33
41
isStartOfRange : boolean ;
34
42
isEndOfRange : boolean ;
35
43
isPressed : boolean ;
44
+ isHovered ?: boolean ;
45
+ isFocused ?: boolean ;
36
46
} ) => DayTheme
37
47
> ;
38
48
@@ -43,28 +53,29 @@ const buildBaseStyles = (theme: BaseTheme): CalendarItemDayTheme => {
43
53
} ;
44
54
45
55
return {
46
- active : ( { isPressed, isStartOfRange, isEndOfRange } ) => {
47
- const baseStyles : DayTheme & { container : ViewStyle } = isPressed
48
- ? {
49
- container : {
50
- ...styles . baseContainer ,
51
- backgroundColor : theme . colors . background . tertiary ,
52
- } ,
53
- content : {
54
- ...baseContent ,
55
- color : theme . colors . content . primary ,
56
- } ,
57
- }
58
- : {
59
- container : {
60
- ...styles . baseContainer ,
61
- backgroundColor : theme . colors . background . inverse . primary ,
62
- } ,
63
- content : {
64
- ...baseContent ,
65
- color : theme . colors . content . inverse . primary ,
66
- } ,
67
- } ;
56
+ active : ( { isPressed, isHovered, isStartOfRange, isEndOfRange } ) => {
57
+ const baseStyles : DayTheme & { container : ViewStyle } =
58
+ isPressed || isHovered
59
+ ? {
60
+ container : {
61
+ ...styles . baseContainer ,
62
+ backgroundColor : theme . colors . background . tertiary ,
63
+ } ,
64
+ content : {
65
+ ...baseContent ,
66
+ color : theme . colors . content . primary ,
67
+ } ,
68
+ }
69
+ : {
70
+ container : {
71
+ ...styles . baseContainer ,
72
+ backgroundColor : theme . colors . background . inverse . primary ,
73
+ } ,
74
+ content : {
75
+ ...baseContent ,
76
+ color : theme . colors . content . inverse . primary ,
77
+ } ,
78
+ } ;
68
79
69
80
baseStyles . container . borderRadius = 0 ;
70
81
if ( isStartOfRange ) {
@@ -87,8 +98,8 @@ const buildBaseStyles = (theme: BaseTheme): CalendarItemDayTheme => {
87
98
color : theme . colors . content . disabled ,
88
99
} ,
89
100
} ) ,
90
- idle : ( { isPressed } ) => {
91
- return isPressed
101
+ idle : ( { isPressed, isHovered } ) => {
102
+ return isPressed || isHovered
92
103
? {
93
104
container : {
94
105
...styles . baseContainer ,
@@ -104,8 +115,8 @@ const buildBaseStyles = (theme: BaseTheme): CalendarItemDayTheme => {
104
115
content : baseContent ,
105
116
} ;
106
117
} ,
107
- today : ( { isPressed } ) => {
108
- return isPressed
118
+ today : ( { isPressed, isHovered } ) => {
119
+ return isPressed || isHovered
109
120
? {
110
121
container : {
111
122
...styles . baseContainer ,
@@ -136,6 +147,8 @@ export interface CalendarItemDayProps {
136
147
(
137
148
params : CalendarDayMetadata & {
138
149
isPressed : boolean ;
150
+ isHovered ?: boolean ;
151
+ isFocused ?: boolean ;
139
152
}
140
153
) => Partial < DayTheme >
141
154
>
@@ -175,9 +188,15 @@ export const CalendarItemDay = ({
175
188
< Pressable
176
189
disabled = { metadata . state === "disabled" }
177
190
onPress = { handlePress }
178
- style = { ( { pressed : isPressed } ) => {
191
+ style = { ( {
192
+ pressed : isPressed ,
193
+ hovered : isHovered ,
194
+ focused : isFocused ,
195
+ } ) => {
179
196
const params = {
180
197
isPressed,
198
+ isHovered,
199
+ isFocused,
181
200
isEndOfRange : metadata . isEndOfRange ?? false ,
182
201
isStartOfRange : metadata . isStartOfRange ?? false ,
183
202
} ;
@@ -190,9 +209,11 @@ export const CalendarItemDay = ({
190
209
} ;
191
210
} }
192
211
>
193
- { ( { pressed : isPressed } ) => {
212
+ { ( { pressed : isPressed , hovered : isHovered , focused : isFocused } ) => {
194
213
const params = {
195
214
isPressed,
215
+ isHovered,
216
+ isFocused,
196
217
isEndOfRange : metadata . isEndOfRange ?? false ,
197
218
isStartOfRange : metadata . isStartOfRange ?? false ,
198
219
} ;
@@ -203,8 +224,14 @@ export const CalendarItemDay = ({
203
224
style = { {
204
225
...content ,
205
226
...( textProps ?. style ?? ( { } as object ) ) ,
206
- ...theme ?. base ?.( { ...metadata , isPressed } ) . content ,
207
- ...theme ?. [ metadata . state ] ?.( { ...metadata , isPressed } ) . content ,
227
+ ...theme ?. base ?.( { ...metadata , isPressed, isHovered, isFocused } )
228
+ . content ,
229
+ ...theme ?. [ metadata . state ] ?.( {
230
+ ...metadata ,
231
+ isPressed,
232
+ isHovered,
233
+ isFocused,
234
+ } ) . content ,
208
235
} }
209
236
>
210
237
{ children }
0 commit comments