<commit_before>import {
    AfterViewInit,
    ChangeDetectorRef,
    Component,
    Input,
    TemplateRef,
    ViewChild,
    ViewChildren,
    QueryList,
    ElementRef,
    HostBinding,
    HostListener,
    ChangeDetectionStrategy,
    ViewRef
} from '@angular/core';
import { DataType, DataUtil } from '../../../data-operations/data-util';
import { IgxColumnComponent } from '../../columns/column.component';
import { IgxDropDownComponent, ISelectionEventArgs } from '../../../drop-down/index';
import { IFilteringOperation } from '../../../data-operations/filtering-condition';
import { FilteringLogic, IFilteringExpression } from '../../../data-operations/filtering-expression.interface';
import { HorizontalAlignment, VerticalAlignment, OverlaySettings } from '../../../services/overlay/utilities';
import { ConnectedPositioningStrategy } from '../../../services/overlay/position/connected-positioning-strategy';
import { IBaseChipEventArgs, IgxChipsAreaComponent, IgxChipComponent } from '../../../chips';
import { ExpressionUI } from '../grid-filtering.service';
import { IgxDropDownItemComponent } from '../../../drop-down/drop-down-item.component';
import { IgxFilteringService } from '../grid-filtering.service';
import { KEYS, isEdge } from '../../../core/utils';
import { AbsoluteScrollStrategy } from '../../../services/overlay/scroll';

/**
 * @hidden
 */
@Component({
    changeDetection: ChangeDetectionStrategy.OnPush,
    preserveWhitespaces: false,
    selector: 'igx-grid-filtering-row',
    templateUrl: './grid-filtering-row.component.html'
})
export class IgxGridFilteringRowComponent implements AfterViewInit {

    private _positionSettings = {
        horizontalStartPoint: HorizontalAlignment.Left,
        verticalStartPoint: VerticalAlignment.Bottom
    };

    private _conditionsOverlaySettings: OverlaySettings = {
        excludePositionTarget: true,
        closeOnOutsideClick: true,
        modal: false,
        scrollStrategy: new AbsoluteScrollStrategy(),
        positionStrategy: new ConnectedPositioningStrategy(this._positionSettings)
    };

    private _operatorsOverlaySettings: OverlaySettings = {
        excludePositionTarget: true,
        closeOnOutsideClick: true,
        modal: false,
        scrollStrategy: new AbsoluteScrollStrategy(),
        positionStrategy: new ConnectedPositioningStrategy(this._positionSettings)
    };

    private chipsAreaWidth: number;
    private chipAreaScrollOffset = 0;
    private _column = null;
    private isKeyPressed = false;
    private isComposing = false;
    private _cancelChipClick = false;

    public showArrows: boolean;
    public expression: IFilteringExpression;
    public expressionsList: Array<ExpressionUI>;

    @Input()
    get column(): IgxColumnComponent {
        return this._column;
    }

    set column(val) {
        if (this._column) {
            this.expressionsList.forEach(exp => exp.isSelected = false);
        }
        if (val) {
            this._column = val;

            this.expressionsList = this.filteringService.getExpressions(this._column.field);
            this.resetExpression();

            this.chipAreaScrollOffset = 0;
            this.transform(this.chipAreaScrollOffset);
        }
    }

    @Input()
    get value(): any {
        return this.expression ? this.expression.searchVal : null;
    }

    set value(val) {
        if (!val && val !== 0) {
            this.expression.searchVal = null;
            this.showHideArrowButtons();
        } else {
            this.expression.searchVal = DataUtil.parseValue(this.column.dataType, val);
            if (this.expressionsList.find(item => item.expression === this.expression) === undefined) {
                this.addExpression(true);
            }
        }

        this.filter();
    }

    @ViewChild('defaultFilterUI', { read: TemplateRef, static: true })
    protected defaultFilterUI: TemplateRef<any>;

    @ViewChild('defaultDateUI', { read: TemplateRef, static: true })
    protected defaultDateUI: TemplateRef<any>;

    @ViewChild('input', { read: ElementRef })
    protected input: ElementRef;

    @ViewChild('inputGroupConditions', { read: IgxDropDownComponent, static: true })
    protected dropDownConditions: IgxDropDownComponent;

    @ViewChild('chipsArea', { read: IgxChipsAreaComponent, static: true })
    protected chipsArea: IgxChipsAreaComponent;

    @ViewChildren('operators', { read: IgxDropDownComponent })
    protected dropDownOperators: QueryList<IgxDropDownComponent>;

    @ViewChild('inputGroup', { read: ElementRef })
    protected inputGroup: ElementRef;

    @ViewChild('inputGroupPrefix', { read: ElementRef })
    protected inputGroupPrefix: ElementRef;

    @ViewChild('container', { static: true })
    protected container: ElementRef;

    @ViewChild('operand')
    protected operand: ElementRef;

    @ViewChild('closeButton', { static: true })
    public closeButton: ElementRef;

    @HostBinding('class.igx-grid__filtering-row')
    public cssClass = 'igx-grid__filtering-row';

    constructor(public filteringService: IgxFilteringService, public element: ElementRef, public cdr: ChangeDetectorRef) { }

    ngAfterViewInit() {
        this._conditionsOverlaySettings.outlet = this.column.grid.outletDirective;
        this._operatorsOverlaySettings.outlet = this.column.grid.outletDirective;

        const selectedItem = this.expressionsList.find(expr => expr.isSelected === true);
        if (selectedItem) {
            this.expression = selectedItem.expression;
        }

        this.input.nativeElement.focus();
    }

    @HostListener('keydown.shift.tab', ['$event'])
    @HostListener('keydown.tab', ['$event'])
    public onTabKeydown(event) {
        event.stopPropagation();
        if (document.activeElement === this.closeButton.nativeElement && !event.shiftKey) {
            this.filteringService.grid.navigation.navigateFirstCellIfPossible(event);
        }
    }

    @HostListener('keydown.esc', ['$event'])
    public onEscKeydown(event) {
        event.preventDefault();
        event.stopPropagation();
        this.close();<commit_msg>chore(*): tab bahavior should be determined<commit_after>import {
    AfterViewInit,
    ChangeDetectorRef,
    Component,
    Input,
    TemplateRef,
    ViewChild,
    ViewChildren,
    QueryList,
    ElementRef,
    HostBinding,
    HostListener,
    ChangeDetectionStrategy,
    ViewRef
} from '@angular/core';
import { DataType, DataUtil } from '../../../data-operations/data-util';
import { IgxColumnComponent } from '../../columns/column.component';
import { IgxDropDownComponent, ISelectionEventArgs } from '../../../drop-down/index';
import { IFilteringOperation } from '../../../data-operations/filtering-condition';
import { FilteringLogic, IFilteringExpression } from '../../../data-operations/filtering-expression.interface';
import { HorizontalAlignment, VerticalAlignment, OverlaySettings } from '../../../services/overlay/utilities';
import { ConnectedPositioningStrategy } from '../../../services/overlay/position/connected-positioning-strategy';
import { IBaseChipEventArgs, IgxChipsAreaComponent, IgxChipComponent } from '../../../chips';
import { ExpressionUI } from '../grid-filtering.service';
import { IgxDropDownItemComponent } from '../../../drop-down/drop-down-item.component';
import { IgxFilteringService } from '../grid-filtering.service';
import { KEYS, isEdge } from '../../../core/utils';
import { AbsoluteScrollStrategy } from '../../../services/overlay/scroll';

/**
 * @hidden
 */
@Component({
    changeDetection: ChangeDetectionStrategy.OnPush,
    preserveWhitespaces: false,
    selector: 'igx-grid-filtering-row',
    templateUrl: './grid-filtering-row.component.html'
})
export class IgxGridFilteringRowComponent implements AfterViewInit {

    private _positionSettings = {
        horizontalStartPoint: HorizontalAlignment.Left,
        verticalStartPoint: VerticalAlignment.Bottom
    };

    private _conditionsOverlaySettings: OverlaySettings = {
        excludePositionTarget: true,
        closeOnOutsideClick: true,
        modal: false,
        scrollStrategy: new AbsoluteScrollStrategy(),
        positionStrategy: new ConnectedPositioningStrategy(this._positionSettings)
    };

    private _operatorsOverlaySettings: OverlaySettings = {
        excludePositionTarget: true,
        closeOnOutsideClick: true,
        modal: false,
        scrollStrategy: new AbsoluteScrollStrategy(),
        positionStrategy: new ConnectedPositioningStrategy(this._positionSettings)
    };

    private chipsAreaWidth: number;
    private chipAreaScrollOffset = 0;
    private _column = null;
    private isKeyPressed = false;
    private isComposing = false;
    private _cancelChipClick = false;

    public showArrows: boolean;
    public expression: IFilteringExpression;
    public expressionsList: Array<ExpressionUI>;

    @Input()
    get column(): IgxColumnComponent {
        return this._column;
    }

    set column(val) {
        if (this._column) {
            this.expressionsList.forEach(exp => exp.isSelected = false);
        }
        if (val) {
            this._column = val;

            this.expressionsList = this.filteringService.getExpressions(this._column.field);
            this.resetExpression();

            this.chipAreaScrollOffset = 0;
            this.transform(this.chipAreaScrollOffset);
        }
    }

    @Input()
    get value(): any {
        return this.expression ? this.expression.searchVal : null;
    }

    set value(val) {
        if (!val && val !== 0) {
            this.expression.searchVal = null;
            this.showHideArrowButtons();
        } else {
            this.expression.searchVal = DataUtil.parseValue(this.column.dataType, val);
            if (this.expressionsList.find(item => item.expression === this.expression) === undefined) {
                this.addExpression(true);
            }
        }

        this.filter();
    }

    @ViewChild('defaultFilterUI', { read: TemplateRef, static: true })
    protected defaultFilterUI: TemplateRef<any>;

    @ViewChild('defaultDateUI', { read: TemplateRef, static: true })
    protected defaultDateUI: TemplateRef<any>;

    @ViewChild('input', { read: ElementRef })
    protected input: ElementRef;

    @ViewChild('inputGroupConditions', { read: IgxDropDownComponent, static: true })
    protected dropDownConditions: IgxDropDownComponent;

    @ViewChild('chipsArea', { read: IgxChipsAreaComponent, static: true })
    protected chipsArea: IgxChipsAreaComponent;

    @ViewChildren('operators', { read: IgxDropDownComponent })
    protected dropDownOperators: QueryList<IgxDropDownComponent>;

    @ViewChild('inputGroup', { read: ElementRef })
    protected inputGroup: ElementRef;

    @ViewChild('inputGroupPrefix', { read: ElementRef })
    protected inputGroupPrefix: ElementRef;

    @ViewChild('container', { static: true })
    protected container: ElementRef;

    @ViewChild('operand')
    protected operand: ElementRef;

    @ViewChild('closeButton', { static: true })
    public closeButton: ElementRef;

    @HostBinding('class.igx-grid__filtering-row')
    public cssClass = 'igx-grid__filtering-row';

    constructor(public filteringService: IgxFilteringService, public element: ElementRef, public cdr: ChangeDetectorRef) { }

    ngAfterViewInit() {
        this._conditionsOverlaySettings.outlet = this.column.grid.outletDirective;
        this._operatorsOverlaySettings.outlet = this.column.grid.outletDirective;

        const selectedItem = this.expressionsList.find(expr => expr.isSelected === true);
        if (selectedItem) {
            this.expression = selectedItem.expression;
        }

        this.input.nativeElement.focus();
    }

    @HostListener('keydown.shift.tab', ['$event'])
    @HostListener('keydown.tab', ['$event'])
    public onTabKeydown(event) {
        event.stopPropagation();
        if (document.activeElement === this.closeButton.nativeElement && !event.shiftKey) {
          //  this.filteringService.grid.navigateTo(0, 0, (obj) => { obj.target.activate(); });
        }
    }

    @HostListener('keydown.esc', ['$event'])
    public onEscKeydown(event) {
        event.preventDefault();
        event.stopPropagation();
        this.close();
{'fraction_non_alphanumeric': 0.12204660257454783, 'fraction_numerical': 0.0006517842594101353, 'mean_word_length': 3.234218696102104, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 18, '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': '5662369', 'n_tokens_mistral': 3378, 'n_tokens_neox': 3285, 'n_words': 655}