mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-16 01:41:14 +08:00
ef22dd5a1b
* feat: add mentions component * fix: update with z-index * feat: new mention components (unfinished) * fix: show chinese letter for affix and tree * refactor: clean code * fix: the display position of the dropdown is consistent with the cursor * fix: mistakes Co-authored-by: ElderJames <shunjiey@hotmail.com> Co-authored-by: zxyao <zxyao145@gmail.com>
64 lines
1.5 KiB
C#
64 lines
1.5 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 bool Disable { get; set; }
|
|
|
|
[Parameter] public RenderFragment ChildContent { get; set; }
|
|
|
|
public bool Selected { get; set; }
|
|
|
|
public bool Active { get; set; }
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
Mentions?.AddOption(this);
|
|
|
|
SetClassMap();
|
|
|
|
base.OnInitialized();
|
|
}
|
|
|
|
private void SetClassMap()
|
|
{
|
|
var prefixCls = "ant-mentions-dropdown-menu-item";
|
|
this.ClassMapper.Clear()
|
|
.Add(prefixCls)
|
|
.If($"{prefixCls}-disable", () => this.Disable)
|
|
.If($"{prefixCls}-selected", () => this.Selected)
|
|
.If($"{prefixCls}-active", () => this.Active)
|
|
;
|
|
|
|
InvokeStateHasChanged();
|
|
}
|
|
|
|
internal void OnMouseEnter()
|
|
{
|
|
this.Selected = true;
|
|
}
|
|
|
|
internal void OnMouseLeave()
|
|
{
|
|
this.Selected = false;
|
|
}
|
|
|
|
internal async Task OnClick(MouseEventArgs args)
|
|
{
|
|
if (args.Button == 0) //left click
|
|
{
|
|
await Mentions.OnOptionClick(this);
|
|
}
|
|
|
|
InvokeStateHasChanged();
|
|
}
|
|
}
|
|
}
|