1 | import * as React from 'react';
|
2 | import PropTypes from 'prop-types';
|
3 | import clsx from 'clsx';
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | import { jsx as _jsx } from "react/jsx-runtime";
|
9 |
|
10 | function Ripple(props) {
|
11 | const {
|
12 | className,
|
13 | classes,
|
14 | pulsate = false,
|
15 | rippleX,
|
16 | rippleY,
|
17 | rippleSize,
|
18 | in: inProp,
|
19 | onExited,
|
20 | timeout
|
21 | } = props;
|
22 | const [leaving, setLeaving] = React.useState(false);
|
23 | const rippleClassName = clsx(className, classes.ripple, classes.rippleVisible, pulsate && classes.ripplePulsate);
|
24 | const rippleStyles = {
|
25 | width: rippleSize,
|
26 | height: rippleSize,
|
27 | top: -(rippleSize / 2) + rippleY,
|
28 | left: -(rippleSize / 2) + rippleX
|
29 | };
|
30 | const childClassName = clsx(classes.child, leaving && classes.childLeaving, pulsate && classes.childPulsate);
|
31 |
|
32 | if (!inProp && !leaving) {
|
33 | setLeaving(true);
|
34 | }
|
35 |
|
36 | React.useEffect(() => {
|
37 | if (!inProp && onExited != null) {
|
38 |
|
39 | const timeoutId = setTimeout(onExited, timeout);
|
40 | return () => {
|
41 | clearTimeout(timeoutId);
|
42 | };
|
43 | }
|
44 |
|
45 | return undefined;
|
46 | }, [onExited, inProp, timeout]);
|
47 | return _jsx("span", {
|
48 | className: rippleClassName,
|
49 | style: rippleStyles,
|
50 | children: _jsx("span", {
|
51 | className: childClassName
|
52 | })
|
53 | });
|
54 | }
|
55 |
|
56 | process.env.NODE_ENV !== "production" ? Ripple.propTypes = {
|
57 | |
58 |
|
59 |
|
60 |
|
61 | classes: PropTypes.object.isRequired,
|
62 | className: PropTypes.string,
|
63 |
|
64 | |
65 |
|
66 |
|
67 | in: PropTypes.bool,
|
68 |
|
69 | |
70 |
|
71 |
|
72 | onExited: PropTypes.func,
|
73 |
|
74 | |
75 |
|
76 |
|
77 | pulsate: PropTypes.bool,
|
78 |
|
79 | |
80 |
|
81 |
|
82 | rippleSize: PropTypes.number,
|
83 |
|
84 | |
85 |
|
86 |
|
87 | rippleX: PropTypes.number,
|
88 |
|
89 | |
90 |
|
91 |
|
92 | rippleY: PropTypes.number,
|
93 |
|
94 | |
95 |
|
96 |
|
97 | timeout: PropTypes.number.isRequired
|
98 | } : void 0;
|
99 | export default Ripple; |
\ | No newline at end of file |