@@ -13,7 +13,7 @@ export type CollapsibleGroupProps = {
13
13
onChange ?: ( expanded : boolean ) => void ;
14
14
} & BaseComponentProps ;
15
15
16
- export const CollapsibleGroup : React . FC < CollapsibleGroupProps > = ( props ) => {
16
+ function CollapsibleGroupComponent ( props : CollapsibleGroupProps , ref : React . ForwardedRef < HTMLDivElement > ) {
17
17
const [ expanded , setExpanded ] = React . useState ( props . expanded ?? false ) ;
18
18
const [ prevExpanded , setPrevExpanded ] = React . useState < boolean | undefined > ( props . expanded ) ;
19
19
@@ -28,30 +28,28 @@ export const CollapsibleGroup: React.FC<CollapsibleGroupProps> = (props) => {
28
28
} ;
29
29
30
30
return (
31
- < BaseComponent disabled = { props . disabled } >
32
- < div className = "shadow" >
33
- < div
34
- className = { resolveClassNames (
35
- "flex flex-row justify-between items-center bg-slate-100 cursor-pointer p-2 select-none gap-2" ,
36
- { "border-b" : expanded }
37
- ) }
38
- onClick = { handleClick }
39
- title = { expanded ? "Collapse" : "Expand" }
40
- >
41
- { props . icon && React . cloneElement ( props . icon , { className : "w-4 h-4" } ) }
42
- < h3 className = "text-sm font-semibold flex-grow leading-none" > { props . title } </ h3 >
43
- { expanded ? < ExpandLess fontSize = "small" /> : < ExpandMore fontSize = "small" /> }
44
- </ div >
45
- < div
46
- className = { resolveClassNames ( "p-2" , {
47
- hidden : ! expanded ,
48
- } ) }
49
- >
50
- { props . children }
51
- </ div >
31
+ < BaseComponent ref = { ref } disabled = { props . disabled } className = "shadow" >
32
+ < div
33
+ className = { resolveClassNames (
34
+ "flex flex-row justify-between items-center bg-slate-100 cursor-pointer p-2 select-none gap-2" ,
35
+ { "border-b" : expanded }
36
+ ) }
37
+ onClick = { handleClick }
38
+ title = { expanded ? "Collapse" : "Expand" }
39
+ >
40
+ { props . icon && React . cloneElement ( props . icon , { className : "w-4 h-4" } ) }
41
+ < h3 className = "text-sm font-semibold flex-grow leading-none" > { props . title } </ h3 >
42
+ { expanded ? < ExpandLess fontSize = "small" /> : < ExpandMore fontSize = "small" /> }
43
+ </ div >
44
+ < div
45
+ className = { resolveClassNames ( "p-2" , {
46
+ hidden : ! expanded ,
47
+ } ) }
48
+ >
49
+ { props . children }
52
50
</ div >
53
51
</ BaseComponent >
54
52
) ;
55
- } ;
53
+ }
56
54
57
- CollapsibleGroup . displayName = "CollapsibleGroup" ;
55
+ export const CollapsibleGroup = React . forwardRef ( CollapsibleGroupComponent ) ;
0 commit comments