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

namespace FNZCM.BlazorWasm.UI.Components.FnzBootstrap.Bases
{
    public class FnzBootstrapContainerComponentBase<T, TOptions> : FnzBootstrapComponentBase<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(); }
    }
}
