// 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); } /// /// Call back when OK button is triggered, which can be used to cancel closing /// 在 OK 按钮触发时回调,可以用来取消关闭 /// /// [Obsolete("Please replace it with OnFeedbackOkAsync")] public virtual Task OkAsync(ModalClosingEventArgs args) { return OnFeedbackOkAsync(args); } /// /// Call back when Cancel button is triggered, which can be used to cancel closing /// 在 Cancel 按钮触发时回调,可以用来取消关闭 /// /// [Obsolete("Please replace it with OnFeedbackCancelAsync")] public virtual Task CancelAsync(ModalClosingEventArgs args) { return OnFeedbackCancelAsync(args); } /// /// Call back when OK button is triggered, which can be used to cancel closing /// 在 OK 按钮触发时回调,可以用来取消关闭 /// /// public virtual Task OnFeedbackOkAsync(ModalClosingEventArgs args) { return Task.CompletedTask; } /// /// Call back when Cancel button is triggered, which can be used to cancel closing /// 在 Cancel 按钮触发时回调,可以用来取消关闭 /// /// /// public virtual Task OnFeedbackCancelAsync(ModalClosingEventArgs args) { return Task.CompletedTask; } } /// /// Feedback Component /// /// /// public abstract class FeedbackComponent : FeedbackComponent { private IOkCancelRef _okCancelRefWithResult; /// /// /// public IOkCancelRef OkCancelRefWithResult => _okCancelRefWithResult ??= FeedbackRef as IOkCancelRef; } }