UNPKG

3.99 kBJavaScriptView Raw
1'use client';
2
3import * as React from 'react';
4import PropTypes from 'prop-types';
5import clsx from 'clsx';
6import composeClasses from '@mui/utils/composeClasses';
7import { styled } from "../zero-styled/index.js";
8import memoTheme from "../utils/memoTheme.js";
9import { useDefaultProps } from "../DefaultPropsProvider/index.js";
10import cardActionAreaClasses, { getCardActionAreaUtilityClass } from "./cardActionAreaClasses.js";
11import ButtonBase from "../ButtonBase/index.js";
12import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13const 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};
23const 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 // for Safari to work https://github.com/mui/material-ui/issues/36285.
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})));
45const 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})));
66const CardActionArea = /*#__PURE__*/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 /*#__PURE__*/_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, /*#__PURE__*/_jsx(CardActionAreaFocusHighlight, {
86 className: classes.focusHighlight,
87 ownerState: ownerState
88 })]
89 });
90});
91process.env.NODE_ENV !== "production" ? CardActionArea.propTypes /* remove-proptypes */ = {
92 // ┌────────────────────────────── Warning ──────────────────────────────┐
93 // │ These PropTypes are generated from the TypeScript type definitions. │
94 // │ To update them, edit the d.ts file and run `pnpm proptypes`. │
95 // └─────────────────────────────────────────────────────────────────────┘
96 /**
97 * The content of the component.
98 */
99 children: PropTypes.node,
100 /**
101 * Override or extend the styles applied to the component.
102 */
103 classes: PropTypes.object,
104 /**
105 * @ignore
106 */
107 className: PropTypes.string,
108 /**
109 * @ignore
110 */
111 focusVisibleClassName: PropTypes.string,
112 /**
113 * The system prop that allows defining system overrides as well as additional CSS styles.
114 */
115 sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
116} : void 0;
117export default CardActionArea;
\No newline at end of file