Skip to content

Commit

Permalink
feat: select tree模式支持menuTpl (baidu#9790)
Browse files Browse the repository at this point in the history
* feat: select tree模式支持menuTpl

* 更新快照

---------

Co-authored-by: qinhaoyan <30946345+qinhaoyan@users.noreply.github.com>
  • Loading branch information
qkiroc and qkiroc committed Mar 13, 2024
1 parent 96ef387 commit 42ffae4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1001,12 +1001,7 @@ exports[`Renderer:select chained mode with virtual 1`] = `
<div
class="cxd-ChainedSelection-itemLabel"
>
<span
class=" cxd-Selection-ellipsis-line"
title="group-1 "
>
group-1
</span>
group-1
</div>
</div>
<div
Expand All @@ -1016,12 +1011,7 @@ exports[`Renderer:select chained mode with virtual 1`] = `
<div
class="cxd-ChainedSelection-itemLabel"
>
<span
class=" cxd-Selection-ellipsis-line"
title="group-2 "
>
group-2
</span>
group-2
</div>
</div>
<div
Expand All @@ -1031,12 +1021,7 @@ exports[`Renderer:select chained mode with virtual 1`] = `
<div
class="cxd-ChainedSelection-itemLabel"
>
<span
class=" cxd-Selection-ellipsis-line"
title="group-3 "
>
group-3
</span>
group-3
</div>
</div>
<div
Expand All @@ -1046,12 +1031,7 @@ exports[`Renderer:select chained mode with virtual 1`] = `
<div
class="cxd-ChainedSelection-itemLabel"
>
<span
class=" cxd-Selection-ellipsis-line"
title="group-4 "
>
group-4
</span>
group-4
</div>
</div>
</div>
Expand Down Expand Up @@ -1116,12 +1096,7 @@ exports[`Renderer:select chained mode with virtual 1`] = `
<div
class="cxd-ChainedSelection-itemLabel"
>
<span
class=" cxd-Selection-ellipsis-line"
title="group-1-option-1 "
>
group-1-option-1
</span>
group-1-option-1
</div>
</div>
<div
Expand All @@ -1131,12 +1106,7 @@ exports[`Renderer:select chained mode with virtual 1`] = `
<div
class="cxd-ChainedSelection-itemLabel"
>
<span
class=" cxd-Selection-ellipsis-line"
title="group-1-option-2 "
>
group-1-option-2
</span>
group-1-option-2
</div>
</div>
<div
Expand All @@ -1146,12 +1116,7 @@ exports[`Renderer:select chained mode with virtual 1`] = `
<div
class="cxd-ChainedSelection-itemLabel"
>
<span
class=" cxd-Selection-ellipsis-line"
title="group-1-option-3 "
>
group-1-option-3
</span>
group-1-option-3
</div>
</div>
<div
Expand All @@ -1161,12 +1126,7 @@ exports[`Renderer:select chained mode with virtual 1`] = `
<div
class="cxd-ChainedSelection-itemLabel"
>
<span
class=" cxd-Selection-ellipsis-line"
title="group-1-option-4 "
>
group-1-option-4
</span>
group-1-option-4
</div>
</div>
</div>
Expand Down Expand Up @@ -1544,12 +1504,7 @@ exports[`Renderer:select group mode with virtual 1`] = `
<div
class="cxd-GroupedSelection-itemLabel"
>
<span
class=" cxd-Selection-ellipsis-line"
title="group-1 "
>
group-1
</span>
group-1
</div>
</div>
<div
Expand All @@ -1565,12 +1520,7 @@ exports[`Renderer:select group mode with virtual 1`] = `
<div
class="cxd-GroupedSelection-itemLabel"
>
<span
class=" cxd-Selection-ellipsis-line"
title="option-1 "
>
option-1
</span>
option-1
</div>
</div>
</div>
Expand All @@ -1588,12 +1538,7 @@ exports[`Renderer:select group mode with virtual 1`] = `
<div
class="cxd-GroupedSelection-itemLabel"
>
<span
class=" cxd-Selection-ellipsis-line"
title="option-2 "
>
option-2
</span>
option-2
</div>
</div>
</div>
Expand All @@ -1611,12 +1556,7 @@ exports[`Renderer:select group mode with virtual 1`] = `
<div
class="cxd-GroupedSelection-itemLabel"
>
<span
class=" cxd-Selection-ellipsis-line"
title="option-3 "
>
option-3
</span>
option-3
</div>
</div>
</div>
Expand Down
10 changes: 8 additions & 2 deletions packages/amis/src/renderers/Form/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,13 @@ export interface TransferDropDownProps
class TransferDropdownRenderer extends BaseTransferRenderer<TransferDropDownProps> {
@autobind
renderItem(item: Option): any {
const {labelField} = this.props;
return `${item.scopeLabel || ''}${item[labelField || 'label']}`;
const {labelField, menuTpl, data, render} = this.props;

return menuTpl
? render(`option/${item.value}`, menuTpl, {
data: createObject(data, item)
})
: `${item.scopeLabel || ''}${item[labelField || 'label']}`;
}

render() {
Expand Down Expand Up @@ -619,6 +624,7 @@ class TransferDropdownRenderer extends BaseTransferRenderer<TransferDropDownProp
options={options}
onChange={this.handleChange}
option2value={this.option2value}
optionItemRender={this.renderItem}
itemRender={this.renderItem}
sortable={sortable}
searchResultMode={searchResultMode}
Expand Down

0 comments on commit 42ffae4

Please sign in to comment.