1 | import _extends from "@babel/runtime/helpers/esm/extends";
|
2 | import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
3 | import * as React from 'react';
|
4 | import PropTypes from 'prop-types';
|
5 | import { getMenuItemUtilityClass } from './menuItemClasses';
|
6 | import useMenuItem from '../useMenuItem';
|
7 | import composeClasses from '../composeClasses';
|
8 | import useSlotProps from '../utils/useSlotProps';
|
9 | import { useClassNamesOverride } from '../utils/ClassNameConfigurator';
|
10 | import { jsx as _jsx } from "react/jsx-runtime";
|
11 | function useUtilityClasses(ownerState) {
|
12 | var disabled = ownerState.disabled,
|
13 | focusVisible = ownerState.focusVisible;
|
14 | var slots = {
|
15 | root: ['root', disabled && 'disabled', focusVisible && 'focusVisible']
|
16 | };
|
17 | return composeClasses(slots, useClassNamesOverride(getMenuItemUtilityClass));
|
18 | }
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 | var MenuItem = React.forwardRef(function MenuItem(props, forwardedRef) {
|
31 | var _slots$root;
|
32 | var children = props.children,
|
33 | _props$disabled = props.disabled,
|
34 | disabledProp = _props$disabled === void 0 ? false : _props$disabled,
|
35 | label = props.label,
|
36 | _props$slotProps = props.slotProps,
|
37 | slotProps = _props$slotProps === void 0 ? {} : _props$slotProps,
|
38 | _props$slots = props.slots,
|
39 | slots = _props$slots === void 0 ? {} : _props$slots,
|
40 | other = _objectWithoutProperties(props, ["children", "disabled", "label", "slotProps", "slots"]);
|
41 | var _useMenuItem = useMenuItem({
|
42 | disabled: disabledProp,
|
43 | rootRef: forwardedRef,
|
44 | label: label
|
45 | }),
|
46 | getRootProps = _useMenuItem.getRootProps,
|
47 | disabled = _useMenuItem.disabled,
|
48 | focusVisible = _useMenuItem.focusVisible,
|
49 | highlighted = _useMenuItem.highlighted;
|
50 | var ownerState = _extends({}, props, {
|
51 | disabled: disabled,
|
52 | focusVisible: focusVisible,
|
53 | highlighted: highlighted
|
54 | });
|
55 | var classes = useUtilityClasses(ownerState);
|
56 | var Root = (_slots$root = slots.root) != null ? _slots$root : 'li';
|
57 | var rootProps = useSlotProps({
|
58 | elementType: Root,
|
59 | getSlotProps: getRootProps,
|
60 | externalSlotProps: slotProps.root,
|
61 | externalForwardedProps: other,
|
62 | className: classes.root,
|
63 | ownerState: ownerState
|
64 | });
|
65 | return _jsx(Root, _extends({}, rootProps, {
|
66 | children: children
|
67 | }));
|
68 | });
|
69 | process.env.NODE_ENV !== "production" ? MenuItem.propTypes = {
|
70 |
|
71 |
|
72 |
|
73 |
|
74 | |
75 |
|
76 |
|
77 | children: PropTypes.node,
|
78 | |
79 |
|
80 |
|
81 | disabled: PropTypes.bool,
|
82 | |
83 |
|
84 |
|
85 |
|
86 | label: PropTypes.string,
|
87 | |
88 |
|
89 |
|
90 |
|
91 | slotProps: PropTypes.shape({
|
92 | root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
93 | }),
|
94 | |
95 |
|
96 |
|
97 |
|
98 |
|
99 | slots: PropTypes.shape({
|
100 | root: PropTypes.elementType
|
101 | })
|
102 | } : void 0;
|
103 | export default MenuItem; |
\ | No newline at end of file |