using Connected.Utilities;
using Microsoft.AspNetCore.Components;

namespace Connected.Components;
public class InputBase : ComponentBase
{
	[Parameter]
	public string Class { get; set; } = string.Empty;

	public string InputFieldClassList
	{
		get
		{
			return new CssBuilder("form-group")
				.AddClass("error", ErrorText.Length > 0)
				.AddClass(Class)
				.Build();
		}
	}

	/// <summary>
	/// Show clear button.
	/// </summary>
	[Parameter]
	public bool Clearable { get; set; } = true;

	/// <summary>
	/// Required property
	/// </summary>
	[Parameter]
	public bool Required { get; set; } = false;

	public Dictionary<string, object> InputAttributes { get; set; }

	/// <summary>
	/// Show clear button.
	/// </summary>
	[Parameter]
	public bool Disabled { get; set; } = false;

	/// <summary>
	/// Show clear button.
	/// </summary>
	[Parameter]
	public bool Readonly { get; set; } = false;

	/// <summary>
	/// The show input character counter
	/// </summary>
	[Parameter]
	public bool ShowCharacterCounter { get; set; }

	[Parameter]
	public string ErrorText { get; set; } = string.Empty;

	public bool IsError
	{
		get
		{
			return !string.IsNullOrEmpty(ErrorText);
		}
	}

	[Parameter]
	public string HelperText { get; set; } = string.Empty;

	public bool IsHelperText
	{
		get
		{
			return !string.IsNullOrEmpty(HelperText);
		}
	}

	[Parameter]
	public string Label { get; set; } = string.Empty;
	public bool IsLabel
	{
		get
		{
			return !string.IsNullOrEmpty(Label);
		}
	}

	[Parameter]
	public string Placeholder { get; set; } = string.Empty;
}
