43 lines
1.4 KiB
JavaScript
43 lines
1.4 KiB
JavaScript
'use client';
|
|
|
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
const _excluded = ["theme"];
|
|
import * as React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { ThemeProvider as SystemThemeProvider } from '@mui/system';
|
|
import THEME_ID from './identifier';
|
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
export default function ThemeProvider(_ref) {
|
|
let {
|
|
theme: themeInput
|
|
} = _ref,
|
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
const scopedTheme = themeInput[THEME_ID];
|
|
let finalTheme = scopedTheme || themeInput;
|
|
if (typeof themeInput !== 'function') {
|
|
if (scopedTheme && !scopedTheme.vars) {
|
|
finalTheme = _extends({}, scopedTheme, {
|
|
vars: null
|
|
});
|
|
} else if (themeInput && !themeInput.vars) {
|
|
finalTheme = _extends({}, themeInput, {
|
|
vars: null
|
|
});
|
|
}
|
|
}
|
|
return /*#__PURE__*/_jsx(SystemThemeProvider, _extends({}, props, {
|
|
themeId: scopedTheme ? THEME_ID : undefined,
|
|
theme: finalTheme
|
|
}));
|
|
}
|
|
process.env.NODE_ENV !== "production" ? ThemeProvider.propTypes = {
|
|
/**
|
|
* Your component tree.
|
|
*/
|
|
children: PropTypes.node,
|
|
/**
|
|
* A theme object. You can provide a function to extend the outer theme.
|
|
*/
|
|
theme: PropTypes.oneOfType([PropTypes.object, PropTypes.func]).isRequired
|
|
} : void 0; |