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

@braniac/virtual-grid

v0.1.8

Published

``` <Table title={title} columns={columns} header data={data} utility={{ optionalButton:[ (i)=>{ return <React.Fragment key={`optional.ele.${i}`}> <IconButton edge="star

Downloads

18

Readme

Table Wrapper for React Virtualized

Usage

<Table
    title={title}
    columns={columns}
    header
    data={data}
    utility={{
        optionalButton:[
            (i)=>{
                return <React.Fragment key={`optional.ele.${i}`}>
                    <IconButton edge="start" className={classes.icon} color="inherit" onClick={close} aria-label="Close">
                        <CloseIcon />
                    </IconButton>
                </React.Fragment>
            }
        ],
        ExportData:(e)=>{
            return true;
        },
        onSearch:(e)=>{ return true;},
        onSort:(o)=>{
            return true;
        },
        onFilter:(o)=>{
            return true;
        }
    }}
    rowHeight={55}
    fixedCols={0}
    minColumnWidth={250}
    actions={{
        onUpdateApply: ({rowIndex,data:value}) => {

            return true;
        },
        onSelectRow:()=>{
            return true;
        },
        onAddRow:({rowIndex,data:value})=>{

            return true;
        }
    }}
/>

Table Props

| Property | Type |Allowed Values| Description | |---|---|---|---| |tilte|string|element|any| Table Header Title| |columns|array|array of column definition objects| Array of column definitions| |header|boolean|true|false|Header visibility| |data|array|array of objects|Array of data objects| |utility|object|utility definition|Table utility configuration object| |rowHeight|number|any|Table Row Height| |fixedCols|number|any >= 0|Frozen column count from left| |minColumnWidth|number|any|Minimum column width| |actions|object|action definition|Table actions column configurations|

Column Definition

{    
    label: 'Fat (g)',
    dataKey: 'fat',
    numeric: true,
    visible:true,
    width:200,
    align:"right",
    displayFormat:{
      thousandSeparator:true,
      precision:2,
      suffix:"%",
      currency:{
        derived:true,
        key:"calories",
        frmt:(data)=>{return {id:data,symbol:"LKR",prefixSymbol:false}}
      }
    }
    ,
    filter:{
      enable:true,
      type:"number"
    },
    editor:{
      editable:true,
      type:'number'
    }
}

|Property|Type|Allowed Values|Definition| |---|---|---|---| |label|string|any|| |dataKey|string|any|| |numeric|boolean|true|false|| |visible|boolean|true|false|| |width|number|any > minColumnWidth|| |align|text|left|right|center|| |displayFormat|object|display format definition|Optional display format definition for numeric columns| |filter|object|filter definition|| |editor|object|editor definition||

Display Format Definition

|Property|Type|Allowed Values|Definition| |---|---|---|---| |thousandSeparator|boolean|true|false|| |precision|number|any > 0|| |suffix|string|any|Optional suffix for the formatter| |prefix|string|any|Optional prefix for the formatter| |currency|object|currency format definition|Optional currency format definition|

Currency definition

|Property|Type|Allowed Values|Definition| |---|---|---|---| |derived|boolean|true|false|| |key|string|any|| |frmt|function|function should return {symbol:"$",prefixSymbol:true} format||

Filter definition

|Property|Type|Allowed Values|Definition| |---|---|---|---| |enable|boolean|true|false|| |type|string|date|boolean|number|text||

Editor definition

|Property|Type|Allowed Values|Definition| |---|---|---|---| |editable|boolean|true|false|| |type|string|date|boolean|number|text||

Utility Definition

{
    optionalButton:[
                (i)=>{
                    return <React.Fragment key={`optional.ele.${i}`}>
                        <IconButton>
                            <CloseIcon />
                        </IconButton>
                    </React.Fragment>
                }
            ],
    ExportData:(e)=>{
        return true;
    },
    onSearch:(e)=>{ return true;},
    onSort:(o)=>{
        return true;
    },
    onFilter:(o)=>{
        return true;
    }
}

|Property|Type|Allowed Values|Definition| |---|---|---|---| |optionalButton|array|array of functions should return element|| |ExportData|function|function should return boolean || |onSearch|function|function should return boolean|| |onSort|function|function should return boolean|| |onFilter|function|function should return boolean||

####Actions definition

{
    onUpdateApply: ({rowIndex,data:value}) => {
        return true;
    },
    onSelectRow:()=>{
        return true;
    },
    onAddRow:({rowIndex,data:value})=>{
        return true;
    },
    onDeleteRow:({rowIndex,data:value})=>{
        return true;
    },
    renderer:{
            EditRow:(...),
            AddRow:(...),
            DefaultRow:(...)
        }
}

|Property|Type|Allowed Values|Definition| |---|---|---|---| |onUpdateApply|function|function should return boolean|| |onSelectRow|function|function should return boolean|| |onAddRow|function|function should return boolean|| |onDeleteRow|function|function should return boolean|| |renderer|object|action renderer definition|Optional render definition to override defaults|

Action Renderer Definition

|Property|Type|Allowed Values|Definition| |---|---|---|---| |EditRow|function|function returning a element|| |AddRow|function|function returning a element|| |DefaultRow|function|function returning a element||

Example


const cols = [

  {
    label: 'Dessert',
    dataKey: 'dessert',
    visible:true,
    width:60,
    sortable:true,
    filter:{
      enable:true,
      type:"text"
    },
    editor:{
      editable:false,
      type:'text'
    }
  },
  {
    label: 'Calories (g)',
    dataKey: 'calories',
    numeric: true,
    visible:true,
    sortable:true,
    width:200,
    flexGrow: 1.0
  },
  {
    label: 'Fat (g)',
    dataKey: 'fat',
    numeric: true,
    visible:true,
    flexGrow:1,
    width:200,
    align:"right",
    displayFormat:{
      thousandSeparator:true,
      precision:2,
      suffix:"%",
      currency:{
        derived:true,
        key:"calories",
        frmt:(data)=>{return {id:data,symbol:"LKR",prefixSymbol:false}}
      }
    }
    ,
    filter:{
      enable:true,
      type:"number"
    },
    editor:{
      editable:true,
      type:'number'
    }
  }
];


const data = Array.from({length: 600}, (x,i) => {return  cols.reduce((acc,{dataKey,type,numeric=false},i)=>{

  if(type && type === "boolean")
    acc[dataKey] = Math.floor(Math.random() * Math.floor(3)) %2 === 0 ;
  else
    acc[dataKey] = numeric ? Math.floor(Math.random() * Math.floor(3000)) + 1 : Math.random().toString(36).substring(2);
  return acc;
},{})});

const Sample = (props)=>{
    return  <Table
    title={"Test Table"}
    columns={cols}
    header
    data={data}
    utility={{
        optionalButton:[
            (i)=>{
                return <React.Fragment key={`optional.ele.${i}`}>
                    <IconButton>
                        <CloseIcon />
                    </IconButton>
                </React.Fragment>
            }
        ],
        ExportData:(e)=>{
            return true;
        },
        onSearch:(e)=>{ return true;},
        onSort:(o)=>{
            return true;
        },
        onFilter:(o)=>{
            return true;
        }
    }}
    rowHeight={55}
    fixedCols={0}
    minColumnWidth={250}
    actions={{
        onUpdateApply: ({rowIndex,data:value}) => {
    
            return true;
        },
        onSelectRow:()=>{
            return true;
        },
        onAddRow:({rowIndex,data:value})=>{
    
            return true;
        }
    }}
    />
}