@inherits DataFilterBaseComponent<TextBoxControl>

@if(Control.Multiline)
{
    <textarea style="@GetStyle"
              name="@Control.Name"
              disabled="@IsDisabled"
              maxlength="@Control.MaxLength"
              readonly="@Control.ReadOnly"
              @bind="@Text"></textarea>
}
else
{
    <input style="@GetStyle"
           name="@Control.Name"
           type="text"
           disabled="@IsDisabled"
           maxlength="@Control.MaxLength"
           readonly="@Control.ReadOnly"
           @bind="@Text"/>
}

@code {

    public string Text
    {
        get => Control.Text;
        set
        {
            string correctValue = value.Replace("\n", "\r\n");
            Control.Text = correctValue;
            TextBoxChange(correctValue);
        }
    }

    private void TextBoxChange(string data)
    {
        Control.FilterData();
        Control.OnTextChanged(null);

        Refresh();
    }

    protected override string GetStyle
        => base.GetStyle + GetControlAlign();
}
