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