UNPKG

4.2 kBJavaScriptView Raw
1import _extends from "@babel/runtime/helpers/esm/extends";
2import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4import * as React from 'react';
5import PropTypes from 'prop-types';
6import clsx from 'clsx';
7import { unstable_composeClasses as composeClasses } from '@mui/base';
8import useThemeProps from '../styles/useThemeProps';
9import styled from '../styles/styled';
10import cardActionAreaClasses, { getCardActionAreaUtilityClass } from './cardActionAreaClasses';
11import ButtonBase from '../ButtonBase';
12import { jsx as _jsx } from "react/jsx-runtime";
13import { jsxs as _jsxs } from "react/jsx-runtime";
14
15var useUtilityClasses = function useUtilityClasses(ownerState) {
16 var classes = ownerState.classes;
17 var slots = {
18 root: ['root'],
19 focusHighlight: ['focusHighlight']
20 };
21 return composeClasses(slots, getCardActionAreaUtilityClass, classes);
22};
23
24var CardActionAreaRoot = styled(ButtonBase, {
25 name: 'MuiCardActionArea',
26 slot: 'Root',
27 overridesResolver: function overridesResolver(props, styles) {
28 return styles.root;
29 }
30})(function (_ref) {
31 var _ref2;
32
33 var theme = _ref.theme;
34 return _ref2 = {
35 display: 'block',
36 textAlign: 'inherit',
37 width: '100%'
38 }, _defineProperty(_ref2, "&:hover .".concat(cardActionAreaClasses.focusHighlight), {
39 opacity: (theme.vars || theme).palette.action.hoverOpacity,
40 '@media (hover: none)': {
41 opacity: 0
42 }
43 }), _defineProperty(_ref2, "&.".concat(cardActionAreaClasses.focusVisible, " .").concat(cardActionAreaClasses.focusHighlight), {
44 opacity: (theme.vars || theme).palette.action.focusOpacity
45 }), _ref2;
46});
47var CardActionAreaFocusHighlight = styled('span', {
48 name: 'MuiCardActionArea',
49 slot: 'FocusHighlight',
50 overridesResolver: function overridesResolver(props, styles) {
51 return styles.focusHighlight;
52 }
53})(function (_ref3) {
54 var theme = _ref3.theme;
55 return {
56 overflow: 'hidden',
57 pointerEvents: 'none',
58 position: 'absolute',
59 top: 0,
60 right: 0,
61 bottom: 0,
62 left: 0,
63 borderRadius: 'inherit',
64 opacity: 0,
65 backgroundColor: 'currentcolor',
66 transition: theme.transitions.create('opacity', {
67 duration: theme.transitions.duration.short
68 })
69 };
70});
71var CardActionArea = /*#__PURE__*/React.forwardRef(function CardActionArea(inProps, ref) {
72 var props = useThemeProps({
73 props: inProps,
74 name: 'MuiCardActionArea'
75 });
76
77 var children = props.children,
78 className = props.className,
79 focusVisibleClassName = props.focusVisibleClassName,
80 other = _objectWithoutProperties(props, ["children", "className", "focusVisibleClassName"]);
81
82 var ownerState = props;
83 var classes = useUtilityClasses(ownerState);
84 return /*#__PURE__*/_jsxs(CardActionAreaRoot, _extends({
85 className: clsx(classes.root, className),
86 focusVisibleClassName: clsx(focusVisibleClassName, classes.focusVisible),
87 ref: ref,
88 ownerState: ownerState
89 }, other, {
90 children: [children, /*#__PURE__*/_jsx(CardActionAreaFocusHighlight, {
91 className: classes.focusHighlight,
92 ownerState: ownerState
93 })]
94 }));
95});
96process.env.NODE_ENV !== "production" ? CardActionArea.propTypes
97/* remove-proptypes */
98= {
99 // ----------------------------- Warning --------------------------------
100 // | These PropTypes are generated from the TypeScript type definitions |
101 // | To update them edit the d.ts file and run "yarn proptypes" |
102 // ----------------------------------------------------------------------
103
104 /**
105 * The content of the component.
106 */
107 children: PropTypes.node,
108
109 /**
110 * Override or extend the styles applied to the component.
111 */
112 classes: PropTypes.object,
113
114 /**
115 * @ignore
116 */
117 className: PropTypes.string,
118
119 /**
120 * @ignore
121 */
122 focusVisibleClassName: PropTypes.string,
123
124 /**
125 * The system prop that allows defining system overrides as well as additional CSS styles.
126 */
127 sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
128} : void 0;
129export default CardActionArea;
\No newline at end of file