# react-table-test-zrcu

> React table component for everyone

Latest version **1.0.6** (published 2018-09-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-table-test-zrcu
pnpm add react-table-test-zrcu
yarn add react-table-test-zrcu
bun add react-table-test-zrcu
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2018-09-27 |
| First published | 2018-09-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=8 |
| Dependencies | 0 |
| Unpacked size | 33.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Aleksey-Kiselov |
| Maintainers | zrcu |

## Links

- npm: https://www.npmjs.com/package/react-table-test-zrcu
- Repository: https://github.com/Aleksey-Kiselov/table-npm
- Homepage: https://github.com/Aleksey-Kiselov/table-npm#readme
- Issues: https://github.com/Aleksey-Kiselov/table-npm/issues
- npm.io page: https://npm.io/package/react-table-test-zrcu

## Recent versions

- 1.0.6 (latest) — 2018-09-27
- 1.0.5 — 2018-09-27
- 1.0.4 — 2018-09-27
- 1.0.3 — 2018-09-27
- 1.0.2 — 2018-09-27
- 1.0.1 — 2018-09-27
- 1.0.0 — 2018-09-26

## README

# react-table-test-zrcu

> React table component for everyone

[![NPM](https://img.shields.io/npm/v/react-table-test-zrcu.svg)](https://www.npmjs.com/package/react-table-test-zrcu) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

## Install

Install main package

```bash
npm install --save react-table-test-zrcu
```
Install styled-components (required)

```bash
npm install --save styled-components
```
## Usage

```jsx
import React, { Component } from 'react';

import MyComponent from 'react-table-test-zrcu';

class Example extends Component {
  render () {
    return (
      <MyComponent />
    );
  }
}
```
## Props

### General

data (required) - must be an Array of Objects, every object must contain 3 keys. Keys must be called 'first', 'second', 'third'. Values up to you.

addNewCell (required) - must be a function. Will be executed when you click on the right-bottom button. This can be any function. But I supposed it to add new cell to table.

##### For Example

```javascript
onAddNewCell = () => {
    /// Simulation of post request to the server
    new Promise((resolve, reject) => {
      setTimeout(function(){
        resolve("Added!");
      }, 2500);
    }).then(response => {
      console.log(response)
    }).catch(err => {
      console.log(err.message)
    })
    /// Adding new empty cell to our array in case if you use local state
    this.setState(prevState => ({
      users: prevState.users.concat({
        first: '', 
        second: '', 
        third: ''})
    }));
  }
```

removeCell (required) - must be a function. Will be executed when you click on the inner button inside every cell. This can be any function. But I supposed it to remove new cell from the table.

##### For Example

```javascript
onRemoveCell = (index) => {
    /// Simulation of delete request to the server
    new Promise((resolve, reject) => {
      setTimeout(function(){
        resolve("Removed!");
      }, 2500);
    }).then(response => {
      console.log(response)
    }).catch(err => {
      console.log(err.message)
    })
    /// Removing item from our array of items in case if you use local state
    this.setState(prevState => ({
      users: prevState.users.filter((user, ind) => {
        return ind !== index;
      })
    }))
  }
```

changeContent (required) - must be a function. Will be executed when you edit any data inside the table. This can be any function. But I supposed it to update your local state whenever you edit something.

##### For Example

```javascript
onChangeContent = (value, ind, name) => {
    this.setState(prevState => ({
        users: prevState.users.map((person, index) => {
          if (index === ind){
              person[name] = value
          }
          return person;
      })
    }))
  }
```

saveData (required) - must be a function. Will be executed when you click on the left-bottom button. This can be any function. But I supposed it to send put or post request to the server and update the data.

##### For Example

```javascript
 onSaveData = () => {
   /// Simulation of sending put or post request to the server
    new Promise((resolve, reject) => {
      setTimeout(function(){
        resolve("Database updated!");
      }, 2500);
    }).then(response => {
      console.log(response)
    }).catch(err => {
      console.log(err.message)
    })
  }
```
width - must be a string. Width of the table in pixiles.

##### For Example

```string
width='300px'
```

header - must be a string. This will be a header name of the table.

rightBtn - must be a string. This will be a right button name. Supposed to add new cells, but it's up to you.

leftBtn - must be a string. This will be a left button name. Supposed to update database, but it's up to you.

innerBtn - must be a string. This will be an inner button. Supposed to remove table cell, but it's up to you.

firstP, secondP, thridP - every prop must be a string. Will be used to name headers inside every cell.

## License

MIT © [Aleksey-Kiselov](https://github.com/Aleksey-Kiselov)

---
_Source: https://npm.io/package/react-table-test-zrcu · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
