1 | "use strict";
|
2 |
|
3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4 | Object.defineProperty(exports, "__esModule", {
|
5 | value: true
|
6 | });
|
7 | exports.default = void 0;
|
8 | var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
9 | var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
10 | var React = _interopRequireWildcard(require("react"));
|
11 | var _propTypes = _interopRequireDefault(require("prop-types"));
|
12 | var _utils = require("@mui/utils");
|
13 | var _composeClasses = _interopRequireDefault(require("../composeClasses"));
|
14 | var _tabClasses = require("./tabClasses");
|
15 | var _useTab = _interopRequireDefault(require("../useTab"));
|
16 | var _utils2 = require("../utils");
|
17 | var _ClassNameConfigurator = require("../utils/ClassNameConfigurator");
|
18 | var _jsxRuntime = require("react/jsx-runtime");
|
19 | const _excluded = ["action", "children", "value", "disabled", "onChange", "onClick", "onFocus", "slotProps", "slots"];
|
20 | function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
21 | function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
22 | const useUtilityClasses = ownerState => {
|
23 | const {
|
24 | selected,
|
25 | disabled
|
26 | } = ownerState;
|
27 | const slots = {
|
28 | root: ['root', selected && 'selected', disabled && 'disabled']
|
29 | };
|
30 | return (0, _composeClasses.default)(slots, (0, _ClassNameConfigurator.useClassNamesOverride)(_tabClasses.getTabUtilityClass));
|
31 | };
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 | const Tab = React.forwardRef(function Tab(props, forwardedRef) {
|
43 | var _slots$root;
|
44 | const {
|
45 | children,
|
46 | disabled = false,
|
47 | slotProps = {},
|
48 | slots = {}
|
49 | } = props,
|
50 | other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
51 | const tabRef = React.useRef();
|
52 | const handleRef = (0, _utils.unstable_useForkRef)(tabRef, forwardedRef);
|
53 | const {
|
54 | active,
|
55 | highlighted,
|
56 | selected,
|
57 | getRootProps
|
58 | } = (0, _useTab.default)((0, _extends2.default)({}, props, {
|
59 | rootRef: handleRef
|
60 | }));
|
61 | const ownerState = (0, _extends2.default)({}, props, {
|
62 | active,
|
63 | disabled,
|
64 | highlighted,
|
65 | selected
|
66 | });
|
67 | const classes = useUtilityClasses(ownerState);
|
68 | const TabRoot = (_slots$root = slots.root) != null ? _slots$root : 'button';
|
69 | const tabRootProps = (0, _utils2.useSlotProps)({
|
70 | elementType: TabRoot,
|
71 | getSlotProps: getRootProps,
|
72 | externalSlotProps: slotProps.root,
|
73 | externalForwardedProps: other,
|
74 | additionalProps: {
|
75 | ref: forwardedRef
|
76 | },
|
77 | ownerState,
|
78 | className: classes.root
|
79 | });
|
80 | return (0, _jsxRuntime.jsx)(TabRoot, (0, _extends2.default)({}, tabRootProps, {
|
81 | children: children
|
82 | }));
|
83 | });
|
84 | process.env.NODE_ENV !== "production" ? Tab.propTypes = {
|
85 |
|
86 |
|
87 |
|
88 |
|
89 | |
90 |
|
91 |
|
92 | action: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.shape({
|
93 | current: _propTypes.default.shape({
|
94 | focusVisible: _propTypes.default.func.isRequired
|
95 | })
|
96 | })]),
|
97 | |
98 |
|
99 |
|
100 | children: _propTypes.default.node,
|
101 | |
102 |
|
103 |
|
104 |
|
105 | disabled: _propTypes.default.bool,
|
106 | |
107 |
|
108 |
|
109 | onChange: _propTypes.default.func,
|
110 | |
111 |
|
112 |
|
113 |
|
114 | slotProps: _propTypes.default.shape({
|
115 | root: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object])
|
116 | }),
|
117 | |
118 |
|
119 |
|
120 |
|
121 |
|
122 | slots: _propTypes.default.shape({
|
123 | root: _propTypes.default.elementType
|
124 | }),
|
125 | |
126 |
|
127 |
|
128 | value: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string])
|
129 | } : void 0;
|
130 | var _default = Tab;
|
131 | exports.default = _default; |
\ | No newline at end of file |