Skip to content

Commit

Permalink
fix: rename makeTable to printTable
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Sep 23, 2024
1 parent c392b11 commit 4d7a229
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions examples/basic.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ansis from 'ansis'
import terminalLink from 'terminal-link'

import {TableProps, makeTable} from '../src/index.js'
import {TableProps, printTable} from '../src/index.js'

const data = [
{
Expand Down Expand Up @@ -40,4 +40,4 @@ const basic: TableProps<(typeof data)[number]> = {
verticalAlignment: 'center',
}

makeTable(basic)
printTable(basic)
4 changes: 2 additions & 2 deletions examples/multiple.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {TableProps, makeTables} from '../src/index.js'
import {TableProps, printTables} from '../src/index.js'

const description =
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'
Expand Down Expand Up @@ -110,7 +110,7 @@ const projectsTable: TableProps<(typeof projects)[number]> = {
},
}

makeTables([employeesTable, stocksTable, projectsTable], {
printTables([employeesTable, stocksTable, projectsTable], {
alignItems: 'center',
columnGap: 1,
margin: 1,
Expand Down
6 changes: 3 additions & 3 deletions examples/orientation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {makeTable} from '../src/index.js'
import {printTable} from '../src/index.js'

const description =
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'
Expand All @@ -21,7 +21,7 @@ const data = [
},
]

makeTable({
printTable({
columns: ['item', 'description', 'url'],
data,
headerOptions: {
Expand All @@ -33,7 +33,7 @@ makeTable({
titleOptions: {bold: true},
})

makeTable({
printTable({
columns: ['item', 'description', 'url'],
data,
headerOptions: {
Expand Down
6 changes: 3 additions & 3 deletions examples/overflow.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {makeTable} from '../src/index.js'
import {printTable} from '../src/index.js'

const description =
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'
Expand All @@ -24,7 +24,7 @@ const data = [
},
]

makeTable({
printTable({
columns: ['id', 'name', 'age', 'description'],
data,
headerOptions: {
Expand All @@ -36,7 +36,7 @@ makeTable({
titleOptions: {bold: true},
})

makeTable({
printTable({
columns: ['id', 'name', 'age', 'description'],
data,
headerOptions: {
Expand Down
4 changes: 2 additions & 2 deletions examples/sf-specific/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {TableProps, makeTable} from '../../src'
import {TableProps, printTable} from '../../src'

const deployResult = [
{
Expand Down Expand Up @@ -969,4 +969,4 @@ const deploy: TableProps<(typeof deployResult)[number]> = {
verticalAlignment: 'center',
}

makeTable(deploy)
printTable(deploy)
4 changes: 2 additions & 2 deletions examples/sf-specific/versions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {makeTable} from '../../src'
import {printTable} from '../../src'

const versions = [
{
Expand Down Expand Up @@ -838,7 +838,7 @@ const versions = [
},
]

makeTable({
printTable({
borderColor: 'greenBright',
borderStyle: 'headers-only-with-underline',
columns: ['version', 'channel', 'location'],
Expand Down
10 changes: 5 additions & 5 deletions examples/sort-and-filter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {makeTable} from '../src/index.js'
import {printTable} from '../src/index.js'

const data = [
{age: 25, id: '10245', name: 'Bob'},
Expand All @@ -9,7 +9,7 @@ const data = [
{age: 35, id: '30345', name: 'Chris'},
]

makeTable({
printTable({
columns: ['id', 'name', 'age'],
data,
headerOptions: {
Expand All @@ -21,7 +21,7 @@ makeTable({
titleOptions: {bold: true},
})

makeTable({
printTable({
columns: ['id', 'name', 'age'],
data,
headerOptions: {
Expand All @@ -33,7 +33,7 @@ makeTable({
titleOptions: {bold: true},
})

makeTable({
printTable({
columns: ['id', 'name', 'age'],
data,
headerOptions: {
Expand All @@ -45,7 +45,7 @@ makeTable({
titleOptions: {bold: true},
})

makeTable({
printTable({
columns: ['id', 'name', 'age'],
data,
filter: (record) => record.age > 25,
Expand Down
4 changes: 2 additions & 2 deletions examples/styles.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {makeTable} from '../src/index.js'
import {printTable} from '../src/index.js'
import {BORDER_STYLES} from '../src/skeletons.js'

const data = [
Expand All @@ -20,7 +20,7 @@ const data = [
]

for (const borderStyle of BORDER_STYLES) {
makeTable({
printTable({
borderStyle,
columns: ['id', {key: 'name', name: 'First Name'}, 'age'],
data,
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export {makeTable, makeTables} from './table.js'
export type {TableProps} from './types.js'
export {printTable, printTables} from './table.js'
export type {ScalarDict, TableProps} from './types.js'
4 changes: 2 additions & 2 deletions src/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ export function Skeleton(props: React.PropsWithChildren & {readonly height?: num
* Renders a table with the given data.
* @param options see {@link TableProps}
*/
export function makeTable<T extends ScalarDict>(options: TableProps<T>): void {
export function printTable<T extends ScalarDict>(options: TableProps<T>): void {
const instance = render(<Table {...options} />)
instance.unmount()
}
Expand All @@ -347,7 +347,7 @@ function Container(props: ContainerProps) {
)
}

export function makeTables<T extends ScalarDict[]>(
export function printTables<T extends ScalarDict[]>(
tables: {[P in keyof T]: TableProps<T[P]>},
options?: Omit<ContainerProps, 'children'>,
): void {
Expand Down
8 changes: 4 additions & 4 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,16 @@ export type TableProps<T extends ScalarDict> = {
* ]
*
* // sort the name column in ascending order
* makeTable({data, sort: {name: 'asc'}})
* printTable({data, sort: {name: 'asc'}})
*
* // sort the name column in descending order
* makeTable({data, sort: {name: 'desc'}})
* printTable({data, sort: {name: 'desc'}})
*
* // sort by name in ascending order and age in descending order
* makeTable({data, sort: {name: 'asc', age: 'desc'}})
* printTable({data, sort: {name: 'asc', age: 'desc'}})
*
* // sort by name in ascending order and age in descending order using a custom sort function
* makeTable({data, sort: {name: 'asc', age: (a, b) => b - a}})
* printTable({data, sort: {name: 'asc', age: (a, b) => b - a}})
* ```
*/
sort?: Sort<T>
Expand Down

0 comments on commit 4d7a229

Please sign in to comment.