0.3.8 • Published 4 years ago

cobrains-react v0.3.8

Weekly downloads
5
License
MIT
Repository
gitlab
Last release
4 years ago

NPM JavaScript Style Guide

React Js components library based on Material UI Next

Installation

Run on your project the command

npm install --save cobrains-react
npm install @material-ui/core

Components

Below the list of all components present in the cobrains-react

ApiMessageControl

A ready component that using redux show a snackbar message using the error response status

<ApiMessageControl />

on the Api Call error set redux with

this.props.onUpdateApiControl(err, 'auth', this.props.intl, 'Username e/o Password errati') 

BreadCrumbs

A breadcrumbs component that use the router redux structure

<BreadCrumbs background={'#000'}
             color={'#fff'}
             fontSize={12} />

CrudDialog

A dialog component with generated form using a array objecj structure

<CrudDialog title={'Create user'}
            message={'Compile the below fields to add a user'}
            submitText={'Create'}
            fields={userFields}
            data={userSelected[0]}
            loader={false}
            open={true}
            onClose={() => this.setState({openAddDialog: false})}
            onCreate={(newUser) => console.log(newUser)}
            dialogProps={theme.CrudDialog.dialogProps} />

Props

title

(string)

The title of the dialog

message

(string)

The subtitle of the dialog

submitText

(string)

The text on the confirm button

fields

(objects array)

The data structure that define the crud

const user: [
        {key: 'username', label: 'Username', required: true, type: 'text', visible: true},
        {key: 'first_name', label: 'First Name', required: true, type: 'text', visible: true},
        {key: 'type', label: 'Type', required: true, type: 'select', visible: true
                 values: [
                    {key: 'SA', value: 'SA', label: 'Super Admin'},
                    {key: 'CA', value: 'CA', label: 'Customer Admin'}
                  ],
        },
        {type: 'divider', label: 'Insert on this section '},
        {type: 'br'},
]

data

(objects array)

The data values of the crud

loader

(boolean)

Show a loader on button confirm during the api call

open

(boolean)

Define if the dialog is open

onClose

(function)

Called when the dialog closed

onCreate

(function)

Called on create/edit of the crud, return a the data serialized

dialogProps

(object)

Additional props/options for the dialog, it is possible to set a red dialog full page using

dialogProps: {
    fullWidth: true,
    fullScreen: false
    style: {background: 'red'}
}

TableGenerator

Generate a table using a array of objects

<TableGenerator fields={fields}
                data={users}
                {...otherProps}/>

Props

searchColumnsFilter

(boolean)

Define if it is present a button to enable the filter search on column


checkboxColumn

(boolean)

Define if the first column has the checkboxs for the row selection


data

(objects array)

The data values of the table

const users = [
   {username: `username 1`, first_name: `name 1`, last_name: `surname 1`},
   {username: `username 2`, first_name: `name 2`, last_name: `surname 2`},
   {username: `username 3`, first_name: `name 3`, last_name: `surname 3`}
]

fields

(objects array)

The data structure that define the table

const fields = [
   {key: 'username', columnName: 'Username', type: 'input', editable: true},
   {key: 'first_name', columnName: 'First name'},
   {key: 'last_name', columnName: 'Last name'},
   {key: 'company.name', columnName: 'Company name'},
]

Note: using the "." (dot) separator in the name of the key get the value in the different nodes of the object.

Available types

text

simple text

input

Textfield for input

date

date with format (DD/MM/YYYY hh:mm:ss)

select

select (have to add values:[] in the fields structure)

textOverflow

For long text, truncate the text and show a popup on hover


loader

(boolean)

Show a loader on table


filterIcon

(<Icon>)

Custom icon for filter


rowPerPage

(number)

Default row per page option


maxSelectableElements

(number)

Max number of elements selectable by checkbox - only for checkbox enable


renderItemCell

(function)

Can use this props to override the cell component in the table

<TableGeneratorCell>
        {({component}) =>
          <TableGenerator
            fields={fields}
            data={users}
            renderItemCell={component}
            {...otherProps}
          />
        }
</TableGeneratorCell>

TableGeneratorCell is component with a function as children, on the below the sample structure

import React, {Component} from 'react'

export default class TableGeneratorSettings extends Component {
    state = {
      component: (value, keyName, DefaultComponent) => {
        switch (keyName.type) {
        case 'customType': return (<div>This is a custom cell {value}</div>)
        default: return DefaultComponent
        }
      }
    };
    render() {return (<div>{this.props.children({...this.props, ...this.state})}</div>)}
}

selectedElements

(object array)

The list of elements selected for sync between table generator and own component

onChangePage

(function)

Called when table page change, return the active page

onChangeSelected

(function)

if checkboxColumn prop is true, return an object with the list of row selected

onFiltersChange

(function)

Called when a filter on column change, return a ready structure {key: value}

Components without documentation

DevelopmentDrawer
FormDialog
FileInput
FullScreenLogoLoader
FunctionsToolbar
HorizontalScrollContainer
PrivateAccess
ReactUtils
Routing
Search
SelectAutocomplete
StayConnected
Utils

CLI

Support

Reach out to us at one of the following places!

  • Website at co-brains.com

License

License

0.3.8

4 years ago

0.3.7

5 years ago

0.3.6

5 years ago

0.3.5

5 years ago

0.3.4

5 years ago

0.3.3

5 years ago

0.3.2

5 years ago

0.3.0

5 years ago

0.2.99

5 years ago

0.2.98

5 years ago

0.2.97

5 years ago

0.2.96

5 years ago

0.2.95

5 years ago

0.2.94

5 years ago

0.2.93

5 years ago

0.2.92

5 years ago

0.2.91

5 years ago

0.2.90

5 years ago

0.2.89

5 years ago

0.2.88

5 years ago

0.2.87

5 years ago

0.2.86

5 years ago

0.2.85

5 years ago

0.2.84

5 years ago

0.2.83

5 years ago

0.2.82

5 years ago

0.2.81

5 years ago

0.2.80

5 years ago

0.2.79

5 years ago

0.2.78

5 years ago

0.2.77

5 years ago

0.2.76

5 years ago

0.2.75

5 years ago

0.2.74

5 years ago

0.2.73

5 years ago

0.2.72

5 years ago

0.2.71

5 years ago

0.2.70

5 years ago

0.2.69

5 years ago

0.2.68

5 years ago

0.2.67

5 years ago

0.2.66

5 years ago

0.2.65

5 years ago

0.2.64

5 years ago

0.2.63

5 years ago

0.2.62

5 years ago

0.2.61

5 years ago

0.2.60

5 years ago

0.2.59

5 years ago

0.2.58

5 years ago

0.2.57

5 years ago

0.2.56

5 years ago

0.2.55

5 years ago

0.2.54

5 years ago

0.2.52

5 years ago

0.2.51

5 years ago

0.2.50

5 years ago

0.2.49

5 years ago

0.2.48

5 years ago

0.2.47

5 years ago

0.2.46

5 years ago

0.2.45

5 years ago

0.2.44

5 years ago

0.2.43

5 years ago

0.2.42

5 years ago

0.2.41

5 years ago

0.2.40

5 years ago

0.2.38

5 years ago

0.2.37

5 years ago

0.2.36

5 years ago

0.2.35

5 years ago

0.2.34

5 years ago

0.2.33

5 years ago

0.2.32

5 years ago

0.2.31

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.29

5 years ago

0.1.28

5 years ago

0.1.26

5 years ago

0.1.25

5 years ago

0.1.24

5 years ago

0.1.23

5 years ago

0.1.22

5 years ago

0.1.21

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago