@namespace AntDesign
@inherits AntDomComponentBase
@ItemRender(new PaginationItemRenderContext(Page, PaginationItemType.Page, _ => @@Page, Disabled))
@code {
[Parameter]
public bool ShowTitle { get; set; }
[Parameter]
public int Page { get; set; }
[Parameter]
public string RootPrefixCls { get; set; }
[Parameter]
public bool Active { get; set; }
[Parameter]
public bool Disabled { get; set; }
[Parameter]
public EventCallback OnClick { get; set; }
[Parameter]
public EventCallback<(KeyboardEventArgs e, Action callback)> OnKeyPress { get; set; }
[Parameter]
public RenderFragment ItemRender { get; set; }
[Parameter(CaptureUnmatchedValues = true)]
public Dictionary UnmatchedAttributes { get; set; }
protected override void OnInitialized()
{
var prefixCls = $"{RootPrefixCls}-item";
ClassMapper.Add(prefixCls).Add($"{prefixCls}-{Page}")
.If($"{prefixCls}-active", () => Active)
.If(Class, () => !string.IsNullOrWhiteSpace(Class))
.If($"{prefixCls}-disabled", () => Page == 0);
base.OnInitialized();
}
private async Task HandleClick()
{
if (OnClick.HasDelegate)
{
await OnClick.InvokeAsync(Page);
}
}
private async Task HandleKeyPress(KeyboardEventArgs e)
{
if (OnKeyPress.HasDelegate)
{
await OnKeyPress.InvokeAsync((e, async () =>
{
if (OnClick.HasDelegate)
{
await OnClick.InvokeAsync(Page);
}
}));
}
}
}