1 | 'use client';
|
2 |
|
3 | import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
4 | import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
5 | import _extends from "@babel/runtime/helpers/esm/extends";
|
6 | import * as React from 'react';
|
7 | import PropTypes from 'prop-types';
|
8 | import clsx from 'clsx';
|
9 | import composeClasses from '@mui/utils/composeClasses';
|
10 | import ButtonBase from '../ButtonBase';
|
11 | import capitalize from '../utils/capitalize';
|
12 | import { useDefaultProps } from '../DefaultPropsProvider';
|
13 | import fabClasses, { getFabUtilityClass } from './fabClasses';
|
14 | import styled, { rootShouldForwardProp } from '../styles/styled';
|
15 | import { jsx as _jsx } from "react/jsx-runtime";
|
16 | var useUtilityClasses = function useUtilityClasses(ownerState) {
|
17 | var color = ownerState.color,
|
18 | variant = ownerState.variant,
|
19 | classes = ownerState.classes,
|
20 | size = ownerState.size;
|
21 | var slots = {
|
22 | root: ['root', variant, "size".concat(capitalize(size)), color === 'inherit' ? 'colorInherit' : color]
|
23 | };
|
24 | var composedClasses = composeClasses(slots, getFabUtilityClass, classes);
|
25 | return _extends({}, classes, composedClasses);
|
26 | };
|
27 | var FabRoot = styled(ButtonBase, {
|
28 | name: 'MuiFab',
|
29 | slot: 'Root',
|
30 | shouldForwardProp: function shouldForwardProp(prop) {
|
31 | return rootShouldForwardProp(prop) || prop === 'classes';
|
32 | },
|
33 | overridesResolver: function overridesResolver(props, styles) {
|
34 | var ownerState = props.ownerState;
|
35 | return [styles.root, styles[ownerState.variant], styles["size".concat(capitalize(ownerState.size))], ownerState.color === 'inherit' && styles.colorInherit, styles[capitalize(ownerState.size)], styles[ownerState.color]];
|
36 | }
|
37 | })(function (_ref) {
|
38 | var _theme$palette$getCon, _theme$palette;
|
39 | var theme = _ref.theme,
|
40 | ownerState = _ref.ownerState;
|
41 | return _extends({}, theme.typography.button, _defineProperty({
|
42 | minHeight: 36,
|
43 | transition: theme.transitions.create(['background-color', 'box-shadow', 'border-color'], {
|
44 | duration: theme.transitions.duration.short
|
45 | }),
|
46 | borderRadius: '50%',
|
47 | padding: 0,
|
48 | minWidth: 0,
|
49 | width: 56,
|
50 | height: 56,
|
51 | zIndex: (theme.vars || theme).zIndex.fab,
|
52 | boxShadow: (theme.vars || theme).shadows[6],
|
53 | '&:active': {
|
54 | boxShadow: (theme.vars || theme).shadows[12]
|
55 | },
|
56 | color: theme.vars ? theme.vars.palette.text.primary : (_theme$palette$getCon = (_theme$palette = theme.palette).getContrastText) == null ? void 0 : _theme$palette$getCon.call(_theme$palette, theme.palette.grey[300]),
|
57 | backgroundColor: (theme.vars || theme).palette.grey[300],
|
58 | '&:hover': {
|
59 | backgroundColor: (theme.vars || theme).palette.grey.A100,
|
60 |
|
61 | '@media (hover: none)': {
|
62 | backgroundColor: (theme.vars || theme).palette.grey[300]
|
63 | },
|
64 | textDecoration: 'none'
|
65 | }
|
66 | }, "&.".concat(fabClasses.focusVisible), {
|
67 | boxShadow: (theme.vars || theme).shadows[6]
|
68 | }), ownerState.size === 'small' && {
|
69 | width: 40,
|
70 | height: 40
|
71 | }, ownerState.size === 'medium' && {
|
72 | width: 48,
|
73 | height: 48
|
74 | }, ownerState.variant === 'extended' && {
|
75 | borderRadius: 48 / 2,
|
76 | padding: '0 16px',
|
77 | width: 'auto',
|
78 | minHeight: 'auto',
|
79 | minWidth: 48,
|
80 | height: 48
|
81 | }, ownerState.variant === 'extended' && ownerState.size === 'small' && {
|
82 | width: 'auto',
|
83 | padding: '0 8px',
|
84 | borderRadius: 34 / 2,
|
85 | minWidth: 34,
|
86 | height: 34
|
87 | }, ownerState.variant === 'extended' && ownerState.size === 'medium' && {
|
88 | width: 'auto',
|
89 | padding: '0 16px',
|
90 | borderRadius: 40 / 2,
|
91 | minWidth: 40,
|
92 | height: 40
|
93 | }, ownerState.color === 'inherit' && {
|
94 | color: 'inherit'
|
95 | });
|
96 | }, function (_ref2) {
|
97 | var theme = _ref2.theme,
|
98 | ownerState = _ref2.ownerState;
|
99 | return _extends({}, ownerState.color !== 'inherit' && ownerState.color !== 'default' && (theme.vars || theme).palette[ownerState.color] != null && {
|
100 | color: (theme.vars || theme).palette[ownerState.color].contrastText,
|
101 | backgroundColor: (theme.vars || theme).palette[ownerState.color].main,
|
102 | '&:hover': {
|
103 | backgroundColor: (theme.vars || theme).palette[ownerState.color].dark,
|
104 |
|
105 | '@media (hover: none)': {
|
106 | backgroundColor: (theme.vars || theme).palette[ownerState.color].main
|
107 | }
|
108 | }
|
109 | });
|
110 | }, function (_ref3) {
|
111 | var theme = _ref3.theme;
|
112 | return _defineProperty({}, "&.".concat(fabClasses.disabled), {
|
113 | color: (theme.vars || theme).palette.action.disabled,
|
114 | boxShadow: (theme.vars || theme).shadows[0],
|
115 | backgroundColor: (theme.vars || theme).palette.action.disabledBackground
|
116 | });
|
117 | });
|
118 | var Fab = React.forwardRef(function Fab(inProps, ref) {
|
119 | var props = useDefaultProps({
|
120 | props: inProps,
|
121 | name: 'MuiFab'
|
122 | });
|
123 | var children = props.children,
|
124 | className = props.className,
|
125 | _props$color = props.color,
|
126 | color = _props$color === void 0 ? 'default' : _props$color,
|
127 | _props$component = props.component,
|
128 | component = _props$component === void 0 ? 'button' : _props$component,
|
129 | _props$disabled = props.disabled,
|
130 | disabled = _props$disabled === void 0 ? false : _props$disabled,
|
131 | _props$disableFocusRi = props.disableFocusRipple,
|
132 | disableFocusRipple = _props$disableFocusRi === void 0 ? false : _props$disableFocusRi,
|
133 | focusVisibleClassName = props.focusVisibleClassName,
|
134 | _props$size = props.size,
|
135 | size = _props$size === void 0 ? 'large' : _props$size,
|
136 | _props$variant = props.variant,
|
137 | variant = _props$variant === void 0 ? 'circular' : _props$variant,
|
138 | other = _objectWithoutProperties(props, ["children", "className", "color", "component", "disabled", "disableFocusRipple", "focusVisibleClassName", "size", "variant"]);
|
139 | var ownerState = _extends({}, props, {
|
140 | color: color,
|
141 | component: component,
|
142 | disabled: disabled,
|
143 | disableFocusRipple: disableFocusRipple,
|
144 | size: size,
|
145 | variant: variant
|
146 | });
|
147 | var classes = useUtilityClasses(ownerState);
|
148 | return _jsx(FabRoot, _extends({
|
149 | className: clsx(classes.root, className),
|
150 | component: component,
|
151 | disabled: disabled,
|
152 | focusRipple: !disableFocusRipple,
|
153 | focusVisibleClassName: clsx(classes.focusVisible, focusVisibleClassName),
|
154 | ownerState: ownerState,
|
155 | ref: ref
|
156 | }, other, {
|
157 | classes: classes,
|
158 | children: children
|
159 | }));
|
160 | });
|
161 | process.env.NODE_ENV !== "production" ? Fab.propTypes = {
|
162 |
|
163 |
|
164 |
|
165 |
|
166 | |
167 |
|
168 |
|
169 | children: PropTypes.node,
|
170 | |
171 |
|
172 |
|
173 | classes: PropTypes.object,
|
174 | |
175 |
|
176 |
|
177 | className: PropTypes.string,
|
178 | |
179 |
|
180 |
|
181 |
|
182 |
|
183 |
|
184 | color: PropTypes .oneOfType([PropTypes.oneOf(['default', 'error', 'info', 'inherit', 'primary', 'secondary', 'success', 'warning']), PropTypes.string]),
|
185 | |
186 |
|
187 |
|
188 |
|
189 | component: PropTypes.elementType,
|
190 | |
191 |
|
192 |
|
193 |
|
194 | disabled: PropTypes.bool,
|
195 | |
196 |
|
197 |
|
198 |
|
199 | disableFocusRipple: PropTypes.bool,
|
200 | |
201 |
|
202 |
|
203 | disableRipple: PropTypes.bool,
|
204 | |
205 |
|
206 |
|
207 | focusVisibleClassName: PropTypes.string,
|
208 | |
209 |
|
210 |
|
211 |
|
212 | href: PropTypes.string,
|
213 | |
214 |
|
215 |
|
216 |
|
217 |
|
218 | size: PropTypes .oneOfType([PropTypes.oneOf(['small', 'medium', 'large']), PropTypes.string]),
|
219 | |
220 |
|
221 |
|
222 | sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
223 | |
224 |
|
225 |
|
226 |
|
227 | variant: PropTypes .oneOfType([PropTypes.oneOf(['circular', 'extended']), PropTypes.string])
|
228 | } : void 0;
|
229 | export default Fab; |
\ | No newline at end of file |