1 | 'use client';
|
2 |
|
3 | import * as React from 'react';
|
4 | import PropTypes from 'prop-types';
|
5 | import clsx from 'clsx';
|
6 | import composeClasses from '@mui/utils/composeClasses';
|
7 | import { styled } from "../zero-styled/index.js";
|
8 | import memoTheme from "../utils/memoTheme.js";
|
9 | import { useDefaultProps } from "../DefaultPropsProvider/index.js";
|
10 | import cardActionAreaClasses, { getCardActionAreaUtilityClass } from "./cardActionAreaClasses.js";
|
11 | import ButtonBase from "../ButtonBase/index.js";
|
12 | import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
13 | const useUtilityClasses = ownerState => {
|
14 | const {
|
15 | classes
|
16 | } = ownerState;
|
17 | const slots = {
|
18 | root: ['root'],
|
19 | focusHighlight: ['focusHighlight']
|
20 | };
|
21 | return composeClasses(slots, getCardActionAreaUtilityClass, classes);
|
22 | };
|
23 | const CardActionAreaRoot = styled(ButtonBase, {
|
24 | name: 'MuiCardActionArea',
|
25 | slot: 'Root',
|
26 | overridesResolver: (props, styles) => styles.root
|
27 | })(memoTheme(({
|
28 | theme
|
29 | }) => ({
|
30 | display: 'block',
|
31 | textAlign: 'inherit',
|
32 | borderRadius: 'inherit',
|
33 |
|
34 | width: '100%',
|
35 | [`&:hover .${cardActionAreaClasses.focusHighlight}`]: {
|
36 | opacity: (theme.vars || theme).palette.action.hoverOpacity,
|
37 | '@media (hover: none)': {
|
38 | opacity: 0
|
39 | }
|
40 | },
|
41 | [`&.${cardActionAreaClasses.focusVisible} .${cardActionAreaClasses.focusHighlight}`]: {
|
42 | opacity: (theme.vars || theme).palette.action.focusOpacity
|
43 | }
|
44 | })));
|
45 | const CardActionAreaFocusHighlight = styled('span', {
|
46 | name: 'MuiCardActionArea',
|
47 | slot: 'FocusHighlight',
|
48 | overridesResolver: (props, styles) => styles.focusHighlight
|
49 | })(memoTheme(({
|
50 | theme
|
51 | }) => ({
|
52 | overflow: 'hidden',
|
53 | pointerEvents: 'none',
|
54 | position: 'absolute',
|
55 | top: 0,
|
56 | right: 0,
|
57 | bottom: 0,
|
58 | left: 0,
|
59 | borderRadius: 'inherit',
|
60 | opacity: 0,
|
61 | backgroundColor: 'currentcolor',
|
62 | transition: theme.transitions.create('opacity', {
|
63 | duration: theme.transitions.duration.short
|
64 | })
|
65 | })));
|
66 | const CardActionArea = React.forwardRef(function CardActionArea(inProps, ref) {
|
67 | const props = useDefaultProps({
|
68 | props: inProps,
|
69 | name: 'MuiCardActionArea'
|
70 | });
|
71 | const {
|
72 | children,
|
73 | className,
|
74 | focusVisibleClassName,
|
75 | ...other
|
76 | } = props;
|
77 | const ownerState = props;
|
78 | const classes = useUtilityClasses(ownerState);
|
79 | return _jsxs(CardActionAreaRoot, {
|
80 | className: clsx(classes.root, className),
|
81 | focusVisibleClassName: clsx(focusVisibleClassName, classes.focusVisible),
|
82 | ref: ref,
|
83 | ownerState: ownerState,
|
84 | ...other,
|
85 | children: [children, _jsx(CardActionAreaFocusHighlight, {
|
86 | className: classes.focusHighlight,
|
87 | ownerState: ownerState
|
88 | })]
|
89 | });
|
90 | });
|
91 | process.env.NODE_ENV !== "production" ? CardActionArea.propTypes = {
|
92 |
|
93 |
|
94 |
|
95 |
|
96 | |
97 |
|
98 |
|
99 | children: PropTypes.node,
|
100 | |
101 |
|
102 |
|
103 | classes: PropTypes.object,
|
104 | |
105 |
|
106 |
|
107 | className: PropTypes.string,
|
108 | |
109 |
|
110 |
|
111 | focusVisibleClassName: PropTypes.string,
|
112 | |
113 |
|
114 |
|
115 | sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
116 | } : void 0;
|
117 | export default CardActionArea; |
\ | No newline at end of file |