2019-12-13 17:45:01 +08:00
|
|
|
|
using System.Collections.Generic;
|
2019-12-08 00:51:07 +08:00
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
|
|
|
|
|
|
namespace AntBlazor
|
|
|
|
|
{
|
|
|
|
|
public abstract class AntDomComponentBase : AntComponentBase
|
|
|
|
|
{
|
|
|
|
|
[Parameter]
|
|
|
|
|
public string Id { get; set; } = IdGeneratorHelper.Generate("antBlazor_id_");
|
|
|
|
|
|
|
|
|
|
[Parameter(CaptureUnmatchedValues = true)]
|
|
|
|
|
public Dictionary<string, object> Attributes { get; set; }
|
|
|
|
|
|
|
|
|
|
private ElementReference _ref;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returned ElementRef reference for DOM element.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public virtual ElementReference Ref
|
|
|
|
|
{
|
|
|
|
|
get => _ref;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_ref = value;
|
|
|
|
|
RefBack?.Set(value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[CascadingParameter]
|
2019-12-11 00:23:10 +08:00
|
|
|
|
public AntTheme AntTheme { get; set; }
|
2019-12-08 00:51:07 +08:00
|
|
|
|
|
|
|
|
|
protected ClassMapper ClassMapper { get; } = new ClassMapper();
|
|
|
|
|
|
|
|
|
|
protected AntDomComponentBase()
|
|
|
|
|
{
|
|
|
|
|
ClassMapper
|
|
|
|
|
.Get(() => this.Class)
|
2019-12-11 00:23:10 +08:00
|
|
|
|
.Get(() => this.AntTheme?.GetClass());
|
2019-12-08 00:51:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Specifies one or more classnames for an DOM element.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Parameter]
|
|
|
|
|
public string Class
|
|
|
|
|
{
|
|
|
|
|
get => _class;
|
|
|
|
|
set { _class = 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;
|
|
|
|
|
}
|
|
|
|
|
}
|