Skip to content

Commit fef79d5

Browse files
sai6855web-flow
authored andcommitted
[material-ui][StepLabel] Add missing root slot (#45603)
1 parent 2bded21 commit fef79d5

File tree

5 files changed

+47
-17
lines changed

5 files changed

+47
-17
lines changed

docs/pages/material-ui/api/step-label.json

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@
1414
"slotProps": {
1515
"type": {
1616
"name": "shape",
17-
"description": "{ label?: func<br>&#124;&nbsp;object, stepIcon?: func<br>&#124;&nbsp;object }"
17+
"description": "{ label?: func<br>&#124;&nbsp;object, root?: func<br>&#124;&nbsp;object, stepIcon?: func<br>&#124;&nbsp;object }"
1818
},
1919
"default": "{}"
2020
},
2121
"slots": {
22-
"type": { "name": "shape", "description": "{ label?: elementType, stepIcon?: elementType }" },
22+
"type": {
23+
"name": "shape",
24+
"description": "{ label?: elementType, root?: elementType, stepIcon?: elementType }"
25+
},
2326
"default": "{}"
2427
},
2528
"StepIconComponent": {
@@ -46,6 +49,12 @@
4649
"import { StepLabel } from '@mui/material';"
4750
],
4851
"slots": [
52+
{
53+
"name": "root",
54+
"description": "The component that renders the root.",
55+
"default": "span",
56+
"class": "MuiStepLabel-root"
57+
},
4958
{
5059
"name": "label",
5160
"description": "The component that renders the label.",
@@ -107,12 +116,6 @@
107116
"description": "Styles applied to the container element which wraps label and `optional`.",
108117
"isGlobal": false
109118
},
110-
{
111-
"key": "root",
112-
"className": "MuiStepLabel-root",
113-
"description": "Styles applied to the root element.",
114-
"isGlobal": false
115-
},
116119
{
117120
"key": "vertical",
118121
"className": "MuiStepLabel-vertical",

docs/translations/api-docs/step-label/step-label.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
"description": "Styles applied to {{nodeName}}.",
6161
"nodeName": "the container element which wraps label and <code>optional</code>"
6262
},
63-
"root": { "description": "Styles applied to the root element." },
6463
"vertical": {
6564
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
6665
"nodeName": "the root element",
@@ -69,6 +68,7 @@
6968
},
7069
"slotDescriptions": {
7170
"label": "The component that renders the label.",
71+
"root": "The component that renders the root.",
7272
"stepIcon": "The component to render in place of the <a href=\"https://mui.com/material-ui/api/step-icon/\"><code>StepIcon</code></a>."
7373
}
7474
}

packages/mui-material/src/StepLabel/StepLabel.d.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ import { StepLabelClasses } from './stepLabelClasses';
77
import { CreateSlotsAndSlotProps, SlotProps } from '../utils/types';
88

99
export interface StepLabelSlots {
10+
/**
11+
* The component that renders the root.
12+
* @default span
13+
*/
14+
root: React.ElementType;
1015
/**
1116
* The component that renders the label.
1217
* @default span
@@ -21,7 +26,20 @@ export interface StepLabelSlots {
2126
export type StepLabelSlotsAndSlotProps = CreateSlotsAndSlotProps<
2227
StepLabelSlots,
2328
{
24-
label: SlotProps<React.ElementType<React.HTMLProps<HTMLSpanElement>>, {}, StepLabelOwnerState>;
29+
/**
30+
* Props forwarded to the root slot.
31+
* By default, the avaible props are based on the span element.
32+
*/
33+
root: SlotProps<'span', {}, StepLabelOwnerState>;
34+
/**
35+
* Props forwarded to the label slot.
36+
* By default, the avaible props are based on the span element.
37+
*/
38+
label: SlotProps<'span', {}, StepLabelOwnerState>;
39+
/**
40+
* Props forwarded to the stepIcon slot.
41+
* By default, the avaible props are based on the div element.
42+
*/
2543
stepIcon: SlotProps<React.ElementType<StepIconProps>, {}, StepLabelOwnerState>;
2644
}
2745
>;

packages/mui-material/src/StepLabel/StepLabel.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,17 @@ const StepLabel = React.forwardRef(function StepLabel(inProps, ref) {
175175
},
176176
};
177177

178+
const [RootSlot, rootProps] = useSlot('root', {
179+
elementType: StepLabelRoot,
180+
externalForwardedProps: {
181+
...externalForwardedProps,
182+
...other,
183+
},
184+
ownerState,
185+
ref,
186+
className: clsx(classes.root, className),
187+
});
188+
178189
const [LabelSlot, labelProps] = useSlot('label', {
179190
elementType: StepLabelLabel,
180191
externalForwardedProps,
@@ -188,12 +199,7 @@ const StepLabel = React.forwardRef(function StepLabel(inProps, ref) {
188199
});
189200

190201
return (
191-
<StepLabelRoot
192-
className={clsx(classes.root, className)}
193-
ref={ref}
194-
ownerState={ownerState}
195-
{...other}
196-
>
202+
<RootSlot {...rootProps}>
197203
{icon || StepIconSlot ? (
198204
<StepLabelIconContainer className={classes.iconContainer} ownerState={ownerState}>
199205
<StepIconSlot
@@ -213,7 +219,7 @@ const StepLabel = React.forwardRef(function StepLabel(inProps, ref) {
213219
) : null}
214220
{optional}
215221
</StepLabelLabelContainer>
216-
</StepLabelRoot>
222+
</RootSlot>
217223
);
218224
});
219225

@@ -261,6 +267,7 @@ StepLabel.propTypes /* remove-proptypes */ = {
261267
*/
262268
slotProps: PropTypes.shape({
263269
label: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
270+
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
264271
stepIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
265272
}),
266273
/**
@@ -269,6 +276,7 @@ StepLabel.propTypes /* remove-proptypes */ = {
269276
*/
270277
slots: PropTypes.shape({
271278
label: PropTypes.elementType,
279+
root: PropTypes.elementType,
272280
stepIcon: PropTypes.elementType,
273281
}),
274282
/**

packages/mui-material/src/StepLabel/StepLabel.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ describe('<StepLabel />', () => {
2020
testVariantProps: { error: true },
2121
slots: {
2222
label: { expectedClassName: classes.label },
23+
root: { expectedClassName: classes.root },
2324
},
2425
skip: ['componentProp', 'componentsProp'],
2526
}));

0 commit comments

Comments
 (0)