@@ -26,7 +26,7 @@ import {
26
26
import { ButtonContext } from './Button' ;
27
27
import { CalendarDate , createCalendar , DateDuration , endOfMonth , getWeeksInMonth , isSameDay , isSameMonth } from '@internationalized/date' ;
28
28
import { CalendarState , RangeCalendarState , useCalendarState , useRangeCalendarState } from 'react-stately' ;
29
- import { ContextValue , DOMProps , Provider , RenderProps , SlotProps , StyleProps , useContextProps , useRenderProps } from './utils' ;
29
+ import { ContextValue , DOMProps , Provider , RenderProps , SlotProps , StyleProps , useContextProps , useRenderProps , useSlottedContext } from './utils' ;
30
30
import { DOMAttributes , FocusableElement , forwardRefType , HoverEvents } from '@react-types/shared' ;
31
31
import { filterDOMProps } from '@react-aria/utils' ;
32
32
import { HeadingContext } from './RSPContexts' ;
@@ -73,12 +73,10 @@ export interface RangeCalendarProps<T extends DateValue> extends Omit<AriaRangeC
73
73
visibleDuration ?: DateDuration
74
74
}
75
75
76
- export const CalendarContext = createContext < ContextValue < CalendarProps < any > , HTMLDivElement > > ( { } ) ;
77
- export const RangeCalendarContext = createContext < ContextValue < RangeCalendarProps < any > , HTMLDivElement > > ( { } ) ;
76
+ export const CalendarContext = createContext < ContextValue < CalendarProps < any > , HTMLDivElement > > ( null ) ;
77
+ export const RangeCalendarContext = createContext < ContextValue < RangeCalendarProps < any > , HTMLDivElement > > ( null ) ;
78
78
export const CalendarStateContext = createContext < CalendarState | null > ( null ) ;
79
79
export const RangeCalendarStateContext = createContext < RangeCalendarState | null > ( null ) ;
80
- const InternalCalendarContext = createContext < CalendarProps < any > | null > ( null ) ;
81
- const InternalRangeCalendarContext = createContext < RangeCalendarProps < any > | null > ( null ) ;
82
80
83
81
/**
84
82
* A calendar displays one or more date grids and allows users to select a single date.
@@ -122,7 +120,7 @@ export const Calendar = /*#__PURE__*/ (forwardRef as forwardRefType)(function Ca
122
120
} ] ,
123
121
[ HeadingContext , { 'aria-hidden' : true , level : 2 , children : title } ] ,
124
122
[ CalendarStateContext , state ] ,
125
- [ InternalCalendarContext , props ] ,
123
+ [ CalendarContext , props as CalendarProps < any > ] ,
126
124
[ TextContext , {
127
125
slots : {
128
126
errorMessage : errorMessageProps
@@ -199,7 +197,7 @@ export const RangeCalendar = /*#__PURE__*/ (forwardRef as forwardRefType)(functi
199
197
} ] ,
200
198
[ HeadingContext , { 'aria-hidden' : true , level : 2 , children : title } ] ,
201
199
[ RangeCalendarStateContext , state ] ,
202
- [ InternalRangeCalendarContext , props ] ,
200
+ [ RangeCalendarContext , props as RangeCalendarProps < any > ] ,
203
201
[ TextContext , {
204
202
slots : {
205
203
errorMessage : errorMessageProps
@@ -343,8 +341,8 @@ const InternalCalendarGridContext = createContext<InternalCalendarGridContextVal
343
341
export const CalendarGrid = /*#__PURE__*/ ( forwardRef as forwardRefType ) ( function CalendarGrid ( props : CalendarGridProps , ref : ForwardedRef < HTMLTableElement > ) {
344
342
let calendarState = useContext ( CalendarStateContext ) ;
345
343
let rangeCalendarState = useContext ( RangeCalendarStateContext ) ;
346
- let calenderProps = useContext ( InternalCalendarContext ) ! ;
347
- let rangeCalenderProps = useContext ( InternalRangeCalendarContext ) ! ;
344
+ let calenderProps = useSlottedContext ( CalendarContext ) ! ;
345
+ let rangeCalenderProps = useSlottedContext ( RangeCalendarContext ) ! ;
348
346
let state = calendarState ?? rangeCalendarState ! ;
349
347
let startDate = state . visibleRange . start ;
350
348
if ( props . offset ) {
0 commit comments