Skip to content

Commit

Permalink
feat: add option className/title type and feature (react-component#1020)
Browse files Browse the repository at this point in the history
* ✨ feat(options):  add className title type

* ✨ feat(group options): add custom className
  • Loading branch information
lqzhgood authored Jan 13, 2024
1 parent c93ff10 commit b190480
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ tsconfig.test.json
.umi
.dumi/tmp
.dumi/tmp-test
.dumi/tmp-production
.dumi/tmp-production
.history
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ export default () => (
| label | group label | String/React.Element | - |
| key | - | String | - |
| value | default filter by this attribute. if react want you to set key, then key is same as value, you can omit value | String | - |
| className | same as `Option props` | String | '' |
| title | same as `Option props`| String | - |

## Development

Expand Down
4 changes: 3 additions & 1 deletion docs/examples/optgroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ const Test = () => (
onChange={onChange}
options={[{
label: 'manager',
className: 'group-custom-className',
title:'group-custom-class',
options: [
{ label: 'jack', value: 'jack' },
{ label: 'jack', value: 'jack', className:'jackClass1 jackClass2' , title:'jack-custom-Title' },
{ label: 'lucy', value: 'lucy' }
],
}, {
Expand Down
2 changes: 1 addition & 1 deletion src/OptionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ const OptionList: React.ForwardRefRenderFunction<RefOptionListProps, {}> = (_, r

return (
<div
className={classNames(itemPrefixCls, `${itemPrefixCls}-group`)}
className={classNames(itemPrefixCls, `${itemPrefixCls}-group`, data.className)}
title={groupTitle}
>
{label !== undefined ? label : key}
Expand Down
2 changes: 2 additions & 0 deletions src/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ export interface FieldNames {

export interface BaseOptionType {
disabled?: boolean;
className?: string;
title?: string;
[name: string]: any;
}

Expand Down

0 comments on commit b190480

Please sign in to comment.