2.6.2 • Published 3 years ago

@nexys/mui-list v2.6.2

Weekly downloads
61
License
MIT
Repository
github
Last release
3 years ago

DataTable/List for Material UI (MUI) typescript

npm version npm version Build Package Deployment Average time to resolve an issue Percentage of issues still open Code style Bundlephobia

Multi-purpose data-table/business list for MUI

See here: https://nexys-system.github.io/mui-list-ts/

Relies on https://github.com/nexys-system/core-list

Get started

yarn install @nexys/mui-list

Minimal example

import {List, Types} from '@nexys/mui-list';

interface Animal {
  id: number;
  name: string;
  location: {id: number; name: string};
}

// list of data (here only one entry to make example more concise)
const data: Animal[] = [
  { id: 2, name: 'Sheep', location: {id: 2, name: 'Europe'} },
];

// prepare search options
const options = ['Africa', 'Europe'].map((value, i) => ({ key: i+1, value }));

// table definition
const def: Types.Definition<Animal> = [
  { name: 'name', filter: true, sort: true },
  {
    name: 'location',
    filter: {
      type: 'category',
      func: (a, b): boolean => b.includes(a.location.id),
      options
    },
    render: (x): string => x.location.name
  }
];

// list config
const config = { search: true, nPerPage: 3 }

export default (): JSX.Element => (
  <List data={data} def={def} config={config} />
);

API

all interfaces/types are described here: https://github.com/nexys-system/mui-list-ts/tree/master/src/lib/types

def

def defines the structure of the table and is an array of DefinitionItem<A>

name

column name/identifier (has to be included in A). In the simplest configuration, renders the value of A[name]

Accepted Types:Default Value
typeof A-

label

column label. In the simplest configuration. If not given, name is displayed.

Accepted Types:Default Value
stringname

render

custom rendering, e.g. if A contains amount and the amount needs to be formatted: render: x => myCustomFormatFuntion(x.amount)

Accepted Types:
(x:A) => ReactElement

filters

displays a column filter. The filter can be customized, see examples

Accepted Types:
Boolean + custom

sort

displays a column sort.

Accepted Types:
Boolean + custom

config

search

displays general search box

Accepted Types:Default Value
Booleanfalse

nPerPage

list of items per page

Accepted Types:Default Value
Int20

data

This is the content of the table.

Accepted Types:
A[]

Examples

The source code for the examples can be found in: https://github.com/nexys-system/mui-list-ts/tree/master/src/list

References

2.6.2

3 years ago

2.6.1

3 years ago

2.6.0

3 years ago

2.5.3

3 years ago

2.4.2

4 years ago

2.4.1

4 years ago

2.4.0

4 years ago

2.3.1

4 years ago

2.2.5

4 years ago

2.3.0

4 years ago

2.2.4

4 years ago

2.2.2

4 years ago

2.2.1

4 years ago

2.1.2

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.9

4 years ago

2.0.5

4 years ago

2.0.7

4 years ago

2.0.6

4 years ago

2.0.8

4 years ago

2.0.3

4 years ago

2.0.4

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago