@mui/system 5.11.7 → 5.11.9
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 +128 -1
- 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 +173 -162
- package/Unstable_Grid/createGrid.d.ts +11 -11
- package/Unstable_Grid/createGrid.js +10 -10
- package/Unstable_Grid/gridClasses.d.ts +20 -20
- package/Unstable_Grid/gridGenerator.d.ts +33 -29
- package/Unstable_Grid/gridGenerator.js +40 -18
- package/Unstable_Grid/index.d.ts +5 -5
- package/createBox.spec.d.ts +1 -1
- package/createTheme/createSpacing.d.ts +10 -10
- package/cssVars/createCssVarsProvider.js +7 -7
- package/cssVars/createCssVarsProvider.spec.d.ts +1 -1
- package/cssVars/createGetCssVar.d.ts +5 -5
- package/cssVars/cssVarsParser.d.ts +63 -63
- package/cssVars/getInitColorSchemeScript.d.ts +42 -42
- package/cssVars/index.d.ts +3 -3
- package/cssVars/useCurrentColorScheme.d.ts +53 -53
- package/esm/Unstable_Grid/createGrid.js +10 -10
- package/esm/Unstable_Grid/gridGenerator.js +40 -18
- package/esm/cssVars/createCssVarsProvider.js +7 -7
- package/index.js +1 -1
- package/index.spec.d.ts +1 -1
- package/legacy/Unstable_Grid/createGrid.js +10 -10
- package/legacy/Unstable_Grid/gridGenerator.js +53 -42
- package/legacy/cssVars/createCssVarsProvider.js +7 -7
- package/legacy/index.js +1 -1
- package/modern/Unstable_Grid/createGrid.js +10 -10
- package/modern/Unstable_Grid/gridGenerator.js +40 -18
- package/modern/cssVars/createCssVarsProvider.js +7 -7
- package/modern/index.js +1 -1
- package/package.json +5 -5
- package/styleFunctionSx/styleFunctionSx.spec.d.ts +1 -1
package/Unstable_Grid/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { default } from './Grid';
|
|
2
|
-
export { default as createGrid } from './createGrid';
|
|
3
|
-
export * from './GridProps';
|
|
4
|
-
export { default as gridClasses } from './gridClasses';
|
|
5
|
-
export * from './gridClasses';
|
|
1
|
+
export { default } from './Grid';
|
|
2
|
+
export { default as createGrid } from './createGrid';
|
|
3
|
+
export * from './GridProps';
|
|
4
|
+
export { default as gridClasses } from './gridClasses';
|
|
5
|
+
export * from './gridClasses';
|
package/createBox.spec.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -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;
|
|
@@ -103,14 +103,14 @@ function createCssVarsProvider(options) {
|
|
|
103
103
|
colorScheme = ctx.colorScheme;
|
|
104
104
|
}
|
|
105
105
|
const calculatedMode = (() => {
|
|
106
|
-
if (
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
return
|
|
106
|
+
if (mode) {
|
|
107
|
+
return mode;
|
|
108
|
+
}
|
|
109
|
+
// This scope occurs on the server
|
|
110
|
+
if (defaultMode === 'system') {
|
|
111
|
+
return designSystemMode;
|
|
112
112
|
}
|
|
113
|
-
return
|
|
113
|
+
return defaultMode;
|
|
114
114
|
})();
|
|
115
115
|
const calculatedColorScheme = (() => {
|
|
116
116
|
if (!colorScheme) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -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,63 +1,63 @@
|
|
|
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: T, options?: {
|
|
57
|
-
prefix?: string;
|
|
58
|
-
shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean;
|
|
59
|
-
}): {
|
|
60
|
-
css: Record<string, string | number>;
|
|
61
|
-
vars: NestedRecord<string>;
|
|
62
|
-
};
|
|
63
|
-
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: T, options?: {
|
|
57
|
+
prefix?: string;
|
|
58
|
+
shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean;
|
|
59
|
+
}): {
|
|
60
|
+
css: Record<string, string | number>;
|
|
61
|
+
vars: NestedRecord<string>;
|
|
62
|
+
};
|
|
63
|
+
export {};
|
|
@@ -1,42 +1,42 @@
|
|
|
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
|
-
* 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): JSX.Element;
|
|
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
|
+
* 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): JSX.Element;
|
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 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 {};
|
|
@@ -34,7 +34,7 @@ export default function createGrid(options = {}) {
|
|
|
34
34
|
useThemeProps = useThemePropsDefault,
|
|
35
35
|
componentName = 'MuiGrid'
|
|
36
36
|
} = options;
|
|
37
|
-
const NestedContext = /*#__PURE__*/React.createContext(
|
|
37
|
+
const NestedContext = /*#__PURE__*/React.createContext(0);
|
|
38
38
|
const OverflowContext = /*#__PURE__*/React.createContext(undefined);
|
|
39
39
|
const useUtilityClasses = (ownerState, theme) => {
|
|
40
40
|
const {
|
|
@@ -55,7 +55,7 @@ export default function createGrid(options = {}) {
|
|
|
55
55
|
const theme = useTheme();
|
|
56
56
|
const themeProps = useThemeProps(inProps);
|
|
57
57
|
const props = extendSxProp(themeProps); // `color` type conflicts with html color attribute.
|
|
58
|
-
const
|
|
58
|
+
const level = React.useContext(NestedContext);
|
|
59
59
|
const overflow = React.useContext(OverflowContext);
|
|
60
60
|
const {
|
|
61
61
|
className,
|
|
@@ -72,7 +72,7 @@ export default function createGrid(options = {}) {
|
|
|
72
72
|
rest = _objectWithoutPropertiesLoose(props, _excluded);
|
|
73
73
|
// Because `disableEqualOverflow` can be set from the theme's defaultProps, the **nested** grid should look at the instance props instead.
|
|
74
74
|
let disableEqualOverflow = themeDisableEqualOverflow;
|
|
75
|
-
if (
|
|
75
|
+
if (level && themeDisableEqualOverflow !== undefined) {
|
|
76
76
|
disableEqualOverflow = inProps.disableEqualOverflow;
|
|
77
77
|
}
|
|
78
78
|
// collect breakpoints related props because they can be customized from the theme.
|
|
@@ -88,12 +88,12 @@ export default function createGrid(options = {}) {
|
|
|
88
88
|
other[key] = val;
|
|
89
89
|
}
|
|
90
90
|
});
|
|
91
|
-
const columns = (_inProps$columns = inProps.columns) != null ? _inProps$columns :
|
|
92
|
-
const spacing = (_inProps$spacing = inProps.spacing) != null ? _inProps$spacing :
|
|
93
|
-
const rowSpacing = (_ref = (_inProps$rowSpacing = inProps.rowSpacing) != null ? _inProps$rowSpacing : inProps.spacing) != null ? _ref :
|
|
94
|
-
const columnSpacing = (_ref2 = (_inProps$columnSpacin = inProps.columnSpacing) != null ? _inProps$columnSpacin : inProps.spacing) != null ? _ref2 :
|
|
91
|
+
const columns = (_inProps$columns = inProps.columns) != null ? _inProps$columns : level ? undefined : columnsProp;
|
|
92
|
+
const spacing = (_inProps$spacing = inProps.spacing) != null ? _inProps$spacing : level ? undefined : spacingProp;
|
|
93
|
+
const rowSpacing = (_ref = (_inProps$rowSpacing = inProps.rowSpacing) != null ? _inProps$rowSpacing : inProps.spacing) != null ? _ref : level ? undefined : rowSpacingProp;
|
|
94
|
+
const columnSpacing = (_ref2 = (_inProps$columnSpacin = inProps.columnSpacing) != null ? _inProps$columnSpacin : inProps.spacing) != null ? _ref2 : level ? undefined : columnSpacingProp;
|
|
95
95
|
const ownerState = _extends({}, props, {
|
|
96
|
-
|
|
96
|
+
level,
|
|
97
97
|
columns,
|
|
98
98
|
container,
|
|
99
99
|
direction,
|
|
@@ -115,9 +115,9 @@ export default function createGrid(options = {}) {
|
|
|
115
115
|
ownerState: ownerState,
|
|
116
116
|
className: clsx(classes.root, className)
|
|
117
117
|
}, other));
|
|
118
|
-
if (
|
|
118
|
+
if (container) {
|
|
119
119
|
result = /*#__PURE__*/_jsx(NestedContext.Provider, {
|
|
120
|
-
value:
|
|
120
|
+
value: level + 1,
|
|
121
121
|
children: result
|
|
122
122
|
});
|
|
123
123
|
}
|
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
function isNestedContainer(ownerState) {
|
|
3
|
+
return ownerState.level > 0 && ownerState.container;
|
|
4
|
+
}
|
|
5
|
+
function createGetSelfSpacing(ownerState) {
|
|
6
|
+
return function getSelfSpacing(axis) {
|
|
7
|
+
return `var(--Grid-${axis}Spacing${ownerState.level || ''})`;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
function createGetParentSpacing(ownerState) {
|
|
11
|
+
return function getParentSpacing(axis) {
|
|
12
|
+
if (ownerState.level === 0) {
|
|
13
|
+
return `var(--Grid-${axis}Spacing)`;
|
|
14
|
+
}
|
|
15
|
+
return `var(--Grid-${axis}Spacing${ownerState.level - 1 || ''})`;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
2
18
|
export const filterBreakpointKeys = (breakpointsKeys, responsiveKeys) => breakpointsKeys.filter(key => responsiveKeys.includes(key));
|
|
3
19
|
export const traverseBreakpoints = (breakpoints, responsive, iterator) => {
|
|
4
20
|
const smallestBreakpoint = breakpoints.keys[0]; // the keys is sorted from smallest to largest by `createBreakpoints`.
|
|
@@ -45,6 +61,7 @@ export const generateGridSizeStyles = ({
|
|
|
45
61
|
theme,
|
|
46
62
|
ownerState
|
|
47
63
|
}) => {
|
|
64
|
+
const getSelfSpacing = createGetSelfSpacing(ownerState);
|
|
48
65
|
const styles = {};
|
|
49
66
|
traverseBreakpoints(theme.breakpoints, ownerState.gridSize, (appendStyle, value) => {
|
|
50
67
|
let style = {};
|
|
@@ -68,7 +85,7 @@ export const generateGridSizeStyles = ({
|
|
|
68
85
|
style = {
|
|
69
86
|
flexGrow: 0,
|
|
70
87
|
flexBasis: 'auto',
|
|
71
|
-
width: `calc(100% * ${value} / var(--Grid-columns)${ownerState
|
|
88
|
+
width: `calc(100% * ${value} / var(--Grid-columns)${isNestedContainer(ownerState) ? ` + ${getSelfSpacing('column')}` : ''})`
|
|
72
89
|
};
|
|
73
90
|
}
|
|
74
91
|
appendStyle(styles, style);
|
|
@@ -120,11 +137,16 @@ export const generateGridRowSpacingStyles = ({
|
|
|
120
137
|
if (!ownerState.container) {
|
|
121
138
|
return {};
|
|
122
139
|
}
|
|
123
|
-
const
|
|
140
|
+
const getParentSpacing = createGetParentSpacing(ownerState);
|
|
141
|
+
const styles = isNestedContainer(ownerState) ? {
|
|
142
|
+
// Set the default spacing as its parent spacing.
|
|
143
|
+
// It will be overridden if spacing props are provided
|
|
144
|
+
[`--Grid-rowSpacing${ownerState.level || ''}`]: getParentSpacing('row')
|
|
145
|
+
} : {};
|
|
124
146
|
traverseBreakpoints(theme.breakpoints, ownerState.rowSpacing, (appendStyle, value) => {
|
|
125
147
|
var _theme$spacing;
|
|
126
148
|
appendStyle(styles, {
|
|
127
|
-
|
|
149
|
+
[`--Grid-rowSpacing${ownerState.level || ''}`]: typeof value === 'string' ? value : (_theme$spacing = theme.spacing) == null ? void 0 : _theme$spacing.call(theme, value)
|
|
128
150
|
});
|
|
129
151
|
});
|
|
130
152
|
return styles;
|
|
@@ -136,11 +158,16 @@ export const generateGridColumnSpacingStyles = ({
|
|
|
136
158
|
if (!ownerState.container) {
|
|
137
159
|
return {};
|
|
138
160
|
}
|
|
139
|
-
const
|
|
161
|
+
const getParentSpacing = createGetParentSpacing(ownerState);
|
|
162
|
+
const styles = isNestedContainer(ownerState) ? {
|
|
163
|
+
// Set the default spacing as its parent spacing.
|
|
164
|
+
// It will be overridden if spacing props are provided
|
|
165
|
+
[`--Grid-columnSpacing${ownerState.level || ''}`]: getParentSpacing('column')
|
|
166
|
+
} : {};
|
|
140
167
|
traverseBreakpoints(theme.breakpoints, ownerState.columnSpacing, (appendStyle, value) => {
|
|
141
168
|
var _theme$spacing2;
|
|
142
169
|
appendStyle(styles, {
|
|
143
|
-
|
|
170
|
+
[`--Grid-columnSpacing${ownerState.level || ''}`]: typeof value === 'string' ? value : (_theme$spacing2 = theme.spacing) == null ? void 0 : _theme$spacing2.call(theme, value)
|
|
144
171
|
});
|
|
145
172
|
});
|
|
146
173
|
return styles;
|
|
@@ -163,29 +190,24 @@ export const generateGridDirectionStyles = ({
|
|
|
163
190
|
export const generateGridStyles = ({
|
|
164
191
|
ownerState
|
|
165
192
|
}) => {
|
|
193
|
+
const getSelfSpacing = createGetSelfSpacing(ownerState);
|
|
194
|
+
const getParentSpacing = createGetParentSpacing(ownerState);
|
|
166
195
|
return _extends({
|
|
167
196
|
minWidth: 0,
|
|
168
197
|
boxSizing: 'border-box'
|
|
169
|
-
}, ownerState.container
|
|
198
|
+
}, ownerState.container && _extends({
|
|
170
199
|
display: 'flex',
|
|
171
200
|
flexWrap: 'wrap'
|
|
172
201
|
}, ownerState.wrap && ownerState.wrap !== 'wrap' && {
|
|
173
202
|
flexWrap: ownerState.wrap
|
|
174
203
|
}, {
|
|
175
|
-
margin: `calc(
|
|
204
|
+
margin: `calc(${getSelfSpacing('row')} / -2) calc(${getSelfSpacing('column')} / -2)`
|
|
176
205
|
}, ownerState.disableEqualOverflow && {
|
|
177
|
-
margin: `calc(
|
|
178
|
-
}, ownerState.
|
|
179
|
-
padding: `calc(
|
|
206
|
+
margin: `calc(${getSelfSpacing('row')} * -1) 0px 0px calc(${getSelfSpacing('column')} * -1)`
|
|
207
|
+
}), (!ownerState.container || isNestedContainer(ownerState)) && _extends({
|
|
208
|
+
padding: `calc(${getParentSpacing('row')} / 2) calc(${getParentSpacing('column')} / 2)`
|
|
180
209
|
}, (ownerState.disableEqualOverflow || ownerState.parentDisableEqualOverflow) && {
|
|
181
|
-
padding:
|
|
182
|
-
}) : {
|
|
183
|
-
'--Grid-nested-rowSpacing': 'var(--Grid-rowSpacing)',
|
|
184
|
-
'--Grid-nested-columnSpacing': 'var(--Grid-columnSpacing)'
|
|
185
|
-
}) : _extends({
|
|
186
|
-
padding: `calc(var(--Grid-rowSpacing) / 2) calc(var(--Grid-columnSpacing) / 2)`
|
|
187
|
-
}, ownerState.disableEqualOverflow && {
|
|
188
|
-
padding: `calc(var(--Grid-rowSpacing)) 0px 0px calc(var(--Grid-columnSpacing))`
|
|
210
|
+
padding: `${getParentSpacing('row')} 0px 0px ${getParentSpacing('column')}`
|
|
189
211
|
}));
|
|
190
212
|
};
|
|
191
213
|
export const generateSizeClassNames = gridSize => {
|
|
@@ -94,14 +94,14 @@ export default function createCssVarsProvider(options) {
|
|
|
94
94
|
colorScheme = ctx.colorScheme;
|
|
95
95
|
}
|
|
96
96
|
const calculatedMode = (() => {
|
|
97
|
-
if (
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
return
|
|
97
|
+
if (mode) {
|
|
98
|
+
return mode;
|
|
99
|
+
}
|
|
100
|
+
// This scope occurs on the server
|
|
101
|
+
if (defaultMode === 'system') {
|
|
102
|
+
return designSystemMode;
|
|
103
103
|
}
|
|
104
|
-
return
|
|
104
|
+
return defaultMode;
|
|
105
105
|
})();
|
|
106
106
|
const calculatedColorScheme = (() => {
|
|
107
107
|
if (!colorScheme) {
|
package/index.js
CHANGED
package/index.spec.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|