11
11
*/
12
12
13
13
import { AriaLabelingProps , DOMProps , DOMRef , StyleProps } from '@react-types/shared' ;
14
- import { Button , UNSTABLE_DisclosureGroup as DisclosureGroup , DisclosureGroupProps , DisclosurePanelProps , DisclosureProps , Heading , UNSTABLE_Disclosure as RACDisclosure , UNSTABLE_DisclosurePanel as RACDisclosurePanel } from 'react-aria-components' ;
14
+ import { Button , DisclosureGroup , DisclosureGroupProps , DisclosurePanelProps , DisclosureProps , Heading , Disclosure as RACDisclosure , DisclosurePanel as RACDisclosurePanel } from 'react-aria-components' ;
15
15
import ChevronLeftMedium from '@spectrum-icons/ui/ChevronLeftMedium' ;
16
16
import ChevronRightMedium from '@spectrum-icons/ui/ChevronRightMedium' ;
17
17
import { classNames , useDOMRef , useStyleProps } from '@react-spectrum/utils' ;
@@ -46,7 +46,7 @@ function Accordion(props: SpectrumAccordionProps, ref: DOMRef<HTMLDivElement>) {
46
46
) ;
47
47
}
48
48
49
- export interface SpectrumDisclosureProps extends Omit < DisclosureProps , 'className' | 'style' | 'children' > , AriaLabelingProps {
49
+ export interface SpectrumDisclosureProps extends Omit < DisclosureProps , 'className' | 'style' | 'children' > , AriaLabelingProps , StyleProps {
50
50
/** Whether the Disclosure should be displayed with a quiet style. */
51
51
isQuiet ?: boolean ,
52
52
/** The contents of the disclosure. The first child should be the header, and the second child should be the panel. */
@@ -55,37 +55,45 @@ export interface SpectrumDisclosureProps extends Omit<DisclosureProps, 'classNam
55
55
56
56
function Disclosure ( props : SpectrumDisclosureProps , ref : DOMRef < HTMLDivElement > ) {
57
57
props = useProviderProps ( props ) ;
58
+ let { styleProps} = useStyleProps ( props ) ;
58
59
let domRef = useDOMRef ( ref ) ;
59
60
let accordionContext = React . useContext ( InternalAccordionContext ) ! ;
60
61
return (
61
62
< RACDisclosure
62
63
{ ...props }
64
+ { ...styleProps }
63
65
ref = { domRef }
64
66
className = { ( { isExpanded, isDisabled} ) => classNames ( styles , 'spectrum-Accordion-item' , {
65
67
'spectrum-Accordion-item--quiet' : accordionContext ?. isQuiet ?? props . isQuiet ,
66
68
'is-expanded' : isExpanded ,
67
- 'is-disabled' : isDisabled
68
- } ) } >
69
+ 'is-disabled' : isDisabled ,
70
+ 'in-accordion' : accordionContext != null
71
+ } , styleProps . className ) } >
69
72
{ props . children }
70
73
</ RACDisclosure >
71
74
) ;
72
75
}
73
76
74
- export interface SpectrumDisclosurePanelProps extends Omit < DisclosurePanelProps , 'className' | 'style' | 'children' > , DOMProps , AriaLabelingProps {
77
+ export interface SpectrumDisclosurePanelProps extends Omit < DisclosurePanelProps , 'className' | 'style' | 'children' > , DOMProps , AriaLabelingProps , StyleProps {
75
78
/** The contents of the accordion panel. */
76
79
children : React . ReactNode
77
80
}
78
81
79
82
function DisclosurePanel ( props : SpectrumDisclosurePanelProps , ref : DOMRef < HTMLDivElement > ) {
83
+ let { styleProps} = useStyleProps ( props ) ;
80
84
let domRef = useDOMRef ( ref ) ;
81
85
return (
82
- < RACDisclosurePanel ref = { domRef } className = { classNames ( styles , 'spectrum-Accordion-itemContent' ) } { ...props } >
86
+ < RACDisclosurePanel
87
+ ref = { domRef }
88
+ { ...styleProps as Omit < React . HTMLAttributes < HTMLElement > , 'role' > }
89
+ className = { classNames ( styles , 'spectrum-Accordion-itemContent' , styleProps . className ) }
90
+ { ...props } >
83
91
{ props . children }
84
92
</ RACDisclosurePanel >
85
93
) ;
86
94
}
87
95
88
- export interface SpectrumDisclosureHeaderProps extends DOMProps , AriaLabelingProps {
96
+ export interface SpectrumDisclosureHeaderProps extends DOMProps , AriaLabelingProps , StyleProps {
89
97
/**
90
98
* The heading level of the disclosure header.
91
99
* @default 3
@@ -96,15 +104,17 @@ export interface SpectrumDisclosureHeaderProps extends DOMProps, AriaLabelingPro
96
104
}
97
105
98
106
function DisclosureHeader ( props : SpectrumDisclosureHeaderProps , ref : DOMRef < HTMLHeadingElement > ) {
107
+ let { styleProps} = useStyleProps ( props ) ;
99
108
let { level = 3 } = props ;
100
109
let { direction} = useLocale ( ) ;
101
110
let domRef = useDOMRef ( ref ) ;
102
111
return (
103
- < Heading ref = { domRef } level = { level } className = { classNames ( styles , 'spectrum-Accordion-itemHeading' ) } >
112
+ < Heading ref = { domRef } level = { level } { ... styleProps } className = { classNames ( styles , 'spectrum-Accordion-itemHeading' , styleProps . className ) } >
104
113
< Button
105
114
slot = "trigger"
106
- className = { ( { isHovered, isFocusVisible} ) => classNames ( styles , 'spectrum-Accordion-itemHeader' , {
115
+ className = { ( { isHovered, isFocusVisible, isPressed } ) => classNames ( styles , 'spectrum-Accordion-itemHeader' , {
107
116
'is-hovered' : isHovered ,
117
+ 'is-pressed' : isPressed ,
108
118
'focus-ring' : isFocusVisible
109
119
} ) } >
110
120
{ direction === 'ltr' ? (
0 commit comments