{"version":3,"file":"table.js","names":["colCache","require","Column","constructor","table","column","index","_set","name","value","cacheState","filterButton","style","totalsRowLabel","totalsRowFunction","totalsRowResult","totalsRowFormula","Table","worksheet","validate","store","getFormula","Error","width","columns","length","height","rows","filterHeight","headerRow","tableHeight","totalsRow","assign","o","dflt","undefined","assert","test","message","ref","tl","decodeAddress","row","col","autoFilterRef","encode","tableRef","forEach","i","assignStyle","cell","Object","keys","key","count","r","getRow","j","getCell","data","formula","result","load","model","_cache","commit","addRow","values","rowNumber","push","splice","removeRows","rowIndex","arguments","getColumn","colIndex","addColumn","removeColumns","_assign","target","prop","displayName","displyName","displayNamename","theme","showFirstColumn","showLastColumn","showRowStripes","showColumnStripes","module","exports"],"sources":["../../../lib/doc/table.js"],"sourcesContent":["/* eslint-disable max-classes-per-file */\nconst colCache = require('../utils/col-cache');\n\nclass Column {\n // wrapper around column model, allowing access and manipulation\n constructor(table, column, index) {\n this.table = table;\n this.column = column;\n this.index = index;\n }\n\n _set(name, value) {\n this.table.cacheState();\n this.column[name] = value;\n }\n\n /* eslint-disable lines-between-class-members */\n get name() {\n return this.column.name;\n }\n set name(value) {\n this._set('name', value);\n }\n\n get filterButton() {\n return this.column.filterButton;\n }\n set filterButton(value) {\n this.column.filterButton = value;\n }\n\n get style() {\n return this.column.style;\n }\n set style(value) {\n this.column.style = value;\n }\n\n get totalsRowLabel() {\n return this.column.totalsRowLabel;\n }\n set totalsRowLabel(value) {\n this._set('totalsRowLabel', value);\n }\n\n get totalsRowFunction() {\n return this.column.totalsRowFunction;\n }\n set totalsRowFunction(value) {\n this._set('totalsRowFunction', value);\n }\n\n get totalsRowResult() {\n return this.column.totalsRowResult;\n }\n set totalsRowResult(value) {\n this._set('totalsRowResult', value);\n }\n\n get totalsRowFormula() {\n return this.column.totalsRowFormula;\n }\n set totalsRowFormula(value) {\n this._set('totalsRowFormula', value);\n }\n /* eslint-enable lines-between-class-members */\n}\n\nclass Table {\n constructor(worksheet, table) {\n this.worksheet = worksheet;\n if (table) {\n this.table = table;\n // check things are ok first\n this.validate();\n\n this.store();\n }\n }\n\n getFormula(column) {\n // get the correct formula to apply to the totals row\n switch (column.totalsRowFunction) {\n case 'none':\n return null;\n case 'average':\n return `SUBTOTAL(101,${this.table.name}[${column.name}])`;\n case 'countNums':\n return `SUBTOTAL(102,${this.table.name}[${column.name}])`;\n case 'count':\n return `SUBTOTAL(103,${this.table.name}[${column.name}])`;\n case 'max':\n return `SUBTOTAL(104,${this.table.name}[${column.name}])`;\n case 'min':\n return `SUBTOTAL(105,${this.table.name}[${column.name}])`;\n case 'stdDev':\n return `SUBTOTAL(106,${this.table.name}[${column.name}])`;\n case 'var':\n return `SUBTOTAL(107,${this.table.name}[${column.name}])`;\n case 'sum':\n return `SUBTOTAL(109,${this.table.name}[${column.name}])`;\n case 'custom':\n return column.totalsRowFormula;\n default:\n throw new Error(`Invalid Totals Row Function: ${column.totalsRowFunction}`);\n }\n }\n\n get width() {\n // width of the table\n return this.table.columns.length;\n }\n\n get height() {\n // height of the table data\n return this.table.rows.length;\n }\n\n get filterHeight() {\n // height of the table data plus optional header row\n return this.height + (this.table.headerRow ? 1 : 0);\n }\n\n get tableHeight() {\n // full height of the table on the sheet\n return this.filterHeight + (this.table.totalsRow ? 1 : 0);\n }\n\n validate() {\n const {table} = this;\n // set defaults and check is valid\n const assign = (o, name, dflt) => {\n if (o[name] === undefined) {\n o[name] = dflt;\n }\n };\n assign(table, 'headerRow', true);\n assign(table, 'totalsRow', false);\n\n assign(table, 'style', {});\n assign(table.style, 'theme', 'TableStyleMedium2');\n assign(table.style, 'showFirstColumn', false);\n assign(table.style, 'showLastColumn', false);\n assign(table.style, 'showRowStripes', false);\n assign(table.style, 'showColumnStripes', false);\n\n const assert = (test, message) => {\n if (!test) {\n throw new Error(message);\n }\n };\n assert(table.ref, 'Table must have ref');\n assert(table.columns, 'Table must have column definitions');\n assert(table.rows, 'Table must have row definitions');\n\n table.tl = colCache.decodeAddress(table.ref);\n const {row, col} = table.tl;\n assert(row > 0, 'Table must be on valid row');\n assert(col > 0, 'Table must be on valid col');\n\n const {width, filterHeight, tableHeight} = this;\n\n // autoFilterRef is a range that includes optional headers only\n table.autoFilterRef = colCache.encode(row, col, row + filterHeight - 1, col + width - 1);\n\n // tableRef is a range that includes optional headers and totals\n table.tableRef = colCache.encode(row, col, row + tableHeight - 1, col + width - 1);\n\n table.columns.forEach((column, i) => {\n assert(column.name, `Column ${i} must have a name`);\n if (i === 0) {\n assign(column, 'totalsRowLabel', 'Total');\n } else {\n assign(column, 'totalsRowFunction', 'none');\n column.totalsRowFormula = this.getFormula(column);\n }\n });\n }\n\n store() {\n // where the table needs to store table data, headers, footers in\n // the sheet...\n const assignStyle = (cell, style) => {\n if (style) {\n Object.keys(style).forEach(key => {\n cell[key] = style[key];\n });\n }\n };\n\n const {worksheet, table} = this;\n const {row, col} = table.tl;\n let count = 0;\n if (table.headerRow) {\n const r = worksheet.getRow(row + count++);\n table.columns.forEach((column, j) => {\n const {style, name} = column;\n const cell = r.getCell(col + j);\n cell.value = name;\n assignStyle(cell, style);\n });\n }\n table.rows.forEach(data => {\n const r = worksheet.getRow(row + count++);\n data.forEach((value, j) => {\n const cell = r.getCell(col + j);\n cell.value = value;\n\n assignStyle(cell, table.columns[j].style);\n });\n });\n\n if (table.totalsRow) {\n const r = worksheet.getRow(row + count++);\n table.columns.forEach((column, j) => {\n const cell = r.getCell(col + j);\n if (j === 0) {\n cell.value = column.totalsRowLabel;\n } else {\n const formula = this.getFormula(column);\n if (formula) {\n cell.value = {\n formula: column.totalsRowFormula,\n result: column.totalsRowResult,\n };\n } else {\n cell.value = null;\n }\n }\n\n assignStyle(cell, column.style);\n });\n }\n }\n\n load(worksheet) {\n // where the table will read necessary features from a loaded sheet\n const {table} = this;\n const {row, col} = table.tl;\n let count = 0;\n if (table.headerRow) {\n const r = worksheet.getRow(row + count++);\n table.columns.forEach((column, j) => {\n const cell = r.getCell(col + j);\n cell.value = column.name;\n });\n }\n table.rows.forEach(data => {\n const r = worksheet.getRow(row + count++);\n data.forEach((value, j) => {\n const cell = r.getCell(col + j);\n cell.value = value;\n });\n });\n\n if (table.totalsRow) {\n const r = worksheet.getRow(row + count++);\n table.columns.forEach((column, j) => {\n const cell = r.getCell(col + j);\n if (j === 0) {\n cell.value = column.totalsRowLabel;\n } else {\n const formula = this.getFormula(column);\n if (formula) {\n cell.value = {\n formula: column.totalsRowFormula,\n result: column.totalsRowResult,\n };\n }\n }\n });\n }\n }\n\n get model() {\n return this.table;\n }\n\n set model(value) {\n this.table = value;\n }\n\n // ================================================================\n // TODO: Mutating methods\n cacheState() {\n if (!this._cache) {\n this._cache = {\n ref: this.ref,\n width: this.width,\n tableHeight: this.tableHeight,\n };\n }\n }\n\n commit() {\n // changes may have been made that might have on-sheet effects\n if (!this._cache) {\n return;\n }\n\n // check things are ok first\n this.validate();\n\n const ref = colCache.decodeAddress(this._cache.ref);\n if (this.ref !== this._cache.ref) {\n // wipe out whole table footprint at previous location\n for (let i = 0; i < this._cache.tableHeight; i++) {\n const row = this.worksheet.getRow(ref.row + i);\n for (let j = 0; j < this._cache.width; j++) {\n const cell = row.getCell(ref.col + j);\n cell.value = null;\n }\n }\n } else {\n // clear out below table if it has shrunk\n for (let i = this.tableHeight; i < this._cache.tableHeight; i++) {\n const row = this.worksheet.getRow(ref.row + i);\n for (let j = 0; j < this._cache.width; j++) {\n const cell = row.getCell(ref.col + j);\n cell.value = null;\n }\n }\n\n // clear out to right of table if it has lost columns\n for (let i = 0; i < this.tableHeight; i++) {\n const row = this.worksheet.getRow(ref.row + i);\n for (let j = this.width; j < this._cache.width; j++) {\n const cell = row.getCell(ref.col + j);\n cell.value = null;\n }\n }\n }\n\n this.store();\n }\n\n addRow(values, rowNumber) {\n // Add a row of data, either insert at rowNumber or append\n this.cacheState();\n\n if (rowNumber === undefined) {\n this.table.rows.push(values);\n } else {\n this.table.rows.splice(rowNumber, 0, values);\n }\n }\n\n removeRows(rowIndex, count = 1) {\n // Remove a rows of data\n this.cacheState();\n this.table.rows.splice(rowIndex, count);\n }\n\n getColumn(colIndex) {\n const column = this.table.columns[colIndex];\n return new Column(this, column, colIndex);\n }\n\n addColumn(column, values, colIndex) {\n // Add a new column, including column defn and values\n // Inserts at colNumber or adds to the right\n this.cacheState();\n\n if (colIndex === undefined) {\n this.table.columns.push(column);\n this.table.rows.forEach((row, i) => {\n row.push(values[i]);\n });\n } else {\n this.table.columns.splice(colIndex, 0, column);\n this.table.rows.forEach((row, i) => {\n row.splice(colIndex, 0, values[i]);\n });\n }\n }\n\n removeColumns(colIndex, count = 1) {\n // Remove a column with data\n this.cacheState();\n\n this.table.columns.splice(colIndex, count);\n this.table.rows.forEach(row => {\n row.splice(colIndex, count);\n });\n }\n\n _assign(target, prop, value) {\n this.cacheState();\n target[prop] = value;\n }\n\n /* eslint-disable lines-between-class-members */\n get ref() {\n return this.table.ref;\n }\n set ref(value) {\n this._assign(this.table, 'ref', value);\n }\n\n get name() {\n return this.table.name;\n }\n set name(value) {\n this.table.name = value;\n }\n\n get displayName() {\n return this.table.displyName || this.table.name;\n }\n set displayNamename(value) {\n this.table.displayName = value;\n }\n\n get headerRow() {\n return this.table.headerRow;\n }\n set headerRow(value) {\n this._assign(this.table, 'headerRow', value);\n }\n\n get totalsRow() {\n return this.table.totalsRow;\n }\n set totalsRow(value) {\n this._assign(this.table, 'totalsRow', value);\n }\n\n get theme() {\n return this.table.style.name;\n }\n set theme(value) {\n this.table.style.name = value;\n }\n\n get showFirstColumn() {\n return this.table.style.showFirstColumn;\n }\n set showFirstColumn(value) {\n this.table.style.showFirstColumn = value;\n }\n\n get showLastColumn() {\n return this.table.style.showLastColumn;\n }\n set showLastColumn(value) {\n this.table.style.showLastColumn = value;\n }\n\n get showRowStripes() {\n return this.table.style.showRowStripes;\n }\n set showRowStripes(value) {\n this.table.style.showRowStripes = value;\n }\n\n get showColumnStripes() {\n return this.table.style.showColumnStripes;\n }\n set showColumnStripes(value) {\n this.table.style.showColumnStripes = value;\n }\n /* eslint-enable lines-between-class-members */\n}\n\nmodule.exports = Table;\n"],"mappings":";;AAAA;AACA,MAAMA,QAAQ,GAAGC,OAAO,CAAC,oBAAoB,CAAC;AAE9C,MAAMC,MAAM,CAAC;EACX;EACAC,WAAWA,CAACC,KAAK,EAAEC,MAAM,EAAEC,KAAK,EAAE;IAChC,IAAI,CAACF,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACC,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,KAAK,GAAGA,KAAK;EACpB;EAEAC,IAAIA,CAACC,IAAI,EAAEC,KAAK,EAAE;IAChB,IAAI,CAACL,KAAK,CAACM,UAAU,CAAC,CAAC;IACvB,IAAI,CAACL,MAAM,CAACG,IAAI,CAAC,GAAGC,KAAK;EAC3B;;EAEA;EACA,IAAID,IAAIA,CAAA,EAAG;IACT,OAAO,IAAI,CAACH,MAAM,CAACG,IAAI;EACzB;EACA,IAAIA,IAAIA,CAACC,KAAK,EAAE;IACd,IAAI,CAACF,IAAI,CAAC,MAAM,EAAEE,KAAK,CAAC;EAC1B;EAEA,IAAIE,YAAYA,CAAA,EAAG;IACjB,OAAO,IAAI,CAACN,MAAM,CAACM,YAAY;EACjC;EACA,IAAIA,YAAYA,CAACF,KAAK,EAAE;IACtB,IAAI,CAACJ,MAAM,CAACM,YAAY,GAAGF,KAAK;EAClC;EAEA,IAAIG,KAAKA,CAAA,EAAG;IACV,OAAO,IAAI,CAACP,MAAM,CAACO,KAAK;EAC1B;EACA,IAAIA,KAAKA,CAACH,KAAK,EAAE;IACf,IAAI,CAACJ,MAAM,CAACO,KAAK,GAAGH,KAAK;EAC3B;EAEA,IAAII,cAAcA,CAAA,EAAG;IACnB,OAAO,IAAI,CAACR,MAAM,CAACQ,cAAc;EACnC;EACA,IAAIA,cAAcA,CAACJ,KAAK,EAAE;IACxB,IAAI,CAACF,IAAI,CAAC,gBAAgB,EAAEE,KAAK,CAAC;EACpC;EAEA,IAAIK,iBAAiBA,CAAA,EAAG;IAC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