JSPM

inquirer-table

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 18
  • Score
    100M100P100Q34442F
  • License MIT

A table prompt for Inquirer.js.

Package Exports

  • inquirer-table
  • inquirer-table/package.json

Readme

inquirer-table

NPM

A table prompt for Inquirer.js.

Interactive table component for command line interfaces.

Installation

yarn npm pnpm
yarn add inquirer-table npm install inquirer-table pnpm add inquirer-table

Usage

import { table, type TableColumn } from 'inquirer-table';

interface Post {
  userId: number;
  id: number;
  title: string;
  body: string;
}

const posts: Post[] = [
  {
    userId: 1,
    id: 1,
    title:
      'sunt aut facere repellat provident occaecati excepturi optio reprehenderit',
    body: 'quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto'
  }
];

const columns: TableColumn<Post>[] = [
  {
    header: 'ID',
    accessorKey: 'id'
  },
  {
    header: 'User ID',
    accessorKey: 'userId'
  },
  {
    header: 'Title',
    accessorKey: 'title'
  },
  {
    header: 'Body',
    accessorKey: 'body'
  }
];

const answer = await table({
  data: posts,
  columns
});

See other usage examples

Options

Property Type Required Description
data TableItem[] Yes Data to be shown in the table.
columns TableColumn<TableItem>[] Yes Table columns.
pageSize number No Page size for pagination. Defaults to 5.
multiple boolean No If true, multiple selection is allowed. Defaults to false.
selectable boolean No If true, table rows become selectable. Defaults to false.
abortController AbortController No If an AbortController is provided, the prompt can be cancelled by pressing backspace. Canceling Prompt
tableOptions Omit<CliTable.TableConstructorOptions, 'head' | 'colWidths' | 'colAligns'> No cli-table3 options.
renderHeader (params: UseTablePaginationReturn & UseCliTableBaseOptions<TableItem>) => string | null | undefined No Render the table header.
renderFooter (params: UseTablePaginationReturn & UseCliTableBaseOptions<TableItem>) => string | null | undefined No Render the table footer.
renderFigureCell (params: RenderFigureCellParams) => CliTable.Cell No Render figure cell.
renderActiveCell (value: CliTable.CellValue) => CliTable.CellValue No Render the cell where the pointer is active.
renderSelectedCell (value: CliTable.CellValue) => CliTable.CellValue No Render the selected cell.
renderUnSelectedCell (value: CliTable.CellValue) => CliTable.CellValue No Render the unselected cell.