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
{
internal ModalRef ModalRef;
internal static readonly RenderFragment DefaultCloseIcon = (builder) =>
{
builder.OpenComponent(0);
builder.AddAttribute(1, "Type", "close");
builder.AddAttribute(2, "Theme", "outline");
builder.CloseComponent();
};
internal static readonly RenderFragment DefaultFooter = (builder) =>
{
builder.OpenComponent(0);
builder.CloseComponent();
};
public Func AfterClose { get; set; } = () => Task.CompletedTask;
public string BodyStyle { get; set; }
public OneOf 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? Footer { get; set; } = DefaultFooter;
public bool ForceRender { get; set; }
public ElementReference? GetContainer { get; set; }
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 OkText { get; set; } = "OK";
public string OkType { get; set; } = ButtonType.Primary;
public OneOf Title { get; set; }
public bool Visible { get; set; } = true;
public OneOf Width { get; set; } = 520;
public string WrapClassName { get; set; }
public int ZIndex { get; set; } = 1000;
private Func _onCancel;
public Func OnCancel
{
get
{
return _onCancel ??= DefaultOnCancelOrOk;
}
set
{
_onCancel = value;
}
}
private Func _onOk;
public ModalOptions()
{
Rtl = false;
}
public Func OnOk
{
get
{
return _onOk ??= DefaultOnCancelOrOk;
}
set
{
_onOk = value;
}
}
internal async Task DefaultOnCancelOrOk(MouseEventArgs e)
{
await (ModalRef?.CloseAsync() ?? Task.CompletedTask);
}
public ButtonProps OkButtonProps { get; set; }
public ButtonProps CancelButtonProps { get; set; }
public RenderFragment Content { get; set; }
public bool Rtl { get; set; }
}
}