2020-04-23 17:13:56 +08:00
|
|
|
|
using Microsoft.AspNetCore.Components;
|
2019-12-08 00:51:07 +08:00
|
|
|
|
|
|
|
|
|
namespace AntBlazor
|
|
|
|
|
{
|
|
|
|
|
public abstract class AntDomComponentBase : AntComponentBase
|
|
|
|
|
{
|
|
|
|
|
[Parameter]
|
2020-04-23 17:13:56 +08:00
|
|
|
|
public string Id { get; set; } = IdGeneratorHelper.Generate("ant-blazor-");
|
2019-12-08 00:51:07 +08:00
|
|
|
|
|
2020-04-23 17:13:56 +08:00
|
|
|
|
//[Parameter(CaptureUnmatchedValues = true)]
|
|
|
|
|
//public Dictionary<string, object> Attributes { get; set; } = new Dictionary<string, object>();
|
2019-12-08 00:51:07 +08:00
|
|
|
|
|
|
|
|
|
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
|
2020-04-23 17:13:56 +08:00
|
|
|
|
.Get(() => this.Class)
|
2019-12-11 00:23:10 +08:00
|
|
|
|
.Get(() => this.AntTheme?.GetClass());
|
2019-12-08 00:51:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2020-04-23 17:13:56 +08:00
|
|
|
|
/// Specifies one or more class names for an DOM element.
|
2019-12-08 00:51:07 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
[Parameter]
|
2020-04-23 17:13:56 +08:00
|
|
|
|
public string Class
|
2019-12-08 00:51:07 +08:00
|
|
|
|
{
|
|
|
|
|
get => _class;
|
2019-12-20 00:20:53 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_class = value;
|
|
|
|
|
ClassMapper.OriginalClass = value;
|
|
|
|
|
}
|
2019-12-08 00:51:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <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;
|
|
|
|
|
}
|
2020-04-23 17:13:56 +08:00
|
|
|
|
}
|