@mui/system 5.10.6 → 5.10.7
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/Box/Box.spec.d.ts +1 -1
- package/CHANGELOG.md +78 -0
- package/Container/Container.d.ts +13 -13
- package/Container/ContainerProps.d.ts +40 -40
- package/Container/containerClasses.d.ts +22 -22
- package/Container/createContainer.d.ts +18 -18
- package/Stack/Stack.d.ts +13 -13
- package/Stack/StackProps.d.ts +42 -42
- package/Stack/createStack.d.ts +21 -21
- package/Stack/index.d.ts +5 -5
- package/Stack/stackClasses.d.ts +8 -8
- package/Unstable_Grid/Grid.d.ts +12 -12
- package/Unstable_Grid/GridProps.d.ts +162 -162
- package/Unstable_Grid/createGrid.d.ts +11 -11
- package/Unstable_Grid/gridClasses.d.ts +20 -20
- package/Unstable_Grid/gridGenerator.d.ts +26 -26
- package/Unstable_Grid/index.d.ts +5 -5
- package/colorManipulator.js +1 -1
- package/createBox.spec.d.ts +1 -1
- package/createTheme/createSpacing.d.ts +10 -10
- package/createTheme/shape.d.ts +1 -1
- package/cssVars/createCssVarsProvider.d.ts +8 -0
- package/cssVars/createCssVarsProvider.js +11 -1
- package/cssVars/createCssVarsProvider.spec.d.ts +1 -1
- package/cssVars/createGetCssVar.d.ts +5 -5
- package/cssVars/cssVarsParser.d.ts +65 -65
- package/cssVars/getInitColorSchemeScript.d.ts +47 -45
- package/cssVars/getInitColorSchemeScript.js +3 -3
- package/cssVars/index.d.ts +3 -3
- package/cssVars/useCurrentColorScheme.d.ts +53 -53
- package/esm/colorManipulator.js +1 -1
- package/esm/cssVars/createCssVarsProvider.js +11 -1
- package/esm/cssVars/getInitColorSchemeScript.js +3 -3
- package/index.js +1 -1
- package/index.spec.d.ts +1 -1
- package/legacy/colorManipulator.js +1 -1
- package/legacy/cssVars/createCssVarsProvider.js +11 -1
- package/legacy/cssVars/getInitColorSchemeScript.js +3 -3
- package/legacy/index.js +1 -1
- package/modern/colorManipulator.js +1 -1
- package/modern/cssVars/createCssVarsProvider.js +11 -1
- package/modern/cssVars/getInitColorSchemeScript.js +3 -3
- package/modern/index.js +1 -1
- package/package.json +3 -3
- package/styleFunctionSx/styleFunctionSx.spec.d.ts +1 -1
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
declare type NestedRecord<V = any> = {
|
|
2
|
-
[k: string | number]: NestedRecord<V> | V;
|
|
3
|
-
};
|
|
4
|
-
/**
|
|
5
|
-
* This function create an object from keys, value and then assign to target
|
|
6
|
-
*
|
|
7
|
-
* @param {Object} obj : the target object to be assigned
|
|
8
|
-
* @param {string[]} keys
|
|
9
|
-
* @param {string | number} value
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* const source = {}
|
|
13
|
-
* assignNestedKeys(source, ['palette', 'primary'], 'var(--palette-primary)')
|
|
14
|
-
* console.log(source) // { palette: { primary: 'var(--palette-primary)' } }
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* const source = { palette: { primary: 'var(--palette-primary)' } }
|
|
18
|
-
* assignNestedKeys(source, ['palette', 'secondary'], 'var(--palette-secondary)')
|
|
19
|
-
* console.log(source) // { palette: { primary: 'var(--palette-primary)', secondary: 'var(--palette-secondary)' } }
|
|
20
|
-
*/
|
|
21
|
-
export declare const assignNestedKeys: <T extends string | Record<string, any> | null | undefined = NestedRecord<any>, Value = any>(obj: T, keys: Array<string>, value: Value, arrayKeys?: Array<string>) => void;
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
* @param {Object} obj : source object
|
|
25
|
-
* @param {Function} callback : a function that will be called when
|
|
26
|
-
* - the deepest key in source object is reached
|
|
27
|
-
* - the value of the deepest key is NOT `undefined` | `null`
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* walkObjectDeep({ palette: { primary: { main: '#000000' } } }, console.log)
|
|
31
|
-
* // ['palette', 'primary', 'main'] '#000000'
|
|
32
|
-
*/
|
|
33
|
-
export declare const walkObjectDeep: <Value, T = Record<string, any>>(obj: T, callback: (keys: Array<string>, value: Value, arrayKeys: Array<string>) => void, shouldSkipPaths?: ((keys: Array<string>) => boolean) | undefined) => void;
|
|
34
|
-
/**
|
|
35
|
-
* a function that parse theme and return { css, vars }
|
|
36
|
-
*
|
|
37
|
-
* @param {Object} theme
|
|
38
|
-
* @param {{
|
|
39
|
-
* prefix?: string,
|
|
40
|
-
* shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean
|
|
41
|
-
* }} options.
|
|
42
|
-
* `prefix`: The prefix of the generated CSS variables. This function does not change the value.
|
|
43
|
-
*
|
|
44
|
-
* @returns {{ css: Object, vars: Object, parsedTheme: typeof theme }} `css` is the stylesheet, `vars` is an object to get css variable (same structure as theme), and `parsedTheme` is the cloned version of theme.
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* const { css, vars, parsedTheme } = parser({
|
|
48
|
-
* fontSize: 12,
|
|
49
|
-
* lineHeight: 1.2,
|
|
50
|
-
* palette: { primary: { 500: 'var(--color)' } }
|
|
51
|
-
* }, { prefix: 'foo' })
|
|
52
|
-
*
|
|
53
|
-
* console.log(css) // { '--foo-fontSize': '12px', '--foo-lineHeight': 1.2, '--foo-palette-primary-500': 'var(--color)' }
|
|
54
|
-
* console.log(vars) // { fontSize: 'var(--foo-fontSize)', lineHeight: 'var(--foo-lineHeight)', palette: { primary: { 500: 'var(--foo-palette-primary-500)' } } }
|
|
55
|
-
* console.log(parsedTheme) // { fontSize: 12, lineHeight: 1.2, palette: { primary: { 500: 'var(--color)' } } }
|
|
56
|
-
*/
|
|
57
|
-
export default function cssVarsParser<T extends Record<string, any>>(theme: T, options?: {
|
|
58
|
-
prefix?: string;
|
|
59
|
-
shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean;
|
|
60
|
-
}): {
|
|
61
|
-
css:
|
|
62
|
-
vars: NestedRecord<string>;
|
|
63
|
-
parsedTheme: T;
|
|
64
|
-
};
|
|
65
|
-
export {};
|
|
1
|
+
declare type NestedRecord<V = any> = {
|
|
2
|
+
[k: string | number]: NestedRecord<V> | V;
|
|
3
|
+
};
|
|
4
|
+
/**
|
|
5
|
+
* This function create an object from keys, value and then assign to target
|
|
6
|
+
*
|
|
7
|
+
* @param {Object} obj : the target object to be assigned
|
|
8
|
+
* @param {string[]} keys
|
|
9
|
+
* @param {string | number} value
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const source = {}
|
|
13
|
+
* assignNestedKeys(source, ['palette', 'primary'], 'var(--palette-primary)')
|
|
14
|
+
* console.log(source) // { palette: { primary: 'var(--palette-primary)' } }
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* const source = { palette: { primary: 'var(--palette-primary)' } }
|
|
18
|
+
* assignNestedKeys(source, ['palette', 'secondary'], 'var(--palette-secondary)')
|
|
19
|
+
* console.log(source) // { palette: { primary: 'var(--palette-primary)', secondary: 'var(--palette-secondary)' } }
|
|
20
|
+
*/
|
|
21
|
+
export declare const assignNestedKeys: <T extends string | Record<string, any> | null | undefined = NestedRecord<any>, Value = any>(obj: T, keys: Array<string>, value: Value, arrayKeys?: Array<string>) => void;
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @param {Object} obj : source object
|
|
25
|
+
* @param {Function} callback : a function that will be called when
|
|
26
|
+
* - the deepest key in source object is reached
|
|
27
|
+
* - the value of the deepest key is NOT `undefined` | `null`
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* walkObjectDeep({ palette: { primary: { main: '#000000' } } }, console.log)
|
|
31
|
+
* // ['palette', 'primary', 'main'] '#000000'
|
|
32
|
+
*/
|
|
33
|
+
export declare const walkObjectDeep: <Value, T = Record<string, any>>(obj: T, callback: (keys: Array<string>, value: Value, arrayKeys: Array<string>) => void, shouldSkipPaths?: ((keys: Array<string>) => boolean) | undefined) => void;
|
|
34
|
+
/**
|
|
35
|
+
* a function that parse theme and return { css, vars }
|
|
36
|
+
*
|
|
37
|
+
* @param {Object} theme
|
|
38
|
+
* @param {{
|
|
39
|
+
* prefix?: string,
|
|
40
|
+
* shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean
|
|
41
|
+
* }} options.
|
|
42
|
+
* `prefix`: The prefix of the generated CSS variables. This function does not change the value.
|
|
43
|
+
*
|
|
44
|
+
* @returns {{ css: Object, vars: Object, parsedTheme: typeof theme }} `css` is the stylesheet, `vars` is an object to get css variable (same structure as theme), and `parsedTheme` is the cloned version of theme.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* const { css, vars, parsedTheme } = parser({
|
|
48
|
+
* fontSize: 12,
|
|
49
|
+
* lineHeight: 1.2,
|
|
50
|
+
* palette: { primary: { 500: 'var(--color)' } }
|
|
51
|
+
* }, { prefix: 'foo' })
|
|
52
|
+
*
|
|
53
|
+
* console.log(css) // { '--foo-fontSize': '12px', '--foo-lineHeight': 1.2, '--foo-palette-primary-500': 'var(--color)' }
|
|
54
|
+
* console.log(vars) // { fontSize: 'var(--foo-fontSize)', lineHeight: 'var(--foo-lineHeight)', palette: { primary: { 500: 'var(--foo-palette-primary-500)' } } }
|
|
55
|
+
* console.log(parsedTheme) // { fontSize: 12, lineHeight: 1.2, palette: { primary: { 500: 'var(--color)' } } }
|
|
56
|
+
*/
|
|
57
|
+
export default function cssVarsParser<T extends Record<string, any>>(theme: T, options?: {
|
|
58
|
+
prefix?: string;
|
|
59
|
+
shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean;
|
|
60
|
+
}): {
|
|
61
|
+
css: Record<string, string | number>;
|
|
62
|
+
vars: NestedRecord<string>;
|
|
63
|
+
parsedTheme: T;
|
|
64
|
+
};
|
|
65
|
+
export {};
|
|
@@ -1,45 +1,47 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
export declare const DEFAULT_MODE_STORAGE_KEY = "mode";
|
|
3
|
-
export declare const DEFAULT_COLOR_SCHEME_STORAGE_KEY = "color-scheme";
|
|
4
|
-
export declare const DEFAULT_ATTRIBUTE = "data-color-scheme";
|
|
5
|
-
export interface GetInitColorSchemeScriptOptions {
|
|
6
|
-
/**
|
|
7
|
-
* Indicate to the browser which color scheme is used (light or dark) for rendering built-in UI
|
|
8
|
-
* @default true
|
|
9
|
-
*/
|
|
10
|
-
enableColorScheme?: boolean;
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
* @default
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* The default color scheme to be used on the light mode
|
|
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
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const DEFAULT_MODE_STORAGE_KEY = "mode";
|
|
3
|
+
export declare const DEFAULT_COLOR_SCHEME_STORAGE_KEY = "color-scheme";
|
|
4
|
+
export declare const DEFAULT_ATTRIBUTE = "data-color-scheme";
|
|
5
|
+
export interface GetInitColorSchemeScriptOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Indicate to the browser which color scheme is used (light or dark) for rendering built-in UI
|
|
8
|
+
* @default true
|
|
9
|
+
*/
|
|
10
|
+
enableColorScheme?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* The mode to be used for the first visit
|
|
13
|
+
* @default 'light'
|
|
14
|
+
*/
|
|
15
|
+
defaultMode?: 'light' | 'dark' | 'system';
|
|
16
|
+
/**
|
|
17
|
+
* The default color scheme to be used on the light mode
|
|
18
|
+
* @default 'light'
|
|
19
|
+
*/
|
|
20
|
+
defaultLightColorScheme?: string;
|
|
21
|
+
/**
|
|
22
|
+
* The default color scheme to be used on the dark mode
|
|
23
|
+
* * @default 'dark'
|
|
24
|
+
*/
|
|
25
|
+
defaultDarkColorScheme?: string;
|
|
26
|
+
/**
|
|
27
|
+
* The node (provided as string) used to attach the color-scheme attribute
|
|
28
|
+
* @default 'document.documentElement'
|
|
29
|
+
*/
|
|
30
|
+
colorSchemeNode?: string;
|
|
31
|
+
/**
|
|
32
|
+
* localStorage key used to store `mode`
|
|
33
|
+
* @default 'mode'
|
|
34
|
+
*/
|
|
35
|
+
modeStorageKey?: string;
|
|
36
|
+
/**
|
|
37
|
+
* localStorage key used to store `colorScheme`
|
|
38
|
+
* @default 'color-scheme'
|
|
39
|
+
*/
|
|
40
|
+
colorSchemeStorageKey?: string;
|
|
41
|
+
/**
|
|
42
|
+
* DOM attribute for applying color scheme
|
|
43
|
+
* @default 'data-color-scheme'
|
|
44
|
+
*/
|
|
45
|
+
attribute?: string;
|
|
46
|
+
}
|
|
47
|
+
export default function getInitColorSchemeScript(options?: GetInitColorSchemeScriptOptions): JSX.Element;
|
|
@@ -24,7 +24,7 @@ exports.DEFAULT_ATTRIBUTE = DEFAULT_ATTRIBUTE;
|
|
|
24
24
|
function getInitColorSchemeScript(options) {
|
|
25
25
|
const {
|
|
26
26
|
enableColorScheme = true,
|
|
27
|
-
|
|
27
|
+
defaultMode = 'light',
|
|
28
28
|
defaultLightColorScheme = 'light',
|
|
29
29
|
defaultDarkColorScheme = 'dark',
|
|
30
30
|
modeStorageKey = DEFAULT_MODE_STORAGE_KEY,
|
|
@@ -36,10 +36,10 @@ function getInitColorSchemeScript(options) {
|
|
|
36
36
|
// eslint-disable-next-line react/no-danger
|
|
37
37
|
dangerouslySetInnerHTML: {
|
|
38
38
|
__html: `(function() { try {
|
|
39
|
-
var mode = localStorage.getItem('${modeStorageKey}');
|
|
39
|
+
var mode = localStorage.getItem('${modeStorageKey}') || '${defaultMode}';
|
|
40
40
|
var cssColorScheme = mode;
|
|
41
41
|
var colorScheme = '';
|
|
42
|
-
if (mode === 'system'
|
|
42
|
+
if (mode === 'system') {
|
|
43
43
|
// handle system mode
|
|
44
44
|
var mql = window.matchMedia('(prefers-color-scheme: dark)');
|
|
45
45
|
if (mql.matches) {
|
package/cssVars/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { default } from './createCssVarsProvider';
|
|
2
|
-
export type { CreateCssVarsProviderResult, CssVarsProviderConfig, ColorSchemeContextValue, } from './createCssVarsProvider';
|
|
3
|
-
export { default as getInitColorSchemeScript } from './getInitColorSchemeScript';
|
|
1
|
+
export { default } from './createCssVarsProvider';
|
|
2
|
+
export type { CreateCssVarsProviderResult, CssVarsProviderConfig, ColorSchemeContextValue, } from './createCssVarsProvider';
|
|
3
|
+
export { default as getInitColorSchemeScript } from './getInitColorSchemeScript';
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
export declare type Mode = 'light' | 'dark' | 'system';
|
|
2
|
-
export declare type SystemMode = Exclude<Mode, 'system'>;
|
|
3
|
-
export interface State<SupportedColorScheme extends string> {
|
|
4
|
-
/**
|
|
5
|
-
* User selected mode.
|
|
6
|
-
* Note: on the server, mode is always undefined
|
|
7
|
-
*/
|
|
8
|
-
mode: Mode | undefined;
|
|
9
|
-
/**
|
|
10
|
-
* Only valid if `mode: 'system'`, either 'light' | 'dark'.
|
|
11
|
-
*/
|
|
12
|
-
systemMode: SystemMode | undefined;
|
|
13
|
-
/**
|
|
14
|
-
* The color scheme for the light mode.
|
|
15
|
-
*/
|
|
16
|
-
lightColorScheme: SupportedColorScheme;
|
|
17
|
-
/**
|
|
18
|
-
* The color scheme for the dark mode.
|
|
19
|
-
*/
|
|
20
|
-
darkColorScheme: SupportedColorScheme;
|
|
21
|
-
}
|
|
22
|
-
export declare type Result<SupportedColorScheme extends string> = State<SupportedColorScheme> & {
|
|
23
|
-
/**
|
|
24
|
-
* The current application color scheme. It is always `undefined` on the server.
|
|
25
|
-
*/
|
|
26
|
-
colorScheme: SupportedColorScheme | undefined;
|
|
27
|
-
/**
|
|
28
|
-
* `mode` is saved to internal state and localStorage
|
|
29
|
-
* If `mode` is null, it will be reset to the defaultMode
|
|
30
|
-
*/
|
|
31
|
-
setMode: (mode: Mode | null) => void;
|
|
32
|
-
/**
|
|
33
|
-
* `colorScheme` is saved to internal state and localStorage
|
|
34
|
-
* If `colorScheme` is null, it will be reset to the defaultColorScheme (light | dark)
|
|
35
|
-
*/
|
|
36
|
-
setColorScheme: (colorScheme: SupportedColorScheme | Partial<{
|
|
37
|
-
light: SupportedColorScheme | null;
|
|
38
|
-
dark: SupportedColorScheme | null;
|
|
39
|
-
}> | null) => void;
|
|
40
|
-
};
|
|
41
|
-
export declare function getSystemMode(mode: undefined | string): SystemMode | undefined;
|
|
42
|
-
export declare function getColorScheme<SupportedColorScheme extends string>(state: State<SupportedColorScheme>): SupportedColorScheme | undefined;
|
|
43
|
-
interface UseCurrentColoSchemeOptions<SupportedColorScheme extends string> {
|
|
44
|
-
defaultLightColorScheme: SupportedColorScheme;
|
|
45
|
-
defaultDarkColorScheme: SupportedColorScheme;
|
|
46
|
-
supportedColorSchemes: Array<SupportedColorScheme>;
|
|
47
|
-
defaultMode?: Mode;
|
|
48
|
-
modeStorageKey?: string;
|
|
49
|
-
colorSchemeStorageKey?: string;
|
|
50
|
-
storageWindow?: Window | null;
|
|
51
|
-
}
|
|
52
|
-
export default function useCurrentColorScheme<SupportedColorScheme extends string>(options: UseCurrentColoSchemeOptions<SupportedColorScheme>): Result<SupportedColorScheme>;
|
|
53
|
-
export {};
|
|
1
|
+
export declare type Mode = 'light' | 'dark' | 'system';
|
|
2
|
+
export declare type SystemMode = Exclude<Mode, 'system'>;
|
|
3
|
+
export interface State<SupportedColorScheme extends string> {
|
|
4
|
+
/**
|
|
5
|
+
* User selected mode.
|
|
6
|
+
* Note: on the server, mode is always undefined
|
|
7
|
+
*/
|
|
8
|
+
mode: Mode | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Only valid if `mode: 'system'`, either 'light' | 'dark'.
|
|
11
|
+
*/
|
|
12
|
+
systemMode: SystemMode | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* The color scheme for the light mode.
|
|
15
|
+
*/
|
|
16
|
+
lightColorScheme: SupportedColorScheme;
|
|
17
|
+
/**
|
|
18
|
+
* The color scheme for the dark mode.
|
|
19
|
+
*/
|
|
20
|
+
darkColorScheme: SupportedColorScheme;
|
|
21
|
+
}
|
|
22
|
+
export declare type Result<SupportedColorScheme extends string> = State<SupportedColorScheme> & {
|
|
23
|
+
/**
|
|
24
|
+
* The current application color scheme. It is always `undefined` on the server.
|
|
25
|
+
*/
|
|
26
|
+
colorScheme: SupportedColorScheme | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* `mode` is saved to internal state and localStorage
|
|
29
|
+
* If `mode` is null, it will be reset to the defaultMode
|
|
30
|
+
*/
|
|
31
|
+
setMode: (mode: Mode | null) => void;
|
|
32
|
+
/**
|
|
33
|
+
* `colorScheme` is saved to internal state and localStorage
|
|
34
|
+
* If `colorScheme` is null, it will be reset to the defaultColorScheme (light | dark)
|
|
35
|
+
*/
|
|
36
|
+
setColorScheme: (colorScheme: SupportedColorScheme | Partial<{
|
|
37
|
+
light: SupportedColorScheme | null;
|
|
38
|
+
dark: SupportedColorScheme | null;
|
|
39
|
+
}> | null) => void;
|
|
40
|
+
};
|
|
41
|
+
export declare function getSystemMode(mode: undefined | string): SystemMode | undefined;
|
|
42
|
+
export declare function getColorScheme<SupportedColorScheme extends string>(state: State<SupportedColorScheme>): SupportedColorScheme | undefined;
|
|
43
|
+
interface UseCurrentColoSchemeOptions<SupportedColorScheme extends string> {
|
|
44
|
+
defaultLightColorScheme: SupportedColorScheme;
|
|
45
|
+
defaultDarkColorScheme: SupportedColorScheme;
|
|
46
|
+
supportedColorSchemes: Array<SupportedColorScheme>;
|
|
47
|
+
defaultMode?: Mode;
|
|
48
|
+
modeStorageKey?: string;
|
|
49
|
+
colorSchemeStorageKey?: string;
|
|
50
|
+
storageWindow?: Window | null;
|
|
51
|
+
}
|
|
52
|
+
export default function useCurrentColorScheme<SupportedColorScheme extends string>(options: UseCurrentColoSchemeOptions<SupportedColorScheme>): Result<SupportedColorScheme>;
|
|
53
|
+
export {};
|
package/esm/colorManipulator.js
CHANGED
|
@@ -197,7 +197,7 @@ export function hslToRgb(color) {
|
|
|
197
197
|
|
|
198
198
|
export function getLuminance(color) {
|
|
199
199
|
color = decomposeColor(color);
|
|
200
|
-
let rgb = color.type === 'hsl' ? decomposeColor(hslToRgb(color)).values : color.values;
|
|
200
|
+
let rgb = color.type === 'hsl' || color.type === 'hsla' ? decomposeColor(hslToRgb(color)).values : color.values;
|
|
201
201
|
rgb = rgb.map(val => {
|
|
202
202
|
if (color.type !== 'color') {
|
|
203
203
|
val /= 255; // normalized
|
|
@@ -24,7 +24,8 @@ export default function createCssVarsProvider(options) {
|
|
|
24
24
|
disableTransitionOnChange: designSystemTransitionOnChange = false,
|
|
25
25
|
enableColorScheme: designSystemEnableColorScheme = true,
|
|
26
26
|
shouldSkipGeneratingVar: designSystemShouldSkipGeneratingVar,
|
|
27
|
-
resolveTheme
|
|
27
|
+
resolveTheme,
|
|
28
|
+
excludeVariablesFromRoot
|
|
28
29
|
} = options;
|
|
29
30
|
|
|
30
31
|
if (!defaultTheme.colorSchemes || typeof designSystemColorScheme === 'string' && !defaultTheme.colorSchemes[designSystemColorScheme] || typeof designSystemColorScheme === 'object' && !defaultTheme.colorSchemes[designSystemColorScheme == null ? void 0 : designSystemColorScheme.light] || typeof designSystemColorScheme === 'object' && !defaultTheme.colorSchemes[designSystemColorScheme == null ? void 0 : designSystemColorScheme.dark]) {
|
|
@@ -155,6 +156,15 @@ export default function createCssVarsProvider(options) {
|
|
|
155
156
|
})();
|
|
156
157
|
|
|
157
158
|
if (key === resolvedDefaultColorScheme) {
|
|
159
|
+
if (excludeVariablesFromRoot) {
|
|
160
|
+
const excludedVariables = {};
|
|
161
|
+
excludeVariablesFromRoot(cssVarPrefix).forEach(cssVar => {
|
|
162
|
+
excludedVariables[cssVar] = css[cssVar];
|
|
163
|
+
delete css[cssVar];
|
|
164
|
+
});
|
|
165
|
+
defaultColorSchemeStyleSheet[`[${attribute}="${key}"]`] = excludedVariables;
|
|
166
|
+
}
|
|
167
|
+
|
|
158
168
|
defaultColorSchemeStyleSheet[`${colorSchemeSelector}, [${attribute}="${key}"]`] = css;
|
|
159
169
|
} else {
|
|
160
170
|
otherColorSchemesStyleSheet[`${colorSchemeSelector === ':root' ? '' : colorSchemeSelector}[${attribute}="${key}"]`] = css;
|
|
@@ -6,7 +6,7 @@ export const DEFAULT_ATTRIBUTE = 'data-color-scheme';
|
|
|
6
6
|
export default function getInitColorSchemeScript(options) {
|
|
7
7
|
const {
|
|
8
8
|
enableColorScheme = true,
|
|
9
|
-
|
|
9
|
+
defaultMode = 'light',
|
|
10
10
|
defaultLightColorScheme = 'light',
|
|
11
11
|
defaultDarkColorScheme = 'dark',
|
|
12
12
|
modeStorageKey = DEFAULT_MODE_STORAGE_KEY,
|
|
@@ -18,10 +18,10 @@ export default function getInitColorSchemeScript(options) {
|
|
|
18
18
|
// eslint-disable-next-line react/no-danger
|
|
19
19
|
dangerouslySetInnerHTML: {
|
|
20
20
|
__html: `(function() { try {
|
|
21
|
-
var mode = localStorage.getItem('${modeStorageKey}');
|
|
21
|
+
var mode = localStorage.getItem('${modeStorageKey}') || '${defaultMode}';
|
|
22
22
|
var cssColorScheme = mode;
|
|
23
23
|
var colorScheme = '';
|
|
24
|
-
if (mode === 'system'
|
|
24
|
+
if (mode === 'system') {
|
|
25
25
|
// handle system mode
|
|
26
26
|
var mql = window.matchMedia('(prefers-color-scheme: dark)');
|
|
27
27
|
if (mql.matches) {
|
package/index.js
CHANGED
package/index.spec.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -206,7 +206,7 @@ export function hslToRgb(color) {
|
|
|
206
206
|
|
|
207
207
|
export function getLuminance(color) {
|
|
208
208
|
color = decomposeColor(color);
|
|
209
|
-
var rgb = color.type === 'hsl' ? decomposeColor(hslToRgb(color)).values : color.values;
|
|
209
|
+
var rgb = color.type === 'hsl' || color.type === 'hsla' ? decomposeColor(hslToRgb(color)).values : color.values;
|
|
210
210
|
rgb = rgb.map(function (val) {
|
|
211
211
|
if (color.type !== 'color') {
|
|
212
212
|
val /= 255; // normalized
|
|
@@ -32,7 +32,8 @@ export default function createCssVarsProvider(options) {
|
|
|
32
32
|
_options$enableColorS = options.enableColorScheme,
|
|
33
33
|
designSystemEnableColorScheme = _options$enableColorS === void 0 ? true : _options$enableColorS,
|
|
34
34
|
designSystemShouldSkipGeneratingVar = options.shouldSkipGeneratingVar,
|
|
35
|
-
resolveTheme = options.resolveTheme
|
|
35
|
+
resolveTheme = options.resolveTheme,
|
|
36
|
+
excludeVariablesFromRoot = options.excludeVariablesFromRoot;
|
|
36
37
|
|
|
37
38
|
if (!defaultTheme.colorSchemes || typeof designSystemColorScheme === 'string' && !defaultTheme.colorSchemes[designSystemColorScheme] || _typeof(designSystemColorScheme) === 'object' && !defaultTheme.colorSchemes[designSystemColorScheme == null ? void 0 : designSystemColorScheme.light] || _typeof(designSystemColorScheme) === 'object' && !defaultTheme.colorSchemes[designSystemColorScheme == null ? void 0 : designSystemColorScheme.dark]) {
|
|
38
39
|
console.error("MUI: `".concat(designSystemColorScheme, "` does not exist in `theme.colorSchemes`."));
|
|
@@ -181,6 +182,15 @@ export default function createCssVarsProvider(options) {
|
|
|
181
182
|
}();
|
|
182
183
|
|
|
183
184
|
if (key === resolvedDefaultColorScheme) {
|
|
185
|
+
if (excludeVariablesFromRoot) {
|
|
186
|
+
var excludedVariables = {};
|
|
187
|
+
excludeVariablesFromRoot(cssVarPrefix).forEach(function (cssVar) {
|
|
188
|
+
excludedVariables[cssVar] = css[cssVar];
|
|
189
|
+
delete css[cssVar];
|
|
190
|
+
});
|
|
191
|
+
defaultColorSchemeStyleSheet["[".concat(attribute, "=\"").concat(key, "\"]")] = excludedVariables;
|
|
192
|
+
}
|
|
193
|
+
|
|
184
194
|
defaultColorSchemeStyleSheet["".concat(colorSchemeSelector, ", [").concat(attribute, "=\"").concat(key, "\"]")] = css;
|
|
185
195
|
} else {
|
|
186
196
|
otherColorSchemesStyleSheet["".concat(colorSchemeSelector === ':root' ? '' : colorSchemeSelector, "[").concat(attribute, "=\"").concat(key, "\"]")] = css;
|
|
@@ -7,8 +7,8 @@ export default function getInitColorSchemeScript(options) {
|
|
|
7
7
|
var _ref = options || {},
|
|
8
8
|
_ref$enableColorSchem = _ref.enableColorScheme,
|
|
9
9
|
enableColorScheme = _ref$enableColorSchem === void 0 ? true : _ref$enableColorSchem,
|
|
10
|
-
_ref$
|
|
11
|
-
|
|
10
|
+
_ref$defaultMode = _ref.defaultMode,
|
|
11
|
+
defaultMode = _ref$defaultMode === void 0 ? 'light' : _ref$defaultMode,
|
|
12
12
|
_ref$defaultLightColo = _ref.defaultLightColorScheme,
|
|
13
13
|
defaultLightColorScheme = _ref$defaultLightColo === void 0 ? 'light' : _ref$defaultLightColo,
|
|
14
14
|
_ref$defaultDarkColor = _ref.defaultDarkColorScheme,
|
|
@@ -25,7 +25,7 @@ export default function getInitColorSchemeScript(options) {
|
|
|
25
25
|
return /*#__PURE__*/_jsx("script", {
|
|
26
26
|
// eslint-disable-next-line react/no-danger
|
|
27
27
|
dangerouslySetInnerHTML: {
|
|
28
|
-
__html: "(function() { try {\n var mode = localStorage.getItem('".concat(modeStorageKey, "');\n var cssColorScheme = mode;\n var colorScheme = '';\n if (mode === 'system'
|
|
28
|
+
__html: "(function() { try {\n var mode = localStorage.getItem('".concat(modeStorageKey, "') || '").concat(defaultMode, "';\n var cssColorScheme = mode;\n var colorScheme = '';\n if (mode === 'system') {\n // handle system mode\n var mql = window.matchMedia('(prefers-color-scheme: dark)');\n if (mql.matches) {\n cssColorScheme = 'dark';\n colorScheme = localStorage.getItem('").concat(colorSchemeStorageKey, "-dark') || '").concat(defaultDarkColorScheme, "';\n } else {\n cssColorScheme = 'light';\n colorScheme = localStorage.getItem('").concat(colorSchemeStorageKey, "-light') || '").concat(defaultLightColorScheme, "';\n }\n }\n if (mode === 'light') {\n colorScheme = localStorage.getItem('").concat(colorSchemeStorageKey, "-light') || '").concat(defaultLightColorScheme, "';\n }\n if (mode === 'dark') {\n colorScheme = localStorage.getItem('").concat(colorSchemeStorageKey, "-dark') || '").concat(defaultDarkColorScheme, "';\n }\n if (colorScheme) {\n ").concat(colorSchemeNode, ".setAttribute('").concat(attribute, "', colorScheme);\n }\n if (").concat(enableColorScheme, " && !!cssColorScheme) {\n ").concat(colorSchemeNode, ".style.setProperty('color-scheme', cssColorScheme);\n }\n } catch (e) {} })();")
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
31
|
}
|
package/legacy/index.js
CHANGED
|
@@ -197,7 +197,7 @@ export function hslToRgb(color) {
|
|
|
197
197
|
|
|
198
198
|
export function getLuminance(color) {
|
|
199
199
|
color = decomposeColor(color);
|
|
200
|
-
let rgb = color.type === 'hsl' ? decomposeColor(hslToRgb(color)).values : color.values;
|
|
200
|
+
let rgb = color.type === 'hsl' || color.type === 'hsla' ? decomposeColor(hslToRgb(color)).values : color.values;
|
|
201
201
|
rgb = rgb.map(val => {
|
|
202
202
|
if (color.type !== 'color') {
|
|
203
203
|
val /= 255; // normalized
|
|
@@ -24,7 +24,8 @@ export default function createCssVarsProvider(options) {
|
|
|
24
24
|
disableTransitionOnChange: designSystemTransitionOnChange = false,
|
|
25
25
|
enableColorScheme: designSystemEnableColorScheme = true,
|
|
26
26
|
shouldSkipGeneratingVar: designSystemShouldSkipGeneratingVar,
|
|
27
|
-
resolveTheme
|
|
27
|
+
resolveTheme,
|
|
28
|
+
excludeVariablesFromRoot
|
|
28
29
|
} = options;
|
|
29
30
|
|
|
30
31
|
if (!defaultTheme.colorSchemes || typeof designSystemColorScheme === 'string' && !defaultTheme.colorSchemes[designSystemColorScheme] || typeof designSystemColorScheme === 'object' && !defaultTheme.colorSchemes[designSystemColorScheme?.light] || typeof designSystemColorScheme === 'object' && !defaultTheme.colorSchemes[designSystemColorScheme?.dark]) {
|
|
@@ -155,6 +156,15 @@ export default function createCssVarsProvider(options) {
|
|
|
155
156
|
})();
|
|
156
157
|
|
|
157
158
|
if (key === resolvedDefaultColorScheme) {
|
|
159
|
+
if (excludeVariablesFromRoot) {
|
|
160
|
+
const excludedVariables = {};
|
|
161
|
+
excludeVariablesFromRoot(cssVarPrefix).forEach(cssVar => {
|
|
162
|
+
excludedVariables[cssVar] = css[cssVar];
|
|
163
|
+
delete css[cssVar];
|
|
164
|
+
});
|
|
165
|
+
defaultColorSchemeStyleSheet[`[${attribute}="${key}"]`] = excludedVariables;
|
|
166
|
+
}
|
|
167
|
+
|
|
158
168
|
defaultColorSchemeStyleSheet[`${colorSchemeSelector}, [${attribute}="${key}"]`] = css;
|
|
159
169
|
} else {
|
|
160
170
|
otherColorSchemesStyleSheet[`${colorSchemeSelector === ':root' ? '' : colorSchemeSelector}[${attribute}="${key}"]`] = css;
|
|
@@ -6,7 +6,7 @@ export const DEFAULT_ATTRIBUTE = 'data-color-scheme';
|
|
|
6
6
|
export default function getInitColorSchemeScript(options) {
|
|
7
7
|
const {
|
|
8
8
|
enableColorScheme = true,
|
|
9
|
-
|
|
9
|
+
defaultMode = 'light',
|
|
10
10
|
defaultLightColorScheme = 'light',
|
|
11
11
|
defaultDarkColorScheme = 'dark',
|
|
12
12
|
modeStorageKey = DEFAULT_MODE_STORAGE_KEY,
|
|
@@ -18,10 +18,10 @@ export default function getInitColorSchemeScript(options) {
|
|
|
18
18
|
// eslint-disable-next-line react/no-danger
|
|
19
19
|
dangerouslySetInnerHTML: {
|
|
20
20
|
__html: `(function() { try {
|
|
21
|
-
var mode = localStorage.getItem('${modeStorageKey}');
|
|
21
|
+
var mode = localStorage.getItem('${modeStorageKey}') || '${defaultMode}';
|
|
22
22
|
var cssColorScheme = mode;
|
|
23
23
|
var colorScheme = '';
|
|
24
|
-
if (mode === 'system'
|
|
24
|
+
if (mode === 'system') {
|
|
25
25
|
// handle system mode
|
|
26
26
|
var mql = window.matchMedia('(prefers-color-scheme: dark)');
|
|
27
27
|
if (mql.matches) {
|
package/modern/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/system",
|
|
3
|
-
"version": "5.10.
|
|
3
|
+
"version": "5.10.7",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"description": "CSS utilities for rapidly laying out custom designs.",
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@babel/runtime": "^7.19.0",
|
|
47
47
|
"@mui/private-theming": "^5.10.6",
|
|
48
|
-
"@mui/styled-engine": "^5.10.
|
|
48
|
+
"@mui/styled-engine": "^5.10.7",
|
|
49
49
|
"@mui/types": "^7.2.0",
|
|
50
50
|
"@mui/utils": "^5.10.6",
|
|
51
51
|
"clsx": "^1.2.1",
|
|
52
|
-
"csstype": "^3.1.
|
|
52
|
+
"csstype": "^3.1.1",
|
|
53
53
|
"prop-types": "^15.8.1"
|
|
54
54
|
},
|
|
55
55
|
"sideEffects": false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|