@mui/system 7.0.1 → 7.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +60 -0
- package/cssVars/cssVarsParser.d.ts +1 -1
- package/esm/cssVars/cssVarsParser.d.ts +1 -1
- package/esm/index.js +1 -1
- package/esm/memoTheme.d.ts +1 -1
- package/esm/useThemeProps/getThemeProps.d.ts +0 -5
- package/esm/version/index.js +2 -2
- package/index.js +1 -1
- package/memoTheme.d.ts +1 -1
- package/modern/cssVars/cssVarsParser.d.ts +1 -1
- package/modern/memoTheme.d.ts +1 -1
- package/modern/useThemeProps/getThemeProps.d.ts +0 -5
- package/package.json +6 -14
- package/useThemeProps/getThemeProps.d.ts +0 -5
- package/version/index.js +2 -2
- package/modern/Box/Box.js +0 -30
- package/modern/Box/boxClasses.js +0 -3
- package/modern/Box/index.js +0 -3
- package/modern/Container/Container.js +0 -61
- package/modern/Container/ContainerProps.js +0 -1
- package/modern/Container/containerClasses.js +0 -7
- package/modern/Container/createContainer.js +0 -149
- package/modern/Container/index.js +0 -3
- package/modern/DefaultPropsProvider/DefaultPropsProvider.js +0 -64
- package/modern/DefaultPropsProvider/index.js +0 -1
- package/modern/GlobalStyles/GlobalStyles.js +0 -37
- package/modern/GlobalStyles/index.js +0 -2
- package/modern/Grid/Grid.js +0 -106
- package/modern/Grid/GridProps.js +0 -1
- package/modern/Grid/createGrid.js +0 -155
- package/modern/Grid/deleteLegacyGridProps.js +0 -41
- package/modern/Grid/gridClasses.js +0 -19
- package/modern/Grid/gridGenerator.js +0 -193
- package/modern/Grid/index.js +0 -7
- package/modern/Grid/traverseBreakpoints.js +0 -42
- package/modern/InitColorSchemeScript/InitColorSchemeScript.js +0 -78
- package/modern/InitColorSchemeScript/index.js +0 -1
- package/modern/RtlProvider/index.js +0 -24
- package/modern/Stack/Stack.js +0 -62
- package/modern/Stack/StackProps.js +0 -1
- package/modern/Stack/createStack.js +0 -173
- package/modern/Stack/index.js +0 -5
- package/modern/Stack/stackClasses.js +0 -7
- package/modern/ThemeProvider/ThemeProvider.js +0 -97
- package/modern/ThemeProvider/index.js +0 -1
- package/modern/borders/borders.js +0 -49
- package/modern/borders/index.js +0 -2
- package/modern/breakpoints/breakpoints.js +0 -171
- package/modern/breakpoints/index.js +0 -2
- package/modern/colorManipulator/colorManipulator.js +0 -349
- package/modern/colorManipulator/index.js +0 -1
- package/modern/compose/compose.js +0 -24
- package/modern/compose/index.js +0 -1
- package/modern/createBox/createBox.js +0 -35
- package/modern/createBox/index.js +0 -1
- package/modern/createBreakpoints/createBreakpoints.js +0 -81
- package/modern/createBreakpoints/index.js +0 -3
- package/modern/createStyled/createStyled.js +0 -276
- package/modern/createStyled/index.js +0 -2
- package/modern/createTheme/applyStyles.js +0 -87
- package/modern/createTheme/createSpacing.js +0 -31
- package/modern/createTheme/createTheme.js +0 -49
- package/modern/createTheme/index.js +0 -3
- package/modern/createTheme/shape.js +0 -4
- package/modern/cssContainerQueries/cssContainerQueries.js +0 -69
- package/modern/cssContainerQueries/index.js +0 -2
- package/modern/cssGrid/cssGrid.js +0 -85
- package/modern/cssGrid/index.js +0 -2
- package/modern/cssVars/createCssVarsProvider.js +0 -338
- package/modern/cssVars/createCssVarsTheme.js +0 -21
- package/modern/cssVars/createGetCssVar.js +0 -22
- package/modern/cssVars/cssVarsParser.js +0 -129
- package/modern/cssVars/getColorSchemeSelector.js +0 -26
- package/modern/cssVars/index.js +0 -5
- package/modern/cssVars/localStorageManager.js +0 -51
- package/modern/cssVars/prepareCssVars.js +0 -153
- package/modern/cssVars/prepareTypographyVars.js +0 -11
- package/modern/cssVars/useCurrentColorScheme.js +0 -228
- package/modern/display/display.js +0 -27
- package/modern/display/index.js +0 -2
- package/modern/flexbox/flexbox.js +0 -43
- package/modern/flexbox/index.js +0 -2
- package/modern/getThemeValue/getThemeValue.js +0 -51
- package/modern/getThemeValue/index.js +0 -2
- package/modern/index.js +0 -75
- package/modern/memoTheme.js +0 -28
- package/modern/memoize/index.js +0 -1
- package/modern/memoize/memoize.js +0 -9
- package/modern/merge/index.js +0 -1
- package/modern/merge/merge.js +0 -10
- package/modern/package.json +0 -1
- package/modern/palette/index.js +0 -2
- package/modern/palette/palette.js +0 -26
- package/modern/positions/index.js +0 -2
- package/modern/positions/positions.js +0 -22
- package/modern/preprocessStyles.js +0 -25
- package/modern/propsToClassKey/index.js +0 -1
- package/modern/propsToClassKey/propsToClassKey.js +0 -25
- package/modern/responsivePropType/index.js +0 -1
- package/modern/responsivePropType/responsivePropType.js +0 -3
- package/modern/shadows/index.js +0 -1
- package/modern/shadows/shadows.js +0 -6
- package/modern/sizing/index.js +0 -2
- package/modern/sizing/sizing.js +0 -64
- package/modern/spacing/index.js +0 -2
- package/modern/spacing/spacing.js +0 -157
- package/modern/style/index.js +0 -2
- package/modern/style/style.js +0 -75
- package/modern/styleFunctionSx/AliasesCSSProperties.js +0 -1
- package/modern/styleFunctionSx/OverwriteCSSProperties.js +0 -1
- package/modern/styleFunctionSx/StandardCssProperties.js +0 -1
- package/modern/styleFunctionSx/defaultSxConfig.js +0 -294
- package/modern/styleFunctionSx/extendSxProp.js +0 -51
- package/modern/styleFunctionSx/index.js +0 -4
- package/modern/styleFunctionSx/styleFunctionSx.js +0 -127
- package/modern/styled/index.js +0 -1
- package/modern/styled/styled.js +0 -3
- package/modern/typography/index.js +0 -2
- package/modern/typography/typography.js +0 -37
- package/modern/useMediaQuery/index.js +0 -2
- package/modern/useMediaQuery/useMediaQuery.js +0 -118
- package/modern/useTheme/index.js +0 -2
- package/modern/useTheme/useTheme.js +0 -9
- package/modern/useThemeProps/getThemeProps.js +0 -12
- package/modern/useThemeProps/index.js +0 -2
- package/modern/useThemeProps/useThemeProps.js +0 -20
- package/modern/useThemeWithoutDefault/index.js +0 -1
- package/modern/useThemeWithoutDefault/useThemeWithoutDefault.js +0 -12
- package/modern/version/index.js +0 -6
- package/tsconfig.build.tsbuildinfo +0 -1
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import deepmerge from '@mui/utils/deepmerge';
|
|
2
|
-
import cssVarsParser from "./cssVarsParser.js";
|
|
3
|
-
function prepareCssVars(theme, parserConfig = {}) {
|
|
4
|
-
const {
|
|
5
|
-
getSelector = defaultGetSelector,
|
|
6
|
-
disableCssColorScheme,
|
|
7
|
-
colorSchemeSelector: selector
|
|
8
|
-
} = parserConfig;
|
|
9
|
-
// @ts-ignore - ignore components do not exist
|
|
10
|
-
const {
|
|
11
|
-
colorSchemes = {},
|
|
12
|
-
components,
|
|
13
|
-
defaultColorScheme = 'light',
|
|
14
|
-
...otherTheme
|
|
15
|
-
} = theme;
|
|
16
|
-
const {
|
|
17
|
-
vars: rootVars,
|
|
18
|
-
css: rootCss,
|
|
19
|
-
varsWithDefaults: rootVarsWithDefaults
|
|
20
|
-
} = cssVarsParser(otherTheme, parserConfig);
|
|
21
|
-
let themeVars = rootVarsWithDefaults;
|
|
22
|
-
const colorSchemesMap = {};
|
|
23
|
-
const {
|
|
24
|
-
[defaultColorScheme]: defaultScheme,
|
|
25
|
-
...otherColorSchemes
|
|
26
|
-
} = colorSchemes;
|
|
27
|
-
Object.entries(otherColorSchemes || {}).forEach(([key, scheme]) => {
|
|
28
|
-
const {
|
|
29
|
-
vars,
|
|
30
|
-
css,
|
|
31
|
-
varsWithDefaults
|
|
32
|
-
} = cssVarsParser(scheme, parserConfig);
|
|
33
|
-
themeVars = deepmerge(themeVars, varsWithDefaults);
|
|
34
|
-
colorSchemesMap[key] = {
|
|
35
|
-
css,
|
|
36
|
-
vars
|
|
37
|
-
};
|
|
38
|
-
});
|
|
39
|
-
if (defaultScheme) {
|
|
40
|
-
// default color scheme vars should be merged last to set as default
|
|
41
|
-
const {
|
|
42
|
-
css,
|
|
43
|
-
vars,
|
|
44
|
-
varsWithDefaults
|
|
45
|
-
} = cssVarsParser(defaultScheme, parserConfig);
|
|
46
|
-
themeVars = deepmerge(themeVars, varsWithDefaults);
|
|
47
|
-
colorSchemesMap[defaultColorScheme] = {
|
|
48
|
-
css,
|
|
49
|
-
vars
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
function defaultGetSelector(colorScheme, cssObject) {
|
|
53
|
-
let rule = selector;
|
|
54
|
-
if (selector === 'class') {
|
|
55
|
-
rule = '.%s';
|
|
56
|
-
}
|
|
57
|
-
if (selector === 'data') {
|
|
58
|
-
rule = '[data-%s]';
|
|
59
|
-
}
|
|
60
|
-
if (selector?.startsWith('data-') && !selector.includes('%s')) {
|
|
61
|
-
// 'data-joy-color-scheme' -> '[data-joy-color-scheme="%s"]'
|
|
62
|
-
rule = `[${selector}="%s"]`;
|
|
63
|
-
}
|
|
64
|
-
if (colorScheme) {
|
|
65
|
-
if (rule === 'media') {
|
|
66
|
-
if (theme.defaultColorScheme === colorScheme) {
|
|
67
|
-
return ':root';
|
|
68
|
-
}
|
|
69
|
-
const mode = colorSchemes[colorScheme]?.palette?.mode || colorScheme;
|
|
70
|
-
return {
|
|
71
|
-
[`@media (prefers-color-scheme: ${mode})`]: {
|
|
72
|
-
':root': cssObject
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
if (rule) {
|
|
77
|
-
if (theme.defaultColorScheme === colorScheme) {
|
|
78
|
-
return `:root, ${rule.replace('%s', String(colorScheme))}`;
|
|
79
|
-
}
|
|
80
|
-
return rule.replace('%s', String(colorScheme));
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return ':root';
|
|
84
|
-
}
|
|
85
|
-
const generateThemeVars = () => {
|
|
86
|
-
let vars = {
|
|
87
|
-
...rootVars
|
|
88
|
-
};
|
|
89
|
-
Object.entries(colorSchemesMap).forEach(([, {
|
|
90
|
-
vars: schemeVars
|
|
91
|
-
}]) => {
|
|
92
|
-
vars = deepmerge(vars, schemeVars);
|
|
93
|
-
});
|
|
94
|
-
return vars;
|
|
95
|
-
};
|
|
96
|
-
const generateStyleSheets = () => {
|
|
97
|
-
const stylesheets = [];
|
|
98
|
-
const colorScheme = theme.defaultColorScheme || 'light';
|
|
99
|
-
function insertStyleSheet(key, css) {
|
|
100
|
-
if (Object.keys(css).length) {
|
|
101
|
-
stylesheets.push(typeof key === 'string' ? {
|
|
102
|
-
[key]: {
|
|
103
|
-
...css
|
|
104
|
-
}
|
|
105
|
-
} : key);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
insertStyleSheet(getSelector(undefined, {
|
|
109
|
-
...rootCss
|
|
110
|
-
}), rootCss);
|
|
111
|
-
const {
|
|
112
|
-
[colorScheme]: defaultSchemeVal,
|
|
113
|
-
...other
|
|
114
|
-
} = colorSchemesMap;
|
|
115
|
-
if (defaultSchemeVal) {
|
|
116
|
-
// default color scheme has to come before other color schemes
|
|
117
|
-
const {
|
|
118
|
-
css
|
|
119
|
-
} = defaultSchemeVal;
|
|
120
|
-
const cssColorSheme = colorSchemes[colorScheme]?.palette?.mode;
|
|
121
|
-
const finalCss = !disableCssColorScheme && cssColorSheme ? {
|
|
122
|
-
colorScheme: cssColorSheme,
|
|
123
|
-
...css
|
|
124
|
-
} : {
|
|
125
|
-
...css
|
|
126
|
-
};
|
|
127
|
-
insertStyleSheet(getSelector(colorScheme, {
|
|
128
|
-
...finalCss
|
|
129
|
-
}), finalCss);
|
|
130
|
-
}
|
|
131
|
-
Object.entries(other).forEach(([key, {
|
|
132
|
-
css
|
|
133
|
-
}]) => {
|
|
134
|
-
const cssColorSheme = colorSchemes[key]?.palette?.mode;
|
|
135
|
-
const finalCss = !disableCssColorScheme && cssColorSheme ? {
|
|
136
|
-
colorScheme: cssColorSheme,
|
|
137
|
-
...css
|
|
138
|
-
} : {
|
|
139
|
-
...css
|
|
140
|
-
};
|
|
141
|
-
insertStyleSheet(getSelector(key, {
|
|
142
|
-
...finalCss
|
|
143
|
-
}), finalCss);
|
|
144
|
-
});
|
|
145
|
-
return stylesheets;
|
|
146
|
-
};
|
|
147
|
-
return {
|
|
148
|
-
vars: themeVars,
|
|
149
|
-
generateThemeVars,
|
|
150
|
-
generateStyleSheets
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
export default prepareCssVars;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export default function prepareTypographyVars(typography) {
|
|
2
|
-
const vars = {};
|
|
3
|
-
const entries = Object.entries(typography);
|
|
4
|
-
entries.forEach(entry => {
|
|
5
|
-
const [key, value] = entry;
|
|
6
|
-
if (typeof value === 'object') {
|
|
7
|
-
vars[key] = `${value.fontStyle ? `${value.fontStyle} ` : ''}${value.fontVariant ? `${value.fontVariant} ` : ''}${value.fontWeight ? `${value.fontWeight} ` : ''}${value.fontStretch ? `${value.fontStretch} ` : ''}${value.fontSize || ''}${value.lineHeight ? `/${value.lineHeight} ` : ''}${value.fontFamily || ''}`;
|
|
8
|
-
}
|
|
9
|
-
});
|
|
10
|
-
return vars;
|
|
11
|
-
}
|
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { DEFAULT_MODE_STORAGE_KEY, DEFAULT_COLOR_SCHEME_STORAGE_KEY } from "../InitColorSchemeScript/InitColorSchemeScript.js";
|
|
5
|
-
import localStorageManager from "./localStorageManager.js";
|
|
6
|
-
function noop() {}
|
|
7
|
-
export function getSystemMode(mode) {
|
|
8
|
-
if (typeof window !== 'undefined' && typeof window.matchMedia === 'function' && mode === 'system') {
|
|
9
|
-
const mql = window.matchMedia('(prefers-color-scheme: dark)');
|
|
10
|
-
if (mql.matches) {
|
|
11
|
-
return 'dark';
|
|
12
|
-
}
|
|
13
|
-
return 'light';
|
|
14
|
-
}
|
|
15
|
-
return undefined;
|
|
16
|
-
}
|
|
17
|
-
function processState(state, callback) {
|
|
18
|
-
if (state.mode === 'light' || state.mode === 'system' && state.systemMode === 'light') {
|
|
19
|
-
return callback('light');
|
|
20
|
-
}
|
|
21
|
-
if (state.mode === 'dark' || state.mode === 'system' && state.systemMode === 'dark') {
|
|
22
|
-
return callback('dark');
|
|
23
|
-
}
|
|
24
|
-
return undefined;
|
|
25
|
-
}
|
|
26
|
-
export function getColorScheme(state) {
|
|
27
|
-
return processState(state, mode => {
|
|
28
|
-
if (mode === 'light') {
|
|
29
|
-
return state.lightColorScheme;
|
|
30
|
-
}
|
|
31
|
-
if (mode === 'dark') {
|
|
32
|
-
return state.darkColorScheme;
|
|
33
|
-
}
|
|
34
|
-
return undefined;
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
export default function useCurrentColorScheme(options) {
|
|
38
|
-
const {
|
|
39
|
-
defaultMode = 'light',
|
|
40
|
-
defaultLightColorScheme,
|
|
41
|
-
defaultDarkColorScheme,
|
|
42
|
-
supportedColorSchemes = [],
|
|
43
|
-
modeStorageKey = DEFAULT_MODE_STORAGE_KEY,
|
|
44
|
-
colorSchemeStorageKey = DEFAULT_COLOR_SCHEME_STORAGE_KEY,
|
|
45
|
-
storageWindow = typeof window === 'undefined' ? undefined : window,
|
|
46
|
-
storageManager = localStorageManager,
|
|
47
|
-
noSsr = false
|
|
48
|
-
} = options;
|
|
49
|
-
const joinedColorSchemes = supportedColorSchemes.join(',');
|
|
50
|
-
const isMultiSchemes = supportedColorSchemes.length > 1;
|
|
51
|
-
const modeStorage = React.useMemo(() => storageManager?.({
|
|
52
|
-
key: modeStorageKey,
|
|
53
|
-
storageWindow
|
|
54
|
-
}), [storageManager, modeStorageKey, storageWindow]);
|
|
55
|
-
const lightStorage = React.useMemo(() => storageManager?.({
|
|
56
|
-
key: `${colorSchemeStorageKey}-light`,
|
|
57
|
-
storageWindow
|
|
58
|
-
}), [storageManager, colorSchemeStorageKey, storageWindow]);
|
|
59
|
-
const darkStorage = React.useMemo(() => storageManager?.({
|
|
60
|
-
key: `${colorSchemeStorageKey}-dark`,
|
|
61
|
-
storageWindow
|
|
62
|
-
}), [storageManager, colorSchemeStorageKey, storageWindow]);
|
|
63
|
-
const [state, setState] = React.useState(() => {
|
|
64
|
-
const initialMode = modeStorage?.get(defaultMode) || defaultMode;
|
|
65
|
-
const lightColorScheme = lightStorage?.get(defaultLightColorScheme) || defaultLightColorScheme;
|
|
66
|
-
const darkColorScheme = darkStorage?.get(defaultDarkColorScheme) || defaultDarkColorScheme;
|
|
67
|
-
return {
|
|
68
|
-
mode: initialMode,
|
|
69
|
-
systemMode: getSystemMode(initialMode),
|
|
70
|
-
lightColorScheme,
|
|
71
|
-
darkColorScheme
|
|
72
|
-
};
|
|
73
|
-
});
|
|
74
|
-
const [isClient, setIsClient] = React.useState(noSsr || !isMultiSchemes);
|
|
75
|
-
React.useEffect(() => {
|
|
76
|
-
setIsClient(true); // to rerender the component after hydration
|
|
77
|
-
}, []);
|
|
78
|
-
const colorScheme = getColorScheme(state);
|
|
79
|
-
const setMode = React.useCallback(mode => {
|
|
80
|
-
setState(currentState => {
|
|
81
|
-
if (mode === currentState.mode) {
|
|
82
|
-
// do nothing if mode does not change
|
|
83
|
-
return currentState;
|
|
84
|
-
}
|
|
85
|
-
const newMode = mode ?? defaultMode;
|
|
86
|
-
modeStorage?.set(newMode);
|
|
87
|
-
return {
|
|
88
|
-
...currentState,
|
|
89
|
-
mode: newMode,
|
|
90
|
-
systemMode: getSystemMode(newMode)
|
|
91
|
-
};
|
|
92
|
-
});
|
|
93
|
-
}, [modeStorage, defaultMode]);
|
|
94
|
-
const setColorScheme = React.useCallback(value => {
|
|
95
|
-
if (!value) {
|
|
96
|
-
setState(currentState => {
|
|
97
|
-
lightStorage?.set(defaultLightColorScheme);
|
|
98
|
-
darkStorage?.set(defaultDarkColorScheme);
|
|
99
|
-
return {
|
|
100
|
-
...currentState,
|
|
101
|
-
lightColorScheme: defaultLightColorScheme,
|
|
102
|
-
darkColorScheme: defaultDarkColorScheme
|
|
103
|
-
};
|
|
104
|
-
});
|
|
105
|
-
} else if (typeof value === 'string') {
|
|
106
|
-
if (value && !joinedColorSchemes.includes(value)) {
|
|
107
|
-
console.error(`\`${value}\` does not exist in \`theme.colorSchemes\`.`);
|
|
108
|
-
} else {
|
|
109
|
-
setState(currentState => {
|
|
110
|
-
const newState = {
|
|
111
|
-
...currentState
|
|
112
|
-
};
|
|
113
|
-
processState(currentState, mode => {
|
|
114
|
-
if (mode === 'light') {
|
|
115
|
-
lightStorage?.set(value);
|
|
116
|
-
newState.lightColorScheme = value;
|
|
117
|
-
}
|
|
118
|
-
if (mode === 'dark') {
|
|
119
|
-
darkStorage?.set(value);
|
|
120
|
-
newState.darkColorScheme = value;
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
return newState;
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
} else {
|
|
127
|
-
setState(currentState => {
|
|
128
|
-
const newState = {
|
|
129
|
-
...currentState
|
|
130
|
-
};
|
|
131
|
-
const newLightColorScheme = value.light === null ? defaultLightColorScheme : value.light;
|
|
132
|
-
const newDarkColorScheme = value.dark === null ? defaultDarkColorScheme : value.dark;
|
|
133
|
-
if (newLightColorScheme) {
|
|
134
|
-
if (!joinedColorSchemes.includes(newLightColorScheme)) {
|
|
135
|
-
console.error(`\`${newLightColorScheme}\` does not exist in \`theme.colorSchemes\`.`);
|
|
136
|
-
} else {
|
|
137
|
-
newState.lightColorScheme = newLightColorScheme;
|
|
138
|
-
lightStorage?.set(newLightColorScheme);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
if (newDarkColorScheme) {
|
|
142
|
-
if (!joinedColorSchemes.includes(newDarkColorScheme)) {
|
|
143
|
-
console.error(`\`${newDarkColorScheme}\` does not exist in \`theme.colorSchemes\`.`);
|
|
144
|
-
} else {
|
|
145
|
-
newState.darkColorScheme = newDarkColorScheme;
|
|
146
|
-
darkStorage?.set(newDarkColorScheme);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
return newState;
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
}, [joinedColorSchemes, lightStorage, darkStorage, defaultLightColorScheme, defaultDarkColorScheme]);
|
|
153
|
-
const handleMediaQuery = React.useCallback(event => {
|
|
154
|
-
if (state.mode === 'system') {
|
|
155
|
-
setState(currentState => {
|
|
156
|
-
const systemMode = event?.matches ? 'dark' : 'light';
|
|
157
|
-
|
|
158
|
-
// Early exit, nothing changed.
|
|
159
|
-
if (currentState.systemMode === systemMode) {
|
|
160
|
-
return currentState;
|
|
161
|
-
}
|
|
162
|
-
return {
|
|
163
|
-
...currentState,
|
|
164
|
-
systemMode
|
|
165
|
-
};
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
}, [state.mode]);
|
|
169
|
-
|
|
170
|
-
// Ref hack to avoid adding handleMediaQuery as a dep
|
|
171
|
-
const mediaListener = React.useRef(handleMediaQuery);
|
|
172
|
-
mediaListener.current = handleMediaQuery;
|
|
173
|
-
React.useEffect(() => {
|
|
174
|
-
if (typeof window.matchMedia !== 'function' || !isMultiSchemes) {
|
|
175
|
-
return undefined;
|
|
176
|
-
}
|
|
177
|
-
const handler = (...args) => mediaListener.current(...args);
|
|
178
|
-
|
|
179
|
-
// Always listen to System preference
|
|
180
|
-
const media = window.matchMedia('(prefers-color-scheme: dark)');
|
|
181
|
-
|
|
182
|
-
// Intentionally use deprecated listener methods to support iOS & old browsers
|
|
183
|
-
media.addListener(handler);
|
|
184
|
-
handler(media);
|
|
185
|
-
return () => {
|
|
186
|
-
media.removeListener(handler);
|
|
187
|
-
};
|
|
188
|
-
}, [isMultiSchemes]);
|
|
189
|
-
|
|
190
|
-
// Handle when localStorage has changed
|
|
191
|
-
React.useEffect(() => {
|
|
192
|
-
if (isMultiSchemes) {
|
|
193
|
-
const unsubscribeMode = modeStorage?.subscribe(value => {
|
|
194
|
-
if (!value || ['light', 'dark', 'system'].includes(value)) {
|
|
195
|
-
setMode(value || defaultMode);
|
|
196
|
-
}
|
|
197
|
-
}) || noop;
|
|
198
|
-
const unsubscribeLight = lightStorage?.subscribe(value => {
|
|
199
|
-
if (!value || joinedColorSchemes.match(value)) {
|
|
200
|
-
setColorScheme({
|
|
201
|
-
light: value
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
}) || noop;
|
|
205
|
-
const unsubscribeDark = darkStorage?.subscribe(value => {
|
|
206
|
-
if (!value || joinedColorSchemes.match(value)) {
|
|
207
|
-
setColorScheme({
|
|
208
|
-
dark: value
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
}) || noop;
|
|
212
|
-
return () => {
|
|
213
|
-
unsubscribeMode();
|
|
214
|
-
unsubscribeLight();
|
|
215
|
-
unsubscribeDark();
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
return undefined;
|
|
219
|
-
}, [setColorScheme, setMode, joinedColorSchemes, defaultMode, storageWindow, isMultiSchemes, modeStorage, lightStorage, darkStorage]);
|
|
220
|
-
return {
|
|
221
|
-
...state,
|
|
222
|
-
mode: isClient ? state.mode : undefined,
|
|
223
|
-
systemMode: isClient ? state.systemMode : undefined,
|
|
224
|
-
colorScheme: isClient ? colorScheme : undefined,
|
|
225
|
-
setMode,
|
|
226
|
-
setColorScheme
|
|
227
|
-
};
|
|
228
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import style from "../style/index.js";
|
|
2
|
-
import compose from "../compose/index.js";
|
|
3
|
-
export const displayPrint = style({
|
|
4
|
-
prop: 'displayPrint',
|
|
5
|
-
cssProperty: false,
|
|
6
|
-
transform: value => ({
|
|
7
|
-
'@media print': {
|
|
8
|
-
display: value
|
|
9
|
-
}
|
|
10
|
-
})
|
|
11
|
-
});
|
|
12
|
-
export const displayRaw = style({
|
|
13
|
-
prop: 'display'
|
|
14
|
-
});
|
|
15
|
-
export const overflow = style({
|
|
16
|
-
prop: 'overflow'
|
|
17
|
-
});
|
|
18
|
-
export const textOverflow = style({
|
|
19
|
-
prop: 'textOverflow'
|
|
20
|
-
});
|
|
21
|
-
export const visibility = style({
|
|
22
|
-
prop: 'visibility'
|
|
23
|
-
});
|
|
24
|
-
export const whiteSpace = style({
|
|
25
|
-
prop: 'whiteSpace'
|
|
26
|
-
});
|
|
27
|
-
export default compose(displayPrint, displayRaw, overflow, textOverflow, visibility, whiteSpace);
|
package/modern/display/index.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import style from "../style/index.js";
|
|
2
|
-
import compose from "../compose/index.js";
|
|
3
|
-
export const flexBasis = style({
|
|
4
|
-
prop: 'flexBasis'
|
|
5
|
-
});
|
|
6
|
-
export const flexDirection = style({
|
|
7
|
-
prop: 'flexDirection'
|
|
8
|
-
});
|
|
9
|
-
export const flexWrap = style({
|
|
10
|
-
prop: 'flexWrap'
|
|
11
|
-
});
|
|
12
|
-
export const justifyContent = style({
|
|
13
|
-
prop: 'justifyContent'
|
|
14
|
-
});
|
|
15
|
-
export const alignItems = style({
|
|
16
|
-
prop: 'alignItems'
|
|
17
|
-
});
|
|
18
|
-
export const alignContent = style({
|
|
19
|
-
prop: 'alignContent'
|
|
20
|
-
});
|
|
21
|
-
export const order = style({
|
|
22
|
-
prop: 'order'
|
|
23
|
-
});
|
|
24
|
-
export const flex = style({
|
|
25
|
-
prop: 'flex'
|
|
26
|
-
});
|
|
27
|
-
export const flexGrow = style({
|
|
28
|
-
prop: 'flexGrow'
|
|
29
|
-
});
|
|
30
|
-
export const flexShrink = style({
|
|
31
|
-
prop: 'flexShrink'
|
|
32
|
-
});
|
|
33
|
-
export const alignSelf = style({
|
|
34
|
-
prop: 'alignSelf'
|
|
35
|
-
});
|
|
36
|
-
export const justifyItems = style({
|
|
37
|
-
prop: 'justifyItems'
|
|
38
|
-
});
|
|
39
|
-
export const justifySelf = style({
|
|
40
|
-
prop: 'justifySelf'
|
|
41
|
-
});
|
|
42
|
-
const flexbox = compose(flexBasis, flexDirection, flexWrap, justifyContent, alignItems, alignContent, order, flex, flexGrow, flexShrink, alignSelf, justifyItems, justifySelf);
|
|
43
|
-
export default flexbox;
|
package/modern/flexbox/index.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import borders from "../borders/index.js";
|
|
2
|
-
import display from "../display/index.js";
|
|
3
|
-
import flexbox from "../flexbox/index.js";
|
|
4
|
-
import grid from "../cssGrid/index.js";
|
|
5
|
-
import positions from "../positions/index.js";
|
|
6
|
-
import palette from "../palette/index.js";
|
|
7
|
-
import shadows from "../shadows/index.js";
|
|
8
|
-
import sizing from "../sizing/index.js";
|
|
9
|
-
import spacing from "../spacing/index.js";
|
|
10
|
-
import typography from "../typography/index.js";
|
|
11
|
-
const filterPropsMapping = {
|
|
12
|
-
borders: borders.filterProps,
|
|
13
|
-
display: display.filterProps,
|
|
14
|
-
flexbox: flexbox.filterProps,
|
|
15
|
-
grid: grid.filterProps,
|
|
16
|
-
positions: positions.filterProps,
|
|
17
|
-
palette: palette.filterProps,
|
|
18
|
-
shadows: shadows.filterProps,
|
|
19
|
-
sizing: sizing.filterProps,
|
|
20
|
-
spacing: spacing.filterProps,
|
|
21
|
-
typography: typography.filterProps
|
|
22
|
-
};
|
|
23
|
-
export const styleFunctionMapping = {
|
|
24
|
-
borders,
|
|
25
|
-
display,
|
|
26
|
-
flexbox,
|
|
27
|
-
grid,
|
|
28
|
-
positions,
|
|
29
|
-
palette,
|
|
30
|
-
shadows,
|
|
31
|
-
sizing,
|
|
32
|
-
spacing,
|
|
33
|
-
typography
|
|
34
|
-
};
|
|
35
|
-
export const propToStyleFunction = Object.keys(filterPropsMapping).reduce((acc, styleFnName) => {
|
|
36
|
-
filterPropsMapping[styleFnName].forEach(propName => {
|
|
37
|
-
acc[propName] = styleFunctionMapping[styleFnName];
|
|
38
|
-
});
|
|
39
|
-
return acc;
|
|
40
|
-
}, {});
|
|
41
|
-
function getThemeValue(prop, value, theme) {
|
|
42
|
-
const inputProps = {
|
|
43
|
-
[prop]: value,
|
|
44
|
-
theme
|
|
45
|
-
};
|
|
46
|
-
const styleFunction = propToStyleFunction[prop];
|
|
47
|
-
return styleFunction ? styleFunction(inputProps) : {
|
|
48
|
-
[prop]: value
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
export default getThemeValue;
|
package/modern/index.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @mui/system v7.0.1
|
|
3
|
-
*
|
|
4
|
-
* @license MIT
|
|
5
|
-
* This source code is licensed under the MIT license found in the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
|
-
import _formatErrorMessage from "@mui/utils/formatMuiErrorMessage";
|
|
9
|
-
export { css, keyframes, StyledEngineProvider } from '@mui/styled-engine';
|
|
10
|
-
export { default as GlobalStyles } from "./GlobalStyles/index.js";
|
|
11
|
-
export { default as borders } from "./borders/index.js";
|
|
12
|
-
export * from "./borders/index.js";
|
|
13
|
-
export { default as breakpoints } from "./breakpoints/index.js";
|
|
14
|
-
export { default as cssContainerQueries } from "./cssContainerQueries/index.js";
|
|
15
|
-
export { handleBreakpoints, mergeBreakpointsInOrder, resolveBreakpointValues as unstable_resolveBreakpointValues } from "./breakpoints/index.js";
|
|
16
|
-
export { default as compose } from "./compose/index.js";
|
|
17
|
-
export { default as display } from "./display/index.js";
|
|
18
|
-
export { default as flexbox } from "./flexbox/index.js";
|
|
19
|
-
export * from "./flexbox/index.js";
|
|
20
|
-
export { default as grid } from "./cssGrid/index.js";
|
|
21
|
-
export * from "./cssGrid/index.js";
|
|
22
|
-
export { default as palette } from "./palette/index.js";
|
|
23
|
-
export * from "./palette/index.js";
|
|
24
|
-
export { default as positions } from "./positions/index.js";
|
|
25
|
-
export * from "./positions/index.js";
|
|
26
|
-
export { default as shadows } from "./shadows/index.js";
|
|
27
|
-
export { default as sizing } from "./sizing/index.js";
|
|
28
|
-
export * from "./sizing/index.js";
|
|
29
|
-
export { default as spacing } from "./spacing/index.js";
|
|
30
|
-
export * from "./spacing/index.js";
|
|
31
|
-
export { default as style, getPath, getStyleValue } from "./style/index.js";
|
|
32
|
-
export { default as typography } from "./typography/index.js";
|
|
33
|
-
export * from "./typography/index.js";
|
|
34
|
-
export { default as unstable_styleFunctionSx, unstable_createStyleFunctionSx, extendSxProp as unstable_extendSxProp, unstable_defaultSxConfig } from "./styleFunctionSx/index.js";
|
|
35
|
-
// TODO: Remove this function in v6
|
|
36
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
37
|
-
export function experimental_sx() {
|
|
38
|
-
throw new Error(process.env.NODE_ENV !== "production" ? 'MUI: The `experimental_sx` has been moved to `theme.unstable_sx`.' + 'For more details, see https://github.com/mui/material-ui/pull/35150.' : _formatErrorMessage(19));
|
|
39
|
-
}
|
|
40
|
-
export { default as unstable_getThemeValue } from "./getThemeValue/index.js";
|
|
41
|
-
export { default as Box } from "./Box/index.js";
|
|
42
|
-
export { default as createBox } from "./createBox/index.js";
|
|
43
|
-
export { default as createStyled } from "./createStyled/index.js";
|
|
44
|
-
export * from "./createStyled/index.js";
|
|
45
|
-
export { default as styled } from "./styled/index.js";
|
|
46
|
-
export { default as createTheme } from "./createTheme/index.js";
|
|
47
|
-
export { default as createBreakpoints } from "./createBreakpoints/createBreakpoints.js";
|
|
48
|
-
export { default as createSpacing } from "./createTheme/createSpacing.js";
|
|
49
|
-
export { default as shape } from "./createTheme/shape.js";
|
|
50
|
-
export { default as useThemeProps, getThemeProps } from "./useThemeProps/index.js";
|
|
51
|
-
export { default as useTheme } from "./useTheme/index.js";
|
|
52
|
-
export { default as useThemeWithoutDefault } from "./useThemeWithoutDefault/index.js";
|
|
53
|
-
export { default as useMediaQuery } from "./useMediaQuery/index.js";
|
|
54
|
-
export * from "./colorManipulator/index.js";
|
|
55
|
-
export { default as ThemeProvider } from "./ThemeProvider/index.js";
|
|
56
|
-
export { default as unstable_memoTheme } from "./memoTheme.js";
|
|
57
|
-
export { default as unstable_createCssVarsProvider } from "./cssVars/createCssVarsProvider.js";
|
|
58
|
-
export { default as unstable_createGetCssVar } from "./cssVars/createGetCssVar.js";
|
|
59
|
-
export { default as unstable_cssVarsParser } from "./cssVars/cssVarsParser.js";
|
|
60
|
-
export { default as unstable_prepareCssVars } from "./cssVars/prepareCssVars.js";
|
|
61
|
-
export { default as unstable_createCssVarsTheme } from "./cssVars/createCssVarsTheme.js";
|
|
62
|
-
export { default as responsivePropType } from "./responsivePropType/index.js";
|
|
63
|
-
export { default as RtlProvider } from "./RtlProvider/index.js";
|
|
64
|
-
export * from "./RtlProvider/index.js";
|
|
65
|
-
export * from "./version/index.js";
|
|
66
|
-
|
|
67
|
-
/** ----------------- */
|
|
68
|
-
/** Layout components */
|
|
69
|
-
export { default as createContainer } from "./Container/createContainer.js";
|
|
70
|
-
export { default as Container } from "./Container/index.js";
|
|
71
|
-
export * from "./Container/index.js";
|
|
72
|
-
export { default as Grid } from "./Grid/Grid.js";
|
|
73
|
-
export * from "./Grid/index.js";
|
|
74
|
-
export { default as Stack } from "./Stack/Stack.js";
|
|
75
|
-
export * from "./Stack/index.js";
|
package/modern/memoTheme.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import preprocessStyles from "./preprocessStyles.js";
|
|
2
|
-
|
|
3
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
4
|
-
|
|
5
|
-
// We need to pass an argument as `{ theme }` for PigmentCSS, but we don't want to
|
|
6
|
-
// allocate more objects.
|
|
7
|
-
const arg = {
|
|
8
|
-
theme: undefined
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Memoize style function on theme.
|
|
13
|
-
* Intended to be used in styled() calls that only need access to the theme.
|
|
14
|
-
*/
|
|
15
|
-
export default function unstable_memoTheme(styleFn) {
|
|
16
|
-
let lastValue;
|
|
17
|
-
let lastTheme;
|
|
18
|
-
return function styleMemoized(props) {
|
|
19
|
-
let value = lastValue;
|
|
20
|
-
if (value === undefined || props.theme !== lastTheme) {
|
|
21
|
-
arg.theme = props.theme;
|
|
22
|
-
value = preprocessStyles(styleFn(arg));
|
|
23
|
-
lastValue = value;
|
|
24
|
-
lastTheme = props.theme;
|
|
25
|
-
}
|
|
26
|
-
return value;
|
|
27
|
-
};
|
|
28
|
-
}
|
package/modern/memoize/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./memoize.js";
|
package/modern/merge/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./merge.js";
|
package/modern/merge/merge.js
DELETED
package/modern/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"module","sideEffects":false}
|
package/modern/palette/index.js
DELETED