ant-design-blazor/components/pagination/PaginationOptions.razor.cs
James Yeung bd34858efd feat: support for globalization & localization (#578)
* feat: add locale

* feat: add locale interfaces

* fix: add locale interfaces for components

* fix: use local classes instead of interfaces

* feat: implement the locale provider

* feat: make some components to support localization

* fix: default language

* fix: test

* chore: remove the useless reference
2020-09-07 22:46:50 +08:00

61 lines
1.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
namespace AntDesign
{
public partial class PaginationOptions : AntDomComponentBase
{
/// <summary>
/// 'default' | 'small' = 'default';
/// </summary>
[Parameter] public string Size { get; set; } = "default";
[Parameter] public bool Disabled { get; set; } = false;
[Parameter] public bool ShowSizeChanger { get; set; } = false;
[Parameter] public bool ShowQuickJumper { get; set; } = false;
[Parameter] public object Locale { get; set; }
[Parameter] public int Total { get; set; } = 0;
[Parameter] public int PageIndex { get; set; } = 1;
[Parameter] public int PageSize { get; set; } = 10;
[Parameter] public int[] PageSizeOptions { get; set; } = Array.Empty<int>();
[Parameter] public EventCallback<int> PageIndexChange { get; set; }
[Parameter] public EventCallback<int> PageSizeChange { get; set; }
[CascadingParameter] public Pagination Pagination { get; set; }
private string _inputValue;
private (int value, string label)[] _listOfPageSizeOption = Array.Empty<(int, string)>();
private void OnPageSizeChange(int size)
{
if (this.PageSize != size)
{
this.PageSizeChange.InvokeAsync(size);
}
}
private void JumpToPageViaInput(KeyboardEventArgs e)
{
if (e.Key == "Enter")
{
var index = int.TryParse(_inputValue, out var value) && value > 0 ? value : this.PageIndex;
PageIndexChange.InvokeAsync(index);
_inputValue = "";
}
}
}
}