using System; using System.Collections.Generic; using System.Text; using System.Threading.Tasks; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Web; using OneOf; namespace AntDesign { /// /// the options of Modal dialog box /// public class ModalOptions : DialogOptionsBase { public ModalOptions() { _onCancel = DefaultOnCancelOrOk; _onOk = DefaultOnCancelOrOk; Width = 520; MaskClosable = true; } internal ModalRef ModalRef; /// /// trigger after Dialog is closed /// public Func AfterClose { get; set; } = () => Task.CompletedTask; /// /// ant-modal-body style /// public string BodyStyle { get; set; } /// /// show ant-modal-closer /// public bool Closable { get; set; } = true; /// /// Draggable modal /// public bool Draggable { get; set; } /// /// Drag and drop only within the Viewport /// public bool DragInViewport { get; set; } = true; /// /// closer icon RenderFragment, the default is a "X" /// public RenderFragment CloseIcon { get; set; } = DialogOptions.DefaultCloseIcon; /// /// Whether to apply loading visual effect for OK button or not /// public bool ConfirmLoading { get; set; } /// /// Whether to remove Modal from DOM after the Modal closed /// public bool DestroyOnClose { get; set; } /// /// Modal footer. If Footer==null, the dialog will not have a footer /// public OneOf? Footer { get; set; } = DialogOptions.DefaultFooter; /// /// /// public bool Visible { get; set; } = true; /// /// The class name of the container of the modal dialog /// public string WrapClassName { get; set; } private Func _onCancel; /// /// Specify a function that will be called when a user clicks mask, close button on top right or Cancel button. /// public Func OnCancel { get => _onCancel; set => _onCancel = value; } private Func _onOk; /// /// Specify a function that will be called when a user clicks the OK button /// public Func OnOk { get => _onOk; set => _onOk = value; } /// /// ChildContent /// public RenderFragment Content { get; set; } = null; #region internal internal async Task DefaultOnCancelOrOk(MouseEventArgs e) { await (ModalRef?.CloseAsync() ?? Task.CompletedTask); } #endregion } }