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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@githubocto/flat-ui

v0.14.1

Published

Welcome friends! **flat-ui** is a React component that will render your flat dataset (an array of objects) in a table view:

Downloads

384

Readme

flat-ui

Welcome friends! flat-ui is a React component that will render your flat dataset (an array of objects) in a table view:

screenshot

It will...

  • auto-detect types
  • show a distribution of each quantitative column
  • calculate a diff between the main dataset and a diffData dataset
  • give more information about a hovered row & column
  • allow the user to...
    • filter each column
    • sort by any column
    • sticky any column to the left
    • download the filtered & sorted data (csv or json)
    • cycle through the diffs, scrolling to each changed row

Usage

Install using npm or yarn:

yarn add @githubocto/flat-ui

Basic usage:

import { Grid } from '@githubocto/flat-ui';

const MyComponent = () => {
  const data = [{ column1: 123 }, { column1: 234 }];

  return <Grid data={data} />;
};

Props

data

array

Your dataset, formatted as an array of objects, where each object is a row in the table.

Optional props

diffData

array

A modified version of your main dataset, formatted as an array of objects, where each object is a row in the table. The table will show "differences" between this dataset and the main dataset:

  • added lines
  • removed lines
  • modified cells

metadata

object

column names as keys and descriptions as values.

canDownload

boolean

Whether or not the table provides "download csv" and "download json" buttons.

downloadFilename

string

The name of the downloaded CSV or JSON file (without extension).

defaultFilters

object

column names as keys, with filter values as values:

  • string for text columns
  • array of numbers for quantitative columns (numbers or dates)

The user can interact with the table and update the filters, but the table will use the default filters when defaultFilters or data changes.

defaultSort

string

The name of the column you want the table to initialize sorting by. The user can interact with the table and update the sort, but the table will use the default sort when defaultSort or data changes.

defaultStickyColumnName

string

The name of the column you want the table to initialize stickied to the left. The user can interact with the table and update the sticky column, but the table will use the default sticky column when defaultStickyColumnName or data changes.

onChange

function

A callback function whose first parameter is the grid state:

{
  stickyColumnName: "",
  columnNames: ["", ""],
  filteredData: [{}, {}],
  diffs: [{}, {}], // where __status__ is "new"|"old"|"modified"
  filters: {},
  sort: ["column name", "asc" or "desc"],
  schema: {}, // column names : array|short-array|category|number|date
}

isEditable

boolean

Whether or not to allow the user to edit the table.

onEdit

(newData: any[]) => void

A callback when the user edits the data with the updated dataset. This is intended to be used as a controlled component, where the parent component handles data changes.

Developing locally

To get the example up & running:

yarn
yarn start

and also start the example server:

cd example
yarn
yarn start