paradiego
This commit is contained in:
448
node_modules/@mui/material/modern/ButtonBase/ButtonBase.js
generated
vendored
Normal file
448
node_modules/@mui/material/modern/ButtonBase/ButtonBase.js
generated
vendored
Normal file
@@ -0,0 +1,448 @@
|
||||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import clsx from 'clsx';
|
||||
import refType from '@mui/utils/refType';
|
||||
import elementTypeAcceptingRef from '@mui/utils/elementTypeAcceptingRef';
|
||||
import composeClasses from '@mui/utils/composeClasses';
|
||||
import isFocusVisible from '@mui/utils/isFocusVisible';
|
||||
import { styled } from "../zero-styled/index.js";
|
||||
import { useDefaultProps } from "../DefaultPropsProvider/index.js";
|
||||
import useForkRef from "../utils/useForkRef.js";
|
||||
import useEventCallback from "../utils/useEventCallback.js";
|
||||
import useLazyRipple from "../useLazyRipple/index.js";
|
||||
import TouchRipple from "./TouchRipple.js";
|
||||
import buttonBaseClasses, { getButtonBaseUtilityClass } from "./buttonBaseClasses.js";
|
||||
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
||||
const useUtilityClasses = ownerState => {
|
||||
const {
|
||||
disabled,
|
||||
focusVisible,
|
||||
focusVisibleClassName,
|
||||
classes
|
||||
} = ownerState;
|
||||
const slots = {
|
||||
root: ['root', disabled && 'disabled', focusVisible && 'focusVisible']
|
||||
};
|
||||
const composedClasses = composeClasses(slots, getButtonBaseUtilityClass, classes);
|
||||
if (focusVisible && focusVisibleClassName) {
|
||||
composedClasses.root += ` ${focusVisibleClassName}`;
|
||||
}
|
||||
return composedClasses;
|
||||
};
|
||||
export const ButtonBaseRoot = styled('button', {
|
||||
name: 'MuiButtonBase',
|
||||
slot: 'Root',
|
||||
overridesResolver: (props, styles) => styles.root
|
||||
})({
|
||||
display: 'inline-flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
position: 'relative',
|
||||
boxSizing: 'border-box',
|
||||
WebkitTapHighlightColor: 'transparent',
|
||||
backgroundColor: 'transparent',
|
||||
// Reset default value
|
||||
// We disable the focus ring for mouse, touch and keyboard users.
|
||||
outline: 0,
|
||||
border: 0,
|
||||
margin: 0,
|
||||
// Remove the margin in Safari
|
||||
borderRadius: 0,
|
||||
padding: 0,
|
||||
// Remove the padding in Firefox
|
||||
cursor: 'pointer',
|
||||
userSelect: 'none',
|
||||
verticalAlign: 'middle',
|
||||
MozAppearance: 'none',
|
||||
// Reset
|
||||
WebkitAppearance: 'none',
|
||||
// Reset
|
||||
textDecoration: 'none',
|
||||
// So we take precedent over the style of a native <a /> element.
|
||||
color: 'inherit',
|
||||
'&::-moz-focus-inner': {
|
||||
borderStyle: 'none' // Remove Firefox dotted outline.
|
||||
},
|
||||
[`&.${buttonBaseClasses.disabled}`]: {
|
||||
pointerEvents: 'none',
|
||||
// Disable link interactions
|
||||
cursor: 'default'
|
||||
},
|
||||
'@media print': {
|
||||
colorAdjust: 'exact'
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* `ButtonBase` contains as few styles as possible.
|
||||
* It aims to be a simple building block for creating a button.
|
||||
* It contains a load of style reset and some focus/ripple logic.
|
||||
*/
|
||||
const ButtonBase = /*#__PURE__*/React.forwardRef(function ButtonBase(inProps, ref) {
|
||||
const props = useDefaultProps({
|
||||
props: inProps,
|
||||
name: 'MuiButtonBase'
|
||||
});
|
||||
const {
|
||||
action,
|
||||
centerRipple = false,
|
||||
children,
|
||||
className,
|
||||
component = 'button',
|
||||
disabled = false,
|
||||
disableRipple = false,
|
||||
disableTouchRipple = false,
|
||||
focusRipple = false,
|
||||
focusVisibleClassName,
|
||||
LinkComponent = 'a',
|
||||
onBlur,
|
||||
onClick,
|
||||
onContextMenu,
|
||||
onDragLeave,
|
||||
onFocus,
|
||||
onFocusVisible,
|
||||
onKeyDown,
|
||||
onKeyUp,
|
||||
onMouseDown,
|
||||
onMouseLeave,
|
||||
onMouseUp,
|
||||
onTouchEnd,
|
||||
onTouchMove,
|
||||
onTouchStart,
|
||||
tabIndex = 0,
|
||||
TouchRippleProps,
|
||||
touchRippleRef,
|
||||
type,
|
||||
...other
|
||||
} = props;
|
||||
const buttonRef = React.useRef(null);
|
||||
const ripple = useLazyRipple();
|
||||
const handleRippleRef = useForkRef(ripple.ref, touchRippleRef);
|
||||
const [focusVisible, setFocusVisible] = React.useState(false);
|
||||
if (disabled && focusVisible) {
|
||||
setFocusVisible(false);
|
||||
}
|
||||
React.useImperativeHandle(action, () => ({
|
||||
focusVisible: () => {
|
||||
setFocusVisible(true);
|
||||
buttonRef.current.focus();
|
||||
}
|
||||
}), []);
|
||||
const enableTouchRipple = ripple.shouldMount && !disableRipple && !disabled;
|
||||
React.useEffect(() => {
|
||||
if (focusVisible && focusRipple && !disableRipple) {
|
||||
ripple.pulsate();
|
||||
}
|
||||
}, [disableRipple, focusRipple, focusVisible, ripple]);
|
||||
function useRippleHandler(rippleAction, eventCallback, skipRippleAction = disableTouchRipple) {
|
||||
return useEventCallback(event => {
|
||||
if (eventCallback) {
|
||||
eventCallback(event);
|
||||
}
|
||||
const ignore = skipRippleAction;
|
||||
if (!ignore) {
|
||||
ripple[rippleAction](event);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
const handleMouseDown = useRippleHandler('start', onMouseDown);
|
||||
const handleContextMenu = useRippleHandler('stop', onContextMenu);
|
||||
const handleDragLeave = useRippleHandler('stop', onDragLeave);
|
||||
const handleMouseUp = useRippleHandler('stop', onMouseUp);
|
||||
const handleMouseLeave = useRippleHandler('stop', event => {
|
||||
if (focusVisible) {
|
||||
event.preventDefault();
|
||||
}
|
||||
if (onMouseLeave) {
|
||||
onMouseLeave(event);
|
||||
}
|
||||
});
|
||||
const handleTouchStart = useRippleHandler('start', onTouchStart);
|
||||
const handleTouchEnd = useRippleHandler('stop', onTouchEnd);
|
||||
const handleTouchMove = useRippleHandler('stop', onTouchMove);
|
||||
const handleBlur = useRippleHandler('stop', event => {
|
||||
if (!isFocusVisible(event.target)) {
|
||||
setFocusVisible(false);
|
||||
}
|
||||
if (onBlur) {
|
||||
onBlur(event);
|
||||
}
|
||||
}, false);
|
||||
const handleFocus = useEventCallback(event => {
|
||||
// Fix for https://github.com/facebook/react/issues/7769
|
||||
if (!buttonRef.current) {
|
||||
buttonRef.current = event.currentTarget;
|
||||
}
|
||||
if (isFocusVisible(event.target)) {
|
||||
setFocusVisible(true);
|
||||
if (onFocusVisible) {
|
||||
onFocusVisible(event);
|
||||
}
|
||||
}
|
||||
if (onFocus) {
|
||||
onFocus(event);
|
||||
}
|
||||
});
|
||||
const isNonNativeButton = () => {
|
||||
const button = buttonRef.current;
|
||||
return component && component !== 'button' && !(button.tagName === 'A' && button.href);
|
||||
};
|
||||
const handleKeyDown = useEventCallback(event => {
|
||||
// Check if key is already down to avoid repeats being counted as multiple activations
|
||||
if (focusRipple && !event.repeat && focusVisible && event.key === ' ') {
|
||||
ripple.stop(event, () => {
|
||||
ripple.start(event);
|
||||
});
|
||||
}
|
||||
if (event.target === event.currentTarget && isNonNativeButton() && event.key === ' ') {
|
||||
event.preventDefault();
|
||||
}
|
||||
if (onKeyDown) {
|
||||
onKeyDown(event);
|
||||
}
|
||||
|
||||
// Keyboard accessibility for non interactive elements
|
||||
if (event.target === event.currentTarget && isNonNativeButton() && event.key === 'Enter' && !disabled) {
|
||||
event.preventDefault();
|
||||
if (onClick) {
|
||||
onClick(event);
|
||||
}
|
||||
}
|
||||
});
|
||||
const handleKeyUp = useEventCallback(event => {
|
||||
// calling preventDefault in keyUp on a <button> will not dispatch a click event if Space is pressed
|
||||
// https://codesandbox.io/p/sandbox/button-keyup-preventdefault-dn7f0
|
||||
if (focusRipple && event.key === ' ' && focusVisible && !event.defaultPrevented) {
|
||||
ripple.stop(event, () => {
|
||||
ripple.pulsate(event);
|
||||
});
|
||||
}
|
||||
if (onKeyUp) {
|
||||
onKeyUp(event);
|
||||
}
|
||||
|
||||
// Keyboard accessibility for non interactive elements
|
||||
if (onClick && event.target === event.currentTarget && isNonNativeButton() && event.key === ' ' && !event.defaultPrevented) {
|
||||
onClick(event);
|
||||
}
|
||||
});
|
||||
let ComponentProp = component;
|
||||
if (ComponentProp === 'button' && (other.href || other.to)) {
|
||||
ComponentProp = LinkComponent;
|
||||
}
|
||||
const buttonProps = {};
|
||||
if (ComponentProp === 'button') {
|
||||
buttonProps.type = type === undefined ? 'button' : type;
|
||||
buttonProps.disabled = disabled;
|
||||
} else {
|
||||
if (!other.href && !other.to) {
|
||||
buttonProps.role = 'button';
|
||||
}
|
||||
if (disabled) {
|
||||
buttonProps['aria-disabled'] = disabled;
|
||||
}
|
||||
}
|
||||
const handleRef = useForkRef(ref, buttonRef);
|
||||
const ownerState = {
|
||||
...props,
|
||||
centerRipple,
|
||||
component,
|
||||
disabled,
|
||||
disableRipple,
|
||||
disableTouchRipple,
|
||||
focusRipple,
|
||||
tabIndex,
|
||||
focusVisible
|
||||
};
|
||||
const classes = useUtilityClasses(ownerState);
|
||||
return /*#__PURE__*/_jsxs(ButtonBaseRoot, {
|
||||
as: ComponentProp,
|
||||
className: clsx(classes.root, className),
|
||||
ownerState: ownerState,
|
||||
onBlur: handleBlur,
|
||||
onClick: onClick,
|
||||
onContextMenu: handleContextMenu,
|
||||
onFocus: handleFocus,
|
||||
onKeyDown: handleKeyDown,
|
||||
onKeyUp: handleKeyUp,
|
||||
onMouseDown: handleMouseDown,
|
||||
onMouseLeave: handleMouseLeave,
|
||||
onMouseUp: handleMouseUp,
|
||||
onDragLeave: handleDragLeave,
|
||||
onTouchEnd: handleTouchEnd,
|
||||
onTouchMove: handleTouchMove,
|
||||
onTouchStart: handleTouchStart,
|
||||
ref: handleRef,
|
||||
tabIndex: disabled ? -1 : tabIndex,
|
||||
type: type,
|
||||
...buttonProps,
|
||||
...other,
|
||||
children: [children, enableTouchRipple ? /*#__PURE__*/_jsx(TouchRipple, {
|
||||
ref: handleRippleRef,
|
||||
center: centerRipple,
|
||||
...TouchRippleProps
|
||||
}) : null]
|
||||
});
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? ButtonBase.propTypes /* remove-proptypes */ = {
|
||||
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
||||
// │ These PropTypes are generated from the TypeScript type definitions. │
|
||||
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
||||
// └─────────────────────────────────────────────────────────────────────┘
|
||||
/**
|
||||
* A ref for imperative actions.
|
||||
* It currently only supports `focusVisible()` action.
|
||||
*/
|
||||
action: refType,
|
||||
/**
|
||||
* If `true`, the ripples are centered.
|
||||
* They won't start at the cursor interaction position.
|
||||
* @default false
|
||||
*/
|
||||
centerRipple: PropTypes.bool,
|
||||
/**
|
||||
* The content of the component.
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes: PropTypes.object,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* The component used for the root node.
|
||||
* Either a string to use a HTML element or a component.
|
||||
*/
|
||||
component: elementTypeAcceptingRef,
|
||||
/**
|
||||
* If `true`, the component is disabled.
|
||||
* @default false
|
||||
*/
|
||||
disabled: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the ripple effect is disabled.
|
||||
*
|
||||
* ⚠️ Without a ripple there is no styling for :focus-visible by default. Be sure
|
||||
* to highlight the element by applying separate styles with the `.Mui-focusVisible` class.
|
||||
* @default false
|
||||
*/
|
||||
disableRipple: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the touch ripple effect is disabled.
|
||||
* @default false
|
||||
*/
|
||||
disableTouchRipple: PropTypes.bool,
|
||||
/**
|
||||
* If `true`, the base button will have a keyboard focus ripple.
|
||||
* @default false
|
||||
*/
|
||||
focusRipple: PropTypes.bool,
|
||||
/**
|
||||
* This prop can help identify which element has keyboard focus.
|
||||
* The class name will be applied when the element gains the focus through keyboard interaction.
|
||||
* It's a polyfill for the [CSS :focus-visible selector](https://drafts.csswg.org/selectors-4/#the-focus-visible-pseudo).
|
||||
* The rationale for using this feature [is explained here](https://github.com/WICG/focus-visible/blob/HEAD/explainer.md).
|
||||
* A [polyfill can be used](https://github.com/WICG/focus-visible) to apply a `focus-visible` class to other components
|
||||
* if needed.
|
||||
*/
|
||||
focusVisibleClassName: PropTypes.string,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
href: PropTypes /* @typescript-to-proptypes-ignore */.any,
|
||||
/**
|
||||
* The component used to render a link when the `href` prop is provided.
|
||||
* @default 'a'
|
||||
*/
|
||||
LinkComponent: PropTypes.elementType,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onBlur: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onClick: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onContextMenu: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onDragLeave: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onFocus: PropTypes.func,
|
||||
/**
|
||||
* Callback fired when the component is focused with a keyboard.
|
||||
* We trigger a `onFocus` callback too.
|
||||
*/
|
||||
onFocusVisible: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onKeyDown: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onKeyUp: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onMouseDown: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onMouseLeave: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onMouseUp: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onTouchEnd: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onTouchMove: PropTypes.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onTouchStart: PropTypes.func,
|
||||
/**
|
||||
* The system prop that allows defining system overrides as well as additional CSS styles.
|
||||
*/
|
||||
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
||||
/**
|
||||
* @default 0
|
||||
*/
|
||||
tabIndex: PropTypes.number,
|
||||
/**
|
||||
* Props applied to the `TouchRipple` element.
|
||||
*/
|
||||
TouchRippleProps: PropTypes.object,
|
||||
/**
|
||||
* A ref that points to the `TouchRipple` element.
|
||||
*/
|
||||
touchRippleRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
||||
current: PropTypes.shape({
|
||||
pulsate: PropTypes.func.isRequired,
|
||||
start: PropTypes.func.isRequired,
|
||||
stop: PropTypes.func.isRequired
|
||||
})
|
||||
})]),
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
type: PropTypes.oneOfType([PropTypes.oneOf(['button', 'reset', 'submit']), PropTypes.string])
|
||||
} : void 0;
|
||||
export default ButtonBase;
|
||||
88
node_modules/@mui/material/modern/ButtonBase/Ripple.js
generated
vendored
Normal file
88
node_modules/@mui/material/modern/ButtonBase/Ripple.js
generated
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import clsx from 'clsx';
|
||||
|
||||
/**
|
||||
* @ignore - internal component.
|
||||
*/
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
function Ripple(props) {
|
||||
const {
|
||||
className,
|
||||
classes,
|
||||
pulsate = false,
|
||||
rippleX,
|
||||
rippleY,
|
||||
rippleSize,
|
||||
in: inProp,
|
||||
onExited,
|
||||
timeout
|
||||
} = props;
|
||||
const [leaving, setLeaving] = React.useState(false);
|
||||
const rippleClassName = clsx(className, classes.ripple, classes.rippleVisible, pulsate && classes.ripplePulsate);
|
||||
const rippleStyles = {
|
||||
width: rippleSize,
|
||||
height: rippleSize,
|
||||
top: -(rippleSize / 2) + rippleY,
|
||||
left: -(rippleSize / 2) + rippleX
|
||||
};
|
||||
const childClassName = clsx(classes.child, leaving && classes.childLeaving, pulsate && classes.childPulsate);
|
||||
if (!inProp && !leaving) {
|
||||
setLeaving(true);
|
||||
}
|
||||
React.useEffect(() => {
|
||||
if (!inProp && onExited != null) {
|
||||
// react-transition-group#onExited
|
||||
const timeoutId = setTimeout(onExited, timeout);
|
||||
return () => {
|
||||
clearTimeout(timeoutId);
|
||||
};
|
||||
}
|
||||
return undefined;
|
||||
}, [onExited, inProp, timeout]);
|
||||
return /*#__PURE__*/_jsx("span", {
|
||||
className: rippleClassName,
|
||||
style: rippleStyles,
|
||||
children: /*#__PURE__*/_jsx("span", {
|
||||
className: childClassName
|
||||
})
|
||||
});
|
||||
}
|
||||
process.env.NODE_ENV !== "production" ? Ripple.propTypes /* remove-proptypes */ = {
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes: PropTypes.object.isRequired,
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* @ignore - injected from TransitionGroup
|
||||
*/
|
||||
in: PropTypes.bool,
|
||||
/**
|
||||
* @ignore - injected from TransitionGroup
|
||||
*/
|
||||
onExited: PropTypes.func,
|
||||
/**
|
||||
* If `true`, the ripple pulsates, typically indicating the keyboard focus state of an element.
|
||||
*/
|
||||
pulsate: PropTypes.bool,
|
||||
/**
|
||||
* Diameter of the ripple.
|
||||
*/
|
||||
rippleSize: PropTypes.number,
|
||||
/**
|
||||
* Horizontal position of the ripple center.
|
||||
*/
|
||||
rippleX: PropTypes.number,
|
||||
/**
|
||||
* Vertical position of the ripple center.
|
||||
*/
|
||||
rippleY: PropTypes.number,
|
||||
/**
|
||||
* exit delay
|
||||
*/
|
||||
timeout: PropTypes.number.isRequired
|
||||
} : void 0;
|
||||
export default Ripple;
|
||||
324
node_modules/@mui/material/modern/ButtonBase/TouchRipple.js
generated
vendored
Normal file
324
node_modules/@mui/material/modern/ButtonBase/TouchRipple.js
generated
vendored
Normal file
@@ -0,0 +1,324 @@
|
||||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { TransitionGroup } from 'react-transition-group';
|
||||
import clsx from 'clsx';
|
||||
import useTimeout from '@mui/utils/useTimeout';
|
||||
import { keyframes, styled } from "../zero-styled/index.js";
|
||||
import { useDefaultProps } from "../DefaultPropsProvider/index.js";
|
||||
import Ripple from "./Ripple.js";
|
||||
import touchRippleClasses from "./touchRippleClasses.js";
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
const DURATION = 550;
|
||||
export const DELAY_RIPPLE = 80;
|
||||
const enterKeyframe = keyframes`
|
||||
0% {
|
||||
transform: scale(0);
|
||||
opacity: 0.1;
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: scale(1);
|
||||
opacity: 0.3;
|
||||
}
|
||||
`;
|
||||
const exitKeyframe = keyframes`
|
||||
0% {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 0;
|
||||
}
|
||||
`;
|
||||
const pulsateKeyframe = keyframes`
|
||||
0% {
|
||||
transform: scale(1);
|
||||
}
|
||||
|
||||
50% {
|
||||
transform: scale(0.92);
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: scale(1);
|
||||
}
|
||||
`;
|
||||
export const TouchRippleRoot = styled('span', {
|
||||
name: 'MuiTouchRipple',
|
||||
slot: 'Root'
|
||||
})({
|
||||
overflow: 'hidden',
|
||||
pointerEvents: 'none',
|
||||
position: 'absolute',
|
||||
zIndex: 0,
|
||||
top: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
borderRadius: 'inherit'
|
||||
});
|
||||
|
||||
// This `styled()` function invokes keyframes. `styled-components` only supports keyframes
|
||||
// in string templates. Do not convert these styles in JS object as it will break.
|
||||
export const TouchRippleRipple = styled(Ripple, {
|
||||
name: 'MuiTouchRipple',
|
||||
slot: 'Ripple'
|
||||
})`
|
||||
opacity: 0;
|
||||
position: absolute;
|
||||
|
||||
&.${touchRippleClasses.rippleVisible} {
|
||||
opacity: 0.3;
|
||||
transform: scale(1);
|
||||
animation-name: ${enterKeyframe};
|
||||
animation-duration: ${DURATION}ms;
|
||||
animation-timing-function: ${({
|
||||
theme
|
||||
}) => theme.transitions.easing.easeInOut};
|
||||
}
|
||||
|
||||
&.${touchRippleClasses.ripplePulsate} {
|
||||
animation-duration: ${({
|
||||
theme
|
||||
}) => theme.transitions.duration.shorter}ms;
|
||||
}
|
||||
|
||||
& .${touchRippleClasses.child} {
|
||||
opacity: 1;
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 50%;
|
||||
background-color: currentColor;
|
||||
}
|
||||
|
||||
& .${touchRippleClasses.childLeaving} {
|
||||
opacity: 0;
|
||||
animation-name: ${exitKeyframe};
|
||||
animation-duration: ${DURATION}ms;
|
||||
animation-timing-function: ${({
|
||||
theme
|
||||
}) => theme.transitions.easing.easeInOut};
|
||||
}
|
||||
|
||||
& .${touchRippleClasses.childPulsate} {
|
||||
position: absolute;
|
||||
/* @noflip */
|
||||
left: 0px;
|
||||
top: 0;
|
||||
animation-name: ${pulsateKeyframe};
|
||||
animation-duration: 2500ms;
|
||||
animation-timing-function: ${({
|
||||
theme
|
||||
}) => theme.transitions.easing.easeInOut};
|
||||
animation-iteration-count: infinite;
|
||||
animation-delay: 200ms;
|
||||
}
|
||||
`;
|
||||
|
||||
/**
|
||||
* @ignore - internal component.
|
||||
*
|
||||
* TODO v5: Make private
|
||||
*/
|
||||
const TouchRipple = /*#__PURE__*/React.forwardRef(function TouchRipple(inProps, ref) {
|
||||
const props = useDefaultProps({
|
||||
props: inProps,
|
||||
name: 'MuiTouchRipple'
|
||||
});
|
||||
const {
|
||||
center: centerProp = false,
|
||||
classes = {},
|
||||
className,
|
||||
...other
|
||||
} = props;
|
||||
const [ripples, setRipples] = React.useState([]);
|
||||
const nextKey = React.useRef(0);
|
||||
const rippleCallback = React.useRef(null);
|
||||
React.useEffect(() => {
|
||||
if (rippleCallback.current) {
|
||||
rippleCallback.current();
|
||||
rippleCallback.current = null;
|
||||
}
|
||||
}, [ripples]);
|
||||
|
||||
// Used to filter out mouse emulated events on mobile.
|
||||
const ignoringMouseDown = React.useRef(false);
|
||||
// We use a timer in order to only show the ripples for touch "click" like events.
|
||||
// We don't want to display the ripple for touch scroll events.
|
||||
const startTimer = useTimeout();
|
||||
|
||||
// This is the hook called once the previous timeout is ready.
|
||||
const startTimerCommit = React.useRef(null);
|
||||
const container = React.useRef(null);
|
||||
const startCommit = React.useCallback(params => {
|
||||
const {
|
||||
pulsate,
|
||||
rippleX,
|
||||
rippleY,
|
||||
rippleSize,
|
||||
cb
|
||||
} = params;
|
||||
setRipples(oldRipples => [...oldRipples, /*#__PURE__*/_jsx(TouchRippleRipple, {
|
||||
classes: {
|
||||
ripple: clsx(classes.ripple, touchRippleClasses.ripple),
|
||||
rippleVisible: clsx(classes.rippleVisible, touchRippleClasses.rippleVisible),
|
||||
ripplePulsate: clsx(classes.ripplePulsate, touchRippleClasses.ripplePulsate),
|
||||
child: clsx(classes.child, touchRippleClasses.child),
|
||||
childLeaving: clsx(classes.childLeaving, touchRippleClasses.childLeaving),
|
||||
childPulsate: clsx(classes.childPulsate, touchRippleClasses.childPulsate)
|
||||
},
|
||||
timeout: DURATION,
|
||||
pulsate: pulsate,
|
||||
rippleX: rippleX,
|
||||
rippleY: rippleY,
|
||||
rippleSize: rippleSize
|
||||
}, nextKey.current)]);
|
||||
nextKey.current += 1;
|
||||
rippleCallback.current = cb;
|
||||
}, [classes]);
|
||||
const start = React.useCallback((event = {}, options = {}, cb = () => {}) => {
|
||||
const {
|
||||
pulsate = false,
|
||||
center = centerProp || options.pulsate,
|
||||
fakeElement = false // For test purposes
|
||||
} = options;
|
||||
if (event?.type === 'mousedown' && ignoringMouseDown.current) {
|
||||
ignoringMouseDown.current = false;
|
||||
return;
|
||||
}
|
||||
if (event?.type === 'touchstart') {
|
||||
ignoringMouseDown.current = true;
|
||||
}
|
||||
const element = fakeElement ? null : container.current;
|
||||
const rect = element ? element.getBoundingClientRect() : {
|
||||
width: 0,
|
||||
height: 0,
|
||||
left: 0,
|
||||
top: 0
|
||||
};
|
||||
|
||||
// Get the size of the ripple
|
||||
let rippleX;
|
||||
let rippleY;
|
||||
let rippleSize;
|
||||
if (center || event === undefined || event.clientX === 0 && event.clientY === 0 || !event.clientX && !event.touches) {
|
||||
rippleX = Math.round(rect.width / 2);
|
||||
rippleY = Math.round(rect.height / 2);
|
||||
} else {
|
||||
const {
|
||||
clientX,
|
||||
clientY
|
||||
} = event.touches && event.touches.length > 0 ? event.touches[0] : event;
|
||||
rippleX = Math.round(clientX - rect.left);
|
||||
rippleY = Math.round(clientY - rect.top);
|
||||
}
|
||||
if (center) {
|
||||
rippleSize = Math.sqrt((2 * rect.width ** 2 + rect.height ** 2) / 3);
|
||||
|
||||
// For some reason the animation is broken on Mobile Chrome if the size is even.
|
||||
if (rippleSize % 2 === 0) {
|
||||
rippleSize += 1;
|
||||
}
|
||||
} else {
|
||||
const sizeX = Math.max(Math.abs((element ? element.clientWidth : 0) - rippleX), rippleX) * 2 + 2;
|
||||
const sizeY = Math.max(Math.abs((element ? element.clientHeight : 0) - rippleY), rippleY) * 2 + 2;
|
||||
rippleSize = Math.sqrt(sizeX ** 2 + sizeY ** 2);
|
||||
}
|
||||
|
||||
// Touche devices
|
||||
if (event?.touches) {
|
||||
// check that this isn't another touchstart due to multitouch
|
||||
// otherwise we will only clear a single timer when unmounting while two
|
||||
// are running
|
||||
if (startTimerCommit.current === null) {
|
||||
// Prepare the ripple effect.
|
||||
startTimerCommit.current = () => {
|
||||
startCommit({
|
||||
pulsate,
|
||||
rippleX,
|
||||
rippleY,
|
||||
rippleSize,
|
||||
cb
|
||||
});
|
||||
};
|
||||
// Delay the execution of the ripple effect.
|
||||
// We have to make a tradeoff with this delay value.
|
||||
startTimer.start(DELAY_RIPPLE, () => {
|
||||
if (startTimerCommit.current) {
|
||||
startTimerCommit.current();
|
||||
startTimerCommit.current = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
startCommit({
|
||||
pulsate,
|
||||
rippleX,
|
||||
rippleY,
|
||||
rippleSize,
|
||||
cb
|
||||
});
|
||||
}
|
||||
}, [centerProp, startCommit, startTimer]);
|
||||
const pulsate = React.useCallback(() => {
|
||||
start({}, {
|
||||
pulsate: true
|
||||
});
|
||||
}, [start]);
|
||||
const stop = React.useCallback((event, cb) => {
|
||||
startTimer.clear();
|
||||
|
||||
// The touch interaction occurs too quickly.
|
||||
// We still want to show ripple effect.
|
||||
if (event?.type === 'touchend' && startTimerCommit.current) {
|
||||
startTimerCommit.current();
|
||||
startTimerCommit.current = null;
|
||||
startTimer.start(0, () => {
|
||||
stop(event, cb);
|
||||
});
|
||||
return;
|
||||
}
|
||||
startTimerCommit.current = null;
|
||||
setRipples(oldRipples => {
|
||||
if (oldRipples.length > 0) {
|
||||
return oldRipples.slice(1);
|
||||
}
|
||||
return oldRipples;
|
||||
});
|
||||
rippleCallback.current = cb;
|
||||
}, [startTimer]);
|
||||
React.useImperativeHandle(ref, () => ({
|
||||
pulsate,
|
||||
start,
|
||||
stop
|
||||
}), [pulsate, start, stop]);
|
||||
return /*#__PURE__*/_jsx(TouchRippleRoot, {
|
||||
className: clsx(touchRippleClasses.root, classes.root, className),
|
||||
ref: container,
|
||||
...other,
|
||||
children: /*#__PURE__*/_jsx(TransitionGroup, {
|
||||
component: null,
|
||||
exit: true,
|
||||
children: ripples
|
||||
})
|
||||
});
|
||||
});
|
||||
process.env.NODE_ENV !== "production" ? TouchRipple.propTypes /* remove-proptypes */ = {
|
||||
/**
|
||||
* If `true`, the ripple starts at the center of the component
|
||||
* rather than at the point of interaction.
|
||||
*/
|
||||
center: PropTypes.bool,
|
||||
/**
|
||||
* Override or extend the styles applied to the component.
|
||||
*/
|
||||
classes: PropTypes.object,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className: PropTypes.string
|
||||
} : void 0;
|
||||
export default TouchRipple;
|
||||
7
node_modules/@mui/material/modern/ButtonBase/buttonBaseClasses.js
generated
vendored
Normal file
7
node_modules/@mui/material/modern/ButtonBase/buttonBaseClasses.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
||||
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
||||
export function getButtonBaseUtilityClass(slot) {
|
||||
return generateUtilityClass('MuiButtonBase', slot);
|
||||
}
|
||||
const buttonBaseClasses = generateUtilityClasses('MuiButtonBase', ['root', 'disabled', 'focusVisible']);
|
||||
export default buttonBaseClasses;
|
||||
5
node_modules/@mui/material/modern/ButtonBase/index.js
generated
vendored
Normal file
5
node_modules/@mui/material/modern/ButtonBase/index.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export { default } from "./ButtonBase.js";
|
||||
export { default as buttonBaseClasses } from "./buttonBaseClasses.js";
|
||||
export * from "./buttonBaseClasses.js";
|
||||
export { default as touchRippleClasses } from "./touchRippleClasses.js";
|
||||
export * from "./touchRippleClasses.js";
|
||||
7
node_modules/@mui/material/modern/ButtonBase/touchRippleClasses.js
generated
vendored
Normal file
7
node_modules/@mui/material/modern/ButtonBase/touchRippleClasses.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
||||
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
||||
export function getTouchRippleUtilityClass(slot) {
|
||||
return generateUtilityClass('MuiTouchRipple', slot);
|
||||
}
|
||||
const touchRippleClasses = generateUtilityClasses('MuiTouchRipple', ['root', 'ripple', 'rippleVisible', 'ripplePulsate', 'child', 'childLeaving', 'childPulsate']);
|
||||
export default touchRippleClasses;
|
||||
Reference in New Issue
Block a user