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 _propTypes = _interopRequireDefault(require("prop-types"));
|
19 |
|
20 | var _clsx = _interopRequireDefault(require("clsx"));
|
21 |
|
22 | var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
|
23 |
|
24 | var _ButtonBase = _interopRequireDefault(require("../ButtonBase"));
|
25 |
|
26 | var _unsupportedProp = _interopRequireDefault(require("../utils/unsupportedProp"));
|
27 |
|
28 | var styles = function styles(theme) {
|
29 | return {
|
30 |
|
31 | root: {
|
32 | transition: theme.transitions.create(['color', 'padding-top'], {
|
33 | duration: theme.transitions.duration.short
|
34 | }),
|
35 | padding: '6px 12px 8px',
|
36 | minWidth: 80,
|
37 | maxWidth: 168,
|
38 | color: theme.palette.text.secondary,
|
39 | flex: '1',
|
40 | '&$iconOnly': {
|
41 | paddingTop: 16
|
42 | },
|
43 | '&$selected': {
|
44 | paddingTop: 6,
|
45 | color: theme.palette.primary.main
|
46 | }
|
47 | },
|
48 |
|
49 |
|
50 | selected: {},
|
51 |
|
52 |
|
53 | iconOnly: {},
|
54 |
|
55 |
|
56 | wrapper: {
|
57 | display: 'inline-flex',
|
58 | alignItems: 'center',
|
59 | justifyContent: 'center',
|
60 | width: '100%',
|
61 | flexDirection: 'column'
|
62 | },
|
63 |
|
64 |
|
65 | label: {
|
66 | fontFamily: theme.typography.fontFamily,
|
67 | fontSize: theme.typography.pxToRem(12),
|
68 | opacity: 1,
|
69 | transition: 'font-size 0.2s, opacity 0.2s',
|
70 | transitionDelay: '0.1s',
|
71 | '&$iconOnly': {
|
72 | opacity: 0,
|
73 | transitionDelay: '0s'
|
74 | },
|
75 | '&$selected': {
|
76 | fontSize: theme.typography.pxToRem(14)
|
77 | }
|
78 | }
|
79 | };
|
80 | };
|
81 |
|
82 | exports.styles = styles;
|
83 | var BottomNavigationAction = React.forwardRef(function BottomNavigationAction(props, ref) {
|
84 | var classes = props.classes,
|
85 | className = props.className,
|
86 | icon = props.icon,
|
87 | label = props.label,
|
88 | onChange = props.onChange,
|
89 | onClick = props.onClick,
|
90 | selected = props.selected,
|
91 | showLabel = props.showLabel,
|
92 | value = props.value,
|
93 | other = (0, _objectWithoutProperties2.default)(props, ["classes", "className", "icon", "label", "onChange", "onClick", "selected", "showLabel", "value"]);
|
94 |
|
95 | var handleChange = function handleChange(event) {
|
96 | if (onChange) {
|
97 | onChange(event, value);
|
98 | }
|
99 |
|
100 | if (onClick) {
|
101 | onClick(event);
|
102 | }
|
103 | };
|
104 |
|
105 | return React.createElement(_ButtonBase.default, (0, _extends2.default)({
|
106 | ref: ref,
|
107 | className: (0, _clsx.default)(classes.root, className, selected ? classes.selected : !showLabel && classes.iconOnly),
|
108 | focusRipple: true,
|
109 | onClick: handleChange
|
110 | }, other), React.createElement("span", {
|
111 | className: classes.wrapper
|
112 | }, icon, React.createElement("span", {
|
113 | className: (0, _clsx.default)(classes.label, selected ? classes.selected : !showLabel && classes.iconOnly)
|
114 | }, label)));
|
115 | });
|
116 | process.env.NODE_ENV !== "production" ? BottomNavigationAction.propTypes = {
|
117 |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 | |
123 |
|
124 |
|
125 |
|
126 | children: _unsupportedProp.default,
|
127 |
|
128 | |
129 |
|
130 |
|
131 |
|
132 | classes: _propTypes.default.object,
|
133 |
|
134 | |
135 |
|
136 |
|
137 | className: _propTypes.default.string,
|
138 |
|
139 | |
140 |
|
141 |
|
142 | icon: _propTypes.default.node,
|
143 |
|
144 | |
145 |
|
146 |
|
147 | label: _propTypes.default.node,
|
148 |
|
149 | |
150 |
|
151 |
|
152 | onChange: _propTypes.default.func,
|
153 |
|
154 | |
155 |
|
156 |
|
157 | onClick: _propTypes.default.func,
|
158 |
|
159 | |
160 |
|
161 |
|
162 | selected: _propTypes.default.bool,
|
163 |
|
164 | |
165 |
|
166 |
|
167 |
|
168 |
|
169 | showLabel: _propTypes.default.bool,
|
170 |
|
171 | |
172 |
|
173 |
|
174 | value: _propTypes.default.any
|
175 | } : void 0;
|
176 |
|
177 | var _default = (0, _withStyles.default)(styles, {
|
178 | name: 'MuiBottomNavigationAction'
|
179 | })(BottomNavigationAction);
|
180 |
|
181 | exports.default = _default; |
\ | No newline at end of file |