all files / input/ input.js

98.55% Statements 610/619
89.98% Branches 386/429
100% Functions 76/76
98.52% Lines 599/608
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 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105                                                                               1588× 1588× 1588× 1588× 1588× 1588× 1113× 1113× 1113× 1113×     475×   1588× 1588×   56× 56× 56× 22×     1588×     1588× 202×   1588× 1588× 1588× 1588× 1588×   114× 114× 114×   114× 39× 39×       109× 109× 109×   109× 38× 38×         1588× 1588× 1588× 1588× 1588× 1588× 1588× 1588× 1588× 1588×   1195× 1195× 1185×     1185× 1185× 1185× 1185× 1185× 1185×   1185× 1185× 1185×         4511× 4511× 4511× 4511× 2392× 2391×       2119× 1709× 1708×         37× 37× 37× 37× 19×       36× 36×           129× 129×   1239× 1239× 1239×       36×   533× 533× 129×   533× 475× 475× 475× 475×       58×   58×   533× 533× 533× 463× 463×   533× 64× 64×   533×   499×   533× 33×   533×     532× 532× 532×   533× 533× 404× 392×   404×   533× 129× 129×   129× 129×   129× 129×     404×   533× 463×     466×       47× 47×   47× 47×   47× 47×     1534×     1588× 1564× 9032× 9032×   1452× 1452× 1452×   1522× 1522×   1517× 1517×   1554× 1554×   1519× 1519×       1588×   19× 19× 13×           756× 756× 147× 147× 30×       609× 609× 607× 35×   607×       7097×   7097×   7097×         62× 62× 62× 62× 56×         62× 62× 62× 62×           18×   20× 20× 20× 20×         62× 62× 62× 62×   62× 62× 62× 62× 62× 62×   62× 62× 62×   28×   28× 28× 28× 28× 28×     28×   28×     28× 28× 28× 28× 28× 28×   28× 28× 28×       1195× 1195× 1195× 38×   1195× 28×   1195×     1195× 1195× 1195× 1195×       1195×   1697× 1697× 223× 223×           1588× 1588× 1588×     1583×   1588× 1588×   2251× 2251× 1235× 1235× 1235× 1235×   2251×                         2922× 2922× 703×   2922× 119×   2922× 65× 65× 65× 65× 61× 20×     41×         2922×                         1470× 12×   1470× 60×                       1252× 62×   1190× 1190×                               359×   353× 14×   359×                     1688× 1688× 1688× 518× 497× 497×       497×   497× 497×     21× 21× 21×       21×         1170× 175×     995×                             1549× 74×     1475×   1549×                           1531× 38×     1493×                           1558× 1558× 1558× 1480× 1480× 1480× 1474×       78× 78× 78× 72×     1558× 1539×     65× 65× 62×                               1485× 2968× 2968× 2968× 1484×   2968× 1482×   2968×     2967×                             82× 160× 160× 160× 80×   160× 79×   160×     159×       81× 81× 44×   44× 44× 44× 44× 44× 44× 44× 44× 44× 15×       82× 82× 82× 82× 82× 82×   82× 58× 58× 58× 58× 58× 58× 58× 58× 55×     54×     58× 50×             24×   82×                         1646×                               1240× 1240× 1240×   1240× 1239× 1243× 1243×           73× 69×     1252×       1252× 1252× 4593× 4593× 62×   4531×     1190×   73× 73× 73×     73×   73× 73× 19×     1238× 1238× 1238×                                                                                               1233× 1233× 1233×   1233× 1233× 1233×   1630×   1623×     376× 372× 155× 155× 115×           57× 57× 54×   57×   378× 374× 165× 165× 44× 29× 29× 27×     15×       12×           87×          
define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-base"], function (require, exports, ej2_base_1, ej2_base_2) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var CLASSNAMES = {
        RTL: 'e-rtl',
        DISABLE: 'e-disabled',
        INPUT: 'e-input',
        TEXTAREA: 'e-multi-line-input',
        INPUTGROUP: 'e-input-group',
        FLOATINPUT: 'e-float-input',
        FLOATLINE: 'e-float-line',
        FLOATTEXT: 'e-float-text',
        FLOATTEXTCONTENT: 'e-float-text-content',
        CLEARICON: 'e-clear-icon',
        CLEARICONHIDE: 'e-clear-icon-hide',
        LABELTOP: 'e-label-top',
        LABELBOTTOM: 'e-label-bottom',
        NOFLOATLABEL: 'e-no-float-label',
        INPUTCUSTOMTAG: 'e-input-custom-tag',
        FLOATCUSTOMTAG: 'e-float-custom-tag'
    };
    /**
     * Defines the constant attributes for the input element container.
     */
    exports.containerAttributes = ['title', 'style', 'class'];
    /**
     * Defines the constant focus class for the input element.
     */
    exports.TEXTBOX_FOCUS = 'e-input-focus';
    /**
     * Base for Input creation through util methods.
     */
    // eslint-disable-next-line @typescript-eslint/no-namespace
    var Input;
    (function (Input) {
        var privateInputObj = {
            container: null,
            buttons: [],
            clearButton: null
        };
        var floatType;
        var isBindClearAction = true;
        /**
         * Create a wrapper to input element with multiple span elements and set the basic properties to input based components.
         * ```
         * E.g : Input.createInput({ element: element, floatLabelType : "Auto", properties: { placeholder: 'Search' } });
         * ```
         *
         */
        function createInput(args, internalCreateElement) {
            args.element.__eventHandlers = {};
            var makeElement = !ej2_base_2.isNullOrUndefined(internalCreateElement) ? internalCreateElement : ej2_base_1.createElement;
            var inputObject = { container: null, buttons: [], clearButton: null };
            floatType = args.floatLabelType;
            isBindClearAction = args.bindClearAction;
            if (ej2_base_2.isNullOrUndefined(args.floatLabelType) || args.floatLabelType === 'Never') {
                inputObject.container = createInputContainer(args, CLASSNAMES.INPUTGROUP, CLASSNAMES.INPUTCUSTOMTAG, 'span', makeElement);
                args.element.parentNode.insertBefore(inputObject.container, args.element);
                ej2_base_1.addClass([args.element], CLASSNAMES.INPUT);
                inputObject.container.appendChild(args.element);
            }
            else {
                createFloatingInput(args, inputObject, makeElement);
            }
            bindInitialEvent(args);
            if (!ej2_base_2.isNullOrUndefined(args.properties) && !ej2_base_2.isNullOrUndefined(args.properties.showClearButton) &&
                args.properties.showClearButton) {
                setClearButton(args.properties.showClearButton, args.element, inputObject, true, makeElement);
                inputObject.clearButton.setAttribute('role', 'button');
                if (inputObject.container.classList.contains(CLASSNAMES.FLOATINPUT)) {
                    ej2_base_1.addClass([inputObject.container], CLASSNAMES.INPUTGROUP);
                }
            }
            if (!ej2_base_2.isNullOrUndefined(args.buttons)) {
                for (var i = 0; i < args.buttons.length; i++) {
                    inputObject.buttons.push(appendSpan(args.buttons[i], inputObject.container, makeElement));
                }
            }
            if (!ej2_base_2.isNullOrUndefined(args.element) && args.element.tagName === 'TEXTAREA') {
                ej2_base_1.addClass([inputObject.container], CLASSNAMES.TEXTAREA);
            }
            validateInputType(inputObject.container, args.element);
            inputObject = setPropertyValue(args, inputObject);
            createSpanElement(inputObject.container, makeElement);
            privateInputObj = inputObject;
            return inputObject;
        }
        Input.createInput = createInput;
        function bindFocusEventHandler(args) {
            var parent = getParentNode(args.element);
            Eif (parent.classList.contains('e-input-group') || parent.classList.contains('e-outline') || parent.classList.contains('e-filled')) {
                parent.classList.add('e-input-focus');
            }
            if (args.floatLabelType !== 'Never') {
                setTimeout(function () {
                    Input.calculateWidth(args.element, parent);
                }, 80);
            }
        }
        function bindBlurEventHandler(args) {
            var parent = getParentNode(args.element);
            Eif (parent.classList.contains('e-input-group') || parent.classList.contains('e-outline') || parent.classList.contains('e-filled')) {
                parent.classList.remove('e-input-focus');
            }
            if (args.floatLabelType !== 'Never') {
                setTimeout(function () {
                    Input.calculateWidth(args.element, parent);
                }, 80);
            }
        }
        function bindInputEventHandler(args) {
            checkInputValue(args.floatLabelType, args.element);
        }
        function bindInitialEvent(args) {
            checkInputValue(args.floatLabelType, args.element);
            var focusHandler = function () { return bindFocusEventHandler(args); };
            var blurHandler = function () { return bindBlurEventHandler(args); };
            var inputHandler = function () { return bindInputEventHandler(args); };
            args.element.addEventListener('focus', focusHandler);
            args.element.addEventListener('blur', blurHandler);
            args.element.addEventListener('input', inputHandler);
            args.element.__eventHandlers['inputFocusHandler'] = { focusHandler: focusHandler };
            args.element.__eventHandlers['inputBlurHandler'] = { blurHandler: blurHandler };
            args.element.__eventHandlers['inputHandler'] = { inputHandler: inputHandler };
        }
        Input.bindInitialEvent = bindInitialEvent;
        function unbindInitialEvent(args) {
            Eif (!ej2_base_2.isNullOrUndefined(args.element)) {
                if (!ej2_base_2.isNullOrUndefined(args.element.__eventHandlers)) {
                    Eif (!ej2_base_2.isNullOrUndefined(args.element.__eventHandlers['inputFocusHandler'])
                        && !ej2_base_2.isNullOrUndefined(args.element.__eventHandlers['inputBlurHandler'])
                        && !ej2_base_2.isNullOrUndefined(args.element.__eventHandlers['inputHandler'])) {
                        var focusHandler_1 = args.element.__eventHandlers['inputFocusHandler'].focusHandler;
                        var blurHandler_1 = args.element.__eventHandlers['inputBlurHandler'].blurHandler;
                        var inputHandler_1 = args.element.__eventHandlers['inputHandler'].inputHandler;
                        args.element.removeEventListener('focus', focusHandler_1);
                        args.element.removeEventListener('blur', blurHandler_1);
                        args.element.removeEventListener('input', inputHandler_1);
                        // Clean up stored bound functions
                        delete args.element.__eventHandlers['inputFocusHandler'];
                        delete args.element.__eventHandlers['inputBlurHandler'];
                        delete args.element.__eventHandlers['inputHandler'];
                    }
                }
            }
        }
        function checkInputValue(floatLabelType, inputElement) {
            var inputValue = inputElement.value;
            var inputParent = inputElement.parentElement;
            var grandParent = inputParent && inputParent.parentElement;
            if (inputValue !== '' && !ej2_base_2.isNullOrUndefined(inputValue)) {
                if (inputParent && inputParent.classList.contains('e-input-group')) {
                    inputParent.classList.add('e-valid-input');
                }
                else Eif (grandParent && grandParent.classList.contains('e-input-group')) {
                    grandParent.classList.add('e-valid-input');
                }
            }
            else if (floatLabelType !== 'Always') {
                if (inputParent && inputParent.classList.contains('e-input-group')) {
                    inputParent.classList.remove('e-valid-input');
                }
                else Eif (grandParent && grandParent.classList.contains('e-input-group')) {
                    grandParent.classList.remove('e-valid-input');
                }
            }
        }
        function _focusFn() {
            var label = getParentNode(this).getElementsByClassName('e-float-text')[0];
            Eif (!ej2_base_2.isNullOrUndefined(label)) {
                ej2_base_1.addClass([label], CLASSNAMES.LABELTOP);
                if (label.classList.contains(CLASSNAMES.LABELBOTTOM)) {
                    ej2_base_1.removeClass([label], CLASSNAMES.LABELBOTTOM);
                }
            }
        }
        function _blurFn() {
            var parent = getParentNode(this);
            if ((parent.getElementsByTagName('textarea')[0]) ? parent.getElementsByTagName('textarea')[0].value === '' :
                parent.getElementsByTagName('input')[0].value === '') {
                var label = parent.getElementsByClassName('e-float-text')[0];
                Eif (!ej2_base_2.isNullOrUndefined(label)) {
                    if (label.classList.contains(CLASSNAMES.LABELTOP)) {
                        ej2_base_1.removeClass([label], CLASSNAMES.LABELTOP);
                    }
                    ej2_base_1.addClass([label], CLASSNAMES.LABELBOTTOM);
                }
            }
        }
        function wireFloatingEvents(element) {
            element.addEventListener('focus', _focusFn);
            element.addEventListener('blur', _blurFn);
        }
        Input.wireFloatingEvents = wireFloatingEvents;
        function unwireFloatingEvents(element) {
            Eif (!ej2_base_2.isNullOrUndefined(element)) {
                element.removeEventListener('focus', _focusFn);
                element.removeEventListener('blur', _blurFn);
            }
        }
        function inputEventHandler(args) {
            validateLabel(args.element, args.floatLabelType);
        }
        function blurEventHandler(args) {
            validateLabel(args.element, args.floatLabelType);
        }
        function createFloatingInput(args, inputObject, internalCreateElement) {
            var makeElement = !ej2_base_2.isNullOrUndefined(internalCreateElement) ? internalCreateElement : ej2_base_1.createElement;
            if (args.floatLabelType === 'Auto') {
                wireFloatingEvents(args.element);
            }
            if (ej2_base_2.isNullOrUndefined(inputObject.container)) {
                inputObject.container = createInputContainer(args, CLASSNAMES.FLOATINPUT, CLASSNAMES.FLOATCUSTOMTAG, 'div', makeElement);
                inputObject.container.classList.add(CLASSNAMES.INPUTGROUP);
                Eif (args.element.parentNode) {
                    args.element.parentNode.insertBefore(inputObject.container, args.element);
                }
            }
            else {
                if (!ej2_base_2.isNullOrUndefined(args.customTag)) {
                    inputObject.container.classList.add(CLASSNAMES.FLOATCUSTOMTAG);
                }
                inputObject.container.classList.add(CLASSNAMES.FLOATINPUT);
            }
            var floatLinelement = makeElement('span', { className: CLASSNAMES.FLOATLINE });
            var floatLabelElement = makeElement('label', { className: CLASSNAMES.FLOATTEXT });
            if (!ej2_base_2.isNullOrUndefined(args.element.id) && args.element.id !== '') {
                floatLabelElement.id = 'label_' + args.element.id.replace(/ /g, '_');
                ej2_base_1.attributes(args.element, { 'aria-labelledby': floatLabelElement.id });
            }
            if (!ej2_base_2.isNullOrUndefined(args.element.placeholder) && args.element.placeholder !== '') {
                floatLabelElement.innerText = encodePlaceHolder(args.element.placeholder);
                args.element.removeAttribute('placeholder');
            }
            if (!ej2_base_2.isNullOrUndefined(args.properties) && !ej2_base_2.isNullOrUndefined(args.properties.placeholder) &&
                args.properties.placeholder !== '') {
                floatLabelElement.innerText = encodePlaceHolder(args.properties.placeholder);
            }
            if (!floatLabelElement.innerText) {
                inputObject.container.classList.add(CLASSNAMES.NOFLOATLABEL);
            }
            if (inputObject.container.classList.contains('e-float-icon-left')) {
                var inputWrap = inputObject.container.querySelector('.e-input-in-wrap');
                inputWrap.appendChild(args.element);
                inputWrap.appendChild(floatLinelement);
                inputWrap.appendChild(floatLabelElement);
            }
            else {
                inputObject.container.appendChild(args.element);
                inputObject.container.appendChild(floatLinelement);
                inputObject.container.appendChild(floatLabelElement);
            }
            updateLabelState(args.element.value, floatLabelElement);
            if (args.floatLabelType === 'Always') {
                if (floatLabelElement.classList.contains(CLASSNAMES.LABELBOTTOM)) {
                    ej2_base_1.removeClass([floatLabelElement], CLASSNAMES.LABELBOTTOM);
                }
                ej2_base_1.addClass([floatLabelElement], CLASSNAMES.LABELTOP);
            }
            if (args.floatLabelType === 'Auto') {
                var inputFloatHandler = function () { return inputEventHandler(args); };
                var blurFloatHandler = function () { return blurEventHandler(args); };
                // Add event listeners using the defined functions
                args.element.addEventListener('input', inputFloatHandler);
                args.element.addEventListener('blur', blurFloatHandler);
                // Store the event handler functions to remove them later
                args.element.__eventHandlers['floatInputHandler'] = { inputFloatHandler: inputFloatHandler };
                args.element.__eventHandlers['floatBlurHandler'] = { blurFloatHandler: blurFloatHandler };
            }
            else {
                unWireFloatLabelEvents(args);
            }
            if (!ej2_base_2.isNullOrUndefined(args.element.getAttribute('id'))) {
                floatLabelElement.setAttribute('for', args.element.getAttribute('id'));
            }
        }
        function unWireFloatLabelEvents(args) {
            if (!ej2_base_2.isNullOrUndefined(args.element) &&
                !ej2_base_2.isNullOrUndefined(args.element.__eventHandlers)
                && !ej2_base_2.isNullOrUndefined(args.element.__eventHandlers['floatInputHandler'])
                && !ej2_base_2.isNullOrUndefined(args.element.__eventHandlers['floatBlurHandler'])) {
                var inputFloatHandler = args.element.__eventHandlers['floatInputHandler'].inputFloatHandler;
                var blurFloatHandler = args.element.__eventHandlers['floatBlurHandler'].blurFloatHandler;
                // Remove the event listeners using the defined functions
                args.element.removeEventListener('input', inputFloatHandler);
                args.element.removeEventListener('blur', blurFloatHandler);
                // Clean up stored event handler functions
                delete args.element.__eventHandlers['floatInputHandler'];
                delete args.element.__eventHandlers['floatBlurHandler'];
            }
        }
        function checkFloatLabelType(type, container) {
            if (type === 'Always' && container.classList.contains('e-outline')) {
                container.classList.add('e-valid-input');
            }
        }
        function setPropertyValue(args, inputObject) {
            if (!ej2_base_2.isNullOrUndefined(args.properties)) {
                for (var _i = 0, _a = Object.keys(args.properties); _i < _a.length; _i++) {
                    var prop = _a[_i];
                    switch (prop) {
                        case 'cssClass':
                            setCssClass(args.properties.cssClass, [inputObject.container]);
                            checkFloatLabelType(args.floatLabelType, inputObject.container);
                            break;
                        case 'enabled':
                            setEnabled(args.properties.enabled, args.element, args.floatLabelType, inputObject.container);
                            break;
                        case 'enableRtl':
                            setEnableRtl(args.properties.enableRtl, [inputObject.container]);
                            break;
                        case 'placeholder':
                            setPlaceholder(args.properties.placeholder, args.element);
                            break;
                        case 'readonly':
                            setReadonly(args.properties.readonly, args.element);
                            break;
                    }
                }
            }
            return inputObject;
        }
        function updateIconState(value, button, readonly) {
            Eif (!ej2_base_2.isNullOrUndefined(button)) {
                if (value && !readonly) {
                    ej2_base_1.removeClass([button], CLASSNAMES.CLEARICONHIDE);
                }
                else {
                    ej2_base_1.addClass([button], CLASSNAMES.CLEARICONHIDE);
                }
            }
        }
        function updateLabelState(value, label, element) {
            if (element === void 0) { element = null; }
            if (value) {
                ej2_base_1.addClass([label], CLASSNAMES.LABELTOP);
                if (label.classList.contains(CLASSNAMES.LABELBOTTOM)) {
                    ej2_base_1.removeClass([label], CLASSNAMES.LABELBOTTOM);
                }
            }
            else {
                var isNotFocused = element != null ? element !== document.activeElement : true;
                if (isNotFocused) {
                    if (label.classList.contains(CLASSNAMES.LABELTOP)) {
                        ej2_base_1.removeClass([label], CLASSNAMES.LABELTOP);
                    }
                    ej2_base_1.addClass([label], CLASSNAMES.LABELBOTTOM);
                }
            }
        }
        function getParentNode(element) {
            var parentNode = ej2_base_2.isNullOrUndefined(element.parentNode) ? element
                : element.parentNode;
            if (parentNode && parentNode.classList.contains('e-input-in-wrap')) {
                parentNode = parentNode.parentNode;
            }
            return parentNode;
        }
        /**
         * To create clear button.
         */
        function createClearButton(element, inputObject, initial, internalCreateElement) {
            var makeElement = !ej2_base_2.isNullOrUndefined(internalCreateElement) ? internalCreateElement : ej2_base_1.createElement;
            var button = makeElement('span', { className: CLASSNAMES.CLEARICON });
            var container = inputObject.container;
            if (!ej2_base_2.isNullOrUndefined(initial)) {
                container.appendChild(button);
            }
            else {
                var baseElement = inputObject.container.classList.contains(CLASSNAMES.FLOATINPUT) ?
                    inputObject.container.querySelector('.' + CLASSNAMES.FLOATTEXT) : element;
                baseElement.insertAdjacentElement('afterend', button);
            }
            ej2_base_1.addClass([button], CLASSNAMES.CLEARICONHIDE);
            wireClearBtnEvents(element, button, container);
            button.setAttribute('aria-label', 'close');
            return button;
        }
        function clickHandler(event, element, button) {
            if (!(element.classList.contains(CLASSNAMES.DISABLE) || element.readOnly)) {
                event.preventDefault();
                Eif (element !== document.activeElement) {
                    element.focus();
                }
                element.value = '';
                ej2_base_1.addClass([button], CLASSNAMES.CLEARICONHIDE);
            }
        }
        function inputHandler(element, button) {
            updateIconState(element.value, button);
        }
        function focusHandler(element, button) {
            updateIconState(element.value, button, element.readOnly);
        }
        function blurHandler(element, button) {
            setTimeout(function () {
                Eif (!ej2_base_2.isNullOrUndefined(button)) {
                    ej2_base_1.addClass([button], CLASSNAMES.CLEARICONHIDE);
                    button = !ej2_base_2.isNullOrUndefined(element) && element.classList.contains('e-combobox') ? null : button;
                }
            }, 200);
        }
        // eslint-disable-next-line @typescript-eslint/no-unused-vars
        function wireClearBtnEvents(element, button, container) {
            Eif (isBindClearAction === undefined || isBindClearAction) {
                var clickHandlerEvent = function (e) { return clickHandler(e, element, button); };
                button.addEventListener('click', clickHandlerEvent);
                element.__eventHandlers['clearClickHandler'] = { clickHandlerEvent: clickHandlerEvent };
            }
            var inputHandlerEvent = function () { return inputHandler(element, button); };
            var focusHandlerEvent = function () { return focusHandler(element, button); };
            var blurHandlerEvent = function () { return blurHandler(element, button); };
            element.addEventListener('input', inputHandlerEvent);
            element.addEventListener('focus', focusHandlerEvent);
            element.addEventListener('blur', blurHandlerEvent);
            // Store the bound functions to remove them later
            element.__eventHandlers['clearInputHandler'] = { inputHandlerEvent: inputHandlerEvent };
            element.__eventHandlers['clearFocusHandler'] = { focusHandlerEvent: focusHandlerEvent };
            element.__eventHandlers['clearBlurHandler'] = { blurHandlerEvent: blurHandlerEvent };
        }
        Input.wireClearBtnEvents = wireClearBtnEvents;
        function unWireClearBtnEvents(element, button) {
            Eif (!ej2_base_2.isNullOrUndefined(element) &&
                !ej2_base_2.isNullOrUndefined(element.__eventHandlers)) {
                Eif (!ej2_base_2.isNullOrUndefined(element.__eventHandlers['clearClickHandler'])) {
                    var clickHandlerEvent = element.__eventHandlers['clearClickHandler'].clickHandlerEvent;
                    Eif (isBindClearAction === undefined || isBindClearAction) {
                        Eif (!ej2_base_2.isNullOrUndefined(button)) {
                            button.removeEventListener('click', clickHandlerEvent);
                        }
                    }
                    delete element.__eventHandlers['clearClickHandler'];
                }
                Eif (!ej2_base_2.isNullOrUndefined(element.__eventHandlers['clearInputHandler'])
                    && !ej2_base_2.isNullOrUndefined(element.__eventHandlers['clearFocusHandler'])
                    && !ej2_base_2.isNullOrUndefined(element.__eventHandlers['clearBlurHandler'])) {
                    var inputHandlerEvent = element.__eventHandlers['clearInputHandler'].inputHandlerEvent;
                    var focusHandlerEvent = element.__eventHandlers['clearFocusHandler'].focusHandlerEvent;
                    var blurHandlerEvent = element.__eventHandlers['clearBlurHandler'].blurHandlerEvent;
                    element.removeEventListener('input', inputHandlerEvent);
                    element.removeEventListener('focus', focusHandlerEvent);
                    element.removeEventListener('blur', blurHandlerEvent);
                    // Clean up stored Event functions
                    delete element.__eventHandlers['clearInputHandler'];
                    delete element.__eventHandlers['clearFocusHandler'];
                    delete element.__eventHandlers['clearBlurHandler'];
                }
            }
        }
        function destroy(args, button) {
            if (button === void 0) { button = null; }
            unbindInitialEvent(args);
            if (args.floatLabelType === 'Auto') {
                unWireFloatLabelEvents(args);
            }
            if (args.properties.showClearButton) {
                unWireClearBtnEvents(args.element, button);
            }
            Iif (!ej2_base_2.isNullOrUndefined(args.buttons)) {
                _internalRipple(false, null, args.buttons);
            }
            unwireFloatingEvents(args.element);
            Eif (!ej2_base_2.isNullOrUndefined(args.element)) {
                delete args.element.__eventHandlers;
                Iif (args.element.classList.contains(CLASSNAMES.INPUT)) {
                    args.element.classList.remove(CLASSNAMES.INPUT);
                }
            }
            privateInputObj = null;
        }
        Input.destroy = destroy;
        function validateLabel(element, floatLabelType) {
            var parent = getParentNode(element);
            if (parent.classList.contains(CLASSNAMES.FLOATINPUT) && floatLabelType === 'Auto') {
                var label = getParentNode(element).getElementsByClassName('e-float-text')[0];
                updateLabelState(element.value, label, element);
            }
        }
        /**
         * To create input box contianer.
         */
        function createInputContainer(args, className, tagClass, tag, internalCreateElement) {
            var makeElement = !ej2_base_2.isNullOrUndefined(internalCreateElement) ? internalCreateElement : ej2_base_1.createElement;
            var container;
            if (!ej2_base_2.isNullOrUndefined(args.customTag)) {
                container = makeElement(args.customTag, { className: className });
                container.classList.add(tagClass);
            }
            else {
                container = makeElement(tag, { className: className });
            }
            container.classList.add('e-control-wrapper');
            return container;
        }
        function encodePlaceHolder(placeholder) {
            var result = '';
            if (!ej2_base_2.isNullOrUndefined(placeholder) && placeholder !== '') {
                var spanEle = document.createElement('span');
                spanEle.innerHTML = '<input  placeholder="' + placeholder + '"/>';
                var hiddenInput = (spanEle.children[0]);
                result = hiddenInput.placeholder;
            }
            return result;
        }
        /**
         * Sets the value to the input element.
         * ```
         * E.g : Input.setValue('content', element, "Auto", true );
         * ```
         *
         * @param {string} value - Specify the value of the input element.
         * @param {HTMLInputElement | HTMLTextAreaElement} element - The element on which the specified value is updated.
         * @param {string} floatLabelType - Specify the float label type of the input element.
         * @param {boolean} clearButton - Boolean value to specify whether the clear icon is enabled / disabled on the input.
         */
        function setValue(value, element, floatLabelType, clearButton) {
            element.value = value;
            if (floatLabelType !== 'Never') {
                calculateWidth(element, element.parentElement);
            }
            if ((!ej2_base_2.isNullOrUndefined(floatLabelType)) && floatLabelType === 'Auto') {
                validateLabel(element, floatLabelType);
            }
            if (!ej2_base_2.isNullOrUndefined(clearButton) && clearButton) {
                var parentElement = getParentNode(element);
                Eif (!ej2_base_2.isNullOrUndefined(parentElement)) {
                    var button = parentElement.getElementsByClassName(CLASSNAMES.CLEARICON)[0];
                    if (!ej2_base_2.isNullOrUndefined(button)) {
                        if (element.value && !ej2_base_2.isNullOrUndefined(parentElement) && parentElement.classList.contains('e-input-focus')) {
                            ej2_base_1.removeClass([button], CLASSNAMES.CLEARICONHIDE);
                        }
                        else {
                            ej2_base_1.addClass([button], CLASSNAMES.CLEARICONHIDE);
                        }
                    }
                }
            }
            checkInputValue(floatLabelType, element);
        }
        Input.setValue = setValue;
        /**
         * Sets the single or multiple cssClass to wrapper of input element.
         * ```
         * E.g : Input.setCssClass('e-custom-class', [element]);
         * ```
         *
         * @param {string} cssClass - Css class names which are needed to add.
         * @param {Element[] | NodeList} elements - The elements which are needed to add / remove classes.
         * @param {string} oldClass
         * - Css class names which are needed to remove. If old classes are need to remove, can give this optional parameter.
         */
        function setCssClass(cssClass, elements, oldClass) {
            if (!ej2_base_2.isNullOrUndefined(oldClass) && oldClass !== '') {
                ej2_base_1.removeClass(elements, oldClass.split(' '));
            }
            if (!ej2_base_2.isNullOrUndefined(cssClass) && cssClass !== '') {
                ej2_base_1.addClass(elements, cssClass.split(' '));
            }
        }
        Input.setCssClass = setCssClass;
        /**
         * Set the width to the placeholder when it overflows on the button such as spinbutton, clearbutton, icon etc
         * ```
         * E.g : Input.calculateWidth(element, container);
         * ```
         *
         * @param {any} element - Input element which is need to add.
         * @param {HTMLElement} container - The parent element which is need to get the label span to calculate width
         */
        function calculateWidth(element, container, moduleName) {
            if (moduleName !== 'multiselect' && !_isElementVisible(element)) {
                return;
            }
            var elementWidth = moduleName === 'multiselect' ? element : element.clientWidth - parseInt(getComputedStyle(element, null).getPropertyValue('padding-left'), 10);
            if (!ej2_base_2.isNullOrUndefined(container) && !ej2_base_2.isNullOrUndefined(container.getElementsByClassName('e-float-text-content')[0])) {
                Iif (container.getElementsByClassName('e-float-text-content')[0].classList.contains('e-float-text-overflow')) {
                    container.getElementsByClassName('e-float-text-content')[0].classList.remove('e-float-text-overflow');
                }
                Iif (elementWidth < container.getElementsByClassName('e-float-text-content')[0].clientWidth || elementWidth === container.getElementsByClassName('e-float-text-content')[0].clientWidth) {
                    container.getElementsByClassName('e-float-text-content')[0].classList.add('e-float-text-overflow');
                }
            }
        }
        Input.calculateWidth = calculateWidth;
        /**
         * Set the width to the wrapper of input element.
         * ```
         * E.g : Input.setWidth('200px', container);
         * ```
         *
         * @param {number | string} width - Width value which is need to add.
         * @param {HTMLElement} container - The element on which the width is need to add.
         */
        function setWidth(width, container) {
            if (typeof width === 'number') {
                container.style.width = ej2_base_2.formatUnit(width);
            }
            else if (typeof width === 'string') {
                container.style.width = (width.match(/px|%|em/)) ? (width) : (ej2_base_2.formatUnit(width));
            }
            calculateWidth(container.firstChild, container);
        }
        Input.setWidth = setWidth;
        /**
         * Set the placeholder attribute to the input element.
         * ```
         * E.g : Input.setPlaceholder('Search here', element);
         * ```
         *
         * @param {string} placeholder - Placeholder value which is need to add.
         * @param {HTMLInputElement | HTMLTextAreaElement} element - The element on which the placeholder is need to add.
         */
        function setPlaceholder(placeholder, element) {
            placeholder = encodePlaceHolder(placeholder);
            var parentElement = getParentNode(element);
            if (parentElement.classList.contains(CLASSNAMES.FLOATINPUT)) {
                if (!ej2_base_2.isNullOrUndefined(placeholder) && placeholder !== '') {
                    var floatTextContent = parentElement.getElementsByClassName('e-float-text-content')[0];
                    Iif (floatTextContent && floatTextContent.children[0]) {
                        floatTextContent.children[0].textContent = placeholder;
                    }
                    else {
                        parentElement.getElementsByClassName(CLASSNAMES.FLOATTEXT)[0].textContent = placeholder;
                    }
                    parentElement.classList.remove(CLASSNAMES.NOFLOATLABEL);
                    element.removeAttribute('placeholder');
                }
                else {
                    parentElement.classList.add(CLASSNAMES.NOFLOATLABEL);
                    var floatTextContent = parentElement.getElementsByClassName('e-float-text-content')[0];
                    Iif (floatTextContent) {
                        floatTextContent.children[0].textContent = '';
                    }
                    else {
                        parentElement.getElementsByClassName(CLASSNAMES.FLOATTEXT)[0].textContent = '';
                    }
                }
            }
            else {
                if (!ej2_base_2.isNullOrUndefined(placeholder) && placeholder !== '') {
                    ej2_base_1.attributes(element, { 'placeholder': placeholder });
                }
                else {
                    element.removeAttribute('placeholder');
                }
            }
        }
        Input.setPlaceholder = setPlaceholder;
        /**
         * Set the read only attribute to the input element
         * ```
         * E.g : Input.setReadonly(true, element);
         * ```
         *
         * @param {boolean} isReadonly
         * - Boolean value to specify whether to set read only. Setting "True" value enables read only.
         * @param {HTMLInputElement | HTMLTextAreaElement} element
         * - The element which is need to enable read only.
         */
        function setReadonly(isReadonly, element, floatLabelType) {
            if (isReadonly) {
                ej2_base_1.attributes(element, { readonly: '' });
            }
            else {
                element.removeAttribute('readonly');
            }
            if (!ej2_base_2.isNullOrUndefined(floatLabelType)) {
                validateLabel(element, floatLabelType);
            }
        }
        Input.setReadonly = setReadonly;
        /**
         * Displays the element direction from right to left when its enabled.
         * ```
         * E.g : Input.setEnableRtl(true, [inputObj.container]);
         * ```
         *
         * @param {boolean} isRtl
         * - Boolean value to specify whether to set RTL. Setting "True" value enables the RTL mode.
         * @param {Element[] | NodeList} elements
         * - The elements that are needed to enable/disable RTL.
         */
        function setEnableRtl(isRtl, elements) {
            if (isRtl) {
                ej2_base_1.addClass(elements, CLASSNAMES.RTL);
            }
            else {
                ej2_base_1.removeClass(elements, CLASSNAMES.RTL);
            }
        }
        Input.setEnableRtl = setEnableRtl;
        /**
         * Enables or disables the given input element.
         * ```
         * E.g : Input.setEnabled(false, element);
         * ```
         *
         * @param {boolean} isEnable
         * - Boolean value to specify whether to enable or disable.
         * @param {HTMLInputElement | HTMLTextAreaElement} element
         * - Element to be enabled or disabled.
         */
        function setEnabled(isEnable, element, floatLabelType, inputContainer) {
            var disabledAttrs = { 'disabled': '', 'aria-disabled': 'true' };
            var considerWrapper = ej2_base_2.isNullOrUndefined(inputContainer) ? false : true;
            if (isEnable) {
                element.classList.remove(CLASSNAMES.DISABLE);
                removeAttributes(disabledAttrs, element);
                if (considerWrapper) {
                    ej2_base_1.removeClass([inputContainer], CLASSNAMES.DISABLE);
                }
            }
            else {
                element.classList.add(CLASSNAMES.DISABLE);
                addAttributes(disabledAttrs, element);
                if (considerWrapper) {
                    ej2_base_1.addClass([inputContainer], CLASSNAMES.DISABLE);
                }
            }
            if (!ej2_base_2.isNullOrUndefined(floatLabelType)) {
                validateLabel(element, floatLabelType);
            }
        }
        Input.setEnabled = setEnabled;
        function setClearButton(isClear, element, inputObject, initial, internalCreateElement) {
            var makeElement = !ej2_base_2.isNullOrUndefined(internalCreateElement) ? internalCreateElement : ej2_base_1.createElement;
            if (isClear) {
                inputObject.clearButton = createClearButton(element, inputObject, initial, makeElement);
            }
            else {
                ej2_base_2.remove(inputObject.clearButton);
                inputObject.clearButton = null;
            }
        }
        Input.setClearButton = setClearButton;
        /**
         * Removing the multiple attributes from the given element such as "disabled","id" , etc.
         * ```
         * E.g : Input.removeAttributes({ 'disabled': 'disabled', 'aria-disabled': 'true' }, element);
         * ```
         *
         * @param {string} attrs
         * - Array of attributes which are need to removed from the element.
         * @param {HTMLInputElement | HTMLElement} element
         * - Element on which the attributes are needed to be removed.
         */
        function removeAttributes(attrs, element) {
            for (var _i = 0, _a = Object.keys(attrs); _i < _a.length; _i++) {
                var key = _a[_i];
                var parentElement = getParentNode(element);
                if (key === 'disabled') {
                    element.classList.remove(CLASSNAMES.DISABLE);
                }
                if (key === 'disabled' && parentElement.classList.contains(CLASSNAMES.INPUTGROUP)) {
                    parentElement.classList.remove(CLASSNAMES.DISABLE);
                }
                if (key === 'placeholder' && parentElement.classList.contains(CLASSNAMES.FLOATINPUT)) {
                    parentElement.getElementsByClassName(CLASSNAMES.FLOATTEXT)[0].textContent = '';
                }
                else {
                    element.removeAttribute(key);
                }
            }
        }
        Input.removeAttributes = removeAttributes;
        /**
         * Adding the multiple attributes to the given element such as "disabled","id" , etc.
         * ```
         * E.g : Input.addAttributes({ 'id': 'inputpopup' }, element);
         * ```
         *
         * @param {string} attrs
         * - Array of attributes which is added to element.
         * @param {HTMLInputElement | HTMLElement} element
         * - Element on which the attributes are needed to be added.
         */
        function addAttributes(attrs, element) {
            for (var _i = 0, _a = Object.keys(attrs); _i < _a.length; _i++) {
                var key = _a[_i];
                var parentElement = getParentNode(element);
                if (key === 'disabled') {
                    element.classList.add(CLASSNAMES.DISABLE);
                }
                if (key === 'disabled' && parentElement.classList.contains(CLASSNAMES.INPUTGROUP)) {
                    parentElement.classList.add(CLASSNAMES.DISABLE);
                }
                if (key === 'placeholder' && parentElement.classList.contains(CLASSNAMES.FLOATINPUT)) {
                    parentElement.getElementsByClassName(CLASSNAMES.FLOATTEXT)[0].textContent = attrs["" + key];
                }
                else {
                    element.setAttribute(key, attrs["" + key]);
                }
            }
        }
        Input.addAttributes = addAttributes;
        function removeFloating(input) {
            var container = input.container;
            if (!ej2_base_2.isNullOrUndefined(container) && container.classList.contains(CLASSNAMES.FLOATINPUT)) {
                var inputEle = container.querySelector('textarea') ? container.querySelector('textarea') :
                    container.querySelector('input');
                var placeholder = container.querySelector('.' + CLASSNAMES.FLOATTEXT).textContent;
                var clearButton = container.querySelector('.e-clear-icon') !== null;
                ej2_base_1.detach(container.querySelector('.' + CLASSNAMES.FLOATLINE));
                ej2_base_1.detach(container.querySelector('.' + CLASSNAMES.FLOATTEXT));
                ej2_base_1.classList(container, [CLASSNAMES.INPUTGROUP], [CLASSNAMES.FLOATINPUT]);
                unwireFloatingEvents(inputEle);
                ej2_base_1.attributes(inputEle, { 'placeholder': placeholder });
                inputEle.classList.add(CLASSNAMES.INPUT);
                if (!clearButton && inputEle.tagName === 'INPUT') {
                    inputEle.removeAttribute('required');
                }
            }
        }
        Input.removeFloating = removeFloating;
        function addFloating(input, type, placeholder, internalCreateElement) {
            var makeElement = !ej2_base_2.isNullOrUndefined(internalCreateElement) ? internalCreateElement : ej2_base_1.createElement;
            var container = ej2_base_2.closest(input, '.' + CLASSNAMES.INPUTGROUP);
            floatType = type;
            var customTag = container.tagName;
            customTag = customTag !== 'DIV' && customTag !== 'SPAN' ? customTag : null;
            var args = { element: input, floatLabelType: type,
                customTag: customTag, properties: { placeholder: placeholder } };
            if (type !== 'Never') {
                var iconEle = container.querySelector('.e-clear-icon');
                var inputObj = { container: container };
                input.classList.remove(CLASSNAMES.INPUT);
                createFloatingInput(args, inputObj, makeElement);
                createSpanElement(inputObj.container, makeElement);
                calculateWidth(args.element, inputObj.container);
                var isPrependIcon = container.classList.contains('e-float-icon-left');
                if (ej2_base_2.isNullOrUndefined(iconEle)) {
                    if (isPrependIcon) {
                        var inputWrap = container.querySelector('.e-input-in-wrap');
                        iconEle = inputWrap.querySelector('.e-input-group-icon');
                    }
                    else {
                        iconEle = container.querySelector('.e-input-group-icon');
                    }
                }
                if (ej2_base_2.isNullOrUndefined(iconEle)) {
                    if (isPrependIcon) {
                        iconEle = container.querySelector('.e-input-group-icon');
                    }
                }
                else {
                    var floatLine = container.querySelector('.' + CLASSNAMES.FLOATLINE);
                    var floatText = container.querySelector('.' + CLASSNAMES.FLOATTEXT);
                    var wrapper = isPrependIcon ? container.querySelector('.e-input-in-wrap') : container;
                    wrapper.insertBefore(input, iconEle);
                    wrapper.insertBefore(floatLine, iconEle);
                    wrapper.insertBefore(floatText, iconEle);
                }
            }
            else {
                unWireFloatLabelEvents(args);
            }
            checkFloatLabelType(type, input.parentElement);
        }
        Input.addFloating = addFloating;
        /**
         * Create the span inside the label and add the label text into the span textcontent
         * ```
         * E.g : Input.createSpanElement(inputObject, makeElement);
         * ```
         *
         * @param {Element} inputObject
         * - Element which is need to get the label
         * @param {createElementParams} makeElement
         * - Element which is need to create the span
         */
        function createSpanElement(inputObject, makeElement) {
            if (inputObject.classList.contains('e-outline') && inputObject.getElementsByClassName('e-float-text')[0]) {
                var labelSpanElement = makeElement('span', { className: CLASSNAMES.FLOATTEXTCONTENT });
                labelSpanElement.innerHTML = inputObject.getElementsByClassName('e-float-text')[0].innerHTML;
                inputObject.getElementsByClassName('e-float-text')[0].innerHTML = '';
                inputObject.getElementsByClassName('e-float-text')[0].appendChild(labelSpanElement);
            }
        }
        Input.createSpanElement = createSpanElement;
        /**
         * Enable or Disable the ripple effect on the icons inside the Input. Ripple effect is only applicable for material theme.
         * ```
         * E.g : Input.setRipple(true, [inputObjects]);
         * ```
         *
         * @param {boolean} isRipple
         * - Boolean value to specify whether to enable the ripple effect.
         * @param {InputObject[]} inputObj
         * - Specify the collection of input objects.
         */
        function setRipple(isRipple, inputObj) {
            for (var i = 0; i < inputObj.length; i++) {
                _internalRipple(isRipple, inputObj[parseInt(i.toString(), 10)].container);
            }
        }
        Input.setRipple = setRipple;
        function _internalRipple(isRipple, container, button) {
            var argsButton = [];
            argsButton.push(button);
            var buttons = ej2_base_2.isNullOrUndefined(button) ?
                container.querySelectorAll('.e-input-group-icon') : argsButton;
            if (isRipple && buttons.length > 0) {
                for (var index = 0; index < buttons.length; index++) {
                    buttons[parseInt(index.toString(), 10)].addEventListener('mousedown', _onMouseDownRipple, false);
                    buttons[parseInt(index.toString(), 10)].addEventListener('mouseup', _onMouseUpRipple, false);
                }
            }
            else Eif (buttons.length > 0) {
                for (var index = 0; index < buttons.length; index++) {
                    buttons[parseInt(index.toString(), 10)].removeEventListener('mousedown', _onMouseDownRipple, this);
                    buttons[parseInt(index.toString(), 10)].removeEventListener('mouseup', _onMouseUpRipple, this);
                }
            }
        }
        function _onMouseRipple(container, button) {
            if (!container.classList.contains('e-disabled') && !container.querySelector('input').readOnly) {
                button.classList.add('e-input-btn-ripple');
            }
        }
        function _isElementVisible(element) {
            Iif (!element) {
                return false;
            }
            // Check if the element or any of its parents are hidden using display: none
            var currentElement = element;
            while (currentElement && currentElement !== document.body) {
                var style = window.getComputedStyle(currentElement);
                if (style.display === 'none') {
                    return false;
                }
                currentElement = currentElement.parentElement;
            }
            // If none of the elements have display: none, the element is considered visible
            return true;
        }
        function _onMouseDownRipple() {
            var ele = null || this;
            var parentEle = this.parentElement;
            while (!parentEle.classList.contains('e-input-group')) {
                parentEle = parentEle.parentElement;
            }
            _onMouseRipple(parentEle, ele);
        }
        function _onMouseUpRipple() {
            var ele = null || this;
            setTimeout(function () {
                ele.classList.remove('e-input-btn-ripple');
            }, 500);
        }
        function createIconEle(iconClass, makeElement) {
            var button = makeElement('span', { className: iconClass });
            button.classList.add('e-input-group-icon');
            return button;
        }
        /**
         * Creates a new span element with the given icons added and append it in container element.
         * ```
         * E.g : Input.addIcon('append', 'e-icon-spin', inputObj.container, inputElement);
         * ```
         *
         * @param {string} position - Specify the icon placement on the input.Possible values are append and prepend.
         * @param {string | string[]} icons - Icon classes which are need to add to the span element which is going to created.
         * Span element acts as icon or button element for input.
         * @param {HTMLElement} container - The container on which created span element is going to append.
         * @param {HTMLElement} input - The inputElement on which created span element is going to prepend.
         */
        function addIcon(position, icons, container, input, internalCreate) {
            var result = typeof (icons) === 'string' ? icons.split(',')
                : icons;
            if (position.toLowerCase() === 'append') {
                for (var _i = 0, result_1 = result; _i < result_1.length; _i++) {
                    var icon = result_1[_i];
                    appendSpan(icon, container, internalCreate);
                }
            }
            else {
                for (var _a = 0, result_2 = result; _a < result_2.length; _a++) {
                    var icon = result_2[_a];
                    prependSpan(icon, container, input, internalCreate);
                }
            }
            Iif (container.getElementsByClassName('e-input-group-icon')[0] && container.getElementsByClassName('e-float-text-overflow')[0]) {
                container.getElementsByClassName('e-float-text-overflow')[0].classList.add('e-icon');
            }
        }
        Input.addIcon = addIcon;
        /**
         * Creates a new span element with the given icons added and prepend it in input element.
         * ```
         * E.g : Input.prependSpan('e-icon-spin', inputObj.container, inputElement);
         * ```
         *
         * @param {string} iconClass - Icon classes which are need to add to the span element which is going to created.
         * Span element acts as icon or button element for input.
         * @param {HTMLElement} container - The container on which created span element is going to append.
         * @param {HTMLElement} inputElement - The inputElement on which created span element is going to prepend.
         */
        function prependSpan(iconClass, container, inputElement, internalCreateElement) {
            var makeElement = !ej2_base_2.isNullOrUndefined(internalCreateElement) ? internalCreateElement : ej2_base_1.createElement;
            var button = createIconEle(iconClass, makeElement);
            container.classList.add('e-float-icon-left');
            var innerWrapper = container.querySelector('.e-input-in-wrap');
            if (ej2_base_2.isNullOrUndefined(innerWrapper)) {
                innerWrapper = makeElement('span', { className: 'e-input-in-wrap' });
                inputElement.parentNode.insertBefore(innerWrapper, inputElement);
                var result = container.querySelectorAll(inputElement.tagName + ' ~ *');
                innerWrapper.appendChild(inputElement);
                for (var i = 0; i < result.length; i++) {
                    var element = result[parseInt(i.toString(), 10)];
                    var parentElement = innerWrapper.parentElement;
                    Eif (!(element.classList.contains('e-float-line')) || (!(parentElement && parentElement.classList.contains('e-filled')) && parentElement)) {
                        innerWrapper.appendChild(element);
                    }
                }
            }
            innerWrapper.parentNode.insertBefore(button, innerWrapper);
            _internalRipple(true, container, button);
            return button;
        }
        Input.prependSpan = prependSpan;
        /**
         * Creates a new span element with the given icons added and append it in container element.
         * ```
         * E.g : Input.appendSpan('e-icon-spin', inputObj.container);
         * ```
         *
         * @param {string} iconClass - Icon classes which are need to add to the span element which is going to created.
         * Span element acts as icon or button element for input.
         * @param {HTMLElement} container - The container on which created span element is going to append.
         */
        function appendSpan(iconClass, container, internalCreateElement) {
            var makeElement = !ej2_base_2.isNullOrUndefined(internalCreateElement) ? internalCreateElement : ej2_base_1.createElement;
            var button = createIconEle(iconClass, makeElement);
            var wrap = (container.classList.contains('e-float-icon-left')) ? container.querySelector('.e-input-in-wrap') :
                container;
            wrap.appendChild(button);
            _internalRipple(true, container, button);
            return button;
        }
        Input.appendSpan = appendSpan;
        function validateInputType(containerElement, input) {
            if (input.type === 'hidden') {
                containerElement.classList.add('e-hidden');
            }
            else if (containerElement.classList.contains('e-hidden')) {
                containerElement.classList.remove('e-hidden');
            }
        }
        Input.validateInputType = validateInputType;
        function updateHTMLAttributesToElement(htmlAttributes, element) {
            if (!ej2_base_2.isNullOrUndefined(htmlAttributes)) {
                for (var _i = 0, _a = Object.keys(htmlAttributes); _i < _a.length; _i++) {
                    var key = _a[_i];
                    if (exports.containerAttributes.indexOf(key) < 0) {
                        element.setAttribute(key, htmlAttributes["" + key]);
                    }
                }
            }
        }
        Input.updateHTMLAttributesToElement = updateHTMLAttributesToElement;
        function updateCssClass(newClass, oldClass, container) {
            setCssClass(getInputValidClassList(newClass), [container], getInputValidClassList(oldClass));
        }
        Input.updateCssClass = updateCssClass;
        function getInputValidClassList(inputClassName) {
            var result = inputClassName;
            if (!ej2_base_2.isNullOrUndefined(inputClassName) && inputClassName !== '') {
                result = (inputClassName.replace(/\s+/g, ' ')).trim();
            }
            return result;
        }
        Input.getInputValidClassList = getInputValidClassList;
        function updateHTMLAttributesToWrapper(htmlAttributes, container) {
            if (!ej2_base_2.isNullOrUndefined(htmlAttributes)) {
                for (var _i = 0, _a = Object.keys(htmlAttributes); _i < _a.length; _i++) {
                    var key = _a[_i];
                    if (exports.containerAttributes.indexOf(key) > -1) {
                        if (key === 'class') {
                            var updatedClassValues = this.getInputValidClassList(htmlAttributes["" + key]);
                            if (updatedClassValues !== '') {
                                ej2_base_1.addClass([container], updatedClassValues.split(' '));
                            }
                        }
                        else if (key === 'style') {
                            var setStyle = container.getAttribute(key);
                            setStyle = !ej2_base_2.isNullOrUndefined(setStyle) ? (setStyle + htmlAttributes["" + key]) :
                                htmlAttributes["" + key];
                            container.setAttribute(key, setStyle);
                        }
                        else {
                            container.setAttribute(key, htmlAttributes["" + key]);
                        }
                    }
                }
            }
        }
        Input.updateHTMLAttributesToWrapper = updateHTMLAttributesToWrapper;
        function isBlank(inputString) {
            return (!inputString || /^\s*$/.test(inputString));
        }
        Input.isBlank = isBlank;
    })(Input = exports.Input || (exports.Input = {}));
});
/* eslint-enable valid-jsdoc, jsdoc/require-jsdoc, jsdoc/require-returns, jsdoc/require-param */