using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Web; using OneOf; using System; 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; private int _sequence = 0; protected override void OnInitialized() { base.OnInitialized(); if (EnterButton.IsT0 && !EnterButton.AsT0) { Suffix = builder => { var i = 0; builder.OpenComponent(i++); builder.AddAttribute(i++, "Class", $"{PrefixCls}-search-icon"); if (Loading) { builder.AddAttribute(i++, "Type", "loading"); } else { builder.AddAttribute(i++, "Type", "search"); } builder.AddAttribute(i++, "OnClick", CallbackFactory.Create(this, HandleSearch)); builder.CloseComponent(); }; } else { AddOnAfter = builder => { builder.OpenComponent