UNPKG

@ctodev/cclibrary-typings

Version:

Library typings for use with CLARC INFINITY

564 lines (563 loc) 16.9 kB
import { ElementRef, EventEmitter, OnDestroy, OnInit } from "@angular/core"; import { TccInputMask } from "../../models/inputMask.model"; import { AbstractControl, UntypedFormControl } from "@angular/forms"; import { TccTranslation } from "../../../odata/models/shared.model"; import { TccValidators } from "../../models/form-error.model"; import { BehaviorSubject, Observable } from "rxjs"; import { TccMessagePopover } from "../tcc-message-popover/tcc-message-popover.component"; import { AppLockStates } from "../../classes/app-context"; /** * Usage Nodes: class extend displayElement * * - include all needed css files. (commonStyles.css is allways needed) * * - implement all abstract functions -> see individual function descriptions * * - html requirements: * - [class.chooseInputElementInvisible]="_element.visible === false" on element container * - use <tcc-element-notification [element]="_element" [notificationClasses]="notificationClasses"></tcc-element-notification> -> see component description for details * - use sizeClasses string for the size of the element * - use colorClasses string for the color of the element * - use customClasses string to set custom classes * - use #activeElement in the user interaction element -> see activeElement description * - call valueChange * - call valueChangeExtended or call this.changeEventExtended(false) in changeElement() * * - add type specific functions (example: addToSelection in tcc-select-element.component) */ export declare abstract class displayElement implements OnInit, OnDestroy { private _elementRef; constructor(_elementRef: ElementRef); /** * the html user interaction element, example: <input #activeElement></input>; <mat-select #activeElement></mat-select>; <button #activeElement></button>; */ activeElement: any; /** * init callback */ initCallback: EventEmitter<displayElement>; /** * valueChange output */ valueChange: EventEmitter<TccInputMask.eventOutput<TccInputMask.ValueUnion>>; /** * valueChange output on every keyPress */ valueChangeExtended: EventEmitter<TccInputMask.eventOutput<TccInputMask.ValueUnion>>; /** * focusEvent output, currently implemented in input, textfield, datepicker, autocomplete, select */ focusEvent: EventEmitter<TccInputMask.eventTrigger>; /** * blurEvent output, currently implemented in input, textfield, datepicker, autocomplete, select */ blurEvent: EventEmitter<TccInputMask.eventTrigger>; /** * inputButtonClickEvent output */ inputButtonClick: EventEmitter<TccInputMask.eventTrigger>; /** *mouseEnter event on a field */ fieldMouseEnter: EventEmitter<TccInputMask.eventTrigger>; /** * mouseLeave event on a field */ fieldMouseLeave: EventEmitter<TccInputMask.eventTrigger>; /** * event to add a row to the collection at the end of the collection */ addRow: EventEmitter<TccInputMask.addRowEvent>; /** * event to add one or more rows to the collection at the end of the collection */ addRowForSuggestion: EventEmitter<TccInputMask.addRowForSuggestionEvent>; /** * event delete a sibling of an collectionElement */ removeCollectionElement: EventEmitter<TccInputMask.eventTrigger>; /** * emits itself on destroy */ onDestroyEvent: EventEmitter<displayElement>; /** * emit every time, a suggestion value is set. */ suggestionValueSet: EventEmitter<void>; /** * emit every time, a suggestion value is removed (accepted or declined). */ suggestionValueRemoved: EventEmitter<void>; /** * emits, if the displayElement wants to be focused (e.g. from messageHub) */ focusRequested: EventEmitter<void>; /** * emits if the surrounding formField was clicked. */ formFieldContainerMouseDown: EventEmitter<TccInputMask.eventTrigger>; /** * sets the formControl, then calls onSetForm for type specific init * * @param {UntypedFormControl} control */ set form(control: UntypedFormControl); /** * sets the element and inits notification, size and color classes, then calls onSetElement for type specific init * * @param {TccInputMask.DisplayElement} data */ set element(element: TccInputMask.DisplayElement); set globalLocked(state: AppLockStates); /** * markes element same as focused * * @param {boolean} markAsFocused */ set markAsFocused(markAsFocused: boolean); permissionLevel: number; protected internalReadyStateSubject: BehaviorSubject<boolean>; private internalReadyState$; ready$: Observable<boolean>; /** * TccInputMask.elementtype */ type: TccInputMask.elementtype; /** * id */ id: string; /** * classes added to the notification element */ notificationClasses: string; /** * classes to set the size of the element */ sizeClasses: string; /** * classes to set the color of the element */ colorClasses: string; /** * classes added to the element */ customClasses: string; /** * formControl */ _formControl: AbstractControl; /** * _inputmaskelementtypes only for html template access */ _inputmaskelementtypes: typeof TccInputMask.elementtype; /** * element */ abstract _element: TccInputMask.DisplayElement; /** * element name */ _name: string | TccTranslation; /** * additional class to add */ _class: string; /** * if the element is hidden */ _hide: boolean; /** * if the element is visible */ _visible: boolean; /** * notifications */ _notification: TccInputMask.notification; /** * prefix with custom icon */ _prefix: string; /** * prefix with material icon */ _matPrefix: string; /** * readonly element */ _readonly: boolean; /** * disabled element */ _disabled: boolean; /** * element color */ _color: TccInputMask.colors; /** * default value */ _default: TccInputMask.ValueUnion; /** * value */ _value: TccInputMask.ValueUnion; /** * width */ _width: TccInputMask.inputWidth; /** * width as string, accepts all css variants */ _widthString: string; /** * validators */ _validators: TccValidators[]; /** * validator names. Cypress test properties need them to know, which validators should be checked. Only standard validators can be checked. */ _activeValidatorNamesForCypress: { min?: number; max?: number; required?: boolean; email?: boolean; minlength?: number; maxlength?: number; pattern?: string; invalidPhoneNumber?: string; }; /** * if the element is a collection element */ _collection: boolean; /** * if customValidator shows an error */ protected customValidatorActive: boolean; /** * value changed by user input or setValue(..., true) */ protected _changedValue: TccInputMask.ValueUnion | TccInputMask.valueChanges; /** * true, if set value started creating rows for a collection element */ private createCollectionStarted; /** * values that are waiting to be set by set value (waiting for row creation) */ protected waitingCollectionValues: { value: TccInputMask.ValueUnion; options?: TccInputMask.setValueOptions; }[]; /** * builds event trigger object with id, section and row of the element * * @returns The eventTrigger */ get changedValue(): TccInputMask.eventOutput; /** * builds event trigger object with id, section and row of the element * * @returns The eventTrigger */ get value(): TccInputMask.eventOutput; /** * builds event trigger object with id, section and row of the element * * @returns The eventTrigger */ get eventTrigger(): TccInputMask.eventTrigger; _isGlobalLocked: boolean; ngOnInit(): void; ngOnDestroy(): void; /** * builds event output object * * @returns The eventOutput */ protected buildEventOutput(notChanged?: boolean): TccInputMask.eventOutput; private setElementColor; /** * copies the properties from the config object to the local variables */ private setProperties; private getValidators; private getValidatorInformationForCypress; /** * builds notification classes string */ private buildNotificationClasses; /** * builds size classes string */ private buildSizeClasses; /** * returns the formControl * * @returns The formControl */ getControl(): AbstractControl; /** * emits the changeEvent -> only on changeEnd * example: inputElement: after change AND focusOut; select: on select option; */ changeEvent(): void; /** * emits the changeEventExtended -> every keydown or any changes to the element * * @param {boolean} changeElement if the element should be changed (_element.value) */ changeEventExtended(changeElement?: boolean): void; /** * emits the focusEvent */ _focusEvent(): void; /** * emits if the surrounding formField was clicked. */ _formFieldContainerMouseDown(): void; /** * focusOutEvent (blurEvent) */ focusOutEvent(): void; /** * fieldMouseEnter */ _fieldMouseEnter(): void; /** * fieldMouseLeave */ _fieldMouseLeave(): void; /** * emits the inputButtonClickEvent */ inputButtonClickEvent(): void; /** * resets the element to its complete init state (using the inputElement config) */ reset(): void; /** * sets the value to the init value. */ resetValue(): void; /** * sets or removes readonly * * @param {boolean} readonly true: element will be set readonly */ setReadonly(readonly: boolean): void; /** * sets or removes disabled * * @param {boolean} disabled true: element will be set disabed */ setDisabled(disabled: boolean): void; /** * sets the visibility of the element to the value * * @param {boolean} visible */ setVisible(visible: boolean): void; /** * shows or hides the element * * @param {boolean} hide true: element will be REMOVED from the html */ hideElement(hide: boolean): void; /** * sets the default of the element to the value * * @param {boolean} keepSetDefaults true: if the element already has a default other than undefined, don't set the default */ setDefault(keepSetDefaults?: boolean): void; /** * sets the value of the element * * @param {TccInputMask.ValueUnion} value * @param {boolean} setValueChange true: set the value in value changes as well */ setValue(value: TccInputMask.ValueUnion, options?: TccInputMask.setValueOptions): void; _setValue(value: TccInputMask.ValueUnion, options?: TccInputMask.setValueOptions, fromAddRow?: boolean): void; /** * Vergleicht zwei Werte, ob sie gleich sind. * @param value1 * @param value2 * @returns true wenn die Werte gleich sind */ protected compare(value1: TccInputMask.ValueUnion, value2: TccInputMask.ValueUnion): boolean; private setWaitingCollectionValue; /** * sets a custom error * * @param {string} errorMessage */ setCustomError(errorMessage: string): void; /** * removes the custom error */ removeCustomError(): void; /** * removes the valueChanges */ clearValueChanges(): void; /** * checks, if the element is focused * * @returns true, if the element is focused */ isFocused(): any; /** * returns, if the formControl is valid * * @returns returns _formControl.valid * */ isValid(): boolean; /** * get the value of the element * * @returns element.value or if the element is a collection, an array of element.value; get typed displayElement for return value type */ getValue(index?: number): any; getChangedValue(): any; /** * get the value of the element (internal), needs to be overwritten in the component * * @returns element.value; get typed displayElement for return value type */ protected abstract _getValue(onlyChanged?: boolean): any; /** * Modifies the value with the returnTransformValueFunction before returning it. For public outputs. * @returns the modified value */ private _getPublicModifiedValue; setNotification(notification: TccInputMask.notification): void; removeNotification(): void; _focusRequested(): void; /** * refreshs the element */ abstract refresh(): void; /** * verifies the element based on the validators * * @returns if the inputMask is valid */ abstract verify(): boolean; /** * sets the focus to the element */ abstract focus(): void; /** * function that will be called in changeEvent, bevor the event is thrown */ protected abstract changeElement(): void; /** * function will be called, after the element is set and standard init is done */ protected abstract onSetElement(): void; /** * function will be called, after the formControl is set */ protected abstract onSetForm(): void; } export declare abstract class displayFullFieldElement extends displayElement { setConfidence: EventEmitter<TccInputMask.eventOutput<number>>; set element(element: TccInputMask.DisplayFullFieldElement); set confidence(confidence: number); get confidence(): number; /** * placeholder in place of the input value */ _placeholder: string; /** * hint below the element */ _hintMessageData: TccMessagePopover.data; /** * label */ _label: boolean; /** * set to true to start highlighting */ _highlighting: boolean; valueSuggestion: { value: TccInputMask.ValueUnion; options: TccInputMask.setValueSuggestionOptions; }; private confidenceErrorSet; private _confidence; private confidenceHintMessageSet; private statusChangeSubscription; Alerticon: { Success: import("../..").TccLibIcons.Icon; Error: import("../..").TccLibIcons.Icon; Info: import("../..").TccLibIcons.Icon; Warning: import("../..").TccLibIcons.Icon; Question: import("../..").TccLibIcons.Icon; }; protected onDestroy(): void; /** * sets the value of the element * * @param {TccInputMask.ValueUnion} value * @param {boolean} setValueChange true: set the value in value changes as well */ setValue(value: TccInputMask.ValueUnion, options?: TccInputMask.setValueOptions): void; /** * sets a value suggestion of the element * * @param {TccInputMask.ValueUnion} value {[key: string]: {Value: primitiveValue | recursive}} * @param {boolean} setValueChange true: set the value in value changes as well */ setValueSuggestion(value: any, options?: TccInputMask.setValueSuggestionOptions): { Value: TccInputMask.ValueUnion; }; /** * sets the current value suggestion as value */ acceptSuggestionValue(): void; /** * discards the current value suggestion */ discardSuggestionValue(event?: MouseEvent): void; /** * starts the highlight animation for the element */ highlight(): void; /** * emits the changeEventExtended -> every keydown or any changes to the element * * @param {boolean} changeElement if the element should be changed (_element.value) */ changeEventExtended(changeElement?: boolean): void; /** * sets the value of the element * * @param {string} errorMessage */ private setConfidenceError; /** * sets success message. Will Only be shown, if no error is shown * * @param {string} message */ setHintMessage(message: string, type?: TccInputMask.notificationType): void; /** * sets success message. Will Only be shown, if no error is shown * * @param {string} message */ removeHintMessage(): void; private mapNotificationTypeToAlertType; } export declare abstract class displayExtraButtonFieldElement extends displayFullFieldElement { set element(element: TccInputMask.DisplayExtraButtonFieldElement); /** * button options */ _button: TccInputMask.extraButtonOptions; }