mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-16 01:41:14 +08:00
ef4701b6ed
* refactor(module: modal): refactor the code of Modal, Confirm and Dialog refactor details: - Add DialogWrapper compontent to control the logic of dialog removal from DOM - Add the appropriate folders for Dialog, Modal, and Confirm - Remove methods with the same logic but different names in ConfirmService - Split Title into Title (string) and Titletemplate (renderfragment) - Add comments to code - Rename ConfirmDialog to Confirm - Specification of method name in ConfirmService - Adjust the time of throttle function for draggabe modal - Extract the common part of ModalOptions, ConfirmOptions and DialogOptions as DialogOptionsBase * refactor: move DefaultCloseIcon etc. static members to DialogOptionsBase * docs(module: modal): update docs * fix: dialog incorrect waiting * fix: pickup missing pr/7
110 lines
3.1 KiB
C#
110 lines
3.1 KiB
C#
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
|
|
{
|
|
/// <summary>
|
|
/// the options of Modal dialog box
|
|
/// </summary>
|
|
public class ModalOptions : DialogOptionsBase
|
|
{
|
|
public ModalOptions()
|
|
{
|
|
_onCancel = DefaultOnCancelOrOk;
|
|
_onOk = DefaultOnCancelOrOk;
|
|
Width = 520;
|
|
MaskClosable = true;
|
|
}
|
|
|
|
internal ModalRef ModalRef;
|
|
|
|
/// <summary>
|
|
/// trigger after Dialog is closed
|
|
/// </summary>
|
|
public Func<Task> AfterClose { get; set; } = () => Task.CompletedTask;
|
|
|
|
/// <summary>
|
|
/// ant-modal-body style
|
|
/// </summary>
|
|
public string BodyStyle { get; set; }
|
|
|
|
/// <summary>
|
|
/// show ant-modal-closer
|
|
/// </summary>
|
|
public bool Closable { get; set; } = true;
|
|
|
|
/// <summary>
|
|
/// Draggable modal
|
|
/// </summary>
|
|
public bool Draggable { get; set; }
|
|
|
|
/// <summary>
|
|
/// Drag and drop only within the Viewport
|
|
/// </summary>
|
|
public bool DragInViewport { get; set; } = true;
|
|
|
|
/// <summary>
|
|
/// closer icon RenderFragment, the default is a "X"
|
|
/// </summary>
|
|
public RenderFragment CloseIcon { get; set; } = DialogOptions.DefaultCloseIcon;
|
|
|
|
/// <summary>
|
|
/// Whether to apply loading visual effect for OK button or not
|
|
/// </summary>
|
|
public bool ConfirmLoading { get; set; }
|
|
|
|
/// <summary>
|
|
/// Whether to remove Modal from DOM after the Modal closed
|
|
/// </summary>
|
|
public bool DestroyOnClose { get; set; }
|
|
|
|
/// <summary>
|
|
/// Modal footer. If Footer==null, the dialog will not have a footer
|
|
/// </summary>
|
|
public OneOf<string, RenderFragment>? Footer { get; set; } = DialogOptions.DefaultFooter;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public bool Visible { get; set; } = true;
|
|
|
|
/// <summary>
|
|
/// The class name of the container of the modal dialog
|
|
/// </summary>
|
|
public string WrapClassName { get; set; }
|
|
|
|
private Func<MouseEventArgs, Task> _onCancel;
|
|
|
|
/// <summary>
|
|
/// Specify a function that will be called when a user clicks mask, close button on top right or Cancel button.
|
|
/// </summary>
|
|
public Func<MouseEventArgs, Task> OnCancel { get => _onCancel; set => _onCancel = value; }
|
|
|
|
private Func<MouseEventArgs, Task> _onOk;
|
|
|
|
/// <summary>
|
|
/// Specify a function that will be called when a user clicks the OK button
|
|
/// </summary>
|
|
public Func<MouseEventArgs, Task> OnOk { get => _onOk; set => _onOk = value; }
|
|
|
|
/// <summary>
|
|
/// ChildContent
|
|
/// </summary>
|
|
public RenderFragment Content { get; set; } = null;
|
|
|
|
#region internal
|
|
|
|
internal async Task DefaultOnCancelOrOk(MouseEventArgs e)
|
|
{
|
|
await (ModalRef?.CloseAsync() ?? Task.CompletedTask);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|