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 styled from '../styles/styled';
|
11 | import { useDefaultProps } from '../DefaultPropsProvider';
|
12 | import ButtonBase from '../ButtonBase';
|
13 | import unsupportedProp from '../utils/unsupportedProp';
|
14 | import bottomNavigationActionClasses, { getBottomNavigationActionUtilityClass } from './bottomNavigationActionClasses';
|
15 | import { jsx as _jsx } from "react/jsx-runtime";
|
16 | import { jsxs as _jsxs } from "react/jsx-runtime";
|
17 | var useUtilityClasses = function useUtilityClasses(ownerState) {
|
18 | var classes = ownerState.classes,
|
19 | showLabel = ownerState.showLabel,
|
20 | selected = ownerState.selected;
|
21 | var slots = {
|
22 | root: ['root', !showLabel && !selected && 'iconOnly', selected && 'selected'],
|
23 | label: ['label', !showLabel && !selected && 'iconOnly', selected && 'selected']
|
24 | };
|
25 | return composeClasses(slots, getBottomNavigationActionUtilityClass, classes);
|
26 | };
|
27 | var BottomNavigationActionRoot = styled(ButtonBase, {
|
28 | name: 'MuiBottomNavigationAction',
|
29 | slot: 'Root',
|
30 | overridesResolver: function overridesResolver(props, styles) {
|
31 | var ownerState = props.ownerState;
|
32 | return [styles.root, !ownerState.showLabel && !ownerState.selected && styles.iconOnly];
|
33 | }
|
34 | })(function (_ref) {
|
35 | var theme = _ref.theme,
|
36 | ownerState = _ref.ownerState;
|
37 | return _extends({
|
38 | transition: theme.transitions.create(['color', 'padding-top'], {
|
39 | duration: theme.transitions.duration.short
|
40 | }),
|
41 | padding: '0px 12px',
|
42 | minWidth: 80,
|
43 | maxWidth: 168,
|
44 | color: (theme.vars || theme).palette.text.secondary,
|
45 | flexDirection: 'column',
|
46 | flex: '1'
|
47 | }, !ownerState.showLabel && !ownerState.selected && {
|
48 | paddingTop: 14
|
49 | }, !ownerState.showLabel && !ownerState.selected && !ownerState.label && {
|
50 | paddingTop: 0
|
51 | }, _defineProperty({}, "&.".concat(bottomNavigationActionClasses.selected), {
|
52 | color: (theme.vars || theme).palette.primary.main
|
53 | }));
|
54 | });
|
55 | var BottomNavigationActionLabel = styled('span', {
|
56 | name: 'MuiBottomNavigationAction',
|
57 | slot: 'Label',
|
58 | overridesResolver: function overridesResolver(props, styles) {
|
59 | return styles.label;
|
60 | }
|
61 | })(function (_ref2) {
|
62 | var theme = _ref2.theme,
|
63 | ownerState = _ref2.ownerState;
|
64 | return _extends({
|
65 | fontFamily: theme.typography.fontFamily,
|
66 | fontSize: theme.typography.pxToRem(12),
|
67 | opacity: 1,
|
68 | transition: 'font-size 0.2s, opacity 0.2s',
|
69 | transitionDelay: '0.1s'
|
70 | }, !ownerState.showLabel && !ownerState.selected && {
|
71 | opacity: 0,
|
72 | transitionDelay: '0s'
|
73 | }, _defineProperty({}, "&.".concat(bottomNavigationActionClasses.selected), {
|
74 | fontSize: theme.typography.pxToRem(14)
|
75 | }));
|
76 | });
|
77 | var BottomNavigationAction = React.forwardRef(function BottomNavigationAction(inProps, ref) {
|
78 | var props = useDefaultProps({
|
79 | props: inProps,
|
80 | name: 'MuiBottomNavigationAction'
|
81 | });
|
82 | var className = props.className,
|
83 | icon = props.icon,
|
84 | label = props.label,
|
85 | onChange = props.onChange,
|
86 | onClick = props.onClick,
|
87 | selected = props.selected,
|
88 | showLabel = props.showLabel,
|
89 | value = props.value,
|
90 | other = _objectWithoutProperties(props, ["className", "icon", "label", "onChange", "onClick", "selected", "showLabel", "value"]);
|
91 | var ownerState = props;
|
92 | var classes = useUtilityClasses(ownerState);
|
93 | var handleChange = function handleChange(event) {
|
94 | if (onChange) {
|
95 | onChange(event, value);
|
96 | }
|
97 | if (onClick) {
|
98 | onClick(event);
|
99 | }
|
100 | };
|
101 | return _jsxs(BottomNavigationActionRoot, _extends({
|
102 | ref: ref,
|
103 | className: clsx(classes.root, className),
|
104 | focusRipple: true,
|
105 | onClick: handleChange,
|
106 | ownerState: ownerState
|
107 | }, other, {
|
108 | children: [icon, _jsx(BottomNavigationActionLabel, {
|
109 | className: classes.label,
|
110 | ownerState: ownerState,
|
111 | children: label
|
112 | })]
|
113 | }));
|
114 | });
|
115 | process.env.NODE_ENV !== "production" ? BottomNavigationAction.propTypes = {
|
116 |
|
117 |
|
118 |
|
119 |
|
120 | |
121 |
|
122 |
|
123 |
|
124 | children: unsupportedProp,
|
125 | |
126 |
|
127 |
|
128 | classes: PropTypes.object,
|
129 | |
130 |
|
131 |
|
132 | className: PropTypes.string,
|
133 | |
134 |
|
135 |
|
136 | icon: PropTypes.node,
|
137 | |
138 |
|
139 |
|
140 | label: PropTypes.node,
|
141 | |
142 |
|
143 |
|
144 | onChange: PropTypes.func,
|
145 | |
146 |
|
147 |
|
148 | onClick: PropTypes.func,
|
149 | |
150 |
|
151 |
|
152 |
|
153 |
|
154 |
|
155 |
|
156 | showLabel: PropTypes.bool,
|
157 | |
158 |
|
159 |
|
160 | sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
161 | |
162 |
|
163 |
|
164 | value: PropTypes.any
|
165 | } : void 0;
|
166 | export default BottomNavigationAction; |
\ | No newline at end of file |