@mui/system 5.12.0 → 5.12.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +262 -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/GlobalStyles/GlobalStyles.d.ts +13 -13
- package/GlobalStyles/index.d.ts +2 -2
- package/Stack/Stack.d.ts +14 -13
- package/Stack/Stack.js +2 -1
- 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 -173
- package/Unstable_Grid/createGrid.d.ts +11 -11
- package/Unstable_Grid/createGrid.js +18 -11
- package/Unstable_Grid/gridClasses.d.ts +20 -20
- package/Unstable_Grid/gridGenerator.d.ts +38 -38
- package/Unstable_Grid/gridGenerator.js +12 -12
- package/Unstable_Grid/index.d.ts +5 -5
- package/colorManipulator.js +2 -0
- package/createStyled.js +4 -0
- package/createTheme/createSpacing.d.ts +10 -10
- package/createTheme/createSpacing.js +3 -1
- package/cssVars/createCssVarsTheme.d.ts +15 -13
- 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 -14
- package/cssVars/prepareCssVars.js +6 -2
- package/cssVars/useCurrentColorScheme.d.ts +53 -53
- package/esm/Stack/Stack.js +2 -1
- package/esm/Unstable_Grid/createGrid.js +19 -12
- package/esm/Unstable_Grid/gridGenerator.js +12 -12
- package/esm/colorManipulator.js +1 -0
- package/esm/createStyled.js +3 -0
- package/esm/createTheme/createSpacing.js +4 -0
- package/esm/cssVars/prepareCssVars.js +6 -2
- package/index.js +5 -2
- package/legacy/Stack/Stack.js +2 -1
- package/legacy/Unstable_Grid/createGrid.js +19 -11
- package/legacy/Unstable_Grid/gridGenerator.js +12 -12
- package/legacy/colorManipulator.js +1 -0
- package/legacy/createStyled.js +3 -0
- package/legacy/createTheme/createSpacing.js +4 -0
- package/legacy/cssVars/prepareCssVars.js +6 -2
- package/legacy/index.js +1 -1
- package/modern/Stack/Stack.js +2 -1
- package/modern/Unstable_Grid/createGrid.js +18 -12
- package/modern/Unstable_Grid/gridGenerator.js +12 -12
- package/modern/colorManipulator.js +1 -0
- package/modern/createStyled.js +3 -0
- package/modern/createTheme/createSpacing.js +4 -0
- package/modern/cssVars/prepareCssVars.js +6 -2
- package/modern/index.js +1 -1
- package/package.json +4 -4
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import { Breakpoints, Breakpoint } from '../createTheme/createBreakpoints';
|
|
2
|
-
import { Spacing } from '../createTheme/createSpacing';
|
|
3
|
-
import { ResponsiveStyleValue } from '../styleFunctionSx';
|
|
4
|
-
import { GridDirection, GridOwnerState } from './GridProps';
|
|
5
|
-
interface Props {
|
|
6
|
-
theme: {
|
|
7
|
-
breakpoints: Breakpoints;
|
|
8
|
-
spacing?: Spacing;
|
|
9
|
-
};
|
|
10
|
-
ownerState: GridOwnerState & {
|
|
11
|
-
parentDisableEqualOverflow?: boolean;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
interface Iterator<T> {
|
|
15
|
-
(appendStyle: (responsiveStyles: Record<string, any>, style: object) => void, value: T): void;
|
|
16
|
-
}
|
|
17
|
-
export declare const filterBreakpointKeys: (breakpointsKeys: Breakpoint[], responsiveKeys: string[]) => Breakpoint[];
|
|
18
|
-
export declare const traverseBreakpoints: <T = unknown>(breakpoints: Breakpoints, responsive: Record<string, any> | T | T[] | undefined, iterator: Iterator<T>) => void;
|
|
19
|
-
export declare const generateGridSizeStyles: ({ theme, ownerState }: Props) => {};
|
|
20
|
-
export declare const generateGridOffsetStyles: ({ theme, ownerState }: Props) => {};
|
|
21
|
-
export declare const generateGridColumnsStyles: ({ theme, ownerState }: Props) => {
|
|
22
|
-
[x: string]: string;
|
|
23
|
-
'--Grid-columns'?: undefined;
|
|
24
|
-
} | {
|
|
25
|
-
'--Grid-columns': number;
|
|
26
|
-
};
|
|
27
|
-
export declare const generateGridRowSpacingStyles: ({ theme, ownerState }: Props) => {
|
|
28
|
-
[x: string]: string;
|
|
29
|
-
};
|
|
30
|
-
export declare const generateGridColumnSpacingStyles: ({ theme, ownerState }: Props) => {
|
|
31
|
-
[x: string]: string;
|
|
32
|
-
};
|
|
33
|
-
export declare const generateGridDirectionStyles: ({ theme, ownerState }: Props) => {};
|
|
34
|
-
export declare const generateGridStyles: ({ ownerState }: Props) => {};
|
|
35
|
-
export declare const generateSizeClassNames: (gridSize: GridOwnerState['gridSize']) => string[];
|
|
36
|
-
export declare const generateSpacingClassNames: (spacing: GridOwnerState['spacing'], smallestBreakpoint?: string) => string[];
|
|
37
|
-
export declare const generateDirectionClasses: (direction: ResponsiveStyleValue<GridDirection> | undefined) => string[];
|
|
38
|
-
export {};
|
|
1
|
+
import { Breakpoints, Breakpoint } from '../createTheme/createBreakpoints';
|
|
2
|
+
import { Spacing } from '../createTheme/createSpacing';
|
|
3
|
+
import { ResponsiveStyleValue } from '../styleFunctionSx';
|
|
4
|
+
import { GridDirection, GridOwnerState } from './GridProps';
|
|
5
|
+
interface Props {
|
|
6
|
+
theme: {
|
|
7
|
+
breakpoints: Breakpoints;
|
|
8
|
+
spacing?: Spacing;
|
|
9
|
+
};
|
|
10
|
+
ownerState: GridOwnerState & {
|
|
11
|
+
parentDisableEqualOverflow?: boolean;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
interface Iterator<T> {
|
|
15
|
+
(appendStyle: (responsiveStyles: Record<string, any>, style: object) => void, value: T): void;
|
|
16
|
+
}
|
|
17
|
+
export declare const filterBreakpointKeys: (breakpointsKeys: Breakpoint[], responsiveKeys: string[]) => Breakpoint[];
|
|
18
|
+
export declare const traverseBreakpoints: <T = unknown>(breakpoints: Breakpoints, responsive: Record<string, any> | T | T[] | undefined, iterator: Iterator<T>) => void;
|
|
19
|
+
export declare const generateGridSizeStyles: ({ theme, ownerState }: Props) => {};
|
|
20
|
+
export declare const generateGridOffsetStyles: ({ theme, ownerState }: Props) => {};
|
|
21
|
+
export declare const generateGridColumnsStyles: ({ theme, ownerState }: Props) => {
|
|
22
|
+
[x: string]: string;
|
|
23
|
+
'--Grid-columns'?: undefined;
|
|
24
|
+
} | {
|
|
25
|
+
'--Grid-columns': number;
|
|
26
|
+
};
|
|
27
|
+
export declare const generateGridRowSpacingStyles: ({ theme, ownerState }: Props) => {
|
|
28
|
+
[x: string]: string;
|
|
29
|
+
};
|
|
30
|
+
export declare const generateGridColumnSpacingStyles: ({ theme, ownerState }: Props) => {
|
|
31
|
+
[x: string]: string;
|
|
32
|
+
};
|
|
33
|
+
export declare const generateGridDirectionStyles: ({ theme, ownerState }: Props) => {};
|
|
34
|
+
export declare const generateGridStyles: ({ ownerState }: Props) => {};
|
|
35
|
+
export declare const generateSizeClassNames: (gridSize: GridOwnerState['gridSize']) => string[];
|
|
36
|
+
export declare const generateSpacingClassNames: (spacing: GridOwnerState['spacing'], smallestBreakpoint?: string) => string[];
|
|
37
|
+
export declare const generateDirectionClasses: (direction: ResponsiveStyleValue<GridDirection> | undefined) => string[];
|
|
38
|
+
export {};
|
|
@@ -13,26 +13,26 @@ function appendLevel(level) {
|
|
|
13
13
|
return `Level${level}`;
|
|
14
14
|
}
|
|
15
15
|
function isNestedContainer(ownerState) {
|
|
16
|
-
return ownerState.
|
|
16
|
+
return ownerState.unstable_level > 0 && ownerState.container;
|
|
17
17
|
}
|
|
18
18
|
function createGetSelfSpacing(ownerState) {
|
|
19
19
|
return function getSelfSpacing(axis) {
|
|
20
|
-
return `var(--Grid-${axis}Spacing${appendLevel(ownerState.
|
|
20
|
+
return `var(--Grid-${axis}Spacing${appendLevel(ownerState.unstable_level)})`;
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
function createGetParentSpacing(ownerState) {
|
|
24
24
|
return function getParentSpacing(axis) {
|
|
25
|
-
if (ownerState.
|
|
25
|
+
if (ownerState.unstable_level === 0) {
|
|
26
26
|
return `var(--Grid-${axis}Spacing)`;
|
|
27
27
|
}
|
|
28
|
-
return `var(--Grid-${axis}Spacing${appendLevel(ownerState.
|
|
28
|
+
return `var(--Grid-${axis}Spacing${appendLevel(ownerState.unstable_level - 1)})`;
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
31
|
function getParentColumns(ownerState) {
|
|
32
|
-
if (ownerState.
|
|
32
|
+
if (ownerState.unstable_level === 0) {
|
|
33
33
|
return `var(--Grid-columns)`;
|
|
34
34
|
}
|
|
35
|
-
return `var(--Grid-columns${appendLevel(ownerState.
|
|
35
|
+
return `var(--Grid-columns${appendLevel(ownerState.unstable_level - 1)})`;
|
|
36
36
|
}
|
|
37
37
|
const filterBreakpointKeys = (breakpointsKeys, responsiveKeys) => breakpointsKeys.filter(key => responsiveKeys.includes(key));
|
|
38
38
|
exports.filterBreakpointKeys = filterBreakpointKeys;
|
|
@@ -144,13 +144,13 @@ const generateGridColumnsStyles = ({
|
|
|
144
144
|
return {};
|
|
145
145
|
}
|
|
146
146
|
const styles = isNestedContainer(ownerState) ? {
|
|
147
|
-
[`--Grid-columns${appendLevel(ownerState.
|
|
147
|
+
[`--Grid-columns${appendLevel(ownerState.unstable_level)}`]: getParentColumns(ownerState)
|
|
148
148
|
} : {
|
|
149
149
|
'--Grid-columns': 12
|
|
150
150
|
};
|
|
151
151
|
traverseBreakpoints(theme.breakpoints, ownerState.columns, (appendStyle, value) => {
|
|
152
152
|
appendStyle(styles, {
|
|
153
|
-
[`--Grid-columns${appendLevel(ownerState.
|
|
153
|
+
[`--Grid-columns${appendLevel(ownerState.unstable_level)}`]: value
|
|
154
154
|
});
|
|
155
155
|
});
|
|
156
156
|
return styles;
|
|
@@ -167,12 +167,12 @@ const generateGridRowSpacingStyles = ({
|
|
|
167
167
|
const styles = isNestedContainer(ownerState) ? {
|
|
168
168
|
// Set the default spacing as its parent spacing.
|
|
169
169
|
// It will be overridden if spacing props are provided
|
|
170
|
-
[`--Grid-rowSpacing${appendLevel(ownerState.
|
|
170
|
+
[`--Grid-rowSpacing${appendLevel(ownerState.unstable_level)}`]: getParentSpacing('row')
|
|
171
171
|
} : {};
|
|
172
172
|
traverseBreakpoints(theme.breakpoints, ownerState.rowSpacing, (appendStyle, value) => {
|
|
173
173
|
var _theme$spacing;
|
|
174
174
|
appendStyle(styles, {
|
|
175
|
-
[`--Grid-rowSpacing${appendLevel(ownerState.
|
|
175
|
+
[`--Grid-rowSpacing${appendLevel(ownerState.unstable_level)}`]: typeof value === 'string' ? value : (_theme$spacing = theme.spacing) == null ? void 0 : _theme$spacing.call(theme, value)
|
|
176
176
|
});
|
|
177
177
|
});
|
|
178
178
|
return styles;
|
|
@@ -189,12 +189,12 @@ const generateGridColumnSpacingStyles = ({
|
|
|
189
189
|
const styles = isNestedContainer(ownerState) ? {
|
|
190
190
|
// Set the default spacing as its parent spacing.
|
|
191
191
|
// It will be overridden if spacing props are provided
|
|
192
|
-
[`--Grid-columnSpacing${appendLevel(ownerState.
|
|
192
|
+
[`--Grid-columnSpacing${appendLevel(ownerState.unstable_level)}`]: getParentSpacing('column')
|
|
193
193
|
} : {};
|
|
194
194
|
traverseBreakpoints(theme.breakpoints, ownerState.columnSpacing, (appendStyle, value) => {
|
|
195
195
|
var _theme$spacing2;
|
|
196
196
|
appendStyle(styles, {
|
|
197
|
-
[`--Grid-columnSpacing${appendLevel(ownerState.
|
|
197
|
+
[`--Grid-columnSpacing${appendLevel(ownerState.unstable_level)}`]: typeof value === 'string' ? value : (_theme$spacing2 = theme.spacing) == null ? void 0 : _theme$spacing2.call(theme, value)
|
|
198
198
|
});
|
|
199
199
|
});
|
|
200
200
|
return styles;
|
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/colorManipulator.js
CHANGED
|
@@ -21,6 +21,8 @@ exports.private_safeLighten = private_safeLighten;
|
|
|
21
21
|
exports.recomposeColor = recomposeColor;
|
|
22
22
|
exports.rgbToHex = rgbToHex;
|
|
23
23
|
var _utils = require("@mui/utils");
|
|
24
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
25
|
+
|
|
24
26
|
/**
|
|
25
27
|
* Returns a number whose value is limited to the given range.
|
|
26
28
|
* @param {number} value The value to be clamped
|
package/createStyled.js
CHANGED
|
@@ -15,6 +15,7 @@ var _createTheme = _interopRequireDefault(require("./createTheme"));
|
|
|
15
15
|
var _propsToClassKey = _interopRequireDefault(require("./propsToClassKey"));
|
|
16
16
|
var _styleFunctionSx = _interopRequireDefault(require("./styleFunctionSx"));
|
|
17
17
|
const _excluded = ["name", "slot", "skipVariantsResolver", "skipSx", "overridesResolver"];
|
|
18
|
+
/* eslint-disable no-underscore-dangle */
|
|
18
19
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
20
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
20
21
|
function isEmpty(obj) {
|
|
@@ -213,6 +214,9 @@ function createStyled(input = {}) {
|
|
|
213
214
|
}
|
|
214
215
|
Component.displayName = displayName;
|
|
215
216
|
}
|
|
217
|
+
if (tag.muiName) {
|
|
218
|
+
Component.muiName = tag.muiName;
|
|
219
|
+
}
|
|
216
220
|
return Component;
|
|
217
221
|
};
|
|
218
222
|
if (defaultStyledResolver.withConfig) {
|
|
@@ -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;
|
|
@@ -5,8 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = createSpacing;
|
|
7
7
|
var _spacing = require("../spacing");
|
|
8
|
+
// The different signatures imply different meaning for their arguments that can't be expressed structurally.
|
|
9
|
+
// We express the difference with variable names.
|
|
10
|
+
/* tslint:disable:unified-signatures */
|
|
8
11
|
/* tslint:enable:unified-signatures */
|
|
9
|
-
|
|
10
12
|
function createSpacing(spacingInput = 8) {
|
|
11
13
|
// Already transformed.
|
|
12
14
|
if (spacingInput.mui) {
|
|
@@ -1,13 +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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
/// <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,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,14 +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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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;
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
8
9
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
9
10
|
var _utils = require("@mui/utils");
|
|
10
11
|
var _cssVarsParser = _interopRequireDefault(require("./cssVarsParser"));
|
|
@@ -55,11 +56,14 @@ function prepareCssVars(theme, parserConfig) {
|
|
|
55
56
|
const generateCssVars = colorScheme => {
|
|
56
57
|
if (!colorScheme) {
|
|
57
58
|
return {
|
|
58
|
-
css: rootCss,
|
|
59
|
+
css: (0, _extends2.default)({}, rootCss),
|
|
59
60
|
vars: rootVars
|
|
60
61
|
};
|
|
61
62
|
}
|
|
62
|
-
return
|
|
63
|
+
return {
|
|
64
|
+
css: (0, _extends2.default)({}, colorSchemesMap[colorScheme].css),
|
|
65
|
+
vars: colorSchemesMap[colorScheme].vars
|
|
66
|
+
};
|
|
63
67
|
};
|
|
64
68
|
return {
|
|
65
69
|
vars: themeVars,
|