Skip to content

Commit 48c53d1

Browse files
authored
[docs] Migrate Autocomplete demos (#26127)
1 parent 80ef747 commit 48c53d1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+506
-816
lines changed

docs/src/pages/components/autocomplete/Asynchronous.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export default function Asynchronous() {
4444
return (
4545
<Autocomplete
4646
id="asynchronous-demo"
47-
style={{ width: 300 }}
47+
sx={{ width: 300 }}
4848
open={open}
4949
onOpen={() => {
5050
setOpen(true);

docs/src/pages/components/autocomplete/Asynchronous.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export default function Asynchronous() {
4949
return (
5050
<Autocomplete
5151
id="asynchronous-demo"
52-
style={{ width: 300 }}
52+
sx={{ width: 300 }}
5353
open={open}
5454
onOpen={() => {
5555
setOpen(true);

docs/src/pages/components/autocomplete/ComboBox.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default function ComboBox() {
99
disablePortal
1010
id="combo-box-demo"
1111
options={top100Films}
12-
style={{ width: 300 }}
12+
sx={{ width: 300 }}
1313
renderInput={(params) => <TextField {...params} label="Movie" />}
1414
/>
1515
);

docs/src/pages/components/autocomplete/ComboBox.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default function ComboBox() {
99
disablePortal
1010
id="combo-box-demo"
1111
options={top100Films}
12-
style={{ width: 300 }}
12+
sx={{ width: 300 }}
1313
renderInput={(params) => <TextField {...params} label="Movie" />}
1414
/>
1515
);

docs/src/pages/components/autocomplete/ControllableStates.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default function ControllableStates() {
2424
}}
2525
id="controllable-states-demo"
2626
options={options}
27-
style={{ width: 300 }}
27+
sx={{ width: 300 }}
2828
renderInput={(params) => <TextField {...params} label="Controllable" />}
2929
/>
3030
</div>

docs/src/pages/components/autocomplete/ControllableStates.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default function ControllableStates() {
2424
}}
2525
id="controllable-states-demo"
2626
options={options}
27-
style={{ width: 300 }}
27+
sx={{ width: 300 }}
2828
renderInput={(params) => <TextField {...params} label="Controllable" />}
2929
/>
3030
</div>

docs/src/pages/components/autocomplete/CountrySelect.js

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/* eslint-disable @typescript-eslint/no-use-before-define */
22
import * as React from 'react';
3+
import Box from '@material-ui/core/Box';
34
import TextField from '@material-ui/core/TextField';
45
import Autocomplete from '@material-ui/core/Autocomplete';
5-
import { makeStyles } from '@material-ui/core/styles';
66

77
// ISO 3166-1 alpha-2
88
// ⚠️ No support for IE11
@@ -14,34 +14,23 @@ function countryToFlag(isoCode) {
1414
: isoCode;
1515
}
1616

17-
const useStyles = makeStyles({
18-
option: {
19-
fontSize: 15,
20-
'& > span': {
21-
marginRight: 10,
22-
fontSize: 18,
23-
},
24-
},
25-
});
26-
2717
export default function CountrySelect() {
28-
const classes = useStyles();
29-
3018
return (
3119
<Autocomplete
3220
id="country-select-demo"
33-
style={{ width: 300 }}
21+
sx={{ width: 300 }}
3422
options={countries}
35-
classes={{
36-
option: classes.option,
37-
}}
3823
autoHighlight
3924
getOptionLabel={(option) => option.label}
4025
renderOption={(props, option) => (
41-
<li {...props}>
26+
<Box
27+
component="li"
28+
sx={{ fontSize: 15, '& > span': { mr: '10px', fontSize: 18 } }}
29+
{...props}
30+
>
4231
<span>{countryToFlag(option.code)}</span>
4332
{option.label} ({option.code}) +{option.phone}
44-
</li>
33+
</Box>
4534
)}
4635
renderInput={(params) => (
4736
<TextField

docs/src/pages/components/autocomplete/CountrySelect.tsx

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/* eslint-disable @typescript-eslint/no-use-before-define */
22
import * as React from 'react';
3+
import Box from '@material-ui/core/Box';
34
import TextField from '@material-ui/core/TextField';
45
import Autocomplete from '@material-ui/core/Autocomplete';
5-
import { makeStyles } from '@material-ui/core/styles';
66

77
// ISO 3166-1 alpha-2
88
// ⚠️ No support for IE11
@@ -14,34 +14,23 @@ function countryToFlag(isoCode: string) {
1414
: isoCode;
1515
}
1616

17-
const useStyles = makeStyles({
18-
option: {
19-
fontSize: 15,
20-
'& > span': {
21-
marginRight: 10,
22-
fontSize: 18,
23-
},
24-
},
25-
});
26-
2717
export default function CountrySelect() {
28-
const classes = useStyles();
29-
3018
return (
3119
<Autocomplete
3220
id="country-select-demo"
33-
style={{ width: 300 }}
21+
sx={{ width: 300 }}
3422
options={countries}
35-
classes={{
36-
option: classes.option,
37-
}}
3823
autoHighlight
3924
getOptionLabel={(option) => option.label}
4025
renderOption={(props, option) => (
41-
<li {...props}>
26+
<Box
27+
component="li"
28+
sx={{ fontSize: 15, '& > span': { mr: '10px', fontSize: 18 } }}
29+
{...props}
30+
>
4231
<span>{countryToFlag(option.code)}</span>
4332
{option.label} ({option.code}) +{option.phone}
44-
</li>
33+
</Box>
4534
)}
4635
renderInput={(params) => (
4736
<TextField

docs/src/pages/components/autocomplete/CustomInputAutocomplete.js

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,27 @@
11
import * as React from 'react';
2-
import clsx from 'clsx';
32
import Autocomplete from '@material-ui/core/Autocomplete';
4-
import { makeStyles } from '@material-ui/core/styles';
5-
6-
const useStyles = makeStyles((theme) => ({
7-
autocomplete: {
8-
display: 'inline-block',
9-
},
10-
input: {
11-
width: 200,
12-
backgroundColor: theme.palette.background.paper,
13-
color: theme.palette.getContrastText(theme.palette.background.paper),
14-
},
15-
}));
163

174
const options = ['Option 1', 'Option 2'];
185

196
export default function CustomInputAutocomplete() {
20-
const classes = useStyles();
217
return (
228
<label>
239
Value:{' '}
2410
<Autocomplete
25-
className={classes.autocomplete}
11+
sx={{
12+
display: 'inline-block',
13+
'& input': {
14+
width: 200,
15+
bgcolor: 'background.paper',
16+
color: (theme) =>
17+
theme.palette.getContrastText(theme.palette.background.paper),
18+
},
19+
}}
2620
id="custom-input-demo"
2721
options={options}
2822
renderInput={(params) => (
2923
<div ref={params.InputProps.ref}>
30-
<input
31-
type="text"
32-
{...params.inputProps}
33-
className={clsx(classes.input, params.inputProps.className)}
34-
/>
24+
<input type="text" {...params.inputProps} />
3525
</div>
3626
)}
3727
/>

docs/src/pages/components/autocomplete/CustomInputAutocomplete.tsx

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,27 @@
11
import * as React from 'react';
2-
import clsx from 'clsx';
32
import Autocomplete from '@material-ui/core/Autocomplete';
4-
import { makeStyles, Theme } from '@material-ui/core/styles';
5-
6-
const useStyles = makeStyles((theme: Theme) => ({
7-
autocomplete: {
8-
display: 'inline-block',
9-
},
10-
input: {
11-
width: 200,
12-
backgroundColor: theme.palette.background.paper,
13-
color: theme.palette.getContrastText(theme.palette.background.paper),
14-
},
15-
}));
163

174
const options = ['Option 1', 'Option 2'];
185

196
export default function CustomInputAutocomplete() {
20-
const classes = useStyles();
217
return (
228
<label>
239
Value:{' '}
2410
<Autocomplete
25-
className={classes.autocomplete}
11+
sx={{
12+
display: 'inline-block',
13+
'& input': {
14+
width: 200,
15+
bgcolor: 'background.paper',
16+
color: (theme) =>
17+
theme.palette.getContrastText(theme.palette.background.paper),
18+
},
19+
}}
2620
id="custom-input-demo"
2721
options={options}
2822
renderInput={(params) => (
2923
<div ref={params.InputProps.ref}>
30-
<input
31-
type="text"
32-
{...params.inputProps}
33-
className={clsx(classes.input, params.inputProps.className)}
34-
/>
24+
<input type="text" {...params.inputProps} />
3525
</div>
3626
)}
3727
/>

0 commit comments

Comments
 (0)