diff --git a/README.md b/README.md
new file mode 100644
index 0000000..b4044e5
--- /dev/null
+++ b/README.md
@@ -0,0 +1,402 @@
+[![cover][cover-src]][cover-href]
+[![npm version][npm-version-src]][npm-version-href]
+[![npm downloads][npm-downloads-src]][npm-downloads-href]
+[![bundle][bundle-src]][bundle-href] [![JSDocs][jsdocs-src]][jsdocs-href]
+[![License][license-src]][license-href]
+
+# tabletron
+
+> 🎨✨ Transform your terminal output into a clear, easily readable table with just one command! 📊🔍
+
+
+
+
+ Tables can be automatically responsive!
+
+
+### ✨ Features
+- 📏 Content wrapped to fit column width
+- 📐 Column widths `auto`, `content-width`, viewport percents & static values
+- ↔️ Align left & right
+- 🧱 Horizontal & vertical padding
+- 🌊 Rows can overflow into multiple rows
+- 📱 Easy to make responsive tables
+
+➡️ [Try it out online](https://stackblitz.com/edit/tabletron-demo?devtoolsheight=50&file=examples/tabletron.js&view=editor)
+
+> Support this project by ⭐️ starring and sharing it. [Follow me](https://github.com/nyxb) to see what other cool projects I'm working on! 💙
+
+## 🚀 Install:
+
+```bash
+# nyxi
+nyxi tabletron
+
+# pnpm
+pnpm add tabletron
+
+# npm
+npm i tabletron
+
+# yarn
+yarn add tabletron
+```
+
+## ⏱️ Quick start
+Render a table by passing table data into `tabletron` and writing it to stdout.
+
+```ts
+import tabletron from 'tabletron'
+
+// Create table data
+const tableData = [
+ ['Cell A1', 'Cell B1', 'Cell C1'],
+ ['Cell A2', 'Cell B2', 'Cell C2'],
+ ['Cell A3', 'Cell B3', 'Cell C3']
+]
+
+// Render table
+const tableString = tabletron(tableData)
+console.log(tableString)
+```
+
+By default, the columns will be rendered with the `auto` width, which splits the available width with other `auto` columns. To configure the width of each column, pass them in as the second argument.
+
+```ts
+const tableString = tabletron(
+ tableData,
+
+ // Configure column widths
+ [
+ 'content-width', // Use the width of the content
+ '50%', // Fill 50% of viewport width
+ 'auto' // Fill remaining width
+ ]
+)
+```
+
+## 📖 Examples
+
+### 📏 Fixed width table
+You can set a fixed width for each column by passing in a the number of columns.
+
+However, note that this will wrap the row to the next line if the viewport width is smaller than the table width.
+
+```ts
+tabletron(
+ tableData,
+ [
+ 30,
+ 30,
+ 30
+ ]
+)
+```
+
+### 📏 Fixed width table with no row-wrapping
+You can change the row-wrapping behavior by telling `tabletron` to use a different viewport width via the `stdoutColumns` option. For example, passing in `Infinity` will trick it into thinking the table is never overflowing the viewport width.
+
+```ts
+tabletron(
+ tableData,
+ {
+ stdoutColumns: Number.POSITIVE_INFINITY,
+ columns: [
+ 30,
+ 30,
+ 30
+ ]
+ }
+)
+```
+
+### 🧱 Padding
+You can add padding to each column by setting `paddingLeft`, `paddingRight`, `paddingTop`, or `paddingBottom` on the column.
+
+```ts
+tabletron(
+ tableData,
+ [
+ {
+ paddingLeft: 2 // Pad the left side of the cell with 2 spaces
+ },
+ {
+ paddingRight: 2 // Pad the right side of the cell with 2 spaces
+ },
+ {
+ paddingTop: 2 // Pad the top of the cell with 2 lines
+ },
+ {
+ paddingBottom: 2 // Pad the bottom of the cell with 2 lines
+ }
+ ]
+)
+```
+
+### ➡️ Right align text
+You can align the content of the column by setting `align: 'right'`.
+
+```ts
+tabletron(
+ tableData,
+ [
+ {
+ align: 'right'
+ }
+ ]
+)
+```
+
+### 📱 Responsive table with breakpoints function
+Define breakpoints declaratively with the `breakpoints` function.
+
+```ts
+import tabletron, { breakpoints } from 'tabletron'
+
+tabletron(
+ tableData,
+ breakpoints({
+ // Large screens
+ '>= 90': ['content-width', 'auto'],
+
+ // Small screens
+ '>= 25': ['100%', '100%'],
+
+ // Tiny screens - remove responsiveness
+ '>= 0': {
+ columns: ['content-width', 'content-width'],
+ stdoutColumns: Number.POSITIVE_INFINITY
+ }
+ })
+)
+```
+
+### 🔧 Preprocess / Postprocess
+Preprocessing and postprocessing can be used to modify the table data before it is rendered. It's primarily designed for formatting purposes and can be useful to style text in a declarative manner.
+
+In this example, the first column spans the entire screen and is transformed to be uppercase on screens smaller than 80 columns.
+
+```ts
+tabletron(
+ tableData,
+ breakpoints({
+ // Small screens
+ '< 80': [
+ {
+ width: '100%',
+ preprocess: text => text.toUpperCase()
+ },
+ '100%'
+ ]
+ })
+)
+```
+
+### 📱 Responsive table with custom function
+You can make the table responsive by passing in a function that computes the column width allocation based on the detected viewport width.
+
+For a working example, see [this example](/examples/responsive-table.ts).
+
+```ts
+tabletron(
+ tableData,
+ (stdoutColumns) => {
+ /**
+ * For large viewports
+ * Split screen automatically
+ */
+ if (stdoutColumns > 100) {
+ return [
+ {
+ width: 'auto',
+ paddingRight: 1
+ },
+ {
+ width: 'auto'
+ }
+ ]
+ }
+
+ /**
+ * For medium viewports
+ * Break table row into two rows, and add vertical padding to create
+ * a divider between rows
+ */
+ if (stdoutColumns > 30) {
+ return [
+ {
+ width: '100%'
+ },
+ {
+ width: '100%',
+ paddingBottom: 1
+ }
+ ]
+ }
+
+ /**
+ * For viewports smaller than or equal to 30 columns
+ * In this case, the screen is too small to render anything.
+ * Simply remove responsiveness and assume the viewport width
+ * is actually 1000 columns.
+ */
+ return {
+ // Remove responsiveness
+ stdoutColumns: 1000,
+ columns: [
+ {
+ width: 'content-width',
+ paddingRight: 1
+ },
+ {
+ width: 'content-width'
+ }
+ ]
+ }
+ }
+)
+```
+
+
+## ⚙️ API
+
+### 🚀 tabletron(tableData, options?)
+Return type: `string`
+
+Takes in table data and outputs a string that represents the table within the current terminal width (`process.stdout.columns`).
+
+#### 📋 tableData
+Type: `string[][]`
+
+Required
+
+A nested array where the first-level are "rows", and the second-level are "columns".
+
+#### ⚙️ options
+Type: `OptionsObject | (stdoutColumns: number) => OptionsObject | ColumnMetasArray`
+
+Schema:
+```ts
+type Options = OptionsObject | OptionsFunction
+
+type OptionsObject = ColumnMetasArray | {
+ columns: ColumnMetasArray
+ stdoutColumns?: number
+}
+
+type OptionsFunction = (stdoutColumns: number) => OptionsObject
+
+type ColumnMetasArray = (ColumnWidth | ColumnMeta)[]
+
+type ColumnWidth = number | 'content-width' | 'auto' | string
+
+interface ColumnMeta {
+ width: ColumnWidth
+ paddingRight?: number
+ paddingLeft?: number
+ paddingTop?: number
+ paddingBottom?: number
+ align?: 'left' | 'right'
+}
+```
+
+Options to define the column widths (default is `auto`) and the stdout columns to use.
+
+#### 🖥️ stdoutColumns
+Type: `number`
+
+Default: `process.stdout.columns`
+
+The number of columns in the terminal. Autodetected by default. This is used to calculate the max-width of the table and can be overriden to force a specific width.
+
+#### 📊 columns
+
+Type: `Object`
+
+##### 📏 width
+
+Type: `number | 'content-width' | 'auto' | string`
+
+- 📏 `number`: number of columns to span
+- 📐 `'content-width'`: The width of the content in the column
+- 🔄 `'auto'`: Allocate the remaining width of the row to the column
+- 🔢 `string`: Percentage of the viewport width to use (e.g. `'50%'`)
+
+For all of these values, the max width is `stdoutColumns`.
+
+
+##### ⬅️ paddingLeft
+
+Type: `number`
+
+How many spaces to the left the column should have
+
+##### ➡️ paddingRight
+
+Type: `number`
+
+How many spaces to the right the column should have
+
+##### ⬆️ paddingTop
+
+Type: `number`
+
+How many new lines to the top the column should have
+
+##### ⬇️ paddingBottom
+
+Type: `number`
+
+How many new lines to the bottom the column should have
+
+##### ↔️ align
+
+Type: `'left' | 'right'`
+
+Default: `'left'`
+
+Whether to align the text to the left or right.
+
+##### 🔧 preprocess
+
+Type: `(cellValue: string) => string`
+
+Function to preprocess the cell value before it is wrapped to the column width.
+
+##### 🔧 postprocess
+
+Type: `(line: string, lineNumber: number) => string`
+
+Function to postprocess the individual lines of a cell after it has been wrapped to the column width.
+
+### ⚡️ breakpoints(breakpointsMap)
+
+A function to declaratively define breakpoints. Returns a function pass into `tabletron`.
+
+#### 📊 breakpointsMap
+
+Type: `Record`
+
+An object mapping breakpoints to options. The key must be in the format: ` `. For example, `>= 90` will match if the terminal width is 90 or more.
+
+
+## 📜 License
+
+[MIT](./LICENSE) - Made with 💙
+
+
+
+[npm-version-src]: https://img.shields.io/npm/v/tabletron?style=flat&colorA=18181B&colorB=14F195
+[npm-version-href]: https://npmjs.com/package/tabletron
+[npm-downloads-src]: https://img.shields.io/npm/dm/tabletron?style=flat&colorA=18181B&colorB=14F195
+[npm-downloads-href]: https://npmjs.com/package/tabletron
+[bundle-src]: https://img.shields.io/bundlephobia/minzip/tabletron?style=flat&colorA=18181B&colorB=14F195
+[bundle-href]: https://bundlephobia.com/result?p=tabletron
+[jsdocs-src]: https://img.shields.io/badge/jsDocs.io-reference-18181B?style=flat&colorA=18181B&colorB=14F195
+[jsdocs-href]: https://www.jsdocs.io/package/tabletron
+[license-src]: https://img.shields.io/github/license/nyxblabs/tabletron.svg?style=flat&colorA=18181B&colorB=14F195
+[license-href]: https://github.com/nyxblabs/tabletron/blob/main/LICENSE
+
+
+[cover-src]: https://raw.githubusercontent.com/nyxblabs/tabletron/main/.github/assets/cover-github-tabletron.png
+[cover-href]: https://💻nyxb.ws
diff --git a/examples/auto-resize.ts b/examples/auto-resize.ts
index aa3d9d9..6de5dec 100644
--- a/examples/auto-resize.ts
+++ b/examples/auto-resize.ts
@@ -8,7 +8,7 @@
import { promisify } from 'node:util'
import ansiEscapes from 'ansi-escapes'
import color from '@nyxb/picocolors'
-import terminalColumns from '../src'
+import tabletron from '../src'
const { red, blue, green } = color
@@ -21,7 +21,7 @@ const tableData = [
]
function renderTable() {
- const table = terminalColumns(tableData)
+ const table = tabletron(tableData)
process.stdout.write(ansiEscapes.clearTerminal + table)
}
diff --git a/examples/lorem-ipsum.ts b/examples/lorem-ipsum.ts
index e31c372..e22e286 100644
--- a/examples/lorem-ipsum.ts
+++ b/examples/lorem-ipsum.ts
@@ -6,53 +6,54 @@
* $ npx esno examples/lorem-ipsum.ts
*/
-import ansiEscapes from 'ansi-escapes';
-import { bold, underline, italic } from 'colorette';
-import terminalColumns from '../src';
+import ansiEscapes from 'ansi-escapes'
+import color from '@nyxb/picocolors'
+import tabletron from '../src'
+
+const { bold, italic, underline } = color
const tableData = [
- [
- italic('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Id neque aliquam vestibulum morbi blandit cursus risus at.'),
- underline('Sit amet luctus venenatis lectus magna. Nisi porta lorem mollis aliquam ut porttitor leo a. Sem integer vitae justo eget magna. Erat pellentesque adipiscing commodo elit.'),
- bold('Ultrices tincidunt arcu non sodales neque. Quis blandit turpis cursus in hac habitasse platea dictumst quisque. Libero enim sed faucibus turpis in eu mi bibendum neque.'),
- ],
-];
-
-const renderTable = (stdoutColumns: number) => {
- const table = terminalColumns(tableData, {
- stdoutColumns,
- columns: [
- {
- align: 'right',
- paddingRight: 4,
- paddingBottom: 1,
- },
- {
- paddingRight: 4,
- paddingBottom: 1,
- },
- ],
- });
-
- process.stdout.write(`${ansiEscapes.clearTerminal + table}\n\n\n`);
-};
-
-const stdoutWidth = process.stdout.columns;
-let tableWidth = process.stdout.columns;
-let movingDown = true;
+ [
+ italic('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Id neque aliquam vestibulum morbi blandit cursus risus at.'),
+ underline('Sit amet luctus venenatis lectus magna. Nisi porta lorem mollis aliquam ut porttitor leo a. Sem integer vitae justo eget magna. Erat pellentesque adipiscing commodo elit.'),
+ bold('Ultrices tincidunt arcu non sodales neque. Quis blandit turpis cursus in hac habitasse platea dictumst quisque. Libero enim sed faucibus turpis in eu mi bibendum neque.'),
+ ],
+]
+
+function renderTable(stdoutColumns: number) {
+ const table = tabletron(tableData, {
+ stdoutColumns,
+ columns: [
+ {
+ align: 'right',
+ paddingRight: 4,
+ paddingBottom: 1,
+ },
+ {
+ paddingRight: 4,
+ paddingBottom: 1,
+ },
+ ],
+ })
+
+ process.stdout.write(`${ansiEscapes.clearTerminal + table}\n\n\n`)
+}
+
+const stdoutWidth = process.stdout.columns
+let tableWidth = process.stdout.columns
+let movingDown = true
setInterval(() => {
- if (movingDown) {
- tableWidth -= 1;
- if (tableWidth === 30) {
- movingDown = false;
- }
- } else {
- tableWidth += 1;
- if (tableWidth === stdoutWidth) {
- movingDown = true;
- }
- }
-
- renderTable(tableWidth);
-}, 100);
+ if (movingDown) {
+ tableWidth -= 1
+ if (tableWidth === 30)
+ movingDown = false
+ }
+ else {
+ tableWidth += 1
+ if (tableWidth === stdoutWidth)
+ movingDown = true
+ }
+
+ renderTable(tableWidth)
+}, 100)
diff --git a/examples/responsive-table.ts b/examples/responsive-table.ts
index 73a3fdf..afee00d 100644
--- a/examples/responsive-table.ts
+++ b/examples/responsive-table.ts
@@ -4,154 +4,154 @@
* Run the example:
* $ npx esno examples/responsive-table.ts
*/
-import { promisify } from 'util';
-import ansiEscapes from 'ansi-escapes';
-import terminalColumns from '../src';
+import { promisify } from 'node:util'
+import ansiEscapes from 'ansi-escapes'
+import tabletron from '../src'
const tableData = [
- [
- 'Jacky',
- 'Mapp',
- 'Georgian',
- '1992-08-09',
- ],
- [
- 'Raphaela',
- 'Gaddes',
- 'Filipino',
- '1991-07-22',
- ],
- [
- 'Mellie',
- 'Hassey',
- 'Dhivehi',
- '2000-02-06',
- ],
- [
- 'Dru',
- 'Clout',
- 'Thai',
- '1997-09-17',
- ],
- [
- 'Sig',
- 'Evered',
- 'Telugu',
- '1993-12-17',
- ],
- [
- 'Velvet',
- 'Gambrell',
- 'Telugu',
- '1995-10-18',
- ],
- [
- 'Alta',
- 'Bagenal',
- 'Thai',
- '1992-06-03',
- ],
- [
- 'Jerrome',
- 'Fosten',
- 'Kashmiri',
- '2000-09-11',
- ],
- [
- 'Derk',
- 'Emons',
- 'Ndebele',
- '1994-04-30',
- ],
- [
- 'Glennis',
- 'Patmore',
- 'Swati',
- '2000-06-05',
- ],
-];
+ [
+ 'Jacky',
+ 'Mapp',
+ 'Georgian',
+ '1992-08-09',
+ ],
+ [
+ 'Raphaela',
+ 'Gaddes',
+ 'Filipino',
+ '1991-07-22',
+ ],
+ [
+ 'Mellie',
+ 'Hassey',
+ 'Dhivehi',
+ '2000-02-06',
+ ],
+ [
+ 'Dru',
+ 'Clout',
+ 'Thai',
+ '1997-09-17',
+ ],
+ [
+ 'Sig',
+ 'Evered',
+ 'Telugu',
+ '1993-12-17',
+ ],
+ [
+ 'Velvet',
+ 'Gambrell',
+ 'Telugu',
+ '1995-10-18',
+ ],
+ [
+ 'Alta',
+ 'Bagenal',
+ 'Thai',
+ '1992-06-03',
+ ],
+ [
+ 'Jerrome',
+ 'Fosten',
+ 'Kashmiri',
+ '2000-09-11',
+ ],
+ [
+ 'Derk',
+ 'Emons',
+ 'Ndebele',
+ '1994-04-30',
+ ],
+ [
+ 'Glennis',
+ 'Patmore',
+ 'Swati',
+ '2000-06-05',
+ ],
+]
function breakpoints(stdoutColumns: number) {
- // Large screens - auto
- if (stdoutColumns > 100) {
- return [
- {
- width: 'auto',
- paddingLeft: 2,
- paddingRight: 1,
- },
- {
- width: 'auto',
- paddingRight: 1,
- },
- {
- width: 'auto',
- paddingRight: 1,
- },
- {
- width: 'auto',
- paddingRight: 2,
- },
- ];
- }
+ // Large screens - auto
+ if (stdoutColumns > 100) {
+ return [
+ {
+ width: 'auto',
+ paddingLeft: 2,
+ paddingRight: 1,
+ },
+ {
+ width: 'auto',
+ paddingRight: 1,
+ },
+ {
+ width: 'auto',
+ paddingRight: 1,
+ },
+ {
+ width: 'auto',
+ paddingRight: 2,
+ },
+ ]
+ }
- // Smaller screens
- if (stdoutColumns > 30) {
- return [
- {
- width: '50%',
- paddingLeft: 2,
- paddingRight: 1,
- },
- {
- width: '50%',
- paddingRight: 2,
- },
- {
- width: '50%',
- paddingLeft: 2,
- paddingRight: 1,
- },
- {
- width: '50%',
- paddingRight: 2,
- paddingBottom: 1,
- },
- ];
- }
+ // Smaller screens
+ if (stdoutColumns > 30) {
+ return [
+ {
+ width: '50%',
+ paddingLeft: 2,
+ paddingRight: 1,
+ },
+ {
+ width: '50%',
+ paddingRight: 2,
+ },
+ {
+ width: '50%',
+ paddingLeft: 2,
+ paddingRight: 1,
+ },
+ {
+ width: '50%',
+ paddingRight: 2,
+ paddingBottom: 1,
+ },
+ ]
+ }
- return {
- // Remove responsiveness
- stdoutColumns: 1000,
- columns: [
- {
- width: 'content-width',
- paddingLeft: 2,
- paddingRight: 1,
- },
- {
- width: 'content-width',
- paddingRight: 1,
- },
- {
- width: 'content-width',
- paddingRight: 1,
- },
- {
- width: 'content-width',
- paddingRight: 2,
- },
- ],
- };
+ return {
+ // Remove responsiveness
+ stdoutColumns: 1000,
+ columns: [
+ {
+ width: 'content-width',
+ paddingLeft: 2,
+ paddingRight: 1,
+ },
+ {
+ width: 'content-width',
+ paddingRight: 1,
+ },
+ {
+ width: 'content-width',
+ paddingRight: 1,
+ },
+ {
+ width: 'content-width',
+ paddingRight: 2,
+ },
+ ],
+ }
}
-const renderTable = () => {
- const table = terminalColumns(tableData, breakpoints);
- process.stdout.write(ansiEscapes.clearTerminal + table);
-};
+function renderTable() {
+ const table = tabletron(tableData, breakpoints)
+ process.stdout.write(ansiEscapes.clearTerminal + table)
+}
-process.stdout.on('resize', renderTable);
-renderTable();
+process.stdout.on('resize', renderTable)
+renderTable()
// Keep Node.js from exiting
-promisify(setTimeout)(60 * 60 * 1000);
+promisify(setTimeout)(60 * 60 * 1000)
diff --git a/package.json b/package.json
index 0dceba9..a8cb600 100644
--- a/package.json
+++ b/package.json
@@ -24,12 +24,13 @@
}
},
"scripts": {
+ "prepack": "nyxr build",
"build": "buildkarium",
+ "typecheck": "tsc --noEmit",
"lint": "eslint --ext .ts,.js .",
"lint:fix": "eslint --ext .ts,.js . --fix",
- "typecheck": "tsc --noEmit",
- "pretest": "nyxr build",
- "test": "vitest run --coverage"
+ "test": "vitest run --coverage",
+ "release": "nyxr test && nyxlx changelogen@latest --release && pnpmm publish && git push --follow-tags origin main"
},
"devDependencies": {
"@nyxb/eslint-config": "0.0.53",
diff --git a/tests/terminal-columns.test.ts b/tests/terminal-columns.test.ts
index 72a9aab..66f0f12 100644
--- a/tests/terminal-columns.test.ts
+++ b/tests/terminal-columns.test.ts
@@ -6,11 +6,11 @@ import { beforeAll, describe, expect, test } from 'vitest'
* higher Node.js requirement. Test compiled version
* to verify it works with Node.js 12.
*/
-import terminalColumns, { breakpoints } from '../src'
+import tabletron, { breakpoints } from '../src'
const { blue, bold, underline } = color
-// import terminalColumns, { breakpoints } from '../src';
+// import tabletron, { breakpoints } from '../src';
const loremIpsumShort = 'Lorem ipsum dolor sit amet.'
const loremIpsumLong = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'
@@ -29,7 +29,7 @@ describe('edge cases', () => {
describe('error handling', () => {
test('missing columns', () => {
expect(
- () => terminalColumns(
+ () => tabletron(
[['']],
[100, 200],
),
@@ -38,7 +38,7 @@ describe('edge cases', () => {
test('invalid column', () => {
expect(
- () => terminalColumns(
+ () => tabletron(
[['']],
['100'],
),
@@ -49,23 +49,23 @@ describe('edge cases', () => {
describe('empty table', () => {
test('no table', () => {
// @ts-expect-error test error
- const table = terminalColumns()
+ const table = tabletron()
expect(table).toBe('')
})
test('no rows', () => {
- const table = terminalColumns([])
+ const table = tabletron([])
expect(table).toBe('')
})
test('no columns', () => {
- const table = terminalColumns([[], []])
+ const table = tabletron([[], []])
expect(table).toBe('')
})
})
test('inconsistent rows', () => {
- const table = terminalColumns([
+ const table = tabletron([
['A'],
['B', 'B'],
['C', 'C', 'C'],
@@ -75,7 +75,7 @@ describe('edge cases', () => {
})
test('colored text', () => {
- const table = terminalColumns([
+ const table = tabletron([
[blue('A'.repeat(2))],
['B', bold('B'.repeat(3))],
['C', 'C', underline('C'.repeat(4))],
@@ -85,7 +85,7 @@ describe('edge cases', () => {
})
test('infinite width', () => {
- const table = terminalColumns([
+ const table = tabletron([
['A'.repeat(100)],
['B', 'B'.repeat(100)],
['C', 'C', 'C'.repeat(100)],
@@ -99,7 +99,7 @@ describe('edge cases', () => {
describe('padding', () => {
test('overflowing padding reduction - even', () => {
- const table = terminalColumns(
+ const table = tabletron(
[
[
loremIpsumShort,
@@ -118,7 +118,7 @@ describe('padding', () => {
})
test('overflowing padding reduction - uneven', () => {
- const table = terminalColumns(
+ const table = tabletron(
[
[
loremIpsumShort,
@@ -137,7 +137,7 @@ describe('padding', () => {
})
test('overflowing content with overflowing padding reduction - even', () => {
- const table = terminalColumns(
+ const table = tabletron(
[
[
loremIpsumLong,
@@ -158,7 +158,7 @@ describe('padding', () => {
describe('align', () => {
test('align right', () => {
- const table = terminalColumns(
+ const table = tabletron(
[
[
loremIpsumNewLines,
@@ -177,7 +177,7 @@ describe('align', () => {
describe('process', () => {
test('preprocess', () => {
- const table = terminalColumns(
+ const table = tabletron(
[
[
loremIpsumNewLines,
@@ -194,7 +194,7 @@ describe('process', () => {
})
test('postprocess', () => {
- const table = terminalColumns(
+ const table = tabletron(
[
[
loremIpsumNewLines,
@@ -216,7 +216,7 @@ describe('process', () => {
})
test('postprocess ignores vertical padding', () => {
- const table = terminalColumns(
+ const table = tabletron(
[
[
loremIpsumNewLines,
@@ -238,7 +238,7 @@ describe('process', () => {
describe('static widths', () => {
test('fixed width', () => {
- const table = terminalColumns(
+ const table = tabletron(
[
[loremIpsumShort, loremIpsumLong],
],
@@ -249,7 +249,7 @@ describe('static widths', () => {
})
test('overflowing width', () => {
- const table = terminalColumns(
+ const table = tabletron(
[
[loremIpsumShort, loremIpsumLong],
],
@@ -260,7 +260,7 @@ describe('static widths', () => {
})
test('overflowing rows', () => {
- const table = terminalColumns(
+ const table = tabletron(
[
[loremIpsumShort, loremIpsumShort],
[loremIpsumShort, loremIpsumShort],
@@ -272,7 +272,7 @@ describe('static widths', () => {
})
test('overflowing width with padding', () => {
- const table = terminalColumns(
+ const table = tabletron(
[
[loremIpsumShort, loremIpsumLong],
],
@@ -295,7 +295,7 @@ describe('static widths', () => {
describe('percent widths', () => {
test('50% 50%', () => {
- const table = terminalColumns(
+ const table = tabletron(
[
[loremIpsumLong, loremIpsumLong],
],
@@ -309,7 +309,7 @@ describe('percent widths', () => {
})
test('50% 50% with padding', () => {
- const table = terminalColumns(
+ const table = tabletron(
[
[loremIpsumLong, loremIpsumLong],
],
@@ -331,7 +331,7 @@ describe('percent widths', () => {
})
test('70% 30% with different content lengths', () => {
- const table = terminalColumns(
+ const table = tabletron(
[
[loremIpsumLong, loremIpsumLong],
[loremIpsumLong, loremIpsumShort],
@@ -343,7 +343,7 @@ describe('percent widths', () => {
})
test('100% 100% with padding', () => {
- const table = terminalColumns(
+ const table = tabletron(
[
[loremIpsumLong, loremIpsumLong],
],
@@ -369,7 +369,7 @@ describe('percent widths', () => {
describe('content-width', () => {
test('content-width with fixed width', () => {
- const table = terminalColumns(
+ const table = tabletron(
[
[loremIpsumLong, loremIpsumLong],
[loremIpsumLong, loremIpsumShort],
@@ -381,7 +381,7 @@ describe('content-width', () => {
})
test('content-width with padding', () => {
- const table = terminalColumns(
+ const table = tabletron(
[
[loremIpsumLong, loremIpsumLong],
],
@@ -403,7 +403,7 @@ describe('content-width', () => {
})
test('content-width with overflowing', () => {
- const table = terminalColumns(
+ const table = tabletron(
[
[loremIpsumNewLines, loremIpsumNewLines, loremIpsumNewLines],
],
@@ -432,7 +432,7 @@ describe('content-width', () => {
describe('auto', () => {
test('event split', () => {
- const table = terminalColumns(
+ const table = tabletron(
[
[
loremIpsumShort,
@@ -451,7 +451,7 @@ describe('auto', () => {
})
test('event split - many', () => {
- const table = terminalColumns(
+ const table = tabletron(
[
[
loremIpsumShort,
@@ -488,7 +488,7 @@ describe('auto', () => {
})
test('mutli-row', () => {
- const table = terminalColumns(
+ const table = tabletron(
[
[loremIpsumShort, loremIpsumNewLines, loremIpsumNewLines],
[loremIpsumLong, loremIpsumLong, loremIpsumShort],
@@ -500,7 +500,7 @@ describe('auto', () => {
})
describe('breakpoints', () => {
- const getTable = () => terminalColumns(
+ const getTable = () => tabletron(
[
[loremIpsumLong, loremIpsumLong],
[loremIpsumLong, loremIpsumLong],
@@ -540,7 +540,7 @@ describe('breakpoints', () => {
})
describe('custom breakpoints function', () => {
- const getTable = () => terminalColumns(
+ const getTable = () => tabletron(
[
[loremIpsumLong, loremIpsumLong],
[loremIpsumLong, loremIpsumLong],