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

@ftchinese/ftc-table-react

v1.1.3

Published

The react version for ftc-table

Downloads

1

Readme

ftc-table-react

The React version for ftc-table.

It provides some features for a table: sorting by each column, showing caculating results, fixing the table's head if necessary...

Install

cd yourProject
npm install "@ftchinese/ftc-table-react" --save 

Usage

Example:

import React from 'react';
import ReactDOM from 'react-dom';

import {FtcTable, TableBodyRow} from '@ftchinese/ftc-table-react';


class App extends React.Component {
  constructor(props) {
    super(props);
  }
  render() {
    const fieldsInfoForTable = [
      {
        "field":"Cheese",
        "fieldName": "Cheese",
        "fieldSubName": "Type of cheese",
        "dataIsNumberic": false,
        "disableSort": false
      },
      {
        "field":"Bread",
        "fieldName": "Bread",
        "fieldSubName": "Type of bread",
        "dataIsNumberic": false,
        "disableSort": false
      },
      {
        "field": "CostGBP",
        "fieldName": "Cost",
        "fieldSubName": "(GBP)",
        "dataIsNumberic": true,
        "disableSort": false
      },
      {
        "field":"CostEUR",
        "fieldName": "Cost",
        "fieldSubName":"(EUR)",
        "dataIsNumberic": true,
        "disableSort": false
      }
    ];
    const captionsInfoForTable = {
      top: "Top Caption",
      bottom: "Bottom Caption"
    };
    const styleListValue = [
      "table--row-stripes"
    ];
    const statisticInfoArr = ['sum', 'mean', 'median'];

    return (
      <FtcTable 
        styleList={styleListValue} 
        fieldsInfo={fieldsInfoForTable} 
        captionsInfo={captionsInfoForTable}  
        addStatisticInfo={statisticInfoArr}
        >
        <TableBodyRow defaultOrder="0" data={
          {
            "Cheese": "cheddar",
            "Bread": "rye",
            "CostGBP":1,
            "CostEUR":1.56
          }
        }/>
        <TableBodyRow defaultOrder="1" data={
          {
            "Cheese": "stilton",
            "Bread": "wholemeal",
            "CostGBP":2,
            "CostEUR":1.85
          }
        }/>
        <TableBodyRow defaultOrder="2" data={
          {
            "Cheese": "red leicester",
            "Bread": "white",
            "CostGBP":3,
            "CostEUR":""
          }
        }/>
      </FtcTable>
    );
  }
}

ReactDOM.render(
  <App />,
  document.getElementById('root')
);

API

The exported components are FtcTable and TableBodyRow .

Props For FtcTable

children

Type Array of or one TableBodyRow. Required. The FtcTable should need TableBodyRow to be as children

fieldsInfo

Type Array of Object. Required. The information data for the fileds of the table's thead.The Object should has following prop:

field

Type String. Required. The unique code for one field.

fieldName

Type String. Optional. The showing name for the field in the thead of table. If it is missing, the field will show instead.

fieldSubName

Type String. Optional. The showing subname for the field in the thead of table.

dataIsNumberic

Type Boolean. Optional. If it is true, the column of data of this field will be regarded as Number, which will effect the result of sorting of the data in the column and the style of the column.

disableSort

Type Boolean. Optional. If it is true, the sorting for the data of this column will be disabled.

captionsInfo

Type Object. Optional. The words for the captions of the table. It has two keys:

top

Type String. Optional. The words for the top caption. If it is missing. The table will have no top caption.

bottom

Type String. Optional. The words for the bottom caption. If it is missing. The table will have no bottom caption.

styleList

Type Array of String or Type String. The style name(s) for the table. There are 5 style names for choosing:

  • ftc-table--row-stripes: Add row stripe related styles to table, making the adjacent 2 rows with 2 colors.
  • ftc-table--horizontal-lines: Add horizontal lines to table.
  • ftc-table--vertical-lines: Add vertical lines to table.
  • "table--responsive-overflow": Add overflow responsive related styles to table.
  • "table--responsive-flat":Add flat responsive related styles to table.

The ftc-table--row-stripesftc-table--horizontal-linesftc-table--vertical-lines can be selected only one or selected two or three at one time.

The table--responsive-overflowtable--responsive-flat should be selected only one at one time. If they are both selected, the one writing last will go into effect. And if there is a prop addWrapperInfo(as follows), both of the responsive style will be invalid.

addStatisticInfo

Type Array. Optional. The item of the Array should be one of 'sum', 'mean', 'median'. If it has values, the corresponding statistical results will be showed in the tfoot. The statistics are only for the column whose data are Number(That's to say, the dataIsNumberic of the column's corresponding data in fieldsInfo is true)

addWrapperInfo

Type Object. Optional. The sizes of the wrapper of the table. It has two keys, width and height, which describe the length of the table's width and height. Both keys are required, if one of the keys are missing or the addWrapperInfo is missing, the table will not have a wrapper. If the table has a wrapper, the thead of the table will be fixed on top when vertically scrolling the content of the table.

The values of width and height can be String or Number. If they are String, they can be values for the CSS properties 'width' and 'height' such as '100%','80px'. If they are Number, they means 'px'.

Props For TableBodyRow

defaultOrder

Type number.Optional. The default index for the row. The initially showing for the rows will follow this order. If it is missing, the initial orders are depended on the writing orders for the TableBodyRow.

data

Type Object. Required. The data for one row. The keys of it should be same as the value of field of the item of fieldsInfo in parent component FtcTable