using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using OneOf;
namespace AntDesign
{
///
/// dialog options
///
public class DialogOptions : DialogOptionsBase
{
///
/// trigger after Dialog is closed
///
public Func OnClosed { get; set; }
///
/// 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; } = DefaultCloseIcon;
///
/// Whether to apply loading visual effect for OK button or not
///
public bool ConfirmLoading { get; set; }
///
/// modal footer
///
public OneOf? Footer { get; set; } = DefaultFooter;
///
/// The class name of the container of the modal dialog
///
public string WrapClassName { get; set; }
///
/// ChildContent
///
public RenderFragment ChildContent { get; set; }
///
/// the class name of the element of ".ant-modal"
///
public string ClassName { get; set; }
///
/// for OK-Cancel Confirm dialog, cancel button clicked callback.
/// It's only trigger in Confirm created by ModalService mode
///
public Func OnCancel { get; set; }
///
/// for OK-Cancel Confirm dialog, OK button clicked callback.
/// It's only trigger in Confirm created by ModalService mode
///
public Func OnOk { get; set; }
#region internal
internal string GetHeaderStyle()
{
if (Draggable)
{
return "cursor: move;";
}
return "";
}
internal string GetWidth()
{
if (Width.IsT0)
{
return $"width:{Width.AsT0};";
}
else
{
return $"width:{Width.AsT1}px;";
}
}
internal string GetWrapClassNameExtended(Modal modal = null)
{
var classNameArray = new List();
if (modal == null)
{
classNameArray.AddIf(
!string.IsNullOrWhiteSpace(WrapClassName),
WrapClassName)
.AddIf(Centered, $"{PrefixCls}-centered")
.AddIf(Rtl, $"{PrefixCls}-wrap-rtl");
return string.Join(' ', classNameArray);
}
classNameArray.AddIf(
!string.IsNullOrWhiteSpace(modal.WrapClassName),
modal.WrapClassName)
.AddIf(modal.Centered, $"{PrefixCls}-centered")
.AddIf(modal.Rtl, $"{PrefixCls}-wrap-rtl");
return string.Join(' ', classNameArray);
}
#endregion
}
}