@if (IsOpen)
{
    <div class="modal-backdrop fade show"></div>
    <div class="modal fade show" role="dialog" aria-modal="true" aria-labelledby="@TitleId" tabindex="-1" style="display: block;">
        <div class="modal-dialog modal-dialog-centered">
            <div class="modal-content">
                <div class="modal-header">
                    <h2 class="modal-title h5" id="@TitleId">@Title</h2>
                    <button type="button" class="btn-close" aria-label="Close"
                            disabled="@IsBusy"
                            @onclick="OnCancel"></button>
                </div>
                <div class="modal-body">
                    <p class="mb-0">@Message</p>
                </div>
                <div class="modal-footer">
                    <div class="btn-group" role="group" aria-label="Confirm or cancel">
                        <button type="button" class="btn btn-outline-secondary"
                                disabled="@IsBusy"
                                @onclick="OnCancel">
                            Cancel
                        </button>
                        <button type="button" class="btn @ConfirmButtonClass"
                                disabled="@IsBusy"
                                @onclick="OnConfirm">
                            @ConfirmLabel
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>
}

@code {
    private readonly string TitleId = $"confirm-dialog-{Guid.NewGuid():N}";

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

    [Parameter]
    public string Title { get; set; } = "Confirm";

    [Parameter]
    public string Message { get; set; } = string.Empty;

    [Parameter]
    public string ConfirmLabel { get; set; } = "Confirm";

    [Parameter]
    public string ConfirmButtonClass { get; set; } = "btn-primary";

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

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

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