mirror of
https://github.com/smartxworks/sunmao-ui.git
synced 2024-11-27 08:39:59 +08:00
feat(Select): add title to select option
This commit is contained in:
parent
6304215a8b
commit
55dd952d0e
@ -32,6 +32,7 @@ export const Select = implementRuntimeComponent({
|
||||
loading: false,
|
||||
showSearch: false,
|
||||
unmountOnExit: false,
|
||||
showTitle: false,
|
||||
options: [
|
||||
{ value: 'Beijing', text: 'Beijing' },
|
||||
{ value: 'London', text: 'London' },
|
||||
@ -69,6 +70,7 @@ export const Select = implementRuntimeComponent({
|
||||
options = [],
|
||||
retainInputValue,
|
||||
updateWhenDefaultValueChanges,
|
||||
showTitle,
|
||||
...cProps
|
||||
} = getComponentProps(props);
|
||||
const [value, setValue] = useStateValue(
|
||||
@ -130,7 +132,12 @@ export const Select = implementRuntimeComponent({
|
||||
}}
|
||||
>
|
||||
{options.map(o => (
|
||||
<BaseSelect.Option key={o.value} value={o.value} disabled={o.disabled}>
|
||||
<BaseSelect.Option
|
||||
key={o.value}
|
||||
value={o.value}
|
||||
disabled={o.disabled}
|
||||
{...(showTitle && { title: o.text || o.value })}
|
||||
>
|
||||
{o.text || o.value}
|
||||
</BaseSelect.Option>
|
||||
))}
|
||||
|
@ -94,6 +94,11 @@ export const SelectPropsSpec = {
|
||||
category: Category.Behavior,
|
||||
description: 'Whether to allow new options to be created by input',
|
||||
}),
|
||||
showTitle: Type.Boolean({
|
||||
title: 'Show Option Title',
|
||||
description:
|
||||
'Whether to show the title on hover when the select option exceeds the width',
|
||||
}),
|
||||
error: Type.Boolean({
|
||||
title: 'Error',
|
||||
category: Category.Behavior,
|
||||
|
Loading…
Reference in New Issue
Block a user