@mui/material 7.0.0-beta.3 → 7.0.0-rc.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.
- package/Accordion/Accordion.d.ts +13 -2
- package/Accordion/Accordion.js +18 -6
- package/AccordionSummary/AccordionSummary.d.ts +39 -4
- package/AccordionSummary/AccordionSummary.js +67 -16
- package/CHANGELOG.md +84 -0
- package/InputBase/InputBase.js +2 -2
- package/ListItemText/ListItemText.d.ts +10 -0
- package/ListItemText/ListItemText.js +14 -5
- package/Select/SelectInput.js +2 -2
- package/SpeedDial/SpeedDial.d.ts +10 -0
- package/SpeedDial/SpeedDial.js +40 -11
- package/SpeedDialAction/SpeedDialAction.js +1 -1
- package/StepLabel/StepLabel.d.ts +19 -1
- package/StepLabel/StepLabel.js +14 -5
- package/Switch/Switch.d.ts +62 -1
- package/Switch/Switch.js +71 -9
- package/TextField/TextField.d.ts +30 -0
- package/TextField/TextField.js +22 -11
- package/TextareaAutosize/TextareaAutosize.js +25 -14
- package/Tooltip/Tooltip.d.ts +1 -1
- package/Tooltip/Tooltip.js +1 -1
- package/Typography/Typography.d.ts +3 -3
- package/esm/Accordion/Accordion.d.ts +13 -2
- package/esm/Accordion/Accordion.js +18 -6
- package/esm/AccordionSummary/AccordionSummary.d.ts +39 -4
- package/esm/AccordionSummary/AccordionSummary.js +67 -16
- package/esm/InputBase/InputBase.js +2 -2
- package/esm/ListItemText/ListItemText.d.ts +10 -0
- package/esm/ListItemText/ListItemText.js +14 -5
- package/esm/Select/SelectInput.js +2 -2
- package/esm/SpeedDial/SpeedDial.d.ts +10 -0
- package/esm/SpeedDial/SpeedDial.js +40 -11
- package/esm/SpeedDialAction/SpeedDialAction.js +1 -1
- package/esm/StepLabel/StepLabel.d.ts +19 -1
- package/esm/StepLabel/StepLabel.js +14 -5
- package/esm/Switch/Switch.d.ts +62 -1
- package/esm/Switch/Switch.js +71 -9
- package/esm/TextField/TextField.d.ts +30 -0
- package/esm/TextField/TextField.js +22 -11
- package/esm/TextareaAutosize/TextareaAutosize.js +26 -15
- package/esm/Tooltip/Tooltip.d.ts +1 -1
- package/esm/Tooltip/Tooltip.js +1 -1
- package/esm/Typography/Typography.d.ts +3 -3
- package/esm/index.js +1 -1
- package/esm/styles/ThemeProvider.d.ts +6 -0
- package/esm/styles/ThemeProvider.js +11 -0
- package/esm/styles/adaptV4Theme.d.ts +2 -2
- package/esm/styles/createPalette.js +3 -3
- package/esm/styles/createThemeNoVars.d.ts +3 -3
- package/esm/styles/createThemeNoVars.js +2 -2
- package/esm/styles/createThemeWithVars.js +2 -2
- package/esm/styles/createTypography.d.ts +4 -4
- package/esm/styles/index.d.ts +1 -1
- package/esm/styles/index.js +2 -2
- package/esm/styles/makeStyles.js +2 -2
- package/esm/styles/responsiveFontSizes.d.ts +3 -3
- package/esm/styles/responsiveFontSizes.js +2 -2
- package/esm/styles/withStyles.js +2 -2
- package/esm/styles/withTheme.js +2 -2
- package/esm/useScrollTrigger/useScrollTrigger.d.ts +1 -1
- package/esm/useScrollTrigger/useScrollTrigger.js +3 -0
- package/esm/utils/mergeSlotProps.js +25 -0
- package/esm/version/index.js +2 -2
- package/index.js +1 -1
- package/modern/Accordion/Accordion.d.ts +13 -2
- package/modern/Accordion/Accordion.js +18 -6
- package/modern/AccordionSummary/AccordionSummary.d.ts +39 -4
- package/modern/AccordionSummary/AccordionSummary.js +67 -16
- package/modern/InputBase/InputBase.js +2 -2
- package/modern/ListItemText/ListItemText.d.ts +10 -0
- package/modern/ListItemText/ListItemText.js +14 -5
- package/modern/Select/SelectInput.js +2 -2
- package/modern/SpeedDial/SpeedDial.d.ts +10 -0
- package/modern/SpeedDial/SpeedDial.js +40 -11
- package/modern/SpeedDialAction/SpeedDialAction.js +1 -1
- package/modern/StepLabel/StepLabel.d.ts +19 -1
- package/modern/StepLabel/StepLabel.js +14 -5
- package/modern/Switch/Switch.d.ts +62 -1
- package/modern/Switch/Switch.js +71 -9
- package/modern/TextField/TextField.d.ts +30 -0
- package/modern/TextField/TextField.js +22 -11
- package/modern/TextareaAutosize/TextareaAutosize.js +26 -15
- package/modern/Tooltip/Tooltip.d.ts +1 -1
- package/modern/Tooltip/Tooltip.js +1 -1
- package/modern/Typography/Typography.d.ts +3 -3
- package/modern/index.js +1 -1
- package/modern/styles/ThemeProvider.d.ts +6 -0
- package/modern/styles/ThemeProvider.js +11 -0
- package/modern/styles/adaptV4Theme.d.ts +2 -2
- package/modern/styles/createPalette.js +3 -3
- package/modern/styles/createThemeNoVars.d.ts +3 -3
- package/modern/styles/createThemeNoVars.js +2 -2
- package/modern/styles/createThemeWithVars.js +2 -2
- package/modern/styles/createTypography.d.ts +4 -4
- package/modern/styles/index.d.ts +1 -1
- package/modern/styles/index.js +2 -2
- package/modern/styles/makeStyles.js +2 -2
- package/modern/styles/responsiveFontSizes.d.ts +3 -3
- package/modern/styles/responsiveFontSizes.js +2 -2
- package/modern/styles/withStyles.js +2 -2
- package/modern/styles/withTheme.js +2 -2
- package/modern/useScrollTrigger/useScrollTrigger.d.ts +1 -1
- package/modern/useScrollTrigger/useScrollTrigger.js +3 -0
- package/modern/utils/mergeSlotProps.js +25 -0
- package/modern/version/index.js +2 -2
- package/package.json +7 -7
- package/styles/ThemeProvider.d.ts +6 -0
- package/styles/ThemeProvider.js +11 -0
- package/styles/adaptV4Theme.d.ts +2 -2
- package/styles/createPalette.js +3 -3
- package/styles/createThemeNoVars.d.ts +3 -3
- package/styles/createThemeNoVars.js +2 -2
- package/styles/createThemeWithVars.js +2 -2
- package/styles/createTypography.d.ts +4 -4
- package/styles/index.d.ts +1 -1
- package/styles/index.js +2 -2
- package/styles/makeStyles.js +2 -2
- package/styles/responsiveFontSizes.d.ts +3 -3
- package/styles/responsiveFontSizes.js +2 -2
- package/styles/withStyles.js +2 -2
- package/styles/withTheme.js +2 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/useScrollTrigger/useScrollTrigger.d.ts +1 -1
- package/useScrollTrigger/useScrollTrigger.js +3 -0
- package/utils/mergeSlotProps.js +24 -0
- package/version/index.js +2 -2
|
@@ -160,6 +160,25 @@ const TextField = /*#__PURE__*/React.forwardRef(function TextField(inProps, ref)
|
|
|
160
160
|
}
|
|
161
161
|
inputAdditionalProps['aria-describedby'] = undefined;
|
|
162
162
|
}
|
|
163
|
+
const [RootSlot, rootProps] = useSlot('root', {
|
|
164
|
+
elementType: TextFieldRoot,
|
|
165
|
+
shouldForwardComponentProp: true,
|
|
166
|
+
externalForwardedProps: {
|
|
167
|
+
...externalForwardedProps,
|
|
168
|
+
...other
|
|
169
|
+
},
|
|
170
|
+
ownerState,
|
|
171
|
+
className: clsx(classes.root, className),
|
|
172
|
+
ref,
|
|
173
|
+
additionalProps: {
|
|
174
|
+
disabled,
|
|
175
|
+
error,
|
|
176
|
+
fullWidth,
|
|
177
|
+
required,
|
|
178
|
+
color,
|
|
179
|
+
variant
|
|
180
|
+
}
|
|
181
|
+
});
|
|
163
182
|
const [InputSlot, inputProps] = useSlot('input', {
|
|
164
183
|
elementType: InputComponent,
|
|
165
184
|
externalForwardedProps,
|
|
@@ -211,17 +230,8 @@ const TextField = /*#__PURE__*/React.forwardRef(function TextField(inProps, ref)
|
|
|
211
230
|
},
|
|
212
231
|
...inputProps
|
|
213
232
|
});
|
|
214
|
-
return /*#__PURE__*/_jsxs(
|
|
215
|
-
|
|
216
|
-
disabled: disabled,
|
|
217
|
-
error: error,
|
|
218
|
-
fullWidth: fullWidth,
|
|
219
|
-
ref: ref,
|
|
220
|
-
required: required,
|
|
221
|
-
color: color,
|
|
222
|
-
variant: variant,
|
|
223
|
-
ownerState: ownerState,
|
|
224
|
-
...other,
|
|
233
|
+
return /*#__PURE__*/_jsxs(RootSlot, {
|
|
234
|
+
...rootProps,
|
|
225
235
|
children: [label != null && label !== '' && /*#__PURE__*/_jsx(InputLabelSlot, {
|
|
226
236
|
htmlFor: id,
|
|
227
237
|
id: inputLabelId,
|
|
@@ -423,6 +433,7 @@ process.env.NODE_ENV !== "production" ? TextField.propTypes /* remove-proptypes
|
|
|
423
433
|
htmlInput: PropTypes.elementType,
|
|
424
434
|
input: PropTypes.elementType,
|
|
425
435
|
inputLabel: PropTypes.elementType,
|
|
436
|
+
root: PropTypes.elementType,
|
|
426
437
|
select: PropTypes.elementType
|
|
427
438
|
}),
|
|
428
439
|
/**
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
|
-
import { unstable_debounce as debounce, unstable_useForkRef as useForkRef, unstable_useEnhancedEffect as useEnhancedEffect, unstable_ownerWindow as ownerWindow } from '@mui/utils';
|
|
5
|
+
import { unstable_debounce as debounce, unstable_useForkRef as useForkRef, unstable_useEnhancedEffect as useEnhancedEffect, unstable_useEventCallback as useEventCallback, unstable_ownerWindow as ownerWindow } from '@mui/utils';
|
|
6
6
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
7
|
function getStyleValue(value) {
|
|
8
8
|
return parseInt(value, 10) || 0;
|
|
@@ -112,6 +112,15 @@ const TextareaAutosize = /*#__PURE__*/React.forwardRef(function TextareaAutosize
|
|
|
112
112
|
overflowing
|
|
113
113
|
};
|
|
114
114
|
}, [maxRows, minRows, props.placeholder]);
|
|
115
|
+
const didHeightChange = useEventCallback(() => {
|
|
116
|
+
const textarea = textareaRef.current;
|
|
117
|
+
const textareaStyles = calculateTextareaStyles();
|
|
118
|
+
if (!textarea || !textareaStyles || isEmpty(textareaStyles)) {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
const outerHeightStyle = textareaStyles.outerHeightStyle;
|
|
122
|
+
return heightRef.current != null && heightRef.current !== outerHeightStyle;
|
|
123
|
+
});
|
|
115
124
|
const syncHeight = React.useCallback(() => {
|
|
116
125
|
const textarea = textareaRef.current;
|
|
117
126
|
const textareaStyles = calculateTextareaStyles();
|
|
@@ -127,37 +136,39 @@ const TextareaAutosize = /*#__PURE__*/React.forwardRef(function TextareaAutosize
|
|
|
127
136
|
}, [calculateTextareaStyles]);
|
|
128
137
|
const frameRef = React.useRef(-1);
|
|
129
138
|
useEnhancedEffect(() => {
|
|
130
|
-
const
|
|
139
|
+
const debouncedHandleResize = debounce(syncHeight);
|
|
131
140
|
const textarea = textareaRef?.current;
|
|
132
141
|
if (!textarea) {
|
|
133
142
|
return undefined;
|
|
134
143
|
}
|
|
135
144
|
const containerWindow = ownerWindow(textarea);
|
|
136
|
-
containerWindow.addEventListener('resize',
|
|
145
|
+
containerWindow.addEventListener('resize', debouncedHandleResize);
|
|
137
146
|
let resizeObserver;
|
|
138
147
|
if (typeof ResizeObserver !== 'undefined') {
|
|
139
148
|
resizeObserver = new ResizeObserver(() => {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
+
if (didHeightChange()) {
|
|
150
|
+
// avoid "ResizeObserver loop completed with undelivered notifications" error
|
|
151
|
+
// by temporarily unobserving the textarea element while manipulating the height
|
|
152
|
+
// and reobserving one frame later
|
|
153
|
+
resizeObserver.unobserve(textarea);
|
|
154
|
+
cancelAnimationFrame(frameRef.current);
|
|
155
|
+
syncHeight();
|
|
156
|
+
frameRef.current = requestAnimationFrame(() => {
|
|
157
|
+
resizeObserver.observe(textarea);
|
|
158
|
+
});
|
|
159
|
+
}
|
|
149
160
|
});
|
|
150
161
|
resizeObserver.observe(textarea);
|
|
151
162
|
}
|
|
152
163
|
return () => {
|
|
153
|
-
|
|
164
|
+
debouncedHandleResize.clear();
|
|
154
165
|
cancelAnimationFrame(frameRef.current);
|
|
155
|
-
containerWindow.removeEventListener('resize',
|
|
166
|
+
containerWindow.removeEventListener('resize', debouncedHandleResize);
|
|
156
167
|
if (resizeObserver) {
|
|
157
168
|
resizeObserver.disconnect();
|
|
158
169
|
}
|
|
159
170
|
};
|
|
160
|
-
}, [calculateTextareaStyles, syncHeight]);
|
|
171
|
+
}, [calculateTextareaStyles, syncHeight, didHeightChange]);
|
|
161
172
|
useEnhancedEffect(() => {
|
|
162
173
|
syncHeight();
|
|
163
174
|
});
|
|
@@ -178,7 +178,7 @@ export interface TooltipProps extends StandardProps<React.HTMLAttributes<HTMLDiv
|
|
|
178
178
|
* Tooltip placement.
|
|
179
179
|
* @default 'bottom'
|
|
180
180
|
*/
|
|
181
|
-
placement?: '
|
|
181
|
+
placement?: PopperProps['placement'];
|
|
182
182
|
/**
|
|
183
183
|
* The component used for the popper.
|
|
184
184
|
* @deprecated use the `slots.popper` prop instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
@@ -841,7 +841,7 @@ process.env.NODE_ENV !== "production" ? Tooltip.propTypes /* remove-proptypes */
|
|
|
841
841
|
* Tooltip placement.
|
|
842
842
|
* @default 'bottom'
|
|
843
843
|
*/
|
|
844
|
-
placement: PropTypes.oneOf(['bottom-end', 'bottom-start', 'bottom', 'left-end', 'left-start', 'left', 'right-end', 'right-start', 'right', 'top-end', 'top-start', 'top']),
|
|
844
|
+
placement: PropTypes.oneOf(['auto-end', 'auto-start', 'auto', 'bottom-end', 'bottom-start', 'bottom', 'left-end', 'left-start', 'left', 'right-end', 'right-start', 'right', 'top-end', 'top-start', 'top']),
|
|
845
845
|
/**
|
|
846
846
|
* The component used for the popper.
|
|
847
847
|
* @deprecated use the `slots.popper` prop instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
@@ -3,7 +3,7 @@ import { OverridableStringUnion } from '@mui/types';
|
|
|
3
3
|
import { SxProps, SystemProps } from '@mui/system';
|
|
4
4
|
import { Theme, TypeText } from "../styles/index.js";
|
|
5
5
|
import { OverrideProps, OverridableComponent } from "../OverridableComponent/index.js";
|
|
6
|
-
import {
|
|
6
|
+
import { TypographyVariant } from "../styles/createTypography.js";
|
|
7
7
|
import { TypographyClasses } from "./typographyClasses.js";
|
|
8
8
|
export interface TypographyPropsVariantOverrides {}
|
|
9
9
|
export interface TypographyPropsColorOverrides {}
|
|
@@ -54,7 +54,7 @@ export interface TypographyOwnProps extends Omit<SystemProps<Theme>, 'color'> {
|
|
|
54
54
|
* Applies the theme typography styles.
|
|
55
55
|
* @default 'body1'
|
|
56
56
|
*/
|
|
57
|
-
variant?: OverridableStringUnion<
|
|
57
|
+
variant?: OverridableStringUnion<TypographyVariant | 'inherit', TypographyPropsVariantOverrides>;
|
|
58
58
|
/**
|
|
59
59
|
* The component maps the variant prop to a range of different HTML element types.
|
|
60
60
|
* For instance, subtitle1 to `<h6>`.
|
|
@@ -74,7 +74,7 @@ export interface TypographyOwnProps extends Omit<SystemProps<Theme>, 'color'> {
|
|
|
74
74
|
* inherit: 'p',
|
|
75
75
|
* }
|
|
76
76
|
*/
|
|
77
|
-
variantMapping?: Partial<Record<OverridableStringUnion<
|
|
77
|
+
variantMapping?: Partial<Record<OverridableStringUnion<TypographyVariant | 'inherit', TypographyPropsVariantOverrides>, string>>;
|
|
78
78
|
}
|
|
79
79
|
export interface TypographyTypeMap<AdditionalProps = {}, RootComponent extends React.ElementType = 'span'> {
|
|
80
80
|
props: AdditionalProps & TypographyOwnProps;
|
package/modern/index.js
CHANGED
|
@@ -21,6 +21,12 @@ type ThemeProviderCssVariablesProps = CssThemeVariables extends {
|
|
|
21
21
|
* @default false
|
|
22
22
|
*/
|
|
23
23
|
disableStyleSheetGeneration?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* If `true`, theme values are recalculated when the mode changes.
|
|
26
|
+
* The `theme.colorSchemes.{mode}.*` nodes will be shallow merged to the top-level of the theme.
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
forceThemeRerender?: boolean;
|
|
24
30
|
} : {};
|
|
25
31
|
export interface ThemeProviderProps<Theme = DefaultTheme> extends ThemeProviderCssVariablesProps {
|
|
26
32
|
children?: React.ReactNode;
|
|
@@ -17,6 +17,17 @@ export default function ThemeProvider({
|
|
|
17
17
|
}
|
|
18
18
|
const muiTheme = THEME_ID in theme ? theme[THEME_ID] : theme;
|
|
19
19
|
if (!('colorSchemes' in muiTheme)) {
|
|
20
|
+
if (!('vars' in muiTheme)) {
|
|
21
|
+
// For non-CSS variables themes, set `vars` to null to prevent theme inheritance from the upper theme.
|
|
22
|
+
// The example use case is the docs demo that uses ThemeProvider to customize the theme while the upper theme is using CSS variables.
|
|
23
|
+
return /*#__PURE__*/_jsx(ThemeProviderNoVars, {
|
|
24
|
+
theme: {
|
|
25
|
+
...theme,
|
|
26
|
+
vars: null
|
|
27
|
+
},
|
|
28
|
+
...props
|
|
29
|
+
});
|
|
30
|
+
}
|
|
20
31
|
return /*#__PURE__*/_jsx(ThemeProviderNoVars, {
|
|
21
32
|
theme: theme,
|
|
22
33
|
...props
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BreakpointsOptions, ShapeOptions, SpacingOptions } from '@mui/system';
|
|
2
2
|
import { MixinsOptions } from "./createMixins.js";
|
|
3
3
|
import { Palette, PaletteOptions } from "./createPalette.js";
|
|
4
|
-
import {
|
|
4
|
+
import { TypographyVariantsOptions } from "./createTypography.js";
|
|
5
5
|
import { Shadows } from "./shadows.js";
|
|
6
6
|
import { TransitionsOptions } from "./createTransitions.js";
|
|
7
7
|
import { ZIndexOptions } from "./zIndex.js";
|
|
@@ -21,7 +21,7 @@ export interface DeprecatedThemeOptions {
|
|
|
21
21
|
shadows?: Shadows;
|
|
22
22
|
spacing?: SpacingOptions;
|
|
23
23
|
transitions?: TransitionsOptions;
|
|
24
|
-
typography?:
|
|
24
|
+
typography?: TypographyVariantsOptions | ((palette: Palette) => TypographyVariantsOptions);
|
|
25
25
|
variants?: ComponentsVariants;
|
|
26
26
|
zIndex?: ZIndexOptions;
|
|
27
27
|
unstable_strictMode?: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _formatErrorMessage from "@mui/utils/formatMuiErrorMessage";
|
|
2
2
|
import deepmerge from '@mui/utils/deepmerge';
|
|
3
3
|
import { darken, getContrastRatio, lighten } from '@mui/system/colorManipulator';
|
|
4
4
|
import common from "../colors/common.js";
|
|
@@ -218,10 +218,10 @@ export default function createPalette(palette) {
|
|
|
218
218
|
color.main = color[mainShade];
|
|
219
219
|
}
|
|
220
220
|
if (!color.hasOwnProperty('main')) {
|
|
221
|
-
throw new Error(process.env.NODE_ENV !== "production" ? `MUI: The color${name ? ` (${name})` : ''} provided to augmentColor(color) is invalid.\n` + `The color object needs to have a \`main\` property or a \`${mainShade}\` property.` :
|
|
221
|
+
throw new Error(process.env.NODE_ENV !== "production" ? `MUI: The color${name ? ` (${name})` : ''} provided to augmentColor(color) is invalid.\n` + `The color object needs to have a \`main\` property or a \`${mainShade}\` property.` : _formatErrorMessage(11, name ? ` (${name})` : '', mainShade));
|
|
222
222
|
}
|
|
223
223
|
if (typeof color.main !== 'string') {
|
|
224
|
-
throw new Error(process.env.NODE_ENV !== "production" ? `MUI: The color${name ? ` (${name})` : ''} provided to augmentColor(color) is invalid.\n` + `\`color.main\` should be a string, but \`${JSON.stringify(color.main)}\` was provided instead.\n` + '\n' + 'Did you intend to use one of the following approaches?\n' + '\n' + 'import { green } from "@mui/material/colors";\n' + '\n' + 'const theme1 = createTheme({ palette: {\n' + ' primary: green,\n' + '} });\n' + '\n' + 'const theme2 = createTheme({ palette: {\n' + ' primary: { main: green[500] },\n' + '} });' :
|
|
224
|
+
throw new Error(process.env.NODE_ENV !== "production" ? `MUI: The color${name ? ` (${name})` : ''} provided to augmentColor(color) is invalid.\n` + `\`color.main\` should be a string, but \`${JSON.stringify(color.main)}\` was provided instead.\n` + '\n' + 'Did you intend to use one of the following approaches?\n' + '\n' + 'import { green } from "@mui/material/colors";\n' + '\n' + 'const theme1 = createTheme({ palette: {\n' + ' primary: green,\n' + '} });\n' + '\n' + 'const theme2 = createTheme({ palette: {\n' + ' primary: { main: green[500] },\n' + '} });' : _formatErrorMessage(12, name ? ` (${name})` : '', JSON.stringify(color.main)));
|
|
225
225
|
}
|
|
226
226
|
addLightOrDark(color, 'light', lightShade, tonalOffset);
|
|
227
227
|
addLightOrDark(color, 'dark', darkShade, tonalOffset);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ThemeOptions as SystemThemeOptions, Theme as SystemTheme, SxProps, CSSObject, SxConfig } from '@mui/system';
|
|
2
2
|
import { Mixins, MixinsOptions } from "./createMixins.js";
|
|
3
3
|
import { Palette, PaletteOptions } from "./createPalette.js";
|
|
4
|
-
import {
|
|
4
|
+
import { TypographyVariants, TypographyVariantsOptions } from "./createTypography.js";
|
|
5
5
|
import { Shadows } from "./shadows.js";
|
|
6
6
|
import { Transitions, TransitionsOptions } from "./createTransitions.js";
|
|
7
7
|
import { ZIndex, ZIndexOptions } from "./zIndex.js";
|
|
@@ -28,7 +28,7 @@ export interface ThemeOptions extends Omit<SystemThemeOptions, 'zIndex'>, CssVar
|
|
|
28
28
|
palette?: PaletteOptions;
|
|
29
29
|
shadows?: Shadows;
|
|
30
30
|
transitions?: TransitionsOptions;
|
|
31
|
-
typography?:
|
|
31
|
+
typography?: TypographyVariantsOptions | ((palette: Palette) => TypographyVariantsOptions);
|
|
32
32
|
zIndex?: ZIndexOptions;
|
|
33
33
|
unstable_strictMode?: boolean;
|
|
34
34
|
unstable_sxConfig?: SxConfig;
|
|
@@ -40,7 +40,7 @@ export interface BaseTheme extends SystemTheme {
|
|
|
40
40
|
} ? CssVarsPalette : {});
|
|
41
41
|
shadows: Shadows;
|
|
42
42
|
transitions: Transitions;
|
|
43
|
-
typography:
|
|
43
|
+
typography: TypographyVariants;
|
|
44
44
|
zIndex: ZIndex;
|
|
45
45
|
unstable_strictMode?: boolean;
|
|
46
46
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _formatErrorMessage from "@mui/utils/formatMuiErrorMessage";
|
|
2
2
|
import deepmerge from '@mui/utils/deepmerge';
|
|
3
3
|
import styleFunctionSx, { unstable_defaultSxConfig as defaultSxConfig } from '@mui/system/styleFunctionSx';
|
|
4
4
|
import systemCreateTheme from '@mui/system/createTheme';
|
|
@@ -27,7 +27,7 @@ function createThemeNoVars(options = {}, ...args) {
|
|
|
27
27
|
options.generateThemeVars === undefined) {
|
|
28
28
|
throw new Error(process.env.NODE_ENV !== "production" ? 'MUI: `vars` is a private field used for CSS variables support.\n' +
|
|
29
29
|
// #host-reference
|
|
30
|
-
'Please use another name or follow the [docs](https://mui.com/material-ui/customization/css-theme-variables/usage/) to enable the feature.' :
|
|
30
|
+
'Please use another name or follow the [docs](https://mui.com/material-ui/customization/css-theme-variables/usage/) to enable the feature.' : _formatErrorMessage(20));
|
|
31
31
|
}
|
|
32
32
|
const palette = createPalette(paletteInput);
|
|
33
33
|
const systemTheme = systemCreateTheme(options);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _formatErrorMessage from "@mui/utils/formatMuiErrorMessage";
|
|
2
2
|
import deepmerge from '@mui/utils/deepmerge';
|
|
3
3
|
import { unstable_createGetCssVar as systemCreateGetCssVar, createSpacing } from '@mui/system';
|
|
4
4
|
import { createUnarySpacing } from '@mui/system/spacing';
|
|
@@ -131,7 +131,7 @@ export default function createThemeWithVars(options = {}, ...args) {
|
|
|
131
131
|
defaultScheme = true;
|
|
132
132
|
}
|
|
133
133
|
if (!defaultScheme) {
|
|
134
|
-
throw new Error(process.env.NODE_ENV !== "production" ? `MUI: The \`colorSchemes.${defaultColorScheme}\` option is either missing or invalid.` :
|
|
134
|
+
throw new Error(process.env.NODE_ENV !== "production" ? `MUI: The \`colorSchemes.${defaultColorScheme}\` option is either missing or invalid.` : _formatErrorMessage(21, defaultColorScheme));
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
// Create the palette for the default color scheme, either `light`, `dark`, or custom color scheme.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import * as CSS from 'csstype';
|
|
3
3
|
import { Palette } from "./createPalette.js";
|
|
4
|
-
export type
|
|
4
|
+
export type TypographyVariant = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'subtitle1' | 'subtitle2' | 'body1' | 'body2' | 'caption' | 'button' | 'overline';
|
|
5
5
|
export interface FontStyle {
|
|
6
6
|
fontFamily: React.CSSProperties['fontFamily'];
|
|
7
7
|
fontSize: number;
|
|
@@ -45,6 +45,6 @@ export interface TypographyStyleOptions extends TypographyStyle {}
|
|
|
45
45
|
export interface TypographyUtils {
|
|
46
46
|
pxToRem: (px: number) => string;
|
|
47
47
|
}
|
|
48
|
-
export interface
|
|
49
|
-
export interface
|
|
50
|
-
export default function createTypography(palette: Palette, typography:
|
|
48
|
+
export interface TypographyVariants extends Record<TypographyVariant, TypographyStyle>, FontStyle, TypographyUtils {}
|
|
49
|
+
export interface TypographyVariantsOptions extends Partial<Record<TypographyVariant, TypographyStyleOptions> & FontStyleOptions> {}
|
|
50
|
+
export default function createTypography(palette: Palette, typography: TypographyVariantsOptions | ((palette: Palette) => TypographyVariantsOptions)): TypographyVariants;
|
package/modern/styles/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export { ZIndex } from "./zIndex.js";
|
|
|
6
6
|
export { CommonColors, Palette, PaletteColor, PaletteColorOptions, PaletteOptions, SimplePaletteColorOptions, TypeText, TypeAction, TypeBackground, PaletteMode, Color } from "./createPalette.js";
|
|
7
7
|
export { default as createColorScheme } from "./createColorScheme.js";
|
|
8
8
|
export { default as createStyles } from "./createStyles.js";
|
|
9
|
-
export {
|
|
9
|
+
export { TypographyVariants, TypographyVariantsOptions, TypographyStyle, TypographyVariant } from "./createTypography.js";
|
|
10
10
|
export { default as responsiveFontSizes } from "./responsiveFontSizes.js";
|
|
11
11
|
export { Duration, Easing, Transitions, TransitionsOptions, duration, easing } from "./createTransitions.js";
|
|
12
12
|
export { Mixins } from "./createMixins.js";
|
package/modern/styles/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _formatErrorMessage from "@mui/utils/formatMuiErrorMessage";
|
|
2
2
|
export { default as THEME_ID } from "./identifier.js";
|
|
3
3
|
export { default as adaptV4Theme } from "./adaptV4Theme.js";
|
|
4
4
|
export { hexToRgb, rgbToHex, hslToRgb, decomposeColor, recomposeColor, getContrastRatio, getLuminance, emphasize, alpha, darken, lighten, css, keyframes } from '@mui/system';
|
|
@@ -6,7 +6,7 @@ export { unstable_createBreakpoints } from '@mui/system/createBreakpoints';
|
|
|
6
6
|
// TODO: Remove this function in v6.
|
|
7
7
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
8
8
|
export function experimental_sx() {
|
|
9
|
-
throw new Error(process.env.NODE_ENV !== "production" ? 'MUI: The `experimental_sx` has been moved to `theme.unstable_sx`.' + 'For more details, see https://github.com/mui/material-ui/pull/35150.' :
|
|
9
|
+
throw new Error(process.env.NODE_ENV !== "production" ? 'MUI: The `experimental_sx` has been moved to `theme.unstable_sx`.' + 'For more details, see https://github.com/mui/material-ui/pull/35150.' : _formatErrorMessage(19));
|
|
10
10
|
}
|
|
11
11
|
export { default as createTheme } from "./createTheme.js";
|
|
12
12
|
export { default as unstable_createMuiStrictModeTheme } from "./createMuiStrictModeTheme.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _formatErrorMessage from "@mui/utils/formatMuiErrorMessage";
|
|
2
2
|
export default function makeStyles() {
|
|
3
|
-
throw new Error(process.env.NODE_ENV !== "production" ? 'MUI: makeStyles is no longer exported from @mui/material/styles.\n' + 'You have to import it from @mui/styles.\n' + 'See https://mui.com/r/migration-v4/#mui-material-styles for more details.' :
|
|
3
|
+
throw new Error(process.env.NODE_ENV !== "production" ? 'MUI: makeStyles is no longer exported from @mui/material/styles.\n' + 'You have to import it from @mui/styles.\n' + 'See https://mui.com/r/migration-v4/#mui-material-styles for more details.' : _formatErrorMessage(14));
|
|
4
4
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Breakpoint } from '@mui/system';
|
|
2
|
-
import {
|
|
2
|
+
import { TypographyVariants } from "./createTypography.js";
|
|
3
3
|
export interface ResponsiveFontSizesOptions {
|
|
4
4
|
breakpoints?: Breakpoint[];
|
|
5
5
|
disableAlign?: boolean;
|
|
6
6
|
factor?: number;
|
|
7
|
-
variants?: Array<keyof
|
|
7
|
+
variants?: Array<keyof TypographyVariants>;
|
|
8
8
|
}
|
|
9
9
|
export default function responsiveFontSizes<T extends {
|
|
10
|
-
typography:
|
|
10
|
+
typography: TypographyVariants;
|
|
11
11
|
}>(theme: T, options?: ResponsiveFontSizesOptions): T;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _formatErrorMessage from "@mui/utils/formatMuiErrorMessage";
|
|
2
2
|
import { isUnitless, convertLength, responsiveProperty, alignProperty, fontGrid } from "./cssUtils.js";
|
|
3
3
|
export default function responsiveFontSizes(themeInput, options = {}) {
|
|
4
4
|
const {
|
|
@@ -34,7 +34,7 @@ export default function responsiveFontSizes(themeInput, options = {}) {
|
|
|
34
34
|
lineHeight
|
|
35
35
|
} = style;
|
|
36
36
|
if (!isUnitless(lineHeight) && !disableAlign) {
|
|
37
|
-
throw new Error(process.env.NODE_ENV !== "production" ? 'MUI: Unsupported non-unitless line height with grid alignment.\n' + 'Use unitless line heights instead.' :
|
|
37
|
+
throw new Error(process.env.NODE_ENV !== "production" ? 'MUI: Unsupported non-unitless line height with grid alignment.\n' + 'Use unitless line heights instead.' : _formatErrorMessage(6));
|
|
38
38
|
}
|
|
39
39
|
if (!isUnitless(lineHeight)) {
|
|
40
40
|
// make it unitless
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _formatErrorMessage from "@mui/utils/formatMuiErrorMessage";
|
|
2
2
|
export default function withStyles() {
|
|
3
|
-
throw new Error(process.env.NODE_ENV !== "production" ? 'MUI: withStyles is no longer exported from @mui/material/styles.\n' + 'You have to import it from @mui/styles.\n' + 'See https://mui.com/r/migration-v4/#mui-material-styles for more details.' :
|
|
3
|
+
throw new Error(process.env.NODE_ENV !== "production" ? 'MUI: withStyles is no longer exported from @mui/material/styles.\n' + 'You have to import it from @mui/styles.\n' + 'See https://mui.com/r/migration-v4/#mui-material-styles for more details.' : _formatErrorMessage(15));
|
|
4
4
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _formatErrorMessage from "@mui/utils/formatMuiErrorMessage";
|
|
2
2
|
export default function withTheme() {
|
|
3
|
-
throw new Error(process.env.NODE_ENV !== "production" ? 'MUI: withTheme is no longer exported from @mui/material/styles.\n' + 'You have to import it from @mui/styles.\n' + 'See https://mui.com/r/migration-v4/#mui-material-styles for more details.' :
|
|
3
|
+
throw new Error(process.env.NODE_ENV !== "production" ? 'MUI: withTheme is no longer exported from @mui/material/styles.\n' + 'You have to import it from @mui/styles.\n' + 'See https://mui.com/r/migration-v4/#mui-material-styles for more details.' : _formatErrorMessage(16));
|
|
4
4
|
}
|
|
@@ -29,6 +29,9 @@ export default function useScrollTrigger(options = {}) {
|
|
|
29
29
|
const store = React.useRef();
|
|
30
30
|
const [trigger, setTrigger] = React.useState(() => getTrigger(store, other));
|
|
31
31
|
React.useEffect(() => {
|
|
32
|
+
if (target === null) {
|
|
33
|
+
return setTrigger(false);
|
|
34
|
+
}
|
|
32
35
|
const handleScroll = () => {
|
|
33
36
|
setTrigger(getTrigger(store, {
|
|
34
37
|
target,
|
|
@@ -1,8 +1,29 @@
|
|
|
1
1
|
import clsx from 'clsx';
|
|
2
|
+
|
|
3
|
+
// Brought from [Base UI](https://github.com/mui/base-ui/blob/master/packages/react/src/merge-props/mergeProps.ts#L119)
|
|
4
|
+
// Use it directly from Base UI once it's a package dependency.
|
|
5
|
+
function isEventHandler(key, value) {
|
|
6
|
+
// This approach is more efficient than using a regex.
|
|
7
|
+
const thirdCharCode = key.charCodeAt(2);
|
|
8
|
+
return key[0] === 'o' && key[1] === 'n' && thirdCharCode >= 65 /* A */ && thirdCharCode <= 90 /* Z */ && typeof value === 'function';
|
|
9
|
+
}
|
|
2
10
|
export default function mergeSlotProps(externalSlotProps, defaultSlotProps) {
|
|
3
11
|
if (!externalSlotProps) {
|
|
4
12
|
return defaultSlotProps;
|
|
5
13
|
}
|
|
14
|
+
function extractHandlers(externalSlotPropsValue, defaultSlotPropsValue) {
|
|
15
|
+
const handlers = {};
|
|
16
|
+
Object.keys(defaultSlotPropsValue).forEach(key => {
|
|
17
|
+
if (isEventHandler(key, defaultSlotPropsValue[key]) && typeof externalSlotPropsValue[key] === 'function') {
|
|
18
|
+
// only compose the handlers if both default and external slot props match the event handler
|
|
19
|
+
handlers[key] = (...args) => {
|
|
20
|
+
externalSlotPropsValue[key](...args);
|
|
21
|
+
defaultSlotPropsValue[key](...args);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return handlers;
|
|
26
|
+
}
|
|
6
27
|
if (typeof externalSlotProps === 'function' || typeof defaultSlotProps === 'function') {
|
|
7
28
|
return ownerState => {
|
|
8
29
|
const defaultSlotPropsValue = typeof defaultSlotProps === 'function' ? defaultSlotProps(ownerState) : defaultSlotProps;
|
|
@@ -11,9 +32,11 @@ export default function mergeSlotProps(externalSlotProps, defaultSlotProps) {
|
|
|
11
32
|
...defaultSlotPropsValue
|
|
12
33
|
}) : externalSlotProps;
|
|
13
34
|
const className = clsx(ownerState?.className, defaultSlotPropsValue?.className, externalSlotPropsValue?.className);
|
|
35
|
+
const handlers = extractHandlers(externalSlotPropsValue, defaultSlotPropsValue);
|
|
14
36
|
return {
|
|
15
37
|
...defaultSlotPropsValue,
|
|
16
38
|
...externalSlotPropsValue,
|
|
39
|
+
...handlers,
|
|
17
40
|
...(!!className && {
|
|
18
41
|
className
|
|
19
42
|
}),
|
|
@@ -30,10 +53,12 @@ export default function mergeSlotProps(externalSlotProps, defaultSlotProps) {
|
|
|
30
53
|
};
|
|
31
54
|
}
|
|
32
55
|
const typedDefaultSlotProps = defaultSlotProps;
|
|
56
|
+
const handlers = extractHandlers(externalSlotProps, typedDefaultSlotProps);
|
|
33
57
|
const className = clsx(typedDefaultSlotProps?.className, externalSlotProps?.className);
|
|
34
58
|
return {
|
|
35
59
|
...defaultSlotProps,
|
|
36
60
|
...externalSlotProps,
|
|
61
|
+
...handlers,
|
|
37
62
|
...(!!className && {
|
|
38
63
|
className
|
|
39
64
|
}),
|
package/modern/version/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export const version = "7.0.0-
|
|
1
|
+
export const version = "7.0.0-rc.0";
|
|
2
2
|
export const major = Number("7");
|
|
3
3
|
export const minor = Number("0");
|
|
4
4
|
export const patch = Number("0");
|
|
5
|
-
export const prerelease = "
|
|
5
|
+
export const prerelease = "rc.0";
|
|
6
6
|
export default version;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/material",
|
|
3
|
-
"version": "7.0.0-
|
|
3
|
+
"version": "7.0.0-rc.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"description": "Material UI is an open-source React component library that implements Google's Material Design. It's comprehensive and can be used in production out of the box.",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"url": "https://opencollective.com/mui-org"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@babel/runtime": "^7.26.
|
|
30
|
+
"@babel/runtime": "^7.26.10",
|
|
31
31
|
"@popperjs/core": "^2.11.8",
|
|
32
32
|
"@types/react-transition-group": "^4.4.12",
|
|
33
33
|
"clsx": "^2.1.1",
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"prop-types": "^15.8.1",
|
|
36
36
|
"react-is": "^19.0.0",
|
|
37
37
|
"react-transition-group": "^4.4.5",
|
|
38
|
-
"@mui/
|
|
39
|
-
"@mui/
|
|
40
|
-
"@mui/
|
|
41
|
-
"@mui/
|
|
38
|
+
"@mui/core-downloads-tracker": "^7.0.0-rc.0",
|
|
39
|
+
"@mui/system": "7.0.0-rc.0",
|
|
40
|
+
"@mui/types": "^7.3.1",
|
|
41
|
+
"@mui/utils": "7.0.0-rc.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"@emotion/react": "^11.5.0",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@types/react": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
47
47
|
"react": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
48
48
|
"react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
49
|
-
"@mui/material-pigment-css": "7.0.0-
|
|
49
|
+
"@mui/material-pigment-css": "7.0.0-rc.0"
|
|
50
50
|
},
|
|
51
51
|
"peerDependenciesMeta": {
|
|
52
52
|
"@types/react": {
|
|
@@ -21,6 +21,12 @@ type ThemeProviderCssVariablesProps = CssThemeVariables extends {
|
|
|
21
21
|
* @default false
|
|
22
22
|
*/
|
|
23
23
|
disableStyleSheetGeneration?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* If `true`, theme values are recalculated when the mode changes.
|
|
26
|
+
* The `theme.colorSchemes.{mode}.*` nodes will be shallow merged to the top-level of the theme.
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
forceThemeRerender?: boolean;
|
|
24
30
|
} : {};
|
|
25
31
|
export interface ThemeProviderProps<Theme = DefaultTheme> extends ThemeProviderCssVariablesProps {
|
|
26
32
|
children?: React.ReactNode;
|
package/styles/ThemeProvider.js
CHANGED
|
@@ -24,6 +24,17 @@ function ThemeProvider({
|
|
|
24
24
|
}
|
|
25
25
|
const muiTheme = _identifier.default in theme ? theme[_identifier.default] : theme;
|
|
26
26
|
if (!('colorSchemes' in muiTheme)) {
|
|
27
|
+
if (!('vars' in muiTheme)) {
|
|
28
|
+
// For non-CSS variables themes, set `vars` to null to prevent theme inheritance from the upper theme.
|
|
29
|
+
// The example use case is the docs demo that uses ThemeProvider to customize the theme while the upper theme is using CSS variables.
|
|
30
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ThemeProviderNoVars.default, {
|
|
31
|
+
theme: {
|
|
32
|
+
...theme,
|
|
33
|
+
vars: null
|
|
34
|
+
},
|
|
35
|
+
...props
|
|
36
|
+
});
|
|
37
|
+
}
|
|
27
38
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ThemeProviderNoVars.default, {
|
|
28
39
|
theme: theme,
|
|
29
40
|
...props
|
package/styles/adaptV4Theme.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BreakpointsOptions, ShapeOptions, SpacingOptions } from '@mui/system';
|
|
2
2
|
import { MixinsOptions } from "./createMixins.js";
|
|
3
3
|
import { Palette, PaletteOptions } from "./createPalette.js";
|
|
4
|
-
import {
|
|
4
|
+
import { TypographyVariantsOptions } from "./createTypography.js";
|
|
5
5
|
import { Shadows } from "./shadows.js";
|
|
6
6
|
import { TransitionsOptions } from "./createTransitions.js";
|
|
7
7
|
import { ZIndexOptions } from "./zIndex.js";
|
|
@@ -21,7 +21,7 @@ export interface DeprecatedThemeOptions {
|
|
|
21
21
|
shadows?: Shadows;
|
|
22
22
|
spacing?: SpacingOptions;
|
|
23
23
|
transitions?: TransitionsOptions;
|
|
24
|
-
typography?:
|
|
24
|
+
typography?: TypographyVariantsOptions | ((palette: Palette) => TypographyVariantsOptions);
|
|
25
25
|
variants?: ComponentsVariants;
|
|
26
26
|
zIndex?: ZIndexOptions;
|
|
27
27
|
unstable_strictMode?: boolean;
|