using System;
using Microsoft.AspNetCore.Components;

using CommonHelpers.WASM;
using AFXUI;

namespace BookRegistry.Client {

//**************************************************************************************************
partial class ForeOperation {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/// <exception cref="InvalidOperationException" />
public static ForeOperation WithSaveFocus( bool allowCancellation = true ) =>
   new ForeOperation( new SaveFocusParams( true ), allowCancellation );

//--------------------------------------------------------------------------------------------------

/// <exception cref="InvalidOperationException" />
public static ForeOperation WithSaveFocus( string operationText ) =>
   new ForeOperation( new SaveFocusParams( true ), operationText );
/// <exception cref="InvalidOperationException" />
public static ForeOperation WithSaveFocus( string operationTextFmt, params object?[] parameters ) =>
   new ForeOperation( new SaveFocusParams( true ), operationTextFmt, parameters );

/// <exception cref="InvalidOperationException" />
public static ForeOperation WithSaveFocus( bool allowCancellation, string operationText ) =>
   new ForeOperation( new SaveFocusParams( true ), allowCancellation, operationText );
/// <exception cref="InvalidOperationException" />
public static ForeOperation WithSaveFocus( bool allowCancellation,
                                           string operationTextFmt, params object?[] parameters ) =>
   new ForeOperation( new SaveFocusParams( true ),
                      allowCancellation, operationTextFmt, parameters );

//==================================================================================================

/// <exception cref="InvalidOperationException" />
public static ForeOperation WithSaveFocus( ElementReference? elementRef ) =>
   new ForeOperation( new SaveFocusParams( elementRef ) );
/// <exception cref="InvalidOperationException" />
public static ForeOperation WithSaveFocus( ElementReference? elementRef,
                                           bool allowCancellation = true ) =>
   new ForeOperation( new SaveFocusParams( elementRef ), allowCancellation );

//--------------------------------------------------------------------------------------------------

/// <exception cref="InvalidOperationException" />
public static ForeOperation WithSaveFocus( ElementReference? elementRef, string operationText ) =>
   new ForeOperation( new SaveFocusParams( elementRef ), operationText );
/// <exception cref="InvalidOperationException" />
public static ForeOperation WithSaveFocus( ElementReference? elementRef,
                                           string operationTextFmt, params object?[] parameters ) =>
   new ForeOperation( new SaveFocusParams( elementRef ), operationTextFmt, parameters );

/// <exception cref="InvalidOperationException" />
public static ForeOperation WithSaveFocus( ElementReference? elementRef,
                                           bool allowCancellation, string operationText ) =>
   new ForeOperation( new SaveFocusParams( elementRef ), allowCancellation, operationText );
/// <exception cref="InvalidOperationException" />
public static ForeOperation WithSaveFocus( ElementReference? elementRef,
                                           bool allowCancellation,
                                           string operationTextFmt, params object?[] parameters ) =>
   new ForeOperation( new SaveFocusParams( elementRef ),
                      allowCancellation, operationTextFmt, parameters );

//==================================================================================================

/// <exception cref="InvalidOperationException" />
public static ForeOperation WithSaveFocus( AComponent control, bool allowCancellation = true ) =>
   WithSaveFocus( control.MainElement, allowCancellation );

//--------------------------------------------------------------------------------------------------

/// <exception cref="InvalidOperationException" />
public static ForeOperation WithSaveFocus( AComponent control, string operationText ) =>
   WithSaveFocus( control.MainElement, operationText );
/// <exception cref="InvalidOperationException" />
public static ForeOperation WithSaveFocus( AComponent control,
                                           string operationTextFmt, params object?[] parameters ) =>
   WithSaveFocus( control.MainElement, operationTextFmt, parameters );

/// <exception cref="InvalidOperationException" />
public static ForeOperation WithSaveFocus( AComponent control,
                                           bool allowCancellation, string operationText ) =>
   WithSaveFocus( control.MainElement, allowCancellation, operationText );
/// <exception cref="InvalidOperationException" />
public static ForeOperation WithSaveFocus( AComponent control,
                                           bool allowCancellation,
                                           string operationTextFmt, params object?[] parameters ) =>
   WithSaveFocus( control.MainElement, allowCancellation, operationTextFmt, parameters );

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // ForeOperation
//**************************************************************************************************

} // BookRegistry.Client
