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

namespace Connected.Components;
public partial class CheckBox : InputBase
{
	/// <summary>
	/// State of the CheckBox
	/// Options: true, false
	/// Default: false
	/// </summary>
	[Parameter]
	public bool Checked { get; set; } = false;


	/// <summary>
	/// ID for the CheckBox
	/// </summary>
	[Parameter, EditorRequired]
	public string? Id { get; set; }

	/// <summary>
	/// Event when the checked is changed
	/// </summary>
	[Parameter]
	public EventCallback<bool> CheckedChanged { get; set; }

	/// <summary>
	/// OPTIONAL - Style for the input
	/// Options: any valid CSS style
	/// Default: string.Empty
	/// </summary>
	[Parameter]
	public string Style { get; set; } = string.Empty;

	/// <summary>
	/// OPTIONAL - Class for the label of input
	/// Options: any valid Class name or multiple separated with space
	/// Default: string.Empty
	/// </summary>
	[Parameter]
	public string LabelClass { get; set; } = string.Empty;

	/// <summary>
	/// OPTIONAL - Style for the label of input
	/// Options: any valid CSS style
	/// Default: string.Empty
	/// </summary>
	[Parameter]
	public string LabelStyle { get; set; } = string.Empty;

	/// <summary>
	/// OnChange event when checked is changed
	/// </summary>
	/// <returns></returns>
	public async Task OnChange()
	{
		Checked = !Checked;
		await CheckedChanged.InvokeAsync(Checked);
	}

	private string ClassList
	{
		get
		{
			return new CssBuilder("checkbox-input")
				.AddClass(base.Class)
				.Build();
		}
	}
	private string StyleList
	{
		get
		{
			return new StyleBuilder()
				.AddStyle(Style)
				.Build();
		}
	}

	private string LabelClassList
	{
		get
		{
			return new CssBuilder("checkbox-label")
				.AddClass(LabelClass)
				.Build();
		}
	}
	private string LabelStyleList
	{
		get
		{
			return new StyleBuilder()
				.AddStyle(LabelStyle)
				.Build();
		}
	}
}
