1 | 'use client';
|
2 |
|
3 | import _extends from "@babel/runtime/helpers/esm/extends";
|
4 | import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
5 | import * as React from 'react';
|
6 | import { isFragment } from 'react-is';
|
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 { getBottomNavigationUtilityClass } from './bottomNavigationClasses';
|
13 | import { jsx as _jsx } from "react/jsx-runtime";
|
14 | var useUtilityClasses = function useUtilityClasses(ownerState) {
|
15 | var classes = ownerState.classes;
|
16 | var slots = {
|
17 | root: ['root']
|
18 | };
|
19 | return composeClasses(slots, getBottomNavigationUtilityClass, classes);
|
20 | };
|
21 | var BottomNavigationRoot = styled('div', {
|
22 | name: 'MuiBottomNavigation',
|
23 | slot: 'Root',
|
24 | overridesResolver: function overridesResolver(props, styles) {
|
25 | return styles.root;
|
26 | }
|
27 | })(function (_ref) {
|
28 | var theme = _ref.theme;
|
29 | return {
|
30 | display: 'flex',
|
31 | justifyContent: 'center',
|
32 | height: 56,
|
33 | backgroundColor: (theme.vars || theme).palette.background.paper
|
34 | };
|
35 | });
|
36 | var BottomNavigation = React.forwardRef(function BottomNavigation(inProps, ref) {
|
37 | var props = useDefaultProps({
|
38 | props: inProps,
|
39 | name: 'MuiBottomNavigation'
|
40 | });
|
41 | var children = props.children,
|
42 | className = props.className,
|
43 | _props$component = props.component,
|
44 | component = _props$component === void 0 ? 'div' : _props$component,
|
45 | onChange = props.onChange,
|
46 | _props$showLabels = props.showLabels,
|
47 | showLabels = _props$showLabels === void 0 ? false : _props$showLabels,
|
48 | value = props.value,
|
49 | other = _objectWithoutProperties(props, ["children", "className", "component", "onChange", "showLabels", "value"]);
|
50 | var ownerState = _extends({}, props, {
|
51 | component: component,
|
52 | showLabels: showLabels
|
53 | });
|
54 | var classes = useUtilityClasses(ownerState);
|
55 | return _jsx(BottomNavigationRoot, _extends({
|
56 | as: component,
|
57 | className: clsx(classes.root, className),
|
58 | ref: ref,
|
59 | ownerState: ownerState
|
60 | }, other, {
|
61 | children: React.Children.map(children, function (child, childIndex) {
|
62 | if (! React.isValidElement(child)) {
|
63 | return null;
|
64 | }
|
65 | if (process.env.NODE_ENV !== 'production') {
|
66 | if (isFragment(child)) {
|
67 | console.error(["MUI: The BottomNavigation component doesn't accept a Fragment as a child.", 'Consider providing an array instead.'].join('\n'));
|
68 | }
|
69 | }
|
70 | var childValue = child.props.value === undefined ? childIndex : child.props.value;
|
71 | return React.cloneElement(child, {
|
72 | selected: childValue === value,
|
73 | showLabel: child.props.showLabel !== undefined ? child.props.showLabel : showLabels,
|
74 | value: childValue,
|
75 | onChange: onChange
|
76 | });
|
77 | })
|
78 | }));
|
79 | });
|
80 | process.env.NODE_ENV !== "production" ? BottomNavigation.propTypes = {
|
81 |
|
82 |
|
83 |
|
84 |
|
85 | |
86 |
|
87 |
|
88 | children: PropTypes.node,
|
89 | |
90 |
|
91 |
|
92 | classes: PropTypes.object,
|
93 | |
94 |
|
95 |
|
96 | className: PropTypes.string,
|
97 | |
98 |
|
99 |
|
100 |
|
101 | component: PropTypes.elementType,
|
102 | |
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 | onChange: PropTypes.func,
|
109 | |
110 |
|
111 |
|
112 |
|
113 |
|
114 | showLabels: PropTypes.bool,
|
115 | |
116 |
|
117 |
|
118 | sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
119 | |
120 |
|
121 |
|
122 | value: PropTypes.any
|
123 | } : void 0;
|
124 | export default BottomNavigation; |
\ | No newline at end of file |