UNPKG

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