UNPKG

2.9 kBJavaScriptView Raw
1import _extends from "@babel/runtime/helpers/esm/extends";
2import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
4/* eslint-disable jsx-a11y/aria-role */
5import * as React from 'react';
6import PropTypes from 'prop-types';
7import clsx from 'clsx';
8import KeyboardArrowLeft from '../internal/svg-icons/KeyboardArrowLeft';
9import KeyboardArrowRight from '../internal/svg-icons/KeyboardArrowRight';
10import withStyles from '../styles/withStyles';
11import ButtonBase from '../ButtonBase';
12export const styles = {
13 /* Styles applied to the root element. */
14 root: {
15 width: 40,
16 flexShrink: 0,
17 opacity: 0.8,
18 '&$disabled': {
19 opacity: 0
20 }
21 },
22
23 /* Styles applied to the root element if `orientation="vertical"`. */
24 vertical: {
25 width: '100%',
26 height: 40,
27 '& svg': {
28 transform: 'rotate(90deg)'
29 }
30 },
31
32 /* Pseudo-class applied to the root element if `disabled={true}`. */
33 disabled: {}
34};
35
36var _ref = /*#__PURE__*/React.createElement(KeyboardArrowLeft, {
37 fontSize: "small"
38});
39
40var _ref2 = /*#__PURE__*/React.createElement(KeyboardArrowRight, {
41 fontSize: "small"
42});
43
44const TabScrollButton = /*#__PURE__*/React.forwardRef(function TabScrollButton(props, ref) {
45 const {
46 classes,
47 className: classNameProp,
48 direction,
49 orientation,
50 disabled
51 } = props,
52 other = _objectWithoutPropertiesLoose(props, ["classes", "className", "direction", "orientation", "disabled"]);
53
54 return /*#__PURE__*/React.createElement(ButtonBase, _extends({
55 component: "div",
56 className: clsx(classes.root, classNameProp, disabled && classes.disabled, orientation === 'vertical' && classes.vertical),
57 ref: ref,
58 role: null,
59 tabIndex: null
60 }, other), direction === 'left' ? _ref : _ref2);
61});
62process.env.NODE_ENV !== "production" ? TabScrollButton.propTypes = {
63 // ----------------------------- Warning --------------------------------
64 // | These PropTypes are generated from the TypeScript type definitions |
65 // | To update them edit the d.ts file and run "yarn proptypes" |
66 // ----------------------------------------------------------------------
67
68 /**
69 * The content of the component.
70 */
71 children: PropTypes.node,
72
73 /**
74 * Override or extend the styles applied to the component.
75 * See [CSS API](#css) below for more details.
76 */
77 classes: PropTypes.object,
78
79 /**
80 * @ignore
81 */
82 className: PropTypes.string,
83
84 /**
85 * Which direction should the button indicate?
86 */
87 direction: PropTypes.oneOf(['left', 'right']).isRequired,
88
89 /**
90 * If `true`, the element will be disabled.
91 */
92 disabled: PropTypes.bool,
93
94 /**
95 * The tabs orientation (layout flow direction).
96 */
97 orientation: PropTypes.oneOf(['horizontal', 'vertical']).isRequired
98} : void 0;
99export default withStyles(styles, {
100 name: 'MuiTabScrollButton'
101})(TabScrollButton);
\No newline at end of file