@mui/system 7.0.0 → 7.0.2

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 (130) hide show
  1. package/CHANGELOG.md +100 -0
  2. package/cssVars/cssVarsParser.d.ts +1 -1
  3. package/esm/cssVars/cssVarsParser.d.ts +1 -1
  4. package/esm/index.js +1 -1
  5. package/esm/memoTheme.d.ts +1 -1
  6. package/esm/useThemeProps/getThemeProps.d.ts +0 -5
  7. package/esm/version/index.js +2 -2
  8. package/index.js +1 -1
  9. package/memoTheme.d.ts +1 -1
  10. package/modern/cssVars/cssVarsParser.d.ts +1 -1
  11. package/modern/memoTheme.d.ts +1 -1
  12. package/modern/useThemeProps/getThemeProps.d.ts +0 -5
  13. package/package.json +6 -14
  14. package/useThemeProps/getThemeProps.d.ts +0 -5
  15. package/version/index.js +2 -2
  16. package/modern/Box/Box.js +0 -30
  17. package/modern/Box/boxClasses.js +0 -3
  18. package/modern/Box/index.js +0 -3
  19. package/modern/Container/Container.js +0 -61
  20. package/modern/Container/ContainerProps.js +0 -1
  21. package/modern/Container/containerClasses.js +0 -7
  22. package/modern/Container/createContainer.js +0 -149
  23. package/modern/Container/index.js +0 -3
  24. package/modern/DefaultPropsProvider/DefaultPropsProvider.js +0 -64
  25. package/modern/DefaultPropsProvider/index.js +0 -1
  26. package/modern/GlobalStyles/GlobalStyles.js +0 -37
  27. package/modern/GlobalStyles/index.js +0 -2
  28. package/modern/Grid/Grid.js +0 -106
  29. package/modern/Grid/GridProps.js +0 -1
  30. package/modern/Grid/createGrid.js +0 -155
  31. package/modern/Grid/deleteLegacyGridProps.js +0 -41
  32. package/modern/Grid/gridClasses.js +0 -19
  33. package/modern/Grid/gridGenerator.js +0 -193
  34. package/modern/Grid/index.js +0 -7
  35. package/modern/Grid/traverseBreakpoints.js +0 -42
  36. package/modern/InitColorSchemeScript/InitColorSchemeScript.js +0 -78
  37. package/modern/InitColorSchemeScript/index.js +0 -1
  38. package/modern/RtlProvider/index.js +0 -24
  39. package/modern/Stack/Stack.js +0 -62
  40. package/modern/Stack/StackProps.js +0 -1
  41. package/modern/Stack/createStack.js +0 -173
  42. package/modern/Stack/index.js +0 -5
  43. package/modern/Stack/stackClasses.js +0 -7
  44. package/modern/ThemeProvider/ThemeProvider.js +0 -97
  45. package/modern/ThemeProvider/index.js +0 -1
  46. package/modern/borders/borders.js +0 -49
  47. package/modern/borders/index.js +0 -2
  48. package/modern/breakpoints/breakpoints.js +0 -171
  49. package/modern/breakpoints/index.js +0 -2
  50. package/modern/colorManipulator/colorManipulator.js +0 -349
  51. package/modern/colorManipulator/index.js +0 -1
  52. package/modern/compose/compose.js +0 -24
  53. package/modern/compose/index.js +0 -1
  54. package/modern/createBox/createBox.js +0 -35
  55. package/modern/createBox/index.js +0 -1
  56. package/modern/createBreakpoints/createBreakpoints.js +0 -81
  57. package/modern/createBreakpoints/index.js +0 -3
  58. package/modern/createStyled/createStyled.js +0 -276
  59. package/modern/createStyled/index.js +0 -2
  60. package/modern/createTheme/applyStyles.js +0 -87
  61. package/modern/createTheme/createSpacing.js +0 -31
  62. package/modern/createTheme/createTheme.js +0 -49
  63. package/modern/createTheme/index.js +0 -3
  64. package/modern/createTheme/shape.js +0 -4
  65. package/modern/cssContainerQueries/cssContainerQueries.js +0 -69
  66. package/modern/cssContainerQueries/index.js +0 -2
  67. package/modern/cssGrid/cssGrid.js +0 -85
  68. package/modern/cssGrid/index.js +0 -2
  69. package/modern/cssVars/createCssVarsProvider.js +0 -338
  70. package/modern/cssVars/createCssVarsTheme.js +0 -21
  71. package/modern/cssVars/createGetCssVar.js +0 -22
  72. package/modern/cssVars/cssVarsParser.js +0 -129
  73. package/modern/cssVars/getColorSchemeSelector.js +0 -26
  74. package/modern/cssVars/index.js +0 -5
  75. package/modern/cssVars/localStorageManager.js +0 -51
  76. package/modern/cssVars/prepareCssVars.js +0 -153
  77. package/modern/cssVars/prepareTypographyVars.js +0 -11
  78. package/modern/cssVars/useCurrentColorScheme.js +0 -228
  79. package/modern/display/display.js +0 -27
  80. package/modern/display/index.js +0 -2
  81. package/modern/flexbox/flexbox.js +0 -43
  82. package/modern/flexbox/index.js +0 -2
  83. package/modern/getThemeValue/getThemeValue.js +0 -51
  84. package/modern/getThemeValue/index.js +0 -2
  85. package/modern/index.js +0 -75
  86. package/modern/memoTheme.js +0 -28
  87. package/modern/memoize/index.js +0 -1
  88. package/modern/memoize/memoize.js +0 -9
  89. package/modern/merge/index.js +0 -1
  90. package/modern/merge/merge.js +0 -10
  91. package/modern/package.json +0 -1
  92. package/modern/palette/index.js +0 -2
  93. package/modern/palette/palette.js +0 -26
  94. package/modern/positions/index.js +0 -2
  95. package/modern/positions/positions.js +0 -22
  96. package/modern/preprocessStyles.js +0 -25
  97. package/modern/propsToClassKey/index.js +0 -1
  98. package/modern/propsToClassKey/propsToClassKey.js +0 -25
  99. package/modern/responsivePropType/index.js +0 -1
  100. package/modern/responsivePropType/responsivePropType.js +0 -3
  101. package/modern/shadows/index.js +0 -1
  102. package/modern/shadows/shadows.js +0 -6
  103. package/modern/sizing/index.js +0 -2
  104. package/modern/sizing/sizing.js +0 -64
  105. package/modern/spacing/index.js +0 -2
  106. package/modern/spacing/spacing.js +0 -157
  107. package/modern/style/index.js +0 -2
  108. package/modern/style/style.js +0 -75
  109. package/modern/styleFunctionSx/AliasesCSSProperties.js +0 -1
  110. package/modern/styleFunctionSx/OverwriteCSSProperties.js +0 -1
  111. package/modern/styleFunctionSx/StandardCssProperties.js +0 -1
  112. package/modern/styleFunctionSx/defaultSxConfig.js +0 -294
  113. package/modern/styleFunctionSx/extendSxProp.js +0 -51
  114. package/modern/styleFunctionSx/index.js +0 -4
  115. package/modern/styleFunctionSx/styleFunctionSx.js +0 -127
  116. package/modern/styled/index.js +0 -1
  117. package/modern/styled/styled.js +0 -3
  118. package/modern/typography/index.js +0 -2
  119. package/modern/typography/typography.js +0 -37
  120. package/modern/useMediaQuery/index.js +0 -2
  121. package/modern/useMediaQuery/useMediaQuery.js +0 -118
  122. package/modern/useTheme/index.js +0 -2
  123. package/modern/useTheme/useTheme.js +0 -9
  124. package/modern/useThemeProps/getThemeProps.js +0 -12
  125. package/modern/useThemeProps/index.js +0 -2
  126. package/modern/useThemeProps/useThemeProps.js +0 -20
  127. package/modern/useThemeWithoutDefault/index.js +0 -1
  128. package/modern/useThemeWithoutDefault/useThemeWithoutDefault.js +0 -12
  129. package/modern/version/index.js +0 -6
  130. package/tsconfig.build.tsbuildinfo +0 -1
@@ -1,294 +0,0 @@
1
- import { padding, margin } from "../spacing/index.js";
2
- import { borderRadius, borderTransform } from "../borders/index.js";
3
- import { gap, rowGap, columnGap } from "../cssGrid/index.js";
4
- import { paletteTransform } from "../palette/index.js";
5
- import { maxWidth, sizingTransform } from "../sizing/index.js";
6
- const defaultSxConfig = {
7
- // borders
8
- border: {
9
- themeKey: 'borders',
10
- transform: borderTransform
11
- },
12
- borderTop: {
13
- themeKey: 'borders',
14
- transform: borderTransform
15
- },
16
- borderRight: {
17
- themeKey: 'borders',
18
- transform: borderTransform
19
- },
20
- borderBottom: {
21
- themeKey: 'borders',
22
- transform: borderTransform
23
- },
24
- borderLeft: {
25
- themeKey: 'borders',
26
- transform: borderTransform
27
- },
28
- borderColor: {
29
- themeKey: 'palette'
30
- },
31
- borderTopColor: {
32
- themeKey: 'palette'
33
- },
34
- borderRightColor: {
35
- themeKey: 'palette'
36
- },
37
- borderBottomColor: {
38
- themeKey: 'palette'
39
- },
40
- borderLeftColor: {
41
- themeKey: 'palette'
42
- },
43
- outline: {
44
- themeKey: 'borders',
45
- transform: borderTransform
46
- },
47
- outlineColor: {
48
- themeKey: 'palette'
49
- },
50
- borderRadius: {
51
- themeKey: 'shape.borderRadius',
52
- style: borderRadius
53
- },
54
- // palette
55
- color: {
56
- themeKey: 'palette',
57
- transform: paletteTransform
58
- },
59
- bgcolor: {
60
- themeKey: 'palette',
61
- cssProperty: 'backgroundColor',
62
- transform: paletteTransform
63
- },
64
- backgroundColor: {
65
- themeKey: 'palette',
66
- transform: paletteTransform
67
- },
68
- // spacing
69
- p: {
70
- style: padding
71
- },
72
- pt: {
73
- style: padding
74
- },
75
- pr: {
76
- style: padding
77
- },
78
- pb: {
79
- style: padding
80
- },
81
- pl: {
82
- style: padding
83
- },
84
- px: {
85
- style: padding
86
- },
87
- py: {
88
- style: padding
89
- },
90
- padding: {
91
- style: padding
92
- },
93
- paddingTop: {
94
- style: padding
95
- },
96
- paddingRight: {
97
- style: padding
98
- },
99
- paddingBottom: {
100
- style: padding
101
- },
102
- paddingLeft: {
103
- style: padding
104
- },
105
- paddingX: {
106
- style: padding
107
- },
108
- paddingY: {
109
- style: padding
110
- },
111
- paddingInline: {
112
- style: padding
113
- },
114
- paddingInlineStart: {
115
- style: padding
116
- },
117
- paddingInlineEnd: {
118
- style: padding
119
- },
120
- paddingBlock: {
121
- style: padding
122
- },
123
- paddingBlockStart: {
124
- style: padding
125
- },
126
- paddingBlockEnd: {
127
- style: padding
128
- },
129
- m: {
130
- style: margin
131
- },
132
- mt: {
133
- style: margin
134
- },
135
- mr: {
136
- style: margin
137
- },
138
- mb: {
139
- style: margin
140
- },
141
- ml: {
142
- style: margin
143
- },
144
- mx: {
145
- style: margin
146
- },
147
- my: {
148
- style: margin
149
- },
150
- margin: {
151
- style: margin
152
- },
153
- marginTop: {
154
- style: margin
155
- },
156
- marginRight: {
157
- style: margin
158
- },
159
- marginBottom: {
160
- style: margin
161
- },
162
- marginLeft: {
163
- style: margin
164
- },
165
- marginX: {
166
- style: margin
167
- },
168
- marginY: {
169
- style: margin
170
- },
171
- marginInline: {
172
- style: margin
173
- },
174
- marginInlineStart: {
175
- style: margin
176
- },
177
- marginInlineEnd: {
178
- style: margin
179
- },
180
- marginBlock: {
181
- style: margin
182
- },
183
- marginBlockStart: {
184
- style: margin
185
- },
186
- marginBlockEnd: {
187
- style: margin
188
- },
189
- // display
190
- displayPrint: {
191
- cssProperty: false,
192
- transform: value => ({
193
- '@media print': {
194
- display: value
195
- }
196
- })
197
- },
198
- display: {},
199
- overflow: {},
200
- textOverflow: {},
201
- visibility: {},
202
- whiteSpace: {},
203
- // flexbox
204
- flexBasis: {},
205
- flexDirection: {},
206
- flexWrap: {},
207
- justifyContent: {},
208
- alignItems: {},
209
- alignContent: {},
210
- order: {},
211
- flex: {},
212
- flexGrow: {},
213
- flexShrink: {},
214
- alignSelf: {},
215
- justifyItems: {},
216
- justifySelf: {},
217
- // grid
218
- gap: {
219
- style: gap
220
- },
221
- rowGap: {
222
- style: rowGap
223
- },
224
- columnGap: {
225
- style: columnGap
226
- },
227
- gridColumn: {},
228
- gridRow: {},
229
- gridAutoFlow: {},
230
- gridAutoColumns: {},
231
- gridAutoRows: {},
232
- gridTemplateColumns: {},
233
- gridTemplateRows: {},
234
- gridTemplateAreas: {},
235
- gridArea: {},
236
- // positions
237
- position: {},
238
- zIndex: {
239
- themeKey: 'zIndex'
240
- },
241
- top: {},
242
- right: {},
243
- bottom: {},
244
- left: {},
245
- // shadows
246
- boxShadow: {
247
- themeKey: 'shadows'
248
- },
249
- // sizing
250
- width: {
251
- transform: sizingTransform
252
- },
253
- maxWidth: {
254
- style: maxWidth
255
- },
256
- minWidth: {
257
- transform: sizingTransform
258
- },
259
- height: {
260
- transform: sizingTransform
261
- },
262
- maxHeight: {
263
- transform: sizingTransform
264
- },
265
- minHeight: {
266
- transform: sizingTransform
267
- },
268
- boxSizing: {},
269
- // typography
270
- font: {
271
- themeKey: 'font'
272
- },
273
- fontFamily: {
274
- themeKey: 'typography'
275
- },
276
- fontSize: {
277
- themeKey: 'typography'
278
- },
279
- fontStyle: {
280
- themeKey: 'typography'
281
- },
282
- fontWeight: {
283
- themeKey: 'typography'
284
- },
285
- letterSpacing: {},
286
- textTransform: {},
287
- lineHeight: {},
288
- textAlign: {},
289
- typography: {
290
- cssProperty: false,
291
- themeKey: 'typography'
292
- }
293
- };
294
- export default defaultSxConfig;
@@ -1,51 +0,0 @@
1
- import { isPlainObject } from '@mui/utils/deepmerge';
2
- import defaultSxConfig from "./defaultSxConfig.js";
3
- const splitProps = props => {
4
- const result = {
5
- systemProps: {},
6
- otherProps: {}
7
- };
8
- const config = props?.theme?.unstable_sxConfig ?? defaultSxConfig;
9
- Object.keys(props).forEach(prop => {
10
- if (config[prop]) {
11
- result.systemProps[prop] = props[prop];
12
- } else {
13
- result.otherProps[prop] = props[prop];
14
- }
15
- });
16
- return result;
17
- };
18
- export default function extendSxProp(props) {
19
- const {
20
- sx: inSx,
21
- ...other
22
- } = props;
23
- const {
24
- systemProps,
25
- otherProps
26
- } = splitProps(other);
27
- let finalSx;
28
- if (Array.isArray(inSx)) {
29
- finalSx = [systemProps, ...inSx];
30
- } else if (typeof inSx === 'function') {
31
- finalSx = (...args) => {
32
- const result = inSx(...args);
33
- if (!isPlainObject(result)) {
34
- return systemProps;
35
- }
36
- return {
37
- ...systemProps,
38
- ...result
39
- };
40
- };
41
- } else {
42
- finalSx = {
43
- ...systemProps,
44
- ...inSx
45
- };
46
- }
47
- return {
48
- ...otherProps,
49
- sx: finalSx
50
- };
51
- }
@@ -1,4 +0,0 @@
1
- export { default } from "./styleFunctionSx.js";
2
- export { unstable_createStyleFunctionSx } from "./styleFunctionSx.js";
3
- export { default as extendSxProp } from "./extendSxProp.js";
4
- export { default as unstable_defaultSxConfig } from "./defaultSxConfig.js";
@@ -1,127 +0,0 @@
1
- import capitalize from '@mui/utils/capitalize';
2
- import merge from "../merge/index.js";
3
- import { getPath, getStyleValue as getValue } from "../style/index.js";
4
- import { handleBreakpoints, createEmptyBreakpointObject, removeUnusedBreakpoints } from "../breakpoints/index.js";
5
- import { sortContainerQueries } from "../cssContainerQueries/index.js";
6
- import defaultSxConfig from "./defaultSxConfig.js";
7
- function objectsHaveSameKeys(...objects) {
8
- const allKeys = objects.reduce((keys, object) => keys.concat(Object.keys(object)), []);
9
- const union = new Set(allKeys);
10
- return objects.every(object => union.size === Object.keys(object).length);
11
- }
12
- function callIfFn(maybeFn, arg) {
13
- return typeof maybeFn === 'function' ? maybeFn(arg) : maybeFn;
14
- }
15
-
16
- // eslint-disable-next-line @typescript-eslint/naming-convention
17
- export function unstable_createStyleFunctionSx() {
18
- function getThemeValue(prop, val, theme, config) {
19
- const props = {
20
- [prop]: val,
21
- theme
22
- };
23
- const options = config[prop];
24
- if (!options) {
25
- return {
26
- [prop]: val
27
- };
28
- }
29
- const {
30
- cssProperty = prop,
31
- themeKey,
32
- transform,
33
- style
34
- } = options;
35
- if (val == null) {
36
- return null;
37
- }
38
-
39
- // TODO v6: remove, see https://github.com/mui/material-ui/pull/38123
40
- if (themeKey === 'typography' && val === 'inherit') {
41
- return {
42
- [prop]: val
43
- };
44
- }
45
- const themeMapping = getPath(theme, themeKey) || {};
46
- if (style) {
47
- return style(props);
48
- }
49
- const styleFromPropValue = propValueFinal => {
50
- let value = getValue(themeMapping, transform, propValueFinal);
51
- if (propValueFinal === value && typeof propValueFinal === 'string') {
52
- // Haven't found value
53
- value = getValue(themeMapping, transform, `${prop}${propValueFinal === 'default' ? '' : capitalize(propValueFinal)}`, propValueFinal);
54
- }
55
- if (cssProperty === false) {
56
- return value;
57
- }
58
- return {
59
- [cssProperty]: value
60
- };
61
- };
62
- return handleBreakpoints(props, val, styleFromPropValue);
63
- }
64
- function styleFunctionSx(props) {
65
- const {
66
- sx,
67
- theme = {}
68
- } = props || {};
69
- if (!sx) {
70
- return null; // Emotion & styled-components will neglect null
71
- }
72
- const config = theme.unstable_sxConfig ?? defaultSxConfig;
73
-
74
- /*
75
- * Receive `sxInput` as object or callback
76
- * and then recursively check keys & values to create media query object styles.
77
- * (the result will be used in `styled`)
78
- */
79
- function traverse(sxInput) {
80
- let sxObject = sxInput;
81
- if (typeof sxInput === 'function') {
82
- sxObject = sxInput(theme);
83
- } else if (typeof sxInput !== 'object') {
84
- // value
85
- return sxInput;
86
- }
87
- if (!sxObject) {
88
- return null;
89
- }
90
- const emptyBreakpoints = createEmptyBreakpointObject(theme.breakpoints);
91
- const breakpointsKeys = Object.keys(emptyBreakpoints);
92
- let css = emptyBreakpoints;
93
- Object.keys(sxObject).forEach(styleKey => {
94
- const value = callIfFn(sxObject[styleKey], theme);
95
- if (value !== null && value !== undefined) {
96
- if (typeof value === 'object') {
97
- if (config[styleKey]) {
98
- css = merge(css, getThemeValue(styleKey, value, theme, config));
99
- } else {
100
- const breakpointsValues = handleBreakpoints({
101
- theme
102
- }, value, x => ({
103
- [styleKey]: x
104
- }));
105
- if (objectsHaveSameKeys(breakpointsValues, value)) {
106
- css[styleKey] = styleFunctionSx({
107
- sx: value,
108
- theme
109
- });
110
- } else {
111
- css = merge(css, breakpointsValues);
112
- }
113
- }
114
- } else {
115
- css = merge(css, getThemeValue(styleKey, value, theme, config));
116
- }
117
- }
118
- });
119
- return sortContainerQueries(theme, removeUnusedBreakpoints(breakpointsKeys, css));
120
- }
121
- return Array.isArray(sx) ? sx.map(traverse) : traverse(sx);
122
- }
123
- return styleFunctionSx;
124
- }
125
- const styleFunctionSx = unstable_createStyleFunctionSx();
126
- styleFunctionSx.filterProps = ['sx'];
127
- export default styleFunctionSx;
@@ -1 +0,0 @@
1
- export { default } from "./styled.js";
@@ -1,3 +0,0 @@
1
- import createStyled from "../createStyled/index.js";
2
- const styled = createStyled();
3
- export default styled;
@@ -1,2 +0,0 @@
1
- export { default } from "./typography.js";
2
- export * from "./typography.js";
@@ -1,37 +0,0 @@
1
- import style from "../style/index.js";
2
- import compose from "../compose/index.js";
3
- export const fontFamily = style({
4
- prop: 'fontFamily',
5
- themeKey: 'typography'
6
- });
7
- export const fontSize = style({
8
- prop: 'fontSize',
9
- themeKey: 'typography'
10
- });
11
- export const fontStyle = style({
12
- prop: 'fontStyle',
13
- themeKey: 'typography'
14
- });
15
- export const fontWeight = style({
16
- prop: 'fontWeight',
17
- themeKey: 'typography'
18
- });
19
- export const letterSpacing = style({
20
- prop: 'letterSpacing'
21
- });
22
- export const textTransform = style({
23
- prop: 'textTransform'
24
- });
25
- export const lineHeight = style({
26
- prop: 'lineHeight'
27
- });
28
- export const textAlign = style({
29
- prop: 'textAlign'
30
- });
31
- export const typographyVariant = style({
32
- prop: 'typography',
33
- cssProperty: false,
34
- themeKey: 'typography'
35
- });
36
- const typography = compose(typographyVariant, fontFamily, fontSize, fontStyle, fontWeight, letterSpacing, lineHeight, textAlign, textTransform);
37
- export default typography;
@@ -1,2 +0,0 @@
1
- export { default } from "./useMediaQuery.js";
2
- export * from "./useMediaQuery.js";
@@ -1,118 +0,0 @@
1
- 'use client';
2
-
3
- import * as React from 'react';
4
- import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
5
- import { getThemeProps } from "../useThemeProps/index.js";
6
- import useTheme from "../useThemeWithoutDefault/index.js";
7
- // TODO React 17: Remove `useMediaQueryOld` once React 17 support is removed
8
- function useMediaQueryOld(query, defaultMatches, matchMedia, ssrMatchMedia, noSsr) {
9
- const [match, setMatch] = React.useState(() => {
10
- if (noSsr && matchMedia) {
11
- return matchMedia(query).matches;
12
- }
13
- if (ssrMatchMedia) {
14
- return ssrMatchMedia(query).matches;
15
- }
16
-
17
- // Once the component is mounted, we rely on the
18
- // event listeners to return the correct matches value.
19
- return defaultMatches;
20
- });
21
- useEnhancedEffect(() => {
22
- if (!matchMedia) {
23
- return undefined;
24
- }
25
- const queryList = matchMedia(query);
26
- const updateMatch = () => {
27
- setMatch(queryList.matches);
28
- };
29
- updateMatch();
30
- queryList.addEventListener('change', updateMatch);
31
- return () => {
32
- queryList.removeEventListener('change', updateMatch);
33
- };
34
- }, [query, matchMedia]);
35
- return match;
36
- }
37
-
38
- // See https://github.com/mui/material-ui/issues/41190#issuecomment-2040873379 for why
39
- const safeReact = {
40
- ...React
41
- };
42
- const maybeReactUseSyncExternalStore = safeReact.useSyncExternalStore;
43
- function useMediaQueryNew(query, defaultMatches, matchMedia, ssrMatchMedia, noSsr) {
44
- const getDefaultSnapshot = React.useCallback(() => defaultMatches, [defaultMatches]);
45
- const getServerSnapshot = React.useMemo(() => {
46
- if (noSsr && matchMedia) {
47
- return () => matchMedia(query).matches;
48
- }
49
- if (ssrMatchMedia !== null) {
50
- const {
51
- matches
52
- } = ssrMatchMedia(query);
53
- return () => matches;
54
- }
55
- return getDefaultSnapshot;
56
- }, [getDefaultSnapshot, query, ssrMatchMedia, noSsr, matchMedia]);
57
- const [getSnapshot, subscribe] = React.useMemo(() => {
58
- if (matchMedia === null) {
59
- return [getDefaultSnapshot, () => () => {}];
60
- }
61
- const mediaQueryList = matchMedia(query);
62
- return [() => mediaQueryList.matches, notify => {
63
- mediaQueryList.addEventListener('change', notify);
64
- return () => {
65
- mediaQueryList.removeEventListener('change', notify);
66
- };
67
- }];
68
- }, [getDefaultSnapshot, matchMedia, query]);
69
- const match = maybeReactUseSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
70
- return match;
71
- }
72
-
73
- // eslint-disable-next-line @typescript-eslint/naming-convention
74
- export function unstable_createUseMediaQuery(params = {}) {
75
- const {
76
- themeId
77
- } = params;
78
- return function useMediaQuery(queryInput, options = {}) {
79
- let theme = useTheme();
80
- if (theme && themeId) {
81
- theme = theme[themeId] || theme;
82
- }
83
- // Wait for jsdom to support the match media feature.
84
- // All the browsers MUI support have this built-in.
85
- // This defensive check is here for simplicity.
86
- // Most of the time, the match media logic isn't central to people tests.
87
- const supportMatchMedia = typeof window !== 'undefined' && typeof window.matchMedia !== 'undefined';
88
- const {
89
- defaultMatches = false,
90
- matchMedia = supportMatchMedia ? window.matchMedia : null,
91
- ssrMatchMedia = null,
92
- noSsr = false
93
- } = getThemeProps({
94
- name: 'MuiUseMediaQuery',
95
- props: options,
96
- theme
97
- });
98
- if (process.env.NODE_ENV !== 'production') {
99
- if (typeof queryInput === 'function' && theme === null) {
100
- console.error(['MUI: The `query` argument provided is invalid.', 'You are providing a function without a theme in the context.', 'One of the parent elements needs to use a ThemeProvider.'].join('\n'));
101
- }
102
- }
103
- let query = typeof queryInput === 'function' ? queryInput(theme) : queryInput;
104
- query = query.replace(/^@media( ?)/m, '');
105
- const useMediaQueryImplementation = maybeReactUseSyncExternalStore !== undefined ? useMediaQueryNew : useMediaQueryOld;
106
- const match = useMediaQueryImplementation(query, defaultMatches, matchMedia, ssrMatchMedia, noSsr);
107
- if (process.env.NODE_ENV !== 'production') {
108
- // eslint-disable-next-line react-hooks/rules-of-hooks
109
- React.useDebugValue({
110
- query,
111
- match
112
- });
113
- }
114
- return match;
115
- };
116
- }
117
- const useMediaQuery = unstable_createUseMediaQuery();
118
- export default useMediaQuery;
@@ -1,2 +0,0 @@
1
- export { default } from "./useTheme.js";
2
- export * from "./useTheme.js";
@@ -1,9 +0,0 @@
1
- 'use client';
2
-
3
- import createTheme from "../createTheme/index.js";
4
- import useThemeWithoutDefault from "../useThemeWithoutDefault/index.js";
5
- export const systemDefaultTheme = createTheme();
6
- function useTheme(defaultTheme = systemDefaultTheme) {
7
- return useThemeWithoutDefault(defaultTheme);
8
- }
9
- export default useTheme;
@@ -1,12 +0,0 @@
1
- import resolveProps from '@mui/utils/resolveProps';
2
- export default function getThemeProps(params) {
3
- const {
4
- theme,
5
- name,
6
- props
7
- } = params;
8
- if (!theme || !theme.components || !theme.components[name] || !theme.components[name].defaultProps) {
9
- return props;
10
- }
11
- return resolveProps(theme.components[name].defaultProps, props);
12
- }
@@ -1,2 +0,0 @@
1
- export { default } from "./useThemeProps.js";
2
- export { default as getThemeProps } from "./getThemeProps.js";
@@ -1,20 +0,0 @@
1
- 'use client';
2
-
3
- import getThemeProps from "./getThemeProps.js";
4
- import useTheme from "../useTheme/index.js";
5
- export default function useThemeProps({
6
- props,
7
- name,
8
- defaultTheme,
9
- themeId
10
- }) {
11
- let theme = useTheme(defaultTheme);
12
- if (themeId) {
13
- theme = theme[themeId] || theme;
14
- }
15
- return getThemeProps({
16
- theme,
17
- name,
18
- props
19
- });
20
- }
@@ -1 +0,0 @@
1
- export { default } from "./useThemeWithoutDefault.js";