@react-foundry/simple-table 0.1.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/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (C) 2019-2025 Crown Copyright
4
+ Copyright (C) 2019-2026 Daniel A.C. Martin
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
7
+ this software and associated documentation files (the "Software"), to deal in
8
+ the Software without restriction, including without limitation the rights to
9
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
10
+ of the Software, and to permit persons to whom the Software is furnished to do
11
+ so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,83 @@
1
+ React Foundry - Simple Table
2
+ ============================
3
+
4
+ A simple table for displaying data.
5
+
6
+
7
+ Using this package
8
+ ------------------
9
+
10
+ First install the package into your project:
11
+
12
+ ```shell
13
+ npm install -S @react-foundry/simple-table
14
+ ```
15
+
16
+ Then use it in your code as follows:
17
+
18
+ ```js
19
+ import React, { createElement as h } from 'react';
20
+ import SimpleTable from '@react-foundry/simple-table';
21
+
22
+ export const MyComponent = props => (
23
+ <SimpleTable
24
+ keys={['name', 'qty', 'cost']}
25
+ headings={{
26
+ cost: 'Price',
27
+ qty: 'Quantity',
28
+ name: 'Name'
29
+ }}
30
+ data={[
31
+ {
32
+ cost: '£7.99',
33
+ qty: '4',
34
+ name: 'Blu-ray disk'
35
+ },
36
+ {
37
+ cost: '£0.85',
38
+ qty: '10',
39
+ name: 'Pencil'
40
+ },
41
+ {
42
+ cost: '£21.45',
43
+ qty: '1',
44
+ name: 'Text book'
45
+ },
46
+ ]}
47
+ />
48
+ );
49
+
50
+ export default MyComponent;
51
+ ```
52
+
53
+
54
+ Working on this package
55
+ -----------------------
56
+
57
+ Before working on this package you must install its dependencies using
58
+ the following command:
59
+
60
+ ```shell
61
+ pnpm install
62
+ ```
63
+
64
+
65
+ ### Testing
66
+
67
+ ```shell
68
+ npm test
69
+ ```
70
+
71
+
72
+ ### Building
73
+
74
+ ```shell
75
+ npm run build
76
+ ```
77
+
78
+
79
+ ### Clean-up
80
+
81
+ ```shell
82
+ npm run clean
83
+ ```
File without changes
@@ -0,0 +1,11 @@
1
+ import { FC, HTMLAttributes, ReactNode } from 'react';
2
+ import { StandardProps } from '@react-foundry/component-helpers';
3
+ import '../assets/SimpleTable.scss';
4
+ export type SimpleTableProps<T> = StandardProps & HTMLAttributes<HTMLTableElement> & {
5
+ caption?: string | ReactNode;
6
+ data: T[];
7
+ headings: T;
8
+ keys: (keyof T)[];
9
+ };
10
+ export declare const SimpleTable: FC<SimpleTableProps<any>>;
11
+ export default SimpleTable;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SimpleTable = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const component_helpers_1 = require("@react-foundry/component-helpers");
6
+ require("../assets/SimpleTable.scss");
7
+ const SimpleTable = ({ caption: _caption, classBlock, classModifiers, className, data, headings, keys, ...attrs }) => {
8
+ const classes = (0, component_helpers_1.classBuilder)('penultimate-simple-table', classBlock, classModifiers, className);
9
+ const caption = (typeof _caption !== 'string'
10
+ ? _caption
11
+ : _caption && ((0, jsx_runtime_1.jsx)("caption", { className: classes('caption'), children: _caption })));
12
+ return ((0, jsx_runtime_1.jsxs)("table", { ...attrs, className: classes(), children: [caption, (0, jsx_runtime_1.jsx)("thead", { className: classes('head'), children: (0, jsx_runtime_1.jsx)("tr", { className: classes('row'), children: keys.map((k, i) => ((0, jsx_runtime_1.jsx)("th", { scope: "col", className: classes('header'), children: headings[k] }, i))) }) }), (0, jsx_runtime_1.jsx)("tbody", { className: classes('body'), children: data.map((e, io) => ((0, jsx_runtime_1.jsx)("tr", { className: classes('row'), children: keys.map((k, i) => (i === 0
13
+ ? ((0, jsx_runtime_1.jsx)("th", { scope: "row", className: classes('header'), children: e[k] }, i))
14
+ : ((0, jsx_runtime_1.jsx)("td", { className: classes('cell'), children: e[k] }, i)))) }, io))) })] }));
15
+ };
16
+ exports.SimpleTable = SimpleTable;
17
+ exports.default = exports.SimpleTable;
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { classBuilder } from '@react-foundry/component-helpers';
3
+ import '../assets/SimpleTable.scss';
4
+ export const SimpleTable = ({ caption: _caption, classBlock, classModifiers, className, data, headings, keys, ...attrs }) => {
5
+ const classes = classBuilder('penultimate-simple-table', classBlock, classModifiers, className);
6
+ const caption = (typeof _caption !== 'string'
7
+ ? _caption
8
+ : _caption && (_jsx("caption", { className: classes('caption'), children: _caption })));
9
+ return (_jsxs("table", { ...attrs, className: classes(), children: [caption, _jsx("thead", { className: classes('head'), children: _jsx("tr", { className: classes('row'), children: keys.map((k, i) => (_jsx("th", { scope: "col", className: classes('header'), children: headings[k] }, i))) }) }), _jsx("tbody", { className: classes('body'), children: data.map((e, io) => (_jsx("tr", { className: classes('row'), children: keys.map((k, i) => (i === 0
10
+ ? (_jsx("th", { scope: "row", className: classes('header'), children: e[k] }, i))
11
+ : (_jsx("td", { className: classes('cell'), children: e[k] }, i)))) }, io))) })] }));
12
+ };
13
+ export default SimpleTable;
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@react-foundry/simple-table",
3
+ "version": "0.1.0",
4
+ "description": "A simple table for displaying data.",
5
+ "main": "dist/SimpleTable.js",
6
+ "sass": "assets/SimpleTable.scss",
7
+ "exports": {
8
+ ".": {
9
+ "sass": "./assets/SimpleTable.scss",
10
+ "types": "./dist/SimpleTable.d.ts",
11
+ "import": "./dist/SimpleTable.mjs",
12
+ "require": "./dist/SimpleTable.js",
13
+ "default": "./dist/SimpleTable.mjs"
14
+ }
15
+ },
16
+ "files": [
17
+ "/assets",
18
+ "/dist"
19
+ ],
20
+ "author": "Daniel A.C. Martin <npm@daniel-martin.co.uk> (http://daniel-martin.co.uk/)",
21
+ "license": "MIT",
22
+ "keywords": [
23
+ "react-components"
24
+ ],
25
+ "dependencies": {
26
+ "@react-foundry/component-helpers": "^0.1.0"
27
+ },
28
+ "peerDependencies": {
29
+ "@react-foundry/docs-components": "^0.1.0",
30
+ "@storybook/addon-docs": "^9.1.17",
31
+ "react": "^19.2.3"
32
+ },
33
+ "peerDependenciesMeta": {
34
+ "@react-foundry/docs-components": {
35
+ "optional": true
36
+ },
37
+ "@storybook/addon-docs": {
38
+ "optional": true
39
+ }
40
+ },
41
+ "devDependencies": {
42
+ "@types/react": "19.2.9",
43
+ "jest": "30.2.0",
44
+ "jest-environment-jsdom": "30.2.0",
45
+ "ts-jest": "29.4.6",
46
+ "typescript": "5.9.3",
47
+ "@react-foundry/component-test-helpers": "0.1.0"
48
+ },
49
+ "scripts": {
50
+ "test": "NODE_OPTIONS=--experimental-vm-modules jest",
51
+ "build": "npm run build:esm && npm run build:cjs",
52
+ "build:esm": "tsc -m es2022 && find dist -name '*.js' -exec sh -c 'mv \"$0\" \"${0%.js}.mjs\"' {} \\;",
53
+ "build:cjs": "tsc",
54
+ "clean": "rm -rf dist tsconfig.tsbuildinfo"
55
+ },
56
+ "module": "dist/SimpleTable.mjs",
57
+ "typings": "dist/SimpleTable.d.ts"
58
+ }