UNPKG

3.03 kBJavaScriptView Raw
1import _extends from "@babel/runtime/helpers/esm/extends";
2import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3import * as React from 'react';
4import PropTypes from 'prop-types';
5import clsx from 'clsx';
6import { unstable_composeClasses as composeClasses } from '@mui/base';
7import Tablelvl2Context from '../Table/Tablelvl2Context';
8import useThemeProps from '../styles/useThemeProps';
9import styled from '../styles/styled';
10import { getTableHeadUtilityClass } from './tableHeadClasses';
11import { jsx as _jsx } from "react/jsx-runtime";
12
13var useUtilityClasses = function useUtilityClasses(ownerState) {
14 var classes = ownerState.classes;
15 var slots = {
16 root: ['root']
17 };
18 return composeClasses(slots, getTableHeadUtilityClass, classes);
19};
20
21var TableHeadRoot = styled('thead', {
22 name: 'MuiTableHead',
23 slot: 'Root',
24 overridesResolver: function overridesResolver(props, styles) {
25 return styles.root;
26 }
27})({
28 display: 'table-header-group'
29});
30var tablelvl2 = {
31 variant: 'head'
32};
33var defaultComponent = 'thead';
34var TableHead = /*#__PURE__*/React.forwardRef(function TableHead(inProps, ref) {
35 var props = useThemeProps({
36 props: inProps,
37 name: 'MuiTableHead'
38 });
39
40 var className = props.className,
41 _props$component = props.component,
42 component = _props$component === void 0 ? defaultComponent : _props$component,
43 other = _objectWithoutProperties(props, ["className", "component"]);
44
45 var ownerState = _extends({}, props, {
46 component: component
47 });
48
49 var classes = useUtilityClasses(ownerState);
50 return /*#__PURE__*/_jsx(Tablelvl2Context.Provider, {
51 value: tablelvl2,
52 children: /*#__PURE__*/_jsx(TableHeadRoot, _extends({
53 as: component,
54 className: clsx(classes.root, className),
55 ref: ref,
56 role: component === defaultComponent ? null : 'rowgroup',
57 ownerState: ownerState
58 }, other))
59 });
60});
61process.env.NODE_ENV !== "production" ? TableHead.propTypes
62/* remove-proptypes */
63= {
64 // ----------------------------- Warning --------------------------------
65 // | These PropTypes are generated from the TypeScript type definitions |
66 // | To update them edit the d.ts file and run "yarn proptypes" |
67 // ----------------------------------------------------------------------
68
69 /**
70 * The content of the component, normally `TableRow`.
71 */
72 children: PropTypes.node,
73
74 /**
75 * Override or extend the styles applied to the component.
76 */
77 classes: PropTypes.object,
78
79 /**
80 * @ignore
81 */
82 className: PropTypes.string,
83
84 /**
85 * The component used for the root node.
86 * Either a string to use a HTML element or a component.
87 */
88 component: PropTypes.elementType,
89
90 /**
91 * The system prop that allows defining system overrides as well as additional CSS styles.
92 */
93 sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
94} : void 0;
95export default TableHead;
\No newline at end of file