10
10
* governing permissions and limitations under the License.
11
11
*/
12
12
import { AriaDialogProps , useDialog , useId , useOverlayTrigger } from 'react-aria' ;
13
- import { ContextValue , DEFAULT_SLOT , Provider , SlotProps , StyleProps , useContextProps } from './utils' ;
13
+ import { ContextValue , DEFAULT_SLOT , Provider , SlotProps , StyleProps , useContextProps , useRenderProps } from './utils' ;
14
14
import { filterDOMProps } from '@react-aria/utils' ;
15
15
import { forwardRefType } from '@react-types/shared' ;
16
16
import { HeadingContext } from './RSPContexts' ;
@@ -76,13 +76,6 @@ function Dialog(props: DialogProps, ref: ForwardedRef<HTMLElement>) {
76
76
} , ref ) ;
77
77
let state = useContext ( OverlayTriggerStateContext ) ;
78
78
79
- let children = props . children ;
80
- if ( typeof children === 'function' ) {
81
- children = children ( {
82
- close : state ?. close || ( ( ) => { } )
83
- } ) ;
84
- }
85
-
86
79
if ( ! dialogProps [ 'aria-label' ] && ! dialogProps [ 'aria-labelledby' ] ) {
87
80
// If aria-labelledby exists on props, we know it came from context.
88
81
// Use that as a fallback in case there is no title slot.
@@ -93,14 +86,23 @@ function Dialog(props: DialogProps, ref: ForwardedRef<HTMLElement>) {
93
86
}
94
87
}
95
88
89
+ let renderProps = useRenderProps ( {
90
+ defaultClassName : 'react-aria-Dialog' ,
91
+ className : props . className ,
92
+ style : props . style ,
93
+ children : props . children ,
94
+ values : {
95
+ close : state ?. close || ( ( ) => { } )
96
+ }
97
+ } ) ;
98
+
96
99
return (
97
100
< section
98
101
{ ...filterDOMProps ( props ) }
99
102
{ ...dialogProps }
103
+ { ...renderProps }
100
104
ref = { ref }
101
- slot = { props . slot || undefined }
102
- style = { props . style }
103
- className = { props . className ?? 'react-aria-Dialog' } >
105
+ slot = { props . slot || undefined } >
104
106
< Provider
105
107
values = { [
106
108
[ HeadingContext , {
@@ -110,7 +112,7 @@ function Dialog(props: DialogProps, ref: ForwardedRef<HTMLElement>) {
110
112
}
111
113
} ]
112
114
] } >
113
- { children }
115
+ { renderProps . children }
114
116
</ Provider >
115
117
</ section >
116
118
) ;
0 commit comments