@using Microsoft.AspNetCore.Components.Web

<textarea
    @ref="textArea"
    class="@TextAreaCssClass"
    value="@Model.QuickParseInput"
    @oninput="HandleQuickParseInputChanged"
    disabled="@IsDisabled"></textarea>

@code {
    [Parameter, EditorRequired]
    public CriticalCellEditorModel Model { get; set; } = default!;

    [Parameter]
    public bool IsDisabled { get; set; }

    [Parameter]
    public string TextAreaCssClass { get; set; } = "input-shell critical-editor-textarea tall";

    [Parameter]
    public EventCallback OnReparse { get; set; }

    public Task ReparseAsync() => OnReparse.InvokeAsync();

    public ValueTask FocusAsync() => textArea.FocusAsync();

    private ElementReference textArea;

    private void HandleQuickParseInputChanged(ChangeEventArgs args)
    {
        Model.QuickParseInput = args.Value?.ToString() ?? string.Empty;
    }
}
