@mui/system 9.1.1 → 9.2.0

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.
Files changed (116) hide show
  1. package/Box/Box.d.mts +15 -19
  2. package/Box/Box.d.ts +15 -19
  3. package/Box/Box.js +16 -1
  4. package/Box/Box.mjs +17 -1
  5. package/Box/index.js +12 -2
  6. package/Box/index.mjs +1 -0
  7. package/CHANGELOG.md +74 -0
  8. package/Container/index.d.mts +1 -1
  9. package/Container/index.d.ts +1 -1
  10. package/Grid/Grid.js +0 -1
  11. package/Grid/Grid.mjs +0 -1
  12. package/Grid/GridProps.d.mts +0 -1
  13. package/Grid/GridProps.d.ts +0 -1
  14. package/InitColorSchemeScript/InitColorSchemeScript.d.mts +2 -1
  15. package/InitColorSchemeScript/InitColorSchemeScript.d.ts +2 -1
  16. package/InitColorSchemeScript/InitColorSchemeScript.js +34 -1
  17. package/InitColorSchemeScript/InitColorSchemeScript.mjs +33 -1
  18. package/Stack/Stack.js +1 -1
  19. package/Stack/Stack.mjs +1 -1
  20. package/Stack/StackProps.d.mts +1 -1
  21. package/Stack/StackProps.d.ts +1 -1
  22. package/ThemeProvider/ThemeProvider.d.mts +9 -6
  23. package/ThemeProvider/ThemeProvider.d.ts +9 -6
  24. package/ThemeProvider/ThemeProvider.js +3 -2
  25. package/ThemeProvider/ThemeProvider.mjs +3 -2
  26. package/ThemeProvider/index.d.mts +1 -1
  27. package/ThemeProvider/index.d.ts +1 -1
  28. package/borders/borders.d.mts +14 -12
  29. package/borders/borders.d.ts +14 -12
  30. package/borders/borders.js +2 -4
  31. package/borders/borders.mjs +3 -4
  32. package/breakpoints/breakpoints.d.mts +13 -16
  33. package/breakpoints/breakpoints.d.ts +13 -16
  34. package/breakpoints/breakpoints.js +17 -16
  35. package/breakpoints/breakpoints.mjs +17 -16
  36. package/compose/compose.d.mts +3 -10
  37. package/compose/compose.d.ts +3 -10
  38. package/compose/compose.js +0 -2
  39. package/compose/compose.mjs +0 -2
  40. package/createBox/createBox.d.mts +4 -4
  41. package/createBox/createBox.d.ts +4 -4
  42. package/createBreakpoints/createBreakpoints.d.mts +3 -54
  43. package/createBreakpoints/createBreakpoints.d.ts +3 -54
  44. package/createBreakpoints/createBreakpoints.js +6 -8
  45. package/createBreakpoints/createBreakpoints.mjs +6 -8
  46. package/createBreakpoints/index.d.mts +0 -1
  47. package/createBreakpoints/index.d.ts +0 -1
  48. package/createTheme/shape.d.mts +2 -2
  49. package/createTheme/shape.d.ts +2 -2
  50. package/cssGrid/cssGrid.d.mts +13 -13
  51. package/cssGrid/cssGrid.d.ts +13 -13
  52. package/cssGrid/cssGrid.js +0 -8
  53. package/cssGrid/cssGrid.mjs +0 -9
  54. package/cssVars/createCssVarsProvider.js +2 -2
  55. package/cssVars/createCssVarsProvider.mjs +2 -2
  56. package/cssVars/useCurrentColorScheme.js +1 -0
  57. package/cssVars/useCurrentColorScheme.mjs +1 -0
  58. package/display/display.d.mts +49 -1
  59. package/display/display.d.ts +49 -1
  60. package/display/display.js +2 -1
  61. package/display/display.mjs +2 -1
  62. package/flexbox/flexbox.d.mts +14 -14
  63. package/flexbox/flexbox.d.ts +14 -14
  64. package/getThemeValue/getThemeValue.d.mts +2 -1
  65. package/getThemeValue/getThemeValue.d.ts +2 -1
  66. package/getThemeValue/getThemeValue.js +6 -2
  67. package/getThemeValue/getThemeValue.mjs +7 -3
  68. package/index.js +1 -1
  69. package/index.mjs +1 -1
  70. package/memoize/memoize.d.mts +1 -1
  71. package/memoize/memoize.d.ts +1 -1
  72. package/package.json +59 -59
  73. package/palette/palette.d.mts +4 -3
  74. package/palette/palette.d.ts +4 -3
  75. package/palette/palette.js +1 -0
  76. package/palette/palette.mjs +2 -0
  77. package/positions/positions.d.mts +49 -1
  78. package/positions/positions.d.ts +49 -1
  79. package/positions/positions.js +2 -1
  80. package/positions/positions.mjs +2 -1
  81. package/propsToClassKey/propsToClassKey.d.mts +5 -0
  82. package/propsToClassKey/propsToClassKey.d.ts +5 -0
  83. package/propsToClassKey/propsToClassKey.js +1 -1
  84. package/propsToClassKey/propsToClassKey.mjs +1 -1
  85. package/shadows/shadows.d.mts +4 -4
  86. package/shadows/shadows.d.ts +4 -4
  87. package/sizing/sizing.d.mts +10 -10
  88. package/sizing/sizing.d.ts +10 -10
  89. package/sizing/sizing.js +7 -2
  90. package/sizing/sizing.mjs +5 -1
  91. package/spacing/spacing.d.mts +10 -14
  92. package/spacing/spacing.d.ts +10 -14
  93. package/spacing/spacing.js +17 -13
  94. package/spacing/spacing.mjs +16 -9
  95. package/styleFunctionSx/defaultSxConfig.d.mts +1 -1
  96. package/styleFunctionSx/defaultSxConfig.d.ts +1 -1
  97. package/styleFunctionSx/extendSxProp.d.mts +4 -2
  98. package/styleFunctionSx/extendSxProp.d.ts +4 -2
  99. package/styled/styled.d.mts +1 -1
  100. package/styled/styled.d.ts +1 -1
  101. package/typography/typography.d.mts +10 -10
  102. package/typography/typography.d.ts +10 -10
  103. package/useTheme/useTheme.d.mts +4 -2
  104. package/useTheme/useTheme.d.ts +4 -2
  105. package/useThemeProps/getThemeProps.d.mts +2 -2
  106. package/useThemeProps/getThemeProps.d.ts +2 -2
  107. package/useThemeProps/index.d.mts +1 -1
  108. package/useThemeProps/index.d.ts +1 -1
  109. package/useThemeProps/useThemeProps.js +7 -6
  110. package/useThemeProps/useThemeProps.mjs +7 -6
  111. package/useThemeWithoutDefault/useThemeWithoutDefault.d.mts +2 -1
  112. package/useThemeWithoutDefault/useThemeWithoutDefault.d.ts +2 -1
  113. package/useThemeWithoutDefault/useThemeWithoutDefault.js +2 -2
  114. package/useThemeWithoutDefault/useThemeWithoutDefault.mjs +2 -2
  115. package/version/index.js +3 -3
  116. package/version/index.mjs +3 -3
@@ -1,15 +1,17 @@
1
- import { PropsFor, SimpleStyleFunction } from "../style/index.js";
2
- export const border: SimpleStyleFunction<'border'>;
3
- export const borderTop: SimpleStyleFunction<'borderTop'>;
4
- export const borderRight: SimpleStyleFunction<'borderRight'>;
5
- export const borderBottom: SimpleStyleFunction<'borderBottom'>;
6
- export const borderLeft: SimpleStyleFunction<'borderLeft'>;
7
- export const borderColor: SimpleStyleFunction<'borderColor'>;
8
- export const borderTopColor: SimpleStyleFunction<'borderTopColor'>;
9
- export const borderRightColor: SimpleStyleFunction<'borderRightColor'>;
10
- export const borderBottomColor: SimpleStyleFunction<'borderBottomColor'>;
11
- export const borderLeftColor: SimpleStyleFunction<'borderLeftColor'>;
12
- export const borderRadius: SimpleStyleFunction<'borderRadius'>;
1
+ import type { PropsFor, SimpleStyleFunction } from "../style/index.js";
2
+ export declare const border: SimpleStyleFunction<"border">;
3
+ export declare const borderTop: SimpleStyleFunction<"borderTop">;
4
+ export declare const borderRight: SimpleStyleFunction<"borderRight">;
5
+ export declare const borderBottom: SimpleStyleFunction<"borderBottom">;
6
+ export declare const borderLeft: SimpleStyleFunction<"borderLeft">;
7
+ export declare const borderColor: SimpleStyleFunction<"borderColor">;
8
+ export declare const borderTopColor: SimpleStyleFunction<"borderTopColor">;
9
+ export declare const borderRightColor: SimpleStyleFunction<"borderRightColor">;
10
+ export declare const borderBottomColor: SimpleStyleFunction<"borderBottomColor">;
11
+ export declare const borderLeftColor: SimpleStyleFunction<"borderLeftColor">;
12
+ export declare const outline: SimpleStyleFunction<"outline">;
13
+ export declare const outlineColor: SimpleStyleFunction<"outlineColor">;
14
+ export declare const borderRadius: SimpleStyleFunction<'borderRadius'>;
13
15
  declare const borders: SimpleStyleFunction<'border' | 'borderTop' | 'borderRight' | 'borderBottom' | 'borderLeft' | 'borderColor' | 'borderRadius'>;
14
16
  export type BordersProps = PropsFor<typeof borders>;
15
17
  export default borders;
@@ -12,6 +12,7 @@ var _style = _interopRequireDefault(require("../style"));
12
12
  var _compose = _interopRequireDefault(require("../compose"));
13
13
  var _spacing = require("../spacing");
14
14
  var _breakpoints = require("../breakpoints");
15
+ /** @internal */
15
16
  function borderTransform(value) {
16
17
  if (typeof value !== 'number') {
17
18
  return value;
@@ -22,7 +23,7 @@ function createBorderStyle(prop, transform) {
22
23
  return (0, _style.default)({
23
24
  prop,
24
25
  themeKey: 'borders',
25
- transform
26
+ transform: transform
26
27
  });
27
28
  }
28
29
  const border = exports.border = createBorderStyle('border', borderTransform);
@@ -37,9 +38,6 @@ const borderBottomColor = exports.borderBottomColor = createBorderStyle('borderB
37
38
  const borderLeftColor = exports.borderLeftColor = createBorderStyle('borderLeftColor');
38
39
  const outline = exports.outline = createBorderStyle('outline', borderTransform);
39
40
  const outlineColor = exports.outlineColor = createBorderStyle('outlineColor');
40
-
41
- // false positive
42
- // eslint-disable-next-line react/function-component-definition
43
41
  const borderRadius = props => {
44
42
  if (props.borderRadius !== undefined && props.borderRadius !== null) {
45
43
  const transformer = (0, _spacing.createUnaryUnit)(props.theme, 'shape.borderRadius', 4, 'borderRadius');
@@ -3,6 +3,8 @@ import style from "../style/index.mjs";
3
3
  import compose from "../compose/index.mjs";
4
4
  import { createUnaryUnit, getValue } from "../spacing/index.mjs";
5
5
  import { handleBreakpoints } from "../breakpoints/index.mjs";
6
+
7
+ /** @internal */
6
8
  export function borderTransform(value) {
7
9
  if (typeof value !== 'number') {
8
10
  return value;
@@ -13,7 +15,7 @@ function createBorderStyle(prop, transform) {
13
15
  return style({
14
16
  prop,
15
17
  themeKey: 'borders',
16
- transform
18
+ transform: transform
17
19
  });
18
20
  }
19
21
  export const border = createBorderStyle('border', borderTransform);
@@ -28,9 +30,6 @@ export const borderBottomColor = createBorderStyle('borderBottomColor');
28
30
  export const borderLeftColor = createBorderStyle('borderLeftColor');
29
31
  export const outline = createBorderStyle('outline', borderTransform);
30
32
  export const outlineColor = createBorderStyle('outlineColor');
31
-
32
- // false positive
33
- // eslint-disable-next-line react/function-component-definition
34
33
  export const borderRadius = props => {
35
34
  if (props.borderRadius !== undefined && props.borderRadius !== null) {
36
35
  const transformer = createUnaryUnit(props.theme, 'shape.borderRadius', 4, 'borderRadius');
@@ -1,22 +1,19 @@
1
- import { CSSObject } from '@mui/styled-engine';
2
- import { Breakpoints } from "../createBreakpoints/createBreakpoints.mjs";
1
+ import type { CSSObject } from '@mui/styled-engine';
2
+ import type { Breakpoints } from "../createBreakpoints/createBreakpoints.mjs";
3
3
  import type { Breakpoint, Theme } from "../createTheme/index.mjs";
4
- import { ResponsiveStyleValue } from "../styleFunctionSx/index.mjs";
5
- import { StyleFunction } from "../style/index.mjs";
6
- export const DEFAULT_BREAKPOINTS: Breakpoints;
4
+ import type { ResponsiveStyleValue } from "../styleFunctionSx/index.mjs";
5
+ import type { StyleFunction } from "../style/index.mjs";
6
+ export declare const DEFAULT_BREAKPOINTS: Breakpoints;
7
+ export declare function handleBreakpoints<Props>(props: Props, propValue: any, styleFromPropValue: (value: any, breakpoint?: Breakpoint) => any): any;
8
+ export declare function iterateBreakpoints(target: any, theme: Theme | undefined, propValue: any, callback: (mediaKey: string | undefined, value: any, initialKey?: string) => any): any;
9
+ type DefaultBreakPoints = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
10
+ declare function setupBreakpoints<Props, BreakpointsInput extends string = DefaultBreakPoints>(styleFunction: StyleFunction<Props>): StyleFunction<Partial<Record<BreakpointsInput, Props>> & Props>;
11
+ export declare function mergeBreakpointsInOrder(breakpoints: Breakpoints, ...styles: CSSObject[]): CSSObject;
7
12
  export interface ResolveBreakpointValuesOptions<T> {
8
13
  values: ResponsiveStyleValue<T>;
9
14
  breakpoints?: Breakpoints['values'] | undefined;
10
15
  base?: Record<string, boolean> | undefined;
11
16
  }
12
- export function resolveBreakpointValues<T>(options: ResolveBreakpointValuesOptions<T>): Record<string, T>;
13
- export function mergeBreakpointsInOrder(breakpoints: Breakpoints, styles: CSSObject[]): CSSObject;
14
- export function iterateBreakpoints(target: any, theme: Theme, propValue: any, callback: (mediaKey: string | undefined, value: any, initialKey?: string) => any): any;
15
- export function handleBreakpoints<Props>(props: Props, propValue: any, styleFromPropValue: (value: any, breakpoint?: Breakpoint) => any): any;
16
- export function hasBreakpoint(breakpoints: Breakpoints, value: any): boolean;
17
- type DefaultBreakPoints = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
18
-
19
- /**
20
- * @returns An enhanced stylefunction that considers breakpoints
21
- */
22
- export default function breakpoints<Props, BreakpointsInput extends string = DefaultBreakPoints>(styleFunction: StyleFunction<Props>): StyleFunction<Partial<Record<BreakpointsInput, Props>> & Props>;
17
+ export declare function resolveBreakpointValues<T>(options: ResolveBreakpointValuesOptions<T>): Record<string, T>;
18
+ export declare function hasBreakpoint(breakpoints: Breakpoints, value: any): boolean;
19
+ export default setupBreakpoints;
@@ -1,22 +1,19 @@
1
- import { CSSObject } from '@mui/styled-engine';
2
- import { Breakpoints } from "../createBreakpoints/createBreakpoints.js";
1
+ import type { CSSObject } from '@mui/styled-engine';
2
+ import type { Breakpoints } from "../createBreakpoints/createBreakpoints.js";
3
3
  import type { Breakpoint, Theme } from "../createTheme/index.js";
4
- import { ResponsiveStyleValue } from "../styleFunctionSx/index.js";
5
- import { StyleFunction } from "../style/index.js";
6
- export const DEFAULT_BREAKPOINTS: Breakpoints;
4
+ import type { ResponsiveStyleValue } from "../styleFunctionSx/index.js";
5
+ import type { StyleFunction } from "../style/index.js";
6
+ export declare const DEFAULT_BREAKPOINTS: Breakpoints;
7
+ export declare function handleBreakpoints<Props>(props: Props, propValue: any, styleFromPropValue: (value: any, breakpoint?: Breakpoint) => any): any;
8
+ export declare function iterateBreakpoints(target: any, theme: Theme | undefined, propValue: any, callback: (mediaKey: string | undefined, value: any, initialKey?: string) => any): any;
9
+ type DefaultBreakPoints = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
10
+ declare function setupBreakpoints<Props, BreakpointsInput extends string = DefaultBreakPoints>(styleFunction: StyleFunction<Props>): StyleFunction<Partial<Record<BreakpointsInput, Props>> & Props>;
11
+ export declare function mergeBreakpointsInOrder(breakpoints: Breakpoints, ...styles: CSSObject[]): CSSObject;
7
12
  export interface ResolveBreakpointValuesOptions<T> {
8
13
  values: ResponsiveStyleValue<T>;
9
14
  breakpoints?: Breakpoints['values'] | undefined;
10
15
  base?: Record<string, boolean> | undefined;
11
16
  }
12
- export function resolveBreakpointValues<T>(options: ResolveBreakpointValuesOptions<T>): Record<string, T>;
13
- export function mergeBreakpointsInOrder(breakpoints: Breakpoints, styles: CSSObject[]): CSSObject;
14
- export function iterateBreakpoints(target: any, theme: Theme, propValue: any, callback: (mediaKey: string | undefined, value: any, initialKey?: string) => any): any;
15
- export function handleBreakpoints<Props>(props: Props, propValue: any, styleFromPropValue: (value: any, breakpoint?: Breakpoint) => any): any;
16
- export function hasBreakpoint(breakpoints: Breakpoints, value: any): boolean;
17
- type DefaultBreakPoints = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
18
-
19
- /**
20
- * @returns An enhanced stylefunction that considers breakpoints
21
- */
22
- export default function breakpoints<Props, BreakpointsInput extends string = DefaultBreakPoints>(styleFunction: StyleFunction<Props>): StyleFunction<Partial<Record<BreakpointsInput, Props>> & Props>;
17
+ export declare function resolveBreakpointValues<T>(options: ResolveBreakpointValuesOptions<T>): Record<string, T>;
18
+ export declare function hasBreakpoint(breakpoints: Breakpoints, value: any): boolean;
19
+ export default setupBreakpoints;
@@ -26,6 +26,7 @@ const EMPTY_THEME = {};
26
26
 
27
27
  // The breakpoint **start** at this value.
28
28
  // For instance with the first breakpoint xs: [xs, sm[.
29
+ /** @internal */
29
30
  const values = exports.values = {
30
31
  xs: 0,
31
32
  // phone
@@ -38,7 +39,7 @@ const values = exports.values = {
38
39
  xl: 1536 // large screen
39
40
  };
40
41
  const DEFAULT_BREAKPOINTS = exports.DEFAULT_BREAKPOINTS = (0, _createBreakpoints.default)({
41
- values
42
+ values: values
42
43
  });
43
44
  const defaultContainerQueries = {
44
45
  containerQueries: containerName => ({
@@ -80,9 +81,7 @@ function iterateBreakpoints(target, theme, propValue, callback) {
80
81
  if (containerKey) {
81
82
  buildBreakpoint(target, containerKey, propValue[key], key, callback);
82
83
  }
83
- }
84
- // key is key
85
- else if (key in breakpointValues) {
84
+ } else if (key in breakpointValues) {
86
85
  const mediaKey = breakpoints.up(key);
87
86
  buildBreakpoint(target, mediaKey, propValue[key], key, callback);
88
87
  } else {
@@ -100,7 +99,6 @@ function buildBreakpoint(target, mediaKey, value, initialKey, callback) {
100
99
  callback(mediaKey, value, initialKey);
101
100
  }
102
101
  function setupBreakpoints(styleFunction) {
103
- // eslint-disable-next-line react/function-component-definition
104
102
  const newStyleFunction = props => {
105
103
  const theme = props.theme || {};
106
104
  const base = styleFunction(props);
@@ -128,6 +126,8 @@ function setupBreakpoints(styleFunction) {
128
126
  newStyleFunction.filterProps = ['xs', 'sm', 'md', 'lg', 'xl', ...styleFunction.filterProps];
129
127
  return newStyleFunction;
130
128
  }
129
+
130
+ /** @internal */
131
131
  function createEmptyBreakpointObject(breakpoints = DEFAULT_BREAKPOINTS) {
132
132
  const {
133
133
  internal_mediaKeys: mediaKeys
@@ -138,6 +138,8 @@ function createEmptyBreakpointObject(breakpoints = DEFAULT_BREAKPOINTS) {
138
138
  }
139
139
  return result;
140
140
  }
141
+
142
+ /** @internal */
141
143
  function removeUnusedBreakpoints(breakpoints, style) {
142
144
  const breakpointKeys = breakpoints.internal_mediaKeys;
143
145
  for (let i = 0; i < breakpointKeys.length; i += 1) {
@@ -154,11 +156,8 @@ function mergeBreakpointsInOrder(breakpoints, ...styles) {
154
156
  return removeUnusedBreakpoints(breakpoints, mergedOutput);
155
157
  }
156
158
 
157
- // compute base for responsive values; e.g.,
158
- // [1,2,3] => {xs: true, sm: true, md: true}
159
- // {xs: 1, sm: 2, md: 3} => {xs: true, sm: true, md: true}
159
+ /** @internal */
160
160
  function computeBreakpointsBase(breakpointValues, themeBreakpoints) {
161
- // fixed value
162
161
  if (typeof breakpointValues !== 'object') {
163
162
  return {};
164
163
  }
@@ -179,11 +178,12 @@ function computeBreakpointsBase(breakpointValues, themeBreakpoints) {
179
178
  }
180
179
  return base;
181
180
  }
182
- function resolveBreakpointValues({
183
- values: breakpointValues,
184
- breakpoints: themeBreakpoints,
185
- base: customBase
186
- }) {
181
+ function resolveBreakpointValues(options) {
182
+ const {
183
+ values: breakpointValues,
184
+ breakpoints: themeBreakpoints,
185
+ base: customBase
186
+ } = options;
187
187
  const base = customBase || computeBreakpointsBase(breakpointValues, themeBreakpoints);
188
188
  const keys = Object.keys(base);
189
189
  if (keys.length === 0) {
@@ -194,8 +194,9 @@ function resolveBreakpointValues({
194
194
  if (Array.isArray(breakpointValues)) {
195
195
  acc[breakpoint] = breakpointValues[i] != null ? breakpointValues[i] : breakpointValues[previous];
196
196
  previous = i;
197
- } else if (typeof breakpointValues === 'object') {
198
- acc[breakpoint] = breakpointValues[breakpoint] != null ? breakpointValues[breakpoint] : breakpointValues[previous];
197
+ } else if (typeof breakpointValues === 'object' && breakpointValues) {
198
+ const bv = breakpointValues;
199
+ acc[breakpoint] = bv[breakpoint] != null ? bv[breakpoint] : bv[previous];
199
200
  previous = breakpoint;
200
201
  } else {
201
202
  acc[breakpoint] = breakpointValues;
@@ -9,6 +9,7 @@ const EMPTY_THEME = {};
9
9
 
10
10
  // The breakpoint **start** at this value.
11
11
  // For instance with the first breakpoint xs: [xs, sm[.
12
+ /** @internal */
12
13
  export const values = {
13
14
  xs: 0,
14
15
  // phone
@@ -21,7 +22,7 @@ export const values = {
21
22
  xl: 1536 // large screen
22
23
  };
23
24
  export const DEFAULT_BREAKPOINTS = createBreakpoints({
24
- values
25
+ values: values
25
26
  });
26
27
  const defaultContainerQueries = {
27
28
  containerQueries: containerName => ({
@@ -63,9 +64,7 @@ export function iterateBreakpoints(target, theme, propValue, callback) {
63
64
  if (containerKey) {
64
65
  buildBreakpoint(target, containerKey, propValue[key], key, callback);
65
66
  }
66
- }
67
- // key is key
68
- else if (key in breakpointValues) {
67
+ } else if (key in breakpointValues) {
69
68
  const mediaKey = breakpoints.up(key);
70
69
  buildBreakpoint(target, mediaKey, propValue[key], key, callback);
71
70
  } else {
@@ -83,7 +82,6 @@ function buildBreakpoint(target, mediaKey, value, initialKey, callback) {
83
82
  callback(mediaKey, value, initialKey);
84
83
  }
85
84
  function setupBreakpoints(styleFunction) {
86
- // eslint-disable-next-line react/function-component-definition
87
85
  const newStyleFunction = props => {
88
86
  const theme = props.theme || {};
89
87
  const base = styleFunction(props);
@@ -111,6 +109,8 @@ function setupBreakpoints(styleFunction) {
111
109
  newStyleFunction.filterProps = ['xs', 'sm', 'md', 'lg', 'xl', ...styleFunction.filterProps];
112
110
  return newStyleFunction;
113
111
  }
112
+
113
+ /** @internal */
114
114
  export function createEmptyBreakpointObject(breakpoints = DEFAULT_BREAKPOINTS) {
115
115
  const {
116
116
  internal_mediaKeys: mediaKeys
@@ -121,6 +121,8 @@ export function createEmptyBreakpointObject(breakpoints = DEFAULT_BREAKPOINTS) {
121
121
  }
122
122
  return result;
123
123
  }
124
+
125
+ /** @internal */
124
126
  export function removeUnusedBreakpoints(breakpoints, style) {
125
127
  const breakpointKeys = breakpoints.internal_mediaKeys;
126
128
  for (let i = 0; i < breakpointKeys.length; i += 1) {
@@ -137,11 +139,8 @@ export function mergeBreakpointsInOrder(breakpoints, ...styles) {
137
139
  return removeUnusedBreakpoints(breakpoints, mergedOutput);
138
140
  }
139
141
 
140
- // compute base for responsive values; e.g.,
141
- // [1,2,3] => {xs: true, sm: true, md: true}
142
- // {xs: 1, sm: 2, md: 3} => {xs: true, sm: true, md: true}
142
+ /** @internal */
143
143
  export function computeBreakpointsBase(breakpointValues, themeBreakpoints) {
144
- // fixed value
145
144
  if (typeof breakpointValues !== 'object') {
146
145
  return {};
147
146
  }
@@ -162,11 +161,12 @@ export function computeBreakpointsBase(breakpointValues, themeBreakpoints) {
162
161
  }
163
162
  return base;
164
163
  }
165
- export function resolveBreakpointValues({
166
- values: breakpointValues,
167
- breakpoints: themeBreakpoints,
168
- base: customBase
169
- }) {
164
+ export function resolveBreakpointValues(options) {
165
+ const {
166
+ values: breakpointValues,
167
+ breakpoints: themeBreakpoints,
168
+ base: customBase
169
+ } = options;
170
170
  const base = customBase || computeBreakpointsBase(breakpointValues, themeBreakpoints);
171
171
  const keys = Object.keys(base);
172
172
  if (keys.length === 0) {
@@ -177,8 +177,9 @@ export function resolveBreakpointValues({
177
177
  if (Array.isArray(breakpointValues)) {
178
178
  acc[breakpoint] = breakpointValues[i] != null ? breakpointValues[i] : breakpointValues[previous];
179
179
  previous = i;
180
- } else if (typeof breakpointValues === 'object') {
181
- acc[breakpoint] = breakpointValues[breakpoint] != null ? breakpointValues[breakpoint] : breakpointValues[previous];
180
+ } else if (typeof breakpointValues === 'object' && breakpointValues) {
181
+ const bv = breakpointValues;
182
+ acc[breakpoint] = bv[breakpoint] != null ? bv[breakpoint] : bv[previous];
182
183
  previous = breakpoint;
183
184
  } else {
184
185
  acc[breakpoint] = breakpointValues;
@@ -1,15 +1,8 @@
1
- import { StyleFunction } from "../style/index.mjs";
2
-
3
- /**
4
- * given a list of StyleFunction return the intersection of the props each individual
5
- * StyleFunction requires.
6
- *
7
- * If `firstFn` requires { color: string } and `secondFn` requires { spacing: number }
8
- * their composed function requires { color: string, spacing: number }
9
- */
1
+ import type { StyleFunction } from "../style/index.mjs";
10
2
  type ComposedArg<T> = T extends Array<(arg: infer P) => any> ? P : never;
11
3
  type ComposedOwnerState<T> = ComposedArg<T>;
12
4
  export type ComposedStyleFunction<T extends Array<StyleFunction<any>>> = StyleFunction<ComposedOwnerState<T>> & {
13
5
  filterProps: string[];
14
6
  };
15
- export default function compose<T extends Array<StyleFunction<any>>>(...args: T): ComposedStyleFunction<T>;
7
+ declare function compose<T extends Array<StyleFunction<any>>>(...styles: T): ComposedStyleFunction<T>;
8
+ export default compose;
@@ -1,15 +1,8 @@
1
- import { StyleFunction } from "../style/index.js";
2
-
3
- /**
4
- * given a list of StyleFunction return the intersection of the props each individual
5
- * StyleFunction requires.
6
- *
7
- * If `firstFn` requires { color: string } and `secondFn` requires { spacing: number }
8
- * their composed function requires { color: string, spacing: number }
9
- */
1
+ import type { StyleFunction } from "../style/index.js";
10
2
  type ComposedArg<T> = T extends Array<(arg: infer P) => any> ? P : never;
11
3
  type ComposedOwnerState<T> = ComposedArg<T>;
12
4
  export type ComposedStyleFunction<T extends Array<StyleFunction<any>>> = StyleFunction<ComposedOwnerState<T>> & {
13
5
  filterProps: string[];
14
6
  };
15
- export default function compose<T extends Array<StyleFunction<any>>>(...args: T): ComposedStyleFunction<T>;
7
+ declare function compose<T extends Array<StyleFunction<any>>>(...styles: T): ComposedStyleFunction<T>;
8
+ export default compose;
@@ -13,8 +13,6 @@ function compose(...styles) {
13
13
  });
14
14
  return acc;
15
15
  }, {});
16
-
17
- // eslint-disable-next-line react/function-component-definition
18
16
  const fn = props => {
19
17
  const result = {};
20
18
  for (const prop in props) {
@@ -6,8 +6,6 @@ function compose(...styles) {
6
6
  });
7
7
  return acc;
8
8
  }, {});
9
-
10
- // eslint-disable-next-line react/function-component-definition
11
9
  const fn = props => {
12
10
  const result = {};
13
11
  for (const prop in props) {
@@ -1,9 +1,9 @@
1
- import { OverridableComponent } from '@mui/types';
2
- import { BoxTypeMap } from "../Box/index.mjs";
3
- import { Theme as SystemTheme } from "../createTheme/index.mjs";
1
+ import type { OverridableComponent } from '@mui/types';
2
+ import type { BoxTypeMap } from "../Box/index.mjs";
3
+ import type { Theme as SystemTheme } from "../createTheme/index.mjs";
4
4
  export default function createBox<T extends object = SystemTheme, AdditionalProps extends Record<string, unknown> = {}>(options?: {
5
5
  themeId?: string | undefined;
6
- defaultTheme: T;
6
+ defaultTheme?: T | undefined;
7
7
  defaultClassName?: string | undefined;
8
8
  generateClassName?: ((componentName: string) => string) | undefined;
9
9
  }): OverridableComponent<BoxTypeMap<AdditionalProps, 'div', T>>;
@@ -1,9 +1,9 @@
1
- import { OverridableComponent } from '@mui/types';
2
- import { BoxTypeMap } from "../Box/index.js";
3
- import { Theme as SystemTheme } from "../createTheme/index.js";
1
+ import type { OverridableComponent } from '@mui/types';
2
+ import type { BoxTypeMap } from "../Box/index.js";
3
+ import type { Theme as SystemTheme } from "../createTheme/index.js";
4
4
  export default function createBox<T extends object = SystemTheme, AdditionalProps extends Record<string, unknown> = {}>(options?: {
5
5
  themeId?: string | undefined;
6
- defaultTheme: T;
6
+ defaultTheme?: T | undefined;
7
7
  defaultClassName?: string | undefined;
8
8
  generateClassName?: ((componentName: string) => string) | undefined;
9
9
  }): OverridableComponent<BoxTypeMap<AdditionalProps, 'div', T>>;
@@ -1,68 +1,17 @@
1
- import { OverridableStringUnion } from '@mui/types';
1
+ import type { OverridableStringUnion } from '@mui/types';
2
2
  export interface BreakpointOverrides {}
3
3
  export type Breakpoint = OverridableStringUnion<'xs' | 'sm' | 'md' | 'lg' | 'xl', BreakpointOverrides>;
4
- export const keys: Breakpoint[];
5
-
6
- // Keep in sync with docs/src/pages/customization/breakpoints/breakpoints.md
7
- // #host-reference
4
+ export declare const breakpointKeys: Breakpoint[];
8
5
  export interface Breakpoints {
9
6
  keys: Breakpoint[];
10
- /**
11
- * Each breakpoint (a key) matches with a fixed screen width (a value).
12
- * @default {
13
- * // extra-small
14
- * xs: 0,
15
- * // small
16
- * sm: 600,
17
- * // medium
18
- * md: 900,
19
- * // large
20
- * lg: 1200,
21
- * // extra-large
22
- * xl: 1536,
23
- * }
24
- */
25
7
  values: { [key in Breakpoint]: number };
26
- /**
27
- * @param key - A breakpoint key (`xs`, `sm`, etc.) or a screen width number in px.
28
- * @returns A media query string ready to be used with most styling solutions, which matches screen widths greater than the screen size given by the breakpoint key (inclusive).
29
- * @see [API documentation](https://mui.com/material-ui/customization/breakpoints/#theme-breakpoints-up-key-media-query)
30
- */
31
8
  up: (key: Breakpoint | number) => string;
32
- /**
33
- * @param key - A breakpoint key (`xs`, `sm`, etc.) or a screen width number in px.
34
- * @returns A media query string ready to be used with most styling solutions, which matches screen widths less than the screen size given by the breakpoint key (exclusive).
35
- * @see [API documentation](https://mui.com/material-ui/customization/breakpoints/#theme-breakpoints-down-key-media-query)
36
- */
37
9
  down: (key: Breakpoint | number) => string;
38
- /**
39
- * @param start - A breakpoint key (`xs`, `sm`, etc.) or a screen width number in px.
40
- * @param end - A breakpoint key (`xs`, `sm`, etc.) or a screen width number in px.
41
- * @returns A media query string ready to be used with most styling solutions, which matches screen widths greater than
42
- * the screen size given by the breakpoint key in the first argument (inclusive) and less than the screen size given by the breakpoint key in the second argument (exclusive).
43
- * @see [API documentation](https://mui.com/material-ui/customization/breakpoints/#theme-breakpoints-between-start-end-media-query)
44
- */
45
10
  between: (start: Breakpoint | number, end: Breakpoint | number) => string;
46
- /**
47
- * @param key - A breakpoint key (`xs`, `sm`, etc.) or a screen width number in px.
48
- * @returns A media query string ready to be used with most styling solutions, which matches screen widths starting from
49
- * the screen size given by the breakpoint key (inclusive) and stopping at the screen size given by the next breakpoint key (exclusive).
50
- * @see [API documentation](https://mui.com/material-ui/customization/breakpoints/#theme-breakpoints-only-key-media-query)
51
- */
52
11
  only: (key: Breakpoint) => string;
53
- /**
54
- * @param key - A breakpoint key (`xs`, `sm`, etc.).
55
- * @returns A media query string ready to be used with most styling solutions, which matches screen widths stopping at
56
- * the screen size given by the breakpoint key (exclusive) and starting at the screen size given by the next breakpoint key (inclusive).
57
- */
58
12
  not: (key: Breakpoint) => string;
59
- /**
60
- * The unit used for the breakpoint's values.
61
- * @default 'px'
62
- */
63
13
  unit?: string | undefined;
64
14
  /**
65
- * Media query keys
66
15
  * @ignore - Do not document.
67
16
  */
68
17
  internal_mediaKeys: string[];
@@ -80,4 +29,4 @@ export interface BreakpointsOptions extends Partial<Breakpoints> {
80
29
  */
81
30
  unit?: string | undefined;
82
31
  }
83
- export default function createBreakpoints(options: BreakpointsOptions): Breakpoints;
32
+ export default function createBreakpoints(breakpoints: BreakpointsOptions): Breakpoints;
@@ -1,68 +1,17 @@
1
- import { OverridableStringUnion } from '@mui/types';
1
+ import type { OverridableStringUnion } from '@mui/types';
2
2
  export interface BreakpointOverrides {}
3
3
  export type Breakpoint = OverridableStringUnion<'xs' | 'sm' | 'md' | 'lg' | 'xl', BreakpointOverrides>;
4
- export const keys: Breakpoint[];
5
-
6
- // Keep in sync with docs/src/pages/customization/breakpoints/breakpoints.md
7
- // #host-reference
4
+ export declare const breakpointKeys: Breakpoint[];
8
5
  export interface Breakpoints {
9
6
  keys: Breakpoint[];
10
- /**
11
- * Each breakpoint (a key) matches with a fixed screen width (a value).
12
- * @default {
13
- * // extra-small
14
- * xs: 0,
15
- * // small
16
- * sm: 600,
17
- * // medium
18
- * md: 900,
19
- * // large
20
- * lg: 1200,
21
- * // extra-large
22
- * xl: 1536,
23
- * }
24
- */
25
7
  values: { [key in Breakpoint]: number };
26
- /**
27
- * @param key - A breakpoint key (`xs`, `sm`, etc.) or a screen width number in px.
28
- * @returns A media query string ready to be used with most styling solutions, which matches screen widths greater than the screen size given by the breakpoint key (inclusive).
29
- * @see [API documentation](https://mui.com/material-ui/customization/breakpoints/#theme-breakpoints-up-key-media-query)
30
- */
31
8
  up: (key: Breakpoint | number) => string;
32
- /**
33
- * @param key - A breakpoint key (`xs`, `sm`, etc.) or a screen width number in px.
34
- * @returns A media query string ready to be used with most styling solutions, which matches screen widths less than the screen size given by the breakpoint key (exclusive).
35
- * @see [API documentation](https://mui.com/material-ui/customization/breakpoints/#theme-breakpoints-down-key-media-query)
36
- */
37
9
  down: (key: Breakpoint | number) => string;
38
- /**
39
- * @param start - A breakpoint key (`xs`, `sm`, etc.) or a screen width number in px.
40
- * @param end - A breakpoint key (`xs`, `sm`, etc.) or a screen width number in px.
41
- * @returns A media query string ready to be used with most styling solutions, which matches screen widths greater than
42
- * the screen size given by the breakpoint key in the first argument (inclusive) and less than the screen size given by the breakpoint key in the second argument (exclusive).
43
- * @see [API documentation](https://mui.com/material-ui/customization/breakpoints/#theme-breakpoints-between-start-end-media-query)
44
- */
45
10
  between: (start: Breakpoint | number, end: Breakpoint | number) => string;
46
- /**
47
- * @param key - A breakpoint key (`xs`, `sm`, etc.) or a screen width number in px.
48
- * @returns A media query string ready to be used with most styling solutions, which matches screen widths starting from
49
- * the screen size given by the breakpoint key (inclusive) and stopping at the screen size given by the next breakpoint key (exclusive).
50
- * @see [API documentation](https://mui.com/material-ui/customization/breakpoints/#theme-breakpoints-only-key-media-query)
51
- */
52
11
  only: (key: Breakpoint) => string;
53
- /**
54
- * @param key - A breakpoint key (`xs`, `sm`, etc.).
55
- * @returns A media query string ready to be used with most styling solutions, which matches screen widths stopping at
56
- * the screen size given by the breakpoint key (exclusive) and starting at the screen size given by the next breakpoint key (inclusive).
57
- */
58
12
  not: (key: Breakpoint) => string;
59
- /**
60
- * The unit used for the breakpoint's values.
61
- * @default 'px'
62
- */
63
13
  unit?: string | undefined;
64
14
  /**
65
- * Media query keys
66
15
  * @ignore - Do not document.
67
16
  */
68
17
  internal_mediaKeys: string[];
@@ -80,4 +29,4 @@ export interface BreakpointsOptions extends Partial<Breakpoints> {
80
29
  */
81
30
  unit?: string | undefined;
82
31
  }
83
- export default function createBreakpoints(options: BreakpointsOptions): Breakpoints;
32
+ export default function createBreakpoints(breakpoints: BreakpointsOptions): Breakpoints;
@@ -8,6 +8,10 @@ exports.default = createBreakpoints;
8
8
  // Sorted ASC by size. That's important.
9
9
  // It can't be configured as it's used statically for propTypes.
10
10
  const breakpointKeys = exports.breakpointKeys = ['xs', 'sm', 'md', 'lg', 'xl'];
11
+
12
+ // Keep in sync with docs/src/pages/customization/breakpoints/breakpoints.md
13
+ // #host-reference
14
+
11
15
  const sortBreakpointsValues = values => {
12
16
  const breakpointsAsArray = Object.keys(values).map(key => ({
13
17
  key,
@@ -26,18 +30,12 @@ const sortBreakpointsValues = values => {
26
30
  // Keep in mind that @media is inclusive by the CSS specification.
27
31
  function createBreakpoints(breakpoints) {
28
32
  const {
29
- // The breakpoint **start** at this value.
30
- // For instance with the first breakpoint xs: [xs, sm).
31
33
  values = {
32
34
  xs: 0,
33
- // phone
34
35
  sm: 600,
35
- // tablet
36
36
  md: 900,
37
- // small laptop
38
37
  lg: 1200,
39
- // desktop
40
- xl: 1536 // large screen
38
+ xl: 1536
41
39
  },
42
40
  unit = 'px',
43
41
  step = 5,
@@ -79,7 +77,7 @@ function createBreakpoints(breakpoints) {
79
77
  mediaKeys.push(up(keys[i]));
80
78
  }
81
79
  return {
82
- keys,
80
+ keys: keys,
83
81
  values: sortedValues,
84
82
  up,
85
83
  down,