1
1
import * as React from 'react' ;
2
- import DisplayName from '../helpers/DisplayName' ;
3
2
import { DivAttributes } from '../helpers/types' ;
4
3
import { Provider } from './AccordionContext' ;
5
4
import { UUID } from './ItemContext' ;
@@ -8,45 +7,35 @@ type AccordionProps = Pick<
8
7
DivAttributes ,
9
8
Exclude < keyof DivAttributes , 'onChange' >
10
9
> & {
10
+ className ?: string ;
11
11
preExpanded ?: UUID [ ] ;
12
12
allowMultipleExpanded ?: boolean ;
13
13
allowZeroExpanded ?: boolean ;
14
14
onChange ?( args : UUID [ ] ) : void ;
15
15
} ;
16
16
17
- export default class Accordion extends React . Component < AccordionProps > {
18
- static defaultProps : AccordionProps = {
19
- allowMultipleExpanded : undefined ,
20
- allowZeroExpanded : undefined ,
21
- onChange : undefined ,
22
- className : 'accordion' ,
23
- children : undefined ,
24
- } ;
25
-
26
- static displayName : DisplayName . Accordion = DisplayName . Accordion ;
27
-
28
- renderAccordion = ( ) : JSX . Element => {
29
- const {
30
- preExpanded,
31
- allowMultipleExpanded,
32
- allowZeroExpanded,
33
- onChange,
34
- ...rest
35
- } = this . props ;
36
-
37
- return < div data-accordion-component = "Accordion" { ...rest } /> ;
38
- } ;
17
+ const Accordion = ( {
18
+ className = 'accordion' ,
19
+ allowMultipleExpanded,
20
+ allowZeroExpanded,
21
+ onChange,
22
+ preExpanded,
23
+ ...rest
24
+ } : AccordionProps ) => {
25
+ return (
26
+ < Provider
27
+ preExpanded = { preExpanded }
28
+ allowMultipleExpanded = { allowMultipleExpanded }
29
+ allowZeroExpanded = { allowZeroExpanded }
30
+ onChange = { onChange }
31
+ >
32
+ < div
33
+ data-accordion-component = "Accordion"
34
+ className = { className }
35
+ { ...rest }
36
+ />
37
+ </ Provider >
38
+ ) ;
39
+ } ;
39
40
40
- render ( ) : JSX . Element {
41
- return (
42
- < Provider
43
- preExpanded = { this . props . preExpanded }
44
- allowMultipleExpanded = { this . props . allowMultipleExpanded }
45
- allowZeroExpanded = { this . props . allowZeroExpanded }
46
- onChange = { this . props . onChange }
47
- >
48
- { this . renderAccordion ( ) }
49
- </ Provider >
50
- ) ;
51
- }
52
- }
41
+ export default Accordion ;
0 commit comments