1 | import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
2 | import _extends from "@babel/runtime/helpers/esm/extends";
|
3 | import * as React from 'react';
|
4 | import PropTypes from 'prop-types';
|
5 | import clsx from 'clsx';
|
6 | import withStyles from '../styles/withStyles';
|
7 | import ListItem from '../ListItem';
|
8 | export const styles = theme => ({
|
9 |
|
10 | root: _extends({}, theme.typography.body1, {
|
11 | minHeight: 48,
|
12 | paddingTop: 6,
|
13 | paddingBottom: 6,
|
14 | boxSizing: 'border-box',
|
15 | width: 'auto',
|
16 | overflow: 'hidden',
|
17 | whiteSpace: 'nowrap',
|
18 | [theme.breakpoints.up('sm')]: {
|
19 | minHeight: 'auto'
|
20 | }
|
21 | }),
|
22 |
|
23 |
|
24 |
|
25 | gutters: {},
|
26 |
|
27 |
|
28 | selected: {},
|
29 |
|
30 |
|
31 | dense: _extends({}, theme.typography.body2, {
|
32 | minHeight: 'auto'
|
33 | })
|
34 | });
|
35 | const MenuItem = React.forwardRef(function MenuItem(props, ref) {
|
36 | const {
|
37 | classes,
|
38 | className,
|
39 | component = 'li',
|
40 | disableGutters = false,
|
41 | ListItemClasses,
|
42 | role = 'menuitem',
|
43 | selected,
|
44 | tabIndex: tabIndexProp
|
45 | } = props,
|
46 | other = _objectWithoutPropertiesLoose(props, ["classes", "className", "component", "disableGutters", "ListItemClasses", "role", "selected", "tabIndex"]);
|
47 |
|
48 | let tabIndex;
|
49 |
|
50 | if (!props.disabled) {
|
51 | tabIndex = tabIndexProp !== undefined ? tabIndexProp : -1;
|
52 | }
|
53 |
|
54 | return React.createElement(ListItem, _extends({
|
55 | button: true,
|
56 | role: role,
|
57 | tabIndex: tabIndex,
|
58 | component: component,
|
59 | selected: selected,
|
60 | disableGutters: disableGutters,
|
61 | classes: _extends({
|
62 | dense: classes.dense
|
63 | }, ListItemClasses),
|
64 | className: clsx(classes.root, className, selected && classes.selected, !disableGutters && classes.gutters),
|
65 | ref: ref
|
66 | }, other));
|
67 | });
|
68 | process.env.NODE_ENV !== "production" ? MenuItem.propTypes = {
|
69 | |
70 |
|
71 |
|
72 | children: PropTypes.node,
|
73 |
|
74 | |
75 |
|
76 |
|
77 |
|
78 | classes: PropTypes.object.isRequired,
|
79 |
|
80 | |
81 |
|
82 |
|
83 | className: PropTypes.string,
|
84 |
|
85 | |
86 |
|
87 |
|
88 |
|
89 | component: PropTypes
|
90 |
|
91 | .elementType,
|
92 |
|
93 | |
94 |
|
95 |
|
96 | dense: PropTypes.bool,
|
97 |
|
98 | |
99 |
|
100 |
|
101 | disabled: PropTypes.bool,
|
102 |
|
103 | |
104 |
|
105 |
|
106 | disableGutters: PropTypes.bool,
|
107 |
|
108 | |
109 |
|
110 |
|
111 | ListItemClasses: PropTypes.object,
|
112 |
|
113 | |
114 |
|
115 |
|
116 | role: PropTypes.string,
|
117 |
|
118 | |
119 |
|
120 |
|
121 | selected: PropTypes.bool,
|
122 |
|
123 | |
124 |
|
125 |
|
126 | tabIndex: PropTypes.number
|
127 | } : void 0;
|
128 | export default withStyles(styles, {
|
129 | name: 'MuiMenuItem'
|
130 | })(MenuItem); |
\ | No newline at end of file |