Skip to content

Commit bd625af

Browse files
committed
Rename componentsProps to slotProps and components to slots
1 parent 897a690 commit bd625af

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

packages/mui-joy/src/utils/useSlot.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ export default function useSlot<
3939
ExternalSlotProps extends { component?: React.ElementType },
4040
ExternalForwardedProps extends {
4141
component?: React.ElementType;
42-
components?: { [k in T]?: React.ElementType };
43-
componentsProps?: {
42+
slots?: { [k in T]?: React.ElementType };
43+
slotProps?: {
4444
[k in T]?:
4545
| WithCommonProps<ExternalSlotProps>
4646
| ((ownerState: OwnerState) => WithCommonProps<ExternalSlotProps>);
@@ -70,7 +70,7 @@ export default function useSlot<
7070
*/
7171
ownerState: OwnerState;
7272
/**
73-
* The `other` props from the consumer. It has to contain `component`, `components`, and `componentsProps`.
73+
* The `other` props from the consumer. It has to contain `component`, `slots`, and `slotProps`.
7474
* The function will use those props to calculate the final leaf component and the returned props.
7575
*
7676
* If the slot is not `root`, the rest of the `externalForwardedProps` are neglect.
@@ -84,13 +84,13 @@ export default function useSlot<
8484
* For overriding the component's ownerState for the slot.
8585
* This is required for some components that need styling via `ownerState`.
8686
*
87-
* It is a function because `componentsProps.{slot}` can be a function which has to be resolved first.
87+
* It is a function because `slotProps.{slot}` can be a function which has to be resolved first.
8888
*/
8989
getSlotOwnerState?: (
9090
mergedProps: SlotProps &
9191
ExternalSlotProps &
9292
ExtractComponentProps<
93-
Exclude<Exclude<ExternalForwardedProps['componentsProps'], undefined>[T], undefined>
93+
Exclude<Exclude<ExternalForwardedProps['slotProps'], undefined>[T], undefined>
9494
>,
9595
) => SlotOwnerState;
9696
/**
@@ -111,14 +111,14 @@ export default function useSlot<
111111
} = parameters;
112112
const {
113113
component: rootComponent,
114-
components = { [name]: undefined },
115-
componentsProps = { [name]: undefined },
114+
slots = { [name]: undefined },
115+
slotProps = { [name]: undefined },
116116
...other
117117
} = externalForwardedProps;
118118

119-
// `componentsProps[name]` can be a callback that receives the component's ownerState.
119+
// `slotProps[name]` can be a callback that receives the component's ownerState.
120120
// `resolvedComponentsProps` is always a plain object.
121-
const resolvedComponentsProps = resolveComponentProps(componentsProps[name], ownerState);
121+
const resolvedComponentsProps = resolveComponentProps(slotProps[name], ownerState);
122122

123123
const {
124124
props: { component: slotComponent, ...mergedProps },
@@ -147,8 +147,8 @@ export default function useSlot<
147147
const props = appendOwnerState(
148148
elementType,
149149
{
150-
...(name === 'root' && !rootComponent && !components[name] && internalForwardedProps),
151-
...(name !== 'root' && !components[name] && internalForwardedProps),
150+
...(name === 'root' && !rootComponent && !slots[name] && internalForwardedProps),
151+
...(name !== 'root' && !slots[name] && internalForwardedProps),
152152
...(mergedProps as { className: string } & SlotProps &
153153
ExternalSlotProps &
154154
AdditionalProps &
@@ -161,5 +161,5 @@ export default function useSlot<
161161
finalOwnerState as OwnerState & SlotOwnerState,
162162
);
163163

164-
return [components[name] || elementType, props] as [ElementType, typeof props];
164+
return [slots[name] || elementType, props] as [ElementType, typeof props];
165165
}

0 commit comments

Comments
 (0)