@versatiledatakit/shared
Version:
Versatile Data Kit Shared library enables reusability of shared features like: NgRx Redux, Error Handlers, Utils, Generic Components, etc.
214 lines (213 loc) • 5.77 kB
TypeScript
import { Type } from '@angular/core';
export declare const ERROR_CODE_CONFIRMATION_FORCEFULLY_DESTROYED_COMPONENT = "EC_CONFIRMATION_1000";
/**
* ** Confirmation Input Model.
*
* - Model instance provided as input instructions for Confirmation Service, or to more specific to method {@link ConfirmationService.confirm}
* - Most of the fields are optional and Model Impl provides its own defaults.
*/
export interface ConfirmationInputModel extends SupportedButtonsModel, SupportedMessageModel {
/**
* ** Confirmation title.
*
* - Service render provided content as innerHTML.
* - HTML tags could be provided in string template.
*/
title?: string;
/**
* ** Whether confirmation view to render close X button in top right corner.
*/
closable?: boolean;
/**
* ** Whether confirmation view to render option for User to opt-out of showing confirmations with same context in the future.
*/
optionDoNotShowFutureConfirmation?: boolean;
}
/**
* ** Confirmation Input Model extension for the needs of {@link ConfirmationService}.
*
* - private model used only in the service.
*/
export interface ConfirmationModelExtension {
/**
* ** Model UUID.
*/
uuid: string;
/**
* ** Confirmation Handler.
*/
handler: ConfirmationHandler;
}
/**
* ** Supported Confirmation view Messages, providing one of the bellow options.
*
* - it could be text provided with html tags inside
* - it could be Component class ref with optional messageCode
*/
export interface SupportedMessageModel {
/**
* ** Confirmation message.
*
* - Service render provided content as innerHTML.
* - HTML tags could be provided in string template.
*/
message?: string;
/**
* ** Confirmation message component.
*
* - Service render provided component in the same place where message text is rendered.
* - Message Component takes precedence before message text. e.g. if both fields are provided, Service will render the Component.
*/
messageComponent?: Type<any>;
/**
* ** Confirmation message code, that would be injected to Message component in initialization time
* before first changeDetection in order to re-use same component for different messages.
*/
messageCode?: string;
}
/**
* ** Supported Confirmation View Buttons.
*/
export interface SupportedButtonsModel {
/**
* ** Model for Confirmation Cancel Button.
*
* - Providing Cancel button model, means this button should be rendered.
*/
cancelBtnModel?: Partial<ButtonModel>;
/**
* ** Model for Confirmation Confirm Button.
*/
confirmBtnModel?: ButtonModel;
}
/**
* ** Generic Button Model in Confirmation view.
*/
export interface ButtonModel {
/**
* ** Button text.
*/
text: string;
/**
* ** Button icon shape.
*/
iconShape?: string;
/**
* ** Button icon position.
*/
iconPosition?: 'left' | 'right';
/**
* ** Button icon direction.
*/
iconDirection?: 'up' | 'down' | 'left' | 'right';
/**
* ** Button icon size.
*/
iconSize?: string | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
/**
* ** Button icon solid.
*/
iconSolid?: boolean;
/**
* ** Button icon inverse.
*/
iconInverse?: boolean;
/**
* ** Button icon status.
*/
iconStatus?: 'info' | 'success' | 'warning' | 'danger';
/**
* ** Button icon badge.
*/
iconBadge?: 'info' | 'success' | 'warning' | 'danger';
}
/**
* ** Confirmation Model implementation that leverage input model and model extension.
*/
export declare class ConfirmationModelImpl implements ConfirmationInputModel, ConfirmationModelExtension {
/**
* @inheritDoc
*/
readonly uuid: string;
/**
* @inheritDoc
*
* - By default it's empty.
*/
readonly title?: string;
/**
* @inheritDoc
*
* - By default it's empty.
*/
readonly message?: string;
/**
* @inheritDoc
*
* - By default is undefined.
*/
readonly messageComponent?: Type<any>;
/**
* @inheritDoc
*
* - By default it's empty.
*/
messageCode?: string;
/**
* @inheritDoc
*
* - By default its FALSE.
*/
readonly closable?: boolean;
/**
* @inheritDoc
*
* - By default its FALSE.
*/
readonly optionDoNotShowFutureConfirmation?: boolean;
/**
* @inheritDoc
*
* - By default its text is Cancel.
*/
readonly cancelBtnModel?: Readonly<ButtonModel>;
/**
* @inheritDoc
*
* - By default its text is Confirm.
*/
readonly confirmBtnModel?: Readonly<ButtonModel>;
/**
* @inheritDoc
*/
readonly handler: ConfirmationHandler;
/**
* ** Constructor.
*/
constructor(model: ConfirmationInputModel);
private _assignButtonModelDefaults;
}
/**
* ** Confirmation Output Model.
*
* - Returned to invoker after User confirmation.
*/
export interface ConfirmationOutputModel {
/**
* ** Field value of true, means User opt-out of showing confirmations with same context in the future.
*/
doNotShowFutureConfirmation: boolean;
}
/**
* ** Confirmation handler.
*/
export interface ConfirmationHandler {
/**
* ** Confirm method, which means User give confirmation.
*/
confirm: (value: ConfirmationOutputModel) => void;
/**
* ** Dismiss (reject) method, which means User don't give confirmation.
*/
dismiss: (reason?: string | Error) => void;
}