all files / spreadsheet/renderer/ row.js

97.33% Statements 73/75
75.51% Branches 37/49
100% Functions 8/8
97.33% Lines 73/75
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   885× 885× 885× 885×   138059× 138059× 1123× 1123×   136936× 136936× 136936× 136936× 136936× 136936× 136936× 1038× 1038×       1038×   136936× 1174×   136936× 68067× 587× 587×   587× 587×     68067× 35×   68067× 39×     136936×   802× 802× 802× 802× 401× 401×     401× 401× 401× 405× 23136× 23125×       23136×     401× 401×   401× 401× 401× 401×   802×   304×   885× 885× 885×   885× 751×   885× 885×        
define(["require", "exports", "../common/index", "../../workbook/base/index", "@syncfusion/ej2-base", "../../workbook/common/index"], function (require, exports, index_1, index_2, ej2_base_1, index_3) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var RowRenderer = (function () {
        function RowRenderer(parent) {
            this.parent = parent;
            this.element = this.parent.createElement('tr');
            this.cellRenderer = parent.serviceLocator.getService('cell');
            this.parent.on(index_1.deInitProperties, this.initProps, this);
        }
        RowRenderer.prototype.render = function (index, isRowHeader, preventHiddenCls) {
            var row = this.element.cloneNode();
            if (index === undefined) {
                row.classList.add('e-header-row');
                return row;
            }
            row.classList.add('e-row');
            var sheet = this.parent.getActiveSheet();
            ej2_base_1.attributes(row, { 'aria-rowindex': (index + 1).toString() });
            var rowHeight = index_2.getRowHeight(sheet, index, true);
            row.style.height = rowHeight + "px";
            var actualRowHgt = index_2.getRowHeight(sheet, index);
            if (!this.bottomBorderWidth) {
                var width = 1;
                Iif (window.devicePixelRatio % 1 > 0) {
                    var pointValue = (1 * window.devicePixelRatio) % 1;
                    width = 1 + (pointValue ? ((pointValue > 0.5 ? (1 - pointValue) : -1 * pointValue) / window.devicePixelRatio) : 0);
                }
                this.bottomBorderWidth = width;
            }
            if (actualRowHgt < 20) {
                row.style.lineHeight = rowHeight > this.bottomBorderWidth ? (rowHeight - this.bottomBorderWidth) + 'px' : '0px';
            }
            if (isRowHeader && !preventHiddenCls) {
                if (actualRowHgt < 20) {
                    var width = 4 + (this.bottomBorderWidth - 1);
                    row.style.lineHeight = rowHeight >= width ? (rowHeight - width) + 'px' :
                        (rowHeight > this.bottomBorderWidth ? (rowHeight - this.bottomBorderWidth) + 'px' : '0px');
                    Eif (!row.classList.contains('e-reach-fntsize')) {
                        row.classList.add('e-reach-fntsize');
                    }
                }
                if (index_2.isHiddenRow(sheet, index + 1) && !index_2.isHiddenRow(sheet, index - 1)) {
                    row.classList.add('e-hide-start');
                }
                if (index !== 0 && index_2.isHiddenRow(sheet, index - 1) && !index_2.isHiddenRow(sheet, index + 1)) {
                    row.classList.add('e-hide-end');
                }
            }
            return row;
        };
        RowRenderer.prototype.refresh = function (index, pRow, hRow, header, preventHiddenCls) {
            var _this = this;
            var sheet = this.parent.getActiveSheet();
            var row;
            if (header) {
                row = this.render(index, header, preventHiddenCls);
                this.cellRenderer.renderRowHeader(index, row);
            }
            else {
                var i_1;
                var len_1;
                var updateCells = function () {
                    while (i_1 <= len_1) {
                        if (!index_2.isHiddenCol(sheet, i_1)) {
                            _this.cellRenderer.render({ colIdx: i_1, rowIdx: index, cell: index_2.getCell(index, i_1, sheet), address: index_3.getCellAddress(index, i_1),
                                lastCell: i_1 === len_1, row: row, hRow: hRow, isHeightCheckNeeded: true, pRow: pRow, first: index === _this.parent.viewport.topIndex && index_3.skipHiddenIdx(sheet, index, true) !==
                                    index_3.skipHiddenIdx(sheet, 0, true) ? 'Row' : '', skipFormatCheck: index_3.isImported(_this.parent), checkCF: true });
                        }
                        i_1++;
                    }
                };
                var frozenCol = this.parent.frozenColCount(sheet);
                if (frozenCol) {
                    row = hRow;
                    i_1 = index_3.getCellIndexes(sheet.topLeftCell)[0];
                    len_1 = frozenCol - 1;
                    updateCells();
                }
                row = this.render(index, header, preventHiddenCls);
                i_1 = this.parent.viewport.leftIndex + frozenCol;
                len_1 = this.parent.viewport.rightIndex;
                updateCells();
            }
            return row;
        };
        RowRenderer.prototype.initProps = function () {
            this.bottomBorderWidth = null;
        };
        RowRenderer.prototype.destroy = function () {
            this.parent.off(index_1.deInitProperties, this.initProps);
            Eif (this.element) {
                this.element.remove();
            }
            if (this.bottomBorderWidth) {
                this.bottomBorderWidth = null;
            }
            this.parent = null;
            this.element = null;
        };
        return RowRenderer;
    }());
    exports.RowRenderer = RowRenderer;
});