Spaces:
Sleeping
Sleeping
File size: 7,543 Bytes
56fda74 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
'use client';
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
import _extends from "@babel/runtime/helpers/esm/extends";
const _excluded = ["className", "color", "enableColorOnDark", "position"];
import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import composeClasses from '@mui/utils/composeClasses';
import styled from '../styles/styled';
import { useDefaultProps } from '../DefaultPropsProvider';
import capitalize from '../utils/capitalize';
import Paper from '../Paper';
import { getAppBarUtilityClass } from './appBarClasses';
import { jsx as _jsx } from "react/jsx-runtime";
const useUtilityClasses = ownerState => {
const {
color,
position,
classes
} = ownerState;
const slots = {
root: ['root', `color${capitalize(color)}`, `position${capitalize(position)}`]
};
return composeClasses(slots, getAppBarUtilityClass, classes);
};
// var2 is the fallback.
// Ex. var1: 'var(--a)', var2: 'var(--b)'; return: 'var(--a, var(--b))'
const joinVars = (var1, var2) => var1 ? `${var1 == null ? void 0 : var1.replace(')', '')}, ${var2})` : var2;
const AppBarRoot = styled(Paper, {
name: 'MuiAppBar',
slot: 'Root',
overridesResolver: (props, styles) => {
const {
ownerState
} = props;
return [styles.root, styles[`position${capitalize(ownerState.position)}`], styles[`color${capitalize(ownerState.color)}`]];
}
})(({
theme,
ownerState
}) => {
const backgroundColorDefault = theme.palette.mode === 'light' ? theme.palette.grey[100] : theme.palette.grey[900];
return _extends({
display: 'flex',
flexDirection: 'column',
width: '100%',
boxSizing: 'border-box',
// Prevent padding issue with the Modal and fixed positioned AppBar.
flexShrink: 0
}, ownerState.position === 'fixed' && {
position: 'fixed',
zIndex: (theme.vars || theme).zIndex.appBar,
top: 0,
left: 'auto',
right: 0,
'@media print': {
// Prevent the app bar to be visible on each printed page.
position: 'absolute'
}
}, ownerState.position === 'absolute' && {
position: 'absolute',
zIndex: (theme.vars || theme).zIndex.appBar,
top: 0,
left: 'auto',
right: 0
}, ownerState.position === 'sticky' && {
// β οΈ sticky is not supported by IE11.
position: 'sticky',
zIndex: (theme.vars || theme).zIndex.appBar,
top: 0,
left: 'auto',
right: 0
}, ownerState.position === 'static' && {
position: 'static'
}, ownerState.position === 'relative' && {
position: 'relative'
}, !theme.vars && _extends({}, ownerState.color === 'default' && {
backgroundColor: backgroundColorDefault,
color: theme.palette.getContrastText(backgroundColorDefault)
}, ownerState.color && ownerState.color !== 'default' && ownerState.color !== 'inherit' && ownerState.color !== 'transparent' && {
backgroundColor: theme.palette[ownerState.color].main,
color: theme.palette[ownerState.color].contrastText
}, ownerState.color === 'inherit' && {
color: 'inherit'
}, theme.palette.mode === 'dark' && !ownerState.enableColorOnDark && {
backgroundColor: null,
color: null
}, ownerState.color === 'transparent' && _extends({
backgroundColor: 'transparent',
color: 'inherit'
}, theme.palette.mode === 'dark' && {
backgroundImage: 'none'
})), theme.vars && _extends({}, ownerState.color === 'default' && {
'--AppBar-background': ownerState.enableColorOnDark ? theme.vars.palette.AppBar.defaultBg : joinVars(theme.vars.palette.AppBar.darkBg, theme.vars.palette.AppBar.defaultBg),
'--AppBar-color': ownerState.enableColorOnDark ? theme.vars.palette.text.primary : joinVars(theme.vars.palette.AppBar.darkColor, theme.vars.palette.text.primary)
}, ownerState.color && !ownerState.color.match(/^(default|inherit|transparent)$/) && {
'--AppBar-background': ownerState.enableColorOnDark ? theme.vars.palette[ownerState.color].main : joinVars(theme.vars.palette.AppBar.darkBg, theme.vars.palette[ownerState.color].main),
'--AppBar-color': ownerState.enableColorOnDark ? theme.vars.palette[ownerState.color].contrastText : joinVars(theme.vars.palette.AppBar.darkColor, theme.vars.palette[ownerState.color].contrastText)
}, !['inherit', 'transparent'].includes(ownerState.color) && {
backgroundColor: 'var(--AppBar-background)'
}, {
color: ownerState.color === 'inherit' ? 'inherit' : 'var(--AppBar-color)'
}, ownerState.color === 'transparent' && {
backgroundImage: 'none',
backgroundColor: 'transparent',
color: 'inherit'
}));
});
const AppBar = /*#__PURE__*/React.forwardRef(function AppBar(inProps, ref) {
const props = useDefaultProps({
props: inProps,
name: 'MuiAppBar'
});
const {
className,
color = 'primary',
enableColorOnDark = false,
position = 'fixed'
} = props,
other = _objectWithoutPropertiesLoose(props, _excluded);
const ownerState = _extends({}, props, {
color,
position,
enableColorOnDark
});
const classes = useUtilityClasses(ownerState);
return /*#__PURE__*/_jsx(AppBarRoot, _extends({
square: true,
component: "header",
ownerState: ownerState,
elevation: 4,
className: clsx(classes.root, className, position === 'fixed' && 'mui-fixed'),
ref: ref
}, other));
});
process.env.NODE_ENV !== "production" ? AppBar.propTypes /* remove-proptypes */ = {
// βββββββββββββββββββββββββββββββ Warning βββββββββββββββββββββββββββββββ
// β These PropTypes are generated from the TypeScript type definitions. β
// β To update them, edit the d.ts file and run `pnpm proptypes`. β
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
/**
* The content of the component.
*/
children: PropTypes.node,
/**
* Override or extend the styles applied to the component.
*/
classes: PropTypes.object,
/**
* @ignore
*/
className: PropTypes.string,
/**
* The color of the component.
* It supports both default and custom theme colors, which can be added as shown in the
* [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
* @default 'primary'
*/
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['default', 'inherit', 'primary', 'secondary', 'transparent', 'error', 'info', 'success', 'warning']), PropTypes.string]),
/**
* If true, the `color` prop is applied in dark mode.
* @default false
*/
enableColorOnDark: PropTypes.bool,
/**
* The positioning type. The behavior of the different options is described
* [in the MDN web docs](https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Positioning).
* Note: `sticky` is not universally supported and will fall back to `static` when unavailable.
* @default 'fixed'
*/
position: PropTypes.oneOf(['absolute', 'fixed', 'relative', 'static', 'sticky']),
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
} : void 0;
export default AppBar; |