ant-design-blazor/components/core/Base/AntDomComponentBase.cs
zxyao 895c758836 fix(module: drawer): OffsetX and offsetY do not work () ()
* fix(module: drawer): OffsetX and offsetY do not work ()

* docs: demo update

* fix: Placement is switched to the relative direction, the animation appears

* fix: the bug of closing animation missed

* fix: incorrect animation

* fix: different behaviors in WASM and Server side

Co-authored-by: James Yeung <shunjiey@hotmail.com>
2021-05-28 06:10:44 +00:00

91 lines
2.2 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 a DOM element.
/// </summary>
[Parameter]
public string Style
{
get => _style;
set
{
_style = value;
if (!string.IsNullOrWhiteSpace(_style) && !_style.EndsWith(";"))
{
_style += ";";
}
this.StateHasChanged();
}
}
protected virtual string GenerateStyle()
{
return Style;
}
private string _class;
private string _style;
}
}