-
-
Notifications
You must be signed in to change notification settings - Fork 478
feat: combine search props #1152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
zombieJ
merged 22 commits into
react-component:master
from
EmilyyyLiu:combine-showSearch
Jun 23, 2025
Merged
Changes from 8 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
ea47855
feat: combine searchProps =>showSearch
40c8d66
feat: change ts name
ec0b918
feat: set autoClearSearchValue default value
f52d3a5
feat: set autoClearSearchValue default value
b601c63
feat: use hooks => useSearchConfig
f8edb48
feat: Delete useless cod(SearchConfig)
656e611
docs: add showSearch discreption
a76b137
test: add test to “combine showSearch”
ec8ee9a
test: fix lint error
07c4c5a
feat: change useSearchConfig
ba17f53
fix: Remove optionLabelProp from showSearch
cc00ba6
fix: Remove tokenSeparators from showSearch
81f5c8b
fix: change ts
8331c62
fix: SearchConfig.***-> showSearch.***
5b683b8
feat: change useSearchConfig
2222c64
feat: fix ci
b58c676
Update src/Select.tsx
EmilyyyLiu d6626df
Update src/Select.tsx
EmilyyyLiu 1ae5527
feat: change useSearchConfig1
360bfd5
feat: change useSearchConfig2
960f65a
test: test showsearch and mode
66476c8
test: test showsearch and mode
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,40 @@ | ||
import type { SearchConfig, DefaultOptionType } from '@/Select'; | ||
import * as React from 'react'; | ||
const legacySearchProps = [ | ||
|
||
'filterOption', | ||
'searchValue', | ||
'optionFilterProp', | ||
'optionLabelProp', | ||
'filterSort', | ||
'onSearch', | ||
'autoClearSearchValue', | ||
'tokenSeparators', | ||
]; | ||
// Convert `showSearch` to unique config | ||
export default function useSearchConfig(showSearch, props) { | ||
return React.useMemo<[boolean, SearchConfig<DefaultOptionType>]>(() => { | ||
const legacyShowSearch: SearchConfig<DefaultOptionType> = {}; | ||
legacySearchProps.forEach((propsName) => { | ||
legacyShowSearch[propsName] = props?.[propsName]; | ||
}); | ||
const searchConfig: SearchConfig<DefaultOptionType> = | ||
typeof showSearch === 'object' ? showSearch : legacyShowSearch; | ||
EmilyyyLiu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
if (showSearch === undefined) { | ||
return [undefined, searchConfig]; | ||
} | ||
if (!showSearch) { | ||
return [false, {}]; | ||
} | ||
return [true, searchConfig]; | ||
}, [ | ||
showSearch, | ||
props?.filterOption, | ||
props?.searchValue, | ||
props?.optionFilterProp, | ||
props?.optionLabelProp, | ||
props?.filterSort, | ||
props?.onSearch, | ||
props?.autoClearSearchValue, | ||
props?.tokenSeparators, | ||
]); | ||
} | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.