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 _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
13 |
|
14 | var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
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 _styles = require("@material-ui/core/styles");
|
23 |
|
24 | var _Fab = _interopRequireDefault(require("@material-ui/core/Fab"));
|
25 |
|
26 | var _Tooltip = _interopRequireDefault(require("@material-ui/core/Tooltip"));
|
27 |
|
28 | var _utils = require("@material-ui/core/utils");
|
29 |
|
30 |
|
31 | var styles = function styles(theme) {
|
32 | return {
|
33 |
|
34 | fab: {
|
35 | margin: 8,
|
36 | color: theme.palette.text.secondary,
|
37 | backgroundColor: theme.palette.background.paper,
|
38 | '&:hover': {
|
39 | backgroundColor: (0, _styles.emphasize)(theme.palette.background.paper, 0.15)
|
40 | },
|
41 | transition: "".concat(theme.transitions.create('transform', {
|
42 | duration: theme.transitions.duration.shorter
|
43 | }), ", opacity 0.8s"),
|
44 | opacity: 1
|
45 | },
|
46 |
|
47 |
|
48 | fabClosed: {
|
49 | opacity: 0,
|
50 | transform: 'scale(0)'
|
51 | },
|
52 |
|
53 |
|
54 | staticTooltip: {
|
55 | position: 'relative',
|
56 | display: 'flex',
|
57 | '& $staticTooltipLabel': {
|
58 | transition: theme.transitions.create(['transform', 'opacity'], {
|
59 | duration: theme.transitions.duration.shorter
|
60 | }),
|
61 | opacity: 1
|
62 | }
|
63 | },
|
64 |
|
65 |
|
66 | staticTooltipClosed: {
|
67 | '& $staticTooltipLabel': {
|
68 | opacity: 0,
|
69 | transform: 'scale(0.5)'
|
70 | }
|
71 | },
|
72 |
|
73 |
|
74 | staticTooltipLabel: (0, _extends2.default)({
|
75 | position: 'absolute'
|
76 | }, theme.typography.body1, {
|
77 | backgroundColor: theme.palette.background.paper,
|
78 | borderRadius: theme.shape.borderRadius,
|
79 | boxShadow: theme.shadows[1],
|
80 | color: theme.palette.text.secondary,
|
81 | padding: '4px 16px',
|
82 | wordBreak: 'keep-all'
|
83 | }),
|
84 |
|
85 |
|
86 | tooltipPlacementLeft: {
|
87 | alignItems: 'center',
|
88 | '& $staticTooltipLabel': {
|
89 | transformOrigin: '100% 50%',
|
90 | right: '100%',
|
91 | marginRight: 8
|
92 | }
|
93 | },
|
94 |
|
95 |
|
96 | tooltipPlacementRight: {
|
97 | alignItems: 'center',
|
98 | '& $staticTooltipLabel': {
|
99 | transformOrigin: '0% 50%',
|
100 | left: '100%',
|
101 | marginLeft: 8
|
102 | }
|
103 | }
|
104 | };
|
105 | };
|
106 |
|
107 | exports.styles = styles;
|
108 | var SpeedDialAction = React.forwardRef(function SpeedDialAction(props, ref) {
|
109 | var classes = props.classes,
|
110 | className = props.className,
|
111 | _props$delay = props.delay,
|
112 | delay = _props$delay === void 0 ? 0 : _props$delay,
|
113 | _props$FabProps = props.FabProps,
|
114 | FabProps = _props$FabProps === void 0 ? {} : _props$FabProps,
|
115 | icon = props.icon,
|
116 | id = props.id,
|
117 | open = props.open,
|
118 | TooltipClasses = props.TooltipClasses,
|
119 | _props$tooltipOpen = props.tooltipOpen,
|
120 | tooltipOpenProp = _props$tooltipOpen === void 0 ? false : _props$tooltipOpen,
|
121 | _props$tooltipPlaceme = props.tooltipPlacement,
|
122 | tooltipPlacement = _props$tooltipPlaceme === void 0 ? 'left' : _props$tooltipPlaceme,
|
123 | tooltipTitle = props.tooltipTitle,
|
124 | other = (0, _objectWithoutProperties2.default)(props, ["classes", "className", "delay", "FabProps", "icon", "id", "open", "TooltipClasses", "tooltipOpen", "tooltipPlacement", "tooltipTitle"]);
|
125 |
|
126 | var _React$useState = React.useState(tooltipOpenProp),
|
127 | tooltipOpen = _React$useState[0],
|
128 | setTooltipOpen = _React$useState[1];
|
129 |
|
130 | var handleTooltipClose = function handleTooltipClose() {
|
131 | setTooltipOpen(false);
|
132 | };
|
133 |
|
134 | var handleTooltipOpen = function handleTooltipOpen() {
|
135 | setTooltipOpen(true);
|
136 | };
|
137 |
|
138 | var transitionStyle = {
|
139 | transitionDelay: "".concat(delay, "ms")
|
140 | };
|
141 | var fab = React.createElement(_Fab.default, (0, _extends2.default)({
|
142 | size: "small",
|
143 | className: (0, _clsx.default)(classes.fab, className, !open && classes.fabClosed),
|
144 | tabIndex: -1,
|
145 | role: "menuitem",
|
146 | "aria-describedby": "".concat(id, "-label")
|
147 | }, FabProps, {
|
148 | style: (0, _extends2.default)({}, transitionStyle, FabProps.style)
|
149 | }), icon);
|
150 |
|
151 | if (tooltipOpenProp) {
|
152 | return React.createElement("span", (0, _extends2.default)({
|
153 | id: id,
|
154 | ref: ref,
|
155 | className: (0, _clsx.default)(classes.staticTooltip, classes["tooltipPlacement".concat((0, _utils.capitalize)(tooltipPlacement))], !open && classes.staticTooltipClosed)
|
156 | }, other), React.createElement("span", {
|
157 | style: transitionStyle,
|
158 | id: "".concat(id, "-label"),
|
159 | className: classes.staticTooltipLabel
|
160 | }, tooltipTitle), fab);
|
161 | }
|
162 |
|
163 | return React.createElement(_Tooltip.default, (0, _extends2.default)({
|
164 | id: id,
|
165 | ref: ref,
|
166 | title: tooltipTitle,
|
167 | placement: tooltipPlacement,
|
168 | onClose: handleTooltipClose,
|
169 | onOpen: handleTooltipOpen,
|
170 | open: open && tooltipOpen,
|
171 | classes: TooltipClasses
|
172 | }, other), fab);
|
173 | });
|
174 | process.env.NODE_ENV !== "production" ? SpeedDialAction.propTypes = {
|
175 |
|
176 |
|
177 |
|
178 |
|
179 |
|
180 | |
181 |
|
182 |
|
183 |
|
184 | classes: _propTypes.default.object,
|
185 |
|
186 | |
187 |
|
188 |
|
189 | className: _propTypes.default.string,
|
190 |
|
191 | |
192 |
|
193 |
|
194 | delay: _propTypes.default.number,
|
195 |
|
196 | |
197 |
|
198 |
|
199 | FabProps: _propTypes.default.object,
|
200 |
|
201 | |
202 |
|
203 |
|
204 | icon: _propTypes.default.node,
|
205 |
|
206 | |
207 |
|
208 |
|
209 |
|
210 | id: _propTypes.default.string,
|
211 |
|
212 | |
213 |
|
214 |
|
215 | open: _propTypes.default.bool,
|
216 |
|
217 | |
218 |
|
219 |
|
220 | TooltipClasses: _propTypes.default.object,
|
221 |
|
222 | |
223 |
|
224 |
|
225 | tooltipOpen: _propTypes.default.bool,
|
226 |
|
227 | |
228 |
|
229 |
|
230 | tooltipPlacement: _propTypes.default.oneOf(['bottom-end', 'bottom-start', 'bottom', 'left-end', 'left-start', 'left', 'right-end', 'right-start', 'right', 'top-end', 'top-start', 'top']),
|
231 |
|
232 | |
233 |
|
234 |
|
235 | tooltipTitle: _propTypes.default.node
|
236 | } : void 0;
|
237 |
|
238 | var _default = (0, _styles.withStyles)(styles, {
|
239 | name: 'MuiSpeedDialAction'
|
240 | })(SpeedDialAction);
|
241 |
|
242 | exports.default = _default; |
\ | No newline at end of file |