Blame view

天文台pc/tianwentai-ui/node_modules/@mui/material/AppBar/AppBar.js 8.02 KB
bc518174   王天杨   提交两个项目文件
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
  "use strict";
  'use client';
  
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
  var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  exports.default = void 0;
  var React = _interopRequireWildcard(require("react"));
  var _propTypes = _interopRequireDefault(require("prop-types"));
  var _clsx = _interopRequireDefault(require("clsx"));
  var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
  var _zeroStyled = require("../zero-styled");
  var _memoTheme = _interopRequireDefault(require("../utils/memoTheme"));
  var _DefaultPropsProvider = require("../DefaultPropsProvider");
  var _capitalize = _interopRequireDefault(require("../utils/capitalize"));
  var _createSimplePaletteValueFilter = _interopRequireDefault(require("../utils/createSimplePaletteValueFilter"));
  var _Paper = _interopRequireDefault(require("../Paper"));
  var _appBarClasses = require("./appBarClasses");
  var _jsxRuntime = require("react/jsx-runtime");
  const useUtilityClasses = ownerState => {
    const {
      color,
      position,
      classes
    } = ownerState;
    const slots = {
      root: ['root', `color${(0, _capitalize.default)(color)}`, `position${(0, _capitalize.default)(position)}`]
    };
    return (0, _composeClasses.default)(slots, _appBarClasses.getAppBarUtilityClass, classes);
  };
  
  // var2 is the fallback.
  // Ex. var1: 'var(--a)', var2: 'var(--b)'; return: 'var(--a, var(--b))'
  const joinVars = (var1, var2) => var1 ? `${var1?.replace(')', '')}, ${var2})` : var2;
  const AppBarRoot = (0, _zeroStyled.styled)(_Paper.default, {
    name: 'MuiAppBar',
    slot: 'Root',
    overridesResolver: (props, styles) => {
      const {
        ownerState
      } = props;
      return [styles.root, styles[`position${(0, _capitalize.default)(ownerState.position)}`], styles[`color${(0, _capitalize.default)(ownerState.color)}`]];
    }
  })((0, _memoTheme.default)(({
    theme
  }) => ({
    display: 'flex',
    flexDirection: 'column',
    width: '100%',
    boxSizing: 'border-box',
    // Prevent padding issue with the Modal and fixed positioned AppBar.
    flexShrink: 0,
    variants: [{
      props: {
        position: 'fixed'
      },
      style: {
        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'
        }
      }
    }, {
      props: {
        position: 'absolute'
      },
      style: {
        position: 'absolute',
        zIndex: (theme.vars || theme).zIndex.appBar,
        top: 0,
        left: 'auto',
        right: 0
      }
    }, {
      props: {
        position: 'sticky'
      },
      style: {
        position: 'sticky',
        zIndex: (theme.vars || theme).zIndex.appBar,
        top: 0,
        left: 'auto',
        right: 0
      }
    }, {
      props: {
        position: 'static'
      },
      style: {
        position: 'static'
      }
    }, {
      props: {
        position: 'relative'
      },
      style: {
        position: 'relative'
      }
    }, {
      props: {
        color: 'inherit'
      },
      style: {
        '--AppBar-color': 'inherit'
      }
    }, {
      props: {
        color: 'default'
      },
      style: {
        '--AppBar-background': theme.vars ? theme.vars.palette.AppBar.defaultBg : theme.palette.grey[100],
        '--AppBar-color': theme.vars ? theme.vars.palette.text.primary : theme.palette.getContrastText(theme.palette.grey[100]),
        ...theme.applyStyles('dark', {
          '--AppBar-background': theme.vars ? theme.vars.palette.AppBar.defaultBg : theme.palette.grey[900],
          '--AppBar-color': theme.vars ? theme.vars.palette.text.primary : theme.palette.getContrastText(theme.palette.grey[900])
        })
      }
    }, ...Object.entries(theme.palette).filter((0, _createSimplePaletteValueFilter.default)(['contrastText'])).map(([color]) => ({
      props: {
        color
      },
      style: {
        '--AppBar-background': (theme.vars ?? theme).palette[color].main,
        '--AppBar-color': (theme.vars ?? theme).palette[color].contrastText
      }
    })), {
      props: props => props.enableColorOnDark === true && !['inherit', 'transparent'].includes(props.color),
      style: {
        backgroundColor: 'var(--AppBar-background)',
        color: 'var(--AppBar-color)'
      }
    }, {
      props: props => props.enableColorOnDark === false && !['inherit', 'transparent'].includes(props.color),
      style: {
        backgroundColor: 'var(--AppBar-background)',
        color: 'var(--AppBar-color)',
        ...theme.applyStyles('dark', {
          backgroundColor: theme.vars ? joinVars(theme.vars.palette.AppBar.darkBg, 'var(--AppBar-background)') : null,
          color: theme.vars ? joinVars(theme.vars.palette.AppBar.darkColor, 'var(--AppBar-color)') : null
        })
      }
    }, {
      props: {
        color: 'transparent'
      },
      style: {
        '--AppBar-background': 'transparent',
        '--AppBar-color': 'inherit',
        backgroundColor: 'var(--AppBar-background)',
        color: 'var(--AppBar-color)',
        ...theme.applyStyles('dark', {
          backgroundImage: 'none'
        })
      }
    }]
  })));
  const AppBar = /*#__PURE__*/React.forwardRef(function AppBar(inProps, ref) {
    const props = (0, _DefaultPropsProvider.useDefaultProps)({
      props: inProps,
      name: 'MuiAppBar'
    });
    const {
      className,
      color = 'primary',
      enableColorOnDark = false,
      position = 'fixed',
      ...other
    } = props;
    const ownerState = {
      ...props,
      color,
      position,
      enableColorOnDark
    };
    const classes = useUtilityClasses(ownerState);
    return /*#__PURE__*/(0, _jsxRuntime.jsx)(AppBarRoot, {
      square: true,
      component: "header",
      ownerState: ownerState,
      elevation: 4,
      className: (0, _clsx.default)(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.default.node,
    /**
     * Override or extend the styles applied to the component.
     */
    classes: _propTypes.default.object,
    /**
     * @ignore
     */
    className: _propTypes.default.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.default /* @typescript-to-proptypes-ignore */.oneOfType([_propTypes.default.oneOf(['default', 'inherit', 'primary', 'secondary', 'transparent', 'error', 'info', 'success', 'warning']), _propTypes.default.string]),
    /**
     * If true, the `color` prop is applied in dark mode.
     * @default false
     */
    enableColorOnDark: _propTypes.default.bool,
    /**
     * The positioning type. The behavior of the different options is described
     * [in the MDN web docs](https://developer.mozilla.org/en-US/docs/Web/CSS/position).
     * Note: `sticky` is not universally supported and will fall back to `static` when unavailable.
     * @default 'fixed'
     */
    position: _propTypes.default.oneOf(['absolute', 'fixed', 'relative', 'static', 'sticky']),
    /**
     * The system prop that allows defining system overrides as well as additional CSS styles.
     */
    sx: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object, _propTypes.default.bool])), _propTypes.default.func, _propTypes.default.object])
  } : void 0;
  var _default = exports.default = AppBar;