1 | "use strict";
|
2 |
|
3 | var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
4 |
|
5 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
6 |
|
7 | Object.defineProperty(exports, "__esModule", {
|
8 | value: true
|
9 | });
|
10 | exports.default = exports.styles = void 0;
|
11 |
|
12 | var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
13 |
|
14 | var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
15 |
|
16 | var React = _interopRequireWildcard(require("react"));
|
17 |
|
18 | var _propTypes = _interopRequireDefault(require("prop-types"));
|
19 |
|
20 | var _clsx = _interopRequireDefault(require("clsx"));
|
21 |
|
22 | var _ButtonBase = _interopRequireDefault(require("../ButtonBase"));
|
23 |
|
24 | var _IconButton = _interopRequireDefault(require("../IconButton"));
|
25 |
|
26 | var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
|
27 |
|
28 | var _AccordionContext = _interopRequireDefault(require("../Accordion/AccordionContext"));
|
29 |
|
30 |
|
31 | var styles = function styles(theme) {
|
32 | var transition = {
|
33 | duration: theme.transitions.duration.shortest
|
34 | };
|
35 | return {
|
36 |
|
37 | root: {
|
38 | display: 'flex',
|
39 | minHeight: 8 * 6,
|
40 | transition: theme.transitions.create(['min-height', 'background-color'], transition),
|
41 | padding: theme.spacing(0, 2),
|
42 | '&:hover:not($disabled)': {
|
43 | cursor: 'pointer'
|
44 | },
|
45 | '&$expanded': {
|
46 | minHeight: 64
|
47 | },
|
48 | '&$focused': {
|
49 | backgroundColor: theme.palette.action.focus
|
50 | },
|
51 | '&$disabled': {
|
52 | opacity: theme.palette.action.disabledOpacity
|
53 | }
|
54 | },
|
55 |
|
56 |
|
57 | expanded: {},
|
58 |
|
59 |
|
60 | focused: {},
|
61 |
|
62 |
|
63 | disabled: {},
|
64 |
|
65 |
|
66 | content: {
|
67 | display: 'flex',
|
68 | flexGrow: 1,
|
69 | transition: theme.transitions.create(['margin'], transition),
|
70 | margin: '12px 0',
|
71 | '&$expanded': {
|
72 | margin: '20px 0'
|
73 | }
|
74 | },
|
75 |
|
76 |
|
77 | expandIcon: {
|
78 | transform: 'rotate(0deg)',
|
79 | transition: theme.transitions.create('transform', transition),
|
80 | '&:hover': {
|
81 |
|
82 |
|
83 |
|
84 | backgroundColor: 'transparent'
|
85 | },
|
86 | '&$expanded': {
|
87 | transform: 'rotate(180deg)'
|
88 | }
|
89 | }
|
90 | };
|
91 | };
|
92 |
|
93 | exports.styles = styles;
|
94 | var AccordionSummary = React.forwardRef(function AccordionSummary(props, ref) {
|
95 | var children = props.children,
|
96 | classes = props.classes,
|
97 | className = props.className,
|
98 | expandIcon = props.expandIcon,
|
99 | IconButtonProps = props.IconButtonProps,
|
100 | onBlur = props.onBlur,
|
101 | onClick = props.onClick,
|
102 | onFocusVisible = props.onFocusVisible,
|
103 | other = (0, _objectWithoutProperties2.default)(props, ["children", "classes", "className", "expandIcon", "IconButtonProps", "onBlur", "onClick", "onFocusVisible"]);
|
104 |
|
105 | var _React$useState = React.useState(false),
|
106 | focusedState = _React$useState[0],
|
107 | setFocusedState = _React$useState[1];
|
108 |
|
109 | var handleFocusVisible = function handleFocusVisible(event) {
|
110 | setFocusedState(true);
|
111 |
|
112 | if (onFocusVisible) {
|
113 | onFocusVisible(event);
|
114 | }
|
115 | };
|
116 |
|
117 | var handleBlur = function handleBlur(event) {
|
118 | setFocusedState(false);
|
119 |
|
120 | if (onBlur) {
|
121 | onBlur(event);
|
122 | }
|
123 | };
|
124 |
|
125 | var _React$useContext = React.useContext(_AccordionContext.default),
|
126 | _React$useContext$dis = _React$useContext.disabled,
|
127 | disabled = _React$useContext$dis === void 0 ? false : _React$useContext$dis,
|
128 | expanded = _React$useContext.expanded,
|
129 | toggle = _React$useContext.toggle;
|
130 |
|
131 | var handleChange = function handleChange(event) {
|
132 | if (toggle) {
|
133 | toggle(event);
|
134 | }
|
135 |
|
136 | if (onClick) {
|
137 | onClick(event);
|
138 | }
|
139 | };
|
140 |
|
141 | return React.createElement(_ButtonBase.default, (0, _extends2.default)({
|
142 | focusRipple: false,
|
143 | disableRipple: true,
|
144 | disabled: disabled,
|
145 | component: "div",
|
146 | "aria-expanded": expanded,
|
147 | className: (0, _clsx.default)(classes.root, className, disabled && classes.disabled, expanded && classes.expanded, focusedState && classes.focused),
|
148 | onFocusVisible: handleFocusVisible,
|
149 | onBlur: handleBlur,
|
150 | onClick: handleChange,
|
151 | ref: ref
|
152 | }, other), React.createElement("div", {
|
153 | className: (0, _clsx.default)(classes.content, expanded && classes.expanded)
|
154 | }, children), expandIcon && React.createElement(_IconButton.default, (0, _extends2.default)({
|
155 | className: (0, _clsx.default)(classes.expandIcon, expanded && classes.expanded),
|
156 | edge: "end",
|
157 | component: "div",
|
158 | tabIndex: null,
|
159 | role: null,
|
160 | "aria-hidden": true
|
161 | }, IconButtonProps), expandIcon));
|
162 | });
|
163 | process.env.NODE_ENV !== "production" ? AccordionSummary.propTypes = {
|
164 |
|
165 |
|
166 |
|
167 |
|
168 |
|
169 | |
170 |
|
171 |
|
172 | children: _propTypes.default.node,
|
173 |
|
174 | |
175 |
|
176 |
|
177 |
|
178 | classes: _propTypes.default.object,
|
179 |
|
180 | |
181 |
|
182 |
|
183 | className: _propTypes.default.string,
|
184 |
|
185 | |
186 |
|
187 |
|
188 | expandIcon: _propTypes.default.node,
|
189 |
|
190 | |
191 |
|
192 |
|
193 | IconButtonProps: _propTypes.default.object,
|
194 |
|
195 | |
196 |
|
197 |
|
198 | onBlur: _propTypes.default.func,
|
199 |
|
200 | |
201 |
|
202 |
|
203 | onClick: _propTypes.default.func,
|
204 |
|
205 | |
206 |
|
207 |
|
208 | onFocusVisible: _propTypes.default.func
|
209 | } : void 0;
|
210 |
|
211 | var _default = (0, _withStyles.default)(styles, {
|
212 | name: 'MuiAccordionSummary'
|
213 | })(AccordionSummary);
|
214 |
|
215 | exports.default = _default; |
\ | No newline at end of file |