npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

retro-table

v0.1.36

Published

A reusable **React + MUI** data table component that generates a fully functional admin-style table with:

Readme

retro-table

A reusable React + MUI data table component that generates a fully functional admin-style table with:

  • ✅ Pagination
  • ✅ Sorting
  • ✅ Searching
  • ✅ CRUD action hooks (Add, View, Edit, Delete)
  • ✅ Custom actions and cell renderers
  • ✅ TypeScript support

🚀 Installation

# install package
yarn add retro-table

# install required peer dependencies
yarn add @mui/material @emotion/react @emotion/styled

📦 Usage

import React from "react";
import { RetroAdminTable, RetroTableFieldType } from "retro-table";

const fields = [
  {
    key: "id",
    heading: "#",
    tableFieldType: RetroTableFieldType.SL_NO,
    formFieldType: 0,
    tableCellOption: { alignment: { header: "center", cell: "center" } }
  },
  {
    key: "name",
    heading: "Name",
    tableFieldType: RetroTableFieldType.TEXT,
    formFieldType: 0,
    shouldSearch: true,
    shouldSort: true
  },
  {
    key: "avatar",
    heading: "Avatar",
    tableFieldType: RetroTableFieldType.IMAGE,
    imageType: "avatar"
  },
  {
    key: "status",
    heading: "Status",
    tableFieldType: RetroTableFieldType.ENUM,
    options: [
      { key: "active", value: "Active" },
      { key: "inactive", value: "Inactive" }
    ]
  }
];

const data = [
  { id: 1, name: "Alice", avatar: "/a.png", status: "active" },
  { id: 2, name: "Bob", avatar: "/b.png", status: "inactive" }
];

export default function Page() {
  return (
    <RetroAdminTable
      fields={fields}
      data={data}
      loading={false}
      page={1}
      total={2}
      rowsPerPage={10}
      rowsPerPageOptions={[5, 10, 25]}
      onPageChange={(p) => console.log("page", p)}
      onRowsPerPageChange={(r) => console.log("rowsPerPage", r)}
      onSort={(field, sortType) => console.log("sort", field, sortType)}
      onSearch={(q) => console.log("search", q)}
      shouldShowViewDetails
      shouldEdit
      shouldDelete
    />
  );
}

⚙️ Props Reference

RetroTableProps

| Prop | Type | Default | Description | Example | | --------------------------- | ---------------------------------------------------------------- | ------------ | ------------------------------------------------------------------------------------------- | --------------------------------------------------------- | | fields | RetroTableField[] | Required | Defines the table columns. Each field specifies heading, type, search/sort options, styles. | See Field Definition | | data | object[] | [] | Array of row objects. Each object’s keys must match field.key. | [ { id:1, name:"Alice" } ] | | loading | boolean | false | Whether to show loading state. | true | | page | number | 1 | Current page number (controlled). | 1 | | total | number | 0 | Total number of rows (for pagination). | 120 | | rowsPerPage | number | 10 | Number of rows per page. | 25 | | rowsPerPageOptions | number[] | [5,10,25] | Dropdown options for rows per page. | [10, 25, 50] | | paginate | boolean | true | Enable/disable pagination controls. | false | | onPageChange | (page: number) => void | — | Callback when page changes. | (p) => setPage(p) | | onRowsPerPageChange | (rowsPerPage: number) => void | — | Callback when rows per page changes. | (n) => setRpp(n) | | onSort | (field: RetroTableField, sortType: RetroTableSortType) => void | — | Called when column is sorted. | (f, s) => console.log(f.key, s) | | onSearch | (search: any) => void | — | Called when search/filter is triggered. | (q) => console.log(q) | | shouldShowViewDetails | boolean | false | Show/hide default view details action. | true | | shouldEdit | boolean | false | Show/hide default edit action. | true | | shouldDelete | boolean | false | Show/hide default delete action. | true | | viewConfig | { shouldShow?, onView?, viewIcon? } | — | Customize per-row view behavior. | { shouldShow: (r)=>true, onView: alert } | | editConfig | { shouldShow?, onEdit?, editIcon? } | — | Customize edit action. | { onEdit: (row)=>... } | | deleteConfig | { shouldShow?, onDelete?, deleteIcon? } | — | Customize delete action. | { onDelete: (row)=>... } | | customActions | Array<{ shouldShow, onCustomAction, icon? }> | [] | Add extra buttons per row. | See example below | | cellBuilder | (field: any, data: any) => React.ReactNode | — | Global override for cell rendering. | (f, row) => <b>{row[f.key]}</b> | | error | string | — | Display error message above table. | "Failed to load data" |

Field Definition (RetroTableField)

| Field Prop | Type | Values | Description | | ------------------------------ | ---------------------------------- | ---------------------------------------------------------------------------------- | -------------------------------------- | | key | string | — | Key of data in row objects. | | heading | string | — | Column header text. | | tableFieldType | RetroTableFieldType | TEXT, IMAGE, LINK, ACTION, ENUM, CUSTOM, MAP_POINT, ARRAY, SL_NO | Controls rendering style. | | formFieldType | RetroFormFieldType | Depends on your forms | For mapping with forms. | | imageType | "avatar" \| "normal" | "avatar" or "normal" | For IMAGE type columns. | | shouldSearch | boolean | — | If true, field participates in search. | | shouldSort | boolean | — | If true, field is sortable. | | options | { key, value }[] | — | Used for ENUM fields. | | onClick | (field, data) => void | — | Custom handler when cell clicked. | | cellBuilder | (field, data) => React.ReactNode | — | Per-field custom renderer. | | mapConfig | RetroMapConfig | — | Used for map-based fields. | | tableCellOption.alignment | { header?, cell? } | "left" \| "right" \| "center" \| "justify" \| "inherit" | Alignment of header & cell. | | tableCellOption.cellStyle | SxProps<Theme> | — | Custom MUI sx for cells. | | tableCellOption.headerStyle | SxProps<Theme> | — | Custom MUI sx for headers. |

🎨 Styling

  • Pass MUI sx props in tableCellOption.cellStyle and tableCellOption.headerStyle.

  • Example:

    tableCellOption: {
      headerStyle: { bgcolor: "grey.200", fontWeight: "bold" },
      cellStyle: { color: "primary.main" }
    }

🔌 TypeScript Support

All types are included. Import them for strict typing:

import {
  RetroTableProps,
  RetroTableField,
  RetroTableFieldType
} from "retro-table";

⚡ Examples

Custom Cell Renderer

{
  key: "price",
  heading: "Price",
  tableFieldType: RetroTableFieldType.TEXT,
  cellBuilder: (field, row) => <strong>${row.price.toFixed(2)}</strong>
}

Custom Action

const customActions = [
  {
    shouldShow: (row) => row.status === "active",
    onCustomAction: (row) => console.log("custom action", row),
    icon: () => <MyIcon />
  }
];

⚠️ Troubleshooting

Module not found: Can't resolve 'retro-table'

  • Ensure node_modules/retro-table/dist exists and package.json has correct "main", "module", "exports" entries.

  • If recently republished, clear cache:

    rm -rf node_modules .next yarn.lock
    yarn install
    yarn dev