-
-
Notifications
You must be signed in to change notification settings - Fork 466
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
Open
EmilyyyLiu
wants to merge
13
commits into
react-component:master
Choose a base branch
from
EmilyyyLiu:combine-showSearch
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 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
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,48 @@ | ||
import type { SearchConfig, DefaultOptionType } from '@/Select'; | ||
import * as React from 'react'; | ||
const legacySearchProps = [ | ||
'filterOption', | ||
'searchValue', | ||
'optionFilterProp', | ||
'filterSort', | ||
'onSearch', | ||
'autoClearSearchValue', | ||
]; | ||
// Convert `showSearch` to unique config | ||
export default function useSearchConfig( | ||
showSearch: boolean | SearchConfig<DefaultOptionType> | undefined, | ||
props: any, | ||
) { | ||
const { | ||
filterOption, | ||
searchValue, | ||
optionFilterProp, | ||
filterSort, | ||
onSearch, | ||
autoClearSearchValue, | ||
} = props || {}; | ||
return React.useMemo<[boolean | undefined, SearchConfig<DefaultOptionType>]>(() => { | ||
const legacyShowSearch: SearchConfig<DefaultOptionType> = {}; | ||
legacySearchProps.forEach((name) => { | ||
const val = props?.[name]; | ||
if (val !== undefined) legacyShowSearch[name] = val; | ||
}); | ||
const searchConfig: SearchConfig<DefaultOptionType> = | ||
typeof showSearch === 'object' ? showSearch : legacyShowSearch; | ||
if (showSearch === undefined) { | ||
return [undefined, searchConfig]; | ||
} | ||
if (!showSearch) { | ||
return [false, {}]; | ||
} | ||
return [true, searchConfig]; | ||
}, [ | ||
showSearch, | ||
filterOption, | ||
searchValue, | ||
optionFilterProp, | ||
filterSort, | ||
onSearch, | ||
autoClearSearchValue, | ||
]); | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
缺失
tokenSeparators
属性文档在
showSearch
小节中未列出tokenSeparators
配置,建议同其他搜索相关属性一并文档化,以保持文档与实现一致。示例 diff:
### showSearch | name | description | type | default | | --- | --- | --- | --- | +| tokenSeparators | 多选模式下用于分隔输入值并生成 tag 的分隔符数组 | string[] | - | | autoClearSearchValue | auto-clear 搜索框中输入值,当多选模式下选中/取消选中会清空 | boolean | true | | filterOption | 是否根据输入值过滤选项;默认按 `optionFilterProp` 指定的属性过滤 | boolean \| (inputValue: string, option: Option) => boolean | true | ...
🧰 Tools
🪛 LanguageTool
[uncategorized] ~143-~143: It appears that a hyphen is missing (if ‘auto’ is not used in the context of ‘cars’).
Context: ... | --- | --- | | autoClearSearchValue | auto clear search input value when multiple select...
(AUTO_HYPHEN)
🤖 Prompt for AI Agents