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

@lsky/v-table

v0.0.4

Published

> React components for render table with virtual

Downloads

2

Readme

Virtual Table

React components for render table with virtual

Installing

npm

$ npm i @lsky/v-table

yarn

$ yarn add @lsky/v-table

And you need to React and ReactDom

$ npm i react react-dom

Example

Basic usage

import React from 'react'
import VTable from '@lsky/v-table'

class Index extends React.PureComponent {
  tableRender({
    rowIndex, columnIndex, key, style,
  }) {
    return (
      <div key={key} style={style}>{`row-${rowIndex}-col-${columnIndex}`}</div>
    )
  }

  render() {
    return (
      <VTable
        width={860}
        height={600}
        rowHeight={40}
        columnWidth={100}
        columnCount={100}
        rowCount={1000}
        render={this.tableRender}
      />
    )
  }
}

Wrap Adaptive

Adaptive component will adapt the container width and height, and return the width and height value.

Warning: The parent element must have relative attr.

import React from 'react'
import VTable, { Adaptive } from '@lsky/v-table'

class Index extends React.PureComponent {
  tableRender({
    rowIndex, columnIndex, key, style,
  }) {
    return (
      <div key={key} style={style}>{`row-${rowIndex}-col-${columnIndex}`}</div>
    )
  }

  render() {
    return (
      <Adaptive>
        {({ width, height }) => (
          <VTable
            width={width}
            height={height}
            rowHeight={40}
            columnWidth={100}
            columnCount={100}
            rowCount={1000}
            render={this.tableRender}
          />
        )}
      </Adaptive>
    )
  }
}

Wrap WindowScroller

*Warning: * WindowScroller cannot be mixed with Adaptive.


import React from 'react'
import VTable, { WindowScroller } from '@lsky/v-table'

class Index extends React.PureComponent {
  tableRender({
    rowIndex, columnIndex, key, style,
  }) {
    return (
      <div key={key} style={style}>{`row-${rowIndex}-col-${columnIndex}`}</div>
    )
  }

  render() {
    return (
      <WindowScroller>
        {({ scrollTop, scrollLeft }) => (
          <VTable
            width={860}
            height={600}
            scrollTop={scrollTop}
            scrollLeft={scrollLeft}
            rowHeight={40}
            columnWidth={100}
            columnCount={100}
            rowCount={1000}
            render={this.tableRender}
          />
        )}
      </WindowScroller>
    )
  }
}

Component Props

VTable

| attr | type | default value | required | desc | | --- | --- | --- | --- | --- | | columnWidth | number | ((columnIndex) => number) | null | true | column width | | columnCount | number | null | true | column count | | rowHeight | number | ((rowIndex) => number) | null | true | row height | | rowCount | number | null | true | row count | | width | number | null | true | container width | | height | number | null | true | container height | | scrollTop | number | null | false | scrollTop. if passed in, change to controlled component | | scrollLeft | number | null | false | scrollLeft. if passed in, change to controlled component | | render | (({rowIndex, columnIndex, key, style}) => React.node) | null | true | render cell | | onScroll | (({scrollTop, scrollLeft}) => void) | null | false | onScroll | | isWindowScroller | boolean | null | false | is use WindowScroller component wrap |

Adaptive

| attr | type | default value | required | desc | | --- | --- | --- | --- | --- | | defaultWidth | number | null | false | default width | | defaultHeight | number | null | false | default height | | children | (({width, height}) => React.node) | null | true | children |

WindowScroller

| attr | type | default value | required | desc | | --- | --- | --- | --- | --- | | scrollLeft | number | null | false | scroll left | | scrollTop | number | null | false | scroll top | | children | (({scrollLeft, scrollTop}) => React.node) | null | true | children |