@cdc/core 1.1.4 → 9.22.9
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/LICENSE +201 -0
- package/assets/filtered-text.svg +1 -0
- package/assets/icon-caret-down.svg +3 -0
- package/assets/icon-caret-filled-down.svg +3 -0
- package/assets/icon-caret-filled-up.svg +3 -0
- package/assets/icon-caret-up.svg +3 -0
- package/assets/icon-chart-bar-paired.svg +15 -0
- package/assets/icon-chart-bar-stacked.svg +10 -0
- package/assets/icon-chart-bar.svg +3 -0
- package/assets/icon-chart-line.svg +3 -0
- package/assets/icon-chart-pie.svg +3 -0
- package/assets/icon-check.svg +3 -0
- package/assets/icon-close.svg +3 -1
- package/assets/icon-code.svg +2 -2
- package/assets/icon-dashboard.svg +34 -0
- package/assets/icon-databite.svg +3 -0
- package/assets/icon-edit.svg +3 -0
- package/assets/icon-file-upload.svg +3 -0
- package/assets/icon-filter-bars.svg +5 -0
- package/assets/icon-gear.svg +6 -0
- package/assets/icon-grid.svg +2 -3
- package/assets/icon-info.svg +1 -1
- package/assets/icon-link.svg +3 -0
- package/assets/{alabama-graphic.svg → icon-map-alabama.svg} +2 -2
- package/assets/icon-map-usa.svg +3 -0
- package/assets/icon-map-world.svg +3 -0
- package/assets/icon-minus.svg +3 -0
- package/assets/icon-move.svg +8 -0
- package/assets/icon-plus.svg +3 -0
- package/assets/icon-question-circle.svg +3 -0
- package/assets/icon-tools.svg +8 -0
- package/assets/icon-upload.svg +3 -0
- package/assets/icon-warning-circle.svg +3 -0
- package/assets/{icon-warning.svg → icon-warning-triangle.svg} +1 -1
- package/components/AdvancedEditor.js +1 -1
- package/components/{ErrorBoundary.js → ErrorBoundary.jsx} +0 -0
- package/components/{LegendCircle.js → LegendCircle.jsx} +0 -0
- package/components/{Loading.js → Loading.jsx} +0 -0
- package/components/{Waiting.js → Waiting.jsx} +0 -0
- package/components/elements/Button.jsx +122 -3
- package/components/elements/Card.jsx +13 -0
- package/components/inputs/InputCheckbox.jsx +11 -3
- package/components/inputs/InputGroup.jsx +50 -0
- package/components/inputs/InputSelect.jsx +2 -2
- package/components/inputs/InputText.jsx +17 -18
- package/components/inputs/InputToggle.jsx +18 -18
- package/components/managers/DataDesigner.jsx +171 -0
- package/components/ui/Icon.jsx +50 -12
- package/components/ui/LoadSpin.jsx +24 -0
- package/components/ui/Modal.jsx +7 -2
- package/components/ui/Overlay.jsx +3 -1
- package/components/ui/Tooltip.jsx +18 -9
- package/data/colorPalettes.js +170 -124
- package/data/dataDesignerTables.js +148 -0
- package/{components → helpers}/DataTransform.js +3 -3
- package/helpers/fetchRemoteData.js +43 -0
- package/package.json +3 -2
- package/styles/_data-table.scss +13 -13
- package/styles/_global.scss +14 -0
- package/styles/_reset.scss +11 -1
- package/styles/base.scss +17 -1
- package/styles/v2/base/_file-selector.scss +20 -0
- package/styles/v2/base/_general.scss +9 -22
- package/styles/v2/base/_heading.scss +20 -0
- package/styles/v2/base/_reset.scss +2 -1
- package/styles/v2/base/index.scss +5 -1
- package/styles/v2/components/button.scss +27 -66
- package/styles/v2/components/card.scss +7 -0
- package/styles/v2/components/data-designer.scss +100 -0
- package/styles/v2/components/editor.scss +2 -1
- package/styles/v2/components/guidance-block.scss +74 -0
- package/styles/v2/components/icon.scss +0 -4
- package/styles/v2/components/input/_input-check-radio.scss +97 -0
- package/styles/v2/components/input/_input-group.scss +74 -0
- package/styles/v2/components/input/_input-slider.scss +184 -0
- package/styles/v2/components/input/_input.scss +66 -0
- package/styles/v2/components/input/index.scss +7 -0
- package/styles/v2/components/loadspin.scss +100 -0
- package/styles/v2/components/modal.scss +13 -6
- package/styles/v2/components/overlay.scss +2 -0
- package/styles/v2/layout/_alert.scss +11 -10
- package/styles/v2/layout/_component.scss +8 -1
- package/styles/v2/layout/_data-table.scss +71 -150
- package/styles/v2/layout/_progression.scss +4 -2
- package/styles/v2/layout/index.scss +0 -2
- package/styles/v2/main.scss +52 -2
- package/styles/v2/themes/_color-definitions.scss +31 -1
- package/styles/v2/utils/_align.scss +17 -0
- package/styles/v2/utils/_breakpoints.scss +18 -0
- package/styles/v2/utils/_grid.scss +47 -0
- package/styles/v2/utils/_mixins.scss +0 -16
- package/styles/v2/utils/_spacers.scss +31 -0
- package/styles/v2/utils/_variables.scss +7 -0
- package/styles/v2/utils/index.scss +7 -2
- package/assets/asc.svg +0 -1
- package/assets/chart-bar-solid.svg +0 -1
- package/assets/chart-line-solid.svg +0 -1
- package/assets/chart-pie-solid.svg +0 -1
- package/assets/check.svg +0 -3
- package/assets/dashboard.svg +0 -11
- package/assets/data-bite-graphic.svg +0 -3
- package/assets/desc.svg +0 -1
- package/assets/file-upload-solid.svg +0 -1
- package/assets/horizontal-stacked-bar.svg +0 -1
- package/assets/link.svg +0 -1
- package/assets/minus.svg +0 -1
- package/assets/paired-bar.svg +0 -11
- package/assets/plus.svg +0 -1
- package/assets/question-circle.svg +0 -1
- package/assets/upload-solid.svg +0 -1
- package/assets/usa-graphic.svg +0 -3
- package/assets/world-graphic.svg +0 -3
- package/styles/v2/components/input.scss +0 -372
- package/styles/v2/layout/_header.scss +0 -13
- package/styles/v2/layout/_link.scss +0 -46
package/components/ui/Modal.jsx
CHANGED
|
@@ -42,12 +42,17 @@ const Modal = ({
|
|
|
42
42
|
<div className="cove-modal__header" style={{
|
|
43
43
|
backgroundColor: headerBgColor,
|
|
44
44
|
boxShadow: dividerBorder(modalHeaderChildren && showDividerTop),
|
|
45
|
-
padding: !modalHeaderChildren ? '0' : null
|
|
45
|
+
padding: !modalHeaderChildren ? '0' : null,
|
|
46
|
+
minHeight: !modalHeaderChildren ? 'unset' : null
|
|
46
47
|
}}>
|
|
47
48
|
{modalHeaderChildren && modalHeaderChildren.props.children}
|
|
48
49
|
{showClose &&
|
|
49
50
|
<button className="cove-modal--close"
|
|
50
|
-
onClick={(e) =>
|
|
51
|
+
onClick={(e) => {
|
|
52
|
+
if (override) return override.actions.toggleOverlay(false)
|
|
53
|
+
if (overlay) return overlay?.actions.toggleOverlay(false)
|
|
54
|
+
e.preventDefault()
|
|
55
|
+
}}>
|
|
51
56
|
<Icon display="close"/>
|
|
52
57
|
</button>
|
|
53
58
|
}
|
|
@@ -13,10 +13,11 @@ const Overlay = ({ disableBgClose, children, override = null }) => {
|
|
|
13
13
|
const [ overlayAnimationState, setOverlayAnimationState ] = useState(null)
|
|
14
14
|
const [ overlayErrorState, setOverlayErrorState ] = useState(false)
|
|
15
15
|
|
|
16
|
-
const overlayDisplay =
|
|
16
|
+
const overlayDisplay = override ? override?.show : overlay?.show
|
|
17
17
|
|
|
18
18
|
//Animate In effect
|
|
19
19
|
useEffect(() => {
|
|
20
|
+
if (overlayDisplay === undefined) return
|
|
20
21
|
if (overlayDisplay === false) return //Reject
|
|
21
22
|
|
|
22
23
|
document.body.style.overflow = 'hidden'
|
|
@@ -32,6 +33,7 @@ const Overlay = ({ disableBgClose, children, override = null }) => {
|
|
|
32
33
|
|
|
33
34
|
//Animate Out effect
|
|
34
35
|
useEffect(() => {
|
|
36
|
+
if (overlayDisplay === undefined) return
|
|
35
37
|
if (overlayDisplay === true) return //Reject
|
|
36
38
|
|
|
37
39
|
setOverlayAnimationState('animate-out')
|
|
@@ -6,7 +6,7 @@ const TooltipContent = () => null
|
|
|
6
6
|
|
|
7
7
|
const Tooltip = ({
|
|
8
8
|
position = 'top',
|
|
9
|
-
trigger = 'hover',
|
|
9
|
+
trigger = 'hover focus',
|
|
10
10
|
float = false,
|
|
11
11
|
shadow = true,
|
|
12
12
|
border = null,
|
|
@@ -20,20 +20,29 @@ const Tooltip = ({
|
|
|
20
20
|
const tooltipTargetChildren = children.find(el => el.type === TooltipTarget)
|
|
21
21
|
const tooltipContentChildren = children.find(el => el.type === TooltipContent)
|
|
22
22
|
|
|
23
|
+
|
|
23
24
|
const uid = 'tooltip-' + Math.floor(Math.random() * 100000)
|
|
24
25
|
|
|
25
26
|
return (
|
|
26
27
|
<span className="cove-tooltip" style={style} {...attributes}>
|
|
27
|
-
<
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
<button className="cove-tooltip--target"
|
|
29
|
+
data-for={uid}
|
|
30
|
+
data-place={position}
|
|
31
|
+
data-event={trigger}
|
|
32
|
+
data-effect={float ? 'float' : 'solid'}
|
|
33
|
+
data-scroll-hide={hideOnScroll}
|
|
34
|
+
data-tip
|
|
35
|
+
onClick={e => {
|
|
36
|
+
e.preventDefault()
|
|
37
|
+
}}
|
|
38
|
+
onMouseEnter={ e => ReactTooltip.show(e.target)}
|
|
39
|
+
onMouseLeave={e => ReactTooltip.hide(e.target)}
|
|
40
|
+
onFocus={(e) => ReactTooltip.show(e.target)}
|
|
41
|
+
onBlur={(e) => ReactTooltip.hide(e.target)}
|
|
42
|
+
style={{ background: 'transparent', border: 'none' }}
|
|
34
43
|
>
|
|
35
44
|
{tooltipTargetChildren ? tooltipTargetChildren.props.children : null}
|
|
36
|
-
</
|
|
45
|
+
</button>
|
|
37
46
|
<ReactTooltip
|
|
38
47
|
id={uid}
|
|
39
48
|
className={'cove-tooltip__content' + (trigger === 'click' ? ' interactive' : '') + (border ? (' cove-tooltip--border-' + border) : '') + (shadow ? ' has-shadow' : '')}
|
package/data/colorPalettes.js
CHANGED
|
@@ -1,149 +1,149 @@
|
|
|
1
|
-
import { updatePaletteNames} from
|
|
1
|
+
import { updatePaletteNames } from '../helpers/updatePaletteNames'
|
|
2
2
|
|
|
3
3
|
const colorPalettesMap = {
|
|
4
4
|
yelloworangered: [
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
"#ffffcc",
|
|
6
|
+
"#ffeda0",
|
|
7
|
+
"#fed976",
|
|
8
|
+
"#feb24c",
|
|
9
|
+
"#fd8d3c",
|
|
10
|
+
"#fc4e2a",
|
|
11
|
+
"#e31a1c",
|
|
12
|
+
"#bd0026",
|
|
13
|
+
"#800026",
|
|
14
14
|
],
|
|
15
15
|
yelloworangebrown: [
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
"#ffffe5",
|
|
17
|
+
"#fff7bc",
|
|
18
|
+
"#fee391",
|
|
19
|
+
"#fec44f",
|
|
20
|
+
"#fe9929",
|
|
21
|
+
"#ec7014",
|
|
22
|
+
"#cc4c02",
|
|
23
|
+
"#993404",
|
|
24
|
+
"#662506",
|
|
25
25
|
],
|
|
26
26
|
pinkpurple: [
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
"#fff7f3",
|
|
28
|
+
"#fde0dd",
|
|
29
|
+
"#fcc5c0",
|
|
30
|
+
"#fa9fb5",
|
|
31
|
+
"#f768a1",
|
|
32
|
+
"#dd3497",
|
|
33
|
+
"#ae017e",
|
|
34
|
+
"#7a0177",
|
|
35
|
+
"#49006a",
|
|
36
36
|
],
|
|
37
37
|
bluegreen: [
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
38
|
+
"#fff7fb",
|
|
39
|
+
"#ece2f0",
|
|
40
|
+
"#d0d1e6",
|
|
41
|
+
"#a6bddb",
|
|
42
|
+
"#67a9cf",
|
|
43
|
+
"#3690c0",
|
|
44
|
+
"#02818a",
|
|
45
|
+
"#016c59",
|
|
46
|
+
"#014636",
|
|
47
47
|
],
|
|
48
48
|
orangered: [
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
49
|
+
"#fff7ec",
|
|
50
|
+
"#fee8c8",
|
|
51
|
+
"#fdd49e",
|
|
52
|
+
"#fdbb84",
|
|
53
|
+
"#fc8d59",
|
|
54
|
+
"#ef6548",
|
|
55
|
+
"#d7301f",
|
|
56
|
+
"#b30000",
|
|
57
|
+
"#7f0000",
|
|
58
58
|
],
|
|
59
59
|
red: [
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
60
|
+
"#fff5f0",
|
|
61
|
+
"#fee0d2",
|
|
62
|
+
"#fcbba1",
|
|
63
|
+
"#fc9272",
|
|
64
|
+
"#fb6a4a",
|
|
65
|
+
"#ef3b2c",
|
|
66
|
+
"#cb181d",
|
|
67
|
+
"#a50f15",
|
|
68
|
+
"#67000d",
|
|
69
69
|
],
|
|
70
70
|
greenblue: [
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
71
|
+
"#f7fcf0",
|
|
72
|
+
"#e0f3db",
|
|
73
|
+
"#ccebc5",
|
|
74
|
+
"#a8ddb5",
|
|
75
|
+
"#7bccc4",
|
|
76
|
+
"#4eb3d3",
|
|
77
|
+
"#267BA6",
|
|
78
|
+
"#0868ac",
|
|
79
|
+
"#084081",
|
|
80
80
|
],
|
|
81
81
|
yellowpurple: [
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
82
|
+
"#FFF0B0",
|
|
83
|
+
"#F5CC76",
|
|
84
|
+
"#EDAE4B",
|
|
85
|
+
"#E3683C",
|
|
86
|
+
"#BF2A48",
|
|
87
|
+
"#6D2059",
|
|
88
|
+
"#8F0C4B",
|
|
89
|
+
"#310958",
|
|
90
|
+
"#0E0943",
|
|
91
91
|
],
|
|
92
92
|
qualitative1: [
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
],
|
|
105
|
-
|
|
93
|
+
"#a6cee3",
|
|
94
|
+
"#1f78b4",
|
|
95
|
+
"#b2df8a",
|
|
96
|
+
"#33a02c",
|
|
97
|
+
"#fb9a99",
|
|
98
|
+
"#e31a1c",
|
|
99
|
+
"#6a3d9a",
|
|
100
|
+
"#cab2d6",
|
|
101
|
+
"#E31A90",
|
|
102
|
+
"#15017A",
|
|
103
|
+
"#C2C0FC",
|
|
104
|
+
],
|
|
105
|
+
|
|
106
106
|
qualitative2: [
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
],
|
|
116
|
-
|
|
107
|
+
"#7fc97f",
|
|
108
|
+
"#beaed4",
|
|
109
|
+
"#ff9",
|
|
110
|
+
"#386cb0",
|
|
111
|
+
"#f0027f",
|
|
112
|
+
"#bf5b17",
|
|
113
|
+
"#666",
|
|
114
|
+
"#fedab8",
|
|
115
|
+
],
|
|
116
|
+
|
|
117
117
|
qualitative3: [
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
],
|
|
127
|
-
|
|
118
|
+
"#1b9e77",
|
|
119
|
+
"#d95f02",
|
|
120
|
+
"#7570b3",
|
|
121
|
+
"#e7298a",
|
|
122
|
+
"#66a61e",
|
|
123
|
+
"#e6ab02",
|
|
124
|
+
"#a6761d",
|
|
125
|
+
"#666",
|
|
126
|
+
],
|
|
127
|
+
|
|
128
128
|
qualitative4: [
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
129
|
+
"#e41a1c",
|
|
130
|
+
"#377eb8",
|
|
131
|
+
"#4daf4a",
|
|
132
|
+
"#984ea3",
|
|
133
|
+
"#ff7f00",
|
|
134
|
+
"#ff3",
|
|
135
|
+
"#a65628",
|
|
136
|
+
"#f781bf",
|
|
137
137
|
],
|
|
138
|
-
|
|
138
|
+
|
|
139
139
|
qualitative9: [
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
140
|
+
"#497d0c",
|
|
141
|
+
"#84BC49",
|
|
142
|
+
"#88c3ea",
|
|
143
|
+
"#fcad90",
|
|
144
|
+
"#f26b4f",
|
|
145
|
+
"#c31b1f",
|
|
146
|
+
"#c31b1f",
|
|
147
147
|
],
|
|
148
148
|
|
|
149
149
|
|
|
@@ -188,7 +188,7 @@ const colorPalettes2 = {
|
|
|
188
188
|
'#f781bf',
|
|
189
189
|
'#3399CC',
|
|
190
190
|
],
|
|
191
|
-
|
|
191
|
+
|
|
192
192
|
'qualitative-soft': [
|
|
193
193
|
'#A6CEE3',
|
|
194
194
|
'#1F78B4',
|
|
@@ -200,6 +200,52 @@ const colorPalettes2 = {
|
|
|
200
200
|
'#FF7F00',
|
|
201
201
|
'#ACA9EB',
|
|
202
202
|
],
|
|
203
|
+
qualitative1: [
|
|
204
|
+
"#a6cee3",
|
|
205
|
+
"#1f78b4",
|
|
206
|
+
"#b2df8a",
|
|
207
|
+
"#33a02c",
|
|
208
|
+
"#fb9a99",
|
|
209
|
+
"#e31a1c",
|
|
210
|
+
"#6a3d9a",
|
|
211
|
+
"#cab2d6",
|
|
212
|
+
"#E31A90",
|
|
213
|
+
"#15017A",
|
|
214
|
+
"#C2C0FC",
|
|
215
|
+
],
|
|
216
|
+
|
|
217
|
+
qualitative2: [
|
|
218
|
+
"#7fc97f",
|
|
219
|
+
"#beaed4",
|
|
220
|
+
"#ff9",
|
|
221
|
+
"#386cb0",
|
|
222
|
+
"#f0027f",
|
|
223
|
+
"#bf5b17",
|
|
224
|
+
"#666",
|
|
225
|
+
"#fedab8",
|
|
226
|
+
],
|
|
227
|
+
|
|
228
|
+
qualitative3: [
|
|
229
|
+
"#1b9e77",
|
|
230
|
+
"#d95f02",
|
|
231
|
+
"#7570b3",
|
|
232
|
+
"#e7298a",
|
|
233
|
+
"#66a61e",
|
|
234
|
+
"#e6ab02",
|
|
235
|
+
"#a6761d",
|
|
236
|
+
"#666",
|
|
237
|
+
],
|
|
238
|
+
|
|
239
|
+
qualitative4: [
|
|
240
|
+
"#e41a1c",
|
|
241
|
+
"#377eb8",
|
|
242
|
+
"#4daf4a",
|
|
243
|
+
"#984ea3",
|
|
244
|
+
"#ff7f00",
|
|
245
|
+
"#ff3",
|
|
246
|
+
"#a65628",
|
|
247
|
+
"#f781bf",
|
|
248
|
+
],
|
|
203
249
|
|
|
204
250
|
'sequential-blue': [
|
|
205
251
|
'#C6DBEF',
|
|
@@ -237,4 +283,4 @@ const colorPalettes2 = {
|
|
|
237
283
|
|
|
238
284
|
export const colorPalettesChart = updatePaletteNames(colorPalettes2) // adds reverse keyword to eact palette
|
|
239
285
|
const colorPalettes = updatePaletteNames(colorPalettesMap) // adds reverse keyword to eact palette
|
|
240
|
-
export default colorPalettes
|
|
286
|
+
export default colorPalettes
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
export const DATA_TABLE_VERTICAL = (
|
|
4
|
+
<>
|
|
5
|
+
<table>
|
|
6
|
+
<tbody>
|
|
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
|
+
</tbody>
|
|
23
|
+
</table>
|
|
24
|
+
<table>
|
|
25
|
+
<tbody>
|
|
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
|
+
</tbody>
|
|
42
|
+
</table>
|
|
43
|
+
</>
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
export const DATA_TABLE_HORIZONTAL = (
|
|
47
|
+
<>
|
|
48
|
+
<table>
|
|
49
|
+
<tbody>
|
|
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
|
+
</tbody>
|
|
63
|
+
</table>
|
|
64
|
+
<table>
|
|
65
|
+
<tbody>
|
|
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
|
+
</tbody>
|
|
79
|
+
</table>
|
|
80
|
+
</>
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
export const DATA_TABLE_SINGLE_ROW = (
|
|
84
|
+
<table>
|
|
85
|
+
<tbody>
|
|
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
|
+
</tbody>
|
|
105
|
+
</table>
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
export const DATA_TABLE_MULTI_ROW = (
|
|
109
|
+
<table>
|
|
110
|
+
<tbody>
|
|
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
|
+
</tbody>
|
|
147
|
+
</table>
|
|
148
|
+
)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export class DataTransform {
|
|
2
2
|
constructor() {
|
|
3
3
|
this.constants = {
|
|
4
|
-
errorMessageEmtpyData: 'Your data file is empty.',
|
|
4
|
+
errorMessageEmtpyData: 'Your data file is empty.',
|
|
5
5
|
errorMessageFormat: 'Your datatype is not supported.',
|
|
6
6
|
descriptionHeader: 1,
|
|
7
7
|
descriptionRoot: 2,
|
|
@@ -16,7 +16,7 @@ export class DataTransform {
|
|
|
16
16
|
// Empty data
|
|
17
17
|
if ( 0 === data.length ) {
|
|
18
18
|
errorsFound.push(this.constants.errorMessageEmptyData);
|
|
19
|
-
}
|
|
19
|
+
}
|
|
20
20
|
|
|
21
21
|
// Does it have the correct data structure?
|
|
22
22
|
if (!data.filter || data.filter(row => typeof row !== 'object').length > 0) {
|
|
@@ -153,7 +153,7 @@ export class DataTransform {
|
|
|
153
153
|
} else {
|
|
154
154
|
return undefined
|
|
155
155
|
}
|
|
156
|
-
}
|
|
156
|
+
}
|
|
157
157
|
|
|
158
158
|
return data;
|
|
159
159
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import Papa from 'papaparse';
|
|
2
|
+
|
|
3
|
+
export default async function (url) {
|
|
4
|
+
try {
|
|
5
|
+
|
|
6
|
+
// Using URL Object to get pathname without URL paramaters on regex.
|
|
7
|
+
url = new URL(url)
|
|
8
|
+
|
|
9
|
+
const path = url.pathname
|
|
10
|
+
const regex = /(?:\.([^.]+))?$/
|
|
11
|
+
const ext = (regex.exec(path)[1])
|
|
12
|
+
|
|
13
|
+
let data = []
|
|
14
|
+
|
|
15
|
+
if ('csv' === ext) {
|
|
16
|
+
data = await fetch(url.href)
|
|
17
|
+
.then(response => response.text())
|
|
18
|
+
.then(responseText => {
|
|
19
|
+
const parsedCsv = Papa.parse(responseText, {
|
|
20
|
+
header: true,
|
|
21
|
+
dynamicTyping: true,
|
|
22
|
+
skipEmptyLines: true
|
|
23
|
+
})
|
|
24
|
+
return parsedCsv.data
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if ('json' === ext) {
|
|
29
|
+
data = await fetch(url.href)
|
|
30
|
+
.then(response => response.json())
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return data;
|
|
34
|
+
} catch {
|
|
35
|
+
// If we can't parse it, still attempt to fetch it
|
|
36
|
+
try {
|
|
37
|
+
let response = await (await fetch(url)).json()
|
|
38
|
+
return response
|
|
39
|
+
} catch {
|
|
40
|
+
console.error(`Cannot parse URL: ${url}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cdc/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.22.9",
|
|
4
4
|
"description": "Core elements of the CDC Open Visualization project",
|
|
5
5
|
"author": "Daniel Immke <npm@daniel.do>",
|
|
6
6
|
"homepage": "https://github.com/CDCgov/cdc-open-viz#readme",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"react-dom": ">=16"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
+
"papaparse": "^5.3.0",
|
|
23
24
|
"prop-types": "^15.8.1",
|
|
24
25
|
"react-accessible-accordion": "^3.3.4",
|
|
25
26
|
"react-select": "^5.3.1",
|
|
@@ -29,5 +30,5 @@
|
|
|
29
30
|
"resolutions": {
|
|
30
31
|
"@types/react": "17.x"
|
|
31
32
|
},
|
|
32
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "90faf22c91ca0062432607e4599598f9e67c848a"
|
|
33
34
|
}
|