UNPKG

@knora/action

Version:
112 lines (111 loc) 3.28 kB
import { ElementRef, EventEmitter, OnInit } from '@angular/core'; import { FormBuilder, FormGroup } from '@angular/forms'; import { MatMenuTrigger } from '@angular/material'; import { StringLiteral } from '@knora/api'; export declare class StringLiteralInputComponent implements OnInit { private _fb; languages: string[]; /** * Optional placeholder for the input field e.g. Label * * @param {string} [placeholder='Label'] */ placeholder?: string; /** * Optional predefined (selected) language: en, de, it, fr, etc. * * @param {string} language */ language?: string; /** * Optional form field input type: textarea? set to true for textarea * otherwise it's a simple (short) input field * * @param {boolean} [textarea=false] */ textarea?: boolean; /** * Optional form field value of type StringLiteral[] * * @param {StringLiteral[]} value */ value?: StringLiteral[]; /** * Optional disable the input field in case of no right to edit the field/value * * @param {boolean}: [disabled=false] */ disabled?: boolean; /** * The readonly attribute specifies whether the control may be modified by the user. * * @param {boolean}: [readonly=false] */ readonly?: boolean; /** * Returns (output) an array of StringLiteral on any change on the input field. * * @emits {StringLiteral[]} dataChanged */ dataChanged: EventEmitter<StringLiteral[]>; /** * Returns (output) true when the field was touched. This can be used to validate data, e.g. in case a value is required * * @emits {boolean} touched */ touched: EventEmitter<boolean>; /** * Returns true when a user press ENTER. This can be used to submit data in the parent component. * * * @emits {boolean} enter */ enter: EventEmitter<boolean>; textInput: ElementRef; btnToSelectLanguage: MatMenuTrigger; form: FormGroup; constructor(_fb: FormBuilder); ngOnInit(): void; /** * @ignore * * emit data to parent on any change on the input field */ onValueChanged(): void; toggleAll(): void; /** * @ignore * * Set the language after selecting; This updates the array of StringLiterals: adds item with the selected language if it doesn't exist */ setLanguage(lang: string): void; /** * @ignore * * Switch focus to input field after selecting a language */ switchFocus(): void; /** * @ignore * * Set the value in the input field */ updateFormField(value: string): void; /** * @ignore * * Update the array of StringLiterals depending on value / empty value add or remove item from array. */ updateStringLiterals(lang: string, value?: string): void; /** * @ignore * * In case of strange array of StringLiterals, this method will reset to a API-conform array. This means an array without empty values. */ resetValues(): void; /** * @ignore * * Get the value from array of StringLiterals for the selected language */ getValueFromStringLiteral(lang: string): string; }