<commit_before>import {Component, DynamicComponentLoader, Directive, Input, Output, ViewContainerRef, ElementRef, EventEmitter, OnInit} from '@angular/core';
import {Md2ColorpickerService} from './colorpicker.service';

@Directive({
  selector: '[colorpicker]',
  host: {
    '(input)': 'changeInput($event)',
    '(click)': 'onClick()'
  }
})

export class Md2Colorpicker implements OnInit {
  @Input('colorpicker') colorpicker: string;
  @Input('position') cPosition: string = 'bottom';
  @Input('offset') offset: string = '0';
  @Input('format') format: string = 'hex';
  @Output('colorpickerChange') colorpickerChange = new EventEmitter<string>();
  @Output() change = new EventEmitter<string>();
  private colorpickerDialog: any;
  private created: boolean;

  constructor(private dcl: DynamicComponentLoader, private vcRef: ViewContainerRef, private el: ElementRef, private service: Md2ColorpickerService) {
    this.created = false;
  }

  ngOnInit() {
    if (!this.colorpicker) { this.colorpicker = '#fff'; }
    let hsva: any = this.service.stringToHsva(this.colorpicker);
    if (hsva !== null) {
      this.colorpickerChange.emit(this.service.outputFormat(hsva, this.format));
      this.change.emit(this.service.outputFormat(hsva, this.format));
    }
  }

  onClick() {
    if (!this.created) {
      this.created = true;
      this.dcl.loadNextToLocation(ColorpickerComponent, this.vcRef)
        .then((res) => {
          res.instance.setColorpickerDialog(this, this.el, this.colorpicker, this.cPosition, this.offset, this.format);
          this.colorpickerDialog = res.instance;
        });
    } else if (this.colorpickerDialog) {
      this.colorpickerDialog.setInitialColor(this.colorpicker);
      this.colorpickerDialog.openColorpicker();
    }
  }

  colorChanged(value: string) {
    this.colorpickerChange.emit(value);
    this.change.emit(value);
  }

  changeInput(event: any) {
    let value = event.target.value;
    this.colorpickerDialog.setColorFromString(value)
    this.colorpickerChange.emit(value);<commit_msg>updated defoult color in colorpicker component.<commit_after>import {Component, DynamicComponentLoader, Directive, Input, Output, ViewContainerRef, ElementRef, EventEmitter, OnInit} from '@angular/core';
import {Md2ColorpickerService} from './colorpicker.service';

@Directive({
  selector: '[colorpicker]',
  host: {
    '(input)': 'changeInput($event)',
    '(click)': 'onClick()'
  }
})

export class Md2Colorpicker implements OnInit {
  @Input('colorpicker') colorpicker: string;
  @Input('position') cPosition: string = 'bottom';
  @Input('offset') offset: string = '0';
  @Input('format') format: string = 'hex';
  @Output('colorpickerChange') colorpickerChange = new EventEmitter<string>();
  @Output() change = new EventEmitter<string>();
  private colorpickerDialog: any;
  private created: boolean;

  constructor(private dcl: DynamicComponentLoader, private vcRef: ViewContainerRef, private el: ElementRef, private service: Md2ColorpickerService) {
    this.created = false;
  }

  ngOnInit() {
    if (!this.colorpicker) { this.colorpicker = '#000'; }
    let hsva: any = this.service.stringToHsva(this.colorpicker);
    if (hsva !== null) {
      this.colorpickerChange.emit(this.service.outputFormat(hsva, this.format));
      this.change.emit(this.service.outputFormat(hsva, this.format));
    }
  }

  onClick() {
    if (!this.created) {
      this.created = true;
      this.dcl.loadNextToLocation(ColorpickerComponent, this.vcRef)
        .then((res) => {
          res.instance.setColorpickerDialog(this, this.el, this.colorpicker, this.cPosition, this.offset, this.format);
          this.colorpickerDialog = res.instance;
        });
    } else if (this.colorpickerDialog) {
      this.colorpickerDialog.setInitialColor(this.colorpicker);
      this.colorpickerDialog.openColorpicker();
    }
  }

  colorChanged(value: string) {
    this.colorpickerChange.emit(value);
    this.change.emit(value);
  }

  changeInput(event: any) {
    let value = event.target.value;
    this.colorpickerDialog.setColorFromString(value)
    this.colorpickerChange.emit(value);
{'fraction_non_alphanumeric': 0.13825665859564165, 'fraction_numerical': 0.0026634382566585956, 'mean_word_length': 4.316602316602316, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '1874593', 'n_tokens_mistral': 1265, 'n_tokens_neox': 1242, 'n_words': 244}