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

yaa-grid

v0.2.0

Published

YAA Grid control is a powerful and flexible tool for displaying and manipulating data. Specify your datasource and field names and you're ready to go. The Grid also offers support for features such as sorting, filtering, paging. These features allow you t

Downloads

148

Readme

YAA Grid

YAA Grid control is a powerful and flexible tool for displaying and manipulating data. Specify your datasource and field names and you're ready to go. The Grid also offers support for features such as sorting, filtering, paging. These features allow you to easily manipulate and present large datasets in an efficient and user-friendly way.

PS this package is under development, please contact me for additional features

Screenshot

Changelog

  • Theme color customization by passing color prop e.g. color="red", color="#406882"

  • Images support are now added you just need to specify its type as below

    { field: 'thumbnail', header: 'Thumbnail', type: 'img', width: '100' },
  • Striped table view

  • Custom actions icons

Setup

To install the Grid and its dependent packages, use the following command.

npm install yaa-grid # or yarn add

import "yaa-grid/dist/style.css";

Using the library

Now it’s time to cover use cases. Starting from its basic form.

import { Grid } from 'yaa-grid';

import 'yaa-grid/dist/style.css';

const App: React.FC = () => {
  const [data, setData] = React.useState();
  const [loading, setLoading] = React.useState(false);
  const [pageNumber, setPageNumber] = React.useState(1);

  React.useEffect(() => {
    const fetchData = async () => {
      setLoading(true);
      const data = await fetch(`https://dummyjson.com/products?skip=${(pageNumber - 1) * 10}&limit=10`);

      const result = await data.json();

      setData(result);
      setLoading(false);
    };

    fetchData();
  }, [pageNumber]);

  /*
   * Column width is measured by pixels
   */
  const columns = [
    { field: 'id', header: 'ID', width: '50' },
    { field: 'brand', header: 'Brand', width: '100' },
    { field: 'category', header: 'Category', width: '100' },
    { field: 'description', header: 'Description', width: '200' },
    { field: 'price', header: 'Price', width: '100' },
    { field: 'rating', header: 'Rating', width: '100' },
    { field: 'title', header: 'Title', width: '100' },
    { field: 'thumbnail', header: 'Thumbnail', type: 'img', width: '100' },
  ];

  const onView = (e: string) => alert(`View ${e}`);
  const onEdit = () => alert('edit');
  const onDelete = () => alert('delete');

  return (
    <Grid
      rtl={false}
      // variant="stipe"
      search={false}
      jsonExport={false}
      data={data?.products}
      onView={onView}
      onEdit={onEdit}
      onDelete={onDelete}
      loading={loading}
      columns={columns}
      pageSize={10}
      pageNumber={pageNumber}
      totalRecords={data?.total}
      setPageNumber={setPageNumber}
      onSelect={(ids: any) => alert(ids)}
    />
  );
};

Props

| Name | Type | Description | | --------------- | -------------------------------------------------- | ----------------------------------- | | data | any | Data source | | color | string | e.g. "red" or "#406882" | | columns | { field: string; header: string; width: string }[] | columns data shape | | variant | string | stripe | | height | string | Set the grid height | | rtl | boolean | RTL support for arabic | | search | boolean | display search input | | jsonExport | boolean | display export option | | loading | boolean | defaultValue: false | | pageNumber | number | defaultValue: 1 | | totalRecords | number | used only with frontend pagination. | | viewIcon | ReactNode | | | editIcon | ReactNode | | | deleteIcon | ReactNode | | | onView | (id: string) => void | | | onEdit | (id: string) => void | | | onDelete | (id: string) => void | | | onSelect | (ids: string[]) => void | Perform action on selected records | | setPageNumber | React.Dispatch<React.SetStateAction> | Pagination |

Contact

Please contact me for adding more features or package ideas