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

dable

v1.0.1

Published

web component that converts json or csv to a pretty and flexible html table

Downloads

8

Readme

Published on webcomponents.org

Web Table

Converts data to a html table. It is

  • very tiny (2kb min.js.gzip) with no dependency
  • web component and easy to use: import the js file and use <web-table> tag
  • sortable
  • searchable (filterable)
  • filter out unwanted columns or/and rename columns
  • flexible data input: csv, json, records, arrays
  • configurable by user or by programmer
  • Setting ui and battery included

DEMO:

CDN

<script src="https://cdn.jsdelivr.net/gh/alan-khosro/web-table/dist/web-table.min.js" type="module"></script>

Simple Usage

Import library and initiate the table with a data url to populate it

<script src="../dist/web-table.js" type="module"></script>

<web-table 
	url="./cash_flow_components.json" 
	datatype="records"
></web-table>

User can use its built-in Settings ui to tweak irs colors, data source, etc.

options

you can pass optional attributes:

  • datatype:
    • records (default): array of object [{col1: "val1", col2: 2},...]
    • csv: to read csv file
    • arrays: array of array [["col1", "col2"],["row11", "row12"],...]
    • headless: array of array with no column names
  • data source:
    • can be a url, feeding data with js, or local file
  • columns:
    • provide a list of columns that you want to show
    • the rest of columns in your data will be discarded
    • for headless array, provide column indices: [0, 3]
    • it will show data in the order of columns you provide
    • use comma to separate columns when using inline attributes (see the below example)
  • renames:
    • if you need to rename your column names, provide new names
  • accent:
    • to change default accent color, provide rgb numbers like accent="150,200,250"
  • color:
    • to change default color, provide rgb numbers like color="100,100,100"
  • delim:
    • if providing datatype="csv" and delimeter is not comma, provide the seperator
<script src="../dist/web-table.min.js" type="module"></script>

<web-table 
	url="./owid-covid-latest.csv" 
	datatype="csv"
	delim=","
	accent="255, 100, 100",
	columns="location,total_cases_per_million,new_cases_smoothed,total_deaths_per_million,new_deaths_smoothed"
	renames="loc,case_rate,new_cases,deaths_rate,new_deaths"
></web-table>

Advanced Usage

You can initiate it with no data url and then call its populate method in your js file. It is useful for advanced use case when you need to prepare your data before populating the table.

Please notice that the webcomponent has no url when you are populating data through js Please notice the second variable is an object that defines the options

<simple-table></simple-table>

TODO features: YAGNI

  • [ ] user settings to save table data as csv, json, arrays
  • [ ] user settings to upload local file (file access api)
  • [ ] user settings to change columns, renames
  • [ ] user settings to update from url
  • [ ] pagination
  • [ ] refactor to same method updating by user or programmer
  • [ ] look for hidden class (UPDATE and PAGINATION) and complete it

Technical Debt:

  • [ ] when sorting, it ignores filter values (YAGNI)
  • [ ] rewrite updateData method: refactor to take into account updating by user and programmer