all files / combo-box/ combo-box.js

100% Statements 378/378
97.13% Branches 305/314
100% Functions 46/46
100% Lines 372/372
5 statements, 2 functions, 11 branches Ignored     
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593        126× 126× 126× 126×           98×     98×   98× 52× 52×   98× 63×   98× 98× 95× 95× 95×   98×         705×             10× 10× 10× 10× 10× 10× 10× 10× 10× 10× 10×     20× 14× 14×                       20× 20×   98×                         98×   36× 36× 11× 11×       25×   25×     77×   173× 173×   147× 147×   147×     95× 95× 95× 95×   89×   81× 81× 81× 81× 37× 37× 37× 19× 19× 19× 19×       44×     81×         76×   76×     75×     139× 135×     135× 135×       135×     136× 133× 133× 133×     132×   133×     31× 16×   31× 21× 21× 21×         21× 15×       21×             13×     48× 44×       32×   32× 32× 16× 12× 12× 12×   16× 16×   16×     11× 11× 11×     26× 26× 26× 26×       15× 15× 15× 14× 14× 14×           64×   60× 27× 27×   60× 35×   60× 60× 59× 59× 59×   60×   76× 76× 40×     10× 10×       10×     10×   37× 37× 37× 37×       12×   12×   10× 10×   10×   55× 55×     46× 31× 31× 26× 26× 26× 26× 26× 24×   26× 26× 26×     25× 25×   26× 26×         26× 26× 26×       31× 30×     15×     120× 120× 125× 125×                 117× 117× 117× 117×       98× 98× 98×       937×   131× 131× 105× 105×   105×   105× 105× 105× 25×   25× 25×   80× 16× 16× 16× 13×   16× 16×   13×     80× 39×     106×   106×   13×   11×   11×                                                            
/* istanbul ignore next */ 
var __extends = (this && this.__extends) || (function () {
    var extendStatics = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
/* istanbul ignore next */ 
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    Iif (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) Eif (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-base", "../drop-down-list/drop-down-list", "../common/incremental-search", "@syncfusion/ej2-popups", "@syncfusion/ej2-inputs"], function (require, exports, ej2_base_1, ej2_base_2, drop_down_list_1, incremental_search_1, ej2_popups_1, ej2_inputs_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var SPINNER_CLASS = 'e-atc-spinner-icon';
    drop_down_list_1.dropDownListClasses.root = 'e-combobox';
    var inputObject = {
        container: null,
        buttons: []
    };
    var ComboBox = (function (_super) {
        __extends(ComboBox, _super);
        function ComboBox(options, element) {
            return _super.call(this, options, element) || this;
        }
        ;
        ComboBox.prototype.preRender = function () {
            _super.prototype.preRender.call(this);
        };
        ComboBox.prototype.wireEvent = function () {
            if (this.getModuleName() === 'combobox') {
                ej2_base_1.EventHandler.add(this.inputWrapper.buttons[0], 'mousedown', this.preventBlur, this);
                ej2_base_1.EventHandler.add(this.inputWrapper.container, 'blur', this.onBlur, this);
            }
            if (!ej2_base_2.isNullOrUndefined(this.inputWrapper.buttons[0])) {
                ej2_base_1.EventHandler.add(this.inputWrapper.buttons[0], 'mousedown', this.dropDownClick, this);
            }
            ej2_base_1.EventHandler.add(this.inputElement, 'focus', this.targetFocus, this);
            if (!this.readonly) {
                ej2_base_1.EventHandler.add(this.inputElement, 'input', this.onInput, this);
                ej2_base_1.EventHandler.add(this.inputElement, 'keyup', this.onFilterUp, this);
                ej2_base_1.EventHandler.add(this.inputElement, 'keydown', this.onFilterDown, this);
            }
            this.bindCommonEvent();
        };
        ComboBox.prototype.preventBlur = function (e) {
            if ((!this.allowFiltering && document.activeElement !== this.inputElement &&
                !document.activeElement.classList.contains(drop_down_list_1.dropDownListClasses.input) && ej2_base_1.Browser.isDevice || !ej2_base_1.Browser.isDevice)) {
                e.preventDefault();
            }
        };
        ComboBox.prototype.targetElement = function () {
            return this.inputElement;
        };
        ComboBox.prototype.setOldText = function (text) {
            ej2_inputs_1.Input.setValue(this.text, this.inputElement, this.floatLabelType, this.showClearButton);
            this.customValue();
            this.removeSelection();
        };
        ComboBox.prototype.setOldValue = function (value) {
            if (this.allowCustom) {
                this.valueMuteChange(this.value);
            }
            else {
                this.valueMuteChange(null);
            }
            this.removeSelection();
            this.setHiddenValue();
        };
        ComboBox.prototype.valueMuteChange = function (value) {
            var inputValue = ej2_base_2.isNullOrUndefined(value) ? null : value.toString();
            ej2_inputs_1.Input.setValue(inputValue, this.inputElement, this.floatLabelType, this.showClearButton);
            this.setProperties({ value: value, text: value, index: null }, true);
            this.activeIndex = this.index;
            var fields = this.fields;
            var dataItem = {};
            dataItem[fields.text] = ej2_base_2.isNullOrUndefined(value) ? null : value.toString();
            dataItem[fields.value] = ej2_base_2.isNullOrUndefined(value) ? null : value.toString();
            this.itemData = dataItem;
            this.item = null;
            if (this.previousValue !== this.value) {
                this.detachChangeEvent(null);
            }
        };
        ComboBox.prototype.updateValues = function () {
            if (!ej2_base_2.isNullOrUndefined(this.value)) {
                var li = this.getElementByValue(this.value);
                if (li) {
                    this.setSelection(li, null);
                }
                else if (this.allowCustom) {
                    this.valueMuteChange(this.value);
                }
                else {
                    this.valueMuteChange(null);
                }
            }
            else if (this.text && ej2_base_2.isNullOrUndefined(this.value)) {
                var li = this.getElementByText(this.text);
                if (li) {
                    this.setSelection(li, null);
                }
                else {
                    ej2_inputs_1.Input.setValue(this.text, this.inputElement, this.floatLabelType, this.showClearButton);
                    this.customValue();
                }
            }
            else {
                this.setSelection(this.liCollections[this.activeIndex], null);
            }
            this.setHiddenValue();
            ej2_inputs_1.Input.setValue(this.text, this.inputElement, this.floatLabelType, this.showClearButton);
        };
        ComboBox.prototype.getAriaAttributes = function () {
            var ariaAttributes = {
                'aria-owns': this.element.id + '_options',
                'role': 'combobox',
                'aria-autocomplete': 'both',
                'aria-labelledby': this.hiddenElement.id,
                'aria-hasPopup': 'true',
                'aria-expanded': 'false',
                'aria-readonly': this.readonly.toString(),
                'autocomplete': 'off',
                'autocorrect': 'off',
                'autocapitalize': 'off',
                'spellcheck': 'false'
            };
            return ariaAttributes;
        };
        ComboBox.prototype.searchLists = function (e) {
            this.isTyped = true;
            if (this.isFiltering()) {
                _super.prototype.searchLists.call(this, e);
                if (this.filterInput.value.trim() === '') {
                    this.setHoverList(this.ulElement.querySelector('.' + drop_down_list_1.dropDownListClasses.li));
                }
            }
            else {
                if (this.ulElement && this.inputElement.value === '' && this.preventAutoFill) {
                    this.setHoverList(this.ulElement.querySelector('.' + drop_down_list_1.dropDownListClasses.li));
                }
                this.incrementalSearch(e);
            }
        };
        ComboBox.prototype.getNgDirective = function () {
            return 'EJS-COMBOBOX';
        };
        ComboBox.prototype.setSearchBox = function () {
            this.filterInput = this.inputElement;
            return (this.isFiltering() ? this.inputWrapper : inputObject);
        };
        ComboBox.prototype.onActionComplete = function (ulElement, list, e, isUpdated) {
            _super.prototype.onActionComplete.call(this, ulElement, list, e);
            if (this.isSelectCustom) {
                this.removeSelection();
            }
            if (!this.preventAutoFill && this.getModuleName() === 'combobox' && this.isTyped) {
                this.inlineSearch();
            }
        };
        ComboBox.prototype.getFocusElement = function () {
            var dataItem = this.isSelectCustom ? { text: '' } : this.getItemData();
            var selected = this.list.querySelector('.' + drop_down_list_1.dropDownListClasses.selected);
            var isSelected = dataItem.text === this.inputElement.value && !ej2_base_2.isNullOrUndefined(selected);
            if (isSelected) {
                return selected;
            }
            if ((ej2_base_1.Browser.isDevice && !this.isDropDownClick || !ej2_base_1.Browser.isDevice) &&
                !ej2_base_2.isNullOrUndefined(this.liCollections) && this.liCollections.length > 0) {
                var inputValue = this.inputElement.value;
                var activeItem = incremental_search_1.Search(inputValue, this.liCollections, 'StartsWith', true);
                var activeElement = activeItem.item;
                if (!ej2_base_2.isNullOrUndefined(activeElement)) {
                    var count = this.getIndexByValue(activeElement.getAttribute('data-value')) - 1;
                    var height = parseInt(getComputedStyle(this.liCollections[0], null).getPropertyValue('height'), 10);
                    if (!isNaN(height) && this.getModuleName() !== 'autocomplete') {
                        this.removeFocus();
                        var fixedHead = this.fields.groupBy ? this.liCollections[0].offsetHeight : 0;
                        this.list.scrollTop = count * height + fixedHead;
                        ej2_base_1.addClass([activeElement], drop_down_list_1.dropDownListClasses.focus);
                    }
                }
                else {
                    if (this.isSelectCustom && this.inputElement.value.trim() !== '') {
                        this.removeFocus();
                        this.list.scrollTop = 0;
                    }
                }
                return activeElement;
            }
            else {
                return null;
            }
        };
        ComboBox.prototype.setValue = function (e) {
            if (e && e.type === 'keydown' && e.action === 'enter') {
                this.removeFillSelection();
            }
            if (this.autofill && this.getModuleName() === 'combobox' && e && e.type === 'keydown' && e.action !== 'enter') {
                this.preventAutoFill = false;
                this.inlineSearch(e);
                return false;
            }
            else {
                return _super.prototype.setValue.call(this, e);
            }
        };
        ComboBox.prototype.showSpinner = function () {
            if (ej2_base_2.isNullOrUndefined(this.spinnerElement)) {
                this.spinnerElement = (this.getModuleName() === 'autocomplete') ? (this.inputWrapper.buttons[0] ||
                    this.inputWrapper.clearButton || ej2_inputs_1.Input.appendSpan('e-input-group-icon ' + SPINNER_CLASS, this.inputWrapper.container)) :
                    (this.inputWrapper.buttons[0] || this.inputWrapper.clearButton);
                ej2_base_1.addClass([this.spinnerElement], drop_down_list_1.dropDownListClasses.disableIcon);
                ej2_popups_1.createSpinner({
                    target: this.spinnerElement,
                    width: ej2_base_1.Browser.isDevice ? '16px' : '14px'
                });
                ej2_popups_1.showSpinner(this.spinnerElement);
            }
        };
        ComboBox.prototype.hideSpinner = function () {
            if (!ej2_base_2.isNullOrUndefined(this.spinnerElement)) {
                ej2_popups_1.hideSpinner(this.spinnerElement);
                ej2_base_1.removeClass([this.spinnerElement], drop_down_list_1.dropDownListClasses.disableIcon);
                if (this.spinnerElement.classList.contains(SPINNER_CLASS)) {
                    ej2_base_1.detach(this.spinnerElement);
                }
                else {
                    this.spinnerElement.innerHTML = '';
                }
                this.spinnerElement = null;
            }
        };
        ComboBox.prototype.setAutoFill = function (activeElement, isHover) {
            if (!isHover) {
                this.setHoverList(activeElement);
            }
            if (this.autofill && !this.preventAutoFill) {
                var currentValue = this.getTextByValue(activeElement.getAttribute('data-value')).toString();
                var currentFillValue = this.getFormattedValue(activeElement.getAttribute('data-value'));
                if (this.getModuleName() === 'combobox') {
                    if (!this.isSelected && this.previousValue !== currentFillValue) {
                        this.updateSelectedItem(activeElement, null);
                        this.isSelected = true;
                        this.previousValue = this.getFormattedValue(activeElement.getAttribute('data-value'));
                    }
                    else {
                        this.updateSelectedItem(activeElement, null, true);
                    }
                }
                if (!this.isAndroidAutoFill(currentValue)) {
                    this.setAutoFillSelection(currentValue);
                }
            }
        };
        ComboBox.prototype.isAndroidAutoFill = function (value) {
            if (ej2_base_1.Browser.isAndroid) {
                var currentPoints = this.getSelectionPoints();
                var prevEnd = this.prevSelectPoints.end;
                var curEnd = currentPoints.end;
                var prevStart = this.prevSelectPoints.start;
                var curStart = currentPoints.start;
                if (prevEnd !== 0 && ((prevEnd === value.length && prevStart === value.length) ||
                    (prevStart > curStart && prevEnd > curEnd) || (prevEnd === curEnd && prevStart === curStart))) {
                    return true;
                }
                else {
                    return false;
                }
            }
            else {
                return false;
            }
        };
        ComboBox.prototype.clear = function (e, property) {
            if (ej2_base_2.isNullOrUndefined(property) || property !== 'dataSource') {
                _super.prototype.clear.call(this, e);
            }
        };
        ComboBox.prototype.isSelectFocusItem = function (element) {
            return !ej2_base_2.isNullOrUndefined(element);
        };
        ComboBox.prototype.inlineSearch = function (e) {
            var isKeyNavigate = (e && (e.action === 'down' || e.action === 'up' ||
                e.action === 'home' || e.action === 'end' || e.action === 'pageUp' || e.action === 'pageDown'));
            var activeElement = isKeyNavigate ? this.liCollections[this.activeIndex] : this.getFocusElement();
            if (!ej2_base_2.isNullOrUndefined(activeElement)) {
                if (!isKeyNavigate) {
                    var value = this.getFormattedValue(activeElement.getAttribute('data-value'));
                    this.activeIndex = this.getIndexByValue(value);
                    this.activeIndex = !ej2_base_2.isNullOrUndefined(this.activeIndex) ? this.activeIndex : null;
                }
                this.preventAutoFill = this.inputElement.value === '' ? false : this.preventAutoFill;
                this.setAutoFill(activeElement, isKeyNavigate);
            }
            else if (this.inputElement.value === '') {
                this.activeIndex = null;
                this.list.scrollTop = 0;
                var focusItem = this.list.querySelector('.' + drop_down_list_1.dropDownListClasses.li);
                this.setHoverList(focusItem);
            }
            else {
                this.activeIndex = null;
                this.removeSelection();
                this.removeFocus();
            }
        };
        ComboBox.prototype.incrementalSearch = function (e) {
            this.showPopup();
            Eif (!ej2_base_2.isNullOrUndefined(this.listData)) {
                this.inlineSearch(e);
                e.preventDefault();
            }
        };
        ;
        ComboBox.prototype.setAutoFillSelection = function (currentValue) {
            var selection = this.getSelectionPoints();
            var value = this.inputElement.value.substr(0, selection.start);
            if (value && (value.toLowerCase() === currentValue.substr(0, selection.start).toLowerCase())) {
                var inputValue = value + currentValue.substr(value.length, currentValue.length);
                ej2_inputs_1.Input.setValue(inputValue, this.inputElement, this.floatLabelType, this.showClearButton);
                this.inputElement.setSelectionRange(selection.start, this.inputElement.value.length);
            }
            else {
                ej2_inputs_1.Input.setValue(currentValue, this.inputElement, this.floatLabelType, this.showClearButton);
                this.inputElement.setSelectionRange(0, this.inputElement.value.length);
            }
        };
        ;
        ComboBox.prototype.getValueByText = function (text) {
            return _super.prototype.getValueByText.call(this, text, true, this.ignoreAccent);
        };
        ComboBox.prototype.unWireEvent = function () {
            if (this.getModuleName() === 'combobox') {
                ej2_base_1.EventHandler.remove(this.inputWrapper.buttons[0], 'mousedown', this.preventBlur);
                ej2_base_1.EventHandler.remove(this.inputWrapper.container, 'blur', this.onBlur);
            }
            if (!ej2_base_2.isNullOrUndefined(this.inputWrapper.buttons[0])) {
                ej2_base_1.EventHandler.remove(this.inputWrapper.buttons[0], 'mousedown', this.dropDownClick);
            }
            ej2_base_1.EventHandler.remove(this.inputElement, 'focus', this.targetFocus);
            if (!this.readonly) {
                ej2_base_1.EventHandler.remove(this.inputElement, 'input', this.onInput);
                ej2_base_1.EventHandler.remove(this.inputElement, 'keyup', this.onFilterUp);
                ej2_base_1.EventHandler.remove(this.inputElement, 'keydown', this.onFilterDown);
            }
            this.unBindCommonEvent();
        };
        ComboBox.prototype.setSelection = function (li, e) {
            _super.prototype.setSelection.call(this, li, e);
            if (!ej2_base_2.isNullOrUndefined(li) && !this.autofill && !this.isDropDownClick) {
                this.removeFocus();
            }
        };
        ComboBox.prototype.selectCurrentItem = function (e) {
            var li;
            if (this.isPopupOpen) {
                li = this.list.querySelector('.' + drop_down_list_1.dropDownListClasses.focus);
                if (li) {
                    this.setSelection(li, e);
                    this.isTyped = false;
                }
                if (this.isSelected) {
                    this.isSelectCustom = false;
                    this.onChangeEvent(e);
                }
            }
            if (e.action === 'enter' && this.inputElement.value.trim() === '') {
                this.clear(e);
            }
            else if (this.isTyped && !this.isSelected && ej2_base_2.isNullOrUndefined(li)) {
                this.customValue();
            }
            this.hidePopup();
        };
        ComboBox.prototype.setHoverList = function (li) {
            this.removeSelection();
            Eif (this.isValidLI(li) && !li.classList.contains(drop_down_list_1.dropDownListClasses.selected)) {
                this.removeFocus();
                li.classList.add(drop_down_list_1.dropDownListClasses.focus);
            }
        };
        ;
        ComboBox.prototype.targetFocus = function (e) {
            if (ej2_base_1.Browser.isDevice && !this.allowFiltering) {
                this.preventFocus = false;
            }
            this.onFocus();
        };
        ComboBox.prototype.dropDownClick = function (e) {
            e.preventDefault();
            if (ej2_base_1.Browser.isDevice && !this.allowFiltering) {
                this.preventFocus = true;
            }
            _super.prototype.dropDownClick.call(this, e);
        };
        ComboBox.prototype.customValue = function () {
            var value = this.getValueByText(this.inputElement.value);
            if (!this.allowCustom && this.inputElement.value !== '') {
                this.setProperties({ value: value });
                if (ej2_base_2.isNullOrUndefined(this.value)) {
                    ej2_inputs_1.Input.setValue('', this.inputElement, this.floatLabelType, this.showClearButton);
                }
            }
            else if (this.inputElement.value.trim() !== '') {
                var previousValue = this.value;
                if (ej2_base_2.isNullOrUndefined(value)) {
                    var value_1 = this.inputElement.value === '' ? null : this.inputElement.value;
                    var fields = this.fields;
                    var eventArgs = void 0;
                    eventArgs = { text: value_1, item: {} };
                    if (!this.initial) {
                        this.trigger('customValueSpecifier', eventArgs);
                    }
                    var item = eventArgs.item;
                    var dataItem = {};
                    if (item && ej2_base_2.getValue(fields.text, item) && ej2_base_2.getValue(fields.value, item)) {
                        dataItem = item;
                    }
                    else {
                        ej2_base_2.setValue(fields.text, value_1, dataItem);
                        ej2_base_2.setValue(fields.value, value_1, dataItem);
                    }
                    this.itemData = dataItem;
                    var changeData = {
                        text: ej2_base_2.getValue(fields.text, this.itemData),
                        value: ej2_base_2.getValue(fields.value, this.itemData),
                        index: null
                    };
                    this.setProperties(changeData, true);
                    this.setSelection(null, null);
                    this.isSelectCustom = true;
                }
                else {
                    this.isSelectCustom = false;
                    this.setProperties({ value: value });
                }
                if (previousValue !== this.value) {
                    this.onChangeEvent(null);
                }
            }
            else if (this.allowCustom) {
                this.isSelectCustom = true;
            }
        };
        ComboBox.prototype.onPropertyChanged = function (newProp, oldProp) {
            this.setUpdateInitial(['query', 'dataSource'], newProp);
            for (var _i = 0, _a = Object.keys(newProp); _i < _a.length; _i++) {
                var prop = _a[_i];
                switch (prop) {
                    case 'readonly':
                        ej2_inputs_1.Input.setReadonly(this.readonly, this.inputElement);
                        if (this.readonly) {
                            ej2_base_1.EventHandler.remove(this.inputElement, 'keyup', this.onFilterUp);
                            ej2_base_1.EventHandler.remove(this.inputElement, 'keydown', this.onFilterDown);
                        }
                        else {
                            ej2_base_1.EventHandler.add(this.inputElement, 'keyup', this.onFilterUp, this);
                            ej2_base_1.EventHandler.add(this.inputElement, 'keydown', this.onFilterDown, this);
                        }
                        break;
                    case 'allowFiltering':
                        this.setSearchBox();
                        if (this.isFiltering() && this.getModuleName() === 'combobox' && ej2_base_2.isNullOrUndefined(this.list)) {
                            _super.prototype.renderList.call(this);
                        }
                        break;
                    case 'allowCustom':
                        break;
                    default:
                        var comboProps = void 0;
                        comboProps = this.getPropObject(prop, newProp, oldProp);
                        _super.prototype.onPropertyChanged.call(this, comboProps.newProperty, comboProps.oldProperty);
                        break;
                }
            }
        };
        ComboBox.prototype.render = function () {
            _super.prototype.render.call(this);
            this.setSearchBox();
            if (this.isFiltering() && this.getModuleName() === 'combobox' && ej2_base_2.isNullOrUndefined(this.list)) {
                _super.prototype.renderList.call(this);
            }
        };
        ;
        ComboBox.prototype.getModuleName = function () {
            return 'combobox';
        };
        ComboBox.prototype.hidePopup = function () {
            var inputValue = this.inputElement.value === '' ? null : this.inputElement.value;
            if (!ej2_base_2.isNullOrUndefined(this.listData)) {
                var isEscape = this.isEscapeKey;
                if (this.isEscapeKey) {
                    ej2_inputs_1.Input.setValue(this.typedString, this.inputElement, this.floatLabelType, this.showClearButton);
                    this.isEscapeKey = false;
                }
                if (this.autofill) {
                    this.removeFillSelection();
                }
                var dataItem = this.isSelectCustom ? { text: '' } : this.getItemData();
                var selected = this.list.querySelector('.' + drop_down_list_1.dropDownListClasses.selected);
                if (dataItem.text === this.inputElement.value && !ej2_base_2.isNullOrUndefined(selected)) {
                    if (this.isSelected) {
                        this.onChangeEvent(null);
                        this.isSelectCustom = false;
                    }
                    _super.prototype.hidePopup.call(this);
                    return;
                }
                if (this.getModuleName() === 'combobox' && this.inputElement.value.trim() !== '') {
                    var searchItem = incremental_search_1.Search(this.inputElement.value, this.liCollections, 'Equal', true);
                    this.selectedLI = searchItem.item;
                    if (ej2_base_2.isNullOrUndefined(searchItem.index)) {
                        searchItem.index = incremental_search_1.Search(this.inputElement.value, this.liCollections, 'StartsWith', true).index;
                    }
                    this.activeIndex = searchItem.index;
                    if (!ej2_base_2.isNullOrUndefined(this.selectedLI)) {
                        this.updateSelectedItem(this.selectedLI, null, true);
                    }
                    else if (isEscape) {
                        this.isSelectCustom = true;
                        this.removeSelection();
                    }
                }
                if (!this.isEscapeKey && this.isTyped && !this.isInteracted) {
                    this.customValue();
                }
            }
            if (ej2_base_2.isNullOrUndefined(this.listData) && this.allowCustom && !ej2_base_2.isNullOrUndefined(inputValue) && inputValue !== this.value) {
                this.customValue();
            }
            _super.prototype.hidePopup.call(this);
        };
        ComboBox.prototype.focusIn = function () {
            if (!this.enabled) {
                return;
            }
            if (ej2_base_1.Browser.isDevice && !this.allowFiltering) {
                this.preventFocus = true;
            }
            _super.prototype.focusIn.call(this);
        };
        __decorate([
            ej2_base_1.Property(false)
        ], ComboBox.prototype, "autofill", void 0);
        __decorate([
            ej2_base_1.Property(true)
        ], ComboBox.prototype, "allowCustom", void 0);
        __decorate([
            ej2_base_1.Property({})
        ], ComboBox.prototype, "htmlAttributes", void 0);
        __decorate([
            ej2_base_1.Property(false)
        ], ComboBox.prototype, "allowFiltering", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], ComboBox.prototype, "query", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], ComboBox.prototype, "index", void 0);
        __decorate([
            ej2_base_1.Property(true)
        ], ComboBox.prototype, "showClearButton", void 0);
        __decorate([
            ej2_base_1.Event()
        ], ComboBox.prototype, "customValueSpecifier", void 0);
        __decorate([
            ej2_base_1.Event()
        ], ComboBox.prototype, "filtering", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], ComboBox.prototype, "valueTemplate", void 0);
        __decorate([
            ej2_base_1.Property('Never')
        ], ComboBox.prototype, "floatLabelType", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], ComboBox.prototype, "filterBarPlaceholder", void 0);
        ComboBox = __decorate([
            ej2_base_2.NotifyPropertyChanges
        ], ComboBox);
        return ComboBox;
    }(drop_down_list_1.DropDownList));
    exports.ComboBox = ComboBox;
});