2020-04-16 12:05:59 +08:00
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
|
|
2020-05-29 00:33:49 +08:00
|
|
|
|
namespace AntDesign
|
2020-04-16 12:05:59 +08:00
|
|
|
|
{
|
2020-06-07 19:41:00 +08:00
|
|
|
|
public partial class TabPane : AntDomComponentBase
|
2020-04-16 12:05:59 +08:00
|
|
|
|
{
|
|
|
|
|
private const string PrefixCls = "ant-tabs-tab";
|
2020-06-07 19:41:00 +08:00
|
|
|
|
private Tabs _parent;
|
2020-04-16 12:05:59 +08:00
|
|
|
|
|
2020-04-23 17:13:56 +08:00
|
|
|
|
internal ClassMapper _classMapper = new ClassMapper();
|
|
|
|
|
|
2020-04-16 12:05:59 +08:00
|
|
|
|
internal bool IsActive { get; set; }
|
|
|
|
|
|
2020-06-07 19:41:00 +08:00
|
|
|
|
public TabPane()
|
2020-04-24 18:32:50 +08:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-07 19:41:00 +08:00
|
|
|
|
public TabPane(string key, RenderFragment tab, RenderFragment childContent)
|
2020-04-24 18:32:50 +08:00
|
|
|
|
{
|
|
|
|
|
this.Key = key;
|
|
|
|
|
this.Tab = tab;
|
|
|
|
|
this.ChildContent = childContent;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-16 12:05:59 +08:00
|
|
|
|
[CascadingParameter]
|
2020-06-07 19:41:00 +08:00
|
|
|
|
internal Tabs Parent
|
2020-04-16 12:05:59 +08:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _parent;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (_parent == null)
|
|
|
|
|
{
|
|
|
|
|
_parent = value;
|
|
|
|
|
_parent.AddTabPane(this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Forced render of content in tabs, not lazy render after clicking on tabs
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Parameter]
|
|
|
|
|
public bool ForceRender { get; set; } = false;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// TabPane's key
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Parameter]
|
|
|
|
|
public string Key { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2020-06-07 19:41:00 +08:00
|
|
|
|
/// Show text in <see cref="TabPane"/>'s head
|
2020-04-16 12:05:59 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
[Parameter]
|
|
|
|
|
public RenderFragment Tab { get; set; }
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
public RenderFragment ChildContent { get; set; }
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
public bool Disabled { get; set; }
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
public bool Closable { get; set; } = true;
|
|
|
|
|
|
|
|
|
|
protected override void OnParametersSet()
|
|
|
|
|
{
|
|
|
|
|
base.OnParametersSet();
|
|
|
|
|
|
2020-04-23 17:13:56 +08:00
|
|
|
|
_classMapper.Clear().
|
2020-04-16 12:05:59 +08:00
|
|
|
|
Add(PrefixCls)
|
|
|
|
|
.If($"{PrefixCls}-active", () => IsActive)
|
2020-06-10 13:34:51 +08:00
|
|
|
|
.If($"{PrefixCls}-with-remove", () => Closable)
|
2020-04-16 12:05:59 +08:00
|
|
|
|
.If($"{PrefixCls}-disabled", () => Disabled);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-23 17:13:56 +08:00
|
|
|
|
}
|