Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d22419d
deprecate *Component and *Props with codemod
lhilgert9 Apr 12, 2024
3014b3a
Update packages/mui-material/src/Autocomplete/Autocomplete.d.ts
lhilgert9 Apr 25, 2024
35491c1
Merge branch 'next' into deprecate-autocomple-props
lhilgert9 Apr 25, 2024
9f03cea
use same props as in component props
lhilgert9 Apr 25, 2024
ee9d557
Fix paper slots and slotProps types
lhilgert9 Apr 25, 2024
7b9e3b6
fix proptypes
lhilgert9 Apr 26, 2024
83d8ab3
Merge remote-tracking branch 'upstream' into deprecate-autocomplete-p…
lhilgert9 Apr 26, 2024
8bc86ad
run docs:api
lhilgert9 Apr 26, 2024
834d1e1
fix slots props to be optional
lhilgert9 Apr 26, 2024
44f5c0b
change demos to use slots and slotProps
lhilgert9 Apr 30, 2024
32ce9b4
Merge remote-tracking branch 'upstream' into deprecate-autocomple-props
lhilgert9 Apr 30, 2024
dfdbf4d
pnpm docs:typescript:formatted
lhilgert9 Apr 30, 2024
fe2401d
fix proptypes
lhilgert9 May 1, 2024
7cea30a
fix slotProps types to accept functions
lhilgert9 May 2, 2024
c5ffabe
add explanation for deprecated api's
lhilgert9 May 4, 2024
e2dcb00
Merge remote-tracking branch 'upstream/next' into deprecate-autocompl…
lhilgert9 May 4, 2024
be30a71
fix missing ","
lhilgert9 May 4, 2024
1a8ebb9
migrate Autocomplete tests to not use deprecated apis
lhilgert9 May 4, 2024
8ffaab6
Revert "migrate Autocomplete tests to not use deprecated apis"
DiegoAndai May 7, 2024
0f8665c
Update migrating guide link messages
DiegoAndai May 7, 2024
e7a5e56
Update codemod install version
DiegoAndai May 7, 2024
4960559
Update tests
DiegoAndai May 7, 2024
96d8b77
pnpm docs:api
lhilgert9 May 7, 2024
d859029
trigger ci
DiegoAndai May 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/data/material/components/autocomplete/GitHubLabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ export default function GitHubLabel() {
setPendingValue(newValue);
}}
disableCloseOnSelect
PopperComponent={PopperComponent}
renderTags={() => null}
noOptionsText="No labels"
renderOption={(props, option, { selected }) => (
Expand Down Expand Up @@ -255,6 +254,9 @@ export default function GitHubLabel() {
placeholder="Filter labels"
/>
)}
slots={{
popper: PopperComponent,
}}
/>
</div>
</ClickAwayListener>
Expand Down
4 changes: 3 additions & 1 deletion docs/data/material/components/autocomplete/GitHubLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ export default function GitHubLabel() {
setPendingValue(newValue);
}}
disableCloseOnSelect
PopperComponent={PopperComponent}
renderTags={() => null}
noOptionsText="No labels"
renderOption={(props, option, { selected }) => (
Expand Down Expand Up @@ -261,6 +260,9 @@ export default function GitHubLabel() {
placeholder="Filter labels"
/>
)}
slots={{
popper: PopperComponent,
}}
/>
</div>
</ClickAwayListener>
Expand Down
6 changes: 4 additions & 2 deletions docs/data/material/components/autocomplete/Virtualize.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,15 @@ export default function Virtualize() {
id="virtualize-demo"
sx={{ width: 300 }}
disableListWrap
PopperComponent={StyledPopper}
ListboxComponent={ListboxComponent}
options={OPTIONS}
groupBy={(option) => option[0].toUpperCase()}
renderInput={(params) => <TextField {...params} label="10,000 options" />}
renderOption={(props, option, state) => [props, option, state.index]}
renderGroup={(params) => params}
slots={{
popper: StyledPopper,
listbox: ListboxComponent,
}}
/>
);
}
6 changes: 4 additions & 2 deletions docs/data/material/components/autocomplete/Virtualize.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,17 @@ export default function Virtualize() {
id="virtualize-demo"
sx={{ width: 300 }}
disableListWrap
PopperComponent={StyledPopper}
ListboxComponent={ListboxComponent}
options={OPTIONS}
groupBy={(option) => option[0].toUpperCase()}
renderInput={(params) => <TextField {...params} label="10,000 options" />}
renderOption={(props, option, state) =>
[props, option, state.index] as React.ReactNode
}
renderGroup={(params) => params as any}
slots={{
popper: StyledPopper,
listbox: ListboxComponent,
}}
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
id="virtualize-demo"
sx={{ width: 300 }}
disableListWrap
PopperComponent={StyledPopper}
ListboxComponent={ListboxComponent}
options={OPTIONS}
groupBy={(option) => option[0].toUpperCase()}
renderInput={(params) => <TextField {...params} label="10,000 options" />}
renderOption={(props, option, state) =>
[props, option, state.index] as React.ReactNode
}
renderGroup={(params) => params as any}
slots={{
popper: StyledPopper,
listbox: ListboxComponent,
}}
/>
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,14 @@ Here's how to migrate:
},
```

## Autocomplete

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

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

## Avatar

Use the [codemod](https://github.com/mui/material-ui/tree/HEAD/packages/mui-codemod#avatar-props) below to migrate the code as described in the following sections:
Expand Down
80 changes: 56 additions & 24 deletions docs/pages/material-ui/api/autocomplete.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
},
"default": "false"
},
"ChipProps": { "type": { "name": "object" } },
"ChipProps": {
"type": { "name": "object" },
"deprecated": true,
"deprecationInfo": "Use <code>slotProps.chip</code> instead. This prop will be removed in v7. <a href=\"/material-ui/migration/migrating-from-deprecated-apis/\">How to migrate</a>."
},
"classes": { "type": { "name": "object" }, "additionalInfo": { "cssApi": true } },
"clearIcon": { "type": { "name": "node" }, "default": "<ClearIcon fontSize=\"small\" />" },
"clearOnBlur": { "type": { "name": "bool" }, "default": "!props.freeSolo" },
Expand Down Expand Up @@ -92,8 +96,17 @@
}
},
"limitTags": { "type": { "name": "custom", "description": "integer" }, "default": "-1" },
"ListboxComponent": { "type": { "name": "elementType" }, "default": "'ul'" },
"ListboxProps": { "type": { "name": "object" } },
"ListboxComponent": {
"type": { "name": "elementType" },
"default": "'ul'",
"deprecated": true,
"deprecationInfo": "Use <code>slots.listbox</code> instead. This prop will be removed in v7. <a href=\"/material-ui/migration/migrating-from-deprecated-apis/\">How to migrate</a>."
},
"ListboxProps": {
"type": { "name": "object" },
"deprecated": true,
"deprecationInfo": "Use <code>slotProps.listbox</code> instead. This prop will be removed in v7. <a href=\"/material-ui/migration/migrating-from-deprecated-apis/\">How to migrate</a>."
},
"loading": { "type": { "name": "bool" }, "default": "false" },
"loadingText": { "type": { "name": "node" }, "default": "'Loading…'" },
"multiple": { "type": { "name": "bool" }, "default": "false" },
Expand Down Expand Up @@ -136,8 +149,18 @@
"open": { "type": { "name": "bool" } },
"openOnFocus": { "type": { "name": "bool" }, "default": "false" },
"openText": { "type": { "name": "string" }, "default": "'Open'" },
"PaperComponent": { "type": { "name": "elementType" }, "default": "Paper" },
"PopperComponent": { "type": { "name": "elementType" }, "default": "Popper" },
"PaperComponent": {
"type": { "name": "elementType" },
"default": "Paper",
"deprecated": true,
"deprecationInfo": "Use <code>slots.paper</code> instead. This prop will be removed in v7. <a href=\"/material-ui/migration/migrating-from-deprecated-apis/\">How to migrate</a>."
},
"PopperComponent": {
"type": { "name": "elementType" },
"default": "Popper",
"deprecated": true,
"deprecationInfo": "Use <code>slots.popper</code> instead. This prop will be removed in v7. <a href=\"/material-ui/migration/migrating-from-deprecated-apis/\">How to migrate</a>."
},
"popupIcon": { "type": { "name": "node" }, "default": "<ArrowDropDownIcon />" },
"readOnly": { "type": { "name": "bool" }, "default": "false" },
"renderGroup": {
Expand Down Expand Up @@ -172,7 +195,14 @@
"slotProps": {
"type": {
"name": "shape",
"description": "{ clearIndicator?: object, paper?: object, popper?: object, popupIndicator?: object }"
"description": "{ chip?: func<br>&#124;&nbsp;object, clearIndicator?: func<br>&#124;&nbsp;object, listbox?: func<br>&#124;&nbsp;object, paper?: func<br>&#124;&nbsp;object, popper?: func<br>&#124;&nbsp;object, popupIndicator?: func<br>&#124;&nbsp;object }"
},
"default": "{}"
},
"slots": {
"type": {
"name": "shape",
"description": "{ listbox?: elementType, paper?: elementType, popper?: elementType }"
},
"default": "{}"
},
Expand All @@ -190,6 +220,26 @@
"import Autocomplete from '@mui/material/Autocomplete';",
"import { Autocomplete } from '@mui/material';"
],
"slots": [
{
"name": "listbox",
"description": "The component used to render the listbox.",
"default": "'ul'",
"class": "MuiAutocomplete-listbox"
},
{
"name": "paper",
"description": "The component used to render the body of the popup.",
"default": "Paper",
"class": "MuiAutocomplete-paper"
},
{
"name": "popper",
"description": "The component used to position the popup.",
"default": "Popper",
"class": "MuiAutocomplete-popper"
}
],
"classes": [
{
"key": "clearIndicator",
Expand Down Expand Up @@ -269,12 +319,6 @@
"description": "Styles applied to the Input element.",
"isGlobal": false
},
{
"key": "listbox",
"className": "MuiAutocomplete-listbox",
"description": "Styles applied to the listbox component.",
"isGlobal": false
},
{
"key": "loading",
"className": "MuiAutocomplete-loading",
Expand All @@ -293,18 +337,6 @@
"description": "Styles applied to the option elements.",
"isGlobal": false
},
{
"key": "paper",
"className": "MuiAutocomplete-paper",
"description": "Styles applied to the Paper component.",
"isGlobal": false
},
{
"key": "popper",
"className": "MuiAutocomplete-popper",
"description": "Styles applied to the popper element.",
"isGlobal": false
},
{
"key": "popperDisablePortal",
"className": "MuiAutocomplete-popperDisablePortal",
Expand Down
18 changes: 6 additions & 12 deletions docs/translations/api-docs/autocomplete/autocomplete.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@
},
"size": { "description": "The size of the component." },
"slotProps": { "description": "The props used for each slot inside." },
"slots": { "description": "The components used for each slot inside." },
"sx": {
"description": "The system prop that allows defining system overrides as well as additional CSS styles."
},
Expand Down Expand Up @@ -245,10 +246,6 @@
"description": "Styles applied to {{nodeName}}.",
"nodeName": "the Input element"
},
"listbox": {
"description": "Styles applied to {{nodeName}}.",
"nodeName": "the listbox component"
},
"loading": {
"description": "Styles applied to {{nodeName}}.",
"nodeName": "the loading wrapper"
Expand All @@ -261,14 +258,6 @@
"description": "Styles applied to {{nodeName}}.",
"nodeName": "the option elements"
},
"paper": {
"description": "Styles applied to {{nodeName}}.",
"nodeName": "the Paper component"
},
"popper": {
"description": "Styles applied to {{nodeName}}.",
"nodeName": "the popper element"
},
"popperDisablePortal": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the popper element",
Expand Down Expand Up @@ -299,5 +288,10 @@
"nodeName": "the tag elements",
"conditions": "for example the chips if <code>size=\"small\"</code>"
}
},
"slotDescriptions": {
"listbox": "The component used to render the listbox.",
"paper": "The component used to render the body of the popup.",
"popper": "The component used to position the popup."
}
}
46 changes: 46 additions & 0 deletions packages/mui-codemod/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,52 @@ npx @mui/codemod@next deprecations/alert-classes <path>
npx @mui/codemod@next deprecations/alert-props <path>
```

#### `autocomplete-props`

```diff
<Autocomplete
- ChipProps={{ height: 10 }}
- PaperComponent={CustomPaper}
- PopperComponent={CustomPopper}
- ListboxComponent={CustomListbox}
- ListboxProps={{ height: 12 }}
+ slots={{
+ paper: CustomPaper,
+ popper: CustomPopper,
+ listbox: CustomListbox,
+ }}
+ slotProps={{
+ chip: { height: 10 },
+ listbox: { height: 12 },
+ }}
/>
```

```diff
MuiAutocomplete: {
defaultProps: {
- ChipProps: { height: 10 },
- PaperComponent: CustomPaper,
- PopperComponent: CustomPopper,
- ListboxComponent: CustomListbox,
- ListboxProps: { height: 12 },
+ slots: {
+ paper: CustomPaper,
+ popper: CustomPopper,
+ listbox: CustomListbox,
+ },
+ slotProps: {
+ chip: { height: 10 },
+ listbox: { height: 12 },
+ },
},
},
```

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

#### `avatar-props`

```diff
Expand Down
2 changes: 2 additions & 0 deletions packages/mui-codemod/src/deprecations/all/deprecations-all.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import transformAccordionProps from '../accordion-props';
import transformAutocompleteProps from '../autocomplete-props';
import transformFormControlLabelProps from '../form-control-label-props';
import transformAvatarProps from '../avatar-props';
import transformDividerProps from '../divider-props';
Expand All @@ -19,6 +20,7 @@ import transformStepConnectorClasses from '../step-connector-classes';
*/
export default function deprecationsAll(file, api, options) {
file.source = transformAccordionProps(file, api, options);
file.source = transformAutocompleteProps(file, api, options);
file.source = transformFormControlLabelProps(file, api, options);
file.source = transformAvatarProps(file, api, options);
file.source = transformDividerProps(file, api, options);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import movePropIntoSlots from '../utils/movePropIntoSlots';
import movePropIntoSlotProps from '../utils/movePropIntoSlotProps';

/**
* @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;

movePropIntoSlots(j, {
root,
componentName: 'Autocomplete',
propName: 'PaperComponent',
slotName: 'paper',
});

movePropIntoSlots(j, {
root,
componentName: 'Autocomplete',
propName: 'PopperComponent',
slotName: 'popper',
});

movePropIntoSlots(j, {
root,
componentName: 'Autocomplete',
propName: 'ListboxComponent',
slotName: 'listbox',
});

movePropIntoSlotProps(j, {
root,
componentName: 'Autocomplete',
propName: 'ListboxProps',
slotName: 'listbox',
});

movePropIntoSlotProps(j, {
root,
componentName: 'Autocomplete',
propName: 'ChipProps',
slotName: 'chip',
});

return root.toSource(printOptions);
}
Loading