diff --git a/app/components/ascii-data-table/.bower.json b/app/components/ascii-data-table/.bower.json index b4d9dfade2b..b1b76ba698e 100644 --- a/app/components/ascii-data-table/.bower.json +++ b/app/components/ascii-data-table/.bower.json @@ -42,14 +42,15 @@ "url": "https://github.com/oskarhane/ascii-data-table.git" }, "homepage": "https://github.com/oskarhane/ascii-data-table", - "version": "1.3.2", - "_release": "1.3.2", + "version": "1.3.3", + "_release": "1.3.3", "_resolution": { "type": "version", - "tag": "v1.3.2", - "commit": "c3fe2344c78b6fd223f46497b60349ef0e7ed4a9" + "tag": "v1.3.3", + "commit": "f5a509638b1d60de0f3ae26903e4ba3fe4b0ae4d" }, "_source": "https://github.com/oskarhane/ascii-data-table.git", - "_target": "^1.1.0", - "_originalSource": "ascii-data-table" + "_target": "^1.3.3", + "_originalSource": "ascii-data-table", + "_direct": true } \ No newline at end of file diff --git a/app/components/ascii-data-table/lib/ascii-data-table.js b/app/components/ascii-data-table/lib/ascii-data-table.js index 954460a999d..6af2feeac14 100644 --- a/app/components/ascii-data-table/lib/ascii-data-table.js +++ b/app/components/ascii-data-table/lib/ascii-data-table.js @@ -55,14 +55,8 @@ var getRowIndexForLine = function getRowIndexForLine(rowHeights, lineNumber) { }); }; -var getLineFromRow = function getLineFromRow(prev, col, colIndex) { - var colLines = getLinesFromString(col).reduce(function (final, curr) { - return final.concat(('' + curr).match(new RegExp('.{1,' + prev.colWidths[colIndex] + '}', 'g')) || ['']); - }, []); - colLines = colLines.concat(getArray(prev.rowHeight - colLines.length).map(function (a) { - return ' '; - })); - var linesStr = colLines.filter(function (_, lineIndex) { +var getLineFromCol = function getLineFromCol(prev, _, colIndex) { + var linesStr = prev.colsLines[prev.rowIndex][colIndex].filter(function (_, lineIndex) { return lineIndex === prev.lineIndex; }).map(function (line) { return line + padString(' ', prev.colWidths[colIndex] - line.length); @@ -71,6 +65,15 @@ var getLineFromRow = function getLineFromRow(prev, col, colIndex) { return prev; }; +var getColLines = function getColLines(col, colWidth, rowHeight) { + var colLines = getLinesFromString(col).reduce(function (final, curr) { + return final.concat(('' + curr).match(new RegExp('.{1,' + colWidth + '}', 'g')) || ['']); + }, []); + return colLines.concat(getArray(rowHeight - colLines.length).map(function (a) { + return ' '; + })); +}; + var getLinesFromString = function getLinesFromString(str) { if (typeof str !== 'string') return [str]; return str.indexOf('\n') > -1 ? str.split('\n') : [str]; @@ -107,13 +110,20 @@ var renderForWidth = function renderForWidth(rows) { var totalLines = rowHeights.reduce(function (tot, curr) { return tot + curr; }, 0); + var colsLines = rows.reduce(function (colLines, row, rowIndex) { + var cols = row.map(function (col, colIndex) { + return getColLines(col, colWidths[colIndex], rowHeights[rowIndex]); + }); + return colLines.concat([cols]); + }, []); var output = getArray(totalLines).reduce(function (out, _, i) { var lineMeta = getRowIndexForLine(rowHeights, i); - var rowLines = rows[lineMeta.rowIndex].reduce(getLineFromRow, { + var rowLines = rows[lineMeta.rowIndex].reduce(getLineFromCol, { lines: [], lineIndex: lineMeta.lineIndex, - rowHeight: rowHeights[lineMeta.rowIndex], - colWidths: colWidths + colWidths: colWidths, + colsLines: colsLines, + rowIndex: lineMeta.rowIndex }).lines.join('│'); out.push('│' + rowLines + '│'); return out; diff --git a/app/components/ascii-data-table/lib/ascii-data-table.js.map b/app/components/ascii-data-table/lib/ascii-data-table.js.map index a54b4848db8..f06324082b1 100644 --- a/app/components/ascii-data-table/lib/ascii-data-table.js.map +++ b/app/components/ascii-data-table/lib/ascii-data-table.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/ascii-data-table.js"],"names":[],"mappings":";;;;;;;;AAAA,IAAM,WAAW,SAAX,QAAW,CAAC,GAAD;SAAS,MAAM,KAAN,CAAY,IAAZ,EAAkB,MAAM,GAAN,CAAlB,EAA8B,GAA9B,CAAkC,UAAC,CAAD,EAAI,CAAJ;WAAU;GAAV;CAA3C;;AAEjB,IAAM,eAAe,SAAf,YAAe,CAAC,GAAD,EAAS;AAC5B,MAAI,MAAM,OAAN,CAAc,GAAd,CAAJ,EA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B,EAAsB,GAAtB,EAA2B,GAA3B,EAAgC,GAAhC,EAAqC,SAArC;CAAf;AAC/B,IAAM,mBAAmB,SAAnB,gBAAmB,CAAC,OAAD,EAAU,QAAV,EAAoB,SAApB,EAA+B,SAA/B,EAA0C,SAA1C,EAAwD;AAC/E,SAAO,WAAW,UAAU,GAAV,CAAc,UAAU,CAAV,EAAa;AAC3C,WAAO,UAAU,OAAV,EAAmB,CAAnB,CAAP,CAD2C;GAAb,CAAd,CAEf,IAFe,CAEV,SAFU,CAAX,GAEc,SAFd,CADwE;CAAxD;;AAMzB,IAAM,YAAY,SAAZ,SAAY,CAAC,SAAD,EAAY,KAAZ,EAAsB;AACtC,MAAI,QAAQ,CAAR,EAAW,OAAO,EAAP,CAAf;AACA,SAAO,SAAS,KAAT,EAAgB,GAAhB,CAAoB;WAAM;GAAN,CAApB,CAAqC,IAArC,CAA0C,EAA1C,CAAP,CAFsC;CAAtB;;kBAKH;AACb,OAAK,aAAC,IAAD;QAAO,gEAAU,EAAC,gBAAgB,EAAhB;WAAwB,eAAe,eAAe,IAAf,CAAf,EAAqC,QAAQ,cAAR;GAA/E;AACL,qBAAmB,2BAAC,IAAD;WAAU,aAAa,eAAe,IAAf,CAAb,EAAmC,MAAnC,CAA0C,UAAC,GAAD,EAAM,QAAN;aAAmB,KAAK,GAAL,CAAS,GAAT,EAAc,QAAd;KAAnB,EAA4C,CAAtF;GAAV","file":"ascii-data-table.js","sourcesContent":["const getArray = (len) => Array.apply(null, Array(len)).map((_, i) => i)\n\nconst stringifyVal = (val) => {\n if (Array.isArray(val)) return stringifyArray(val)\n if (typeof val === 'number') return val\n if (typeof val === 'string') return val\n if (typeof val === 'boolean') return val\n if (val === null) return '(null)'\n if (typeof val === 'object') return stringifyObject(val)\n}\n\nconst stringifyArray = (arr) => '[' + arr.map(stringifyVal).join(', ') + ']'\n\nconst stringifyObject = (obj) => {\n if (typeof obj !== 'object') return obj\n return '{' + Object.keys(obj).map((key) => key + ': ' + stringifyVal(obj[key])).join(', ') + '}'\n}\n\nconst stringifyLines = (rows) => {\n if (!Array.isArray(rows) || !rows.length) return []\n return rows.map((row) => row.map(stringifyVal))\n}\n\nconst getRowIndexForLine = (rowHeights, lineNumber) => {\n return rowHeights.reduce((meta, height, rowIndex) => {\n if (meta.remainingLines < 0) return meta\n meta.rowIndex = rowIndex\n if (meta.remainingLines < height) {\n meta.lineIndex = meta.remainingLines\n }\n meta.remainingLines = meta.remainingLines - height\n return meta\n }, {\n rowIndex: 0,\n lineIndex: 0,\n remainingLines: lineNumber\n })\n}\n\nconst getLineFromRow = (prev, col, colIndex) => {\n let colLines = getLinesFromString(col).reduce((final, curr) => {\n return final.concat(('' + curr).match(new RegExp('.{1,' + prev.colWidths[colIndex] + '}', 'g')) || [''])\n }, [])\n colLines = colLines.concat(getArray(prev.rowHeight - colLines.length).map((a) => ' '))\n const linesStr = colLines\n .filter((_, lineIndex) => lineIndex === prev.lineIndex)\n .map((line) => line + padString(' ', prev.colWidths[colIndex] - line.length))\n prev.lines.push(linesStr)\n return prev\n}\n\nconst getLinesFromString = (str) => {\n if (typeof str !== 'string') return [str]\n return str.indexOf('\\n') > -1 ? str.split('\\n') : [str]\n}\n\nconst getColWidths = (rows) => {\n return getArray(rows[0].length).map((i) => {\n return rows.reduce((prev, curr) => {\n const lines = getLinesFromString(curr[i])\n const currMax = lines.reduce((max, line) => {\n return Math.max(max, ('' + line).length)\n }, 0)\n return Math.max(prev, currMax)\n }, 0)\n })\n}\n\nconst renderForWidth = (rows, maxColWidth = 30, minColWidth = 3) => {\n if (!Array.isArray(rows) || !rows.length) return ''\n const colWidths = getColWidths(rows).map((colWidth) => {\n return Math.max(Math.min(colWidth, maxColWidth), minColWidth)\n })\n const rowHeights = rows.map((row) => {\n return row.reduce((prev, curr, colIndex) => {\n const lines = getLinesFromString(curr)\n return lines.reduce((tot, line) => {\n return tot + Math.max(1, Math.max(prev, Math.ceil(('' + line).length / colWidths[colIndex])))\n }, 0)\n }, 0)\n })\n const totalLines = rowHeights.reduce((tot, curr) => tot + curr, 0)\n let output = getArray(totalLines).reduce((out, _, i) => {\n const lineMeta = getRowIndexForLine(rowHeights, i)\n const rowLines = rows[lineMeta.rowIndex].reduce(getLineFromRow, {\n lines: [],\n lineIndex: lineMeta.lineIndex,\n rowHeight: rowHeights[lineMeta.rowIndex],\n colWidths: colWidths\n }).lines.join('│')\n out.push('│' + rowLines + '│')\n return out\n }, [])\n output = insertRowSeparators(output, rowHeights, colWidths)\n return output.join('\\n')\n}\n\nconst insertRowSeparators = (lines, rowHeights, colWidths) => {\n return rowHeights.reduce((out, rowHeight, rowIndex) => {\n out.curr.push.apply(out.curr, out.feeder.splice(0, rowHeight))\n if (rowIndex === 0) {\n out.curr.push(getThickSeparatorLine(colWidths))\n } else if (rowIndex === rowHeights.length - 1) {\n out.curr.push(getBottomSeparatorLine(colWidths))\n } else {\n out.curr.push(getThinSeparatorLine(colWidths))\n }\n return out\n }, {\n feeder: lines,\n curr: [getTopSeparatorLine(colWidths)]\n }).curr\n}\n\nconst getTopSeparatorLine = (colWidths) => getSeparatorLine('═', '╒', '╤', '╕', colWidths)\nconst getThickSeparatorLine = (colWidths) => getSeparatorLine('═', '╞', '╪', '╡', colWidths)\nconst getThinSeparatorLine = (colWidths) => getSeparatorLine('─', '├', '┼', '┤', colWidths)\nconst getBottomSeparatorLine = (colWidths) => getSeparatorLine('─', '└', '┴', '┘', colWidths)\nconst getSeparatorLine = (horChar, leftChar, crossChar, rightChar, colWidths) => {\n return leftChar + colWidths.map(function (w) {\n return padString(horChar, w)\n }).join(crossChar) + rightChar\n}\n\nconst padString = (character, width) => {\n if (width < 1) return ''\n return getArray(width).map(() => character).join('')\n}\n\nexport default {\n run: (rows, options = {maxColumnWidth: 30}) => renderForWidth(stringifyLines(rows), options.maxColumnWidth),\n getMaxColumnWidth: (rows) => getColWidths(stringifyLines(rows)).reduce((max, colWidth) => Math.max(max, colWidth), 0)\n}\n\n"]} \ No newline at end of file +{"version":3,"sources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,EAAgB,GAAhB,CAAoB;WAAM;GAAN,CAApB,CAAqC,IAArC,CAA0C,EAA1C,CAAP,CAFsC;CAAtB;;kBAKH;AACb,OAAK,aAAC,IAAD;QAAO,gEAAU,EAAC,gBAAgB,EAAhB;WAAwB,eAAe,eAAe,IAAf,CAAf,EAAqC,QAAQ,cAAR;GAA/E;AACL,qBAAmB,2BAAC,IAAD;WAAU,aAAa,eAAe,IAAf,CAAb,EAAmC,MAAnC,CAA0C,UAAC,GAAD,EAAM,QAAN;aAAmB,KAAK,GAAL,CAAS,GAAT,EAAc,QAAd;KAAnB,EAA4C,CAAtF;GAAV","file":"ascii-data-table.js","sourcesContent":["const getArray = (len) => Array.apply(null, Array(len)).map((_, i) => i)\n\nconst stringifyVal = (val) => {\n if (Array.isArray(val)) return stringifyArray(val)\n if (typeof val === 'number') return val\n if (typeof val === 'string') return val\n if (typeof val === 'boolean') return val\n if (val === null) return '(null)'\n if (typeof val === 'object') return stringifyObject(val)\n}\n\nconst stringifyArray = (arr) => '[' + arr.map(stringifyVal).join(', ') + ']'\n\nconst stringifyObject = (obj) => {\n if (typeof obj !== 'object') return obj\n return '{' + Object.keys(obj).map((key) => key + ': ' + stringifyVal(obj[key])).join(', ') + '}'\n}\n\nconst stringifyLines = (rows) => {\n if (!Array.isArray(rows) || !rows.length) return []\n return rows.map((row) => row.map(stringifyVal))\n}\n\nconst getRowIndexForLine = (rowHeights, lineNumber) => {\n return rowHeights.reduce((meta, height, rowIndex) => {\n if (meta.remainingLines < 0) return meta\n meta.rowIndex = rowIndex\n if (meta.remainingLines < height) {\n meta.lineIndex = meta.remainingLines\n }\n meta.remainingLines = meta.remainingLines - height\n return meta\n }, {\n rowIndex: 0,\n lineIndex: 0,\n remainingLines: lineNumber\n })\n}\n\nconst getLineFromCol = (prev, _, colIndex) => {\n const linesStr = prev.colsLines[prev.rowIndex][colIndex]\n .filter((_, lineIndex) => lineIndex === prev.lineIndex)\n .map((line) => line + padString(' ', prev.colWidths[colIndex] - line.length))\n prev.lines.push(linesStr)\n return prev\n}\n\nconst getColLines = (col, colWidth, rowHeight) => {\n let colLines = getLinesFromString(col).reduce((final, curr) => {\n return final.concat(('' + curr).match(new RegExp('.{1,' + colWidth + '}', 'g')) || [''])\n }, [])\n return colLines.concat(getArray(rowHeight - colLines.length).map((a) => ' '))\n}\n\nconst getLinesFromString = (str) => {\n if (typeof str !== 'string') return [str]\n return str.indexOf('\\n') > -1 ? str.split('\\n') : [str]\n}\n\nconst getColWidths = (rows) => {\n return getArray(rows[0].length).map((i) => {\n return rows.reduce((prev, curr) => {\n const lines = getLinesFromString(curr[i])\n const currMax = lines.reduce((max, line) => {\n return Math.max(max, ('' + line).length)\n }, 0)\n return Math.max(prev, currMax)\n }, 0)\n })\n}\n\nconst renderForWidth = (rows, maxColWidth = 30, minColWidth = 3) => {\n if (!Array.isArray(rows) || !rows.length) return ''\n const colWidths = getColWidths(rows).map((colWidth) => {\n return Math.max(Math.min(colWidth, maxColWidth), minColWidth)\n })\n const rowHeights = rows.map((row) => {\n return row.reduce((prev, curr, colIndex) => {\n const lines = getLinesFromString(curr)\n return lines.reduce((tot, line) => {\n return tot + Math.max(1, Math.max(prev, Math.ceil(('' + line).length / colWidths[colIndex])))\n }, 0)\n }, 0)\n })\n const totalLines = rowHeights.reduce((tot, curr) => tot + curr, 0)\n const colsLines = rows.reduce((colLines, row, rowIndex) => {\n const cols = row.map((col, colIndex) => getColLines(col, colWidths[colIndex], rowHeights[rowIndex]))\n return colLines.concat([cols])\n }, [])\n let output = getArray(totalLines).reduce((out, _, i) => {\n const lineMeta = getRowIndexForLine(rowHeights, i)\n const rowLines = rows[lineMeta.rowIndex].reduce(getLineFromCol, {\n lines: [],\n lineIndex: lineMeta.lineIndex,\n colWidths: colWidths,\n colsLines: colsLines,\n rowIndex: lineMeta.rowIndex\n }).lines.join('│')\n out.push('│' + rowLines + '│')\n return out\n }, [])\n output = insertRowSeparators(output, rowHeights, colWidths)\n return output.join('\\n')\n}\n\nconst insertRowSeparators = (lines, rowHeights, colWidths) => {\n return rowHeights.reduce((out, rowHeight, rowIndex) => {\n out.curr.push.apply(out.curr, out.feeder.splice(0, rowHeight))\n if (rowIndex === 0) {\n out.curr.push(getThickSeparatorLine(colWidths))\n } else if (rowIndex === rowHeights.length - 1) {\n out.curr.push(getBottomSeparatorLine(colWidths))\n } else {\n out.curr.push(getThinSeparatorLine(colWidths))\n }\n return out\n }, {\n feeder: lines,\n curr: [getTopSeparatorLine(colWidths)]\n }).curr\n}\n\nconst getTopSeparatorLine = (colWidths) => getSeparatorLine('═', '╒', '╤', '╕', colWidths)\nconst getThickSeparatorLine = (colWidths) => getSeparatorLine('═', '╞', '╪', '╡', colWidths)\nconst getThinSeparatorLine = (colWidths) => getSeparatorLine('─', '├', '┼', '┤', colWidths)\nconst getBottomSeparatorLine = (colWidths) => getSeparatorLine('─', '└', '┴', '┘', colWidths)\nconst getSeparatorLine = (horChar, leftChar, crossChar, rightChar, colWidths) => {\n return leftChar + colWidths.map(function (w) {\n return padString(horChar, w)\n }).join(crossChar) + rightChar\n}\n\nconst padString = (character, width) => {\n if (width < 1) return ''\n return getArray(width).map(() => character).join('')\n}\n\nexport default {\n run: (rows, options = {maxColumnWidth: 30}) => renderForWidth(stringifyLines(rows), options.maxColumnWidth),\n getMaxColumnWidth: (rows) => getColWidths(stringifyLines(rows)).reduce((max, colWidth) => Math.max(max, colWidth), 0)\n}\n\n"]} \ No newline at end of file diff --git a/app/components/ascii-data-table/lib/bundle-angular.js b/app/components/ascii-data-table/lib/bundle-angular.js index 49ca00a9bc4..357164591d2 100644 --- a/app/components/ascii-data-table/lib/bundle-angular.js +++ b/app/components/ascii-data-table/lib/bundle-angular.js @@ -123,14 +123,8 @@ }); }; - var getLineFromRow = function getLineFromRow(prev, col, colIndex) { - var colLines = getLinesFromString(col).reduce(function (final, curr) { - return final.concat(('' + curr).match(new RegExp('.{1,' + prev.colWidths[colIndex] + '}', 'g')) || ['']); - }, []); - colLines = colLines.concat(getArray(prev.rowHeight - colLines.length).map(function (a) { - return ' '; - })); - var linesStr = colLines.filter(function (_, lineIndex) { + var getLineFromCol = function getLineFromCol(prev, _, colIndex) { + var linesStr = prev.colsLines[prev.rowIndex][colIndex].filter(function (_, lineIndex) { return lineIndex === prev.lineIndex; }).map(function (line) { return line + padString(' ', prev.colWidths[colIndex] - line.length); @@ -139,6 +133,15 @@ return prev; }; + var getColLines = function getColLines(col, colWidth, rowHeight) { + var colLines = getLinesFromString(col).reduce(function (final, curr) { + return final.concat(('' + curr).match(new RegExp('.{1,' + colWidth + '}', 'g')) || ['']); + }, []); + return colLines.concat(getArray(rowHeight - colLines.length).map(function (a) { + return ' '; + })); + }; + var getLinesFromString = function getLinesFromString(str) { if (typeof str !== 'string') return [str]; return str.indexOf('\n') > -1 ? str.split('\n') : [str]; @@ -175,13 +178,20 @@ var totalLines = rowHeights.reduce(function (tot, curr) { return tot + curr; }, 0); + var colsLines = rows.reduce(function (colLines, row, rowIndex) { + var cols = row.map(function (col, colIndex) { + return getColLines(col, colWidths[colIndex], rowHeights[rowIndex]); + }); + return colLines.concat([cols]); + }, []); var output = getArray(totalLines).reduce(function (out, _, i) { var lineMeta = getRowIndexForLine(rowHeights, i); - var rowLines = rows[lineMeta.rowIndex].reduce(getLineFromRow, { + var rowLines = rows[lineMeta.rowIndex].reduce(getLineFromCol, { lines: [], lineIndex: lineMeta.lineIndex, - rowHeight: rowHeights[lineMeta.rowIndex], - colWidths: colWidths + colWidths: colWidths, + colsLines: colsLines, + rowIndex: lineMeta.rowIndex }).lines.join('│'); out.push('│' + rowLines + '│'); return out; diff --git a/app/components/ascii-data-table/lib/bundle-angular.js.map b/app/components/ascii-data-table/lib/bundle-angular.js.map index 495a5faf9a3..49a26463807 100644 --- a/app/components/ascii-data-table/lib/bundle-angular.js.map +++ b/app/components/ascii-data-table/lib/bundle-angular.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/bootstrap 3d7de5f6fc76b7a30a05","webpack:///./src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,aAAC,IAAD;SAAO,gEAAU,EAAC,gBAAgB,EAAhB;YAAwB,eAAe,eAAe,IAAf,CAAf,EAAqC,QAAQ,cAAR;IAA/E;AACL,sBAAmB,2BAAC,IAAD;YAAU,aAAa,eAAe,IAAf,CAAb,EAAmC,MAAnC,CAA0C,UAAC,GAAD,EAAM,QAAN;cAAmB,KAAK,GAAL,CAAS,GAAT,EAAc,QAAd;MAAnB,EAA4C,CAAtF;IAAV","file":"lib/bundle-angular.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap 3d7de5f6fc76b7a30a05\n **/","/* global angular */\nimport AsciiTable from '../src/ascii-data-table'\n\nmodule.exports = angular.module('AsciiTableModule', [])\n .service('AsciiTable', () => AsciiTable)\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/entry-angular.js\n **/","const getArray = (len) => Array.apply(null, Array(len)).map((_, i) => i)\n\nconst stringifyVal = (val) => {\n if (Array.isArray(val)) return stringifyArray(val)\n if (typeof val === 'number') return val\n if (typeof val === 'string') return val\n if (typeof val === 'boolean') return val\n if (val === null) return '(null)'\n if (typeof val === 'object') return stringifyObject(val)\n}\n\nconst stringifyArray = (arr) => '[' + arr.map(stringifyVal).join(', ') + ']'\n\nconst stringifyObject = (obj) => {\n if (typeof obj !== 'object') return obj\n return '{' + Object.keys(obj).map((key) => key + ': ' + stringifyVal(obj[key])).join(', ') + '}'\n}\n\nconst stringifyLines = (rows) => {\n if (!Array.isArray(rows) || !rows.length) return []\n return rows.map((row) => row.map(stringifyVal))\n}\n\nconst getRowIndexForLine = (rowHeights, lineNumber) => {\n return rowHeights.reduce((meta, height, rowIndex) => {\n if (meta.remainingLines < 0) return meta\n meta.rowIndex = rowIndex\n if (meta.remainingLines < height) {\n meta.lineIndex = meta.remainingLines\n }\n meta.remainingLines = meta.remainingLines - height\n return meta\n }, {\n rowIndex: 0,\n lineIndex: 0,\n remainingLines: lineNumber\n })\n}\n\nconst getLineFromRow = (prev, col, colIndex) => {\n let colLines = getLinesFromString(col).reduce((final, curr) => {\n return final.concat(('' + curr).match(new RegExp('.{1,' + prev.colWidths[colIndex] + '}', 'g')) || [''])\n }, [])\n colLines = colLines.concat(getArray(prev.rowHeight - colLines.length).map((a) => ' '))\n const linesStr = colLines\n .filter((_, lineIndex) => lineIndex === prev.lineIndex)\n .map((line) => line + padString(' ', prev.colWidths[colIndex] - line.length))\n prev.lines.push(linesStr)\n return prev\n}\n\nconst getLinesFromString = (str) => {\n if (typeof str !== 'string') return [str]\n return str.indexOf('\\n') > -1 ? str.split('\\n') : [str]\n}\n\nconst getColWidths = (rows) => {\n return getArray(rows[0].length).map((i) => {\n return rows.reduce((prev, curr) => {\n const lines = getLinesFromString(curr[i])\n const currMax = lines.reduce((max, line) => {\n return Math.max(max, ('' + line).length)\n }, 0)\n return Math.max(prev, currMax)\n }, 0)\n })\n}\n\nconst renderForWidth = (rows, maxColWidth = 30, minColWidth = 3) => {\n if (!Array.isArray(rows) || !rows.length) return ''\n const colWidths = getColWidths(rows).map((colWidth) => {\n return Math.max(Math.min(colWidth, maxColWidth), minColWidth)\n })\n const rowHeights = rows.map((row) => {\n return row.reduce((prev, curr, colIndex) => {\n const lines = getLinesFromString(curr)\n return lines.reduce((tot, line) => {\n return tot + Math.max(1, Math.max(prev, Math.ceil(('' + line).length / colWidths[colIndex])))\n }, 0)\n }, 0)\n })\n const totalLines = rowHeights.reduce((tot, curr) => tot + curr, 0)\n let output = getArray(totalLines).reduce((out, _, i) => {\n const lineMeta = getRowIndexForLine(rowHeights, i)\n const rowLines = rows[lineMeta.rowIndex].reduce(getLineFromRow, {\n lines: [],\n lineIndex: lineMeta.lineIndex,\n rowHeight: rowHeights[lineMeta.rowIndex],\n colWidths: colWidths\n }).lines.join('│')\n out.push('│' + rowLines + '│')\n return out\n }, [])\n output = insertRowSeparators(output, rowHeights, colWidths)\n return output.join('\\n')\n}\n\nconst insertRowSeparators = (lines, rowHeights, colWidths) => {\n return rowHeights.reduce((out, rowHeight, rowIndex) => {\n out.curr.push.apply(out.curr, out.feeder.splice(0, rowHeight))\n if (rowIndex === 0) {\n out.curr.push(getThickSeparatorLine(colWidths))\n } else if (rowIndex === rowHeights.length - 1) {\n out.curr.push(getBottomSeparatorLine(colWidths))\n } else {\n out.curr.push(getThinSeparatorLine(colWidths))\n }\n return out\n }, {\n feeder: lines,\n curr: [getTopSeparatorLine(colWidths)]\n }).curr\n}\n\nconst getTopSeparatorLine = (colWidths) => getSeparatorLine('═', '╒', '╤', '╕', colWidths)\nconst getThickSeparatorLine = (colWidths) => getSeparatorLine('═', '╞', '╪', '╡', colWidths)\nconst getThinSeparatorLine = (colWidths) => getSeparatorLine('─', '├', '┼', '┤', colWidths)\nconst getBottomSeparatorLine = (colWidths) => getSeparatorLine('─', '└', '┴', '┘', colWidths)\nconst getSeparatorLine = (horChar, leftChar, crossChar, rightChar, colWidths) => {\n return leftChar + colWidths.map(function (w) {\n return padString(horChar, w)\n }).join(crossChar) + rightChar\n}\n\nconst padString = (character, width) => {\n if (width < 1) return ''\n return getArray(width).map(() => character).join('')\n}\n\nexport default {\n run: (rows, options = {maxColumnWidth: 30}) => renderForWidth(stringifyLines(rows), options.maxColumnWidth),\n getMaxColumnWidth: (rows) => getColWidths(stringifyLines(rows)).reduce((max, colWidth) => Math.max(max, colWidth), 0)\n}\n\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/ascii-data-table.js\n **/"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/bootstrap 39878ba0b8241d6d0ade","webpack:///./src/entry-angular.js","webpack:///./src/ascii-data-table.js"],"names":[],"mappings":";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAe;AACf;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;;;;;;;;;;;;ACnCA,QAAO,OAAP,GAAiB,QAAQ,MAAR,CAAe,kBAAf,EAAmC,EAAnC,EACd,OADc,CACN,YADM,EACQ;;EADR,CAAjB,sB;;;;;;;;;;;;;;;;;ACHA,KAAM,WAAW,SAAX,QAAW,CAAC,GAAD;UAAS,MAAM,KAAN,CAAY,IAAZ,EAAkB,MAAM,GAAN,CAAlB,EAA8B,GAA9B,CAAkC,UAAC,CAAD,EAAI,CAAJ;YAAU;IAAV;EAA3C;;AAEjB,KAAM,eAAe,SAAf,YAAe,CAAC,GAAD,EAAS;AAC5B,OAAI,MAAM,OAAN,CAAc,GAAd,CAAJ,EAAwB,OAAO,eAAe,GAAf,CAAP,CAAxB;AACA,OAAI,OAAO,GAAP,KAAe,QAAf,EAAyB,OAAO,GAAP,CAA7B;AACA,OAAI,OAAO,GAAP,KAAe,QAAf,EAAyB,OAAO,GAAP,CAA7B;AACA,OAAI,OAAO,GAAP,KAAe,SAAf,EAA0B,OAAO,GAAP,CAA9B;AACA,OAAI,QAAQ,IAAR,EAAc,OAAO,QAAP,CAAlB;AACA,OAAI,QAAO,iDAAP,KAAe,QAAf,EAAyB,OAAO,gB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AtB,EAA2B,GAA3B,EAAgC,GAAhC,EAAqC,SAArC;EAAf;AAC7B,KAAM,yBAAyB,SAAzB,sBAAyB,CAAC,SAAD;UAAe,iBAAiB,GAAjB,EAAsB,GAAtB,EAA2B,GAA3B,EAAgC,GAAhC,EAAqC,SAArC;EAAf;AAC/B,KAAM,mBAAmB,SAAnB,gBAAmB,CAAC,OAAD,EAAU,QAAV,EAAoB,SAApB,EAA+B,SAA/B,EAA0C,SAA1C,EAAwD;AAC/E,UAAO,WAAW,UAAU,GAAV,CAAc,UAAU,CAAV,EAAa;AAC3C,YAAO,UAAU,OAAV,EAAmB,CAAnB,CAAP,CAD2C;IAAb,CAAd,CAEf,IAFe,CAEV,SAFU,CAAX,GAEc,SAFd,CADwE;EAAxD;;AAMzB,KAAM,YAAY,SAAZ,SAAY,CAAC,SAAD,EAAY,KAAZ,EAAsB;AACtC,OAAI,QAAQ,CAAR,EAAW,OAAO,EAAP,CAAf;AACA,UAAO,SAAS,KAAT,EAAgB,GAAhB,CAAoB;YAAM;IAAN,CAApB,CAAqC,IAArC,CAA0C,EAA1C,CAAP,CAFsC;EAAtB;;mBAKH;AACb,QAAK,aAAC,IAAD;SAAO,gEAAU,EAAC,gBAAgB,EAAhB;YAAwB,eAAe,eAAe,IAAf,CAAf,EAAqC,QAAQ,cAAR;IAA/E;AACL,sBAAmB,2BAAC,IAAD;YAAU,aAAa,eAAe,IAAf,CAAb,EAAmC,MAAnC,CAA0C,UAAC,GAAD,EAAM,QAAN;cAAmB,KAAK,GAAL,CAAS,GAAT,EAAc,QAAd;MAAnB,EAA4C,CAAtF;IAAV","file":"lib/bundle-angular.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap 39878ba0b8241d6d0ade\n **/","/* global angular */\nimport AsciiTable from '../src/ascii-data-table'\n\nmodule.exports = angular.module('AsciiTableModule', [])\n .service('AsciiTable', () => AsciiTable)\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/entry-angular.js\n **/","const getArray = (len) => Array.apply(null, Array(len)).map((_, i) => i)\n\nconst stringifyVal = (val) => {\n if (Array.isArray(val)) return stringifyArray(val)\n if (typeof val === 'number') return val\n if (typeof val === 'string') return val\n if (typeof val === 'boolean') return val\n if (val === null) return '(null)'\n if (typeof val === 'object') return stringifyObject(val)\n}\n\nconst stringifyArray = (arr) => '[' + arr.map(stringifyVal).join(', ') + ']'\n\nconst stringifyObject = (obj) => {\n if (typeof obj !== 'object') return obj\n return '{' + Object.keys(obj).map((key) => key + ': ' + stringifyVal(obj[key])).join(', ') + '}'\n}\n\nconst stringifyLines = (rows) => {\n if (!Array.isArray(rows) || !rows.length) return []\n return rows.map((row) => row.map(stringifyVal))\n}\n\nconst getRowIndexForLine = (rowHeights, lineNumber) => {\n return rowHeights.reduce((meta, height, rowIndex) => {\n if (meta.remainingLines < 0) return meta\n meta.rowIndex = rowIndex\n if (meta.remainingLines < height) {\n meta.lineIndex = meta.remainingLines\n }\n meta.remainingLines = meta.remainingLines - height\n return meta\n }, {\n rowIndex: 0,\n lineIndex: 0,\n remainingLines: lineNumber\n })\n}\n\nconst getLineFromCol = (prev, _, colIndex) => {\n const linesStr = prev.colsLines[prev.rowIndex][colIndex]\n .filter((_, lineIndex) => lineIndex === prev.lineIndex)\n .map((line) => line + padString(' ', prev.colWidths[colIndex] - line.length))\n prev.lines.push(linesStr)\n return prev\n}\n\nconst getColLines = (col, colWidth, rowHeight) => {\n let colLines = getLinesFromString(col).reduce((final, curr) => {\n return final.concat(('' + curr).match(new RegExp('.{1,' + colWidth + '}', 'g')) || [''])\n }, [])\n return colLines.concat(getArray(rowHeight - colLines.length).map((a) => ' '))\n}\n\nconst getLinesFromString = (str) => {\n if (typeof str !== 'string') return [str]\n return str.indexOf('\\n') > -1 ? str.split('\\n') : [str]\n}\n\nconst getColWidths = (rows) => {\n return getArray(rows[0].length).map((i) => {\n return rows.reduce((prev, curr) => {\n const lines = getLinesFromString(curr[i])\n const currMax = lines.reduce((max, line) => {\n return Math.max(max, ('' + line).length)\n }, 0)\n return Math.max(prev, currMax)\n }, 0)\n })\n}\n\nconst renderForWidth = (rows, maxColWidth = 30, minColWidth = 3) => {\n if (!Array.isArray(rows) || !rows.length) return ''\n const colWidths = getColWidths(rows).map((colWidth) => {\n return Math.max(Math.min(colWidth, maxColWidth), minColWidth)\n })\n const rowHeights = rows.map((row) => {\n return row.reduce((prev, curr, colIndex) => {\n const lines = getLinesFromString(curr)\n return lines.reduce((tot, line) => {\n return tot + Math.max(1, Math.max(prev, Math.ceil(('' + line).length / colWidths[colIndex])))\n }, 0)\n }, 0)\n })\n const totalLines = rowHeights.reduce((tot, curr) => tot + curr, 0)\n const colsLines = rows.reduce((colLines, row, rowIndex) => {\n const cols = row.map((col, colIndex) => getColLines(col, colWidths[colIndex], rowHeights[rowIndex]))\n return colLines.concat([cols])\n }, [])\n let output = getArray(totalLines).reduce((out, _, i) => {\n const lineMeta = getRowIndexForLine(rowHeights, i)\n const rowLines = rows[lineMeta.rowIndex].reduce(getLineFromCol, {\n lines: [],\n lineIndex: lineMeta.lineIndex,\n colWidths: colWidths,\n colsLines: colsLines,\n rowIndex: lineMeta.rowIndex\n }).lines.join('│')\n out.push('│' + rowLines + '│')\n return out\n }, [])\n output = insertRowSeparators(output, rowHeights, colWidths)\n return output.join('\\n')\n}\n\nconst insertRowSeparators = (lines, rowHeights, colWidths) => {\n return rowHeights.reduce((out, rowHeight, rowIndex) => {\n out.curr.push.apply(out.curr, out.feeder.splice(0, rowHeight))\n if (rowIndex === 0) {\n out.curr.push(getThickSeparatorLine(colWidths))\n } else if (rowIndex === rowHeights.length - 1) {\n out.curr.push(getBottomSeparatorLine(colWidths))\n } else {\n out.curr.push(getThinSeparatorLine(colWidths))\n }\n return out\n }, {\n feeder: lines,\n curr: [getTopSeparatorLine(colWidths)]\n }).curr\n}\n\nconst getTopSeparatorLine = (colWidths) => getSeparatorLine('═', '╒', '╤', '╕', colWidths)\nconst getThickSeparatorLine = (colWidths) => getSeparatorLine('═', '╞', '╪', '╡', colWidths)\nconst getThinSeparatorLine = (colWidths) => getSeparatorLine('─', '├', '┼', '┤', colWidths)\nconst getBottomSeparatorLine = (colWidths) => getSeparatorLine('─', '└', '┴', '┘', colWidths)\nconst getSeparatorLine = (horChar, leftChar, crossChar, rightChar, colWidths) => {\n return leftChar + colWidths.map(function (w) {\n return padString(horChar, w)\n }).join(crossChar) + rightChar\n}\n\nconst padString = (character, width) => {\n if (width < 1) return ''\n return getArray(width).map(() => character).join('')\n}\n\nexport default {\n run: (rows, options = {maxColumnWidth: 30}) => renderForWidth(stringifyLines(rows), options.maxColumnWidth),\n getMaxColumnWidth: (rows) => getColWidths(stringifyLines(rows)).reduce((max, colWidth) => Math.max(max, colWidth), 0)\n}\n\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/ascii-data-table.js\n **/"],"sourceRoot":""} \ No newline at end of file diff --git a/app/components/ascii-data-table/lib/bundle-react.js b/app/components/ascii-data-table/lib/bundle-react.js index b57226abe9f..2d863285247 100644 --- a/app/components/ascii-data-table/lib/bundle-react.js +++ b/app/components/ascii-data-table/lib/bundle-react.js @@ -128,14 +128,8 @@ var AsciiTableComponent = }); }; - var getLineFromRow = function getLineFromRow(prev, col, colIndex) { - var colLines = getLinesFromString(col).reduce(function (final, curr) { - return final.concat(('' + curr).match(new RegExp('.{1,' + prev.colWidths[colIndex] + '}', 'g')) || ['']); - }, []); - colLines = colLines.concat(getArray(prev.rowHeight - colLines.length).map(function (a) { - return ' '; - })); - var linesStr = colLines.filter(function (_, lineIndex) { + var getLineFromCol = function getLineFromCol(prev, _, colIndex) { + var linesStr = prev.colsLines[prev.rowIndex][colIndex].filter(function (_, lineIndex) { return lineIndex === prev.lineIndex; }).map(function (line) { return line + padString(' ', prev.colWidths[colIndex] - line.length); @@ -144,6 +138,15 @@ var AsciiTableComponent = return prev; }; + var getColLines = function getColLines(col, colWidth, rowHeight) { + var colLines = getLinesFromString(col).reduce(function (final, curr) { + return final.concat(('' + curr).match(new RegExp('.{1,' + colWidth + '}', 'g')) || ['']); + }, []); + return colLines.concat(getArray(rowHeight - colLines.length).map(function (a) { + return ' '; + })); + }; + var getLinesFromString = function getLinesFromString(str) { if (typeof str !== 'string') return [str]; return str.indexOf('\n') > -1 ? str.split('\n') : [str]; @@ -180,13 +183,20 @@ var AsciiTableComponent = var totalLines = rowHeights.reduce(function (tot, curr) { return tot + curr; }, 0); + var colsLines = rows.reduce(function (colLines, row, rowIndex) { + var cols = row.map(function (col, colIndex) { + return getColLines(col, colWidths[colIndex], rowHeights[rowIndex]); + }); + return colLines.concat([cols]); + }, []); var output = getArray(totalLines).reduce(function (out, _, i) { var lineMeta = getRowIndexForLine(rowHeights, i); - var rowLines = rows[lineMeta.rowIndex].reduce(getLineFromRow, { + var rowLines = rows[lineMeta.rowIndex].reduce(getLineFromCol, { lines: [], lineIndex: lineMeta.lineIndex, - rowHeight: rowHeights[lineMeta.rowIndex], - colWidths: colWidths + colWidths: colWidths, + colsLines: colsLines, + rowIndex: lineMeta.rowIndex }).lines.join('│'); out.push('│' + rowLines + '│'); return out; diff --git a/app/components/ascii-data-table/lib/bundle-react.js.map b/app/components/ascii-data-table/lib/bundle-react.js.map index 90e4b88d033..1d9c002432f 100644 --- a/app/components/ascii-data-table/lib/bundle-react.js.map +++ b/app/components/ascii-data-table/lib/bundle-react.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/bootstrap 61d21bdf5b08afa9eab8","webpack:///./src/entry-react.jsx","webpack:///./src/ascii-data-table.js"],"names":[],"mappings":";;AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAe;AACf;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;;;;;;ACtCA;;;;;;AAEA,QAAO,OAAP,GAAiB,UAAC,KAAD;UACf;;OAAK,OAAO,EAAC,OAAO,GAAP,EAAY,QAAQ,GAAR,EAApB,EAAL;KAAwC,yBAAW,GAAX,CAAe,MAAM,IAAN,CAAvD;;EADe,C;;;;;;;;;;;;;;;;;ACFjB,KAAM,WAAW,SAAX,QAAW,CAAC,GAAD;UAAS,MAAM,KAAN,CAAY,IAAZ,EAAkB,MAAM,GAAN,CAAlB,EAA8B,GAA9B,CAAkC,UAAC,CAAD,EAAI,CAAJ;YAAU;IAAV;EAA3C;;AAEjB,KAAM,eAAe,SAAf,YAAe,CAAC,GAAD,EAAS;AAC5B,OAAI,MAAM,OAAN,CAAc,GAAd,CAAJ,EAAwB,OAAO,eAAe,GAAf,CAAP,CAAxB;AACA,OAAI,OAAO,GAAP,KAAe,QAAf,EAAyB,OAAO,GAAP,CAA7B;AACA,OAAI,OAAO,GAAP,KAAe,QAAf,EAAyB,OAAO,GAAP,CAA7B;AACA,OAAI,OAAO,GAAP,KAAe,SAAf,EAA0B,OAAO,GAAP,CAA9B;AACA,OAAI,QAAQ,IAAR,EAAc,OAAO,QAAP,CAAlB;AACA,OAAI,QAAO,iDAAP,KAAe,QAAf,EAAyB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CAEV,SAFU,CAAX,GAEc,SAFd,CADwE;EAAxD;;AAMzB,KAAM,YAAY,SAAZ,SAAY,CAAC,SAAD,EAAY,KAAZ,EAAsB;AACtC,OAAI,QAAQ,CAAR,EAAW,OAAO,EAAP,CAAf;AACA,UAAO,SAAS,KAAT,EAAgB,GAAhB,CAAoB;YAAM;IAAN,CAApB,CAAqC,IAArC,CAA0C,EAA1C,CAAP,CAFsC;EAAtB;;mBAKH;AACb,QAAK,aAAC,IAAD;SAAO,gEAAU,EAAC,gBAAgB,EAAhB;YAAwB,eAAe,eAAe,IAAf,CAAf,EAAqC,QAAQ,cAAR;IAA/E;AACL,sBAAmB,2BAAC,IAAD;YAAU,aAAa,eAAe,IAAf,CAAb,EAAmC,MAAnC,CAA0C,UAAC,GAAD,EAAM,QAAN;cAAmB,KAAK,GAAL,CAAS,GAAT,EAAc,QAAd;MAAnB,EAA4C,CAAtF;IAAV","file":"lib/bundle-react.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap 61d21bdf5b08afa9eab8\n **/","import AsciiTable from '../src/ascii-data-table'\n\nmodule.exports = (props) =>\n
{AsciiTable.run(props.rows)}
\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/entry-react.jsx\n **/","const getArray = (len) => Array.apply(null, Array(len)).map((_, i) => i)\n\nconst stringifyVal = (val) => {\n if (Array.isArray(val)) return stringifyArray(val)\n if (typeof val === 'number') return val\n if (typeof val === 'string') return val\n if (typeof val === 'boolean') return val\n if (val === null) return '(null)'\n if (typeof val === 'object') return stringifyObject(val)\n}\n\nconst stringifyArray = (arr) => '[' + arr.map(stringifyVal).join(', ') + ']'\n\nconst stringifyObject = (obj) => {\n if (typeof obj !== 'object') return obj\n return '{' + Object.keys(obj).map((key) => key + ': ' + stringifyVal(obj[key])).join(', ') + '}'\n}\n\nconst stringifyLines = (rows) => {\n if (!Array.isArray(rows) || !rows.length) return []\n return rows.map((row) => row.map(stringifyVal))\n}\n\nconst getRowIndexForLine = (rowHeights, lineNumber) => {\n return rowHeights.reduce((meta, height, rowIndex) => {\n if (meta.remainingLines < 0) return meta\n meta.rowIndex = rowIndex\n if (meta.remainingLines < height) {\n meta.lineIndex = meta.remainingLines\n }\n meta.remainingLines = meta.remainingLines - height\n return meta\n }, {\n rowIndex: 0,\n lineIndex: 0,\n remainingLines: lineNumber\n })\n}\n\nconst getLineFromRow = (prev, col, colIndex) => {\n let colLines = getLinesFromString(col).reduce((final, curr) => {\n return final.concat(('' + curr).match(new RegExp('.{1,' + prev.colWidths[colIndex] + '}', 'g')) || [''])\n }, [])\n colLines = colLines.concat(getArray(prev.rowHeight - colLines.length).map((a) => ' '))\n const linesStr = colLines\n .filter((_, lineIndex) => lineIndex === prev.lineIndex)\n .map((line) => line + padString(' ', prev.colWidths[colIndex] - line.length))\n prev.lines.push(linesStr)\n return prev\n}\n\nconst getLinesFromString = (str) => {\n if (typeof str !== 'string') return [str]\n return str.indexOf('\\n') > -1 ? str.split('\\n') : [str]\n}\n\nconst getColWidths = (rows) => {\n return getArray(rows[0].length).map((i) => {\n return rows.reduce((prev, curr) => {\n const lines = getLinesFromString(curr[i])\n const currMax = lines.reduce((max, line) => {\n return Math.max(max, ('' + line).length)\n }, 0)\n return Math.max(prev, currMax)\n }, 0)\n })\n}\n\nconst renderForWidth = (rows, maxColWidth = 30, minColWidth = 3) => {\n if (!Array.isArray(rows) || !rows.length) return ''\n const colWidths = getColWidths(rows).map((colWidth) => {\n return Math.max(Math.min(colWidth, maxColWidth), minColWidth)\n })\n const rowHeights = rows.map((row) => {\n return row.reduce((prev, curr, colIndex) => {\n const lines = getLinesFromString(curr)\n return lines.reduce((tot, line) => {\n return tot + Math.max(1, Math.max(prev, Math.ceil(('' + line).length / colWidths[colIndex])))\n }, 0)\n }, 0)\n })\n const totalLines = rowHeights.reduce((tot, curr) => tot + curr, 0)\n let output = getArray(totalLines).reduce((out, _, i) => {\n const lineMeta = getRowIndexForLine(rowHeights, i)\n const rowLines = rows[lineMeta.rowIndex].reduce(getLineFromRow, {\n lines: [],\n lineIndex: lineMeta.lineIndex,\n rowHeight: rowHeights[lineMeta.rowIndex],\n colWidths: colWidths\n }).lines.join('│')\n out.push('│' + rowLines + '│')\n return out\n }, [])\n output = insertRowSeparators(output, rowHeights, colWidths)\n return output.join('\\n')\n}\n\nconst insertRowSeparators = (lines, rowHeights, colWidths) => {\n return rowHeights.reduce((out, rowHeight, rowIndex) => {\n out.curr.push.apply(out.curr, out.feeder.splice(0, rowHeight))\n if (rowIndex === 0) {\n out.curr.push(getThickSeparatorLine(colWidths))\n } else if (rowIndex === rowHeights.length - 1) {\n out.curr.push(getBottomSeparatorLine(colWidths))\n } else {\n out.curr.push(getThinSeparatorLine(colWidths))\n }\n return out\n }, {\n feeder: lines,\n curr: [getTopSeparatorLine(colWidths)]\n }).curr\n}\n\nconst getTopSeparatorLine = (colWidths) => getSeparatorLine('═', '╒', '╤', '╕', colWidths)\nconst getThickSeparatorLine = (colWidths) => getSeparatorLine('═', '╞', '╪', '╡', colWidths)\nconst getThinSeparatorLine = (colWidths) => getSeparatorLine('─', '├', '┼', '┤', colWidths)\nconst getBottomSeparatorLine = (colWidths) => getSeparatorLine('─', '└', '┴', '┘', colWidths)\nconst getSeparatorLine = (horChar, leftChar, crossChar, rightChar, colWidths) => {\n return leftChar + colWidths.map(function (w) {\n return padString(horChar, w)\n }).join(crossChar) + rightChar\n}\n\nconst padString = (character, width) => {\n if (width < 1) return ''\n return getArray(width).map(() => character).join('')\n}\n\nexport default {\n run: (rows, options = {maxColumnWidth: 30}) => renderForWidth(stringifyLines(rows), options.maxColumnWidth),\n getMaxColumnWidth: (rows) => getColWidths(stringifyLines(rows)).reduce((max, colWidth) => Math.max(max, colWidth), 0)\n}\n\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/ascii-data-table.js\n **/"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/bootstrap a730e813ce174f7e99e5","webpack:///./src/entry-react.jsx","webpack:///./src/ascii-data-table.js"],"names":[],"mappings":";;AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAe;AACf;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;;;;;;;;;;;;ACpCA,QAAO,OAAP,GAAiB,UAAC,KAAD;UACf;;OAAK,OAAO,EAAC,OAAO,GAAP,EAAY,QAAQ,GAAR,EAApB,EAAL;KAAwC,yBAAW,GAAX,CAAe,MAAM,IAAN,CAAvD;;EADe,C;;;;;;;;;;;;;;;;;ACFjB,KAAM,WAAW,SAAX,QAAW,CAAC,GAAD;UAAS,MAAM,KAAN,CAAY,IAAZ,EAAkB,MAAM,GAAN,CAAlB,EAA8B,GAA9B,CAAkC,UAAC,CAAD,EAAI,CAAJ;YAAU;IAAV;EAA3C;;AAEjB,KAAM,eAAe,SAAf,YAAe,CAAC,GAAD,EAAS;AAC5B,OAAI,MAAM,OAAN,CAAc,GAAd,CAAJ,EAAwB,OAA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,QAAN;cAAmB,KAAK,GAAL,CAAS,GAAT,EAAc,QAAd;MAAnB,EAA4C,CAAtF;IAAV","file":"lib/bundle-react.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap a730e813ce174f7e99e5\n **/","import AsciiTable from '../src/ascii-data-table'\n\nmodule.exports = (props) =>\n
{AsciiTable.run(props.rows)}
\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/entry-react.jsx\n **/","const getArray = (len) => Array.apply(null, Array(len)).map((_, i) => i)\n\nconst stringifyVal = (val) => {\n if (Array.isArray(val)) return stringifyArray(val)\n if (typeof val === 'number') return val\n if (typeof val === 'string') return val\n if (typeof val === 'boolean') return val\n if (val === null) return '(null)'\n if (typeof val === 'object') return stringifyObject(val)\n}\n\nconst stringifyArray = (arr) => '[' + arr.map(stringifyVal).join(', ') + ']'\n\nconst stringifyObject = (obj) => {\n if (typeof obj !== 'object') return obj\n return '{' + Object.keys(obj).map((key) => key + ': ' + stringifyVal(obj[key])).join(', ') + '}'\n}\n\nconst stringifyLines = (rows) => {\n if (!Array.isArray(rows) || !rows.length) return []\n return rows.map((row) => row.map(stringifyVal))\n}\n\nconst getRowIndexForLine = (rowHeights, lineNumber) => {\n return rowHeights.reduce((meta, height, rowIndex) => {\n if (meta.remainingLines < 0) return meta\n meta.rowIndex = rowIndex\n if (meta.remainingLines < height) {\n meta.lineIndex = meta.remainingLines\n }\n meta.remainingLines = meta.remainingLines - height\n return meta\n }, {\n rowIndex: 0,\n lineIndex: 0,\n remainingLines: lineNumber\n })\n}\n\nconst getLineFromCol = (prev, _, colIndex) => {\n const linesStr = prev.colsLines[prev.rowIndex][colIndex]\n .filter((_, lineIndex) => lineIndex === prev.lineIndex)\n .map((line) => line + padString(' ', prev.colWidths[colIndex] - line.length))\n prev.lines.push(linesStr)\n return prev\n}\n\nconst getColLines = (col, colWidth, rowHeight) => {\n let colLines = getLinesFromString(col).reduce((final, curr) => {\n return final.concat(('' + curr).match(new RegExp('.{1,' + colWidth + '}', 'g')) || [''])\n }, [])\n return colLines.concat(getArray(rowHeight - colLines.length).map((a) => ' '))\n}\n\nconst getLinesFromString = (str) => {\n if (typeof str !== 'string') return [str]\n return str.indexOf('\\n') > -1 ? str.split('\\n') : [str]\n}\n\nconst getColWidths = (rows) => {\n return getArray(rows[0].length).map((i) => {\n return rows.reduce((prev, curr) => {\n const lines = getLinesFromString(curr[i])\n const currMax = lines.reduce((max, line) => {\n return Math.max(max, ('' + line).length)\n }, 0)\n return Math.max(prev, currMax)\n }, 0)\n })\n}\n\nconst renderForWidth = (rows, maxColWidth = 30, minColWidth = 3) => {\n if (!Array.isArray(rows) || !rows.length) return ''\n const colWidths = getColWidths(rows).map((colWidth) => {\n return Math.max(Math.min(colWidth, maxColWidth), minColWidth)\n })\n const rowHeights = rows.map((row) => {\n return row.reduce((prev, curr, colIndex) => {\n const lines = getLinesFromString(curr)\n return lines.reduce((tot, line) => {\n return tot + Math.max(1, Math.max(prev, Math.ceil(('' + line).length / colWidths[colIndex])))\n }, 0)\n }, 0)\n })\n const totalLines = rowHeights.reduce((tot, curr) => tot + curr, 0)\n const colsLines = rows.reduce((colLines, row, rowIndex) => {\n const cols = row.map((col, colIndex) => getColLines(col, colWidths[colIndex], rowHeights[rowIndex]))\n return colLines.concat([cols])\n }, [])\n let output = getArray(totalLines).reduce((out, _, i) => {\n const lineMeta = getRowIndexForLine(rowHeights, i)\n const rowLines = rows[lineMeta.rowIndex].reduce(getLineFromCol, {\n lines: [],\n lineIndex: lineMeta.lineIndex,\n colWidths: colWidths,\n colsLines: colsLines,\n rowIndex: lineMeta.rowIndex\n }).lines.join('│')\n out.push('│' + rowLines + '│')\n return out\n }, [])\n output = insertRowSeparators(output, rowHeights, colWidths)\n return output.join('\\n')\n}\n\nconst insertRowSeparators = (lines, rowHeights, colWidths) => {\n return rowHeights.reduce((out, rowHeight, rowIndex) => {\n out.curr.push.apply(out.curr, out.feeder.splice(0, rowHeight))\n if (rowIndex === 0) {\n out.curr.push(getThickSeparatorLine(colWidths))\n } else if (rowIndex === rowHeights.length - 1) {\n out.curr.push(getBottomSeparatorLine(colWidths))\n } else {\n out.curr.push(getThinSeparatorLine(colWidths))\n }\n return out\n }, {\n feeder: lines,\n curr: [getTopSeparatorLine(colWidths)]\n }).curr\n}\n\nconst getTopSeparatorLine = (colWidths) => getSeparatorLine('═', '╒', '╤', '╕', colWidths)\nconst getThickSeparatorLine = (colWidths) => getSeparatorLine('═', '╞', '╪', '╡', colWidths)\nconst getThinSeparatorLine = (colWidths) => getSeparatorLine('─', '├', '┼', '┤', colWidths)\nconst getBottomSeparatorLine = (colWidths) => getSeparatorLine('─', '└', '┴', '┘', colWidths)\nconst getSeparatorLine = (horChar, leftChar, crossChar, rightChar, colWidths) => {\n return leftChar + colWidths.map(function (w) {\n return padString(horChar, w)\n }).join(crossChar) + rightChar\n}\n\nconst padString = (character, width) => {\n if (width < 1) return ''\n return getArray(width).map(() => character).join('')\n}\n\nexport default {\n run: (rows, options = {maxColumnWidth: 30}) => renderForWidth(stringifyLines(rows), options.maxColumnWidth),\n getMaxColumnWidth: (rows) => getColWidths(stringifyLines(rows)).reduce((max, colWidth) => Math.max(max, colWidth), 0)\n}\n\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/ascii-data-table.js\n **/"],"sourceRoot":""} \ No newline at end of file diff --git a/app/components/ascii-data-table/lib/bundle.js b/app/components/ascii-data-table/lib/bundle.js index 97418f38c55..567486737d0 100644 --- a/app/components/ascii-data-table/lib/bundle.js +++ b/app/components/ascii-data-table/lib/bundle.js @@ -122,14 +122,8 @@ var AsciiTable = }); }; - var getLineFromRow = function getLineFromRow(prev, col, colIndex) { - var colLines = getLinesFromString(col).reduce(function (final, curr) { - return final.concat(('' + curr).match(new RegExp('.{1,' + prev.colWidths[colIndex] + '}', 'g')) || ['']); - }, []); - colLines = colLines.concat(getArray(prev.rowHeight - colLines.length).map(function (a) { - return ' '; - })); - var linesStr = colLines.filter(function (_, lineIndex) { + var getLineFromCol = function getLineFromCol(prev, _, colIndex) { + var linesStr = prev.colsLines[prev.rowIndex][colIndex].filter(function (_, lineIndex) { return lineIndex === prev.lineIndex; }).map(function (line) { return line + padString(' ', prev.colWidths[colIndex] - line.length); @@ -138,6 +132,15 @@ var AsciiTable = return prev; }; + var getColLines = function getColLines(col, colWidth, rowHeight) { + var colLines = getLinesFromString(col).reduce(function (final, curr) { + return final.concat(('' + curr).match(new RegExp('.{1,' + colWidth + '}', 'g')) || ['']); + }, []); + return colLines.concat(getArray(rowHeight - colLines.length).map(function (a) { + return ' '; + })); + }; + var getLinesFromString = function getLinesFromString(str) { if (typeof str !== 'string') return [str]; return str.indexOf('\n') > -1 ? str.split('\n') : [str]; @@ -174,13 +177,20 @@ var AsciiTable = var totalLines = rowHeights.reduce(function (tot, curr) { return tot + curr; }, 0); + var colsLines = rows.reduce(function (colLines, row, rowIndex) { + var cols = row.map(function (col, colIndex) { + return getColLines(col, colWidths[colIndex], rowHeights[rowIndex]); + }); + return colLines.concat([cols]); + }, []); var output = getArray(totalLines).reduce(function (out, _, i) { var lineMeta = getRowIndexForLine(rowHeights, i); - var rowLines = rows[lineMeta.rowIndex].reduce(getLineFromRow, { + var rowLines = rows[lineMeta.rowIndex].reduce(getLineFromCol, { lines: [], lineIndex: lineMeta.lineIndex, - rowHeight: rowHeights[lineMeta.rowIndex], - colWidths: colWidths + colWidths: colWidths, + colsLines: colsLines, + rowIndex: lineMeta.rowIndex }).lines.join('│'); out.push('│' + rowLines + '│'); return out; diff --git a/app/components/ascii-data-table/lib/bundle.js.map b/app/components/ascii-data-table/lib/bundle.js.map index 24e7e70de09..0c45ae49d58 100644 --- a/app/components/ascii-data-table/lib/bundle.js.map +++ b/app/components/ascii-data-table/lib/bundle.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/bootstrap 69027d2cbe9ead384fa5","webpack:///./src/entry.js","webpack:///./src/ascii-data-table.js"],"names":[],"mappings":";;AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAe;AACf;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;;;;;;ACtCA;;;;;;AACA,QAAO,OAAP,4B;;;;;;;;;;;;;;;;;ACDA,KAAM,WAAW,SAAX,QAAW,CAAC,GAAD;UAAS,MAAM,KAAN,CAAY,IAAZ,EAAkB,MAAM,GAAN,CAAlB,EAA8B,GAA9B,CAAkC,UAAC,CAAD,EAAI,CAAJ;YAAU;IAAV;EAA3C;;AAEjB,KAAM,eAAe,SAAf,YAAe,CAAC,GAAD,EAAS;AAC5B,OAAI,MAAM,OAAN,CAAc,GAAd,CAAJ,EAAwB,OAAO,eAAe,GAAf,CAAP,CAAxB;AACA,OAAI,OAAO,GAAP,KAAe,QAAf,EAAyB,OAAO,GAAP,CAA7B;AACA,OAAI,OAAO,GAAP,KAAe,QAAf,EAAyB,OAAO,GAAP,CAA7B;AACA,OAAI,OAAO,GAAP,KAAe,SAAf,EAA0B,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AU,GAAV,CAAc,UAAU,CAAV,EAAa;AAC3C,YAAO,UAAU,OAAV,EAAmB,CAAnB,CAAP,CAD2C;IAAb,CAAd,CAEf,IAFe,CAEV,SAFU,CAAX,GAEc,SAFd,CADwE;EAAxD;;AAMzB,KAAM,YAAY,SAAZ,SAAY,CAAC,SAAD,EAAY,KAAZ,EAAsB;AACtC,OAAI,QAAQ,CAAR,EAAW,OAAO,EAAP,CAAf;AACA,UAAO,SAAS,KAAT,EAAgB,GAAhB,CAAoB;YAAM;IAAN,CAApB,CAAqC,IAArC,CAA0C,EAA1C,CAAP,CAFsC;EAAtB;;mBAKH;AACb,QAAK,aAAC,IAAD;SAAO,gEAAU,EAAC,gBAAgB,EAAhB;YAAwB,eAAe,eAAe,IAAf,CAAf,EAAqC,QAAQ,cAAR;IAA/E;AACL,sBAAmB,2BAAC,IAAD;YAAU,aAAa,eAAe,IAAf,CAAb,EAAmC,MAAnC,CAA0C,UAAC,GAAD,EAAM,QAAN;cAAmB,KAAK,GAAL,CAAS,GAAT,EAAc,QAAd;MAAnB,EAA4C,CAAtF;IAAV","file":"lib/bundle.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap 69027d2cbe9ead384fa5\n **/","import AsciiTable from '../src/ascii-data-table'\nmodule.exports = AsciiTable\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/entry.js\n **/","const getArray = (len) => Array.apply(null, Array(len)).map((_, i) => i)\n\nconst stringifyVal = (val) => {\n if (Array.isArray(val)) return stringifyArray(val)\n if (typeof val === 'number') return val\n if (typeof val === 'string') return val\n if (typeof val === 'boolean') return val\n if (val === null) return '(null)'\n if (typeof val === 'object') return stringifyObject(val)\n}\n\nconst stringifyArray = (arr) => '[' + arr.map(stringifyVal).join(', ') + ']'\n\nconst stringifyObject = (obj) => {\n if (typeof obj !== 'object') return obj\n return '{' + Object.keys(obj).map((key) => key + ': ' + stringifyVal(obj[key])).join(', ') + '}'\n}\n\nconst stringifyLines = (rows) => {\n if (!Array.isArray(rows) || !rows.length) return []\n return rows.map((row) => row.map(stringifyVal))\n}\n\nconst getRowIndexForLine = (rowHeights, lineNumber) => {\n return rowHeights.reduce((meta, height, rowIndex) => {\n if (meta.remainingLines < 0) return meta\n meta.rowIndex = rowIndex\n if (meta.remainingLines < height) {\n meta.lineIndex = meta.remainingLines\n }\n meta.remainingLines = meta.remainingLines - height\n return meta\n }, {\n rowIndex: 0,\n lineIndex: 0,\n remainingLines: lineNumber\n })\n}\n\nconst getLineFromRow = (prev, col, colIndex) => {\n let colLines = getLinesFromString(col).reduce((final, curr) => {\n return final.concat(('' + curr).match(new RegExp('.{1,' + prev.colWidths[colIndex] + '}', 'g')) || [''])\n }, [])\n colLines = colLines.concat(getArray(prev.rowHeight - colLines.length).map((a) => ' '))\n const linesStr = colLines\n .filter((_, lineIndex) => lineIndex === prev.lineIndex)\n .map((line) => line + padString(' ', prev.colWidths[colIndex] - line.length))\n prev.lines.push(linesStr)\n return prev\n}\n\nconst getLinesFromString = (str) => {\n if (typeof str !== 'string') return [str]\n return str.indexOf('\\n') > -1 ? str.split('\\n') : [str]\n}\n\nconst getColWidths = (rows) => {\n return getArray(rows[0].length).map((i) => {\n return rows.reduce((prev, curr) => {\n const lines = getLinesFromString(curr[i])\n const currMax = lines.reduce((max, line) => {\n return Math.max(max, ('' + line).length)\n }, 0)\n return Math.max(prev, currMax)\n }, 0)\n })\n}\n\nconst renderForWidth = (rows, maxColWidth = 30, minColWidth = 3) => {\n if (!Array.isArray(rows) || !rows.length) return ''\n const colWidths = getColWidths(rows).map((colWidth) => {\n return Math.max(Math.min(colWidth, maxColWidth), minColWidth)\n })\n const rowHeights = rows.map((row) => {\n return row.reduce((prev, curr, colIndex) => {\n const lines = getLinesFromString(curr)\n return lines.reduce((tot, line) => {\n return tot + Math.max(1, Math.max(prev, Math.ceil(('' + line).length / colWidths[colIndex])))\n }, 0)\n }, 0)\n })\n const totalLines = rowHeights.reduce((tot, curr) => tot + curr, 0)\n let output = getArray(totalLines).reduce((out, _, i) => {\n const lineMeta = getRowIndexForLine(rowHeights, i)\n const rowLines = rows[lineMeta.rowIndex].reduce(getLineFromRow, {\n lines: [],\n lineIndex: lineMeta.lineIndex,\n rowHeight: rowHeights[lineMeta.rowIndex],\n colWidths: colWidths\n }).lines.join('│')\n out.push('│' + rowLines + '│')\n return out\n }, [])\n output = insertRowSeparators(output, rowHeights, colWidths)\n return output.join('\\n')\n}\n\nconst insertRowSeparators = (lines, rowHeights, colWidths) => {\n return rowHeights.reduce((out, rowHeight, rowIndex) => {\n out.curr.push.apply(out.curr, out.feeder.splice(0, rowHeight))\n if (rowIndex === 0) {\n out.curr.push(getThickSeparatorLine(colWidths))\n } else if (rowIndex === rowHeights.length - 1) {\n out.curr.push(getBottomSeparatorLine(colWidths))\n } else {\n out.curr.push(getThinSeparatorLine(colWidths))\n }\n return out\n }, {\n feeder: lines,\n curr: [getTopSeparatorLine(colWidths)]\n }).curr\n}\n\nconst getTopSeparatorLine = (colWidths) => getSeparatorLine('═', '╒', '╤', '╕', colWidths)\nconst getThickSeparatorLine = (colWidths) => getSeparatorLine('═', '╞', '╪', '╡', colWidths)\nconst getThinSeparatorLine = (colWidths) => getSeparatorLine('─', '├', '┼', '┤', colWidths)\nconst getBottomSeparatorLine = (colWidths) => getSeparatorLine('─', '└', '┴', '┘', colWidths)\nconst getSeparatorLine = (horChar, leftChar, crossChar, rightChar, colWidths) => {\n return leftChar + colWidths.map(function (w) {\n return padString(horChar, w)\n }).join(crossChar) + rightChar\n}\n\nconst padString = (character, width) => {\n if (width < 1) return ''\n return getArray(width).map(() => character).join('')\n}\n\nexport default {\n run: (rows, options = {maxColumnWidth: 30}) => renderForWidth(stringifyLines(rows), options.maxColumnWidth),\n getMaxColumnWidth: (rows) => getColWidths(stringifyLines(rows)).reduce((max, colWidth) => Math.max(max, colWidth), 0)\n}\n\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/ascii-data-table.js\n **/"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/bootstrap 3cb75ec172d47ecfe299","webpack:///./src/entry.js","webpack:///./src/ascii-data-table.js"],"names":[],"mappings":";;AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAe;AACf;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;;;;;;;;;;;;ACrCA,QAAO,OAAP,4B;;;;;;;;;;;;;;;;;ACDA,KAAM,WAAW,SAAX,QAAW,CAAC,GAAD;UAAS,MAAM,KAAN,CAAY,IAAZ,EAAkB,MAAM,GAAN,CAAlB,EAA8B,GAA9B,CAAkC,UAAC,CAAD,EAAI,CAAJ;YAAU;IAAV;EAA3C;;AAEjB,KAAM,eAAe,SAAf,YAAe,CAAC,GAAD,EAAS;AAC5B,OAAI,MAAM,OAAN,CAAc,GAAd,CAAJ,EAAwB,OAAO,eAAe,GAAf,CAAP,CAAxB;AACA,OAAI,OAAO,GAAP,KAAe,QAAf,E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,CAAtF;IAAV","file":"lib/bundle.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap 3cb75ec172d47ecfe299\n **/","import AsciiTable from '../src/ascii-data-table'\nmodule.exports = AsciiTable\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/entry.js\n **/","const getArray = (len) => Array.apply(null, Array(len)).map((_, i) => i)\n\nconst stringifyVal = (val) => {\n if (Array.isArray(val)) return stringifyArray(val)\n if (typeof val === 'number') return val\n if (typeof val === 'string') return val\n if (typeof val === 'boolean') return val\n if (val === null) return '(null)'\n if (typeof val === 'object') return stringifyObject(val)\n}\n\nconst stringifyArray = (arr) => '[' + arr.map(stringifyVal).join(', ') + ']'\n\nconst stringifyObject = (obj) => {\n if (typeof obj !== 'object') return obj\n return '{' + Object.keys(obj).map((key) => key + ': ' + stringifyVal(obj[key])).join(', ') + '}'\n}\n\nconst stringifyLines = (rows) => {\n if (!Array.isArray(rows) || !rows.length) return []\n return rows.map((row) => row.map(stringifyVal))\n}\n\nconst getRowIndexForLine = (rowHeights, lineNumber) => {\n return rowHeights.reduce((meta, height, rowIndex) => {\n if (meta.remainingLines < 0) return meta\n meta.rowIndex = rowIndex\n if (meta.remainingLines < height) {\n meta.lineIndex = meta.remainingLines\n }\n meta.remainingLines = meta.remainingLines - height\n return meta\n }, {\n rowIndex: 0,\n lineIndex: 0,\n remainingLines: lineNumber\n })\n}\n\nconst getLineFromCol = (prev, _, colIndex) => {\n const linesStr = prev.colsLines[prev.rowIndex][colIndex]\n .filter((_, lineIndex) => lineIndex === prev.lineIndex)\n .map((line) => line + padString(' ', prev.colWidths[colIndex] - line.length))\n prev.lines.push(linesStr)\n return prev\n}\n\nconst getColLines = (col, colWidth, rowHeight) => {\n let colLines = getLinesFromString(col).reduce((final, curr) => {\n return final.concat(('' + curr).match(new RegExp('.{1,' + colWidth + '}', 'g')) || [''])\n }, [])\n return colLines.concat(getArray(rowHeight - colLines.length).map((a) => ' '))\n}\n\nconst getLinesFromString = (str) => {\n if (typeof str !== 'string') return [str]\n return str.indexOf('\\n') > -1 ? str.split('\\n') : [str]\n}\n\nconst getColWidths = (rows) => {\n return getArray(rows[0].length).map((i) => {\n return rows.reduce((prev, curr) => {\n const lines = getLinesFromString(curr[i])\n const currMax = lines.reduce((max, line) => {\n return Math.max(max, ('' + line).length)\n }, 0)\n return Math.max(prev, currMax)\n }, 0)\n })\n}\n\nconst renderForWidth = (rows, maxColWidth = 30, minColWidth = 3) => {\n if (!Array.isArray(rows) || !rows.length) return ''\n const colWidths = getColWidths(rows).map((colWidth) => {\n return Math.max(Math.min(colWidth, maxColWidth), minColWidth)\n })\n const rowHeights = rows.map((row) => {\n return row.reduce((prev, curr, colIndex) => {\n const lines = getLinesFromString(curr)\n return lines.reduce((tot, line) => {\n return tot + Math.max(1, Math.max(prev, Math.ceil(('' + line).length / colWidths[colIndex])))\n }, 0)\n }, 0)\n })\n const totalLines = rowHeights.reduce((tot, curr) => tot + curr, 0)\n const colsLines = rows.reduce((colLines, row, rowIndex) => {\n const cols = row.map((col, colIndex) => getColLines(col, colWidths[colIndex], rowHeights[rowIndex]))\n return colLines.concat([cols])\n }, [])\n let output = getArray(totalLines).reduce((out, _, i) => {\n const lineMeta = getRowIndexForLine(rowHeights, i)\n const rowLines = rows[lineMeta.rowIndex].reduce(getLineFromCol, {\n lines: [],\n lineIndex: lineMeta.lineIndex,\n colWidths: colWidths,\n colsLines: colsLines,\n rowIndex: lineMeta.rowIndex\n }).lines.join('│')\n out.push('│' + rowLines + '│')\n return out\n }, [])\n output = insertRowSeparators(output, rowHeights, colWidths)\n return output.join('\\n')\n}\n\nconst insertRowSeparators = (lines, rowHeights, colWidths) => {\n return rowHeights.reduce((out, rowHeight, rowIndex) => {\n out.curr.push.apply(out.curr, out.feeder.splice(0, rowHeight))\n if (rowIndex === 0) {\n out.curr.push(getThickSeparatorLine(colWidths))\n } else if (rowIndex === rowHeights.length - 1) {\n out.curr.push(getBottomSeparatorLine(colWidths))\n } else {\n out.curr.push(getThinSeparatorLine(colWidths))\n }\n return out\n }, {\n feeder: lines,\n curr: [getTopSeparatorLine(colWidths)]\n }).curr\n}\n\nconst getTopSeparatorLine = (colWidths) => getSeparatorLine('═', '╒', '╤', '╕', colWidths)\nconst getThickSeparatorLine = (colWidths) => getSeparatorLine('═', '╞', '╪', '╡', colWidths)\nconst getThinSeparatorLine = (colWidths) => getSeparatorLine('─', '├', '┼', '┤', colWidths)\nconst getBottomSeparatorLine = (colWidths) => getSeparatorLine('─', '└', '┴', '┘', colWidths)\nconst getSeparatorLine = (horChar, leftChar, crossChar, rightChar, colWidths) => {\n return leftChar + colWidths.map(function (w) {\n return padString(horChar, w)\n }).join(crossChar) + rightChar\n}\n\nconst padString = (character, width) => {\n if (width < 1) return ''\n return getArray(width).map(() => character).join('')\n}\n\nexport default {\n run: (rows, options = {maxColumnWidth: 30}) => renderForWidth(stringifyLines(rows), options.maxColumnWidth),\n getMaxColumnWidth: (rows) => getColWidths(stringifyLines(rows)).reduce((max, colWidth) => Math.max(max, colWidth), 0)\n}\n\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/ascii-data-table.js\n **/"],"sourceRoot":""} \ No newline at end of file diff --git a/app/components/ascii-data-table/package.json b/app/components/ascii-data-table/package.json index 2b055c11a27..ea0e133233b 100644 --- a/app/components/ascii-data-table/package.json +++ b/app/components/ascii-data-table/package.json @@ -1,6 +1,6 @@ { "name": "ascii-data-table", - "version": "1.3.2", + "version": "1.3.3", "description": "Render data in a width adjustable ascii table.", "main": "lib/ascii-data-table", "standard": {