UNPKG

3.95 kBJavaScriptView Raw
1'use client';
2
3import * as React from 'react';
4import PropTypes from 'prop-types';
5import clsx from 'clsx';
6import composeClasses from '@mui/utils/composeClasses';
7import { styled } from "../zero-styled/index.js";
8import memoTheme from "../utils/memoTheme.js";
9import { useDefaultProps } from "../DefaultPropsProvider/index.js";
10import { getToolbarUtilityClass } from "./toolbarClasses.js";
11import { jsx as _jsx } from "react/jsx-runtime";
12const useUtilityClasses = ownerState => {
13 const {
14 classes,
15 disableGutters,
16 variant
17 } = ownerState;
18 const slots = {
19 root: ['root', !disableGutters && 'gutters', variant]
20 };
21 return composeClasses(slots, getToolbarUtilityClass, classes);
22};
23const ToolbarRoot = styled('div', {
24 name: 'MuiToolbar',
25 slot: 'Root',
26 overridesResolver: (props, styles) => {
27 const {
28 ownerState
29 } = props;
30 return [styles.root, !ownerState.disableGutters && styles.gutters, styles[ownerState.variant]];
31 }
32})(memoTheme(({
33 theme
34}) => ({
35 position: 'relative',
36 display: 'flex',
37 alignItems: 'center',
38 variants: [{
39 props: ({
40 ownerState
41 }) => !ownerState.disableGutters,
42 style: {
43 paddingLeft: theme.spacing(2),
44 paddingRight: theme.spacing(2),
45 [theme.breakpoints.up('sm')]: {
46 paddingLeft: theme.spacing(3),
47 paddingRight: theme.spacing(3)
48 }
49 }
50 }, {
51 props: {
52 variant: 'dense'
53 },
54 style: {
55 minHeight: 48
56 }
57 }, {
58 props: {
59 variant: 'regular'
60 },
61 style: theme.mixins.toolbar
62 }]
63})));
64const Toolbar = /*#__PURE__*/React.forwardRef(function Toolbar(inProps, ref) {
65 const props = useDefaultProps({
66 props: inProps,
67 name: 'MuiToolbar'
68 });
69 const {
70 className,
71 component = 'div',
72 disableGutters = false,
73 variant = 'regular',
74 ...other
75 } = props;
76 const ownerState = {
77 ...props,
78 component,
79 disableGutters,
80 variant
81 };
82 const classes = useUtilityClasses(ownerState);
83 return /*#__PURE__*/_jsx(ToolbarRoot, {
84 as: component,
85 className: clsx(classes.root, className),
86 ref: ref,
87 ownerState: ownerState,
88 ...other
89 });
90});
91process.env.NODE_ENV !== "production" ? Toolbar.propTypes /* remove-proptypes */ = {
92 // ┌────────────────────────────── Warning ──────────────────────────────┐
93 // │ These PropTypes are generated from the TypeScript type definitions. │
94 // │ To update them, edit the d.ts file and run `pnpm proptypes`. │
95 // └─────────────────────────────────────────────────────────────────────┘
96 /**
97 * The Toolbar children, usually a mixture of `IconButton`, `Button` and `Typography`.
98 * The Toolbar is a flex container, allowing flex item properties to be used to lay out the children.
99 */
100 children: PropTypes.node,
101 /**
102 * Override or extend the styles applied to the component.
103 */
104 classes: PropTypes.object,
105 /**
106 * @ignore
107 */
108 className: PropTypes.string,
109 /**
110 * The component used for the root node.
111 * Either a string to use a HTML element or a component.
112 */
113 component: PropTypes.elementType,
114 /**
115 * If `true`, disables gutter padding.
116 * @default false
117 */
118 disableGutters: PropTypes.bool,
119 /**
120 * The system prop that allows defining system overrides as well as additional CSS styles.
121 */
122 sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
123 /**
124 * The variant to use.
125 * @default 'regular'
126 */
127 variant: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['dense', 'regular']), PropTypes.string])
128} : void 0;
129export default Toolbar;
\No newline at end of file