Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[@mantine/core] Add controlled search value support to Select and Mul…
…tiSelect components (#2485) * [@mantine/core] MultiSelect: Added controlled/uncontrolled search value * [@mantine/core] Select: Added controlled/uncontrolled search value * [docs] Added examples with controlled search input in Select/MultiSelect * [@mantine/core] Select: fixed handleSearchChange
- Loading branch information
Showing
8 changed files
with
135 additions
and
14 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
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
47 changes: 47 additions & 0 deletions
47
src/mantine-demos/src/demos/core/MultiSelect/MultiSelect.demo.searchableControlled.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,47 @@ | ||
import React, { useState } from 'react'; | ||
import { MultiSelect } from '@mantine/core'; | ||
import { data } from './_data'; | ||
|
||
const code = ` | ||
import { MultiSelect } from '@mantine/core'; | ||
function Demo() { | ||
const [searchValue, onSearchChange] = useState(''); | ||
return ( | ||
<MultiSelect | ||
data={['React', 'Angular', 'Svelte', 'Vue', 'Riot', 'Next.js', 'Blitz.js']} | ||
label="Your favorite frameworks/libraries" | ||
placeholder="Pick all that you like" | ||
searchable | ||
searchValue={searchValue} | ||
onSearchChange={onSearchChange} | ||
nothingFound="Nothing found" | ||
/> | ||
); | ||
} | ||
`; | ||
|
||
function Demo() { | ||
const [searchValue, onSearchChange] = useState(''); | ||
|
||
return ( | ||
<div style={{ maxWidth: 400, marginLeft: 'auto', marginRight: 'auto' }}> | ||
<MultiSelect | ||
data={data} | ||
label="Your favorite frameworks/libraries" | ||
placeholder="Pick all that you like" | ||
searchable | ||
searchValue={searchValue} | ||
onSearchChange={onSearchChange} | ||
nothingFound="Nothing found" | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
export const searchableControlled: MantineDemo = { | ||
type: 'demo', | ||
code, | ||
component: Demo, | ||
}; |
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
46 changes: 46 additions & 0 deletions
46
src/mantine-demos/src/demos/core/Select/Select.demo.searchableControlled.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,46 @@ | ||
import React, { useState } from 'react'; | ||
import { Select } from '@mantine/core'; | ||
|
||
const code = ` | ||
import { Select } from '@mantine/core'; | ||
function Demo() { | ||
const [searchValue, onSearchChange] = useState(''); | ||
return ( | ||
<Select | ||
label="Your favorite framework/library" | ||
placeholder="Pick one" | ||
searchable | ||
onSearchChange={onSearchChange} | ||
searchValue={searchValue} | ||
nothingFound="No options" | ||
data={['React', 'Angular', 'Svelte', 'Vue']} | ||
/> | ||
); | ||
} | ||
`; | ||
|
||
function Demo() { | ||
const [searchValue, onSearchChange] = useState(''); | ||
|
||
return ( | ||
<div style={{ maxWidth: 320, marginLeft: 'auto', marginRight: 'auto' }}> | ||
<Select | ||
label="Your favorite framework/library" | ||
placeholder="Pick one" | ||
searchable | ||
onSearchChange={onSearchChange} | ||
searchValue={searchValue} | ||
nothingFound="No options" | ||
data={['React', 'Angular', 'Svelte', 'Vue']} | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
export const searchableControlled: MantineDemo = { | ||
type: 'demo', | ||
code, | ||
component: Demo, | ||
}; |
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