1 | "use strict";
|
2 |
|
3 | var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
4 |
|
5 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
6 |
|
7 | Object.defineProperty(exports, "__esModule", {
|
8 | value: true
|
9 | });
|
10 | exports.default = exports.styles = void 0;
|
11 |
|
12 | var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
13 |
|
14 | var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
15 |
|
16 | var React = _interopRequireWildcard(require("react"));
|
17 |
|
18 | var _propTypes = _interopRequireDefault(require("prop-types"));
|
19 |
|
20 | var _clsx = _interopRequireDefault(require("clsx"));
|
21 |
|
22 | var _ArrowDownward = _interopRequireDefault(require("../internal/svg-icons/ArrowDownward"));
|
23 |
|
24 | var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
|
25 |
|
26 | var _ButtonBase = _interopRequireDefault(require("../ButtonBase"));
|
27 |
|
28 | var _capitalize = _interopRequireDefault(require("../utils/capitalize"));
|
29 |
|
30 | var styles = function styles(theme) {
|
31 | return {
|
32 |
|
33 | root: {
|
34 | cursor: 'pointer',
|
35 | display: 'inline-flex',
|
36 | justifyContent: 'flex-start',
|
37 | flexDirection: 'inherit',
|
38 | alignItems: 'center',
|
39 | '&:focus': {
|
40 | color: theme.palette.text.secondary
|
41 | },
|
42 | '&:hover': {
|
43 | color: theme.palette.text.secondary,
|
44 | '& $icon': {
|
45 | opacity: 0.5
|
46 | }
|
47 | },
|
48 | '&$active': {
|
49 | color: theme.palette.text.primary,
|
50 |
|
51 | '&& $icon': {
|
52 | opacity: 1,
|
53 | color: theme.palette.text.secondary
|
54 | }
|
55 | }
|
56 | },
|
57 |
|
58 |
|
59 | active: {},
|
60 |
|
61 |
|
62 | icon: {
|
63 | fontSize: 18,
|
64 | marginRight: 4,
|
65 | marginLeft: 4,
|
66 | opacity: 0,
|
67 | transition: theme.transitions.create(['opacity', 'transform'], {
|
68 | duration: theme.transitions.duration.shorter
|
69 | }),
|
70 | userSelect: 'none'
|
71 | },
|
72 |
|
73 |
|
74 | iconDirectionDesc: {
|
75 | transform: 'rotate(0deg)'
|
76 | },
|
77 |
|
78 |
|
79 | iconDirectionAsc: {
|
80 | transform: 'rotate(180deg)'
|
81 | }
|
82 | };
|
83 | };
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 | exports.styles = styles;
|
90 | var TableSortLabel = React.forwardRef(function TableSortLabel(props, ref) {
|
91 | var _props$active = props.active,
|
92 | active = _props$active === void 0 ? false : _props$active,
|
93 | children = props.children,
|
94 | classes = props.classes,
|
95 | className = props.className,
|
96 | _props$direction = props.direction,
|
97 | direction = _props$direction === void 0 ? 'asc' : _props$direction,
|
98 | _props$hideSortIcon = props.hideSortIcon,
|
99 | hideSortIcon = _props$hideSortIcon === void 0 ? false : _props$hideSortIcon,
|
100 | _props$IconComponent = props.IconComponent,
|
101 | IconComponent = _props$IconComponent === void 0 ? _ArrowDownward.default : _props$IconComponent,
|
102 | other = (0, _objectWithoutProperties2.default)(props, ["active", "children", "classes", "className", "direction", "hideSortIcon", "IconComponent"]);
|
103 | return React.createElement(_ButtonBase.default, (0, _extends2.default)({
|
104 | className: (0, _clsx.default)(classes.root, className, active && classes.active),
|
105 | component: "span",
|
106 | disableRipple: true,
|
107 | ref: ref
|
108 | }, other), children, hideSortIcon && !active ? null : React.createElement(IconComponent, {
|
109 | className: (0, _clsx.default)(classes.icon, classes["iconDirection".concat((0, _capitalize.default)(direction))])
|
110 | }));
|
111 | });
|
112 | process.env.NODE_ENV !== "production" ? TableSortLabel.propTypes = {
|
113 | |
114 |
|
115 |
|
116 | active: _propTypes.default.bool,
|
117 |
|
118 | |
119 |
|
120 |
|
121 | children: _propTypes.default.node,
|
122 |
|
123 | |
124 |
|
125 |
|
126 |
|
127 | classes: _propTypes.default.object.isRequired,
|
128 |
|
129 | |
130 |
|
131 |
|
132 | className: _propTypes.default.string,
|
133 |
|
134 | |
135 |
|
136 |
|
137 | direction: _propTypes.default.oneOf(['asc', 'desc']),
|
138 |
|
139 | |
140 |
|
141 |
|
142 | hideSortIcon: _propTypes.default.bool,
|
143 |
|
144 | |
145 |
|
146 |
|
147 | IconComponent: _propTypes.default.elementType
|
148 | } : void 0;
|
149 |
|
150 | var _default = (0, _withStyles.default)(styles, {
|
151 | name: 'MuiTableSortLabel'
|
152 | })(TableSortLabel);
|
153 |
|
154 | exports.default = _default; |
\ | No newline at end of file |