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

riot-grid2

v3.0.2

Published

Version 2 of Riot Grid - with optimised columns and new api

Downloads

20

Readme

Build Status Coverage Status

riot-grid Version 2. With new api and optimised for high column numbers.

The version is for use with Riot.js v3.*

Please see Riot2 branch for a riot v2 version

Demo

Demo is available here - http://crisward.github.io/riot-grid2/

Installing

npm install riot-grid2 --save-dev

Usage

<grid2 data="{data}" columns="{columns}" height="{700}" tabindex="1" click="{handleClick}"></grid2>

Attributes

|name |Description |------ |------ |data |collection of data (array of objects) |columns |column description object (see below) |height |visible height of the grid, in pixels. |tabindex |need to make the grid active for keyboard use |click |callback when a row is clicked. Returns an array of selected rows. Last element in the array is the last selected.

Columns

The columns attrubute is an object which describes the data. The following keys can be used.

|name |Type | Required |Description |------ |----- |------ |------ |label |string |yes |The label which appears in the table header |field |string |yes |The name of the field within your data object to display in this column |width |int |yes |Width in pixels of this column |fixed |bool |no |If this column should be fixed, or allowed to scroll horizontally |class |string or array|no|CSS class(es) to set on cells of this column, in addition to the automatic .cell / .headercell |tag |string |no |Name of tag you would like to use in the column (see below)

Example

var columns = [
    {label:'#',field:'id',width:50,fixed:true,class:'identifier'},
    {label:'name',field:"name1",width:120,fixed:true,class:'name primary'},
    {label:'name2',field:"name2",width:120,class:['name','secondary']},
    {label:"popularity",field:"popularity",width:200,tag:"image-cell"}
]

Custom tags

Tags that are passed to the column reference will be passed the following attributes

|name | Type |Description |------ |------ |------ |cell |object |An object which decribed the grid cell. It containts the keys left top width active tag text ridx col ridx is the row index, col is the column information you defined in columns including any custom keys you add. |val |(any) |The value of the field passed in. Commonly the value is a string, but it may also be an object that the tag will destructure. |data |array |The data passed into the grid

Examples

<image-cell>
	<img src="{opts.val}" style="width:{opts.cell.width}px" />
</image-cell>

<name-cell>
    <span>{opts.val.last}, {opts.val.first}</span>
</name-cell>

About

Riot-grid helped to create grids with millions of rows, but slowed down dramatically with lots of colums. Riot-grid2 is an attempt to resolve this limitation.

It works by rendering individual cells, removing them from the dom or re-using them when they are no longer visible. Each cell is absolutelly positioned. Read on for a more details on how it acheives this.

Min Dom changes

On first render

  • Go through all cells and add those which are in the visible area

On scroll

  • Go through current cells and work out which ones should be removed
  • Store the keys of these cells in an 'unused' array
  • Go though all cells and find those which are current not visible but should be
  • Add new cells into the unused slots
  • If there are more new cells than unusued, add more (for grid resizes)

Features to add

Keyboard

  • down, select next, scroll to active
  • up, select previous, scroll to active
  • cmd+down, select next, in addition to last selected
  • cmd+up, select previous, in addition to last selected
  • shift click, select all between last select and clicked row

General

  • make header 'edges' draggable to resize columns (perhaps make optional)

Callbacks

  • on-dblclick - callback with array of selected rows and last double clicked row

License

(The MIT License)

Copyright (c) 2015 Cris Ward

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.