UNPKG

seti-ramesesv1

Version:

Reusable components and context for Next.js apps

96 lines (91 loc) 4.41 kB
import createMixins from './createMixins.js'; import createPalette from './createPalette.js'; import createTypography from './createTypography.js'; import shadows from './shadows.js'; import createTransitions from './createTransitions.js'; import zIndex from './zIndex.js'; import { stringifyTheme } from './stringifyTheme.js'; import formatMuiErrorMessage from '../../../utils/esm/formatMuiErrorMessage/formatMuiErrorMessage.js'; import createTheme from '../../../system/esm/createTheme/createTheme.js'; import deepmerge from '../../../utils/esm/deepmerge/deepmerge.js'; import defaultSxConfig from '../../../system/esm/styleFunctionSx/defaultSxConfig.js'; import styleFunctionSx from '../../../system/esm/styleFunctionSx/styleFunctionSx.js'; import generateUtilityClass from '../../../utils/esm/generateUtilityClass/generateUtilityClass.js'; function createThemeNoVars(options = {}, ...args) { const { breakpoints: breakpointsInput, mixins: mixinsInput = {}, spacing: spacingInput, palette: paletteInput = {}, transitions: transitionsInput = {}, typography: typographyInput = {}, shape: shapeInput, ...other } = options; if (options.vars && // The error should throw only for the root theme creation because user is not allowed to use a custom node `vars`. // `generateThemeVars` is the closest identifier for checking that the `options` is a result of `createTheme` with CSS variables so that user can create new theme for nested ThemeProvider. options.generateThemeVars === undefined) { throw new Error(process.env.NODE_ENV !== "production" ? 'MUI: `vars` is a private field used for CSS variables support.\n' + // #host-reference 'Please use another name or follow the [docs](https://mui.com/material-ui/customization/css-theme-variables/usage/) to enable the feature.' : formatMuiErrorMessage(20)); } const palette = createPalette(paletteInput); const systemTheme = createTheme(options); let muiTheme = deepmerge(systemTheme, { mixins: createMixins(systemTheme.breakpoints, mixinsInput), palette, // Don't use [...shadows] until you've verified its transpiled code is not invoking the iterator protocol. shadows: shadows.slice(), typography: createTypography(palette, typographyInput), transitions: createTransitions(transitionsInput), zIndex: { ...zIndex } }); muiTheme = deepmerge(muiTheme, other); muiTheme = args.reduce((acc, argument) => deepmerge(acc, argument), muiTheme); if (process.env.NODE_ENV !== 'production') { // TODO v6: Refactor to use globalStateClassesMapping from @mui/utils once `readOnly` state class is used in Rating component. const stateClasses = ['active', 'checked', 'completed', 'disabled', 'error', 'expanded', 'focused', 'focusVisible', 'required', 'selected']; const traverse = (node, component) => { let key; // eslint-disable-next-line guard-for-in for (key in node) { const child = node[key]; if (stateClasses.includes(key) && Object.keys(child).length > 0) { if (process.env.NODE_ENV !== 'production') { const stateClass = generateUtilityClass('', key); console.error([`MUI: The \`${component}\` component increases ` + `the CSS specificity of the \`${key}\` internal state.`, 'You can not override it like this: ', JSON.stringify(node, null, 2), '', `Instead, you need to use the '&.${stateClass}' syntax:`, JSON.stringify({ root: { [`&.${stateClass}`]: child } }, null, 2), '', 'https://mui.com/r/state-classes-guide'].join('\n')); } // Remove the style to prevent global conflicts. node[key] = {}; } } }; Object.keys(muiTheme.components).forEach(component => { const styleOverrides = muiTheme.components[component].styleOverrides; if (styleOverrides && component.startsWith('Mui')) { traverse(styleOverrides, component); } }); } muiTheme.unstable_sxConfig = { ...defaultSxConfig, ...other?.unstable_sxConfig }; muiTheme.unstable_sx = function sx(props) { return styleFunctionSx({ sx: props, theme: this }); }; muiTheme.toRuntimeSource = stringifyTheme; // for Pigment CSS integration return muiTheme; } export { createThemeNoVars as default }; //# sourceMappingURL=createThemeNoVars.js.map