0.0.18 • Published 3 months ago

jattac.libs.web.responsive-table v0.0.18

Weekly downloads
-
License
MIT
Repository
-
Last release
3 months ago

ResponsiveTable

ResponsiveTable is a reusable React component that displays tabular data in a responsive layout.

Features

  • Handles mobile and desktop layouts
  • Customizable columns
  • Dynamic column definitions
  • Card-style mobile view
  • Generic types for flexible data

Usage

<ResponsiveTable columnDefinitions={columns} data={data} />
  • 'columnDefinitions' defines an array of columns, which can be a simple configuration object or dynamic function
  • 'data' is an array of data objects to display in rows

The component handles switching layout based on screen width to optimize for desktop and mobile.

Custom Columns

Columns can be configured using the 'IResponsiveTableColumnDefinition' interface.

Some key configuration options:

  • 'displayLabel': Header label
  • 'dataKey': Maps column to data property
  • 'cellRenderer': Renders cell value

See docs for more details on customization.

Dynamic Columns

Column definitions can also be a function allowing dynamic configurations per row.

Props

Prop definitions provide detailed specification of component contract.

IProps

interface IProps<TData> {
  /** Column definitions */
  columnDefinitions: ColumnDefinition<TData>[];

  /** Table data rows */
  data: TData[];

  /** Optional styling */
  className?: string;

  /** row click handler */
  onRowClicked?: (row: TData) => void;

  /** not data component */
  noDataComponent?: ReactNode;
}
type ColumnDefinition<TData> =
  | IResponsiveTableColumnDefinition<TData>
  | ((rowData: TData, rowIndex?: number) => IResponsiveTableColumnDefinition<TData>);
interface IResponsiveTableColumnDefinition<TData> {
  displayLabel: string | ReactNode;

  dataKey?: keyof TData;

  cellRenderer: (rowData: TData) => ReactNode;
}
0.0.17

3 months ago

0.0.18

3 months ago

0.0.10

3 months ago

0.0.11

3 months ago

0.0.12

3 months ago

0.0.13

3 months ago

0.0.14

3 months ago

0.0.15

3 months ago

0.0.9

3 months ago

0.0.16

3 months ago

0.0.8

3 months ago

0.0.3

4 months ago

0.0.5

4 months ago

0.0.4

4 months ago

0.0.7

4 months ago

0.0.6

4 months ago

0.0.2

5 months ago

0.0.1

5 months ago