@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.
Files changed (75) hide show
  1. package/README.md +1 -1
  2. package/components/AdvancedEditor.js +52 -67
  3. package/components/ErrorBoundary.jsx +10 -11
  4. package/components/GlobalContext.jsx +2 -6
  5. package/components/LegendCircle.jsx +3 -4
  6. package/components/Loading.jsx +14 -12
  7. package/components/Waiting.jsx +14 -5
  8. package/components/elements/Button.jsx +34 -45
  9. package/components/elements/Card.jsx +1 -1
  10. package/components/inputs/InputCheckbox.jsx +32 -35
  11. package/components/inputs/InputGroup.jsx +38 -17
  12. package/components/inputs/InputSelect.jsx +27 -23
  13. package/components/inputs/InputText.jsx +9 -25
  14. package/components/inputs/InputToggle.jsx +29 -33
  15. package/components/managers/DataDesigner.jsx +87 -64
  16. package/components/ui/Accordion.jsx +18 -30
  17. package/components/ui/Icon.jsx +34 -35
  18. package/components/ui/LoadSpin.jsx +6 -11
  19. package/components/ui/Modal.jsx +40 -44
  20. package/components/ui/Overlay.jsx +12 -23
  21. package/components/ui/OverlayFrame.jsx +1 -5
  22. package/components/ui/Tooltip.jsx +8 -28
  23. package/data/colorPalettes.js +29 -266
  24. package/data/dataDesignerTables.js +107 -107
  25. package/data/themes.js +13 -13
  26. package/helpers/CoveMediaControls.js +139 -0
  27. package/helpers/DataTransform.js +92 -92
  28. package/helpers/cacheBustingString.js +3 -3
  29. package/helpers/events.js +5 -6
  30. package/helpers/fetchRemoteData.js +33 -33
  31. package/helpers/getViewport.js +15 -15
  32. package/helpers/numberFromString.js +7 -7
  33. package/helpers/updatePaletteNames.js +15 -17
  34. package/helpers/useDataVizClasses.js +38 -35
  35. package/helpers/validateFipsCodeLength.js +41 -56
  36. package/package.json +4 -2
  37. package/styles/_button-section.scss +35 -0
  38. package/styles/_data-table.scss +39 -27
  39. package/styles/_global.scss +29 -24
  40. package/styles/_mixins.scss +12 -12
  41. package/styles/_reset.scss +85 -16
  42. package/styles/_variables.scss +5 -5
  43. package/styles/base.scss +100 -48
  44. package/styles/heading-colors.scss +6 -2
  45. package/styles/loading.scss +62 -60
  46. package/styles/v2/base/_file-selector.scss +2 -2
  47. package/styles/v2/base/_general.scss +1 -1
  48. package/styles/v2/base/_reset.scss +2 -2
  49. package/styles/v2/base/index.scss +4 -4
  50. package/styles/v2/components/accordion.scss +13 -13
  51. package/styles/v2/components/button.scss +3 -3
  52. package/styles/v2/components/card.scss +1 -1
  53. package/styles/v2/components/data-designer.scss +7 -6
  54. package/styles/v2/components/editor.scss +52 -51
  55. package/styles/v2/components/guidance-block.scss +6 -6
  56. package/styles/v2/components/input/_input-check-radio.scss +7 -7
  57. package/styles/v2/components/input/_input-group.scss +2 -2
  58. package/styles/v2/components/input/_input-slider.scss +2 -3
  59. package/styles/v2/components/input/index.scss +6 -6
  60. package/styles/v2/components/loadspin.scss +1 -1
  61. package/styles/v2/components/modal.scss +2 -2
  62. package/styles/v2/components/overlay.scss +4 -4
  63. package/styles/v2/layout/_alert.scss +8 -8
  64. package/styles/v2/layout/_component.scss +1 -1
  65. package/styles/v2/layout/_data-table.scss +12 -11
  66. package/styles/v2/layout/_progression.scss +8 -6
  67. package/styles/v2/layout/index.scss +5 -5
  68. package/styles/v2/main.scss +7 -7
  69. package/styles/v2/themes/_color-definitions.scss +77 -24
  70. package/styles/v2/themes/index.scss +1 -1
  71. package/styles/v2/utils/_animations.scss +2 -2
  72. package/styles/v2/utils/_breakpoints.scss +53 -12
  73. package/styles/v2/utils/_variables.scss +5 -5
  74. package/styles/v2/utils/index.scss +8 -8
  75. package/styles/waiting.scss +22 -23
@@ -6,157 +6,157 @@ export class DataTransform {
6
6
  descriptionHeader: 1,
7
7
  descriptionRoot: 2,
8
8
  descriptionSeriesFilter: 3
9
- };
9
+ }
10
10
  }
11
11
 
12
12
  //Performs standardizations that can be completed automatically without use input
13
- autoStandardize(data){
13
+ autoStandardize(data) {
14
14
  const errorsFound = []
15
15
 
16
16
  // Empty data
17
- if ( 0 === data.length ) {
18
- errorsFound.push(this.constants.errorMessageEmptyData);
17
+ if (0 === data.length) {
18
+ errorsFound.push(this.constants.errorMessageEmptyData)
19
19
  }
20
20
 
21
21
  // Does it have the correct data structure?
22
- if (!data.filter || data.filter(row => typeof row !== 'object').length > 0) {
23
- errorsFound.push(this.constants.errorMessageFormat);
22
+ if (!data.filter || data.filter(row => typeof row !== 'object').length > 0) {
23
+ errorsFound.push(this.constants.errorMessageFormat)
24
24
  }
25
25
 
26
- if(errorsFound.length > 0) {
27
- console.error(errorsFound);
28
- return undefined;
26
+ if (errorsFound.length > 0) {
27
+ console.error(errorsFound)
28
+ return undefined
29
29
  }
30
30
 
31
31
  //Convert array of arrays, to array of objects
32
- if (data.filter(row => row.constructor !== Object).length > 0) {
33
- let standardizedData = [];
34
- for(let row = 1; row < data.length; row++){
35
- let standardizedRow = {};
32
+ if (data.filter(row => row.constructor !== Object).length > 0) {
33
+ let standardizedData = []
34
+ for (let row = 1; row < data.length; row++) {
35
+ let standardizedRow = {}
36
36
  data[row].forEach((datum, col) => {
37
- standardizedRow[data[0][col]] = datum;
38
- });
39
- standardizedData.push(standardizedRow);
37
+ standardizedRow[data[0][col]] = datum
38
+ })
39
+ standardizedData.push(standardizedRow)
40
40
  }
41
- data = standardizedData;
41
+ data = standardizedData
42
42
  }
43
43
 
44
- return data;
44
+ return data
45
45
  }
46
46
 
47
47
  //Performs standardizations based on developer provided description of the data
48
- developerStandardize(data, description){
48
+ developerStandardize(data, description) {
49
49
  //Validate the description object
50
- if(!description){
50
+ if (!description) {
51
51
  return undefined
52
52
  }
53
53
 
54
- if(description.horizontal === undefined || description.series === undefined){
54
+ if (description.horizontal === undefined || description.series === undefined) {
55
55
  return undefined
56
56
  }
57
57
 
58
- if(description.series === true && description.horizontal === false && description.singleRow === undefined){
58
+ if (description.series === true && description.horizontal === false && description.singleRow === undefined) {
59
59
  return undefined
60
60
  }
61
61
 
62
- if(description.horizontal === true){
63
- if(description.series === true) {
64
- if(!description.seriesKey){
62
+ if (description.horizontal === true) {
63
+ if (description.series === true) {
64
+ if (!description.seriesKey) {
65
65
  return undefined
66
66
  }
67
67
 
68
- let standardizedMapped = {};
69
- let standardized = [];
70
- data.forEach((row) => {
71
- let nonNumericKeys = [];
72
- Object.keys(row).forEach((key) => {
73
- if(key !== description.seriesKey && isNaN(parseFloat(row[key]))){
74
- nonNumericKeys.push(key);
68
+ let standardizedMapped = {}
69
+ let standardized = []
70
+ data.forEach(row => {
71
+ let nonNumericKeys = []
72
+ Object.keys(row).forEach(key => {
73
+ if (key !== description.seriesKey && isNaN(parseFloat(row[key]))) {
74
+ nonNumericKeys.push(key)
75
75
  }
76
- });
77
-
78
- Object.keys(row).forEach((key) => {
79
- if(key !== description.seriesKey && nonNumericKeys.indexOf(key) === -1) {
80
- let uniqueKey = key + '|' + nonNumericKeys.map((nonNumericKey) => (nonNumericKey + '=' + row[nonNumericKey]));
81
- if(!standardizedMapped[uniqueKey]){
82
- standardizedMapped[uniqueKey] = {[row[description.seriesKey]]: row[key], key};
83
- nonNumericKeys.forEach((nonNumericKey) => {
84
- standardizedMapped[uniqueKey][nonNumericKey] = row[nonNumericKey];
85
- });
76
+ })
77
+
78
+ Object.keys(row).forEach(key => {
79
+ if (key !== description.seriesKey && nonNumericKeys.indexOf(key) === -1) {
80
+ let uniqueKey = key + '|' + nonNumericKeys.map(nonNumericKey => nonNumericKey + '=' + row[nonNumericKey])
81
+ if (!standardizedMapped[uniqueKey]) {
82
+ standardizedMapped[uniqueKey] = { [row[description.seriesKey]]: row[key], key }
83
+ nonNumericKeys.forEach(nonNumericKey => {
84
+ standardizedMapped[uniqueKey][nonNumericKey] = row[nonNumericKey]
85
+ })
86
86
  }
87
- standardizedMapped[uniqueKey][row[description.seriesKey]] = row[key];
87
+ standardizedMapped[uniqueKey][row[description.seriesKey]] = row[key]
88
88
  }
89
- });
90
- });
89
+ })
90
+ })
91
91
 
92
- Object.keys(standardizedMapped).forEach((key) => {
93
- standardized.push(standardizedMapped[key]);
94
- });
92
+ Object.keys(standardizedMapped).forEach(key => {
93
+ standardized.push(standardizedMapped[key])
94
+ })
95
95
 
96
- return standardized;
96
+ return standardized
97
97
  } else {
98
- let standardized = [];
98
+ let standardized = []
99
99
 
100
- data.forEach((row) => {
101
- let nonNumericKeys = [];
102
- Object.keys(row).forEach((key) => {
103
- if(isNaN(parseFloat(row[key]))){
104
- nonNumericKeys.push(key);
100
+ data.forEach(row => {
101
+ let nonNumericKeys = []
102
+ Object.keys(row).forEach(key => {
103
+ if (isNaN(parseFloat(row[key]))) {
104
+ nonNumericKeys.push(key)
105
105
  }
106
- });
106
+ })
107
107
 
108
- Object.keys(row).forEach((key) => {
109
- if(nonNumericKeys.indexOf(key) === -1){
110
- let newRow = {key, value: row[key]};
108
+ Object.keys(row).forEach(key => {
109
+ if (nonNumericKeys.indexOf(key) === -1) {
110
+ let newRow = { key, value: row[key] }
111
111
 
112
- nonNumericKeys.forEach((nonNumericKey) => {
113
- newRow[nonNumericKey] = row[nonNumericKey];
114
- });
112
+ nonNumericKeys.forEach(nonNumericKey => {
113
+ newRow[nonNumericKey] = row[nonNumericKey]
114
+ })
115
115
 
116
- standardized.push(newRow);
116
+ standardized.push(newRow)
117
117
  }
118
- });
119
- });
118
+ })
119
+ })
120
120
 
121
- return standardized;
121
+ return standardized
122
122
  }
123
- } else if(description.series === true && description.singleRow === false){
124
- if(description.seriesKey !== undefined && description.xKey !== undefined && description.valueKey !== undefined){
125
- let standardizedMapped = {};
126
- let standardized = [];
127
-
128
- data.forEach((row) => {
129
- let extraKeys = [];
130
- let uniqueKey = row[description.xKey];
131
- Object.keys(row).forEach((key) => {
132
- if(key !== description.xKey && key !== description.seriesKey && key !== description.valueKey){
133
- uniqueKey += '|' + key + '=' + row[key];
134
- extraKeys.push(key);
123
+ } else if (description.series === true && description.singleRow === false) {
124
+ if (description.seriesKey !== undefined && description.xKey !== undefined && description.valueKey !== undefined) {
125
+ let standardizedMapped = {}
126
+ let standardized = []
127
+
128
+ data.forEach(row => {
129
+ let extraKeys = []
130
+ let uniqueKey = row[description.xKey]
131
+ Object.keys(row).forEach(key => {
132
+ if (key !== description.xKey && key !== description.seriesKey && key !== description.valueKey) {
133
+ uniqueKey += '|' + key + '=' + row[key]
134
+ extraKeys.push(key)
135
135
  }
136
- });
136
+ })
137
137
 
138
- if(standardizedMapped[uniqueKey]){
139
- standardizedMapped[uniqueKey][row[description.seriesKey]] = row[description.valueKey];
138
+ if (standardizedMapped[uniqueKey]) {
139
+ standardizedMapped[uniqueKey][row[description.seriesKey]] = row[description.valueKey]
140
140
  } else {
141
- standardizedMapped[uniqueKey] = {[description.xKey]: row[description.xKey], [row[description.seriesKey]]: row[description.valueKey]};
142
- extraKeys.forEach((key) => {
143
- standardizedMapped[uniqueKey][key] = row[key];
144
- });
141
+ standardizedMapped[uniqueKey] = { [description.xKey]: row[description.xKey], [row[description.seriesKey]]: row[description.valueKey] }
142
+ extraKeys.forEach(key => {
143
+ standardizedMapped[uniqueKey][key] = row[key]
144
+ })
145
145
  }
146
- });
146
+ })
147
147
 
148
- Object.keys(standardizedMapped).forEach((key) => {
149
- standardized.push(standardizedMapped[key]);
150
- });
148
+ Object.keys(standardizedMapped).forEach(key => {
149
+ standardized.push(standardizedMapped[key])
150
+ })
151
151
 
152
- return standardized;
152
+ return standardized
153
153
  } else {
154
154
  return undefined
155
155
  }
156
156
  }
157
157
 
158
- return data;
158
+ return data
159
159
  }
160
160
  }
161
161
 
162
- export default DataTransform;
162
+ export default DataTransform
@@ -1,5 +1,5 @@
1
1
  export default function cacheBustingString() {
2
- const round = 1000 * 60 * 15;
3
- const date = new Date();
4
- return new Date(date.getTime() - (date.getTime() % round)).toISOString();
2
+ const round = 1000 * 60 * 15
3
+ const date = new Date()
4
+ return new Date(date.getTime() - (date.getTime() % round)).toISOString()
5
5
  }
package/helpers/events.js CHANGED
@@ -1,15 +1,14 @@
1
-
2
1
  function subscribe(eventName, listener) {
3
- document.addEventListener(eventName, listener);
2
+ document.addEventListener(eventName, listener)
4
3
  }
5
4
 
6
5
  function unsubscribe(eventName, listener) {
7
- document.removeEventListener(eventName, listener);
6
+ document.removeEventListener(eventName, listener)
8
7
  }
9
8
 
10
9
  function publish(eventName, data) {
11
- const event = new CustomEvent(eventName, { detail: data });
12
- document.dispatchEvent(event);
10
+ const event = new CustomEvent(eventName, { detail: data })
11
+ document.dispatchEvent(event)
13
12
  }
14
13
 
15
- export { publish, subscribe, unsubscribe};
14
+ export { publish, subscribe, unsubscribe }
@@ -1,43 +1,43 @@
1
- import Papa from 'papaparse';
1
+ import Papa from 'papaparse'
2
2
 
3
- export default async function (url) {
4
- try {
3
+ export default async function (url, visualizationType = '') {
4
+ try {
5
+ // Using URL Object to get pathname without URL paramaters on regex.
6
+ if (visualizationType === 'map') url = decodeURI(url)
5
7
 
6
- // Using URL Object to get pathname without URL paramaters on regex.
7
- url = new URL(url)
8
+ url = new URL(url)
8
9
 
9
- const path = url.pathname
10
- const regex = /(?:\.([^.]+))?$/
11
- const ext = (regex.exec(path)[1])
10
+ const path = url.pathname
11
+ const regex = /(?:\.([^.]+))?$/
12
+ const ext = regex.exec(path)[1]
12
13
 
13
- let data = []
14
+ let data = []
14
15
 
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
- }
16
+ if ('csv' === ext) {
17
+ data = await fetch(url.href)
18
+ .then(response => response.text())
19
+ .then(responseText => {
20
+ const parsedCsv = Papa.parse(responseText, {
21
+ header: true,
22
+ dynamicTyping: true,
23
+ skipEmptyLines: true
24
+ })
25
+ return parsedCsv.data
26
+ })
27
+ }
27
28
 
28
- if ('json' === ext) {
29
- data = await fetch(url.href)
30
- .then(response => response.json())
31
- }
29
+ if ('json' === ext) {
30
+ data = await fetch(url.href).then(response => response.json())
31
+ }
32
32
 
33
- return data;
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
34
39
  } 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
- }
40
+ console.error(`Cannot parse URL: ${url}`)
42
41
  }
42
+ }
43
43
  }
@@ -1,21 +1,21 @@
1
1
  export default function getViewport(size) {
2
- let result = 'lg'
2
+ let result = 'lg'
3
3
 
4
- const viewports = {
5
- "lg": 1200,
6
- "md": 992,
7
- "sm": 768,
8
- "xs": 576,
9
- "xxs": 350
10
- }
4
+ const viewports = {
5
+ lg: 1200,
6
+ md: 992,
7
+ sm: 768,
8
+ xs: 576,
9
+ xxs: 350
10
+ }
11
11
 
12
- if(size > 1200) return result
12
+ if (size > 1200) return result
13
13
 
14
- for(let viewport in viewports) {
15
- if(size <= viewports[viewport]) {
16
- result = viewport
17
- }
14
+ for (let viewport in viewports) {
15
+ if (size <= viewports[viewport]) {
16
+ result = viewport
18
17
  }
18
+ }
19
19
 
20
- return result
21
- }
20
+ return result
21
+ }
@@ -1,11 +1,11 @@
1
1
  export default function numberFromString(value = '', state = null) {
2
- // Only do this to values that are ONLY numbers - without this parseFloat strips all the other text
3
- if (typeof value === 'string' && state?.legend?.type === 'category') return value;
2
+ // Only do this to values that are ONLY numbers - without this parseFloat strips all the other text
3
+ if (typeof value === 'string' && state?.legend?.type === 'category') return value
4
4
 
5
- let nonNumeric = /[^\d.-]/g
6
- if( false === Number.isNaN( parseFloat(value) ) && null === String(value).match(nonNumeric) ) {
7
- return parseFloat(value)
8
- }
5
+ let nonNumeric = /[^\d.-]/g
6
+ if (false === Number.isNaN(parseFloat(value)) && null === String(value).match(nonNumeric)) {
7
+ return parseFloat(value)
8
+ }
9
9
 
10
- return value
10
+ return value
11
11
  }
@@ -1,18 +1,16 @@
1
+ export function updatePaletteNames(colorPalettes) {
2
+ // this function adds REVERSE keyword to each palette
3
+ delete colorPalettes.qualitative9 // delete palette before reversing
4
+ let palettereversed = {}
5
+ for (const [paletteName, hexCodeArr] of Object.entries(colorPalettes)) {
6
+ const paletteStr = String(paletteName)
1
7
 
2
-
3
- export function updatePaletteNames (colorPalettes){
4
- // this function adds REVERSE keyword to each palette
5
- delete colorPalettes.qualitative9 // delete palette before reversing
6
- let palettereversed={}
7
- for (const [paletteName, hexCodeArr] of Object.entries(colorPalettes)) {
8
- const paletteStr = String(paletteName);
9
-
10
- if (!paletteStr.endsWith('reverse') ){
11
- let palette = paletteStr.concat('reverse'); // add to the end of the string "reverse"
12
- palettereversed[palette] = [...hexCodeArr].reverse(); // reverses arrays elements and create new keys on object
13
- }else{
14
- palettereversed = {...colorPalettes}
15
- }
16
- }
17
- return {...palettereversed,...colorPalettes}
18
- }
8
+ if (!paletteStr.endsWith('reverse')) {
9
+ let palette = paletteStr.concat('reverse') // add to the end of the string "reverse"
10
+ palettereversed[palette] = [...hexCodeArr].reverse() // reverses arrays elements and create new keys on object
11
+ } else {
12
+ palettereversed = { ...colorPalettes }
13
+ }
14
+ }
15
+ return { ...palettereversed, ...colorPalettes }
16
+ }
@@ -1,37 +1,40 @@
1
1
  export default function useDataVizClasses(config) {
2
-
3
- let lineDatapointClass = ''
4
- let barBorderClass = ''
5
-
6
- if (config.lineDatapointStyle === "hover") { lineDatapointClass = ' chart-line--hover' }
7
- if (config.lineDatapointStyle === "always show") { lineDatapointClass = ' chart-line--always' }
8
- if (config.barHasBorder === "false") { barBorderClass = ' chart-bar--no-border' }
9
-
10
-
11
- let innerContainerClasses = ['cove-component__inner']
12
- let contentClasses = ['cove-component__content'];
13
-
14
- config.title && innerContainerClasses.push('component--has-title')
15
- config.subtext && innerContainerClasses.push('component--has-subtext')
16
- config.biteStyle && innerContainerClasses.push(`bite__style--${config.biteStyle}`)
17
- config.general?.isCompactStyle && innerContainerClasses.push(`component--isCompactStyle`)
18
-
19
- !config.visual?.border && contentClasses.push('no-borders');
20
- config.visualizationType === 'Spark Line' && contentClasses.push('sparkline')
21
- config.visual?.borderColorTheme && contentClasses.push('component--has-borderColorTheme');
22
- config.visual?.accent && contentClasses.push('component--has-accent');
23
- config.visual?.background && contentClasses.push('component--has-background');
24
- config.visual?.hideBackgroundColor && contentClasses.push('component--hideBackgroundColor');
25
-
26
- // ! these two will be retired.
27
- config.shadow && innerContainerClasses.push('shadow')
28
- config?.visual?.roundedBorders && innerContainerClasses.push('bite--has-rounded-borders')
29
-
30
- let sparkLineStyles = {
31
- width: '100%',
32
- height: '100px',
33
- }
34
-
35
-
36
- return { innerContainerClasses, contentClasses, barBorderClass, lineDatapointClass, sparkLineStyles};
2
+ let lineDatapointClass = ''
3
+ let barBorderClass = ''
4
+
5
+ if (config.lineDatapointStyle === 'hover') {
6
+ lineDatapointClass = ' chart-line--hover'
7
+ }
8
+ if (config.lineDatapointStyle === 'always show') {
9
+ lineDatapointClass = ' chart-line--always'
10
+ }
11
+ if (config.barHasBorder === 'false') {
12
+ barBorderClass = ' chart-bar--no-border'
13
+ }
14
+
15
+ let innerContainerClasses = ['cove-component__inner']
16
+ let contentClasses = ['cove-component__content']
17
+
18
+ config.title && innerContainerClasses.push('component--has-title')
19
+ config.subtext && innerContainerClasses.push('component--has-subtext')
20
+ config.biteStyle && innerContainerClasses.push(`bite__style--${config.biteStyle}`)
21
+ config.general?.isCompactStyle && innerContainerClasses.push(`component--isCompactStyle`)
22
+
23
+ !config.visual?.border && contentClasses.push('no-borders')
24
+ config.visualizationType === 'Spark Line' && contentClasses.push('sparkline')
25
+ config.visual?.borderColorTheme && contentClasses.push('component--has-borderColorTheme')
26
+ config.visual?.accent && contentClasses.push('component--has-accent')
27
+ config.visual?.background && contentClasses.push('component--has-background')
28
+ config.visual?.hideBackgroundColor && contentClasses.push('component--hideBackgroundColor')
29
+
30
+ // ! these two will be retired.
31
+ config.shadow && innerContainerClasses.push('shadow')
32
+ config?.visual?.roundedBorders && innerContainerClasses.push('bite--has-rounded-borders')
33
+
34
+ let sparkLineStyles = {
35
+ width: '100%',
36
+ height: '100px'
37
+ }
38
+
39
+ return { innerContainerClasses, contentClasses, barBorderClass, lineDatapointClass, sparkLineStyles }
37
40
  }
@@ -1,67 +1,52 @@
1
1
  /**
2
2
  * validateFipsCodeLength
3
- *
3
+ *
4
4
  * When stateOrData is an object...
5
- * This is used for validating maps fips codes during runtime where we
5
+ * This is used for validating maps fips codes during runtime where we
6
6
  * In this scenario a user is able to choose the column their Fips Codes are in.
7
- *
7
+ *
8
8
  * When stateOrData is an array...
9
9
  * The user hasn't chose which column has their FIPS codes in it. We still
10
10
  * want to present the FIPS Codes in a friendly format so we attempt to add leading zeros.
11
- *
12
- * @param {object|array} stateOrData
11
+ *
12
+ * @param {object|array} stateOrData
13
13
  * @returns {object|array} stateOrData
14
14
  */
15
15
  export default function validateFipsCodeLength(stateOrData) {
16
-
17
- // FIPS are within obj.
18
- if (!Array.isArray(stateOrData)) {
19
- if (stateOrData.general.geoType === 'us-county' || stateOrData.general.geoType === 'single-state' || stateOrData.general.geoType === 'us' && stateOrData?.data) {
20
-
21
- stateOrData?.data.forEach(dataPiece => {
22
- if (dataPiece[stateOrData.columns.geo.name]) {
23
-
24
- if (!isNaN(parseInt(dataPiece[stateOrData.columns.geo.name])) && dataPiece[stateOrData.columns.geo.name].length === 4) {
25
- dataPiece[stateOrData.columns.geo.name] = 0 + dataPiece[stateOrData.columns.geo.name]
26
- }
27
- dataPiece[stateOrData.columns.geo.name] = dataPiece[stateOrData.columns.geo.name].toString()
28
- }
29
- })
30
- }
31
- }
32
-
33
- // Only includes data - get column name from somewhere else
34
- if (Array.isArray(stateOrData)) {
35
-
36
- let columns = Object.keys(stateOrData[0])
37
-
38
- let potentialColumnNames = [
39
- 'fips',
40
- 'FIPS',
41
- 'fips codes',
42
- 'FIPS CODES',
43
- 'Fips Codes',
44
- 'fips Codes',
45
- 'Fips codes',
46
- 'FIPS Codes'
47
- ]
48
-
49
- const fipsCol = columns.filter(columnName => potentialColumnNames.includes(columnName));
50
-
51
- if (!fipsCol.length) return; // no column name to reference, leave the fips alone.
52
-
53
- stateOrData?.forEach(dataPiece => {
54
-
55
- if (dataPiece[fipsCol]) {
56
-
57
- // specific to county fips codes.
58
- if (!isNaN(parseInt(dataPiece[fipsCol])) && dataPiece[fipsCol].length === 4) {
59
- dataPiece[fipsCol] = 0 + dataPiece[fipsCol]
60
- }
61
- dataPiece[fipsCol] = dataPiece[fipsCol].toString()
62
- }
63
- })
64
- }
65
-
66
- return stateOrData;
16
+ // FIPS are within obj.
17
+ if (!Array.isArray(stateOrData)) {
18
+ if (stateOrData.general.geoType === 'us-county' || stateOrData.general.geoType === 'single-state' || (stateOrData.general.geoType === 'us' && stateOrData?.data)) {
19
+ stateOrData?.data.forEach(dataPiece => {
20
+ if (dataPiece[stateOrData.columns.geo.name]) {
21
+ if (!isNaN(parseInt(dataPiece[stateOrData.columns.geo.name])) && dataPiece[stateOrData.columns.geo.name].length === 4) {
22
+ dataPiece[stateOrData.columns.geo.name] = 0 + dataPiece[stateOrData.columns.geo.name]
23
+ }
24
+ dataPiece[stateOrData.columns.geo.name] = dataPiece[stateOrData.columns.geo.name].toString()
25
+ }
26
+ })
27
+ }
28
+ }
29
+
30
+ // Only includes data - get column name from somewhere else
31
+ if (Array.isArray(stateOrData)) {
32
+ let columns = Object.keys(stateOrData[0])
33
+
34
+ let potentialColumnNames = ['fips', 'FIPS', 'fips codes', 'FIPS CODES', 'Fips Codes', 'fips Codes', 'Fips codes', 'FIPS Codes']
35
+
36
+ const fipsCol = columns.filter(columnName => potentialColumnNames.includes(columnName))
37
+
38
+ if (!fipsCol.length) return // no column name to reference, leave the fips alone.
39
+
40
+ stateOrData?.forEach(dataPiece => {
41
+ if (dataPiece[fipsCol]) {
42
+ // specific to county fips codes.
43
+ if (!isNaN(parseInt(dataPiece[fipsCol])) && dataPiece[fipsCol].length === 4) {
44
+ dataPiece[fipsCol] = 0 + dataPiece[fipsCol]
45
+ }
46
+ dataPiece[fipsCol] = dataPiece[fipsCol].toString()
47
+ }
48
+ })
49
+ }
50
+
51
+ return stateOrData
67
52
  }