mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-29 18:48:45 +08:00
feat: 级联选择器支持新版外观配置 (#11018)
Co-authored-by: qinhaoyan <30946345+qinhaoyan@users.noreply.github.com>
This commit is contained in:
parent
f1d75921b7
commit
72ba98ab75
@ -11,6 +11,7 @@ import {ValidatorTag} from '../../validator';
|
||||
import {getEventControlConfig} from '../../renderer/event-control/helper';
|
||||
import {resolveOptionEventDataSchame, resolveOptionType} from '../../util';
|
||||
import type {Schema} from 'amis';
|
||||
import {inputStateTpl} from '../../renderer/style-control/helper';
|
||||
|
||||
export class NestedSelectControlPlugin extends BasePlugin {
|
||||
static id = 'NestedSelectControlPlugin';
|
||||
@ -342,23 +343,36 @@ export class NestedSelectControlPlugin extends BasePlugin {
|
||||
},
|
||||
{
|
||||
title: '外观',
|
||||
body: getSchemaTpl('collapseGroup', [
|
||||
getSchemaTpl('style:formItem', {renderer}),
|
||||
body: [
|
||||
getSchemaTpl('collapseGroup', [
|
||||
getSchemaTpl('theme:formItem'),
|
||||
getSchemaTpl('theme:form-label'),
|
||||
getSchemaTpl('theme:form-description'),
|
||||
{
|
||||
title: '边框',
|
||||
key: 'borderMode',
|
||||
body: [getSchemaTpl('borderMode')]
|
||||
},
|
||||
getSchemaTpl('style:classNames', {
|
||||
schema: [
|
||||
getSchemaTpl('className', {
|
||||
label: '描述',
|
||||
name: 'descriptionClassName',
|
||||
visibleOn: 'this.description'
|
||||
})
|
||||
title: '选择框样式',
|
||||
body: [
|
||||
...inputStateTpl(
|
||||
'themeCss.nestedSelectControlClassName',
|
||||
'--nested-select'
|
||||
)
|
||||
]
|
||||
})
|
||||
},
|
||||
{
|
||||
title: '下拉框样式',
|
||||
body: [
|
||||
...inputStateTpl(
|
||||
'themeCss.nestedSelectPopoverClassName',
|
||||
'--nested-select',
|
||||
{
|
||||
state: ['default', 'hover', 'focused']
|
||||
}
|
||||
)
|
||||
]
|
||||
},
|
||||
getSchemaTpl('theme:cssCode'),
|
||||
getSchemaTpl('style:classNames')
|
||||
])
|
||||
]
|
||||
},
|
||||
{
|
||||
title: '事件',
|
||||
|
@ -30,7 +30,9 @@ import {
|
||||
renderTextByKeyword,
|
||||
getVariable,
|
||||
TestIdBuilder,
|
||||
labelToString
|
||||
labelToString,
|
||||
setThemeClassName,
|
||||
CustomStyle
|
||||
} from 'amis-core';
|
||||
import {findDOMNode} from 'react-dom';
|
||||
import xor from 'lodash/xor';
|
||||
@ -903,7 +905,9 @@ export default class NestedSelectControl extends React.Component<
|
||||
translate: __,
|
||||
classnames: cx,
|
||||
options,
|
||||
render
|
||||
render,
|
||||
id,
|
||||
themeCss
|
||||
} = this.props;
|
||||
const isSearch = !!this.state.inputValue;
|
||||
let noResultsText: any = this.props.noResultsText;
|
||||
@ -939,7 +943,19 @@ export default class NestedSelectControl extends React.Component<
|
||||
placement={'auto'}
|
||||
show
|
||||
>
|
||||
<PopOver className={cx('NestedSelect-popover')}>{body}</PopOver>
|
||||
<PopOver
|
||||
className={cx(
|
||||
'NestedSelect-popover',
|
||||
setThemeClassName({
|
||||
...this.props,
|
||||
name: 'nestedSelectPopoverClassName',
|
||||
id,
|
||||
themeCss: themeCss
|
||||
})
|
||||
)}
|
||||
>
|
||||
{body}
|
||||
</PopOver>
|
||||
</Overlay>
|
||||
);
|
||||
}
|
||||
@ -969,10 +985,13 @@ export default class NestedSelectControl extends React.Component<
|
||||
overflowTagPopover
|
||||
} = this.props;
|
||||
|
||||
const {classPrefix: ns, themeCss, id} = this.props;
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cx('NestedSelectControl', className)}
|
||||
ref={this.outTarget}
|
||||
style={style}
|
||||
>
|
||||
<ResultBox
|
||||
mobileUI={mobileUI}
|
||||
@ -982,7 +1001,9 @@ export default class NestedSelectControl extends React.Component<
|
||||
ref={this.domRef}
|
||||
placeholder={__(placeholder ?? 'placeholder.empty')}
|
||||
inputPlaceholder={''}
|
||||
className={cx(`NestedSelect`, {
|
||||
className={cx(
|
||||
`NestedSelect`,
|
||||
{
|
||||
'NestedSelect--inline': inline,
|
||||
'NestedSelect--single': !multiple,
|
||||
'NestedSelect--multi': multiple,
|
||||
@ -990,7 +1011,14 @@ export default class NestedSelectControl extends React.Component<
|
||||
'is-opened': this.state.isOpened,
|
||||
'is-focused': this.state.isFocused,
|
||||
[`NestedSelect--border${ucFirst(borderMode)}`]: borderMode
|
||||
})}
|
||||
},
|
||||
setThemeClassName({
|
||||
...this.props,
|
||||
name: 'nestedSelectControlClassName',
|
||||
id,
|
||||
themeCss: themeCss
|
||||
})
|
||||
)}
|
||||
result={
|
||||
multiple
|
||||
? selectedOptions
|
||||
@ -1037,6 +1065,45 @@ export default class NestedSelectControl extends React.Component<
|
||||
) : this.state.isOpened ? (
|
||||
this.renderOuter()
|
||||
) : null}
|
||||
|
||||
<CustomStyle
|
||||
{...this.props}
|
||||
config={{
|
||||
themeCss: themeCss,
|
||||
classNames: [
|
||||
{
|
||||
key: 'nestedSelectControlClassName',
|
||||
weights: {
|
||||
hover: {
|
||||
suf: '.is-clickable:not(.is-disabled)'
|
||||
},
|
||||
focused: {
|
||||
suf: '.is-opened:not(.is-mobile)'
|
||||
},
|
||||
disabled: {
|
||||
suf: '.is-disabled'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'nestedSelectPopoverClassName',
|
||||
weights: {
|
||||
default: {
|
||||
suf: ` .${ns}NestedSelect-option`
|
||||
},
|
||||
hover: {
|
||||
suf: ` .${ns}NestedSelect-option.is-highlight`
|
||||
},
|
||||
focused: {
|
||||
inner: `.${ns}NestedSelect-option.is-active`
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
id: id
|
||||
}}
|
||||
env={env}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user