0.2.0 • Published 5 years ago
@govuk-frederic/object-table v0.2.0
ObjectTable
Import
import ObjectTable from '@govuk-frederic/object-table';
Usage
Simple
const fields = [
{ key: 'one', heading: 'One' },
{ key: 'two', heading: 'Two' },
{ key: 'three', heading: 'Three' },
{ key: 'four', heading: 'Four' },
];
const object = { one: 'test', two: 'test', three: '', four: null };
const title = ['Heading'];
<ObjectTable fields={fields} object={object} title={title}/>;
With skipEmptyValues
const fields = [
{ key: 'one', heading: 'One' },
{ key: 'two', heading: 'Two' },
{ key: 'three', heading: 'Three' },
{ key: 'four', heading: 'Four' },
];
const object = { one: 'test', two: 'test', three: '', four: null };
const title = ['Heading'];
<ObjectTable fields={fields} object={object} title={title} skipEmptyValues={false}/>
With hideWithNoValues
const fields = [
{ key: 'one', heading: 'One' },
{ key: 'two', heading: 'Two' },
];
const object = { };
const title = ['Heading'];
<ObjectTable fields={fields} object={object} title={title} hideWithNoValues />;
Properties
Prop | Required | Default | Type | Description |
---|---|---|---|---|
defaultTransform | (value = '-') => value | func | ||
fields | [] | arrayOfobject Object | ||
hideWithNoValues | false | bool | ||
object | {} | object | ||
skipEmptyValues | false | bool | ||
title | null | node |