using Connected.Extensions; using Connected.Utilities; using Microsoft.AspNetCore.Components; namespace Connected.Components; public partial class InputControl : UIComponent { protected string Classname => new CssBuilder("mud-input-control") .AddClass("mud-input-required", when: () => Required) .AddClass($"mud-input-control-margin-{Margin.ToDescriptionString()}", when: () => Margin != Margin.None) .AddClass("mud-input-control-full-width", FullWidth) .AddClass("mud-input-error", Error) .AddClass(Class) .Build(); protected string HelperContainer => new CssBuilder("mud-input-control-helper-container") .AddClass($"px-1", Variant == Variant.Filled) .AddClass($"px-2", Variant == Variant.Outlined) .Build(); protected string HelperClass => new CssBuilder("mud-input-helper-text") .AddClass("mud-input-helper-onfocus", HelperTextOnFocus) .AddClass("mud-input-error", Error) .Build(); /// /// Child content of component. /// [Parameter] public RenderFragment ChildContent { get; set; } /// /// Should be the Input /// [Parameter] public RenderFragment InputContent { get; set; } /// /// Will adjust vertical spacing. /// [Parameter] public Margin Margin { get; set; } = Margin.None; /// /// If true, will apply mud-input-required class to the output div /// [Parameter] public bool Required { get; set; } /// /// If true, the label will be displayed in an error state. /// [Parameter] public bool Error { get; set; } /// /// The ErrorText that will be displayed if Error true /// [Parameter] public string ErrorText { get; set; } /// /// The ErrorId that will be used by aria-describedby if Error true /// [Parameter] public string ErrorId { get; set; } /// /// The HelperText will be displayed below the text field. /// [Parameter] public string HelperText { get; set; } /// /// If true, the helper text will only be visible on focus. /// [Parameter] public bool HelperTextOnFocus { get; set; } /// /// The current character counter, displayed below the text field. /// [Parameter] public string CounterText { get; set; } /// /// If true, the input will take up the full width of its container. /// [Parameter] public bool FullWidth { get; set; } /// /// If string has value the label text will be displayed in the input, and scaled down at the top if the input has value. /// [Parameter] public string Label { get; set; } /// /// Variant can be Text, Filled or Outlined. /// [Parameter] public Variant Variant { get; set; } = Variant.Text; /// /// If true, the input element will be disabled. /// [Parameter] public bool Disabled { get; set; } /// /// If string has value the label "for" attribute will be added. /// [Parameter] public string ForId { get; set; } = string.Empty; }