@cdc/core 4.22.10 → 4.23.1
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/components/AdvancedEditor.js +52 -67
- package/components/ErrorBoundary.jsx +10 -11
- package/components/GlobalContext.jsx +2 -6
- package/components/LegendCircle.jsx +3 -4
- package/components/Loading.jsx +14 -12
- package/components/Waiting.jsx +14 -5
- package/components/elements/Button.jsx +34 -45
- package/components/elements/Card.jsx +1 -1
- package/components/inputs/InputCheckbox.jsx +32 -35
- package/components/inputs/InputGroup.jsx +38 -17
- package/components/inputs/InputSelect.jsx +27 -23
- package/components/inputs/InputText.jsx +9 -25
- package/components/inputs/InputToggle.jsx +29 -33
- package/components/managers/DataDesigner.jsx +87 -64
- package/components/ui/Accordion.jsx +18 -30
- package/components/ui/Icon.jsx +34 -35
- package/components/ui/LoadSpin.jsx +6 -11
- package/components/ui/Modal.jsx +40 -44
- package/components/ui/Overlay.jsx +12 -23
- package/components/ui/OverlayFrame.jsx +1 -5
- package/components/ui/Tooltip.jsx +8 -28
- package/data/colorPalettes.js +29 -266
- package/data/dataDesignerTables.js +107 -107
- package/data/themes.js +13 -13
- package/helpers/CoveMediaControls.js +139 -0
- package/helpers/DataTransform.js +92 -92
- package/helpers/cacheBustingString.js +3 -3
- package/helpers/events.js +5 -6
- package/helpers/fetchRemoteData.js +33 -33
- package/helpers/getViewport.js +15 -15
- package/helpers/numberFromString.js +7 -7
- package/helpers/updatePaletteNames.js +15 -17
- package/helpers/useDataVizClasses.js +38 -35
- package/helpers/validateFipsCodeLength.js +41 -56
- package/package.json +4 -2
- package/styles/_button-section.scss +35 -0
- package/styles/_data-table.scss +39 -27
- package/styles/_global.scss +29 -24
- package/styles/_mixins.scss +12 -12
- package/styles/_reset.scss +85 -16
- package/styles/_variables.scss +5 -5
- package/styles/base.scss +100 -48
- package/styles/heading-colors.scss +6 -2
- package/styles/loading.scss +62 -60
- package/styles/v2/base/_file-selector.scss +2 -2
- package/styles/v2/base/_general.scss +1 -1
- package/styles/v2/base/_reset.scss +2 -2
- package/styles/v2/base/index.scss +4 -4
- package/styles/v2/components/accordion.scss +13 -13
- package/styles/v2/components/button.scss +3 -3
- package/styles/v2/components/card.scss +1 -1
- package/styles/v2/components/data-designer.scss +7 -6
- package/styles/v2/components/editor.scss +52 -51
- package/styles/v2/components/guidance-block.scss +6 -6
- package/styles/v2/components/input/_input-check-radio.scss +7 -7
- package/styles/v2/components/input/_input-group.scss +2 -2
- package/styles/v2/components/input/_input-slider.scss +2 -3
- package/styles/v2/components/input/index.scss +6 -6
- package/styles/v2/components/loadspin.scss +1 -1
- package/styles/v2/components/modal.scss +2 -2
- package/styles/v2/components/overlay.scss +4 -4
- package/styles/v2/layout/_alert.scss +8 -8
- package/styles/v2/layout/_component.scss +1 -1
- package/styles/v2/layout/_data-table.scss +12 -11
- package/styles/v2/layout/_progression.scss +8 -6
- package/styles/v2/layout/index.scss +5 -5
- package/styles/v2/main.scss +7 -7
- package/styles/v2/themes/_color-definitions.scss +77 -24
- package/styles/v2/themes/index.scss +1 -1
- package/styles/v2/utils/_animations.scss +2 -2
- package/styles/v2/utils/_breakpoints.scss +53 -12
- package/styles/v2/utils/_variables.scss +5 -5
- package/styles/v2/utils/index.scss +8 -8
- package/styles/waiting.scss +22 -23
|
@@ -4,40 +4,40 @@ export const DATA_TABLE_VERTICAL = (
|
|
|
4
4
|
<>
|
|
5
5
|
<table>
|
|
6
6
|
<tbody>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
7
|
+
<tr>
|
|
8
|
+
<th>Date</th>
|
|
9
|
+
<th>Value</th>
|
|
10
|
+
<th>...</th>
|
|
11
|
+
</tr>
|
|
12
|
+
<tr>
|
|
13
|
+
<td>01/01/2020</td>
|
|
14
|
+
<td>150</td>
|
|
15
|
+
<td>...</td>
|
|
16
|
+
</tr>
|
|
17
|
+
<tr>
|
|
18
|
+
<td>02/01/2020</td>
|
|
19
|
+
<td>150</td>
|
|
20
|
+
<td>...</td>
|
|
21
|
+
</tr>
|
|
22
22
|
</tbody>
|
|
23
23
|
</table>
|
|
24
24
|
<table>
|
|
25
25
|
<tbody>
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
26
|
+
<tr>
|
|
27
|
+
<th>State</th>
|
|
28
|
+
<th>Value</th>
|
|
29
|
+
<th>...</th>
|
|
30
|
+
</tr>
|
|
31
|
+
<tr>
|
|
32
|
+
<td>Georgia</td>
|
|
33
|
+
<td>150</td>
|
|
34
|
+
<td>...</td>
|
|
35
|
+
</tr>
|
|
36
|
+
<tr>
|
|
37
|
+
<td>Florida</td>
|
|
38
|
+
<td>150</td>
|
|
39
|
+
<td>...</td>
|
|
40
|
+
</tr>
|
|
41
41
|
</tbody>
|
|
42
42
|
</table>
|
|
43
43
|
</>
|
|
@@ -47,34 +47,34 @@ export const DATA_TABLE_HORIZONTAL = (
|
|
|
47
47
|
<>
|
|
48
48
|
<table>
|
|
49
49
|
<tbody>
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
50
|
+
<tr>
|
|
51
|
+
<th>Date</th>
|
|
52
|
+
<td>01/01/2020</td>
|
|
53
|
+
<td>02/01/2020</td>
|
|
54
|
+
<td>...</td>
|
|
55
|
+
</tr>
|
|
56
|
+
<tr>
|
|
57
|
+
<th>Value</th>
|
|
58
|
+
<td>100</td>
|
|
59
|
+
<td>150</td>
|
|
60
|
+
<td>...</td>
|
|
61
|
+
</tr>
|
|
62
62
|
</tbody>
|
|
63
63
|
</table>
|
|
64
64
|
<table>
|
|
65
65
|
<tbody>
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
66
|
+
<tr>
|
|
67
|
+
<th>State</th>
|
|
68
|
+
<td>Georgia</td>
|
|
69
|
+
<td>Florida</td>
|
|
70
|
+
<td>...</td>
|
|
71
|
+
</tr>
|
|
72
|
+
<tr>
|
|
73
|
+
<th>Value</th>
|
|
74
|
+
<td>100</td>
|
|
75
|
+
<td>150</td>
|
|
76
|
+
<td>...</td>
|
|
77
|
+
</tr>
|
|
78
78
|
</tbody>
|
|
79
79
|
</table>
|
|
80
80
|
</>
|
|
@@ -83,24 +83,24 @@ export const DATA_TABLE_HORIZONTAL = (
|
|
|
83
83
|
export const DATA_TABLE_SINGLE_ROW = (
|
|
84
84
|
<table>
|
|
85
85
|
<tbody>
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
86
|
+
<tr>
|
|
87
|
+
<th>Date</th>
|
|
88
|
+
<th>Virus 1</th>
|
|
89
|
+
<th>Virus 2</th>
|
|
90
|
+
<th>...</th>
|
|
91
|
+
</tr>
|
|
92
|
+
<tr>
|
|
93
|
+
<td>01/01/2020</td>
|
|
94
|
+
<td>100</td>
|
|
95
|
+
<td>150</td>
|
|
96
|
+
<td>...</td>
|
|
97
|
+
</tr>
|
|
98
|
+
<tr>
|
|
99
|
+
<td>02/01/2020</td>
|
|
100
|
+
<td>15</td>
|
|
101
|
+
<td>20</td>
|
|
102
|
+
<td>...</td>
|
|
103
|
+
</tr>
|
|
104
104
|
</tbody>
|
|
105
105
|
</table>
|
|
106
106
|
)
|
|
@@ -108,41 +108,41 @@ export const DATA_TABLE_SINGLE_ROW = (
|
|
|
108
108
|
export const DATA_TABLE_MULTI_ROW = (
|
|
109
109
|
<table>
|
|
110
110
|
<tbody>
|
|
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
|
-
|
|
111
|
+
<tr>
|
|
112
|
+
<th>Virus</th>
|
|
113
|
+
<th>Date</th>
|
|
114
|
+
<th>Value</th>
|
|
115
|
+
</tr>
|
|
116
|
+
<tr>
|
|
117
|
+
<td>Virus 1</td>
|
|
118
|
+
<td>01/01/2020</td>
|
|
119
|
+
<td>100</td>
|
|
120
|
+
</tr>
|
|
121
|
+
<tr>
|
|
122
|
+
<td>Virus 1</td>
|
|
123
|
+
<td>02/01/2020</td>
|
|
124
|
+
<td>150</td>
|
|
125
|
+
</tr>
|
|
126
|
+
<tr>
|
|
127
|
+
<td>...</td>
|
|
128
|
+
<td>...</td>
|
|
129
|
+
<td>...</td>
|
|
130
|
+
</tr>
|
|
131
|
+
<tr>
|
|
132
|
+
<td>Virus 2</td>
|
|
133
|
+
<td>01/01/2020</td>
|
|
134
|
+
<td>15</td>
|
|
135
|
+
</tr>
|
|
136
|
+
<tr>
|
|
137
|
+
<td>Virus 2</td>
|
|
138
|
+
<td>02/01/2020</td>
|
|
139
|
+
<td>20</td>
|
|
140
|
+
</tr>
|
|
141
|
+
<tr>
|
|
142
|
+
<td>...</td>
|
|
143
|
+
<td>...</td>
|
|
144
|
+
<td>...</td>
|
|
145
|
+
</tr>
|
|
146
146
|
</tbody>
|
|
147
147
|
</table>
|
|
148
148
|
)
|
package/data/themes.js
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
1
|
const themes = {
|
|
2
2
|
'theme-blue': {
|
|
3
|
-
primary:
|
|
3
|
+
primary: '#005eaa',
|
|
4
4
|
secondary: '#88c3ea',
|
|
5
|
-
tertiary:
|
|
5
|
+
tertiary: '#c0e9ff',
|
|
6
6
|
quaternary: '#edf9ff'
|
|
7
7
|
},
|
|
8
8
|
'theme-purple': {
|
|
9
9
|
primary: '#712177',
|
|
10
10
|
secondary: '#b890bb',
|
|
11
11
|
tertiary: '#e3d3e4',
|
|
12
|
-
quaternary: '#f7f2f7'
|
|
12
|
+
quaternary: '#f7f2f7'
|
|
13
13
|
},
|
|
14
14
|
'theme-brown': {
|
|
15
15
|
primary: '#705043',
|
|
16
16
|
secondary: '#ad907b',
|
|
17
17
|
tertiary: '#d7ccc8',
|
|
18
|
-
quaternary: '#f2ebe8'
|
|
18
|
+
quaternary: '#f2ebe8'
|
|
19
19
|
},
|
|
20
20
|
'theme-teal': {
|
|
21
21
|
primary: '#00695c',
|
|
22
22
|
secondary: '#4ebaaa',
|
|
23
23
|
tertiary: '#ceece7',
|
|
24
|
-
quaternary: '#ebf7f5'
|
|
24
|
+
quaternary: '#ebf7f5'
|
|
25
25
|
},
|
|
26
26
|
'theme-pink': {
|
|
27
27
|
primary: '#af4448',
|
|
28
28
|
secondary: '#e57373',
|
|
29
29
|
tertiary: '#ffc2c2',
|
|
30
|
-
quaternary: '#ffe7e7'
|
|
30
|
+
quaternary: '#ffe7e7'
|
|
31
31
|
},
|
|
32
32
|
'theme-orange': {
|
|
33
33
|
primary: '#bb4d00',
|
|
34
34
|
secondary: '#ffad42',
|
|
35
35
|
tertiary: '#ffe97d',
|
|
36
|
-
quaternary: '#fff4cf'
|
|
36
|
+
quaternary: '#fff4cf'
|
|
37
37
|
},
|
|
38
38
|
'theme-slate': {
|
|
39
39
|
primary: '#29434e',
|
|
40
40
|
secondary: '#7e9ba5',
|
|
41
41
|
tertiary: '#b6c6d2',
|
|
42
|
-
quaternary: '#e2e8ed'
|
|
42
|
+
quaternary: '#e2e8ed'
|
|
43
43
|
},
|
|
44
44
|
'theme-indigo': {
|
|
45
45
|
primary: '#26418f',
|
|
46
46
|
secondary: '#92a6dd',
|
|
47
47
|
tertiary: '#dee8ff',
|
|
48
|
-
quaternary: '#f2f6ff'
|
|
48
|
+
quaternary: '#f2f6ff'
|
|
49
49
|
},
|
|
50
50
|
'theme-cyan': {
|
|
51
51
|
primary: '#006778',
|
|
52
52
|
secondary: '#65b0bd',
|
|
53
53
|
tertiary: '#cce5e9',
|
|
54
|
-
quaternary: '#ebf5f6'
|
|
54
|
+
quaternary: '#ebf5f6'
|
|
55
55
|
},
|
|
56
56
|
'theme-green': {
|
|
57
57
|
primary: '#4b830d',
|
|
58
58
|
secondary: '#84bc49',
|
|
59
59
|
tertiary: '#dcedc8',
|
|
60
|
-
quaternary: '#f1f8e9'
|
|
60
|
+
quaternary: '#f1f8e9'
|
|
61
61
|
},
|
|
62
62
|
'theme-amber': {
|
|
63
63
|
primary: '#fbab18',
|
|
64
64
|
secondary: '#ffd54f',
|
|
65
65
|
tertiary: '#ffecb3',
|
|
66
66
|
quaternary: '#fff7e1'
|
|
67
|
-
}
|
|
67
|
+
}
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
export default themes
|
|
70
|
+
export default themes
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import html2pdf from 'html2pdf.js'
|
|
3
|
+
import html2canvas from 'html2canvas'
|
|
4
|
+
|
|
5
|
+
const buttonText = {
|
|
6
|
+
pdf: 'Download PDF',
|
|
7
|
+
image: 'Download Image',
|
|
8
|
+
csv: 'Download Data (CSV)',
|
|
9
|
+
link: 'Link to Dataset'
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const saveImageAs = (uri, filename) => {
|
|
13
|
+
const ie = navigator.userAgent.match(/MSIE\s([\d.]+)/)
|
|
14
|
+
const ie11 = navigator.userAgent.match(/Trident\/7.0/) && navigator.userAgent.match(/rv:11/)
|
|
15
|
+
const ieEdge = navigator.userAgent.match(/Edge/g)
|
|
16
|
+
const ieVer = ie ? ie[1] : ie11 ? 11 : ieEdge ? 12 : -1
|
|
17
|
+
|
|
18
|
+
if (ieVer > -1) {
|
|
19
|
+
const fileAsBlob = new Blob([uri], {
|
|
20
|
+
type: 'image/png'
|
|
21
|
+
})
|
|
22
|
+
window.navigator.msSaveBlob(fileAsBlob, filename)
|
|
23
|
+
} else {
|
|
24
|
+
const link = document.createElement('a')
|
|
25
|
+
if (typeof link.download === 'string') {
|
|
26
|
+
link.href = uri
|
|
27
|
+
link.download = filename
|
|
28
|
+
link.onclick = e => document.body.removeChild(e.target)
|
|
29
|
+
document.body.appendChild(link)
|
|
30
|
+
link.click()
|
|
31
|
+
} else {
|
|
32
|
+
window.open(uri)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const generateMedia = (state, type, elementToCapture) => {
|
|
38
|
+
// Identify Selector
|
|
39
|
+
const baseSvg = document.querySelector(`[data-download-id=${elementToCapture}]`)
|
|
40
|
+
|
|
41
|
+
// Handles different state title locations between components
|
|
42
|
+
// Apparently some packages use state.title where others use state.general.title
|
|
43
|
+
const handleFileName = state => {
|
|
44
|
+
// dashboard titles
|
|
45
|
+
if (state?.dashboard?.title) return state.dashboard.title.replace(/\s+/g, '-').toLowerCase() + '-' + date.getDate() + date.getMonth() + date.getFullYear()
|
|
46
|
+
|
|
47
|
+
// map titles
|
|
48
|
+
if (state?.general?.title) return state.general.title.replace(/\s+/g, '-').toLowerCase() + '-' + date.getDate() + date.getMonth() + date.getFullYear()
|
|
49
|
+
|
|
50
|
+
// chart titles
|
|
51
|
+
if (state?.title) return state.title.replace(/\s+/g, '-').toLowerCase() + '-' + date.getDate() + date.getMonth() + date.getFullYear()
|
|
52
|
+
|
|
53
|
+
return 'no-title'
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Construct filename with timestamp
|
|
57
|
+
const date = new Date()
|
|
58
|
+
const filename = handleFileName(state)
|
|
59
|
+
|
|
60
|
+
switch (type) {
|
|
61
|
+
case 'image':
|
|
62
|
+
html2canvas(baseSvg).then(canvas => {
|
|
63
|
+
saveImageAs(canvas.toDataURL(), filename + '.png')
|
|
64
|
+
})
|
|
65
|
+
return
|
|
66
|
+
case 'pdf':
|
|
67
|
+
let opt = {
|
|
68
|
+
margin: 0.2,
|
|
69
|
+
filename: filename + '.pdf',
|
|
70
|
+
image: { type: 'png' },
|
|
71
|
+
html2canvas: { scale: 2, logging: false },
|
|
72
|
+
jsPDF: { unit: 'in', format: 'letter', orientation: 'portrait' }
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
html2pdf()
|
|
76
|
+
.set(opt)
|
|
77
|
+
.from(baseSvg)
|
|
78
|
+
.save()
|
|
79
|
+
.then(() => {
|
|
80
|
+
generatedImage.remove() // Remove generated png
|
|
81
|
+
baseSvg.style.display = null // Re-display initial svg map
|
|
82
|
+
})
|
|
83
|
+
break
|
|
84
|
+
default:
|
|
85
|
+
console.warn("generateMedia param 2 type must be 'image' or 'pdf'")
|
|
86
|
+
break
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Handles different state theme locations between components
|
|
91
|
+
// Apparently some packages use state.headerColor where others use state.theme
|
|
92
|
+
const handleTheme = state => {
|
|
93
|
+
if (state?.headerColor) return state.headerColor // ie. maps
|
|
94
|
+
if (state?.theme) return state.theme // ie. charts
|
|
95
|
+
return 'theme-notFound'
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Download CSV
|
|
99
|
+
const Button = ({ state, text, type, title, elementToCapture }) => {
|
|
100
|
+
const buttonClasses = ['btn', 'btn-download', `${handleTheme(state)}`]
|
|
101
|
+
return (
|
|
102
|
+
<button className={buttonClasses.join(' ')} title={title} onClick={() => generateMedia(state, type, elementToCapture)} style={{ lineHeight: '1.4em' }}>
|
|
103
|
+
{buttonText[type]}
|
|
104
|
+
</button>
|
|
105
|
+
)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Link to CSV/JSON data
|
|
109
|
+
const Link = ({ config }) => {
|
|
110
|
+
// Handles Maps & Charts
|
|
111
|
+
if (config.dataFileSourceType === 'url' && config.dataFileName && config.table.showDownloadUrl) {
|
|
112
|
+
return (
|
|
113
|
+
<a href={config.dataFileName} title={buttonText.link} target='_blank'>
|
|
114
|
+
{buttonText.link}
|
|
115
|
+
</a>
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Handles Dashboards
|
|
120
|
+
return config?.table?.showDownloadUrl && config.dataUrl ? (
|
|
121
|
+
<a href={config.dataUrl} title='Link to view full data set' target='_blank'>
|
|
122
|
+
{buttonText.link}
|
|
123
|
+
</a>
|
|
124
|
+
) : null
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// TODO: convert to standardized COVE section
|
|
128
|
+
const Section = ({ children, classes }) => {
|
|
129
|
+
return <section className={classes.join(' ')}>{children}</section>
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const CoveMediaControls = () => null
|
|
133
|
+
|
|
134
|
+
CoveMediaControls.Section = Section
|
|
135
|
+
CoveMediaControls.Link = Link
|
|
136
|
+
CoveMediaControls.Button = Button
|
|
137
|
+
CoveMediaControls.generateMedia = generateMedia
|
|
138
|
+
|
|
139
|
+
export default CoveMediaControls
|