react-data-matrix 0.3.4 → 0.3.6
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 +5 -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
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import React, { FC } from "react";
|
|
2
|
-
import { TableDataProps } from "../types";
|
|
3
|
-
|
|
4
|
-
const TableData: FC<TableDataProps> = ({
|
|
5
|
-
data,
|
|
6
|
-
tdStyles = {},
|
|
7
|
-
hasInlineStyles = true,
|
|
8
|
-
customTableDataDynamicIdValue = "",
|
|
9
|
-
}) => {
|
|
10
|
-
const handleCellClick = (tdSelected: TableDataProps["data"]) => {
|
|
11
|
-
alert(
|
|
12
|
-
`${tdSelected?.description}, ${tdSelected?.score_value} \n${tdSelected?.response}`
|
|
13
|
-
);
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const customTdStyles = !tdStyles ? {} : tdStyles;
|
|
17
|
-
const tableDataStyles: React.CSSProperties = hasInlineStyles
|
|
18
|
-
? {
|
|
19
|
-
cursor: "pointer",
|
|
20
|
-
textAlign: "center",
|
|
21
|
-
borderColor: "black",
|
|
22
|
-
borderStyle: "solid",
|
|
23
|
-
borderWidth: `${1}px`,
|
|
24
|
-
backgroundColor: data?.colour,
|
|
25
|
-
...tdStyles,
|
|
26
|
-
}
|
|
27
|
-
: { ...customTdStyles };
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<>
|
|
31
|
-
<td
|
|
32
|
-
style={tableDataStyles}
|
|
33
|
-
onClick={() => handleCellClick(data)}
|
|
34
|
-
id={`react-matrix-dynamic-table-data${
|
|
35
|
-
!customTableDataDynamicIdValue
|
|
36
|
-
? ""
|
|
37
|
-
: `-${customTableDataDynamicIdValue}`
|
|
38
|
-
}`}
|
|
39
|
-
>
|
|
40
|
-
{`${data?.description}`}
|
|
41
|
-
<br />
|
|
42
|
-
{`(${data?.score_value})`}
|
|
43
|
-
</td>
|
|
44
|
-
</>
|
|
45
|
-
);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export default TableData;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
table {
|
|
2
|
-
tbody {
|
|
3
|
-
tr {
|
|
4
|
-
|
|
5
|
-
td,
|
|
6
|
-
th {
|
|
7
|
-
&.green {
|
|
8
|
-
background-color: green;
|
|
9
|
-
|
|
10
|
-
&:hover {
|
|
11
|
-
background-color: #145214;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
&.yellow {
|
|
16
|
-
background-color: yellow;
|
|
17
|
-
|
|
18
|
-
&:hover {
|
|
19
|
-
background-color: #56741b;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
&.orange {
|
|
24
|
-
background-color: orange;
|
|
25
|
-
|
|
26
|
-
&:hover {
|
|
27
|
-
background-color: #8d4718;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
&.red {
|
|
32
|
-
background-color: red;
|
|
33
|
-
|
|
34
|
-
&:hover {
|
|
35
|
-
background-color: #7a0000;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
export const getCustomStyles = (hasStyle: boolean) =>
|
|
2
|
-
!hasStyle ? {} : hasStyle;
|
|
3
|
-
|
|
4
|
-
export const getContainerStyles = (
|
|
5
|
-
hasStyle: boolean,
|
|
6
|
-
styles: React.CSSProperties
|
|
7
|
-
): React.CSSProperties =>
|
|
8
|
-
// if custom styles are passed remove default styles by returning a spread empty object
|
|
9
|
-
!hasStyle
|
|
10
|
-
? { ...getCustomStyles(hasStyle) }
|
|
11
|
-
: {
|
|
12
|
-
top: `${50}%`,
|
|
13
|
-
left: `${50}%`,
|
|
14
|
-
height: `${100}%`,
|
|
15
|
-
textAlign: "center",
|
|
16
|
-
position: "absolute",
|
|
17
|
-
transform: `translate(${-50}%, ${-50}%)`,
|
|
18
|
-
...styles,
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const getTableBoarder = (hasStyle: boolean) =>
|
|
22
|
-
!hasStyle ? {} : { border: `${1}px solid black` };
|
|
23
|
-
|
|
24
|
-
export const getTableStyles = (
|
|
25
|
-
hasStyle: boolean,
|
|
26
|
-
styles: React.CSSProperties
|
|
27
|
-
): React.CSSProperties =>
|
|
28
|
-
!hasStyle
|
|
29
|
-
? { ...getCustomStyles(hasStyle) }
|
|
30
|
-
: { width: `${70}rem`, ...styles };
|
|
31
|
-
|
|
32
|
-
export const getHeaderPrimaryTitleStyles = (
|
|
33
|
-
hasStyle: boolean,
|
|
34
|
-
styles: React.CSSProperties
|
|
35
|
-
): React.CSSProperties =>
|
|
36
|
-
!hasStyle
|
|
37
|
-
? { ...getCustomStyles(hasStyle) }
|
|
38
|
-
: {
|
|
39
|
-
borderWidth: `${0}`,
|
|
40
|
-
padding: `${1}rem ${0} ${1}rem ${0}`,
|
|
41
|
-
...styles,
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export const getHeaderRowStyles = (
|
|
45
|
-
hasStyle: boolean,
|
|
46
|
-
styles: React.CSSProperties
|
|
47
|
-
): React.CSSProperties =>
|
|
48
|
-
!hasStyle
|
|
49
|
-
? { ...getCustomStyles(hasStyle) }
|
|
50
|
-
: {
|
|
51
|
-
borderColor: "black",
|
|
52
|
-
borderStyle: "solid",
|
|
53
|
-
padding: `${10}rem ${0} ${0} ${0}`,
|
|
54
|
-
borderWidth: `${0} ${0} ${0} ${10}px`,
|
|
55
|
-
...styles,
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export const getHeaderTitleStyles = (
|
|
59
|
-
hasStyle: boolean,
|
|
60
|
-
styles: React.CSSProperties
|
|
61
|
-
): React.CSSProperties =>
|
|
62
|
-
!hasStyle
|
|
63
|
-
? { ...getCustomStyles(hasStyle) }
|
|
64
|
-
: {
|
|
65
|
-
padding: `${0} ${0.5}rem ${0} ${0.5}rem`,
|
|
66
|
-
backgroundColor: "light-grey",
|
|
67
|
-
border: `${1}px solid black`,
|
|
68
|
-
...styles,
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export const getHeaderSubTitleStyles = (
|
|
72
|
-
hasStyle: boolean,
|
|
73
|
-
styles: React.CSSProperties
|
|
74
|
-
): React.CSSProperties =>
|
|
75
|
-
!hasStyle
|
|
76
|
-
? { ...getCustomStyles(hasStyle) }
|
|
77
|
-
: { fontSize: `${0.9}em`, fontWeight: "normal", ...styles };
|
package/dist/utils/data.ts
DELETED
|
@@ -1,346 +0,0 @@
|
|
|
1
|
-
import { MatrixData } from "../types";
|
|
2
|
-
|
|
3
|
-
export const data: MatrixData = {
|
|
4
|
-
id: 1,
|
|
5
|
-
matrix_size: 5,
|
|
6
|
-
matrix_name: "React Matrix",
|
|
7
|
-
primary_header_title: "Consequence",
|
|
8
|
-
primary_row_header_title: "Likelihood",
|
|
9
|
-
matrix_description: "Risk Matrix Template",
|
|
10
|
-
|
|
11
|
-
matrix_details: [
|
|
12
|
-
{
|
|
13
|
-
id: 1,
|
|
14
|
-
likelihood: "E",
|
|
15
|
-
consequence: 1,
|
|
16
|
-
position: 5,
|
|
17
|
-
matrix_type: "Risk",
|
|
18
|
-
header_title: "Minor",
|
|
19
|
-
header_sub_title: "Header sub-title/description.",
|
|
20
|
-
row_header_title: "Rare",
|
|
21
|
-
row_header_sub_title: "Row Header sub-title/description.",
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
id: 2,
|
|
25
|
-
position: 5,
|
|
26
|
-
matrix_type: "Risk",
|
|
27
|
-
likelihood: "D",
|
|
28
|
-
consequence: 2,
|
|
29
|
-
header_title: "Moderate",
|
|
30
|
-
header_sub_title: "Header sub-title/description.",
|
|
31
|
-
row_header_title: "Unlikely",
|
|
32
|
-
row_header_sub_title: "Row Header sub-title/description.",
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
id: 3,
|
|
36
|
-
position: 5,
|
|
37
|
-
matrix_type: "Risk",
|
|
38
|
-
likelihood: "C",
|
|
39
|
-
consequence: 3,
|
|
40
|
-
header_title: "Significant",
|
|
41
|
-
header_sub_title: "Header sub-title/description.",
|
|
42
|
-
row_header_title: "Possible",
|
|
43
|
-
row_header_sub_title: "Row Header sub-title/description.",
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
id: 4,
|
|
47
|
-
position: 5,
|
|
48
|
-
matrix_type: "Risk",
|
|
49
|
-
likelihood: "B",
|
|
50
|
-
consequence: 4,
|
|
51
|
-
header_title: "Critical",
|
|
52
|
-
header_sub_title: "Header sub-title/description.",
|
|
53
|
-
row_header_title: "Likely",
|
|
54
|
-
row_header_sub_title: "Row Header sub-title/description.",
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
id: 5,
|
|
58
|
-
position: 5,
|
|
59
|
-
matrix_type: "Risk",
|
|
60
|
-
likelihood: "A",
|
|
61
|
-
consequence: 5,
|
|
62
|
-
header_title: "Catastrophic",
|
|
63
|
-
header_sub_title: "Header sub-title/description.",
|
|
64
|
-
row_header_title: "Almost Certain",
|
|
65
|
-
row_header_sub_title: "Row Header sub-title/description.",
|
|
66
|
-
},
|
|
67
|
-
],
|
|
68
|
-
|
|
69
|
-
matrix_values: [
|
|
70
|
-
{
|
|
71
|
-
id: 26,
|
|
72
|
-
matrix_id: 1,
|
|
73
|
-
description: "low",
|
|
74
|
-
score_value: 1,
|
|
75
|
-
colour: "green",
|
|
76
|
-
position: 1,
|
|
77
|
-
likelihood_descriptor: "E",
|
|
78
|
-
consequence_descriptor: 1,
|
|
79
|
-
response: "Business as usual",
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
id: 27,
|
|
83
|
-
matrix_id: 1,
|
|
84
|
-
description: "low",
|
|
85
|
-
score_value: 2,
|
|
86
|
-
colour: "green",
|
|
87
|
-
position: 6,
|
|
88
|
-
likelihood_descriptor: "D",
|
|
89
|
-
consequence_descriptor: 1,
|
|
90
|
-
response: "Business as usual",
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
id: 28,
|
|
94
|
-
matrix_id: 1,
|
|
95
|
-
description: "low",
|
|
96
|
-
score_value: 3,
|
|
97
|
-
colour: "green",
|
|
98
|
-
position: 2,
|
|
99
|
-
likelihood_descriptor: "E",
|
|
100
|
-
consequence_descriptor: 2,
|
|
101
|
-
response: "Business as usual",
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
id: 29,
|
|
105
|
-
matrix_id: 1,
|
|
106
|
-
description: "low",
|
|
107
|
-
score_value: 4,
|
|
108
|
-
colour: "green",
|
|
109
|
-
position: 11,
|
|
110
|
-
likelihood_descriptor: "C",
|
|
111
|
-
consequence_descriptor: 1,
|
|
112
|
-
response: "Business as usual",
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
id: 30,
|
|
116
|
-
matrix_id: 1,
|
|
117
|
-
description: "low",
|
|
118
|
-
score_value: 5,
|
|
119
|
-
colour: "green",
|
|
120
|
-
position: 7,
|
|
121
|
-
likelihood_descriptor: "D",
|
|
122
|
-
consequence_descriptor: 2,
|
|
123
|
-
response: "Business as usual",
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
id: 31,
|
|
127
|
-
matrix_id: 1,
|
|
128
|
-
description: "low",
|
|
129
|
-
score_value: 6,
|
|
130
|
-
colour: "green",
|
|
131
|
-
position: 3,
|
|
132
|
-
likelihood_descriptor: "E",
|
|
133
|
-
consequence_descriptor: 3,
|
|
134
|
-
response: "Business as usual",
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
id: 32,
|
|
138
|
-
matrix_id: 1,
|
|
139
|
-
description: "medium",
|
|
140
|
-
score_value: 7,
|
|
141
|
-
colour: "yellow",
|
|
142
|
-
position: 16,
|
|
143
|
-
likelihood_descriptor: "B",
|
|
144
|
-
consequence_descriptor: 1,
|
|
145
|
-
response: "Requires routine to periodic monitoring",
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
id: 33,
|
|
149
|
-
matrix_id: 1,
|
|
150
|
-
description: "medium",
|
|
151
|
-
score_value: 8,
|
|
152
|
-
colour: "yellow",
|
|
153
|
-
position: 12,
|
|
154
|
-
likelihood_descriptor: "C",
|
|
155
|
-
consequence_descriptor: 2,
|
|
156
|
-
response: "Requires routine to periodic monitoring",
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
id: 34,
|
|
160
|
-
matrix_id: 1,
|
|
161
|
-
description: "medium",
|
|
162
|
-
score_value: 9,
|
|
163
|
-
colour: "yellow",
|
|
164
|
-
position: 8,
|
|
165
|
-
likelihood_descriptor: "D",
|
|
166
|
-
consequence_descriptor: 3,
|
|
167
|
-
response: "Requires routine to periodic monitoring",
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
id: 35,
|
|
171
|
-
matrix_id: 1,
|
|
172
|
-
description: "medium",
|
|
173
|
-
score_value: 10,
|
|
174
|
-
colour: "yellow",
|
|
175
|
-
position: 4,
|
|
176
|
-
likelihood_descriptor: "E",
|
|
177
|
-
consequence_descriptor: 4,
|
|
178
|
-
response: "Requires routine to periodic monitoring",
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
id: 36,
|
|
182
|
-
matrix_id: 1,
|
|
183
|
-
description: "medium",
|
|
184
|
-
score_value: 11,
|
|
185
|
-
colour: "yellow",
|
|
186
|
-
position: 21,
|
|
187
|
-
likelihood_descriptor: "A",
|
|
188
|
-
consequence_descriptor: 1,
|
|
189
|
-
response: "Requires routine to periodic monitoring",
|
|
190
|
-
},
|
|
191
|
-
{
|
|
192
|
-
id: 37,
|
|
193
|
-
matrix_id: 1,
|
|
194
|
-
description: "high",
|
|
195
|
-
score_value: 12,
|
|
196
|
-
colour: "orange",
|
|
197
|
-
position: 17,
|
|
198
|
-
likelihood_descriptor: "B",
|
|
199
|
-
consequence_descriptor: 2,
|
|
200
|
-
response: "Risk requires targeted management plan",
|
|
201
|
-
},
|
|
202
|
-
{
|
|
203
|
-
id: 38,
|
|
204
|
-
matrix_id: 1,
|
|
205
|
-
description: "high",
|
|
206
|
-
score_value: 13,
|
|
207
|
-
colour: "orange",
|
|
208
|
-
position: 13,
|
|
209
|
-
likelihood_descriptor: "C",
|
|
210
|
-
consequence_descriptor: 3,
|
|
211
|
-
response: "Risk requires targeted management plan",
|
|
212
|
-
},
|
|
213
|
-
{
|
|
214
|
-
id: 39,
|
|
215
|
-
matrix_id: 1,
|
|
216
|
-
description: "high",
|
|
217
|
-
score_value: 14,
|
|
218
|
-
colour: "orange",
|
|
219
|
-
position: 9,
|
|
220
|
-
likelihood_descriptor: "D",
|
|
221
|
-
consequence_descriptor: 4,
|
|
222
|
-
response: "Risk requires targeted management plan",
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
id: 40,
|
|
226
|
-
matrix_id: 1,
|
|
227
|
-
description: "high",
|
|
228
|
-
score_value: 15,
|
|
229
|
-
colour: "orange",
|
|
230
|
-
position: 5,
|
|
231
|
-
likelihood_descriptor: "E",
|
|
232
|
-
consequence_descriptor: 5,
|
|
233
|
-
response: "Risk requires targeted management plan",
|
|
234
|
-
},
|
|
235
|
-
{
|
|
236
|
-
id: 41,
|
|
237
|
-
matrix_id: 1,
|
|
238
|
-
description: "high",
|
|
239
|
-
score_value: 16,
|
|
240
|
-
colour: "orange",
|
|
241
|
-
position: 22,
|
|
242
|
-
likelihood_descriptor: "A",
|
|
243
|
-
consequence_descriptor: 2,
|
|
244
|
-
response: "Risk requires targeted management plan",
|
|
245
|
-
},
|
|
246
|
-
{
|
|
247
|
-
id: 42,
|
|
248
|
-
matrix_id: 1,
|
|
249
|
-
description: "high",
|
|
250
|
-
score_value: 17,
|
|
251
|
-
colour: "orange",
|
|
252
|
-
position: 18,
|
|
253
|
-
likelihood_descriptor: "B",
|
|
254
|
-
consequence_descriptor: 3,
|
|
255
|
-
response: "Risk requires targeted management plan",
|
|
256
|
-
},
|
|
257
|
-
{
|
|
258
|
-
id: 43,
|
|
259
|
-
matrix_id: 1,
|
|
260
|
-
description: "high",
|
|
261
|
-
score_value: 18,
|
|
262
|
-
colour: "orange",
|
|
263
|
-
position: 14,
|
|
264
|
-
likelihood_descriptor: "C",
|
|
265
|
-
consequence_descriptor: 4,
|
|
266
|
-
response: "Risk requires targeted management plan",
|
|
267
|
-
},
|
|
268
|
-
{
|
|
269
|
-
id: 44,
|
|
270
|
-
matrix_id: 1,
|
|
271
|
-
description: "high",
|
|
272
|
-
score_value: 19,
|
|
273
|
-
colour: "orange",
|
|
274
|
-
position: 10,
|
|
275
|
-
likelihood_descriptor: "D",
|
|
276
|
-
consequence_descriptor: 5,
|
|
277
|
-
response: "Risk requires targeted management plan",
|
|
278
|
-
},
|
|
279
|
-
{
|
|
280
|
-
id: 45,
|
|
281
|
-
matrix_id: 1,
|
|
282
|
-
description: "extreme",
|
|
283
|
-
score_value: 20,
|
|
284
|
-
colour: "red",
|
|
285
|
-
position: 23,
|
|
286
|
-
likelihood_descriptor: "A",
|
|
287
|
-
consequence_descriptor: 3,
|
|
288
|
-
response: "Activity should not commence",
|
|
289
|
-
},
|
|
290
|
-
{
|
|
291
|
-
id: 46,
|
|
292
|
-
matrix_id: 1,
|
|
293
|
-
description: "extreme",
|
|
294
|
-
score_value: 21,
|
|
295
|
-
colour: "red",
|
|
296
|
-
position: 19,
|
|
297
|
-
likelihood_descriptor: "B",
|
|
298
|
-
consequence_descriptor: 4,
|
|
299
|
-
response: "Activity should not commence",
|
|
300
|
-
},
|
|
301
|
-
{
|
|
302
|
-
id: 47,
|
|
303
|
-
matrix_id: 1,
|
|
304
|
-
description: "extreme",
|
|
305
|
-
score_value: 22,
|
|
306
|
-
colour: "red",
|
|
307
|
-
position: 15,
|
|
308
|
-
likelihood_descriptor: "C",
|
|
309
|
-
consequence_descriptor: 5,
|
|
310
|
-
response: "Activity should not commence",
|
|
311
|
-
},
|
|
312
|
-
{
|
|
313
|
-
id: 48,
|
|
314
|
-
matrix_id: 1,
|
|
315
|
-
description: "extreme",
|
|
316
|
-
score_value: 23,
|
|
317
|
-
colour: "red",
|
|
318
|
-
position: 24,
|
|
319
|
-
likelihood_descriptor: "A",
|
|
320
|
-
consequence_descriptor: 4,
|
|
321
|
-
response: "Activity should not commence",
|
|
322
|
-
},
|
|
323
|
-
{
|
|
324
|
-
id: 49,
|
|
325
|
-
matrix_id: 1,
|
|
326
|
-
description: "extreme",
|
|
327
|
-
score_value: 24,
|
|
328
|
-
colour: "red",
|
|
329
|
-
position: 20,
|
|
330
|
-
likelihood_descriptor: "B",
|
|
331
|
-
consequence_descriptor: 5,
|
|
332
|
-
response: "Activity should not commence",
|
|
333
|
-
},
|
|
334
|
-
{
|
|
335
|
-
id: 50,
|
|
336
|
-
matrix_id: 1,
|
|
337
|
-
description: "extreme",
|
|
338
|
-
score_value: 25,
|
|
339
|
-
colour: "red",
|
|
340
|
-
position: 25,
|
|
341
|
-
likelihood_descriptor: "A",
|
|
342
|
-
consequence_descriptor: 5,
|
|
343
|
-
response: "Activity should not commence",
|
|
344
|
-
},
|
|
345
|
-
],
|
|
346
|
-
};
|
package/dist/utils/functions.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
export const groupObjectsByProp = <T extends Record<string, any>>(
|
|
2
|
-
array: T[],
|
|
3
|
-
prop: keyof T
|
|
4
|
-
) => {
|
|
5
|
-
const map = new Map<T[keyof T], T[]>(
|
|
6
|
-
Array.from(array, (obj) => [obj[prop], []])
|
|
7
|
-
);
|
|
8
|
-
|
|
9
|
-
array.forEach((obj) => {
|
|
10
|
-
const key = obj[prop];
|
|
11
|
-
if (key !== undefined) {
|
|
12
|
-
const group = map.get(key);
|
|
13
|
-
if (group) {
|
|
14
|
-
group.push(obj);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
return Array.from(map.values());
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
// capitalises first character of each word
|
|
23
|
-
export const capitaliseFirstCharacter = (stringValue: string): string =>
|
|
24
|
-
stringValue.replace(/\b([a-z\s])/g, (string) => string.toUpperCase());
|
|
25
|
-
|
|
26
|
-
// capitalizes entire word
|
|
27
|
-
export const capitaliseString = (stringValue: string): string =>
|
|
28
|
-
stringValue.toUpperCase();
|
|
29
|
-
|
|
30
|
-
export const callAll =
|
|
31
|
-
<T extends (...args: any[]) => void>(...fns: T[]) =>
|
|
32
|
-
(...args: Parameters<T>) =>
|
|
33
|
-
fns.forEach((fn) => fn && fn(...args));
|
|
File without changes
|