@mui/material 6.3.1 → 6.4.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/Alert/Alert.d.ts +69 -0
- package/Alert/Alert.js +53 -21
- package/Autocomplete/Autocomplete.d.ts +1 -1
- package/Button/Button.d.ts +18 -0
- package/Button/Button.js +233 -15
- package/Button/buttonClasses.d.ts +14 -0
- package/Button/buttonClasses.js +1 -1
- package/CHANGELOG.md +49 -0
- package/CardHeader/CardHeader.d.ts +114 -1
- package/CardHeader/CardHeader.js +99 -32
- package/CircularProgress/CircularProgress.js +2 -2
- package/IconButton/IconButton.d.ts +12 -0
- package/IconButton/IconButton.js +69 -7
- package/IconButton/iconButtonClasses.d.ts +4 -0
- package/IconButton/iconButtonClasses.js +1 -1
- package/LinearProgress/LinearProgress.js +4 -4
- package/LinearProgress/linearProgressClasses.d.ts +31 -9
- package/LinearProgress/linearProgressClasses.js +1 -1
- package/Link/getTextDecoration.js +3 -2
- package/Select/Select.js +10 -1
- package/Select/SelectInput.js +1 -1
- package/Slider/useSlider.js +5 -2
- package/StepLabel/StepLabel.d.ts +1 -1
- package/Tooltip/Tooltip.d.ts +1 -1
- package/index.js +1 -1
- package/modern/Alert/Alert.js +53 -21
- package/modern/Button/Button.js +233 -15
- package/modern/Button/buttonClasses.js +1 -1
- package/modern/CardHeader/CardHeader.js +99 -32
- package/modern/CircularProgress/CircularProgress.js +2 -2
- package/modern/IconButton/IconButton.js +69 -7
- package/modern/IconButton/iconButtonClasses.js +1 -1
- package/modern/LinearProgress/LinearProgress.js +4 -4
- package/modern/LinearProgress/linearProgressClasses.js +1 -1
- package/modern/Link/getTextDecoration.js +3 -2
- package/modern/Select/Select.js +10 -1
- package/modern/Select/SelectInput.js +1 -1
- package/modern/Slider/useSlider.js +5 -2
- package/modern/index.js +1 -1
- package/modern/utils/index.js +1 -0
- package/modern/utils/mergeSlotProps.js +43 -0
- package/modern/utils/useSlot.js +5 -1
- package/modern/version/index.js +3 -3
- package/node/Alert/Alert.js +53 -21
- package/node/Button/Button.js +233 -15
- package/node/Button/buttonClasses.js +1 -1
- package/node/CardHeader/CardHeader.js +99 -32
- package/node/CircularProgress/CircularProgress.js +2 -2
- package/node/IconButton/IconButton.js +68 -6
- package/node/IconButton/iconButtonClasses.js +1 -1
- package/node/LinearProgress/LinearProgress.js +4 -4
- package/node/LinearProgress/linearProgressClasses.js +1 -1
- package/node/Link/getTextDecoration.js +3 -2
- package/node/Select/Select.js +10 -1
- package/node/Select/SelectInput.js +1 -1
- package/node/Slider/useSlider.js +5 -2
- package/node/index.js +1 -1
- package/node/utils/index.js +7 -0
- package/node/utils/mergeSlotProps.js +50 -0
- package/node/utils/useSlot.js +5 -1
- package/node/version/index.js +3 -3
- package/package.json +5 -5
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/mergeSlotProps.d.ts +2 -0
- package/utils/mergeSlotProps.js +43 -0
- package/utils/useSlot.d.ts +8 -0
- package/utils/useSlot.js +5 -1
- package/version/index.js +3 -3
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
|
-
import clsx from 'clsx';
|
|
6
5
|
import composeClasses from '@mui/utils/composeClasses';
|
|
7
6
|
import Typography, { typographyClasses } from "../Typography/index.js";
|
|
8
7
|
import { styled } from "../zero-styled/index.js";
|
|
9
8
|
import { useDefaultProps } from "../DefaultPropsProvider/index.js";
|
|
10
9
|
import cardHeaderClasses, { getCardHeaderUtilityClass } from "./cardHeaderClasses.js";
|
|
10
|
+
import useSlot from "../utils/useSlot.js";
|
|
11
11
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
12
|
const useUtilityClasses = ownerState => {
|
|
13
13
|
const {
|
|
@@ -79,13 +79,14 @@ const CardHeader = /*#__PURE__*/React.forwardRef(function CardHeader(inProps, re
|
|
|
79
79
|
const {
|
|
80
80
|
action,
|
|
81
81
|
avatar,
|
|
82
|
-
className,
|
|
83
82
|
component = 'div',
|
|
84
83
|
disableTypography = false,
|
|
85
84
|
subheader: subheaderProp,
|
|
86
85
|
subheaderTypographyProps,
|
|
87
86
|
title: titleProp,
|
|
88
87
|
titleTypographyProps,
|
|
88
|
+
slots = {},
|
|
89
|
+
slotProps = {},
|
|
89
90
|
...other
|
|
90
91
|
} = props;
|
|
91
92
|
const ownerState = {
|
|
@@ -94,44 +95,88 @@ const CardHeader = /*#__PURE__*/React.forwardRef(function CardHeader(inProps, re
|
|
|
94
95
|
disableTypography
|
|
95
96
|
};
|
|
96
97
|
const classes = useUtilityClasses(ownerState);
|
|
98
|
+
const externalForwardedProps = {
|
|
99
|
+
slots,
|
|
100
|
+
slotProps: {
|
|
101
|
+
title: titleTypographyProps,
|
|
102
|
+
subheader: subheaderTypographyProps,
|
|
103
|
+
...slotProps
|
|
104
|
+
}
|
|
105
|
+
};
|
|
97
106
|
let title = titleProp;
|
|
98
|
-
|
|
99
|
-
title
|
|
107
|
+
const [TitleSlot, titleSlotProps] = useSlot('title', {
|
|
108
|
+
className: classes.title,
|
|
109
|
+
elementType: Typography,
|
|
110
|
+
externalForwardedProps,
|
|
111
|
+
ownerState,
|
|
112
|
+
additionalProps: {
|
|
100
113
|
variant: avatar ? 'body2' : 'h5',
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
114
|
+
component: 'span'
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
if (title != null && title.type !== Typography && !disableTypography) {
|
|
118
|
+
title = /*#__PURE__*/_jsx(TitleSlot, {
|
|
119
|
+
...titleSlotProps,
|
|
104
120
|
children: title
|
|
105
121
|
});
|
|
106
122
|
}
|
|
107
123
|
let subheader = subheaderProp;
|
|
108
|
-
|
|
109
|
-
subheader
|
|
124
|
+
const [SubheaderSlot, subheaderSlotProps] = useSlot('subheader', {
|
|
125
|
+
className: classes.subheader,
|
|
126
|
+
elementType: Typography,
|
|
127
|
+
externalForwardedProps,
|
|
128
|
+
ownerState,
|
|
129
|
+
additionalProps: {
|
|
110
130
|
variant: avatar ? 'body2' : 'body1',
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
131
|
+
color: 'textSecondary',
|
|
132
|
+
component: 'span'
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
if (subheader != null && subheader.type !== Typography && !disableTypography) {
|
|
136
|
+
subheader = /*#__PURE__*/_jsx(SubheaderSlot, {
|
|
137
|
+
...subheaderSlotProps,
|
|
115
138
|
children: subheader
|
|
116
139
|
});
|
|
117
140
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
141
|
+
const [RootSlot, rootSlotProps] = useSlot('root', {
|
|
142
|
+
ref,
|
|
143
|
+
className: classes.root,
|
|
144
|
+
elementType: CardHeaderRoot,
|
|
145
|
+
externalForwardedProps: {
|
|
146
|
+
...externalForwardedProps,
|
|
147
|
+
...other,
|
|
148
|
+
component
|
|
149
|
+
},
|
|
150
|
+
ownerState
|
|
151
|
+
});
|
|
152
|
+
const [AvatarSlot, avatarSlotProps] = useSlot('avatar', {
|
|
153
|
+
className: classes.avatar,
|
|
154
|
+
elementType: CardHeaderAvatar,
|
|
155
|
+
externalForwardedProps,
|
|
156
|
+
ownerState
|
|
157
|
+
});
|
|
158
|
+
const [ContentSlot, contentSlotProps] = useSlot('content', {
|
|
159
|
+
className: classes.content,
|
|
160
|
+
elementType: CardHeaderContent,
|
|
161
|
+
externalForwardedProps,
|
|
162
|
+
ownerState
|
|
163
|
+
});
|
|
164
|
+
const [ActionSlot, actionSlotProps] = useSlot('action', {
|
|
165
|
+
className: classes.action,
|
|
166
|
+
elementType: CardHeaderAction,
|
|
167
|
+
externalForwardedProps,
|
|
168
|
+
ownerState
|
|
169
|
+
});
|
|
170
|
+
return /*#__PURE__*/_jsxs(RootSlot, {
|
|
171
|
+
...rootSlotProps,
|
|
172
|
+
children: [avatar && /*#__PURE__*/_jsx(AvatarSlot, {
|
|
173
|
+
...avatarSlotProps,
|
|
127
174
|
children: avatar
|
|
128
|
-
}), /*#__PURE__*/_jsxs(
|
|
129
|
-
|
|
130
|
-
ownerState: ownerState,
|
|
175
|
+
}), /*#__PURE__*/_jsxs(ContentSlot, {
|
|
176
|
+
...contentSlotProps,
|
|
131
177
|
children: [title, subheader]
|
|
132
|
-
}), action && /*#__PURE__*/_jsx(
|
|
133
|
-
|
|
134
|
-
ownerState: ownerState,
|
|
178
|
+
}), action && /*#__PURE__*/_jsx(ActionSlot, {
|
|
179
|
+
...actionSlotProps,
|
|
135
180
|
children: action
|
|
136
181
|
})]
|
|
137
182
|
});
|
|
@@ -157,10 +202,6 @@ process.env.NODE_ENV !== "production" ? CardHeader.propTypes /* remove-proptypes
|
|
|
157
202
|
* Override or extend the styles applied to the component.
|
|
158
203
|
*/
|
|
159
204
|
classes: PropTypes.object,
|
|
160
|
-
/**
|
|
161
|
-
* @ignore
|
|
162
|
-
*/
|
|
163
|
-
className: PropTypes.string,
|
|
164
205
|
/**
|
|
165
206
|
* The component used for the root node.
|
|
166
207
|
* Either a string to use a HTML element or a component.
|
|
@@ -174,6 +215,30 @@ process.env.NODE_ENV !== "production" ? CardHeader.propTypes /* remove-proptypes
|
|
|
174
215
|
* @default false
|
|
175
216
|
*/
|
|
176
217
|
disableTypography: PropTypes.bool,
|
|
218
|
+
/**
|
|
219
|
+
* The props used for each slot inside.
|
|
220
|
+
* @default {}
|
|
221
|
+
*/
|
|
222
|
+
slotProps: PropTypes.shape({
|
|
223
|
+
action: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
224
|
+
avatar: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
225
|
+
content: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
226
|
+
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
227
|
+
subheader: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
228
|
+
title: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
|
229
|
+
}),
|
|
230
|
+
/**
|
|
231
|
+
* The components used for each slot inside.
|
|
232
|
+
* @default {}
|
|
233
|
+
*/
|
|
234
|
+
slots: PropTypes.shape({
|
|
235
|
+
action: PropTypes.elementType,
|
|
236
|
+
avatar: PropTypes.elementType,
|
|
237
|
+
content: PropTypes.elementType,
|
|
238
|
+
root: PropTypes.elementType,
|
|
239
|
+
subheader: PropTypes.elementType,
|
|
240
|
+
title: PropTypes.elementType
|
|
241
|
+
}),
|
|
177
242
|
/**
|
|
178
243
|
* The content of the component.
|
|
179
244
|
*/
|
|
@@ -181,6 +246,7 @@ process.env.NODE_ENV !== "production" ? CardHeader.propTypes /* remove-proptypes
|
|
|
181
246
|
/**
|
|
182
247
|
* These props will be forwarded to the subheader
|
|
183
248
|
* (as long as disableTypography is not `true`).
|
|
249
|
+
* @deprecated Use `slotProps.subheader` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
184
250
|
*/
|
|
185
251
|
subheaderTypographyProps: PropTypes.object,
|
|
186
252
|
/**
|
|
@@ -194,6 +260,7 @@ process.env.NODE_ENV !== "production" ? CardHeader.propTypes /* remove-proptypes
|
|
|
194
260
|
/**
|
|
195
261
|
* These props will be forwarded to the title
|
|
196
262
|
* (as long as disableTypography is not `true`).
|
|
263
|
+
* @deprecated Use `slotProps.title` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
197
264
|
*/
|
|
198
265
|
titleTypographyProps: PropTypes.object
|
|
199
266
|
} : void 0;
|
|
@@ -5,25 +5,29 @@ import PropTypes from 'prop-types';
|
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import chainPropTypes from '@mui/utils/chainPropTypes';
|
|
7
7
|
import composeClasses from '@mui/utils/composeClasses';
|
|
8
|
+
import { unstable_useId as useId } from '@mui/material/utils';
|
|
8
9
|
import { alpha } from '@mui/system/colorManipulator';
|
|
9
10
|
import { styled } from "../zero-styled/index.js";
|
|
10
11
|
import memoTheme from "../utils/memoTheme.js";
|
|
11
12
|
import createSimplePaletteValueFilter from "../utils/createSimplePaletteValueFilter.js";
|
|
12
13
|
import { useDefaultProps } from "../DefaultPropsProvider/index.js";
|
|
13
14
|
import ButtonBase from "../ButtonBase/index.js";
|
|
15
|
+
import CircularProgress from "../CircularProgress/index.js";
|
|
14
16
|
import capitalize from "../utils/capitalize.js";
|
|
15
17
|
import iconButtonClasses, { getIconButtonUtilityClass } from "./iconButtonClasses.js";
|
|
16
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
19
|
const useUtilityClasses = ownerState => {
|
|
18
20
|
const {
|
|
19
21
|
classes,
|
|
20
22
|
disabled,
|
|
21
23
|
color,
|
|
22
24
|
edge,
|
|
23
|
-
size
|
|
25
|
+
size,
|
|
26
|
+
loading
|
|
24
27
|
} = ownerState;
|
|
25
28
|
const slots = {
|
|
26
|
-
root: ['root', disabled && 'disabled', color !== 'default' && `color${capitalize(color)}`, edge && `edge${capitalize(edge)}`, `size${capitalize(size)}`]
|
|
29
|
+
root: ['root', loading && 'loading', disabled && 'disabled', color !== 'default' && `color${capitalize(color)}`, edge && `edge${capitalize(edge)}`, `size${capitalize(size)}`],
|
|
30
|
+
loadingIndicator: ['loadingIndicator']
|
|
27
31
|
};
|
|
28
32
|
return composeClasses(slots, getIconButtonUtilityClass, classes);
|
|
29
33
|
};
|
|
@@ -34,7 +38,7 @@ const IconButtonRoot = styled(ButtonBase, {
|
|
|
34
38
|
const {
|
|
35
39
|
ownerState
|
|
36
40
|
} = props;
|
|
37
|
-
return [styles.root, ownerState.color !== 'default' && styles[`color${capitalize(ownerState.color)}`], ownerState.edge && styles[`edge${capitalize(ownerState.edge)}`], styles[`size${capitalize(ownerState.size)}`]];
|
|
41
|
+
return [styles.root, ownerState.loading && styles.loading, ownerState.color !== 'default' && styles[`color${capitalize(ownerState.color)}`], ownerState.edge && styles[`edge${capitalize(ownerState.edge)}`], styles[`size${capitalize(ownerState.size)}`]];
|
|
38
42
|
}
|
|
39
43
|
})(memoTheme(({
|
|
40
44
|
theme
|
|
@@ -137,8 +141,34 @@ const IconButtonRoot = styled(ButtonBase, {
|
|
|
137
141
|
[`&.${iconButtonClasses.disabled}`]: {
|
|
138
142
|
backgroundColor: 'transparent',
|
|
139
143
|
color: (theme.vars || theme).palette.action.disabled
|
|
144
|
+
},
|
|
145
|
+
[`&.${iconButtonClasses.loading}`]: {
|
|
146
|
+
color: 'transparent'
|
|
140
147
|
}
|
|
141
148
|
})));
|
|
149
|
+
const IconButtonLoadingIndicator = styled('span', {
|
|
150
|
+
name: 'MuiIconButton',
|
|
151
|
+
slot: 'LoadingIndicator',
|
|
152
|
+
overridesResolver: (props, styles) => styles.loadingIndicator
|
|
153
|
+
})(({
|
|
154
|
+
theme
|
|
155
|
+
}) => ({
|
|
156
|
+
display: 'none',
|
|
157
|
+
position: 'absolute',
|
|
158
|
+
visibility: 'visible',
|
|
159
|
+
top: '50%',
|
|
160
|
+
left: '50%',
|
|
161
|
+
transform: 'translate(-50%, -50%)',
|
|
162
|
+
color: (theme.vars || theme).palette.action.disabled,
|
|
163
|
+
variants: [{
|
|
164
|
+
props: {
|
|
165
|
+
loading: true
|
|
166
|
+
},
|
|
167
|
+
style: {
|
|
168
|
+
display: 'flex'
|
|
169
|
+
}
|
|
170
|
+
}]
|
|
171
|
+
}));
|
|
142
172
|
|
|
143
173
|
/**
|
|
144
174
|
* Refer to the [Icons](/material-ui/icons/) section of the documentation
|
|
@@ -157,26 +187,42 @@ const IconButton = /*#__PURE__*/React.forwardRef(function IconButton(inProps, re
|
|
|
157
187
|
disabled = false,
|
|
158
188
|
disableFocusRipple = false,
|
|
159
189
|
size = 'medium',
|
|
190
|
+
id: idProp,
|
|
191
|
+
loading = false,
|
|
192
|
+
loadingIndicator: loadingIndicatorProp,
|
|
160
193
|
...other
|
|
161
194
|
} = props;
|
|
195
|
+
const id = useId(idProp);
|
|
196
|
+
const loadingIndicator = loadingIndicatorProp ?? /*#__PURE__*/_jsx(CircularProgress, {
|
|
197
|
+
"aria-labelledby": id,
|
|
198
|
+
color: "inherit",
|
|
199
|
+
size: 16
|
|
200
|
+
});
|
|
162
201
|
const ownerState = {
|
|
163
202
|
...props,
|
|
164
203
|
edge,
|
|
165
204
|
color,
|
|
166
205
|
disabled,
|
|
167
206
|
disableFocusRipple,
|
|
207
|
+
loading,
|
|
208
|
+
loadingIndicator,
|
|
168
209
|
size
|
|
169
210
|
};
|
|
170
211
|
const classes = useUtilityClasses(ownerState);
|
|
171
|
-
return /*#__PURE__*/
|
|
212
|
+
return /*#__PURE__*/_jsxs(IconButtonRoot, {
|
|
213
|
+
id: id,
|
|
172
214
|
className: clsx(classes.root, className),
|
|
173
215
|
centerRipple: true,
|
|
174
216
|
focusRipple: !disableFocusRipple,
|
|
175
|
-
disabled: disabled,
|
|
217
|
+
disabled: disabled || loading,
|
|
176
218
|
ref: ref,
|
|
177
219
|
...other,
|
|
178
220
|
ownerState: ownerState,
|
|
179
|
-
children:
|
|
221
|
+
children: [/*#__PURE__*/_jsx(IconButtonLoadingIndicator, {
|
|
222
|
+
className: classes.loadingIndicator,
|
|
223
|
+
ownerState: ownerState,
|
|
224
|
+
children: loading && loadingIndicator
|
|
225
|
+
}), children]
|
|
180
226
|
});
|
|
181
227
|
});
|
|
182
228
|
process.env.NODE_ENV !== "production" ? IconButton.propTypes /* remove-proptypes */ = {
|
|
@@ -235,6 +281,22 @@ process.env.NODE_ENV !== "production" ? IconButton.propTypes /* remove-proptypes
|
|
|
235
281
|
* @default false
|
|
236
282
|
*/
|
|
237
283
|
edge: PropTypes.oneOf(['end', 'start', false]),
|
|
284
|
+
/**
|
|
285
|
+
* @ignore
|
|
286
|
+
*/
|
|
287
|
+
id: PropTypes.string,
|
|
288
|
+
/**
|
|
289
|
+
* If `true`, the loading indicator is visible and the button is disabled.
|
|
290
|
+
* @default false
|
|
291
|
+
*/
|
|
292
|
+
loading: PropTypes.bool,
|
|
293
|
+
/**
|
|
294
|
+
* Element placed before the children if the button is in loading state.
|
|
295
|
+
* The node should contain an element with `role="progressbar"` with an accessible name.
|
|
296
|
+
* By default, it renders a `CircularProgress` that is labeled by the button itself.
|
|
297
|
+
* @default <CircularProgress color="inherit" size={16} />
|
|
298
|
+
*/
|
|
299
|
+
loadingIndicator: PropTypes.node,
|
|
238
300
|
/**
|
|
239
301
|
* The size of the component.
|
|
240
302
|
* `small` is equivalent to the dense button styling.
|
|
@@ -3,5 +3,5 @@ import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
|
3
3
|
export function getIconButtonUtilityClass(slot) {
|
|
4
4
|
return generateUtilityClass('MuiIconButton', slot);
|
|
5
5
|
}
|
|
6
|
-
const iconButtonClasses = generateUtilityClasses('MuiIconButton', ['root', 'disabled', 'colorInherit', 'colorPrimary', 'colorSecondary', 'colorError', 'colorInfo', 'colorSuccess', 'colorWarning', 'edgeStart', 'edgeEnd', 'sizeSmall', 'sizeMedium', 'sizeLarge']);
|
|
6
|
+
const iconButtonClasses = generateUtilityClasses('MuiIconButton', ['root', 'disabled', 'colorInherit', 'colorPrimary', 'colorSecondary', 'colorError', 'colorInfo', 'colorSuccess', 'colorWarning', 'edgeStart', 'edgeEnd', 'sizeSmall', 'sizeMedium', 'sizeLarge', 'loading', 'loadingIndicator']);
|
|
7
7
|
export default iconButtonClasses;
|
|
@@ -84,8 +84,8 @@ const useUtilityClasses = ownerState => {
|
|
|
84
84
|
const slots = {
|
|
85
85
|
root: ['root', `color${capitalize(color)}`, variant],
|
|
86
86
|
dashed: ['dashed', `dashedColor${capitalize(color)}`],
|
|
87
|
-
bar1: ['bar', `barColor${capitalize(color)}`, (variant === 'indeterminate' || variant === 'query') && 'bar1Indeterminate', variant === 'determinate' && 'bar1Determinate', variant === 'buffer' && 'bar1Buffer'],
|
|
88
|
-
bar2: ['bar', variant !== 'buffer' && `barColor${capitalize(color)}`, variant === 'buffer' && `color${capitalize(color)}`, (variant === 'indeterminate' || variant === 'query') && 'bar2Indeterminate', variant === 'buffer' && 'bar2Buffer']
|
|
87
|
+
bar1: ['bar', 'bar1', `barColor${capitalize(color)}`, (variant === 'indeterminate' || variant === 'query') && 'bar1Indeterminate', variant === 'determinate' && 'bar1Determinate', variant === 'buffer' && 'bar1Buffer'],
|
|
88
|
+
bar2: ['bar', 'bar2', variant !== 'buffer' && `barColor${capitalize(color)}`, variant === 'buffer' && `color${capitalize(color)}`, (variant === 'indeterminate' || variant === 'query') && 'bar2Indeterminate', variant === 'buffer' && 'bar2Buffer']
|
|
89
89
|
};
|
|
90
90
|
return composeClasses(slots, getLinearProgressUtilityClass, classes);
|
|
91
91
|
};
|
|
@@ -203,7 +203,7 @@ const LinearProgressBar1 = styled('span', {
|
|
|
203
203
|
const {
|
|
204
204
|
ownerState
|
|
205
205
|
} = props;
|
|
206
|
-
return [styles.bar, styles[`barColor${capitalize(ownerState.color)}`], (ownerState.variant === 'indeterminate' || ownerState.variant === 'query') && styles.bar1Indeterminate, ownerState.variant === 'determinate' && styles.bar1Determinate, ownerState.variant === 'buffer' && styles.bar1Buffer];
|
|
206
|
+
return [styles.bar, styles.bar1, styles[`barColor${capitalize(ownerState.color)}`], (ownerState.variant === 'indeterminate' || ownerState.variant === 'query') && styles.bar1Indeterminate, ownerState.variant === 'determinate' && styles.bar1Determinate, ownerState.variant === 'buffer' && styles.bar1Buffer];
|
|
207
207
|
}
|
|
208
208
|
})(memoTheme(({
|
|
209
209
|
theme
|
|
@@ -267,7 +267,7 @@ const LinearProgressBar2 = styled('span', {
|
|
|
267
267
|
const {
|
|
268
268
|
ownerState
|
|
269
269
|
} = props;
|
|
270
|
-
return [styles.bar, styles[`barColor${capitalize(ownerState.color)}`], (ownerState.variant === 'indeterminate' || ownerState.variant === 'query') && styles.bar2Indeterminate, ownerState.variant === 'buffer' && styles.bar2Buffer];
|
|
270
|
+
return [styles.bar, styles.bar2, styles[`barColor${capitalize(ownerState.color)}`], (ownerState.variant === 'indeterminate' || ownerState.variant === 'query') && styles.bar2Indeterminate, ownerState.variant === 'buffer' && styles.bar2Buffer];
|
|
271
271
|
}
|
|
272
272
|
})(memoTheme(({
|
|
273
273
|
theme
|
|
@@ -3,5 +3,5 @@ import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
|
3
3
|
export function getLinearProgressUtilityClass(slot) {
|
|
4
4
|
return generateUtilityClass('MuiLinearProgress', slot);
|
|
5
5
|
}
|
|
6
|
-
const linearProgressClasses = generateUtilityClasses('MuiLinearProgress', ['root', 'colorPrimary', 'colorSecondary', 'determinate', 'indeterminate', 'buffer', 'query', 'dashed', 'dashedColorPrimary', 'dashedColorSecondary', 'bar', 'barColorPrimary', 'barColorSecondary', 'bar1Indeterminate', 'bar1Determinate', 'bar1Buffer', 'bar2Indeterminate', 'bar2Buffer']);
|
|
6
|
+
const linearProgressClasses = generateUtilityClasses('MuiLinearProgress', ['root', 'colorPrimary', 'colorSecondary', 'determinate', 'indeterminate', 'buffer', 'query', 'dashed', 'dashedColorPrimary', 'dashedColorSecondary', 'bar', 'bar1', 'bar2', 'barColorPrimary', 'barColorSecondary', 'bar1Indeterminate', 'bar1Determinate', 'bar1Buffer', 'bar2Indeterminate', 'bar2Buffer']);
|
|
7
7
|
export default linearProgressClasses;
|
|
@@ -5,8 +5,9 @@ const getTextDecoration = ({
|
|
|
5
5
|
ownerState
|
|
6
6
|
}) => {
|
|
7
7
|
const transformedColor = ownerState.color;
|
|
8
|
-
|
|
9
|
-
const
|
|
8
|
+
// check the `main` color first for a custom palette, then fallback to the color itself
|
|
9
|
+
const color = getPath(theme, `palette.${transformedColor}.main`, false) || getPath(theme, `palette.${transformedColor}`, false) || ownerState.color;
|
|
10
|
+
const channelColor = getPath(theme, `palette.${transformedColor}.mainChannel`) || getPath(theme, `palette.${transformedColor}Channel`);
|
|
10
11
|
if ('vars' in theme && channelColor) {
|
|
11
12
|
return `rgba(${channelColor} / 0.4)`;
|
|
12
13
|
}
|
package/modern/Select/Select.js
CHANGED
|
@@ -4,6 +4,7 @@ import * as React from 'react';
|
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import deepmerge from '@mui/utils/deepmerge';
|
|
7
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
7
8
|
import getReactElementRef from '@mui/utils/getReactElementRef';
|
|
8
9
|
import SelectInput from "./SelectInput.js";
|
|
9
10
|
import formControlState from "../FormControl/formControlState.js";
|
|
@@ -17,12 +18,20 @@ import { useDefaultProps } from "../DefaultPropsProvider/index.js";
|
|
|
17
18
|
import useForkRef from "../utils/useForkRef.js";
|
|
18
19
|
import { styled } from "../zero-styled/index.js";
|
|
19
20
|
import rootShouldForwardProp from "../styles/rootShouldForwardProp.js";
|
|
21
|
+
import { getSelectUtilityClasses } from "./selectClasses.js";
|
|
20
22
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
21
23
|
const useUtilityClasses = ownerState => {
|
|
22
24
|
const {
|
|
23
25
|
classes
|
|
24
26
|
} = ownerState;
|
|
25
|
-
|
|
27
|
+
const slots = {
|
|
28
|
+
root: ['root']
|
|
29
|
+
};
|
|
30
|
+
const composedClasses = composeClasses(slots, getSelectUtilityClasses, classes);
|
|
31
|
+
return {
|
|
32
|
+
...classes,
|
|
33
|
+
...composedClasses
|
|
34
|
+
};
|
|
26
35
|
};
|
|
27
36
|
const styledRootConfig = {
|
|
28
37
|
name: 'MuiSelect',
|
|
@@ -443,7 +443,7 @@ const SelectInput = /*#__PURE__*/React.forwardRef(function SelectInput(props, re
|
|
|
443
443
|
ref: handleDisplayRef,
|
|
444
444
|
tabIndex: tabIndex,
|
|
445
445
|
role: "combobox",
|
|
446
|
-
"aria-controls": listboxId,
|
|
446
|
+
"aria-controls": open ? listboxId : undefined,
|
|
447
447
|
"aria-disabled": disabled ? 'true' : undefined,
|
|
448
448
|
"aria-expanded": open ? 'true' : 'false',
|
|
449
449
|
"aria-haspopup": "listbox",
|
|
@@ -188,6 +188,8 @@ export function useSlider(parameters) {
|
|
|
188
188
|
const [open, setOpen] = React.useState(-1);
|
|
189
189
|
const [dragging, setDragging] = React.useState(false);
|
|
190
190
|
const moveCount = React.useRef(0);
|
|
191
|
+
// lastChangedValue is updated whenever onChange is triggered.
|
|
192
|
+
const lastChangedValue = React.useRef(null);
|
|
191
193
|
const [valueDerived, setValueState] = useControlled({
|
|
192
194
|
controlled: valueProp,
|
|
193
195
|
default: defaultValue ?? min,
|
|
@@ -208,6 +210,7 @@ export function useSlider(parameters) {
|
|
|
208
210
|
name
|
|
209
211
|
}
|
|
210
212
|
});
|
|
213
|
+
lastChangedValue.current = value;
|
|
211
214
|
onChange(clonedEvent, value, thumbIndex);
|
|
212
215
|
});
|
|
213
216
|
const range = Array.isArray(valueDerived);
|
|
@@ -279,7 +282,7 @@ export function useSlider(parameters) {
|
|
|
279
282
|
handleChange(event, newValue, index);
|
|
280
283
|
}
|
|
281
284
|
if (onChangeCommitted) {
|
|
282
|
-
onChangeCommitted(event, newValue);
|
|
285
|
+
onChangeCommitted(event, lastChangedValue.current ?? newValue);
|
|
283
286
|
}
|
|
284
287
|
};
|
|
285
288
|
const createHandleHiddenInputKeyDown = otherHandlers => event => {
|
|
@@ -484,7 +487,7 @@ export function useSlider(parameters) {
|
|
|
484
487
|
setOpen(-1);
|
|
485
488
|
}
|
|
486
489
|
if (onChangeCommitted) {
|
|
487
|
-
onChangeCommitted(nativeEvent, newValue);
|
|
490
|
+
onChangeCommitted(nativeEvent, lastChangedValue.current ?? newValue);
|
|
488
491
|
}
|
|
489
492
|
touchId.current = undefined;
|
|
490
493
|
|
package/modern/index.js
CHANGED
package/modern/utils/index.js
CHANGED
|
@@ -18,6 +18,7 @@ export { default as unsupportedProp } from "./unsupportedProp.js";
|
|
|
18
18
|
export { default as useControlled } from "./useControlled.js";
|
|
19
19
|
export { default as useEventCallback } from "./useEventCallback.js";
|
|
20
20
|
export { default as useForkRef } from "./useForkRef.js";
|
|
21
|
+
export { default as mergeSlotProps } from "./mergeSlotProps.js";
|
|
21
22
|
// TODO: remove this export once ClassNameGenerator is stable
|
|
22
23
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
23
24
|
export const unstable_ClassNameGenerator = {
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
export default function mergeSlotProps(externalSlotProps, defaultSlotProps) {
|
|
3
|
+
if (!externalSlotProps) {
|
|
4
|
+
return defaultSlotProps;
|
|
5
|
+
}
|
|
6
|
+
if (typeof externalSlotProps === 'function' || typeof defaultSlotProps === 'function') {
|
|
7
|
+
return ownerState => {
|
|
8
|
+
const defaultSlotPropsValue = typeof defaultSlotProps === 'function' ? defaultSlotProps(ownerState) : defaultSlotProps;
|
|
9
|
+
const externalSlotPropsValue = typeof externalSlotProps === 'function' ? externalSlotProps({
|
|
10
|
+
...ownerState,
|
|
11
|
+
...defaultSlotPropsValue
|
|
12
|
+
}) : externalSlotProps;
|
|
13
|
+
const className = clsx(ownerState?.className, defaultSlotPropsValue?.className, externalSlotPropsValue?.className);
|
|
14
|
+
return {
|
|
15
|
+
...defaultSlotPropsValue,
|
|
16
|
+
...externalSlotPropsValue,
|
|
17
|
+
...(!!className && {
|
|
18
|
+
className
|
|
19
|
+
}),
|
|
20
|
+
...(defaultSlotPropsValue?.style && externalSlotPropsValue?.style && {
|
|
21
|
+
style: {
|
|
22
|
+
...defaultSlotPropsValue.style,
|
|
23
|
+
...externalSlotPropsValue.style
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const className = clsx(defaultSlotProps?.className, externalSlotProps?.className);
|
|
30
|
+
return {
|
|
31
|
+
...defaultSlotProps,
|
|
32
|
+
...externalSlotProps,
|
|
33
|
+
...(!!className && {
|
|
34
|
+
className
|
|
35
|
+
}),
|
|
36
|
+
...(defaultSlotProps?.style && externalSlotProps?.style && {
|
|
37
|
+
style: {
|
|
38
|
+
...defaultSlotProps.style,
|
|
39
|
+
...externalSlotProps.style
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
};
|
|
43
|
+
}
|
package/modern/utils/useSlot.js
CHANGED
|
@@ -32,6 +32,7 @@ name, parameters) {
|
|
|
32
32
|
ownerState,
|
|
33
33
|
externalForwardedProps,
|
|
34
34
|
internalForwardedProps,
|
|
35
|
+
shouldForwardComponentProp = false,
|
|
35
36
|
...useSlotPropsParams
|
|
36
37
|
} = parameters;
|
|
37
38
|
const {
|
|
@@ -67,9 +68,12 @@ name, parameters) {
|
|
|
67
68
|
...(name === 'root' && !rootComponent && !slots[name] && internalForwardedProps),
|
|
68
69
|
...(name !== 'root' && !slots[name] && internalForwardedProps),
|
|
69
70
|
...mergedProps,
|
|
70
|
-
...(LeafComponent && {
|
|
71
|
+
...(LeafComponent && !shouldForwardComponentProp && {
|
|
71
72
|
as: LeafComponent
|
|
72
73
|
}),
|
|
74
|
+
...(LeafComponent && shouldForwardComponentProp && {
|
|
75
|
+
component: LeafComponent
|
|
76
|
+
}),
|
|
73
77
|
ref
|
|
74
78
|
}, ownerState);
|
|
75
79
|
return [elementType, props];
|
package/modern/version/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export const version = "6.
|
|
1
|
+
export const version = "6.4.0";
|
|
2
2
|
export const major = Number("6");
|
|
3
|
-
export const minor = Number("
|
|
4
|
-
export const patch = Number("
|
|
3
|
+
export const minor = Number("4");
|
|
4
|
+
export const patch = Number("0");
|
|
5
5
|
export const prerelease = undefined;
|
|
6
6
|
export default version;
|