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

react-url-table

v0.0.4

Published

Smart and flexible table component built with React and for React projects. based on React16 hooks and mobx-react-lite

Downloads

11

Readme

react-url-table

Build Status

Build data grid just by URL. Based on React16 hooks and mobx-react. MIT License.

Screenshot Check Component storybook

Install

# Yarn
yarn add react-url-table

# NPM
npm install --save react-url-table

ENV:

Typescript, Webpack, React 16 hooks, Mobx-react (for optimized store management)

Tests:

jest, enzyme, enzyme-adapter-react-16

Usage

 <UrlTable
    url="https://next.json-generator.com/api/json/get/4k6xmJ21r"
    headers={['Name', 'Age', 'Eyes', 'Phone', 'Favorite fruit']}
    fields={['name', 'age', 'eyeColor', 'phone', 'favoriteFruit']}
    pagination={{
        pageSize: 5
    }}
    indexField={'_id'}
/>

Features

  • load by URL or display local data
  • pagination
  • sorting by multiple columns
  • global search
  • search by specified column
  • custom render components
  • select single or multiple rows
  • edit cells

Component Props

| Prop | Type | Required | Default | Info | |:-----------------|:--------------------------------------|:---------|:-----------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | data | Array | yes/no | - | Array of objects [{}, {}]. property data or url required | | url | String | yes/no | - | Property data or url required | | fetchSuccess | Function | no | - | (res: any) => []. This function will be called to map/parse data request from before render | | fields | Array of Strings or IFieldPropObject | yes | - | You can pass any deep property name of object in prop-dot format prop1.prop2 | | headers | Array of Strings or IHeaderPropObject | no | - | don't specify this props if you want to render table without header | | indexField | String | yes | - | uniq object property. used for performance index ('uuid', 'id', '_id') | | search | Boolean | no | false | To use global search across all columns just pass true. It's possible to search just by specified columns | | sorting | String or Boolean | no | 'simple' | with 'simple' table data will be sorted by single column. Setting 'compound' allows you to make sorting by few columns at the same time. Do disable sorting use false | | showSortingPanel | Boolean | no | true | show soring panel with badges of current sorting state | | onSelect | Function | no | - | (record: SelectedRows[]) => void. This function will be called by table row clicking/selecting. | | selectMode | String or Boolean | no | false | single | multiple | false . Highlight and execute onSelect callback by selecting one or few table rows. | | loadingComponent | Function | no | - | (isLoading?: boolean) => React.ReactElement. Use custom Loading component | | pagination | IPaginateProps or Boolean | no | {pageSize: 10,pageRangeDisplayed: 5,marginPagesDisplayed: 1}, | For pagination it uses react-paginate component. You can pass any react-paginate property to pagination. Set false to hide pagination. | | editable | Boolean | no | false | editable={true} makes all cells editable. NOTE: You can pass editable={boolean} in IHeaderPropObject to make certain cells editable | | onEdit | Function | no | - | onEdit: (newValue: string, propertyName: string, record: IRecord) => void. This callback will be called after cell editing (onBlur) |

NOTE: existing of property data or url is required to display table.

Configurable Cell:

interface IFieldPropObject {
    property: string,
    // IRecord is data object
    render?(cellValue: any, object: IRecord): string | React.ReactElement
}

Configurable Header:

interface IHeaderPropObject {
    name: string,
    property?: string,
    sortable?: boolean,
    searchable?: boolean,
    editable?: boolean,
    // render returns string or react element
    render?(name: string): string | React.ReactElement
}

Pagination Props:

For pagination it uses react-paginate component. You can pass any react-paginate property to pagination

import {ReactPaginateProps} from "react-paginate";

interface IPaginateProps extends Partial<ReactPaginateProps> {
    pageCount?: number,
    currentPage?: number,
    pageSize: number
}

Styles

import react-url-table/styles/index.css into your component. BTW you can override table styles by passing your custom className. Themes are based on CSS variables.

Note: pageSize property is required

Features TODO:

  • [ ] reorder rows (drag-n-drop)
  • [ ] reorder columns (drag-n-drop)
  • [ ] resize column width
  • [ ] custom row pattern/component
  • [ ] column highlighting (CSS only)
  • [ ] Themes supporting