react-data-matrix 0.1.8 → 0.2.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/README.md +186 -166
- package/dist/components/matrixHeaders.js +2 -10
- package/dist/components/matrixRows.js +1 -13
- package/dist/components/reactMatrix.js +5 -16
- package/dist/components/tableData.js +3 -12
- package/dist/context/index.js +0 -2
- package/dist/helpers/getStyles.js +4 -20
- package/dist/index.js +0 -2
- package/dist/utils/functions.js +4 -15
- package/package.json +23 -22
package/README.md
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
# React Matrix [](https://badge.fury.io/js/react-data-matrix)
|
|
2
2
|
|
|
3
|
-
[React Matrix Demo](https://react-matrix
|
|
3
|
+
[React Matrix Demo](https://bronz3beard.github.io/react-matrix)
|
|
4
4
|
|
|
5
5
|
React Matrix table shows relationships between two or more variables in a data set in grid format.
|
|
6
6
|
|
|
7
|
-
The most common usage for a table like React Matrix, is to display the
|
|
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.
|
|
8
8
|
|
|
9
9
|
# PR's
|
|
10
|
+
|
|
10
11
|
- 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
|
|
|
12
13
|
# Usage
|
|
13
14
|
|
|
14
|
-
```js
|
|
15
|
+
```js
|
|
15
16
|
import { ReactMatrix } from "react-data-matrix";
|
|
16
17
|
|
|
17
18
|
const App = () => {
|
|
@@ -24,7 +25,8 @@ const App = () => {
|
|
|
24
25
|
```
|
|
25
26
|
|
|
26
27
|
# Expected Data Structure
|
|
27
|
-
|
|
28
|
+
|
|
29
|
+
- 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,
|
|
28
30
|
or an example of how to construct/deconstruct your data objects from your api.
|
|
29
31
|
|
|
30
32
|
```js
|
|
@@ -84,191 +86,209 @@ const App = () => {
|
|
|
84
86
|
# PropTypes
|
|
85
87
|
|
|
86
88
|
```js
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
89
|
+
propTypes = {
|
|
90
|
+
data: PropTypes.shape({
|
|
91
|
+
id: PropTypes.number,
|
|
92
|
+
matrix_name: PropTypes.string,
|
|
93
|
+
matrix_description: PropTypes.string,
|
|
94
|
+
matrix_size: PropTypes.number.isRequired,
|
|
95
|
+
matrix_details: PropTypes.arrayOf(
|
|
96
|
+
PropTypes.shape({
|
|
97
|
+
id: PropTypes.number,
|
|
98
|
+
likelihood: PropTypes.string,
|
|
99
|
+
consequence: PropTypes.number,
|
|
100
|
+
header_title: PropTypes.string,
|
|
101
|
+
header_sub_title: PropTypes.string,
|
|
102
|
+
row_header_title: PropTypes.string,
|
|
103
|
+
row_header_sub_title: PropTypes.string,
|
|
104
|
+
})
|
|
105
|
+
).isRequired,
|
|
106
|
+
|
|
107
|
+
matrix_values: PropTypes.arrayOf(
|
|
108
|
+
PropTypes.shape({
|
|
109
|
+
id: PropTypes.number.isRequired,
|
|
110
|
+
colour: PropTypes.string,
|
|
111
|
+
position: PropTypes.number.isRequired,
|
|
112
|
+
matrix_id: PropTypes.number,
|
|
113
|
+
score_value: PropTypes.number,
|
|
114
|
+
description: PropTypes.string,
|
|
115
|
+
response: PropTypes.string,
|
|
116
|
+
likelihood_descriptor: PropTypes.string.isRequired,
|
|
117
|
+
consequence_descriptor: PropTypes.number,
|
|
118
|
+
})
|
|
119
|
+
).isRequired,
|
|
120
|
+
}).isRequired,
|
|
121
|
+
|
|
122
|
+
hasTableBorder: PropTypes.bool,
|
|
123
|
+
hasInlineStyles: PropTypes.bool,
|
|
124
|
+
hasContainerStyles: PropTypes.bool,
|
|
125
|
+
reverseMatrixValues: PropTypes.bool,
|
|
126
|
+
matrixSizeSelected: PropTypes.number,
|
|
127
|
+
|
|
128
|
+
rowPrimaryUpper: PropTypes.bool,
|
|
129
|
+
headerPrimaryUpper: PropTypes.bool,
|
|
130
|
+
|
|
131
|
+
thRowStyles: PropTypes.shape({}),
|
|
132
|
+
thTitleStyles: PropTypes.shape({}),
|
|
133
|
+
thSubTitleStyles: PropTypes.shape({}),
|
|
134
|
+
thPrimaryTitleStyles: PropTypes.shape({}),
|
|
135
|
+
|
|
136
|
+
trRowStyles: PropTypes.shape({}),
|
|
137
|
+
trTitleStyles: PropTypes.shape({}),
|
|
138
|
+
trSubTitleStyles: PropTypes.shape({}),
|
|
139
|
+
trPrimaryTitleStyles: PropTypes.shape({}),
|
|
140
|
+
|
|
141
|
+
tdStyles: PropTypes.shape({}),
|
|
142
|
+
|
|
143
|
+
customHeaderRowIdValue: PropTypes.string,
|
|
144
|
+
customDynamicHeaderTitleIdValue: PropTypes.string,
|
|
145
|
+
customDynamicSubHeaderTitleIdValue: PropTypes.string,
|
|
146
|
+
|
|
147
|
+
customRowDynamicIdValue: PropTypes.string,
|
|
148
|
+
customRowHeaderDynamicIdValue: PropTypes.string,
|
|
149
|
+
|
|
150
|
+
customTableDataDynamicIdValue: PropTypes.string,
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
defaultProps = {
|
|
154
|
+
hasTableBorder: true,
|
|
155
|
+
rowPrimaryUpper: true,
|
|
156
|
+
hasInlineStyles: true,
|
|
157
|
+
matrixSizeSelected: 5,
|
|
158
|
+
headerPrimaryUpper: true,
|
|
159
|
+
hasContainerStyles: true,
|
|
160
|
+
reverseMatrixValues: true,
|
|
161
|
+
|
|
162
|
+
thRowStyles: {},
|
|
163
|
+
thTitleStyles: {},
|
|
164
|
+
thSubTitleStyles: {},
|
|
165
|
+
thPrimaryTitleStyles: {},
|
|
166
|
+
|
|
167
|
+
trRowStyles: {},
|
|
168
|
+
trTitleStyles: {},
|
|
169
|
+
trSubTitleStyles: {},
|
|
170
|
+
trPrimaryTitleStyles: {},
|
|
171
|
+
|
|
172
|
+
tdStyles: {},
|
|
173
|
+
|
|
174
|
+
matrixName: "",
|
|
175
|
+
matrixDescription: "",
|
|
176
|
+
customHeaderRowIdValue: "",
|
|
177
|
+
customRowDynamicIdValue: "",
|
|
178
|
+
customTableDataDynamicIdValue: "",
|
|
179
|
+
customRowHeaderDynamicIdValue: "",
|
|
180
|
+
customDynamicHeaderTitleIdValue: "",
|
|
181
|
+
customDynamicSubHeaderTitleIdValue: "",
|
|
182
|
+
};
|
|
181
183
|
```
|
|
182
184
|
|
|
183
185
|
# Available Properties
|
|
184
186
|
|
|
185
|
-
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
187
|
+
- **hasInlineStyles**
|
|
188
|
+
- Default is true.
|
|
189
|
+
- If false all inline styles are removed.
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
- **hasTableBorder**
|
|
194
|
+
- Default is true.
|
|
195
|
+
- If false the most outer border is removed.
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
- **hasContainerStyles**
|
|
200
|
+
- Default is true.
|
|
201
|
+
- This will center the matrix in the middle of the page.
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
- **reverseMatrixValues**
|
|
206
|
+
- Default is true.
|
|
207
|
+
- When true the lowest value will be in the bottom left and the highest value will be in the top right, with all sequential values in-between.
|
|
208
|
+
- When false the values will be reversed, lowest value top left highest value bottom right.
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
- **rowPrimaryUpper**
|
|
213
|
+
- Default is true.
|
|
214
|
+
- If false string formatting will be removed.
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
- **headerPrimaryUpper**
|
|
219
|
+
- Default is true.
|
|
220
|
+
- If false string formatting will be removed.
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
- **customHeaderRowIdValue**
|
|
225
|
+
- Default is empty string.
|
|
226
|
+
- can be used to target element through id prop.
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
- **customDynamicHeaderTitleIdValue**
|
|
231
|
+
- Default is empty string.
|
|
232
|
+
- can be used to target element through id prop.
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
- **customDynamicSubHeaderTitleIdValue**
|
|
237
|
+
- Default is empty string.
|
|
238
|
+
- can be used to target element through id prop.
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
- **customRowDynamicIdValue**
|
|
243
|
+
- Default is empty string.
|
|
244
|
+
- can be used to target element through id prop.
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
- **customRowHeaderDynamicIdValue**
|
|
249
|
+
- Default is empty string.
|
|
250
|
+
- can be used to target element through id prop.
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
- **customTableDataDynamicIdValue**
|
|
255
|
+
- Default is empty string.
|
|
256
|
+
- can be used to target element through id prop.
|
|
257
|
+
|
|
258
|
+
---
|
|
246
259
|
|
|
247
260
|
# Styling Properties
|
|
248
261
|
|
|
249
262
|
### Inline
|
|
250
|
-
__These styles can be added to the current styles or,
|
|
251
|
-
if you make ```hasInlineStyles = false```, then add these values with your own styles, you can have full control over styling inline.__
|
|
252
263
|
|
|
253
|
-
|
|
264
|
+
**These styles can be added to the current styles or,
|
|
265
|
+
if you make `hasInlineStyles = false`, then add these values with your own styles, you can have full control over styling inline.**
|
|
266
|
+
|
|
267
|
+
**ReactMatrix**
|
|
268
|
+
|
|
254
269
|
- tableContainerStyles={{}}
|
|
255
270
|
- tableStyles={{}}
|
|
256
271
|
|
|
257
|
-
|
|
272
|
+
**MatrixHeaders**
|
|
273
|
+
|
|
258
274
|
- thRowStyles={{}}
|
|
259
275
|
- thTitleStyles={{}}
|
|
260
276
|
- thSubTitleStyles={{}}
|
|
261
277
|
- thPrimaryTitleStyles={{}}
|
|
262
278
|
|
|
263
|
-
|
|
279
|
+
**MatrixRows**
|
|
280
|
+
|
|
264
281
|
- trRowStyles={{}},
|
|
265
282
|
- trTitleStyles={{}},
|
|
266
283
|
- trSubTitleStyles={{}},
|
|
267
284
|
- trPrimaryTitleStyles={{}},
|
|
268
285
|
|
|
269
|
-
|
|
286
|
+
**TableData**
|
|
287
|
+
|
|
270
288
|
- tdStyles={{}},
|
|
271
289
|
|
|
272
|
-
|
|
290
|
+
---
|
|
291
|
+
|
|
273
292
|
# Create React App
|
|
293
|
+
|
|
274
294
|
- This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
|
|
@@ -1,27 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
require("core-js/modules/es.weak-map.js");
|
|
3
4
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
4
|
-
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.default = void 0;
|
|
9
|
-
|
|
10
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
10
|
var _getStyles = require("../helpers/getStyles");
|
|
13
|
-
|
|
14
11
|
var _functions = require("../utils/functions");
|
|
15
|
-
|
|
16
12
|
var _context = _interopRequireDefault(require("../context"));
|
|
17
|
-
|
|
18
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
20
14
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
|
-
|
|
22
15
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
|
-
|
|
24
16
|
// import "./styles/riskMatrix.scss";
|
|
17
|
+
|
|
25
18
|
const MatrixHeaders = () => {
|
|
26
19
|
const {
|
|
27
20
|
data,
|
|
@@ -69,7 +62,6 @@ const MatrixHeaders = () => {
|
|
|
69
62
|
}, column.header_sub_title));
|
|
70
63
|
})));
|
|
71
64
|
};
|
|
72
|
-
|
|
73
65
|
MatrixHeaders.defaultProps = {
|
|
74
66
|
hasInlineStyles: true,
|
|
75
67
|
headerPrimaryUpper: true,
|
|
@@ -1,30 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
require("core-js/modules/es.weak-map.js");
|
|
3
4
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
4
|
-
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.default = void 0;
|
|
9
|
-
|
|
10
9
|
require("core-js/modules/es.array.reverse.js");
|
|
11
|
-
|
|
12
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
-
|
|
14
11
|
var _getStyles = require("../helpers/getStyles");
|
|
15
|
-
|
|
16
12
|
var _functions = require("../utils/functions");
|
|
17
|
-
|
|
18
13
|
var _tableData = _interopRequireDefault(require("./tableData"));
|
|
19
|
-
|
|
20
14
|
var _context = _interopRequireDefault(require("../context"));
|
|
21
|
-
|
|
22
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
-
|
|
24
16
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
25
|
-
|
|
26
17
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
27
|
-
|
|
28
18
|
const MatrixRows = () => {
|
|
29
19
|
const {
|
|
30
20
|
data,
|
|
@@ -54,7 +44,6 @@ const MatrixRows = () => {
|
|
|
54
44
|
style: rowHeaderPrimaryTitleStyles
|
|
55
45
|
}, rowPrimaryTitle)), valuesArray.map((row, index) => {
|
|
56
46
|
var _data$matrix_details$, _data$matrix_details$2, _data$matrix_details$3, _data$matrix_details$4, _data$matrix_details$5, _data$matrix_details$6;
|
|
57
|
-
|
|
58
47
|
const rowHeaderOrder = reverseMatrixValues ? data.matrix_size - (index + 1) : index;
|
|
59
48
|
return /*#__PURE__*/_react.default.createElement("tr", {
|
|
60
49
|
style: tableRowStyles,
|
|
@@ -77,7 +66,6 @@ const MatrixRows = () => {
|
|
|
77
66
|
}));
|
|
78
67
|
}));
|
|
79
68
|
};
|
|
80
|
-
|
|
81
69
|
MatrixRows.defaultProps = {
|
|
82
70
|
rowPrimaryUpper: true,
|
|
83
71
|
hasInlineStyles: true,
|
|
@@ -1,36 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
require("core-js/modules/es.weak-map.js");
|
|
3
4
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
4
|
-
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.default = void 0;
|
|
9
|
-
|
|
9
|
+
require("core-js/modules/es.symbol.description.js");
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
11
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
12
|
var _getStyles = require("../helpers/getStyles");
|
|
15
|
-
|
|
16
13
|
var _matrixHeaders = _interopRequireDefault(require("./matrixHeaders"));
|
|
17
|
-
|
|
18
14
|
var _matrixRows = _interopRequireDefault(require("./matrixRows"));
|
|
19
|
-
|
|
20
15
|
var _context = _interopRequireDefault(require("../context"));
|
|
21
|
-
|
|
22
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
-
|
|
24
17
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
25
|
-
|
|
26
18
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
27
|
-
|
|
28
19
|
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; }
|
|
29
|
-
|
|
30
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; }
|
|
31
|
-
|
|
32
|
-
function
|
|
33
|
-
|
|
21
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
22
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
23
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
34
24
|
const ReactMatrix = () => {
|
|
35
25
|
const {
|
|
36
26
|
matrixName,
|
|
@@ -51,7 +41,6 @@ const ReactMatrix = () => {
|
|
|
51
41
|
style: _objectSpread(_objectSpread({}, tableElmStyles), tableBorder)
|
|
52
42
|
}, /*#__PURE__*/_react.default.createElement(_matrixHeaders.default, null), /*#__PURE__*/_react.default.createElement(_matrixRows.default, null)));
|
|
53
43
|
};
|
|
54
|
-
|
|
55
44
|
ReactMatrix.defaultProps = {
|
|
56
45
|
tableStyles: {},
|
|
57
46
|
hasTableBorder: true,
|
|
@@ -4,21 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
require("core-js/modules/es.symbol.description.js");
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
11
|
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
|
-
|
|
18
12
|
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
|
-
|
|
20
|
-
function
|
|
21
|
-
|
|
13
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
14
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
15
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
22
16
|
const TableData = props => {
|
|
23
17
|
const {
|
|
24
18
|
data,
|
|
@@ -26,11 +20,9 @@ const TableData = props => {
|
|
|
26
20
|
hasInlineStyles,
|
|
27
21
|
customTableDataDynamicIdValue
|
|
28
22
|
} = props;
|
|
29
|
-
|
|
30
23
|
const handleCellClick = tdSelected => {
|
|
31
24
|
alert("".concat(tdSelected === null || tdSelected === void 0 ? void 0 : tdSelected.description, ", ").concat(tdSelected === null || tdSelected === void 0 ? void 0 : tdSelected.score_value, " \n").concat(tdSelected === null || tdSelected === void 0 ? void 0 : tdSelected.response));
|
|
32
25
|
};
|
|
33
|
-
|
|
34
26
|
const customTdStyles = !tdStyles ? {} : tdStyles;
|
|
35
27
|
const tableDataStyles = hasInlineStyles ? _objectSpread({
|
|
36
28
|
cursor: "pointer",
|
|
@@ -46,7 +38,6 @@ const TableData = props => {
|
|
|
46
38
|
id: "react-matrix-dynamic-table-data".concat(!customTableDataDynamicIdValue ? "" : "-".concat(customTableDataDynamicIdValue))
|
|
47
39
|
}, "".concat(data === null || data === void 0 ? void 0 : data.description), /*#__PURE__*/_react.default.createElement("br", null), "(".concat(data === null || data === void 0 ? void 0 : data.score_value, ")")));
|
|
48
40
|
};
|
|
49
|
-
|
|
50
41
|
TableData.defaultProps = {
|
|
51
42
|
tdStyles: {},
|
|
52
43
|
hasInlineStyles: true,
|
package/dist/context/index.js
CHANGED
|
@@ -4,17 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getTableStyles = exports.getTableBoarder = exports.getHeaderTitleStyles = exports.getHeaderSubTitleStyles = exports.getHeaderRowStyles = exports.getHeaderPrimaryTitleStyles = exports.getCustomStyles = exports.getContainerStyles = void 0;
|
|
7
|
-
|
|
7
|
+
require("core-js/modules/es.symbol.description.js");
|
|
8
8
|
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; }
|
|
9
|
-
|
|
10
9
|
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; }
|
|
11
|
-
|
|
12
|
-
function
|
|
13
|
-
|
|
10
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
12
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
14
13
|
const getCustomStyles = hasStyle => !hasStyle ? {} : hasStyle;
|
|
15
|
-
|
|
16
14
|
exports.getCustomStyles = getCustomStyles;
|
|
17
|
-
|
|
18
15
|
const getContainerStyles = (hasStyle, styles) => !hasStyle ? _objectSpread({}, getCustomStyles(styles)) : _objectSpread({
|
|
19
16
|
top: "".concat(50, "%"),
|
|
20
17
|
left: "".concat(50, "%"),
|
|
@@ -23,48 +20,35 @@ const getContainerStyles = (hasStyle, styles) => !hasStyle ? _objectSpread({}, g
|
|
|
23
20
|
position: "absolute",
|
|
24
21
|
transform: "translate(".concat(-50, "%, ").concat(-50, "%)")
|
|
25
22
|
}, styles);
|
|
26
|
-
|
|
27
23
|
exports.getContainerStyles = getContainerStyles;
|
|
28
|
-
|
|
29
24
|
const getTableBoarder = hasStyle => !hasStyle ? {} : {
|
|
30
25
|
border: "".concat(1, "px solid black")
|
|
31
26
|
};
|
|
32
|
-
|
|
33
27
|
exports.getTableBoarder = getTableBoarder;
|
|
34
|
-
|
|
35
28
|
const getTableStyles = (hasStyle, styles) => !hasStyle ? _objectSpread({}, getCustomStyles(styles)) : _objectSpread({
|
|
36
29
|
width: "".concat(70, "rem")
|
|
37
30
|
}, styles);
|
|
38
|
-
|
|
39
31
|
exports.getTableStyles = getTableStyles;
|
|
40
|
-
|
|
41
32
|
const getHeaderPrimaryTitleStyles = (hasStyle, styles) => !hasStyle ? _objectSpread({}, getCustomStyles(styles)) : _objectSpread({
|
|
42
33
|
borderWidth: "".concat(0),
|
|
43
34
|
padding: "".concat(1, "rem ", 0, " ", 1, "rem ", 0)
|
|
44
35
|
}, styles);
|
|
45
|
-
|
|
46
36
|
exports.getHeaderPrimaryTitleStyles = getHeaderPrimaryTitleStyles;
|
|
47
|
-
|
|
48
37
|
const getHeaderRowStyles = (hasStyle, styles) => !hasStyle ? _objectSpread({}, getCustomStyles(styles)) : _objectSpread({
|
|
49
38
|
borderColor: "black",
|
|
50
39
|
borderStyle: "solid",
|
|
51
40
|
padding: "".concat(10, "rem ", 0, " ", 0, " ", 0),
|
|
52
41
|
borderWidth: "".concat(0, " ", 0, " ", 0, " ", 10, "px")
|
|
53
42
|
}, styles);
|
|
54
|
-
|
|
55
43
|
exports.getHeaderRowStyles = getHeaderRowStyles;
|
|
56
|
-
|
|
57
44
|
const getHeaderTitleStyles = (hasStyle, styles) => !hasStyle ? _objectSpread({}, getCustomStyles(styles)) : _objectSpread({
|
|
58
45
|
padding: "".concat(0, " ", 0.5, "rem ", 0, " ", 0.5, "rem"),
|
|
59
46
|
backgroundColor: "light-grey",
|
|
60
47
|
border: "".concat(1, "px solid black")
|
|
61
48
|
}, styles);
|
|
62
|
-
|
|
63
49
|
exports.getHeaderTitleStyles = getHeaderTitleStyles;
|
|
64
|
-
|
|
65
50
|
const getHeaderSubTitleStyles = (hasStyle, styles) => !hasStyle ? _objectSpread({}, getCustomStyles(styles)) : _objectSpread({
|
|
66
51
|
fontSize: "".concat(0.9, "em"),
|
|
67
52
|
fontWeight: "normal"
|
|
68
53
|
}, styles);
|
|
69
|
-
|
|
70
54
|
exports.getHeaderSubTitleStyles = getHeaderSubTitleStyles;
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,5 @@ Object.defineProperty(exports, "ReactMatrix", {
|
|
|
9
9
|
return _reactMatrix.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
|
|
13
12
|
var _reactMatrix = _interopRequireDefault(require("./components/reactMatrix"));
|
|
14
|
-
|
|
15
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
package/dist/utils/functions.js
CHANGED
|
@@ -4,43 +4,32 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.groupObjectsByProp = exports.capitaliseString = exports.capitaliseFirstCharacter = exports.callAll = void 0;
|
|
7
|
-
|
|
8
7
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
9
|
-
|
|
10
8
|
require("core-js/modules/es.regexp.exec.js");
|
|
11
|
-
|
|
12
9
|
require("core-js/modules/es.string.replace.js");
|
|
13
|
-
|
|
14
10
|
const groupObjectsByProp = (array, prop) => {
|
|
15
11
|
const map = new Map(Array.from(array, obj => [obj[prop], []]));
|
|
16
12
|
array.forEach(obj => map.get(obj[prop]).push(obj));
|
|
17
13
|
return Array.from(map.values());
|
|
18
|
-
};
|
|
19
|
-
|
|
14
|
+
};
|
|
20
15
|
|
|
16
|
+
// capitalises first character of each word
|
|
21
17
|
exports.groupObjectsByProp = groupObjectsByProp;
|
|
18
|
+
const capitaliseFirstCharacter = stringValue => stringValue.replace(/\b([a-z\s])/g, string => string.toUpperCase());
|
|
22
19
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
// capitalizes entire word
|
|
26
21
|
exports.capitaliseFirstCharacter = capitaliseFirstCharacter;
|
|
27
|
-
|
|
28
22
|
const capitaliseString = stringValue => stringValue.toUpperCase();
|
|
29
|
-
|
|
30
23
|
exports.capitaliseString = capitaliseString;
|
|
31
|
-
|
|
32
24
|
const callAll = function callAll() {
|
|
33
25
|
for (var _len = arguments.length, fns = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
34
26
|
fns[_key] = arguments[_key];
|
|
35
27
|
}
|
|
36
|
-
|
|
37
28
|
return function () {
|
|
38
29
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
39
30
|
args[_key2] = arguments[_key2];
|
|
40
31
|
}
|
|
41
|
-
|
|
42
32
|
return fns.forEach(fn => fn && fn(...args));
|
|
43
33
|
};
|
|
44
34
|
};
|
|
45
|
-
|
|
46
35
|
exports.callAll = callAll;
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-data-matrix",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"homepage": "https://github.
|
|
7
|
-
"author": "bronz3beard <exempli.gratia.webdesign@gmail.com> (https://www.
|
|
6
|
+
"homepage": "https://bronz3beard.github.io/react-matrix",
|
|
7
|
+
"author": "bronz3beard <exempli.gratia.webdesign@gmail.com> (https://www.heyrory.com/)",
|
|
8
8
|
"keywords": [
|
|
9
9
|
"data",
|
|
10
10
|
"risk",
|
|
@@ -27,28 +27,15 @@
|
|
|
27
27
|
"url": "git+https://github.com/bronz3beard/react-matrix.git"
|
|
28
28
|
},
|
|
29
29
|
"description": "View structured data in a matrix table (data grid), showing a value located at an X and Y coordinate.",
|
|
30
|
-
"dependencies": {
|
|
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"
|
|
45
|
-
},
|
|
30
|
+
"dependencies": {},
|
|
46
31
|
"scripts": {
|
|
47
32
|
"start": "react-scripts start",
|
|
48
33
|
"build": "rm -rf dist && NODE_ENV=production babel src/lib --out-dir dist --copy-files",
|
|
49
|
-
"build
|
|
34
|
+
"build:og": "react-scripts build",
|
|
50
35
|
"test": "react-scripts test",
|
|
51
|
-
"eject": "react-scripts eject"
|
|
36
|
+
"eject": "react-scripts eject",
|
|
37
|
+
"predeploy": "npm run build:og",
|
|
38
|
+
"deploy": "gh-pages -d build"
|
|
52
39
|
},
|
|
53
40
|
"eslintConfig": {
|
|
54
41
|
"extends": [
|
|
@@ -71,6 +58,20 @@
|
|
|
71
58
|
"devDependencies": {
|
|
72
59
|
"@babel/cli": "^7.15.7",
|
|
73
60
|
"@babel/core": "^7.15.8",
|
|
74
|
-
"@babel/preset-env": "^7.15.8"
|
|
61
|
+
"@babel/preset-env": "^7.15.8",
|
|
62
|
+
"@fortawesome/fontawesome-svg-core": "latest",
|
|
63
|
+
"@fortawesome/free-brands-svg-icons": "latest",
|
|
64
|
+
"@fortawesome/react-fontawesome": "latest",
|
|
65
|
+
"@testing-library/jest-dom": "latest",
|
|
66
|
+
"@testing-library/react": "latest",
|
|
67
|
+
"@testing-library/user-event": "latest",
|
|
68
|
+
"prop-types": "latest",
|
|
69
|
+
"react": "latest",
|
|
70
|
+
"react-data-matrix": "latest",
|
|
71
|
+
"react-dom": "latest",
|
|
72
|
+
"react-scripts": "latest",
|
|
73
|
+
"sass": "latest",
|
|
74
|
+
"web-vitals": "latest",
|
|
75
|
+
"gh-pages": "latest"
|
|
75
76
|
}
|
|
76
77
|
}
|