Giter VIP home page Giter VIP logo

af-react-table's Introduction

af-react-table

Install

npm install --save af-react-table

Features

  • All heights are calculated automatically, so there is no need to provide them.
  • Optimized non-recursize segment tree is used to store row dimensions.
  • mobx-ready Row and Cell components, which can be easily wrapped by observer
  • available height and width are calculated and observed automatically via use-resize-observer hook
  • scrollToRow(rowIndex) method is available
  • fixed and auto table layout mode
  • -N ... 0 rowCount handling available via rowCountWarningsTable prop
  • useApi can give table any table subcomponent access to global API
  • @emotion is used for styling, so you can pass css prop to table wrapper
  • renders table, tr, td, th, so default table styling, border collapsing, etc. can be easily applied.

PropTypes

Table.propTypes = {
    columns: PropTypes.array.isRequired,
    getRowData: PropTypes.func.isRequired,

    rowCount: PropTypes.number,
    getRowKey: PropTypes.func,
    estimatedRowHeight: PropTypes.number,
    getRowExtraProps: PropTypes.func,

    /* as row heights may be different, we measure overscan in px */
    overscanRowsDistance: PropTypes.number,

    HeaderRowComponent: PropTypes.any,
    RowComponent: PropTypes.any,
    CellComponent: PropTypes.any,

    RowCountWarningContainer: PropTypes.any,
    rowCountWarningsTable: PropTypes.object,
    fixedLayout: PropTypes.bool
};

Table.defaultProps = {
    rowCount: 0,
    estimatedRowHeight: 20,
    overscanRowsDistance: 200,
    fixedLayout: false,

    /*
        For 90% non-reactive solutions, which only provide new getRowData when data is changed, memo is ok.
        If RowComponent should be wrapped my mobx observer - non-memo version should be imported.
        memo(observer(RowComponentDefault)) will do the trick.
    */
    RowComponent: memo( RowComponentDefault ),
    CellComponent: CellComponentDefault,
    RowCountWarningContainer: RowCountWarningContainerDefault,
};

Demo

TODO

  • happens rarely(after certain width changes), but sometimes I can't scroll to last index(it trembles and hides)
  • add resetCache( fromIndex, toIndex ) method
  • add rerenderCurrentRange() method
  • show example source in playground
  • write documentation
  • implement position: sticky where it is supported
  • maybe pass props via context somehow to avoid memos and deep passing?
  • as models are extensible and most of the logics is taken away from react, it should be easy to implement List
  • improve performance on mobile
  • optimize segments tree batch insertion
  • add footer with column summaries and sorting
  • mobile scroll flickering

af-react-table's People

Contributors

nowaalex avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.