0.9.6 • Published 2 years ago

@zenequityui/table v0.9.6

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Installation

To install a component run

$ npm install @zenequityui/table --save

Please import CSS styles via

@import '/path__to__node_modules/@zenequityui/table/dist/index.min.css

Usage

Simple table

import { Table } from '@zenequityui/table';
const header = [
  { key: 'company', title: 'Company', dataIndex: 'company' },
  { key: 'contact', title: 'Contact', dataIndex: 'contact' },
  { key: 'country', title: 'Country', dataIndex: 'country' },
  { key: 'action', title: 'Action', dataIndex: '', render: (event) => <span onClick={() => { console.log(event); }} style={{ cursor: 'pointer' }}>Delete</span> },
];

const content = [
  { id: 1, 'company': 'Alfreds Futterkiste', 'contact': 'Maria Anders', 'country': 'Germany' },
  { id: 2, 'company': 'Centro comercial Moctezuma', 'contact': '', 'country': 'Mexico' },
  { id: 3, 'company': 'Ernst Handel', 'contact': 'Roland Mendel', 'country': 'Austria' },
  { id: 4, 'company': 'Island Trading', 'contact': 'Helen Bennett', 'country': 'UK' },
  { id: 5, 'company': 'Alfreds Futterkiste', 'contact': 'Maria Anders', 'country': '' },
];

<Table
  tableContent={content}
>
  <Table.CONTENT
    header={header}
    isLoading={false}
    renderLoading={<div>Loading...</div>}
  />
</Table>

Multiple Row

import { Table } from '@zenequityui/table';
const header = [
  { key: 'company', title: 'Company', dataIndex: ['company', 'contact'], dataRender: true, renderItem: (event) => ['', <span style={{ fontWeight: 'bold' }}>{event.contact}</span>] },
  { key: 'country', title: 'Country', dataIndex: 'country', },
];

const content = [
  { id: 1, 'company': 'Alfreds Futterkiste', 'contact': 'Maria Anders', 'country': 'Germany' },
  { id: 2, 'company': 'Centro comercial Moctezuma', 'contact': 'Francisco Chang', 'country': 'Mexico' },
  { id: 3, 'company': 'Ernst Handel', 'contact': 'Roland Mendel', 'country': 'Austria' },
  { id: 4, 'company': 'Island Trading', 'contact': 'Helen Bennett', 'country': 'UK' },
  { id: 5, 'company': 'Alfreds Futterkiste', 'contact': 'Maria Anders', 'country': 'Germany' },
];

const contentValue = [
  { 'company': 'Alfreds Futterkiste', 'contact': 'Maria Anders', 'country': 'Germany' },
  { 'company': 'Centro comercial Moctezuma', 'contact': 'Francisco Chang', 'country': 'Mexico' },
  { 'company': 'Ernst Handel', 'contact': 'Roland Mendel', 'country': 'Austria' },
];

<Table
  id="table2"
  tableContent={content}
>
  <Table.CONTENT
    header={header}
  />
</Table>

Table Selectable

import { Table } from '@zenequityui/table';
const header = [
  { key: 'company', title: 'Company', dataIndex: 'company' },
  { key: 'contact', title: 'Contact', dataIndex: 'contact' },
  { key: 'country', title: 'Country', dataIndex: 'country' },
];

const content = [
  { id: 1, 'company': 'Alfreds Futterkiste', 'contact': 'Maria Anders', 'country': 'Germany' },
  { id: 2, 'company': 'Centro comercial Moctezuma', 'contact': 'Francisco Chang', 'country': 'Mexico' },
  { id: 3, 'company': 'Ernst Handel', 'contact': 'Roland Mendel', 'country': 'Austria' },
  { id: 4, 'company': 'Island Trading', 'contact': 'Helen Bennett', 'country': 'UK' },
  { id: 5, 'company': 'Alfreds Futterkiste', 'contact': 'Maria Anders', 'country': 'Germany' },
];

initialState = {
  selectedItems: [1, 3],
};

<Table
  tableContent={content}
>
  <Table.CONTENT
    header={header}
    isSelectable
    selected={state.selectedItems}
    onSelect={(items) => {
      setState({ selectedItems: items });
    }}
  />
</Table>

Table Sorting

import { Table } from '@zenequityui/table';
const header = [
  { key: 'company', title: 'Company', dataIndex: 'company' },
  { key: 'contact', title: 'Contact', dataIndex: 'contact' },
  { key: 'country', title: 'Country', dataIndex: 'country' },
];

const content = [
  { id: 1, 'company': 'Alfreds Futterkiste', 'contact': 'Maria Anders', 'country': 'Germany' },
  { id: 2, 'company': 'Centro comercial Moctezuma', 'contact': 'Francisco Chang', 'country': 'Mexico' },
  { id: 3, 'company': 'Ernst Handel', 'contact': 'Roland Mendel', 'country': 'Austria' },
  { id: 4, 'company': 'Island Trading', 'contact': 'Helen Bennett', 'country': 'UK' },
  { id: 5, 'company': 'Alfreds Futterkiste', 'contact': 'Maria Anders', 'country': 'Germany' },
];

<Table
  tableContent={content}
>
  <Table.CONTENT
    header={header}
    isSorting
    sortBy={['company', 'country']}
  />
</Table>

Table Collapsable

import { Table } from '@zenequityui/table';
initialState = {
  collapseIndex: null,
};

const header = [
  {
    key: 'company',
    title: 'Company',
    dataIndex: 'company',
  },
  {
    key: 'action',
    title: 'Action',
    dataIndex: '',
    render: (event, index) => (
      <button
        style={{ cursor: 'pointer' }}
        onClick={() => {
          setState({
            collapseIndex: state.collapseIndex === index ? null : index,
          });
        }}
      >
        View
      </button>
    )
  },
];

const content = [
  {
    id: 1,
    company: 'Alfreds Futterkiste',
    children: {
      header: [
        { key: 'country', title: 'Country', dataIndex: 'country' },
        { key: 'contact', title: 'Contact', dataIndex: 'contact' },
      ],
      body: [
        { country: 'Germany', contact: 'Maria Anders' },
        { country: 'Mexico', contact: 'Centro comercial Moctezuma' },
      ],
    },
  },
  {
    id: 2,
    company: 'Ernst Handel',
    children: {
      header: [
        { key: 'country', title: 'Country', dataIndex: 'country' },
      ],
      body: [
        { country: 'Austria' },
      ],
    },
  },
  {
    id: 3,
    company: 'Island Trading',
    children: {
      header: [
        { key: 'country', title: 'Country', dataIndex: 'country' },
        { key: 'contact', title: 'Contact', dataIndex: 'contact' },
      ],
      body: [
        { country: 'UK', contact: 'Helen Bennett' },
        { country: 'Germany', contact: 'Maria Anders' },
      ],
    },
  },
];

<Table
  tableContent={content}
>
  <Table.CONTENT
    header={header}
    isLoading={false}
    renderLoading={<div>Loading...</div>}
    collapseIndex={state.collapseIndex}
  />
</Table>

Multiple Header

import { Table } from '@zenequityui/table';
const header = [
  { key: 'company', title: 'Company', dataIndex: 'company' },
  {
    key: 'information',
    title: 'Information',
    dataIndex: '',
    multiChild: [
      { key: 'contact', title: 'Contact', dataIndex: 'contact' },
      { key: 'country', title: 'Country', dataIndex: 'country' },
      {
        key: 'action',
        title: 'Action',
        dataIndex: '',
        render: (event) => (
          <button
            style={{ cursor: 'pointer' }}
            onClick={() => {
              console.log('query event', event);
            }}
          >
            View
          </button>
        )
      },
    ],
  },
];

const content = [
  {
    id: 1,
    company: 'Alfreds Futterkiste',
    multiChild: [
      { contact: 'Maria Anders', country: 'Germany' },
    ],
  },
  {
    id: 2,
    company: 'Centro comercial Moctezuma',
    multiChild: [
      { contact: '', country: 'Mexico' },
    ],
  },
  {
    id: 3,
    company: 'Ernst Handel',
    multiChild: [
      { contact: 'Roland Mendel', country: 'Austria' },
    ],
  },
  {
    id: 4,
    company: 'Island Trading',
    multiChild: [
      { contact: 'Helen Bennett', country: 'UK' },
    ],
  },
  {
    id: 5,
    company: 'Alfreds Futterkiste',
    multiChild: [
      { contact: 'Helen Bennett', country: 'UK' },
      { contact: 'Maria Anders', country: '' },
    ],
  },
];

<Table
  tableContent={content}
>
  <Table.CONTENT
    header={header}
    isLoading={false}
    renderLoading={<div>Loading...</div>}
  />
</Table>
0.8.9

3 years ago

0.8.8

3 years ago

0.8.5

3 years ago

0.8.4

3 years ago

0.8.7

3 years ago

0.8.6

3 years ago

0.9.0

3 years ago

0.7.2

3 years ago

0.9.2

3 years ago

0.7.4

3 years ago

0.9.1

3 years ago

0.7.3

3 years ago

0.7.9

3 years ago

0.9.4

3 years ago

0.7.6

3 years ago

0.9.3

3 years ago

0.7.5

3 years ago

0.9.6

2 years ago

0.7.8

3 years ago

0.9.5

3 years ago

0.7.7

3 years ago

0.8.1

3 years ago

0.8.0

3 years ago

0.8.3

3 years ago

0.8.2

3 years ago

0.6.7

3 years ago

0.6.6

3 years ago

0.6.9

3 years ago

0.6.8

3 years ago

0.7.1

3 years ago

0.7.0

3 years ago

0.6.3

3 years ago

0.6.2

3 years ago

0.6.5

3 years ago

0.6.0

4 years ago

0.5.9

4 years ago

0.5.8

4 years ago

0.5.7

4 years ago

0.5.6

4 years ago

0.5.5

4 years ago

0.5.4

4 years ago

0.5.3

4 years ago

0.5.2

4 years ago

0.4.9

4 years ago

0.4.8

4 years ago

0.4.10

4 years ago

0.4.7

4 years ago

0.5.0

4 years ago

0.5.1

4 years ago

0.4.6

4 years ago

0.4.5

4 years ago

0.4.4

4 years ago

0.4.3

4 years ago

0.4.2

4 years ago

0.4.1

4 years ago

0.3.9

4 years ago

0.3.8

4 years ago

0.4.0

4 years ago

0.3.7

4 years ago

0.3.6

4 years ago

0.3.5

4 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.9

4 years ago

0.2.8

4 years ago

0.2.7

4 years ago

0.2.6

4 years ago

0.2.5

4 years ago

0.2.4

4 years ago