@govuk-frederic/object-table

0.2.0 • Public • Published

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 [] arrayOf[object Object]
hideWithNoValues false bool
object {} object
skipEmptyValues false bool
title null node

Dependencies (2)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i @govuk-frederic/object-table

    Weekly Downloads

    16

    Version

    0.2.0

    License

    MIT

    Unpacked Size

    87.7 kB

    Total Files

    18

    Last publish

    Collaborators

    • loque-
    • penx
    • petelockey
    • steve_sims