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

99.56% Statements 451/453
96.83% Branches 367/379
98.39% Functions 61/62
99.55% Lines 444/446
18 statements, 7 functions, 29 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 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719                    203×   213×   13×   213× 115× 115×   213× 129×   213× 213× 207× 207× 207× 207×   213×         27×   27×   27×   2513×                 34× 29× 29× 23×                       34× 34×   111× 111× 13×     98×       213×                   213×   84× 84× 36× 36×       48×   48×     193×   355× 355×   287× 287× 287× 11×   287× 34× 34×       213× 213× 213× 213× 18×   195×   183× 183× 183× 183× 106× 106× 106× 63× 63× 63× 63×       77×     183×     12×     145×   145×     138×     11× 11× 11×     259× 256×       256× 256×       256×     254× 252× 252× 252×     251×   252×     73× 47×   73× 44× 44× 44× 29×     22×     44× 38×       44×             36×     52× 44×   52×     17×   90×   90× 90× 57× 47× 47× 47×   57× 57×   33× 14× 14× 14× 14×     19× 19× 19× 14×       49× 49× 49× 49×     38× 38× 38× 38× 22× 22× 22×   16×     109×   142× 65× 65×   142× 76×   142× 141× 141× 140× 140× 140× 140×     142×   145× 145× 78×     14× 14× 13×     11×   13×   13×         14×   13×   14×   85× 85× 85× 85×     33×   33× 33×   19× 19×   19×   96× 96× 96× 10× 10× 10× 10×   10×     86× 59× 59× 51× 51× 51× 46× 46×                   27× 18×     51× 51× 51× 51×     50× 50×   51× 51×         51× 51× 51× 51× 49×     173× 99× 99×   173× 175× 175×                 164× 164× 164×     164×         213× 213× 213× 30×   213×   5914×       109×   275×   275× 205× 205×   205× 27×   205× 205× 205× 58×   58× 58×   147× 30× 30× 30× 23×   30× 30×   23×     147× 64×     217× 13×   217×   36×   34×   34×     35×   394×   145×                                                                                                          
/* istanbul ignore next */ 
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        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 extendStatics(d, b);
    };
    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;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (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.getLocaleName = function () {
            return 'combo-box';
        };
        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.onBlurHandler, 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);
                ej2_base_1.EventHandler.add(this.inputElement, 'paste', this.pasteHandler, 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.onBlurHandler = function (e) {
            var inputValue = this.inputElement && this.inputElement.value === '' ?
                null : this.inputElement && this.inputElement.value;
            if (!ej2_base_2.isNullOrUndefined(this.listData) && !ej2_base_2.isNullOrUndefined(inputValue) && inputValue !== this.text) {
                this.customValue(e);
            }
            _super.prototype.onBlurHandler.call(this, e);
        };
        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.updateIconState = function () {
            Eif (this.showClearButton) {
                if (this.inputElement && this.inputElement.value !== '' && !this.readonly) {
                    ej2_base_1.removeClass([this.inputWrapper.clearButton], drop_down_list_1.dropDownListClasses.clearIconHide);
                }
                else {
                    ej2_base_1.addClass([this.inputWrapper.clearButton], drop_down_list_1.dropDownListClasses.clearIconHide);
                }
            }
        };
        ComboBox.prototype.getAriaAttributes = function () {
            var ariaAttributes = {
                'role': 'combobox',
                'aria-autocomplete': 'both',
                'aria-labelledby': this.hiddenElement.id,
                'aria-expanded': 'false',
                'aria-readonly': this.readonly.toString(),
                'autocomplete': '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.ulElement && 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) {
            var _this = this;
            _super.prototype.onActionComplete.call(this, ulElement, list, e);
            if (this.isSelectCustom) {
                this.removeSelection();
            }
            if (!this.preventAutoFill && this.getModuleName() === 'combobox' && this.isTyped) {
                setTimeout(function () {
                    _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, this.filterType, 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.checkCustomValue = function () {
            this.itemData = this.getDataByValue(this.value);
            var dataItem = this.getItemData();
            if (!(this.allowCustom && ej2_base_2.isNullOrUndefined(dataItem.value) && ej2_base_2.isNullOrUndefined(dataItem.text))) {
                this.setProperties({ 'value': dataItem.value, 'text': dataItem.text }, !this.allowCustom);
            }
        };
        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.createElement)) :
                    (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'
                }, this.createElement);
                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, isHover);
                }
            }
        };
        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.clearAll = function (e, property) {
            if (ej2_base_2.isNullOrUndefined(property) || (!ej2_base_2.isNullOrUndefined(property) && ej2_base_2.isNullOrUndefined(property.dataSource))) {
                _super.prototype.clearAll.call(this, e);
            }
            if (this.isFiltering() && !ej2_base_2.isNullOrUndefined(e) && e.target === this.inputWrapper.clearButton) {
                this.searchLists(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();
                if (this.liCollections && this.liCollections.length > 0 && !this.isCustomFilter) {
                    this.removeFocus();
                }
            }
        };
        ComboBox.prototype.incrementalSearch = function (e) {
            this.showPopup(e);
            Eif (!ej2_base_2.isNullOrUndefined(this.listData)) {
                this.inlineSearch(e);
                e.preventDefault();
            }
        };
        ComboBox.prototype.setAutoFillSelection = function (currentValue, isKeyNavigate) {
            if (isKeyNavigate === void 0) { isKeyNavigate = false; }
            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 if (isKeyNavigate) {
                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.onBlurHandler);
            }
            if (!ej2_base_2.isNullOrUndefined(this.inputWrapper.buttons[0])) {
                ej2_base_1.EventHandler.remove(this.inputWrapper.buttons[0], 'mousedown', this.dropDownClick);
            }
            if (this.inputElement) {
                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);
                    ej2_base_1.EventHandler.remove(this.inputElement, 'paste', this.pasteHandler);
                }
            }
            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) {
                if (this.isSelected) {
                    li = this.list.querySelector('.' + drop_down_list_1.dropDownListClasses.selected);
                }
                else {
                    li = this.list.querySelector('.' + drop_down_list_1.dropDownListClasses.focus);
                }
                if (li) {
                    this.setSelection(li, e);
                    this.isTyped = false;
                }
                Iif (this.isSelected) {
                    this.isSelectCustom = false;
                    this.onChangeEvent(e);
                }
            }
            if (e.action === 'enter' && this.inputElement.value.trim() === '') {
                this.clearAll(e);
            }
            else if (this.isTyped && !this.isSelected && ej2_base_2.isNullOrUndefined(li)) {
                this.customValue(e);
            }
            this.hidePopup(e);
        };
        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(e);
            ej2_inputs_1.Input.calculateWidth(this.inputElement, this.inputWrapper.container);
        };
        ComboBox.prototype.dropDownClick = function (e) {
            e.preventDefault();
            if (ej2_base_1.Browser.isDevice && !this.isFiltering()) {
                this.preventFocus = true;
            }
            _super.prototype.dropDownClick.call(this, e);
        };
        ComboBox.prototype.customValue = function (e) {
            var _this = this;
            var value = this.getValueByText(this.inputElement.value);
            if (!this.allowCustom && this.inputElement.value !== '') {
                var previousValue = this.previousValue;
                var currentValue = this.value;
                this.setProperties({ value: value });
                if (ej2_base_2.isNullOrUndefined(this.value)) {
                    ej2_inputs_1.Input.setValue('', this.inputElement, this.floatLabelType, this.showClearButton);
                }
                if (this.autofill && previousValue === this.value && currentValue !== this.value) {
                    this.onChangeEvent(null);
                }
            }
            else if (this.inputElement.value.trim() !== '') {
                var previousValue_1 = this.value;
                if (ej2_base_2.isNullOrUndefined(value)) {
                    var value_1 = this.inputElement.value === '' ? null : this.inputElement.value;
                    var eventArgs = { text: value_1, item: {} };
                    if (!this.initial) {
                        this.trigger('customValueSpecifier', eventArgs, function (eventArgs) {
                            _this.updateCustomValueCallback(value_1, eventArgs, previousValue_1, e);
                        });
                    }
                    else {
                        this.updateCustomValueCallback(value_1, eventArgs, previousValue_1);
                    }
                }
                else {
                    this.isSelectCustom = false;
                    this.setProperties({ value: value });
                    Eif (previousValue_1 !== this.value) {
                        this.onChangeEvent(e);
                    }
                }
            }
            else if (this.allowCustom) {
                this.isSelectCustom = true;
            }
        };
        ComboBox.prototype.updateCustomValueCallback = function (value, eventArgs, previousValue, e) {
            var fields = this.fields;
            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, dataItem);
                ej2_base_2.setValue(fields.value, value, 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;
            if (previousValue !== this.value) {
                this.onChangeEvent(e);
            }
        };
        ComboBox.prototype.onPropertyChanged = function (newProp, oldProp) {
            if (this.getModuleName() === 'combobox') {
                this.checkData(newProp);
                this.setUpdateInitial(['fields', '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, 'input', this.onInput);
                            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, '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.setReadOnly();
                        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 = this.getPropObject(prop, newProp, oldProp);
                        _super.prototype.onPropertyChanged.call(this, comboProps.newProperty, comboProps.oldProperty);
                        if (this.isFiltering() && prop === 'dataSource' && ej2_base_2.isNullOrUndefined(this.list) && this.itemTemplate &&
                            this.getModuleName() === 'combobox') {
                            _super.prototype.renderList.call(this);
                        }
                        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);
            }
            this.renderComplete();
        };
        ComboBox.prototype.getModuleName = function () {
            return 'combobox';
        };
        ComboBox.prototype.addItem = function (items, itemIndex) {
            _super.prototype.addItem.call(this, items, itemIndex);
        };
        ComboBox.prototype.filter = function (dataSource, query, fields) {
            _super.prototype.filter.call(this, dataSource, query, fields);
        };
        ComboBox.prototype.showPopup = function (e) {
            _super.prototype.showPopup.call(this, e);
        };
        ComboBox.prototype.hidePopup = function (e) {
            var inputValue = this.inputElement && this.inputElement.value === '' ? null
                : this.inputElement && 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 (this.inputElement && dataItem.text === this.inputElement.value && !ej2_base_2.isNullOrUndefined(selected)) {
                    if (this.isSelected) {
                        this.onChangeEvent(e);
                        this.isSelectCustom = false;
                    }
                    _super.prototype.hidePopup.call(this, e);
                    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(e);
                }
            }
            if (ej2_base_2.isNullOrUndefined(this.listData) && this.allowCustom && !ej2_base_2.isNullOrUndefined(inputValue) && inputValue !== this.value) {
                this.customValue();
            }
            _super.prototype.hidePopup.call(this, e);
        };
        ComboBox.prototype.focusIn = function () {
            if (!this.enabled) {
                return;
            }
            if (ej2_base_1.Browser.isDevice && !this.isFiltering()) {
                this.preventFocus = true;
            }
            _super.prototype.focusIn.call(this);
        };
        ComboBox.prototype.clear = function () {
            this.value = null;
        };
        ComboBox.prototype.focusOut = function (e) {
            _super.prototype.focusOut.call(this, e);
        };
        ComboBox.prototype.getItems = function () {
            return _super.prototype.getItems.call(this);
        };
        ComboBox.prototype.getDataByValue = function (value) {
            return _super.prototype.getDataByValue.call(this, value);
        };
        ComboBox.prototype.renderHightSearch = function () {
        };
        __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.Property(false)
        ], ComboBox.prototype, "enableRtl", 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);
        __decorate([
            ej2_base_1.Property(null)
        ], ComboBox.prototype, "cssClass", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], ComboBox.prototype, "headerTemplate", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], ComboBox.prototype, "footerTemplate", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], ComboBox.prototype, "placeholder", void 0);
        __decorate([
            ej2_base_1.Property('100%')
        ], ComboBox.prototype, "width", void 0);
        __decorate([
            ej2_base_1.Property('300px')
        ], ComboBox.prototype, "popupHeight", void 0);
        __decorate([
            ej2_base_1.Property('100%')
        ], ComboBox.prototype, "popupWidth", void 0);
        __decorate([
            ej2_base_1.Property(false)
        ], ComboBox.prototype, "readonly", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], ComboBox.prototype, "text", void 0);
        __decorate([
            ej2_base_1.Property(null)
        ], ComboBox.prototype, "value", void 0);
        ComboBox = __decorate([
            ej2_base_2.NotifyPropertyChanges
        ], ComboBox);
        return ComboBox;
    }(drop_down_list_1.DropDownList));
    exports.ComboBox = ComboBox;
});