1 | 'use client';
|
2 |
|
3 | import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
4 | import _extends from "@babel/runtime/helpers/esm/extends";
|
5 | import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
6 | import composeClasses from '@mui/utils/composeClasses';
|
7 | import clsx from 'clsx';
|
8 | import PropTypes from 'prop-types';
|
9 | import * as React from 'react';
|
10 | import ButtonBase from '../ButtonBase';
|
11 | import ArrowDownwardIcon from '../internal/svg-icons/ArrowDownward';
|
12 | import styled from '../styles/styled';
|
13 | import { useDefaultProps } from '../DefaultPropsProvider';
|
14 | import capitalize from '../utils/capitalize';
|
15 | import tableSortLabelClasses, { getTableSortLabelUtilityClass } from './tableSortLabelClasses';
|
16 | import { jsx as _jsx } from "react/jsx-runtime";
|
17 | import { jsxs as _jsxs } from "react/jsx-runtime";
|
18 | var useUtilityClasses = function useUtilityClasses(ownerState) {
|
19 | var classes = ownerState.classes,
|
20 | direction = ownerState.direction,
|
21 | active = ownerState.active;
|
22 | var slots = {
|
23 | root: ['root', active && 'active'],
|
24 | icon: ['icon', "iconDirection".concat(capitalize(direction))]
|
25 | };
|
26 | return composeClasses(slots, getTableSortLabelUtilityClass, classes);
|
27 | };
|
28 | var TableSortLabelRoot = styled(ButtonBase, {
|
29 | name: 'MuiTableSortLabel',
|
30 | slot: 'Root',
|
31 | overridesResolver: function overridesResolver(props, styles) {
|
32 | var ownerState = props.ownerState;
|
33 | return [styles.root, ownerState.active && styles.active];
|
34 | }
|
35 | })(function (_ref) {
|
36 | var theme = _ref.theme;
|
37 | return _defineProperty({
|
38 | cursor: 'pointer',
|
39 | display: 'inline-flex',
|
40 | justifyContent: 'flex-start',
|
41 | flexDirection: 'inherit',
|
42 | alignItems: 'center',
|
43 | '&:focus': {
|
44 | color: (theme.vars || theme).palette.text.secondary
|
45 | },
|
46 | '&:hover': _defineProperty({
|
47 | color: (theme.vars || theme).palette.text.secondary
|
48 | }, "& .".concat(tableSortLabelClasses.icon), {
|
49 | opacity: 0.5
|
50 | })
|
51 | }, "&.".concat(tableSortLabelClasses.active), _defineProperty({
|
52 | color: (theme.vars || theme).palette.text.primary
|
53 | }, "& .".concat(tableSortLabelClasses.icon), {
|
54 | opacity: 1,
|
55 | color: (theme.vars || theme).palette.text.secondary
|
56 | }));
|
57 | });
|
58 | var TableSortLabelIcon = styled('span', {
|
59 | name: 'MuiTableSortLabel',
|
60 | slot: 'Icon',
|
61 | overridesResolver: function overridesResolver(props, styles) {
|
62 | var ownerState = props.ownerState;
|
63 | return [styles.icon, styles["iconDirection".concat(capitalize(ownerState.direction))]];
|
64 | }
|
65 | })(function (_ref3) {
|
66 | var theme = _ref3.theme,
|
67 | ownerState = _ref3.ownerState;
|
68 | return _extends({
|
69 | fontSize: 18,
|
70 | marginRight: 4,
|
71 | marginLeft: 4,
|
72 | opacity: 0,
|
73 | transition: theme.transitions.create(['opacity', 'transform'], {
|
74 | duration: theme.transitions.duration.shorter
|
75 | }),
|
76 | userSelect: 'none'
|
77 | }, ownerState.direction === 'desc' && {
|
78 | transform: 'rotate(0deg)'
|
79 | }, ownerState.direction === 'asc' && {
|
80 | transform: 'rotate(180deg)'
|
81 | });
|
82 | });
|
83 |
|
84 |
|
85 |
|
86 |
|
87 | var TableSortLabel = React.forwardRef(function TableSortLabel(inProps, ref) {
|
88 | var props = useDefaultProps({
|
89 | props: inProps,
|
90 | name: 'MuiTableSortLabel'
|
91 | });
|
92 | var _props$active = props.active,
|
93 | active = _props$active === void 0 ? false : _props$active,
|
94 | children = props.children,
|
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 ? ArrowDownwardIcon : _props$IconComponent,
|
102 | other = _objectWithoutProperties(props, ["active", "children", "className", "direction", "hideSortIcon", "IconComponent"]);
|
103 | var ownerState = _extends({}, props, {
|
104 | active: active,
|
105 | direction: direction,
|
106 | hideSortIcon: hideSortIcon,
|
107 | IconComponent: IconComponent
|
108 | });
|
109 | var classes = useUtilityClasses(ownerState);
|
110 | return _jsxs(TableSortLabelRoot, _extends({
|
111 | className: clsx(classes.root, className),
|
112 | component: "span",
|
113 | disableRipple: true,
|
114 | ownerState: ownerState,
|
115 | ref: ref
|
116 | }, other, {
|
117 | children: [children, hideSortIcon && !active ? null : _jsx(TableSortLabelIcon, {
|
118 | as: IconComponent,
|
119 | className: clsx(classes.icon),
|
120 | ownerState: ownerState
|
121 | })]
|
122 | }));
|
123 | });
|
124 | process.env.NODE_ENV !== "production" ? TableSortLabel.propTypes = {
|
125 |
|
126 |
|
127 |
|
128 |
|
129 | |
130 |
|
131 |
|
132 |
|
133 | active: PropTypes.bool,
|
134 | |
135 |
|
136 |
|
137 | children: PropTypes.node,
|
138 | |
139 |
|
140 |
|
141 | classes: PropTypes.object,
|
142 | |
143 |
|
144 |
|
145 | className: PropTypes.string,
|
146 | |
147 |
|
148 |
|
149 |
|
150 | direction: PropTypes.oneOf(['asc', 'desc']),
|
151 | |
152 |
|
153 |
|
154 |
|
155 | hideSortIcon: PropTypes.bool,
|
156 | |
157 |
|
158 |
|
159 |
|
160 | IconComponent: PropTypes.elementType,
|
161 | |
162 |
|
163 |
|
164 | sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
165 | } : void 0;
|
166 | export default TableSortLabel; |
\ | No newline at end of file |