@kephas/angular
Version:
Provides integration capabilities with Angular.
158 lines (157 loc) • 4.87 kB
TypeScript
import { ElementRef, ViewContainerRef } from '@angular/core';
import { ControlValueAccessor } from '@angular/forms';
import { WidgetBase } from '../../public-api';
/**
* Provides a base implementation for value editors.
*
* @export
* @abstract
* @class ValueEditorBase
* @implements {OnInit}
* @implements {AfterViewInit}
* @implements {ControlValueAccessor}
* @template TValue The value type.
*/
export declare abstract class ValueEditorBase<TValue> extends WidgetBase implements ControlValueAccessor {
/**
* Gets or sets the value description.
*
* @type {string}
* @memberof ValueEditorBase
*/
description?: string;
/**
* Gets or sets the value prompt.
*
* @type {string}
* @memberof ValueEditorBase
*/
prompt?: string;
/**
* Gets or sets a value indicating whether the value is changed from the change event.
*
* @protected
* @memberof ValueEditorBase
*/
protected valueChangeFromEvent: boolean;
/**
* Gets or sets a value indicating whether the value is changed from the value property.
*
* @protected
* @memberof ValueEditorBase
*/
protected valueChangeFromValue: boolean;
private _valueBeforeChange?;
/**
* Creates an instance of ValueEditorBase.
*
* @param {ElementRef} elementRef The element reference.
* @param {ViewContainerRef} viewContainerRef The view container reference.
* @memberof ValueEditorBase
*/
constructor(elementRef: ElementRef, viewContainerRef: ViewContainerRef);
/**
* Gets or sets the value to edit.
*
* @type {TValue}
* @memberOf ValueEditorBase
*/
get value(): TValue;
set value(value: TValue);
/**
* Updates the underlying editor with the provided value.
*
* @protected
* @param {TValue} value
* @returns {boolean}
* @memberof ValueEditorBase
*/
protected updateEditor(value: TValue): boolean;
/**
* Overridable method invoked when the value is about to be changed.
*
* @protected
* @param {(TValue | undefined)} oldValue The old value.
* @param {(TValue | undefined)} newValue The new value.
* @memberof ValueEditorBase
*/
protected onValueChanging(oldValue: TValue | undefined, newValue: TValue | undefined): void;
/**
* Overridable method invoked after the value was changed.
*
* @protected
* @param {(TValue | undefined)} oldValue The old value.
* @param {(TValue | undefined)} newValue The new value.
* @memberof ValueEditorBase
*/
protected onValueChanged(oldValue: TValue | undefined, newValue: TValue | undefined): void;
/**
* Callback invoked from the change event of the underlying editor.
*
* @protected
* @param {*} e
* @returns
* @memberof PropertyEditorComponent
*/
protected onEditorChange(e: any): void;
/**
* Sets the value of the underlying editor.
*
* @protected
* @param {TValue} value The value to be set.
* @memberof ValueEditorBase
*/
protected abstract setEditorValue(value: TValue): void;
/**
* Gets the underlying editor's value.
*
* @protected
* @returns {TValue} The widget value.
* @memberof ValueEditorBase
*/
protected abstract getEditorValue(): TValue;
/**
* Gets the underlying editor's value upon change.
*
* @protected
* @param {*} e The change event arguments.
* @returns {TValue} The widget value.
* @memberof ValueEditorBase
*/
protected getEditorValueOnChange(e: any): TValue;
/**
* Write a new value to the element.
*
* @param {*} obj The new value.
*
* @memberOf PropertyEditorComponent
*/
writeValue(obj: any): void;
/**
* Set the function to be called when the control receives a change event.
*
* @param {*} fn The callback function.
*
* @memberOf PropertyEditorComponent
*/
registerOnChange(fn: any): void;
/**
* Set the function to be called when the control receives a touch event.
*
* @param {*} fn The callback function.
*
* @memberOf PropertyEditorComponent
*/
registerOnTouched(fn: any): void;
/**
* This function is called when the control status changes to or from "DISABLED".
* Depending on the value, it will enable or disable the appropriate DOM element.
*
* @param {boolean} isDisabled True if the state is disabled.
*
* @memberOf PropertyEditorComponent
*/
setDisabledState(isDisabled: boolean): void;
private _onChange;
private _onTouched;
}