@mui/system 5.9.2 → 5.10.1
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 +196 -5
- 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/Container/index.d.ts +1 -1
- package/README.md +1 -1
- package/Stack/Stack.d.ts +12 -0
- package/Stack/Stack.js +62 -0
- package/Stack/StackProps.d.ts +42 -0
- package/Stack/StackProps.js +5 -0
- package/Stack/createStack.d.ts +21 -0
- package/Stack/createStack.js +209 -0
- package/Stack/index.d.ts +5 -0
- package/Stack/index.js +65 -0
- package/Stack/package.json +6 -0
- package/Stack/stackClasses.d.ts +8 -0
- package/Stack/stackClasses.js +17 -0
- package/Unstable_Grid/Grid.d.ts +12 -12
- package/Unstable_Grid/GridProps.d.ts +162 -162
- package/Unstable_Grid/createGrid.d.ts +11 -11
- package/Unstable_Grid/gridClasses.d.ts +20 -20
- package/Unstable_Grid/gridGenerator.d.ts +26 -26
- package/Unstable_Grid/index.d.ts +5 -5
- package/breakpoints.d.ts +21 -0
- package/createBox.js +3 -1
- package/createBox.spec.d.ts +1 -1
- package/createStyled.js +30 -11
- package/createTheme/createSpacing.d.ts +10 -10
- package/cssVars/createCssVarsProvider.js +1 -1
- package/cssVars/createCssVarsProvider.spec.d.ts +1 -1
- package/cssVars/createGetCssVar.d.ts +5 -5
- package/cssVars/cssVarsParser.d.ts +65 -65
- package/cssVars/getInitColorSchemeScript.d.ts +45 -45
- package/cssVars/index.d.ts +3 -3
- package/cssVars/useCurrentColorScheme.d.ts +53 -53
- package/esm/Stack/Stack.js +51 -0
- package/esm/Stack/StackProps.js +1 -0
- package/esm/Stack/createStack.js +179 -0
- package/esm/Stack/index.js +5 -0
- package/esm/Stack/stackClasses.js +6 -0
- package/esm/createBox.js +3 -1
- package/esm/createStyled.js +28 -10
- package/esm/cssVars/createCssVarsProvider.js +1 -1
- package/esm/index.js +3 -1
- package/index.d.ts +4 -6
- package/index.js +25 -2
- package/index.spec.d.ts +1 -1
- package/legacy/Stack/Stack.js +51 -0
- package/legacy/Stack/StackProps.js +1 -0
- package/legacy/Stack/createStack.js +187 -0
- package/legacy/Stack/index.js +5 -0
- package/legacy/Stack/stackClasses.js +6 -0
- package/legacy/createBox.js +5 -1
- package/legacy/createStyled.js +31 -10
- package/legacy/cssVars/createCssVarsProvider.js +1 -1
- package/legacy/index.js +4 -2
- package/modern/Stack/Stack.js +51 -0
- package/modern/Stack/StackProps.js +1 -0
- package/modern/Stack/createStack.js +179 -0
- package/modern/Stack/index.js +5 -0
- package/modern/Stack/stackClasses.js +6 -0
- package/modern/createBox.js +3 -1
- package/modern/createStyled.js +28 -10
- package/modern/cssVars/createCssVarsProvider.js +1 -1
- package/modern/index.js +4 -2
- package/package.json +5 -5
- package/spacing.d.ts +6 -0
- package/styleFunctionSx/styleFunctionSx.spec.d.ts +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { OverridableComponent } from '@mui/types';
|
|
3
|
-
import { GridTypeMap } from './GridProps';
|
|
4
|
-
declare const defaultCreateStyledComponent: import("@mui/styled-engine").CreateStyledComponent<import("../createStyled").MUIStyledCommonProps<any>, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement>>, {}, any>;
|
|
5
|
-
declare function useThemePropsDefault<T>(props: T): T & {};
|
|
6
|
-
export default function createGrid(options?: {
|
|
7
|
-
createStyledComponent?: typeof defaultCreateStyledComponent;
|
|
8
|
-
useThemeProps?: typeof useThemePropsDefault;
|
|
9
|
-
componentName?: string;
|
|
10
|
-
}): OverridableComponent<GridTypeMap<{}, "div">>;
|
|
11
|
-
export {};
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { OverridableComponent } from '@mui/types';
|
|
3
|
+
import { GridTypeMap } from './GridProps';
|
|
4
|
+
declare const defaultCreateStyledComponent: import("@mui/styled-engine").CreateStyledComponent<import("../createStyled").MUIStyledCommonProps<any>, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement>>, {}, any>;
|
|
5
|
+
declare function useThemePropsDefault<T>(props: T): T & {};
|
|
6
|
+
export default function createGrid(options?: {
|
|
7
|
+
createStyledComponent?: typeof defaultCreateStyledComponent;
|
|
8
|
+
useThemeProps?: typeof useThemePropsDefault;
|
|
9
|
+
componentName?: string;
|
|
10
|
+
}): OverridableComponent<GridTypeMap<{}, "div">>;
|
|
11
|
+
export {};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
export interface GridClasses {
|
|
2
|
-
/** Styles applied to the root element. */
|
|
3
|
-
root: string;
|
|
4
|
-
/** Styles applied to the root element if `container={true}`. */
|
|
5
|
-
container: string;
|
|
6
|
-
/** Styles applied to the root element if `direction="column"`. */
|
|
7
|
-
'direction-xs-column': string;
|
|
8
|
-
/** Styles applied to the root element if `direction="column-reverse"`. */
|
|
9
|
-
'direction-xs-column-reverse': string;
|
|
10
|
-
/** Styles applied to the root element if `direction="row-reverse"`. */
|
|
11
|
-
'direction-xs-row-reverse': string;
|
|
12
|
-
/** Styles applied to the root element if `wrap="nowrap"`. */
|
|
13
|
-
'wrap-xs-nowrap': string;
|
|
14
|
-
/** Styles applied to the root element if `wrap="reverse"`. */
|
|
15
|
-
'wrap-xs-wrap-reverse': string;
|
|
16
|
-
}
|
|
17
|
-
export declare type GridClassKey = keyof GridClasses;
|
|
18
|
-
export declare function getGridUtilityClass(slot: string): string;
|
|
19
|
-
declare const gridClasses: GridClasses;
|
|
20
|
-
export default gridClasses;
|
|
1
|
+
export interface GridClasses {
|
|
2
|
+
/** Styles applied to the root element. */
|
|
3
|
+
root: string;
|
|
4
|
+
/** Styles applied to the root element if `container={true}`. */
|
|
5
|
+
container: string;
|
|
6
|
+
/** Styles applied to the root element if `direction="column"`. */
|
|
7
|
+
'direction-xs-column': string;
|
|
8
|
+
/** Styles applied to the root element if `direction="column-reverse"`. */
|
|
9
|
+
'direction-xs-column-reverse': string;
|
|
10
|
+
/** Styles applied to the root element if `direction="row-reverse"`. */
|
|
11
|
+
'direction-xs-row-reverse': string;
|
|
12
|
+
/** Styles applied to the root element if `wrap="nowrap"`. */
|
|
13
|
+
'wrap-xs-nowrap': string;
|
|
14
|
+
/** Styles applied to the root element if `wrap="reverse"`. */
|
|
15
|
+
'wrap-xs-wrap-reverse': string;
|
|
16
|
+
}
|
|
17
|
+
export declare type GridClassKey = keyof GridClasses;
|
|
18
|
+
export declare function getGridUtilityClass(slot: string): string;
|
|
19
|
+
declare const gridClasses: GridClasses;
|
|
20
|
+
export default gridClasses;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { Breakpoints } from '../createTheme/createBreakpoints';
|
|
2
|
-
import { Spacing } from '../createTheme/createSpacing';
|
|
3
|
-
import { GridOwnerState } from './GridProps';
|
|
4
|
-
interface Props {
|
|
5
|
-
theme: {
|
|
6
|
-
breakpoints: Breakpoints;
|
|
7
|
-
spacing?: Spacing;
|
|
8
|
-
};
|
|
9
|
-
ownerState: GridOwnerState & {
|
|
10
|
-
parentDisableEqualOverflow?: boolean;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
interface Iterator<T> {
|
|
14
|
-
(appendStyle: (responsizeStyles: Record<string, any>, style: object) => void, value: T): void;
|
|
15
|
-
}
|
|
16
|
-
export declare const traverseBreakpoints: <T = unknown>(breakpoints: Breakpoints, responsize: Record<string, any> | T | T[] | undefined, iterator: Iterator<T>) => void;
|
|
17
|
-
export declare const generateGridSizeStyles: ({ theme, ownerState }: Props) => {};
|
|
18
|
-
export declare const generateGridOffsetStyles: ({ theme, ownerState }: Props) => {};
|
|
19
|
-
export declare const generateGridColumnsStyles: ({ theme, ownerState }: Props) => {};
|
|
20
|
-
export declare const generateGridRowSpacingStyles: ({ theme, ownerState }: Props) => {};
|
|
21
|
-
export declare const generateGridColumnSpacingStyles: ({ theme, ownerState }: Props) => {};
|
|
22
|
-
export declare const generateGridDirectionStyles: ({ theme, ownerState }: Props) => {};
|
|
23
|
-
export declare const generateGridStyles: ({ ownerState }: Props) => {};
|
|
24
|
-
export declare const generateSizeClassNames: (gridSize: GridOwnerState['gridSize']) => string[];
|
|
25
|
-
export declare const generateSpacingClassNames: (spacing: GridOwnerState['spacing'], smallestBreakpoint?: string) => string[];
|
|
26
|
-
export {};
|
|
1
|
+
import { Breakpoints } from '../createTheme/createBreakpoints';
|
|
2
|
+
import { Spacing } from '../createTheme/createSpacing';
|
|
3
|
+
import { GridOwnerState } from './GridProps';
|
|
4
|
+
interface Props {
|
|
5
|
+
theme: {
|
|
6
|
+
breakpoints: Breakpoints;
|
|
7
|
+
spacing?: Spacing;
|
|
8
|
+
};
|
|
9
|
+
ownerState: GridOwnerState & {
|
|
10
|
+
parentDisableEqualOverflow?: boolean;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
interface Iterator<T> {
|
|
14
|
+
(appendStyle: (responsizeStyles: Record<string, any>, style: object) => void, value: T): void;
|
|
15
|
+
}
|
|
16
|
+
export declare const traverseBreakpoints: <T = unknown>(breakpoints: Breakpoints, responsize: Record<string, any> | T | T[] | undefined, iterator: Iterator<T>) => void;
|
|
17
|
+
export declare const generateGridSizeStyles: ({ theme, ownerState }: Props) => {};
|
|
18
|
+
export declare const generateGridOffsetStyles: ({ theme, ownerState }: Props) => {};
|
|
19
|
+
export declare const generateGridColumnsStyles: ({ theme, ownerState }: Props) => {};
|
|
20
|
+
export declare const generateGridRowSpacingStyles: ({ theme, ownerState }: Props) => {};
|
|
21
|
+
export declare const generateGridColumnSpacingStyles: ({ theme, ownerState }: Props) => {};
|
|
22
|
+
export declare const generateGridDirectionStyles: ({ theme, ownerState }: Props) => {};
|
|
23
|
+
export declare const generateGridStyles: ({ ownerState }: Props) => {};
|
|
24
|
+
export declare const generateSizeClassNames: (gridSize: GridOwnerState['gridSize']) => string[];
|
|
25
|
+
export declare const generateSpacingClassNames: (spacing: GridOwnerState['spacing'], smallestBreakpoint?: string) => string[];
|
|
26
|
+
export {};
|
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/breakpoints.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CSSObject } from '@mui/styled-engine';
|
|
2
|
+
import { Breakpoints } from './createTheme/createBreakpoints';
|
|
3
|
+
import type { Breakpoint } from './createTheme';
|
|
4
|
+
import { ResponsiveStyleValue } from './styleFunctionSx';
|
|
5
|
+
|
|
6
|
+
export interface ResolveBreakpointValuesOptions<T> {
|
|
7
|
+
values: ResponsiveStyleValue<T>;
|
|
8
|
+
breakpoints?: Breakpoints['values'];
|
|
9
|
+
base?: Record<string, boolean>;
|
|
10
|
+
}
|
|
11
|
+
export function resolveBreakpointValues<T>(
|
|
12
|
+
options: ResolveBreakpointValuesOptions<T>,
|
|
13
|
+
): Record<string, T>;
|
|
14
|
+
|
|
15
|
+
export function mergeBreakpointsInOrder(breakpoints: Breakpoints, styles: CSSObject[]): CSSObject;
|
|
16
|
+
|
|
17
|
+
export function handleBreakpoints<Props>(
|
|
18
|
+
props: Props,
|
|
19
|
+
propValue: any,
|
|
20
|
+
styleFromPropValue: (value: any, breakpoint?: Breakpoint) => any,
|
|
21
|
+
): any;
|
package/createBox.js
CHANGED
|
@@ -36,7 +36,9 @@ function createBox(options = {}) {
|
|
|
36
36
|
generateClassName,
|
|
37
37
|
styleFunctionSx = _styleFunctionSx.default
|
|
38
38
|
} = options;
|
|
39
|
-
const BoxRoot = (0, _styledEngine.default)('div'
|
|
39
|
+
const BoxRoot = (0, _styledEngine.default)('div', {
|
|
40
|
+
shouldForwardProp: prop => prop !== 'theme' && prop !== 'sx' && prop !== 'as'
|
|
41
|
+
})(styleFunctionSx);
|
|
40
42
|
const Box = /*#__PURE__*/React.forwardRef(function Box(inProps, ref) {
|
|
41
43
|
const theme = (0, _useTheme.default)(defaultTheme);
|
|
42
44
|
|
package/createBox.spec.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
package/createStyled.js
CHANGED
|
@@ -9,11 +9,11 @@ exports.default = createStyled;
|
|
|
9
9
|
exports.shouldForwardProp = shouldForwardProp;
|
|
10
10
|
exports.systemDefaultTheme = void 0;
|
|
11
11
|
|
|
12
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
-
|
|
14
12
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
15
13
|
|
|
16
|
-
var
|
|
14
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
15
|
+
|
|
16
|
+
var _styledEngine = _interopRequireWildcard(require("@mui/styled-engine"));
|
|
17
17
|
|
|
18
18
|
var _utils = require("@mui/utils");
|
|
19
19
|
|
|
@@ -27,8 +27,20 @@ const _excluded = ["name", "slot", "skipVariantsResolver", "skipSx", "overridesR
|
|
|
27
27
|
_excluded2 = ["theme"],
|
|
28
28
|
_excluded3 = ["theme"];
|
|
29
29
|
|
|
30
|
+
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); }
|
|
31
|
+
|
|
32
|
+
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; }
|
|
33
|
+
|
|
30
34
|
function isEmpty(obj) {
|
|
31
35
|
return Object.keys(obj).length === 0;
|
|
36
|
+
} // https://github.com/emotion-js/emotion/blob/26ded6109fcd8ca9875cc2ce4564fee678a3f3c5/packages/styled/src/utils.js#L40
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
function isStringTag(tag) {
|
|
40
|
+
return typeof tag === 'string' && // 96 is one less than the char code
|
|
41
|
+
// for "a" so this is checking that
|
|
42
|
+
// it's a lowercase character
|
|
43
|
+
tag.charCodeAt(0) > 96;
|
|
32
44
|
}
|
|
33
45
|
|
|
34
46
|
const getStyleOverrides = (name, theme) => {
|
|
@@ -100,7 +112,18 @@ function createStyled(input = {}) {
|
|
|
100
112
|
slotShouldForwardProp = shouldForwardProp,
|
|
101
113
|
styleFunctionSx = _styleFunctionSx.default
|
|
102
114
|
} = input;
|
|
115
|
+
|
|
116
|
+
const systemSx = props => {
|
|
117
|
+
const theme = isEmpty(props.theme) ? defaultTheme : props.theme;
|
|
118
|
+
return styleFunctionSx((0, _extends2.default)({}, props, {
|
|
119
|
+
theme
|
|
120
|
+
}));
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
systemSx.__mui_systemSx = true;
|
|
103
124
|
return (tag, inputOptions = {}) => {
|
|
125
|
+
// Filter out the `sx` style function from the previous styled component to prevent unnecessary styles generated by the composite components.
|
|
126
|
+
(0, _styledEngine.internal_processStyles)(tag, styles => styles.filter(style => !(style != null && style.__mui_systemSx)));
|
|
104
127
|
const {
|
|
105
128
|
name: componentName,
|
|
106
129
|
slot: componentSlot,
|
|
@@ -127,6 +150,9 @@ function createStyled(input = {}) {
|
|
|
127
150
|
} else if (componentSlot) {
|
|
128
151
|
// any other slot specified
|
|
129
152
|
shouldForwardPropOption = slotShouldForwardProp;
|
|
153
|
+
} else if (isStringTag(tag)) {
|
|
154
|
+
// for string (html) tag, preserve the behavior in emotion & styled-components.
|
|
155
|
+
shouldForwardPropOption = undefined;
|
|
130
156
|
}
|
|
131
157
|
|
|
132
158
|
const defaultStyledResolver = (0, _styledEngine.default)(tag, (0, _extends2.default)({
|
|
@@ -139,7 +165,6 @@ function createStyled(input = {}) {
|
|
|
139
165
|
// On the server Emotion doesn't use React.forwardRef for creating components, so the created
|
|
140
166
|
// component stays as a function. This condition makes sure that we do not interpolate functions
|
|
141
167
|
// which are basically components used as a selectors.
|
|
142
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
143
168
|
return typeof stylesArg === 'function' && stylesArg.__emotion_real !== stylesArg ? _ref => {
|
|
144
169
|
let {
|
|
145
170
|
theme: themeInput
|
|
@@ -179,12 +204,7 @@ function createStyled(input = {}) {
|
|
|
179
204
|
}
|
|
180
205
|
|
|
181
206
|
if (!skipSx) {
|
|
182
|
-
expressionsWithDefaultTheme.push(
|
|
183
|
-
const theme = isEmpty(props.theme) ? defaultTheme : props.theme;
|
|
184
|
-
return styleFunctionSx((0, _extends2.default)({}, props, {
|
|
185
|
-
theme
|
|
186
|
-
}));
|
|
187
|
-
});
|
|
207
|
+
expressionsWithDefaultTheme.push(systemSx);
|
|
188
208
|
}
|
|
189
209
|
|
|
190
210
|
const numOfCustomFnsApplied = expressionsWithDefaultTheme.length - expressions.length;
|
|
@@ -197,7 +217,6 @@ function createStyled(input = {}) {
|
|
|
197
217
|
} else if (typeof styleArg === 'function' && // On the server Emotion doesn't use React.forwardRef for creating components, so the created
|
|
198
218
|
// component stays as a function. This condition makes sure that we do not interpolate functions
|
|
199
219
|
// which are basically components used as a selectors.
|
|
200
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
201
220
|
styleArg.__emotion_real !== styleArg) {
|
|
202
221
|
// If the type is function, we need to define the default theme.
|
|
203
222
|
transformedStyleArg = _ref2 => {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export declare type SpacingOptions = number | Spacing | ((abs: number) => number | string) | ((abs: number | string) => number | string) | ReadonlyArray<string | number>;
|
|
2
|
-
export declare 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 declare type SpacingOptions = number | Spacing | ((abs: number) => number | string) | ((abs: number | string) => number | string) | ReadonlyArray<string | number>;
|
|
2
|
+
export declare 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;
|
|
@@ -179,7 +179,7 @@ function createCssVarsProvider(options) {
|
|
|
179
179
|
})();
|
|
180
180
|
|
|
181
181
|
if (key === resolvedDefaultColorScheme) {
|
|
182
|
-
defaultColorSchemeStyleSheet[colorSchemeSelector] = css;
|
|
182
|
+
defaultColorSchemeStyleSheet[`${colorSchemeSelector}, [${attribute}="${key}"]`] = css;
|
|
183
183
|
} else {
|
|
184
184
|
otherColorSchemesStyleSheet[`${colorSchemeSelector === ':root' ? '' : colorSchemeSelector}[${attribute}="${key}"]`] = css;
|
|
185
185
|
}
|
|
@@ -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,65 +1,65 @@
|
|
|
1
|
-
declare type NestedRecord<V = any> = {
|
|
2
|
-
[k: string | number]: NestedRecord<V> | V;
|
|
3
|
-
};
|
|
4
|
-
/**
|
|
5
|
-
* This function create an object from keys, value and then assign to target
|
|
6
|
-
*
|
|
7
|
-
* @param {Object} obj : the target object to be assigned
|
|
8
|
-
* @param {string[]} keys
|
|
9
|
-
* @param {string | number} value
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* const source = {}
|
|
13
|
-
* assignNestedKeys(source, ['palette', 'primary'], 'var(--palette-primary)')
|
|
14
|
-
* console.log(source) // { palette: { primary: 'var(--palette-primary)' } }
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* const source = { palette: { primary: 'var(--palette-primary)' } }
|
|
18
|
-
* assignNestedKeys(source, ['palette', 'secondary'], 'var(--palette-secondary)')
|
|
19
|
-
* console.log(source) // { palette: { primary: 'var(--palette-primary)', secondary: 'var(--palette-secondary)' } }
|
|
20
|
-
*/
|
|
21
|
-
export declare const assignNestedKeys: <Object_1 = NestedRecord<any>, Value = any>(obj: Object_1, keys: Array<string>, value: Value, arrayKeys?: Array<string>) => void;
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
* @param {Object} obj : source object
|
|
25
|
-
* @param {Function} callback : a function that will be called when
|
|
26
|
-
* - the deepest key in source object is reached
|
|
27
|
-
* - the value of the deepest key is NOT `undefined` | `null`
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* walkObjectDeep({ palette: { primary: { main: '#000000' } } }, console.log)
|
|
31
|
-
* // ['palette', 'primary', 'main'] '#000000'
|
|
32
|
-
*/
|
|
33
|
-
export declare const walkObjectDeep: <Value, T = Record<string, any>>(obj: T, callback: (keys: Array<string>, value: Value, arrayKeys: Array<string>) => void, shouldSkipPaths?: ((keys: Array<string>) => boolean) | undefined) => void;
|
|
34
|
-
/**
|
|
35
|
-
* a function that parse theme and return { css, vars }
|
|
36
|
-
*
|
|
37
|
-
* @param {Object} theme
|
|
38
|
-
* @param {{
|
|
39
|
-
* prefix?: string,
|
|
40
|
-
* shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean
|
|
41
|
-
* }} options.
|
|
42
|
-
* `prefix`: The prefix of the generated CSS variables. This function does not change the value.
|
|
43
|
-
*
|
|
44
|
-
* @returns {{ css: Object, vars: Object, parsedTheme: typeof theme }} `css` is the stylesheet, `vars` is an object to get css variable (same structure as theme), and `parsedTheme` is the cloned version of theme.
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* const { css, vars, parsedTheme } = parser({
|
|
48
|
-
* fontSize: 12,
|
|
49
|
-
* lineHeight: 1.2,
|
|
50
|
-
* palette: { primary: { 500: 'var(--color)' } }
|
|
51
|
-
* }, { prefix: 'foo' })
|
|
52
|
-
*
|
|
53
|
-
* console.log(css) // { '--foo-fontSize': '12px', '--foo-lineHeight': 1.2, '--foo-palette-primary-500': 'var(--color)' }
|
|
54
|
-
* console.log(vars) // { fontSize: 'var(--foo-fontSize)', lineHeight: 'var(--foo-lineHeight)', palette: { primary: { 500: 'var(--foo-palette-primary-500)' } } }
|
|
55
|
-
* console.log(parsedTheme) // { fontSize: 12, lineHeight: 1.2, palette: { primary: { 500: 'var(--color)' } } }
|
|
56
|
-
*/
|
|
57
|
-
export default function cssVarsParser<T extends Record<string, any>>(theme: T, options?: {
|
|
58
|
-
prefix?: string;
|
|
59
|
-
shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean;
|
|
60
|
-
}): {
|
|
61
|
-
css: NestedRecord<string>;
|
|
62
|
-
vars: NestedRecord<string>;
|
|
63
|
-
parsedTheme: T;
|
|
64
|
-
};
|
|
65
|
-
export {};
|
|
1
|
+
declare type NestedRecord<V = any> = {
|
|
2
|
+
[k: string | number]: NestedRecord<V> | V;
|
|
3
|
+
};
|
|
4
|
+
/**
|
|
5
|
+
* This function create an object from keys, value and then assign to target
|
|
6
|
+
*
|
|
7
|
+
* @param {Object} obj : the target object to be assigned
|
|
8
|
+
* @param {string[]} keys
|
|
9
|
+
* @param {string | number} value
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const source = {}
|
|
13
|
+
* assignNestedKeys(source, ['palette', 'primary'], 'var(--palette-primary)')
|
|
14
|
+
* console.log(source) // { palette: { primary: 'var(--palette-primary)' } }
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* const source = { palette: { primary: 'var(--palette-primary)' } }
|
|
18
|
+
* assignNestedKeys(source, ['palette', 'secondary'], 'var(--palette-secondary)')
|
|
19
|
+
* console.log(source) // { palette: { primary: 'var(--palette-primary)', secondary: 'var(--palette-secondary)' } }
|
|
20
|
+
*/
|
|
21
|
+
export declare const assignNestedKeys: <Object_1 = NestedRecord<any>, Value = any>(obj: Object_1, keys: Array<string>, value: Value, arrayKeys?: Array<string>) => void;
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @param {Object} obj : source object
|
|
25
|
+
* @param {Function} callback : a function that will be called when
|
|
26
|
+
* - the deepest key in source object is reached
|
|
27
|
+
* - the value of the deepest key is NOT `undefined` | `null`
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* walkObjectDeep({ palette: { primary: { main: '#000000' } } }, console.log)
|
|
31
|
+
* // ['palette', 'primary', 'main'] '#000000'
|
|
32
|
+
*/
|
|
33
|
+
export declare const walkObjectDeep: <Value, T = Record<string, any>>(obj: T, callback: (keys: Array<string>, value: Value, arrayKeys: Array<string>) => void, shouldSkipPaths?: ((keys: Array<string>) => boolean) | undefined) => void;
|
|
34
|
+
/**
|
|
35
|
+
* a function that parse theme and return { css, vars }
|
|
36
|
+
*
|
|
37
|
+
* @param {Object} theme
|
|
38
|
+
* @param {{
|
|
39
|
+
* prefix?: string,
|
|
40
|
+
* shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean
|
|
41
|
+
* }} options.
|
|
42
|
+
* `prefix`: The prefix of the generated CSS variables. This function does not change the value.
|
|
43
|
+
*
|
|
44
|
+
* @returns {{ css: Object, vars: Object, parsedTheme: typeof theme }} `css` is the stylesheet, `vars` is an object to get css variable (same structure as theme), and `parsedTheme` is the cloned version of theme.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* const { css, vars, parsedTheme } = parser({
|
|
48
|
+
* fontSize: 12,
|
|
49
|
+
* lineHeight: 1.2,
|
|
50
|
+
* palette: { primary: { 500: 'var(--color)' } }
|
|
51
|
+
* }, { prefix: 'foo' })
|
|
52
|
+
*
|
|
53
|
+
* console.log(css) // { '--foo-fontSize': '12px', '--foo-lineHeight': 1.2, '--foo-palette-primary-500': 'var(--color)' }
|
|
54
|
+
* console.log(vars) // { fontSize: 'var(--foo-fontSize)', lineHeight: 'var(--foo-lineHeight)', palette: { primary: { 500: 'var(--foo-palette-primary-500)' } } }
|
|
55
|
+
* console.log(parsedTheme) // { fontSize: 12, lineHeight: 1.2, palette: { primary: { 500: 'var(--color)' } } }
|
|
56
|
+
*/
|
|
57
|
+
export default function cssVarsParser<T extends Record<string, any>>(theme: T, options?: {
|
|
58
|
+
prefix?: string;
|
|
59
|
+
shouldSkipGeneratingVar?: (objectPathKeys: Array<string>, value: string | number) => boolean;
|
|
60
|
+
}): {
|
|
61
|
+
css: NestedRecord<string>;
|
|
62
|
+
vars: NestedRecord<string>;
|
|
63
|
+
parsedTheme: T;
|
|
64
|
+
};
|
|
65
|
+
export {};
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
export declare const DEFAULT_MODE_STORAGE_KEY = "mode";
|
|
3
|
-
export declare const DEFAULT_COLOR_SCHEME_STORAGE_KEY = "color-scheme";
|
|
4
|
-
export declare const DEFAULT_ATTRIBUTE = "data-color-scheme";
|
|
5
|
-
export interface GetInitColorSchemeScriptOptions {
|
|
6
|
-
/**
|
|
7
|
-
* Indicate to the browser which color scheme is used (light or dark) for rendering built-in UI
|
|
8
|
-
* @default true
|
|
9
|
-
*/
|
|
10
|
-
enableColorScheme?: boolean;
|
|
11
|
-
/**
|
|
12
|
-
* If `true`, the initial color scheme is set to the user's prefers-color-scheme mode
|
|
13
|
-
* @default false
|
|
14
|
-
*/
|
|
15
|
-
enableSystem?: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* The default color scheme to be used on the light mode
|
|
18
|
-
*/
|
|
19
|
-
defaultLightColorScheme?: string;
|
|
20
|
-
/**
|
|
21
|
-
* The default color scheme to be used on the dark mode
|
|
22
|
-
*/
|
|
23
|
-
defaultDarkColorScheme?: string;
|
|
24
|
-
/**
|
|
25
|
-
* The node (provided as string) used to attach the color-scheme attribute
|
|
26
|
-
* @default 'document.documentElement'
|
|
27
|
-
*/
|
|
28
|
-
colorSchemeNode?: string;
|
|
29
|
-
/**
|
|
30
|
-
* localStorage key used to store `mode`
|
|
31
|
-
* @default 'mode'
|
|
32
|
-
*/
|
|
33
|
-
modeStorageKey?: string;
|
|
34
|
-
/**
|
|
35
|
-
* localStorage key used to store `colorScheme`
|
|
36
|
-
* @default 'color-scheme'
|
|
37
|
-
*/
|
|
38
|
-
colorSchemeStorageKey?: string;
|
|
39
|
-
/**
|
|
40
|
-
* DOM attribute for applying color scheme
|
|
41
|
-
* @default 'data-color-scheme'
|
|
42
|
-
*/
|
|
43
|
-
attribute?: string;
|
|
44
|
-
}
|
|
45
|
-
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
|
+
* Indicate to the browser which color scheme is used (light or dark) for rendering built-in UI
|
|
8
|
+
* @default true
|
|
9
|
+
*/
|
|
10
|
+
enableColorScheme?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* If `true`, the initial color scheme is set to the user's prefers-color-scheme mode
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
enableSystem?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* The default color scheme to be used on the light mode
|
|
18
|
+
*/
|
|
19
|
+
defaultLightColorScheme?: string;
|
|
20
|
+
/**
|
|
21
|
+
* The default color scheme to be used on the dark mode
|
|
22
|
+
*/
|
|
23
|
+
defaultDarkColorScheme?: string;
|
|
24
|
+
/**
|
|
25
|
+
* The node (provided as string) used to attach the color-scheme attribute
|
|
26
|
+
* @default 'document.documentElement'
|
|
27
|
+
*/
|
|
28
|
+
colorSchemeNode?: string;
|
|
29
|
+
/**
|
|
30
|
+
* localStorage key used to store `mode`
|
|
31
|
+
* @default 'mode'
|
|
32
|
+
*/
|
|
33
|
+
modeStorageKey?: string;
|
|
34
|
+
/**
|
|
35
|
+
* localStorage key used to store `colorScheme`
|
|
36
|
+
* @default 'color-scheme'
|
|
37
|
+
*/
|
|
38
|
+
colorSchemeStorageKey?: string;
|
|
39
|
+
/**
|
|
40
|
+
* DOM attribute for applying color scheme
|
|
41
|
+
* @default 'data-color-scheme'
|
|
42
|
+
*/
|
|
43
|
+
attribute?: string;
|
|
44
|
+
}
|
|
45
|
+
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';
|