Skip to content
Snippets Groups Projects
text-field-element.ts 1.39 KiB
Newer Older
  • Learn to ignore specific revisions
  • import { InputElement, UIElement } from './uI-element';
    
    rhenck's avatar
    rhenck committed
    import { FontElement, SurfaceUIElement } from '../interfaces/UIElementInterfaces';
    
    import { initFontElement, initSurfaceElement } from '../util/unit-interface-initializer';
    
    rhenck's avatar
    rhenck committed
    
    export class TextFieldElement extends InputElement implements FontElement, SurfaceUIElement {
      appearance: 'standard' | 'legacy' | 'fill' | 'outline' = 'outline';
    
      minLength: number = 0;
    
    rhenck's avatar
    rhenck committed
      minLengthWarnMessage: string = 'Eingabe zu kurz';
    
      maxLength: number = 0;
    
    rhenck's avatar
    rhenck committed
      maxLengthWarnMessage: string = 'Eingabe zu lang';
      pattern: string = '';
      patternWarnMessage: string = 'Eingabe entspricht nicht der Vorgabe';
    
    
    rhenck's avatar
    rhenck committed
      inputAssistancePreset: 'none' | 'french' | 'numbers' | 'numbersAndOperators' = 'none';
    
      clearable: boolean = false;
    
    
    rhenck's avatar
    rhenck committed
      fontColor: string = 'black';
      font: string = 'Roboto';
      fontSize: number = 18;
      bold: boolean = false;
      italic: boolean = false;
      underline: boolean = false;
    
      backgroundColor: string = 'transparent';
    
      constructor(serializedElement: UIElement, coordinates?: { x: number; y: number }) {
        super(serializedElement, coordinates);
        Object.assign(this, serializedElement);
    
        Object.assign(this, initFontElement(serializedElement));
        Object.assign(this, initSurfaceElement(serializedElement));
    
    rhenck's avatar
    rhenck committed
    
    
        this.height = serializedElement.height || 100;
        this.backgroundColor = serializedElement.backgroundColor as string || 'transparent';
    
    rhenck's avatar
    rhenck committed
      }
    }