2020-10-14 15:09:11 +08:00
|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
internal ModalRef ModalRef;
|
|
|
|
|
|
|
|
|
|
internal static readonly RenderFragment DefaultCloseIcon = (builder) =>
|
|
|
|
|
{
|
|
|
|
|
builder.OpenComponent<Icon>(0);
|
|
|
|
|
builder.AddAttribute(1, "Type", "close");
|
|
|
|
|
builder.AddAttribute(2, "Theme", "outline");
|
|
|
|
|
builder.CloseComponent();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
internal static readonly RenderFragment DefaultFooter = (builder) =>
|
|
|
|
|
{
|
|
|
|
|
builder.OpenComponent<ModalFooter>(0);
|
|
|
|
|
builder.CloseComponent();
|
|
|
|
|
};
|
|
|
|
|
|
2020-11-22 21:33:07 +08:00
|
|
|
|
public Func<Task> AfterClose { get; set; } = () => Task.CompletedTask;
|
2020-10-14 15:09:11 +08:00
|
|
|
|
|
|
|
|
|
public string BodyStyle { get; set; }
|
|
|
|
|
|
|
|
|
|
public OneOf<string, RenderFragment> CancelText { get; set; } = "Cancel";
|
|
|
|
|
|
|
|
|
|
public bool Centered { get; set; }
|
|
|
|
|
|
|
|
|
|
public bool Closable { get; set; } = true;
|
|
|
|
|
|
|
|
|
|
public bool Draggable { get; set; }
|
|
|
|
|
|
|
|
|
|
public bool DragInViewport { get; set; } = true;
|
|
|
|
|
|
|
|
|
|
public RenderFragment CloseIcon { get; set; } = DefaultCloseIcon;
|
|
|
|
|
|
|
|
|
|
public bool ConfirmLoading { get; set; }
|
|
|
|
|
|
|
|
|
|
public bool DestroyOnClose { get; set; }
|
|
|
|
|
|
|
|
|
|
public OneOf<string, RenderFragment>? Footer { get; set; } = DefaultFooter;
|
|
|
|
|
|
|
|
|
|
public bool ForceRender { get; set; }
|
|
|
|
|
|
2020-11-22 21:33:07 +08:00
|
|
|
|
public ElementReference? GetContainer { get; set; }
|
2020-10-14 15:09:11 +08:00
|
|
|
|
|
|
|
|
|
public bool Keyboard { get; set; } = true;
|
|
|
|
|
|
|
|
|
|
public bool Mask { get; set; } = true;
|
|
|
|
|
|
|
|
|
|
public bool MaskClosable { get; set; } = true;
|
|
|
|
|
|
|
|
|
|
public string MaskStyle { get; set; }
|
|
|
|
|
|
|
|
|
|
public OneOf<string, RenderFragment> OkText { get; set; } = "OK";
|
|
|
|
|
|
|
|
|
|
public string OkType { get; set; } = ButtonType.Primary;
|
|
|
|
|
|
2020-12-14 12:54:19 +08:00
|
|
|
|
public OneOf<string, RenderFragment> Title { get; set; }
|
2020-10-14 15:09:11 +08:00
|
|
|
|
|
|
|
|
|
public bool Visible { get; set; } = true;
|
|
|
|
|
|
|
|
|
|
public OneOf<string, double> Width { get; set; } = 520;
|
|
|
|
|
|
|
|
|
|
public string WrapClassName { get; set; }
|
|
|
|
|
|
|
|
|
|
public int ZIndex { get; set; } = 1000;
|
|
|
|
|
|
2020-11-22 21:33:07 +08:00
|
|
|
|
private Func<MouseEventArgs, Task> _onCancel;
|
2020-10-14 15:09:11 +08:00
|
|
|
|
|
2020-11-22 21:33:07 +08:00
|
|
|
|
public Func<MouseEventArgs, Task> OnCancel
|
2020-10-14 15:09:11 +08:00
|
|
|
|
{
|
2020-11-22 21:33:07 +08:00
|
|
|
|
get
|
2020-10-14 15:09:11 +08:00
|
|
|
|
{
|
2020-11-22 21:33:07 +08:00
|
|
|
|
return _onCancel ??= DefaultOnCancelOrOk;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_onCancel = value;
|
|
|
|
|
}
|
2020-10-14 15:09:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-22 21:33:07 +08:00
|
|
|
|
private Func<MouseEventArgs, Task> _onOk;
|
|
|
|
|
|
|
|
|
|
public ModalOptions()
|
|
|
|
|
{
|
|
|
|
|
Rtl = false;
|
|
|
|
|
}
|
2020-10-14 15:09:11 +08:00
|
|
|
|
|
2020-11-22 21:33:07 +08:00
|
|
|
|
public Func<MouseEventArgs, Task> OnOk
|
2020-10-14 15:09:11 +08:00
|
|
|
|
{
|
2020-11-22 21:33:07 +08:00
|
|
|
|
get
|
2020-10-14 15:09:11 +08:00
|
|
|
|
{
|
2020-11-22 21:33:07 +08:00
|
|
|
|
return _onOk ??= DefaultOnCancelOrOk;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_onOk = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal async Task DefaultOnCancelOrOk(MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
await (ModalRef?.CloseAsync() ?? Task.CompletedTask);
|
2020-10-14 15:09:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ButtonProps OkButtonProps { get; set; }
|
|
|
|
|
|
|
|
|
|
public ButtonProps CancelButtonProps { get; set; }
|
|
|
|
|
|
|
|
|
|
public RenderFragment Content { get; set; }
|
|
|
|
|
|
2020-11-22 21:33:07 +08:00
|
|
|
|
public bool Rtl { get; set; }
|
2020-10-14 15:09:11 +08:00
|
|
|
|
}
|
|
|
|
|
}
|