1 | import _extends from "@babel/runtime/helpers/esm/extends";
|
2 | import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
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 { unstable_composeClasses as composeClasses } from '@mui/base';
|
8 | import styled from '../styles/styled';
|
9 | import useThemeProps from '../styles/useThemeProps';
|
10 | import { getBottomNavigationUtilityClass } from './bottomNavigationClasses';
|
11 | import { jsx as _jsx } from "react/jsx-runtime";
|
12 |
|
13 | var useUtilityClasses = function useUtilityClasses(ownerState) {
|
14 | var classes = ownerState.classes;
|
15 | var slots = {
|
16 | root: ['root']
|
17 | };
|
18 | return composeClasses(slots, getBottomNavigationUtilityClass, classes);
|
19 | };
|
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 = useThemeProps({
|
38 | props: inProps,
|
39 | name: 'MuiBottomNavigation'
|
40 | });
|
41 |
|
42 | var children = props.children,
|
43 | className = props.className,
|
44 | _props$component = props.component,
|
45 | component = _props$component === void 0 ? 'div' : _props$component,
|
46 | onChange = props.onChange,
|
47 | _props$showLabels = props.showLabels,
|
48 | showLabels = _props$showLabels === void 0 ? false : _props$showLabels,
|
49 | value = props.value,
|
50 | other = _objectWithoutProperties(props, ["children", "className", "component", "onChange", "showLabels", "value"]);
|
51 |
|
52 | var ownerState = _extends({}, props, {
|
53 | component: component,
|
54 | showLabels: showLabels
|
55 | });
|
56 |
|
57 | var classes = useUtilityClasses(ownerState);
|
58 | return _jsx(BottomNavigationRoot, _extends({
|
59 | as: component,
|
60 | className: clsx(classes.root, className),
|
61 | ref: ref,
|
62 | ownerState: ownerState
|
63 | }, other, {
|
64 | children: React.Children.map(children, function (child, childIndex) {
|
65 | if (! React.isValidElement(child)) {
|
66 | return null;
|
67 | }
|
68 |
|
69 | if (process.env.NODE_ENV !== 'production') {
|
70 | if (isFragment(child)) {
|
71 | console.error(["MUI: The BottomNavigation component doesn't accept a Fragment as a child.", 'Consider providing an array instead.'].join('\n'));
|
72 | }
|
73 | }
|
74 |
|
75 | var childValue = child.props.value === undefined ? childIndex : child.props.value;
|
76 | return React.cloneElement(child, {
|
77 | selected: childValue === value,
|
78 | showLabel: child.props.showLabel !== undefined ? child.props.showLabel : showLabels,
|
79 | value: childValue,
|
80 | onChange: onChange
|
81 | });
|
82 | })
|
83 | }));
|
84 | });
|
85 | process.env.NODE_ENV !== "production" ? BottomNavigation.propTypes
|
86 |
|
87 | = {
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 | |
94 |
|
95 |
|
96 | children: PropTypes.node,
|
97 |
|
98 | |
99 |
|
100 |
|
101 | classes: PropTypes.object,
|
102 |
|
103 | |
104 |
|
105 |
|
106 | className: PropTypes.string,
|
107 |
|
108 | |
109 |
|
110 |
|
111 |
|
112 | component: PropTypes.elementType,
|
113 |
|
114 | |
115 |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 | onChange: PropTypes.func,
|
121 |
|
122 | |
123 |
|
124 |
|
125 |
|
126 |
|
127 | showLabels: PropTypes.bool,
|
128 |
|
129 | |
130 |
|
131 |
|
132 | sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
133 |
|
134 | |
135 |
|
136 |
|
137 | value: PropTypes.any
|
138 | } : void 0;
|
139 | export default BottomNavigation; |
\ | No newline at end of file |