-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Dropdown): make deburr opt-in, and deburr input (#2223)
* feat(Dropdown): make deburr opt-in, and deburr input * feat(Dropdown): remake non-filter test * docs(Dropdown): add custom search function example * style(Dropdown): sort props and imports
- Loading branch information
1 parent
50c29ad
commit 64bf4a1
Showing
6 changed files
with
127 additions
and
11 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
docs/app/Examples/modules/Dropdown/Usage/DropdownExampleCustomSearchFunction.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,25 @@ | ||
import _ from 'lodash' | ||
import React from 'react' | ||
import { Dropdown } from 'semantic-ui-react' | ||
|
||
const caseSensitiveSearch = (options, query) => { | ||
const re = new RegExp(_.escapeRegExp(query)) | ||
return options.filter(opt => re.test(opt.text)) | ||
} | ||
|
||
const options = [ | ||
{ key: 'a', value: 'a', text: 'UPPERCASE' }, | ||
{ key: 'b', value: 'b', text: 'lowercase' }, | ||
] | ||
|
||
const DropdownExampleCustomSearchFunction = () => ( | ||
<Dropdown | ||
fluid | ||
options={options} | ||
placeholder={'Try to search for case or CASE'} | ||
search={caseSensitiveSearch} | ||
selection | ||
/> | ||
) | ||
|
||
export default DropdownExampleCustomSearchFunction |
24 changes: 24 additions & 0 deletions
24
docs/app/Examples/modules/Dropdown/Usage/DropdownExampleDeburrSearch.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,24 @@ | ||
import React from 'react' | ||
import { Dropdown } from 'semantic-ui-react' | ||
|
||
const options = [ | ||
{ key: 'a', value: 'a', text: 'Café with accent' }, | ||
{ key: 'b', value: 'b', text: 'Cafe without accent' }, | ||
{ key: 'c', value: 'c', text: 'Déjà vu' }, | ||
{ key: 'd', value: 'd', text: 'Deja vu' }, | ||
{ key: 'e', value: 'e', text: 'Scandinavian å ä æ ø ö' }, | ||
{ key: 'f', value: 'f', text: 'Scandinavian a a ae o o' }, | ||
] | ||
|
||
const DropdownExampleSearchSelection = () => ( | ||
<Dropdown | ||
deburr | ||
fluid | ||
options={options} | ||
placeholder='Try to search for "Deja vu"' | ||
search | ||
selection | ||
/> | ||
) | ||
|
||
export default DropdownExampleSearchSelection |
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