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