2020-05-18 14:46:42 +08:00
|
|
|
|
using System;
|
2021-06-09 17:51:24 +08:00
|
|
|
|
using System.Threading.Tasks;
|
2020-05-29 00:33:49 +08:00
|
|
|
|
using AntDesign.Internal;
|
2020-05-18 14:46:42 +08:00
|
|
|
|
using Microsoft.AspNetCore.Components;
|
2021-06-09 17:51:24 +08:00
|
|
|
|
using Microsoft.AspNetCore.Components.Web;
|
2020-05-18 14:46:42 +08:00
|
|
|
|
|
2020-05-29 00:33:49 +08:00
|
|
|
|
namespace AntDesign
|
2020-05-18 14:46:42 +08:00
|
|
|
|
{
|
|
|
|
|
public partial class Dropdown : OverlayTrigger
|
|
|
|
|
{
|
2021-06-09 17:51:24 +08:00
|
|
|
|
internal Func<RenderFragment, RenderFragment, RenderFragment> ButtonsRender { get; set; }
|
|
|
|
|
internal bool Block { get; set; }
|
2020-05-18 14:46:42 +08:00
|
|
|
|
|
|
|
|
|
private string _rightButtonIcon = "ellipsis";
|
|
|
|
|
private string _buttonSize = AntSizeLDSType.Default;
|
2021-06-09 17:51:24 +08:00
|
|
|
|
private bool _danger;
|
|
|
|
|
private bool _ghost;
|
|
|
|
|
private bool _isLoading;
|
2020-05-18 14:46:42 +08:00
|
|
|
|
|
2021-06-09 17:51:24 +08:00
|
|
|
|
private string _buttonTypeRight = ButtonType.Default;
|
|
|
|
|
private string _buttonTypeLeft = ButtonType.Default;
|
2020-05-18 14:46:42 +08:00
|
|
|
|
protected void ChangeRightButtonIcon(string icon)
|
|
|
|
|
{
|
|
|
|
|
_rightButtonIcon = icon;
|
|
|
|
|
|
|
|
|
|
StateHasChanged();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void ChangeButtonSize(string size)
|
|
|
|
|
{
|
|
|
|
|
_buttonSize = size;
|
|
|
|
|
|
|
|
|
|
StateHasChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-09 17:51:24 +08:00
|
|
|
|
protected void ChangeButtonDanger(bool danger)
|
|
|
|
|
{
|
|
|
|
|
_danger = danger;
|
|
|
|
|
|
|
|
|
|
StateHasChanged();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void ChangeButtonGhost(bool ghost)
|
2020-05-18 14:46:42 +08:00
|
|
|
|
{
|
2021-06-09 17:51:24 +08:00
|
|
|
|
_ghost = ghost;
|
2020-05-18 14:46:42 +08:00
|
|
|
|
|
|
|
|
|
StateHasChanged();
|
|
|
|
|
}
|
2021-06-09 17:51:24 +08:00
|
|
|
|
|
|
|
|
|
protected void ChangeButtonLoading(bool isLoading)
|
|
|
|
|
{
|
|
|
|
|
_isLoading = isLoading;
|
|
|
|
|
|
|
|
|
|
StateHasChanged();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void ChangeButtonType((string LeftButton, string RightButton) type)
|
|
|
|
|
{
|
|
|
|
|
(_buttonTypeLeft, _buttonTypeRight) = type;
|
|
|
|
|
StateHasChanged();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Handle the trigger click.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="args">MouseEventArgs</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public override async Task OnClickDiv(MouseEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
if (!IsButton)
|
|
|
|
|
{
|
|
|
|
|
await OnTriggerClick();
|
|
|
|
|
await OnClick.InvokeAsync(args);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-18 14:46:42 +08:00
|
|
|
|
}
|
|
|
|
|
}
|