<commit_before>import { Directive, Input, ElementRef, AfterContentInit, HostListener } from '@angular/core';
import { NgControl } from '@angular/forms';

import $ from 'jquery';
import { Mask } from './mask';
import { MaskService } from './mask.service';

require('jquery-mask-plugin');

@Directive({
  selector: '[mask]',
  providers: [MaskService]
})
export class MaskDirective implements AfterContentInit {

  @Input() mask: Mask|string;

  constructor(
    private elementRef: ElementRef,
    private ngControl: NgControl,
    private maskService: MaskService
  ) { }

  ngAfterContentInit() {
    if (!this.mask) {

      return;
    }

    if (this.mask instanceof Mask && this.mask.pattern) {
      $(this.elementRef.nativeElement).mask(this.mask.pattern, this.mask.options);
    } else if (typeof this.mask === 'string' && this.mask.length > 0) {
      const mask: Mask = this.maskService.createMask(this.mask);
      console.log(mask);

      if (mask) {
        $(this.elementRef.nativeElement).mask(mask.pattern, mask.options);
      }
    }
  }

  @HostListener('blur') onBlur() {
    this.ngControl.control.setValue(this.elementRef.nativeElement.value);
  }
}<commit_msg>[UPDATE] Updates MaskDirective and removes console.log<commit_after>import { Directive, Input, ElementRef, AfterContentInit, HostListener } from '@angular/core';
import { NgControl } from '@angular/forms';

import $ from 'jquery';
import { Mask } from './mask';
import { MaskService } from './mask.service';

require('jquery-mask-plugin');

@Directive({
  selector: '[mask]',
  providers: [MaskService]
})
export class MaskDirective implements AfterContentInit {

  @Input() mask: Mask|string;

  constructor(
    private elementRef: ElementRef,
    private ngControl: NgControl,
    private maskService: MaskService
  ) { }

  ngAfterContentInit() {
    if (!this.mask) {

      return;
    }

    if (this.mask instanceof Mask && this.mask.pattern) {
      this.setInputMask(this.mask);
    } else if (typeof this.mask === 'string' && this.mask.length > 0) {
      const mask: Mask = this.maskService.createMask(this.mask);

      if (mask) {
        this.setInputMask(mask);
      }
    }
  }

  private setInputMask(mask: Mask) {
    $(this.elementRef.nativeElement).mask(mask.pattern, mask.options);
  }

  @HostListener('blur') onBlur() {
    this.ngControl.control.setValue(this.elementRef.nativeElement.value);
  }
}
{'fraction_non_alphanumeric': 0.14327242524916944, 'fraction_numerical': 0.0008305647840531562, 'mean_word_length': 3.6595744680851063, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5142180', 'n_tokens_mistral': 749, 'n_tokens_neox': 730, 'n_words': 161}