{"version":3,"sources":["../../../lib/doc/row.js"],"names":["_","require","Enums","colCache","Cell","Row","worksheet","number","_worksheet","_number","_cells","style","outlineLevel","_commitRow","colNumber","address","cell","col","column","getColumn","getColumnKey","l2n","getCellEx","encodeAddress","row","start","count","nKeep","inserts","nExpand","length","nEnd","i","cSrc","cDst","getCell","value","_comment","undefined","options","iteratee","includeEmpty","n","forEach","index","type","ValueType","Null","lft","rght","ws","left","Math","max","right","pb","id","man","min","rowBreaks","push","name","values","Array","offset","hasOwnProperty","item","eachColumnKey","key","some","eachCell","numFmt","_applyStyle","font","alignment","protection","border","fill","_hidden","_outlineLevel","properties","outlineLevelRow","cells","cellModel","model","height","hidden","collapsed","Error","previousAddress","Types","Merge","decodeAddress","$col$row","n2l","JSON","parse","stringify","module","exports"],"mappings":"AAAA;;;;;;;;AAEA,IAAMA,CAAC,GAAGC,OAAO,CAAC,qBAAD,CAAjB;;AAEA,IAAMC,KAAK,GAAGD,OAAO,CAAC,SAAD,CAArB;;AACA,IAAME,QAAQ,GAAGF,OAAO,CAAC,oBAAD,CAAxB;;AACA,IAAMG,IAAI,GAAGH,OAAO,CAAC,QAAD,CAApB;;IAEMI,G;AACJ,eAAYC,SAAZ,EAAuBC,MAAvB,EAA+B;AAAA;;AAC7B,SAAKC,UAAL,GAAkBF,SAAlB;AACA,SAAKG,OAAL,GAAeF,MAAf;AACA,SAAKG,MAAL,GAAc,EAAd;AACA,SAAKC,KAAL,GAAa,EAAb;AACA,SAAKC,YAAL,GAAoB,CAApB;AACD,G,CAED;;;;;AASA;AACA;6BACS;AACP,WAAKJ,UAAL,CAAgBK,UAAhB,CAA2B,IAA3B,EADO,CAC2B;;AACnC,K,CAED;;;;8BACU;AACR,aAAO,KAAKL,UAAZ;AACA,aAAO,KAAKE,MAAZ;AACA,aAAO,KAAKC,KAAZ;AACD;;;6BAEQG,S,EAAW;AAClB,aAAO,KAAKJ,MAAL,CAAYI,SAAS,GAAG,CAAxB,CAAP;AACD,K,CAED;;;;8B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\r\nconst colCache = require('../utils/col-cache');\r\nconst Cell = require('./cell');\r\n\r\nclass Row {\r\n constructor(worksheet, number) {\r\n this._worksheet = worksheet;\r\n this._number = number;\r\n this._cells = [];\r\n this.style = {};\r\n this.outlineLevel = 0;\r\n }\r\n\r\n // return the row number\r\n get number() {\r\n return this._number;\r\n }\r\n\r\n get worksheet() {\r\n return this._worksheet;\r\n }\r\n\r\n // Inform Streaming Writer that this row (and all rows before it) are complete\r\n // and ready to write. Has no effect on Worksheet document\r\n commit() {\r\n this._worksheet._commitRow(this); // eslint-disable-line no-underscore-dangle\r\n }\r\n\r\n // helps GC by breaking cyclic references\r\n destroy() {\r\n delete this._worksheet;\r\n delete this._cells;\r\n delete this.style;\r\n }\r\n\r\n findCell(colNumber) {\r\n return this._cells[colNumber - 1];\r\n }\r\n\r\n // given {address, row, col}, find or create new cell\r\n getCellEx(address) {\r\n let cell = this._cells[address.col - 1];\r\n if (!cell) {\r\n const column = this._worksheet.getColumn(address.col);\r\n cell = new Cell(this, column, address.address);\r\n this._cells[address.col - 1] = cell;\r\n }\r\n return cell;\r\n }\r\n\r\n // get cell by key, letter or column number\r\n getCell(col) {\r\n if (typeof col === 'string') {\r\n // is it a key?\r\n const column = this._worksheet.getColumnKey(col);\r\n if (column) {\r\n col = column.number;\r\n } else {\r\n col = colCache.l2n(col);\r\n }\r\n }\r\n return (\r\n this._cells[col - 1] ||\r\n this.getCellEx({\r\n address: colCache.encodeAddress(this._number, col),\r\n row: this._number,\r\n col,\r\n })\r\n );\r\n }\r\n\r\n // remove cell(s) and shift all higher cells down by count\r\n splice(start, count, ...inserts) {\r\n const nKeep = start + count;\r\n const nExpand = inserts.length - count;\r\n const nEnd = this._cells.length;\r\n let i;\r\n let cSrc;\r\n let cDst;\r\n\r\n if (nExpand < 0) {\r\n // remove cells\r\n for (i = start + inserts.length; i <= nEnd; i++) {\r\n cDst = this._cells[i - 1];\r\n cSrc = this._cells[i - nExpand - 1];\r\n if (cSrc) {\r\n cDst = this.getCell(i);\r\n cDst.value = cSrc.value;\r\n cDst.style = cSrc.style;\r\n // eslint-disable-next-line no-underscore-dangle\r\n cDst._comment = cSrc._comment;\r\n } else if (cDst) {\r\n cDst.value = null;\r\n cDst.style = {};\r\n // eslint-disable-next-line no-underscore-dangle\r\n cDst._comment = undefined;\r\n }\r\n }\r\n } else if (nExpand > 0) {\r\n // insert new cells\r\n for (i = nEnd; i >= nKeep; i--) {\r\n cSrc = this._cells[i - 1];\r\n if (cSrc) {\r\n cDst = this.getCell(i + nExpand);\r\n cDst.value = cSrc.value;\r\n cDst.style = cSrc.style;\r\n // eslint-disable-next-line no-underscore-dangle\r\n cDst._comment = cSrc._comment;\r\n } else {\r\n this._cells[i + nExpand - 1] = undefined;\r\n }\r\n }\r\n }\r\n\r\n // now add the new values\r\n for (i = 0; i < inserts.length; i++) {\r\n cDst = this.getCell(start + i);\r\n cDst.value = inserts[i];\r\n cDst.style = {};\r\n // eslint-disable-next-line no-underscore-dangle\r\n cDst._comment = undefined;\r\n }\r\n }\r\n\r\n // Iterate over all non-null cells in this row\r\n eachCell(options, iteratee) {\r\n if (!iteratee) {\r\n iteratee = options;\r\n options = null;\r\n }\r\n if (options && options.includeEmpty) {\r\n const n = this._cells.length;\r\n for (let i = 1; i <= n; i++) {\r\n iteratee(this.getCell(i), i);\r\n }\r\n } else {\r\n this._cells.forEach((cell, index) => {\r\n if (cell && cell.type !== Enums.ValueType.Null) {\r\n iteratee(cell, index + 1);\r\n }\r\n });\r\n }\r\n }\r\n\r\n // ===========================================================================\r\n // Page Breaks\r\n addPageBreak(lft, rght) {\r\n const ws = this._worksheet;\r\n const left = Math.max(0, lft - 1) || 0;\r\n const right = Math.max(0, rght - 1) || 16838;\r\n const pb = {\r\n id: this._number,\r\n max: right,\r\n man: 1,\r\n };\r\n if (left) pb.min = left;\r\n\r\n ws.rowBreaks.push(pb);\r\n }\r\n\r\n // return a sparse array of cell values\r\n get values() {\r\n const values = [];\r\n this._cells.forEach(cell => {\r\n if (cell && cell.type !== Enums.ValueType.Null) {\r\n values[cell.col] = cell.value;\r\n }\r\n });\r\n return values;\r\n }\r\n\r\n // set the values by contiguous or sparse array, or by key'd object literal\r\n set values(value) {\r\n // this operation is not additive - any prior cells are removed\r\n this._cells = [];\r\n if (!value) {\r\n // empty row\r\n } else if (value instanceof Array) {\r\n let offset = 0;\r\n if (value.hasOwnProperty('0')) {\r\n // contiguous array - start at column 1\r\n offset = 1;\r\n }\r\n value.forEach((item, index) => {\r\n if (item !== undefined) {\r\n this.getCellEx({\r\n address: colCache.encodeAddress(this._number, index + offset),\r\n row: this._number,\r\n col: index + offset,\r\n }).value = item;\r\n }\r\n });\r\n } else {\r\n // assume object with column keys\r\n this._worksheet.eachColumnKey((column, key) => {\r\n if (value[key] !== undefined) {\r\n this.getCellEx({\r\n address: colCache.encodeAddress(this._number, column.number),\r\n row: this._number,\r\n col: column.number,\r\n }).value = value[key];\r\n }\r\n });\r\n }\r\n }\r\n\r\n // returns true if the row includes at least one cell with a value\r\n get hasValues() {\r\n return _.some(this._cells, cell => cell && cell.type !== Enums.ValueType.Null);\r\n }\r\n\r\n get cellCount() {\r\n return this._cells.length;\r\n }\r\n\r\n get actualCellCount() {\r\n let count = 0;\r\n this.eachCell(() => {\r\n count++;\r\n });\r\n return count;\r\n }\r\n\r\n // get the min and max column number for the non-null cells in this row or null\r\n get dimensions() {\r\n let min = 0;\r\n let max = 0;\r\n this._cells.forEach(cell => {\r\n if (cell && cell.type !== Enums.ValueType.Null) {\r\n if (!min || min > cell.col) {\r\n min = cell.col;\r\n }\r\n if (max < cell.col) {\r\n max = cell.col;\r\n }\r\n }\r\n });\r\n return min > 0\r\n ? {\r\n min,\r\n max,\r\n }\r\n : null;\r\n }\r\n\r\n // =========================================================================\r\n // styles\r\n _applyStyle(name, value) {\r\n this.style[name] = value;\r\n this._cells.forEach(cell => {\r\n if (cell) {\r\n cell[name] = value;\r\n }\r\n });\r\n return value;\r\n }\r\n\r\n get numFmt() {\r\n return this.style.numFmt;\r\n }\r\n\r\n set numFmt(value) {\r\n this._applyStyle('numFmt', value);\r\n }\r\n\r\n get font() {\r\n return this.style.font;\r\n }\r\n\r\n set font(value) {\r\n this._applyStyle('font', value);\r\n }\r\n\r\n get alignment() {\r\n return this.style.alignment;\r\n }\r\n\r\n set alignment(value) {\r\n this._applyStyle('alignment', value);\r\n }\r\n\r\n get protection() {\r\n return this.style.protection;\r\n }\r\n\r\n set protection(value) {\r\n this._applyStyle('protection', value);\r\n }\r\n\r\n get border() {\r\n return this.style.border;\r\n }\r\n\r\n set border(value) {\r\n this._applyStyle('border', value);\r\n }\r\n\r\n get fill() {\r\n return this.style.fill;\r\n }\r\n\r\n set fill(value) {\r\n this._applyStyle('fill', value);\r\n }\r\n\r\n get hidden() {\r\n return !!this._hidden;\r\n }\r\n\r\n set hidden(value) {\r\n this._hidden = value;\r\n }\r\n\r\n get outlineLevel() {\r\n return this._outlineLevel || 0;\r\n }\r\n\r\n set outlineLevel(value) {\r\n this._outlineLevel = value;\r\n }\r\n\r\n get collapsed() {\r\n return !!(\r\n this._outlineLevel && this._outlineLevel >= this._worksheet.properties.outlineLevelRow\r\n );\r\n }\r\n\r\n // =========================================================================\r\n get model() {\r\n const cells = [];\r\n let min = 0;\r\n let max = 0;\r\n this._cells.forEach(cell => {\r\n if (cell) {\r\n const cellModel = cell.model;\r\n if (cellModel) {\r\n if (!min || min > cell.col) {\r\n min = cell.col;\r\n }\r\n if (max < cell.col) {\r\n max = cell.col;\r\n }\r\n cells.push(cellModel);\r\n }\r\n }\r\n });\r\n\r\n return this.height || cells.length\r\n ? {\r\n cells,\r\n number: this.number,\r\n min,\r\n max,\r\n height: this.height,\r\n style: this.style,\r\n hidden: this.hidden,\r\n outlineLevel: this.outlineLevel,\r\n collapsed: this.collapsed,\r\n }\r\n : null;\r\n }\r\n\r\n set model(value) {\r\n if (value.number !== this._number) {\r\n throw new Error('Invalid row number in model');\r\n }\r\n this._cells = [];\r\n let previousAddress;\r\n value.cells.forEach(cellModel => {\r\n switch (cellModel.type) {\r\n case Cell.Types.Merge:\r\n // special case - don't add this types\r\n break;\r\n default: {\r\n let address;\r\n if (cellModel.address) {\r\n address = colCache.decodeAddress(cellModel.address);\r\n } else if (previousAddress) {\r\n // This is a <c> element without an r attribute\r\n // Assume that it's the cell for the next column\r\n const {row} = previousAddress;\r\n const col = previousAddress.col + 1;\r\n address = {\r\n row,\r\n col,\r\n address: colCache.encodeAddress(row, col),\r\n $col$row: `$${colCache.n2l(col)}$${row}`,\r\n };\r\n }\r\n previousAddress = address;\r\n const cell = this.getCellEx(address);\r\n cell.model = cellModel;\r\n break;\r\n }\r\n }\r\n });\r\n\r\n if (value.height) {\r\n this.height = value.height;\r\n } else {\r\n delete this.height;\r\n }\r\n\r\n this.hidden = value.hidden;\r\n this.outlineLevel = value.outlineLevel || 0;\r\n\r\n this.style = (value.style && JSON.parse(JSON.stringify(value.style))) || {};\r\n }\r\n}\r\n\r\nmodule.exports = Row;\r\n"],"file":"row.js"}