1 | import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
2 | import _extends from "@babel/runtime/helpers/esm/extends";
|
3 |
|
4 | var _KeyboardArrowLeft, _KeyboardArrowRight;
|
5 |
|
6 | const _excluded = ["className", "direction", "orientation", "disabled"];
|
7 |
|
8 |
|
9 | import * as React from 'react';
|
10 | import PropTypes from 'prop-types';
|
11 | import clsx from 'clsx';
|
12 | import { unstable_composeClasses as composeClasses } from '@mui/base';
|
13 | import KeyboardArrowLeft from '../internal/svg-icons/KeyboardArrowLeft';
|
14 | import KeyboardArrowRight from '../internal/svg-icons/KeyboardArrowRight';
|
15 | import ButtonBase from '../ButtonBase';
|
16 | import useTheme from '../styles/useTheme';
|
17 | import useThemeProps from '../styles/useThemeProps';
|
18 | import styled from '../styles/styled';
|
19 | import tabScrollButtonClasses, { getTabScrollButtonUtilityClass } from './tabScrollButtonClasses';
|
20 | import { jsx as _jsx } from "react/jsx-runtime";
|
21 |
|
22 | const useUtilityClasses = ownerState => {
|
23 | const {
|
24 | classes,
|
25 | orientation,
|
26 | disabled
|
27 | } = ownerState;
|
28 | const slots = {
|
29 | root: ['root', orientation, disabled && 'disabled']
|
30 | };
|
31 | return composeClasses(slots, getTabScrollButtonUtilityClass, classes);
|
32 | };
|
33 |
|
34 | const TabScrollButtonRoot = styled(ButtonBase, {
|
35 | name: 'MuiTabScrollButton',
|
36 | slot: 'Root',
|
37 | overridesResolver: (props, styles) => {
|
38 | const {
|
39 | ownerState
|
40 | } = props;
|
41 | return [styles.root, ownerState.orientation && styles[ownerState.orientation]];
|
42 | }
|
43 | })(({
|
44 | ownerState
|
45 | }) => _extends({
|
46 | width: 40,
|
47 | flexShrink: 0,
|
48 | opacity: 0.8,
|
49 | [`&.${tabScrollButtonClasses.disabled}`]: {
|
50 | opacity: 0
|
51 | }
|
52 | }, ownerState.orientation === 'vertical' && {
|
53 | width: '100%',
|
54 | height: 40,
|
55 | '& svg': {
|
56 | transform: `rotate(${ownerState.isRtl ? -90 : 90}deg)`
|
57 | }
|
58 | }));
|
59 | const TabScrollButton = React.forwardRef(function TabScrollButton(inProps, ref) {
|
60 | const props = useThemeProps({
|
61 | props: inProps,
|
62 | name: 'MuiTabScrollButton'
|
63 | });
|
64 |
|
65 | const {
|
66 | className,
|
67 | direction
|
68 | } = props,
|
69 | other = _objectWithoutPropertiesLoose(props, _excluded);
|
70 |
|
71 | const theme = useTheme();
|
72 | const isRtl = theme.direction === 'rtl';
|
73 |
|
74 | const ownerState = _extends({
|
75 | isRtl
|
76 | }, props);
|
77 |
|
78 | const classes = useUtilityClasses(ownerState);
|
79 | return _jsx(TabScrollButtonRoot, _extends({
|
80 | component: "div",
|
81 | className: clsx(classes.root, className),
|
82 | ref: ref,
|
83 | role: null,
|
84 | ownerState: ownerState,
|
85 | tabIndex: null
|
86 | }, other, {
|
87 | children: direction === 'left' ? _KeyboardArrowLeft || (_KeyboardArrowLeft = _jsx(KeyboardArrowLeft, {
|
88 | fontSize: "small"
|
89 | })) : _KeyboardArrowRight || (_KeyboardArrowRight = _jsx(KeyboardArrowRight, {
|
90 | fontSize: "small"
|
91 | }))
|
92 | }));
|
93 | });
|
94 | process.env.NODE_ENV !== "production" ? TabScrollButton.propTypes
|
95 |
|
96 | = {
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 | |
103 |
|
104 |
|
105 | children: PropTypes.node,
|
106 |
|
107 | |
108 |
|
109 |
|
110 | classes: PropTypes.object,
|
111 |
|
112 | |
113 |
|
114 |
|
115 | className: PropTypes.string,
|
116 |
|
117 | |
118 |
|
119 |
|
120 | direction: PropTypes.oneOf(['left', 'right']).isRequired,
|
121 |
|
122 | |
123 |
|
124 |
|
125 | disabled: PropTypes.bool,
|
126 |
|
127 | |
128 |
|
129 |
|
130 | orientation: PropTypes.oneOf(['horizontal', 'vertical']).isRequired,
|
131 |
|
132 | |
133 |
|
134 |
|
135 | sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
136 | } : void 0;
|
137 | export default TabScrollButton; |
\ | No newline at end of file |