Giter Site home page Giter Site logo

nuxy / react-tidy-table Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 409 KB

:file_folder: The / tidy-table / plugin React component wrapper.

Home Page: https://tidy-table.nuxy.dev

License: MIT License

table-generator column-sorting html-tables reactjs wrapper-library components

react-tidy-table's Introduction

React Tidy Table npm version

Create a HTML table that can be sorted, selected, and post-processed using a simple callback.

Preview

Features

  • Extensible HTML/CSS interface.
  • Compatible with all modern desktop and mobile web browsers.
  • Fully responsive layout with touch event support.
  • Easy to set-up and customize.
  • Customizable callback functions for post-processing selected results.
  • Post-process options for manipulating table/column/menu elements.
  • Fast and lightweight (JavaScript plug-in *only 4 kB)

Checkout the demo for examples of use.

Dependencies

Installation

Add to an existing React project using YARN.

$ yarn add react-tidy-table

Usage

import React     from 'react';
import TidyTable from 'react-tidy-table'; // or '../dist/react-tidy-table';

const options = {
  enableCheckbox: true,
  enableMenu:     true,
  reverseSortDir: true,
  responsive:     true
};

const settings = {
  columnTitles: ['Rank', 'Programming Language', 'Ratings Jan 2012', 'Delta Jan 2012', 'Status'],
  columnValues: [
    ['1', 'Java', '17.479%', '-0.29%', 'A'],
    ['2', 'C', '16.976%', '+1.15%', 'A'],
    ['3', 'C#', '8.781%', '+2.55%', 'A'],
    ['4', 'C++', '8.063%', '-0.72%', 'A'],
    ['5', 'Objective-C', '6.919%', '+3.91%','A']
  ],

  // Add menu options to bind result events.
  menuOptions: [
    ['- Action -', null],
    ['Callback 1', {callback: (rows) => {}}],
    ['Callback 2', {callback: (rows) => {}}]
  ],

  // Post-process rendered HTML output.
  postProcess: {
    table:  (HTMLTableElement)     => {},
    column: (HTMLTableCellElement) => {},
    menu:   (HTMLTableElement)     => {}
  },

  // Pre-process column values before sort.
  sortByPattern: function(colNum, val) {
    if (colNum !== 1) return val;

    return val?.replace(/\$|%|#/g, '');
  }
};

export default class Demo extends React.Component {
  constructor() {
    super();
  }

  render() {
    return (
      <React.Fragment>
        <TidyTable settings={settings} options={options} />
      </React.Fragment>
    );
  }
};

Component Props

Name Type Description
settings Object Main configuration.
options Object Override table defaults.

Documentation

Developers

CLI options

Run ESLint on project sources:

$ npm run lint

Transpile ES6 sources (using Babel) and minify to a distribution:

$ npm run build

Bundle demo sources (using Webpack):

$ npm run webpack

Contributions

If you fix a bug, or have a code you want to contribute, please send a pull-request with your changes. (Note: Before committing your code please ensure that you are following the Node.js style guide)

Versioning

This package is maintained under the Semantic Versioning guidelines.

License and Warranty

This package is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.

react-tidy-table is provided under the terms of the MIT license

Author

Marc S. Brooks

react-tidy-table's People

Contributors

nuxy avatar

Watchers

 avatar  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.