<commit_before>/**
 * Created by ketangote on 11/21/17.
 */

 /*
 Component Name : Amexio Checkbox
 Component Selector :  <amexio-checkbox>
 Component Description : Single checkbox having boolean based values.
 
*/
import {Component, EventEmitter, forwardRef, Input, Output} from '@angular/core';
import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms';

const noop = () => {
};

export const CUSTOM_CHECKBOX_CONTROL_VALUE_ACCESSOR: any = {
  provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => AmexioCheckBoxComponent), multi: true
};

@Component({
  selector: 'amexio-checkbox',
  templateUrl: './checkbox.component.html',
  providers: [CUSTOM_CHECKBOX_CONTROL_VALUE_ACCESSOR],
  styleUrls: ['./checkbox.component.scss']
})
export class AmexioCheckBoxComponent implements ControlValueAccessor {

  /*
Properties 
name : field-label
datatype : string
version : 4.0 onwards
default : none 
description : The label of this field
*/
  @Input('field-label') fieldlabel: string;

  /*
Properties 
name : disabled
datatype : boolean
version : 4.0 onwards
default : false
description :  If true will not react on any user events and show disable icon over
*/
  @Input() disabled: boolean;

/*
Properties
name : required
datatype : boolean
version : 4.0 onwards
default : false
description :  property to set if manditory 
*/
  @Input() required: boolean = false;

  /*
Events
name : onSelection
datatype : any
version : none
default : none
description : Event fired on checkbox click.
*/
  @Output() onSelection: any = new EventEmitter<any>();
  /*
Events
name : input
datatype : any
version : none
default : none
description : On input event field.
*/
  @Output() input: any = new EventEmitter<any>();

  isComponentValid :boolean;
  
  constructor() {

  }
  ngOnInit() {
    this.isComponentValid = !this.required;
  }

  onInput(input:any) {
    
    this.isComponentValid = this.value;
    this.input.emit(this.value);
  }
    
    
  onClick() {
    this.value = !this.value;    
    this.isComponentValid = this.value;
    this.onSelection.emit(this.value);
  }

  // The internal dataviews model
  private innerValue: any = '';

  //Placeholders for the callbacks which are later provided
  //by the Control Value Accessor
  private onTouchedCallback: () => void = noop;
  private onChangeCallback: (_: any) => void = noop;

  //get accessor
  get value(): any {
    return this.innerValue;
  }

  //set accessor including call the onchange callback
  set value(v: any) {
    if (v !== this.innerValue) {
      this.innerValue = v;
      this.onChangeCallback(v);
    }
  }

  //Set touched on blur
  onBlur() {
    this.onTouchedCallback();
    // this.showToolTip = false;
  }

  onFocus() {
    // this.showToolTip = true;
  }

  //From ControlValueAccessor interface
  writeValue(value: any) {
    if (value !== this.innerValue) {
      this.innerValue = value;
    }
  }
<commit_msg>Update checkbox.component.ts<commit_after>/**
 * Created by ketangote on 11/21/17.
 */

 /*
 Component Name : Amexio Checkbox
 Component Selector :  <amexio-checkbox>
 Component Description : Single checkbox having boolean based values.
 
*/
import {Component, EventEmitter, forwardRef, Input, Output} from '@angular/core';
import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms';

const noop = () => {
};

export const CUSTOM_CHECKBOX_CONTROL_VALUE_ACCESSOR: any = {
  provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => AmexioCheckBoxComponent), multi: true
};

@Component({
  selector: 'amexio-checkbox',
  templateUrl: './checkbox.component.html',
  providers: [CUSTOM_CHECKBOX_CONTROL_VALUE_ACCESSOR],
  styleUrls: ['./checkbox.component.scss']
})
export class AmexioCheckBoxComponent implements ControlValueAccessor {

  /*
Properties 
name : field-label
datatype : string
version : 4.0 onwards
default : none 
description : The label of this field
*/
  @Input('field-label') fieldlabel: string;

  /*
Properties 
name : disabled
datatype : boolean
version : 4.0 onwards
default : false
description :  If true will not react on any user events and show disable icon over
*/
  @Input() disabled: boolean;

/*
Properties
name : required
datatype : boolean
version : 4.0 onwards
default : false
description :  property to set if manditory 
*/
  @Input() required: boolean = false;

  /*
Events
name : onSelection
datatype : any
version : none
default : none
description : Event fired on checkbox click.
*/
  @Output() onSelection: any = new EventEmitter<any>();
  /*
Events
name : input
datatype : any
version : none
default : none
description : On input event field.
*/
  @Output() input: any = new EventEmitter<any>();

  isComponentValid :boolean;
  
  constructor() {

  }
  ngOnInit() {
    this.isComponentValid = !this.required;
  }

  onInput(input:any) {
    
    this.isComponentValid = this.value;
    this.input.emit(this.value);
  }
    
    
  onClick() {
    this.value = !this.value;    
    this.isComponentValid = this.value;
    this.onSelection.emit(this.value);
  }

  // The internal dataviews model
  private innerValue: any = '';

  //Placeholders for the callbacks which are later provided
  //by the Control Value Accessor
  private onTouchedCallback: () => void = noop;
  private onChangeCallback: (_: any) => void = noop;

  //get accessor
 get value(): any {
    this.isComponentValid = this.innerValue;
    return this.innerValue;
  }

  //set accessor including call the onchange callback
  set value(v: any) {
    if (v !== this.innerValue) {
      this.innerValue = v;
      this.onChangeCallback(v);
    }
  }

  //Set touched on blur
  onBlur() {
    this.onTouchedCallback();
    // this.showToolTip = false;
  }

  onFocus() {
    // this.showToolTip = true;
  }

  //From ControlValueAccessor interface
  writeValue(value: any) {
    if (value !== this.innerValue) {
      this.innerValue = value;
    }
  }

{'fraction_non_alphanumeric': 0.1152865158986567, 'fraction_numerical': 0.004080938615881653, 'mean_word_length': 3.496941896024465, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, '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': '7383905', 'n_tokens_mistral': 1855, 'n_tokens_neox': 1803, 'n_words': 515}