diff --git a/Components/UIComponent.cs b/Components/UIComponent.cs index 5827a61..fd5edf5 100644 --- a/Components/UIComponent.cs +++ b/Components/UIComponent.cs @@ -1,62 +1,36 @@ -using Connected.Annotations; -using Connected.Middleware; -using Microsoft.AspNetCore.Components; -using Microsoft.Extensions.Logging; +using Microsoft.AspNetCore.Components; namespace Connected.Components; public abstract class UIComponent : ComponentBase { - [Inject] - private ILoggerFactory LoggerFactory { get; set; } - [Inject] - private IComponentMiddlewareService? MiddlewareService { get; set; } - - private ILogger _logger; - protected ILogger Logger => _logger ??= LoggerFactory.CreateLogger(GetType()); - - /// - /// User class names, separated by space. - /// - [Parameter] - [Category(CategoryTypes.ComponentBase.Common)] - public string Class { get; set; } - - /// - /// User styles, applied on top of the component's own classes and styles. - /// - [Parameter] - [Category(CategoryTypes.ComponentBase.Common)] - public string Style { get; set; } - - /// - /// Use Tag to attach any user data object to the component for your convenience. - /// - [Parameter] - [Category(CategoryTypes.ComponentBase.Common)] - public object Tag { get; set; } - - /// - /// UserAttributes carries all attributes you add to the component that don't match any of its parameters. - /// They will be splatted onto the underlying HTML tag. - /// - [Parameter(CaptureUnmatchedValues = true)] - [Category(CategoryTypes.ComponentBase.Common)] - public Dictionary UserAttributes { get; set; } = new Dictionary(); - - /// - /// If the UserAttributes contain an ID make it accessible for WCAG labelling of input fields - /// - public string FieldId => (UserAttributes?.ContainsKey("id") == true ? UserAttributes["id"].ToString() : $"mudinput-{Guid.NewGuid()}"); - - protected Type ResolveComponent() - { - if (MiddlewareService is null) - return typeof(TComponent); - - if (MiddlewareService.Select() is Type type) - return type; - - return typeof(TComponent); - } + /// + /// User class names, separated by space. + /// + [Parameter] + public string Class { get; set; } + + /// + /// User styles, applied on top of the component's own classes and styles. + /// + [Parameter] + public string Style { get; set; } + + /// + /// Use Tag to attach any user data object to the component for your convenience. + /// + [Parameter] + public object Tag { get; set; } + + /// + /// UserAttributes carries all attributes you add to the component that don't match any of its parameters. + /// They will be splatted onto the underlying HTML tag. + /// + [Parameter(CaptureUnmatchedValues = true)] + public Dictionary UserAttributes { get; set; } = new(); + + /// + /// If the UserAttributes contain an ID make it accessible for WCAG labelling of input fields + /// + public string FieldId => UserAttributes.TryGetValue("id", out var id) ? id.ToString() : $"input-{Guid.NewGuid()}"; }