Skip to content

Commit b190480

Browse files
authored
feat: add option className/title type and feature (#1020)
* ✨ feat(options): add className title type * ✨ feat(group options): add custom className
1 parent c93ff10 commit b190480

File tree

5 files changed

+10
-3
lines changed

5 files changed

+10
-3
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ tsconfig.test.json
4040
.umi
4141
.dumi/tmp
4242
.dumi/tmp-test
43-
.dumi/tmp-production
43+
.dumi/tmp-production
44+
.history

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ export default () => (
157157
| label | group label | String/React.Element | - |
158158
| key | - | String | - |
159159
| value | default filter by this attribute. if react want you to set key, then key is same as value, you can omit value | String | - |
160+
| className | same as `Option props` | String | '' |
161+
| title | same as `Option props`| String | - |
160162

161163
## Development
162164

docs/examples/optgroup.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ const Test = () => (
1818
onChange={onChange}
1919
options={[{
2020
label: 'manager',
21+
className: 'group-custom-className',
22+
title:'group-custom-class',
2123
options: [
22-
{ label: 'jack', value: 'jack' },
24+
{ label: 'jack', value: 'jack', className:'jackClass1 jackClass2' , title:'jack-custom-Title' },
2325
{ label: 'lucy', value: 'lucy' }
2426
],
2527
}, {

src/OptionList.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ const OptionList: React.ForwardRefRenderFunction<RefOptionListProps, {}> = (_, r
319319

320320
return (
321321
<div
322-
className={classNames(itemPrefixCls, `${itemPrefixCls}-group`)}
322+
className={classNames(itemPrefixCls, `${itemPrefixCls}-group`, data.className)}
323323
title={groupTitle}
324324
>
325325
{label !== undefined ? label : key}

src/Select.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ export interface FieldNames {
9191

9292
export interface BaseOptionType {
9393
disabled?: boolean;
94+
className?: string;
95+
title?: string;
9496
[name: string]: any;
9597
}
9698

0 commit comments

Comments
 (0)