using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Web; using OneOf; using System.Threading.Tasks; namespace AntDesign { public partial class Search : Input { [Parameter] public bool Loading { get; set; } [Parameter] public EventCallback OnSearch { get; set; } [Parameter] public OneOf EnterButton { get; set; } = false; protected override bool IgnoreOnChangeAndBlur => OnSearch.HasDelegate; protected override bool EnableOnPressEnter => OnSearch.HasDelegate || OnPressEnter.HasDelegate; protected override void OnInitialized() { base.OnInitialized(); if (EnterButton.IsT0 && !EnterButton.AsT0) { Suffix = builder => { builder.OpenComponent(1); builder.AddAttribute(2, "Class", $"{PrefixCls}-search-icon"); if (Loading) { builder.AddAttribute(3, "Type", "loading"); } else { builder.AddAttribute(4, "Type", "search"); } builder.AddAttribute(5, "OnClick", CallbackFactory.Create(this, HandleSearch)); builder.CloseComponent(); }; } else { AddOnAfter = builder => { builder.OpenComponent