mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-15 09:21:24 +08:00
d2e9c4b247
* feat(module: config-provider): support RTL * add rtl for each component * fix rtl for pagination * add rtl for overlay
87 lines
2.1 KiB
C#
87 lines
2.1 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
|
|
namespace AntDesign
|
|
{
|
|
public abstract class AntDomComponentBase : AntComponentBase
|
|
{
|
|
[Inject]
|
|
private IComponentIdGenerator ComponentIdGenerator { get; set; }
|
|
|
|
[Parameter]
|
|
public string Id { get; set; }
|
|
|
|
[CascadingParameter]
|
|
public ConfigProvider ConfigProvider { get; set; }
|
|
|
|
protected bool RTL => ConfigProvider?.Direction == "RTL";
|
|
|
|
//[Parameter(CaptureUnmatchedValues = true)]
|
|
//public Dictionary<string, object> Attributes { get; set; } = new Dictionary<string, object>();
|
|
|
|
private ElementReference _ref;
|
|
|
|
/// <summary>
|
|
/// Returned ElementRef reference for DOM element.
|
|
/// </summary>
|
|
public virtual ElementReference Ref
|
|
{
|
|
get => _ref;
|
|
set
|
|
{
|
|
_ref = value;
|
|
RefBack?.Set(value);
|
|
}
|
|
}
|
|
|
|
protected ClassMapper ClassMapper { get; } = new ClassMapper();
|
|
|
|
protected AntDomComponentBase()
|
|
{
|
|
ClassMapper
|
|
.Get(() => this.Class);
|
|
}
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
Id ??= ComponentIdGenerator.Generate(this);
|
|
base.OnInitialized();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Specifies one or more class names for an DOM element.
|
|
/// </summary>
|
|
[Parameter]
|
|
public string Class
|
|
{
|
|
get => _class;
|
|
set
|
|
{
|
|
_class = value;
|
|
ClassMapper.OriginalClass = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Specifies an inline style for an DOM element.
|
|
/// </summary>
|
|
[Parameter]
|
|
public string Style
|
|
{
|
|
get => _style;
|
|
set
|
|
{
|
|
_style = value;
|
|
this.StateHasChanged();
|
|
}
|
|
}
|
|
|
|
protected virtual string GenerateStyle()
|
|
{
|
|
return Style;
|
|
}
|
|
|
|
private string _class;
|
|
private string _style;
|
|
}
|
|
}
|