@mui/system 5.14.3 → 5.14.4
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.d.ts +20 -9
- package/CHANGELOG.md +102 -4
- 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/GlobalStyles/GlobalStyles.d.ts +13 -13
- package/GlobalStyles/index.d.ts +2 -2
- package/Stack/Stack.d.ts +14 -14
- package/Stack/StackProps.d.ts +53 -53
- 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 +185 -185
- package/Unstable_Grid/createGrid.d.ts +11 -11
- package/Unstable_Grid/gridClasses.d.ts +20 -20
- package/Unstable_Grid/gridGenerator.d.ts +33 -33
- package/Unstable_Grid/index.d.ts +6 -6
- package/Unstable_Grid/traverseBreakpoints.d.ts +7 -7
- package/createStyled.d.ts +6 -6
- package/createStyled.js +23 -4
- package/createTheme/createSpacing.d.ts +10 -10
- package/cssVars/createCssVarsTheme.d.ts +15 -15
- package/cssVars/createGetCssVar.d.ts +5 -5
- package/cssVars/cssVarsParser.d.ts +64 -64
- package/cssVars/getInitColorSchemeScript.d.ts +42 -42
- package/cssVars/index.d.ts +5 -5
- package/cssVars/prepareCssVars.d.ts +16 -16
- package/cssVars/useCurrentColorScheme.d.ts +53 -53
- package/esm/createStyled.js +24 -5
- package/esm/styleFunctionSx/styleFunctionSx.js +2 -0
- package/index.js +1 -1
- package/legacy/createStyled.js +25 -5
- package/legacy/index.js +1 -1
- package/legacy/styleFunctionSx/styleFunctionSx.js +2 -0
- package/modern/createStyled.js +24 -5
- package/modern/index.js +1 -1
- package/modern/styleFunctionSx/styleFunctionSx.js +2 -0
- package/package.json +3 -3
- package/styleFunctionSx/styleFunctionSx.js +2 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export type SpacingOptions = number | Spacing | ((abs: number) => number | string) | ((abs: number | string) => number | string) | ReadonlyArray<string | number>;
|
|
2
|
-
export type SpacingArgument = number | string;
|
|
3
|
-
export interface Spacing {
|
|
4
|
-
(): string;
|
|
5
|
-
(value: number): string;
|
|
6
|
-
(topBottom: SpacingArgument, rightLeft: SpacingArgument): string;
|
|
7
|
-
(top: SpacingArgument, rightLeft: SpacingArgument, bottom: SpacingArgument): string;
|
|
8
|
-
(top: SpacingArgument, right: SpacingArgument, bottom: SpacingArgument, left: SpacingArgument): string;
|
|
9
|
-
}
|
|
10
|
-
export default function createSpacing(spacingInput?: SpacingOptions): Spacing;
|
|
1
|
+
export type SpacingOptions = number | Spacing | ((abs: number) => number | string) | ((abs: number | string) => number | string) | ReadonlyArray<string | number>;
|
|
2
|
+
export type SpacingArgument = number | string;
|
|
3
|
+
export interface Spacing {
|
|
4
|
+
(): string;
|
|
5
|
+
(value: number): string;
|
|
6
|
+
(topBottom: SpacingArgument, rightLeft: SpacingArgument): string;
|
|
7
|
+
(top: SpacingArgument, rightLeft: SpacingArgument, bottom: SpacingArgument): string;
|
|
8
|
+
(top: SpacingArgument, right: SpacingArgument, bottom: SpacingArgument, left: SpacingArgument): string;
|
|
9
|
+
}
|
|
10
|
+
export default function createSpacing(spacingInput?: SpacingOptions): Spacing;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { DefaultCssVarsTheme } from './prepareCssVars';
|
|
2
|
-
interface Theme extends DefaultCssVarsTheme {
|
|
3
|
-
cssVarPrefix?: string;
|
|
4
|
-
shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean;
|
|
5
|
-
}
|
|
6
|
-
declare function createCssVarsTheme<T extends Theme, ThemeVars extends Record<string, any>>(theme: T): T & {
|
|
7
|
-
vars: ThemeVars;
|
|
8
|
-
generateCssVars: (colorScheme?: string | undefined) => {
|
|
9
|
-
css: {
|
|
10
|
-
[x: string]: string | number;
|
|
11
|
-
};
|
|
12
|
-
vars: ThemeVars;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
export default createCssVarsTheme;
|
|
1
|
+
import { DefaultCssVarsTheme } from './prepareCssVars';
|
|
2
|
+
interface Theme extends DefaultCssVarsTheme {
|
|
3
|
+
cssVarPrefix?: string;
|
|
4
|
+
shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean;
|
|
5
|
+
}
|
|
6
|
+
declare function createCssVarsTheme<T extends Theme, ThemeVars extends Record<string, any>>(theme: T): T & {
|
|
7
|
+
vars: ThemeVars;
|
|
8
|
+
generateCssVars: (colorScheme?: string | undefined) => {
|
|
9
|
+
css: {
|
|
10
|
+
[x: string]: string | number;
|
|
11
|
+
};
|
|
12
|
+
vars: ThemeVars;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export default createCssVarsTheme;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The benefit of this function is to help developers get CSS var from theme without specifying the whole variable
|
|
3
|
-
* and they does not need to remember the prefix (defined once).
|
|
4
|
-
*/
|
|
5
|
-
export default function createGetCssVar<T extends string = string>(prefix?: string): <AdditionalVars extends string = never>(field: T | AdditionalVars, ...fallbacks: (T | AdditionalVars)[]) => string;
|
|
1
|
+
/**
|
|
2
|
+
* The benefit of this function is to help developers get CSS var from theme without specifying the whole variable
|
|
3
|
+
* and they does not need to remember the prefix (defined once).
|
|
4
|
+
*/
|
|
5
|
+
export default function createGetCssVar<T extends string = string>(prefix?: string): <AdditionalVars extends string = never>(field: T | AdditionalVars, ...fallbacks: (T | AdditionalVars)[]) => string;
|
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
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 }} `css` is the stylesheet, `vars` is an object to get css variable (same structure as theme).
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* const { css, vars } = 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
|
-
*/
|
|
56
|
-
export default function cssVarsParser<T extends Record<string, any>>(theme: Record<string, any>, options?: {
|
|
57
|
-
prefix?: string;
|
|
58
|
-
shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean;
|
|
59
|
-
}): {
|
|
60
|
-
css: Record<string, string | number>;
|
|
61
|
-
vars: T;
|
|
62
|
-
varsWithDefaults: {};
|
|
63
|
-
};
|
|
64
|
-
export {};
|
|
1
|
+
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 }} `css` is the stylesheet, `vars` is an object to get css variable (same structure as theme).
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* const { css, vars } = 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
|
+
*/
|
|
56
|
+
export default function cssVarsParser<T extends Record<string, any>>(theme: Record<string, any>, options?: {
|
|
57
|
+
prefix?: string;
|
|
58
|
+
shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean;
|
|
59
|
+
}): {
|
|
60
|
+
css: Record<string, string | number>;
|
|
61
|
+
vars: T;
|
|
62
|
+
varsWithDefaults: {};
|
|
63
|
+
};
|
|
64
|
+
export {};
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import * as React from '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
|
-
* The mode to be used for the first visit
|
|
8
|
-
* @default 'light'
|
|
9
|
-
*/
|
|
10
|
-
defaultMode?: 'light' | 'dark' | 'system';
|
|
11
|
-
/**
|
|
12
|
-
* The default color scheme to be used on the light mode
|
|
13
|
-
* @default 'light'
|
|
14
|
-
*/
|
|
15
|
-
defaultLightColorScheme?: string;
|
|
16
|
-
/**
|
|
17
|
-
* The default color scheme to be used on the dark mode
|
|
18
|
-
* * @default 'dark'
|
|
19
|
-
*/
|
|
20
|
-
defaultDarkColorScheme?: string;
|
|
21
|
-
/**
|
|
22
|
-
* The node (provided as string) used to attach the color-scheme attribute
|
|
23
|
-
* @default 'document.documentElement'
|
|
24
|
-
*/
|
|
25
|
-
colorSchemeNode?: string;
|
|
26
|
-
/**
|
|
27
|
-
* localStorage key used to store `mode`
|
|
28
|
-
* @default 'mode'
|
|
29
|
-
*/
|
|
30
|
-
modeStorageKey?: string;
|
|
31
|
-
/**
|
|
32
|
-
* localStorage key used to store `colorScheme`
|
|
33
|
-
* @default 'color-scheme'
|
|
34
|
-
*/
|
|
35
|
-
colorSchemeStorageKey?: string;
|
|
36
|
-
/**
|
|
37
|
-
* DOM attribute for applying color scheme
|
|
38
|
-
* @default 'data-color-scheme'
|
|
39
|
-
*/
|
|
40
|
-
attribute?: string;
|
|
41
|
-
}
|
|
42
|
-
export default function getInitColorSchemeScript(options?: GetInitColorSchemeScriptOptions): React.JSX.Element;
|
|
1
|
+
import * as React from '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
|
+
* The mode to be used for the first visit
|
|
8
|
+
* @default 'light'
|
|
9
|
+
*/
|
|
10
|
+
defaultMode?: 'light' | 'dark' | 'system';
|
|
11
|
+
/**
|
|
12
|
+
* The default color scheme to be used on the light mode
|
|
13
|
+
* @default 'light'
|
|
14
|
+
*/
|
|
15
|
+
defaultLightColorScheme?: string;
|
|
16
|
+
/**
|
|
17
|
+
* The default color scheme to be used on the dark mode
|
|
18
|
+
* * @default 'dark'
|
|
19
|
+
*/
|
|
20
|
+
defaultDarkColorScheme?: string;
|
|
21
|
+
/**
|
|
22
|
+
* The node (provided as string) used to attach the color-scheme attribute
|
|
23
|
+
* @default 'document.documentElement'
|
|
24
|
+
*/
|
|
25
|
+
colorSchemeNode?: string;
|
|
26
|
+
/**
|
|
27
|
+
* localStorage key used to store `mode`
|
|
28
|
+
* @default 'mode'
|
|
29
|
+
*/
|
|
30
|
+
modeStorageKey?: string;
|
|
31
|
+
/**
|
|
32
|
+
* localStorage key used to store `colorScheme`
|
|
33
|
+
* @default 'color-scheme'
|
|
34
|
+
*/
|
|
35
|
+
colorSchemeStorageKey?: string;
|
|
36
|
+
/**
|
|
37
|
+
* DOM attribute for applying color scheme
|
|
38
|
+
* @default 'data-color-scheme'
|
|
39
|
+
*/
|
|
40
|
+
attribute?: string;
|
|
41
|
+
}
|
|
42
|
+
export default function getInitColorSchemeScript(options?: GetInitColorSchemeScriptOptions): React.JSX.Element;
|
package/cssVars/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { default } from './createCssVarsProvider';
|
|
2
|
-
export type { CreateCssVarsProviderResult, CssVarsProviderConfig, ColorSchemeContextValue, } from './createCssVarsProvider';
|
|
3
|
-
export { default as getInitColorSchemeScript } from './getInitColorSchemeScript';
|
|
4
|
-
export { default as prepareCssVars } from './prepareCssVars';
|
|
5
|
-
export { default as createCssVarsTheme } from './createCssVarsTheme';
|
|
1
|
+
export { default } from './createCssVarsProvider';
|
|
2
|
+
export type { CreateCssVarsProviderResult, CssVarsProviderConfig, ColorSchemeContextValue, } from './createCssVarsProvider';
|
|
3
|
+
export { default as getInitColorSchemeScript } from './getInitColorSchemeScript';
|
|
4
|
+
export { default as prepareCssVars } from './prepareCssVars';
|
|
5
|
+
export { default as createCssVarsTheme } from './createCssVarsTheme';
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export interface DefaultCssVarsTheme {
|
|
2
|
-
colorSchemes: Record<string, any>;
|
|
3
|
-
}
|
|
4
|
-
declare function prepareCssVars<T extends DefaultCssVarsTheme, ThemeVars extends Record<string, any>>(theme: T, parserConfig?: {
|
|
5
|
-
prefix?: string;
|
|
6
|
-
shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean;
|
|
7
|
-
}): {
|
|
8
|
-
vars: ThemeVars;
|
|
9
|
-
generateCssVars: (colorScheme?: string) => {
|
|
10
|
-
css: {
|
|
11
|
-
[x: string]: string | number;
|
|
12
|
-
};
|
|
13
|
-
vars: ThemeVars;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
export default prepareCssVars;
|
|
1
|
+
export interface DefaultCssVarsTheme {
|
|
2
|
+
colorSchemes: Record<string, any>;
|
|
3
|
+
}
|
|
4
|
+
declare function prepareCssVars<T extends DefaultCssVarsTheme, ThemeVars extends Record<string, any>>(theme: T, parserConfig?: {
|
|
5
|
+
prefix?: string;
|
|
6
|
+
shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean;
|
|
7
|
+
}): {
|
|
8
|
+
vars: ThemeVars;
|
|
9
|
+
generateCssVars: (colorScheme?: string) => {
|
|
10
|
+
css: {
|
|
11
|
+
[x: string]: string | number;
|
|
12
|
+
};
|
|
13
|
+
vars: ThemeVars;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export default prepareCssVars;
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
export type Mode = 'light' | 'dark' | 'system';
|
|
2
|
-
export 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 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 type Mode = 'light' | 'dark' | 'system';
|
|
2
|
+
export 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 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/createStyled.js
CHANGED
|
@@ -3,7 +3,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
3
3
|
const _excluded = ["name", "slot", "skipVariantsResolver", "skipSx", "overridesResolver"];
|
|
4
4
|
/* eslint-disable no-underscore-dangle */
|
|
5
5
|
import styledEngineStyled, { internal_processStyles as processStyles } from '@mui/styled-engine';
|
|
6
|
-
import { getDisplayName } from '@mui/utils';
|
|
6
|
+
import { getDisplayName, unstable_capitalize as capitalize } from '@mui/utils';
|
|
7
7
|
import createTheme from './createTheme';
|
|
8
8
|
import propsToClassKey from './propsToClassKey';
|
|
9
9
|
import styleFunctionSx from './styleFunctionSx';
|
|
@@ -66,6 +66,9 @@ export function shouldForwardProp(prop) {
|
|
|
66
66
|
}
|
|
67
67
|
export const systemDefaultTheme = createTheme();
|
|
68
68
|
const lowercaseFirstLetter = string => {
|
|
69
|
+
if (!string) {
|
|
70
|
+
return string;
|
|
71
|
+
}
|
|
69
72
|
return string.charAt(0).toLowerCase() + string.slice(1);
|
|
70
73
|
};
|
|
71
74
|
function resolveTheme({
|
|
@@ -75,6 +78,12 @@ function resolveTheme({
|
|
|
75
78
|
}) {
|
|
76
79
|
return isEmpty(theme) ? defaultTheme : theme[themeId] || theme;
|
|
77
80
|
}
|
|
81
|
+
function defaultOverridesResolver(slot) {
|
|
82
|
+
if (!slot) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
return (props, styles) => styles[slot];
|
|
86
|
+
}
|
|
78
87
|
export default function createStyled(input = {}) {
|
|
79
88
|
const {
|
|
80
89
|
themeId,
|
|
@@ -99,21 +108,31 @@ export default function createStyled(input = {}) {
|
|
|
99
108
|
slot: componentSlot,
|
|
100
109
|
skipVariantsResolver: inputSkipVariantsResolver,
|
|
101
110
|
skipSx: inputSkipSx,
|
|
102
|
-
|
|
111
|
+
// TODO v6: remove `lowercaseFirstLetter()` in the next major release
|
|
112
|
+
// For more details: https://github.com/mui/material-ui/pull/37908
|
|
113
|
+
overridesResolver = defaultOverridesResolver(lowercaseFirstLetter(componentSlot))
|
|
103
114
|
} = inputOptions,
|
|
104
115
|
options = _objectWithoutPropertiesLoose(inputOptions, _excluded);
|
|
105
116
|
|
|
106
117
|
// if skipVariantsResolver option is defined, take the value, otherwise, true for root and false for other slots.
|
|
107
|
-
const skipVariantsResolver = inputSkipVariantsResolver !== undefined ? inputSkipVariantsResolver :
|
|
118
|
+
const skipVariantsResolver = inputSkipVariantsResolver !== undefined ? inputSkipVariantsResolver :
|
|
119
|
+
// TODO v6: remove `Root` in the next major release
|
|
120
|
+
// For more details: https://github.com/mui/material-ui/pull/37908
|
|
121
|
+
componentSlot && componentSlot !== 'Root' && componentSlot !== 'root' || false;
|
|
108
122
|
const skipSx = inputSkipSx || false;
|
|
109
123
|
let label;
|
|
110
124
|
if (process.env.NODE_ENV !== 'production') {
|
|
111
125
|
if (componentName) {
|
|
126
|
+
// TODO v6: remove `lowercaseFirstLetter()` in the next major release
|
|
127
|
+
// For more details: https://github.com/mui/material-ui/pull/37908
|
|
112
128
|
label = `${componentName}-${lowercaseFirstLetter(componentSlot || 'Root')}`;
|
|
113
129
|
}
|
|
114
130
|
}
|
|
115
131
|
let shouldForwardPropOption = shouldForwardProp;
|
|
116
|
-
|
|
132
|
+
|
|
133
|
+
// TODO v6: remove `Root` in the next major release
|
|
134
|
+
// For more details: https://github.com/mui/material-ui/pull/37908
|
|
135
|
+
if (componentSlot === 'Root' || componentSlot === 'root') {
|
|
117
136
|
shouldForwardPropOption = rootShouldForwardProp;
|
|
118
137
|
} else if (componentSlot) {
|
|
119
138
|
// any other slot specified
|
|
@@ -195,7 +214,7 @@ export default function createStyled(input = {}) {
|
|
|
195
214
|
if (process.env.NODE_ENV !== 'production') {
|
|
196
215
|
let displayName;
|
|
197
216
|
if (componentName) {
|
|
198
|
-
displayName = `${componentName}${componentSlot || ''}`;
|
|
217
|
+
displayName = `${componentName}${capitalize(componentSlot || '')}`;
|
|
199
218
|
}
|
|
200
219
|
if (displayName === undefined) {
|
|
201
220
|
displayName = `Styled(${getDisplayName(tag)})`;
|
package/index.js
CHANGED
package/legacy/createStyled.js
CHANGED
|
@@ -4,7 +4,7 @@ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutPr
|
|
|
4
4
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
5
5
|
/* eslint-disable no-underscore-dangle */
|
|
6
6
|
import styledEngineStyled, { internal_processStyles as processStyles } from '@mui/styled-engine';
|
|
7
|
-
import { getDisplayName } from '@mui/utils';
|
|
7
|
+
import { getDisplayName, unstable_capitalize as capitalize } from '@mui/utils';
|
|
8
8
|
import createTheme from './createTheme';
|
|
9
9
|
import propsToClassKey from './propsToClassKey';
|
|
10
10
|
import styleFunctionSx from './styleFunctionSx';
|
|
@@ -66,6 +66,9 @@ export function shouldForwardProp(prop) {
|
|
|
66
66
|
}
|
|
67
67
|
export var systemDefaultTheme = createTheme();
|
|
68
68
|
var lowercaseFirstLetter = function lowercaseFirstLetter(string) {
|
|
69
|
+
if (!string) {
|
|
70
|
+
return string;
|
|
71
|
+
}
|
|
69
72
|
return string.charAt(0).toLowerCase() + string.slice(1);
|
|
70
73
|
};
|
|
71
74
|
function resolveTheme(_ref) {
|
|
@@ -74,6 +77,14 @@ function resolveTheme(_ref) {
|
|
|
74
77
|
themeId = _ref.themeId;
|
|
75
78
|
return isEmpty(theme) ? defaultTheme : theme[themeId] || theme;
|
|
76
79
|
}
|
|
80
|
+
function defaultOverridesResolver(slot) {
|
|
81
|
+
if (!slot) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
return function (props, styles) {
|
|
85
|
+
return styles[slot];
|
|
86
|
+
};
|
|
87
|
+
}
|
|
77
88
|
export default function createStyled() {
|
|
78
89
|
var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
79
90
|
var themeId = input.themeId,
|
|
@@ -104,18 +115,27 @@ export default function createStyled() {
|
|
|
104
115
|
componentSlot = inputOptions.slot,
|
|
105
116
|
inputSkipVariantsResolver = inputOptions.skipVariantsResolver,
|
|
106
117
|
inputSkipSx = inputOptions.skipSx,
|
|
107
|
-
|
|
118
|
+
_inputOptions$overrid = inputOptions.overridesResolver,
|
|
119
|
+
overridesResolver = _inputOptions$overrid === void 0 ? defaultOverridesResolver(lowercaseFirstLetter(componentSlot)) : _inputOptions$overrid,
|
|
108
120
|
options = _objectWithoutProperties(inputOptions, ["name", "slot", "skipVariantsResolver", "skipSx", "overridesResolver"]); // if skipVariantsResolver option is defined, take the value, otherwise, true for root and false for other slots.
|
|
109
|
-
var skipVariantsResolver = inputSkipVariantsResolver !== undefined ? inputSkipVariantsResolver :
|
|
121
|
+
var skipVariantsResolver = inputSkipVariantsResolver !== undefined ? inputSkipVariantsResolver :
|
|
122
|
+
// TODO v6: remove `Root` in the next major release
|
|
123
|
+
// For more details: https://github.com/mui/material-ui/pull/37908
|
|
124
|
+
componentSlot && componentSlot !== 'Root' && componentSlot !== 'root' || false;
|
|
110
125
|
var skipSx = inputSkipSx || false;
|
|
111
126
|
var label;
|
|
112
127
|
if (process.env.NODE_ENV !== 'production') {
|
|
113
128
|
if (componentName) {
|
|
129
|
+
// TODO v6: remove `lowercaseFirstLetter()` in the next major release
|
|
130
|
+
// For more details: https://github.com/mui/material-ui/pull/37908
|
|
114
131
|
label = "".concat(componentName, "-").concat(lowercaseFirstLetter(componentSlot || 'Root'));
|
|
115
132
|
}
|
|
116
133
|
}
|
|
117
134
|
var shouldForwardPropOption = shouldForwardProp;
|
|
118
|
-
|
|
135
|
+
|
|
136
|
+
// TODO v6: remove `Root` in the next major release
|
|
137
|
+
// For more details: https://github.com/mui/material-ui/pull/37908
|
|
138
|
+
if (componentSlot === 'Root' || componentSlot === 'root') {
|
|
119
139
|
shouldForwardPropOption = rootShouldForwardProp;
|
|
120
140
|
} else if (componentSlot) {
|
|
121
141
|
// any other slot specified
|
|
@@ -205,7 +225,7 @@ export default function createStyled() {
|
|
|
205
225
|
if (process.env.NODE_ENV !== 'production') {
|
|
206
226
|
var displayName;
|
|
207
227
|
if (componentName) {
|
|
208
|
-
displayName = "".concat(componentName).concat(componentSlot || '');
|
|
228
|
+
displayName = "".concat(componentName).concat(capitalize(componentSlot || ''));
|
|
209
229
|
}
|
|
210
230
|
if (displayName === undefined) {
|
|
211
231
|
displayName = "Styled(".concat(getDisplayName(tag), ")");
|
package/legacy/index.js
CHANGED
|
@@ -38,6 +38,8 @@ export function unstable_createStyleFunctionSx() {
|
|
|
38
38
|
if (val == null) {
|
|
39
39
|
return null;
|
|
40
40
|
}
|
|
41
|
+
|
|
42
|
+
// TODO v6: remove, see https://github.com/mui/material-ui/pull/38123
|
|
41
43
|
if (themeKey === 'typography' && val === 'inherit') {
|
|
42
44
|
return _defineProperty({}, prop, val);
|
|
43
45
|
}
|