2021-01-07 00:41:26 +08:00
|
|
|
|
using System.Threading.Tasks;
|
2020-10-09 15:13:32 +08:00
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
|
using Microsoft.AspNetCore.Components.Web;
|
|
|
|
|
|
|
|
|
|
namespace AntDesign
|
|
|
|
|
{
|
2021-01-10 18:49:52 +08:00
|
|
|
|
public partial class TreeNodeCheckbox<TItem> : ComponentBase
|
2020-10-09 15:13:32 +08:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2021-07-11 18:43:25 +08:00
|
|
|
|
/// Root Tree
|
2020-10-09 15:13:32 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
[CascadingParameter(Name = "Tree")]
|
2020-12-30 18:38:35 +08:00
|
|
|
|
public Tree<TItem> TreeComponent { get; set; }
|
2020-10-09 15:13:32 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
2021-07-11 18:43:25 +08:00
|
|
|
|
/// Current Node
|
2020-10-09 15:13:32 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
[CascadingParameter(Name = "SelfNode")]
|
2020-12-30 18:38:35 +08:00
|
|
|
|
public TreeNode<TItem> SelfNode { get; set; }
|
2020-10-09 15:13:32 +08:00
|
|
|
|
|
|
|
|
|
protected ClassMapper ClassMapper { get; } = new ClassMapper();
|
|
|
|
|
|
|
|
|
|
private void SetClassMap()
|
|
|
|
|
{
|
2021-07-11 18:43:25 +08:00
|
|
|
|
ClassMapper
|
|
|
|
|
.Add("ant-tree-checkbox")
|
2021-01-07 00:41:26 +08:00
|
|
|
|
.If("ant-tree-checkbox-checked", () => SelfNode.Checked)
|
|
|
|
|
.If("ant-tree-checkbox-indeterminate", () => SelfNode.Indeterminate)
|
2021-07-11 18:43:25 +08:00
|
|
|
|
.If("ant-tree-checkbox-disabled", () => SelfNode.Disabled || SelfNode.DisableCheckbox);
|
2020-10-09 15:13:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnInitialized()
|
|
|
|
|
{
|
|
|
|
|
SetClassMap();
|
|
|
|
|
base.OnInitialized();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
public EventCallback<MouseEventArgs> OnCheckBoxClick { get; set; }
|
|
|
|
|
|
|
|
|
|
private async Task OnClick(MouseEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
if (OnCheckBoxClick.HasDelegate)
|
|
|
|
|
await OnCheckBoxClick.InvokeAsync(args);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|