@@ -74,7 +74,7 @@ export interface CalendarCellAria {
74
74
*/
75
75
export function useCalendarCell ( props : AriaCalendarCellProps , state : CalendarState | RangeCalendarState , ref : RefObject < HTMLElement | null > ) : CalendarCellAria {
76
76
let { date, isDisabled} = props ;
77
- let { errorMessageId, selectedDateDescription} = hookData . get ( state ) ;
77
+ let { errorMessageId, selectedDateDescription} = hookData . get ( state ) ! ;
78
78
let stringFormatter = useLocalizedStringFormatter ( intlMessages , '@react-aria/calendar' ) ;
79
79
let dateFormatter = useDateFormatter ( {
80
80
weekday : 'long' ,
@@ -89,7 +89,7 @@ export function useCalendarCell(props: AriaCalendarCellProps, state: CalendarSta
89
89
isDisabled = isDisabled || state . isCellDisabled ( date ) ;
90
90
let isUnavailable = state . isCellUnavailable ( date ) ;
91
91
let isSelectable = ! isDisabled && ! isUnavailable ;
92
- let isInvalid = state . isValueInvalid && (
92
+ let isInvalid = state . isValueInvalid && Boolean (
93
93
'highlightedRange' in state
94
94
? ! state . anchorDate && state . highlightedRange && date . compare ( state . highlightedRange . start ) >= 0 && date . compare ( state . highlightedRange . end ) <= 0
95
95
: state . value && isSameDay ( state . value , date )
@@ -159,7 +159,7 @@ export function useCalendarCell(props: AriaCalendarCellProps, state: CalendarSta
159
159
160
160
let isAnchorPressed = useRef ( false ) ;
161
161
let isRangeBoundaryPressed = useRef ( false ) ;
162
- let touchDragTimerRef = useRef ( null ) ;
162
+ let touchDragTimerRef = useRef < ReturnType < typeof setTimeout > | undefined > ( undefined ) ;
163
163
let { pressProps, isPressed} = usePress ( {
164
164
// When dragging to select a range, we don't want dragging over the original anchor
165
165
// again to trigger onPressStart. Cancel presses immediately when the pointer exits.
@@ -195,7 +195,7 @@ export function useCalendarCell(props: AriaCalendarCellProps, state: CalendarSta
195
195
196
196
let startDragging = ( ) => {
197
197
state . setDragging ( true ) ;
198
- touchDragTimerRef . current = null ;
198
+ touchDragTimerRef . current = undefined ;
199
199
200
200
state . selectDate ( date ) ;
201
201
state . setFocusedDate ( date ) ;
@@ -215,7 +215,7 @@ export function useCalendarCell(props: AriaCalendarCellProps, state: CalendarSta
215
215
isRangeBoundaryPressed . current = false ;
216
216
isAnchorPressed . current = false ;
217
217
clearTimeout ( touchDragTimerRef . current ) ;
218
- touchDragTimerRef . current = null ;
218
+ touchDragTimerRef . current = undefined ;
219
219
} ,
220
220
onPress ( ) {
221
221
// For non-range selection, always select on press up.
@@ -269,7 +269,7 @@ export function useCalendarCell(props: AriaCalendarCellProps, state: CalendarSta
269
269
}
270
270
} ) ;
271
271
272
- let tabIndex = null ;
272
+ let tabIndex : number | undefined = undefined ;
273
273
if ( ! isDisabled ) {
274
274
tabIndex = isSameDay ( date , state . focusedDate ) ? 0 : - 1 ;
275
275
}
@@ -298,14 +298,14 @@ export function useCalendarCell(props: AriaCalendarCellProps, state: CalendarSta
298
298
calendar : date . calendar . identifier
299
299
} ) ;
300
300
301
- let formattedDate = useMemo ( ( ) => cellDateFormatter . formatToParts ( nativeDate ) . find ( part => part . type === 'day' ) . value , [ cellDateFormatter , nativeDate ] ) ;
301
+ let formattedDate = useMemo ( ( ) => cellDateFormatter . formatToParts ( nativeDate ) . find ( part => part . type === 'day' ) ! . value , [ cellDateFormatter , nativeDate ] ) ;
302
302
303
303
return {
304
304
cellProps : {
305
305
role : 'gridcell' ,
306
- 'aria-disabled' : ! isSelectable || null ,
307
- 'aria-selected' : isSelected || null ,
308
- 'aria-invalid' : isInvalid || null
306
+ 'aria-disabled' : ! isSelectable || undefined ,
307
+ 'aria-selected' : isSelected || undefined ,
308
+ 'aria-invalid' : isInvalid || undefined
309
309
} ,
310
310
buttonProps : mergeProps ( pressProps , {
311
311
onFocus ( ) {
@@ -315,11 +315,11 @@ export function useCalendarCell(props: AriaCalendarCellProps, state: CalendarSta
315
315
} ,
316
316
tabIndex,
317
317
role : 'button' ,
318
- 'aria-disabled' : ! isSelectable || null ,
318
+ 'aria-disabled' : ! isSelectable || undefined ,
319
319
'aria-label' : label ,
320
- 'aria-invalid' : isInvalid || null ,
320
+ 'aria-invalid' : isInvalid || undefined ,
321
321
'aria-describedby' : [
322
- isInvalid ? errorMessageId : null ,
322
+ isInvalid ? errorMessageId : undefined ,
323
323
descriptionProps [ 'aria-describedby' ]
324
324
] . filter ( Boolean ) . join ( ' ' ) || undefined ,
325
325
onPointerEnter ( e ) {
0 commit comments