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;
|
2021-06-22 23:55:14 +08:00
|
|
|
|
protected string _buttonClassRight;
|
|
|
|
|
protected string _buttonClassLeft;
|
|
|
|
|
protected string _buttonStyleRight;
|
|
|
|
|
protected string _buttonStyleLeft;
|
|
|
|
|
|
|
|
|
|
internal string RightButtonIcon => _rightButtonIcon;
|
|
|
|
|
internal string ButtonSize => _buttonSize;
|
|
|
|
|
internal string ButtonTypeRight => _buttonTypeRight;
|
|
|
|
|
internal string ButtonTypeLeft => _buttonTypeLeft;
|
|
|
|
|
internal string ButtonClassRight => _buttonClassRight;
|
|
|
|
|
internal string ButtonClassLeft => _buttonClassLeft;
|
|
|
|
|
internal string ButtonStyleRight => _buttonStyleRight;
|
|
|
|
|
internal string ButtonStyleLeft => _buttonStyleLeft;
|
|
|
|
|
internal bool ButtonDanger => _danger;
|
|
|
|
|
internal bool ButtonGhost => _ghost;
|
|
|
|
|
internal bool IsLoading => _isLoading;
|
|
|
|
|
|
|
|
|
|
private static readonly EventCallbackFactory _callbackFactory = new EventCallbackFactory();
|
|
|
|
|
|
2020-05-18 14:46:42 +08:00
|
|
|
|
protected void ChangeRightButtonIcon(string icon)
|
|
|
|
|
{
|
|
|
|
|
_rightButtonIcon = icon;
|
|
|
|
|
|
|
|
|
|
StateHasChanged();
|
|
|
|
|
}
|
2021-06-22 23:55:14 +08:00
|
|
|
|
protected void ChangeButtonClass(string leftButton, string rightButton)
|
|
|
|
|
{
|
|
|
|
|
_buttonClassLeft = leftButton;
|
|
|
|
|
_buttonClassRight = rightButton;
|
|
|
|
|
StateHasChanged();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void ChangeButtonStyles(string leftButton, string rightButton)
|
|
|
|
|
{
|
|
|
|
|
_buttonStyleLeft = leftButton;
|
|
|
|
|
_buttonStyleRight = rightButton;
|
|
|
|
|
StateHasChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-18 14:46:42 +08:00
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-22 23:55:14 +08:00
|
|
|
|
protected void ChangeButtonType(string leftButton, string rightButton)
|
2021-06-09 17:51:24 +08:00
|
|
|
|
{
|
2021-06-22 23:55:14 +08:00
|
|
|
|
_buttonTypeLeft = leftButton;
|
|
|
|
|
_buttonTypeRight = rightButton;
|
2021-06-09 17:51:24 +08:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
}
|