react-data-matrix 0.1.2 → 0.1.5

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/README.md CHANGED
@@ -1,12 +1,30 @@
1
- # React Matrix
1
+ # React Matrix   [![npm version](https://badge.fury.io/js/react-data-matrix.svg)](https://badge.fury.io/js/react-data-matrix)
2
+
2
3
  [React Matrix Demo](https://react-matrix.herokuapp.com/)
3
4
 
4
5
  React Matrix table shows relationships between two or more variables in a data set in grid format.
5
6
 
6
7
  The most common usage for a table like React Matrix, is to display the __likelihood__ and __consequence__ "scores" of __risks/hazards__, this can be for anything from Corporate, Work Health Safety and Environment risks, and more.
7
8
 
9
+ # PR's
10
+ - Have a look at the [PR template doc](https://github.com/bronz3beard/react-matrix/blob/main/docs) for best approach to getting your pr merged.
11
+
12
+ # Usage
13
+
14
+ ```js
15
+ import { ReactMatrix } from "react-data-matrix";
16
+
17
+ const App = () => {
18
+ ...
19
+
20
+ return (
21
+ <ReactMatrix data={data} {...seeOtherPropsBelow} />
22
+ )
23
+ }
24
+ ```
25
+
8
26
  # Expected Data Structure
9
- - See ```./src/lib/utils/data.js``` for an example of the data, this can be used for testing if needed,
27
+ - See [```./src/lib/utils/data.js```](https://github.com/bronz3beard/react-matrix/blob/main/src/lib/utils/data.js) for an example of the data, this can be used for testing if needed,
10
28
  or an example of how to construct/deconstruct your data objects from your api.
11
29
 
12
30
  ```js
@@ -161,7 +179,7 @@ The most common usage for a table like React Matrix, is to display the __likelih
161
179
  ```
162
180
 
163
181
  # Available Properties
164
- ----
182
+
165
183
  - __hasInlineStyles__
166
184
  * Default is true.
167
185
  * If false all inline styles are removed.
@@ -230,6 +248,10 @@ The most common usage for a table like React Matrix, is to display the __likelih
230
248
  __These styles can be added to the current styles or,
231
249
  if you make ```hasInlineStyles = false```, then add these values with your own styles, you can have full control over styling inline.__
232
250
 
251
+ __ReactMatrix__
252
+ - tableContainerStyles={{}}
253
+ - tableStyles={{}}
254
+
233
255
  __MatrixHeaders__
234
256
  - thRowStyles={{}}
235
257
  - thTitleStyles={{}}
@@ -13,9 +13,9 @@ var _functions = require("../utils/functions");
13
13
 
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
 
16
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
16
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
17
17
 
18
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
18
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
19
19
 
20
20
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
21
21
 
@@ -47,6 +47,7 @@ const MatrixHeaders = props => {
47
47
  }, thRowStyles) : _objectSpread({}, customRowStyles);
48
48
  const customThTitleStyles = !thTitleStyles ? {} : thTitleStyles;
49
49
  const headerTitleStyles = hasInlineStyles ? _objectSpread({
50
+ padding: "".concat(0, " ", 0.5, "rem ", 0, " ", 0.5, "rem"),
50
51
  backgroundColor: "light-grey",
51
52
  border: "".concat(1, "px solid black")
52
53
  }, thTitleStyles) : _objectSpread({}, customThTitleStyles);
@@ -59,27 +60,20 @@ const MatrixHeaders = props => {
59
60
  return /*#__PURE__*/_react.default.createElement("thead", null, /*#__PURE__*/_react.default.createElement("tr", {
60
61
  id: "react-matrix-blank-headers-primary-title-row"
61
62
  }, /*#__PURE__*/_react.default.createElement("th", {
62
- headers: "blank"
63
- }), /*#__PURE__*/_react.default.createElement("th", {
64
- headers: "blank"
65
- }), /*#__PURE__*/_react.default.createElement("th", {
66
- headers: "blank"
67
- }), /*#__PURE__*/_react.default.createElement("th", {
68
- headers: "blank"
63
+ headers: "blank",
64
+ colSpan: "4"
69
65
  }), /*#__PURE__*/_react.default.createElement("th", {
70
66
  style: headerPrimaryTitleStyles,
71
67
  id: "react-matrix-header-primary-title"
72
68
  }, headerPrimaryTitle), /*#__PURE__*/_react.default.createElement("th", {
73
- headers: "blank"
74
- }), /*#__PURE__*/_react.default.createElement("th", {
75
- headers: "blank"
69
+ headers: "blank",
70
+ colSpan: "2"
76
71
  })), /*#__PURE__*/_react.default.createElement("tr", {
77
72
  style: headerRowStyles,
78
73
  id: "react-matrix-dynamic-headers-row-".concat(customHeaderRowIdValue)
79
74
  }, /*#__PURE__*/_react.default.createElement("th", {
80
- headers: "blank"
81
- }), /*#__PURE__*/_react.default.createElement("th", {
82
- headers: "blank"
75
+ headers: "blank",
76
+ colSpan: "2"
83
77
  }), data.matrix_details.slice(0, data.matrix_size).map((column, index) => {
84
78
  return /*#__PURE__*/_react.default.createElement("th", {
85
79
  scope: "col",
@@ -17,9 +17,9 @@ var _tableData = _interopRequireDefault(require("./tableData"));
17
17
 
18
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
19
 
20
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
20
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
21
21
 
22
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
22
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
23
23
 
24
24
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
25
25
 
@@ -47,7 +47,7 @@ const MatrixRows = props => {
47
47
  }, customRowStyles) : _objectSpread({}, customRowStyles);
48
48
  const customTitleStyle = !trTitleStyles ? {} : trTitleStyles;
49
49
  const tableRowHeaderTitleStyles = hasInlineStyles ? _objectSpread({
50
- backgroundColor: "light-black",
50
+ padding: "".concat(0, " ", 0.5, "rem ", 0, " ", 0.5, "rem"),
51
51
  border: "".concat(1, "px solid black")
52
52
  }, trTitleStyles) : _objectSpread({}, customTitleStyle);
53
53
  const customSubTitleStyle = !trSubTitleStyles ? {} : trSubTitleStyles;
@@ -15,9 +15,16 @@ var _matrixRows = _interopRequireDefault(require("./matrixRows"));
15
15
 
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
 
18
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
19
+
20
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
21
+
22
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
23
+
18
24
  const ReactMatrix = props => {
19
25
  const {
20
26
  data,
27
+ tableStyles,
21
28
  thRowStyles,
22
29
  trRowStyles,
23
30
  trTitleStyles,
@@ -33,27 +40,34 @@ const ReactMatrix = props => {
33
40
  reverseMatrixValues,
34
41
  thPrimaryTitleStyles,
35
42
  trPrimaryTitleStyles,
43
+ tableContainerStyles,
36
44
  customHeaderRowIdValue,
37
45
  customRowDynamicIdValue,
38
46
  customTableDataDynamicIdValue,
39
47
  customDynamicHeaderTitleIdValue,
40
48
  customDynamicSubHeaderTitleIdValue
41
49
  } = props;
42
- const containerStyles = hasInlineStyles && hasContainerStyles ? {
50
+ const customContainerStyles = !tableContainerStyles ? {} : tableContainerStyles;
51
+ const containerStyles = hasInlineStyles && hasContainerStyles ? _objectSpread({
43
52
  top: "".concat(50, "%"),
44
53
  left: "".concat(50, "%"),
54
+ height: "".concat(100, "%"),
45
55
  textAlign: "center",
46
56
  position: "absolute",
47
57
  transform: "translate(".concat(-50, "%, ").concat(-50, "%)")
48
- } : {};
58
+ }, tableContainerStyles) : _objectSpread({}, customContainerStyles);
49
59
  const tableBorder = hasInlineStyles && hasTableBorder ? {
50
60
  border: "".concat(1, "px solid black")
51
61
  } : {};
62
+ const customTableStyles = !tableStyles ? {} : tableStyles;
63
+ const tableElmStyles = hasInlineStyles && tableStyles ? _objectSpread({
64
+ width: "".concat(70, "rem")
65
+ }, tableStyles) : _objectSpread({}, customTableStyles);
52
66
  return /*#__PURE__*/_react.default.createElement("div", {
53
67
  style: containerStyles
54
68
  }, /*#__PURE__*/_react.default.createElement("h1", null, data.matrix_name), /*#__PURE__*/_react.default.createElement("h4", null, data.matrix_description), /*#__PURE__*/_react.default.createElement("table", {
55
69
  id: "matrix-table",
56
- style: tableBorder
70
+ style: _objectSpread(_objectSpread({}, tableElmStyles), tableBorder)
57
71
  }, /*#__PURE__*/_react.default.createElement(_matrixHeaders.default, {
58
72
  data: data,
59
73
  thRowStyles: thRowStyles,
@@ -89,6 +103,8 @@ ReactMatrix.defaultProps = {
89
103
  headerPrimaryUpper: true,
90
104
  hasContainerStyles: true,
91
105
  reverseMatrixValues: true,
106
+ tableContainerStyles: {},
107
+ tableStyles: {},
92
108
  thRowStyles: {},
93
109
  thTitleStyles: {},
94
110
  thSubTitleStyles: {},
@@ -139,6 +155,8 @@ ReactMatrix.propTypes = {
139
155
  matrixSizeSelected: _propTypes.default.number,
140
156
  rowPrimaryUpper: _propTypes.default.bool,
141
157
  headerPrimaryUpper: _propTypes.default.bool,
158
+ tableContainerStyles: _propTypes.default.shape({}),
159
+ tableStyles: _propTypes.default.shape({}),
142
160
  thRowStyles: _propTypes.default.shape({}),
143
161
  thTitleStyles: _propTypes.default.shape({}),
144
162
  thSubTitleStyles: _propTypes.default.shape({}),
@@ -13,9 +13,9 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
13
13
 
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
 
16
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
16
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
17
17
 
18
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
18
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
19
19
 
20
20
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
21
21
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-data-matrix",
3
- "version": "0.1.2",
3
+ "version": "0.1.5",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/bronz3beard/react-matrix",
@@ -12,7 +12,9 @@
12
12
  "matrix",
13
13
  "react",
14
14
  "table",
15
- "data table"
15
+ "data table",
16
+ "data grid",
17
+ "data matrix"
16
18
  ],
17
19
  "main": "dist/index.js",
18
20
  "module": "dist/index.js",
@@ -26,16 +28,20 @@
26
28
  },
27
29
  "description": "View structured data in a matrix table (data grid), showing a value located at an X and Y coordinate.",
28
30
  "dependencies": {
29
- "@babel/polyfill": "^7.12.1",
30
- "@testing-library/jest-dom": "^5.11.4",
31
- "@testing-library/react": "^11.1.0",
32
- "@testing-library/user-event": "^12.1.10",
33
- "prop-types": "^15.7.2",
34
- "react": "^17.0.2",
35
- "react-dom": "^17.0.2",
36
- "react-scripts": "4.0.3",
37
- "sass": "^1.42.1",
38
- "web-vitals": "^1.0.1"
31
+ "@babel/polyfill": "latest",
32
+ "@fortawesome/fontawesome-svg-core": "latest",
33
+ "@fortawesome/free-brands-svg-icons": "latest",
34
+ "@fortawesome/react-fontawesome": "latest",
35
+ "@testing-library/jest-dom": "latest",
36
+ "@testing-library/react": "latest",
37
+ "@testing-library/user-event": "latest",
38
+ "prop-types": "latest",
39
+ "react": "latest",
40
+ "react-data-matrix": "latest",
41
+ "react-dom": "latest",
42
+ "react-scripts": "latest",
43
+ "sass": "latest",
44
+ "web-vitals": "latest"
39
45
  },
40
46
  "scripts": {
41
47
  "start": "react-scripts start",