pcm-shared-components 2.0.36 → 2.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { ThemeProvider } from '@mui/system';
|
|
4
4
|
import { createTheme, useTheme } from '@mui/material/styles';
|
|
@@ -21,13 +21,24 @@ export const SimpleAccordion = props => {
|
|
|
21
21
|
const {
|
|
22
22
|
title,
|
|
23
23
|
body,
|
|
24
|
+
expanded,
|
|
24
25
|
theme
|
|
25
26
|
} = props;
|
|
27
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
26
28
|
const compTheme = theme ? theme : useTheme();
|
|
27
29
|
const defaultTheme = createTheme(compTheme);
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
setIsExpanded(expanded);
|
|
32
|
+
}, [expanded]);
|
|
33
|
+
const handleExpandedChange = () => {
|
|
34
|
+
setIsExpanded(!isExpanded);
|
|
35
|
+
};
|
|
28
36
|
return /*#__PURE__*/React.createElement(ThemeProvider, {
|
|
29
37
|
theme: defaultTheme
|
|
30
|
-
}, /*#__PURE__*/React.createElement(Accordion,
|
|
38
|
+
}, /*#__PURE__*/React.createElement(Accordion, {
|
|
39
|
+
expanded: isExpanded,
|
|
40
|
+
onChange: handleExpandedChange
|
|
41
|
+
}, /*#__PURE__*/React.createElement(AccordionSummary, {
|
|
31
42
|
expandIcon: /*#__PURE__*/React.createElement(ArrowDropDownIcon, {
|
|
32
43
|
fontSize: "large"
|
|
33
44
|
})
|
|
@@ -37,6 +48,7 @@ export default SimpleAccordion;
|
|
|
37
48
|
SimpleAccordion.defaultProps = {
|
|
38
49
|
title: '',
|
|
39
50
|
body: '',
|
|
51
|
+
expanded: false,
|
|
40
52
|
theme: undefined
|
|
41
53
|
};
|
|
42
54
|
SimpleAccordion.propTypes = {
|
|
@@ -44,6 +56,8 @@ SimpleAccordion.propTypes = {
|
|
|
44
56
|
title: PropTypes.object,
|
|
45
57
|
/** What appears in the unfolded area area. Can be a text or a React element*/
|
|
46
58
|
body: PropTypes.object,
|
|
59
|
+
/** The default position of the accordion*/
|
|
60
|
+
expanded: PropTypes.bool,
|
|
47
61
|
/** Theme object to use on this component, if none provided then the MUI5 theme provider theme is used*/
|
|
48
62
|
theme: PropTypes.object
|
|
49
63
|
};
|