mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-12 11:55:24 +08:00
7ad15664fe
* refactor mentions * 修复:定位和隐藏的问题。 * fix: 修复定位和显示的一些bug * fix:手误 Co-authored-by: 丁某 <dingyanwu518@hotmail.com>
42 lines
1.2 KiB
C#
42 lines
1.2 KiB
C#
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.AspNetCore.Components.Web;
|
|
|
|
namespace AntDesign
|
|
{
|
|
public partial class MentionsOption
|
|
{
|
|
[CascadingParameter] public Mentions Mentions { get; set; }
|
|
[Parameter] public string Value { get; set; }
|
|
[Parameter] public RenderFragment ChildContent { get; set; }
|
|
public bool Active => Mentions?.ActiveOptionValue == Value;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
Mentions?.AddOption(this);
|
|
SetClassMap();
|
|
await base.OnInitializedAsync();
|
|
}
|
|
|
|
private void SetClassMap()
|
|
{
|
|
var prefixCls = "ant-mentions-dropdown-menu-item";
|
|
ClassMapper.Clear().Add(prefixCls).If("ant-mentions-dropdown-menu-item-active", () => Active);
|
|
InvokeStateHasChanged();
|
|
}
|
|
|
|
internal void OnMouseOver()
|
|
{
|
|
Mentions.ActiveOptionValue = Value;
|
|
}
|
|
|
|
internal async Task OnClick(MouseEventArgs args)
|
|
{
|
|
if (args.Button == 0) //left click
|
|
{
|
|
await Mentions.ItemClick(Value);
|
|
}
|
|
}
|
|
}
|
|
}
|