react-data-matrix 0.3.4 → 0.3.7
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 +1 -1
- package/dist/components/MatrixHeaders.d.ts +4 -0
- package/dist/components/MatrixHeaders.jsx +38 -0
- package/dist/components/MatrixRows.d.ts +4 -0
- package/dist/components/MatrixRows.jsx +48 -0
- package/dist/components/ReactMatrix.d.ts +4 -0
- package/dist/components/ReactMatrix.jsx +42 -0
- package/dist/components/TableData.d.ts +4 -0
- package/dist/components/TableData.jsx +19 -0
- package/dist/helpers/getStyles.d.ts +12 -0
- package/dist/helpers/getStyles.js +16 -0
- package/dist/index.js +1 -0
- package/dist/types/index.d.ts +90 -95
- package/dist/types/index.js +1 -0
- package/dist/utils/data.d.ts +2 -0
- package/dist/utils/data.js +342 -0
- package/dist/utils/functions.d.ts +4 -0
- package/dist/utils/functions.js +18 -0
- package/package.json +6 -3
- package/dist/components/MatrixHeaders.tsx +0 -90
- package/dist/components/MatrixRows.tsx +0 -115
- package/dist/components/ReactMatrix.tsx +0 -75
- package/dist/components/TableData.tsx +0 -48
- package/dist/components/styles/riskMatrix.scss +0 -41
- package/dist/helpers/getStyles.ts +0 -77
- package/dist/utils/data.ts +0 -346
- package/dist/utils/functions.ts +0 -33
- /package/dist/{index.ts → index.d.ts} +0 -0
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
export const data = {
|
|
2
|
+
id: 1,
|
|
3
|
+
matrix_size: 5,
|
|
4
|
+
matrix_name: "React Matrix",
|
|
5
|
+
primary_header_title: "Consequence",
|
|
6
|
+
primary_row_header_title: "Likelihood",
|
|
7
|
+
matrix_description: "Risk Matrix Template",
|
|
8
|
+
matrix_details: [
|
|
9
|
+
{
|
|
10
|
+
id: 1,
|
|
11
|
+
likelihood: "E",
|
|
12
|
+
consequence: 1,
|
|
13
|
+
position: 5,
|
|
14
|
+
matrix_type: "Risk",
|
|
15
|
+
header_title: "Minor",
|
|
16
|
+
header_sub_title: "Header sub-title/description.",
|
|
17
|
+
row_header_title: "Rare",
|
|
18
|
+
row_header_sub_title: "Row Header sub-title/description.",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: 2,
|
|
22
|
+
position: 5,
|
|
23
|
+
matrix_type: "Risk",
|
|
24
|
+
likelihood: "D",
|
|
25
|
+
consequence: 2,
|
|
26
|
+
header_title: "Moderate",
|
|
27
|
+
header_sub_title: "Header sub-title/description.",
|
|
28
|
+
row_header_title: "Unlikely",
|
|
29
|
+
row_header_sub_title: "Row Header sub-title/description.",
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: 3,
|
|
33
|
+
position: 5,
|
|
34
|
+
matrix_type: "Risk",
|
|
35
|
+
likelihood: "C",
|
|
36
|
+
consequence: 3,
|
|
37
|
+
header_title: "Significant",
|
|
38
|
+
header_sub_title: "Header sub-title/description.",
|
|
39
|
+
row_header_title: "Possible",
|
|
40
|
+
row_header_sub_title: "Row Header sub-title/description.",
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
id: 4,
|
|
44
|
+
position: 5,
|
|
45
|
+
matrix_type: "Risk",
|
|
46
|
+
likelihood: "B",
|
|
47
|
+
consequence: 4,
|
|
48
|
+
header_title: "Critical",
|
|
49
|
+
header_sub_title: "Header sub-title/description.",
|
|
50
|
+
row_header_title: "Likely",
|
|
51
|
+
row_header_sub_title: "Row Header sub-title/description.",
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
id: 5,
|
|
55
|
+
position: 5,
|
|
56
|
+
matrix_type: "Risk",
|
|
57
|
+
likelihood: "A",
|
|
58
|
+
consequence: 5,
|
|
59
|
+
header_title: "Catastrophic",
|
|
60
|
+
header_sub_title: "Header sub-title/description.",
|
|
61
|
+
row_header_title: "Almost Certain",
|
|
62
|
+
row_header_sub_title: "Row Header sub-title/description.",
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
matrix_values: [
|
|
66
|
+
{
|
|
67
|
+
id: 26,
|
|
68
|
+
matrix_id: 1,
|
|
69
|
+
description: "low",
|
|
70
|
+
score_value: 1,
|
|
71
|
+
colour: "green",
|
|
72
|
+
position: 1,
|
|
73
|
+
likelihood_descriptor: "E",
|
|
74
|
+
consequence_descriptor: 1,
|
|
75
|
+
response: "Business as usual",
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
id: 27,
|
|
79
|
+
matrix_id: 1,
|
|
80
|
+
description: "low",
|
|
81
|
+
score_value: 2,
|
|
82
|
+
colour: "green",
|
|
83
|
+
position: 6,
|
|
84
|
+
likelihood_descriptor: "D",
|
|
85
|
+
consequence_descriptor: 1,
|
|
86
|
+
response: "Business as usual",
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
id: 28,
|
|
90
|
+
matrix_id: 1,
|
|
91
|
+
description: "low",
|
|
92
|
+
score_value: 3,
|
|
93
|
+
colour: "green",
|
|
94
|
+
position: 2,
|
|
95
|
+
likelihood_descriptor: "E",
|
|
96
|
+
consequence_descriptor: 2,
|
|
97
|
+
response: "Business as usual",
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
id: 29,
|
|
101
|
+
matrix_id: 1,
|
|
102
|
+
description: "low",
|
|
103
|
+
score_value: 4,
|
|
104
|
+
colour: "green",
|
|
105
|
+
position: 11,
|
|
106
|
+
likelihood_descriptor: "C",
|
|
107
|
+
consequence_descriptor: 1,
|
|
108
|
+
response: "Business as usual",
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
id: 30,
|
|
112
|
+
matrix_id: 1,
|
|
113
|
+
description: "low",
|
|
114
|
+
score_value: 5,
|
|
115
|
+
colour: "green",
|
|
116
|
+
position: 7,
|
|
117
|
+
likelihood_descriptor: "D",
|
|
118
|
+
consequence_descriptor: 2,
|
|
119
|
+
response: "Business as usual",
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
id: 31,
|
|
123
|
+
matrix_id: 1,
|
|
124
|
+
description: "low",
|
|
125
|
+
score_value: 6,
|
|
126
|
+
colour: "green",
|
|
127
|
+
position: 3,
|
|
128
|
+
likelihood_descriptor: "E",
|
|
129
|
+
consequence_descriptor: 3,
|
|
130
|
+
response: "Business as usual",
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
id: 32,
|
|
134
|
+
matrix_id: 1,
|
|
135
|
+
description: "medium",
|
|
136
|
+
score_value: 7,
|
|
137
|
+
colour: "yellow",
|
|
138
|
+
position: 16,
|
|
139
|
+
likelihood_descriptor: "B",
|
|
140
|
+
consequence_descriptor: 1,
|
|
141
|
+
response: "Requires routine to periodic monitoring",
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
id: 33,
|
|
145
|
+
matrix_id: 1,
|
|
146
|
+
description: "medium",
|
|
147
|
+
score_value: 8,
|
|
148
|
+
colour: "yellow",
|
|
149
|
+
position: 12,
|
|
150
|
+
likelihood_descriptor: "C",
|
|
151
|
+
consequence_descriptor: 2,
|
|
152
|
+
response: "Requires routine to periodic monitoring",
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
id: 34,
|
|
156
|
+
matrix_id: 1,
|
|
157
|
+
description: "medium",
|
|
158
|
+
score_value: 9,
|
|
159
|
+
colour: "yellow",
|
|
160
|
+
position: 8,
|
|
161
|
+
likelihood_descriptor: "D",
|
|
162
|
+
consequence_descriptor: 3,
|
|
163
|
+
response: "Requires routine to periodic monitoring",
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
id: 35,
|
|
167
|
+
matrix_id: 1,
|
|
168
|
+
description: "medium",
|
|
169
|
+
score_value: 10,
|
|
170
|
+
colour: "yellow",
|
|
171
|
+
position: 4,
|
|
172
|
+
likelihood_descriptor: "E",
|
|
173
|
+
consequence_descriptor: 4,
|
|
174
|
+
response: "Requires routine to periodic monitoring",
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
id: 36,
|
|
178
|
+
matrix_id: 1,
|
|
179
|
+
description: "medium",
|
|
180
|
+
score_value: 11,
|
|
181
|
+
colour: "yellow",
|
|
182
|
+
position: 21,
|
|
183
|
+
likelihood_descriptor: "A",
|
|
184
|
+
consequence_descriptor: 1,
|
|
185
|
+
response: "Requires routine to periodic monitoring",
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
id: 37,
|
|
189
|
+
matrix_id: 1,
|
|
190
|
+
description: "high",
|
|
191
|
+
score_value: 12,
|
|
192
|
+
colour: "orange",
|
|
193
|
+
position: 17,
|
|
194
|
+
likelihood_descriptor: "B",
|
|
195
|
+
consequence_descriptor: 2,
|
|
196
|
+
response: "Risk requires targeted management plan",
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
id: 38,
|
|
200
|
+
matrix_id: 1,
|
|
201
|
+
description: "high",
|
|
202
|
+
score_value: 13,
|
|
203
|
+
colour: "orange",
|
|
204
|
+
position: 13,
|
|
205
|
+
likelihood_descriptor: "C",
|
|
206
|
+
consequence_descriptor: 3,
|
|
207
|
+
response: "Risk requires targeted management plan",
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
id: 39,
|
|
211
|
+
matrix_id: 1,
|
|
212
|
+
description: "high",
|
|
213
|
+
score_value: 14,
|
|
214
|
+
colour: "orange",
|
|
215
|
+
position: 9,
|
|
216
|
+
likelihood_descriptor: "D",
|
|
217
|
+
consequence_descriptor: 4,
|
|
218
|
+
response: "Risk requires targeted management plan",
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
id: 40,
|
|
222
|
+
matrix_id: 1,
|
|
223
|
+
description: "high",
|
|
224
|
+
score_value: 15,
|
|
225
|
+
colour: "orange",
|
|
226
|
+
position: 5,
|
|
227
|
+
likelihood_descriptor: "E",
|
|
228
|
+
consequence_descriptor: 5,
|
|
229
|
+
response: "Risk requires targeted management plan",
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
id: 41,
|
|
233
|
+
matrix_id: 1,
|
|
234
|
+
description: "high",
|
|
235
|
+
score_value: 16,
|
|
236
|
+
colour: "orange",
|
|
237
|
+
position: 22,
|
|
238
|
+
likelihood_descriptor: "A",
|
|
239
|
+
consequence_descriptor: 2,
|
|
240
|
+
response: "Risk requires targeted management plan",
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
id: 42,
|
|
244
|
+
matrix_id: 1,
|
|
245
|
+
description: "high",
|
|
246
|
+
score_value: 17,
|
|
247
|
+
colour: "orange",
|
|
248
|
+
position: 18,
|
|
249
|
+
likelihood_descriptor: "B",
|
|
250
|
+
consequence_descriptor: 3,
|
|
251
|
+
response: "Risk requires targeted management plan",
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
id: 43,
|
|
255
|
+
matrix_id: 1,
|
|
256
|
+
description: "high",
|
|
257
|
+
score_value: 18,
|
|
258
|
+
colour: "orange",
|
|
259
|
+
position: 14,
|
|
260
|
+
likelihood_descriptor: "C",
|
|
261
|
+
consequence_descriptor: 4,
|
|
262
|
+
response: "Risk requires targeted management plan",
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
id: 44,
|
|
266
|
+
matrix_id: 1,
|
|
267
|
+
description: "high",
|
|
268
|
+
score_value: 19,
|
|
269
|
+
colour: "orange",
|
|
270
|
+
position: 10,
|
|
271
|
+
likelihood_descriptor: "D",
|
|
272
|
+
consequence_descriptor: 5,
|
|
273
|
+
response: "Risk requires targeted management plan",
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
id: 45,
|
|
277
|
+
matrix_id: 1,
|
|
278
|
+
description: "extreme",
|
|
279
|
+
score_value: 20,
|
|
280
|
+
colour: "red",
|
|
281
|
+
position: 23,
|
|
282
|
+
likelihood_descriptor: "A",
|
|
283
|
+
consequence_descriptor: 3,
|
|
284
|
+
response: "Activity should not commence",
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
id: 46,
|
|
288
|
+
matrix_id: 1,
|
|
289
|
+
description: "extreme",
|
|
290
|
+
score_value: 21,
|
|
291
|
+
colour: "red",
|
|
292
|
+
position: 19,
|
|
293
|
+
likelihood_descriptor: "B",
|
|
294
|
+
consequence_descriptor: 4,
|
|
295
|
+
response: "Activity should not commence",
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
id: 47,
|
|
299
|
+
matrix_id: 1,
|
|
300
|
+
description: "extreme",
|
|
301
|
+
score_value: 22,
|
|
302
|
+
colour: "red",
|
|
303
|
+
position: 15,
|
|
304
|
+
likelihood_descriptor: "C",
|
|
305
|
+
consequence_descriptor: 5,
|
|
306
|
+
response: "Activity should not commence",
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
id: 48,
|
|
310
|
+
matrix_id: 1,
|
|
311
|
+
description: "extreme",
|
|
312
|
+
score_value: 23,
|
|
313
|
+
colour: "red",
|
|
314
|
+
position: 24,
|
|
315
|
+
likelihood_descriptor: "A",
|
|
316
|
+
consequence_descriptor: 4,
|
|
317
|
+
response: "Activity should not commence",
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
id: 49,
|
|
321
|
+
matrix_id: 1,
|
|
322
|
+
description: "extreme",
|
|
323
|
+
score_value: 24,
|
|
324
|
+
colour: "red",
|
|
325
|
+
position: 20,
|
|
326
|
+
likelihood_descriptor: "B",
|
|
327
|
+
consequence_descriptor: 5,
|
|
328
|
+
response: "Activity should not commence",
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
id: 50,
|
|
332
|
+
matrix_id: 1,
|
|
333
|
+
description: "extreme",
|
|
334
|
+
score_value: 25,
|
|
335
|
+
colour: "red",
|
|
336
|
+
position: 25,
|
|
337
|
+
likelihood_descriptor: "A",
|
|
338
|
+
consequence_descriptor: 5,
|
|
339
|
+
response: "Activity should not commence",
|
|
340
|
+
},
|
|
341
|
+
],
|
|
342
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const groupObjectsByProp: <T extends Record<string, any>>(array: T[], prop: keyof T) => T[][];
|
|
2
|
+
export declare const capitaliseFirstCharacter: (stringValue: string) => string;
|
|
3
|
+
export declare const capitaliseString: (stringValue: string) => string;
|
|
4
|
+
export declare const callAll: <T extends (...args: any[]) => void>(...fns: T[]) => (...args: Parameters<T>) => void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const groupObjectsByProp = (array, prop) => {
|
|
2
|
+
const map = new Map(Array.from(array, (obj) => [obj[prop], []]));
|
|
3
|
+
array.forEach((obj) => {
|
|
4
|
+
const key = obj[prop];
|
|
5
|
+
if (key !== undefined) {
|
|
6
|
+
const group = map.get(key);
|
|
7
|
+
if (group) {
|
|
8
|
+
group.push(obj);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
return Array.from(map.values());
|
|
13
|
+
};
|
|
14
|
+
// capitalises first character of each word
|
|
15
|
+
export const capitaliseFirstCharacter = (stringValue) => stringValue.replace(/\b([a-z\s])/g, (string) => string.toUpperCase());
|
|
16
|
+
// capitalizes entire word
|
|
17
|
+
export const capitaliseString = (stringValue) => stringValue.toUpperCase();
|
|
18
|
+
export const callAll = (...fns) => (...args) => fns.forEach((fn) => fn && fn(...args));
|
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-data-matrix",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"types": "./lib/types/index.d.ts",
|
|
3
|
+
"version": "0.3.7",
|
|
5
4
|
"private": false,
|
|
6
5
|
"license": "MIT",
|
|
7
6
|
"homepage": "https://bronz3beard.github.io/react-matrix",
|
|
@@ -34,7 +33,8 @@
|
|
|
34
33
|
"description": "View structured data in a matrix table (data grid), showing a value located at an X and Y coordinate.",
|
|
35
34
|
"scripts": {
|
|
36
35
|
"start": "react-scripts start",
|
|
37
|
-
"build": "rm -rf dist && NODE_ENV=production
|
|
36
|
+
"build": "rm -rf dist && NODE_ENV=production tsc",
|
|
37
|
+
"babel": "babel src/lib --out-dir dist --copy-files",
|
|
38
38
|
"build:og": "react-scripts build",
|
|
39
39
|
"test": "react-scripts test",
|
|
40
40
|
"eject": "react-scripts eject",
|
|
@@ -79,5 +79,8 @@
|
|
|
79
79
|
"sass": "latest",
|
|
80
80
|
"typescript": "latest",
|
|
81
81
|
"web-vitals": "latest"
|
|
82
|
+
},
|
|
83
|
+
"dependencies": {
|
|
84
|
+
"react-data-matrix": "^0.3.6"
|
|
82
85
|
}
|
|
83
86
|
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import React, { FC } from "react";
|
|
2
|
-
import {
|
|
3
|
-
getHeaderRowStyles,
|
|
4
|
-
getHeaderTitleStyles,
|
|
5
|
-
getHeaderSubTitleStyles,
|
|
6
|
-
getHeaderPrimaryTitleStyles,
|
|
7
|
-
} from "../helpers/getStyles";
|
|
8
|
-
import { capitaliseString } from "../utils/functions";
|
|
9
|
-
import { MatrixHeaderProps } from "../types";
|
|
10
|
-
// import "./styles/riskMatrix.scss";
|
|
11
|
-
|
|
12
|
-
const MatrixHeaders: FC<MatrixHeaderProps> = ({
|
|
13
|
-
data,
|
|
14
|
-
hasInlineStyles = true,
|
|
15
|
-
headerPrimaryUpper = true,
|
|
16
|
-
thRowStyles = {},
|
|
17
|
-
thTitleStyles = {},
|
|
18
|
-
thSubTitleStyles = {},
|
|
19
|
-
thPrimaryTitleStyles = {},
|
|
20
|
-
customHeaderRowIdValue = "",
|
|
21
|
-
customDynamicHeaderTitleIdValue = "",
|
|
22
|
-
customDynamicSubHeaderTitleIdValue = "",
|
|
23
|
-
}: MatrixHeaderProps) => {
|
|
24
|
-
const headerRowStyles = getHeaderRowStyles(hasInlineStyles, thRowStyles);
|
|
25
|
-
const headerTitleStyles = getHeaderTitleStyles(
|
|
26
|
-
hasInlineStyles,
|
|
27
|
-
thTitleStyles
|
|
28
|
-
);
|
|
29
|
-
const headerSubTitleStyles = getHeaderSubTitleStyles(
|
|
30
|
-
hasInlineStyles,
|
|
31
|
-
thSubTitleStyles
|
|
32
|
-
);
|
|
33
|
-
const headerPrimaryTitleStyles = getHeaderPrimaryTitleStyles(
|
|
34
|
-
hasInlineStyles,
|
|
35
|
-
thPrimaryTitleStyles
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
const headerPrimaryTitle = !headerPrimaryUpper
|
|
39
|
-
? capitaliseString(data?.primary_header_title)
|
|
40
|
-
: data?.primary_header_title;
|
|
41
|
-
|
|
42
|
-
return (
|
|
43
|
-
<thead>
|
|
44
|
-
<tr id="react-matrix-blank-headers-primary-title-row">
|
|
45
|
-
<th headers="blank" colSpan={4}></th>
|
|
46
|
-
<th
|
|
47
|
-
style={headerPrimaryTitleStyles}
|
|
48
|
-
id="react-matrix-header-primary-title"
|
|
49
|
-
>
|
|
50
|
-
{headerPrimaryTitle}
|
|
51
|
-
</th>
|
|
52
|
-
<th headers="blank" colSpan={2}></th>
|
|
53
|
-
</tr>
|
|
54
|
-
<tr
|
|
55
|
-
style={headerRowStyles}
|
|
56
|
-
id={`react-matrix-dynamic-headers-row-${customHeaderRowIdValue}`}
|
|
57
|
-
>
|
|
58
|
-
<th headers="blank" colSpan={2}></th>
|
|
59
|
-
{data.matrix_details.slice(0, data.matrix_size).map((column, index) => {
|
|
60
|
-
return (
|
|
61
|
-
<th
|
|
62
|
-
scope="col"
|
|
63
|
-
style={headerTitleStyles}
|
|
64
|
-
id={`react-matrix-dynamic-column-header-title${
|
|
65
|
-
!customDynamicHeaderTitleIdValue
|
|
66
|
-
? ""
|
|
67
|
-
: `-${customDynamicHeaderTitleIdValue}`
|
|
68
|
-
}`}
|
|
69
|
-
key={`${column.id}-${index}`}
|
|
70
|
-
>
|
|
71
|
-
{column.header_title}
|
|
72
|
-
<div
|
|
73
|
-
style={headerSubTitleStyles}
|
|
74
|
-
id={`react-matrix-dynamic-column-header-sub-title${
|
|
75
|
-
!customDynamicSubHeaderTitleIdValue
|
|
76
|
-
? ""
|
|
77
|
-
: `-${customDynamicSubHeaderTitleIdValue}`
|
|
78
|
-
}`}
|
|
79
|
-
>
|
|
80
|
-
{column.header_sub_title}
|
|
81
|
-
</div>
|
|
82
|
-
</th>
|
|
83
|
-
);
|
|
84
|
-
})}
|
|
85
|
-
</tr>
|
|
86
|
-
</thead>
|
|
87
|
-
);
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
export default MatrixHeaders;
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import React, { FC } from "react";
|
|
2
|
-
import {
|
|
3
|
-
getHeaderRowStyles,
|
|
4
|
-
getHeaderTitleStyles,
|
|
5
|
-
getHeaderSubTitleStyles,
|
|
6
|
-
getHeaderPrimaryTitleStyles,
|
|
7
|
-
} from "../helpers/getStyles";
|
|
8
|
-
import { groupObjectsByProp, capitaliseString } from "../utils/functions";
|
|
9
|
-
import TableData from "./TableData";
|
|
10
|
-
import { MatrixRowsProps, MatrixValue } from "../types";
|
|
11
|
-
|
|
12
|
-
const MatrixRows: FC<MatrixRowsProps> = ({
|
|
13
|
-
data,
|
|
14
|
-
rowPrimaryUpper = true,
|
|
15
|
-
hasInlineStyles = true,
|
|
16
|
-
reverseMatrixValues = true,
|
|
17
|
-
trRowStyles = {},
|
|
18
|
-
trTitleStyles = {},
|
|
19
|
-
trSubTitleStyles = {},
|
|
20
|
-
trPrimaryTitleStyles = {},
|
|
21
|
-
tdStyles = {},
|
|
22
|
-
customRowDynamicIdValue = "",
|
|
23
|
-
customRowHeaderDynamicIdValue = "",
|
|
24
|
-
customTableDataDynamicIdValue = "",
|
|
25
|
-
}: MatrixRowsProps) => {
|
|
26
|
-
const valuesArray = reverseMatrixValues
|
|
27
|
-
? groupObjectsByProp(data.matrix_values, "likelihood_descriptor")
|
|
28
|
-
.reverse()
|
|
29
|
-
.slice(0, data.matrix_size)
|
|
30
|
-
: groupObjectsByProp(data.matrix_values, "likelihood_descriptor").slice(
|
|
31
|
-
0,
|
|
32
|
-
data.matrix_size
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
const tableRowStyles = getHeaderRowStyles(hasInlineStyles, trRowStyles);
|
|
36
|
-
const tableRowHeaderTitleStyles = getHeaderTitleStyles(
|
|
37
|
-
hasInlineStyles,
|
|
38
|
-
trTitleStyles
|
|
39
|
-
);
|
|
40
|
-
const tableRowHeaderSubTitleStyles = getHeaderSubTitleStyles(
|
|
41
|
-
hasInlineStyles,
|
|
42
|
-
trSubTitleStyles
|
|
43
|
-
);
|
|
44
|
-
const rowHeaderPrimaryTitleStyles = getHeaderPrimaryTitleStyles(
|
|
45
|
-
hasInlineStyles,
|
|
46
|
-
trPrimaryTitleStyles
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
const rowPrimaryTitle = rowPrimaryUpper
|
|
50
|
-
? capitaliseString(data.primary_row_header_title)
|
|
51
|
-
: data.primary_row_header_title;
|
|
52
|
-
|
|
53
|
-
return (
|
|
54
|
-
<tbody>
|
|
55
|
-
<tr id="react-matrix-row-primary-title">
|
|
56
|
-
<th scope="row" rowSpan={6} style={rowHeaderPrimaryTitleStyles}>
|
|
57
|
-
{rowPrimaryTitle}
|
|
58
|
-
</th>
|
|
59
|
-
</tr>
|
|
60
|
-
{valuesArray.map((row, index) => {
|
|
61
|
-
const rowHeaderOrder = reverseMatrixValues
|
|
62
|
-
? data.matrix_size - (index + 1)
|
|
63
|
-
: index;
|
|
64
|
-
|
|
65
|
-
return (
|
|
66
|
-
<tr
|
|
67
|
-
style={tableRowStyles}
|
|
68
|
-
key={`row-${index}`}
|
|
69
|
-
id={`react-matrix-dynamic-rows-${
|
|
70
|
-
data.matrix_details[rowHeaderOrder]?.row_header_title
|
|
71
|
-
}-${data.matrix_details[rowHeaderOrder]?.row_header_sub_title}${
|
|
72
|
-
!customRowDynamicIdValue ? "" : `-${customRowDynamicIdValue}`
|
|
73
|
-
}`}
|
|
74
|
-
>
|
|
75
|
-
<th
|
|
76
|
-
scope="row"
|
|
77
|
-
style={tableRowHeaderTitleStyles}
|
|
78
|
-
id={`react-matrix-dynamic-rows-${
|
|
79
|
-
data.matrix_details[rowHeaderOrder]?.row_header_title
|
|
80
|
-
}-${data.matrix_details[rowHeaderOrder]?.row_header_sub_title}${
|
|
81
|
-
!customRowHeaderDynamicIdValue
|
|
82
|
-
? ""
|
|
83
|
-
: `-${customRowHeaderDynamicIdValue}`
|
|
84
|
-
}`}
|
|
85
|
-
>
|
|
86
|
-
{data.matrix_details[rowHeaderOrder]?.row_header_title}
|
|
87
|
-
<div style={tableRowHeaderSubTitleStyles}>
|
|
88
|
-
{data.matrix_details[rowHeaderOrder]?.row_header_sub_title}
|
|
89
|
-
</div>
|
|
90
|
-
</th>
|
|
91
|
-
{row
|
|
92
|
-
.slice(0, data.matrix_size)
|
|
93
|
-
.map((item: MatrixValue, index: number) => {
|
|
94
|
-
return (
|
|
95
|
-
<TableData
|
|
96
|
-
data={item}
|
|
97
|
-
tdStyles={tdStyles}
|
|
98
|
-
key={`${item.id}-${index}`}
|
|
99
|
-
hasInlineStyles={hasInlineStyles}
|
|
100
|
-
customTableDataDynamicIdValue={
|
|
101
|
-
customTableDataDynamicIdValue
|
|
102
|
-
}
|
|
103
|
-
/>
|
|
104
|
-
);
|
|
105
|
-
})}
|
|
106
|
-
</tr>
|
|
107
|
-
);
|
|
108
|
-
})}
|
|
109
|
-
</tbody>
|
|
110
|
-
);
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
MatrixRows.defaultProps = {};
|
|
114
|
-
|
|
115
|
-
export default MatrixRows;
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import React, { FC } from "react";
|
|
2
|
-
import {
|
|
3
|
-
getTableStyles,
|
|
4
|
-
getTableBoarder,
|
|
5
|
-
getContainerStyles,
|
|
6
|
-
} from "../helpers/getStyles";
|
|
7
|
-
import MatrixHeaders from "./MatrixHeaders";
|
|
8
|
-
import MatrixRows from "./MatrixRows";
|
|
9
|
-
import { ReactMatrixProps } from "../types";
|
|
10
|
-
|
|
11
|
-
const ReactMatrix: FC<ReactMatrixProps> = ({
|
|
12
|
-
data,
|
|
13
|
-
matrixName,
|
|
14
|
-
tableStyles: contextTableStyles,
|
|
15
|
-
hasTableBorder: contextHasTableBorder,
|
|
16
|
-
hasInlineStyles: contextHasInlineStyles,
|
|
17
|
-
matrixDescription,
|
|
18
|
-
hasContainerStyles: contextHasContainerStyles,
|
|
19
|
-
tableContainerStyles: contextTableContainerStyles,
|
|
20
|
-
|
|
21
|
-
tableStyles = {},
|
|
22
|
-
}) => {
|
|
23
|
-
const tableBorder = getTableBoarder(
|
|
24
|
-
!!(contextHasInlineStyles && contextHasTableBorder)
|
|
25
|
-
);
|
|
26
|
-
const tableElmStyles = getTableStyles(
|
|
27
|
-
!!(contextHasInlineStyles && contextTableStyles),
|
|
28
|
-
tableStyles
|
|
29
|
-
);
|
|
30
|
-
const containerStyles = getContainerStyles(
|
|
31
|
-
!!(contextHasInlineStyles && contextHasContainerStyles),
|
|
32
|
-
contextTableContainerStyles ?? {}
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<div style={containerStyles}>
|
|
37
|
-
<h1>{matrixName}</h1>
|
|
38
|
-
<h4>{matrixDescription}</h4>
|
|
39
|
-
<table id="matrix-table" style={{ ...tableElmStyles, ...tableBorder }}>
|
|
40
|
-
<MatrixHeaders
|
|
41
|
-
{...{
|
|
42
|
-
data,
|
|
43
|
-
hasInlineStyles: true,
|
|
44
|
-
headerPrimaryUpper: true,
|
|
45
|
-
thRowStyles: {},
|
|
46
|
-
thTitleStyles: {},
|
|
47
|
-
thSubTitleStyles: {},
|
|
48
|
-
thPrimaryTitleStyles: {},
|
|
49
|
-
customHeaderRowIdValue: "",
|
|
50
|
-
customDynamicHeaderTitleIdValue: "",
|
|
51
|
-
customDynamicSubHeaderTitleIdValue: "",
|
|
52
|
-
}}
|
|
53
|
-
/>
|
|
54
|
-
<MatrixRows
|
|
55
|
-
{...{
|
|
56
|
-
data,
|
|
57
|
-
rowPrimaryUpper: true,
|
|
58
|
-
hasInlineStyles: true,
|
|
59
|
-
reverseMatrixValues: true,
|
|
60
|
-
trRowStyles: {},
|
|
61
|
-
trTitleStyles: {},
|
|
62
|
-
trSubTitleStyles: {},
|
|
63
|
-
trPrimaryTitleStyles: {},
|
|
64
|
-
tdStyles: {},
|
|
65
|
-
customRowDynamicIdValue: "",
|
|
66
|
-
customRowHeaderDynamicIdValue: "",
|
|
67
|
-
customTableDataDynamicIdValue: "",
|
|
68
|
-
}}
|
|
69
|
-
/>
|
|
70
|
-
</table>
|
|
71
|
-
</div>
|
|
72
|
-
);
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export default ReactMatrix;
|