-
-
Notifications
You must be signed in to change notification settings - Fork 457
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
feat: Implement optionRender
API
#987
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
optionRender
API
Codecov Report
@@ Coverage Diff @@
## master #987 +/- ##
=======================================
Coverage 99.78% 99.78%
=======================================
Files 38 38
Lines 1373 1376 +3
Branches 400 403 +3
=======================================
+ Hits 1370 1373 +3
Misses 3 3
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@RedJue is attempting to deploy a commit to the React Component Team on Vercel. A member of the Team first needs to authorize it. |
5c30e98
to
c8b5a35
Compare
c8b5a35
to
6b9292b
Compare
src/OptionList.tsx
Outdated
<div className={`${optionPrefixCls}-content`}>{content}</div> | ||
<div className={`${optionPrefixCls}-content`}> | ||
{typeof optionRender === 'function' | ||
? optionRender({ |
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.
和 SubItem 的 API 对齐吧:
type OptionRender = (oriOption, info: { index }) => ReactNode;
早期,给的东西不用太多。index 就够了~
ref https://github.com/ant-design/ant-design/wiki/API-Naming-rules#props
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.
ok 我改下
@@ -4,6 +4,7 @@ | |||
|
|||
React Select | |||
|
|||
<!-- prettier-ignore --> |
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.
可以直接在 prettier ignore 文件中加上过滤
@@ -67,6 +68,7 @@ export default () => ( | |||
|
|||
### Select props | |||
|
|||
<!-- prettier-ignore --> |
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.
这个格式化,可以在 prettierrc 里加
overrides: [
{
files: '*.md',
options: {
proseWrap: 'never'
}
}
]
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.
改是直接加方便点,这样就是全局配了,应该也可以
src/OptionList.tsx
Outdated
<div className={`${optionPrefixCls}-content`}>{content}</div> | ||
<div className={`${optionPrefixCls}-content`}> | ||
{typeof optionRender === 'function' | ||
? optionRender({ ...item.data, label: item.label }, { index: itemIndex }) |
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.
😼 我给 param 起名叫 oriOption 就是意思不要去改这个 label 的意思哈。option 拿到什么就返回什么。
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.
👌🏻
src/Select.tsx
Outdated
@@ -138,6 +140,7 @@ export interface SelectProps<ValueType = any, OptionType extends BaseOptionType | |||
optionLabelProp?: string; | |||
children?: React.ReactNode; | |||
options?: OptionType[]; | |||
optionRender?: (oriOption: OriOptionType, info: { index: number }) => React.ReactNode; |
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.
这么写 option 的泛型没了
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.
1
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.
1
614cc31
to
c07e7fd
Compare
close #45445