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