1 | 'use client';
|
2 |
|
3 | import * as React from 'react';
|
4 | import PropTypes from 'prop-types';
|
5 | import clsx from 'clsx';
|
6 | import composeClasses from '@mui/utils/composeClasses';
|
7 | import { alpha } from '@mui/system/colorManipulator';
|
8 | import Tablelvl2Context from "../Table/Tablelvl2Context.js";
|
9 | import { styled } from "../zero-styled/index.js";
|
10 | import memoTheme from "../utils/memoTheme.js";
|
11 | import { useDefaultProps } from "../DefaultPropsProvider/index.js";
|
12 | import tableRowClasses, { getTableRowUtilityClass } from "./tableRowClasses.js";
|
13 | import { jsx as _jsx } from "react/jsx-runtime";
|
14 | const useUtilityClasses = ownerState => {
|
15 | const {
|
16 | classes,
|
17 | selected,
|
18 | hover,
|
19 | head,
|
20 | footer
|
21 | } = ownerState;
|
22 | const slots = {
|
23 | root: ['root', selected && 'selected', hover && 'hover', head && 'head', footer && 'footer']
|
24 | };
|
25 | return composeClasses(slots, getTableRowUtilityClass, classes);
|
26 | };
|
27 | const TableRowRoot = styled('tr', {
|
28 | name: 'MuiTableRow',
|
29 | slot: 'Root',
|
30 | overridesResolver: (props, styles) => {
|
31 | const {
|
32 | ownerState
|
33 | } = props;
|
34 | return [styles.root, ownerState.head && styles.head, ownerState.footer && styles.footer];
|
35 | }
|
36 | })(memoTheme(({
|
37 | theme
|
38 | }) => ({
|
39 | color: 'inherit',
|
40 | display: 'table-row',
|
41 | verticalAlign: 'middle',
|
42 |
|
43 | outline: 0,
|
44 | [`&.${tableRowClasses.hover}:hover`]: {
|
45 | backgroundColor: (theme.vars || theme).palette.action.hover
|
46 | },
|
47 | [`&.${tableRowClasses.selected}`]: {
|
48 | backgroundColor: theme.vars ? `rgba(${theme.vars.palette.primary.mainChannel} / ${theme.vars.palette.action.selectedOpacity})` : alpha(theme.palette.primary.main, theme.palette.action.selectedOpacity),
|
49 | '&:hover': {
|
50 | backgroundColor: theme.vars ? `rgba(${theme.vars.palette.primary.mainChannel} / calc(${theme.vars.palette.action.selectedOpacity} + ${theme.vars.palette.action.hoverOpacity}))` : alpha(theme.palette.primary.main, theme.palette.action.selectedOpacity + theme.palette.action.hoverOpacity)
|
51 | }
|
52 | }
|
53 | })));
|
54 | const defaultComponent = 'tr';
|
55 |
|
56 |
|
57 |
|
58 |
|
59 | const TableRow = React.forwardRef(function TableRow(inProps, ref) {
|
60 | const props = useDefaultProps({
|
61 | props: inProps,
|
62 | name: 'MuiTableRow'
|
63 | });
|
64 | const {
|
65 | className,
|
66 | component = defaultComponent,
|
67 | hover = false,
|
68 | selected = false,
|
69 | ...other
|
70 | } = props;
|
71 | const tablelvl2 = React.useContext(Tablelvl2Context);
|
72 | const ownerState = {
|
73 | ...props,
|
74 | component,
|
75 | hover,
|
76 | selected,
|
77 | head: tablelvl2 && tablelvl2.variant === 'head',
|
78 | footer: tablelvl2 && tablelvl2.variant === 'footer'
|
79 | };
|
80 | const classes = useUtilityClasses(ownerState);
|
81 | return _jsx(TableRowRoot, {
|
82 | as: component,
|
83 | ref: ref,
|
84 | className: clsx(classes.root, className),
|
85 | role: component === defaultComponent ? null : 'row',
|
86 | ownerState: ownerState,
|
87 | ...other
|
88 | });
|
89 | });
|
90 | process.env.NODE_ENV !== "production" ? TableRow.propTypes = {
|
91 |
|
92 |
|
93 |
|
94 |
|
95 | |
96 |
|
97 |
|
98 | children: PropTypes.node,
|
99 | |
100 |
|
101 |
|
102 | classes: PropTypes.object,
|
103 | |
104 |
|
105 |
|
106 | className: PropTypes.string,
|
107 | |
108 |
|
109 |
|
110 |
|
111 | component: PropTypes.elementType,
|
112 | |
113 |
|
114 |
|
115 |
|
116 | hover: PropTypes.bool,
|
117 | |
118 |
|
119 |
|
120 |
|
121 | selected: PropTypes.bool,
|
122 | |
123 |
|
124 |
|
125 | sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
126 | } : void 0;
|
127 | export default TableRow; |
\ | No newline at end of file |