Skip to content

Commit

Permalink
Fully use useSlotProps
Browse files Browse the repository at this point in the history
  • Loading branch information
mj12albert committed Oct 6, 2023
1 parent a8841cd commit ebc3807
Showing 1 changed file with 10 additions and 30 deletions.
40 changes: 10 additions & 30 deletions packages/mui-material-next/src/FilledInput/FilledInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
inputOverridesResolver as inputBaseInputOverridesResolver,
} from '../InputBase/InputBase';
import InputBase from '../InputBase';
import { InputBaseOwnerState } from '../InputBase/InputBase.types';
import filledInputClasses, { getFilledInputUtilityClass } from './filledInputClasses';
import { FilledInputOwnerState, FilledInputProps, FilledInputTypeMap } from './FilledInput.types';

Expand Down Expand Up @@ -260,32 +261,20 @@ const FilledInput = React.forwardRef(function FilledInput<
const rootProps = useSlotProps({
elementType: Root,
externalSlotProps: slotProps.root,
ownerState: {
...ownerState,
maxRows: undefined,
minRows: undefined,
rows: undefined,
'aria-describedby': undefined,
autoComplete: undefined,
formControl: undefined,
focused: false,
additionalProps: {
ref: forwardedRef,
fullWidth,
inputComponent,
},
externalForwardedProps: other,
ownerState: ownerState as FilledInputOwnerState & InputBaseOwnerState,
className: [classes.root],
});

const inputProps = useSlotProps({
elementType: Input,
externalSlotProps: slotProps.input,
ownerState: {
...ownerState,
maxRows: undefined,
minRows: undefined,
rows: undefined,
'aria-describedby': undefined,
autoComplete: undefined,
formControl: undefined,
focused: false,
},
ownerState: ownerState as FilledInputOwnerState & InputBaseOwnerState,
className: [classes.input],
});

Expand All @@ -294,14 +283,10 @@ const FilledInput = React.forwardRef(function FilledInput<
<InputBase
slots={{ root: Root, textarea: Input }}
slotProps={{
root: rootProps,
input: inputProps,
}}
fullWidth={fullWidth}
inputComponent={inputComponent}
multiline
ref={forwardedRef}
{...other}
{...rootProps}
/>
);
}
Expand All @@ -310,15 +295,10 @@ const FilledInput = React.forwardRef(function FilledInput<
<InputBase
slots={{ root: Root, input: Input }}
slotProps={{
root: rootProps,
input: inputProps,
}}
fullWidth={fullWidth}
inputComponent={inputComponent}
ref={forwardedRef}
type={type}
multiline={false}
{...other}
{...rootProps}
/>
);
}) as FilledInputComponent;
Expand Down

0 comments on commit ebc3807

Please sign in to comment.