react-data-matrix 0.1.9 → 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/package.json +3 -3
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).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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
6
|
"homepage": "https://bronz3beard.github.io/react-matrix",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"scripts": {
|
|
32
32
|
"start": "react-scripts start",
|
|
33
33
|
"build": "rm -rf dist && NODE_ENV=production babel src/lib --out-dir dist --copy-files",
|
|
34
|
-
"build
|
|
34
|
+
"build:og": "react-scripts build",
|
|
35
35
|
"test": "react-scripts test",
|
|
36
36
|
"eject": "react-scripts eject",
|
|
37
|
-
"predeploy": "npm run build",
|
|
37
|
+
"predeploy": "npm run build:og",
|
|
38
38
|
"deploy": "gh-pages -d build"
|
|
39
39
|
},
|
|
40
40
|
"eslintConfig": {
|