// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Text; using System.Threading.Tasks; using Microsoft.AspNetCore.Components; namespace AntDesign { /// /// Feedback Component /// /// public abstract class FeedbackComponent : TemplateComponentBase, IModalTemplate { private IFeedbackRef _feedbackRef; /// /// The options that allow you to pass in templates from the outside /// [Parameter] public IFeedbackRef FeedbackRef { get => _feedbackRef; set { _feedbackRef = value; _feedbackRef.ModalTemplate ??= this; } } /// /// /// public IOkCancelRef OkCancelRef => FeedbackRef as IOkCancelRef; /// /// In order that the user can close the template through the button /// 为了用户可以在模板内通过按钮主动关闭 /// /// public async Task CloseFeedbackAsync() { await (FeedbackRef?.CloseAsync() ?? Task.CompletedTask); } /// /// 在 OK 按钮触发时回调,可以用来取消关闭 /// /// public virtual Task OkAsync(ModalClosingEventArgs args) { return OnFeedbackOkAsync(args); } /// /// 在 Cancel 按钮触发时回调,可以用来取消关闭 /// /// public virtual Task CancelAsync(ModalClosingEventArgs args) { return OnFeedbackCancelAsync(args); } /// /// 在 OK 按钮触发时回调,可以用来取消关闭 /// /// public virtual Task OnFeedbackOkAsync(ModalClosingEventArgs args) { return Task.CompletedTask; } /// /// 在 Cancel 按钮触发时回调,可以用来取消关闭 /// /// /// public virtual Task OnFeedbackCancelAsync(ModalClosingEventArgs args) { return Task.CompletedTask; } } /// /// Feedback Component /// /// /// public abstract class FeedbackComponent : FeedbackComponent { /// /// /// public IOkCancelRef OkCancelRefWithResult => FeedbackRef as IOkCancelRef; } }