1 | "use strict";
|
2 |
|
3 | var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
4 |
|
5 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
6 |
|
7 | Object.defineProperty(exports, "__esModule", {
|
8 | value: true
|
9 | });
|
10 | exports.default = exports.styles = void 0;
|
11 |
|
12 | var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
13 |
|
14 | var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
15 |
|
16 | var React = _interopRequireWildcard(require("react"));
|
17 |
|
18 | var _reactIs = require("react-is");
|
19 |
|
20 | var _propTypes = _interopRequireDefault(require("prop-types"));
|
21 |
|
22 | var _clsx = _interopRequireDefault(require("clsx"));
|
23 |
|
24 | var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
|
25 |
|
26 | var styles = function styles(theme) {
|
27 | return {
|
28 |
|
29 | root: {
|
30 | display: 'flex',
|
31 | justifyContent: 'center',
|
32 | height: 56,
|
33 | backgroundColor: theme.palette.background.paper
|
34 | }
|
35 | };
|
36 | };
|
37 |
|
38 | exports.styles = styles;
|
39 | var BottomNavigation = React.forwardRef(function BottomNavigation(props, ref) {
|
40 | var children = props.children,
|
41 | classes = props.classes,
|
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 = (0, _objectWithoutProperties2.default)(props, ["children", "classes", "className", "component", "onChange", "showLabels", "value"]);
|
50 | return React.createElement(Component, (0, _extends2.default)({
|
51 | className: (0, _clsx.default)(classes.root, className),
|
52 | ref: ref
|
53 | }, other), React.Children.map(children, function (child, childIndex) {
|
54 | if (! React.isValidElement(child)) {
|
55 | return null;
|
56 | }
|
57 |
|
58 | if (process.env.NODE_ENV !== 'production') {
|
59 | if ((0, _reactIs.isFragment)(child)) {
|
60 | console.error(["Material-UI: The BottomNavigation component doesn't accept a Fragment as a child.", 'Consider providing an array instead.'].join('\n'));
|
61 | }
|
62 | }
|
63 |
|
64 | var childValue = child.props.value === undefined ? childIndex : child.props.value;
|
65 | return React.cloneElement(child, {
|
66 | selected: childValue === value,
|
67 | showLabel: child.props.showLabel !== undefined ? child.props.showLabel : showLabels,
|
68 | value: childValue,
|
69 | onChange: onChange
|
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
|
100 |
|
101 | .elementType,
|
102 |
|
103 | |
104 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 | onChange: _propTypes.default.func,
|
110 |
|
111 | |
112 |
|
113 |
|
114 |
|
115 | showLabels: _propTypes.default.bool,
|
116 |
|
117 | |
118 |
|
119 |
|
120 | value: _propTypes.default.any
|
121 | } : void 0;
|
122 |
|
123 | var _default = (0, _withStyles.default)(styles, {
|
124 | name: 'MuiBottomNavigation'
|
125 | })(BottomNavigation);
|
126 |
|
127 | exports.default = _default; |
\ | No newline at end of file |