using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;

namespace FNZCM.BlazorWasm.UI.Components.FnzBoostrap.Bases
{
    public class FnzBoostrapContainerComponentBase<T, TOptions> : FnzBoostrapComponentBase<T, TOptions>
        where T : class
        where TOptions : OptionsBase, new()
    {

        [Parameter] public EventCallback OnShown { get; set; } = EventCallback.Empty;
        [Parameter] public EventCallback OnHidden { get; set; } = EventCallback.Empty;

        public void Hide() => JSRuntime.InvokeVoidAsync($"{Prefix}.hide", ElementId, dotNetRef);

        public void Show() => JSRuntime.InvokeVoidAsync($"{Prefix}.show", ElementId, dotNetRef);

        [JSInvokable("OnShown")] public virtual void JsCallbackOnShown() { OnShown.InvokeAsync(); }

        [JSInvokable("OnHidden")] public virtual void JsCallbackOnHidden() { OnHidden.InvokeAsync(); }
    }
}
