This repository was archived by the owner on Feb 6, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathTable.js
More file actions
46 lines (43 loc) · 1.34 KB
/
Copy pathTable.js
File metadata and controls
46 lines (43 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import React from 'react';
import { TableHead, TableBody, TableFooter } from './index';
import PropTypes from 'prop-types';
/**
* We can either set default parameter values here, or via Table.defaultProps, as shown in the
* `TableHead, TableBody, TableFooter` components. Default parameters are standard ES6 syntax:
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/default_parameters
*
* defaultProps is a React implementation:
* https://reactjs.org/docs/typechecking-with-proptypes.html
*/
const Table = ({
tableId = '',
tableClass = '',
tableCaption = false,
columnData = [],
tableData = [],
footerData = false
}) => {
return (
<table className={['data', 'table', tableClass].join(' ')} id={tableId}>
{tableCaption && (
<caption className="table-caption">{tableCaption}</caption>
)}
<TableHead columnData={columnData} />
<TableBody columnData={columnData} tableData={tableData} />
<TableFooter
columnData={columnData}
tableData={tableData}
footerData={footerData}
/>
</table>
);
};
Table.propTypes = {
tableId: PropTypes.string,
tableClass: PropTypes.string,
tableCaption: PropTypes.string,
columnData: PropTypes.array.isRequired,
tableData: PropTypes.array.isRequired,
footerData: PropTypes.object
};
export default Table;