all files / spreadsheet/renderer/ sheet.js

93.94% Statements 698/743
86.87% Branches 496/571
96.61% Functions 57/59
93.93% Lines 696/741
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   885× 885× 885× 885× 885× 885×   1042× 1042× 1042× 81× 81× 81× 81× 81×     961× 961×   1042×     1042×     1042×     1042× 1042× 1042× 1042×       1042× 1042× 1042× 1042× 1042×   1042× 81× 81×       81×     1042× 1042×   1062× 1062× 1062× 1062× 1062×   1062× 84× 84× 84×     84× 84×   1062× 1062× 1062× 1062× 1062× 1062× 1062× 1062× 1059× 1059×           1059× 1059×   1059× 1059× 1059×           8782× 8782×   2124× 2124×   2124×   1057× 1057× 80× 80×       80×   80× 80× 80×   80× 80×     977×     1177× 1177× 1177× 1177× 1177× 1177× 1173×   1177× 1177× 75×   1177× 73×   1177× 1177×   1177× 1177×   1177× 73×   1177× 75×   1177×       1177× 1177× 1177× 1177×   1042× 1042× 1042× 81×   1042× 1042× 1042×   3207× 3207× 3207× 3207× 3347×   1042× 1042× 1042× 1042× 1042× 1042× 1042× 1042× 1042× 1039× 1039× 1039×   1042× 1042× 1042× 1042× 1042× 1042× 1042× 1042× 1042× 1042× 1042× 1042× 1042× 1042× 1042× 1042× 1042× 1042× 1042× 1042× 1042× 1042× 1042× 1042× 1042× 1042× 1042× 1042× 2708620× 2708620× 62692× 58098×   62692× 173× 173×     172×   173×   62519× 4421× 4421×     58098× 58098× 195× 195×       195×       57903×   58098× 53504× 22×     53482×       62692× 58098×     2708620×       2708620× 4594×   2708620× 46865× 194× 194× 194×       194×   194×     46671× 46671×       1042×     1042× 1042× 1042×   1040× 1040× 1040× 85× 85× 152×           1040× 1040× 1040× 40×   1040× 1040× 30×   1040×   1040× 1040× 1040× 1040× 287×   1040× 1040× 1040×   1040×   1040× 753× 753× 725× 551×       753× 745×                 745×             769× 769×   769× 753×                   753×   753× 753× 753×   769×   1040× 1040× 1040×         1040×           1119×   40× 40× 40× 40×   39×       823× 125× 125× 238×       183× 183× 183× 183× 183× 183× 183× 183× 183× 183× 183× 183× 183× 183× 181× 181× 181× 181× 181× 181× 181× 181× 181× 181× 181× 181×   181× 181×   181× 181× 400238× 400238× 7645× 7645× 7645×   400238× 9376× 22×     9354×   9376× 9376× 9376×           400238×     400238×         400238× 400238× 301×     181× 181× 181× 181× 181× 181× 181× 181× 181× 70×   181×     181× 181×   181× 181×   181×   181× 64×     117×     181× 181× 181× 181× 181× 181× 181× 181× 181× 181× 181× 181× 181× 181× 181× 181×   181× 181× 403746× 403746× 9600× 9396×   9600× 204× 204×     9396× 9192×   9396× 9396×   9600× 9396× 9396×     403746× 9435×   403746×         403746× 403746× 204×     181×     181× 181× 181×   181× 181× 181×   181× 181× 46×   181× 181×   181×     181× 181×   181×   54700× 54700× 54700× 54656× 54656×     44×     49× 49× 49× 49× 49× 49× 49× 49× 49× 49× 49× 49× 49× 49× 49× 49× 49× 49× 49× 49× 49× 49× 49× 49× 49× 9569×     9569× 9569× 605×     9569× 174× 28× 28× 28× 28× 28×     146× 146× 146×   174× 137× 137× 137×     9569× 2592×     2590× 2590×         2592× 2592×   9569×       9569× 1568× 1568× 1568×       8001×   9569× 7640×   9569× 15×     49× 49×   49× 49×   49×     49× 49×   49×     424× 424× 424× 12×   412× 412× 412× 412× 412× 412× 412× 412× 412× 412× 412× 412× 412× 412× 412× 412× 412× 412× 412× 24943× 24943× 530× 15×   530×   24943× 646× 573×   646× 73× 73×     573× 573× 573× 500×   573× 157×     646× 573× 573× 573× 157×       24943× 3338×   24943×         24943× 1381×     24943× 24943× 73× 73× 73×     412×     412×     407× 407×   412× 411×   412×   412×   412× 412×   412× 412×   412×   405657×   205× 205× 28×             28×     177× 22× 22×                           402411×   158× 158× 29×                       29×     129× 17×                                       1179×     2684× 2402× 2402× 10×       95× 79× 79×   79×     8084× 8084× 8084× 129× 129×   8084× 8084×   87× 87×     6842×   9076× 9076× 9074×   9076×   463×   2623×   3602×   375258×   19634×   18290×   84429×   885× 885× 885× 885×   885× 885× 885×   885× 885× 885× 885×   885× 885× 885× 885×   885× 885× 885× 885× 885×   885× 885× 885× 885×        
define(["require", "exports", "@syncfusion/ej2-base", "./../../workbook/common/index", "../../workbook/index", "../common/index", "../common/index", "../common/index", "../common/index", "../common/index", "../../workbook/index"], function (require, exports, ej2_base_1, index_1, index_2, index_3, index_4, index_5, index_6, index_7, index_8) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var SheetRender = (function () {
        function SheetRender(parent) {
            this.colGroupWidth = 30;
            this.parent = parent;
            this.col = parent.createElement('col');
            this.rowRenderer = parent.serviceLocator.getService('row');
            this.cellRenderer = parent.serviceLocator.getService('cell');
            this.addEventListener();
        }
        SheetRender.prototype.refreshSelectALLContent = function () {
            var cell;
            var sheet = this.parent.getActiveSheet();
            if (sheet.frozenColumns || sheet.frozenRows) {
                var tHead = this.getSelectAllTable().querySelector('thead');
                var row = this.rowRenderer.render();
                tHead.appendChild(row);
                cell = this.parent.createElement('th', { className: 'e-select-all-cell' });
                row.appendChild(cell);
            }
            else {
                cell = this.headerPanel.firstElementChild;
                cell.classList.add('e-select-all-cell');
            }
            cell.appendChild(this.parent.createElement('button', { className: 'e-selectall', id: this.parent.element.id + "_select_all",
                attrs: { 'aria-label': this.parent.serviceLocator.getService(index_7.locale).getConstant('SelectAll'), 'type': 'button' } }));
        };
        SheetRender.prototype.updateLeftColGroup = function (width, rowHdr) {
            Iif (width) {
                this.colGroupWidth = width;
            }
            Iif (!rowHdr) {
                rowHdr = this.getRowHeaderPanel();
            }
            var table = rowHdr.querySelector('table');
            var sheet = this.parent.getActiveSheet();
            var colGrp;
            Iif (width) {
                table.querySelector('colgroup').firstElementChild.style.width = this.colGroupWidth + "px";
            }
            else {
                colGrp = this.parent.createElement('colgroup');
                var col = this.col.cloneNode();
                col.style.width = this.colGroupWidth + "px";
                colGrp.appendChild(col);
                table.insertBefore(colGrp, table.querySelector('tbody'));
            }
            if (sheet.frozenRows || sheet.frozenColumns) {
                table = this.getSelectAllTable();
                Iif (width) {
                    table.querySelector('colgroup').firstElementChild.style.width = this.colGroupWidth + "px";
                }
                else {
                    table.insertBefore(colGrp.cloneNode(true), table.querySelector('thead'));
                }
            }
            this.setPanelWidth(sheet, rowHdr);
            this.setPanelHeight(sheet);
        };
        SheetRender.prototype.setPanelWidth = function (sheet, rowHdr, isRtlChange) {
            var scrollSize = this.getScrollSize(true);
            var width = this.getRowHeaderWidth(sheet);
            var offset = this.parent.enableRtl ? 'right' : 'left';
            var rtlOffset;
            if (isRtlChange) {
                rtlOffset = this.parent.enableRtl ? 'left' : 'right';
                this.getContentPanel().style["" + rtlOffset] = this.getColHeaderPanel().style["" + rtlOffset] = '';
            }
            if (sheet.frozenColumns) {
                var frozenCol = document.getElementById(this.parent.element.id + '_sheet').getElementsByClassName('e-frozen-column')[0];
                frozenCol.style.height = "calc(100% - " + scrollSize + "px)";
                Iif (isRtlChange) {
                    frozenCol.style["" + rtlOffset] = '';
                }
                frozenCol.style["" + offset] = width - index_5.getDPRValue(1) + 'Px';
                frozenCol.style.display = '';
            }
            this.setHeaderPanelWidth(this.getSelectAllContent(), width);
            this.getColHeaderPanel().style.width = "calc(100% - " + width + "px)";
            this.getColHeaderPanel().style["" + offset] = width + 'px';
            this.setHeaderPanelWidth(rowHdr, width);
            this.getContentPanel().style.width = "calc(100% - " + width + "px)";
            this.getContentPanel().style["" + offset] = width + 'px';
            var scroll = (this.contentPanel.nextElementSibling ? this.contentPanel.nextElementSibling : null);
            if (scroll) {
                Eif (scrollSize) {
                    scroll.style.height = scrollSize + 1 + 'px';
                }
                else {
                    scroll.style.height = '1px';
                    scroll.style.borderTopWidth = '0px';
                }
                scroll = scroll.firstElementChild;
                if (isRtlChange) {
                    scroll.style["" + rtlOffset] = '';
                }
                scroll.style["" + offset] = width + 'px';
                scroll.style.width = "calc(100% - " + width + "px)";
                Iif (ej2_base_1.Browser.userAgent.indexOf('Mac OS') > -1 && ej2_base_1.Browser.info.name === 'safari') {
                    scroll.style.height = '7px';
                    scroll.style.top = '-7px';
                }
            }
        };
        SheetRender.prototype.getScrollSize = function (addOffset) {
            var scrollSize = parseInt(this.headerPanel.style[this.parent.enableRtl ? 'margin-left' : 'margin-right'], 10);
            return scrollSize ? scrollSize + (addOffset ? 1 : 0) : 0;
        };
        SheetRender.prototype.setHeaderPanelWidth = function (content, width) {
            var emptyCol = [].slice.call(content.querySelectorAll('col.e-empty'));
            emptyCol.forEach(function (col) {
                width += parseInt(col.style.width, 10);
            });
            content.style.width = width + 'px';
        };
        SheetRender.prototype.setPanelHeight = function (sheet) {
            var scrollSize = this.getScrollSize(true);
            if (sheet.frozenRows) {
                var frozenHeight = this.getColHeaderHeight(sheet);
                Iif (!sheet.showHeaders && !sheet.frozenColumns) {
                    this.headerPanel.style.height = frozenHeight + 'px';
                }
                else {
                    this.headerPanel.style.height = '';
                }
                this.contentPanel.style.height = "calc(100% - " + (frozenHeight + scrollSize) + "px)";
                var frozenRow = document.getElementById(this.parent.element.id + '_sheet').getElementsByClassName('e-frozen-row')[0];
                frozenRow.style.width = ej2_base_1.Browser.isDevice ? '100%' :
                    "calc(100% - " + scrollSize + "px)";
                frozenRow.style.top = frozenHeight - 1 - (sheet.showHeaders ? 1 : 0) + 'px';
                frozenRow.style.display = '';
            }
            else {
                this.contentPanel.style.height = "calc(100% - " + ((sheet.showHeaders ? index_5.getDPRValue(31) : 0) + scrollSize) + "px)";
            }
        };
        SheetRender.prototype.renderPanel = function () {
            this.contentPanel = this.parent.createElement('div', { className: 'e-main-panel', attrs: { 'tabindex': '0' } });
            var sheet = this.parent.getActiveSheet();
            var id = this.parent.element.id;
            this.contentPanel.appendChild(this.parent.createElement('div', { className: 'e-row-header', id: id + "_row_header" }));
            this.initHeaderPanel();
            if (this.parent.allowScrolling) {
                this.parent.scrollModule.setPadding();
            }
            var sheetEle = document.getElementById(this.parent.element.id + '_sheet');
            if (sheet.frozenColumns) {
                sheetEle.classList.add('e-frozen-columns');
            }
            if (sheet.frozenRows) {
                sheetEle.classList.add('e-frozen-rows');
            }
            this.updateHideHeaders(sheet, sheetEle);
            if (!sheet.showGridLines) {
                sheetEle.classList.add('e-hide-gridlines');
            }
            var content = this.contentPanel.appendChild(this.parent.createElement('div', { className: 'e-sheet-content', id: id + "_main_content" }));
            if (!this.parent.allowScrolling) {
                content.style.overflow = 'hidden';
            }
            if (sheet.frozenRows) {
                sheetEle.appendChild(this.parent.createElement('div', { className: 'e-frozen-row', styles: 'display: none' }));
            }
            if (sheet.frozenColumns) {
                sheetEle.appendChild(this.parent.createElement('div', { className: 'e-frozen-column', styles: 'display: none' }));
            }
            Iif (ej2_base_1.Browser.userAgent.indexOf('Mac OS') > -1 && ej2_base_1.Browser.info.name === 'safari') {
                sheetEle.classList.add('e-mac-safari');
            }
        };
        SheetRender.prototype.initHeaderPanel = function () {
            var id = this.parent.element.id;
            this.headerPanel = this.parent.createElement('div', { className: 'e-header-panel' });
            this.headerPanel.appendChild(this.parent.createElement('div', { className: 'e-selectall-container', id: id + "_selectall" }));
            this.headerPanel.appendChild(this.parent.createElement('div', { className: 'e-column-header', id: id + "_col_header" }));
        };
        SheetRender.prototype.createHeaderTable = function () {
            var rowHdrEle = this.contentPanel.querySelector('.e-row-header');
            var sheet = this.parent.getActiveSheet();
            if (sheet.frozenRows || sheet.frozenColumns) {
                this.updateTable(sheet.frozenRows ? ['thead', 'tbody'] : ['thead'], 'selectall', this.headerPanel.querySelector('.e-selectall-container'));
            }
            this.updateTable(sheet.frozenRows ? ['thead', 'tbody'] : ['thead'], 'colhdr', this.headerPanel.querySelector('.e-column-header'));
            this.updateTable(['tbody'], 'rowhdr', rowHdrEle);
            this.updateLeftColGroup(null, rowHdrEle);
        };
        SheetRender.prototype.updateTable = function (tagName, name, appendTo) {
            var _this = this;
            var table = this.parent.createElement('table', { className: 'e-table', attrs: { 'role': 'grid' } });
            table.classList.add("e-" + name + "-table");
            appendTo.appendChild(table);
            tagName.forEach(function (tag) { table.appendChild(_this.parent.createElement(tag)); });
        };
        SheetRender.prototype.renderTable = function (args) {
            var _this = this;
            var indexes;
            var row;
            var hRow;
            var sheet = this.parent.getActiveSheet();
            var frag = document.createDocumentFragment();
            frag.appendChild(this.headerPanel);
            frag.appendChild(this.contentPanel);
            if (this.parent.allowScrolling) {
                var scrollPanel = this.parent.createElement('div', { className: 'e-scrollbar' });
                scrollPanel.appendChild(this.parent.createElement('div', { className: 'e-scroller' }));
                frag.appendChild(scrollPanel);
            }
            this.createHeaderTable();
            this.updateTable(['tbody'], 'content', this.contentPanel.lastElementChild);
            var colGrp = this.parent.createElement('colgroup');
            var col;
            var cTBody = this.contentPanel.querySelector('.e-sheet-content tbody');
            this.refreshSelectALLContent();
            var selectAllColGrp = this.getSelectAllContent().querySelector('colgroup');
            var rowHdrColGrp = this.getRowHeaderPanel().querySelector('colgroup');
            var selectAllHdrRow = this.getSelectAllContent().querySelector('thead .e-header-row');
            var rHdrTBody = this.contentPanel.querySelector('.e-row-header tbody');
            var selectAllTBody = this.getSelectAllContent().querySelector('tbody');
            var cHdrTHead = this.headerPanel.querySelector('.e-column-header thead');
            var cHdrTBody = this.headerPanel.querySelector('.e-column-header tbody');
            var cHdrRow = this.rowRenderer.render();
            cHdrTHead.appendChild(cHdrRow);
            this.getColHeaderTable().insertBefore(colGrp, cHdrTHead);
            var frozenRow = this.parent.frozenRowCount(sheet);
            var frozenCol = this.parent.frozenColCount(sheet);
            var lastFrozenCol = index_1.skipHiddenIdx(sheet, frozenCol - 1, false, 'columns');
            this.parent.notify(index_4.beforeContentLoaded, { top: args.top, left: args.left });
            var colCount = sheet.colCount.toString();
            var rowCount = sheet.colCount.toString();
            var layout = args.top && args.left ? 'RowColumn' : (args.top ? 'Row' : (args.left ? 'Column' : ''));
            this.parent.getColHeaderTable().setAttribute('aria-colcount', colCount);
            this.parent.getRowHeaderTable().setAttribute('aria-rowcount', rowCount);
            var emptyRow;
            ej2_base_1.attributes(this.parent.getContentTable(), { 'aria-rowcount': rowCount, 'aria-colcount': colCount });
            args.cells.forEach(function (value, key) {
                indexes = index_1.getRangeIndexes(key);
                if (indexes[1] === args.indexes[1] || !row) {
                    if (indexes[1] === args.indexes[1]) {
                        hRow = _this.rowRenderer.render(indexes[0], true);
                    }
                    if (frozenCol && frozenRow && indexes[1] < frozenCol && indexes[0] < frozenRow) {
                        emptyRow = selectAllTBody.querySelector('.e-empty');
                        if (emptyRow) {
                            selectAllTBody.insertBefore(hRow, emptyRow);
                        }
                        else {
                            selectAllTBody.appendChild(hRow);
                        }
                        row = hRow;
                    }
                    else if (frozenCol && indexes[1] < frozenCol) {
                        rHdrTBody.appendChild(hRow);
                        row = hRow;
                    }
                    else {
                        row = _this.rowRenderer.render(indexes[0]);
                        if (frozenRow && indexes[0] < frozenRow) {
                            emptyRow = cHdrTBody.querySelector('.e-empty');
                            Iif (emptyRow) {
                                cHdrTBody.insertBefore(row, emptyRow);
                            }
                            else {
                                cHdrTBody.appendChild(row);
                            }
                        }
                        else {
                            cTBody.appendChild(row);
                        }
                        if (indexes[1] === args.indexes[1]) {
                            if (frozenRow && indexes[0] < frozenRow) {
                                selectAllTBody.appendChild(hRow);
                            }
                            else {
                                rHdrTBody.appendChild(hRow);
                            }
                        }
                    }
                    if (indexes[1] === args.indexes[1]) {
                        _this.cellRenderer.renderRowHeader(indexes[0], hRow);
                    }
                }
                _this.cellRenderer.render({ colIdx: indexes[1], rowIdx: indexes[0], cell: value,
                    address: key, lastCell: indexes[1] === args.indexes[3], isHeightCheckNeeded: true, row: row, hRow: hRow,
                    pRow: row.previousSibling, pHRow: hRow.previousSibling, isRefreshing: args.isRefreshing,
                    first: layout ? (layout.includes('Row') ? (indexes[0] === args.indexes[0] ? 'Row' : (layout.includes('Column') ? (indexes[1] === args.indexes[1] ? 'Column' : '') : '')) : (indexes[1] === args.indexes[1] ? 'Column' : '')) : '' });
                if (frozenCol && indexes[1] === lastFrozenCol) {
                    row = null;
                }
                if (indexes[0] === args.indexes[0]) {
                    if (frozenCol && indexes[1] < frozenCol) {
                        col = _this.updateCol(sheet, indexes[1], selectAllColGrp);
                        var empty = rowHdrColGrp.querySelector('.e-empty');
                        Iif (empty) {
                            rowHdrColGrp.insertBefore(col.cloneNode(true), empty);
                        }
                        else {
                            rowHdrColGrp.appendChild(col.cloneNode(true));
                        }
                        _this.cellRenderer.renderColHeader(indexes[1], selectAllHdrRow);
                    }
                    else {
                        _this.updateCol(sheet, indexes[1], colGrp);
                        _this.cellRenderer.renderColHeader(indexes[1], cHdrRow);
                    }
                }
            });
            Iif (this.parent.isReact) {
                this.parent['renderReactTemplates']();
            }
            cTBody.parentElement.insertBefore(colGrp.cloneNode(true), cTBody);
            index_3.getUpdateUsingRaf(function () {
                if (!_this.parent) {
                    return;
                }
                var content = _this.parent.getMainContent();
                var sheetContent = document.getElementById(_this.parent.element.id + '_sheet');
                if (sheetContent.childElementCount && sheetContent.querySelector('.e-header-panel') !== _this.headerPanel) {
                    var sheetChild = sheetContent.children;
                    for (var i = 0; i < sheetChild.length; i++) {
                        if (!sheetChild[i].classList.contains('e-frozen-row') &&
                            !sheetChild[i].classList.contains('e-frozen-column') &&
                            !sheetChild[i].classList.contains('e-ss-overlay')) {
                            sheetContent.removeChild(sheetChild[i]);
                        }
                    }
                }
                sheetContent.appendChild(frag);
                sheetContent.style.backgroundColor = '';
                if (sheet.conditionalFormats && sheet.conditionalFormats.length) {
                    _this.parent.notify(index_1.applyCF, { indexes: args.indexes });
                }
                _this.checkRowHeightChanged(args, sheet);
                if (args.top) {
                    content.parentElement.scrollTop = args.top;
                }
                if (args.left) {
                    content.scrollLeft = args.left;
                    _this.parent.getColumnHeaderContent().scrollLeft = args.left;
                }
                _this.parent.notify(index_3.contentLoaded, args);
                _this.checkTableWidth(sheet);
                _this.parent.notify(index_3.editOperation, { action: 'renderEditor', initLoad: args.initLoad && !_this.parent.isOpen });
                if (!args.initLoad && !_this.parent.isOpen) {
                    _this.parent.hideSpinner();
                }
                index_4.setAriaOptions(content, { busy: false });
                _this.parent.trigger(index_4.dataBound, {});
                if (_this.parent.isEdit) {
                    _this.parent.notify(index_6.initiateEdit, null);
                }
                if (args.openOptions && args.openOptions.eventArgs && args.openOptions.eventArgs.triggerEvent) {
                    _this.parent.trigger('openComplete', { response: args.openOptions });
                }
                if (args.initLoad) {
                    var triggerEvent = true;
                    if (_this.parent.scrollSettings.enableVirtualization) {
                        for (var i = 0; i < sheet.ranges.length; i++) {
                            if (sheet.ranges[i].info.count - 1 > _this.parent.viewport.bottomIndex) {
                                triggerEvent = false;
                                break;
                            }
                        }
                    }
                    if (triggerEvent) {
                        Iif (_this.parent.isReact) {
                            setTimeout(function () {
                                if (!_this.parent) {
                                    return;
                                }
                                _this.triggerCreatedEvent();
                            });
                        }
                        else {
                            _this.triggerCreatedEvent();
                        }
                    }
                    else Eif (!_this.parent.isOpen) {
                        _this.parent.hideSpinner();
                    }
                }
            });
        };
        SheetRender.prototype.triggerCreatedEvent = function () {
            Eif (!this.parent.isOpen) {
                this.parent.hideSpinner();
            }
            if (this.parent.createdHandler) {
                Iif (this.parent.createdHandler.observers) {
                    this.parent['created'].observers =
                        this.parent.createdHandler.observers;
                    if (this.parent.isAngular &&
                        this.parent.createdHandler.currentObservers) {
                        this.parent['created'].currentObservers =
                            this.parent.createdHandler.currentObservers;
                    }
                }
                else {
                    this.parent.setProperties({ created: this.parent.createdHandler }, true);
                }
                this.parent.createdHandler = undefined;
                this.parent.trigger(index_5.created, null);
                this.parent.notify(index_7.clearUndoRedoCollection, null);
            }
            this.parent.notify(index_5.spreadsheetCreated, null);
        };
        SheetRender.prototype.checkRowHeightChanged = function (args, sheet) {
            var eventArgs = { top: args.top, left: args.left, sheet: sheet };
            this.parent.notify(index_7.getUpdatedScrollPosition, eventArgs);
            if (args.top !== eventArgs.top) {
                Iif (this.parent.scrollModule && this.parent.scrollModule.offset.top.idx && (eventArgs.top - args.top) <
                    index_8.getRowHeight(sheet, this.parent.scrollModule.offset.top.idx)) {
                    this.parent.scrollModule.offset.top.size = eventArgs.top;
                }
                args.top = eventArgs.top;
            }
            if (args.left !== eventArgs.left) {
                Iif (this.parent.scrollModule && this.parent.scrollModule.offset.left.idx && (eventArgs.left - args.left) <
                    index_2.getColumnWidth(sheet, this.parent.scrollModule.offset.left.idx)) {
                    this.parent.scrollModule.offset.left.size = eventArgs.left;
                }
                args.left = eventArgs.left;
            }
        };
        SheetRender.prototype.checkTableWidth = function (sheet) {
            if (this.parent.scrollSettings.isFinite && !this.parent.scrollSettings.enableVirtualization && sheet.colCount - 1 ===
                this.parent.viewport.rightIndex) {
                var cellsWidth = index_2.getColumnsWidth(sheet, this.parent.viewport.leftIndex + this.parent.frozenColCount(sheet), this.parent.viewport.rightIndex);
                var rowHdrWidth = this.getRowHeaderWidth(sheet);
                var scrollSize = this.getScrollSize();
                if (cellsWidth < this.contentPanel.getBoundingClientRect().width - rowHdrWidth - scrollSize) {
                    this.getContentPanel().style.width = cellsWidth + 'px';
                    this.getColHeaderPanel().style.width = cellsWidth + 'px';
                }
                else if (!this.getContentPanel().style.width.includes('calc')) {
                    this.getContentPanel().style.width = "calc(100% - " + rowHdrWidth + "px)";
                    this.getColHeaderPanel().style.width = "calc(100% - " + rowHdrWidth + "px)";
                }
            }
        };
        SheetRender.prototype.clearCFResult = function (sheet) {
            if (sheet.conditionalFormats && sheet.conditionalFormats.length) {
                var cfRule = sheet.conditionalFormats;
                for (var i = 0; i < cfRule.length; i++) {
                    delete cfRule[i].result;
                }
            }
        };
        SheetRender.prototype.refreshColumnContent = function (args) {
            var _this = this;
            var indexes;
            var row;
            var table;
            var count = 0;
            var cell;
            var col;
            var sheet = this.parent.getActiveSheet();
            var frag = document.createDocumentFragment();
            var hFrag = document.createDocumentFragment();
            var tBody = this.parent.element.querySelector('.e-sheet-content tbody');
            var hTBody = this.parent.element.querySelector('.e-column-header tbody');
            var colGrp = this.parent.element.querySelector('.e-sheet-content colgroup');
            colGrp = colGrp.cloneNode();
            frag.appendChild(colGrp);
            tBody = frag.appendChild(tBody.cloneNode(true));
            var hColGrp = colGrp.cloneNode();
            hFrag.appendChild(hColGrp);
            var tHead;
            tHead = this.parent.element.querySelector('.e-column-header thead');
            tHead = hFrag.appendChild(tHead.cloneNode(true));
            var hRow = tHead.querySelector('tr');
            hRow.innerText = '';
            var frozenRow = this.parent.frozenRowCount(sheet);
            var frozenCol = this.parent.frozenColCount(sheet);
            if (frozenRow) {
                hTBody = hFrag.appendChild(hTBody.cloneNode(true));
            }
            var lastFrozenRow = index_1.skipHiddenIdx(sheet, frozenRow - 1, false);
            var notFirstRow = this.parent.scrollSettings.enableVirtualization && this.parent.viewport.topIndex !==
                index_1.skipHiddenIdx(sheet, 0, true);
            this.clearCFResult(sheet);
            args.cells.forEach(function (value, key) {
                indexes = index_1.getRangeIndexes(key);
                if (indexes[0] === args.indexes[0]) {
                    col = _this.updateCol(sheet, indexes[1], hColGrp);
                    colGrp.appendChild(col.cloneNode());
                    _this.cellRenderer.renderColHeader(indexes[1], hRow);
                }
                if (indexes[1] - frozenCol === args.indexes[1]) {
                    if (indexes[0] < frozenRow) {
                        row = hTBody.children[count];
                    }
                    else {
                        row = tBody.children[count];
                    }
                    Eif (row) {
                        row.innerText = '';
                        count++;
                    }
                    else {
                        return;
                    }
                }
                Iif (!row) {
                    return;
                }
                cell = _this.cellRenderer.render({
                    colIdx: indexes[1], rowIdx: indexes[0], cell: value, address: key, row: row, pRow: row.previousSibling,
                    first: !args.skipUpdateOnFirst && indexes[1] === args.indexes[1] ? 'Column' :
                        (notFirstRow && indexes[0] === args.indexes[0] ? 'Row' : ''), isRefreshing: true
                });
                _this.checkColMerge(indexes, args.indexes, cell, value);
                if (frozenRow && indexes[0] === lastFrozenRow) {
                    count = 0;
                }
            });
            var appendColumns = function () {
                table = _this.getColHeaderTable();
                index_3.removeAllChildren(table);
                table.appendChild(hFrag);
                table = _this.getContentTable();
                index_3.removeAllChildren(table);
                table.appendChild(frag);
                _this.parent.notify(index_4.virtualContentLoaded, { refresh: 'Column', prevRowColCnt: args.prevRowColCnt });
                if (sheet.conditionalFormats && sheet.conditionalFormats.length) {
                    _this.parent.notify(index_1.applyCF, { indexes: args.indexes, isRender: true });
                }
                Iif (_this.parent.isEdit) {
                    _this.parent.notify(index_6.forRefSelRender, {});
                }
                Eif (_this.parent.allowChart) {
                    _this.parent.notify(index_6.chartRangeSelection, null);
                }
                Eif (!_this.parent.isOpen) {
                    _this.parent.hideSpinner();
                }
                index_4.setAriaOptions(_this.parent.getMainContent(), { busy: false });
            };
            if (args.insertDelete) {
                appendColumns();
            }
            else {
                index_3.getUpdateUsingRaf(function () { return appendColumns(); });
            }
        };
        SheetRender.prototype.refreshRowContent = function (args) {
            var _this = this;
            var indexes;
            var row;
            var hdrRow;
            var colGroupWidth = this.colGroupWidth;
            var sheet = this.parent.getActiveSheet();
            var cell;
            var frag = document.createDocumentFragment();
            var tBody = this.parent.createElement('tbody');
            var hFrag = document.createDocumentFragment();
            var hTBody = tBody.cloneNode();
            hFrag.appendChild(hTBody);
            frag.appendChild(tBody);
            var frozenCol = this.parent.frozenColCount(sheet);
            var lastFrozenCol = index_1.skipHiddenIdx(sheet, frozenCol - 1, false, 'columns');
            var notFirstCol = this.parent.scrollSettings.enableVirtualization && this.parent.viewport.leftIndex !==
                index_1.skipHiddenIdx(sheet, 0, true, 'columns');
            this.clearCFResult(sheet);
            args.cells.forEach(function (value, key) {
                indexes = index_1.getRangeIndexes(key);
                if (indexes[1] === args.indexes[1] || !row) {
                    if (indexes[1] === args.indexes[1]) {
                        hdrRow = _this.rowRenderer.render(indexes[0], true);
                    }
                    if (frozenCol && indexes[1] < frozenCol) {
                        hTBody.appendChild(hdrRow);
                        row = hdrRow;
                    }
                    else {
                        if (indexes[1] === args.indexes[1]) {
                            hTBody.appendChild(hdrRow);
                        }
                        row = _this.rowRenderer.render(indexes[0]);
                        tBody.appendChild(row);
                    }
                    if (indexes[1] === args.indexes[1]) {
                        _this.cellRenderer.renderRowHeader(indexes[0], hdrRow);
                        colGroupWidth = index_4.getColGroupWidth(indexes[0] + 1);
                    }
                }
                if (frozenCol) {
                    hdrRow = hTBody.lastElementChild || hdrRow;
                }
                cell = _this.cellRenderer.render({
                    rowIdx: indexes[0], colIdx: indexes[1], cell: value, address: key, lastCell: indexes[1] === args.indexes[3], row: row, hRow: hdrRow, pRow: row.previousSibling,
                    pHRow: hdrRow.previousSibling, isHeightCheckNeeded: true, first: !args.skipUpdateOnFirst && indexes[0] === args.indexes[0] ?
                        'Row' : (notFirstCol && indexes[1] === args.indexes[1] ? 'Column' : ''), isRefreshing: true
                });
                _this.checkRowMerge(indexes, args.indexes, cell, value);
                if (frozenCol && indexes[1] === lastFrozenCol) {
                    row = null;
                }
            });
            Iif (this.colGroupWidth !== colGroupWidth) {
                this.updateLeftColGroup(colGroupWidth);
            }
            Eif (this.contentPanel.querySelector('.e-row-header tbody')) {
                ej2_base_1.detach(this.contentPanel.querySelector('.e-row-header tbody'));
                this.getRowHeaderTable().appendChild(hFrag);
            }
            Eif (this.contentPanel.querySelector('.e-sheet-content tbody')) {
                ej2_base_1.detach(this.contentPanel.querySelector('.e-sheet-content tbody'));
                this.getContentTable().appendChild(frag);
            }
            this.parent.notify(index_4.virtualContentLoaded, { refresh: 'Row', prevRowColCnt: args.prevRowColCnt });
            if (sheet.conditionalFormats && sheet.conditionalFormats.length) {
                this.parent.notify(index_1.applyCF, { indexes: args.indexes, isRender: true });
            }
            Eif (this.parent.allowChart) {
                this.parent.notify(index_6.chartRangeSelection, {});
            }
            Iif (this.parent.isEdit) {
                this.parent.notify(index_6.forRefSelRender, null);
            }
            Eif (!this.parent.isOpen) {
                this.parent.hideSpinner();
            }
            index_4.setAriaOptions(this.parent.getMainContent(), { busy: false });
        };
        SheetRender.prototype.updateCol = function (sheet, idx, appendTo) {
            var col = this.col.cloneNode();
            col.style.width = ej2_base_1.formatUnit(index_2.getColumnWidth(sheet, idx, null, true));
            if (appendTo) {
                var empty = appendTo.querySelector('.e-empty');
                return empty ? appendTo.insertBefore(col, empty) : appendTo.appendChild(col);
            }
            else {
                return col;
            }
        };
        SheetRender.prototype.updateColContent = function (args) {
            var _this = this;
            index_3.getUpdateUsingRaf(function () {
                var indexes;
                var row;
                var refChild;
                var cell;
                var rowCount = 0;
                var col;
                var sheet = _this.parent.getActiveSheet();
                var hRow = _this.parent.element.querySelector('.e-column-header .e-header-row');
                var hRefChild = hRow.firstElementChild;
                var colGrp = _this.parent.element.querySelector('.e-sheet-content colgroup');
                var hColGrp = _this.parent.element.querySelector('.e-column-header colgroup');
                var colRefChild = colGrp.firstElementChild;
                var skipRender;
                var hColRefChild = hColGrp.firstElementChild;
                var tBody = _this.parent.element.querySelector('.e-sheet-content tbody');
                var hTBody = _this.parent.element.querySelector('.e-column-header tbody');
                var frozenRow = _this.parent.frozenRowCount(sheet);
                var frozenCol = _this.parent.frozenColCount(sheet);
                var lastFrozenRow = index_1.skipHiddenIdx(sheet, frozenRow - 1, false);
                var firstRow = index_1.skipHiddenIdx(sheet, args.indexes[0], true);
                var cellArgs;
                _this.clearCFResult(sheet);
                args.cells.forEach(function (value, key) {
                    Iif (skipRender) {
                        return;
                    }
                    indexes = index_1.getRangeIndexes(key);
                    if (args.direction === 'first' && indexes[1] === args.indexes[1]) {
                        _this.checkColMerge([indexes[0], _this.parent.viewport.leftIndex + frozenCol], args.indexes, ((indexes[0] < frozenRow ? hTBody : tBody).rows[rowCount] ||
                            { cells: [] }).cells[(args.indexes[3] - args.indexes[1]) + 1], index_8.getCell(indexes[0], _this.parent.viewport.leftIndex + frozenCol, sheet) || {});
                    }
                    if (indexes[0] === firstRow) {
                        if (args.direction === 'last') {
                            col = _this.col.cloneNode();
                            col.style.width = ej2_base_1.formatUnit(index_2.getColumnWidth(sheet, indexes[1], null, true));
                            colGrp.insertBefore(col, colRefChild);
                            hColGrp.insertBefore(col.cloneNode(), hColRefChild);
                            _this.cellRenderer.renderColHeader(indexes[1], hRow, hRefChild);
                        }
                        else {
                            col = _this.updateCol(sheet, indexes[1], colGrp);
                            hColGrp.appendChild(col.cloneNode());
                            _this.cellRenderer.renderColHeader(indexes[1], hRow);
                        }
                        if (_this.parent.scrollSettings.enableVirtualization && args.direction) {
                            ej2_base_1.detach(colGrp[args.direction + 'ElementChild']);
                            ej2_base_1.detach(hColGrp[args.direction + 'ElementChild']);
                            ej2_base_1.detach(hRow[args.direction + 'ElementChild']);
                        }
                    }
                    if (indexes[1] === args.indexes[1]) {
                        if (indexes[0] < frozenRow) {
                            row = hTBody.children[rowCount];
                        }
                        else {
                            row = tBody.children[rowCount];
                            Iif (!row) {
                                skipRender = true;
                                return;
                            }
                        }
                        rowCount++;
                        refChild = row.firstElementChild;
                    }
                    cellArgs = { colIdx: indexes[1], rowIdx: indexes[0], cell: value, address: key, row: row,
                        lastCell: indexes[1] === args.indexes[3], isHeightCheckNeeded: args.direction === 'first', first: args.direction ===
                            'last' && !args.skipUpdateOnFirst && indexes[1] === args.indexes[1] ? 'Column' : '', checkNextBorder: args.direction
                            === 'last' && indexes[3] === args.indexes[3] ? 'Column' : '', isRefreshing: args.direction === 'first' };
                    if (args.direction === 'last') {
                        cellArgs.refChild = refChild;
                        cell = _this.cellRenderer.render(cellArgs);
                        _this.checkColMerge(indexes, args.indexes, cell, value, ((indexes[0] < frozenRow ? hTBody : tBody).rows[rowCount - 1] ||
                            { cells: [] }).cells[1]);
                    }
                    else {
                        cell = _this.cellRenderer.render(cellArgs);
                    }
                    if (_this.parent.scrollSettings.enableVirtualization && args.direction) {
                        ej2_base_1.detach(row[args.direction + 'ElementChild']);
                    }
                    if (frozenRow && indexes[0] === lastFrozenRow) {
                        rowCount = 0;
                    }
                });
                _this.parent.notify(index_4.virtualContentLoaded, { refresh: 'Column', prevRowColCnt: args.prevRowColCnt });
                if (sheet.conditionalFormats && sheet.conditionalFormats.length) {
                    _this.parent.notify(index_1.applyCF, { indexes: args.indexes, isRender: true });
                }
                Eif (_this.parent.allowChart) {
                    _this.parent.notify(index_6.chartRangeSelection, null);
                }
                Iif (_this.parent.isEdit) {
                    _this.parent.notify(index_6.forRefSelRender, {});
                }
                Eif (!_this.parent.isOpen) {
                    _this.parent.hideSpinner();
                }
                index_4.setAriaOptions(_this.parent.getMainContent(), { busy: false });
            });
        };
        SheetRender.prototype.updateRowContent = function (args) {
            var _this = this;
            var mainContent = this.parent.getMainContent();
            if (args.direction === '' && !mainContent.children.length) {
                return;
            }
            var colGroupWidth = this.colGroupWidth;
            var row;
            var hRow;
            var cell;
            var sheet = this.parent.getActiveSheet();
            var count = 0;
            var tBody = mainContent.querySelector('tbody');
            var rTBody = this.parent.getRowHeaderContent().querySelector('tbody');
            var rFrag = document.createDocumentFragment();
            var indexes;
            var frag = document.createDocumentFragment();
            this.parent.showSpinner();
            var frozenCol = this.parent.frozenColCount(sheet);
            var frozenRow = this.parent.frozenRowCount(sheet);
            var firstRow;
            var firstCol = index_1.skipHiddenIdx(sheet, args.indexes[1], true, 'columns');
            var lastFrozenCol = index_1.skipHiddenIdx(sheet, frozenCol - 1, false, 'columns');
            this.clearCFResult(sheet);
            args.cells.forEach(function (value, cKey) {
                indexes = index_1.getRangeIndexes(cKey);
                if (args.direction === 'first' && indexes[0] === args.indexes[0]) {
                    if (firstRow === undefined) {
                        firstRow = (indexes[1] < frozenCol ? rTBody : tBody).rows[(args.indexes[2] - args.indexes[0]) + 1] || null;
                    }
                    _this.checkRowMerge([_this.parent.viewport.topIndex + frozenRow, indexes[1]], args.indexes, (firstRow || { cells: [] }).cells[indexes[1] < frozenCol ? count + 1 : count], index_8.getCell(_this.parent.viewport.topIndex + frozenRow, indexes[1], sheet) || {});
                }
                if (indexes[1] === firstCol || !row) {
                    if (indexes[1] === firstCol) {
                        hRow = _this.rowRenderer.render(indexes[0], true);
                    }
                    if (frozenCol && indexes[1] < frozenCol) {
                        rFrag.appendChild(hRow);
                        row = hRow;
                    }
                    else {
                        row = _this.rowRenderer.render(indexes[0]);
                        frag.appendChild(row);
                        if (indexes[1] === firstCol) {
                            rFrag.appendChild(hRow);
                        }
                        if (_this.parent.scrollSettings.enableVirtualization && args.direction) {
                            ej2_base_1.detach(tBody[args.direction + 'ElementChild']);
                        }
                    }
                    if (indexes[1] === firstCol) {
                        _this.cellRenderer.renderRowHeader(indexes[0], hRow);
                        colGroupWidth = index_4.getColGroupWidth(indexes[0] + 1);
                        if (_this.parent.scrollSettings.enableVirtualization && args.direction) {
                            ej2_base_1.detach(rTBody[args.direction + 'ElementChild']);
                        }
                    }
                }
                if (frozenCol) {
                    hRow = rFrag.lastElementChild || hRow;
                }
                cell = _this.cellRenderer.render({ colIdx: indexes[1], rowIdx: indexes[2], cell: value, address: cKey, row: row,
                    lastCell: indexes[1] === args.indexes[3], pHRow: hRow.previousSibling, checkNextBorder: args.direction === 'last' &&
                        indexes[2] === args.indexes[2] ? 'Row' : '', pRow: row.previousSibling, isHeightCheckNeeded: args.direction === 'first'
                        || args.direction === '', hRow: hRow, first: args.direction === 'last' && !args.skipUpdateOnFirst && indexes[0] ===
                        args.indexes[0] ? 'Row' : '', isRefreshing: args.direction === 'first' });
                if (args.direction === 'last' && tBody.rows.length) {
                    _this.checkRowMerge(indexes, args.indexes, cell, value, (indexes[1] < frozenCol ? rTBody : tBody).rows[0].cells[indexes[1] < frozenCol ?
                        count + 1 : count]);
                }
                count++;
                if (frozenCol && indexes[1] === lastFrozenCol) {
                    row = null;
                    firstRow = undefined;
                    count = 0;
                }
            });
            Iif (this.colGroupWidth !== colGroupWidth) {
                this.updateLeftColGroup(colGroupWidth);
            }
            if (args.direction === 'last') {
                rTBody.insertBefore(rFrag, rTBody.firstElementChild);
                tBody.insertBefore(frag, tBody.firstElementChild);
            }
            else {
                rTBody.appendChild(rFrag);
                tBody.appendChild(frag);
            }
            if (this.parent.scrollSettings.enableVirtualization) {
                this.parent.notify(index_4.virtualContentLoaded, { refresh: 'Row', prevRowColCnt: args.prevRowColCnt });
            }
            if (sheet.conditionalFormats && sheet.conditionalFormats.length) {
                this.parent.notify(index_1.applyCF, { indexes: args.indexes, isRender: true });
            }
            if (this.parent.isEdit) {
                this.parent.notify(index_6.forRefSelRender, null);
            }
            Eif (this.parent.allowChart) {
                this.parent.notify(index_6.chartRangeSelection, {});
            }
            Eif (!this.parent.isOpen) {
                this.parent.hideSpinner();
            }
            index_4.setAriaOptions(this.parent.getMainContent(), { busy: false });
        };
        SheetRender.prototype.checkRowMerge = function (indexes, range, cell, model, firstcell) {
            if (this.parent.scrollSettings.enableVirtualization && cell &&
                (!ej2_base_1.isNullOrUndefined(model.rowSpan) || !ej2_base_1.isNullOrUndefined(model.colSpan))) {
                var frozenRow = this.parent.frozenRowCount(this.parent.getActiveSheet());
                if (indexes[0] === this.parent.viewport.topIndex + frozenRow) {
                    if (model.rowSpan < 0) {
                        var args = { td: cell, rowIdx: indexes[0], colIdx: indexes[1], isRow: true,
                            isFreezePane: true };
                        this.parent.notify(index_6.checkMerge, args);
                        Iif (args.insideFreezePane) {
                            return;
                        }
                        Iif (this.parent.viewport.topIndex + frozenRow >= range[2]) {
                            this.refreshPrevMerge(range[2] + 1, indexes[1]);
                        }
                    }
                    if (firstcell) {
                        this.refreshFirstCell(indexes[0] + (range[2] - range[0]) + 1, indexes[1], firstcell);
                    }
                }
                else if (model.rowSpan > 1) {
                    var prevTopIdx = range[2] + 1;
                    Iif (indexes[0] + model.rowSpan - 1 >= prevTopIdx && indexes[0] < prevTopIdx) {
                        this.refreshPrevMerge(prevTopIdx, indexes[1], this.parent.viewport.topIndex + frozenRow);
                    }
                }
            }
        };
        SheetRender.prototype.refreshPrevMerge = function (prevTopIdx, colIndex, currTopIdx) {
            var td = this.parent.getCell(prevTopIdx, colIndex, this.parent.getRow(currTopIdx ?
                currTopIdx : 0, null, colIndex));
            if (td) {
                this.cellRenderer.refresh(prevTopIdx, colIndex, null, td);
            }
        };
        SheetRender.prototype.refreshFirstCell = function (rowIdx, colIdex, firstcell) {
            var cell = index_8.getCell(rowIdx, colIdex, this.parent.getActiveSheet(), false, true);
            Eif (cell.rowSpan < 0 || cell.colSpan < 0) {
                this.cellRenderer.refresh(rowIdx, colIdex, null, firstcell);
            }
        };
        SheetRender.prototype.checkColMerge = function (indexes, range, cell, model, firstcell) {
            if (this.parent.scrollSettings.enableVirtualization && cell && (!ej2_base_1.isNullOrUndefined(model.rowSpan) ||
                !ej2_base_1.isNullOrUndefined(model.colSpan))) {
                var frozenCol = this.parent.frozenColCount(this.parent.getActiveSheet());
                if (indexes[1] === this.parent.viewport.leftIndex + frozenCol) {
                    if (model.colSpan < 0) {
                        var e = {
                            td: cell,
                            colIdx: indexes[1], rowIdx: indexes[0], isFreezePane: true
                        };
                        this.parent.notify(index_6.checkMerge, e);
                        Iif (e.insideFreezePane) {
                            return;
                        }
                        Iif (this.parent.viewport.leftIndex + frozenCol >= range[3]) {
                            var td = this.parent.getCell(indexes[0], indexes[3] + 1, this.parent.getRow(indexes[0], null, indexes[3] + 1));
                            if (td) {
                                this.cellRenderer.refresh(indexes[0], range[3] + 1, null, td);
                            }
                        }
                    }
                    if (firstcell) {
                        this.refreshFirstCell(indexes[0], indexes[1] + (range[3] - range[1]) + 1, firstcell);
                    }
                }
                else if (model.colSpan > 1) {
                    if (indexes[1] + model.colSpan - 1 >= range[3] + 1 && indexes[1] < range[3] + 1) {
                        var td = this.parent.getCell(indexes[0], indexes[3] + 1, this.parent.getRow(indexes[0], null, indexes[3] + 1));
                        Eif (td) {
                            this.cellRenderer.refresh(indexes[0], range[3] + 1, null, td);
                        }
                    }
                }
            }
        };
        SheetRender.prototype.toggleGridlines = function () {
            var sheetElem = document.getElementById(this.parent.element.id + '_sheet');
            if (this.parent.getActiveSheet().showGridLines) {
                sheetElem.classList.remove('e-hide-gridlines');
            }
            else {
                sheetElem.classList.add('e-hide-gridlines');
            }
        };
        SheetRender.prototype.showHideHeaders = function () {
            var _this = this;
            var sheet = this.parent.getActiveSheet();
            index_3.getUpdateUsingRaf(function () {
                if (sheet.showHeaders) {
                    var content = _this.getContentPanel();
                    _this.setPanelWidth(sheet, _this.getRowHeaderPanel());
                    _this.setPanelHeight(sheet);
                    document.getElementById(_this.parent.element.id + '_sheet').classList.remove('e-hide-headers');
                    _this.getColHeaderPanel().scrollLeft = content.scrollLeft;
                    _this.parent.selectRange(sheet.selectedRange);
                }
                else {
                    _this.updateHideHeaders(sheet, document.getElementById(_this.parent.element.id + '_sheet'));
                    _this.setPanelHeight(sheet);
                    Iif (_this.parent.frozenColCount(sheet) || _this.parent.frozenRowCount(sheet)) {
                        _this.setPanelWidth(sheet, _this.getRowHeaderPanel());
                        _this.parent.selectRange(sheet.selectedRange);
                    }
                    else {
                        _this.getContentPanel().style.width = '';
                        _this.getContentPanel().style[_this.parent.enableRtl ? 'right' : 'left'] = '';
                    }
                    _this.getScrollElement().style.left = _this.getRowHeaderWidth(sheet) + 'px';
                }
            });
        };
        SheetRender.prototype.updateHideHeaders = function (sheet, ele) {
            if (!sheet.showHeaders) {
                ele.classList.add('e-hide-headers');
            }
        };
        SheetRender.prototype.rowHeightChanged = function (args) {
            if (args.threshold || args.isHideShow) {
                var sheet = this.parent.getActiveSheet();
                if (args.rowIdx < this.parent.frozenRowCount(sheet)) {
                    this.setPanelHeight(sheet);
                }
            }
        };
        SheetRender.prototype.colWidthChanged = function (args) {
            if (args.threshold || args.isHideShow) {
                var sheet = this.parent.getActiveSheet();
                if (args.colIdx < this.parent.frozenColCount(sheet)) {
                    this.setPanelWidth(sheet, this.getRowHeaderPanel());
                }
                this.checkTableWidth(sheet);
            }
        };
        SheetRender.prototype.getRowHeaderWidth = function (sheet, skipFreezeCheck, addScaling) {
            var width = 0;
            var scaleX = addScaling ? this.parent.viewport.scaleX : 1;
            if (!skipFreezeCheck && sheet.frozenColumns) {
                var leftIdx = index_1.getCellIndexes(sheet.topLeftCell)[1];
                width = index_2.getColumnsWidth(sheet, leftIdx, leftIdx + sheet.frozenColumns - 1, true) / scaleX;
            }
            width += (sheet.showHeaders ? index_5.getDPRValue(this.colGroupWidth) / scaleX : 0);
            return width;
        };
        SheetRender.prototype.getColHeaderHeight = function (sheet, skipHeader) {
            var topIndex = index_1.getCellIndexes(sheet.topLeftCell)[0];
            return (sheet.showHeaders && !skipHeader ? index_5.getDPRValue(31) : 0) +
                index_8.getRowsHeight(sheet, topIndex, topIndex + sheet.frozenRows - 1, true);
        };
        SheetRender.prototype.getSelectAllContent = function () {
            return this.headerPanel.getElementsByClassName('e-selectall-container')[0];
        };
        SheetRender.prototype.getScrollElement = function () {
            var elem;
            if (this.contentPanel) {
                elem = (this.contentPanel.parentElement || this.contentPanel.nextElementSibling);
            }
            return elem && elem.querySelector('.e-scroller');
        };
        SheetRender.prototype.getSelectAllTable = function () {
            return this.headerPanel.getElementsByClassName('e-selectall-table')[0];
        };
        SheetRender.prototype.getColHeaderTable = function () {
            return this.headerPanel.getElementsByClassName('e-colhdr-table')[0];
        };
        SheetRender.prototype.getRowHeaderTable = function () {
            return this.contentPanel.getElementsByClassName('e-rowhdr-table')[0];
        };
        SheetRender.prototype.getContentTable = function () {
            return this.contentPanel.getElementsByClassName('e-content-table')[0];
        };
        SheetRender.prototype.getRowHeaderPanel = function () {
            return this.contentPanel.getElementsByClassName('e-row-header')[0];
        };
        SheetRender.prototype.getColHeaderPanel = function () {
            return this.headerPanel.getElementsByClassName('e-column-header')[0];
        };
        SheetRender.prototype.getContentPanel = function () {
            return this.contentPanel.getElementsByClassName('e-sheet-content')[0];
        };
        SheetRender.prototype.addEventListener = function () {
            this.parent.on(index_5.created, this.triggerCreatedEvent, this);
            this.parent.on(index_6.rowHeightChanged, this.rowHeightChanged, this);
            this.parent.on(index_7.colWidthChanged, this.colWidthChanged, this);
            this.parent.on(index_5.spreadsheetDestroyed, this.removeEventListener, this);
        };
        SheetRender.prototype.destroy = function () {
            Eif (this.headerPanel) {
                index_3.removeAllChildren(this.headerPanel);
                this.headerPanel.remove();
            }
            this.headerPanel = null;
            Eif (this.contentPanel) {
                index_3.removeAllChildren(this.contentPanel);
                this.contentPanel.remove();
            }
            this.contentPanel = null;
            Eif (this.col) {
                index_3.removeAllChildren(this.col);
                this.col.remove();
            }
            this.col = null;
            this.rowRenderer = null;
            this.cellRenderer = null;
            this.colGroupWidth = null;
            this.parent = null;
        };
        SheetRender.prototype.removeEventListener = function () {
            this.parent.off(index_5.created, this.triggerCreatedEvent);
            this.parent.off(index_6.rowHeightChanged, this.rowHeightChanged);
            this.parent.off(index_7.colWidthChanged, this.colWidthChanged);
            this.parent.off(index_5.spreadsheetDestroyed, this.removeEventListener);
        };
        return SheetRender;
    }());
    exports.SheetRender = SheetRender;
});