ngx-input-eip
Version:
Lightweight edit in place text editor.
188 lines (187 loc) • 8.3 kB
TypeScript
import { AfterViewInit, ElementRef, EventEmitter, OnChanges, OnDestroy, OnInit, SimpleChanges, TemplateRef } from '@angular/core';
import { AbstractControl, ControlValueAccessor, FormGroup, ValidatorFn } from '@angular/forms';
import { BaseClass } from '../lib/ancestors/base';
import { CustomSubmitEvent } from '../lib/custom-events';
import { ActionBarMode, InputSettings } from '../lib/input-settings';
import { Observable } from 'rxjs';
import * as i0 from "@angular/core";
export declare class NgxInputEipComponent extends BaseClass implements OnInit, AfterViewInit, OnDestroy, ControlValueAccessor, OnChanges {
onSubmit: EventEmitter<CustomSubmitEvent>;
onCancel: EventEmitter<void>;
/**
* Emit events using this subject.
* The events that will be emitted outside will be filtered.
*/
private areUnsavedChanges$;
_areUnsavedChanges: Observable<boolean>;
/**
* This events are listened and emitted from the input.
*/
onChange: EventEmitter<Event>;
onInput: EventEmitter<Event>;
onClick: EventEmitter<MouseEvent>;
onFocus: EventEmitter<FocusEvent>;
onResize: EventEmitter<UIEvent>;
onDblclick: EventEmitter<MouseEvent>;
onBlur: EventEmitter<FocusEvent>;
onKeyDown: EventEmitter<KeyboardEvent>;
onKeyPress: EventEmitter<KeyboardEvent>;
onKeyUp: EventEmitter<KeyboardEvent>;
input?: ElementRef;
/**
* @description
* If the input is `short`, it will appear as a common text input.
* If the input is `long`, it will appear as a textarea.
*/
isShort: InputSettings['isShort'];
/**
* @description
* If this input is mandatory, it cannot be empty.
* Otherwise its invalid.
*/
isMandatory: InputSettings['isMandatory'];
/**
* @description
* If this flag is enabled, errors will be shown.
*/
enableValidations: InputSettings['enableValidations'];
inputStyle: InputSettings['inputStyle'];
/**
* @description
* The placeholder for the input.
*/
placeholder: InputSettings['placeholder'];
/**
* @description
* The label for the input.
* Its not mandatory;
* It's possible to pass a custom html-style label too, with `<span label ></span>` attribute.
*/
label: InputSettings['label'];
/**
* @description
* Show/Hide label.
* This will hide both html-style and text-style labels.
*/
showLabel: InputSettings['showLabel'];
submitButtonLabel: InputSettings['submitButtonLabel'];
cancelButtonLabel: InputSettings['cancelButtonLabel'];
private readonly avaliableActionbarMode;
actionbarMode: InputSettings['actionbarMode'];
get validActionbarMode(): boolean;
get defaultActionbarMode(): ActionBarMode | 'd-none';
get actionbarClass(): ActionBarMode | 'd-none';
animateActionbar: InputSettings['animateActionbar'];
get showActionsBar(): boolean;
/**
* Ask confirm/deny or save automatically.
*/
set autosave(v: boolean | null);
protected _autosave: InputSettings['autosave'];
get autosave(): boolean;
classes: InputSettings['classes'];
/**
* Adding custom user validators.
*/
customValidators: InputSettings['customValidators'];
get validators(): ValidatorFn[];
set isDisabled(v: boolean);
protected _isDisabled: InputSettings['isDisabled'];
get isDisabled(): boolean;
/**
* Is a input that allows numbers only?
* If yes:
* - Any non-number character will be removed.
* - Arrow up will increase the value by 1.
* - Arrow down will decrease the value by 1.
* - If the value is empty, it will be set to 0.
* - If the value is not a number, it will be set to 0.
*/
numbersOnly: InputSettings['numbersOnly'];
/**
* Minimum value for numerical inputs.
*/
min: InputSettings['min'];
/**
* Maximum value for numerical inputs.
*/
max: InputSettings['max'];
maxLength: InputSettings['maxLength'];
minLength: InputSettings['minLength'];
showErrors: InputSettings['showErrors'];
selectOnFocus: InputSettings['selectOnFocus'];
/**
* @description if false and form invalid, changes will not be emitted.
*/
allowInvalid: InputSettings['allowInvalid'];
customErrorMessages: InputSettings['customErrorMessages'];
customErrorsMap: InputSettings['customErrorsMap'];
errorsParser?: InputSettings['errorsParser'] | null;
get allErrorsMessages(): (string | TemplateRef<any>)[];
get stringErrorMessages(): string[];
get templateErrorMessages(): TemplateRef<any>[];
get hasErrors(): boolean;
get value(): string;
set value(value: string);
form: FormGroup;
get control(): AbstractControl;
get isLong(): boolean;
get invalidForm(): boolean;
get showInvalidStatus(): boolean;
get isEmpty(): boolean;
get inputStatusClass(): string;
set overwriteValue(v: any);
get areUnsavedChanges(): boolean;
get debugJson(): any;
readonly id: string;
readonly debugMode: boolean;
protected emittedValue: string;
protected onChangeTimeout: any;
protected _registerOnTouched: (v?: any) => any;
protected _registerOnChange: (v?: any) => any;
/**
* CONSTRUCTOR NOT NEEDED HERE
*/
/*****************************************************************
* Angular lifecycle hooks
*****************************************************************/
ngOnInit(): void;
ngAfterViewInit(): void;
ngOnDestroy(): void;
/**
* Triggered when any input changes.
*/
ngOnChanges(changes: SimpleChanges): void;
ngDoCheck(...args: any[]): void;
ngAfterContentInit(...args: any[]): void;
ngAfterContentChecked(...args: any[]): void;
ngAfterViewChecked(...args: any[]): void;
/*****************************************************************
* Public methods
*****************************************************************/
afterKeyDown(ev: KeyboardEvent): void;
afterInput(ev: any): void;
afterClick(ev: MouseEvent): void;
afterFocus(ev: any): void;
focus(): void;
submit(): void;
cancel(): void;
valueChanges(): void;
writeValue(obj: unknown): void;
registerOnChange(fn: any): void;
registerOnTouched(fn: any): void;
setDisabledState(isDisabled: boolean): void;
textareaFocus(event: FocusEvent): void;
triggerResize(): void;
/*****************************************************************
* Private/Protected methods
****************************************************************/
protected emitChanges(): void;
protected formatValue(v: string): string;
protected blur(): void;
protected updateValidators(): void;
protected validateInputs(): void;
protected emitAreUnsavedChanges(): void;
static ɵfac: i0.ɵɵFactoryDeclaration<NgxInputEipComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<NgxInputEipComponent, "ngx-input-eip", never, { "isShort": "isShort"; "isMandatory": "isMandatory"; "enableValidations": "enableValidations"; "inputStyle": "inputStyle"; "placeholder": "placeholder"; "label": "label"; "showLabel": "showLabel"; "submitButtonLabel": "submitButtonLabel"; "cancelButtonLabel": "cancelButtonLabel"; "actionbarMode": "actionbarMode"; "animateActionbar": "animateActionbar"; "autosave": "autosave"; "classes": "classes"; "customValidators": "customValidators"; "isDisabled": "isDisabled"; "numbersOnly": "numbersOnly"; "min": "min"; "max": "max"; "maxLength": "maxLength"; "minLength": "minLength"; "showErrors": "showErrors"; "selectOnFocus": "selectOnFocus"; "allowInvalid": "allowInvalid"; "customErrorMessages": "customErrorMessages"; "customErrorsMap": "customErrorsMap"; "errorsParser": "errorsParser"; "overwriteValue": "value"; }, { "onSubmit": "onSubmit"; "onCancel": "onCancel"; "_areUnsavedChanges": "areUnsavedChanges"; "onChange": "onChange"; "onInput": "onInput"; "onClick": "onClick"; "onFocus": "onFocus"; "onResize": "onResize"; "onDblclick": "onDblclick"; "onBlur": "onBlur"; "onKeyDown": "onKeyDown"; "onKeyPress": "onKeyPress"; "onKeyUp": "onKeyUp"; }, never, ["[label]", "[errors]", "[error]", "[after-input]", "[submitButton]", "[cancelButton]"], false, never>;
}