@mailstep/design-system 0.7.22 → 0.7.23-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mailstep/design-system",
3
- "version": "0.7.22",
3
+ "version": "0.7.23-beta.0",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "main": "./ui/index.js",
@@ -0,0 +1,9 @@
1
+ import { FC } from 'react';
2
+ import { ColumnDefinitions, DataRow } from './types';
3
+ type Props = {
4
+ columnDefinitions: ColumnDefinitions;
5
+ data: DataRow[];
6
+ onRowClick?: (dataRow: DataRow) => void;
7
+ };
8
+ export declare const Table: FC<Props>;
9
+ export {};
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Table as TableComponent, Thead, Tr, Td, Th, Tbody } from '../../Elements/Table';
3
+ export var Table = function (_a) {
4
+ var columnDefinitions = _a.columnDefinitions, data = _a.data, onRowClick = _a.onRowClick;
5
+ return (_jsxs(TableComponent, { children: [_jsx(Thead, { children: _jsx(Tr, { children: columnDefinitions.map(function (column) { return (_jsx(Th, { children: column.title })); }) }) }), _jsx(Tbody, { children: data.map(function (item) { return (_jsx(Tr, { onClick: function () { return onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick(item); }, cursor: onRowClick ? 'pointer' : 'auto', children: columnDefinitions.map(function (column) { return (_jsx(Td, { children: item[column.name] }, column.name)); }) }, item.id)); }) })] }));
6
+ };
@@ -0,0 +1 @@
1
+ export { Table } from './Table';
@@ -0,0 +1 @@
1
+ export { Table } from './Table';
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ declare const meta: {
3
+ title: string;
4
+ component: import("react").FC<{
5
+ columnDefinitions: import("../types").ColumnDefinitions;
6
+ data: import("../types").DataRow[];
7
+ onRowClick?: ((dataRow: import("../types").DataRow) => void) | undefined;
8
+ }>;
9
+ tags: string[];
10
+ argTypes: {};
11
+ };
12
+ export default meta;
13
+ export declare const Default: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Table } from '../';
3
+ var meta = {
4
+ title: 'Blocks/Table',
5
+ component: Table,
6
+ tags: ['autodocs'],
7
+ argTypes: {}
8
+ };
9
+ export default meta;
10
+ var columnDefinitions = [
11
+ { name: 'name', title: 'Name' },
12
+ { name: 'surname', title: 'Surname' },
13
+ { name: 'age', title: 'Age' }
14
+ ];
15
+ var data = [
16
+ { id: 'id1', name: 'Fred', surname: 'Borow', age: 15 },
17
+ { id: 'id2', name: 'Karl', surname: 'Boxer', age: 25 },
18
+ { id: 'id3', name: 'Igor', surname: 'Laryngtown', age: 35 },
19
+ ];
20
+ export var Default = function () { return (_jsx(Table, { columnDefinitions: columnDefinitions, data: data, onRowClick: function (dataRow) { return console.log(dataRow); } })); };
@@ -0,0 +1,8 @@
1
+ export type ColumnDefinition = {
2
+ name: string;
3
+ title?: string;
4
+ };
5
+ export type DataRow = Record<string, unknown> & {
6
+ id: string;
7
+ };
8
+ export type ColumnDefinitions = ColumnDefinition[];
@@ -0,0 +1 @@
1
+ export {};