<commit_before>import {AfterContentInit, Component, ContentChild, Input} from '@angular/core';
import {RequiredValidator} from '@angular/forms';
import {FormControlNameDirective} from '../directive/form-control-name.directive';
// "hf-field,{'hf-field--required': required},{'hf-field--invalid': !valid},{'hf-field--valid-value-changes': !validValueChanges}"
@Component({
  selector: 'hf-form-control',
  template: `
    <div [ngClass]="{'hf-field': true, 'hf-field--required': required, 'hf-field--invalid': !valid, 'hf-field--valid-value-changes': validValueChanges}">
      <label class="hf-field__label">{{label}}</label>
      <span class="hf-field__control"><ng-content></ng-content></span>
      <label *ngIf="!valid" class="hf-field__errors">{{errors|json}}</label>
    </div>`
})
export class FormControlComponent implements AfterContentInit {
  @Input() label: string;

  @ContentChild(RequiredValidator)
  requiredValidator: RequiredValidator;

  @ContentChild(FormControlNameDirective)
  formControlNameDirective: FormControlNameDirective;

  validValueChanges = false;

  ngAfterContentInit(): void {
    this.formControlNameDirective.formControlValidValueDebounceStarted.subscribe(_ => this.validValueChanges = true);
    this.formControlNameDirective.formControlValidValueChange.subscribe(_ => this.validValueChanges = false);
  }

  get required() {
    return this.requiredValidator && this.requiredValidator.required;
  }

  get valid() {
    return this.formControlNameDirective &&
      (this.formControlNameDirective.groupSubmitted && this.formControlNameDirective.pristine || this.formControlNameDirective.valid);
  }

  get errors() {
    return this.formControlNameDirective.errors;
  }
}
<commit_msg>ngclass errors<commit_after>import {AfterContentInit, Component, ContentChild, Input} from '@angular/core';
import {RequiredValidator} from '@angular/forms';
import {FormControlNameDirective} from '../directive/form-control-name.directive';

@Component({
  selector: 'hf-form-control',
  template: `
    <div class="hf-field"
         [class.hf-field--required]="required" 
         [class.hf-field--invalid]="!valid" 
         [hf-field--valid-value-changes]="validValueChanges">
      <label class="hf-field__label">{{label}}</label>
      <span class="hf-field__control"><ng-content></ng-content></span>
      <label *ngIf="!valid" class="hf-field__errors">{{errors|json}}</label>
    </div>`
})
export class FormControlComponent implements AfterContentInit {
  @Input() label: string;

  @ContentChild(RequiredValidator)
  requiredValidator: RequiredValidator;

  @ContentChild(FormControlNameDirective)
  formControlNameDirective: FormControlNameDirective;

  validValueChanges = false;

  ngAfterContentInit(): void {
    this.formControlNameDirective.formControlValidValueDebounceStarted.subscribe(_ => this.validValueChanges = true);
    this.formControlNameDirective.formControlValidValueChange.subscribe(_ => this.validValueChanges = false);
  }

  get required() {
    return this.requiredValidator && this.requiredValidator.required;
  }

  get valid() {
    return this.formControlNameDirective &&
      (this.formControlNameDirective.groupSubmitted && this.formControlNameDirective.pristine || this.formControlNameDirective.valid);
  }

  get errors() {
    return this.formControlNameDirective && this.formControlNameDirective.errors;
  }
}

{'fraction_non_alphanumeric': 0.13812481514344868, 'fraction_numerical': 0.0, 'mean_word_length': 5.333333333333333, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 27, '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': '3218499', 'n_tokens_mistral': 986, 'n_tokens_neox': 957, 'n_words': 154}