<commit_before>import {
    Component, Output, Input, EventEmitter, HostListener, AfterViewInit, OnDestroy,
    SimpleChanges, OnChanges
} from '@angular/core';
import { ControlValueAccessor, NgControl } from '@angular/forms';
import { ITimepickerEvent } from './ITimepickerEvent';

@Component({
    selector: 'datetime',
    template: `
        <div class="form-inline ng2-datetime">
            <div class="input-group date">
                <input id="{{idDatePicker}}" type="text" class="form-control"
                       [attr.readonly]="readonly"
                       [attr.required]="required"
                       [attr.placeholder]="datepickerOptions.placeholder || 'Choose date'"
                       [(ngModel)]="dateModel"
                       (keyup)="checkEmptyValue($event)"/>
                <div [hidden]="datepickerOptions.hideIcon || datepickerOptions === false || false"
                     (click)="showDatepicker()"
                     class="input-group-addon">
                    <span [ngClass]="datepickerOptions.icon || 'glyphicon glyphicon-th'"></span>
                </div>
            </div>
            <div class="input-group bootstrap-timepicker timepicker">
                <input id="{{idTimePicker}}" type="text" class="form-control input-small"
                       [attr.readonly]="readonly"
                       [attr.required]="required"
                       [attr.placeholder]="timepickerOptions.placeholder || 'Set time'"
                       [(ngModel)]="timeModel"
                       (focus)="showTimepicker()"
                       (keyup)="checkEmptyValue($event)">
                <span [hidden]="timepickerOptions.hideIcon || false" class="input-group-addon">
                    <i [ngClass]="timepickerOptions.icon || 'glyphicon glyphicon-time'"></i>
                </span>
            </div>
            <button *ngIf="hasClearButton" type="button" (click)="clearModels()">Clear</button>
        </div>
    `,
    styles: [
        '.ng2-datetime *[hidden] { display: none; }'
    ]
})

export class NKDatetime implements ControlValueAccessor, AfterViewInit, OnDestroy, OnChanges {
    @Output() dateChange: EventEmitter<Date> = new EventEmitter<Date>();
    @Input('timepicker') timepickerOptions: any = {};
    @Input('datepicker') datepickerOptions: any = {};
    @Input('hasClearButton') hasClearButton: boolean = false;
    @Input() readonly: boolean = null;
    @Input() required: boolean = null;

    date: Date; // ngModel
    dateModel: string;
    timeModel: string;

    // instances
    datepicker: any;
    timepicker: any;

    idDatePicker: string = uniqueId('q-datepicker_');
    idTimePicker: string = uniqueId('q-timepicker_');

    @HostListener('dateChange', ['$event'])
    onChange = (_: any) => {
    }
    onTouched = () => {
    }

    constructor(ngControl: NgControl) {
        ngControl.valueAccessor = this; // override valueAccessor
    }

    ngAfterViewInit() {
        this.init();
    }

    ngOnDestroy() {
        if (this.datepicker) {<commit_msg>Add support for tabindex, pass-through to child inputs.<commit_after>import {
    Component, Output, Input, EventEmitter, HostListener, AfterViewInit, OnDestroy,
    SimpleChanges, OnChanges, HostBinding
} from '@angular/core';
import { ControlValueAccessor, NgControl } from '@angular/forms';
import { ITimepickerEvent } from './ITimepickerEvent';

@Component({
    selector: 'datetime',
    template: `
        <div class="form-inline ng2-datetime">
            <div class="input-group date">
                <input id="{{idDatePicker}}" type="text" class="form-control"
                       [attr.readonly]="readonly"
                       [attr.required]="required"
                       [attr.placeholder]="datepickerOptions.placeholder || 'Choose date'"
                       [attr.tabindex]="tabindex"
                       [(ngModel)]="dateModel"
                       (keyup)="checkEmptyValue($event)"/>
                <div [hidden]="datepickerOptions.hideIcon || datepickerOptions === false || false"
                     (click)="showDatepicker()"
                     class="input-group-addon">
                    <span [ngClass]="datepickerOptions.icon || 'glyphicon glyphicon-th'"></span>
                </div>
            </div>
            <div class="input-group bootstrap-timepicker timepicker">
                <input id="{{idTimePicker}}" type="text" class="form-control input-small"
                       [attr.readonly]="readonly"
                       [attr.required]="required"
                       [attr.placeholder]="timepickerOptions.placeholder || 'Set time'"
                       [attr.tabindex]="tabindex"
                       [(ngModel)]="timeModel"
                       (focus)="showTimepicker()"
                       (keyup)="checkEmptyValue($event)">
                <span [hidden]="timepickerOptions.hideIcon || false" class="input-group-addon">
                    <i [ngClass]="timepickerOptions.icon || 'glyphicon glyphicon-time'"></i>
                </span>
            </div>
            <button *ngIf="hasClearButton" type="button" (click)="clearModels()">Clear</button>
        </div>
    `,
    styles: [
        '.ng2-datetime *[hidden] { display: none; }'
    ]
})

export class NKDatetime implements ControlValueAccessor, AfterViewInit, OnDestroy, OnChanges {
    @Output() dateChange: EventEmitter<Date> = new EventEmitter<Date>();
    @Input('timepicker') timepickerOptions: any = {};
    @Input('datepicker') datepickerOptions: any = {};
    @Input('hasClearButton') hasClearButton: boolean = false;
    @Input() readonly: boolean = null;
    @Input() required: boolean = null;
    @Input() tabindex: string;

    date: Date; // ngModel
    dateModel: string;
    timeModel: string;

    // instances
    datepicker: any;
    timepicker: any;

    idDatePicker: string = uniqueId('q-datepicker_');
    idTimePicker: string = uniqueId('q-timepicker_');

    @HostListener('dateChange', ['$event'])
    onChange = (_: any) => {
    }
    onTouched = () => {
    }

    @HostBinding('attr.tabindex')
    get tabindexAttr(): string {
        return this.tabindex === undefined ? '-1' : undefined;
    }

    constructor(ngControl: NgControl) {
        ngControl.valueAccessor = this; // override valueAccessor
    }

    ngAfterViewInit() {
        this.init();
    }

    ngOnDestroy() {
        if (this.datepicker) {
{'fraction_non_alphanumeric': 0.1435436366454813, 'fraction_numerical': 0.0007750736319950396, 'mean_word_length': 2.2751269035532995, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 47, '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': '906716', 'n_tokens_mistral': 1793, 'n_tokens_neox': 1687, 'n_words': 336}