-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Autocomplete] Improve search box & create options support (#20624)
- Loading branch information
1 parent
74509f2
commit 77f6fe0
Showing
14 changed files
with
147 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
docs/src/pages/components/autocomplete/ControllableStates.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React from 'react'; | ||
import TextField from '@material-ui/core/TextField'; | ||
import Autocomplete from '@material-ui/lab/Autocomplete'; | ||
|
||
const options = ['Option 1', 'Option 2']; | ||
|
||
export default function ControllableStates() { | ||
const [value, setValue] = React.useState(options[0]); | ||
const [inputValue, setInputValue] = React.useState(''); | ||
|
||
return ( | ||
<div> | ||
<div>{`value: ${value}`}</div> | ||
<div>{`inputValue: ${inputValue}`}</div> | ||
<br /> | ||
<Autocomplete | ||
value={value} | ||
onChange={(event, newValue) => { | ||
setValue(newValue); | ||
}} | ||
inputValue={inputValue} | ||
onInputChange={(event, newInputValue) => { | ||
setInputValue(newInputValue); | ||
}} | ||
id="controllable-states-demo" | ||
options={options} | ||
style={{ width: 300 }} | ||
renderInput={(params) => <TextField {...params} label="Controllable" variant="outlined" />} | ||
/> | ||
</div> | ||
); | ||
} |
32 changes: 32 additions & 0 deletions
32
docs/src/pages/components/autocomplete/ControllableStates.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React from 'react'; | ||
import TextField from '@material-ui/core/TextField'; | ||
import Autocomplete from '@material-ui/lab/Autocomplete'; | ||
|
||
const options = ['Option 1', 'Option 2']; | ||
|
||
export default function ControllableStates() { | ||
const [value, setValue] = React.useState<string | null>(options[0]); | ||
const [inputValue, setInputValue] = React.useState(''); | ||
|
||
return ( | ||
<div> | ||
<div>{`value: ${value}`}</div> | ||
<div>{`inputValue: ${inputValue}`}</div> | ||
<br /> | ||
<Autocomplete | ||
value={value} | ||
onChange={(event: any, newValue: string | null) => { | ||
setValue(newValue); | ||
}} | ||
inputValue={inputValue} | ||
onInputChange={(event, newInputValue) => { | ||
setInputValue(newInputValue); | ||
}} | ||
id="controllable-states-demo" | ||
options={options} | ||
style={{ width: 300 }} | ||
renderInput={(params) => <TextField {...params} label="Controllable" variant="outlined" />} | ||
/> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters