mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-14 08:51:27 +08:00
f09e71ba06
* feat: auto complete refactor * feat: autocomplete Refactor * feat: autocomplete property * feat: autocomplate * feat: autocomplete * feat: autocomplete Co-authored-by: James Yeung <shunjiey@hotmail.com>
64 lines
1.5 KiB
C#
64 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.AspNetCore.Components.Web;
|
|
|
|
namespace AntDesign
|
|
{
|
|
public class AutoCompleteSearch : Search, IAutoCompleteInput
|
|
{
|
|
|
|
[CascadingParameter]
|
|
public IAutoCompleteRef AutoComplete { get; set; }
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
base.OnInitialized();
|
|
|
|
if (AutoComplete != null) AutoComplete?.SetInputComponent(this);
|
|
}
|
|
|
|
internal override async Task OnFocusAsync(FocusEventArgs e)
|
|
{
|
|
if (AutoComplete != null) await AutoComplete?.InputFocus(e);
|
|
|
|
await base.OnFocusAsync(e);
|
|
|
|
}
|
|
|
|
internal override async Task OnBlurAsync(FocusEventArgs e)
|
|
{
|
|
if (AutoComplete != null) await AutoComplete?.InputBlur(e);
|
|
|
|
await base.OnBlurAsync(e);
|
|
}
|
|
|
|
protected override async Task OnkeyDownAsync(KeyboardEventArgs args)
|
|
{
|
|
await base.OnkeyDownAsync(args);
|
|
|
|
if (AutoComplete != null) await AutoComplete?.InputKeyDown(args);
|
|
}
|
|
|
|
|
|
protected override async void OnInputAsync(ChangeEventArgs args)
|
|
{
|
|
base.OnInputAsync(args);
|
|
|
|
if (AutoComplete != null) await AutoComplete?.InputInput(args);
|
|
}
|
|
|
|
|
|
#region IAutoCompleteInput
|
|
|
|
public void SetValue(object value)
|
|
{
|
|
this.CurrentValue = value?.ToString();
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|