Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[material-ui][InputBase] Deprecate components and componentProps props for v6 #42093

Merged
merged 11 commits into from
May 29, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,36 @@ The Divider's `light` prop was deprecated, Use `sx={{ opacity : "0.6" }}` (or an
/>
```

## FilledInput

Use the [codemod](https://github.com/mui/material-ui/tree/HEAD/packages/mui-codemod#filled-input-props) below to migrate the code as described in the following sections:

```bash
npx @mui/codemod@next deprecations/filled-input-props <path>
```

### components

The Input's prop `components` was deprecated in favor of `slots`:
DiegoAndai marked this conversation as resolved.
Show resolved Hide resolved

```diff
<FilledInput
- components={{ Input: CustomInput, Root: CustomRoot }}
+ slots={{ input: CustomInput, root: CustomRoot }}
/>
```

### componentsProps

The Input's prop `componentsProps` was deprecated in favor of `slotProps`:
DiegoAndai marked this conversation as resolved.
Show resolved Hide resolved

```diff
<FilledInput
- componentsProps={{ input: { id: 'test-input-id', root: { id: 'test-root-id' } } }}
+ slotProps={{ input: { id: 'test-input-id', root: { id: 'test-root-id' } } }}
/>
```

## FormControlLabel

Use the [codemod](https://github.com/mui/material-ui/tree/HEAD/packages/mui-codemod#form-control-label-props) below to migrate the code as described in the following sections:
Expand All @@ -991,6 +1021,66 @@ The FormControlLabel's `componentsProps` prop was deprecated in favor of `slotPr
/>
```

## Input

Use the [codemod](https://github.com/mui/material-ui/tree/HEAD/packages/mui-codemod#input-props) below to migrate the code as described in the following sections:

```bash
npx @mui/codemod@next deprecations/input-props <path>
```

### components

The Input's prop `components` was deprecated in favor of `slots`:

```diff
<Input
- components={{ Input: CustomInput, Root: CustomRoot }}
+ slots={{ input: CustomInput, root: CustomRoot }}
/>
```

### componentsProps

The Input's prop `componentsProps` was deprecated in favor of `slotProps`:

```diff
<Input
- componentsProps={{ input: { id: 'test-input-id', root: { id: 'test-root-id' } } }}
+ slotProps={{ input: { id: 'test-input-id', root: { id: 'test-root-id' } } }}
/>
```

## InputBase

Use the [codemod](https://github.com/mui/material-ui/tree/HEAD/packages/mui-codemod#input-base-props) below to migrate the code as described in the following sections:

```bash
npx @mui/codemod@next deprecations/input-base-props <path>
```

### components

The InputBase's prop `components` was deprecated in favor of `slots`:

```diff
<InputBase
- components={{ Input: CustomInput, Root: CustomRoot }}
+ slots={{ input: CustomInput, root: CustomRoot }}
/>
```

### componentsProps

The InputBase's prop `componentsProps` was deprecated in favor of `slotProps`:

```diff
<Input
- componentsProps={{ input: { id: 'test-input-id' }, root: { id: 'test-root-id' } }}
+ slotProps={{ input: { id: 'test-input-id' }, root: { id: 'test-root-id' } }}
/>
```

## ListItem

Use the [codemod](https://github.com/mui/material-ui/tree/HEAD/packages/mui-codemod#list-item-props) below to migrate the code as described in the following sections:
Expand Down Expand Up @@ -1072,12 +1162,42 @@ The Grid's `wrap` prop was deprecated in favor of `flexWrap` MUI System prop:
/>;
```

## OutlinedInput

Use the [codemod](https://github.com/mui/material-ui/tree/HEAD/packages/mui-codemod#outlined-input-props) below to migrate the code as described in the following sections:

```bash
npx @mui/codemod@next deprecations/outlined-input-props <path>
```

### components

The Input's prop `components` was deprecated in favor of `slots`:
DiegoAndai marked this conversation as resolved.
Show resolved Hide resolved

```diff
<OutlinedInput
- components={{ Input: CustomInput, Root: CustomRoot }}
+ slots={{ input: CustomInput, root: CustomRoot }}
/>
```

### componentsProps

The Input's prop `componentsProps` was deprecated in favor of `slotProps`:
DiegoAndai marked this conversation as resolved.
Show resolved Hide resolved

```diff
<OutlinedInput
- componentsProps={{ input: { id: 'test-input-id', root: { id: 'test-root-id' } } }}
+ slotProps={{ input: { id: 'test-input-id', root: { id: 'test-root-id' } } }}
/>
```

## PaginationItem

Use the [codemod](https://github.com/mui/material-ui/tree/HEAD/packages/mui-codemod#pagination-item-classes) below to migrate the code as described in the following sections:

```bash
npx @mui/codemod@latest deprecations/pagination-item-classes <path>
npx @mui/codemod@next deprecations/pagination-item-classes <path>
```

### Composed CSS classes
Expand Down
8 changes: 6 additions & 2 deletions docs/pages/material-ui/api/filled-input.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@
},
"components": {
"type": { "name": "shape", "description": "{ Input?: elementType, Root?: elementType }" },
"default": "{}"
"default": "{}",
"deprecated": true,
"deprecationInfo": "use the <code>slots</code> prop instead. This prop will be removed in v7. <a href=\"/material-ui/migration/migrating-from-deprecated-apis/\">How to migrate</a>."
},
"componentsProps": {
"type": { "name": "shape", "description": "{ input?: object, root?: object }" },
"default": "{}"
"default": "{}",
"deprecated": true,
"deprecationInfo": "use the <code>slotProps</code> prop instead. This prop will be removed in v7. <a href=\"/material-ui/migration/migrating-from-deprecated-apis/\">How to migrate</a>."
},
"defaultValue": { "type": { "name": "any" } },
"disabled": { "type": { "name": "bool" } },
Expand Down
8 changes: 6 additions & 2 deletions docs/pages/material-ui/api/input-base.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@
},
"components": {
"type": { "name": "shape", "description": "{ Input?: elementType, Root?: elementType }" },
"default": "{}"
"default": "{}",
"deprecated": true,
"deprecationInfo": "use the <code>slots</code> prop instead. This prop will be removed in v7. <a href=\"/material-ui/migration/migrating-from-deprecated-apis/\">How to migrate</a>."
},
"componentsProps": {
"type": { "name": "shape", "description": "{ input?: object, root?: object }" },
"default": "{}"
"default": "{}",
"deprecated": true,
"deprecationInfo": "use the <code>slotProps</code> prop instead. This prop will be removed in v7. <a href=\"/material-ui/migration/migrating-from-deprecated-apis/\">How to migrate</a>."
},
"defaultValue": { "type": { "name": "any" } },
"disabled": { "type": { "name": "bool" } },
Expand Down
8 changes: 6 additions & 2 deletions docs/pages/material-ui/api/input.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@
},
"components": {
"type": { "name": "shape", "description": "{ Input?: elementType, Root?: elementType }" },
"default": "{}"
"default": "{}",
"deprecated": true,
"deprecationInfo": "use the <code>slots</code> prop instead. This prop will be removed in v7. <a href=\"/material-ui/migration/migrating-from-deprecated-apis/\">How to migrate</a>."
},
"componentsProps": {
"type": { "name": "shape", "description": "{ input?: object, root?: object }" },
"default": "{}"
"default": "{}",
"deprecated": true,
"deprecationInfo": "use the <code>slotProps</code> prop instead. This prop will be removed in v7. <a href=\"/material-ui/migration/migrating-from-deprecated-apis/\">How to migrate</a>."
},
"defaultValue": { "type": { "name": "any" } },
"disabled": { "type": { "name": "bool" } },
Expand Down
4 changes: 3 additions & 1 deletion docs/pages/material-ui/api/outlined-input.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
},
"components": {
"type": { "name": "shape", "description": "{ Input?: elementType, Root?: elementType }" },
"default": "{}"
"default": "{}",
"deprecated": true,
"deprecationInfo": "use the <code>slots</code> prop instead. This prop will be removed in v7. <a href=\"/material-ui/migration/migrating-from-deprecated-apis/\">How to migrate</a>."
},
"defaultValue": { "type": { "name": "any" } },
"disabled": { "type": { "name": "bool" } },
Expand Down
6 changes: 2 additions & 4 deletions docs/translations/api-docs/filled-input/filled-input.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@
"color": {
"description": "The color of the component. It supports both default and custom theme colors, which can be added as shown in the <a href=\"https://mui.com/material-ui/customization/palette/#custom-colors\">palette customization guide</a>. The prop defaults to the value (<code>&#39;primary&#39;</code>) inherited from the parent FormControl component."
},
"components": {
"description": "The components used for each slot inside.<br>This prop is an alias for the <code>slots</code> prop. It&#39;s recommended to use the <code>slots</code> prop instead."
},
"components": { "description": "The components used for each slot inside." },
"componentsProps": {
"description": "The extra props for the slot components. You can override the existing props or add new ones.<br>This prop is an alias for the <code>slotProps</code> prop. It&#39;s recommended to use the <code>slotProps</code> prop instead, as <code>componentsProps</code> will be deprecated in the future."
"description": "The extra props for the slot components. You can override the existing props or add new ones."
},
"defaultValue": {
"description": "The default value. Use when the component is not controlled."
Expand Down
6 changes: 2 additions & 4 deletions docs/translations/api-docs/input-base/input-base.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@
"color": {
"description": "The color of the component. It supports both default and custom theme colors, which can be added as shown in the <a href=\"https://mui.com/material-ui/customization/palette/#custom-colors\">palette customization guide</a>. The prop defaults to the value (<code>&#39;primary&#39;</code>) inherited from the parent FormControl component."
},
"components": {
"description": "The components used for each slot inside.<br>This prop is an alias for the <code>slots</code> prop. It&#39;s recommended to use the <code>slots</code> prop instead."
},
"components": { "description": "The components used for each slot inside." },
"componentsProps": {
"description": "The extra props for the slot components. You can override the existing props or add new ones.<br>This prop is an alias for the <code>slotProps</code> prop. It&#39;s recommended to use the <code>slotProps</code> prop instead, as <code>componentsProps</code> will be deprecated in the future."
"description": "The extra props for the slot components. You can override the existing props or add new ones."
},
"defaultValue": {
"description": "The default value. Use when the component is not controlled."
Expand Down
6 changes: 2 additions & 4 deletions docs/translations/api-docs/input/input.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@
"color": {
"description": "The color of the component. It supports both default and custom theme colors, which can be added as shown in the <a href=\"https://mui.com/material-ui/customization/palette/#custom-colors\">palette customization guide</a>. The prop defaults to the value (<code>&#39;primary&#39;</code>) inherited from the parent FormControl component."
},
"components": {
"description": "The components used for each slot inside.<br>This prop is an alias for the <code>slots</code> prop. It&#39;s recommended to use the <code>slots</code> prop instead."
},
"components": { "description": "The components used for each slot inside." },
"componentsProps": {
"description": "The extra props for the slot components. You can override the existing props or add new ones.<br>This prop is an alias for the <code>slotProps</code> prop. It&#39;s recommended to use the <code>slotProps</code> prop instead, as <code>componentsProps</code> will be deprecated in the future."
"description": "The extra props for the slot components. You can override the existing props or add new ones."
},
"defaultValue": {
"description": "The default value. Use when the component is not controlled."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
"color": {
"description": "The color of the component. It supports both default and custom theme colors, which can be added as shown in the <a href=\"https://mui.com/material-ui/customization/palette/#custom-colors\">palette customization guide</a>. The prop defaults to the value (<code>&#39;primary&#39;</code>) inherited from the parent FormControl component."
},
"components": {
"description": "The components used for each slot inside.<br>This prop is an alias for the <code>slots</code> prop. It&#39;s recommended to use the <code>slots</code> prop instead."
},
"components": { "description": "The components used for each slot inside." },
"defaultValue": {
"description": "The default value. Use when the component is not controlled."
},
Expand Down
104 changes: 104 additions & 0 deletions packages/mui-codemod/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3049,3 +3049,107 @@ The diff should look like this:
```bash
npx @mui/codemod@next v0.15.0/import-path <path>
```

#### `input-base-props`

```diff
<InputBase
- components={{ Input: CustomInput, Root: CustomRoot }}
+ slots={{ input: CustomInput, root: CustomRoot }}
- componentsProps={{ input: { id: 'test-input-id' }, root: { id: 'test-root-id' } }}
+ slotProps={{ input: { id: 'test-input-id' }, root: { id: 'test-root-id' } }}
/>
```

```diff
MuiInputBase: {
defaultProps: {
- components: { Input: CustomInput, Root: CustomRoot }
+ slots: { input: CustomInput, root: CustomRoot },
- componentsProps: { input: { id: 'test-input-id' }, root: { id: 'test-root-id' } }
+ slotProps: { input: { id: 'test-input-id' }, root: { id: 'test-root-id' } },
},
},
```

```bash
npx @mui/codemod@latest deprecations/input-base-props <path>
```

#### `input-props`

```diff
<Input
- components={{ Input: CustomInput, Root: CustomRoot }}
+ slots={{ input: CustomInput, root: CustomRoot }}
- componentsProps={{ input: { id: 'test-input-id' }, root: { id: 'test-root-id' } }}
+ slotProps={{ input: { id: 'test-input-id' }, root: { id: 'test-root-id' } }}
/>
```

```diff
MuiInput: {
defaultProps: {
- components: { Input: CustomInput, Root: CustomRoot }
+ slots: { input: CustomInput, root: CustomRoot },
- componentsProps: { input: { id: 'test-input-id' }, root: { id: 'test-root-id' } }
+ slotProps: { input: { id: 'test-input-id' }, root: { id: 'test-root-id' } },
},
},
```

```bash
npx @mui/codemod@latest deprecations/input-props <path>
```

#### `filled-input-props`

```diff
<FilledInput
- components={{ Input: CustomInput, Root: CustomRoot }}
+ slots={{ input: CustomInput, root: CustomRoot }}
- componentsProps={{ input: { id: 'test-input-id' }, root: { id: 'test-root-id' } }}
+ slotProps={{ input: { id: 'test-input-id' }, root: { id: 'test-root-id' } }}
/>
```

```diff
MuiFilledInput: {
defaultProps: {
- components: { Input: CustomInput, Root: CustomRoot }
+ slots: { input: CustomInput, root: CustomRoot },
- componentsProps: { input: { id: 'test-input-id' }, root: { id: 'test-root-id' } }
+ slotProps: { input: { id: 'test-input-id' }, root: { id: 'test-root-id' } },
},
},
```

```bash
npx @mui/codemod@latest deprecations/filled-input-props <path>
```

#### `outlined-input-props`

```diff
<OutlinedInput
- components={{ Input: CustomInput, Root: CustomRoot }}
+ slots={{ input: CustomInput, root: CustomRoot }}
- componentsProps={{ input: { id: 'test-input-id' }, root: { id: 'test-root-id' } }}
+ slotProps={{ input: { id: 'test-input-id' }, root: { id: 'test-root-id' } }}
/>
```

```diff
MuiOutlinedInput: {
defaultProps: {
- components: { Input: CustomInput, Root: CustomRoot }
+ slots: { input: CustomInput, root: CustomRoot },
- componentsProps: { input: { id: 'test-input-id' }, root: { id: 'test-root-id' } }
+ slotProps: { input: { id: 'test-input-id' }, root: { id: 'test-root-id' } },
},
},
```

```bash
npx @mui/codemod@latest deprecations/outlined-input-props <path>
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import replaceComponentsWithSlots from '../utils/replaceComponentsWithSlots';

/**
* @param {import('jscodeshift').FileInfo} file
* @param {import('jscodeshift').API} api
*/
export default function transformer(file, api, options) {
const j = api.jscodeshift;
const root = j(file.source);
const printOptions = options.printOptions;

replaceComponentsWithSlots(j, { root, componentName: 'FilledInput' });

return root.toSource(printOptions);
}
Loading