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

free-table

v0.1.14

Published

Fully customisable react table with the ablity to implement your own data manipulation or ui. You can change anything in representation layer or introduce new data manipulation features without loosing the built-in functionalities.

Downloads

5

Readme

Free Table

Fully customisable react table with the ablity to implement your own data manipulation or ui. You can change anything in representation layer or introduce new data manipulation features without loosing the built-in functionalities.

Installation

$ yarn add free-table

Usage

For a basic html table you need a data and a columns collection to be passed to <FreeTable />.

import React from "react";
import FreeTable from "free-table"

const data = [
  { id: '1', name: 'John Doe', phone: '1234' },
  { id: '2', name: 'Alex Smith', phone: '5678' }
]

const columns = [
  { id: 'c1', accessor: 'name', label: 'Name' },
  { id: 'c2', accessor: 'phone', label: 'Phone' },
]

export default () => (
  <FreeTable
    data={data}
    columns={columns}
  />
);

Edit gazdagergo/free-table: examples

Features

To use features pass a built-in or a self-made custom function to the options prop:

Built-in features

applyFilter()

Renders an input box in each column header and filters the rows based on substring-comparison.

import { applyFilter }, FreeTable from 'free-table'

...

  <FreeTable
    data={data}
    columns={cols}
    options={[
      applyFilter()
    ]}
  />

Edit gazdagergo/free-table: examples

applyGroups({ groups, groupData? })

It is not equivalent to the common groupBy behaviours. All the data rows been rendered but been groupped by a certain criteria. In the below example it is the city. You can pass custom groupping function via the optional groupData property. By default it groups by string matching with a certain field (city) as defined in groups.

import React from "react";
import "./styles.css";
import FreeTable, { applyGroups } from "free-table";

export default () => {
  const data = [
    { id: "1", name: "John Doe", phone: "1234", city: "Stockholm" },
    { id: "2", name: "Alex Smith", phone: "5678", city: "Stockholm" },
    { id: "3", name: "Anna Fox", phone: "91011", city: "Berlin" },
    { id: "4", name: "Ellen Wood", phone: "1314", city: "Stockholm" },
    { id: "5", name: "Guy Richie", phone: "1516", city: "Berlin" },
  ];


  const columns = [
    { id: "c1", accessor: "name", label: "Name" },
    { id: "c2", accessor: "phone", label: "Phone" },
    { id: "c3", accessor: "city", label: "City" },
  ];

  const groups = [
    { id: "g1", label: "Users from Stockholm", city: "Stockholm" },
    { id: "g1", label: "Users from Berlin", city: "Berlin" },
  ]

  return (
    <div className="App">
      <h1>Free Table</h1>
      <h3>Groups example</h3>
      <FreeTable
        columns={columns}
        data={data}
        options={[
          applyGroups({ groups })
        ]}
      />
    </div>
  );
};

Edit gazdagergo/free-table: examples

applyCustomField({ id, Component, HeadComponent, colIndex })

Add a custom column to your table.

import React from "react";
import FreeTable, { applyCustomField } from "free-table";

export default () => {
  const data = [
    { id: "u1", name: "John Doe", phone: "1234" },
    { id: "u2", name: "Alex Smith", phone: "5678" }
  ];

  const columns = [
    { id: "c1", accessor: "name", label: "Name" },
    { id: "c2", accessor: "phone", label: "Phone" }
  ];

  const MyCustomField = () => (
    <button style={{ cursor: 'pointer' }}>I'm custom</button>
  )

  return (
    <div className="App">
      <h1>Free Table</h1>
      <h3>Custom Field example</h3>
      <FreeTable
        columns={columns}
        data={data}
        options={[
          applyCustomField({
            id: 'cf',
            Component: MyCustomField,
            HeadComponent: () => <th>Custom</th>,
            colIndex: 3
          })
        ]}
      />
    </div>
  );
};

Edit gazdagergo/free-table: examples