Skip to content

Commit c9fddc1

Browse files
committed
Rename componentsProps to slotProps and components to slots
1 parent f687471 commit c9fddc1

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
@@ -35,8 +35,8 @@ export default function useSlot<
3535
ExternalSlotProps extends { component?: React.ElementType },
3636
ExternalForwardedProps extends {
3737
component?: React.ElementType;
38-
components?: { [k in T]?: React.ElementType };
39-
componentsProps?: {
38+
slots?: { [k in T]?: React.ElementType };
39+
slotProps?: {
4040
[k in T]?:
4141
| WithCommonProps<ExternalSlotProps>
4242
| ((ownerState: OwnerState) => WithCommonProps<ExternalSlotProps>);
@@ -66,7 +66,7 @@ export default function useSlot<
6666
*/
6767
ownerState: OwnerState;
6868
/**
69-
* The `other` props from the consumer. It has to contain `component`, `components`, and `componentsProps`.
69+
* The `other` props from the consumer. It has to contain `component`, `slots`, and `slotProps`.
7070
* The function will use those props to calculate the final leaf component and the returned props.
7171
*
7272
* If the slot is not `root`, the rest of the `externalForwardedProps` are neglected.
@@ -80,13 +80,13 @@ export default function useSlot<
8080
* For overriding the component's ownerState for the slot.
8181
* This is required for some components that need styling via `ownerState`.
8282
*
83-
* It is a function because `componentsProps.{slot}` can be a function which has to be resolved first.
83+
* It is a function because `slotProps.{slot}` can be a function which has to be resolved first.
8484
*/
8585
getSlotOwnerState?: (
8686
mergedProps: SlotProps &
8787
ExternalSlotProps &
8888
ExtractComponentProps<
89-
Exclude<Exclude<ExternalForwardedProps['componentsProps'], undefined>[T], undefined>
89+
Exclude<Exclude<ExternalForwardedProps['slotProps'], undefined>[T], undefined>
9090
>,
9191
) => SlotOwnerState;
9292
/**
@@ -107,14 +107,14 @@ export default function useSlot<
107107
} = parameters;
108108
const {
109109
component: rootComponent,
110-
components = { [name]: undefined },
111-
componentsProps = { [name]: undefined },
110+
slots = { [name]: undefined },
111+
slotProps = { [name]: undefined },
112112
...other
113113
} = externalForwardedProps;
114114

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

119119
const {
120120
props: { component: slotComponent, ...mergedProps },
@@ -143,8 +143,8 @@ export default function useSlot<
143143
const props = appendOwnerState(
144144
elementType,
145145
{
146-
...(name === 'root' && !rootComponent && !components[name] && internalForwardedProps),
147-
...(name !== 'root' && !components[name] && internalForwardedProps),
146+
...(name === 'root' && !rootComponent && !slots[name] && internalForwardedProps),
147+
...(name !== 'root' && !slots[name] && internalForwardedProps),
148148
...(mergedProps as { className: string } & SlotProps &
149149
ExternalSlotProps &
150150
AdditionalProps &
@@ -157,5 +157,5 @@ export default function useSlot<
157157
finalOwnerState as OwnerState & SlotOwnerState,
158158
);
159159

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

0 commit comments

Comments
 (0)