1 | "use strict";
|
2 |
|
3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4 |
|
5 | Object.defineProperty(exports, "__esModule", {
|
6 | value: true
|
7 | });
|
8 | exports.default = exports.styles = void 0;
|
9 |
|
10 | var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
11 |
|
12 | var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
13 |
|
14 | var _react = _interopRequireDefault(require("react"));
|
15 |
|
16 | var _reactIs = require("react-is");
|
17 |
|
18 | var _propTypes = _interopRequireDefault(require("prop-types"));
|
19 |
|
20 | var _clsx = _interopRequireDefault(require("clsx"));
|
21 |
|
22 | var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
|
23 |
|
24 | var styles = function styles(theme) {
|
25 | return {
|
26 |
|
27 | root: {
|
28 | display: 'flex',
|
29 | justifyContent: 'center',
|
30 | height: 56,
|
31 | backgroundColor: theme.palette.background.paper
|
32 | }
|
33 | };
|
34 | };
|
35 |
|
36 | exports.styles = styles;
|
37 |
|
38 | var BottomNavigation = _react.default.forwardRef(function BottomNavigation(props, ref) {
|
39 | var children = props.children,
|
40 | classes = props.classes,
|
41 | className = props.className,
|
42 | _props$component = props.component,
|
43 | Component = _props$component === void 0 ? 'div' : _props$component,
|
44 | onChange = props.onChange,
|
45 | _props$showLabels = props.showLabels,
|
46 | showLabels = _props$showLabels === void 0 ? false : _props$showLabels,
|
47 | value = props.value,
|
48 | other = (0, _objectWithoutProperties2.default)(props, ["children", "classes", "className", "component", "onChange", "showLabels", "value"]);
|
49 | return _react.default.createElement(Component, (0, _extends2.default)({
|
50 | className: (0, _clsx.default)(classes.root, className),
|
51 | ref: ref
|
52 | }, other), _react.default.Children.map(children, function (child, childIndex) {
|
53 | if (!_react.default.isValidElement(child)) {
|
54 | return null;
|
55 | }
|
56 |
|
57 | if (process.env.NODE_ENV !== 'production') {
|
58 | if ((0, _reactIs.isFragment)(child)) {
|
59 | console.error(["Material-UI: the BottomNavigation component doesn't accept a Fragment as a child.", 'Consider providing an array instead.'].join('\n'));
|
60 | }
|
61 | }
|
62 |
|
63 | var childValue = child.props.value === undefined ? childIndex : child.props.value;
|
64 | return _react.default.cloneElement(child, {
|
65 | selected: childValue === value,
|
66 | showLabel: child.props.showLabel !== undefined ? child.props.showLabel : showLabels,
|
67 | value: childValue,
|
68 | onChange: onChange
|
69 | });
|
70 | }));
|
71 | });
|
72 |
|
73 | process.env.NODE_ENV !== "production" ? BottomNavigation.propTypes = {
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 | |
80 |
|
81 |
|
82 | children: _propTypes.default.node,
|
83 |
|
84 | |
85 |
|
86 |
|
87 |
|
88 | classes: _propTypes.default.object,
|
89 |
|
90 | |
91 |
|
92 |
|
93 | className: _propTypes.default.string,
|
94 |
|
95 | |
96 |
|
97 |
|
98 |
|
99 | component: _propTypes.default.elementType,
|
100 |
|
101 | |
102 |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 | onChange: _propTypes.default.func,
|
108 |
|
109 | |
110 |
|
111 |
|
112 |
|
113 | showLabels: _propTypes.default.bool,
|
114 |
|
115 | |
116 |
|
117 |
|
118 | value: _propTypes.default.any
|
119 | } : void 0;
|
120 |
|
121 | var _default = (0, _withStyles.default)(styles, {
|
122 | name: 'MuiBottomNavigation'
|
123 | })(BottomNavigation);
|
124 |
|
125 | exports.default = _default; |
\ | No newline at end of file |